From b4555bcf60695c263752ada5ce070ebb2557f0d0 Mon Sep 17 00:00:00 2001 From: Byounghui Date: Tue, 30 Jul 2013 15:45:24 +0900 Subject: [PATCH] IPC Change-Id: Ibdd2cb848c69acde085fb3090ce6ae272d84a451 Signed-off-by: Byounghui --- CMakeLists.txt | 4 + inc/FMsgCbsChannel.h | 382 +++++++++++------------ packaging/osp-messaging.spec | 1 + src/FMsgCbsChannel.cpp | 347 ++++++++++----------- src/FMsg_CbsChannelImpl.cpp | 414 ++++++++++++------------- src/FMsg_CbsChannelImpl.h | 572 +++++++++++++++++------------------ src/FMsg_MessagingIpcProxy.cpp | 568 ++++++++++++++++++++++++++++++++++ src/FMsg_MessagingIpcProxy.h | 88 ++++++ src/FMsg_MessagingMessageTypes.cpp | 45 +++ src/FMsg_SmsManagerImpl.cpp | 195 +++++------- src/FMsg_SmsManagerImpl.h | 3 +- src/FMsg_SmsMmsCallbackHandler.cpp | 20 +- src/FMsg_SmsMmsCallbackHandler.h | 9 +- src/FMsg_WapPushManagerImpl.cpp | 173 +---------- src/inc/FMsg_MessagingMessageTypes.h | 68 +++++ src/{ => inc}/FMsg_Types.h | 0 16 files changed, 1729 insertions(+), 1160 deletions(-) create mode 100644 src/FMsg_MessagingIpcProxy.cpp create mode 100644 src/FMsg_MessagingIpcProxy.h create mode 100644 src/FMsg_MessagingMessageTypes.cpp create mode 100644 src/inc/FMsg_MessagingMessageTypes.h rename src/{ => inc}/FMsg_Types.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index c154a44..7b751ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ INCLUDE_DIRECTORIES( inc src src/inc + /usr/include/chromium /usr/include/appfw /usr/include/glib-2.0 /usr/lib/glib-2.0/include @@ -21,6 +22,7 @@ INCLUDE_DIRECTORIES( /usr/lib/dbus-1.0/include /usr/include/email-service /usr/include/libxml2 + /usr/include/osp/io ) SET (${this_target}_SOURCE_FILES @@ -71,6 +73,8 @@ SET (${this_target}_SOURCE_FILES src/FMsg_EtwsPrimaryNotificationImpl.cpp src/FMsg_MsgUtil.cpp src/FMsg_SmsMmsCallbackHandler.cpp + src/FMsg_MessagingMessageTypes.cpp + src/FMsg_MessagingIpcProxy.cpp ) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall" ) diff --git a/inc/FMsgCbsChannel.h b/inc/FMsgCbsChannel.h index dea3484..de1b940 100755 --- a/inc/FMsgCbsChannel.h +++ b/inc/FMsgCbsChannel.h @@ -1,191 +1,191 @@ -// -// 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 FMsgCbsChannel.h -* @brief This is the header file for the %CbsChannel class. -* -* This header file contains the declarations of the %CbsChannel class. -*/ - -#ifndef _FMSG_CBS_CHANNEL_H_ -#define _FMSG_CBS_CHANNEL_H_ - -namespace Tizen { namespace Base -{ -class String; -} } - -#include - -namespace Tizen { namespace Messaging -{ -class _CbsChannelImpl; - -/** -* @class CbsChannel -* @brief This class provides methods for handling a Cell Broadcast Service (CBS) channel. -* -* @since 2.0 -* -* @final This class is not intended for extension. -* -* The %CbsChannel class provides methods for handling a CBS channel. @n -* It allows you to get and set the CBS channel information. -*/ -class _OSP_EXPORT_ CbsChannel - : public Tizen::Base::Object -{ -public: - - /** - * This destructor overrides Tizen::Base::Object::~Object(). - * - * @since 2.0 - */ - virtual ~CbsChannel(void); - - /** - * Gets the range of a CBS channel. - * - * @since 2.0 - * - * @return An error code - * @param[out] from The starting index of the message ID of the channel - * @param[out] to The last index of the message ID of the channel - * @exception E_SUCCESS The method is successful. - * @exception E_INVALID_STATE The range has not been set as yet. - * @exception E_SYSTEM A system error has occurred. - * @remarks In case of an error, this method sets the negative values for @c from and @c to. For example, @c -1. - */ - result GetRange(int& from, int& to) const; - - /** - * Gets the name of a CBS channel. - * - * @since 2.0 - * - * @return The name of the channel @n - * The name can be an empty string. - */ - Tizen::Base::String GetName(void) const; - - /** - * Checks whether a CBS channel is activated. - * - * @since 2.0 - * - * @return @c true if a CBS channel is activated, @n - * else @c false - */ - bool IsActivated(void) const; - - /** - * Activates the status of a CBS channel. - * - * @since 2.0 - * @privlevel platform - * @privilege %http://tizen.org/privilege/cellbroadcast - * - * @return An error code - * @exception E_SUCCESS The method is successful. - * @exception E_ILLEGAL_ACCESS The application does not have the permission to activate the CBS channel status. - * @exception E_SYSTEM A system error has occurred. - * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. - */ - result Activate(void); - - /** - * Deactivates the status of a CBS channel. - * - * @since 2.0 - * @privlevel platform - * @privilege %http://tizen.org/privilege/cellbroadcast - * - * @return An error code - * @exception E_SUCCESS The method is successful. - * @exception E_ILLEGAL_ACCESS The application does not have the permission to activate the CBS channel status. - * @exception E_SYSTEM A system error has occurred. - * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. - */ - result Deactivate(void); - - /** - * Updates the name of a CBS channel. - * - * @since 2.0 - * @privlevel platform - * @privilege %http://tizen.org/privilege/cellbroadcast - - * @return An error code - * @param[in] name The name of the CBS channel to update - * @exception E_SUCCESS The method is successful. - * @exception E_ILLEGAL_ACCESS The application does not have the permission to update the CBS channel name. - * @exception E_SYSTEM A system error has occurred. - * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. - */ - result UpdateName(const Tizen::Base::String& name); - -private: - /** - * This default constructor is intentionally declared as private so that only the platform can create an instance. - * - * @since 2.0 - */ - CbsChannel(void); - - /** - * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. - * - * @param[in] rhs An instance of %CbsChannel - */ - CbsChannel(const CbsChannel& rhs); - - /** - * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. - * - * @param[in] rhs An instance of %CbsChannel - */ - CbsChannel& operator =(const CbsChannel& rhs); - - /** - * Initializes this instance of %CbsChannel with the specified parameters. - * - * @since 2.0 - * - * @return An error code - * @param[in] from The starting index of the message ID of the channel - * @param[in] to The last index of the message ID of the channel - * @param[in] name The name of the channel (can be an empty string) - * @exception E_SUCCESS The method is successful. - * @exception E_INVALID_ARG Either of the following conditions has occurred: @n - * - The specified @c to parameter is smaller than @c from. @n - * - The specified @c to or @c from parameter is a negative value. @n - * - The specified @c to parameter exceeds the limit (0xFFFF). @n - * - The range (@c to - @c from) exceeds the limit (0xFFFF). @n - * - The specified @c name string length is greater than @c 32. @n - * @exception E_SYSTEM A system error has occurred. - */ - result Construct(int from, int to, const Tizen::Base::String& name); - -private: - _CbsChannelImpl* __pCbsChannelImpl; - - friend class _CbsChannelImpl; -}; // CbsChannel - -} } // Tizen::Messaging -#endif // _FMSG_CBS_CHANNEL_H_ +// +// 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 FMsgCbsChannel.h +* @brief This is the header file for the %CbsChannel class. +* +* This header file contains the declarations of the %CbsChannel class. +*/ + +#ifndef _FMSG_CBS_CHANNEL_H_ +#define _FMSG_CBS_CHANNEL_H_ + +namespace Tizen { namespace Base +{ +class String; +} } + +#include + +namespace Tizen { namespace Messaging +{ +class _CbsChannelImpl; + +/** +* @class CbsChannel +* @brief This class provides methods for handling a Cell Broadcast Service (CBS) channel. +* +* @since 2.0 +* +* @final This class is not intended for extension. +* +* The %CbsChannel class provides methods for handling a CBS channel. @n +* It allows you to get and set the CBS channel information. +*/ +class _OSP_EXPORT_ CbsChannel + : public Tizen::Base::Object +{ +public: + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~CbsChannel(void); + + /** + * Gets the range of a CBS channel. + * + * @since 2.0 + * + * @return An error code + * @param[out] from The starting index of the message ID of the channel + * @param[out] to The last index of the message ID of the channel + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE The range has not been set as yet. + * @exception E_SYSTEM A system error has occurred. + * @remarks In case of an error, this method sets the negative values for @c from and @c to. For example, @c -1. + */ + result GetRange(int& from, int& to) const; + + /** + * Gets the name of a CBS channel. + * + * @since 2.0 + * + * @return The name of the channel @n + * The name can be an empty string. + */ + Tizen::Base::String GetName(void) const; + + /** + * Checks whether a CBS channel is activated. + * + * @since 2.0 + * + * @return @c true if a CBS channel is activated, @n + * else @c false + */ + bool IsActivated(void) const; + + /** + * Activates the status of a CBS channel. + * + * @since 2.0 + * @privlevel platform + * @privilege %http://tizen.org/privilege/cellbroadcast + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_ILLEGAL_ACCESS The application does not have the permission to activate the CBS channel status. + * @exception E_SYSTEM A system error has occurred. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + */ + result Activate(void); + + /** + * Deactivates the status of a CBS channel. + * + * @since 2.0 + * @privlevel platform + * @privilege %http://tizen.org/privilege/cellbroadcast + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_ILLEGAL_ACCESS The application does not have the permission to activate the CBS channel status. + * @exception E_SYSTEM A system error has occurred. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + */ + result Deactivate(void); + + /** + * Updates the name of a CBS channel. + * + * @since 2.0 + * @privlevel platform + * @privilege %http://tizen.org/privilege/cellbroadcast + + * @return An error code + * @param[in] name The name of the CBS channel to update + * @exception E_SUCCESS The method is successful. + * @exception E_ILLEGAL_ACCESS The application does not have the permission to update the CBS channel name. + * @exception E_SYSTEM A system error has occurred. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + */ + result UpdateName(const Tizen::Base::String& name); + +private: + /** + * This default constructor is intentionally declared as private so that only the platform can create an instance. + * + * @since 2.0 + */ + CbsChannel(void); + + /** + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + * + * @param[in] rhs An instance of %CbsChannel + */ + CbsChannel(const CbsChannel& rhs); + + /** + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + * + * @param[in] rhs An instance of %CbsChannel + */ + CbsChannel& operator =(const CbsChannel& rhs); + + /** + * Initializes this instance of %CbsChannel with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] from The starting index of the message ID of the channel + * @param[in] to The last index of the message ID of the channel + * @param[in] name The name of the channel (can be an empty string) + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG Either of the following conditions has occurred: @n + * - The specified @c to parameter is smaller than @c from. @n + * - The specified @c to or @c from parameter is a negative value. @n + * - The specified @c to parameter exceeds the limit (0xFFFF). @n + * - The range (@c to - @c from) exceeds the limit (0xFFFF). @n + * - The specified @c name string length is greater than @c 32. @n + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(int from, int to, const Tizen::Base::String& name); + +private: + _CbsChannelImpl* __pCbsChannelImpl; + + friend class _CbsChannelImpl; +}; // CbsChannel + +} } // Tizen::Messaging +#endif // _FMSG_CBS_CHANNEL_H_ diff --git a/packaging/osp-messaging.spec b/packaging/osp-messaging.spec index b0b0dbc..7aead78 100644 --- a/packaging/osp-messaging.spec +++ b/packaging/osp-messaging.spec @@ -9,6 +9,7 @@ Group: System/Libraries License: Apache License, Version 2.0 Source0: %{name}-%{version}.tar.gz BuildRequires: cmake +BuildRequires: pkgconfig(chromium) BuildRequires: pkgconfig(capi-appfw-application) BuildRequires: pkgconfig(msg-service) BuildRequires: pkgconfig(push) diff --git a/src/FMsgCbsChannel.cpp b/src/FMsgCbsChannel.cpp index 1853db5..fda2bea 100644 --- a/src/FMsgCbsChannel.cpp +++ b/src/FMsgCbsChannel.cpp @@ -1,173 +1,174 @@ -// -// 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. -// -/** - * @if VISPARTNER-OPERATOR - * - * @file FMsgCbsChannel.cpp - * @brief This is the implementation file for the %CbsChannel class. - * - * @visibility partner-operator - * - * This file contains the implementation of the %CbsChannel class. - * - * @endif -*/ - -#include -#include -#include -#include "FMsg_Types.h" -#include "FMsg_CbsChannelImpl.h" - -using namespace Tizen::Base; -using namespace Tizen::Messaging; -using namespace Tizen::Security; - -namespace Tizen { namespace Messaging -{ - -CbsChannel::CbsChannel(void) -{ - __pCbsChannelImpl = new (std::nothrow) _CbsChannelImpl(); - SysTryReturnVoidResult(NID_MSG, __pCbsChannelImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed."); -} - -CbsChannel::CbsChannel(const CbsChannel& value) -{ - __pCbsChannelImpl = new (std::nothrow) _CbsChannelImpl(*(value.__pCbsChannelImpl)); - SysTryReturnVoidResult(NID_MSG, __pCbsChannelImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed."); -} - -CbsChannel::~CbsChannel(void) -{ - if (__pCbsChannelImpl) - { - delete __pCbsChannelImpl; - } - __pCbsChannelImpl = null; -} - -CbsChannel& -CbsChannel::operator =(const CbsChannel& rhs) -{ - if (this != &rhs) - { - *__pCbsChannelImpl = *(rhs.__pCbsChannelImpl); - } - - return (*this); -} - -result -CbsChannel::Construct(int from, int to, const Tizen::Base::String& name) -{ - result r = E_SUCCESS; - - SysAssertf(__pCbsChannelImpl != null, "The CbsChannel instance is not constructed yet."); - - // argument check - SysTryReturnResult(NID_MSG, name.GetLength() <= MAX_CBS_CHANNEL_NAME_LENGTH, E_INVALID_ARG, - "The length (%d) of channel name is too long.", name.GetLength()); - - SysTryReturnResult(NID_MSG, - ((to >= 0) && (from >= 0) && (to >= from) && (to <= MAX_CBS_CHANNEL_LIMIT) && ((to - from) <= MAX_CBS_CHANNEL_RANGE)), - E_INVALID_ARG, "Failed to add construct channel, invalid arguments. to:[%d], from:[%d]", to , from); - - r = __pCbsChannelImpl->Construct(from, to, name); - SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_INVALID_ARG, "Failed to construct CbsChannel"); - - return r; -} - -result -CbsChannel::UpdateName(const Tizen::Base::String& name) -{ - result r = E_SUCCESS; - - SysAssertf(__pCbsChannelImpl != null, "The CbsChannel instance is not constructed yet."); - - // checking privilege - r = _AccessController::CheckUserPrivilege(_PRV_CELLBROADCAST); - SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagating."); - - // argument check - SysTryReturn(NID_MSG, name.GetLength() <= MAX_CBS_CHANNEL_NAME_LENGTH, E_INVALID_ARG, r = E_INVALID_ARG, - "[E_INVALID_ARG] invalid channel name."); - - r = __pCbsChannelImpl->UpdateName(name); - - return r; -} - -result -CbsChannel::Deactivate(void) -{ - result r = E_SUCCESS; - - SysAssertf(__pCbsChannelImpl != null, "The CbsChannel instance is not constructed yet."); - - // checking privilege - r = _AccessController::CheckUserPrivilege(_PRV_CELLBROADCAST); - SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagating."); - - r = __pCbsChannelImpl->Deactivate(); - return r; -} - -result -CbsChannel::Activate(void) -{ - result r = E_SUCCESS; - - SysAssertf(__pCbsChannelImpl != null, "The CbsChannel instance is not constructed yet."); - - // checking privilege - r = _AccessController::CheckUserPrivilege(_PRV_CELLBROADCAST); - SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagating."); - - return __pCbsChannelImpl->Activate(); -} - -bool -CbsChannel::IsActivated(void) const -{ - SysAssertf(__pCbsChannelImpl != null, "The CbsChannel instance is not constructed yet."); - - return(__pCbsChannelImpl->IsActivated()); -} - -Tizen::Base::String -CbsChannel::GetName(void) const -{ - SysAssertf(__pCbsChannelImpl != null, "The CbsChannel instance is not constructed yet."); - - return(__pCbsChannelImpl->GetName()); -} - -result -CbsChannel::GetRange(int& from, int& to) const -{ - result r = E_SUCCESS; - - SysAssertf(__pCbsChannelImpl != null, "The CbsChannel instance is not constructed yet."); - - r = __pCbsChannelImpl->GetRange(from, to); - - return r; -} - -} } // Tizen::Messaging +// +// 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. +// +/** + * @if VISPARTNER-OPERATOR + * + * @file FMsgCbsChannel.cpp + * @brief This is the implementation file for the %CbsChannel class. + * + * @visibility partner-operator + * + * This file contains the implementation of the %CbsChannel class. + * + * @endif +*/ + +#include +#include +#include +#include "FMsg_Types.h" +#include "FMsg_CbsChannelImpl.h" +#include "FMsg_MessagingIpcProxy.h" + +using namespace Tizen::Base; +using namespace Tizen::Messaging; +using namespace Tizen::Security; + +namespace Tizen { namespace Messaging +{ + +CbsChannel::CbsChannel(void) +{ + __pCbsChannelImpl = new (std::nothrow) _CbsChannelImpl(); + SysTryReturnVoidResult(NID_MSG, __pCbsChannelImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed."); +} + +CbsChannel::CbsChannel(const CbsChannel& value) +{ + __pCbsChannelImpl = new (std::nothrow) _CbsChannelImpl(*(value.__pCbsChannelImpl)); + SysTryReturnVoidResult(NID_MSG, __pCbsChannelImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed."); +} + +CbsChannel::~CbsChannel(void) +{ + if (__pCbsChannelImpl) + { + delete __pCbsChannelImpl; + } + __pCbsChannelImpl = null; +} + +CbsChannel& +CbsChannel::operator =(const CbsChannel& rhs) +{ + if (this != &rhs) + { + *__pCbsChannelImpl = *(rhs.__pCbsChannelImpl); + } + + return (*this); +} + +result +CbsChannel::Construct(int from, int to, const Tizen::Base::String& name) +{ + result r = E_SUCCESS; + + SysAssertf(__pCbsChannelImpl != null, "The CbsChannel instance is not constructed yet."); + + // argument check + SysTryReturnResult(NID_MSG, name.GetLength() <= MAX_CBS_CHANNEL_NAME_LENGTH, E_INVALID_ARG, + "The length (%d) of channel name is too long.", name.GetLength()); + + SysTryReturnResult(NID_MSG, + ((to >= 0) && (from >= 0) && (to >= from) && (to <= MAX_CBS_CHANNEL_LIMIT) && ((to - from) <= MAX_CBS_CHANNEL_RANGE)), + E_INVALID_ARG, "Failed to add construct channel, invalid arguments. to:[%d], from:[%d]", to , from); + + r = __pCbsChannelImpl->Construct(from, to, name); + SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_INVALID_ARG, "Failed to construct CbsChannel"); + + return r; +} + +result +CbsChannel::UpdateName(const Tizen::Base::String& name) +{ + result r = E_SUCCESS; + + SysAssertf(__pCbsChannelImpl != null, "The CbsChannel instance is not constructed yet."); + + // checking privilege + r = _AccessController::CheckUserPrivilege(_PRV_CELLBROADCAST); + SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagating."); + + // argument check + SysTryReturn(NID_MSG, name.GetLength() <= MAX_CBS_CHANNEL_NAME_LENGTH, E_INVALID_ARG, r = E_INVALID_ARG, + "[E_INVALID_ARG] invalid channel name."); + + r = __pCbsChannelImpl->UpdateName(name); + + return r; +} + +result +CbsChannel::Deactivate(void) +{ + result r = E_SUCCESS; + + SysAssertf(__pCbsChannelImpl != null, "The CbsChannel instance is not constructed yet."); + + // checking privilege + r = _AccessController::CheckUserPrivilege(_PRV_CELLBROADCAST); + SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagating."); + + r = __pCbsChannelImpl->Deactivate(); + return r; +} + +result +CbsChannel::Activate(void) +{ + result r = E_SUCCESS; + + SysAssertf(__pCbsChannelImpl != null, "The CbsChannel instance is not constructed yet."); + + // checking privilege + r = _AccessController::CheckUserPrivilege(_PRV_CELLBROADCAST); + SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagating."); + + return __pCbsChannelImpl->Activate(); +} + +bool +CbsChannel::IsActivated(void) const +{ + SysAssertf(__pCbsChannelImpl != null, "The CbsChannel instance is not constructed yet."); + + return(__pCbsChannelImpl->IsActivated()); +} + +Tizen::Base::String +CbsChannel::GetName(void) const +{ + SysAssertf(__pCbsChannelImpl != null, "The CbsChannel instance is not constructed yet."); + + return(__pCbsChannelImpl->GetName()); +} + +result +CbsChannel::GetRange(int& from, int& to) const +{ + result r = E_SUCCESS; + + SysAssertf(__pCbsChannelImpl != null, "The CbsChannel instance is not constructed yet."); + + r = __pCbsChannelImpl->GetRange(from, to); + + return r; +} + +} } // Tizen::Messaging diff --git a/src/FMsg_CbsChannelImpl.cpp b/src/FMsg_CbsChannelImpl.cpp index 19b6303..6746094 100644 --- a/src/FMsg_CbsChannelImpl.cpp +++ b/src/FMsg_CbsChannelImpl.cpp @@ -1,207 +1,207 @@ -// -// 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. -// -/** - * @if VISPARTNER-OPERATOR - * - * @file FMsg_CbsChannelImpl.cpp - * @brief This is the implementation file for the %_CbsChannelImpl class. - * - * @visibility partner-operator - * - * This file contains the implementation of the %_CbsChannelImpl class. - * - * @endif - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "FMsg_Types.h" -#include "FMsg_CbsChannelImpl.h" -#include "FMsg_SmsMmsCallbackHandler.h" - -using namespace Tizen::Base; -using namespace Tizen::Messaging; -using namespace Tizen::Security; - -namespace Tizen { namespace Messaging -{ - -_CbsChannelImpl::_CbsChannelImpl(void) - : __fromId(-1) - , __toId(-1) - , __channelName(L"") - , __isChannelEnable(false) -{ -} - -_CbsChannelImpl::_CbsChannelImpl(const _CbsChannelImpl& value) -{ - __fromId = value.__fromId; - __toId = value.__toId; - __channelName = value.__channelName; - __isChannelEnable = value.__isChannelEnable; -} - -_CbsChannelImpl::~_CbsChannelImpl(void) -{ -} - -_CbsChannelImpl& -_CbsChannelImpl::operator =(const _CbsChannelImpl& rhs) -{ - if (this != &rhs) - { - __fromId = rhs.__fromId; - __toId = rhs.__toId; - __channelName = rhs.__channelName; - __isChannelEnable = rhs.__isChannelEnable; - } - - return (*this); -} - -result -_CbsChannelImpl::Construct(int from, int to, const Tizen::Base::String& name) -{ - __fromId = from; - __toId = to; - __channelName = name; - __isChannelEnable = false; - - return E_SUCCESS; -} - -CbsChannel* -_CbsChannelImpl::GetCbsChannelN(int from, int to, const Tizen::Base::String& name) -{ - result r = E_SUCCESS; - CbsChannel* pCbsChannel = null; - - pCbsChannel = new (std::nothrow) CbsChannel(); - 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; -} - -_CbsChannelImpl* -_CbsChannelImpl::GetInstance(CbsChannel& cbsChannel) -{ - return cbsChannel.__pCbsChannelImpl; -} - -result -_CbsChannelImpl::UpdateName(const Tizen::Base::String& name) -{ - result r = E_SUCCESS; - ClearLastResult(); - - // save the setting - r = _SmsMmsCallbackHandler::GetInstance()->UpdateCbsChannel(__fromId, __toId, name, __isChannelEnable); - SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to save the setting."); - - __channelName = name; - - return r; -} - -result -_CbsChannelImpl::Deactivate(void) -{ - result r = E_SUCCESS; - ClearLastResult(); - - // save the setting - r = _SmsMmsCallbackHandler::GetInstance()->UpdateCbsChannel(__fromId, __toId, __channelName, false); - SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to save the setting."); - - __isChannelEnable = false; - - return r; -} - -result -_CbsChannelImpl::Activate(void) -{ - result r = E_SUCCESS; - ClearLastResult(); - - // save the setting - r = _SmsMmsCallbackHandler::GetInstance()->UpdateCbsChannel(__fromId, __toId, __channelName, true); - SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to save the setting."); - - __isChannelEnable = true; - - return r; -} - -bool -_CbsChannelImpl::IsActivated(void) const -{ - return __isChannelEnable; -} - -Tizen::Base::String -_CbsChannelImpl::GetName(void) const -{ - return __channelName; -} - -result -_CbsChannelImpl::GetRange(int& from, int& to) const -{ - result r = E_SUCCESS; - - from = __fromId; - to = __toId; - - return r; -} - -void -_CbsChannelImpl::SetCbsChannelName(Tizen::Base::String channelName) -{ - __channelName = channelName; -} - -void -_CbsChannelImpl::SetCbsChannelState(bool isChannelEnable) -{ - __isChannelEnable = isChannelEnable; -} - -} } // Tizen::Messaging +// +// 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. +// +/** + * @if VISPARTNER-OPERATOR + * + * @file FMsg_CbsChannelImpl.cpp + * @brief This is the implementation file for the %_CbsChannelImpl class. + * + * @visibility partner-operator + * + * This file contains the implementation of the %_CbsChannelImpl class. + * + * @endif + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "FMsg_Types.h" +#include "FMsg_CbsChannelImpl.h" +#include "FMsg_SmsMmsCallbackHandler.h" +#include "FMsg_MessagingIpcProxy.h" + +using namespace Tizen::Base; +using namespace Tizen::Messaging; +using namespace Tizen::Security; + +namespace Tizen { namespace Messaging +{ + +_CbsChannelImpl::_CbsChannelImpl(void) + : __fromId(-1) + , __toId(-1) + , __channelName(L"") + , __isChannelEnable(false) +{ +} + +_CbsChannelImpl::_CbsChannelImpl(const _CbsChannelImpl& value) +{ + __fromId = value.__fromId; + __toId = value.__toId; + __channelName = value.__channelName; + __isChannelEnable = value.__isChannelEnable; +} + +_CbsChannelImpl::~_CbsChannelImpl(void) +{ +} + +_CbsChannelImpl& +_CbsChannelImpl::operator =(const _CbsChannelImpl& rhs) +{ + if (this != &rhs) + { + __fromId = rhs.__fromId; + __toId = rhs.__toId; + __channelName = rhs.__channelName; + __isChannelEnable = rhs.__isChannelEnable; + } + + return (*this); +} + +result +_CbsChannelImpl::Construct(int from, int to, const Tizen::Base::String& name) +{ + __fromId = from; + __toId = to; + __channelName = name; + __isChannelEnable = false; + + return E_SUCCESS; +} + +CbsChannel* +_CbsChannelImpl::GetCbsChannelN(int from, int to, const Tizen::Base::String& name) +{ + result r = E_SUCCESS; + CbsChannel* pCbsChannel = null; + + pCbsChannel = new (std::nothrow) CbsChannel(); + 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; +} + +_CbsChannelImpl* +_CbsChannelImpl::GetInstance(CbsChannel& cbsChannel) +{ + return cbsChannel.__pCbsChannelImpl; +} + +result +_CbsChannelImpl::UpdateName(const Tizen::Base::String& name) +{ + result r = E_SUCCESS; + ClearLastResult(); + SysTryReturnResult(NID_MSG, _MessagingProxy::GetInstance()!= null, E_OUT_OF_MEMORY,"Failed to get msg proxy instance"); + r = _MessagingProxy::GetInstance()->UpdateCbsChannel(__fromId, __toId, name, __isChannelEnable); + SysTryReturnResult(NID_MSG, r == E_SUCCESS, r, "Failed to update cbs channel."); + + __channelName = name; + + return r; +} + +result +_CbsChannelImpl::Deactivate(void) +{ + result r = E_SUCCESS; + ClearLastResult(); + + SysTryReturnResult(NID_MSG, _MessagingProxy::GetInstance()!= null, E_OUT_OF_MEMORY,"Failed to get msg proxy instance"); + r = _MessagingProxy::GetInstance()->UpdateCbsChannel(__fromId, __toId, __channelName, false); + SysTryReturnResult(NID_MSG, r == E_SUCCESS, r, "Failed to save the setting."); + + __isChannelEnable = false; + + return r; +} + +result +_CbsChannelImpl::Activate(void) +{ + result r = E_SUCCESS; + ClearLastResult(); + + SysTryReturnResult(NID_MSG, _MessagingProxy::GetInstance()!= null, E_OUT_OF_MEMORY, "Failed to get msg proxy instance"); + r = _MessagingProxy::GetInstance()->UpdateCbsChannel(__fromId, __toId, __channelName, true); + SysTryReturnResult(NID_MSG, r == E_SUCCESS, r, "Failed to save the setting."); + + __isChannelEnable = true; + + return r; +} + +bool +_CbsChannelImpl::IsActivated(void) const +{ + return __isChannelEnable; +} + +Tizen::Base::String +_CbsChannelImpl::GetName(void) const +{ + return __channelName; +} + +result +_CbsChannelImpl::GetRange(int& from, int& to) const +{ + result r = E_SUCCESS; + + from = __fromId; + to = __toId; + + return r; +} + +void +_CbsChannelImpl::SetCbsChannelName(Tizen::Base::String channelName) +{ + __channelName = channelName; +} + +void +_CbsChannelImpl::SetCbsChannelState(bool isChannelEnable) +{ + __isChannelEnable = isChannelEnable; +} + +} } // Tizen::Messaging diff --git a/src/FMsg_CbsChannelImpl.h b/src/FMsg_CbsChannelImpl.h index ce1148d..befb781 100644 --- a/src/FMsg_CbsChannelImpl.h +++ b/src/FMsg_CbsChannelImpl.h @@ -1,286 +1,286 @@ -// -// 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. -// -/** - * @if VISPARTNER-OPERATOR - * - * @file FMsg_CbsChannelImpl.h - * @brief This is the header file for the _CbsChannelImpl class. - * - * @visibility partner-operator - * - * This header file contains the declarations of the _CbsChannelImpl class. - * - * @endif - */ - -#ifndef _FMSG_INTERNAL_CBS_CHANNEL_IMPL_H_ -#define _FMSG_INTERNAL_CBS_CHANNEL_IMPL_H_ - -namespace Tizen { namespace Messaging -{ - -/** -* @if VISPARTNER-OPERATOR -* -* @class _CbsChannelImpl -* @brief This class provides methods for handling a Cell Broadcast Service (CBS) channel. -* -* @since 2.1 -* -* @final This class is not intended for extension. -* -* @visibility partner-operator -* -* The %_CbsChannelImpl class provides methods for handling a CBS channel. @n -* It allows you to get and set the CBS channel information. -* -* @endif -*/ - -class _CbsChannelImpl - : public Tizen::Base::Object -{ -public: - - /** - * @if VISPARTNER-OPERATOR - * - * This destructor overrides Tizen::Base::Object::~Object(). - * - * @since 2.1 - * - * @visibility partner-operator - * - * @endif - */ - virtual ~_CbsChannelImpl(void); - - /** - * @if VISPARTNER-OPERATOR - * - * Gets the range of the channel - * - * @since 2.1 - * - * @visibility partner-operator - * - * @privlevel user - * @privilege http://tizen.org/privilege/cellbroadcast - * - * - * @return An error code - * @param[out] from The starting index of the message ID of the channel. - * @param[out] to The last index of the message ID of the channel. - * @exception E_SUCCESS The method is successful. - * @exception E_INVALID_STATE The range has not been set as yet. - * @exception E_SYSTEM A system error has occurred. - * @remarks In case of an error, this method sets the negative values for @c from and @c to. For example, @c -1. - * - * @endif - */ - result GetRange(int& from, int& to) const; - - /** - * @if VISPARTNER-OPERATOR - * - * Gets the name of the channel. - * - * @since 2.1 - * - * @visibility partner-operator - * - * @privlevel user - * @privilege http://tizen.org/privilege/cellbroadcast - * - * @return The name of the channel - * - * @remark The name can be an empty string. - * - * @endif - */ - Tizen::Base::String GetName(void) const; - - /** - * @if VISPARTNER-OPERATOR - * - * Gets the activation status of the channel. - * - * @since 2.1 - * - * @visibility partner-operator - * - * @privlevel user - * @privilege http://tizen.org/privilege/cellbroadcast - * - * @return @c true if the channel is activated, - * else @c false - * - * @endif - */ - bool IsActivated(void) const; - - /** - * @if VISPARTNER-OPERATOR - * - * Activates the channel status . - * - * @since 2.1 - * - * @visibility partner-operator - * - * @privlevel user - * @privilege http://tizen.org/privilege/cellbroadcast - * - * @return An error code - * @exception E_SUCCESS The method is successful. - * @exception E_ILLEGAL_ACCESS The application does not have the permission to activate the CBS channel status. - * @exception E_SYSTEM A system error has occurred. - * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. - * - * @endif - */ - result Activate(void); - - /** - * @if VISPARTNER-OPERATOR - * - * Deactivates the channel status - * - * @privlevel user - * @privilege http://tizen.org/privilege/cellbroadcast - * - * @since 2.1 - * - * @visibility partner-operator - * - * @return An error code - * @exception E_SUCCESS The method is successful. - * @exception E_ILLEGAL_ACCESS The application does not have the permission to activate the CBS channel status. - * @exception E_SYSTEM A system error has occurred. - * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. - * - * @endif - */ - result Deactivate(void); - - /** - * @if VISPARTNER-OPERATOR - * - * Updates the name of the channel. - * - * @privlevel user - * @privilege http://tizen.org/privilege/cellbroadcast - * - * @since 2.1 - * - * @visibility partner-operator - * - * @return An error code - * @param[in] name The name of the CBS channel to update - * @exception E_SUCCESS The method is successful. - * @exception E_ILLEGAL_ACCESS The application does not have the permission to update the CBS channel name. - * @exception E_SYSTEM A system error has occurred. - * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. - * - * @endif - */ - result UpdateName(const Tizen::Base::String& name); - - /** - * Sets the cbs channel name to CbsChannelImpl object. - * - * @since 2.1 - * @param[in] channelName An Cbs Channel Name - */ - void SetCbsChannelName(Tizen::Base::String channelName); - - /** - * Sets the cbs Channel State to CbsChannelImpl object. - * - * @since 2.1 - * @param[in] isChannelEnable CBS on/off flag - */ - void SetCbsChannelState(bool isChannelEnable); - -public: - /** - * Gets the instance of CbsChannel - * - * @since 2.1 - */ - static CbsChannel* GetCbsChannelN(int from, int to, const Tizen::Base::String& name); - - /** - * Gets the Impl instance. - * - * @since 2.1 - * @return The pointer to _CbsChannelImpl - * @param[in] CbsChannel An instance of CbsChannel - */ - static _CbsChannelImpl* GetInstance(CbsChannel& cbsChannel); - -public: - /** - * This default constructor is intentionally declared as private so that only the platform can create an instance. - * - * @since 2.1 - */ - _CbsChannelImpl(void); - - /** - * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. - * - * @param[in] rhs An instance of _CbsChannelImpl - */ - _CbsChannelImpl(const _CbsChannelImpl& rhs); - - /** - * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. - * - * @param[in] rhs An instance of _CbsChannelImpl - */ - _CbsChannelImpl& operator =(const _CbsChannelImpl& rhs); - - /** - * Initializes this instance of %_CbsChannelImpl with the specified parameter. - * - * @since 2.1 - * - * @return An error code - * @param[in] from The starting index of the message ID of the channel. - * @param[in] to The last index of the message ID of the channel. - * @param[in] name The name of the channel. (can be an empty string) - * @exception E_SUCCESS The method is successful. - * @exception E_INVALID_ARG The specified @c to parameter is smaller than @c from. @n - * The specified @c to or @c from parameter is a negative value. @n - * The specified @c to parameter exceeds the limit (0xFFFF). @n - * The range (@c to - @c from) exceeds the limit (0xFFFF). - * The specified @c name string length is greater than @c 32. @n - * @exception E_OUT_OF_MEMORY The memory is insufficient. - * @exception E_SYSTEM A system error has occurred. - */ - result Construct(int from, int to, const Tizen::Base::String& name); - -private: - int __fromId; - int __toId; - Tizen::Base::String __channelName; - bool __isChannelEnable; -}; // _CbsChannelImpl - -} } // Tizen::Messaging -#endif // _FMSG_INTERNAL_CBS_CHANNEL_IMPL_H_ +// +// 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. +// +/** + * @if VISPARTNER-OPERATOR + * + * @file FMsg_CbsChannelImpl.h + * @brief This is the header file for the _CbsChannelImpl class. + * + * @visibility partner-operator + * + * This header file contains the declarations of the _CbsChannelImpl class. + * + * @endif + */ + +#ifndef _FMSG_INTERNAL_CBS_CHANNEL_IMPL_H_ +#define _FMSG_INTERNAL_CBS_CHANNEL_IMPL_H_ + +namespace Tizen { namespace Messaging +{ + +/** +* @if VISPARTNER-OPERATOR +* +* @class _CbsChannelImpl +* @brief This class provides methods for handling a Cell Broadcast Service (CBS) channel. +* +* @since 2.1 +* +* @final This class is not intended for extension. +* +* @visibility partner-operator +* +* The %_CbsChannelImpl class provides methods for handling a CBS channel. @n +* It allows you to get and set the CBS channel information. +* +* @endif +*/ + +class _CbsChannelImpl + : public Tizen::Base::Object +{ +public: + + /** + * @if VISPARTNER-OPERATOR + * + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.1 + * + * @visibility partner-operator + * + * @endif + */ + virtual ~_CbsChannelImpl(void); + + /** + * @if VISPARTNER-OPERATOR + * + * Gets the range of the channel + * + * @since 2.1 + * + * @visibility partner-operator + * + * @privlevel user + * @privilege http://tizen.org/privilege/cellbroadcast + * + * + * @return An error code + * @param[out] from The starting index of the message ID of the channel. + * @param[out] to The last index of the message ID of the channel. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE The range has not been set as yet. + * @exception E_SYSTEM A system error has occurred. + * @remarks In case of an error, this method sets the negative values for @c from and @c to. For example, @c -1. + * + * @endif + */ + result GetRange(int& from, int& to) const; + + /** + * @if VISPARTNER-OPERATOR + * + * Gets the name of the channel. + * + * @since 2.1 + * + * @visibility partner-operator + * + * @privlevel user + * @privilege http://tizen.org/privilege/cellbroadcast + * + * @return The name of the channel + * + * @remark The name can be an empty string. + * + * @endif + */ + Tizen::Base::String GetName(void) const; + + /** + * @if VISPARTNER-OPERATOR + * + * Gets the activation status of the channel. + * + * @since 2.1 + * + * @visibility partner-operator + * + * @privlevel user + * @privilege http://tizen.org/privilege/cellbroadcast + * + * @return @c true if the channel is activated, + * else @c false + * + * @endif + */ + bool IsActivated(void) const; + + /** + * @if VISPARTNER-OPERATOR + * + * Activates the channel status . + * + * @since 2.1 + * + * @visibility partner-operator + * + * @privlevel user + * @privilege http://tizen.org/privilege/cellbroadcast + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_ILLEGAL_ACCESS The application does not have the permission to activate the CBS channel status. + * @exception E_SYSTEM A system error has occurred. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * + * @endif + */ + result Activate(void); + + /** + * @if VISPARTNER-OPERATOR + * + * Deactivates the channel status + * + * @privlevel user + * @privilege http://tizen.org/privilege/cellbroadcast + * + * @since 2.1 + * + * @visibility partner-operator + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_ILLEGAL_ACCESS The application does not have the permission to activate the CBS channel status. + * @exception E_SYSTEM A system error has occurred. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * + * @endif + */ + result Deactivate(void); + + /** + * @if VISPARTNER-OPERATOR + * + * Updates the name of the channel. + * + * @privlevel user + * @privilege http://tizen.org/privilege/cellbroadcast + * + * @since 2.1 + * + * @visibility partner-operator + * + * @return An error code + * @param[in] name The name of the CBS channel to update + * @exception E_SUCCESS The method is successful. + * @exception E_ILLEGAL_ACCESS The application does not have the permission to update the CBS channel name. + * @exception E_SYSTEM A system error has occurred. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * + * @endif + */ + result UpdateName(const Tizen::Base::String& name); + + /** + * Sets the cbs channel name to CbsChannelImpl object. + * + * @since 2.1 + * @param[in] channelName An Cbs Channel Name + */ + void SetCbsChannelName(Tizen::Base::String channelName); + + /** + * Sets the cbs Channel State to CbsChannelImpl object. + * + * @since 2.1 + * @param[in] isChannelEnable CBS on/off flag + */ + void SetCbsChannelState(bool isChannelEnable); + +public: + /** + * Gets the instance of CbsChannel + * + * @since 2.1 + */ + static CbsChannel* GetCbsChannelN(int from, int to, const Tizen::Base::String& name); + + /** + * Gets the Impl instance. + * + * @since 2.1 + * @return The pointer to _CbsChannelImpl + * @param[in] CbsChannel An instance of CbsChannel + */ + static _CbsChannelImpl* GetInstance(CbsChannel& cbsChannel); + +public: + /** + * This default constructor is intentionally declared as private so that only the platform can create an instance. + * + * @since 2.1 + */ + _CbsChannelImpl(void); + + /** + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + * + * @param[in] rhs An instance of _CbsChannelImpl + */ + _CbsChannelImpl(const _CbsChannelImpl& rhs); + + /** + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + * + * @param[in] rhs An instance of _CbsChannelImpl + */ + _CbsChannelImpl& operator =(const _CbsChannelImpl& rhs); + + /** + * Initializes this instance of %_CbsChannelImpl with the specified parameter. + * + * @since 2.1 + * + * @return An error code + * @param[in] from The starting index of the message ID of the channel. + * @param[in] to The last index of the message ID of the channel. + * @param[in] name The name of the channel. (can be an empty string) + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c to parameter is smaller than @c from. @n + * The specified @c to or @c from parameter is a negative value. @n + * The specified @c to parameter exceeds the limit (0xFFFF). @n + * The range (@c to - @c from) exceeds the limit (0xFFFF). + * The specified @c name string length is greater than @c 32. @n + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(int from, int to, const Tizen::Base::String& name); + +private: + int __fromId; + int __toId; + Tizen::Base::String __channelName; + bool __isChannelEnable; +}; // _CbsChannelImpl + +} } // Tizen::Messaging +#endif // _FMSG_INTERNAL_CBS_CHANNEL_IMPL_H_ diff --git a/src/FMsg_MessagingIpcProxy.cpp b/src/FMsg_MessagingIpcProxy.cpp new file mode 100644 index 0000000..c39c6c7 --- /dev/null +++ b/src/FMsg_MessagingIpcProxy.cpp @@ -0,0 +1,568 @@ +// +// 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_MessagingIpcProxy.cpp + * @brief This is the implementation file for the %_MessagingProxy class. + * + * This file contains the implementation of the %_MessagingProxy class. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include "FMsg_MessagingMessageTypes.h" +#include "FMsg_MessagingIpcProxy.h" +#include "FMsg_SmsEvent.h" +#include "FMsg_SmsEventArg.h" +#include "FMsg_MsgUtil.h" +#include "FMsg_SmsMmsCallbackHandler.h" + +using namespace Tizen::Base; +using namespace Tizen::Messaging; +using namespace Tizen::Io; + +namespace Tizen { namespace Messaging +{ + +_MessagingProxy* _MessagingProxy::__pSelf = null; + +_MessagingProxy::_MessagingProxy(void) + : __pIpcClient(null) + ,__pWapPushListener(null) + ,__pSmsListenerList(null) + ,__pCbsListenerEvent(null) + ,__pEtwsListenerEvent(null) + +{ +} + + +_MessagingProxy::~_MessagingProxy(void) +{ + if(__pIpcClient) + { + delete __pIpcClient; + } + +} +result +_MessagingProxy::Construct(void) +{ + + + __pIpcClient = new (std::nothrow) _IpcClient(); + SysTryReturnResult(NID_MSG, __pIpcClient != null, E_OUT_OF_MEMORY, "_IpcClient creation failed."); + + result r = __pIpcClient->Construct(MESSAGING_IPC_SERVER_NAME, this); + SysTryReturnResult(NID_MSG, !IsFailed(r), r, "_IpcClient constructing faliied."); + std::atexit(DestroyInstance); + + return r; +} + + +_MessagingProxy* +_MessagingProxy::GetInstance(void) +{ + if(_MessagingProxy::__pSelf == null) + { + _MessagingProxy::__pSelf = new (std::nothrow)_MessagingProxy(); + SysTryCatch(NID_MSG, __pSelf != null, , E_OUT_OF_MEMORY, "_IpcClient creation failed."); + + result r = _MessagingProxy::__pSelf->Construct(); + SysTryCatch(NID_MSG, !IsFailed(r), , r, "_IpcClient creation failed."); + + } + return _MessagingProxy::__pSelf; + +CATCH: + if(_MessagingProxy::__pSelf) + { + delete _MessagingProxy::__pSelf; + _MessagingProxy::__pSelf = null; + } + return null; +} + +void +_MessagingProxy::DestroyInstance(void) +{ + if(_MessagingProxy::__pSelf) + { + delete _MessagingProxy::__pSelf ; + _MessagingProxy::__pSelf = null; + + } + +} + +void +_MessagingProxy::OnIpcResponseReceived(Tizen::Io::_IpcClient& client, const IPC::Message& message) +{ + IPC_BEGIN_MESSAGE_MAP(_MessagingProxy, message) + IPC_MESSAGE_HANDLER(MessagingMsgStart_wapPushEventCallBack, OnWapPushEventCallBack, &client) + IPC_MESSAGE_HANDLER(MessagingMsgStart_incomingEtwsCallback, OnIncomingEtwsCallback, &client) + IPC_MESSAGE_HANDLER(MessagingMsgStart_incomingCbsCallback, OnIncomingCbsCallback, &client) + IPC_MESSAGE_HANDLER(MessagingMsgStart_incomingSmsCallback, OnIncomingSmsCallback, &client) + IPC_END_MESSAGE_MAP() +} + + +result +_MessagingProxy::AddWapPushEventListener(const Tizen::Base::String& wapApplicationId, _SmsEvent* pListener) +{ + result r = E_SUCCESS; + IPC::Message* pMessage = null; + unsigned long ret = 0; + + SysTryReturnResult(NID_MSG, pListener != null, E_SYSTEM, "A system error occurred."); + __pWapPushListener = pListener; + + pMessage = new (std::nothrow) MessagingMsgStart_addWapPushEventListener(wapApplicationId, &ret); + SysTryReturnResult(NID_MSG, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __pIpcClient->SendRequest(*pMessage); + delete pMessage; + SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "A system error occurred."); + + SysLog(NID_MSG, "The result of checking through IPC is %d.", ret); + + return ret; + +} + + +void +_MessagingProxy::OnWapPushEventCallBack(const Tizen::Base::String &header, const Tizen::Base::ByteBuffer &body, int bodyLength) +{ + + SysLog(NID_MSG, "push msg body: [%s]", body.GetPointer()); + SysLog(NID_MSG, "push msg header: [%ls]", header.GetPointer()); + SysLog(NID_MSG, "push body length: [%d]", bodyLength); + + if (__pWapPushListener) + { + _SmsEventArg* pSmsEventArg = null; + pSmsEventArg = new (std::nothrow) _SmsEventArg(header, body, _SMS_EVENT_TYPE_WAP_PUSH_RECEIVE_RESULT); + SysTryReturnVoidResult(NID_MSG, pSmsEventArg != null, E_OUT_OF_MEMORY, "memory allocation failed."); + __pWapPushListener->Fire(*pSmsEventArg); + } + +} + + +/* +result +_MessagingProxy::RemoveWapPushEventListener(const Tizen::Base::String& wapApplicationId) +{ + result r = E_SUCCESS; + IPC::Message* pMessage = null; + unsigned long ret = 0; + + + pMessage = new (std::nothrow) MessagingMsgStart_removeWapPushEventListener(wapApplicationId, &ret); + SysTryReturn(NID_MSG, pMessage != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pIpcClient->SendRequest(*pMessage); + delete pMessage; + SysTryReturn(NID_MSG, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + SysLog(NID_MSG, "The result of checking through IPC is %d.", ret); + + return ret; + +} +*/ +result +_MessagingProxy::RegisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType) +{ + result r = E_SUCCESS; + IPC::Message* pMessage = null; + unsigned long ret = 0; + + + pMessage = new (std::nothrow) MessagingMsgStart_registerCondition(wapApplicationId, contentType, &ret); + SysTryReturnResult(NID_MSG, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __pIpcClient->SendRequest(*pMessage); + delete pMessage; + SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "A system error occurred."); + + SysLog(NID_MSG, "The result of checking through IPC is %d.", ret); + + return ret; + +} + +result +_MessagingProxy::UnregisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType) +{ + result r = E_SUCCESS; + IPC::Message* pMessage = null; + unsigned long ret = 0; + + + pMessage = new (std::nothrow) MessagingMsgStart_unregisterCondition(wapApplicationId, contentType, &ret); + SysTryReturnResult(NID_MSG, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __pIpcClient->SendRequest(*pMessage); + delete pMessage; + SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "A system error occurred."); + + SysLog(NID_MSG, "The result of checking through IPC is %d.", ret); + + return ret; + +} + +result +_MessagingProxy::OpenMsgHandle() +{ + + result r = 0; + IPC::Message* pMessage = null; + unsigned long ret = 0; + + + pMessage = new (std::nothrow) MessagingMsgStart_openMsgHandle(&ret); + SysTryReturnResult(NID_MSG, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __pIpcClient->SendRequest(*pMessage); + delete pMessage; + SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "A system error occurred."); + + SysLog(NID_MSG, "The result of checking through IPC is %d.", ret); + + return ret; + +} + + +result +_MessagingProxy::OpenCbsHandle() +{ + + result r = 0; + IPC::Message* pMessage = null; + unsigned long ret = 0; + + + pMessage = new (std::nothrow) MessagingMsgStart_openCbsHandle(&ret); + SysTryReturnResult(NID_MSG, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __pIpcClient->SendRequest(*pMessage); + delete pMessage; + SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "A system error occurred."); + + SysLog(NID_MSG, "The result of checking through IPC is %d.", ret); + + return ret; + +} + + +result +_MessagingProxy::AddSmsEventListener(int port, Tizen::Base::Collection::ArrayList* pListenerList) +{ + result r = E_SUCCESS; + IPC::Message* pMessage = null; + unsigned long ret = 0; + + SysTryReturnResult(NID_MSG, pListenerList != null, E_SYSTEM, "A system error occurred."); + __pSmsListenerList = pListenerList; + + pMessage = new (std::nothrow) MessagingMsgStart_addSmsEventListener(port, &ret); + SysTryReturnResult(NID_MSG, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __pIpcClient->SendRequest(*pMessage); + delete pMessage; + SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "A system error occurred."); + + SysLog(NID_MSG, "The result of checking through IPC is %d.", ret); + + return ret; + +} + +void +_MessagingProxy::OnIncomingSmsCallback(int port, int displayTime, const Tizen::Base::String &message, const Tizen::Base::String &senderAddress) +{ + + DateTime receivedTime = _MsgUtil::ConvertTime((time_t *) &displayTime); + if (_SmsMmsCallbackHandler::GetInstance()->GetInComingSmsCallback() && __pSmsListenerList->GetCount() > 0) + { + for( int i = 0; i < __pSmsListenerList->GetCount(); i++) + { + _SmsEvent* pSmsEvent = static_cast <_SmsEvent*>(__pSmsListenerList->GetAt(i)); + + if (pSmsEvent) + { + if (pSmsEvent->GetPort() == port) + { + _SmsEventArg* pSmsEventArg = null; + pSmsEventArg = new (std::nothrow) _SmsEventArg(port, receivedTime, message, senderAddress); + SysTryReturnVoidResult(NID_MSG, pSmsEventArg != null, E_OUT_OF_MEMORY, "memory allocation failed."); + + pSmsEvent->Fire(*pSmsEventArg); + break; + } + } + } + } + +} + +result +_MessagingProxy::AddCbsEtwsEventListener(bool enabled) +{ + result r = E_SUCCESS; + IPC::Message* pMessage = null; + unsigned long ret = 0; + + pMessage = new (std::nothrow) MessagingMsgStart_addCbsEtwsEventListener(enabled, &ret); + SysTryReturnResult(NID_MSG, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + r = __pIpcClient->SendRequest(*pMessage); + delete pMessage; + SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "A system error occurred."); + SysLog(NID_MSG, "The result of checking through IPC is %d.", ret); + + return ret; + +} + +void +_MessagingProxy::OnIncomingEtwsCallback(int tempReceivedTime, const Tizen::Base::ByteBuffer &msgSerialNumber, const Tizen::Base::ByteBuffer &msgSecurityInfo, int messgeId, const Tizen::Base::ByteBuffer &etwsMsgWarningType) +{ + + _SmsEventArg* pSmsEventArg = null; + DateTime receivedTime; + receivedTime = _MsgUtil::ConvertTime((time_t *) &tempReceivedTime); + SysLog(NID_MSG, "Etws In Handle[%d]", __pEtwsListenerEvent); + + if (__pEtwsListenerEvent) + { + pSmsEventArg = new (std::nothrow) _SmsEventArg(receivedTime, msgSerialNumber, msgSecurityInfo, messgeId, + etwsMsgWarningType, _SMS_EVENT_TYPE_ETWS_RECEIVE_RESULT); + SysTryReturnVoidResult(NID_MSG, pSmsEventArg != null, E_OUT_OF_MEMORY, "memory allocation failed."); + __pEtwsListenerEvent->Fire(*pSmsEventArg); + } + + + +} + +void +_MessagingProxy::OnIncomingCbsCallback(const Tizen::Base::String &message, const Tizen::Base::ByteBuffer &msgSerialNumber, int tempReceivedTime, int messgeId, int dataCodingScheme, const Tizen::Base::String &messageLanguage) +{ + + _SmsEventArg* pSmsEventArg = null; + DateTime receivedTime = _MsgUtil::ConvertTime((time_t *) &tempReceivedTime); + Tizen::Base::Integer dataCodingSchemeTemp(dataCodingScheme); + SysLog(NID_MSG, "CBS In Handle[%d]", __pCbsListenerEvent); + + if (__pCbsListenerEvent) + { + pSmsEventArg = new (std::nothrow) _SmsEventArg(message, msgSerialNumber, receivedTime, messgeId, false, + ((byte) dataCodingSchemeTemp.ToChar()),messageLanguage, _SMS_EVENT_TYPE_CBS_RECEIVE_RESULT); + SysTryReturnVoidResult(NID_MSG, pSmsEventArg != null, E_OUT_OF_MEMORY, "memory allocation failed."); + __pCbsListenerEvent->Fire(*pSmsEventArg); + } + +} + +void +_MessagingProxy::SetCbsAndEtwsUserEvent(_MessageType msgType, _SmsEvent* pEvent) +{ + if (msgType == _MSG_CBS) + { + __pCbsListenerEvent = pEvent; + } + else + { + __pEtwsListenerEvent = pEvent; + } +} + + +result +_MessagingProxy::SetSavingToCbsBoxEnabled(bool enable) +{ + + result r = 0; + IPC::Message* pMessage = null; + unsigned long ret = 0; + + + pMessage = new (std::nothrow) MessagingMsgStart_setSavingToCbsBoxEnabled(enable, &ret); + SysTryReturnResult(NID_MSG, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __pIpcClient->SendRequest(*pMessage); + delete pMessage; + SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "A system error occurred."); + SysLog(NID_MSG, "The result of checking through IPC is %d.", ret); + + return ret; +} +result +_MessagingProxy::IsCbsEnabled(bool* isCbsEnabled) +{ + + result r = 0; + IPC::Message* pMessage = null; + unsigned long ret = 0; + + SysTryReturnResult(NID_MSG, isCbsEnabled != null, E_SYSTEM, "isCbsEnabled is null."); + + pMessage = new (std::nothrow) MessagingMsgStart_isCbsEnabled(isCbsEnabled, &ret); + SysTryReturnResult(NID_MSG, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __pIpcClient->SendRequest(*pMessage); + delete pMessage; + SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "A system error occurred."); + + SysLog(NID_MSG, "The result of checking through IPC is %d. isCbsEnabled = %d", ret, *isCbsEnabled ); + + return ret; +} + + +result +_MessagingProxy::SetCbsEnabled(bool enable) +{ + + result r = 0; + IPC::Message* pMessage = null; + unsigned long ret = 0; + + + pMessage = new (std::nothrow) MessagingMsgStart_setCbsEnabled(enable, &ret); + SysTryReturnResult(NID_MSG, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __pIpcClient->SendRequest(*pMessage); + delete pMessage; + SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "A system error occurred."); + + SysLog(NID_MSG, "The result of checking through IPC is %d.", ret); + + return ret; +} + +result +_MessagingProxy::AddCbsChannel(int from, int to, Tizen::Base::String& name, bool activate) +{ + + result r = 0; + IPC::Message* pMessage = null; + unsigned long ret = 0; + + pMessage = new (std::nothrow) MessagingMsgStart_addCbsChannel(from, to, name, activate, &ret); + SysTryReturnResult(NID_MSG, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __pIpcClient->SendRequest(*pMessage); + delete pMessage; + SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "A system error occurred."); + + SysLog(NID_MSG, "The result of checking through IPC is %d.", ret); + + return ret; +} +result +_MessagingProxy::RemoveCbsChannel(int from, int to) +{ + + result r = 0; + IPC::Message* pMessage = null; + unsigned long ret = 0; + + + pMessage = new (std::nothrow) MessagingMsgStart_removeCbsChannel(from, to, &ret); + SysTryReturnResult(NID_MSG, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __pIpcClient->SendRequest(*pMessage); + delete pMessage; + SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "A system error occurred."); + + SysLog(NID_MSG, "The result of checking through IPC is %d.", ret); + + return ret; +} + +result +_MessagingProxy::GetCbsChannelN(int from, int to, bool &isActive, String &channelName) +{ + + result r = 0; + IPC::Message* pMessage = null; + unsigned long ret = 0; + + + pMessage = new (std::nothrow) MessagingMsgStart_getCbsChannelN(from, to, &isActive, &channelName,&ret); + SysTryReturnResult(NID_MSG, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __pIpcClient->SendRequest(*pMessage); + delete pMessage; + SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "A system error occurred."); + SysLog(NID_MSG, "The result of checking through IPC is %d.", ret); + + return ret; + +} + +result +_MessagingProxy::GetCbsChannelListN(Tizen::Base::Collection::ArrayList &pCbsList) +{ + result r = 0; + IPC::Message* pMessage = null; + unsigned long ret = 0; + + + pMessage = new (std::nothrow) MessagingMsgStart_getCbsChannelListN(&pCbsList,&ret); + SysTryReturnResult(NID_MSG, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __pIpcClient->SendRequest(*pMessage); + delete pMessage; + SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "A system error occurred."); + SysLog(NID_MSG, "The result of checking through IPC is %d.", ret); + + return ret; +} + +result +_MessagingProxy::UpdateCbsChannel(int from, int to, Tizen::Base::String name, bool isChannelEnable) +{ + + result r = 0; + IPC::Message* pMessage = null; + unsigned long ret = 0; + + pMessage = new (std::nothrow) MessagingMsgStart_updateCbsChannel(from, to, name, isChannelEnable, &ret); + SysTryReturnResult(NID_MSG, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + r = __pIpcClient->SendRequest(*pMessage); + delete pMessage; + SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "A system error occurred."); + + SysLog(NID_MSG, "The result of checking through IPC is %d.", ret); + + return ret; +} + + +} } diff --git a/src/FMsg_MessagingIpcProxy.h b/src/FMsg_MessagingIpcProxy.h new file mode 100644 index 0000000..798b4c7 --- /dev/null +++ b/src/FMsg_MessagingIpcProxy.h @@ -0,0 +1,88 @@ +// +// 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_MESSAGING_PROXY_H_ +#define _FMSG_MESSAGING_PROXY_H_ + +#include +#include +#include +#include "FMsg_Types.h" + +namespace Tizen { namespace Base { +class String; +} } + +namespace Tizen { namespace Io { +class _IpcClient; +} } +namespace Tizen { namespace Messaging +{ + +class _SmsEvent; +class CbsChannel; +class _MessagingProxy + : public Tizen::Base::Object + , public Tizen::Io::_IIpcClientEventListener +{ + +public: + result Construct(void); + result AddWapPushEventListener(const Tizen::Base::String& wapApplicationId, _SmsEvent* pListener); + //result RemoveWapPushEventListener(const Tizen::Base::String& wapApplicationId); + 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 OpenMsgHandle(); + result OpenCbsHandle(); + result AddSmsEventListener(int port, Tizen::Base::Collection::ArrayList* pListenerList); + result AddCbsEtwsEventListener(bool enabled); + result SetSavingToCbsBoxEnabled(bool enable); + result IsCbsEnabled(bool* isCbsEnabled); + result SetCbsEnabled(bool enable); + result AddCbsChannel(int from, int to, Tizen::Base::String& name, bool activate); + result RemoveCbsChannel(int from, int to); + result UpdateCbsChannel(int from, int to, Tizen::Base::String name, bool isChannelEnable); + result GetCbsChannelN(int from, int to, bool &isActive, Tizen::Base::String &channelName); + result GetCbsChannelListN(Tizen::Base::Collection::ArrayList &pCbsList); + + static _MessagingProxy* GetInstance(void); + static void DestroyInstance(void); + + void OnIpcResponseReceived(Tizen::Io::_IpcClient& client, const IPC::Message& message); + void OnWapPushEventCallBack(const Tizen::Base::String &header, const Tizen::Base::ByteBuffer &body, int bodyLength); + void OnIncomingEtwsCallback(int tempReceivedTime, const Tizen::Base::ByteBuffer &msgSerialNumber,const Tizen::Base::ByteBuffer &msgSecurityInfo, int messgeId, const Tizen::Base::ByteBuffer &etwsMsgWarningType); + void OnIncomingCbsCallback(const Tizen::Base::String &message, const Tizen::Base::ByteBuffer &msgSerialNumber, int tempReceivedTime, int messgeId, int dataCodingScheme, const Tizen::Base::String &messageLanguage); + void OnIncomingSmsCallback(int port, int displayTime, const Tizen::Base::String &message, const Tizen::Base::String &senderAddress); + void SetCbsAndEtwsUserEvent(_MessageType msgType, _SmsEvent* pEvent); + +private: + _MessagingProxy(void); + virtual ~_MessagingProxy(void); + +private: + Tizen::Io::_IpcClient* __pIpcClient; + static _MessagingProxy *__pSelf; + _SmsEvent* __pWapPushListener; + Tizen::Base::Collection::ArrayList* __pSmsListenerList; + _SmsEvent* __pCbsListenerEvent; + _SmsEvent* __pEtwsListenerEvent; +}; // _MessagingProxy + +} } // Tizen::Messaging +#endif // _FMSG_MESSAGING_PROXY_H_ \ No newline at end of file diff --git a/src/FMsg_MessagingMessageTypes.cpp b/src/FMsg_MessagingMessageTypes.cpp new file mode 100644 index 0000000..385966d --- /dev/null +++ b/src/FMsg_MessagingMessageTypes.cpp @@ -0,0 +1,45 @@ +// +// 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_MessagingMessageTypes.cpp + * @brief This is the generator of IPC messages for the wap push. + */ + +#define IPC_MESSAGE_IMPL +#include "FMsg_MessagingMessageTypes.h" + +// Generate constructors. +#include +#include "FMsg_MessagingMessageTypes.h" + +// Generate destructors. +#include +#include "FMsg_MessagingMessageTypes.h" + +// Generate param traits write methods. +#include +namespace IPC { +#include "FMsg_MessagingMessageTypes.h" +} // namespace IPC + +// Generate param traits read methods. +#include +namespace IPC { +#include "FMsg_MessagingMessageTypes.h" +} // namespace IPC + diff --git a/src/FMsg_SmsManagerImpl.cpp b/src/FMsg_SmsManagerImpl.cpp index 9f95ed1..cf2b771 100644 --- a/src/FMsg_SmsManagerImpl.cpp +++ b/src/FMsg_SmsManagerImpl.cpp @@ -38,6 +38,8 @@ #include "FMsg_RecipientListImpl.h" #include "FMsg_SmsMmsCallbackHandler.h" #include "FMsg_CbsChannelImpl.h" +#include "FMsg_MessagingIpcProxy.h" + using namespace std; using namespace Tizen::Base; @@ -56,9 +58,9 @@ _SmsManagerImpl::_SmsManagerImpl(void) , __pEtwsReceiveEvent(null) , __pSmsTriggerEventList(null) , __msgHandle(0) - , __cbsSettingsHandle(0) , __pCbsListener(null) , __pEtwsListener(null) + ,__isOpenCbsHandle(0) { } @@ -140,25 +142,13 @@ _SmsManagerImpl::Construct(const ISmsListener& listener) r = ConvertException(err); SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to register sms,mms callback."); - // open cbs message handle - err = _SmsMmsCallbackHandler::GetInstance()->OpenCbsSettingsHandle(__cbsSettingsHandle); - - if (err == MSG_ERR_NO_SIM) - { - r = E_SUCCESS; - SysLog(NID_MSG, "Sim card is not present in device"); // even no sim, return sucess so that app will launch sucess - } - else - { - r = ConvertException(err); + SysTryReturnResult(NID_MSG, _MessagingProxy::GetInstance()!= null, E_OUT_OF_MEMORY, "Failed to get msg proxy instance"); + r = _MessagingProxy::GetInstance()->OpenMsgHandle(); + SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to open messageHandle."); + r = _MessagingProxy::GetInstance()->OpenCbsHandle(); SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to open cbs Settings Handle"); + __isOpenCbsHandle = true; - // check value of cbs settings handle - SysTryReturnResult(NID_MSG, __cbsSettingsHandle > 0, E_SYSTEM, "cbsSettingsHandle is invalid."); - } - - // load cbs settings - _SmsMmsCallbackHandler::GetInstance()->LoadCbsSettings(); __pSmsEvent = move(pSmsEvent); __isConstructed = true; @@ -175,7 +165,6 @@ _SmsManagerImpl::AddSmsEventListener(int port, ISmsEventListener& eventListener) result r = E_SUCCESS; _SmsEvent* pSmsTriggerEvent = null; - int err = MSG_SUCCESS; // check duplications if (__pSmsTriggerEventList) @@ -218,17 +207,9 @@ _SmsManagerImpl::AddSmsEventListener(int port, ISmsEventListener& eventListener) r = __pSmsTriggerEventList->Add(*pSmsTriggerEvent); SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to add a listener.", GetErrorMessage(r)); - // Register SMS Trigger - err = msg_reg_sms_message_callback(__msgHandle, &_SmsMmsCallbackHandler::IncomingSmsMessageCallback, port, (void*) pSmsTriggerEvent); - - if (err != MSG_SUCCESS) - { - r = __pSmsTriggerEventList->Remove(*pSmsTriggerEvent); - r = E_SYSTEM; - SysLogException(NID_MSG, r, "[%s] Failed to register for incoming sms callback.", GetErrorMessage(r)); - - goto CATCH; - } + SysTryCatch(NID_MSG, _MessagingProxy::GetInstance()!= null, ,E_OUT_OF_MEMORY, "Failed to get msg proxy instance"); + r = _MessagingProxy::GetInstance()->AddSmsEventListener(port, __pSmsTriggerEventList); + SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to add a listener.", GetErrorMessage(r)); return r; @@ -792,7 +773,6 @@ _SmsManagerImpl::SetCbsMessageEventListener(ICbsMessageEventListener* pListener) SysAssertf(__msgHandle > 0, "message handle is invalid."); result r = E_SUCCESS; - int err = MSG_SUCCESS; if (!pListener) { @@ -823,20 +803,18 @@ _SmsManagerImpl::SetCbsMessageEventListener(ICbsMessageEventListener* pListener) r = __pCbsReceiveEvent->AddListener(*__pCbsListener, true); SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Failed to add cbs listner"); - err = msg_reg_cb_message_callback(__msgHandle, &_SmsMmsCallbackHandler::IncomingCbsMessageCallback, __isCbsSaveEnabled, null); - r = ConvertException(err); + SysTryCatch(NID_MSG, _MessagingProxy::GetInstance()!= null, r = E_OUT_OF_MEMORY,E_OUT_OF_MEMORY, "Failed to get msg proxy instance"); + r = _MessagingProxy::GetInstance()->AddCbsEtwsEventListener(__isCbsSaveEnabled); + SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Failed to set cbs incoming callback"); if (r == E_SUCCESS) { - if (_SmsMmsCallbackHandler::GetInstance()) - { - _SmsMmsCallbackHandler::GetInstance()->SetCbsAndEtwsUserEvent(_MSG_CBS, __pCbsReceiveEvent); - } - else - { - r = E_SYSTEM; - } + _MessagingProxy::GetInstance()->SetCbsAndEtwsUserEvent(_MSG_CBS, __pCbsReceiveEvent); + } + else + { + r = E_SYSTEM; } return r; @@ -859,7 +837,6 @@ _SmsManagerImpl::SetEtwsPrimaryNotificationEventListener(IEtwsPrimaryNotificatio SysAssertf(__msgHandle > 0, "message handle is invalid."); result r = E_SUCCESS; - int err = MSG_SUCCESS; if (!pListener) { @@ -891,22 +868,20 @@ _SmsManagerImpl::SetEtwsPrimaryNotificationEventListener(IEtwsPrimaryNotificatio r = __pEtwsReceiveEvent->AddListener(*__pEtwsListener, true); SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Failed to add an etws primary notification event listener."); - err = msg_reg_cb_message_callback(__msgHandle, &_SmsMmsCallbackHandler::IncomingCbsMessageCallback, __isCbsSaveEnabled, null); - r = ConvertException(err); + SysTryCatch(NID_MSG, _MessagingProxy::GetInstance()!= null, r = E_OUT_OF_MEMORY,E_OUT_OF_MEMORY, "Failed to get msg proxy instance"); + r = _MessagingProxy::GetInstance()->AddCbsEtwsEventListener(__isCbsSaveEnabled); SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM,"Failed to add an etws primary notification event listener."); if (r == E_SUCCESS) { - if (_SmsMmsCallbackHandler::GetInstance()) - { - _SmsMmsCallbackHandler::GetInstance()->SetCbsAndEtwsUserEvent(_MSG_ETWS, __pEtwsReceiveEvent); - } - else - { - r = E_SYSTEM; - } + _MessagingProxy::GetInstance()->SetCbsAndEtwsUserEvent(_MSG_ETWS, __pEtwsReceiveEvent); + } + else + { + r = E_SYSTEM; } + return r; CATCH: @@ -925,16 +900,16 @@ _SmsManagerImpl::SetSavingToCbsBoxEnabled(bool enable) { SysAssertf(__isConstructed == true, "_SmsManagerImpl 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; + SysTryReturnResult(NID_MSG, __isOpenCbsHandle == true, E_SYSTEM, "Cb handle is null"); - err = msg_reg_cb_message_callback(__msgHandle, &_SmsMmsCallbackHandler::IncomingCbsMessageCallback, enable, null); - SysTryReturnResult(NID_MSG, err == MSG_SUCCESS, E_SYSTEM, "Failed to set SavingToCbsBoxEnabled option."); + SysTryReturnResult(NID_MSG, _MessagingProxy::GetInstance()!= null, E_OUT_OF_MEMORY, "Failed to get msg proxy instance"); + r = _MessagingProxy::GetInstance()->SetSavingToCbsBoxEnabled(enable); + SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "[%s] Setting of CbsBoxEnabled Failed", GetErrorMessage(r)); __isCbsSaveEnabled = enable; - return E_SUCCESS; + return r; } bool @@ -942,13 +917,14 @@ _SmsManagerImpl::IsCbsEnabled(void) const { SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet."); SysAssertf(__msgHandle > 0, "message handle is invalid."); - SysTryReturn(NID_MSG, __cbsSettingsHandle != NULL, false, E_SYSTEM, "Cb handle is null"); + SysTryReturn(NID_MSG, __isOpenCbsHandle != false, false, E_SYSTEM, "Cb handle is null"); bool isCbsEnabled = false; - int err = MSG_SUCCESS; + result r = E_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."); + SysTryReturnResult(NID_MSG, _MessagingProxy::GetInstance()!= null, false, "Failed to get msg proxy instance"); + r = _MessagingProxy::GetInstance()->IsCbsEnabled(&isCbsEnabled); + SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "[%s] Geting the Cbs Status Failed ", GetErrorMessage(r)); return isCbsEnabled; } @@ -958,18 +934,15 @@ _SmsManagerImpl::SetCbsEnabled(bool enable) { SysAssertf(__isConstructed == true, "_SmsManagerImpl 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; + SysTryReturnResult(NID_MSG, __isOpenCbsHandle != false, E_SYSTEM, "Cb handle is null"); - err = msg_set_bool_value(__cbsSettingsHandle, MSG_CB_RECEIVE_BOOL, enable); - SysTryReturnResult(NID_MSG, err == MSG_SUCCESS, E_SYSTEM, "Failed to set cbs enabled."); + SysTryReturnResult(NID_MSG, _MessagingProxy::GetInstance()!= null, E_OUT_OF_MEMORY, "Failed to get msg proxy instance"); + r = _MessagingProxy::GetInstance()->SetCbsEnabled(enable); + SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "[%s] Set status failed", GetErrorMessage(r)); - r = _SmsMmsCallbackHandler::GetInstance()->SaveCbsSettings(); - SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "Failed to save cbs settings."); - return E_SUCCESS; + return r; } result @@ -977,22 +950,12 @@ _SmsManagerImpl::AddCbsChannel(int from, int to, Tizen::Base::String& name, bool { SysAssertf(__isConstructed == true, "_SmsManagerImpl 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 = _SmsMmsCallbackHandler::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; - } + SysTryReturnResult(NID_MSG, __isOpenCbsHandle != false, E_SYSTEM, "Cb handle is null"); - // add channel - r = _SmsMmsCallbackHandler::GetInstance()->AddCbsChannel(from, to, name, activate); - SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to add a CB Channel."); + SysTryReturnResult(NID_MSG, _MessagingProxy::GetInstance()!= null, E_OUT_OF_MEMORY, "Failed to get msg proxy instance"); + r = _MessagingProxy::GetInstance()->AddCbsChannel(from, to, name, activate); + SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "[%s] adding channel Failed", GetErrorMessage(r)); return r; } @@ -1002,13 +965,14 @@ _SmsManagerImpl::RemoveCbsChannel(int from, int to) { SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet."); SysAssertf(__msgHandle > 0, "message handle is invalid."); - SysTryReturnResult(NID_MSG, __cbsSettingsHandle != NULL, E_SYSTEM, "Cb handle is null"); + SysTryReturnResult(NID_MSG, __isOpenCbsHandle != false, E_SYSTEM, "Cb handle is null"); result r = E_SUCCESS; - // remove channel - r = _SmsMmsCallbackHandler::GetInstance()->RemoveCbsChannel(from, to); - SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to remove a CB Channel."); + SysTryReturnResult(NID_MSG, _MessagingProxy::GetInstance()!= null, E_OUT_OF_MEMORY, "Failed to get msg proxy instance"); + r = _MessagingProxy::GetInstance()->RemoveCbsChannel(from, to); + SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "[%s] To remove channel Failed", GetErrorMessage(r)); + return r; } @@ -1018,32 +982,24 @@ _SmsManagerImpl::GetCbsChannelN(int from, int to) const { SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet."); SysAssertf(__msgHandle > 0, "message handle is invalid."); - SysTryReturn(NID_MSG, __cbsSettingsHandle != null, null, E_SYSTEM, "Cb handle is null."); + SysTryReturn(NID_MSG, __isOpenCbsHandle != 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 pCbsChannel; - ClearLastResult(); - - // search channel - r = _SmsMmsCallbackHandler::GetInstance()->SearchCbsChannel(from, to, index); - SysTryReturn(NID_MSG, r == E_SUCCESS, null, r, "Failed to find the cb channel."); - - // get channel - r = _SmsMmsCallbackHandler::GetInstance()->GetCbsChannel(index, fromId, toId, channelName, isActive); - SysTryReturn(NID_MSG, r == E_SUCCESS, null, r, "Failed to get the cb channel."); + SysTryReturn(NID_MSG, _MessagingProxy::GetInstance()!= null, null, E_OUT_OF_MEMORY,"Failed to get msg proxy instance"); + r = _MessagingProxy::GetInstance()->GetCbsChannelN(from, to, isActive, channelName); + SysTryReturn(NID_MSG, r == E_SUCCESS, null, r, "Failed to get msg proxy instance"); // creates channel - pCbsChannel.reset(_CbsChannelImpl::GetCbsChannelN(fromId, toId, channelName)); + pCbsChannel.reset(_CbsChannelImpl::GetCbsChannelN(from, to, channelName)); if (isActive) { - pCbsChannel->Activate(); + _CbsChannelImpl::GetInstance(*pCbsChannel.get())->SetCbsChannelState(true); + } return pCbsChannel.release(); @@ -1054,16 +1010,17 @@ _SmsManagerImpl::GetCbsChannelListN(void) { SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet."); SysAssertf(__msgHandle > 0, "message handle is invalid."); - SysTryReturn(NID_MSG, __cbsSettingsHandle != null, null, E_SYSTEM, "Cb handle is null."); + SysTryReturn(NID_MSG, __isOpenCbsHandle != null, null, E_SYSTEM, "Cb handle is null."); result r = E_SUCCESS; unique_ptr pList; int cbChannelCount = 0; int fromId = 0; int toId = 0; - bool isActive = false; + int isActive = false; String channelName; std::unique_ptr pCbsChannel; + Tizen::Base::Collection::ArrayList pCbsList; ClearLastResult(); @@ -1074,23 +1031,31 @@ _SmsManagerImpl::GetCbsChannelListN(void) r = pList->Construct(); SysTryReturn(NID_MSG, r == E_SUCCESS, null, r, "Failed to construct array list."); - r = _SmsMmsCallbackHandler::GetInstance()->GetCbsChannelsCount(cbChannelCount); - SysTryReturn(NID_MSG, r == E_SUCCESS, null, r, "Failed to get CB Channel count."); - for (int index = 0; index < cbChannelCount; index++) + SysTryReturn(NID_MSG, _MessagingProxy::GetInstance()!= null, null, E_OUT_OF_MEMORY,"Failed to get msg proxy instance"); + r = _MessagingProxy::GetInstance()->GetCbsChannelListN(pCbsList); + SysTryReturn(NID_MSG, r == E_SUCCESS, null, r, "Failed to get msg proxy instance"); + + + cbChannelCount = pCbsList.GetCount(); + for (int index = 0; index < cbChannelCount; ) { - // get channel - r = _SmsMmsCallbackHandler::GetInstance()->GetCbsChannel(index, fromId, toId, channelName, isActive); - SysTryReturn(NID_MSG, r == E_SUCCESS, null, r , "Failed to get the cb channel."); + + Integer::Parse(*static_cast (pCbsList.GetAt(index++)), fromId); + Integer::Parse(*static_cast (pCbsList.GetAt(index++)), toId); + channelName = *static_cast (pCbsList.GetAt(index++)); + Integer::Parse(*static_cast (pCbsList.GetAt(index++)),isActive); + SysLog(NID_MSG, "cbs %d, %d, %ls, %d",fromId, toId, channelName.GetPointer(),(bool)isActive); pCbsChannel.reset(_CbsChannelImpl::GetCbsChannelN(fromId, toId, channelName)); - if (pCbsChannel && isActive) + if (isActive) { - _CbsChannelImpl::GetInstance(*pCbsChannel)->SetCbsChannelState(isActive); - // add to the list - pList->Add(*pCbsChannel.release()); + _CbsChannelImpl::GetInstance(*pCbsChannel.get())->SetCbsChannelState((bool)isActive); + } + pList->Add(*pCbsChannel.release()); } + pCbsList.RemoveAll(); return pList.release(); } diff --git a/src/FMsg_SmsManagerImpl.h b/src/FMsg_SmsManagerImpl.h index 9471581..548cc04 100644 --- a/src/FMsg_SmsManagerImpl.h +++ b/src/FMsg_SmsManagerImpl.h @@ -379,9 +379,10 @@ private: _SmsEvent* __pEtwsReceiveEvent; Tizen::Base::Collection::ArrayList* __pSmsTriggerEventList; msg_handle_t __msgHandle; - msg_struct_t __cbsSettingsHandle; ICbsMessageEventListener* __pCbsListener; IEtwsPrimaryNotificationEventListener* __pEtwsListener; + bool __isOpenCbsHandle; + }; // _SmsManagerImpl } } // Tizen::Messaging diff --git a/src/FMsg_SmsMmsCallbackHandler.cpp b/src/FMsg_SmsMmsCallbackHandler.cpp index 1a3524c..b34b160 100644 --- a/src/FMsg_SmsMmsCallbackHandler.cpp +++ b/src/FMsg_SmsMmsCallbackHandler.cpp @@ -179,7 +179,7 @@ _SmsMmsCallbackHandler::AddCbsChannel(int from, int to, Tizen::Base::String& nam int fromId = 0; int toId = 0; bool channelFound = false; - SysLog(NID_MSG, "AddCbsChannel from %d to %d name %s activate %d ",from, to, name.GetPointer(), activate); + 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++) { @@ -299,7 +299,7 @@ _SmsMmsCallbackHandler::UpdateCbsChannel(int from, int to, Tizen::Base::String n bool channelFound = false; int index = 0; CbsChannel* pCbsChannel = NULL; - SysLog(NID_MSG, "UpdateCbsChannel from %d to %d name %s activate %d ",from, to, name.GetPointer(), activate); + 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++) { @@ -528,18 +528,10 @@ _SmsMmsCallbackHandler::SetInComingSmsCallback(bool incomingSmsCallbackRegistere { __incomingSmsCallbackRegistered = incomingSmsCallbackRegistered; } - -void -_SmsMmsCallbackHandler::SetCbsAndEtwsUserEvent(_MessageType msgType, Tizen::Base::Object* pEvent) +bool +_SmsMmsCallbackHandler::GetInComingSmsCallback() { - if (msgType == _MSG_CBS) - { - __pCbsUserEvent = pEvent; - } - else - { - __pEtwsUserEvent = pEvent; - } + return __incomingSmsCallbackRegistered; } result @@ -871,7 +863,7 @@ _SmsMmsCallbackHandler::IncomingCbsMessageCallback(msg_handle_t hMsgHandle, msg_ SysLog(NID_MSG, "cbs msg_body: [%s]", msgBody); SysLog(NID_MSG, "cbs dataCodingScheme: [%d]", dataCodingScheme); - SysLog(NID_MSG, "cbs languageType: [%s]", messageLanguage.GetPointer()); + SysLog(NID_MSG, "cbs languageType: [%ls]", messageLanguage.GetPointer()); } SysLog(NID_MSG, "cbs msg_id: [%d]", messgeId); diff --git a/src/FMsg_SmsMmsCallbackHandler.h b/src/FMsg_SmsMmsCallbackHandler.h index f9a6c44..d53ab40 100644 --- a/src/FMsg_SmsMmsCallbackHandler.h +++ b/src/FMsg_SmsMmsCallbackHandler.h @@ -212,15 +212,8 @@ public: * @param[in] incomingSmsCallbackRegistered SMS registered flag */ void SetInComingSmsCallback(bool incomingSmsCallbackRegistered); + bool GetInComingSmsCallback(); - /** - * Sets the Cbs And Etws UserEvent. - * - * @since 3.0 - * @param[in] msgType message type - * @param[in] pEvent message Event - */ - void SetCbsAndEtwsUserEvent(_MessageType msgType, Tizen::Base::Object* pEvent); // for incoming CBS/Etws static void IncomingCbsMessageCallback(msg_handle_t hMsgHandle, msg_struct_t newMsg, void* pUserParam); diff --git a/src/FMsg_WapPushManagerImpl.cpp b/src/FMsg_WapPushManagerImpl.cpp index 0e5afd6..eed31db 100644 --- a/src/FMsg_WapPushManagerImpl.cpp +++ b/src/FMsg_WapPushManagerImpl.cpp @@ -33,6 +33,7 @@ #include "FMsg_Types.h" #include "FMsg_WapPushManagerImpl.h" #include "FMsg_SmsMmsCallbackHandler.h" +#include "FMsg_MessagingIpcProxy.h" using namespace Tizen::Base; using namespace Tizen::Messaging; @@ -78,14 +79,8 @@ result _WapPushManagerImpl::AddWapPushEventListener(const Tizen::Base::String& wapApplicationId, const IWapPushEventListener& listener) { 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"); - // set event if (!__pWapPushReceiveEvent) { @@ -101,38 +96,13 @@ _WapPushManagerImpl::AddWapPushEventListener(const Tizen::Base::String& wapAppli r = __pWapPushReceiveEvent->AddListener(listener, true); SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "failed to add push listner."); - SysTryCatch(NID_MSG, _SmsMmsCallbackHandler::GetInstance() != null, r = E_OUT_OF_MEMORY, r, "failed to get msg handle."); - - // open message handle - err = _SmsMmsCallbackHandler::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, &_SmsMmsCallbackHandler::IncomingWapPushMessageCallback, pWapAppId, (void*) __pWapPushReceiveEvent); - - r = ConvertException(err); - SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to Add WapPush EventListener.", GetErrorMessage(r)); - - if (pWapAppId) - { - delete[] pWapAppId; - pWapAppId = null; - } + SysTryReturnResult(NID_MSG, _MessagingProxy::GetInstance()!= null, E_OUT_OF_MEMORY, "Failed to get msg proxy instance"); + r = _MessagingProxy::GetInstance()->AddWapPushEventListener(wapApplicationId, __pWapPushReceiveEvent); return r; CATCH: - if (pWapAppId) - { - delete[] pWapAppId; - pWapAppId = null; - } + if (__pWapPushReceiveEvent) { @@ -167,149 +137,22 @@ result _WapPushManagerImpl::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(); + SysTryReturnResult(NID_MSG, _MessagingProxy::GetInstance()!= null, E_OUT_OF_MEMORY, "Failed to get msg proxy instance"); + r = _MessagingProxy::GetInstance()->RegisterCondition(wapApplicationId,contentType); - 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 _WapPushManagerImpl::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; - } + SysTryReturnResult(NID_MSG, _MessagingProxy::GetInstance()!= null, E_OUT_OF_MEMORY, "Failed to get msg proxy instance"); + r = _MessagingProxy::GetInstance()->UnregisterCondition(wapApplicationId,contentType); - 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 diff --git a/src/inc/FMsg_MessagingMessageTypes.h b/src/inc/FMsg_MessagingMessageTypes.h new file mode 100644 index 0000000..c990722 --- /dev/null +++ b/src/inc/FMsg_MessagingMessageTypes.h @@ -0,0 +1,68 @@ +// +// 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_MessagingMessageTypes.h + * @brief This is the header file for the Messaging's IPC messages. + * + * This header file contains the declarations of the IPC messages for the wap push. + */ + +#include +#include // must be modified. +#include +//#include "FMsg_MessagingIpcParamTraits.h" + +#ifndef MESSAGING_IPC_SERVER_NAME +#define MESSAGING_IPC_SERVER_NAME "osp.messaging.ipcserver.msg" +#endif +#define IPC_MESSAGE_START MessagingMsgStart +/* Sync */ + /* WapPush */ + IPC_SYNC_MESSAGE_CONTROL1_1(MessagingMsgStart_addWapPushEventListener, Tizen::Base::String /* wapApplicationId */, unsigned long /* result */) + //IPC_SYNC_MESSAGE_CONTROL1_1(MessagingMsgStart_removeWapPushEventListener, Tizen::Base::String /* wapApplicationId */, unsigned long /* result */) + IPC_SYNC_MESSAGE_CONTROL2_1(MessagingMsgStart_registerCondition, Tizen::Base::String /* wapApplicationId */, Tizen::Base::String /* contentType*/, unsigned long /* result */) + IPC_SYNC_MESSAGE_CONTROL2_1(MessagingMsgStart_unregisterCondition, Tizen::Base::String /* wapApplicationId */, Tizen::Base::String /* contentType*/, unsigned long /* result */) + + + /* etc control */ + IPC_SYNC_MESSAGE_CONTROL0_1(MessagingMsgStart_openCbsHandle, unsigned long /* result */); + IPC_SYNC_MESSAGE_CONTROL0_1(MessagingMsgStart_openMsgHandle, unsigned long /* result */); + + IPC_SYNC_MESSAGE_CONTROL1_1(MessagingMsgStart_addSmsEventListener, int /* port */, unsigned long /* result */) + IPC_SYNC_MESSAGE_CONTROL1_1(MessagingMsgStart_addCbsEtwsEventListener, bool /* enabled */, unsigned long /* result */) + + + IPC_SYNC_MESSAGE_CONTROL1_1(MessagingMsgStart_setSavingToCbsBoxEnabled, bool /* enable */, unsigned long /* result */); + IPC_SYNC_MESSAGE_CONTROL0_2(MessagingMsgStart_isCbsEnabled, bool /* isCbsEnabled */, unsigned long /* result */); + IPC_SYNC_MESSAGE_CONTROL1_1(MessagingMsgStart_setCbsEnabled, bool /* enable */, unsigned long /* result */); + IPC_SYNC_MESSAGE_CONTROL4_1(MessagingMsgStart_addCbsChannel , int /* from */, int /* to */, Tizen::Base::String /* name */, bool /* activate */, unsigned long /* result */) + IPC_SYNC_MESSAGE_CONTROL2_1(MessagingMsgStart_removeCbsChannel, int /* from */, int /* to */, unsigned long /* result */) + IPC_SYNC_MESSAGE_CONTROL2_3(MessagingMsgStart_getCbsChannelN, int /* from */, int /* to */,bool /* isActive */, Tizen::Base::String /* channelName */, unsigned long /* result */) + IPC_SYNC_MESSAGE_CONTROL0_2(MessagingMsgStart_getCbsChannelListN, Tizen::Base::Collection::ArrayList /*pCbsList*/, unsigned long /* result */) + IPC_SYNC_MESSAGE_CONTROL4_1(MessagingMsgStart_updateCbsChannel, int /* from */, int /* to */, Tizen::Base::String /* name */, bool /* isChannelEnable */, unsigned long /* result */) + + +/* Async */ + /* WapPush */ + IPC_MESSAGE_CONTROL3(MessagingMsgStart_wapPushEventCallBack, Tizen::Base::String /* header */, Tizen::Base::ByteBuffer /* body */, int /* bodyLength */) + /* Sms */ + IPC_MESSAGE_CONTROL4(MessagingMsgStart_incomingSmsCallback, int/* port */, int /* displayTime */, Tizen::Base::String /* message */, Tizen::Base::String/* senderAddress */) + IPC_MESSAGE_CONTROL5(MessagingMsgStart_incomingEtwsCallback, int /* tempReceivedTime */, Tizen::Base::ByteBuffer /* msgSerialNumber */, Tizen::Base::ByteBuffer /* msgSecurityInfo */, int /* messgeId */, Tizen::Base::ByteBuffer /* etwsMsgWarningType */) + IPC_MESSAGE_CONTROL6(MessagingMsgStart_incomingCbsCallback, Tizen::Base::String /* message */, Tizen::Base::ByteBuffer /* msgSerialNumber */, int /* tempReceivedTime */, int /* messgeId */, int /* dataCodingScheme */, Tizen::Base::String /* messageLanguage */) + + + diff --git a/src/FMsg_Types.h b/src/inc/FMsg_Types.h similarity index 100% rename from src/FMsg_Types.h rename to src/inc/FMsg_Types.h -- 2.7.4