diff options
author | jk7744.park <jk7744.park@samsung.com> | 2015-09-08 22:09:51 +0900 |
---|---|---|
committer | jk7744.park <jk7744.park@samsung.com> | 2015-09-08 22:09:51 +0900 |
commit | 2d960947ca292cf040f74206eb2b58f93af83982 (patch) | |
tree | f2447ffe8a2d99882fffb642b4b855863b349b0f | |
parent | 2a671aad55d18f2db00b15049bca4651c6302aa2 (diff) | |
download | media-key-tizen_2.3.1.tar.gz media-key-tizen_2.3.1.tar.bz2 media-key-tizen_2.3.1.zip |
tizen 2.3.1 releasetizen_2.3.1_releasesubmit/tizen_2.3.1/20150915.075800tizen_2.3.1
33 files changed, 677 insertions, 79 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 20233c9..174013e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(INC_DIR include) INCLUDE_DIRECTORIES(${INC_DIR}) -SET(requires "dlog capi-base-common aul utilX") +SET(requires "dlog capi-base-common utilX ecore ecore-x ecore-input evas") SET(pc_requires "capi-base-common") INCLUDE(FindPkgConfig) diff --git a/TC/_export_env.sh b/TC/_export_env.sh new file mode 100755 index 0000000..72a11ec --- /dev/null +++ b/TC/_export_env.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +. ./config +export TET_INSTALL_PATH=$TET_INSTALL_HOST_PATH # tetware root 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 new file mode 100755 index 0000000..5ddaa53 --- /dev/null +++ b/TC/_export_target_env.sh @@ -0,0 +1,7 @@ +#!/bin/sh +. ./config +export TET_INSTALL_PATH=$TET_INSTALL_TARGET_PATH # path to path +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/build.sh b/TC/build.sh new file mode 100755 index 0000000..e838751 --- /dev/null +++ b/TC/build.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +export TET_INSTALL_PATH=/tetware # local tetware path +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 + +export TET_SUITE_ROOT=`pwd` +FILE_NAME_EXTENSION=`date +%s` + +RESULT_DIR=results +HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html +JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal + +mkdir -p $RESULT_DIR + +tcc -c -p ./ +tcc -b -j $JOURNAL_RESULT -p ./ +grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/TC/clean.sh b/TC/clean.sh new file mode 100755 index 0000000..29743e0 --- /dev/null +++ b/TC/clean.sh @@ -0,0 +1,11 @@ +#!/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 new file mode 100755 index 0000000..cec194a --- /dev/null +++ b/TC/config @@ -0,0 +1,2 @@ +TET_INSTALL_HOST_PATH=/home/jyotsna.a/workspace/TETware +TET_INSTALL_TARGET_PATH=/mnt/nfs/workspace/TETware diff --git a/TC/execute.sh b/TC/execute.sh new file mode 100755 index 0000000..e2c742e --- /dev/null +++ b/TC/execute.sh @@ -0,0 +1,19 @@ +#!/bin/sh +export TET_INSTALL_PATH=/mnt/nfs/TETware +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 + +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 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/TC/testcase/Makefile b/TC/testcase/Makefile new file mode 100755 index 0000000..be57abf --- /dev/null +++ b/TC/testcase/Makefile @@ -0,0 +1,24 @@ +CC ?= gcc + +C_FILES = $(shell ls *.c) + +PKGS = capi-system-media-key + +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/tc_gen.sh b/TC/testcase/tc_gen.sh new file mode 100755 index 0000000..9b8696a --- /dev/null +++ b/TC/testcase/tc_gen.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +TMPSTR=$0 +SCRIPT=${TMPSTR##*/} + +if [ $# -lt 2 ]; then + echo "Usage) $SCRIPT module_name api_name" + exit 1 +fi + +MODULE=$1 +API=$2 +TEMPLATE=utc_MODULE_API_func.c.in +TESTCASE=utc_${MODULE}_${API}_func + +sed -e ' + s^@API@^'"$API"'^g + s^@MODULE@^'"$MODULE"'^g + ' $TEMPLATE > $TESTCASE.c + +if [ ! -e "$TESTCASE.c" ]; then + echo "Failed" + exit 1 +fi +echo "Testcase file is $TESTCASE.c" +echo "Done" +echo "please put \"$TESTCASE\" as Target in Makefile" +echo "please put \"/testcase/$TESTCASE\" in tslist" diff --git a/TC/testcase/tet_captured b/TC/testcase/tet_captured new file mode 100755 index 0000000..fc92ad4 --- /dev/null +++ b/TC/testcase/tet_captured @@ -0,0 +1 @@ +make: `utc_media_key_release_func' is up to date. diff --git a/TC/testcase/tslist b/TC/testcase/tslist new file mode 100755 index 0000000..1cc094b --- /dev/null +++ b/TC/testcase/tslist @@ -0,0 +1,2 @@ +/testcase/utc_media_key_reserve_func +/testcase/utc_media_key_release_func diff --git a/TC/testcase/utc_MODULE_API_func.c.in b/TC/testcase/utc_MODULE_API_func.c.in new file mode 100755 index 0000000..4326c2b --- /dev/null +++ b/TC/testcase/utc_MODULE_API_func.c.in @@ -0,0 +1,67 @@ +#include <tet_api.h> +#include <media_key.h> + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_@MODULE@_@API@_func_01(void); +static void utc_@MODULE@_@API@_func_02(void); + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +struct tet_testlist tet_testlist[] = { + { utc_@MODULE@_@API@_func_01, POSITIVE_TC_IDX }, + { utc_@MODULE@_@API@_func_02, NEGATIVE_TC_IDX }, +}; + +static int pid; + +static void startup(void) +{ +} + +static void cleanup(void) +{ +} + +/** + * @brief Positive test case of @API@() + */ +static void utc_@MODULE@_@API@_func_01(void) +{ + int r = 0; + char buf[MAX_LOCAL_BUFSZ]; + + r = @API@(...); + + if (r<0) { + tet_infoline("@API@() failed in positive test case"); + tet_result(TET_FAIL); + return; + } + tet_result(TET_PASS); +} + +/** + * @brief Negative test case of @API@() + */ +static void utc_@MODULE@_@API@_func_02(void) +{ + int r = 0; + char buf[MAX_LOCAL_BUFSZ]; + + r = @API@(...); + + if (r>=0) { + tet_infoline("@API@() failed in negative test case"); + tet_result(TET_FAIL); + return; + } + tet_result(TET_PASS); +} diff --git a/TC/testcase/utc_media_key_release_func.c b/TC/testcase/utc_media_key_release_func.c new file mode 100755 index 0000000..f8cabde --- /dev/null +++ b/TC/testcase/utc_media_key_release_func.c @@ -0,0 +1,53 @@ +#include <tet_api.h> +#include <media_key.h> + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_media_key_release_positive(void); + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +struct tet_testlist tet_testlist[] = { + { utc_media_key_release_positive, POSITIVE_TC_IDX }, + { NULL, 0}, +}; + +static void startup(void) +{ +} + +static void cleanup(void) +{ +} + +void event_cb(media_key_e key, media_key_event_e status, void* user_data) +{ +} + +/** + * @brief Positive test case of media_key_release() + */ +static void utc_media_key_release_positive(void) +{ + int r = 0; + + media_key_reserve(event_cb, NULL); + r = media_key_release(); + if(r == 0) + { + dts_pass("utc_media_key_release_positive", "passed"); + } + else + { + dts_fail("utc_media_key_release_positive", "failed"); + } + +} + diff --git a/TC/testcase/utc_media_key_reserve_func.c b/TC/testcase/utc_media_key_reserve_func.c new file mode 100755 index 0000000..85620ae --- /dev/null +++ b/TC/testcase/utc_media_key_reserve_func.c @@ -0,0 +1,52 @@ +#include <tet_api.h> +#include <media_key.h> + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_media_key_reserve_positive(void); + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +struct tet_testlist tet_testlist[] = { + { utc_media_key_reserve_positive, POSITIVE_TC_IDX }, + { NULL, 0}, +}; + +static void startup(void) +{ +} + +static void cleanup(void) +{ + media_key_release(); +} + +void event_cb(media_key_e key, media_key_event_e status, void* user_data) +{ +} + +/** + * @brief Positive test case of media_key_reserve() + */ +static void utc_media_key_reserve_positive(void) +{ + int r = 0; + + r = media_key_reserve(event_cb, NULL); + + if(r == MEDIA_KEY_ERROR_NONE) + { + dts_pass("utc_media_key_reserve_positive", "passed"); + } + else + { + dts_fail("utc_media_key_reserve_positive", "failed"); + } +} diff --git a/TC/tet_scen b/TC/tet_scen new file mode 100755 index 0000000..03f029a --- /dev/null +++ b/TC/tet_scen @@ -0,0 +1,7 @@ +all + ^TEST +##### Scenarios for TEST ##### + +# Test scenario +TEST + :include:/testcase/tslist diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg new file mode 100755 index 0000000..f7eda55 --- /dev/null +++ b/TC/tetbuild.cfg @@ -0,0 +1,5 @@ +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 new file mode 100755 index 0000000..02d7030 --- /dev/null +++ b/TC/tetclean.cfg @@ -0,0 +1,5 @@ +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 new file mode 100755 index 0000000..ef3e452 --- /dev/null +++ b/TC/tetexec.cfg @@ -0,0 +1,5 @@ +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/capi-system-media-key.manifest b/capi-system-media-key.manifest new file mode 100644 index 0000000..75b0fa5 --- /dev/null +++ b/capi-system-media-key.manifest @@ -0,0 +1,5 @@ +<manifest> + <request> + <domain name="_"/> + </request> +</manifest> diff --git a/debian/README b/debian/README new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/debian/README diff --git a/debian/capi-system-media-key-dev.install b/debian/capi-system-media-key-dev.install new file mode 100644 index 0000000..761a28b --- /dev/null +++ b/debian/capi-system-media-key-dev.install @@ -0,0 +1,4 @@ +/usr/include/* +/usr/include/*/* +/usr/lib/pkgconfig/*.pc + diff --git a/debian/capi-system-media-key-dev.postinst b/debian/capi-system-media-key-dev.postinst new file mode 100644 index 0000000..1a24852 --- /dev/null +++ b/debian/capi-system-media-key-dev.postinst @@ -0,0 +1 @@ +#!/bin/sh diff --git a/debian/capi-system-media-key.install b/debian/capi-system-media-key.install new file mode 100644 index 0000000..4a755a4 --- /dev/null +++ b/debian/capi-system-media-key.install @@ -0,0 +1 @@ +/usr/lib/lib*.so* diff --git a/debian/capi-system-media-key.postinst b/debian/capi-system-media-key.postinst new file mode 100644 index 0000000..1a24852 --- /dev/null +++ b/debian/capi-system-media-key.postinst @@ -0,0 +1 @@ +#!/bin/sh diff --git a/debian/changelog b/debian/changelog new file mode 100755 index 0000000..5b19b3f --- /dev/null +++ b/debian/changelog @@ -0,0 +1,9 @@ +capi-system-media-key (0.0.1-1) unstable; urgency=low + + * Initial upload + * Git: slp/api/media-key + * Tag: capi-system-media-key_0.0.1-1 + + + -- Jaeho Lee <jaeho81.lee@samsung.com> Sat, 28 Aug 2012 10:40:37 +0900 + diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100755 index 0000000..cca9785 --- /dev/null +++ b/debian/control @@ -0,0 +1,22 @@ + +Source: capi-system-media-key +Section: libs +Priority: extra +Maintainer: Jaeho Lee <jaeho81.lee@samsung.com> +Build-Depends: debhelper (>= 5), dlog-dev, capi-base-common-dev, libaul-1-dev, libslp-utilx-dev + +Package: capi-system-media-key +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: A Media key library in Tizen Native API + +Package: capi-system-media-key-dev +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, capi-system-media-key (= ${Source-Version}), capi-base-common-dev +Description: A Media key library in Tizen Native API (DEV) + +Package: capi-system-media-key-dbg +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, capi-system-media-key (= ${Source-Version}) +Description: A Media key library in Tizen Native API (DBG) + diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..1af2fa7 --- /dev/null +++ b/debian/rules @@ -0,0 +1,68 @@ +#!/usr/bin/make -f + +CFLAGS = -Wall -g + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif +CMAKE_ROOT_DIR ?= $(CURDIR) +CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp + +FULLVER ?= $(shell dpkg-parsechangelog | grep Version: | cut -d ' ' -f 2 | cut -d '-' -f 1) +MAJORVER ?= $(shell echo $(FULLVER) | cut -d '.' -f 1) + +configure: configure-stamp +configure-stamp: + dh_testdir + mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && cmake .. -DFULLVER=${FULLVER} -DMAJORVER=${MAJORVER} + touch configure-stamp + + +build: build-stamp +build-stamp: configure-stamp + dh_testdir + cd $(CMAKE_BUILD_DIR) && $(MAKE) + touch $@ + +clean: + cd $(CMAKE_ROOT_DIR) + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + rm -f `find . -name *.pc` + rm -rf $(CMAKE_BUILD_DIR) + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install + +binary-indep: build install + +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples + dh_install --sourcedir=debian/tmp + dh_installman + dh_link + dh_strip --dbg-package=capi-system-media-key-dbg + dh_fixperms + 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/media_key_doc.h b/doc/media_key_doc.h new file mode 100755 index 0000000..23e09f1 --- /dev/null +++ b/doc/media_key_doc.h @@ -0,0 +1,32 @@ +/* + * 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. + */ + +#ifndef __TIZEN_SYSTEM_MEDIA_KEY_DOC_H__ +#define __TIZEN_SYSTEM_MEDIA_KEY_DOC_H__ + +/** + * @ingroup CAPI_SYSTEM_FRAMEWORK + * @defgroup CAPI_SYSTEM_MEDIA_KEY_MODULE Media key + * @brief The Media key API contains the media key library. + * + * @section CAPI_SYSTEM_MEDIA_KEY_MODULE_HEADER Required Header + * \#include <media_key.h> + * + * @section CAPI_SYSTEM_MEDIA_KEY_MODULE_OVERVIEW Overview + * The Media key API provides functions for getting the status of the media key when the key is changed. + */ + +#endif /* __TIZEN_SYSTEM_MEDIA_KEY_DOC_H__ */ diff --git a/include/media_key.h b/include/media_key.h index e50297c..3d81032 100755 --- a/include/media_key.h +++ b/include/media_key.h @@ -24,53 +24,66 @@ extern "C" { #endif - /** +/** + * @file media_key.h + */ + +/** * @addtogroup CAPI_SYSTEM_MEDIA_KEY_MODULE * @{ */ /** - * @brief Enumeration of error code for media key + * @brief Enumeration for error codes of a media key. + * + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { - MEDIA_KEY_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + MEDIA_KEY_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ MEDIA_KEY_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + MEDIA_KEY_ERROR_OPERATION_FAILED = TIZEN_ERROR_MEDIA_KEY | 0x01, /**< Reserve/Release failed */ } media_key_error_e; - /** - * @brief Enumeration of media key + * @brief Enumeration for media keys. + * + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { - MEDIA_KEY_PLAY, /**< */ - MEDIA_KEY_STOP, /**< */ - MEDIA_KEY_PAUSE, /**< */ - MEDIA_KEY_PREVIOUS, /**< */ - MEDIA_KEY_NEXT, /**< */ - MEDIA_KEY_FASTFORWARD, /**< */ - MEDIA_KEY_REWIND, /**< */ - MEDIA_KEY_UNKNOWN, + MEDIA_KEY_PLAY, /**< Play key */ + MEDIA_KEY_STOP, /**< Stop key */ + MEDIA_KEY_PAUSE, /**< Pause key */ + MEDIA_KEY_PREVIOUS, /**< Previous key */ + MEDIA_KEY_NEXT, /**< Next key */ + MEDIA_KEY_FASTFORWARD, /**< Fastforward key */ + MEDIA_KEY_REWIND, /**< Rewind key */ + MEDIA_KEY_PLAYPAUSE, /**< Playpause key */ + MEDIA_KEY_MEDIA, /**< Media key for earjack */ + MEDIA_KEY_UNKNOWN, /**< Unknown key */ } media_key_e; - /** - * @brief Enumeration of media key event status + * @brief Enumeration for event statuses of a media key. + * + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { - MEDIA_KEY_STATUS_PRESSED, /**< */ - MEDIA_KEY_STATUS_RELEASED, /**< */ - MEDIA_KEY_STATUS_UNKNOWN, + MEDIA_KEY_STATUS_PRESSED, /**< Pressed status */ + MEDIA_KEY_STATUS_RELEASED, /**< Released status */ + MEDIA_KEY_STATUS_UNKNOWN, /**< Unknown status */ } media_key_event_e; - /** - * @brief Called when the status of media key is changed - * @param[in] key the key which has status change - * @param[in] status the status of key + * @brief Called when the status of the media key is changed. + * + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] key The key whose status is changed + * @param[in] status The status of the key * @param[in] user_data The user data passed from the callback registration function * @pre media_key_reserve() will invoke this callback function. * @see media_key_reserve() @@ -78,36 +91,35 @@ typedef enum */ typedef void (*media_key_event_cb)(media_key_e key, media_key_event_e status, void* user_data); - /** - * @brief Registers a change event callback for all media keys. + * @brief Registers a change event callback for all media keys. + * + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] callback The callback function to invoke * @param[in] user_data The user data to be passed to the callback function - * - * @return 0 on success, otherwise a negative error value. + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_KEY_ERROR_NONE Successful * @retval #MEDIA_KEY_ERROR_INVALID_PARAMETER Invalid parameter - * @post runtime_info_changed_cb() will be invoked. - * + * @retval #MEDIA_KEY_ERROR_OPERATION_FAILED Reserve key failed * @see media_key_release() - * @see media_key_event_cb() */ int media_key_reserve(media_key_event_cb callback, void* user_data); - /** - * @brief Unregisters the callback function. + * @brief Unregisters the change event callback function. + * + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * - * @param[in] key The runtime information type - * @return 0 on success, otherwise a negative error value. + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_KEY_ERROR_NONE Successful * @retval #MEDIA_KEY_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see media_key_set_event_cb() + * @retval #MEDIA_KEY_ERROR_OPERATION_FAILED Release key failed + * @see media_key_reserve() */ -int media_key_release(); - +int media_key_release(void); /** * @} diff --git a/packaging/capi-system-media-key.spec b/packaging/capi-system-media-key.spec index b80cec8..49ed40c 100644 --- a/packaging/capi-system-media-key.spec +++ b/packaging/capi-system-media-key.spec @@ -1,17 +1,19 @@ Name: capi-system-media-key Summary: A System Information library in SLP C API -Version: 0.1.0 -Release: 1 +Version: 0.1.2 +Release: 6 Group: TO_BE/FILLED_IN -License: TO BE FILLED IN +License: Apache-2.0 Source0: %{name}-%{version}.tar.gz BuildRequires: cmake BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(capi-base-common) -BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(x11) BuildRequires: pkgconfig(utilX) +BuildRequires: pkgconfig(ecore) +BuildRequires: pkgconfig(ecore-x) +BuildRequires: pkgconfig(ecore-input) +BuildRequires: pkgconfig(evas) Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig @@ -33,6 +35,11 @@ Requires: %{name} = %{version}-%{release} %build +%if 0%{?sec_build_binary_debug_enable} +export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE" +export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE" +export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" +%endif MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} @@ -43,6 +50,9 @@ make %{?jobs:-j%jobs} rm -rf %{buildroot} %make_install +mkdir -p %{buildroot}/usr/share/license +cp LICENSE %{buildroot}/usr/share/license/%{name} + %post -p /sbin/ldconfig %postun -p /sbin/ldconfig @@ -50,6 +60,8 @@ rm -rf %{buildroot} %files %{_libdir}/libcapi-system-media-key.so.* +%manifest capi-system-media-key.manifest +/usr/share/license/%{name} %files devel %{_includedir}/system/media_key.h diff --git a/src/media_key.c b/src/media_key.c index 08a6b6d..eb2e7cd 100755 --- a/src/media_key.c +++ b/src/media_key.c @@ -1,4 +1,8 @@ -#include <aul.h> +#include <Ecore_X.h> +#include <Evas.h> +#include <Ecore.h> +#include <Ecore_Input.h> +#include <unistd.h> #include <media_key.h> #include <string.h> #include <utilX.h> @@ -8,27 +12,57 @@ #undef LOG_TAG #endif -#define LOG_TAG "TIZEN_N_MEDIA_KEY" +#define LOG_TAG "CAPI_SYSTEM_MEDIA_KEY" + +static char *media_keys[] = { + KEY_PLAYCD, + KEY_STOPCD, + KEY_PAUSECD, + KEY_NEXTSONG, + KEY_PREVIOUSSONG, + KEY_REWIND, + KEY_FASTFORWARD, + KEY_PLAYPAUSE, + KEY_MEDIA, + NULL +}; static void (*_media_key_event_cb)(media_key_e key, media_key_event_e status, void* user_data) = NULL; static void *_media_key_data = NULL; static int _media_key_initialized = 0; -extern int aul_key_reserve(); -extern int aul_key_release(); -extern int aul_key_init(int (*aul_handler) (bundle *, void *), void *data); +static Ecore_Event_Handler *media_key_up; +static Ecore_Event_Handler *media_key_down; +static Ecore_X_Window win; -static int __aul_key_handler(bundle *b, void *data) +static int _media_key_init(void) { - int ret = MEDIA_KEY_ERROR_NONE; - char *key_str; - char *event_str; - media_key_e key = MEDIA_KEY_UNKNOWN; - media_key_event_e event = MEDIA_KEY_STATUS_UNKNOWN; + if (_media_key_initialized) + return 0; - key_str = (char *)bundle_get_val(b, AUL_K_MULTI_KEY); - event_str = (char *)bundle_get_val(b, AUL_K_MULTI_KEY_EVENT); + win = ecore_x_window_input_new(ecore_x_window_root_first_get(), 0, 0, 1, 1); + if (!win) { + LOGE("failed to create input window"); + return -1; + } + + ecore_x_icccm_title_set(win, "media key receiver"); + ecore_x_netwm_name_set(win, "media key receiver"); + ecore_x_netwm_pid_set(win, getpid()); + + ecore_x_window_show(win); + + _media_key_initialized = 1; + + return 0; +} + +static void _media_key_handler(const char *key_str, media_key_e event) +{ + media_key_e key; + + key = MEDIA_KEY_UNKNOWN; if (!strcmp(key_str, KEY_PLAYCD)) { key = MEDIA_KEY_PLAY; @@ -44,52 +78,132 @@ static int __aul_key_handler(bundle *b, void *data) key = MEDIA_KEY_REWIND; } else if (!strcmp(key_str, KEY_FASTFORWARD)) { key = MEDIA_KEY_FASTFORWARD; + } else if (!strcmp(key_str, KEY_PLAYPAUSE)) { + key = MEDIA_KEY_PLAYPAUSE; + } else if (!strcmp(key_str, KEY_MEDIA)) { + key = MEDIA_KEY_MEDIA; } - if (!strcmp(event_str, AUL_V_KEY_RELEASED)) { - event = MEDIA_KEY_STATUS_RELEASED; - } else if (!strcmp(event_str, AUL_V_KEY_PRESSED)) { - event = MEDIA_KEY_STATUS_PRESSED; + if (_media_key_event_cb && key != MEDIA_KEY_UNKNOWN) + _media_key_event_cb(key, event, _media_key_data); +} + +static Eina_Bool _media_key_press_cb(void *data, int type, void *event) +{ + Evas_Event_Key_Down *ev; + + ev = event; + if (!ev) { + LOGE("Invalid event object"); + return ECORE_CALLBACK_RENEW; } - LOGD("[%s] media_key [%s][%d]", __FUNCTION__, key_str, key); - LOGD("[%s] media_key_event [%s][%d]", __FUNCTION__, event_str, event); + _media_key_handler(ev->keyname, MEDIA_KEY_STATUS_PRESSED); - if(_media_key_event_cb) - _media_key_event_cb(key, event, _media_key_data); + return ECORE_CALLBACK_RENEW; +} + +static Eina_Bool _media_key_release_cb(void *data, int type, void *event) +{ + Evas_Event_Key_Up *ev; + + ev = event; + if (!ev) { + LOGE("Invalid event object"); + return ECORE_CALLBACK_RENEW; + } - return ret; + _media_key_handler(ev->keyname, MEDIA_KEY_STATUS_RELEASED); + + return ECORE_CALLBACK_RENEW; } -int media_key_reserve(media_key_event_cb callback, void* user_data) +static int _grab_media_key(void) { + int i; int ret; - if(!_media_key_initialized) { - aul_key_init(__aul_key_handler, NULL); - _media_key_initialized = 1; + for (i = 0; media_keys[i]; i++) { + ret = utilx_grab_key(ecore_x_display_get(), win, media_keys[i], OR_EXCLUSIVE_GRAB); + if (ret) { + LOGE("failed to grab key: %s", media_keys[i]); + for (i = i - 1; i >= 0; i--) + utilx_ungrab_key(ecore_x_display_get(), win, media_keys[i]); + + return ret; + } } - _media_key_event_cb = callback; - _media_key_data = user_data; + return 0; +} - ret = aul_key_reserve(); - if(ret < 0) { - LOGE("[%s] aul_key_set_event error [%d]", __FUNCTION__, ret); +static int _ungrab_media_key(void) +{ + int i; + int ret; + + for (i = 0; media_keys[i]; i++) { + ret = utilx_ungrab_key(ecore_x_display_get(), win, media_keys[i]); + if (ret) + LOGE("failed to ungrab key: %s", media_keys[i]); + } + + return 0; +} + +int media_key_reserve(media_key_event_cb callback, void* user_data) +{ + int ret; + + if (callback == NULL) { + LOGE("[%s] media_key_event_cb callback is NULL", __FUNCTION__); return MEDIA_KEY_ERROR_INVALID_PARAMETER; } + if (!_media_key_initialized) { + if (_media_key_init()) + return MEDIA_KEY_ERROR_OPERATION_FAILED; + } + + ret = _grab_media_key(); + if (ret) { + LOGE("reserve media key error [%d]", ret); + return MEDIA_KEY_ERROR_OPERATION_FAILED; + } + + media_key_down = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _media_key_press_cb, NULL); + if (!media_key_down) + LOGE("failed to register key down event handler"); + + + media_key_up = ecore_event_handler_add(ECORE_EVENT_KEY_UP, _media_key_release_cb, NULL); + if (!media_key_down) + LOGE("failed to register key up event handler"); + + _media_key_event_cb = callback; + _media_key_data = user_data; + return MEDIA_KEY_ERROR_NONE; } -int media_key_release() +int media_key_release(void) { int ret; - ret = aul_key_release(); - if(ret < 0) { - LOGE("[%s] aul_key_unset_event error [%d]", __FUNCTION__, ret); - return MEDIA_KEY_ERROR_INVALID_PARAMETER; + ret = _ungrab_media_key(); + if (ret) { + LOGE("release media key error [%d]", ret); + return MEDIA_KEY_ERROR_OPERATION_FAILED; + } + + if (media_key_down) { + ecore_event_handler_del(media_key_down); + media_key_down = NULL; + } + + if (media_key_up) { + ecore_event_handler_del(media_key_up); + media_key_up = NULL; } _media_key_event_cb = NULL; |