From a535dbcccf034720562d9b593942d00f5f1bb1fd Mon Sep 17 00:00:00 2001 From: Sunwook Bae Date: Tue, 21 May 2013 13:42:06 +0900 Subject: Fix an issue on registering the same port Change-Id: I2f4f42ae30b9a4436d932478cbf73110f64fbf64 Signed-off-by: Sunwook Bae --- include/message-port.h | 6 ++++-- src/MessagePortProxy.cpp | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/message-port.h b/include/message-port.h index 677a50b..4c84da2 100755 --- a/include/message-port.h +++ b/include/message-port.h @@ -55,7 +55,8 @@ typedef void (*messageport_message_cb)(int id, const char* remote_app_id, const /** - * @brief Registers the local message port. + * @brief Registers the local message port. @n + * If the message port name is already registered, the previous message port id returns and the callback function is changed. * * @param [in] local_port the name of the local message port * @param [in] callback The callback function to be called when a message is received @@ -69,7 +70,8 @@ int messageport_register_local_port(const char* local_port, messageport_message_ /** * @brief Registers the trusted local message port. @n - * This allows communications only if the applications are signed with the same certificate which is uniquely assigned to the developer. + * If the message port name is already registered, the previous message port id returns and the callback function is changed. @n + * This allows communications only if the applications are signed with the same certificate which is uniquely assigned to the developer. * * @param [in] local_port the name of the local message port * @param [in] callback The callback function to be called when a message is received diff --git a/src/MessagePortProxy.cpp b/src/MessagePortProxy.cpp index eaf285f..8954eef 100644 --- a/src/MessagePortProxy.cpp +++ b/src/MessagePortProxy.cpp @@ -531,6 +531,7 @@ MessagePortProxy::IsLocalPortRegisted(const string& localPort, bool trusted, int } else { + _LOGD("MessagePort name is already registered."); for (map::iterator it = __ids.begin(); it != __ids.end(); ++it) { if (localPort.compare(it->second) == 0) @@ -550,7 +551,8 @@ MessagePortProxy::IsLocalPortRegisted(const string& localPort, bool trusted, int } else { - for (map::iterator it = __ids.begin(); it != __trustedIds.end(); ++it) + _LOGD("MessagePort name is already registered."); + for (map::iterator it = __trustedIds.begin(); it != __trustedIds.end(); ++it) { if (localPort.compare(it->second) == 0) { -- cgit v1.2.3 From 4c0f19f709059921201c4143b9a66502f0ffd416 Mon Sep 17 00:00:00 2001 From: Sunwook Bae Date: Wed, 22 May 2013 15:56:26 +0900 Subject: Add an error-checking in write() Change-Id: I3297030d5f5c45838cd4090d32e2cd2bdeccf1e6 Signed-off-by: Sunwook Bae --- src/IpcClient.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/IpcClient.cpp b/src/IpcClient.cpp index 8f4d34b..6d5221f 100644 --- a/src/IpcClient.cpp +++ b/src/IpcClient.cpp @@ -479,6 +479,14 @@ IpcClient::SendAsync(IPC::Message* pMessage) while (remain > 0) { written = write(fd, (char*) pData, remain); + if (written < 0) + { + _LOGE("Failed to send a request: %d, %s", errno, strerror(errno)); + + ReleaseFd(fd); + return MESSAGEPORT_ERROR_IO_ERROR; + } + remain -= written; pData += written; } @@ -523,6 +531,7 @@ IpcClient::SendSync(IPC::Message* pMessage) ReleaseFd(fd); return MESSAGEPORT_ERROR_IO_ERROR; } + remain -= written; pData += written; } @@ -552,6 +561,8 @@ IpcClient::SendSync(IPC::Message* pMessage) } _LOGE("Failed to poll (%d, %s).", errno, strerror(errno)); + + ReleaseFd(fd); return MESSAGEPORT_ERROR_IO_ERROR; } @@ -580,6 +591,8 @@ IpcClient::SendSync(IPC::Message* pMessage) if (pReply == NULL) { _LOGE("The memory is insufficient."); + + ReleaseFd(fd); return MESSAGEPORT_ERROR_OUT_OF_MEMORY; } -- cgit v1.2.3 From 41de7d3f6c868916f0d78f8ed87de205691285ef Mon Sep 17 00:00:00 2001 From: Sunwook Bae Date: Tue, 4 Jun 2013 10:38:18 +0900 Subject: Fix a prevent issue Change-Id: I519ff000a0c57cc496069a8cb41b4fdce8f6d14f Signed-off-by: Sunwook Bae --- src/MessagePortProxy.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/MessagePortProxy.cpp b/src/MessagePortProxy.cpp index 8954eef..69977fd 100644 --- a/src/MessagePortProxy.cpp +++ b/src/MessagePortProxy.cpp @@ -384,6 +384,8 @@ MessagePortProxy::SendMessageInternal(const BundleBuffer& metadata, const Bundle if (len > MAX_MESSAGE_SIZE) { _LOGE("The size of message (%d) has exceeded the maximum limit.", len); + + delete pMsg; return MESSAGEPORT_ERROR_MAX_EXCEEDED; } -- cgit v1.2.3 From a70e66055b186f418b964cbd85f18189b19d562a Mon Sep 17 00:00:00 2001 From: Sunwook Bae Date: Fri, 7 Jun 2013 19:29:00 +0900 Subject: Change version to 2.2 Change-Id: I5be8e7bfd9431fbec7c0a5bf1728f8a2abf63132 Signed-off-by: Sunwook Bae --- packaging/message-port.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/message-port.spec b/packaging/message-port.spec index f84c57d..36b375e 100755 --- a/packaging/message-port.spec +++ b/packaging/message-port.spec @@ -1,6 +1,6 @@ Name: message-port Summary: Message Port library -Version: 1.2.1.0 +Version: 1.2.2.0 Release: 1 Group: TO_BE/FILLED_IN License: Apache License, Version 2.0 -- cgit v1.2.3 From c0562c2dc210e20b89a3d9b49f4cbbc463294891 Mon Sep 17 00:00:00 2001 From: Sunwook Bae Date: Tue, 11 Jun 2013 14:35:04 +0900 Subject: Change LOGD to LOGI Change-Id: I77f789a543cd94a1af98b61ceff79840c6b766f4 Signed-off-by: Sunwook Bae --- src/IpcClient.cpp | 8 ++++---- src/MessagePortProxy.cpp | 20 ++++++++++---------- src/message-port-log.h | 6 +++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/IpcClient.cpp b/src/IpcClient.cpp index 6d5221f..90e0c48 100644 --- a/src/IpcClient.cpp +++ b/src/IpcClient.cpp @@ -179,7 +179,7 @@ IpcClient::MakeConnection(bool forReverse) ret = connect(client, (struct sockaddr*) &server, serverLen); if (ret < 0 && errno == ENOENT) { - _LOGD("The server is not ready. %d", retry); + _LOGI("The server is not ready. %d", retry); usleep(1000 * 1000); @@ -319,7 +319,7 @@ IpcClient::HandleReceivedMessage(GIOChannel* source, GIOCondition condition) if (condition & G_IO_HUP) { - _LOGD("G_IO_HUP, the connection is closed."); + _LOGI("G_IO_HUP, the connection is closed."); g_source_destroy(__pReverseSource); g_source_unref(__pReverseSource); @@ -347,11 +347,11 @@ IpcClient::HandleReceivedMessage(GIOChannel* source, GIOCondition condition) { if (status == G_IO_STATUS_EOF) { - _LOGD("G_IO_STATUS_EOF, the connection is closed."); + _LOGI("G_IO_STATUS_EOF, the connection is closed."); } else { - _LOGD("G_IO_STATUS_ERROR, the connection is closed."); + _LOGI("G_IO_STATUS_ERROR, the connection is closed."); } pGError = NULL; diff --git a/src/MessagePortProxy.cpp b/src/MessagePortProxy.cpp index 69977fd..50b5f77 100644 --- a/src/MessagePortProxy.cpp +++ b/src/MessagePortProxy.cpp @@ -120,7 +120,7 @@ MessagePortProxy::OnIpcResponseReceived(IpcClient& client, const IPC::Message& m int MessagePortProxy::RegisterMessagePort(const string& localPort, bool isTrusted, messageport_message_cb callback) { - _LOGD("Register a message port : [%s:%s]", __appId.c_str(), localPort.c_str()); + _LOGI("Register a message port : [%s:%s]", __appId.c_str(), localPort.c_str()); int id = 0; @@ -208,7 +208,7 @@ MessagePortProxy::RegisterMessagePort(const string& localPort, bool isTrusted, int MessagePortProxy::CheckRemotePort(const string& remoteAppId, const string& remotePort, bool isTrusted, bool *exist) { - _LOGD("Check a remote port : [%s:%s]", remoteAppId.c_str(), remotePort.c_str()); + _LOGI("Check a remote port : [%s:%s]", remoteAppId.c_str(), remotePort.c_str()); bundle *b = bundle_create(); @@ -263,7 +263,7 @@ MessagePortProxy::CheckRemotePort(const string& remoteAppId, const string& remot } else if (return_value == MESSAGEPORT_ERROR_CERTIFICATE_NOT_MATCH) { - _LOGE("The remote application (%s) is not signed with the same certificate", remoteAppId.c_str()); + _LOGI("The remote application (%s) is not signed with the same certificate", remoteAppId.c_str()); *exist = true; return MESSAGEPORT_ERROR_CERTIFICATE_NOT_MATCH; @@ -282,7 +282,7 @@ MessagePortProxy::CheckRemotePort(const string& remoteAppId, const string& remot int MessagePortProxy::SendMessage(const string& remoteAppId, const string& remotePort, bool trustedMessage, bundle* data) { - _LOGD("Send a message to : [%s:%s]", remoteAppId.c_str(), remotePort.c_str()); + _LOGI("Send a message to : [%s:%s]", remoteAppId.c_str(), remotePort.c_str()); int ret = 0; @@ -319,7 +319,7 @@ MessagePortProxy::SendMessage(const string& remoteAppId, const string& remotePor int MessagePortProxy::SendMessage(const string& localPort, bool trustedPort, const string& remoteAppId, const string& remotePort, bool trustedMessage, bundle* data) { - _LOGD("Send a bidirectional message from [%s:%s] to [%s:%s]", __appId.c_str(), localPort.c_str(), remoteAppId.c_str(), remotePort.c_str()); + _LOGI("Send a bidirectional message from [%s:%s] to [%s:%s]", __appId.c_str(), localPort.c_str(), remoteAppId.c_str(), remotePort.c_str()); int ret = 0; @@ -533,7 +533,7 @@ MessagePortProxy::IsLocalPortRegisted(const string& localPort, bool trusted, int } else { - _LOGD("MessagePort name is already registered."); + _LOGI("MessagePort name is already registered."); for (map::iterator it = __ids.begin(); it != __ids.end(); ++it) { if (localPort.compare(it->second) == 0) @@ -553,7 +553,7 @@ MessagePortProxy::IsLocalPortRegisted(const string& localPort, bool trusted, int } else { - _LOGD("MessagePort name is already registered."); + _LOGI("MessagePort name is already registered."); for (map::iterator it = __trustedIds.begin(); it != __trustedIds.end(); ++it) { if (localPort.compare(it->second) == 0) @@ -579,7 +579,7 @@ MessagePortProxy::OnSendMessageInternal(const BundleBuffer& metadata, const Bund string messageType = bundle_get_val(b, MESSAGE_TYPE); - _LOGD("Message received to App: %s, Port: %s, Trusted: %s", pRemoteAppId, pRemotePort, trustedMessage.c_str()); + _LOGI("Message received to App: %s, Port: %s, Trusted: %s", pRemoteAppId, pRemotePort, trustedMessage.c_str()); int id = 0; messageport_message_cb callback; @@ -608,7 +608,7 @@ MessagePortProxy::OnSendMessageInternal(const BundleBuffer& metadata, const Bund string localPort = bundle_get_val(b, LOCAL_PORT); string trustedLocal = bundle_get_val(b, TRUSTED_LOCAL); - _LOGD("From App: %s, Port: %s, TrustedLocal: %s", localAppId.c_str(), localPort.c_str(), trustedLocal.c_str()); + _LOGI("From App: %s, Port: %s, TrustedLocal: %s", localAppId.c_str(), localPort.c_str(), trustedLocal.c_str()); bool trustedPort = (trustedLocal.compare("TRUE") == 0); @@ -618,7 +618,7 @@ MessagePortProxy::OnSendMessageInternal(const BundleBuffer& metadata, const Bund } else { - _LOGD("No callback"); + _LOGI("No callback"); } bundle_free(b); diff --git a/src/message-port-log.h b/src/message-port-log.h index 15dc711..9823651 100644 --- a/src/message-port-log.h +++ b/src/message-port-log.h @@ -30,10 +30,10 @@ extern "C" { #define LOG_TAG "MESSAGE_PORT" #define _LOGE(fmt, arg...) LOGE(fmt, ##arg) -#define _LOGD(fmt, arg...) LOGD(fmt, ##arg) +#define _LOGI(fmt, arg...) LOGI(fmt, ##arg) -#define _SECURE_LOGE(fmt, arg...) SECURE_LOGE(fmt, ##arg) -#define _SECURE_LOGD(fmt, arg...) SECURE_LOGD(fmt, ##arg) +//#define _SECURE_LOGE(fmt, arg...) SECURE_LOGE(fmt, ##arg) +//#define _SECURE_LOGI(fmt, arg...) SECURE_LOGI(fmt, ##arg) /** * @} -- cgit v1.2.3 From 75f7722ba72ef7fb4577fbc47fec38d06f98b14d Mon Sep 17 00:00:00 2001 From: Sunwook Bae Date: Wed, 24 Jul 2013 19:51:32 +0900 Subject: Update document Change-Id: Iafb50a706ead369282dee26bd11c0dbf4204bb25 Signed-off-by: Sunwook Bae --- src/IpcClient.h | 39 +++++++++------------------------------ 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/src/IpcClient.h b/src/IpcClient.h index 716ed5d..ba1abfe 100644 --- a/src/IpcClient.h +++ b/src/IpcClient.h @@ -60,14 +60,12 @@ public: /** * Constructs the instance of this class. * - * @return An error code - * @param[in] serverName The name of the server - * @param[in] pListener Set if the client want to handle a message from the IPC server. + * @return 0 on success, otherwise a negative error value. + * @param [in] serverName The name of the server + * @param [in] pListener Set if the client want to handle a message from the IPC server. * @c NULL, otherwise. - * @exception E_SUCCESS The method was successful. - * @exception E_OBJ_NOT_FOUND The IPC server was not found. - * @exception E_OUT_OF_MEMORY Insufficient memory. - * @exception E_SYSTEM A system error occurred. + * @retval MESSAGEPORT_ERROR_OUT_OF_MEMORY Insufficient memory. + * @retval MESSAGEPORT_ERROR_IO_ERROR A system error occurred. */ int Construct(const std::string& serverName, const IIpcClientEventListener* pListener = NULL); @@ -81,28 +79,10 @@ public: /** * Sends a request message to an IPC server. * - * @code - * - * - * int - * CalculatorProxy::Add(int a , int b) - * { - * int c = 0; - * - * My_sum mySum(a, b, &c); - * - * __pIpcClient->SendRequest(mySum); - * - * return c; - * } - * - * @endcode - * @return An error code - * @param[in] message The message to send - * @exception E_SUCCESS The method was successful. - * @exception E_INVALID_STATE The instance is in an invalid state. - * @exception E_OUT_OF_MEMORY Insufficient memory. - * @exception E_SYSTEM A system error occurred. + * @return 0 on success, otherwise a negative error value. + * @param [in] message The message to send + * @retval MESSAGEPORT_ERROR_OUT_OF_MEMORY Insufficient memory. + * @retval MESSAGEPORT_ERROR_IO_ERROR A system error occurred. * */ int SendRequest(const IPC::Message& message); @@ -135,7 +115,6 @@ private: pthread_mutex_t* __pMutex; std::vector __fds; - //Tizen::Base::Runtime::Mutex* __pFdLock; std::string __name; std::string __appId; IIpcClientEventListener* __pListener; -- cgit v1.2.3 From 483c7d7e659b87528a83f18383bd799c6ecdc74e Mon Sep 17 00:00:00 2001 From: Sunwook Bae Date: Wed, 31 Jul 2013 20:08:39 +0900 Subject: Apply the secure logs Change-Id: Ic5b87849f5a921dfde4811ce28867aff63ddbcf5 Signed-off-by: Sunwook Bae --- src/MessagePortProxy.cpp | 14 +++++++------- src/message-port-log.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/MessagePortProxy.cpp b/src/MessagePortProxy.cpp index 50b5f77..24abd93 100644 --- a/src/MessagePortProxy.cpp +++ b/src/MessagePortProxy.cpp @@ -120,7 +120,7 @@ MessagePortProxy::OnIpcResponseReceived(IpcClient& client, const IPC::Message& m int MessagePortProxy::RegisterMessagePort(const string& localPort, bool isTrusted, messageport_message_cb callback) { - _LOGI("Register a message port : [%s:%s]", __appId.c_str(), localPort.c_str()); + _SECURE_LOGI("Register a message port : [%s:%s]", __appId.c_str(), localPort.c_str()); int id = 0; @@ -208,7 +208,7 @@ MessagePortProxy::RegisterMessagePort(const string& localPort, bool isTrusted, int MessagePortProxy::CheckRemotePort(const string& remoteAppId, const string& remotePort, bool isTrusted, bool *exist) { - _LOGI("Check a remote port : [%s:%s]", remoteAppId.c_str(), remotePort.c_str()); + _SECURE_LOGI("Check a remote port : [%s:%s]", remoteAppId.c_str(), remotePort.c_str()); bundle *b = bundle_create(); @@ -263,7 +263,7 @@ MessagePortProxy::CheckRemotePort(const string& remoteAppId, const string& remot } else if (return_value == MESSAGEPORT_ERROR_CERTIFICATE_NOT_MATCH) { - _LOGI("The remote application (%s) is not signed with the same certificate", remoteAppId.c_str()); + _SECURE_LOGI("The remote application (%s) is not signed with the same certificate", remoteAppId.c_str()); *exist = true; return MESSAGEPORT_ERROR_CERTIFICATE_NOT_MATCH; @@ -282,7 +282,7 @@ MessagePortProxy::CheckRemotePort(const string& remoteAppId, const string& remot int MessagePortProxy::SendMessage(const string& remoteAppId, const string& remotePort, bool trustedMessage, bundle* data) { - _LOGI("Send a message to : [%s:%s]", remoteAppId.c_str(), remotePort.c_str()); + _SECURE_LOGI("Send a message to : [%s:%s]", remoteAppId.c_str(), remotePort.c_str()); int ret = 0; @@ -319,7 +319,7 @@ MessagePortProxy::SendMessage(const string& remoteAppId, const string& remotePor int MessagePortProxy::SendMessage(const string& localPort, bool trustedPort, const string& remoteAppId, const string& remotePort, bool trustedMessage, bundle* data) { - _LOGI("Send a bidirectional message from [%s:%s] to [%s:%s]", __appId.c_str(), localPort.c_str(), remoteAppId.c_str(), remotePort.c_str()); + _SECURE_LOGI("Send a bidirectional message from [%s:%s] to [%s:%s]", __appId.c_str(), localPort.c_str(), remoteAppId.c_str(), remotePort.c_str()); int ret = 0; @@ -579,7 +579,7 @@ MessagePortProxy::OnSendMessageInternal(const BundleBuffer& metadata, const Bund string messageType = bundle_get_val(b, MESSAGE_TYPE); - _LOGI("Message received to App: %s, Port: %s, Trusted: %s", pRemoteAppId, pRemotePort, trustedMessage.c_str()); + _SECURE_LOGI("Message received to App: %s, Port: %s, Trusted: %s", pRemoteAppId, pRemotePort, trustedMessage.c_str()); int id = 0; messageport_message_cb callback; @@ -608,7 +608,7 @@ MessagePortProxy::OnSendMessageInternal(const BundleBuffer& metadata, const Bund string localPort = bundle_get_val(b, LOCAL_PORT); string trustedLocal = bundle_get_val(b, TRUSTED_LOCAL); - _LOGI("From App: %s, Port: %s, TrustedLocal: %s", localAppId.c_str(), localPort.c_str(), trustedLocal.c_str()); + _SECURE_LOGI("From App: %s, Port: %s, TrustedLocal: %s", localAppId.c_str(), localPort.c_str(), trustedLocal.c_str()); bool trustedPort = (trustedLocal.compare("TRUE") == 0); diff --git a/src/message-port-log.h b/src/message-port-log.h index 9823651..ea6b979 100644 --- a/src/message-port-log.h +++ b/src/message-port-log.h @@ -32,8 +32,8 @@ extern "C" { #define _LOGE(fmt, arg...) LOGE(fmt, ##arg) #define _LOGI(fmt, arg...) LOGI(fmt, ##arg) -//#define _SECURE_LOGE(fmt, arg...) SECURE_LOGE(fmt, ##arg) -//#define _SECURE_LOGI(fmt, arg...) SECURE_LOGI(fmt, ##arg) +#define _SECURE_LOGE(fmt, arg...) SECURE_LOGE(fmt, ##arg) +#define _SECURE_LOGI(fmt, arg...) SECURE_LOGI(fmt, ##arg) /** * @} -- cgit v1.2.3 From 815c0af8821b9e6aed05ef514e2545f611511418 Mon Sep 17 00:00:00 2001 From: Sunwook Bae Date: Mon, 12 Aug 2013 20:11:45 +0900 Subject: Change the default visibility to hidden Change-Id: Ief04ded934465949d396c994516306ef72ed3089 Signed-off-by: Sunwook Bae --- CMakeLists.txt | 4 ++-- include/message-port.h | 26 ++++++++++++++++---------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 617689a..7eedc89 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,11 +36,11 @@ ENDFOREACH(flag) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall" ) ## SET C COMPILER FLAGS -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -fvisibility=hidden") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") ## SET CPP COMPILER FLAGS -SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}") +SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden") IF("${ARCH}" STREQUAL "arm") ADD_DEFINITIONS("-DTARGET") diff --git a/include/message-port.h b/include/message-port.h index 4c84da2..a71ef93 100755 --- a/include/message-port.h +++ b/include/message-port.h @@ -19,6 +19,12 @@ #ifndef __APPFW_MESSAGE_PORT_H__ #define __APPFW_MESSAGE_PORT_H__ +#ifdef __GNUC__ +# define EXPORT_API __attribute__((visibility("default"))) +#else +# define EXPORT_API +#endif + #include #ifdef __cplusplus @@ -66,7 +72,7 @@ typedef void (*messageport_message_cb)(int id, const char* remote_app_id, const * @retval #MESSAGEPORT_ERROR_OUT_OF_MEMORY Out of memory * @retval #MESSAGEPORT_ERROR_IO_ERROR Internal I/O error */ -int messageport_register_local_port(const char* local_port, messageport_message_cb callback); +EXPORT_API int messageport_register_local_port(const char* local_port, messageport_message_cb callback); /** * @brief Registers the trusted local message port. @n @@ -81,7 +87,7 @@ int messageport_register_local_port(const char* local_port, messageport_message_ * @retval #MESSAGEPORT_ERROR_OUT_OF_MEMORY Out of memory * @retval #MESSAGEPORT_ERROR_IO_ERROR Internal I/O error */ -int messageport_register_trusted_local_port(const char* local_port, messageport_message_cb callback); +EXPORT_API int messageport_register_trusted_local_port(const char* local_port, messageport_message_cb callback); /** * @brief Checks if the message port of a remote application is registered. @@ -95,7 +101,7 @@ int messageport_register_trusted_local_port(const char* local_port, messageport_ * @retval #MESSAGEPORT_ERROR_OUT_OF_MEMORY Out of memory * @retval #MESSAGEPORT_ERROR_IO_ERROR Internal I/O error */ -int messageport_check_remote_port(const char* remote_app_id, const char *remote_port, bool* exist); +EXPORT_API int messageport_check_remote_port(const char* remote_app_id, const char *remote_port, bool* exist); /** * @brief Checks if the trusted message port of a remote application is registered. @@ -110,7 +116,7 @@ int messageport_check_remote_port(const char* remote_app_id, const char *remote_ * @retval #MESSAGEPORT_ERROR_CERTIFICATE_NOT_MATCH The remote application is not signed with the same certificate * @retval #MESSAGEPORT_ERROR_IO_ERROR Internal I/O error */ -int messageport_check_trusted_remote_port(const char* remote_app_id, const char *remote_port, bool* exist); +EXPORT_API int messageport_check_trusted_remote_port(const char* remote_app_id, const char *remote_port, bool* exist); /** * @brief Sends a message to the message port of a remote application. @@ -138,7 +144,7 @@ int messageport_check_trusted_remote_port(const char* remote_app_id, const char * bundle_free(b); * @endcode */ -int messageport_send_message(const char* remote_app_id, const char* remote_port, bundle* message); +EXPORT_API int messageport_send_message(const char* remote_app_id, const char* remote_port, bundle* message); /** * @brief Sends a trusted message to the message port of a remote application. @n @@ -156,7 +162,7 @@ int messageport_send_message(const char* remote_app_id, const char* remote_port, * @retval #MESSAGEPORT_ERROR_MAX_EXCEEDED The size of message has exceeded the maximum limit * @retval #MESSAGEPORT_ERROR_IO_ERROR Internal I/O error */ -int messageport_send_trusted_message(const char* remote_app_id, const char* remote_port, bundle* message); +EXPORT_API int messageport_send_trusted_message(const char* remote_app_id, const char* remote_port, bundle* message); /** * @brief Sends a message to the message port of a remote application. This method is used for the bidirectional communication. @@ -194,7 +200,7 @@ int messageport_send_trusted_message(const char* remote_app_id, const char* remo * bundle_free(b); * } */ -int messageport_send_bidirectional_message(int id, const char* remote_app_id, const char* remote_port, bundle* data); +EXPORT_API int messageport_send_bidirectional_message(int id, const char* remote_app_id, const char* remote_port, bundle* data); /** * @brief Sends a trusted message to the message port of a remote application. This method is used for the bidirectional communication. @@ -213,7 +219,7 @@ int messageport_send_bidirectional_message(int id, const char* remote_app_id, co * @retval #MESSAGEPORT_ERROR_MAX_EXCEEDED The size of message has exceeded the maximum limit * @retval #MESSAGEPORT_ERROR_IO_ERROR Internal I/O error */ -int messageport_send_bidirectional_trusted_message(int id, const char* remote_app_id, const char* remote_port, bundle* data); +EXPORT_API int messageport_send_bidirectional_trusted_message(int id, const char* remote_app_id, const char* remote_port, bundle* data); /** @@ -227,7 +233,7 @@ int messageport_send_bidirectional_trusted_message(int id, const char* remote_ap * @retval #MESSAGEPORT_ERROR_OUT_OF_MEMORY Out of memory * @remarks @a name must be released with free() by you */ -int messageport_get_local_port_name(int id, char **name); +EXPORT_API int messageport_get_local_port_name(int id, char **name); /** * @brief Checks if the local message port is trusted. @@ -239,7 +245,7 @@ int messageport_get_local_port_name(int id, char **name); * @retval #MESSAGEPORT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MESSAGEPORT_ERROR_OUT_OF_MEMORY Out of memory */ -int messageport_check_trusted_local_port(int id, bool *trusted); +EXPORT_API int messageport_check_trusted_local_port(int id, bool *trusted); /** * @} -- cgit v1.2.3 From f35c4af281ffca3fc8ec066269ba656c0e2ec2aa Mon Sep 17 00:00:00 2001 From: Sunwook Bae Date: Tue, 13 Aug 2013 09:33:46 +0900 Subject: Add to check the EXPORT_API define Change-Id: I17c525c6c4a512a4e7991cfcf12fadcba0bea3ca Signed-off-by: Sunwook Bae --- include/message-port.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/message-port.h b/include/message-port.h index a71ef93..6b194f9 100755 --- a/include/message-port.h +++ b/include/message-port.h @@ -20,7 +20,9 @@ #define __APPFW_MESSAGE_PORT_H__ #ifdef __GNUC__ -# define EXPORT_API __attribute__((visibility("default"))) +# ifndef EXPORT_API +# define EXPORT_API __attribute__((visibility("default"))) +# endif #else # define EXPORT_API #endif -- cgit v1.2.3 From 1c6e860459b427c460ab4dc679388a8ba63b0c20 Mon Sep 17 00:00:00 2001 From: Sunwook Bae Date: Mon, 19 Aug 2013 14:39:21 +0900 Subject: Remove the pid info in the hello message Change-Id: I88a099aad0a4e58cad3320c1878a2984556027fc Signed-off-by: Sunwook Bae --- src/IpcClient.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/IpcClient.cpp b/src/IpcClient.cpp index 90e0c48..fbe6df5 100644 --- a/src/IpcClient.cpp +++ b/src/IpcClient.cpp @@ -120,7 +120,6 @@ IpcClient::GetName(void) const struct HelloMessage { - int pid; int reverse; }; @@ -138,9 +137,8 @@ IpcClient::MakeConnection(bool forReverse) socketNameLength = socketName.size() + 1; - HelloMessage helloMessage = {0, 0}; + HelloMessage helloMessage = {0}; - helloMessage.pid = getpid(); if (forReverse) { helloMessage.reverse = 1; -- cgit v1.2.3 From 43221f752e04eaed04ec926fba07c0340d94c36d Mon Sep 17 00:00:00 2001 From: Sunwook Bae Date: Wed, 21 Aug 2013 16:30:13 +0900 Subject: Update to use the aul api instead of app-manager Change-Id: I976ab3deae12bbcf14d5a79e4a4551e2c9a24d3b Signed-off-by: Sunwook Bae --- CMakeLists.txt | 4 ++-- message-port.pc.in | 2 +- packaging/message-port.spec | 2 +- src/MessagePortProxy.cpp | 15 +++++++-------- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7eedc89..150a797 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ SET (${this_target}_SOURCE_FILES src/MessagePortProxy.cpp ) -SET(requires "dlog bundle glib-2.0 chromium") +SET(requires "dlog bundle glib-2.0 aul chromium") INCLUDE(FindPkgConfig) pkg_check_modules(${this_target} REQUIRED ${requires}) @@ -59,7 +59,7 @@ TARGET_LINK_LIBRARIES(${this_target} "-ldlog" ) TARGET_LINK_LIBRARIES(${this_target} "-lbundle" ) TARGET_LINK_LIBRARIES(${this_target} "-lglib-2.0" ) TARGET_LINK_LIBRARIES(${this_target} "-lchromium" ) -TARGET_LINK_LIBRARIES(${this_target} "-lcapi-appfw-app-manager" ) +TARGET_LINK_LIBRARIES(${this_target} "-laul" ) SET_TARGET_PROPERTIES(${this_target} PROPERTIES diff --git a/message-port.pc.in b/message-port.pc.in index ec7cdb8..bd7816a 100755 --- a/message-port.pc.in +++ b/message-port.pc.in @@ -4,7 +4,7 @@ prefix=@PREFIX@ exec_prefix=/usr libdir=@LIB_INSTALL_DIR@ -includedir=/usr/include/appfw +includedir=@INCLUDE_INSTALL_DIR@/appfw Name: @PC_NAME@ Description: @PACKAGE_DESCRIPTION@ diff --git a/packaging/message-port.spec b/packaging/message-port.spec index 36b375e..899608e 100755 --- a/packaging/message-port.spec +++ b/packaging/message-port.spec @@ -10,7 +10,7 @@ BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(bundle) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(chromium) -BuildRequires: pkgconfig(capi-appfw-app-manager) +BuildRequires: pkgconfig(aul) # runtime requires Requires: chromium diff --git a/src/MessagePortProxy.cpp b/src/MessagePortProxy.cpp index 24abd93..0ff878d 100644 --- a/src/MessagePortProxy.cpp +++ b/src/MessagePortProxy.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include "message-port.h" #include "message-port-messages.h" @@ -93,18 +93,17 @@ MessagePortProxy::Construct(void) __pIpcClient = pIpcClient; int pid = getpid(); - char* pAppId = NULL; - ret = app_manager_get_app_id(pid, &pAppId); - if (ret < 0) + char buffer[256] = {0, }; + + ret = aul_app_get_appid_bypid(pid, buffer, sizeof(buffer)); + if (ret != AUL_R_OK) { - _LOGE("Failed to get_app_id: %d", ret); + _LOGE("Failed to get the application ID: %d", ret); return MESSAGEPORT_ERROR_IO_ERROR; } - __appId = pAppId; - - free(pAppId); + __appId = buffer; return MESSAGEPORT_ERROR_NONE; } -- cgit v1.2.3 From ede588f9b04dc32f109f73f47fa02c5cf56a6a7e Mon Sep 17 00:00:00 2001 From: Sunwook Bae Date: Mon, 26 Aug 2013 20:35:39 +0900 Subject: Fix a memory leak in Deserializer Change-Id: I7c83b8c8cd59102037b280c5f61e54843a6e1fb7 Signed-off-by: Sunwook Bae --- src/IpcClient.cpp | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/src/IpcClient.cpp b/src/IpcClient.cpp index fbe6df5..8c06900 100644 --- a/src/IpcClient.cpp +++ b/src/IpcClient.cpp @@ -261,6 +261,7 @@ IpcClient::MakeConnection(bool forReverse) ret = write(client, &helloMessage, sizeof(helloMessage)); if (ret < 0) { + _LOGE("Failed to send a hello message: %d, %s", errno, strerror(errno)); goto CATCH; } @@ -497,8 +498,16 @@ IpcClient::SendAsync(IPC::Message* pMessage) int IpcClient::SendSync(IPC::Message* pMessage) { + int error = MESSAGEPORT_ERROR_NONE; + int ret = 0; + + int readSize = 0; + char buffer[1024]; + char* pEndOfMessage = NULL; + + std::string message; + IPC::Message* pReply = NULL; - MessageReplyDeserializer* pReplyDeserializer = NULL; IPC::SyncMessage* pSyncMessage = dynamic_cast (pMessage); if (pSyncMessage == NULL) { @@ -506,12 +515,15 @@ IpcClient::SendSync(IPC::Message* pMessage) return MESSAGEPORT_ERROR_IO_ERROR; } + MessageReplyDeserializer* pReplyDeserializer = pSyncMessage->GetReplyDeserializer(); int messageId = SyncMessage::GetMessageId(*pSyncMessage); int fd = AcquireFd(); if (fd < 0) { _LOGE("Failed to get fd."); + + delete pReplyDeserializer; return MESSAGEPORT_ERROR_IO_ERROR; } @@ -526,8 +538,8 @@ IpcClient::SendSync(IPC::Message* pMessage) { _LOGE("Failed to send a request: %d, %s", errno, strerror(errno)); - ReleaseFd(fd); - return MESSAGEPORT_ERROR_IO_ERROR; + error = MESSAGEPORT_ERROR_IO_ERROR; + goto CATCH; } remain -= written; @@ -541,13 +553,6 @@ IpcClient::SendSync(IPC::Message* pMessage) pfd.events = POLLIN | POLLRDHUP; pfd.revents = 0; - char buffer[1024]; - std::string message; - int readSize = 0; - char* pEndOfMessage = NULL; - - int ret = 0; - while (true) { ret = poll(&pfd, 1, -1); @@ -560,16 +565,16 @@ IpcClient::SendSync(IPC::Message* pMessage) _LOGE("Failed to poll (%d, %s).", errno, strerror(errno)); - ReleaseFd(fd); - return MESSAGEPORT_ERROR_IO_ERROR; + error = MESSAGEPORT_ERROR_IO_ERROR; + goto CATCH; } if (pfd.revents & POLLRDHUP) { _LOGE("POLLRDHUP"); - ReleaseFd(fd); - return MESSAGEPORT_ERROR_IO_ERROR; + error = MESSAGEPORT_ERROR_IO_ERROR; + goto CATCH; } if (pfd.revents & POLLIN) @@ -590,23 +595,23 @@ IpcClient::SendSync(IPC::Message* pMessage) { _LOGE("The memory is insufficient."); - ReleaseFd(fd); - return MESSAGEPORT_ERROR_OUT_OF_MEMORY; + error = MESSAGEPORT_ERROR_OUT_OF_MEMORY; + goto CATCH; } break; } } - pReplyDeserializer = pSyncMessage->GetReplyDeserializer(); pReplyDeserializer->SerializeOutputParameters(*pReply); - delete pReply; + +CATCH: delete pReplyDeserializer; ReleaseFd(fd); - return MESSAGEPORT_ERROR_NONE; + return error; } int -- cgit v1.2.3