From: Hyunbin Lee Date: Thu, 25 Apr 2013 10:43:14 +0000 (+0900) Subject: Revert commit ID eb415081365ae7736bf6d0436d008d374c34a884 X-Git-Tag: 2.1b_release~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5f54e7f164a654942ce8596938f4fee1a30b543f;p=platform%2Fframework%2Fnative%2Fappfw.git Revert commit ID eb415081365ae7736bf6d0436d008d374c34a884 Change-Id: If6f00f616d380c55a1266d976851d07831479048 Signed-off-by: Hyunbin Lee --- diff --git a/src/io/FIo_IpcClient.cpp b/src/io/FIo_IpcClient.cpp index 32843d0..9e98c93 100644 --- a/src/io/FIo_IpcClient.cpp +++ b/src/io/FIo_IpcClient.cpp @@ -57,6 +57,7 @@ namespace Tizen { namespace Io _IpcClient::_IpcClient(void) : __pReverseSource(null) + , __fdCount(0) , __pFdLock(null) , __pListener(null) { @@ -133,7 +134,9 @@ _IpcClient::GetName(void) const struct HelloMessage { int pid; - int reverse; + bool reverse; + char pkgId[256]; + char appExecutableName[256]; }; result @@ -172,6 +175,34 @@ _IpcClient::MakeConnection(bool forReverse) 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)); @@ -267,6 +298,8 @@ _IpcClient::MakeConnection(bool forReverse) } else { + ++__fdCount; + ReleaseFd(client); } diff --git a/src/io/inc/FIo_IpcClient.h b/src/io/inc/FIo_IpcClient.h index 60c2c85..ef48ac5 100644 --- a/src/io/inc/FIo_IpcClient.h +++ b/src/io/inc/FIo_IpcClient.h @@ -137,6 +137,7 @@ private: GSource* __pReverseSource; std::vector __fds; + int __fdCount; Tizen::Base::Runtime::Mutex* __pFdLock; Tizen::Base::String __name; _IIpcClientEventListener* __pListener; diff --git a/src/server/inc/FIo_IpcServer.h b/src/server/inc/FIo_IpcServer.h index 758237d..df1530c 100644 --- a/src/server/inc/FIo_IpcServer.h +++ b/src/server/inc/FIo_IpcServer.h @@ -190,7 +190,8 @@ private: _IpcServer* pIpcServer; /**< the pointer to an _ IpcServer */ GIOChannel* pReverseChannel; /**< the channel for sending reverse message */ std::vector channels; /**< the set of channels associated with a client */ - Tizen::Base::String appId; + Tizen::Base::String pkgId; + Tizen::Base::String appExecutableName; }; Tizen::Base::String __name; diff --git a/src/server/io/FIo_IpcServer.cpp b/src/server/io/FIo_IpcServer.cpp index 91f9808..43dfffe 100644 --- a/src/server/io/FIo_IpcServer.cpp +++ b/src/server/io/FIo_IpcServer.cpp @@ -36,8 +36,6 @@ #include -#include - #include #include #include @@ -279,7 +277,9 @@ CATCH: struct HelloMessage { int pid; - int reverse; // if the connection is for reverse message + bool reverse; // true if the connection is for reverse message + char pkgId[256]; + char appExecutableName[256]; }; gboolean @@ -304,9 +304,11 @@ _IpcServer::OnConnectionRequest(GIOChannel* source, GIOCondition condition, gpoi 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."); @@ -325,17 +327,12 @@ _IpcServer::OnConnectionRequest(GIOChannel* source, GIOCondition condition, gpoi 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->pkgId.Append((wchar_t*) helloMessage.pkgId); + pClientInfo->appExecutableName.Append((wchar_t*) helloMessage.appExecutableName); pClientInfo->pReverseChannel = null; pIpcServer->__clients[helloMessage.pid] = pClientInfo; + pIpcServer->__pCurrentClientInfo = pClientInfo; pIpcServer->__pListener->OnIpcClientConnected(*pIpcServer, helloMessage.pid); pIpcServer->__pCurrentClientInfo = null; @@ -406,10 +403,7 @@ _IpcServer::GetClientAppId(void) const if (__pCurrentClientInfo) { - String pkgId; - __pCurrentClientInfo->appId.SubString(0, 10, pkgId); - - return pkgId; + return __pCurrentClientInfo->pkgId; } return nullString; @@ -422,10 +416,7 @@ _IpcServer::GetClientAppExecutableName(void) const if (__pCurrentClientInfo) { - String appName; - __pCurrentClientInfo->appId.SubString(11, appName); - - return appName; + return __pCurrentClientInfo->appExecutableName; } return nullString; @@ -438,10 +429,7 @@ _IpcServer::GetClientPackageId(void) const if (__pCurrentClientInfo) { - String pkgId; - __pCurrentClientInfo->appId.SubString(0, 10, pkgId); - - return pkgId; + return __pCurrentClientInfo->pkgId; } return nullString; @@ -454,7 +442,11 @@ _IpcServer::GetClientApplicationId(void) const if (__pCurrentClientInfo) { - return __pCurrentClientInfo->appId; + String appId(__pCurrentClientInfo->pkgId); + appId.Append(L'.'); + appId.Append(__pCurrentClientInfo->appExecutableName); + + return appId; } return nullString;