From 26fe51e727f6a96be7c20560de6f006116a87781 Mon Sep 17 00:00:00 2001 From: SangSoo Lee Date: Fri, 12 Apr 2013 19:44:11 +0900 Subject: [PATCH] fixed launch popup to use pgid Change-Id: I73068e8216575a64bdb373752da12c0459a8c0c7 --- packaging/nfc-manager.spec | 3 ++- src/commonlib/CMakeLists.txt | 2 +- src/commonlib/include/net_nfc_util_private.h | 1 + src/commonlib/net_nfc_util.c | 19 +++++++++++++++++++ src/manager/include/net_nfc_server_context_private.h | 1 + src/manager/net_nfc_server_context.c | 7 ++++--- 6 files changed, 28 insertions(+), 5 deletions(-) diff --git a/packaging/nfc-manager.spec b/packaging/nfc-manager.spec index 6aa43f5..897d103 100644 --- a/packaging/nfc-manager.spec +++ b/packaging/nfc-manager.spec @@ -1,6 +1,6 @@ Name: nfc-manager Summary: NFC framework manager -Version: 0.0.44 +Version: 0.0.45 Release: 0 Group: libs License: Flora Software License @@ -30,6 +30,7 @@ BuildRequires: pkgconfig(pmapi) BuildRequires: pkgconfig(pkgmgr) BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: pkgconfig(ecore-x) +BuildRequires: pkgconfig(capi-appfw-app-manager) BuildRequires: cmake BuildRequires: gettext-tools Requires(post): /sbin/ldconfig diff --git a/src/commonlib/CMakeLists.txt b/src/commonlib/CMakeLists.txt index 65e4b30..302cde8 100644 --- a/src/commonlib/CMakeLists.txt +++ b/src/commonlib/CMakeLists.txt @@ -14,7 +14,7 @@ IF("${CMAKE_BUILD_TYPE}" STREQUAL "") ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "") INCLUDE(FindPkgConfig) -pkg_check_modules(commonlib_pkges REQUIRED glib-2.0 dlog bluetooth-api libssl) +pkg_check_modules(commonlib_pkges REQUIRED glib-2.0 dlog bluetooth-api libssl capi-appfw-app-manager) FOREACH(flag ${commonlib_pkges_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/src/commonlib/include/net_nfc_util_private.h b/src/commonlib/include/net_nfc_util_private.h index a6ca0a0..bd4f645 100644 --- a/src/commonlib/include/net_nfc_util_private.h +++ b/src/commonlib/include/net_nfc_util_private.h @@ -82,5 +82,6 @@ bool net_nfc_util_strip_string(char *buffer, int buffer_length); void net_nfc_util_compute_CRC(CRC_type_e CRC_type, uint8_t *buffer, uint32_t length); const char *net_nfc_util_get_schema_string(int index); +pid_t net_nfc_util_get_current_app_pgid(pid_t pid); #endif diff --git a/src/commonlib/net_nfc_util.c b/src/commonlib/net_nfc_util.c index deca7c1..bd3dc94 100644 --- a/src/commonlib/net_nfc_util.c +++ b/src/commonlib/net_nfc_util.c @@ -23,6 +23,7 @@ // platform header #include #include +#include // nfc-manager header #include "net_nfc_util_private.h" @@ -504,3 +505,21 @@ const char *net_nfc_util_get_schema_string(int index) else return schema[index]; } + +pid_t net_nfc_util_get_current_app_pgid(pid_t pid) +{ + char *app_id = NULL; + app_context_h context = NULL; + pid_t pgid = NULL; + + app_manager_get_app_id(pid, &app_id); + app_manager_get_app_context(app_id, &context); + + app_context_get_pid(context, &pgid); + + free(app_id); + app_context_destroy(context); + + return pgid; +} + diff --git a/src/manager/include/net_nfc_server_context_private.h b/src/manager/include/net_nfc_server_context_private.h index 2cfe156..22a3c4e 100644 --- a/src/manager/include/net_nfc_server_context_private.h +++ b/src/manager/include/net_nfc_server_context_private.h @@ -25,6 +25,7 @@ typedef struct _net_nfc_client_info_t { pid_t pid; + pid_t pgid; int socket; GIOChannel *channel; uint32_t src_id; diff --git a/src/manager/net_nfc_server_context.c b/src/manager/net_nfc_server_context.c index 5fe5b92..9fe7b89 100644 --- a/src/manager/net_nfc_server_context.c +++ b/src/manager/net_nfc_server_context.c @@ -40,12 +40,12 @@ static gint _client_context_compare_by_socket(gconstpointer a, gconstpointer b) return result; } -static gint _client_context_compare_by_pid(gconstpointer a, gconstpointer b) +static gint _client_context_compare_by_pgid(gconstpointer a, gconstpointer b) { gint result = -1; net_nfc_client_info_t *info = (net_nfc_client_info_t *)a; - if (info->pid == (int)b) + if (info->pgid == (pid_t)b) result = 0; else result = 1; @@ -136,6 +136,7 @@ void net_nfc_server_add_client_context(pid_t pid, int socket, GIOChannel *channe if (info != NULL) { info->pid = pid; + info->pgid = net_nfc_util_get_current_app_pgid(pid); info->socket = socket; info->channel = channel; info->src_id = src_id; @@ -306,7 +307,7 @@ net_nfc_launch_popup_state_e net_nfc_server_get_client_popup_state(pid_t pid) pthread_mutex_lock(&g_client_context_lock); - item = g_list_find_custom(g_client_contexts, (gconstpointer)pid, _client_context_compare_by_pid); + item = g_list_find_custom(g_client_contexts, (gconstpointer)pid, _client_context_compare_by_pgid); if (item != NULL) { state = ((net_nfc_client_info_t *)item->data)->launch_popup_state; -- 2.7.4