diff --git a/.gitignore b/.gitignore index 0f1313a..31fcefd 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,4 @@ INSTALL src/bin/clouseaud src/bin/clouseau_client src/scripts/clouseau_start +build/ diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index ee22837..0000000 --- a/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -Tom Hacohen diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..f08977e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 2.8.1) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") + +project(CLOUSEAU) + +find_package(Efl REQUIRED) +find_package(Eina REQUIRED) +find_package(Eet REQUIRED) +find_package(Efreet REQUIRED) +find_package(Eolian REQUIRED) +find_package(Eo REQUIRED) +find_package(Elementary REQUIRED) +find_package(Ecore REQUIRED) +find_package(Evas REQUIRED) +find_package(Edebug REQUIRED) + +add_subdirectory(src/bin) diff --git a/COPYING b/COPYING deleted file mode 100644 index 189a6b6..0000000 --- a/COPYING +++ /dev/null @@ -1,25 +0,0 @@ -Copyright notice for Clouseau: - -Copyright (C) 2000-2011 Tom Hacohen and various contributors (see AUTHORS) - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/COPYING.icons b/COPYING.icons deleted file mode 100644 index 220881d..0000000 --- a/COPYING.icons +++ /dev/null @@ -1 +0,0 @@ -The icons in this repository are herefore released into the Public Domain. diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index e69de29..0000000 diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index f8558db..0000000 --- a/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ - -MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess \ - config.h.in config.sub configure install-sh \ - depcomp libtool missing - -EXTRA_DIST = README AUTHORS COPYING autogen.sh - -SUBDIRS = src data - -ACLOCAL_AMFLAGS = -I m4 - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = clouseau.pc diff --git a/NEWS b/NEWS deleted file mode 100644 index e69de29..0000000 diff --git a/README b/README deleted file mode 100644 index 9180b7d..0000000 --- a/README +++ /dev/null @@ -1,19 +0,0 @@ -An UI inspection tool for the EFL. This tool lets you inspect UI elements and get a lot of their properties, e.g position, size and weight. - -Clouseau consists of a client (clouseau_client) and launcher (clouseau_server). This design means we can: -1. Run the application we are debugging on one device and the clouseau_client itself on another. -2. Run the application we are debugging with a different environment/theme/etc compared to the clouseau client. - -Clouseau provides a wrapper script that automatically launches the application with clouseau support, and launches the client, the script is called "clouseau". - -Usage: -1. Using the wrapper script: - "clouseau elementary_test" or "clouseau elementary_test Entry". -2. Using the split client/server approach (different machines/environments/setups): - "clouseau_start elementary_test" and then "clouseau_client" - As mentioned above, this is done over the network, so it can be run from different machines - -Using the clouseau client: -When the client opens you'll be asked to enter the server's IP address. That's the IP address of where you ran clouseau_start from. When in doubt, just use the default, 127.0.0.1. -Then press "Ok" to connect to the server, and the rest should be fairly straightforward. -TBD diff --git a/TODO b/TODO deleted file mode 100644 index e0a5356..0000000 --- a/TODO +++ /dev/null @@ -1,18 +0,0 @@ -* Make it possible to hide rects? or show only elm-widgets? or something similar? too much clutter atm. -* Add filter? -* Make it an elm module (or setting an env var without a module?) so I'll be able to remotely connect to elm apps. -* Split UI and actual program code (better to do the previous bullet first). -* Add "grab screenshot" button. -* Add a clipping range rectangle. -* Add special per object info, for example edje part names? -* When items are coloured, show the exact colour using a rect? -* Handle map/proxy -* add a way to filter object with some regexp on the name and also finding a specific object according to name. -* Add general info like hinting/whole interface scale/finger size and etc. - -* Things to show per-object - * clipping info. - * callback list? - -* Fix has_focus. -* Hook on feed events or something and let us see who gets what? diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index cf63ef1..0000000 --- a/autogen.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -rm -rf autom4te.cache -rm -f aclocal.m4 ltmain.sh - -echo "Running aclocal..." ; aclocal -I m4 $ACLOCAL_FLAGS || exit 1 -echo "Running autoheader..." ; autoheader || exit 1 -echo "Running autoconf..." ; autoconf || exit 1 -echo "Running libtoolize..." ; (libtoolize --copy --automake || glibtoolize --automake) || exit 1 -echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1 - -if [ -z "$NOCONFIGURE" ]; then - ./configure "$@" -fi diff --git a/clouseau.pc.in b/clouseau.pc.in deleted file mode 100644 index 841af96..0000000 --- a/clouseau.pc.in +++ /dev/null @@ -1,10 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: clouseau -Description: Clouseau lib for elm debug -Version: @VERSION@ -Libs: -L${libdir} -llibclouseau -Cflags: -I${includedir}/clouseau-@VMAJ@ diff --git a/cmake/Modules/FindFfi.cmake b/cmake/Modules/FindFfi.cmake new file mode 100644 index 0000000..c9224d1 --- /dev/null +++ b/cmake/Modules/FindFfi.cmake @@ -0,0 +1,40 @@ +# - Try to find ffi +# Once done this will define +# FFI_FOUND - System has ffi +# FFI_INCLUDE_DIRS - The ffi include directories +# FFI_LIBRARIES - The libraries needed to use ffi +# FFI_LDFLAGS_OTHER - Other LDFLAGS needed te use ffi. +# FFI_DEFINITIONS - Compiler switches required for using ffi + +find_package(PkgConfig) +if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1") + # "QUIET" was introduced in 2.8.2 + set(_QUIET QUIET) +endif () +pkg_check_modules(PC_LIBFFI ${_QUIET} libffi) +#set(FFI_DEFINITIONS ${PC_LIBFFI_CFLAGS_OTHER}) +#set(FFI_LDFLAGS_OTHER ${PC_LIBFFI_LDFLAGS_OTHER}) + +# before verison 2.8.11 variable CMAKE_LIBRARY_ARCHITECTURE wasn't automatically added to search path +if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_LESS "2.8.11") + set(FIND_PATH_HINTS ${PC_LIBFFI_INCLUDEDIR}/${CMAKE_LIBRARY_ARCHITECTURE}) +endif () + +find_path(FFI_INCLUDE_DIR ffi.h + HINTS ${PC_LIBFFI_INCLUDEDIR} ${PC_LIBFFI_INCLUDE_DIRS} + ${FIND_PATH_HINTS} + ) + +find_library(FFI_LIBRARY NAMES ffi libffi + HINTS ${PC_LIBFFI_LIBDIR} ${PC_LIBFFI_LIBRARY_DIRS}) + +set(FFI_INCLUDE_DIRS ${FFI_INCLUDE_DIR}) +set(FFI_LIBRARIES ${FFI_LIBRARY}) + +#include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set EINA_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(ffi DEFAULT_MSG + FFI_LIBRARY) + +mark_as_advanced(FFI_INCLUDE_DIRS FFI_LIBRARY) diff --git a/configure.ac b/configure.ac deleted file mode 100644 index b9e0e88..0000000 --- a/configure.ac +++ /dev/null @@ -1,120 +0,0 @@ -##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## -##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## -m4_define([v_maj], [0]) -m4_define([v_min], [2]) -m4_define([v_mic], [0]) -m4_define([v_rev], m4_esyscmd([(git rev-list --count HEAD 2>/dev/null || echo 0) | tr -d '\n']))dnl -##-- When released, remove the dnl on the below line -dnl m4_undefine([v_rev]) -##-- When doing snapshots - change soname. remove dnl on below line -dnl m4_define([relname], [ver-pre-svn-07]) -dnl m4_define([v_rel], [-release relname]) -##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## -m4_ifdef([v_rev], [m4_define([v_ver], [v_maj.v_min.v_mic.v_rev])], [m4_define([v_ver], [v_maj.v_min.v_mic])]) -m4_define([lt_cur], m4_eval(v_maj + v_min)) -m4_define([lt_rev], v_mic) -m4_define([lt_age], v_min) -##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## -##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## - -AC_INIT(clouseau, [v_ver], tom@stosb.com) -AC_PREREQ(2.52) -AC_CONFIG_SRCDIR(configure.ac) -AC_CONFIG_MACRO_DIR([m4]) -AC_CANONICAL_BUILD -AC_CANONICAL_HOST -AC_CANONICAL_TARGET - -AM_INIT_AUTOMAKE(1.6 dist-bzip2) -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) -AC_CONFIG_HEADERS(config.h) - -AC_GNU_SOURCE -AC_PROG_LIBTOOL - -##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## -##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## -m4_ifdef([v_rev], , [m4_define([v_rev], [0])]) -m4_ifdef([v_rel], , [m4_define([v_rel], [])]) -AC_DEFINE_UNQUOTED(VMAJ, [v_maj], [Major version]) -AC_DEFINE_UNQUOTED(VMIN, [v_min], [Minor version]) -AC_DEFINE_UNQUOTED(VMIC, [v_mic], [Micro version]) -AC_DEFINE_UNQUOTED(VREV, [v_rev], [Revison]) -version_info="lt_cur:lt_rev:lt_age" -release_info="v_rel" -AC_SUBST(version_info) -AC_SUBST(release_info) -##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## -##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## -VMAJ=v_maj -AC_SUBST(VMAJ) - -PKG_CHECK_MODULES([EFL], - [ - eina >= 1.7.99 - eet >= 1.7.99 - elementary >= 1.7.99 - evas >= 1.7.99 - ecore >= 1.7.99 - ecore-ipc >= 1.7.99 - edje >= 1.7.99 - eo >= 1.7.99 - ] - ) - -want_systemd="yes" -EFL_ENABLE_BETA_API_SUPPORT - -AC_DEFINE([EFL_EO_API_SUPPORT], [1], [Enable access to unstable EFL EO API.]) -AC_ARG_ENABLE([systemd], - [AC_HELP_STRING([--disable-systemd], - [disable systemd integration. @<:@default=enabled@:>@])], - [ - if test "x${enableval}" = "xyes" ; then - want_systemd="yes" - else - want_systemd="no" - fi - ]) - -if test "x${want_systemd}" = "xyes"; then - # Detect systemd user session directory properly - EFL_PKG_CHECK_VAR([USER_SESSION_DIR], [systemd], [systemduserunitdir], - [have_systemd_user_session="yes"], [have_systemd_user_session="no"]) - AC_SUBST([USER_SESSION_DIR]) -fi -AM_CONDITIONAL([HAVE_SYSTEMD_USER_SESSION], [test "x${have_systemd_user_session}" = "xyes"]) - -### Checks for linker characteristics -lt_enable_auto_import="" -case "${host_os}" in - mingw*) - lt_enable_auto_import="-Wl,--enable-auto-import" - ;; -esac -case "$host_vendor" in - ps3*) - # Escape had already been checked to exist - ;; -esac -AC_SUBST([lt_enable_auto_import]) - -EFL_ATTRIBUTE_UNUSED - -AC_CHECK_LIB(dl,dlopen) -AC_CHECK_FUNCS(dlopen dlerror) - -AC_CONFIG_FILES([ -clouseau.pc -Makefile -src/Makefile -src/lib/Makefile -src/bin/Makefile -src/scripts/Makefile -src/modules/Makefile -data/Makefile -data/images/Makefile -data/units/Makefile -]) - -AC_OUTPUT diff --git a/data/Makefile.am b/data/Makefile.am deleted file mode 100644 index 984455c..0000000 --- a/data/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -MAINTAINERCLEANFILES = Makefile.in -SUBDIRS = images units diff --git a/data/images/Makefile.am b/data/images/Makefile.am deleted file mode 100644 index f9d5426..0000000 --- a/data/images/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -MAINTAINERCLEANFILES = Makefile.in - -filesdir = $(datadir)/clouseau/images -files_DATA = \ - clipper.png \ - hidden.png \ - background.png \ - screenshot-missing.png \ - show-screenshot.png \ - take-screenshot.png - -EXTRA_DIST = $(files_DATA) diff --git a/data/images/background.png b/data/images/background.png deleted file mode 100644 index 7c0d7d1..0000000 Binary files a/data/images/background.png and /dev/null differ diff --git a/data/images/clipper.png b/data/images/clipper.png deleted file mode 100644 index 217663b..0000000 Binary files a/data/images/clipper.png and /dev/null differ diff --git a/data/images/hidden.png b/data/images/hidden.png deleted file mode 100644 index 2ac5747..0000000 Binary files a/data/images/hidden.png and /dev/null differ diff --git a/data/images/screenshot-missing.png b/data/images/screenshot-missing.png deleted file mode 100644 index 27fccd5..0000000 Binary files a/data/images/screenshot-missing.png and /dev/null differ diff --git a/data/images/take-screenshot.png b/data/images/take-screenshot.png deleted file mode 100644 index ffbffc7..0000000 Binary files a/data/images/take-screenshot.png and /dev/null differ diff --git a/data/units/Makefile.am b/data/units/Makefile.am deleted file mode 100644 index e4e9ffd..0000000 --- a/data/units/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -AUTOMAKE_OPTIONS = 1.4 foreign -MAINTAINERCLEANFILES = Makefile.in - -UNITS_FILES=clouseaud.service clouseaud.socket - -if HAVE_SYSTEMD_USER_SESSION -unitsdir = $(USER_SESSION_DIR) -units_DATA = $(UNITS_FILES) -endif - -EXTRA_DIST = $(UNITS_FILES) diff --git a/data/units/clouseaud.service b/data/units/clouseaud.service deleted file mode 100644 index c071126..0000000 --- a/data/units/clouseaud.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=Clouseau system service -Requires=xorg.target -After=xorg.target - -[Service] -ExecStart=/usr/bin/clouseaud - -[Install] -Also=clouseaud.socket diff --git a/data/units/clouseaud.socket b/data/units/clouseaud.socket deleted file mode 100644 index adfbec7..0000000 --- a/data/units/clouseaud.socket +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -Description=Clouseau Service Sockets - -[Socket] -ListenStream=22522 - -[Install] -WantedBy=sockets.target diff --git a/m4/A b/m4/A deleted file mode 100644 index e69de29..0000000 diff --git a/m4/efl_attribute.m4 b/m4/efl_attribute.m4 deleted file mode 100644 index 78bff15..0000000 --- a/m4/efl_attribute.m4 +++ /dev/null @@ -1,56 +0,0 @@ -dnl Copyright (C) 2011 Vincent Torri -dnl That code is public domain and can be freely used or copied. - -dnl Macros for checking if the compiler supports some __attribute__ uses - -dnl Usage: EFL_ATTRIBUTE_UNUSED -dnl call AC_DEFINE for __UNUSED__ if __attribute__((unused)) is available - -AC_DEFUN([EFL_ATTRIBUTE_UNUSED], -[ -AC_MSG_CHECKING([for __attribute__ ((unused))]) -AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[ -void foo(int x __attribute__ ((unused))) {} - ]], - [[ - ]])], - [have_attribute_unused="yes"], - [have_attribute_unused="no"]) -AC_MSG_RESULT([${have_attribute_unused}]) - -if test "x${have_attribute_unused}" = "xyes" ; then - AC_DEFINE([__UNUSED__], [__attribute__ ((unused))], [Macro declaring a function argument to be unused.]) -else - AC_DEFINE([__UNUSED__], [], [__attribute__ ((unused)) is not supported.]) -fi -]) - -dnl Usage: EFL_ATTRIBUTE_VECTOR -dnl call AC_DEFINE for HAVE_GCC_ATTRIBUTE_VECTOR if __attribute__((vector)) is available - -AC_DEFUN([EFL_ATTRIBUTE_VECTOR], -[ -AC_MSG_CHECKING([for __attribute__ ((vector))]) -AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[ -typedef int v4si __attribute__ ((vector_size (16))); - ]], - [[ -if (sizeof(v4si) == 16) - return 0; -else - return -1; - ]])], - [have_attribute_vector="yes"], - [have_attribute_vector="no"]) -AC_MSG_RESULT([${have_attribute_vector}]) - -if test "x${have_attribute_vector}" = "xyes" ; then - AC_DEFINE([HAVE_GCC_ATTRIBUTE_VECTOR], [1], [Define to 1 if your compiler supports __attribute__ ((vector)).]) -fi -]) - -dnl End of efl_attribute.m4 diff --git a/m4/efl_beta.m4 b/m4/efl_beta.m4 deleted file mode 100644 index c804729..0000000 --- a/m4/efl_beta.m4 +++ /dev/null @@ -1,5 +0,0 @@ -dnl use: EFL_ENABLE_BETA_API_SUPPORT -AC_DEFUN([EFL_ENABLE_BETA_API_SUPPORT], -[ - AC_DEFINE([EFL_BETA_API_SUPPORT], [1], [Enable access to unstable EFL API that are still in beta]) -]) diff --git a/m4/pkg_var.m4 b/m4/pkg_var.m4 deleted file mode 100644 index 3d0a309..0000000 --- a/m4/pkg_var.m4 +++ /dev/null @@ -1,14 +0,0 @@ -# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, -# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# ------------------------------------------- -# Retrieves the value of the pkg-config variable for the given module. -AC_DEFUN([EFL_PKG_CHECK_VAR], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl -AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl - -_PKG_CONFIG([$1], [variable="][$3]["], [$2]) -AS_VAR_COPY([$1], [pkg_cv_][$1]) - -AS_VAR_IF([$1], [""], [$5], [$4])dnl -])# PKG_CHECK_VAR - diff --git a/make.sh b/make.sh deleted file mode 100755 index d1f4e60..0000000 --- a/make.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -gcc -Wall -Wextra -fPIC -rdynamic -g3 -O0 -c libclouseau.c `pkg-config --libs --cflags elementary ecore evas` -gcc -g3 -O0 -shared -Wl,-soname,libclouseau.so.1 -o libclouseau.so.1.0.1 libclouseau.o -lc -ldl `pkg-config --libs --cflags elementary` - diff --git a/src/Makefile.am b/src/Makefile.am deleted file mode 100644 index d265b83..0000000 --- a/src/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ - -MAINTAINERCLEANFILES = Makefile.in - -SUBDIRS = lib bin scripts modules diff --git a/src/bin/CMakeLists.txt b/src/bin/CMakeLists.txt new file mode 100644 index 0000000..7a649dd --- /dev/null +++ b/src/bin/CMakeLists.txt @@ -0,0 +1,43 @@ +set(CMAKE_BUILD_TYPE Debug) + +LIST(APPEND SOURCES clouseau_client.c gui.c) + +STRING(REGEX REPLACE "\n" "" EOLIAN_EO_DIR ${EOLIAN_EO_DIR}) +STRING(REGEX REPLACE " " "" EOLIAN_EO_DIR ${EOLIAN_EO_DIR}) +add_definitions(${CLI_COMMON_DEFINITIONS} -DEFL_EO_API_SUPPORT + -DEOLIAN_EO_DIR="${EOLIAN_EO_DIR}" -DGUI_IMAGES_PATH="${CMAKE_HOME_DIRECTORY}/data/images") + +link_directories (${PC_LIBELEMENTARY_LIBRARY_DIRS}) + +include_directories( + ${ELEMENTARY_INCLUDE_DIRS} + ${EINA_INCLUDE_DIRS} + ${EET_INCLUDE_DIRS} + ${EFREET_INCLUDE_DIRS} + ${EO_INCLUDE_DIRS} + ${EOLIAN_INCLUDE_DIRS} + ${ECORE_INCLUDE_DIRS} + ${EVAS_INCLUDE_DIRS} + ${EDEBUG_INCLUDE_DIRS} + ) + +set(EOLIAN_INCLUDE_FLAG -I \"${EOLIAN_EO_DIR}/eo-1\" -I${CMAKE_CURRENT_SOURCE_DIR}) + +add_executable(clouseau_client ${SOURCES}) + +target_link_libraries(clouseau_client + pthread + ${EFL_LIBRARIES} + ${ELEMENTARY_LIBRARIES} + ${EINA_LIBRARIES} + ${EET_LIBRARIES} + ${EFREET_LIBRARIES} + ${EO_LIBRARIES} + ${EOLIAN_LIBRARIES} + ${ECORE_LIBRARIES} + ${EVAS_LIBRARIES} + ${EDEBUG_LIBRARIES} + ecore_file + ) + +install(TARGETS clouseau_client DESTINATION bin) diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am deleted file mode 100644 index 8ed761a..0000000 --- a/src/bin/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ -MAINTAINERCLEANFILES = Makefile.in - -bin_PROGRAMS = clouseaud clouseau_client - -clouseaud_SOURCES = clouseaud.c -clouseau_client_SOURCES = \ - clouseau_client.c \ - client/cfg.c \ - client/config_dialog.c - -AM_CPPFLAGS = \ --I$(top_srcdir)/src/lib \ --I$(top_srcdir)/src/include \ --I$(top_builddir)/src/include \ --DPACKAGE_BIN_DIR=\"$(bindir)\" \ --DPACKAGE_LIB_DIR=\"$(libdir)\" \ --DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ -@EFL_CFLAGS@ - -clouseaud_LDADD = $(top_builddir)/src/lib/libclouseau.la @EFL_LIBS@ -clouseau_client_LDADD = $(top_builddir)/src/lib/libclouseau.la @EFL_LIBS@ diff --git a/src/bin/client/cfg.c b/src/bin/client/cfg.c deleted file mode 100644 index 97f4b2f..0000000 --- a/src/bin/client/cfg.c +++ /dev/null @@ -1,147 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include - -#include "cfg.h" -#include "Clouseau.h" - -Clouseau_Cfg *_clouseau_cfg = NULL; -static Eet_Data_Descriptor * _clouseau_cfg_descriptor; -#define _CONFIG_ENTRY "config" - -static char *config_file = NULL; - -static void -_clouseau_cfg_descriptor_init(void) -{ - Eet_Data_Descriptor_Class eddc; - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Clouseau_Cfg); - _clouseau_cfg_descriptor = eet_data_descriptor_stream_new(&eddc); - -#define CFG_ADD_BASIC(member, eet_type)\ - EET_DATA_DESCRIPTOR_ADD_BASIC\ - (_clouseau_cfg_descriptor, Clouseau_Cfg, # member, member, eet_type) - - CFG_ADD_BASIC(version, EET_T_UINT); - CFG_ADD_BASIC(show_hidden, EET_T_UCHAR); - CFG_ADD_BASIC(show_clippers, EET_T_UCHAR); - CFG_ADD_BASIC(show_elm_only, EET_T_UCHAR); - -#undef CFG_ADD_BASIC -} - -static void -_clouseau_cfg_descriptor_shutdown(void) -{ - eet_data_descriptor_free(_clouseau_cfg_descriptor); -} - -void -clouseau_cfg_shutdown(void) -{ - if (config_file) - free(config_file); - - _clouseau_cfg_descriptor_shutdown(); - - eet_shutdown(); - efreet_shutdown(); -} - -void -clouseau_cfg_init(const char *file) -{ - const char *ext = ".cfg"; - const char *path; - size_t len; - - efreet_init(); - eet_init(); - - path = efreet_config_home_get(); - if (!path || !file) - return; - - if (config_file) - free(config_file); - - len = strlen(path) + strlen(file) + strlen(ext) + 1; /* +1 for '/' */ - - config_file = malloc(len + 1); - snprintf(config_file, len + 1, "%s/%s%s", path, file, ext); - - _clouseau_cfg_descriptor_init(); -} - -static Clouseau_Cfg * -_clouseau_cfg_new(void) -{ - Clouseau_Cfg *ret; - ret = calloc(1, sizeof(*ret)); - - ret->version = _CLOUSEAU_CFG_VERSION; - /* Default values */ - ret->show_elm_only = EINA_TRUE; - ret->show_clippers = EINA_TRUE; - ret->show_hidden = EINA_TRUE; - - return ret; -} - -/* Return false on error. */ -Eina_Bool -clouseau_cfg_load(void) -{ - Eet_File *ef; - - if (!config_file) - goto end; - - ef = eet_open(config_file, EET_FILE_MODE_READ); - if (!ef) - { - /* FIXME Info message? create new config? */ - goto end; - } - - _clouseau_cfg = eet_data_read(ef, _clouseau_cfg_descriptor, _CONFIG_ENTRY); - -end: - if (!_clouseau_cfg) - { - _clouseau_cfg = _clouseau_cfg_new(); - } - - eet_close(ef); - return EINA_TRUE; -} - -/* Return false on error. */ -Eina_Bool -clouseau_cfg_save(void) -{ - Eet_File *ef; - Eina_Bool ret; - - if (!config_file) - return EINA_FALSE; - - - ef = eet_open(config_file, EET_FILE_MODE_WRITE); - if (!ef) - { - EINA_LOG_ERR("could not open '%s' for writing.", config_file); - return EINA_FALSE; - } - - ret = eet_data_write - (ef, _clouseau_cfg_descriptor, _CONFIG_ENTRY, _clouseau_cfg, EINA_TRUE); - eet_close(ef); - - return ret; -} - diff --git a/src/bin/client/cfg.h b/src/bin/client/cfg.h deleted file mode 100644 index f65c4d7..0000000 --- a/src/bin/client/cfg.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _CFG_H -#define _CFG_H - -#include - -#define _CLOUSEAU_CFG_VERSION 1 - -void clouseau_cfg_init(const char *file); -void clouseau_cfg_shutdown(void); - -Eina_Bool clouseau_cfg_save(void); -Eina_Bool clouseau_cfg_load(void); - -typedef struct -{ - unsigned int version; - - Eina_Bool show_hidden; - Eina_Bool show_clippers; - Eina_Bool show_elm_only; -} Clouseau_Cfg; - -extern Clouseau_Cfg *_clouseau_cfg; - -#endif diff --git a/src/bin/client/config_dialog.c b/src/bin/client/config_dialog.c deleted file mode 100644 index 00e987b..0000000 --- a/src/bin/client/config_dialog.c +++ /dev/null @@ -1,93 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include - -#include "Clouseau.h" -#include "client/cfg.h" -#include "client/config_dialog.h" - -static Clouseau_Config_Changed_Cb _conf_changed_cb = NULL; -static void *_conf_changed_cb_data = NULL; - -static Eina_Bool _cfg_changed; - -static void -_close_btn_clicked(void *data, Evas_Object *obj EINA_UNUSED, - void *event_info EINA_UNUSED) -{ - Evas_Object *popup = data; - - if (_cfg_changed) - _conf_changed_cb(_conf_changed_cb_data); - - _conf_changed_cb = NULL; - _conf_changed_cb_data = NULL; - - evas_object_del(popup); -} - -static void -_config_check_changed(void *data, Evas_Object *obj, - void *event_info EINA_UNUSED) -{ - Eina_Bool *setting = data; - *setting = elm_check_state_get(obj); - _cfg_changed = EINA_TRUE; -} - -void -clouseau_settings_dialog_open(Evas_Object *parent, Clouseau_Config_Changed_Cb callback, const void *callback_data) -{ - Evas_Object *popup, *bx, *check, *btn; - - _cfg_changed = EINA_FALSE; - _conf_changed_cb = callback; - _conf_changed_cb_data = (void *) callback_data; - - popup = elm_popup_add(parent); - elm_object_part_text_set(popup, "title,text", "Clouseau Settings"); - evas_object_show(popup); - - bx = elm_box_add(popup); - elm_object_content_set(popup, bx); - evas_object_show(bx); - - check = elm_check_add(bx); - elm_object_text_set(check, "Show Hidden"); - elm_check_state_set(check, _clouseau_cfg->show_hidden); - evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(check, 0.0, 0.5); - elm_box_pack_end(bx, check); - evas_object_show(check); - evas_object_smart_callback_add(check, "changed", - _config_check_changed, &(_clouseau_cfg->show_hidden)); - - check = elm_check_add(bx); - elm_object_text_set(check, "Show Clippers"); - elm_check_state_set(check, _clouseau_cfg->show_clippers); - evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(check, 0.0, 0.5); - elm_box_pack_end(bx, check); - evas_object_show(check); - evas_object_smart_callback_add(check, "changed", - _config_check_changed, &(_clouseau_cfg->show_clippers)); - - check = elm_check_add(bx); - elm_object_text_set(check, "Only show Elementary widgets"); - elm_check_state_set(check, _clouseau_cfg->show_elm_only); - evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(check, 0.0, 0.5); - elm_box_pack_end(bx, check); - evas_object_show(check); - evas_object_smart_callback_add(check, "changed", - _config_check_changed, &(_clouseau_cfg->show_elm_only)); - - btn = elm_button_add(bx); - elm_object_text_set(btn, "Close"); - elm_object_part_content_set(popup, "button1", btn); - evas_object_show(btn); - evas_object_smart_callback_add(btn, "clicked", - _close_btn_clicked, popup); -} diff --git a/src/bin/client/config_dialog.h b/src/bin/client/config_dialog.h deleted file mode 100644 index e0a9b9a..0000000 --- a/src/bin/client/config_dialog.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _CONFIG_DIALOG_H -#define _CONFIG_DIALOG_H - -typedef void (*Clouseau_Config_Changed_Cb)(void *data); -void clouseau_settings_dialog_open(Evas_Object *parent, Clouseau_Config_Changed_Cb callback, const void *callback_data); - -#endif - diff --git a/src/bin/clouseau_client.c b/src/bin/clouseau_client.c index 5a0deb1..e300a0b 100644 --- a/src/bin/clouseau_client.c +++ b/src/bin/clouseau_client.c @@ -1,2736 +1,953 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" +#ifndef EFL_BETA_API_SUPPORT +#define EFL_BETA_API_SUPPORT #endif +#ifndef EFL_EO_API_SUPPORT +#define EFL_EO_API_SUPPORT +#endif +#ifndef ELM_INTERNAL_API_ARGESFSDFEFC +#define ELM_INTERNAL_API_ARGESFSDFEFC +#endif +#include +#include +#include +#include +#include +#include "gui.h" -#include -#include - -#include "Clouseau.h" -#include "client/cfg.h" -#include "client/config_dialog.h" - -#define CLIENT_NAME "Clouseau Client" -#define SELECT_APP_TEXT "Select App" +#include +#include #define SHOW_SCREENSHOT "/images/show-screenshot.png" -#define TAKE_SCREENSHOT "/images/take-screenshot.png" -#define SCREENSHOT_MISSING "/images/screenshot-missing.png" -static int _clouseau_client_log_dom = -1; +#define EXTRACT(_buf, pval, sz) \ +{ \ + memcpy(pval, _buf, sz); \ + _buf += sz; \ +} -#ifdef CRITICAL -#undef CRITICAL -#endif -#define CRITICAL(...) EINA_LOG_DOM_CRIT(_clouseau_client_log_dom, __VA_ARGS__) +#define _PROFILE_EET_ENTRY "config" -#ifdef ERR -#undef ERR -#endif -#define ERR(...) EINA_LOG_DOM_ERR(_clouseau_client_log_dom, __VA_ARGS__) +static Evas_Object * +_obj_info_tootip(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, + Evas_Object *tt, void *item EINA_UNUSED); -#ifdef WRN -#undef WRN -#endif -#define WRN(...) EINA_LOG_DOM_WARN(_clouseau_client_log_dom, __VA_ARGS__) +static int _cl_stat_reg_opcode = EINA_DEBUG_OPCODE_INVALID; +static int _module_init_opcode = EINA_DEBUG_OPCODE_INVALID; +static int _eo_list_opcode = EINA_DEBUG_OPCODE_INVALID; +static int _obj_info_opcode = EINA_DEBUG_OPCODE_INVALID; +static int _obj_highlight_opcode = EINA_DEBUG_OPCODE_INVALID; -#ifdef INF -#undef INF -#endif -#define INF(...) EINA_LOG_DOM_INFO(_clouseau_client_log_dom, __VA_ARGS__) +static Gui_Main_Win_Widgets *_main_widgets = NULL; +static Gui_Profiles_Win_Widgets *_profiles_wdgs = NULL; -#ifdef DBG -#undef DBG -#endif -#define DBG(...) EINA_LOG_DOM_DBG(_clouseau_client_log_dom, __VA_ARGS__) - -static Evas_Object *prop_list = NULL; -// Item class for app name list -static Elm_Genlist_Item_Class *_app_itc = NULL; -static Elm_Genlist_Item_Class _obj_info_itc; -// Item class for objects classnames -static Elm_Genlist_Item_Class _class_info_itc; - -/* FIXME: Most hackish thing even seen. Needed because of the lack of a - * way to list genlist item's children. */ -static Elm_Object_Item *_tree_item_show_last_expanded_item = NULL; - -struct _App_Data_St +typedef struct { - app_info_st *app; - tree_data_st *td; -}; -typedef struct _App_Data_St App_Data_St; + int *opcode; /* address to the opcode */ + void *buffer; + int size; +} _pending_request; -struct _Bmp_Node +typedef struct { - unsigned int ctr; /* Current refresh_ctr */ - unsigned long long object; /* Evas ptr */ - Evas_Object *bt; /* Button of BMP_REQ */ -}; -typedef struct _Bmp_Node Bmp_Node; + Obj_Info *info; + Eina_List *children; +} _Obj_list_node; -struct _Gui_Elementns +typedef enum { - Evas_Object *win; - Evas_Object *bx; /* The main box */ - Evas_Object *hbx; /* The top menu box */ - Evas_Object *bt_load; - Evas_Object *bt_save; - struct { - Evas_Object *dd_list; - Evas_Object *obj; - Evas_Object *btn; - Evas_Object *resize_rect; - Eina_Bool is_expand : 1; - } hover; - Evas_Object *gl; - Evas_Object *prop_list; - Evas_Object *connect_inwin; - Evas_Object *save_inwin; - Evas_Object *en; - Evas_Object *pb; /* Progress wheel shown when waiting for TREE_DATA */ - char *address; - App_Data_St *sel_app; /* Currently selected app data */ - Elm_Object_Item *gl_it; /* Currently selected genlist item */ - uintptr_t jump_to_ptr; -}; -typedef struct _Gui_Elementns Gui_Elements; + CLOUSEAU_OBJ_CLASS = 0, + CLOUSEAU_OBJ_FUNC, + CLOUSEAU_OBJ_PARAM, + CLOUSEAU_OBJ_RET +} Clouseau_Obj_Info_Type; -static void _load_list(Gui_Elements *g); -static void _bt_load_file(void *data, Evas_Object *obj EINA_UNUSED, void *event_info); -static void _show_gui(Gui_Elements *g, Eina_Bool work_offline); +typedef struct +{ + Clouseau_Obj_Info_Type type; + void *data; +} _Obj_info_node; -/* Globals */ -static Gui_Elements *gui = NULL; -static Eina_List *apps = NULL; /* List of (App_Data_St *) */ -static Eina_List *bmp_req = NULL; /* List of (Bmp_Node *) */ +typedef enum +{ + CLOUSEAU_PROFILE_LOCAL = 1, + CLOUSEAU_PROFILE_SHELL_REMOTE +} Clouseau_Profile_Type; -static Elm_Genlist_Item_Class itc; -static Eina_Bool do_highlight = EINA_TRUE; -static Ecore_Con_Reply *eet_svr = NULL; -static Eina_Bool _add_callback_called = EINA_FALSE; -static void _cancel_bt_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED); -static void _ofl_bt_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED); -static void _jump_to_ptr(Gui_Elements *g, uintptr_t ptr); +typedef struct +{ + const char *file_name; + const char *name; + const char *command; + const char *script; + Clouseau_Profile_Type type; + Elm_Object_Item *item; +} Clouseau_Profile; + +static Eina_List *_pending = NULL; +static Eina_Debug_Session *_session = NULL; +static int _selected_app = -1; +static Elm_Genlist_Item_Class *_objs_itc = NULL; +static Elm_Genlist_Item_Class *_obj_info_itc = NULL; +static Elm_Genlist_Item_Class *_profiles_itc = NULL; +static Eina_List *_objs_list_tree = NULL; +static Eolian_Debug_Object_Information *_obj_info = NULL; + +static Eet_Data_Descriptor *_profile_edd = NULL; +static Eina_List *_profiles = NULL; +static Clouseau_Profile *_selected_profile = NULL; static void -_titlebar_string_set(Gui_Elements *g, Eina_Bool online) +_consume(int opcode) { - if (online) + if (!_pending) return; + _pending_request *req; + Eina_List *itr; + EINA_LIST_FOREACH(_pending, itr, req) { - char *str = malloc(strlen(CLIENT_NAME) + (g->address ? strlen(g->address) : 0) + 32); - sprintf(str, "%s - %s", CLIENT_NAME, g->address); - elm_win_title_set(g->win, str); - free(str); - } - else - { - char *str = malloc(strlen(CLIENT_NAME) + strlen(" - Offline") + 32); - sprintf(str, "%s - Offline", CLIENT_NAME); - elm_win_title_set(g->win, str); - free(str); - } -} - -static Eina_Bool -_client_connected(EINA_UNUSED void *data, Ecore_Con_Reply *reply, - EINA_UNUSED Ecore_Con_Server *conn) -{ - _add_callback_called = EINA_TRUE; - - eet_svr = reply; - connect_st t = { getpid(), __FILE__ }; - ecore_con_eet_send(reply, CLOUSEAU_GUI_CLIENT_CONNECT_STR, &t); - _titlebar_string_set(gui, EINA_TRUE); - - return ECORE_CALLBACK_RENEW; -} - -static void -_set_button(Evas_Object *w, Evas_Object *bt, - char *ic_name, char *tip, Eina_Bool en) -{ /* Update button icon and tooltip */ - char buf[1024]; - Evas_Object *ic = elm_icon_add(w); - snprintf(buf, sizeof(buf), "%s%s", PACKAGE_DATA_DIR, ic_name); - elm_image_file_set(ic, buf, NULL); - elm_object_part_content_set(bt, "icon", ic); - elm_object_tooltip_text_set(bt, tip); - elm_object_disabled_set(bt, en); - evas_object_show(ic); -} - -static void -_work_offline_popup(void) -{ - Evas_Object *bxx, *lb, *bt_bx, *bt_ofl, *bt_exit; - /* START - Popup asking user to close client or work offline */ - gui->connect_inwin = elm_win_inwin_add(gui->win); - evas_object_show(gui->connect_inwin); - - bxx = elm_box_add(gui->connect_inwin); - elm_object_style_set(gui->connect_inwin, "minimal_vertical"); - evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_show(bxx); - - lb = elm_label_add(bxx); - evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, 0.0); - elm_object_text_set(lb, "Connection to server failed."); - elm_box_pack_end(bxx, lb); - evas_object_show(lb); - - bt_bx = elm_box_add(bxx); - elm_box_horizontal_set(bt_bx, EINA_TRUE); - elm_box_homogeneous_set(bt_bx, EINA_TRUE); - evas_object_size_hint_align_set(bt_bx, 0.5, 0.5); - evas_object_size_hint_weight_set(bt_bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_show(bt_bx); - elm_box_pack_end(bxx, bt_bx); - - /* Add the exit button */ - bt_exit = elm_button_add(bt_bx); - elm_object_text_set(bt_exit, "Exit"); - evas_object_smart_callback_add(bt_exit, "clicked", - _cancel_bt_clicked, (void *) gui); - - elm_box_pack_end(bt_bx, bt_exit); - evas_object_show(bt_exit); - - bt_ofl = elm_button_add(bt_bx); - elm_object_text_set(bt_ofl, "Work Offline"); - evas_object_smart_callback_add(bt_ofl, "clicked", - _ofl_bt_clicked, (void *) gui); - - elm_box_pack_end(bt_bx, bt_ofl); - evas_object_show(bt_ofl); - - elm_win_inwin_content_set(gui->connect_inwin, bxx); - /* END - Popup asking user to close client or work offline */ -} - -static Eina_Bool -_client_disconnected(EINA_UNUSED void *data, EINA_UNUSED Ecore_Con_Reply *reply, - Ecore_Con_Server *conn) -{ - if ((!_add_callback_called) || (!eet_svr)) - { /* if initial connection with daemon failed - exit */ - ecore_con_server_del(conn); - eet_svr = NULL; /* Global svr var */ - _work_offline_popup(); - return ECORE_CALLBACK_RENEW; - } - - ERR("Lost server with ip <%s>!\n", ecore_con_server_ip_get(conn)); - - ecore_con_server_del(conn); - eet_svr = NULL; /* Global svr var */ - _show_gui(gui, EINA_TRUE); - - return ECORE_CALLBACK_RENEW; -} - -static void -clouseau_lines_free(bmp_info_st *st) -{ /* Free lines asociated with a bmp */ - if (st->lx) - evas_object_del(st->lx); - - if (st->ly) - evas_object_del(st->ly); - - st->lx = st->ly = NULL; -} - -static void -clouseau_bmp_blob_free(bmp_info_st *st) -{ /* We also free all lines drawn in this bmp canvas */ - clouseau_lines_free(st); - - if (st->bmp) - free(st->bmp); -} - -static Eina_Bool -_load_gui_with_list(Gui_Elements *g, Eina_List *trees) -{ - Eina_List *l; - Clouseau_Tree_Item *treeit; - - if (!trees) - return EINA_TRUE; - - /* Stop progress wheel as we load tree data */ - elm_progressbar_pulse(g->pb, EINA_FALSE); - evas_object_hide(g->pb); - - elm_genlist_clear(g->gl); - - EINA_LIST_FOREACH(trees, l, treeit) - { /* Insert the base ee items */ - Elm_Genlist_Item_Type glflag = (treeit->children) ? - ELM_GENLIST_ITEM_TREE : ELM_GENLIST_ITEM_NONE; - elm_genlist_item_append(g->gl, &itc, treeit, NULL, - glflag, NULL, NULL); - } - - if (g->jump_to_ptr) - { - _jump_to_ptr(g, g->jump_to_ptr); - g->jump_to_ptr = 0; - } - - return EINA_TRUE; -} - -static char * -_app_name_get(app_info_st *app) -{ - char *str = NULL; - if (app->file) - { - char *tmp = strdup(app->file); - char *bname = basename(tmp); - str = malloc(strlen(bname) + strlen(app->name) + 32); - sprintf(str, "%s:%s [%d]", bname, app->name, app->pid); - free(tmp); - } - else - { - str = malloc(strlen(app->name)+32); - sprintf(str, "%s [%d]", app->name, app->pid); - } - - return str; /* User has to free(str) */ -} - -static void -_close_app_views(app_info_st *app, Eina_Bool clr) -{ /* Close any open-views if this app */ - Eina_List *l; - bmp_info_st *view; - EINA_LIST_FOREACH(app->view, l, view) - { - if (view->win) - evas_object_del(view->win); - - if (view->bt) - elm_object_disabled_set(view->bt, EINA_FALSE); - - view->win = view->bt = NULL; - } - - if (clr) - { /* These are cleared when app data is reloaded */ - EINA_LIST_FREE(app->view, view) - { /* Free memory allocated to show any app screens */ - clouseau_bmp_blob_free(view); - free(view); - } - - app->view = NULL; - } -} - -static void -_set_selected_app(void *data, Evas_Object *pobj, - void *event_info EINA_UNUSED) -{ /* Set hovel label */ - App_Data_St *st = data; - elm_progressbar_pulse(gui->pb, EINA_FALSE); - evas_object_hide(gui->pb); - gui->gl_it = NULL; - - if (gui->sel_app) - _close_app_views(gui->sel_app->app, EINA_FALSE); - - if (st) - { - if (!eet_svr) - { /* Got TREE_DATA from file, update this immidately */ - gui->sel_app = st; - char *str = _app_name_get(st->app); - elm_object_text_set(gui->hover.btn, str); - free(str); - _load_list(gui); + if (*(req->opcode) != EINA_DEBUG_OPCODE_INVALID && + (opcode == EINA_DEBUG_OPCODE_INVALID || *(req->opcode) == opcode)) + { + eina_debug_session_send(_session, _selected_app, *(req->opcode), req->buffer, req->size); + _pending = eina_list_remove_list(_pending, itr); + free(req->buffer); + free(req); return; } - - if (gui->sel_app != st) - { /* Reload only of selected some other app */ - gui->sel_app = st; - char *str = _app_name_get(st->app); - elm_object_text_set(gui->hover.btn, str); - free(str); - - elm_progressbar_pulse(gui->pb, EINA_FALSE); - evas_object_hide(gui->pb); - _load_list(gui); - } - } - else - { /* If we got a NULL ptr, reset lists and dd_list text */ - elm_object_text_set(gui->hover.btn, SELECT_APP_TEXT); - elm_genlist_clear(gui->gl); - elm_genlist_clear(gui->prop_list); - gui->sel_app = NULL; - } - - if (eet_svr) - { /* Enable/Disable buttons only if we are online */ - elm_object_disabled_set(gui->bt_load, (gui->sel_app == NULL)); - elm_object_disabled_set(gui->bt_save, (gui->sel_app == NULL)); - } - elm_genlist_item_selected_set(elm_genlist_selected_item_get(pobj), EINA_FALSE); - elm_hover_dismiss(gui->hover.obj); -} - -static int -_app_ptr_cmp(const void *d1, const void *d2) -{ - const App_Data_St *info = d1; - app_info_st *app = info->app; - - return ((app->ptr) - (unsigned long long) (uintptr_t) d2); -} - -static char * -_app_item_label_get(void *data, Evas_Object *obj EINA_UNUSED, - const char *part EINA_UNUSED) -{ - App_Data_St *st = data; - char *str, *retstr; - - str = _app_name_get(st->app); - retstr = strdup(str); - free(str); - return retstr; -} - -static void -_add_app_to_dd_list(Evas_Object *dd_list, App_Data_St *st) -{ /* Add app to Drop Down List */ - elm_genlist_item_append(dd_list, _app_itc, st, - NULL, ELM_GENLIST_ITEM_NONE, - _set_selected_app, st); -} - -static int -_bmp_object_ptr_cmp(const void *d1, const void *d2) -{ /* Comparison according to Evas ptr of BMP struct */ - const bmp_info_st *bmp = d1; - return ((bmp->object) - (unsigned long long) (uintptr_t) d2); -} - -static int -_bmp_app_ptr_cmp(const void *d1, const void *d2) -{ /* Comparison according to app ptr of BMP struct */ - const bmp_info_st *bmp = d1; - return ((bmp->app) - (unsigned long long) (uintptr_t) d2); -} - -static Eina_List * -_remove_bmp(Eina_List *view, void *ptr) -{ /* Remove app bitmap from bitmaps list */ - bmp_info_st *st = (bmp_info_st *) - eina_list_search_unsorted(view, _bmp_app_ptr_cmp, - (void *) (uintptr_t) ptr); - - if (st) - { - if (st->win) - evas_object_del(st->win); - - if (st->bmp) - free(st->bmp); - - free(st); - return eina_list_remove(view, st); - } - - return view; -} - -static App_Data_St * -_add_app(Gui_Elements *g, app_info_st *app) -{ - App_Data_St *st; - - st = malloc(sizeof(App_Data_St)); - if (!st) return NULL; - - st->app = app; - st->td = NULL; /* Will get this on TREE_DATA message */ - apps = eina_list_append(apps, st); - - _add_app_to_dd_list(g->hover.dd_list, st); - - return st; -} - -static void -_free_app_tree_data(tree_data_st *ftd) -{ - - if (!ftd) return; - - clouseau_data_tree_free(ftd->tree); - free(ftd); -} - -static void -_free_app(App_Data_St *st) -{ - bmp_info_st *view; - app_info_st *app = st->app; - if (app->file) - free(app->file); - - EINA_LIST_FREE(app->view, view) - { /* Free memory allocated to show any app screens */ - if (view->win) - evas_object_del(view->win); - - if (view->bmp) - free(view->bmp); - - free(view); - } - - _free_app_tree_data(st->td); - free(app); - free(st); -} - -static void -_remove_app(Gui_Elements *g, app_closed_st *app) -{ /* Handle the case that NO app is selected, set sel_app to NULL */ - app_info_st *sel_app = (g->sel_app) ? g->sel_app->app: NULL; - App_Data_St *st = (App_Data_St *) - eina_list_search_unsorted(apps, _app_ptr_cmp, - (void *) (uintptr_t) app->ptr); - - /* if NO app selected OR closing app is the selected one, reset display */ - if ((!sel_app) || (app->ptr == sel_app->ptr)) - _set_selected_app(NULL, g->hover.dd_list, NULL); - - if (st) - { /* Remove from list and free all app info */ - Eina_List *l; - apps = eina_list_remove(apps, st); - _free_app(st); - - if (g->hover.is_expand) - { - elm_hover_dismiss(g->hover.obj); - g->hover.is_expand = EINA_FALSE; - } - - elm_genlist_clear(g->hover.dd_list); - EINA_LIST_FOREACH(apps, l , st) - _add_app_to_dd_list(g->hover.dd_list, st); } } static void -_update_tree_offline(Gui_Elements *g, tree_data_st *td) +_pending_add(int *opcode, void *buffer, int size) { - elm_genlist_clear(g->gl); - _load_gui_with_list(g, td->tree); -} - -static int -_Bmp_Node_cmp(const void *d1, const void *d2) -{ /* Compare accoring to Evas ptr */ - const Bmp_Node *info = d1; - - return ((info->object) - (unsigned long long) (uintptr_t) d2); -} - -static Bmp_Node * -_get_Bmp_Node(bmp_info_st *st, app_info_st *app) -{ /* Find the request of this bmp info, in the req list */ - /* We would like to verify this bmp_info_st is still relevant */ - Eina_List *req_list = bmp_req; - Bmp_Node *nd = NULL; - - if (!app) - return NULL; - - do - { /* First find according to Evas ptr, then match ctr with refresh_ctr */ - req_list = eina_list_search_unsorted_list(req_list, _Bmp_Node_cmp, - (void *) (uintptr_t) st->object); - - if (req_list) - nd = (Bmp_Node *) eina_list_data_get(req_list); - - if (nd) - { /* if found this object in list, compare ctr */ - if (nd->ctr == app->refresh_ctr) - return nd; - - /* ctr did not match, look further in list */ - req_list = eina_list_next(req_list); - } - } - while(req_list); - - return NULL; + _pending_request *req = calloc(1, sizeof(*req)); + req->opcode = opcode; + req->buffer = buffer; + req->size = size; + _pending = eina_list_append(_pending, req); } static void -clouseau_make_lines(bmp_info_st *st, Evas_Coord xx, Evas_Coord yy) -{ /* and no, we are NOT talking about WHITE lines */ - Evas_Coord x_rgn, y_rgn, w_rgn, h_rgn; - - clouseau_lines_free(st); - - elm_scroller_region_get(st->scr, &x_rgn, &y_rgn, &w_rgn, &h_rgn); - - st->lx = evas_object_line_add(evas_object_evas_get(st->o)); - st->ly = evas_object_line_add(evas_object_evas_get(st->o)); - evas_object_repeat_events_set(st->lx, EINA_TRUE); - evas_object_repeat_events_set(st->ly, EINA_TRUE); - - evas_object_line_xy_set(st->lx, 0, yy, w_rgn, yy); - evas_object_line_xy_set(st->ly, xx, 0, xx, h_rgn); - - evas_object_color_set(st->lx, HIGHLIGHT_R, HIGHLIGHT_G, HIGHLIGHT_B, - HIGHLIGHT_A); - evas_object_color_set(st->ly, HIGHLIGHT_R, HIGHLIGHT_G, HIGHLIGHT_B, - HIGHLIGHT_A); - evas_object_show(st->lx); - evas_object_show(st->ly); -} - -static void -clouseau_lines_cb(void *data, - Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, - void *event_info) +_obj_info_expand_request_cb(void *data EINA_UNUSED, const Efl_Event *event) { - if (((Evas_Event_Mouse_Down *) event_info)->button == 1) - return; /* Draw line only if not left mouse button */ - - clouseau_make_lines(data, - (((Evas_Event_Mouse_Move *) event_info)->cur.canvas.x), - (((Evas_Event_Mouse_Move *) event_info)->cur.canvas.y)); -} - -static void -_mouse_out(void *data, - Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, - EINA_UNUSED void *event_info) -{ - bmp_info_st *st = data; - elm_object_text_set(st->lb_mouse, " "); - elm_object_text_set(st->lb_rgba, " "); -} - -static void -_mouse_move(void *data, - Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, - void *event_info) -{ /* Event info is label getting mouse pointer cords */ - bmp_info_st *st = data; - unsigned char *pt; - char s_bar[64]; - float dx, dy; - Evas_Coord mp_x, mp_y, xx, yy; - Evas_Coord x, y, w, h; - - mp_x = (((Evas_Event_Mouse_Move *) event_info)->cur.canvas.x); - mp_y = (((Evas_Event_Mouse_Move *) event_info)->cur.canvas.y); - evas_object_geometry_get(st->o, &x, &y, &w, &h); - - dx = ((float) (mp_x - x)) / ((float) w); - dy = ((float) (mp_y - y)) / ((float) h); - - xx = dx * st->w; - yy = dy * st->h; - - sprintf(s_bar, "%dx%d", xx, yy); - - elm_object_text_set(st->lb_mouse, s_bar); - - if (((Evas_Event_Mouse_Move *) event_info)->buttons > 1) - clouseau_make_lines(st, mp_x, mp_y); - - if (((xx >= 0) && (xx < ((Evas_Coord) st->w))) && - ((yy >= 0) && (yy < ((Evas_Coord) st->h)))) - { /* Need to test borders, because image may be scrolled */ - pt = ((unsigned char *) st->bmp) + (((yy * st->w) + xx) * sizeof(int)); - sprintf(s_bar, "rgba(%d,%d,%d,%d)", pt[2], pt[1], pt[0], pt[3]); - elm_object_text_set(st->lb_rgba, s_bar); - } - else - elm_object_text_set(st->lb_rgba, " "); -} - -static void -_app_win_del(void *data, - Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ /* when closeing view, set view ptr to NULL, and enable open button */ - bmp_info_st *st = data; - clouseau_lines_free(st); - elm_object_disabled_set(st->bt, EINA_FALSE); - evas_object_event_callback_del(st->o, EVAS_CALLBACK_MOUSE_MOVE, - _mouse_move); - evas_object_event_callback_del(st->o, EVAS_CALLBACK_MOUSE_OUT, - _mouse_out); - evas_object_event_callback_del(st->o, EVAS_CALLBACK_MOUSE_DOWN, - clouseau_lines_cb); - st->win = st->bt = st->lb_mouse = st->o = NULL; -} - -/* START - Callbacks to handle zoom on app window (screenshot) */ -static Evas_Event_Flags -reset_view(void *data , void *event_info EINA_UNUSED) -{ /* Cancel ZOOM and remove LINES on double tap */ - bmp_info_st *st = data; - st->zoom_val = 1.0; - clouseau_lines_free(st); - evas_object_size_hint_min_set(st->o, st->w, st->h); - - return EVAS_EVENT_FLAG_ON_HOLD; -} - -static void -_update_zoom(Evas_Object *img, Evas_Object *scr, Evas_Coord zx, - Evas_Coord zy, double zoom, Evas_Coord origw, Evas_Coord origh) -{ - Evas_Coord origrelx = 0, origrely= 0; - Evas_Coord offx = 0, offy= 0; - - Evas_Coord sx, sy, sw, sh; - elm_scroller_region_get(scr, &sx, &sy, &sw, &sh); - - /* Get coords on pic. */ - { - Evas_Coord x, y, w, h; - evas_object_geometry_get(img, &x, &y, &w, &h); - double ratio = (((double) origw) / w) * zoom; - origrelx = ratio * (double) (zx - x); - origrely = ratio * (double) (zy - y); - - /* Offset of the cursor from the first visible pixel of the - * content. */ - offx = (zx - x) - sx; - offy = (zy - y) - sy; - } - - Evas_Coord imw, imh; - imw = origw * zoom; - imh = origh * zoom; - evas_object_size_hint_min_set(img, imw, imh); - evas_object_size_hint_max_set(img, imw, imh); - - elm_scroller_region_show(scr, origrelx - offx, origrely - offy, sw, sh); -} - -static Evas_Event_Flags -zoom_start(void *data , void *event_info) -{ - bmp_info_st *st = data; - Elm_Gesture_Zoom_Info *p = (Elm_Gesture_Zoom_Info *) event_info; - clouseau_lines_free(st); - _update_zoom(st->o, st->scr, p->x, p->y, st->zoom_val, st->w, st->h); - - return EVAS_EVENT_FLAG_ON_HOLD; -} - -static Evas_Event_Flags -zoom_move(void *data , void *event_info) -{ - bmp_info_st *st = data; - Elm_Gesture_Zoom_Info *p = (Elm_Gesture_Zoom_Info *) event_info; - _update_zoom(st->o, st->scr, p->x, p->y, - st->zoom_val * p->zoom, st->w, st->h); - - return EVAS_EVENT_FLAG_ON_HOLD; -} - -static Evas_Event_Flags -zoom_end(void *data , void *event_info) -{ - Elm_Gesture_Zoom_Info *p = (Elm_Gesture_Zoom_Info *) event_info; - bmp_info_st *st = data; - st->zoom_val *= p->zoom; - - return EVAS_EVENT_FLAG_ON_HOLD; -} -/* END - Callbacks to handle zoom on app window (screenshot) */ - -static void -_open_app_window(bmp_info_st *st, Evas_Object *bt, Clouseau_Tree_Item *treeit) -{ -#define SHOT_HEADER " - Screenshot" -#define SBAR_PAD_X 4 -#define SBAR_PAD_Y 2 - - Evas_Object *tb, *bg, *lb_size, *hbx, *glayer; - - char s_bar[128]; - char *win_name = malloc(strlen(treeit->name) + strlen(SHOT_HEADER) + 1); - st->zoom_val = 1.0; /* Init zoom value */ - st->bt = bt; - st->win = elm_win_add(NULL, "win", ELM_WIN_BASIC); - sprintf(win_name, "%s%s", treeit->name, SHOT_HEADER); - elm_win_title_set(st->win, win_name); - free(win_name); - - bg = elm_bg_add(st->win); - elm_win_resize_object_add(st->win, bg); - evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_show(bg); - - Evas_Object *bx = elm_box_add(st->win); - evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_show(bx); - - /* Table to holds bg and scr on top of it */ - tb = elm_table_add(bx); - elm_box_pack_end(bx, tb); - evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_show(tb); - - /* Set background to scr in table cell */ - bg = elm_bg_add(tb); - snprintf(s_bar, sizeof(s_bar), "%s/images/background.png", - PACKAGE_DATA_DIR); - elm_bg_file_set(bg, s_bar, NULL); - elm_bg_option_set(bg, ELM_BG_OPTION_TILE); - evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_show(bg); - elm_table_pack(tb, bg, 0, 0, 1, 1); - - /* Then add the scroller in same cell */ - st->scr = elm_scroller_add(tb); - elm_table_pack(tb, st->scr, 0, 0, 1, 1); - evas_object_size_hint_weight_set(st->scr, - EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - - evas_object_size_hint_align_set(st->scr, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_show(st->scr); - - st->o = evas_object_image_filled_add( - evas_object_evas_get(bx)); - - evas_object_size_hint_min_set(st->o, st->w, st->h); - elm_object_content_set(st->scr, st->o); - elm_object_cursor_set(st->o, ELM_CURSOR_TARGET); - - elm_object_disabled_set(bt, EINA_TRUE); - evas_object_image_colorspace_set(st->o, EVAS_COLORSPACE_ARGB8888); - evas_object_image_alpha_set(st->o, EINA_FALSE); - evas_object_image_size_set(st->o, st->w, st->h); - evas_object_image_data_copy_set(st->o, st->bmp); - evas_object_image_data_update_add(st->o, 0, 0, st->w, st->h); - evas_object_show(st->o); - evas_object_smart_callback_add(st->win, - "delete,request", _app_win_del, st); - - /* Build status bar */ - hbx = elm_box_add(bx); - elm_box_horizontal_set(hbx, EINA_TRUE); - evas_object_show(hbx); - elm_box_padding_set(hbx, SBAR_PAD_X, SBAR_PAD_Y); - evas_object_size_hint_align_set(hbx, 0.0, EVAS_HINT_FILL); - elm_box_pack_end(bx, hbx); - lb_size = elm_label_add(hbx); - sprintf(s_bar, "%llux%llu", st->w, st->h); - elm_object_text_set(lb_size, s_bar); - evas_object_show(lb_size); - elm_box_pack_end(hbx, lb_size); - - st->lb_mouse = elm_label_add(hbx); - elm_object_text_set(st->lb_mouse, s_bar); - evas_object_show(st->lb_mouse); - elm_box_pack_end(hbx, st->lb_mouse); - - st->lb_rgba = elm_label_add(hbx); - elm_object_text_set(st->lb_rgba, s_bar); - evas_object_show(st->lb_rgba); - elm_box_pack_end(hbx, st->lb_rgba); - - evas_object_event_callback_add(st->o, EVAS_CALLBACK_MOUSE_MOVE, - _mouse_move, st); - - evas_object_event_callback_add(st->o, EVAS_CALLBACK_MOUSE_OUT, - _mouse_out, st); - - evas_object_event_callback_add(st->o, EVAS_CALLBACK_MOUSE_DOWN, - clouseau_lines_cb, st); - - evas_object_resize(st->scr, st->w, st->h); - elm_win_resize_object_add(st->win, bx); - evas_object_resize(st->win, st->w, st->h); - - elm_win_autodel_set(st->win, EINA_TRUE); - evas_object_show(st->win); - - /* Attach a gesture layer object to support ZOOM gesture */ - glayer = elm_gesture_layer_add(st->scr); - elm_gesture_layer_attach(glayer, st->scr); - - /* Reset zoom and remove lines on double click */ - elm_gesture_layer_cb_set(glayer, ELM_GESTURE_N_DOUBLE_TAPS, - ELM_GESTURE_STATE_END, reset_view, st); - - elm_gesture_layer_cb_set(glayer, ELM_GESTURE_ZOOM, - ELM_GESTURE_STATE_START, zoom_start, st); - elm_gesture_layer_cb_set(glayer, ELM_GESTURE_ZOOM, - ELM_GESTURE_STATE_MOVE, zoom_move, st); - elm_gesture_layer_cb_set(glayer, ELM_GESTURE_ZOOM, - ELM_GESTURE_STATE_END, zoom_end, st); - elm_gesture_layer_cb_set(glayer, ELM_GESTURE_ZOOM, - ELM_GESTURE_STATE_ABORT, zoom_end, st); -} - -static void -_show_app_window(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) -{ /* Open window with currnent bmp, or download it if missing */ - app_info_st *st = gui->sel_app->app; - Clouseau_Tree_Item *treeit = data; - - /* First search app->view list if already have the window bmp */ - bmp_info_st *bmp = (bmp_info_st *) - eina_list_search_unsorted(st->view, _bmp_object_ptr_cmp, - (void *) (uintptr_t) treeit->ptr); - if (bmp) - return _open_app_window(bmp, obj, data); - - /* Need to issue BMP_REQ */ - if (eet_svr) - { - bmp_req_st t = { (unsigned long long) (uintptr_t) NULL, - (unsigned long long) (uintptr_t) st->ptr, - (unsigned long long) (uintptr_t) treeit->ptr, st->refresh_ctr }; - - ecore_con_eet_send(eet_svr, CLOUSEAU_BMP_REQ_STR, &t); - elm_object_disabled_set(obj, EINA_TRUE); - elm_progressbar_pulse(gui->pb, EINA_TRUE); - evas_object_show(gui->pb); - - Bmp_Node *b_node = malloc(sizeof(*b_node)); - b_node->ctr = st->refresh_ctr; - b_node->object = (unsigned long long) (uintptr_t) treeit->ptr; - b_node->bt = obj; /* Button of BMP_REQ */ - bmp_req = eina_list_append(bmp_req, b_node); - } - else /* Disable button if we lost server */ - _set_button(gui->win, obj, - SCREENSHOT_MISSING, - "Screenshot not available", EINA_TRUE); -} - -/* START - Callbacks to handle messages from daemon */ -void -_app_closed_cb(EINA_UNUSED void *data, EINA_UNUSED Ecore_Con_Reply *reply, - EINA_UNUSED const char *protocol_name, void *value) -{ - _remove_app(gui, value); -} - -void -_app_add_cb(EINA_UNUSED void *data, EINA_UNUSED Ecore_Con_Reply *reply, - EINA_UNUSED const char *protocol_name, void *value) -{ - _add_app(gui, value); -} - -void -_tree_data_cb(EINA_UNUSED void *data, EINA_UNUSED Ecore_Con_Reply *reply, - EINA_UNUSED const char *protocol_name, void *value) -{ /* Update Tree for app, then update GUI if its displayed */ - tree_data_st *td = value; - app_info_st *selected = gui->sel_app->app; - - /* Update only if tree is from APP on our list */ - App_Data_St *st = (App_Data_St *) - eina_list_search_unsorted(apps, _app_ptr_cmp, - (void *) (uintptr_t) td->app); - - if (st) - { /* Free app TREE_DATA then set ptr to new data */ - _free_app_tree_data(st->td); - st->td = value; - - if (selected->ptr == td->app) - { /* Update GUI only if TREE_DATA is from SELECTED app */ - elm_genlist_clear(gui->gl); - _load_gui_with_list(gui, td->tree); - } - } - else - { /* Happens when TREE_DATA of app that already closed has arrived */ - _free_app_tree_data(value); - } -} - -void -_bmp_data_cb(EINA_UNUSED void *data, EINA_UNUSED Ecore_Con_Reply *reply, - const char *protocol_name, EINA_UNUSED const char *section, - void *value, size_t length) -{ /* Remove bmp if exists (according to obj-ptr), then add the new one */ - bmp_info_st *st = clouseau_data_packet_info_get(protocol_name, - value, length); - - st->zoom_val = 1.0; /* Init zoom value */ - - App_Data_St *app = (App_Data_St *) - eina_list_search_unsorted(apps, _app_ptr_cmp, - (void *) (uintptr_t) st->app); - - /* Check for relevant bmp req in the bmp_req list */ - Bmp_Node *nd = _get_Bmp_Node(st, app->app); - - if (!st->bmp) - { /* We consider a case out request will be answered with empty bmp - this may happen if we have a sub-window of app - (like checks in elementary test) - if the user closed it just as we send our BMP_REQ - this Evas is no longer valid and we get NULL ptr for BMP. - This code ignores this case. */ - elm_progressbar_pulse(gui->pb, EINA_FALSE); - evas_object_hide(gui->pb); - free(st); - - /* Make refresh button display: screenshot NOT available */ - if (nd) - _set_button(gui->win, nd->bt, - SCREENSHOT_MISSING, - "Screenshot not available", EINA_TRUE); - return; - } - - if (app && nd) - { /* Remove app bmp data if exists, then update */ - elm_progressbar_pulse(gui->pb, EINA_FALSE); - evas_object_hide(gui->pb); - - app_info_st *info = app->app; - info->view = _remove_bmp(info->view, - (void *) (uintptr_t) (st->object)); - info->view = eina_list_append(info->view, st); - - /* Now we need to update refresh button, make it open-window */ - _set_button(gui->win, nd->bt, - SHOW_SCREENSHOT, - "Show App Screenshot", EINA_FALSE); - - bmp_req = eina_list_remove(bmp_req, nd); - free(nd); - } - else - { /* Dispose bmp info if app no longer in the list of apps */ - /* or the bmp_info is no longer relevant */ - if (st->bmp) - free(st->bmp); - - free(st); - } -} - -static Eina_Bool -_tree_it_is_elm(Clouseau_Tree_Item *treeit) -{ - Eina_List *l; - Efl_Dbg_Info *eo_root, *eo; - Eina_Value_List eo_list; - clouseau_tree_item_from_legacy_convert(treeit); - eo_root = treeit->new_eo_info; - - eina_value_pget(&(eo_root->value), &eo_list); - - EINA_LIST_FOREACH(eo_list.list, l, eo) - { - if (!strcmp(eo->name, "Elm_Widget")) - return EINA_TRUE; - } - - return EINA_FALSE; -} - -static void -_gl_exp_add_subitems(Evas_Object *gl, Elm_Object_Item *glit, Clouseau_Tree_Item *parent) -{ - Clouseau_Tree_Item *treeit; - Eina_List *itr; - - EINA_LIST_FOREACH(parent->children, itr, treeit) - { - /* Skip the item if we don't want to show it. */ - if ((!_clouseau_cfg->show_hidden && !treeit->is_visible) || - (!_clouseau_cfg->show_clippers && treeit->is_clipper)) - continue; - - if (_clouseau_cfg->show_elm_only && !_tree_it_is_elm(treeit)) - { - _gl_exp_add_subitems(gl, glit, treeit); - } - else - { - Elm_Genlist_Item_Type iflag = (treeit->children) ? - ELM_GENLIST_ITEM_TREE : ELM_GENLIST_ITEM_NONE; - _tree_item_show_last_expanded_item = - elm_genlist_item_append(gl, &itc, treeit, glit, iflag, - NULL, NULL); - } - } -} - -static void -gl_exp(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) -{ - Elm_Object_Item *glit = event_info; - Evas_Object *gl = elm_object_item_widget_get(glit); - Clouseau_Tree_Item *parent = elm_object_item_data_get(glit); - _gl_exp_add_subitems(gl, glit, parent); -} - -static void -gl_con(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) -{ - Elm_Object_Item *glit = event_info; - elm_genlist_item_subitems_clear(glit); -} - -static void -gl_exp_req(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) -{ - Elm_Object_Item *glit = event_info; + Elm_Object_Item *glit = event->info; elm_genlist_item_expanded_set(glit, EINA_TRUE); } static void -gl_clk_double(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) +_obj_info_contract_request_cb(void *data EINA_UNUSED, const Efl_Event *event) { - Elm_Object_Item *glit = (Elm_Object_Item *)event_info; - if (elm_genlist_item_type_get(glit) == ELM_GENLIST_ITEM_TREE) - { - if (elm_genlist_item_expanded_get(glit)) - elm_genlist_item_subitems_clear(glit); - else - elm_genlist_item_expanded_set(glit, EINA_TRUE); - } -} - -static void -gl_con_req(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) -{ - Elm_Object_Item *glit = event_info; + Elm_Object_Item *glit = event->info; elm_genlist_item_expanded_set(glit, EINA_FALSE); } -static Evas_Object * -item_icon_get(void *data, Evas_Object *parent, const char *part) -{ - Clouseau_Tree_Item *treeit = data; - char buf[PATH_MAX]; - - if (!treeit->is_obj) - { /* Add "Download" button for evas objects */ - if (!strcmp(part, "elm.swallow.end")) - { - Evas_Object *bt = elm_button_add(parent); - app_info_st *app = NULL; - if (gui->sel_app) - app = gui->sel_app->app; - - if (app) - { /* match ptr with bmp->object ptr to find view */ - bmp_info_st *bmp = (bmp_info_st *) - eina_list_search_unsorted(app->view, _bmp_object_ptr_cmp, - (void *) (uintptr_t) treeit->ptr); - - if (bmp) - { /* Set to "show view" if view exists */ - _set_button(parent, bt, - SHOW_SCREENSHOT, - "Show App Screenshot", EINA_FALSE); - } - else - { /* Set to Download or not available if offline */ - if (eet_svr) - { - _set_button(parent, bt, - TAKE_SCREENSHOT, - "Download Screenshot", EINA_FALSE); - } - else - { /* Make button display: screenshot NOT available */ - _set_button(parent, bt, - SCREENSHOT_MISSING, - "Screenshot not available", EINA_TRUE); - } - } - } - - evas_object_smart_callback_add(bt, "clicked", - _show_app_window, treeit); - - evas_object_show(bt); - return bt; - } - - return NULL; - } - - if (!strcmp(part, "elm.swallow.icon")) - { - if (treeit->is_clipper && !treeit->is_visible) - { - Evas_Object *ic; - Evas_Object *bx = elm_box_add(parent); - evas_object_size_hint_aspect_set(bx, EVAS_ASPECT_CONTROL_VERTICAL, - 1, 1); - - ic = elm_icon_add(bx); - snprintf(buf, sizeof(buf), "%s/images/clipper.png", - PACKAGE_DATA_DIR); - elm_image_file_set(ic, buf, NULL); - evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, - 1, 1); - evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(ic, EVAS_HINT_FILL, - EVAS_HINT_FILL); - elm_box_pack_end(bx, ic); - - ic = elm_icon_add(bx); - snprintf(buf, sizeof(buf), "%s/images/hidden.png", - PACKAGE_DATA_DIR); - elm_image_file_set(ic, buf, NULL); - evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, - 1, 1); - evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(ic, EVAS_HINT_FILL, - EVAS_HINT_FILL); - elm_box_pack_end(bx, ic); - - return bx; - - } - else if (treeit->is_clipper) - { - Evas_Object *ic; - ic = elm_icon_add(parent); - snprintf(buf, sizeof(buf), "%s/images/clipper.png", - PACKAGE_DATA_DIR); - elm_image_file_set(ic, buf, NULL); - evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, - 1, 1); - return ic; - } - else if (!treeit->is_visible) - { - Evas_Object *ic; - ic = elm_icon_add(parent); - snprintf(buf, sizeof(buf), "%s/images/hidden.png", - PACKAGE_DATA_DIR); - elm_image_file_set(ic, buf, NULL); - evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, - 1, 1); - return ic; - } - } - - return NULL; -} - -static char * -item_text_get(void *data, Evas_Object *obj EINA_UNUSED, - const char *part EINA_UNUSED) -{ - Clouseau_Tree_Item *treeit = data; - char buf[256]; - snprintf(buf, sizeof(buf), "%s %llx", treeit->name, treeit->ptr); - return strdup(buf); -} - static void -client_win_del(void *data EINA_UNUSED, - Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ /* called when client window is deleted */ - elm_exit(); /* exit the program's main loop that runs in elm_run() */ -} - -static Eina_Bool -_connect_to_daemon(Gui_Elements *g) -{ - if (eet_svr) - return EINA_TRUE; - - int port = PORT; - char *address = LOCALHOST; - char *p_colon = NULL; - Ecore_Con_Server *server; - Ecore_Con_Eet *ece = NULL; - - if (g->address && strlen(g->address)) - { - address = g->address; - p_colon = strchr(g->address, ':'); - } - - if (p_colon) - { - *p_colon = '\0'; - if (isdigit(*(p_colon+1))) - port = atoi(p_colon+1); - } - - server = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, - address, port, NULL); - - if (p_colon) - *p_colon = ':'; - - if (!server) - { - ERR("could not connect to the server: %s\n", g->address); - return EINA_FALSE; - } - - /* TODO: ecore_con_server_data_size_max_set(server, -1); */ - - ece = ecore_con_eet_client_new(server); - if (!ece) - { - ERR("could not connect to the server: %s\n", g->address); - return EINA_FALSE; - } - - clouseau_register_descs(ece); - - /* Register callbacks for ecore_con_eet */ - ecore_con_eet_server_connect_callback_add(ece, _client_connected, NULL); - ecore_con_eet_server_disconnect_callback_add(ece, _client_disconnected, NULL); - ecore_con_eet_data_callback_add(ece, CLOUSEAU_APP_CLOSED_STR, - _app_closed_cb, NULL); - ecore_con_eet_data_callback_add(ece, CLOUSEAU_APP_ADD_STR, - _app_add_cb, NULL); - ecore_con_eet_data_callback_add(ece, CLOUSEAU_TREE_DATA_STR, - _tree_data_cb, NULL); - - /* At the moment our only raw-data packet is BMP info */ - ecore_con_eet_raw_data_callback_add(ece, CLOUSEAU_BMP_DATA_STR, - _bmp_data_cb, NULL); - - return EINA_TRUE; -} - -static void -_send_highlight(App_Data_St *app, Clouseau_Tree_Item *tree) -{ - if (!do_highlight) - return; - - if (!eet_svr) - { - //do offline highlight - Efl_Dbg_Info *evas_object, *pos, *size, *x, *y, *w, *h; - Eina_Rectangle r; - Evas_Object *rectangle; - bmp_info_st *bmp; - Evas *e; - - evas_object = clouseau_eo_info_find(tree->new_eo_info , "Evas_Object"); - size = clouseau_eo_info_find(evas_object, "Size"); - pos = clouseau_eo_info_find(evas_object, "Position"); - -#define FIND_AND_GET(c, name) \ - name = clouseau_eo_info_find(c, ""#name""); \ - eina_value_get(&name->value, &r.name); - - FIND_AND_GET(pos, x) - FIND_AND_GET(pos, y) - FIND_AND_GET(size, w) - FIND_AND_GET(size, h) - -#undef FIND_AND_GET - - bmp = eina_list_search_unsorted(app->app->view, - _bmp_app_ptr_cmp, - (void*) (uintptr_t) app->td->app); - - if (!bmp) - { - printf("Error, failed to find window of open screenshot!\n"); - return; - } - - //win is null as long as the screenshot is not displayed - if (!bmp->win) return; - e = efl_parent_get(bmp->win); - rectangle = evas_object_rectangle_add(e); - evas_object_geometry_set(rectangle, r.x, r.y, r.w, r.h); - clouseau_data_object_highlight(rectangle); - } - else - { - //sent highlight to the listening client - highlight_st st = { (unsigned long long) (uintptr_t) app->app->ptr, - tree->ptr }; - - ecore_con_eet_send(eet_svr, CLOUSEAU_HIGHLIGHT_STR, &st); - } -} - -static void -_gl_selected(void *data, Evas_Object *pobj EINA_UNUSED, void *event_info) -{ - Gui_Elements *g = data; - Clouseau_Tree_Item *treeit = elm_object_item_data_get(event_info); - const Elm_Object_Item *parent; - const Elm_Object_Item *prt = elm_genlist_item_parent_get(event_info); - - if (!prt) - { - g->gl_it = NULL; - return; - } - - /* Populate object information, then do highlight */ - if (g->gl_it != event_info) - { - elm_genlist_clear(prop_list); - clouseau_object_information_list_populate(treeit); - g->gl_it = event_info; - - { - /* Fetch properties of eo object */ - Eina_List *expand_list = NULL, *l, *l_prev; - Elm_Object_Item *eo_it; - - /* Populate the property list. */ - { - Efl_Dbg_Info *eo_root, *eo; - Eina_Value_List eo_list; - /* FIXME: Do it before and save it like that. Probably at the - * eet conversion stage. */ - clouseau_tree_item_from_legacy_convert(treeit); - eo_root = treeit->new_eo_info; - - eina_value_pget(&(eo_root->value), &eo_list); - - EINA_LIST_FOREACH(eo_list.list, l, eo) - { - Elm_Genlist_Item_Type iflag = (eina_value_type_get(&(eo->value)) == EINA_VALUE_TYPE_LIST) ? - ELM_GENLIST_ITEM_TREE : ELM_GENLIST_ITEM_NONE; - // We force the item to be a tree for the class layers - eo_it = elm_genlist_item_append(prop_list, &_class_info_itc, eo, NULL, - iflag, _gl_selected, data); - expand_list = eina_list_append(expand_list, eo_it); - } - } - EINA_LIST_REVERSE_FOREACH_SAFE(expand_list, l, l_prev, eo_it) - { - elm_genlist_item_expanded_set(eo_it, EINA_TRUE); - expand_list = eina_list_remove_list(expand_list, l); - } - } - } - - _send_highlight(g->sel_app , treeit); -} - -static void -_load_list(Gui_Elements *g) -{ - elm_progressbar_pulse(g->pb, EINA_FALSE); - evas_object_hide(g->pb); - - if (g->sel_app) - { - elm_genlist_clear(g->gl); - elm_genlist_clear(g->prop_list); - app_info_st *st = g->sel_app->app; - tree_data_st *td = (g->sel_app->td) ? g->sel_app->td : NULL; - - if (td) - { /* Just show currnet tree we got */ - _load_gui_with_list(g, td->tree); - } - else - { /* Ask for app info only if was not fetched */ - if (!eet_svr) - { - _update_tree_offline(g, g->sel_app->td); - return; - } - - if (eina_list_search_unsorted(apps, _app_ptr_cmp, - (void *) (uintptr_t) st->ptr)) - { /* do it only if app selected AND found in apps list */ - data_req_st t = { (unsigned long long) (uintptr_t) NULL, - (unsigned long long) (uintptr_t) st->ptr }; - - ecore_con_eet_send(eet_svr, CLOUSEAU_DATA_REQ_STR, &t); - elm_progressbar_pulse(g->pb, EINA_TRUE); - evas_object_show(g->pb); - } - } - } -} - -static void -_highlight_check_check_changed(EINA_UNUSED void *data, Evas_Object *obj, - void *event_info EINA_UNUSED) -{ - do_highlight = elm_check_state_get(obj); -} - -static void -_bt_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ - Gui_Elements *g = data; - - /* If there's a currently selected item, try to reopening it. */ - if (g->gl_it) - { - Clouseau_Tree_Item *treeit = elm_object_item_data_get(g->gl_it); - g->jump_to_ptr = (treeit) ? (uintptr_t) treeit->ptr : 0; - } - - /* Close all app-bmp-view windows here and clear mem */ - if (g->sel_app) - { - app_info_st *st = g->sel_app->app; - _close_app_views(st, EINA_TRUE); - st->refresh_ctr++; - } - - _free_app_tree_data(g->sel_app->td); - g->sel_app->td = NULL; - g->gl_it = NULL; - _load_list(data); -} - -static void -_load_file(const char *path) -{ - app_info_st *app = calloc(1, sizeof(*app)); - tree_data_st *td = calloc(1, sizeof(*td)); - Eina_Bool s = clouseau_data_eet_info_read(path, - (app_info_st **) &app, (tree_data_st **) &td); - - if (s) - { /* Add the app to list of apps, then set this as selected app */ - app->file = strdup(path); - App_Data_St *st = _add_app(gui, app); - st->td = td; /* This is the same as we got TREE_DATA message */ - _set_selected_app(st, gui->hover.dd_list, NULL); - } -} - -static void -_bt_load_file(void *data, Evas_Object *obj EINA_UNUSED, void *event_info) -{ - if (event_info) - _load_file(event_info); -} - -static void -_dismiss_save_dialog(void *data, - Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ /* Just close save file save_inwin, do nothing */ - Gui_Elements *g = data; - evas_object_del(g->save_inwin); - g->save_inwin = NULL; -} - -static void -_bt_save_file(void *data, Evas_Object *obj EINA_UNUSED, void *event_info) -{ - app_info_st *app = gui->sel_app->app; - tree_data_st *ftd = gui->sel_app->td; - if (event_info) - { - /* FIXME: Handle failure. */ - Eina_List *bmp_ck_list = elm_box_children_get(data); - - clouseau_data_eet_info_save(event_info, app, ftd, bmp_ck_list); - eina_list_free(bmp_ck_list); - } - - - if (event_info) /* Dismiss save dialog after saving */ - _dismiss_save_dialog(gui, NULL, NULL); -} - -static void -_dismiss_inwin(Gui_Elements *g) -{ - g->address = (g->en) ? strdup(elm_entry_entry_get(g->en)) : NULL; - evas_object_del(g->connect_inwin); - g->en = NULL; - g->connect_inwin = NULL; -} - -static void -_save_all(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) -{ - Evas_Object *ck_bx = data; - Evas_Object *ck; - Eina_List *l; - Eina_List *ck_list = elm_box_children_get(ck_bx); - Eina_Bool val = elm_check_state_get(obj); - - EINA_LIST_FOREACH(ck_list, l, ck) - { /* Run through checkoxes, set / unset marks for all */ - if (!elm_object_disabled_get(ck)) - elm_check_state_set(ck, val); - } - - eina_list_free(ck_list); -} - -static Eina_Bool -_tree_item_show_item(Elm_Object_Item *git, Eina_List *item_list) -{ - if (eina_list_data_get(item_list) == elm_object_item_data_get(git)) - { - item_list = eina_list_next(item_list); - if (item_list) - { - Elm_Object_Item *gitc; - _tree_item_show_last_expanded_item = NULL; - elm_genlist_item_expanded_set(git, EINA_FALSE); - elm_genlist_item_expanded_set(git, EINA_TRUE); - gitc = _tree_item_show_last_expanded_item; - - while (gitc && (gitc != git)) - { - if (_tree_item_show_item(gitc, item_list)) - return EINA_TRUE; - gitc = elm_genlist_item_prev_get(gitc); - } - } - else - { - elm_genlist_item_bring_in(git, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE); - elm_genlist_item_selected_set(git, EINA_TRUE); - return EINA_TRUE; - } - } - - return EINA_FALSE; -} - -static void -_tree_item_show(Evas_Object *tree_genlist, Eina_List *item_list) -{ - Elm_Object_Item *git = elm_genlist_first_item_get(tree_genlist); - while (git) - { - if (_tree_item_show_item(git, item_list)) - break; - git = elm_genlist_item_next_get(git); - } - -} - -static Eina_List * -_tree_item_pointer_find(Clouseau_Tree_Item *treeit, uintptr_t ptr) -{ - Eina_List *l; - - /* Mark that we found the item, and start adding. */ - if (treeit->ptr == ptr) - return eina_list_prepend(NULL, NULL); - - EINA_LIST_FOREACH(treeit->children, l, treeit) - { - Eina_List *found; - if ((found = _tree_item_pointer_find(treeit, ptr))) - { - if (!eina_list_data_get(found)) - { - eina_list_free(found); - found = NULL; - } - return eina_list_prepend(found, treeit); - } - } - - return NULL; -} - -static Eina_List * -_list_tree_item_pointer_find(Eina_List *tree, uintptr_t ptr) -{ - Clouseau_Tree_Item *treeit; - Eina_List *l; - EINA_LIST_FOREACH(tree, l, treeit) - { - Eina_List *found; - if ((found = _tree_item_pointer_find(treeit, ptr))) - { - found = eina_list_prepend(found, treeit); - return found; - } - } - - return NULL; -} - -/* Load/unload modules. */ - -static Eina_List *_client_modules = NULL; - -static void -_modules_load_from_path(const char *path) -{ - Eina_Array *modules = NULL; - - modules = eina_module_list_get(modules, path, EINA_TRUE, NULL, NULL); - if (modules) - { - eina_module_list_load(modules); - - _client_modules = eina_list_append(_client_modules, modules); - } -} - -#define MODULES_POSTFIX PACKAGE "/modules/client" - -static void -_modules_init(void) -{ - char *path; - - path = eina_module_environment_path_get("HOME", "/." MODULES_POSTFIX); - _modules_load_from_path(path); - free(path); - - path = PACKAGE_LIB_DIR "/" MODULES_POSTFIX; - _modules_load_from_path(path); -} - -static void -_modules_shutdown(void) -{ - Eina_Array *module_list; - - EINA_LIST_FREE(_client_modules, module_list) - eina_module_list_free(module_list); -} - -static void -_run_module_btn_clicked(void *data, - Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ - Eina_Module *module = data; - tree_data_st *td = NULL; - - if (gui && gui->sel_app) - td = (gui->sel_app->td) ? gui->sel_app->td : NULL; - - if (td) - { - void (*module_run)(Eina_List *) = eina_module_symbol_get(module, "clouseau_client_module_run"); - - module_run(td->tree); - } - else - { - ERR("No selected apps!"); - } -} - -static Eina_Bool -_module_name_get_cb(const void *container EINA_UNUSED, void *data, void *fdata) -{ - Evas_Object *box = fdata; - Eina_Module *module = data; - Evas_Object *btn = NULL; - - const char **name = eina_module_symbol_get(module, "clouseau_module_name"); - if (name) - { - btn = elm_button_add(box); - elm_object_text_set(btn, *name); - evas_object_smart_callback_add(btn, "clicked", _run_module_btn_clicked, module); - elm_box_pack_end(box, btn); - evas_object_show(btn); - } - - return EINA_TRUE; -} - -static void -_popup_close_clicked_cb(void *data, - Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ - evas_object_del(data); -} - -static void -_extensions_btn_clicked(void *data EINA_UNUSED, - Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +_obj_info_expanded_cb(void *data EINA_UNUSED, const Efl_Event *event) { + Elm_Object_Item *glit = event->info; + _Obj_info_node *node = elm_object_item_data_get(glit); Eina_List *itr; - Eina_Array *module_list; - Evas_Object *popup, *box, *btn; - - popup = elm_popup_add(gui->win); - elm_object_part_text_set(popup, "title,text", "Run Extensions"); - evas_object_show(popup); - - box = elm_box_add(popup); - elm_object_content_set(popup, box); - evas_object_show(box); - - EINA_LIST_FOREACH(_client_modules, itr, module_list) + if(node->type == CLOUSEAU_OBJ_CLASS) { - eina_array_foreach(module_list, _module_name_get_cb, box); - } - - btn = elm_button_add(box); - elm_object_text_set(btn, "Close"); - evas_object_smart_callback_add(btn, "clicked", _popup_close_clicked_cb, popup); - evas_object_size_hint_align_set(btn, 1.0, 0.5); - elm_box_pack_end(box, btn); - evas_object_show(btn); -} - -static void -_settings_btn_clicked(void *data EINA_UNUSED, - Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ - clouseau_settings_dialog_open(gui->win, - (Clouseau_Config_Changed_Cb) _load_list, (void *) gui); -} - -static void -_save_file_dialog(void *data, - Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ /* START - Popup to save eet file */ - Gui_Elements *g = data; - Evas_Object *scr, *bt_bx, *bx, *ck_bx, - *lb, *ck, *bt_cancel, *bt_save; - g->save_inwin = elm_win_inwin_add(g->win); - evas_object_show(g->save_inwin); - - - bx = elm_box_add(g->save_inwin); - evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_show(bx); - - lb = elm_label_add(bx); - evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, 0.0); - elm_object_text_set(lb, "Select Screeenshots to save:"); - elm_box_pack_end(bx, lb); - evas_object_show(lb); - - /* Add checkboxes to select screenshots to save */ - ck_bx = elm_box_add(g->save_inwin); - - Eina_List *l; - app_info_st *a = g->sel_app->app; - tree_data_st *td = g->sel_app->td; - Clouseau_Tree_Item *treeit; - char buf[256]; - EINA_LIST_FOREACH(td->tree, l, treeit) - { /* First search app->view list if already have the window bmp */ - bmp_info_st *bmp = (bmp_info_st *) - eina_list_search_unsorted(a->view, _bmp_object_ptr_cmp, - (void *) (uintptr_t) treeit->ptr); - - ck = elm_check_add(ck_bx); - evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, 1.0); - evas_object_size_hint_align_set(ck, EVAS_HINT_FILL, 0.0); - elm_box_pack_end(ck_bx, ck); - elm_object_disabled_set(ck, !(bmp && bmp->bmp)); - evas_object_data_set(ck, BMP_FIELD, bmp); /* Associate ck with bmp */ - snprintf(buf, sizeof(buf), "%llx %s", treeit->ptr, treeit->name); - elm_object_text_set(ck, buf); - - evas_object_show(ck); - } - - evas_object_show(ck_bx); - scr = elm_scroller_add(bx); - elm_object_content_set(scr, ck_bx); - evas_object_size_hint_align_set(scr, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_size_hint_weight_set(scr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_show(scr); - elm_box_pack_end(bx, scr); - - /* Add the save all checkbox */ - ck = elm_check_add(bx); - elm_object_text_set(ck, "Save All"); - evas_object_smart_callback_add(ck, "changed", _save_all, ck_bx); - evas_object_show(ck); - elm_box_pack_end(bx, ck); - - bt_bx = elm_box_add(bx); - elm_box_horizontal_set(bt_bx, EINA_TRUE); - elm_box_homogeneous_set(bt_bx, EINA_TRUE); - evas_object_size_hint_align_set(bt_bx, 0.5, 1.0); - evas_object_size_hint_weight_set(bt_bx, EVAS_HINT_EXPAND, 0.0); - evas_object_show(bt_bx); - elm_box_pack_end(bx, bt_bx); - - /* Add the cancel button */ - bt_cancel = elm_button_add(bt_bx); - elm_object_text_set(bt_cancel, "Cancel"); - evas_object_smart_callback_add(bt_cancel, "clicked", - _dismiss_save_dialog, g); - - elm_box_pack_end(bt_bx, bt_cancel); - evas_object_show(bt_cancel); - - /* Add the Save fileselector button */ - bt_save = elm_fileselector_button_add(bt_bx); - elm_fileselector_is_save_set(bt_save, EINA_TRUE); - elm_object_text_set(bt_save, "Save File"); - elm_fileselector_path_set(bt_save, getenv("HOME")); - evas_object_smart_callback_add(bt_save, "file,chosen", - _bt_save_file, ck_bx); - - elm_box_pack_end(bt_bx, bt_save); - evas_object_show(bt_save); - - elm_win_inwin_content_set(g->save_inwin, bx); - /* END - Popup to save eet file */ -} - -static void -_remove_apps_with_no_tree_data(Gui_Elements *g) -{ /* We need to remove apps with no tree data when losing commection - * with daemon. We may have apps in our list that were added but - * tree-data was NOT loaded. - * In this case, we want to remove them if connection was lost. */ - - Eina_List *l, *l_next; - App_Data_St *st; - app_closed_st t; - EINA_LIST_FOREACH_SAFE(apps, l, l_next, st) - { - if (!st->td) - { /* We actually fake APP_CLOSED message, for app NO tree */ - t.ptr = (unsigned long long) (uintptr_t) - (((app_info_st *) st->app)->ptr); - - _remove_app(g, &t); - } - } -} - -static void -_show_gui(Gui_Elements *g, Eina_Bool work_offline) -{ - if (work_offline) - { /* Replace bt_load with fileselector button */ - _titlebar_string_set(g, EINA_FALSE); - elm_box_unpack(g->hbx, g->bt_load); - evas_object_del(g->bt_load); - - /* We need this in case conneciton closed and no tree data */ - _remove_apps_with_no_tree_data(g); - - g->bt_load = elm_fileselector_button_add(g->hbx); - elm_box_pack_start(g->hbx, g->bt_load); - elm_object_text_set(g->bt_load, "Load File"); - elm_fileselector_path_set(g->bt_load, getenv("HOME")); - evas_object_smart_callback_add(g->bt_load, "file,chosen", - _bt_load_file, g); - - evas_object_show(g->bt_load); - } - else - { - elm_object_text_set(g->bt_load, "Reload"); - evas_object_smart_callback_add(g->bt_load, "clicked", _bt_clicked, g); - - /* Add the Save button to open save dialog */ - if (g->bt_save) - evas_object_del(g->bt_save); - - g->bt_save = elm_button_add(g->hbx); - elm_object_text_set(g->bt_save, "Save"); - evas_object_smart_callback_add(g->bt_save, "clicked", - _save_file_dialog, (void *) gui); - - elm_box_pack_end(g->hbx, g->bt_save); - evas_object_show(g->bt_save); - - elm_object_disabled_set(g->bt_load, (g->sel_app == NULL)); - elm_object_disabled_set(g->bt_save, (g->sel_app == NULL)); - evas_object_show(g->bt_save); - - if (!_connect_to_daemon(g)) + Eolian_Debug_Class *kl = node->data; + Eolian_Debug_Function *func; + EINA_LIST_FOREACH(kl->functions, itr, func) { - ERR("Failed to connect to server.\n"); - elm_exit(); /* exit the program's main loop,runs in elm_run() */ - } - } - - evas_object_show(g->bx); -} - -static void -_cancel_bt_clicked(void *data, - Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ - _dismiss_inwin(data); - elm_exit(); /* exit the program's main loop that runs in elm_run() */ -} - -static void -_ok_bt_clicked(void *data, - Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ /* Set the IP, PORT, then connect to server */ - _dismiss_inwin(data); - _show_gui(data, EINA_FALSE); -} - -static void -_ofl_bt_clicked(void *data, - Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ /* Disbale entry when working offline */ - _dismiss_inwin(data); - _show_gui(data, EINA_TRUE); -} - -static void -_jump_to_ptr(Gui_Elements *g, uintptr_t ptr) -{ - tree_data_st *td = (g->sel_app->td) ? g->sel_app->td : NULL; - Eina_List *found = NULL; - - if (td && (found = _list_tree_item_pointer_find(td->tree, (uintptr_t) ptr))) - { - _tree_item_show(g->gl, found); - eina_list_free(found); - } -} - -static void -_jump_to_entry_activated(void *data, - Evas_Object *obj, void *event_info EINA_UNUSED) -{ - Gui_Elements *g = data; - long long unsigned int ptr = strtoul(elm_object_text_get(obj), NULL, 16); - - _jump_to_ptr(g, ptr); -} - -static Eina_Bool -_calc_list(Gui_Elements *g) -{ - int count = elm_genlist_items_count(g->hover.dd_list); - - if (count == 0) - return EINA_FALSE; - else - { - Evas_Object *track; - Elm_Object_Item *item; - Evas_Coord w, h; - Eina_List *realized_items; - - realized_items = elm_genlist_realized_items_get(g->hover.dd_list); - if (!realized_items) return EINA_FALSE; - - item = realized_items->data; - track = elm_object_item_track(item); - evas_object_geometry_get(track, NULL, NULL, &w, &h); - elm_object_item_untrack(item); - - eina_list_free(realized_items); - - if (count < 8) - { - elm_scroller_policy_set(g->hover.dd_list, ELM_SCROLLER_POLICY_OFF, - ELM_SCROLLER_POLICY_OFF); - evas_object_size_hint_min_set(g->hover.resize_rect, w, h * count); - } - else - { - elm_scroller_policy_set(g->hover.dd_list, ELM_SCROLLER_POLICY_ON, - ELM_SCROLLER_POLICY_ON); - evas_object_size_hint_min_set(g->hover.resize_rect, w, h * 8); - } - } - - return EINA_TRUE; -} - -static void -_show_hover(void *d, Evas_Object *o EINA_UNUSED, - void *ei EINA_UNUSED) -{ - Gui_Elements *g = d; - - if (!_calc_list(g)) return; - evas_object_show(g->hover.dd_list); - evas_object_show(g->hover.obj); - g->hover.is_expand = EINA_TRUE; -} - -static Evas_Object * -_app_list_min_set(Gui_Elements *g, Evas_Coord w, Evas_Coord h) -{ - Evas_Object *table, *rect; - - table = elm_table_add(g->hover.obj); - - rect = evas_object_rectangle_add(evas_object_evas_get(table)); - evas_object_size_hint_min_set(rect, w, h); - evas_object_color_set(rect, 0, 0, 0, 0); - evas_object_size_hint_align_set(rect, EVAS_HINT_FILL, - EVAS_HINT_FILL); - evas_object_size_hint_weight_set(rect, EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - elm_table_pack(table, rect, 0, 0, 1, 1); - evas_object_size_hint_align_set(g->hover.dd_list, EVAS_HINT_FILL, - EVAS_HINT_FILL); - evas_object_size_hint_weight_set(g->hover.dd_list, EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - - elm_table_pack(table, g->hover.dd_list, 0, 0, 1, 1); - evas_object_show(rect); - - g->hover.resize_rect = rect; - - return table; -} - -static void -_control_buttons_create(Gui_Elements *g, Evas_Object *win) -{ - Evas_Object *highlight_check; - Evas_Object *jump_to_entry, *frame, *table; - - frame = elm_frame_add(gui->bx); - elm_object_style_set(frame, "pad_medium"); - evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_box_pack_end(g->bx, frame); - evas_object_show(frame); - - g->hbx = elm_box_add(g->bx); - evas_object_size_hint_align_set(g->hbx, 0.0, 0.5); - elm_box_horizontal_set(g->hbx, EINA_TRUE); - elm_object_content_set(frame, g->hbx); - elm_box_padding_set(g->hbx, 4, 0); - evas_object_size_hint_align_set(g->hbx, EVAS_HINT_FILL, 0.0); - evas_object_size_hint_weight_set(g->hbx, EVAS_HINT_EXPAND, 0.0); - evas_object_show(g->hbx); - - g->bt_load = elm_button_add(g->hbx); - evas_object_size_hint_align_set(g->bt_load, 0.0, 0.3); - elm_box_pack_end(g->hbx, g->bt_load); - evas_object_show(g->bt_load); - - g->hover.btn = elm_button_add(g->hbx); - elm_object_style_set(g->hover.btn, "hoversel_vertical/default"); - elm_object_text_set(g->hover.btn, SELECT_APP_TEXT); - evas_object_size_hint_align_set(g->hover.btn, 0.0, 0.3); - elm_box_pack_end(g->hbx, g->hover.btn); - evas_object_show(g->hover.btn); - - g->hover.obj = elm_hover_add(win); - elm_object_style_set(g->hover.obj, "hoversel_vertical/default"); - - if (!_app_itc) - { - _app_itc = elm_genlist_item_class_new(); - _app_itc->item_style = "default"; - _app_itc->func.text_get = _app_item_label_get; - _app_itc->func.state_get = NULL; - _app_itc->func.del = NULL; - } - g->hover.dd_list = elm_genlist_add(g->hover.obj); - elm_scroller_policy_set(g->hover.dd_list, ELM_SCROLLER_POLICY_OFF, - ELM_SCROLLER_POLICY_OFF); - elm_object_style_set(g->hover.dd_list, "popup/no_inset_shadow"); - evas_object_size_hint_align_set(g->hover.dd_list, EVAS_HINT_FILL, - EVAS_HINT_FILL); - evas_object_size_hint_weight_set(g->hover.dd_list, EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - table = _app_list_min_set(g, 0, 0); - elm_object_part_content_set(g->hover.obj, "bottom", table); - elm_hover_target_set(g->hover.obj, g->hover.btn); - elm_hover_parent_set(g->hover.obj, win); - - evas_object_smart_callback_add(g->hover.btn, "clicked", - _show_hover, g); - - highlight_check = elm_check_add(g->hbx); - elm_object_text_set(highlight_check , "Highlight"); - elm_check_state_set(highlight_check , do_highlight); - elm_box_pack_end(g->hbx, highlight_check); - evas_object_show(highlight_check); - - evas_object_smart_callback_add(highlight_check, "changed", - _highlight_check_check_changed, g); - - jump_to_entry = elm_entry_add(g->hbx); - elm_entry_scrollable_set(jump_to_entry, EINA_TRUE); - elm_entry_single_line_set(jump_to_entry, EINA_TRUE); - elm_object_part_text_set(jump_to_entry, "guide", "Jump To Pointer"); - evas_object_size_hint_align_set(jump_to_entry, - EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_size_hint_weight_set(jump_to_entry, - EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_box_pack_end(g->hbx, jump_to_entry); - evas_object_show(jump_to_entry); - - evas_object_smart_callback_add(jump_to_entry, "activated", - _jump_to_entry_activated, g); - - Evas_Object *btn_extensions; - - btn_extensions = elm_button_add(g->hbx); - elm_object_text_set(btn_extensions, "Extensions"); - evas_object_smart_callback_add(btn_extensions, "clicked", - _extensions_btn_clicked, NULL); - elm_box_pack_end(g->hbx, btn_extensions); - evas_object_show(btn_extensions); - - Evas_Object *btn_settings; - - btn_settings = elm_button_add(g->hbx); - elm_object_text_set(btn_settings, "Settings"); - evas_object_smart_callback_add(btn_settings, "clicked", - _settings_btn_clicked, NULL); - elm_box_pack_end(g->hbx, btn_settings); - evas_object_show(btn_settings); -} - -static void -_main_list_create(Evas_Object *panes) -{ - gui->gl = elm_genlist_add(panes); - elm_genlist_select_mode_set(gui->gl, ELM_OBJECT_SELECT_MODE_ALWAYS); - evas_object_size_hint_align_set(gui->gl, - EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_size_hint_weight_set(gui->gl, - EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_object_part_content_set(panes, "left", gui->gl); - evas_object_show(gui->gl); - - itc.item_style = "default"; - itc.func.text_get = item_text_get; - itc.func.content_get = item_icon_get; - itc.func.state_get = NULL; - itc.func.del = NULL; - - evas_object_smart_callback_add(gui->gl, - "expand,request", gl_exp_req, gui->gl); - evas_object_smart_callback_add(gui->gl, - "contract,request", gl_con_req, gui->gl); - evas_object_smart_callback_add(gui->gl, - "expanded", gl_exp, gui->gl); - evas_object_smart_callback_add(gui->gl, - "contracted", gl_con, gui->gl); - evas_object_smart_callback_add(gui->gl, - "selected", _gl_selected, gui); - evas_object_smart_callback_add(gui->gl, - "clicked,double", gl_clk_double, gui->gl); -} - -static void -_obj_info_compactable_list_to_buffer(Efl_Dbg_Info *root_eo, char* buffer, unsigned int buffer_size) -{ - Eina_List *l; // Iterator - Eina_Value_List list; // list of the elements in root_eo - eina_value_pget(&(root_eo->value), &list); - Efl_Dbg_Info *eo; // List element - buffer += snprintf(buffer, buffer_size, "%s:", root_eo->name); - EINA_LIST_FOREACH(list.list, l, eo) - { - if (eina_value_type_get(&(eo->value)) == EINA_VALUE_TYPE_UINT64) - { - /* We treat UINT64 as a pointer. */ - uint64_t ptr = 0; - eina_value_get(&(eo->value), &ptr); - buffer += snprintf(buffer, buffer_size, " %s: %llx", eo->name, (unsigned long long) ptr); - } - else - { - char *strval = eina_value_to_string(&(eo->value)); - buffer += snprintf(buffer, buffer_size, " %s: %s", eo->name, strval); - free(strval); - } - } -} - -static Eina_Bool -_obj_info_can_list_be_compacted(Efl_Dbg_Info *root_eo) -{ - Eina_List *l; // Iterator - Eina_Value_List list; // list of the elements in root_eo - Efl_Dbg_Info *eo; // List element - eina_value_pget(&(root_eo->value), &list); - // We check that there is no list into this list. If such list exists, - // we can't compact the list. - int number = 0; - EINA_LIST_FOREACH(list.list, l, eo) - { - number ++; - if (eina_value_type_get(&(eo->value)) == EINA_VALUE_TYPE_LIST) - return EINA_FALSE; - //this is very unreadable - if (number > 10) - return EINA_FALSE; - } - return EINA_TRUE; -} - -static Clouseau_Tree_Item* -_rec_find(Clouseau_Tree_Item *item, unsigned long long ptr) -{ - Eina_List *n; - Clouseau_Tree_Item *it; - - if (item->ptr == ptr) return item; - - EINA_LIST_FOREACH(item->children, n, it) - { - Clouseau_Tree_Item *ret = _rec_find(it, ptr); - - if (ret) return ret; - } - - return NULL; -} - -static void -_send_highlight_ptr(App_Data_St *app, unsigned long long ptr) -{ - Clouseau_Tree_Item *item; - Eina_List *n; - - if (!ptr) return; - - EINA_LIST_FOREACH(app->td->tree, n, item) - { - Clouseau_Tree_Item *ret = _rec_find(item, ptr); - - if (ret) - { - _send_highlight(app, ret); - return; - } - - } - - printf("Error, ptr %p cannot be found\n", (void*)ptr); -} - -static void -_obj_info_gl_selected(void *data EINA_UNUSED, Evas_Object *pobj EINA_UNUSED, - void *event_info) -{ - Efl_Dbg_Info *info = elm_object_item_data_get(event_info); - - /* if the user clicks on a property which is a pointer, try to highlight it*/ - if (eina_value_type_get(&info->value) == EINA_VALUE_TYPE_STRING) - { - const char *string; - - eina_value_get(&info->value, &string); - elm_cnp_selection_set(pobj, ELM_SEL_TYPE_PRIMARY, ELM_SEL_FORMAT_TEXT, string, strlen(string)); - } - if (eina_value_type_get(&info->value) == EINA_VALUE_TYPE_UINT64) - { - uint64_t ptr; - - eina_value_get(&info->value, &ptr); - _send_highlight_ptr(gui->sel_app, ptr); - } - - /* if the user is clicking on a list of pointers its usefull to highlight them */ - if (eina_value_type_get(&info->value) == EINA_VALUE_TYPE_LIST) - { - Eina_Value_List list; - Eina_List *n; - uint64_t ptr; - Efl_Dbg_Info *eo; - - eina_value_pget(&info->value, &list); - - EINA_LIST_FOREACH(list.list, n, eo) - { - if (eina_value_type_get(&(eo->value)) == EINA_VALUE_TYPE_UINT64) - { - uint64_t ptr; - - eina_value_get(&eo->value, &ptr); - _send_highlight_ptr(gui->sel_app, ptr); - } - } - } - return; -} - -static void -_obj_info_gl_exp(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) -{ - Elm_Object_Item *glit = event_info; - - { - Eina_List *l; - Eina_Value_List eo_list; - Efl_Dbg_Info *eo_root, *eo; - eo_root = elm_object_item_data_get(glit); - eina_value_pget(&(eo_root->value), &eo_list); - - EINA_LIST_FOREACH(eo_list.list, l, eo) - { - Elm_Genlist_Item_Type iflag = ELM_GENLIST_ITEM_NONE; - if (eina_value_type_get(&(eo->value)) == EINA_VALUE_TYPE_LIST) - { - if (!_obj_info_can_list_be_compacted(eo)) - iflag = ELM_GENLIST_ITEM_TREE; - } - elm_genlist_item_append(prop_list, &_obj_info_itc, eo, glit, - iflag, _obj_info_gl_selected, NULL); + _Obj_info_node *node_itr = calloc(1, sizeof(*node_itr)); + node_itr->type = CLOUSEAU_OBJ_FUNC; + node_itr->data = func; + + Elm_Genlist_Item *glist = elm_genlist_item_append( + event->object, _obj_info_itc, node_itr, glit, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_tooltip_content_cb_set(glist, _obj_info_tootip, node_itr, NULL); } } } static void -_obj_info_gl_con(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) +_obj_info_contracted_cb(void *data EINA_UNUSED, const Efl_Event *event) { - Elm_Object_Item *glit = event_info; + Elm_Object_Item *glit = event->info; elm_genlist_item_subitems_clear(glit); } static void -_obj_info_gl_exp_req(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) +_obj_info_item_del(void *data, Evas_Object *obj EINA_UNUSED) { - Elm_Object_Item *glit = event_info; + _Obj_info_node *node = data; + free(node); +} + +static void +_eolian_type_to_string(const Eolian_Type *param_eolian_type, char *c_type) +{ + c_type[0] = '\0'; + if ((eolian_type_type_get(param_eolian_type) == EOLIAN_TYPE_REGULAR)//if its one of the base type or alias + && !eolian_type_base_type_get(param_eolian_type)) + { + sprintf(c_type, "%s", eolian_type_name_get(param_eolian_type)); + } + else + { + const Eolian_Type *base = eolian_type_base_type_get(param_eolian_type); + if ((eolian_type_type_get(base) == EOLIAN_TYPE_REGULAR) || + (eolian_type_type_get(base) == EOLIAN_TYPE_CLASS)) + { + sprintf(c_type, "%s *", eolian_type_full_name_get(base)); + } + else if (eolian_type_type_get(base) == EOLIAN_TYPE_VOID) + { + sprintf(c_type, "void *"); + } +#if 0 + else if (eolian_type_type_get(base) == EOLIAN_TYPE_ENUM) + { + sprintf(c_type, "%s", eolian_type_full_name_get(param_eolian_type)); + } + else if (eolian_type_type_get(base) == EOLIAN_TYPE_ALIAS) + { + sprintf(c_type, "%s", eolian_type_full_name_get(base)); + } +#endif + else + { + sprintf(c_type, "%s *", eolian_type_is_const(base) ? "const " : ""); + } + } +} + +static int +_eolian_value_to_string(Eolian_Debug_Value *value, char *buffer, int max) +{ + switch(value->type) + { + case EOLIAN_DEBUG_STRING: return snprintf(buffer, max, "%s ", + (char *)value->value.value); + case EOLIAN_DEBUG_POINTER: return snprintf(buffer, max, "%p ", + (void *)value->value.value); + case EOLIAN_DEBUG_CHAR: return snprintf(buffer, max, "%c ", + (char)value->value.value); + case EOLIAN_DEBUG_INT: return snprintf(buffer, max, "%d ", + (int)value->value.value); + case EOLIAN_DEBUG_SHORT: return snprintf(buffer, max, "%u ", + (unsigned int)value->value.value); + case EOLIAN_DEBUG_DOUBLE: return snprintf(buffer, max, "%f ", + (double)value->value.value); + case EOLIAN_DEBUG_BOOLEAN: return snprintf(buffer, max, "%s ", + (value->value.value ? "true" : "false")); + case EOLIAN_DEBUG_LONG: return snprintf(buffer, max, "%ld ", + (long)value->value.value); + case EOLIAN_DEBUG_UINT: return snprintf(buffer, max, "%u ", + (unsigned int)value->value.value); + default: return snprintf(buffer, max, "%lX ", value->value.value); + } +} + +#define _MAX_LABEL 2000 +static void +_obj_info_params_to_string(_Obj_info_node *node, char *buffer, Eina_Bool full) +{ + Eina_List *itr; + int buffer_size = 0; + buffer_size += snprintf(buffer + buffer_size, + _MAX_LABEL - buffer_size, "%s: ", + eolian_function_name_get(((Eolian_Debug_Function *)(node->data))->efunc)); + buffer[0] = toupper(buffer[0]); + + Eolian_Debug_Function *func = (Eolian_Debug_Function *)(node->data); + Eolian_Debug_Parameter *param; + EINA_LIST_FOREACH(func->params, itr, param) + { + if(full) + { + char c_type[_MAX_LABEL]; + _eolian_type_to_string(eolian_parameter_type_get(param->etype), c_type); + buffer_size += snprintf(buffer + buffer_size, + _MAX_LABEL - buffer_size, "%s ", c_type); + } + buffer_size += snprintf(buffer + buffer_size, + _MAX_LABEL - buffer_size, "%s: ", eolian_parameter_name_get(param->etype)); + buffer_size += _eolian_value_to_string(&(param->value), + buffer + buffer_size, _MAX_LABEL - buffer_size); + if(full) + buffer_size += snprintf(buffer + buffer_size, + _MAX_LABEL - buffer_size, "(%lX) ", param->value.value.value); + + } + if(func->params == NULL) + { + if(full) + { + char c_type[_MAX_LABEL]; + _eolian_type_to_string(func->ret.etype, c_type); + buffer_size += snprintf(buffer + buffer_size, + _MAX_LABEL - buffer_size, "%s ", c_type); + } + buffer_size += snprintf(buffer + buffer_size, + _MAX_LABEL - buffer_size, "%s: ", ""); + buffer_size += _eolian_value_to_string(&(func->ret.value), + buffer + buffer_size, _MAX_LABEL - buffer_size); + if(full) + buffer_size += snprintf(buffer + buffer_size, + _MAX_LABEL - buffer_size, "(%lX) ", func->ret.value.value.value); + } +} + +static Evas_Object * +_obj_info_tootip(void *data EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, + Evas_Object *tt, + void *item EINA_UNUSED) +{ + Evas_Object *l = elm_label_add(tt); + char buffer[_MAX_LABEL]; + _obj_info_params_to_string(data, buffer, EINA_TRUE); + elm_object_text_set(l, buffer); + elm_label_line_wrap_set(l, ELM_WRAP_NONE); + + return l; +} + +static char * +_obj_info_item_label_get(void *data, Evas_Object *obj EINA_UNUSED, + const char *part EINA_UNUSED) +{ + _Obj_info_node *node = data; + + if(node->type == CLOUSEAU_OBJ_CLASS) + { + return strdup(eolian_class_full_name_get(((Eolian_Debug_Class *)(node->data))->ekl)); + } + else if(node->type == CLOUSEAU_OBJ_FUNC) + { + char buffer[_MAX_LABEL]; + _obj_info_params_to_string(node, buffer, EINA_FALSE); + return strdup(buffer); + } + return NULL; +} +#undef _MAX_LABEL + +static Eina_Bool +_debug_obj_info_cb(Eina_Debug_Session *session EINA_UNUSED, int src EINA_UNUSED, + void *buffer, int size) +{ + if(_obj_info) + { + elm_genlist_clear(_main_widgets->object_infos_list); + eolian_debug_object_information_free(_obj_info); + _obj_info = NULL; + } + _obj_info = eolian_debug_object_information_decode(buffer, size); + + Eolian_Debug_Class *kl; + Eina_List *kl_itr; + EINA_LIST_FOREACH(_obj_info->classes, kl_itr, kl) + { + Elm_Genlist_Item_Type type = ELM_GENLIST_ITEM_TREE; + _Obj_info_node *node = NULL; + node = calloc(1, sizeof(*node)); + node->type = CLOUSEAU_OBJ_CLASS; + node->data = kl; + + Elm_Object_Item *glg = elm_genlist_item_append( + _main_widgets->object_infos_list, _obj_info_itc, + (void *)node, NULL, + type, + NULL, NULL); + elm_genlist_item_expanded_set(glg, EINA_FALSE); + } + + return EINA_TRUE; +} + +static void +_objs_expand_request_cb(void *data EINA_UNUSED, const Efl_Event *event) +{ + Elm_Object_Item *glit = event->info; elm_genlist_item_expanded_set(glit, EINA_TRUE); } static void -_obj_info_gl_con_req(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) +_objs_contract_request_cb(void *data EINA_UNUSED, const Efl_Event *event) { - Elm_Object_Item *glit = event_info; + Elm_Object_Item *glit = event->info; elm_genlist_item_expanded_set(glit, EINA_FALSE); } -static Evas_Object * -_obj_info_gl_item_icon_get(void *data EINA_UNUSED, Evas_Object *parent EINA_UNUSED, - const char *part EINA_UNUSED) +static void +_objs_sel_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) { - return NULL; + Elm_Object_Item *glit = event_info; + _Obj_list_node *info_node = elm_object_item_data_get(glit); + + uint64_t ptr = (uint64_t)info_node->info->ptr; + + printf("Sending Eolian get request for Eo object[%lX]\n", info_node->info->ptr); + elm_genlist_clear(_main_widgets->object_infos_list); + eina_debug_session_send(_session, _selected_app, _obj_info_opcode, &ptr, sizeof(uint64_t)); + eina_debug_session_send(_session, _selected_app, _obj_highlight_opcode, &ptr, sizeof(uint64_t)); +} + +static void +_objs_expanded_cb(void *data EINA_UNUSED, const Efl_Event *event) +{ + Eina_List *itr; + Elm_Object_Item *glit = event->info; + _Obj_list_node *info_node = elm_object_item_data_get(glit), *it_data; + EINA_LIST_FOREACH(info_node->children, itr, it_data) + { + Elm_Object_Item *nitem = elm_genlist_item_append(event->object, _objs_itc, + it_data, glit, + it_data->children ? ELM_GENLIST_ITEM_TREE : ELM_GENLIST_ITEM_NONE, + _objs_sel_cb, NULL); + elm_genlist_item_expanded_set(nitem, EINA_FALSE); + } +} + +static void +_objs_contracted_cb(void *data EINA_UNUSED, const Efl_Event *event) +{ + Elm_Object_Item *glit = event->info; + elm_genlist_item_subitems_clear(glit); } static char * -_obj_info_gl_item_text_get(void *data, Evas_Object *obj EINA_UNUSED, +_objs_item_label_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED) { - Efl_Dbg_Info *eo = data; - char buf[1024] = ""; - if (eina_value_type_get(&(eo->value)) == EINA_VALUE_TYPE_LIST) - { - if (_obj_info_can_list_be_compacted(eo)) - _obj_info_compactable_list_to_buffer(eo, buf, sizeof(buf)); - else - snprintf(buf, sizeof(buf), "%s", eo->name); - } - else if (eina_value_type_get(&(eo->value)) == EINA_VALUE_TYPE_UINT64) - { - /* We treat UINT64 as a pointer. */ - - uint64_t ptr = 0; - eina_value_get(&(eo->value), &ptr); - snprintf(buf, sizeof(buf), "%s: %llx", eo->name, (unsigned long long) ptr); - } - else - { - char *strval = eina_value_to_string(&(eo->value)); - snprintf(buf, sizeof(buf), "%s: %s", eo->name, strval); - free(strval); - } - + _Obj_list_node *info_node = data; + char buf[128]; + sprintf(buf, "%s %lX", info_node->info->kl_name, info_node->info->ptr); return strdup(buf); } -// Classes are not displayed in the same way as infos. -// Infos lists can be compacted, not class infos. -static char * -_class_info_gl_item_text_get(void *data, Evas_Object *obj EINA_UNUSED, - const char *part EINA_UNUSED) +Eina_Bool +screenshot_req_cb(void *data EINA_UNUSED, Eo *obj, const Efl_Event *event EINA_UNUSED, void *event_info EINA_UNUSED) { - Efl_Dbg_Info *eo = data; - return strdup(eo->name); + _Obj_list_node *info_node = NULL; + info_node = efl_key_data_get(obj, "__info_node"); + + printf("show screenshot of obj %s %lX\n", info_node->info->kl_name, info_node->info->ptr); + return EINA_TRUE; } static Evas_Object * -_clouseau_object_information_list_add(Evas_Object *parent) +_objs_item_content_get(void *data, Evas_Object *obj, const char *part) { - prop_list = elm_genlist_add(parent); - - _class_info_itc.item_style = "default"; - _class_info_itc.func.text_get = _class_info_gl_item_text_get; - _class_info_itc.func.content_get = _obj_info_gl_item_icon_get; - _class_info_itc.func.state_get = NULL; - _class_info_itc.func.del = NULL; - - _obj_info_itc.item_style = "default"; - _obj_info_itc.func.text_get = _obj_info_gl_item_text_get; - _obj_info_itc.func.content_get = _obj_info_gl_item_icon_get; - _obj_info_itc.func.state_get = NULL; - _obj_info_itc.func.del = NULL; - - evas_object_smart_callback_add(prop_list, "expand,request", _obj_info_gl_exp_req, - prop_list); - evas_object_smart_callback_add(prop_list, "contract,request", _obj_info_gl_con_req, - prop_list); - evas_object_smart_callback_add(prop_list, "expanded", _obj_info_gl_exp, prop_list); - evas_object_smart_callback_add(prop_list, "contracted", _obj_info_gl_con, prop_list); - evas_object_smart_callback_add(prop_list, "selected", _obj_info_gl_selected, NULL); - - return prop_list; + if(!strcmp(part, "elm.swallow.end")) + { + Gui_Screenshot_Button_Widgets *wdgs = gui_screenshot_button_create(obj); + elm_object_tooltip_text_set(wdgs->screenshot_button, "Show App Screenshot"); + efl_key_data_set(wdgs->screenshot_button, "__info_node", data); + return wdgs->screenshot_button; + } + return NULL; } static void -_property_list_create(Evas_Object *panes) +_objs_nodes_free(Eina_List *parents) { - Evas_Object *o= NULL; - gui->prop_list = o = _clouseau_object_information_list_add(panes); - evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + _Obj_list_node *info_node; - elm_object_part_content_set(panes, "right", o); - evas_object_show(o); -} - -static void -print_help(void) -{ - printf("Usage of clouseau_client:\n"); - printf(" -f will start clouseau_client in offline mode with the specified file loaded.\n"); - printf(" -a will start clouseau_client, and connect to the specified adress.\n"); - printf(" Only one file or one adress is allowed\n"); - exit(-1); -} -static void -_parse_arguments(int argc, char **argv, char **file) -{ - for (int i = 1; i < argc; ++i) + EINA_LIST_FREE(parents, info_node) { - if (!strcmp(argv[i], "-f")) + if (info_node->info) free(info_node->info->kl_name); + free(info_node->info); + _objs_nodes_free(info_node->children); + free(info_node); + } +} + +static void +_hoversel_selected_app(void *data, + Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + _selected_app = (int)(long)data; + + if(_objs_list_tree) + { + _objs_nodes_free(_objs_list_tree); + _objs_list_tree = NULL; + elm_genlist_clear(_main_widgets->objects_list); + elm_genlist_clear(_main_widgets->object_infos_list); + } + + eina_debug_session_send(_session, _selected_app, _module_init_opcode, "eo", 11); + eina_debug_session_send(_session, _selected_app, _module_init_opcode, "eolian", 7); + eina_debug_session_send(_session, _selected_app, _module_init_opcode, "evas", 5); + _pending_add(&_eo_list_opcode, NULL, 0); +} + +static Eina_Bool +_clients_info_added_cb(Eina_Debug_Session *session EINA_UNUSED, int src EINA_UNUSED, void *buffer, int size) +{ + char *buf = buffer; + while(size) + { + int cid, pid, len; + EXTRACT(buf, &cid, sizeof(int)); + EXTRACT(buf, &pid, sizeof(int)); + if(pid != getpid()) { - if (i+1 >= argc) print_help(); - *file = argv[i+1]; - i++; + char option[100]; + snprintf(option, 90, "%s [%d]", buf, pid); + elm_hoversel_item_add(_main_widgets->apps_selector, + option, "home", ELM_ICON_STANDARD, _hoversel_selected_app, + (void *)(long)cid); } - else if (!strcmp(argv[i], "-a")) + len = strlen(buf) + 1; + buf += len; + size -= (2 * sizeof(int) + len); + } + return EINA_TRUE; +} + +static Eina_Bool +_clients_info_deleted_cb(Eina_Debug_Session *session EINA_UNUSED, int src EINA_UNUSED, void *buffer, int size) +{ + char *buf = buffer; + if(size >= (int)sizeof(int)) + { + int cid; + EXTRACT(buf, &cid, sizeof(int)); + + const Eina_List *items = elm_hoversel_items_get(_main_widgets->apps_selector); + const Eina_List *l; + Elm_Object_Item *hoversel_it; + + EINA_LIST_FOREACH(items, l, hoversel_it) { - if (i+1 >= argc) print_help(); - gui->address = strdup(argv[i+1]); - i++; + if((int)(long)elm_object_item_data_get(hoversel_it) == cid) + { + elm_object_item_del(hoversel_it); + break; + } + } + } + return EINA_TRUE; +} + +static Eina_Bool +_eo_objects_list_cb(Eina_Debug_Session *session EINA_UNUSED, int src EINA_UNUSED, void *buffer, int size) +{ + Eina_List *objs = efl_debug_list_response_decode(buffer, size); + Obj_Info *info; + + Eina_Hash *objects_hash = NULL; + Eina_List *l = NULL; + objects_hash = eina_hash_pointer_new(NULL); + _Obj_list_node *info_node; + + /* Add all objects to hash table */ + EINA_LIST_FOREACH(objs, l, info) + { + info_node = calloc(1, sizeof(_Obj_list_node)); + info_node->info = info; + info_node->children = NULL; + eina_hash_add(objects_hash, &(info_node->info->ptr), info_node); + } + + /* Fill children lists */ + EINA_LIST_FOREACH(objs, l, info) + { + _Obj_list_node *info_parent = eina_hash_find(objects_hash, &(info->parent)); + info_node = eina_hash_find(objects_hash, &(info->ptr)); + + if(info_parent) + info_parent->children = eina_list_append(info_parent->children, info_node); + else + _objs_list_tree = eina_list_append(_objs_list_tree, info_node); + } + + /* Add to Genlist */ + EINA_LIST_FOREACH(_objs_list_tree, l, info_node) + { + Elm_Object_Item *glg = elm_genlist_item_append( + _main_widgets->objects_list, _objs_itc, + (void *)info_node, NULL, + info_node->children ? ELM_GENLIST_ITEM_TREE : ELM_GENLIST_ITEM_NONE, + _objs_sel_cb, NULL); + if (info_node->children) elm_genlist_item_expanded_set(glg, EINA_FALSE); + } + + /* Free allocated memory */ + eina_hash_free(objects_hash); + eina_list_free(objs); + + return EINA_TRUE; +} + +static void +_ecore_thread_dispatcher(void *data) +{ + eina_debug_dispatch(_session, data); +} + +Eina_Bool +_disp_cb(Eina_Debug_Session *session EINA_UNUSED, void *buffer) +{ + ecore_main_loop_thread_safe_call_async(_ecore_thread_dispatcher, buffer); + return EINA_TRUE; +} + +static Eina_Bool +_module_initted(Eina_Debug_Session *session EINA_UNUSED, int src EINA_UNUSED, void *buffer, int size) +{ + if (size > 0) + { + if (!strcmp(buffer, "eo")) _consume(_eo_list_opcode); + } + return EINA_TRUE; +} + +static void +_post_register_handle(Eina_Bool flag) +{ + if(!flag) return; + eina_debug_session_dispatch_override(_session, _disp_cb); + eina_debug_session_send(_session, 0, _cl_stat_reg_opcode, NULL, 0); +} + +static Eina_Bool +_mkdir(const char *dir) +{ + if (!ecore_file_exists(dir)) + { + Eina_Bool success = ecore_file_mkdir(dir); + if (!success) + { + printf("Cannot create a config folder \"%s\"\n", dir); + return EINA_FALSE; + } + } + return EINA_TRUE; +} + +static void +_profile_eet_load() +{ + if (_profile_edd) return; + Eet_Data_Descriptor_Class eddc; + + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Clouseau_Profile); + _profile_edd = eet_data_descriptor_stream_new(&eddc); + +#define CFG_ADD_BASIC(member, eet_type)\ + EET_DATA_DESCRIPTOR_ADD_BASIC\ + (_profile_edd, Clouseau_Profile, # member, member, eet_type) + + CFG_ADD_BASIC(name, EET_T_STRING); + CFG_ADD_BASIC(command, EET_T_STRING); + CFG_ADD_BASIC(script, EET_T_STRING); + CFG_ADD_BASIC(type, EET_T_INT); + +#undef CFG_ADD_BASIC +} + +static void +_config_load() +{ + char path[1024], *filename; + sprintf(path, "%s/clouseau", efreet_config_home_get()); + if (!_mkdir(path)) return; + sprintf(path, "%s/clouseau/profiles", efreet_config_home_get()); + if (!_mkdir(path)) return; + Eina_List *files = ecore_file_ls(path), *itr; + if (files) _profile_eet_load(); + EINA_LIST_FOREACH(files, itr, filename) + { + sprintf(path, "%s/clouseau/profiles/%s", efreet_config_home_get(), filename); + Eet_File *file = eet_open(path, EET_FILE_MODE_READ); + Clouseau_Profile *p = eet_data_read(file, _profile_edd, _PROFILE_EET_ENTRY); + p->file_name = eina_stringshare_add(filename); + eet_close(file); + _profiles = eina_list_append(_profiles, p); + } +} + +static Clouseau_Profile * +_profile_find(const char *name) +{ + Eina_List *itr; + Clouseau_Profile *p; + EINA_LIST_FOREACH(_profiles, itr, p) + if (p->name == name || !strcmp(p->name, name)) return p; + return NULL; +} + +static void +_profile_save(const Clouseau_Profile *p) +{ + char path[1024]; + if (!p) return; + sprintf(path, "%s/clouseau/profiles/%s", efreet_config_home_get(), p->file_name); + Eet_File *file = eet_open(path, EET_FILE_MODE_WRITE); + _profile_eet_load(); + eet_data_write(file, _profile_edd, _PROFILE_EET_ENTRY, p, EINA_TRUE); + eet_close(file); + _profiles = eina_list_append(_profiles, p); +} + +static const Eina_Debug_Opcode ops[] = +{ + {"daemon/observer/client/register", &_cl_stat_reg_opcode, NULL}, + {"daemon/observer/slave_added", NULL, _clients_info_added_cb}, + {"daemon/observer/slave_deleted", NULL, _clients_info_deleted_cb}, + {"module/init", &_module_init_opcode, &_module_initted}, + {"eo/objects_list", &_eo_list_opcode, &_eo_objects_list_cb}, + {"eolian/object/info_get", &_obj_info_opcode, &_debug_obj_info_cb}, + {"evas/object/highlight", &_obj_highlight_opcode, NULL}, + {NULL, NULL, NULL} +}; + +static void +_profile_sel_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) +{ + Elm_Object_Item *glit = event_info; + _selected_profile = glit ? elm_object_item_data_get(glit) : NULL; + elm_object_disabled_set(_profiles_wdgs->profile_ok_button, !_selected_profile); + elm_object_disabled_set(_profiles_wdgs->profile_delete_button, !_selected_profile); +} + +static Eina_List * +_parse_script(const char *script) +{ + Eina_List *lines = NULL; + while (script && *script) + { + char *tmp = strchr(script, '\n'); + Eina_Stringshare *line; + if (tmp) + { + line = eina_stringshare_add_length(script, tmp - script); + script = tmp + 1; } else { - printf("Cannot undestand argument %s\n", argv[i]); - print_help(); + line = eina_stringshare_add(script); + script = NULL; } + lines = eina_list_append(lines, line); } - - if (*file && gui->address) - { - printf("Only file or adress is allowed\n"); - exit(-1); - } + return lines; } -int -main(int argc, char **argv) -{ /* Create Client Window */ - const char *log_dom = "clouseau_client"; - char *file = NULL; - _clouseau_client_log_dom = eina_log_domain_register(log_dom, EINA_COLOR_LIGHTBLUE); - if (_clouseau_client_log_dom < 0) +static void +_profile_load() +{ + switch (_selected_profile->type) { - EINA_LOG_ERR("Could not register log domain: %s", log_dom); - return 3; + case CLOUSEAU_PROFILE_LOCAL: + if (!(_session = eina_debug_local_connect(EINA_TRUE))) + { + fprintf(stderr, "ERROR: Cannot connect to debug daemon.\n"); + elm_exit(); + } + break; + case CLOUSEAU_PROFILE_SHELL_REMOTE: +#if 0 + eina_debug_session_basic_codec_add(_session, EINA_DEBUG_CODEC_SHELL); + Eina_List *script_lines = _parse_script(_selected_profile->script); + if (!eina_debug_shell_remote_connect(_session, _selected_profile->command, script_lines)) + { + fprintf(stderr, "ERROR: Cannot connect to shell remote debug daemon.\n"); + elm_exit(); + } +#endif + break; + default: + { + printf("Profile type %d not supported\n", _selected_profile->type); + elm_exit(); + } } - Evas_Object *win, *panes, *frame; + eina_debug_opcodes_register(_session, ops, _post_register_handle); +} - /* For inwin popup */ - Evas_Object *lb, *bxx, *bt_bx, *bt_ok, *bt_cancel; - Evas_Object *bt_ofl; /* work_offline button */ - void *st; +static void _profile_type_selected_cb(void *data, Evas_Object *obj, void *event_info) +{ + Gui_New_Profile_Win_Widgets *wdgs = NULL; + wdgs = efl_key_data_get(obj, "_wdgs"); + elm_object_text_set(obj, elm_object_item_text_get(event_info)); + Clouseau_Profile_Type type = (Clouseau_Profile_Type) data; + if (type == CLOUSEAU_PROFILE_SHELL_REMOTE) + { + elm_object_disabled_set(wdgs->new_profile_command, EINA_FALSE); + elm_object_disabled_set(wdgs->new_profile_script, EINA_FALSE); + } + else + { + elm_object_text_set(wdgs->new_profile_command, NULL); + elm_object_text_set(wdgs->new_profile_script, NULL); + elm_object_disabled_set(wdgs->new_profile_command, EINA_TRUE); + elm_object_disabled_set(wdgs->new_profile_script, EINA_TRUE); + } + efl_key_data_set(wdgs->new_profile_type_selector, "_current_type", data); +} - gui = calloc(1, sizeof(Gui_Elements)); +Eina_Bool +_new_profile_save_cb(void *data, Eo *save_bt, const Efl_Event *event EINA_UNUSED, void *event_info EINA_UNUSED) +{ + Gui_New_Profile_Win_Widgets *wdgs = NULL; + Clouseau_Profile *p = NULL; + wdgs = efl_key_data_get(save_bt, "_wdgs"); + data = NULL; + data = efl_key_data_get(wdgs->new_profile_type_selector, "_current_type"); + if (!data) return EINA_TRUE; /* No type selected yet -> nothing done */ + Clouseau_Profile_Type type = (Clouseau_Profile_Type) data; + const char *name = elm_object_text_get(wdgs->new_profile_name); + const char *cmd = elm_object_text_get(wdgs->new_profile_command); + const char *script = elm_entry_markup_to_utf8(elm_object_text_get(wdgs->new_profile_script)); + if (!name || !*name) return EINA_TRUE; + if (type == CLOUSEAU_PROFILE_SHELL_REMOTE) + { + if (!cmd || !*cmd) return EINA_TRUE; + } + p = calloc(1, sizeof(*p)); + p->file_name = eina_stringshare_add(name); /* FIXME: Have to format name to conform to file names convention */ + p->name = eina_stringshare_add(name); + p->type = type; + p->command = eina_stringshare_add(cmd); + p->script = eina_stringshare_add(script); + _profile_save(p); + efl_del(wdgs->new_profile_win); + p->item = elm_genlist_item_append(_profiles_wdgs->profiles_list, _profiles_itc, p, + NULL, ELM_GENLIST_ITEM_NONE, _profile_sel_cb, NULL); + return EINA_TRUE; +} - setenv("ELM_CLOUSEAU", "0", 1); - elm_init(argc, argv); +void +gui_new_profile_win_create_done(Gui_New_Profile_Win_Widgets *wdgs) + { + efl_key_data_set(wdgs->new_profile_type_selector, "_wdgs", wdgs); + elm_hoversel_hover_parent_set(wdgs->new_profile_type_selector, wdgs->new_profile_win); + elm_hoversel_item_add(wdgs->new_profile_type_selector, "Local connection", NULL, ELM_ICON_NONE, _profile_type_selected_cb, (void *)CLOUSEAU_PROFILE_LOCAL); + elm_hoversel_item_add(wdgs->new_profile_type_selector, "Shell remote", NULL, ELM_ICON_NONE, _profile_type_selected_cb, (void *)CLOUSEAU_PROFILE_SHELL_REMOTE); - _parse_arguments(argc, argv, &file); + efl_key_data_set(wdgs->new_profile_save_button, "_wdgs", wdgs); + efl_key_data_set(wdgs->new_profile_cancel_button, "_wdgs", wdgs); +} - clouseau_cfg_init(PACKAGE_NAME); - clouseau_cfg_load(); +static char *_profile_item_label_get(void *data, Evas_Object *obj EINA_UNUSED, + const char *part EINA_UNUSED) +{ + Clouseau_Profile *p = data; + return strdup(p->name); +} - _modules_init(); +Eina_Bool +_profile_win_close_cb(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Efl_Event *event EINA_UNUSED, void *event_info EINA_UNUSED) +{ + efl_del(_profiles_wdgs->profiles_win); + _profiles_wdgs = NULL; + _profile_load(); + return EINA_TRUE; +} - gui->win = win = elm_win_util_standard_add("client", CLIENT_NAME); - elm_win_autodel_set(win, EINA_TRUE); - _titlebar_string_set(gui, EINA_FALSE); +static void +_profile_item_del(void *data, Evas_Object *obj EINA_UNUSED) +{ + Clouseau_Profile *p = data; + p->item = NULL; +} - gui->bx = elm_box_add(win); - evas_object_size_hint_weight_set(gui->bx, - EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(gui->bx, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_win_resize_object_add(win, gui->bx); - - _control_buttons_create(gui, win); - - frame = elm_frame_add(gui->bx); - elm_object_style_set(frame, "pad_medium"); - evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_box_pack_end(gui->bx, frame); - evas_object_show(frame); - - panes = elm_panes_add(gui->bx); - evas_object_size_hint_weight_set(panes, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(panes, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_object_content_set(frame, panes); - evas_object_show(panes); - - _main_list_create(panes); - _property_list_create(panes); - - /* Add progress wheel */ - gui->pb = elm_progressbar_add(win); - elm_object_style_set(gui->pb, "wheel"); - elm_object_text_set(gui->pb, "Style: wheel"); - elm_progressbar_pulse_set(gui->pb, EINA_TRUE); - elm_progressbar_pulse(gui->pb, EINA_FALSE); - evas_object_size_hint_align_set(gui->pb, 0.5, 0.0); - evas_object_size_hint_weight_set(gui->pb, - EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_win_resize_object_add(win, gui->pb); - - /* Resize and show main window */ - evas_object_resize(win, 500, 500); - evas_object_show(win); - - evas_object_smart_callback_add(win, "delete,request", client_win_del, NULL); +Eina_Bool +_profile_del_cb(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Efl_Event *event EINA_UNUSED, void *event_info EINA_UNUSED) +{ + if (_selected_profile) + { + char path[1024]; + sprintf(path, "%s/clouseau/profiles/%s", efreet_config_home_get(), _selected_profile->file_name); + remove(path); + elm_object_item_del(_selected_profile->item); + _profiles = eina_list_remove(_profiles, _selected_profile); + eina_stringshare_del(_selected_profile->file_name); + eina_stringshare_del(_selected_profile->name); + free(_selected_profile); + _selected_profile = NULL; + } + _profile_sel_cb(NULL, NULL, NULL); + return EINA_TRUE; +} +EAPI_MAIN int +elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED) +{ eina_init(); - ecore_init(); - ecore_con_init(); - clouseau_data_init(); + eolian_init(); - if (gui->address) + _config_load(); + if (!_profile_find("Local connection")) { - _show_gui(gui, EINA_FALSE); + Clouseau_Profile *p = calloc(1, sizeof(*p)); + p->file_name = "local"; + p->name = eina_stringshare_add("Local connection"); + p->type = CLOUSEAU_PROFILE_LOCAL; + _profile_save(p); } - else if (file) + + if (!_profiles_itc) { - _show_gui(gui, EINA_TRUE); - _load_file(file); + _profiles_itc = elm_genlist_item_class_new(); + _profiles_itc->item_style = "default"; + _profiles_itc->func.text_get = _profile_item_label_get; + _profiles_itc->func.del = _profile_item_del; } - else + + eolian_directory_scan(EOLIAN_EO_DIR); + elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); + _main_widgets = gui_gui_get()->main_win; + + //Init objects Genlist + if (!_objs_itc) { - /* START - Popup to get IP, PORT from user */ - gui->connect_inwin = elm_win_inwin_add(win); - evas_object_show(gui->connect_inwin); + _objs_itc = elm_genlist_item_class_new(); + _objs_itc->item_style = "default"; + _objs_itc->func.text_get = _objs_item_label_get; + _objs_itc->func.content_get = _objs_item_content_get; + _objs_itc->func.state_get = NULL; + _objs_itc->func.del = NULL; + } + efl_event_callback_add(_main_widgets->objects_list, ELM_GENLIST_EVENT_EXPAND_REQUEST, _objs_expand_request_cb, NULL); + efl_event_callback_add(_main_widgets->objects_list, ELM_GENLIST_EVENT_CONTRACT_REQUEST, _objs_contract_request_cb, NULL); + efl_event_callback_add(_main_widgets->objects_list, ELM_GENLIST_EVENT_EXPANDED, _objs_expanded_cb, NULL); + efl_event_callback_add(_main_widgets->objects_list, ELM_GENLIST_EVENT_CONTRACTED, _objs_contracted_cb, NULL); - bxx = elm_box_add(gui->connect_inwin); - evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_show(bxx); + //Init object info Genlist + if (!_obj_info_itc) + { + _obj_info_itc = elm_genlist_item_class_new(); + _obj_info_itc->item_style = "default"; + _obj_info_itc->func.text_get = _obj_info_item_label_get; + _obj_info_itc->func.content_get = NULL; + _obj_info_itc->func.state_get = NULL; + _obj_info_itc->func.del = _obj_info_item_del; + } + efl_event_callback_add(_main_widgets->object_infos_list, ELM_GENLIST_EVENT_EXPAND_REQUEST, _obj_info_expand_request_cb, NULL); + efl_event_callback_add(_main_widgets->object_infos_list, ELM_GENLIST_EVENT_CONTRACT_REQUEST, _obj_info_contract_request_cb, NULL); + efl_event_callback_add(_main_widgets->object_infos_list, ELM_GENLIST_EVENT_EXPANDED, _obj_info_expanded_cb, NULL); + efl_event_callback_add(_main_widgets->object_infos_list, ELM_GENLIST_EVENT_CONTRACTED, _obj_info_contracted_cb, NULL); - lb = elm_label_add(bxx); - evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, 0.0); - elm_object_text_set(lb, "Enter remote address[:port]"); - elm_box_pack_end(bxx, lb); - evas_object_show(lb); - - /* Single line selected entry */ - gui->en = elm_entry_add(bxx); - elm_entry_scrollable_set(gui->en, EINA_TRUE); - evas_object_size_hint_weight_set(gui->en, - EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(gui->en, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_object_style_set(gui->connect_inwin, "minimal_vertical"); - elm_scroller_policy_set(gui->en, ELM_SCROLLER_POLICY_OFF, - ELM_SCROLLER_POLICY_OFF); - elm_object_text_set(gui->en, LOCALHOST); - elm_entry_single_line_set(gui->en, EINA_TRUE); - elm_entry_select_all(gui->en); - evas_object_smart_callback_add(gui->en, "activated", _ok_bt_clicked, (void *)gui); - elm_box_pack_end(bxx, gui->en); - evas_object_show(gui->en); - elm_object_focus_set(gui->en, EINA_TRUE); - - bt_bx = elm_box_add(bxx); - elm_box_horizontal_set(bt_bx, EINA_TRUE); - elm_box_homogeneous_set(bt_bx, EINA_TRUE); - evas_object_size_hint_align_set(bt_bx, 0.5, 0.5); - evas_object_size_hint_weight_set(bt_bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_show(bt_bx); - elm_box_pack_end(bxx, bt_bx); - - /* Add the cancel button */ - bt_cancel = elm_button_add(bt_bx); - elm_object_text_set(bt_cancel, "Cancel"); - evas_object_smart_callback_add(bt_cancel, "clicked", - _cancel_bt_clicked, (void *) gui); - - elm_box_pack_end(bt_bx, bt_cancel); - evas_object_show(bt_cancel); - - /* Add the OK button */ - bt_ok = elm_button_add(bt_bx); - elm_object_text_set(bt_ok, "OK"); - evas_object_smart_callback_add(bt_ok, "clicked", - _ok_bt_clicked, (void *) gui); - - elm_box_pack_end(bt_bx, bt_ok); - evas_object_show(bt_ok); - - bt_ofl = elm_button_add(bt_bx); - elm_object_text_set(bt_ofl, "Work Offline"); - evas_object_smart_callback_add(bt_ofl, "clicked", - _ofl_bt_clicked, (void *) gui); - - elm_box_pack_end(bt_bx, bt_ofl); - evas_object_show(bt_ofl); - - elm_win_inwin_content_set(gui->connect_inwin, bxx); - /* END - Popup to get IP, PORT from user */ + if (1) /* if a profile is not given as parameter, we show the profiles window */ + { + _profiles_wdgs = gui_profiles_win_create(_main_widgets->main_win); + elm_win_modal_set(_profiles_wdgs->profiles_win, EINA_TRUE); + Eina_List *itr; + Clouseau_Profile *p; + EINA_LIST_FOREACH(_profiles, itr, p) + p->item = elm_genlist_item_append(_profiles_wdgs->profiles_list, _profiles_itc, p, + NULL, ELM_GENLIST_ITEM_NONE, _profile_sel_cb, NULL); } elm_run(); - /* cleanup - free apps data */ - EINA_LIST_FREE(apps, st) - _free_app(st); - - EINA_LIST_FREE(bmp_req, st) - free(st); - - clouseau_data_shutdown(); - if (gui->address) - free(gui->address); - - free(gui); - - _modules_shutdown(); - clouseau_cfg_save(); - clouseau_cfg_shutdown(); - elm_shutdown(); - + eolian_debug_object_information_free(_obj_info); + _objs_nodes_free(_objs_list_tree); + eina_debug_session_terminate(_session); + eina_shutdown(); + eolian_shutdown(); return 0; } +ELM_MAIN() diff --git a/src/bin/clouseaud.c b/src/bin/clouseaud.c deleted file mode 100644 index b45c90c..0000000 --- a/src/bin/clouseaud.c +++ /dev/null @@ -1,459 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include - -#include "Clouseau.h" - -#define LOCK_FILE "/tmp/clouseaud.pid" - -static Eina_List *gui = NULL; /* List of app_info_st for gui clients */ -static Eina_List *app = NULL; /* List of app_info_st for app clients */ -static Ecore_Con_Eet *eet_svr = NULL; - -static int _clouseaud_log_dom = -1; - -#ifdef CRITICAL -#undef CRITICAL -#endif -#define CRITICAL(...) EINA_LOG_DOM_CRIT(_clouseaud_log_dom, __VA_ARGS__) - -#ifdef ERR -#undef ERR -#endif -#define ERR(...) EINA_LOG_DOM_ERR(_clouseaud_log_dom, __VA_ARGS__) - -#ifdef WRN -#undef WRN -#endif -#define WRN(...) EINA_LOG_DOM_WARN(_clouseaud_log_dom, __VA_ARGS__) - -#ifdef INF -#undef INF -#endif -#define INF(...) EINA_LOG_DOM_INFO(_clouseaud_log_dom, __VA_ARGS__) - -#ifdef DBG -#undef DBG -#endif -#define DBG(...) EINA_LOG_DOM_DBG(_clouseaud_log_dom, __VA_ARGS__) - - -static void -_daemon_cleanup(void) -{ /* Free strings */ - app_info_st *p; - - DBG("Clients connected to this server when exiting: %d", - eina_list_count(app) + eina_list_count(gui)); - - EINA_LIST_FREE(gui, p) - { - if(p->file) - free(p->file); - - if (p->ptr) - free((void *) (uintptr_t) p->ptr); - - free(p->name); - free(p); - } - - EINA_LIST_FREE(app, p) - { - if(p->file) - free(p->file); - - if (p->ptr) - free((void *) (uintptr_t) p->ptr); - - free(p->name); - free(p); - } - - gui = app = NULL; - eet_svr = NULL; -} - -/* START - Ecore communication callbacks */ -static int -_client_ptr_cmp(const void *d1, const void *d2) -{ - return (((app_info_st *) d1)->ptr - ((unsigned long long) (uintptr_t) d2)); -} - -static Eina_List * -_add_client(Eina_List *clients, connect_st *t, void *client, const char *type) -{ - DBG("msg from <%p>", client); - - if(!eina_list_search_unsorted(clients, _client_ptr_cmp, client)) - { - app_info_st *st = calloc(1, sizeof(app_info_st)); - st->name = strdup(t->name); - st->pid = t->pid; - st->ptr = (unsigned long long) (uintptr_t) client; - DBG("Added %s client <%p>", type, client); - return eina_list_append(clients, st); - } - - return clients; -} - -static Eina_List * -_remove_client(Eina_List *clients, void *client, const char *type) -{ - app_info_st *p = eina_list_search_unsorted(clients, _client_ptr_cmp, client); - DBG("Msg from <%p>", client); - - if (p) - { - free(p->name); - free(p); - DBG("Removed %s client <%p>", type, client); - return eina_list_remove(clients, p); - } - - return clients; -} - -Eina_Bool -_add(EINA_UNUSED void *data, Ecore_Con_Reply *reply, - EINA_UNUSED Ecore_Con_Client *conn) -{ -/* TODO: ecore_ipc_client_data_size_max_set(ev->client, -1); */ - DBG("msg from <%p>", reply); - - return ECORE_CALLBACK_RENEW; -} - -Eina_Bool -_del(EINA_UNUSED void *data, Ecore_Con_Reply *reply, - EINA_UNUSED Ecore_Con_Client *conn) -{ - DBG("msg from <%p>", reply); - - /* Now we need to find if its an APP or GUI client */ - app_info_st *i = eina_list_search_unsorted(gui, _client_ptr_cmp, reply); - if (i) /* Only need to remove GUI client from list */ - gui = _remove_client(gui, reply, "GUI"); - - i = eina_list_search_unsorted(app, _client_ptr_cmp, reply); - if (i) - { /* Notify all GUI clients to remove this APP */ - app_closed_st t = { (unsigned long long) (uintptr_t) reply }; - Eina_List *l; - EINA_LIST_FOREACH(gui, l, i) - { - DBG("<%p> Sending APP_CLOSED to <%p>", reply, - (void *) (uintptr_t) i->ptr); - ecore_con_eet_send((void *) (uintptr_t) i->ptr, - CLOUSEAU_APP_CLOSED_STR, &t); - } - - app = _remove_client(app, reply, "APP"); - } - - if (!(gui || app)) - { /* Trigger cleanup and exit when all clients disconneced */ - /* ecore_con_eet_server_free(eet_svr); why this causes Segfault? */ - ecore_con_server_del(data); - ecore_main_loop_quit(); - } - - return ECORE_CALLBACK_RENEW; -} - -void -_gui_client_connect_cb(EINA_UNUSED void *data, Ecore_Con_Reply *reply, - EINA_UNUSED const char *protocol_name, void *value) -{ /* Register GUI, then notify about all APP */ - app_info_st *st; - Eina_List *l; - connect_st *t = value; - DBG("msg from <%p>", reply); - - gui = _add_client(gui, t, reply, "GUI"); - - /* Add all registered apps to newly open GUI */ - EINA_LIST_FOREACH(app, l, st) - { - DBG("<%p> Sending APP_ADD to <%p>", - (void *) (uintptr_t) st->ptr, reply); - - ecore_con_eet_send(reply, CLOUSEAU_APP_ADD_STR, st); - } -} - -void -_app_client_connect_cb(EINA_UNUSED void *data, Ecore_Con_Reply *reply, - EINA_UNUSED const char *protocol_name, void *value) -{ /* Register APP then notify GUI about it */ - app_info_st *st; - Eina_List *l; - connect_st *t = value; - app_info_st m = { t->pid, (char *) t->name, NULL, - (unsigned long long) (uintptr_t) reply, NULL, 0 }; - - DBG("msg from <%p>", reply); - - app = _add_client(app, t, reply, "APP"); - - /* Notify all GUI clients to add APP */ - EINA_LIST_FOREACH(gui, l, st) - { - DBG("<%p> Sending APP_ADD to <%p>", - reply, (void *) (uintptr_t) st->ptr); - ecore_con_eet_send((void *) (uintptr_t) st->ptr, - CLOUSEAU_APP_ADD_STR, &m); - } -} - -void -_data_req_cb(EINA_UNUSED void *data, Ecore_Con_Reply *reply, - EINA_UNUSED const char *protocol_name, void *value) -{ /* msg coming from GUI, FWD this to APP specified in REQ */ - data_req_st *req = value; - DBG("msg from <%p>", reply); - - if (req->app) - { /* Requesting specific app data */ - if(eina_list_search_unsorted(app, - _client_ptr_cmp, - (void *) (uintptr_t) req->app)) - { /* Do the req only of APP connected to daemon */ - data_req_st t = { - (unsigned long long) (uintptr_t) reply, - (unsigned long long) (uintptr_t) req->app }; - - DBG("<%p> Sending DATA_REQ to <%p>", - reply, (void *) (uintptr_t) req->app); - ecore_con_eet_send((void *) (uintptr_t) req->app, - CLOUSEAU_DATA_REQ_STR, &t); - } - } - else - { /* requesting ALL apps data */ - Eina_List *l; - app_info_st *st; - data_req_st t = { - (unsigned long long) (uintptr_t) reply, - (unsigned long long) (uintptr_t) NULL }; - - EINA_LIST_FOREACH(app, l, st) - { - t.app = (unsigned long long) (uintptr_t) st->ptr; - DBG("<%p> Sending DATA_REQ to <%p>", - reply, (void *) (uintptr_t) st->ptr); - ecore_con_eet_send((void *) (uintptr_t) st->ptr, CLOUSEAU_DATA_REQ_STR, &t); - } - } -} - -void -_tree_data_cb(EINA_UNUSED void *data, EINA_UNUSED Ecore_Con_Reply *reply, - EINA_UNUSED const char *protocol_name, void *value) -{ /* Tree Data comes from APP, GUI client specified in msg */ - tree_data_st *td = value; - DBG("msg from <%p>", reply); - - if (td->gui) - { /* Sending tree data to specific GUI client */ - if(eina_list_search_unsorted(gui, - _client_ptr_cmp, - (void *) (uintptr_t) td->gui)) - { /* Do the req only of GUI connected to daemon */ - DBG("<%p> Sending TREE_DATA to <%p>", - reply, (void *) (uintptr_t) td->gui); - ecore_con_eet_send((void *) (uintptr_t) td->gui, - CLOUSEAU_TREE_DATA_STR, value); - } - } - else - { /* Sending tree data to all GUI clients */ - Eina_List *l; - app_info_st *info; - EINA_LIST_FOREACH(gui, l, info) - { - DBG("<%p> Sending TREE_DATA to <%p>", - reply, (void *) (uintptr_t) info->ptr); - ecore_con_eet_send((void *) (uintptr_t) info->ptr, - CLOUSEAU_TREE_DATA_STR, value); - } - } - - clouseau_data_tree_free(td->tree); -} - -void -_highlight_cb(EINA_UNUSED void *data, EINA_UNUSED Ecore_Con_Reply *reply, - EINA_UNUSED const char *protocol_name, void *value) -{ /* FWD this message to APP */ - highlight_st *ht = value; - DBG("msg from <%p>", reply); - - if(eina_list_search_unsorted(app, - _client_ptr_cmp, (void *) (uintptr_t) ht->app)) - { /* Do the REQ only of APP connected to daemon */ - DBG("<%p> Sending HIGHLIGHT to <%p>", - reply, (void *) (uintptr_t) ht->app); - ecore_con_eet_send((void *) (uintptr_t) ht->app, - CLOUSEAU_HIGHLIGHT_STR, value); - } -} - -void -_bmp_req_cb(EINA_UNUSED void *data, Ecore_Con_Reply *reply, - EINA_UNUSED const char *protocol_name, void *value) -{ /* BMP data request coming from GUI to APP client */ - bmp_req_st *req = value; - DBG("msg from <%p>", reply); - - if(eina_list_search_unsorted(app, - _client_ptr_cmp, (void *) (uintptr_t) req->app)) - { /* Do the req only if APP connected to daemon */ - bmp_req_st t = { - (unsigned long long) (uintptr_t) reply, - req->app, req->object, req->ctr }; - - DBG("<%p> Sending BMP_REQ to <%p>", - reply, (void *) (uintptr_t) req->app); - ecore_con_eet_send((void *) (uintptr_t) req->app, - CLOUSEAU_BMP_REQ_STR, &t); - } -} - -void -_bmp_data_cb(EINA_UNUSED void *data, EINA_UNUSED Ecore_Con_Reply *reply, - EINA_UNUSED const char *protocol_name, EINA_UNUSED const char *section, - void *value, EINA_UNUSED size_t length) -{ /* BMP Data comes from APP, GUI client specified in msg */ - bmp_info_st *st = clouseau_data_packet_info_get(protocol_name, - value, length); - - DBG("msg from <%p>", reply); - - if (st->gui) - { /* Sending BMP data to specific GUI client */ - if(eina_list_search_unsorted(gui, - _client_ptr_cmp, - (void *) (uintptr_t) st->gui)) - { /* Do the req only of GUI connected to daemon */ - DBG("<%p> Sending BMP_DATA to <%p>", - reply, (void *) (uintptr_t) st->gui); - ecore_con_eet_raw_send((void *) (uintptr_t) st->gui, - CLOUSEAU_BMP_DATA_STR, "BMP", value, length); - } - } - else - { /* Sending BMP data to all GUI clients */ - Eina_List *l; - app_info_st *info; - EINA_LIST_FOREACH(gui, l, info) - { - DBG("<%p> Sending BMP_DATA to <%p>", - reply, (void *) (uintptr_t) info->ptr); - ecore_con_eet_raw_send((void *) (uintptr_t) info->ptr, - CLOUSEAU_BMP_DATA_STR, "BMP", value, length); - } - } - - if (st->bmp) - free(st->bmp); - - free(st); -} -/* END - Ecore communication callbacks */ - -static void -_clouseaud_send_ready(void) -{ - printf("%s", CLOUSEAUD_READY_STR); - printf("\n"); - fflush(stdout); -} - -int main(void) -{ - int ret = 0; - /* Check single instance. */ - - { - int pid_file = open(LOCK_FILE, O_CREAT | O_RDWR, 0666); - int rc = lockf(pid_file, F_TLOCK, 0); - if ((pid_file == -1) || rc) - { - _clouseaud_send_ready(); - exit(0); - } - } - /* End of check single instance. */ - - eina_init(); - ecore_init(); - ecore_con_init(); - clouseau_data_init(); - Ecore_Con_Server *server = NULL; - const char *log_dom = "clouseaud"; - - - _clouseaud_log_dom = eina_log_domain_register(log_dom, EINA_COLOR_LIGHTBLUE); - if (_clouseaud_log_dom < 0) - { - EINA_LOG_ERR("Could not register log domain: %s", log_dom); - ret = 3; - goto shutdown_and_exit; - } - - if (!(server = ecore_con_server_add(ECORE_CON_REMOTE_TCP | ECORE_CON_SOCKET_ACTIVATE, - LISTEN_IP, PORT, NULL))) - { - ret = 1; - goto shutdown_and_exit; - } - - eet_svr = ecore_con_eet_server_new(server); - if (!eet_svr) - { - ret = 2; - goto shutdown_and_exit; - } - - clouseau_register_descs(eet_svr); - - /* Register callbacks for ecore_con_eet */ - ecore_con_eet_client_connect_callback_add(eet_svr, _add, NULL); - ecore_con_eet_client_disconnect_callback_add(eet_svr, _del, server); - ecore_con_eet_data_callback_add(eet_svr, CLOUSEAU_GUI_CLIENT_CONNECT_STR, - _gui_client_connect_cb, NULL); - ecore_con_eet_data_callback_add(eet_svr, CLOUSEAU_APP_CLIENT_CONNECT_STR, - _app_client_connect_cb, NULL); - ecore_con_eet_data_callback_add(eet_svr, CLOUSEAU_DATA_REQ_STR, - _data_req_cb, NULL); - ecore_con_eet_data_callback_add(eet_svr, CLOUSEAU_TREE_DATA_STR, - _tree_data_cb, NULL); - ecore_con_eet_data_callback_add(eet_svr, CLOUSEAU_HIGHLIGHT_STR, - _highlight_cb, NULL); - ecore_con_eet_data_callback_add(eet_svr, CLOUSEAU_BMP_REQ_STR, - _bmp_req_cb, NULL); - ecore_con_eet_raw_data_callback_add(eet_svr, CLOUSEAU_BMP_DATA_STR, - _bmp_data_cb, NULL); - - /* Print to stdout which will be read by the monitoring app. */ - _clouseaud_send_ready(); - - ecore_main_loop_begin(); - - _daemon_cleanup(); - -shutdown_and_exit: - clouseau_data_shutdown(); - ecore_con_shutdown(); - ecore_shutdown(); - eina_shutdown(); - - return ret; -} diff --git a/src/bin/gui b/src/bin/gui new file mode 100644 index 0000000..76bf5e8 --- /dev/null +++ b/src/bin/gui @@ -0,0 +1,595 @@ +{ + "JSON_Version":"1", + "Settings": + { + "project":"gui", + "start_points":["main_win"] + }, + "Resources": + { + "Images": + { + "SCREENSHOT_ICON":"../../data/images/show-screenshot.png" + }, + "Eo_Callbacks": + { + "profile_close":"_profile_win_close_cb", + "new_profile_save":"_new_profile_save_cb", + "new_profile_cancel":"_new_profile_cancel_cb", + "profile_del":"_profile_del_cb", + "screenshot_request":"screenshot_req_cb" + } + }, + "Widgets": + { + "main_win": + { + "Desc": + { + "parent":null, + "class":"Elm.Win", + "public":true + }, + "Properties": + { + "Elm.Win.type":["ELM_WIN_BASIC"], + "Elm.Widget.part_text":[null, "Window"], + "Elm.Win.autodel":[true], + "Evas.Object.size_hint_weight":[1, 1], + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.size":[478, 484] + }, + "Contains":["elm_bg1", "elm_box1"] + }, + "elm_bg1": + { + "Desc": + { + "parent":"main_win", + "class":"Elm.Bg" + }, + "Properties": + { + "Evas.Object.size_hint_weight":[1, 1], + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.position":[0, 0] + } + }, + "elm_box1": + { + "Desc": + { + "parent":"main_win", + "class":"Elm.Box" + }, + "Properties": + { + "Evas.Object.size_hint_weight":[1, 1], + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.size":[643, 598], + "Efl.Gfx.Base.position":[-7, -2], + "Elm.Box.padding":[0, 0], + "Elm.Box.align":[0, 0] + }, + "Contains":["apps_selector", "elm_panes1"] + }, + "apps_selector": + { + "Desc": + { + "parent":"elm_box1", + "class":"Elm.Hoversel", + "public":true + }, + "Properties": + { + "Evas.Object.size_hint_weight":[1, 0], + "Evas.Object.size_hint_align":[0.50, 0], + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.size":[1174, 643], + "Efl.Gfx.Base.position":[-8, -2], + "Elm.Widget.part_text":[null, "Select App"] + } + }, + "elm_panes1": + { + "Desc": + { + "parent":"elm_box1", + "class":"Elm.Panes" + }, + "Properties": + { + "Elm.Panes.content_right_size":[0.60], + "Evas.Object.size_hint_weight":[1, 1], + "Efl.Gfx.Base.size":[75, 75], + "Efl.Gfx.Base.visible":[true], + "Evas.Object.size_hint_weight":[1, 1], + "Evas.Object.size_hint_align":[-1, -1] + }, + "Contains": + { + "objects_list":["left"], + "object_infos_list":["right"] + } + }, + "object_infos_list": + { + "Desc": + { + "parent":"elm_panes1", + "class":"Elm.Genlist", + "public":true + }, + "Properties": + { + "Evas.Object.size_hint_weight":[1, 1], + "Efl.Gfx.Base.visible":[true] + } + }, + "objects_list": + { + "Desc": + { + "parent":"elm_panes1", + "class":"Elm.Genlist", + "public":true + }, + "Properties": + { + "Evas.Object.size_hint_weight":[1, 1], + "Efl.Gfx.Base.visible":[true] + } + }, + "profiles_win": + { + "Desc": + { + "parent":null, + "class":"Elm.Win", + "public":true + }, + "Properties": + { + "Elm.Win.name":["Win"], + "Elm.Win.type":["ELM_WIN_BASIC"], + "Elm.Win.autodel":[true], + "Elm.Widget.part_text":[null, "Window"], + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.size":[347, 362], + "Evas.Object.size_hint_weight":[1, 1], + "Evas.Object.freeze_events":[false], + "Evas.Object.repeat_events":[false], + "Elm.Win.title":["Profiles"] + }, + "Contains":["elm_bg2", "elm_box2"] + }, + "elm_bg2": + { + "Desc": + { + "parent":"profiles_win", + "class":"Elm.Bg" + }, + "Properties": + { + "Evas.Object.size_hint_weight":[1, 1], + "Efl.Gfx.Base.visible":[true] + } + }, + "elm_box2": + { + "Desc": + { + "parent":"profiles_win", + "class":"Elm.Box" + }, + "Properties": + { + "Elm.Box.padding":[7, 0], + "Evas.Object.size_hint_weight":[1, 1], + "Efl.Gfx.Base.size":[200, 200], + "Efl.Gfx.Base.visible":[true] + }, + "Contains":["profiles_list", "elm_box3"] + }, + "elm_box3": + { + "Desc": + { + "parent":"elm_box2", + "class":"Elm.Box" + }, + "Properties": + { + "Elm.Box.padding":[7, 0], + "Evas.Object.size_hint_align":[-1, -1], + "Efl.Gfx.Base.visible":[true], + "Elm.Box.horizontal":[true], + "Efl.Gfx.Base.size":[200, 139], + "Efl.Gfx.Base.position":[289, 742], + "Evas.Object.size_hint_weight":[1, 0.20] + }, + "Contains":["profile_ok_button", "profile_cancel_button", "profile_new_button", "profile_delete_button"] + }, + "profile_delete_button": + { + "Desc": + { + "parent":"elm_box3", + "class":"Elm.Button", + "public":true + }, + "Properties": + { + "Efl.Gfx.Base.visible":[true], + "Elm.Widget.disabled":[true], + "Elm.Widget.part_text":[null, "Delete profile"], + "Efl.Gfx.Base.size":[115, 30], + "Efl.Gfx.Base.position":[-42, 0], + "Evas.Object.size_hint_align":[0.50, 0.50], + "Evas.Object.size_hint_weight":[1, 1] + }, + "Callbacks": + { + "clicked":["Invoke", "profile_del", null] + } + }, + "profile_ok_button": + { + "Desc": + { + "parent":"elm_box3", + "class":"Elm.Button", + "public":true + }, + "Properties": + { + "Evas.Object.size_hint_weight":[1, 1], + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.size":[73, 30], + "Elm.Widget.part_text":[null, "Ok"], + "Elm.Widget.disabled":[true] + }, + "Callbacks": + { + "clicked":["Invoke", "profile_close", null] + } + }, + "profile_cancel_button": + { + "Desc": + { + "parent":"elm_box3", + "class":"Elm.Button", + "public":true + }, + "Properties": + { + "Evas.Object.size_hint_weight":[1, 1], + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.size":[73, 30], + "Elm.Widget.part_text":[null, "Cancel"] + } + }, + "profile_new_button": + { + "Desc": + { + "parent":"elm_box3", + "class":"Elm.Button" + }, + "Properties": + { + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.size":[73, 30], + "Elm.Widget.part_text":[null, "New profile"], + "Evas.Object.size_hint_weight":[1, 1], + "Evas.Object.size_hint_align":[0.50, 0.50] + }, + "Callbacks": + { + "clicked":["Create", "new_profile_win", null] + } + }, + "profiles_list": + { + "Desc": + { + "parent":"elm_box2", + "class":"Elm.Genlist", + "public":true + }, + "Properties": + { + "Evas.Object.size_hint_weight":[1, 1], + "Efl.Gfx.Base.visible":[true], + "Evas.Object.size_hint_align":[-1, -1] + } + }, + "new_profile_win": + { + "Desc": + { + "parent":null, + "class":"Elm.Win", + "public":true + }, + "Properties": + { + "Elm.Win.type":["ELM_WIN_BASIC"], + "Elm.Win.autodel":[true], + "Elm.Widget.part_text":[null, "Window"], + "Evas.Object.size_hint_weight":[1, 1], + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.size":[689, 390], + "Elm.Win.title":["New profile..."], + "Elm.Win.modal":[true] + }, + "Contains":["elm_bg4", "elm_box5"] + }, + "elm_bg4": + { + "Desc": + { + "parent":"new_profile_win", + "class":"Elm.Bg" + }, + "Properties": + { + "Evas.Object.size_hint_weight":[1, 1], + "Efl.Gfx.Base.visible":[true] + } + }, + "elm_box5": + { + "Desc": + { + "parent":"new_profile_win", + "class":"Elm.Box" + }, + "Properties": + { + "Elm.Box.padding":[7, 0], + "Evas.Object.size_hint_weight":[1, 1], + "Evas.Object.size_hint_align":[-1, -1], + "Efl.Gfx.Base.size":[200, 200], + "Efl.Gfx.Base.visible":[true] + }, + "Contains":["elm_box6", "elm_label1", "new_profile_command", "elm_label2", "new_profile_script", "elm_box4"] + }, + "elm_box4": + { + "Desc": + { + "parent":"elm_box5", + "class":"Elm.Box" + }, + "Properties": + { + "Elm.Box.padding":[7, 0], + "Evas.Object.size_hint_weight":[1, 1], + "Evas.Object.size_hint_align":[-1, -1], + "Efl.Gfx.Base.size":[200, 200], + "Efl.Gfx.Base.visible":[true], + "Elm.Box.horizontal":[true] + }, + "Contains":["new_profile_save_button", "new_profile_cancel_button"] + }, + "new_profile_cancel_button": + { + "Desc": + { + "parent":"elm_box4", + "class":"Elm.Button", + "public":true + }, + "Properties": + { + "Evas.Object.size_hint_weight":[1, 1], + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.size":[73, 30], + "Elm.Widget.part_text":[null, "Cancel"] + } + }, + "new_profile_save_button": + { + "Desc": + { + "parent":"elm_box4", + "class":"Elm.Button", + "public":true + }, + "Properties": + { + "Evas.Object.size_hint_weight":[1, 1], + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.size":[73, 30], + "Elm.Widget.part_text":[null, "Save"] + }, + "Callbacks": + { + "clicked":["Invoke", "new_profile_save", null] + } + }, + "elm_box6": + { + "Desc": + { + "parent":"elm_box5", + "class":"Elm.Box" + }, + "Properties": + { + "Elm.Box.padding":[7, 0], + "Evas.Object.size_hint_weight":[1, 1], + "Evas.Object.size_hint_align":[-1, -1], + "Efl.Gfx.Base.size":[200, 200], + "Efl.Gfx.Base.visible":[true], + "Elm.Box.horizontal":[true] + }, + "Contains":["new_profile_type_selector", "elm_label3", "new_profile_name"] + }, + "new_profile_type_selector": + { + "Desc": + { + "parent":"elm_box6", + "class":"Elm.Hoversel", + "public":true + }, + "Properties": + { + "Evas.Object.size_hint_weight":[1, 1], + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.size":[60, 40], + "Evas.Object.size_hint_align":[0, 0.50], + "Elm.Widget.part_text":[null, "Choose the profile type"] + } + }, + "elm_label3": + { + "Desc": + { + "parent":"elm_box6", + "class":"Elm.Label" + }, + "Properties": + { + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.size":[60, 30], + "Evas.Object.size_hint_align":[1, -1], + "Elm.Widget.part_text":[null, "Name: "], + "Evas.Object.size_hint_weight":[0, 1] + } + }, + "new_profile_name": + { + "Desc": + { + "parent":"elm_box6", + "class":"Elm.Entry", + "public":true + }, + "Properties": + { + "Evas.Object.size_hint_align":[-1, -1], + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.size":[65, 35], + "Elm.Entry.scrollable":[true], + "Elm.Entry.single_line":[true], + "Evas.Object.size_hint_weight":[4, 1], + "Elm.Entry.editable":[true], + "Elm.Widget.part_text":[null, ""] + } + }, + "elm_label1": + { + "Desc": + { + "parent":"elm_box5", + "class":"Elm.Label" + }, + "Properties": + { + "Evas.Object.size_hint_weight":[1, 1], + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.size":[115, 30], + "Efl.Gfx.Base.position":[847, 0], + "Elm.Widget.part_text":[null, "Command: "], + "Evas.Object.size_hint_align":[0, 2] + } + }, + "new_profile_command": + { + "Desc": + { + "parent":"elm_box5", + "class":"Elm.Entry", + "public":true + }, + "Properties": + { + "Elm.Entry.scrollable":[true], + "Evas.Object.size_hint_align":[-1, -1], + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.size":[65, 35], + "Elm.Entry.single_line":[true], + "Evas.Object.size_hint_weight":[1, 2], + "Elm.Widget.disabled":[true] + } + }, + "elm_label2": + { + "Desc": + { + "parent":"elm_box5", + "class":"Elm.Label" + }, + "Properties": + { + "Evas.Object.size_hint_weight":[1, 1], + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.size":[60, 30], + "Evas.Object.size_hint_align":[0, 1], + "Elm.Widget.part_text":[null, "Script: "] + } + }, + "new_profile_script": + { + "Desc": + { + "parent":"elm_box5", + "class":"Elm.Entry", + "public":true + }, + "Properties": + { + "Elm.Entry.scrollable":[true], + "Evas.Object.size_hint_align":[-1, -1], + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.size":[65, 35], + "Evas.Object.size_hint_weight":[1, 8], + "Elm.Widget.disabled":[true] + } + }, + "screenshot_button": + { + "Desc": + { + "parent":null, + "class":"Elm.Button", + "public":true + }, + "Properties": + { + "Evas.Object.size_hint_weight":[1, 1], + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.size":[73, 30] + }, + "Callbacks": + { + "clicked":["Invoke", "screenshot_request", null] + }, + "Contains": + { + "elm_icon1":["icon"] + } + }, + "elm_icon1": + { + "Desc": + { + "parent":"screenshot_button", + "class":"Elm.Icon" + }, + "Properties": + { + "Evas.Object.size_hint_weight":[1, 1], + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.size":[40, 40], + "Efl.File.file":["SCREENSHOT_ICON", null] + } + } + } + } diff --git a/src/bin/gui.c b/src/bin/gui.c new file mode 100644 index 0000000..e06b640 --- /dev/null +++ b/src/bin/gui.c @@ -0,0 +1,400 @@ +#ifndef EFL_BETA_API_SUPPORT +#define EFL_BETA_API_SUPPORT +#endif +#ifndef EFL_EO_API_SUPPORT +#define EFL_EO_API_SUPPORT +#endif +#ifndef ELM_INTERNAL_API_ARGESFSDFEFC +#define ELM_INTERNAL_API_ARGESFSDFEFC +#endif +#include +#include "elm_widget_container.h" +#include "elm_interface_scrollable.h" +#include "elm_interface_fileselector.h" +#include "gui.h" + +static Gui_Widgets g_pub_widgets; + +extern void gui_new_profile_win_create_done(Gui_New_Profile_Win_Widgets *wdgs); + +#ifdef GUI_IMAGES_PATH + const char *SCREENSHOT_ICON = GUI_IMAGES_PATH"/show-screenshot.png"; +#else + #error "Please define GUI_IMAGES_PATH" +#endif + +extern void +_profile_win_close_cb(void *data, const Efl_Event *event); +extern void +_new_profile_save_cb(void *data, const Efl_Event *event); +extern void +_new_profile_cancel_cb(void *data, const Efl_Event *event); +extern void +_profile_del_cb(void *data, const Efl_Event *event); +extern void +screenshot_req_cb(void *data, const Efl_Event *event); + +static void +_pubs_free_cb(void *data, const Efl_Event *event EINA_UNUSED) +{ + free(data); +} + +Gui_Main_Win_Widgets * +gui_main_win_create(Eo *__main_parent) +{ + Gui_Main_Win_Widgets *pub_widgets = calloc(1, sizeof(*pub_widgets)); + + Eo *main_win; + Eo *elm_bg1; + Eo *elm_box1; + Eo *apps_selector; + Eo *elm_panes1; + Eo *object_infos_list; + Eo *objects_list; + + main_win = elm_win_add(__main_parent, "Window", ELM_WIN_BASIC); + pub_widgets->main_win = main_win; + elm_win_autodel_set(main_win, EINA_TRUE); + evas_object_size_hint_weight_set(main_win, 1.000000, 1.000000); + efl_gfx_size_set(main_win, 478, 484); + elm_bg1 = efl_add(ELM_BG_CLASS, main_win); + evas_object_size_hint_weight_set(elm_bg1, 1.000000, 1.000000); + efl_gfx_visible_set(elm_bg1, EINA_TRUE); + efl_gfx_position_set(elm_bg1, 0, 0); + elm_box1 = elm_box_add(main_win); + evas_object_size_hint_weight_set(elm_box1, 1.000000, 1.000000); + efl_gfx_visible_set(elm_box1, EINA_TRUE); + efl_gfx_size_set(elm_box1, 643, 598); + efl_gfx_position_set(elm_box1, -7, -2); + elm_box_padding_set(elm_box1, 0, 0); + elm_box_align_set(elm_box1, 0.000000, 0.000000); + elm_win_resize_object_add(main_win, elm_bg1); + elm_win_resize_object_add(main_win, elm_box1); + apps_selector = elm_hoversel_add(elm_box1); + pub_widgets->apps_selector = apps_selector; + evas_object_size_hint_weight_set(apps_selector, 1.000000, 0.000000); + evas_object_size_hint_align_set(apps_selector, 0.500000, 0.000000); + efl_gfx_visible_set(apps_selector, EINA_TRUE); + efl_gfx_size_set(apps_selector, 1174, 643); + efl_gfx_position_set(apps_selector, -8, -2); + elm_obj_widget_part_text_set(apps_selector, NULL, "Select App"); + elm_panes1 = efl_add(ELM_PANES_CLASS, elm_box1); + elm_obj_panes_content_right_size_set(elm_panes1, 0.600000); + evas_object_size_hint_weight_set(elm_panes1, 1.000000, 1.000000); + efl_gfx_size_set(elm_panes1, 75, 75); + efl_gfx_visible_set(elm_panes1, EINA_TRUE); + evas_object_size_hint_weight_set(elm_panes1, 1.000000, 1.000000); + evas_object_size_hint_align_set(elm_panes1, -1.000000, -1.000000); + elm_box_pack_end(elm_box1, apps_selector); + elm_box_pack_end(elm_box1, elm_panes1); + object_infos_list = elm_genlist_add(elm_panes1); + pub_widgets->object_infos_list = object_infos_list; + evas_object_size_hint_weight_set(object_infos_list, 1.000000, 1.000000); + efl_gfx_visible_set(object_infos_list, EINA_TRUE); + objects_list = efl_add(ELM_GENLIST_CLASS, elm_panes1); + pub_widgets->objects_list = objects_list; + evas_object_size_hint_weight_set(objects_list, 1.000000, 1.000000); + efl_gfx_visible_set(objects_list, EINA_TRUE); + elm_object_part_content_set(elm_panes1, "left", objects_list); + elm_object_part_content_set(elm_panes1, "right", object_infos_list); + efl_gfx_visible_set(main_win, EINA_TRUE); + efl_event_callback_add(main_win, EFL_EVENT_DEL, _pubs_free_cb, pub_widgets); + + return pub_widgets; +} + +static void +profile_delete_button_clicked(void *data, const Efl_Event *event) +{ + _profile_del_cb(data, event); +} + +static void +profile_new_button_clicked(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED) +{ + Gui_New_Profile_Win_Widgets *wdgs = gui_new_profile_win_create(NULL); + gui_new_profile_win_create_done(wdgs); +} + +static void +profile_ok_button_clicked(void *data, const Efl_Event *event) +{ + _profile_win_close_cb(data, event); +} + +Gui_Profiles_Win_Widgets * +gui_profiles_win_create(Eo *__main_parent) +{ + Gui_Profiles_Win_Widgets *pub_widgets = calloc(1, sizeof(*pub_widgets)); + + Eo *profiles_win; + Eo *elm_bg2; + Eo *elm_box2; + Eo *elm_box3; + Eo *profile_delete_button; + Eo *profile_ok_button; + Eo *profile_cancel_button; + Eo *profile_new_button; + Eo *profiles_list; + + + profiles_win = elm_win_add(__main_parent, "Win", ELM_WIN_BASIC); + pub_widgets->profiles_win = profiles_win; + elm_win_autodel_set(profiles_win, EINA_TRUE); + elm_widget_part_text_set(profiles_win, NULL, "Window"); + efl_gfx_size_set(profiles_win, 347, 362); + evas_object_size_hint_weight_set(profiles_win, 1.000000, 1.000000); + evas_object_freeze_events_set(profiles_win, EINA_FALSE); + evas_object_repeat_events_set(profiles_win, EINA_FALSE); + elm_win_title_set(profiles_win, "Profiles"); + elm_bg2 = elm_bg_add(profiles_win); + evas_object_size_hint_weight_set(elm_bg2, 1.000000, 1.000000); + efl_gfx_visible_set(elm_bg2, EINA_TRUE); + elm_box2 = elm_box_add(profiles_win); + elm_box_padding_set(elm_box2, 7, 0); + evas_object_size_hint_weight_set(elm_box2, 1.000000, 1.000000); + efl_gfx_size_set(elm_box2, 200, 200); + efl_gfx_visible_set(elm_box2, EINA_TRUE); + elm_win_resize_object_add(profiles_win, elm_bg2); + elm_win_resize_object_add(profiles_win, elm_box2); + elm_box3 = elm_box_add(elm_box2); + elm_box_padding_set(elm_box3, 7, 0); + evas_object_size_hint_align_set(elm_box3, -1.000000, -1.000000); + efl_gfx_visible_set(elm_box3, EINA_TRUE); + elm_box_horizontal_set(elm_box3, EINA_TRUE); + efl_gfx_size_set(elm_box3, 200, 139); + efl_gfx_position_set(elm_box3, 289, 742); + evas_object_size_hint_weight_set(elm_box3, 1.000000, 0.200000); + profile_delete_button = efl_add(ELM_BUTTON_CLASS, elm_box3); + pub_widgets->profile_delete_button = profile_delete_button; + efl_gfx_visible_set(profile_delete_button, EINA_TRUE); + elm_obj_widget_disabled_set(profile_delete_button, EINA_TRUE); + elm_obj_widget_part_text_set(profile_delete_button, NULL, "Delete profile"); + efl_gfx_size_set(profile_delete_button, 115, 30); + efl_gfx_position_set(profile_delete_button, -42, 0); + evas_object_size_hint_align_set(profile_delete_button, 0.500000, 0.500000); + evas_object_size_hint_weight_set(profile_delete_button, 1.000000, 1.000000); + efl_event_callback_add(profile_delete_button, EFL_UI_EVENT_CLICKED, profile_delete_button_clicked, NULL); + profile_ok_button = efl_add(ELM_BUTTON_CLASS, elm_box3); + pub_widgets->profile_ok_button = profile_ok_button; + evas_object_size_hint_weight_set(profile_ok_button, 1.000000, 1.000000); + efl_gfx_visible_set(profile_ok_button, EINA_TRUE); + efl_gfx_size_set(profile_ok_button, 73, 30); + elm_obj_widget_part_text_set(profile_ok_button, NULL, "Ok"); + elm_obj_widget_disabled_set(profile_ok_button, EINA_TRUE); + efl_event_callback_add(profile_ok_button, EFL_UI_EVENT_CLICKED, profile_ok_button_clicked, NULL); + profile_cancel_button = efl_add(ELM_BUTTON_CLASS, elm_box3); + pub_widgets->profile_cancel_button = profile_cancel_button; + evas_object_size_hint_weight_set(profile_cancel_button, 1.000000, 1.000000); + efl_gfx_visible_set(profile_cancel_button, EINA_TRUE); + efl_gfx_size_set(profile_cancel_button, 73, 30); + elm_obj_widget_part_text_set(profile_cancel_button, NULL, "Cancel"); + profile_new_button = efl_add(ELM_BUTTON_CLASS, elm_box3); + efl_gfx_visible_set(profile_new_button, EINA_TRUE); + efl_gfx_size_set(profile_new_button, 73, 30); + elm_obj_widget_part_text_set(profile_new_button, NULL, "New profile"); + evas_object_size_hint_weight_set(profile_new_button, 1.000000, 1.000000); + evas_object_size_hint_align_set(profile_new_button, 0.500000, 0.500000); + efl_event_callback_add(profile_new_button, EFL_UI_EVENT_CLICKED, profile_new_button_clicked, NULL); + elm_box_pack_end(elm_box3, profile_ok_button); + elm_box_pack_end(elm_box3, profile_cancel_button); + elm_box_pack_end(elm_box3, profile_new_button); + elm_box_pack_end(elm_box3, profile_delete_button); + profiles_list = efl_add(ELM_GENLIST_CLASS, elm_box2); + pub_widgets->profiles_list = profiles_list; + evas_object_size_hint_weight_set(profiles_list, 1.000000, 1.000000); + efl_gfx_visible_set(profiles_list, EINA_TRUE); + evas_object_size_hint_align_set(profiles_list, -1.000000, -1.000000); + elm_box_pack_end(elm_box2, profiles_list); + elm_box_pack_end(elm_box2, elm_box3); + efl_gfx_visible_set(profiles_win, EINA_TRUE); + efl_event_callback_add(profiles_win, EFL_EVENT_DEL, _pubs_free_cb, pub_widgets); + + return pub_widgets; +} + +static void +new_profile_save_button_clicked(void *data, const Efl_Event *event) +{ + _new_profile_save_cb(data, event); +} + +Gui_New_Profile_Win_Widgets * +gui_new_profile_win_create(Eo *__main_parent) +{ + Gui_New_Profile_Win_Widgets *pub_widgets = calloc(1, sizeof(*pub_widgets)); + + Eo *new_profile_win; + Eo *elm_bg4; + Eo *elm_box5; + Eo *elm_box4; + Eo *new_profile_cancel_button; + Eo *new_profile_save_button; + Eo *elm_box6; + Eo *new_profile_type_selector; + Eo *elm_label3; + Eo *new_profile_name; + Eo *elm_label1; + Eo *new_profile_command; + Eo *elm_label2; + Eo *new_profile_script; + + + new_profile_win = elm_win_add(__main_parent, "Window", ELM_WIN_BASIC); + pub_widgets->new_profile_win = new_profile_win; + elm_win_autodel_set(new_profile_win, EINA_TRUE); + evas_object_size_hint_weight_set(new_profile_win, 1.000000, 1.000000); + efl_gfx_size_set(new_profile_win, 689, 390); + elm_win_title_set(new_profile_win, "New profile..."); + elm_win_modal_set(new_profile_win, EINA_TRUE); + elm_bg4 = efl_add(ELM_BG_CLASS, new_profile_win); + evas_object_size_hint_weight_set(elm_bg4, 1.000000, 1.000000); + efl_gfx_visible_set(elm_bg4, EINA_TRUE); + elm_box5 = elm_box_add(new_profile_win); + elm_box_padding_set(elm_box5, 7, 0); + evas_object_size_hint_weight_set(elm_box5, 1.000000, 1.000000); + evas_object_size_hint_align_set(elm_box5, -1.000000, -1.000000); + efl_gfx_size_set(elm_box5, 200, 200); + efl_gfx_visible_set(elm_box5, EINA_TRUE); + elm_win_resize_object_add(new_profile_win, elm_bg4); + elm_win_resize_object_add(new_profile_win, elm_box5); + elm_box4 = elm_box_add(elm_box5); + elm_box_padding_set(elm_box4, 7, 0); + evas_object_size_hint_weight_set(elm_box4, 1.000000, 1.000000); + evas_object_size_hint_align_set(elm_box4, -1.000000, -1.000000); + efl_gfx_size_set(elm_box4, 200, 200); + efl_gfx_visible_set(elm_box4, EINA_TRUE); + elm_box_horizontal_set(elm_box4, EINA_TRUE); + new_profile_cancel_button = efl_add(ELM_BUTTON_CLASS, elm_box4); + pub_widgets->new_profile_cancel_button = new_profile_cancel_button; + evas_object_size_hint_weight_set(new_profile_cancel_button, 1.000000, 1.000000); + efl_gfx_visible_set(new_profile_cancel_button, EINA_TRUE); + efl_gfx_size_set(new_profile_cancel_button, 73, 30); + elm_obj_widget_part_text_set(new_profile_cancel_button, NULL, "Cancel"); + new_profile_save_button = efl_add(ELM_BUTTON_CLASS, elm_box4); + pub_widgets->new_profile_save_button = new_profile_save_button; + evas_object_size_hint_weight_set(new_profile_save_button, 1.000000, 1.000000); + efl_gfx_visible_set(new_profile_save_button, EINA_TRUE); + efl_gfx_size_set(new_profile_save_button, 73, 30); + elm_obj_widget_part_text_set(new_profile_save_button, NULL, "Save"); + efl_event_callback_add(new_profile_save_button, EFL_UI_EVENT_CLICKED, new_profile_save_button_clicked, NULL); + elm_box_pack_end(elm_box4, new_profile_save_button); + elm_box_pack_end(elm_box4, new_profile_cancel_button); + elm_box6 = elm_box_add(elm_box5); + elm_box_padding_set(elm_box6, 7, 0); + evas_object_size_hint_weight_set(elm_box6, 1.000000, 1.000000); + evas_object_size_hint_align_set(elm_box6, -1.000000, -1.000000); + efl_gfx_size_set(elm_box6, 200, 200); + efl_gfx_visible_set(elm_box6, EINA_TRUE); + elm_box_horizontal_set(elm_box6, EINA_TRUE); + new_profile_type_selector = elm_hoversel_add(elm_box6); + pub_widgets->new_profile_type_selector = new_profile_type_selector; + evas_object_size_hint_weight_set(new_profile_type_selector, 1.000000, 1.000000); + efl_gfx_visible_set(new_profile_type_selector, EINA_TRUE); + efl_gfx_size_set(new_profile_type_selector, 60, 40); + evas_object_size_hint_align_set(new_profile_type_selector, 0.000000, 0.500000); + elm_obj_widget_part_text_set(new_profile_type_selector, NULL, "Choose the profile type"); + elm_label3 = efl_add(ELM_LABEL_CLASS, elm_box6); + efl_gfx_visible_set(elm_label3, EINA_TRUE); + efl_gfx_size_set(elm_label3, 60, 30); + evas_object_size_hint_align_set(elm_label3, 1.000000, -1.000000); + elm_obj_widget_part_text_set(elm_label3, NULL, "Name: "); + evas_object_size_hint_weight_set(elm_label3, 0.000000, 1.000000); + new_profile_name = efl_add(ELM_ENTRY_CLASS, elm_box6); + pub_widgets->new_profile_name = new_profile_name; + evas_object_size_hint_align_set(new_profile_name, -1.000000, -1.000000); + efl_gfx_visible_set(new_profile_name, EINA_TRUE); + efl_gfx_size_set(new_profile_name, 65, 35); + elm_obj_entry_scrollable_set(new_profile_name, EINA_TRUE); + elm_obj_entry_single_line_set(new_profile_name, EINA_TRUE); + evas_object_size_hint_weight_set(new_profile_name, 4.000000, 1.000000); + elm_obj_entry_editable_set(new_profile_name, EINA_TRUE); + elm_obj_widget_part_text_set(new_profile_name, NULL, ""); + elm_box_pack_end(elm_box6, new_profile_type_selector); + elm_box_pack_end(elm_box6, elm_label3); + elm_box_pack_end(elm_box6, new_profile_name); + elm_label1 = efl_add(ELM_LABEL_CLASS, elm_box5); + evas_object_size_hint_weight_set(elm_label1, 1.000000, 1.000000); + efl_gfx_visible_set(elm_label1, EINA_TRUE); + efl_gfx_size_set(elm_label1, 115, 30); + efl_gfx_position_set(elm_label1, 847, 0); + elm_obj_widget_part_text_set(elm_label1, NULL, "Command: "); + evas_object_size_hint_align_set(elm_label1, 0.000000, 2.000000); + new_profile_command = efl_add(ELM_ENTRY_CLASS, elm_box5); + pub_widgets->new_profile_command = new_profile_command; + elm_obj_entry_scrollable_set(new_profile_command, EINA_TRUE); + evas_object_size_hint_align_set(new_profile_command, -1.000000, -1.000000); + efl_gfx_visible_set(new_profile_command, EINA_TRUE); + efl_gfx_size_set(new_profile_command, 65, 35); + elm_obj_entry_single_line_set(new_profile_command, EINA_TRUE); + evas_object_size_hint_weight_set(new_profile_command, 1.000000, 2.000000); + elm_obj_widget_disabled_set(new_profile_command, EINA_TRUE); + elm_label2 = efl_add(ELM_LABEL_CLASS, elm_box5); + evas_object_size_hint_weight_set(elm_label2, 1.000000, 1.000000); + efl_gfx_visible_set(elm_label2, EINA_TRUE); + efl_gfx_size_set(elm_label2, 60, 30); + evas_object_size_hint_align_set(elm_label2, 0.000000, 1.000000); + elm_obj_widget_part_text_set(elm_label2, NULL, "Script: "); + new_profile_script = efl_add(ELM_ENTRY_CLASS, elm_box5); + pub_widgets->new_profile_script = new_profile_script; + elm_obj_entry_scrollable_set(new_profile_script, EINA_TRUE); + evas_object_size_hint_align_set(new_profile_script, -1.000000, -1.000000); + efl_gfx_visible_set(new_profile_script, EINA_TRUE); + efl_gfx_size_set(new_profile_script, 65, 35); + evas_object_size_hint_weight_set(new_profile_script, 1.000000, 8.000000); + elm_obj_widget_disabled_set(new_profile_script, EINA_TRUE); + elm_box_pack_end(elm_box5, elm_box6); + elm_box_pack_end(elm_box5, elm_label1); + elm_box_pack_end(elm_box5, new_profile_command); + elm_box_pack_end(elm_box5, elm_label2); + elm_box_pack_end(elm_box5, new_profile_script); + elm_box_pack_end(elm_box5, elm_box4); + efl_gfx_visible_set(new_profile_win, EINA_TRUE); + efl_event_callback_add(new_profile_win, EFL_EVENT_DEL, _pubs_free_cb, pub_widgets); + + return pub_widgets; +} + +static void +screenshot_button_clicked(void *data, const Efl_Event *event) +{ + screenshot_req_cb(data, event); +} + +Gui_Screenshot_Button_Widgets * +gui_screenshot_button_create(Eo *__main_parent) +{ + Gui_Screenshot_Button_Widgets *pub_widgets = calloc(1, sizeof(*pub_widgets)); + + Eo *screenshot_button; + Eo *elm_icon1; + + + screenshot_button = efl_add(ELM_BUTTON_CLASS, __main_parent); + pub_widgets->screenshot_button = screenshot_button; + evas_object_size_hint_weight_set(screenshot_button, 1.000000, 1.000000); + efl_gfx_visible_set(screenshot_button, EINA_TRUE); + efl_gfx_size_set(screenshot_button, 73, 30); + efl_event_callback_add(screenshot_button, EFL_UI_EVENT_CLICKED, screenshot_button_clicked, NULL); + elm_icon1 = elm_icon_add(screenshot_button); + evas_object_size_hint_weight_set(elm_icon1, 1.000000, 1.000000); + efl_gfx_visible_set(elm_icon1, EINA_TRUE); + efl_gfx_size_set(elm_icon1, 40, 40); + efl_file_set(elm_icon1, SCREENSHOT_ICON, NULL); + elm_object_part_content_set(screenshot_button, "icon", elm_icon1); + efl_event_callback_add(screenshot_button, EFL_EVENT_DEL, _pubs_free_cb, pub_widgets); + + return pub_widgets; +} + +Gui_Widgets *gui_gui_get() +{ + static Eina_Bool initialized = EINA_FALSE; + if (!initialized) + { + g_pub_widgets.main_win = gui_main_win_create(NULL); + initialized = EINA_TRUE; + } + return &g_pub_widgets; +} diff --git a/src/bin/gui.h b/src/bin/gui.h new file mode 100644 index 0000000..3155639 --- /dev/null +++ b/src/bin/gui.h @@ -0,0 +1,56 @@ +#ifndef _gui_h_ +#define _gui_h_ +#include +#include + +typedef struct +{ + Eo *main_win; + Eo *apps_selector; + Eo *object_infos_list; + Eo *objects_list; +} Gui_Main_Win_Widgets; + + +typedef struct +{ + Eo *profiles_win; + Eo *profile_delete_button; + Eo *profile_ok_button; + Eo *profile_cancel_button; + Eo *profiles_list; +} Gui_Profiles_Win_Widgets; + + +typedef struct +{ + Eo *new_profile_win; + Eo *new_profile_cancel_button; + Eo *new_profile_save_button; + Eo *new_profile_type_selector; + Eo *new_profile_name; + Eo *new_profile_command; + Eo *new_profile_script; +} Gui_New_Profile_Win_Widgets; + + +typedef struct +{ + Eo *screenshot_button; +} Gui_Screenshot_Button_Widgets; + + +typedef struct { + Gui_Main_Win_Widgets *main_win; +} Gui_Widgets; + +Gui_Main_Win_Widgets *gui_main_win_create(Eo *parent); + +Gui_Profiles_Win_Widgets *gui_profiles_win_create(Eo *parent); + +Gui_New_Profile_Win_Widgets *gui_new_profile_win_create(Eo *parent); + +Gui_Screenshot_Button_Widgets *gui_screenshot_button_create(Eo *parent); + +Gui_Widgets *gui_gui_get(); +#endif diff --git a/src/lib/Clouseau.h b/src/lib/Clouseau.h deleted file mode 100644 index cc14e40..0000000 --- a/src/lib/Clouseau.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _CLOUSEAU_H -#define _CLOUSEAU_H - -/* FIXME: This doesn't include anything yet. - * Still need to expose stuff for clouseaud and clouseau_client. Those will be - * added once the whole interface will be better defined. - * These functions will probably need to be renamed/change as well. - * We'll also remove the private include once things are done. */ - -#include -#include -#include - -typedef struct _Clouseau_Bitmap Clouseau_Bitmap; -typedef struct _Clouseau_Tree_Item Clouseau_Tree_Item; - -/* Legacy type. */ -typedef struct _Clouseau_Object Clouseau_Object; - -struct _Clouseau_Bitmap -{ - unsigned char *bmp; - int bmp_count; /* is (w * h), for EET_DATA_DESCRIPTOR_ADD_BASIC_VAR_ARRAY */ - Evas_Coord w; - Evas_Coord h; -}; - -/* FIXME: Should name be a stringshare? - * FIXME: Should strip this structure to be half the size. Most of the stuff are - * not really needed. */ -struct _Clouseau_Tree_Item -{ - Eina_List *children; - Eina_List *eo_info; /* The intermediate type we use for eet. */ - Efl_Dbg_Info *new_eo_info; - const char *name; - unsigned long long ptr; /* Just a ptr, we keep the value but not accessing mem */ - Clouseau_Object *info; /* Legacy */ - Eina_Bool is_obj; - Eina_Bool is_clipper; - Eina_Bool is_visible; -}; - -EAPI Eina_Bool clouseau_app_connect(const char *appname); - -EAPI Eina_Bool clouseau_daemon_connect(void); -EAPI Eina_Bool clouseau_client_connect(void); -EAPI Eina_Bool clouseau_disconnect(void); - -EAPI int clouseau_init(void); -EAPI int clouseau_shutdown(void); - -/* FIXME: Remove. */ -#include "clouseau_private.h" - -#endif diff --git a/src/lib/Clouseau_Debug.h b/src/lib/Clouseau_Debug.h new file mode 100644 index 0000000..1ee0e59 --- /dev/null +++ b/src/lib/Clouseau_Debug.h @@ -0,0 +1,120 @@ +#ifndef _CLOUSEAU_DEBUG_H +#define _CLOUSEAUEO_DEBUG_H + +#ifdef EAPI +# undef EAPI +#endif + +#ifdef _WIN32 +# ifdef DEBUG_BUILD +# ifdef DLL_EXPORT +# define EAPI __declspec(dllexport) +# else +# define EAPI +# endif /* ! DLL_EXPORT */ +# else +# define EAPI __declspec(dllimport) +# endif /* ! DEBUG_BUILD */ +#else +# ifdef __GNUC__ +# if __GNUC__ >= 4 +# define EAPI __attribute__ ((visibility("default"))) +# else +# define EAPI +# endif +# else +# define EAPI +# endif +#endif /* ! _WIN32 */ + +#define EOLIAN_DEBUG_MAXARGS 15 + +#include +#include + +typedef void (*Eo_Debug_Class_Extract_Cb)(void *data, uint64_t kl, char *kl_name); + +typedef void (*Eo_Debug_Object_Extract_Cb)(void *data, uint64_t obj, uint64_t kl, uint64_t parent); + +typedef enum +{ + EOLIAN_DEBUG_INVALID_TYPE = 0, + EOLIAN_DEBUG_POINTER, + EOLIAN_DEBUG_STRING, + EOLIAN_DEBUG_CHAR, + EOLIAN_DEBUG_INT, + EOLIAN_DEBUG_SHORT, + EOLIAN_DEBUG_DOUBLE, + EOLIAN_DEBUG_BOOLEAN, + EOLIAN_DEBUG_LONG, + EOLIAN_DEBUG_UINT, + EOLIAN_DEBUG_VOID +} Eolian_Debug_Basic_Type; + +typedef struct +{ + Eolian_Debug_Basic_Type type; + union + { + uint64_t value; + } value; +} Eolian_Debug_Value; + +typedef struct +{ + Eolian_Debug_Value value; + const Eolian_Function_Parameter *eparam; +} Eolian_Debug_Parameter; + +typedef struct +{ + Eolian_Debug_Value value; + const Eolian_Type *etype; +} Eolian_Debug_Return; + +typedef struct +{ + const Eolian_Function *efunc; + Eolian_Debug_Return ret; + Eina_List *params; /* List of Eolian_Debug_Parameter * */ +} Eolian_Debug_Function; + +typedef struct +{ + const Eolian_Unit *unit; + const Eolian_Class *ekl; + Eina_List *functions; /* List of Eolian_Debug_Function * */ +} Eolian_Debug_Class; + +typedef struct +{ + uint64_t obj; /* Eo * */ + Eina_List *classes; /* List of Eolian_Debug_Class * */ +} Eolian_Debug_Object_Information; + +typedef struct +{ + uint64_t obj; + int w; + int h; + char *img; + int img_size; + int tm_sec; + int tm_min; + int tm_hour; +} Evas_Debug_Screenshot; + +EAPI void *eo_debug_eoids_request_prepare(int *size, ...); + +EAPI void eo_debug_klids_extract(void *buffer, int size, Eo_Debug_Class_Extract_Cb cb, void *data); + +EAPI void eo_debug_eoids_extract(void *buffer, int size, Eo_Debug_Object_Extract_Cb cb, void *data); + +EAPI void eolian_debug_object_information_free(Eolian_Debug_Object_Information *main); + +EAPI Eolian_Debug_Object_Information * +eolian_debug_object_information_decode(char *buffer, unsigned int size); + +EAPI Evas_Debug_Screenshot * +evas_debug_screenshot_decode(char *buffer, unsigned int size); +#endif diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am deleted file mode 100644 index 4798abe..0000000 --- a/src/lib/Makefile.am +++ /dev/null @@ -1,42 +0,0 @@ -MAINTAINERCLEANFILES = Makefile.in - -AM_CPPFLAGS = \ --I$(top_srcdir)/src/include \ --I$(top_builddir)/src/include \ --DPACKAGE_BIN_DIR=\"$(bindir)\" \ --DPACKAGE_LIB_DIR=\"$(libdir)\" \ --DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ -@EFL_CFLAGS@ - -EXTRA_DIST = \ - clouseau_private.h \ - clouseau_private2.h \ - clouseau_data_legacy.h - -includesdir = $(includedir)/clouseau-@VMAJ@ -includes_HEADERS = \ - Clouseau.h - -pkgdir = $(libdir)/clouseau -pkg_LTLIBRARIES = libclouseau_preload.la -lib_LTLIBRARIES = libclouseau.la - -libclouseau_la_SOURCES = clouseau_object_information.c \ - clouseau_data_legacy.c \ - clouseau.c \ - clouseau_app.c \ - clouseau_data.c - -libclouseau_la_DEPENDENCIES = $(top_builddir)/config.h -libclouseau_la_LIBADD = @EFL_LIBS@ -libclouseau_la_CFLAGS = @EFL_CFLAGS@ -DCLOUSEAUD_PATH=\"$(bindir)/clouseaud\" -libclouseau_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@ - -libclouseau_preload_la_SOURCES = \ - clouseau_preload.c - -libclouseau_preload_la_LDFLAGS = -module -avoid-version -rdynamic -libclouseau_preload_la_DEPENDENCIES = $(top_builddir)/config.h libclouseau.la -libclouseau_preload_la_LIBADD = libclouseau.la @EFL_LIBS@ -libclouseau_preload_la_CFLAGS = @EFL_CFLAGS@ - diff --git a/src/lib/clouseau.c b/src/lib/clouseau.c deleted file mode 100644 index 86092f5..0000000 --- a/src/lib/clouseau.c +++ /dev/null @@ -1,56 +0,0 @@ -#include "clouseau_private.h" - -static int _clouseau_init_count = 0; - -EAPI Eina_Bool -clouseau_daemon_connect(void) -{ - return EINA_TRUE; -} - -EAPI Eina_Bool -clouseau_client_connect(void) -{ - return EINA_TRUE; -} - -EAPI Eina_Bool -clouseau_disconnect(void) -{ - clouseau_app_disconnect(); - return EINA_TRUE; -} - -EAPI int -clouseau_init(void) -{ - if (++_clouseau_init_count == 1) - { - eina_init(); - ecore_init(); - ecore_con_init(); - clouseau_data_init(); - } - - return _clouseau_init_count; -} - -EAPI int -clouseau_shutdown(void) -{ - if (--_clouseau_init_count == 0) - { - clouseau_disconnect(); - clouseau_data_shutdown(); - ecore_con_shutdown(); - ecore_shutdown(); - eina_shutdown(); - } - else if (_clouseau_init_count < 0) - { - _clouseau_init_count = 0; - printf("Tried to shutdown although not initiated.\n"); - } - - return _clouseau_init_count; -} diff --git a/src/lib/clouseau_app.c b/src/lib/clouseau_app.c deleted file mode 100644 index 09b5107..0000000 --- a/src/lib/clouseau_app.c +++ /dev/null @@ -1,505 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "clouseau_private.h" - -#include -#include - -static Ecore_Con_Server *econ_server = NULL; -static Ecore_Con_Eet *eet_svr = NULL; -static Eina_Stringshare *_my_appname = NULL; - -static Clouseau_Object *_clouseau_object_information_get(Clouseau_Tree_Item *treeit); - -static void -libclouseau_item_add(Evas_Object *o, Clouseau_Tree_Item *parent) -{ - Clouseau_Tree_Item *treeit; - Eina_List *children; - Evas_Object *child; - - treeit = calloc(1, sizeof(Clouseau_Tree_Item)); - if (!treeit) return ; - - treeit->ptr = (uintptr_t) o; - treeit->is_obj = EINA_TRUE; - - treeit->name = eina_stringshare_add(efl_class_name_get(o)); - - /* FIXME: Hack to work with old smart inheritance. - * Check if the class *is* (not just implements) Evas_Smart. */ - if (efl_class_get(o) == EFL_CANVAS_GROUP_CLASS) - { - char buf[1024]; - snprintf(buf, sizeof(buf), "%s (%s)", evas_object_type_get(o), treeit->name); - eina_stringshare_replace(&treeit->name, buf); - } - - treeit->is_clipper = !!evas_object_clipees_get(o); - treeit->is_visible = evas_object_visible_get(o); - treeit->info = _clouseau_object_information_get(treeit); - - parent->children = eina_list_append(parent->children, treeit); - - /* if (!evas_object_smart_data_get(o)) return ; */ - - /* Do this only for smart object */ - if (efl_isa(o, EFL_CANVAS_GROUP_CLASS)) - { - children = evas_object_smart_members_get(o); - EINA_LIST_FREE(children, child) - libclouseau_item_add(child, treeit); - } -} - -static void * -_canvas_bmp_get(Ecore_Evas *ee, Evas_Coord *w_out, Evas_Coord *h_out) -{ - Ecore_X_Image *img; - Ecore_X_Window_Attributes att; - unsigned char *src; - unsigned int *dst; - int bpl = 0, rows = 0, bpp = 0; - Evas_Coord w, h; - - /* Check that this window still exists */ - Eina_List *eeitr, *ees = ecore_evas_ecore_evas_list_get(); - Ecore_Evas *eel; - Eina_Bool found_evas = EINA_FALSE; - - EINA_LIST_FOREACH(ees, eeitr, eel) - if (eel == ee) - { - found_evas = EINA_TRUE; - break; - } - - Ecore_X_Window xwin = (found_evas) ? - (Ecore_X_Window) ecore_evas_window_get(ee) : 0; - - if (!xwin) - { - printf("Can't grab X window.\n"); - *w_out = *h_out = 0; - return NULL; - } - - Evas *e = ecore_evas_get(ee); - evas_output_size_get(e, &w, &h); - memset(&att, 0, sizeof(Ecore_X_Window_Attributes)); - ecore_x_window_attributes_get(xwin, &att); - img = ecore_x_image_new(w, h, att.visual, att.depth); - ecore_x_image_get(img, xwin, 0, 0, 0, 0, w, h); - src = ecore_x_image_data_get(img, &bpl, &rows, &bpp); - dst = malloc(w * h * sizeof(int)); /* Will be freed by the user */ - if (!ecore_x_image_is_argb32_get(img)) - { /* Fill dst buffer with image convert */ - ecore_x_image_to_argb_convert(src, bpp, bpl, - att.colormap, att.visual, - 0, 0, w, h, - dst, (w * sizeof(int)), 0, 0); - } - else - { /* Fill dst buffer by copy */ - memcpy(dst, src, (w * h * sizeof(int))); - } - - /* dst now holds window bitmap */ - ecore_x_image_free(img); - *w_out = w; - *h_out = h; - return (void *) dst; -} - -static Eina_List * -_load_list(void) -{ - Eina_List *tree = NULL; - Eina_List *ees; - Ecore_Evas *ee; - - ees = ecore_evas_ecore_evas_list_get(); - - EINA_LIST_FREE(ees, ee) - { - Eina_List *objs; - Evas_Object *obj; - Clouseau_Tree_Item *treeit; - - Evas *e; - int w, h; - - e = ecore_evas_get(ee); - evas_output_size_get(e, &w, &h); - - treeit = calloc(1, sizeof(Clouseau_Tree_Item)); - if (!treeit) continue ; - - treeit->name = eina_stringshare_add(ecore_evas_title_get(ee)); - treeit->ptr = (uintptr_t) ee; - - tree = eina_list_append(tree, treeit); - - objs = evas_objects_in_rectangle_get(e, SHRT_MIN, SHRT_MIN, - USHRT_MAX, USHRT_MAX, EINA_TRUE, EINA_TRUE); - - EINA_LIST_FREE(objs, obj) - libclouseau_item_add(obj, treeit); - } - - return tree; /* User has to call clouseau_tree_free() */ -} - -/* Highlight functions. */ -static Eina_Bool -_clouseau_highlight_fade(void *_rect) -{ - Evas_Object *rect = _rect; - int r, g, b, a; - double na; - - evas_object_color_get(rect, &r, &g, &b, &a); - if (a < 20) - { - evas_object_del(rect); - /* The del callback of the object will destroy the animator */ - return EINA_TRUE; - } - - na = a - 5; - r = na / a * r; - g = na / a * g; - b = na / a * b; - evas_object_color_set(rect, r, g, b, na); - - return EINA_TRUE; -} - -static Evas_Object * -_clouseau_verify_e_children(Evas_Object *obj, Evas_Object *ptr) -{ - /* Verify that obj still exists (can be found on evas canvas) */ - Evas_Object *child; - Evas_Object *p = NULL; - Eina_List *children; - - if (ptr == obj) - return ptr; - - if (efl_isa(obj, EFL_CANVAS_GROUP_CLASS)) - { - children = evas_object_smart_members_get(obj); - EINA_LIST_FREE(children, child) - { - p = _clouseau_verify_e_children(child, ptr); - if (p) break; - } - eina_list_free(children); - } - - return p; -} - -static Evas_Object * -_clouseau_verify_e_obj(Evas_Object *obj) -{ - /* Verify that obj still exists (can be found on evas canvas) */ - Evas_Object *o; - Eina_List *ees; - Ecore_Evas *ee; - Evas_Object *rt = NULL; - - ees = ecore_evas_ecore_evas_list_get(); - EINA_LIST_FREE(ees, ee) - { - Evas *e; - Eina_List *objs; - - e = ecore_evas_get(ee); - objs = evas_objects_in_rectangle_get(e, SHRT_MIN, SHRT_MIN, - USHRT_MAX, USHRT_MAX, - EINA_TRUE, EINA_TRUE); - - EINA_LIST_FREE(objs, o) - { - rt = _clouseau_verify_e_children(o, obj); - if (rt) break; - } - eina_list_free(objs); - - if (rt) break; - } - eina_list_free(ees); - - return rt; -} - -static void -_clouseau_highlight_del(void *data, - EINA_UNUSED Evas *e, - EINA_UNUSED Evas_Object *obj, - EINA_UNUSED void *event_info) -{ /* Delete timer for this rect */ - ecore_animator_del(data); -} - - -EAPI void -clouseau_data_object_highlight(Evas_Object *obj) -{ - const Evas_Map *map; - Ecore_Animator *t; - Evas *e = NULL; - Evas_Object *r; - int x, y, wd, ht; - - e = evas_object_evas_get(obj); - r = evas_object_polygon_add(e); - - if ((map = evas_object_map_get(obj))) - { - int i = evas_map_count_get(map); - for ( ; i > 0 ; i--) - { - Evas_Coord mx, my; - evas_map_point_coord_get(map, i - 1, &mx, &my, NULL); - evas_object_polygon_point_add(r, mx, my); - } - } - else - { - evas_object_geometry_get(obj, &x, &y, &wd, &ht); - evas_object_polygon_point_add(r, x, y); - evas_object_polygon_point_add(r, x + wd, y); - evas_object_polygon_point_add(r, x + wd, y + ht); - evas_object_polygon_point_add(r, x, y + ht); - } - - evas_object_layer_set(r, EVAS_LAYER_MAX); - evas_object_color_set(r, - HIGHLIGHT_R, HIGHLIGHT_G, HIGHLIGHT_B, HIGHLIGHT_A); - evas_object_show(r); - - /* Add Timer for fade and a callback to delete timer on obj del */ - t = ecore_animator_add(_clouseau_highlight_fade, r); - evas_object_event_callback_add(r, EVAS_CALLBACK_DEL, - _clouseau_highlight_del, t); -} - -static Clouseau_Object * -_clouseau_object_information_get(Clouseau_Tree_Item *treeit) -{ - Evas_Object *obj = (void*) (uintptr_t) treeit->ptr; - Efl_Dbg_Info *efl_dbg_info; - - if (!treeit->is_obj) - return NULL; - - efl_dbg_info = EFL_DBG_INFO_LIST_APPEND(NULL, ""); - efl_dbg_info_get(obj, efl_dbg_info); - - /* XXX: Edje information that should be here because Evas objects can't - * depend on Edje. This should be removed in the future. */ - { - const char *part_name = edje_object_part_object_name_get(obj); - if (part_name) - { - Efl_Dbg_Info *group = EFL_DBG_INFO_LIST_APPEND(efl_dbg_info, "Edje_Part"); - EFL_DBG_INFO_APPEND(group, "Part name", EINA_VALUE_TYPE_STRING, part_name); - } - } - - treeit->eo_info = clouseau_eo_to_legacy_convert(efl_dbg_info); - - efl_dbg_info_free(efl_dbg_info); /* Free original list */ - - return NULL; -} - - -Eina_Bool -_add(EINA_UNUSED void *data, Ecore_Con_Reply *reply, - EINA_UNUSED Ecore_Con_Server *conn) -{ -/* ecore_con_server_data_size_max_set(conn, -1); */ - connect_st t = { getpid(), _my_appname }; - ecore_con_eet_send(reply, CLOUSEAU_APP_CLIENT_CONNECT_STR, &t); - - return ECORE_CALLBACK_RENEW; -} - -Eina_Bool -_del(EINA_UNUSED void *data, EINA_UNUSED Ecore_Con_Reply *reply, - Ecore_Con_Server *conn) -{ - if (!conn) - { - printf("Failed to establish connection to the server.\n"); - } - - printf("Lost server with ip <%s>\n", ecore_con_server_ip_get(conn)); - - ecore_con_server_del(conn); - - return ECORE_CALLBACK_RENEW; -} - -void -_data_req_cb(EINA_UNUSED void *data, Ecore_Con_Reply *reply, - EINA_UNUSED const char *protocol_name, void *value) -{ /* data req includes ptr to GUI, to tell which client asking */ - data_req_st *req = value; - tree_data_st t; - t.gui = req->gui; /* GUI client requesting data from daemon */ - t.app = req->app; /* APP client sending data to daemon */ - t.tree = _load_list(); - - if (t.tree) - { /* Reply with tree data to data request */ - ecore_con_eet_send(reply, CLOUSEAU_TREE_DATA_STR, &t); - clouseau_data_tree_free(t.tree); - } -} - -void -_highlight_cb(EINA_UNUSED void *data, EINA_UNUSED Ecore_Con_Reply *reply, - EINA_UNUSED const char *protocol_name, void *value) -{ /* Highlight msg contains PTR of object to highlight */ - highlight_st *ht = value; - Evas_Object *obj = (Evas_Object *) (uintptr_t) ht->object; - - if (!_clouseau_verify_e_obj(obj)) - { - printf("Evas Object not found <%p> (probably deleted)\n", obj); - return; - } - - clouseau_data_object_highlight(obj); -} - -void -_bmp_req_cb(EINA_UNUSED void *data, EINA_UNUSED Ecore_Con_Reply *reply, - EINA_UNUSED const char *protocol_name, void *value) -{ /* Bitmap req msg contains PTR of Ecore Evas */ - bmp_req_st *req = value; - Evas_Coord w, h; - unsigned int size = 0; - void *bmp = _canvas_bmp_get((Ecore_Evas *) (uintptr_t) - req->object, &w, &h); - - bmp_info_st t = { req->gui, - req->app, req->object , req->ctr, w, h, - NULL,NULL, NULL, 1.0, - NULL, NULL, NULL, NULL, NULL, NULL }; - - void *p = clouseau_data_packet_compose(CLOUSEAU_BMP_DATA_STR, - &t, &size, bmp, (w * h * sizeof(int))); - - - if (p) - { - ecore_con_eet_raw_send(reply, CLOUSEAU_BMP_DATA_STR, "BMP", p, size); - free(p); - } - - if (bmp) - free(bmp); -} - -typedef struct -{ - Ecore_Event_Handler *ee_handle; - Ecore_Exe *daemon_exe; -} Msg_From_Daemon_Data; - -static void -_msg_from_daemon_data_free(Msg_From_Daemon_Data *msg_data) -{ - ecore_event_handler_del(msg_data->ee_handle); - ecore_exe_free(msg_data->daemon_exe); - free(msg_data); -} - -static Eina_Bool -_msg_from_daemon(void *data, int type EINA_UNUSED, void *event) -{ - Ecore_Exe_Event_Data *msg = (Ecore_Exe_Event_Data *)event; - - if (!strncmp(msg->data, CLOUSEAUD_READY_STR, sizeof(CLOUSEAUD_READY_STR))) - { - const char *address = LOCALHOST; - - if (eet_svr) - { - fprintf(stderr, "Clouseau: Trying to connect to daemon although already supposedly connected. Error.\n"); - return ECORE_CALLBACK_DONE; - } - - econ_server = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, - LOCALHOST, PORT, NULL); - - if (!econ_server) - { - printf("could not connect to the server: %s, port %d.\n", - address, PORT); - return ECORE_CALLBACK_DONE; - } - - eet_svr = ecore_con_eet_client_new(econ_server); - if (!eet_svr) - { - printf("could not create con_eet client.\n"); - return ECORE_CALLBACK_DONE; - } - - clouseau_register_descs(eet_svr); - - /* Register callbacks for ecore_con_eet */ - ecore_con_eet_server_connect_callback_add(eet_svr, _add, NULL); - ecore_con_eet_server_disconnect_callback_add(eet_svr, _del, NULL); - ecore_con_eet_data_callback_add(eet_svr, CLOUSEAU_DATA_REQ_STR, - _data_req_cb, NULL); - ecore_con_eet_data_callback_add(eet_svr, CLOUSEAU_HIGHLIGHT_STR, - _highlight_cb, NULL); - ecore_con_eet_data_callback_add(eet_svr, CLOUSEAU_BMP_REQ_STR, - _bmp_req_cb, NULL); - - _msg_from_daemon_data_free(data); - } - - return ECORE_CALLBACK_DONE; -} - -void -clouseau_app_disconnect(void) -{ - if (eet_svr) ecore_con_eet_server_free(eet_svr); - eet_svr = NULL; - if (econ_server) ecore_con_server_del(econ_server); - econ_server = NULL; -} - -EAPI Eina_Bool -clouseau_app_connect(const char *appname) -{ - Msg_From_Daemon_Data *msg_data = calloc(1, sizeof(*msg_data)); - - eina_stringshare_replace(&_my_appname, appname); - - msg_data->ee_handle = ecore_event_handler_add(ECORE_EXE_EVENT_DATA, _msg_from_daemon, msg_data); - /* FIXME: Possibly have a better way to get rid of preload. */ - msg_data->daemon_exe = ecore_exe_pipe_run("LD_PRELOAD='' " CLOUSEAUD_PATH, - ECORE_EXE_PIPE_READ_LINE_BUFFERED | - ECORE_EXE_PIPE_READ, NULL); - - if (!msg_data->daemon_exe) - { - _msg_from_daemon_data_free(msg_data); - fprintf(stderr, "Could not start the daemon.!\n"); - return EINA_FALSE; - } - - return EINA_TRUE; -} diff --git a/src/lib/clouseau_data.c b/src/lib/clouseau_data.c deleted file mode 100644 index 037e156..0000000 --- a/src/lib/clouseau_data.c +++ /dev/null @@ -1,814 +0,0 @@ -#include "clouseau_private.h" -#include "clouseau_data_legacy.h" - -static int clouseau_init_count = 0; - -static Eet_Data_Descriptor *clouseau_union_edd = NULL; -static Eet_Data_Descriptor *clouseau_connect_edd = NULL; -static Eet_Data_Descriptor *clouseau_app_add_edd = NULL; -static Eet_Data_Descriptor *clouseau_data_req_edd = NULL; -static Eet_Data_Descriptor *clouseau_bmp_info_edd = NULL; -static Eet_Data_Descriptor *clouseau_shot_list_edd = NULL; -static Eet_Data_Descriptor *clouseau_tree_data_edd = NULL; -static Eet_Data_Descriptor *clouseau_tree_edd = NULL; -static Eet_Data_Descriptor *clouseau_app_closed_edd = NULL; -static Eet_Data_Descriptor *clouseau_highlight_edd = NULL; -static Eet_Data_Descriptor *clouseau_bmp_req_edd = NULL; -static Eet_Data_Descriptor *clouseau_protocol_edd = NULL; - -static Eet_Data_Descriptor *eo_string_edd = NULL; -static Eet_Data_Descriptor *eo_int_edd = NULL; -static Eet_Data_Descriptor *eo_bool_edd = NULL; -static Eet_Data_Descriptor *eo_ptr_edd = NULL; -static Eet_Data_Descriptor *eo_double_edd = NULL; -static Eet_Data_Descriptor *eo_list_edd = NULL; -static Eet_Data_Descriptor *efl_dbg_info_edd = NULL; - -EAPI void -clouseau_eo_info_free(Clouseau_Efl_Dbg_Info *parent) -{ - Clouseau_Efl_Dbg_Info *eo; - - if (parent->type == CLOUSEAU_DBG_INFO_TYPE_LIST) - EINA_LIST_FREE(parent->un_dbg_info.dbg.list, eo) - clouseau_eo_info_free(eo); - else if (parent->type == CLOUSEAU_DBG_INFO_TYPE_STRING) - eina_stringshare_del(parent->un_dbg_info.text.s); - - eina_stringshare_del(parent->name); - free(parent); -} - - -EAPI Efl_Dbg_Info* -clouseau_eo_info_find(Efl_Dbg_Info *root, const char *name) -{ - Eina_Value_List eo_list; - Eina_List *n; - Efl_Dbg_Info *info; - - if (!root) return NULL; - - eina_value_pget(&(root->value), &eo_list); - - EINA_LIST_FOREACH(eo_list.list, n, info) - { - if (!strcmp(info->name, name)) - { - return info; - } - } - return NULL; -} - -static void -_clouseau_tree_item_free(Clouseau_Tree_Item *parent) -{ - Clouseau_Tree_Item *treeit; - Clouseau_Efl_Dbg_Info *eo; - - if (parent->new_eo_info) - efl_dbg_info_free(parent->new_eo_info); - - EINA_LIST_FREE(parent->eo_info, eo) - clouseau_eo_info_free(eo); - - EINA_LIST_FREE(parent->children, treeit) - _clouseau_tree_item_free(treeit); - - clouseau_object_information_free(parent->info); - eina_stringshare_del(parent->name); - free(parent); -} - -EAPI void -clouseau_data_tree_free(Eina_List *tree) -{ - Clouseau_Tree_Item *treeit; - - EINA_LIST_FREE(tree, treeit) - _clouseau_tree_item_free(treeit); -} - -static void -_clouseau_connect_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, connect_st); - clouseau_connect_edd = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_connect_edd, connect_st, - "pid", pid, EET_T_UINT); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_connect_edd, connect_st, - "name", name, EET_T_STRING); -} - -static void -_clouseau_app_add_desc_make(void) -{ /* view field not transferred, will be loaded on user request */ - Eet_Data_Descriptor_Class eddc; - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, app_info_st); - clouseau_app_add_edd = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_app_add_edd, app_info_st, - "pid", pid, EET_T_UINT); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_app_add_edd, app_info_st, - "name", name, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_app_add_edd, app_info_st, - "ptr", ptr, EET_T_ULONG_LONG); -} - -static void -_clouseau_req_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, data_req_st); - clouseau_data_req_edd = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_data_req_edd, data_req_st, - "gui", gui, EET_T_ULONG_LONG); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_data_req_edd, data_req_st, - "app", app, EET_T_ULONG_LONG); -} - -static void -_clouseau_bmp_info_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, bmp_info_st); - clouseau_bmp_info_edd = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_bmp_info_edd, bmp_info_st, - "gui", gui, EET_T_ULONG_LONG); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_bmp_info_edd, bmp_info_st, - "app", app, EET_T_ULONG_LONG); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_bmp_info_edd, bmp_info_st, - "object", object, EET_T_ULONG_LONG); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_bmp_info_edd, bmp_info_st, - "ctr", ctr, EET_T_ULONG_LONG); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_bmp_info_edd, bmp_info_st, - "w", w, EET_T_ULONG_LONG); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_bmp_info_edd, bmp_info_st, - "h", h, EET_T_ULONG_LONG); -} - -static void -_clouseau_shot_list_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, shot_list_st); - clouseau_shot_list_edd = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_LIST(clouseau_shot_list_edd, shot_list_st, - "view", view, clouseau_bmp_info_edd); -} - -static void -_clouseau_tree_item_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Clouseau_Tree_Item); - clouseau_tree_edd = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_LIST(clouseau_tree_edd, Clouseau_Tree_Item, - "children", children, clouseau_tree_edd); - EET_DATA_DESCRIPTOR_ADD_LIST(clouseau_tree_edd, Clouseau_Tree_Item, - "eo_info", eo_info, efl_dbg_info_edd); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_tree_edd, Clouseau_Tree_Item, - "name", name, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_tree_edd, Clouseau_Tree_Item, - "ptr", ptr, EET_T_ULONG_LONG); - EET_DATA_DESCRIPTOR_ADD_SUB(clouseau_tree_edd, Clouseau_Tree_Item, - "info", info, clouseau_object_edd); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_tree_edd, Clouseau_Tree_Item, - "is_obj", is_obj, EET_T_UCHAR); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_tree_edd, Clouseau_Tree_Item, - "is_clipper", is_clipper, EET_T_UCHAR); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_tree_edd, Clouseau_Tree_Item, - "is_visible", is_visible, EET_T_UCHAR); -} - -static void -_clouseau_tree_data_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, tree_data_st); - clouseau_tree_data_edd = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_tree_data_edd, tree_data_st, - "gui", gui, EET_T_ULONG_LONG); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_tree_data_edd, tree_data_st, - "app", app, EET_T_ULONG_LONG); - EET_DATA_DESCRIPTOR_ADD_LIST(clouseau_tree_data_edd, tree_data_st, - "tree", tree, clouseau_tree_edd); -} - -static void -_clouseau_app_closed_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, app_closed_st); - clouseau_app_closed_edd = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_app_closed_edd, app_closed_st, - "ptr", ptr, EET_T_ULONG_LONG); -} - -static void -_clouseau_highlight_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, highlight_st); - clouseau_highlight_edd = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_highlight_edd, highlight_st, - "app", app, EET_T_ULONG_LONG); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_highlight_edd, highlight_st, - "object", object, EET_T_ULONG_LONG); -} - -static void -_clouseau_bmp_req_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, bmp_req_st); - clouseau_bmp_req_edd = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_bmp_req_edd, bmp_req_st, - "gui", gui, EET_T_ULONG_LONG); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_bmp_req_edd, bmp_req_st, - "app", app, EET_T_ULONG_LONG); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_bmp_req_edd, bmp_req_st, - "object", object, EET_T_ULONG_LONG); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_bmp_req_edd, bmp_req_st, - "ctr", ctr, EET_T_UINT); -} - -/* START EO descs */ -struct _Clouseau_Efl_Dbg_Info_Mapping -{ - Clouseau_Dbg_Info_Type u; - const char *name; -}; -typedef struct _Clouseau_Efl_Dbg_Info_Mapping Clouseau_Efl_Dbg_Info_Mapping; - -/* It's init later. */ -static Clouseau_Efl_Dbg_Info_Mapping eet_dbg_info_mapping[] = -{ - { CLOUSEAU_DBG_INFO_TYPE_STRING, EFL_DBG_INFO_TYPE_STRING_STR }, - { CLOUSEAU_DBG_INFO_TYPE_INT, EFL_DBG_INFO_TYPE_INT_STR }, - { CLOUSEAU_DBG_INFO_TYPE_BOOL, EFL_DBG_INFO_TYPE_BOOL_STR }, - { CLOUSEAU_DBG_INFO_TYPE_PTR, EFL_DBG_INFO_TYPE_PTR_STR }, - { CLOUSEAU_DBG_INFO_TYPE_DOUBLE, EFL_DBG_INFO_TYPE_DOUBLE_STR }, - { CLOUSEAU_DBG_INFO_TYPE_LIST, EFL_DBG_INFO_TYPE_LIST_STR }, - { CLOUSEAU_DBG_INFO_TYPE_UNKNOWN, NULL } -}; - -static const char * -_dbg_info_union_type_get(const void *data, Eina_Bool *unknow) -{ /* _union_type_get */ - const Clouseau_Dbg_Info_Type *u = data; - int i; - - if (unknow) - *unknow = EINA_FALSE; - - for (i = 0; eet_dbg_info_mapping[i].name != NULL; ++i) - if (*u == eet_dbg_info_mapping[i].u) - return eet_dbg_info_mapping[i].name; - - if (unknow) - *unknow = EINA_TRUE; - - return NULL; -} - -static Eina_Bool -_dbg_info_union_type_set(const char *type, void *data, Eina_Bool unknow) -{ /* same as _union_type_set */ - Clouseau_Dbg_Info_Type *u = data; - int i; - - if (unknow) - return EINA_FALSE; - - for (i = 0; eet_dbg_info_mapping[i].name != NULL; ++i) - if (strcmp(eet_dbg_info_mapping[i].name, type) == 0) - { - *u = eet_dbg_info_mapping[i].u; - return EINA_TRUE; - } - - return EINA_FALSE; -} - -static Eet_Data_Descriptor * -clouseau_string_desc_make(void) -{ - Eet_Data_Descriptor *d; - - Eet_Data_Descriptor_Class eddc; - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Clouseau_st_string); - d = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC (d, Clouseau_st_string, "s", - s, EET_T_STRING); - - return d; -} - -static Eet_Data_Descriptor * -clouseau_int_desc_make(void) -{ - Eet_Data_Descriptor *d; - - Eet_Data_Descriptor_Class eddc; - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Clouseau_st_int); - d = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC (d, Clouseau_st_int, "i", - i, EET_T_INT); - - return d; -} - -static Eet_Data_Descriptor * -clouseau_bool_desc_make(void) -{ - Eet_Data_Descriptor *d; - - Eet_Data_Descriptor_Class eddc; - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Clouseau_st_bool); - d = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC (d, Clouseau_st_bool, "b", - b, EET_T_UCHAR); - - return d; -} - -static Eet_Data_Descriptor * -clouseau_ptr_desc_make(void) -{ - Eet_Data_Descriptor *d; - - Eet_Data_Descriptor_Class eddc; - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Clouseau_st_ptr); - d = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC (d, Clouseau_st_ptr, "p", - p, EET_T_ULONG_LONG); - - return d; -} - -static Eet_Data_Descriptor * -clouseau_double_desc_make(void) -{ - Eet_Data_Descriptor *d; - - Eet_Data_Descriptor_Class eddc; - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Clouseau_st_double); - d = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC (d, Clouseau_st_double, "d", - d, EET_T_DOUBLE); - - return d; -} - -static Eet_Data_Descriptor * -clouseau_list_desc_make(void) -{ - Eet_Data_Descriptor *d; - - Eet_Data_Descriptor_Class eddc; - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Clouseau_st_dbg_list); - d = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_LIST (d, Clouseau_st_dbg_list, - "list", list, efl_dbg_info_edd); /* Carefull, has to be initiated */ - - return d; -} - -static void -_clouseau_eo_descs_make(void) -{ - Eet_Data_Descriptor_Class eddc; - - eo_string_edd = clouseau_string_desc_make(); - eo_int_edd = clouseau_int_desc_make(); - eo_bool_edd = clouseau_bool_desc_make(); - eo_ptr_edd = clouseau_ptr_desc_make(); - eo_double_edd = clouseau_double_desc_make(); - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Clouseau_Efl_Dbg_Info); - efl_dbg_info_edd = eet_data_descriptor_stream_new(&eddc); - EET_DATA_DESCRIPTOR_ADD_BASIC (efl_dbg_info_edd, Clouseau_Efl_Dbg_Info, - "name", name, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC (efl_dbg_info_edd, Clouseau_Efl_Dbg_Info, - "type", type, EET_T_UINT); - - /* Here because clouseau_list_desc_make() uses efl_dbg_info_edd */ - eo_list_edd = clouseau_list_desc_make(); - - /* for union */ - eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION; - eddc.func.type_get = _dbg_info_union_type_get; - eddc.func.type_set = _dbg_info_union_type_set; - clouseau_union_edd = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_MAPPING( - clouseau_union_edd, EFL_DBG_INFO_TYPE_STRING_STR - ,eo_string_edd); - - EET_DATA_DESCRIPTOR_ADD_MAPPING( - clouseau_union_edd, EFL_DBG_INFO_TYPE_INT_STR - ,eo_int_edd); - - EET_DATA_DESCRIPTOR_ADD_MAPPING( - clouseau_union_edd, EFL_DBG_INFO_TYPE_BOOL_STR - ,eo_bool_edd); - - EET_DATA_DESCRIPTOR_ADD_MAPPING( - clouseau_union_edd, EFL_DBG_INFO_TYPE_PTR_STR - ,eo_ptr_edd); - - EET_DATA_DESCRIPTOR_ADD_MAPPING( - clouseau_union_edd, EFL_DBG_INFO_TYPE_DOUBLE_STR - ,eo_double_edd); - - EET_DATA_DESCRIPTOR_ADD_MAPPING( - clouseau_union_edd, EFL_DBG_INFO_TYPE_LIST_STR - ,eo_list_edd); - - EET_DATA_DESCRIPTOR_ADD_UNION(efl_dbg_info_edd, - Clouseau_Efl_Dbg_Info, - "un_dbg_info", un_dbg_info, - type, clouseau_union_edd); -} -/* END EO descs */ - - - -static void -_clouseau_data_descriptors_init(void) -{ - clouseau_data_descriptors_legacy_init(); - _clouseau_eo_descs_make(); - _clouseau_bmp_req_desc_make(); - _clouseau_bmp_info_desc_make(); - _clouseau_shot_list_desc_make(); - _clouseau_tree_item_desc_make(); - _clouseau_connect_desc_make(); - _clouseau_app_add_desc_make(); - _clouseau_req_desc_make(); - _clouseau_tree_data_desc_make(); - _clouseau_app_closed_desc_make(); - _clouseau_highlight_desc_make(); -} - -static void -_clouseau_data_descriptors_shutdown(void) -{ - eet_data_descriptor_free(eo_string_edd); - eet_data_descriptor_free(eo_int_edd); - eet_data_descriptor_free(eo_bool_edd); - eet_data_descriptor_free(eo_ptr_edd); - eet_data_descriptor_free(eo_double_edd); - eet_data_descriptor_free(eo_list_edd); - eet_data_descriptor_free(efl_dbg_info_edd); - eet_data_descriptor_free(clouseau_union_edd); - - eet_data_descriptor_free(clouseau_connect_edd); - eet_data_descriptor_free(clouseau_app_add_edd); - eet_data_descriptor_free(clouseau_data_req_edd); - eet_data_descriptor_free(clouseau_tree_edd); - eet_data_descriptor_free(clouseau_app_closed_edd); - eet_data_descriptor_free(clouseau_highlight_edd); - eet_data_descriptor_free(clouseau_bmp_req_edd); - eet_data_descriptor_free(clouseau_bmp_info_edd); - eet_data_descriptor_free(clouseau_shot_list_edd); - eet_data_descriptor_free(clouseau_protocol_edd); - clouseau_data_descriptors_legacy_shutdown(); -} - -static void * -_host_to_net_blob_get(void *blob, int *blob_size) -{ - if (!blob) - return blob; - - /* Complete blob_size to sizeof(uint32_t) */ - int mod = (*blob_size) % sizeof(uint32_t); - if (mod) - *blob_size += (sizeof(uint32_t) - mod); - - void *n_blob = malloc(*blob_size); - uint32_t *src = blob; - uint32_t *dst = n_blob; - int cnt = (*blob_size) / sizeof(uint32_t); - while (cnt) - { - *dst = htonl(*src); - src++; - dst++; - cnt--; - } - - return n_blob; -} - -static void * -_net_to_host_blob_get(void *blob, int blob_size) -{ - if (!blob) - return blob; - - void *h_blob = malloc(blob_size); - - uint32_t *src = blob; - uint32_t *dst = h_blob; - int cnt = blob_size / sizeof(uint32_t); - while (cnt) - { - *dst = ntohl(*src); - src++; - dst++; - cnt--; - } - - return h_blob; -} - -EAPI void * -clouseau_data_packet_compose(const char *p_type, void *data, - unsigned int *size, void *blob, int blob_size) -{ /* Returns packet BLOB and size in size param, NULL on failure */ - /* User has to free returned buffer */ - /* Packet is composed of Message Type + packet data. */ - void *net_blob = NULL; - - if (!strcmp(p_type, CLOUSEAU_BMP_DATA_STR)) - { /* Builed Bitmap data as follows: - First uint32_t is encoding size of bmp_info_st - The next to come will be the encoded bmp_info_st itself - Then we have blob_size param (specifiying bmp-blob-size) - folloed by the Bitmap raw data. */ - - int t_size; /* total size */ - int e_size; - uint32_t e_size32; - uint32_t tmp; - void *p; - char *b; - char *ptr; - - /* First, we like to encode bmp_info_st from data */ - p = eet_data_descriptor_encode(clouseau_bmp_info_edd, data, &e_size); - e_size32 = (uint32_t) e_size; - - /* Allocate buffer to hold whole packet data */ - t_size = sizeof(e_size32) /* encoding size of bmp_info_st */ - + e_size /* Encoded bmp_info_st */ - + sizeof(e_size32) /* bmp-blob-size */ - + blob_size; /* The BMP blob data */ - - ptr = b = malloc(t_size); - - /* START - Build BMP_RAW_DATA packet data */ - /* Size of encoded bmp_info_st comes next in uint32 format */ - memcpy(ptr, &e_size32, sizeof(e_size32)); - ptr += sizeof(e_size32); - - /* Encoded bmp_info_st comes next */ - memcpy(ptr, p, e_size); - ptr += e_size; - - /* Size of BMP blob comes next */ - tmp = (uint32_t) blob_size; - memcpy(ptr, &tmp, sizeof(uint32_t)); - ptr += sizeof(uint32_t); - - if (blob && blob_size) - { /* BMP blob info comes right after BMP blob_size */ - memcpy(ptr, blob, blob_size); - } - - /* Save encoded size in network format */ - net_blob = _host_to_net_blob_get(b, &t_size); - *size = t_size; /* Update packet size */ - - /* All info now in net_blob, free allocated mem */ - free(b); - free(p); - /* END - Build BMP_RAW_DATA packet data */ - } - - return net_blob; -} - -EAPI void * -clouseau_data_packet_info_get(const char *p_type, void *data, size_t size) -{ - bmp_info_st *st = NULL; - void *host_blob = NULL; - char *ptr = NULL; - - if (size <= 0) - return NULL; - - host_blob = _net_to_host_blob_get(data, size); - ptr = host_blob; - - if (!strcmp(p_type, CLOUSEAU_BMP_DATA_STR)) - { - uint32_t *e_size32 = (uint32_t *) ptr; - int e_size = (int) (*e_size32); /* First Encoded bmp_info_st size */ - ptr += sizeof(uint32_t); - - /* Get the encoded bmp_info_st */ - st = eet_data_descriptor_decode(clouseau_bmp_info_edd - ,ptr, e_size); - ptr += e_size; - - st->bmp = NULL; - - /* Next Get bmp-blob-size */ - e_size32 = (uint32_t *) ptr; - e_size = (int) (*e_size32); /* Get bmp-blob size */ - ptr += sizeof(uint32_t); - - /* Now we need to get the bmp data */ - if (e_size) - { /* BMP data available, allocate and copy */ - st->bmp = malloc(e_size); /* Freed by user */ - memcpy(st->bmp, ptr, e_size); - } - } /* User has to free st, st->bmp */ - - free(host_blob); - return st; -} - -EAPI Eina_Bool -clouseau_data_eet_info_save(const char *filename, - app_info_st *a, tree_data_st *ftd, Eina_List *ck_list) -{ - Eina_List *shots = NULL; - Eina_List *l; - Eet_File *fp; - Evas_Object *ck; - - fp = eet_open(filename, EET_FILE_MODE_WRITE); - if (!fp) return EINA_FALSE; - - eet_data_write(fp, clouseau_app_add_edd, CLOUSEAU_APP_ADD_ENTRY, - a, EET_COMPRESSION_DEFAULT); - eet_data_write(fp, clouseau_tree_data_edd, CLOUSEAU_TREE_DATA_ENTRY, - ftd, EET_COMPRESSION_DEFAULT); - - /* Build list of (bmp_info_st *) according to user selection */ - EINA_LIST_FOREACH(ck_list, l , ck) - if (elm_check_state_get(ck)) - { - void *data; - - data = evas_object_data_get(ck, BMP_FIELD); - if (data) - shots = eina_list_append(shots, data); - } - - if (shots) - { - /* Write list and bitmaps */ - char buf[1024]; - shot_list_st t; - bmp_info_st *st; - - t.view = shots; - eet_data_write(fp, clouseau_shot_list_edd, CLOUSEAU_BMP_LIST_ENTRY, - &t, EET_COMPRESSION_DEFAULT); - EINA_LIST_FREE(shots, st) - { - sprintf(buf, CLOUSEAU_BMP_DATA_ENTRY"/%llx", st->object); - eet_data_image_write(fp, buf, st->bmp, - st->w, st->h, 1, 0, 100, 0); - } - } - - eet_close(fp); - - return EINA_TRUE; -} - -EAPI Eina_Bool -clouseau_data_eet_info_read(const char *filename, - app_info_st **a, tree_data_st **ftd) -{ - bmp_info_st *st; - shot_list_st *t; - Eet_File *fp; - - fp = eet_open(filename, EET_FILE_MODE_READ); - if (!fp) return EINA_FALSE; - - *a = eet_data_read(fp, clouseau_app_add_edd, CLOUSEAU_APP_ADD_ENTRY); - *ftd = eet_data_read(fp, clouseau_tree_data_edd, CLOUSEAU_TREE_DATA_ENTRY); - t = eet_data_read(fp, clouseau_shot_list_edd, CLOUSEAU_BMP_LIST_ENTRY); - - if (t) - { - EINA_LIST_FREE(t->view, st) - { - char buf[1024]; - int alpha; - int compress; - int quality; - Eet_Image_Encoding lossy; - - sprintf(buf, CLOUSEAU_BMP_DATA_ENTRY"/%llx", st->object); - st->bmp = eet_data_image_read(fp, buf, - (unsigned int *) &st->w, - (unsigned int *) &st->h, - &alpha, &compress, &quality, &lossy); - - /* Add the bitmaps to the actuall app data struct */ - (*a)->view = eina_list_append((*a)->view, st); - } - free(t); - } - - eet_close(fp); - - return EINA_TRUE; -} - -EAPI int -clouseau_data_init(void) -{ - if (clouseau_init_count++ != 0) - return clouseau_init_count; - - eina_init(); - eet_init(); - ecore_init(); - - _clouseau_data_descriptors_init(); - - return clouseau_init_count; -} - -int -clouseau_register_descs(Ecore_Con_Eet *eet_svr) -{ /* Register descriptors for ecore_con_eet */ - if (clouseau_init_count) - { /* MUST be called after clouseau_data_init */ - ecore_con_eet_register(eet_svr, CLOUSEAU_GUI_CLIENT_CONNECT_STR, - clouseau_connect_edd); - ecore_con_eet_register(eet_svr, CLOUSEAU_APP_CLIENT_CONNECT_STR, - clouseau_connect_edd); - ecore_con_eet_register(eet_svr, CLOUSEAU_APP_ADD_STR, - clouseau_app_add_edd); - ecore_con_eet_register(eet_svr, CLOUSEAU_DATA_REQ_STR, - clouseau_data_req_edd); - ecore_con_eet_register(eet_svr, CLOUSEAU_TREE_DATA_STR, - clouseau_tree_data_edd); - ecore_con_eet_register(eet_svr, CLOUSEAU_APP_CLOSED_STR, - clouseau_app_closed_edd); - ecore_con_eet_register(eet_svr, CLOUSEAU_HIGHLIGHT_STR, - clouseau_highlight_edd); - ecore_con_eet_register(eet_svr, CLOUSEAU_BMP_REQ_STR, - clouseau_bmp_req_edd); - ecore_con_eet_register(eet_svr, CLOUSEAU_BMP_DATA_STR, - clouseau_bmp_info_edd); - } - - return clouseau_init_count; -} - -EAPI int -clouseau_data_shutdown(void) -{ - if (--clouseau_init_count != 0) - return clouseau_init_count; - - _clouseau_data_descriptors_shutdown(); - - ecore_shutdown(); - eet_shutdown(); - eina_shutdown(); - - return clouseau_init_count; -} diff --git a/src/lib/clouseau_data_legacy.c b/src/lib/clouseau_data_legacy.c deleted file mode 100644 index a837e14..0000000 --- a/src/lib/clouseau_data_legacy.c +++ /dev/null @@ -1,295 +0,0 @@ -#include "clouseau_data_legacy.h" - -Eet_Data_Descriptor *clouseau_object_edd = NULL; -static Eet_Data_Descriptor *clouseau_union_edd = NULL; -static Eet_Data_Descriptor *clouseau_textblock_edd = NULL; -static Eet_Data_Descriptor *clouseau_edje_edd = NULL; -static Eet_Data_Descriptor *clouseau_image_edd = NULL; -static Eet_Data_Descriptor *clouseau_text_edd = NULL; -static Eet_Data_Descriptor *clouseau_elm_edd = NULL; -static Eet_Data_Descriptor *clouseau_map_point_props_edd = NULL; - -static struct { - Clouseau_Object_Type u; - const char *name; -} eet_props_mapping[] = { - /* As eet_mapping */ - { CLOUSEAU_OBJ_TYPE_OTHER, "CLOUSEAU_OBJ_TYPE_OTHER" }, - { CLOUSEAU_OBJ_TYPE_ELM, "CLOUSEAU_OBJ_TYPE_ELM" }, - { CLOUSEAU_OBJ_TYPE_TEXT, "CLOUSEAU_OBJ_TYPE_TEXT" }, - { CLOUSEAU_OBJ_TYPE_IMAGE, "CLOUSEAU_OBJ_TYPE_IMAGE" }, - { CLOUSEAU_OBJ_TYPE_EDJE, "CLOUSEAU_OBJ_TYPE_EDJE" }, - { CLOUSEAU_OBJ_TYPE_TEXTBLOCK, "CLOUSEAU_OBJ_TYPE_TEXTBLOCK" }, - { CLOUSEAU_OBJ_TYPE_UNKNOWN, NULL } -}; - -static const char * -_clouseau_props_union_type_get(const void *data, Eina_Bool *unknow) -{ /* _union_type_get */ - const Clouseau_Object_Type *u = data; - int i; - - if (unknow) - *unknow = EINA_FALSE; - - for (i = 0; eet_props_mapping[i].name != NULL; ++i) - if (*u == eet_props_mapping[i].u) - return eet_props_mapping[i].name; - - if (unknow) - *unknow = EINA_TRUE; - - return NULL; -} - -static Eina_Bool -_clouseau_props_union_type_set(const char *type, void *data, Eina_Bool unknow) -{ /* same as _union_type_set */ - Clouseau_Object_Type *u = data; - int i; - - if (unknow) - return EINA_FALSE; - - for (i = 0; eet_props_mapping[i].name != NULL; ++i) - if (strcmp(eet_props_mapping[i].name, type) == 0) - { - *u = eet_props_mapping[i].u; - return EINA_TRUE; - } - - return EINA_FALSE; -} - -static void -_clouseau_elm_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Clouseau_Elm_Props); - clouseau_elm_edd = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_elm_edd, Clouseau_Elm_Props, - "type", type, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_elm_edd, Clouseau_Elm_Props, - "style", style, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_elm_edd, Clouseau_Elm_Props, - "scale", scale, EET_T_DOUBLE); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_elm_edd, Clouseau_Elm_Props, - "has_focus", has_focus, EET_T_UCHAR); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_elm_edd, Clouseau_Elm_Props, - "is_disabled", is_disabled, EET_T_UCHAR); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_elm_edd, Clouseau_Elm_Props, - "is_mirrored", is_mirrored, EET_T_UCHAR); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_elm_edd, Clouseau_Elm_Props, - "is_mirrored_automatic", is_mirrored_automatic, EET_T_UCHAR); -} - -static void -_clouseau_text_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Clouseau_Evas_Text_Props); - clouseau_text_edd = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_text_edd, Clouseau_Evas_Text_Props, - "font", font, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_text_edd, Clouseau_Evas_Text_Props, - "size", size, EET_T_INT); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_text_edd, Clouseau_Evas_Text_Props, - "source", source, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_text_edd, Clouseau_Evas_Text_Props, - "text", text, EET_T_STRING); -} - -static void -_clouseau_image_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Clouseau_Evas_Image_Props); - clouseau_image_edd = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_image_edd, Clouseau_Evas_Image_Props, - "file", file, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_image_edd, Clouseau_Evas_Image_Props, - "key", key, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_image_edd, Clouseau_Evas_Image_Props, - "source", source, EET_T_UINT); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_image_edd, Clouseau_Evas_Image_Props, - "load_err", load_err, EET_T_STRING); -} - -static void -_clouseau_edje_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Clouseau_Edje_Props); - clouseau_edje_edd = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_edje_edd, Clouseau_Edje_Props, - "file", file, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_edje_edd, Clouseau_Edje_Props, - "group", group, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_edje_edd, Clouseau_Edje_Props, - "load_err", load_err, EET_T_STRING); -} - -static void -_clouseau_textblock_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Clouseau_Evas_Textblock_Props); - clouseau_textblock_edd = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_textblock_edd, Clouseau_Evas_Textblock_Props, - "style", style, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_textblock_edd, Clouseau_Evas_Textblock_Props, - "text", text, EET_T_STRING); -} - -static void -_clouseau_map_point_props_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, - Clouseau_Evas_Map_Point_Props); - - clouseau_map_point_props_edd = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_map_point_props_edd, - Clouseau_Evas_Map_Point_Props, "x", x, EET_T_INT); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_map_point_props_edd, - Clouseau_Evas_Map_Point_Props, "y", y, EET_T_INT); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_map_point_props_edd, - Clouseau_Evas_Map_Point_Props, "z", z, EET_T_INT); -} - - -void -clouseau_data_descriptors_legacy_init(void) -{ - Eet_Data_Descriptor_Class eddc; - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Clouseau_Object); - clouseau_object_edd = eet_data_descriptor_stream_new(&eddc); - - /* START - evas_props Struct desc */ - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.name", evas_props.name, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.bt", evas_props.bt, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.layer", evas_props.layer, EET_T_SHORT); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.x", evas_props.x, EET_T_INT); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.y", evas_props.y, EET_T_INT); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.w", evas_props.w, EET_T_INT); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.h", evas_props.h, EET_T_INT); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.scale", evas_props.scale, EET_T_DOUBLE); - - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.min_w", evas_props.min_w, EET_T_INT); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.min_h", evas_props.min_h, EET_T_INT); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.max_w", evas_props.max_w, EET_T_INT); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.max_h", evas_props.max_h, EET_T_INT); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.req_w", evas_props.req_w, EET_T_INT); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.req_h", evas_props.req_h, EET_T_INT); - - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.align_x", evas_props.align_x, EET_T_DOUBLE); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.align_y", evas_props.align_y, EET_T_DOUBLE); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.weight_x", evas_props.weight_x, EET_T_DOUBLE); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.weight_y", evas_props.weight_y, EET_T_DOUBLE); - - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.r", evas_props.r, EET_T_INT); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.g", evas_props.g, EET_T_INT); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.b", evas_props.b, EET_T_INT); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.a", evas_props.a, EET_T_INT); - - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.pass_events", evas_props.pass_events, EET_T_UCHAR); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.repeat_events", evas_props.repeat_events, EET_T_UCHAR); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.propagate_events", evas_props.propagate_events, EET_T_UCHAR); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.has_focus", evas_props.has_focus, EET_T_UCHAR); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.is_clipper", evas_props.is_clipper, EET_T_UCHAR); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.is_visible", evas_props.is_visible, EET_T_UCHAR); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.clipper", evas_props.clipper, EET_T_ULONG_LONG); - EET_DATA_DESCRIPTOR_ADD_BASIC(clouseau_object_edd, Clouseau_Object, - "evas_props.mode", evas_props.mode, EET_T_INT); - - _clouseau_elm_desc_make(); - _clouseau_text_desc_make(); - _clouseau_image_desc_make(); - _clouseau_edje_desc_make(); - _clouseau_textblock_desc_make(); - - _clouseau_map_point_props_desc_make(); - EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(clouseau_object_edd, Clouseau_Object, - "evas_props.points", evas_props.points, - clouseau_map_point_props_edd); - - /* for union */ - EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Clouseau_Extra_Props); - eddc.func.type_get = _clouseau_props_union_type_get; - eddc.func.type_set = _clouseau_props_union_type_set; - clouseau_union_edd = eet_data_descriptor_file_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_MAPPING(clouseau_union_edd, - "CLOUSEAU_OBJ_TYPE_ELM", clouseau_elm_edd); - EET_DATA_DESCRIPTOR_ADD_MAPPING(clouseau_union_edd, - "CLOUSEAU_OBJ_TYPE_TEXT", - clouseau_text_edd); - EET_DATA_DESCRIPTOR_ADD_MAPPING(clouseau_union_edd, - "CLOUSEAU_OBJ_TYPE_IMAGE", - clouseau_image_edd); - EET_DATA_DESCRIPTOR_ADD_MAPPING(clouseau_union_edd, - "CLOUSEAU_OBJ_TYPE_EDJE", - clouseau_edje_edd); - EET_DATA_DESCRIPTOR_ADD_MAPPING(clouseau_union_edd, - "CLOUSEAU_OBJ_TYPE_TEXTBLOCK", - clouseau_textblock_edd); - - EET_DATA_DESCRIPTOR_ADD_UNION(clouseau_object_edd, Clouseau_Object, - "u", extra_props.u, - extra_props.type, clouseau_union_edd); -} - -void -clouseau_data_descriptors_legacy_shutdown(void) -{ - eet_data_descriptor_free(clouseau_object_edd); - eet_data_descriptor_free(clouseau_elm_edd); - eet_data_descriptor_free(clouseau_text_edd); - eet_data_descriptor_free(clouseau_image_edd); - eet_data_descriptor_free(clouseau_edje_edd); - eet_data_descriptor_free(clouseau_textblock_edd); - eet_data_descriptor_free(clouseau_union_edd); - eet_data_descriptor_free(clouseau_map_point_props_edd); -} - diff --git a/src/lib/clouseau_data_legacy.h b/src/lib/clouseau_data_legacy.h deleted file mode 100644 index 4b9d292..0000000 --- a/src/lib/clouseau_data_legacy.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _CLOUSEAU_DATA_LEGACY_H -#define _CLOUSEAU_DATA_LEGACY_H - -#include "clouseau_private.h" - -extern Eet_Data_Descriptor *clouseau_object_edd; -void clouseau_data_descriptors_legacy_init(void); -void clouseau_data_descriptors_legacy_shutdown(void); - -#endif diff --git a/src/lib/clouseau_object_information.c b/src/lib/clouseau_object_information.c deleted file mode 100644 index 5dfc8e3..0000000 --- a/src/lib/clouseau_object_information.c +++ /dev/null @@ -1,373 +0,0 @@ -#include "clouseau_private.h" - -EAPI void -clouseau_object_information_free(Clouseau_Object *oinfo) -{ - if (!oinfo) - return; - - eina_stringshare_del(oinfo->evas_props.name); - eina_stringshare_del(oinfo->evas_props.bt); - - if (oinfo->evas_props.points) - free(oinfo->evas_props.points); - - switch (oinfo->extra_props.type) - { - case CLOUSEAU_OBJ_TYPE_ELM: - eina_stringshare_del(oinfo->extra_props.u.elm.type); - eina_stringshare_del(oinfo->extra_props.u.elm.style); - break; - case CLOUSEAU_OBJ_TYPE_TEXT: - eina_stringshare_del(oinfo->extra_props.u.text.font); - eina_stringshare_del(oinfo->extra_props.u.text.source); - eina_stringshare_del(oinfo->extra_props.u.text.text); - break; - case CLOUSEAU_OBJ_TYPE_IMAGE: - eina_stringshare_del(oinfo->extra_props.u.image.file); - eina_stringshare_del(oinfo->extra_props.u.image.key); - eina_stringshare_del(oinfo->extra_props.u.image.load_err); - break; - case CLOUSEAU_OBJ_TYPE_EDJE: - eina_stringshare_del(oinfo->extra_props.u.edje.file); - eina_stringshare_del(oinfo->extra_props.u.edje.group); - - eina_stringshare_del(oinfo->extra_props.u.edje.load_err); - break; - case CLOUSEAU_OBJ_TYPE_TEXTBLOCK: - eina_stringshare_del(oinfo->extra_props.u.textblock.style); - eina_stringshare_del(oinfo->extra_props.u.textblock.text); - break; - case CLOUSEAU_OBJ_TYPE_UNKNOWN: - case CLOUSEAU_OBJ_TYPE_OTHER: - break; - default: - break; - } - - free(oinfo); -} - -static void -_clouseau_eo_from_legacy_convert_helper(Efl_Dbg_Info *new_root, Clouseau_Efl_Dbg_Info *root) -{ - switch (root->type) - { - case CLOUSEAU_DBG_INFO_TYPE_STRING: - EFL_DBG_INFO_APPEND(new_root, root->name, EINA_VALUE_TYPE_STRING, root->un_dbg_info.text.s); - break; - case CLOUSEAU_DBG_INFO_TYPE_INT: - EFL_DBG_INFO_APPEND(new_root, root->name, EINA_VALUE_TYPE_INT, root->un_dbg_info.intg.i); - break; - case CLOUSEAU_DBG_INFO_TYPE_BOOL: - EFL_DBG_INFO_APPEND(new_root, root->name, EINA_VALUE_TYPE_CHAR, root->un_dbg_info.bl.b); - break; - case CLOUSEAU_DBG_INFO_TYPE_PTR: - EFL_DBG_INFO_APPEND(new_root, root->name, EINA_VALUE_TYPE_UINT64, root->un_dbg_info.ptr.p); - break; - case CLOUSEAU_DBG_INFO_TYPE_DOUBLE: - EFL_DBG_INFO_APPEND(new_root, root->name, EINA_VALUE_TYPE_DOUBLE, root->un_dbg_info.dbl.d); - break; - case CLOUSEAU_DBG_INFO_TYPE_LIST: - { - Eina_List *l; - Clouseau_Efl_Dbg_Info *eo; - - new_root = EFL_DBG_INFO_LIST_APPEND(new_root, root->name); - EINA_LIST_FOREACH(root->un_dbg_info.dbg.list, l, eo) - _clouseau_eo_from_legacy_convert_helper(new_root, eo); - } - break; - default: - // FIXME - printf("Oops, wrong type.\n"); - break; - } -} - -EAPI void -clouseau_tree_item_from_legacy_convert(Clouseau_Tree_Item *treeit) -{ - if (!treeit->eo_info) - return; - Eina_List *root = treeit->eo_info; - Efl_Dbg_Info *new_root = NULL; - Eina_List *l; - Clouseau_Efl_Dbg_Info *eo; - - new_root = EFL_DBG_INFO_LIST_APPEND(NULL, ""); - EINA_LIST_FOREACH(root, l, eo) - { - _clouseau_eo_from_legacy_convert_helper(new_root, eo); - clouseau_eo_info_free(eo); - } - - eina_list_free(treeit->eo_info); - treeit->eo_info = NULL; - treeit->new_eo_info = new_root; -} - -static Clouseau_Dbg_Info_Type -_clouseau_eina_value_type_to_clouseau_type(const Eina_Value_Type *type) -{ - if (type == EINA_VALUE_TYPE_STRING) - return CLOUSEAU_DBG_INFO_TYPE_STRING; - else if (type == EINA_VALUE_TYPE_INT) - return CLOUSEAU_DBG_INFO_TYPE_INT; - else if (type == EINA_VALUE_TYPE_CHAR) - return CLOUSEAU_DBG_INFO_TYPE_BOOL; - else if (type == EINA_VALUE_TYPE_UINT64) - return CLOUSEAU_DBG_INFO_TYPE_PTR; - else if (type == EINA_VALUE_TYPE_DOUBLE) - return CLOUSEAU_DBG_INFO_TYPE_DOUBLE; - else if (type == EINA_VALUE_TYPE_LIST) - return CLOUSEAU_DBG_INFO_TYPE_LIST; - - return CLOUSEAU_DBG_INFO_TYPE_UNKNOWN; -} - -/* This function converts a list of Efl_Dbg_Info - * to a list of Clouseau_Efl_Dbg_Info. - * This is required because we would like to keep the def of - * Efl_Dbg_Info in EO code. Thus, avoiding API/ABI error if user - * does not do a full update of Clouseau and EO */ -EAPI Eina_List * -clouseau_eo_to_legacy_convert(Efl_Dbg_Info *root) -{ - Eina_List *l; - Eina_List *new_list = NULL; - Efl_Dbg_Info *eo; - - if (!root && (eina_value_type_get(&(root->value)) != EINA_VALUE_TYPE_LIST)) - return new_list; - Eina_Value_List root_list; - eina_value_pget(&(root->value), &root_list); - - EINA_LIST_FOREACH(root_list.list, l, eo) - { - Clouseau_Efl_Dbg_Info *info = calloc(1, sizeof(*info)); - info->type = _clouseau_eina_value_type_to_clouseau_type( - eina_value_type_get(&(eo->value))); - info->name = eina_stringshare_add(eo->name); - - switch (info->type) - { - case CLOUSEAU_DBG_INFO_TYPE_STRING: - { - const char *tmp; - eina_value_get(&(eo->value), &tmp); - info->un_dbg_info.text.s = eina_stringshare_add(tmp); - } - break; - case CLOUSEAU_DBG_INFO_TYPE_INT: - eina_value_get(&(eo->value), &(info->un_dbg_info.intg.i)); - break; - case CLOUSEAU_DBG_INFO_TYPE_BOOL: - eina_value_get(&(eo->value), &(info->un_dbg_info.bl.b)); - break; - case CLOUSEAU_DBG_INFO_TYPE_PTR: - { - uint64_t tmp; - eina_value_get(&(eo->value), &tmp); - info->un_dbg_info.ptr.p = tmp; - } - break; - case CLOUSEAU_DBG_INFO_TYPE_DOUBLE: - eina_value_get(&(eo->value), &(info->un_dbg_info.dbl.d)); - break; - case CLOUSEAU_DBG_INFO_TYPE_LIST: - info->un_dbg_info.dbg.list = - clouseau_eo_to_legacy_convert(eo); - break; - default: - // FIXME - printf("Oops, wrong type.\n"); - break; - } - - new_list = eina_list_append(new_list, info); - } - - return new_list; -} - -static const struct { - const char *text; - Evas_Object_Pointer_Mode mode; -} pointer_mode[3] = { -# define POINTER_MODE(Value) { #Value, Value } - POINTER_MODE(EVAS_OBJECT_POINTER_MODE_AUTOGRAB), - POINTER_MODE(EVAS_OBJECT_POINTER_MODE_NOGRAB), - POINTER_MODE(EVAS_OBJECT_POINTER_MODE_NOGRAB_NO_REPEAT_UPDOWN) -# undef POINTER_MODE -}; - -static const struct { - Clouseau_Object_Type type; - const char *name; -} _clouseau_types[] = { - { CLOUSEAU_OBJ_TYPE_ELM, "Elementary" }, - { CLOUSEAU_OBJ_TYPE_TEXT, "Text" }, - { CLOUSEAU_OBJ_TYPE_IMAGE, "Image" }, - { CLOUSEAU_OBJ_TYPE_EDJE, "Edje" }, - { CLOUSEAU_OBJ_TYPE_TEXTBLOCK, "Textblock" } -}; - -EAPI void -clouseau_object_information_list_populate(Clouseau_Tree_Item *treeit) -{ - Clouseau_Object *oinfo; - char buf[1024]; - unsigned int i; - - if (!treeit->is_obj) - return; - - oinfo = treeit->info; - - /* This code is here only for backward compatibility and will be removed soon */ - if (!treeit->eo_info && !treeit->new_eo_info) - { - Efl_Dbg_Info *root = EFL_DBG_INFO_LIST_APPEND(NULL, ""); - /* Populate evas properties list */ - Efl_Dbg_Info *group = EFL_DBG_INFO_LIST_APPEND(root, "Evas"); - Efl_Dbg_Info *node; - - EFL_DBG_INFO_APPEND(group, "Visibility", EINA_VALUE_TYPE_CHAR, oinfo->evas_props.is_visible); - EFL_DBG_INFO_APPEND(group, "Layer", EINA_VALUE_TYPE_INT, oinfo->evas_props.layer); - - node = EFL_DBG_INFO_LIST_APPEND(group, "Position"); - EFL_DBG_INFO_APPEND(node, "x", EINA_VALUE_TYPE_INT, oinfo->evas_props.x); - EFL_DBG_INFO_APPEND(node, "y", EINA_VALUE_TYPE_INT, oinfo->evas_props.y); - - node = EFL_DBG_INFO_LIST_APPEND(group, "Size"); - EFL_DBG_INFO_APPEND(node, "w", EINA_VALUE_TYPE_INT, oinfo->evas_props.w); - EFL_DBG_INFO_APPEND(node, "h", EINA_VALUE_TYPE_INT, oinfo->evas_props.h); - - EFL_DBG_INFO_APPEND(group, "Scale", EINA_VALUE_TYPE_DOUBLE, oinfo->evas_props.scale); - -#if 0 - if (evas_object_clip_get(obj)) - { - evas_object_geometry_get(evas_object_clip_get(obj), &x, &y, &w, &h); - _clouseau_information_geometry_to_tree(main_tit, "Clipper position", x, y); - _clouseau_information_geometry_to_tree(main_tit, "Clipper size", w, h); - } -#endif - - node = EFL_DBG_INFO_LIST_APPEND(group, "Min size"); - EFL_DBG_INFO_APPEND(node, "w", EINA_VALUE_TYPE_INT, oinfo->evas_props.min_w); - EFL_DBG_INFO_APPEND(node, "h", EINA_VALUE_TYPE_INT, oinfo->evas_props.min_h); - node = EFL_DBG_INFO_LIST_APPEND(group, "Max size"); - EFL_DBG_INFO_APPEND(node, "w", EINA_VALUE_TYPE_INT, oinfo->evas_props.max_w); - EFL_DBG_INFO_APPEND(node, "h", EINA_VALUE_TYPE_INT, oinfo->evas_props.max_h); - node = EFL_DBG_INFO_LIST_APPEND(group, "Request size"); - EFL_DBG_INFO_APPEND(node, "w", EINA_VALUE_TYPE_INT, oinfo->evas_props.req_w); - EFL_DBG_INFO_APPEND(node, "h", EINA_VALUE_TYPE_INT, oinfo->evas_props.req_h); - node = EFL_DBG_INFO_LIST_APPEND(group, "Align"); - EFL_DBG_INFO_APPEND(node, "w", EINA_VALUE_TYPE_DOUBLE, oinfo->evas_props.align_x); - EFL_DBG_INFO_APPEND(node, "h", EINA_VALUE_TYPE_DOUBLE, oinfo->evas_props.align_y); - node = EFL_DBG_INFO_LIST_APPEND(group, "Weight"); - EFL_DBG_INFO_APPEND(node, "w", EINA_VALUE_TYPE_DOUBLE, oinfo->evas_props.weight_x); - EFL_DBG_INFO_APPEND(node, "h", EINA_VALUE_TYPE_DOUBLE, oinfo->evas_props.weight_y); - -#if 0 - evas_object_size_hint_aspect_get(obj, &w, &h); - _clouseau_information_geometry_to_tree(main_tit, "Aspect", w, h); -#endif - - node = EFL_DBG_INFO_LIST_APPEND(group, "Color"); - EFL_DBG_INFO_APPEND(node, "r", EINA_VALUE_TYPE_INT, oinfo->evas_props.r); - EFL_DBG_INFO_APPEND(node, "g", EINA_VALUE_TYPE_INT, oinfo->evas_props.g); - EFL_DBG_INFO_APPEND(node, "b", EINA_VALUE_TYPE_INT, oinfo->evas_props.b); - EFL_DBG_INFO_APPEND(node, "a", EINA_VALUE_TYPE_INT, oinfo->evas_props.a); - - EFL_DBG_INFO_APPEND(group, "Has focus", EINA_VALUE_TYPE_CHAR, oinfo->evas_props.has_focus); - - for (i = 0; i < sizeof (pointer_mode) / sizeof (pointer_mode[0]); ++i) - if (pointer_mode[i].mode == oinfo->evas_props.mode) - { - EFL_DBG_INFO_APPEND(group, "Pointer Mode", EINA_VALUE_TYPE_STRING, pointer_mode[i].text); - break; - } - - EFL_DBG_INFO_APPEND(group, "Pass Events", EINA_VALUE_TYPE_CHAR, oinfo->evas_props.pass_events); - EFL_DBG_INFO_APPEND(group, "Repeat Events", EINA_VALUE_TYPE_CHAR, oinfo->evas_props.repeat_events); - EFL_DBG_INFO_APPEND(group, "Propagate Events", EINA_VALUE_TYPE_CHAR, oinfo->evas_props.propagate_events); - EFL_DBG_INFO_APPEND(group, "Has clipees", EINA_VALUE_TYPE_CHAR, oinfo->evas_props.is_clipper); - if (oinfo->evas_props.clipper) - { - snprintf(buf, sizeof(buf), "%llx", oinfo->evas_props.clipper); - EFL_DBG_INFO_APPEND(group, "Clipper", EINA_VALUE_TYPE_STRING, buf); - } - - if (oinfo->evas_props.points_count) - { - node = EFL_DBG_INFO_LIST_APPEND(group, "Evas Map"); - Clouseau_Evas_Map_Point_Props *p; - for(i = 0 ; (int) i < oinfo->evas_props.points_count; i++) - { - p = &oinfo->evas_props.points[i]; - - Efl_Dbg_Info *point = EFL_DBG_INFO_LIST_APPEND(node, "Coords"); - EFL_DBG_INFO_APPEND(point, "x", EINA_VALUE_TYPE_INT, p->x); - EFL_DBG_INFO_APPEND(point, "y", EINA_VALUE_TYPE_INT, p->y); - EFL_DBG_INFO_APPEND(point, "z", EINA_VALUE_TYPE_INT, p->z); - } - } - - if (oinfo->extra_props.type == CLOUSEAU_OBJ_TYPE_ELM) - { - group = EFL_DBG_INFO_LIST_APPEND(root, "Elm"); - EFL_DBG_INFO_APPEND(group, "Wid-Type", EINA_VALUE_TYPE_STRING, oinfo->extra_props.u.elm.type); -#if 0 - /* Extract actual data from theme? */ - _clouseau_information_string_to_tree(main_tit, "Theme", elm_widget_theme_get(obj)); -#endif - EFL_DBG_INFO_APPEND(group, "Style", EINA_VALUE_TYPE_STRING, oinfo->extra_props.u.elm.style); - EFL_DBG_INFO_APPEND(group, "Scale", EINA_VALUE_TYPE_DOUBLE, oinfo->extra_props.u.elm.scale); - EFL_DBG_INFO_APPEND(group, "Disabled", EINA_VALUE_TYPE_CHAR, oinfo->extra_props.u.elm.is_disabled); - EFL_DBG_INFO_APPEND(group, "Has focus", EINA_VALUE_TYPE_CHAR, oinfo->extra_props.u.elm.has_focus); - EFL_DBG_INFO_APPEND(group, "Mirrored", EINA_VALUE_TYPE_CHAR, oinfo->extra_props.u.elm.is_mirrored); - EFL_DBG_INFO_APPEND(group, "Automatic mirroring", EINA_VALUE_TYPE_CHAR, oinfo->extra_props.u.elm.is_mirrored_automatic); - } - else if (oinfo->extra_props.type == CLOUSEAU_OBJ_TYPE_TEXT) - { /* EVAS_OBJ_TEXT_CLASS */ - group = EFL_DBG_INFO_LIST_APPEND(root, "Text"); - EFL_DBG_INFO_APPEND(group, "Font", EINA_VALUE_TYPE_STRING, oinfo->extra_props.u.text.font); - - EFL_DBG_INFO_APPEND(group, "Size", EINA_VALUE_TYPE_INT, oinfo->extra_props.u.text.size); - - EFL_DBG_INFO_APPEND(group, "Source", EINA_VALUE_TYPE_STRING, oinfo->extra_props.u.text.source); - EFL_DBG_INFO_APPEND(group, "Text", EINA_VALUE_TYPE_STRING, oinfo->extra_props.u.text.text); - } - else if (oinfo->extra_props.type == CLOUSEAU_OBJ_TYPE_IMAGE) - { /* EVAS_OBJ_IMAGE_CLASS */ - group = EFL_DBG_INFO_LIST_APPEND(root, "Image"); - EFL_DBG_INFO_APPEND(group, "Filename", EINA_VALUE_TYPE_STRING, oinfo->extra_props.u.image.file); - EFL_DBG_INFO_APPEND(group, "File key", EINA_VALUE_TYPE_STRING, oinfo->extra_props.u.image.key); - EFL_DBG_INFO_APPEND(group, "Source", EINA_VALUE_TYPE_UINT64, oinfo->extra_props.u.image.source); - - if (oinfo->extra_props.u.image.load_err) - EFL_DBG_INFO_APPEND(group, "Load error", EINA_VALUE_TYPE_STRING, oinfo->extra_props.u.image.load_err); - } - else if (oinfo->extra_props.type == CLOUSEAU_OBJ_TYPE_EDJE) - { /* EDJE_OBJ_CLASS */ - group = EFL_DBG_INFO_LIST_APPEND(root, "Edje"); - EFL_DBG_INFO_APPEND(group, "File", EINA_VALUE_TYPE_STRING, oinfo->extra_props.u.edje.file); - EFL_DBG_INFO_APPEND(group, "Group", EINA_VALUE_TYPE_STRING, oinfo->extra_props.u.edje.group); - if (oinfo->extra_props.u.image.load_err) - EFL_DBG_INFO_APPEND(group, "Load error", EINA_VALUE_TYPE_STRING, oinfo->extra_props.u.edje.load_err); - } - else if (oinfo->extra_props.type == CLOUSEAU_OBJ_TYPE_TEXTBLOCK) - { /* EVAS_OBJ_TEXTBLOCK_CLASS */ - group = EFL_DBG_INFO_LIST_APPEND(root, "Text Block"); - EFL_DBG_INFO_APPEND(group, "Style", EINA_VALUE_TYPE_STRING, oinfo->extra_props.u.textblock.style); - EFL_DBG_INFO_APPEND(group, "Text", EINA_VALUE_TYPE_STRING, oinfo->extra_props.u.textblock.text); - } - - /* Convert Old format to Clouseau_eo */ - treeit->new_eo_info = root; - } -} - diff --git a/src/lib/clouseau_preload.c b/src/lib/clouseau_preload.c deleted file mode 100644 index 87b364b..0000000 --- a/src/lib/clouseau_preload.c +++ /dev/null @@ -1,148 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif -#include -#include - -#include "Clouseau.h" - -static Eina_Bool _elm_is_init = EINA_FALSE; -static const char *_my_app_name = NULL; - -/** PRELOAD functions. */ - -/* Hook on the elm_init - * We only do something here if we didn't already go into elm_init, - * which probably means we are not using elm. */ -EAPI int -elm_init(int argc, char **argv) -{ - int (*_elm_init)(int, char **) = dlsym(RTLD_NEXT, __func__); - - setenv("ELM_CLOUSEAU", "0", 1); - - if (!_elm_is_init) - { - _my_app_name = argv[0]; - _elm_is_init = EINA_TRUE; - } - - return _elm_init(argc, argv); -} - -/* Hook on the main loop - * We only do something here if we didn't already go into elm_init, - * which probably means we are not using elm. */ -EAPI void -ecore_main_loop_begin(void) -{ - void (*_ecore_main_loop_begin)(void) = dlsym(RTLD_NEXT, __func__); - - if (!_elm_is_init) - { - _my_app_name = "unknown"; - } - - clouseau_init(); - - if(!clouseau_app_connect(_my_app_name)) - { - printf("Failed to connect to server.\n"); - return; - } - - _ecore_main_loop_begin(); - - clouseau_shutdown(); - - return; -} - -#define EINA_LOCK_DEBUG_BT_NUM 64 - -static void -_clouseau_efl_object_dbg_info_get(Eo *obj, void *pd EINA_UNUSED, Efl_Dbg_Info *root) -{ - const char *bt; - Efl_Dbg_Info *creation; - - bt = efl_key_data_get(obj, ".clouseau.bt"); - creation = EFL_DBG_INFO_LIST_APPEND(root, "Creation"); - EFL_DBG_INFO_APPEND(creation, "Backtrace", EINA_VALUE_TYPE_STRING, bt); - - efl_dbg_info_get(efl_super(obj, EFL_OBJECT_OVERRIDE_CLASS), root); -} -static void -_clouseau_efl_destructor(Eo *obj, void *pd EINA_UNUSED) -{ - char *bt; - - bt = efl_key_data_get(obj, ".clouseau.bt"); - free(bt); - - efl_destructor(efl_super(obj, EFL_OBJECT_OVERRIDE_CLASS)); -} - -static char* -_clouseau_backtrace_create(void) -{ - void *bt[EINA_LOCK_DEBUG_BT_NUM]; - Eina_Strbuf *buf; - int lock_bt_num; - - lock_bt_num = backtrace((void **)bt, EINA_LOCK_DEBUG_BT_NUM); - buf = eina_strbuf_new(); - for (int i = 0; i < lock_bt_num; ++i) - { - Dl_info info; - const char *file; - unsigned long long offset, base; - - if ((dladdr(bt[i], &info)) && (info.dli_fname[0])) - { - offset = (unsigned long long)bt[i]; - base = (unsigned long long)info.dli_fbase; - file = info.dli_fname; - } - if (file) - eina_strbuf_append_printf(buf, "%s\t 0x%llx 0x%llx\n", file, offset, base); - else - eina_strbuf_append_printf(buf, "??\t -\n"); - } - - { - char *str; - - str = eina_strbuf_string_steal(buf); - eina_strbuf_free(buf); - - return str; - } -} - -EAPI Eo* -_efl_add_internal_start(const char *file, int line, const Efl_Class *klass_id, Eo *parent_id, Eina_Bool ref, Eina_Bool is_fallback) -{ - Eo* (*__efl_add_internal_start)(const char *file, int line, const Efl_Class *klass_id, Eo *parent_id, Eina_Bool ref EINA_UNUSED, Eina_Bool is_fallback); - const char *str; - Eo *obj; - - //create bt - str = _clouseau_backtrace_create(); - - //containue construction - __efl_add_internal_start = dlsym(RTLD_NEXT, __func__); - obj = __efl_add_internal_start(file, line, klass_id, parent_id, ref, is_fallback); - - //override needed functions - EFL_OPS_DEFINE(ops, - EFL_OBJECT_OP_FUNC(efl_dbg_info_get, _clouseau_efl_object_dbg_info_get), - EFL_OBJECT_OP_FUNC(efl_destructor, _clouseau_efl_destructor) - ); - efl_object_override(obj, &ops); - - //add backtrace and free buf - efl_key_data_set(obj, ".clouseau.bt", str); - - return obj; -} \ No newline at end of file diff --git a/src/lib/clouseau_private.h b/src/lib/clouseau_private.h deleted file mode 100644 index 4e6f441..0000000 --- a/src/lib/clouseau_private.h +++ /dev/null @@ -1,241 +0,0 @@ -#ifndef _CLOUSEAU_PRIVATE_H -#define _CLOUSEAU_PRIVATE_H - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include - -#include "clouseau_private2.h" - -/* Global constants */ -#define BMP_FIELD "bmp" - -#define PORT (22522) -#define MAX_LINE (1023) -#define LOCALHOST "127.0.0.1" -#define LISTEN_IP "0.0.0.0" /* Avail all, no mask */ - -#define CLOUSEAU_GUI_CLIENT_CONNECT_STR "CLOUSEAU_GUI_CLIENT_CONNECT" -#define CLOUSEAU_APP_CLIENT_CONNECT_STR "CLOUSEAU_APP_CLIENT_CONNECT" -#define CLOUSEAU_APP_ADD_STR "CLOUSEAU_APP_ADD" -#define CLOUSEAU_DATA_REQ_STR "CLOUSEAU_DATA_REQ" -#define CLOUSEAU_TREE_DATA_STR "CLOUSEAU_TREE_DATA" -#define CLOUSEAU_APP_CLOSED_STR "CLOUSEAU_APP_CLOSED" -#define CLOUSEAU_HIGHLIGHT_STR "CLOUSEAU_HIGHLIGHT" -#define CLOUSEAU_BMP_REQ_STR "CLOUSEAU_BMP_REQ" -#define CLOUSEAU_BMP_DATA_STR "CLOUSEAU_BMP_DATA" - -/* Private function */ -#define CLOUSEAU_APP_ADD_ENTRY "clouseau/app" -#define CLOUSEAU_TREE_DATA_ENTRY "clouseau/app/tree" -#define CLOUSEAU_BMP_LIST_ENTRY "clouseau/app/shot_list" -#define CLOUSEAU_BMP_DATA_ENTRY "clouseau/app/screenshot" - -/* START - EO EET defs */ -#define EFL_DBG_INFO_TYPE_UNKNOWN_STR "EFL_DBG_INFO_TYPE_UNKNOWN" -#define EFL_DBG_INFO_TYPE_STRING_STR "EFL_DBG_INFO_TYPE_STRING" -#define EFL_DBG_INFO_TYPE_INT_STR "EFL_DBG_INFO_TYPE_INT" -#define EFL_DBG_INFO_TYPE_BOOL_STR "EFL_DBG_INFO_TYPE_BOOL" -#define EFL_DBG_INFO_TYPE_PTR_STR "EFL_DBG_INFO_TYPE_PTR" -#define EFL_DBG_INFO_TYPE_DOUBLE_STR "EFL_DBG_INFO_TYPE_DOUBLE" -#define EFL_DBG_INFO_TYPE_LIST_STR "EFL_DBG_INFO_TYPE_LIST" -/* END - EO EET defs */ - -struct _connect_st -{ /* This will be used for APP, GUI client connect */ - unsigned int pid; - const char *name; -}; -typedef struct _connect_st connect_st; - -struct _app_info_st -{ /* This will be used to register new APP in GUI client */ - unsigned int pid; - char *name; - char *file; /* Valid only if was read from file in offline mode */ - unsigned long long ptr; /* (void *) client ptr of app as saved by daemon */ - Eina_List *view; /* Screen views pointers of (bmp_info_st *) */ - unsigned int refresh_ctr; /* Counter of how many times down refresh */ -}; -typedef struct _app_info_st app_info_st; - -struct _data_req_st -{ /* This will be used to ask for tree data by DAEMON or GUI */ - unsigned long long gui; /* (void *) client ptr of GUI */ - unsigned long long app; /* (void *) client ptr APP */ -}; -typedef struct _data_req_st data_req_st; - -struct _tree_data_st -{ /* This will be used to send tree data to/from APP/DAEMON */ - unsigned long long gui; /* (void *) client ptr of GUI */ - unsigned long long app; /* (void *) client ptr APP */ - Eina_List *tree; /* The actual (Tree_Item *) list */ -}; -typedef struct _tree_data_st tree_data_st; - -struct _app_closed_st -{ /* This will be used to notify GUI of app closed */ - unsigned long long ptr; /* (void *) client ptr APP */ -}; -typedef struct _app_closed_st app_closed_st; - -struct _highlight_st -{ /* This will be used to highlight object in APP */ - unsigned long long app; /* (void *) client ptr of APP */ - unsigned long long object; /* (void *) object ptr of object to highlight */ -}; -typedef struct _highlight_st highlight_st; - -struct _bmp_req_st -{ /* This will be used to send tree data to/from APP/DAEMON */ - unsigned long long gui; /* (void *) client ptr of GUI */ - unsigned long long app; /* (void *) client ptr APP */ - unsigned long long object; /* (void *) object ptr of Evas */ - unsigned int ctr; /* Reload counter to match */ -}; -typedef struct _bmp_req_st bmp_req_st; - -struct _bmp_info_st -{ /* This will be used to send app window Bitmap */ - /* We are using ULONGLONG because we send this as RAW data */ - /* win, bt are NOT transferred. */ - unsigned long long gui; /* (void *) client ptr of GUI */ - unsigned long long app; /* (void *) client ptr of APP */ - unsigned long long object; /* (void *) object ptr of evas */ - unsigned long long ctr; /* Reload counter to match */ - unsigned long long w; /* BMP width, make Evas_Coord */ - unsigned long long h; /* BMP hight, make Evas_Coord */ - - /* All the following fields are NOT transferred in EET msg */ - Evas_Object *win; /* Window of view if open */ - Evas_Object *scr; /* Scroller holds view */ - Evas_Object *o; /* Actuall object displays BMP */ - double zoom_val; /* Current zoom value */ - Evas_Object *lb_mouse; /* Label contains mouse cords */ - Evas_Object *lb_rgba; /* Current mouse pos rgba val */ - Evas_Object *bt; /* Button opening win */ - Evas_Object *lx; /* Line on X axis */ - Evas_Object *ly; /* Line on Y axis */ - void *bmp; /* Bitmap BLOB, size (w * h * sizeof(int)) */ -}; -typedef struct _bmp_info_st bmp_info_st; - -struct _shot_list_st -{ /* This will be used to write a shot list to eet file */ - Eina_List *view; /* Screen views eahc is (bmp_info_st *) ptr */ -}; -typedef struct _shot_list_st shot_list_st; - -struct _data_desc -{ - Eet_Data_Descriptor *bmp_data; - Eet_Data_Descriptor *bmp_req; - Eet_Data_Descriptor *bmp_info; - Eet_Data_Descriptor *shot_list; - Eet_Data_Descriptor *connect; - Eet_Data_Descriptor *app_add; - Eet_Data_Descriptor *data_req; - Eet_Data_Descriptor *tree_data; - Eet_Data_Descriptor *app_closed; - Eet_Data_Descriptor *highlight; - Eet_Data_Descriptor *tree; - Eet_Data_Descriptor *obj_info; -}; -typedef struct _data_desc data_desc; - -/* START - EO - debug structs */ -struct _Clouseau_st_string -{ - const char *s; -}; - -struct _Clouseau_st_int -{ - int i; -}; - -struct _Clouseau_st_bool -{ - Eina_Bool b; -}; - -struct _Clouseau_st_ptr -{ - unsigned long long p; /* For pointer value */ -}; - -struct _Clouseau_st_double -{ - double d; -}; - -struct _Clouseau_st_dbg_list -{ - Eina_List *list; /* Sub-List of (Efl_Dbg_Info *) if needed */ -}; - -/* START - EO - debug structs */ -typedef struct _Clouseau_st_string Clouseau_st_string; -typedef struct _Clouseau_st_int Clouseau_st_int; -typedef struct _Clouseau_st_bool Clouseau_st_bool; -typedef struct _Clouseau_st_ptr Clouseau_st_ptr; -typedef struct _Clouseau_st_double Clouseau_st_double; -typedef struct _Clouseau_st_dbg_list Clouseau_st_dbg_list; -typedef struct _Clouseau_Efl_Dbg_Info Clouseau_Efl_Dbg_Info; -/* END - EO - debug structs */ - -typedef enum -{ - CLOUSEAU_DBG_INFO_TYPE_STRING, - CLOUSEAU_DBG_INFO_TYPE_INT, - CLOUSEAU_DBG_INFO_TYPE_BOOL, - CLOUSEAU_DBG_INFO_TYPE_PTR, - CLOUSEAU_DBG_INFO_TYPE_DOUBLE, - CLOUSEAU_DBG_INFO_TYPE_LIST, - CLOUSEAU_DBG_INFO_TYPE_UNKNOWN -} Clouseau_Dbg_Info_Type; - -struct _Clouseau_Efl_Dbg_Info -{ /* Debug info composed of a list of Efl_Dbg_Info */ - const char *name; - Clouseau_Dbg_Info_Type type; - - union _un_dbg_info - { - Clouseau_st_string text; - Clouseau_st_int intg; - Clouseau_st_bool bl; - Clouseau_st_ptr ptr; - Clouseau_st_double dbl; - Clouseau_st_dbg_list dbg; /* Sub-List of (Efl_Dbg_Info *) if needed */ - } un_dbg_info; -}; -/* END - EO - debug structs */ - -void clouseau_app_disconnect(void); - - -EAPI Efl_Dbg_Info* clouseau_eo_info_find(Efl_Dbg_Info *root, const char *name); -EAPI void clouseau_eo_info_free(Clouseau_Efl_Dbg_Info *parent); -EAPI void clouseau_tree_item_from_legacy_convert(Clouseau_Tree_Item *treeit); -EAPI Eina_List *clouseau_eo_to_legacy_convert(Efl_Dbg_Info *root); - -/* Exported From Object information */ -EAPI void clouseau_object_information_free(Clouseau_Object *oinfo); -EAPI Clouseau_Object * clouseau_object_information_get(Clouseau_Tree_Item *treeit); - -/* Exported function */ -EAPI void clouseau_data_tree_free(Eina_List *tree); -EAPI void *clouseau_data_packet_compose(const char *p_type, void *data, unsigned int *size, void *blob, int blob_size); -EAPI void *clouseau_data_packet_info_get(const char *p_type, void *data, size_t size); -EAPI void clouseau_data_object_highlight(Evas_Object *obj); -EAPI Eina_Bool clouseau_data_eet_info_save(const char *filename, app_info_st *a, tree_data_st *ftd, Eina_List *ck_list); -EAPI Eina_Bool clouseau_data_eet_info_read(const char *filename, app_info_st **a, tree_data_st **ftd); -EAPI int clouseau_data_init(void); -EAPI int clouseau_register_descs(Ecore_Con_Eet *eet_svr); -EAPI int clouseau_data_shutdown(void); -#endif /* EET_DATA_H */ diff --git a/src/lib/clouseau_private2.h b/src/lib/clouseau_private2.h deleted file mode 100644 index b229e17..0000000 --- a/src/lib/clouseau_private2.h +++ /dev/null @@ -1,133 +0,0 @@ -#ifndef _CLOUSEAU_PRIVATE2_H -#define _CLOUSEAU_PRIVATE2_H - -#include - -/* This header replaces the old Clouseau.h - * The contents here are not public by any means, and the name indicated as if - * they were. - * We will "whitelist" parts from here to the public header when we'll need - * it. */ - -#include "Clouseau.h" - -#define CLOUSEAUD_READY_STR "READY" - -typedef struct _Clouseau_Evas_Props Clouseau_Evas_Props; -typedef struct _Clouseau_Evas_Text_Props Clouseau_Evas_Text_Props; -typedef struct _Clouseau_Evas_Image_Props Clouseau_Evas_Image_Props; -typedef struct _Clouseau_Elm_Props Clouseau_Elm_Props; -typedef struct _Clouseau_Edje_Props Clouseau_Edje_Props; -typedef struct _Clouseau_Evas_Map_Point_Props Clouseau_Evas_Map_Point_Props; - -typedef struct _Clouseau_Extra_Props Clouseau_Extra_Props; - -/* The color of the highlight */ -enum { - HIGHLIGHT_R = 255, - HIGHLIGHT_G = 128, - HIGHLIGHT_B = 128, - HIGHLIGHT_A = 255 -}; - -typedef enum -{ - CLOUSEAU_OBJ_TYPE_UNKNOWN, - CLOUSEAU_OBJ_TYPE_OTHER, - CLOUSEAU_OBJ_TYPE_ELM, - CLOUSEAU_OBJ_TYPE_TEXT, - CLOUSEAU_OBJ_TYPE_IMAGE, - CLOUSEAU_OBJ_TYPE_EDJE, - CLOUSEAU_OBJ_TYPE_TEXTBLOCK -} Clouseau_Object_Type; - -struct _Clouseau_Evas_Map_Point_Props -{ - Evas_Coord x, y, z; -}; - -struct _Clouseau_Evas_Props -{ - const char *name; - const char *bt; - short layer; - Evas_Coord x, y, w, h; - double scale; - Evas_Coord min_w, min_h, max_w, max_h, req_w, req_h; - double align_x, align_y; - double weight_x, weight_y; - int r, g, b, a; - Eina_Bool pass_events; - Eina_Bool repeat_events; - Eina_Bool propagate_events; - Eina_Bool has_focus; - Eina_Bool is_clipper; - Eina_Bool is_visible; - Evas_Object_Pointer_Mode mode; - Clouseau_Evas_Map_Point_Props *points; - int points_count; - unsigned long long clipper; -}; - -struct _Clouseau_Evas_Text_Props -{ - const char *font; - const char *source; - const char *text; - int size; -}; - -struct _Clouseau_Evas_Image_Props -{ - const char *file, *key; - void *source; - const char *load_err; -}; - -struct _Clouseau_Evas_Textblock_Props -{ - const char *style; - const char *text; -}; -typedef struct _Clouseau_Evas_Textblock_Props Clouseau_Evas_Textblock_Props; - -struct _Clouseau_Edje_Props -{ - const char *file, *group; - const char *load_err; -}; - -struct _Clouseau_Elm_Props -{ - const char *type; - const char *style; - double scale; - Eina_Bool has_focus; - Eina_Bool is_disabled; - Eina_Bool is_mirrored; - Eina_Bool is_mirrored_automatic; -}; - -struct _Clouseau_Extra_Props -{ /* as Example_Union */ - Clouseau_Object_Type type; - union { - Clouseau_Elm_Props elm; - Clouseau_Evas_Text_Props text; - Clouseau_Evas_Image_Props image; - Clouseau_Edje_Props edje; - Clouseau_Evas_Textblock_Props textblock; - } u; -}; - -struct _Clouseau_Object -{ - Clouseau_Evas_Props evas_props; - Clouseau_Extra_Props extra_props; -}; - -void clouseau_object_desc_shutdown(void); - -/* Public */ -EAPI void clouseau_object_information_list_populate(Clouseau_Tree_Item *treeit); -#endif diff --git a/src/modules/Makefile.am b/src/modules/Makefile.am deleted file mode 100644 index ab0ad9a..0000000 --- a/src/modules/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -MAINTAINERCLEANFILES = Makefile.in - -AM_CPPFLAGS = \ --I$(top_srcdir)/src/lib \ --I$(top_srcdir)/src/include \ --I$(top_builddir)/src/include \ --DPACKAGE_BIN_DIR=\"$(bindir)\" \ --DPACKAGE_LIB_DIR=\"$(libdir)\" \ --DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ -@EFL_CFLAGS@ - -client_modulesdir = $(libdir)/clouseau/modules/client -client_modules_LTLIBRARIES = canvas_checker.la - -canvas_checker_la_SOURCES = client/canvas_checker.c - -canvas_checker_la_LDFLAGS = -module -avoid-version -rdynamic -canvas_checker_la_DEPENDENCIES = $(top_builddir)/config.h -canvas_checker_la_LIBADD = @EFL_LIBS@ - diff --git a/src/modules/client/canvas_checker.c b/src/modules/client/canvas_checker.c deleted file mode 100644 index ed0d2e2..0000000 --- a/src/modules/client/canvas_checker.c +++ /dev/null @@ -1,156 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include - -EAPI const char *clouseau_module_name = "Canvas Sanity Checker"; - -static Eina_Bool -_init(void) -{ - return EINA_TRUE; -} - -static void -_shutdown(void) -{ -} - -typedef struct { - Clouseau_Tree_Item *ptr; - Clouseau_Tree_Item *parent; -} Clipper_Info; - -typedef struct { - Clouseau_Tree_Item *ptr; - Clouseau_Tree_Item *parent; - uint64_t clipper; -} Clippee_Info; - -typedef struct { - Eina_Hash *clippers; - Eina_List *clippees; -} Context; - -static void -_hash_clipper_free_cb(void *data) -{ - free(data); -} - -static uint64_t -_treeit_clipee_is(Clouseau_Tree_Item *treeit) -{ - Eina_List *l; - Efl_Dbg_Info *eo_root, *eo; - Eina_Value_List eo_list; - clouseau_tree_item_from_legacy_convert(treeit); - eo_root = treeit->new_eo_info; - - eina_value_pget(&(eo_root->value), &eo_list); - - EINA_LIST_FOREACH(eo_list.list, l, eo) - { - if (!strcmp(eo->name, "Evas_Object")) - { - Eina_Value_List eo_list2; - Eina_List *l2; - eina_value_pget(&(eo->value), &eo_list2); - EINA_LIST_FOREACH(eo_list2.list, l2, eo) - { - if (!strcmp(eo->name, "Clipper")) - { - uint64_t ptr = 0; - eina_value_get(&(eo->value), &ptr); - - return ptr; - } - } - - return 0; - } - } - - return 0; -} - - -static void -_treeit_clipper_clipee_recursively_add(Context *ctx, Clouseau_Tree_Item *parent) -{ - Clouseau_Tree_Item *treeit; - Eina_List *l; - - EINA_LIST_FOREACH(parent->children, l, treeit) - { - uint64_t ptr; - if (treeit->is_clipper) - { - Clipper_Info *info = calloc(1, sizeof(*info)); - info->ptr = treeit; - info->parent = parent; - - eina_hash_add(ctx->clippers, &info->ptr->ptr, info); - } - else if ((ptr = _treeit_clipee_is(treeit))) - { - Clippee_Info *info = calloc(1, sizeof(*info)); - info->ptr = treeit; - info->parent = parent; - info->clipper = ptr; - - ctx->clippees = eina_list_append(ctx->clippees, info); - } - - _treeit_clipper_clipee_recursively_add(ctx, treeit); - } -} - -EAPI void -clouseau_client_module_run(Eina_List *tree) -{ - Context ctx; - ctx.clippers = eina_hash_int64_new(_hash_clipper_free_cb); - ctx.clippees = NULL; - - /* Gather the information from the tree. */ - Clouseau_Tree_Item *treeit; - Eina_List *l; - EINA_LIST_FOREACH(tree, l, treeit) - { - _treeit_clipper_clipee_recursively_add(&ctx, treeit); - } - - /* Analyze the information. */ - Clippee_Info *info; - EINA_LIST_FOREACH(ctx.clippees, l, info) - { - Clipper_Info *clipper = eina_hash_find(ctx.clippers, &info->clipper); - - if (!clipper) - { - printf("Error! Object: %llx. Can't find clipper '%llx'\n", (unsigned long long) info->ptr->ptr, (unsigned long long) info->clipper); - } - else if (clipper->parent != info->parent) - { - printf("Error! Object's (%llx) parent (%llx) != Clipper's (%llx) parent (%llx)\n", info->ptr->ptr, info->parent->ptr, clipper->ptr->ptr, clipper->parent->ptr); - } - } - - printf("Finished running '%s'\n", clouseau_module_name); - - /* Clear the data. */ - { - void *data; - - eina_hash_free(ctx.clippers); - EINA_LIST_FREE(ctx.clippees, data) - free(data); - } -} - -EINA_MODULE_INIT(_init); -EINA_MODULE_SHUTDOWN(_shutdown); diff --git a/src/scripts/Makefile.am b/src/scripts/Makefile.am deleted file mode 100644 index 564d550..0000000 --- a/src/scripts/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -MAINTAINERCLEANFILES = Makefile.in - -clouseau_start: clouseau_start.in - $(AM_V_GEN) $(SED) -e "s|\@libdir\@|$(libdir)|" $(srcdir)/clouseau_start.in > $(builddir)/clouseau_start - -bin_SCRIPTS = clouseau clouseau_start - -CLEAN_FILES = clouseau_start - -# FIXME: I'm not even sure .in files should be included here. -EXTRA_DIST = clouseau_start.in diff --git a/src/scripts/clouseau b/src/scripts/clouseau deleted file mode 100644 index 3b661f6..0000000 --- a/src/scripts/clouseau +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -clouseau_client & -if [ $# -gt 0 ] -then - # Start clouseau daemon (will start single instance), then run app - clouseau_start "$@" -fi - diff --git a/src/scripts/clouseau_start.in b/src/scripts/clouseau_start.in deleted file mode 100644 index 1c53cb6..0000000 --- a/src/scripts/clouseau_start.in +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -if [ $# -lt 1 ] -then - echo "Usage: clouseau_start [executable parameters]" -else - LD_PRELOAD="@libdir@/clouseau/libclouseau_preload.so" "$@" -fi