fixed launch popup to use pgid
authorSangSoo Lee <constant.lee@samsung.com>
Fri, 12 Apr 2013 10:44:11 +0000 (19:44 +0900)
committerJaekyun Lee <jkyun.lee@samsung.com>
Thu, 18 Apr 2013 08:28:56 +0000 (17:28 +0900)
Change-Id: I73068e8216575a64bdb373752da12c0459a8c0c7

packaging/nfc-manager.spec
src/commonlib/CMakeLists.txt
src/commonlib/include/net_nfc_util_private.h
src/commonlib/net_nfc_util.c
src/manager/include/net_nfc_server_context_private.h
src/manager/net_nfc_server_context.c

index 6aa43f5..897d103 100644 (file)
@@ -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
index 65e4b30..302cde8 100644 (file)
@@ -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}")
index a6ca0a0..bd4f645 100644 (file)
@@ -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
index deca7c1..bd3dc94 100644 (file)
@@ -23,6 +23,7 @@
 // platform header
 #include <bluetooth-api.h>
 #include <vconf.h>
+#include <app_manager.h>
 
 // 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;
+}
+
index 2cfe156..22a3c4e 100644 (file)
@@ -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;
index 5fe5b92..9fe7b89 100644 (file)
@@ -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;