summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/aul.h36
-rw-r--r--src/app_signal.c36
2 files changed, 68 insertions, 4 deletions
diff --git a/include/aul.h b/include/aul.h
index ec4708f2..866b1776 100644
--- a/include/aul.h
+++ b/include/aul.h
@@ -1363,6 +1363,42 @@ int aul_listen_app_launch_signal(int (*func) (int, void *), void *data);
/**
* @par Description:
+ * This API sets callback fuction that will be called when applications are launched.
+ * @par Purpose:
+ * This API's purpose is to listen the application launching event.
+ * In general, task manager Application need this API.
+ *
+ * @param[in] func callback function
+ * @param[in] data user data
+ * @return 0 if success, negative value if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_ERROR - general error
+ *
+ * @see
+ * aul_listen_app_dead_signal
+ * @code
+ * #include <aul.h>
+ *
+ * int app_launch_handler(int pid, const char *app_id, void *data)
+ * {
+ * printf("===> %s : %d, %s\n", __FUNCTION__, pid, app_id);
+ * return 0;
+ * }
+ *
+ * void dead_listen()
+ * {
+ * aul_listen_app_launch_signal(app_launch_handler, NULL);
+ * }
+ *
+ * @endcode
+ * @remark
+ * This API is only available in User Session.
+ *
+ */
+int aul_listen_app_launch_signal_v2(int (*func) (int, const char *, void *), void *data);
+
+/**
+ * @par Description:
* This API gets status of specified application process id.
* @par Purpose:
* This API's purpose is to get the application's status.
diff --git a/src/app_signal.c b/src/app_signal.c
index d8a5203e..381ea7af 100644
--- a/src/app_signal.c
+++ b/src/app_signal.c
@@ -35,6 +35,9 @@ static void *_app_dead_data;
static int (*_app_launch_handler) (int pid, void *data);
static void *_app_launch_data;
+static int (*_app_launch_handler2) (int pid, const char *app_id, void *data);
+static void *_app_launch_data2;
+
static int (*_booting_done_handler) (int pid, void *data);
static void *_booting_done_data;
@@ -131,14 +134,20 @@ __dbus_signal_filter_session(DBusConnection *conn, DBusMessage *message,
_app_dead_handler(pid, _app_dead_data);
} else if (dbus_message_is_signal(
message, interface, AUL_DBUS_APPLAUNCH_SIGNAL)) {
- if (dbus_message_get_args(message, &error, DBUS_TYPE_UINT32,
- &pid, DBUS_TYPE_INVALID) == FALSE) {
+ const char *app_id = NULL;
+ if (dbus_message_get_args(message, &error,
+ DBUS_TYPE_UINT32, &pid,
+ DBUS_TYPE_STRING, &app_id,
+ DBUS_TYPE_INVALID) == FALSE) {
_E("Failed to get data: %s", error.message);
dbus_error_free(&error);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
if (_app_launch_handler)
_app_launch_handler(pid, _app_launch_data);
+
+ if (_app_launch_handler2)
+ _app_launch_handler2(pid, app_id, _app_launch_data2);
}
return DBUS_HANDLER_RESULT_HANDLED;
@@ -267,7 +276,7 @@ SLPAPI int aul_listen_app_dead_signal(int (*func) (int, void *), void *data)
_E("error app signal init");
return AUL_R_ERROR;
}
- } else if (_app_launch_handler == NULL) {
+ } else if (_app_launch_handler == NULL && _app_launch_handler2 == NULL) {
if (__app_dbus_signal_handler_fini(AUL_DBUS_PATH, AUL_DBUS_SIGNAL_INTERFACE, false) < 0) {
_E("error app signal fini");
return AUL_R_ERROR;
@@ -286,7 +295,7 @@ SLPAPI int aul_listen_app_launch_signal(int (*func) (int, void *), void *data)
_E("error app signal init");
return AUL_R_ERROR;
}
- } else if (_app_dead_handler == NULL) {
+ } else if (_app_launch_handler2 == NULL && _app_dead_handler == NULL) {
if (__app_dbus_signal_handler_fini(AUL_DBUS_PATH, AUL_DBUS_SIGNAL_INTERFACE, false) < 0) {
_E("error app signal fini");
return AUL_R_ERROR;
@@ -298,6 +307,25 @@ SLPAPI int aul_listen_app_launch_signal(int (*func) (int, void *), void *data)
return AUL_R_OK;
}
+SLPAPI int aul_listen_app_launch_signal_v2(int (*func) (int, const char *, void *), void *data)
+{
+ if (func) {
+ if (__app_dbus_signal_handler_init(AUL_DBUS_PATH, AUL_DBUS_SIGNAL_INTERFACE, false) < 0) {
+ _E("error app signal init");
+ return AUL_R_ERROR;
+ }
+ } else if (_app_launch_handler == NULL && _app_dead_handler == NULL) {
+ if (__app_dbus_signal_handler_fini(AUL_DBUS_PATH, AUL_DBUS_SIGNAL_INTERFACE, false) < 0) {
+ _E("error app signal fini");
+ return AUL_R_ERROR;
+ }
+ }
+
+ _app_launch_handler2 = func;
+ _app_launch_data2 = data;
+
+ return AUL_R_OK;
+}
SLPAPI int aul_listen_booting_done_signal(int (*func) (int, void *), void *data)
{
if (func && !_booting_done_handler) {