#include <ipc/ipc_message.h>
+#include <app_manager.h>
+
#include <FBaseRtMutex.h>
#include <FBaseSysLog.h>
#include <FBase_StringConverter.h>
SysTryCatch(NID_IO, ret == 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to change permission of a socket(%d, %s): %s", serverSocket,
socketName.c_str(), strerror(errno));
- listen(serverSocket, 15);
+ ret = listen(serverSocket, 15);
+ SysTryCatch(NID_IO, ret == 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to listen a socket(%d, %s): %s", serverSocket,
+ socketName.c_str(), strerror(errno));
pGIOChannel = g_io_channel_unix_new(serverSocket);
SysTryCatch(NID_IO, pGIOChannel != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Not enough memory.");
struct HelloMessage
{
int pid;
- bool reverse; // true if the connection is for reverse message
- char appId[256];
+ int reverse; // if the connection is for reverse message
};
gboolean
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.");
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, delete pClientInfo, 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;
}
- if (helloMessage.reverse)
+ if (helloMessage.reverse != 0)
{
pClientInfo->pReverseChannel = pChannel;
}
return -1;
}
-int
-IpcServer::GetClientProcessId(void) const
-{
- if (__pCurrentClientInfo)
- {
- return __pCurrentClientInfo->clientId;
- }
-
- return -1;
-}
-
-String
-IpcServer::GetClientAppId(void) const
-{
- static String nullString;
-
- if (__pCurrentClientInfo)
- {
- return __pCurrentClientInfo->appId;
- }
-
- return nullString;
-}
-
-String
-IpcServer::GetClientAppExecutableName(void) const
-{
- static String nullString;
-
- //if (__pCurrentClientInfo)
- {
- //return __pCurrentClientInfo->appExecutableName;
- }
-
- return nullString;
-}
-
AppId
IpcServer::GetClientApplicationId(void) const
{