Remove the C-Channel
[platform/framework/native/channel-service.git] / src / FIo_ChannelService.cpp
index cb1f9f1..e2918bc 100644 (file)
@@ -30,9 +30,7 @@
 #include "FIo_ChannelService.h"
 #include "FIo_ChannelMessages.h"
 #include "FIo_IChannelServiceStub.h"
-#include "FIo_ChannelCAppStub.h"
 
-using namespace std;
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::Base::Runtime;
@@ -58,7 +56,6 @@ _ChannelService::Construct(_IChannelServiceStub& stub)
 {
        static _StringHashProvider hashProvider;
        static _StringComparer stringComparer;
-       result r = E_SUCCESS;
 
        __channels.Construct(0, 0, hashProvider, stringComparer);
 
@@ -66,17 +63,6 @@ _ChannelService::Construct(_IChannelServiceStub& stub)
 
        __pIChannelServiceStub->SetChannelService(*this);
 
-       // Create a CAppStub
-       unique_ptr<_ChannelCAppStub> pCStub(new (std::nothrow) _ChannelCAppStub());
-       SysTryReturnResult(NID_IO, pCStub != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
-
-       r = pCStub->Construct();
-       SysTryReturnResult(NID_IO, r == E_SUCCESS, E_SYSTEM, "Failed to create a CAppStub.");
-
-       pCStub->SetChannelService(*this);
-
-       pCStub.release();
-
        return E_SUCCESS;
 }
 
@@ -87,47 +73,28 @@ _ChannelService::RegisterChannel(const String& channelId, const _IChannelService
 }
 
 result
-_ChannelService::RegisterChannel(const String& channelId, int clientId, unsigned int type)
+_ChannelService::RegisterChannel(const String& channelId, int clientId)
 {
        result r = E_SUCCESS;
        _ChannelInfo* pChannelInfo = null;
 
-       SysLog(NID_IO, "Register a channel : %ls.", channelId.GetPointer());
+       SysLog(NID_IO, "Register a channel : %ls", channelId.GetPointer());
 
        r = __channels.GetValue(channelId, pChannelInfo);
-       SysTryReturnResult(NID_IO, pChannelInfo == null, E_SYSTEM,  "Channel has already been registered.");
-
-       pChannelInfo = new (std::nothrow) _ChannelInfo;
-       SysTryReturnResult(NID_IO, pChannelInfo != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
-
-       pChannelInfo->channelId = channelId;
-       pChannelInfo->clientId = clientId;
-       pChannelInfo->type = type;
-       pChannelInfo->pGIOChannel = null;
-
-       __channels.Add(channelId, pChannelInfo);
-
-       return E_SUCCESS;
-}
-
-result
-_ChannelService::RegisterChannel(const String& channelId, int clientId, void* pGIOChannel)
-{
-       result r = E_SUCCESS;
-       _ChannelInfo* pChannelInfo = null;
-
-       SysLog(NID_IO, "Register a channel : [%ls]", channelId.GetPointer());
+       if (pChannelInfo != null)
+       {
+               SysTryReturnResult(NID_IO, pChannelInfo->clientId != clientId, E_SYSTEM,  "Channel has already been registered.");
 
-       r = __channels.GetValue(channelId, pChannelInfo);
-       SysTryReturnResult(NID_IO, pChannelInfo == null, E_SYSTEM, "Channel has already been registered.");
+               SysLog(NID_IO, "Remove garbage values : %ls", channelId.GetPointer());
+               __channels.Remove(channelId);
+       }
 
        pChannelInfo = new (std::nothrow) _ChannelInfo;
        SysTryReturnResult(NID_IO, pChannelInfo != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
 
        pChannelInfo->channelId = channelId;
        pChannelInfo->clientId = clientId;
-       pChannelInfo->type = CAPP_CHANNEL;
-       pChannelInfo->pGIOChannel = pGIOChannel;
+       pChannelInfo->pGIOChannel = null;
 
        __channels.Add(channelId, pChannelInfo);
 
@@ -143,7 +110,7 @@ _ChannelService::UnregisterChannel(const String& channelId)
 result
 _ChannelService::UnregisterChannel(int clientId)
 {
-       SysLog(NID_IO, "Unregister - clientId =  %d", clientId);
+       SysLog(NID_IO, "Unregister - client =  %d", clientId);
 
        result r = E_OBJ_NOT_FOUND;
 
@@ -160,7 +127,7 @@ _ChannelService::UnregisterChannel(int clientId)
                __channels.GetValue(key, pValue);
                if (pValue != null && pValue->clientId == clientId)
                {
-                       SysLog(NID_IO, "Unregister - ChannelId = %ls", key.GetPointer());
+                       SysLog(NID_IO, "Unregister - Channel = %ls", key.GetPointer());
                        __channels.Remove(key);
                        delete pValue;
 
@@ -179,7 +146,7 @@ _ChannelService::SendRequest(const String& src,
                                                         const ArrayList& args,
                                                         int requestId)
 {
-       SysLog(NID_IO, "[%ls] ---> [%ls], Request ID = %d", src.GetPointer(), dest.GetPointer(), requestId);
+       SysLog(NID_IO, "[%ls] ---> [%ls], Request = %d", src.GetPointer(), dest.GetPointer(), requestId);
 
        _ChannelInfo* pChannelInfo = null;
 
@@ -198,7 +165,7 @@ _ChannelService::SendNullRequest(const String& src,
                                                         const String& dest,
                                                         int requestId)
 {
-       SysLog(NID_IO, "[%ls] ---> [%ls], Request ID = %d", src.GetPointer(), dest.GetPointer(), requestId);
+       SysLog(NID_IO, "[%ls] ---> [%ls], Request = %d", src.GetPointer(), dest.GetPointer(), requestId);
 
        _ChannelInfo* pChannelInfo = null;
 
@@ -217,7 +184,7 @@ _ChannelService::SendResponse(const String& src,
                                                          const ArrayList& args,
                                                          int requestId)
 {
-       SysLog(NID_IO, "[%ls] ---> [%ls], Request ID = %d", src.GetPointer(), dest.GetPointer(), requestId);
+       SysLog(NID_IO, "[%ls] ---> [%ls], Request = %d", src.GetPointer(), dest.GetPointer(), requestId);
 
        _ChannelInfo* pChannelInfo = null;
 
@@ -225,18 +192,8 @@ _ChannelService::SendResponse(const String& src,
        SysTryReturnResult(NID_IO, pChannelInfo != null, E_OBJ_NOT_FOUND,
                                "Destination channel not found.");
 
-       // Channel for CApp
-       if (pChannelInfo->type == CAPP_CHANNEL)
-       {
-               bool ret = _ChannelCAppStub::SendResponse(requestId, pChannelInfo->pGIOChannel, args);
-               SysTryReturnResult(NID_IO, ret, E_SYSTEM, "Failed to send the data to a CApp.");
-       }
-       // Channel for OspApp
-       else
-       {
-               result r = __pIChannelServiceStub->SendResponse(pChannelInfo->clientId, src, dest, args, requestId);
-               SysTryReturnResult(NID_IO, r == E_SUCCESS, E_SYSTEM, "Failed to send the response data");
-       }
+       result r = __pIChannelServiceStub->SendResponse(pChannelInfo->clientId, src, dest, args, requestId);
+       SysTryReturnResult(NID_IO, r == E_SUCCESS, E_SYSTEM, "Failed to send the response data");
 
        return E_SUCCESS;
 }
@@ -246,7 +203,7 @@ _ChannelService::SendNullResponse(const String& src,
                                                          const String& dest,
                                                          int requestId)
 {
-       SysLog(NID_IO, "[%ls] ---> [%ls], Request ID = %d", src.GetPointer(), dest.GetPointer(), requestId);
+       SysLog(NID_IO, "[%ls] ---> [%ls], Request = %d", src.GetPointer(), dest.GetPointer(), requestId);
 
        _ChannelInfo* pChannelInfo = null;