summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjk7744.park <jk7744.park@samsung.com>2015-02-01 13:30:33 +0900
committerjk7744.park <jk7744.park@samsung.com>2015-02-01 13:30:33 +0900
commit094c20a84cd9fa36e4ba2734f6ddd6f0cebc3336 (patch)
tree91d73fc96a2a1e1e5d28ed2300c3f434f0b426c6
parentd53b063c863f0058699fe884485deb54da3042bd (diff)
downloadmedia-key-tizen_2.3.tar.gz
media-key-tizen_2.3.tar.bz2
media-key-tizen_2.3.zip
-rwxr-xr-xCMakeLists.txt2
-rw-r--r--[-rwxr-xr-x]LICENSE0
-rwxr-xr-xTC/_export_env.sh8
-rwxr-xr-xTC/_export_target_env.sh7
-rwxr-xr-xTC/build.sh20
-rwxr-xr-xTC/clean.sh11
-rwxr-xr-xTC/config2
-rwxr-xr-xTC/execute.sh19
-rwxr-xr-xTC/testcase/Makefile24
-rwxr-xr-xTC/testcase/tc_gen.sh28
-rwxr-xr-xTC/testcase/tet_captured1
-rwxr-xr-xTC/testcase/tslist2
-rwxr-xr-xTC/testcase/utc_MODULE_API_func.c.in67
-rwxr-xr-xTC/testcase/utc_media_key_release_func.c53
-rwxr-xr-xTC/testcase/utc_media_key_reserve_func.c52
-rwxr-xr-xTC/tet_scen7
-rwxr-xr-xTC/tetbuild.cfg5
-rwxr-xr-xTC/tetclean.cfg5
-rwxr-xr-xTC/tetexec.cfg5
-rwxr-xr-xdoc/media_key_doc.h32
-rwxr-xr-xinclude/media_key.h87
-rw-r--r--packaging/capi-system-media-key.spec16
-rwxr-xr-xsrc/media_key.c184
23 files changed, 555 insertions, 82 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/LICENSE b/LICENSE
index bbe9d02..bbe9d02 100755..100644
--- a/LICENSE
+++ b/LICENSE
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/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 895b6f7..8ec7479 100755
--- a/include/media_key.h
+++ b/include/media_key.h
@@ -24,54 +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 2.3
*/
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 2.3
*/
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_PLAYPAUSE, /**< */
- 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 2.3
*/
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 2.3
+ *
+ * @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()
@@ -79,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 2.3
*
* @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 2.3
*
- * @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 2e63720..c80c511 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.1
+Version: 0.1.2
Release: 6
Group: TO_BE/FILLED_IN
License: TO BE FILLED IN
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,10 +35,10 @@ Requires: %{name} = %{version}-%{release}
%build
-%if 0%{?tizen_build_binary_release_type_eng}
-export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE"
-export CXXFLAGS="$CXXFLAGS -DTIZEN_ENGINEER_MODE"
-export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
+%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}
diff --git a/src/media_key.c b/src/media_key.c
index 0b46320..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>
@@ -10,25 +14,55 @@
#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 _media_key_init(void)
+{
+ if (_media_key_initialized)
+ return 0;
+
+ 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);
-static int __aul_key_handler(bundle *b, void *data)
+ _media_key_initialized = 1;
+
+ return 0;
+}
+
+static void _media_key_handler(const char *key_str, media_key_e event)
{
- 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;
+ media_key_e key;
- key_str = (char *)bundle_get_val(b, AUL_K_MULTI_KEY);
- event_str = (char *)bundle_get_val(b, AUL_K_MULTI_KEY_EVENT);
+ key = MEDIA_KEY_UNKNOWN;
if (!strcmp(key_str, KEY_PLAYCD)) {
key = MEDIA_KEY_PLAY;
@@ -44,54 +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)) {
+ } 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;