//
-// Open Service Platform
// Copyright (c) 2012 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the License);
#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 appId[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.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;
-
- 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->appId.Append((wchar_t*) helloMessage.appId);
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)
- {
- String pkgId;
- __pCurrentClientInfo->appId.SubString(0, 10, pkgId);
-
- return pkgId;
- }
-
- return nullString;
-}
-
-String
-_IpcServer::GetClientAppExecutableName(void) const
-{
- static String nullString;
-
- if (__pCurrentClientInfo)
- {
- String appName;
- __pCurrentClientInfo->appId.SubString(11, appName);
-
- return appName;
- }
-
- return nullString;
-}
-
PackageId
_IpcServer::GetClientPackageId(void) const
{
char* pData = null;
GError* pGError = null;
_ClientInfo* pClientInfo = null;
+ int ret = 0;
SysTryReturn(NID_IO, client >= 0 && pMessage != null, false, E_INVALID_ARG,
"[E_INVALID_ARG] pMessage(0x%x) is null or clinet(%d) < 0", pMessage,
while (remain > 0)
{
pGError = NULL;
- g_io_channel_write_chars(pClientInfo->pReverseChannel, (char*) pData, remain, &written, &pGError);
+ ret = g_io_channel_write_chars(pClientInfo->pReverseChannel, (char*) pData, remain, &written, &pGError);
+ if (ret != G_IO_STATUS_NORMAL)
+ {
+ SysLog(NID_IO, "Failed to send a response: %d", ret);
+ SysTryCatch(NID_IO, ret != G_IO_STATUS_ERROR, , E_SYSTEM, "[E_SYSTEM] Error occurred during writing message to socket.");
+ }
+
SysTryCatch(NID_IO, pGError == null, , E_SYSTEM, "[E_SYSTEM] Error occurred during writing message to socket.");
remain -= written;
char* pData = null;
GError* pGError = null;
_ClientInfo* pClientInfo = null;
+ int ret = 0;
SysTryReturn(NID_IO, client >= 0, false, E_INVALID_ARG, "[E_INVALID_ARG] clinet(%d) < 0", client);
SysTryCatch(NID_IO, !message.is_sync(), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Can't send sync. messagee.");
while (remain > 0)
{
pGError = NULL;
- g_io_channel_write_chars(pClientInfo->pReverseChannel, (char*) pData, remain, &written, &pGError);
+ ret = g_io_channel_write_chars(pClientInfo->pReverseChannel, (char*) pData, remain, &written, &pGError);
+ if (ret != G_IO_STATUS_NORMAL)
+ {
+ SysLog(NID_IO, "Failed to send a response: %d", ret);
+ SysTryCatch(NID_IO, ret != G_IO_STATUS_ERROR, , E_SYSTEM, "[E_SYSTEM] Error occurred during writing message to socket.");
+ }
+
SysTryCatch(NID_IO, pGError == null, , E_SYSTEM, "[E_SYSTEM] Error occurred during writing message to socket.");
remain -= written;