Remove unused static constant
[platform/framework/native/appfw.git] / src / io / FIo_MessagePortProxy.cpp
index 0f637b5..23ad6ea 100644 (file)
@@ -1,5 +1,4 @@
 //
-// Open Service Platform
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
 // Licensed under the Apache License, Version 2.0 (the License);
 #include <typeinfo>
 #include <unique_ptr.h>
 
-#include <package_manager.h>
-
 #include <message-port.h>
 
 #include <FBaseSysLog.h>
+#include <FBaseByteBuffer.h>
+
 #include <FBase_StringConverter.h>
 #include <FApp_AppInfo.h>
 
@@ -46,12 +45,12 @@ using namespace Tizen::Base::Runtime;
 namespace Tizen { namespace Io
 {
 
-static const int MAX_MESSAGE_SIZE = 16 * 1024;
+//static const int MAX_MESSAGE_SIZE = 16 * 1024;
 
 static void
 ConvertBundleToMap(const char *pKey, const int type, const bundle_keyval_t *pVal, void *pData)
 {
-       SysLog(NID_IO, "CB key = %s", pKey);
+       //SysLog(NID_IO, "CB key = %s", pKey);
 
        HashMap* pMap = static_cast<HashMap*>(pData);
 
@@ -72,16 +71,18 @@ ConvertBundleToMap(const char *pKey, const int type, const bundle_keyval_t *pVal
                        case BUNDLE_TYPE_BYTE:
                                bundle_keyval_get_basic_val(const_cast<bundle_keyval_t*>(pVal), reinterpret_cast<void**>(&pStr), &size);
 
-                               SysLog(NID_IO, "Bundle byte value = %s, size = %d", pStr, size);
+                               //SysLog(NID_IO, "Bundle byte value = %s, size = %d", pStr, size);
 
                                if (pStr)
                                {
                                        ByteBuffer* pBuffer = new (std::nothrow) ByteBuffer();
-                                       SysTryReturn(NID_IO, pMap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+                                       SysTryReturnVoidResult(NID_IO, pMap != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
                                        result r = pBuffer->Construct(size);
-                                       SysTryReturn(NID_IO, r == E_SUCCESS, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+                                       SysTryCatch(NID_IO, r == E_SUCCESS, delete pBuffer, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                                       r = pBuffer->SetArray((const byte*)pStr, 0, size);
+                                       SysTryCatch(NID_IO, r == E_SUCCESS, delete pBuffer, E_INVALID_ARG, "[E_INVALID_ARG] The buffer argument is invalid.");
 
-                                       pBuffer->SetArray((const byte*)pStr, 0, size);
                                        pBuffer->Flip();
 
                                        pMap->Add(new (std::nothrow) String(pKey), pBuffer);
@@ -93,6 +94,9 @@ ConvertBundleToMap(const char *pKey, const int type, const bundle_keyval_t *pVal
                                break;
                }
        }
+
+CATCH:
+       return;
 }
 
 static void
@@ -108,13 +112,13 @@ OnMessageReceived(int id, const char* remote_app_id, const char* remote_port, bo
        ret = messageport_get_local_port_name(id, &pLocalPort);
        if (pLocalPort == null)
        {
-               SysLog(NID_IO, "No local port for id: %d", id);
+               SysSecureLog(NID_IO, "No local port for id: %d", id);
 
                bundle_free(data);
                return;
        }
 
-       SysLog(NID_IO, "local port name: %s", pLocalPort);
+       //SysLog(NID_IO, "local port name: %s", pLocalPort);
 
        _IMessagePortListener* pListener = null;
        p->__listeners.GetValue(pLocalPort, pListener);
@@ -129,8 +133,6 @@ OnMessageReceived(int id, const char* remote_app_id, const char* remote_port, bo
                result r = pMap->Construct();
                SysTryCatch(NID_IO, r == E_SUCCESS, delete pMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
-               SysLog(NID_IO, "bundle to map");
-
                bundle_foreach(data, ConvertBundleToMap, pMap);
 
                if (remote_app_id == null) // Uni-directional
@@ -139,7 +141,7 @@ OnMessageReceived(int id, const char* remote_app_id, const char* remote_port, bo
                }
                else // Bi-directional
                {
-                       SysLog(NID_IO, "Message received from [%s:%s], trusted: %d", remote_app_id, remote_port, trusted_port);
+                       SysSecureLog(NID_IO, "Message received from [%s:%s], trusted: %d", remote_app_id, remote_port, trusted_port);
 
                        pListener->OnMessageReceivedN(remote_app_id, remote_port, trusted_port, pMap);
                }
@@ -161,7 +163,7 @@ OnTrustedMessageReceived(int id, const char* remote_app_id, const char* remote_p
        ret = messageport_get_local_port_name(id, &pLocalPort);
        if (pLocalPort == null)
        {
-               SysLog(NID_IO, "No local port for id: %d", id);
+               SysSecureLog(NID_IO, "No local port for id: %d", id);
 
                bundle_free(data);
                return;
@@ -188,7 +190,8 @@ OnTrustedMessageReceived(int id, const char* remote_app_id, const char* remote_p
                }
                else // Bi-directional
                {
-                       SysLog(NID_IO, "Trusted message received from [%s:%s], trusted: %d", remote_app_id, remote_port, trusted_port);
+                       SysSecureLog(NID_IO, "Trusted message received from [%s:%s], trusted: %d", remote_app_id, remote_port, trusted_port);
+
                        pListener->OnMessageReceivedN(remote_app_id, remote_port, trusted_port, pMap);
                }
        }
@@ -226,9 +229,8 @@ result
 _MessagePortProxy::RegisterMessagePort(const String& localPort,        bool isTrusted,
                                                                        const _IMessagePortListener& listener)
 {
-       SysLog(NID_IO, "Register a message port : [%ls:%ls]", __appId.GetPointer(), localPort.GetPointer());
+       SysSecureLog(NID_IO, "Register a message port : [%ls:%ls]", __appId.GetPointer(), localPort.GetPointer());
 
-       result r = E_SUCCESS;
        int ret = 0;
        bool contain = false;
 
@@ -281,7 +283,7 @@ _MessagePortProxy::RequestRemotePort(const AppId& remoteAppId,
                                                                        const String& remotePort,
                                                                        bool isTrusted)
 {
-       SysLog(NID_IO, "Request a remote message port [%ls:%ls]", remoteAppId.GetPointer(), remotePort.GetPointer());
+       SysSecureLog(NID_IO, "Request a remote message port [%ls:%ls]", remoteAppId.GetPointer(), remotePort.GetPointer());
 
        result r = E_SUCCESS;
        int ret = 0;
@@ -318,7 +320,7 @@ _MessagePortProxy::RequestRemotePort(const AppId& remoteAppId,
 result
 _MessagePortProxy::SendMessage(const AppId& remoteAppId, const String& remotePort, bool isTrusted, const HashMap* pMap)
 {
-       SysLog(NID_IO, "Send a unidirectional message to remote port [%ls:%ls]", remoteAppId.GetPointer(), remotePort.GetPointer());
+       SysSecureLog(NID_IO, "Send a unidirectional message to remote port [%ls:%ls]", remoteAppId.GetPointer(), remotePort.GetPointer());
 
        int ret = 0;
        int size = 0;
@@ -361,7 +363,7 @@ _MessagePortProxy::SendMessage(const AppId& remoteAppId, const String& remotePor
 result
 _MessagePortProxy::SendMessage(const String& localPort, bool isTrustedLocal, const AppId& remoteAppId, const String& remotePort, bool isTrustedRemote, const HashMap* pMap)
 {
-       SysLog(NID_IO, "Send a bidirectional message from [%ls:%ls] to [%ls:%ls]", __appId.GetPointer(), localPort.GetPointer(), remoteAppId.GetPointer(), remotePort.GetPointer());
+       SysSecureLog(NID_IO, "Send a bidirectional message from [%ls:%ls] to [%ls:%ls]", __appId.GetPointer(), localPort.GetPointer(), remoteAppId.GetPointer(), remotePort.GetPointer());
 
        result r = E_SUCCESS;
        int id = 0;