From 6df7cd727b770f7dc9d46505ef1d55f4b2d932a4 Mon Sep 17 00:00:00 2001 From: Jinkun Jang Date: Sat, 16 Mar 2013 01:17:03 +0900 Subject: [PATCH] merge with master --- CMakeLists.txt | 9 +- inc/FMessaging.h | 4 +- inc/FMsgCbsChannel.h | 78 +- inc/FMsgCbsMessage.h | 478 +++++----- inc/FMsgDetailedEmailMessage.h | 337 +------ inc/FMsgEmailAttachment.h | 123 +-- inc/FMsgEmailManager.h | 3 +- inc/FMsgEtwsPrimaryNotification.h | 74 +- inc/FMsgICbsMessageEventListener.h | 27 - inc/FMsgIEtwsPrimaryNotificationEventListener.h | 24 - inc/FMsgISmsEventListener.h | 23 - inc/FMsgIWapPushEventListener.h | 24 - inc/FMsgMmsManager.h | 3 +- inc/FMsgPushManager.h | 18 +- inc/FMsgRecipientList.h | 3 + inc/FMsgSmsManager.h | 125 +-- inc/FMsgSmsMessage.h | 48 +- inc/FMsgTypes.h | 9 +- inc/FMsgWapPushManager.h | 62 +- inc/FMsgWapPushMessage.h | 56 +- packaging/osp-messaging.spec | 7 +- src/FMsgCbsChannel.cpp | 1 - src/FMsgCbsMessage.cpp | 9 +- src/FMsgDetailedEmailMessage.cpp | 1 - src/FMsgEmailManager.cpp | 7 +- src/FMsgEmailMessage.cpp | 7 +- src/FMsgEtwsPrimaryNotification.cpp | 4 +- src/FMsgMmsManager.cpp | 7 +- src/FMsgMmsMessage.cpp | 7 +- src/FMsgSmsManager.cpp | 7 +- src/FMsgSmsMessage.cpp | 1 - src/FMsgWapPushManager.cpp | 4 +- src/FMsgWapPushMessage.cpp | 4 +- src/FMsg_CbsChannelImpl.cpp | 119 +-- src/FMsg_CbsChannelImpl.h | 43 +- src/FMsg_CbsMessageImpl.cpp | 24 +- src/FMsg_CbsMessageImpl.h | 29 +- src/FMsg_EmailManagerImpl.cpp | 225 +++-- src/FMsg_EmailManagerImpl.h | 34 +- src/FMsg_EmailMessageImpl.cpp | 7 +- src/FMsg_EtwsPrimaryNotificationImpl.cpp | 4 +- src/FMsg_EtwsPrimaryNotificationImpl.h | 3 + src/FMsg_MmsManagerImpl.cpp | 93 +- src/FMsg_MmsManagerImpl.h | 4 +- src/FMsg_MmsMessageImpl.cpp | 7 +- src/FMsg_MsgUtil.cpp | 1118 ++++++++++++++++------- src/FMsg_MsgUtil.h | 24 +- src/FMsg_PushEventArg.h | 4 +- src/FMsg_PushManagerImpl.cpp | 31 +- src/FMsg_PushMessageImpl.cpp | 14 +- src/FMsg_SmsEvent.cpp | 49 +- src/FMsg_SmsEventArg.cpp | 145 ++- src/FMsg_SmsEventArg.h | 20 +- src/FMsg_SmsManagerImpl.cpp | 547 ++++++----- src/FMsg_SmsManagerImpl.h | 10 +- src/FMsg_SmsMmsCallbackHandler.cpp | 931 +++++++++++++++---- src/FMsg_SmsMmsCallbackHandler.h | 159 +++- src/FMsg_Types.h | 9 +- src/FMsg_WapPushManagerImpl.cpp | 91 +- src/FMsg_WapPushManagerImpl.h | 2 +- src/FMsg_WapPushMessageImpl.cpp | 4 +- 61 files changed, 2978 insertions(+), 2366 deletions(-) mode change 100755 => 100644 CMakeLists.txt mode change 100644 => 100755 inc/FMsgTypes.h mode change 100755 => 100644 packaging/osp-messaging.spec mode change 100644 => 100755 src/FMsg_PushMessageImpl.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100755 new mode 100644 index 5a37f8a..748ae95 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,9 @@ INCLUDE_DIRECTORIES( /usr/include/osp/app /usr/include/osp/base /usr/include/osp/security - /usr/include/messaging + /usr/include/msg-service + /usr/include/dbus-1.0 + /usr/lib/dbus-1.0/include /usr/include/email-service /usr/include/libxml2 ) @@ -88,9 +90,10 @@ SET(CMAKE_SHARED_LINKER_FLAGS -Wl,--no-undefined) TARGET_LINK_LIBRARIES(${this_target} "-lchromium" ) TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-appfw -losp-json -losp-net -losp-shell-core" ) TARGET_LINK_LIBRARIES(${this_target} "-lcapi-appfw-application" ) -TARGET_LINK_LIBRARIES(${this_target} "-lcapi-messaging-email" ) +TARGET_LINK_LIBRARIES(${this_target} "-ldbus-1" ) +TARGET_LINK_LIBRARIES(${this_target} "-ldbus-glib-1" ) TARGET_LINK_LIBRARIES(${this_target} "-lemail-api" ) -TARGET_LINK_LIBRARIES(${this_target} "-lcapi-messaging-messages" ) +TARGET_LINK_LIBRARIES(${this_target} "-lmsg_mapi" ) TARGET_LINK_LIBRARIES(${this_target} "-lpush" ) diff --git a/inc/FMessaging.h b/inc/FMessaging.h index 2605f56..e244683 100644 --- a/inc/FMessaging.h +++ b/inc/FMessaging.h @@ -24,7 +24,6 @@ #ifndef _FMESSAGING_H_ #define _FMESSAGING_H_ -//include #include #include #include @@ -35,6 +34,8 @@ #include #include #include +#include +#include #include #include #include @@ -42,6 +43,7 @@ #include #include #include +#include /** * @namespace Tizen::Messaging diff --git a/inc/FMsgCbsChannel.h b/inc/FMsgCbsChannel.h index 95e2664..142d571 100755 --- a/inc/FMsgCbsChannel.h +++ b/inc/FMsgCbsChannel.h @@ -15,30 +15,27 @@ // limitations under the License. // /** -* @if VISPARTNER-OPERATOR -* * @file FMsgCbsChannel.h * @brief This is the header file for the %CbsChannel class. * -* @visibility partner-operator -* * This header file contains the declarations of the %CbsChannel class. -* -* @endif */ #ifndef _FMSG_CBS_CHANNEL_H_ #define _FMSG_CBS_CHANNEL_H_ -#include +namespace Tizen { namespace Base +{ +class String; +} } + +#include namespace Tizen { namespace Messaging { class _CbsChannelImpl; /** -* @if VISPARTNER-OPERATOR -* * @class CbsChannel * @brief This class provides methods for handling a Cell Broadcast Service (CBS) channel. * @@ -46,12 +43,8 @@ class _CbsChannelImpl; * * @final This class is not intended for extension. * -* @visibility partner-operator -* * The %CbsChannel class provides methods for handling a CBS channel. @n * It allows you to get and set the CBS channel information. -* -* @endif */ class _OSP_EXPORT_ CbsChannel : public Tizen::Base::Object @@ -59,28 +52,17 @@ class _OSP_EXPORT_ CbsChannel public: /** - * @if VISPARTNER-OPERATOR - * * This destructor overrides Tizen::Base::Object::~Object(). * * @since 2.0 - * - * @visibility partner-operator - * - * @endif */ virtual ~CbsChannel(void); /** - * @if VISPARTNER-OPERATOR - * * Gets the range of a CBS channel * * @since 2.0 * - * @visibility partner-operator - * - * * @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 @@ -88,107 +70,73 @@ public: * @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 a CBS channel. * * @since 2.0 * - * @visibility partner-operator - * - * * @return The name of the channel * * @remarks The name can be an empty string. - * - * @endif */ Tizen::Base::String GetName(void) const; /** - * @if VISPARTNER-OPERATOR - * * Checks whether a CBS channel is activated. * * @since 2.0 * - * @visibility partner-operator - * - * * @return @c true if a CBS channel is activated, @n * else @c false - * - * @endif */ bool IsActivated(void) const; /** - * @if VISPARTNER-OPERATOR - * * Activates the status of a CBS channel. * * @since 2.0 - * - * @visibility partner-operator - * - * @privilege %http://tizen.org/privilege/cellbroadcast + * @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. - * - * @endif */ result Activate(void); /** - * @if VISPARTNER-OPERATOR - * * Deactivates the status of a CBS channel. - * - * @privilege %http://tizen.org/privilege/cellbroadcast + * @privlevel platform + * @privilege http://tizen.org/privilege/cellbroadcast * * @since 2.0 * - * @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 a CBS channel. - * - * @privilege %http://tizen.org/privilege/cellbroadcast + * @privlevel platform + * @privilege http://tizen.org/privilege/cellbroadcast * * @since 2.0 * - * @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); @@ -228,7 +176,7 @@ private: * - 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 (900). @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. */ diff --git a/inc/FMsgCbsMessage.h b/inc/FMsgCbsMessage.h index 0899ae7..7c3949d 100644 --- a/inc/FMsgCbsMessage.h +++ b/inc/FMsgCbsMessage.h @@ -1,267 +1,211 @@ -// -// 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 FMsgCbsMessage.h -* @brief This is the header file for the %CbsMessage class. -* -* @visibility partner-operator -* -* This header file contains the declarations of the %CbsMessage class. -* -* @endif -*/ - -#ifndef _FMSG_CBS_MESSAGE_H_ -#define _FMSG_CBS_MESSAGE_H_ - -#include -#include -#include - -namespace Tizen { namespace Messaging -{ - -class _CbsMessageImpl; - -/** -* @if VISPARTNER-OPERATOR -* -* @class CbsMessage -* -* @brief This class provides methods for handling a CBS message. -* -* @since 2.0 -* -* @final This class is not intended for extension. -* -* @visibility partner-operator -* -* The %CbsMessage class provides methods for handling a CBS message (including the ETWS secondary notification). It allows you to get the serial number, -* message ID, body text, and received time of a CBS message. -* -* @endif -*/ -class _OSP_EXPORT_ CbsMessage - : public Tizen::Base::Object -{ -public: - /** - * @if VISPARTNER-OPERATOR - * - * This destructor overrides Tizen::Base::Object::~Object(). - * - * @since 2.0 - * - * @visibility partner-operator - * - * @endif - */ - virtual ~CbsMessage(void); - - /** - * @if VISPARTNER-OPERATOR - * - * Compares the calling instance with the specified instance. - * - * @since 2.0 - * - * @visibility partner-operator - * - * @return @c true if the specified instance of Object is equal to the calling %CbsMessage instance, @n - * else @c false - * @param[in] obj An instance of Object to compare - * @see Object::Equals() - * - * @endif - */ - virtual bool Equals(const Tizen::Base::Object& obj) const; - - /** - * @if VISPARTNER-OPERATOR - * - * Copies the instance of a class. - * - * @since 2.0 - * - * @visibility partner-operator - * - * @return An instance of %CbsMessage - * @exception E_SUCCESS The method is successful. - * @exception E_OUT_OF_MEMORY The memory is insufficient. - * - * @remarks In case of error, this method returns @c null. @n - * The specific error code can be accessed using the GetLastResult() method. - * - * @endif - */ - CbsMessage* CloneN(void) const; - - /** - * @if VISPARTNER-OPERATOR - * - * Gets the hash value of the current instance. - * - * @since 2.0 - * - * @visibility partner-operator - * - * @return The hash value of the current instance - * - * @endif - */ - virtual int GetHashCode(void) const; - - /** - * @if VISPARTNER-OPERATOR - * - * Checks whether this message is an ETWS notification. - * - * @since 2.0 - * - * @visibility partner-operator - * - * @return @c true if this message is an ETWS notification, @n - * else @c false - * @remarks If the return value is @c true, the message is ETWS secondary notification. - * - * @endif - */ - bool IsEtwsNotification(void) const; - - /** - * @if VISPARTNER-OPERATOR - * - * Gets the serial number of the CBS message. - * - * @since 2.0 - * - * @visibility partner-operator - * - * @return The serial number of the CBS message - * @exception E_SUCCESS The method is successful. - * @exception E_OUT_OF_MEMORY The memory is insufficient. - * @remarks The specific error code can be accessed using the GetLastResult() method. @n - * In case of an error, this method returns null. - * - * @endif - */ - Tizen::Base::ByteBuffer* GetSerialNumberN(void) const; - - /** - * @if VISPARTNER-OPERATOR - * - * Gets the message ID of the CBS message. - * - * @since 2.0 - * - * @visibility partner-operator - * - * @return The the message ID of the CBS message - * - * @endif - */ - int GetMessageId(void) const; - - /** - * @if VISPARTNER-OPERATOR - * - * Gets the body of a message. - * - * @since 2.0 - * - * @visibility partner-operator - * - * @return The body of a message - * - * @endif - */ - Tizen::Base::String GetText(void) const; - - /** - * @if VISPARTNER-OPERATOR - * - * Gets the date and time (UTC time) of the message when it is received. - * - * @since 2.0 - * - * @visibility partner-operator - * - * @return The date and time (UTC time) when the message is received - * - * @endif - */ - Tizen::Base::DateTime GetReceivedTime(void) const; - - /** - * @if VISPARTNER-OPERATOR - * - * Gets the Data Coding Scheme of the CBS message. - * - * @since 2.0 - * - * @visibility partner-operator - * - * @return The Data Coding Scheme of the CBS message - * @exception E_SUCCESS The method is successful. - * @exception E_OUT_OF_MEMORY The memory is insufficient. - * @remarks The specific error code can be accessed using the GetLastResult() method. @n - * In case of an error, this method returns null. @n - * The alphabet/coding and the language applied to CBS messages are defined in 3GPP TS 23.038 - * - * @endif - */ - byte GetDataCodingScheme(void) const; - -private: - /** - * This default constructor is intentionally declared as private so that only the platform can create an instance. - * - * @since 2.0 - */ - CbsMessage(void); - - /** - * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. - * - * @since 2.0 - * - * @param[in] rhs An instance of %CbsMessage - */ - CbsMessage(const CbsMessage& rhs); - - /** - * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. @n - * - Use CloneN() to get an exact copy of the instance. - * - Use Equals() to compare the contents of one instance with the other. - * - * @since 2.0 - * - * @return A reference to this instance - * @param[in] rhs An instance of %CbsMessage - */ - CbsMessage& operator =(const CbsMessage& rhs); - -private: - _CbsMessageImpl* __pCbsMessageImpl; - - friend class _CbsMessageImpl; -}; // CbsMessage - -} } // Tizen::Messaging -#endif // _FMSG_CBS_MESSAGE_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 FMsgCbsMessage.h +* @brief This is the header file for the %CbsMessage class. +* +* This header file contains the declarations of the %CbsMessage class. +*/ + +#ifndef _FMSG_CBS_MESSAGE_H_ +#define _FMSG_CBS_MESSAGE_H_ + +namespace Tizen { namespace Base +{ +class ByteBuffer; +class String; +class DateTime; +} } + +#include +#include + +namespace Tizen { namespace Messaging +{ + +class _CbsMessageImpl; + +/** +* @class CbsMessage +* +* @brief This class provides methods for handling a CBS message. +* +* @since 2.0 +* +* @final This class is not intended for extension. +* +* The %CbsMessage class provides methods for handling a CBS message (including the ETWS secondary notification). It allows you to get the serial number, +* message ID, body text, and received time of a CBS message. +*/ +class _OSP_EXPORT_ CbsMessage + : public Tizen::Base::Object +{ +public: + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~CbsMessage(void); + + /** + * Compares the calling instance with the specified instance. + * + * @since 2.0 + * + * @return @c true if the specified instance of Object is equal to the calling %CbsMessage instance, @n + * else @c false + * @param[in] obj An instance of Object to compare + * @see Object::Equals() + */ + virtual bool Equals(const Tizen::Base::Object& obj) const; + + /** + * Copies the instance of a class. + * + * @since 2.0 + * + * @return An instance of %CbsMessage + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * + * @remarks In case of error, this method returns @c null. @n + * The specific error code can be accessed using the GetLastResult() method. + */ + CbsMessage* CloneN(void) const; + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + */ + virtual int GetHashCode(void) const; + + /** + * Checks whether this message is an ETWS notification. + * + * @since 2.0 + * + * @return @c true if this message is an ETWS notification, @n + * else @c false + * @remarks If the return value is @c true, the message is ETWS secondary notification. + */ + bool IsEtwsNotification(void) const; + + /** + * Gets the serial number of the CBS message. + * + * @since 2.0 + * + * @return The serial number of the CBS message + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. @n + * In case of an error, this method returns null. + */ + Tizen::Base::ByteBuffer* GetSerialNumberN(void) const; + + /** + * Gets the message ID of the CBS message. + * + * @since 2.0 + * + * @return The message ID of the CBS message + */ + int GetMessageId(void) const; + + /** + * Gets the body of a message. + * + * @since 2.0 + * + * + * @return The body of a message + */ + Tizen::Base::String GetText(void) const; + + /** + * Gets the date and time (UTC time) of the message when it is received. + * + * @since 2.0 + * + * @return The date and time (UTC time) when the message is received + */ + Tizen::Base::DateTime GetReceivedTime(void) const; + + /** + * Gets the Data Coding Scheme of the CBS message. + * + * @since 2.0 + * + * @return The Data Coding Scheme of the CBS message + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. @n + * In case of an error, this method returns null. @n + * The alphabet/coding and the language applied to CBS messages are defined in 3GPP TS 23.038 + */ + byte GetDataCodingScheme(void) const; + + /** + * Gets the language type of a message. + * + * @since 2.1 + * + * @return The language type of a message + */ + Tizen::Base::String GetLanguageType(void) const; + +private: + /** + * This default constructor is intentionally declared as private so that only the platform can create an instance. + * + * @since 2.0 + */ + CbsMessage(void); + + /** + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.0 + * + * @param[in] rhs An instance of %CbsMessage + */ + CbsMessage(const CbsMessage& rhs); + + /** + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. @n + * - Use CloneN() to get an exact copy of the instance. + * - Use Equals() to compare the contents of one instance with the other. + * + * @since 2.0 + * + * @return A reference to this instance + * @param[in] rhs An instance of %CbsMessage + */ + CbsMessage& operator =(const CbsMessage& rhs); + +private: + _CbsMessageImpl* __pCbsMessageImpl; + + friend class _CbsMessageImpl; +}; // CbsMessage + +} } // Tizen::Messaging +#endif // _FMSG_CBS_MESSAGE_H_ diff --git a/inc/FMsgDetailedEmailMessage.h b/inc/FMsgDetailedEmailMessage.h index 2bf8b64..2235432 100644 --- a/inc/FMsgDetailedEmailMessage.h +++ b/inc/FMsgDetailedEmailMessage.h @@ -15,82 +15,74 @@ // limitations under the License. // /** -* @if VISPARTNER-OPERATOR -* * @file FMsgDetailedEmailMessage.h * @brief This is the header file for the %DetailedEmailMessage class. * -* @visibility partner-operator -* * This header file contains the declarations of the %DetailedEmailMessage class. -* -* @endif */ #ifndef _FMSG_DETAILED_EMAIL_MESSAGE_H_ #define _FMSG_DETAILED_EMAIL_MESSAGE_H_ -#include +namespace Tizen { namespace Base +{ +class String; +class DateTime; +namespace Collection +{ + class IList; +} +} } + #include #include namespace Tizen { namespace Messaging { /** - * @if VISPARTNER-OPERATOR - * * @enum EmailMessageClass * * Defines the class of the email messages. * * @since 2.0 * - * @visibility partner-operator - * - * @endif */ -enum EmailMessageClass -{ - EMAIL_MESSAGE_CLASS_UNSPECIFIED = 0, /** +namespace Tizen { namespace Base +{ +class String; +} } + +#include #include namespace Tizen { namespace Messaging @@ -39,18 +38,12 @@ namespace Tizen { namespace Messaging class _EmailAttachmentImpl; /** - * @if VISPARTNER-OPERATOR - * * @class EmailAttachment * @brief This class provides methods for handling email attachments. * * @since 2.0 * - * @visibility partner-operator - * * The %EmailAttachment class provides methods for handling email attachments. - * - * @endif */ class _OSP_EXPORT_ EmailAttachment : public Tizen::Base::Object @@ -58,95 +51,58 @@ namespace Tizen { namespace Messaging // Life cycle public: /** - * @if VISPARTNER-OPERATOR - * * This is the default constructor for this class. * * @since 2.0 - * - * @visibility partner-operator - * - * @endif */ EmailAttachment(void); /** - * @if VISPARTNER-OPERATOR - * * This is the destructor for this class. * * @since 2.0 - * - * @visibility partner-operator - * - * @endif */ virtual ~EmailAttachment(void); /** - * @if VISPARTNER-OPERATOR - * * This is the copy constructor for the %EmailAttachment class. @n * Copying of objects using this copy constructor is allowed. * * @since 2.0 * - * @visibility partner-operator - * * @param[in] rhs An instance of %EmailAttachment - * - * @endif */ EmailAttachment(const EmailAttachment& rhs); - public: /** - * @if VISPARTNER-OPERATOR - * * Assigns the value of the specified instance to the current instance of %EmailAttachment. @n * Copying of objects using this copy assignment operator is allowed. * * @since 2.0 * - * @visibility partner-operator - * * @return The reference of this instance * @param[in] rhs An instance of %EmailAttachment - * - * @endif */ EmailAttachment& operator =(const EmailAttachment& rhs); /** - * @if VISPARTNER-OPERATOR - * * Compares the calling instance with the specified instance. * * @since 2.0 * - * @visibility partner-operator - * * @return @c true if the specified instance of Tizen::Base::Object is equal to the calling %EmailAttachment instance, @n * else @c false * @param[in] obj An instance of Tizen::Base::Object to compare - * - * @endif */ virtual bool Equals(const Tizen::Base::Object& obj) const; /** - * @if VISPARTNER-OPERATOR - * * Gets the hash value of the current instance. * * @since 2.0 * - * @visibility partner-operator - * * @return The hash value of the current instance - * - * @endif */ virtual int GetHashCode(void) const; @@ -156,100 +112,63 @@ namespace Tizen { namespace Messaging // Getters /////////////////////////////////////////////////////////////// /** - * @if VISPARTNER-OPERATOR - * * Gets the name of an email attachment. * * @since 2.0 * - * @visibility partner-operator - * * @return The name of an email attachment * @see SetName() - * - * @endif */ Tizen::Base::String GetName(void) const; /** - * - * @if VISPARTNER-OPERATOR - * * Gets the file path of an email attachment. * * @since 2.0 * - * @visibility partner-operator - * * @return The file path of an email attachment * @see SetFilePath() - * - * @endif */ Tizen::Base::String GetFilePath(void) const; /** - * @if VISPARTNER-OPERATOR - * * Gets the size of an email attachment. * * @since 2.0 * - * @visibility partner-operator - * * @return The size of an email attachment - * - * @endif */ int GetSize(void) const; /** - * @if VISPARTNER-OPERATOR - * * Gets the inline-content status of an email attachment. * * @since 2.0 * - * @visibility partner-operator - * * @return @c true if an email attachment has inline-content(s), @n * else @c false * @see SetInlineContentStatus() - * - * @endif */ bool GetInlineContentStatus(void) const; /** - * @if VISPARTNER-OPERATOR - * * Gets the DRM status of an email attachment. * * @since 2.0 * - * @visibility partner-operator - * * @return @c true if an email attachment contains DRM, @n * else @c false * @see SetDrmStatus() - * - * @endif */ bool GetDrmStatus(void) const; /** - * @if VISPARTNER-OPERATOR - * * Gets the MIME type of an email attachment. * * @since 2.0 * - * @visibility partner-operator - * * @return The MIME type of an email attachment * @see SetMimeType() - * - * @endif */ Tizen::Base::String GetMimeType(void) const; @@ -259,94 +178,64 @@ namespace Tizen { namespace Messaging // Setters /////////////////////////////////////////////////////////////// /** - * @if VISPARTNER-OPERATOR - * * Sets the name of an email attachment. * * @since 2.0 * - * @visibility partner-operator - * * @return An error code * @param[in] name The name of the email attachment * @exception E_SUCCESS The method is successful. * @exception E_MAX_EXCEEDED The length of the name exceeds the maximum limit (Maximum 256 characters). * @see GetName() - * - * @endif */ result SetName(const Tizen::Base::String& name); /** - * @if VISPARTNER-OPERATOR - * * Sets the file path of an email attachment. * * @since 2.0 * - * @visibility partner-operator - * * @return An error code * @param[in] filePath The file path of the attachment * @exception E_SUCCESS The method is successful. * @exception E_INVALID_ARG The length of the specified @c filePath is too long or @c 0. * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed. * @see GetFilePath() - * - * @endif */ result SetFilePath(const Tizen::Base::String& filePath); /** - * @if VISPARTNER-OPERATOR - * * Sets the inline-content status of an email attachment. * * @since 2.0 * - * @visibility partner-operator - * * @param[in] status Set to @c true to change the inline-content status of the attachment to true, @n * else @c false * @see GetInlineContentStatus() - * - * @endif */ void SetInlineContentStatus(bool status); /** - * @if VISPARTNER-OPERATOR - * * Sets the DRM status of an email attachment. * * @since 2.0 * - * @visibility partner-operator - * * @param[in] status Set to @c true to change the DRM status of the attachment to true, @n * else @c false * @see GetDrmStatus() - * - * @endif */ void SetDrmStatus(bool status); /** - * @if VISPARTNER-OPERATOR - * * Sets the MIME type of an email attachment. * * @since 2.0 * - * @visibility partner-operator - * * @return An error code * @param[in] type The MIME type of the attachment * @exception E_SUCCESS The method is successful. * @exception E_INVALID_ARG The length of the specified @c type is @c 0. * @see GetMimeType() - * - * @endif */ result SetMimeType(const Tizen::Base::String& type); diff --git a/inc/FMsgEmailManager.h b/inc/FMsgEmailManager.h index 9365d87..34a8630 100755 --- a/inc/FMsgEmailManager.h +++ b/inc/FMsgEmailManager.h @@ -144,7 +144,8 @@ namespace Tizen { namespace Messaging * Sends the email message. * * @since 2.0 - * @privilege %http://tizen.org/privilege/messaging.email + * @privlevel public + * @privilege http://tizen.org/privilege/messaging.email * * @return An error code * @param[in] message The message to be sent diff --git a/inc/FMsgEtwsPrimaryNotification.h b/inc/FMsgEtwsPrimaryNotification.h index 528f321..8bc37cb 100644 --- a/inc/FMsgEtwsPrimaryNotification.h +++ b/inc/FMsgEtwsPrimaryNotification.h @@ -15,23 +15,22 @@ // limitations under the License. // /** -* @if VISPARTNER-OPERATOR -* * @file FMsgEtwsPrimaryNotification.h * @brief This is the header file for the %EtwsPrimaryNotification class. * -* @visibility partner-operator -* * This header file contains the declarations of the %EtwsPrimaryNotification class. -* -* @endif */ #ifndef _FMSG_ETWS_PRIMARY_NOTIFICATION_H_ #define _FMSG_ETWS_PRIMARY_NOTIFICATION_H_ -#include -#include +namespace Tizen { namespace Base +{ +class DateTime; +class ByteBuffer; +} } + +#include #include namespace Tizen { namespace Messaging @@ -40,8 +39,6 @@ namespace Tizen { namespace Messaging class _EtwsPrimaryNotificationImpl; /** -* @if VISPARTNER-OPERATOR -* * @class EtwsPrimaryNotification * * @brief This class provides methods for handling an ETWS primary notification. @@ -50,162 +47,105 @@ class _EtwsPrimaryNotificationImpl; * * @final This class is not intended for extension. * -* @visibility partner-operator -* * The %EtwsPrimaryNotification class provides methods for handling an ETWS primary notification. It allows you to get the serial number, * message ID, warning type, warning security info, and received time of an ETWS primary notification. -* -* @endif */ class _OSP_EXPORT_ EtwsPrimaryNotification : public Tizen::Base::Object { public: /** - * @if VISPARTNER-OPERATOR - * * This destructor overrides Tizen::Base::Object::~Object(). * * @since 2.0 - * - * @visibility partner-operator - * - * @endif */ virtual ~EtwsPrimaryNotification(void); /** - * @if VISPARTNER-OPERATOR - * * Compares the specified instance of %EtwsPrimaryNotification with the calling instance. * * @since 2.0 * - * @visibility partner-operator - * * @return @c true if the values match, @n * else @c false * @param[in] obj The other Tizen::Base::Object to be compared * @see Tizen::Base::Object::Equals() - * - * @endif */ virtual bool Equals(const Tizen::Base::Object& obj) const; /** - * @if VISPARTNER-OPERATOR - * * Gets the copied instance of the class. * * @since 2.0 * - * @visibility partner-operator - * * @return An instance of %EtwsPrimaryNotification * @exception E_SUCCESS The method is successful. * @exception E_OUT_OF_MEMORY The memory is insufficient. * * @remarks In case of error, this method returns @c null. @n * The specific error code can be accessed using the GetLastResult() method. - * - * @endif */ EtwsPrimaryNotification* CloneN(void) const; /** - * @if VISPARTNER-OPERATOR - * * Gets the hash value of the current instance. * * @since 2.0 * - * @visibility partner-operator - * * @return The current instance's hash value - * - * @endif */ virtual int GetHashCode(void) const; /** - * @if VISPARTNER-OPERATOR - * * Gets the date and time (UTC time) of the message when it is received. * * @since 2.0 * - * @visibility partner-operator - * * @return The date and time (UTC time) when the message is received - * - * @endif */ Tizen::Base::DateTime GetReceivedTime(void) const; /** - * @if VISPARTNER-OPERATOR - * * Gets the serial number of the ETWS primary notification. * * @since 2.0 * - * @visibility partner-operator - * * @return The serial number of the ETWS primary notification * @exception E_SUCCESS The method is successful. * @exception E_OUT_OF_MEMORY The memory is insufficient. * @remarks The specific error code can be accessed using the GetLastResult() method. @n * In case of an error, this method returns null. - * - * @endif */ Tizen::Base::ByteBuffer* GetSerialNumberN(void) const; /** - * @if VISPARTNER-OPERATOR - * * Gets the message ID of the ETWS primary notification. * * @since 2.0 * - * @visibility partner-operator - * * @return The message ID of the ETWS primary notification - * - * @endif */ int GetMessageId(void) const; /** - * @if VISPARTNER-OPERATOR - * * Gets the warning type. * * @since 2.0 * - * @visibility partner-operator - * * @return The ETWS warning type of the message - * - * @endif */ Tizen::Base::ByteBuffer* GetWarningTypeN(void) const; /** - * @if VISPARTNER-OPERATOR - * * Gets the warning security information of the ETWS primary notification. * * @since 2.0 * - * @visibility partner-operator - * * @return The warning security information of the ETWS primary notification * @exception E_SUCCESS The method is successful. * @exception E_OUT_OF_MEMORY The memory is insufficient. * @remarks The specific error code can be accessed using the GetLastResult() method. @n * In case of an error, this method returns null. - * @endif */ Tizen::Base::ByteBuffer* GetWarningSecurityInfoN(void) const; diff --git a/inc/FMsgICbsMessageEventListener.h b/inc/FMsgICbsMessageEventListener.h index fce258e..690e03c 100644 --- a/inc/FMsgICbsMessageEventListener.h +++ b/inc/FMsgICbsMessageEventListener.h @@ -15,73 +15,46 @@ // limitations under the License. // /** -* @if VISPARTNER-OPERATOR -* * @file FMsgICbsMessageEventListener.h * @brief This is the header file for the %ICbsMessageEventListener interface. * * This header file contains the declarations of the %ICbsMessageEventListener interface. -* -* @visibility partner-operator -* -* @endif */ #ifndef _FMSG_ICBS_MESSAGE_EVENT_LISTENER_H_ #define _FMSG_ICBS_MESSAGE_EVENT_LISTENER_H_ -#include - namespace Tizen { namespace Messaging { class CbsMessage; /** - * @if VISPARTNER-OPERATOR - * * @interface ICbsMessageEventListener * @brief This is the listener interface for receiving CBS messages. * * @since 2.0 * - * @visibility partner-operator - * * The %ICbsMessageEventListener interface must be implemented to handle incoming CBS messages. An application must register this interface using the SmsManager::SetCbsMessageEventListener() method. - * - * @endif */ class _OSP_EXPORT_ ICbsMessageEventListener : virtual public Tizen::Base::Runtime::IEventListener { public: /** - * @if VISPARTNER-OPERATOR - * * This polymorphic destructor should be overridden if required. @n * This way, the destructors of the derived classes are called when the destructor of this interface is called. - * * @since 2.0 - * - * @visibility partner-operator - * - * @endif */ virtual ~ICbsMessageEventListener(void) {} /** - * @if VISPARTNER-OPERATOR - * * Called when a CBS message is received. * * @since 2.0 * - * @visibility partner-operator - * * @param[in] message The message that is received * @see SmsManager::SetCbsMessageEventListener() - * - * @endif */ virtual void OnCbsMessageReceived(const CbsMessage& message) = 0; diff --git a/inc/FMsgIEtwsPrimaryNotificationEventListener.h b/inc/FMsgIEtwsPrimaryNotificationEventListener.h index 2222504..539090a 100644 --- a/inc/FMsgIEtwsPrimaryNotificationEventListener.h +++ b/inc/FMsgIEtwsPrimaryNotificationEventListener.h @@ -15,16 +15,10 @@ // limitations under the License. // /** -* @if VISPARTNER-OPERATOR -* * @file FMsgIEtwsPrimaryNotificationEventListener.h * @brief This is the header file for the %IEtwsPrimaryNotificationEventListener interface. * * This header file contains the declarations of the %IEtwsPrimaryNotificationEventListener interface. -* -* @visibility partner-operator -* -* @endif */ #ifndef _FMSG_IETWS_PRIMARY_NOTIFICATION_EVENT_LISTENER_H_ @@ -37,52 +31,34 @@ namespace Tizen { namespace Messaging class EtwsPrimaryNotification; /** - * @if VISPARTNER-OPERATOR - * * @interface IEtwsPrimaryNotificationEventListener * @brief This is the listener interface for receiving ETWS primary notification. * * @since 2.0 * - * @visibility partner-operator - * * The %IEtwsPrimaryNotificationEventListener interface must be implemented to handle incoming ETWS primary notification. * An application must register this interface using the SmsManager::SetEtwsPrimaryNotificationEventListener() method. - * - * @endif */ class _OSP_EXPORT_ IEtwsPrimaryNotificationEventListener : virtual public Tizen::Messaging::ICbsMessageEventListener { public: /** - * @if VISPARTNER-OPERATOR - * * This polymorphic destructor should be overridden if required. @n * This way, the destructors of the derived classes are called when the destructor of this interface is called. * * @since 2.0 - * - * @visibility partner-operator - * - * @endif */ virtual ~IEtwsPrimaryNotificationEventListener(void) {} /** - * @if VISPARTNER-OPERATOR - * * Called when the ETWS primary notification is received. * * @since 2.0 * - * @visibility partner-operator - * * @param[in] message The ETWS primary notification that is received * @see SmsManager::SetEtwsPrimaryNotificationEventListener() - * - * @endif */ virtual void OnEtwsPrimaryNotificationReceived(const EtwsPrimaryNotification& message) = 0; diff --git a/inc/FMsgISmsEventListener.h b/inc/FMsgISmsEventListener.h index 59db18b..7acb3ff 100644 --- a/inc/FMsgISmsEventListener.h +++ b/inc/FMsgISmsEventListener.h @@ -15,15 +15,9 @@ // limitations under the License. // /** - * @if VISPARTNER - * * @file FMsgISmsEventListener.h * @brief This is the header file for the %ISmsEventListener interface. - * @visibility partner - * * This header file contains the declarations of the %ISmsEventListener interface. - * - * @endif */ #ifndef _FMSG_ISMS_EVENT_LISTENER_H_ @@ -38,20 +32,15 @@ namespace Tizen { namespace Messaging /** - * @if VISPARTNER - * * @interface ISmsEventListener * @brief This is the listener interface for receiving SMS messages. * * @since 2.0 * - * @visibility partner - * * The %ISmsEventListener interface is the listener interface for receiving SMS messages. * An application implements this interface and registers it using the SmsManager::AddSmsEventListener() method to receive SMS messages. * * For more information on the class features, see Messaging Guide. - * @endif */ class _OSP_EXPORT_ ISmsEventListener : virtual public Tizen::Base::Runtime::IEventListener @@ -59,36 +48,24 @@ namespace Tizen { namespace Messaging // Lifecycle public: /** - * @if VISPARTNER - * * This is the destructor for this class. * * @since 2.0 - * - * @visibility partner - * - * @endif */ virtual ~ISmsEventListener(void) {} // Operations public: /** - * @if VISPARTNER - * * Called when an SMS message is received. * * @since 2.0 * - * @visibility partner - * * @param[in] port A port number * @param[in] dateTime The date and time when the message is received * @param[in] message The message that is received * @see SmsManager::AddSmsEventListener() * @see SmsManager::RemoveSmsEventListener() - * - * @endif */ virtual void OnSmsMessageReceived(int port, const Tizen::Base::DateTime& dateTime, const SmsMessage& message) = 0; diff --git a/inc/FMsgIWapPushEventListener.h b/inc/FMsgIWapPushEventListener.h index 462b878..4dbab0d 100644 --- a/inc/FMsgIWapPushEventListener.h +++ b/inc/FMsgIWapPushEventListener.h @@ -15,16 +15,10 @@ // limitations under the License. // /** -* @if VISPARTNER-OPERATOR -* * @file FMsgIWapPushEventListener.h * @brief This is the header file for the %IWapPushEventListener interface. * -* @visibility partner-operator -* * This header file contains the declaration of the %IWapPushEventListener interface. -* -* @endif */ #ifndef _FMSG_IWAP_PUSH_EVENT_LISTENER_H_ @@ -36,50 +30,32 @@ namespace Tizen { namespace Messaging { /** -* @if VISPARTNER-OPERATOR -* * @interface IWapPushEventListener * @brief This is the listener interface for receiving WAP Push messages. * * @since 2.0 * -* @visibility partner-operator -* * The %IWapPushEventListener interface must be implemented to receive WAP Push messages. An application must register this interface using the WapPushManager::AddWapPushEventListener() method. -* -* @endif */ class _OSP_EXPORT_ IWapPushEventListener : virtual public Tizen::Base::Runtime::IEventListener { public: /** - * @if VISPARTNER-OPERATOR - * * This polymorphic destructor should be overridden if required. This way, the destructors of the derived * classes are called when the destructor of this interface is called. * * @since 2.0 - * - * @visibility partner-operator - * - * @endif */ virtual ~IWapPushEventListener(void) {} public: /** - * @if VISPARTNER-OPERATOR - * * Called when a WAP Push message is received. * * @since 2.0 * - * @visibility partner-operator - * * @param[in] message The WAP push message - * - * @endif */ virtual void OnWapPushMessageReceived(const WapPushMessage& message) = 0; diff --git a/inc/FMsgMmsManager.h b/inc/FMsgMmsManager.h index 85e3b3f..a5e5f2c 100755 --- a/inc/FMsgMmsManager.h +++ b/inc/FMsgMmsManager.h @@ -146,7 +146,8 @@ namespace Tizen { namespace Messaging * Sends the MMS message. * * @since 2.0 - * @privilege %http://tizen.org/privilege/messaging.mms + * @privlevel public + * @privilege http://tizen.org/privilege/messaging.mms * * @return An error code * @param[in] message The message to be sent diff --git a/inc/FMsgPushManager.h b/inc/FMsgPushManager.h index ec29162..34cdb9a 100755 --- a/inc/FMsgPushManager.h +++ b/inc/FMsgPushManager.h @@ -152,7 +152,8 @@ public: * Initializes this instance of the %PushManager class with the specified parameters. * * @since 2.0 - * @privilege %http://tizen.org/privilege/push + * @privlevel public + * @privilege http://tizen.org/privilege/push * * @pre In order to use the push messaging service, see Push Messaging Guide. * @@ -174,7 +175,8 @@ public: * This method is asynchronous. * * @since 2.0 - * @privilege %http://tizen.org/privilege/push + * @privlevel public + * @privilege http://tizen.org/privilege/push * * @pre In order to use the push messaging service, see Push Messaging Guide. * @@ -193,7 +195,8 @@ public: * This method is asynchronous. * * @since 2.0 - * @privilege %http://tizen.org/privilege/push + * @privlevel public + * @privilege http://tizen.org/privilege/push * * @pre In order to use the push messaging service, see Push Messaging Guide. * @@ -224,7 +227,8 @@ public: * If an application receives unread messages with this method, the messages are removed from the system. * * @since 2.0 - * @privilege %http://tizen.org/privilege/push + * @privlevel public + * @privilege http://tizen.org/privilege/push * * @pre In order to use the push messaging service, see Push Messaging Guide. * @@ -250,7 +254,8 @@ public: * This method is asynchronous. * * @since 2.0 - * @privilege %http://tizen.org/privilege/push and %http://tizen.org/privilege/http @n + * @privlevel public + * @privilege http://tizen.org/privilege/push and http://tizen.org/privilege/http @n * Both privileges are required * * @pre In order to use the push messaging service, see Push Messaging Guide. @@ -275,7 +280,8 @@ public: * This method is asynchronous. * * @since 2.0 - * @privilege %http://tizen.org/privilege/push and %http://tizen.org/privilege/http @n + * @privlevel public + * @privilege http://tizen.org/privilege/push and http://tizen.org/privilege/http @n * Both privileges are required * * @pre In order to use the push messaging service, see Push Messaging Guide. diff --git a/inc/FMsgRecipientList.h b/inc/FMsgRecipientList.h index ee68218..8fb18a3 100644 --- a/inc/FMsgRecipientList.h +++ b/inc/FMsgRecipientList.h @@ -145,6 +145,9 @@ namespace Tizen { namespace Messaging * @exception E_OBJ_ALREADY_EXIST The specified @c recipient is already added. * @exception E_INVALID_ARG The specified @c recipient string length is too short (< 3) or too long (> 320), or * the specified @c type is invalid. + * @remarks The limit of the number of recipients is not checked in this method. This is done in the Send() method of each manager class (SmsManager, MmsManager, and EmailManager). @n + * The minimum length of a recipient is @c 3 for a phone number and @c 5 for an email address. @n + * The maximum length of a recipient is @c 41 for a phone number and @c 320 for an email address. * @see Set() * @see GetListN() * @see SmsManager::Send() diff --git a/inc/FMsgSmsManager.h b/inc/FMsgSmsManager.h index f294af1..6ca5d4e 100755 --- a/inc/FMsgSmsManager.h +++ b/inc/FMsgSmsManager.h @@ -146,14 +146,12 @@ namespace Tizen { namespace Messaging result Construct(ISmsListener& listener); /** - * @if VISPARTNER - * * Adds the event listener for receiving SMS messages. * * @since 2.0 * - * @visibility partner - * @privilege %http://tizen.org/privilege/smstrigger + * @privlevel partner + * @privilege http://tizen.org/privilege/smstrigger * * @return An error code * @param[in] port A port number @@ -168,20 +166,16 @@ namespace Tizen { namespace Messaging * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. * @see ISmsEventListener * @see RemoveSmsEventListener() - * - * @endif */ result AddSmsEventListener(int port, ISmsEventListener& eventListener); /** - * @if VISPARTNER - * * Removes the event listener for receiving SMS messages. * * @since 2.0 * - * @visibility partner - * @privilege %http://tizen.org/privilege/smstrigger + * @privlevel partner + * @privilege http://tizen.org/privilege/smstrigger * * @return An error code * @param[in] port A port number @@ -195,8 +189,6 @@ namespace Tizen { namespace Messaging * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. * @see ISmsEventListener * @see AddSmsEventListener() - * - * @endif */ result RemoveSmsEventListener(int port, ISmsEventListener& eventListener); @@ -205,7 +197,8 @@ namespace Tizen { namespace Messaging * * @since 2.0 * - * @privilege %http://tizen.org/privilege/messaging.sms + * @privlevel public + * @privilege http://tizen.org/privilege/messaging.sms * * @return An error code * @param[in] eventListener The listener to receive SMS messages @@ -223,7 +216,8 @@ namespace Tizen { namespace Messaging * * @since 2.0 * - * @privilege %http://tizen.org/privilege/messaging.sms + * @privlevel public + * @privilege http://tizen.org/privilege/messaging.sms * * @return An error code * @param[in] eventListener The listener to receive SMS messages @@ -242,7 +236,8 @@ namespace Tizen { namespace Messaging * * @since 2.0 * - * @privilege %http://tizen.org/privilege/messaging.sms + * @privlevel public + * @privilege http://tizen.org/privilege/messaging.sms * * @return An error code * @param[in] message The message to be sent @@ -269,7 +264,8 @@ namespace Tizen { namespace Messaging * * @since 2.0 * - * @privilege %http://tizen.org/privilege/messaging.sms + * @privlevel public + * @privilege http://tizen.org/privilege/messaging.sms * * @return The total number of SMS messages in the specified message box * @param[in] type The type of message box @@ -287,7 +283,8 @@ namespace Tizen { namespace Messaging * * @since 2.0 * - * @privilege %http://tizen.org/privilege/messaging.sms + * @privlevel public + * @privilege http://tizen.org/privilege/messaging.sms * * @return A pointer to the list of the SmsMessage class instances * @param[in] pKeyword A part of the body text as a keyword (partial match) @n @@ -300,6 +297,7 @@ namespace Tizen { namespace Messaging * @exception E_SUCCESS The method is successful. * @exception E_INVALID_ARG Either of the following conditions has occurred: @n * - The specified @c pKeyword string length is less than @c 2 or greater than @c 30. @n + * - The specified @c pSenderAddress string length is less than @c 3 or greater than @c 41. @n * - The specified @c startIndex value is less than @c 0. @n * - The specified @c count value is less than @c 0 or greater than @c 20. * @exception E_OUT_OF_MEMORY The memory is insufficient. @@ -320,7 +318,8 @@ namespace Tizen { namespace Messaging * * @since 2.0 * - * @privilege %http://tizen.org/privilege/messaging.sms + * @privlevel public + * @privilege http://tizen.org/privilege/messaging.sms * * @return A pointer to the list of the SmsMessage class instances * @param[in] type The type of message box @@ -352,7 +351,8 @@ namespace Tizen { namespace Messaging * * @since 2.0 * - * @privilege %http://tizen.org/privilege/messaging.sms + * @privlevel public + * @privilege http://tizen.org/privilege/messaging.sms * * @return The full text of the specified SMS message * @param[in] messageId The unique ID of the message @@ -368,15 +368,12 @@ namespace Tizen { namespace Messaging Tizen::Base::String GetFullText(int messageId) const; /** - * @if VISPARTNER-OPERATOR - * * Sets the event listener for receiving CB messages. * * @since 2.0 * - * @visibility partner-operator - * - * @privilege %http://tizen.org/privilege/cellbroadcast + * @privlevel platform + * @privilege http://tizen.org/privilege/cellbroadcast * * @return An error code * @param[in] pListener The listener to receive CB messages @@ -384,21 +381,16 @@ namespace Tizen { namespace Messaging * @exception E_SYSTEM A system error has occurred. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. * @see ICbsMessageEventListener - * - * @endif */ result SetCbsMessageEventListener(ICbsMessageEventListener* pListener); /** - * @if VISPARTNER-OPERATOR - * * Sets the event listener for receiving ETWS primary notification. * * @since 2.0 * - * @visibility partner-operator - * - * @privilege %http://tizen.org/privilege/cellbroadcast + * @privlevel platform + * @privilege http://tizen.org/privilege/cellbroadcast * * @return An error code * @param[in] pListener The listener to receive ETWS primary notification @@ -406,21 +398,16 @@ namespace Tizen { namespace Messaging * @exception E_SYSTEM A system error has occurred. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. * @see IEtwsPrimaryNotificationEventListener - * - * @endif */ result SetEtwsPrimaryNotificationEventListener(IEtwsPrimaryNotificationEventListener* pListener); /** - * @if VISPARTNER-OPERATOR - * * Enables or disables the save option for CBS message to the CbsBox * * @since 2.0 * - * @visibility partner-operator - * - * @privilege %http://tizen.org/privilege/cellbroadcast + * @privlevel platform + * @privilege http://tizen.org/privilege/cellbroadcast * * @return An error code * @param[in] enable Set to @c true to save the message in the CbsBox, @n @@ -428,40 +415,30 @@ namespace Tizen { namespace Messaging * @exception E_SUCCESS The method is successful. * @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 SetSavingToCbsBoxEnabled(bool enable); /** - * @if VISPARTNER-OPERATOR - * * Checks whether the CB service is enabled. * * @since 2.0 * - * @visibility partner-operator - * - * @privilege %http://tizen.org/privilege/cellbroadcast + * @privlevel platform + * @privilege http://tizen.org/privilege/cellbroadcast * * @return @c true if the CB service is enabled, @n * else @c false * @see SetCbsEnabled() - * - * @endif */ bool IsCbsEnabled(void) const; /** - * @if VISPARTNER-OPERATOR - * * Enables or disables the CB service. * * @since 2.0 * - * @visibility partner-operator - * - * @privilege %http://tizen.org/privilege/cellbroadcast + * @privlevel platform + * @privilege http://tizen.org/privilege/cellbroadcast * * @return An error code * @param[in] enable Set to @c true to enable the CB service, @n @@ -470,21 +447,16 @@ namespace Tizen { namespace Messaging * @exception E_SYSTEM A system error has occurred. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. * @see IsCbsEnabled() - * - * @endif */ result SetCbsEnabled(bool enable); /** - * @if VISPARTNER-OPERATOR - * * Adds a CBS channel with specified parameters. * * @since 2.0 * - * @visibility partner-operator - * - * @privilege %http://tizen.org/privilege/cellbroadcast + * @privlevel platform + * @privilege http://tizen.org/privilege/cellbroadcast * * @return An error code * @param[in] from The starting index of the message ID of the channel @@ -497,28 +469,23 @@ namespace Tizen { namespace Messaging * - 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 (900). + * - The range (@c to - @c from) exceeds the limit (0xFFFF). * - The specified @c name string length is greater than @c 32. @n * @exception E_ALREADY_SET The channel range (@c from ~ @c to) is already set. * @exception E_ILLEGAL_ACCESS The application does not have the permission to add the CBS channel. * @exception E_SYSTEM A system error has occurred. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. * @see RemoveCbsChannel() - * - * @endif */ result AddCbsChannel(int from, int to, Tizen::Base::String& name, bool activate = true); /** - * @if VISPARTNER-OPERATOR - * * Removes a CBS channel. * * @since 2.0 * - * @visibility partner-operator - * - * @privilege %http://tizen.org/privilege/cellbroadcast + * @privlevel platform + * @privilege http://tizen.org/privilege/cellbroadcast * * @return An error code * @param[in] from The starting index of the message ID of the channel @@ -528,27 +495,22 @@ namespace Tizen { namespace Messaging * - 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 (900). + * - The range (@c to - @c from) exceeds the limit (0xFFFF). * @exception E_OBJ_NOT_FOUND The channel range (@c from ~ @c to) is not found. * @exception E_ILLEGAL_ACCESS The application does not have the permission to remove the CBS channel. * @exception E_SYSTEM A system error has occurred. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. * @see AddCbsChannel() - * - * @endif */ result RemoveCbsChannel(int from, int to); /** - * @if VISPARTNER-OPERATOR - * * Gets a CBS channel with specified range. * * @since 2.0 * - * @visibility partner-operator - * - * @privilege %http://tizen.org/privilege/cellbroadcast + * @privlevel platform + * @privilege http://tizen.org/privilege/cellbroadcast * * @return A pointer to the CBS channel with specific range. * @param[in] from The starting index of the message ID of the channel @@ -558,27 +520,22 @@ namespace Tizen { namespace Messaging * - 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 (900). + * - The range (@c to - @c from) exceeds the limit (0xFFFF). * @exception E_SYSTEM A system error has occurred. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. * @remarks The specific error code can be accessed using the GetLastResult() method. * @see AddCbsChannel() * @see RemoveCbsChannel() - * - * @endif */ CbsChannel* GetCbsChannelN(int from, int to) const; /** - * @if VISPARTNER-OPERATOR - * * Gets the CBS channel list. * * @since 2.0 * - * @visibility partner-operator - * - * @privilege %http://tizen.org/privilege/cellbroadcast + * @privlevel platform + * @privilege http://tizen.org/privilege/cellbroadcast * * @return A pointer to the list of CBS channel * @exception E_SUCCESS The method is successful. @@ -588,8 +545,6 @@ namespace Tizen { namespace Messaging * @see AddCbsChannel() * @see RemoveCbsChannel() * @see CbsChannel - * - * @endif */ Tizen::Base::Collection::IList* GetCbsChannelListN(void); diff --git a/inc/FMsgSmsMessage.h b/inc/FMsgSmsMessage.h index 9cc8499..10783cc 100755 --- a/inc/FMsgSmsMessage.h +++ b/inc/FMsgSmsMessage.h @@ -24,15 +24,20 @@ #ifndef _FMSG_SMS_MESSAGE_H_ #define _FMSG_SMS_MESSAGE_H_ -// Includes -#include -#include +namespace Tizen { namespace Base +{ +class String; +class DateTime; +} } + +#include +#include namespace Tizen { namespace Messaging { - // forward declaration for class extension class _SmsMessageImpl; + class RecipientList; /** * @class SmsMessage @@ -140,8 +145,9 @@ namespace Tizen { namespace Messaging * Gets the sender address of the SMS message. * * @since 2.0 - * - * @privilege %http://tizen.org/privilege/messaging.sms + * + * @privlevel public + * @privilege http://tizen.org/privilege/messaging.sms * * @return The sender address of the SMS message * @exception E_SUCCESS The method is successful. @@ -155,8 +161,9 @@ namespace Tizen { namespace Messaging * Gets the received time of the SMS message. * * @since 2.0 - * - * @privilege %http://tizen.org/privilege/messaging.sms + * + * @privlevel public + * @privilege http://tizen.org/privilege/messaging.sms * * @return The received time of the SMS message * @exception E_SUCCESS The method is successful. @@ -171,8 +178,9 @@ namespace Tizen { namespace Messaging * Gets the unique ID of the SMS message. * * @since 2.0 - * - * @privilege %http://tizen.org/privilege/messaging.sms + * + * @privlevel public + * @privilege http://tizen.org/privilege/messaging.sms * * @return The unique ID of the SMS message * @exception E_SUCCESS The method is successful. @@ -187,8 +195,9 @@ namespace Tizen { namespace Messaging * Gets the sent time of the SMS message. * * @since 2.0 - * - * @privilege %http://tizen.org/privilege/messaging.sms + * + * @privlevel public + * @privilege http://tizen.org/privilege/messaging.sms * * @return The sent time of the SMS message * @exception E_SUCCESS The method is successful. @@ -203,8 +212,9 @@ namespace Tizen { namespace Messaging * Gets the type of the SMS message box. * * @since 2.0 - * - * @privilege %http://tizen.org/privilege/messaging.sms + * + * @privlevel public + * @privilege http://tizen.org/privilege/messaging.sms * * @return The type of the SMS message box * @exception E_SUCCESS The method is successful. @@ -219,8 +229,9 @@ namespace Tizen { namespace Messaging * Gets the list of the recipients. * * @since 2.0 - * - * @privilege %http://tizen.org/privilege/messaging.sms + * + * @privlevel public + * @privilege http://tizen.org/privilege/messaging.sms * * @return The list of the recipient * @exception E_SUCCESS The method is successful. @@ -234,8 +245,9 @@ namespace Tizen { namespace Messaging * Checks whether the SMS message contains more than @c 160 bytes for the body text. * * @since 2.0 - * - * @privilege %http://tizen.org/privilege/messaging.sms + * + * @privlevel public + * @privilege http://tizen.org/privilege/messaging.sms * * @return @c true if this SMS message contains more than @c 160 bytes for the body text, @n * else @c false diff --git a/inc/FMsgTypes.h b/inc/FMsgTypes.h old mode 100644 new mode 100755 index 660c926..b09f527 --- a/inc/FMsgTypes.h +++ b/inc/FMsgTypes.h @@ -87,17 +87,11 @@ namespace Tizen { namespace Messaging }; /** - * @if VISPARTNER-OPERATOR - * * @enum EmailMessagePriority * * Defines the priority level for an email. * * @since 2.0 - * - * @visibility partner-operator - * - * @endif */ enum EmailMessagePriority { @@ -118,7 +112,8 @@ namespace Tizen { namespace Messaging { PUSH_ACTION_SILENT = 0, /**< Store the message without alerting the user */ PUSH_ACTION_DISCARD, /**< Discard the message */ - PUSH_ACTION_ALERT /**< Store the message and alert the user */ + PUSH_ACTION_ALERT, /**< Store the message and alert the user */ + PUSH_ACTION_LAUNCH /**< Launch the application @b Since: @b 2.1 */ }; } } // Tizen::Messaging diff --git a/inc/FMsgWapPushManager.h b/inc/FMsgWapPushManager.h index bb499d0..f74dd59 100755 --- a/inc/FMsgWapPushManager.h +++ b/inc/FMsgWapPushManager.h @@ -15,22 +15,20 @@ // limitations under the License. // /** -* @if VISPARTNER-OPERATOR -* * @file FMsgWapPushManager.h * @brief This is the header file for the %WapPushManager class. * -* @visibility partner-operator -* * This header file contains the declarations of the %WapPushManager class. -* -* @endif */ #ifndef _FMSG_WAP_PUSH_MANAGER_H_ #define _FMSG_WAP_PUSH_MANAGER_H_ -#include +namespace Tizen { namespace Base +{ +class String; +} } + #include namespace Tizen { namespace Messaging @@ -38,59 +36,39 @@ namespace Tizen { namespace Messaging class _WapPushManagerImpl; /** -* @if VISPARTNER-OPERATOR -* * @class WapPushManager * @brief This class provides methods to use the WAP Push messaging service. * * @since 2.0 * * @final This class is not intended for extension. -* -* @visibility partner-operator -* -* @endif */ class _OSP_EXPORT_ WapPushManager : public Tizen::Base::Object { public: /** - * @if VISPARTNER-OPERATOR - * * This is the default constructor for this class. * * @since 2.0 - * - * @visibility partner-operator - * - * @endif */ WapPushManager(void); /** - * @if VISPARTNER-OPERATOR - * * This destructor overrides Tizen::Base::Object::~Object(). * * @since 2.0 - * - * @visibility partner-operator - * - * @endif */ virtual ~WapPushManager(void); public: /** - * @if VISPARTNER-OPERATOR - * * Adds the event listener for receiving WAP Push messages for a specific WAP Push application ID. * * @since 2.0 * - * @visibility partner-operator - * @privilege %http://tizen.org/privilege/wappush + * @privlevel platform + * @privilege http://tizen.org/privilege/wappush * * @return An error code * @param[in] wapApplicationId The X-Wap-Application-Id indicating a WAP Push application ID @@ -103,21 +81,17 @@ public: * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. * @see IWapPushEventListener * @see RemoveWapPushEventListener() - * - * @endif */ result AddWapPushEventListener(const Tizen::Base::String& wapApplicationId, IWapPushEventListener& listener); /** - * @if VISPARTNER-OPERATOR - * * Removes the event listener for receiving WAP Push messages for a specific WAP Push application * ID. * * @since 2.0 * - * @visibility partner-operator - * @privilege %http://tizen.org/privilege/wappush + * @privlevel platform + * @privilege http://tizen.org/privilege/wappush * * @return An error code * @param[in] wapApplicationId The X-Wap-Application-Id indicating a WAP Push @@ -131,20 +105,16 @@ public: * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. * @see IWapPushEventListener * @see AddWapPushEventListener() - * - * @endif */ result RemoveWapPushEventListener(const Tizen::Base::String& wapApplicationId, IWapPushEventListener& listener); /** - * @if VISPARTNER-OPERATOR - * * Registers a condition to receive WAP Push message. * * @since 2.0 * - * @visibility partner-operator - * @privilege %http://tizen.org/privilege/wappush + * @privlevel platform + * @privilege http://tizen.org/privilege/wappush * * @return An error code * @param[in] wapApplicationId The X-Wap-Application-Id indicating a WAP push application ID. @@ -155,20 +125,16 @@ public: * @exception E_SYSTEM A system error has occurred. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. * @see UnregisterCondition() - * - * @endif */ result RegisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType); /** - * @if VISPARTNER-OPERATOR - * * Unregisters a condition to receive WAP push message. * * @since 2.0 * - * @visibility partner-operator - * @privilege %http://tizen.org/privilege/wappush + * @privlevel platform + * @privilege http://tizen.org/privilege/wappush * * @return An error code * @param[in] wapApplicationId The X-Wap-Application-Id indicating a WAP push application ID. @@ -179,8 +145,6 @@ public: * @exception E_SYSTEM A system error has occurred. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. * @see RegisterCondition() - * - * @endif */ result UnregisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType); diff --git a/inc/FMsgWapPushMessage.h b/inc/FMsgWapPushMessage.h index 030ebde..00dd4cf 100644 --- a/inc/FMsgWapPushMessage.h +++ b/inc/FMsgWapPushMessage.h @@ -15,30 +15,28 @@ // limitations under the License. // /** -* @if VISPARTNER-OPERATOR -* * @file FMsgWapPushMessage.h * @brief This is the header file for the %WapPushMessage class. * -* @visibility partner-operator -* * This header file contains the declarations of the %WapPushMessage class. -* -* @endif */ #ifndef _FMSG_WAP_PUSH_MESSAGE_H_ #define _FMSG_WAP_PUSH_MESSAGE_H_ -#include +namespace Tizen { namespace Base +{ +class String; +class ByteBuffer; +} } + +#include namespace Tizen { namespace Messaging { class _WapPushMessageImpl; /** -* @if VISPARTNER-OPERATOR -* * @class WapPushMessage * @brief This class provides methods for handling a WAP Push message. * @@ -46,116 +44,76 @@ class _WapPushMessageImpl; * * @final This class is not intended for extension. * -* @visibility partner-operator -* * The %WapPushMessage class provides methods for handling a WAP Push message. @n * The methods of this class fetches the header and the body of a WAP Push message. -* -* @endif */ class _OSP_EXPORT_ WapPushMessage : public Tizen::Base::Object { public: /** - * @if VISPARTNER-OPERATOR - * * This destructor overrides Tizen::Base::Object::~Object(). * * @since 2.0 - * - * @visibility partner-operator - * - * @endif */ virtual ~WapPushMessage(void); public: /** - * @if VISPARTNER-OPERATOR - * * Gets the header of a message. * * @since 2.0 * - * @visibility partner-operator - * * @return The header of a message * @remarks The header has X-Wap-Application-Id and Content-Type fields. - * - * @endif */ Tizen::Base::String GetHeader(void) const; /** - * @if VISPARTNER-OPERATOR - * * Gets the body of a message. * * @since 2.0 * - * @visibility partner-operator - * * @return The body of a message * @remarks The message body can be any MIME content-type. @n * In case of error, this method returns null. @n * The specific error code can be accessed using the GetLastResult() method. - * - * @endif */ Tizen::Base::ByteBuffer* GetBodyN(void) const; /** - * @if VISPARTNER-OPERATOR - * * Compares the calling instance with the specified instance. * * @since 2.0 * - * @visibility partner-operator - * * @return @c true if the specified instance of Object is equal to the calling %WapPushMessage instance, @n * else @c false * @param[in] obj An instance of Object to compare * @see Object::Equals() - * - * @endif */ virtual bool Equals(const Tizen::Base::Object& obj) const; /** - * @if VISPARTNER-OPERATOR - * * Gets the hash value of the current instance. * * @since 2.0 * - * @visibility partner-operator - * * @return The hash value of the current instance - * - * @endif */ virtual int GetHashCode(void) const; /** - * @if VISPARTNER-OPERATOR - * * Gets the copied instance of the class. * * @since 2.0 * - * @visibility partner-operator - * * @return An instance of %WapPushMessage, @n * else @c null in case of an error * @exception E_SUCCESS The method is successful. * @exception E_OUT_OF_MEMORY The memory is insufficient. * * @remarks The specific error code can be accessed using the GetLastResult() method. - * - * @endif */ WapPushMessage* CloneN(void) const; diff --git a/packaging/osp-messaging.spec b/packaging/osp-messaging.spec old mode 100755 new mode 100644 index 584a03a..c2d5843 --- a/packaging/osp-messaging.spec +++ b/packaging/osp-messaging.spec @@ -3,16 +3,17 @@ Name: osp-messaging Summary: osp messaging library -Version: 1.2.0.0 +Version: 1.2.1.0 Release: 2 Group: System/Libraries License: Apache License, Version 2.0 Source0: %{name}-%{version}.tar.gz BuildRequires: cmake BuildRequires: pkgconfig(capi-appfw-application) -BuildRequires: pkgconfig(capi-messaging-messages) -BuildRequires: pkgconfig(capi-messaging-email) +BuildRequires: pkgconfig(msg-service) BuildRequires: pkgconfig(push) +BuildRequires: pkgconfig(dbus-1) +BuildRequires: pkgconfig(dbus-glib-1) BuildRequires: pkgconfig(email-service) BuildRequires: pkgconfig(pkgmgr) BuildRequires: pkgconfig(glib-2.0) diff --git a/src/FMsgCbsChannel.cpp b/src/FMsgCbsChannel.cpp index cc01657..1853db5 100644 --- a/src/FMsgCbsChannel.cpp +++ b/src/FMsgCbsChannel.cpp @@ -27,7 +27,6 @@ * @endif */ -#include #include #include #include diff --git a/src/FMsgCbsMessage.cpp b/src/FMsgCbsMessage.cpp index 0e7f332..ddf0a07 100644 --- a/src/FMsgCbsMessage.cpp +++ b/src/FMsgCbsMessage.cpp @@ -21,7 +21,6 @@ * This file contains the implementation of the %CbsMessage class. */ -#include #include #include #include @@ -161,4 +160,12 @@ CbsMessage::GetDataCodingScheme(void) const return (__pCbsMessageImpl->GetDataCodingScheme()); } +Tizen::Base::String +CbsMessage::GetLanguageType(void) const +{ + SysAssertf(__pCbsMessageImpl != null, "The CbsChannel instance is not constructed yet."); + + return (__pCbsMessageImpl->GetLanguageType()); +} + } } // Tizen::Messaging diff --git a/src/FMsgDetailedEmailMessage.cpp b/src/FMsgDetailedEmailMessage.cpp index 2614fc9..fc57553 100644 --- a/src/FMsgDetailedEmailMessage.cpp +++ b/src/FMsgDetailedEmailMessage.cpp @@ -30,7 +30,6 @@ #include "FMsg_DetailedEmailMessageImpl.h" #include "FMsg_Types.h" - using namespace Tizen::Base; using namespace Tizen::Messaging; using namespace Tizen::Base::Collection; diff --git a/src/FMsgEmailManager.cpp b/src/FMsgEmailManager.cpp index b50fac0..cc01002 100644 --- a/src/FMsgEmailManager.cpp +++ b/src/FMsgEmailManager.cpp @@ -21,8 +21,11 @@ * This file contains the implementation of the %EmailManager class. */ -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/FMsgEmailMessage.cpp b/src/FMsgEmailMessage.cpp index 1cdab19..6a5e24a 100644 --- a/src/FMsgEmailMessage.cpp +++ b/src/FMsgEmailMessage.cpp @@ -22,8 +22,11 @@ */ #include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/FMsgEtwsPrimaryNotification.cpp b/src/FMsgEtwsPrimaryNotification.cpp index 3f6ad44..be0be7a 100644 --- a/src/FMsgEtwsPrimaryNotification.cpp +++ b/src/FMsgEtwsPrimaryNotification.cpp @@ -21,7 +21,9 @@ * This file contains the implementation of the %EtwsPrimaryNotification class. */ -#include +#include +#include +#include #include #include #include diff --git a/src/FMsgMmsManager.cpp b/src/FMsgMmsManager.cpp index 83ef086..92d8714 100644 --- a/src/FMsgMmsManager.cpp +++ b/src/FMsgMmsManager.cpp @@ -21,8 +21,11 @@ * This file contains the implementation of the %MmsManager class. */ -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/FMsgMmsMessage.cpp b/src/FMsgMmsMessage.cpp index 83b09dc..037a2e5 100644 --- a/src/FMsgMmsMessage.cpp +++ b/src/FMsgMmsMessage.cpp @@ -22,8 +22,11 @@ */ #include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/FMsgSmsManager.cpp b/src/FMsgSmsManager.cpp index fbf2214..ab3bdd7 100644 --- a/src/FMsgSmsManager.cpp +++ b/src/FMsgSmsManager.cpp @@ -21,8 +21,11 @@ * This file contains the implementation of the %SmsManager class. */ -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/FMsgSmsMessage.cpp b/src/FMsgSmsMessage.cpp index dd41192..996e82c 100644 --- a/src/FMsgSmsMessage.cpp +++ b/src/FMsgSmsMessage.cpp @@ -33,7 +33,6 @@ using namespace Tizen::Security; namespace Tizen { namespace Messaging { - SmsMessage::SmsMessage(void) { __pImpl = new (std::nothrow) _SmsMessageImpl(); diff --git a/src/FMsgWapPushManager.cpp b/src/FMsgWapPushManager.cpp index 2fd8e83..fd7c349 100644 --- a/src/FMsgWapPushManager.cpp +++ b/src/FMsgWapPushManager.cpp @@ -21,7 +21,9 @@ * This file contains the implementation of the %WapPushManger class. */ -#include +#include +#include +#include #include #include #include diff --git a/src/FMsgWapPushMessage.cpp b/src/FMsgWapPushMessage.cpp index a1ef7c2..a9eec29 100644 --- a/src/FMsgWapPushMessage.cpp +++ b/src/FMsgWapPushMessage.cpp @@ -21,7 +21,9 @@ * This file contains the implementation of the %WapPushMessage class. */ -#include +#include +#include +#include #include #include #include diff --git a/src/FMsg_CbsChannelImpl.cpp b/src/FMsg_CbsChannelImpl.cpp index 15b97bd..19b6303 100644 --- a/src/FMsg_CbsChannelImpl.cpp +++ b/src/FMsg_CbsChannelImpl.cpp @@ -27,7 +27,9 @@ * @endif */ -#include +#include +#include +#include #include #include #include @@ -35,6 +37,7 @@ #include #include "FMsg_Types.h" #include "FMsg_CbsChannelImpl.h" +#include "FMsg_SmsMmsCallbackHandler.h" using namespace Tizen::Base; using namespace Tizen::Messaging; @@ -48,7 +51,6 @@ _CbsChannelImpl::_CbsChannelImpl(void) , __toId(-1) , __channelName(L"") , __isChannelEnable(false) - , __cbsChannelHandle(0) { } @@ -58,7 +60,6 @@ _CbsChannelImpl::_CbsChannelImpl(const _CbsChannelImpl& value) __toId = value.__toId; __channelName = value.__channelName; __isChannelEnable = value.__isChannelEnable; - __cbsChannelHandle = value.__cbsChannelHandle; } _CbsChannelImpl::~_CbsChannelImpl(void) @@ -74,7 +75,6 @@ _CbsChannelImpl::operator =(const _CbsChannelImpl& rhs) __toId = rhs.__toId; __channelName = rhs.__channelName; __isChannelEnable = rhs.__isChannelEnable; - __cbsChannelHandle = rhs.__cbsChannelHandle; } return (*this); @@ -87,7 +87,6 @@ _CbsChannelImpl::Construct(int from, int to, const Tizen::Base::String& name) __toId = to; __channelName = name; __isChannelEnable = false; - __cbsChannelHandle = 0; return E_SUCCESS; } @@ -125,33 +124,17 @@ _CbsChannelImpl::GetInstance(CbsChannel& cbsChannel) return cbsChannel.__pCbsChannelImpl; } -void -_CbsChannelImpl::SetCbsChannelHandle(messages_cb_channel_h cbsChannelHandle) -{ - __cbsChannelHandle = cbsChannelHandle; -} - result _CbsChannelImpl::UpdateName(const Tizen::Base::String& name) { result r = E_SUCCESS; - int err = MESSAGES_ERROR_NONE; - char* pChannelName = null; - __channelName = name; - ClearLastResult(); - pChannelName = _StringConverter::CopyToCharArrayN(name); - SysTryReturn(NID_MSG, pChannelName != null, E_OUT_OF_MEMORY, r = E_OUT_OF_MEMORY, "memory allocation failed"); - - err = messages_cb_channel_set_name(__cbsChannelHandle, pChannelName); - r = ConvertException(err); + // save the setting + r = _SmsMmsCallbackHandler::GetInstance()->UpdateCbsChannel(__fromId, __toId, name, __isChannelEnable); + SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to save the setting."); - if (pChannelName) - { - delete[] pChannelName; - pChannelName =null; - } + __channelName = name; return r; } @@ -161,12 +144,12 @@ _CbsChannelImpl::Deactivate(void) { result r = E_SUCCESS; ClearLastResult(); - int err = MESSAGES_ERROR_NONE; - err = messages_cb_channel_set_activated(__cbsChannelHandle, false); - __isChannelEnable = false; + // save the setting + r = _SmsMmsCallbackHandler::GetInstance()->UpdateCbsChannel(__fromId, __toId, __channelName, false); + SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to save the setting."); - r = ConvertException(err); + __isChannelEnable = false; return r; } @@ -176,12 +159,12 @@ _CbsChannelImpl::Activate(void) { result r = E_SUCCESS; ClearLastResult(); - int err = MESSAGES_ERROR_NONE; - err = messages_cb_channel_set_activated(__cbsChannelHandle, true); - __isChannelEnable = true; + // save the setting + r = _SmsMmsCallbackHandler::GetInstance()->UpdateCbsChannel(__fromId, __toId, __channelName, true); + SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to save the setting."); - r = ConvertException(err); + __isChannelEnable = true; return r; } @@ -189,30 +172,13 @@ _CbsChannelImpl::Activate(void) bool _CbsChannelImpl::IsActivated(void) const { - result r = E_SUCCESS; - ClearLastResult(); - int err = MESSAGES_ERROR_NONE; - bool isActivated = false; - - err = messages_cb_channel_is_activated(__cbsChannelHandle, &isActivated); - - r = ConvertException(err); - SetLastResult(r); - - if (isActivated) - { - return isActivated; - } - else - { - return false; - } + return __isChannelEnable; } Tizen::Base::String _CbsChannelImpl::GetName(void) const { - return __channelName; + return __channelName; } result @@ -226,49 +192,16 @@ _CbsChannelImpl::GetRange(int& from, int& to) const return r; } -result -_CbsChannelImpl::ConvertException(int err) const +void +_CbsChannelImpl::SetCbsChannelName(Tizen::Base::String channelName) { - result r = E_SUCCESS; - - switch (err) - { - case MESSAGES_ERROR_NONE: - r = E_SUCCESS; - break; - - case MESSAGES_ERROR_INVALID_PARAMETER: - r = E_INVALID_ARG; - break; - - case MESSAGES_ERROR_OUT_OF_MEMORY: - r = E_OUT_OF_MEMORY; - break; - - case MESSAGES_ERROR_SERVER_NOT_READY: // Communication error between client and server - case MESSAGES_ERROR_COMMUNICATION_WITH_SERVER_FAILED: - r = E_NETWORK_UNAVAILABLE; - break; - - case MESSAGES_ERROR_NO_SIM_CARD: - r = E_DEVICE_UNAVAILABLE; - break; - - case MESSAGES_ERROR_OUT_OF_RANGE: - r = E_ALREADY_SET; - break; - - case MESSAGES_ERROR_SENDING_FAILED: - case MESSAGES_ERROR_OPERATION_FAILED: - r = E_FAILURE; - break; - - default: - r = E_SYSTEM; - break; - } + __channelName = channelName; +} - return r; +void +_CbsChannelImpl::SetCbsChannelState(bool isChannelEnable) +{ + __isChannelEnable = isChannelEnable; } } } // Tizen::Messaging diff --git a/src/FMsg_CbsChannelImpl.h b/src/FMsg_CbsChannelImpl.h index 7622e4a..ce1148d 100644 --- a/src/FMsg_CbsChannelImpl.h +++ b/src/FMsg_CbsChannelImpl.h @@ -200,6 +200,22 @@ public: */ 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 @@ -208,25 +224,15 @@ public: */ 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 - */ + /** + * Gets the Impl instance. + * + * @since 2.1 + * @return The pointer to _CbsChannelImpl + * @param[in] CbsChannel An instance of CbsChannel + */ static _CbsChannelImpl* GetInstance(CbsChannel& cbsChannel); - /** - * Sets the cbs handle to CbsChannelImpl object. - * - * @since 2.1 - * @param[in] cbsChannelHandle An Cbs Channel Handle - */ - void SetCbsChannelHandle(messages_cb_channel_h cbsChannelHandle); - - result ConvertException(int err) const; - public: /** * This default constructor is intentionally declared as private so that only the platform can create an instance. @@ -262,7 +268,7 @@ public: * @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 (900). + * 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. @@ -274,7 +280,6 @@ private: int __toId; Tizen::Base::String __channelName; bool __isChannelEnable; - messages_cb_channel_h __cbsChannelHandle; }; // _CbsChannelImpl } } // Tizen::Messaging diff --git a/src/FMsg_CbsMessageImpl.cpp b/src/FMsg_CbsMessageImpl.cpp index 2baf955..25a4200 100644 --- a/src/FMsg_CbsMessageImpl.cpp +++ b/src/FMsg_CbsMessageImpl.cpp @@ -21,16 +21,14 @@ * This file contains the implementation of the %_CbsMessageImpl class. */ -#include #include #include -#include +#include #include "FMsg_Types.h" #include "FMsg_CbsMessageImpl.h" using namespace Tizen::Base; using namespace Tizen::Messaging; -using namespace Tizen::Security; namespace Tizen { namespace Messaging { @@ -39,6 +37,7 @@ _CbsMessageImpl::_CbsMessageImpl(void) : __cbsMsgTime() , __pCbsSerialNumber(null) , __cbsSenderMsg(L"") + , __cbslanguageType(L"") , __cbsMessageId(0) , __isEtwsNotification(false) , __dataCodingScheme() @@ -56,13 +55,14 @@ _CbsMessageImpl::_CbsMessageImpl(const _CbsMessageImpl& value) __cbsSenderMsg = value.__cbsSenderMsg; __isEtwsNotification = value.__isEtwsNotification; __dataCodingScheme = value.__dataCodingScheme; + __cbslanguageType = value.__cbslanguageType; __pCbsSerialNumber->SetArray(value.__pCbsSerialNumber->GetPointer(), 0, value.__pCbsSerialNumber->GetLimit()); __pCbsSerialNumber->SetPosition(0); } result -_CbsMessageImpl::SetCbsMessageImpl(const Tizen::Base::DateTime& dateTime, const Tizen::Base::ByteBuffer& cbsSerialNumber, const Tizen::Base::String& text, int cbsMessageId, bool isEtwsNotification, byte dataCodingScheme) +_CbsMessageImpl::SetCbsMessageImpl(const Tizen::Base::DateTime& dateTime, const Tizen::Base::ByteBuffer& cbsSerialNumber, const Tizen::Base::String& text, int cbsMessageId, bool isEtwsNotification, byte dataCodingScheme, const Tizen::Base::String& languageType) { result r = E_SUCCESS; @@ -71,6 +71,7 @@ _CbsMessageImpl::SetCbsMessageImpl(const Tizen::Base::DateTime& dateTime, const __cbsSenderMsg = text; __isEtwsNotification = isEtwsNotification; __dataCodingScheme = dataCodingScheme; + __cbslanguageType = languageType; __pCbsSerialNumber = new (std::nothrow) ByteBuffer(); SysTryReturn(NID_MSG, __pCbsSerialNumber != null, E_OUT_OF_MEMORY, r = E_OUT_OF_MEMORY, "memory allocation failed"); @@ -100,6 +101,7 @@ _CbsMessageImpl::operator =(const _CbsMessageImpl& rhs) __cbsSenderMsg = rhs.__cbsSenderMsg; __isEtwsNotification = rhs.__isEtwsNotification; __dataCodingScheme = rhs.__dataCodingScheme; + __cbslanguageType = rhs.__cbslanguageType; __pCbsSerialNumber->SetArray(rhs.__pCbsSerialNumber->GetPointer(), 0, rhs.__pCbsSerialNumber->GetLimit()); __pCbsSerialNumber->SetPosition(0); @@ -117,7 +119,7 @@ _CbsMessageImpl::CloneN() const pCbsMsg = _CbsMessageImpl::GetCbsMessageN(); SysTryCatch(NID_MSG, pCbsMsg != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed"); - r = _CbsMessageImpl::GetInstance(*pCbsMsg)->SetCbsMessageImpl(__cbsMsgTime, *(__pCbsSerialNumber), __cbsSenderMsg, __cbsMessageId, __isEtwsNotification, __dataCodingScheme); + r = _CbsMessageImpl::GetInstance(*pCbsMsg)->SetCbsMessageImpl(__cbsMsgTime, *(__pCbsSerialNumber), __cbsSenderMsg, __cbsMessageId, __isEtwsNotification, __dataCodingScheme, __cbslanguageType); SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "cbsimpl message construct failed"); SetLastResult(GetLastResult()); @@ -180,6 +182,12 @@ _CbsMessageImpl::Equals(const Tizen::Base::Object& obj) const return false; } + // language type + if (__cbslanguageType != pCbsMessageImpl->__cbslanguageType) + { + return false; + } + return true; } @@ -269,4 +277,10 @@ _CbsMessageImpl::GetDataCodingScheme(void) const return __dataCodingScheme; } +Tizen::Base::String +_CbsMessageImpl::GetLanguageType(void) const +{ + return __cbslanguageType; +} + } } // Tizen::Messaging diff --git a/src/FMsg_CbsMessageImpl.h b/src/FMsg_CbsMessageImpl.h index 8e4eea2..87c307e 100644 --- a/src/FMsg_CbsMessageImpl.h +++ b/src/FMsg_CbsMessageImpl.h @@ -30,6 +30,15 @@ #ifndef _FMSG_INTERNAL_CBS_MESSAGE_IMPL_H_ #define _FMSG_INTERNAL_CBS_MESSAGE_IMPL_H_ +namespace Tizen { namespace Base +{ +class ByteBuffer; +class String; +class DateTime; +} } + +#include + namespace Tizen { namespace Messaging { @@ -225,6 +234,23 @@ public: * @endif */ byte GetDataCodingScheme(void) const; + + /** + + * @if VISPARTNER-OPERATOR + * + * Gets the language type of a message. + * + + * @since 2.1 + * + * @visibility partner-operator + * + * @return The language type of a message + * + * @endif + */ + Tizen::Base::String GetLanguageType(void) const; public: /** @@ -286,12 +312,13 @@ public: * @exception E_OUT_OF_MEMORY The memory is insufficient. * @exception E_SYSTEM A system error has occurred. */ - result SetCbsMessageImpl(const Tizen::Base::DateTime& dateTime, const Tizen::Base::ByteBuffer& cbsSerialNumber, const Tizen::Base::String& text, int cbsMessageId, bool isEtwsNotification, byte dataCodingScheme); + result SetCbsMessageImpl(const Tizen::Base::DateTime& dateTime, const Tizen::Base::ByteBuffer& cbsSerialNumber, const Tizen::Base::String& text, int cbsMessageId, bool isEtwsNotification, byte dataCodingScheme, const Tizen::Base::String& languageType); private: Tizen::Base::DateTime __cbsMsgTime; Tizen::Base::ByteBuffer* __pCbsSerialNumber; Tizen::Base::String __cbsSenderMsg; + Tizen::Base::String __cbslanguageType; int __cbsMessageId; bool __isEtwsNotification; byte __dataCodingScheme; diff --git a/src/FMsg_EmailManagerImpl.cpp b/src/FMsg_EmailManagerImpl.cpp index 90cb1c2..287c68e 100644 --- a/src/FMsg_EmailManagerImpl.cpp +++ b/src/FMsg_EmailManagerImpl.cpp @@ -21,8 +21,11 @@ * This file contains the implementation of the %_EmailManagerImpl class. */ -#include -#include +#include +#include +#include +#include +#include #include #include #include @@ -42,6 +45,9 @@ using namespace Tizen::Base::Collection; namespace Tizen { namespace Messaging { + ArrayListT<_EmailAsyncData*>* _EmailManagerImpl::__pEmailAsyncData = null; + Tizen::Base::Runtime::Mutex * _EmailManagerImpl::__pMutex = null; + _EmailManagerImpl::_EmailManagerImpl(void) : __pEmailEvent(null) , __isConstructed(false) @@ -79,43 +85,112 @@ _EmailManagerImpl::Construct(IEmailListener& listener) } void -_EmailManagerImpl::SentEmailStatusCallback(email_h emailHandle, email_sending_e status, void* pData) +_EmailManagerImpl::SentEmailStatusCallback(int msgId, email_noti_on_network_event status, int errorCode ) { result r = E_SUCCESS; switch (status) { - case EMAIL_SENDING_FAILED: + case NOTI_SEND_FAIL: { r = E_FAILURE; - _EmailEvent* pEmailEvent = static_cast <_EmailEvent*>(pData); - _EmailEventArg* pEmailEventArg = null; + _EmailEvent* pEmailEvent = null; + _EmailAsyncData *pEmailAsyncData = null; - if (pEmailEvent) + for( int i=0; i < _EmailManagerImpl::__pEmailAsyncData->GetCount() ; i++) { - pEmailEventArg = new (std::nothrow) _EmailEventArg(r); - if (pEmailEventArg) + _EmailManagerImpl::__pMutex->Acquire(); + _EmailManagerImpl::__pEmailAsyncData->GetAt(i, pEmailAsyncData); + if ( null == pEmailAsyncData) + { + _EmailManagerImpl::__pMutex->Release(); + break; + + } + if ( msgId == pEmailAsyncData->msgId ) { - pEmailEvent->Fire(*pEmailEventArg); + _EmailManagerImpl::__pEmailAsyncData->RemoveAt(i); + } + _EmailManagerImpl::__pMutex->Release(); + + + if (msgId == pEmailAsyncData->msgId); + { + _EmailEventArg* pEmailEventArg = null; + pEmailEvent = pEmailAsyncData->pEventData; + + if (pEmailEvent) + { + pEmailEventArg = new (std::nothrow) _EmailEventArg(r); + if (pEmailEventArg) + { + pEmailEvent->Fire(*pEmailEventArg); + } + } + if (pEmailAsyncData) + { + delete []pEmailAsyncData; + pEmailAsyncData = null; + + } + + break; } } + + } break; - case EMAIL_SENDING_SUCCEEDED: + case NOTI_SEND_FINISH: { r = E_SUCCESS; - _EmailEvent* pEmailEvent = static_cast <_EmailEvent*>(pData); - _EmailEventArg* pEmailEventArg = null; + _EmailEvent* pEmailEvent = null; + _EmailAsyncData *pEmailAsyncData = null; - if (pEmailEvent) + for( int i=0; i < _EmailManagerImpl::__pEmailAsyncData->GetCount() ; i++) { - pEmailEventArg = new (std::nothrow) _EmailEventArg(r); - if (pEmailEventArg) + _EmailManagerImpl::__pMutex->Acquire(); + _EmailManagerImpl::__pEmailAsyncData->GetAt(i, pEmailAsyncData); + if ( null == pEmailAsyncData) { - pEmailEvent->Fire(*pEmailEventArg); + _EmailManagerImpl::__pMutex->Release(); + break; + + } + if ( msgId == pEmailAsyncData->msgId ) + { + _EmailManagerImpl::__pEmailAsyncData->RemoveAt(i); + } + _EmailManagerImpl::__pMutex->Release(); + + + if (msgId == pEmailAsyncData->msgId); + { + _EmailEventArg* pEmailEventArg = null; + pEmailEvent = pEmailAsyncData->pEventData; + + if (pEmailEvent) + { + pEmailEventArg = new (std::nothrow) _EmailEventArg(r); + if (pEmailEventArg) + { + pEmailEvent->Fire(*pEmailEventArg); + } + } + + if (pEmailAsyncData) + { + delete []pEmailAsyncData; + pEmailAsyncData = null; + + } + + break; } } + + } break; @@ -125,48 +200,68 @@ _EmailManagerImpl::SentEmailStatusCallback(email_h emailHandle, email_sending_e } } + result _EmailManagerImpl::Send(const EmailMessage& message, const RecipientList& recipientList, bool saveToSentBox) { result r = E_SUCCESS; - int err = EMAIL_ERROR_NONE; - email_h emailMsg = {0}; + int msgId = -1; + int requestId = 0; + _EmailAsyncData *pTemp=null; - - SysAssertf(__isConstructed == true, "_EmailManagerImpl instance is not constructed yet."); + SysAssertf(__isConstructed == true, "The _EmailManagerImpl instance is not constructed yet."); SysLog(NID_MSG, "sending an email message."); - err = email_create_message(&emailMsg); - r = ConvertException(err); - SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to create msg.", GetErrorMessage(r)); - - err = _MsgUtil::GetEmailMessage(message, recipientList, emailMsg); - r = ConvertException(err); - SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to get email.", GetErrorMessage(r)); - - err = email_save_message(emailMsg); - r = ConvertException(err); - SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to save msg.", GetErrorMessage(r)); + r = _MsgUtil::SendEmail(message, recipientList, msgId, requestId); + SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to send the email message.", GetErrorMessage(r)); + + pTemp = new (std::nothrow) _EmailAsyncData(); + SysTryCatch(NID_MSG, pTemp != null, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] Failed to allocate memory."); + + pTemp->requestId = requestId; + pTemp->msgId = msgId; + pTemp->pEventData = __pEmailEvent.get(); + + if(null ==__pEmailAsyncData) + + { + __pEmailAsyncData = new (std::nothrow) ArrayListT<_EmailAsyncData*> ; + SysTryCatch(NID_MSG, __pEmailAsyncData != null, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] Failed to allocate memory."); + __pEmailAsyncData->Construct(); + + } - err = email_set_message_sent_cb(emailMsg, &_EmailManagerImpl::SentEmailStatusCallback, (void*) (__pEmailEvent.get())); - r = ConvertException(err); - SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to set cb.", GetErrorMessage(r)); + __pEmailAsyncData->Add(pTemp); - err = email_send_message(emailMsg, saveToSentBox); - r = ConvertException(err); - SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to send the email message.", GetErrorMessage(r)); - email_destroy_message(emailMsg); + if ( null == __pMutex) + { + __pMutex = new (std::nothrow) Tizen::Base::Runtime::Mutex(); + SysTryCatch(NID_MSG, __pMutex != null, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] Failed to allocate memory."); + __pMutex->Create(); + + } - SysLog(NID_MSG, "sending an email message success"); return r; CATCH: + + if (pTemp) + { + if (__pEmailAsyncData->Contains(pTemp)) + { + __pEmailAsyncData->Remove(pTemp); + + } + delete pTemp; + pTemp = null; + + } - email_destroy_message(emailMsg); return r; } + _EmailManagerImpl* _EmailManagerImpl::GetInstance(EmailManager& emailManager) { @@ -179,52 +274,4 @@ _EmailManagerImpl::GetInstance(const EmailManager& emailManager) return emailManager.__pImpl; } -result -_EmailManagerImpl::ConvertException(int err) const -{ - result r = E_SUCCESS; - - switch (err) - { - case EMAIL_ERROR_NONE: - r = E_SUCCESS; - break; - - case EMAIL_ERROR_OPERATION_FAILED: - r = E_INVALID_CONDITION; - break; - - //case EMF_ERROR_INVALID_ADDRESS: - // r = E_INVALID_ADDRESS; - // break; - - case EMAIL_ERROR_INVALID_PARAMETER: - r = E_INVALID_ARG; - break; - - case EMAIL_ERROR_ACCOUNT_NOT_FOUND: - r = E_INVALID_ACCOUNT; - break; - - case EMAIL_ERROR_SERVER_NOT_READY: - r = E_NETWORK_UNAVAILABLE; - break; - - case EMAIL_ERROR_COMMUNICATION_WITH_SERVER_FAILED: - r = E_ON_INITIALIZING; - break; - - case EMAIL_ERROR_DB_FAILED: - case EMAIL_ERROR_OUT_OF_MEMORY: - r = E_STORAGE_FULL; - break; - - default: - r = E_SYSTEM; - break; - } - - return r; -} - } } // Tizen::Messaging diff --git a/src/FMsg_EmailManagerImpl.h b/src/FMsg_EmailManagerImpl.h index 583dae6..3a06077 100644 --- a/src/FMsg_EmailManagerImpl.h +++ b/src/FMsg_EmailManagerImpl.h @@ -36,6 +36,17 @@ class EmailMessage; class RecipientList; class _EmailEvent; + +class _EmailAsyncData +{ +public: + int requestId; + int msgId; + _EmailEvent *pEventData; + +}; + + /** * @class _EmailManagerImpl * @brief This class provides methods to use the email messaging service. @@ -128,30 +139,25 @@ public: */ static const _EmailManagerImpl* GetInstance(const EmailManager& emailManager); - //utility -private: + + /** * Call back for sent message * - * @param[in] hMsgHandle The message handle. - * @param[in] pMsgStatus The sent message status. - * @param[in] pUserParam The callback object.. + * @param[in] msgId The msg Id + * @param[in] status The sent message status. + * @param[in] errorCode The error code. * */ - static void SentEmailStatusCallback(email_h emailHandle, email_sending_e status, void* pData); + static void SentEmailStatusCallback(int msgId, email_noti_on_network_event status, int errorCode ); - /** - * Converts platform error codes to BADA fwk error codes - * - * @return An error code - * @param[in] err The error to convert - * - */ - result ConvertException(int err) const; private: std::unique_ptr<_EmailEvent> __pEmailEvent; bool __isConstructed; + static Tizen::Base::Collection::ArrayListT<_EmailAsyncData*>*__pEmailAsyncData; + static Tizen::Base::Runtime::Mutex *__pMutex; + }; // _EmailManagerImpl } } // Tizen::Messaging diff --git a/src/FMsg_EmailMessageImpl.cpp b/src/FMsg_EmailMessageImpl.cpp index 39431b2..6eaa6cc 100644 --- a/src/FMsg_EmailMessageImpl.cpp +++ b/src/FMsg_EmailMessageImpl.cpp @@ -22,8 +22,11 @@ */ #include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/FMsg_EtwsPrimaryNotificationImpl.cpp b/src/FMsg_EtwsPrimaryNotificationImpl.cpp index e6ba3ef..da777bf 100644 --- a/src/FMsg_EtwsPrimaryNotificationImpl.cpp +++ b/src/FMsg_EtwsPrimaryNotificationImpl.cpp @@ -21,7 +21,9 @@ * This file contains the implementation of the %_EtwsPrimaryNotificationImpl class. */ -#include +#include +#include +#include #include #include #include diff --git a/src/FMsg_EtwsPrimaryNotificationImpl.h b/src/FMsg_EtwsPrimaryNotificationImpl.h index e92c61b..02f4894 100644 --- a/src/FMsg_EtwsPrimaryNotificationImpl.h +++ b/src/FMsg_EtwsPrimaryNotificationImpl.h @@ -30,6 +30,9 @@ #ifndef _FMSG_INTERNAL_ETWS_PRIMARY_NOTIFICATION_IMPL_H_ #define _FMSG_INTERNAL_ETWS_PRIMARY_NOTIFICATION_IMPL_H_ +#include +#include + namespace Tizen { namespace Messaging { diff --git a/src/FMsg_MmsManagerImpl.cpp b/src/FMsg_MmsManagerImpl.cpp index 825b68d..16b392d 100644 --- a/src/FMsg_MmsManagerImpl.cpp +++ b/src/FMsg_MmsManagerImpl.cpp @@ -21,8 +21,11 @@ * This file contains the implementation of the %_MmsManagerImpl class. */ -#include -#include +#include +#include +#include +#include +#include #include #include #include @@ -54,14 +57,14 @@ _MmsManagerImpl::_MmsManagerImpl(void) _MmsManagerImpl::~_MmsManagerImpl(void) { result r = E_SUCCESS; - int err = MESSAGES_ERROR_NONE; + int err = MSG_SUCCESS; if (_SmsMmsCallbackHandler::GetInstance()) { err = _SmsMmsCallbackHandler::GetInstance()->CloseMessageHandle(); } - if (err != MESSAGES_ERROR_NONE) + if (err != MSG_SUCCESS) { r = ConvertException(err); SysLogException(NID_MSG, r, "[%s] Failed to close message handle.", GetErrorMessage(r)); @@ -74,7 +77,7 @@ result _MmsManagerImpl::Construct(IMmsListener& listener) { result r = E_SUCCESS; - int err = MESSAGES_ERROR_NONE; + int err = MSG_SUCCESS; SysAssertf(__isConstructed == false, "_MmsManagerImpl instance is already constructed."); @@ -111,34 +114,67 @@ _MmsManagerImpl::Construct(IMmsListener& listener) result _MmsManagerImpl::Send(const MmsMessage& message, const RecipientList& recipientList, bool saveToSentBox) { + SysAssertf(__isConstructed == true, "_MmsManagerImpl instance is not constructed yet."); + result r = E_SUCCESS; - messages_message_h mmsMsg = {0}; - int err = MESSAGES_ERROR_NONE; - bool saveMsgToSentbox = saveToSentBox; + int err = MSG_SUCCESS; + int msgReqId = -1; + msg_struct_t msgOption = NULL; - SysAssertf(__isConstructed == true, "_MmsManagerImpl instance is not constructed yet."); SysLog(NID_MSG, "sending an mms message"); - //pack mms message - err = _MsgUtil::GetMmsMessage(message, recipientList, mmsMsg); + msg_struct_t msgReq = msg_create_struct(MSG_STRUCT_REQUEST_INFO); + msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + msg_struct_t msgSendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); + + msg_set_bool_value(msgSendOpt, MSG_SEND_OPT_SETTING_BOOL, true); + msg_set_bool_value(msgSendOpt, MSG_SEND_OPT_DELIVER_REQ_BOOL, false); + msg_set_bool_value(msgSendOpt, MSG_SEND_OPT_KEEPCOPY_BOOL, saveToSentBox); + + msg_get_struct_handle(msgSendOpt, MSG_SEND_OPT_MMS_OPT_HND, &msgOption); + msg_set_bool_value(msgOption, MSG_MMS_SENDOPTION_READ_REQUEST_BOOL, false); + msg_set_int_value(msgOption, MSG_MMS_SENDOPTION_PRIORITY_INT, MSG_MESSAGE_PRIORITY_NORMAL); + msg_set_int_value(msgOption, MSG_MMS_SENDOPTION_EXPIRY_TIME_INT, MSG_EXPIRY_TIME_MAXIMUM); + msg_set_int_value(msgOption, MSG_MMS_SENDOPTION_DELIVERY_TIME_INT, MSG_DELIVERY_TIME_IMMEDIATLY); + + err = _MsgUtil::GetMmsMessage(msgInfo, message, recipientList); + + r = ConvertException(err); + SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to generate the MMS message.", GetErrorMessage(r)); + + msg_set_struct_handle(msgReq, MSG_REQUEST_MESSAGE_HND, msgInfo); + msg_set_struct_handle(msgReq, MSG_REQUEST_SENDOPT_HND, msgSendOpt); - if (err == MESSAGES_ERROR_NONE) + if (err == MSG_SUCCESS) { - err = messages_send_message(__msgHandle, mmsMsg, saveMsgToSentbox, &_SmsMmsCallbackHandler::SentMmsMessageStatusCallback, - (void*) (__pMmsEvent.get())); + err = msg_mms_send_message(__msgHandle, msgReq); } r = ConvertException(err); + + if (r == E_SUCCESS) + { + if (_SmsMmsCallbackHandler::GetInstance()) + { + msg_get_int_value(msgReq, MSG_REQUEST_REQUESTID_INT, &msgReqId); + r = _SmsMmsCallbackHandler::GetInstance()->AddToMessageMap(msgReqId, _MSG_MMS, __pMmsEvent.get()); + } + else + { + r = E_SYSTEM; + } + } + SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to send the MMS message.", GetErrorMessage(r)); //release message - messages_destroy_message(mmsMsg); - + msg_release_struct(&msgReq); SysLog(NID_MSG, "sending an mms message success"); return r; CATCH: - messages_destroy_message(mmsMsg); + //release message + msg_release_struct(&msgReq); return r; } @@ -161,33 +197,32 @@ _MmsManagerImpl::ConvertException(int err) const switch (err) { - case MESSAGES_ERROR_NONE: + case MSG_SUCCESS: r = E_SUCCESS; break; - case MESSAGES_ERROR_INVALID_PARAMETER: + case MSG_ERR_INVALID_PARAMETER: + case MSG_ERR_INVALID_MESSAGE: + case MSG_ERR_NULL_POINTER: + case MSG_ERR_NULL_MESSAGE: r = E_INVALID_ARG; break; - case MESSAGES_ERROR_OUT_OF_MEMORY: + case MSG_ERR_MEMORY_ERROR: r = E_OUT_OF_MEMORY; break; - case MESSAGES_ERROR_SERVER_NOT_READY: - case MESSAGES_ERROR_COMMUNICATION_WITH_SERVER_FAILED: + case MSG_ERR_SERVER_NOT_READY: + case MSG_ERR_TRANSPORT_ERROR: + case MSG_ERR_COMMUNICATION_ERROR: r = E_NETWORK_UNAVAILABLE; break; - case MESSAGES_ERROR_NO_SIM_CARD: + case MSG_ERR_NO_SIM: r = E_DEVICE_UNAVAILABLE; break; - case MESSAGES_ERROR_OUT_OF_RANGE: - r = E_ALREADY_SET; - break; - - case MESSAGES_ERROR_SENDING_FAILED: - case MESSAGES_ERROR_OPERATION_FAILED: + case MSG_ERR_PLUGIN_TAPI_FAILED: r = E_FAILURE; break; diff --git a/src/FMsg_MmsManagerImpl.h b/src/FMsg_MmsManagerImpl.h index 632385a..75e08d0 100644 --- a/src/FMsg_MmsManagerImpl.h +++ b/src/FMsg_MmsManagerImpl.h @@ -131,7 +131,7 @@ public: //utility private: /** - * Converts platform error codes to BADA fwk error codes + * Converts platform error codes * * @return An error code * @param[in] err The error to convert @@ -142,7 +142,7 @@ private: private: std::unique_ptr<_MmsEvent> __pMmsEvent; bool __isConstructed; - messages_service_h __msgHandle; + msg_handle_t __msgHandle; }; // _MmsManagerImpl } } diff --git a/src/FMsg_MmsMessageImpl.cpp b/src/FMsg_MmsMessageImpl.cpp index 70a7534..e28a57d 100644 --- a/src/FMsg_MmsMessageImpl.cpp +++ b/src/FMsg_MmsMessageImpl.cpp @@ -22,8 +22,11 @@ */ #include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/FMsg_MsgUtil.cpp b/src/FMsg_MsgUtil.cpp index af8db27..34feb07 100644 --- a/src/FMsg_MsgUtil.cpp +++ b/src/FMsg_MsgUtil.cpp @@ -22,8 +22,12 @@ */ // includes -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -32,6 +36,7 @@ #include #include #include "FMsg_SmsMessageImpl.h" +#include "FMsg_EmailManagerImpl.h" #include "FMsg_MsgUtil.h" using namespace Tizen::Base; @@ -39,6 +44,8 @@ using namespace Tizen::Base::Collection; using namespace Tizen::Base::Utility; using namespace Tizen::Io; +static const char* BODY_TEXT_FILE_NAME = "/tmp/mmsbodytext.txt"; + namespace Tizen { namespace Messaging { @@ -409,7 +416,7 @@ _MsgUtil::CheckPhoneNumberValidity(_MessageType type, const RecipientList& recip { pItem = dynamic_cast< String* >(pToList->GetAt(index)); SysTryCatch(NID_MSG, pItem != null, r = E_INVALID_ADDRESS, r, "To List Null"); - r = CheckAddressValidity(*pItem, type); + r = CheckAddressValidity(*pItem, type); if (type == _MSG_MMS && r != E_SUCCESS) //Check If MMS might have email address { @@ -830,24 +837,24 @@ _MsgUtil::IsValidPhoneNumber(const Tizen::Base::String& phoneNumber) } SmsMessageBoxType -_MsgUtil::GetSmsMessageBoxType(messages_message_box_e folderId) +_MsgUtil::GetSmsMessageBoxType(_MSG_FOLDER_ID_E folderId) { SmsMessageBoxType type = SMS_MESSAGE_BOX_TYPE_NONE; switch (folderId) { - case MESSAGES_MBOX_INBOX: + case MSG_INBOX_ID: type = SMS_MESSAGE_BOX_TYPE_INBOX; break; - case MESSAGES_MBOX_OUTBOX: + case MSG_OUTBOX_ID: type = SMS_MESSAGE_BOX_TYPE_OUTBOX; break; - case MESSAGES_MBOX_SENTBOX: + case MSG_SENTBOX_ID: type = SMS_MESSAGE_BOX_TYPE_SENTBOX; break; -// case MESSAGES_MBOX_ALL: +// case MSG_ALLBOX_ID: // type = SMS_MESSAGE_BOX_TYPE_ALL; // break; @@ -859,31 +866,31 @@ _MsgUtil::GetSmsMessageBoxType(messages_message_box_e folderId) return type; } -messages_message_box_e +_MSG_FOLDER_ID_E _MsgUtil::GetMsgFolderId(const SmsMessageBoxType& type) { - messages_message_box_e folderId; + _MSG_FOLDER_ID_E folderId; switch (type) { case SMS_MESSAGE_BOX_TYPE_INBOX: - folderId = MESSAGES_MBOX_INBOX; + folderId = MSG_INBOX_ID; break; case SMS_MESSAGE_BOX_TYPE_OUTBOX: - folderId = MESSAGES_MBOX_OUTBOX; + folderId = MSG_OUTBOX_ID; break; case SMS_MESSAGE_BOX_TYPE_SENTBOX: - folderId = MESSAGES_MBOX_SENTBOX; + folderId = MSG_SENTBOX_ID; break; case SMS_MESSAGE_BOX_TYPE_ALL: - folderId = MESSAGES_MBOX_ALL; + folderId = MSG_ALLBOX_ID; break; default: - folderId = (messages_message_box_e) -1; + folderId = MSG_MAX_FOLDER_ID; break; } @@ -891,25 +898,25 @@ _MsgUtil::GetMsgFolderId(const SmsMessageBoxType& type) } SmsMessageBoxType -_MsgUtil::GetMsgBoxType(const messages_message_box_e& folderId) +_MsgUtil::GetMsgBoxType(const _MSG_FOLDER_ID_E& folderId) { SmsMessageBoxType type; switch (folderId) { - case MESSAGES_MBOX_INBOX: + case MSG_INBOX_ID: type = SMS_MESSAGE_BOX_TYPE_INBOX; break; - case MESSAGES_MBOX_OUTBOX: + case MSG_OUTBOX_ID: type = SMS_MESSAGE_BOX_TYPE_OUTBOX; break; - case MESSAGES_MBOX_SENTBOX: + case MSG_SENTBOX_ID: type = SMS_MESSAGE_BOX_TYPE_SENTBOX; break; - case MESSAGES_MBOX_ALL: + case MSG_ALLBOX_ID: type = SMS_MESSAGE_BOX_TYPE_ALL; break; @@ -922,16 +929,12 @@ _MsgUtil::GetMsgBoxType(const messages_message_box_e& folderId) } int -_MsgUtil::GetSmsMessage(const SmsMessage& message, const RecipientList& recipientList, messages_message_h& smsMsg) +_MsgUtil::GetSmsMessage(msg_struct_t& msgInfo, const SmsMessage& message, const RecipientList& recipientList) { - int err = MESSAGES_ERROR_NONE; - const char* pMsgBody = null; + int err = MSG_SUCCESS; + char* pMsgBody = null; result r = E_SUCCESS; - //create new message - err = messages_create_message(MESSAGES_TYPE_SMS, &smsMsg); - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "failed to create message object"); - if (message.GetText().GetLength() == 0) { Tizen::Base::String emptyText(L" "); @@ -944,11 +947,14 @@ _MsgUtil::GetSmsMessage(const SmsMessage& message, const RecipientList& recipien SysTryCatch(NID_MSG, pMsgBody != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "memory allocation failed."); - err = messages_set_text(smsMsg, pMsgBody); - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "failed to set message text"); + err = msg_set_int_value(msgInfo, MSG_MESSAGE_TYPE_INT, MSG_TYPE_SMS); + SysTryCatch(NID_MSG, err == MSG_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Set Message Type error"); - err = AddMessageAddress(recipientList, RECIPIENT_TYPE_TO, smsMsg, MESSAGES_RECIPIENT_TO); - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "failed to set message To address"); + err = msg_set_str_value(msgInfo, MSG_MESSAGE_SMS_DATA_STR, pMsgBody, strlen(pMsgBody)); + SysTryCatch(NID_MSG, err == MSG_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Set Message body error"); + + err = AddMessageAddress(recipientList, RECIPIENT_TYPE_TO, msgInfo, MSG_RECIPIENTS_TYPE_TO); + SysTryCatch(NID_MSG, err == MSG_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Message add address error"); if (pMsgBody) { @@ -959,6 +965,7 @@ _MsgUtil::GetSmsMessage(const SmsMessage& message, const RecipientList& recipien return err; CATCH: + SetLastResult(r); if (pMsgBody) { @@ -970,72 +977,33 @@ CATCH: } int -_MsgUtil::GetEmailMessage(const EmailMessage& message, const RecipientList& recipientList, email_h& emailMsg) +_MsgUtil::GetMmsMessage(msg_struct_t& msgInfo, const MmsMessage& message, const RecipientList& recipientList) { - int err = EMAIL_ERROR_NONE; + int err = MSG_SUCCESS; result r = E_SUCCESS; - int attachNum = 0; - const char* pSubject = null; - const char* pMsgBody = null; - Tizen::Base::Collection::IList* pAttachmentList = null; + char* pSubject = null; pSubject = _StringConverter::CopyToCharArrayN(message.GetSubject()); - pMsgBody = _StringConverter::CopyToCharArrayN(message.GetText()); + SysTryCatch(NID_MSG, pSubject != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "memory allocation failed."); - err = email_set_subject(emailMsg, pSubject); - SysTryCatch(NID_MSG, err == EMAIL_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] email add subject failed"); - err = email_set_body(emailMsg, pMsgBody); - SysTryCatch(NID_MSG, err == EMAIL_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] email add body failed"); + //create new message + err = msg_set_int_value(msgInfo, MSG_MESSAGE_TYPE_INT, MSG_TYPE_MMS); + SysTryCatch(NID_MSG, err == MSG_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Set Message Type error"); - err = AddEmailMessageAddress(recipientList, RECIPIENT_TYPE_TO, emailMsg, EMAIL_RECIPIENT_TYPE_TO); - SysTryCatch(NID_MSG, err == EMAIL_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] email add recipient failed"); - err = AddEmailMessageAddress(recipientList, RECIPIENT_TYPE_CC, emailMsg, EMAIL_RECIPIENT_TYPE_CC); - SysTryCatch(NID_MSG, err == EMAIL_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] email add recipient failed"); - err = AddEmailMessageAddress(recipientList, RECIPIENT_TYPE_BCC, emailMsg, EMAIL_RECIPIENT_TYPE_BCC); - SysTryCatch(NID_MSG, err == EMAIL_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] email add recipient failed"); + err = msg_set_str_value(msgInfo, MSG_MESSAGE_SUBJECT_STR, pSubject, strlen(pSubject)); + SysTryCatch(NID_MSG, err == MSG_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Set Message body error"); - pAttachmentList = message.GetAttachmentListN(); + err = AddMessageAddress(recipientList, RECIPIENT_TYPE_TO, msgInfo, MSG_RECIPIENTS_TYPE_TO); + SysTryCatch(NID_MSG, err == MSG_SUCCESS, r = E_SYSTEM, E_SYSTEM, "failed to add To address"); - if (pAttachmentList) - { - attachNum = pAttachmentList->GetCount(); - } + err = AddMessageAddress(recipientList, RECIPIENT_TYPE_CC, msgInfo, MSG_RECIPIENTS_TYPE_CC); + SysTryCatch(NID_MSG, err == MSG_SUCCESS, r = E_SYSTEM, E_SYSTEM, "failed to add Cc address"); - if (attachNum >= 1) - { - String* pAttachPath = null; - char* pTempAttachPath = null; - - for (int index = 0; index < attachNum; index++) - { - pAttachPath = dynamic_cast< String* >(pAttachmentList->GetAt(index)); - SysTryCatch(NID_MSG, pAttachPath != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] email add attachment failed"); - pTempAttachPath = _StringConverter::CopyToCharArrayN(*pAttachPath); - err = email_add_attach(emailMsg, pTempAttachPath); - if (pTempAttachPath) - { - delete[] pTempAttachPath; - pTempAttachPath = null; - } - SysTryCatch(NID_MSG, err == EMAIL_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] email add attachment failed"); - } - } - - if (pAttachmentList) - { - if (pAttachmentList->GetCount() > 0) - { - pAttachmentList->RemoveAll(true); - } - delete pAttachmentList; - pAttachmentList = null; - } + err = AddMessageAddress(recipientList, RECIPIENT_TYPE_BCC, msgInfo, MSG_RECIPIENTS_TYPE_BCC); + SysTryCatch(NID_MSG, err == MSG_SUCCESS, r = E_SYSTEM, E_SYSTEM, "failed to add Bcc address"); - if (pMsgBody) - { - delete[] pMsgBody; - pMsgBody = null; - } + err = PopulateMmsContent(message, msgInfo); + SysTryCatch(NID_MSG, err == MSG_SUCCESS, r = E_SYSTEM, E_SYSTEM, "failed to generate MMS message"); if (pSubject) { @@ -1046,11 +1014,7 @@ _MsgUtil::GetEmailMessage(const EmailMessage& message, const RecipientList& reci return err; CATCH: - if (pMsgBody) - { - delete[] pMsgBody; - pMsgBody = null; - } + SetLastResult(r); if (pSubject) { @@ -1058,94 +1022,302 @@ CATCH: pSubject = null; } - if (pAttachmentList) - { - if (pAttachmentList->GetCount() > 0) - { - pAttachmentList->RemoveAll(true); - } - delete pAttachmentList; - pAttachmentList = null; - } - return err; } int -_MsgUtil::AddEmailMessageAddress(const RecipientList& recipientList, RecipientType type, email_h& emailMsg, email_recipient_type_e recipientType) +_MsgUtil::PopulateMmsContent(const MmsMessage& message, msg_struct_t& msgData) { - String* pTempRecipient = null; - IList* pRecipientList = null; - char* pEmailAddr = null; - int count = 0; - int err = EMAIL_ERROR_NONE; + int err = MSG_SUCCESS; result r = E_SUCCESS; + String filePath; + char* pFilePath = null; + bool isImage = false; + bool isAudio = false; + bool isText = false; - pRecipientList = (const_cast< RecipientList& >(recipientList)).GetListN(type); - if (!pRecipientList) + msg_struct_t mmsData = NULL; + msg_struct_t region = NULL; + msg_struct_t page = NULL; + msg_struct_t media = NULL; + msg_struct_t smilText = NULL; + msg_struct_t mmsAttach = NULL; + + //create a temp file for body text + Tizen::Base::String bodyText = message.GetText(); + Tizen::Base::String bodyTextFilePath(BODY_TEXT_FILE_NAME); + Tizen::Io::File file; + r = file.Construct(bodyTextFilePath, L"w+"); + err = MSG_ERR_MEMORY_ERROR; + SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_OUT_OF_MEMORY, r, "memory allocation failed"); + + mmsData = msg_create_struct(MSG_STRUCT_MMS); + + if (bodyText.GetLength()) { - r = GetLastResult(); - SysLogException(NID_MSG, r, "[%s] Failed to get recipient list", GetErrorMessage(r)); - goto CATCH; + isText = true; + //write text to file + r = file.Write(bodyText); + err = MSG_ERR_MEMORY_ERROR; + SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_OUT_OF_MEMORY, r, "memory allocation failed"); } - count = pRecipientList->GetCount(); - for (int index = 0; index < count; index++) + filePath = message.GetAttachment(MMS_IMAGE); + if (filePath.GetLength()) { - pTempRecipient = dynamic_cast< String* >(pRecipientList->GetAt(index)); - if (!pTempRecipient) + isImage = true; + } + + filePath = message.GetAttachment(MMS_VIDEO); + if (filePath.GetLength()) + { + isImage = true; + } + + filePath = message.GetAttachment(MMS_AUDIO); + if (filePath.GetLength()) + { + isAudio = true; + } + + // Layout Setting + msg_set_int_value(mmsData, MSG_MMS_ROOTLAYOUT_WIDTH_INT, 100); + msg_set_int_value(mmsData, MSG_MMS_ROOTLAYOUT_HEIGHT_INT, 100); + msg_set_int_value(mmsData, MSG_MMS_ROOTLAYOUT_BGCOLOR_INT, 0xffffff); + msg_set_bool_value(mmsData, MSG_MMS_ROOTLAYOUT_WIDTH_PERCENT_BOOL, true); + msg_set_bool_value(mmsData, MSG_MMS_ROOTLAYOUT_HEIGHT_PERCENT_BOOL, true); + + if (!isImage) + { + msg_mms_add_item(mmsData, MSG_STRUCT_MMS_REGION, ®ion); + msg_set_str_value(region, MSG_MMS_REGION_ID_STR, (char *)"Text", 4); + msg_set_int_value(region, MSG_MMS_REGION_LENGTH_LEFT_INT, 0); + msg_set_int_value(region, MSG_MMS_REGION_LENGTH_TOP_INT, 0); + msg_set_int_value(region, MSG_MMS_REGION_LENGTH_WIDTH_INT, 100); + msg_set_int_value(region, MSG_MMS_REGION_LENGTH_HEIGHT_INT, 100); + msg_set_int_value(region, MSG_MMS_REGION_BGCOLOR_INT, 0xffffff); + } + else if (!isText) + { + msg_mms_add_item(mmsData, MSG_STRUCT_MMS_REGION, ®ion); + msg_set_str_value(region, MSG_MMS_REGION_ID_STR, (char *)"Image", 5); + msg_set_int_value(region, MSG_MMS_REGION_LENGTH_LEFT_INT, 0); + msg_set_int_value(region, MSG_MMS_REGION_LENGTH_TOP_INT, 0); + msg_set_int_value(region, MSG_MMS_REGION_LENGTH_WIDTH_INT, 100); + msg_set_int_value(region, MSG_MMS_REGION_LENGTH_HEIGHT_INT, 100); + msg_set_int_value(region, MSG_MMS_REGION_BGCOLOR_INT, 0xffffff); + } + else + { + msg_mms_add_item(mmsData, MSG_STRUCT_MMS_REGION, ®ion); + msg_set_str_value(region, MSG_MMS_REGION_ID_STR, (char *)"Image", 5); + msg_set_int_value(region, MSG_MMS_REGION_LENGTH_LEFT_INT, 0); + msg_set_int_value(region, MSG_MMS_REGION_LENGTH_TOP_INT, 0); + msg_set_int_value(region, MSG_MMS_REGION_LENGTH_WIDTH_INT, 100); + msg_set_int_value(region, MSG_MMS_REGION_LENGTH_HEIGHT_INT, 50); + msg_set_int_value(region, MSG_MMS_REGION_BGCOLOR_INT, 0xffffff); + + msg_mms_add_item(mmsData, MSG_STRUCT_MMS_REGION, ®ion); + msg_set_str_value(region, MSG_MMS_REGION_ID_STR, (char *)"Text", 4); + msg_set_int_value(region, MSG_MMS_REGION_LENGTH_LEFT_INT, 0); + msg_set_int_value(region, MSG_MMS_REGION_LENGTH_TOP_INT, 50); + msg_set_int_value(region, MSG_MMS_REGION_LENGTH_WIDTH_INT, 100); + msg_set_int_value(region, MSG_MMS_REGION_LENGTH_HEIGHT_INT, 50); + msg_set_int_value(region, MSG_MMS_REGION_BGCOLOR_INT, 0xffffff); + } + + // Add Media + msg_mms_add_item(mmsData, MSG_STRUCT_MMS_PAGE, &page); + msg_set_int_value(page, MSG_MMS_PAGE_PAGE_DURATION_INT, 5440); + + if (isImage) + { + filePath = message.GetAttachment(MMS_IMAGE); + if (filePath.GetLength()) { - r = GetLastResult(); - err = EMAIL_ERROR_OPERATION_FAILED; - SysLogException(NID_MSG, r, "[%s] Failed to get a recipient", GetErrorMessage(r)); - goto CATCH; + pFilePath = _StringConverter::CopyToCharArrayN(filePath); + err = MSG_ERR_MEMORY_ERROR; + SysTryCatch(NID_MSG, pFilePath != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed"); + + msg_mms_add_item(page, MSG_STRUCT_MMS_MEDIA, &media); + msg_set_int_value(media, MSG_MMS_MEDIA_TYPE_INT, MMS_SMIL_MEDIA_IMG); + msg_set_str_value(media, MSG_MMS_MEDIA_REGION_ID_STR, (char *)"Image", 5); + msg_set_str_value(media, MSG_MMS_MEDIA_FILEPATH_STR, pFilePath, MSG_FILEPATH_LEN_MAX); + + delete[] pFilePath; + pFilePath = null; } - pEmailAddr = _StringConverter::CopyToCharArrayN(*pTempRecipient); - err = email_add_recipient(emailMsg, recipientType, pEmailAddr); + filePath = message.GetAttachment(MMS_VIDEO); + if (filePath.GetLength()) + { + pFilePath = _StringConverter::CopyToCharArrayN(filePath); + err = MSG_ERR_MEMORY_ERROR; + SysTryCatch(NID_MSG, pFilePath != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed"); + + msg_mms_add_item(page, MSG_STRUCT_MMS_MEDIA, &media); + msg_set_int_value(media, MSG_MMS_MEDIA_TYPE_INT, MMS_SMIL_MEDIA_VIDEO); + msg_set_str_value(media, MSG_MMS_MEDIA_REGION_ID_STR, (char *)"Image", 5); + msg_set_str_value(media, MSG_MMS_MEDIA_FILEPATH_STR, pFilePath, MSG_FILEPATH_LEN_MAX); - if (pEmailAddr) + delete[] pFilePath; + pFilePath = null; + } + } + + if (isAudio) + { + filePath = message.GetAttachment(MMS_AUDIO); + if (filePath.GetLength()) { - delete[] pEmailAddr; - pEmailAddr = null; + pFilePath = _StringConverter::CopyToCharArrayN(filePath); + err = MSG_ERR_MEMORY_ERROR; + SysTryCatch(NID_MSG, pFilePath != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed"); + + msg_mms_add_item(page, MSG_STRUCT_MMS_MEDIA, &media); + msg_set_int_value(media, MSG_MMS_MEDIA_TYPE_INT, MMS_SMIL_MEDIA_AUDIO); + msg_set_str_value(media, MSG_MMS_MEDIA_REGION_ID_STR, (char *)"Audio", 5); + msg_set_str_value(media, MSG_MMS_MEDIA_FILEPATH_STR, pFilePath, MSG_FILEPATH_LEN_MAX); + + delete[] pFilePath; + pFilePath = null; } - SysTryCatch(NID_MSG, err == EMAIL_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "failed to set message address"); + } + if (isText) + { + pFilePath = _StringConverter::CopyToCharArrayN(bodyTextFilePath); + err = MSG_ERR_MEMORY_ERROR; + SysTryCatch(NID_MSG, pFilePath != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "memory allocation failed."); + + msg_mms_add_item(page, MSG_STRUCT_MMS_MEDIA, &media); + msg_set_int_value(media, MSG_MMS_MEDIA_TYPE_INT, MMS_SMIL_MEDIA_TEXT); + msg_set_str_value(media, MSG_MMS_MEDIA_REGION_ID_STR, (char *)"Text", 4); + msg_set_str_value(media, MSG_MMS_MEDIA_FILEPATH_STR, pFilePath, MSG_FILEPATH_LEN_MAX); + + msg_get_struct_handle(media, MSG_MMS_MEDIA_SMIL_TEXT_HND, &smilText); + msg_set_int_value(smilText, MSG_MMS_SMIL_TEXT_COLOR_INT, 0x000000); + msg_set_int_value(smilText, MSG_MMS_SMIL_TEXT_SIZE_INT, MMS_SMIL_FONT_SIZE_NORMAL); + msg_set_bool_value(smilText, MSG_MMS_SMIL_TEXT_BOLD_BOOL, false); + + delete[] pFilePath; + pFilePath = null; } - // deallocate - if (pRecipientList->GetCount() > 0) + //vcard attachment + filePath = message.GetAttachment(MMS_VCARD); + if (filePath.GetLength()) { - pRecipientList->RemoveAll(true); + pFilePath = _StringConverter::CopyToCharArrayN(filePath); + err = MSG_ERR_MEMORY_ERROR; + SysTryCatch(NID_MSG, pFilePath != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "memory allocation failed."); + msg_mms_add_item(mmsData, MSG_STRUCT_MMS_ATTACH, &mmsAttach); + msg_set_str_value(mmsAttach, MSG_MMS_ATTACH_FILEPATH_STR, pFilePath, MSG_FILEPATH_LEN_MAX); + delete[] pFilePath; + pFilePath = null; } - delete pRecipientList; - pRecipientList = null; + //calander attachment + filePath = message.GetAttachment(MMS_VCALENDAR); + if (filePath.GetLength()) + { + pFilePath = _StringConverter::CopyToCharArrayN(filePath); + err = MSG_ERR_MEMORY_ERROR; + SysTryCatch(NID_MSG, pFilePath != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "memory allocation failed."); + msg_mms_add_item(mmsData, MSG_STRUCT_MMS_ATTACH, &mmsAttach); + msg_set_str_value(mmsAttach, MSG_MMS_ATTACH_FILEPATH_STR, pFilePath, MSG_FILEPATH_LEN_MAX); + delete[] pFilePath; + pFilePath = null; + } + + err = msg_set_mms_struct(msgData, mmsData); + SysTryCatch(NID_MSG, err == MSG_SUCCESS, r = E_SYSTEM, E_SYSTEM, "failed to set message contents"); + + msg_release_struct(&mmsData); return err; CATCH: - SetLastResult(r); - if (pRecipientList) + if (mmsData) + { + msg_release_struct(&mmsData); + } + return err; +} + +result +_MsgUtil::AddEmailMessageAddress(const RecipientList& recipientList, RecipientType type, email_mail_data_t *pMail) +{ + String tempRecipient = null; + IList* pRecipientList = null; + int count = 0; + int index = 0; + const int zero = 0; + result r = E_SUCCESS; + + pRecipientList = (const_cast< RecipientList& >(recipientList)).GetListN(type); + SysTryCatch(NID_MSG, pRecipientList != null, r = GetLastResult(), r, "[%s] Failed to get recipient list", GetErrorMessage(r)); + + count = pRecipientList->GetCount(); + SysTryCatch(NID_MSG, count != zero, r = E_SUCCESS , r, "Type[%d] Recipient is empty",type); + + tempRecipient.Append(L"<" + *(dynamic_cast< String* >(pRecipientList->GetAt(index))) + L">"); + index++; + + for (; index < count; index++) { + tempRecipient.Append(L",<" + *(dynamic_cast< String* >(pRecipientList->GetAt(index))) + L">"); + + } + if(RECIPIENT_TYPE_TO == type) + { + pMail->full_address_to = _StringConverter::CopyToCharArrayN(tempRecipient); + } + else if(RECIPIENT_TYPE_CC == type) + { + pMail->full_address_cc = _StringConverter::CopyToCharArrayN(tempRecipient); + + } + else if( RECIPIENT_TYPE_BCC == type) + { + pMail->full_address_bcc = _StringConverter::CopyToCharArrayN(tempRecipient); + } + else + { + SysLog(NID_MSG, "[%d] Wrong recipeint type", type); + r = E_INVALID_ARG; + goto CATCH; + } + if (pRecipientList->GetCount() > 0) { pRecipientList->RemoveAll(true); } delete pRecipientList; pRecipientList = null; + + return r; + +CATCH: + if (pRecipientList->GetCount() > 0) + { + pRecipientList->RemoveAll(true); } + delete pRecipientList; + pRecipientList = null; + + return r; - return err; } int -_MsgUtil::AddMessageAddress(const RecipientList& recipientList, RecipientType type, messages_message_h& messageMsg, messages_recipient_type_e recipientType) +_MsgUtil::AddMessageAddress(const RecipientList& recipientList, RecipientType type, msg_struct_t& messageMsg, _MSG_RECIPIENT_TYPE_E recipientType) { String* pTempRecipient = null; IList* pRecipientList = null; char* pPhoneNum = null; int count = 0; - int err = MESSAGES_ERROR_NONE; + int msgType = -1; + int err = MSG_SUCCESS; result r = E_SUCCESS; pRecipientList = (const_cast< RecipientList& >(recipientList)).GetListN(type); @@ -1156,6 +1328,9 @@ _MsgUtil::AddMessageAddress(const RecipientList& recipientList, RecipientType ty goto CATCH; } + err = msg_get_int_value(messageMsg, MSG_MESSAGE_TYPE_INT, &msgType); + SysTryCatch(NID_MSG, err == MSG_SUCCESS, r = E_SYSTEM, E_SYSTEM, "failed to get message type"); + count = pRecipientList->GetCount(); for (int index = 0; index < count; index++) { @@ -1163,21 +1338,48 @@ _MsgUtil::AddMessageAddress(const RecipientList& recipientList, RecipientType ty if (!pTempRecipient) { r = GetLastResult(); - err = MESSAGES_ERROR_OPERATION_FAILED; + err = MSG_ERR_NULL_POINTER; SysLogException(NID_MSG, r, "[%s] Failed to get a recipient", GetErrorMessage(r)); goto CATCH; } pPhoneNum = _StringConverter::CopyToCharArrayN(*pTempRecipient); - err = messages_add_address(messageMsg, pPhoneNum, recipientType); + + msg_struct_list_s *pAddrList = NULL; + msg_struct_t addrInfo = NULL; + + err = msg_get_list_handle(messageMsg, MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&pAddrList); + SysTryCatch(NID_MSG, err == MSG_SUCCESS, r = E_SYSTEM, E_SYSTEM, "failed to get message address handle"); + + addrInfo = pAddrList->msg_struct_info[pAddrList->nCount]; + + if (msgType == MSG_TYPE_SMS) + { + msg_set_int_value(addrInfo, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, recipientType); + } + else if (msgType == MSG_TYPE_MMS) + { + if (strchr(pPhoneNum, '@') == NULL) + { + msg_set_int_value(addrInfo, MSG_ADDRESS_INFO_ADDRESS_TYPE_INT, MSG_ADDRESS_TYPE_PLMN); + } + else + { + msg_set_int_value(addrInfo, MSG_ADDRESS_INFO_ADDRESS_TYPE_INT, MSG_ADDRESS_TYPE_EMAIL); + } + msg_set_int_value(addrInfo, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, recipientType); + } + + err = msg_set_str_value(addrInfo, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, pPhoneNum, strlen(pPhoneNum)); + SysTryCatch(NID_MSG, err == MSG_SUCCESS, r = E_SYSTEM, E_SYSTEM, "failed to set message address"); + + pAddrList->nCount++; if (pPhoneNum) { delete[] pPhoneNum; pPhoneNum = null; } - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "failed to set message address"); - } // deallocate @@ -1202,6 +1404,11 @@ CATCH: pRecipientList = null; } + if (pPhoneNum) + { + delete[] pPhoneNum; + pPhoneNum = null; + } return err; } @@ -1271,124 +1478,6 @@ CATCH: return concatenatedString; } -int -_MsgUtil::GetMmsMessage(const MmsMessage& message, const RecipientList& recipientList, messages_message_h& mmsMsg) -{ - int err = MESSAGES_ERROR_NONE; - result r = E_SUCCESS; - const char* pSubject = null; - const char* pMsgBody = null; - const char* pFilePath = null; - String filePath; - - pSubject = _StringConverter::CopyToCharArrayN(message.GetSubject()); - pMsgBody = _StringConverter::CopyToCharArrayN(message.GetText()); - - //create new message - err = messages_create_message(MESSAGES_TYPE_MMS, &mmsMsg); - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "Insufficient memory"); - - err = messages_set_text(mmsMsg, pMsgBody); - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "failed to set mms text"); - - err = messages_mms_set_subject(mmsMsg, pSubject); - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "failed to set mms body"); - - err = AddMessageAddress(recipientList, RECIPIENT_TYPE_TO, mmsMsg, MESSAGES_RECIPIENT_TO); - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "failed to add To address"); - - err = AddMessageAddress(recipientList, RECIPIENT_TYPE_CC, mmsMsg, MESSAGES_RECIPIENT_CC); - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "failed to add Cc address"); - - err = AddMessageAddress(recipientList, RECIPIENT_TYPE_BCC, mmsMsg, MESSAGES_RECIPIENT_BCC); - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "failed to add Bcc address"); - - // populate attachments - filePath = message.GetAttachment(MMS_IMAGE); - if (filePath.GetLength()) - { - pFilePath = _StringConverter::CopyToCharArrayN(filePath); - err = messages_mms_add_attachment(mmsMsg, MESSAGES_MEDIA_IMAGE, pFilePath); - delete[] pFilePath; - pFilePath = null; - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "mms add attachment failed"); - } - - //video attachment - filePath = message.GetAttachment(MMS_VIDEO); - if (filePath.GetLength()) - { - pFilePath = _StringConverter::CopyToCharArrayN(filePath); - err = messages_mms_add_attachment(mmsMsg, MESSAGES_MEDIA_VIDEO, pFilePath); - delete[] pFilePath; - pFilePath = null; - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "mms add attachment failed"); - } - - //audio attachment - filePath = message.GetAttachment(MMS_AUDIO); - if (filePath.GetLength()) - { - pFilePath = _StringConverter::CopyToCharArrayN(filePath); - err = messages_mms_add_attachment(mmsMsg, MESSAGES_MEDIA_AUDIO, pFilePath); - delete[] pFilePath; - pFilePath = null; - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "mms add attachment failed"); - } - - //vcard attachment - filePath = message.GetAttachment(MMS_VCARD); - if (filePath.GetLength()) - { - pFilePath = _StringConverter::CopyToCharArrayN(filePath); - err = messages_mms_add_attachment(mmsMsg, MESSAGES_MEDIA_UNKNOWN, pFilePath); // Not Suppourted Yet - delete[] pFilePath; - pFilePath = null; - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "mms add attachment failed"); - } - - //calander attachment - filePath = message.GetAttachment(MMS_VCALENDAR); - if (filePath.GetLength()) - { - pFilePath = _StringConverter::CopyToCharArrayN(filePath); - err = messages_mms_add_attachment(mmsMsg, MESSAGES_MEDIA_UNKNOWN, pFilePath); // Not Suppourted Yet - delete[] pFilePath; - pFilePath = null; - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "mms add attachment failed"); - } - - if (pMsgBody) - { - delete[] pMsgBody; - pMsgBody = null; - } - - if (pSubject) - { - delete[] pSubject; - pSubject = null; - } - - return err; - -CATCH: - - if (pMsgBody) - { - delete[] pMsgBody; - pMsgBody = null; - } - - if (pSubject) - { - delete[] pSubject; - pSubject = null; - } - - return err; -} - Tizen::Base::DateTime _MsgUtil::ConvertTime(time_t* pTime) { @@ -1404,19 +1493,16 @@ _MsgUtil::ConvertTime(time_t* pTime) } SmsMessage* -_MsgUtil::ConvertSmsMessageN(const SmsMessageBoxType& type, messages_message_h msg) +_MsgUtil::ConvertSmsMessageN(const SmsMessageBoxType& type, msg_struct_t& msg) { result r = E_SUCCESS; + int err = MSG_SUCCESS; SmsMessage* pSmsMessage = null; - char* pOriginalText = null; - char* pBodyText = null; - char* pMsgAddress = null; DateTime time; - time_t tempTime = 0; + int msgTime = -1; bool hasMoreText = false; - int messageId = 0; + int messageId; String body; - messages_recipient_type_e recipientType = MESSAGES_RECIPIENT_TO; const int msgBodyLength = 160; int originalTextLength = 0; @@ -1424,45 +1510,44 @@ _MsgUtil::ConvertSmsMessageN(const SmsMessageBoxType& type, messages_message_h m SysTryCatch(NID_MSG, pSmsMessage != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed"); // message ID - messages_get_message_id(msg, &messageId); + err = msg_get_int_value(msg, MSG_MESSAGE_ID_INT, &messageId); + // body text - messages_get_text(msg, &pOriginalText); - SysTryCatch(NID_MSG, pOriginalText != null, r = E_SYSTEM, r, "sms get message body failed"); + char msgText[MAX_MSG_TEXT_LEN]; + err = msg_get_str_value(msg, MSG_MESSAGE_SMS_DATA_STR, msgText, MAX_MSG_TEXT_LEN); + SysTryCatch(NID_MSG, err == MSG_SUCCESS, r = E_SYSTEM, r, "sms get message body failed"); - originalTextLength = strlen(pOriginalText); + originalTextLength = strlen(msgText); if (originalTextLength > msgBodyLength) { - pBodyText = (char*) calloc(msgBodyLength + 1, sizeof(char)); // include NULL character - SysTryCatch(NID_MSG, pBodyText != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed"); - strncpy(pBodyText, pOriginalText, msgBodyLength); - pBodyText[msgBodyLength] = '\0'; // add NULL character - free(const_cast< char* >(pOriginalText)); - pOriginalText = null; + char msgBodyText[msgBodyLength + 1]; + memset(msgText, 0, msgBodyLength + 1); + strncpy(msgBodyText, msgText, msgBodyLength); + body = msgBodyText; hasMoreText = true; - } else { - pBodyText = const_cast< char* >(pOriginalText); - pOriginalText = null; + body = msgText; } - body = pBodyText; - // received/sent time - messages_get_time(msg, &tempTime); - time = _MsgUtil::ConvertTime(&tempTime); + err = msg_get_int_value(msg, MSG_MESSAGE_DISPLAY_TIME_INT, &msgTime); + time = _MsgUtil::ConvertTime((time_t*) &msgTime); switch (type) { case SMS_MESSAGE_BOX_TYPE_INBOX: { // sender address - messages_get_address(msg, 0, &pMsgAddress, &recipientType); - SysTryCatch(NID_MSG, pMsgAddress != null, r = E_SYSTEM, r, "sms get message address failed"); - String senderAddress(pMsgAddress); - free(pMsgAddress); - pMsgAddress = null; + char address[MAX_ADDRESS_VAL_LEN] = {0, }; + msg_struct_list_s* pAddrList = NULL; + msg_struct_t addrInfo = NULL; + err = msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&pAddrList); + addrInfo = pAddrList->msg_struct_info[0]; + err = msg_get_str_value(addrInfo, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, address, MAX_ADDRESS_VAL_LEN); + String senderAddress(address); + _SmsMessageImpl::GetInstance(*pSmsMessage)->SetInboxMessage(messageId, body, hasMoreText, senderAddress, time); break; } @@ -1470,19 +1555,22 @@ _MsgUtil::ConvertSmsMessageN(const SmsMessageBoxType& type, messages_message_h m case SMS_MESSAGE_BOX_TYPE_SENTBOX: { // recipient list - int recipient_count = 0; - messages_get_address_count(msg, &recipient_count); + char address[MAX_ADDRESS_VAL_LEN] = {0, }; + msg_struct_list_s* pAddrList = NULL; + msg_struct_t addrInfo = NULL; + err = msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&pAddrList); + addrInfo = pAddrList->msg_struct_info[0]; + int recipient_count = pAddrList->nCount; RecipientList recipients; for (int index = 0; index < recipient_count; index++) { - messages_get_address(msg, index, &pMsgAddress, &recipientType); - SysTryCatch(NID_MSG, pMsgAddress != null, r = E_SYSTEM, r, "sms get message address failed"); - String senderAddress(pMsgAddress); - free(pMsgAddress); - pMsgAddress = null; + addrInfo = pAddrList->msg_struct_info[index]; + err = msg_get_str_value(addrInfo, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, address, MAX_ADDRESS_VAL_LEN); + String senderAddress(address); r = recipients.Add(RECIPIENT_TYPE_TO, senderAddress); } + _SmsMessageImpl::GetInstance(*pSmsMessage)->SetSentboxMessage(messageId, body, hasMoreText, recipients, time); break; } @@ -1490,19 +1578,21 @@ _MsgUtil::ConvertSmsMessageN(const SmsMessageBoxType& type, messages_message_h m case SMS_MESSAGE_BOX_TYPE_OUTBOX: { // recipient list - int recipient_count = 0; - messages_get_address_count(msg, &recipient_count); + char address[MAX_ADDRESS_VAL_LEN] = {0, }; + msg_struct_list_s* pAddrList = NULL; + msg_struct_t addrInfo = NULL; + err = msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&pAddrList); + addrInfo = pAddrList->msg_struct_info[0]; + int recipient_count = pAddrList->nCount; RecipientList recipients; for (int index = 0; index < recipient_count; index++) { - messages_get_address(msg, index, &pMsgAddress, &recipientType); - SysTryCatch(NID_MSG, pMsgAddress != null, r = E_SYSTEM, r, "sms get message address failed"); - String senderAddress(pMsgAddress); - free(pMsgAddress); - pMsgAddress = null; - r = recipients.Add(RECIPIENT_TYPE_TO, senderAddress); + addrInfo = pAddrList->msg_struct_info[index]; + err = msg_get_str_value(addrInfo, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, address, MAX_ADDRESS_VAL_LEN); + String senderAddress(address); } + _SmsMessageImpl::GetInstance(*pSmsMessage)->SetOutboxMessage(messageId, body, hasMoreText, recipients, time); break; } @@ -1511,28 +1601,430 @@ _MsgUtil::ConvertSmsMessageN(const SmsMessageBoxType& type, messages_message_h m break; } - if (pBodyText) + return pSmsMessage; + +CATCH: + if (pSmsMessage) { - free(pBodyText); - pBodyText = null; + delete pSmsMessage; } - return pSmsMessage; + return NULL; +} +result +_MsgUtil::SendEmail(const EmailMessage& message, const RecipientList& recipientList, int &mailId, int &requestId) +{ + +////////////////// + email_account_t* pAccount = NULL; + email_mail_data_t *pMail = null; + email_mailbox_t *pMailbox = null; + email_attachment_data_t **pAttach=null; + int accountId = 0; + int err = EMAIL_ERROR_NONE; + result r = E_SUCCESS; + String fromAddr; + + + email_service_begin(); + + pMail = (email_mail_data_t *)calloc(1,sizeof(email_mail_data_t)); + SysTryCatch(NID_MSG, pMail != null, r = E_OUT_OF_MEMORY, r, "Insufficient memory"); + + pMailbox = (email_mailbox_t *)calloc(1,sizeof(email_mailbox_t)); + SysTryCatch(NID_MSG, pMailbox != null, r = E_OUT_OF_MEMORY, r, "Insufficient memory"); + + + err = email_load_default_account_id(&accountId); + SysTryCatch(NID_MSG, err == EMAIL_ERROR_NONE, r = E_INVALID_ACCOUNT, r, "Account Load is Failed."); + + err = email_get_account(accountId, GET_FULL_DATA, &pAccount); + SysTryCatch(NID_MSG, err == EMAIL_ERROR_NONE, r = E_INVALID_ACCOUNT, r, "Account is Failed."); + + fromAddr.Append(L'\"'); + fromAddr.Append(pAccount->incoming_server_user_name); + fromAddr.Append(L"\"<"); + fromAddr.Append(pAccount->user_email_address); + fromAddr.Append(L'>'); + pMail->full_address_from = _StringConverter::CopyToCharArrayN(fromAddr); + + err = email_get_mailbox_by_mailbox_type(accountId, EMAIL_MAILBOX_TYPE_OUTBOX, &pMailbox); + SysTryCatch(NID_MSG, err == EMAIL_ERROR_NONE, r = E_STORAGE_FULL, r, "Account is Failed."); + + //info + pMail->account_id = pAccount->account_id; + pMail->flags_draft_field = 1; + pMail->flags_seen_field = 1; + pMail->priority = EMAIL_MAIL_PRIORITY_NORMAL; + pMail->mailbox_id = pMailbox->mailbox_id; + pMail->mailbox_type = pMailbox->mailbox_type; + pMail->attachment_count = 0; + pMail->subject = _StringConverter::CopyToCharArrayN(message.GetSubject()); + + r = AddEmailMessageBody(pMail,_StringConverter::CopyToCharArrayN(message.GetText())); + SysTryReturnResult(NID_MSG, r == E_SUCCESS, r, "[%s] email add body failed", GetErrorMessage(r)); + r = AddEmailMessageAddress(recipientList, RECIPIENT_TYPE_TO, pMail); + SysTryReturnResult(NID_MSG, r == E_SUCCESS, r, "[%s] email add recipient failed", GetErrorMessage(r)); + r = AddEmailMessageAddress(recipientList, RECIPIENT_TYPE_CC, pMail); + SysTryReturnResult(NID_MSG, r == E_SUCCESS, r, "[%s] email add recipient failed", GetErrorMessage(r)); + r = AddEmailMessageAddress(recipientList, RECIPIENT_TYPE_BCC, pMail); + SysTryReturnResult(NID_MSG, r == E_SUCCESS, r, "[%s] email add recipient failed", GetErrorMessage(r)); + + + r = AddEmailMessageAttachment(message, &pAttach, pMail); + SysTryReturnResult(NID_MSG, r == E_SUCCESS, r, "[%s] email add recipient failed", GetErrorMessage(r)); + + + if( null != pAttach) + { + err=email_add_mail(pMail,*pAttach, pMail->attachment_count, NULL, 0); + } + else + { + err=email_add_mail(pMail,null, pMail->attachment_count, NULL, 0); + } + + r = _MsgUtil::EmailConvertException(err); + SysTryReturnResult(NID_MSG, r == E_SUCCESS, r, "To make email body is failed."); + + err = email_send_mail(pMail->mail_id, &requestId); + r = _MsgUtil::EmailConvertException(err); + SysTryReturnResult(NID_MSG, r == E_SUCCESS, r, "The sent mail is failed."); + + mailId = pMail->mail_id; + + r = AddEmailCallBackToDbus(); + + if (pAttach) + { + if (*pAttach) + { + for(int i=0 ; i < pMail->attachment_count ; i++) + { + if(pAttach[i]) + { + if(pAttach[i]->attachment_name) + { + free(pAttach[i]->attachment_name); + } + if(pAttach[i]->attachment_path) + { + free(pAttach[i]->attachment_path); + } + } + + } + free(*pAttach); + } + free( pAttach); + + } + email_free_mail_data(&pMail, 1); + email_free_mailbox(&pMailbox, 1); + email_service_end(); + + return r; CATCH: + if (pAttach) + { + if (*pAttach) + { + for(int i=0 ; i < pMail->attachment_count ; i++) + { + if(pAttach[i]) + { + if(pAttach[i]->attachment_name) + { + free(pAttach[i]->attachment_name); + } + if(pAttach[i]->attachment_path) + { + free(pAttach[i]->attachment_path); + } + } - if (pBodyText) + } + free(*pAttach); + } + free( pAttach); + + } + email_free_mail_data(&pMail, 1); + email_free_mailbox(&pMailbox, 1); + email_service_end(); + + return r; + +///////////// + +} + +result +_MsgUtil::AddEmailMessageBody(email_mail_data_t *pMail, char * pBody) +{ + + String fileName(L"/tmp/mail.txt"); + File file; + result r = E_SUCCESS; + int bodyLen = 0; + r = file.Construct(fileName, L"w"); + if(IsFailed(r)) { - free(pBodyText); - pBodyText = null; + return E_STORAGE_FULL; + + } + if (pBody) + { + bodyLen = strlen(pBody); + if (bodyLen) + { + r = file.Write(pBody, bodyLen); + if(IsFailed(r)) + { + return E_STORAGE_FULL; + } + } } - if (pSmsMessage) + pMail->file_path_plain = _StringConverter::CopyToCharArrayN(fileName); + + return E_SUCCESS; + +} + +result +_MsgUtil::AddEmailMessageAttachment(const EmailMessage& message, email_attachment_data_t ***pAttach, email_mail_data_t *pMail) +{ + Tizen::Base::Collection::IList* pAttachmentList = null; + result r = E_SUCCESS; + int attachNum = 0 ; + email_attachment_data_t *getMemory=null; + + SysTryCatch(NID_MSG, pAttach != null, r = E_OUT_OF_MEMORY, r, "Insufficient memory"); + + pAttachmentList = message.GetAttachmentListN(); + SysTryCatch(NID_MSG, null != pAttachmentList, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] email add attachment failed"); + + attachNum = pAttachmentList->GetCount(); + SysTryCatch(NID_MSG, attachNum > 0, r = E_SUCCESS, E_SUCCESS, "email attachment file does not exist."); + + + (*pAttach) = (email_attachment_data_t **)calloc( attachNum,sizeof(email_attachment_data_t*)); + SysTryCatch(NID_MSG, *pAttach != null, r = E_OUT_OF_MEMORY, r, "Insufficient memory"); + + getMemory = (email_attachment_data_t *)calloc(attachNum,sizeof(email_attachment_data_t)); + SysTryCatch(NID_MSG, getMemory != null, r = E_OUT_OF_MEMORY, r, "Insufficient memory"); + + for( int index = 0; index < attachNum ; index ++) { - delete pSmsMessage; + int startIndex = 0; + int findIndex = 0; + String* pAttachPath = null; + String tempString = null; + File file; + FileAttributes attr; + + pAttachPath = dynamic_cast< String* >(pAttachmentList->GetAt(index)); + SysTryCatch(NID_MSG, pAttachPath != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] email add attachment failed"); + + startIndex = pAttachPath->GetLength()-1; + if( E_SUCCESS == pAttachPath->LastIndexOf( L"/", startIndex, findIndex)) + { + pAttachPath->SubString(findIndex+1, tempString); + } + else + { + tempString = *pAttachPath; + } + + (*pAttach)[index] = getMemory + index; + memset((*pAttach)[index], 0 , sizeof(email_attachment_data_t)); + + r = File::GetAttributes(*pAttachPath, attr); + SysTryCatch(NID_MSG, r == E_SUCCESS , r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] email add attachment failed"); + + (*pAttach)[index]->attachment_name = _StringConverter::CopyToCharArrayN(tempString); + (*pAttach)[index]->attachment_path = _StringConverter::CopyToCharArrayN(*pAttachPath); + (*pAttach)[index]->attachment_size = attr.GetFileSize(); + (*pAttach)[index]->save_status = 1; + pMail->attachment_count = index+1; + } + + if (pAttachmentList) + { + if (pAttachmentList->GetCount() > 0) + { + pAttachmentList->RemoveAll(true); + } + delete pAttachmentList; + pAttachmentList = null; } + return r; - return NULL; +CATCH: + + if (pAttachmentList) + { + if (pAttachmentList->GetCount() > 0) + { + pAttachmentList->RemoveAll(true); + } + delete pAttachmentList; + pAttachmentList = null; + } + + return r; + +} + + +result +_MsgUtil::AddEmailCallBackToDbus(void) +{ + + DBusConnection* pConnection=NULL; + DBusError error = {0}; + result r = E_SUCCESS; + static bool registerDbus = false; + + SysTryCatch(NID_MSG, false == registerDbus ,, E_SUCCESS, "Dbus was already registered"); + + dbus_error_init(&error); + + pConnection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error); + SysTryCatch(NID_MSG, pConnection != null, r = E_STORAGE_FULL, r, "dbus handler is null"); + + dbus_connection_setup_with_g_main(pConnection, null); + dbus_bus_add_match(pConnection, "path='/User/Email/NetworkStatus',type='signal',interface='User.Email.NetworkStatus'", &error); + SysTryCatch(NID_MSG, !dbus_error_is_set(&error) ,dbus_error_free(&error);r = E_STORAGE_FULL, E_STORAGE_FULL, "[E_STORAGE_FULL] Fail to add match : %s",error.message); + SysTryCatch(NID_MSG, FALSE != dbus_connection_add_filter(pConnection, EmailNetworkCallBack, NULL, NULL) ,dbus_error_free(&error);r = E_STORAGE_FULL, E_STORAGE_FULL, "[E_STORAGE_FULL] Fail to add match : %s",error.message); + + if (false == registerDbus) + { + registerDbus = true; + SysLog(NID_MSG, "Now. Dbus was registered"); + + } + + + return r; + +CATCH: + + return r; + +} + +DBusHandlerResult +_MsgUtil::EmailNetworkCallBack(DBusConnection* pConnection, DBusMessage* pMessage, void* pUserData) +{ + DBusError error ={0}; + + if(dbus_message_is_signal(pMessage, "User.Email.NetworkStatus", "email")) + { + dbus_error_init(&error); + int status=0; + int accountId=0; + char* fileId=NULL; + int mailId=0; + int errorCode=0; + unsigned int checkDbus; + checkDbus = dbus_message_get_args(pMessage, &error, + DBUS_TYPE_INT32, &status, + DBUS_TYPE_INT32, &accountId, + DBUS_TYPE_STRING, &fileId, + DBUS_TYPE_INT32, &mailId, + DBUS_TYPE_INT32, &errorCode, + DBUS_TYPE_INVALID); + SysLog(NID_MSG, "Dbus status [%d], msg [%d], err [%d]",status, mailId, errorCode); + + if(checkDbus) + { + switch (status) { + case NOTI_SEND_START: + break; + + case NOTI_SEND_FAIL: + + switch(errorCode) + { + case EMAIL_ERROR_NO_SIM_INSERTED: + case EMAIL_ERROR_FLIGHT_MODE: + case EMAIL_ERROR_SMTP_SEND_FAILURE: + case EMAIL_ERROR_NO_SUCH_HOST: + case EMAIL_ERROR_CONNECTION_FAILURE: + case EMAIL_ERROR_CONNECTION_BROKEN: + case EMAIL_ERROR_INVALID_SERVER: + case EMAIL_ERROR_NO_RESPONSE: + + break; + + default: + break; + } + _EmailManagerImpl::SentEmailStatusCallback(mailId, (email_noti_on_network_event)status, errorCode); + return DBUS_HANDLER_RESULT_HANDLED; + break; + + case NOTI_SEND_FINISH: + _EmailManagerImpl::SentEmailStatusCallback(mailId, (email_noti_on_network_event)status, errorCode); + return DBUS_HANDLER_RESULT_HANDLED; + break; + + default: + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + } + } + else + { + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + + } + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + +} + +result +_MsgUtil::EmailConvertException(int err) +{ + result r = E_SUCCESS; + SysLog(NID_MSG,"Core Error [%d]", err); + + switch (err) + { + case EMAIL_ERROR_NONE: + r = E_SUCCESS; + break; + + case EMAIL_ERROR_INVALID_PARAM: + r = E_INVALID_ARG; + break; + + + case EMAIL_ERROR_INVALID_ACCOUNT: + case EMAIL_ERROR_ACCOUNT_NOT_FOUND: + r = E_INVALID_ACCOUNT; + break; + + case EMAIL_ERROR_NULL_VALUE: + case EMAIL_ERROR_IPC_SOCKET_FAILURE: + r = E_ON_INITIALIZING; + break; + + case EMAIL_ERROR_DB_FAILURE: + case EMAIL_ERROR_OUT_OF_MEMORY: + r = E_STORAGE_FULL; + break; + + default: + r = E_INVALID_CONDITION; + break; + } + + return r; } } } // Tizen::Messaging diff --git a/src/FMsg_MsgUtil.h b/src/FMsg_MsgUtil.h index 5e2aef6..404a934 100644 --- a/src/FMsg_MsgUtil.h +++ b/src/FMsg_MsgUtil.h @@ -55,17 +55,23 @@ public: static bool IsValidVcardFile(const Tizen::Base::String& filePath); static bool IsValidVcalendarFile(const Tizen::Base::String& filePath); static bool IsValidPhoneNumber(const Tizen::Base::String& phoneNumber); - static SmsMessageBoxType GetSmsMessageBoxType(messages_message_box_e folderId); - static messages_message_box_e GetMsgFolderId(const SmsMessageBoxType& type); - static SmsMessageBoxType GetMsgBoxType(const messages_message_box_e& folderId); - static int GetSmsMessage(const SmsMessage& message, const RecipientList& recipientList, messages_message_h& smsMsg); + static SmsMessageBoxType GetSmsMessageBoxType(_MSG_FOLDER_ID_E folderId); + static _MSG_FOLDER_ID_E GetMsgFolderId(const SmsMessageBoxType& type); + static SmsMessageBoxType GetMsgBoxType(const _MSG_FOLDER_ID_E& folderId); + static int GetSmsMessage(msg_struct_t& msgInfo, const SmsMessage& message, const RecipientList& recipientList); static Tizen::Base::String GetConcatenatedRecipientListString(const RecipientList& recipientList, RecipientType type, const Tizen::Base::String& delim); - static int GetMmsMessage(const MmsMessage& message, const RecipientList& recipientList, messages_message_h& mmsMsg); - static int GetEmailMessage(const EmailMessage& message, const RecipientList& recipientList, email_h& emailMsg); + static int GetMmsMessage(msg_struct_t& msgInfo, const MmsMessage& message, const RecipientList& recipientList); + static int PopulateMmsContent(const MmsMessage& message, msg_struct_t& msgData); static Tizen::Base::DateTime ConvertTime(time_t* pTime); - static SmsMessage* ConvertSmsMessageN(const SmsMessageBoxType& type, messages_message_h msg); - static int AddMessageAddress(const RecipientList& recipientList, RecipientType type, messages_message_h& messageMsg, messages_recipient_type_e recipientType); - static int AddEmailMessageAddress(const RecipientList& recipientList, RecipientType type, email_h& emailMsg, email_recipient_type_e recipientType); + static SmsMessage* ConvertSmsMessageN(const SmsMessageBoxType& type, msg_struct_t& msg); + static int AddMessageAddress(const RecipientList& recipientList, RecipientType type, msg_struct_t& messageMsg, _MSG_RECIPIENT_TYPE_E recipientType); + static result AddEmailMessageAddress(const RecipientList& recipientList, RecipientType type, email_mail_data_t *pMail); + static result SendEmail(const EmailMessage& message, const RecipientList& recipientList, int &mailboxId, int &requestId); + static result AddEmailMessageBody(email_mail_data_t *pMail, char * pBody); + static result AddEmailMessageAttachment(const EmailMessage& message, email_attachment_data_t ***pAttach, email_mail_data_t *pMail); + static result AddEmailCallBackToDbus(void); + static DBusHandlerResult EmailNetworkCallBack(DBusConnection* pConnection, DBusMessage* pMessage, void* pUserData); + static result EmailConvertException(int err); private: _MsgUtil(void); diff --git a/src/FMsg_PushEventArg.h b/src/FMsg_PushEventArg.h index 52b42a8..d39842c 100644 --- a/src/FMsg_PushEventArg.h +++ b/src/FMsg_PushEventArg.h @@ -16,10 +16,10 @@ // /** * @file FMsg_PushEventArg.h - * @brief This is the header file for _PushEventArg class. + * @brief This is the header file for %_PushEventArg class. * @version 3.0 * - * This header file contains the declarations of _PushEventArg class. + * This header file contains the declarations of %_PushEventArg class. */ #ifndef _FMSG_INTERNAL_PUSH_EVENT_ARG_H_ diff --git a/src/FMsg_PushManagerImpl.cpp b/src/FMsg_PushManagerImpl.cpp index 014694d..41284bc 100755 --- a/src/FMsg_PushManagerImpl.cpp +++ b/src/FMsg_PushManagerImpl.cpp @@ -381,7 +381,7 @@ _PushManagerImpl::Construct(IPushManagerListener& managerListener, IPushEventLis result r = E_SUCCESS; int ret = PUSH_ERROR_NONE; push_connection_h pushHandle = null; - String packageId; + PackageId packageId; char* pPackageId = null; SysTryReturnResult(NID_MSG, __pPushHandle == null, E_INVALID_STATE, "The __pPushHandle instance is already constructed."); @@ -406,9 +406,7 @@ _PushManagerImpl::Construct(IPushManagerListener& managerListener, IPushEventLis pRequestList.reset(new (std::nothrow) ArrayList()); SysTryCatch(NID_MSG, pRequestList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); - r = _AppInfo::GetAppId().SubString(0, 10, packageId); - SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to get a package ID."); - + packageId = _AppInfo::GetPackageId(); SysLog(NID_MSG, "Package ID is [%ls].", packageId.GetPointer()); pPackageId = _StringConverter::CopyToCharArrayN(packageId); @@ -1299,7 +1297,7 @@ _PushManagerImpl::SendHttpRequest(const String& url, const _PushRequest* pReques int timeout = _MAX_TRANSACTION_TIMEOUT; int length = 0; String lengthAsString(L""); - String packageId(L""); + PackageId packageId(L""); String appSecret(L""); r = uri.SetUri(url); @@ -1341,8 +1339,7 @@ _PushManagerImpl::SendHttpRequest(const String& url, const _PushRequest* pReques // Create Http Request Header __pHeader = __pRequest->GetHeader(); - r = _AppInfo::GetAppId().SubString(0, 10, packageId); - SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to get a package ID."); + packageId = _AppInfo::GetPackageId(); appSecret = GetAppSecret(); @@ -1463,7 +1460,11 @@ _PushManagerImpl::ComposeJsonObject(const _PushRequest* pRequest, const PushMess } PushAction pushAction = pushMessage.GetAction(); - if (pushAction == PUSH_ACTION_SILENT) + if (pushAction == PUSH_ACTION_ALERT) + { + action.Append("action=ALERT"); + } + else if (pushAction == PUSH_ACTION_SILENT) { action.Append("action=SILENT"); } @@ -1471,9 +1472,13 @@ _PushManagerImpl::ComposeJsonObject(const _PushRequest* pRequest, const PushMess { action.Append("action=DISCARD"); } + else if (pushAction == PUSH_ACTION_LAUNCH) + { + action.Append("action=LAUNCH"); + } else { - action.Append("action=ALERT"); + action.Append("action=SILENT"); } String alertText1 = notificationMessage.GetAlertText(); @@ -1588,12 +1593,8 @@ _PushManagerImpl::RequestPushRegistration(const _PushRequest* pRequest) ret = service_create(&svc); SysTryReturnResult(NID_MSG, ret == SERVICE_ERROR_NONE, E_SYSTEM, "service_create() is failed[%d].", ret); - // ToDo - Remove GetAppExecutableName(). - String appId; - appId.Clear(); - appId.Append(_AppInfo::GetAppId()); - appId.Append(L"."); - appId.Append(_AppInfo::GetAppExecutableName()); + AppId appId; + appId = _AppInfo::GetApplicationId(); pAppId = _StringConverter::CopyToCharArrayN(appId); SysTryReturnResult(NID_MSG, pAppId != null, E_SYSTEM, "Failed to get the application ID."); diff --git a/src/FMsg_PushMessageImpl.cpp b/src/FMsg_PushMessageImpl.cpp old mode 100644 new mode 100755 index 92f7a17..56cd859 --- a/src/FMsg_PushMessageImpl.cpp +++ b/src/FMsg_PushMessageImpl.cpp @@ -47,6 +47,8 @@ static const wchar_t _PUSH_MESSAGE_VALUE_BADGE_DECREASE[] = L"DECREASE"; static const wchar_t _PUSH_MESSAGE_VALUE_ACTION_SILENT[] = L"SILENT"; static const wchar_t _PUSH_MESSAGE_VALUE_ACTION_DISCARD[] = L"DISCARD"; static const wchar_t _PUSH_MESSAGE_VALUE_ACTION_ALERT[] = L"ALERT"; +static const wchar_t _PUSH_MESSAGE_VALUE_ACTION_LAUNCH[] = L"LAUNCH"; + namespace Tizen { namespace Messaging { @@ -156,7 +158,7 @@ result _PushMessageImpl::SetAction(PushAction action) { result r = E_SUCCESS; - SysTryReturn(NID_NET_SOCK, (action >= PUSH_ACTION_SILENT && action <= PUSH_ACTION_ALERT), r = E_INVALID_ARG, E_INVALID_ARG, + SysTryReturn(NID_NET_SOCK, (action >= PUSH_ACTION_SILENT && action <= PUSH_ACTION_LAUNCH), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid PushAction [%d] argument.", (int)action); __pushAction = action; @@ -282,7 +284,11 @@ _PushMessageImpl::ConvertMessageToNotification(const String& message) } else if (key.Equals(_PUSH_MESSAGE_KEY_ACTION, false) == true) { - if (value.Equals(_PUSH_MESSAGE_VALUE_ACTION_SILENT, false) == true) + if (value.Equals(_PUSH_MESSAGE_VALUE_ACTION_ALERT, false) == true) + { + __pushAction = PUSH_ACTION_ALERT; + } + else if (value.Equals(_PUSH_MESSAGE_VALUE_ACTION_SILENT, false) == true) { __pushAction = PUSH_ACTION_SILENT; } @@ -290,9 +296,9 @@ _PushMessageImpl::ConvertMessageToNotification(const String& message) { __pushAction = PUSH_ACTION_DISCARD; } - else if (value.Equals(_PUSH_MESSAGE_VALUE_ACTION_ALERT, false) == true) + else if (value.Equals(_PUSH_MESSAGE_VALUE_ACTION_LAUNCH, false) == true) { - __pushAction = PUSH_ACTION_ALERT; + __pushAction = PUSH_ACTION_LAUNCH; } else { diff --git a/src/FMsg_SmsEvent.cpp b/src/FMsg_SmsEvent.cpp index de6a90a..5b2333c 100644 --- a/src/FMsg_SmsEvent.cpp +++ b/src/FMsg_SmsEvent.cpp @@ -22,6 +22,7 @@ */ #include +#include #include #include #include @@ -94,7 +95,7 @@ _SmsEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen: IEventArg* pEventArg = const_cast (&arg); _SmsEventArg* pSmsEventArg = dynamic_cast <_SmsEventArg*>(pEventArg); - SysTryReturnVoidResult(NID_MSG, pSmsEventArg != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system."); + SysTryReturnVoidResult(NID_MSG, pSmsEventArg != null, E_SYSTEM, "A failure occurred from the underlying system."); SmsMessage message; CbsMessage* pCbsMessage = null; @@ -107,44 +108,57 @@ _SmsEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen: if (pSmsEventArg->GetEventType() == _SMS_EVENT_TYPE_SMS_SEND_RESULT) { pSmsListener = dynamic_cast (&listener); - SysTryReturnVoidResult(NID_MSG, pSmsListener != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system."); + SysTryReturnVoidResult(NID_MSG, pSmsListener != null, E_SYSTEM, "A failure occurred from the underlying system."); + + // set result pSmsEventArg->GetErrorResult(r); + // Fire pSmsListener->OnSmsMessageSent(r); } else if (pSmsEventArg->GetEventType() == _SMS_EVENT_TYPE_SMS_TRIGGER) { pSmsEventListener = dynamic_cast (&listener); - SysTryReturnVoidResult(NID_MSG, pSmsEventListener != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system."); - r = message.SetText(pSmsEventArg->GetMessage()); - if (IsFailed(r)) - { - SysLogException(NID_MSG, r, "[%s] occurred. Input text is [%ls] and its length is [%d].", GetErrorMessage(r), pSmsEventArg->GetMessage().GetPointer(), pSmsEventArg->GetMessage().GetLength()); - } - dateTime = pSmsEventArg->GetDateTime(); + SysTryReturnVoidResult(NID_MSG, pSmsEventListener != null, E_SYSTEM, "A failure occurred from the underlying system."); + + _SmsMessageImpl* pImpl = _SmsMessageImpl::GetInstance(message); + SysTryReturnVoidResult(NID_MSG, pImpl != null, E_SYSTEM, "A failure occurred from the underlying system."); + + // port port = pSmsEventArg->GetPort(); + // received time + dateTime = pSmsEventArg->GetDateTime(); + // message + pImpl->SetIncomingMessage(pSmsEventArg->GetMessage(), pSmsEventArg->GetSenderAddress(), dateTime); + // Fire pSmsEventListener->OnSmsMessageReceived(port, dateTime, message); } else if (pSmsEventArg->GetEventType() == _SMS_EVENT_TYPE_SMS_RECEIVE_RESULT) { pSmsMessageEventListener = dynamic_cast (&listener); - SysTryReturnVoidResult(NID_MSG, pSmsMessageEventListener != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system."); - _SmsMessageImpl::GetInstance(message)->SetIncomingMessage(pSmsEventArg->GetMessage(), - pSmsEventArg->GetSenderAddress(), pSmsEventArg->GetDateTime()); + SysTryReturnVoidResult(NID_MSG, pSmsMessageEventListener != null, E_SYSTEM, "A failure occurred from the underlying system."); + + _SmsMessageImpl* pImpl = _SmsMessageImpl::GetInstance(message); + SysTryReturnVoidResult(NID_MSG, pImpl != null, E_SYSTEM, "A failure occurred from the underlying system."); + + // set message + pImpl->SetIncomingMessage(pSmsEventArg->GetMessage(), pSmsEventArg->GetSenderAddress(), pSmsEventArg->GetDateTime()); + // Fire pSmsMessageEventListener->OnSmsMessageReceived(message); } else if (pSmsEventArg->GetEventType() == _SMS_EVENT_TYPE_CBS_RECEIVE_RESULT) { pCbsMessageEventListener = dynamic_cast (&listener); - SysTryReturnVoidResult(NID_MSG, pCbsMessageEventListener != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system."); - pCbsMessage = _CbsMessageImpl::GetCbsMessageN(); + SysTryReturnVoidResult(NID_MSG, pCbsMessageEventListener != null, E_SYSTEM, "A failure occurred from the underlying system."); + pCbsMessage = _CbsMessageImpl::GetCbsMessageN(); if (pCbsMessage) { - _CbsMessageImpl::GetInstance(*pCbsMessage)->SetCbsMessageImpl(pSmsEventArg->GetDateTime(), *(pSmsEventArg->GetSerialNumber()), pSmsEventArg->GetMessage(), pSmsEventArg->GetMessageId(), pSmsEventArg->GetEtwsNotification(), pSmsEventArg->GetDataCodingScheme()); + _CbsMessageImpl::GetInstance(*pCbsMessage)->SetCbsMessageImpl(pSmsEventArg->GetDateTime(), *(pSmsEventArg->GetSerialNumber()), pSmsEventArg->GetMessage(), pSmsEventArg->GetMessageId(), pSmsEventArg->GetEtwsNotification(), pSmsEventArg->GetDataCodingScheme(), pSmsEventArg->GetCbsLanguageType()); } + // Fire if (pCbsMessage) { @@ -156,7 +170,8 @@ _SmsEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen: else if (pSmsEventArg->GetEventType() == _SMS_EVENT_TYPE_WAP_PUSH_RECEIVE_RESULT) { pWapPushMessageEventListener = dynamic_cast (&listener); - SysTryReturnVoidResult(NID_MSG, pWapPushMessageEventListener != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system."); + SysTryReturnVoidResult(NID_MSG, pWapPushMessageEventListener != null, E_SYSTEM, "A failure occurred from the underlying system."); + pWapPushMessage = _WapPushMessageImpl::GetWapPushMessageN(pSmsEventArg->GetMessage(), *(pSmsEventArg->GetWapPushBody())); // Fire @@ -170,7 +185,7 @@ _SmsEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen: else if (pSmsEventArg->GetEventType() == _SMS_EVENT_TYPE_ETWS_RECEIVE_RESULT) { pEtwsNotificationMesssageEventListener = dynamic_cast (&listener); - SysTryReturnVoidResult(NID_MSG, pEtwsNotificationMesssageEventListener != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system."); + SysTryReturnVoidResult(NID_MSG, pEtwsNotificationMesssageEventListener != null, E_SYSTEM, "A failure occurred from the underlying system."); pEtwsNotificationMessage = _EtwsPrimaryNotificationImpl::GetEtwsPrimaryNotificationN(); if (pEtwsNotificationMessage) diff --git a/src/FMsg_SmsEventArg.cpp b/src/FMsg_SmsEventArg.cpp index 28d0479..97e9119 100644 --- a/src/FMsg_SmsEventArg.cpp +++ b/src/FMsg_SmsEventArg.cpp @@ -32,96 +32,95 @@ namespace Tizen { namespace Messaging { _SmsEventArg::_SmsEventArg(void) + : __result(E_SUCCESS) + , __port(-1) + , __eventType(_SMS_EVENT_TYPE_NONE) + , __pPushMsgBody(null) + , __pMsgSerialNumber(null) + , __pMsgSecurityInfo(null) + , __pEtwsWarningType(null) { - __eventType = _SMS_EVENT_TYPE_NONE; - __port = -1; - __result = E_SUCCESS; - __pPushMsgBody = null; - __pMsgSerialNumber = null; - __pMsgSecurityInfo = null; - __pEtwsWarningType = null; } _SmsEventArg::_SmsEventArg(const result r) + : __port(-1) + , __eventType(_SMS_EVENT_TYPE_SMS_SEND_RESULT) + , __pPushMsgBody(null) + , __pMsgSerialNumber(null) + , __pMsgSecurityInfo(null) + , __pEtwsWarningType(null) { - __eventType = _SMS_EVENT_TYPE_SMS_SEND_RESULT; - __port = -1; - __pPushMsgBody = null; - __pMsgSerialNumber = null; - __pMsgSecurityInfo = null; - __pEtwsWarningType = null; - if (IsFailed(r)) { __result = E_FAILURE; } else { - __result = r; // E_SUCCESS + __result = r; // E_SUCCESS } } -_SmsEventArg::_SmsEventArg(int port, const DateTime& dateTime, const String& message) +_SmsEventArg::_SmsEventArg(int port, const DateTime& dateTime, const String& message, const String& senderAddress) + : __result(E_UNKNOWN) + , __message(message) + , __port(port) + , __sender(senderAddress) + , __dateTime(dateTime) + , __eventType(_SMS_EVENT_TYPE_SMS_TRIGGER) + , __pPushMsgBody(null) + , __pMsgSerialNumber(null) + , __pMsgSecurityInfo(null) + , __pEtwsWarningType(null) { - __eventType = _SMS_EVENT_TYPE_SMS_TRIGGER; - __port = port; - __dateTime = dateTime; - __message = message; - __result = E_UNKNOWN; - __pPushMsgBody = null; - __pMsgSerialNumber = null; - __pMsgSecurityInfo = null; - __pEtwsWarningType = null; } _SmsEventArg::_SmsEventArg(const Tizen::Base::String& text, const Tizen::Base::String& senderAddress, const Tizen::Base::DateTime& receivedTime) + : __result(E_UNKNOWN) + , __message(text) + , __port(-1) + , __sender(senderAddress) + , __dateTime(receivedTime) + , __eventType(_SMS_EVENT_TYPE_SMS_RECEIVE_RESULT) + , __pPushMsgBody(null) + , __pMsgSerialNumber(null) + , __pMsgSecurityInfo(null) + , __pEtwsWarningType(null) { - __eventType = _SMS_EVENT_TYPE_SMS_RECEIVE_RESULT; - __port = -1; - __sender = senderAddress; - __dateTime = receivedTime; - __message = text; - __result = E_UNKNOWN; - __pPushMsgBody = null; - __pMsgSerialNumber = null; - __pMsgSecurityInfo = null; - __pEtwsWarningType = null; } -_SmsEventArg::_SmsEventArg(const Tizen::Base::String& text, const Tizen::Base::ByteBuffer& msgSerialNumber, const Tizen::Base::DateTime& receivedTime, int messageId, bool isEtwsNotification, byte dataCodingScheme, _SmsEventType eventType) +_SmsEventArg::_SmsEventArg(const Tizen::Base::String& text, const Tizen::Base::ByteBuffer& msgSerialNumber, const Tizen::Base::DateTime& receivedTime, int messageId, bool isEtwsNotification, byte dataCodingScheme, const Tizen::Base::String& languageType, _SmsEventType eventType) + : __result(E_UNKNOWN) + , __message(text) + , __port(-1) + , __dateTime(receivedTime) + , __eventType(eventType) //_SMS_EVENT_TYPE_CBS_RECEIVE_RESULT + , __pPushMsgBody(null) + , __pMsgSerialNumber(null) + , __pMsgSecurityInfo(null) + , __messageId(messageId) + , __isEtwsNotification(isEtwsNotification) + , __pEtwsWarningType(null) + , __dataCodingScheme(dataCodingScheme) + , __cbslanguageType(languageType) { - __eventType = eventType; //_SMS_EVENT_TYPE_CBS_RECEIVE_RESULT - __port = -1; - __dateTime = receivedTime; - __message = text; - __result = E_UNKNOWN; - __pPushMsgBody = null; - __messageId = messageId; - __isEtwsNotification = isEtwsNotification; - __pMsgSerialNumber = null; - __pMsgSecurityInfo = null; - __pEtwsWarningType = null; - __dataCodingScheme = dataCodingScheme; - __pMsgSerialNumber = new (std::nothrow) ByteBuffer(); - SysTryReturnVoidResult(NID_MSG, __pMsgSerialNumber != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory"); + SysTryReturnVoidResult(NID_MSG, __pMsgSerialNumber != null, E_OUT_OF_MEMORY, "memory allocation failed"); __pMsgSerialNumber->Construct(msgSerialNumber); __pMsgSerialNumber->SetPosition(0); } _SmsEventArg::_SmsEventArg(const Tizen::Base::DateTime& receivedTime, const Tizen::Base::ByteBuffer& msgSerialNumber, const Tizen::Base::ByteBuffer& msgSecurityInfo, int messageId, const Tizen::Base::ByteBuffer& etwsWarningType, _SmsEventType eventType) + : __result(E_UNKNOWN) + , __port(-1) + , __dateTime(receivedTime) + , __eventType(eventType) //_SMS_EVENT_TYPE_ETWS_RECEIVE_RESULT + , __pPushMsgBody(null) + , __pMsgSerialNumber(null) + , __pMsgSecurityInfo(null) + , __messageId(messageId) + , __pEtwsWarningType(null) { - __eventType = eventType; //_SMS_EVENT_TYPE_ETWS_RECEIVE_RESULT - __port = -1; - __dateTime = receivedTime; - __result = E_UNKNOWN; - __pPushMsgBody = null; - __messageId = messageId; - __pMsgSerialNumber = null; - __pMsgSecurityInfo = null; - __pEtwsWarningType = null; - __pMsgSerialNumber = new (std::nothrow) ByteBuffer(); SysTryReturnVoidResult(NID_MSG, __pMsgSerialNumber != null, E_OUT_OF_MEMORY, "memory allocation failed"); @@ -142,15 +141,14 @@ _SmsEventArg::_SmsEventArg(const Tizen::Base::DateTime& receivedTime, const Tize } _SmsEventArg::_SmsEventArg(const Tizen::Base::String& pushMsgHdr, const Tizen::Base::ByteBuffer& pushMsgBody, _SmsEventType eventType) + : __result(E_UNKNOWN) + , __message(pushMsgHdr) + , __port(-1) + , __eventType(eventType) //_SMS_EVENT_TYPE_WAP_PUSH_RECEIVE_RESULT + , __pMsgSerialNumber(null) + , __pMsgSecurityInfo(null) + , __pEtwsWarningType(null) { - __eventType = eventType; //_SMS_EVENT_TYPE_WAP_PUSH_RECEIVE_RESULT - __port = -1; - __message = pushMsgHdr; - __result = E_UNKNOWN; - __pMsgSerialNumber = null; - __pMsgSecurityInfo = null; - __pEtwsWarningType = null; - __pPushMsgBody = new (std::nothrow) ByteBuffer(); SysTryReturnVoidResult(NID_MSG, __pPushMsgBody != null, E_OUT_OF_MEMORY, "memory allocation failed"); @@ -236,11 +234,6 @@ _SmsEventArg::GetMessage(void) const String _SmsEventArg::GetSenderAddress(void) const { - if (__eventType != _SMS_EVENT_TYPE_SMS_RECEIVE_RESULT) - { - return L""; - } - return __sender; } @@ -292,4 +285,10 @@ _SmsEventArg::GetDataCodingScheme(void) const return __dataCodingScheme; } +Tizen::Base::String +_SmsEventArg::GetCbsLanguageType(void) const +{ + return __cbslanguageType; +} + } } diff --git a/src/FMsg_SmsEventArg.h b/src/FMsg_SmsEventArg.h index cd328db..8c6e690 100644 --- a/src/FMsg_SmsEventArg.h +++ b/src/FMsg_SmsEventArg.h @@ -65,11 +65,12 @@ public: /** * This is the constructor. * - * @param[in] port - the port number - * @param[in] dateTime - the received date time - * @param[in] message - the received message + * @param[in] port The port number + * @param[in] dateTime The received date time + * @param[in] message The received message + * @param[in] senderAddress The sender address of the message */ - _SmsEventArg(int port, const Tizen::Base::DateTime& dateTime, const Tizen::Base::String& message); + _SmsEventArg(int port, const Tizen::Base::DateTime& dateTime, const Tizen::Base::String& message, const Tizen::Base::String& senderAddress); /** * This is the constructor. @@ -90,7 +91,7 @@ public: * @param[in] isEtwsNotification The Etws Notification * @param[in] eventType The received event type of the message */ - _SmsEventArg(const Tizen::Base::String& text, const Tizen::Base::ByteBuffer& msgSerialNumber, const Tizen::Base::DateTime& receivedTime, int messageId, bool isEtwsNotification, byte dataCodingScheme, _SmsEventType eventType); + _SmsEventArg(const Tizen::Base::String& text, const Tizen::Base::ByteBuffer& msgSerialNumber, const Tizen::Base::DateTime& receivedTime, int messageId, bool isEtwsNotification, byte dataCodingScheme, const Tizen::Base::String& languageType, _SmsEventType eventType); /** * This is the constructor. @@ -218,6 +219,14 @@ public: Tizen::Base::ByteBuffer* GetWapPushBody(void) const; + /** + * + * Gets the language type of a CB message. + * + * @return The language type of a message + */ + Tizen::Base::String GetCbsLanguageType(void) const; + private: _SmsEventArg(const _SmsEventArg& eventArg); _SmsEventArg& operator =(const _SmsEventArg& value); @@ -236,6 +245,7 @@ private: bool __isEtwsNotification; Tizen::Base::ByteBuffer* __pEtwsWarningType; byte __dataCodingScheme; + Tizen::Base::String __cbslanguageType; }; // _SmsEventArg } } diff --git a/src/FMsg_SmsManagerImpl.cpp b/src/FMsg_SmsManagerImpl.cpp index dfccfe1..1d1e138 100644 --- a/src/FMsg_SmsManagerImpl.cpp +++ b/src/FMsg_SmsManagerImpl.cpp @@ -23,8 +23,11 @@ // OAF headers #include -#include -#include +#include +#include +#include +#include +#include #include #include #include @@ -61,7 +64,6 @@ _SmsManagerImpl::_SmsManagerImpl(void) _SmsManagerImpl::~_SmsManagerImpl(void) { - int err = MESSAGES_ERROR_NONE; if (__pSmsReceiveEvent) { @@ -93,9 +95,8 @@ _SmsManagerImpl::~_SmsManagerImpl(void) if (_SmsMmsCallbackHandler::GetInstance()) { - err = messages_cb_unset_incoming_cb(__msgHandle); - err = messages_cb_unset_etws_primary_noti_cb(__msgHandle); - err = _SmsMmsCallbackHandler::GetInstance()->CloseMessageHandle(); + _SmsMmsCallbackHandler::GetInstance()->CloseMessageHandle(); + _SmsMmsCallbackHandler::GetInstance()->CloseCbsSettingsHandle(); } __isConstructed = false; @@ -106,7 +107,7 @@ _SmsManagerImpl::Construct(const ISmsListener& listener) { // method return code result r = E_SUCCESS; - int err = MESSAGES_ERROR_NONE; + int err = MSG_SUCCESS; SysAssertf(__isConstructed == false, "_SmsManagerImpl instance is already constructed."); @@ -134,11 +135,16 @@ _SmsManagerImpl::Construct(const ISmsListener& listener) // check value of msg handle SysTryReturnResult(NID_MSG, __msgHandle > 0, E_SYSTEM, "msgHandle is invalid."); - // open CB message settings handle + // register sent status callback + err = _SmsMmsCallbackHandler::GetInstance()->RegisterMessageCallback(); + + 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); - SysLog(NID_MSG, "value of __cbsSettingsHandle is [%d]", __cbsSettingsHandle); - if (err == MESSAGES_ERROR_NO_SIM_CARD) + 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 @@ -152,6 +158,10 @@ _SmsManagerImpl::Construct(const ISmsListener& listener) SysTryReturnResult(NID_MSG, __cbsSettingsHandle > 0, E_SYSTEM, "cbsSettingsHandle is invalid."); } + // load cbs settings + r = _SmsMmsCallbackHandler::GetInstance()->LoadCbsSettings(); + SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to load cbs message settings."); + __pSmsEvent = move(pSmsEvent); __isConstructed = true; @@ -167,7 +177,7 @@ _SmsManagerImpl::AddSmsEventListener(int port, ISmsEventListener& eventListener) result r = E_SUCCESS; _SmsEvent* pSmsTriggerEvent = null; - int err = MESSAGES_ERROR_NONE; + int err = MSG_SUCCESS; // check duplications if (__pSmsTriggerEventList) @@ -211,24 +221,13 @@ _SmsManagerImpl::AddSmsEventListener(int port, ISmsEventListener& eventListener) SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to add a listener.", GetErrorMessage(r)); // Register SMS Trigger - err = messages_set_message_incoming_cb(__msgHandle, &_SmsMmsCallbackHandler::IncomingSmsMessageCallback,(void*)pSmsTriggerEvent); + err = msg_reg_sms_message_callback(__msgHandle, &_SmsMmsCallbackHandler::IncomingSmsMessageCallback, port, (void*) pSmsTriggerEvent); - if (err != MESSAGES_ERROR_NONE) + if (err != MSG_SUCCESS) { r = __pSmsTriggerEventList->Remove(*pSmsTriggerEvent); r = E_SYSTEM; - SysLogException(NID_MSG, r, "[%s] Failed to remove a listener.", GetErrorMessage(r)); - - goto CATCH; - } - - err = messages_add_sms_listening_port(__msgHandle, port); - - if (err != MESSAGES_ERROR_NONE) - { - r = __pSmsTriggerEventList->Remove(*pSmsTriggerEvent); - r = E_SYSTEM; - SysLogException(NID_MSG, r, "[%s] Failed to remove a listener.", GetErrorMessage(r)); + SysLogException(NID_MSG, r, "[%s] Failed to register for incoming sms callback.", GetErrorMessage(r)); goto CATCH; } @@ -254,7 +253,6 @@ _SmsManagerImpl::RemoveSmsEventListener(int port, ISmsEventListener& eventListen int index = -1; int listSize = -1; bool isFound = false; - int err = MESSAGES_ERROR_NONE; // find the SmsTriggerEvent using port if (__pSmsTriggerEventList) @@ -279,11 +277,6 @@ _SmsManagerImpl::RemoveSmsEventListener(int port, ISmsEventListener& eventListen r = __pSmsTriggerEventList->RemoveAt(index, true); SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to remove the event listener"); - err = messages_unset_message_incoming_cb(__msgHandle); - - r = ConvertException(err); - SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to remove the event listener"); - return r; } @@ -294,7 +287,7 @@ _SmsManagerImpl::AddSmsMessageEventListener(const ISmsMessageEventListener& even SysAssertf(__msgHandle > 0, "message handle is invalid."); result r = E_SUCCESS; - int err = MESSAGES_ERROR_NONE; + int err = MSG_SUCCESS; // set event if (!__pSmsReceiveEvent) @@ -310,11 +303,16 @@ _SmsManagerImpl::AddSmsMessageEventListener(const ISmsMessageEventListener& even r = __pSmsReceiveEvent->AddListener(eventListener, true); SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "Failed to add a listener"); - err = messages_set_message_incoming_cb(__msgHandle, &_SmsMmsCallbackHandler::IncomingSmsMessageCallback, (void*) + err = msg_reg_sms_message_callback(__msgHandle, &_SmsMmsCallbackHandler::IncomingSmsMessageCallback, 0, (void*) __pSmsReceiveEvent); r = ConvertException(err); - SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to add a listener.", GetErrorMessage(r)); + SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to register for incoming sms callback.", GetErrorMessage(r)); + + if (_SmsMmsCallbackHandler::GetInstance()) + { + _SmsMmsCallbackHandler::GetInstance()->SetInComingSmsCallback(true); + } return E_SUCCESS; @@ -335,16 +333,16 @@ _SmsManagerImpl::RemoveSmsMessageEventListener(const ISmsMessageEventListener& e SysAssertf(__msgHandle > 0, "message handle is invalid."); result r = E_SUCCESS; - int err = MESSAGES_ERROR_NONE; SysTryReturnResult(NID_MSG, __pSmsReceiveEvent != NULL, E_OBJ_NOT_FOUND, "Failed to remove a listener"); r = __pSmsReceiveEvent->RemoveListener(eventListener); SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to remove a listener..", GetErrorMessage(r)); - err = messages_unset_message_incoming_cb(__msgHandle); - - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "Failed to remove the event listener"); + if (_SmsMmsCallbackHandler::GetInstance()) + { + _SmsMmsCallbackHandler::GetInstance()->SetInComingSmsCallback(false); + } if (__pSmsReceiveEvent) { @@ -365,8 +363,9 @@ _SmsManagerImpl::GetTotalMessageCount(SmsMessageBoxType type) const SysAssertf(__msgHandle > 0, "message handle is invalid."); int msgCount = 0; - int err = MESSAGES_ERROR_NONE; - messages_message_box_e folderType = MESSAGES_MBOX_INBOX; + msg_struct_t countInfo = NULL; + int err = MSG_SUCCESS; + _MSG_FOLDER_ID_E folderType = MSG_ALLBOX_ID; result r = E_SUCCESS; ClearLastResult(); @@ -374,16 +373,29 @@ _SmsManagerImpl::GetTotalMessageCount(SmsMessageBoxType type) const switch (type) { case SMS_MESSAGE_BOX_TYPE_INBOX: - folderType = MESSAGES_MBOX_INBOX; + folderType = MSG_INBOX_ID; break; case SMS_MESSAGE_BOX_TYPE_SENTBOX: - folderType = MESSAGES_MBOX_SENTBOX; + folderType = MSG_SENTBOX_ID; break; case SMS_MESSAGE_BOX_TYPE_OUTBOX: - folderType = MESSAGES_MBOX_OUTBOX; + folderType = MSG_OUTBOX_ID; break; case SMS_MESSAGE_BOX_TYPE_ALL: - folderType = MESSAGES_MBOX_ALL; + { + err = msg_count_msg_by_type(__msgHandle, MSG_TYPE_SMS, &msgCount); + + if (err != MSG_SUCCESS) + { + r = ConvertException(err); + SysLogException(NID_MSG, r, "[%s] Failed to get the message count", GetErrorMessage(r)); + SetLastResult(r); + return -1; + } + + SysLog(NID_MSG, "Total count of messages is [%d]", msgCount); + return msgCount; + } break; case SMS_MESSAGE_BOX_TYPE_NONE: // impossible case break; @@ -391,15 +403,21 @@ _SmsManagerImpl::GetTotalMessageCount(SmsMessageBoxType type) const break; } - // get the count of corresponding message box - err = messages_get_message_count(__msgHandle, folderType, MESSAGES_TYPE_SMS, &msgCount); - if (err != MESSAGES_ERROR_NONE) + // get the count of corresponding message box + countInfo = msg_create_struct(MSG_STRUCT_COUNT_INFO); + err = msg_count_message(__msgHandle, folderType, countInfo); + + if (err != MSG_SUCCESS) { r = ConvertException(err); SysLogException(NID_MSG, r, "[%s] Failed to get the message count of the message box (%d)", GetErrorMessage(r), (int) type); + msg_release_struct(&countInfo); SetLastResult(r); return -1; } + + msg_get_int_value(countInfo, MSG_COUNT_INFO_SMS_INT, &msgCount); + msg_release_struct(&countInfo); SysLog(NID_MSG, "Total count of messages is [%d]", msgCount); return msgCount; @@ -416,11 +434,10 @@ _SmsManagerImpl::SearchInboxN(const Tizen::Base::String* pKeyword, const Tizen:: char* pSearchString = NULL; char* pSenderAddressTemp = NULL; ArrayList* pList = null; - int err = MESSAGES_ERROR_NONE; + int err = MSG_SUCCESS; result r = E_SUCCESS; - messages_message_h* pMsgList = null; - int searchCount = 0; - int totalCount = 0; + msg_struct_list_s msgList; + msg_struct_t searchCon = NULL; ClearLastResult(); @@ -431,34 +448,41 @@ _SmsManagerImpl::SearchInboxN(const Tizen::Base::String* pKeyword, const Tizen:: r = pList->Construct(); SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "Failed to construct an ArrayList"); + // Set Condition + searchCon = msg_create_struct(MSG_STRUCT_SEARCH_CONDITION); + msg_set_int_value(searchCon, MSG_SEARCH_CONDITION_FOLDERID_INT, MSG_INBOX_ID); + msg_set_int_value(searchCon, MSG_SEARCH_CONDITION_MSGTYPE_INT, MSG_TYPE_SMS); + // keyword if (pKeyword) { pSearchString = _StringConverter::CopyToCharArrayN(*pKeyword); + SysTryCatch(NID_MSG, pSearchString != null, r = E_OUT_OF_MEMORY, r, "Memory allocation failed."); + msg_set_str_value(searchCon, MSG_SEARCH_CONDITION_SEARCH_VALUE_STR, pSearchString, strlen(pSearchString)); } // sender address if (pSenderAddress) { pSenderAddressTemp = _StringConverter::CopyToCharArrayN(*pSenderAddress); + SysTryCatch(NID_MSG, pSenderAddressTemp != null, r = E_OUT_OF_MEMORY, r, "Memory allocation failed."); + msg_set_str_value(searchCon, MSG_SEARCH_CONDITION_ADDRESS_VALUE_STR, pSenderAddressTemp, strlen(pSenderAddressTemp)); } - // searching - err = messages_search_message(__msgHandle, MESSAGES_MBOX_INBOX, MESSAGES_TYPE_SMS, - pSearchString, pSenderAddressTemp, startIndex, count, - &pMsgList, &searchCount, &totalCount); + // Search + err = msg_search_message(__msgHandle, searchCon, startIndex, count, &msgList); r = ConvertException(err); SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] msg_search_message call failed.", GetErrorMessage(r)); - totalResultCount = searchCount; + totalResultCount = msgList.nCount; SysLog(NID_MSG, "Total Search count of messages is [%d]", totalResultCount); - for (int index = 0; index < searchCount; index++) + for (int index = 0; index < totalResultCount; index++) { // get SmsMessage instance - SmsMessage* pSmsMessage = _MsgUtil::ConvertSmsMessageN(SMS_MESSAGE_BOX_TYPE_INBOX, pMsgList[index]); + SmsMessage* pSmsMessage = _MsgUtil::ConvertSmsMessageN(SMS_MESSAGE_BOX_TYPE_INBOX, msgList.msg_struct_info[index]); // add to the list pList->Add(*pSmsMessage); } @@ -475,7 +499,8 @@ _SmsManagerImpl::SearchInboxN(const Tizen::Base::String* pKeyword, const Tizen:: pSenderAddressTemp = NULL; } - messages_free_message_array(pMsgList); + msg_release_struct(&searchCon); + msg_release_list_struct(&msgList); return pList; @@ -502,7 +527,8 @@ CATCH: pList = null; } - messages_free_message_array(pMsgList); + msg_release_struct(&searchCon); + msg_release_list_struct(&msgList); return null; } @@ -515,13 +541,12 @@ _SmsManagerImpl::SearchMessageBoxN(SmsMessageBoxType type, const Tizen::Base::St SysAssertf(__msgHandle > 0, "message handle is invalid."); result r = E_SUCCESS; - int err = MESSAGES_ERROR_NONE; + int err = MSG_SUCCESS; char* pSearchString = NULL; - messages_message_box_e folderId = MESSAGES_MBOX_ALL; + int folderId = MSG_ALLBOX_ID; ArrayList* pList = NULL; - messages_message_h* pMsgList = null; - int searchCount = 0; - int totalCount = 0; + msg_struct_list_s msgList; + msg_struct_t searchCon = NULL; ClearLastResult(); @@ -535,51 +560,57 @@ _SmsManagerImpl::SearchMessageBoxN(SmsMessageBoxType type, const Tizen::Base::St // type folderId = _MsgUtil::GetMsgFolderId(type); + // Set Condition + searchCon = msg_create_struct(MSG_STRUCT_SEARCH_CONDITION); + msg_set_int_value(searchCon, MSG_SEARCH_CONDITION_FOLDERID_INT, folderId); + msg_set_int_value(searchCon, MSG_SEARCH_CONDITION_MSGTYPE_INT, MSG_TYPE_SMS); + // keyword if (pKeyword) { pSearchString = _StringConverter::CopyToCharArrayN(*pKeyword); + SysTryCatch(NID_MSG, pSearchString != null, r = E_OUT_OF_MEMORY, r, "Memory allocation failed."); + msg_set_str_value(searchCon, MSG_SEARCH_CONDITION_SEARCH_VALUE_STR, pSearchString, strlen(pSearchString)); } - // searching - err = messages_search_message(__msgHandle, folderId, MESSAGES_TYPE_SMS, pSearchString, null, - startIndex, count, &pMsgList, &searchCount, &totalCount); + // Search + err = msg_search_message(__msgHandle, searchCon, startIndex, count, &msgList); r = ConvertException(err); SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] msg_search_message call failed.", GetErrorMessage(r)); - totalResultCount = searchCount; + totalResultCount = msgList.nCount; SysLog(NID_MSG, "Total Search count of messages is [%d]", totalResultCount); - for (int index = 0; index < searchCount; index++) + for (int index = 0; index < totalResultCount; index++) { SmsMessage* pSmsMessage = null; if (type == SMS_MESSAGE_BOX_TYPE_ALL) { - messages_get_mbox_type(pMsgList[index], &folderId); + err = msg_get_int_value(msgList.msg_struct_info[index], MSG_MESSAGE_FOLDER_ID_INT, &folderId); switch (folderId) { - case MESSAGES_MBOX_INBOX: - pSmsMessage = _MsgUtil::ConvertSmsMessageN(SMS_MESSAGE_BOX_TYPE_INBOX, pMsgList[index]); + case MSG_INBOX_ID: + pSmsMessage = _MsgUtil::ConvertSmsMessageN(SMS_MESSAGE_BOX_TYPE_INBOX, msgList.msg_struct_info[index]); break; - case MESSAGES_MBOX_OUTBOX: - pSmsMessage = _MsgUtil::ConvertSmsMessageN(SMS_MESSAGE_BOX_TYPE_OUTBOX, pMsgList[index]); + case MSG_OUTBOX_ID: + pSmsMessage = _MsgUtil::ConvertSmsMessageN(SMS_MESSAGE_BOX_TYPE_OUTBOX, msgList.msg_struct_info[index]); break; - case MESSAGES_MBOX_SENTBOX: - pSmsMessage = _MsgUtil::ConvertSmsMessageN(SMS_MESSAGE_BOX_TYPE_SENTBOX, pMsgList[index]); + case MSG_SENTBOX_ID: + pSmsMessage = _MsgUtil::ConvertSmsMessageN(SMS_MESSAGE_BOX_TYPE_SENTBOX, msgList.msg_struct_info[index]); break; - case MESSAGES_MBOX_DRAFT : - //pSmsMessage = _MsgUtil::ConvertSmsMessageN(SMS_MESSAGE_BOX_TYPE_SENTBOX, pMsgList[index]); + case MSG_DRAFT_ID: + //pSmsMessage = _MsgUtil::ConvertSmsMessageN(SMS_MESSAGE_BOX_TYPE_SENTBOX, msgList.msg_struct_info[index]); break; - case MESSAGES_MBOX_ALL: - //pSmsMessage = _MsgUtil::ConvertSmsMessageN(SMS_MESSAGE_BOX_TYPE_SENTBOX, msgList[index]); + case MSG_ALLBOX_ID: + //pSmsMessage = _MsgUtil::ConvertSmsMessageN(SMS_MESSAGE_BOX_TYPE_SENTBOX, msgList.msg_struct_info[index]); break; } @@ -588,7 +619,7 @@ _SmsManagerImpl::SearchMessageBoxN(SmsMessageBoxType type, const Tizen::Base::St } else { - pSmsMessage = _MsgUtil::ConvertSmsMessageN(type, pMsgList[index]); + pSmsMessage = _MsgUtil::ConvertSmsMessageN(type, msgList.msg_struct_info[index]); pList->Add(*pSmsMessage); } } @@ -599,7 +630,8 @@ _SmsManagerImpl::SearchMessageBoxN(SmsMessageBoxType type, const Tizen::Base::St pSearchString = NULL; } - messages_free_message_array(pMsgList); + msg_release_struct(&searchCon); + msg_release_list_struct(&msgList); return pList; @@ -620,7 +652,8 @@ CATCH: pSearchString = NULL; } - messages_free_message_array(pMsgList); + msg_release_struct(&searchCon); + msg_release_list_struct(&msgList); return null; } @@ -633,44 +666,39 @@ _SmsManagerImpl::GetFullText(int messageId) const result r = E_SUCCESS; String fullText; - messages_message_h msg = {0}; - int err = MESSAGES_ERROR_NONE; - - char* pOriginalText = null; - char* pBodyText = null; + msg_struct_t smsMsg = null; + msg_struct_t sendOpt = null; + int err = MSG_SUCCESS; + char msgText[MAX_MSG_TEXT_LEN]; ClearLastResult(); // get SMS message - err = messages_search_message_by_id(__msgHandle, messageId, &msg); + smsMsg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); + err = msg_get_message(__msgHandle, messageId, smsMsg, sendOpt); r = ConvertException(err); SetLastResult(r); - SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] messages_search_message_by_id call failed.", GetErrorMessage(r)); + SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] msg_get_message by messageid failed.", GetErrorMessage(r)); // get text - messages_get_text(msg, &pOriginalText); - SysTryCatch(NID_MSG, pOriginalText != null, r = E_SYSTEM, r, "sms get message body failed"); - - // convert to const char* type - pBodyText = const_cast(pOriginalText); + err = msg_get_str_value(smsMsg, MSG_MESSAGE_SMS_DATA_STR, msgText, MAX_MSG_TEXT_LEN); + SysTryCatch(NID_MSG, err == MSG_SUCCESS, r = E_SYSTEM, r, "sms get message body failed"); - // convert to SmsMessage type - fullText = String(pBodyText); + fullText = msgText; SysLog(NID_MSG, "Returned Full Text : [%ls]", fullText.GetPointer()); - free(pOriginalText); - pOriginalText = null; - pBodyText = null; - - messages_destroy_message(msg); + msg_release_struct(&sendOpt); + msg_release_struct(&smsMsg); return fullText; CATCH: - messages_destroy_message(msg); + msg_release_struct(&sendOpt); + msg_release_struct(&smsMsg); return L""; } @@ -682,32 +710,58 @@ _SmsManagerImpl::Send(const SmsMessage& message, const RecipientList& recipientL SysAssertf(__msgHandle > 0, "message handle is invalid."); result r = E_SUCCESS; - messages_message_h smsMsg = {0}; - int err = MESSAGES_ERROR_NONE; + int err = MSG_SUCCESS; + int msgReqId = -1; bool saveMsgToSentbox = saveToSentbox; SysLog(NID_MSG, "sending an sms message"); - err = _MsgUtil::GetSmsMessage(message, recipientList, smsMsg); + msg_struct_t msgReq = msg_create_struct(MSG_STRUCT_REQUEST_INFO); + msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);; + msg_struct_t msgSendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); + + msg_set_bool_value(msgSendOpt, MSG_SEND_OPT_SETTING_BOOL, true); + msg_set_bool_value(msgSendOpt, MSG_SEND_OPT_DELIVER_REQ_BOOL, false); + msg_set_bool_value(msgSendOpt, MSG_SEND_OPT_KEEPCOPY_BOOL, saveMsgToSentbox); - if (err == MESSAGES_ERROR_NONE) + err = _MsgUtil::GetSmsMessage(msgInfo, message, recipientList); + + r = ConvertException(err); + SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to generate the SMS message.", GetErrorMessage(r)); + + msg_set_struct_handle(msgReq, MSG_REQUEST_MESSAGE_HND, msgInfo); + msg_set_struct_handle(msgReq, MSG_REQUEST_SENDOPT_HND, msgSendOpt); + + if (err == MSG_SUCCESS) { - err = messages_send_message(__msgHandle, smsMsg, saveMsgToSentbox, - &_SmsMmsCallbackHandler::SentSmsMessageStatusCallback, (void*) (__pSmsEvent.get())); + err = msg_sms_send_message(__msgHandle, msgReq); } r = ConvertException(err); + if (r == E_SUCCESS) + { + if (_SmsMmsCallbackHandler::GetInstance()) + { + msg_get_int_value(msgReq, MSG_REQUEST_REQUESTID_INT, &msgReqId); + r = _SmsMmsCallbackHandler::GetInstance()->AddToMessageMap(msgReqId, _MSG_SMS, __pSmsEvent.get()); + } + else + { + r = E_SYSTEM; + } + } + SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to send the SMS message.", GetErrorMessage(r)); //release message - messages_destroy_message(smsMsg); + msg_release_struct(&msgReq); SysLog(NID_MSG, "sending an sms message success"); return r; CATCH: //release message - messages_destroy_message(smsMsg); + msg_release_struct(&msgReq); return r; } @@ -718,7 +772,7 @@ _SmsManagerImpl::SetCbsMessageEventListener(ICbsMessageEventListener* pListener) SysAssertf(__msgHandle > 0, "message handle is invalid."); result r = E_SUCCESS; - int err = MESSAGES_ERROR_NONE; + int err = MSG_SUCCESS; if (!pListener) { @@ -749,9 +803,21 @@ _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 = messages_cb_set_incoming_cb(__msgHandle, __isCbsSaveEnabled, - &_SmsMmsCallbackHandler::IncomingCbsMessageCallback, (void*) __pCbsReceiveEvent); - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "Failed to set cbs incoming callback"); + err = msg_reg_cb_message_callback(__msgHandle, &_SmsMmsCallbackHandler::IncomingCbsMessageCallback, __isCbsSaveEnabled, null); + r = ConvertException(err); + 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; + } + } return r; @@ -773,7 +839,7 @@ _SmsManagerImpl::SetEtwsPrimaryNotificationEventListener(IEtwsPrimaryNotificatio SysAssertf(__msgHandle > 0, "message handle is invalid."); result r = E_SUCCESS; - int err = MESSAGES_ERROR_NONE; + int err = MSG_SUCCESS; if (!pListener) { @@ -805,9 +871,21 @@ _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 = messages_cb_set_etws_primary_noti_cb(__msgHandle, &_SmsMmsCallbackHandler::IncomingEtwsMessageCallback, (void*)__pEtwsReceiveEvent); - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, 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, 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; + } + } return r; @@ -829,11 +907,10 @@ _SmsManagerImpl::SetSavingToCbsBoxEnabled(bool enable) SysAssertf(__msgHandle > 0, "message handle is invalid."); SysTryReturnResult(NID_MSG, __cbsSettingsHandle != NULL, E_SYSTEM, "Cb handle is null"); - int err = MESSAGES_ERROR_NONE; + int err = MSG_SUCCESS; - err = messages_cb_set_incoming_cb(__msgHandle, enable, - &_SmsMmsCallbackHandler::IncomingCbsMessageCallback, (void*)__pCbsReceiveEvent); - SysTryReturnResult(NID_MSG, err == MESSAGES_ERROR_NONE, E_SYSTEM, "Failed to set SavingToCbsBoxEnabled option."); + err = msg_reg_cb_message_callback(__msgHandle, &_SmsMmsCallbackHandler::IncomingCbsMessageCallback, enable, null); + SysTryReturnResult(NID_MSG, err == MSG_SUCCESS, E_SYSTEM, "Failed to set SavingToCbsBoxEnabled option."); __isCbsSaveEnabled = enable; @@ -848,10 +925,10 @@ _SmsManagerImpl::IsCbsEnabled(void) const SysTryReturn(NID_MSG, __cbsSettingsHandle != NULL, false, E_SYSTEM, "Cb handle is null"); bool isCbsEnabled = false; - int err = MESSAGES_ERROR_NONE; + int err = MSG_SUCCESS; - err = messages_cb_settings_is_enabled(__cbsSettingsHandle, &isCbsEnabled); - SysTryReturn(NID_MSG, err == MESSAGES_ERROR_NONE, false, E_SYSTEM, "Failed to set SavingToCbsBoxEnabled option."); + err = msg_get_bool_value(__cbsSettingsHandle, MSG_CB_RECEIVE_BOOL, &isCbsEnabled); + SysTryReturn(NID_MSG, err == MSG_SUCCESS, false, E_SYSTEM, "Failed to set SavingToCbsBoxEnabled option."); return isCbsEnabled; } @@ -863,13 +940,14 @@ _SmsManagerImpl::SetCbsEnabled(bool enable) SysAssertf(__msgHandle > 0, "message handle is invalid."); SysTryReturnResult(NID_MSG, __cbsSettingsHandle != NULL, E_SYSTEM, "Cb handle is null"); - int err = MESSAGES_ERROR_NONE; + int err = MSG_SUCCESS; + result r = E_SUCCESS; - err = messages_cb_settings_set_enabled(__cbsSettingsHandle, enable); - SysTryReturnResult(NID_MSG, err == MESSAGES_ERROR_NONE, E_SYSTEM, "Failed to set cbs enabled."); + err = msg_set_bool_value(__cbsSettingsHandle, MSG_CB_RECEIVE_BOOL, enable); + SysTryReturnResult(NID_MSG, err == MSG_SUCCESS, E_SYSTEM, "Failed to set cbs enabled."); - err = messages_cb_save_settings(__msgHandle, __cbsSettingsHandle); - SysTryReturnResult(NID_MSG, err == MESSAGES_ERROR_NONE, E_SYSTEM, "Failed to save cbs settings."); + r = _SmsMmsCallbackHandler::GetInstance()->SaveCbsSettings(); + SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "Failed to save cbs settings."); return E_SUCCESS; } @@ -882,48 +960,21 @@ _SmsManagerImpl::AddCbsChannel(int from, int to, Tizen::Base::String& name, bool SysTryReturnResult(NID_MSG, __cbsSettingsHandle != NULL, E_SYSTEM, "Cb handle is null"); result r = E_SUCCESS; - int err = MESSAGES_ERROR_NONE; - messages_cb_channel_h cbsChannel = {0}; - std::unique_ptr pChannelName; + int count = 0; - // create a channel - err = messages_cb_create_channel(&cbsChannel); - SysTryReturnResult(NID_MSG, err == MESSAGES_ERROR_NONE, E_SYSTEM, "Failed to create a channel."); + r = _SmsMmsCallbackHandler::GetInstance()->GetCbsChannelsCount(count); + SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to get CB Channel count."); - // set channel ids - err = messages_cb_channel_set_id(cbsChannel, from, to); - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = ConvertException(err), r, "Failed to set channel ids."); - - // set channel name - pChannelName.reset(_StringConverter::CopyToCharArrayN(name)); - SysTryCatch(NID_MSG, pChannelName != null, r = E_OUT_OF_MEMORY, r, "Memory allocation failed."); - - err = messages_cb_channel_set_name(cbsChannel, pChannelName.get()); - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = ConvertException(err), r, "Failed to set channel name."); - - // activate - err = messages_cb_channel_set_activated(cbsChannel, activate); - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = ConvertException(err), r, "Failed to activate the channel."); + if (CB_CHANNEL_MAX <= count) + { + return E_ALREADY_SET; + } // add channel - err = messages_cb_settings_add_channel(__cbsSettingsHandle, cbsChannel); - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = ConvertException(err), r, "Failed to add the channel."); - - // save the setting - err = messages_cb_save_settings(__msgHandle, __cbsSettingsHandle); - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = ConvertException(err), r, "Failed to save the setting."); - - // destroy the channel - err = messages_cb_destroy_channel(cbsChannel); - SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = ConvertException(err), r, "Failed to destroy the channel."); + r = _SmsMmsCallbackHandler::GetInstance()->AddCbsChannel(from, to, name, activate); + SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to add a CB Channel."); return r; - -CATCH: - messages_cb_settings_remove_channel(__cbsSettingsHandle, cbsChannel); - messages_cb_save_settings(__msgHandle, __cbsSettingsHandle); - messages_cb_destroy_channel(cbsChannel); - return r; } result @@ -934,48 +985,10 @@ _SmsManagerImpl::RemoveCbsChannel(int from, int to) SysTryReturnResult(NID_MSG, __cbsSettingsHandle != NULL, E_SYSTEM, "Cb handle is null"); result r = E_SUCCESS; - int err = MESSAGES_ERROR_NONE; - int cbChannelCount = 0; - int fromId = 0; - int toId = 0; - bool channelFound = false; - messages_cb_channel_h cbsChannel = {0}; - - err = messages_cb_settings_get_channel_count(__cbsSettingsHandle, &cbChannelCount); - r = ConvertException(err); - SysTryReturnResult(NID_MSG, err == MESSAGES_ERROR_NONE, r, "Failed to get channel count."); - - for (int index = 0; index < cbChannelCount; index++) - { - if ((err = messages_cb_settings_get_channel(__cbsSettingsHandle, index, &cbsChannel)) == MESSAGES_ERROR_NONE) - { - if ((err = messages_cb_channel_get_id(cbsChannel, &fromId, &toId)) == MESSAGES_ERROR_NONE) - { - if (from == fromId && to == toId) - { - channelFound = true; - break; // found channel to be removed. - } - } - } - } - - SysTryReturnResult(NID_MSG, channelFound, E_OBJ_NOT_FOUND, "channel not found"); // remove channel - err = messages_cb_settings_remove_channel(__cbsSettingsHandle, cbsChannel); - r = ConvertException(err); - SysTryReturnResult(NID_MSG, err == MESSAGES_ERROR_NONE, r, "Failed to remove the channel. (from:%d, to:%d)", from, to); - - // destroy channel - err = messages_cb_destroy_channel(cbsChannel); - r = ConvertException(err); - SysTryReturnResult(NID_MSG, err == MESSAGES_ERROR_NONE, r, "Failed to destroy the channel."); - - // save the status - err = messages_cb_save_settings(__msgHandle, __cbsSettingsHandle); - r = ConvertException(err); - SysTryReturnResult(NID_MSG, err == MESSAGES_ERROR_NONE, r, "Failed to save the setting."); + r = _SmsMmsCallbackHandler::GetInstance()->RemoveCbsChannel(from, to); + SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to remove a CB Channel."); return r; } @@ -988,51 +1001,30 @@ _SmsManagerImpl::GetCbsChannelN(int from, int to) const SysTryReturn(NID_MSG, __cbsSettingsHandle != null, null, E_SYSTEM, "Cb handle is null."); result r = E_SUCCESS; - int err = MESSAGES_ERROR_NONE; - int cbChannelCount = 0; int fromId = 0; int toId = 0; - bool channelFound = false; - char* pTempChannelName = null; - std::unique_ptr pChannelName; - messages_cb_channel_h cbsChannel = {0}; + int index = 0; + bool isActive = false; + String channelName; std::unique_ptr pCbsChannel; ClearLastResult(); - err = messages_cb_settings_get_channel_count(__cbsSettingsHandle, &cbChannelCount); - r = ConvertException(err); - SysTryReturn(NID_MSG, err == MESSAGES_ERROR_NONE, null, r, "Failed to get channel count."); - - for (int index = 0; index < cbChannelCount; index++) - { - if ((err = messages_cb_settings_get_channel(__cbsSettingsHandle, index, &cbsChannel)) == MESSAGES_ERROR_NONE) - { - if ((err = messages_cb_channel_get_id(cbsChannel, &fromId, &toId)) == MESSAGES_ERROR_NONE) - { - if (from == fromId && to == toId) - { - channelFound = true; - break; // found channel. - } - } - } - } - - SysTryReturn(NID_MSG, channelFound, null, E_OBJ_NOT_FOUND, "Failed to find the cb channel"); - - err = messages_cb_channel_get_name(cbsChannel, &pTempChannelName); - r = ConvertException(err); - SysTryReturn(NID_MSG, err == MESSAGES_ERROR_NONE, null, r, "Failed to get the channel name."); - SysTryReturn(NID_MSG, pTempChannelName != null, null, r, "Failed to get the channel name."); - pChannelName.reset(pTempChannelName); + // 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 - pCbsChannel.reset(_CbsChannelImpl::GetCbsChannelN(from, to, String(pChannelName.release()))); - SysTryReturn(NID_MSG, pCbsChannel != null, null, r, "Failed to get the channel."); + r = _SmsMmsCallbackHandler::GetInstance()->GetCbsChannel(index, fromId, toId, channelName, isActive); + SysTryReturn(NID_MSG, r == E_SUCCESS, null, r, "Failed to get the cb channel."); - // set cbs handle - _CbsChannelImpl::GetInstance(*pCbsChannel)->SetCbsChannelHandle(cbsChannel); + // creates channel + pCbsChannel.reset(_CbsChannelImpl::GetCbsChannelN(fromId, toId, channelName)); + + if (isActive) + { + pCbsChannel->Activate(); + } return pCbsChannel.release(); } @@ -1046,13 +1038,11 @@ _SmsManagerImpl::GetCbsChannelListN(void) result r = E_SUCCESS; unique_ptr pList; - int err = MESSAGES_ERROR_NONE; int cbChannelCount = 0; int fromId = 0; int toId = 0; - unique_ptr pChannelName; - char* pTempChannelName = null; - messages_cb_channel_h cbsChannel = {0}; + bool isActive = false; + String channelName; std::unique_ptr pCbsChannel; ClearLastResult(); @@ -1064,36 +1054,24 @@ _SmsManagerImpl::GetCbsChannelListN(void) r = pList->Construct(); SysTryReturn(NID_MSG, r == E_SUCCESS, null, r, "Failed to construct array list."); - err = messages_cb_settings_get_channel_count(__cbsSettingsHandle, &cbChannelCount); - SysTryReturn(NID_MSG, r == E_SUCCESS, null, r, "Failed to get channel count."); + 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++) { - if ((err = messages_cb_settings_get_channel(__cbsSettingsHandle, index, &cbsChannel)) == MESSAGES_ERROR_NONE) + // 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."); + + pCbsChannel.reset(_CbsChannelImpl::GetCbsChannelN(fromId, toId, channelName)); + if (pCbsChannel && isActive) { - if ((err = messages_cb_channel_get_id(cbsChannel, &fromId, &toId)) == MESSAGES_ERROR_NONE) - { - if ((err = messages_cb_channel_get_name(cbsChannel, &pTempChannelName)) == MESSAGES_ERROR_NONE) - { - if (pTempChannelName) - { - pChannelName.reset(pTempChannelName); - pCbsChannel.reset(_CbsChannelImpl::GetCbsChannelN(fromId, toId, String(pChannelName.release()))); - } - - if (pCbsChannel) - { - _CbsChannelImpl::GetInstance(*pCbsChannel)->SetCbsChannelHandle(cbsChannel); - // add to the list - pList->Add(*pCbsChannel); - } - } - } + _CbsChannelImpl::GetInstance(*pCbsChannel)->SetCbsChannelState(isActive); + // add to the list + pList->Add(*pCbsChannel); } } - SysTryReturn(NID_MSG, err == MESSAGES_ERROR_NONE, null, E_SYSTEM, "Failed to GetCbsChannelListN."); - return pList.release(); } @@ -1116,37 +1094,32 @@ _SmsManagerImpl::ConvertException(int err) const switch (err) { - case MESSAGES_ERROR_NONE: + case MSG_SUCCESS: r = E_SUCCESS; break; - case MESSAGES_ERROR_INVALID_PARAMETER: + case MSG_ERR_INVALID_PARAMETER: + case MSG_ERR_INVALID_MESSAGE: + case MSG_ERR_NULL_POINTER: + case MSG_ERR_NULL_MESSAGE: r = E_INVALID_ARG; break; - case MESSAGES_ERROR_NO_DATA: - r = E_OBJ_NOT_FOUND; - break; - - case MESSAGES_ERROR_OUT_OF_MEMORY: + case MSG_ERR_MEMORY_ERROR: r = E_OUT_OF_MEMORY; break; - case MESSAGES_ERROR_SERVER_NOT_READY: // Communication error between client and server - case MESSAGES_ERROR_COMMUNICATION_WITH_SERVER_FAILED: + case MSG_ERR_SERVER_NOT_READY: + case MSG_ERR_TRANSPORT_ERROR: + case MSG_ERR_COMMUNICATION_ERROR: r = E_NETWORK_UNAVAILABLE; break; - case MESSAGES_ERROR_NO_SIM_CARD: + case MSG_ERR_NO_SIM: r = E_DEVICE_UNAVAILABLE; break; - case MESSAGES_ERROR_OUT_OF_RANGE: - r = E_ALREADY_SET; - break; - - case MESSAGES_ERROR_SENDING_FAILED: - case MESSAGES_ERROR_OPERATION_FAILED: + case MSG_ERR_PLUGIN_TAPI_FAILED: r = E_FAILURE; break; diff --git a/src/FMsg_SmsManagerImpl.h b/src/FMsg_SmsManagerImpl.h index 2178018..9471581 100644 --- a/src/FMsg_SmsManagerImpl.h +++ b/src/FMsg_SmsManagerImpl.h @@ -294,7 +294,7 @@ public: * @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 (900). + * The range (@c to - @c from) exceeds the limit (0xFFFF). * The specified @c name string length is greater than @c 32. @n * @exception E_ALREADY_SET The channel range (@c from ~ @c to) is already set. * @exception E_ILLEGAL_ACCESS The application does not have the permission to add the CBS channel. @@ -313,7 +313,7 @@ public: * @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 (900). + * The range (@c to - @c from) exceeds the limit (0xFFFF). * @exception E_OBJ_NOT_FOUND The channel range (@c from ~ @c to) is not found. * @exception E_ILLEGAL_ACCESS The application does not have the permission to remove the CBS channel. * @exception E_SYSTEM A system error has occurred. @@ -331,7 +331,7 @@ public: * @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 (900). + * The range (@c to - @c from) exceeds the limit (0xFFFF). * @exception E_SYSTEM A system error has occurred. * @remarks The specific error code can be accessed using the GetLastResult() method. * @see AddCbsChannel(), RemoveCbsChannel() @@ -378,8 +378,8 @@ private: _SmsEvent* __pCbsReceiveEvent; _SmsEvent* __pEtwsReceiveEvent; Tizen::Base::Collection::ArrayList* __pSmsTriggerEventList; - messages_service_h __msgHandle; - messages_cb_settings_h __cbsSettingsHandle; + msg_handle_t __msgHandle; + msg_struct_t __cbsSettingsHandle; ICbsMessageEventListener* __pCbsListener; IEtwsPrimaryNotificationEventListener* __pEtwsListener; }; // _SmsManagerImpl diff --git a/src/FMsg_SmsMmsCallbackHandler.cpp b/src/FMsg_SmsMmsCallbackHandler.cpp index 9d44b41..450a8ab 100644 --- a/src/FMsg_SmsMmsCallbackHandler.cpp +++ b/src/FMsg_SmsMmsCallbackHandler.cpp @@ -21,17 +21,23 @@ * This file contains the implementation of the %_SmsMmsCallbackHandler class. */ -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include +#include #include "FMsg_SmsEvent.h" #include "FMsg_SmsEventArg.h" #include "FMsg_MmsEvent.h" #include "FMsg_MmsEventArg.h" #include "FMsg_MsgUtil.h" #include "FMsg_SmsMmsCallbackHandler.h" +#include "FMsg_CbsChannelImpl.h" using namespace Tizen::Base; using namespace Tizen::Base::Collection; @@ -45,39 +51,93 @@ _SmsMmsCallbackHandler* _SmsMmsCallbackHandler::__pMessageCallbackHandler = 0; _SmsMmsCallbackHandler::_SmsMmsCallbackHandler(void) : __msgHandle(0) , __cbsSettingsHandle(0) + , __pCbsChannelList(0) + , __pTempCbsChannelList(0) + , __callbackRegistered(false) + , __incomingSmsCallbackRegistered(true) + , __pCbsUserEvent(null) + , __pEtwsUserEvent(null) { +} + +result +_SmsMmsCallbackHandler::Construct() +{ + result r = E_SUCCESS; + + r = __messageMap.Construct(); + if (r == E_SUCCESS) + { + r = __msgMutex.Create(); + } + + return r; } _SmsMmsCallbackHandler::~_SmsMmsCallbackHandler(void) { if (__msgHandle) { - messages_close_service(__msgHandle); + msg_close_msg_handle(&__msgHandle); __msgHandle = 0; } + if (__messageMap.GetCount()) + { + __messageMap.RemoveAll(true); + } + + if (__cbsSettingsHandle) + { + msg_release_struct(&__cbsSettingsHandle); + __cbsSettingsHandle = 0; + } + + if (__pTempCbsChannelList) + { + if (__pTempCbsChannelList->GetCount() > 0) + { + __pTempCbsChannelList->RemoveAll(true); + } + delete __pTempCbsChannelList; + __pTempCbsChannelList = null; + } } _SmsMmsCallbackHandler* _SmsMmsCallbackHandler::GetInstance(void) { + result r = E_SUCCESS; + if (!__pMessageCallbackHandler) { __pMessageCallbackHandler = new (std::nothrow) _SmsMmsCallbackHandler(); + SysTryReturn(NID_MSG, __pMessageCallbackHandler != NULL, null, E_SYSTEM, "failed to create instance"); + + if (__pMessageCallbackHandler) + { + r = __pMessageCallbackHandler->Construct(); + + if (r != E_SUCCESS) + { + delete __pMessageCallbackHandler; + __pMessageCallbackHandler = 0; + } + } } return __pMessageCallbackHandler; } int -_SmsMmsCallbackHandler::OpenMessageHandle(messages_service_h& messageHandle) +_SmsMmsCallbackHandler::OpenMessageHandle(msg_handle_t& messageHandle) { - int err = MESSAGES_ERROR_NONE; + int err = MSG_SUCCESS; if (!__msgHandle) { - err = messages_open_service(&__msgHandle); + err = msg_open_msg_handle(&__msgHandle); } messageHandle = __msgHandle; @@ -85,220 +145,706 @@ _SmsMmsCallbackHandler::OpenMessageHandle(messages_service_h& messageHandle) } int -_SmsMmsCallbackHandler::OpenCbsSettingsHandle(messages_cb_settings_h& cbsSettingsHandle) +_SmsMmsCallbackHandler::OpenCbsSettingsHandle(msg_struct_t& cbsSettingsHandle) { - int err = MESSAGES_ERROR_NONE; + int err = MSG_SUCCESS; if (!__cbsSettingsHandle) { - err = messages_cb_load_settings(__msgHandle, &__cbsSettingsHandle); + __cbsSettingsHandle = msg_create_struct(MSG_STRUCT_SETTING_CB_OPT); + if (__cbsSettingsHandle && __msgHandle) + { + err = msg_get_cb_opt(__msgHandle, __cbsSettingsHandle); + } } cbsSettingsHandle = __cbsSettingsHandle; return err; } -int -_SmsMmsCallbackHandler::CloseMessageHandle() +result +_SmsMmsCallbackHandler::AddCbsChannel(int from, int to, Tizen::Base::String& name, bool activate) { - int err = MESSAGES_ERROR_NONE; + int err = MSG_SUCCESS; + result r = E_SUCCESS; + CbsChannel* pCbsChannel = NULL; - if (__msgHandle) + pCbsChannel = _CbsChannelImpl::GetCbsChannelN(from, to, name); + SysTryReturn(NID_MSG, pCbsChannel != null, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel."); + + if (activate) { - err = messages_close_service(__msgHandle); - __msgHandle = 0; + _CbsChannelImpl::GetInstance(*pCbsChannel)->SetCbsChannelState(activate); } - return err; + r =__pTempCbsChannelList->Add(*pCbsChannel); + + err = SaveCbsSettings(); + r = ConvertException(err); + + return r; } -void -_SmsMmsCallbackHandler::SentSmsMessageStatusCallback(messages_sending_result_e status, void* pUserEvent) +result +_SmsMmsCallbackHandler::RemoveCbsChannel(int from, int to) { + int err = MSG_SUCCESS; result r = E_SUCCESS; - _SmsEvent* pSmsEvent = static_cast <_SmsEvent*>(pUserEvent); - _SmsEventArg* pSmsEventArg = null; + int fromId = 0; + int toId = 0; + bool channelFound = false; + CbsChannel* pCbsChannel = NULL; + + for (int index = 0; index < __pTempCbsChannelList->GetCount(); index++) + { + pCbsChannel = dynamic_cast< Tizen::Messaging::CbsChannel* >(__pTempCbsChannelList->GetAt(index)); + SysTryReturn(NID_MSG, pCbsChannel != null, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel."); + + pCbsChannel->GetRange(fromId, toId); + if (from == fromId && to == toId) + { + channelFound = true; // found channel to be removed. + __pTempCbsChannelList->RemoveAt(index); - SysLog(NID_MSG, "SMS message sent status[%d]", status); + err = SaveCbsSettings(); + r = ConvertException(err); + delete pCbsChannel; + break; + } + } - switch (status) + if (!channelFound) { - case MESSAGES_SENDING_SUCCEEDED: // Message is sent successfully - SysLog(NID_MSG, "MESSAGES_SENDING_SUCCEEDED -> E_SUCCESS"); - r = E_SUCCESS; - break; + return E_OBJ_NOT_FOUND; + } - case MESSAGES_SENDING_FAILED: // Message is not sending - SysLog(NID_MSG, "MESSAGES_SENDING_FAILED -> E_FAILURE"); - r = E_FAILURE; - SysLog(NID_MSG, "Failed to send the SMS message. error cause: Message is not sending"); - break; + return r; +} - default: - SysLog(NID_MSG, "default -> E_FAILURE"); - r = E_FAILURE; - SysLog(NID_MSG, "Failed to send the SMS message. error cause: Unknown"); - break; +result +_SmsMmsCallbackHandler::SearchCbsChannel(int from, int to, int& index) +{ + result r = E_SUCCESS; + int fromId = 0; + int toId = 0; + bool channelFound = false; + CbsChannel* pCbsChannel = NULL; + + for (int tempIndex = 0; tempIndex < __pTempCbsChannelList->GetCount(); tempIndex++) + { + pCbsChannel = dynamic_cast< Tizen::Messaging::CbsChannel* >(__pTempCbsChannelList->GetAt(tempIndex)); + SysTryReturn(NID_MSG, pCbsChannel != null, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel."); + + pCbsChannel->GetRange(fromId, toId); + if (from == fromId && to == toId) + { + channelFound = true; + index = tempIndex; + break; // found channel to be searched. + } } - if (pSmsEvent) + if (!channelFound) { - pSmsEventArg = new (std::nothrow) _SmsEventArg(r); - if (pSmsEventArg) + return E_OBJ_NOT_FOUND; + } + + return r; +} + +result +_SmsMmsCallbackHandler::UpdateCbsChannel(int from, int to, Tizen::Base::String name, bool activate) +{ + int err = MSG_SUCCESS; + result r = E_SUCCESS; + int fromId = 0; + int toId = 0; + bool channelFound = false; + CbsChannel* pCbsChannel = NULL; + + for (int index = 0; index < __pTempCbsChannelList->GetCount(); index++) + { + pCbsChannel = dynamic_cast< Tizen::Messaging::CbsChannel* >(__pTempCbsChannelList->GetAt(index)); + SysTryReturn(NID_MSG, pCbsChannel != null, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel."); + + pCbsChannel->GetRange(fromId, toId); + if (from == fromId && to == toId) { - pSmsEvent->Fire(*pSmsEventArg); + channelFound = true; + break; // found channel to be updated. + } + } + + if (!channelFound) + { + return E_OBJ_NOT_FOUND; + } + + // set cbs channel name + _CbsChannelImpl::GetInstance(*pCbsChannel)->SetCbsChannelName(name); + + if (activate) + { + _CbsChannelImpl::GetInstance(*pCbsChannel)->SetCbsChannelState(activate); + } + else + { + _CbsChannelImpl::GetInstance(*pCbsChannel)->SetCbsChannelState(false); + } + + err = SaveCbsSettings(); + r = ConvertException(err); + return r; +} + +result +_SmsMmsCallbackHandler::GetCbsChannel(int index, int& from, int& to, Tizen::Base::String& name, bool& activate) +{ + result r = E_SUCCESS; + CbsChannel* pCbsChannel = NULL; + + pCbsChannel = dynamic_cast< Tizen::Messaging::CbsChannel* >(__pTempCbsChannelList->GetAt(index)); + SysTryReturn(NID_MSG, pCbsChannel != null, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel."); + + pCbsChannel->GetRange(from, to); + name = pCbsChannel->GetName(); + if (pCbsChannel->IsActivated()) + { + activate = true; + } + else + { + activate = false; + } + return r; +} + +result +_SmsMmsCallbackHandler::GetCbsChannelsCount(int& count) +{ + result r = E_SUCCESS; + + if (__pTempCbsChannelList) + { + count = __pTempCbsChannelList->GetCount(); + } + + return r; +} + +result +_SmsMmsCallbackHandler::SaveCbsSettings() +{ + int err = MSG_SUCCESS; + result r = E_SUCCESS; + int fromId = 0; + int toId = 0; + bool isChannelActive = false; + String channelName; + char* pTempChannelName = null; + + SysTryReturn(NID_MSG, __pTempCbsChannelList != null, r = E_SYSTEM, E_SYSTEM, "Failed to save the channel."); + err = msg_get_list_handle(__cbsSettingsHandle, MSG_CB_CHANNEL_LIST_STRUCT, (void **)&__pCbsChannelList); + + // save Channel List + for (int index = 0; index < __pTempCbsChannelList->GetCount(); index++) + { + Tizen::Messaging::CbsChannel* pCbsChannel = dynamic_cast< Tizen::Messaging::CbsChannel* >(__pTempCbsChannelList->GetAt(index)); + SysTryReturn(NID_MSG, pCbsChannel != null, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel."); + pCbsChannel->GetRange(fromId, toId); + channelName = pCbsChannel->GetName(); + if (pCbsChannel->IsActivated()) + { + isChannelActive = true; + } + + pTempChannelName = _StringConverter::CopyToCharArrayN(channelName); + SysTryReturn(NID_MSG, pTempChannelName != null, r = E_OUT_OF_MEMORY, r, "Memory allocation failed."); + + msg_set_bool_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_ACTIVATE_BOOL, isChannelActive); + msg_set_int_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_ID_FROM_INT, fromId); + msg_set_int_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_ID_TO_INT, toId); + msg_set_str_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_NAME_STR, + pTempChannelName,CB_CHANNEL_NAME_MAX); + + if (pTempChannelName) + { + delete[] pTempChannelName; + pTempChannelName = null; } } + + err = msg_set_cb_opt(__msgHandle, __cbsSettingsHandle); + r = ConvertException(err); + return r; } -void -_SmsMmsCallbackHandler::SentMmsMessageStatusCallback(messages_sending_result_e status, void* pUserEvent) +result +_SmsMmsCallbackHandler::LoadCbsSettings() { + int err = MSG_SUCCESS; result r = E_SUCCESS; - _MmsEvent* pMmsEvent = static_cast <_MmsEvent*>(pUserEvent); - _MmsEventArg* pMmsEventArg = null; + CbsChannel* pCbsChannel = NULL; + int fromId = 0; + int toId = 0; + bool isChannelActive = false; + char channelName[CB_CHANNEL_NAME_MAX + 1] = {0,}; - SysLog(NID_MSG, "MMS message sent status[%d]", status); + __pTempCbsChannelList = new (std::nothrow) ArrayList(); + SysTryCatch(NID_MSG, __pTempCbsChannelList != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed"); - switch (status) + // make a list + r = __pTempCbsChannelList->Construct(); + SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "Failed to construct an ArrayList"); + + if (__cbsSettingsHandle) { - case MESSAGES_SENDING_SUCCEEDED: // Message is sent successfully - SysLog(NID_MSG, "MESSAGES_SENDING_SUCCEEDED -> E_SUCCESS"); - r = E_SUCCESS; - break; + // Load Channel List + err = msg_get_list_handle(__cbsSettingsHandle, MSG_CB_CHANNEL_LIST_STRUCT, (void **)&__pCbsChannelList); + for (int index = 0; index < __pCbsChannelList->nCount; index++) + { + msg_get_bool_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_ACTIVATE_BOOL, &isChannelActive); + msg_get_int_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_ID_FROM_INT, &fromId); + msg_get_int_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_ID_TO_INT, &toId); + msg_get_str_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_NAME_STR, + channelName,CB_CHANNEL_NAME_MAX); + + pCbsChannel = _CbsChannelImpl::GetCbsChannelN(fromId, toId, String(channelName)); + SysTryCatch(NID_MSG, pCbsChannel != null, r = E_SYSTEM, r, "Failed to get the channel."); + if (isChannelActive) + { + _CbsChannelImpl::GetInstance(*pCbsChannel)->SetCbsChannelState(isChannelActive); + } + __pTempCbsChannelList->Add(*pCbsChannel); + } + } - case MESSAGES_SENDING_FAILED: // Message is not sending - SysLog(NID_MSG, "MESSAGES_SENDING_SUCCEEDED -> E_FAILURE"); - r = E_FAILURE; - break; + r = ConvertException(err); + return r; - default: - SysLog(NID_MSG, "default -> E_FAILURE"); - r = E_FAILURE; - break; +CATCH: + if (__pTempCbsChannelList) + { + if (__pTempCbsChannelList->GetCount() > 0) + { + __pTempCbsChannelList->RemoveAll(true); + } + delete __pTempCbsChannelList; + __pTempCbsChannelList = null; + } + + return r; +} + +int +_SmsMmsCallbackHandler::RegisterMessageCallback() +{ + int err = MSG_SUCCESS; + + if (__msgHandle && !__callbackRegistered) + { + err = msg_reg_sent_status_callback(__msgHandle, &_SmsMmsCallbackHandler::SentMessageStatusCallback, null); + __callbackRegistered = true; + } + + return err; +} + +int +_SmsMmsCallbackHandler::CloseMessageHandle() +{ + int err = MSG_SUCCESS; + + if (__msgHandle) + { + err = msg_close_msg_handle(&__msgHandle); + __msgHandle = 0; + } + + return err; +} + +int +_SmsMmsCallbackHandler::CloseCbsSettingsHandle() +{ + int err = MSG_SUCCESS; + + if (__cbsSettingsHandle) + { + err = msg_release_struct(&__cbsSettingsHandle); + __cbsSettingsHandle = 0; } - if (pMmsEvent) + if (__pTempCbsChannelList) { - pMmsEventArg = new (std::nothrow) _MmsEventArg(r); - if (pMmsEventArg) + if (__pTempCbsChannelList->GetCount() > 0) { - pMmsEvent->Fire(*pMmsEventArg); + __pTempCbsChannelList->RemoveAll(true); } + delete __pTempCbsChannelList; + __pTempCbsChannelList = null; } + + return err; } void -_SmsMmsCallbackHandler::IncomingSmsMessageCallback(messages_message_h incomingMsg, void* pUserParam) +_SmsMmsCallbackHandler::SetInComingSmsCallback(bool incomingSmsCallbackRegistered) { - _SmsEvent* pSmsEvent = static_cast <_SmsEvent*>(pUserParam); - _SmsEventArg* pSmsEventArg = null; - char* pMsgBody = null; - char* pMsgAddress = null; - time_t tempReceivedTime = 0; - int port = 0; - DateTime receivedTime; - messages_recipient_type_e recipientType = MESSAGES_RECIPIENT_TO; + __incomingSmsCallbackRegistered = incomingSmsCallbackRegistered; +} + +void +_SmsMmsCallbackHandler::SetCbsAndEtwsUserEvent(_MessageType msgType, Tizen::Base::Object* pEvent) +{ + if (msgType == _MSG_CBS) + { + __pCbsUserEvent = pEvent; + } + else + { + __pEtwsUserEvent = pEvent; + } +} - messages_get_text(incomingMsg, &pMsgBody); - messages_get_time(incomingMsg, &tempReceivedTime); // get msg time - messages_get_message_port(incomingMsg, &port); // get port number - messages_get_address(incomingMsg, 0, &pMsgAddress, &recipientType); +result +_SmsMmsCallbackHandler::AddToMessageMap(int reqId, _MessageType msgType, Tizen::Base::Object* pEvent) +{ + result r = E_SUCCESS; - String message(pMsgBody); // porting char* to String - String senderAddress(pMsgAddress); + Integer* pReqId = new (std::nothrow) Integer(reqId); + SysTryReturn(NID_MSG, pReqId != null, E_OUT_OF_MEMORY, r = E_OUT_OF_MEMORY, "memory allocation failed."); + Integer* pMsgType = new (std::nothrow) Integer(msgType); + SysTryReturn(NID_MSG, pMsgType != null, E_OUT_OF_MEMORY, r = E_OUT_OF_MEMORY, "memory allocation failed."); - receivedTime = _MsgUtil::ConvertTime(&tempReceivedTime); + __msgMutex.Acquire(); - SysLog(NID_MSG, "incoming sms msg_body: [%s]", pMsgBody); - SysLog(NID_MSG, "incoming sms port: [%d]", port); - SysLog(NID_MSG, "incoming sms received time: [%s]", ctime(&tempReceivedTime)); + r = __messageMap.Add(*pReqId, *pMsgType); + r = __messageMap.Add(*pReqId, *pEvent); - free(pMsgBody); - pMsgBody = null; - free(pMsgAddress); - pMsgAddress = null; + __msgMutex.Release(); - if (pSmsEvent) + return r; +} + +result +_SmsMmsCallbackHandler::GetAndRemoveFromMessageMap(int reqId, _MessageType& msgType, Tizen::Base::Object** pUserEvent) +{ + result r = E_SUCCESS; + + Integer* pReqId = new (std::nothrow) Integer(reqId); + SysTryReturn(NID_MSG, pReqId != null, E_OUT_OF_MEMORY, r = E_OUT_OF_MEMORY, "memory allocation failed."); + Integer* pKey = null; + Integer* pMsgType = null; + Tizen::Base::Object* pEvent = null; + IEnumerator* pValueEnum = null; + IMapEnumerator* pMapEnum = null; + + __msgMutex.Acquire(); + + pValueEnum = __messageMap.GetValuesN(*pReqId); + + if (pValueEnum) { - if (port == 0) // normal incoming SMS message case + if (pValueEnum->MoveNext() == E_SUCCESS) { - pSmsEventArg = new (std::nothrow) _SmsEventArg(message, senderAddress, receivedTime); - SysTryReturnVoidResult(NID_MSG, pSmsEventArg != null, E_OUT_OF_MEMORY, "memory allocation failed."); + pMsgType = static_cast (pValueEnum->GetCurrent()); + + if (pValueEnum->MoveNext() == E_SUCCESS) + { + pEvent = static_cast (pValueEnum->GetCurrent()); + } } - else // SMS trigger message case + } + + *pUserEvent = pEvent; + + if (pMsgType) + { + if (pMsgType->ToInt() == _MSG_SMS) { - pSmsEventArg = new (std::nothrow) _SmsEventArg(port, receivedTime, message); - SysTryReturnVoidResult(NID_MSG, pSmsEventArg != null, E_OUT_OF_MEMORY, "memory allocation failed."); + msgType = _MSG_SMS; } + else + { + msgType = _MSG_MMS; + } + } - pSmsEvent->Fire(*pSmsEventArg); + //Manually getting and deleting the key value + pMapEnum = __messageMap.GetMapEnumeratorN(); + + if (pMapEnum) + { + while (pMapEnum->MoveNext() == E_SUCCESS) + { + pKey = static_cast (pMapEnum->GetKey()); + if (pKey) + { + if (!(pKey->CompareTo(*pReqId))) + { + break; + } + } + } + } + + r = __messageMap.Remove(*pReqId, false); + + delete pMapEnum; + delete pValueEnum; + delete pMsgType; + delete pReqId; + delete pKey; + + __msgMutex.Release(); + + return r; +} + +void +_SmsMmsCallbackHandler::SentMessageStatusCallback(msg_handle_t hMsgHandle, msg_struct_t msgStatus, void* pUserParam) +{ + result r = E_SUCCESS; + _MessageType msgType = (_MessageType) -1; + Tizen::Base::Object* pUserEvent = null; + int status = MSG_NETWORK_SEND_FAIL; + int reqId = 0; + + msg_get_int_value(msgStatus, MSG_SENT_STATUS_REQUESTID_INT, &reqId); + msg_get_int_value(msgStatus, MSG_SENT_STATUS_NETWORK_STATUS_INT, &status); + + _SmsMmsCallbackHandler::GetInstance()->GetAndRemoveFromMessageMap(reqId, msgType, &pUserEvent); + + SysLog(NID_MSG, "hMsgHandle[%d]", hMsgHandle); + SysLog(NID_MSG, "req[%d]", reqId); + SysLog(NID_MSG, "msgType[%d]", msgType); + SysLog(NID_MSG, "pUserEvent[%d]", pUserEvent); + + if (status == MSG_NETWORK_SEND_SUCCESS) + { + r = E_SUCCESS; + SysLog(NID_MSG, "Message is sent successfully"); + } + else + { + r = E_FAILURE; + SysLog(NID_MSG, "Failed to send the message. error cause: Message is not sending"); + } + + if (msgType == _MSG_SMS) + { + _SmsEvent* pSmsEvent = dynamic_cast <_SmsEvent*>(pUserEvent); + _SmsEventArg* pSmsEventArg = null; + + if (pSmsEvent) + { + pSmsEventArg = new (std::nothrow) _SmsEventArg(r); + if (pSmsEventArg) + { + pSmsEvent->Fire(*pSmsEventArg); + } + } + } + else + { + if (msgType == _MSG_MMS) + { + _MmsEvent* pMmsEvent = dynamic_cast <_MmsEvent*>(pUserEvent); + _MmsEventArg* pMmsEventArg = null; + + if (pMmsEvent) + { + pMmsEventArg = new (std::nothrow) _MmsEventArg(r); + if (pMmsEventArg) + { + pMmsEvent->Fire(*pMmsEventArg); + } + } + } } + } void -_SmsMmsCallbackHandler::IncomingCbsMessageCallback(messages_cb_message_h incomingMsg, void* pUserParam) +_SmsMmsCallbackHandler::IncomingSmsMessageCallback(msg_handle_t hMsgHandle, msg_struct_t newMsg, void* pUserParam) { _SmsEvent* pSmsEvent = static_cast <_SmsEvent*>(pUserParam); _SmsEventArg* pSmsEventArg = null; - char* pMsgBody = null; - time_t tempReceivedTime = 0; + + int msgSize = 0; + msg_get_int_value(newMsg, MSG_MESSAGE_DATA_SIZE_INT, &msgSize); + char msgText[msgSize + 1]; + memset(msgText, 0, msgSize + 1); + msg_get_str_value(newMsg, MSG_MESSAGE_SMS_DATA_STR, msgText, msgSize); + String message(msgText); + + int port = -1; + msg_get_int_value(newMsg, MSG_MESSAGE_DEST_PORT_INT, &port); + + int displayTime = -1; + msg_get_int_value(newMsg, MSG_MESSAGE_DISPLAY_TIME_INT, &displayTime); + DateTime receivedTime = _MsgUtil::ConvertTime((time_t *) &displayTime); + + char address[MAX_ADDRESS_VAL_LEN] = {0, }; + msg_struct_list_s* pAddrList = NULL; + msg_struct_t addrInfo = NULL; + msg_get_list_handle(newMsg, MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&pAddrList); + addrInfo = pAddrList->msg_struct_info[0]; + msg_get_str_value(addrInfo, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, address, MAX_ADDRESS_VAL_LEN); + String senderAddress(address); + + SysLog(NID_MSG, "hMsgHandle: [%d]", hMsgHandle); + SysLog(NID_MSG, "msg_body: [%s]", msgText); + SysLog(NID_MSG, "port: [%d]", port); + //SysLog(NID_MSG, "received time: [%s]", ctime(pReceivedTime)); + + if (_SmsMmsCallbackHandler::GetInstance()->__incomingSmsCallbackRegistered) + { + if (pSmsEvent) + { + if (port == 0) // normal incoming SMS message case + { + pSmsEventArg = new (std::nothrow) _SmsEventArg(message, senderAddress, receivedTime); + SysTryReturnVoidResult(NID_MSG, pSmsEventArg != null, E_OUT_OF_MEMORY, "memory allocation failed."); + } + else // SMS trigger message case + { + pSmsEventArg = new (std::nothrow) _SmsEventArg(port, receivedTime, message, senderAddress); + SysTryReturnVoidResult(NID_MSG, pSmsEventArg != null, E_OUT_OF_MEMORY, "memory allocation failed."); + } + pSmsEvent->Fire(*pSmsEventArg); + } + } +} + +void +_SmsMmsCallbackHandler::IncomingCbsMessageCallback(msg_handle_t hMsgHandle, msg_struct_t newMsg, void* pUserParam) +{ + _SmsEventArg* pSmsEventArg = null; + int tempReceivedTime = 0; DateTime receivedTime; bool etwsNotifiation = false; int messgeId = 0; int serialNumber = 0; int length = 0; - int dataCodingScheme = 0; - messages_message_type_e cbsType; + int cbsType = -1; Tizen::Base::ByteBuffer msgSerialNumber; - messages_cb_get_text(incomingMsg, &pMsgBody); - messages_cb_get_time(incomingMsg, &tempReceivedTime); - messages_cb_get_message_id(incomingMsg, &messgeId); - messages_cb_get_serial_number(incomingMsg, &serialNumber); - messages_cb_get_message_type(incomingMsg, &cbsType); - messages_cb_get_dcs(incomingMsg, &dataCodingScheme); + msg_get_int_value(newMsg, MSG_CB_MSG_RECV_TIME_INT, &tempReceivedTime); + receivedTime = _MsgUtil::ConvertTime((time_t *) &tempReceivedTime); - Tizen::Base::Integer serialno(serialNumber); + msg_get_int_value(newMsg, MSG_CB_MSG_MSG_ID_INT, &messgeId); + msg_get_int_value(newMsg, MSG_CB_MSG_SERIAL_NUM_INT, &serialNumber); + msg_get_int_value(newMsg, MSG_CB_MSG_TYPE_INT, &cbsType); + + Tizen::Base::Integer serialno(serialNumber); length = serialno.ToString().GetLength(); msgSerialNumber.Construct(length); msgSerialNumber.SetInt(0, serialNumber); msgSerialNumber.SetPosition(0); - String message(pMsgBody); // porting char* to String + if (cbsType == MSG_TYPE_SMS_ETWS_PRIMARY || cbsType == MSG_TYPE_SMS_ETWS_SECONDARY) + { + int etwsWarningType; + char etwsWarningInfo[MESSAGES_ETWS_WARNING_INFO_LEN]; + Tizen::Base::ByteBuffer msgSecurityInfo; + Tizen::Base::ByteBuffer etwsMsgWarningType; + msg_get_int_value(newMsg, MSG_CB_MSG_ETWS_WARNING_TYPE_INT, &etwsWarningType); + msg_get_str_value(newMsg, MSG_CB_MSG_ETWS_WARNING_SECU_INFO_STR, etwsWarningInfo, MESSAGES_ETWS_WARNING_INFO_LEN); + + String etwsSecurityInfo(etwsWarningInfo); + length = etwsSecurityInfo.GetLength(); + msgSecurityInfo.Construct(length); + msgSecurityInfo.SetArray((byte*) etwsWarningInfo, 0, length); + msgSecurityInfo.SetPosition(0); + + Tizen::Base::Integer warningtype(etwsWarningType); + length = warningtype.ToString().GetLength(); + + etwsMsgWarningType.Construct(length); + etwsMsgWarningType.SetInt(0, etwsWarningType); + etwsMsgWarningType.SetPosition(0); - receivedTime = _MsgUtil::ConvertTime(&tempReceivedTime); + etwsNotifiation = true; + _SmsEvent* pSmsEvent = static_cast <_SmsEvent*>(_SmsMmsCallbackHandler::GetInstance()->__pEtwsUserEvent); - Tizen::Base::Integer dataCodingSchemeTemp(dataCodingScheme); + SysLog(NID_MSG, "cbs etwsWarningType: [%d]", etwsWarningType); - if (cbsType == MESSAGES_TYPE_SMS_ETWS_PRIMARY || cbsType == MESSAGES_TYPE_SMS_ETWS_SECONDARY) - { - etwsNotifiation = true; + if (pSmsEvent) + { + 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."); + pSmsEvent->Fire(*pSmsEventArg); + } } - - if (pMsgBody) + else { - free(pMsgBody); - pMsgBody = null; + _SmsEvent* pSmsEvent = static_cast <_SmsEvent*>(_SmsMmsCallbackHandler::GetInstance()->__pCbsUserEvent); + int dataCodingScheme = 0; + int msgSize = 0; + + msg_get_int_value(newMsg, MSG_CB_MSG_CB_TEXT_LEN_INT, &msgSize); + char msgBody[msgSize + 1]; + memset(msgBody, 0, msgSize + 1); + msg_get_str_value(newMsg, MSG_CB_MSG_CB_TEXT_STR, msgBody, msgSize + 1); + String message(msgBody); // porting char* to String + + msg_get_int_value(newMsg, MSG_CB_MSG_DCS_INT, &dataCodingScheme); + Tizen::Base::Integer dataCodingSchemeTemp(dataCodingScheme); + + //language type of cbs message + String messageLanguage(L""); + byte higherNibble = dataCodingScheme & 0xf0; + byte lowerNibble = dataCodingScheme & 0x0f; + + //check higher nibble + // if higher nibble 0000 + if (higherNibble == 0x00) + { + messageLanguage = GetCbsLanguageType(lowerNibble); + } + else if (higherNibble == 0x01) + { + // if higher nibble is 0001, get language type from framework + int len = 15; + char type[len + 1]; + memset(type, 0, len + 1); + msg_get_str_value(newMsg, MSG_CB_MSG_LANGUAGE_TYPE_STR, type, len); + messageLanguage = String(type); + } + else if (higherNibble == 0x20 && lowerNibble == 0x00) + { + // if 0010 0000 + messageLanguage = String(L"CS"); + } + else + { + // use empty string + } + + if (pSmsEvent) + { + pSmsEventArg = new (std::nothrow) _SmsEventArg(message, msgSerialNumber, receivedTime, messgeId, etwsNotifiation, + ((byte) dataCodingSchemeTemp.ToChar()),messageLanguage, _SMS_EVENT_TYPE_CBS_RECEIVE_RESULT); + SysTryReturnVoidResult(NID_MSG, pSmsEventArg != null, E_OUT_OF_MEMORY, "memory allocation failed."); + pSmsEvent->Fire(*pSmsEventArg); + } + + 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 msg_body: [%s]", pMsgBody); + SysLog(NID_MSG, "cbs msg_id: [%d]", messgeId); SysLog(NID_MSG, "cbs serialNumber: [%d]", serialNumber); - SysLog(NID_MSG, "cbs received time: [%s]", ctime(&tempReceivedTime)); SysLog(NID_MSG, "cbs etwsNotifiation: [%d]", etwsNotifiation); - SysLog(NID_MSG, "cbs dataCodingScheme: [%d]", dataCodingScheme); - - if (pSmsEvent) - { - pSmsEventArg = new (std::nothrow) _SmsEventArg(message, msgSerialNumber, receivedTime, messgeId, etwsNotifiation, ((byte) dataCodingSchemeTemp.ToChar()), _SMS_EVENT_TYPE_CBS_RECEIVE_RESULT); - SysTryReturnVoidResult(NID_MSG, pSmsEventArg != null, E_OUT_OF_MEMORY, "memory allocation failed."); - pSmsEvent->Fire(*pSmsEventArg); - } } void -_SmsMmsCallbackHandler::IncomingWapPushMessageCallback(const char* pHeader, const char* pBody, int bodyLength, void* pUserParam) +_SmsMmsCallbackHandler::IncomingWapPushMessageCallback(msg_handle_t hMsgHandle, const char* pHeader, const char* pBody, int bodyLength, void* pUserParam) { _SmsEvent* pSmsEvent = static_cast <_SmsEvent*>(pUserParam); _SmsEventArg* pSmsEventArg = null; @@ -320,56 +866,111 @@ _SmsMmsCallbackHandler::IncomingWapPushMessageCallback(const char* pHeader, cons } } -void -_SmsMmsCallbackHandler::IncomingEtwsMessageCallback(messages_cb_message_h incomingMsg, int etwsWarningType, const char* pEtwsSecurityInfo, void* pUserParam) +Tizen::Base::String +_SmsMmsCallbackHandler::GetCbsLanguageType(byte codingScheme) { - _SmsEvent* pSmsEvent = static_cast <_SmsEvent*>(pUserParam); - _SmsEventArg* pSmsEventArg = null; - time_t tempReceivedTime = 0; - DateTime receivedTime; - int messgeId = 0; - int serialNumber = 0; - int length = 0; - Tizen::Base::ByteBuffer msgSerialNumber; - Tizen::Base::ByteBuffer msgSecurityInfo; - Tizen::Base::ByteBuffer etwsMsgWarningType; + String languageType(L""); - messages_cb_get_time(incomingMsg, &tempReceivedTime); - messages_cb_get_message_id(incomingMsg, &messgeId); - messages_cb_get_serial_number(incomingMsg, &serialNumber); + switch(codingScheme) + { + case 0x00: + languageType = String(L"DE"); + break; + case 0x01: + languageType = String(L"EN"); + break; + case 0x02: + languageType = String(L"IT"); + break; + case 0x03: + languageType = String(L"FR"); + break; + case 0x04: + languageType = String(L"ES"); + break; + case 0x05: + languageType = String(L"NL"); + break; + case 0x06: + languageType = String(L"SV"); + break; + case 0x07: + languageType = String(L"DA"); + break; + case 0x08: + languageType = String(L"PT"); + break; + case 0x09: + languageType = String(L"FI"); + break; + case 0x0a: + languageType = String(L"NO"); + break; + case 0x0b: + languageType = String(L"EL"); + break; + case 0x0c: + languageType = String(L"TR"); + break; + case 0x0d: + languageType = String(L"HU"); + break; + case 0x0e: + languageType = String(L"PL"); + break; + case 0x0f: + languageType = String(L""); + SysLog(NID_MSG, "Language unspecified."); + break; + default: + break; + }; + + return languageType; +} - Tizen::Base::Integer serialno(serialNumber); - length = serialno.ToString().GetLength(); +result +_SmsMmsCallbackHandler::ConvertException(int err) const +{ + result r = E_SUCCESS; - msgSerialNumber.Construct(length); - msgSerialNumber.SetInt(0, serialNumber); - msgSerialNumber.SetPosition(0); + switch (err) + { + case MSG_SUCCESS: + r = E_SUCCESS; + break; - String etwsSecurityInfo(pEtwsSecurityInfo); - length = etwsSecurityInfo.GetLength(); - msgSecurityInfo.Construct(length); - msgSecurityInfo.SetArray((byte*) pEtwsSecurityInfo, 0, length); - msgSecurityInfo.SetPosition(0); + case MSG_ERR_INVALID_PARAMETER: + case MSG_ERR_INVALID_MESSAGE: + case MSG_ERR_NULL_POINTER: + case MSG_ERR_NULL_MESSAGE: + r = E_INVALID_ARG; + break; - Tizen::Base::Integer warningtype(etwsWarningType); - length = warningtype.ToString().GetLength(); + case MSG_ERR_MEMORY_ERROR: + r = E_OUT_OF_MEMORY; + break; - etwsMsgWarningType.Construct(length); - etwsMsgWarningType.SetInt(0, etwsWarningType); - etwsMsgWarningType.SetPosition(0); + case MSG_ERR_SERVER_NOT_READY: + case MSG_ERR_TRANSPORT_ERROR: + case MSG_ERR_COMMUNICATION_ERROR: + r = E_NETWORK_UNAVAILABLE; + break; - receivedTime = _MsgUtil::ConvertTime(&tempReceivedTime); + case MSG_ERR_NO_SIM: + r = E_DEVICE_UNAVAILABLE; + break; - SysLog(NID_MSG, "cbs msg_id: [%d]", messgeId); - SysLog(NID_MSG, "cbs received time: [%s]", ctime(&tempReceivedTime)); - SysLog(NID_MSG, "cbs etwsWarningType: [%d]", etwsWarningType); + case MSG_ERR_PLUGIN_TAPI_FAILED: + r = E_FAILURE; + break; - if (pSmsEvent) - { - 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."); - pSmsEvent->Fire(*pSmsEventArg); + default: + r = E_SYSTEM; + break; } + + return r; } } } // Tizen::Messaging diff --git a/src/FMsg_SmsMmsCallbackHandler.h b/src/FMsg_SmsMmsCallbackHandler.h index a000b22..21b2fa7 100644 --- a/src/FMsg_SmsMmsCallbackHandler.h +++ b/src/FMsg_SmsMmsCallbackHandler.h @@ -53,6 +53,17 @@ public: */ virtual ~_SmsMmsCallbackHandler(void); + /** + * Initializes the Messaging Hash Map table + * + * @since 3.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG Input parameter is NULL. + * @exception E_OUT_OF_MEMORY Memory error. + */ + result Construct(void); + // Operation public: /** @@ -66,31 +77,82 @@ public: /** * gets the Message Handle for SMS/MMS operation. * - * @since 2.1 + * @since 3.0 * @return An error code * @param[in] messageHandle message Handle * @exception MSG_SUCCESS The method was successful. * @exception MSG_ERR_NULL_POINTER Input parameter is NULL. * @exception MSG_ERR_MEMORY_ERROR Memory error. */ - int OpenMessageHandle(messages_service_h& messageHandle); + int OpenMessageHandle(msg_handle_t& messageHandle); /** * gets the Message Handle for Cbs message operation. * - * @since 2.1 + * @since 3.0 * @return An error code * @param[in] cbsSettingsHandle cbs message Handle * @exception MSG_SUCCESS The method was successful. * @exception MSG_ERR_NULL_POINTER Input parameter is NULL. * @exception MSG_ERR_MEMORY_ERROR Memory error. */ - int OpenCbsSettingsHandle(messages_cb_settings_h& cbsSettingsHandle); + int OpenCbsSettingsHandle(msg_struct_t& cbsSettingsHandle); + + // Adds a CBS channel with specified parameters. + result AddCbsChannel(int from, int to, Tizen::Base::String& name, bool activate); + + // Removes a CBS channel with specified parameters. + result RemoveCbsChannel(int from, int to); + + // Searches a CBS channel with specified parameters and returns index of channel found. + result SearchCbsChannel(int from, int to, int& index); + + // Updates a CBS channel with specified parameters. + result UpdateCbsChannel(int from, int to, Tizen::Base::String name, bool activate); + + // Gets a CBS channel data with specified index. + result GetCbsChannel(int index, int& from, int& to, Tizen::Base::String& name, bool& activate); + + // Gets a CBS channel count. + result GetCbsChannelsCount(int& count); + + /** + * loads the Cbs channels list. + * + * @since 3.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG Input parameter is NULL. + * @exception E_OUT_OF_MEMORY Memory error. + */ + result LoadCbsSettings(); + + /** + * saves the Cbs channels list. + * + * @since 3.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG Input parameter is NULL. + * @exception E_OUT_OF_MEMORY Memory error. + */ + result SaveCbsSettings(); + + /** + * closes the CBS Message Handle. + * + * @since 3.0 + * @return An error code + * @exception MSG_SUCCESS The method was successful. + * @exception MSG_ERR_NULL_POINTER Input parameter is NULL. + * @exception MSG_ERR_MEMORY_ERROR Memory error. + */ + int CloseCbsSettingsHandle(void); /** * closes the Message Handle for SMS/MMS operation. * - * @since 2.1 + * @since 3.0 * @return An error code * @exception MSG_SUCCESS The method was successful. * @exception MSG_ERR_NULL_POINTER Input parameter is NULL. @@ -98,23 +160,76 @@ public: */ int CloseMessageHandle(void); - // for SMS sent status - static void SentSmsMessageStatusCallback(messages_sending_result_e status, void* pUserEvent); + /** + * Registers the Message call back for SMS/MMS operation. + * + * @since 3.0 + * @return An error code + * @exception MSG_SUCCESS The method was successful. + * @exception MSG_ERR_NULL_POINTER Input parameter is NULL. + * @exception MSG_ERR_MEMORY_ERROR Memory error. + */ + int RegisterMessageCallback(void); - //for MMS sent status - static void SentMmsMessageStatusCallback(messages_sending_result_e status, void* pUserEvent); + /** + * Adds the message requestId/Message Type/Message Event to Message Hash Map table + * + * @since 3.0 + * @return An error code + * @param[in] reqId SMS/MMS message requestId + * @param[in] msgType message type + * @param[in] pEvent message Event + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG Input parameter is NULL. + * @exception E_OUT_OF_MEMORY Memory error. + */ + result AddToMessageMap(int reqId, _MessageType msgType, Tizen::Base::Object* pEvent); + + /** + * Gets the Message Type and Message Event based on the message requestId. Also removes the Hashmap elements for the requestId + * + * @since 3.0 + * @return An error code + * @param[in] reqId SMS/MMS message requestId + * @param[in] msgType message type + * @param[in] pEvent message Event + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG Input parameter is NULL. + * @exception E_OUT_OF_MEMORY Memory error. + */ + result GetAndRemoveFromMessageMap(int reqId, _MessageType& msgType, Tizen::Base::Object** pEvent); + + // for SMS and MMS sent status + static void SentMessageStatusCallback(msg_handle_t hMsgHandle, msg_struct_t msgStatus, void* pUserParam); // for incoming SMS - static void IncomingSmsMessageCallback(messages_message_h incomingMsg, void* pUserParam); + static void IncomingSmsMessageCallback(msg_handle_t hMsgHandle, msg_struct_t newMsg, void* pUserParam); + + /** + * Sets the __incomingSmsCallbackRegistered flag. + * + * @since 3.0 + * @param[in] incomingSmsCallbackRegistered SMS registered flag + */ + void SetInComingSmsCallback(bool incomingSmsCallbackRegistered); - // for incoming CBS - static void IncomingCbsMessageCallback(messages_cb_message_h incomingMsg, void* pUserParam); + /** + * 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); // for incoming Wap push - static void IncomingWapPushMessageCallback(const char* pHeader, const char* pBody, int bodyLength, void* pUserParam); + static void IncomingWapPushMessageCallback(msg_handle_t hMsgHandle, const char* pHeader, const char* pBody, int bodyLength, void* pUserParam); - // for incoming Etws cbs - static void IncomingEtwsMessageCallback(messages_cb_message_h incomingMsg, int etwsWarningType, const char* pEtwsSecurityInfo, void* pUserParam); + //get cb message language type + static Tizen::Base::String GetCbsLanguageType(byte codingScheme); // Life cycle private: @@ -125,10 +240,20 @@ private: */ _SmsMmsCallbackHandler(void); + result ConvertException(int err) const; + private: static _SmsMmsCallbackHandler* __pMessageCallbackHandler; - messages_service_h __msgHandle; - messages_cb_settings_h __cbsSettingsHandle; + msg_handle_t __msgHandle; + msg_struct_t __cbsSettingsHandle; + msg_struct_list_s* __pCbsChannelList; + Tizen::Base::Collection::ArrayList* __pTempCbsChannelList; + bool __callbackRegistered; + bool __incomingSmsCallbackRegistered; + Tizen::Base::Collection::MultiHashMap __messageMap; + Tizen::Base::Runtime::Mutex __msgMutex; + Tizen::Base::Object* __pCbsUserEvent; + Tizen::Base::Object* __pEtwsUserEvent; }; // _SmsMmsCallbackHandler } } // Tizen::Messaging diff --git a/src/FMsg_Types.h b/src/FMsg_Types.h index 6e513b7..ea09dab 100644 --- a/src/FMsg_Types.h +++ b/src/FMsg_Types.h @@ -45,7 +45,7 @@ namespace Tizen { namespace Messaging #define MAX_EMAIL_BODY_TEXT_LENGTH 2000 // file size -#define MAX_MMS_FILE_SIZE (295 * 1024) // 295KB = 300KB - 4KB (MMS header margin) - 1KB (my margin for local language size) +#define MAX_MMS_FILE_SIZE (295 * 1024) // 295KB = 300KB - 4KB (MMS header margin) - 1KB (margin for local language size) #define MAX_EMAIL_FILE_SIZE (5 * 1024 * 1024) // 5MB // attachment count @@ -63,8 +63,9 @@ namespace Tizen { namespace Messaging // Cbs channel name length #define MAX_CBS_CHANNEL_NAME_LENGTH 32 -#define MAX_CBS_CHANNEL_RANGE 900 +#define MAX_CBS_CHANNEL_RANGE 0xFFFF #define MAX_CBS_CHANNEL_LIMIT 0xFFFF +#define MESSAGES_ETWS_WARNING_INFO_LEN 50 //Detail email message @@ -85,7 +86,9 @@ enum _MessageType _MSG_SMS = 0, /** +#include +#include +#include +#include #include #include #include @@ -75,7 +78,7 @@ result _WapPushManagerImpl::AddWapPushEventListener(const Tizen::Base::String& wapApplicationId, const IWapPushEventListener& listener) { result r = E_SUCCESS; - int err = MESSAGES_ERROR_NONE; + int err = MSG_SUCCESS; char* pWapAppId = null; ClearLastResult(); @@ -111,7 +114,7 @@ _WapPushManagerImpl::AddWapPushEventListener(const Tizen::Base::String& wapAppli // check value of msg handle SysTryCatch(NID_MSG, __msgHandle > 0, r = E_SYSTEM, r, "failed to get msg handle."); - err = messages_push_add_incoming_cb(__msgHandle, pWapAppId, &_SmsMmsCallbackHandler::IncomingWapPushMessageCallback, (void*) __pWapPushReceiveEvent); + 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)); @@ -144,29 +147,13 @@ result _WapPushManagerImpl::RemoveWapPushEventListener(const Tizen::Base::String& wapApplicationId, const IWapPushEventListener& listener) { result r = E_SUCCESS; - int err = MESSAGES_ERROR_NONE; ClearLastResult(); - char* pWapAppId = null; SysTryCatch(NID_MSG, __pWapPushReceiveEvent != null, r = E_OBJ_NOT_FOUND, r, "listner not found"); r = __pWapPushReceiveEvent->RemoveListener(listener); SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "listner remove failed"); - pWapAppId = _StringConverter::CopyToCharArrayN(wapApplicationId); - SysTryCatch(NID_MSG, pWapAppId != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed"); - - err = messages_push_remove_incoming_cb(__msgHandle, pWapAppId); - - r = ConvertException(err); - SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to Remove WapPush EventListener.", GetErrorMessage(r)); - - if (pWapAppId) - { - delete[] pWapAppId; - pWapAppId = null; - } - if (__pWapPushReceiveEvent) { delete __pWapPushReceiveEvent; @@ -176,11 +163,6 @@ _WapPushManagerImpl::RemoveWapPushEventListener(const Tizen::Base::String& wapAp return r; CATCH: - if (pWapAppId) - { - delete[] pWapAppId; - pWapAppId = null; - } return r; } @@ -188,9 +170,11 @@ result _WapPushManagerImpl::RegisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType) { result r = E_SUCCESS; - int err = MESSAGES_ERROR_NONE; + int err = MSG_SUCCESS; char* pWapAppId = null; char* pContentType = null; + msg_struct_t pushInfo; + char* pPkgName = null; ClearLastResult(); @@ -200,7 +184,17 @@ _WapPushManagerImpl::RegisterCondition(const Tizen::Base::String& wapApplication pContentType = _StringConverter::CopyToCharArrayN(contentType); SysTryCatch(NID_MSG, pContentType != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed"); - err = messages_push_register(__msgHandle, pContentType, pWapAppId); + 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, (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); + + 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)); @@ -219,6 +213,9 @@ _WapPushManagerImpl::RegisterCondition(const Tizen::Base::String& wapApplication return r; CATCH: + free(pPkgName); + msg_release_struct(&pushInfo); + if (pWapAppId) { delete[] pWapAppId; @@ -237,9 +234,11 @@ result _WapPushManagerImpl::UnregisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType) { result r = E_SUCCESS; - int err = MESSAGES_ERROR_NONE; + int err = MSG_SUCCESS; char* pWapAppId = null; char* pContentType = null; + msg_struct_t pushInfo; + char* pPkgName = null; ClearLastResult(); @@ -249,7 +248,17 @@ _WapPushManagerImpl::UnregisterCondition(const Tizen::Base::String& wapApplicati pContentType = _StringConverter::CopyToCharArrayN(contentType); SysTryCatch(NID_MSG, pContentType != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed"); - err = messages_push_deregister(__msgHandle, pContentType, pWapAppId); + 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); + + 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)); @@ -268,6 +277,9 @@ _WapPushManagerImpl::UnregisterCondition(const Tizen::Base::String& wapApplicati return r; CATCH: + free(pPkgName); + msg_release_struct(&pushInfo); + if (pWapAppId) { delete[] pWapAppId; @@ -289,33 +301,32 @@ _WapPushManagerImpl::ConvertException(int err) const switch (err) { - case MESSAGES_ERROR_NONE: + case MSG_SUCCESS: r = E_SUCCESS; break; - case MESSAGES_ERROR_INVALID_PARAMETER: + case MSG_ERR_INVALID_PARAMETER: + case MSG_ERR_INVALID_MESSAGE: + case MSG_ERR_NULL_POINTER: + case MSG_ERR_NULL_MESSAGE: r = E_INVALID_ARG; break; - case MESSAGES_ERROR_OUT_OF_MEMORY: + case MSG_ERR_MEMORY_ERROR: r = E_OUT_OF_MEMORY; break; - case MESSAGES_ERROR_SERVER_NOT_READY: // Communication error between client and server - case MESSAGES_ERROR_COMMUNICATION_WITH_SERVER_FAILED: + case MSG_ERR_SERVER_NOT_READY: + case MSG_ERR_TRANSPORT_ERROR: + case MSG_ERR_COMMUNICATION_ERROR: r = E_NETWORK_UNAVAILABLE; break; - case MESSAGES_ERROR_NO_SIM_CARD: + case MSG_ERR_NO_SIM: r = E_DEVICE_UNAVAILABLE; break; - case MESSAGES_ERROR_OUT_OF_RANGE: - r = E_OBJ_ALREADY_EXIST; - break; - - case MESSAGES_ERROR_SENDING_FAILED: - case MESSAGES_ERROR_OPERATION_FAILED: + case MSG_ERR_PLUGIN_TAPI_FAILED: r = E_FAILURE; break; diff --git a/src/FMsg_WapPushManagerImpl.h b/src/FMsg_WapPushManagerImpl.h index 5e14edc..afbc941 100644 --- a/src/FMsg_WapPushManagerImpl.h +++ b/src/FMsg_WapPushManagerImpl.h @@ -205,7 +205,7 @@ public: _WapPushManagerImpl& operator =(const _WapPushManagerImpl& rhs); private: - messages_service_h __msgHandle; + msg_handle_t __msgHandle; _SmsEvent* __pWapPushReceiveEvent; }; // _WapPushManagerImpl diff --git a/src/FMsg_WapPushMessageImpl.cpp b/src/FMsg_WapPushMessageImpl.cpp index 4af8fcd..8bf941d 100644 --- a/src/FMsg_WapPushMessageImpl.cpp +++ b/src/FMsg_WapPushMessageImpl.cpp @@ -21,7 +21,9 @@ * This file contains the implementation of the %__WapPushMessageImpl class. */ -#include +#include +#include +#include #include #include #include -- 2.7.4