_IpcClient::_IpcClient(void)
: __pReverseSource(null)
- , __fdCount(0)
, __pFdLock(null)
, __pListener(null)
{
{
int pid;
bool reverse;
- char pkgId[256];
- char appExecutableName[256];
};
result
socketNameLength = socketName.size() + 1;
SysTryReturnResult(NID_IO, socketNameLength < 108, E_INVALID_ARG, "Server name is too long.");
- if (__fdCount == 0)
- {
- // Set an pkgId
- String pkgId = _AppInfo::GetPackageId();
- int length = (pkgId.GetLength() + 1) * sizeof(wchar_t);
- if (length > 255)
- {
- length = 255;
- }
-
- SysTryReturnResult(NID_IO, pkgId.GetLength() > 0, E_SYSTEM, "AppId dose not exist.");
-
- memcpy(helloMessage.pkgId, pkgId.GetPointer(), length);
-
- // Set an executableName
- String appExecutableName = _AppInfo::GetAppExecutableName();
- length = (appExecutableName.GetLength() + 1) * sizeof(wchar_t);
- if (length > 255)
- {
- length = 255;
- }
-
- if (appExecutableName.GetLength() != 0)
- {
- memcpy(helloMessage.appExecutableName, appExecutableName.GetPointer(), length);
- }
- }
-
client = socket(AF_UNIX, SOCK_STREAM, 0);
SysTryCatch(NID_IO, client != -1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to create a socket : %s.", strerror(errno));
}
else
{
- ++__fdCount;
-
ReleaseFd(client);
}
#include <ipc/ipc_message.h>
+#include <app_manager.h>
+
#include <FBaseRtMutex.h>
#include <FBaseSysLog.h>
#include <FBase_StringConverter.h>
{
int pid;
bool reverse; // true if the connection is for reverse message
- char pkgId[256];
- char appExecutableName[256];
};
gboolean
server = g_io_channel_unix_get_fd(source);
client = accept(server, (struct sockaddr*) &clientAddress, &clientLen);
- SysTryCatch(NID_IO, client != -1, , E_SYSTEM, "[E_SYSTEM] Accept failed.");
+ SysTryCatch(NID_IO, client != -1, ,E_SYSTEM, "[E_SYSTEM] Accept failed.");
read(client, &helloMessage, sizeof(helloMessage));
- helloMessage.pkgId[255] = '\0';
- helloMessage.appExecutableName[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->pkgId.Append((wchar_t*) helloMessage.pkgId);
- pClientInfo->appExecutableName.Append((wchar_t*) helloMessage.appExecutableName);
+
+ 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;
if (__pCurrentClientInfo)
{
- return __pCurrentClientInfo->pkgId;
+ String pkgId;
+ __pCurrentClientInfo->appId.SubString(0, 10, pkgId);
+
+ return pkgId;
}
return nullString;
if (__pCurrentClientInfo)
{
- return __pCurrentClientInfo->appExecutableName;
+ String appName;
+ __pCurrentClientInfo->appId.SubString(11, appName);
+
+ return appName;
}
return nullString;
if (__pCurrentClientInfo)
{
- return __pCurrentClientInfo->pkgId;
+ String pkgId;
+ __pCurrentClientInfo->appId.SubString(0, 10, pkgId);
+
+ return pkgId;
}
return nullString;
if (__pCurrentClientInfo)
{
- String appId(__pCurrentClientInfo->pkgId);
- appId.Append(L'.');
- appId.Append(__pCurrentClientInfo->appExecutableName);
-
- return appId;
+ return __pCurrentClientInfo->appId;
}
return nullString;