Get appid from pid
authorSunwook Bae <sunwook45.bae@samsung.com>
Mon, 22 Apr 2013 10:49:30 +0000 (19:49 +0900)
committerSunwook Bae <sunwook45.bae@samsung.com>
Tue, 23 Apr 2013 05:52:31 +0000 (14:52 +0900)
Change-Id: I8582759ddd83c24c316de2177bd0776072f905c9
Signed-off-by: Sunwook Bae <sunwook45.bae@samsung.com>
CMakeLists.txt
packaging/osp-channel-service.spec
src/IpcServer.cpp

index 3f7f673..c57e68d 100644 (file)
@@ -63,6 +63,7 @@ TARGET_LINK_LIBRARIES(${this_target} "-lsmack" )
 TARGET_LINK_LIBRARIES(${this_target} "-lpthread" )
 TARGET_LINK_LIBRARIES(${this_target} "-lcrypto" )
 TARGET_LINK_LIBRARIES(${this_target} "-lsoup-2.4" )
+TARGET_LINK_LIBRARIES(${this_target} "-lcapi-appfw-app-manager" )
 TARGET_LINK_LIBRARIES(${this_target} "-lcapi-appfw-package-manager" )
 TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp-server -losp-appfw-server")
 
index 10f4872..693a5ea 100755 (executable)
@@ -16,6 +16,7 @@ BuildRequires:        pkgconfig(libssl)
 BuildRequires: pkgconfig(libsmack)
 BuildRequires: pkgconfig(message-port)
 BuildRequires: pkgconfig(openssl)
+BuildRequires:  pkgconfig(capi-appfw-app-manager)
 BuildRequires:  pkgconfig(capi-appfw-package-manager)
 BuildRequires:  osp-appfw-internal-devel
 
index 02023d0..e623125 100644 (file)
@@ -38,6 +38,8 @@
 
 #include <ipc/ipc_message.h>
 
+#include <app_manager.h>
+
 #include <FBaseRtMutex.h>
 #include <FBaseSysLog.h>
 #include <FBase_StringConverter.h>
@@ -289,7 +291,6 @@ struct HelloMessage
 {
        int pid;
        bool reverse;  // true if the connection is for reverse message
-       char appId[256];
 };
 
 gboolean
@@ -317,7 +318,6 @@ IpcServer::OnConnectionRequest(GIOChannel* source, GIOCondition condition, gpoin
        SysTryCatch(NID_IO, client != -1, , E_SYSTEM, "[E_SYSTEM] Accept failed.");
 
        read(client, &helloMessage, sizeof(helloMessage));
-       helloMessage.appId[255] = '\0';
 
        pChannel = g_io_channel_unix_new(client);
        SysTryCatch(NID_IO, pChannel != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Not enough memory.");
@@ -336,11 +336,17 @@ IpcServer::OnConnectionRequest(GIOChannel* source, GIOCondition condition, gpoin
 
                pClientInfo->pIpcServer = pIpcServer;
                pClientInfo->clientId = helloMessage.pid;
-               pClientInfo->appId.Append((wchar_t*) helloMessage.appId);
+
+               char* pAppId = NULL;
+               int ret = app_manager_get_app_id(helloMessage.pid, &pAppId);
+               SysTryCatch(NID_IO, ret >= 0, ,E_SYSTEM, "[E_SYSTEM] Failed to get_app_id: %d", ret);
+
+               pClientInfo->appId = pAppId;
+               free(pAppId);
+
                pClientInfo->pReverseChannel = null;
 
                pIpcServer->__clients[helloMessage.pid] = pClientInfo;
-
                pIpcServer->__pCurrentClientInfo = pClientInfo;
                pIpcServer->__pListener->OnIpcClientConnected(*pIpcServer, helloMessage.pid);
                pIpcServer->__pCurrentClientInfo = null;