From: jk7744.park Date: Sat, 24 Oct 2015 06:40:04 +0000 (+0900) Subject: tizen 2.4 release X-Git-Tag: accepted/tizen/2.4/mobile/20151029.041543^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cf4be8bb15d827cab3b4c4fcd9ef84c6dfa55490;p=apps%2Fhome%2Fminicontrol.git tizen 2.4 release --- diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100755 new mode 100644 index ff1e4f7..690d3b0 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,17 +14,18 @@ SET(CMAKE_SKIP_BUILD_RPATH true) SET(INSTALL_HEADERS minicontrol-error.h minicontrol-type.h + minicontrol-internal.h minicontrol-monitor.h minicontrol-provider.h + minicontrol-provider-internal.h minicontrol-viewer.h - minicontrol-handler.h + minicontrol-viewer-internal.h ) SET(SUBMODULES minicontrol-provider minicontrol-viewer minicontrol-monitor - minicontrol-handler ) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) @@ -43,7 +44,7 @@ FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -g -Wall -fPIC") +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -g -Wall -fPIC ") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") @@ -52,7 +53,6 @@ ADD_DEFINITIONS("-DMINICTRL_USE_DLOG") ADD_LIBRARY(${PROJECT_NAME}-inter STATIC src/minicontrol-internal.c - src/minicontrol-internal-handler.c ) TARGET_LINK_LIBRARIES(${PROJECT_NAME}-inter ${pkgs_LDFLAGS}) diff --git a/LICENSE b/LICENSE old mode 100755 new mode 100644 diff --git a/TC/_export_env.sh b/TC/_export_env.sh deleted file mode 100755 index 7a317f8..0000000 --- a/TC/_export_env.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -source ./config - -export TET_INSTALL_PATH=$TET_INSTALL_HOST_PATH # tetware root path -#export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-simulator # tetware target path -export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path -export PATH=$TET_TARGET_PATH/bin:$PATH -export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH -export TET_ROOT=$TET_TARGET_PATH diff --git a/TC/_export_target_env.sh b/TC/_export_target_env.sh deleted file mode 100755 index 5e005cf..0000000 --- a/TC/_export_target_env.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -. ./config - -export TET_INSTALL_PATH=$TET_INSTALL_TARGET_PATH # path to path -#export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-simulator -export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target -export PATH=$TET_TARGET_PATH/bin:$PATH -export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH -export TET_ROOT=$TET_TARGET_PATH diff --git a/TC/clean.sh b/TC/clean.sh deleted file mode 100755 index 29743e0..0000000 --- a/TC/clean.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -. ./_export_env.sh # setting environment variables - -export TET_SUITE_ROOT=`pwd` -RESULT_DIR=results - -tcc -c -p ./ # executing tcc, with clean option (-c) -rm -r $RESULT_DIR -rm -r tet_tmp_dir -rm testcase/tet_captured diff --git a/TC/config b/TC/config deleted file mode 100755 index e4fd50a..0000000 --- a/TC/config +++ /dev/null @@ -1,3 +0,0 @@ -PKG_NAME=minicontrol -TET_INSTALL_HOST_PATH=/var/tmp/dts_fw/TC/TETware -TET_INSTALL_TARGET_PATH=/opt/home/$PKG_NAME/TETware diff --git a/TC/push.sh b/TC/push.sh deleted file mode 100755 index 5eb9510..0000000 --- a/TC/push.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -. ./config - -TC_PATH=/opt/home/$PKG_NAME - -echo $TC_PATH - -sdb shell "mkdir -p $TC_PATH" - -sdb push . $TC_PATH - - diff --git a/TC/run.sh b/TC/run.sh deleted file mode 100755 index cec5778..0000000 --- a/TC/run.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -source ./_export_target_env.sh - -export TET_SUITE_ROOT=`pwd` -FILE_NAME_EXTENSION=`date +%s` - -RESULT_DIR=results -HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html -JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal - -mkdir -p $RESULT_DIR - -tcc -e -j $JOURNAL_RESULT -p ./ -grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/TC/testcase/Makefile b/TC/testcase/Makefile deleted file mode 100755 index ae79127..0000000 --- a/TC/testcase/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -include ../config - -CC ?= gcc - -C_FILES = $(shell ls *.c) - -PKGS += minicontrol-monitor -PKGS += minicontrol-provider -PKGS += minicontrol-viewer -PKGS += minicontrol-viewer -PKGS += dlog -PKGS += elementary -PKGS += evas -PKGS += ecore-evas -PKGS += dbus-1 -PKGS += dbus-glib-1 -PKGS += glib-2.0 -LDFLAGS = `pkg-config --libs $(PKGS)` -LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o -LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s -LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s - -CFLAGS = -I. `pkg-config --cflags $(PKGS)` -CFLAGS += -I$(TET_ROOT)/inc/tet3 -CFLAGS += -Wall - -TCS := $(shell ls -1 *.c | cut -d. -f1) - -all: $(TCS) - -%: %.c - $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) - -clean: - rm -f $(TCS) diff --git a/TC/testcase/tslist b/TC/testcase/tslist deleted file mode 100755 index dc1d735..0000000 --- a/TC/testcase/tslist +++ /dev/null @@ -1 +0,0 @@ -/testcase/utc_minicontrol \ No newline at end of file diff --git a/TC/testcase/utc_minicontrol b/TC/testcase/utc_minicontrol deleted file mode 100755 index 871e6b1..0000000 Binary files a/TC/testcase/utc_minicontrol and /dev/null differ diff --git a/TC/testcase/utc_minicontrol.c b/TC/testcase/utc_minicontrol.c deleted file mode 100755 index cf890d0..0000000 --- a/TC/testcase/utc_minicontrol.c +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define TEST_PKG "org.tizen.tetware" - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -static void startup(void); -static void cleanup(void); - -static void utc_minicontrol_monitor_start_n(void); -static void utc_minicontrol_monitor_start_p(void); -static void utc_minicontrol_monitor_stop_p(void); -static void utc_minicontrol_win_add_n(void); -static void utc_minicontrol_win_add_p(void); -static void utc_minicontrol_request_n(void); -static void utc_minicontrol_request_p(void); -static void utc_minicontrol_viewer_add_n(void); -static void utc_minicontrol_viewer_add_p(void); -static void utc_minicontrol_viewer_image_object_get_n(void); -static void utc_minicontrol_viewer_image_object_get_p(void); -static void utc_minicontrol_viewer_request_n(void); -static void utc_minicontrol_viewer_request_p(void); - -void (*tet_startup)(void) = startup; -void (*tet_cleanup)(void) = cleanup; - -struct tet_testlist tet_testlist[] = { - {utc_minicontrol_monitor_start_n, NEGATIVE_TC_IDX}, - {utc_minicontrol_monitor_start_p, POSITIVE_TC_IDX}, - {utc_minicontrol_monitor_stop_p, POSITIVE_TC_IDX}, - {utc_minicontrol_win_add_n, NEGATIVE_TC_IDX}, - {utc_minicontrol_win_add_p, POSITIVE_TC_IDX}, - {utc_minicontrol_request_n, NEGATIVE_TC_IDX}, - {utc_minicontrol_request_p, POSITIVE_TC_IDX}, - {utc_minicontrol_viewer_add_n, NEGATIVE_TC_IDX}, - {utc_minicontrol_viewer_add_p, POSITIVE_TC_IDX}, - {utc_minicontrol_viewer_image_object_get_n, NEGATIVE_TC_IDX}, - {utc_minicontrol_viewer_image_object_get_p, POSITIVE_TC_IDX}, - {utc_minicontrol_viewer_request_n, NEGATIVE_TC_IDX}, - {utc_minicontrol_viewer_request_p, POSITIVE_TC_IDX}, - { NULL, 0 }, -}; - -static void _minicontrol_monitor_cb(minicontrol_action_e action, - const char *name, - unsigned int width, - unsigned int height, - minicontrol_priority_e priority, - void *data) { - -} - -static Evas_Object *_ui_window_add(void) -{ - Evas_Object *eo = NULL; - - eo = elm_win_add(NULL, "TETware", ELM_WIN_BASIC); - - if (eo != NULL) { - elm_win_title_set(eo, "TETware"); - elm_win_borderless_set(eo, EINA_TRUE); - elm_win_autodel_set(eo, EINA_TRUE); - evas_object_show(eo); - } - - return eo; -} - -static void startup(void) -{ - /* start of TC */ - tet_printf("\n TC start"); -} - - -static void cleanup(void) -{ - /* end of TC */ - tet_printf("\n TC end"); -} - -/** - * @brief Negative test case of minicontrol_monitor_start() - */ -static void utc_minicontrol_monitor_start_n(void) -{ - int ret; - - ret = minicontrol_monitor_start(NULL, NULL); - - dts_check_eq("minicontrol_monitor_start", ret, MINICONTROL_ERROR_INVALID_PARAMETER, - "Must return MINICONTROL_ERROR_INVALID_PARAMETER in case of invalid parameter"); -} - -/** - * @brief Positive test case of minicontrol_monitor_start() - */ -static void utc_minicontrol_monitor_start_p(void) -{ - int ret; - - ret = minicontrol_monitor_start(_minicontrol_monitor_cb, NULL); - - dts_check_eq("minicontrol_monitor_start", ret, MINICONTROL_ERROR_NONE, - "Must return MINICONTROL_ERROR_NONE in case of invalid parameter"); -} - -/** - * @brief Positive test case of minicontrol_monitor_stop() - */ -static void utc_minicontrol_monitor_stop_p(void) -{ - int ret; - - ret = minicontrol_monitor_start(_minicontrol_monitor_cb, NULL); - ret = minicontrol_monitor_stop(); - - dts_check_eq("minicontrol_monitor_start", ret, MINICONTROL_ERROR_NONE, - "Must return MINICONTROL_ERROR_NONE in case of invalid parameter"); -} - -/** - * @brief Negative test case of minicontrol_win_add() - */ -static void utc_minicontrol_win_add_n(void) -{ - int ret; - Evas_Object *win = NULL; - - win = minicontrol_win_add(NULL); - dts_check_eq("minicontrol_win_add", win, NULL, - "Must return NULL in case of invalid parameter"); -} - -/** - * @brief Positive test case of minicontrol_win_add() - */ -static void utc_minicontrol_win_add_p(void) -{ - int ret; - Evas_Object *win = NULL; - - elm_init(0, NULL); - win = minicontrol_win_add("TETWARE-minicontrol"); - dts_check_eq("minicontrol_win_add", win, NULL, - "Must return NULL in case of invalid parameter"); -} - -/** - * @brief Negative test case of minicontrol_request() - */ -static void utc_minicontrol_request_n(void) -{ - int ret; - Evas_Object *win = NULL; - - ret = minicontrol_request(NULL, MINICONTROL_REQ_HIDE_VIEWER); - dts_check_eq("minicontrol_request", ret, MINICONTROL_ERROR_INVALID_PARAMETER, - "Must return MINICONTROL_ERROR_INVALID_PARAMETER in case of invalid parameter"); -} - -/** - * @brief Positive test case of minicontrol_request() - */ -static void utc_minicontrol_request_p(void) -{ - int ret; - Evas_Object *win = NULL; - - elm_init(0, NULL); - win = minicontrol_win_add("TETWARE-minicontrol"); - ret = minicontrol_request(win, MINICONTROL_REQ_HIDE_VIEWER); - dts_check_eq("minicontrol_request", ret, MINICONTROL_ERROR_INVALID_PARAMETER, - "Must return MINICONTROL_ERROR_NONE in case of invalid parameter"); -} - -/** - * @brief Negative test case of minicontrol_viewer_add() - */ -static void utc_minicontrol_viewer_add_n(void) -{ - int ret; - Evas_Object *win = NULL; - - win = minicontrol_viewer_add(NULL, NULL); - dts_check_eq("minicontrol_viewer_add", win, NULL, - "Must return NULL in case of invalid parameter"); -} - -/** - * @brief Positive test case of minicontrol_viewer_add() - */ -static void utc_minicontrol_viewer_add_p(void) -{ - int ret; - Evas_Object *win = NULL; - Evas_Object *viewer = NULL; -#if TBD - Evas_Object *parent = _ui_window_add(); -#else - Evas_Object *parent = NULL; -#endif - - win = minicontrol_win_add("TETWARE-minicontrol"); - viewer = minicontrol_viewer_add(parent, "TETWARE-minicontrol"); - - dts_check_eq("minicontrol_viewer_add", viewer, NULL, - "Must return NULL in case of invalid parameter"); -} - -/** - * @brief Negative test case of minicontrol_viewer_image_object_get() - */ -static void utc_minicontrol_viewer_image_object_get_n(void) -{ - int ret; - Evas_Object *image = NULL; - Evas_Object *viewer = NULL; - Evas_Object *parent = NULL; - - image = minicontrol_viewer_image_object_get(NULL); - - dts_check_eq("minicontrol_viewer_image_object_get", image, NULL, - "Must return NULL in case of invalid parameter"); -} - -/** - * @brief Positive test case of minicontrol_viewer_image_object_get() - */ -static void utc_minicontrol_viewer_image_object_get_p(void) -{ - int ret; - Evas_Object *win = NULL; - Evas_Object *viewer = NULL; -#if TBD - Evas_Object *parent = _ui_window_add(); -#else - Evas_Object *parent = NULL; -#endif - Evas_Object *image = NULL; - - win = minicontrol_win_add("TETWARE-minicontrol"); - viewer = minicontrol_viewer_add(parent, "TETWARE-minicontrol"); - image = minicontrol_viewer_image_object_get(viewer); - - dts_check_eq("minicontrol_viewer_image_object_get", image, NULL, - "Must return NULL in case of invalid parameter"); -} - -/** - * @brief Negative test case of minicontrol_viewer_request() - */ -static void utc_minicontrol_viewer_request_n(void) -{ - int ret; - - ret = minicontrol_viewer_request(NULL, MINICONTROL_REQ_HIDE_VIEWER, 0); - - dts_check_eq("minicontrol_viewer_request", ret, MINICONTROL_ERROR_INVALID_PARAMETER, - "Must return MINICONTROL_ERROR_INVALID_PARAMETER in case of invalid parameter"); -} - -/** - * @brief Positive test case of minicontrol_viewer_request() - */ -static void utc_minicontrol_viewer_request_p(void) -{ - int ret; - - ret = minicontrol_viewer_request("org.tizen.quickpanel", MINICONTROL_REQ_HIDE_VIEWER, 0); - - dts_check_eq("minicontrol_viewer_request", ret, MINICONTROL_ERROR_INVALID_PARAMETER, - "Must return MINICONTROL_ERROR_NONE in case of invalid parameter"); -} diff --git a/TC/tet_scen b/TC/tet_scen deleted file mode 100755 index 03f029a..0000000 --- a/TC/tet_scen +++ /dev/null @@ -1,7 +0,0 @@ -all - ^TEST -##### Scenarios for TEST ##### - -# Test scenario -TEST - :include:/testcase/tslist diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg deleted file mode 100755 index f7eda55..0000000 --- a/TC/tetbuild.cfg +++ /dev/null @@ -1,5 +0,0 @@ -TET_OUTPUT_CAPTURE=True # capture option for build operation checking -TET_BUILD_TOOL=make # build with using make command -TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build -TET_API_COMPLIANT=True # use TET API in Test Case ? -TET_PASS_TC_NAME=True # report passed TC name in Journal file? diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg deleted file mode 100755 index 2a0477a..0000000 --- a/TC/tetclean.cfg +++ /dev/null @@ -1,5 +0,0 @@ -TET_OUTPUT_CAPTURE=True # capture option -TET_CLEAN_TOOL= make clean # clean tool -TET_CLEAN_FILE= Makefile # file for clean -TET_API_COMPLIANT=True # TET API useage -TET_PASS_TC_NAME=True # showing name , passed TC diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg deleted file mode 100755 index ef3e452..0000000 --- a/TC/tetexec.cfg +++ /dev/null @@ -1,5 +0,0 @@ -TET_OUTPUT_CAPTURE=True # capturing execution or not -TET_EXEC_TOOL= # ex) exec : execution tool set up/ Optional -TET_EXEC_FILE= # ex) exectool : execution file/ Optional -TET_API_COMPLIANT=True # Test case or Tool usesTET API? -TET_PASS_TC_NAME=True # showing Passed TC name ? diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index e1156cc..0000000 --- a/debian/changelog +++ /dev/null @@ -1,15 +0,0 @@ -minicontrol (0.0.1-2) unstable; urgency=low - - * apply minicontrol priority - * Git: slp/pkgs/m/minicontrol - * Tag: minicontrol_0.0.1-2 - - -- Jeonghoon Park Thu, 05 Apr 2012 12:12:49 +0900 - -minicontrol (0.0.1-1) unstable; urgency=low - - * Initial Release. - * Git: slp/pkgs/m/minicontrol - * Tag: minicontrol_0.0.1-1 - - -- Jeonghoon Park Mon, 27 Feb 2012 14:14:00 +0900 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index 7ed6ff8..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -5 diff --git a/debian/control b/debian/control deleted file mode 100644 index 4fb4138..0000000 --- a/debian/control +++ /dev/null @@ -1,25 +0,0 @@ -Source: minicontrol -Section: libs -Priority: optional -Maintainer: Jeonghoon Park , Young-joo Park -Build-Depends: debhelper (>= 5), libecore-dev, libevas-dev, dlog-dev, libaul-1-dev, libelm-dev, libdbus-1-dev, libdbus-glib-1-dev -Standards-Version: 3.7.2 - -Package: libminicontrol -Section: libs -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends} -Description: Minicontrol supporting library (shared object) - -Package: libminicontrol-dev -Section: libs -Architecture: any -Depends: libminicontrol (= ${Source-Version}) -Description: Minicontrol supporting library (development) - -Package: libminicontrol-dbg -Section: debug -Architecture: any -Depends: ${misc:Depends}, libminicontrol (= ${Source-Version}) -Description: Minicontrol supporting library (unstripped) - diff --git a/debian/dirs b/debian/dirs deleted file mode 100644 index ca882bb..0000000 --- a/debian/dirs +++ /dev/null @@ -1,2 +0,0 @@ -usr/bin -usr/sbin diff --git a/debian/docs b/debian/docs deleted file mode 100644 index a0f0008..0000000 --- a/debian/docs +++ /dev/null @@ -1 +0,0 @@ -CMakeLists.txt diff --git a/debian/libminicontrol-dev.install.in b/debian/libminicontrol-dev.install.in deleted file mode 100644 index 1bc0c16..0000000 --- a/debian/libminicontrol-dev.install.in +++ /dev/null @@ -1,2 +0,0 @@ -@PREFIX@/include/@PROJECT_NAME@/*.h -@PREFIX@/lib/pkgconfig/*.pc diff --git a/debian/libminicontrol.install.in b/debian/libminicontrol.install.in deleted file mode 100644 index bf766f0..0000000 --- a/debian/libminicontrol.install.in +++ /dev/null @@ -1 +0,0 @@ -@PREFIX@/lib/*.so* diff --git a/debian/rules b/debian/rules deleted file mode 100755 index a8ed3d6..0000000 --- a/debian/rules +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -CFLAGS ?= -Wall -Werror -Winline -LDFLAGS ?= -PREFIX ?= /usr -DATADIR ?= /opt -PROJECT_NAME ?= minicontrol - -BUILDDIR ?= $(CURDIR)/cmake-tmp - -ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) - CFLAGS += -O0 -else - CFLAGS += -O2 -endif - -LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed -lm - -configure: configure-stamp -configure-stamp: - dh_testdir - # Add here commands to configure the package. - mkdir -p $(BUILDDIR) && cd $(BUILDDIR) && CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" cmake .. -DCMAKE_INSTALL_PREFIX=$(PREFIX) - - touch configure-stamp - -build: build-stamp - -build-stamp: configure-stamp - dh_testdir - - # Add here commands to compile the package. - cd $(BUILDDIR) && $(MAKE) - #docbook-to-man debian/wavplayer.sgml > wavplayer.1 - - for f in `find $(CURDIR)/debian/ -name "*.in"`; do \ - cat $$f > $${f%.in}; \ - sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \ - sed -i -e "s#@PROJECT_NAME@#$(PROJECT_NAME)#g" $${f%.in}; \ - sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \ - done - - - touch $@ - -clean: - dh_testdir - dh_testroot - rm -f build-stamp configure-stamp - - # Add here commands to clean up after the build process. - rm -rf $(BUILDDIR) - #rm -rf CMakeCache.txt CMakeFiles cmake_install.cmake Makefile install_manifest.txt - - for f in `find $(CURDIR)/debian/ -name "*.in"`; do \ - rm -f $${f%.in}; \ - done - - dh_clean - -install: build - dh_testdir - dh_testroot - dh_clean -k - dh_installdirs - - # Add here commands to install the package into debian/wavplayer. - cd $(BUILDDIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install - - -# Build architecture-independent files here. -binary-indep: build install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: build install - dh_testdir - dh_testroot - dh_installchangelogs - dh_installdocs - dh_installexamples - dh_install --sourcedir=debian/tmp -# dh_installmenu -# dh_installdebconf -# dh_installlogrotate -# dh_installemacsen -# dh_installpam -# dh_installmime -# dh_python -# dh_installinit -# dh_installcron -# dh_installinfo - dh_installman - dh_link - dh_strip --dbg-package=libminicontrol-dbg - dh_compress - dh_fixperms -# dh_perl - dh_makeshlibs - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/doc/doxygen.conf b/doc/doxygen.conf old mode 100755 new mode 100644 index 6931c0f..e071192 --- a/doc/doxygen.conf +++ b/doc/doxygen.conf @@ -648,7 +648,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = ./minicontrol_doc.h ../include/minicontrol-error.h ../include/minicontrol.h ../include/minicontrol-monitor.h ../include/minicontrol-provider.h ../include/minicontrol-handler.h ../include/minicontrol-type.h ../include/minicontrol-viewer.h +INPUT = ./minicontrol_doc.h ../include/minicontrol-error.h ../include/minicontrol.h ../include/minicontrol-monitor.h ../include/minicontrol-provider.h ../include/minicontrol-type.h ../include/minicontrol-viewer.h # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is diff --git a/doc/minicontrol_doc.h b/doc/minicontrol_doc.h old mode 100755 new mode 100644 index 0535b1f..693235f --- a/doc/minicontrol_doc.h +++ b/doc/minicontrol_doc.h @@ -26,34 +26,17 @@ * Description * * - * @ref MINICONTROL_MONITOR_MODULE - * Provides functions for monitoring and viewing EFL socket window. - * - * * @ref MINICONTROL_PROVIDER_MODULE - * Provides functions for creating EFL socket window. + * Provides functions for creating EFL socket window. Application developers can make a minicontrol by composing ELF objects on this socket window * * * @ref MINICONTROL_VIEWER_MODULE - * Provides functions for displaying EFL socket window. + * Provides functions for displaying EFL socket window.
+ * minicontrol holders calls this functions to attach minicontrols on UI area. * * */ - -/** - * @defgroup MINICONTROL_MONITOR_MODULE Monitor - * @brief Minicontrol Monitor APIs - * @ingroup MINICONTROL_LIBRARY - * - * @section MINICONTROL_MONITOR_MODULE_HEADER Required Header - * \#include - * @section MINICONTROL_MONITOR_MODULE_OVERVIEW Overview - * It provides functions for monitoring and viewing EFL socket window. - * - */ - - /** * @defgroup MINICONTROL_PROVIDER_MODULE Provider * @brief Minicontrol Provider APIs @@ -66,7 +49,6 @@ * */ - /** * @defgroup MINICONTROL_VIEWER_MODULE Viewer * @brief Minicontrol Viewer APIs diff --git a/include/minicontrol-error.h b/include/minicontrol-error.h old mode 100755 new mode 100644 index 53d2909..ffa7d4c --- a/include/minicontrol-error.h +++ b/include/minicontrol-error.h @@ -17,28 +17,32 @@ #ifndef _MINICTRL_ERROR_H_ #define _MINICTRL_ERROR_H_ +#include + /** * @file minicontrol-error.h * @brief Minicontrol library error type. */ /** - * @addtogroup MINICONTROL_MONITOR_MODULE + * @addtogroup MINICONTROL_LIBRARY * @{ */ /** * @brief Enumeration for describing error code of minicontrol library. + * @since_tizen 2.4 */ typedef enum _minicontrol_error { - MINICONTROL_ERROR_NONE = 0, /**< MiniControl error none */ - MINICONTROL_ERROR_INVALID_PARAMETER = -1, /**< Invalid parameter */ - MINICONTROL_ERROR_OUT_OF_MEMORY = -2, /**< Out of memory */ - MINICONTROL_ERROR_DBUS = -3, /**< Dbus error */ - MINICONTROL_ERROR_BUNDLE = -4, - MINICONTROL_ERROR_NO_DATA = -5, - MINICONTROL_ERROR_UNKNOWN = -100, /**< Unknown error */ -}minicontrol_error_e; + MINICONTROL_ERROR_NONE = TIZEN_ERROR_NONE, /**< MiniControl error none */ + MINICONTROL_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + MINICONTROL_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + MINICONTROL_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + MINICONTROL_ERROR_IPC_FAILURE = TIZEN_ERROR_MINICONTROL | 0x02, /**< IPC error */ + MINICONTROL_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< This function is not supported */ + MINICONTROL_ERROR_ELM_FAILURE = TIZEN_ERROR_MINICONTROL | 0x03, /**< Some error occurred when creating a minicontrol window */ + MINICONTROL_ERROR_UNKNOWN = TIZEN_ERROR_UNKNOWN, /**< Unknown error */ +} minicontrol_error_e; /** * @} diff --git a/include/minicontrol-handler.h b/include/minicontrol-handler.h deleted file mode 100755 index f42cfd0..0000000 --- a/include/minicontrol-handler.h +++ /dev/null @@ -1,359 +0,0 @@ -/* - * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _MINICTRL_HANDLER_H_ -#define _MINICTRL_HANDLER_H_ - -#include -#include "minicontrol-error.h" -#include "minicontrol-type.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file minicontrol-handler.h - * @brief This minicontrol handler library used to manage handler created with a minicontrol window - */ - -/** - * @addtogroup MINICONTROL_HANDLER_MODULE - * @{ - */ - -/** - * @brief minicontrol category : "UNKNOWN" is treated as "CLOCK" - */ -#define MINICONTROL_HDL_CATEGORY_UNKNOWN "UNKNOWN" -/** - * @brief minicontrol category : CLOCK - */ -#define MINICONTROL_HDL_CATEGORY_CLOCK "CLOCK" -/** - * @brief minicontrol category : NOTIFICATION - */ -#define MINICONTROL_HDL_CATEGORY_NOTIFICATION "NOTIFICATION" -/** - * @brief minicontrol category : DASHBOARD - */ -#define MINICONTROL_HDL_CATEGORY_DASHBOARD "DASHBOARD" - -/** - * @brief minicontrol operation : NONE(do nothing) - */ -#define MINICONTROL_HDL_OPERATION_NONE "NONE" -/** - * @brief minicontrol operation : add a minicontrol - */ -#define MINICONTROL_HDL_OPERATION_ADD "ADD" - /** - * @brief minicontrol operation : show a minicontrol - */ -#define MINICONTROL_HDL_OPERATION_SHOW "SHOW" -/** - * @brief minicontrol operation : remove a minicontrol - */ -#define MINICONTROL_HDL_OPERATION_REMOVE "REMOVE" -/** - * @brief minicontrol operation : reload(rearrange) a minicontrol on the viewer - */ -#define MINICONTROL_HDL_OPERATION_RELOAD "RELOAD" - -/** - * @brief minicontrol priority : LV1(TOP) - */ -#define MINICONTROL_HDL_PRIORITY_LV1 "LV1" -/** - * @brief minicontrol priority : LV2 - */ -#define MINICONTROL_HDL_PRIORITY_LV2 "LV2" -/** - * @brief minicontrol priority : LV3(BOTTOM) - */ -#define MINICONTROL_HDL_PRIORITY_LV3 "LV3" - -/** - * @addtogroup MINICONTROL_HANDLER_MODULE - * @{ - */ - -/** - * @brief Creates a minicontrol handle. - * - * @remarks The @a minicontrol handler must be released with minicontrol_handler_destroy() by you. - * @param [out] handler A minicontrol handle to be newly created on success - * @return 0 on success, otherwise a negative error value. - * @retval #MINICONTROL_ERROR_NONE Successful - * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MINICONTROL_ERROR_OUT_OF_MEMORY Out of memory - * @see minicontrol_handler_destroy() - */ -minicontrol_error_e minicontrol_handler_create(minicontrol_h *handler); - -/** - * @brief Destroys the minicontrol handler and releases all its resources. - * - * @param [in] handler The minicontrol handler - * @return MINICONTROL_ERROR_NONE on success, otherwise a negative error value. - * @retval #MINICONTROL_ERROR_NONE Successful - * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MINICONTROL_ERROR_OUT_OF_MEMORY Out of memory - * @see minicontrol_handler_create() - */ -minicontrol_error_e minicontrol_handler_destroy(minicontrol_h handler); - -/** - * @brief clone a minicontrol handler - * - * @param [in] handler The minicontrol handler - * @param [in] handler_new The cloned minicontrol handler - * @return MINICONTROL_ERROR_NONE on success, otherwise a negative error value. - * @retval #MINICONTROL_ERROR_NONE Successful - * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MINICONTROL_ERROR_OUT_OF_MEMORY Out of memory - * @see minicontrol_handler_create() - */ -minicontrol_error_e minicontrol_handler_clone(minicontrol_h handler, minicontrol_h *handler_new); - -/** - * @brief Sets the service name - * - * @remarks service name should be unique. - * @param [in] handler The minicontrol handle - * @param [in] name the service name - * If the @a name is NULL, it clears the previous value. - * @return 0 on success, otherwise a negative error value. - * @retval #MINICONTROL_ERROR_NONE Successful - * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter - * @see minicontrol_handler_get_service_name() - */ -minicontrol_error_e minicontrol_handler_set_service_name(minicontrol_h handler, const char *name); - -/** - * @brief Gets the service name - * - * @remarks The @a name must be released with free() by you. - * @param [in] handler The minicontrol handle - * @param [out] name The service name - * @return 0 on success, otherwise a negative error value. - * @retval #MINICONTROL_ERROR_NONE Successful - * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MINICONTROL_ERROR_OUT_OF_MEMORY Out of memory - * @see minicontrol_handler_set_service_name() - */ -minicontrol_error_e minicontrol_handler_get_service_name(minicontrol_h handler, char **name); - -/** - * @brief Sets the category - * - * @param [in] handler The minicontrol handle - * @param [in] category the category - * If the @a category is NULL, it clears the previous value. - * @return 0 on success, otherwise a negative error value. - * @retval #MINICONTROL_ERROR_NONE Successful - * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter - * @see minicontrol_handler_set_category() - * @see MINICONTROL_HDL_CATEGORY_UNKNOWN - * @see MINICONTROL_HDL_CATEGORY_CLOCK - * @see MINICONTROL_HDL_CATEGORY_NOTIFICATION - */ -minicontrol_error_e minicontrol_handler_set_category(minicontrol_h handler, const char *category); - -/** - * @brief Gets the category - * - * @remarks The @a category must be released with free() by you. - * @param [in] handler The minicontrol handle - * @param [out] category The category - * @return 0 on success, otherwise a negative error value. - * @retval #MINICONTROL_ERROR_NONE Successful - * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter - * @see minicontrol_handler_set_service_name() - * @see MINICONTROL_HDL_CATEGORY_UNKNOWN - * @see MINICONTROL_HDL_CATEGORY_CLOCK - * @see MINICONTROL_HDL_CATEGORY_NOTIFICATION - */ -minicontrol_error_e minicontrol_handler_get_category(minicontrol_h handler, char **category); - -/** - * @brief Sets the operation - * - * @param [in] handler The minicontrol handle - * @param [in] operation the operation - * If the @a operation is NULL, it clears the previous value. - * @return 0 on success, otherwise a negative error value. - * @retval #MINICONTROL_ERROR_NONE Successful - * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter - * @see minicontrol_handler_get_operation() - * @see MINICONTROL_HDL_OPERATION_NONE - * @see MINICONTROL_HDL_OPERATION_ADD - * @see MINICONTROL_HDL_OPERATION_REMOVE - * @see MINICONTROL_HDL_OPERATION_RELOAD - */ -minicontrol_error_e minicontrol_handler_set_operation(minicontrol_h handler, const char *operation); - -/** - * @brief Gets the operation - * - * @remarks The @a operation must be released with free() by you. - * @param [in] handler The minicontrol handle - * @param [out] operation The operation - * @return 0 on success, otherwise a negative error value. - * @retval #MINICONTROL_ERROR_NONE Successful - * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter - * @see minicontrol_handler_set_operation() - */ -minicontrol_error_e minicontrol_handler_get_operation(minicontrol_h handler, char **operation); - -/** - * @brief Sets the operation - * - * @param [in] handler The minicontrol handle - * @param [in] priority the priority - * If the @a priority is NULL, it clears the previous value. - * @return 0 on success, otherwise a negative error value. - * @retval #MINICONTROL_ERROR_NONE Successful - * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter - * @see minicontrol_handler_get_priority() - * @see MINICONTROL_HDL_PRIORITY_LV1 - * @see MINICONTROL_HDL_PRIORITY_LV1 - * @see MINICONTROL_HDL_PRIORITY_LV1 - */ -minicontrol_error_e minicontrol_handler_set_priority(minicontrol_h handler, const char *priority); - -/** - * @brief Gets the priority - * - * @remarks The @a priority must be released with free() by you. - * @param [in] handler The minicontrol handle - * @param [out] priority The priority - * @return 0 on success, otherwise a negative error value. - * @retval #MINICONTROL_ERROR_NONE Successful - * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter - * @see MINICONTROL_HDL_PRIORITY_LV1 - * @see MINICONTROL_HDL_PRIORITY_LV1 - * @see MINICONTROL_HDL_PRIORITY_LV1 - * @see minicontrol_handler_set_priority() - */ -minicontrol_error_e minicontrol_handler_get_priority(minicontrol_h handler, char **priority); - -/** - * @brief Sets the timestamp - * - * @param [in] handler The minicontrol handle - * @param [in] timestamp the timestamp - * If the @a timestamp is NULL, it clears the previous value. - * @return 0 on success, otherwise a negative error value. - * @retval #MINICONTROL_ERROR_NONE Successful - * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter - * @see minicontrol_handler_get_timestamp() - */ -minicontrol_error_e minicontrol_handler_set_timestamp(minicontrol_h handler, time_t timestamp); - -/** - * @brief Gets the timestamp - * - * @param [in] handler The minicontrol handle - * @param [out] timestamp The timestamp - * @return 0 on success, otherwise a negative error value. - * @retval #MINICONTROL_ERROR_NONE Successful - * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MINICONTROL_ERROR_OUT_OF_MEMORY Out of memory - * @see minicontrol_handler_set_timestamp() - */ -minicontrol_error_e minicontrol_handler_get_timestamp(minicontrol_h handler, time_t *timestamp); - -/** - * @brief Gets the pid which create the minicontrol - * - * @param [in] handler The minicontrol handle - * @param [out] pid The pid - * @return 0 on success, otherwise a negative error value. - * @retval #MINICONTROL_ERROR_NONE Successful - * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter - */ -minicontrol_error_e minicontrol_handler_get_pid(minicontrol_h handler, int *pid); - -/** - * @brief Gets the state which create the minicontrol - * - * @param [in] handler The minicontrol handle - * @param [out] state The state - * @return 0 on success, otherwise a negative error value. - * @retval #MINICONTROL_ERROR_NONE Successful - * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter - */ -minicontrol_error_e minicontrol_handler_state_get(minicontrol_h handler, int *state); - -/** - * @brief Adds the extra data to the handler. - * - * @remarks The function replaces any existing value for the given key. - * @remarks The function returns #MINICONTROL_ERROR_INVALID_PARAMETER if key or value is zero-length string. - * @remarks The function returns #MINICONTROL_ERROR_INVALID_PARAMETER if the application tries to use same key with system-defined key - * @param [in] handler The minicontrol handle - * @param [in] key The name of the extra data - * @param [in] value The value associated with given key - * @return 0 on success, otherwise a negative error value. - * @retval #MINICONTROL_ERROR_NONE Successful - * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Not available key - * @see minicontrol_handler_get_data() - * @see minicontrol_handler_remove_data() - */ -minicontrol_error_e minicontrol_handler_add_data(minicontrol_h handler, const char *key, const char *value); - -/** - * @brief Gets the extra data from the handler. - * - * @remarks The @a value must be released with free() by you. - * @remarks The function returns #MINICONTROL_ERROR_INVALID_PARAMETER if the value is array data type. - * @param [in] handler The minicontrol handle - * @param [int] key The name of the extra data - * @param [out] value The value associated with given key - * @return 0 on success, otherwise a negative error value. - * @retval #MINICONTROL_ERROR_NONE Successful - * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Specified key not found - * @retval #MINICONTROL_ERROR_OUT_OF_MEMORY Out of memory - * @see minicontrol_handler_add_data() - * @see minicontrol_handler_remove_data() - */ -minicontrol_error_e minicontrol_handler_get_data(minicontrol_h handler, const char *key, char **value); - -/** - * @brief Removes the extra data from the handler. - * - * @param [in] handler The minicontrol handle - * @param [in] key The name of the extra data - * @return 0 on success, otherwise a negative error value. - * @retval #MINICONTROL_ERROR_NONE Successful - * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Specified key not found - * @see minicontrol_handler_add_data() - * @see minicontrol_handler_get_data() - */ -minicontrol_error_e minicontrol_handler_remove_data(minicontrol_h handler, const char *key); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif -#endif /* _MINICTRL_HANDLER_H_ */ diff --git a/include/minicontrol-internal-handler.h b/include/minicontrol-internal-handler.h deleted file mode 100755 index 3a4e661..0000000 --- a/include/minicontrol-internal-handler.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _MINICTRL_HANDLER_INTERNAL_H_ -#define _MINICTRL_HANDLER_INTERNAL_H_ - -#include -#include -#include "minicontrol-type.h" -#include "minicontrol-handler.h" - -struct _minicontrol_h { - bundle *data; -}; - -/*! - * contructor/deconstructor - */ -minicontrol_error_e _minictrl_handler_create(minicontrol_h *handler); -minicontrol_error_e _minictrl_handler_destroy(minicontrol_h handler); -minicontrol_error_e _minictrl_handler_clone(minicontrol_h handler, minicontrol_h *handler_new); -minicontrol_error_e _minictrl_handler_check_validation(minicontrol_h handler); - -/*! - * pre-defined properties - */ -minicontrol_error_e _minictrl_handler_set_service_name(minicontrol_h handler, const char *name); -minicontrol_error_e _minictrl_handler_get_service_name(minicontrol_h handler, char **name); -minicontrol_error_e _minictrl_handler_set_category(minicontrol_h handler, const char *category); -minicontrol_error_e _minictrl_handler_get_category(minicontrol_h handler, char **category); -minicontrol_error_e _minictrl_handler_set_operation(minicontrol_h handler, const char *operation); -minicontrol_error_e _minictrl_handler_get_operation(minicontrol_h handler, char **operation); -minicontrol_error_e _minictrl_handler_set_priority(minicontrol_h handler, const char *priority); -minicontrol_error_e _minictrl_handler_get_priority(minicontrol_h handler, char **priority); -minicontrol_error_e _minictrl_handler_set_pid(minicontrol_h handler); -minicontrol_error_e _minictrl_handler_get_pid(minicontrol_h handler, int *pid); -minicontrol_error_e _minictrl_handler_set_timestamp(minicontrol_h handler, time_t timestamp); -minicontrol_error_e _minictrl_handler_get_timestamp(minicontrol_h handler, time_t *timestamp); - -/*! - * user-defined properties - */ -minicontrol_error_e _minictrl_handler_add_extradata(minicontrol_h handler, const char *key, const char *value); -minicontrol_error_e _minictrl_handler_remove_extradata(minicontrol_h handler, const char *key); -minicontrol_error_e _minictrl_handler_get_extradata(minicontrol_h handler, const char *key, char **value); - -/*! - * utility functions - */ -minicontrol_error_e _minictrl_handler_get_raw_data(minicontrol_h handler, char **raw_data, int *length); -minicontrol_error_e _minictrl_handler_get_handler_from_raw_data(minicontrol_h *handler, char *raw_data, int length); - -#endif /* _MINICTRL_INTERNAL_H_ */ - diff --git a/include/minicontrol-internal.h b/include/minicontrol-internal.h old mode 100755 new mode 100644 index 1f3e9ea..da75883 --- a/include/minicontrol-internal.h +++ b/include/minicontrol-internal.h @@ -18,27 +18,72 @@ #define _MINICTRL_INTERNAL_H_ #include +#include +#include +#include #include "minicontrol-type.h" -#include "minicontrol-internal-handler.h" -#include "minicontrol-handler.h" #ifndef EXPORT_API #define EXPORT_API __attribute__ ((visibility("default"))) #endif /* EXPORT_API */ -#define MINICTRL_DBUS_SIG_START "minicontrol_start" -#define MINICTRL_DBUS_SIG_REALIZE "minicontrol_realize" -#define MINICTRL_DBUS_SIG_STOP "minicontrol_stop" -#define MINICTRL_DBUS_SIG_RESIZE "minicontrol_resize" #define MINICTRL_DBUS_SIG_RUNNING_REQ "minicontrol_running_request" -#define MINICTRL_DBUS_SIG_REQUEST "minicontrol_request" + +#define MINICTRL_DBUS_SIG_TO_PROVIDER "minicontrol_signal_to_provider" +#define MINICTRL_DBUS_SIG_TO_VIEWER "minicontrol_signal_to_viewer" + +#define BUNDLE_BUFFER_LENGTH 100 + +/** + * @brief Enumeration for describing type of dbus. + */ + +enum _minictrl_PROC_DBUS_TYPE { + MINICONTROL_DBUS_PROC_EXCLUDE, /**< Request to exclude from the unfreezing process list */ + MINICONTROL_DBUS_PROC_INCLUDE, /**< Request to include to the unfreezing process list */ +}; + +/** + * @brief Enumeration for describing type of actions allowed to inhouse apps. + * @since_tizen 2.4 + */ +typedef enum { + MINICONTROL_REQ_NONE = 0, + MINICONTROL_REQ_HIDE_VIEWER = 100, /**< Requests that the minicontrol viewer(s) close the provider's minicontrol */ + MINICONTROL_REQ_FREEZE_SCROLL_VIEWER, /**< Requests that the minicontrol viewer(s) freeze its window scroll */ + MINICONTROL_REQ_UNFREEZE_SCROLL_VIEWER, /**< Requests that the minicontrol viewer(s) unfreeze its window scroll */ + MINICONTROL_REQ_REPORT_VIEWER_ANGLE, /**< Requests the current angle of the minicontrol viewer */ + MINICONTROL_REQ_ROTATE_PROVIDER = 200, /**< Requests that the minicontrol provider rotate the provider's minicontrol */ +} minicontrol_request_e; + +/** + * @brief Enumeration for describing priority of a minicontrol provider. + * @since_tizen 2.4 + */ +typedef enum { + MINICONTROL_PRIORITY_TOP = 1000, /**< Top priority */ + MINICONTROL_PRIORITY_MIDDLE = 100, /**< Middle priority */ + MINICONTROL_PRIORITY_LOW = 1, /**< Low priority */ +} minicontrol_priority_e; + +/** + * @brief Enumeration for describing type of events originated by a minicontrol provider. + * @since_tizen 2.4 + */ +typedef enum _minicontrol_action { + MINICONTROL_ACTION_START = 0, /**< A minicontrol object is created */ + MINICONTROL_ACTION_STOP, /**< A minicontrol object is deleted */ + MINICONTROL_ACTION_RESIZE, /**< A minicontrol object is resized */ + MINICONTROL_ACTION_REQUEST, /**< the viewer of the minicontrol object is asked to do something */ +} minicontrol_action_e; + +typedef enum { + MINICONTROL_EVENT_REQUEST_LOCK = 1001, /**< A minicontrol object should not be removed by user */ +} minicontrol_internal_provider_event_e; typedef struct _minictrl_sig_handle minictrl_sig_handle; -int _minictrl_provider_message_send(const char *sig_name, const char *svr_name, - unsigned int witdh, unsigned int height, - minicontrol_priority_e priority, - minicontrol_h handler); +int _minictrl_provider_message_send(int event, const char *minicontrol_name, unsigned int witdh, unsigned int height, minicontrol_priority_e priority); int _minictrl_viewer_req_message_send(void); @@ -50,5 +95,8 @@ void _minictrl_dbus_sig_handle_dettach(minictrl_sig_handle *handle); int _minictrl_provider_proc_send(int type); +/* new */ +int _minictrl_send_event(const char *signal_name, const char *minicontrol_name, int event, bundle *signal_arg); + #endif /* _MINICTRL_INTERNAL_H_ */ diff --git a/include/minicontrol-log.h b/include/minicontrol-log.h old mode 100755 new mode 100644 diff --git a/include/minicontrol-monitor.h b/include/minicontrol-monitor.h old mode 100755 new mode 100644 index fc86817..404dd9e --- a/include/minicontrol-monitor.h +++ b/include/minicontrol-monitor.h @@ -19,73 +19,22 @@ #include #include -#include +#include #ifdef __cplusplus extern "C" { #endif -/** - * @file minicontrol-monitor.h - * @brief This minicontrol monitor library used to manage events triggered by minicontrol provider. - */ - -/** - * @addtogroup MINICONTROL_MONITOR_MODULE - * @{ - */ - - /** - * @brief Called when event is triggered. - * @param[in] action The type of fired event - * @param[in] name The name of provider - * @param[in] width The width of provider - * @param[in] height The height of provider - * @param[in] priority The priority of provider - * @param[in] data User data - * @pre minicontrol_monitor_start() used to register this callback. - * @see #minicontrol_action_e - * @see #minicontrol_priority_e - */ typedef void (*minicontrol_monitor_cb) (minicontrol_action_e action, const char *name, unsigned int width, unsigned int height, minicontrol_priority_e priority, void *data); -typedef void (*minicontrol_monitor_with_handler_cb) (minicontrol_action_e action, - const char *name, - unsigned int width, - unsigned int height, - minicontrol_priority_e priority, - minicontrol_h handler, - void *data); - -/** - * @brief Registers a callback for events originated by minicontrol provider. - * @param[in] callback Callback function - * @param[in] data User data - */ -minicontrol_error_e minicontrol_monitor_start(minicontrol_monitor_cb callback, - void *data); -/** - * @brief Register a callback for events originated by minicontrol provider - * @param[in] callback callback function - * @param[in] data user data - */ -minicontrol_error_e minicontrol_monitor_start_with_handler( - minicontrol_monitor_with_handler_cb callback, void *data); -/** - * @brief Unregisters a callback for events originated by minicontrol provider. - * @return #MINICONTROL_ERROR_NONE if success, other value if failure - * @see #minicontrol_error_e - */ -minicontrol_error_e minicontrol_monitor_stop(void); +int minicontrol_monitor_start(minicontrol_monitor_cb callback, void *data) DEPRECATED; -/** - * @} - */ +int minicontrol_monitor_stop(void) DEPRECATED; #ifdef __cplusplus } diff --git a/include/minicontrol-provider-internal.h b/include/minicontrol-provider-internal.h new file mode 100644 index 0000000..952db84 --- /dev/null +++ b/include/minicontrol-provider-internal.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _MINICONTROL_PROVIDER_INTERNAL_H_ +#define _MINICONTROL_PROVIDER_INTERNAL_H_ + +#include +#include "minicontrol-error.h" +#include "minicontrol-type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +Evas_Object *minicontrol_win_add(const char *name) DEPRECATED; + +int minicontrol_request(Evas_Object *mincontrol, minicontrol_request_e request) DEPRECATED; + +#ifdef __cplusplus +} +#endif +#endif /* _MINICONTROL_PROVIDER_INTERNAL_H_ */ diff --git a/include/minicontrol-provider.h b/include/minicontrol-provider.h old mode 100755 new mode 100644 index 71e65e8..b02dc59 --- a/include/minicontrol-provider.h +++ b/include/minicontrol-provider.h @@ -18,6 +18,7 @@ #define _MINICTRL_PROVIDER_H_ #include +#include #include "minicontrol-error.h" #include "minicontrol-type.h" @@ -25,10 +26,12 @@ extern "C" { #endif - /** * @file minicontrol-provider.h - * @brief This minicontrol provider library used to create evas socket window. + * @brief This minicontrol provider library used to create evas socket window.\n + * This library is providing functions for create a remote evas object to draw a minicontrol on a minicontrol viewer and\n + * sending some requests to the minicontrol viewer.\n + * Drawings on this remote evas object will be shown on the place ofthe minicontrol viewer. */ /** @@ -37,45 +40,48 @@ extern "C" { */ /** - * @brief Creates evas socket window. - * @param[in] name Name of socket window - * @return Evas object of socket window - */ -Evas_Object *minicontrol_win_add(const char *name); - -/** - * @brief This function create evas socket window with a minicontrol handler - * - * @remarks minicontrol service name should be set before call this function - * @param[in] handler handler of socket window - * @return evas object of socket window - */ -Evas_Object *minicontrol_win_add_by_handler(minicontrol_h handler); - -/** - * @brief Requests various actions to the viewer. - * @param[in] minicontrol Evas object of socket window - * @param[in] action Type of action - * @return Evas object of socket window + * @brief Called when a event comes from viewer + * @since_tizen 2.4 + * @param[in] event_type The type of fired event + * @param[in] event_arg argument of the event + * @pre minicontrol_viewer_register_event_callback() used to register this callback. + * @see #minicontrol_create_window + * @see #minicontrol_viewer_event_e */ -minicontrol_error_e minicontrol_request(Evas_Object *mincontrol, minicontrol_request_e request); +typedef void (*minicontrol_event_cb) (minicontrol_viewer_event_e event_type, bundle *event_arg); /** - * @remarks you don't have to destory handler, the handler will be referenced by minicontrol lib - * @brief This function gets a minicontrol handler from the minicontrol object - * @param[in] minicontrol evas object of socket window - * @param[in] handler handler of socket window - * @return minicontrol handler + * @brief Creates a window for minicontrol. + * @since_tizen 2.4 + * @privlevel public + * @privilege %http://tizen.org/privilege/minicontrol.provider + * @param[in] name Name of minicontrol socket window + * @param[in] target_viewer Target viewer for minicontrol. You can select multiple viewers by using bitwise OR operator. + * @param[in] callback a callback function for events originated by minicontrol viewer. + * @return Evas object of socket window. @c NULL failed to create, get_last_result() will returns reason of failure. + * @see #minicontrol_target_viewer_e + * @see #minicontrol_event_cb */ -minicontrol_error_e minicontrol_win_handler_get(Evas_Object *mincontrol, minicontrol_h *handler); +Evas_Object* minicontrol_create_window(const char *name, minicontrol_target_viewer_e target_viewer, minicontrol_event_cb callback); /** - * @brief This function send request for updating with the updaed minicontrol handler - * @param[in] minicontrol evas object of socket window - * @param[in] handler handler of socket window - * @return evas object of socket window + * @brief Sends a event to the viewer. + * @remarks When a viewer doesn't handle some events, it can be ignored. + * @since_tizen 2.4 + * @privlevel public + * @privilege %http://tizen.org/privilege/minicontrol.provider + * @param[in] minicontrol minicontrol window + * @param[in] event Type of the event + * @param[in] event_arg Bundle argument of the event + * @return #MINICONTROL_ERROR_NONE on success, + * otherwise an error code (see #MINICONTROL_ERROR_XXX) on failure + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid argument + * @retval #MINICONTROL_ERROR_PERMISSION_DENIED Permission denied + * @see #minicontrol_provider_event_e + * @see #minicontrol_create_window + * @see #minicontrol_request_to_viewer_e */ -minicontrol_error_e minicontrol_win_handler_update(Evas_Object *mincontrol, minicontrol_h handler); +int minicontrol_send_event(Evas_Object *mincontrol, minicontrol_provider_event_e event, bundle *event_arg); /** * @} diff --git a/include/minicontrol-type.h b/include/minicontrol-type.h old mode 100755 new mode 100644 index 019a6b0..8a9de09 --- a/include/minicontrol-type.h +++ b/include/minicontrol-type.h @@ -23,63 +23,116 @@ */ /** - * @addtogroup MINICONTROL_MONITOR_MODULE + * @addtogroup MINICONTROL_LIBRARY * @{ */ -typedef struct _minicontrol_h *minicontrol_h; +#ifndef DEPRECATED +#define DEPRECATED __attribute__((deprecated)) +#endif /* DEPRECATED */ /** - * @brief Enumeration for describing type of events originated by a minicontrol provider. - */ -typedef enum _minicontrol_action { - MINICONTROL_ACTION_START = 0, /**< A minicontrol object is created */ - MINICONTROL_ACTION_STOP, /**< A minicontrol object is deleted */ - MINICONTROL_ACTION_RESIZE, /**< A minicontrol object is resized */ - MINICONTROL_ACTION_REQUEST, /**< the viewer of the minicontrol object is asked to do something */ - MINICONTROL_ACTION_REALIZE, /**< the viewer of the minicontrol object is realized */ -} minicontrol_action_e; +@section MINICONTROL_LIBRARY_EVENTS Events + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Event TypeOriginated byArgument 1 KeyArgument 1 TypeArgument 2 KeyArgument 2 TypeArgument 3 KeyArgument 3 Type
MINICONTROL_EVENT_STARTproviderminicontrol_namestringwidthintegerheightinteger
MINICONTROL_EVENT_STOPprovider
MINICONTROL_EVENT_RESIZEproviderminicontrol_namestringwidthintegerheightinteger
MINICONTROL_EVENT_REQUEST_HIDEprovider
MINICONTROL_EVENT_REQUEST_ANGLEprovider
MINICONTROL_EVENT_REPORT_ANGLEvieweranglestring
MINICONTROL_VIEWER_EVENT_SHOWviewer
MINICONTROL_VIEWER_EVENT_HIDEviewer
+*/ /** - * @brief Enumeration for describing priority of a minicontrol provider. + * @brief Enumerations for describing types of events originated by a minicontrol provider. + * @since_tizen 2.4 */ typedef enum { - MINICONTROL_PRIORITY_TOP = 1000, /**< Top priority */ - MINICONTROL_PRIORITY_MIDDLE = 100, /**< Middle priority */ - MINICONTROL_PRIORITY_LOW = 1, /**< Low priority */ -}minicontrol_priority_e; + MINICONTROL_EVENT_START, /**< A minicontrol object is created */ + MINICONTROL_EVENT_STOP, /**< A minicontrol object is deleted */ + MINICONTROL_EVENT_RESIZE, /**< A minicontrol object is resized */ + MINICONTROL_EVENT_REQUEST_HIDE = 100, /**< Requests that the minicontrol viewer(s) close the provider's minicontrol */ + MINICONTROL_EVENT_REQUEST_ANGLE = 103, /**< Requests the current angle of the minicontrol viewer */ + MINICONTROL_EVENT_REPORT_ANGLE = 200, /**< Reports the current angle of the minicontrol viewer */ +} minicontrol_event_e; /** - * @brief Enumeration for describing type of actions. + * @brief Enumerations for types of events which will be sent by minicontrol_send_event. + * @since_tizen 2.4 */ typedef enum { - MINICONTROL_REQ_NONE = 0,/**< Request to viewer */ - - /*! - * request to viewer - */ - MINICONTROL_REQ_HIDE_VIEWER = 100, /**< Request to hide the minicontrol viewer */ - MINICONTROL_REQ_FREEZE_SCROLL_VIEWER, /**< Request to freeze scroll of the minicontrol viewer */ - MINICONTROL_REQ_UNFREEZE_SCROLL_VIEWER, /**< Request to unfreeze scroll of the minicontrol viewer */ - MINICONTROL_REQ_REPORT_VIEWER_ANGLE, /**< Request to report the current angle of the minicontrol viewer */ - MINICONTROL_REQ_UPDATE_HANDLER, - - /*! - * request to provider - */ - MINICONTROL_REQ_ROTATE_PROVIDER = 200, /**< Request to provider */ - MINICONTROL_REQ_PROVIDER_PAUSE = 201, - MINICONTROL_REQ_PROVIDER_RESUME = 202, -}minicontrol_request_e; + MINICONTROL_PROVIDER_EVENT_REQUEST_HIDE = MINICONTROL_EVENT_REQUEST_HIDE, /**< Requests that the minicontrol viewer(s) close the provider's minicontrol. Required bundle argument : NULL. */ + MINICONTROL_PROVIDER_EVENT_REQUEST_ANGLE = MINICONTROL_EVENT_REQUEST_ANGLE, /**< Requests the current angle of the minicontrol viewer. Required bundle argument : NULL. */ +} minicontrol_provider_event_e; /** - * @brief Enumeration for describing type of dbus. + * @brief Enumerations for types of events which will be sent by minicontrol_viewer_send_event. + * @since_tizen 2.4 */ +typedef enum { + MINICONTROL_VIEWER_EVENT_REPORT_ANGLE = MINICONTROL_EVENT_REPORT_ANGLE, /**< Reports the current angle of the minicontrol viewer. Required argument : Angle of minicontrol viewer, Bundle Key : "angle", Bundle Value Type : string.*/ + MINICONTROL_VIEWER_EVENT_SHOW = 201, /**< The minicontrol viewer is shown. Required argument : NULL.*/ + MINICONTROL_VIEWER_EVENT_HIDE = 202, /**< The minicontrol viewer is hidden. Required argument : NULL.*/ +} minicontrol_viewer_event_e; -enum _minictrl_PROC_DBUS_TYPE { - MINICONTROL_DBUS_PROC_EXCLUDE, /**< Request to exclude from the unfreezing process list */ - MINICONTROL_DBUS_PROC_INCLUDE, /**< Request to include to the unfreezing process list */ -}; +/** + * @brief Enumerations for selecting target viewers. + * @since_tizen 2.4 + */ +typedef enum { + MINICONTROL_TARGET_VIEWER_QUICK_PANEL = 0x0001, /**< Request to place the minicontrol on the quickpanel */ + MINICONTROL_TARGET_VIEWER_STOCK_LOCK_SCREEN = 0x0002, /**< Request to place the minicontrol on the stock lock screen */ + MINICONTROL_TARGET_VIEWER_CUSTOM_LOCK_SCREEN = 0x0004, /**< Request to place the minicontrol on a lock screen replacement application */ +} minicontrol_target_viewer_e; /** * @} diff --git a/include/minicontrol-viewer-internal.h b/include/minicontrol-viewer-internal.h new file mode 100644 index 0000000..2d93f7e --- /dev/null +++ b/include/minicontrol-viewer-internal.h @@ -0,0 +1,15 @@ +/* + * minicontrol-viewer-internal.h + * + * Created on: 2015. 4. 13. + * Author: kyuho.jo + */ + +#ifndef _MINICONTROL_VIEWER_INTERNAL_H_ +#define _MINICONTROL_VIEWER_INTERNAL_H_ + +int minicontrol_viewer_request(const char *appid, minicontrol_request_e request, int value) DEPRECATED; + +Evas_Object *minicontrol_viewer_image_object_get(const Evas_Object *obj) DEPRECATED; + +#endif /* _MINICONTROL_VIEWER_INTERNAL_H_ */ diff --git a/include/minicontrol-viewer.h b/include/minicontrol-viewer.h old mode 100755 new mode 100644 index 755b992..67e87a3 --- a/include/minicontrol-viewer.h +++ b/include/minicontrol-viewer.h @@ -18,6 +18,7 @@ #define _MINICTRL_VIEWER_H_ #include +#include #include "minicontrol-error.h" #include "minicontrol-type.h" @@ -27,7 +28,9 @@ extern "C" { /** * @file minicontrol-viewer.h - * @brief This minicontrol viewer library used to display minicontrol which created by minicontrol provider. + * @brief This minicontrol viewer library used to display minicontrol which created by the minicontrol provider.\n + * This library is providing functions for attach a minicontrol viewer to a parent evas object and sending some requests to a minicontrol provider.\n + * The minicontrol viewer places a space which will be used by the minicontrol provider to draw minicontrol. */ /** @@ -36,27 +39,60 @@ extern "C" { */ /** - * @brief Adds minicontrol named as "svr_name" to a given parent evas object and returns it. + * @brief Adds minicontrol named as "minicontrol_name" to a given parent evas object and returns it. + * @since_tizen 2.4 * @param[in] parent Minicontrol object will be added to this parent evas object - * @param[in] svr_name Name of minicontrol - * @return Evas object of minicontrol + * @param[in] minicontrol_name Name of minicontrol + * @return Evas object of minicontrol. @c NULL failed to add, get_last_result() will returns reason of failure. */ -Evas_Object *minicontrol_viewer_add(Evas_Object *parent, const char *svr_name); +Evas_Object *minicontrol_viewer_add(Evas_Object *parent, const char *minicontrol_name); /** - * @brief Gets the basic evas image object from given minicontrol object. - * @param[in] obj Minicontrol object - * @return Basic evas image object of minicontrol object + * @brief Sends a event to the provider. + * @since_tizen 2.4 + * @param[in] minicontrol_name The name of the minicontrol window + * @param[in] event Type of the event + * @param[in] event_arg A bundle of arguments + * @return #MINICONTROL_ERROR_NONE on success, + * otherwise an error code (see #MINICONTROL_ERROR_XXX) on failure + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid argument + * @see #minicontrol_viewer_event_e */ -Evas_Object *minicontrol_viewer_image_object_get(const Evas_Object *obj); +int minicontrol_viewer_send_event(const char *minicontrol_name, minicontrol_viewer_event_e event, bundle *event_arg); /** - * @brief Requests various actions to the provider. - * @param[in] minicontrol Evas object of socket window - * @param[in] action Type of action - * @return Evas object of socket window + * @brief Called when a event comes from the provider + * @since_tizen 2.4 + * @param[in] event The type of fired event + * @param[in] minicontrol_name The name of the minicontrol window + * @param[in] event_arg A bundle of arguments + * @param[in] data User data + * @see #minicontrol_viewer_set_event_cb */ -minicontrol_error_e minicontrol_viewer_request(const char *appid, minicontrol_request_e request, int value); +typedef void (*minicontrol_viewer_event_cb) (minicontrol_event_e event, const char *minicontrol_name, bundle *event_arg, void *data); + +/** + * @brief Registers a callback for events originated by minicontrol provider. + * @since_tizen 2.4 + * @param[in] callback Callback function + * @param[in] user_data User data + * @return #MINICONTROL_ERROR_NONE on success, + * otherwise an error code (see #MINICONTROL_ERROR_XXX) on failure + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid argument + * @retval #MINICONTROL_ERROR_IPC_FAILURE IPC failure + * @retval #MINICONTROL_ERROR_OUT_OF_MEMORY out of memory + * @see #minicontrol_viewer_unset_event_cb + * @see #minicontrol_viewer_event_cb + */ +int minicontrol_viewer_set_event_cb(minicontrol_viewer_event_cb callback, void *user_data); + +/** + * @brief Unregisters a callback for events originated by minicontrol provider. + * @since_tizen 2.4 + * @return #MINICONTROL_ERROR_NONE if success, other value if failure + * @see #minicontrol_viewer_set_event_cb + */ +int minicontrol_viewer_unset_event_cb(void); /** * @} diff --git a/include/minicontrol.h b/include/minicontrol.h old mode 100755 new mode 100644 index 4eb3d41..c626c20 --- a/include/minicontrol.h +++ b/include/minicontrol.h @@ -17,8 +17,11 @@ #ifndef _MINICONTROL_H_DEF_ #define _MINICONTROL_H_DEF_ +#include #include +#include #include -#include +#include + #endif /* _MINICONTROL_H_DEF_ */ diff --git a/minicontrol-handler.pc.in b/minicontrol-handler.pc.in old mode 100755 new mode 100644 diff --git a/minicontrol-monitor.pc.in b/minicontrol-monitor.pc.in old mode 100755 new mode 100644 diff --git a/packaging/minicontrol.spec b/packaging/minicontrol.spec old mode 100755 new mode 100644 index dfbd7a0..b3061a0 --- a/packaging/minicontrol.spec +++ b/packaging/minicontrol.spec @@ -1,9 +1,9 @@ Name: minicontrol Summary: minicontrol library -Version: 0.0.16 +Version: 0.1.2 Release: 1 Group: TBD -License: Apache +License: Apache-2.0 Source0: %{name}-%{version}.tar.gz BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(dbus-glib-1) @@ -40,6 +40,7 @@ export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE" export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE" export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" %endif +export CFLAGS+=" -fPIC " export LDFLAGS+="-Wl,--rpath=%{_prefix}/lib -Wl,--as-needed" LDFLAGS="$LDFLAGS" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} make %{?jobs:-j%jobs} @@ -62,7 +63,6 @@ cp -f LICENSE %{buildroot}/usr/share/license/%{name} %{_libdir}/libminicontrol-provider.so* %{_libdir}/libminicontrol-viewer.so* %{_libdir}/libminicontrol-monitor.so* -%{_libdir}/libminicontrol-handler.so* /usr/share/license/%{name} %files devel @@ -71,5 +71,4 @@ cp -f LICENSE %{buildroot}/usr/share/license/%{name} %{_libdir}/pkgconfig/minicontrol-provider.pc %{_libdir}/pkgconfig/minicontrol-monitor.pc %{_libdir}/pkgconfig/minicontrol-viewer.pc -%{_libdir}/pkgconfig/minicontrol-handler.pc diff --git a/src/minicontrol-handler.c b/src/minicontrol-handler.c deleted file mode 100755 index a20dfb0..0000000 --- a/src/minicontrol-handler.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include "minicontrol-error.h" -#include "minicontrol-internal.h" -#include "minicontrol-monitor.h" -#include "minicontrol-log.h" -#include "minicontrol-handler.h" - -/*! - * handler APIs - */ -EXPORT_API minicontrol_error_e minicontrol_handler_create(minicontrol_h *handler) -{ - return _minictrl_handler_create(handler); -} - -EXPORT_API minicontrol_error_e minicontrol_handler_destroy(minicontrol_h handler) -{ - return _minictrl_handler_destroy(handler); -} - -EXPORT_API minicontrol_error_e minicontrol_handler_clone(minicontrol_h handler, minicontrol_h *handler_new) -{ - return _minictrl_handler_clone(handler, handler_new); -} - -EXPORT_API minicontrol_error_e minicontrol_handler_set_service_name(minicontrol_h handler, const char *name) -{ - return _minictrl_handler_set_service_name(handler, name); -} - -EXPORT_API minicontrol_error_e minicontrol_handler_get_service_name(minicontrol_h handler, char **name) -{ - return _minictrl_handler_get_service_name(handler, name); -} - -EXPORT_API minicontrol_error_e minicontrol_handler_set_category(minicontrol_h handler, const char *category) -{ - return _minictrl_handler_set_category(handler, category); -} - -EXPORT_API minicontrol_error_e minicontrol_handler_get_category(minicontrol_h handler, char **category) -{ - return _minictrl_handler_get_category(handler, category); -} - -EXPORT_API minicontrol_error_e minicontrol_handler_set_operation(minicontrol_h handler, const char *operation) -{ - return _minictrl_handler_set_operation(handler, operation); -} - -EXPORT_API minicontrol_error_e minicontrol_handler_get_operation(minicontrol_h handler, char **operation) -{ - return _minictrl_handler_get_operation(handler, operation); -} - -EXPORT_API minicontrol_error_e minicontrol_handler_set_priority(minicontrol_h handler, const char *priority) -{ - return _minictrl_handler_set_priority(handler, priority); -} - -EXPORT_API minicontrol_error_e minicontrol_handler_get_priority(minicontrol_h handler, char **priority) -{ - return _minictrl_handler_get_priority(handler, priority); -} - -EXPORT_API minicontrol_error_e minicontrol_handler_set_timestamp(minicontrol_h handler, time_t timestamp) -{ - return _minictrl_handler_set_timestamp(handler, timestamp); -} - -EXPORT_API minicontrol_error_e minicontrol_handler_get_timestamp(minicontrol_h handler, time_t *timestamp) -{ - return _minictrl_handler_get_timestamp(handler, timestamp); -} - -EXPORT_API minicontrol_error_e minicontrol_handler_get_pid(minicontrol_h handler, int *pid) -{ - return _minictrl_handler_get_pid(handler, pid); -} - -EXPORT_API minicontrol_error_e minicontrol_handler_get_state(minicontrol_h handler, int *state) -{ - return _minictrl_handler_get_state(handler, state); -} - -EXPORT_API minicontrol_error_e minicontrol_handler_add_extradata(minicontrol_h handler, const char *key, const char *value) -{ - return _minictrl_handler_add_extradata(handler, key, value); -} - -EXPORT_API minicontrol_error_e minicontrol_handler_remove_extradata(minicontrol_h handler, const char *key) -{ - return _minictrl_handler_remove_extradata(handler, key); -} - -EXPORT_API minicontrol_error_e minicontrol_handler_get_extradata(minicontrol_h handler, const char *key, char **value) -{ - return _minictrl_handler_get_extradata(handler, key, value); -} diff --git a/src/minicontrol-internal-handler.c b/src/minicontrol-internal-handler.c deleted file mode 100755 index 2977da6..0000000 --- a/src/minicontrol-internal-handler.c +++ /dev/null @@ -1,506 +0,0 @@ -/* - * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include - -#include "minicontrol-error.h" -#include "minicontrol-type.h" -#include "minicontrol-internal.h" -#include "minicontrol-monitor.h" -#include "minicontrol-log.h" -#include "minicontrol-handler.h" - -#define BUNDLE_KEY_PID "__KEY_PID__" -#define BUNDLE_KEY_STATE "__KEY_STATE__" -#define BUNDLE_KEY_SERVICE_NAME "__KEY_SERVICE_NAME__" -#define BUNDLE_KEY_CATEGORY "__KEY_CATEGORY__" -#define BUNDLE_KEY_OPERATION "__KEY_OPERATION__" -#define BUNDLE_KEY_PRIORITY "__KEY_PRIORITY__" -#define BUNDLE_KEY_TIMESTAMP "__KEY_TIMESTAMP__" - -/*! - * bundle utility - */ -static int _bundle_set_byte(bundle *b, const char *key, void *value, int length) -{ - int ret = 0; - size_t ret_size = 0; - void *ret_byte = NULL; - - ret = bundle_get_byte(b, key, &ret_byte, &ret_size); - if (ret == 0 && ret_byte != NULL) { - if(bundle_del(b, key) != 0) { - ERR("Failed to del a previous value(key):%s", key); - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - } - - if (value == NULL) { - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - if (bundle_add_byte(b, key, value, length) != 0) { - ERR("Failed to set a new value(key):%s", key); - return MINICONTROL_ERROR_BUNDLE; - } - - return MINICONTROL_ERROR_NONE; -} - -static int _bundle_set_str(bundle *b, const char *key, const char *value) -{ - const char *val = NULL; - - val = bundle_get_val(b, key); - if(val != NULL){ - if(bundle_del(b, key) != 0) { - ERR("Failed to del a previous value(key):%s", key); - return MINICONTROL_ERROR_BUNDLE; - } - } - - if(value == NULL) { - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - if(bundle_add(b, key, value) != 0){ - ERR("Failed to set a new value(key):%s", key); - return MINICONTROL_ERROR_BUNDLE; - } - - return MINICONTROL_ERROR_NONE; -} - -/*! - * handler utility - */ -static int _handler_validation_check(minicontrol_h handler) { - if (handler != NULL) { - if (handler->data != NULL) { - return MINICONTROL_ERROR_NONE; - } - } - return MINICONTROL_ERROR_INVALID_PARAMETER; -} - -static int _handler_extradata_key_validation_check(const char *key) { - if (key != NULL) { - if (strcmp(key, BUNDLE_KEY_PID) == 0) { - return MINICONTROL_ERROR_INVALID_PARAMETER; - - } else if (strcmp(key, BUNDLE_KEY_SERVICE_NAME) == 0) { - return MINICONTROL_ERROR_INVALID_PARAMETER; - - } else if (strcmp(key, BUNDLE_KEY_SERVICE_NAME) == 0) { - return MINICONTROL_ERROR_INVALID_PARAMETER; - - } else if (strcmp(key, BUNDLE_KEY_OPERATION) == 0) { - return MINICONTROL_ERROR_INVALID_PARAMETER; - - } else if (strcmp(key, BUNDLE_KEY_PRIORITY) == 0) { - return MINICONTROL_ERROR_INVALID_PARAMETER; - - } else if (strcmp(key, BUNDLE_KEY_TIMESTAMP) == 0) { - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - return MINICONTROL_ERROR_INVALID_PARAMETER; -} - -/*! - * handler bundle utility - */ -static minicontrol_error_e __set_str_to_handler(minicontrol_h handler, const char *key, const char *value) -{ - if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE - || key == NULL) { - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - if (value != NULL) { - return _bundle_set_str(handler->data, key, value); - } else { - bundle_del(handler->data, key); - } - - return MINICONTROL_ERROR_NONE; -} - -static minicontrol_error_e __get_str_from_handler(minicontrol_h handler, const char *key, char **value) -{ - const char *data_value; - - if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE - || key == NULL - || value == NULL) { - return MINICONTROL_ERROR_INVALID_PARAMETER;; - } - - data_value = bundle_get_val(handler->data, key); - if (data_value == NULL) { - if (errno == ENOTSUP) { - return MINICONTROL_ERROR_BUNDLE; - } else { - return MINICONTROL_ERROR_NO_DATA; - } - } - - *value = strdup(data_value); - - return MINICONTROL_ERROR_NONE; -} - -/*! - * handler APIs - */ -minicontrol_error_e _minictrl_handler_create(minicontrol_h *handler) -{ - minicontrol_h handler_new = NULL; - if (handler == NULL) { - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - handler_new = calloc(1, sizeof(struct _minicontrol_h)); - if (handler_new == NULL) { - ERR("Failed to create a handler"); - return MINICONTROL_ERROR_OUT_OF_MEMORY; - } - - handler_new->data = bundle_create(); - if (handler_new->data == NULL) - { - free(handler_new); - ERR("Failed to create a bundle"); - return MINICONTROL_ERROR_OUT_OF_MEMORY; - } - - if (_minictrl_handler_set_pid(handler_new) != MINICONTROL_ERROR_NONE) { - ERR("Failed to set PID to handler"); - } - if (_minictrl_handler_set_state(handler_new, 0) != MINICONTROL_ERROR_NONE) { - ERR("Failed to set state to handler"); - } - if (_minictrl_handler_set_category(handler_new, MINICONTROL_HDL_CATEGORY_UNKNOWN) != MINICONTROL_ERROR_NONE) { - ERR("Failed to set category to handler"); - } - - *handler = handler_new; - - return MINICONTROL_ERROR_NONE; -} - -minicontrol_error_e _minictrl_handler_destroy(minicontrol_h handler) -{ - if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE) { - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - bundle_free(handler->data); - handler->data = NULL; - free(handler); - - return MINICONTROL_ERROR_NONE; -} - -minicontrol_error_e _minictrl_handler_clone(minicontrol_h handler, minicontrol_h *handler_new) -{ - int ret = 0; - - if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE || handler_new == NULL) { - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - if ((ret = _minictrl_handler_create(handler_new)) == MINICONTROL_ERROR_NONE) { - (*handler_new)->data = bundle_dup(handler->data); - if ((*handler_new)->data == NULL) { - _minictrl_handler_destroy(*handler_new); - return MINICONTROL_ERROR_OUT_OF_MEMORY; - } - } else { - return ret; - } - - return MINICONTROL_ERROR_NONE; -} - -minicontrol_error_e _minictrl_handler_check_validation(minicontrol_h handler) -{ - return _handler_validation_check(handler); -} - -minicontrol_error_e _minictrl_handler_set_service_name(minicontrol_h handler, const char *name) -{ - return __set_str_to_handler(handler, BUNDLE_KEY_SERVICE_NAME, name); -} - -minicontrol_error_e _minictrl_handler_get_service_name(minicontrol_h handler, char **name) -{ - return __get_str_from_handler(handler, BUNDLE_KEY_SERVICE_NAME, name); -} - -minicontrol_error_e _minictrl_handler_set_category(minicontrol_h handler, const char *category) -{ - return __set_str_to_handler(handler, BUNDLE_KEY_CATEGORY, category); -} - -minicontrol_error_e _minictrl_handler_get_category(minicontrol_h handler, char **category) -{ - return __get_str_from_handler(handler, BUNDLE_KEY_CATEGORY, category); -} - -minicontrol_error_e _minictrl_handler_set_operation(minicontrol_h handler, const char *operation) -{ - return __set_str_to_handler(handler, BUNDLE_KEY_OPERATION, operation); -} - -minicontrol_error_e _minictrl_handler_get_operation(minicontrol_h handler, char **operation) -{ - return __get_str_from_handler(handler, BUNDLE_KEY_OPERATION, operation); -} - -minicontrol_error_e _minictrl_handler_set_priority(minicontrol_h handler, const char *priority) -{ - return __set_str_to_handler(handler, BUNDLE_KEY_PRIORITY, priority); -} - -minicontrol_error_e _minictrl_handler_get_priority(minicontrol_h handler, char **priority) -{ - return __get_str_from_handler(handler, BUNDLE_KEY_PRIORITY, priority); -} - -minicontrol_error_e _minictrl_handler_set_timestamp(minicontrol_h handler, time_t timestamp) -{ - if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE) { - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - if (timestamp > 0) { - return _bundle_set_byte(handler->data, BUNDLE_KEY_TIMESTAMP, (void *)×tamp, sizeof(time_t)); - } else { - bundle_del(handler->data, BUNDLE_KEY_TIMESTAMP); - } - - return MINICONTROL_ERROR_NONE; -} - -minicontrol_error_e _minictrl_handler_get_timestamp(minicontrol_h handler, time_t *timestamp) -{ - int ret = 0; - size_t ret_size = 0; - void *ret_value = NULL; - - if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE || timestamp == NULL) { - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - ret = bundle_get_byte(handler->data, BUNDLE_KEY_TIMESTAMP, &ret_value, &ret_size); - if (ret == 0 && ret_value != NULL && ret_size == sizeof(time_t)) { - *timestamp = *((time_t *)ret_value); - } else { - *timestamp = 0; - } - - return MINICONTROL_ERROR_NONE; -} - -minicontrol_error_e _minictrl_handler_set_pid(minicontrol_h handler) -{ - int pid = 0; - if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE) { - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - pid = getpid(); - if (pid > 0) { - return _bundle_set_byte(handler->data, BUNDLE_KEY_PID, (void *)&pid, sizeof(int)); - } else { - bundle_del(handler->data, BUNDLE_KEY_PID); - } - - return MINICONTROL_ERROR_NONE; -} - -minicontrol_error_e _minictrl_handler_get_pid(minicontrol_h handler, int *pid) -{ - int ret = 0; - size_t ret_size = 0; - void *ret_value = NULL; - - if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE || pid == NULL) { - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - ret = bundle_get_byte(handler->data, BUNDLE_KEY_PID, &ret_value, &ret_size); - if (ret == 0 && ret_value != NULL && ret_size == sizeof(int)) { - *pid = *((int *)ret_value); - } else { - *pid = 0; - } - - return MINICONTROL_ERROR_NONE; -} - -minicontrol_error_e _minictrl_handler_set_state(minicontrol_h handler, int state) -{ - if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE) { - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - if (state >= 0) { - return _bundle_set_byte(handler->data, BUNDLE_KEY_STATE, (void *)&state, sizeof(int)); - } else { - bundle_del(handler->data, BUNDLE_KEY_STATE); - } - - return MINICONTROL_ERROR_NONE; -} - -minicontrol_error_e _minictrl_handler_get_state(minicontrol_h handler, int *state) -{ - int ret = 0; - size_t ret_size = 0; - void *ret_value = NULL; - - if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE || state == NULL) { - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - ret = bundle_get_byte(handler->data, BUNDLE_KEY_STATE, &ret_value, &ret_size); - if (ret == 0 && ret_value != NULL && ret_size == sizeof(int)) { - *state = *((int *)ret_value); - } else { - *state = 0; - } - - return MINICONTROL_ERROR_NONE; -} - -minicontrol_error_e _minictrl_handler_add_extradata(minicontrol_h handler, const char *key, const char *value) -{ - if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE - || _handler_extradata_key_validation_check(key) != MINICONTROL_ERROR_NONE - || value == NULL) { - return MINICONTROL_ERROR_INVALID_PARAMETER;; - } - - return _bundle_set_str(handler->data, key, value); -} - -minicontrol_error_e _minictrl_handler_remove_extradata(minicontrol_h handler, const char *key) -{ - if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE - || _handler_extradata_key_validation_check(key) != MINICONTROL_ERROR_NONE) { - return MINICONTROL_ERROR_INVALID_PARAMETER;; - } - - if (bundle_del(handler->data, key)) { - return MINICONTROL_ERROR_NO_DATA; - } - - return MINICONTROL_ERROR_NONE; -} - -minicontrol_error_e _minictrl_handler_get_extradata(minicontrol_h handler, const char *key, char **value) -{ - const char *data_value; - - if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE - || _handler_extradata_key_validation_check(key) != MINICONTROL_ERROR_NONE - || value == NULL) { - return MINICONTROL_ERROR_INVALID_PARAMETER;; - } - - data_value = bundle_get_val(handler->data, key); - if (data_value == NULL) { - if (errno == ENOTSUP) { - return MINICONTROL_ERROR_BUNDLE; - } else { - return MINICONTROL_ERROR_NO_DATA; - } - } - - *value = strdup(data_value); - - return MINICONTROL_ERROR_NONE; -} - -minicontrol_error_e _minictrl_handler_get_raw_data(minicontrol_h handler, char **raw_data, int *length) -{ - if (handler == NULL || raw_data == NULL || length == NULL) { - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - if (handler->data != NULL) { - bundle_encode(handler->data, - (bundle_raw **) raw_data, length); - } else { - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - return MINICONTROL_ERROR_NONE; -} - -static void iterate_bundleforeach(const char *key,const int type, bundle_keyval_t *kv, void *data) -{ - switch(type) - { - case BUNDLE_TYPE_STR: - { - size_t size; - char *basic_val = NULL; - - bundle_keyval_get_basic_val(kv,(void *)&basic_val,&size); - ERR("Key: %s ---- Val: %s\n",key,basic_val); - - break; - } - case BUNDLE_TYPE_BYTE: - { - size_t size; - char *basic_val = NULL; - - bundle_keyval_get_basic_val(kv,(void *)&basic_val,&size); - ERR("Key: %s ---- Val: %d\n",key, *((int *)basic_val)); - - break; - } - default: - { - DBG("\n no match found"); - DBG("Key: %s is of type %d\n",key, type); - break; - } - } -} - -minicontrol_error_e _minictrl_handler_get_handler_from_raw_data(minicontrol_h *handler, char *raw_data, int length) -{ - if (_minictrl_handler_create(handler) == MINICONTROL_ERROR_NONE) { - (*handler)->data = bundle_decode((bundle_raw *)raw_data, length); - bundle_foreach((*handler)->data,(void *)iterate_bundleforeach,NULL); - } else { - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - return MINICONTROL_ERROR_NONE; -} diff --git a/src/minicontrol-internal.c b/src/minicontrol-internal.c old mode 100755 new mode 100644 index 9b0d1a6..25ceb4a --- a/src/minicontrol-internal.c +++ b/src/minicontrol-internal.c @@ -15,15 +15,14 @@ */ #include -#include #include #include +#include #include "minicontrol-error.h" #include "minicontrol-type.h" #include "minicontrol-internal.h" #include "minicontrol-log.h" -#include "minicontrol-handler.h" #define MINICTRL_DBUS_PATH "/org/tizen/minicontrol" #define MINICTRL_DBUS_INTERFACE "org.tizen.minicontrol.signal" @@ -53,7 +52,7 @@ int _minictrl_viewer_req_message_send(void) connection = dbus_bus_get(DBUS_BUS_SYSTEM, &err); if (!connection) { ERR("Fail to dbus_bus_get : %s", err.message); - ret = MINICONTROL_ERROR_DBUS; + ret = MINICONTROL_ERROR_IPC_FAILURE; goto release_n_return; } @@ -69,7 +68,7 @@ int _minictrl_viewer_req_message_send(void) dbus_ret = dbus_connection_send(connection, message, NULL); if (!dbus_ret) { ERR("fail to send dbus viewer req message"); - ret = MINICONTROL_ERROR_DBUS; + ret = MINICONTROL_ERROR_IPC_FAILURE; goto release_n_return; } @@ -109,7 +108,7 @@ int _minictrl_provider_proc_send(int type) conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err); if (!conn) { ERR("Fail to dbus_bus_get : %s", err.message); - ret = MINICONTROL_ERROR_DBUS; + ret = MINICONTROL_ERROR_IPC_FAILURE; goto release_n_return; } msg = dbus_message_new_signal(PROC_DBUS_OBJECT, // object name of the signal @@ -139,44 +138,30 @@ release_n_return: } -int _minictrl_provider_message_send(const char *sig_name, const char *svr_name, - unsigned int witdh, unsigned int height, - minicontrol_priority_e priority, - minicontrol_h handler) +int _minictrl_send_event(const char *signal_name, const char *minicontrol_name, int event, bundle *signal_arg) { DBusConnection *connection = NULL; DBusMessage *message = NULL; DBusError err; dbus_bool_t dbus_ret; + bundle_raw *serialized_arg = NULL; + unsigned int serialized_arg_length = 0; int ret = MINICONTROL_ERROR_NONE; - int handler_raw_data_len = 0; - char *handler_raw_data = NULL; - if (!sig_name) { - ERR("sig_name is NULL, invaild parameter"); + if (minicontrol_name == NULL) { + ERR("Invaild parameter"); return MINICONTROL_ERROR_INVALID_PARAMETER; } - if (!svr_name) { - ERR("svr_name is NULL, invaild parameter"); - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - if (handler != NULL) { - _minictrl_handler_get_raw_data(handler, &handler_raw_data, &handler_raw_data_len); - } - dbus_error_init(&err); connection = dbus_bus_get(DBUS_BUS_SYSTEM, &err); if (!connection) { ERR("Fail to dbus_bus_get : %s", err.message); - ret = MINICONTROL_ERROR_DBUS; + ret = MINICONTROL_ERROR_IPC_FAILURE; goto release_n_return; } - message = dbus_message_new_signal(MINICTRL_DBUS_PATH, - MINICTRL_DBUS_INTERFACE, - sig_name); + message = dbus_message_new_signal(MINICTRL_DBUS_PATH, MINICTRL_DBUS_INTERFACE, signal_name); if (!message) { ERR("fail to create dbus message"); @@ -184,34 +169,36 @@ int _minictrl_provider_message_send(const char *sig_name, const char *svr_name, goto release_n_return; } - - if (handler_raw_data != NULL && handler_raw_data_len > 0) { - dbus_ret = dbus_message_append_args(message, - DBUS_TYPE_STRING, &svr_name, - DBUS_TYPE_UINT32, &witdh, - DBUS_TYPE_UINT32, &height, - DBUS_TYPE_UINT32, &priority, - DBUS_TYPE_STRING, &handler_raw_data, - DBUS_TYPE_UINT32, &handler_raw_data_len, - DBUS_TYPE_INVALID); - } else { - dbus_ret = dbus_message_append_args(message, - DBUS_TYPE_STRING, &svr_name, - DBUS_TYPE_UINT32, &witdh, - DBUS_TYPE_UINT32, &height, - DBUS_TYPE_UINT32, &priority, - DBUS_TYPE_INVALID); + if (signal_arg != NULL) { + if (bundle_encode(signal_arg, &serialized_arg, (int*)&serialized_arg_length) != BUNDLE_ERROR_NONE) { + ERR("fail to serialize bundle argument"); + ret = MINICONTROL_ERROR_OUT_OF_MEMORY; + goto release_n_return; + } } + else { + serialized_arg = (bundle_raw*)strdup(""); + serialized_arg_length = 0; + } + + dbus_ret = dbus_message_append_args(message, + DBUS_TYPE_STRING, &minicontrol_name, + DBUS_TYPE_INT32, &event, + DBUS_TYPE_STRING, &serialized_arg, + DBUS_TYPE_UINT32, &serialized_arg_length, + DBUS_TYPE_INVALID); + if (!dbus_ret) { - ERR("fail to append name to dbus message : %s", svr_name); + ERR("fail to append arguments to dbus message : [%s][%d]", minicontrol_name, event); ret = MINICONTROL_ERROR_OUT_OF_MEMORY; goto release_n_return; } dbus_ret = dbus_connection_send(connection, message, NULL); + if (!dbus_ret) { - ERR("fail to send dbus message : %s", svr_name); - ret = MINICONTROL_ERROR_DBUS; + ERR("fail to send dbus message : %s", minicontrol_name); + ret = MINICONTROL_ERROR_IPC_FAILURE; goto release_n_return; } @@ -220,6 +207,9 @@ int _minictrl_provider_message_send(const char *sig_name, const char *svr_name, release_n_return: dbus_error_free(&err); + if (serialized_arg) + free(serialized_arg); + if (message) dbus_message_unref(message); @@ -229,8 +219,38 @@ release_n_return: return ret; } -static DBusHandlerResult _minictrl_signal_filter(DBusConnection *conn, - DBusMessage *msg, void *user_data) + +int _minictrl_provider_message_send(int event, const char *minicontrol_name, unsigned int witdh, unsigned int height, minicontrol_priority_e priority) +{ + bundle *event_arg_bundle = NULL; + int ret = MINICONTROL_ERROR_NONE; + char bundle_value_buffer[BUNDLE_BUFFER_LENGTH] = { 0, }; + + event_arg_bundle = bundle_create(); + + if (event_arg_bundle == NULL) { + ERR("fail to create a bundle instance"); + ret = MINICONTROL_ERROR_OUT_OF_MEMORY; + goto out; + } + + snprintf(bundle_value_buffer, BUNDLE_BUFFER_LENGTH, "%s", minicontrol_name); + + bundle_add_str(event_arg_bundle, "minicontrol_name", bundle_value_buffer); + bundle_add_byte(event_arg_bundle, "width", (void*)&witdh, sizeof(int)); + bundle_add_byte(event_arg_bundle, "height", (void*)&height, sizeof(int)); + bundle_add_byte(event_arg_bundle, "priority", (void*)&priority, sizeof(int)); + + _minictrl_send_event(MINICTRL_DBUS_SIG_TO_VIEWER, minicontrol_name, event, event_arg_bundle); + +out: + if (event_arg_bundle) + bundle_free(event_arg_bundle); + + return ret; +} + +static DBusHandlerResult _minictrl_signal_filter(DBusConnection *conn, DBusMessage *msg, void *user_data) { minictrl_sig_handle *handle = NULL; const char *interface; @@ -353,8 +373,7 @@ void _minictrl_dbus_sig_handle_dettach(minictrl_sig_handle *handle) dbus_error_init(&err); - dbus_connection_remove_filter(handle->conn, - _minictrl_signal_filter, handle); + dbus_connection_remove_filter(handle->conn, _minictrl_signal_filter, handle); snprintf(rule, 1024, "path='%s',type='signal',interface='%s',member='%s'", diff --git a/src/minicontrol-monitor.c b/src/minicontrol-monitor.c old mode 100755 new mode 100644 index 50f9609..2f94835 --- a/src/minicontrol-monitor.c +++ b/src/minicontrol-monitor.c @@ -20,20 +20,16 @@ #include "minicontrol-error.h" #include "minicontrol-internal.h" #include "minicontrol-monitor.h" +#include "minicontrol-viewer.h" #include "minicontrol-log.h" struct _minicontrol_monitor { - minictrl_sig_handle *start_sh; - minictrl_sig_handle *realize_sh; - minictrl_sig_handle *stop_sh; - minictrl_sig_handle *resize_sh; - minictrl_sig_handle *request_sh; + minictrl_sig_handle *event_sh; minicontrol_monitor_cb callback; - minicontrol_monitor_with_handler_cb callback_with_handler; void *user_data; }; -static struct _minicontrol_monitor *g_monitor_h; +static struct _minicontrol_monitor *g_monitor_h = NULL; static minicontrol_priority_e _int_to_priority(unsigned int value) { @@ -53,384 +49,74 @@ static minicontrol_priority_e _int_to_priority(unsigned int value) return priority; } -static int _provider_get_data_from_dbus_message( - DBusMessage *msg, char **name, - unsigned int *w, unsigned int *h, unsigned int *pri, - minicontrol_h *handler) +static void _sig_to_viewer_handler_cb(minicontrol_event_e event, const char *minicontrol_name, bundle *event_arg, void *data) { + minicontrol_action_e action; + int width = 0; + int height = 0; + int priority_from_signal = 0; + minicontrol_priority_e priority = 0; + size_t n_size; + + switch(event) { + case MINICONTROL_EVENT_START: + action = MINICONTROL_ACTION_START; + break; - DBusError err; - dbus_bool_t dbus_ret; - char *raw_data = NULL; - int raw_data_len = 0; - - if (msg != NULL && name != NULL && - w != NULL && h != NULL && pri != NULL && - handler != NULL) { - dbus_error_init(&err); - dbus_ret = dbus_message_get_args(msg, &err, - DBUS_TYPE_STRING, name, - DBUS_TYPE_UINT32, w, - DBUS_TYPE_UINT32, h, - DBUS_TYPE_UINT32, pri, - DBUS_TYPE_STRING, &raw_data, - DBUS_TYPE_UINT32, &raw_data_len, - DBUS_TYPE_INVALID); - if (!dbus_ret) { - ERR("fail to get args : %s", err.message); - if (*name == NULL) { - ERR("Failed to get a service name, give up"); - dbus_error_free(&err); - return MINICONTROL_ERROR_DBUS; - } - } - - if (raw_data != NULL && raw_data_len > 0) { - _minictrl_handler_get_handler_from_raw_data(handler, raw_data, raw_data_len); - } else { - ERR("failed to get handler from DBUS message"); - } - dbus_error_free(&err); - } - - return MINICONTROL_ERROR_NONE; -} - -static void _provider_start_cb(void *data, DBusMessage *msg) -{ - char *svr_name = NULL; - unsigned int w = 0; - unsigned int h = 0; - unsigned int pri = 0; - minicontrol_h handler = NULL; - minicontrol_priority_e priority; - - if (_provider_get_data_from_dbus_message(msg, &svr_name, &w, &h, &pri, &handler) != MINICONTROL_ERROR_NONE) { - ERR("fail to data from DBUS message"); - return ; - } - - priority = _int_to_priority(pri); - - if (g_monitor_h->callback) { - g_monitor_h->callback(MINICONTROL_ACTION_START, - svr_name, w, h, priority, - g_monitor_h->user_data); - } - if (g_monitor_h->callback_with_handler) { - g_monitor_h->callback_with_handler(MINICONTROL_ACTION_START, - svr_name, w, h, priority, - handler, - g_monitor_h->user_data); - } - - if (handler != NULL) { - _minictrl_handler_destroy(handler); - } -} - -static void _provider_realized_cb(void *data, DBusMessage *msg) -{ - char *svr_name = NULL; - unsigned int w = 0; - unsigned int h = 0; - unsigned int pri = 0; - minicontrol_h handler = NULL; - minicontrol_priority_e priority; - - if (_provider_get_data_from_dbus_message(msg, &svr_name, &w, &h, &pri, &handler) != MINICONTROL_ERROR_NONE) { - ERR("fail to data from DBUS message"); - return ; - } - - priority = _int_to_priority(pri); - - if (g_monitor_h->callback) { - g_monitor_h->callback(MINICONTROL_ACTION_REALIZE, - svr_name, w, h, priority, - g_monitor_h->user_data); - } - if (g_monitor_h->callback_with_handler) { - g_monitor_h->callback_with_handler(MINICONTROL_ACTION_REALIZE, - svr_name, w, h, priority, - handler, - g_monitor_h->user_data); - } - - if (handler != NULL) { - _minictrl_handler_destroy(handler); - } -} - -static void _provider_stop_cb(void *data, DBusMessage *msg) -{ - char *svr_name = NULL; - unsigned int w = 0; - unsigned int h = 0; - unsigned int pri = 0; - minicontrol_h handler = NULL; - minicontrol_priority_e priority; - - if (_provider_get_data_from_dbus_message(msg, &svr_name, &w, &h, &pri, &handler) != MINICONTROL_ERROR_NONE) { - ERR("fail to data from DBUS message"); - return ; - } - - priority = _int_to_priority(pri); - - if (g_monitor_h->callback) { - g_monitor_h->callback(MINICONTROL_ACTION_STOP, - svr_name, w, h, priority, - g_monitor_h->user_data); - } - if (g_monitor_h->callback_with_handler) { - g_monitor_h->callback_with_handler(MINICONTROL_ACTION_STOP, - svr_name, w, h, priority, - handler, - g_monitor_h->user_data); - } - - if (handler != NULL) { - _minictrl_handler_destroy(handler); - } -} - -static void _provider_resize_cb(void *data, DBusMessage *msg) -{ - char *svr_name = NULL; - unsigned int w = 0; - unsigned int h = 0; - unsigned int pri = 0; - minicontrol_h handler = NULL; - minicontrol_priority_e priority; - - if (_provider_get_data_from_dbus_message(msg, &svr_name, &w, &h, &pri, &handler) != MINICONTROL_ERROR_NONE) { - ERR("fail to data from DBUS message"); - return ; - } - - priority = _int_to_priority(pri); - - if (g_monitor_h->callback) { - g_monitor_h->callback(MINICONTROL_ACTION_RESIZE, - svr_name, w, h, priority, - g_monitor_h->user_data); - } - if (g_monitor_h->callback_with_handler) { - g_monitor_h->callback_with_handler(MINICONTROL_ACTION_RESIZE, - svr_name, w, h, priority, - handler, - g_monitor_h->user_data); - } + case MINICONTROL_EVENT_STOP: + action = MINICONTROL_ACTION_STOP; + break; - if (handler != NULL) { - _minictrl_handler_destroy(handler); - } -} + case MINICONTROL_EVENT_RESIZE: + action = MINICONTROL_ACTION_RESIZE; + break; -static void _provider_request_cb(void *data, DBusMessage *msg) -{ - char *svr_name = NULL; - unsigned int w = 0; - unsigned int h = 0; - unsigned int pri = 0; - minicontrol_h handler = NULL; - minicontrol_priority_e priority; + case MINICONTROL_EVENT_REQUEST_HIDE: + case MINICONTROL_EVENT_REQUEST_ANGLE: + action = MINICONTROL_ACTION_REQUEST; + break; - if (_provider_get_data_from_dbus_message(msg, &svr_name, &w, &h, &pri, &handler) != MINICONTROL_ERROR_NONE) { - ERR("fail to data from DBUS message"); - return ; + default: + WARN("Not supported event [%d]", event); + action = event; + break; } - priority = _int_to_priority(pri); - - if (g_monitor_h->callback) { - g_monitor_h->callback(MINICONTROL_ACTION_REQUEST, - svr_name, w, h, priority, - g_monitor_h->user_data); + if (action == MINICONTROL_ACTION_START || action == MINICONTROL_ACTION_RESIZE || action == MINICONTROL_ACTION_REQUEST) { + bundle_get_byte(event_arg, "width", (void*)&width, &n_size); + bundle_get_byte(event_arg, "height", (void*)&height, &n_size); + bundle_get_byte(event_arg, "priority", (void*)&priority_from_signal, &n_size); + priority = _int_to_priority(priority_from_signal); } - if (g_monitor_h->callback_with_handler) { - g_monitor_h->callback_with_handler(MINICONTROL_ACTION_REQUEST, - svr_name, w, h, priority, - handler, - g_monitor_h->user_data); + else { + priority = MINICONTROL_PRIORITY_LOW; } - if (handler != NULL) { - _minictrl_handler_destroy(handler); - } + g_monitor_h->callback(action, minicontrol_name, width, height, priority, g_monitor_h->user_data); } -EXPORT_API minicontrol_error_e minicontrol_monitor_start( - minicontrol_monitor_cb callback, void *data) +EXPORT_API minicontrol_error_e minicontrol_monitor_start(minicontrol_monitor_cb callback, void *data) { if (!callback) return MINICONTROL_ERROR_INVALID_PARAMETER; - if (!g_monitor_h) { - minictrl_sig_handle *start_sh; - minictrl_sig_handle *realize_sh; - minictrl_sig_handle *stop_sh; - minictrl_sig_handle *resize_sh; - minictrl_sig_handle *request_sh; - struct _minicontrol_monitor *monitor_h; - - start_sh = _minictrl_dbus_sig_handle_attach( - MINICTRL_DBUS_SIG_START, - _provider_start_cb, NULL); - if (!start_sh) { - ERR("fail to _minictrl_dbus_sig_handle_attach - %s", - MINICTRL_DBUS_SIG_START); - return MINICONTROL_ERROR_DBUS; - } - - realize_sh = _minictrl_dbus_sig_handle_attach( - MINICTRL_DBUS_SIG_REALIZE, - _provider_realized_cb, NULL); - if (!realize_sh) { - ERR("fail to _minictrl_dbus_sig_handle_attach - %s", - MINICTRL_DBUS_SIG_REALIZE); - return MINICONTROL_ERROR_DBUS; - } - - stop_sh = _minictrl_dbus_sig_handle_attach( - MINICTRL_DBUS_SIG_STOP, - _provider_stop_cb, NULL); - if (!stop_sh) { - ERR("fail to _minictrl_dbus_sig_handle_attach - %s", - MINICTRL_DBUS_SIG_STOP); - return MINICONTROL_ERROR_DBUS; - } - - resize_sh = _minictrl_dbus_sig_handle_attach( - MINICTRL_DBUS_SIG_RESIZE, - _provider_resize_cb, NULL); - if (!resize_sh) { - ERR("fail to _minictrl_dbus_sig_handle_attach - %s", - MINICTRL_DBUS_SIG_RESIZE); - return MINICONTROL_ERROR_DBUS; - } - - request_sh = _minictrl_dbus_sig_handle_attach( - MINICTRL_DBUS_SIG_REQUEST, - _provider_request_cb, NULL); - if (!request_sh) { - ERR("fail to _minictrl_dbus_sig_handle_attach - %s", - MINICTRL_DBUS_SIG_REQUEST); - return MINICONTROL_ERROR_DBUS; - } - - monitor_h = calloc(1, sizeof(struct _minicontrol_monitor)); - if (!monitor_h) { - ERR("fail to alloc monitor_h"); - _minictrl_dbus_sig_handle_dettach(start_sh); - _minictrl_dbus_sig_handle_dettach(realize_sh); - _minictrl_dbus_sig_handle_dettach(stop_sh); - _minictrl_dbus_sig_handle_dettach(resize_sh); - _minictrl_dbus_sig_handle_dettach(request_sh); - return MINICONTROL_ERROR_OUT_OF_MEMORY; - } - - monitor_h->start_sh = start_sh; - monitor_h->realize_sh = realize_sh; - monitor_h->stop_sh = stop_sh; - monitor_h->resize_sh = resize_sh; - monitor_h->request_sh = request_sh; - monitor_h->callback = NULL; - monitor_h->callback_with_handler = NULL; - g_monitor_h = monitor_h; - } - - g_monitor_h->callback = callback; - g_monitor_h->user_data = data; INFO("callback[%p], data[%p]", callback, data); - return _minictrl_viewer_req_message_send(); -} - -EXPORT_API minicontrol_error_e minicontrol_monitor_start_with_handler( - minicontrol_monitor_with_handler_cb callback, void *data) -{ - if (!callback) - return MINICONTROL_ERROR_INVALID_PARAMETER; - - if (!g_monitor_h) { - minictrl_sig_handle *start_sh; - minictrl_sig_handle *realize_sh; - minictrl_sig_handle *stop_sh; - minictrl_sig_handle *resize_sh; - minictrl_sig_handle *request_sh; - struct _minicontrol_monitor *monitor_h; - - start_sh = _minictrl_dbus_sig_handle_attach( - MINICTRL_DBUS_SIG_START, - _provider_start_cb, NULL); - if (!start_sh) { - ERR("fail to _minictrl_dbus_sig_handle_attach - %s", - MINICTRL_DBUS_SIG_START); - return MINICONTROL_ERROR_DBUS; - } - - realize_sh = _minictrl_dbus_sig_handle_attach( - MINICTRL_DBUS_SIG_REALIZE, - _provider_realized_cb, NULL); - if (!realize_sh) { - ERR("fail to _minictrl_dbus_sig_handle_attach - %s", - MINICTRL_DBUS_SIG_REALIZE); - return MINICONTROL_ERROR_DBUS; - } - - stop_sh = _minictrl_dbus_sig_handle_attach( - MINICTRL_DBUS_SIG_STOP, - _provider_stop_cb, NULL); - if (!stop_sh) { - ERR("fail to _minictrl_dbus_sig_handle_attach - %s", - MINICTRL_DBUS_SIG_STOP); - return MINICONTROL_ERROR_DBUS; - } - - resize_sh = _minictrl_dbus_sig_handle_attach( - MINICTRL_DBUS_SIG_RESIZE, - _provider_resize_cb, NULL); - if (!resize_sh) { - ERR("fail to _minictrl_dbus_sig_handle_attach - %s", - MINICTRL_DBUS_SIG_RESIZE); - return MINICONTROL_ERROR_DBUS; - } - - request_sh = _minictrl_dbus_sig_handle_attach( - MINICTRL_DBUS_SIG_REQUEST, - _provider_request_cb, NULL); - if (!request_sh) { - ERR("fail to _minictrl_dbus_sig_handle_attach - %s", - MINICTRL_DBUS_SIG_REQUEST); - return MINICONTROL_ERROR_DBUS; - } - - monitor_h = calloc(1, sizeof(struct _minicontrol_monitor)); - if (!monitor_h) { - ERR("fail to alloc monitor_h"); - _minictrl_dbus_sig_handle_dettach(start_sh); - _minictrl_dbus_sig_handle_dettach(realize_sh); - _minictrl_dbus_sig_handle_dettach(stop_sh); - _minictrl_dbus_sig_handle_dettach(resize_sh); - _minictrl_dbus_sig_handle_dettach(request_sh); - return MINICONTROL_ERROR_OUT_OF_MEMORY; - } + if (g_monitor_h) { + ERR("Already started"); + return MINICONTROL_ERROR_UNKNOWN; + } - monitor_h->start_sh = start_sh; - monitor_h->realize_sh = realize_sh; - monitor_h->stop_sh = stop_sh; - monitor_h->resize_sh = resize_sh; - monitor_h->request_sh = request_sh; - monitor_h->callback = NULL; - monitor_h->callback_with_handler = NULL; - g_monitor_h = monitor_h; + g_monitor_h = malloc(sizeof(struct _minicontrol_monitor)); + if (g_monitor_h == NULL) { + ERR("fail to alloc monitor_h"); + return MINICONTROL_ERROR_OUT_OF_MEMORY; } - g_monitor_h->callback_with_handler = callback; + minicontrol_viewer_set_event_cb(_sig_to_viewer_handler_cb, data); + + g_monitor_h->callback = callback; g_monitor_h->user_data = data; - INFO("callback[%p], data[%p]", callback, data); return _minictrl_viewer_req_message_send(); } @@ -440,24 +126,10 @@ EXPORT_API minicontrol_error_e minicontrol_monitor_stop(void) if (!g_monitor_h) return MINICONTROL_ERROR_NONE; - if (g_monitor_h->start_sh) - _minictrl_dbus_sig_handle_dettach(g_monitor_h->start_sh); - - if (g_monitor_h->realize_sh) - _minictrl_dbus_sig_handle_dettach(g_monitor_h->realize_sh); - - if (g_monitor_h->stop_sh) - _minictrl_dbus_sig_handle_dettach(g_monitor_h->stop_sh); - - if (g_monitor_h->resize_sh) - _minictrl_dbus_sig_handle_dettach(g_monitor_h->resize_sh); - - if (g_monitor_h->request_sh) - _minictrl_dbus_sig_handle_dettach(g_monitor_h->request_sh); + minicontrol_viewer_unset_event_cb(); free(g_monitor_h); g_monitor_h = NULL; return MINICONTROL_ERROR_NONE; } - diff --git a/src/minicontrol-provider.c b/src/minicontrol-provider.c old mode 100755 new mode 100644 index bda4b06..3a45721 --- a/src/minicontrol-provider.c +++ b/src/minicontrol-provider.c @@ -15,13 +15,14 @@ */ #include +#include #include "minicontrol-error.h" #include "minicontrol-type.h" #include "minicontrol-internal.h" #include "minicontrol-provider.h" +#include "minicontrol-provider-internal.h" #include "minicontrol-log.h" -#include "minicontrol-handler.h" #define MINICTRL_PRIORITY_SUFFIX_TOP "__minicontrol_top" #define MINICTRL_PRIORITY_SUFFIX_LOW "__minicontrol_low" @@ -32,54 +33,39 @@ enum { MINICTRL_STATE_RUNNING, }; -struct _provider_data { +struct _minicontrol_provider { char *name; int state; - minicontrol_priority_e priority; Evas_Object *obj; - minictrl_sig_handle *sh; - minicontrol_h handler; + minictrl_sig_handle *running_sh; + minictrl_sig_handle *event_sh; + minicontrol_event_cb event_callback; }; -static void __provider_data_free(struct _provider_data *pd) +static void _minictrl_win_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _minictrl_win_hide_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _minictrl_win_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _minictrl_win_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); + +static void __minicontrol_provider_free(struct _minicontrol_provider *pd) { if (pd) { if (pd->name) free(pd->name); - if (pd->sh) - _minictrl_dbus_sig_handle_dettach(pd->sh); + if (pd->running_sh) + _minictrl_dbus_sig_handle_dettach(pd->running_sh); - if (pd->handler) - _minictrl_handler_destroy(pd->handler); + if (pd->event_sh) + _minictrl_dbus_sig_handle_dettach(pd->event_sh); free(pd); } } -static int __str_has_suffix(const char *str, const char *suffix) -{ - int str_len; - int suffix_len; - - if (!str) - return -1; - - if (!suffix) - return -1; - - str_len = strlen (str); - suffix_len = strlen (suffix); - - if (str_len < suffix_len) - return -1; - - return strcmp(str + str_len - suffix_len, suffix); -} - static void _running_req_cb(void *data, DBusMessage *msg) { - struct _provider_data *pd; + struct _minicontrol_provider *pd; if (!data) { ERR("data is NULL"); @@ -91,14 +77,188 @@ static void _running_req_cb(void *data, DBusMessage *msg) Evas_Coord w = 0; Evas_Coord h = 0; evas_object_geometry_get(pd->obj, NULL, NULL, &w, &h); - _minictrl_provider_message_send(MINICTRL_DBUS_SIG_START, - pd->name, w, h, pd->priority, pd->handler); + _minictrl_provider_message_send(MINICONTROL_EVENT_START, pd->name, w, h, 0); } } -static int minicontrol_win_start(Evas_Object *mincontrol) +static void _sig_to_provider_handler_cb(void *data, DBusMessage *msg) +{ + struct _minicontrol_provider *pd; + DBusError err; + char *minicontrol_name = NULL; + minicontrol_viewer_event_e event; + dbus_bool_t dbus_ret; + bundle *event_arg_bundle = NULL; + bundle_raw *serialized_arg = NULL; + unsigned int serialized_arg_length = 0; + + if (!data) { + ERR("data is NULL"); + return; + } + pd = data; + + dbus_error_init(&err); /* Does not allocate any memory. the error only needs to be freed if it is set at some point. */ + + dbus_ret = dbus_message_get_args(msg, &err, + DBUS_TYPE_STRING, &minicontrol_name, + DBUS_TYPE_INT32, &event, + DBUS_TYPE_STRING, &serialized_arg, + DBUS_TYPE_UINT32, &serialized_arg_length, + DBUS_TYPE_INVALID); + + if (!dbus_ret) { + ERR("fail to get args : %s", err.message); + dbus_error_free(&err); + return; + } + + INFO("minicontrol_name[%s] event[%d] pd->name[%s]", minicontrol_name, event, pd->name); + + if (minicontrol_name && pd->name && strcmp(minicontrol_name, pd->name) == 0) { + event_arg_bundle = bundle_decode(serialized_arg, serialized_arg_length); + /* event argument can be null */ + + if (event == MINICONTROL_VIEWER_EVENT_SHOW) { + Evas_Coord width; + Evas_Coord height; + evas_object_geometry_get (pd->obj, NULL, NULL, &width, &height); + INFO("width[%d] height[%d]", width, height); + _minictrl_provider_message_send(MINICONTROL_EVENT_RESIZE, pd->name, width, height, 0); + } + + if (pd->event_callback) + pd->event_callback(event, event_arg_bundle); + + if (event_arg_bundle) + bundle_free(event_arg_bundle); + } +} + + + +static char *_minictrl_create_name(const char *name) +{ + char *buf; + int size = 0; + + if (!name) { + ERR("name is NULL, invaild parameter"); + set_last_result(MINICONTROL_ERROR_INVALID_PARAMETER); + return NULL; + } + + size = snprintf(NULL, 0, "[%s]", name) + 1; + buf = (char *)malloc(sizeof(char) * size); + if (!buf) { + ERR("fail to alloc buf"); + set_last_result(MINICONTROL_ERROR_OUT_OF_MEMORY); + return NULL; + } + + snprintf(buf, size, "[%s]", name); + + return buf; +} + +static void _access_changed_cb(void *data, Evas_Object *obj, void *event_info) +{ + Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj)); + if (ee != NULL) { + if (elm_config_access_get()) { + /* TODO : Check this API is supported + ecore_evas_extn_socket_events_block_set(ee, EINA_TRUE); + */ + } + else { + /* TODO : Check this API is supported + ecore_evas_extn_socket_events_block_set(ee, EINA_FALSE); + */ + } + } +} + + +EXPORT_API Evas_Object* minicontrol_create_window(const char *name, minicontrol_target_viewer_e target_viewer, minicontrol_event_cb event_callback) +{ + Evas_Object *win = NULL; + char *name_inter = NULL; + struct _minicontrol_provider *pd; + + if (!name) { + ERR("invalid parameter"); + set_last_result(MINICONTROL_ERROR_INVALID_PARAMETER); + return NULL; + } + + win = elm_win_add(NULL, "minicontrol", ELM_WIN_SOCKET_IMAGE); + if (!win) { + ERR("elm_win_add failed"); + set_last_result(MINICONTROL_ERROR_ELM_FAILURE); + return NULL; + } + + if (elm_config_access_get()) { + Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(win)); + + if (ee != NULL) { + /* TODO : Check this API is supported + ecore_evas_extn_socket_events_block_set(ee, EINA_TRUE); + */ + } + + } + evas_object_smart_callback_add(win, "access,changed", _access_changed_cb, NULL); + + name_inter = _minictrl_create_name(name); + if (!name_inter) { + ERR("Fail to create name_inter for : %s", name); + evas_object_del(win); + return NULL; + } + + if (!elm_win_socket_listen(win, name_inter, 0, EINA_TRUE)) { + ERR("Fail to elm win socket listen"); + set_last_result(MINICONTROL_ERROR_ELM_FAILURE); + evas_object_del(win); + free(name_inter); + return NULL; + } + + pd = malloc(sizeof(struct _minicontrol_provider)); + if (!pd) { + ERR("Fail to alloc memory"); + set_last_result(MINICONTROL_ERROR_OUT_OF_MEMORY); + evas_object_del(win); + free(name_inter); + return NULL; + + } + memset(pd, 0x00, sizeof(struct _minicontrol_provider)); + pd->name = name_inter; + pd->state = MINICTRL_STATE_READY; + pd->obj = win; + + evas_object_data_set(win ,MINICTRL_DATA_KEY,pd); + + elm_win_autodel_set(win, EINA_TRUE); + + evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _minictrl_win_del_cb, pd); + evas_object_event_callback_add(win, EVAS_CALLBACK_SHOW, _minictrl_win_show_cb, pd); + evas_object_event_callback_add(win, EVAS_CALLBACK_HIDE, _minictrl_win_hide_cb, pd); + evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _minictrl_win_resize_cb, pd); + + pd->running_sh = _minictrl_dbus_sig_handle_attach(MINICTRL_DBUS_SIG_RUNNING_REQ, _running_req_cb, pd); + pd->event_sh = _minictrl_dbus_sig_handle_attach(MINICTRL_DBUS_SIG_TO_PROVIDER, _sig_to_provider_handler_cb, pd); + pd->event_callback = event_callback; + + INFO("new minicontrol created - %s", pd->name); + return win; +} + +EXPORT_API int minicontrol_send_event(Evas_Object *mincontrol, minicontrol_provider_event_e event, bundle *event_arg) { - struct _provider_data *pd; + struct _minicontrol_provider *pd; int ret = MINICONTROL_ERROR_NONE; if (!mincontrol) { @@ -117,23 +277,16 @@ static int minicontrol_win_start(Evas_Object *mincontrol) return MINICONTROL_ERROR_INVALID_PARAMETER; } - if (pd->state != MINICTRL_STATE_RUNNING) { - Evas_Coord w = 0; - Evas_Coord h = 0; - pd->state = MINICTRL_STATE_RUNNING; - - evas_object_geometry_get(mincontrol, NULL, NULL, &w, &h); - _minictrl_provider_proc_send(MINICONTROL_DBUS_PROC_EXCLUDE); - ret = _minictrl_provider_message_send(MINICTRL_DBUS_SIG_START, - pd->name, w, h, pd->priority, pd->handler); + if (pd->state == MINICTRL_STATE_RUNNING) { + ret = _minictrl_send_event(MINICTRL_DBUS_SIG_TO_VIEWER, pd->name, event, event_arg); } return ret; } -static int minicontrol_win_realize(Evas_Object *mincontrol) +static int minicontrol_win_start(Evas_Object *mincontrol) { - struct _provider_data *pd; + struct _minicontrol_provider *pd; int ret = MINICONTROL_ERROR_NONE; if (!mincontrol) { @@ -152,22 +305,22 @@ static int minicontrol_win_realize(Evas_Object *mincontrol) return MINICONTROL_ERROR_INVALID_PARAMETER; } - Evas_Coord w = 0; - Evas_Coord h = 0; if (pd->state != MINICTRL_STATE_RUNNING) { + Evas_Coord w = 0; + Evas_Coord h = 0; pd->state = MINICTRL_STATE_RUNNING; - } - evas_object_geometry_get(mincontrol, NULL, NULL, &w, &h); - ret = _minictrl_provider_message_send(MINICTRL_DBUS_SIG_REALIZE, - pd->name, w, h, pd->priority, pd->handler); + evas_object_geometry_get(mincontrol, NULL, NULL, &w, &h); + _minictrl_provider_proc_send(MINICONTROL_DBUS_PROC_EXCLUDE); + ret = _minictrl_provider_message_send(MINICONTROL_EVENT_START, pd->name, w, h, 0); + } return ret; } static int minicontrol_win_stop(Evas_Object *mincontrol) { - struct _provider_data *pd; + struct _minicontrol_provider *pd; int ret = MINICONTROL_ERROR_NONE; if (!mincontrol) { @@ -188,71 +341,40 @@ static int minicontrol_win_stop(Evas_Object *mincontrol) if (pd->state != MINICTRL_STATE_READY) { pd->state = MINICTRL_STATE_READY; _minictrl_provider_proc_send(MINICONTROL_DBUS_PROC_INCLUDE); - ret = _minictrl_provider_message_send(MINICTRL_DBUS_SIG_STOP, - pd->name, 0, 0, pd->priority, pd->handler); + ret = _minictrl_provider_message_send(MINICONTROL_EVENT_STOP, pd->name, 0, 0, 0); } return ret; } -static void _minictrl_win_del(void *data, Evas *e, - Evas_Object *obj, void *event_info) +static void _minictrl_win_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) { - struct _provider_data *pd = NULL; + struct _minicontrol_provider *pd = NULL; minicontrol_win_stop(obj); pd = evas_object_data_get(obj, MINICTRL_DATA_KEY); - __provider_data_free(pd); + __minicontrol_provider_free(pd); evas_object_data_set(obj, MINICTRL_DATA_KEY, NULL); } -static void _minictrl_win_hide(void *data, Evas *e, - Evas_Object *obj, void *event_info) +static void _minictrl_win_hide_cb(void *data, Evas *e, + Evas_Object *obj, void *event_info) { minicontrol_win_stop(obj); } -static void _minictrl_win_show(void *data, Evas *e, - Evas_Object *obj, void *event_info) +static void _minictrl_win_show_cb(void *data, Evas *e, + Evas_Object *obj, void *event_info) { minicontrol_win_start(obj); } -static void _minictrl_win_realize(void *data, Evas *e, - Evas_Object *obj, void *event_info) -{ - struct _provider_data *pd; - - if (!data) { - ERR("data is NULL, invaild parameter"); - return; - } - pd = data; - - if (!pd->obj) { - ERR("minicontrol object is NULL, invalid parameter"); - return; - } - - Evas *win_e = evas_object_evas_get(pd->obj); - if (win_e != NULL) { - evas_event_callback_del(win_e, EVAS_CALLBACK_RENDER_POST, - _minictrl_win_realize); - } - - minicontrol_win_realize(pd->obj); - - if (pd->handler != NULL) { - _minictrl_handler_set_state(pd->handler, 1); - } -} - -static void _minictrl_win_resize(void *data, Evas *e, - Evas_Object *obj, void *event_info) +static void _minictrl_win_resize_cb(void *data, Evas *e, + Evas_Object *obj, void *event_info) { - struct _provider_data *pd; + struct _minicontrol_provider *pd; if (!data) { ERR("data is NULL, invaild parameter"); @@ -265,219 +387,94 @@ static void _minictrl_win_resize(void *data, Evas *e, Evas_Coord h = 0; evas_object_geometry_get(obj, NULL, NULL, &w, &h); - _minictrl_provider_message_send(MINICTRL_DBUS_SIG_RESIZE, - pd->name, w, h, pd->priority, pd->handler); + _minictrl_provider_message_send(MINICONTROL_EVENT_RESIZE, pd->name, w, h, 0); } } -static char *_minictrl_create_name(const char *name) -{ - char *buf; - int size = 0; - - if (!name) { - ERR("name is NULL, invaild parameter"); - return NULL; - } - - size = snprintf(NULL, 0, "[%s]", name) + 1; - buf = (char *)malloc(sizeof(char) * size); - if (!buf) { - ERR("fail to alloc buf"); - return NULL; - } - - snprintf(buf, size, "[%s]", name); - - return buf; -} - -static minicontrol_priority_e _minictrl_get_priroty_by_name(const char *name) -{ - minicontrol_priority_e priority = MINICONTROL_PRIORITY_MIDDLE; - - if (!__str_has_suffix(name, MINICTRL_PRIORITY_SUFFIX_TOP)) - priority = MINICONTROL_PRIORITY_TOP; - else if (!__str_has_suffix(name, MINICTRL_PRIORITY_SUFFIX_LOW)) - priority = MINICONTROL_PRIORITY_LOW; - - return priority; -} - EXPORT_API Evas_Object *minicontrol_win_add(const char *name) { - minicontrol_h handler = NULL; Evas_Object *win = NULL; - - if (_minictrl_handler_create(&handler) == MINICONTROL_ERROR_NONE) { - if (_minictrl_handler_set_service_name(handler, name) != MINICONTROL_ERROR_NONE) { - ERR("failed to service name"); - _minictrl_handler_destroy(handler); - return NULL; - } - if (_minictrl_handler_set_timestamp(handler, time(NULL)) != MINICONTROL_ERROR_NONE) { - ERR("failed to set timestamp"); - } - if (_minictrl_handler_set_priority(handler, MINICONTROL_HDL_PRIORITY_LV3) != MINICONTROL_ERROR_NONE) { - ERR("failed to set priority"); - } - } else { - ERR("Failed to create minicontrol handler"); - return NULL; - } - - win = minicontrol_win_add_by_handler(handler); - _minictrl_handler_destroy(handler); - - return win; -} - -EXPORT_API Evas_Object *minicontrol_win_add_by_handler(minicontrol_h handler) -{ - Evas_Object *win = NULL; - char *name = NULL; char *name_inter = NULL; - char *priority = NULL; - struct _provider_data *pd; - time_t timestamp_value = 0; + struct _minicontrol_provider *pd; - if (_minictrl_handler_check_validation(handler) != MINICONTROL_ERROR_NONE) { - ERR("handler is invalid, invaild parameter"); - return NULL; - } + INFO("minicontrol_win_add [%s]", name); - _minictrl_handler_get_service_name(handler, &name); - if (name == NULL) { - ERR("service name cannot be NULL"); + if (!name) { + ERR("name is null"); return NULL; } - _minictrl_handler_get_timestamp(handler, ×tamp_value); - if (timestamp_value == 0) { - if (_minictrl_handler_set_timestamp(handler, time(NULL)) != MINICONTROL_ERROR_NONE) { - ERR("failed to set timestamp"); - } - } - _minictrl_handler_get_priority(handler, &priority); - if (priority == NULL) { - if (_minictrl_handler_set_priority(handler, MINICONTROL_HDL_PRIORITY_LV3) != MINICONTROL_ERROR_NONE) { - ERR("failed to set priority"); - } - } else { - free(priority); - } win = elm_win_add(NULL, "minicontrol", ELM_WIN_SOCKET_IMAGE); if (!win) { - free(name); + ERR("elm_win_add returns null for [%s]", name); return NULL; } + if (elm_config_access_get()) { + Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(win)); + + if (ee != NULL) { + /* TODO : Check this API is supported + ecore_evas_extn_socket_events_block_set(ee, EINA_TRUE); + */ + } + + } + evas_object_smart_callback_add(win, "access,changed", _access_changed_cb, NULL); + name_inter = _minictrl_create_name(name); if (!name_inter) { + ERR("Fail to create name_inter for : %s", name); - free(name); evas_object_del(win); return NULL; } if (!elm_win_socket_listen(win, name_inter, 0, EINA_TRUE)) { ERR("Fail to elm win socket listen"); - free(name); evas_object_del(win); free(name_inter); return NULL; } - pd = malloc(sizeof(struct _provider_data)); + pd = malloc(sizeof(struct _minicontrol_provider)); if (!pd) { ERR("Fail to alloc memory"); - free(name); evas_object_del(win); free(name_inter); return NULL; } - memset(pd, 0x00, sizeof(struct _provider_data)); + memset(pd, 0x00, sizeof(struct _minicontrol_provider)); pd->name = name_inter; pd->state = MINICTRL_STATE_READY; pd->obj = win; - pd->priority = _minictrl_get_priroty_by_name(name); - - if (_minictrl_handler_clone(handler, &(pd->handler)) != MINICONTROL_ERROR_NONE) { - ERR("Fail to clone handler"); - free(name); - evas_object_del(win); - free(name_inter); - free(pd); - return NULL; - } evas_object_data_set(win ,MINICTRL_DATA_KEY,pd); elm_win_autodel_set(win, EINA_TRUE); - evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, - _minictrl_win_del, pd); - - evas_object_event_callback_add(win, EVAS_CALLBACK_SHOW, - _minictrl_win_show, pd); + evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _minictrl_win_del_cb, pd); + evas_object_event_callback_add(win, EVAS_CALLBACK_SHOW, _minictrl_win_show_cb, pd); + evas_object_event_callback_add(win, EVAS_CALLBACK_HIDE, _minictrl_win_hide_cb, pd); + evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _minictrl_win_resize_cb, pd); - evas_object_event_callback_add(win, EVAS_CALLBACK_HIDE, - _minictrl_win_hide, pd); - - evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, - _minictrl_win_resize, pd); - - Evas *win_e = evas_object_evas_get(win); - if (win_e != NULL) { - evas_event_callback_add(win_e, EVAS_CALLBACK_RENDER_POST, - _minictrl_win_realize, pd); - } - - pd->sh = _minictrl_dbus_sig_handle_attach(MINICTRL_DBUS_SIG_RUNNING_REQ, - _running_req_cb, pd); + pd->running_sh = _minictrl_dbus_sig_handle_attach(MINICTRL_DBUS_SIG_RUNNING_REQ, _running_req_cb, pd); INFO("new minicontrol created - %s", pd->name); - - free(name); - return win; } -EXPORT_API minicontrol_error_e minicontrol_win_handler_get(Evas_Object *mincontrol, minicontrol_h *handler) -{ - if (!mincontrol) { - ERR("invaild mincontrol object"); - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - if (!handler) { - ERR("invaild mincontrol handler"); - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - struct _provider_data *pd = evas_object_data_get(mincontrol, MINICTRL_DATA_KEY); - if (pd != NULL) { - *handler = pd->handler; - } else { - return MINICONTROL_ERROR_NO_DATA; - } - - return MINICONTROL_ERROR_NONE; -} - -EXPORT_API minicontrol_error_e minicontrol_win_handler_update(Evas_Object *mincontrol, minicontrol_h handler) +EXPORT_API int minicontrol_request(Evas_Object *mincontrol, minicontrol_request_e request) { - struct _provider_data *pd; + struct _minicontrol_provider *pd; int ret = MINICONTROL_ERROR_NONE; + minicontrol_event_e event; if (!mincontrol) { ERR("mincontrol is NULL, invaild parameter"); return MINICONTROL_ERROR_INVALID_PARAMETER; } - if (_minictrl_handler_check_validation(handler) != MINICONTROL_ERROR_NONE) { - ERR("handler is invalid, invaild parameter"); - return MINICONTROL_ERROR_INVALID_PARAMETER; - } pd = evas_object_data_get(mincontrol, MINICTRL_DATA_KEY); if (!pd) { @@ -490,51 +487,33 @@ EXPORT_API minicontrol_error_e minicontrol_win_handler_update(Evas_Object *minco return MINICONTROL_ERROR_INVALID_PARAMETER; } - if (pd->handler != handler) { - if (pd->handler != NULL) { - _minictrl_handler_destroy(pd->handler); - pd->handler = NULL; - } - if (_minictrl_handler_clone(handler, &(pd->handler)) != MINICONTROL_ERROR_NONE) { - ERR("failed to clone a minicontrol handler"); - return MINICONTROL_ERROR_OUT_OF_MEMORY; + if (pd->state == MINICTRL_STATE_RUNNING) { + switch(request) { + case MINICONTROL_REQ_HIDE_VIEWER : + event = MINICONTROL_EVENT_REQUEST_HIDE; + break; + + case MINICONTROL_REQ_REPORT_VIEWER_ANGLE : + event = MINICONTROL_EVENT_REQUEST_ANGLE; + break; + + case MINICONTROL_REQ_FREEZE_SCROLL_VIEWER : + case MINICONTROL_REQ_UNFREEZE_SCROLL_VIEWER : + case MINICONTROL_REQ_ROTATE_PROVIDER : + WARN("Could be not supported [%d]", request); + event = request; + break; + + case MINICONTROL_REQ_NONE : + default : + ERR("Not supported request[%d]", request); + ret = MINICONTROL_ERROR_NOT_SUPPORTED; + goto out; } - } - if (pd->state == MINICTRL_STATE_RUNNING) { - ret = _minictrl_provider_message_send(MINICTRL_DBUS_SIG_REQUEST, - pd->name, MINICONTROL_REQ_UPDATE_HANDLER, MINICONTROL_REQ_UPDATE_HANDLER - , pd->priority, pd->handler); + _minictrl_send_event(MINICTRL_DBUS_SIG_TO_VIEWER, pd->name, event, NULL); } - +out: return ret; } -EXPORT_API minicontrol_error_e minicontrol_request(Evas_Object *mincontrol, minicontrol_request_e request) -{ - struct _provider_data *pd; - int ret = MINICONTROL_ERROR_NONE; - - if (!mincontrol) { - ERR("mincontrol is NULL, invaild parameter"); - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - pd = evas_object_data_get(mincontrol, MINICTRL_DATA_KEY); - if (!pd) { - ERR("pd is NULL, invaild parameter"); - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - if (!pd->name) { - ERR("pd name is NULL, invaild parameter"); - return MINICONTROL_ERROR_INVALID_PARAMETER; - } - - if (pd->state == MINICTRL_STATE_RUNNING) { - ret = _minictrl_provider_message_send(MINICTRL_DBUS_SIG_REQUEST, - pd->name, request, request, pd->priority, pd->handler); - } - - return ret; -} diff --git a/src/minicontrol-viewer.c b/src/minicontrol-viewer.c old mode 100755 new mode 100644 index 5e6e5dd..4d024f4 --- a/src/minicontrol-viewer.c +++ b/src/minicontrol-viewer.c @@ -20,67 +20,188 @@ #include "minicontrol-internal.h" #include "minicontrol-type.h" #include "minicontrol-viewer.h" +#include "minicontrol-viewer-internal.h" #include "minicontrol-log.h" #define MINICTRL_PLUG_DATA_KEY "__minictrl_plug_name" -static void _minictrl_plug_server_del(Ecore_Evas *ee) +struct _minicontrol_viewer { + minictrl_sig_handle *event_sh; + minicontrol_viewer_event_cb callback; + void *user_data; +}; + +static struct _minicontrol_viewer *g_minicontrol_viewer_h = NULL; + +EXPORT_API int minicontrol_viewer_send_event(const char *minicontrol_name, minicontrol_viewer_event_e event, bundle *event_arg) +{ + int ret = MINICONTROL_ERROR_NONE; + + if (minicontrol_name == NULL) { + ERR("appid is NULL, invaild parameter"); + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + ret = _minictrl_send_event(MINICTRL_DBUS_SIG_TO_PROVIDER, minicontrol_name, event, event_arg); + + return ret; +} + + +static void _sig_to_viewer_handler_cb(void *data, DBusMessage *msg) { - char *svr_name = NULL; + DBusError err; + char *minicontrol_name = NULL; + minicontrol_event_e event; + dbus_bool_t dbus_ret; + bundle *event_arg_bundle = NULL; + bundle_raw *serialized_arg = NULL; + unsigned int serialized_arg_length = 0; + + dbus_error_init(&err); /* Does not allocate any memory. the error only needs to be freed if it is set at some point. */ - svr_name = ecore_evas_data_get(ee, MINICTRL_PLUG_DATA_KEY); - if (!svr_name) { - ERR("fail to get svr_name"); + dbus_ret = dbus_message_get_args(msg, &err, + DBUS_TYPE_STRING, &minicontrol_name, + DBUS_TYPE_INT32, &event, + DBUS_TYPE_STRING, &serialized_arg, + DBUS_TYPE_UINT32, &serialized_arg_length, + DBUS_TYPE_INVALID); + + if (!dbus_ret) { + ERR("fail to get args : %s", err.message); + dbus_error_free(&err); return; } - INFO("server - %s is deleted", svr_name); + if (serialized_arg_length != 0) { + event_arg_bundle = bundle_decode(serialized_arg, serialized_arg_length); - /* send message to remve plug */ - _minictrl_provider_message_send(MINICTRL_DBUS_SIG_STOP, - svr_name, 0, 0, - MINICONTROL_PRIORITY_LOW, NULL); - _minictrl_provider_proc_send(MINICONTROL_DBUS_PROC_INCLUDE); + if (event_arg_bundle == NULL) { + ERR("fail to deserialize arguments"); + return; + } + } + + if (g_minicontrol_viewer_h->callback) + g_minicontrol_viewer_h->callback(event, minicontrol_name, event_arg_bundle, g_minicontrol_viewer_h->user_data); + + bundle_free(event_arg_bundle); + dbus_error_free(&err); } -static void _minictrl_plug_del(void *data, Evas *e, - Evas_Object *obj, void *event_info) + +EXPORT_API int minicontrol_viewer_set_event_cb(minicontrol_viewer_event_cb callback, void *data) { - Ecore_Evas *ee = NULL; - char *svr_name = NULL; + if (!callback) { + ERR("MINICONTROL_ERROR_INVALID_PARAMETER"); + return MINICONTROL_ERROR_INVALID_PARAMETER; + } - ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj)); - if (!ee) + INFO("g_minicontrol_viewer_h [%p]", g_minicontrol_viewer_h); + + if (g_minicontrol_viewer_h == NULL) { + minictrl_sig_handle *event_sh; + struct _minicontrol_viewer *minicontrol_viewer_h; + + event_sh = _minictrl_dbus_sig_handle_attach(MINICTRL_DBUS_SIG_TO_VIEWER, _sig_to_viewer_handler_cb, NULL); + if (!event_sh) { + ERR("fail to _minictrl_dbus_sig_handle_attach - %s", MINICTRL_DBUS_SIG_TO_VIEWER); + return MINICONTROL_ERROR_IPC_FAILURE; + } + + minicontrol_viewer_h = malloc(sizeof(struct _minicontrol_viewer)); + if (!minicontrol_viewer_h) { + ERR("fail to alloc minicontrol_viewer_h"); + _minictrl_dbus_sig_handle_dettach(event_sh); + return MINICONTROL_ERROR_OUT_OF_MEMORY; + } + + minicontrol_viewer_h->event_sh = event_sh; + g_minicontrol_viewer_h = minicontrol_viewer_h; + } + + g_minicontrol_viewer_h->callback = callback; + g_minicontrol_viewer_h->user_data = data; + INFO("callback[%p], data[%p]", callback, data); + + return _minictrl_viewer_req_message_send(); +} + +EXPORT_API int minicontrol_viewer_unset_event_cb(void) +{ + if (!g_minicontrol_viewer_h) + return MINICONTROL_ERROR_NONE; + + if (g_minicontrol_viewer_h->event_sh) + _minictrl_dbus_sig_handle_dettach(g_minicontrol_viewer_h->event_sh); + + free(g_minicontrol_viewer_h); + g_minicontrol_viewer_h = NULL; + + return MINICONTROL_ERROR_NONE; +} + +static void _minictrl_plug_server_del(Ecore_Evas *ee) +{ + char *minicontrol_name = NULL; + + minicontrol_name = ecore_evas_data_get(ee, MINICTRL_PLUG_DATA_KEY); + if (!minicontrol_name) { + ERR("fail to get minicontrol_name"); return; + } - svr_name = ecore_evas_data_get(ee, MINICTRL_PLUG_DATA_KEY); - if (svr_name) - free(svr_name); + INFO("server - %s is deleted", minicontrol_name); + /* To avoid retrying to free minicontrol_name again, set MINICTRL_PLUG_DATA_KEY as NULL */ ecore_evas_data_set(ee, MINICTRL_PLUG_DATA_KEY, NULL); + + /* send message to remove plug */ + _minictrl_provider_message_send(MINICONTROL_EVENT_STOP, minicontrol_name, 0, 0, MINICONTROL_PRIORITY_LOW); + _minictrl_provider_proc_send(MINICONTROL_DBUS_PROC_INCLUDE); + free(minicontrol_name); } -EXPORT_API -Evas_Object *minicontrol_viewer_image_object_get(const Evas_Object *obj) +static void _minictrl_plug_del(void *data, Evas *e, Evas_Object *obj, void *event_info) { - return elm_plug_image_object_get(obj); + Ecore_Evas *ee = data; + char *minicontrol_name = NULL; + + if (!ee) + return; + + minicontrol_name = ecore_evas_data_get(ee, MINICTRL_PLUG_DATA_KEY); + + if (minicontrol_name) { + /* Sending an event 'MINICONTROL_EVENT_REQUEST_HIDE' should be done by minicontrol viewer manually */ + free(minicontrol_name); + ecore_evas_data_set(ee, MINICTRL_PLUG_DATA_KEY, NULL); + } } -EXPORT_API Evas_Object *minicontrol_viewer_add(Evas_Object *parent, - const char *svr_name) +EXPORT_API Evas_Object *minicontrol_viewer_add(Evas_Object *parent, const char *minicontrol_name) { Evas_Object *plug = NULL; Evas_Object *plug_img = NULL; Ecore_Evas *ee = NULL; + if (parent == NULL || minicontrol_name == NULL) { + ERR("invalid parameter"); + set_last_result(MINICONTROL_ERROR_INVALID_PARAMETER); + return NULL; + } + plug = elm_plug_add(parent); + if (!plug) { ERR("fail to create plug"); + set_last_result(MINICONTROL_ERROR_ELM_FAILURE); return NULL; } - if (!elm_plug_connect(plug, svr_name, 0, EINA_TRUE)) { - ERR("Cannot connect plug[%s]", svr_name); + if (!elm_plug_connect(plug, minicontrol_name, 0, EINA_TRUE)) { + ERR("Cannot connect plug[%s]", minicontrol_name); + set_last_result(MINICONTROL_ERROR_ELM_FAILURE); evas_object_del(plug); return NULL; } @@ -88,31 +209,62 @@ EXPORT_API Evas_Object *minicontrol_viewer_add(Evas_Object *parent, plug_img = elm_plug_image_object_get(plug); ee = ecore_evas_object_ecore_evas_get(plug_img); - ecore_evas_data_set(ee, MINICTRL_PLUG_DATA_KEY, strdup(svr_name)); + ecore_evas_data_set(ee, MINICTRL_PLUG_DATA_KEY, strdup(minicontrol_name)); ecore_evas_callback_delete_request_set(ee, _minictrl_plug_server_del); - evas_object_event_callback_add(plug, EVAS_CALLBACK_DEL, - _minictrl_plug_del, plug); + evas_object_event_callback_add(plug, EVAS_CALLBACK_DEL, _minictrl_plug_del, ee); return plug; } -EXPORT_API minicontrol_error_e minicontrol_viewer_request(const char *appid, minicontrol_request_e request, int value) +EXPORT_API Evas_Object *minicontrol_viewer_image_object_get(const Evas_Object *obj) +{ + return elm_plug_image_object_get(obj); +} + +EXPORT_API int minicontrol_viewer_request(const char *minicontrol_name, minicontrol_request_e request, int value) { int ret = MINICONTROL_ERROR_NONE; + minicontrol_viewer_event_e event = 0; + bundle *event_arg_bundle = NULL; + char bundle_value_buffer[BUNDLE_BUFFER_LENGTH] = { 0, }; - if (appid == NULL) { + if (minicontrol_name == NULL) { ERR("appid is NULL, invaild parameter"); return MINICONTROL_ERROR_INVALID_PARAMETER; } - if (request != MINICONTROL_REQ_ROTATE_PROVIDER - && request != MINICONTROL_REQ_PROVIDER_PAUSE - && request != MINICONTROL_REQ_PROVIDER_RESUME) { - return MINICONTROL_ERROR_INVALID_PARAMETER; + + switch(request) { + case MINICONTROL_REQ_ROTATE_PROVIDER: { + event = MINICONTROL_EVENT_REPORT_ANGLE; + event_arg_bundle = bundle_create(); + + if (event_arg_bundle == NULL) { + ERR("fail to create a bundle instance"); + ret = MINICONTROL_ERROR_OUT_OF_MEMORY; + goto out; + } + + snprintf(bundle_value_buffer, BUNDLE_BUFFER_LENGTH, "%d", value); + + bundle_add_str(event_arg_bundle, "angle", bundle_value_buffer); + break; } + case MINICONTROL_REQ_NONE: + case MINICONTROL_REQ_HIDE_VIEWER: + case MINICONTROL_REQ_FREEZE_SCROLL_VIEWER: + case MINICONTROL_REQ_UNFREEZE_SCROLL_VIEWER: + case MINICONTROL_REQ_REPORT_VIEWER_ANGLE: + default : + ret = MINICONTROL_ERROR_INVALID_PARAMETER; + goto out; + } + + _minictrl_send_event(MINICTRL_DBUS_SIG_TO_PROVIDER, minicontrol_name, event, event_arg_bundle); - ret = _minictrl_provider_message_send(MINICTRL_DBUS_SIG_REQUEST, - appid, request, value, MINICONTROL_PRIORITY_MIDDLE, NULL); +out: + if (event_arg_bundle) + bundle_free(event_arg_bundle); return ret; }