remove message_port_unregister
authorSunwook Bae <sunwook45.bae@samsung.com>
Fri, 26 Apr 2013 06:20:55 +0000 (15:20 +0900)
committerSunwook Bae <sunwook45.bae@samsung.com>
Mon, 29 Apr 2013 01:12:53 +0000 (10:12 +0900)
Change-Id: I1c8e60e6ff80c86dc2d5477ad75ce24afa968ae7
Signed-off-by: Sunwook Bae <sunwook45.bae@samsung.com>
include/message-port.h
src/MessagePortProxy.cpp
src/message-port.cpp

index e663ba7..6df7a95 100755 (executable)
@@ -80,18 +80,6 @@ int messageport_register_local_port(const char* local_port, messageport_message_
  */
 int messageport_register_trusted_local_port(const char* local_port, messageport_message_cb callback);
 
-
-/**
- * @brief Unregisters the local message port.
- *
- * @param [in] id The message port id returned by messageport_register_local_port() or messageport_register_trusted_local_port()
- * @return 0 on success, otherwise a negative error value.
- * @retval #MESSAGEPORT_ERROR_NONE Successful
- * @retval #MESSAGEPORT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MESSAGEPORT_ERROR_OUT_OF_MEMORY Out of memory
- */
-int messageport_unregister_local_port(int id);
-
 /**
  * @brief Checks if the message port of a remote application is registered.
  *
index 59801fd..1fc0b68 100644 (file)
@@ -67,6 +67,7 @@ MessagePortProxy::Construct(void)
        IpcClient* pIpcClient = new (std::nothrow) IpcClient();
        if (pIpcClient == NULL)
        {
+               _LOGE("Out of memory");
                return MESSAGEPORT_ERROR_OUT_OF_MEMORY;
        }
 
@@ -76,13 +77,13 @@ MessagePortProxy::Construct(void)
                delete pIpcClient;
 
                _LOGE("Failed to create ipc client: %d.", ret);
-
                return MESSAGEPORT_ERROR_IO_ERROR;
        }
 
        pthread_mutex_t* pMutex = (pthread_mutex_t*) malloc(sizeof(pthread_mutex_t));
        if (pMutex == NULL)
        {
+               _LOGE("Out of memory");
                return MESSAGEPORT_ERROR_OUT_OF_MEMORY;
        }
 
@@ -164,6 +165,8 @@ MessagePortProxy::RegisterMessagePort(const string& localPort, bool isTrusted,
        if (pMsg == NULL)
        {
                bundle_free(b);
+
+               _LOGE("Out of memory");
                return  MESSAGEPORT_ERROR_OUT_OF_MEMORY;
        }
 
@@ -233,6 +236,7 @@ MessagePortProxy::CheckRemotePort(const string& remoteAppId, const string& remot
        {
                bundle_free(b);
 
+               _LOGE("Out of memory");
                return MESSAGEPORT_ERROR_OUT_OF_MEMORY;
        }
 
@@ -245,7 +249,6 @@ MessagePortProxy::CheckRemotePort(const string& remoteAppId, const string& remot
        if (ret < 0)
        {
                _LOGE("Failed to send a request: %d.", ret);
-
                return MESSAGEPORT_ERROR_IO_ERROR;
        }
 
@@ -367,6 +370,7 @@ MessagePortProxy::SendMessageInternal(const BundleBuffer& metadata, const Bundle
        IPC::Message* pMsg = new MessagePort_sendMessage(metadata, buffer, &return_value);
        if (pMsg == NULL)
        {
+               _LOGE("Out of memory");
                return MESSAGEPORT_ERROR_OUT_OF_MEMORY;
        }
 
@@ -389,7 +393,6 @@ MessagePortProxy::SendMessageInternal(const BundleBuffer& metadata, const Bundle
        if (ret < 0)
        {
                _LOGE("Failed to send a request: %d.", ret);
-
                return MESSAGEPORT_ERROR_IO_ERROR;
        }
 
@@ -431,6 +434,7 @@ MessagePortProxy::GetLocalPortNameN(int id)
                it = __trustedIds.find(id);
                if (it == __ids.end())
                {
+                       _LOGE("Invalid value %d", id);
                        return NULL;
                }
                else
@@ -459,6 +463,7 @@ MessagePortProxy::CheckTrustedLocalPort(int id, bool* trusted)
                it = __trustedIds.find(id);
                if (it == __ids.end())
                {
+                       _LOGE("Invalid value %d", id);
                        return MESSAGEPORT_ERROR_INVALID_PARAMETER;
                }
                else
@@ -486,6 +491,7 @@ MessagePortProxy::GetProxy(void)
                MessagePortProxy* p = new MessagePortProxy();
                if (p == NULL)
                {
+                       _LOGE("Out of memory");
                        return NULL;
                }
 
index f6f53cc..e8ece33 100644 (file)
@@ -108,7 +108,11 @@ messageport_send_bidirectional_message(int id, const char* remote_app_id, const
        {
                char* pName = pProxy->GetLocalPortNameN(id);
                bool trusted = false;
-               pProxy->CheckTrustedLocalPort(id, &trusted);
+               ret = pProxy->CheckTrustedLocalPort(id, &trusted);
+               if (ret < 0)
+               {
+                       return MESSAGEPORT_ERROR_INVALID_PARAMETER;
+               }
 
                ret = pProxy->SendMessage(pName, trusted, remote_app_id, remote_port, false, message);