IPC Messaging Chanaged.
authorByounghui <byounghui.lim@samsung.com>
Wed, 31 Jul 2013 10:27:03 +0000 (19:27 +0900)
committerByounghui <byounghui.lim@samsung.com>
Wed, 31 Jul 2013 10:27:03 +0000 (19:27 +0900)
Change-Id: I30de52e2e3fd1ba9ee0e2c82d9b011a5d6a59ce7
Signed-off-by: Byounghui <byounghui.lim@samsung.com>
15 files changed:
CMakeLists.txt
inc/CommonService.h
packaging/osp-common-service.spec
src/CommonService.cpp
src/messaging/CMakeLists.txt [new file with mode: 0644]
src/messaging/FMsg_CbsMaker.cpp [new file with mode: 0644]
src/messaging/FMsg_CbsMaker.h [new file with mode: 0644]
src/messaging/FMsg_IpcCallbackHandler.cpp [new file with mode: 0644]
src/messaging/FMsg_IpcCallbackHandler.h [new file with mode: 0644]
src/messaging/FMsg_MessagingIpcStub.cpp [new file with mode: 0644]
src/messaging/FMsg_MessagingIpcStub.h [new file with mode: 0644]
src/messaging/FMsg_SmsService.cpp [new file with mode: 0644]
src/messaging/FMsg_SmsService.h [new file with mode: 0644]
src/messaging/FMsg_WapPushService.cpp [new file with mode: 0644]
src/messaging/FMsg_WapPushService.h [new file with mode: 0644]

index 24514ac..684c2bd 100644 (file)
@@ -26,6 +26,7 @@ INCLUDE_DIRECTORIES (
        /usr/include/osp/system-server/
        inc
        src/system
+       src/messaging
        )
 
 SET (${this_target}_SOURCE_FILES
@@ -36,7 +37,7 @@ SET (${this_target}_SOURCE_FILES
        )
 
 ADD_SUBDIRECTORY(src/system)
-
+ADD_SUBDIRECTORY(src/messaging)
 ## SET EXTRA COMPILER FLAGS
 SET(EXTRA_CFLAGS  "${EXTRA_CFLAGS} -fPIE -Wall -pthread -g3" )
 #SET(EXTRA_CFLAGS  "${EXTRA_CFLAGS} -fstack-protector -Wstack-protector" )
@@ -77,9 +78,26 @@ SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -
 
 TARGET_LINK_LIBRARIES( ${this_target} ${STATIC_LIBS})
 
+## Create Shared Library
+SET(STATIC_LIBS messaging_service)
+
+SET_TARGET_PROPERTIES(${this_target} PROPERTIES LINK_INTERFACE_LIBRARIES "")
+
+ADD_DEPENDENCIES(${this_target} ${STATIC_LIBS})
+
+OSP_ADD_OBJS_IN_ARCHIVE(${STATIC_LIBS})
+
+SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed")
+
+TARGET_LINK_LIBRARIES( ${this_target} ${STATIC_LIBS})
+
+
 TARGET_LINK_LIBRARIES(${this_target} -Xlinker --no-undefined -Xlinker --as-needed -pie)
 TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-appfw -lchromium")
 TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-uifw" )
+TARGET_LINK_LIBRARIES(${this_target} -L/usr/lib/osp -losp-messaging)
+TARGET_LINK_LIBRARIES(${this_target} "-lcapi-appfw-application" )
+TARGET_LINK_LIBRARIES(${this_target} "-lmsg_mapi" )
 TARGET_LINK_LIBRARIES(${this_target} "-lutilX" )
 TARGET_LINK_LIBRARIES(${this_target} "-lecore_x" )
 TARGET_LINK_LIBRARIES(${this_target} "-lSLP-tapi" )
index 05b67c8..833f93b 100644 (file)
@@ -42,6 +42,10 @@ class _DeviceManagerStub;
 class _PowerManagerStub;
 }}
 
+namespace Tizen { namespace Messaging
+{
+class _MessagingIpcStub;
+}}
 /**
  * @class      CommonService
  * @brief
@@ -72,6 +76,7 @@ private:
        Tizen::System::_RuntimeInfoStub* __pRuntimeInfoStub;
        Tizen::System::_DeviceManagerStub* __pDeviceManagerStub;
        Tizen::System::_PowerManagerStub* __pPowerManagerStub;
+       std::unique_ptr<Tizen::Messaging::_MessagingIpcStub>__pMessagingIpcStub;
 };
 
 #endif // _COMMON_SERVICE_H_
index 454b53a..3d1e260 100644 (file)
@@ -11,6 +11,7 @@ BuildRequires:        pkgconfig(capi-system-info)
 BuildRequires: pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(chromium)
 BuildRequires: pkgconfig(capi-appfw-package-manager)
+BuildRequires:  pkgconfig(capi-appfw-application)
 BuildRequires: pkgconfig(capi-network-wifi)
 BuildRequires: pkgconfig(capi-network-bluetooth)
 BuildRequires: pkgconfig(capi-media-sound-manager)
@@ -26,7 +27,13 @@ BuildRequires:  pkgconfig(x11)
 BuildRequires:         pkgconfig(utilX)
 BuildRequires: pkgconfig(tapi)
 BuildRequires:  hash-signer
-
+BuildRequires:  pkgconfig(dbus-1)
+BuildRequires:  pkgconfig(dbus-glib-1)
+BuildRequires:  pkgconfig(email-service)
+BuildRequires:  pkgconfig(msg-service)
+BuildRequires:  pkgconfig(osp-shell)
+BuildRequires:  pkgconfig(osp-messaging)
+BuildRequires:  osp-messaging-internal-devel
 # runtime requires
 Requires: chromium
 Requires: osp-appfw
index 01a8df2..5007b85 100644 (file)
@@ -26,6 +26,7 @@
 #include "FSys_RuntimeInfoStub.h"
 #include "FSys_DeviceManagerStub.h"
 #include "FSys_PowerManagerStub.h"
+#include "FMsg_MessagingIpcStub.h"
 
 using namespace std;
 using namespace Tizen::App;
@@ -39,6 +40,7 @@ CommonService::CommonService(void)
        , __pRuntimeInfoStub(null)
        , __pDeviceManagerStub(null)
        , __pPowerManagerStub(null)
+       , __pMessagingIpcStub(null)
 {      
 }
 
@@ -114,5 +116,11 @@ CommonService::InitializeServices(void)
                __pDeviceManagerStub = _DeviceManagerStub::GetInstance();
        }
        __pPowerManagerStub = _PowerManagerStub::GetInstance();
+
+       __pMessagingIpcStub.reset(new (std::nothrow) Tizen::Messaging::_MessagingIpcStub());
+       SysTryReturnVoidResult(NID_MSG, __pMessagingIpcStub, E_OUT_OF_MEMORY, "Memory is insufficient.");
+
+       r = __pMessagingIpcStub->Construct();
+       SysTryReturnVoidResult(NID_MSG, r == E_SUCCESS, r, "MsgStub Failed.");
 }
 
diff --git a/src/messaging/CMakeLists.txt b/src/messaging/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f56b0d0
--- /dev/null
@@ -0,0 +1,35 @@
+SET (this_target messaging_service)
+
+INCLUDE_DIRECTORIES(
+       ${SLP_INCLUDE_DIRS}
+       ${CMAKE_SOURCE_DIR}/inc
+       /usr/include/msg-service
+       /usr/include/dbus-1.0
+       /usr/lib/dbus-1.0/include
+       /usr/include/email-service
+       /usr/include/osp/messaging
+       ./
+       )
+
+SET (${this_target}_SOURCE_FILES
+       FMsg_IpcCallbackHandler.cpp
+       FMsg_MessagingIpcStub.cpp
+       FMsg_SmsService.cpp
+       FMsg_WapPushService.cpp
+       FMsg_CbsMaker.cpp
+)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
+
+## SET EXTRA COMPILER FLAGS
+SET(EXTRA_CFLAGS  "${EXTRA_CFLAGS} -fPIC" )
+
+## SET C COMPILER FLAGS
+SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## SET CPP COMPILER FLAGS
+SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## Create Library
+ADD_LIBRARY (${this_target} STATIC ${${this_target}_SOURCE_FILES})
+
diff --git a/src/messaging/FMsg_CbsMaker.cpp b/src/messaging/FMsg_CbsMaker.cpp
new file mode 100644 (file)
index 0000000..acaf1d4
--- /dev/null
@@ -0,0 +1,159 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ *
+ * @file               FMsg_CbsMaker.cpp
+ * @brief              This is the implementation file for the %_CbsMaker class.
+ *
+ *
+ * This file contains the implementation of the %_CbsMaker class.
+ *
+ * @endif
+ */
+
+#include <msg.h>
+#include <msg_transport.h>
+#include <msg_storage.h>
+#include <FMsgCbsChannel.h>
+#include <FBaseSysLog.h>
+#include <FBaseUtilStringUtil.h>
+#include <FBase_StringConverter.h>
+#include <FSec_AccessController.h>
+#include "FMsg_Types.h"
+#include "FMsg_CbsMaker.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Messaging;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Messaging
+{
+
+_CbsMaker::_CbsMaker(void)
+       : __fromId(-1)
+       , __toId(-1)
+       , __channelName(L"")
+       , __isChannelEnable(false)
+{
+}
+
+_CbsMaker::_CbsMaker(const _CbsMaker& value)
+{
+       __fromId = value.__fromId;
+       __toId = value.__toId;
+       __channelName = value.__channelName;
+       __isChannelEnable = value.__isChannelEnable;
+}
+
+_CbsMaker::~_CbsMaker(void)
+{
+}
+
+_CbsMaker&
+_CbsMaker::operator =(const _CbsMaker& rhs)
+{
+       if (this != &rhs)
+       {
+               __fromId = rhs.__fromId;
+               __toId = rhs.__toId;
+               __channelName = rhs.__channelName;
+               __isChannelEnable = rhs.__isChannelEnable;
+       }
+
+       return (*this);
+}
+
+result
+_CbsMaker::Construct(int from, int to, const Tizen::Base::String& name)
+{
+       __fromId = from;
+       __toId = to;
+       __channelName = name;
+       __isChannelEnable = false;
+
+       return E_SUCCESS;
+}
+
+_CbsMaker*
+_CbsMaker::GetCbsChannelN(int from, int to, const Tizen::Base::String& name)
+{
+       result r = E_SUCCESS;
+       _CbsMaker* pCbsChannel = null;
+
+       pCbsChannel = new (std::nothrow) _CbsMaker();
+       SysTryCatch(NID_MSG, pCbsChannel != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+
+       r = pCbsChannel->Construct(from, to, name);
+       SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "failed to construct channel.");
+
+       SetLastResult(GetLastResult());
+       return pCbsChannel;
+
+CATCH:
+       SetLastResult(GetLastResult());
+
+       if(pCbsChannel)
+       {
+               delete pCbsChannel;
+               pCbsChannel = null;
+       }
+
+       return null;
+}
+
+_CbsMaker*
+_CbsMaker::GetInstance(_CbsMaker& cbsChannel)
+{
+       return &cbsChannel;
+}
+
+bool
+_CbsMaker::IsActivated(void) const
+{
+       return __isChannelEnable;
+}
+
+Tizen::Base::String
+_CbsMaker::GetName(void) const
+{
+       return __channelName;
+}
+
+result
+_CbsMaker::GetRange(int& from, int& to) const
+{
+       result r = E_SUCCESS;
+
+       from = __fromId;
+       to = __toId;
+
+       return r;
+}
+
+void
+_CbsMaker::SetCbsChannelName(Tizen::Base::String channelName)
+{
+       __channelName = channelName;
+}
+
+void
+_CbsMaker::SetCbsChannelState(bool isChannelEnable)
+{
+       __isChannelEnable = isChannelEnable;
+}
+
+} } // Tizen::Messaging
diff --git a/src/messaging/FMsg_CbsMaker.h b/src/messaging/FMsg_CbsMaker.h
new file mode 100644 (file)
index 0000000..caf9554
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ *
+ * @file               FMsg_CbsMaker.h
+ * @brief              This is the header file for the _CbsMaker class.
+ *
+ *
+ * This header file contains the declarations of the _CbsMaker class.
+ *
+ * @endif
+ */
+
+#ifndef _FMSG_INTERNAL_CBS_MAKER_H_
+#define _FMSG_INTERNAL_CBS_MAKER_H_
+
+namespace Tizen { namespace Messaging
+{
+
+
+
+class _CbsMaker
+       : public Tizen::Base::Object
+{
+public:
+
+
+       virtual ~_CbsMaker(void);
+
+       result GetRange(int& from, int& to) const;
+       Tizen::Base::String GetName(void) const;
+       bool IsActivated(void) const;
+       void SetCbsChannelName(Tizen::Base::String channelName);
+       void SetCbsChannelState(bool isChannelEnable);
+       static _CbsMaker* GetCbsChannelN(int from, int to, const Tizen::Base::String& name);
+       static _CbsMaker* GetInstance(_CbsMaker& cbsChannel);
+
+public:
+
+       _CbsMaker(void);
+       _CbsMaker(const _CbsMaker& rhs);
+       _CbsMaker& operator =(const _CbsMaker& rhs);
+       result Construct(int from, int to, const Tizen::Base::String& name);
+
+private:
+       int __fromId;
+       int __toId;
+       Tizen::Base::String __channelName;
+       bool __isChannelEnable;
+}; // _CbsMaker
+
+} } // Tizen::Messaging
+#endif // _FMSG_INTERNAL_CBS_MAKER_H_
diff --git a/src/messaging/FMsg_IpcCallbackHandler.cpp b/src/messaging/FMsg_IpcCallbackHandler.cpp
new file mode 100644 (file)
index 0000000..97adc56
--- /dev/null
@@ -0,0 +1,935 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FMsg_IpcCallbackHandler.cpp
+ * @brief              This is the implementation file for the %_IpcCallbackHandler class.
+ *
+ * This file contains the implementation of the %_IpcCallbackHandler class.
+ */
+
+#include <msg.h>
+#include <msg_transport.h>
+#include <msg_storage.h>
+#include <dbus/dbus.h>
+#include <email-api.h>
+#include <FMsgSmsManager.h>
+#include <FBaseInteger.h>
+#include <FBaseSysLog.h>
+#include <FMsgEtwsPrimaryNotification.h>
+#include <FBase_StringConverter.h>
+#include "FMsg_IpcCallbackHandler.h"
+#include "FMsg_SmsService.h"
+#include "FMsg_Types.h"
+#include "FMsg_CbsMaker.h"
+#include "FMsg_MessagingIpcStub.h"
+#include "FMsg_WapPushService.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Messaging
+{
+
+_IpcCallbackHandler* _IpcCallbackHandler::__pMessageCallbackHandler = 0;
+bool _IpcCallbackHandler::__destroyed = false;
+
+_IpcCallbackHandler::_IpcCallbackHandler(void)
+       : __msgHandle(0)
+       , __cbsSettingsHandle(0)
+       , __pCbsChannelList(0)
+       , __pTempCbsChannelList(0)
+       , __callbackRegistered(false)
+       , __incomingSmsCallbackRegistered(true)
+       , __pWapPushClientId(null)
+       ,__pSmsClientId(null)
+       ,__pCbsEtwsClientId(null)
+
+{
+}
+
+result
+_IpcCallbackHandler::Construct()
+{
+       result r = E_SUCCESS;
+
+       r = __messageMap.Construct();
+
+       if (r == E_SUCCESS)
+       {
+               r = __msgMutex.Create();
+       }
+
+       __pTempCbsChannelList = new (std::nothrow) ArrayList();
+       SysTryReturnResult(NID_MSG, __pTempCbsChannelList != null, E_OUT_OF_MEMORY, "memory allocation failed");
+       r = __pTempCbsChannelList->Construct();
+       SysTryReturnResult(NID_MSG, r == E_SUCCESS, r, "Failed to construct an ArrayList");
+       std::atexit(CloseCbsSettingsHandle);
+
+       return r;
+}
+
+_IpcCallbackHandler::~_IpcCallbackHandler(void)
+{
+
+       if (__msgHandle)
+       {
+               msg_close_msg_handle(&__msgHandle);
+               __msgHandle = 0;
+       }
+
+       if (__messageMap.GetCount())
+       {
+               __messageMap.RemoveAll(true);
+       }
+
+       if (__cbsSettingsHandle)
+       {
+               msg_release_struct(&__cbsSettingsHandle);
+               __cbsSettingsHandle = 0;
+       }
+
+       if (__pTempCbsChannelList)
+       {
+               if (__pTempCbsChannelList->GetCount() > 0)
+               {
+                       __pTempCbsChannelList->RemoveAll(true);
+               }
+               delete __pTempCbsChannelList;
+               __pTempCbsChannelList = null;
+       }
+}
+
+_IpcCallbackHandler*
+_IpcCallbackHandler::GetInstance(void)
+{
+       SysTryReturn(NID_MSG, __destroyed == false, null, E_SYSTEM, "Instance Dead");
+
+       result r = E_SUCCESS;
+
+       if (!__pMessageCallbackHandler)
+       {
+               __pMessageCallbackHandler = new (std::nothrow) _IpcCallbackHandler();
+                SysTryReturn(NID_MSG, __pMessageCallbackHandler != NULL, null, E_SYSTEM, "failed to create instance");
+
+               if (__pMessageCallbackHandler)
+               {
+                       r = __pMessageCallbackHandler->Construct();
+
+                       if (r != E_SUCCESS)
+                       {
+                               delete __pMessageCallbackHandler;
+                                __pMessageCallbackHandler = 0;
+                       }
+               }
+       }
+
+       return __pMessageCallbackHandler;
+}
+
+int
+_IpcCallbackHandler::OpenMessageHandle(msg_handle_t& messageHandle)
+{
+       int err = MSG_SUCCESS;
+
+       if (!__msgHandle)
+       {
+               err = msg_open_msg_handle(&__msgHandle);
+       }
+
+       messageHandle = __msgHandle;
+       return err;
+}
+
+int
+_IpcCallbackHandler::OpenCbsSettingsHandle(msg_struct_t& cbsSettingsHandle)
+{
+       int err = MSG_SUCCESS;
+
+       if (!__cbsSettingsHandle)
+       {
+               __cbsSettingsHandle = msg_create_struct(MSG_STRUCT_SETTING_CB_OPT);
+               if (__cbsSettingsHandle && __msgHandle)
+               {
+                       err = msg_get_cb_opt(__msgHandle, __cbsSettingsHandle);
+               }
+       }
+
+       cbsSettingsHandle = __cbsSettingsHandle;
+       return err;
+}
+
+result
+_IpcCallbackHandler::AddCbsChannel(int from, int to, const Tizen::Base::String& name, bool activate)
+{
+       result r = E_SUCCESS;
+       int fromId = 0;
+       int toId = 0;
+       bool channelFound = false;
+       SysLog(NID_MSG, "AddCbsChannel from %d to %d name %ls activate %d ",from, to, name.GetPointer(), activate);
+
+       for (int index = 0; index < __pTempCbsChannelList->GetCount(); index++)
+       {
+               _CbsMaker* pCbsChannel = null;
+               pCbsChannel = dynamic_cast< Tizen::Messaging::_CbsMaker* >(__pTempCbsChannelList->GetAt(index));
+               SysTryReturn(NID_MSG, pCbsChannel != null, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel.");
+
+               pCbsChannel->GetRange(fromId, toId);
+               if (from == fromId && to == toId)
+               {
+                       channelFound = true;
+                       break;  // found channel to be updated.
+               }
+
+       }
+       SysTryReturn(NID_MSG, channelFound == false, r = E_ALREADY_SET, E_ALREADY_SET, "Failed due to already cb range.");
+
+       if (!channelFound)
+       {
+               _CbsMaker* pCbsChannel = null;
+       pCbsChannel = _CbsMaker::GetCbsChannelN(from, to, name);
+       SysTryReturn(NID_MSG, pCbsChannel != null, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel.");
+
+       if (activate)
+       {
+               _CbsMaker::GetInstance(*pCbsChannel)->SetCbsChannelState(activate);
+       }
+       r =__pTempCbsChannelList->Add(*pCbsChannel);
+               SysTryReturn(NID_MSG,r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Failed to set the channel.");
+
+       }
+
+
+
+
+       r = SaveCbsSettings();
+       return r;
+}
+
+result
+_IpcCallbackHandler::RemoveCbsChannel(int from, int to)
+{
+       result r = E_SUCCESS;
+       int fromId = 0;
+       int toId = 0;
+       bool channelFound = false;
+       _CbsMaker* pCbsChannel = NULL;
+       SysLog(NID_MSG, "RemoveCbsChannel from %d %d ",from, to);
+
+       for (int index = 0; index < __pTempCbsChannelList->GetCount(); index++)
+       {
+               pCbsChannel = dynamic_cast< Tizen::Messaging::_CbsMaker* >(__pTempCbsChannelList->GetAt(index));
+               SysTryReturn(NID_MSG, pCbsChannel != null, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel.");
+
+               pCbsChannel->GetRange(fromId, toId);
+               if (from == fromId && to == toId)
+               {
+                       channelFound = true;  // found channel to be removed.
+                       __pTempCbsChannelList->RemoveAt(index);
+                       index--;
+                       delete pCbsChannel;
+
+               }
+       }
+
+
+        if (!channelFound)
+       {
+               return E_OBJ_NOT_FOUND;
+       }
+       r = SaveCbsSettings();
+       SysTryReturn(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Failed to remove the channel.");
+
+       return r;
+}
+
+result
+_IpcCallbackHandler::SearchCbsChannel(int from, int to, int& index)
+{
+       result r = E_SUCCESS;
+       int fromId = 0;
+       int toId = 0;
+       bool channelFound = false;
+       _CbsMaker* pCbsChannel = NULL;
+       SysLog(NID_MSG, "SearchCbsChannel from %d %d ",from, to);
+
+       for (int tempIndex = 0; tempIndex < __pTempCbsChannelList->GetCount(); tempIndex++)
+       {
+               pCbsChannel = dynamic_cast< Tizen::Messaging::_CbsMaker* >(__pTempCbsChannelList->GetAt(tempIndex));
+               SysTryReturn(NID_MSG, pCbsChannel != null, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel.");
+
+               pCbsChannel->GetRange(fromId, toId);
+               if (from == fromId && to == toId)
+               {
+                       channelFound = true;
+                       index = tempIndex;
+                       break;  // found channel to be searched.
+               }
+       }
+
+        if (!channelFound)
+       {
+               return E_OBJ_NOT_FOUND;
+       }
+
+       return r;
+}
+
+result
+_IpcCallbackHandler::UpdateCbsChannel(int from, int to, Tizen::Base::String name, bool activate)
+{
+       result r = E_SUCCESS;
+       int fromId = 0;
+       int toId = 0;
+       bool channelFound = false;
+       int index = 0;
+       _CbsMaker* pCbsChannel = NULL;
+       SysLog(NID_MSG, "UpdateCbsChannel from %d to %d name %ls activate %d ",from, to, name.GetPointer(), activate);
+
+       for (int i = 0; i < __pTempCbsChannelList->GetCount(); i++)
+       {
+               pCbsChannel = dynamic_cast< Tizen::Messaging::_CbsMaker* >(__pTempCbsChannelList->GetAt(i));
+               SysTryReturn(NID_MSG, pCbsChannel != null, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel.");
+
+               pCbsChannel->GetRange(fromId, toId);
+               if (from == fromId && to == toId)
+               {
+                       channelFound = true;
+                       index = i;
+                       break;  // found channel to be updated.
+               }
+       }
+
+        if (!channelFound)
+       {
+               return E_OBJ_NOT_FOUND;
+       }
+
+       // set cbs channel name
+       _CbsMaker::GetInstance(*pCbsChannel)->SetCbsChannelName(name);
+
+       if (activate)
+       {
+               _CbsMaker::GetInstance(*pCbsChannel)->SetCbsChannelState(activate);
+       }
+       else
+       {
+               _CbsMaker::GetInstance(*pCbsChannel)->SetCbsChannelState(false);
+       }
+       //For changing to latest
+       __pTempCbsChannelList->RemoveAt(index);
+       __pTempCbsChannelList->Add(*pCbsChannel);
+
+       r = SaveCbsSettings();
+       SysTryReturn(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Failed to save the channel.");
+
+       return r;
+}
+
+result
+_IpcCallbackHandler::GetCbsChannel(int index, int& from, int& to, Tizen::Base::String& name, bool& activate)
+{
+       result r = E_SUCCESS;
+       _CbsMaker* pCbsChannel = NULL;
+
+       pCbsChannel = dynamic_cast< Tizen::Messaging::_CbsMaker* >(__pTempCbsChannelList->GetAt(index));
+       SysTryReturn(NID_MSG, pCbsChannel != null, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel.");
+
+       pCbsChannel->GetRange(from, to);
+       name = pCbsChannel->GetName();
+       if (pCbsChannel->IsActivated())
+       {
+               activate = true;
+       }
+       else
+       {
+               activate = false;
+       }
+       return r;
+}
+
+result
+_IpcCallbackHandler::GetCbsChannelsCount(int& count)
+{
+       result r = E_SUCCESS;
+
+       if (__pTempCbsChannelList)
+       {
+               count = __pTempCbsChannelList->GetCount();
+       }
+
+       return r;
+}
+
+result
+_IpcCallbackHandler::SaveCbsSettings()
+{
+       int err = MSG_SUCCESS;
+       result r = E_SUCCESS;
+       int fromId = 0;
+       int toId = 0;
+       bool isChannelActive = false;
+       String channelName;
+       char* pTempChannelName = null;
+
+       SysTryReturn(NID_MSG, __pTempCbsChannelList != null, r = E_SYSTEM, E_SYSTEM, "Failed to save the channel.");
+       err = msg_get_list_handle(__cbsSettingsHandle, MSG_CB_CHANNEL_LIST_STRUCT, (void **)&__pCbsChannelList);
+       SysTryReturn(NID_MSG, err == MSG_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel handle.");
+       SysLog(NID_MSG, "SaveCbsSettings Count %d, %d ",__pCbsChannelList->nCount,__pTempCbsChannelList->GetCount());
+       __pCbsChannelList->nCount = __pTempCbsChannelList->GetCount();
+
+       // save Channel List
+       for (int index = 0; index < __pTempCbsChannelList->GetCount(); index++)
+       {
+               Tizen::Messaging::_CbsMaker* pCbsChannel = dynamic_cast< Tizen::Messaging::_CbsMaker* >(__pTempCbsChannelList->GetAt(index));
+               SysTryReturn(NID_MSG, pCbsChannel != null, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel.");
+               pCbsChannel->GetRange(fromId, toId);
+               channelName = pCbsChannel->GetName();
+               if (pCbsChannel->IsActivated())
+               {
+                       isChannelActive = true;
+               }
+
+               pTempChannelName = _StringConverter::CopyToCharArrayN(channelName);
+               SysTryReturn(NID_MSG, pTempChannelName != null, r = E_OUT_OF_MEMORY, r, "Memory allocation failed.");
+
+               msg_set_bool_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_ACTIVATE_BOOL, isChannelActive);
+               msg_set_int_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_ID_FROM_INT, fromId);
+               msg_set_int_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_ID_TO_INT, toId);
+               msg_set_str_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_NAME_STR,
+                                        pTempChannelName,CB_CHANNEL_NAME_MAX);
+
+               if (pTempChannelName)
+               {
+                       delete[] pTempChannelName;
+                       pTempChannelName = null;
+               }
+       }
+
+       err = msg_set_cb_opt(__msgHandle, __cbsSettingsHandle);
+       r = ConvertException(err);
+       SysTryReturnResult(NID_MSG, r == E_SUCCESS, r, "Failed to save the channel.[%d] ",err);
+       return r;
+}
+
+result
+_IpcCallbackHandler::LoadCbsSettings()
+{
+       int err = MSG_SUCCESS;
+       result r = E_SUCCESS;
+       _CbsMaker* pCbsChannel = NULL;
+       int fromId = 0;
+       int toId = 0;
+       bool isChannelActive = false;
+       char channelName[CB_CHANNEL_NAME_MAX + 1] = {0,};
+
+       if (__pTempCbsChannelList->GetCount() > 0)
+       {
+               __pTempCbsChannelList->RemoveAll(true);
+       }
+
+       if (__cbsSettingsHandle)
+       {
+               // Load Channel List
+               err = msg_get_list_handle(__cbsSettingsHandle, MSG_CB_CHANNEL_LIST_STRUCT, (void **)&__pCbsChannelList);
+               r = ConvertException(err);
+               SysTryReturnResult(NID_MSG, r == E_SUCCESS, r, "Failed to open cbs Settings Handle");
+
+               for (int index = 0; index < __pCbsChannelList->nCount; index++)
+               {
+                       msg_get_bool_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_ACTIVATE_BOOL, &isChannelActive);
+                       msg_get_int_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_ID_FROM_INT, &fromId);
+                       msg_get_int_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_ID_TO_INT, &toId);
+                       msg_get_str_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_NAME_STR,
+                                                channelName,CB_CHANNEL_NAME_MAX);
+                       if((toId >= 0) && (fromId >= 0) && (toId >= fromId) && (toId <= MAX_CBS_CHANNEL_LIMIT) && ((toId - fromId) <= MAX_CBS_CHANNEL_RANGE))
+                       {
+                               pCbsChannel = _CbsMaker::GetCbsChannelN(fromId, toId, String(channelName));
+                               SysTryReturnResult(NID_MSG, pCbsChannel != null, E_SYSTEM, "Failed to get the channel.");
+                               if (isChannelActive)
+                               {
+                                       _CbsMaker::GetInstance(*pCbsChannel)->SetCbsChannelState(isChannelActive);
+                               }
+                               __pTempCbsChannelList->Add(*pCbsChannel);
+                       }
+                       else
+                       {
+                               SysLog(NID_MSG, "Load CBS Error: From[%d] To[%d] ",fromId, toId);
+
+                       }
+               }
+       }
+
+       return r;
+
+}
+
+int
+_IpcCallbackHandler::CloseMessageHandle()
+{
+       int err = MSG_SUCCESS;
+
+       if (__msgHandle)
+       {
+               err = msg_close_msg_handle(&__msgHandle);
+               __msgHandle = 0;
+               __callbackRegistered = false;
+       }
+
+       return err;
+}
+
+void
+_IpcCallbackHandler::CloseCbsSettingsHandle()
+{
+
+       if (__pMessageCallbackHandler)
+       {
+               delete __pMessageCallbackHandler;
+               __pMessageCallbackHandler = null;
+       }
+       __destroyed = true;
+
+}
+
+void
+_IpcCallbackHandler::SetInComingSmsCallback(bool incomingSmsCallbackRegistered)
+{
+       __incomingSmsCallbackRegistered = incomingSmsCallbackRegistered;
+}
+
+void
+_IpcCallbackHandler::IncomingSmsCallback(msg_handle_t hMsgHandle, msg_struct_t newMsg, void* pUserParam)
+{
+
+       int msgSize = 0;
+       msg_get_int_value(newMsg, MSG_MESSAGE_DATA_SIZE_INT, &msgSize);
+       char msgText[msgSize + 1];
+       memset(msgText, 0, msgSize + 1);
+       msg_get_str_value(newMsg, MSG_MESSAGE_SMS_DATA_STR, msgText, msgSize);
+       String message(msgText);
+
+       int port = -1;
+       msg_get_int_value(newMsg, MSG_MESSAGE_DEST_PORT_INT, &port);
+
+       int displayTime = -1;
+       msg_get_int_value(newMsg, MSG_MESSAGE_DISPLAY_TIME_INT, &displayTime);
+       //DateTime receivedTime = _MsgUtil::ConvertTime((time_t *) &displayTime);
+
+       char address[MAX_ADDRESS_VAL_LEN] = {0, };
+       msg_struct_list_s* pAddrList = NULL;
+       msg_struct_t addrInfo = NULL;
+       msg_get_list_handle(newMsg, MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&pAddrList);
+       addrInfo = pAddrList->msg_struct_info[0];
+       msg_get_str_value(addrInfo, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, address, MAX_ADDRESS_VAL_LEN);
+       String senderAddress(address);
+
+       SysLog(NID_MSG, "hMsgHandle: [%d]", hMsgHandle);
+       SysLog(NID_MSG, "msg_body: [%s]", msgText);
+       SysLog(NID_MSG, "port: [%d]", port);
+       //SysLog(NID_MSG, "received time: [%s]", ctime(pReceivedTime));
+
+       SysTryReturnVoidResult(NID_MSG, GetInstance()->__pSmsClientId != null, E_OUT_OF_MEMORY,"failed to get client id.");
+       for ( int i = 0; i < GetInstance()->__pSmsClientId->GetCount(); i++)
+       {
+               Integer * pId = static_cast <Integer*>(GetInstance()->__pSmsClientId->GetAt(i));
+               _SmsService::GetStubInstance()->IncomingSmsCallback(port, displayTime, message, senderAddress,pId->ToInt());
+       }
+}
+
+void
+_IpcCallbackHandler::IncomingCbsMessageCallback(msg_handle_t hMsgHandle, msg_struct_t newMsg, void* pUserParam)
+{
+
+       int tempReceivedTime = 0;
+       DateTime receivedTime;
+       bool etwsNotifiation = false;
+       int messgeId = 0;
+       int serialNumber = 0;
+       int length = 0;
+       int cbsType = -1;
+       Tizen::Base::ByteBuffer msgSerialNumber;
+
+       msg_get_int_value(newMsg, MSG_CB_MSG_RECV_TIME_INT, &tempReceivedTime);
+       receivedTime = __pMessageCallbackHandler->ConvertTime((time_t *) &tempReceivedTime);
+
+       msg_get_int_value(newMsg, MSG_CB_MSG_MSG_ID_INT, &messgeId);
+       msg_get_int_value(newMsg, MSG_CB_MSG_SERIAL_NUM_INT, &serialNumber);
+       msg_get_int_value(newMsg, MSG_CB_MSG_TYPE_INT, &cbsType);
+
+       Tizen::Base::Integer serialno(serialNumber);
+       length = serialno.ToString().GetLength();
+
+       msgSerialNumber.Construct(length);
+       msgSerialNumber.SetInt(0, serialNumber);
+       msgSerialNumber.SetPosition(0);
+
+       if (cbsType == MSG_TYPE_SMS_ETWS_PRIMARY)
+       {
+               int etwsWarningType;
+               char etwsWarningInfo[MESSAGES_ETWS_WARNING_INFO_LEN];
+               Tizen::Base::ByteBuffer msgSecurityInfo;
+               Tizen::Base::ByteBuffer etwsMsgWarningType;
+               msg_get_int_value(newMsg, MSG_CB_MSG_ETWS_WARNING_TYPE_INT, &etwsWarningType);
+               msg_get_str_value(newMsg, MSG_CB_MSG_ETWS_WARNING_SECU_INFO_STR, etwsWarningInfo, MESSAGES_ETWS_WARNING_INFO_LEN);
+
+               String etwsSecurityInfo(etwsWarningInfo);
+               length = etwsSecurityInfo.GetLength();
+               msgSecurityInfo.Construct(length);
+               msgSecurityInfo.SetArray((byte*) etwsWarningInfo, 0, length);
+               msgSecurityInfo.SetPosition(0);
+
+               Tizen::Base::Integer warningtype(etwsWarningType);
+               length = warningtype.ToString().GetLength();
+
+               etwsMsgWarningType.Construct(length);
+               etwsMsgWarningType.SetInt(0, etwsWarningType);
+               etwsMsgWarningType.SetPosition(0);
+
+               etwsNotifiation = true;
+
+               SysLog(NID_MSG, "cbs etwsWarningType: [%d]", etwsWarningType);
+
+               SysTryReturnVoidResult(NID_MSG, GetInstance()->__pCbsEtwsClientId != null, E_OUT_OF_MEMORY,"failed to get client id.");
+               for ( int i = 0; i < GetInstance()->__pCbsEtwsClientId->GetCount(); i++)
+               {
+                       Integer * pId = static_cast <Integer*>(GetInstance()->__pCbsEtwsClientId->GetAt(i));
+                       _SmsService::GetStubInstance()->IncomingEtwsCallback(tempReceivedTime, msgSerialNumber, msgSecurityInfo, messgeId, etwsMsgWarningType, pId->ToInt());
+               }
+
+
+       }
+       else
+       {
+               int dataCodingScheme = 0;
+               int msgSize = 0;
+
+               msg_get_int_value(newMsg, MSG_CB_MSG_CB_TEXT_LEN_INT, &msgSize);
+               char msgBody[msgSize + 1];
+               memset(msgBody, 0, msgSize + 1);
+               msg_get_str_value(newMsg, MSG_CB_MSG_CB_TEXT_STR, msgBody, msgSize + 1);
+               String message(msgBody);       // porting char* to String
+
+               msg_get_int_value(newMsg, MSG_CB_MSG_DCS_INT, &dataCodingScheme);
+               Tizen::Base::Integer dataCodingSchemeTemp(dataCodingScheme);
+
+               //language type of cbs message
+               String messageLanguage(L"");
+               byte higherNibble = dataCodingScheme & 0xf0;
+               byte lowerNibble = dataCodingScheme & 0x0f;
+
+               //check higher nibble
+               // if higher nibble 0000
+               if (higherNibble == 0x00)
+               {
+                       messageLanguage = GetCbsLanguageType(lowerNibble);
+               }
+               else if (higherNibble == 0x01)
+               {
+                       // if higher nibble is 0001, get language type from framework
+                       int len = 15;
+                       char type[len + 1];
+                       memset(type, 0, len + 1);
+                       msg_get_str_value(newMsg, MSG_CB_MSG_LANGUAGE_TYPE_STR, type, len);
+                       messageLanguage = String(type);
+               }
+               else if (higherNibble == 0x20 && lowerNibble == 0x00)
+               {
+                       // if 0010 0000
+                       messageLanguage = String(L"CS");
+               }
+               else
+               {
+                       // use empty string
+               }
+
+               SysTryReturnVoidResult(NID_MSG, GetInstance()->__pCbsEtwsClientId != null, E_OUT_OF_MEMORY,"failed to get client id.");
+               for ( int i = 0; i < GetInstance()->__pCbsEtwsClientId->GetCount(); i++)
+               {
+                       Integer * pId = static_cast <Integer*>(GetInstance()->__pCbsEtwsClientId->GetAt(i));
+                       _SmsService::GetStubInstance()->IncomingCbsCallback(message, msgSerialNumber, tempReceivedTime, messgeId, dataCodingScheme, messageLanguage, pId->ToInt());
+               }
+
+               SysLog(NID_MSG, "cbs msg_body: [%s]", msgBody);
+               SysLog(NID_MSG, "cbs dataCodingScheme: [%d]", dataCodingScheme);
+               SysLog(NID_MSG, "cbs languageType: [%ls]", messageLanguage.GetPointer());
+       }
+
+       SysLog(NID_MSG, "cbs msg_id: [%d]", messgeId);
+       SysLog(NID_MSG, "cbs serialNumber: [%d]", serialNumber);
+       SysLog(NID_MSG, "cbs etwsNotifiation: [%d]", etwsNotifiation);
+}
+
+void
+_IpcCallbackHandler::IncomingWapPushMessageCallback(msg_handle_t hMsgHandle, const char* pHeader, const char* pBody, int bodyLength, void* pUserParam)
+{
+
+       String msgHeader(pHeader);
+       Tizen::Base::ByteBuffer msgBody;
+       msgBody.Construct(bodyLength);
+       msgBody.SetArray((byte*) pBody, 0, bodyLength);
+       msgBody.SetPosition(0);
+
+       SysLog(NID_MSG, "push msg body: [%s]", pBody);
+       SysLog(NID_MSG, "push msg header: [%s]", pHeader);
+       SysLog(NID_MSG, "push body length: [%d]", bodyLength);
+
+       SysTryReturnVoidResult(NID_MSG, _IpcCallbackHandler::GetInstance()->__pWapPushClientId != null, E_OUT_OF_MEMORY, "failed to get client id.");
+       for ( int i = 0; i < _IpcCallbackHandler::GetInstance()->__pWapPushClientId->GetCount(); i++)
+       {
+
+               Integer * pId = static_cast <Integer*>(_IpcCallbackHandler::GetInstance()->__pWapPushClientId->GetAt(i));
+               _WapPushService::GetStubInstance()->IncomingWapPushMessageCallback(msgHeader, msgBody, bodyLength, pId->ToInt());
+       }
+
+}
+
+Tizen::Base::String
+_IpcCallbackHandler::GetCbsLanguageType(byte codingScheme)
+{
+       String languageType(L"");
+
+       switch(codingScheme)
+       {
+       case 0x00:
+               languageType = String(L"DE");
+               break;
+       case 0x01:
+               languageType = String(L"EN");
+               break;
+       case 0x02:
+               languageType = String(L"IT");
+               break;
+       case 0x03:
+               languageType = String(L"FR");
+               break;
+       case 0x04:
+               languageType = String(L"ES");
+               break;
+       case 0x05:
+               languageType = String(L"NL");
+               break;
+       case 0x06:
+               languageType = String(L"SV");
+               break;
+       case 0x07:
+               languageType = String(L"DA");
+               break;
+       case 0x08:
+               languageType = String(L"PT");
+               break;
+       case 0x09:
+               languageType = String(L"FI");
+               break;
+       case 0x0a:
+               languageType = String(L"NO");
+               break;
+       case 0x0b:
+               languageType = String(L"EL");
+               break;
+       case 0x0c:
+               languageType = String(L"TR");
+               break;
+       case 0x0d:
+               languageType = String(L"HU");
+               break;
+       case 0x0e:
+               languageType = String(L"PL");
+               break;
+       case 0x0f:
+               languageType = String(L"");
+               SysLog(NID_MSG, "Language unspecified.");
+               break;
+       default:
+               break;
+       };
+
+       return languageType;
+}
+
+result
+_IpcCallbackHandler::SetWapPushClientId( int id)
+{
+       result r = E_SUCCESS;
+       Integer *pId = new Integer(id);
+
+       if(!__pWapPushClientId)
+       {
+               __pWapPushClientId = new (std::nothrow) Tizen::Base::Collection::ArrayList();
+               SysTryReturnResult(NID_MSG, __pWapPushClientId != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+               __pWapPushClientId->Construct();
+
+       }
+       if(!__pWapPushClientId->Contains(*pId))
+       {
+               r = __pWapPushClientId->Add(*pId);
+               SysLog(NID_MSG, "Client %d",id);                
+               return r;
+       }
+       delete pId;
+       return r;
+}
+
+result
+_IpcCallbackHandler::SetSmsClientId ( int id)
+{
+       result r = E_SUCCESS;
+       Integer *pId = new Integer(id);
+       
+       if(!__pSmsClientId)
+       {
+               __pSmsClientId = new (std::nothrow) Tizen::Base::Collection::ArrayList();
+               SysTryReturnResult(NID_MSG, __pSmsClientId != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+               __pSmsClientId->Construct();
+
+       }
+       if(!__pSmsClientId->Contains(*pId))
+       {
+               r = __pSmsClientId->Add(*pId);
+               SysLog(NID_MSG, "Client %d",id);
+               return r;
+       }
+       delete pId;
+       return r;
+}
+
+
+result
+_IpcCallbackHandler::SetCbsEtwsClientId ( int id)
+{
+       result r = E_SUCCESS;
+       Integer *pId = new Integer(id);
+
+       if(!__pCbsEtwsClientId)
+       {
+               __pCbsEtwsClientId = new (std::nothrow) Tizen::Base::Collection::ArrayList();
+               SysTryReturnResult(NID_MSG, __pCbsEtwsClientId != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+               __pCbsEtwsClientId->Construct();
+
+       }
+       if(!__pCbsEtwsClientId->Contains(*pId))
+       {
+               r = __pCbsEtwsClientId->Add(*pId);
+               SysLog(NID_MSG, "Client %d",id);
+               return r;
+       }
+       delete pId;
+       return r;
+}
+
+result
+_IpcCallbackHandler::RemoveClientId ( int id)
+{
+       result r = E_SUCCESS;
+       Integer *pId = new Integer(id);
+
+       if(__pWapPushClientId)
+       {
+
+               if(__pWapPushClientId->Contains(*pId))
+               {
+                       r = __pWapPushClientId->Remove(*pId);
+                       SysLog(NID_MSG, "WapPush Removed :Client %d",id);
+               }
+
+       }
+       if(__pSmsClientId)
+       {
+
+               if(__pSmsClientId->Contains(*pId))
+               {
+                       r = __pSmsClientId->Remove(*pId);
+                       SysLog(NID_MSG, "SMS Removed :Client %d",id);
+               }
+
+       }
+       if(__pCbsEtwsClientId)
+       {
+
+               if(__pCbsEtwsClientId->Contains(*pId))
+               {
+                       r = __pCbsEtwsClientId->Remove(*pId);
+                       SysLog(NID_MSG, "CbsEtws Removed :Client %d",id);
+               }
+
+       }
+
+       delete pId;
+       return r;
+}
+
+
+result
+_IpcCallbackHandler::ConvertException(int err) const
+{
+       result r = E_SUCCESS;
+
+       switch (err)
+       {
+       case MSG_SUCCESS:
+               r = E_SUCCESS;
+               break;
+
+       case MSG_ERR_INVALID_PARAMETER:
+       case MSG_ERR_INVALID_MESSAGE:
+       case MSG_ERR_NULL_POINTER:
+       case MSG_ERR_NULL_MESSAGE:
+               r = E_INVALID_ARG;
+               break;
+
+       case MSG_ERR_MEMORY_ERROR:
+               r = E_OUT_OF_MEMORY;
+               break;
+
+       case MSG_ERR_SERVER_NOT_READY:
+       case MSG_ERR_TRANSPORT_ERROR:
+       case MSG_ERR_COMMUNICATION_ERROR:
+               r = E_NETWORK_UNAVAILABLE;
+               break;
+
+       case MSG_ERR_NO_SIM:
+               r = E_DEVICE_UNAVAILABLE;
+               break;
+
+       case MSG_ERR_PLUGIN_TAPI_FAILED:
+               r = E_FAILURE;
+               break;
+
+       default:
+               r = E_SYSTEM;
+               break;
+       }
+
+       return r;
+}
+
+Tizen::Base::DateTime
+_IpcCallbackHandler::ConvertTime(time_t* pTime)
+{
+       DateTime dateTime;
+       struct tm* pTempTime = null;
+
+       pTempTime = gmtime(pTime);
+       if (pTempTime)
+       {
+               dateTime.SetValue(pTempTime->tm_year + 1900, pTempTime->tm_mon + 1, pTempTime->tm_mday, pTempTime->tm_hour, pTempTime->tm_min, pTempTime->tm_sec);
+       }
+       return dateTime;
+}
+
+
+} } // Tizen::Messaging
diff --git a/src/messaging/FMsg_IpcCallbackHandler.h b/src/messaging/FMsg_IpcCallbackHandler.h
new file mode 100644 (file)
index 0000000..a58ef53
--- /dev/null
@@ -0,0 +1,227 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FMsg_IpcCallbackHandler.h
+ * @brief              This is the header file for _IpcCallbackHandler class.
+ *
+ * This header file contains declaration of _IpcCallbackHandler class
+ */
+
+#ifndef _FMSG_INTERNAL_SMS_MMS_CALLBACK_HANDLER_H_
+#define _FMSG_INTERNAL_SMS_MMS_CALLBACK_HANDLER_H_
+
+// includes
+#include <FBaseObject.h>
+#include <FBaseColMultiHashMap.h>
+#include <FBaseDateTime.h>
+
+namespace Tizen { namespace Messaging
+{
+
+/**
+* @class       _IpcCallbackHandler
+* @brief       This class provides methods to use the SMS/MMS call back Handler service
+* @since 2.1
+*
+* This class provides methods to use the SMS/MMS call back Handler service . @n
+*/
+
+// forward declaration
+
+class _IpcCallbackHandler
+       : public Tizen::Base::Object
+{
+public:
+       /**
+       * This is the destructor for this class.
+       *
+       * @since 2.1
+       */
+       virtual ~_IpcCallbackHandler(void);
+
+       /**
+       * Initializes the Messaging Hash Map table
+       *
+       * @since                        3.0
+       * @return       An error code
+       * @exception    E_SUCCESS                       The method was successful.
+       * @exception    E_INVALID_ARG                   Input parameter is NULL.
+       * @exception    E_OUT_OF_MEMORY                 Memory error.
+       */
+       result  Construct(void);
+
+       // Operation
+public:
+       /**
+       * Gets the instance of SmsMmsCallbackHandler class.
+       *
+       * @since 2.1
+       * @return                       instance of SmsMmsCallbackHandler class
+       */
+       static _IpcCallbackHandler* GetInstance(void);
+
+       /**
+       * gets the Message Handle for SMS/MMS operation.
+       *
+       * @since 3.0
+       * @return       An error code
+       * @param[in]    messageHandle                   message Handle
+       * @exception    MSG_SUCCESS                     The method was successful.
+       * @exception    MSG_ERR_NULL_POINTER            Input parameter is NULL.
+       * @exception    MSG_ERR_MEMORY_ERROR            Memory error.
+       */
+       int OpenMessageHandle(msg_handle_t& messageHandle);
+
+       /**
+       * gets the Message Handle for Cbs message operation.
+       *
+       * @since 3.0
+       * @return       An error code
+       * @param[in]    cbsSettingsHandle               cbs message Handle
+       * @exception    MSG_SUCCESS                     The method was successful.
+       * @exception    MSG_ERR_NULL_POINTER            Input parameter is NULL.
+       * @exception    MSG_ERR_MEMORY_ERROR            Memory error.
+       */
+       int OpenCbsSettingsHandle(msg_struct_t& cbsSettingsHandle);
+
+       // Adds a CBS channel with specified parameters.
+       result AddCbsChannel(int from, int to, const Tizen::Base::String& name, bool activate);
+
+       // Removes a CBS channel with specified parameters.
+       result RemoveCbsChannel(int from, int to);
+
+       // Searches a CBS channel with specified parameters and returns index of channel found.
+       result SearchCbsChannel(int from, int to, int& index);
+
+       // Updates a CBS channel with specified parameters.
+       result UpdateCbsChannel(int from, int to, Tizen::Base::String name, bool activate);
+
+       // Gets a CBS channel data with specified index.
+       result GetCbsChannel(int index, int& from, int& to, Tizen::Base::String& name, bool& activate);
+
+       // Gets a CBS channel count.
+       result GetCbsChannelsCount(int& count);
+
+       /**
+       * loads the Cbs channels list.
+       *
+       * @since 3.0
+       * @return       An error code
+       * @exception    E_SUCCESS                       The method was successful.
+       * @exception    E_INVALID_ARG                   Input parameter is NULL.
+       * @exception    E_OUT_OF_MEMORY                 Memory error.
+       */
+       result LoadCbsSettings();
+
+       /**
+       * saves the Cbs channels list.
+       *
+       * @since 3.0
+       * @return       An error code
+       * @exception    E_SUCCESS                       The method was successful.
+       * @exception    E_INVALID_ARG                   Input parameter is NULL.
+       * @exception    E_OUT_OF_MEMORY                 Memory error.
+       */
+       result SaveCbsSettings();
+
+       /**
+       * closes the CBS Message Handle.
+       *
+       * @since 3.0
+       * @return       An error code
+       * @exception    MSG_SUCCESS                     The method was successful.
+       * @exception    MSG_ERR_NULL_POINTER            Input parameter is NULL.
+       * @exception    MSG_ERR_MEMORY_ERROR            Memory error.
+       */
+       static void CloseCbsSettingsHandle(void);
+
+       /**
+       * closes the Message Handle for SMS/MMS operation.
+       *
+       * @since 3.0
+       * @return       An error code
+       * @exception    MSG_SUCCESS                     The method was successful.
+       * @exception    MSG_ERR_NULL_POINTER            Input parameter is NULL.
+       * @exception    MSG_ERR_MEMORY_ERROR            Memory error.
+       */
+       int CloseMessageHandle(void);
+
+
+       static void IncomingSmsCallback(msg_handle_t hMsgHandle, msg_struct_t newMsg, void* pUserParam);
+
+       /**
+       * Sets the __incomingSmsCallbackRegistered flag.
+       *
+       * @since                        3.0
+       * @param[in]    incomingSmsCallbackRegistered      SMS registered flag
+       */
+       void SetInComingSmsCallback(bool incomingSmsCallbackRegistered);
+
+       /**
+       * Sets the Cbs And Etws UserEvent.
+       *
+       * @since                        3.0
+       * @param[in]    msgType     message type
+       * @param[in]    pEvent      message Event
+       */
+
+       // for incoming CBS/Etws
+       static void IncomingCbsMessageCallback(msg_handle_t hMsgHandle, msg_struct_t newMsg, void* pUserParam);
+
+       // for incoming Wap push
+       static void IncomingWapPushMessageCallback(msg_handle_t hMsgHandle, const char* pHeader, const char* pBody, int bodyLength, void* pUserParam);
+
+       //get cb message language type
+       static Tizen::Base::String GetCbsLanguageType(byte codingScheme);
+
+       result SetWapPushClientId( int id);
+       result SetSmsClientId ( int id);
+       result SetCbsEtwsClientId ( int id);
+       result RemoveClientId ( int id);
+       Tizen::Base::DateTime ConvertTime(time_t* pTime);
+
+       // Life cycle
+private:
+       /**
+       *       This is the default constructor for this class.
+       *
+       * @since 2.1
+       */
+       _IpcCallbackHandler(void);
+
+       result ConvertException(int err) const;
+
+private:
+       static _IpcCallbackHandler* __pMessageCallbackHandler;
+       msg_handle_t __msgHandle;
+       msg_struct_t __cbsSettingsHandle;
+       msg_struct_list_s* __pCbsChannelList;
+       Tizen::Base::Collection::ArrayList* __pTempCbsChannelList;
+       bool   __callbackRegistered;
+       bool   __incomingSmsCallbackRegistered;
+       Tizen::Base::Collection::MultiHashMap __messageMap;
+       Tizen::Base::Runtime::Mutex  __msgMutex;
+       Tizen::Base::Collection::ArrayList* __pWapPushClientId;
+       Tizen::Base::Collection::ArrayList* __pSmsClientId;
+       Tizen::Base::Collection::ArrayList* __pCbsEtwsClientId;
+       static bool __destroyed;
+
+}; // _IpcCallbackHandler
+
+} } // Tizen::Messaging
+
+#endif // _FMSG_INTERNAL_SMS_MMS_CALLBACK_HANDLER_H_
diff --git a/src/messaging/FMsg_MessagingIpcStub.cpp b/src/messaging/FMsg_MessagingIpcStub.cpp
new file mode 100644 (file)
index 0000000..9fccf76
--- /dev/null
@@ -0,0 +1,601 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FMsg_MessagingIpcStub.cpp
+ * @brief   This is the implementation file for the %_MessagingIpcStub class.
+ */
+#include <msg.h>
+#include <msg_transport.h>
+#include <msg_storage.h>
+#include <FBaseSysLog.h>
+#include <FIo_IpcServer.h>
+#include <FSec_AccessController.h>
+#include <FIo_IpcCommonParamTraits.h>
+#include "FMsg_MessagingMessageTypes.h"
+#include "FMsg_MessagingIpcStub.h"
+#include "FMsg_IpcCallbackHandler.h"
+#include "FMsg_WapPushService.h"
+#include "FMsg_SmsService.h"
+#include "FMsg_CbsMaker.h"
+
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Messaging;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Messaging
+{
+
+_MessagingIpcStub::_MessagingIpcStub(void)
+       :__pWapPushService(null)
+       ,__pSmsService(null)
+       ,__pIpcServer(null)
+       ,__pCbsList(null)
+{
+}
+
+_MessagingIpcStub::~_MessagingIpcStub(void)
+{
+
+       if (__pIpcServer)
+       {
+               __pIpcServer->Stop();
+               delete __pIpcServer;
+               __pIpcServer = null;
+       }
+       if (__pWapPushService)
+       {
+               delete __pWapPushService;
+               __pWapPushService = null;
+       }
+       if (__pSmsService)
+       {
+               delete __pSmsService;
+               __pSmsService = null;
+       }
+       if (__pCbsList)
+       {
+               __pCbsList->RemoveAll(true);
+               delete __pCbsList;
+               __pCbsList = null;
+       }
+
+}
+
+result
+_MessagingIpcStub::Construct(void)
+{
+       result r = E_SUCCESS;
+
+       __pIpcServer = new (std::nothrow) _IpcServer;
+       SysTryCatch(NID_MSG, __pIpcServer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = __pIpcServer->Construct(MESSAGING_IPC_SERVER_NAME, *this);
+       SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM,
+                       "[%s] A system error has been occurred. Failed to construct IpcServer.", GetErrorMessage(E_SYSTEM));
+
+       __pWapPushService = _WapPushService::GetInstance(this);
+       SysTryCatch(NID_MSG, __pWapPushService != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __pSmsService = _SmsService::GetInstance(this);
+       SysTryCatch(NID_MSG, __pSmsService != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __pCbsList = new (std::nothrow) Tizen::Base::Collection::ArrayList;
+       SysTryCatch(NID_MSG, __pCbsList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       __pCbsList->Construct();
+
+       SysLog(NID_MSG, "_MessagingIpcStub Construct.");
+
+       return r;
+
+CATCH:
+       if (__pIpcServer)
+       {
+               __pIpcServer->Stop();
+               delete __pIpcServer;
+               __pIpcServer = null;
+       }
+       if (__pWapPushService)
+       {
+               delete __pWapPushService;
+               __pWapPushService = null;
+       }
+       if (__pSmsService)
+       {
+               delete __pSmsService;
+               __pSmsService = null;
+       }
+       if (__pCbsList)
+       {
+               delete __pCbsList;
+               __pCbsList = null;
+       }
+
+       return r;
+}
+
+void
+_MessagingIpcStub::OnIpcServerStarted(const Tizen::Io::_IpcServer& server)
+{
+       SysLog(NID_MSG, "_MessagingIpcStub started.");
+}
+
+void
+_MessagingIpcStub::OnIpcServerStopped(const Tizen::Io::_IpcServer& server)
+{
+       SysLog(NID_MSG, "_MessagingIpcStub stopped.");
+}
+
+void
+_MessagingIpcStub::OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId)
+{
+       SysLog(NID_MSG, "Connected with clientId[%d].", clientId);
+}
+
+void
+_MessagingIpcStub::OnIpcClientDisconnected(const Tizen::Io::_IpcServer&server, int clientId)
+{
+
+       _IpcCallbackHandler::GetInstance()->RemoveClientId(clientId);
+       SysLog(NID_MSG, "Disconnected with clientId[%d].", clientId);
+}
+
+void
+_MessagingIpcStub::OnIpcRequestReceived(Tizen::Io::_IpcServer& server, const IPC::Message& message)
+{
+       IPC_BEGIN_MESSAGE_MAP(_MessagingIpcStub, message)
+       IPC_MESSAGE_HANDLER(MessagingMsgStart_addWapPushEventListener, OnIpcAddWapPushEventListener, &server)
+       //IPC_MESSAGE_HANDLER(MessagingMsgStart_removeWapPushEventListener, OnIpcRemoveWapPushEventListener, &server)
+       IPC_MESSAGE_HANDLER(MessagingMsgStart_registerCondition, OnIpcRegisterCondition, &server)
+       IPC_MESSAGE_HANDLER(MessagingMsgStart_unregisterCondition, OnIpcUnregisterCondition, &server)
+       IPC_MESSAGE_HANDLER(MessagingMsgStart_openCbsHandle, OnIpcOpenMsgHandle, &server)
+       IPC_MESSAGE_HANDLER(MessagingMsgStart_openMsgHandle, OnIpcOpenCbsHandle, &server)
+       IPC_MESSAGE_HANDLER(MessagingMsgStart_addSmsEventListener, OnIpcAddSmsEventListener, &server)
+       IPC_MESSAGE_HANDLER(MessagingMsgStart_addCbsEtwsEventListener, OnIpcAddCbsEtwsEventListener, &server)
+
+       IPC_MESSAGE_HANDLER(MessagingMsgStart_setSavingToCbsBoxEnabled, OnIpcSetSavingToCbsBoxEnabled, &server)
+       IPC_MESSAGE_HANDLER(MessagingMsgStart_isCbsEnabled, OnIpcIsCbsEnabled, &server)
+       IPC_MESSAGE_HANDLER(MessagingMsgStart_setCbsEnabled, OnIpcSetCbsEnabled, &server)
+       IPC_MESSAGE_HANDLER(MessagingMsgStart_addCbsChannel, OnIpcAddCbsChannel, &server)
+       IPC_MESSAGE_HANDLER(MessagingMsgStart_removeCbsChannel, OnIpcRemoveCbsChannel, &server)
+       IPC_MESSAGE_HANDLER(MessagingMsgStart_getCbsChannelN, OnIpcGetCbsChannelN, &server)
+       IPC_MESSAGE_HANDLER(MessagingMsgStart_getCbsChannelListN, OnIpcGetCbsChannelListN, &server)
+       IPC_MESSAGE_HANDLER(MessagingMsgStart_updateCbsChannel, OnIpcUpdateCbsChannel, &server)
+       IPC_END_MESSAGE_MAP()
+}
+
+
+void
+_MessagingIpcStub::OnIpcAddWapPushEventListener(const Tizen::Base::String& wapApplicationId, unsigned long* pResult)
+{
+
+       SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls",
+                       __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer());
+       String packageId = __pIpcServer->GetClientPackageId();
+       *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_WAPPUSH);
+
+       if (*pResult != E_SUCCESS)
+       {
+               *pResult = E_PRIVILEGE_DENIED;
+               SysLogException(NID_MSG, E_PRIVILEGE_DENIED,
+                               "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+       }
+       else
+       {
+
+               *pResult = __pWapPushService->AddWapPushEventListener(wapApplicationId, __pIpcServer->GetClientId());
+
+       }
+
+}
+
+void
+_MessagingIpcStub::IncomingWapPushMessageCallback(Tizen::Base::String &header, Tizen::Base::ByteBuffer  &body, int bodyLength, int clientId)
+{
+
+       SysLog(NID_MSG, "IncomingWapPushMessageCallback with clientId : %d", clientId);
+       IPC::Message* pMessage = new (std::nothrow) MessagingMsgStart_wapPushEventCallBack(header, body, bodyLength);
+       SysTryReturnVoidResult(NID_MSG, pMessage != null , E_OUT_OF_MEMORY, "Memory allocation failed.");
+       __pIpcServer->SendResponse(clientId, *pMessage);
+       SysLog(NID_MSG, "IncomingWapPushMessageCallback End clientId : %d", clientId);
+
+}
+
+/*
+void
+_MessagingIpcStub::OnIpcRemoveWapPushEventListener(const Tizen::Base::String& wapApplicationId, unsigned long* pResult)
+{
+
+       SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls",
+                       __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer());
+       String packageId = __pIpcServer->GetClientPackageId();
+       *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_WAPPUSH);
+
+       if (*pResult != E_SUCCESS)
+       {
+               *pResult = E_PRIVILEGE_DENIED;
+               SysLogException(NID_MSG, E_PRIVILEGE_DENIED,
+                               "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+       }
+       else
+       {
+
+               *pResult = __pWapPushService->RemoveWapPushEventListener(wapApplicationId);
+
+       }
+}
+*/
+void
+_MessagingIpcStub::OnIpcRegisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType, unsigned long* pResult)
+{
+
+       SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls",
+                       __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer());
+       String packageId = __pIpcServer->GetClientPackageId();
+    *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_WAPPUSH);
+
+       if (*pResult != E_SUCCESS)
+       {
+               *pResult = E_PRIVILEGE_DENIED;
+               SysLogException(NID_MSG, E_PRIVILEGE_DENIED,
+                               "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+       }
+       else
+       {
+               *pResult = __pWapPushService->RegisterCondition(wapApplicationId,contentType);
+       }
+
+}
+
+void
+_MessagingIpcStub::OnIpcUnregisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType, unsigned long* pResult)
+{
+
+       SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls",
+                       __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer());
+       String packageId = __pIpcServer->GetClientPackageId();
+       *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_WAPPUSH);
+
+       if (*pResult != E_SUCCESS)
+       {
+               *pResult = E_PRIVILEGE_DENIED;
+               SysLogException(NID_MSG, E_PRIVILEGE_DENIED,
+                               "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+       }
+       else
+       {
+
+               *pResult = __pWapPushService->UnregisterCondition(wapApplicationId, contentType);
+
+       }
+
+
+
+}
+
+void
+_MessagingIpcStub::OnIpcOpenMsgHandle(unsigned long* pResult)
+{
+
+       SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls",
+                       __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer());
+       String packageId = __pIpcServer->GetClientPackageId();
+
+       *pResult = __pSmsService->OpenMsgHandle();
+
+
+
+}
+
+
+void
+_MessagingIpcStub::OnIpcOpenCbsHandle(unsigned long* pResult)
+{
+
+       SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls",
+                       __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer());
+       String packageId = __pIpcServer->GetClientPackageId();
+
+       *pResult = __pSmsService->OpenCbsHandle();
+
+
+
+}
+
+void
+_MessagingIpcStub::OnIpcAddSmsEventListener(int port, unsigned long* pResult)
+{
+
+       SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls",
+                       __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer());
+       String packageId = __pIpcServer->GetClientPackageId();
+       *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_SMSTRIGGER);
+       if (*pResult != E_SUCCESS)
+       {
+               *pResult = E_PRIVILEGE_DENIED;
+               SysLogException(NID_MSG, E_PRIVILEGE_DENIED,
+                               "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+       }
+       else
+       *pResult = __pSmsService->AddSmsEventListener(port, __pIpcServer->GetClientId());
+
+}
+
+void
+_MessagingIpcStub::IncomingSmsCallback(int port, int displayTime, Tizen::Base::String &message, Tizen::Base::String &senderAddress, int clientId)
+{
+
+       SysLog(NID_MSG, "IncomingSmsCallback with clientId : %d", clientId);
+       IPC::Message* pMessage = new (std::nothrow) MessagingMsgStart_incomingSmsCallback(port, displayTime, message, senderAddress);
+       SysTryReturnVoidResult(NID_MSG, pMessage != null , E_OUT_OF_MEMORY, "Memory allocation failed.");
+       __pIpcServer->SendResponse(clientId, *pMessage);
+
+}
+
+void
+_MessagingIpcStub::OnIpcAddCbsEtwsEventListener(bool enabled, unsigned long* pResult)
+{
+
+       SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls",
+                       __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer());
+       String packageId = __pIpcServer->GetClientPackageId();
+       *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_CELLBROADCAST);
+       if (*pResult != E_SUCCESS)
+       {
+               *pResult = E_PRIVILEGE_DENIED;
+               SysLogException(NID_MSG, E_PRIVILEGE_DENIED,
+                               "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+       }
+       else
+       *pResult = __pSmsService->AddCbsEtwsEventListener(enabled, __pIpcServer->GetClientId());
+       SysLog(NID_MSG, "OnIpcAddCbsEtwsEventListener : %d", *pResult);
+
+}
+
+
+void
+_MessagingIpcStub::IncomingEtwsCallback(int tempReceivedTime, Tizen::Base::ByteBuffer &msgSerialNumber, Tizen::Base::ByteBuffer &msgSecurityInfo, int messgeId, Tizen::Base::ByteBuffer &etwsMsgWarningType, int clientId)
+{
+
+       SysLog(NID_MSG, "IncomingEtwsCallback with clientId : %d", clientId);
+       IPC::Message* pMessage = new (std::nothrow) MessagingMsgStart_incomingEtwsCallback(tempReceivedTime, msgSerialNumber, msgSecurityInfo, messgeId, etwsMsgWarningType);
+       SysTryReturnVoidResult(NID_MSG, pMessage != null , E_OUT_OF_MEMORY, "Memory allocation failed.");
+       __pIpcServer->SendResponse(clientId, *pMessage);
+
+
+
+}
+
+void
+_MessagingIpcStub::IncomingCbsCallback(Tizen::Base::String &message, Tizen::Base::ByteBuffer &msgSerialNumber, int tempReceivedTime, int messgeId, int dataCodingScheme, Tizen::Base::String &messageLanguage, int clientId)
+{
+
+       SysLog(NID_MSG, "IncomingCbsCallback with clientId : %d", clientId);
+       IPC::Message* pMessage = new (std::nothrow) MessagingMsgStart_incomingCbsCallback(message, msgSerialNumber, tempReceivedTime, messgeId, dataCodingScheme, messageLanguage);
+       SysTryReturnVoidResult(NID_MSG, pMessage != null , E_OUT_OF_MEMORY, "Memory allocation failed.");
+       __pIpcServer->SendResponse(clientId, *pMessage);
+
+
+
+}
+
+void
+_MessagingIpcStub::OnIpcSetSavingToCbsBoxEnabled(bool enable, unsigned long* pResult)
+{
+
+       SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls",
+                       __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer());
+       String packageId = __pIpcServer->GetClientPackageId();
+       *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_CELLBROADCAST);
+       if (*pResult != E_SUCCESS)
+       {
+               *pResult = E_PRIVILEGE_DENIED;
+               SysLogException(NID_MSG, E_PRIVILEGE_DENIED,
+                               "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+       }
+       else
+       {
+               *pResult = __pSmsService->SetSavingToCbsBoxEnabled(enable);
+       }
+
+}
+
+
+void
+_MessagingIpcStub::OnIpcIsCbsEnabled(bool *isCbsEnabled, unsigned long* pResult)
+{
+
+       SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls",
+                       __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer());
+       String packageId = __pIpcServer->GetClientPackageId();
+       *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_CELLBROADCAST);
+       if (*pResult != E_SUCCESS)
+       {
+               *pResult = E_PRIVILEGE_DENIED;
+               SysLogException(NID_MSG, E_PRIVILEGE_DENIED,
+                               "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+       }
+       else
+       {
+
+               *isCbsEnabled = __pSmsService->IsCbsEnabled();
+               *pResult = GetLastResult();
+       }
+
+}
+
+
+void
+_MessagingIpcStub::OnIpcSetCbsEnabled(bool enable, unsigned long* pResult)
+{
+
+       SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls",
+                       __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer());
+       String packageId = __pIpcServer->GetClientPackageId();
+       *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_CELLBROADCAST);
+       if (*pResult != E_SUCCESS)
+       {
+               *pResult = E_PRIVILEGE_DENIED;
+               SysLogException(NID_MSG, E_PRIVILEGE_DENIED,
+                               "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+       }
+       else
+       {
+               *pResult = __pSmsService->SetCbsEnabled(enable);
+       }
+
+
+}
+
+
+void
+_MessagingIpcStub::OnIpcAddCbsChannel(int from, int to, const Tizen::Base::String& name, bool activate, unsigned long* pResult)
+{
+
+       SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls",
+                       __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer());
+       String packageId = __pIpcServer->GetClientPackageId();
+       *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_CELLBROADCAST);
+       if (*pResult != E_SUCCESS)
+       {
+               *pResult = E_PRIVILEGE_DENIED;
+               SysLogException(NID_MSG, E_PRIVILEGE_DENIED,
+                               "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+       }
+       else
+       {
+               *pResult = __pSmsService->AddCbsChannel(from, to, name, activate);
+       }
+
+
+}
+
+
+
+void
+_MessagingIpcStub::OnIpcRemoveCbsChannel(int from, int to, unsigned long* pResult)
+{
+
+       SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls",
+                       __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer());
+       String packageId = __pIpcServer->GetClientPackageId();
+       *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_CELLBROADCAST);
+       if (*pResult != E_SUCCESS)
+       {
+               *pResult = E_PRIVILEGE_DENIED;
+               SysLogException(NID_MSG, E_PRIVILEGE_DENIED,
+                               "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+       }
+       else
+       {
+               *pResult = __pSmsService->RemoveCbsChannel(from, to);
+       }
+
+
+}
+
+
+void
+_MessagingIpcStub::OnIpcGetCbsChannelN(int from, int to, bool *isActive, Tizen::Base::String *channelName, unsigned long* pResult)
+{
+
+       SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls",
+                       __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer());
+       String packageId = __pIpcServer->GetClientPackageId();
+       *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_CELLBROADCAST);
+       if (*pResult != E_SUCCESS)
+       {
+               *pResult = E_PRIVILEGE_DENIED;
+               SysLogException(NID_MSG, E_PRIVILEGE_DENIED,
+                               "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+       }
+       else
+       {       _CbsMaker *pTemp = const_cast<_CbsMaker*>(__pSmsService->GetCbsChannelN(from, to));
+
+               if (null != pTemp)
+               {
+                       *isActive = pTemp->IsActivated();
+                       *channelName = pTemp->GetName();
+                       delete pTemp;
+               }
+               else
+               {
+                       *isActive = FALSE;
+                       *channelName =L"";
+
+
+               }
+               *pResult = GetLastResult();
+
+       }
+
+}
+
+void
+_MessagingIpcStub::OnIpcGetCbsChannelListN(Tizen::Base::Collection::ArrayList *pCbsList, unsigned long* pResult)
+{
+
+       SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls, Previous Cbs Count : %d",
+                       __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer(), __pCbsList->GetCount());
+
+       __pCbsList->RemoveAll(true);
+       String packageId = __pIpcServer->GetClientPackageId();
+       *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_CELLBROADCAST);
+
+       if (*pResult != E_SUCCESS)
+       {
+               *pResult = E_PRIVILEGE_DENIED;
+               SysLogException(NID_MSG, E_PRIVILEGE_DENIED,
+                               "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+       }
+       else
+       {
+
+               *pResult = __pSmsService->GetCbsChannelListN(pCbsList);
+               __pCbsList->AddItems(*pCbsList);
+       }
+
+}
+
+void
+_MessagingIpcStub::OnIpcUpdateCbsChannel(int from, int to, const Tizen::Base::String &name, bool isChannelEnable, unsigned long* pResult)
+{
+       SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls",
+                       __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer());
+       String packageId = __pIpcServer->GetClientPackageId();
+       *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_CELLBROADCAST);
+       if (*pResult != E_SUCCESS)
+       {
+               *pResult = E_PRIVILEGE_DENIED;
+               SysLogException(NID_MSG, E_PRIVILEGE_DENIED,
+                               "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+       }
+       else
+       *pResult = _IpcCallbackHandler::GetInstance()->UpdateCbsChannel(from, to, name, isChannelEnable);
+
+}
+
+
+}}
+
+
diff --git a/src/messaging/FMsg_MessagingIpcStub.h b/src/messaging/FMsg_MessagingIpcStub.h
new file mode 100644 (file)
index 0000000..59a1425
--- /dev/null
@@ -0,0 +1,112 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file       FMsg_MessagingIpcStub.h
+ * @brief      This is the header file for the %_MessagingIpcStub class.
+ *
+ * This header file contains the declarations of the %_MessagingIpcStub class.
+ */
+
+#ifndef _MESSAGING_IPC_STUB_H_
+#define _MESSAGING_IPC_STUB_H_
+
+#include <FIo_IIpcServerEventListener.h>
+
+namespace Tizen { namespace Base {
+class String;
+} }
+
+namespace Tizen { namespace Io {
+class _IpcServer;
+} }
+
+namespace Tizen { namespace Messaging {
+
+class _WapPushService;
+class _SmsService;
+class _CbsMaker;
+
+
+/**
+ * @class      _MessagingIpcStub
+ * @brief      This class represents an IPC stub for the Connectivity daemon service.
+ *
+ * @since 2.1
+ *
+ * This class represents an IPC stub for the wap push.
+ */
+class _MessagingIpcStub
+    : public Tizen::Base::Object
+    , public Tizen::Io::_IIpcServerEventListener
+{
+public:
+       _MessagingIpcStub(void);
+       virtual ~_MessagingIpcStub(void);
+
+       result Construct(void);
+
+       virtual void OnIpcServerStarted(const Tizen::Io::_IpcServer& server);
+       virtual void OnIpcServerStopped(const Tizen::Io::_IpcServer& server);
+       virtual void OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId);
+       virtual void OnIpcClientDisconnected(const Tizen::Io::_IpcServer&server, int clientId);
+       virtual void OnIpcRequestReceived(Tizen::Io::_IpcServer& server, const IPC::Message& message);
+       void IncomingWapPushMessageCallback(Tizen::Base::String &header, Tizen::Base::ByteBuffer  &body, int bodyLength, int clientId);
+       void IncomingSmsCallback(int port, int displayTime, Tizen::Base::String &message, Tizen::Base::String &senderAddress, int clientId);
+       void IncomingEtwsCallback(int tempReceivedTime, Tizen::Base::ByteBuffer &msgSerialNumber, Tizen::Base::ByteBuffer &msgSecurityInfo, int messgeId, Tizen::Base::ByteBuffer &etwsMsgWarningType, int clientId);
+       void IncomingCbsCallback(Tizen::Base::String &message, Tizen::Base::ByteBuffer &msgSerialNumber, int tempReceivedTime, int messgeId, int dataCodingScheme, Tizen::Base::String &messageLanguage, int clientId);
+
+
+
+private:
+
+       void OnIpcAddWapPushEventListener(const Tizen::Base::String& wapApplicationId, unsigned long* pResult);
+       //void OnIpcRemoveWapPushEventListener(const Tizen::Base::String& wapApplicationId, unsigned long* pResult);
+       void OnIpcRegisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType, unsigned long* pResult);
+       void OnIpcUnregisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType, unsigned long* pResult);
+       void OnIpcOpenMsgHandle(unsigned long* pResult);
+       void OnIpcOpenCbsHandle(unsigned long* pResult);
+       void OnIpcAddSmsEventListener(int port, unsigned long* pResult);
+       void OnIpcAddCbsEtwsEventListener(bool enabled, unsigned long* pResult);
+
+       void OnIpcSetSavingToCbsBoxEnabled(bool enable, unsigned long* pResult);
+       void OnIpcIsCbsEnabled(bool *isCbsEnabled, unsigned long* pResult);
+       void OnIpcSetCbsEnabled(bool enable, unsigned long* pResult);
+       void OnIpcAddCbsChannel(int from, int to, const Tizen::Base::String& name, bool activate, unsigned long* pResult);
+       void OnIpcRemoveCbsChannel(int from, int to, unsigned long* pResult);
+       void OnIpcGetCbsChannelN(int from, int to, bool *isActive, Tizen::Base::String *channelName, unsigned long* pResult);
+       void OnIpcGetCbsChannelListN(Tizen::Base::Collection::ArrayList *pCbsList, unsigned long* pResult);
+       void OnIpcUpdateCbsChannel(int from, int to, const Tizen::Base::String &name, bool isChannelEnable, unsigned long* pResult);
+
+
+
+
+       _MessagingIpcStub(const _MessagingIpcStub& rhs);
+       _MessagingIpcStub& operator =(const _MessagingIpcStub& rhs);
+
+private:
+       _WapPushService *__pWapPushService;
+       _SmsService * __pSmsService;
+       Tizen::Io::_IpcServer* __pIpcServer;
+       Tizen::Base::Collection::ArrayList *__pCbsList;
+       friend class _WapPushService;
+       friend class _SmsService;
+
+};
+}}//Tizen::Messasing
+#endif // _MESSAGING_IPC_STUB_H_
+
diff --git a/src/messaging/FMsg_SmsService.cpp b/src/messaging/FMsg_SmsService.cpp
new file mode 100644 (file)
index 0000000..7c3915a
--- /dev/null
@@ -0,0 +1,436 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FMsg_SmsService.cpp
+ * @brief              This is the implementation file for the %_SmsService class.
+ *
+ * This file contains the implementation of the %_SmsService class.
+ */
+
+// OAF headers
+#include <unique_ptr.h>
+#include <msg.h>
+#include <msg_transport.h>
+#include <msg_storage.h>
+#include <dbus/dbus.h>
+#include <email-api.h>
+#include <FBaseSysLog.h>
+#include <FBaseInteger.h>
+#include <FBase_StringConverter.h>
+#include <FBaseColAllElementsDeleter.h>
+#include "FMsg_MessagingIpcStub.h"
+#include "FMsg_IpcCallbackHandler.h"
+#include "FMsg_SmsService.h"
+#include "FMsg_CbsMaker.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Messaging;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Messaging
+{
+
+_SmsService *_SmsService::__pSelf = null;
+
+
+_SmsService::_SmsService(void)
+       : __isConstructed(false)
+       , __isCbsSaveEnabled(true)
+       , __pSmsTriggerEventList(null)
+       , __msgHandle(0)
+       , __cbsSettingsHandle(0)
+       ,__pStub(0)
+{
+}
+
+_SmsService::~_SmsService(void)
+{
+
+
+       if (__pSmsTriggerEventList)
+       {
+               if (__pSmsTriggerEventList->GetCount() > 0)
+               {
+                       __pSmsTriggerEventList->RemoveAll(true);
+               }
+               delete __pSmsTriggerEventList;
+               __pSmsTriggerEventList = null;
+       }
+
+       if (_IpcCallbackHandler::GetInstance())
+       {
+               _IpcCallbackHandler::GetInstance()->CloseMessageHandle();
+       }
+
+       __isConstructed = false;
+}
+
+_SmsService*
+_SmsService::GetInstance()
+{
+
+       return _SmsService::__pSelf;
+
+}
+
+
+_SmsService*
+_SmsService::GetInstance(_MessagingIpcStub *pStub)
+{
+       if (pStub)
+       {
+               SysTryReturnResult(NID_MSG, _SmsService::__pSelf == null, null, "_SmsService already created.");
+
+               _SmsService::__pSelf = new (std::nothrow)_SmsService();
+               SysTryReturnResult(NID_MSG, _SmsService::__pSelf != null, null, "_SmsService creation failed.");
+               _SmsService::__pSelf->__pStub = pStub;
+               std::atexit(DestroyInstance);
+               return _SmsService::__pSelf;
+
+       }
+       return _SmsService::__pSelf;
+
+}
+
+ _MessagingIpcStub*
+ _SmsService::GetStubInstance()
+ {
+        if(_SmsService::__pSelf)
+        {
+
+                return _SmsService::__pSelf->__pStub;
+        }
+
+       return null;
+
+ }
+
+
+ void
+ _SmsService::DestroyInstance()
+ {
+
+   if(_SmsService::__pSelf)
+
+   {
+      delete _SmsService::__pSelf ;
+      _SmsService::__pSelf = null;
+
+    }
+ }
+
+result
+_SmsService::OpenMsgHandle()
+{
+       result r = E_SUCCESS;
+       int err = MSG_SUCCESS;
+       __isConstructed = true;
+       err = _IpcCallbackHandler::GetInstance()->OpenMessageHandle(__msgHandle);
+       r = ConvertException(err);
+       SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to open messageHandle.");
+
+       return r;
+
+}
+result
+_SmsService::OpenCbsHandle()
+{
+
+       result r = E_SUCCESS;
+       int err = MSG_SUCCESS;
+
+       err = _IpcCallbackHandler::GetInstance()->OpenCbsSettingsHandle(__cbsSettingsHandle);
+       r = ConvertException(err);
+       if (r == E_DEVICE_UNAVAILABLE)
+       {
+               r = E_SUCCESS;
+               SysLog(NID_MSG, "Sim card is not present in device"); // even no sim, return sucess so that app will launch sucess
+       }
+       SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to open cbs Settings Handle");
+       SysTryReturnResult(NID_MSG, __cbsSettingsHandle > 0, E_SYSTEM, "cbsSettingsHandle is invalid.");
+       // load cbs settings
+       r = _IpcCallbackHandler::GetInstance()->LoadCbsSettings();
+       SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to load cbs message settings.");
+
+       return r;
+
+}
+
+result
+_SmsService::AddSmsEventListener(int port, int clientId)
+{
+       // checking conditions
+
+       result r = E_SUCCESS;
+       int err = MSG_SUCCESS;
+
+       SysTryCatch(NID_MSG, _IpcCallbackHandler::GetInstance()->SetSmsClientId(clientId)== E_SUCCESS, r = E_SYSTEM, r, "failed to save client id.");
+       // Register SMS Trigger
+       err = msg_reg_sms_message_callback(__msgHandle, &_IpcCallbackHandler::IncomingSmsCallback, port, null);
+
+       SysTryReturn(NID_MSG, err == MSG_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Failed to register for incoming sms callback.", GetErrorMessage(r));
+       return r;
+
+CATCH:
+       return r;
+}
+
+
+
+result
+_SmsService::AddCbsEtwsEventListener(bool enabled, int clientId)
+{
+       SysAssertf(__isConstructed == true, "_SmsService instance is not constructed yet.");
+       SysAssertf(__msgHandle > 0, "message handle is invalid.");
+
+       result r = E_SUCCESS;
+       int err = MSG_SUCCESS;
+
+       SysTryCatch(NID_MSG, _IpcCallbackHandler::GetInstance()->SetCbsEtwsClientId(clientId)== E_SUCCESS, r = E_SYSTEM, r, "failed to save client id.");
+
+       err = msg_reg_cb_message_callback(__msgHandle, &_IpcCallbackHandler::IncomingCbsMessageCallback, enabled, null);
+       r = ConvertException(err);
+       SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Failed to set cbs incoming callback");
+
+       return r;
+
+CATCH:
+
+       return r;
+       }
+
+
+result
+_SmsService::SetSavingToCbsBoxEnabled(bool enable)
+{
+       SysAssertf(__isConstructed == true, "_SmsService instance is not constructed yet.");
+       SysAssertf(__msgHandle > 0, "message handle is invalid.");
+       SysTryReturnResult(NID_MSG, __cbsSettingsHandle != NULL, E_SYSTEM, "Cb handle is null");
+
+       int err = MSG_SUCCESS;
+
+       err = msg_reg_cb_message_callback(__msgHandle, &_IpcCallbackHandler::IncomingCbsMessageCallback, enable, null);
+       SysTryReturnResult(NID_MSG, err == MSG_SUCCESS, E_SYSTEM, "Failed to set SavingToCbsBoxEnabled option.");
+
+       __isCbsSaveEnabled = enable;
+
+       return E_SUCCESS;
+}
+
+bool
+_SmsService::IsCbsEnabled(void) const
+{
+       SysAssertf(__isConstructed == true, "_SmsService instance is not constructed yet.");
+       SysAssertf(__msgHandle > 0, "message handle is invalid.");
+       SysTryReturn(NID_MSG, __cbsSettingsHandle != NULL, false, E_SYSTEM, "Cb handle is null");
+
+       bool isCbsEnabled = false;
+       int err = MSG_SUCCESS;
+
+       err = msg_get_bool_value(__cbsSettingsHandle, MSG_CB_RECEIVE_BOOL, &isCbsEnabled);
+       SysTryReturn(NID_MSG, err == MSG_SUCCESS, false, E_SYSTEM, "Failed to set SavingToCbsBoxEnabled option.");
+
+       return isCbsEnabled;
+}
+
+result
+_SmsService::SetCbsEnabled(bool enable)
+{
+       SysAssertf(__isConstructed == true, "_SmsService instance is not constructed yet.");
+       SysAssertf(__msgHandle > 0, "message handle is invalid.");
+       SysTryReturnResult(NID_MSG, __cbsSettingsHandle != NULL, E_SYSTEM, "Cb handle is null");
+
+       int err = MSG_SUCCESS;
+       result r = E_SUCCESS;
+
+       err = msg_set_bool_value(__cbsSettingsHandle, MSG_CB_RECEIVE_BOOL, enable);
+       SysTryReturnResult(NID_MSG, err == MSG_SUCCESS, E_SYSTEM, "Failed to set cbs enabled.");
+
+       r = _IpcCallbackHandler::GetInstance()->SaveCbsSettings();
+       SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "Failed to save cbs settings.");
+
+       return E_SUCCESS;
+}
+
+result
+_SmsService::AddCbsChannel(int from, int to, const Tizen::Base::String& name, bool activate)
+{
+       SysAssertf(__isConstructed == true, "_SmsService instance is not constructed yet.");
+       SysAssertf(__msgHandle > 0, "message handle is invalid.");
+       SysTryReturnResult(NID_MSG, __cbsSettingsHandle != NULL, E_SYSTEM, "Cb handle is null");
+
+       result r = E_SUCCESS;
+       int count = 0;
+
+       r = _IpcCallbackHandler::GetInstance()->GetCbsChannelsCount(count);
+       SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to get CB Channel count.");
+
+       if (CB_CHANNEL_MAX <= count)
+       {
+               return E_ALREADY_SET;
+       }
+
+       // add channel
+       r = _IpcCallbackHandler::GetInstance()->AddCbsChannel(from, to, name, activate);
+       SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to add a CB Channel.");
+
+       return r;
+}
+
+result
+_SmsService::RemoveCbsChannel(int from, int to)
+{
+       SysAssertf(__isConstructed == true, "_SmsService instance is not constructed yet.");
+       SysAssertf(__msgHandle > 0, "message handle is invalid.");
+       SysTryReturnResult(NID_MSG, __cbsSettingsHandle != NULL, E_SYSTEM, "Cb handle is null");
+
+       result r = E_SUCCESS;
+
+       // remove channel
+       r = _IpcCallbackHandler::GetInstance()->RemoveCbsChannel(from, to);
+       SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to remove a CB Channel.");
+
+       return r;
+}
+
+_CbsMaker*
+_SmsService::GetCbsChannelN(int from, int to) const
+{
+       SysAssertf(__isConstructed == true, "_SmsService instance is not constructed yet.");
+       SysAssertf(__msgHandle > 0, "message handle is invalid.");
+       SysTryReturn(NID_MSG, __cbsSettingsHandle != null, null, E_SYSTEM, "Cb handle is null.");
+
+       result r = E_SUCCESS;
+       int fromId = 0;
+       int toId = 0;
+       int index = 0;
+       bool isActive = false;
+       String channelName;
+       std::unique_ptr<_CbsMaker> pCbsChannel;
+
+       ClearLastResult();
+
+       // search channel
+       r = _IpcCallbackHandler::GetInstance()->SearchCbsChannel(from, to, index);
+       SysTryReturn(NID_MSG, r == E_SUCCESS, null, r, "Failed to find the cb channel.");
+
+       // get channel
+       r = _IpcCallbackHandler::GetInstance()->GetCbsChannel(index, fromId, toId, channelName, isActive);
+       SysTryReturn(NID_MSG, r == E_SUCCESS, null, r, "Failed to get the cb channel.");
+
+       // creates channel
+       pCbsChannel.reset(_CbsMaker::GetCbsChannelN(fromId, toId, channelName));
+
+       if (isActive)
+       {
+               pCbsChannel->SetCbsChannelState(true);
+       }
+
+       return pCbsChannel.release();
+}
+
+result
+_SmsService::GetCbsChannelListN(Tizen::Base::Collection::ArrayList *pCbsList)
+{
+       SysAssertf(__isConstructed == true, "_SmsService instance is not constructed yet.");
+       SysAssertf(__msgHandle > 0, "message handle is invalid.");
+       SysTryReturn(NID_MSG, __cbsSettingsHandle != null, null, E_SYSTEM, "Cb handle is null.");
+
+       result r = E_SUCCESS;
+       int cbChannelCount = 0;
+       int fromId = 0;
+       int toId = 0;
+       bool isActive = false;
+       String channelName;
+       std::unique_ptr<_CbsMaker> pCbsChannel;
+
+       ClearLastResult();
+
+       r = _IpcCallbackHandler::GetInstance()->GetCbsChannelsCount(cbChannelCount);
+       SysTryReturnResult(NID_MSG, r == E_SUCCESS, r, "Failed to get CB Channel count.");
+
+       for (int index = 0; index < cbChannelCount; index++)
+       {
+               // get channel
+               r = _IpcCallbackHandler::GetInstance()->GetCbsChannel(index, fromId, toId, channelName, isActive);
+               SysTryReturnResult(NID_MSG, r == E_SUCCESS, r , "Failed to get the cb channel.");
+
+               pCbsList->Add(new String(Integer::ToString(fromId)));
+               pCbsList->Add(new String(Integer::ToString(toId)));
+               pCbsList->Add(new String(channelName));
+               pCbsList->Add(new String(Integer::ToString(isActive)));
+
+       }
+
+       return E_SUCCESS;
+}
+
+
+result
+_SmsService::ConvertException(int err) const
+{
+       result r = E_SUCCESS;
+
+       switch (err)
+       {
+       case MSG_SUCCESS:
+               r = E_SUCCESS;
+               break;
+
+       case MSG_ERR_INVALID_PARAMETER:
+       case MSG_ERR_INVALID_MESSAGE:
+       case MSG_ERR_NULL_POINTER:
+       case MSG_ERR_NULL_MESSAGE:
+               r = E_INVALID_ARG;
+               break;
+
+       case MSG_ERR_MEMORY_ERROR:
+               r = E_OUT_OF_MEMORY;
+               break;
+
+       case MSG_ERR_STORAGE_ERROR:
+               r = E_STORAGE_FULL;
+               break;
+
+       case MSG_ERR_DB_STEP:
+               r = E_OBJ_NOT_FOUND;
+               break;
+
+       case MSG_ERR_SERVER_NOT_READY:
+       case MSG_ERR_TRANSPORT_ERROR:
+       case MSG_ERR_COMMUNICATION_ERROR:
+               r = E_NETWORK_UNAVAILABLE;
+               break;
+
+       case MSG_ERR_NO_SIM:
+               r = E_DEVICE_UNAVAILABLE;
+               break;
+
+       case MSG_ERR_PLUGIN_TAPI_FAILED:
+               r = E_FAILURE;
+               break;
+
+       default:
+               r = E_SYSTEM;
+               break;
+       }
+
+       return r;
+}
+
+} } // Tizen::Messaging
diff --git a/src/messaging/FMsg_SmsService.h b/src/messaging/FMsg_SmsService.h
new file mode 100644 (file)
index 0000000..328e0b1
--- /dev/null
@@ -0,0 +1,101 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file       FMsg_SmsService.h
+ * @brief      This is the header file for the _SmsService class.
+ *
+ * This header file contains the declarations of the _SmsService class.
+ */
+
+#ifndef _FMSG_INTERNAL_SMS_SERVICE_H_
+#define _FMSG_INTERNAL_SMS_SERVICE_H_
+
+
+namespace Tizen { namespace Messaging
+{
+
+class _CbsMaker;
+class _MessagingIpcStub;
+
+
+/**
+* @class       _SmsService
+* @brief       This class provides methods to use the SMS messaging service.
+* @since       1.0
+*
+* This class provides methods to use the SMS messaging service. @n
+*/
+
+
+class _SmsService
+       : public Tizen::Base::Object
+{
+       // Life cycle
+public:
+
+
+       /**
+       *       This is the destructor for this class.
+       */
+       virtual ~_SmsService(void);
+
+private:
+       _SmsService(void);
+       _SmsService(const _SmsService& value);
+       _SmsService& operator =(const _SmsService& rhs);
+
+
+       // Operation
+public:
+
+       result OpenMsgHandle();
+       result OpenCbsHandle();
+       result AddSmsEventListener(int port, int clientId);
+       result AddCbsEtwsEventListener(bool enabled, int clientId);
+       result SetSavingToCbsBoxEnabled(bool enable);
+       bool IsCbsEnabled(void) const;
+       result SetCbsEnabled(bool enable);
+       result AddCbsChannel(int from, int to, const Tizen::Base::String& name, bool activate = true);
+       result RemoveCbsChannel(int from, int to);
+       _CbsMaker* GetCbsChannelN(int from, int to) const;
+       result GetCbsChannelListN(Tizen::Base::Collection::ArrayList *pCbsList);
+
+public:
+
+       static _SmsService* GetInstance();
+       static _SmsService* GetInstance(_MessagingIpcStub *pStub = null);
+       static _MessagingIpcStub* GetStubInstance();
+       static void DestroyInstance();
+
+private:
+
+       result ConvertException(int err) const;
+
+private:
+       static _SmsService * __pSelf;
+       bool __isConstructed;
+       bool __isCbsSaveEnabled;
+       Tizen::Base::Collection::ArrayList* __pSmsTriggerEventList;
+       msg_handle_t __msgHandle;
+       msg_struct_t __cbsSettingsHandle;
+       _MessagingIpcStub *__pStub;
+       friend class _MessagingIpcStub;
+
+}; // _SmsService
+} } // Tizen::Messaging
+
+#endif // _FMSG_INTERNAL_SMS_SERVICE_H_
diff --git a/src/messaging/FMsg_WapPushService.cpp b/src/messaging/FMsg_WapPushService.cpp
new file mode 100644 (file)
index 0000000..fb50c41
--- /dev/null
@@ -0,0 +1,360 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FMsg_WapPushService.cpp
+ * @brief              This is the implementation file for the %_WapPushService class.
+ *
+ * This file contains the implementation of the %_WapPushService class.
+ */
+
+
+#include <unique_ptr.h>
+#include <msg.h>
+#include <msg_transport.h>
+#include <msg_storage.h>
+#include <app.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include "FMsg_WapPushService.h"
+#include "FMsg_IpcCallbackHandler.h"
+#include "FMsg_MessagingIpcStub.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Messaging;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Messaging
+{
+
+_WapPushService *_WapPushService::__pSelf = null;
+
+_WapPushService::_WapPushService(void)
+       : __msgHandle(0)
+       ,__pStub(null)
+
+{
+}
+
+_WapPushService::_WapPushService(const _WapPushService& value)
+{
+       __msgHandle = value.__msgHandle;
+
+}
+
+_WapPushService::~_WapPushService(void)
+{
+
+}
+
+_WapPushService*
+_WapPushService::GetInstance()
+{
+
+       return _WapPushService::__pSelf;
+
+}
+
+
+_WapPushService*
+_WapPushService::GetInstance(_MessagingIpcStub *pStub)
+{
+       if (pStub)
+       {
+               SysTryReturnResult(NID_MSG, _WapPushService::__pSelf == null, null, "_WapPushService already created.");
+               _WapPushService::__pSelf = new (std::nothrow)_WapPushService();
+               _WapPushService::__pSelf->__pStub = pStub;
+               std::atexit(DestroyInstance);
+               return _WapPushService::__pSelf;
+       }
+       return _WapPushService::__pSelf;
+
+}
+
+ _MessagingIpcStub*
+ _WapPushService::GetStubInstance()
+ {
+        if(_WapPushService::__pSelf)
+        {
+
+                return _WapPushService::__pSelf->__pStub;
+        }
+
+       return null;
+
+ }
+
+
+ void
+ _WapPushService::DestroyInstance()
+{
+
+   if(_WapPushService::__pSelf)
+
+       {
+      delete _WapPushService::__pSelf ;
+      _WapPushService::__pSelf = null;
+
+}
+ }
+
+
+
+result
+_WapPushService::AddWapPushEventListener(const Tizen::Base::String& wapApplicationId,int clientId)
+{
+       result r = E_SUCCESS;
+       int err = MSG_SUCCESS;
+       char* pWapAppId = null;
+
+       ClearLastResult();
+
+       pWapAppId = _StringConverter::CopyToCharArrayN(wapApplicationId);
+       SysTryCatch(NID_MSG, pWapAppId != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+       SysTryCatch(NID_MSG, _IpcCallbackHandler::GetInstance()->SetWapPushClientId(clientId)== E_SUCCESS, r = E_SYSTEM, r, "failed to save client id.");
+       SysTryCatch(NID_MSG, _IpcCallbackHandler::GetInstance() != null, r = E_OUT_OF_MEMORY, r, "failed to get msg handle.");
+
+       // open message handle
+       err = _IpcCallbackHandler::GetInstance()->OpenMessageHandle(__msgHandle);
+
+       r = ConvertException(err);
+       SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to Open Message Handle", GetErrorMessage(r));
+
+       SysLog(NID_MSG, "The value of __msgHandle is [%d]", __msgHandle);
+
+       // check value of msg handle
+       SysTryCatch(NID_MSG, __msgHandle > 0, r = E_SYSTEM, r, "failed to get msg handle.");
+       err = msg_reg_push_message_callback(__msgHandle, &_IpcCallbackHandler::IncomingWapPushMessageCallback, pWapAppId, (void*) null);
+
+       r = ConvertException(err);
+       SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to Add WapPush EventListener.", GetErrorMessage(r));
+
+       if (pWapAppId)
+       {
+               delete[] pWapAppId;
+               pWapAppId = null;
+       }
+
+       return r;
+
+CATCH:
+       if (pWapAppId)
+       {
+               delete[] pWapAppId;
+               pWapAppId = null;
+       }
+
+       return r;
+}
+
+result
+_WapPushService::RegisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType)
+{
+       result r = E_SUCCESS;
+       int err = MSG_SUCCESS;
+       char* pWapAppId = null;
+       char* pContentType = null;
+       msg_struct_t pushInfo = null;
+       char* pPkgName = null;
+
+       ClearLastResult();
+
+       pWapAppId = _StringConverter::CopyToCharArrayN(wapApplicationId);
+       SysTryCatch(NID_MSG, pWapAppId != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+
+       pContentType = _StringConverter::CopyToCharArrayN(contentType);
+       SysTryCatch(NID_MSG, pContentType != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+
+       err = app_get_package(&pPkgName);
+       SysTryCatch(NID_MSG, err == APP_ERROR_NONE && pPkgName != null, r = E_SYSTEM, r, "[%s] Failed to Open Message Handle", GetErrorMessage(r));
+
+       pushInfo = msg_create_struct(MSG_STRUCT_PUSH_CONFIG_INFO);
+       SysTryCatch(NID_MSG, pushInfo != null, r = E_SYSTEM, r, "[%s] Failed to create push data info", GetErrorMessage(r));
+       msg_set_str_value(pushInfo, MSG_PUSH_CONFIG_CONTENT_TYPE_STR, (char *)pContentType, MAX_WAPPUSH_CONTENT_TYPE_LEN);
+       msg_set_str_value(pushInfo, MSG_PUSH_CONFIG_APPLICATON_ID_STR, (char *)pWapAppId, MAX_WAPPUSH_ID_LEN);
+       msg_set_str_value(pushInfo, MSG_PUSH_CONFIG_PACKAGE_NAME_STR, pPkgName, MSG_FILEPATH_LEN_MAX);
+       free(pPkgName);
+       pPkgName = null;
+
+       err = msg_add_push_event(__msgHandle, pushInfo);
+       msg_release_struct(&pushInfo);
+
+       r = ConvertException(err);
+       SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to register Condition for wap push.", GetErrorMessage(r));
+
+       if (pWapAppId)
+       {
+               delete[] pWapAppId;
+               pWapAppId = null;
+       }
+
+       if (pContentType)
+       {
+               delete[] pContentType;
+               pContentType = null;
+       }
+       return r;
+
+CATCH:
+       if (pPkgName)
+       {
+               free(pPkgName);
+               pPkgName = null;
+       }
+
+       if (pushInfo)
+       {
+               msg_release_struct(&pushInfo);
+               pushInfo = null;
+       }
+
+       if (pWapAppId)
+       {
+               delete[] pWapAppId;
+               pWapAppId = null;
+       }
+
+       if (pContentType)
+       {
+               delete[] pContentType;
+               pContentType = null;
+       }
+       return r;
+}
+
+result
+_WapPushService::UnregisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType)
+{
+       result r = E_SUCCESS;
+       int err = MSG_SUCCESS;
+       char* pWapAppId = null;
+       char* pContentType = null;
+       msg_struct_t pushInfo = null;
+       char* pPkgName = null;
+
+       ClearLastResult();
+
+       pWapAppId = _StringConverter::CopyToCharArrayN(wapApplicationId);
+       SysTryCatch(NID_MSG, pWapAppId != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+
+       pContentType = _StringConverter::CopyToCharArrayN(contentType);
+       SysTryCatch(NID_MSG, pContentType != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+
+       err = app_get_package(&pPkgName);
+       SysTryCatch(NID_MSG, err == APP_ERROR_NONE, r = E_SYSTEM, r, "[%s] Failed to Open Message Handle", GetErrorMessage(r));
+
+       pushInfo = msg_create_struct(MSG_STRUCT_PUSH_CONFIG_INFO);
+       msg_set_str_value(pushInfo, MSG_PUSH_CONFIG_CONTENT_TYPE_STR, pContentType, MAX_WAPPUSH_CONTENT_TYPE_LEN);
+       msg_set_str_value(pushInfo, MSG_PUSH_CONFIG_APPLICATON_ID_STR, pWapAppId, MAX_WAPPUSH_ID_LEN);
+       msg_set_str_value(pushInfo, MSG_PUSH_CONFIG_PACKAGE_NAME_STR, pPkgName, MSG_FILEPATH_LEN_MAX);
+       free(pPkgName);
+       pPkgName = null;
+
+       err = msg_delete_push_event(__msgHandle, pushInfo);
+       msg_release_struct(&pushInfo);
+
+       r = ConvertException(err);
+       SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to Unregister Condition for wap push", GetErrorMessage(r));
+
+       if (pWapAppId)
+       {
+               delete[] pWapAppId;
+               pWapAppId = null;
+       }
+
+       if (pContentType)
+       {
+               delete[] pContentType;
+               pContentType = null;
+       }
+       return r;
+
+CATCH:
+       if (pPkgName)
+       {
+               free(pPkgName);
+               pPkgName = null;
+       }
+
+       if (pushInfo)
+       {
+               msg_release_struct(&pushInfo);
+               pushInfo = null;
+       }
+
+       if (pWapAppId)
+       {
+               delete[] pWapAppId;
+               pWapAppId = null;
+       }
+
+       if (pContentType)
+       {
+               delete[] pContentType;
+               pContentType = null;
+       }
+       return r;
+}
+
+result
+_WapPushService::ConvertException(int err) const
+{
+       result r = E_SUCCESS;
+
+       switch (err)
+       {
+       case MSG_SUCCESS:
+               r = E_SUCCESS;
+               break;
+
+       case MSG_ERR_DB_ROW:
+               r = E_ALREADY_SET;
+       break;
+
+       case MSG_ERR_INVALID_PARAMETER:
+       case MSG_ERR_INVALID_MESSAGE:
+       case MSG_ERR_NULL_POINTER:
+       case MSG_ERR_NULL_MESSAGE:
+               r = E_INVALID_ARG;
+               break;
+
+       case MSG_ERR_MEMORY_ERROR:
+               r = E_OUT_OF_MEMORY;
+               break;
+
+       case MSG_ERR_SERVER_NOT_READY:
+       case MSG_ERR_TRANSPORT_ERROR:
+       case MSG_ERR_COMMUNICATION_ERROR:
+               r = E_NETWORK_UNAVAILABLE;
+               break;
+
+       case MSG_ERR_NO_SIM:
+               r = E_DEVICE_UNAVAILABLE;
+               break;
+
+       case MSG_ERR_PLUGIN_TAPI_FAILED:
+               r = E_FAILURE;
+               break;
+
+       default:
+               r = E_SYSTEM;
+               break;
+       }
+
+       return r;
+}
+
+} }
diff --git a/src/messaging/FMsg_WapPushService.h b/src/messaging/FMsg_WapPushService.h
new file mode 100644 (file)
index 0000000..4dabd0b
--- /dev/null
@@ -0,0 +1,72 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+
+#ifndef _FMSG_INTERNAL_WAP_PUSH_SERVICE_H_
+#define _FMSG_INTERNAL_WAP_PUSH_SERVICE_H_
+
+#include <FBaseObject.h>
+
+namespace Tizen { namespace Messaging
+{
+
+class _WapPushCallBackData
+{
+public:
+       int clientId;
+       int addr;
+};
+
+
+// forward declaration
+class _MessagingIpcStub;
+
+class _WapPushService
+       : public Tizen::Base::Object
+{
+private:
+       _WapPushService(void);
+       _WapPushService(const _WapPushService& value);
+
+
+public:
+
+       result AddWapPushEventListener(const Tizen::Base::String& wapApplicationId, int clientId);
+       result RegisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType);
+       result UnregisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType);
+       result ConvertException(int err) const;
+
+       static _WapPushService* GetInstance();
+       static _WapPushService* GetInstance(_MessagingIpcStub *pStub = null);
+       static _MessagingIpcStub* GetStubInstance();
+       static void DestroyInstance();
+
+       virtual ~_WapPushService(void);
+
+
+
+private:
+       msg_handle_t __msgHandle;
+       _MessagingIpcStub *__pStub;
+       static _WapPushService *__pSelf;
+       friend class _MessagingIpcStub;
+
+
+}; // _WapPushService
+
+} } // Tizen::Messaging
+#endif // _FMSG_INTERNAL_WAP_PUSH_MANAGER_IMPL_H_