#include <ipc/ipc_message.h>
+#include <app_manager.h>
+
#include <FBaseRtMutex.h>
#include <FBaseSysLog.h>
#include <FBase_StringConverter.h>
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;
}