--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET (this_target osp-messaging)
+
+SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/cmake_build_tmp/output)
+
+INCLUDE_DIRECTORIES(
+ inc
+ src
+ src/inc
+ /usr/include/appfw
+ /usr/include/glib-2.0
+ /usr/lib/glib-2.0/include
+ /usr/include/osp
+ /usr/include/osp/app
+ /usr/include/osp/base
+ /usr/include/osp/security
+ /usr/include/messaging
+ /usr/include/email-service
+ /usr/include/libxml2
+ )
+
+SET (${this_target}_SOURCE_FILES
+ src/FMsgEmailManager.cpp
+ src/FMsgEmailMessage.cpp
+ src/FMsgEmailAttachment.cpp
+ src/FMsgDetailedEmailMessage.cpp
+ src/FMsgMmsManager.cpp
+ src/FMsgMmsMessage.cpp
+ src/FMsgPushManager.cpp
+ src/FMsgPushMessage.cpp
+ src/FMsgWapPushManager.cpp
+ src/FMsgWapPushMessage.cpp
+ src/FMsgRecipientList.cpp
+ src/FMsgSmsManager.cpp
+ src/FMsgSmsMessage.cpp
+ src/FMsgCbsChannel.cpp
+ src/FMsgCbsMessage.cpp
+ src/FMsgEtwsPrimaryNotification.cpp
+ src/FMsg_EmailEvent.cpp
+ src/FMsg_EmailEventArg.cpp
+ src/FMsg_EmailManagerImpl.cpp
+ src/FMsg_EmailMessageImpl.cpp
+ src/FMsg_EmailAttachmentImpl.cpp
+ src/FMsg_DetailedEmailMessageImpl.cpp
+ src/FMsg_MmsEvent.cpp
+ src/FMsg_MmsEventArg.cpp
+ src/FMsg_MmsManagerImpl.cpp
+ src/FMsg_MmsMessageImpl.cpp
+ src/FMsg_PushEvent.cpp
+ src/FMsg_PushEventArg.cpp
+ src/FMsg_PushManagerImpl.cpp
+ src/FMsg_PushMessageImpl.cpp
+ src/FMsg_PushRequest.cpp
+ src/FMsg_PushSendListener.cpp
+ src/FMsg_PushUrlRequestListener.cpp
+ src/FMsg_WapPushManagerImpl.cpp
+ src/FMsg_WapPushMessageImpl.cpp
+ src/FMsg_ComposerEvent.cpp
+ src/FMsg_ComposerEventArg.cpp
+ src/FMsg_RecipientListImpl.cpp
+ src/FMsg_SmsEvent.cpp
+ src/FMsg_SmsEventArg.cpp
+ src/FMsg_SmsManagerImpl.cpp
+ src/FMsg_SmsMessageImpl.cpp
+ src/FMsg_CbsChannelImpl.cpp
+ src/FMsg_CbsMessageImpl.cpp
+ src/FMsg_EtwsPrimaryNotificationImpl.cpp
+ src/FMsg_MsgUtil.cpp
+ src/FMsg_SmsMmsCallbackHandler.cpp
+)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall" )
+
+## SET C COMPILER FLAGS
+SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## SET CPP COMPILER FLAGS
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
+SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## Create Library
+ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+## SET LINKER FLAGS
+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} "-lemail-api" )
+TARGET_LINK_LIBRARIES(${this_target} "-lcapi-messaging-messages" )
+TARGET_LINK_LIBRARIES(${this_target} "-lpush" )
+
+
+SET_TARGET_PROPERTIES(${this_target}
+ PROPERTIES
+ VERSION ${FULLVER}
+ SOVERSION ${MAJORVER}
+ CLEAN_DIRECT_OUTPUT 1
+ )
+
+ADD_CUSTOM_COMMAND(TARGET ${this_target}
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER}
+ COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${MAJORVER}
+ COMMAND ${CMAKE_STRIP} --strip-unneeded ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}
+ COMMENT "strip ${this_target}"
+ )
+
+INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/ DESTINATION lib/osp
+ FILES_MATCHING PATTERN "*.so*"
+ PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
+ GROUP_EXECUTE GROUP_READ
+ WORLD_EXECUTE WORLD_READ)
+INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/debug/ DESTINATION lib/osp/debug
+ FILES_MATCHING PATTERN "*.so*"
+ PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
+ GROUP_EXECUTE GROUP_READ
+ WORLD_EXECUTE WORLD_READ)
+
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/inc/ DESTINATION include/osp FILES_MATCHING PATTERN "*.h")
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/src/inc/ DESTINATION include/osp/messaging FILES_MATCHING PATTERN "*.h")
+
+# pkgconfig file
+CONFIGURE_FILE(${this_target}.pc.in ${CMAKE_SOURCE_DIR}/${this_target}.pc @ONLY)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/${this_target}.pc DESTINATION lib/pkgconfig)
--- /dev/null
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
--- /dev/null
+Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE.APLv2 file for Apache License terms and conditions.
--- /dev/null
+//
+// 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 FMessaging.h
+ * @brief This is the header file for the %Messaging namespace.
+ *
+ * This header file contains the declarations and descriptions of the %Messaging namespace.
+ */
+
+#ifndef _FMESSAGING_H_
+#define _FMESSAGING_H_
+
+//include
+#include <FMsgTypes.h>
+#include <FMsgSmsMessage.h>
+#include <FMsgMmsMessage.h>
+#include <FMsgEmailMessage.h>
+#include <FMsgPushMessage.h>
+#include <FMsgSmsManager.h>
+#include <FMsgMmsManager.h>
+#include <FMsgEmailManager.h>
+#include <FMsgPushManager.h>
+#include <FMsgRecipientList.h>
+#include <FMsgISmsListener.h>
+#include <FMsgIMmsListener.h>
+#include <FMsgIEmailListener.h>
+#include <FMsgISmsEventListener.h>
+#include <FMsgISmsMessageEventListener.h>
+#include <FMsgIPushEventListener.h>
+#include <FMsgIPushManagerListener.h>
+
+/**
+ * @namespace Tizen::Messaging
+ * @brief This namespace contains classes and interfaces for messaging services.
+ * @since 2.0
+ *
+ * @remarks @b Header @b %file : @b \#include @b <FMessaging.h> @n
+ * @b Library : @b osp-messaging
+ *
+ * The %Messaging namespace accesses the messaging capabilities of the device. @n
+ * It provides classes and interfaces for the following: @n
+ * - SMS: create, send, receive, and retrieve
+ * - MMS: create and send
+ * - email: create and send
+ * - push: receive
+ *
+ * For more information on the %Messaging namespace features, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/messaging.htm">Messaging Guide</a>.
+ *
+ * The following diagram illustrates the relationships between the classes belonging to the %Messaging namespace.
+ * @image html messaging_using_the_apis_classdiagram.png
+ *
+ */
+namespace Tizen
+{
+ namespace Messaging
+ {
+
+ };
+}; // Tizen::Messaging
+
+#endif // _FMESSAGING_H_
--- /dev/null
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+/**\r
+* @if VISPARTNER-OPERATOR\r
+*\r
+* @file FMsgCbsChannel.h\r
+* @brief This is the header file for the %CbsChannel class.\r
+*\r
+* @visibility partner-operator\r
+*\r
+* This header file contains the declarations of the %CbsChannel class.\r
+*\r
+* @endif\r
+*/\r
+\r
+#ifndef _FMSG_CBS_CHANNEL_H_\r
+#define _FMSG_CBS_CHANNEL_H_\r
+\r
+#include <FBase.h>\r
+\r
+namespace Tizen { namespace Messaging\r
+{\r
+class _CbsChannelImpl;\r
+\r
+/**\r
+* @if VISPARTNER-OPERATOR\r
+*\r
+* @class CbsChannel\r
+* @brief This class provides methods for handling a Cell Broadcast Service (CBS) channel.\r
+*\r
+* @since 2.0\r
+*\r
+* @final This class is not intended for extension.\r
+*\r
+* @visibility partner-operator\r
+*\r
+* The %CbsChannel class provides methods for handling a CBS channel. @n\r
+* It allows you to get and set the CBS channel information.\r
+*\r
+* @endif\r
+*/\r
+class _OSP_EXPORT_ CbsChannel\r
+ : public Tizen::Base::Object\r
+{\r
+public:\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * This destructor overrides Tizen::Base::Object::~Object().\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @endif\r
+ */\r
+ virtual ~CbsChannel(void);\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the range of a CBS channel\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ *\r
+ * @return An error code\r
+ * @param[out] from The starting index of the message ID of the channel\r
+ * @param[out] to The last index of the message ID of the channel\r
+ * @exception E_SUCCESS The method is successful.\r
+ * @exception E_INVALID_STATE The range has not been set as yet.\r
+ * @exception E_SYSTEM A system error has occurred.\r
+ * @remarks In case of an error, this method sets the negative values for @c from and @c to. For example, @c -1.\r
+ *\r
+ * @endif\r
+ */\r
+ result GetRange(int& from, int& to) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the name of a CBS channel.\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ *\r
+ * @return The name of the channel\r
+ *\r
+ * @remarks The name can be an empty string.\r
+ *\r
+ * @endif\r
+ */\r
+ Tizen::Base::String GetName(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Checks whether a CBS channel is activated.\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ *\r
+ * @return @c true if a CBS channel is activated, @n\r
+ * else @c false\r
+ *\r
+ * @endif\r
+ */\r
+ bool IsActivated(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Activates the status of a CBS channel.\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @privilege %http://tizen.org/privilege/cellbroadcast\r
+ *\r
+ * @return An error code\r
+ * @exception E_SUCCESS The method is successful.\r
+ * @exception E_ILLEGAL_ACCESS The application does not have the permission to activate the CBS channel status.\r
+ * @exception E_SYSTEM A system error has occurred.\r
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.\r
+ *\r
+ * @endif\r
+ */\r
+ result Activate(void);\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Deactivates the status of a CBS channel.\r
+ *\r
+ * @privilege %http://tizen.org/privilege/cellbroadcast\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return An error code\r
+ * @exception E_SUCCESS The method is successful.\r
+ * @exception E_ILLEGAL_ACCESS The application does not have the permission to activate the CBS channel status.\r
+ * @exception E_SYSTEM A system error has occurred.\r
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.\r
+ *\r
+ * @endif\r
+ */\r
+ result Deactivate(void);\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Updates the name of a CBS channel.\r
+ *\r
+ * @privilege %http://tizen.org/privilege/cellbroadcast\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return An error code\r
+ * @param[in] name The name of the CBS channel to update\r
+ * @exception E_SUCCESS The method is successful.\r
+ * @exception E_ILLEGAL_ACCESS The application does not have the permission to update the CBS channel name.\r
+ * @exception E_SYSTEM A system error has occurred.\r
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.\r
+ *\r
+ * @endif\r
+ */\r
+ result UpdateName(const Tizen::Base::String& name);\r
+\r
+private:\r
+ /**\r
+ * This default constructor is intentionally declared as private so that only the platform can create an instance.\r
+ *\r
+ * @since 2.0\r
+ */\r
+ CbsChannel(void);\r
+\r
+ /**\r
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.\r
+ *\r
+ * @param[in] rhs An instance of %CbsChannel\r
+ */\r
+ CbsChannel(const CbsChannel& rhs);\r
+\r
+ /**\r
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.\r
+ *\r
+ * @param[in] rhs An instance of %CbsChannel\r
+ */\r
+ CbsChannel& operator =(const CbsChannel& rhs);\r
+\r
+ /**\r
+ * Initializes this instance of %CbsChannel with the specified parameters.\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @return An error code\r
+ * @param[in] from The starting index of the message ID of the channel\r
+ * @param[in] to The last index of the message ID of the channel\r
+ * @param[in] name The name of the channel (can be an empty string)\r
+ * @exception E_SUCCESS The method is successful.\r
+ * @exception E_INVALID_ARG Either of the following conditions has occurred: @n\r
+ * - The specified @c to parameter is smaller than @c from. @n\r
+ * - The specified @c to or @c from parameter is a negative value. @n\r
+ * - The specified @c to parameter exceeds the limit (0xFFFF). @n\r
+ * - The range (@c to - @c from) exceeds the limit (900). @n\r
+ * - The specified @c name string length is greater than @c 32. @n\r
+ * @exception E_SYSTEM A system error has occurred.\r
+ */\r
+ result Construct(int from, int to, const Tizen::Base::String& name);\r
+\r
+private:\r
+ _CbsChannelImpl* __pCbsChannelImpl;\r
+\r
+ friend class _CbsChannelImpl;\r
+}; // CbsChannel\r
+\r
+} } // Tizen::Messaging\r
+#endif // _FMSG_CBS_CHANNEL_H_\r
--- /dev/null
+//
+// 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 <FBase.h>
+#include <FApp.h>
+#include <FMsgTypes.h>
+
+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_
--- /dev/null
+//
+// 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 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 <FBase.h>
+#include <FMsgTypes.h>
+#include <FMsgEmailAttachment.h>
+
+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, /**<unspecified */
+ EMAIL_MESSAGE_CLASS_UNKNOWN, /**<unknown */
+ EMAIL_MESSAGE_CLASS_NOTE, /**<Normal email message */
+ EMAIL_MESSAGE_CLASS_NOTE_RULES_OOF_TEMPLATE_MICROSOFT, /**<Out-of-office template */
+ EMAIL_MESSAGE_CLASS_NOTE_SMIME, /**<The message is encrypted and can also be signed */
+ EMAIL_MESSAGE_CLASS_NOTE_SMIME_MULTIPART_SIGNED, /**<The message is clear signed */
+ EMAIL_MESSAGE_CLASS_NOTIFICATION_MEETING, /**<Meeting notification */
+ EMAIL_MESSAGE_CLASS_OCTEL_VOICE, /**<Octel voice message */
+ EMAIL_MESSAGE_CLASS_SCHEDULE_MEETING_REQUEST, /**<Meeting request */
+ EMAIL_MESSAGE_CLASS_SCHEDULE_MEETING_CANCELLED, /**<Meeting cancelled */
+ EMAIL_MESSAGE_CLASS_SCHEDULE_MEETING_POSITIVE_RESPONSE, /**<Positive meeting response */
+ EMAIL_MESSAGE_CLASS_SCHEDULE_MEETING_TENTATIVE_RESPONSE, /**<Tentative meeting response */
+ EMAIL_MESSAGE_CLASS_SCHEDULE_MEETING_NEGATIVE_RESPONSE, /**<Negative meeting response */
+ EMAIL_MESSAGE_CLASS_POST, /**<Post */
+ EMAIL_MESSAGE_CLASS_INFO_PATH_FORM, /**<An InfoPath form */
+ EMAIL_MESSAGE_CLASS_VOICE_NOTES, /**<Electronic voice notes */
+ EMAIL_MESSAGE_CLASS_SHARING, /**<Shared message */
+ //EMAIL_MESSAGE_CLASS_NOTE_EXCHANGE_ACTIVE_SYNC_REMOTE_WIPE_CONFIRMATION, // should be added
+ EMAIL_MESSAGE_CLASS_VOICE_MAIL, /**<Voice mail */
+ //EMAIL_MESSAGE_CLASS_SMS,
+ //EMAIL_MESSAGE_CLASS_SMART_REPLY = 0x01000000,
+ //EMAIL_MESSAGE_CLASS_SMART_FORWARD = 0x02000000,
+ EMAIL_MESSAGE_CLASS_REPORT_NOT_READ_REPORT = 0x10000000, /**<Not read report for a standard message */
+ EMAIL_MESSAGE_CLASS_REPORT_READ_REPORT = 0x20000000, /**<Read report for a standard message */
+ EMAIL_MESSAGE_CLASS_REPORT_NON_DELIVERY_RECEIPT = 0x40000000, /**<Non-delivery report for a standard message */
+ EMAIL_MESSAGE_CLASS_REPORT_DELIVERY_RECEIPT = 0x80000000 /**<Delivery receipt for a standard message */
+};
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * @enum EmailDigestType
+ *
+ * Defines the digest type of the email messages.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @endif
+ */
+ enum EmailDigestType
+ {
+ EMAIL_DIGEST_TYPE_MD5 = 0, /**<The MD5 type */
+ EMAIL_DIGEST_TYPE_SHA1 /**<The SHA-1 type */
+ };
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * @enum EmailSmimeType
+ *
+ * Defines the S/MIME type of the email messages.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @endif
+ */
+ enum EmailSmimeType
+ {
+ EMAIL_SMIME_TYPE_NONE = 0, /**<The undefined type */
+ EMAIL_SMIME_TYPE_SIGNED, /**<The signed type */
+ EMAIL_SMIME_TYPE_ENCRYPTED, /**<The encrypted type */
+ EMAIL_SMIME_TYPE_SIGNED_AND_ENCRYPTED /**<Both signed and encrypted type */
+ };
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * @enum EmailReturnReceiptType
+ *
+ * Defines the return receipt type for an email message.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @endif
+ */
+ enum EmailReturnReceiptType
+ {
+ EMAIL_RETURN_RECEIPT_TYPE_NONE = 0x00, /**<Normal Mail */
+ EMAIL_RETURN_RECEIPT_TYPE_REQUEST = 0x03, /**<MDN-requesting mail*/ // should be deprecated
+ EMAIL_RETURN_RECEIPT_TYPE_DSN = 0x04, /**<Delivery Status Notification (DSN - Delivery Status Mail)*/
+ EMAIL_RETURN_RECEIPT_TYPE_MDN = 0x08, /**<Message Disposition Notification (MDN - Read Status Mail)*/
+ //EMAIL_RETURN_RECEIPT_TYPE_REQUEST_DSN = 0x10,
+ //EMAIL_RETURN_RECEIPT_TYPE_REQUEST_MDN = 0x20,
+ };
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * @enum EmailMessageBodyType
+ *
+ * Defines the type of an email message body.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @endif
+ */
+ enum EmailMessageBodyType
+ {
+ EMAIL_MESSAGE_BODY_TYPE_PLAIN_TEXT = 0, /**<The plain text type */
+ EMAIL_MESSAGE_BODY_TYPE_HTML, /**<The HTML type */
+ EMAIL_MESSAGE_BODY_TYPE_MIME /**<The MIME type */
+ };
+
+
+ // forward declaration
+ class _DetailedEmailMessageImpl;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * @class DetailedEmailMessage
+ * @brief This class provides methods for handling detailed email messages.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * The %DetailedEmailMessage class provides methods for handling detailed email messages.
+ *
+ * @endif
+ */
+ class _OSP_EXPORT_ DetailedEmailMessage
+ : public Tizen::Base::Object
+ {
+ // Life cycle
+ public:
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * This is the default constructor for this class.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @endif
+ */
+ DetailedEmailMessage(void);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * This is the destructor for this class.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @endif
+ */
+ virtual ~DetailedEmailMessage(void);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * This is the copy constructor for the %DetailedEmailMessage class. @n
+ * Copying of objects using this copy constructor is allowed.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @param[in] rhs An instance of %DetailedEmailMessage
+ *
+ * @endif
+ */
+ DetailedEmailMessage(const DetailedEmailMessage& rhs);
+
+
+ public:
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Assigns the value of the specified instance to the current instance of %DetailedEmailMessage. @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 %DetailedEmailMessage
+ *
+ * @endif
+ */
+ DetailedEmailMessage& operator =(const DetailedEmailMessage& 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 %DetailedEmailMessage 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;
+
+ // Operation
+ public:
+ ///////////////////////////////////////////////////////////////
+ // Getters
+ ///////////////////////////////////////////////////////////////
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the message ID.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return The message ID
+ * @see SetMessageId()
+ *
+ * @endif
+ */
+ Tizen::Base::String GetMessageId(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the subject of an email message.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return The subject of an email message
+ * @see SetSubject()
+ *
+ * @endif
+ */
+ Tizen::Base::String GetSubject(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the time when an email message is created.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return The time when an email message is created
+ * @remarks The creation time may be updated by mail server when an email is sent.
+ * @see SetCreationTime()
+ *
+ * @endif
+ */
+ Tizen::Base::DateTime GetCreationTime(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the email address of the specific recipient type.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return The email address of the specific recipient type
+ * @param[in] type The type of recipient
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c type is invalid.
+ * @remarks The values for the various recipients can be a string with multiple email addresses separated by semi-colons(;). @n
+ * The specified @c type contains RECIPIENT_TYPE_TO, RECIPIENT_TYPE_CC, RECIPIENT_TYPE_BCC. @n
+ * The specific error code can be accessed using the GetLastResult() method.
+ * @see SetAddress()
+ *
+ * @endif
+ */
+ Tizen::Base::String GetAddress(RecipientType type) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the email address of an author.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return The email address of an author
+ * @see SetFromAddress()
+ *
+ * @endif
+ */
+ Tizen::Base::String GetFromAddress(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the email address used to reply to a message.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return The email address used to reply to a message
+ * @see SetReplyToAddress()
+ *
+ * @endif
+ */
+ Tizen::Base::String GetReplyToAddress(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the return path.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return The return path
+ * @see SetReturnPath()
+ *
+ * @endif
+ */
+ Tizen::Base::String GetReturnPath(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the file path of the specified message body type.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return The file path of the message body
+ * @param[in] type The type of message body
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c type is invalid.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @see SetFilePath()
+ *
+ * @endif
+ */
+ Tizen::Base::String GetFilePath(EmailMessageBodyType type) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the priority of a message.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return The priority of a message
+ * @see SetPriority()
+ *
+ * @endif
+ */
+ EmailMessagePriority GetPriority(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the return receipt type of a message.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return The return receipt type of a message
+ * @see SetReturnReceiptType()
+ *
+ * @endif
+ */
+ EmailReturnReceiptType GetReturnReceiptType(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the inline content count of a message.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return The inline content count of a message
+ * @see SetInlineContentCount()
+ *
+ * @endif
+ */
+ int GetInlineContentCount(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the class of a message.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return The class of a message
+ * @see SetClass()
+ *
+ * @endif
+ */
+ EmailMessageClass GetClass(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the digest type of a message.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return The digest type of the message
+ * @see SetDigestType()
+ *
+ * @endif
+ */
+ EmailDigestType GetDigestType(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the S/MIME type of a message.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return The S/MIME type of a message
+ * @see SetSmimeType()
+ *
+ * @endif
+ */
+ EmailSmimeType GetSmimeType(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the attachment list of this message.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return A pointer to the attachment list
+ * @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
+ * After using the attachment list, you can call Tizen::Base::Collection::IList::RemoveAll(true) to clean up items in the list.
+ * @see EmailAttachment
+ * @see SetAttachmentList()
+ *
+ * @endif
+ */
+ Tizen::Base::Collection::IList* GetAttachmentListN(void);
+
+
+ public:
+ ///////////////////////////////////////////////////////////////
+ // Setters
+ ///////////////////////////////////////////////////////////////
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the message ID.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] messageId The message ID
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The length of the specified @c messageId is @c 0.
+ * @remarks The message ID is an automatically generated field. @n
+ * It is used to prevent multiple delivery and for reference in In-Reply-To.
+ * @see GetMessageId()
+ *
+ * @endif
+ */
+ result SetMessageId(const Tizen::Base::String& messageId);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the subject of an email message.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] subject The subject of the email message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_MAX_EXCEEDED The subject length of the message exceeds the maximum limit (Maximum 256 characters).
+ * @see GetSubject()
+ *
+ * @endif
+ */
+ result SetSubject(const Tizen::Base::String& subject);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the time when an email message is created.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] dateTime The time when the email message is created
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c dateTime is invalid. @n
+ * The valid range of the time can be from "January 1 1900 00:00:00" to "December 31 2100 23:59:59".
+ * @see GetCreationTime()
+ *
+ * @endif
+ */
+ result SetCreationTime(const Tizen::Base::DateTime& dateTime);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the recipient list of the specific recipient type.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] type The type of recipient
+ * @param[in] recipients The recipients string
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c type is invalid, or
+ * the specified @c recipients string length is too short (< 5).
+ * @remarks The values for the various recipients can be a string with multiple email addresses separated by semi-colons(;).@n
+ * The specified @c type contains RECIPIENT_TYPE_TO, RECIPIENT_TYPE_CC, RECIPIENT_TYPE_BCC.
+ * @see GetAddress()
+ *
+ * @endif
+ */
+ result SetAddress(RecipientType type, const Tizen::Base::String& recipients);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the email address of an author.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] address The email address of the author
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c address string length is too short (< 5).
+ * @see GetFromAddress()
+ *
+ * @endif
+ */
+ result SetFromAddress(const Tizen::Base::String& address);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the email address used to reply to a message.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] address The email address used to reply to the message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c address string length is too short (< 5).
+ * @see GetReplyToAddress()
+ *
+ * @endif
+ */
+ result SetReplyToAddress(const Tizen::Base::String& address);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the return path.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] address The return path
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c address string length is too short (< 5).
+ * @see GetReturnPath()
+ *
+ * @endif
+ */
+ result SetReturnPath(const Tizen::Base::String& address);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the file path of the specified message body type.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] type The type of message body
+ * @param[in] filePath The file path of the message body
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c type is invalid, or
+ * 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(EmailMessageBodyType type, const Tizen::Base::String& filePath);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the priority of a message.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] priority The priority of the message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c priority is invalid.
+ * @see GetPriority()
+ *
+ * @endif
+ */
+ result SetPriority(EmailMessagePriority priority);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the return receipt type of a message.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] type The return receipt type of the message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c type is invalid.
+ * @see GetReturnReceiptType()
+ *
+ * @endif
+ */
+ result SetReturnReceiptType(EmailReturnReceiptType type);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the inline content count of a message.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] count The inline content count of the message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c count is less than @c 0.
+ * @see GetInlineContentCount()
+ *
+ * @endif
+ */
+ result SetInlineContentCount(int count);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the class of a message.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] messageClass The class of the message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c messageClass is invalid.
+ * @see GetClass()
+ *
+ * @endif
+ */
+ result SetClass(EmailMessageClass messageClass);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the digest type of a message.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] type The digest type of the message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c type is invalid.
+ * @see GetDigestType()
+ *
+ * @endif
+ */
+ result SetDigestType(EmailDigestType type);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the S/MIME type of a message.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] type The S/MIME type of the message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c type is invalid.
+ * @see GetSmimeType()
+ *
+ * @endif
+ */
+ result SetSmimeType(EmailSmimeType type);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the attachment list for this message.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] pList A list of EmailAttachment
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The list is not made of EmailAttachment.
+ * @see EmailAttachment
+ * @see GetAttachmentListN()
+ *
+ * @endif
+ */
+ result SetAttachmentList(const Tizen::Base::Collection::IList* pList);
+
+
+ ///////////////////////////////////////////////////////////////
+ // static methods
+ ///////////////////////////////////////////////////////////////
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Parses the MIME file to %DetailedEmailMessage format.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] filePath The MIME file path to parse
+ * @param[out] message The parsed message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
+ * @exception E_PARSING_FAILED The method has failed to parse the MIME file.
+ * @exception E_SYSTEM A system error has occurred.
+ * @see WriteToMimeFile()
+ *
+ * @endif
+ */
+ static result ParseMimeFile(const Tizen::Base::String& filePath, DetailedEmailMessage& message);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Writes to the MIME file from %DetailedEmailMessage.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] message The message to read
+ * @param[in] filePath The file path of the MIME file to write
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The value of the specified @c message is invalid. @n
+ * (The subject, body, recipients and from address field of the message are all empty.)
+ * @exception E_ILLEGAL_ACCESS The specified @c filePath is inaccessible as per the Tizen platform policy.
+ * @exception E_FILE_ALREADY_EXIST The specified file already exists.
+ * @exception E_SYSTEM A system error has occurred.
+ * @see ParseMimeFile()
+ *
+ * @endif
+ */
+ static result WriteToMimeFile(const DetailedEmailMessage& message, const Tizen::Base::String& filePath);
+
+
+
+ private:
+ _DetailedEmailMessageImpl* __pImpl;
+
+ // friend class
+ friend class _DetailedEmailMessageImpl;
+ }; // DetailedEmailMessage
+} } // Tizen::Messaging
+
+#endif // _FMSG_DETAILED_EMAIL_MESSAGE_H_
--- /dev/null
+//
+// 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 FMsgEmailAttachment.h
+* @brief This is the header file for the %EmailAttachment class.
+*
+* @visibility partner-operator
+*
+* This header file contains the declarations of the %EmailAttachment class.
+*
+* @endif
+*/
+
+#ifndef _FMSG_EMAIL_ATTACHMENT_H_
+#define _FMSG_EMAIL_ATTACHMENT_H_
+
+#include <FBase.h>
+#include <FMsgTypes.h>
+
+namespace Tizen { namespace Messaging
+{
+ // forward declaration
+ 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
+ {
+ // 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;
+
+ // Operation
+ public:
+ ///////////////////////////////////////////////////////////////
+ // 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;
+
+
+ public:
+ ///////////////////////////////////////////////////////////////
+ // 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);
+
+ private:
+ _EmailAttachmentImpl* __pImpl;
+
+ // friend class
+ friend class _EmailAttachmentImpl;
+ }; // EmailAttachment
+} } // Tizen::Messaging
+
+#endif // _FMSG_EMAIL_ATTACHMENT_H_
--- /dev/null
+//
+// 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 FMsgEmailManager.h
+ * @brief This is the header file for the %EmailManager class.
+ *
+ * This header file contains the declarations of the %EmailManager class.
+ */
+
+#ifndef _FMSG_EMAIL_MANAGER_H_
+#define _FMSG_EMAIL_MANAGER_H_
+
+#include <FBase.h>
+#include <FMsgIEmailListener.h>
+#include <FMsgEmailMessage.h>
+#include <FMsgRecipientList.h>
+
+namespace Tizen { namespace Messaging
+{
+ // forward declaration for class extension
+ class _EmailManagerImpl;
+
+ /**
+ * @class EmailManager
+ * @brief This class provides methods to use the email messaging service.
+ *
+ * @since 2.0
+ *
+ * The %EmailManager class is used to send email messages.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/messaging.htm">Messaging Guide</a>.
+ *
+ * The following example demonstrates how to use the %EmailManager class.
+ *
+ * @code
+ *
+ // Creates a listener to override the OnEmailMessageSent() function of IEmailListener
+ // in order to be notified of a change in the state of the message being sent.
+
+ class EmailListener
+ : public IEmailListener
+ , public Object
+ {
+ public:
+ void OnEmailMessageSent(result r);
+ };
+
+ void
+ EmailListener::OnEmailMessageSent(result r)
+ {
+ // Do something
+ }
+
+ class SendEmailMessage
+ : public Object
+ {
+ public:
+ void EmailTest(void);
+ };
+
+ void
+ SendEmailMessage::EmailTest(void)
+ {
+ result r = E_SUCCESS;
+
+ // Creates an EmailListener instance.
+ EmailListener* pListener = new EmailListener();
+
+ // Creates an %EmailManager instance with the listener as the callback to check the status of the message being sent.
+ EmailManager* pEmailManager = new EmailManager();
+ r = pEmailManager->Construct(*pListener);
+
+ // Creates a recipient list instance and adds recipients.
+ RecipientList recipient;
+ r = recipient.Add (RECIPIENT_TYPE_TO, L"test10@tizen.org");
+ r = recipient.Add (RECIPIENT_TYPE_CC, L"test09@tizen.org");
+ r = recipient.Add (RECIPIENT_TYPE_BCC, L"test08@tizen.org");
+
+ // Creates a email message instance.
+ EmailMessage emailMessage;
+ r = emailMessage.SetSubject(L"Subject!!!");
+ r = emailMessage.SetText(L"Hello, World");
+ r = emailMessage.AddAttachment(L"/Home/Res/testfile.dat");
+
+ // Sends the message, and sets the @c saveToSentbox parameter to true if the message should be saved in the Sentbox; otherwise, set to false.
+ // EmailListener callback is called once the message is completely sent.
+ r = pEmailManager->Send(emailMessage, recipient, true);
+ }
+ *
+ * @endcode
+ */
+ class _OSP_EXPORT_ EmailManager
+ : public Tizen::Base::Object
+ {
+ // Life cycle
+ public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.0
+ */
+ EmailManager(void);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.0
+ */
+ virtual ~EmailManager(void);
+
+ private:
+ EmailManager(const EmailManager& value);
+ EmailManager& operator =(const EmailManager& rhs);
+
+ // Operation
+ public:
+ /**
+ * Initializes this instance of %EmailManager with the specified parameter.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] listener The listener to receive a send result asynchronously
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ */
+ result Construct(IEmailListener& listener);
+
+ /**
+ * Sends the email message.
+ *
+ * @since 2.0
+ * @privilege %http://tizen.org/privilege/messaging.email
+ *
+ * @return An error code
+ * @param[in] message The message to be sent
+ * @param[in] recipientList The list of recipients
+ * @param[in] saveToSentbox Set to @c true to save the message in the Sentbox, @n
+ * else @c false
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_ON_INITIALIZING The mailbox is not completely loaded as yet.
+ * @exception E_STORAGE_FULL The storage is full.
+ * @exception E_DEVICE_UNAVAILABLE The device is unavailable.
+ * @exception E_NETWORK_UNAVAILABLE The network is unavailable.
+ * @exception E_INVALID_ACCOUNT The email account is not set.
+ * @exception E_INVALID_CONDITION The profile is not set.
+ * @exception E_INVALID_ADDRESS The address is invalid.
+ * @exception E_FDN_MODE The FDN mode has been activated.
+ * @exception E_INVALID_ARG The number of recipients is @c 0.
+ * @exception E_MAX_EXCEEDED The number of recipients has crossed the maximum limit (Maximum 20).
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @remarks The value of the flag, @c saveToSentbox, is fixed to @c false in the emulator.
+ * @see IEmailListener::OnEmailMessageSent()
+ */
+ result Send(const EmailMessage& message, const RecipientList& recipientList, bool saveToSentbox);
+
+ private:
+ _EmailManagerImpl* __pImpl;
+
+ // friend class
+ friend class _EmailManagerImpl;
+ }; // EmailManager
+} } // Tizen::Messaging
+
+#endif // _FMSG_EMAIL_MANAGER_H_
--- /dev/null
+//
+// 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 FMsgEmailMessage.h
+ * @brief This is the header file for the %EmailMessage class.
+ *
+ * This header file contains the declarations of the %EmailMessage class.
+ */
+
+#ifndef _FMSG_EMAIL_MESSAGE_H_
+#define _FMSG_EMAIL_MESSAGE_H_
+
+#include <FBase.h>
+
+namespace Tizen { namespace Messaging
+{
+ class _EmailMessageImpl;
+
+ /**
+ * @class EmailMessage
+ * @brief This class provides methods for handling email messages.
+ *
+ * @since 2.0
+ *
+ * The %EmailMessage class provides methods for handling email messages.
+ * It allows you to set the subject and body text of an email message,
+ * and add or remove the files sent as email attachments.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/messaging.htm">Messaging Guide</a>.
+ */
+ class _OSP_EXPORT_ EmailMessage
+ : public Tizen::Base::Object
+ {
+ // Life cycle
+ public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.0
+ */
+ EmailMessage(void);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.0
+ */
+ virtual ~EmailMessage(void);
+
+ /**
+ * This is the copy constructor for the %EmailMessage class.
+ *
+ * @since 2.0
+ *
+ * @param[in] value An instance of %EmailMessage
+ */
+ EmailMessage(const EmailMessage& value);
+
+
+ public:
+ /**
+ * This assignment operator copies an email message from the specified instance of %EmailMessage to the calling instance of %EmailMessage.
+ *
+ * @since 2.0
+ *
+ * @return The reference of this instance
+ * @param[in] rhs A reference to the %EmailMessage instance to be copied
+ */
+ EmailMessage& operator =(const EmailMessage& rhs);
+
+ /**
+ * 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 %EmailMessage instance, @n
+ * else @c false
+ * @param[in] obj The object to compare
+ */
+ virtual bool Equals(const Tizen::Base::Object& obj) 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;
+
+ // Operation
+ public:
+ /**
+ * Sets the subject of the email.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] subject The subject of the message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_MAX_EXCEEDED The subject length of the message exceeds the maximum limit (Maximum 256 characters),
+ * or the total size of the subject, body, and attachment(s) exceeds the maximum limit (5MB).
+ * @see GetSubject()
+ */
+ result SetSubject(const Tizen::Base::String& subject);
+
+ /**
+ * Sets the body of the message.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] text The body of the message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_MAX_EXCEEDED The body length of the message exceeds the maximum limit (Maximum 2000 characters),
+ * or the total size of the subject, body, and attachment(s) exceeds the maximum limit (5MB).
+ * @see GetText()
+ */
+ result SetText(const Tizen::Base::String& text);
+ /**
+ * Adds a file attachment to the email.
+ *
+ * @if OSPCOMPAT
+ * @brief <i> [Compatibility] </i>
+ * @endif
+ * @since 2.0
+ * @if OSPCOMPAT
+ * @compatibility This method has compatibility issues with OSP compatible applications. @n
+ * For more information, see @ref CompIoPathPage "here".
+ * @endif
+ *
+ * @return An error code
+ * @param[in] filePath The path of the file to attach
+ * @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.
+ * @exception E_FILE_ALREADY_EXIST The file is already attached.
+ * @exception E_MAX_EXCEEDED The total size of the subject, body, and attachment(s) exceeds the maximum limit (5MB), or
+ * the number of attachments exceeds the limit (20 files). @n
+ * The total size of attachments must not exceed 5MB, and the total number of attached files must not exceed 20 files.
+ * @see GetAttachmentListN()
+ */
+ result AddAttachment(const Tizen::Base::String& filePath);
+
+
+ /**
+ * Removes an attachment from an email.
+ *
+ * @if OSPCOMPAT
+ * @brief <i> [Compatibility] </i>
+ * @endif
+ * @since 2.0
+ * @if OSPCOMPAT
+ * @compatibility This method has compatibility issues with OSP compatible applications. @n
+ * For more information, see @ref CompIoPathPage "here".
+ * @endif
+ *
+ * @return An error code
+ * @param[in] filePath The path of the file to be removed
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_FILE_NOT_FOUND The corresponding format file is not found.
+ * @see AddAttachment(), GetAttachmentListN()
+ */
+ result RemoveAttachment(const Tizen::Base::String& filePath);
+
+ /**
+ * Gets the subject of the message.
+ *
+ * @since 2.0
+ *
+ * @return The subject of the message
+ * @see SetSubject()
+ */
+ Tizen::Base::String GetSubject(void) const;
+
+ /**
+ * Gets the body of the message.
+ *
+ * @since 2.0
+ *
+ * @return The body of the message
+ * @see SetText()
+ */
+ Tizen::Base::String GetText(void) const;
+
+ /**
+ * Gets the list of attachments for the email.
+ *
+ * @since 2.0
+ *
+ * @return The list of the attached files
+ * @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.
+ * @see AddAttachment()
+ */
+ Tizen::Base::Collection::IList* GetAttachmentListN(void) const;
+
+ private:
+ _EmailMessageImpl* __pImpl;
+
+ // friend class
+ friend class _EmailMessageImpl;
+ }; // EmailMessage
+} } // Tizen::Messaging
+
+#endif // _FMSG_EMAIL_MESSAGE_H_
--- /dev/null
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+/**\r
+* @if VISPARTNER-OPERATOR\r
+*\r
+* @file FMsgEtwsPrimaryNotification.h\r
+* @brief This is the header file for the %EtwsPrimaryNotification class.\r
+*\r
+* @visibility partner-operator\r
+*\r
+* This header file contains the declarations of the %EtwsPrimaryNotification class.\r
+*\r
+* @endif\r
+*/\r
+\r
+#ifndef _FMSG_ETWS_PRIMARY_NOTIFICATION_H_\r
+#define _FMSG_ETWS_PRIMARY_NOTIFICATION_H_\r
+\r
+#include <FBase.h>\r
+#include <FApp.h>\r
+#include <FMsgTypes.h>\r
+\r
+namespace Tizen { namespace Messaging\r
+{\r
+\r
+class _EtwsPrimaryNotificationImpl;\r
+\r
+/**\r
+* @if VISPARTNER-OPERATOR\r
+*\r
+* @class EtwsPrimaryNotification\r
+*\r
+* @brief This class provides methods for handling an ETWS primary notification.\r
+*\r
+* @since 2.0\r
+*\r
+* @final This class is not intended for extension.\r
+*\r
+* @visibility partner-operator\r
+*\r
+* The %EtwsPrimaryNotification class provides methods for handling an ETWS primary notification. It allows you to get the serial number,\r
+* message ID, warning type, warning security info, and received time of an ETWS primary notification.\r
+*\r
+* @endif\r
+*/\r
+class _OSP_EXPORT_ EtwsPrimaryNotification\r
+ : public Tizen::Base::Object\r
+{\r
+public:\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * This destructor overrides Tizen::Base::Object::~Object().\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @endif\r
+ */\r
+ virtual ~EtwsPrimaryNotification(void);\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Compares the specified instance of %EtwsPrimaryNotification with the calling instance.\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return @c true if the values match, @n\r
+ * else @c false\r
+ * @param[in] obj The other Tizen::Base::Object to be compared\r
+ * @see Tizen::Base::Object::Equals()\r
+ *\r
+ * @endif\r
+ */\r
+ virtual bool Equals(const Tizen::Base::Object& obj) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the copied instance of the class.\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return An instance of %EtwsPrimaryNotification\r
+ * @exception E_SUCCESS The method is successful.\r
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.\r
+ *\r
+ * @remarks In case of error, this method returns @c null. @n\r
+ * The specific error code can be accessed using the GetLastResult() method.\r
+ *\r
+ * @endif\r
+ */\r
+ EtwsPrimaryNotification* CloneN(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the hash value of the current instance.\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return The current instance's hash value\r
+ *\r
+ * @endif\r
+ */\r
+ virtual int GetHashCode(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the date and time (UTC time) of the message when it is received.\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return The date and time (UTC time) when the message is received\r
+ *\r
+ * @endif\r
+ */\r
+ Tizen::Base::DateTime GetReceivedTime(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the serial number of the ETWS primary notification.\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return The serial number of the ETWS primary notification\r
+ * @exception E_SUCCESS The method is successful.\r
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.\r
+ * @remarks The specific error code can be accessed using the GetLastResult() method. @n\r
+ * In case of an error, this method returns null.\r
+ *\r
+ * @endif\r
+ */\r
+ Tizen::Base::ByteBuffer* GetSerialNumberN(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the message ID of the ETWS primary notification.\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return The message ID of the ETWS primary notification\r
+ *\r
+ * @endif\r
+ */\r
+ int GetMessageId(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the warning type.\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return The ETWS warning type of the message\r
+ *\r
+ * @endif\r
+ */\r
+ Tizen::Base::ByteBuffer* GetWarningTypeN(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the warning security information of the ETWS primary notification.\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return The warning security information of the ETWS primary notification\r
+ * @exception E_SUCCESS The method is successful.\r
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.\r
+ * @remarks The specific error code can be accessed using the GetLastResult() method. @n\r
+ * In case of an error, this method returns null.\r
+ * @endif\r
+ */\r
+ Tizen::Base::ByteBuffer* GetWarningSecurityInfoN(void) const;\r
+\r
+private:\r
+ /**\r
+ * This default constructor is intentionally declared as private so that only the platform can create an instance.\r
+ *\r
+ * @since 2.0\r
+ */\r
+ EtwsPrimaryNotification(void);\r
+\r
+ /**\r
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @param[in] rhs An instance of EtwsPrimaryNotification\r
+ */\r
+ EtwsPrimaryNotification(const EtwsPrimaryNotification& rhs);\r
+\r
+ /**\r
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. @n\r
+ * - Use CloneN() to get an exact copy of the instance.\r
+ * - Use Equals() to compare the contents of one instance with the other.\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @return A reference to this instance\r
+ * @param[in] rhs An instance of EtwsPrimaryNotification\r
+ */\r
+ EtwsPrimaryNotification& operator =(const EtwsPrimaryNotification& rhs);\r
+\r
+private:\r
+ _EtwsPrimaryNotificationImpl* __pEtwsPrimaryNotificationImpl;\r
+\r
+ friend class _EtwsPrimaryNotificationImpl;\r
+}; // EtwsPrimaryNotification\r
+\r
+} } // Tizen::Messaging\r
+#endif // _FMSG_ETWS_PRIMARY_NOTIFICATION_H_\r
--- /dev/null
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+/**\r
+* @if VISPARTNER-OPERATOR\r
+*\r
+* @file FMsgICbsMessageEventListener.h\r
+* @brief This is the header file for the %ICbsMessageEventListener interface.\r
+*\r
+* This header file contains the declarations of the %ICbsMessageEventListener interface.\r
+*\r
+* @visibility partner-operator\r
+*\r
+* @endif\r
+*/\r
+\r
+#ifndef _FMSG_ICBS_MESSAGE_EVENT_LISTENER_H_\r
+#define _FMSG_ICBS_MESSAGE_EVENT_LISTENER_H_\r
+\r
+#include <FBase.h>\r
+\r
+namespace Tizen { namespace Messaging\r
+{\r
+ class CbsMessage;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * @interface ICbsMessageEventListener\r
+ * @brief This is the listener interface for receiving CBS messages.\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * The %ICbsMessageEventListener interface must be implemented to handle incoming CBS messages. An application must register this interface using the SmsManager::SetCbsMessageEventListener() method.\r
+ *\r
+ * @endif\r
+ */\r
+ class _OSP_EXPORT_ ICbsMessageEventListener\r
+ : virtual public Tizen::Base::Runtime::IEventListener\r
+ {\r
+ public:\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * This polymorphic destructor should be overridden if required. @n\r
+ * This way, the destructors of the derived classes are called when the destructor of this interface is called.\r
+\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @endif\r
+ */\r
+ virtual ~ICbsMessageEventListener(void) {}\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Called when a CBS message is received.\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @param[in] message The message that is received\r
+ * @see SmsManager::SetCbsMessageEventListener()\r
+ *\r
+ * @endif\r
+ */\r
+ virtual void OnCbsMessageReceived(const CbsMessage& message) = 0;\r
+\r
+ protected:\r
+ //\r
+ // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.\r
+ //\r
+ // This method is reserved and may change its name at any time without prior notice.\r
+ //\r
+ // @since 2.0\r
+ //\r
+ virtual void ICbsMessageEventListener_Reserved1(void) {}\r
+\r
+ //\r
+ // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.\r
+ //\r
+ // This method is reserved and may change its name at any time without prior notice.\r
+ //\r
+ // @since 2.0\r
+ //\r
+ virtual void ICbsMessageEventListener_Reserved2(void) {}\r
+ }; // ICbsMessageEventListener\r
+} } // Tizen::Messaging\r
+#endif // _FMSG_ICBS_MESSAGE_EVENT_LISTENER_H_\r
--- /dev/null
+//
+// 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 FMsgIEmailListener.h
+ * @brief This is the header file for the %IEmailListener interface.
+ *
+ * This header file contains the declarations of the %IEmailListener interface.
+ */
+
+#ifndef _FMSG_IEMAIL_EVENT_LISTENER_H_
+#define _FMSG_IEMAIL_EVENT_LISTENER_H_
+
+// Includes
+#include <FBase.h>
+#include <FMsgTypes.h>
+
+namespace Tizen { namespace Messaging
+{
+
+ /**
+ * @interface IEmailListener
+ * @brief This is the listener interface for receiving email sent status.
+ *
+ * @since 2.0
+ *
+ * The %IEmailListener interface must be implemented to receive the status of the sent email messages asynchronously. An application must register this interface using the EmailManager::Construct() method.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/messaging.htm">Messaging Guide</a>.
+ */
+ class _OSP_EXPORT_ IEmailListener
+ : virtual public Tizen::Base::Runtime::IEventListener
+ {
+ // Lifecycle
+ public:
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.0
+ */
+ virtual ~IEmailListener(void) {}
+
+ // Operation
+ public:
+ /**
+ * Called when the email message is sent.
+ *
+ * @since 2.0
+ *
+ * @param[in] r The result of sending the email message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_FAILURE The method has failed to send the message.
+ * @see EmailManager::Send()
+ */
+ virtual void OnEmailMessageSent(result r) = 0;
+
+ protected:
+ //
+ // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+ //
+ // This method is reserved and may change its name at any time without prior notice.
+ //
+ // @since 2.0
+ //
+ virtual void IEmailListener_Reserved1(void) {}
+
+ //
+ // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+ //
+ // This method is reserved and may change its name at any time without prior notice.
+ //
+ // @since 2.0
+ //
+ virtual void IEmailListener_Reserved2(void) {}
+ }; // IEmailListener
+} } // Tizen::Messaging
+
+#endif // _FMSG_IEMAIL_EVENT_LISTENER_H_
--- /dev/null
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+/**\r
+* @if VISPARTNER-OPERATOR\r
+*\r
+* @file FMsgIEtwsPrimaryNotificationEventListener.h\r
+* @brief This is the header file for the %IEtwsPrimaryNotificationEventListener interface.\r
+*\r
+* This header file contains the declarations of the %IEtwsPrimaryNotificationEventListener interface.\r
+*\r
+* @visibility partner-operator\r
+*\r
+* @endif\r
+*/\r
+\r
+#ifndef _FMSG_IETWS_PRIMARY_NOTIFICATION_EVENT_LISTENER_H_\r
+#define _FMSG_IETWS_PRIMARY_NOTIFICATION_EVENT_LISTENER_H_\r
+\r
+#include <FMsgICbsMessageEventListener.h>\r
+\r
+namespace Tizen { namespace Messaging\r
+{\r
+ class EtwsPrimaryNotification;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * @interface IEtwsPrimaryNotificationEventListener\r
+ * @brief This is the listener interface for receiving ETWS primary notification.\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * The %IEtwsPrimaryNotificationEventListener interface must be implemented to handle incoming ETWS primary notification.\r
+ * An application must register this interface using the SmsManager::SetEtwsPrimaryNotificationEventListener() method.\r
+ *\r
+ * @endif\r
+ */\r
+ class _OSP_EXPORT_ IEtwsPrimaryNotificationEventListener\r
+ : virtual public Tizen::Messaging::ICbsMessageEventListener\r
+ {\r
+ public:\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * This polymorphic destructor should be overridden if required. @n\r
+ * This way, the destructors of the derived classes are called when the destructor of this interface is called.\r
+\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @endif\r
+ */\r
+ virtual ~IEtwsPrimaryNotificationEventListener(void) {}\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Called when the ETWS primary notification is received.\r
+ *\r
+ * @since 2.0\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @param[in] message The ETWS primary notification that is received\r
+ * @see SmsManager::SetEtwsPrimaryNotificationEventListener()\r
+ *\r
+ * @endif\r
+ */\r
+ virtual void OnEtwsPrimaryNotificationReceived(const EtwsPrimaryNotification& message) = 0;\r
+\r
+ protected:\r
+ //\r
+ // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.\r
+ //\r
+ // This method is reserved and may change its name at any time without prior notice.\r
+ //\r
+ // @since 2.0\r
+ //\r
+ virtual void IEtwsPrimaryNotificationEventListener_Reserved1(void) {}\r
+\r
+ //\r
+ // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.\r
+ //\r
+ // This method is reserved and may change its name at any time without prior notice.\r
+ //\r
+ // @since 2.0\r
+ //\r
+ virtual void IEtwsPrimaryNotificationEventListener_Reserved2(void) {}\r
+ }; // IEtwsPrimaryNotificationEventListener\r
+} } // Tizen::Messaging\r
+#endif // _FMSG_IETWS_PRIMARY_NOTIFICATION_EVENT_LISTENER_H_\r
--- /dev/null
+//
+// 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 FMsgIMmsListener.h
+ * @brief This is the header file for the %IMmsListener interface.
+ *
+ * This header file contains the declarations of the %IMmsListener interface.
+ */
+
+#ifndef _FMSG_IMMS_LISTENER_H_
+#define _FMSG_IMMS_LISTENER_H_
+
+// Includes
+#include <FBase.h>
+#include <FMsgTypes.h>
+
+namespace Tizen { namespace Messaging
+{
+
+
+ /**
+ * @interface IMmsListener
+ * @brief This is the listener interface for receiving MMS sent status.
+ *
+ * @since 2.0
+ *
+ * The %IMmsListener interface must be implemented to receive the status of the sent MMS messages asynchronously. An application must register this interface using the MmsManager::Construct() method.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/messaging.htm">Messaging Guide</a>.
+ */
+ class _OSP_EXPORT_ IMmsListener
+ : virtual public Tizen::Base::Runtime::IEventListener
+ {
+ // Lifecycle
+ public:
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.0
+ */
+ virtual ~IMmsListener(void) {}
+
+ // Operation
+ public:
+ /**
+ * Called when the Multimedia Messaging Service(MMS) message is sent.
+ *
+ * @since 2.0
+ *
+ * @param[in] r The result of sending the MMS message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_CONTENT The content is invalid.
+ * @exception E_NETWORK_UNAVAILABLE The network has a problem.
+ * @exception E_SERVICE_UNAVAILABLE The service is unavailable.
+ * @exception E_INVALID_ADDRESS The address is invalid.
+ * @exception E_FAILURE The method has failed to send the message.
+ * @see MmsManager::Send()
+ */
+ virtual void OnMmsMessageSent(result r) = 0;
+
+ protected:
+ //
+ // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+ //
+ // This method is reserved and may change its name at any time without prior notice.
+ //
+ // @since 2.0
+ //
+ virtual void IMmsListener_Reserved1(void) {}
+
+ //
+ // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+ //
+ // This method is reserved and may change its name at any time without prior notice.
+ //
+ // @since 2.0
+ //
+ virtual void IMmsListener_Reserved2(void) {}
+ }; // IMmsListener
+} } // Tizen::Messaging
+
+#endif // _FMSG_IMMS_LISTENER_H_
--- /dev/null
+//
+// 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 FMsgIPushEventListener.h
+ * @brief This is the header file for the %IPushEventListener interface.
+ *
+ * This header file contains the declaration of the %IPushEventListener interface.
+ */
+
+#ifndef _FMSG_IPUSH_EVENT_LISTENER_H_
+#define _FMSG_IPUSH_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FMsgPushMessage.h>
+
+namespace Tizen { namespace Messaging
+{
+/**
+* @interface IPushEventListener
+* @brief This is the listener interface for receiving push messages.
+*
+* @since 2.0
+*
+* The %IPushEventListener interface must be implemented to receive the push messages. An application must register this interface using the PushManager::Construct() method.
+*/
+class _OSP_EXPORT_ IPushEventListener
+ : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+ /**
+ * 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
+ */
+ virtual ~IPushEventListener(void) {}
+
+public:
+ /**
+ * Called when a push message is received from the server.
+ *
+ * @since 2.0
+ *
+ * @param[in] message The push message
+ */
+ virtual void OnPushMessageReceived(const PushMessage& message) = 0;
+
+protected:
+ //
+ // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+ //
+ // This method is reserved and may change its name at any time without prior notice.
+ //
+ // @since 2.0
+ //
+ virtual void IPushEventListener_Reserved1(void) {}
+
+ //
+ // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+ //
+ // This method is reserved and may change its name at any time without prior notice.
+ //
+ // @since 2.0
+ //
+ virtual void IPushEventListener_Reserved2(void) {}
+}; // IPushEventListener
+
+} } // Tizen::Messaging
+#endif // _FMSG_IPUSH_EVENT_LISTENER_H_
--- /dev/null
+//
+// 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 FMsgIPushManagerListener.h
+ * @brief This is the header file for the %IPushManagerListener interface.
+ *
+ * This header file contains the declarations of the %IPushManagerListener interface.
+ */
+
+#ifndef _FMSG_IPUSH_MANAGER_LISTENER_H_
+#define _FMSG_IPUSH_MANAGER_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace Messaging
+{
+/**
+* @interface IPushManagerListener
+* @brief This listener interface receives the registration result.
+*
+* @since 2.0
+*
+* The %IPushManagerListener interface must be implemented to receive results of the push event registration. An application must register this interface using the PushManager::Construct() method.
+*/
+class _OSP_EXPORT_ IPushManagerListener
+ : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+ /**
+ * 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
+ */
+ virtual ~IPushManagerListener(void) {}
+
+public:
+ /**
+ * Called when the result is received from PushManager::RegisterPushService().
+ *
+ * @since 2.0
+ *
+ * @param[in] reqId The request ID
+ * @param[in] registrationId The registration ID of the device @n
+ * The application must deliver this ID to the application server.
+ * @param[in] r The result of the request
+ * @param[in] errorCode The error code from the server
+ * @param[in] errorMsg The error message from the server
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM An unknown operating system error has occurred.
+ * @exception E_CONNECTION_FAILED The network connection has failed.
+ * @exception E_SERVER An error has occurred on the server side.
+ * @exception E_SERVICE_UNAVAILABLE The service is unavailable. @n
+ * Check whether the push service registration is completed. For more information, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/push_messaging.htm">Push Messaging Guide</a>.
+ * @see PushManager::RegisterPushService()
+ */
+ virtual void OnPushServiceRegistered(RequestId reqId, const Tizen::Base::String& registrationId, result r, const Tizen::Base::String& errorCode, const Tizen::Base::String& errorMsg) = 0;
+
+ /**
+ * Called when the result is received from PushManager::UnregisterPushService().
+ *
+ * @since 2.0
+ *
+ * @param[in] reqId The request ID
+ * @param[in] r The result of the request
+ * @param[in] errorCode The error code from the server
+ * @param[in] errorMsg The error message from the server
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM An unknown operating system error has occurred.
+ * @exception E_CONNECTION_FAILED The network connection has failed.
+ * @exception E_SERVER An error has occurred on the server side.
+ * @see PushManager::UnregisterPushService()
+ */
+ virtual void OnPushServiceUnregistered(RequestId reqId, result r, const Tizen::Base::String& errorCode, const Tizen::Base::String& errorMsg) = 0;
+
+ /**
+ * Called when the result is received from PushManager::SendPushMessage().
+ *
+ * @since 2.0
+ *
+ * @param[in] reqId The request ID
+ * @param[in] registrationId The registration ID of the recipient
+ * @param[in] r The result of the request, @n
+ * Exception code may be given through this parameter.
+ * @param[in] errorCode The error code from the server
+ * @param[in] errorMsg The error message from the server
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_DATA An invalid data is received from the server.
+ * @exception E_CONNECTION_FAILED The network connection has failed.
+ * @exception E_REMOTE_DEVICE_NOT_FOUND The registration ID is invalid, so the recipient is not found.
+ * @exception E_AUTHENTICATION The appSecret is invalid, so application authentication has failed.
+ * @exception E_SERVER An error has occurred on the server side.
+ * @exception E_SERVICE_UNAVAILABLE The service is unavailable. @n
+ * Check whether the push service registration is completed. For more information, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/push_messaging.htm">Push Messaging Guide</a>.
+ * @see PushManager::SendPushMessage()
+ */
+ virtual void OnPushMessageSent(RequestId reqId, const Tizen::Base::String& registrationId, result r, const Tizen::Base::String& errorCode, const Tizen::Base::String& errorMsg) {}
+
+protected:
+ //
+ // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+ //
+ // This method is reserved and may change its name at any time without prior notice.
+ //
+ // @since 2.0
+ //
+ virtual void IPushManagerListener_Reserved2(void) {}
+
+ //
+ // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+ //
+ // This method is reserved and may change its name at any time without prior notice.
+ //
+ // @since 2.0
+ //
+ virtual void IPushManagerListener_Reserved3(void) {}
+}; // IPushManagerListener
+
+} } // Tizen::Messaging
+#endif // _FMSG_IPUSH_MANAGER_LISTENER_H_
--- /dev/null
+//
+// 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
+ *
+ * @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_
+#define _FMSG_ISMS_EVENT_LISTENER_H_
+
+#include <FBase.h>
+
+namespace Tizen { namespace Messaging
+{
+
+ class SmsMessage;
+
+
+ /**
+ * @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 <a href="../org.tizen.native.appprogramming/html/guide/messaging/messaging.htm">Messaging Guide</a>.
+ * @endif
+ */
+ class _OSP_EXPORT_ ISmsEventListener
+ : virtual public Tizen::Base::Runtime::IEventListener
+ {
+ // 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;
+
+ protected:
+ //
+ // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+ //
+ // This method is reserved and may change its name at any time without prior notice.
+ //
+ // @since 2.0
+ //
+ virtual void ISmsEventListener_Reserved1(void) {}
+
+ //
+ // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+ //
+ // This method is reserved and may change its name at any time without prior notice.
+ //
+ // @since 2.0
+ //
+ virtual void ISmsEventListener_Reserved2(void) {}
+ }; // ISmsEventListener
+
+} } // Tizen::Messaging
+#endif // _FMSG_ISMS_EVENT_LISTENER_H_
--- /dev/null
+//
+// 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 FMsgISmsListener.h
+ * @brief This is the header file for the %ISmsListener interface.
+ *
+ * This header file contains the declarations of the %ISmsListener interface.
+ */
+
+#ifndef _FMSG_ISMS_LISTENER_H_
+#define _FMSG_ISMS_LISTENER_H_
+
+// Includes
+#include <FBase.h>
+#include <FMsgTypes.h>
+
+namespace Tizen { namespace Messaging
+{
+ /**
+ * @interface ISmsListener
+ * @brief This is the listener interface for receiving SMS sent status.
+ *
+ * @since 2.0
+ *
+ * The %ISmsListener interface must be implemented to receive the status of the sent SMS messages asynchronously. An application must register this interface using the SmsManager::Construct() method.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/messaging.htm">Messaging Guide</a>.
+ */
+ class _OSP_EXPORT_ ISmsListener
+ : virtual public Tizen::Base::Runtime::IEventListener
+ {
+ // Lifecycle
+ public:
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.0
+ */
+ virtual ~ISmsListener(void) {}
+
+ // Operation
+ public:
+ /**
+ * Called when the SMS message is sent.
+ *
+ * @since 2.0
+ *
+ * @param[in] r The result of sending the SMS message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_FAILURE The method has failed to send the message.
+ * @see SmsManager::Send()
+ */
+ virtual void OnSmsMessageSent(result r) = 0;
+
+ protected:
+ //
+ // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+ //
+ // This method is reserved and may change its name at any time without prior notice.
+ //
+ // @since 2.0
+ //
+ virtual void ISmsListener_Reserved1(void) {}
+
+ //
+ // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+ //
+ // This method is reserved and may change its name at any time without prior notice.
+ //
+ // @since 2.0
+ //
+ virtual void ISmsListener_Reserved2(void) {}
+ }; // ISmsListener
+
+} } // Tizen::Messaging
+#endif // _FMSG_ISMS_LISTENER_H_
--- /dev/null
+//
+// 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 FMsgISmsMessageEventListener.h
+ * @brief This is the header file for the %ISmsMessageEventListener interface.
+ *
+ * This header file contains the declarations of the %ISmsMessageEventListener interface.
+ */
+
+#ifndef _FMSG_ISMS_MESSAGE_EVENT_LISTENER_H_
+#define _FMSG_ISMS_MESSAGE_EVENT_LISTENER_H_
+
+#include <FBase.h>
+
+namespace Tizen { namespace Messaging
+{
+ class SmsMessage;
+
+ /**
+ * @interface ISmsMessageEventListener
+ * @brief This is the listener interface for receiving SMS messages.
+ *
+ * @since 2.0
+ *
+ * The %ISmsMessageEventListener interface must be implemented to handle incoming SMS messages. An application must register this interface using the SmsManager::AddSmsMessageEventListener() method.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/messaging.htm">Messaging Guide</a>.
+ */
+ class _OSP_EXPORT_ ISmsMessageEventListener
+ : virtual public Tizen::Base::Runtime::IEventListener
+ {
+ // Lifecycle
+ public:
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.0
+ */
+ virtual ~ISmsMessageEventListener(void) {}
+
+ // Operations
+ public:
+ /**
+ * Called when the SMS message is received.
+ *
+ * @since 2.0
+ *
+ * @param[in] message The message that is received
+ * @see SmsManager::AddSmsMessageEventListener()
+ * @see SmsManager::RemoveSmsMessageEventListener()
+ */
+ virtual void OnSmsMessageReceived(const SmsMessage& message) = 0;
+
+ protected:
+ //
+ // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+ //
+ // This method is reserved and may change its name at any time without prior notice.
+ //
+ // @since 2.0
+ //
+ virtual void ISmsMessageEventListener_Reserved1(void) {}
+
+ //
+ // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+ //
+ // This method is reserved and may change its name at any time without prior notice.
+ //
+ // @since 2.0
+ //
+ virtual void ISmsMessageEventListener_Reserved2(void) {}
+ }; // ISmsMessageEventListener
+} } // Tizen::Messaging
+#endif // _FMSG_ISMS_MESSAGE_EVENT_LISTENER_H_
--- /dev/null
+//
+// 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 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_
+#define _FMSG_IWAP_PUSH_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FMsgWapPushMessage.h>
+
+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;
+
+protected:
+ //
+ // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+ //
+ // This method is reserved and may change its name at any time without prior notice.
+ //
+ // @since 2.0
+ //
+ virtual void IWapPushEventListener_Reserved1(void) {}
+
+ //
+ // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+ //
+ // This method is reserved and may change its name at any time without prior notice.
+ //
+ // @since 2.0
+ //
+ virtual void IWapPushEventListener_Reserved2(void) {}
+}; // IWapPushEventListener
+
+} } // Tizen::Messaging
+#endif // _FMSG_IWAP_PUSH_EVENT_LISTENER_H_
--- /dev/null
+//
+// 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 FMsgMmsManager.h
+ * @brief This is the header file for the %MmsManager class.
+ *
+ * This header file contains the declarations of the %MmsManager class.
+ */
+
+
+#ifndef _FMSG_MMS_MANAGER_H_
+#define _FMSG_MMS_MANAGER_H_
+
+// Includes
+#include <FBase.h>
+#include <FMsgIMmsListener.h>
+#include <FMsgMmsMessage.h>
+#include <FMsgRecipientList.h>
+
+namespace Tizen { namespace Messaging
+{
+
+ // forward declaration for class extension
+ class _MmsManagerImpl;
+
+ /**
+ * @class MmsManager
+ * @brief This class provides methods to use the MMS messaging service.
+ *
+ * @since 2.0
+ *
+ * The %MmsManager class is used to send MMS messages.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/messaging.htm">Messaging Guide</a>.
+ *
+ * The following example demonstrates how to use the %MmsManager class.
+ *
+ * @code
+ *
+ // Creates a listener to override the OnMmsMessageSent() function of IMmsListener
+ // in order to be notified of a change in the state of the message being sent.
+
+ class MmsListener
+ : public IMmsListener
+ , public Object
+ {
+ public:
+ void OnMmsMessageSent(result r);
+ };
+ void MmsListener::OnMmsMessageSent(result r)
+ {
+ // Do something.
+ }
+
+ class SendMmsMessage
+ : public Object
+ {
+ public:
+ void MmsTest(void);
+ };
+
+ void
+ SendMmsMessage::MmsTest(void)
+ {
+ result r = E_SUCCESS;
+
+ // Creates an MmsListener instance.
+ MmsListener* pListener = new MmsListener();
+
+ // Creates an MMS manager instance with the listener as the callback to check the status of the message being sent.
+ MmsManager* pMmsManager = new MmsManager();
+ r = pMmsManager->Construct(*pListener);
+
+ // Creates a recipient list instance and add recipients.
+ RecipientList recipient;
+ r = recipient.Add (RECIPIENT_TYPE_TO, L"01012345678");
+ r = recipient.Add (RECIPIENT_TYPE_CC, L"01012345679");
+ r = recipient.Add (RECIPIENT_TYPE_BCC, L"01012345670");
+
+ // Creates an MMS message instance.
+ MmsMessage mmsMessage;
+ r = mmsMessage.SetSubject(L"Subject!!!");
+ r = mmsMessage.SetText(L"Hello, World");
+ r = mmsMessage.AddAttachment(MMS_IMAGE, L"/Home/Res/image.jpg");
+ r = mmsMessage.AddAttachment(MMS_IMAGE, L"/Home/Res/audio.wav");
+
+ // Sends the message, and set the saveToSentbox parameter to true if the message should be saved in the Sentbox; otherwise, set to false.
+ // MmsListener callback is called once the message has been completely sent.
+ r = pMmsManager->Send(mmsMessage, recipient, true);
+ }
+ *
+ * @endcode
+ */
+ class _OSP_EXPORT_ MmsManager
+ : public Tizen::Base::Object
+ {
+ // Life cycle
+ public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.0
+ */
+ MmsManager(void);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.0
+ */
+ virtual ~MmsManager(void);
+
+ private:
+ MmsManager(const MmsManager& value);
+ MmsManager& operator =(const MmsManager& rhs);
+
+ // Operation
+ public:
+ /**
+ * Initializes this instance of %MmsManager with the specified parameter.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] listener The listener to receive a send result asynchronously
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ */
+ result Construct(IMmsListener &listener);
+
+ /**
+ * Sends the MMS message.
+ *
+ * @since 2.0
+ * @privilege %http://tizen.org/privilege/messaging.mms
+ *
+ * @return An error code
+ * @param[in] message The message to be sent
+ * @param[in] recipientList The list of recipients
+ * @param[in] saveToSentbox Set to @c true to save the message in the Sentbox, @n
+ * else @c false
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_ON_INITIALIZING The mailbox is not completely loaded as yet.
+ * @exception E_STORAGE_FULL The storage is full.
+ * @exception E_DEVICE_UNAVAILABLE The device is unavailable.
+ * @exception E_NETWORK_UNAVAILABLE The network is unavailable.
+ * @exception E_INVALID_CONDITION The profile is not set.
+ * @exception E_INVALID_ADDRESS The address is invalid.
+ * @exception E_FDN_MODE The FDN mode has been activated.
+ * @exception E_INVALID_ARG The number of recipients is @c 0 or the message is empty.
+ * @exception E_MAX_EXCEEDED The number of recipients has crossed the maximum limit (Maximum 10).
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @remarks Some service providers may not support sending MMS messages with an empty subject or body. @n
+ * In this case, the result of the status report will be the E_FAILURE exception. @n
+ * The CC and BCC recipients in the @c recipientList are merged with the TO recipients when sending an MMS message.
+ * @see IMmsListener::OnMmsMessageSent()
+ */
+ result Send(const MmsMessage& message, const RecipientList& recipientList, bool saveToSentbox);
+
+ private:
+ _MmsManagerImpl* __pImpl;
+
+ // friend class
+ friend class _MmsManagerImpl;
+ }; // MmsManager
+} } // Tizen::Messaging
+#endif // _FMSG_MMS_MANAGER_H_
--- /dev/null
+//
+// 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 FMsgMmsMessage.h
+ * @brief This is the header file for the %MmsMessage class.
+ *
+ * This header file contains the declarations of the %MmsMessage class.
+ */
+
+#ifndef _FMSG_MMS_MESSAGE_H_
+#define _FMSG_MMS_MESSAGE_H_
+
+// Includes
+#include <FBase.h>
+#include <FMsgTypes.h>
+
+namespace Tizen { namespace Messaging
+{
+
+ // forward declaration
+ class _MmsMessageImpl;
+ /**
+ * @class MmsMessage
+ * @brief This class provides methods for handling an MMS message.
+ *
+ * @since 2.0
+ *
+ * The %MmsMessage class provides methods for handling MMS messages. It allows you to set
+ * the subject and body text of an MMS message, and add or remove the files sent as MMS attachments.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/messaging.htm">Messaging Guide</a>.
+ */
+ class _OSP_EXPORT_ MmsMessage
+ : public Tizen::Base::Object
+ {
+ // Life cycle
+ public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.0
+ */
+ MmsMessage(void);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.0
+ */
+ virtual ~MmsMessage(void);
+
+ /**
+ * This is the copy constructor for the %MmsMessage class.
+ *
+ * @since 2.0
+ *
+ * @param[in] value An instance of %MmsMessage
+ */
+ MmsMessage(const MmsMessage& value);
+
+ /**
+ * This assignment operator copies an MMS message from the specified instance of %MmsMessage to the calling instance of %MmsMessage.
+ *
+ * @since 2.0
+ *
+ * @return A reference to the %MmsMessage instance
+ * @param[in] rhs A reference to the %MmsMessage instance to be copied
+ */
+ MmsMessage& operator =(const MmsMessage& rhs);
+
+ /**
+ * 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 %MmsMessage instance, @n
+ * else @c false
+ * @param[in] obj The object to compare
+ */
+ virtual bool Equals(const Tizen::Base::Object& obj) 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;
+
+ // Operation
+ public:
+ /**
+ * Sets the subject of the MMS message.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] subject The subject of the MMS message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_MAX_EXCEEDED The subject length of the message exceeds the maximum limit (Maximum 40 characters). @n
+ * The total size of the subject, body, and attachment(s) exceeds the maximum limit (295KB).
+ * @see GetSubject()
+ */
+ result SetSubject(const Tizen::Base::String& subject);
+
+ /**
+ * Sets the body of the MMS message.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] text The body of the MMS message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_MAX_EXCEEDED The body length of the message exceeds the maximum limit (Maximum 1000 characters). @n
+ * The total size of the subject, body, and attachment(s) exceeds the maximum limit (295KB).
+ * @see GetText()
+ */
+ result SetText(const Tizen::Base::String& text);
+
+ /**
+ * Adds the attachment of the specific type.
+ *
+ * @if OSPCOMPAT
+ * @brief <i> [Compatibility] </i>
+ * @endif
+ * @since 2.0
+ * @if OSPCOMPAT
+ * @compatibility This method has compatibility issues with OSP compatible applications. @n
+ * For more information, see @ref CompIoPathPage "here".
+ * @endif
+ *
+ * @return An error code
+ * @param[in] format The format of the attachment
+ * @param[in] filePath The path of the file to attach
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
+ * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
+ * - The length of the specified @c filePath is too long or @c 0. @n
+ * - The specified file format is already attached. @n
+ * - The specified @c format is invalid. @n
+ * - The specified file contains invalid or the media is not supported. @n
+ * - The specified file format cannot be attached.@n
+ * (An MMS attachment may contain either an image, audio, video, vCard, or a vCalendar file or a combination of an image, audio, vCard, and vCalendar file. @n
+ * MMS attachments cannot contain a video file in combination with an image or audio file.)
+ * @exception E_MAX_EXCEEDED The size of the file exceeds the maximum limit (Maximum 295KB). @n
+ * The total size of the subject, body, and attachment(s) exceeds the maximum limit (295KB).
+ * @see GetAttachment()
+ */
+ result AddAttachment(MmsAttachmentFormat format, const Tizen::Base::String& filePath);
+
+ /**
+ * Gets the subject of the MMS message.
+ *
+ * @since 2.0
+ *
+ * @return The subject of the MMS message
+ * @see SetSubject()
+ */
+ Tizen::Base::String GetSubject(void) const;
+
+ /**
+ * Gets the body of the MMS message.
+ *
+ * @since 2.0
+ *
+ * @return The body of the MMS message
+ * @see SetText()
+ */
+ Tizen::Base::String GetText(void) const;
+
+ /**
+ * Gets the attachment file of the specific type.
+ *
+ * @since 2.0
+ *
+ * @return The path of the attached file
+ * @param[in] format The format of the attachment
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_CONDITION The file is not attached.
+ * @exception E_INVALID_ARG The specified @c format is invalid.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @see AddAttachment()
+ */
+ Tizen::Base::String GetAttachment(MmsAttachmentFormat format) const;
+
+ /**
+ * Removes the attachment of the specific type.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] format The format of the attachment to remove
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_FILE_NOT_FOUND The corresponding format file is not found.
+ * @exception E_INVALID_ARG The specified @c format is invalid.
+ * @see AddAttachment()
+ * @see GetAttachment()
+ */
+ result RemoveAttachment(MmsAttachmentFormat format);
+
+ private:
+ _MmsMessageImpl* __pImpl;
+
+ // friend class
+ friend class _MmsMessageImpl;
+ }; // MmsMessage
+} } // Tizen::Messaging
+
+#endif // _FMSG_MMS_MESSAGE_H_
--- /dev/null
+//
+// 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 FMsgPushManager.h
+ * @brief This is the header file for the %PushManager class.
+ *
+ * This header file contains the declarations of the %PushManager class.
+ */
+
+#ifndef _FMSG_PUSH_MANAGER_H_
+#define _FMSG_PUSH_MANAGER_H_
+
+#include <FBase.h>
+#include <FMsgIPushManagerListener.h>
+#include <FMsgIPushEventListener.h>
+
+namespace Tizen { namespace Messaging
+{
+class _PushManagerImpl;
+
+/**
+* @class PushManager
+* @brief This class provides methods to use the push messaging service.
+*
+* @since 2.0
+*
+* @remarks If an application package contains multiple applications, only one application can use the push messaging service at a time.
+*
+* @pre In order to use the push messaging service, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/push_messaging.htm">Push Messaging Guide</a>.
+*
+*
+* The %PushManager class provides methods to register, unregister, and use the push messaging service.
+*
+* For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/messaging.htm">Messaging Guide</a>.
+*
+* @see Tizen::Shell::NotificationManager
+*
+* The following example demonstrates how to use the %PushManager class.
+*
+* @code
+*
+ // Creates a listener to override the methods of IPushManagerListener and IPushEventListener.
+
+ class PushListener : public IPushManagerListener, public IPushEventListener, public Object
+ {
+ public:
+ void OnPushServiceRegistered(RequestId reqId, const Tizen::Base::String& registrationId, result r, const Tizen::Base::String& errorCode, const Tizen::Base::String& errorMsg);
+ void OnPushServiceUnregistered(RequestId reqId, result r, const Tizen::Base::String& errorCode, const Tizen::Base::String& errorMsg);
+ void OnPushMessageReceived(const PushMessage& message);
+ };
+ void PushListener::OnPushServiceRegistered(RequestId reqId, const Tizen::Base::String& registrationId, result r, const Tizen::Base::String& errorCode, const Tizen::Base::String& errorMsg)
+ {
+ if (E_SUCCESS == r) {
+ // The application must send registrationId to the application server.
+ } else {
+ // Error
+ }
+ }
+ void PushListener::OnPushServiceUnregistered(RequestId reqId, result r, const Tizen::Base::String& errorCode, const Tizen::Base::String& errorMsg)
+ {
+ // Do something
+ }
+ void PushListener::OnPushMessageReceived(const PushMessage& message)
+ {
+ // Do something
+ }
+
+ class PushManagerSample : public Object
+ {
+ public:
+ void Initialize(void);
+ void EnablePushService(void);
+ void DisablePushService(void);
+ private:
+ PushListener* pPushListener;
+ PushManager* pPushManager;
+ };
+ void PushManagerSample::Initialize(void)
+ {
+ // Creates a PushListener instance.
+ pPushListener = new PushListener();
+
+ // Creates a PushManager instance.
+ pPushManager = new PushManager();
+ pPushManager->Construct(*pPushListener, *pPushListener);
+ }
+ void PushManagerSample::EnablePushService(void)
+ {
+ RequestId reqId;
+ result r = E_SUCCESS;
+
+ r = pPushManager->RegisterPushService(reqId);
+ if (IsFailed(r)) {
+ // Error
+ return;
+ }
+
+ // The result of registration will be notified by IPushManagerListener::OnPushServiceRegistered().
+ }
+ void PushManagerSample::DisablePushService(void)
+ {
+ // The application must notify the application server to stop sending push messages for this device.
+
+ RequestId reqId;
+ result r = E_SUCCESS;
+
+ r = pPushManager->UnregisterPushService(reqId);
+ if (IsFailed(r)) {
+ // Error
+ return;
+ }
+
+ // The result of unregistration will be notified by IPushManagerListener::OnPushServiceUnregistered().
+ }
+ *
+ * @endcode
+ */
+class _OSP_EXPORT_ PushManager
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
+ *
+ * @since 2.0
+ */
+ PushManager(void);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~PushManager(void);
+
+public:
+ /**
+ * Initializes this instance of the %PushManager class with the specified parameters.
+ *
+ * @since 2.0
+ * @privilege %http://tizen.org/privilege/push
+ *
+ * @pre In order to use the push messaging service, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/push_messaging.htm">Push Messaging Guide</a>.
+ *
+ * @return An error code
+ * @param[in] managerListener A listener that receives the result of the %PushManager
+ * class asynchronous methods
+ * @param[in] eventListener A listener that receives the incoming push messages
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SYSTEM A system error has occurred.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @see IPushManagerListener
+ * @see IPushEventListener
+ */
+ result Construct(IPushManagerListener& managerListener, IPushEventListener& eventListener);
+
+ /**
+ * Registers the push messaging service for the current application. @n
+ * This method is asynchronous.
+ *
+ * @since 2.0
+ * @privilege %http://tizen.org/privilege/push
+ *
+ * @pre In order to use the push messaging service, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/push_messaging.htm">Push Messaging Guide</a>.
+ *
+ * @return An error code
+ * @param[out] reqId The request ID
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SYSTEM A system error has occurred.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @see IPushManagerListener::OnPushServiceRegistered()
+ */
+ result RegisterPushService(RequestId& reqId);
+
+ /**
+ * Unregisters the push messaging service for the current application. @n
+ * This method is asynchronous.
+ *
+ * @since 2.0
+ * @privilege %http://tizen.org/privilege/push
+ *
+ * @pre In order to use the push messaging service, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/push_messaging.htm">Push Messaging Guide</a>.
+ *
+ * @return An error code
+ * @param[out] reqId The request ID
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SYSTEM A system error has occurred.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @see IPushManagerListener::OnPushServiceUnregistered()
+ */
+ result UnregisterPushService(RequestId& reqId);
+
+ /**
+ * Checks whether the push messaging service registration has been completed for the current application.
+ *
+ * @since 2.0
+ *
+ * @pre In order to use the push messaging service, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/push_messaging.htm">Push Messaging Guide</a>.
+ *
+ * @return @c true if the registration is completed, @n
+ * else @c false
+ */
+ bool IsPushServiceRegistered(void) const;
+
+ /**
+ * Gets the unread push messages. @n
+ * 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
+ *
+ * @pre In order to use the push messaging service, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/push_messaging.htm">Push Messaging Guide</a>.
+ *
+ * @return A pointer to the list that contains unread push messages
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @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.
+ * If the user launches the application using a ticker or a quick panel,
+ * the push message related to the notification is delivered to the application
+ * as a launch argument.
+ * The launch arguments are the input parameters for
+ * Tizen::App::IAppControlProviderEventListener::OnAppControlRequestReceivedN().
+ * This function returns all the unread messages including the message
+ * delivered as a launch argument.
+ * @see Tizen::App::IAppControlProviderEventListener
+ */
+ Tizen::Base::Collection::IList* GetUnreadMessagesN(void);
+
+ /**
+ * Sends the push message to a single recipient. @n
+ * This method is asynchronous.
+ *
+ * @since 2.0
+ * @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 <a href="../org.tizen.native.appprogramming/html/guide/messaging/push_messaging.htm">Push Messaging Guide</a>.
+ *
+ * @return An error code
+ * @param[in] message The push message
+ * @param[in] registrationId The registration ID of the recipient
+ * @param[in] appSecret The secret code of the application issued by the push server to authenticate the application
+ * @param[out] reqId The request ID
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG A specified input parameter is invalid.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SYSTEM A system error has occurred.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @see IPushManagerListener::OnPushMessageSent()
+ */
+ result SendPushMessage(const PushMessage& message, const Tizen::Base::String& registrationId, const Tizen::Base::String& appSecret, RequestId& reqId);
+
+
+ /**
+ * Sends the push message to multiple recipients. @n
+ * This method is asynchronous.
+ *
+ * @since 2.0
+ * @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 <a href="../org.tizen.native.appprogramming/html/guide/messaging/push_messaging.htm">Push Messaging Guide</a>.
+ *
+ * @return An error code
+ * @param[in] message The push message
+ * @param[in] registrationIdList The list of registration IDs of the recipients
+ * @param[in] appSecret The secret code of the application issued by the push server to authenticate the application
+ * @param[out] reqId The request ID
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG A specified input parameter is invalid.
+ * @exception E_MAX_EXCEEDED The number of registration IDs has crossed the maximum limit.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @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 maximum limit can be checked by using GetMaxRecipientCount().
+ * @see IPushManagerListener::OnPushMessageSent()
+ */
+ result SendPushMessage(const PushMessage& message, const Tizen::Base::Collection::IList& registrationIdList, const Tizen::Base::String& appSecret, RequestId& reqId);
+
+ /**
+ * Gets the maximum number of recipients sent by a multiple SendPushMessage() method.
+ *
+ * @since 2.0
+ *
+ * @return The maximum number of recipients
+ */
+ static int GetMaxRecipientCount(void);
+
+private:
+ /**
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+ *
+ * @param[in] rhs An instance of PushManager
+ */
+ PushManager(const PushManager& rhs);
+
+ /**
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+ *
+ * @return A reference to this instance
+ * @param[in] rhs An instance of PushManager
+ */
+ PushManager& operator =(const PushManager& rhs);
+
+private:
+ _PushManagerImpl* __pPushManagerImpl;
+
+ friend class _PushManagerImpl;
+}; // PushManager
+
+} } // Tizen::Messaging
+#endif // _FMSG_PUSH_MANAGER_H_
--- /dev/null
+//
+// 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 FMsgPushMessage.h
+ * @brief This is the header file for the %PushMessage class.
+ *
+ * This header file contains the declarations of the %PushMessage class.
+ */
+
+#ifndef _FMSG_PUSH_MESSAGE_H_
+#define _FMSG_PUSH_MESSAGE_H_
+
+#include <FBase.h>
+#include <FShellNotificationRequest.h>
+#include <FMsgTypes.h>
+
+namespace Tizen { namespace Messaging
+{
+class _PushMessageImpl;
+
+/**
+* @class PushMessage
+* @brief This class provides methods for handling a push message.
+*
+* @since 2.0
+*
+* The %PushMessage class provides methods for handling a push message. It allows you to get the body text and
+* the received time of a push message.
+*
+* For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/messaging.htm">Messaging Guide</a>.
+*/
+class _OSP_EXPORT_ PushMessage
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.0
+ */
+ PushMessage(void);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~PushMessage(void);
+
+public:
+ /**
+ * 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;
+
+ /**
+ * @if OSPDEPREC
+ * Gets the body of the message.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This method is deprecated. Instead of using this method, use Tizen::Shell::NotificationRequest::GetAppMessage() method.
+ *
+ * @since 2.0
+ *
+ * @return The body of the message
+ * @endif
+ */
+ Tizen::Base::String GetText(void) const;
+
+ /**
+ * Sets an action of the push message.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] action An action of the push message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ */
+ result SetAction(PushAction action);
+
+ /**
+ * Gets an action of the push message.
+ *
+ * @since 2.0
+ *
+ * @return An action of the push message
+ */
+ PushAction GetAction(void) const;
+
+ /**
+ * Sets the notification of the push message.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] notificationRequest The notification request
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @remarks PushMessage supports to set only alert text of NotificationRequest instance, and others are ignored.
+ * @see Tizen::Shell::NotificationRequest
+ */
+ result SetNotification(const Tizen::Shell::NotificationRequest& notificationRequest);
+
+ /**
+ * Gets the notification of the push message.
+ *
+ * @since 2.0
+ *
+ * @return The notification request
+ * @remarks PushMessage supports to get only alert text of NotificationRequest instance, and others are ignored.
+ * @see Tizen::Shell::NotificationRequest
+ */
+ Tizen::Shell::NotificationRequest GetNotification(void) const;
+
+ /**
+ * Copying of objects using this copy constructor is allowed.
+ *
+ * @since 2.0
+ *
+ * @param[in] rhs An instance of %PushMessage
+ */
+ PushMessage(const PushMessage& rhs);
+
+ /**
+ * Copying of objects using this copy assignment operator is allowed.
+ *
+ * @since 2.0
+ *
+ * @return A reference to this instance
+ * @param[in] rhs An instance of %PushMessage
+ */
+ PushMessage& operator =(const PushMessage& rhs);
+
+ /**
+ * Compares the specified instance of %PushMessage with the calling instance.
+ *
+ * @since 2.0
+ *
+ * @return @c true, if the values match, @n
+ * else @c false
+ * @param[in] obj The other Object to be compared
+ * @see Tizen::Base::Object::Equals()
+ */
+ virtual bool Equals(const Tizen::Base::Object& obj) const;
+
+ /**
+ * Gets the hash value of the current instance.
+ *
+ * @since 2.0
+ *
+ * @return The current instance's hash value
+ */
+ virtual int GetHashCode(void) const;
+
+private:
+ /**
+ * This constructor is intentionally declared as private so that only the platform can create an instance.
+ *
+ * @param[in] dateTime The date and time (UTC time) when the message is received
+ * @param[in] text The message body text
+ */
+ PushMessage(const Tizen::Base::DateTime& dateTime, const Tizen::Base::String& text);
+
+private:
+ _PushMessageImpl* __pPushMessageImpl;
+
+ friend class _PushMessageImpl;
+}; // PushMessage
+
+} } // Tizen::Messaging
+#endif // _FMSG_PUSH_MESSAGE_H_
--- /dev/null
+//
+// 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 FMsgRecipientList.h
+ * @brief This is the header file for the %RecipientList class.
+ *
+ * This header file contains the declarations of the %RecipientList class.
+ */
+
+#ifndef _FMSG_RECIPIENT_LIST_H_
+#define _FMSG_RECIPIENT_LIST_H_
+
+// Includes
+#include <FBase.h>
+#include <FMsgTypes.h>
+
+namespace Tizen { namespace Messaging
+{
+
+ // forward declaration
+ class _RecipientListImpl;
+ /**
+ * @class RecipientList
+ * @brief This class provides the abstract data type and methods for handling recipients.
+ *
+ * @since 2.0
+ *
+ * The %RecipientList class provides methods for handling message recipients. It allows you to add, remove, set,
+ * and get the list of recipients. A recipient is an email address for an email message and a telephone number
+ * for an SMS or MMS message.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/messaging.htm">Messaging Guide</a>.
+
+ */
+ class _OSP_EXPORT_ RecipientList
+ : public Tizen::Base::Object
+ {
+ // Life cycle
+ public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.0
+ */
+ RecipientList(void);
+
+ /**
+ * This is the copy constructor for the %RecipientList class.
+ *
+ * @since 2.0
+ *
+ * @param[in] value An instance of %RecipientList
+ */
+ RecipientList(const RecipientList& value);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.0
+ */
+ virtual ~RecipientList(void);
+
+ //Operator
+ public:
+ /**
+ * This is the assignment operator for this class. @n
+ * Copies the recipient list from the specified instance of %RecipientList to the calling instance of %RecipientList.
+ *
+ * @since 2.0
+ *
+ * @param[in] rhs A reference to the %RecipientList instance
+ */
+ RecipientList& operator =(const RecipientList& rhs);
+
+ /**
+ * This operator compares the two recipient lists.
+ *
+ * @since 2.0
+ *
+ * @return @c true if both instances are equal, @n
+ * else @c false
+ * @param[in] rhs A reference to the %RecipientList instance on the right-hand side of the operator
+ */
+ bool operator ==(const RecipientList& rhs) const;
+
+ /**
+ * This operator compares the specified instance with the calling instance for inequality.
+ *
+ * @since 2.0
+ *
+ * @return @c true if both instances are not equal, @n
+ * else @c false
+ * @param[in] rhs A reference to the %RecipientList instance on the right-hand side of the operator
+ */
+ bool operator !=(const RecipientList& rhs) const;
+
+ /**
+ * Gets the hash value of the current instance.
+ *
+ * @since 2.0
+ *
+ * @return The hash value of the current instance
+ * @remarks Two equal instances should return the same hash value. @n
+ * For better performance, the used hash function must generate a random distribution for all inputs.
+ */
+ virtual int GetHashCode(void) const;
+
+ // Operation
+ public:
+ /**
+ * Compares the specified instance with the calling instance.
+ *
+ * @since 2.0
+ *
+ * @return @c true if both instances are equal, @n
+ * else @c false
+ * @param[in] value An instance of %RecipientList
+ */
+ virtual bool Equals(const Tizen::Base::Object& value) const;
+
+ /**
+ * Adds a recipient string.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] type The type of recipient
+ * @param[in] recipient The recipient string
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @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.
+ * @see Set()
+ * @see GetListN()
+ * @see SmsManager::Send()
+ * @see MmsManager::Send()
+ * @see EmailManager::Send()
+ */
+ result Add(RecipientType type, const Tizen::Base::String& recipient);
+
+ /**
+ * Removes the recipient.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] type The type of recipient
+ * @param[in] recipient The recipient string
+ * @exception E_SUCCESS The method is successful.
+ * @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.
+ * @exception E_OBJ_NOT_FOUND The specified @c recipient does not exist.
+ * @see Add()
+ */
+ result Remove(RecipientType type, const Tizen::Base::String& recipient);
+
+
+ /**
+ * Sets a recipient list.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] type The type of recipient
+ * @param[in] list A list of recipient strings
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The length of one of the recipients in the list is too short (< 3) or too long (> 320), or
+ * the specified @c type is invalid.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_OBJ_ALREADY_EXIST A duplicate recipient in the recipient list already exists.
+ * @remarks The limit of recipients is not checked in this method. @n
+ * This is done in the SmsManager::Send(), MmsManager::Send(), and EmailManager::Send() methods.
+ * @see Add()
+ * @see GetListN()
+ */
+ result Set(RecipientType type, const Tizen::Base::Collection::IList& list);
+
+ /**
+ * Gets the recipient list of the specific recipient type.
+ *
+ * @since 2.0
+ *
+ * @return A pointer to the list of recipient type
+ * @param[in] type The type of recipient
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_INVALID_ARG The specified @c type is invalid.
+ * @remarks The recipient is an email address for an email message or a telephone number for an SMS or MMS message. @n
+ * The specified @c type contains RECIPIENT_TYPE_TO, RECIPIENT_TYPE_CC, RECIPIENT_TYPE_BCC. @n
+ * The specific error code can be accessed using the GetLastResult() method.
+ * @see Add()
+ * @see Set()
+ */
+ Tizen::Base::Collection::IList* GetListN(RecipientType type) const;
+
+ private:
+ _RecipientListImpl* __pImpl;
+
+ // friend class
+ friend class _RecipientListImpl;
+ }; // RecipientList
+
+} } // Tizen::Messaging
+
+#endif // _FMSG_RECIPIENT_LIST_H_
--- /dev/null
+//
+// 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 FMsgSmsManager.h
+ * @brief This is the header file for the %SmsManager class.
+ *
+ * This header file contains the declarations of the %SmsManager class.
+ */
+
+#ifndef _FMSG_SMS_MANAGER_H_
+#define _FMSG_SMS_MANAGER_H_
+
+// Includes
+#include <FMsgISmsListener.h>
+#include <FMsgISmsEventListener.h>
+#include <FMsgISmsMessageEventListener.h>
+#include <FMsgICbsMessageEventListener.h>
+#include <FMsgIEtwsPrimaryNotificationEventListener.h>
+#include <FMsgSmsMessage.h>
+#include <FMsgCbsMessage.h>
+#include <FMsgCbsChannel.h>
+#include <FMsgRecipientList.h>
+
+namespace Tizen { namespace Messaging
+{
+
+ // forward declaration
+ class _SmsManagerImpl;
+
+ /**
+ * @class SmsManager
+ * @brief This class provides methods to use the SMS messaging service.
+ *
+ * @since 2.0
+ *
+ * The %SmsManager class is used to send, receive, and retrieve SMS messages.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/messaging.htm">Messaging Guide</a>.
+ *
+ * The following example demonstrates how to use the %SmsManager class.
+ *
+ * @code
+ *
+ // Creates a listener to override the OnSmsMessageSent() function of ISmsListener
+ // in order to be notified of a change in the state of the message being sent.
+
+ class SmsListener
+ : public ISmsListener
+ , public Object
+ {
+ public:
+ void OnSmsMessageSent(result r);
+ };
+
+ void
+ SmsListener::OnSmsMessageSent(result r)
+ {
+ // Do something
+ }
+
+ class SendSmsMessage
+ : public Object
+ {
+ public:
+ void SmsTest(void);
+ };
+
+ void
+ SendSmsMessage::SmsTest(void)
+ {
+ result r = E_SUCCESS;
+
+ // Creates an SmsListener instance.
+ SmsListener* pListener = new SmsListener();
+
+ // Creates a SMS manager instance with the listener as the callback to check the status of the message being sent.
+ SmsManager* pSmsManager = new SmsManager();
+ r = pSmsManager->Construct(*pListener);
+
+ // Creates a recipient list instance and adds recipients.
+ RecipientList recipient;
+ r = recipient.Add (RECIPIENT_TYPE_TO, L"01012345678");
+ r = recipient.Add (RECIPIENT_TYPE_TO, L"01078901234");
+
+ // Creates an SMS message instance.
+ SmsMessage smsMessage;
+ r = smsMessage.SetText(L"Hello, World");
+
+ // Sends the message, and sets the saveToSentbox parameter to true if the message should be saved in the Sentbox; else, set to false.
+ // SmsListener callback is called once the message has been completely sent.
+ r = pSmsManager->Send(smsMessage, recipient, true);
+ }
+ *
+ * @endcode
+ */
+ class _OSP_EXPORT_ SmsManager
+ : public Tizen::Base::Object
+ {
+ // Life cycle
+ public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.0
+ */
+ SmsManager(void);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.0
+ */
+ virtual ~SmsManager(void);
+
+ private:
+ SmsManager(const SmsManager& value);
+ SmsManager& operator =(const SmsManager& rhs);
+
+
+ // Operation
+ public:
+ /**
+ * Initializes this instance of %SmsManager with the specified parameter.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] listener The listener to receive a send result asynchronously
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ */
+ 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
+ *
+ * @return An error code
+ * @param[in] port A port number
+ * @param[in] eventListener The listener to receive SMS messages
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_OBJ_ALREADY_EXIST The specified port number is already registered. @n
+ * The listener is already exists.
+ * @exception E_FAILURE The specified port number is already used in other applications.
+ * @exception E_INVALID_ARG The specified @c port is invalid. @n
+ * The port number must range from @c 1 to @c 9999 (1 <= port <= 9999).
+ * @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
+ *
+ * @return An error code
+ * @param[in] port A port number
+ * @param[in] eventListener The listener to receive SMS messages
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_OBJ_NOT_FOUND The listener is not found.
+ * @exception E_SYSTEM A system error has occurred.
+ * @exception E_INVALID_ARG The specified @c port is invalid. @n
+ * The port number must range from @c 1 to @c 9999 (1 <= port <= 9999).
+ * @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);
+
+ /**
+ * Adds the event listener for receiving SMS messages.
+ *
+ * @since 2.0
+ *
+ * @privilege %http://tizen.org/privilege/messaging.sms
+ *
+ * @return An error code
+ * @param[in] eventListener The listener to receive SMS messages
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_OBJ_ALREADY_EXIST The listener already exists.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @see ISmsMessageEventListener
+ * @see RemoveSmsMessageEventListener()
+ */
+ result AddSmsMessageEventListener(ISmsMessageEventListener& eventListener);
+
+ /**
+ * Removes the event listener for receiving SMS messages.
+ *
+ * @since 2.0
+ *
+ * @privilege %http://tizen.org/privilege/messaging.sms
+ *
+ * @return An error code
+ * @param[in] eventListener The listener to receive SMS messages
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_OBJ_NOT_FOUND The listener is not found.
+ * @exception E_SYSTEM A system error has occurred.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @see ISmsMessageEventListener
+ * @see AddSmsMessageEventListener()
+ */
+ result RemoveSmsMessageEventListener(ISmsMessageEventListener& eventListener);
+
+ /**
+ * Sends the SMS message.
+ *
+ * @since 2.0
+ *
+ * @privilege %http://tizen.org/privilege/messaging.sms
+ *
+ * @return An error code
+ * @param[in] message The message to be sent
+ * @param[in] recipientList The list of recipients
+ * @param[in] saveToSentbox Set to @c true to save the message in the Sentbox, @n
+ * else @c false
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_ON_INITIALIZING The mailbox is not completely loaded as yet.
+ * @exception E_STORAGE_FULL The storage is full.
+ * @exception E_DEVICE_UNAVAILABLE The device is unavailable.
+ * @exception E_NETWORK_UNAVAILABLE The network is unavailable.
+ * @exception E_INVALID_ADDRESS The address is invalid.
+ * @exception E_FDN_MODE The FDN mode has been activated.
+ * @exception E_INVALID_ARG The number of recipients is @c 0.
+ * @exception E_MAX_EXCEEDED The number of recipients has crossed the maximum limit (Maximum 10).
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @remarks The CC and BCC recipients in the @c recipientList are ignored when sending an SMS message.
+ * @see ISmsListener::OnSmsMessageSent()
+ */
+ result Send(const SmsMessage& message, const RecipientList& recipientList, bool saveToSentbox);
+
+ /**
+ * Gets the total number of SMS messages in the specified message box.
+ *
+ * @since 2.0
+ *
+ * @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
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c type is invalid.
+ * @exception E_SYSTEM A system error has occurred.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @remarks In case of an error, this method returns the negative value. For example, @c -1. @n
+ * The specific error code can be accessed using the GetLastResult() method.
+ */
+ int GetTotalMessageCount(SmsMessageBoxType type) const;
+
+ /**
+ * Searches the SMS messages by keyword and|or sender address in the Inbox.
+ *
+ * @since 2.0
+ *
+ * @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
+ * In case of @c null or an empty string, this method searches all SMS messages in the Inbox regardless of the keyword.
+ * @param[in] pSenderAddress A telephone number as a sender address (exact match) @n
+ * In case of @c null or an empty string, this method searches all SMS messages in the Inbox regardless of the sender address.
+ * @param[in] startIndex The start index (base 0)
+ * @param[in] count The count of SMS messages to search
+ * @param[out] totalResultCount The total count of the searched result
+ * @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 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.
+ * @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. @n
+ * The search with the specified keywords searches using only the first 50 characters of the body text. @n
+ * The SMS messages in the searched result contain only @c 160 bytes for the body text. @n
+ * To check whether there is additional text, use the SmsMessage::HasMoreText() method. @n
+ * To get the full body text, use GetFullText() with its message ID.
+ * @see SmsMessage
+ * @see GetFullText()
+ */
+ Tizen::Base::Collection::IList* SearchInboxN(const Tizen::Base::String* pKeyword, const Tizen::Base::String* pSenderAddress, int startIndex, int count, int& totalResultCount) const;
+
+ /**
+ * Searches the SMS messages by keyword in the specified message box.
+ *
+ * @since 2.0
+ *
+ * @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
+ * @param[in] pKeyword A part of the body text as a keyword (partial match) @n
+ * In case of @c null or an empty string, this method searches all SMS messages in the specified message box.
+ * @param[in] startIndex The start index (base 0)
+ * @param[in] count The count of SMS messages to search
+ * @param[out] totalResultCount The total count of the searched result
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
+ * - The specified @c type is invalid. @n
+ * - The specified @c pKeyword string length is less than @c 2 or greater than @c 30. @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.
+ * @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. @n
+ * The search with the specified keywords searches using only the first 50 characters of the body text. @n
+ * The SMS messages in the searched result contain only @c 160 bytes for the body text. @n
+ * To check whether there is additional text, use the SmsMessage::HasMoreText() method. @n
+ * To get the full body text, use the GetFullText() method with its message ID.
+ * @see SmsMessage, GetFullText()
+ */
+ Tizen::Base::Collection::IList* SearchMessageBoxN(SmsMessageBoxType type, const Tizen::Base::String* pKeyword, int startIndex, int count, int& totalResultCount) const;
+
+ /**
+ * Gets the full text of the SMS message in the message box using the message ID.
+ *
+ * @since 2.0
+ *
+ * @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
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c messageId is invalid, or it must be greater than or equal to @c 0.
+ * @exception E_OBJ_NOT_FOUND The SMS message with the specified @c messageId is not found.
+ * @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. @n
+ * In case of an error, this method returns an empty string.
+ * @see SmsMessage::HasMoreText()
+ */
+ 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
+ *
+ * @return An error code
+ * @param[in] pListener The listener to receive CB messages
+ * @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.
+ * @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
+ *
+ * @return An error code
+ * @param[in] pListener The listener to receive ETWS primary notification
+ * @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.
+ * @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
+ *
+ * @return An error code
+ * @param[in] enable Set to @c true to save the message in the CbsBox, @n
+ * else @c false
+ * @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
+ *
+ * @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
+ *
+ * @return An error code
+ * @param[in] enable Set to @c true to enable the CB service, @n
+ * else @c false
+ * @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.
+ * @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
+ *
+ * @return An error code
+ * @param[in] from The starting index of the message ID of the channel
+ * @param[in] to The last index of the message ID of the channel
+ * @param[in] name The name of the channel. (can be an empty string)
+ * @param[in] activate Set to @c true to activate the channel, @n
+ * else @c false.
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
+ * - The specified @c to parameter is smaller than @c from. @n
+ * - The specified @c to or @c from parameter is a negative value. @n
+ * - The specified @c to parameter exceeds the limit (0xFFFF). @n
+ * - The range (@c to - @c from) exceeds the limit (900).
+ * - 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
+ *
+ * @return An error code
+ * @param[in] from The starting index of the message ID of the channel
+ * @param[in] to The last index of the message ID of the channel
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
+ * - The specified @c to parameter is smaller than @c from. @n
+ * - The specified @c to or @c from parameter is a negative value. @n
+ * - The specified @c to parameter exceeds the limit (0xFFFF). @n
+ * - The range (@c to - @c from) exceeds the limit (900).
+ * @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
+ *
+ * @return A pointer to the CBS channel with specific range.
+ * @param[in] from The starting index of the message ID of the channel
+ * @param[in] to The last index of the message ID of the channel
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
+ * - The specified @c to parameter is smaller than @c from. @n
+ * - The specified @c to or @c from parameter is a negative value. @n
+ * - The specified @c to parameter exceeds the limit (0xFFFF). @n
+ * - The range (@c to - @c from) exceeds the limit (900).
+ * @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
+ *
+ * @return A pointer to the list of CBS channel
+ * @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.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @see AddCbsChannel()
+ * @see RemoveCbsChannel()
+ * @see CbsChannel
+ *
+ * @endif
+ */
+ Tizen::Base::Collection::IList* GetCbsChannelListN(void);
+
+ private:
+ _SmsManagerImpl* __pImpl;
+
+ // friend class
+ friend class _SmsManagerImpl;
+ }; // SmsManager
+} } // Tizen::Messaging
+
+#endif // _FMSG_SMS_MANAGER_H_
--- /dev/null
+//
+// 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 FMsgSmsMessage.h
+ * @brief This is the header file for the %SmsMessage class.
+ *
+ * This header file contains the declarations of the %SmsMessage class.
+ */
+
+#ifndef _FMSG_SMS_MESSAGE_H_
+#define _FMSG_SMS_MESSAGE_H_
+
+// Includes
+#include <FMsgISmsEventListener.h>
+#include <FMsgRecipientList.h>
+
+namespace Tizen { namespace Messaging
+{
+
+ // forward declaration for class extension
+ class _SmsMessageImpl;
+
+ /**
+ * @class SmsMessage
+ * @brief This class provides methods for handling an SMS message.
+ *
+ * @since 2.0
+ *
+ * The %SmsMessage class provides methods for handling SMS messages. It allows you to set and get the body text of an SMS message.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/messaging/messaging.htm">Messaging Guide</a>.
+ */
+ class _OSP_EXPORT_ SmsMessage
+ : public Tizen::Base::Object
+ {
+ // Life cycle
+ public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.0
+ */
+ SmsMessage(void);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.0
+ */
+ virtual ~SmsMessage(void);
+
+ /**
+ * This is the copy constructor for the %SmsMessage class.
+ *
+ * @since 2.0
+ *
+ * @param[in] value An instance of %SmsMessage
+ */
+ SmsMessage(const SmsMessage& value);
+
+ public:
+
+ /**
+ * This assignment operator copies an SMS message from the specified instance of %SmsMessage to the calling instance of %SmsMessage.
+ *
+ * @since 2.0
+ *
+ * @return A reference to the %SmsMessage instance
+ * @param[in] rhs A reference to the %SmsMessage instance to be copied
+ */
+ SmsMessage& operator =(const SmsMessage& rhs);
+
+ /**
+ * 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 %SmsMessage instance, @n
+ * else @c false
+ * @param[in] obj The object to compare
+ */
+ virtual bool Equals(const Tizen::Base::Object& obj) 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;
+
+ // Operation
+ public:
+ /**
+ * Sets the body of the SMS message.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] text The body of the SMS message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_MAX_EXCEEDED The body length of the message exceeds the maximum limit (Maximum 80 characters).
+ * @see GetText()
+ */
+ result SetText(const Tizen::Base::String& text);
+
+ /**
+ * Gets the body of the SMS message.
+ *
+ * @since 2.0
+ *
+ * @return The body of the SMS message
+ * @remarks If the message is from the Inbox, Sentbox, or Outbox, it may contain only @c 160 bytes for the body text. @n
+ * To check whether the message contains more than @c 160 bytes for the body text, use the HasMoreText() method. @n
+ * To get the full body text, use the SmsManager::GetFullText() method with its message ID.
+ * @see SetText()
+ * @see HasMoreText()
+ * @see GetId()
+ * @see SmsManager::GetFullText()
+ */
+ Tizen::Base::String GetText(void) const;
+
+
+ /**
+ * Gets the sender address of the SMS message.
+ *
+ * @since 2.0
+ *
+ * @privilege %http://tizen.org/privilege/messaging.sms
+ *
+ * @return The sender address of the SMS message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_OPERATION This operation is only allowed to the incoming message or the message from the Inbox.
+ * @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.
+ */
+ Tizen::Base::String GetSenderAddress(void) const;
+
+ /**
+ * Gets the received time of the SMS message.
+ *
+ * @since 2.0
+ *
+ * @privilege %http://tizen.org/privilege/messaging.sms
+ *
+ * @return The received time of the SMS message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_OPERATION This operation is only allowed to the incoming message or the message from the Inbox.
+ * @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. @n
+ * In case of an error, this method returns the instance denoting 00:00:00, January 1, 1.
+ */
+ Tizen::Base::DateTime GetReceivedTime(void) const;
+
+ /**
+ * Gets the unique ID of the SMS message.
+ *
+ * @since 2.0
+ *
+ * @privilege %http://tizen.org/privilege/messaging.sms
+ *
+ * @return The unique ID of the SMS message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_OPERATION This operation is allowed only when the message is from the Inbox, Sentbox, or Outbox.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @remarks In case of an error, this method returns the negative value. For example, @c -1. @n
+ * The specific error code can be accessed using the GetLastResult() method.
+ */
+ int GetId(void) const;
+
+ /**
+ * Gets the sent time of the SMS message.
+ *
+ * @since 2.0
+ *
+ * @privilege %http://tizen.org/privilege/messaging.sms
+ *
+ * @return The sent time of the SMS message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_OPERATION This operation is allowed only when the message is from the Sentbox or Outbox.
+ * @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. @n
+ * In case of an error, this method returns the instance denoting 00:00:00, January 1, 1.
+ */
+ Tizen::Base::DateTime GetSentTime(void) const;
+
+ /**
+ * Gets the type of the SMS message box.
+ *
+ * @since 2.0
+ *
+ * @privilege %http://tizen.org/privilege/messaging.sms
+ *
+ * @return The type of the SMS message box
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_OPERATION This operation is allowed only when the message is from the Inbox, Sentbox, or Outbox.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @remarks In case of an error, this method returns the SMS_MESSAGE_BOX_TYPE_NONE value. @n
+ * The specific error code can be accessed using the GetLastResult() method.
+ */
+ SmsMessageBoxType GetMessageBoxType(void) const;
+
+ /**
+ * Gets the list of the recipients.
+ *
+ * @since 2.0
+ *
+ * @privilege %http://tizen.org/privilege/messaging.sms
+ *
+ * @return The list of the recipient
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_OPERATION This operation is allowed only when the message is from the Sentbox or Outbox.
+ * @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.
+ */
+ RecipientList GetRecipientList(void) const;
+
+ /**
+ * 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
+ *
+ * @return @c true if this SMS message contains more than @c 160 bytes for the body text, @n
+ * else @c false
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_OPERATION This operation is allowed only when the message is from the Inbox, Sentbox, or Outbox.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @remarks If the return value is @c true, the SMS message contains more than @c 160 bytes for the body text. @n
+ * To get the full body text, use SmsManager::GetFullText(). @n
+ * The specific error code can be accessed using the GetLastResult() method.
+ */
+ bool HasMoreText(void) const;
+
+ private:
+ _SmsMessageImpl* __pImpl;
+
+ // friend class
+ friend class _SmsMessageImpl;
+ }; // SmsMessage
+} } // Tizen::Messaging
+
+#endif // _FMSG_SMS_MESSAGE_H_
--- /dev/null
+//
+// 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 FMsgTypes.h
+ * @brief This is the header file for the %Messaging class.
+ *
+ * This header file contains the type declarations for the %Messaging namespace.
+ */
+
+#ifndef _FMSG_TYPES_H_
+#define _FMSG_TYPES_H_
+
+namespace Tizen { namespace Messaging
+{
+ /**
+ * @enum RecipientType
+ *
+ * Defines the recipient type for a Short Message Service(SMS), Multimedia %Messaging Service(MMS) and email messages.
+ *
+ * @since 2.0
+ */
+ enum RecipientType
+ {
+ RECIPIENT_TYPE_TO = 0, /**<The recipient is in 'To' list */
+ RECIPIENT_TYPE_CC, /**<The recipient is in 'Cc' list */
+ RECIPIENT_TYPE_BCC /**<The recipient is in 'Bcc' list */
+ };
+
+ /**
+ * @enum AddressType
+ *
+ * Defines the type of an address. @n
+ * All recipient addresses must be either in a phone or an email format.
+ *
+ * @since 2.0
+ */
+ enum AddressType
+ {
+ ADDRESS_TYPE_PHONE = 0, /**<The phone number type*/
+ ADDRESS_TYPE_EMAIL /**<The email type*/
+ };
+
+ /**
+ * @enum MmsAttachmentFormat
+ *
+ * Defines the attachment type for Multimedia %Messaging Service (MMS) messages.
+ *
+ * @since 2.0
+ */
+ enum MmsAttachmentFormat
+ {
+ MMS_IMAGE = 0, /**< The image type */
+ MMS_AUDIO, /**< The audio type */
+ MMS_VIDEO, /**< The video type */
+ MMS_VCARD, /**< The vCard type */
+ MMS_VCALENDAR /**< The vCalendar type */
+ };
+
+ /**
+ * @enum SmsMessageBoxType
+ *
+ * Defines the message box type for Short Message Service(SMS) messages.
+ *
+ * @since 2.0
+ */
+ enum SmsMessageBoxType
+ {
+ SMS_MESSAGE_BOX_TYPE_NONE = -1, /**< None */
+ SMS_MESSAGE_BOX_TYPE_INBOX = 0, /**< The Inbox type */
+ SMS_MESSAGE_BOX_TYPE_SENTBOX = 1, /**< The Sentbox type */
+ SMS_MESSAGE_BOX_TYPE_OUTBOX = 2, /**< The Outbox type */
+ SMS_MESSAGE_BOX_TYPE_ALL = 10 /**< All message box type */
+ };
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * @enum EmailMessagePriority
+ *
+ * Defines the priority level for an email.
+ *
+ * @since 2.0
+ *
+ * @visibility partner-operator
+ *
+ * @endif
+ */
+ enum EmailMessagePriority
+ {
+ EMAIL_MESSAGE_PRIORITY_HIGH = 1, /**< High priority */
+ EMAIL_MESSAGE_PRIORITY_NORMAL = 3, /**< Normal priority */
+ EMAIL_MESSAGE_PRIORITY_LOW = 5 /**< Low priority */
+ };
+
+ /**
+ * @enum PushAction
+ *
+ * Defines the push action. @n
+ * This action is performed when the application is not running.
+ *
+ * @since 2.0
+ */
+ enum PushAction
+ {
+ 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 */
+ };
+
+} } // Tizen::Messaging
+
+#endif // _FMSG_TYPES_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 3.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-3.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 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 <FBase.h>
+#include <FMsgIWapPushEventListener.h>
+
+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
+ *
+ * @return An error code
+ * @param[in] wapApplicationId The X-Wap-Application-Id indicating a WAP Push application ID
+ * @param[in] listener A listener for receiving the incoming WAP Push messages
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_ALREADY_EXIST The specified @c wapApplicationId is already registered, or
+ * the listener already exists.
+ * @exception E_INVALID_ARG The specified @c wapApplicationId is invalid.
+ * @exception E_SYSTEM A system error has occurred.
+ * @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
+ *
+ * @return An error code
+ * @param[in] wapApplicationId The X-Wap-Application-Id indicating a WAP Push
+ * application ID
+ * @param[in] listener A listener for receiving the incoming WAP Push messages
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND The specified @c wapApplicationId is not registered, or
+ * the specified @c listener is not found.
+ * @exception E_INVALID_ARG The specified @c wapApplicationId is invalid.
+ * @exception E_SYSTEM A system error has occurred.
+ * @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
+ *
+ * @return An error code
+ * @param[in] wapApplicationId The X-Wap-Application-Id indicating a WAP push application ID.
+ * @param[in] contentType The MIME content type of the content.
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c contentType or @c wapApplicationId is invalid.
+ * @exception E_ILLEGAL_ACCESS The application does not have the permission to register the conditions.
+ * @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
+ *
+ * @return An error code
+ * @param[in] wapApplicationId The X-Wap-Application-Id indicating a WAP push application ID.
+ * @param[in] contentType The MIME content type of the content.
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c contentType or @c wapApplicationId is invalid.
+ * @exception E_ILLEGAL_ACCESS The application does not have the permission to unregister the conditions.
+ * @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);
+
+private:
+ /**
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+ *
+ * @param[in] rhs An instance of WapPushManager
+ */
+ WapPushManager(const WapPushManager& rhs);
+
+ /**
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+ *
+ * @param[in] rhs An instance of WapPushManager
+ */
+ WapPushManager& operator =(const WapPushManager& rhs);
+
+private:
+ _WapPushManagerImpl* __pWapPushManagerImpl;
+
+ friend class _WapPushManagerImpl;
+}; // WapPushManager
+
+} } // Tizen::Messaging
+#endif // _FMSG_WAP_PUSH_MANAGER_H_
--- /dev/null
+//
+// 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 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 <FBase.h>
+
+namespace Tizen { namespace Messaging
+{
+class _WapPushMessageImpl;
+
+/**
+* @if VISPARTNER-OPERATOR
+*
+* @class WapPushMessage
+* @brief This class provides methods for handling a WAP Push message.
+*
+* @since 2.0
+*
+* @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;
+
+private:
+ /**
+ * This default constructor is intentionally declared as private so that only the platform can create an instance.
+ *
+ * @since 2.0
+ */
+ WapPushMessage(void);
+
+ /**
+ * This is the copy constructor for the %WapPushMessage class. @n
+ * Copying of objects using this copy constructor is allowed.
+ *
+ * @since 2.0
+ *
+ * @param[in] rhs An instance of %WapPushMessage
+ */
+ WapPushMessage(const WapPushMessage& 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.
+ *
+ * @return A reference to this instance
+ *
+ * @param[in] rhs An instance of %WapPushMessage
+ */
+ WapPushMessage& operator =(const WapPushMessage& rhs);
+
+ /**
+ * This constructor is intentionally declared as private so that only the platform can create an instance.
+ *
+ * @param[in] header The header of the received WAP Push message
+ * @param[in] body The body of the received WAP Push message
+ */
+ WapPushMessage(const Tizen::Base::String& header, const Tizen::Base::ByteBuffer& body);
+
+private:
+ _WapPushMessageImpl* __pWapPushMessageImpl;
+
+ friend class _WapPushMessageImpl;
+}; // WapPushMessage
+
+} } // Tizen::Messaging
+#endif // _FMSG_WAP_PUSH_MESSAGE_H_
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
\ No newline at end of file
--- /dev/null
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=/usr/lib/osp
+includedir=/usr/include/osp
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
+
--- /dev/null
+%define debug_package %{nil}
+%define __strip /bin/true
+
+Name: osp-messaging
+Summary: osp messaging library
+Version: 1.2.0.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(push)
+BuildRequires: pkgconfig(email-service)
+BuildRequires: pkgconfig(pkgmgr)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(libwbxml2)
+BuildRequires: pkgconfig(osp-appfw)
+BuildRequires: osp-appfw-internal-devel
+BuildRequires: pkgconfig(osp-net)
+BuildRequires: osp-net-internal-devel
+BuildRequires: pkgconfig(osp-bluetooth)
+BuildRequires: pkgconfig(osp-nfc)
+BuildRequires: pkgconfig(osp-json)
+BuildRequires: pkgconfig(osp-shell)
+
+# runtime requires
+Requires: osp-appfw
+Requires: osp-bluetooth
+Requires: osp-nfc
+Requires: osp-json
+Requires: osp-shell
+
+%description
+osp messaging library
+
+%package devel
+Summary: osp messaging library (Development)
+Group: TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+osp messaging library (DEV)
+
+%package internal-devel
+Summary: osp messaging library (Internal)
+Group: TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description internal-devel
+osp messaging library (Internal-DEV)
+
+%package debug
+Summary: osp messaging library (Development)
+Group: TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description debug
+osp messaging library (DEV)
+
+%prep
+%setup -q
+
+%build
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+%ifarch %{ix86}
+CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_OSP_EMUL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+%else
+CXXFLAGS="-O2 -g -pipe -Wall -fno-exceptions -Wformat -Wformat-security -Wl,--as-needed -fmessage-length=0 -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -D__SOFTFP__ -mthumb -Wa,-mimplicit-it=thumb -funwind-tables -D_OSP_DEBUG_ -D_OSP_ARMEL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+%endif
+
+# Call make instruction with smp support
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/usr/share/license
+cp %{_builddir}/%{name}-%{version}/LICENSE.APLv2 %{buildroot}/usr/share/license/%{name}
+
+%make_install
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest osp-messaging.manifest
+/usr/share/license/%{name}
+%{_libdir}/osp/*.so*
+
+%files devel
+%{_includedir}/osp/*.h
+%{_libdir}/pkgconfig/osp-messaging.pc
+
+%files internal-devel
+%{_includedir}/osp/messaging/*.h
+
+%files debug
+%{_libdir}/osp/debug/*.so*
--- /dev/null
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+/**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * @file FMsgCbsChannel.cpp\r
+ * @brief This is the implementation file for the %CbsChannel class.\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * This file contains the implementation of the %CbsChannel class.\r
+ *\r
+ * @endif\r
+*/\r
+\r
+#include <messages.h>\r
+#include <FMsgCbsChannel.h>\r
+#include <FBaseSysLog.h>\r
+#include <FSec_AccessController.h>\r
+#include "FMsg_Types.h"\r
+#include "FMsg_CbsChannelImpl.h"\r
+\r
+using namespace Tizen::Base;\r
+using namespace Tizen::Messaging;\r
+using namespace Tizen::Security;\r
+\r
+namespace Tizen { namespace Messaging\r
+{\r
+\r
+CbsChannel::CbsChannel(void)\r
+{\r
+ __pCbsChannelImpl = new (std::nothrow) _CbsChannelImpl();\r
+ SysTryReturnVoidResult(NID_MSG, __pCbsChannelImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");\r
+}\r
+\r
+CbsChannel::CbsChannel(const CbsChannel& value)\r
+{\r
+ __pCbsChannelImpl = new (std::nothrow) _CbsChannelImpl(*(value.__pCbsChannelImpl));\r
+ SysTryReturnVoidResult(NID_MSG, __pCbsChannelImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");\r
+}\r
+\r
+CbsChannel::~CbsChannel(void)\r
+{\r
+ if (__pCbsChannelImpl)\r
+ {\r
+ delete __pCbsChannelImpl;\r
+ }\r
+ __pCbsChannelImpl = null;\r
+}\r
+\r
+CbsChannel&\r
+CbsChannel::operator =(const CbsChannel& rhs)\r
+{\r
+ if (this != &rhs)\r
+ {\r
+ *__pCbsChannelImpl = *(rhs.__pCbsChannelImpl);\r
+ }\r
+\r
+ return (*this);\r
+}\r
+\r
+result\r
+CbsChannel::Construct(int from, int to, const Tizen::Base::String& name)\r
+{\r
+ result r = E_SUCCESS;\r
+\r
+ SysAssertf(__pCbsChannelImpl != null, "The CbsChannel instance is not constructed yet.");\r
+\r
+ // argument check\r
+ SysTryReturnResult(NID_MSG, name.GetLength() <= MAX_CBS_CHANNEL_NAME_LENGTH, E_INVALID_ARG,\r
+ "The length (%d) of channel name is too long.", name.GetLength());\r
+\r
+ SysTryReturnResult(NID_MSG,\r
+ ((to >= 0) && (from >= 0) && (to >= from) && (to <= MAX_CBS_CHANNEL_LIMIT) && ((to - from) <= MAX_CBS_CHANNEL_RANGE)),\r
+ E_INVALID_ARG, "Failed to add construct channel, invalid arguments. to:[%d], from:[%d]", to , from);\r
+\r
+ r = __pCbsChannelImpl->Construct(from, to, name);\r
+ SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_INVALID_ARG, "Failed to construct CbsChannel");\r
+\r
+ return r;\r
+}\r
+\r
+result\r
+CbsChannel::UpdateName(const Tizen::Base::String& name)\r
+{\r
+ result r = E_SUCCESS;\r
+\r
+ SysAssertf(__pCbsChannelImpl != null, "The CbsChannel instance is not constructed yet.");\r
+\r
+ // checking privilege\r
+ r = _AccessController::CheckUserPrivilege(_PRV_CELLBROADCAST);\r
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagating.");\r
+\r
+ // argument check\r
+ SysTryReturn(NID_MSG, name.GetLength() <= MAX_CBS_CHANNEL_NAME_LENGTH, E_INVALID_ARG, r = E_INVALID_ARG,\r
+ "[E_INVALID_ARG] invalid channel name.");\r
+\r
+ r = __pCbsChannelImpl->UpdateName(name);\r
+\r
+ return r;\r
+}\r
+\r
+result\r
+CbsChannel::Deactivate(void)\r
+{\r
+ result r = E_SUCCESS;\r
+\r
+ SysAssertf(__pCbsChannelImpl != null, "The CbsChannel instance is not constructed yet.");\r
+\r
+ // checking privilege\r
+ r = _AccessController::CheckUserPrivilege(_PRV_CELLBROADCAST);\r
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagating.");\r
+\r
+ r = __pCbsChannelImpl->Deactivate();\r
+ return r;\r
+}\r
+\r
+result\r
+CbsChannel::Activate(void)\r
+{\r
+ result r = E_SUCCESS;\r
+\r
+ SysAssertf(__pCbsChannelImpl != null, "The CbsChannel instance is not constructed yet.");\r
+\r
+ // checking privilege\r
+ r = _AccessController::CheckUserPrivilege(_PRV_CELLBROADCAST);\r
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagating.");\r
+\r
+ return __pCbsChannelImpl->Activate();\r
+}\r
+\r
+bool\r
+CbsChannel::IsActivated(void) const\r
+{\r
+ SysAssertf(__pCbsChannelImpl != null, "The CbsChannel instance is not constructed yet.");\r
+\r
+ return(__pCbsChannelImpl->IsActivated());\r
+}\r
+\r
+Tizen::Base::String\r
+CbsChannel::GetName(void) const\r
+{\r
+ SysAssertf(__pCbsChannelImpl != null, "The CbsChannel instance is not constructed yet.");\r
+\r
+ return(__pCbsChannelImpl->GetName());\r
+}\r
+\r
+result\r
+CbsChannel::GetRange(int& from, int& to) const\r
+{\r
+ result r = E_SUCCESS;\r
+\r
+ SysAssertf(__pCbsChannelImpl != null, "The CbsChannel instance is not constructed yet.");\r
+\r
+ r = __pCbsChannelImpl->GetRange(from, to);\r
+\r
+ return r;\r
+}\r
+\r
+} } // Tizen::Messaging\r
--- /dev/null
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+/**\r
+ * @file FMsgCbsMessage.cpp\r
+ * @brief This is the implementation file for the %CbsMessage class.\r
+ *\r
+ * This file contains the implementation of the %CbsMessage class.\r
+ */\r
+\r
+#include <messages.h>\r
+#include <FMsgCbsMessage.h>\r
+#include <FBaseSysLog.h>\r
+#include <FSec_AccessController.h>\r
+#include "FMsg_Types.h"\r
+#include "FMsg_CbsMessageImpl.h"\r
+\r
+using namespace Tizen::Base;\r
+using namespace Tizen::Messaging;\r
+using namespace Tizen::Security;\r
+\r
+namespace Tizen { namespace Messaging\r
+{\r
+\r
+CbsMessage::CbsMessage(void)\r
+{\r
+ __pCbsMessageImpl = new (std::nothrow) _CbsMessageImpl();\r
+ SysTryReturnVoidResult(NID_MSG, __pCbsMessageImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");\r
+}\r
+\r
+CbsMessage::CbsMessage(const CbsMessage& value)\r
+{\r
+ __pCbsMessageImpl = new (std::nothrow) _CbsMessageImpl(*(value.__pCbsMessageImpl));\r
+ SysTryReturnVoidResult(NID_MSG, __pCbsMessageImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");\r
+}\r
+\r
+CbsMessage::~CbsMessage(void)\r
+{\r
+ if (__pCbsMessageImpl)\r
+ {\r
+ delete __pCbsMessageImpl;\r
+ }\r
+ __pCbsMessageImpl = null;\r
+}\r
+\r
+CbsMessage&\r
+CbsMessage::operator =(const CbsMessage& rhs)\r
+{\r
+ if (this != &rhs)\r
+ {\r
+ *__pCbsMessageImpl = *(rhs.__pCbsMessageImpl);\r
+ }\r
+\r
+ return (*this);\r
+}\r
+\r
+CbsMessage*\r
+CbsMessage::CloneN() const\r
+{\r
+ return __pCbsMessageImpl->CloneN();\r
+}\r
+\r
+bool\r
+CbsMessage::Equals(const Tizen::Base::Object& obj) const\r
+{\r
+ const CbsMessage* pCbsMessage = dynamic_cast<const CbsMessage*>(&obj);\r
+ if (!pCbsMessage)\r
+ {\r
+ SysLog(NID_MSG, "dynamic_cast is failed");\r
+ return false;\r
+ }\r
+\r
+ return __pCbsMessageImpl->Equals(*(pCbsMessage->__pCbsMessageImpl));\r
+}\r
+\r
+int\r
+CbsMessage::GetHashCode(void) const\r
+{\r
+ return __pCbsMessageImpl->GetHashCode();\r
+}\r
+\r
+Tizen::Base::ByteBuffer*\r
+CbsMessage::GetSerialNumberN(void) const\r
+{\r
+ result r = E_SUCCESS;\r
+ Tizen::Base::ByteBuffer* pSerialnumber = null;\r
+ ClearLastResult();\r
+\r
+ SysAssertf(__pCbsMessageImpl != null, "The CbsChannel instance is not constructed yet.");\r
+\r
+ pSerialnumber = __pCbsMessageImpl->GetSerialNumberN();\r
+\r
+ r = GetLastResult();\r
+ SetLastResult(r);\r
+\r
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "failed to get cbs message SerialNumber .");\r
+\r
+ return pSerialnumber;\r
+\r
+CATCH:\r
+ SetLastResult(GetLastResult());\r
+\r
+ if (pSerialnumber)\r
+ {\r
+ delete pSerialnumber;\r
+ pSerialnumber = null;\r
+ }\r
+ return null;\r
+}\r
+\r
+Tizen::Base::DateTime\r
+CbsMessage::GetReceivedTime(void) const\r
+{\r
+ SysAssertf(__pCbsMessageImpl != null, "The CbsChannel instance is not constructed yet.");\r
+\r
+ return (__pCbsMessageImpl->GetReceivedTime());\r
+}\r
+\r
+Tizen::Base::String\r
+CbsMessage::GetText(void) const\r
+{\r
+ SysAssertf(__pCbsMessageImpl != null, "The CbsChannel instance is not constructed yet.");\r
+\r
+ return (__pCbsMessageImpl->GetText());\r
+}\r
+\r
+int\r
+CbsMessage::GetMessageId(void) const\r
+{\r
+ SysAssertf(__pCbsMessageImpl != null, "The CbsChannel instance is not constructed yet.");\r
+\r
+ return (__pCbsMessageImpl->GetMessageId());\r
+}\r
+\r
+bool\r
+CbsMessage::IsEtwsNotification(void) const\r
+{\r
+ SysAssertf(__pCbsMessageImpl != null, "The CbsChannel instance is not constructed yet.");\r
+\r
+ return (__pCbsMessageImpl->IsEtwsNotification());\r
+}\r
+\r
+byte \r
+CbsMessage::GetDataCodingScheme(void) const\r
+{\r
+ SysAssertf(__pCbsMessageImpl != null, "The CbsChannel instance is not constructed yet.");\r
+\r
+ return (__pCbsMessageImpl->GetDataCodingScheme());\r
+}\r
+\r
+} } // Tizen::Messaging\r
--- /dev/null
+//
+// 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 FMsgDetailedEmailMessage.cpp
+ * @brief This is the implementation file for the %DetailedEmailMessage class.
+ *
+ * This file contains the implementation of the %DetailedEmailMessage class.
+ */
+
+#include <email-api.h>
+#include <FMsgEmailAttachment.h>
+#include <FMsgDetailedEmailMessage.h>
+#include <FIoFile.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FMsg_DetailedEmailMessageImpl.h"
+#include "FMsg_Types.h"
+
+
+using namespace Tizen::Base;
+using namespace Tizen::Messaging;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Messaging
+{
+
+DetailedEmailMessage::DetailedEmailMessage(void)
+{
+ __pImpl = new (std::nothrow) _DetailedEmailMessageImpl();
+ SysTryReturnVoidResult(NID_MSG, __pImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+}
+
+DetailedEmailMessage::DetailedEmailMessage(const DetailedEmailMessage& value)
+{
+ __pImpl = new (std::nothrow) _DetailedEmailMessageImpl(*(value.__pImpl));
+ SysTryReturnVoidResult(NID_MSG, __pImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+}
+
+DetailedEmailMessage::~DetailedEmailMessage(void)
+{
+ if (__pImpl)
+ {
+ delete __pImpl;
+ __pImpl = null;
+ }
+}
+
+DetailedEmailMessage&
+DetailedEmailMessage::operator =(const DetailedEmailMessage& rhs)
+{
+ if (this != &rhs)
+ {
+ *__pImpl = *(rhs.__pImpl);
+ }
+
+ return (*this);
+}
+
+bool
+DetailedEmailMessage::Equals(const Tizen::Base::Object& obj) const
+{
+ const DetailedEmailMessage* pDetailedEmailMessage = dynamic_cast<const DetailedEmailMessage*>(&obj);
+ if (!pDetailedEmailMessage)
+ {
+ SysLog(NID_MSG, "dynamic_cast is failed");
+ return false;
+ }
+
+ return __pImpl->Equals(*(pDetailedEmailMessage->__pImpl));
+}
+
+int
+DetailedEmailMessage::GetHashCode(void) const
+{
+ return __pImpl->GetHashCode();
+}
+
+Tizen::Base::String
+DetailedEmailMessage::GetMessageId(void) const
+{
+ return(__pImpl->GetMessageId());
+}
+
+String
+DetailedEmailMessage::GetSubject(void) const
+{
+ return(__pImpl->GetSubject());
+}
+
+Tizen::Base::DateTime
+DetailedEmailMessage::GetCreationTime(void) const
+{
+ return(__pImpl->GetCreationTime());
+}
+
+Tizen::Base::String
+DetailedEmailMessage::GetAddress(RecipientType type) const
+{
+ return(__pImpl->GetAddress(type));
+}
+
+Tizen::Base::String
+DetailedEmailMessage::GetFromAddress() const
+{
+ return(__pImpl->GetFromAddress());
+}
+
+Tizen::Base::String
+DetailedEmailMessage::GetReplyToAddress() const
+{
+ return(__pImpl->GetReplyToAddress());
+}
+
+Tizen::Base::String
+DetailedEmailMessage::GetReturnPath() const
+{
+ return(__pImpl->GetReturnPath());
+}
+
+Tizen::Base::String
+DetailedEmailMessage::GetFilePath(EmailMessageBodyType type) const
+{
+ return(__pImpl->GetFilePath(type));
+}
+
+EmailMessagePriority
+DetailedEmailMessage::GetPriority(void) const
+{
+ return (__pImpl->GetPriority());
+}
+
+EmailReturnReceiptType
+DetailedEmailMessage::GetReturnReceiptType(void) const
+{
+ return (__pImpl->GetReturnReceiptType());
+}
+
+int
+DetailedEmailMessage::GetInlineContentCount(void) const
+{
+ return(__pImpl->GetInlineContentCount());
+}
+
+EmailMessageClass
+DetailedEmailMessage::GetClass(void) const
+{
+ return (__pImpl->GetClass());
+}
+
+EmailDigestType
+DetailedEmailMessage::GetDigestType(void) const
+{
+ return (__pImpl->GetDigestType());
+}
+
+EmailSmimeType
+DetailedEmailMessage::GetSmimeType(void) const
+{
+ return (__pImpl->GetSmimeType());
+}
+
+Tizen::Base::Collection::IList*
+DetailedEmailMessage::GetAttachmentListN(void)
+{
+ result r = E_SUCCESS;
+ IList* pAttachmentList = null;
+
+ ClearLastResult();
+
+ pAttachmentList = __pImpl->GetAttachmentListN();
+
+ r = GetLastResult();
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "Failed to get the attachment list.");
+
+ return pAttachmentList;
+
+CATCH:
+ SetLastResult(GetLastResult());
+
+ if (pAttachmentList)
+ {
+ if (pAttachmentList->GetCount() > 0)
+ {
+ pAttachmentList->RemoveAll(true);
+ }
+ delete pAttachmentList;
+ pAttachmentList = null;
+ }
+
+ return null;
+}
+
+result
+DetailedEmailMessage::SetMessageId(const Tizen::Base::String& messageId)
+{
+ result r = E_SUCCESS;
+ ClearLastResult();
+
+ //Argument Check
+ SysTryReturn(NID_MSG,
+ messageId.GetLength() != 0, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] The length of message id is invalid.");
+
+ r = __pImpl->SetMessageId(messageId);
+
+ return r;
+}
+
+result
+DetailedEmailMessage::SetSubject(const Tizen::Base::String& subject)
+{
+ result r = E_SUCCESS;
+ ClearLastResult();
+
+ SysTryReturn(NID_MSG,
+ subject.GetLength() <= MAX_EMAIL_SUBJECT_LENGTH, E_MAX_EXCEEDED, r = E_MAX_EXCEEDED, "The length of msg subject is invalid.");
+
+ r = __pImpl->SetSubject(subject);
+
+ return r;
+}
+
+result
+DetailedEmailMessage::SetCreationTime(const Tizen::Base::DateTime& dateTime)
+{
+ result r = E_SUCCESS;
+ ClearLastResult();
+
+ DateTime minDateTime;
+ DateTime maxDateTime;
+
+ minDateTime.SetValue(1900, 1, 1);
+ maxDateTime.SetValue(2100, 12, 31, 23, 59, 59);
+
+ SysTryReturn(NID_MSG,
+ ((dateTime <= maxDateTime) && (dateTime >= minDateTime)), E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] Propagating.");
+
+ r = __pImpl->SetCreationTime(dateTime);
+
+ return r;
+}
+
+result
+DetailedEmailMessage::SetAddress(RecipientType type, const Tizen::Base::String& recipients)
+{
+ result r = E_SUCCESS;
+ ClearLastResult();
+
+ SysTryReturn(NID_MSG,
+ type >= 0, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] invalid email msg Recipient type");
+ SysTryReturn(NID_MSG,
+ type < MAX_EMAIL_MESSAGE_RECEIPT_TYPE, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] invalid email msg body type");
+ SysTryReturn(NID_MSG,
+ recipients.GetLength() >= MIN_LENGTH_EMAIL, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] The length of address is invalid.");
+
+ r = __pImpl->SetAddress(type, recipients);
+
+ return r;
+}
+
+result
+DetailedEmailMessage::SetFromAddress(const Tizen::Base::String& address)
+{
+ result r = E_SUCCESS;
+ ClearLastResult();
+
+ SysTryReturn(NID_MSG,
+ address.GetLength() >= MIN_LENGTH_EMAIL, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] The length of from address is invalid.");
+
+ r = __pImpl->SetFromAddress(address);
+
+ return r;
+}
+
+result
+DetailedEmailMessage::SetReplyToAddress(const Tizen::Base::String& address)
+{
+ result r = E_SUCCESS;
+ ClearLastResult();
+
+ SysTryReturn(NID_MSG,
+ address.GetLength() >= MIN_LENGTH_EMAIL, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] The length of reply address is invalid.");
+
+ r = __pImpl->SetReplyToAddress(address);
+
+ return r;
+}
+
+result
+DetailedEmailMessage::SetReturnPath(const Tizen::Base::String& address)
+{
+ result r = E_SUCCESS;
+ ClearLastResult();
+
+ SysTryReturn(NID_MSG,
+ address.GetLength() >= MIN_LENGTH_EMAIL, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] The length of return path is invalid.");
+
+ r = __pImpl->SetReturnPath(address);
+
+ return r;
+}
+
+result
+DetailedEmailMessage::SetFilePath(EmailMessageBodyType type, const Tizen::Base::String& filePath)
+{
+ result r = E_SUCCESS;
+ bool isFileExist = false;
+ ClearLastResult();
+
+ //Argument Check
+ SysTryReturn(NID_MSG,
+ type >= 0, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] invalid email msg body type");
+ SysTryReturn(NID_MSG,
+ type < MAX_EMAIL_MESSAGE_BODY_TYPE, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] invalid email msg body type");
+ SysTryReturnResult(NID_MSG, filePath.GetLength() > 0, E_INVALID_ARG, "[E_INVALID_ARG] The file path is empty.");
+ SysTryReturnResult(NID_MSG, filePath.GetLength() <= PATH_MAX, E_INVALID_ARG, "[E_INVALID_ARG] The file path is too long.");
+
+ isFileExist = File::IsFileExist(filePath);
+
+ r = GetLastResult();
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[E_INVALID_ARG] Propagating.");
+
+ if (!isFileExist)
+ {
+ r = E_FILE_NOT_FOUND;
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[E_FILE_NOT_FOUND] Propagating.");
+ }
+
+ r = __pImpl->SetFilePath(type, filePath);
+ return r;
+
+CATCH:
+ SetLastResult(GetLastResult());
+ return r;
+}
+
+result
+DetailedEmailMessage::SetPriority(EmailMessagePriority priority)
+{
+ result r = E_SUCCESS;
+ ClearLastResult();
+
+ //Argument Check
+ SysTryReturn(NID_MSG,
+ priority >= 0, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] invalid email msg priority");
+ SysTryReturn(NID_MSG,
+ priority < MAX_EMAIL_MESSAGE_PRIORITY, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] invalid email msg body type");
+
+ r = __pImpl->SetPriority(priority);
+
+ return r;
+}
+
+result
+DetailedEmailMessage::SetReturnReceiptType(EmailReturnReceiptType type)
+{
+ result r = E_SUCCESS;
+ ClearLastResult();
+
+ //Argument Check
+ SysTryReturn(NID_MSG,
+ type >= 0, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] invalid email Return Receipt Type");
+ SysTryReturn(NID_MSG,
+ type < MAX_EMAIL_MESSAGE_RETURN_RECEIPT_TYPE, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] invalid email msg body type");
+
+ r = __pImpl->SetReturnReceiptType(type);
+
+ return r;
+}
+
+result
+DetailedEmailMessage::SetInlineContentCount(int count)
+{
+ result r = E_SUCCESS;
+ ClearLastResult();
+
+ //Argument Check
+ SysTryReturn(NID_MSG,
+ count >= 0, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] invalid email Inline Content Count");
+
+ r = __pImpl->SetInlineContentCount(count);
+
+ return r;
+}
+
+result
+DetailedEmailMessage::SetClass(EmailMessageClass messageClass)
+{
+ result r = E_SUCCESS;
+ ClearLastResult();
+
+ //Argument Check
+ SysTryReturn(NID_MSG,
+ messageClass >= 0, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] invalid email message Class");
+ SysTryReturn(NID_MSG,
+ messageClass < MAX_EMAIL_MESSAGE_CLASS, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] invalid email msg body type");
+
+ r = __pImpl->SetClass(messageClass);
+
+ return r;
+}
+
+result
+DetailedEmailMessage::SetDigestType(EmailDigestType type)
+{
+ result r = E_SUCCESS;
+ ClearLastResult();
+
+ //Argument Check
+ SysTryReturn(NID_MSG,
+ type >= 0, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] invalid email Digest Type");
+ SysTryReturn(NID_MSG,
+ type < MAX_EMAIL_MESSAGE_DIGEST_TYPE, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] invalid email msg body type");
+
+ r = __pImpl->SetDigestType(type);
+
+ return r;
+}
+
+result
+DetailedEmailMessage::SetSmimeType(EmailSmimeType type)
+{
+ result r = E_SUCCESS;
+ ClearLastResult();
+
+ //Argument Check
+ SysTryReturn(NID_MSG,
+ type >= 0, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] invalid email Smime Type");
+ SysTryReturn(NID_MSG,
+ type < MAX_EMAIL_MESSAGE_SMIME_TYPE, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] invalid email msg body type");
+
+ r = __pImpl->SetSmimeType(type);
+
+ return r;
+}
+
+result
+DetailedEmailMessage::SetAttachmentList(const Tizen::Base::Collection::IList* pList)
+{
+ result r = E_SUCCESS;
+ ClearLastResult();
+
+ SysTryReturn(NID_MSG, pList != null, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] Propagating.");
+
+ //Argument check
+ for (int index = 0; index < pList->GetCount(); index++)
+ {
+ const EmailAttachment* pEmailAttachment = dynamic_cast <const EmailAttachment*>(pList->GetAt(index));
+ SysTryReturn(NID_MSG, pEmailAttachment != null, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] Propagating.");
+ }
+
+ r = __pImpl->SetAttachmentList(pList);
+ return r;
+}
+
+result
+DetailedEmailMessage::ParseMimeFile(const Tizen::Base::String& filePath, DetailedEmailMessage& message)
+{
+ result r = E_SUCCESS;
+ bool isFileExist = false;
+ ClearLastResult();
+
+ //Argument check
+ SysTryReturnResult(NID_MSG, filePath.GetLength() > 0, E_INVALID_ARG, "[E_INVALID_ARG] The file path is empty.");
+ SysTryReturnResult(NID_MSG, filePath.GetLength() <= PATH_MAX, E_INVALID_ARG, "[E_INVALID_ARG] The file path is too long.");
+
+ isFileExist = File::IsFileExist(filePath);
+
+ r = GetLastResult();
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[E_INVALID_ARG] Propagating.");
+
+ if (!isFileExist)
+ {
+ r = E_FILE_NOT_FOUND;
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[E_FILE_NOT_FOUND] Propagating.");
+ }
+
+ r = _DetailedEmailMessageImpl::ParseMimeFile(filePath, message);
+ return r;
+
+CATCH:
+ SetLastResult(GetLastResult());
+ return r;
+}
+
+result
+DetailedEmailMessage::WriteToMimeFile(const DetailedEmailMessage& message, const Tizen::Base::String& filePath)
+{
+ result r = E_SUCCESS;
+ bool isFileExist = false;
+ ClearLastResult();
+
+ //Argument check
+ SysTryReturnResult(NID_MSG, filePath.GetLength() > 0, E_INVALID_ARG, "[E_INVALID_ARG] The file path is empty.");
+ SysTryReturnResult(NID_MSG, filePath.GetLength() <= PATH_MAX, E_INVALID_ARG, "[E_INVALID_ARG] The file path is too long.");
+
+ isFileExist = File::IsFileExist(filePath);
+
+ r = GetLastResult();
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[E_INVALID_ARG] Propagating.");
+
+ if (isFileExist)
+ {
+ r = E_FILE_ALREADY_EXIST;
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[E_FILE_NOT_FOUND] Propagating.");
+ }
+
+ r = _DetailedEmailMessageImpl::WriteToMimeFile(message, filePath);
+ return r;
+
+CATCH:
+ SetLastResult(GetLastResult());
+ return r;
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// 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 FMsgEmailAttachment.cpp
+ * @brief This is the implementation file for the %EmailAttachment class.
+ *
+ * This file contains the implementation of the %EmailAttachment class.
+ */
+
+#include <email-api.h>
+#include <FMsgEmailAttachment.h>
+#include <FMsgDetailedEmailMessage.h>
+#include <FBaseSysLog.h>
+#include <FIoFile.h>
+#include <FSec_AccessController.h>
+#include "FMsg_EmailAttachmentImpl.h"
+#include "FMsg_Types.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Messaging;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Messaging
+{
+
+EmailAttachment::EmailAttachment(void)
+{
+ __pImpl = new (std::nothrow) _EmailAttachmentImpl();
+ SysTryReturnVoidResult(NID_MSG, __pImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+}
+
+EmailAttachment::EmailAttachment(const EmailAttachment& value)
+{
+ __pImpl = new (std::nothrow) _EmailAttachmentImpl(*(value.__pImpl));
+ SysTryReturnVoidResult(NID_MSG, __pImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+}
+
+
+EmailAttachment::~EmailAttachment(void)
+{
+ if (__pImpl)
+ {
+ delete __pImpl;
+ __pImpl = null;
+ }
+}
+
+EmailAttachment&
+EmailAttachment::operator =(const EmailAttachment& rhs)
+{
+ if (this != &rhs)
+ {
+ *__pImpl = *(rhs.__pImpl);
+ }
+
+ return (*this);
+}
+
+bool
+EmailAttachment::Equals(const Tizen::Base::Object& obj) const
+{
+ const EmailAttachment* pEmailAttachment = dynamic_cast<const EmailAttachment*>(&obj);
+ if (!pEmailAttachment)
+ {
+ SysLog(NID_MSG, "dynamic_cast is failed");
+ return false;
+ }
+
+ return __pImpl->Equals(*(pEmailAttachment->__pImpl));
+}
+
+int
+EmailAttachment::GetHashCode(void) const
+{
+ return __pImpl->GetHashCode();
+}
+
+Tizen::Base::String
+EmailAttachment::GetName(void) const
+{
+ return(__pImpl->GetName());
+}
+
+Tizen::Base::String
+EmailAttachment::GetFilePath(void) const
+{
+ return(__pImpl->GetFilePath());
+}
+
+int
+EmailAttachment::GetSize(void) const
+{
+ return(__pImpl->GetSize());
+}
+
+bool
+EmailAttachment::GetInlineContentStatus(void) const
+{
+ return(__pImpl->GetInlineContentStatus());
+}
+
+bool
+EmailAttachment::GetDrmStatus(void) const
+{
+ return(__pImpl->GetDrmStatus());
+}
+
+Tizen::Base::String
+EmailAttachment::GetMimeType(void) const
+{
+ return(__pImpl->GetMimeType());
+}
+
+result
+EmailAttachment::SetName(const Tizen::Base::String& name)
+{
+ result r = E_SUCCESS;
+ ClearLastResult();
+
+ //Argument Check
+ SysTryReturn(NID_MSG,
+ name.GetLength() != 0, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] The length of file name is invalid.");
+ SysTryReturn(NID_MSG,
+ name.GetLength() <= MAX_EMAIL_SUBJECT_LENGTH, E_MAX_EXCEEDED, r = E_MAX_EXCEEDED, "The length of file name is invalid.");
+
+ r = __pImpl->SetName(name);
+
+ return r;
+}
+
+result
+EmailAttachment::SetFilePath(const Tizen::Base::String& filePath)
+{
+ result r = E_SUCCESS;
+ bool isFileExist = false;
+ ClearLastResult();
+
+ //Argument Check
+ SysTryReturnResult(NID_MSG, filePath.GetLength() > 0, E_INVALID_ARG, "[E_INVALID_ARG] The file path is empty.");
+ SysTryReturnResult(NID_MSG, filePath.GetLength() <= PATH_MAX, E_INVALID_ARG, "[E_INVALID_ARG] The file path is too long.");
+
+ isFileExist = File::IsFileExist(filePath);
+
+ r = GetLastResult();
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[E_INVALID_ARG] Propagating.");
+
+ if (!isFileExist)
+ {
+ r = E_FILE_NOT_FOUND;
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[E_FILE_NOT_FOUND] Propagating.");
+ }
+
+ r = __pImpl->SetFilePath(filePath);
+
+ return r;
+
+CATCH:
+ SetLastResult(GetLastResult());
+ return r;
+}
+
+void
+EmailAttachment::SetInlineContentStatus(bool status)
+{
+ __pImpl->SetInlineContentStatus(status);
+}
+
+void
+EmailAttachment::SetDrmStatus(bool status)
+{
+ __pImpl->SetDrmStatus(status);
+}
+
+result
+EmailAttachment::SetMimeType(const Tizen::Base::String& type)
+{
+ result r = E_SUCCESS;
+ ClearLastResult();
+
+ //Argument Check
+ SysTryReturn(NID_MSG,
+ type.GetLength() != 0, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] The length of mime type is invalid.");
+
+ r = __pImpl->SetMimeType(type);
+
+ return r;
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// 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 FMsgEmailManager.cpp
+ * @brief This is the implementation file for the %EmailManager class.
+ *
+ * This file contains the implementation of the %EmailManager class.
+ */
+
+#include <messages.h>
+#include <email.h>
+#include <FMsgEmailManager.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FMsg_EmailManagerImpl.h"
+#include "FMsg_MsgUtil.h"
+#include "FMsg_RecipientListImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Messaging;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Messaging
+{
+
+EmailManager::EmailManager(void)
+ : __pImpl(null)
+{
+}
+
+EmailManager::~EmailManager(void)
+{
+ if (__pImpl)
+ {
+ delete __pImpl;
+ __pImpl = null;
+ }
+}
+
+result
+EmailManager::Construct(IEmailListener& listener)
+{
+ // method return code
+ result r = E_SUCCESS;
+
+ SysAssertf(__pImpl == null, "The EmailManager instance is already constructed.");
+
+ // create an _EmailManagerImpl instance
+ __pImpl = new (std::nothrow) _EmailManagerImpl();
+ SysTryReturnResult(NID_MSG, __pImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+
+ r = __pImpl->Construct(listener);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to Construct an instance.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+result
+EmailManager::Send(const EmailMessage& message, const RecipientList& recipientList, bool saveToSentBox)
+{
+ result r = E_SUCCESS;
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_MESSAGING_EMAIL);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagating.");
+
+ SysAssertf(__pImpl != null, "The EmailManager instance is not constructed yet.");
+ SysTryReturnResult(NID_MSG,
+ MAX_EMAIL_RECIPIENT_COUNT >= _RecipientListImpl::GetInstance(recipientList)->GetTotalRecipientCount(), E_MAX_EXCEEDED,
+ "[E_MAX_EXCEEDED] The number of recipients (%d) exceeds the limit (%d).",
+ _RecipientListImpl::GetInstance(recipientList)->GetTotalRecipientCount(), MAX_EMAIL_RECIPIENT_COUNT);
+ SysTryReturnResult(NID_MSG,
+ 0 != _RecipientListImpl::GetInstance(recipientList)->GetTotalRecipientCount(), E_INVALID_ARG,
+ "[E_INVALID_ARG] The number of recipients is 0.");
+
+ // email address validity check
+ r = _MsgUtil::CheckEmailAddressValidity(recipientList);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] There is an invalid email address in the recipient list.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ // send an email message
+ r = __pImpl->Send(message, recipientList, saveToSentBox);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to send the email message.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ return E_SUCCESS;
+
+CATCH:
+ return r;
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// 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 FMsgEmailMessage.cpp
+ * @brief This is the implementation file for the %EmailMessage class.
+ *
+ * This file contains the implementation of the %EmailMessage class.
+ */
+
+#include <limits.h>
+#include <messages.h>
+#include <email.h>
+#include <FMsgEmailMessage.h>
+#include <FIoFile.h>
+#include <FBaseSysLog.h>
+#include "FMsg_EmailMessageImpl.h"
+#include "FMsg_Types.h"
+#include "FMsg_MsgUtil.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Messaging;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Messaging
+{
+
+EmailMessage::EmailMessage(void)
+{
+ __pImpl = new (std::nothrow) _EmailMessageImpl();
+ SysTryReturnVoidResult(NID_MSG, __pImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+}
+
+EmailMessage::EmailMessage(const EmailMessage& value)
+{
+ __pImpl = new (std::nothrow) _EmailMessageImpl(*(value.__pImpl));
+ SysTryReturnVoidResult(NID_MSG, __pImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+}
+
+EmailMessage::~EmailMessage(void)
+{
+ if (__pImpl)
+ {
+ delete __pImpl;
+ __pImpl = null;
+ }
+}
+
+EmailMessage&
+EmailMessage::operator =(const EmailMessage& rhs)
+{
+ if (this != &rhs)
+ {
+ *__pImpl = *(rhs.__pImpl);
+ }
+
+ return (*this);
+}
+
+bool
+EmailMessage::Equals(const Tizen::Base::Object& obj) const
+{
+ const EmailMessage* pEmailMessage = dynamic_cast<const EmailMessage*>(&obj);
+ if (!pEmailMessage)
+ {
+ SysLog(NID_MSG, "dynamic_cast is failed");
+ return false;
+ }
+
+ return __pImpl->Equals(*(pEmailMessage->__pImpl));}
+
+int
+EmailMessage::GetHashCode(void) const
+{
+ return __pImpl->GetHashCode();
+}
+
+result
+EmailMessage::SetSubject(const String& subject)
+{
+ result r = E_SUCCESS;
+
+ if (subject.GetLength() > MAX_EMAIL_SUBJECT_LENGTH)
+ {
+ r = E_MAX_EXCEEDED;
+ SysLogException(NID_MSG, r, "The length of subject exceeds the limit.");
+ goto CATCH;
+ }
+
+ // set subject
+ r = __pImpl->SetSubject(subject);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to set the subject.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+String
+EmailMessage::GetSubject(void) const
+{
+ return __pImpl->GetSubject();
+}
+
+result
+EmailMessage::SetText(const String& text)
+{
+ result r = E_SUCCESS;
+
+ if (text.GetLength() > MAX_EMAIL_BODY_TEXT_LENGTH)
+ {
+ r = E_MAX_EXCEEDED;
+ SysLogException(NID_MSG, r, "The length of body text exceeds the limit.");
+ goto CATCH;
+ }
+
+ r = __pImpl->SetText(text);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to set the body text.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+String
+EmailMessage::GetText(void) const
+{
+ return __pImpl->GetText();
+}
+
+result
+EmailMessage::AddAttachment(const String& filePath)
+{
+ SysTryReturnResult(NID_MSG, filePath.GetLength() > 0, E_INVALID_ARG, "[E_INVALID_ARG] The file path is empty.");
+ SysTryReturnResult(NID_MSG, filePath.GetLength() <= PATH_MAX, E_INVALID_ARG, "[E_INVALID_ARG] The file path is too long.");
+
+ result r = E_SUCCESS;
+
+ // check file existence
+ if (File::IsFileExist(filePath) == false)
+ {
+ r = E_FILE_NOT_FOUND;
+ SysLogException(NID_MSG, r, "[E_FILE_NOT_FOUND] File not found.");
+ goto CATCH;
+ }
+
+ r = __pImpl->AddAttachment(filePath);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to add the attachment.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+result
+EmailMessage::RemoveAttachment(const Tizen::Base::String& filePath)
+{
+ SysTryReturnResult(NID_MSG, filePath.GetLength() > 0, E_INVALID_ARG, "[E_INVALID_ARG] The file path is empty.");
+ SysTryReturnResult(NID_MSG, filePath.GetLength() <= PATH_MAX, E_INVALID_ARG, "[E_INVALID_ARG] The file path is too long.");
+
+ result r = E_SUCCESS;
+
+ // check file existence
+ if (File::IsFileExist(filePath) == false)
+ {
+ r = E_FILE_NOT_FOUND;
+ SysLogException(NID_MSG, r, "[E_FILE_NOT_FOUND] File not exist.");
+ goto CATCH;
+ }
+
+ r = __pImpl->RemoveAttachment(filePath);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to remove the attachment.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+IList*
+EmailMessage::GetAttachmentListN(void) const
+{
+ result r = E_SUCCESS;
+ IList* pAttachmentList = null;
+
+ ClearLastResult();
+
+ pAttachmentList = __pImpl->GetAttachmentListN();
+ r = GetLastResult();
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to get the attachment list.", GetErrorMessage(r));
+ SetLastResult(r);
+ goto CATCH;
+ }
+
+ return pAttachmentList;
+
+CATCH:
+ if (pAttachmentList)
+ {
+ if (pAttachmentList->GetCount() > 0)
+ {
+ pAttachmentList->RemoveAll(true);
+ }
+ delete pAttachmentList;
+ pAttachmentList = null;
+ }
+
+ return null;
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+/**\r
+ * @file FMsgEtwsPrimaryNotification.cpp\r
+ * @brief This is the implementation file for the %EtwsPrimaryNotification class.\r
+ *\r
+ * This file contains the implementation of the %EtwsPrimaryNotification class.\r
+ */\r
+\r
+#include <messages.h>\r
+#include <FMsgEtwsPrimaryNotification.h>\r
+#include <FBaseSysLog.h>\r
+#include <FSec_AccessController.h>\r
+#include "FMsg_Types.h"\r
+#include "FMsg_EtwsPrimaryNotificationImpl.h"\r
+\r
+using namespace Tizen::Base;\r
+using namespace Tizen::Messaging;\r
+using namespace Tizen::Security;\r
+\r
+namespace Tizen { namespace Messaging\r
+{\r
+\r
+EtwsPrimaryNotification::EtwsPrimaryNotification(void)\r
+{\r
+ __pEtwsPrimaryNotificationImpl = new (std::nothrow) _EtwsPrimaryNotificationImpl();\r
+ SysTryReturnVoidResult(NID_MSG, __pEtwsPrimaryNotificationImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");\r
+}\r
+\r
+EtwsPrimaryNotification::EtwsPrimaryNotification(const EtwsPrimaryNotification& value)\r
+{\r
+ __pEtwsPrimaryNotificationImpl = new (std::nothrow) _EtwsPrimaryNotificationImpl(*(value.__pEtwsPrimaryNotificationImpl));\r
+ SysTryReturnVoidResult(NID_MSG, __pEtwsPrimaryNotificationImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");\r
+}\r
+\r
+EtwsPrimaryNotification::~EtwsPrimaryNotification(void)\r
+{\r
+ if (__pEtwsPrimaryNotificationImpl)\r
+ {\r
+ delete __pEtwsPrimaryNotificationImpl;\r
+ }\r
+ __pEtwsPrimaryNotificationImpl = null;\r
+}\r
+\r
+EtwsPrimaryNotification&\r
+EtwsPrimaryNotification::operator =(const EtwsPrimaryNotification& rhs)\r
+{\r
+ if (this != &rhs)\r
+ {\r
+ *__pEtwsPrimaryNotificationImpl = *(rhs.__pEtwsPrimaryNotificationImpl);\r
+ }\r
+\r
+ return (*this);\r
+}\r
+\r
+EtwsPrimaryNotification*\r
+EtwsPrimaryNotification::CloneN() const\r
+{\r
+ return __pEtwsPrimaryNotificationImpl->CloneN();\r
+}\r
+\r
+bool\r
+EtwsPrimaryNotification::Equals(const Tizen::Base::Object& obj) const\r
+{\r
+ const EtwsPrimaryNotification* pEtwsPrimaryNotification = dynamic_cast<const EtwsPrimaryNotification*>(&obj);\r
+ if (!pEtwsPrimaryNotification)\r
+ {\r
+ SysLog(NID_MSG, "dynamic_cast is failed");\r
+ return false;\r
+ }\r
+\r
+ return __pEtwsPrimaryNotificationImpl->Equals(*(pEtwsPrimaryNotification->__pEtwsPrimaryNotificationImpl));\r
+}\r
+\r
+int\r
+EtwsPrimaryNotification::GetHashCode(void) const\r
+{\r
+ return __pEtwsPrimaryNotificationImpl->GetHashCode();\r
+}\r
+\r
+Tizen::Base::ByteBuffer*\r
+EtwsPrimaryNotification::GetSerialNumberN(void) const\r
+{\r
+ result r = E_SUCCESS;\r
+ Tizen::Base::ByteBuffer* pSerialnumber = null;\r
+ ClearLastResult();\r
+\r
+ SysAssertf(__pEtwsPrimaryNotificationImpl != null, "The CbsChannel instance is not constructed yet.");\r
+\r
+ pSerialnumber = __pEtwsPrimaryNotificationImpl->GetSerialNumberN();\r
+\r
+ r = GetLastResult();\r
+ SetLastResult(r);\r
+\r
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "failed to get cbs message SerialNumber .");\r
+\r
+ return pSerialnumber;\r
+\r
+CATCH:\r
+ SetLastResult(GetLastResult());\r
+\r
+ if (pSerialnumber)\r
+ {\r
+ delete pSerialnumber;\r
+ pSerialnumber = null;\r
+ }\r
+ return null;\r
+}\r
+\r
+Tizen::Base::DateTime\r
+EtwsPrimaryNotification::GetReceivedTime(void) const\r
+{\r
+ SysAssertf(__pEtwsPrimaryNotificationImpl != null, "The CbsChannel instance is not constructed yet.");\r
+\r
+ return (__pEtwsPrimaryNotificationImpl->GetReceivedTime());\r
+}\r
+\r
+Tizen::Base::ByteBuffer*\r
+EtwsPrimaryNotification::GetWarningSecurityInfoN(void) const\r
+{\r
+ result r = E_SUCCESS;\r
+ Tizen::Base::ByteBuffer* pSecurityInfo = null;\r
+ ClearLastResult();\r
+\r
+ SysAssertf(__pEtwsPrimaryNotificationImpl != null, "The CbsChannel instance is not constructed yet.");\r
+\r
+ pSecurityInfo = __pEtwsPrimaryNotificationImpl->GetWarningSecurityInfoN();\r
+\r
+ r = GetLastResult();\r
+ SetLastResult(r);\r
+\r
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "failed to get cbs message SerialNumber .");\r
+\r
+ return pSecurityInfo;\r
+\r
+CATCH:\r
+ SetLastResult(GetLastResult());\r
+\r
+ if (pSecurityInfo)\r
+ {\r
+ delete pSecurityInfo;\r
+ pSecurityInfo = null;\r
+ }\r
+ return null;\r
+}\r
+\r
+int\r
+EtwsPrimaryNotification::GetMessageId(void) const\r
+{\r
+ SysAssertf(__pEtwsPrimaryNotificationImpl != null, "The CbsChannel instance is not constructed yet.");\r
+\r
+ return (__pEtwsPrimaryNotificationImpl->GetMessageId());\r
+}\r
+\r
+Tizen::Base::ByteBuffer*\r
+EtwsPrimaryNotification::GetWarningTypeN(void) const\r
+{\r
+ SysAssertf(__pEtwsPrimaryNotificationImpl != null, "The CbsChannel instance is not constructed yet.");\r
+\r
+ result r = E_SUCCESS;\r
+ Tizen::Base::ByteBuffer* pWarningType = null;\r
+ ClearLastResult();\r
+\r
+ SysAssertf(__pEtwsPrimaryNotificationImpl != null, "The CbsChannel instance is not constructed yet.");\r
+\r
+ pWarningType = __pEtwsPrimaryNotificationImpl->GetWarningTypeN();\r
+\r
+ r = GetLastResult();\r
+ SetLastResult(r);\r
+\r
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "failed to get cbs Warning type .");\r
+\r
+ return pWarningType;\r
+\r
+CATCH:\r
+ SetLastResult(GetLastResult());\r
+\r
+ if (pWarningType)\r
+ {\r
+ delete pWarningType;\r
+ pWarningType = null;\r
+ }\r
+ return null;\r
+}\r
+\r
+} } // Tizen::Messaging\r
--- /dev/null
+//
+// 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 FMsgMmsManager.cpp
+ * @brief This is the implementation file for the %MmsManager class.
+ *
+ * This file contains the implementation of the %MmsManager class.
+ */
+
+#include <messages.h>
+#include <email.h>
+#include <FMsgMmsManager.h>
+#include <FMsgMmsMessage.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FMsg_Types.h"
+#include "FMsg_MmsEvent.h"
+#include "FMsg_MsgUtil.h"
+#include "FMsg_MmsManagerImpl.h"
+#include "FMsg_RecipientListImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Messaging;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Messaging
+{
+
+MmsManager::MmsManager(void)
+ : __pImpl(null)
+{
+}
+
+MmsManager::~MmsManager(void)
+{
+ if (__pImpl)
+ {
+ delete __pImpl;
+ __pImpl = null;
+ }
+}
+
+result
+MmsManager::Construct(IMmsListener& listener)
+{
+ // method return code
+ result r = E_SUCCESS;
+
+ SysAssertf(__pImpl == null, "The MmsManager instance is already constructed.");
+ // create an _MmsManagerImpl instance
+ __pImpl = new (std::nothrow) _MmsManagerImpl();
+ SysTryReturn(NID_MSG, __pImpl != null, E_OUT_OF_MEMORY, r = E_OUT_OF_MEMORY, "Failed to allocate memory");
+
+ r = __pImpl->Construct(listener);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to construct an instance.", GetErrorMessage(r));
+
+ return r;
+
+CATCH:
+ if (__pImpl)
+ {
+ delete __pImpl;
+ __pImpl = null;
+ }
+
+ return r;
+}
+
+result
+MmsManager::Send(const MmsMessage& message, const RecipientList& recipientList, bool saveToSentBox)
+{
+ result r = E_SUCCESS;
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_MESSAGING_MMS);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagating.");
+
+ SysAssertf(__pImpl != null, "The MmsManager instance is not constructed yet.");
+ SysTryReturnResult(NID_MSG,
+ MAX_MMS_RECIPIENT_COUNT >= _RecipientListImpl::GetInstance(recipientList)->GetTotalRecipientCount(), E_MAX_EXCEEDED,
+ "The number of recipients exceeds the limit (%d).", MAX_MMS_RECIPIENT_COUNT);
+ SysTryReturnResult(NID_MSG,
+ 0 != _RecipientListImpl::GetInstance(recipientList)->GetTotalRecipientCount(), E_INVALID_ARG,
+ "[E_INVALID_ARG] The number of recipients is 0.");
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // address-check will be done in SHP layer.
+ ////////////////////////////////////////////////////////////////////////////////
+
+ // mms address validity check
+ r = _MsgUtil::CheckPhoneNumberValidity(_MSG_MMS, recipientList);
+
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] There is an invalid phone number in the recipient list.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ // not allow the empty message.
+ if (message.GetSubject().IsEmpty() && message.GetText().IsEmpty() && message.GetAttachment(MMS_IMAGE).IsEmpty() &&
+ message.GetAttachment(MMS_AUDIO).IsEmpty() && message.GetAttachment(MMS_VIDEO).IsEmpty())
+ {
+ r = E_INVALID_ARG;
+ SysLogException(NID_MSG, r, "[E_INVALID_ARG] The message is empty.");
+ return E_INVALID_ARG;
+ }
+
+ // send an MMS message
+ r = __pImpl->Send(message, recipientList, saveToSentBox);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to send the MMS message.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ return E_SUCCESS;
+
+CATCH:
+ return r;
+}
+} } // Tizen::Messaging
--- /dev/null
+//
+// 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 FMsgMmsMessage.cpp
+ * @brief This is the implementation file for the %MmsMessage class.
+ *
+ * This file contains the implementation of the %MmsMessage class.
+ */
+
+#include <limits.h>
+#include <messages.h>
+#include <email.h>
+#include <FMsgMmsMessage.h>
+#include <FBaseInternalTypes.h>
+#include <FApp_AppInfo.h>
+#include <FBaseSysLog.h>
+#include "FMsg_MmsMessageImpl.h"
+#include "FMsg_Types.h"
+#include "FMsg_MsgUtil.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Messaging;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Messaging
+{
+
+MmsMessage::MmsMessage(void)
+{
+ __pImpl = new (std::nothrow) _MmsMessageImpl();
+ SysTryReturnVoidResult(NID_MSG, __pImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+}
+
+MmsMessage::MmsMessage(const MmsMessage& value)
+{
+ __pImpl = new (std::nothrow) _MmsMessageImpl(*(value.__pImpl));
+ SysTryReturnVoidResult(NID_MSG, __pImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+}
+
+MmsMessage::~MmsMessage(void)
+{
+ if (__pImpl)
+ {
+ delete __pImpl;
+ __pImpl = null;
+ }
+}
+
+MmsMessage&
+MmsMessage::operator =(const MmsMessage& rhs)
+{
+ if (this != &rhs)
+ {
+ *__pImpl = *(rhs.__pImpl);
+ }
+
+ return (*this);
+}
+
+bool
+MmsMessage::Equals(const Tizen::Base::Object& obj) const
+{
+ const MmsMessage* pMmsMessage = dynamic_cast<const MmsMessage*>(&obj);
+ if (!pMmsMessage)
+ {
+ SysLog(NID_MSG, "dynamic_cast is failed");
+ return false;
+ }
+
+ return __pImpl->Equals(*(pMmsMessage->__pImpl));
+}
+
+int
+MmsMessage::GetHashCode(void) const
+{
+ return __pImpl->GetHashCode();
+}
+
+result
+MmsMessage::SetSubject(const String& subject)
+{
+ result r = E_SUCCESS;
+
+ if (subject.GetLength() > MAX_MMS_SUBJECT_LENGTH)
+ {
+ r = E_MAX_EXCEEDED;
+ SysLogException(NID_MSG, r, "The length of subject exceeds the limit.");
+ goto CATCH;
+ }
+
+ // set subject
+ r = __pImpl->SetSubject(subject);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to set the subject.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+String
+MmsMessage::GetSubject(void) const
+{
+ return __pImpl->GetSubject();
+}
+
+result
+MmsMessage::SetText(const String& text)
+{
+ result r = E_SUCCESS;
+
+ if (text.GetLength() > MAX_MMS_BODY_TEXT_LENGTH)
+ {
+ r = E_MAX_EXCEEDED;
+ SysLogException(NID_MSG, r, "The length of body text exceeds the limit.");
+ goto CATCH;
+ }
+
+ // set subject
+ r = __pImpl->SetText(text);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to set the text.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+String
+MmsMessage::GetText(void) const
+{
+ return __pImpl->GetText();
+}
+
+result
+MmsMessage::AddAttachment(MmsAttachmentFormat format, const Tizen::Base::String& filePath)
+{
+ result r = E_SUCCESS;
+
+ // firstly, argument check
+ SysTryReturn(NID_MSG, (format >= MMS_IMAGE && format <= MMS_VCALENDAR), E_INVALID_ARG, r = E_INVALID_ARG,
+ "[E_INVALID_ARG] invalid MmsAttachmentFormat[%d] arguments.", (int) format);
+
+ SysTryReturn(NID_MSG, filePath.GetLength() > 0, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] The file path is empty.");
+ SysTryReturn(NID_MSG, filePath.GetLength() <= PATH_MAX, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] The file path is too long.");
+
+ r = __pImpl->AddAttachment(format, filePath);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to add an attachment.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+result
+MmsMessage::RemoveAttachment(MmsAttachmentFormat format)
+{
+ result r = E_SUCCESS;
+
+ // firstly, argument check
+ SysTryReturn(NID_MSG, (format >= MMS_IMAGE && format <= MMS_VCALENDAR), E_INVALID_ARG, r = E_INVALID_ARG,
+ "[E_INVALID_ARG] invalid MmsAttachmentFormat[%d] arguments.", (int) format);
+
+ r = __pImpl->RemoveAttachment(format);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to remove an attachment.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+String
+MmsMessage::GetAttachment(MmsAttachmentFormat format) const
+{
+ String returnValue;
+
+ ClearLastResult();
+
+ // firstly, argument check
+
+ if (format < MMS_IMAGE || format > MMS_VCALENDAR)
+ {
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, GetLastResult(), "[E_INVALID_ARG] invalid MmsAttachmentFormat[%d] arguments.", (int) format);
+ returnValue = L"";
+ return returnValue;
+ }
+
+ // get attachment
+ returnValue = __pImpl->GetAttachment(format);
+ SetLastResult(GetLastResult());
+
+ return returnValue;
+}
+} } // Tizen::Messaging
--- /dev/null
+//
+// 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 FMsgPushManager.cpp
+* @brief This is the implementation file for the %PushManager class.
+*
+* This file contains the implementation of the %PushManager class.
+*/
+
+#include <FMsgPushManager.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FMsg_PushManagerImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Messaging
+{
+
+PushManager::PushManager(void)
+ : __pPushManagerImpl(null)
+{
+}
+
+PushManager::~PushManager(void)
+{
+ delete __pPushManagerImpl;
+ __pPushManagerImpl = null;
+}
+
+result
+PushManager::Construct(IPushManagerListener& managerListener, IPushEventListener& eventListener)
+{
+ result r = E_SUCCESS;
+
+ r = _AccessController::CheckUserPrivilege(_PRV_PUSH);
+ SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+ SysAssertf(__pPushManagerImpl == null,
+ "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+ __pPushManagerImpl = new (std::nothrow) _PushManagerImpl();
+ SysTryReturnResult(NID_MSG, __pPushManagerImpl != null, E_OUT_OF_MEMORY, "Insufficient memory.");
+
+ r = __pPushManagerImpl->Construct(managerListener, eventListener);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ delete __pPushManagerImpl;
+ __pPushManagerImpl = null;
+ }
+
+ return r;
+}
+
+result
+PushManager::RegisterPushService(RequestId& reqId)
+{
+ result r = E_SUCCESS;
+
+ r = _AccessController::CheckUserPrivilege(_PRV_PUSH);
+ SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+ SysAssertf(__pPushManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ r = __pPushManagerImpl->RegisterPushService(reqId);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+
+ return r;
+}
+
+result
+PushManager::UnregisterPushService(RequestId& reqId)
+{
+ result r = E_SUCCESS;
+
+ r = _AccessController::CheckUserPrivilege(_PRV_PUSH);
+ SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+ SysAssertf(__pPushManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ r = __pPushManagerImpl->UnregisterPushService(reqId);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+
+ return r;
+}
+
+bool
+PushManager::IsPushServiceRegistered(void) const
+{
+ bool isRegistered = false;
+
+ ClearLastResult();
+
+ SysAssertf(__pPushManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ isRegistered = __pPushManagerImpl->IsPushServiceRegistered();
+
+ return isRegistered;
+}
+
+IList*
+PushManager::GetUnreadMessagesN(void)
+{
+ result r = E_SUCCESS;
+ IList* pList = null;
+
+ ClearLastResult();
+
+ r = _AccessController::CheckUserPrivilege(_PRV_PUSH);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, null, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+
+ SysAssertf(__pPushManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ pList = __pPushManagerImpl->GetUnreadMessagesN();
+ r = GetLastResult();
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+
+ return pList;
+}
+
+result
+PushManager::SendPushMessage(const PushMessage& message, const String& registrationId, const Tizen::Base::String& appSecret, RequestId& reqId)
+{
+ result r = E_SUCCESS;
+
+ r = _AccessController::CheckUserPrivilege(_PRV_PUSH);
+ SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+ SysAssertf(__pPushManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ r = __pPushManagerImpl->SendPushMessage(message, registrationId, appSecret, reqId);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+
+ return r;
+}
+
+result
+PushManager::SendPushMessage(const PushMessage& message, const IList& registrationIdList, const Tizen::Base::String& appSecret, RequestId& reqId)
+{
+ result r = E_SUCCESS;
+
+ r = _AccessController::CheckUserPrivilege(_PRV_PUSH);
+ SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+ SysAssertf(__pPushManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ r = __pPushManagerImpl->SendPushMessage(message, registrationIdList, appSecret, reqId);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+
+ return r;
+}
+
+int
+PushManager::GetMaxRecipientCount(void)
+{
+ return _PushManagerImpl::GetMaxRecipientCount();
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// 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 FMsgPushMessage.cpp
+* @brief This is the implementation file for the %PushMessage class.
+*
+* This file contains the implementation of the %PushMessage class.
+*/
+
+#include <FMsgPushMessage.h>
+#include <FBaseSysLog.h>
+#include "FMsg_PushMessageImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Shell;
+
+namespace Tizen { namespace Messaging
+{
+
+PushMessage::PushMessage(void)
+{
+ __pPushMessageImpl = new (std::nothrow) _PushMessageImpl();
+ SysTryReturnVoidResult(NID_MSG, __pPushMessageImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+}
+
+PushMessage::PushMessage(const DateTime& dateTime, const String& text)
+{
+ __pPushMessageImpl = new (std::nothrow) _PushMessageImpl(dateTime, text);
+ SysTryReturnVoidResult(NID_MSG, __pPushMessageImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+}
+
+PushMessage::~PushMessage(void)
+{
+ delete __pPushMessageImpl;
+ __pPushMessageImpl = null;
+}
+
+PushMessage::PushMessage(const PushMessage& rhs)
+{
+ __pPushMessageImpl = new (std::nothrow) _PushMessageImpl(*(rhs.__pPushMessageImpl));
+ SysTryReturnVoidResult(NID_MSG, __pPushMessageImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+}
+
+PushMessage&
+PushMessage::operator =(const PushMessage& rhs)
+{
+ if (this == &rhs)
+ {
+ return *this;
+ }
+
+ *__pPushMessageImpl = *rhs.__pPushMessageImpl;
+
+ return *this;
+}
+
+bool
+PushMessage::Equals(const Object& obj) const
+{
+ const PushMessage* pRhs = dynamic_cast<const PushMessage*>(&obj);
+ if (pRhs == null)
+ {
+ return false;
+ }
+
+ const _PushMessageImpl* pRhsImpl = _PushMessageImpl::GetInstance(*pRhs);
+ if (pRhsImpl == null)
+ {
+ return false;
+ }
+
+ return __pPushMessageImpl->Equals(*pRhsImpl);
+}
+
+int
+PushMessage::GetHashCode(void) const
+{
+ return __pPushMessageImpl->GetHashCode();
+}
+
+DateTime
+PushMessage::GetReceivedTime(void) const
+{
+ return __pPushMessageImpl->GetReceivedTime();
+}
+
+String
+PushMessage::GetText(void) const
+{
+ return __pPushMessageImpl->GetText();
+}
+
+result
+PushMessage::SetAction(PushAction action)
+{
+ return __pPushMessageImpl->SetAction(action);
+}
+
+PushAction
+PushMessage::GetAction(void) const
+{
+ return __pPushMessageImpl->GetAction();
+}
+
+result
+PushMessage::SetNotification(const NotificationRequest& notificationRequest)
+{
+ return __pPushMessageImpl->SetNotification(notificationRequest);
+}
+
+NotificationRequest
+PushMessage::GetNotification(void) const
+{
+ return __pPushMessageImpl->GetNotification();
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// 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 FMsgRecipientList.cpp
+ * @brief This is the implementation file for the %RecipientList class.
+ *
+ * This file contains the implementation of the %RecipientList class.
+ */
+
+#include <FMsgRecipientList.h>
+#include <FBaseSysLog.h>
+#include "FMsg_RecipientListImpl.h"
+#include "FMsg_Types.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Messaging
+{
+
+RecipientList::RecipientList(void)
+{
+ __pImpl = new (std::nothrow) _RecipientListImpl();
+ SysTryReturnVoidResult(NID_MSG, __pImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+}
+
+RecipientList::~RecipientList(void)
+{
+ if (__pImpl)
+ {
+ delete __pImpl;
+ __pImpl = null;
+ }
+}
+
+RecipientList::RecipientList(const RecipientList& value)
+{
+ __pImpl = new (std::nothrow) _RecipientListImpl(*(value.__pImpl));
+ SysTryReturnVoidResult(NID_MSG, __pImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+}
+
+RecipientList&
+RecipientList::operator =(const RecipientList& value)
+{
+ if (this != &value)
+ {
+ *__pImpl = *(value.__pImpl);
+ }
+
+ return (*this);
+}
+
+bool
+RecipientList::operator ==(const RecipientList& rhs) const
+{
+ return (Equals(rhs));
+}
+
+bool
+RecipientList::operator !=(const RecipientList& rhs) const
+{
+ return (!Equals(rhs));
+}
+
+bool
+RecipientList::Equals(const Tizen::Base::Object& value) const
+{
+ const RecipientList* pRecipientList = dynamic_cast<const RecipientList*>(&value);
+ if (!pRecipientList)
+ {
+ SysLog(NID_MSG, "dynamic_cast is failed");
+ return false;
+ }
+
+ return __pImpl->Equals(*(pRecipientList->__pImpl));
+}
+
+int
+RecipientList::GetHashCode(void) const
+{
+ return __pImpl->GetHashCode();
+}
+
+result
+RecipientList::Add(RecipientType type, const String& recipient)
+{
+ result r = E_SUCCESS;
+
+ SysTryReturn(NID_MSG, (type >= RECIPIENT_TYPE_TO && type <= RECIPIENT_TYPE_BCC), E_INVALID_ARG, r = E_INVALID_ARG,
+ "[E_INVALID_ARG] Invalid RecipientType [%d] argument.",
+ (int) type);
+ SysTryReturn(NID_MSG, (recipient.GetLength() >= MIN_LENGTH_PHONE) && (recipient.GetLength() <= MAX_LENGTH_EMAIL), E_INVALID_ARG,
+ r = E_INVALID_ARG, "[E_INVALID_ARG] The length (%d) of the phone number or email address is too short or too long.", recipient.GetLength());
+
+ r = __pImpl->Add(type, recipient);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to add the recipient.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ return E_SUCCESS;
+
+CATCH:
+ return r;
+}
+
+result
+RecipientList::Remove(RecipientType type, const Tizen::Base::String& recipient)
+{
+ result r = E_SUCCESS;
+
+ SysTryReturn(NID_MSG, (type >= RECIPIENT_TYPE_TO && type <= RECIPIENT_TYPE_BCC), E_INVALID_ARG, r = E_INVALID_ARG,
+ "[E_INVALID_ARG] Invalid RecipientType [%d] argument.",
+ (int) type);
+ SysTryReturn(NID_MSG, (recipient.GetLength() >= MIN_LENGTH_PHONE) && (recipient.GetLength() <= MAX_LENGTH_EMAIL), E_INVALID_ARG,
+ r = E_INVALID_ARG, "[E_INVALID_ARG] The length (%d) of the phone number or email address is too short or too long.", recipient.GetLength());
+
+ r = __pImpl->Remove(type, recipient);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to remove the recipient.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ return E_SUCCESS;
+
+CATCH:
+ return r;
+}
+
+result
+RecipientList::Set(RecipientType type, const Tizen::Base::Collection::IList& list)
+{
+ result r = E_SUCCESS;
+
+ SysTryReturn(NID_MSG, (type >= RECIPIENT_TYPE_TO && type <= RECIPIENT_TYPE_BCC), E_INVALID_ARG,
+ r = E_INVALID_ARG, "[E_INVALID_ARG] Invalid RecipientType [%d] argument.",
+ (int) type);
+
+ if (list.GetCount() == 0)
+ {
+ r = E_INVALID_ARG;
+ SysLogException(NID_MSG, r, "[E_INVALID_ARG] The input list has no item.");
+ goto CATCH;
+ }
+
+ for (int index = 0; index < list.GetCount(); index++)
+ {
+ String* pItem = (String*) (list.GetAt(index));
+ if (pItem->GetLength() < MIN_LENGTH_PHONE || pItem->GetLength() > MAX_LENGTH_EMAIL)
+ {
+ r = E_INVALID_ARG;
+ SysLogException(NID_MSG, r, "[E_INVALID_ARG] The length of a recipient in the input list is invalid (too short or too long).");
+ goto CATCH;
+ }
+ }
+
+ r = __pImpl->Set(type, list);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to set the corresponding recipient list.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+Tizen::Base::Collection::IList*
+RecipientList::GetListN(RecipientType type) const
+{
+ //ArrayList* pRetRecipient = null;
+ ClearLastResult();
+ IList* pRetRecipient = null;
+
+ if (type < RECIPIENT_TYPE_TO || type > RECIPIENT_TYPE_BCC)
+ {
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, GetLastResult(), "[E_INVALID_ARG] Invalid RecipientType argument.");
+ return null;
+ }
+
+ pRetRecipient = __pImpl->GetListN(type);
+ SetLastResult(GetLastResult());
+
+ return pRetRecipient;
+}
+} } // Tizen::Messaging
--- /dev/null
+//
+// 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 FMsgSmsManager.cpp
+ * @brief This is the implementation file for the %SmsManager class.
+ *
+ * This file contains the implementation of the %SmsManager class.
+ */
+
+#include <messages.h>
+#include <email.h>
+#include <FMsgSmsManager.h>
+#include <FMsgSmsMessage.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FMsg_SmsManagerImpl.h"
+#include "FMsg_Types.h"
+#include "FMsg_SmsEvent.h"
+#include "FMsg_MsgUtil.h"
+#include "FMsg_RecipientListImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Messaging;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Messaging
+{
+
+SmsManager::SmsManager(void)
+ : __pImpl(null)
+{
+}
+
+SmsManager::~SmsManager(void)
+{
+ if (__pImpl)
+ {
+ delete __pImpl;
+ __pImpl = null;
+ }
+}
+
+result
+SmsManager::Construct(ISmsListener& listener)
+{
+ // method return code
+ result r = E_SUCCESS;
+
+ SysAssertf(__pImpl == null, "The SmsManager instance is already constructed.");
+
+ // create an _SmsManagerImpl instance
+ __pImpl = new (std::nothrow) _SmsManagerImpl();
+ SysTryReturnResult(NID_MSG, __pImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+
+ r = __pImpl->Construct(listener);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to construct an instance.", GetErrorMessage(r));
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+result
+SmsManager::AddSmsEventListener(int port, ISmsEventListener& eventListener)
+{
+ result r = E_SUCCESS;
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_SMSTRIGGER);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagated.");
+
+ // checking conditions
+ SysAssertf(__pImpl != null, "The SmsManager instance is not constructed yet.");
+
+ // checking argument
+ SysTryReturn(NID_MSG, (port >= 1 && port <= 9999), E_INVALID_ARG, r = E_INVALID_ARG,
+ "[E_INVALID_ARG] The port number should range from 1 to 9999 (1 <= port <= 9999).");
+
+ r = __pImpl->AddSmsEventListener(port, eventListener);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to register the event listener with port [%d].", GetErrorMessage(r), port);
+ goto CATCH;
+ }
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+result
+SmsManager::RemoveSmsEventListener(int port, ISmsEventListener& eventListener)
+{
+ result r = E_SUCCESS;
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_SMSTRIGGER);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagating.");
+
+ // checking conditions
+ SysAssertf(__pImpl != null, "The SmsManager instance is not constructed yet.");
+
+ // checking argument
+ SysTryReturn(NID_MSG, (port >= 1 && port <= 9999), E_INVALID_ARG, r = E_INVALID_ARG,
+ "[E_INVALID_ARG] The port number should range from 1 to 9999 (1 <= port <= 9999).");
+
+ r = __pImpl->RemoveSmsEventListener(port, eventListener);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to unregister the event listener.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+result
+SmsManager::AddSmsMessageEventListener(ISmsMessageEventListener& eventListener)
+{
+ result r = E_SUCCESS;
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_MESSAGING_SMS);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagated.");
+
+ // checking conditions
+ SysAssertf(__pImpl != null, "The SmsManager instance is not constructed yet.");
+
+ // add listener
+ r = __pImpl->AddSmsMessageEventListener(eventListener);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to add a listener.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+
+ return E_SUCCESS;
+
+CATCH:
+ return r;
+}
+
+result
+SmsManager::RemoveSmsMessageEventListener(ISmsMessageEventListener& eventListener)
+{
+ result r = E_SUCCESS;
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_MESSAGING_SMS);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagated.");
+
+ // checking conditions
+ SysAssertf(__pImpl != null, "The SmsManager instance is not constructed yet.");
+
+ r = __pImpl->RemoveSmsMessageEventListener(eventListener);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to remove a listener.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+int
+SmsManager::GetTotalMessageCount(SmsMessageBoxType type) const
+{
+ result r = E_SUCCESS;
+ int count = 0;
+ ClearLastResult();
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_MESSAGING_SMS);
+ if (r != E_SUCCESS)
+ {
+ SetLastResult(E_PRIVILEGE_DENIED);
+ SysLogException(NID_MSG, GetLastResult(), "[E_PRIVILEGE_DENIED] Propagated.");
+ return -1;
+ }
+
+ // checking condition
+ SysAssertf(__pImpl != null, "The SmsManager instance is not constructed yet.");
+
+ // checking argument
+ if (type <= SMS_MESSAGE_BOX_TYPE_NONE || type > SMS_MESSAGE_BOX_TYPE_ALL)
+ {
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, GetLastResult(), "[E_INVALID_ARG] Invalid SmsMessageBoxType argument.");
+ return -1;
+ }
+ if (type > SMS_MESSAGE_BOX_TYPE_OUTBOX && type < SMS_MESSAGE_BOX_TYPE_ALL)
+ {
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, GetLastResult(), "[E_INVALID_ARG] Invalid SmsMessageBoxType argument.");
+ return -1;
+ }
+
+ count = __pImpl->GetTotalMessageCount(type);
+ r = GetLastResult();
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] exception occurred. Failed to get SMS total count. type:[%d].", GetErrorMessage(r), (int) type);
+ SetLastResult(r);
+ return -1;
+ }
+
+ return count;
+}
+
+Tizen::Base::Collection::IList*
+SmsManager::SearchInboxN(const Tizen::Base::String* pKeyword, const Tizen::Base::String* pSenderAddress, int startIndex, int count,
+ int& totalResultCount) const
+{
+ IList* pList = null;
+ result r = E_SUCCESS;
+
+ ClearLastResult();
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_MESSAGING_SMS);
+ if (r != E_SUCCESS)
+ {
+ SetLastResult(E_PRIVILEGE_DENIED);
+ SysLogException(NID_MSG, GetLastResult(), "[E_PRIVILEGE_DENIED] Propagated.");
+
+ goto CATCH;
+ }
+
+ // checking condition
+ SysAssertf(__pImpl != null, "The SmsManager instance is not constructed yet.");
+
+ // checking arguments
+ if (pKeyword)
+ {
+ if (pKeyword->GetLength() == MIN_KEYWORD_LENGTH || pKeyword->GetLength() > MAX_KEYWORD_LENGTH)
+ {
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, GetLastResult(), "[E_INVALID_ARG] The specified keyword string length [%d] is smaller than 2 or greater than 30.",
+ pKeyword->GetLength());
+ goto CATCH;
+ }
+ }
+
+ if (pSenderAddress)
+ {
+ if (!pSenderAddress->IsEmpty())
+ {
+ if (pSenderAddress->GetLength() < MIN_LENGTH_PHONE || pSenderAddress->GetLength() > MAX_LENGTH_PHONE)
+ {
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, GetLastResult(),
+ "[E_INVALID_ARG] The length of the given sender address should be greater than 3 and less than 41.");
+ goto CATCH;
+ }
+ else if (_MsgUtil::IsValidPhoneNumber(*pSenderAddress) != true)
+ {
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, GetLastResult(), "[E_INVALID_ARG] The sender address may contain non-digit characters.");
+ goto CATCH;
+ }
+ }
+ }
+
+ if (startIndex < 0)
+ {
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, GetLastResult(), "[E_INVALID_ARG] The start index [%d] should be equal to or greater than 0.", startIndex);
+ goto CATCH;
+ }
+
+ if (count < 0 || count > 20)
+ {
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, GetLastResult(), "[E_INVALID_ARG] The count value [%d] is too small (< 0) or too big (> 20).", count);
+ goto CATCH;
+ }
+
+
+ if (count == 0)
+ {
+ SetLastResult(E_SUCCESS);
+ totalResultCount = 0;
+ return null;
+ }
+
+ // searching...
+ pList = __pImpl->SearchInboxN(pKeyword, pSenderAddress, startIndex, count, totalResultCount);
+ r = GetLastResult();
+ if (IsFailed(r) || !pList)
+ {
+ SetLastResult(r);
+ SysLogException(NID_MSG, r, "[%s] Failed to search.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ return pList;
+
+CATCH:
+ if (pList)
+ {
+ if (pList->GetCount() > 0)
+ {
+ pList->RemoveAll(true);
+ }
+ delete pList;
+ pList = null;
+ }
+ return null;
+}
+
+Tizen::Base::Collection::IList*
+SmsManager::SearchMessageBoxN(SmsMessageBoxType type, const Tizen::Base::String* pKeyword, int startIndex, int count,
+ int& totalResultCount) const
+{
+ IList* pList = null;
+ result r = E_SUCCESS;
+
+ ClearLastResult();
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_MESSAGING_SMS);
+ if (r != E_SUCCESS)
+ {
+ SetLastResult(E_PRIVILEGE_DENIED);
+ SysLogException(NID_MSG, GetLastResult(), "[E_PRIVILEGE_DENIED] Propagated.");
+
+ goto CATCH;
+ }
+
+ // checking condition
+ SysAssertf(__pImpl != null, "The SmsManager instance is not constructed yet.");
+
+ // checking sms message box type argument
+ if (type <= SMS_MESSAGE_BOX_TYPE_NONE || type > SMS_MESSAGE_BOX_TYPE_ALL)
+ {
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, GetLastResult(), "[E_INVALID_ARG] The SmsMessageBoxType value [%d] is invalid.", (int) type);
+ goto CATCH;
+ }
+
+ if (type > SMS_MESSAGE_BOX_TYPE_OUTBOX && type < SMS_MESSAGE_BOX_TYPE_ALL)
+ {
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, GetLastResult(), "[E_INVALID_ARG] The SmsMessageBoxType value [%d] is invalid.", (int) type);
+ goto CATCH;
+ }
+
+ // checking keyword arguments
+ if (pKeyword)
+ {
+ if (pKeyword->GetLength() == MIN_KEYWORD_LENGTH || pKeyword->GetLength() > MAX_KEYWORD_LENGTH)
+ {
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, GetLastResult(), "[E_INVALID_ARG] The specified keyword string length [%d] is smaller than 2 or greater than 30.",
+ pKeyword->GetLength());
+ goto CATCH;
+ }
+ }
+
+ // checking start index argument
+ if (startIndex < 0)
+ {
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, GetLastResult(), "[E_INVALID_ARG] The start index [%d] should be equal to or greater than 0.", startIndex);
+ goto CATCH;
+ }
+
+ // checking count argument
+ if (count < 0 || count > 20)
+ {
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, GetLastResult(), "[E_INVALID_ARG] The count value [%d] is too small (< 0) or too big (> 20).", count);
+ goto CATCH;
+ }
+
+ if (count == 0)
+ {
+ SetLastResult(E_SUCCESS);
+ totalResultCount = 0;
+ return null;
+ }
+
+ // searching...
+ pList = __pImpl->SearchMessageBoxN(type, pKeyword, startIndex, count, totalResultCount);
+ r = GetLastResult();
+ if (IsFailed(r) || !pList)
+ {
+ SetLastResult(r);
+ SysLogException(NID_MSG, r, "[%s] Failed to search.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ return pList;
+
+CATCH:
+ if (pList)
+ {
+ if (pList->GetCount() > 0)
+ {
+ pList->RemoveAll(true);
+ }
+ delete pList;
+ pList = null;
+ }
+ return null;
+}
+
+Tizen::Base::String
+SmsManager::GetFullText(int messageId) const
+{
+ result r = E_SUCCESS;
+ String fullText;
+
+ ClearLastResult();
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_MESSAGING_SMS);
+ if (r != E_SUCCESS)
+ {
+ SetLastResult(E_PRIVILEGE_DENIED);
+ SysLogException(NID_MSG, GetLastResult(), "[E_PRIVILEGE_DENIED] Propagated.");
+ goto CATCH;
+ }
+
+ // checking condition
+ SysAssertf(__pImpl != null, "The SmsManager instance is not constructed yet.");
+
+ // checking argument
+ if (messageId < 0)
+ {
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, GetLastResult(), "[%s] exception occurred. The value [%d] of message ID is invalid.", GetErrorMessage(r), messageId);
+ goto CATCH;
+ }
+
+ fullText = __pImpl->GetFullText(messageId);
+ r = GetLastResult();
+ if (IsFailed(r))
+ {
+ SetLastResult(r);
+ SysLogException(NID_MSG, r, "[%s] exception occurred. Failed to get SMS message using message ID [%d].", GetErrorMessage(
+ r), messageId);
+ goto CATCH;
+ }
+
+ SysLog(NID_MSG, "Returned Full Text : [%ls]", fullText.GetPointer());
+
+ return fullText;
+
+CATCH:
+ return L"";
+}
+
+result
+SmsManager::Send(const SmsMessage& message, const RecipientList& recipientList, bool saveToSentBox)
+{
+ result r = E_SUCCESS;
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_MESSAGING_SMS);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagated.");
+
+ SysAssertf(__pImpl != null, "The SmsManager instance is not constructed yet.");
+ SysTryReturnResult(NID_MSG,
+ MAX_SMS_RECIPIENT_COUNT >= _RecipientListImpl::GetInstance(recipientList)->GetTotalRecipientCount(), E_MAX_EXCEEDED,
+ "[E_MAX_EXCEEDED] The number of recipients exceeds the limit (%d).", MAX_SMS_RECIPIENT_COUNT);
+ SysTryReturnResult(NID_MSG,
+ 0 < _RecipientListImpl::GetInstance(recipientList)->GetTotalRecipientCount(), E_INVALID_ARG, "[E_INVALID_ARG] The number of recipients is 0.");
+
+ // check the validity of the phone number in recipient list
+ r = _MsgUtil::CheckPhoneNumberValidity(_MSG_SMS, recipientList);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] There is an invalid phone number in the recipient list.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ // send an SMS message
+ r = __pImpl->Send(message, recipientList, saveToSentBox);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to send the SMS message.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ return E_SUCCESS;
+
+CATCH:
+ return r;
+}
+
+result
+SmsManager::SetCbsMessageEventListener(ICbsMessageEventListener* pListener)
+{
+ result r = E_SUCCESS;
+
+ ClearLastResult();
+
+ SysAssertf(__pImpl != null, "The SmsManager instance is not constructed yet.");
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_CELLBROADCAST);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagated.");
+
+ // add listener
+ r = __pImpl->SetCbsMessageEventListener(pListener);
+
+ return r;
+}
+
+result
+SmsManager::SetEtwsPrimaryNotificationEventListener(IEtwsPrimaryNotificationEventListener* pListener)
+{
+ result r = E_SUCCESS;
+
+ ClearLastResult();
+
+ SysAssertf(__pImpl != null, "The SmsManager instance is not constructed yet.");
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_CELLBROADCAST);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagated.");
+
+ // add listener
+ r = __pImpl->SetEtwsPrimaryNotificationEventListener(pListener);
+
+ return r;
+}
+
+result
+SmsManager::SetSavingToCbsBoxEnabled(bool enable)
+{
+ result r = E_SUCCESS;
+
+ ClearLastResult();
+
+ SysAssertf(__pImpl != null, "The SmsManager instance is not constructed yet.");
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_CELLBROADCAST);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagated.");
+
+ r = __pImpl->SetSavingToCbsBoxEnabled(enable);
+
+ return r;
+}
+
+bool
+SmsManager::IsCbsEnabled(void) const
+{
+ result r = E_SUCCESS;
+ bool isCbsEnabled = false;
+
+ ClearLastResult();
+
+ // checking conditions
+ SysAssertf(__pImpl != null, "The SmsManager instance is not constructed yet.");
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_CELLBROADCAST);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagated.");
+
+ isCbsEnabled = __pImpl->IsCbsEnabled();
+
+ r = GetLastResult();
+ SetLastResult(r);
+
+ return isCbsEnabled;
+
+CATCH:
+ SetLastResult(r);
+ return isCbsEnabled;
+}
+
+result
+SmsManager::SetCbsEnabled(bool enable)
+{
+ result r = E_SUCCESS;
+
+ ClearLastResult();
+
+ SysAssertf(__pImpl != null, "The SmsManager instance is not constructed yet.");
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_CELLBROADCAST);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagated.");
+
+ r = __pImpl->SetCbsEnabled(enable);
+
+ return r;
+}
+
+result
+SmsManager::AddCbsChannel(int from, int to, Tizen::Base::String& name, bool activate)
+{
+ result r = E_SUCCESS;
+
+ ClearLastResult();
+
+ SysAssertf(__pImpl != null, "The SmsManager instance is not constructed yet.");
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_CELLBROADCAST);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagated.");
+
+ // argument check
+ SysTryReturn(NID_MSG,
+ name.GetLength() <= MAX_CBS_CHANNEL_NAME_LENGTH, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] invalid channel name.");
+ SysTryReturn(NID_MSG,
+ ((to >= 0) && (from >= 0) && (to >= from) && (to <= MAX_CBS_CHANNEL_LIMIT) && ((to - from) <= MAX_CBS_CHANNEL_RANGE)),
+ E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] Failed to add construct channel, invalid arguments.");
+
+ r = __pImpl->AddCbsChannel(from, to, name, activate);
+
+ return r;
+}
+
+result
+SmsManager::RemoveCbsChannel(int from, int to)
+{
+ result r = E_SUCCESS;
+
+ ClearLastResult();
+
+ SysAssertf(__pImpl != null, "The SmsManager instance is not constructed yet.");
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_CELLBROADCAST);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagated.");
+
+ SysTryReturn(NID_MSG,
+ ((to >= 0) && (from >= 0) && (to >= from) && (to <= MAX_CBS_CHANNEL_LIMIT) && ((to - from) <= MAX_CBS_CHANNEL_RANGE)),
+ E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] Failed to add construct channel, invalid arguments.");
+
+ r = __pImpl->RemoveCbsChannel(from, to);
+
+ return r;
+}
+
+CbsChannel*
+SmsManager::GetCbsChannelN(int from, int to) const
+{
+ result r = E_SUCCESS;
+ CbsChannel* pCbsChannel = null;
+
+ ClearLastResult();
+
+ SysAssertf(__pImpl != null, "The SmsManager instance is not constructed yet.");
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_CELLBROADCAST);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_PRIVILEGE_DENIED, r, "[E_PRIVILEGE_DENIED] Propagated.");
+
+ SysTryCatch(NID_MSG,
+ ((to >= 0) && (from >= 0) && (to >= from) && (to <= MAX_CBS_CHANNEL_LIMIT) && ((to - from) <= MAX_CBS_CHANNEL_RANGE)),
+ r = E_INVALID_ARG, r, "[E_INVALID_ARG] Failed to add construct channel, invalid arguments.");
+
+ pCbsChannel = __pImpl->GetCbsChannelN(from, to);
+
+ r = GetLastResult();
+ SetLastResult(r);
+
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to get Cbs channel", GetErrorMessage(r));
+
+ return pCbsChannel;
+
+CATCH:
+ SetLastResult(r);
+
+ if (pCbsChannel)
+ {
+ delete pCbsChannel;
+ pCbsChannel = null;
+ }
+ return null;
+}
+
+Tizen::Base::Collection::IList*
+SmsManager::GetCbsChannelListN(void)
+{
+ result r = E_SUCCESS;
+ IList* pList = null;
+
+ ClearLastResult();
+
+ SysAssertf(__pImpl != null, "The SmsManager instance is not constructed yet.");
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_CELLBROADCAST);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_PRIVILEGE_DENIED, r, "[E_PRIVILEGE_DENIED] Propagated.");
+
+ pList = __pImpl->GetCbsChannelListN();
+
+ r = GetLastResult();
+ SetLastResult(r);
+
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to get Cbs channel list", GetErrorMessage(r));
+
+ return pList;
+
+CATCH:
+ SetLastResult(r);
+ if (pList)
+ {
+ if (pList->GetCount() > 0)
+ {
+ pList->RemoveAll(true);
+ }
+ delete pList;
+ pList = null;
+ }
+ return null;
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// 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 FMsgSmsMessage.cpp
+ * @brief This is the implementation file for the %SmsMessage class.
+ *
+ * This file contains the implementation of the %SmsMessage class.
+ */
+
+#include <FMsgSmsMessage.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FMsg_Types.h"
+#include "FMsg_SmsMessageImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Messaging;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Messaging
+{
+
+SmsMessage::SmsMessage(void)
+{
+ __pImpl = new (std::nothrow) _SmsMessageImpl();
+ SysTryReturnVoidResult(NID_MSG, __pImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+}
+
+SmsMessage::SmsMessage(const SmsMessage& value)
+{
+ __pImpl = new (std::nothrow) _SmsMessageImpl(*(value.__pImpl));
+ SysTryReturnVoidResult(NID_MSG, __pImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+}
+
+SmsMessage::~SmsMessage(void)
+{
+ if (__pImpl)
+ {
+ delete __pImpl;
+ }
+ __pImpl = null;
+}
+
+SmsMessage&
+SmsMessage::operator =(const SmsMessage& rhs)
+{
+ if (this != &rhs)
+ {
+ *__pImpl = *(rhs.__pImpl);
+ }
+
+ return (*this);
+}
+
+bool
+SmsMessage::Equals(const Tizen::Base::Object& obj) const
+{
+ const SmsMessage* pSmsMessage = dynamic_cast<const SmsMessage*>(&obj);
+ if (!pSmsMessage)
+ {
+ SysLog(NID_MSG, "dynamic_cast is failed");
+ return false;
+ }
+
+ return __pImpl->Equals(*(pSmsMessage->__pImpl));
+}
+
+int
+SmsMessage::GetHashCode(void) const
+{
+ return __pImpl->GetHashCode();
+}
+
+result
+SmsMessage::SetText(const Tizen::Base::String& text)
+{
+ result r = E_SUCCESS;
+
+ if (text.GetLength() > MAX_SMS_BODY_TEXT_LENGTH)
+ {
+ r = E_MAX_EXCEEDED;
+ SysLogException(NID_MSG, r, "The length of body text exceeds the limit.");
+ goto CATCH;
+ }
+
+ r = __pImpl->SetText(text);
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+String
+SmsMessage::GetText(void) const
+{
+ return __pImpl->GetText();
+}
+
+String
+SmsMessage::GetSenderAddress(void) const
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_MESSAGING_SMS);
+ if (r != E_SUCCESS)
+ {
+ SetLastResult(E_PRIVILEGE_DENIED);
+ SysLogException(NID_MSG, GetLastResult(), "[E_PRIVILEGE_DENIED] Propagating.");
+ return L"";
+ }
+
+ if (__pImpl->__messageBoxType == SMS_MESSAGE_BOX_TYPE_SENTBOX || __pImpl->__messageBoxType == SMS_MESSAGE_BOX_TYPE_OUTBOX ||
+ __pImpl->__messageBoxType == SMS_MESSAGE_BOX_TYPE_ALL)
+ {
+ SetLastResult(E_INVALID_OPERATION);
+ SysLogException(NID_MSG, GetLastResult(),
+ "[%s] exception occurred. The sender address can is valid when the message is incoming message or is from the Inbox. Not valid to the message from Sentbox or Outbox. [%d]",
+ GetErrorMessage(r), (int) __pImpl->__messageBoxType);
+
+ return L"";
+ }
+
+ return __pImpl->GetSenderAddress();
+}
+
+DateTime
+SmsMessage::GetReceivedTime(void) const
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+ DateTime dt;
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_MESSAGING_SMS);
+ if (r != E_SUCCESS)
+ {
+ SetLastResult(E_PRIVILEGE_DENIED);
+ SysLogException(NID_MSG, GetLastResult(), "[E_PRIVILEGE_DENIED] Propagating.");
+
+ dt.SetValue(1, 1, 1, 0, 0, 0);
+ return dt;
+ }
+
+ // argument check
+ if (__pImpl->__messageBoxType == SMS_MESSAGE_BOX_TYPE_SENTBOX || __pImpl->__messageBoxType == SMS_MESSAGE_BOX_TYPE_OUTBOX ||
+ __pImpl->__messageBoxType == SMS_MESSAGE_BOX_TYPE_ALL)
+ {
+ SetLastResult(E_INVALID_OPERATION);
+ SysLogException(NID_MSG, GetLastResult(),
+ "[%s] exception occurred. The received time is valid when the message is incoming message or is from the Inbox. Not valid to the message from Sentbox or Outbox. [%d]",
+ GetErrorMessage(r), __pImpl->__messageBoxType);
+
+ dt.SetValue(1, 1, 1, 0, 0, 0);
+
+ return dt;
+ }
+
+ return __pImpl->GetReceivedTime();
+}
+
+Tizen::Base::DateTime
+SmsMessage::GetSentTime(void) const
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+ DateTime dt;
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_MESSAGING_SMS);
+ if (r != E_SUCCESS)
+ {
+ SetLastResult(E_PRIVILEGE_DENIED);
+ SysLogException(NID_MSG, GetLastResult(), "[E_PRIVILEGE_DENIED] Propagating.");
+
+ dt.SetValue(1, 1, 1, 0, 0, 0);
+ return dt;
+ }
+
+ // argument check
+ if (__pImpl->__messageBoxType == SMS_MESSAGE_BOX_TYPE_INBOX || __pImpl->__messageBoxType == SMS_MESSAGE_BOX_TYPE_NONE ||
+ __pImpl->__messageBoxType == SMS_MESSAGE_BOX_TYPE_ALL)
+ {
+ SetLastResult(E_INVALID_OPERATION);
+ SysLogException(NID_MSG, GetLastResult(),
+ "[%s] exception occurred. The sent time is valid when the message is from the Sentbox or Outbox. Not valid to the message from Inbox or an incoming message. [%d]",
+ GetErrorMessage(r), __pImpl->__messageBoxType);
+
+ dt.SetValue(1, 1, 1, 0, 0, 0);
+
+ return dt;
+ }
+
+ return __pImpl->GetSentTime();
+}
+
+int
+SmsMessage::GetId(void) const
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_MESSAGING_SMS);
+ if (r != E_SUCCESS)
+ {
+ SetLastResult(E_PRIVILEGE_DENIED);
+ SysLogException(NID_MSG, GetLastResult(), "[E_PRIVILEGE_DENIED] Propagating.");
+ return -1;
+ }
+
+ // argument check
+ if (__pImpl->__messageBoxType == SMS_MESSAGE_BOX_TYPE_NONE || __pImpl->__messageBoxType == SMS_MESSAGE_BOX_TYPE_ALL)
+ {
+ SetLastResult(E_INVALID_OPERATION);
+ SysLogException(NID_MSG, GetLastResult(),
+ "[%s] exception occurred. The incoming message does not have message ID. Or the value of MessageBoxType is invalid. [%d]",
+ GetErrorMessage(r), __pImpl->__messageBoxType);
+
+ return -1;
+ }
+
+ return __pImpl->GetId();
+}
+
+SmsMessageBoxType
+SmsMessage::GetMessageBoxType(void) const
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+ DateTime dt;
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_MESSAGING_SMS);
+ if (r != E_SUCCESS)
+ {
+ SetLastResult(E_PRIVILEGE_DENIED);
+ SysLogException(NID_MSG, GetLastResult(), "[E_PRIVILEGE_DENIED] Propagating.");
+ return SMS_MESSAGE_BOX_TYPE_NONE;
+ }
+
+ // argument check
+ if (__pImpl->__messageBoxType == SMS_MESSAGE_BOX_TYPE_ALL)
+ {
+ SetLastResult(E_INVALID_OPERATION);
+ SysLogException(NID_MSG, GetLastResult(), "[%s] exception occurred. Internal error!! The SmsMessageBoxType value is invalid. [%d]",
+ GetErrorMessage(r), __pImpl->__messageBoxType);
+
+ return SMS_MESSAGE_BOX_TYPE_NONE;
+ }
+
+ return __pImpl->GetMessageBoxType();
+}
+
+RecipientList
+SmsMessage::GetRecipientList(void) const
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+ RecipientList recipients;
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_MESSAGING_SMS);
+ if (r != E_SUCCESS)
+ {
+ SetLastResult(E_PRIVILEGE_DENIED);
+ SysLogException(NID_MSG, GetLastResult(), "[E_PRIVILEGE_DENIED] Propagating.");
+ return recipients;
+ }
+
+ // argument check
+ if (__pImpl->__messageBoxType == SMS_MESSAGE_BOX_TYPE_INBOX || __pImpl->__messageBoxType == SMS_MESSAGE_BOX_TYPE_NONE ||
+ __pImpl->__messageBoxType == SMS_MESSAGE_BOX_TYPE_ALL)
+ {
+ SetLastResult(E_INVALID_OPERATION);
+ SysLogException(NID_MSG, GetLastResult(),
+ "[%s] exception occurred. The incoming message or the message in the inbox does not have recipient list. Or the value of SmsMessageBoxType is invalid. [%d]",
+ GetErrorMessage(r), __pImpl->__messageBoxType);
+
+ return recipients;
+ }
+
+ return __pImpl->GetRecipientList();
+}
+
+bool
+SmsMessage::HasMoreText(void) const
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_MESSAGING_SMS);
+ if (r != E_SUCCESS)
+ {
+ SetLastResult(E_PRIVILEGE_DENIED);
+ SysLogException(NID_MSG, GetLastResult(), "[E_PRIVILEGE_DENIED] Propagating.");
+ return false;
+ }
+
+ // argument check
+ if (__pImpl->__messageBoxType == SMS_MESSAGE_BOX_TYPE_NONE || __pImpl->__messageBoxType == SMS_MESSAGE_BOX_TYPE_ALL)
+ {
+ SetLastResult(E_INVALID_OPERATION);
+ SysLogException(NID_MSG, GetLastResult(), "[%s] exception occurred. The value of SmsMessageBoxType is invalid. [%d]", GetErrorMessage(r),
+ __pImpl->__messageBoxType);
+
+ return false;
+ }
+
+ return __pImpl->HasMoreText();
+}
+} } // Tizen::Messaging
--- /dev/null
+//
+// 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 FMsgWapPushManger.cpp
+ * @brief This is the implementation file for the %WapPushManger class.
+ *
+ * This file contains the implementation of the %WapPushManger class.
+ */
+
+#include <messages.h>
+#include <FMsgWapPushManager.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FMsg_Types.h"
+#include "FMsg_WapPushManagerImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Messaging;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Messaging
+{
+
+WapPushManager::WapPushManager(void)
+{
+ __pWapPushManagerImpl = new (std::nothrow) _WapPushManagerImpl();
+ SysTryReturnVoidResult(NID_MSG, __pWapPushManagerImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+}
+
+WapPushManager::WapPushManager(const WapPushManager& value)
+{
+ __pWapPushManagerImpl = new (std::nothrow) _WapPushManagerImpl(*(value.__pWapPushManagerImpl));
+ SysTryReturnVoidResult(NID_MSG, __pWapPushManagerImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+}
+
+WapPushManager::~WapPushManager(void)
+{
+ if (__pWapPushManagerImpl)
+ {
+ delete __pWapPushManagerImpl;
+ }
+ __pWapPushManagerImpl = null;
+}
+
+WapPushManager&
+WapPushManager::operator =(const WapPushManager& rhs)
+{
+ if (this != &rhs)
+ {
+ *__pWapPushManagerImpl = *(rhs.__pWapPushManagerImpl);
+ }
+
+ return (*this);
+}
+
+result
+WapPushManager::AddWapPushEventListener(const Tizen::Base::String& wapApplicationId, IWapPushEventListener& listener)
+{
+ result r = E_SUCCESS;
+
+ ClearLastResult();
+
+ SysAssertf(__pWapPushManagerImpl != null, "The WapPushManager instance is not constructed yet.");
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_WAPPUSH);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagating.");
+
+ // argument check
+ SysTryReturn(NID_MSG,
+ wapApplicationId.GetLength() != 0, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] The length of wapApplicationId is 0.");
+
+ r = __pWapPushManagerImpl->AddWapPushEventListener(wapApplicationId, listener);
+
+ return r;
+}
+
+result
+WapPushManager::RemoveWapPushEventListener(const Tizen::Base::String& wapApplicationId, IWapPushEventListener& listener)
+{
+ result r = E_SUCCESS;
+
+ ClearLastResult();
+
+ SysAssertf(__pWapPushManagerImpl != null, "The WapPushManager instance is not constructed yet.");
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_WAPPUSH);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagating.");
+
+ // argument check
+ SysTryReturn(NID_MSG,
+ wapApplicationId.GetLength() != 0, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] The length of wapApplicationId is 0.");
+
+ r = __pWapPushManagerImpl->RemoveWapPushEventListener(wapApplicationId, listener);
+ return r;
+}
+
+result
+WapPushManager::RegisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType)
+{
+ result r = E_SUCCESS;
+
+ ClearLastResult();
+
+ SysAssertf(__pWapPushManagerImpl != null, "The WapPushManager instance is not constructed yet.");
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_WAPPUSH);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagating.");
+
+ // argument check
+ SysTryReturn(NID_MSG,
+ wapApplicationId.GetLength() != 0, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] The length of wapApplicationId is 0.");
+ SysTryReturn(NID_MSG,
+ contentType.GetLength() != 0, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] The length of contentType is 0.");
+
+ r = __pWapPushManagerImpl->RegisterCondition(wapApplicationId, contentType);
+ return r;
+}
+
+result
+WapPushManager::UnregisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType)
+{
+ result r = E_SUCCESS;
+
+ ClearLastResult();
+
+ SysAssertf(__pWapPushManagerImpl != null, "The WapPushManager instance is not constructed yet.");
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_WAPPUSH);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagating.");
+
+ // argument check
+ SysTryReturn(NID_MSG,
+ wapApplicationId.GetLength() != 0, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] The length of wapApplicationId is 0.");
+ SysTryReturn(NID_MSG,
+ contentType.GetLength() != 0, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] The length of contentType is 0.");
+
+ r = __pWapPushManagerImpl->UnregisterCondition(wapApplicationId, contentType);
+ return r;
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// 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 FMsgWapPushMessage.cpp
+ * @brief This is the implementation file for the %WapPushMessage class.
+ *
+ * This file contains the implementation of the %WapPushMessage class.
+ */
+
+#include <messages.h>
+#include <FMsgWapPushMessage.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FMsg_Types.h"
+#include "FMsg_WapPushMessageImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Messaging;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Messaging
+{
+
+WapPushMessage::WapPushMessage(void)
+{
+ __pWapPushMessageImpl = new (std::nothrow) _WapPushMessageImpl();
+ SysTryReturnVoidResult(NID_MSG, __pWapPushMessageImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+}
+
+WapPushMessage::WapPushMessage(const WapPushMessage& value)
+{
+ __pWapPushMessageImpl = new (std::nothrow) _WapPushMessageImpl(*(value.__pWapPushMessageImpl));
+ SysTryReturnVoidResult(NID_MSG, __pWapPushMessageImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+}
+
+WapPushMessage::~WapPushMessage(void)
+{
+ if (__pWapPushMessageImpl)
+ {
+ delete __pWapPushMessageImpl;
+ }
+ __pWapPushMessageImpl = null;
+}
+
+WapPushMessage&
+WapPushMessage::operator =(const WapPushMessage& rhs)
+{
+ if (this != &rhs)
+ {
+ *__pWapPushMessageImpl = *(rhs.__pWapPushMessageImpl);
+ }
+
+ return (*this);
+}
+
+WapPushMessage::WapPushMessage(const Tizen::Base::String& header, const Tizen::Base::ByteBuffer& body)
+{
+ __pWapPushMessageImpl = new (std::nothrow) _WapPushMessageImpl(header, body);
+}
+
+bool
+WapPushMessage::Equals(const Tizen::Base::Object& obj) const
+{
+ const WapPushMessage* pWapPushMessage = dynamic_cast<const WapPushMessage*>(&obj);
+ if (!pWapPushMessage)
+ {
+ SysLog(NID_MSG, "dynamic_cast is failed");
+ return false;
+ }
+
+ return __pWapPushMessageImpl->Equals(*(pWapPushMessage->__pWapPushMessageImpl));
+}
+
+WapPushMessage*
+WapPushMessage::CloneN() const
+{
+ return __pWapPushMessageImpl->CloneN();
+}
+
+int
+WapPushMessage::GetHashCode(void) const
+{
+ return __pWapPushMessageImpl->GetHashCode();
+}
+
+Tizen::Base::ByteBuffer*
+WapPushMessage::GetBodyN(void) const
+{
+ result r = E_SUCCESS;
+ Tizen::Base::ByteBuffer* pMsgBody = null;
+
+ ClearLastResult();
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_WAPPUSH);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagating.");
+
+ pMsgBody = __pWapPushMessageImpl->GetBodyN();
+ SysTryCatch(NID_MSG, pMsgBody != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "memory allocation failed.");
+
+
+ SetLastResult(GetLastResult());
+ return pMsgBody;
+
+CATCH:
+ SetLastResult(GetLastResult());
+ return pMsgBody;
+}
+
+Tizen::Base::String
+WapPushMessage::GetHeader(void) const
+{
+ result r = E_SUCCESS;
+ Tizen::Base::String msgHeader;
+
+ ClearLastResult();
+
+ // checking privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_WAPPUSH);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagating.");
+
+ msgHeader = __pWapPushMessageImpl->GetHeader();
+
+ SetLastResult(GetLastResult());
+ return msgHeader;
+
+CATCH:
+ SetLastResult(GetLastResult());
+ return msgHeader;
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+/**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * @file FMsg_CbsChannelImpl.cpp\r
+ * @brief This is the implementation file for the %_CbsChannelImpl class.\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * This file contains the implementation of the %_CbsChannelImpl class.\r
+ *\r
+ * @endif\r
+ */\r
+\r
+#include <messages.h>\r
+#include <FMsgCbsChannel.h>\r
+#include <FBaseSysLog.h>\r
+#include <FBaseUtilStringUtil.h>\r
+#include <FBase_StringConverter.h>\r
+#include <FSec_AccessController.h>\r
+#include "FMsg_Types.h"\r
+#include "FMsg_CbsChannelImpl.h"\r
+\r
+using namespace Tizen::Base;\r
+using namespace Tizen::Messaging;\r
+using namespace Tizen::Security;\r
+\r
+namespace Tizen { namespace Messaging\r
+{\r
+\r
+_CbsChannelImpl::_CbsChannelImpl(void)\r
+ : __fromId(-1)\r
+ , __toId(-1)\r
+ , __channelName(L"")\r
+ , __isChannelEnable(false)\r
+ , __cbsChannelHandle(0)\r
+{\r
+}\r
+\r
+_CbsChannelImpl::_CbsChannelImpl(const _CbsChannelImpl& value)\r
+{\r
+ __fromId = value.__fromId;\r
+ __toId = value.__toId;\r
+ __channelName = value.__channelName;\r
+ __isChannelEnable = value.__isChannelEnable;\r
+ __cbsChannelHandle = value.__cbsChannelHandle;\r
+}\r
+\r
+_CbsChannelImpl::~_CbsChannelImpl(void)\r
+{\r
+}\r
+\r
+_CbsChannelImpl&\r
+_CbsChannelImpl::operator =(const _CbsChannelImpl& rhs)\r
+{\r
+ if (this != &rhs)\r
+ {\r
+ __fromId = rhs.__fromId;\r
+ __toId = rhs.__toId;\r
+ __channelName = rhs.__channelName;\r
+ __isChannelEnable = rhs.__isChannelEnable;\r
+ __cbsChannelHandle = rhs.__cbsChannelHandle;\r
+ }\r
+\r
+ return (*this);\r
+}\r
+\r
+result\r
+_CbsChannelImpl::Construct(int from, int to, const Tizen::Base::String& name)\r
+{\r
+ __fromId = from;\r
+ __toId = to;\r
+ __channelName = name;\r
+ __isChannelEnable = false;\r
+ __cbsChannelHandle = 0;\r
+\r
+ return E_SUCCESS;\r
+}\r
+\r
+CbsChannel*\r
+_CbsChannelImpl::GetCbsChannelN(int from, int to, const Tizen::Base::String& name)\r
+{\r
+ result r = E_SUCCESS;\r
+ CbsChannel* pCbsChannel = null;\r
+\r
+ pCbsChannel = new (std::nothrow) CbsChannel();\r
+ SysTryCatch(NID_MSG, pCbsChannel != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");\r
+\r
+ r = pCbsChannel->Construct(from, to, name);\r
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "failed to construct channel.");\r
+\r
+ SetLastResult(GetLastResult());\r
+ return pCbsChannel;\r
+\r
+CATCH:\r
+ SetLastResult(GetLastResult());\r
+\r
+ if(pCbsChannel)\r
+ {\r
+ delete pCbsChannel;\r
+ pCbsChannel = null;\r
+ }\r
+\r
+ return null;\r
+}\r
+\r
+_CbsChannelImpl*\r
+_CbsChannelImpl::GetInstance(CbsChannel& cbsChannel)\r
+{\r
+ return cbsChannel.__pCbsChannelImpl;\r
+}\r
+\r
+void\r
+_CbsChannelImpl::SetCbsChannelHandle(messages_cb_channel_h cbsChannelHandle)\r
+{\r
+ __cbsChannelHandle = cbsChannelHandle;\r
+}\r
+\r
+result\r
+_CbsChannelImpl::UpdateName(const Tizen::Base::String& name)\r
+{\r
+ result r = E_SUCCESS;\r
+ int err = MESSAGES_ERROR_NONE;\r
+ char* pChannelName = null;\r
+ __channelName = name;\r
+\r
+ ClearLastResult();\r
+\r
+ pChannelName = _StringConverter::CopyToCharArrayN(name);\r
+ SysTryReturn(NID_MSG, pChannelName != null, E_OUT_OF_MEMORY, r = E_OUT_OF_MEMORY, "memory allocation failed");\r
+\r
+ err = messages_cb_channel_set_name(__cbsChannelHandle, pChannelName);\r
+ r = ConvertException(err);\r
+\r
+ if (pChannelName)\r
+ {\r
+ delete[] pChannelName;\r
+ pChannelName =null;\r
+ }\r
+\r
+ return r;\r
+}\r
+\r
+result\r
+_CbsChannelImpl::Deactivate(void)\r
+{\r
+ result r = E_SUCCESS;\r
+ ClearLastResult();\r
+ int err = MESSAGES_ERROR_NONE;\r
+\r
+ err = messages_cb_channel_set_activated(__cbsChannelHandle, false);\r
+ __isChannelEnable = false;\r
+\r
+ r = ConvertException(err);\r
+\r
+ return r;\r
+}\r
+\r
+result\r
+_CbsChannelImpl::Activate(void)\r
+{\r
+ result r = E_SUCCESS;\r
+ ClearLastResult();\r
+ int err = MESSAGES_ERROR_NONE;\r
+\r
+ err = messages_cb_channel_set_activated(__cbsChannelHandle, true);\r
+ __isChannelEnable = true;\r
+\r
+ r = ConvertException(err);\r
+\r
+ return r;\r
+}\r
+\r
+bool\r
+_CbsChannelImpl::IsActivated(void) const\r
+{\r
+ result r = E_SUCCESS;\r
+ ClearLastResult();\r
+ int err = MESSAGES_ERROR_NONE;\r
+ bool isActivated = false;\r
+\r
+ err = messages_cb_channel_is_activated(__cbsChannelHandle, &isActivated);\r
+\r
+ r = ConvertException(err);\r
+ SetLastResult(r);\r
+\r
+ if (isActivated)\r
+ {\r
+ return isActivated;\r
+ }\r
+ else\r
+ {\r
+ return false;\r
+ }\r
+}\r
+\r
+Tizen::Base::String\r
+_CbsChannelImpl::GetName(void) const\r
+{\r
+ return __channelName;\r
+}\r
+\r
+result\r
+_CbsChannelImpl::GetRange(int& from, int& to) const\r
+{\r
+ result r = E_SUCCESS;\r
+\r
+ from = __fromId;\r
+ to = __toId;\r
+\r
+ return r;\r
+}\r
+\r
+result\r
+_CbsChannelImpl::ConvertException(int err) const\r
+{\r
+ result r = E_SUCCESS;\r
+\r
+ switch (err)\r
+ {\r
+ case MESSAGES_ERROR_NONE:\r
+ r = E_SUCCESS;\r
+ break;\r
+\r
+ case MESSAGES_ERROR_INVALID_PARAMETER:\r
+ r = E_INVALID_ARG;\r
+ break;\r
+\r
+ case MESSAGES_ERROR_OUT_OF_MEMORY:\r
+ r = E_OUT_OF_MEMORY;\r
+ break;\r
+\r
+ case MESSAGES_ERROR_SERVER_NOT_READY: // Communication error between client and server\r
+ case MESSAGES_ERROR_COMMUNICATION_WITH_SERVER_FAILED:\r
+ r = E_NETWORK_UNAVAILABLE;\r
+ break;\r
+\r
+ case MESSAGES_ERROR_NO_SIM_CARD:\r
+ r = E_DEVICE_UNAVAILABLE;\r
+ break;\r
+\r
+ case MESSAGES_ERROR_OUT_OF_RANGE:\r
+ r = E_ALREADY_SET;\r
+ break;\r
+\r
+ case MESSAGES_ERROR_SENDING_FAILED:\r
+ case MESSAGES_ERROR_OPERATION_FAILED:\r
+ r = E_FAILURE;\r
+ break;\r
+\r
+ default:\r
+ r = E_SYSTEM;\r
+ break;\r
+ }\r
+\r
+ return r;\r
+}\r
+\r
+} } // Tizen::Messaging\r
--- /dev/null
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+/**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * @file FMsg_CbsChannelImpl.h\r
+ * @brief This is the header file for the _CbsChannelImpl class.\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * This header file contains the declarations of the _CbsChannelImpl class.\r
+ *\r
+ * @endif\r
+ */\r
+\r
+#ifndef _FMSG_INTERNAL_CBS_CHANNEL_IMPL_H_\r
+#define _FMSG_INTERNAL_CBS_CHANNEL_IMPL_H_\r
+\r
+namespace Tizen { namespace Messaging\r
+{\r
+\r
+/**\r
+* @if VISPARTNER-OPERATOR\r
+*\r
+* @class _CbsChannelImpl\r
+* @brief This class provides methods for handling a Cell Broadcast Service (CBS) channel.\r
+*\r
+* @since 2.1\r
+*\r
+* @final This class is not intended for extension.\r
+*\r
+* @visibility partner-operator\r
+*\r
+* The %_CbsChannelImpl class provides methods for handling a CBS channel. @n\r
+* It allows you to get and set the CBS channel information.\r
+*\r
+* @endif\r
+*/\r
+\r
+class _CbsChannelImpl\r
+ : public Tizen::Base::Object\r
+{\r
+public:\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * This destructor overrides Tizen::Base::Object::~Object().\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @endif\r
+ */\r
+ virtual ~_CbsChannelImpl(void);\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the range of the channel\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @privlevel user\r
+ * @privilege http://tizen.org/privilege/cellbroadcast\r
+ *\r
+ *\r
+ * @return An error code\r
+ * @param[out] from The starting index of the message ID of the channel.\r
+ * @param[out] to The last index of the message ID of the channel.\r
+ * @exception E_SUCCESS The method is successful.\r
+ * @exception E_INVALID_STATE The range has not been set as yet.\r
+ * @exception E_SYSTEM A system error has occurred.\r
+ * @remarks In case of an error, this method sets the negative values for @c from and @c to. For example, @c -1.\r
+ *\r
+ * @endif\r
+ */\r
+ result GetRange(int& from, int& to) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the name of the channel.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @privlevel user\r
+ * @privilege http://tizen.org/privilege/cellbroadcast\r
+ *\r
+ * @return The name of the channel\r
+ *\r
+ * @remark The name can be an empty string.\r
+ *\r
+ * @endif\r
+ */\r
+ Tizen::Base::String GetName(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the activation status of the channel.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @privlevel user\r
+ * @privilege http://tizen.org/privilege/cellbroadcast\r
+ *\r
+ * @return @c true if the channel is activated,\r
+ * else @c false\r
+ *\r
+ * @endif\r
+ */\r
+ bool IsActivated(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Activates the channel status .\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @privlevel user\r
+ * @privilege http://tizen.org/privilege/cellbroadcast\r
+ *\r
+ * @return An error code\r
+ * @exception E_SUCCESS The method is successful.\r
+ * @exception E_ILLEGAL_ACCESS The application does not have the permission to activate the CBS channel status.\r
+ * @exception E_SYSTEM A system error has occurred.\r
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.\r
+ *\r
+ * @endif\r
+ */\r
+ result Activate(void);\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Deactivates the channel status\r
+ *\r
+ * @privlevel user\r
+ * @privilege http://tizen.org/privilege/cellbroadcast\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return An error code\r
+ * @exception E_SUCCESS The method is successful.\r
+ * @exception E_ILLEGAL_ACCESS The application does not have the permission to activate the CBS channel status.\r
+ * @exception E_SYSTEM A system error has occurred.\r
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.\r
+ *\r
+ * @endif\r
+ */\r
+ result Deactivate(void);\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Updates the name of the channel.\r
+ *\r
+ * @privlevel user\r
+ * @privilege http://tizen.org/privilege/cellbroadcast\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return An error code\r
+ * @param[in] name The name of the CBS channel to update\r
+ * @exception E_SUCCESS The method is successful.\r
+ * @exception E_ILLEGAL_ACCESS The application does not have the permission to update the CBS channel name.\r
+ * @exception E_SYSTEM A system error has occurred.\r
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.\r
+ *\r
+ * @endif\r
+ */\r
+ result UpdateName(const Tizen::Base::String& name);\r
+\r
+public:\r
+ /**\r
+ * Gets the instance of CbsChannel\r
+ *\r
+ * @since 2.1\r
+ */\r
+ static CbsChannel* GetCbsChannelN(int from, int to, const Tizen::Base::String& name);\r
+\r
+ /**\r
+ * Gets the Impl instance.\r
+ *\r
+ * @since 2.1\r
+ * @return The pointer to _CbsChannelImpl\r
+ * @param[in] CbsChannel An instance of CbsChannel\r
+ */\r
+ static _CbsChannelImpl* GetInstance(CbsChannel& cbsChannel);\r
+\r
+ /**\r
+ * Sets the cbs handle to CbsChannelImpl object.\r
+ *\r
+ * @since 2.1\r
+ * @param[in] cbsChannelHandle An Cbs Channel Handle\r
+ */\r
+ void SetCbsChannelHandle(messages_cb_channel_h cbsChannelHandle);\r
+\r
+ result ConvertException(int err) const;\r
+\r
+public:\r
+ /**\r
+ * This default constructor is intentionally declared as private so that only the platform can create an instance.\r
+ *\r
+ * @since 2.1\r
+ */\r
+ _CbsChannelImpl(void);\r
+\r
+ /**\r
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.\r
+ *\r
+ * @param[in] rhs An instance of _CbsChannelImpl\r
+ */\r
+ _CbsChannelImpl(const _CbsChannelImpl& rhs);\r
+\r
+ /**\r
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.\r
+ *\r
+ * @param[in] rhs An instance of _CbsChannelImpl\r
+ */\r
+ _CbsChannelImpl& operator =(const _CbsChannelImpl& rhs);\r
+\r
+ /**\r
+ * Initializes this instance of %_CbsChannelImpl with the specified parameter.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @return An error code\r
+ * @param[in] from The starting index of the message ID of the channel.\r
+ * @param[in] to The last index of the message ID of the channel.\r
+ * @param[in] name The name of the channel. (can be an empty string)\r
+ * @exception E_SUCCESS The method is successful.\r
+ * @exception E_INVALID_ARG The specified @c to parameter is smaller than @c from. @n\r
+ * The specified @c to or @c from parameter is a negative value. @n\r
+ * The specified @c to parameter exceeds the limit (0xFFFF). @n\r
+ * The range (@c to - @c from) exceeds the limit (900).\r
+ * The specified @c name string length is greater than @c 32. @n\r
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.\r
+ * @exception E_SYSTEM A system error has occurred.\r
+ */\r
+ result Construct(int from, int to, const Tizen::Base::String& name);\r
+\r
+private:\r
+ int __fromId;\r
+ int __toId;\r
+ Tizen::Base::String __channelName;\r
+ bool __isChannelEnable;\r
+ messages_cb_channel_h __cbsChannelHandle;\r
+}; // _CbsChannelImpl\r
+\r
+} } // Tizen::Messaging\r
+#endif // _FMSG_INTERNAL_CBS_CHANNEL_IMPL_H_\r
--- /dev/null
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+/**\r
+ * @file FMsg_CbsMessageImpl.cpp\r
+ * @brief This is the implementation file for the %_CbsMessageImpl class.\r
+ *\r
+ * This file contains the implementation of the %_CbsMessageImpl class.\r
+ */\r
+\r
+#include <messages.h>\r
+#include <FMsgCbsMessage.h>\r
+#include <FBaseSysLog.h>\r
+#include <FSec_AccessController.h>\r
+#include "FMsg_Types.h"\r
+#include "FMsg_CbsMessageImpl.h"\r
+\r
+using namespace Tizen::Base;\r
+using namespace Tizen::Messaging;\r
+using namespace Tizen::Security;\r
+\r
+namespace Tizen { namespace Messaging\r
+{\r
+\r
+_CbsMessageImpl::_CbsMessageImpl(void)\r
+ : __cbsMsgTime()\r
+ , __pCbsSerialNumber(null)\r
+ , __cbsSenderMsg(L"")\r
+ , __cbsMessageId(0)\r
+ , __isEtwsNotification(false)\r
+ , __dataCodingScheme()\r
+{\r
+ __pCbsSerialNumber = new (std::nothrow) ByteBuffer();\r
+ SysTryReturnVoidResult(NID_MSG, __pCbsSerialNumber != null, E_OUT_OF_MEMORY, "memory allocation failed");\r
+ __pCbsSerialNumber->Construct(0);\r
+ __pCbsSerialNumber->SetPosition(0);\r
+}\r
+\r
+_CbsMessageImpl::_CbsMessageImpl(const _CbsMessageImpl& value)\r
+{\r
+ __cbsMsgTime = value.__cbsMsgTime;\r
+ __cbsMessageId = value.__cbsMessageId;\r
+ __cbsSenderMsg = value.__cbsSenderMsg;\r
+ __isEtwsNotification = value.__isEtwsNotification;\r
+ __dataCodingScheme = value.__dataCodingScheme;\r
+\r
+ __pCbsSerialNumber->SetArray(value.__pCbsSerialNumber->GetPointer(), 0, value.__pCbsSerialNumber->GetLimit());\r
+ __pCbsSerialNumber->SetPosition(0);\r
+}\r
+\r
+result\r
+_CbsMessageImpl::SetCbsMessageImpl(const Tizen::Base::DateTime& dateTime, const Tizen::Base::ByteBuffer& cbsSerialNumber, const Tizen::Base::String& text, int cbsMessageId, bool isEtwsNotification, byte dataCodingScheme)\r
+{\r
+ result r = E_SUCCESS;\r
+\r
+ __cbsMsgTime = dateTime;\r
+ __cbsMessageId = cbsMessageId;\r
+ __cbsSenderMsg = text;\r
+ __isEtwsNotification = isEtwsNotification;\r
+ __dataCodingScheme = dataCodingScheme;\r
+\r
+ __pCbsSerialNumber = new (std::nothrow) ByteBuffer();\r
+ SysTryReturn(NID_MSG, __pCbsSerialNumber != null, E_OUT_OF_MEMORY, r = E_OUT_OF_MEMORY, "memory allocation failed");\r
+\r
+ r = __pCbsSerialNumber->Construct(cbsSerialNumber);\r
+ r = __pCbsSerialNumber->SetPosition(0);\r
+\r
+ return r;\r
+}\r
+\r
+_CbsMessageImpl::~_CbsMessageImpl(void)\r
+{\r
+ if (__pCbsSerialNumber)\r
+ {\r
+ delete __pCbsSerialNumber;\r
+ __pCbsSerialNumber = null;\r
+ }\r
+}\r
+\r
+_CbsMessageImpl&\r
+_CbsMessageImpl::operator =(const _CbsMessageImpl& rhs)\r
+{\r
+ if (this != &rhs)\r
+ {\r
+ __cbsMsgTime = rhs.__cbsMsgTime;\r
+ __cbsMessageId = rhs.__cbsMessageId;\r
+ __cbsSenderMsg = rhs.__cbsSenderMsg;\r
+ __isEtwsNotification = rhs.__isEtwsNotification;\r
+ __dataCodingScheme = rhs.__dataCodingScheme;\r
+\r
+ __pCbsSerialNumber->SetArray(rhs.__pCbsSerialNumber->GetPointer(), 0, rhs.__pCbsSerialNumber->GetLimit());\r
+ __pCbsSerialNumber->SetPosition(0);\r
+ }\r
+\r
+ return (*this);\r
+}\r
+\r
+CbsMessage*\r
+_CbsMessageImpl::CloneN() const\r
+{\r
+ CbsMessage* pCbsMsg = null;\r
+ result r = E_SUCCESS;\r
+\r
+ pCbsMsg = _CbsMessageImpl::GetCbsMessageN();\r
+ SysTryCatch(NID_MSG, pCbsMsg != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");\r
+\r
+ r = _CbsMessageImpl::GetInstance(*pCbsMsg)->SetCbsMessageImpl(__cbsMsgTime, *(__pCbsSerialNumber), __cbsSenderMsg, __cbsMessageId, __isEtwsNotification, __dataCodingScheme);\r
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "cbsimpl message construct failed");\r
+\r
+ SetLastResult(GetLastResult());\r
+ return pCbsMsg;\r
+\r
+CATCH:\r
+ SetLastResult(GetLastResult());\r
+ if (pCbsMsg)\r
+ {\r
+ delete pCbsMsg;\r
+ pCbsMsg = null;\r
+ }\r
+ return null;\r
+}\r
+\r
+bool\r
+_CbsMessageImpl::Equals(const Tizen::Base::Object& obj) const\r
+{\r
+ const _CbsMessageImpl* pCbsMessageImpl = dynamic_cast<const _CbsMessageImpl*>(&obj);\r
+\r
+ if (!pCbsMessageImpl)\r
+ {\r
+ SysLog(NID_MSG, "dynamic_cast is failed");\r
+ return false;\r
+ }\r
+\r
+ // sender time\r
+ if (__cbsMsgTime != pCbsMessageImpl->__cbsMsgTime)\r
+ {\r
+ return false;\r
+ }\r
+\r
+ // sender address\r
+ if (__pCbsSerialNumber != pCbsMessageImpl->__pCbsSerialNumber)\r
+ {\r
+ return false;\r
+ }\r
+\r
+ // sender msg\r
+ if (__cbsSenderMsg != pCbsMessageImpl->__cbsSenderMsg)\r
+ {\r
+ return false;\r
+ }\r
+\r
+ // cbs message id\r
+ if (__cbsMessageId != pCbsMessageImpl->__cbsMessageId)\r
+ {\r
+ return false;\r
+ }\r
+\r
+ // Etws Notification\r
+ if (__isEtwsNotification != pCbsMessageImpl->__isEtwsNotification)\r
+ {\r
+ return false;\r
+ }\r
+\r
+ // Etws Notification\r
+ if (__dataCodingScheme != pCbsMessageImpl->__dataCodingScheme)\r
+ {\r
+ return false;\r
+ }\r
+\r
+ return true;\r
+}\r
+\r
+int\r
+_CbsMessageImpl::GetHashCode(void) const\r
+{\r
+ int hash = 0;\r
+\r
+ hash = __cbsSenderMsg.GetHashCode() + __pCbsSerialNumber->GetHashCode() + __cbsMsgTime.GetHashCode() + __cbsMessageId + (__isEtwsNotification ? 1 : 0);\r
+\r
+ return hash;\r
+}\r
+\r
+CbsMessage*\r
+_CbsMessageImpl::GetCbsMessageN()\r
+{\r
+ result r = E_SUCCESS;\r
+ CbsMessage* pCbsMsg = null;\r
+\r
+ pCbsMsg = new (std::nothrow) CbsMessage();\r
+ SysTryCatch(NID_MSG, pCbsMsg != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");\r
+\r
+ return pCbsMsg;\r
+\r
+CATCH:\r
+ return null;\r
+}\r
+\r
+_CbsMessageImpl*\r
+_CbsMessageImpl::GetInstance(CbsMessage& cbsMessage)\r
+{\r
+ return cbsMessage.__pCbsMessageImpl;\r
+}\r
+\r
+\r
+Tizen::Base::ByteBuffer*\r
+_CbsMessageImpl::GetSerialNumberN(void) const\r
+{\r
+ result r = E_SUCCESS;\r
+ Tizen::Base::ByteBuffer* pCbsSerialNumber = null;\r
+\r
+ ClearLastResult();\r
+\r
+ pCbsSerialNumber = new (std::nothrow) ByteBuffer();\r
+ SysTryCatch(NID_MSG, pCbsSerialNumber != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");\r
+\r
+ r = pCbsSerialNumber->Construct(*__pCbsSerialNumber);\r
+ r = pCbsSerialNumber->SetPosition(0);\r
+\r
+ SetLastResult(r);\r
+\r
+ return pCbsSerialNumber;\r
+\r
+CATCH:\r
+ SetLastResult(r);\r
+\r
+ return null;\r
+}\r
+\r
+Tizen::Base::DateTime\r
+_CbsMessageImpl::GetReceivedTime(void) const\r
+{\r
+ return __cbsMsgTime;\r
+}\r
+\r
+Tizen::Base::String\r
+_CbsMessageImpl::GetText(void) const\r
+{\r
+ return __cbsSenderMsg;\r
+}\r
+\r
+int\r
+_CbsMessageImpl::GetMessageId(void) const\r
+{\r
+ return __cbsMessageId;\r
+}\r
+\r
+bool\r
+_CbsMessageImpl::IsEtwsNotification(void) const\r
+{\r
+ return __isEtwsNotification;\r
+}\r
+\r
+byte \r
+_CbsMessageImpl::GetDataCodingScheme(void) const\r
+{\r
+ return __dataCodingScheme;\r
+}\r
+\r
+} } // Tizen::Messaging\r
--- /dev/null
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+/**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * @file FMsg_CbsMessageImpl.h\r
+ * @brief This is the header file for the _CbsMessageImpl class.\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * This header file contains the declarations of the _CbsMessageImpl class.\r
+ *\r
+ * @endif\r
+ */\r
+\r
+#ifndef _FMSG_INTERNAL_CBS_MESSAGE_IMPL_H_\r
+#define _FMSG_INTERNAL_CBS_MESSAGE_IMPL_H_\r
+\r
+namespace Tizen { namespace Messaging\r
+{\r
+\r
+class CbsMessage;\r
+\r
+/**\r
+* @if VISPARTNER-OPERATOR\r
+*\r
+* @class _CbsMessageImpl\r
+*\r
+* @brief This class provides methods for handling a CBS message.\r
+*\r
+* @since 2.1\r
+*\r
+* @final This class is not intended for extension.\r
+*\r
+* @visibility partner-operator\r
+*\r
+* The %_CbsMessageImpl class provides methods for handling a CBS message. It allows you to get the body text,\r
+* received time, and sender address of a CBS message.\r
+*\r
+* @endif\r
+*/\r
+\r
+class _CbsMessageImpl\r
+ : public Tizen::Base::Object\r
+{\r
+public:\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * This destructor overrides Tizen::Base::Object::~Object().\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @endif\r
+ */\r
+ virtual ~_CbsMessageImpl(void);\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Compares the specified instance of %_CbsMessageImpl with the calling instance.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return @c true, if the values match @n\r
+ * @c false, otherwise\r
+ * @param[in] obj The other Object to be compared\r
+ * @see Object::Equals()\r
+ *\r
+ * @endif\r
+ */\r
+ virtual bool Equals(const Tizen::Base::Object& obj) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the copied instance of the class.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return An instance of %_CbsMessageImpl\r
+ * @exception E_SUCCESS The method is successful.\r
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.\r
+ *\r
+ * @remarks In case of error, this method returns @c null. @n\r
+ * The specific error code can be accessed using the GetLastResult() method.\r
+ *\r
+ * @endif\r
+ */\r
+ CbsMessage* CloneN(void) const;\r
+\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the hash value of the current instance.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return The current instance's hash value\r
+ *\r
+ * @endif\r
+ */\r
+ virtual int GetHashCode(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Checks whether this message is an ETWS notification.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return @c true if this message is an ETWS notification, @n\r
+ * else @c false\r
+ * @remarks If the return value is @c true, the message is ETWS secondary notification.\r
+ *\r
+ * @endif\r
+ */\r
+ bool IsEtwsNotification(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the serial number of the CBS message.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return The serial number of the CBS message\r
+ * @exception E_SUCCESS The method is successful.\r
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.\r
+ * @remarks The specific error code can be accessed using the GetLastResult() method. @n\r
+ * In case of an error, this method returns null.\r
+ *\r
+ * @endif\r
+ */\r
+ Tizen::Base::ByteBuffer* GetSerialNumberN(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the message ID of the CBS message.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return The the message ID of the CBS message\r
+ *\r
+ * @endif\r
+ */\r
+ int GetMessageId(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the body of the message.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return The body of the message\r
+ *\r
+ * @endif\r
+ */\r
+ Tizen::Base::String GetText(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the date and time (UTC time) of the message when it is received.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return The date and time (UTC time) when the message is received\r
+ *\r
+ * @endif\r
+ */\r
+ Tizen::Base::DateTime GetReceivedTime(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the Data Coding Scheme of the CBS message.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return The Data Coding Scheme of the CBS message\r
+ * @exception E_SUCCESS The method is successful.\r
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.\r
+ * @remarks The specific error code can be accessed using the GetLastResult() method. @n\r
+ * In case of an error, this method returns null. @n\r
+ * The alphabet/coding and the language applied to CBS messages are defined in 3GPP TS 23.038\r
+ *\r
+ * @endif\r
+ */\r
+ byte GetDataCodingScheme(void) const;\r
+\r
+public:\r
+ /**\r
+ * Gets the instance of CbsChannel\r
+ *\r
+ * @since 2.1\r
+ */\r
+ static CbsMessage* GetCbsMessageN();\r
+\r
+ /**\r
+ * Gets the Impl instance.\r
+ *\r
+ * @since 2.1\r
+ * @return The pointer to _CbsMessageImpl\r
+ * @param[in] CbsMessage An instance of CbsMessage\r
+ */\r
+ static _CbsMessageImpl* GetInstance(CbsMessage& cbsMessage);\r
+\r
+public:\r
+ /**\r
+ * This default constructor is intentionally declared as private so that only the platform can create an instance.\r
+ *\r
+ * @since 2.1\r
+ */\r
+ _CbsMessageImpl(void);\r
+\r
+ /**\r
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @param[in] rhs An instance of _CbsMessageImpl\r
+ */\r
+ _CbsMessageImpl(const _CbsMessageImpl& rhs);\r
+\r
+ /**\r
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. @n\r
+ * - Use CloneN() to get an exact copy of the instance.\r
+ * - Use Equals() to compare the contents of one instance with the other.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @return A reference to this instance\r
+ * @param[in] rhs An instance of _CbsMessageImpl\r
+ */\r
+ _CbsMessageImpl& operator =(const _CbsMessageImpl& rhs);\r
+\r
+ /**\r
+ * Initializes this instance of %_CbsChannelImpl with the specified parameter.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @param[in] dateTime The date and time (UTC time) when the message is received\r
+ * @param[in] cbsSerialNumber The cbsSerialNumber of the CBS message\r
+ * @param[in] text The cbs message body text\r
+ * @param[in] cbsMessageId The cbsMessageId of the CBS message\r
+ * @param[in] isEtwsnotification The Etws notification of the CBS message\r
+ * @exception E_SUCCESS The method is successful.\r
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.\r
+ * @exception E_SYSTEM A system error has occurred.\r
+ */\r
+ result SetCbsMessageImpl(const Tizen::Base::DateTime& dateTime, const Tizen::Base::ByteBuffer& cbsSerialNumber, const Tizen::Base::String& text, int cbsMessageId, bool isEtwsNotification, byte dataCodingScheme);\r
+\r
+private:\r
+ Tizen::Base::DateTime __cbsMsgTime;\r
+ Tizen::Base::ByteBuffer* __pCbsSerialNumber;\r
+ Tizen::Base::String __cbsSenderMsg;\r
+ int __cbsMessageId;\r
+ bool __isEtwsNotification;\r
+ byte __dataCodingScheme;\r
+}; // _CbsMessageImpl\r
+\r
+} } // Tizen::Messaging\r
+\r
+#endif // _FMSG_INTERNAL_CBS_MESSAGE_IMPL_H_\r
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_ComposerEvent.cpp
+ * @brief This is the implementation file for the %_ComposerEvent class.
+ *
+ * This file contains the implementation of the %_ComposerEvent class.
+ */
+
+#include <FBaseSysLog.h>
+#include "FMsg_IComposerListener.h"
+#include "FMsg_ComposerEvent.h"
+#include "FMsg_ComposerEventArg.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Messaging
+{
+
+_ComposerEvent::_ComposerEvent(void)
+{
+}
+
+result
+_ComposerEvent::Construct(void)
+{
+ return _Event::Initialize();
+}
+
+void
+_ComposerEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+ result r = E_SUCCESS;
+
+ _IComposerListener* pComposerListener = dynamic_cast <_IComposerListener*>(&listener);
+ SysTryReturnVoidResult(NID_MSG, pComposerListener != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system.");
+
+ IEventArg* pEventArg = const_cast <IEventArg*>(&arg);
+ _ComposerEventArg* pComposerEventArg = dynamic_cast <_ComposerEventArg*>(pEventArg);
+ SysTryReturnVoidResult(NID_MSG, pComposerEventArg != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system.");
+
+ // get error result
+ pComposerEventArg->GetErrorResult(r);
+
+ if (pComposerEventArg->IsTerminateEvent() == false)
+ {
+ // Fire
+ pComposerListener->OnComposerInitialized(r);
+ }
+ else
+ {
+ // Fire
+ pComposerListener->OnComposerTerminated(r);
+ }
+}
+
+} }
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_ComposerEvent.h
+ * @brief This is the header file for _ComposerEvent class.
+ *
+ * This header file contains the declarations of _ComposerEvent class.
+ */
+
+#ifndef _FMSG_INTERNAL_COMPOSER_EVENT_H_
+#define _FMSG_INTERNAL_COMPOSER_EVENT_H_
+
+// Includes
+#include <FBaseRt_Event.h>
+
+namespace Tizen { namespace Messaging
+{
+
+//
+// @class _ComposerEvent
+// @brief This class provides the event for message composer
+// @since 1.0
+//
+// @see _IComposerEventListener, ComposerEventArg
+//
+
+class _ComposerEvent
+ : public Tizen::Base::Runtime::_Event
+{
+// Life cycle
+public:
+ /**
+ * This is the constructor.
+ *
+ */
+ _ComposerEvent(void);
+
+ /**
+ * This is the class destructor.
+ *
+ */
+ virtual ~_ComposerEvent(void) {};
+
+ /**
+ * Initializes a new instance of the class
+ *
+ */
+ result Construct(void);
+
+
+//Operations
+protected:
+ void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+ _ComposerEvent(const _ComposerEvent& _ComposerEvent);
+ _ComposerEvent& operator =(const _ComposerEvent& value);
+}; // _ComposerEvent
+} }
+
+#endif // _FMSG_INTERNAL_COMPOSER_EVENT_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_ComposerEventArg.cpp
+ * @brief This is the implementation file for the %_ComposerEventArg class.
+ *
+ * This file contains the implementation of the %_ComposerEventArg class.
+ */
+
+#include "FMsg_ComposerEventArg.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Messaging
+{
+
+_ComposerEventArg::_ComposerEventArg(void) : __result(E_SUCCESS), __isTerminateEvent(false)
+{
+}
+
+_ComposerEventArg::_ComposerEventArg(result r, bool isTerminateEvent) : __result(r), __isTerminateEvent(isTerminateEvent)
+{
+}
+
+void
+_ComposerEventArg::GetErrorResult(result& r) const
+{
+ r = __result;
+}
+
+bool
+_ComposerEventArg::IsTerminateEvent(void)
+{
+ return __isTerminateEvent;
+}
+
+} }
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_ComposerEventArg.h
+ * @brief This is the header file for _ComposerEventArg class.
+ *
+ * This header file contains the declarations of _ComposerEventArg class.
+ */
+
+#ifndef _FMSG_INTERNAL_COMPOSER_EVENT_ARG_H_
+#define _FMSG_INTERNAL_COMPOSER_EVENT_ARG_H_
+
+// Includes
+#include <FBaseObject.h>
+#include <FBaseDataType.h>
+#include <FBaseRt_Event.h>
+
+namespace Tizen { namespace Messaging
+{
+
+//
+// @class _ComposerEventArg
+// @brief This class provides methods for getting data from message composer event
+// @since 1.0
+//
+
+class _ComposerEventArg
+ : public Tizen::Base::Object
+ , public Tizen::Base::Runtime::IEventArg
+{
+ // Life cycle
+public:
+ /**
+ * This is the constructor.
+ *
+ */
+ _ComposerEventArg(void);
+
+ /**
+ * This is the constructor.
+ *
+ * @param[in] r - the message composer result
+ * @param[in] isTerminateEvent - @c true on terminate event @n
+ * @c false, otherwise
+ */
+ _ComposerEventArg(const result r, bool isTerminateEvent = false);
+
+ /**
+ * This is class destructor.
+ *
+ */
+ virtual ~_ComposerEventArg(void) {};
+
+ // Access
+public:
+ /**
+ * Gets the error result of composer event
+ * This synchronous method retrieves information about the message composer
+ *
+ * @param[out] r - the message composer result
+ * @exception E_SUCCESS - operation is successful
+ * @exception E_OUT_OF_MEMORY - failed to allocate required/requested memory
+ * @exception E_SYSTEM - the system has an error.
+ */
+ void GetErrorResult(result& r) const;
+
+ /**
+ * Check the event is terminating-event or not
+ */
+ bool IsTerminateEvent(void);
+
+private:
+ _ComposerEventArg(const _ComposerEventArg& eventArg);
+ _ComposerEventArg& operator =(const _ComposerEventArg& value);
+
+private:
+ result __result;
+ bool __isTerminateEvent;
+}; // _ComposerEventArg
+
+} }
+
+#endif // _FMSG_INTERNAL_COMPOSER_EVENT_ARG_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_DetailedEmailMessageImpl.cpp
+ * @brief This is the implementation file for the %_DetailedEmailMessageImpl class.
+ *
+ * This file contains the implementation of the %_DetailedEmailMessageImpl class.
+ */
+
+#include <email-api.h>
+#include <FBaseSysLog.h>
+#include <FMsgEmailAttachment.h>
+#include <FIoFile.h>
+#include <FMsgDetailedEmailMessage.h>
+#include <FBase_StringConverter.h>
+#include "FMsg_DetailedEmailMessageImpl.h"
+#include "FMsg_EmailAttachmentImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Messaging;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Messaging
+{
+
+_DetailedEmailMessageImpl::_DetailedEmailMessageImpl(void)
+ : __messageId(L"")
+ , __subject(L"")
+ , __dateTime()
+ , __toAddress(L"")
+ , __ccAddress(L"")
+ , __bccAddress(L"")
+ , __fromAddress(L"")
+ , __replyToAddress(L"")
+ , __returnPath(L"")
+ , __filePathBody(L"")
+ , __filePathHtmlBody(L"")
+ , __filePathMimeEntity(L"")
+ , __mailSize(0)
+ , __priority((EmailMessagePriority) -1)
+ , __returnReceiptType((EmailReturnReceiptType) -1)
+ , __attachmentCount(0)
+ , __inlineContentCount(0)
+ , __messageClass((EmailMessageClass) -1)
+ , __digestType((EmailDigestType) -1)
+ , __smimeType((EmailSmimeType) -1)
+ , __pAttachmentList(null)
+{
+}
+
+_DetailedEmailMessageImpl::_DetailedEmailMessageImpl(const _DetailedEmailMessageImpl& value)
+{
+ int count = 0;
+ ArrayList* pList = null;
+
+ __messageId = value.__messageId;
+ __subject = value.__subject;
+ __dateTime = value.__dateTime;
+ __toAddress = value.__toAddress;
+ __ccAddress = value.__ccAddress;
+ __bccAddress = value.__bccAddress;
+ __fromAddress = value.__fromAddress;
+ __replyToAddress = value.__replyToAddress;
+ __returnPath = value.__returnPath;
+ __filePathBody = value.__filePathBody;
+ __filePathHtmlBody = value.__filePathHtmlBody;
+ __filePathMimeEntity = value.__filePathMimeEntity;
+ __mailSize = value.__mailSize;
+ __priority = value.__priority;
+ __returnReceiptType = value.__returnReceiptType;
+ __attachmentCount = value.__attachmentCount;
+ __inlineContentCount = value.__inlineContentCount;
+ __messageClass = value.__messageClass;
+ __digestType = value.__digestType;
+ __smimeType = value.__smimeType;
+
+ if (value.__pAttachmentList)
+ {
+ pList = new (std::nothrow) ArrayList();
+ SysTryReturnVoidResult(NID_MSG, pList != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+
+ pList->Construct();
+ __pAttachmentList = pList;
+
+ count = value.__pAttachmentList->GetCount();
+
+ for (int index = 0; index < count; index++)
+ {
+ EmailAttachment* pEmailAttachmentItem = dynamic_cast <EmailAttachment*>(value.__pAttachmentList->GetAt(index));
+ SysTryReturnVoidResult(NID_MSG, pEmailAttachmentItem != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+
+ EmailAttachment* pEmailAttachment = null;
+
+ pEmailAttachment = new (std::nothrow) EmailAttachment();
+ if (!pEmailAttachment)
+ {
+ SysLogException(NID_MSG, E_OUT_OF_MEMORY, "memory allocation failed.");
+ __pAttachmentList->RemoveAll(true);
+ delete __pAttachmentList;
+ __pAttachmentList = null;
+ SetLastResult(E_OUT_OF_MEMORY);
+ return;
+ }
+
+ pEmailAttachment->SetName(pEmailAttachmentItem->GetName());
+ pEmailAttachment->SetFilePath(pEmailAttachmentItem->GetFilePath());
+ pEmailAttachment->SetInlineContentStatus(pEmailAttachmentItem->GetInlineContentStatus());
+ pEmailAttachment->SetDrmStatus(pEmailAttachmentItem->GetDrmStatus());
+ pEmailAttachment->SetMimeType(pEmailAttachmentItem->GetMimeType());
+
+ pList->Add(*pEmailAttachment);
+ }
+ }
+}
+
+_DetailedEmailMessageImpl::~_DetailedEmailMessageImpl(void)
+{
+ if (__pAttachmentList)
+ {
+ if (__pAttachmentList->GetCount() > 0)
+ {
+ __pAttachmentList->RemoveAll(true);
+ }
+ delete __pAttachmentList;
+ __pAttachmentList = null;
+ }
+}
+
+_DetailedEmailMessageImpl&
+_DetailedEmailMessageImpl::operator =(const _DetailedEmailMessageImpl& rhs)
+{
+ if (this != &rhs)
+ {
+ int count = 0;
+ ArrayList* pList = null;
+
+ __messageId = rhs.__messageId;
+ __subject = rhs.__subject;
+ __dateTime = rhs.__dateTime;
+ __toAddress = rhs.__toAddress;
+ __ccAddress = rhs.__ccAddress;
+ __bccAddress = rhs.__bccAddress;
+ __fromAddress = rhs.__fromAddress;
+ __replyToAddress = rhs.__replyToAddress;
+ __returnPath = rhs.__returnPath;
+ __filePathBody = rhs.__filePathBody;
+ __filePathHtmlBody = rhs.__filePathHtmlBody;
+ __filePathMimeEntity = rhs.__filePathMimeEntity;
+ __mailSize = rhs.__mailSize;
+ __priority = rhs.__priority;
+ __returnReceiptType = rhs.__returnReceiptType;
+ __attachmentCount = rhs.__attachmentCount;
+ __inlineContentCount = rhs.__inlineContentCount;
+ __messageClass = rhs.__messageClass;
+ __digestType = rhs.__digestType;
+ __smimeType = rhs.__smimeType;
+
+ if (__pAttachmentList)
+ {
+ if (__pAttachmentList->GetCount() > 0)
+ {
+ __pAttachmentList->RemoveAll(true);
+ }
+ delete __pAttachmentList;
+ __pAttachmentList = null;
+ }
+
+
+ if (rhs.__pAttachmentList)
+ {
+ pList = new (std::nothrow) ArrayList();
+ if (!pList)
+ {
+ SysLogException(NID_MSG, E_OUT_OF_MEMORY, "memory allocation failed.");
+ SetLastResult(E_OUT_OF_MEMORY);
+ return (*this);
+ }
+
+ pList->Construct();
+ __pAttachmentList = pList;
+
+ count = rhs.__pAttachmentList->GetCount();
+ for (int index = 0; index < count; index++)
+ {
+ EmailAttachment* pEmailAttachmentItem = dynamic_cast <EmailAttachment*>(rhs.__pAttachmentList->GetAt(index));
+ if (!pEmailAttachmentItem)
+ {
+ SysLogException(NID_MSG, E_OUT_OF_MEMORY, "memory allocation failed.");
+ __pAttachmentList->RemoveAll(true);
+ delete __pAttachmentList;
+ __pAttachmentList = null;
+ SetLastResult(E_OUT_OF_MEMORY);
+ return (*this);
+ }
+
+ EmailAttachment* pEmailAttachment = null;
+ pEmailAttachment = new (std::nothrow) EmailAttachment();
+ if (!pEmailAttachment)
+ {
+ SysLogException(NID_MSG, E_OUT_OF_MEMORY, "memory allocation failed.");
+ __pAttachmentList->RemoveAll(true);
+ delete __pAttachmentList;
+ __pAttachmentList = null;
+ SetLastResult(E_OUT_OF_MEMORY);
+ return (*this);
+ }
+
+ pEmailAttachment->SetName(pEmailAttachmentItem->GetName());
+ pEmailAttachment->SetFilePath(pEmailAttachmentItem->GetFilePath());
+ pEmailAttachment->SetInlineContentStatus(pEmailAttachmentItem->GetInlineContentStatus());
+ pEmailAttachment->SetDrmStatus(pEmailAttachmentItem->GetDrmStatus());
+ pEmailAttachment->SetMimeType(pEmailAttachmentItem->GetMimeType());
+
+ pList->Add(*pEmailAttachment);
+ }
+ }
+ }
+
+ return (*this);
+}
+
+bool
+_DetailedEmailMessageImpl::Equals(const Tizen::Base::Object& value) const
+{
+ const _DetailedEmailMessageImpl* pDetailedEmailMessageImpl = dynamic_cast<const _DetailedEmailMessageImpl*>(&value);
+ if (!pDetailedEmailMessageImpl)
+ {
+ SysLog(NID_MSG, "dynamic_cast is failed");
+ return false;
+ }
+
+ // attach id
+ if (__messageId != pDetailedEmailMessageImpl->__messageId)
+ {
+ return false;
+ }
+
+ // msg subject
+ if (__subject != pDetailedEmailMessageImpl->__subject)
+ {
+ return false;
+ }
+
+ // msg sent/recevie time
+ if (__dateTime != pDetailedEmailMessageImpl->__dateTime)
+ {
+ return false;
+ }
+
+ // msg to address
+ if (__toAddress != pDetailedEmailMessageImpl->__toAddress)
+ {
+ return false;
+ }
+
+ // msg cc address
+ if (__ccAddress != pDetailedEmailMessageImpl->__ccAddress)
+ {
+ return false;
+ }
+
+ // msg bcc address
+ if (__bccAddress != pDetailedEmailMessageImpl->__bccAddress)
+ {
+ return false;
+ }
+ // msg from address
+ if (__fromAddress != pDetailedEmailMessageImpl->__fromAddress)
+ {
+ return false;
+ }
+
+ // msg replay address
+ if (__replyToAddress != pDetailedEmailMessageImpl->__replyToAddress)
+ {
+ return false;
+ }
+
+ // msg return path
+ if (__returnPath != pDetailedEmailMessageImpl->__returnPath)
+ {
+ return false;
+ }
+ // body file path
+ if (__filePathBody != pDetailedEmailMessageImpl->__filePathBody)
+ {
+ return false;
+ }
+
+ // html body file path
+ if (__filePathHtmlBody != pDetailedEmailMessageImpl->__filePathHtmlBody)
+ {
+ return false;
+ }
+
+ // msg mime entity
+ if (__filePathMimeEntity != pDetailedEmailMessageImpl->__filePathMimeEntity)
+ {
+ return false;
+ }
+
+ // msg size
+ if (__mailSize != pDetailedEmailMessageImpl->__mailSize)
+ {
+ return false;
+ }
+
+ // msg priority
+ if (__priority != pDetailedEmailMessageImpl->__priority)
+ {
+ return false;
+ }
+ // msg recepient type
+ if (__returnReceiptType != pDetailedEmailMessageImpl->__returnReceiptType)
+ {
+ return false;
+ }
+
+ // msg attachment count
+ if (__attachmentCount != pDetailedEmailMessageImpl->__attachmentCount)
+ {
+ return false;
+ }
+
+ // msg inline content count
+ if (__inlineContentCount != pDetailedEmailMessageImpl->__inlineContentCount)
+ {
+ return false;
+ }
+ // msg class
+ if (__messageClass != pDetailedEmailMessageImpl->__messageClass)
+ {
+ return false;
+ }
+
+ // msg digest type
+ if (__digestType != pDetailedEmailMessageImpl->__digestType)
+ {
+ return false;
+ }
+
+ // msg mime type
+ if (__smimeType != pDetailedEmailMessageImpl->__smimeType)
+ {
+ return false;
+ }
+
+ // attachment list
+ if (__pAttachmentList)
+ {
+ if (!__pAttachmentList->Equals(*(pDetailedEmailMessageImpl->__pAttachmentList)))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (pDetailedEmailMessageImpl->__pAttachmentList)
+ {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+int
+_DetailedEmailMessageImpl::GetHashCode(void) const
+{
+ int hash = 0;
+
+ hash = __messageId.GetHashCode() + __subject.GetHashCode() + __dateTime.GetHashCode() + __toAddress.GetHashCode() +
+ __ccAddress.GetHashCode() + __bccAddress.GetHashCode() + __fromAddress.GetHashCode() + __replyToAddress.GetHashCode() +
+ __returnPath.GetHashCode() + __filePathBody.GetHashCode() + __filePathHtmlBody.GetHashCode() +
+ __filePathMimeEntity.GetHashCode() + __mailSize + (int)__priority + (int)__returnReceiptType + __attachmentCount +
+ __inlineContentCount + (int)__messageClass + (int)__digestType + (int)__smimeType;
+
+ if (__pAttachmentList)
+ {
+ hash += __pAttachmentList->GetHashCode();
+ }
+
+ return hash;
+}
+
+Tizen::Base::String
+_DetailedEmailMessageImpl::GetMessageId(void) const
+{
+ return __messageId;
+}
+
+Tizen::Base::String
+_DetailedEmailMessageImpl::GetSubject(void) const
+{
+ return __subject;
+}
+
+Tizen::Base::DateTime
+_DetailedEmailMessageImpl::GetCreationTime(void) const
+{
+ return __dateTime;
+}
+
+Tizen::Base::String
+_DetailedEmailMessageImpl::GetAddress(RecipientType type) const
+{
+ if (type == RECIPIENT_TYPE_TO)
+ {
+ return __toAddress;
+ }
+ else if (type == RECIPIENT_TYPE_CC)
+ {
+ return __ccAddress;
+ }
+ else if (type == RECIPIENT_TYPE_BCC)
+ {
+ return __bccAddress;
+ }
+ else
+ {
+ return "";
+ }
+}
+
+Tizen::Base::String
+_DetailedEmailMessageImpl::GetFromAddress(void) const
+{
+ return __fromAddress;
+}
+
+Tizen::Base::String
+_DetailedEmailMessageImpl::GetReplyToAddress(void) const
+{
+ return __replyToAddress;
+}
+
+Tizen::Base::String
+_DetailedEmailMessageImpl::GetReturnPath(void) const
+{
+ return __returnPath;
+}
+
+Tizen::Base::String
+_DetailedEmailMessageImpl::GetFilePath(EmailMessageBodyType type) const
+{
+ if (type == EMAIL_MESSAGE_BODY_TYPE_PLAIN_TEXT)
+ {
+ return __filePathBody;
+ }
+ else if (type == EMAIL_MESSAGE_BODY_TYPE_HTML)
+ {
+ return __filePathHtmlBody;
+ }
+ else if (type == EMAIL_MESSAGE_BODY_TYPE_MIME)
+ {
+ return __filePathMimeEntity;
+ }
+ else
+ {
+ return "";
+ }
+}
+
+EmailMessagePriority
+_DetailedEmailMessageImpl::GetPriority(void) const
+{
+ return __priority;
+}
+
+EmailReturnReceiptType
+_DetailedEmailMessageImpl::GetReturnReceiptType(void) const
+{
+ return __returnReceiptType;
+}
+
+int
+_DetailedEmailMessageImpl::GetInlineContentCount(void) const
+{
+ return __inlineContentCount;
+}
+
+EmailMessageClass
+_DetailedEmailMessageImpl::GetClass(void) const
+{
+ return __messageClass;
+}
+
+EmailDigestType
+_DetailedEmailMessageImpl::GetDigestType(void) const
+{
+ return __digestType;
+}
+
+EmailSmimeType
+_DetailedEmailMessageImpl::GetSmimeType(void) const
+{
+ return __smimeType;
+}
+
+Tizen::Base::Collection::IList*
+_DetailedEmailMessageImpl::GetAttachmentListN(void)
+{
+ result r = E_SUCCESS;
+ ArrayList* pAttachmentList = null;
+ int count = 0;
+
+ ClearLastResult();
+
+ // get total count of attached files
+ if (__pAttachmentList)
+ {
+ count = __pAttachmentList->GetCount();
+ }
+
+ pAttachmentList = new (std::nothrow) ArrayList();
+ SysTryCatch(NID_MSG, pAttachmentList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "memory allocation failed.");
+
+ r = pAttachmentList->Construct();
+ SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Failed to construct attachment list.", GetErrorMessage(r));
+
+
+ for (int index = 0; index < count; index++)
+ {
+ EmailAttachment* pEmailAttachmentItem = dynamic_cast <EmailAttachment*>(__pAttachmentList->GetAt(index));
+ SysTryCatch(NID_MSG, pEmailAttachmentItem != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "memory allocation failed.");
+
+ EmailAttachment* pEmailAttachment = null;
+
+ pEmailAttachment = new (std::nothrow) EmailAttachment();
+ SysTryCatch(NID_MSG, pEmailAttachment != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "memory allocation failed.");
+
+ pEmailAttachment->SetName(pEmailAttachmentItem->GetName());
+ pEmailAttachment->SetFilePath(pEmailAttachmentItem->GetFilePath());
+ pEmailAttachment->SetInlineContentStatus(pEmailAttachmentItem->GetInlineContentStatus());
+ pEmailAttachment->SetDrmStatus(pEmailAttachmentItem->GetDrmStatus());
+ pEmailAttachment->SetMimeType(pEmailAttachmentItem->GetMimeType());
+
+ r = pAttachmentList->Add(*pEmailAttachment);
+ }
+
+ SetLastResult(r);
+ return pAttachmentList;
+
+CATCH:
+ SetLastResult(r);
+ if (pAttachmentList)
+ {
+ if (pAttachmentList->GetCount() > 0)
+ {
+ pAttachmentList->RemoveAll(true);
+ }
+ delete pAttachmentList;
+ pAttachmentList = null;
+ }
+
+ return null;
+}
+
+result
+_DetailedEmailMessageImpl::SetMessageId(const Tizen::Base::String& messageId)
+{
+ result r = E_SUCCESS;
+
+ __messageId = messageId;
+
+ return r;
+}
+
+result
+_DetailedEmailMessageImpl::SetSubject(const Tizen::Base::String& subject)
+{
+ result r = E_SUCCESS;
+
+ __subject = subject;
+
+ return r;
+}
+
+result
+_DetailedEmailMessageImpl::SetCreationTime(const Tizen::Base::DateTime& dateTime)
+{
+ result r = E_SUCCESS;
+
+ __dateTime = dateTime;
+
+ return r;
+}
+
+result
+_DetailedEmailMessageImpl::SetAddress(RecipientType type, const Tizen::Base::String& recipients)
+{
+ result r = E_SUCCESS;
+
+ if (type == RECIPIENT_TYPE_TO)
+ {
+ __toAddress = recipients;
+ }
+ else if (type == RECIPIENT_TYPE_CC)
+ {
+ __ccAddress = recipients;
+ }
+ else if (type == RECIPIENT_TYPE_BCC)
+ {
+ __bccAddress = recipients;
+ }
+ else
+ {
+ }
+
+ return r;
+}
+
+result
+_DetailedEmailMessageImpl::SetFromAddress(const Tizen::Base::String& address)
+{
+ result r = E_SUCCESS;
+
+ __fromAddress = address;
+
+ return r;
+}
+
+result
+_DetailedEmailMessageImpl::SetReplyToAddress(const Tizen::Base::String& address)
+{
+ result r = E_SUCCESS;
+
+ __replyToAddress = address;
+
+ return r;
+}
+
+result
+_DetailedEmailMessageImpl::SetReturnPath(const Tizen::Base::String& address)
+{
+ result r = E_SUCCESS;
+
+ __returnPath = address;
+
+ return r;
+}
+
+result
+_DetailedEmailMessageImpl::SetFilePath(EmailMessageBodyType type, const Tizen::Base::String& filePath)
+{
+ result r = E_SUCCESS;
+
+ if (type == EMAIL_MESSAGE_BODY_TYPE_PLAIN_TEXT)
+ {
+ __filePathBody = filePath;
+ }
+ else if (type == EMAIL_MESSAGE_BODY_TYPE_HTML)
+ {
+ __filePathHtmlBody = filePath;
+ }
+ else if (type == EMAIL_MESSAGE_BODY_TYPE_MIME)
+ {
+ __filePathMimeEntity = filePath;
+ }
+ else
+ {
+ }
+
+ return r;
+}
+
+result
+_DetailedEmailMessageImpl::SetPriority(EmailMessagePriority priority)
+{
+ result r = E_SUCCESS;
+
+ __priority = priority;
+
+ return r;
+}
+
+result
+_DetailedEmailMessageImpl::SetReturnReceiptType(EmailReturnReceiptType type)
+{
+ result r = E_SUCCESS;
+
+ __returnReceiptType = type;
+
+ return r;
+}
+
+result
+_DetailedEmailMessageImpl::SetInlineContentCount(int count)
+{
+ result r = E_SUCCESS;
+
+ __inlineContentCount = count;
+
+ return r;
+}
+
+result
+_DetailedEmailMessageImpl::SetClass(EmailMessageClass messageClass)
+{
+ result r = E_SUCCESS;
+
+ __messageClass = messageClass;
+
+ return r;
+}
+
+result
+_DetailedEmailMessageImpl::SetDigestType(EmailDigestType type)
+{
+ result r = E_SUCCESS;
+
+ __digestType = type;
+
+ return r;
+}
+
+result
+_DetailedEmailMessageImpl::SetSmimeType(EmailSmimeType type)
+{
+ result r = E_SUCCESS;
+
+ __smimeType = type;
+
+ return r;
+}
+
+result
+_DetailedEmailMessageImpl::SetAttachmentList(const Tizen::Base::Collection::IList* pList)
+{
+ result r = E_SUCCESS;
+ Tizen::Base::Collection::IList* pTempList = null;
+ ClearLastResult();
+
+ pTempList = const_cast <Tizen::Base::Collection::IList *>(pList);
+ SysTryReturn(NID_MSG, pTempList != null, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] Propagating.");
+
+ if (__pAttachmentList)
+ {
+ if (__pAttachmentList->GetCount() > 0)
+ {
+ __pAttachmentList->RemoveAll(true);
+ }
+ delete __pAttachmentList;
+ __pAttachmentList = null;
+ }
+
+ __pAttachmentList = new (std::nothrow) ArrayList();
+ SysTryReturn(NID_MSG, __pAttachmentList != null, E_OUT_OF_MEMORY, r = E_OUT_OF_MEMORY, "memory allocation failed.");
+
+ r = __pAttachmentList->Construct();
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_OUT_OF_MEMORY, r = E_OUT_OF_MEMORY, "memory allocation failed.");
+
+ for (int index = 0; index < pTempList->GetCount(); index++)
+ {
+ EmailAttachment* pEmailAttachmentItem = dynamic_cast <EmailAttachment*>(pTempList->GetAt(index));
+ SysTryReturn(NID_MSG, pEmailAttachmentItem != null, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] Propagating.");
+
+ EmailAttachment* pEmailAttachment = null;
+
+ pEmailAttachment = new (std::nothrow) EmailAttachment();
+ SysTryReturn(NID_MSG, pEmailAttachment != null, E_OUT_OF_MEMORY, r = E_OUT_OF_MEMORY, "memory allocation failed.");
+
+ pEmailAttachment->SetName(pEmailAttachmentItem->GetName());
+ pEmailAttachment->SetFilePath(pEmailAttachmentItem->GetFilePath());
+ pEmailAttachment->SetInlineContentStatus(pEmailAttachmentItem->GetInlineContentStatus());
+ pEmailAttachment->SetDrmStatus(pEmailAttachmentItem->GetDrmStatus());
+ pEmailAttachment->SetMimeType(pEmailAttachmentItem->GetMimeType());
+
+ r = __pAttachmentList->Add(*pEmailAttachment);
+ }
+
+ return r;
+}
+
+result
+_DetailedEmailMessageImpl::ParseMimeFile(const Tizen::Base::String& filePath, DetailedEmailMessage& message)
+{
+ result r = E_SUCCESS;
+ int err = EMAIL_ERROR_NONE;
+ char* pEmlFilePath = null;
+ email_mail_data_t* pMailData = null;
+ email_attachment_data_t* pAttachmentData = null;
+ DateTime msgDateTime;
+ int attachmentCount = 0;
+
+ ClearLastResult();
+ pEmlFilePath = _StringConverter::CopyToCharArrayN(filePath);
+ SysTryCatch(NID_MSG, pEmlFilePath != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed.");
+
+ err = email_parse_mime_file(pEmlFilePath, &pMailData, &pAttachmentData, &attachmentCount);
+
+ r = _DetailedEmailMessageImpl::ConvertException(err);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to parse the email message.", GetErrorMessage(r));
+
+ r = _DetailedEmailMessageImpl::FillDetailedEmailMessage(message, pMailData, pAttachmentData);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to Fill Detailed EmailMessage.", GetErrorMessage(r));
+
+ if (pEmlFilePath)
+ {
+ delete[] pEmlFilePath;
+ pEmlFilePath = null;
+ }
+
+ if (pMailData)
+ {
+ email_delete_parsed_data(pMailData);
+ email_free_mail_data(&pMailData, 1);
+ }
+
+ if (pAttachmentData)
+ {
+ email_free_attachment_data(&pAttachmentData, attachmentCount);
+ }
+
+ return r;
+
+CATCH:
+
+ SetLastResult(GetLastResult());
+
+ if (pEmlFilePath)
+ {
+ delete[] pEmlFilePath;
+ pEmlFilePath = null;
+ }
+
+ if (pMailData)
+ {
+ email_delete_parsed_data(pMailData);
+ email_free_mail_data(&pMailData, 1);
+ }
+
+ if (pAttachmentData)
+ {
+ email_free_attachment_data(&pAttachmentData, attachmentCount);
+ }
+
+ return r;
+}
+
+result
+_DetailedEmailMessageImpl::WriteToMimeFile(const DetailedEmailMessage& message, const Tizen::Base::String& filePath)
+{
+ bool isEmptyEmailMessage = _DetailedEmailMessageImpl::IsEmtpyEmailMessage(message);
+ SysTryReturnResult(NID_MSG, isEmptyEmailMessage == false, E_INVALID_ARG,
+ "The subject, body, recipients, and from address field of the message are all empty.");
+
+ result r = E_SUCCESS;
+ int err = EMAIL_ERROR_NONE;
+ char* pEmlFilePath = null;
+ email_mail_data_t* pMailData = null;
+ email_attachment_data_t* pAttachmentData = null;
+ email_attachment_data_t* pTempAttachmentData = null;
+ int attachmentCount = 0;
+ Tizen::Base::Collection::IList* pTempList = null;
+ char* pAttachName = null;
+ char* pAttachFilePath = null;
+ char* pAttachMimeType = null;
+
+ ClearLastResult();
+
+ pEmlFilePath = _StringConverter::CopyToCharArrayN(filePath);
+ SysTryCatch(NID_MSG, pEmlFilePath != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed.");
+
+ pTempList = (const_cast <DetailedEmailMessage&>(message)).GetAttachmentListN();
+ SysTryCatch(NID_MSG, pTempList != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Propagating.");
+
+ attachmentCount = pTempList->GetCount();
+
+ pMailData = (email_mail_data_t*) malloc(sizeof(email_mail_data_t));
+ SysTryCatch(NID_MSG, pMailData != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "memory allocation failed.");
+ memset(pMailData, 0x00, sizeof(email_mail_data_t));
+
+ if (attachmentCount >= 1)
+ {
+ pAttachmentData = (email_attachment_data_t*) malloc(sizeof(email_attachment_data_t)* attachmentCount);
+ SysTryCatch(NID_MSG, pAttachmentData != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "memory allocation failed.");
+ memset(pAttachmentData, 0x00, (sizeof(email_attachment_data_t)* attachmentCount));
+ pTempAttachmentData = pAttachmentData;
+
+ for (int index = 0; index < attachmentCount; index++)
+ {
+ EmailAttachment* pEmailAttachmentItem = dynamic_cast <EmailAttachment*>(pTempList->GetAt(index));
+ SysTryCatch(NID_MSG, pEmailAttachmentItem != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "memory allocation failed.");
+
+ pAttachName = _StringConverter::CopyToCharArrayN(pEmailAttachmentItem->GetName());
+ SysTryCatch(NID_MSG, pAttachName != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+ pTempAttachmentData->attachment_name = strdup(pAttachName);
+
+ pAttachFilePath = _StringConverter::CopyToCharArrayN(pEmailAttachmentItem->GetFilePath());
+ SysTryCatch(NID_MSG, pAttachFilePath != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+ pTempAttachmentData->attachment_path = strdup(pAttachFilePath);
+
+ pTempAttachmentData->inline_content_status = (int) pEmailAttachmentItem->GetInlineContentStatus();
+ pTempAttachmentData->drm_status = (int) pEmailAttachmentItem->GetDrmStatus();
+
+ pAttachMimeType = _StringConverter::CopyToCharArrayN(pEmailAttachmentItem->GetMimeType());
+ SysTryCatch(NID_MSG, pAttachMimeType != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+ pTempAttachmentData->attachment_mime_type = strdup(pAttachMimeType);
+
+ pTempAttachmentData++;
+ }
+ }
+
+ r = _DetailedEmailMessageImpl::FillEmailData(message, &pMailData);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to Fill email data.", GetErrorMessage(r));
+
+ err = email_write_mime_file(pMailData, pAttachmentData, attachmentCount, &pEmlFilePath);
+
+ r = _DetailedEmailMessageImpl::ConvertException(err);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to write email message to file.", GetErrorMessage(r));
+
+ if (pEmlFilePath)
+ {
+ delete[] pEmlFilePath;
+ pEmlFilePath = null;
+ }
+
+ if (pAttachName)
+ {
+ delete[] pAttachName;
+ pAttachName = null;
+ }
+
+ if (pAttachFilePath)
+ {
+ delete[] pAttachFilePath;
+ pAttachFilePath = null;
+ }
+
+ if (pAttachMimeType)
+ {
+ delete[] pAttachMimeType;
+ pAttachMimeType = null;
+ }
+
+ if (pMailData)
+ {
+ email_free_mail_data(&pMailData, 1);
+ }
+
+ if (pAttachmentData)
+ {
+ email_free_attachment_data(&pAttachmentData, attachmentCount);
+ }
+
+ if (pTempList)
+ {
+ if (pTempList->GetCount() > 0)
+ {
+ pTempList->RemoveAll(true);
+ }
+ delete pTempList;
+ pTempList = null;
+ }
+
+ return r;
+
+CATCH:
+
+ SetLastResult(GetLastResult());
+
+ if (pEmlFilePath)
+ {
+ delete[] pEmlFilePath;
+ pEmlFilePath = null;
+ }
+
+ if (pAttachName)
+ {
+ delete[] pAttachName;
+ pAttachName = null;
+ }
+
+ if (pAttachFilePath)
+ {
+ delete[] pAttachFilePath;
+ pAttachFilePath = null;
+ }
+
+ if (pAttachMimeType)
+ {
+ delete[] pAttachMimeType;
+ pAttachMimeType = null;
+ }
+
+ if (pMailData)
+ {
+ email_free_mail_data(&pMailData, 1);
+ }
+
+ if (pAttachmentData)
+ {
+ email_free_attachment_data(&pAttachmentData, attachmentCount);
+ }
+
+ if (pTempList)
+ {
+ if (pTempList->GetCount() > 0)
+ {
+ pTempList->RemoveAll(true);
+ }
+ delete pTempList;
+ pTempList = null;
+ }
+
+ return r;
+}
+
+result
+_DetailedEmailMessageImpl::ConvertException(int err)
+{
+ result r = E_SUCCESS;
+
+ switch (err)
+ {
+ case EMAIL_ERROR_NONE:
+ r = E_SUCCESS;
+ break;
+
+ case EMAIL_ERROR_INVALID_ADDRESS:
+ r = E_INVALID_ADDRESS;
+ break;
+
+ case EMAIL_ERROR_INVALID_PARAM:
+ case EMAIL_ERROR_INVALID_ATTACHMENT:
+ case EMAIL_ERROR_ATTACHMENT_NOT_FOUND:
+ case EMAIL_ERROR_FILE_NOT_FOUND:
+ r = E_INVALID_ARG;
+ break;
+
+ case EMAIL_ERROR_ACCOUNT_NOT_FOUND:
+ case EMAIL_ERROR_INVALID_ACCOUNT:
+ r = E_INVALID_ACCOUNT;
+ break;
+
+ case EMAIL_ERROR_ALREADY_EXISTS:
+ r = E_FILE_ALREADY_EXIST;
+ break;
+
+ case EMAIL_ERROR_XML_PARSER_FAILURE:
+ case EMAIL_ERROR_ON_PARSING:
+ case EMAIL_ERROR_INVALID_DATA:
+ r = E_PARSING_FAILED;
+ break;
+
+ case EMAIL_ERROR_DB_FAILURE:
+ case EMAIL_ERROR_OUT_OF_MEMORY:
+ r = E_STORAGE_FULL;
+ break;
+
+ default:
+ r = E_SYSTEM;
+ break;
+ }
+
+ return r;
+}
+
+result
+_DetailedEmailMessageImpl::FillDetailedEmailMessage(DetailedEmailMessage& message, email_mail_data_t* pMailData, email_attachment_data_t* pAttachmentData)
+{
+ result r = E_SUCCESS;
+ ArrayList* pList = null;
+
+ ClearLastResult();
+
+ SysTryReturn(NID_MSG, pMailData != null, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] Propagating.");
+ SysTryReturn(NID_MSG, pAttachmentData != null, E_INVALID_ARG, r = E_INVALID_ARG, "[E_INVALID_ARG] Propagating.");
+
+ String messageId(pMailData->message_id);
+ message.SetMessageId(messageId);
+
+ String msgSubject(pMailData->subject);
+ message.SetSubject(msgSubject);
+
+ struct tm* pTempTime = null;
+ time_t time = pMailData->date_time;
+ pTempTime = gmtime(&time);
+ DateTime msgDateTime;
+
+ if (pTempTime)
+ {
+ msgDateTime.SetValue(pTempTime->tm_year + 1900, pTempTime->tm_mon + 1, pTempTime->tm_mday, pTempTime->tm_hour + 1, pTempTime->tm_min, pTempTime->tm_sec);
+ }
+ message.SetCreationTime(msgDateTime);
+
+ String toAddr(pMailData->full_address_to);
+ String ccAddr(pMailData->full_address_cc);
+ String bccAddr(pMailData->full_address_bcc);
+
+ message.SetAddress(RECIPIENT_TYPE_TO, toAddr);
+ message.SetAddress(RECIPIENT_TYPE_CC, ccAddr);
+ message.SetAddress(RECIPIENT_TYPE_BCC, bccAddr);
+
+ String fromAddress(pMailData->full_address_from);
+ message.SetFromAddress(fromAddress);
+
+ String replayToAddress(pMailData->full_address_reply);
+ message.SetReplyToAddress(replayToAddress);
+
+ String returnAddrPath(pMailData->full_address_return);
+ message.SetReturnPath(returnAddrPath);
+
+ String filePathPlain(pMailData->file_path_plain);
+ String filePathHtml(pMailData->file_path_html);
+ String filePathMime(pMailData->file_path_mime_entity);
+
+ message.SetFilePath(EMAIL_MESSAGE_BODY_TYPE_PLAIN_TEXT, filePathPlain);
+ message.SetFilePath(EMAIL_MESSAGE_BODY_TYPE_HTML, filePathHtml);
+ message.SetFilePath(EMAIL_MESSAGE_BODY_TYPE_MIME, filePathMime);
+
+ message.SetPriority((EmailMessagePriority) pMailData->priority);
+ message.SetReturnReceiptType((EmailReturnReceiptType) pMailData->report_status);
+ message.SetInlineContentCount(pMailData->inline_content_count);
+ message.SetClass((EmailMessageClass) pMailData->message_class);
+ message.SetDigestType((EmailDigestType) pMailData->digest_type);
+ message.SetSmimeType((EmailSmimeType) pMailData->smime_type);
+
+ pList = new (std::nothrow) ArrayList();
+ SysTryCatch(NID_MSG, pList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "memory allocation failed.");
+
+ r = pList->Construct();
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to construct attachment list.", GetErrorMessage(r));
+
+ for (int index = 0; index < pMailData->attachment_count; index++)
+ {
+ EmailAttachment* pEmailAttachment = null;
+ pEmailAttachment = new (std::nothrow) EmailAttachment();
+ SysTryCatch(NID_MSG, pEmailAttachment != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "memory allocation failed.");
+
+ String attachName(pAttachmentData[index].attachment_name);
+ pEmailAttachment->SetName(attachName);
+ String attachPath(pAttachmentData[index].attachment_path);
+ pEmailAttachment->SetFilePath(attachPath);
+ pEmailAttachment->SetInlineContentStatus((bool) pAttachmentData[index].inline_content_status);
+ pEmailAttachment->SetDrmStatus((bool) pAttachmentData[index].drm_status);
+ String attachMimeType(pAttachmentData[index].attachment_mime_type);
+ pEmailAttachment->SetMimeType(attachMimeType);
+
+ r = pList->Add(*pEmailAttachment);
+ }
+
+ r = message.SetAttachmentList(pList);
+
+ if (pList)
+ {
+ if (pList->GetCount() > 0)
+ {
+ pList->RemoveAll(true);
+ }
+ delete pList;
+ pList = null;
+ }
+
+ return r;
+
+CATCH:
+ SetLastResult(GetLastResult());
+
+ if (pList)
+ {
+ if (pList->GetCount() > 0)
+ {
+ pList->RemoveAll(true);
+ }
+ delete pList;
+ pList = null;
+ }
+ return r;
+}
+
+result
+_DetailedEmailMessageImpl::FillEmailData(const DetailedEmailMessage& message, email_mail_data_t** pMailData)
+{
+ result r = E_SUCCESS;
+ char* pMessageId = null;
+ char* pMessageSubject = null;
+ char* pToAddr = null;
+ char* pCcAddr = null;
+ char* pBccAddr = null;
+ char* pFromAddr = null;
+ char* pReplayToAddr = null;
+ char* pReturnPath = null;
+ char* pFilePathPlain = null;
+ char* pFilePathHtml = null;
+ char* pFilePathMime = null;
+ time_t time = 0;
+ struct tm timeinfo;
+ DateTime msgDateTime;
+
+ ClearLastResult();
+
+ pMessageId = _StringConverter::CopyToCharArrayN(message.GetMessageId());
+ SysTryCatch(NID_MSG, pMessageId != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+ (*pMailData)->message_id = strdup(pMessageId);
+
+ pMessageSubject = _StringConverter::CopyToCharArrayN(message.GetSubject());
+ SysTryCatch(NID_MSG, pMessageSubject != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+ (*pMailData)->subject = strdup(pMessageSubject);
+
+ msgDateTime = message.GetCreationTime();
+ timeinfo.tm_year = msgDateTime.GetYear();
+ timeinfo.tm_mon = msgDateTime.GetMonth();
+ timeinfo.tm_mday = msgDateTime.GetDay();
+ timeinfo.tm_hour = msgDateTime.GetHour();
+ timeinfo.tm_min = msgDateTime.GetMinute();
+ timeinfo.tm_sec = msgDateTime.GetSecond();
+
+ time = mktime(&timeinfo);
+ (*pMailData)->date_time = time;
+
+ pToAddr = _StringConverter::CopyToCharArrayN(message.GetAddress(RECIPIENT_TYPE_TO));
+ SysTryCatch(NID_MSG, pToAddr != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+ (*pMailData)->full_address_to = strdup(pToAddr);
+
+ pCcAddr = _StringConverter::CopyToCharArrayN(message.GetAddress(RECIPIENT_TYPE_CC));
+ SysTryCatch(NID_MSG, pCcAddr != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+ (*pMailData)->full_address_cc = strdup(pCcAddr);
+
+ pBccAddr = _StringConverter::CopyToCharArrayN(message.GetAddress(RECIPIENT_TYPE_BCC));
+ SysTryCatch(NID_MSG, pBccAddr != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+ (*pMailData)->full_address_bcc = strdup(pBccAddr);
+
+ pFromAddr = _StringConverter::CopyToCharArrayN(message.GetFromAddress());
+ SysTryCatch(NID_MSG, pFromAddr != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+ (*pMailData)->full_address_from = strdup(pFromAddr);
+
+ pReplayToAddr = _StringConverter::CopyToCharArrayN(message.GetReplyToAddress());
+ SysTryCatch(NID_MSG, pReplayToAddr != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+ (*pMailData)->full_address_reply = strdup(pReplayToAddr);
+
+ pReturnPath = _StringConverter::CopyToCharArrayN(message.GetReturnPath());
+ SysTryCatch(NID_MSG, pReturnPath != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+ (*pMailData)->full_address_return = strdup(pReturnPath);
+
+ pFilePathPlain = _StringConverter::CopyToCharArrayN(message.GetFilePath(EMAIL_MESSAGE_BODY_TYPE_PLAIN_TEXT));
+ SysTryCatch(NID_MSG, pFilePathPlain != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+ (*pMailData)->full_address_return = strdup(pFilePathPlain);
+
+ pFilePathHtml = _StringConverter::CopyToCharArrayN(message.GetFilePath(EMAIL_MESSAGE_BODY_TYPE_HTML));
+ SysTryCatch(NID_MSG, pFilePathHtml != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+ (*pMailData)->full_address_return = strdup(pFilePathHtml);
+
+ pFilePathMime = _StringConverter::CopyToCharArrayN(message.GetFilePath(EMAIL_MESSAGE_BODY_TYPE_MIME));
+ SysTryCatch(NID_MSG, pFilePathMime != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+ (*pMailData)->full_address_return = strdup(pFilePathMime);
+
+ (*pMailData)->priority = (email_mail_priority_t)message.GetPriority();
+ (*pMailData)->report_status = (email_mail_report_t)message.GetReturnReceiptType();
+ (*pMailData)->inline_content_count = message.GetInlineContentCount();
+ (*pMailData)->message_class = (email_message_class)message.GetClass();
+ (*pMailData)->digest_type = (email_digest_type)message.GetDigestType();
+ (*pMailData)->smime_type = (email_smime_type)message.GetSmimeType();
+ (*pMailData)->body_download_status = 1;
+
+ SetLastResult(GetLastResult());
+
+ if (pMessageId)
+ {
+ delete[] pMessageId;
+ pMessageId = null;
+ }
+
+ if (pMessageSubject)
+ {
+ delete[] pMessageSubject;
+ pMessageSubject = null;
+ }
+
+ if (pToAddr)
+ {
+ delete[] pToAddr;
+ pToAddr = null;
+ }
+
+ if (pCcAddr)
+ {
+ delete[] pCcAddr;
+ pCcAddr = null;
+ }
+
+ if (pBccAddr)
+ {
+ delete[] pBccAddr;
+ pBccAddr = null;
+ }
+
+ if (pFromAddr)
+ {
+ delete[] pFromAddr;
+ pFromAddr = null;
+ }
+
+ if (pReplayToAddr)
+ {
+ delete[] pReplayToAddr;
+ pReplayToAddr = null;
+ }
+
+ if (pReturnPath)
+ {
+ delete[] pReturnPath;
+ pReturnPath = null;
+ }
+
+ if (pFilePathPlain)
+ {
+ delete[] pFilePathPlain;
+ pFilePathPlain = null;
+ }
+
+ if (pFilePathHtml)
+ {
+ delete[] pFilePathHtml;
+ pFilePathHtml = null;
+ }
+
+ if (pFilePathMime)
+ {
+ delete[] pFilePathMime;
+ pFilePathMime = null;
+ }
+
+ return r;
+
+CATCH:
+ SetLastResult(GetLastResult());
+
+ if (pMessageId)
+ {
+ delete[] pMessageId;
+ pMessageId = null;
+ }
+
+ if (pMessageSubject)
+ {
+ delete[] pMessageSubject;
+ pMessageSubject = null;
+ }
+
+ if (pToAddr)
+ {
+ delete[] pToAddr;
+ pToAddr = null;
+ }
+
+ if (pCcAddr)
+ {
+ delete[] pCcAddr;
+ pCcAddr = null;
+ }
+
+ if (pBccAddr)
+ {
+ delete[] pBccAddr;
+ pBccAddr = null;
+ }
+
+ if (pFromAddr)
+ {
+ delete[] pFromAddr;
+ pFromAddr = null;
+ }
+
+ if (pReplayToAddr)
+ {
+ delete[] pReplayToAddr;
+ pReplayToAddr = null;
+ }
+
+ if (pReturnPath)
+ {
+ delete[] pReturnPath;
+ pReturnPath = null;
+ }
+
+ if (pFilePathPlain)
+ {
+ delete[] pFilePathPlain;
+ pFilePathPlain = null;
+ }
+
+ if (pFilePathHtml)
+ {
+ delete[] pFilePathHtml;
+ pFilePathHtml = null;
+ }
+
+ return r;
+}
+
+bool
+_DetailedEmailMessageImpl::IsEmtpyEmailMessage(const DetailedEmailMessage& message)
+{
+ bool isSubjectEmpty= message.GetSubject().IsEmpty();
+ bool isBodyEmpty = message.GetFilePath(EMAIL_MESSAGE_BODY_TYPE_PLAIN_TEXT).IsEmpty()
+ && message.GetFilePath(EMAIL_MESSAGE_BODY_TYPE_HTML).IsEmpty()
+ && message.GetFilePath(EMAIL_MESSAGE_BODY_TYPE_MIME).IsEmpty();
+ bool isRecipientEmpty = message.GetAddress(RECIPIENT_TYPE_TO).IsEmpty()
+ && message.GetAddress(RECIPIENT_TYPE_CC).IsEmpty()
+ && message.GetAddress(RECIPIENT_TYPE_BCC).IsEmpty();
+ bool isFromAddressEmpty = message.GetFromAddress().IsEmpty();
+
+ return (isSubjectEmpty && isBodyEmpty && isRecipientEmpty && isFromAddressEmpty);
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+* @if VISPARTNER-OPERATOR
+*
+* @file FMsg_DetailedEmailMessageImpl.h
+* @brief This is the header file for the %_DetailedEmailMessageImpl class.
+*
+* @visibility partner-operator
+*
+* This header file contains the declarations of the %_DetailedEmailMessageImpl class.
+*
+* @endif
+*/
+
+#ifndef _FMSG_INTERNAL_DETAILED_EMAIL_MESSAGE_IMPL_H_
+#define _FMSG_INTERNAL_DETAILED_EMAIL_MESSAGE_IMPL_H_
+
+namespace Tizen { namespace Messaging
+{
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * @class _DetailedEmailMessageImpl
+ * @brief This class provides methods for handling detailed email messages.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * The %_DetailedEmailMessageImpl class provides methods for handling detailed email messages.
+ *
+ * @endif
+ */
+ class _DetailedEmailMessageImpl
+ : public Tizen::Base::Object
+ {
+ // Life cycle
+ public:
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * This is the default constructor for this class.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @endif
+ */
+ _DetailedEmailMessageImpl(void);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * This is the destructor for this class.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @endif
+ */
+ virtual ~_DetailedEmailMessageImpl(void);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * This is the copy constructor for the %_DetailedEmailMessageImpl class. @n
+ * Copying of objects using this copy constructor is allowed.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @param[in] rhs An instance of %_DetailedEmailMessageImpl
+ *
+ * @endif
+ */
+ _DetailedEmailMessageImpl(const _DetailedEmailMessageImpl& rhs);
+
+
+ public:
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * This assignment operator copies an email message from the specified instance of %_DetailedEmailMessageImpl to the calling instance of %_DetailedEmailMessageImpl. @n
+ * Copying of objects using this copy assignment operator is allowed.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The reference of this instance
+ * @param[in] rhs A reference to the %_DetailedEmailMessageImpl instance to be copied
+ *
+ * @endif
+ */
+ _DetailedEmailMessageImpl& operator =(const _DetailedEmailMessageImpl& rhs);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Compares the calling instance with the specified instance.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return @c true if the specified instance of Object is equal to the calling %_DetailedEmailMessageImpl instance, @n
+ * else @c false
+ * @param[in] obj The 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.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The hash value of the current instance
+ *
+ * @endif
+ */
+ virtual int GetHashCode(void) const;
+
+ // Operation
+ public:
+ ///////////////////////////////////////////////////////////////
+ // Getters
+ ///////////////////////////////////////////////////////////////
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the Message-ID of the message.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The Message-ID of the message.
+ * @see SetMessageId()
+ *
+ * @endif
+ */
+ Tizen::Base::String GetMessageId(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the subject of the message.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The subject of the email message
+ * @see SetSubject()
+ *
+ * @endif
+ */
+ Tizen::Base::String GetSubject(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the time when the email message was created.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The time when the email message was created
+ * @see SetCreationTime()
+ * @remark The creation time may be changed by mail server on sending.
+ *
+ * @endif
+ */
+ Tizen::Base::DateTime GetCreationTime(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the recipients of the specific recipient type.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The email address of specified recipient type
+ * @param[in] type The type of recipient
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c type is invalid.
+ * @remarks The values for the various recipients can be a string with multiple email addresses separated by semi-colons.(;). @n
+ * The specified @c type contains RECIPIENT_TYPE_TO, RECIPIENT_TYPE_CC, RECIPIENT_TYPE_BCC. @n
+ * The specific error code can be accessed using the GetLastResult() method.
+ * @see SetAddress()
+ *
+ * @endif
+ */
+ Tizen::Base::String GetAddress(RecipientType type) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the email address of the author.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The email address of the author
+ * @see SetFromAddress()
+ *
+ * @endif
+ */
+ Tizen::Base::String GetFromAddress(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the email address which used to reply to the message
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The email address which used to reply to the message
+ * @see SetReplyToAddress()
+ *
+ * @endif
+ */
+ Tizen::Base::String GetReplyToAddress(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the return-path
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The return-path
+ * @see SetReturnPath()
+ *
+ * @endif
+ */
+ Tizen::Base::String GetReturnPath(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the file path of the speicified message body type.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The file path of the message body
+ * @param[in] type The type of message body
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c type is invalid.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @see SetFilePath()
+ *
+ * @endif
+ */
+ Tizen::Base::String GetFilePath(EmailMessageBodyType type) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the priority of the message
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The priority of the message
+ * @see SetPriority()
+ *
+ * @endif
+ */
+ EmailMessagePriority GetPriority(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the return receipt type of the message
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The return receipt type of the message
+ * @see SetReturnReceiptType()
+ *
+ * @endif
+ */
+ EmailReturnReceiptType GetReturnReceiptType(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the inline content count of the message.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The inline content count of the message
+ * @see SetInlineContentCount()
+ *
+ * @endif
+ */
+ int GetInlineContentCount(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the class of the message
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The class of the message
+ * @see SetClass()
+ *
+ * @endif
+ */
+ EmailMessageClass GetClass(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the digest type of the message
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The digest type of the message
+ * @see SetDigestType()
+ *
+ * @endif
+ */
+ EmailDigestType GetDigestType(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the S/MIME type of the message
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The S/MIME type of the message
+ * @see SetSmimeType()
+ *
+ * @endif
+ */
+ EmailSmimeType GetSmimeType(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the attachment list of the message
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return A pointer to the list of attachment
+ * @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
+ * After using the attachment list, you can call Tizen::Base::Collection::IList::RemoveAll(true) to clean up items in the list.
+ * @see EmailAttachment, SetAttachmentList()
+ *
+ * @endif
+ */
+ Tizen::Base::Collection::IList* GetAttachmentListN(void);
+
+
+ public:
+ ///////////////////////////////////////////////////////////////
+ // Setters
+ ///////////////////////////////////////////////////////////////
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the Message-ID of the message.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] messageId The Message-ID of the message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The length of the specified @c messageId is @c 0.
+ * @remarks The Message ID is an automatically generated field. @n
+ * It is used to prevent multiple delivery and for reference in In-Reply-To.
+ * @see GetMessageId()
+ *
+ * @endif
+ */
+ result SetMessageId(const Tizen::Base::String& messageId);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the subject of the email.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] subject The subject of the email message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_MAX_EXCEEDED The subject length of the message exceeds the maximum limit (Maximum 256 characters)
+ * @see GetSubject()
+ *
+ * @endif
+ */
+ result SetSubject(const Tizen::Base::String& subject);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the time when the email message was created.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] dateTime The time when the email message was created
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c dateTime is invalid. @n
+ * The valid range of the time can be from "January 1 1900 00:00:00" to "December 31 2100 23:59:59"
+ * @see GetCreationTime()
+ *
+ * @endif
+ */
+ result SetCreationTime(const Tizen::Base::DateTime& dateTime);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the recipient list of the specific recipient type.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] type The type of recipient
+ * @param[in] recipients The recipients string
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c type is invalid. @n
+ * The specified @c recipients string length is too short (< 5).
+ * @remarks The values for the various recipients can be a string with multiple email addresses separated by semi-colons.(;).@n
+ * The specified @c type contains RECIPIENT_TYPE_TO, RECIPIENT_TYPE_CC, RECIPIENT_TYPE_BCC. @n
+ * @see GetAddress()
+ *
+ * @endif
+ */
+ result SetAddress(RecipientType type, const Tizen::Base::String& recipients);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the email address of the author.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] address The email address of the author
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c address string length is too short (< 5).
+ * @see GetFromAddress()
+ *
+ * @endif
+ */
+ result SetFromAddress(const Tizen::Base::String& address);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the email address which used to reply to the message.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] address The email address which used to reply to the message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c address string length is too short (< 5).
+ * @see GetReplyToAddress()
+ *
+ * @endif
+ */
+ result SetReplyToAddress(const Tizen::Base::String& address);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the return-path
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] address The return-path
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c address string length is too short (< 5).
+ * @see GetReturnPath()
+ *
+ * @endif
+ */
+ result SetReturnPath(const Tizen::Base::String& address);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the file path of the speicified message body type.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] type The type of message body
+ * @param[in] filePath The file path of the message body
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c type is invalid. @n
+ * 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(EmailMessageBodyType type, const Tizen::Base::String& filePath);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the prioirity of the message
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] priority The prioirity of the message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c priority is invalid.
+ * @see GetPriority()
+ *
+ * @endif
+ */
+ result SetPriority(EmailMessagePriority priority);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the return receipt type of the message
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] type The return receipt type of the message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c type is invalid.
+ * @see GetReturnReceiptType()
+ *
+ * @endif
+ */
+ result SetReturnReceiptType(EmailReturnReceiptType type);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the inline content count of the message.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] count The inline content count of the message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c count is less than 0.
+ * @see GetInlineContentCount()
+ *
+ * @endif
+ */
+ result SetInlineContentCount(int count);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the class of the message
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] messageClass The class of the message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c messageClass is invalid.
+ * @see GetClass()
+ *
+ * @endif
+ */
+ result SetClass(EmailMessageClass messageClass);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the digest type of the message
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] type The digest type of the message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c type is invalid.
+ * @see GetDigestType()
+ *
+ * @endif
+ */
+ result SetDigestType(EmailDigestType type);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the S/MIME type of the message
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] type The S/MIME type of the message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c type is invalid.
+ * @see GetSmimeType()
+ *
+ * @endif
+ */
+ result SetSmimeType(EmailSmimeType type);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets a attachment list for this message.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] pList A list of %EmailAttachment
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The list is not made of %EmailAttachment
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @see EmailAttachment, GetAttachmentListN()
+ *
+ * @endif
+ */
+ result SetAttachmentList(const Tizen::Base::Collection::IList* pList);
+
+public:
+ ///////////////////////////////////////////////////////////////
+ // static methods
+ ///////////////////////////////////////////////////////////////
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Parses the MIME file to %_DetailedEmailMessageImpl format
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] filePath The MIME file path to be parsed
+ * @param[out] message The parsed message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_PARSING_FAILED The method has failed to parse the MIME file.
+ * @exception E_SYSTEM A system error has occurred.
+ * @see WriteToMimeFile()
+ *
+ * @endif
+ */
+ static result ParseMimeFile(const Tizen::Base::String& filePath, DetailedEmailMessage& message);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Write to the MIME file from %_DetailedEmailMessageImpl
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] message The message to be read
+ * @param[in] filePath The file path of the MIME file to be written
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The value of @c message is invalid
+ * @exception E_ILLEGAL_ACCESS The specified @c filePath is inaccessible as per the Tizen platform policy.
+ * @exception E_FILE_ALREADY_EXIST The specified file already exists.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SYSTEM A system error has occurred.
+ * @see ParseMimeFile()
+ *
+ * @endif
+ */
+ static result WriteToMimeFile(const DetailedEmailMessage& message, const Tizen::Base::String& filePath);
+
+
+ public:
+ static result ConvertException(int err);
+
+ static result FillDetailedEmailMessage(DetailedEmailMessage& message, email_mail_data_t* pMailData, email_attachment_data_t* pAttachmentData);
+
+ static result FillEmailData(const DetailedEmailMessage& message, email_mail_data_t** pMailData);
+
+ static bool IsEmtpyEmailMessage(const DetailedEmailMessage& message);
+
+
+ private:
+ Tizen::Base::String __messageId; // message ID (not a unique number of a mail), defined in RFC2392, time and date stamp along with the local host's domain name, e.g., 950124.162336@XIson.com.
+ Tizen::Base::String __subject; // email subject
+ Tizen::Base::DateTime __dateTime; // sent/received time
+
+ // full address
+ Tizen::Base::String __toAddress;
+ Tizen::Base::String __ccAddress;
+ Tizen::Base::String __bccAddress;
+ Tizen::Base::String __fromAddress;
+ Tizen::Base::String __replyToAddress; // Address that should be used to reply to the message.
+ Tizen::Base::String __returnPath;
+
+ // file path
+ Tizen::Base::String __filePathBody;
+ Tizen::Base::String __filePathHtmlBody;
+ Tizen::Base::String __filePathMimeEntity;
+
+ int __mailSize;
+ EmailMessagePriority __priority;
+ EmailReturnReceiptType __returnReceiptType; // email_mail_report_t
+ int __attachmentCount;
+ int __inlineContentCount; // inline content => for example, embeded image in html
+ EmailMessageClass __messageClass;
+ EmailDigestType __digestType;
+ EmailSmimeType __smimeType;
+
+ Tizen::Base::Collection::ArrayList* __pAttachmentList;
+ }; // DetailedEmailMessage
+} } // Tizen::Messaging
+
+#endif // _FMSG_INTERNAL_DETAILED_EMAIL_MESSAGE_IMPL_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_EmailAttachmentImpl.cpp
+ * @brief This is the implementation file for the %_EmailAttachmentImpl class.
+ *
+ * This file contains the implementation of the %_EmailAttachmentImpl class.
+ */
+
+#include <email-api.h>
+#include <FMsgEmailAttachment.h>
+#include <FMsgDetailedEmailMessage.h>
+#include <FIoFile.h>
+#include <FBaseSysLog.h>
+#include "FMsg_EmailAttachmentImpl.h"
+#include "FMsg_DetailedEmailMessageImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Messaging
+{
+
+_EmailAttachmentImpl::_EmailAttachmentImpl(void)
+ : __id(0)
+ , __name(L"")
+ , __path(L"")
+ , __size(0)
+ , __mailId(0)
+ , __accountId(0)
+ , __mailboxName(L"")
+ , __saveStatus(false)
+ , __drmStatus(false)
+ , __inlineContentStatus(false)
+ , __attachmentMimeType(L"")
+{
+}
+
+_EmailAttachmentImpl::~_EmailAttachmentImpl(void)
+{
+}
+
+_EmailAttachmentImpl::_EmailAttachmentImpl(const _EmailAttachmentImpl& value)
+{
+ __id = value.__id;
+ __name = value.__name;
+ __path = value.__path;
+ __size = value.__size;
+ __mailId = value.__mailId;
+ __accountId = value.__accountId;
+ __mailboxName = value.__mailboxName;
+ __saveStatus = value.__saveStatus;
+ __drmStatus = value.__drmStatus;
+ __inlineContentStatus = value.__inlineContentStatus;
+ __attachmentMimeType = value.__attachmentMimeType;
+}
+
+_EmailAttachmentImpl&
+_EmailAttachmentImpl::operator =(const _EmailAttachmentImpl& rhs)
+{
+ if (this != &rhs)
+ {
+ __id = rhs.__id;
+ __name = rhs.__name;
+ __path = rhs.__path;
+ __size = rhs.__size;
+ __mailId = rhs.__mailId;
+ __accountId = rhs.__accountId;
+ __mailboxName = rhs.__mailboxName;
+ __saveStatus = rhs.__saveStatus;
+ __drmStatus = rhs.__drmStatus;
+ __inlineContentStatus = rhs.__inlineContentStatus;
+ __attachmentMimeType = rhs.__attachmentMimeType;
+ }
+
+ return (*this);
+}
+
+bool
+_EmailAttachmentImpl::Equals(const Tizen::Base::Object& obj) const
+{
+ const _EmailAttachmentImpl* pEmailAttachmentImpl = dynamic_cast<const _EmailAttachmentImpl*>(&obj);
+
+ if (!pEmailAttachmentImpl)
+ {
+ SysLog(NID_MSG, "dynamic_cast is failed");
+ return false;
+ }
+ // attach id
+ if (__id != pEmailAttachmentImpl->__id)
+ {
+ return false;
+ }
+
+ // attach name
+ if (__name != pEmailAttachmentImpl->__name)
+ {
+ return false;
+ }
+
+ // attach path
+ if (__path != pEmailAttachmentImpl->__path)
+ {
+ return false;
+ }
+
+ // attach size
+ if (__size != pEmailAttachmentImpl->__size)
+ {
+ return false;
+ }
+
+ // attach mailid
+ if (__mailId != pEmailAttachmentImpl->__mailId)
+ {
+ return false;
+ }
+
+ // attach accountid
+ if (__accountId != pEmailAttachmentImpl->__accountId)
+ {
+ return false;
+ }
+ // attach id
+ if (__mailboxName != pEmailAttachmentImpl->__mailboxName)
+ {
+ return false;
+ }
+
+ // attach save status
+ if (__saveStatus != pEmailAttachmentImpl->__saveStatus)
+ {
+ return false;
+ }
+
+ // attach drm status
+ if (__drmStatus != pEmailAttachmentImpl->__drmStatus)
+ {
+ return false;
+ }
+ // attach inline content status
+ if (__inlineContentStatus != pEmailAttachmentImpl->__inlineContentStatus)
+ {
+ return false;
+ }
+
+ // attach mime type
+ if (__attachmentMimeType != pEmailAttachmentImpl->__attachmentMimeType)
+ {
+ return false;
+ }
+ return true;
+}
+
+int
+_EmailAttachmentImpl::GetHashCode(void) const
+{
+ int hash = 0;
+
+ hash = __id + __name.GetHashCode() + __path.GetHashCode() + __size + __mailId + __accountId +
+ __mailboxName.GetHashCode() + (__saveStatus ? 1 : 0) + (__drmStatus ? 1 : 0) + (__inlineContentStatus ? 1 : 0) +
+ __attachmentMimeType.GetHashCode();
+
+ return hash;
+}
+
+Tizen::Base::String
+_EmailAttachmentImpl::GetName(void) const
+{
+ return __name;
+}
+
+Tizen::Base::String
+_EmailAttachmentImpl::GetFilePath(void) const
+{
+ return __path;
+}
+
+int
+_EmailAttachmentImpl::GetSize(void) const
+{
+ FileAttributes fileDetails;
+ int fileSize = 0;
+
+ if (File::GetAttributes(__path, fileDetails) == E_SUCCESS)
+ {
+ fileSize = fileDetails.GetFileSize();
+ }
+
+ return fileSize;
+}
+
+bool
+_EmailAttachmentImpl::GetInlineContentStatus(void) const
+{
+ return __inlineContentStatus;
+}
+
+bool
+_EmailAttachmentImpl::GetDrmStatus(void) const
+{
+ return __drmStatus;
+}
+
+Tizen::Base::String
+_EmailAttachmentImpl::GetMimeType(void) const
+{
+ return __attachmentMimeType;
+}
+
+result
+_EmailAttachmentImpl::SetName(const Tizen::Base::String& name)
+{
+ result r = E_SUCCESS;
+ ClearLastResult();
+
+ __name = name;
+
+ return r;
+}
+
+result
+_EmailAttachmentImpl::SetFilePath(const Tizen::Base::String& filePath)
+{
+ result r = E_SUCCESS;
+ ClearLastResult();
+
+ __path = filePath;
+
+ return r;
+}
+
+void
+_EmailAttachmentImpl::SetInlineContentStatus(bool status)
+{
+ __inlineContentStatus = status;
+}
+
+void
+_EmailAttachmentImpl::SetDrmStatus(bool status)
+{
+ __drmStatus = status;
+}
+
+result
+_EmailAttachmentImpl::SetMimeType(const Tizen::Base::String& type)
+{
+ result r = E_SUCCESS;
+ ClearLastResult();
+
+ __attachmentMimeType = type;
+
+ return r;
+}
+} } // Tizen::Messaging
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+* @if VISPARTNER-OPERATOR
+*
+* @file FMsg_EmailAttachmentImpl.h
+* @brief This is the header file for the %_EmailAttachmentImpl class.
+*
+* @visibility partner-operator
+*
+* This header file contains the declarations of the %_EmailAttachmentImpl class.
+*
+* @endif
+*/
+
+#ifndef _FMSG_INTERNAL_EMAIL_ATTACHMENT_IMPL_H_
+#define _FMSG_INTERNAL_EMAIL_ATTACHMENT_IMPL_H_
+
+namespace Tizen { namespace Messaging
+{
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * @class _EmailAttachmentImpl
+ * @brief This class provides methods for handling email attachments.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * The %_EmailAttachmentImpl class provides methods for handling email attachments.
+ *
+ * @endif
+ */
+ class _EmailAttachmentImpl
+ : public Tizen::Base::Object
+ {
+ // Life cycle
+ public:
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * This is the default constructor for this class.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @endif
+ */
+ _EmailAttachmentImpl(void);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * This is the destructor for this class.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @endif
+ */
+ virtual ~_EmailAttachmentImpl(void);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * This is the copy constructor for the %_EmailAttachmentImpl class. @n
+ * Copying of objects using this copy constructor is allowed.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @param[in] rhs An instance of %_EmailAttachmentImpl
+ *
+ * @endif
+ */
+ _EmailAttachmentImpl(const _EmailAttachmentImpl& rhs);
+
+
+ public:
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * This assignment operator copies an email message from the specified instance of %_EmailAttachmentImpl to the calling instance of %_EmailAttachmentImpl. @n
+ * Copying of objects using this copy assignment operator is allowed.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The reference of this instance
+ * @param[in] rhs A reference to the %_EmailAttachmentImpl instance to be copied
+ *
+ * @endif
+ */
+ _EmailAttachmentImpl& operator =(const _EmailAttachmentImpl& rhs);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Compares the calling instance with the specified instance.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return @c true if the specified instance of Object is equal to the calling %_EmailAttachmentImpl instance, @n
+ * else @c false
+ * @param[in] obj The 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.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The hash value of the current instance
+ *
+ * @endif
+ */
+ virtual int GetHashCode(void) const;
+
+ // Operation
+ public:
+ ///////////////////////////////////////////////////////////////
+ // Getters
+ ///////////////////////////////////////////////////////////////
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the name of the attachment.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The name of the email attachment
+ * @see SetName()
+ *
+ * @endif
+ */
+ Tizen::Base::String GetName(void) const;
+
+ /**
+ *
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the file path of the attachment.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The file path of the attachment
+ * @see SetFilePath()
+ *
+ * @endif
+ */
+ Tizen::Base::String GetFilePath(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the size of the attachment.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The size of the attachment
+ *
+ * @endif
+ */
+ int GetSize(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the inline-content status of the attachment
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return @c true if the attachment has inline-content(s), @n
+ * else @c false
+ * @see SetInlineContentStatus()
+ *
+ * @endif
+ */
+ bool GetInlineContentStatus(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the DRM status of the attachment
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return @c true if the attachment contains DRM, @n
+ * else @c false
+ * @see SetDrmStatus()
+ *
+ * @endif
+ */
+ bool GetDrmStatus(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the MIME type of the attachment.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The MIME type of the email attachment
+ * @see SetMimeType()
+ *
+ * @endif
+ */
+ Tizen::Base::String GetMimeType(void) const;
+
+
+ public:
+ ///////////////////////////////////////////////////////////////
+ // Setters
+ ///////////////////////////////////////////////////////////////
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Sets the name of the attachment.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return An error code
+ * @param[in] name The name of the 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 the attachment.
+ *
+ * @since 2.1
+ *
+ * @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 the attachment
+ *
+ * @since 2.1
+ *
+ * @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 the attachment
+ *
+ * @since 2.1
+ *
+ * @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 the attachment.
+ *
+ * @since 2.1
+ *
+ * @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);
+
+ private:
+ int __id;
+ Tizen::Base::String __name;
+ Tizen::Base::String __path;
+ int __size;
+ int __mailId;
+ int __accountId;
+ Tizen::Base::String __mailboxName;
+ bool __saveStatus;
+ bool __drmStatus;
+ bool __inlineContentStatus;
+ Tizen::Base::String __attachmentMimeType; /**< Specifies the context mime type.*/
+
+ }; // _EmailAttachmentImpl
+} } // Tizen::Messaging
+
+#endif // _FMSG_INTERNAL_EMAIL_ATTACHMENT_IMPL_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_EmailEvent.cpp
+ * @brief This is the implementation file for the %_EmailEvent class.
+ *
+ * This file contains the implementation of the %_EmailEvent class.
+ */
+
+#include <FMsgIEmailListener.h>
+#include <FBaseSysLog.h>
+#include "FMsg_EmailEvent.h"
+#include "FMsg_EmailEventArg.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Messaging
+{
+
+_EmailEvent::_EmailEvent(void)
+{
+}
+
+result
+_EmailEvent::Construct(void)
+{
+ return _Event::Initialize();
+}
+
+void
+_EmailEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+ result r = E_SUCCESS;
+
+ IEmailListener* pEmailListener = dynamic_cast <IEmailListener*>(&listener);
+ SysTryReturnVoidResult(NID_MSG, pEmailListener != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system.");
+
+ IEventArg* pEventArg = const_cast <IEventArg*>(&arg);
+ _EmailEventArg* pEmailEventArg = dynamic_cast <_EmailEventArg*>(pEventArg);
+ SysTryReturnVoidResult(NID_MSG, pEmailEventArg != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system.");
+
+ // get error result
+ pEmailEventArg->GetErrorResult(r);
+
+ // Fire
+ pEmailListener->OnEmailMessageSent(r);
+}
+
+} }
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_EmailEvent.h
+ * @brief This is the header file for _EmailEvent class.
+ *
+ * This header file contains the declarations of _EmailEvent class.
+ */
+
+#ifndef _FMSG_INTERNAL_EMAIL_EVENT_H_
+#define _FMSG_INTERNAL_EMAIL_EVENT_H_
+
+// Includes
+#include <FBaseRt_Event.h>
+
+namespace Tizen { namespace Messaging
+{
+
+//
+// @class _EmailEvent
+// @brief This class provides the event for Email message.
+// @since 1.0
+//
+// @see IEmailEventListener, EmailEventArg
+//
+
+class _EmailEvent
+ : public Tizen::Base::Runtime::_Event
+{
+ // Life cycle
+public:
+ /**
+ * This is the constructor.
+ *
+ */
+ _EmailEvent(void);
+
+ /**
+ * This is the class destructor.
+ *
+ */
+ virtual ~_EmailEvent(void) {};
+
+ /**
+ * Initializes a new instance of the class
+ *
+ */
+ result Construct(void);
+
+ //Operations
+protected:
+ void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+ // Lifecycle
+private:
+ _EmailEvent(const _EmailEvent& emailEvent);
+ _EmailEvent& operator =(const _EmailEvent& value);
+}; // _EmailEvent
+
+} }
+
+#endif // _FMSG_INTERNAL_EMAIL_EVENT_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_EmailEventArg.cpp
+ * @brief This is the implementation file for the %_EmailEventArg class.
+ *
+ * This file contains the implementation of the %_EmailEventArg class.
+ */
+
+#include <FBaseErrorDefine.h>
+#include "FMsg_EmailEventArg.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Messaging
+{
+
+_EmailEventArg::_EmailEventArg(void)
+{
+ __result = E_SUCCESS;
+}
+
+_EmailEventArg::_EmailEventArg(result r)
+{
+ if (IsFailed(r))
+ {
+ __result = E_FAILURE;
+ }
+ else
+ {
+ __result = r; // E_SUCCESS
+ }
+}
+
+void
+_EmailEventArg::GetErrorResult(result& r) const
+{
+ r = __result;
+}
+
+} }
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_EmailEventArg.h
+ * @brief This is the header file for _EmailEventArg class.
+ *
+ * This header file contains the declarations of _EmailEventArg class.
+ */
+
+
+#ifndef _FMSG_INTERNAL_EMAIL_EVENT_ARG_H_
+#define _FMSG_INTERNAL_EMAIL_EVENT_ARG_H_
+
+// Includes
+#include <FBaseObject.h>
+#include <FBaseDataType.h>
+#include <FBaseRtIEventArg.h>
+
+namespace Tizen { namespace Messaging
+{
+
+//
+// @class _EmailEventArg
+// @brief This class provides methods for getting data from Email event
+// @since 1.0
+//
+
+class _EmailEventArg
+ : public Tizen::Base::Object
+ , public Tizen::Base::Runtime::IEventArg
+{
+ // Life cycle
+public:
+ /**
+ * This is the constructor.
+ *
+ */
+ _EmailEventArg(void);
+
+ /**
+ * This is the constructor.
+ *
+ * @param[in] r - the message composer result
+ *
+ */
+ _EmailEventArg(result r);
+
+ /**
+ * This is class destructor.
+ *
+ */
+ virtual ~_EmailEventArg(void) {};
+
+ // Access
+public:
+ /**
+ * Gets the error result of Email event
+ *
+ * @param[out] r - the message composer result
+ * @exception E_SUCCESS - operation is successful
+ * @exception E_OUT_OF_MEMORY - failed to allocate required/requested memory
+ * @exception E_SYSTEM - the system has an error.
+ */
+ void GetErrorResult(result& r) const;
+
+ // Lifecycle
+private:
+ _EmailEventArg(const _EmailEventArg& emailEventArg);
+ _EmailEventArg& operator =(const _EmailEventArg& value);
+
+private:
+ result __result;
+}; // _EmailEventArg
+} }
+
+#endif // _FMSG_INTERNAL_EMAIL_EVENT_ARG_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_EmailManagerImpl.cpp
+ * @brief This is the implementation file for the %_EmailManagerImpl class.
+ *
+ * This file contains the implementation of the %_EmailManagerImpl class.
+ */
+
+#include <messages.h>
+#include <email.h>
+#include <FMsgEmailMessage.h>
+#include <FMsgEmailManager.h>
+#include <FMsgRecipientList.h>
+#include <FMsgIEmailListener.h>
+#include <FBaseSysLog.h>
+#include "FMsg_EmailEvent.h"
+#include "FMsg_EmailEventArg.h"
+#include "FMsg_EmailManagerImpl.h"
+#include "FMsg_Types.h"
+#include "FMsg_MsgUtil.h"
+#include "FMsg_RecipientListImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Messaging
+{
+
+_EmailManagerImpl::_EmailManagerImpl(void)
+ : __pEmailEvent(null)
+ , __isConstructed(false)
+{
+}
+
+_EmailManagerImpl::~_EmailManagerImpl(void)
+{
+ __isConstructed = false;
+}
+
+result
+_EmailManagerImpl::Construct(IEmailListener& listener)
+{
+ SysAssertf(__isConstructed == false, "_EmailManagerImpl instance is already constructed.");
+
+ result r = E_SUCCESS;
+
+ // set event
+ unique_ptr<_EmailEvent> pEmailEvent(new (std::nothrow) _EmailEvent());
+ SysTryReturn(NID_MSG, pEmailEvent != null, E_OUT_OF_MEMORY, r = E_OUT_OF_MEMORY, "memory allocation failed");
+
+ // event construction
+ r = pEmailEvent->Construct();
+ SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to construct an instance");
+
+ // add listener
+ r = pEmailEvent->AddListener(listener, true);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to add a listener");
+
+ __pEmailEvent = move(pEmailEvent);
+ __isConstructed = true;
+
+ return r;
+}
+
+void
+_EmailManagerImpl::SentEmailStatusCallback(email_h emailHandle, email_sending_e status, void* pData)
+{
+ result r = E_SUCCESS;
+
+ switch (status)
+ {
+ case EMAIL_SENDING_FAILED:
+ {
+ r = E_FAILURE;
+ _EmailEvent* pEmailEvent = static_cast <_EmailEvent*>(pData);
+ _EmailEventArg* pEmailEventArg = null;
+
+ if (pEmailEvent)
+ {
+ pEmailEventArg = new (std::nothrow) _EmailEventArg(r);
+ if (pEmailEventArg)
+ {
+ pEmailEvent->Fire(*pEmailEventArg);
+ }
+ }
+ }
+ break;
+
+ case EMAIL_SENDING_SUCCEEDED:
+ {
+ r = E_SUCCESS;
+ _EmailEvent* pEmailEvent = static_cast <_EmailEvent*>(pData);
+ _EmailEventArg* pEmailEventArg = null;
+
+ if (pEmailEvent)
+ {
+ pEmailEventArg = new (std::nothrow) _EmailEventArg(r);
+ if (pEmailEventArg)
+ {
+ pEmailEvent->Fire(*pEmailEventArg);
+ }
+ }
+ }
+ break;
+
+ default:
+ r = E_FAILURE;
+ break;
+ }
+}
+
+result
+_EmailManagerImpl::Send(const EmailMessage& message, const RecipientList& recipientList, bool saveToSentBox)
+{
+ result r = E_SUCCESS;
+ int err = EMAIL_ERROR_NONE;
+ email_h emailMsg = {0};
+
+
+ SysAssertf(__isConstructed == true, "_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));
+
+ 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));
+
+ 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);
+
+ SysLog(NID_MSG, "sending an email message success");
+ return r;
+
+CATCH:
+
+ email_destroy_message(emailMsg);
+ return r;
+}
+
+_EmailManagerImpl*
+_EmailManagerImpl::GetInstance(EmailManager& emailManager)
+{
+ return emailManager.__pImpl;
+}
+
+const _EmailManagerImpl*
+_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
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_EmailManagerImpl.h
+ * @brief This is the header file for _EmailManagerImpl class.
+ *
+ * This header file contains the declarations of _EmailManagerImpl class.
+ */
+
+
+#ifndef _FMSG_INTERNAL_EMAIL_MANAGER_IMPL_H_
+#define _FMSG_INTERNAL_EMAIL_MANAGER_IMPL_H_
+
+#include "FMsg_Types.h"
+
+namespace Tizen { namespace Messaging
+{
+// forward declaration
+class EmailManager;
+class IEmailListener;
+class EmailMessage;
+class RecipientList;
+class _EmailEvent;
+
+/**
+* @class _EmailManagerImpl
+* @brief This class provides methods to use the email messaging service.
+* @since 1.0
+*
+* This class provides methods to use the email messaging service. @n
+*
+* The sample code below demonstrates how to send an email message.
+*/
+class _EmailManagerImpl
+ : public Tizen::Base::Object
+{
+ // Life cycle
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 1.0
+ */
+ _EmailManagerImpl(void);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 1.0
+ */
+ virtual ~_EmailManagerImpl(void);
+
+private:
+ _EmailManagerImpl(const _EmailManagerImpl& value);
+ _EmailManagerImpl& operator =(const _EmailManagerImpl& rhs);
+
+ // Operation
+public:
+ /**
+ * Initializes this instance of _EmailManagerImpl with the specified listener.
+ *
+ * @since 1.0
+ * @return An error code
+ * @param[in] listener The listener to receive a send result asynchronously
+ * @exception E_SUCCESS The method was successful.
+ */
+ result Construct(IEmailListener& listener);
+
+ /**
+ * Sends the email message.
+ *
+ * @since 1.0
+ * @privlevel SYSTEM
+ * @privgroup http://tizen.org/privilege/messaging.email
+ *
+ * @return An error code
+ * @param[in] message The message to be sent
+ * @param[in] recipientList The list of recipients
+ * @param[in] saveToSentBox Set to @c true to save the message in the Sentbox, @n
+ * else @c false
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_ON_INITIALIZING The mailbox is not completely loaded yet.
+ * @exception E_STORAGE_FULL The storage is full.
+ * @exception E_DEVICE_UNAVAILABLE The device is unavailable.
+ * @exception E_NETWORK_UNAVAILABLE The network is unavailable.
+ * @exception E_INVALID_ACCOUNT The account is not set.
+ * @exception E_INVALID_CONDITION The profile is not set.
+ * @exception E_INVALID_ADDRESS The address is invalid.
+ * @exception E_FDN_MODE The FDN mode has been activated.
+ * @exception E_INVALID_ARG The number of recipients is @c 0.
+ * @exception E_MAX_EXCEEDED The number of recipients crossed the limit (Maximum 20).
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @remarks The value of the flag, @c saveToSentbox, is fixed to @c false in the emulator.
+ * @see IEmailListener::OnEmailMessageSent()
+ */
+ result Send(const EmailMessage& message, const RecipientList& recipientList, bool saveToSentBox);
+
+public:
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _EmailManagerImpl
+ * @param[in] emailManager An instance of EmailManager
+ */
+ static _EmailManagerImpl* GetInstance(EmailManager& emailManager);
+
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _EmailManagerImpl
+ * @param[in] emailManager An instance of EmailManager
+ */
+ 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..
+ *
+ */
+ static void SentEmailStatusCallback(email_h emailHandle, email_sending_e status, void* pData);
+
+ /**
+ * 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;
+}; // _EmailManagerImpl
+} } // Tizen::Messaging
+
+#endif // _FMSG_INTERNAL_EMAIL_MANAGER_IMPL_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_EmailMessageImpl.cpp
+ * @brief This is the implementation file for the %_EmailMessageImpl class.
+ *
+ * This file contains the implementation of the %_EmailMessageImpl class.
+ */
+
+#include <limits.h>
+#include <messages.h>
+#include <email.h>
+#include <FIoFile.h>
+#include <FBaseSysLog.h>
+#include <FMsgEmailMessage.h>
+#include "FMsg_MsgUtil.h"
+#include "FMsg_EmailMessageImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Messaging;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Messaging
+{
+
+_EmailMessageImpl::_EmailMessageImpl(void)
+ : __pAttachmentList(null)
+ , __totalFileSize(0)
+{
+}
+
+_EmailMessageImpl::_EmailMessageImpl(const _EmailMessageImpl& value)
+{
+ int count = 0;
+ String* pTemp = null;
+
+ __subject = value.__subject;
+ __text = value.__text;
+ __totalFileSize = value.__totalFileSize;
+ __pAttachmentList = null;
+
+ if (value.__pAttachmentList)
+ {
+ __pAttachmentList = new (std::nothrow) ArrayList();
+ SysTryReturnVoidResult(NID_MSG, __pAttachmentList != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+
+ __pAttachmentList->Construct();
+ count = value.__pAttachmentList->GetCount();
+ for (int index = 0; index < count; index++)
+ {
+ pTemp = static_cast <String*>(value.__pAttachmentList->GetAt(index));
+ String* pFilePath = new (std::nothrow) String(*pTemp);
+ if (!pFilePath)
+ {
+ SysLogException(NID_MSG, E_OUT_OF_MEMORY, "memory allocation failed.");
+ __pAttachmentList->RemoveAll(true);
+ delete __pAttachmentList;
+ __pAttachmentList = null;
+ SetLastResult(E_OUT_OF_MEMORY);
+ return;
+ }
+ __pAttachmentList->Add(*pFilePath);
+ }
+ }
+}
+
+_EmailMessageImpl::~_EmailMessageImpl(void)
+{
+ if (__pAttachmentList)
+ {
+ __pAttachmentList->RemoveAll(true); // if true, deallocate object
+ delete __pAttachmentList;
+ __pAttachmentList = null;
+ }
+ __totalFileSize = 0;
+}
+
+_EmailMessageImpl&
+_EmailMessageImpl::operator =(const _EmailMessageImpl& rhs)
+{
+ if (this != &rhs)
+ {
+ int count = 0;
+ String* pTemp = null;
+
+ __subject = rhs.__subject;
+ __text = rhs.__text;
+ __totalFileSize = rhs.__totalFileSize;
+ if (__pAttachmentList)
+ {
+ if (__pAttachmentList->GetCount() > 0)
+ {
+ __pAttachmentList->RemoveAll(true);
+ }
+ delete __pAttachmentList;
+ __pAttachmentList = null;
+ }
+
+
+ if (rhs.__pAttachmentList)
+ {
+ __pAttachmentList = new (std::nothrow) ArrayList();
+ if (!__pAttachmentList)
+ {
+ SysLogException(NID_MSG, E_OUT_OF_MEMORY, "memory allocation failed.");
+ SetLastResult(E_OUT_OF_MEMORY);
+ return (*this);
+ }
+
+ __pAttachmentList->Construct();
+ count = rhs.__pAttachmentList->GetCount();
+ for (int index = 0; index < count; index++)
+ {
+ pTemp = static_cast <String*>(rhs.__pAttachmentList->GetAt(index));
+ String* pFilePath = new (std::nothrow) String(*pTemp);
+ if (!pFilePath)
+ {
+ SysLogException(NID_MSG, E_OUT_OF_MEMORY, "memory allocation failed.");
+ __pAttachmentList->RemoveAll(true);
+ delete __pAttachmentList;
+ __pAttachmentList = null;
+ SetLastResult(E_OUT_OF_MEMORY);
+ return (*this);
+ }
+ __pAttachmentList->Add(*pFilePath);
+ }
+ }
+ }
+
+ return (*this);
+}
+
+bool
+_EmailMessageImpl::Equals(const Tizen::Base::Object& value) const
+{
+ const _EmailMessageImpl* pEmailMessageImpl = dynamic_cast<const _EmailMessageImpl*>(&value);
+ if (!pEmailMessageImpl)
+ {
+ SysLog(NID_MSG, "dynamic_cast is failed");
+ return false;
+ }
+
+ // subject
+ if (__subject != pEmailMessageImpl->__subject)
+ {
+ return false;
+ }
+
+ // text
+ if (__text != __text)
+ {
+ return false;
+ }
+
+ // attachment list
+ if (__pAttachmentList)
+ {
+ if (!__pAttachmentList->Equals(*(pEmailMessageImpl->__pAttachmentList)))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (pEmailMessageImpl->__pAttachmentList)
+ {
+ return false;
+ }
+ }
+
+ // total file size
+ if (__totalFileSize != pEmailMessageImpl->__totalFileSize)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+int
+_EmailMessageImpl::GetHashCode(void) const
+{
+ int hash = 0;
+
+ hash = __subject.GetHashCode() + __text.GetHashCode() + __totalFileSize;
+ if (__pAttachmentList)
+ {
+ hash += __pAttachmentList->GetHashCode();
+ }
+
+ return hash;
+}
+
+result
+_EmailMessageImpl::SetSubject(const String& subject)
+{
+ result r = E_SUCCESS;
+
+ if ((subject.GetLength() * 2 + __totalFileSize) > MAX_EMAIL_FILE_SIZE)
+ {
+ SysLogException(NID_MSG, E_MAX_EXCEEDED, "Unable to add file. The total size exceeds the limit.");
+ r = E_MAX_EXCEEDED;
+ goto CATCH;
+ }
+
+ __totalFileSize += subject.GetLength() * 2;
+ __subject = subject;
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+String
+_EmailMessageImpl::GetSubject(void) const
+{
+ return __subject;
+}
+
+result
+_EmailMessageImpl::SetText(const String& text)
+{
+ result r = E_SUCCESS;
+
+ if ((text.GetLength() * 2 + __totalFileSize) > MAX_EMAIL_FILE_SIZE)
+ {
+ SysLogException(NID_MSG, E_MAX_EXCEEDED, "Unable to add file. The total size exceeds the limit.");
+ r = E_MAX_EXCEEDED;
+ goto CATCH;
+ }
+
+ __totalFileSize += text.GetLength() * 2;
+ __text = text;
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+String
+_EmailMessageImpl::GetText(void) const
+{
+ return __text;
+}
+
+result
+_EmailMessageImpl::AddAttachment(const String& filePath)
+{
+ result r = E_SUCCESS;
+ long fileSize = 0L;
+ FileAttributes fileAttributes;
+ String* pItem = null;
+ String* pFilePath = null;
+ int index = 0;
+ int count = 0;
+
+ // get max value of attachments
+ if (__pAttachmentList)
+ {
+ count = __pAttachmentList->GetCount();
+ if (count >= MAX_EMAIL_ATTACHMENT_COUNT)
+ {
+ SysLogException(NID_MSG, E_MAX_EXCEEDED, "The number of attachments exceeds the limit.");
+ r = E_MAX_EXCEEDED;
+ goto CATCH;
+ }
+ }
+
+ // check there is a same file
+ for (index = 0; index < count; index++)
+ {
+ pItem = static_cast <String*>(__pAttachmentList->GetAt(index));
+ if (pItem->Equals(filePath))
+ {
+ SysLogException(NID_MSG, E_FILE_ALREADY_EXIST, "[E_FILE_ALREADY_EXIST] The file is already attached.");
+ r = E_FILE_ALREADY_EXIST;
+ goto CATCH;
+ }
+ }
+
+ // get file attributes
+ r = File::GetAttributes(filePath, fileAttributes);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to get the file attributes.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ // get file size
+ fileSize = (long) fileAttributes.GetFileSize();
+ if ((fileSize + __totalFileSize) > MAX_EMAIL_FILE_SIZE)
+ {
+ r = E_MAX_EXCEEDED;
+ SysLogException(NID_MSG, E_MAX_EXCEEDED, "Unable to add file. The file size exceeds the limit.");
+ goto CATCH;
+ }
+ __totalFileSize += fileSize;
+
+ // Construct attachment list
+ if (!__pAttachmentList)
+ {
+ __pAttachmentList = new (std::nothrow) ArrayList();
+ if (!__pAttachmentList)
+ {
+ r = E_OUT_OF_MEMORY;
+ SysLogException(NID_MSG, E_OUT_OF_MEMORY, "memory allocation failed.");
+ goto CATCH;
+ }
+ r = __pAttachmentList->Construct();
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to construct an ArrayList.", GetErrorMessage(r));
+ delete __pAttachmentList;
+ __pAttachmentList = null;
+ goto CATCH;
+ }
+ }
+
+ // add file
+ pFilePath = new (std::nothrow) String(filePath);
+ if (!pFilePath)
+ {
+ r = E_OUT_OF_MEMORY;
+ SysLogException(NID_MSG, r, "memory allocation failed.");
+ goto CATCH;
+ }
+
+ r = __pAttachmentList->Add(*pFilePath);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to add file.", GetErrorMessage(r));
+ delete pFilePath;
+ pFilePath = null;
+ goto CATCH;
+ }
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+result
+_EmailMessageImpl::RemoveAttachment(const Tizen::Base::String& filePath)
+{
+ SysTryReturnResult(NID_MSG, filePath.GetLength() > 0, E_INVALID_ARG, "[E_INVALID_ARG] The file path is empty.");
+ SysTryReturnResult(NID_MSG, filePath.GetLength() <= PATH_MAX, E_INVALID_ARG, "[E_INVALID_ARG] The file path is too long.");
+
+ result r = E_SUCCESS;
+ long fileSize = 0L;
+ FileAttributes fileAttributes;
+ String* pItem = null;
+ int index = 0;
+
+ // get there is attachment file
+ if (!__pAttachmentList)
+ {
+ SysLogException(NID_MSG, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] There is no attached file. So cannot remove such file.");
+ r = E_FILE_NOT_FOUND;
+ goto CATCH;
+ }
+
+ // get there is attachment file
+ if (__pAttachmentList->GetCount() == 0)
+ {
+ SysLogException(NID_MSG, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] There is no attached file. So cannot remove such file.");
+ r = E_FILE_NOT_FOUND;
+ goto CATCH;
+ }
+
+ // check file existence
+ if (File::IsFileExist(filePath) == false)
+ {
+ SysLogException(NID_MSG, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] File not exist.");
+ r = E_FILE_NOT_FOUND;
+ goto CATCH;
+ }
+
+ // get file attributes
+ r = File::GetAttributes(filePath, fileAttributes);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to get the file attributes.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ // get file size
+ fileSize = (long) fileAttributes.GetFileSize();
+
+ // find the file
+ for (index = 0; index < __pAttachmentList->GetCount(); index++)
+ {
+ pItem = static_cast <String*>(__pAttachmentList->GetAt(index));
+ if (pItem->Equals(filePath))
+ {
+ r = __pAttachmentList->RemoveAt(index, true);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to remove file from the list.", GetErrorMessage(r));
+ goto CATCH;
+ }
+ // decrease the total file size
+ __totalFileSize -= fileSize;
+ break;
+ }
+ }
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+IList*
+_EmailMessageImpl::GetAttachmentListN(void) const
+{
+ result r = E_SUCCESS;
+ ArrayList* pAttachmentList = null;
+ int count = 0;
+ String* pItem = null;
+ String* pElement = null;
+
+ ClearLastResult();
+
+ pAttachmentList = new (std::nothrow) ArrayList();
+ if (!pAttachmentList)
+ {
+ SysLogException(NID_MSG, E_OUT_OF_MEMORY, "memory allocation failed.");
+ SetLastResult(E_OUT_OF_MEMORY);
+ goto CATCH;
+ }
+ r = pAttachmentList->Construct();
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to construct an ArrayList.", GetErrorMessage(r));
+ SetLastResult(r);
+ goto CATCH;
+ }
+
+ // there is no attachment
+ if (!__pAttachmentList)
+ {
+ SysLog(NID_MSG, "There is no attachment.");
+ // return null
+ return pAttachmentList;
+ }
+
+ // get total count of attached files
+ count = __pAttachmentList->GetCount();
+
+ // abnormal.. but anyway.. there is no attachment
+ if (count == 0)
+ {
+ SysLog(NID_MSG, "There is no attachment.");
+ return pAttachmentList;
+ }
+
+
+ for (int index = 0; index < count; index++)
+ {
+ pItem = static_cast <String*>(__pAttachmentList->GetAt(index));
+ if (!pItem)
+ {
+ SysLog(NID_MSG, "Failed to get a file from ArrayList");
+ SetLastResult(GetLastResult());
+ goto CATCH;
+ }
+
+ // make an element
+ pElement = new (std::nothrow) String(*pItem);
+ if (!pElement)
+ {
+ r = E_OUT_OF_MEMORY;
+ SysLogException(NID_MSG, r, "memory allocation failed.");
+ goto CATCH;
+ }
+
+ // add a element to a new list
+ r = pAttachmentList->Add(*pElement);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to add item to the list.", GetErrorMessage(r));
+ SetLastResult(r);
+ goto CATCH;
+ }
+ }
+
+ return pAttachmentList;
+
+CATCH:
+ if (pAttachmentList)
+ {
+ if (pAttachmentList->GetCount() > 0)
+ {
+ pAttachmentList->RemoveAll(true);
+ }
+ delete pAttachmentList;
+ pAttachmentList = null;
+ }
+ if (pElement)
+ {
+ delete pElement;
+ pElement = null;
+ }
+
+ return null;
+}
+
+_EmailMessageImpl*
+_EmailMessageImpl::GetInstance(EmailMessage& emailMessage)
+{
+ return emailMessage.__pImpl;
+}
+
+const _EmailMessageImpl*
+_EmailMessageImpl::GetInstance(const EmailMessage& emailMessage)
+{
+ return emailMessage.__pImpl;
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_EmailMessageImpl.h
+ * @brief This is the header file for _EmailMessageImpl class.
+ *
+ * This header file contains the declarations of _EmailMessageImpl class.
+ */
+
+
+#ifndef _FMSG_INTERNAL_EMAIL_MESSAGE_IMPL_H_
+#define _FMSG_INTERNAL_EMAIL_MESSAGE_IMPL_H_
+
+#include <FBaseObject.h>
+#include <FBaseColArrayList.h>
+
+namespace Tizen { namespace Messaging
+{
+// forward declaration
+class EmailMessage;
+
+/**
+* @class _EmailMessageImpl
+* @brief This class provides methods for handling email messages.
+* @since 1.0
+*
+* This class provides methods for handling email messages. @n
+* A user can set and get the subject and body text of an email, @n
+* and can also add, remove, and receive attachments.
+*/
+class _EmailMessageImpl
+ : public Tizen::Base::Object
+{
+ // Life cycle
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 1.0
+ */
+ _EmailMessageImpl(void);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 1.0
+ */
+ virtual ~_EmailMessageImpl(void);
+
+ /**
+ * This is the copy constructor for this class.
+ *
+ * @since 1.0
+ * @param[in] value An instance of _EmailMessageImpl
+ */
+ _EmailMessageImpl(const _EmailMessageImpl& value);
+
+public:
+ /**
+ * This assignment operator copies email message from the specified instance of _EmailMessageImpl to the calling instance of _EmailMessageImpl.
+ *
+ * @since 1.0
+ * @return The reference of this instance
+ * @param[in] rhs A reference to the _EmailMessageImpl instance to be copied
+ */
+ _EmailMessageImpl& operator =(const _EmailMessageImpl& rhs);
+
+public:
+ /**
+ * Gets the hash value of the current instance.
+ *
+ * @since 1.0
+ * @return The hash value of the current instance
+ * @remarks Two equal instances should return the same hash value. For better performance,
+ * the used hash function must generate a random distribution for all inputs.
+ */
+ virtual int GetHashCode(void) const;
+
+ /**
+ * Compares the specified instance with the calling instance.
+ *
+ * @since 1.0
+ * @return @c true if both instances are equal @n
+ * @c false, otherwise
+ * @param[in] value An instance of _EmailMessageImpl
+ */
+ virtual bool Equals(const Tizen::Base::Object& value) const;
+
+ // Operation
+public:
+ /**
+ * Sets the subject of the email.
+ *
+ * @since 1.0
+ * @return An error code
+ * @param[in] subject The subject of the message
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_MAX_EXCEEDED The subject length of the message is exceeding the maximum limit (Maximum 256 characters). @n
+ * The total size of the subject, body, and attachment(s) is exceeding the maximum limit (5MB).
+ * @see GetSubject()
+ */
+ result SetSubject(const Tizen::Base::String& subject);
+
+ /**
+ * Sets the body of the message.
+ *
+ * @since 1.0
+ * @return An error code
+ * @param[in] text The body text of the message
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_MAX_EXCEEDED The body length of the message is exceeding the maximum limit (Maximum 2000 characters). @n
+ * The total size of the subject, body, and attachment(s) is exceeding the maximum limit (5MB).
+ * @see GetText()
+ */
+ result SetText(const Tizen::Base::String& text);
+
+ /**
+ * Adds a file attachment to the email.
+ *
+ * @since 1.0
+ * @return An error code
+ * @param[in] filePath The path of the file to attach
+ * @exception E_SUCCESS The method was 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 could not be found or accessed.
+ * @exception E_FILE_ALREADY_EXIST The file is already attached.
+ * @exception E_MAX_EXCEEDED Attachment is constrained to a maximum of 5MB and 20 files. @n
+ * The total size of the subject, body, and attachment(s) is exceeding the maximum limit (5MB).
+ * @see GetAttachmentListN()
+ */
+ result AddAttachment(const Tizen::Base::String& filePath);
+
+ /**
+ * Removes an attachment from an email.
+ *
+ * @since 1.0
+ * @return An error code
+ * @param[in] filePath The path of the file to remove
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_FILE_NOT_FOUND The corresponding format file was not found.
+ * @see AddAttachment(), GetAttachmentListN()
+ */
+ result RemoveAttachment(const Tizen::Base::String& filePath);
+
+ /**
+ * Gets the subject of the message.
+ *
+ * @since 1.0
+ * @return The subject of the message
+ * @see SetSubject()
+ */
+ Tizen::Base::String GetSubject(void) const;
+
+ /**
+ * Gets the body text of the message.
+ *
+ * @since 1.0
+ * @return The body text of the message
+ * @see SetText()
+ */
+ Tizen::Base::String GetText(void) const;
+
+ /**
+ * Gets the list of attachments for the email.
+ *
+ * @since 1.0
+ * @return The list of the attached files
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_OUT_OF_MEMORY Insufficient memory.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @see AddAttachment()
+ */
+ Tizen::Base::Collection::IList* GetAttachmentListN(void) const;
+
+public:
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _EmailMessageImpl
+ * @param[in] emailMessage An instance of EmailMessage
+ */
+ static _EmailMessageImpl* GetInstance(EmailMessage& emailMessage);
+
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _EmailMessageImpl
+ * @param[in] emailMessage An instance of EmailMessage
+ */
+ static const _EmailMessageImpl* GetInstance(const EmailMessage& emailMessage);
+
+private:
+ Tizen::Base::String __subject;
+ Tizen::Base::String __text;
+ Tizen::Base::Collection::ArrayList* __pAttachmentList;
+ long __totalFileSize;
+}; // _EmailMessageImpl
+} } // Tizen::Messaging
+
+#endif // _FMSG_INTERNAL_EMAIL_MESSAGE_IMPL_H_
--- /dev/null
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+/**\r
+ * @file FMsg_EtwsPrimaryNotificationImpl.cpp\r
+ * @brief This is the implementation file for the %_EtwsPrimaryNotificationImpl class.\r
+ *\r
+ * This file contains the implementation of the %_EtwsPrimaryNotificationImpl class.\r
+ */\r
+\r
+#include <messages.h>\r
+#include <FMsgEtwsPrimaryNotification.h>\r
+#include <FBaseSysLog.h>\r
+#include <FSec_AccessController.h>\r
+#include "FMsg_Types.h"\r
+#include "FMsg_EtwsPrimaryNotificationImpl.h"\r
+\r
+using namespace Tizen::Base;\r
+using namespace Tizen::Messaging;\r
+using namespace Tizen::Security;\r
+\r
+namespace Tizen { namespace Messaging\r
+{\r
+\r
+_EtwsPrimaryNotificationImpl::_EtwsPrimaryNotificationImpl(void)\r
+ : __etwsMsgTime()\r
+ , __pEtwsSerialNumber(null)\r
+ , __pEtwsSecurityInfo(null)\r
+ , __etwsMessageId(0)\r
+ , __pEtwsWarningType(null)\r
+{\r
+ __pEtwsSerialNumber = new (std::nothrow) ByteBuffer();\r
+ SysTryReturnVoidResult(NID_MSG, __pEtwsSerialNumber != null, E_OUT_OF_MEMORY, "memory allocation failed");\r
+ __pEtwsSerialNumber->Construct(0);\r
+ __pEtwsSerialNumber->SetPosition(0);\r
+\r
+ __pEtwsSecurityInfo = new (std::nothrow) ByteBuffer();\r
+ SysTryReturnVoidResult(NID_MSG, __pEtwsSecurityInfo != null, E_OUT_OF_MEMORY, "memory allocation failed");\r
+ __pEtwsSecurityInfo->Construct(0);\r
+ __pEtwsSecurityInfo->SetPosition(0);\r
+\r
+ __pEtwsWarningType = new (std::nothrow) ByteBuffer();\r
+ SysTryReturnVoidResult(NID_MSG, __pEtwsWarningType != null, E_OUT_OF_MEMORY, "memory allocation failed");\r
+ __pEtwsWarningType->Construct(0);\r
+ __pEtwsWarningType->SetPosition(0);\r
+}\r
+\r
+_EtwsPrimaryNotificationImpl::_EtwsPrimaryNotificationImpl(const _EtwsPrimaryNotificationImpl& value)\r
+{\r
+ __etwsMsgTime = value.__etwsMsgTime;\r
+ __etwsMessageId = value.__etwsMessageId;\r
+\r
+ __pEtwsSerialNumber->SetArray(value.__pEtwsSerialNumber->GetPointer(), 0, value.__pEtwsSerialNumber->GetLimit());\r
+ __pEtwsSerialNumber->SetPosition(0);\r
+\r
+ __pEtwsSecurityInfo->SetArray(value.__pEtwsSecurityInfo->GetPointer(), 0, value.__pEtwsSecurityInfo->GetLimit());\r
+ __pEtwsSecurityInfo->SetPosition(0);\r
+\r
+ __pEtwsWarningType->SetArray(value.__pEtwsWarningType->GetPointer(), 0, value.__pEtwsWarningType->GetLimit());\r
+ __pEtwsWarningType->SetPosition(0);\r
+}\r
+\r
+result\r
+_EtwsPrimaryNotificationImpl::SetEtwsMessageImpl(const Tizen::Base::DateTime& dateTime, const Tizen::Base::ByteBuffer& etwsSerialNumber, const Tizen::Base::ByteBuffer&\r
+ etwsSecurityInfo, int etwsMessageId, const Tizen::Base::ByteBuffer& etwsWarningType)\r
+{\r
+ result r = E_SUCCESS;\r
+\r
+ __etwsMsgTime = dateTime;\r
+ __etwsMessageId = etwsMessageId;\r
+\r
+ __pEtwsSerialNumber = new (std::nothrow) ByteBuffer();\r
+ SysTryReturn(NID_MSG, __pEtwsSerialNumber != null, E_OUT_OF_MEMORY, r = E_OUT_OF_MEMORY, "memory allocation failed");\r
+ r = __pEtwsSerialNumber->Construct(etwsSerialNumber);\r
+ r = __pEtwsSerialNumber->SetPosition(0);\r
+\r
+ __pEtwsSecurityInfo = new (std::nothrow) ByteBuffer();\r
+ SysTryCatch(NID_MSG, __pEtwsSecurityInfo != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");\r
+ r = __pEtwsSecurityInfo->Construct(etwsSecurityInfo);\r
+ r = __pEtwsSecurityInfo->SetPosition(0);\r
+\r
+ __pEtwsWarningType = new (std::nothrow) ByteBuffer();\r
+ SysTryCatch(NID_MSG, __pEtwsWarningType != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");\r
+ r = __pEtwsWarningType->Construct(etwsWarningType);\r
+ r = __pEtwsWarningType->SetPosition(0);\r
+\r
+ return r;\r
+\r
+CATCH:\r
+ SetLastResult(GetLastResult());\r
+ if (__pEtwsSerialNumber)\r
+ {\r
+ delete __pEtwsSerialNumber;\r
+ __pEtwsSerialNumber = null;\r
+ }\r
+\r
+ if (__pEtwsSecurityInfo)\r
+ {\r
+ delete __pEtwsSecurityInfo;\r
+ __pEtwsSecurityInfo = null;\r
+ }\r
+ return r;\r
+}\r
+\r
+_EtwsPrimaryNotificationImpl::~_EtwsPrimaryNotificationImpl(void)\r
+{\r
+ if (__pEtwsSerialNumber)\r
+ {\r
+ delete __pEtwsSerialNumber;\r
+ __pEtwsSerialNumber = null;\r
+ }\r
+\r
+ if (__pEtwsSecurityInfo)\r
+ {\r
+ delete __pEtwsSecurityInfo;\r
+ __pEtwsSecurityInfo = null;\r
+ }\r
+\r
+ if (__pEtwsWarningType)\r
+ {\r
+ delete __pEtwsWarningType;\r
+ __pEtwsWarningType = null;\r
+ }\r
+}\r
+\r
+_EtwsPrimaryNotificationImpl&\r
+_EtwsPrimaryNotificationImpl::operator =(const _EtwsPrimaryNotificationImpl& rhs)\r
+{\r
+ if (this != &rhs)\r
+ {\r
+ __etwsMsgTime = rhs.__etwsMsgTime;\r
+ __etwsMessageId = rhs.__etwsMessageId;\r
+\r
+ __pEtwsSerialNumber->SetArray(rhs.__pEtwsSerialNumber->GetPointer(), 0, rhs.__pEtwsSerialNumber->GetLimit());\r
+ __pEtwsSerialNumber->SetPosition(0);\r
+\r
+ __pEtwsSecurityInfo->SetArray(rhs.__pEtwsSecurityInfo->GetPointer(), 0, rhs.__pEtwsSecurityInfo->GetLimit());\r
+ __pEtwsSecurityInfo->SetPosition(0);\r
+\r
+ __pEtwsWarningType->SetArray(rhs.__pEtwsWarningType->GetPointer(), 0, rhs.__pEtwsWarningType->GetLimit());\r
+ __pEtwsWarningType->SetPosition(0);\r
+ }\r
+\r
+ return (*this);\r
+}\r
+\r
+EtwsPrimaryNotification*\r
+_EtwsPrimaryNotificationImpl::CloneN() const\r
+{\r
+ EtwsPrimaryNotification* pEtwsMsg = null;\r
+ result r = E_SUCCESS;\r
+\r
+ pEtwsMsg = _EtwsPrimaryNotificationImpl::GetEtwsPrimaryNotificationN();\r
+ SysTryCatch(NID_MSG, pEtwsMsg != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");\r
+\r
+ r = _EtwsPrimaryNotificationImpl::GetInstance(*pEtwsMsg)->SetEtwsMessageImpl(__etwsMsgTime, *(__pEtwsSerialNumber), *(__pEtwsSecurityInfo), __etwsMessageId, *(__pEtwsWarningType));\r
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "etwsimpl message construct failed");\r
+\r
+ SetLastResult(GetLastResult());\r
+ return pEtwsMsg;\r
+\r
+CATCH:\r
+ SetLastResult(GetLastResult());\r
+ if (pEtwsMsg)\r
+ {\r
+ delete pEtwsMsg;\r
+ pEtwsMsg = null;\r
+ }\r
+ return null;\r
+}\r
+\r
+bool\r
+_EtwsPrimaryNotificationImpl::Equals(const Tizen::Base::Object& obj) const\r
+{\r
+ const _EtwsPrimaryNotificationImpl* pEtwsPrimaryNotificationImpl = dynamic_cast<const _EtwsPrimaryNotificationImpl*>(&obj);\r
+\r
+ if (!pEtwsPrimaryNotificationImpl)\r
+ {\r
+ SysLog(NID_MSG, "dynamic_cast is failed");\r
+ return false;\r
+ }\r
+\r
+ // sender time\r
+ if (__etwsMsgTime != pEtwsPrimaryNotificationImpl->__etwsMsgTime)\r
+ {\r
+ return false;\r
+ }\r
+\r
+ // etws serial number\r
+ if (__pEtwsSerialNumber != pEtwsPrimaryNotificationImpl->__pEtwsSerialNumber)\r
+ {\r
+ return false;\r
+ }\r
+\r
+ // etws security info\r
+ if (__pEtwsSecurityInfo != pEtwsPrimaryNotificationImpl->__pEtwsSecurityInfo)\r
+ {\r
+ return false;\r
+ }\r
+\r
+ // cbs message id\r
+ if (__etwsMessageId != pEtwsPrimaryNotificationImpl->__etwsMessageId)\r
+ {\r
+ return false;\r
+ }\r
+\r
+ // Etws warning type\r
+ if (__pEtwsWarningType != pEtwsPrimaryNotificationImpl->__pEtwsWarningType)\r
+ {\r
+ return false;\r
+ }\r
+\r
+ return true;\r
+}\r
+\r
+int\r
+_EtwsPrimaryNotificationImpl::GetHashCode(void) const\r
+{\r
+ int hash = 0;\r
+\r
+ hash = __etwsMsgTime.GetHashCode() + __pEtwsSerialNumber->GetHashCode() + __pEtwsSecurityInfo->GetHashCode() + __etwsMessageId + __pEtwsWarningType->GetHashCode();\r
+\r
+ return hash;\r
+}\r
+\r
+EtwsPrimaryNotification*\r
+_EtwsPrimaryNotificationImpl::GetEtwsPrimaryNotificationN()\r
+{\r
+ result r = E_SUCCESS;\r
+ EtwsPrimaryNotification* pEtwsMsg = null;\r
+\r
+ pEtwsMsg = new (std::nothrow) EtwsPrimaryNotification();\r
+ SysTryCatch(NID_MSG, pEtwsMsg != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");\r
+\r
+ return pEtwsMsg;\r
+\r
+CATCH:\r
+ return null;\r
+}\r
+\r
+_EtwsPrimaryNotificationImpl*\r
+_EtwsPrimaryNotificationImpl::GetInstance(EtwsPrimaryNotification& etwsMessage)\r
+{\r
+ return etwsMessage.__pEtwsPrimaryNotificationImpl;\r
+}\r
+\r
+\r
+Tizen::Base::ByteBuffer*\r
+_EtwsPrimaryNotificationImpl::GetSerialNumberN(void) const\r
+{\r
+ result r = E_SUCCESS;\r
+ Tizen::Base::ByteBuffer* pEtwsSerialNumber = null;\r
+\r
+ ClearLastResult();\r
+\r
+ pEtwsSerialNumber = new (std::nothrow) ByteBuffer();\r
+ SysTryCatch(NID_MSG, pEtwsSerialNumber != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");\r
+\r
+ r = pEtwsSerialNumber->Construct(*__pEtwsSerialNumber);\r
+ r = pEtwsSerialNumber->SetPosition(0);\r
+\r
+ SetLastResult(r);\r
+\r
+ return pEtwsSerialNumber;\r
+\r
+CATCH:\r
+ SetLastResult(r);\r
+\r
+ return null;\r
+}\r
+\r
+Tizen::Base::DateTime\r
+_EtwsPrimaryNotificationImpl::GetReceivedTime(void) const\r
+{\r
+ return __etwsMsgTime;\r
+}\r
+\r
+Tizen::Base::ByteBuffer*\r
+_EtwsPrimaryNotificationImpl::GetWarningSecurityInfoN(void) const\r
+{\r
+ result r = E_SUCCESS;\r
+ Tizen::Base::ByteBuffer* pEtwsSecurityInfo = null;\r
+\r
+ ClearLastResult();\r
+\r
+ pEtwsSecurityInfo = new (std::nothrow) ByteBuffer();\r
+ SysTryCatch(NID_MSG, pEtwsSecurityInfo != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");\r
+\r
+ r = pEtwsSecurityInfo->Construct(*__pEtwsSecurityInfo);\r
+ r = pEtwsSecurityInfo->SetPosition(0);\r
+\r
+ SetLastResult(r);\r
+\r
+ return pEtwsSecurityInfo;\r
+\r
+CATCH:\r
+ SetLastResult(r);\r
+\r
+ return null;\r
+}\r
+\r
+int\r
+_EtwsPrimaryNotificationImpl::GetMessageId(void) const\r
+{\r
+ return __etwsMessageId;\r
+}\r
+\r
+Tizen::Base::ByteBuffer*\r
+_EtwsPrimaryNotificationImpl::GetWarningTypeN(void) const\r
+{\r
+ result r = E_SUCCESS;\r
+ Tizen::Base::ByteBuffer* pEtwsWarningType = null;\r
+\r
+ ClearLastResult();\r
+\r
+ pEtwsWarningType = new (std::nothrow) ByteBuffer();\r
+ SysTryCatch(NID_MSG, pEtwsWarningType != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");\r
+\r
+ r = pEtwsWarningType->Construct(*__pEtwsWarningType);\r
+ r = pEtwsWarningType->SetPosition(0);\r
+\r
+ SetLastResult(r);\r
+\r
+ return pEtwsWarningType;\r
+\r
+CATCH:\r
+ SetLastResult(r);\r
+\r
+ return null;\r
+}\r
+\r
+} } // Tizen::Messaging\r
--- /dev/null
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+/**\r
+* @if VISPARTNER-OPERATOR\r
+*\r
+* @file FMsg_EtwsPrimaryNotificationImpl.h\r
+* @brief This is the header file for the %_EtwsPrimaryNotificationImpl class.\r
+*\r
+* @visibility partner-operator\r
+*\r
+* This header file contains the declarations of the %_EtwsPrimaryNotificationImpl class.\r
+*\r
+* @endif\r
+*/\r
+\r
+#ifndef _FMSG_INTERNAL_ETWS_PRIMARY_NOTIFICATION_IMPL_H_\r
+#define _FMSG_INTERNAL_ETWS_PRIMARY_NOTIFICATION_IMPL_H_\r
+\r
+namespace Tizen { namespace Messaging\r
+{\r
+\r
+class EtwsPrimaryNotification;\r
+\r
+/**\r
+* @if VISPARTNER-OPERATOR\r
+*\r
+* @class _EtwsPrimaryNotificationImpl\r
+*\r
+* @brief This class provides methods for handling an ETWS primary notification.\r
+*\r
+* @since 2.1\r
+*\r
+* @final This class is not intended for extension.\r
+*\r
+* @visibility partner-operator\r
+*\r
+* The %_EtwsPrimaryNotificationImpl class provides methods for handling an ETWS primary notification. It allows you to get the serial number,\r
+* message ID, warning type, warning security info, and received time of an ETWS primary notification.\r
+*\r
+* @endif\r
+*/\r
+\r
+class _EtwsPrimaryNotificationImpl\r
+ : public Tizen::Base::Object\r
+{\r
+public:\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * This destructor overrides Tizen::Base::Object::~Object().\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @endif\r
+ */\r
+ virtual ~_EtwsPrimaryNotificationImpl(void);\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Compares the specified instance of %_EtwsPrimaryNotificationImpl with the calling instance.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return @c true, if the values match @n\r
+ * @c false, otherwise\r
+ * @param[in] obj The other Object to be compared\r
+ * @see Object::Equals()\r
+ *\r
+ * @endif\r
+ */\r
+ virtual bool Equals(const Tizen::Base::Object& obj) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the copied instance of the class.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return An instance of %_EtwsPrimaryNotificationImpl\r
+ * @exception E_SUCCESS The method is successful.\r
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.\r
+ *\r
+ * @remarks In case of error, this method returns @c null. @n\r
+ * The specific error code can be accessed using the GetLastResult() method.\r
+ *\r
+ * @endif\r
+ */\r
+ EtwsPrimaryNotification* CloneN(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the hash value of the current instance.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return The current instance's hash value\r
+ *\r
+ * @endif\r
+ */\r
+ virtual int GetHashCode(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the date and time (UTC time) of the message when it is received.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return The date and time (UTC time) when the message is received\r
+ *\r
+ * @endif\r
+ */\r
+ Tizen::Base::DateTime GetReceivedTime(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the serial number of the ETWS primary notification.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return The serial number of the ETWS primary notification\r
+ * @exception E_SUCCESS The method is successful.\r
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.\r
+ * @remarks The specific error code can be accessed using the GetLastResult() method. @n\r
+ * In case of an error, this method returns null.\r
+ *\r
+ * @endif\r
+ */\r
+ Tizen::Base::ByteBuffer* GetSerialNumberN(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the message ID of the ETWS primary notification.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return The the message ID of the ETWS primary notification\r
+ *\r
+ * @endif\r
+ */\r
+ int GetMessageId(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the warning type.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return The ETWS warning type of the message\r
+ *\r
+ * @endif\r
+ */\r
+ Tizen::Base::ByteBuffer* GetWarningTypeN(void) const;\r
+\r
+ /**\r
+ * @if VISPARTNER-OPERATOR\r
+ *\r
+ * Gets the warning security information of the ETWS primary notification.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @visibility partner-operator\r
+ *\r
+ * @return The warning security information of the ETWS primary notification\r
+ * @exception E_SUCCESS The method is successful.\r
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.\r
+ * @remarks The specific error code can be accessed using the GetLastResult() method. @n\r
+ * In case of an error, this method returns null.\r
+ * @endif\r
+ */\r
+ Tizen::Base::ByteBuffer* GetWarningSecurityInfoN(void) const;\r
+\r
+public:\r
+ /**\r
+ * Gets the instance of CbsChannel\r
+ *\r
+ * @since 2.1\r
+ */\r
+ static EtwsPrimaryNotification* GetEtwsPrimaryNotificationN();\r
+\r
+ /**\r
+ * Gets the Impl instance.\r
+ *\r
+ * @since 2.1\r
+ * @return The pointer to _EtwsPrimaryNotificationImpl\r
+ * @param[in] etwsMessage An instance of EtwsPrimaryNotification\r
+ */\r
+ static _EtwsPrimaryNotificationImpl* GetInstance(EtwsPrimaryNotification& etwsMessage);\r
+\r
+public:\r
+ /**\r
+ * This default constructor is intentionally declared as private so that only the platform can create an instance.\r
+ *\r
+ * @since 2.1\r
+ */\r
+ _EtwsPrimaryNotificationImpl(void);\r
+\r
+ /**\r
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @param[in] rhs An instance of _EtwsPrimaryNotificationImpl\r
+ */\r
+ _EtwsPrimaryNotificationImpl(const _EtwsPrimaryNotificationImpl& rhs);\r
+\r
+ /**\r
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. @n\r
+ * - Use CloneN() to get an exact copy of the instance.\r
+ * - Use Equals() to compare the contents of one instance with the other.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @return A reference to this instance\r
+ * @param[in] rhs An instance of _EtwsPrimaryNotificationImpl\r
+ */\r
+ _EtwsPrimaryNotificationImpl& operator =(const _EtwsPrimaryNotificationImpl& rhs);\r
+\r
+ /**\r
+ * Initializes this instance of %_EtwsPrimaryNotificationImpl with the specified parameter.\r
+ *\r
+ * @since 2.1\r
+ *\r
+ * @param[in] dateTime The date and time (UTC time) when the message is received\r
+ * @param[in] etwsSerialNumber The etwsSerialNumber of the CBS message\r
+ * @param[in] etwsSecurityInfo The etwsSecurityInfo body text\r
+ * @param[in] etwsMessageId The etwsMessageId of the CBS message\r
+ * @param[in] etwsWarningType The Etws warning type\r
+ * @exception E_SUCCESS The method is successful.\r
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.\r
+ * @exception E_SYSTEM A system error has occurred.\r
+ */\r
+ result SetEtwsMessageImpl(const Tizen::Base::DateTime& dateTime, const Tizen::Base::ByteBuffer& etwsSerialNumber, const Tizen::Base::ByteBuffer& etwsSecurityInfo,\r
+ int etwsMessageId, const Tizen::Base::ByteBuffer& etwsWarningType);\r
+\r
+private:\r
+ Tizen::Base::DateTime __etwsMsgTime;\r
+ Tizen::Base::ByteBuffer* __pEtwsSerialNumber;\r
+ Tizen::Base::ByteBuffer* __pEtwsSecurityInfo;\r
+ int __etwsMessageId;\r
+ Tizen::Base::ByteBuffer* __pEtwsWarningType;\r
+}; // _EtwsPrimaryNotificationImpl\r
+\r
+} } // Tizen::Messaging\r
+#endif // _FMSG_INTERNAL_ETWS_PRIMARY_NOTIFICATION_IMPL_H_\r
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_MmsEvent.cpp
+ * @brief This is the implementation file for the %_MmsEvent class.
+ *
+ * This file contains the implementation of the %_MmsEvent class.
+ */
+
+#include <FMsgIMmsListener.h>
+#include <FBaseSysLog.h>
+#include "FMsg_MmsEvent.h"
+#include "FMsg_MmsEventArg.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Messaging
+{
+
+_MmsEvent::_MmsEvent(void)
+{
+}
+
+result
+_MmsEvent::Construct(void)
+{
+ return _Event::Initialize();
+}
+
+void
+_MmsEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+ result r = E_SUCCESS;
+ IMmsListener* pMmsListener = dynamic_cast <IMmsListener*>(&listener);
+ SysTryReturnVoidResult(NID_MSG, pMmsListener != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system.");
+
+ IEventArg* pEventArg = const_cast <IEventArg*>(&arg);
+ _MmsEventArg* pMmsEventArg = dynamic_cast <_MmsEventArg*>(pEventArg);
+ SysTryReturnVoidResult(NID_MSG, pMmsEventArg != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system.");
+
+ // get error result
+ pMmsEventArg->GetErrorResult(r);
+
+ // Fire
+ pMmsListener->OnMmsMessageSent(r);
+}
+
+} }
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_MmsEvent.h
+ * @brief This is the header file for _MmsEvent class.
+ *
+ * This header file contains the declarations of _MmsEvent class.
+ */
+
+
+#ifndef _FMSG_INTERNAL_MMS_EVENT_H_
+#define _FMSG_INTERNAL_MMS_EVENT_H_
+
+// Includes
+#include <FBaseRt_Event.h>
+
+namespace Tizen { namespace Messaging
+{
+
+//
+// @class _MmsEvent
+// @brief This class provides the event for MMS message.
+// @since 1.0
+//
+// @see IMmsEventListener, _MmsEventArg
+//
+
+class _MmsEvent
+ : public Tizen::Base::Runtime::_Event
+{
+// Life cycle
+public:
+ /**
+ * This is the constructor.
+ *
+ */
+ _MmsEvent(void);
+
+ /**
+ * This is the class destructor.
+ *
+ */
+ virtual ~_MmsEvent(void) {};
+
+ /**
+ * Initializes a new instance of the class
+ *
+ */
+ result Construct(void);
+
+ //Operations
+protected:
+ void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+ // Lifecycle
+private:
+ _MmsEvent(const _MmsEvent& mmsEvent);
+ _MmsEvent& operator =(const _MmsEvent& value);
+}; // _MmsEvent
+
+} }
+
+#endif // _FMSG_INTERNAL_MMS_EVENT_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_MmsEventArg.cpp
+ * @brief This is the implementation file for the %_MmsEventArg class.
+ *
+ * This file contains the implementation of the %_MmsEventArg class.
+ */
+
+#include <FBaseErrorDefine.h>
+#include "FMsg_MmsEventArg.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Messaging
+{
+
+_MmsEventArg::_MmsEventArg(void)
+{
+ __result = E_SUCCESS;
+}
+
+_MmsEventArg::_MmsEventArg(const result r)
+{
+ __result = r;
+}
+
+void
+_MmsEventArg::GetErrorResult(result& r) const
+{
+ r = __result;
+}
+
+} }
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_MmsEventArg.h
+ * @brief This is the header file for _MmsEventArg class.
+ *
+ * This header file contains the declarations of _MmsEventArg class.
+ */
+
+
+#ifndef _FMSG_INTERNAL_MMS_EVENT_ARG_H_
+#define _FMSG_INTERNAL_MMS_EVENT_ARG_H_
+
+// Includes
+#include <FBaseObject.h>
+#include <FBaseDataType.h>
+#include <FBaseRtIEventArg.h>
+
+namespace Tizen { namespace Messaging
+{
+
+//
+// @class _MmsEventArg
+// @brief This class provides methods for getting data from MMS event
+// @since 1.0
+//
+
+class _MmsEventArg
+ : public Tizen::Base::Object
+ , public Tizen::Base::Runtime::IEventArg
+{
+ // Life cycle
+public:
+ /**
+ * This is the constructor.
+ *
+ */
+ _MmsEventArg(void);
+
+ /**
+ * This is the constructor.
+ *
+ * @param[in] r - the message composer result
+ *
+ */
+ _MmsEventArg(const result r);
+
+ /**
+ * This is class destructor.
+ *
+ */
+ virtual ~_MmsEventArg(void) {};
+
+ // Access
+public:
+ /**
+ * Gets the error result of MMS event
+ *
+ * @param[out] r - the message composer result
+ * @exception E_SUCCESS - operation is successful
+ * @exception E_OUT_OF_MEMORY - failed to allocate required/requested memory
+ * @exception E_SYSTEM - the system has an error.
+ */
+ void GetErrorResult(result& r) const;
+
+ // Lifecycle
+private:
+ _MmsEventArg(const _MmsEventArg& value);
+ _MmsEventArg& operator =(const _MmsEventArg& rhs);
+
+private:
+ result __result;
+}; // _MmsEventArg
+} }
+
+#endif // _FMSG_INTERNAL_MMS_EVENT_ARG_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_MmsManagerImpl.cpp
+ * @brief This is the implementation file for the %_MmsManagerImpl class.
+ *
+ * This file contains the implementation of the %_MmsManagerImpl class.
+ */
+
+#include <messages.h>
+#include <email.h>
+#include <FIoDirectory.h>
+#include <FIoFile.h>
+#include <FMsgIMmsListener.h>
+#include <FMsgMmsManager.h>
+#include <FBaseSysLog.h>
+#include "FBase_StringConverter.h"
+#include "FMsg_SmsMmsCallbackHandler.h"
+#include "FMsg_MmsManagerImpl.h"
+#include "FMsg_MmsEvent.h"
+#include "FMsg_MmsEventArg.h"
+#include "FMsg_MsgUtil.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Messaging;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Messaging
+{
+
+_MmsManagerImpl::_MmsManagerImpl(void)
+ : __pMmsEvent(null)
+ , __isConstructed(false)
+ , __msgHandle(0)
+{
+}
+
+_MmsManagerImpl::~_MmsManagerImpl(void)
+{
+ result r = E_SUCCESS;
+ int err = MESSAGES_ERROR_NONE;
+
+ if (_SmsMmsCallbackHandler::GetInstance())
+ {
+ err = _SmsMmsCallbackHandler::GetInstance()->CloseMessageHandle();
+ }
+
+ if (err != MESSAGES_ERROR_NONE)
+ {
+ r = ConvertException(err);
+ SysLogException(NID_MSG, r, "[%s] Failed to close message handle.", GetErrorMessage(r));
+
+ }
+ __isConstructed = false;
+}
+
+result
+_MmsManagerImpl::Construct(IMmsListener& listener)
+{
+ result r = E_SUCCESS;
+ int err = MESSAGES_ERROR_NONE;
+
+ SysAssertf(__isConstructed == false, "_MmsManagerImpl instance is already constructed.");
+
+ // set event
+ unique_ptr<_MmsEvent> pMmsEvent(new (std::nothrow) _MmsEvent());
+ SysTryReturn(NID_MSG, pMmsEvent != null, E_OUT_OF_MEMORY, r = E_OUT_OF_MEMORY, "memory allocation failed");
+
+ // event construction
+ r = pMmsEvent->Construct();
+ SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to construct an instance");
+
+ // add listener
+ r = pMmsEvent->AddListener(listener, true);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to add a listener");
+
+ SysTryReturnResult(NID_MSG, _SmsMmsCallbackHandler::GetInstance() != NULL, E_SYSTEM, "Failed to constructSmsMmsCallbackHandler");
+
+ // open message handle
+ err = _SmsMmsCallbackHandler::GetInstance()->OpenMessageHandle(__msgHandle);
+ SysLog(NID_MSG, "value of __msgHandle is [%d]", __msgHandle);
+
+ r = ConvertException(err);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to open messageHandle");
+
+ // check value of msg handle
+ SysTryReturnResult(NID_MSG, __msgHandle > 0, E_SYSTEM, "msgHandle is invalid.");
+
+ __pMmsEvent = move(pMmsEvent);
+ __isConstructed = true;
+
+ return r;
+}
+
+result
+_MmsManagerImpl::Send(const MmsMessage& message, const RecipientList& recipientList, bool saveToSentBox)
+{
+ result r = E_SUCCESS;
+ messages_message_h mmsMsg = {0};
+ int err = MESSAGES_ERROR_NONE;
+ bool saveMsgToSentbox = saveToSentBox;
+
+ 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);
+
+ if (err == MESSAGES_ERROR_NONE)
+ {
+ err = messages_send_message(__msgHandle, mmsMsg, saveMsgToSentbox, &_SmsMmsCallbackHandler::SentMmsMessageStatusCallback,
+ (void*) (__pMmsEvent.get()));
+ }
+
+ r = ConvertException(err);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to send the MMS message.", GetErrorMessage(r));
+
+ //release message
+ messages_destroy_message(mmsMsg);
+
+ SysLog(NID_MSG, "sending an mms message success");
+ return r;
+
+CATCH:
+ messages_destroy_message(mmsMsg);
+ return r;
+}
+
+_MmsManagerImpl*
+_MmsManagerImpl::GetInstance(MmsManager& mmsManager)
+{
+ return mmsManager.__pImpl;
+}
+
+const _MmsManagerImpl*
+_MmsManagerImpl::GetInstance(const MmsManager& mmsManager)
+{
+ return mmsManager.__pImpl;
+}
+
+result
+_MmsManagerImpl::ConvertException(int err) const
+{
+ 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:
+ 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;
+ }
+
+ return r;
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_MmsManagerImpl.h
+ * @brief This is the header file for the _MmsManagerImpl class.
+ *
+ * This header file contains the declarations of the _MmsManagerImpl class.
+ */
+
+#ifndef _FMSG_INTERNAL_MMS_MANAGER_IMPL_H_
+#define _FMSG_INTERNAL_MMS_MANAGER_IMPL_H_
+
+// Includes
+#include <FBaseObject.h>
+#include "FMsg_Types.h"
+
+namespace Tizen { namespace Messaging
+{
+
+// forward declaration
+class MmsManager;
+class IMmsListener;
+class MmsMessage;
+class RecipientList;
+class _MmsEvent;
+
+/**
+* @class _MmsManagerImpl
+* @brief This class provides methods to use the MMS messaging service.
+* @since 1.0
+*
+* This class provides methods to use the MMS messaging service. @n
+*/
+class _MmsManagerImpl
+ : public Tizen::Base::Object
+{
+ // Life cycle
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 1.0
+ */
+ _MmsManagerImpl(void);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 1.0
+ */
+ virtual ~_MmsManagerImpl(void);
+
+private:
+ _MmsManagerImpl(const _MmsManagerImpl& value);
+ _MmsManagerImpl& operator =(const _MmsManagerImpl& rhs);
+
+ // Operation
+public:
+ /**
+ * Initializes this instance of _MmsManagerImpl with the specified listener.
+ *
+ * @since 1.0
+ * @return An error code
+ * @param[in] listener The listener to receive a send result asynchronously
+ * @exception E_SUCCESS The method was successful.
+ */
+ result Construct(IMmsListener& listener);
+
+ /**
+ * Sends the MMS message.
+ *
+ * @since 1.0
+ * @privlevel SYSTEM
+ * @privgroup http://tizen.org/privilege/messaging.mms
+ *
+ * @return An error code
+ * @param[in] message The message to be sent
+ * @param[in] recipientList The list of recipients
+ * @param[in] saveToSentBox Set to @c true to save the message in the Sentbox, @n
+ * else @c false
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_ON_INITIALIZING The mailbox is not completely loaded yet.
+ * @exception E_STORAGE_FULL The storage is full.
+ * @exception E_DEVICE_UNAVAILABLE The device is unavailable.
+ * @exception E_NETWORK_UNAVAILABLE The network is unavailable.
+ * @exception E_INVALID_CONDITION The profile is not set.
+ * @exception E_INVALID_ADDRESS The address is invalid.
+ * @exception E_FDN_MODE The FDN mode has been activated.
+ * @exception E_INVALID_ARG The number of recipients is @c 0 or the message is empty. @n
+ * @exception E_MAX_EXCEEDED The number of recipients crossed the limit (Maximum 10).
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @remarks Some service providers may not support sending MMS messages with an empty subject or body. @n
+ * In this case, the result of the status report will be the E_FAILURE exception.
+ * @see IMmsListener::OnMmsMessageSent()
+ */
+ result Send(const MmsMessage& message, const RecipientList& recipientList, bool saveToSentBox);
+
+public:
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _MmsManagerImpl
+ * @param[in] mmsManager An instance of MmsManager
+ */
+ static _MmsManagerImpl* GetInstance(MmsManager& mmsManager);
+
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _MmsManagerImpl
+ * @param[in] mmsManager An instance of MmsManager
+ */
+ static const _MmsManagerImpl* GetInstance(const MmsManager& mmsManager);
+
+ //utility
+private:
+ /**
+ * 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<_MmsEvent> __pMmsEvent;
+ bool __isConstructed;
+ messages_service_h __msgHandle;
+}; // _MmsManagerImpl
+} }
+
+#endif // _FMSG_INTERNAL_MMS_MANAGER_IMPL_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_MmsMessageImpl.cpp
+ * @brief This is the implementation file for the %_MmsMessageImpl class.
+ *
+ * This file contains the implementation of the %_MmsMessageImpl class.
+ */
+
+#include <limits.h>
+#include <messages.h>
+#include <email.h>
+#include <FIoFile.h>
+#include <FMsgTypes.h>
+#include <FMsgMmsMessage.h>
+#include <FBaseInternalTypes.h>
+#include <FBaseSysLog.h>
+#include <FApp_AppInfo.h>
+#include "FMsg_MsgUtil.h"
+#include "FMsg_MmsMessageImpl.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Messaging;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Messaging
+{
+
+_MmsMessageImpl::_MmsMessageImpl(void)
+ : __remainMsgSize(MAX_MMS_FILE_SIZE)
+{
+}
+
+_MmsMessageImpl::_MmsMessageImpl(const _MmsMessageImpl& value)
+{
+ __subject = value.__subject;
+ __text = value.__text;
+ __imageFilePath = value.__imageFilePath;
+ __audioFilePath = value.__audioFilePath;
+ __videoFilePath = value.__videoFilePath;
+ __vCalendarFilePath = value.__vCalendarFilePath;
+ __vCardFilePath = value.__vCardFilePath;
+ __remainMsgSize = value.__remainMsgSize;
+}
+
+_MmsMessageImpl::~_MmsMessageImpl(void)
+{
+ __remainMsgSize = MAX_MMS_FILE_SIZE;
+}
+
+_MmsMessageImpl&
+_MmsMessageImpl::operator =(const _MmsMessageImpl& rhs)
+{
+ if (this != &rhs)
+ {
+ __subject = rhs.__subject;
+ __text = rhs.__text;
+ __imageFilePath = rhs.__imageFilePath;
+ __audioFilePath = rhs.__audioFilePath;
+ __videoFilePath = rhs.__videoFilePath;
+ __vCalendarFilePath = rhs.__vCalendarFilePath;
+ __vCardFilePath = rhs.__vCardFilePath;
+ __remainMsgSize = rhs.__remainMsgSize;
+ }
+
+ return (*this);
+}
+
+bool
+_MmsMessageImpl::Equals(const Tizen::Base::Object& value) const
+{
+ const _MmsMessageImpl* pMmsMessageImpl = dynamic_cast<const _MmsMessageImpl*>(&value);
+ if (!pMmsMessageImpl)
+ {
+ SysLog(NID_MSG, "dynamic_cast is failed");
+ return false;
+ }
+
+ // subject
+ if (__subject != pMmsMessageImpl->__subject)
+ {
+ return false;
+ }
+
+ // text
+ if (__text != pMmsMessageImpl->__text)
+ {
+ return false;
+ }
+
+ // image
+ if (__imageFilePath != pMmsMessageImpl->__imageFilePath)
+ {
+ return false;
+ }
+
+ // audio
+ if (__audioFilePath != pMmsMessageImpl->__audioFilePath)
+ {
+ return false;
+ }
+
+ // video
+ if (__videoFilePath != pMmsMessageImpl->__videoFilePath)
+ {
+ return false;
+ }
+
+ // vcard
+ if (__vCalendarFilePath != pMmsMessageImpl->__vCalendarFilePath)
+ {
+ return false;
+ }
+
+ // vcal
+ if (__vCardFilePath != pMmsMessageImpl->__vCardFilePath)
+ {
+ return false;
+ }
+
+ // remain size
+ if (__remainMsgSize != pMmsMessageImpl->__remainMsgSize)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+int
+_MmsMessageImpl::GetHashCode(void) const
+{
+ int hash = 0;
+
+ hash = __subject.GetHashCode() + __text.GetHashCode() + __imageFilePath.GetHashCode() + __audioFilePath.GetHashCode() + __videoFilePath.GetHashCode() + __remainMsgSize + __vCalendarFilePath.GetHashCode() + __vCardFilePath.GetHashCode();
+
+ return hash;
+}
+
+result
+_MmsMessageImpl::SetSubject(const String& subject)
+{
+ result r = E_SUCCESS;
+
+ // get subject size
+ if (subject.GetLength() * 2 > __remainMsgSize)
+ {
+ r = E_MAX_EXCEEDED;
+ SysLogException(NID_MSG, r, "[E_MAX_EXCEEDED] Unable to add file. The size of the subject exceeds the maximum message size.");
+ goto CATCH;
+ }
+ __remainMsgSize -= subject.GetLength() * 2;
+
+ __subject = subject;
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+String
+_MmsMessageImpl::GetSubject(void) const
+{
+ return __subject;
+}
+
+result
+_MmsMessageImpl::SetText(const String& text)
+{
+ result r = E_SUCCESS;
+
+ // get subject size
+ if (text.GetLength() * 2 > __remainMsgSize)
+ {
+ r = E_MAX_EXCEEDED;
+ SysLogException(NID_MSG, r, "[E_MAX_EXCEEDED] Unable to add file. The size of the body text exceeds the maximum message size.");
+ goto CATCH;
+ }
+ __remainMsgSize -= text.GetLength() * 2;
+
+ __text = text;
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+String
+_MmsMessageImpl::GetText(void) const
+{
+ return __text;
+}
+
+result
+_MmsMessageImpl::AddAttachment(MmsAttachmentFormat format, const Tizen::Base::String& filePath)
+{
+ result r = E_SUCCESS;
+ long fileSize = 0;
+ FileAttributes fileAttributes;
+
+ // check file existence
+ if (File::IsFileExist(filePath) == false)
+ {
+ r = E_FILE_NOT_FOUND;
+ SysLogException(NID_MSG, r, "[E_FILE_NOT_FOUND] Cannot find corresponding file.");
+ goto CATCH;
+ }
+
+ // get file attributes
+ r = File::GetAttributes(filePath, fileAttributes);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to get the file attributes.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ // get file size
+ fileSize = (long) fileAttributes.GetFileSize();
+ if (fileSize > __remainMsgSize)
+ {
+ r = E_MAX_EXCEEDED;
+ SysLogException(NID_MSG, r, "[E_MAX_EXCEEDED] Unable to add file. The size of the file exceeds the maximum message size.");
+ goto CATCH;
+ }
+
+ // Attachment Format check
+ r = CheckPreviousAttachment(format);
+
+ if (r != E_SUCCESS)
+ {
+ SysLogException(NID_MSG, r, "[%s] Corresponding format file is already attached. Format: %d.", GetErrorMessage(r), (int) format);
+ goto CATCH;
+ }
+
+ if (_MsgUtil::CheckMediaFormat(format, filePath) == false)
+ {
+ r = E_INVALID_ARG;
+ SysLogException(NID_MSG, r, "[E_INVALID_ARG] Specified file contains invalid or unsupported media.");
+ goto CATCH;
+ }
+
+ // Set the attachment filePath.
+ r = SetAttachmentPath(format, filePath);
+
+ if (r != E_SUCCESS)
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to add file. Format: [%d].", GetErrorMessage(r), (int) format);
+ goto CATCH;
+ }
+
+ __remainMsgSize -= fileSize;
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+result
+_MmsMessageImpl::RemoveAttachment(MmsAttachmentFormat format)
+{
+ FileAttributes fileAttribute;
+ long fileSize = 0;
+ result r = E_SUCCESS;
+
+ switch (format)
+ {
+ case MMS_IMAGE:
+ if (__imageFilePath.GetLength() <= 0)
+ {
+ r = E_FILE_NOT_FOUND;
+ SysLogException(NID_MSG, r, "[E_FILE_NOT_FOUND] Cannot find corresponding file.");
+ goto CATCH;
+ }
+ r = File::GetAttributes(__imageFilePath, fileAttribute);
+ if (IsFailed(r))
+ {
+ r = E_FILE_NOT_FOUND;
+ SysLogException(NID_MSG, r, "[E_FILE_NOT_FOUND] Failed to get the file attributes.");
+ goto CATCH;
+ }
+ fileSize = (long) fileAttribute.GetFileSize();
+ __imageFilePath.Clear();
+ break;
+
+ case MMS_AUDIO:
+ if (__audioFilePath.GetLength() <= 0)
+ {
+ r = E_FILE_NOT_FOUND;
+ SysLogException(NID_MSG, r, "[E_FILE_NOT_FOUND] The length of the file name is smaller than 0.");
+ goto CATCH;
+ }
+ r = File::GetAttributes(__audioFilePath, fileAttribute);
+ if (IsFailed(r))
+ {
+ r = E_FILE_NOT_FOUND;
+ SysLogException(NID_MSG, r, "[E_FILE_NOT_FOUND] Failed to get the file attributes.");
+ goto CATCH;
+ }
+ fileSize = (long) fileAttribute.GetFileSize();
+ __audioFilePath.Clear();
+ break;
+
+ case MMS_VIDEO:
+ if (__videoFilePath.GetLength() <= 0)
+ {
+ r = E_FILE_NOT_FOUND;
+ SysLogException(NID_MSG, r, "[E_FILE_NOT_FOUND] The length of the file name is smaller than 0.");
+ goto CATCH;
+ }
+ r = File::GetAttributes(__videoFilePath, fileAttribute);
+ if (IsFailed(r))
+ {
+ r = E_FILE_NOT_FOUND;
+ SysLogException(NID_MSG, r, "[E_FILE_NOT_FOUND] Failed to get the file attributes.");
+ goto CATCH;
+ }
+ fileSize = (long) fileAttribute.GetFileSize();
+ __videoFilePath.Clear();
+ break;
+
+ case MMS_VCARD:
+ if (__vCardFilePath.GetLength() <= 0)
+ {
+ r = E_FILE_NOT_FOUND;
+ SysLogException(NID_MSG, r, "[E_FILE_NOT_FOUND] The length of the file name is smaller than 0.");
+ goto CATCH;
+ }
+ r = File::GetAttributes(__vCardFilePath, fileAttribute);
+ if (IsFailed(r))
+ {
+ r = E_FILE_NOT_FOUND;
+ SysLogException(NID_MSG, r, "[E_FILE_NOT_FOUND] Failed to get the file attributes.");
+ goto CATCH;
+ }
+ fileSize = (long) fileAttribute.GetFileSize();
+ __vCardFilePath.Clear();
+ break;
+
+ case MMS_VCALENDAR:
+ if (__vCalendarFilePath.GetLength() <= 0)
+ {
+ r = E_FILE_NOT_FOUND;
+ SysLogException(NID_MSG, r, "[E_FILE_NOT_FOUND] The length of the file name is smaller than 0.");
+ goto CATCH;
+ }
+ r = File::GetAttributes(__vCalendarFilePath, fileAttribute);
+ if (IsFailed(r))
+ {
+ r = E_FILE_NOT_FOUND;
+ SysLogException(NID_MSG, r, "[E_FILE_NOT_FOUND] Failed to get the file attributes.");
+ goto CATCH;
+ }
+ fileSize = (long) fileAttribute.GetFileSize();
+ __vCalendarFilePath.Clear();
+ break;
+ }
+
+ __remainMsgSize += fileSize;
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+String
+_MmsMessageImpl::GetAttachment(MmsAttachmentFormat format) const
+{
+ String returnValue;
+ ClearLastResult();
+
+ if (__imageFilePath.GetLength() <= 0 && __audioFilePath.GetLength() <= 0 && __videoFilePath.GetLength() <= 0 &&
+ __vCalendarFilePath.GetLength() <= 0 && __vCardFilePath.GetLength() <= 0)
+ {
+ SetLastResult(E_INVALID_CONDITION);
+ SysLogException(NID_MSG, GetLastResult(), "[E_INVALID_CONDITION] The file path is Empty.");
+ returnValue = L"";
+ return returnValue;
+ }
+
+ switch (format)
+ {
+ case MMS_IMAGE:
+ if (__imageFilePath.GetLength() <= 0)
+ {
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, GetLastResult(), "[E_INVALID_ARG] There is no image file.");
+ }
+ returnValue = __imageFilePath;
+ break;
+
+ case MMS_VIDEO:
+ if (__videoFilePath.GetLength() <= 0)
+ {
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, GetLastResult(), "[E_INVALID_ARG] There is no video file.");
+ }
+ returnValue = __videoFilePath;
+ break;
+
+ case MMS_AUDIO:
+ if (__audioFilePath.GetLength() <= 0)
+ {
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, GetLastResult(), "[E_INVALID_ARG] There is no audio file.");
+ }
+ returnValue = __audioFilePath;
+ break;
+
+ case MMS_VCARD:
+ if (__vCardFilePath.GetLength() <= 0)
+ {
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, GetLastResult(), "[E_INVALID_ARG] There is no vCard file.");
+ }
+ returnValue = __vCardFilePath;
+ break;
+
+ case MMS_VCALENDAR:
+ if (__vCalendarFilePath.GetLength() <= 0)
+ {
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, GetLastResult(), "[E_INVALID_ARG] There is no vCalendar file.");
+ }
+ returnValue = __vCalendarFilePath;
+ break;
+
+ default:
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, GetLastResult(), "[E_INVALID_ARG] Invalid MMS format arguments.");
+ returnValue = L"";
+ break;
+ }
+
+ return returnValue;
+}
+
+_MmsMessageImpl*
+_MmsMessageImpl::GetInstance(MmsMessage& mmsMessage)
+{
+ return mmsMessage.__pImpl;
+}
+
+const _MmsMessageImpl*
+_MmsMessageImpl::GetInstance(const MmsMessage& mmsMessage)
+{
+ return mmsMessage.__pImpl;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// private
+//////////////////////////////////////////////////////////////////////////
+result
+_MmsMessageImpl::CheckPreviousAttachment(MmsAttachmentFormat format)
+{
+ result r = E_SUCCESS;
+
+ SysTryReturn(NID_MSG, (format >= MMS_IMAGE && format <= MMS_VCALENDAR), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] Invalid MmsAttachmentFormat arguments.");
+
+ // Attachment Format check
+ switch (format)
+ {
+ case MMS_IMAGE:
+ if (!__imageFilePath.IsEmpty())
+ {
+ r = E_INVALID_ARG;
+ SysLogException(NID_MSG, r, "[E_INVALID_ARG] The image file is already attached.");
+ goto CATCH;
+ }
+ else if (!__videoFilePath.IsEmpty())
+ {
+ r = E_INVALID_ARG;
+ SysLogException(NID_MSG, r, "[E_INVALID_ARG] The image and video file cannot be attached simultaneously.");
+ goto CATCH;
+ }
+ break;
+
+ case MMS_VIDEO:
+ if (!__videoFilePath.IsEmpty())
+ {
+ r = E_INVALID_ARG;
+ SysLogException(NID_MSG, r, "[E_INVALID_ARG] The video file is already attached.");
+ goto CATCH;
+ }
+ else if (!__imageFilePath.IsEmpty())
+ {
+ r = E_INVALID_ARG;
+ SysLogException(NID_MSG, r, "[E_INVALID_ARG] The image and video file cannot be attached simultaneously.");
+ goto CATCH;
+ }
+ else if (!__audioFilePath.IsEmpty())
+ {
+ r = E_INVALID_ARG;
+ SysLogException(NID_MSG, r, "[E_INVALID_ARG] The video and audio file cannot be attached simultaneously.");
+ goto CATCH;
+ }
+ break;
+
+ case MMS_AUDIO:
+ if (!__audioFilePath.IsEmpty())
+ {
+ r = E_INVALID_ARG;
+ SysLogException(NID_MSG, r, "[E_INVALID_ARG] The audio file is already attached.");
+ goto CATCH;
+ }
+ else if (!__videoFilePath.IsEmpty())
+ {
+ r = E_INVALID_ARG;
+ SysLogException(NID_MSG, r, "[E_INVALID_ARG] The video and audio file cannot be attached simultaneously.");
+ goto CATCH;
+ }
+ break;
+
+ case MMS_VCARD:
+ if (!__vCardFilePath.IsEmpty())
+ {
+ r = E_INVALID_ARG;
+ SysLogException(NID_MSG, r, "[E_INVALID_ARG] The vCard file is already attached.");
+ goto CATCH;
+ }
+ break;
+
+ case MMS_VCALENDAR:
+ if (!__vCalendarFilePath.IsEmpty())
+ {
+ r = E_INVALID_ARG;
+ SysLogException(NID_MSG, r, "[E_INVALID_ARG] The vCalendar file is already attached.");
+ goto CATCH;
+ }
+ break;
+ }
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+result
+_MmsMessageImpl::SetAttachmentPath(const MmsAttachmentFormat format, const String& filePath)
+{
+ result r = E_SUCCESS;
+
+ SysTryReturn(NID_MSG, (format >= MMS_IMAGE && format <= MMS_VCALENDAR), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] Invalid MmsAttachmentFormat arguments.");
+ SysTryReturn(NID_MSG, filePath.GetLength() > 0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The file path is empty.");
+ SysTryReturn(NID_MSG, filePath.GetLength() <= PATH_MAX, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The file path is too long.");
+
+ switch (format)
+ {
+ case MMS_IMAGE:
+ __imageFilePath = filePath;
+ break;
+
+ case MMS_VIDEO:
+ __videoFilePath = filePath;
+ break;
+
+ case MMS_AUDIO:
+ __audioFilePath = filePath;
+ break;
+
+ case MMS_VCARD:
+ __vCardFilePath = filePath;
+ break;
+
+ case MMS_VCALENDAR:
+ __vCalendarFilePath = filePath;
+ break;
+ }
+
+ return E_SUCCESS;
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_MmsMessageImpl.h
+ * @brief This is the header file for _MmsMessageImpl class.
+ *
+ * This header file contains the declarations of _MmsMessageImpl class.
+ */
+
+
+#ifndef _FMSG_INTERNAL_MMS_MESSAGE_H_
+#define _FMSG_INTERNAL_MMS_MESSAGE_H_
+
+namespace Tizen { namespace Messaging
+{
+// forward declaration
+class MmsMessage;
+
+/**
+* @class _MmsMessageImpl
+* @brief This class provides methods for handling an MMS message.
+* @since 1.0
+*
+* This class provides methods for handling MMS messages. @n
+* A user can set and get the subject and body text of an MMS, @n
+* and can also add, remove, and receive attachments.
+*/
+class _MmsMessageImpl
+ : public Tizen::Base::Object
+{
+ // Life cycle
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 1.0
+ */
+ _MmsMessageImpl(void);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 1.0
+ */
+ virtual ~_MmsMessageImpl(void);
+
+ /**
+ * This is the copy constructor for this class.
+ *
+ * @since 1.0
+ * @param[in] value An instance of _MmsMessageImpl
+ */
+ _MmsMessageImpl(const _MmsMessageImpl& value);
+
+ /**
+ * This assignment operator copies an MMS message from the specified instance of _MmsMessageImpl to the calling instance of _MmsMessageImpl.
+ *
+ * @since 1.0
+ * @return A reference to this instance
+ * @param[in] rhs A reference to the _MmsMessageImpl instance to be copied
+ */
+ _MmsMessageImpl& operator =(const _MmsMessageImpl& rhs);
+
+public:
+ /**
+ * Gets the hash value of the current instance.
+ *
+ * @since 1.0
+ * @return The hash value of the current instance
+ * @remarks Two equal instances should return the same hash value. For better performance,
+ * the used hash function must generate a random distribution for all inputs.
+ */
+ virtual int GetHashCode(void) const;
+
+ /**
+ * Compares the specified instance with the calling instance.
+ *
+ * @since 1.0
+ * @return @c true if both instances are equal @n
+ * @c false, otherwise
+ * @param[in] value An instance of _MmsMessageImpl
+ */
+ virtual bool Equals(const Tizen::Base::Object& value) const;
+
+ // Operation
+public:
+ /**
+ * Sets the subject of the MMS.
+ *
+ * @since 1.0
+ * @return An error code
+ * @param[in] subject The subject of the message
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_MAX_EXCEEDED The subject length of the message is exceeding the maximum limit (Maximum 40 characters). @n
+ * The total size of the subject, body, and attachment(s) is exceeding the maximum limit (295KB).
+ * @see GetSubject()
+ */
+ result SetSubject(const Tizen::Base::String& subject);
+
+ /**
+ * Sets the text body of the message.
+ *
+ * @since 1.0
+ * @return An error code
+ * @param[in] text The body text of the message
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_MAX_EXCEEDED The body length of the message is exceeding the maximum limit (Maximum 1000 characters). @n
+ * The total size of the subject, body, and attachment(s) is exceeding the maximum limit (295KB).
+ * @see GetText()
+ */
+ result SetText(const Tizen::Base::String& text);
+
+ /**
+ * Adds the attachment of the specific type.
+ *
+ * @since 1.0
+ * @return An error code
+ * @param[in] format The format of the attachment
+ * @param[in] filePath The path of the file to attach
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_FILE_NOT_FOUND The specified file could not be found or accessed.
+ * @exception E_INVALID_ARG The length of the specified @c filePath is too long or @c 0. @n
+ * The specified file format is already attached. @n
+ * The value of the specified @c format is invalid. @n
+ * The specified file contains invalid or unsupported media. @n
+ * The specified file format cannot be attached. @n
+ * (An MMS attachment may contain either an image, an audio, a video, a vCard, or a vCalendar or a combination of an image, an audio, a vCard, and a vCalendar file. @n
+ * MMS attachments cannot contain a video file in combination with an image or audio file.)
+ * @exception E_MAX_EXCEEDED The size of the file is exceeding the maximum limit (Maximum 295KB). @n
+ * The total size of the subject, body, and attachment(s) is exceeding the maximum limit (295KB).
+ * @see GetAttachment()
+ */
+ result AddAttachment(MmsAttachmentFormat format, const Tizen::Base::String& filePath);
+
+ /**
+ * Gets the subject of the message.
+ *
+ * @since 1.0
+ * @return The subject of the message
+ * @see SetSubject()
+ */
+ Tizen::Base::String GetSubject(void) const;
+
+ /**
+ * Gets the body text of the message.
+ *
+ * @since 1.0
+ * @return The body text of the message
+ * @see SetText()
+ */
+ Tizen::Base::String GetText(void) const;
+
+ /**
+ * Gets the attachment file of the specific type.
+ *
+ * @since 1.0
+ * @return The path of the attached file
+ * @param[in] format The format of the attachment
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_CONDITION No file is attached.
+ * @exception E_INVALID_ARG There is no file of the specified @c format. @n
+ * The value of the specified @c format is invalid.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @see AddAttachment()
+ */
+ Tizen::Base::String GetAttachment(MmsAttachmentFormat format) const;
+
+ /**
+ * Removes the attachment of the specific type
+ *
+ * @since 1.0
+ * @return An error code
+ * @param[in] format The format of the attachment to remove
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_FILE_NOT_FOUND The corresponding format file was not found.
+ * @exception E_INVALID_ARG The value of the specified @c format is invalid.
+ * @see AddAttachment(), GetAttachment()
+ */
+ result RemoveAttachment(MmsAttachmentFormat format);
+
+private:
+ /**
+ * Checks the existence of the previous attachment file according to the file format.
+ *
+ * @return An error code
+ * @param[in] format The format of the attachment
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_ARG A specified input parameter is invalid.
+ */
+ result CheckPreviousAttachment(MmsAttachmentFormat format);
+
+
+ /**
+ * Sets the file path to the attachment file path according to the format.
+ *
+ * @return An error code
+ * @param[in] format The format of the attachment
+ * @param[in] filePath The Input file path
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_ARG A specified input parameter is invalid.
+ */
+ result SetAttachmentPath(const MmsAttachmentFormat format, const Tizen::Base::String& filePath);
+
+public:
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _MmsMessageImpl
+ * @param[in] mmsMessage An instance of MmsMessage
+ */
+ static _MmsMessageImpl* GetInstance(MmsMessage& mmsMessage);
+
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _MmsMessageImpl
+ * @param[in] mmsMessage An instance of MmsMessage
+ */
+ static const _MmsMessageImpl* GetInstance(const MmsMessage& mmsMessage);
+
+private:
+ Tizen::Base::String __subject;
+ Tizen::Base::String __text;
+ Tizen::Base::String __imageFilePath;
+ Tizen::Base::String __audioFilePath;
+ Tizen::Base::String __videoFilePath;
+ Tizen::Base::String __vCalendarFilePath;
+ Tizen::Base::String __vCardFilePath;
+ int __remainMsgSize;
+}; // _MmsMessageImpl
+
+} }
+
+#endif // _FMSG_INTERNAL_MMS_MESSAGE_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_MsgUtil.cpp
+ * @brief This is the implementation file for the %_MsgUtil class.
+ *
+ * This file contains the implementation of the %_MsgUtil class.
+ */
+
+// includes
+#include <messages.h>
+#include <email.h>
+#include <FBaseUtilStringUtil.h>
+#include <FIoFile.h>
+#include <FMsgMmsMessage.h>
+#include <FMsgSmsMessage.h>
+#include <FMsgEmailMessage.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include "FMsg_SmsMessageImpl.h"
+#include "FMsg_MsgUtil.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Messaging
+{
+
+result
+_MsgUtil::CheckAddressValidity(const Tizen::Base::String& address, _MessageType type)
+{
+ result r = E_SUCCESS;
+ int addressLen = 0;
+
+ switch (type)
+ {
+ case _MSG_SMS:
+ // fall through
+ case _MSG_MMS:
+ {
+ addressLen = address.GetLength();
+ if (address[0] == L'+')
+ {
+ addressLen--;
+ }
+
+ if (addressLen < MIN_LENGTH_PHONE || addressLen > MAX_LENGTH_PHONE)
+ {
+ SysLogException(NID_MSG, r, "[E_INVALID_ADDRESS] The Address length (%d) is too short or too long.", addressLen);
+ r = E_INVALID_ADDRESS;
+ goto CATCH;
+ }
+
+ for (int index = 0; index < addressLen; index++)
+ {
+ if (address[0] == L'+')
+ {
+ if (!Character::IsDigit(address[index + 1]))
+ {
+ r = E_INVALID_ADDRESS;
+ SysLogException(NID_MSG, r, "[E_INVALID_ADDRESS] The phone number contains a non-digit string.");
+ goto CATCH;
+ }
+ }
+ else
+ {
+ if (!Character::IsDigit(address[index]))
+ {
+ r = E_INVALID_ADDRESS;
+ SysLogException(NID_MSG, r, "[E_INVALID_ADDRESS] The phone number contains a non-digit string.");
+ goto CATCH;
+ }
+ }
+ }
+
+ break;
+ }
+
+ case _MSG_EMAIL:
+ {
+ addressLen = address.GetLength();
+
+ // size check
+ if (addressLen < 5 || addressLen > MAX_LENGTH_EMAIL) // "a@a.a"
+ {
+ r = E_INVALID_ADDRESS;
+ SysLogException(NID_MSG, r, "[E_INVALID_ADDRESS] The length (%d) of email address is too short or too long.", addressLen);
+ goto CATCH;
+ }
+
+ // check number of '@' char and '@' position
+ int pos = 0;
+ int posByLast = 0;
+
+ r = address.IndexOf(L'@', 0, pos);
+ r = address.LastIndexOf(L'@', addressLen - 1, posByLast);
+
+ if (pos <= 0 || pos != posByLast)
+ {
+ r = E_INVALID_ADDRESS;
+ SysLogException(NID_MSG, r, "[E_INVALID_ADDRESS] There is not a @ character or there are multiple @ characters.");
+ goto CATCH;
+ }
+
+ break;
+ }
+
+ default:
+ r = E_INVALID_ARG;
+ SysLogException(NID_MSG, r, "[E_INVALID_ARG] There is not a such type of address (%d).", type);
+ return r;
+ }
+
+ return E_SUCCESS;
+
+CATCH:
+ return r;
+}
+
+result
+_MsgUtil::CheckEmailAddressValidity(const RecipientList& recipientList)
+{
+ result r = E_SUCCESS;
+ RecipientList* pRecipientList = null;
+ IList* pToList = null;
+ IList* pCcList = null;
+ IList* pBccList = null;
+ int count = 0;
+ int index = 0;
+ String* pItem = null;
+
+ pRecipientList = const_cast< RecipientList* >(&recipientList);
+
+ // TO
+ count = 0; // initialize the count value
+ pToList = pRecipientList->GetListN(RECIPIENT_TYPE_TO);
+ if (!pToList)
+ {
+ r = GetLastResult();
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to get TO list.", GetErrorMessage(r));
+ goto CATCH;
+ }
+ else
+ {
+ SysLogException(NID_MSG, r, "[E_INVALID_ADDRESS] One of the address in TO list is not valid.");
+ SysLog(
+ NID_MSG,
+ "Strange!! RecipientList::GetListN(RECIPIENT_TYPE_TO) returns null. But the last result (by GetLastResult) is E_SUCCESS. So just return E_INVALID_ADDRESS.");
+ r = E_INVALID_ADDRESS;
+ goto CATCH;
+ }
+ }
+ else
+ {
+ count = pToList->GetCount();
+ }
+
+ if (count > 0)
+ {
+ for (index = 0; index < count; index++)
+ {
+ pItem = dynamic_cast< String* >(pToList->GetAt(index));
+ if (pItem != null)
+ {
+ r = CheckAddressValidity(*pItem, _MSG_EMAIL);
+ }
+ else
+ {
+ r = E_INVALID_ADDRESS;
+
+ }
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] There is invalid email address in TO list. Please check the RecipientList first.",
+ GetErrorMessage(
+ r));
+ goto CATCH;
+ }
+ }
+ }
+
+ // CC
+ count = 0; // initialize the count value
+ pCcList = pRecipientList->GetListN(RECIPIENT_TYPE_CC);
+ if (!pCcList)
+ {
+ r = GetLastResult();
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to get CC list.", GetErrorMessage(r));
+ goto CATCH;
+ }
+ else
+ {
+ SysLogException(NID_MSG, r, "[E_INVALID_ADDRESS] One of the address in CC list is not valid.");
+ SysLog(
+ NID_MSG,
+ "Strange!! RecipientList::GetListN(RECIPIENT_TYPE_CC) returns null. But the last result (by GetLastResult) is E_SUCCESS. So just return E_INVALID_ADDRESS.");
+ r = E_INVALID_ADDRESS;
+ goto CATCH;
+ }
+ }
+ else
+ {
+ count = pCcList->GetCount();
+ }
+
+ if (count > 0)
+ {
+ for (index = 0; index < count; index++)
+ {
+ pItem = dynamic_cast< String* >(pCcList->GetAt(index));
+ if (pItem != null)
+ {
+ r = CheckAddressValidity(*pItem, _MSG_EMAIL);
+ }
+ else
+ {
+ r = E_INVALID_ADDRESS;
+
+ }
+
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] There is invalid email address in CC list. Please check the RecipientList first.",
+ GetErrorMessage(
+ r));
+ goto CATCH;
+ }
+ }
+ }
+
+ // BCC
+ count = 0; // initialize the count value
+ pBccList = pRecipientList->GetListN(RECIPIENT_TYPE_BCC);
+ if (!pBccList)
+ {
+ r = GetLastResult();
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to get BCC list.", GetErrorMessage(r));
+ goto CATCH;
+ }
+ else
+ {
+ SysLogException(NID_MSG, r, "[E_INVALID_ADDRESS] One of the address in BCC list is not valid.");
+ SysLog(
+ NID_MSG,
+ "Strange!! RecipientList::GetListN(RECIPIENT_TYPE_BCC) returns null. But the last result (by GetLastResult) is E_SUCCESS. So just return E_INVALID_ADDRESS.");
+ r = E_INVALID_ADDRESS;
+ goto CATCH;
+ }
+ }
+ else
+ {
+ count = pBccList->GetCount();
+ }
+
+ if (count > 0)
+ {
+ for (index = 0; index < count; index++)
+ {
+ pItem = dynamic_cast< String* >(pBccList->GetAt(index));
+ if (pItem != null)
+ {
+ r = CheckAddressValidity(*pItem, _MSG_EMAIL);
+ }
+ else
+ {
+ r = E_INVALID_ADDRESS;
+
+ }
+
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] There is invalid email address in BCC list. Please check the RecipientList first.",
+ GetErrorMessage(
+ r));
+ goto CATCH;
+ }
+ }
+ }
+
+ // free the memories
+ if (pToList)
+ {
+ if (pToList->GetCount() > 0)
+ {
+ pToList->RemoveAll(true);
+ }
+ delete pToList;
+ pToList = null;
+ }
+ if (pCcList)
+ {
+ if (pCcList->GetCount() > 0)
+ {
+ pCcList->RemoveAll(true);
+ }
+ delete pCcList;
+ pCcList = null;
+ }
+ if (pBccList)
+ {
+ if (pBccList->GetCount() > 0)
+ {
+ pBccList->RemoveAll(true);
+ }
+ delete pBccList;
+ pBccList = null;
+ }
+
+ return E_SUCCESS;
+
+CATCH:
+ if (pToList)
+ {
+ if (pToList->GetCount() > 0)
+ {
+ pToList->RemoveAll(true);
+ }
+ delete pToList;
+ pToList = null;
+ }
+ if (pCcList)
+ {
+ if (pCcList->GetCount() > 0)
+ {
+ pCcList->RemoveAll(true);
+ }
+ delete pCcList;
+ pCcList = null;
+ }
+ if (pBccList)
+ {
+ if (pBccList->GetCount() > 0)
+ {
+ pBccList->RemoveAll(true);
+ }
+ delete pBccList;
+ pBccList = null;
+ }
+
+ return r;
+}
+
+result
+_MsgUtil::CheckPhoneNumberValidity(_MessageType type, const RecipientList& recipientList)
+{
+ result r = E_SUCCESS;
+ RecipientList* pRecipientList = null;
+ IList* pToList = null;
+ IList* pCcList = null;
+ IList* pBccList = null;
+ int count = 0;
+ int index = 0;
+ String* pItem = null;
+ int addressLen = 0;
+
+ pRecipientList = const_cast< RecipientList* >(&recipientList);
+
+ // TO
+ count = 0; // initialize the count value
+ pToList = pRecipientList->GetListN(RECIPIENT_TYPE_TO);
+ if (!pToList)
+ {
+ r = GetLastResult();
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to get TO list.", GetErrorMessage(r));
+ goto CATCH;
+ }
+ else
+ {
+ SysLogException(NID_MSG, r, "[E_INVALID_ADDRESS] One of the address in TO list is not valid.");
+ SysLog(
+ NID_MSG,
+ "Strange!! RecipientList::GetListN(RECIPIENT_TYPE_TO) returns null. But the last result (by GetLastResult) is E_SUCCESS. So just return E_INVALID_ADDRESS.");
+ r = E_INVALID_ADDRESS;
+ goto CATCH;
+ }
+ }
+ else
+ {
+ count = pToList->GetCount();
+ }
+
+ if (count > 0)
+ {
+ for (index = 0; index < count; index++)
+ {
+ pItem = dynamic_cast< String* >(pToList->GetAt(index));
+ SysTryCatch(NID_MSG, pItem != null, r = E_INVALID_ADDRESS, r, "To List Null");
+ r = CheckAddressValidity(*pItem, type);
+
+ if (type == _MSG_MMS && r != E_SUCCESS) //Check If MMS might have email address
+ {
+ addressLen = pItem->GetLength();
+
+ // size check
+ if (addressLen < 5 || addressLen > MAX_LENGTH_EMAIL) // "a@a.a"
+ {
+ r = E_INVALID_ADDRESS;
+ SysLogException(NID_MSG, r, "[E_INVALID_ADDRESS] The length (%d) of email address is too short or too long.", addressLen);
+ goto CATCH;
+ }
+
+ // check number of '@' char and '@' position
+ int pos = 0;
+ int posByLast = 0;
+
+ r = pItem->IndexOf(L'@', 0, pos);
+ r = pItem->LastIndexOf(L'@', addressLen - 1, posByLast);
+
+ if (pos <= 0 || pos != posByLast)
+ {
+ r = E_INVALID_ADDRESS;
+ SysLogException(NID_MSG, r, "[E_INVALID_ADDRESS] There is not a @ character or there are multiple @ characters.");
+ goto CATCH;
+ }
+ }
+
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] There is invalid phone number in TO list. Please check the RecipientList first.",
+ GetErrorMessage(
+ r));
+ goto CATCH;
+ }
+ }
+ }
+
+ // CC
+ count = 0; // initialize the count value
+ pCcList = pRecipientList->GetListN(RECIPIENT_TYPE_CC);
+ if (!pCcList)
+ {
+ r = GetLastResult();
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to get CC list.", GetErrorMessage(r));
+ goto CATCH;
+ }
+ else
+ {
+ SysLogException(NID_MSG, r, "[E_INVALID_ADDRESS] One of the address in CC list is not valid.");
+ SysLog(
+ NID_MSG,
+ "Strange!! RecipientList::GetListN(RECIPIENT_TYPE_CC) returns null. But the last result (by GetLastResult) is E_SUCCESS. So just return E_INVALID_ADDRESS.");
+ r = E_INVALID_ADDRESS;
+ goto CATCH;
+ }
+ }
+ else
+ {
+ count = pCcList->GetCount();
+ }
+
+ if (count > 0)
+ {
+ for (index = 0; index < count; index++)
+ {
+ pItem = dynamic_cast< String* >(pCcList->GetAt(index));
+ SysTryCatch(NID_MSG, pItem != null, r = E_INVALID_ADDRESS, r, "To List Null");
+ r = CheckAddressValidity(*pItem, type);
+
+
+ if (type == _MSG_MMS && r != E_SUCCESS) //Check If MMS might have email address
+ {
+ addressLen = pItem->GetLength();
+
+ // size check
+ if (addressLen < 5 || addressLen > MAX_LENGTH_EMAIL) // "a@a.a"
+ {
+ r = E_INVALID_ADDRESS;
+ SysLogException(NID_MSG, r, "[E_INVALID_ADDRESS] The length (%d) of email address is too short or too long.", addressLen);
+ goto CATCH;
+ }
+
+ // check number of '@' char and '@' position
+ int pos = 0;
+ int posByLast = 0;
+
+ r = pItem->IndexOf(L'@', 0, pos);
+ r = pItem->LastIndexOf(L'@', addressLen - 1, posByLast);
+
+ if (pos <= 0 || pos != posByLast)
+ {
+ r = E_INVALID_ADDRESS;
+ SysLogException(NID_MSG, r, "[E_INVALID_ADDRESS] There is not a @ character or there are multiple @ characters.");
+ goto CATCH;
+ }
+ }
+
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] There is invalid phone number in CC list. Please check the RecipientList first.",
+ GetErrorMessage(
+ r));
+ goto CATCH;
+ }
+ }
+ }
+
+ // BCC
+ count = 0; // initialize the count value
+ pBccList = pRecipientList->GetListN(RECIPIENT_TYPE_BCC);
+ if (!pBccList)
+ {
+ r = GetLastResult();
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to get BCC list.", GetErrorMessage(r));
+ goto CATCH;
+ }
+ else
+ {
+ SysLogException(NID_MSG, r, "[E_INVALID_ADDRESS] One of the address in BCC list is not valid.");
+ SysLog(
+ NID_MSG,
+ "Strange!! RecipientList::GetListN(RECIPIENT_TYPE_BCC) returns null. But the last result (by GetLastResult) is E_SUCCESS. So just return E_INVALID_ADDRESS.");
+ r = E_INVALID_ADDRESS;
+ goto CATCH;
+ }
+ }
+ else
+ {
+ count = pBccList->GetCount();
+ }
+
+ if (count > 0)
+ {
+ for (index = 0; index < count; index++)
+ {
+ pItem = dynamic_cast< String* >(pBccList->GetAt(index));
+ SysTryCatch(NID_MSG, pItem != null, r = E_INVALID_ADDRESS, r, "To List Null");
+ r = CheckAddressValidity(*pItem, type);
+
+
+ if (type == _MSG_MMS && r != E_SUCCESS) //Check If MMS might have email address
+ {
+ addressLen = pItem->GetLength();
+
+ // size check
+ if (addressLen < 5 || addressLen > MAX_LENGTH_EMAIL) // "a@a.a"
+ {
+ r = E_INVALID_ADDRESS;
+ SysLogException(NID_MSG, r, "[E_INVALID_ADDRESS] The length (%d) of email address is too short or too long.", addressLen);
+ goto CATCH;
+ }
+
+ // check number of '@' char and '@' position
+ int pos = 0;
+ int posByLast = 0;
+
+ r = pItem->IndexOf(L'@', 0, pos);
+ r = pItem->LastIndexOf(L'@', addressLen - 1, posByLast);
+
+ if (pos <= 0 || pos != posByLast)
+ {
+ r = E_INVALID_ADDRESS;
+ SysLogException(NID_MSG, r, "[E_INVALID_ADDRESS] There is not a @ character or there are multiple @ characters.");
+ goto CATCH;
+ }
+ }
+
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] There is invalid phone number in BCC list. Please check the RecipientList first.",
+ GetErrorMessage(
+ r));
+ goto CATCH;
+ }
+ }
+ }
+
+ // free the memories
+ if (pToList)
+ {
+ if (pToList->GetCount() > 0)
+ {
+ pToList->RemoveAll(true);
+ }
+ delete pToList;
+ pToList = null;
+ }
+ if (pCcList)
+ {
+ if (pCcList->GetCount() > 0)
+ {
+ pCcList->RemoveAll(true);
+ }
+ delete pCcList;
+ pCcList = null;
+ }
+ if (pBccList)
+ {
+ if (pBccList->GetCount() > 0)
+ {
+ pBccList->RemoveAll(true);
+ }
+ delete pBccList;
+ pBccList = null;
+ }
+
+ return E_SUCCESS;
+
+CATCH:
+ if (pToList)
+ {
+ if (pToList->GetCount() > 0)
+ {
+ pToList->RemoveAll(true);
+ }
+ delete pToList;
+ pToList = null;
+ }
+ if (pCcList)
+ {
+ if (pCcList->GetCount() > 0)
+ {
+ pCcList->RemoveAll(true);
+ }
+ delete pCcList;
+ pCcList = null;
+ }
+ if (pBccList)
+ {
+ if (pBccList->GetCount() > 0)
+ {
+ pBccList->RemoveAll(true);
+ }
+ delete pBccList;
+ pBccList = null;
+ }
+
+ return r;
+}
+
+bool
+_MsgUtil::IsValidImageFile(const String& filePath)
+{
+ bool isValid = false;
+
+ String delimiter(L";");
+ String fileExtensionTable(L"jpg;jpeg;gif;png;bmp;wbmp;tif;tiff;swf;svg;svgz");
+ String fileExtension = Tizen::Io::File::GetFileExtension(filePath);
+ Tizen::Base::Utility::StringTokenizer strTok(fileExtensionTable, delimiter);
+ String token;
+
+ while (strTok.HasMoreTokens())
+ {
+ strTok.GetNextToken(token);
+ if (token.Equals(fileExtension, false))
+ {
+ isValid = true;
+ break;
+ }
+ }
+
+ return isValid;
+}
+
+bool
+_MsgUtil::IsValidAudioFile(const String& filePath)
+{
+ bool isValid = false;
+
+ String delimiter(L";");
+ String fileExtensionTable(L"mid;midi;spm;imy;amr;mmf;xmf;mxmf;3gp;3gpp;mp4;asf;ra;ram;rv;rm;mp3;aac;wav;3ga;m4a;wma");
+ String fileExtension = Tizen::Io::File::GetFileExtension(filePath);
+ Tizen::Base::Utility::StringTokenizer strTok(fileExtensionTable, delimiter);
+ String token;
+
+ while (strTok.HasMoreTokens())
+ {
+ strTok.GetNextToken(token);
+ if (token.Equals(fileExtension, false))
+ {
+ isValid = true;
+ break;
+ }
+ }
+
+ return isValid;
+}
+
+bool
+_MsgUtil::IsValidVideoFile(const String& filePath)
+{
+
+ bool isValid = false;
+
+ String delimiter(L";");
+ String fileExtensionTable(L"3gp;3gpp;mp4;asf;wmv;ra;ram;rv;rm");
+ String fileExtension = Tizen::Io::File::GetFileExtension(filePath);
+ Tizen::Base::Utility::StringTokenizer strTok(fileExtensionTable, delimiter);
+ String token;
+
+ while (strTok.HasMoreTokens())
+ {
+ strTok.GetNextToken(token);
+ if (token.Equals(fileExtension, false))
+ {
+ isValid = true;
+ break;
+ }
+ }
+
+ return isValid;
+}
+
+
+bool
+_MsgUtil::IsValidVcardFile(const String& filePath)
+{
+ bool isValid = false;
+ String fileExtension = Tizen::Io::File::GetFileExtension(filePath);
+
+ if (fileExtension.Equals(L"vcf", false))
+ {
+ isValid = true;
+ }
+
+ return isValid;
+}
+
+bool
+_MsgUtil::IsValidVcalendarFile(const String& filePath)
+{
+ bool isValid = false;
+ String fileExtension = Tizen::Io::File::GetFileExtension(filePath);
+
+ if (fileExtension.Equals(L"vcs", false))
+ {
+ isValid = true;
+ }
+
+ return isValid;
+}
+
+bool
+_MsgUtil::CheckMediaFormat(const MmsAttachmentFormat format, const String& filePath)
+{
+ bool isValid = false;
+ switch (format)
+ {
+ case MMS_IMAGE:
+ isValid = IsValidImageFile(filePath);
+ break;
+
+ case MMS_AUDIO:
+ isValid = IsValidAudioFile(filePath);
+ break;
+
+ case MMS_VIDEO:
+ isValid = IsValidVideoFile(filePath);
+ break;
+
+ case MMS_VCARD:
+ isValid = IsValidVcardFile(filePath);
+ break;
+
+ case MMS_VCALENDAR:
+ isValid = IsValidVcalendarFile(filePath);
+ break;
+
+ default:
+ break;
+ }
+ return isValid;
+}
+
+bool
+_MsgUtil::IsValidPhoneNumber(const Tizen::Base::String& phoneNumber)
+{
+ int length = 0;
+
+ length = phoneNumber.GetLength();
+ if (phoneNumber[0] == L'+')
+ {
+ length--;
+ }
+
+ if (length < MIN_LENGTH_PHONE || length > MAX_LENGTH_PHONE)
+ {
+ SysLog(NID_MSG, "The length of the phone number (%d) is too short or too long.", length);
+ return false;
+ }
+
+ for (int index = 0; index < length; index++)
+ {
+ if (phoneNumber[0] == L'+')
+ {
+ if (!Character::IsDigit(phoneNumber[index + 1]))
+ {
+ SysLog(NID_MSG, "The phone number contains a non-digit string.");
+ return false;
+ }
+ }
+ else
+ {
+ if (!Character::IsDigit(phoneNumber[index]))
+ {
+ SysLog(NID_MSG, "The phone number contains a non-digit string.");
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+SmsMessageBoxType
+_MsgUtil::GetSmsMessageBoxType(messages_message_box_e folderId)
+{
+ SmsMessageBoxType type = SMS_MESSAGE_BOX_TYPE_NONE;
+ switch (folderId)
+ {
+ case MESSAGES_MBOX_INBOX:
+ type = SMS_MESSAGE_BOX_TYPE_INBOX;
+ break;
+
+ case MESSAGES_MBOX_OUTBOX:
+ type = SMS_MESSAGE_BOX_TYPE_OUTBOX;
+ break;
+
+ case MESSAGES_MBOX_SENTBOX:
+ type = SMS_MESSAGE_BOX_TYPE_SENTBOX;
+ break;
+
+// case MESSAGES_MBOX_ALL:
+// type = SMS_MESSAGE_BOX_TYPE_ALL;
+// break;
+
+ default:
+ type = SMS_MESSAGE_BOX_TYPE_NONE;
+ break;
+ }
+
+ return type;
+}
+
+messages_message_box_e
+_MsgUtil::GetMsgFolderId(const SmsMessageBoxType& type)
+{
+ messages_message_box_e folderId;
+
+ switch (type)
+ {
+ case SMS_MESSAGE_BOX_TYPE_INBOX:
+ folderId = MESSAGES_MBOX_INBOX;
+ break;
+
+ case SMS_MESSAGE_BOX_TYPE_OUTBOX:
+ folderId = MESSAGES_MBOX_OUTBOX;
+ break;
+
+ case SMS_MESSAGE_BOX_TYPE_SENTBOX:
+ folderId = MESSAGES_MBOX_SENTBOX;
+ break;
+
+ case SMS_MESSAGE_BOX_TYPE_ALL:
+ folderId = MESSAGES_MBOX_ALL;
+ break;
+
+ default:
+ folderId = (messages_message_box_e) -1;
+ break;
+ }
+
+ return folderId;
+}
+
+SmsMessageBoxType
+_MsgUtil::GetMsgBoxType(const messages_message_box_e& folderId)
+{
+ SmsMessageBoxType type;
+
+ switch (folderId)
+ {
+ case MESSAGES_MBOX_INBOX:
+ type = SMS_MESSAGE_BOX_TYPE_INBOX;
+ break;
+
+ case MESSAGES_MBOX_OUTBOX:
+ type = SMS_MESSAGE_BOX_TYPE_OUTBOX;
+ break;
+
+ case MESSAGES_MBOX_SENTBOX:
+ type = SMS_MESSAGE_BOX_TYPE_SENTBOX;
+ break;
+
+ case MESSAGES_MBOX_ALL:
+ type = SMS_MESSAGE_BOX_TYPE_ALL;
+ break;
+
+ default:
+ type = SMS_MESSAGE_BOX_TYPE_NONE;
+ break;
+ }
+
+ return type;
+}
+
+int
+_MsgUtil::GetSmsMessage(const SmsMessage& message, const RecipientList& recipientList, messages_message_h& smsMsg)
+{
+ int err = MESSAGES_ERROR_NONE;
+ const 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" ");
+ pMsgBody = _StringConverter::CopyToCharArrayN(emptyText);
+ }
+ else
+ {
+ pMsgBody = _StringConverter::CopyToCharArrayN(message.GetText());
+ }
+
+ 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 = 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");
+
+ if (pMsgBody)
+ {
+ delete[] pMsgBody;
+ pMsgBody = null;
+ }
+
+ return err;
+
+CATCH:
+
+ if (pMsgBody)
+ {
+ delete[] pMsgBody;
+ pMsgBody = null;
+ }
+
+ return err;
+}
+
+int
+_MsgUtil::GetEmailMessage(const EmailMessage& message, const RecipientList& recipientList, email_h& emailMsg)
+{
+ int err = EMAIL_ERROR_NONE;
+ result r = E_SUCCESS;
+ int attachNum = 0;
+ const char* pSubject = null;
+ const char* pMsgBody = null;
+ Tizen::Base::Collection::IList* pAttachmentList = null;
+
+ pSubject = _StringConverter::CopyToCharArrayN(message.GetSubject());
+ pMsgBody = _StringConverter::CopyToCharArrayN(message.GetText());
+
+ 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");
+
+ 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");
+
+ pAttachmentList = message.GetAttachmentListN();
+
+ if (pAttachmentList)
+ {
+ attachNum = pAttachmentList->GetCount();
+ }
+
+ 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;
+ }
+
+ 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;
+ }
+
+ 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)
+{
+ String* pTempRecipient = null;
+ IList* pRecipientList = null;
+ char* pEmailAddr = null;
+ int count = 0;
+ int err = EMAIL_ERROR_NONE;
+ result r = E_SUCCESS;
+
+ pRecipientList = (const_cast< RecipientList& >(recipientList)).GetListN(type);
+ if (!pRecipientList)
+ {
+ r = GetLastResult();
+ SysLogException(NID_MSG, r, "[%s] Failed to get recipient list", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ count = pRecipientList->GetCount();
+ for (int index = 0; index < count; index++)
+ {
+ pTempRecipient = dynamic_cast< String* >(pRecipientList->GetAt(index));
+ if (!pTempRecipient)
+ {
+ r = GetLastResult();
+ err = EMAIL_ERROR_OPERATION_FAILED;
+ SysLogException(NID_MSG, r, "[%s] Failed to get a recipient", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ pEmailAddr = _StringConverter::CopyToCharArrayN(*pTempRecipient);
+ err = email_add_recipient(emailMsg, recipientType, pEmailAddr);
+
+ if (pEmailAddr)
+ {
+ delete[] pEmailAddr;
+ pEmailAddr = null;
+ }
+ SysTryCatch(NID_MSG, err == EMAIL_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "failed to set message address");
+
+ }
+
+ // deallocate
+ if (pRecipientList->GetCount() > 0)
+ {
+ pRecipientList->RemoveAll(true);
+ }
+ delete pRecipientList;
+ pRecipientList = null;
+
+ return err;
+
+CATCH:
+ SetLastResult(r);
+ if (pRecipientList)
+ {
+ if (pRecipientList->GetCount() > 0)
+ {
+ pRecipientList->RemoveAll(true);
+ }
+ delete pRecipientList;
+ pRecipientList = null;
+ }
+
+ return err;
+}
+
+int
+_MsgUtil::AddMessageAddress(const RecipientList& recipientList, RecipientType type, messages_message_h& messageMsg, messages_recipient_type_e recipientType)
+{
+ String* pTempRecipient = null;
+ IList* pRecipientList = null;
+ char* pPhoneNum = null;
+ int count = 0;
+ int err = MESSAGES_ERROR_NONE;
+ result r = E_SUCCESS;
+
+ pRecipientList = (const_cast< RecipientList& >(recipientList)).GetListN(type);
+ if (!pRecipientList)
+ {
+ r = GetLastResult();
+ SysLogException(NID_MSG, r, "[%s] Failed to get recipient list", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ count = pRecipientList->GetCount();
+ for (int index = 0; index < count; index++)
+ {
+ pTempRecipient = dynamic_cast< String* >(pRecipientList->GetAt(index));
+ if (!pTempRecipient)
+ {
+ r = GetLastResult();
+ err = MESSAGES_ERROR_OPERATION_FAILED;
+ 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);
+
+ if (pPhoneNum)
+ {
+ delete[] pPhoneNum;
+ pPhoneNum = null;
+ }
+ SysTryCatch(NID_MSG, err == MESSAGES_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "failed to set message address");
+
+ }
+
+ // deallocate
+ if (pRecipientList->GetCount() > 0)
+ {
+ pRecipientList->RemoveAll(true);
+ }
+ delete pRecipientList;
+ pRecipientList = null;
+
+ return err;
+
+CATCH:
+ SetLastResult(r);
+ if (pRecipientList)
+ {
+ if (pRecipientList->GetCount() > 0)
+ {
+ pRecipientList->RemoveAll(true);
+ }
+ delete pRecipientList;
+ pRecipientList = null;
+ }
+
+ return err;
+}
+
+Tizen::Base::String
+_MsgUtil::GetConcatenatedRecipientListString(const RecipientList& recipientList, RecipientType type,
+ const Tizen::Base::String& delim)
+{
+ String concatenatedString;
+ String* pTempRecipient = null;
+ IList* pRecipientList = null;
+ int count = 0;
+ result r = E_SUCCESS;
+
+ ClearLastResult();
+
+ pRecipientList = (const_cast< RecipientList& >(recipientList)).GetListN(type);
+ if (!pRecipientList)
+ {
+ r = GetLastResult();
+ SysLogException(NID_MSG, r, "[%s] Failed to get recipient list", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ concatenatedString.Clear();
+
+ count = pRecipientList->GetCount();
+ for (int index = 0; index < count; index++)
+ {
+ pTempRecipient = dynamic_cast< String* >(pRecipientList->GetAt(index));
+ if (!pTempRecipient)
+ {
+ r = GetLastResult();
+ SysLogException(NID_MSG, r, "[%s] Failed to get a recipient", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ concatenatedString.Append(*pTempRecipient);
+ if (index < count - 1)
+ {
+ concatenatedString.Append(delim);
+ }
+ }
+
+ // deallocate
+ if (pRecipientList->GetCount() > 0)
+ {
+ pRecipientList->RemoveAll(true);
+ }
+ delete pRecipientList;
+ pRecipientList = null;
+
+ return concatenatedString;
+
+CATCH:
+ SetLastResult(r);
+ // deallocate
+ if (pRecipientList)
+ {
+ if (pRecipientList->GetCount() > 0)
+ {
+ pRecipientList->RemoveAll(true);
+ }
+ delete pRecipientList;
+ pRecipientList = null;
+ }
+
+ 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)
+{
+ DateTime dateTime;
+ struct tm* pTempTime = null;
+
+ pTempTime = gmtime(pTime);
+ if (pTempTime)
+ {
+ dateTime.SetValue(pTempTime->tm_year + 1900, pTempTime->tm_mon + 1, pTempTime->tm_mday, pTempTime->tm_hour, pTempTime->tm_min, pTempTime->tm_sec);
+ }
+ return dateTime;
+}
+
+SmsMessage*
+_MsgUtil::ConvertSmsMessageN(const SmsMessageBoxType& type, messages_message_h msg)
+{
+ result r = E_SUCCESS;
+ SmsMessage* pSmsMessage = null;
+ char* pOriginalText = null;
+ char* pBodyText = null;
+ char* pMsgAddress = null;
+ DateTime time;
+ time_t tempTime = 0;
+ bool hasMoreText = false;
+ int messageId = 0;
+ String body;
+ messages_recipient_type_e recipientType = MESSAGES_RECIPIENT_TO;
+ const int msgBodyLength = 160;
+ int originalTextLength = 0;
+
+ pSmsMessage = new (std::nothrow) SmsMessage();
+ SysTryCatch(NID_MSG, pSmsMessage != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+
+ // message ID
+ messages_get_message_id(msg, &messageId);
+ // body text
+ messages_get_text(msg, &pOriginalText);
+ SysTryCatch(NID_MSG, pOriginalText != null, r = E_SYSTEM, r, "sms get message body failed");
+
+ originalTextLength = strlen(pOriginalText);
+ 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;
+ hasMoreText = true;
+
+ }
+ else
+ {
+ pBodyText = const_cast< char* >(pOriginalText);
+ pOriginalText = null;
+ }
+
+ body = pBodyText;
+
+ // received/sent time
+ messages_get_time(msg, &tempTime);
+ time = _MsgUtil::ConvertTime(&tempTime);
+
+ 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;
+ _SmsMessageImpl::GetInstance(*pSmsMessage)->SetInboxMessage(messageId, body, hasMoreText, senderAddress, time);
+ break;
+ }
+
+ case SMS_MESSAGE_BOX_TYPE_SENTBOX:
+ {
+ // recipient list
+ int recipient_count = 0;
+ messages_get_address_count(msg, &recipient_count);
+ 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);
+ }
+ _SmsMessageImpl::GetInstance(*pSmsMessage)->SetSentboxMessage(messageId, body, hasMoreText, recipients, time);
+ break;
+ }
+
+ case SMS_MESSAGE_BOX_TYPE_OUTBOX:
+ {
+ // recipient list
+ int recipient_count = 0;
+ messages_get_address_count(msg, &recipient_count);
+ 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);
+ }
+ _SmsMessageImpl::GetInstance(*pSmsMessage)->SetOutboxMessage(messageId, body, hasMoreText, recipients, time);
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ if (pBodyText)
+ {
+ free(pBodyText);
+ pBodyText = null;
+ }
+
+ return pSmsMessage;
+
+CATCH:
+
+ if (pBodyText)
+ {
+ free(pBodyText);
+ pBodyText = null;
+ }
+
+ if (pSmsMessage)
+ {
+ delete pSmsMessage;
+ }
+
+ return NULL;
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_MsgUtil.h
+ * @brief This is the header file for _MsgUtil class.
+ *
+ * This header file contains declarations of _MsgUtil class.
+ */
+
+#ifndef _FMSG_INTERNAL_UTIL_H_
+#define _FMSG_INTERNAL_UTIL_H_
+
+// Includes
+#include <FMsgTypes.h>
+#include "FMsg_Types.h"
+
+
+namespace Tizen { namespace Messaging
+{
+
+// forward declaration
+class RecipientList;
+class SmsMessage;
+class MmsMessage;
+class EmailMessage;
+
+/**
+* @class _MsgUtil
+* @brief This class defines utility functions for Messaging namespace.
+*/
+class _MsgUtil
+{
+public:
+ static result CheckAddressValidity(const Tizen::Base::String& address, _MessageType type);
+ static result CheckEmailAddressValidity(const RecipientList& recipientList);
+ static result CheckPhoneNumberValidity(_MessageType type, const RecipientList& recipientList);
+ static bool CheckMediaFormat(const MmsAttachmentFormat format, const Tizen::Base::String& filePath);
+ static bool IsValidImageFile(const Tizen::Base::String& filePath);
+ static bool IsValidAudioFile(const Tizen::Base::String& filePath);
+ static bool IsValidVideoFile(const Tizen::Base::String& filePath);
+ 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 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 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);
+
+private:
+ _MsgUtil(void);
+ virtual ~_MsgUtil(void) {};
+ _MsgUtil(const _MsgUtil& value);
+ _MsgUtil& operator =(const _MsgUtil& rhs);
+}; // _MsgUtil
+} }
+#endif //_FMSG_INTERNAL_UTIL_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_PushEvent.cpp
+ * @brief This is the implementation file for _PushEvent class.
+ * @version 3.0
+ *
+ * This file contains the implementation of _PushEvent class.
+ */
+
+// Includes
+#include <FBaseSysLog.h>
+#include "FMsg_PushManagerImpl.h"
+#include "FMsg_PushEvent.h"
+#include "FMsg_PushEventArg.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Messaging
+{
+
+_PushEvent::_PushEvent(_PushManagerImpl* pPushManager)
+ : __pPushManager(pPushManager)
+{
+ _Event::Initialize();
+}
+
+_PushEvent::~_PushEvent(void)
+{
+ __pPushManager = null;
+}
+
+_PushManagerImpl*
+_PushEvent::GetPushManager(void) const
+{
+ return __pPushManager;
+}
+
+void
+_PushEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
+{
+ SysLog(NID_MSG, "Enter.");
+
+ IEventArg* pEventArg = null;
+ _PushEventArg* pPushEventArg = null;
+
+ pEventArg = const_cast <IEventArg*>(&arg);
+ pPushEventArg = dynamic_cast <_PushEventArg*>(pEventArg);
+
+ if ((__pPushManager != null) && (pPushEventArg != null))
+ {
+ __pPushManager->HandlePushEvent(*pPushEventArg);
+ }
+
+ SysLog(NID_MSG, "Exit.");
+
+ return;
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_PushEvent.h
+ * @brief This is the header file for _PushEvent class.
+ * @version 3.0
+ *
+ * This header file contains the declarations of _PushEvent class.
+ * The _PushEvent class can call listener's method. So, when an event is occured,
+ * application can handle it appropriately.
+ */
+
+#ifndef _FMSG_INTERNAL_PUSH_EVENT_H_
+#define _FMSG_INTERNAL_PUSH_EVENT_H_
+
+#include <FBaseDataType.h>
+#include <FBaseRt_Event.h>
+
+namespace Tizen { namespace Base { namespace Runtime
+{
+class IEventListener;
+class IEventArg;
+} } } // Tizen::Base::Runtime
+
+namespace Tizen { namespace Messaging
+{
+
+class _PushManagerImpl;
+
+class _PushEvent
+ : public Tizen::Base::Runtime::_Event
+{
+public:
+ _PushEvent(_PushManagerImpl* pPushManager);
+ virtual ~_PushEvent(void);
+
+public:
+ _PushManagerImpl* GetPushManager(void) const;
+
+protected:
+ virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+ _PushEvent(void);
+ _PushEvent(const _PushEvent& rhs);
+ _PushEvent& operator =(const _PushEvent& rhs);
+
+private:
+ _PushManagerImpl* __pPushManager;
+
+}; // _PushEvent
+
+} } // Tizen::Messaging
+#endif // _FMSG_INTERNAL_PUSH_EVENT_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_PushEventArg.cpp
+ * @brief This is the implementation file for _PushEventArg class.
+ * @version 3.0
+ *
+ * This file contains the implementation of _PushEventArg class.
+ */
+
+// Includes
+#include <FBaseSysLog.h>
+#include "FMsg_PushEventArg.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Messaging
+{
+
+_PushEventArg::_PushEventArg(_PushEventType type, RequestId reqId, const String& data, const String& message, result ret, const String& errorCode, const String& errorMsg)
+ : __type(type)
+ , __reqId(reqId)
+ , __data(data)
+ , __message(message)
+ , __ret(ret)
+ , __errorCode(errorCode)
+ , __errorMsg(errorMsg)
+{
+}
+
+_PushEventArg::~_PushEventArg(void)
+{
+}
+
+_PushEventType
+_PushEventArg::GetType(void) const
+{
+ return __type;
+}
+
+RequestId
+_PushEventArg::GetRequestId(void) const
+{
+ return __reqId;
+}
+
+String
+_PushEventArg::GetData(void) const
+{
+ return __data;
+}
+
+String
+_PushEventArg::GetMessage(void) const
+{
+ return __message;
+}
+
+result
+_PushEventArg::GetResult(void) const
+{
+ return __ret;
+}
+
+String
+_PushEventArg::GetErrorCode(void) const
+{
+ return __errorCode;
+}
+
+String
+_PushEventArg::GetErrorMsg(void) const
+{
+ return __errorMsg;
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_PushEventArg.h
+ * @brief This is the header file for _PushEventArg class.
+ * @version 3.0
+ *
+ * This header file contains the declarations of _PushEventArg class.
+ */
+
+#ifndef _FMSG_INTERNAL_PUSH_EVENT_ARG_H_
+#define _FMSG_INTERNAL_PUSH_EVENT_ARG_H_
+
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseRtIEventArg.h>
+
+namespace Tizen { namespace Messaging
+{
+
+enum _PushEventType
+{
+ _PUSH_EVENT_TYPE_REGISTRATION,
+ _PUSH_EVENT_TYPE_UNREGISTRATION,
+ _PUSH_EVENT_TYPE_NOTIFICATION,
+ _PUSH_EVENT_TYPE_SEND
+};
+
+class _PushEventArg
+ : public Tizen::Base::Object
+ , public Tizen::Base::Runtime::IEventArg
+{
+public:
+ _PushEventArg(_PushEventType type, RequestId reqId, const Tizen::Base::String& data, const Tizen::Base::String& message, result ret, const Tizen::Base::String& errorCode, const Tizen::Base::String& errorMsg);
+ virtual ~_PushEventArg(void);
+
+public:
+ _PushEventType GetType(void) const;
+ RequestId GetRequestId(void) const;
+ Tizen::Base::String GetData(void) const;
+ Tizen::Base::String GetMessage(void) const;
+ result GetResult(void) const;
+ Tizen::Base::String GetErrorCode(void) const;
+ Tizen::Base::String GetErrorMsg(void) const;
+
+private:
+ _PushEventArg(void);
+ _PushEventArg(const _PushEventArg& rhs);
+ _PushEventArg& operator =(const _PushEventArg& rhs);
+
+private:
+ _PushEventType __type;
+ RequestId __reqId;
+ Tizen::Base::String __data;
+ Tizen::Base::String __message;
+ result __ret;
+ Tizen::Base::String __errorCode;
+ Tizen::Base::String __errorMsg;
+}; // _PushEventArg
+
+} } // Tizen::Messaging
+#endif // _FMSG_INTERNAL_PUSH_EVENT_ARG_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+* @file FMsg_PushManagerImpl.cpp
+* @brief This is the implementation file for the %_PushManagerImpl class.
+*
+* This file contains the implementation of the %_PushManagerImpl class.
+*/
+
+#include <unique_ptr.h>
+#include <app.h>
+#include <push.h>
+#include <FShellNotificationManager.h>
+#include <FIoDirectory.h>
+#include <FIoFile.h>
+#include <FIoRegistry.h>
+#include <FAppApp.h>
+#include <FSysSystemTime.h>
+#include <FMsgPushManager.h>
+#include <FWebJsonJsonObject.h>
+#include <FWebJsonJsonArray.h>
+#include <FWebJsonJsonString.h>
+#include <FWebJsonJsonWriter.h>
+#include <FApp_AppInfo.h>
+#include <FBaseSysLog.h>
+#include <FBaseColMultiHashMap.h>
+#include <FBase_StringConverter.h>
+#include "FMsg_PushManagerImpl.h"
+#include "FMsg_PushMessageImpl.h"
+#include "FMsg_PushEvent.h"
+#include "FMsg_PushEventArg.h"
+#include "FMsg_PushRequest.h"
+
+using namespace std;
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Io;
+using namespace Tizen::Net::Http;
+using namespace Tizen::Shell;
+using namespace Tizen::System;
+using namespace Tizen::Web::Json;
+
+namespace Tizen { namespace Messaging
+{
+
+static const int _MIN_PUSH_REQUEST_ID = 0;
+static const int _MAX_PUSH_REQUEST_ID = 10000;
+static const int _MAX_TRANSACTION_TIMEOUT = 60; // Secounds
+static const wchar_t _INVALID_PUSH_REGISTRATION_ID[] = L"";
+static const wchar_t _DEFAULT_NOTIFICATION_MESSAGE[] = L"";
+static const wchar_t _DEFAULT_SERVER_ERROR_CODE[] = L"";
+static const wchar_t _DEFAULT_SERVER_ERROR_MESSAGE[] = L"";
+static const wchar_t _PUSH_STATUS_REGISTRY_FILE[] = L"data/push.ini";
+static const wchar_t _PUSH_STATUS_REGISTRY_STATUS_SECTION[] = L"Status";
+static const wchar_t _PUSH_STATUS_REGISTRY_IS_REGISTERED_ENTRY[] = L"IsRegistered";
+static const wchar_t _PUSH_SERVER_REGISTRY_SERVER_SECTION[] = L"Server";
+static const wchar_t _PUSH_SERVER_REGISTRY_URL_ENTRY[] = L"Url";
+static const char _PUSH_SERVER_ERROR_APP_NOT_FOUND[] = "Failed to find application with given appId.";
+static const int _MAX_RECIPIENT_COUNT = 20;
+
+static RequestId lastRequestId = 0;
+
+result
+ConvertError(push_result_e res, const char* pServerError)
+{
+ if (pServerError != null)
+ {
+ SysLog(NID_MSG, "The current value of res is [%d], error is [%s].", res, pServerError);
+ }
+ else
+ {
+ SysLog(NID_MSG, "The current value of res is [%d].", res);
+ }
+
+ result r = E_SUCCESS;
+
+ if (res == PUSH_RESULT_SUCCESS)
+ {
+ r = E_SUCCESS;
+ }
+ else if (res == PUSH_RESULT_TIMEOUT)
+ {
+ r = E_CONNECTION_FAILED;
+ }
+ else if (res == PUSH_RESULT_SERVER_ERROR)
+ {
+ if (pServerError != null)
+ {
+ if (strcmp(pServerError, _PUSH_SERVER_ERROR_APP_NOT_FOUND) == 0)
+ {
+ r = E_SERVICE_UNAVAILABLE;
+ }
+ else
+ {
+ r = E_SERVER;
+ }
+ }
+ else
+ {
+ r = E_SERVER;
+ }
+ }
+ else
+ {
+ r = E_SYSTEM;
+ }
+
+ SysLog(NID_MSG, "[%s] error has been occurred.", GetErrorMessage(r));
+
+ return r;
+}
+
+void
+PushStateEventCallback(push_state_e state, const char* pError, void* pUserData)
+{
+ SysLog(NID_MSG, "The PushStateEventCallback is entering with state[%d].", state);
+
+ _PushManagerImpl* pManager = null;
+ char* pRegistrationId = null;
+
+ pManager = (_PushManagerImpl*)pUserData;
+ SysTryReturnVoidResult(NID_MSG, pManager != null, E_OBJ_NOT_FOUND, "[%s] A _PushManagerImpl instance is NULL.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+ if (state == PUSH_STATE_REGISTERED)
+ {
+ // Registered
+ push_get_registration_id((push_connection_h)pManager->GetPushHandle(), &pRegistrationId);
+ if (pRegistrationId != null)
+ {
+ SysLog(NID_MSG, "Registered, regId[%s].", pRegistrationId);
+ pManager->SetPushStatus(true, String(pRegistrationId));
+ free(pRegistrationId);
+ }
+ else
+ {
+ SysLog(NID_MSG, "Registered, but regId[NULL].");
+ pManager->SetPushStatus(false, _INVALID_PUSH_REGISTRATION_ID);
+ }
+ }
+ else if (state == PUSH_STATE_UNREGISTERED)
+ {
+ // Not registered
+ SysLog(NID_MSG, "Not registered.");
+ pManager->SetPushStatus(false, _INVALID_PUSH_REGISTRATION_ID);
+ }
+ else
+ {
+ // Error
+ SysLog(NID_MSG, "Error: state[%d] error[%s]", state, pError);
+
+ return;
+ }
+
+ pManager->SetPushHandleReady();
+ pManager->CheckNextRequest();
+
+ SysLog(NID_MSG, "The PushStateEventCallback is exiting.");
+
+ return;
+}
+
+void
+PushNotiEventCallback(push_notification_h noti, void* pUserData)
+{
+ SysLog(NID_MSG, "The PushNotiEventCallback is entering.");
+
+ _PushManagerImpl* pManager = null;
+ char* pAppData = null;
+ char* pNotiMessage = null;
+ String appData;
+ String notiMessage;
+
+ pManager = (_PushManagerImpl*)pUserData;
+ SysTryCatch(NID_MSG, pManager != null, , E_OBJ_NOT_FOUND, "[%s] A _PushManagerImpl instance is NULL.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+ push_get_notification_data(noti, &pAppData);
+ SysTryCatch(NID_MSG, pAppData != null, , E_INVALID_ARG, "[%s] Invalid arguments is used. appData is NULL.", GetErrorMessage(E_INVALID_ARG));
+
+ push_get_notification_message(noti, &pNotiMessage);
+
+ appData = String(pAppData);
+ free(pAppData);
+
+ if (appData.GetLength() > MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH)
+ {
+ SysLog(NID_MSG, "AppData's length(%d) is too large, so set length(%d).", appData.GetLength(), MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH);
+ appData.SetLength(MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH);
+ }
+
+ if (pNotiMessage != null)
+ {
+ notiMessage = String(pNotiMessage);
+ free(pNotiMessage);
+ }
+
+ pManager->HandlePushMessage(notiMessage, appData);
+
+ SysLog(NID_MSG, "The PushStateEventCallback is exiting.");
+
+ return;
+
+CATCH:
+ return;
+}
+
+void
+PushResultEventCallback(push_result_e res, const char* pServerError, void* pUserData)
+{
+ SysLog(NID_MSG, "The PushResultEventCallback is entering with result[%d].", res);
+
+ result r = E_SUCCESS;
+ _PushRequest* pRequest = null;
+ _PushManagerImpl* pManager = null;
+ char* pRegistrationId = null;
+ int ret = PUSH_ERROR_NONE;
+
+ pRequest = (_PushRequest*)pUserData;
+ SysTryReturnVoidResult(NID_MSG, pRequest != null, E_OBJ_NOT_FOUND, "[%s] A _PushRequest instance is NULL.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+ pManager = pRequest->GetPushManager();
+ SysTryReturnVoidResult(NID_MSG, pManager != null, E_OBJ_NOT_FOUND, "[%s] A _PushManagerImpl instance is NULL.", GetErrorMessage(E_OBJ_NOT_FOUND));
+
+ if (res == PUSH_RESULT_SUCCESS)
+ {
+ if (pRequest->GetType() == _PUSH_REQUEST_REGISTER)
+ {
+ push_get_registration_id((push_connection_h)pManager->GetPushHandle(), &pRegistrationId);
+ if (pRegistrationId != null)
+ {
+ SysLog(NID_MSG, "Registered, regId[%s].", pRegistrationId);
+ pManager->SetPushStatus(true, String(pRegistrationId));
+ free(pRegistrationId);
+ }
+ else
+ {
+ if (ret == PUSH_ERROR_OUT_OF_MEMORY)
+ {
+ r = E_OUT_OF_MEMORY;
+ }
+ else
+ {
+ r = E_SYSTEM;
+ }
+
+ SysLogException(NID_MSG, r, "[%s] Failed to get a registrationId.", GetErrorMessage(r));
+ }
+ }
+ else
+ {
+ SysLog(NID_MSG, "Unregistered.");
+ pManager->SetPushStatus(false, _INVALID_PUSH_REGISTRATION_ID);
+ }
+ }
+ else
+ {
+ r = ConvertError(res, pServerError);
+ }
+
+ if (pRequest->GetType() == _PUSH_REQUEST_REGISTER)
+ {
+ // Registration Request
+ pManager->HandlePushRegistrationResponse(pRequest->GetRequestId(), pManager->GetRegistrationId(), r);
+ }
+ else
+ {
+ // Unregistration Request
+ pManager->HandlePushUnregistrationResponse(pRequest->GetRequestId(), r);
+ }
+
+ pManager->RemoveRequest(pRequest);
+ pManager->UpdateActiveRequest(false);
+ pManager->CheckNextRequest();
+
+ SysLog(NID_MSG, "The PushResultEventCallback is exiting.");
+
+ return;
+}
+
+_PushManagerImpl::_PushManagerImpl(void)
+ : __pManagerListener(null)
+ , __pEventListener(null)
+ , __pEvent(null)
+ , __pHeader(null)
+ , __pSession(null)
+ , __pRequest(null)
+ , __pTransaction(null)
+ , __pBody(null)
+ , __pListener(null)
+ , __pUrlListener(null)
+ , __isRegistered(false)
+ , __pRequestList(null)
+ , __hasActiveRequest(false)
+ , __pPushHandle(null)
+ , __isPushHandleReady(false)
+{
+ __appSecret.Clear();
+ __registrationId.Clear();
+}
+
+_PushManagerImpl::~_PushManagerImpl(void)
+{
+ if (__pPushHandle != null)
+ {
+ push_disconnect((push_connection_h)__pPushHandle);
+ __pPushHandle = null;
+ }
+
+ if (__pRequestList != null)
+ {
+ __pRequestList->RemoveAll(true);
+ delete __pRequestList;
+ __pRequestList = null;
+ }
+
+ if (__pBody != null)
+ {
+ delete __pBody;
+ __pBody = null;
+ }
+
+ if (__pTransaction != null)
+ {
+ delete __pTransaction;
+ __pTransaction = null;
+ }
+
+ if (__pSession != null)
+ {
+ delete __pSession;
+ __pSession = null;
+ }
+
+ if (__pUrlListener != null)
+ {
+ delete __pUrlListener;
+ __pUrlListener = null;
+ }
+
+ if (__pListener != null)
+ {
+ delete __pListener;
+ __pListener = null;
+ }
+
+ if (__pEvent != null)
+ {
+ if (__pManagerListener != null)
+ {
+ __pEvent->RemoveListener(*__pManagerListener);
+ }
+
+ delete __pEvent;
+ __pEvent = null;
+ }
+
+ __pManagerListener = null;
+ __pEventListener = null;
+}
+
+result
+_PushManagerImpl::Construct(IPushManagerListener& managerListener, IPushEventListener& eventListener)
+{
+ SysLog(NID_MSG, "The Construct is entering.");
+
+ result r = E_SUCCESS;
+ int ret = PUSH_ERROR_NONE;
+ push_connection_h pushHandle = null;
+ String packageId;
+ char* pPackageId = null;
+
+ SysTryReturnResult(NID_MSG, __pPushHandle == null, E_INVALID_STATE, "The __pPushHandle instance is already constructed.");
+
+ unique_ptr<_PushEvent> pEvent;
+ unique_ptr<_PushSendListener> pListener;
+ unique_ptr<_PushUrlRequestListener> pUrlListener;
+ unique_ptr<ArrayList> pRequestList;
+
+ pEvent.reset(new (std::nothrow) _PushEvent(this));
+ SysTryCatch(NID_MSG, pEvent != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ r = pEvent->AddListener(managerListener);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to add an event listener.", GetErrorMessage(r));
+
+ pListener.reset(new (std::nothrow) _PushSendListener());
+ SysTryCatch(NID_MSG, pListener != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create push send listener.");
+
+ pUrlListener.reset(new (std::nothrow) _PushUrlRequestListener());
+ SysTryCatch(NID_MSG, pUrlListener != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create push send listener.");
+
+ 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.");
+
+ SysLog(NID_MSG, "Package ID is [%ls].", packageId.GetPointer());
+
+ pPackageId = _StringConverter::CopyToCharArrayN(packageId);
+ SysTryCatch(NID_MSG, pPackageId != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ ret = push_connect(pPackageId, PushStateEventCallback, PushNotiEventCallback, (void*)this, &pushHandle);
+ if (ret == PUSH_ERROR_NONE)
+ {
+ r = E_SUCCESS;
+ }
+ else if (ret == PUSH_ERROR_OUT_OF_MEMORY)
+ {
+ r = E_OUT_OF_MEMORY;
+ }
+ else
+ {
+ r = E_INVALID_STATE;
+ }
+
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to connect to push daemon.", GetErrorMessage(r));
+
+ __pPushHandle = (void*)pushHandle;
+
+ __pManagerListener = &managerListener;
+ __pEventListener = &eventListener;
+
+ __isRegistered = GetLastPushStatus();
+
+ delete[] pPackageId;
+ pPackageId = null;
+
+ __pRequestList = pRequestList.release();
+ __pUrlListener = pUrlListener.release();
+ __pListener = pListener.release();
+ __pEvent = pEvent.release();
+
+ SysLog(NID_MSG, "The Construct is exiting with result[%s] isRegistered[%d].", GetErrorMessage(r), __isRegistered);
+
+ return r;
+
+CATCH:
+ if (pPackageId != null)
+ {
+ delete[] pPackageId;
+ }
+
+ return r;
+}
+
+result
+_PushManagerImpl::RegisterPushService(RequestId& reqId)
+{
+ SysLog(NID_MSG, "The RegisterPushService is entering.");
+
+ result r = E_SUCCESS;
+ _PushRequest* pRequest = null;
+
+ SysTryReturnResult(NID_MSG, __pPushHandle != null, E_INVALID_STATE, "The __pPushHandle instance is not constructed yet.");
+
+ reqId = _PushManagerImpl::GetNextRequestId();
+
+ if ((HasPendingRequest() == true) || (IsPushHandleReady() == false))
+ {
+ SysLog(NID_MSG, "PendingRequest[%d] IsPushHandleReady[%d], so add to the queue.",
+ HasPendingRequest(), IsPushHandleReady());
+
+ pRequest = AddRequest(reqId, _PUSH_REQUEST_REGISTER);
+ r = GetLastResult();
+ SysTryReturn(NID_MSG, pRequest != null, r, r, "[%s] Failed to add to the queue.", GetErrorMessage(r));
+
+ return E_SUCCESS;
+ }
+
+ if (GetPushStatus() == false)
+ {
+ // NOT Registered
+ pRequest = AddRequest(reqId, _PUSH_REQUEST_REGISTER);
+ r = GetLastResult();
+ SysTryReturn(NID_MSG, pRequest != null, r, r, "[%s] Failed to add to the queue.", GetErrorMessage(r));
+
+ r = RequestPushRegistration(pRequest);
+ if (IsFailed(r))
+ {
+ RemoveRequest(pRequest);
+ }
+ }
+ else
+ {
+ // Already registered
+ SysLog(NID_MSG, "Already registered. regId[%ls]", __registrationId.GetPointer());
+
+ HandlePushRegistrationResponse(reqId, __registrationId, E_SUCCESS);
+ }
+
+ SysLog(NID_MSG, "The RegisterPushService is exiting with result[%s].", GetErrorMessage(r));
+
+ return r;
+}
+
+result
+_PushManagerImpl::UnregisterPushService(RequestId& reqId)
+{
+ SysLog(NID_MSG, "The UnregisterPushService is entering.");
+
+ result r = E_SUCCESS;
+ _PushRequest* pRequest = null;
+
+ SysTryReturnResult(NID_MSG, __pPushHandle != null, E_INVALID_STATE, "The __pPushHandle instance is not constructed yet.");
+
+ reqId = _PushManagerImpl::GetNextRequestId();
+
+ if ((HasPendingRequest() == true) || (IsPushHandleReady() == false))
+ {
+ SysLog(NID_MSG, "PendingRequest[%d] IsPushHandleReady[%d], so add to the queue.",
+ HasPendingRequest(), IsPushHandleReady());
+
+ pRequest = AddRequest(reqId, _PUSH_REQUEST_UNREGISTER);
+ r = GetLastResult();
+ SysTryReturn(NID_MSG, pRequest != null, r, r, "[%s] Failed to add to the queue.", GetErrorMessage(r));
+
+ return E_SUCCESS;
+ }
+
+ if (GetPushStatus() == true)
+ {
+ // Registered
+ pRequest = AddRequest(reqId, _PUSH_REQUEST_UNREGISTER);
+ r = GetLastResult();
+ SysTryReturn(NID_MSG, pRequest != null, r, r, "[%s] Failed to add to the queue.", GetErrorMessage(r));
+
+ r = RequestPushUnregistration(pRequest);
+ if (IsFailed(r))
+ {
+ RemoveRequest(pRequest);
+ }
+ }
+ else
+ {
+ // Already unregistered
+ SysLog(NID_MSG, "Already unregistered.");
+
+ HandlePushUnregistrationResponse(reqId, E_SUCCESS);
+ }
+
+ SysLog(NID_MSG, "The UnregisterPushService is exiting with result[%s].", GetErrorMessage(r));
+
+ return r;
+}
+
+bool
+_PushManagerImpl::IsPushServiceRegistered(void) const
+{
+ return GetPushStatus();
+}
+
+IList*
+_PushManagerImpl::GetUnreadMessagesN(void)
+{
+ SysLog(NID_MSG, "The GetUnreadMessagesN is entering.");
+
+ ClearLastResult();
+
+ IList* pList = null;
+ int ret = PUSH_ERROR_NONE;
+ push_notification_h notification;
+
+ SysTryReturn(NID_MSG, __pPushHandle != null, null, E_INVALID_STATE, "[E_INVALID_STATE] The __pPushHandle instance is not constructed yet.");
+
+ pList = new (std::nothrow) ArrayList;
+ SysTryReturn(NID_MSG, pList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ while (ret == PUSH_ERROR_NONE)
+ {
+ ret = push_get_unread_notification((push_connection_h)GetPushHandle(), ¬ification);
+
+ if ((ret == PUSH_ERROR_NONE) && (notification != null))
+ {
+ char* pNotiMessage = null;
+ char* pAppData = null;
+ long long int notiTime = 0;
+ DateTime receivedTime;
+ String appData;
+ String notiMessage;
+ PushMessage* pMessage = null;
+
+ push_get_notification_message(notification, &pNotiMessage);
+ if (pNotiMessage != null)
+ {
+ SysLog(NID_MSG, "NotiMessage=[%s].", pNotiMessage);
+ notiMessage = String(pNotiMessage);
+ free(pNotiMessage);
+ }
+ else
+ {
+ SysLog(NID_MSG, "NotiMessage=NULL.");
+ }
+
+ push_get_notification_time(notification, ¬iTime);
+
+ push_get_notification_data(notification, &pAppData);
+ push_free_notification(notification);
+ if (pAppData != null)
+ {
+ SysLog(NID_MSG, "AppData=[%s].", pAppData);
+ appData = String(pAppData);
+ free(pAppData);
+
+ if (appData.GetLength() > MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH)
+ {
+ SysLog(NID_MSG, "AppData's length(%d) is too large, so set length(%d).", appData.GetLength(), MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH);
+ appData.SetLength(MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH);
+ }
+ }
+ else
+ {
+ SysLog(NID_MSG, "AppData=NULL, so ignore this message.");
+ continue;
+ }
+
+ receivedTime = _PushMessageImpl::ConvertTime(notiTime);
+
+ pMessage = _PushMessageImpl::CreatePushMessageN(receivedTime, appData);
+ if (pMessage != null)
+ {
+ _PushMessageImpl::GetInstance(*pMessage)->ConvertMessageToNotification(notiMessage);
+ pList->Add(*pMessage);
+ }
+ }
+ else
+ {
+ SysLog(NID_MSG, "push_get_unread_notification() ret=[%d].", ret);
+ break;
+ }
+ }
+
+ SysLog(NID_MSG, "The GetUnreadMessagesN is exiting with (%d) unread messages.", pList->GetCount());
+
+ return pList;
+}
+
+result
+_PushManagerImpl::SendPushMessage(const PushMessage& message, const String& registrationId, const String& appSecret, RequestId& reqId)
+{
+ SysLog(NID_MSG, "The SendPushMessage is entering.");
+
+ result r = E_SUCCESS;
+ _PushRequest* pRequest = null;
+
+ SysTryReturnResult(NID_MSG, __pPushHandle != null, E_INVALID_STATE, "The __pPushHandle instance is not constructed yet.");
+
+ __appSecret = appSecret;
+
+ reqId = _PushManagerImpl::GetNextRequestId();
+
+ pRequest = new (std::nothrow) _PushRequest(this, reqId, _PUSH_REQUEST_SEND);
+ SysTryReturn(NID_MSG, pRequest != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ r = RequestPushSendMessageSingle(pRequest, message, registrationId);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "[%s] Failed to send push message to single device.", GetErrorMessage(r));
+
+ SysLog(NID_MSG, "The SendPushMessage is exiting with result[%s].", GetErrorMessage(r));
+
+ return r;
+}
+
+result
+_PushManagerImpl::SendPushMessage(const PushMessage& message, const IList& registrationIdList, const String& appSecret, RequestId& reqId)
+{
+ SysLog(NID_MSG, "The SendPushMessage is entering.");
+
+ result r = E_SUCCESS;
+ _PushRequest* pRequest = null;
+ int count = 0;
+
+ SysTryReturnResult(NID_MSG, __pPushHandle != null, E_INVALID_STATE, "The __pPushHandle instance is not constructed yet.");
+
+ count = registrationIdList.GetCount();
+ SysTryReturnResult(NID_MSG, count > 0, E_INVALID_ARG, "The list of registration IDs is empty.");
+
+ __appSecret = appSecret;
+
+ reqId = _PushManagerImpl::GetNextRequestId();
+
+ pRequest = new (std::nothrow) _PushRequest(this, reqId, _PUSH_REQUEST_SEND);
+ SysTryReturn(NID_MSG, pRequest != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ r = RequestPushSendMessageMultiple(pRequest, message, registrationIdList);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "[%s] Failed to send push message to multiple devices.", GetErrorMessage(r));
+
+ SysLog(NID_MSG, "The SendPushMessage is exiting with result[%s].", GetErrorMessage(r));
+
+ return r;
+}
+
+int
+_PushManagerImpl::GetMaxRecipientCount(void)
+{
+ return _MAX_RECIPIENT_COUNT;
+}
+
+_PushManagerImpl*
+_PushManagerImpl::GetInstance(PushManager& pushManager)
+{
+ return pushManager.__pPushManagerImpl;
+}
+
+const _PushManagerImpl*
+_PushManagerImpl::GetInstance(const PushManager& pushManager)
+{
+ return pushManager.__pPushManagerImpl;
+}
+
+void
+_PushManagerImpl::HandlePushEvent(_PushEventArg& eventArg)
+{
+ SysLog(NID_MSG, "The HandlePushEvent is entering with type(%d).", eventArg.GetType());
+
+ result r = E_SUCCESS;
+ DateTime time;
+ PushMessage* pMessage = null;
+
+ switch (eventArg.GetType())
+ {
+ case _PUSH_EVENT_TYPE_REGISTRATION:
+ if (__pManagerListener != null)
+ {
+ SysLog(NID_MSG, "Calling OnPushServiceRegistered().");
+
+ __pManagerListener->OnPushServiceRegistered(eventArg.GetRequestId(), eventArg.GetData(), eventArg.GetResult(),
+ _DEFAULT_SERVER_ERROR_CODE, _DEFAULT_SERVER_ERROR_MESSAGE);
+
+ SysLog(NID_MSG, "Called OnPushServiceRegistered().");
+ }
+ break;
+
+ case _PUSH_EVENT_TYPE_UNREGISTRATION:
+ if (__pManagerListener != null)
+ {
+ SysLog(NID_MSG, "Calling OnPushServiceUnregistered().");
+
+ __pManagerListener->OnPushServiceUnregistered(eventArg.GetRequestId(), eventArg.GetResult(),
+ _DEFAULT_SERVER_ERROR_CODE, _DEFAULT_SERVER_ERROR_MESSAGE);
+
+ SysLog(NID_MSG, "Called OnPushServiceUnregistered().");
+ }
+ break;
+
+ case _PUSH_EVENT_TYPE_NOTIFICATION:
+ r = SystemTime::GetCurrentTime(time);
+ if (r == E_SUCCESS)
+ {
+ pMessage = _PushMessageImpl::CreatePushMessageN(time, eventArg.GetData());
+ if (pMessage != null)
+ {
+ _PushMessageImpl::GetInstance(*pMessage)->ConvertMessageToNotification(eventArg.GetMessage());
+ if (__pEventListener != null)
+ {
+ SysLog(NID_MSG, "Calling OnPushMessageReceived().");
+
+ __pEventListener->OnPushMessageReceived(*pMessage);
+
+ SysLog(NID_MSG, "Called OnPushMessageReceived().");
+ }
+
+ delete pMessage;
+ }
+ }
+ break;
+
+ case _PUSH_EVENT_TYPE_SEND:
+ if (__pManagerListener != null)
+ {
+ SysLog(NID_MSG, "Calling OnPushMessageSent().");
+
+ __pManagerListener->OnPushMessageSent(eventArg.GetRequestId(), eventArg.GetData(), eventArg.GetResult(),
+ eventArg.GetErrorCode(), eventArg.GetErrorMsg());
+
+ SysLog(NID_MSG, "Called OnPushMessageSent().");
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ SysLog(NID_MSG, "The HandlePushEvent is exiting.");
+
+ return;
+}
+
+void
+_PushManagerImpl::HandlePushRegistrationResponse(RequestId reqId, const String& registrationId, result r)
+{
+ SysLog(NID_MSG, "The HandlePushRegistrationResponse is entering with reqId[%d] result[%s] registrationId[%ls].",
+ reqId, GetErrorMessage(r), registrationId.GetPointer());
+
+ _PushEventArg* pEventArg = null;
+
+ if ((__pManagerListener != null) && (__pEvent != null))
+ {
+ pEventArg = new (std::nothrow) _PushEventArg(_PUSH_EVENT_TYPE_REGISTRATION, reqId, registrationId, _DEFAULT_NOTIFICATION_MESSAGE, r, _DEFAULT_SERVER_ERROR_CODE, _DEFAULT_SERVER_ERROR_MESSAGE);
+ if (pEventArg != null)
+ {
+ __pEvent->FireAsync(*pEventArg);
+ }
+ }
+
+ SysLog(NID_MSG, "The HandlePushRegistrationResponse is exiting.");
+}
+
+void
+_PushManagerImpl::HandlePushUnregistrationResponse(RequestId reqId, result r)
+{
+ SysLog(NID_MSG, "The HandlePushUnregistrationResponse is entering with reqId[%d] result[%s].", reqId, GetErrorMessage(r));
+
+ _PushEventArg* pEventArg = null;
+
+ if ((__pManagerListener != null) && (__pEvent != null))
+ {
+ pEventArg = new (std::nothrow) _PushEventArg(_PUSH_EVENT_TYPE_UNREGISTRATION, reqId, _INVALID_PUSH_REGISTRATION_ID, _DEFAULT_NOTIFICATION_MESSAGE, r, _DEFAULT_SERVER_ERROR_CODE, _DEFAULT_SERVER_ERROR_MESSAGE);
+ if (pEventArg != null)
+ {
+ __pEvent->FireAsync(*pEventArg);
+ }
+ }
+
+ SysLog(NID_MSG, "The HandlePushUnregistrationResponse is exiting.");
+}
+
+void
+_PushManagerImpl::HandlePushMessage(const String& notiMessage, const String& payload)
+{
+ SysLog(NID_MSG, "The HandlePushMessage is entering with notiMessage[%ls] payload[%ls].",
+ notiMessage.GetPointer(), payload.GetPointer());
+
+ _PushEventArg* pEventArg = null;
+
+ if ((__pEventListener != null) && (__pEvent != null))
+ {
+ pEventArg = new (std::nothrow) _PushEventArg(_PUSH_EVENT_TYPE_NOTIFICATION, INVALID_REQUEST_ID, payload, notiMessage, E_SUCCESS, _DEFAULT_SERVER_ERROR_CODE, _DEFAULT_SERVER_ERROR_MESSAGE);
+ if (pEventArg != null)
+ {
+ __pEvent->FireAsync(*pEventArg);
+ }
+ }
+
+ SysLog(NID_MSG, "The HandlePushMessage is exiting.");
+}
+
+void
+_PushManagerImpl::HandlePushSendMessageResponse(RequestId reqId, const String& registrationId, result r, const String& errorCode, const String& errorMsg)
+{
+ SysLog(NID_MSG, "The HandlePushSendMessageResponse is entering with reqId[%d] registrationId[%ls] result[%s] errorCode[%ls] errorMsg[%ls].",
+ reqId, registrationId.GetPointer(), GetErrorMessage(r), errorCode.GetPointer(), errorMsg.GetPointer());
+
+ _PushEventArg* pEventArg = null;
+
+ if ((__pEventListener != null) && (__pEvent != null))
+ {
+ pEventArg = new (std::nothrow) _PushEventArg(_PUSH_EVENT_TYPE_SEND, reqId, registrationId, _DEFAULT_NOTIFICATION_MESSAGE, r, errorCode, errorMsg);
+ if (pEventArg != null)
+ {
+ __pEvent->FireAsync(*pEventArg);
+ }
+ }
+
+ SysLog(NID_MSG, "The HandlePushSendMessageResponse is exiting.");
+}
+
+void
+_PushManagerImpl::SetPushStatus(bool isRegistered, const String& registrationId)
+{
+ if (isRegistered != __isRegistered)
+ {
+ UpdateLastPushStatus(isRegistered);
+ }
+
+ __isRegistered = isRegistered;
+ __registrationId = registrationId;
+}
+
+bool
+_PushManagerImpl::GetPushStatus(void) const
+{
+ return __isRegistered;
+}
+
+String
+_PushManagerImpl::GetRegistrationId(void) const
+{
+ return __registrationId;
+}
+
+void*
+_PushManagerImpl::GetPushHandle(void) const
+{
+ return __pPushHandle;
+}
+
+void
+_PushManagerImpl::SetPushHandleReady(void)
+{
+ __isPushHandleReady = true;
+}
+
+bool
+_PushManagerImpl::IsPushHandleReady(void) const
+{
+ return __isPushHandleReady;
+}
+
+_PushRequest*
+_PushManagerImpl::AddRequest(RequestId reqId, _PushRequestType type)
+{
+ SysLog(NID_MSG, "The AddRequest is entering.");
+
+ ClearLastResult();
+
+ result r = E_SUCCESS;
+ _PushRequest* pRequest = null;
+
+ pRequest = new (std::nothrow) _PushRequest(this, reqId, type);
+ SysTryReturn(NID_MSG, pRequest != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ r = __pRequestList->Add(*pRequest);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to add the request.", GetErrorMessage(r));
+
+ delete pRequest;
+ return null;
+ }
+
+ SysLog(NID_MSG, "The AddRequest is exiting.");
+
+ return pRequest;
+}
+
+_PushRequest*
+_PushManagerImpl::GetNextRequest(void)
+{
+ Object* pObject = null;
+ _PushRequest* pRequest = null;
+
+ pObject = __pRequestList->GetAt(0);
+ if (pObject != null)
+ {
+ pRequest = dynamic_cast<_PushRequest*>(pObject);
+ }
+
+ return pRequest;
+}
+
+void
+_PushManagerImpl::RemoveRequest(_PushRequest* pRequest)
+{
+ __pRequestList->Remove(*pRequest, true);
+
+ return;
+}
+
+bool
+_PushManagerImpl::HasPendingRequest(void) const
+{
+ int count = 0;
+ bool ret = false;
+
+ count = __pRequestList->GetCount();
+
+ if (count > 0)
+ {
+ ret = true;
+ }
+ else
+ {
+ ret = false;
+ }
+
+ return ret;
+}
+
+bool
+_PushManagerImpl::HasActiveRequest(void) const
+{
+ return __hasActiveRequest;
+}
+
+void
+_PushManagerImpl::UpdateActiveRequest(bool hasActiveRequest)
+{
+ __hasActiveRequest = hasActiveRequest;
+}
+
+void
+_PushManagerImpl::CheckNextRequest(void)
+{
+ SysLog(NID_MSG, "The CheckNextRequest is entering.");
+
+ result r = E_SUCCESS;
+ _PushRequest* pRequest = null;
+
+ if (IsPushHandleReady() == false)
+ {
+ SysLog(NID_MSG, "PushHandle is NOT ready.");
+ return;
+ }
+
+ if (HasActiveRequest() == true)
+ {
+ SysLog(NID_MSG, "ActiveRequest exists.");
+ return;
+ }
+
+ pRequest = GetNextRequest();
+ while (pRequest != null)
+ {
+ if (pRequest->GetType() == _PUSH_REQUEST_REGISTER)
+ {
+ // Register
+ if (GetPushStatus() == false)
+ {
+ // NOT Registered
+ r = RequestPushRegistration(pRequest);
+ if (IsFailed(r))
+ {
+ HandlePushRegistrationResponse(pRequest->GetRequestId(), _INVALID_PUSH_REGISTRATION_ID, r);
+ }
+ else
+ {
+ // Send a request, so waiting the response.
+ return;
+ }
+ }
+ else
+ { // Already registered
+ SysLog(NID_MSG, "Already registered. regId[%ls]", __registrationId.GetPointer());
+
+ HandlePushRegistrationResponse(pRequest->GetRequestId(), __registrationId, E_SUCCESS);
+ }
+ }
+ else
+ {
+ // Unregister
+ if (GetPushStatus() == true)
+ {
+ // Registered
+ r = RequestPushUnregistration(pRequest);
+ if (IsFailed(r))
+ {
+ HandlePushUnregistrationResponse(pRequest->GetRequestId(), r);
+ }
+ else
+ {
+ // Send a request, so waiting the response.
+ return;
+ }
+ }
+ else
+ {
+ // Already unregistered
+ SysLog(NID_MSG, "Already unregistered.");
+
+ HandlePushUnregistrationResponse(pRequest->GetRequestId(), E_SUCCESS);
+ }
+ }
+
+ RemoveRequest(pRequest);
+ pRequest = GetNextRequest();
+ }
+
+ SysLog(NID_MSG, "The CheckNextRequest is exiting.");
+}
+
+String
+_PushManagerImpl::GetAppSecret(void) const
+{
+ return __appSecret;
+}
+
+result
+_PushManagerImpl::GetUrlFromRegistrationId(const String& registrationId, const _PushRequest* pRequest, const PushMessage& pushMessage, const IList& registrationIdList, String& url)
+{
+ SysLog(NID_MSG, "The GetUrlFromRegistrationId is entering.");
+
+ result r = E_SUCCESS;
+
+ String prefix("");
+
+ r = registrationId.SubString(0,2, prefix);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_INVALID_ARG, E_INVALID_ARG, "[%s] Failed to get the prefix from registration ID", GetErrorMessage(r));
+
+ if (prefix.Equals("00", false))
+ {
+ SysLog(NID_MSG, "Region : US East");
+ url = "https://useast.push.samsungosp.com:8088/spp/pns/api/push";
+ }
+ else if (prefix.Equals("01", false))
+ {
+ SysLog(NID_MSG, "Region : US West");
+ url = "https://uswest.push.samsungosp.com:8088/spp/pns/api/push";
+ }
+ else if (prefix.Equals("02", false))
+ {
+ SysLog(NID_MSG, "Region : Asia Pacific southeast");
+ url = "https://apsoutheast.push.samsungosp.com:8088/spp/pns/api/push";
+ }
+ else if (prefix.Equals("03", false))
+ {
+ SysLog(NID_MSG, "Region : EU West");
+ url = "https://euwest.push.samsungosp.com:8088/spp/pns/api/push";
+ }
+ else if (prefix.Equals("04", false))
+ {
+ SysLog(NID_MSG, "Region : Asia Pacific Northeast");
+ url = "https://apnortheast.push.samsungosp.com:8088/spp/pns/api/push";
+ }
+ else if (prefix.Equals("05", false))
+ {
+ SysLog(NID_MSG, "Region : Korea");
+ url = "https://apkorea.push.samsungosp.com:8088/spp/pns/api/push";
+ }
+ else if (prefix.Equals("06", false))
+ {
+ SysLog(NID_MSG, "Region : China");
+ url = "https://apchina.push.samsungosp.com.cn:8088/spp/pns/api/push";
+ }
+ else if (prefix.Equals("7c", false))
+ {
+ SysLog(NID_MSG, "Region : Staging");
+ url = "https://175.41.248.50:8088/spp/pns/api/push";
+ }
+ else
+ {
+ url = GetPushServerUrl();
+
+ if (url.IsEmpty() != true)
+ {
+ SysLog(NID_MSG, "Region : Get url from registry");
+ }
+ else
+ {
+ SysLog(NID_MSG, "Region : Query url to server");
+
+ r = QueryServerUrl(prefix, pRequest, pushMessage, registrationIdList);
+ r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+ SysTryReturnResult(NID_MSG, r == E_SUCCESS, r, "Failed to query server url by regionID.");
+ }
+ }
+
+ SysLog(NID_MSG, "The GetUrlFromRegistrationId is exiting.");
+
+ return r;
+}
+
+result
+_PushManagerImpl::QueryServerUrl(const String& prefix, const _PushRequest* pRequest, const PushMessage& pushMessage, const IList& registrationIdList)
+{
+ SysLog(NID_MSG, "The QueryServerUrl is entering.");
+
+ result r = E_SUCCESS;
+
+ String url(L"https://gld.push.samsungosp.com:8089/spp/pns/dr/pushurl");
+ Uri uri;
+ int timeout = _MAX_TRANSACTION_TIMEOUT;
+ HttpUrlEncodedEntity* pHttpUrlEncodedEntity = null;
+ PushMessage* pPushMessage = null;
+ ArrayList* pRegistrationIdList = null;
+ _UserData* pUserData = null;
+ int count = 0;
+
+ r = uri.SetUri(url);
+ r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Invalid URL.", GetErrorMessage(r));
+
+ if(__pSession == null)
+ {
+ // Create Http session
+ __pSession = new (std::nothrow) HttpSession();
+ SysTryCatch(NID_MSG, __pSession != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create the Http session.");
+
+ r = __pSession->Construct(NET_HTTP_SESSION_MODE_MULTIPLE_HOST, null, L"", null);
+ r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to construct Http session.", GetErrorMessage(r));
+ }
+
+ __pTransaction = __pSession->OpenTransactionN();
+ SysTryCatch(NID_MSG, __pTransaction != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create the Http transaction.");
+
+ r = __pTransaction->SetTimeout(timeout);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to set timeout.", GetErrorMessage(r));
+
+ pPushMessage = new (std::nothrow) PushMessage(pushMessage);
+ SysTryCatch(NID_MSG, pPushMessage != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create the pushMessage.");
+
+ pRegistrationIdList = new (std::nothrow) ArrayList();
+ SysTryCatch(NID_MSG, pRegistrationIdList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create the registration Id list.");
+
+ count = registrationIdList.GetCount();
+ SysLog(NID_MSG, "Query url server count [%d]", count);
+
+ r = pRegistrationIdList->Construct(count);
+ r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to construct registration Id list.", GetErrorMessage(r));
+
+ for(int i = 0; i < count; i++)
+ {
+ String* pTemStr = null;
+ pTemStr = new (std::nothrow) String(*(String*)((registrationIdList.GetAt(i))));
+ SysTryCatch(NID_MSG, pTemStr != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create string.");
+
+ pRegistrationIdList->Add(*pTemStr);
+ }
+
+ __pUrlListener->SetParams(pRequest);
+
+ r = __pTransaction->AddHttpTransactionListener(*__pUrlListener);
+ r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to add http transaction listener.", GetErrorMessage(r));
+
+ __pRequest = __pTransaction->GetRequest();
+
+ r = __pRequest->SetMethod(NET_HTTP_METHOD_POST);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to set method into the http request.", GetErrorMessage(r));
+
+ r = __pRequest->SetUri(url);
+ r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to set uri into the http request.", GetErrorMessage(r));
+
+ // Create Http url encoded entity
+ pHttpUrlEncodedEntity = new (std::nothrow) HttpUrlEncodedEntity();
+ SysTryCatch(NID_MSG, pHttpUrlEncodedEntity != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create the Http url encoded entity.");
+
+ r = pHttpUrlEncodedEntity->Construct();
+ r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to construct http url encoded entity.", GetErrorMessage(r));
+
+ r = pHttpUrlEncodedEntity->AddParameter(L"serverid", prefix);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to add parameter into the http url encoded entity.", GetErrorMessage(r));
+
+ r = __pRequest->SetEntity(*pHttpUrlEncodedEntity);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to set entity into the http url encoded entity.", GetErrorMessage(r));
+
+ pUserData = new (std::nothrow) _UserData(pHttpUrlEncodedEntity, pPushMessage, pRegistrationIdList);
+ SysTryCatch(NID_MSG, pUserData != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ r = __pTransaction->SetUserObject(pUserData);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to set user object the http transaction.", GetErrorMessage(r));
+
+ r = __pTransaction->Submit();
+ r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to submit for http transaction.", GetErrorMessage(r));
+
+ SysLog(NID_MSG, "The QueryServerUrl is exiting with result[%s].", GetErrorMessage(r));
+
+ return r;
+
+CATCH:
+
+ delete pHttpUrlEncodedEntity;
+ pHttpUrlEncodedEntity = null;
+
+ delete pPushMessage;
+ pPushMessage = null;
+
+ delete pRegistrationIdList;
+ pRegistrationIdList = null;
+
+ delete pUserData;
+ pUserData = null;
+
+ delete __pTransaction;
+ __pTransaction = null;
+
+ delete __pSession;
+ __pSession = null;
+
+ return r;
+}
+
+result
+_PushManagerImpl::SendHttpRequest(const String& url, const _PushRequest* pRequest, const PushMessage& pushMessage, const IList& registrationIdList)
+{
+ SysLog(NID_MSG, "The SendHttpRequest is entering.");
+
+ result r = E_SUCCESS;
+
+ Uri uri;
+ int timeout = _MAX_TRANSACTION_TIMEOUT;
+ int length = 0;
+ String lengthAsString(L"");
+ String packageId(L"");
+ String appSecret(L"");
+
+ r = uri.SetUri(url);
+ r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Invalid URL.", GetErrorMessage(r));
+
+ if(__pSession == null)
+ {
+ // Create Http session
+ __pSession = new (std::nothrow) HttpSession();
+ SysTryCatch(NID_MSG, __pSession != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create the Http session.");
+
+ r = __pSession->Construct(NET_HTTP_SESSION_MODE_MULTIPLE_HOST, null, L"", null);
+ r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to construct Http session.", GetErrorMessage(r));
+ }
+
+ __pTransaction = __pSession->OpenTransactionN();
+ SysTryCatch(NID_MSG, __pTransaction != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create the Http transaction.");
+
+ r = __pTransaction->SetTimeout(timeout);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to set timeout.", GetErrorMessage(r));
+
+ __pListener->SetParams(pRequest);
+
+ r = __pTransaction->AddHttpTransactionListener(*__pListener);
+ r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to add http transaction listener.", GetErrorMessage(r));
+
+ __pRequest = __pTransaction->GetRequest();
+
+ r = __pRequest->SetMethod(NET_HTTP_METHOD_POST);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to set method into the http request.", GetErrorMessage(r));
+
+ r = __pRequest->SetUri(url);
+ r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to set uri into the http request.", GetErrorMessage(r));
+
+ // 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.");
+
+ appSecret = GetAppSecret();
+
+ r = __pHeader->AddField(L"appID", packageId);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to add appId field into the http header.", GetErrorMessage(r));
+
+ r = __pHeader->AddField(L"appSecret", appSecret);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to add appSecret field into the http header.", GetErrorMessage(r));
+
+ r = __pHeader->AddField(L"content-Type", L"application/json");
+ SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to add content-type field into the http header.", GetErrorMessage(r));
+
+ // Create Http Request Body
+ __pBody = new (std::nothrow) ByteBuffer;
+ SysTryCatch(NID_MSG, __pBody != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create the bytebuffer.");
+
+ r = ComposeJsonObject(pRequest, pushMessage, registrationIdList, *__pBody);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to compose Json object.", GetErrorMessage(r));
+
+ length = __pBody->GetLimit();
+
+ lengthAsString.Append(length);
+ r = __pHeader->AddField(L"content-Length", lengthAsString);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to add content-length field into the http header.", GetErrorMessage(r));
+
+ r = __pRequest->WriteBody(*__pBody);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to write body into the http request.", GetErrorMessage(r));
+
+ r = __pTransaction->Submit();
+ r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to submit for http transaction.", GetErrorMessage(r));
+
+ SysLog(NID_MSG, "The SendHttpRequest is exiting with result[%s].", GetErrorMessage(r));
+
+ return r;
+
+CATCH:
+ if (__pBody)
+ {
+ delete __pBody;
+ __pBody = null;
+ }
+
+ if (__pTransaction)
+ {
+ delete __pTransaction;
+ __pTransaction = null;
+ }
+
+ if (__pSession)
+ {
+ delete __pSession;
+ __pSession = null;
+ }
+
+ return r;
+}
+
+result
+_PushManagerImpl::ComposeJsonObject(const _PushRequest* pRequest, const PushMessage& pushMessage, const IList& registrationIdList, ByteBuffer& buffer) const
+{
+ SysLog(NID_MSG, "The ComposeJsonObject is entering.");
+
+ result r = E_SUCCESS;
+
+ int count = 0;
+ JsonObject* pJsonObj = null;
+ JsonArray* pJsonArray = null;
+ JsonString* pKey1 = null;
+ JsonString* pKey2 = null;
+ JsonString* pKey3 = null;
+ JsonString* pKey4 = null;
+ JsonString* pValue1 = null;
+ JsonString* pValue2 = null;
+ JsonString* pValue3 = null;
+ JsonString* pValue4 = null;
+
+ String* pTempStr = null;
+
+ String reqId(L"");
+ reqId.Append(pRequest->GetRequestId());
+
+ NotificationRequest notificationMessage;
+ String badgeOption(L"");
+ String badgeNumber(L"");
+ String action(L"");
+ String alertMessage(L"");
+ String message(L"");
+
+ notificationMessage = pushMessage.GetNotification();
+
+ String appData = notificationMessage.GetAppMessage();
+
+ int pushBadgeNumber = notificationMessage.GetBadgeNumber();
+ int pushBadgeOption = notificationMessage.GetBadgeOffset();
+
+ if (0 <= pushBadgeNumber)
+ {
+ badgeOption.Append("badgeOption=SET&");
+ badgeNumber.Append("badgeNumber=");
+ badgeNumber.Append(pushBadgeNumber);
+ badgeNumber.Append("&");
+ }
+
+ if (0 < pushBadgeOption)
+ {
+ badgeOption.Append("badgeOption=INCREASE&");
+ badgeNumber.Append("badgeNumber=");
+ badgeNumber.Append(pushBadgeOption);
+ badgeNumber.Append("&");
+ }
+ else if (pushBadgeOption < 0)
+ {
+ badgeOption.Append("badgeOption=DECREASE&");
+ badgeNumber.Append("badgeNumber=");
+ badgeNumber.Append(pushBadgeOption);
+ badgeNumber.Append("&");
+ }
+
+ PushAction pushAction = pushMessage.GetAction();
+ if (pushAction == PUSH_ACTION_SILENT)
+ {
+ action.Append("action=SILENT");
+ }
+ else if (pushAction == PUSH_ACTION_DISCARD)
+ {
+ action.Append("action=DISCARD");
+ }
+ else
+ {
+ action.Append("action=ALERT");
+ }
+
+ String alertText1 = notificationMessage.GetAlertText();
+ String alertText2;
+ if (alertText1.IsEmpty() != true)
+ {
+ r = UrlEncoder::Encode(alertText1, L"UTF-8", alertText2);
+ r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to encode from UrlEncoder.", GetErrorMessage(r));
+
+ alertMessage.Append("&alertMessage=");
+ alertMessage.Append(alertText2);
+ }
+
+ message.Append(badgeOption);
+ message.Append(badgeNumber);
+ message.Append(action);
+ message.Append(alertMessage);
+
+ pJsonObj = new (std::nothrow) JsonObject();
+ pJsonObj->Construct();
+
+ pKey1 = new (std::nothrow) JsonString(L"regID");
+ pKey2 = new (std::nothrow) JsonString(L"requestID");
+ pKey3 = new (std::nothrow) JsonString(L"message");
+ pKey4 = new (std::nothrow) JsonString(L"appData");
+
+ SysLog(NID_MSG, "Address PushMessage [%x]", const_cast<PushMessage*>(&pushMessage));
+ SysLog(NID_MSG, "Address RegistrationIdList [%x]", const_cast<IList*>(®istrationIdList));
+
+ count = registrationIdList.GetCount();
+
+ if (count == 1)
+ {
+ pTempStr = (String*) (registrationIdList.GetAt(0));
+ pValue1 = new (std::nothrow) JsonString(static_cast<JsonString*>(pTempStr)->String::GetPointer());
+ pJsonObj->Add(pKey1, pValue1);
+
+ SysLog(NID_MSG, "####### JsonString %d #######", count);
+ }
+ else
+ {
+ pJsonArray = new (std::nothrow) JsonArray();
+ pJsonArray->Construct();
+
+ for (int i = 0; i < count; i++)
+ {
+ pTempStr = (String*) (registrationIdList.GetAt(i));
+ SysLog(NID_MSG, "pTempStr [%ls].", pTempStr->GetPointer());
+ pValue1 = new (std::nothrow) JsonString(static_cast<JsonString*>(pTempStr)->String::GetPointer());
+ pJsonArray->Add(pValue1);
+ }
+ pJsonObj->Add(pKey1, pJsonArray);
+
+ SysLog(NID_MSG, "####### JsonArray %d #######", count);
+ }
+
+ pValue2 = new (std::nothrow) JsonString(reqId);
+ pValue3 = new (std::nothrow) JsonString(message);
+ pValue4 = new (std::nothrow) JsonString(appData);
+
+ pJsonObj->Add(pKey2, pValue2);
+ pJsonObj->Add(pKey3, pValue3);
+ pJsonObj->Add(pKey4, pValue4);
+
+ r = JsonWriter::Compose(pJsonObj, buffer);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to compose Json object.", GetErrorMessage(r));
+
+ SysLog(NID_MSG, "####### Request message : %s #######", buffer.GetPointer());
+
+ pJsonObj->RemoveAll(true);
+ delete pJsonObj;
+
+ SysLog(NID_MSG, "The ComposeJsonObject is exiting with result[%s].", GetErrorMessage(r));
+
+ return r;
+
+CATCH:
+ if (pJsonObj)
+ {
+ pJsonObj->RemoveAll(true);
+ delete pJsonObj;
+ pJsonObj = null;
+ }
+
+ return r;
+}
+
+RequestId
+_PushManagerImpl::GetNextRequestId(void)
+{
+ if (lastRequestId >= _MAX_PUSH_REQUEST_ID)
+ {
+ lastRequestId = _MIN_PUSH_REQUEST_ID;
+ }
+
+ lastRequestId++;
+
+ return lastRequestId;
+}
+
+result
+_PushManagerImpl::RequestPushRegistration(const _PushRequest* pRequest)
+{
+ SysLog(NID_MSG, "The RequestPushRegistration is entering.");
+
+ result r = E_SUCCESS;
+ int ret = PUSH_ERROR_NONE;
+ char* pAppId = null;
+ service_h svc;
+
+ 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());
+
+ pAppId = _StringConverter::CopyToCharArrayN(appId);
+ SysTryReturnResult(NID_MSG, pAppId != null, E_SYSTEM, "Failed to get the application ID.");
+
+ SysLog(NID_MSG, "AppId=[%s].", pAppId);
+
+ ret = service_set_app_id(svc, pAppId);
+ delete[] pAppId;
+ if (ret != SERVICE_ERROR_NONE)
+ {
+ SysLogException(NID_MSG, E_SYSTEM, "[E_SYSTEM] service_set_package() is failed[%d].", ret);
+ service_destroy(svc);
+
+ return E_SYSTEM;
+ }
+
+ ret = push_register((push_connection_h)GetPushHandle(), svc, PushResultEventCallback, (void*)pRequest);
+ service_destroy(svc);
+ if (ret == PUSH_ERROR_NONE)
+ {
+ SysLog(NID_MSG, "push_register() is successful.");
+ UpdateActiveRequest(true);
+ }
+ else if (ret == PUSH_ERROR_OUT_OF_MEMORY)
+ {
+ SysLogException(NID_MSG, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ r = E_OUT_OF_MEMORY;
+ }
+ else
+ {
+ SysLogException(NID_MSG, E_SYSTEM, "[E_SYSTEM] System error.");
+ r = E_SYSTEM;
+ }
+
+ SysLog(NID_MSG, "The RequestPushRegistration is exiting with result[%s].", GetErrorMessage(r));
+
+ return r;
+}
+
+result
+_PushManagerImpl::RequestPushUnregistration(const _PushRequest* pRequest)
+{
+ SysLog(NID_MSG, "The RequestPushUnregistration is entering.");
+
+ result r = E_SUCCESS;
+ int ret = PUSH_ERROR_NONE;
+
+ ret = push_deregister((push_connection_h)GetPushHandle(), PushResultEventCallback, (void*)pRequest);
+ if (ret == PUSH_ERROR_NONE)
+ {
+ SysLog(NID_MSG, "push_deregister() is successful.");
+ UpdateActiveRequest(true);
+ }
+ else if (ret == PUSH_ERROR_OUT_OF_MEMORY)
+ {
+ SysLogException(NID_MSG, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ r = E_OUT_OF_MEMORY;
+ }
+ else
+ {
+ SysLogException(NID_MSG, E_SYSTEM, "[E_SYSTEM] System error.");
+ r = E_SYSTEM;
+ }
+
+ SysLog(NID_MSG, "The RequestPushUnregistration is exiting with result[%s].", GetErrorMessage(r));
+
+ return r;
+}
+
+result
+_PushManagerImpl::RequestPushSendMessageSingle(const _PushRequest* pRequest, const PushMessage& pushMessage, const String& registrationId)
+{
+ SysLog(NID_MSG, "The RequestPushSendMessageSingle is entering.");
+
+ result r = E_SUCCESS;
+ String url(L"");
+ ArrayList registrationIdList;
+
+ r = registrationIdList.Construct();
+ SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "[%s] Failed to construct registration Id list.", GetErrorMessage(r));
+
+ registrationIdList.Add(registrationId);
+
+ r = GetUrlFromRegistrationId(registrationId, pRequest, pushMessage, registrationIdList, url);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "[%s] Failed to get URL from registrionId.", GetErrorMessage(r));
+
+ if (url.IsEmpty() != true)
+ {
+ r = SendHttpRequest(url, pRequest, pushMessage, registrationIdList);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "[%s] Failed to submit http request.", GetErrorMessage(r));
+ }
+
+ SysLog(NID_MSG, "The RequestPushSendMessageSingle is exiting with result[%s].", GetErrorMessage(r));
+
+ return r;
+}
+
+result
+_PushManagerImpl::RequestPushSendMessageMultiple(const _PushRequest* pRequest, const PushMessage& pushMessage, const IList& registrationIdList)
+{
+ SysLog(NID_MSG, "The RequestPushSendMessageMultiple is entering.");
+
+ result r = E_SUCCESS;
+
+ int count = 0;
+ int subCount = 0;
+ int num = 0;
+ String* pRegistrationId = null;
+ String url(L"");
+ String prefix("");
+ ArrayList subRegistrationIdList;
+
+ String* pKey = null;
+ Integer* pValue = null;
+ Object* pObj = null;
+
+ MultiHashMap map;
+ map.Construct();
+
+ count = registrationIdList.GetCount();
+
+ for (int i = 0; i < count; i++)
+ {
+ pRegistrationId = (String*) (registrationIdList.GetAt(i));
+ SysTryReturn(NID_MSG, pRegistrationId != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] A failure casting.");
+
+ r = pRegistrationId->SubString(0,2, prefix);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, E_INVALID_ARG, E_INVALID_ARG, "[%s] Failed to get the prefix from registration ID", GetErrorMessage(r));
+
+ r = map.Add(*(new String(prefix)), *(new Integer(i)));
+ SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "A System error has occured.");
+ }
+
+ IMapEnumerator* pMapEnum = map.GetMapEnumeratorN();
+ while (pMapEnum->MoveNext() == E_SUCCESS)
+ {
+ pObj = pMapEnum->GetKey();
+ pKey = static_cast<String*> (pMapEnum->GetKey());
+ map.GetCount(*pObj, subCount);
+
+ SysLog(NID_MSG, "Key : [%ls], subCount : [%d].", pKey->GetPointer(), subCount);
+
+ r = subRegistrationIdList.Construct();
+ SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "[%s] Failed to construct sub registration Id list.", GetErrorMessage(r));
+
+ IEnumerator* pEnum = map.GetValuesN(*pObj);
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ pValue = static_cast<Integer*> (pEnum->GetCurrent());
+
+ pRegistrationId = (String*) (registrationIdList.GetAt(pValue->ToInt()));
+
+ SysLog(NID_MSG, "registrationId : [%ls].", pRegistrationId->GetPointer());
+
+ subRegistrationIdList.Add(*(registrationIdList.GetAt(pValue->ToInt())));
+
+ num++;
+
+ SysLog(NID_MSG, "Key : [%ls], Value : [%d] Num : [%d].", pKey->GetPointer(), pValue->ToInt(), num);
+ }
+ delete pEnum;
+
+ for(int j = 0; j < subCount - 1; j++)
+ {
+ r = pMapEnum->MoveNext();
+ SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "A System error has occured.");
+ }
+
+ pRegistrationId = (String*) (registrationIdList.GetAt(pValue->ToInt()));
+ r = GetUrlFromRegistrationId(*pRegistrationId, pRequest, pushMessage, subRegistrationIdList, url);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to get URL from registrionId.", GetErrorMessage(r));
+ goto CATCH;
+ }
+
+ if (url.IsEmpty() != true)
+ {
+ r = SendHttpRequest(url, pRequest, pushMessage, subRegistrationIdList);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to submit http request.", GetErrorMessage(r));
+ goto CATCH;
+ }
+ }
+
+ subRegistrationIdList.RemoveAll();
+
+ if (num >= count)
+ {
+ SysLog(NID_MSG, "Break num : [%d], count : [%d].", num, count);
+ break;
+ }
+ }
+
+ delete pMapEnum;
+
+ map.RemoveAll(true);
+
+ SysLog(NID_MSG, "The RequestPushSendMessageMultiple is exiting with result[%s].", GetErrorMessage(r));
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+bool
+_PushManagerImpl::GetLastPushStatus(void) const
+{
+ result r = E_SUCCESS;
+ Registry reg;
+ String regFile(Tizen::App::App::GetInstance()->GetAppRootPath() + _PUSH_STATUS_REGISTRY_FILE);
+ String section(_PUSH_STATUS_REGISTRY_STATUS_SECTION);
+ String entry(_PUSH_STATUS_REGISTRY_IS_REGISTERED_ENTRY);
+ int value = 0;
+
+ if (true == File::IsFileExist(regFile))
+ {
+ r = reg.Construct(regFile, false);
+ r = reg.GetValue(section, entry, value);
+ }
+
+ return (bool)value;
+}
+
+void
+_PushManagerImpl::UpdateLastPushStatus(bool value)
+{
+ result r = E_SUCCESS;
+ Registry reg;
+ String regFile(Tizen::App::App::GetInstance()->GetAppRootPath() + _PUSH_STATUS_REGISTRY_FILE);
+ String section(_PUSH_STATUS_REGISTRY_STATUS_SECTION);
+ String entry(_PUSH_STATUS_REGISTRY_IS_REGISTERED_ENTRY);
+
+ if (false == File::IsFileExist(regFile))
+ {
+ r = reg.Construct(regFile, true);
+ r = reg.AddSection(section);
+ r = reg.AddValue(section, entry, (int)value);
+ r = reg.Flush();
+ }
+ else
+ {
+ r = reg.Construct(regFile, false);
+ r = reg.SetValue(section, entry, (int)value);
+ if (r == E_SECTION_NOT_FOUND)
+ {
+ r = reg.AddSection(section);
+ r = reg.AddValue(section, entry, (int)value);
+ }
+ else if (r == E_KEY_NOT_FOUND)
+ {
+ r = reg.AddValue(section, entry, (int)value);
+ }
+ r = reg.Flush();
+ }
+
+ return;
+}
+
+String
+_PushManagerImpl::GetPushServerUrl(void) const
+{
+ result r = E_SUCCESS;
+ Registry reg;
+ String regFile(Tizen::App::App::GetInstance()->GetAppRootPath() + _PUSH_STATUS_REGISTRY_FILE);
+ String section(_PUSH_SERVER_REGISTRY_SERVER_SECTION);
+ String entry(_PUSH_SERVER_REGISTRY_URL_ENTRY);
+ String url(L"");
+
+ if (true == File::IsFileExist(regFile))
+ {
+ r = reg.Construct(regFile, false);
+ r = reg.GetValue(section, entry, url);
+ }
+
+ return url;
+}
+
+void
+_PushManagerImpl::UpdatePushServerUrl(String& url)
+{
+ result r = E_SUCCESS;
+ Registry reg;
+ String regFile(Tizen::App::App::GetInstance()->GetAppRootPath() + _PUSH_STATUS_REGISTRY_FILE);
+ String section(_PUSH_SERVER_REGISTRY_SERVER_SECTION);
+ String entry(_PUSH_SERVER_REGISTRY_URL_ENTRY);
+
+ if (false == File::IsFileExist(regFile))
+ {
+ r = reg.Construct(regFile, true);
+ r = reg.AddSection(section);
+ r = reg.AddValue(section, entry, url);
+ r = reg.Flush();
+ }
+ else
+ {
+ r = reg.Construct(regFile, false);
+ r = reg.SetValue(section, entry, url);
+ if (r == E_SECTION_NOT_FOUND)
+ {
+ r = reg.AddSection(section);
+ r = reg.AddValue(section, entry, url);
+ }
+ else if (r == E_KEY_NOT_FOUND)
+ {
+ r = reg.AddValue(section, entry, url);
+ }
+ r = reg.Flush();
+ }
+}
+
+} } // Osp::Messaging
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_PushManagerImpl.h
+ * @brief This is the header file for the %_PushManagerImpl class.
+ *
+ * This header file contains the declarations of the %_PushManagerImpl class.
+ */
+
+#ifndef _FMSG_INTERNAL_PUSH_MANAGER_IMPL_H_
+#define _FMSG_INTERNAL_PUSH_MANAGER_IMPL_H_
+
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseColArrayList.h>
+#include <FNetHttpHttpHeader.h>
+#include <FNetHttpHttpSession.h>
+#include <FNetHttpHttpRequest.h>
+#include <FNetHttpHttpTransaction.h>
+#include <FMsgPushMessage.h>
+#include "FMsg_PushRequest.h"
+#include "FMsg_PushSendListener.h"
+#include "FMsg_PushUrlRequestListener.h"
+
+namespace Tizen { namespace Base
+{
+class String;
+} } // Tizen::Base
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+} } } // Tizen::Base::Collection
+
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpHeader;
+class HttpRequest;
+class HttpSession;
+class HttpTransaction;
+} } } // Tizen::Net::Http
+
+namespace Tizen { namespace Messaging
+{
+class PushManager;
+class IPushManagerListener;
+class IPushEventListener;
+class _PushEvent;
+class _PushEventArg;
+class _PushRequest;
+
+/**
+ * @class _PushManagerImpl
+ * @brief This class represents an implementation of %PushManager class.
+ *
+ * @since 2.1
+ *
+ * This class represents an implementation of %PushManager class.
+ *
+ * @see PushManager
+ */
+class _PushManagerImpl
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.1
+ * @remarks After creating an instance of this class, you must explicitly call the
+ * Construct() method to initialize the instance.
+ * @see Construct()
+ */
+ _PushManagerImpl(void);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.1
+ */
+ virtual ~_PushManagerImpl(void);
+
+public:
+ /**
+ * @see PushManager::Construct()
+ */
+ result Construct(IPushManagerListener& managerListener, IPushEventListener& eventListener);
+
+ /**
+ * @see PushManager::RegisterPushService()
+ */
+ result RegisterPushService(RequestId& reqId);
+
+ /**
+ * @see PushManager::UnregisterPushService()
+ */
+ result UnregisterPushService(RequestId& reqId);
+
+ /**
+ * @see PushManager::IsPushServiceRegistered()
+ */
+ bool IsPushServiceRegistered(void) const;
+
+ /**
+ * @see PushManager::GetUnreadMessagesN()
+ */
+ Tizen::Base::Collection::IList* GetUnreadMessagesN(void);
+
+ /**
+ * @see PushManager::SendPushMessage()
+ */
+ result SendPushMessage(const PushMessage& message, const Tizen::Base::String& registrationId, const Tizen::Base::String& appSecret, RequestId& reqId);
+
+ /**
+ * @see PushManager::SendPushMessage()
+ */
+ result SendPushMessage(const PushMessage& message, const Tizen::Base::Collection::IList& registrationIdList, const Tizen::Base::String& appSecre, RequestId& reqId);
+
+ /**
+ * @see PushManager::GetMaxRecipientCount()
+ */
+ static int GetMaxRecipientCount(void);
+
+public:
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _PushManagerImpl
+ * @param[in] pushManager An instance of PushManager
+ */
+ static _PushManagerImpl* GetInstance(PushManager& pushManager);
+
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _PushManagerImpl
+ * @param[in] pushManager An instance of PushManager
+ */
+ static const _PushManagerImpl* GetInstance(const PushManager& pushManager);
+
+public:
+ void HandlePushEvent(_PushEventArg& eventArg);
+ void HandlePushRegistrationResponse(RequestId reqId, const Tizen::Base::String& registrationId, result r);
+ void HandlePushUnregistrationResponse(RequestId reqId, result r);
+ void HandlePushMessage(const Tizen::Base::String& notiMessage, const Tizen::Base::String& payload);
+ void HandlePushSendMessageResponse(RequestId reqId, const Tizen::Base::String& registrationId, result r, const Tizen::Base::String& errorCode, const Tizen::Base::String& errorMsg);
+
+ void SetPushStatus(bool isRegistered, const Tizen::Base::String& registrationId);
+ bool GetPushStatus(void) const;
+ Tizen::Base::String GetRegistrationId(void) const;
+
+ void* GetPushHandle(void) const;
+ void SetPushHandleReady(void);
+ bool IsPushHandleReady(void) const;
+
+ _PushRequest* AddRequest(RequestId reqId, _PushRequestType type);
+ _PushRequest* GetNextRequest(void);
+ void RemoveRequest(_PushRequest* pRequest);
+ bool HasPendingRequest(void) const;
+ bool HasActiveRequest(void) const;
+ void UpdateActiveRequest(bool hasActiveRequest);
+ void CheckNextRequest(void);
+
+ Tizen::Base::String GetAppSecret(void) const;
+ result GetUrlFromRegistrationId(const Tizen::Base::String& registrationId, const _PushRequest* pRequest, const PushMessage& pushMessage, const Tizen::Base::Collection::IList& registrationIdList, Tizen::Base::String& url);
+ result QueryServerUrl(const Tizen::Base::String& prefix, const _PushRequest* pRequest, const PushMessage& pushMessage, const Tizen::Base::Collection::IList& registrationIdList);
+ result SendHttpRequest(const Tizen::Base::String& url, const _PushRequest* pRequest, const PushMessage& pushMessage, const Tizen::Base::Collection::IList& registrationIdList);
+ result ComposeJsonObject(const _PushRequest* pRequest, const PushMessage& pushMessage, const Tizen::Base::Collection::IList& registrationIdList, Tizen::Base::ByteBuffer& buffer) const;
+
+private:
+ static RequestId GetNextRequestId(void);
+
+private:
+ result RequestPushRegistration(const _PushRequest* pRequest);
+ result RequestPushUnregistration(const _PushRequest* pRequest);
+ result RequestPushSendMessageSingle(const _PushRequest* pRequest, const PushMessage& message, const Tizen::Base::String& registrationId);
+ result RequestPushSendMessageMultiple(const _PushRequest* pRequest, const PushMessage& message, const Tizen::Base::Collection::IList& registrationIdList);
+
+ bool GetLastPushStatus(void) const;
+ void UpdateLastPushStatus(bool value);
+
+ Tizen::Base::String GetPushServerUrl(void) const;
+ void UpdatePushServerUrl(Tizen::Base::String& url);
+
+private:
+ /**
+ * This is the copy constructor for this class.
+ *
+ * @param[in] rhs An instance of _PushManagerImpl
+ */
+ _PushManagerImpl(const _PushManagerImpl& rhs);
+
+ /**
+ * This is the assignment operator.
+ *
+ * @param[in] rhs An instance of _PushManagerImpl
+ */
+ _PushManagerImpl& operator =(const _PushManagerImpl& rhs);
+
+private:
+ IPushManagerListener* __pManagerListener;
+ IPushEventListener* __pEventListener;
+ _PushEvent* __pEvent;
+ Tizen::Net::Http::HttpHeader* __pHeader;
+ Tizen::Net::Http::HttpSession* __pSession;
+ Tizen::Net::Http::HttpRequest* __pRequest;
+ Tizen::Net::Http::HttpTransaction* __pTransaction;
+ Tizen::Base::ByteBuffer* __pBody;
+ _PushSendListener* __pListener;
+ _PushUrlRequestListener* __pUrlListener;
+ Tizen::Base::String __appSecret;
+ bool __isRegistered;
+ Tizen::Base::String __registrationId;
+ Tizen::Base::Collection::ArrayList* __pRequestList;
+ bool __hasActiveRequest;
+ void* __pPushHandle;
+ bool __isPushHandleReady;
+
+ friend class _PushUrlRequestListener;
+}; // _PushManagerImpl
+
+} } // Tizen::Messaging
+#endif // _FMSG_INTERNAL_PUSH_MANAGER_IMPL_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+* @file FMsg_PushMessageImpl.cpp
+* @brief This is the implementation file for the %_PushMessageImpl class.
+*
+* This file contains the implementation of the %_PushMessageImpl class.
+*/
+
+#include <sys/time.h>
+#include <time.h>
+#include <FBaseSysLog.h>
+#include <FBaseUtilStringTokenizer.h>
+#include <FMsgPushMessage.h>
+#include "FMsg_PushMessageImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Shell;
+
+static const int _HASH_CODE_INITIAL_VALUE = 17;
+static const int _HASH_CODE_COEFFICIENT_VALUE = 37;
+static const wchar_t _PUSH_MESSAGE_TOKEN_DELIMITER[] = L"&";
+static const wchar_t _PUSH_MESSAGE_KEY_VALUE_DELIMITER[] = L"=";
+static const wchar_t _PUSH_MESSAGE_KEY_BADGE_OPTION[] = L"badgeOption";
+static const wchar_t _PUSH_MESSAGE_KEY_BADGE_NUMBER[] = L"badgeNumber";
+static const wchar_t _PUSH_MESSAGE_KEY_ACTION[] = L"action";
+static const wchar_t _PUSH_MESSAGE_KEY_ALERT_MESSAGE[] = L"alertMessage";
+static const wchar_t _PUSH_MESSAGE_VALUE_BADGE_SET[] = L"SET";
+static const wchar_t _PUSH_MESSAGE_VALUE_BADGE_INCREASE[] = L"INCREASE";
+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";
+
+namespace Tizen { namespace Messaging
+{
+
+_PushMessageImpl::_PushMessageImpl(void)
+ : __dateTime()
+ , __text(null)
+ , __pushAction(PUSH_ACTION_SILENT)
+ , __notiMessage()
+{
+}
+
+_PushMessageImpl::_PushMessageImpl(const DateTime& dateTime, const String& text)
+ : __pushAction(PUSH_ACTION_SILENT)
+ , __notiMessage()
+{
+ __dateTime = dateTime;
+ __text = text;
+}
+
+_PushMessageImpl::~_PushMessageImpl(void)
+{
+}
+
+_PushMessageImpl::_PushMessageImpl(const _PushMessageImpl& rhs)
+{
+ __dateTime = rhs.__dateTime;
+ __text = rhs.__text;
+ __pushAction = rhs.__pushAction;
+ __notiMessage = rhs.__notiMessage;
+}
+
+_PushMessageImpl&
+_PushMessageImpl::operator =(const _PushMessageImpl& rhs)
+{
+ if (this == &rhs)
+ {
+ return *this;
+ }
+
+ __dateTime = rhs.__dateTime;
+ __text = rhs.__text;
+ __pushAction = rhs.__pushAction;
+ __notiMessage = rhs.__notiMessage;
+
+ return *this;
+}
+
+bool
+_PushMessageImpl::Equals(const Object& obj) const
+{
+ const _PushMessageImpl* pRhs = dynamic_cast<const _PushMessageImpl*>(&obj);
+
+ if (pRhs == null)
+ {
+ return false;
+ }
+
+ if (__dateTime != pRhs->__dateTime)
+ {
+ return false;
+ }
+
+ if (__text != pRhs->__text)
+ {
+ return false;
+ }
+
+ if (__pushAction != pRhs->__pushAction)
+ {
+ return false;
+ }
+
+ if (__notiMessage.Equals(pRhs->__notiMessage) != true)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+int
+_PushMessageImpl::GetHashCode(void) const
+{
+ int hashCode = _HASH_CODE_INITIAL_VALUE;
+
+ hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __dateTime.GetHashCode();
+ hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + Integer(__pushAction).GetHashCode();
+ hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __notiMessage.GetHashCode();
+
+ return hashCode;
+}
+
+DateTime
+_PushMessageImpl::GetReceivedTime(void) const
+{
+ return __dateTime;
+}
+
+String
+_PushMessageImpl::GetText(void) const
+{
+ return __text;
+}
+
+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,
+ "[E_INVALID_ARG] Invalid PushAction [%d] argument.", (int)action);
+
+ __pushAction = action;
+
+ return r;
+}
+
+PushAction
+_PushMessageImpl::GetAction(void) const
+{
+ return __pushAction;
+}
+
+result
+_PushMessageImpl::SetNotification(const NotificationRequest& notificationMessage)
+{
+ result r = E_SUCCESS;
+
+ __notiMessage = notificationMessage;
+ __text = notificationMessage.GetAppMessage();
+
+ SysLog(NID_MSG, "Set NotificationRequest : action[%d]", __pushAction);
+ SysLog(NID_MSG, "Set NotificationRequest : badgeOffset[%d], badgeNumber[%d]", notificationMessage.GetBadgeOffset(), notificationMessage.GetBadgeNumber());
+ SysLog(NID_MSG, "Set NotificationRequest : alertText[%ls], appMessage[%ls]", (notificationMessage.GetAlertText()).GetPointer(), (notificationMessage.GetAppMessage()).GetPointer());
+
+ return r;
+}
+
+NotificationRequest
+_PushMessageImpl::GetNotification(void) const
+{
+ return __notiMessage;
+}
+
+PushMessage*
+_PushMessageImpl::CreatePushMessageN(const DateTime& dateTime, const String& text)
+{
+ return new (std::nothrow) PushMessage(dateTime, text);
+}
+
+DateTime
+_PushMessageImpl::ConvertTime(long long int time)
+{
+ DateTime dateTime;
+ struct tm gmTime;
+
+ gmtime_r((time_t*)&time, &gmTime);
+ dateTime.SetValue(gmTime.tm_year + 1900, gmTime.tm_mon + 1, gmTime.tm_mday, gmTime.tm_hour, gmTime.tm_min, gmTime.tm_sec);
+
+ return dateTime;
+}
+
+void
+_PushMessageImpl::ConvertMessageToNotification(const String& message)
+{
+ result r = E_SUCCESS;
+ int badgeNumber = 0;
+ String alertText;
+
+ r = __notiMessage.SetAppMessage(__text);
+
+ StringTokenizer tokens(message, _PUSH_MESSAGE_TOKEN_DELIMITER);
+
+ while (tokens.HasMoreTokens() == true)
+ {
+ String token;
+ String key;
+ String value;
+ String badgeValue;
+ int delimiterIndex;
+
+ tokens.GetNextToken(token);
+
+ r = token.IndexOf(_PUSH_MESSAGE_KEY_VALUE_DELIMITER, 0, delimiterIndex);
+ if(IsFailed(r))
+ continue;
+
+ r = token.SubString(0, delimiterIndex, key);
+ if (IsFailed(r))
+ continue;
+
+ r = token.SubString(delimiterIndex + 1, token.GetLength() - delimiterIndex - 1, value);
+ if (IsFailed(r))
+ continue;
+
+ if ((key.IsEmpty() == true) || (value.IsEmpty() == true))
+ continue;
+
+ if (key.Equals(_PUSH_MESSAGE_KEY_BADGE_OPTION, false) == true)
+ {
+ badgeValue = value;
+ }
+ else if (key.Equals(_PUSH_MESSAGE_KEY_BADGE_NUMBER, false) == true)
+ {
+ r = Integer::Parse(value, badgeNumber);
+ if (IsFailed(r))
+ continue;
+
+ if (badgeValue.Equals(_PUSH_MESSAGE_VALUE_BADGE_SET, false) == true)
+ {
+ r = __notiMessage.SetBadgeNumber(badgeNumber);
+ if (IsFailed(r))
+ continue;
+ }
+ else if (badgeValue.Equals(_PUSH_MESSAGE_VALUE_BADGE_INCREASE, false) == true)
+ {
+ r = __notiMessage.SetBadgeOffset(badgeNumber);
+ if (IsFailed(r))
+ continue;
+ }
+ else if (badgeValue.Equals(_PUSH_MESSAGE_VALUE_BADGE_DECREASE, false) == true)
+ {
+ r = __notiMessage.SetBadgeOffset(badgeNumber);
+ if (IsFailed(r))
+ continue;
+ }
+ else
+ {
+ r = __notiMessage.SetBadgeOffset(0);
+ if (IsFailed(r))
+ continue;
+ }
+ }
+ else if (key.Equals(_PUSH_MESSAGE_KEY_ACTION, false) == true)
+ {
+ if (value.Equals(_PUSH_MESSAGE_VALUE_ACTION_SILENT, false) == true)
+ {
+ __pushAction = PUSH_ACTION_SILENT;
+ }
+ else if (value.Equals(_PUSH_MESSAGE_VALUE_ACTION_DISCARD, false) == true)
+ {
+ __pushAction = PUSH_ACTION_DISCARD;
+ }
+ else if (value.Equals(_PUSH_MESSAGE_VALUE_ACTION_ALERT, false) == true)
+ {
+ __pushAction = PUSH_ACTION_ALERT;
+ }
+ else
+ {
+ __pushAction = PUSH_ACTION_SILENT;
+ }
+ }
+ else if (key.Equals(_PUSH_MESSAGE_KEY_ALERT_MESSAGE, false) == true)
+ {
+ r = UrlDecoder::Decode(value, L"UTF-8", alertText);
+ if (IsFailed(r))
+ continue;
+
+ r = __notiMessage.SetAlertText(alertText);
+ if (IsFailed(r))
+ continue;
+
+ SysLog(NID_MSG, "AlertText - Original[%ls] Decoded[%ls] result[%s]", value.GetPointer(), alertText.GetPointer(), GetErrorMessage(r));
+ }
+ else
+ {
+ SysLog(NID_MSG, "Ignore UnKnown option[%ls]", key.GetPointer());
+ }
+ }
+
+ SysLog(NID_MSG, "The converted value of action is [%d].", __pushAction);
+ SysLog(NID_MSG, "The converted value of badgeOffset is [%d], badgeNumber is [%d].", __notiMessage.GetBadgeOffset(), __notiMessage.GetBadgeNumber());
+ SysLog(NID_MSG, "The converted value of alertText is [%ls], appMessage is [%ls].", (__notiMessage.GetAlertText()).GetPointer(), (__notiMessage.GetAppMessage()).GetPointer());
+}
+
+_PushMessageImpl*
+_PushMessageImpl::GetInstance(PushMessage& pushMessage)
+{
+ return pushMessage.__pPushMessageImpl;
+}
+
+const _PushMessageImpl*
+_PushMessageImpl::GetInstance(const PushMessage& pushMessage)
+{
+ return pushMessage.__pPushMessageImpl;
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_PushMessageImpl.h
+ * @brief This is the header file for the %_PushMessageImpl class.
+ *
+ * This header file contains the declarations of the %_PushMessageImpl class.
+ */
+
+#ifndef _FMSG_INTERNAL_PUSH_MESSAGE_IMPL_H_
+#define _FMSG_INTERNAL_PUSH_MESSAGE_IMPL_H_
+
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseDateTime.h>
+#include <FShellNotificationRequest.h>
+#include <FMsgTypes.h>
+
+namespace Tizen { namespace Messaging
+{
+class PushMessage;
+
+/**
+ * @class _PushMessageImpl
+ * @brief This class represents an implementation of %PushMessage class.
+ *
+ * @since 2.1
+ *
+ * This class represents an implementation of %PushMessage class.
+ *
+ * @see PushMessage
+ */
+class _PushMessageImpl
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.1
+ */
+ _PushMessageImpl(void);
+
+ /**
+ * This is the constructor for this class.
+ *
+ * @since 2.1
+ */
+ _PushMessageImpl(const Tizen::Base::DateTime& dateTime, const Tizen::Base::String& text);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.1
+ */
+ virtual ~_PushMessageImpl(void);
+
+ /**
+ * This is the copy constructor for this class.
+ *
+ * @param[in] rhs An instance of _PushMessageImpl
+ */
+ _PushMessageImpl(const _PushMessageImpl& rhs);
+
+ /**
+ * This is the assignment operator.
+ *
+ * @param[in] rhs An instance of _PushMessageImpl
+ */
+ _PushMessageImpl& operator =(const _PushMessageImpl& rhs);
+
+ /**
+ * @see PushMessage::Equals()
+ */
+ virtual bool Equals(const Tizen::Base::Object& obj) const;
+
+ /**
+ * @see PushMessage::GetHashCode()
+ */
+ virtual int GetHashCode(void) const;
+
+public:
+ /**
+ * @see PushMessage::GetReceivedTime()
+ */
+ Tizen::Base::DateTime GetReceivedTime(void) const;
+
+ /**
+ * @see PushMessage::GetText()
+ */
+ Tizen::Base::String GetText(void) const;
+
+ /**
+ * @see PushMessage::SetAction()
+ */
+ result SetAction(PushAction action);
+
+ /**
+ * @see PushMessage::GetAction()
+ */
+ PushAction GetAction(void) const;
+
+ /**
+ * @see PushMessage::SetNotification()
+ */
+ result SetNotification(const Tizen::Shell::NotificationRequest& notificationMessage);
+
+ /**
+ * @see PushMessage::GetNotification()
+ */
+ Tizen::Shell::NotificationRequest GetNotification(void) const;
+
+ static PushMessage* CreatePushMessageN(const Tizen::Base::DateTime& dateTime, const Tizen::Base::String& text);
+ static Tizen::Base::DateTime ConvertTime(long long int time);
+ void ConvertMessageToNotification(const Tizen::Base::String& message);
+
+public:
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _PushMessageImpl
+ * @param[in] pushMessage An instance of PushMessage
+ */
+ static _PushMessageImpl* GetInstance(PushMessage& pushMessage);
+
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _PushMessageImpl
+ * @param[in] pushMessage An instance of PushMessage
+ */
+ static const _PushMessageImpl* GetInstance(const PushMessage& pushMessage);
+
+private:
+ Tizen::Base::DateTime __dateTime;
+ Tizen::Base::String __text;
+ PushAction __pushAction;
+ Tizen::Shell::NotificationRequest __notiMessage;
+}; // _PushMessageImpl
+
+} } // Tizen::Messaging
+#endif // _FMSG_INTERNAL_PUSH_MESSAGE_IMPL_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_PushRequest.cpp
+ * @brief This is the implementation file for %_PushRequest class.
+ *
+ * This file contains implementation of _PushRequest class.
+ */
+
+#include "FMsg_PushManagerImpl.h"
+#include "FMsg_PushRequest.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Messaging
+{
+
+_PushRequest::_PushRequest(_PushManagerImpl* pPushManager, RequestId reqId, _PushRequestType type)
+ : __pPushManager(pPushManager)
+ , __reqId(reqId)
+ , __type(type)
+{
+}
+
+_PushRequest::~_PushRequest(void)
+{
+}
+
+_PushManagerImpl*
+_PushRequest::GetPushManager(void) const
+{
+ return __pPushManager;
+}
+
+RequestId
+_PushRequest::GetRequestId(void) const
+{
+ return __reqId;
+}
+
+_PushRequestType
+_PushRequest::GetType(void) const
+{
+ return __type;
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_PushRequest.h
+ * @brief This is the header file for %_PushRequest class.
+ *
+ * This file contains declarations of _PushRequest class.
+ */
+
+#ifndef _FMSG_INTERNAL_PUSH_REQUEST_H_
+#define _FMSG_INTERNAL_PUSH_REQUEST_H_
+
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+
+namespace Tizen { namespace Messaging
+{
+enum _PushRequestType
+{
+ _PUSH_REQUEST_REGISTER = 0,
+ _PUSH_REQUEST_UNREGISTER,
+ _PUSH_REQUEST_SEND
+};
+
+class _PushManagerImpl;
+
+class _PushRequest
+ : public Tizen::Base::Object
+{
+public:
+ _PushRequest(_PushManagerImpl* pPushManager, RequestId reqId, _PushRequestType type);
+ virtual ~_PushRequest(void);
+
+ _PushManagerImpl* GetPushManager(void) const;
+ RequestId GetRequestId(void) const;
+ _PushRequestType GetType(void) const;
+
+private:
+ _PushRequest(void);
+ _PushRequest(const _PushRequest& rhs);
+ _PushRequest& operator =(const _PushRequest& rhs);
+
+private:
+ _PushManagerImpl* __pPushManager;
+ RequestId __reqId;
+ _PushRequestType __type;
+}; // _PushRequest
+
+} } // Tizen::Messaging
+
+#endif // _FMSG_INTERNAL_PUSH_REQUEST_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_PushSendListener.cpp
+ * @brief This is the implementation file for %_PushSendListener class.
+ *
+ * This file contains implementation of _PushSendListener class.
+ */
+
+#include <FBaseByteBuffer.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FWebJsonIJsonValue.h>
+#include <FWebJsonJsonObject.h>
+#include <FWebJsonJsonArray.h>
+#include <FWebJsonJsonString.h>
+#include <FWebJsonJsonNumber.h>
+#include <FWebJsonJsonParser.h>
+#include "FMsg_PushSendListener.h"
+#include "FMsg_PushManagerImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Net::Http;
+using namespace Tizen::Web::Json;
+
+namespace Tizen { namespace Messaging
+{
+
+_PushSendListener::_PushSendListener(void)
+ : __pPushRequest(null)
+{
+}
+
+_PushSendListener::~_PushSendListener(void)
+{
+ __pPushRequest = null;
+}
+
+void
+_PushSendListener::OnTransactionReadyToRead(HttpSession& httpSession, HttpTransaction& httpTransaction, int availableBodyLen)
+{
+ SysLog(NID_MSG, "####### OnTransactionReadyToRead! #######");
+
+}
+
+void
+_PushSendListener::OnTransactionAborted(HttpSession& httpSession, HttpTransaction& httpTransaction, result r)
+{
+ SysLog(NID_MSG, "####### OnTransactionAborted! (%s)#######", GetErrorMessage(r));
+
+ result res = E_CONNECTION_FAILED;
+ _PushManagerImpl* pManager = null;
+ String errorCode(L"");
+ String errorMsg(L"");
+
+ pManager = __pPushRequest->GetPushManager();
+ SysTryReturnVoidResult(NID_MSG, pManager != null, E_SYSTEM, "[E_SYSTEM] A _PushManagerImpl is NULL.");
+
+ if (__pPushRequest->GetType() == _PUSH_REQUEST_SEND)
+ {
+ // Push Send Message Request
+ pManager->HandlePushSendMessageResponse(__pPushRequest->GetRequestId(), pManager->GetRegistrationId(), res, errorCode, errorMsg);
+ }
+
+ delete &httpTransaction;
+}
+
+void
+_PushSendListener::OnTransactionReadyToWrite(HttpSession& httpSession, HttpTransaction& httpTransaction, int recommendedChunkSize)
+{
+ SysLog(NID_MSG, "####### OnTransactionReadyToWrite! #######");
+}
+
+void
+_PushSendListener::OnTransactionHeaderCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction, int headerLen, bool rs)
+{
+ SysLog(NID_MSG, "####### OnTransactionHeaderCompleted! #######");
+}
+
+void
+_PushSendListener::OnTransactionCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction)
+{
+ SysLog(NID_MSG, "####### OnTransactionCompleted! #######");
+
+ HttpResponse* pResponse = httpTransaction.GetResponse();
+ SysTryReturnVoidResult(NID_MSG, pResponse != null, E_SYSTEM, "[E_SYSTEM] HttpResponse is invalid.");
+
+ result r = E_SUCCESS;
+ _PushManagerImpl* pManager = null;
+ String registrationId(L"");
+ String errorCode(L"");
+ String errorMsg(L"");
+ ByteBuffer* pBody = null;
+ IJsonValue* pJsonVal = null;
+ IJsonValue* pRootValue = null;
+ IJsonValue* pEntryValue = null;
+ IJsonValue* pValue1 = null;
+ IJsonValue* pValue2 = null;
+ IJsonValue* pValue3 = null;
+ JsonObject* pJsonObj = null;
+ JsonObject* pJsonObj1 = null;
+ JsonArray* pJsonArr = null;
+ String key(L"results");
+ String key1(L"regID");
+ String key2(L"statusCode");
+ String key3(L"statusMsg");
+ JsonString* pStrValue1 = null;
+ JsonNumber* pNumValue2 = null;
+ JsonString* pStrValue3 = null;
+ String str1(L"");
+ String str2(L"");
+ String str3(L"");
+ int size = 0;
+ int listSize = 0;
+
+ pBody = pResponse->ReadBodyN();
+ SysTryCatch(NID_MSG, pBody != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to read body.");
+
+ SysLog(NID_MSG, "####### Body message : [%s] #######", pBody->GetPointer());
+
+ size = pBody->GetLimit();
+ SysLog(NID_MSG, "####### Body message size : [%d] #######", size);
+
+ pJsonVal = JsonParser::ParseN(*pBody);
+ SysTryCatch(NID_MSG, pJsonVal != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to parse to json.");
+
+ pJsonObj = static_cast<JsonObject*>(pJsonVal);
+ pJsonObj->GetValue(&key, pRootValue);
+
+ pJsonArr = static_cast<JsonArray*>(pRootValue);
+ listSize = pJsonArr->GetCount();
+
+ SysLog(NID_MSG, "Response Json count : [%d] #######", listSize);
+
+ for(int i = 0; i < listSize; i++)
+ {
+ pJsonArr->GetAt(i, pEntryValue);
+
+ pJsonObj1 = static_cast<JsonObject*>(pEntryValue);
+ pJsonObj1->GetValue(&key1, pValue1);
+ pJsonObj1->GetValue(&key2, pValue2);
+ pJsonObj1->GetValue(&key3, pValue3);
+
+ pStrValue1 = static_cast<JsonString*>(pValue1);
+ pNumValue2 = static_cast<JsonNumber*>(pValue2);
+ pStrValue3 = static_cast<JsonString*>(pValue3);
+
+ str1.Append(*((String*)pStrValue1));
+ str2.Append(((Double*)pNumValue2)->ToInt());
+ str3.Append(*((String*)pStrValue3));
+
+ registrationId = str1;
+ errorCode = str2;
+ errorMsg = str3;
+
+ str1.Clear();
+ str2.Clear();
+ str3.Clear();
+
+ SysLog(NID_MSG, "The current value of registrationId is %ls.", registrationId.GetPointer());
+ SysLog(NID_MSG, "The current value of errorCode is %ls.", errorCode.GetPointer());
+ SysLog(NID_MSG, "The current value of errorMsg is %ls.", errorMsg.GetPointer());
+
+ pManager = __pPushRequest->GetPushManager();
+ SysTryCatch(NID_MSG, pManager != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A _PushManagerImpl is NULL.");
+
+ if (pResponse->GetHttpStatusCode() != HTTP_STATUS_OK)
+ {
+ r = E_CONNECTION_FAILED;
+ SysLog(NID_MSG, "[E_CONNECTION_FAILED] HttpResponse status code is not OK.");
+ }
+ else
+ {
+ SysLog(NID_MSG, "[E_SUCCESS] HttpResponse status code is OK.");
+
+ if (errorCode.Equals(L"1000", false))
+ {
+ // Success
+ r = E_SUCCESS;
+ SysLog(NID_MSG, "[E_SUCCESS] Success.");
+ }
+ else if (errorCode.Equals(L"3008", false))
+ {
+ // error of not registered regID
+ r = E_CONNECTION_FAILED;
+ SysLog(NID_MSG, "[E_HOST_NOT_FOUND] Error of not registered regID.");
+ }
+ else if (errorCode.Equals(L"3009", false))
+ {
+ // error of not registered appID
+ r = E_SERVICE_UNAVAILABLE;
+ SysLog(NID_MSG, "[E_SERVICE_UNAVAILABLE] Error of not registered appID.");
+ }
+ else if (errorCode.Equals(L"3045", false))
+ {
+ // error of application authentication failed
+ r = E_AUTHENTICATION;
+ SysLog(NID_MSG, "[E_AUTHENTICATION] Error of application authentication failed.");
+ }
+ else
+ {
+ // TODO : Convert Error Code from Server
+ r = E_SERVER;
+ SysLog(NID_MSG, "[E_SERVER] Error of something wrong.");
+ }
+ }
+
+ if (__pPushRequest->GetType() == _PUSH_REQUEST_SEND)
+ {
+ // Push Send Message Request
+ pManager->HandlePushSendMessageResponse(__pPushRequest->GetRequestId(), registrationId, r, errorCode, errorMsg);
+ }
+ }
+
+ delete pBody;
+ delete pJsonVal;
+
+ return;
+
+CATCH:
+ if (pBody)
+ {
+ delete pBody;
+ pBody = null;
+ }
+
+ if (pJsonVal)
+ {
+ delete pJsonVal;
+ pJsonVal = null;
+ }
+
+ return;
+}
+
+void
+_PushSendListener::OnTransactionCertVerificationRequiredN(HttpSession& httpSession, HttpTransaction& httpTransaction, Tizen::Base::String* pCert)
+{
+ SysLog(NID_MSG, "####### OnTransactionCertVerificationRequiredN! #######");
+
+ result r = httpTransaction.Resume();
+ SysTryReturnVoidResult(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, "[E_SYSTEM] http transaction resume.");
+
+ delete pCert;
+
+ return;
+}
+
+void
+_PushSendListener::SetParams(const _PushRequest* pPushRequestSet)
+{
+ __pPushRequest = pPushRequestSet;
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_PushSendListener.h
+ * @brief This is the header file for %_PushSendListener class.
+ *
+ * This file contains declarations of _PushSendListener class.
+ */
+
+#ifndef _FMSG_INTERNAL_PUSH_SEND_LISTENER_H_
+#define _FMSG_INTERNAL_PUSH_SEND_LISTENER_H_
+
+
+#include <FNet.h>
+#include "FMsg_PushRequest.h"
+
+namespace Tizen { namespace Messaging
+{
+
+class _PushSendListener
+ : public Tizen::Net::Http::IHttpTransactionEventListener
+{
+
+public:
+ _PushSendListener(void);
+ virtual ~_PushSendListener(void);
+
+public:
+
+ void OnTransactionReadyToRead(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction, int availableBodyLen);
+
+ void OnTransactionAborted(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction, result r);
+
+ void OnTransactionReadyToWrite(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction, int recommendedChunkSize);
+
+ void OnTransactionHeaderCompleted(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction, int headerLen, bool rs);
+
+ void OnTransactionCompleted(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction);
+
+ void OnTransactionCertVerificationRequiredN(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction, Tizen::Base::String* pCert);
+
+ void SetParams(const _PushRequest* pPushRequestSet);
+
+private:
+ _PushSendListener(const _PushSendListener& rhs);
+ _PushSendListener& operator =(const _PushSendListener& rhs);
+
+private:
+ const _PushRequest* __pPushRequest;
+
+}; // _PushSendListener
+
+} } // Tizen::Messaging
+
+#endif // _FMSG_INTERNAL_PUSH_SEND_LISTENER_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_PushUrlRequestListener.cpp
+ * @brief This is the implementation file for %_PushUrlRequestListener class.
+ *
+ * This file contains implementation of _PushUrlRequestListener class.
+ */
+
+#include <FBaseByteBuffer.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FBaseUtilStringUtil.h>
+#include <FBaseUtilStringTokenizer.h>
+#include "FMsg_PushUrlRequestListener.h"
+#include "FMsg_PushManagerImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Net::Http;
+
+namespace Tizen { namespace Messaging
+{
+
+_PushUrlRequestListener::_PushUrlRequestListener(void)
+ : __pPushRequest(null)
+{
+}
+
+_PushUrlRequestListener::~_PushUrlRequestListener(void)
+{
+ __pPushRequest = null;
+}
+
+void
+_PushUrlRequestListener::OnTransactionReadyToRead(HttpSession& httpSession, HttpTransaction& httpTransaction, int availableBodyLen)
+{
+ SysLog(NID_MSG, "####### OnTransactionReadyToRead! #######");
+}
+
+void
+_PushUrlRequestListener::OnTransactionAborted(HttpSession& httpSession, HttpTransaction& httpTransaction, result r)
+{
+ SysLog(NID_MSG, "####### OnTransactionAborted! (%s)#######", GetErrorMessage(r));
+
+ _UserData* pUserData = dynamic_cast<_UserData*> (httpTransaction.GetUserObject());
+ SysTryReturnVoidResult(NID_MSG, pUserData != null, E_SYSTEM, "[E_SYSTEM] Failed to cast user data.");
+
+ delete pUserData;
+
+ delete &httpTransaction;
+}
+
+void
+_PushUrlRequestListener::OnTransactionReadyToWrite(HttpSession& httpSession, HttpTransaction& httpTransaction, int recommendedChunkSize)
+{
+ SysLog(NID_MSG, "####### OnTransactionReadyToWrite! #######");
+}
+
+void
+_PushUrlRequestListener::OnTransactionHeaderCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction, int headerLen, bool rs)
+{
+ SysLog(NID_MSG, "####### OnTransactionHeaderCompleted! #######");
+}
+
+void
+_PushUrlRequestListener::OnTransactionCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction)
+{
+ SysLog(NID_MSG, "####### OnTransactionCompleted! #######");
+
+ HttpResponse* pResponse = httpTransaction.GetResponse();
+ SysTryReturnVoidResult(NID_MSG, pResponse != null, E_SYSTEM, "[E_SYSTEM] HttpResponse is invalid.");
+
+ result r = E_SUCCESS;
+ _PushManagerImpl* pManager = null;
+ String response;
+ ByteBuffer tempBuffer;
+ _UserData* pUserData = dynamic_cast<_UserData*> (httpTransaction.GetUserObject());
+ SysTryReturnVoidResult(NID_MSG, pUserData != null, E_SYSTEM, "[E_SYSTEM] Failed to cast user data.");
+
+ if (pResponse->GetHttpStatusCode() == HTTP_STATUS_OK)
+ {
+ ByteBuffer* pBody = pResponse->ReadBodyN();
+ SysTryReturnVoidResult(NID_MSG, pBody != null, E_SYSTEM, "[E_SYSTEM] Failed to read body.");
+
+ r = tempBuffer.Construct(pBody->GetRemaining() + 1);
+ SysTryReturnVoidResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Failed to construct byte buffer.");
+
+ r = tempBuffer.CopyFrom(*pBody);
+ SysTryReturnVoidResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Failed to copy from body.");
+
+ SysLog(NID_MSG, "The read body is %s.", tempBuffer.GetPointer());
+
+ StringUtil::Utf8ToString((char*) tempBuffer.GetPointer(), response);
+
+ SysLog(NID_MSG, "The read body response is %ls.", response.GetPointer());
+
+ StringTokenizer tokens(response, L"&");
+
+ while (tokens.HasMoreTokens() == true)
+ {
+ String token;
+ String key;
+ String value;
+ int delimiterIndex;
+ int resultValue;
+ String urlValue;
+
+ tokens.GetNextToken(token);
+
+ r = token.IndexOf(L"=", 0, delimiterIndex);
+ if(IsFailed(r))
+ continue;
+
+ r = token.SubString(0, delimiterIndex, key);
+ if (IsFailed(r))
+ continue;
+
+ r = token.SubString(delimiterIndex + 1, token.GetLength() - delimiterIndex - 1, value);
+ if (IsFailed(r))
+ continue;
+
+ if ((key.IsEmpty() == true) || (value.IsEmpty() == true))
+ continue;
+
+ if (key.Equals(L"resultcode", false) == true)
+ {
+ r = Integer::Parse(value, resultValue);
+ if (IsFailed(r))
+ continue;
+ }
+ else if (key.Equals(L"url", false) == true)
+ {
+ urlValue = value;
+ urlValue.Append(L"/spp/pns/api/push");
+ SysLog(NID_MSG, "The read body url is %ls.", urlValue.GetPointer());
+
+ pManager = __pPushRequest->GetPushManager();
+ pManager->UpdatePushServerUrl(urlValue);
+
+ r = pManager->SendHttpRequest(urlValue, __pPushRequest, *(pUserData->GetPushMessage()), *(pUserData->GetRegistrationIdList()));
+ SysTryReturnVoidResult(NID_MSG, r == E_SUCCESS, r, "[%s] Failed to submit http request.", GetErrorMessage(r));
+ }
+ else
+ {
+ SysLog(NID_MSG, "Ignore UnKnown option[%ls]", key.GetPointer());
+ }
+ }
+
+ delete pBody;
+ }
+
+ delete pUserData;
+
+ delete &httpTransaction;
+}
+
+void
+_PushUrlRequestListener::OnTransactionCertVerificationRequiredN(HttpSession& httpSession, HttpTransaction& httpTransaction, String* pCert)
+{
+ SysLog(NID_MSG, "####### OnTransactionCertVerificationRequiredN! #######");
+
+ result r = httpTransaction.Resume();
+ SysTryReturnVoidResult(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, "[E_SYSTEM] http transaction resume.");
+
+ delete pCert;
+
+ return;
+}
+
+void
+_PushUrlRequestListener::SetParams(const _PushRequest* pPushRequestSet)
+{
+ __pPushRequest = pPushRequestSet;
+}
+
+_UserData::_UserData(HttpUrlEncodedEntity* pHttpUrlEncodedEntity, PushMessage* pPushMessage, IList* pRegistrationIdList)
+ : __pHttpUrlEncodedEntity(pHttpUrlEncodedEntity),
+ __pPushMessage(pPushMessage),
+ __pRegistrationIdList(pRegistrationIdList)
+{
+}
+
+_UserData::~_UserData(void)
+{
+ if (__pHttpUrlEncodedEntity != null)
+ {
+ delete __pHttpUrlEncodedEntity;
+ __pHttpUrlEncodedEntity = null;
+ }
+
+ if (__pPushMessage != null)
+ {
+ delete __pPushMessage;
+ __pPushMessage = null;
+ }
+
+ if (__pRegistrationIdList != null)
+ {
+ delete __pRegistrationIdList;
+ __pRegistrationIdList = null;
+ }
+}
+
+PushMessage*
+_UserData::GetPushMessage(void)
+{
+ return __pPushMessage;
+}
+
+IList*
+_UserData::GetRegistrationIdList(void)
+{
+ return __pRegistrationIdList;
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_PushUrlRequestListener.h
+ * @brief This is the header file for %_PushUrlRequestListener class.
+ *
+ * This file contains declarations of _PushUrlRequestListener class.
+ */
+
+#ifndef _FMSG_INTERNAL_PUSH_URL_REQUEST_LISTENER_H_
+#define _FMSG_INTERNAL_PUSH_URL_REQUEST_LISTENER_H_
+
+#include <FNet.h>
+#include <FBaseColIList.h>
+#include <FMsgPushMessage.h>
+#include "FMsg_PushRequest.h"
+
+namespace Tizen { namespace Messaging
+{
+class _PushUrlRequestListener
+ : public Tizen::Net::Http::IHttpTransactionEventListener
+{
+public:
+ _PushUrlRequestListener(void);
+ virtual ~_PushUrlRequestListener(void);
+
+public:
+
+ void OnTransactionReadyToRead(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction, int availableBodyLen);
+
+ void OnTransactionAborted(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction, result r);
+
+ void OnTransactionReadyToWrite(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction, int recommendedChunkSize);
+
+ void OnTransactionHeaderCompleted(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction, int headerLen, bool rs);
+
+ void OnTransactionCompleted(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction);
+
+ void OnTransactionCertVerificationRequiredN(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction, Tizen::Base::String* pCert);
+
+ void SetParams(const _PushRequest* pPushRequestSet);
+
+private:
+ _PushUrlRequestListener(const _PushUrlRequestListener& rhs);
+ _PushUrlRequestListener& operator =(const _PushUrlRequestListener& rhs);
+
+private:
+ const _PushRequest* __pPushRequest;
+}; // _PushUrlRequestListener
+
+class _UserData
+ : public Tizen::Base::Object
+{
+public:
+ _UserData(Tizen::Net::Http::HttpUrlEncodedEntity* pHttpUrlEncodedEntity, PushMessage* pPushMessage, Tizen::Base::Collection::IList* pRegistrationIdList);
+ virtual ~_UserData(void);
+
+public:
+ PushMessage* GetPushMessage(void);
+ Tizen::Base::Collection::IList* GetRegistrationIdList(void);
+
+private:
+ _UserData(const _UserData& rhs);
+ _UserData& operator =(const _UserData& rhs);
+
+private:
+ Tizen::Net::Http::HttpUrlEncodedEntity* __pHttpUrlEncodedEntity;
+ PushMessage* __pPushMessage;
+ Tizen::Base::Collection::IList* __pRegistrationIdList;
+ }; // _UserData
+
+} } // Tizen::Messaging
+
+#endif // _FMSG_INTERNAL_PUSH_URL_REQUEST_LISTENER_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_RecipientListImpl.cpp
+ * @brief This is the implementation file for the %_RecipientListImpl class.
+ *
+ * This file contains the implementation of the %_RecipientListImpl class.
+ */
+
+#include <FBaseColArrayList.h>
+#include <FBaseSysLog.h>
+#include <FMsgRecipientList.h>
+#include "FMsg_RecipientListImpl.h"
+#include "FMsg_Types.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Messaging
+{
+
+_RecipientListImpl::_RecipientListImpl(void)
+ : __pRecipientList(null)
+ , __pRecipientCcList(null)
+ , __pRecipientBccList(null)
+{
+}
+
+_RecipientListImpl::~_RecipientListImpl(void)
+{
+ if (__pRecipientList)
+ {
+ if (__pRecipientList->GetCount() > 0)
+ {
+ __pRecipientList->RemoveAll(true); // if true, deallocate object
+ }
+ delete __pRecipientList;
+ __pRecipientList = null;
+ }
+
+ if (__pRecipientCcList)
+ {
+ if (__pRecipientCcList->GetCount() > 0)
+ {
+ __pRecipientCcList->RemoveAll(true); // if true, deallocate object
+ }
+ delete __pRecipientCcList;
+ __pRecipientCcList = null;
+ }
+
+ if (__pRecipientBccList)
+ {
+ if (__pRecipientBccList->GetCount() > 0)
+ {
+ __pRecipientBccList->RemoveAll(true); // if true, deallocate object
+ }
+ delete __pRecipientBccList;
+ __pRecipientBccList = null;
+ }
+}
+
+_RecipientListImpl::_RecipientListImpl(const _RecipientListImpl& value)
+{
+ __pRecipientList = null;
+ __pRecipientCcList = null;
+ __pRecipientBccList = null;
+
+ int count = 0;
+ int index = 0;
+ String* pTmpStr = null;
+
+ // TO
+ if (value.__pRecipientList)
+ {
+ __pRecipientList = new ArrayList();
+ __pRecipientList->Construct();
+ count = value.__pRecipientList->GetCount();
+ for (index = 0; index < count; index++)
+ {
+ pTmpStr = static_cast <String*>(value.__pRecipientList->GetAt(index));
+ String* pRecipient = new String(*pTmpStr);
+ __pRecipientList->Add(*pRecipient);
+ }
+ }
+
+ // CC
+ if (value.__pRecipientCcList)
+ {
+ __pRecipientCcList = new ArrayList();
+ __pRecipientCcList->Construct();
+ count = value.__pRecipientCcList->GetCount();
+ for (index = 0; index < count; index++)
+ {
+ pTmpStr = static_cast <String*>(value.__pRecipientCcList->GetAt(index));
+ String* pRecipient = new String(*pTmpStr);
+ __pRecipientCcList->Add(*pRecipient);
+ }
+ }
+
+ // BCC
+ if (value.__pRecipientBccList)
+ {
+ __pRecipientBccList = new ArrayList();
+ __pRecipientBccList->Construct();
+ count = value.__pRecipientBccList->GetCount();
+ for (index = 0; index < count; index++)
+ {
+ pTmpStr = static_cast <String*>(value.__pRecipientBccList->GetAt(index));
+ String* pRecipient = new String(*pTmpStr);
+ __pRecipientBccList->Add(*pRecipient);
+ }
+ }
+}
+
+void
+_RecipientListImpl::ClearRecipients(RecipientType type)
+{
+ if (type == RECIPIENT_TYPE_TO && __pRecipientList)
+ {
+ if (__pRecipientList->GetCount() > 0)
+ {
+ __pRecipientList->RemoveAll(true); // if true, deallocate object
+ }
+ delete __pRecipientList;
+ __pRecipientList = null;
+ }
+
+ if (type == RECIPIENT_TYPE_CC && __pRecipientCcList)
+ {
+ if (__pRecipientCcList->GetCount() > 0)
+ {
+ __pRecipientCcList->RemoveAll(true); // if true, deallocate object
+ }
+ delete __pRecipientCcList;
+ __pRecipientCcList = null;
+ }
+
+ if (type == RECIPIENT_TYPE_BCC && __pRecipientBccList)
+ {
+ if (__pRecipientBccList->GetCount() > 0)
+ {
+ __pRecipientBccList->RemoveAll(true); // if true, deallocate object
+ }
+ delete __pRecipientBccList;
+ __pRecipientBccList = null;
+ }
+}
+
+void
+_RecipientListImpl::ClearAllRecipients(void)
+{
+ if (__pRecipientList)
+ {
+ if (__pRecipientList->GetCount() > 0)
+ {
+ __pRecipientList->RemoveAll(true); // if true, deallocate object
+ }
+ delete __pRecipientList;
+ __pRecipientList = null;
+ }
+
+ if (__pRecipientCcList)
+ {
+ if (__pRecipientCcList->GetCount() > 0)
+ {
+ __pRecipientCcList->RemoveAll(true); // if true, deallocate object
+ }
+ delete __pRecipientCcList;
+ __pRecipientCcList = null;
+ }
+
+ if (__pRecipientBccList)
+ {
+ if (__pRecipientBccList->GetCount() > 0)
+ {
+ __pRecipientBccList->RemoveAll(true); // if true, deallocate object
+ }
+ delete __pRecipientBccList;
+ __pRecipientBccList = null;
+ }
+}
+
+_RecipientListImpl&
+_RecipientListImpl::operator =(const _RecipientListImpl& value)
+{
+ if (this != &value)
+ {
+ ClearAllRecipients();
+
+ int count = 0;
+ int index = 0;
+ String* pTmpStr = null;
+
+ if (value.__pRecipientList)
+ {
+ __pRecipientList = new ArrayList();
+ if (__pRecipientList)
+ {
+ __pRecipientList->Construct();
+ count = value.__pRecipientList->GetCount();
+ for (int index = 0; index < count; index++)
+ {
+ pTmpStr = static_cast <String*>(value.__pRecipientList->GetAt(index));
+ String* pRecipient = new String(*pTmpStr);
+ __pRecipientList->Add(*pRecipient);
+ }
+ }
+ }
+
+ if (value.__pRecipientCcList)
+ {
+ __pRecipientCcList = new ArrayList();
+ if (__pRecipientCcList)
+ {
+ __pRecipientCcList->Construct();
+ count = value.__pRecipientCcList->GetCount();
+ for (index = 0; index < count; index++)
+ {
+ pTmpStr = static_cast <String*>(value.__pRecipientCcList->GetAt(index));
+ String* pRecipient = new String(*pTmpStr);
+ __pRecipientCcList->Add(*pRecipient);
+ }
+ }
+ }
+
+ if (value.__pRecipientBccList)
+ {
+ __pRecipientBccList = new ArrayList();
+ if (__pRecipientBccList)
+ {
+ __pRecipientBccList->Construct();
+ count = value.__pRecipientBccList->GetCount();
+ for (index = 0; index < count; index++)
+ {
+ pTmpStr = static_cast <String*>(value.__pRecipientBccList->GetAt(index));
+ String* pRecipient = new String(*pTmpStr);
+ __pRecipientBccList->Add(*pRecipient);
+ }
+ }
+ }
+ }
+
+ return (*this);
+}
+
+bool
+_RecipientListImpl::operator ==(const _RecipientListImpl& rhs) const
+{
+ return (Equals(rhs));
+}
+
+bool
+_RecipientListImpl::operator !=(const _RecipientListImpl& rhs) const
+{
+ return (!Equals(rhs));
+}
+
+bool
+_RecipientListImpl::Equals(const Tizen::Base::Object& value) const
+{
+ const _RecipientListImpl* pList = dynamic_cast<const _RecipientListImpl*>(&value);
+ int index = 0;
+
+ if (!pList)
+ {
+ SysLog(NID_MSG, "dynamic_cast is failed");
+ return false;
+ }
+
+ String* pTempString1 = null;
+ String* pTempString2 = null;
+ int count = 0;
+ int valueCount = 0;
+
+ // TO
+ if (__pRecipientList)
+ {
+ count = __pRecipientList->GetCount();
+ }
+ else
+ {
+ count = 0;
+ }
+
+ if (pList->__pRecipientList)
+ {
+ valueCount = pList->__pRecipientList->GetCount();
+ }
+ else
+ {
+ valueCount = 0;
+ }
+
+ if (count != valueCount)
+ {
+ return false;
+ }
+
+ if (pList->__pRecipientList)
+ {
+ for (index = 0; index < count; index++)
+ {
+ pTempString1 = (String*) (__pRecipientList->GetAt(index));
+ pTempString2 = (String*) (pList->__pRecipientList->GetAt(index));
+ if (0 != pTempString1->CompareTo(*pTempString2))
+ {
+ return false;
+ }
+ }
+ }
+
+
+ // CC
+ if (__pRecipientCcList)
+ {
+ count = __pRecipientCcList->GetCount();
+ }
+ else
+ {
+ count = 0;
+ }
+
+ if (pList->__pRecipientCcList)
+ {
+ valueCount = pList->__pRecipientCcList->GetCount();
+ }
+ else
+ {
+ valueCount = 0;
+ }
+
+ if (count != valueCount)
+ {
+ return false;
+ }
+
+ if (pList->__pRecipientCcList)
+ {
+ for (index = 0; index < count; index++)
+ {
+ pTempString1 = (String*) (__pRecipientCcList->GetAt(index));
+ pTempString2 = (String*) (pList->__pRecipientCcList->GetAt(index));
+ if (0 != pTempString1->CompareTo(*pTempString2))
+ {
+ return false;
+ }
+ }
+ }
+
+ // BCC
+ if (__pRecipientBccList)
+ {
+ count = __pRecipientBccList->GetCount();
+ }
+ else
+ {
+ count = 0;
+ }
+
+ if (pList->__pRecipientBccList)
+ {
+ valueCount = pList->__pRecipientBccList->GetCount();
+ }
+ else
+ {
+ valueCount = 0;
+ }
+
+ if (count != valueCount)
+ {
+ return false;
+ }
+
+ if (pList->__pRecipientBccList)
+ {
+ for (index = 0; index < count; index++)
+ {
+ pTempString1 = (String*) (__pRecipientBccList->GetAt(index));
+ pTempString2 = (String*) (pList->__pRecipientBccList->GetAt(index));
+ if (0 != pTempString1->CompareTo(*pTempString2))
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+int
+_RecipientListImpl::GetHashCode(void) const
+{
+ String* pTempString = null;
+ int count = 0;
+ int hash = 0;
+ int index = 0;
+
+ if (__pRecipientList)
+ {
+ count = __pRecipientList->GetCount();
+ for (index = 0; index < count; index++)
+ {
+ pTempString = static_cast <String*>(__pRecipientList->GetAt(index));
+ hash += pTempString->GetHashCode();
+ }
+ }
+
+ if (__pRecipientCcList)
+ {
+ count = __pRecipientCcList->GetCount();
+ for (index = 0; index < count; index++)
+ {
+ pTempString = static_cast <String*>(__pRecipientCcList->GetAt(index));
+ hash += pTempString->GetHashCode();
+ }
+ }
+
+ if (__pRecipientBccList)
+ {
+ count = __pRecipientBccList->GetCount();
+ for (index = 0; index < count; index++)
+ {
+ pTempString = static_cast <String*>(__pRecipientBccList->GetAt(index));
+ hash += pTempString->GetHashCode();
+ }
+ }
+
+ return hash;
+}
+
+int
+_RecipientListImpl::GetTotalRecipientCount(void) const
+{
+ int totalCount = 0;
+
+ if (__pRecipientList)
+ {
+ totalCount += __pRecipientList->GetCount();
+ }
+
+ if (__pRecipientCcList)
+ {
+ totalCount += __pRecipientCcList->GetCount();
+ }
+
+ if (__pRecipientBccList)
+ {
+ totalCount += __pRecipientBccList->GetCount();
+ }
+
+ return totalCount;
+}
+
+result
+_RecipientListImpl::Add(RecipientType type, const String& recipient)
+{
+ result r = E_SUCCESS;
+ String* pRecipient = null;
+
+ // duplication check in TO list
+ if (__pRecipientList && __pRecipientList->Contains(recipient))
+ {
+ r = E_OBJ_ALREADY_EXIST;
+ SysLogException(NID_MSG, r, "[E_OBJ_ALREADY_EXIST] The corresponding recipient is already added to TO list.");
+ goto CATCH;
+ }
+
+ // duplication check in CC list
+ if (__pRecipientCcList && __pRecipientCcList->Contains(recipient))
+ {
+ r = E_OBJ_ALREADY_EXIST;
+ SysLogException(NID_MSG, r, "[E_OBJ_ALREADY_EXIST] The corresponding recipient is already added to CC list.");
+ goto CATCH;
+ }
+
+ // duplication check in BCC list
+ if (__pRecipientBccList && __pRecipientBccList->Contains(recipient))
+ {
+ r = E_OBJ_ALREADY_EXIST;
+ SysLogException(NID_MSG, r, "[E_OBJ_ALREADY_EXIST] The corresponding recipient is already added to BCC list.");
+ goto CATCH;
+ }
+
+ if (type == RECIPIENT_TYPE_TO )
+ {
+ if (!__pRecipientList)
+ {
+ __pRecipientList = new ArrayList();
+ r = __pRecipientList->Construct();
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to construct a TO list.", GetErrorMessage(r));
+ delete __pRecipientList;
+ __pRecipientList = null;
+ goto CATCH;
+ }
+ }
+ // add a recipient
+ pRecipient = new String(recipient);
+ r = __pRecipientList->Add(*pRecipient);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to add the recipient to TO list.", GetErrorMessage(r));
+ delete pRecipient;
+ pRecipient = null;
+ goto CATCH;
+ }
+ }
+ else if (type == RECIPIENT_TYPE_CC)
+ {
+ if (!__pRecipientCcList)
+ {
+ __pRecipientCcList = new ArrayList();
+ r = __pRecipientCcList->Construct();
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to construct a CC list.", GetErrorMessage(r));
+ delete __pRecipientCcList;
+ __pRecipientCcList = null;
+ goto CATCH;
+ }
+ }
+ // add a recipient
+ pRecipient = new String(recipient);
+ r = __pRecipientCcList->Add(*pRecipient);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to add the recipient to CC list.", GetErrorMessage(r));
+ delete pRecipient;
+ pRecipient = null;
+ goto CATCH;
+ }
+ }
+ else if (type == RECIPIENT_TYPE_BCC)
+ {
+ if (!__pRecipientBccList)
+ {
+ __pRecipientBccList = new ArrayList();
+ r = __pRecipientBccList->Construct();
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to construct a BCC list.", GetErrorMessage(r));
+ delete __pRecipientBccList;
+ __pRecipientBccList = null;
+ goto CATCH;
+ }
+ }
+ // add a recipient
+ pRecipient = new String(recipient);
+ r = __pRecipientBccList->Add(*pRecipient);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to add the recipient to BCC list.", GetErrorMessage(r));
+ delete pRecipient;
+ pRecipient = null;
+ goto CATCH;
+ }
+ }
+
+ return E_SUCCESS;
+
+CATCH:
+ return r;
+}
+
+result
+_RecipientListImpl::Remove(RecipientType type, const Tizen::Base::String& recipient)
+{
+ result r = E_SUCCESS;
+
+ SysTryReturnResult(NID_MSG, (type >= RECIPIENT_TYPE_TO && type <= RECIPIENT_TYPE_BCC), E_INVALID_ARG,
+ "[E_INVALID_ARG] Invalid RecipientType argument.");
+
+ if ((recipient.GetLength() < MIN_LENGTH_PHONE) || (recipient.GetLength() > MAX_LENGTH_EMAIL))
+ {
+ r = E_INVALID_ARG;
+ SysLogException(NID_MSG, r, "[E_INVALID_ARG] The length of phone number or email address is too short or too long (%d).",
+ recipient.GetLength());
+ goto CATCH;
+ }
+
+
+ if ((type == RECIPIENT_TYPE_TO && !__pRecipientList) ||
+ (type == RECIPIENT_TYPE_CC && !__pRecipientCcList) || (type == RECIPIENT_TYPE_BCC && !__pRecipientBccList))
+ {
+ r = E_OBJ_NOT_FOUND;
+ SysLogException(NID_MSG, r, "[E_OBJ_NOT_FOUND] There is not such type of recipient.");
+ goto CATCH;
+ }
+
+ if (type == RECIPIENT_TYPE_TO)
+ {
+ r = __pRecipientList->Remove(recipient, true);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to remove the recipient from TO list.", GetErrorMessage(r));
+ goto CATCH;
+ }
+ }
+ else if (type == RECIPIENT_TYPE_CC)
+ {
+ r = __pRecipientCcList->Remove(recipient, true);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to remove the recipient from CC list.", GetErrorMessage(r));
+ goto CATCH;
+ }
+ }
+ else if (type == RECIPIENT_TYPE_BCC)
+ {
+ r = __pRecipientBccList->Remove(recipient, true);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to remove the recipient from BCC list.", GetErrorMessage(r));
+ goto CATCH;
+ }
+ }
+
+ return E_SUCCESS;
+
+CATCH:
+ return r;
+}
+
+result
+_RecipientListImpl::Set(RecipientType type, const Tizen::Base::Collection::IList& list)
+{
+ result r = E_SUCCESS;
+ int index = 0;
+
+ if (list.GetCount() == 0)
+ {
+ r = E_INVALID_ARG;
+ SysLogException(NID_MSG, r, "[E_INVALID_ARG] The input list has no item.");
+ goto CATCH;
+ }
+
+ for (index = 0; index < list.GetCount(); index++)
+ {
+ String* pItem = (String*) (list.GetAt(index));
+ if (pItem->GetLength() < MIN_LENGTH_PHONE || pItem->GetLength() > MAX_LENGTH_EMAIL)
+ {
+ r = E_INVALID_ARG;
+ SysLogException(NID_MSG, r, "[E_INVALID_ARG] The length of a recipient in the input list is invalid (too short or too long).");
+ goto CATCH;
+ }
+ }
+
+ switch (type)
+ {
+ case RECIPIENT_TYPE_TO:
+ {
+ ClearRecipients(RECIPIENT_TYPE_TO);
+ __pRecipientList = new ArrayList();
+ __pRecipientList->Construct();
+ int count = 0;
+ String* pTmpStr = null;
+ count = list.GetCount();
+ for (index = 0; index < count; index++)
+ {
+ pTmpStr = (String*) (list.GetAt(index));
+ // duplication check in TO
+ if (__pRecipientList->Contains(*pTmpStr))
+ {
+ ClearRecipients(RECIPIENT_TYPE_TO);
+ r = E_OBJ_ALREADY_EXIST;
+ SysLogException(NID_MSG, r,
+ "[E_OBJ_ALREADY_EXIST] There is a duplicate recipient in the input list. Please check the duplications.");
+ goto CATCH;
+ }
+ // duplication check in CC
+ if (__pRecipientCcList && __pRecipientCcList->Contains(*pTmpStr))
+ {
+ ClearRecipients(RECIPIENT_TYPE_TO);
+ r = E_OBJ_ALREADY_EXIST;
+ SysLogException(NID_MSG, r,
+ "[E_OBJ_ALREADY_EXIST] There is a duplicate recipient in the input list comparing to the CC list. Please check the duplications.");
+ goto CATCH;
+ }
+ // duplication check in BCC
+ if (__pRecipientBccList && __pRecipientBccList->Contains(*pTmpStr))
+ {
+ ClearRecipients(RECIPIENT_TYPE_TO);
+ r = E_OBJ_ALREADY_EXIST;
+ SysLogException(NID_MSG, r,
+ "[E_OBJ_ALREADY_EXIST] There is a duplicate recipient in the input list comparing to the BCC list. Please check the duplications.");
+ goto CATCH;
+ }
+ String* pRecipient = new String(*pTmpStr);
+ r = __pRecipientList->Add(*pRecipient);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to add the recipient to the TO list.", GetErrorMessage(r));
+ goto CATCH;
+ }
+ }
+ break;
+ }
+
+ case RECIPIENT_TYPE_CC:
+ {
+ ClearRecipients(RECIPIENT_TYPE_CC);
+ __pRecipientCcList = new ArrayList();
+ __pRecipientCcList->Construct();
+ int count = 0;
+ String* pTmpStr = null;
+ count = list.GetCount();
+ for (index = 0; index < count; index++)
+ {
+ pTmpStr = (String*) (list.GetAt(index));
+ // duplication check in TO
+ if (__pRecipientList && __pRecipientList->Contains(*pTmpStr))
+ {
+ ClearRecipients(RECIPIENT_TYPE_CC);
+ r = E_OBJ_ALREADY_EXIST;
+ SysLogException(NID_MSG, r,
+ "[E_OBJ_ALREADY_EXIST] There is a duplicate recipient in the input list comparing to the TO list. Please check the duplications.");
+ goto CATCH;
+ }
+ // duplication check in CC
+ if (__pRecipientCcList->Contains(*pTmpStr))
+ {
+ ClearRecipients(RECIPIENT_TYPE_CC);
+ r = E_OBJ_ALREADY_EXIST;
+ SysLogException(NID_MSG, r,
+ "[E_OBJ_ALREADY_EXIST] There is a duplicate recipient in the input list. Please check the duplications.");
+ goto CATCH;
+ }
+ // duplication check in BCC
+ if (__pRecipientBccList && __pRecipientBccList->Contains(*pTmpStr))
+ {
+ ClearRecipients(RECIPIENT_TYPE_CC);
+ r = E_OBJ_ALREADY_EXIST;
+ SysLogException(NID_MSG, r,
+ "[E_OBJ_ALREADY_EXIST] There is a duplicate recipient in the input list comparing to the BCC list. Please check the duplications.");
+ goto CATCH;
+ }
+ String* pRecipient = new String(*pTmpStr);
+ r = __pRecipientCcList->Add(*pRecipient);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to add the recipient to the CC list.", GetErrorMessage(r));
+ goto CATCH;
+ }
+ }
+ break;
+ }
+
+ case RECIPIENT_TYPE_BCC:
+ {
+ ClearRecipients(RECIPIENT_TYPE_BCC);
+ __pRecipientBccList = new ArrayList();
+ __pRecipientBccList->Construct();
+ int count = 0;
+ String* pTmpStr = null;
+ count = list.GetCount();
+ for (index = 0; index < count; index++)
+ {
+ pTmpStr = (String*) (list.GetAt(index));
+ // duplication check in TO
+ if (__pRecipientList && __pRecipientList->Contains(*pTmpStr))
+ {
+ ClearRecipients(RECIPIENT_TYPE_BCC);
+ r = E_OBJ_ALREADY_EXIST;
+ SysLogException(NID_MSG, r,
+ "[E_OBJ_ALREADY_EXIST] There is a duplicate recipient in the input list comparing to the TO list. Please check the duplications.");
+ goto CATCH;
+ }
+ // duplication check in CC
+ if (__pRecipientCcList && __pRecipientCcList->Contains(*pTmpStr))
+ {
+ ClearRecipients(RECIPIENT_TYPE_BCC);
+ r = E_OBJ_ALREADY_EXIST;
+ SysLogException(NID_MSG, r,
+ "[E_OBJ_ALREADY_EXIST] There is a duplicate recipient in the input list comparing to the CC list. Please check the duplications.");
+ goto CATCH;
+ }
+ // duplication check in BCC
+ if (__pRecipientBccList->Contains(*pTmpStr))
+ {
+ ClearRecipients(RECIPIENT_TYPE_BCC);
+ r = E_OBJ_ALREADY_EXIST;
+ SysLogException(NID_MSG, r,
+ "[E_OBJ_ALREADY_EXIST] There is a duplicate recipient in the input list. Please check the duplications.");
+ goto CATCH;
+ }
+ String* pRecipient = new String(*pTmpStr);
+ r = __pRecipientBccList->Add(*pRecipient);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_MSG, r, "[%s] Failed to add the recipient to the BCC list.", GetErrorMessage(r));
+ goto CATCH;
+ }
+ }
+ break;
+ }
+
+ default:
+ r = E_INVALID_ARG;
+ SysLogException(NID_MSG, r, "[E_INVALID_ARG] Invalid recipient type (%d).", type);
+ break;
+ }
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+Tizen::Base::Collection::IList*
+_RecipientListImpl::GetListN(RecipientType type)
+{
+ result r = E_SUCCESS;
+ ArrayList* pRetRecipient = null;
+ int index = 0;
+
+ ClearLastResult();
+
+ if (type < RECIPIENT_TYPE_TO || type > RECIPIENT_TYPE_BCC)
+ {
+ SetLastResult(E_INVALID_ARG);
+ SysLogException(NID_MSG, r, "[E_INVALID_ARG] Invalid RecipientType argument.");
+ return null;
+ }
+
+ pRetRecipient = new ArrayList();
+ if (!pRetRecipient)
+ {
+ SetLastResult(E_OUT_OF_MEMORY);
+ SysLogException(NID_MSG, r, "memory allocation failed.");
+ return null;
+ }
+ r = pRetRecipient->Construct();
+ if (IsFailed(r))
+ {
+ SetLastResult(r);
+ SysLogException(NID_MSG, r, "[%s] Failed to construct an ArrayList.", GetErrorMessage(r));
+ delete pRetRecipient;
+ pRetRecipient = null;
+ return null;
+ }
+
+ switch (type)
+ {
+ case RECIPIENT_TYPE_TO:
+ {
+ int count = 0;
+ String* pTmpStr = null;
+
+ if (__pRecipientList)
+ {
+ count = __pRecipientList->GetCount();
+ }
+ if (count == 0)
+ {
+ SysLog(NID_MSG, "TO list has no recipient");
+ return pRetRecipient;
+ }
+
+ for (index = 0; index < count; index++)
+ {
+ pTmpStr = static_cast <String*>(__pRecipientList->GetAt(index));
+ String* pRecipient = new String(*pTmpStr);
+ pRetRecipient->Add(*pRecipient);
+ }
+ break;
+ }
+
+ case RECIPIENT_TYPE_CC:
+ {
+ int count = 0;
+ String* pTmpStr = null;
+
+ if (__pRecipientCcList)
+ {
+ count = __pRecipientCcList->GetCount();
+ }
+ if (count == 0)
+ {
+ SysLog(NID_MSG, "CC list has no recipient");
+ return pRetRecipient;
+ }
+
+ for (index = 0; index < count; index++)
+ {
+ pTmpStr = static_cast <String*>(__pRecipientCcList->GetAt(index));
+ String* pRecipient = new String(*pTmpStr);
+ pRetRecipient->Add(*pRecipient);
+ }
+ break;
+ }
+
+ case RECIPIENT_TYPE_BCC:
+ {
+ int count = 0;
+ String* pTmpStr = null;
+
+ if (__pRecipientBccList)
+ {
+ count = __pRecipientBccList->GetCount();
+ }
+ if (count == 0)
+ {
+ SysLog(NID_MSG, "BCC list has no recipient");
+ return pRetRecipient;
+ }
+
+ for (index = 0; index < count; index++)
+ {
+ pTmpStr = static_cast <String*>(__pRecipientBccList->GetAt(index));
+ String* pRecipient = new String(*pTmpStr);
+ pRetRecipient->Add(*pRecipient);
+ }
+ break;
+ }
+ }
+
+ return pRetRecipient;
+}
+
+_RecipientListImpl*
+_RecipientListImpl::GetInstance(RecipientList& recipientList)
+{
+ return recipientList.__pImpl;
+}
+
+const _RecipientListImpl*
+_RecipientListImpl::GetInstance(const RecipientList& recipientList)
+{
+ return recipientList.__pImpl;
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_RecipientListImpl.h
+ * @brief This is the header file for _RecipientListImpl class.
+ *
+ * This header file contains the declarations of _RecipientListImpl class.
+ */
+
+#ifndef _FMSG_INTERNAL_RECIPIENT_LIST_IMPL_H_
+#define _FMSG_INTERNAL_RECIPIENT_LIST_IMPL_H_
+
+// Includes
+#include <FBaseObject.h>
+#include <FMsgTypes.h>
+
+// forward declaration
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+class ArrayList;
+}}}
+
+namespace Tizen { namespace Messaging
+{
+
+// forward declarations
+class RecipientList;
+
+/**
+* @class _RecipientListImpl
+* @brief This class provides the abstract data type and methods for handling recipients.
+* @since 1.0
+*
+* This class provides the method for handling message recipients. @n
+* A user can add, remove, set, and get recipients using this class. @n
+* The recipient is an email address for an email message and a telephone number for an SMS or MMS message.
+*/
+class _RecipientListImpl
+ : public Tizen::Base::Object
+{
+ // Life cycle
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 1.0
+ */
+ _RecipientListImpl(void);
+
+ /**
+ * This is the copy constructor for this class.
+ *
+ * @since 1.0
+ * @param[in] value An instance of _RecipientListImpl
+ */
+ _RecipientListImpl(const _RecipientListImpl& value);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 1.0
+ */
+ virtual ~_RecipientListImpl(void);
+
+ //Operator
+public:
+ /**
+ * This assignment operator copies recipient list from the specified instance of _RecipientListImpl to the calling instance of _RecipientListImpl.
+ *
+ * @since 1.0
+ * @param[in] rhs The reference of this instance
+ */
+ _RecipientListImpl& operator =(const _RecipientListImpl& rhs);
+
+ /**
+ * This operator compares the two recipient list.
+ *
+ * @since 1.0
+ * @return @c true if both instances are equal @n
+ * @c false, otherwise
+ * @param[in] rhs A reference to the _RecipientListImpl instance on the right-hand side of the operator
+ */
+ bool operator ==(const _RecipientListImpl& rhs) const;
+
+ /**
+ * This operator compares the specified instance with the calling instance for inequality.
+ *
+ * @since 2.1
+ * @return @c true if both instances are not equal, @n
+ * else @c false
+ * @param[in] rhs A reference to the %RecipientList instance on the right-hand side of the operator
+ */
+ bool operator !=(const _RecipientListImpl& rhs) const;
+
+ /**
+ * Gets the hash value of the current instance.
+ *
+ * @since 1.0
+ * @return The hash value of the current instance
+ * @remarks Two equal instances should return the same hash value. For better performance,
+ * the used hash function must generate a random distribution for all inputs.
+ */
+ virtual int GetHashCode(void) const;
+
+ // Operation
+public:
+ /**
+ * Compares the specified instance with the calling instance.
+ *
+ * @since 1.0
+ * @return @c true if both instances are equal @n
+ * @c false, otherwise
+ * @param[in] value An instance of _RecipientListImpl
+ */
+ virtual bool Equals(const Tizen::Base::Object& value) const;
+ /**
+ * Adds a recipient string.
+ *
+ * @since 1.0
+ * @return An error code
+ * @param[in] type The type of recipient
+ * @param[in] recipient The recipient
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_OUT_OF_MEMORY Insufficient memory.
+ * @exception E_OBJ_ALREADY_EXIST The specified recipient is already added.
+ * @exception E_INVALID_ARG The specified @c recipient %string length is too @c short (< 3) or too @c long (> 320). @n
+ * The value of 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 3 for phone number and 5 for email address. @n
+ * The maximum length of a recipient is 41 for phone number and 320 for email address.
+ * @see Set(), GetListN(), SmsManager::Send(), MmsManager::Send(), EmailManager::Send()
+ */
+ result Add(RecipientType type, const Tizen::Base::String& recipient);
+
+ /**
+ * Remove a recipient.
+ *
+ * @since 1.0
+ * @return An error code
+ * @param[in] type The type of recipient
+ * @param[in] recipient The recipient string
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_ARG The specified @c recipient %string length is too @c short (< 3) or too @c long (> 320). @n
+ * The value of the specified @c type is invalid.
+ * @exception E_OBJ_NOT_FOUND There is no such recipient.
+ * @see Add()
+ */
+ result Remove(RecipientType type, const Tizen::Base::String& recipient);
+
+
+ /**
+ * Sets a recipient list.
+ *
+ * @since 1.0
+ * @return An error code
+ * @param[in] type The type of recipient
+ * @param[in] list A list of recipient strings
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_ARG The length of one of the recipients in the list is too @c short (< 3) or too @c long (> 320). @n
+ * The value of the specified @c type is invalid.
+ * @exception E_OUT_OF_MEMORY Insufficient memory.
+ * @exception E_OBJ_ALREADY_EXIST There is a duplicate recipient in the recipient list.
+ * @remarks The limit of recipients is not checked in this method. @n
+ * This is done in Send() method of each manager class. (SmsManager, MmsManager, and EmailManager)
+ * @see Add(), GetListN()
+ */
+ result Set(RecipientType type, const Tizen::Base::Collection::IList& list);
+
+ /**
+ * Gets the recipient list of the specific recipient type.
+ *
+ * @since 1.0
+ * @return The list of the recipient
+ * @param[in] type The type of recipient
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_OUT_OF_MEMORY Insufficient memory.
+ * @exception E_INVALID_ARG The value of the specified @c type is invalid.
+ * @remarks The recipient is an email address for an email message and a telephone number for an SMS or MMS message. The type of the recipient is String. @n
+ * The specific error code can be accessed using the GetLastResult() method.
+ * @see Add(), Set()
+ */
+ Tizen::Base::Collection::IList* GetListN(RecipientType type);
+
+ /**
+ * Returns the number of recipients ( To + Cc + Bcc ).
+ *
+ * @return The number of total recipient count
+ */
+ int GetTotalRecipientCount(void) const;
+
+ /**
+ * Clear corresponding recipients ( To or Cc or Bcc ).
+ *
+ */
+ void ClearRecipients(RecipientType type);
+
+ /**
+ * Clear all recipients ( To + Cc + Bcc ).
+ *
+ */
+ void ClearAllRecipients(void);
+
+public:
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _RecipientListImpl
+ * @param[in] recipientList An instance of RecipientList
+ */
+ static _RecipientListImpl* GetInstance(RecipientList& recipientList);
+
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _RecipientListImpl
+ * @param[in] recipientList An instance of RecipientList
+ */
+ static const _RecipientListImpl* GetInstance(const RecipientList& recipientList);
+
+private:
+ Tizen::Base::Collection::ArrayList* __pRecipientList;
+ Tizen::Base::Collection::ArrayList* __pRecipientCcList;
+ Tizen::Base::Collection::ArrayList* __pRecipientBccList;
+}; // _RecipientListImpl
+} } // Tizen::Messaging
+
+#endif // _FMSG_INTERNAL_RECIPIENT_LIST_IMPL_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_SmsEvent.cpp
+ * @brief This is the implementation file for the %_SmsEvent class.
+ *
+ * This file contains the implementation of the %_SmsEvent class.
+ */
+
+#include <FMsgISmsMessageEventListener.h>
+#include <FMsgISmsListener.h>
+#include <FMsgICbsMessageEventListener.h>
+#include <FMsgIWapPushEventListener.h>
+#include <FMsgIEtwsPrimaryNotificationEventListener.h>
+#include <FMsgSmsMessage.h>
+#include <FMsgCbsMessage.h>
+#include <FMsgWapPushMessage.h>
+#include <FMsgEtwsPrimaryNotification.h>
+#include <FBaseErrorDefine.h>
+#include <FBaseSysLog.h>
+#include "FMsg_SmsEvent.h"
+#include "FMsg_SmsEventArg.h"
+#include "FMsg_SmsMessageImpl.h"
+#include "FMsg_CbsMessageImpl.h"
+#include "FMsg_WapPushMessageImpl.h"
+#include "FMsg_EtwsPrimaryNotificationImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Messaging
+{
+
+_SmsEvent::_SmsEvent(void)
+ : __port(-1)
+ , __smsEventType(_SMS_EVENT_TYPE_NONE)
+{
+}
+
+result
+_SmsEvent::Construct(_SmsEventType type)
+{
+ __smsEventType = type;
+
+ return _Event::Initialize();
+}
+
+result
+_SmsEvent::Construct(int port)
+{
+ __smsEventType = _SMS_EVENT_TYPE_SMS_TRIGGER;
+ __port = port;
+
+ return _Event::Initialize();
+}
+
+int
+_SmsEvent::GetPort(void) const
+{
+ return __port;
+}
+
+_SmsEventType
+_SmsEvent::GetType(void) const
+{
+ return __smsEventType;
+}
+
+void
+_SmsEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+ result r = E_SUCCESS;
+
+ ISmsListener* pSmsListener = null;
+ ISmsEventListener* pSmsEventListener = null;
+ ISmsMessageEventListener* pSmsMessageEventListener = null;
+ ICbsMessageEventListener* pCbsMessageEventListener = null;
+ IWapPushEventListener* pWapPushMessageEventListener = null;
+ IEtwsPrimaryNotificationEventListener* pEtwsNotificationMesssageEventListener = null;
+
+ IEventArg* pEventArg = const_cast <IEventArg*>(&arg);
+ _SmsEventArg* pSmsEventArg = dynamic_cast <_SmsEventArg*>(pEventArg);
+ SysTryReturnVoidResult(NID_MSG, pSmsEventArg != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system.");
+
+ SmsMessage message;
+ CbsMessage* pCbsMessage = null;
+ WapPushMessage* pWapPushMessage = null;
+ EtwsPrimaryNotification* pEtwsNotificationMessage = null;
+ DateTime dateTime;
+ int port = 0;
+ String sender;
+
+ if (pSmsEventArg->GetEventType() == _SMS_EVENT_TYPE_SMS_SEND_RESULT)
+ {
+ pSmsListener = dynamic_cast <ISmsListener*>(&listener);
+ SysTryReturnVoidResult(NID_MSG, pSmsListener != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system.");
+ pSmsEventArg->GetErrorResult(r);
+ // Fire
+ pSmsListener->OnSmsMessageSent(r);
+ }
+ else if (pSmsEventArg->GetEventType() == _SMS_EVENT_TYPE_SMS_TRIGGER)
+ {
+ pSmsEventListener = dynamic_cast <ISmsEventListener*>(&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();
+ port = pSmsEventArg->GetPort();
+ // Fire
+ pSmsEventListener->OnSmsMessageReceived(port, dateTime, message);
+ }
+ else if (pSmsEventArg->GetEventType() == _SMS_EVENT_TYPE_SMS_RECEIVE_RESULT)
+ {
+ pSmsMessageEventListener = dynamic_cast <ISmsMessageEventListener*>(&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());
+ // Fire
+ pSmsMessageEventListener->OnSmsMessageReceived(message);
+ }
+ else if (pSmsEventArg->GetEventType() == _SMS_EVENT_TYPE_CBS_RECEIVE_RESULT)
+ {
+ pCbsMessageEventListener = dynamic_cast <ICbsMessageEventListener*>(&listener);
+ SysTryReturnVoidResult(NID_MSG, pCbsMessageEventListener != null, E_SYSTEM, "[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());
+ }
+ // Fire
+ if (pCbsMessage)
+ {
+ pCbsMessageEventListener->OnCbsMessageReceived((*pCbsMessage));
+ delete pCbsMessage;
+ pCbsMessage = null;
+ }
+ }
+ else if (pSmsEventArg->GetEventType() == _SMS_EVENT_TYPE_WAP_PUSH_RECEIVE_RESULT)
+ {
+ pWapPushMessageEventListener = dynamic_cast <IWapPushEventListener*>(&listener);
+ SysTryReturnVoidResult(NID_MSG, pWapPushMessageEventListener != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system.");
+ pWapPushMessage = _WapPushMessageImpl::GetWapPushMessageN(pSmsEventArg->GetMessage(), *(pSmsEventArg->GetWapPushBody()));
+
+ // Fire
+ if (pWapPushMessage)
+ {
+ pWapPushMessageEventListener->OnWapPushMessageReceived((*pWapPushMessage));
+ delete pWapPushMessage;
+ pWapPushMessage = null;
+ }
+ }
+ else if (pSmsEventArg->GetEventType() == _SMS_EVENT_TYPE_ETWS_RECEIVE_RESULT)
+ {
+ pEtwsNotificationMesssageEventListener = dynamic_cast <IEtwsPrimaryNotificationEventListener*>(&listener);
+ SysTryReturnVoidResult(NID_MSG, pEtwsNotificationMesssageEventListener != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system.");
+ pEtwsNotificationMessage = _EtwsPrimaryNotificationImpl::GetEtwsPrimaryNotificationN();
+
+ if (pEtwsNotificationMessage)
+ {
+ _EtwsPrimaryNotificationImpl::GetInstance(*pEtwsNotificationMessage)->SetEtwsMessageImpl(pSmsEventArg->GetDateTime(), *(pSmsEventArg->GetSerialNumber()), *(pSmsEventArg->GetWarningSecurityInfo()), pSmsEventArg->GetMessageId(), *(pSmsEventArg->GetEtwsWarningType()));
+ }
+ // Fire
+ if (pEtwsNotificationMessage)
+ {
+ pEtwsNotificationMesssageEventListener->OnEtwsPrimaryNotificationReceived((*pEtwsNotificationMessage));
+ delete pEtwsNotificationMessage;
+ pEtwsNotificationMessage = null;
+ }
+ }
+}
+
+} }
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_SmsEvent.h
+ * @brief This is the header file for _SmsEvent class.
+ *
+ * This header file contains the declarations of _SmsEvent class.
+ */
+
+
+#ifndef _FMSG_INTERNAL_SMS_EVENT_H_
+#define _FMSG_INTERNAL_SMS_EVENT_H_
+
+// Includes
+#include <FBaseRt_Event.h>
+#include "FMsg_Types.h"
+
+namespace Tizen { namespace Messaging
+{
+
+//
+// @class _SmsEvent
+// @brief This class provides the event for SMS message.
+// @since 1.0
+//
+// @see ISmsEventListener, _SmsEventArg
+//
+
+class _SmsEvent
+ : public Tizen::Base::Runtime::_Event
+{
+// Life cycle
+public:
+ /**
+ * This is the constructor.
+ *
+ */
+ _SmsEvent(void);
+
+ /**
+ * This is the class destructor.
+ *
+ */
+ virtual ~_SmsEvent(void) {};
+
+ /**
+ * Initializes a new instance of the class
+ *
+ */
+ result Construct(_SmsEventType type);
+
+ /**
+ * This is the overloaded Construct. (just for SMS Trigger)
+ *
+ */
+ result Construct(int port);
+
+ /**
+ * Get the corresponding port number (just for SMS trigger)
+ */
+ int GetPort(void) const;
+
+ /**
+ * Get the SMS event type
+ */
+ _SmsEventType GetType(void) const;
+
+
+//Operations
+protected:
+ void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+ _SmsEvent(const _SmsEvent& smsEvent);
+ _SmsEvent& operator =(const _SmsEvent& value);
+
+ // Attributes
+private:
+ int __port;
+ _SmsEventType __smsEventType;
+}; // _SmsEvent
+
+} }
+
+#endif // _FMSG_INTERNAL_SMS_EVENT_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_SmsEventArg.cpp
+ * @brief This is the implementation file for the %_SmsEventArg class.
+ *
+ * This file contains the implementation of the %_SmsEventArg class.
+ */
+
+#include <FBaseErrorDefine.h>
+#include <FBaseErrors.h>
+#include <FBaseSysLog.h>
+#include "FMsg_SmsEventArg.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Messaging
+{
+
+_SmsEventArg::_SmsEventArg(void)
+{
+ __eventType = _SMS_EVENT_TYPE_NONE;
+ __port = -1;
+ __result = E_SUCCESS;
+ __pPushMsgBody = null;
+ __pMsgSerialNumber = null;
+ __pMsgSecurityInfo = null;
+ __pEtwsWarningType = null;
+}
+
+_SmsEventArg::_SmsEventArg(const result r)
+{
+ __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
+ }
+}
+
+_SmsEventArg::_SmsEventArg(int port, const DateTime& dateTime, const String& message)
+{
+ __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)
+{
+ __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)
+{
+ __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");
+
+ __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)
+{
+ __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");
+
+ __pMsgSerialNumber->Construct(msgSerialNumber);
+ __pMsgSerialNumber->SetPosition(0);
+
+ __pMsgSecurityInfo = new (std::nothrow) ByteBuffer();
+ SysTryReturnVoidResult(NID_MSG, __pMsgSecurityInfo != null, E_OUT_OF_MEMORY, "memory allocation failed");
+
+ __pMsgSecurityInfo->Construct(msgSecurityInfo);
+ __pMsgSecurityInfo->SetPosition(0);
+
+ __pEtwsWarningType = new (std::nothrow) ByteBuffer();
+ SysTryReturnVoidResult(NID_MSG, __pEtwsWarningType != null, E_OUT_OF_MEMORY, "memory allocation failed");
+
+ __pEtwsWarningType->Construct(etwsWarningType);
+ __pEtwsWarningType->SetPosition(0);
+}
+
+_SmsEventArg::_SmsEventArg(const Tizen::Base::String& pushMsgHdr, const Tizen::Base::ByteBuffer& pushMsgBody, _SmsEventType eventType)
+{
+ __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");
+
+ __pPushMsgBody->Construct(pushMsgBody);
+ __pPushMsgBody->SetPosition(0);
+}
+
+_SmsEventArg::~_SmsEventArg(void)
+{
+ if (__pPushMsgBody)
+ {
+ delete __pPushMsgBody;
+ __pPushMsgBody = null;
+ }
+
+ if (__pMsgSerialNumber)
+ {
+ delete __pMsgSerialNumber;
+ __pMsgSerialNumber = null;
+ }
+
+ if (__pMsgSecurityInfo)
+ {
+ delete __pMsgSecurityInfo;
+ __pMsgSecurityInfo = null;
+ }
+
+ if (__pEtwsWarningType)
+ {
+ delete __pEtwsWarningType;
+ __pEtwsWarningType = null;
+ }
+}
+
+void
+_SmsEventArg::GetErrorResult(result& r) const
+{
+ if (__eventType == _SMS_EVENT_TYPE_SMS_SEND_RESULT)
+ {
+ r = __result;
+ }
+ else
+ {
+ r = E_UNKNOWN;
+ }
+}
+
+int
+_SmsEventArg::GetPort(void) const
+{
+ if (__eventType == _SMS_EVENT_TYPE_SMS_SEND_RESULT || __eventType == _SMS_EVENT_TYPE_NONE)
+ {
+ return -1;
+ }
+
+ return __port;
+}
+
+DateTime
+_SmsEventArg::GetDateTime(void) const
+{
+ if (__eventType == _SMS_EVENT_TYPE_SMS_SEND_RESULT || __eventType == _SMS_EVENT_TYPE_NONE)
+ {
+ DateTime dt;
+ dt.SetValue(9999, 12, 31);
+ return dt;
+ }
+
+ return __dateTime;
+}
+
+String
+_SmsEventArg::GetMessage(void) const
+{
+ if (__eventType == _SMS_EVENT_TYPE_SMS_SEND_RESULT || __eventType == _SMS_EVENT_TYPE_NONE)
+ {
+ return L"";
+ }
+
+ return __message;
+}
+
+String
+_SmsEventArg::GetSenderAddress(void) const
+{
+ if (__eventType != _SMS_EVENT_TYPE_SMS_RECEIVE_RESULT)
+ {
+ return L"";
+ }
+
+ return __sender;
+}
+
+_SmsEventType
+_SmsEventArg::GetEventType(void) const
+{
+ return __eventType;
+}
+
+Tizen::Base::ByteBuffer*
+_SmsEventArg::GetWapPushBody(void) const
+{
+ return __pPushMsgBody;
+}
+
+int
+_SmsEventArg::GetMessageId(void) const
+{
+ return __messageId;
+}
+
+Tizen::Base::ByteBuffer*
+_SmsEventArg::GetSerialNumber(void) const
+{
+ return __pMsgSerialNumber;
+}
+
+Tizen::Base::ByteBuffer*
+_SmsEventArg::GetWarningSecurityInfo(void) const
+{
+ return __pMsgSecurityInfo;
+}
+
+Tizen::Base::ByteBuffer*
+_SmsEventArg::GetEtwsWarningType(void) const
+{
+ return __pEtwsWarningType;
+}
+
+bool
+_SmsEventArg::GetEtwsNotification(void) const
+{
+ return __isEtwsNotification;
+}
+
+byte
+_SmsEventArg::GetDataCodingScheme(void) const
+{
+ return __dataCodingScheme;
+}
+
+} }
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_SmsEventArg.h
+ * @brief This is the header file for _SmsEventArg class.
+ *
+ * This header file contains the declarations of _SmsEventArg class.
+ */
+
+
+#ifndef _FMSG_INTERNAL_SMS_EVENT_ARG_H_
+#define _FMSG_INTERNAL_SMS_EVENT_ARG_H_
+
+// Includes
+#include <FBaseByteBuffer.h>
+#include <FBaseObject.h>
+#include <FBaseDataType.h>
+#include <FBaseDateTime.h>
+#include <FBaseString.h>
+#include <FBaseRtIEventArg.h>
+#include "FMsg_Types.h"
+
+namespace Tizen { namespace Messaging
+{
+
+//
+// @class _SmsEventArg
+// @brief This class provides methods for getting data from SMS event
+// @since 1.0
+//
+
+class _SmsEventArg
+ : public Tizen::Base::Object
+ , public Tizen::Base::Runtime::IEventArg
+{
+ // Life cycle
+public:
+ /**
+ * This is the default constructor.
+ *
+ */
+ _SmsEventArg(void);
+
+ /**
+ * This is the constructor.
+ *
+ * @param[in] r - the result
+ */
+ _SmsEventArg(const result r);
+
+ /**
+ * This is the constructor.
+ *
+ * @param[in] port - the port number
+ * @param[in] dateTime - the received date time
+ * @param[in] message - the received message
+ */
+ _SmsEventArg(int port, const Tizen::Base::DateTime& dateTime, const Tizen::Base::String& message);
+
+ /**
+ * This is the constructor.
+ *
+ * @param[in] text The body text of the message
+ * @param[in] senderAddress The sender address of the message
+ * @param[in] receivedTime The received time of the message
+ */
+ _SmsEventArg(const Tizen::Base::String& text, const Tizen::Base::String& senderAddress, const Tizen::Base::DateTime& receivedTime);
+
+ /**
+ * This is the constructor.
+ *
+ * @param[in] text The body text of the message
+ * @param[in] msgSerialNumber The msg SerialNumber of the message
+ * @param[in] receivedTime The received time of the message
+ * @param[in] messageId The messageId of the message
+ * @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);
+
+ /**
+ * This is the constructor.
+ *
+ * @param[in] receivedTime The received time of the message
+ * @param[in] msgSerialNumber The msg SerialNumber of the message
+ * @param[in] msgSecurityInfo The msg Security Info
+ * @param[in] messageId The messageId of the message
+ * @param[in] etwsWarningType The Etws Warning Type
+ * @param[in] eventType The received event type of the message
+ */
+ _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);
+
+
+ /**
+ * This is the constructor.
+ *
+ * @param[in] pushMsgHdr The header of the message
+ * @param[in] pushMsgBody The body text of the message
+ * @param[in] eventType The received event type of the message
+ */
+ _SmsEventArg(const Tizen::Base::String& pushMsgHdr, const Tizen::Base::ByteBuffer& pushMsgBody, _SmsEventType eventType);
+
+
+ /**
+ * This is class destructor.
+ *
+ */
+ virtual ~_SmsEventArg(void);
+
+ // Access
+public:
+ /**
+ * Gets the error result of SMS sending
+ *
+ * @param[out] r - the message composer result
+ * @exception E_SUCCESS - operation is successful
+ * @exception E_OUT_OF_MEMORY - failed to allocate required/requested memory
+ * @exception E_SYSTEM - the system has an error.
+ */
+ void GetErrorResult(result& r) const;
+
+ /**
+ * Gets the port number
+ *
+ * @return the port number
+ */
+ int GetPort(void) const;
+
+ /**
+ * Gets the date time
+ *
+ * @return the date time
+ */
+ Tizen::Base::DateTime GetDateTime(void) const;
+
+ /**
+ * Gets the received message
+ *
+ * @return the received message
+ */
+ Tizen::Base::String GetMessage(void) const;
+
+ /**
+ * Gets the sender address
+ *
+ * @return the sender address
+ */
+ Tizen::Base::String GetSenderAddress(void) const;
+
+ /**
+ * Gets the serial number
+ *
+ * @return the serial number
+ */
+ Tizen::Base::ByteBuffer* GetSerialNumber(void) const;
+
+ /**
+ * Gets the security info
+ *
+ * @return the security info
+ */
+ Tizen::Base::ByteBuffer* GetWarningSecurityInfo(void) const;
+
+ /**
+ * Gets the mesage id
+ *
+ * @return the mesage id
+ */
+ int GetMessageId(void) const;
+
+ /**
+ * Gets the cbs message ETWS status
+ *
+ * @return ETWS status
+ */
+ bool GetEtwsNotification(void) const;
+
+ /**
+ * Gets the cbs message Data Coding Scheme
+ *
+ * @return Data Coding scheme
+ */
+ byte GetDataCodingScheme(void) const;
+
+ /**
+ * Gets the event type
+ *
+ * @return the event type
+ */
+ _SmsEventType GetEventType(void) const;
+
+ /**
+ * Gets the event type
+ *
+ * @return the event type
+ */
+ Tizen::Base::ByteBuffer* GetEtwsWarningType(void) const;
+
+ /**
+ * Gets the wap push body
+ *
+ * @return wap push body
+ */
+
+ Tizen::Base::ByteBuffer* GetWapPushBody(void) const;
+
+private:
+ _SmsEventArg(const _SmsEventArg& eventArg);
+ _SmsEventArg& operator =(const _SmsEventArg& value);
+
+private:
+ result __result;
+ Tizen::Base::String __message;
+ int __port;
+ Tizen::Base::String __sender;
+ Tizen::Base::DateTime __dateTime;
+ _SmsEventType __eventType;
+ Tizen::Base::ByteBuffer* __pPushMsgBody;
+ Tizen::Base::ByteBuffer* __pMsgSerialNumber;
+ Tizen::Base::ByteBuffer* __pMsgSecurityInfo;
+ int __messageId;
+ bool __isEtwsNotification;
+ Tizen::Base::ByteBuffer* __pEtwsWarningType;
+ byte __dataCodingScheme;
+}; // _SmsEventArg
+
+} }
+
+#endif // _FMSG_INTERNAL_SMS_EVENT_ARG_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_SmsManagerImpl.cpp
+ * @brief This is the implementation file for the %_SmsManagerImpl class.
+ *
+ * This file contains the implementation of the %_SmsManagerImpl class.
+ */
+
+// OAF headers
+#include <unique_ptr.h>
+#include <messages.h>
+#include <email.h>
+#include <FMsgSmsManager.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include "FMsg_SmsManagerImpl.h"
+#include "FMsg_SmsMessageImpl.h"
+#include "FMsg_SmsEvent.h"
+#include "FMsg_MsgUtil.h"
+#include "FMsg_RecipientListImpl.h"
+#include "FMsg_SmsMmsCallbackHandler.h"
+#include "FMsg_CbsChannelImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Messaging;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Messaging
+{
+
+_SmsManagerImpl::_SmsManagerImpl(void)
+ : __isConstructed(false)
+ , __isCbsSaveEnabled(true)
+ , __pSmsEvent(null)
+ , __pSmsReceiveEvent(null)
+ , __pCbsReceiveEvent(null)
+ , __pEtwsReceiveEvent(null)
+ , __pSmsTriggerEventList(null)
+ , __msgHandle(0)
+ , __cbsSettingsHandle(0)
+ , __pCbsListener(null)
+ , __pEtwsListener(null)
+{
+}
+
+_SmsManagerImpl::~_SmsManagerImpl(void)
+{
+ int err = MESSAGES_ERROR_NONE;
+
+ if (__pSmsReceiveEvent)
+ {
+ delete __pSmsReceiveEvent;
+ __pSmsReceiveEvent = null;
+ }
+
+ if (__pCbsReceiveEvent)
+ {
+ delete __pCbsReceiveEvent;
+ __pCbsReceiveEvent = null;
+ }
+
+ if (__pEtwsReceiveEvent)
+ {
+ delete __pEtwsReceiveEvent;
+ __pEtwsReceiveEvent = null;
+ }
+
+ if (__pSmsTriggerEventList)
+ {
+ if (__pSmsTriggerEventList->GetCount() > 0)
+ {
+ __pSmsTriggerEventList->RemoveAll(true);
+ }
+ delete __pSmsTriggerEventList;
+ __pSmsTriggerEventList = null;
+ }
+
+ if (_SmsMmsCallbackHandler::GetInstance())
+ {
+ err = messages_cb_unset_incoming_cb(__msgHandle);
+ err = messages_cb_unset_etws_primary_noti_cb(__msgHandle);
+ err = _SmsMmsCallbackHandler::GetInstance()->CloseMessageHandle();
+ }
+
+ __isConstructed = false;
+}
+
+result
+_SmsManagerImpl::Construct(const ISmsListener& listener)
+{
+ // method return code
+ result r = E_SUCCESS;
+ int err = MESSAGES_ERROR_NONE;
+
+ SysAssertf(__isConstructed == false, "_SmsManagerImpl instance is already constructed.");
+
+ // set event
+ unique_ptr<_SmsEvent> pSmsEvent(new (std::nothrow) _SmsEvent());
+ SysTryReturn(NID_MSG, pSmsEvent != null, E_OUT_OF_MEMORY, r = E_OUT_OF_MEMORY, "memory allocation failed.");
+
+ // event construction
+ r = pSmsEvent->Construct(_SMS_EVENT_TYPE_SMS_SEND_RESULT);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to construct an instance");
+
+ // add listener
+ r = pSmsEvent->AddListener(listener, true);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to add a listener");
+
+ SysTryReturnResult(NID_MSG, _SmsMmsCallbackHandler::GetInstance() != NULL, E_SYSTEM, "Failed to constructSmsMmsCallbackHandler.");
+
+ // open message handle
+ err = _SmsMmsCallbackHandler::GetInstance()->OpenMessageHandle(__msgHandle);
+ SysLog(NID_MSG, "value of __msgHandle is [%d]", __msgHandle);
+
+ r = ConvertException(err);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to open messageHandle.");
+
+ // check value of msg handle
+ SysTryReturnResult(NID_MSG, __msgHandle > 0, E_SYSTEM, "msgHandle is invalid.");
+
+ // open CB message settings handle
+ err = _SmsMmsCallbackHandler::GetInstance()->OpenCbsSettingsHandle(__cbsSettingsHandle);
+ SysLog(NID_MSG, "value of __cbsSettingsHandle is [%d]", __cbsSettingsHandle);
+
+ if (err == MESSAGES_ERROR_NO_SIM_CARD)
+ {
+ r = E_SUCCESS;
+ SysLog(NID_MSG, "Sim card is not present in device"); // even no sim, return sucess so that app will launch sucess
+ }
+ else
+ {
+ r = ConvertException(err);
+ SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to open cbs Settings Handle");
+
+ // check value of cbs settings handle
+ SysTryReturnResult(NID_MSG, __cbsSettingsHandle > 0, E_SYSTEM, "cbsSettingsHandle is invalid.");
+ }
+
+ __pSmsEvent = move(pSmsEvent);
+ __isConstructed = true;
+
+ return r;
+}
+
+result
+_SmsManagerImpl::AddSmsEventListener(int port, ISmsEventListener& eventListener)
+{
+ // checking conditions
+ SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet.");
+ SysAssertf(__msgHandle > 0, "message handle is invalid.");
+
+ result r = E_SUCCESS;
+ _SmsEvent* pSmsTriggerEvent = null;
+ int err = MESSAGES_ERROR_NONE;
+
+ // check duplications
+ if (__pSmsTriggerEventList)
+ {
+ int listSize = __pSmsTriggerEventList->GetCount();
+ for (int i = 0; i < listSize; i++)
+ {
+ _SmsEvent* pItem = static_cast <_SmsEvent*>(__pSmsTriggerEventList->GetAt(i));
+ if (pItem->GetPort() == port)
+ {
+ r = E_OBJ_ALREADY_EXIST;
+ SysLogException(NID_MSG, r, "[%s] The specific port [%d] is already registered.", GetErrorMessage(r), port);
+ goto CATCH;
+ }
+ }
+ }
+
+ // make an sms trigger event
+ pSmsTriggerEvent = new (std::nothrow) _SmsEvent();
+ SysTryReturn(NID_MSG, pSmsTriggerEvent != null, E_OUT_OF_MEMORY, r = E_OUT_OF_MEMORY, "memory allocation failed");
+
+ // construct an sms trigger event
+ r = pSmsTriggerEvent->Construct(port);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to construct an instance.", GetErrorMessage(r));
+
+ // add corresponding listener to the event
+ r = pSmsTriggerEvent->AddListener(eventListener, true);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to add a listener.", GetErrorMessage(r));
+
+ // make a list for events
+ if (!__pSmsTriggerEventList)
+ {
+ __pSmsTriggerEventList = new (std::nothrow) ArrayList();
+ SysTryReturnResult(NID_MSG, __pSmsTriggerEventList != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+
+ r = __pSmsTriggerEventList->Construct();
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to construct an instance.", GetErrorMessage(r));
+ }
+ // add an event to the list
+ r = __pSmsTriggerEventList->Add(*pSmsTriggerEvent);
+ 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);
+
+ if (err != MESSAGES_ERROR_NONE)
+ {
+ 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));
+
+ goto CATCH;
+ }
+
+ return r;
+
+CATCH:
+ if (pSmsTriggerEvent)
+ {
+ delete pSmsTriggerEvent;
+ }
+
+ return r;
+}
+
+result
+_SmsManagerImpl::RemoveSmsEventListener(int port, ISmsEventListener& eventListener)
+{
+ SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet.");
+ SysAssertf(__msgHandle > 0, "message handle is invalid.");
+
+ result r = E_SUCCESS;
+ int index = -1;
+ int listSize = -1;
+ bool isFound = false;
+ int err = MESSAGES_ERROR_NONE;
+
+ // find the SmsTriggerEvent using port
+ if (__pSmsTriggerEventList)
+ {
+ listSize = __pSmsTriggerEventList->GetCount();
+ for (int i = 0; i < listSize; i++)
+ {
+ _SmsEvent* pItem = static_cast <_SmsEvent*>(__pSmsTriggerEventList->GetAt(i));
+ if (pItem->GetPort() == port)
+ {
+ index = i;
+ isFound = true;
+ break;
+ }
+ }
+ }
+
+ // if not found..
+ SysTryReturn(NID_MSG, isFound, E_OBJ_NOT_FOUND, r = E_OBJ_NOT_FOUND, "Failed to find the SMS event listener");
+
+ // remove corresponding event from the list
+ 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;
+}
+
+result
+_SmsManagerImpl::AddSmsMessageEventListener(const ISmsMessageEventListener& eventListener)
+{
+ SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet.");
+ SysAssertf(__msgHandle > 0, "message handle is invalid.");
+
+ result r = E_SUCCESS;
+ int err = MESSAGES_ERROR_NONE;
+
+ // set event
+ if (!__pSmsReceiveEvent)
+ {
+ __pSmsReceiveEvent = new (std::nothrow) _SmsEvent();
+ SysTryReturn(NID_MSG, __pSmsReceiveEvent != null, E_OUT_OF_MEMORY, r = E_OUT_OF_MEMORY, "memory allocation failed");
+
+ r = __pSmsReceiveEvent->Construct(_SMS_EVENT_TYPE_SMS_RECEIVE_RESULT);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "Failed to construct an instance");
+ }
+
+ // add listener
+ 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*)
+ __pSmsReceiveEvent);
+
+ r = ConvertException(err);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to add a listener.", GetErrorMessage(r));
+
+ return E_SUCCESS;
+
+CATCH:
+ if (__pSmsReceiveEvent)
+ {
+ delete __pSmsReceiveEvent;
+ __pSmsReceiveEvent = null;
+ }
+
+ return r;
+}
+
+result
+_SmsManagerImpl::RemoveSmsMessageEventListener(const ISmsMessageEventListener& eventListener)
+{
+ SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet.");
+ 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 (__pSmsReceiveEvent)
+ {
+ delete __pSmsReceiveEvent;
+ __pSmsReceiveEvent = null;
+ }
+
+ return r;
+
+CATCH:
+ return r;
+}
+
+int
+_SmsManagerImpl::GetTotalMessageCount(SmsMessageBoxType type) const
+{
+ SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet.");
+ SysAssertf(__msgHandle > 0, "message handle is invalid.");
+
+ int msgCount = 0;
+ int err = MESSAGES_ERROR_NONE;
+ messages_message_box_e folderType = MESSAGES_MBOX_INBOX;
+ result r = E_SUCCESS;
+
+ ClearLastResult();
+
+ switch (type)
+ {
+ case SMS_MESSAGE_BOX_TYPE_INBOX:
+ folderType = MESSAGES_MBOX_INBOX;
+ break;
+ case SMS_MESSAGE_BOX_TYPE_SENTBOX:
+ folderType = MESSAGES_MBOX_SENTBOX;
+ break;
+ case SMS_MESSAGE_BOX_TYPE_OUTBOX:
+ folderType = MESSAGES_MBOX_OUTBOX;
+ break;
+ case SMS_MESSAGE_BOX_TYPE_ALL:
+ folderType = MESSAGES_MBOX_ALL;
+ break;
+ case SMS_MESSAGE_BOX_TYPE_NONE: // impossible case
+ break;
+ default:
+ break;
+ }
+
+ // get the count of corresponding message box
+ err = messages_get_message_count(__msgHandle, folderType, MESSAGES_TYPE_SMS, &msgCount);
+ if (err != MESSAGES_ERROR_NONE)
+ {
+ r = ConvertException(err);
+ SysLogException(NID_MSG, r, "[%s] Failed to get the message count of the message box (%d)", GetErrorMessage(r), (int) type);
+ SetLastResult(r);
+ return -1;
+ }
+ SysLog(NID_MSG, "Total count of messages is [%d]", msgCount);
+
+ return msgCount;
+}
+
+Tizen::Base::Collection::IList*
+_SmsManagerImpl::SearchInboxN(const Tizen::Base::String* pKeyword, const Tizen::Base::String* pSenderAddress, int startIndex,
+ int count,
+ int& totalResultCount) const
+{
+ SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet.");
+ SysAssertf(__msgHandle > 0, "message handle is invalid.");
+
+ char* pSearchString = NULL;
+ char* pSenderAddressTemp = NULL;
+ ArrayList* pList = null;
+ int err = MESSAGES_ERROR_NONE;
+ result r = E_SUCCESS;
+ messages_message_h* pMsgList = null;
+ int searchCount = 0;
+ int totalCount = 0;
+
+ ClearLastResult();
+
+ pList = new (std::nothrow) ArrayList();
+ SysTryCatch(NID_MSG, pList != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+
+ // make a list
+ r = pList->Construct();
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "Failed to construct an ArrayList");
+
+ // keyword
+ if (pKeyword)
+ {
+ pSearchString = _StringConverter::CopyToCharArrayN(*pKeyword);
+ }
+
+ // sender address
+ if (pSenderAddress)
+ {
+ pSenderAddressTemp = _StringConverter::CopyToCharArrayN(*pSenderAddress);
+ }
+
+ // searching
+ err = messages_search_message(__msgHandle, MESSAGES_MBOX_INBOX, MESSAGES_TYPE_SMS,
+ pSearchString, pSenderAddressTemp, startIndex, count,
+ &pMsgList, &searchCount, &totalCount);
+
+ r = ConvertException(err);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] msg_search_message call failed.", GetErrorMessage(r));
+
+ totalResultCount = searchCount;
+
+ SysLog(NID_MSG, "Total Search count of messages is [%d]", totalResultCount);
+
+ for (int index = 0; index < searchCount; index++)
+ {
+ // get SmsMessage instance
+ SmsMessage* pSmsMessage = _MsgUtil::ConvertSmsMessageN(SMS_MESSAGE_BOX_TYPE_INBOX, pMsgList[index]);
+ // add to the list
+ pList->Add(*pSmsMessage);
+ }
+
+ if (pSearchString)
+ {
+ delete[] pSearchString;
+ pSearchString = NULL;
+ }
+
+ if (pSenderAddressTemp)
+ {
+ delete[] pSenderAddressTemp;
+ pSenderAddressTemp = NULL;
+ }
+
+ messages_free_message_array(pMsgList);
+
+ return pList;
+
+CATCH:
+ if (pSearchString)
+ {
+ delete[] pSearchString;
+ pSearchString = NULL;
+ }
+
+ if (pSenderAddressTemp)
+ {
+ delete[] pSenderAddressTemp;
+ pSenderAddressTemp = NULL;
+ }
+
+ if (pList)
+ {
+ if (pList->GetCount() > 0)
+ {
+ pList->RemoveAll(true);
+ }
+ delete pList;
+ pList = null;
+ }
+
+ messages_free_message_array(pMsgList);
+
+ return null;
+}
+
+Tizen::Base::Collection::IList*
+_SmsManagerImpl::SearchMessageBoxN(SmsMessageBoxType type, const Tizen::Base::String* pKeyword, int startIndex, int count,
+ int& totalResultCount) const
+{
+ SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet.");
+ SysAssertf(__msgHandle > 0, "message handle is invalid.");
+
+ result r = E_SUCCESS;
+ int err = MESSAGES_ERROR_NONE;
+ char* pSearchString = NULL;
+ messages_message_box_e folderId = MESSAGES_MBOX_ALL;
+ ArrayList* pList = NULL;
+ messages_message_h* pMsgList = null;
+ int searchCount = 0;
+ int totalCount = 0;
+
+ ClearLastResult();
+
+ pList = new (std::nothrow) ArrayList();
+ SysTryCatch(NID_MSG, pList != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+
+ // make a list
+ r = pList->Construct();
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "Failed to construct an ArrayList");
+
+ // type
+ folderId = _MsgUtil::GetMsgFolderId(type);
+
+ // keyword
+ if (pKeyword)
+ {
+ pSearchString = _StringConverter::CopyToCharArrayN(*pKeyword);
+ }
+
+ // searching
+ err = messages_search_message(__msgHandle, folderId, MESSAGES_TYPE_SMS, pSearchString, null,
+ startIndex, count, &pMsgList, &searchCount, &totalCount);
+
+ r = ConvertException(err);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] msg_search_message call failed.", GetErrorMessage(r));
+
+ totalResultCount = searchCount;
+
+ SysLog(NID_MSG, "Total Search count of messages is [%d]", totalResultCount);
+
+ for (int index = 0; index < searchCount; index++)
+ {
+ SmsMessage* pSmsMessage = null;
+
+ if (type == SMS_MESSAGE_BOX_TYPE_ALL)
+ {
+ messages_get_mbox_type(pMsgList[index], &folderId);
+
+ switch (folderId)
+ {
+ case MESSAGES_MBOX_INBOX:
+ pSmsMessage = _MsgUtil::ConvertSmsMessageN(SMS_MESSAGE_BOX_TYPE_INBOX, pMsgList[index]);
+ break;
+
+ case MESSAGES_MBOX_OUTBOX:
+ pSmsMessage = _MsgUtil::ConvertSmsMessageN(SMS_MESSAGE_BOX_TYPE_OUTBOX, pMsgList[index]);
+ break;
+
+ case MESSAGES_MBOX_SENTBOX:
+ pSmsMessage = _MsgUtil::ConvertSmsMessageN(SMS_MESSAGE_BOX_TYPE_SENTBOX, pMsgList[index]);
+ break;
+
+ case MESSAGES_MBOX_DRAFT :
+ //pSmsMessage = _MsgUtil::ConvertSmsMessageN(SMS_MESSAGE_BOX_TYPE_SENTBOX, pMsgList[index]);
+ break;
+
+ case MESSAGES_MBOX_ALL:
+ //pSmsMessage = _MsgUtil::ConvertSmsMessageN(SMS_MESSAGE_BOX_TYPE_SENTBOX, msgList[index]);
+ break;
+ }
+
+ // add the item to the list
+ pList->Add(*pSmsMessage);
+ }
+ else
+ {
+ pSmsMessage = _MsgUtil::ConvertSmsMessageN(type, pMsgList[index]);
+ pList->Add(*pSmsMessage);
+ }
+ }
+
+ if (pSearchString)
+ {
+ delete[] pSearchString;
+ pSearchString = NULL;
+ }
+
+ messages_free_message_array(pMsgList);
+
+ return pList;
+
+CATCH:
+ if (pList)
+ {
+ if (pList->GetCount() > 0)
+ {
+ pList->RemoveAll(true);
+ }
+ delete pList;
+ pList = null;
+ }
+
+ if (pSearchString)
+ {
+ delete[] pSearchString;
+ pSearchString = NULL;
+ }
+
+ messages_free_message_array(pMsgList);
+
+ return null;
+}
+
+Tizen::Base::String
+_SmsManagerImpl::GetFullText(int messageId) const
+{
+ SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet.");
+ SysAssertf(__msgHandle > 0, "message handle is invalid.");
+
+ result r = E_SUCCESS;
+ String fullText;
+ messages_message_h msg = {0};
+ int err = MESSAGES_ERROR_NONE;
+
+ char* pOriginalText = null;
+ char* pBodyText = null;
+
+ ClearLastResult();
+
+ // get SMS message
+ err = messages_search_message_by_id(__msgHandle, messageId, &msg);
+
+ r = ConvertException(err);
+ SetLastResult(r);
+
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] messages_search_message_by_id call 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<char*>(pOriginalText);
+
+ // convert to SmsMessage type
+ fullText = String(pBodyText);
+
+ SysLog(NID_MSG, "Returned Full Text : [%ls]", fullText.GetPointer());
+
+ free(pOriginalText);
+ pOriginalText = null;
+ pBodyText = null;
+
+ messages_destroy_message(msg);
+
+ return fullText;
+
+CATCH:
+ messages_destroy_message(msg);
+
+ return L"";
+}
+
+result
+_SmsManagerImpl::Send(const SmsMessage& message, const RecipientList& recipientList, bool saveToSentbox)
+{
+ SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet.");
+ SysAssertf(__msgHandle > 0, "message handle is invalid.");
+
+ result r = E_SUCCESS;
+ messages_message_h smsMsg = {0};
+ int err = MESSAGES_ERROR_NONE;
+ bool saveMsgToSentbox = saveToSentbox;
+
+ SysLog(NID_MSG, "sending an sms message");
+
+ err = _MsgUtil::GetSmsMessage(message, recipientList, smsMsg);
+
+ if (err == MESSAGES_ERROR_NONE)
+ {
+ err = messages_send_message(__msgHandle, smsMsg, saveMsgToSentbox,
+ &_SmsMmsCallbackHandler::SentSmsMessageStatusCallback, (void*) (__pSmsEvent.get()));
+ }
+
+ r = ConvertException(err);
+
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to send the SMS message.", GetErrorMessage(r));
+
+ //release message
+ messages_destroy_message(smsMsg);
+ SysLog(NID_MSG, "sending an sms message success");
+ return r;
+
+CATCH:
+ //release message
+ messages_destroy_message(smsMsg);
+ return r;
+}
+
+result
+_SmsManagerImpl::SetCbsMessageEventListener(ICbsMessageEventListener* pListener)
+{
+ SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet.");
+ SysAssertf(__msgHandle > 0, "message handle is invalid.");
+
+ result r = E_SUCCESS;
+ int err = MESSAGES_ERROR_NONE;
+
+ if (!pListener)
+ {
+ if (__pCbsReceiveEvent)
+ {
+ r = __pCbsReceiveEvent->RemoveListener(*__pCbsListener);
+ SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "Failed to reset the cbs message event listener.");
+
+ __pCbsListener = null;
+ }
+ return r;
+ }
+
+ // set listener
+ __pCbsListener = pListener;
+
+ // set event
+ if (!__pCbsReceiveEvent)
+ {
+ __pCbsReceiveEvent = new (std::nothrow) _SmsEvent();
+ SysTryCatch(NID_MSG, __pCbsReceiveEvent != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+
+ r = __pCbsReceiveEvent->Construct(_SMS_EVENT_TYPE_CBS_RECEIVE_RESULT);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Failed to construct an cbs listener instance");
+ }
+
+ // add listener
+ 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");
+
+ return r;
+
+CATCH:
+ if (__pCbsReceiveEvent)
+ {
+ delete __pCbsReceiveEvent;
+ __pCbsReceiveEvent = null;
+ }
+ __pCbsListener = null;
+
+ return r;
+}
+
+result
+_SmsManagerImpl::SetEtwsPrimaryNotificationEventListener(IEtwsPrimaryNotificationEventListener* pListener)
+{
+ SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet.");
+ SysAssertf(__msgHandle > 0, "message handle is invalid.");
+
+ result r = E_SUCCESS;
+ int err = MESSAGES_ERROR_NONE;
+
+ if (!pListener)
+ {
+ if (__pEtwsReceiveEvent)
+ {
+ r = __pEtwsReceiveEvent->RemoveListener(*__pEtwsListener);
+ SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "Failed to reset the etws primary notification event listener.");
+
+ __pEtwsListener = null;
+ }
+ return r;
+ }
+
+ // set listener
+ __pEtwsListener = pListener;
+
+ // set event
+ if (!__pEtwsReceiveEvent)
+ {
+ __pEtwsReceiveEvent = new (std::nothrow) _SmsEvent();
+ SysTryCatch(NID_MSG, __pEtwsReceiveEvent != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+
+ r = __pEtwsReceiveEvent->Construct(_SMS_EVENT_TYPE_ETWS_RECEIVE_RESULT);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM,
+ "Failed to construct an etws primary notification event listener instance");
+ }
+
+ // add listener
+ 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.");
+
+ return r;
+
+CATCH:
+ if (__pEtwsReceiveEvent)
+ {
+ delete __pEtwsReceiveEvent;
+ __pEtwsReceiveEvent = null;
+ }
+ __pEtwsListener = null;
+
+ return r;
+}
+
+result
+_SmsManagerImpl::SetSavingToCbsBoxEnabled(bool enable)
+{
+ SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet.");
+ SysAssertf(__msgHandle > 0, "message handle is invalid.");
+ SysTryReturnResult(NID_MSG, __cbsSettingsHandle != NULL, E_SYSTEM, "Cb handle is null");
+
+ int err = MESSAGES_ERROR_NONE;
+
+ 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.");
+
+ __isCbsSaveEnabled = enable;
+
+ return E_SUCCESS;
+}
+
+bool
+_SmsManagerImpl::IsCbsEnabled(void) const
+{
+ SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet.");
+ SysAssertf(__msgHandle > 0, "message handle is invalid.");
+ SysTryReturn(NID_MSG, __cbsSettingsHandle != NULL, false, E_SYSTEM, "Cb handle is null");
+
+ bool isCbsEnabled = false;
+ int err = MESSAGES_ERROR_NONE;
+
+ err = messages_cb_settings_is_enabled(__cbsSettingsHandle, &isCbsEnabled);
+ SysTryReturn(NID_MSG, err == MESSAGES_ERROR_NONE, false, E_SYSTEM, "Failed to set SavingToCbsBoxEnabled option.");
+
+ return isCbsEnabled;
+}
+
+result
+_SmsManagerImpl::SetCbsEnabled(bool enable)
+{
+ SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet.");
+ SysAssertf(__msgHandle > 0, "message handle is invalid.");
+ SysTryReturnResult(NID_MSG, __cbsSettingsHandle != NULL, E_SYSTEM, "Cb handle is null");
+
+ int err = MESSAGES_ERROR_NONE;
+
+ err = messages_cb_settings_set_enabled(__cbsSettingsHandle, enable);
+ SysTryReturnResult(NID_MSG, err == MESSAGES_ERROR_NONE, 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.");
+
+ return E_SUCCESS;
+}
+
+result
+_SmsManagerImpl::AddCbsChannel(int from, int to, Tizen::Base::String& name, bool activate)
+{
+ SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet.");
+ SysAssertf(__msgHandle > 0, "message handle is invalid.");
+ SysTryReturnResult(NID_MSG, __cbsSettingsHandle != NULL, E_SYSTEM, "Cb handle is null");
+
+ result r = E_SUCCESS;
+ int err = MESSAGES_ERROR_NONE;
+ messages_cb_channel_h cbsChannel = {0};
+ std::unique_ptr<char[]> pChannelName;
+
+ // create a channel
+ err = messages_cb_create_channel(&cbsChannel);
+ SysTryReturnResult(NID_MSG, err == MESSAGES_ERROR_NONE, E_SYSTEM, "Failed to create a channel.");
+
+ // 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.");
+
+ // 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.");
+
+ return r;
+
+CATCH:
+ messages_cb_settings_remove_channel(__cbsSettingsHandle, cbsChannel);
+ messages_cb_save_settings(__msgHandle, __cbsSettingsHandle);
+ messages_cb_destroy_channel(cbsChannel);
+ return r;
+}
+
+result
+_SmsManagerImpl::RemoveCbsChannel(int from, int to)
+{
+ SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet.");
+ SysAssertf(__msgHandle > 0, "message handle is invalid.");
+ SysTryReturnResult(NID_MSG, __cbsSettingsHandle != NULL, E_SYSTEM, "Cb handle is null");
+
+ 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.");
+
+ return r;
+}
+
+CbsChannel*
+_SmsManagerImpl::GetCbsChannelN(int from, int to) const
+{
+ SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet.");
+ SysAssertf(__msgHandle > 0, "message handle is invalid.");
+ SysTryReturn(NID_MSG, __cbsSettingsHandle != null, null, E_SYSTEM, "Cb handle is null.");
+
+ 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<char> pChannelName;
+ messages_cb_channel_h cbsChannel = {0};
+ std::unique_ptr<CbsChannel> 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);
+
+ // get channel
+ pCbsChannel.reset(_CbsChannelImpl::GetCbsChannelN(from, to, String(pChannelName.release())));
+ SysTryReturn(NID_MSG, pCbsChannel != null, null, r, "Failed to get the channel.");
+
+ // set cbs handle
+ _CbsChannelImpl::GetInstance(*pCbsChannel)->SetCbsChannelHandle(cbsChannel);
+
+ return pCbsChannel.release();
+}
+
+Tizen::Base::Collection::IList*
+_SmsManagerImpl::GetCbsChannelListN(void)
+{
+ SysAssertf(__isConstructed == true, "_SmsManagerImpl instance is not constructed yet.");
+ SysAssertf(__msgHandle > 0, "message handle is invalid.");
+ SysTryReturn(NID_MSG, __cbsSettingsHandle != null, null, E_SYSTEM, "Cb handle is null.");
+
+ result r = E_SUCCESS;
+ unique_ptr<ArrayList, AllElementsDeleter> pList;
+ int err = MESSAGES_ERROR_NONE;
+ int cbChannelCount = 0;
+ int fromId = 0;
+ int toId = 0;
+ unique_ptr<char> pChannelName;
+ char* pTempChannelName = null;
+ messages_cb_channel_h cbsChannel = {0};
+ std::unique_ptr<CbsChannel> pCbsChannel;
+
+ ClearLastResult();
+
+ pList.reset(new (std::nothrow) ArrayList(SingleObjectDeleter));
+ SysTryReturn(NID_MSG, pList != null, null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ // make a list
+ 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.");
+
+ 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 ((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);
+ }
+ }
+ }
+ }
+ }
+
+ SysTryReturn(NID_MSG, err == MESSAGES_ERROR_NONE, null, E_SYSTEM, "Failed to GetCbsChannelListN.");
+
+ return pList.release();
+}
+
+_SmsManagerImpl*
+_SmsManagerImpl::GetInstance(SmsManager& smsManager)
+{
+ return smsManager.__pImpl;
+}
+
+const _SmsManagerImpl*
+_SmsManagerImpl::GetInstance(const SmsManager& smsManager)
+{
+ return smsManager.__pImpl;
+}
+
+result
+_SmsManagerImpl::ConvertException(int err) const
+{
+ 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_NO_DATA:
+ r = E_OBJ_NOT_FOUND;
+ 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;
+ }
+
+ return r;
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_SmsManagerImpl.h
+ * @brief This is the header file for the _SmsManagerImpl class.
+ *
+ * This header file contains the declarations of the _SmsManagerImpl class.
+ */
+
+#ifndef _FMSG_INTERNAL_SMS_MANAGER_IMPL_H_
+#define _FMSG_INTERNAL_SMS_MANAGER_IMPL_H_
+
+#include "FMsg_Types.h"
+
+namespace Tizen { namespace Messaging
+{
+
+/**
+* @class _SmsManagerImpl
+* @brief This class provides methods to use the SMS messaging service.
+* @since 1.0
+*
+* This class provides methods to use the SMS messaging service. @n
+*/
+
+// forward declaration
+class _SmsEvent;
+class SmsManager;
+
+class _SmsManagerImpl
+ : public Tizen::Base::Object
+{
+ // Life cycle
+public:
+ /**
+ * This is the default constructor for this class.
+ */
+ _SmsManagerImpl(void);
+
+ /**
+ * This is the destructor for this class.
+ */
+ virtual ~_SmsManagerImpl(void);
+
+private:
+ _SmsManagerImpl(const _SmsManagerImpl& value);
+ _SmsManagerImpl& operator =(const _SmsManagerImpl& rhs);
+
+
+ // Operation
+public:
+ /**
+ * Initializes this instance of _SmsManagerImpl with the specified listener.
+ *
+ * @return An error code
+ * @param[in] listener The listener to receive a send result asynchronously
+ * @exception E_SUCCESS The method was successful.
+ */
+ result Construct(const ISmsListener& listener);
+
+ /**
+ * Adds the event listener for receiving SMS messages.
+ *
+ * @return An error code
+ * @param[in] port A port number
+ * @param[in] eventListener The listener to receive SMS messages
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_OBJ_ALREADY_EXIST The port number was already registered.
+ * @exception E_FAILURE The port number was already used in other applications.
+ * @exception E_INVALID_ARG The value of the specified @c port is invalid. @n
+ * The port number should range from 1 to 9999 (1 <= port <= 9999).
+ * @see ISmsEventListener, RemoveSmsEventListener()
+ */
+ result AddSmsEventListener(int port, ISmsEventListener& eventListener);
+
+ /**
+ * Removes the event listener for receiving SMS messages.
+ *
+ * @return An error code
+ * @param[in] port A port number
+ * @param[in] eventListener The listener to receive SMS messages
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_OBJ_NOT_FOUND The listener was not found.
+ * @exception E_SYSTEM A system error occurred.
+ * @exception E_INVALID_ARG The value of the specified @c port is invalid. @n
+ * The port number should range from 1 to 9999 (1 <= port <= 9999).
+ * @see ISmsEventListener, AddSmsEventListener()
+ */
+ result RemoveSmsEventListener(int port, ISmsEventListener& eventListener);
+
+ /**
+ * Adds the event listener for receiving SMS messages.
+ *
+ * @return An error code
+ * @param[in] eventListener The listener to receive SMS messages
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_OUT_OF_MEMORY Insufficient memory.
+ * @see ISmsMessageEventListener, RemoveSmsMessageEventListener()
+ */
+ result AddSmsMessageEventListener(const ISmsMessageEventListener& eventListener);
+
+ /**
+ * Removes the event listener for receiving SMS messages.
+ *
+ * @return An error code
+ * @param[in] eventListener The listener to receive SMS messages
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_OBJ_NOT_FOUND The listener was not found.
+ * @exception E_SYSTEM A system error occurred.
+ * @see ISmsMessageEventListener, AddSmsMessageEventListener()
+ */
+ result RemoveSmsMessageEventListener(const ISmsMessageEventListener& eventListener);
+
+ /**
+ * Sends the SMS message.
+ *
+ * @return An error code
+ * @param[in] message The message to be sent
+ * @param[in] recipientList The list of recipients
+ * @param[in] saveToSentBox Set to @c true to save the message in the Sentbox, @n
+ * else @c false
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_ON_INITIALIZING The mailbox is not completely loaded yet.
+ * @exception E_STORAGE_FULL The storage is full.
+ * @exception E_DEVICE_UNAVAILABLE The device is unavailable.
+ * @exception E_NETWORK_UNAVAILABLE The network is unavailable.
+ * @exception E_INVALID_ADDRESS The address is invalid.
+ * @exception E_FDN_MODE The FDN mode has been activated.
+ * @exception E_INVALID_ARG The number of recipients is @c 0.
+ * @exception E_MAX_EXCEEDED The number of recipients crossed the limit (Maximum 10).
+ * @see ISmsListener::OnSmsMessageSent()
+ */
+ result Send(const SmsMessage& message, const RecipientList& recipientList, bool saveToSentBox);
+
+ /**
+ * Gets the total number of SMS messages in the specified message box.
+ *
+ * @return The total number of SMS messages in the specified message box
+ * @param[in] type The type of message box
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_ARG The value of specified @c type is invalid.
+ * @exception E_SYSTEM A system error occurred.
+ * @remarks In case of an error, this method returns the negative value (-1).
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ int GetTotalMessageCount(SmsMessageBoxType type) const;
+
+ /**
+ * Searches the SMS messages by keyword and|or sender address in the Inbox.
+ *
+ * @return The list of the SmsMessage class instances
+ * @param[in] pKeyword A part of the body text as a keyword (partial match) @n
+ * In case of @c null or an empty string, this method searches all SMS messages in the Inbox regardless of the keyword.
+ * @param[in] pSenderAddress A telephone number as a sender address (exact match) @n
+ * In case of @c null or an empty string, this method searches all SMS messages in the Inbox regardless of the sender address.
+ * @param[in] startIndex The start index (base 0)
+ * @param[in] count The count of SMS messages to search
+ * @param[out] totalResultCount The total count of the searched result
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_ARG Either of the following of the 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 o. @n
+ * -- The specified @c count value is less than @c 0 or greater than @c 20.
+ * @exception E_SYSTEM A system error occurred.
+ * @remarks The specific error code can be accessed using the GetLastResult() method. @n
+ * @remarks The search with the specified keywords searches using only the first 50 characters of the body text.
+ * @remarks The SMS messages in the searched result contain only 160 bytes for the body text. @n
+ * To check whether there is additional text, use the SmsMessage::HasMoreText() method. @n
+ * To get the full body text, use GetFullText() with its message ID.
+ * @see SmsMessage, GetFullText()
+ */
+ Tizen::Base::Collection::IList* SearchInboxN(const Tizen::Base::String* pKeyword, const Tizen::Base::String* pSenderAddress, int startIndex, int count, int& totalResultCount) const;
+
+ /**
+ * Searches the SMS messages by keyword in the specified message box.
+ *
+ * @return The list of the SmsMessage class instances
+ * @param[in] type The type of message box
+ * @param[in] pKeyword A part of the body text as a keyword (partial match) @n
+ * In case of @c null or an empty string, this method searches all SMS messages in the specified message box.
+ * @param[in] startIndex The start index (base 0)
+ * @param[in] count The count of SMS messages to search
+ * @param[out] totalResultCount The total count of the searched result
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
+ * -- The value of specified @c type is invalid. @n
+ * -- The specified @c pKeyword string length is less than @c 2 or greater than @c 30. @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_SYSTEM A system error occurred.
+ * @remarks The specific error code can be accessed using the GetLastResult() method. @n
+ * @remarks The search with the specified keywords searches using only the first 50 characters of the body text.
+ * @remarks The SMS messages in the searched result contain only 160 bytes for the body text. @n
+ * To check whether there is additional text, use the SmsMessage::HasMoreText() method. @n
+ * To get the full body text, use the GetFullText() method with its message ID.
+ * @see SmsMessage, GetFullText()
+ */
+ Tizen::Base::Collection::IList* SearchMessageBoxN(SmsMessageBoxType type, const Tizen::Base::String* pKeyword, int startIndex, int count, int& totalResultCount) const;
+
+ /**
+ * Gets the full text of the SMS message in the message box using the message ID.
+ *
+ * @return The full text of the specified SMS message
+ * @param[in] messageId The unique ID of the message
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_ARG The value of the specified @c messageId is invalid, or @c messageId should be greater than or equal to @c 0.
+ * @exception E_OBJ_NOT_FOUND The SMS message with the specified @c messageId was not found.
+ * @exception E_SYSTEM A system error occurred.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @remarks In case of an error, this method returns an empty string.
+ * @see SmsMessage::HasMoreText()
+ */
+ Tizen::Base::String GetFullText(int messageId) const;
+
+ /**
+ * Sets the event listener for receiving CB messages.
+ *
+ * @return An error code
+ * @param[in] pListener The listener to receive CB messages
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM A system error has occurred.
+ * @see ICbsMessageEventListener
+ */
+ result SetCbsMessageEventListener(ICbsMessageEventListener* pListener);
+
+ /**
+ * Sets the event listener for receiving ETWS primary notification.
+ *
+ * @return An error code
+ * @param[in] pListener The listener to receive ETWS primary notification
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM A system error has occurred.
+ * @see IEtwsPrimaryNotificationEventListener
+ */
+ result SetEtwsPrimaryNotificationEventListener(IEtwsPrimaryNotificationEventListener* pListener);
+
+ /**
+ * Enables or disables the save option for CBS message to the CbsBox
+ *
+ * @return An error code
+ * @param[in] enable Set to @c true to save the message in the CbsBox, @n
+ * else @c false
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ result SetSavingToCbsBoxEnabled(bool enable);
+
+ /**
+ * Checks whether the CB service is enabled.
+ *
+ * @return @c true if the CB service is enabled, @n
+ * else @c false
+ * @see SetCbsEnabled()
+ */
+ bool IsCbsEnabled(void) const;
+
+ /**
+ * Enables or disables the CB service.
+ *
+ * @return An error code
+ * @param[in] enable Set to @c true to enable the CB service, @n
+ * else @c false
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM A system error has occurred.
+ * @see IsCbsEnabled()
+ */
+ result SetCbsEnabled(bool enable);
+
+ /**
+ * Adds a CBS channel with specified parameters.
+ *
+ * @return An error code
+ * @param[in] from The starting index of the message ID of the channel.
+ * @param[in] to The last index of the message ID of the channel.
+ * @param[in] name The name of the channel. (can be an empty string)
+ * @param[in] activate Set to @c true to activate the channel, @n
+ * else @c false.
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c to parameter is smaller than @c from. @n
+ * The specified @c to or @c from parameter is a negative value. @n
+ * The specified @c to parameter exceeds the limit (0xFFFF). @n
+ * The range (@c to - @c from) exceeds the limit (900).
+ * 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.
+ * @see RemoveCbsChannel()
+ */
+ result AddCbsChannel(int from, int to, Tizen::Base::String& name, bool activate = true);
+
+ /**
+ * Removes a CBS channel.
+ *
+ * @return An error code
+ * @param[in] from The starting index of the message ID of the channel.
+ * @param[in] to The last index of the message ID of the channel.
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c to parameter is smaller than @c from. @n
+ * The specified @c to or @c from parameter is a negative value. @n
+ * The specified @c to parameter exceeds the limit (0xFFFF). @n
+ * The range (@c to - @c from) exceeds the limit (900).
+ * @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.
+ * @see AddCbsChannel()
+ */
+ result RemoveCbsChannel(int from, int to);
+
+ /**
+ * Gets a CBS channel with specified range.
+ *
+ * @return A pointer to the CBS channel with specific range.
+ * @param[in] from The starting index of the message ID of the channel.
+ * @param[in] to The last index of the message ID of the channel.
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c to parameter is smaller than @c from. @n
+ * The specified @c to or @c from parameter is a negative value. @n
+ * The specified @c to parameter exceeds the limit (0xFFFF). @n
+ * The range (@c to - @c from) exceeds the limit (900).
+ * @exception E_SYSTEM A system error has occurred.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @see AddCbsChannel(), RemoveCbsChannel()
+ */
+ CbsChannel* GetCbsChannelN(int from, int to) const;
+
+ /**
+ * Gets the CBS channel list.
+ *
+ * @return A pointer to the list of CBS channel
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM A system error has occurred.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @see AddCbsChannel(), RemoveCbsChannel(), CbsChannel
+ */
+ Tizen::Base::Collection::IList* GetCbsChannelListN(void);
+
+public:
+ /**
+ * Gets the Impl instance.
+ *
+ * @return The pointer to _SmsManagerImpl
+ * @param[in] smsManager An instance of SmsManager
+ */
+ static _SmsManagerImpl* GetInstance(SmsManager& smsManager);
+
+ /**
+ * Gets the Impl instance.
+ *
+ * @return The pointer to _SmsManagerImpl
+ * @param[in] smsManager An instance of SmsManager
+ */
+ static const _SmsManagerImpl* GetInstance(const SmsManager& smsManager);
+
+ // utility
+private:
+ result ConvertException(int err) const;
+
+private:
+ bool __isConstructed;
+ bool __isCbsSaveEnabled;
+ std::unique_ptr<_SmsEvent> __pSmsEvent;
+ _SmsEvent* __pSmsReceiveEvent;
+ _SmsEvent* __pCbsReceiveEvent;
+ _SmsEvent* __pEtwsReceiveEvent;
+ Tizen::Base::Collection::ArrayList* __pSmsTriggerEventList;
+ messages_service_h __msgHandle;
+ messages_cb_settings_h __cbsSettingsHandle;
+ ICbsMessageEventListener* __pCbsListener;
+ IEtwsPrimaryNotificationEventListener* __pEtwsListener;
+}; // _SmsManagerImpl
+} } // Tizen::Messaging
+
+#endif // _FMSG_INTERNAL_SMS_MANAGER_IMPL_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_SmsMessageImpl.cpp
+ * @brief This is the implementation file for the %_SmsMessageImpl class.
+ *
+ * This file contains the implementation of the %_SmsMessageImpl class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FMsgSmsMessage.h>
+#include "FMsg_SmsMessageImpl.h"
+#include "FMsg_Types.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Messaging;
+
+namespace Tizen { namespace Messaging
+{
+
+_SmsMessageImpl::_SmsMessageImpl(void)
+ : __messageId(-1)
+ , __messageBoxType(SMS_MESSAGE_BOX_TYPE_NONE)
+ , __hasMoreText(false)
+{
+}
+
+_SmsMessageImpl::_SmsMessageImpl(const _SmsMessageImpl& value)
+{
+ __messageBoxType = value.__messageBoxType;
+ __messageId = value.__messageId;
+ __text = value.__text;
+ __hasMoreText = value.__hasMoreText;
+ __senderAddress = value.__senderAddress;
+ __recipientList = value.__recipientList;
+ __time = value.__time;
+}
+
+_SmsMessageImpl::~_SmsMessageImpl(void)
+{
+ __messageId = -1;
+ __messageBoxType = SMS_MESSAGE_BOX_TYPE_NONE;
+ __hasMoreText = false;
+}
+
+_SmsMessageImpl&
+_SmsMessageImpl::operator =(const _SmsMessageImpl& rhs)
+{
+ if (this != &rhs)
+ {
+ __messageBoxType = rhs.__messageBoxType;
+ __messageId = rhs.__messageId;
+ __text = rhs.__text;
+ __hasMoreText = rhs.__hasMoreText;
+ __senderAddress = rhs.__senderAddress;
+ __recipientList = rhs.__recipientList;
+ __time = rhs.__time;
+ }
+
+ return (*this);
+}
+
+bool
+_SmsMessageImpl::Equals(const Tizen::Base::Object& value) const
+{
+ const _SmsMessageImpl* pSmsMessageImpl = dynamic_cast<const _SmsMessageImpl*>(&value);
+ if (!pSmsMessageImpl)
+ {
+ SysLog(NID_MSG, "dynamic_cast is failed");
+ return false;
+ }
+
+ // text
+ if (__text != pSmsMessageImpl->__text)
+ {
+ return false;
+ }
+
+ // message ID
+ if (__messageId != pSmsMessageImpl->__messageId)
+ {
+ return false;
+ }
+
+ // messageBoxType
+ if (__messageBoxType != pSmsMessageImpl->__messageBoxType)
+ {
+ return false;
+ }
+
+ // time
+ if (__time != pSmsMessageImpl->__time)
+ {
+ return false;
+ }
+
+ // senderAddress
+ if (__senderAddress != pSmsMessageImpl->__senderAddress)
+ {
+ return false;
+ }
+
+ // RecipientList
+ if (!(__recipientList == pSmsMessageImpl->__recipientList))
+ {
+ return false;
+ }
+
+ // __hasMoreText
+ if (__hasMoreText != pSmsMessageImpl->__hasMoreText)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+int
+_SmsMessageImpl::GetHashCode(void) const
+{
+ int hash = 0;
+
+ hash = __text.GetHashCode() + __messageId + (int)__messageBoxType + __time.GetHashCode() + __senderAddress.GetHashCode() + __recipientList.GetHashCode() + (__hasMoreText ? 1 : 0);
+
+ return hash;
+}
+
+result
+_SmsMessageImpl::SetText(const Tizen::Base::String& text)
+{
+ __text = text;
+
+ return E_SUCCESS;
+}
+
+String
+_SmsMessageImpl::GetText(void) const
+{
+ return __text;
+}
+
+String
+_SmsMessageImpl::GetSenderAddress(void) const
+{
+ return __senderAddress;
+}
+
+DateTime
+_SmsMessageImpl::GetReceivedTime(void) const
+{
+ return __time;
+}
+
+Tizen::Base::DateTime
+_SmsMessageImpl::GetSentTime(void) const
+{
+ return __time;
+}
+
+int
+_SmsMessageImpl::GetId(void) const
+{
+ return __messageId;
+}
+
+SmsMessageBoxType
+_SmsMessageImpl::GetMessageBoxType(void) const
+{
+ return __messageBoxType;
+}
+
+RecipientList
+_SmsMessageImpl::GetRecipientList(void) const
+{
+ return __recipientList;
+}
+
+bool
+_SmsMessageImpl::HasMoreText(void) const
+{
+ return __hasMoreText;
+}
+
+_SmsMessageImpl*
+_SmsMessageImpl::GetInstance(SmsMessage& smsMessage)
+{
+ return smsMessage.__pImpl;
+}
+
+const _SmsMessageImpl*
+_SmsMessageImpl::GetInstance(const SmsMessage& smsMessage)
+{
+ return smsMessage.__pImpl;
+}
+
+// private - used only for the incoming message
+void
+_SmsMessageImpl::SetIncomingMessage(const Tizen::Base::String& text, const Tizen::Base::String& senderAddress,
+ const Tizen::Base::DateTime& receivedTime)
+{
+ __messageBoxType = SMS_MESSAGE_BOX_TYPE_NONE;
+ __messageId = -1; // message ID should not be available
+ __text = text;
+ __hasMoreText = false;
+ __senderAddress = senderAddress;
+// __recipientList.GetImpl()->ClearAllRecipients(); // recipient list should be empty
+ __time = receivedTime;
+}
+
+// private - used only for the messages in the inbox
+void
+_SmsMessageImpl::SetInboxMessage(int messageId, const Tizen::Base::String& text, bool hasMoreText,
+ const Tizen::Base::String& senderAddress,
+ const Tizen::Base::DateTime& receivedTime)
+{
+ __messageBoxType = SMS_MESSAGE_BOX_TYPE_INBOX;
+ __messageId = messageId;
+ __text = text;
+ __hasMoreText = hasMoreText;
+ __senderAddress = senderAddress;
+// __recipientList.GetImpl()->ClearAllRecipients(); // recipient list should be empty
+ __time = receivedTime;
+}
+
+// private - used for the messages in the sentbox
+void
+_SmsMessageImpl::SetSentboxMessage(int messageId, const Tizen::Base::String& text, bool hasMoreText,
+ const Tizen::Messaging::RecipientList& recipientList,
+ const Tizen::Base::DateTime& sentTime)
+{
+ __messageBoxType = SMS_MESSAGE_BOX_TYPE_SENTBOX;
+ __messageId = messageId;
+ __text = text;
+ __hasMoreText = hasMoreText;
+ __recipientList = recipientList;
+ __senderAddress.Clear(); // sender address should be empty
+ __time = sentTime;
+}
+
+// private - used for the messages in the outbox
+void
+_SmsMessageImpl::SetOutboxMessage(int messageId, const Tizen::Base::String& text, bool hasMoreText,
+ const Tizen::Messaging::RecipientList& recipientList,
+ const Tizen::Base::DateTime& sentTime)
+{
+ __messageBoxType = SMS_MESSAGE_BOX_TYPE_OUTBOX;
+ __messageId = messageId;
+ __text = text;
+ __hasMoreText = hasMoreText;
+ __recipientList = recipientList;
+ __senderAddress.Clear(); // sender address should be empty
+ __time = sentTime;
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_SmsMessageImpl.h
+ * @brief This is the header file for _SmsMessageImpl class.
+ *
+ * This header file contains the declarations of _SmsMessageImpl class.
+ */
+
+
+#ifndef _FMSG_INTERNAL_SMS_MESSAGE_IMPL_H_
+#define _FMSG_INTERNAL_SMS_MESSAGE_IMPL_H_
+
+// Includes
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseDateTime.h>
+#include <FMsgTypes.h>
+#include <FMsgRecipientList.h>
+#include "FMsg_Types.h"
+
+namespace Tizen { namespace Messaging
+{
+
+// forward declaration
+class RecipientList;
+class SmsMessage;
+
+/**
+* @class _SmsMessageImpl
+* @brief This class provides methods for handling an SMS message.
+* @since 1.0
+*
+* This class provides methods for handling SMS messages. @n
+* A user can set and get an SMS body text.
+*/
+class _SmsMessageImpl
+ : public Tizen::Base::Object
+{
+ // Life cycle
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 1.0
+ */
+ _SmsMessageImpl(void);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 1.0
+ */
+ virtual ~_SmsMessageImpl(void);
+
+ /**
+ * This is the copy constructor for this class.
+ *
+ * @since 1.0
+ * @param[in] value An instance of _SmsMessageImpl
+ */
+ _SmsMessageImpl(const _SmsMessageImpl& value);
+
+public:
+ /**
+ * This assignment operator copies SMS message from the specified instance of _SmsMessageImpl to the calling instance of SmsMessage.
+ *
+ * @since 1.0
+ * @return A reference to this instance
+ * @param[in] rhs A reference to the SmsMessage instance to be copied
+ */
+ _SmsMessageImpl& operator =(const _SmsMessageImpl& rhs);
+
+public:
+ /**
+ * Gets the hash value of the current instance.
+ *
+ * @since 1.0
+ * @return The hash value of the current instance
+ * @remarks Two equal instances should return the same hash value. For better performance,
+ * the used hash function must generate a random distribution for all inputs.
+ */
+ virtual int GetHashCode(void) const;
+
+ /**
+ * Compares the specified instance with the calling instance.
+ *
+ * @since 1.0
+ * @return @c true if both instances are equal @n
+ * @c false, otherwise
+ * @param[in] value An instance of _SmsMessageImpl
+ */
+ virtual bool Equals(const Tizen::Base::Object& value) const;
+
+ // Operation
+public:
+ /**
+ * Sets the body of the message.
+ *
+ * @since 1.0
+ * @return An error code
+ * @param[in] text The body text of the message
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_MAX_EXCEEDED The body length of the message is exceeding the maximum limit (Maximum 80 characters).
+ * @see GetText()
+ */
+ result SetText(const Tizen::Base::String& text);
+
+ /**
+ * Gets the body text of the message.
+ *
+ * @since 1.0
+ * @return The body text of the message
+ * @remarks If the message is from the Inbox, Sentbox, or Outbox, it may contain only 160 bytes for the body text. @n
+ * To check whether the message contains more than 160 bytes for the body text, use the HasMoreText() method.
+ * To get the full body text, use the SmsManager::GetFullText() method with its message ID.
+ * @see SetText(), HasMoreText(), GetId(), SmsManager::GetFullText()
+ */
+ Tizen::Base::String GetText(void) const;
+
+ /**
+ * Gets the sender address of the message.
+ *
+ * @since 2.0
+ * @privlevel SYSTEM
+ * @privgroup http://tizen.org/privilege/messaging.sms
+ *
+ * @return The sender address of the message
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_OPERATION This operation is only allowed to the incoming message or the message from the Inbox.
+ * @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.
+ */
+ Tizen::Base::String GetSenderAddress(void) const;
+
+ /**
+ * Gets the received time of the message.
+ *
+ * @since 2.0
+ * @privlevel SYSTEM
+ * @privgroup http://tizen.org/privilege/messaging.sms
+ *
+ * @return The received time of the message
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_OPERATION This operation is only allowed to the incoming message or the message from the Inbox.
+ * @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.
+ * @remarks In case of an error, this method returns the instance denoting 00:00:00, January 1, 1.
+ */
+ Tizen::Base::DateTime GetReceivedTime(void) const;
+
+ /**
+ * Gets the unique ID of the message.
+ *
+ * @since 2.0
+ * @privlevel SYSTEM
+ * @privgroup http://tizen.org/privilege/messaging.sms
+ *
+ * @return The unique ID of the message
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_OPERATION This operation is allowed only when the message is from the Inbox, Sentbox, or Outbox.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @remarks In case of an error, this method returns the negative value (-1).
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ int GetId(void) const;
+
+ /**
+ * Gets the sent time of the message.
+ *
+ * @since 2.0
+ * @privlevel SYSTEM
+ * @privgroup http://tizen.org/privilege/messaging.sms
+ *
+ * @return The sent time of the message
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_OPERATION This operation is allowed only when the message is from the Sentbox or Outbox.
+ * @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.
+ * @remarks In case of an error, this method returns the instance denoting 00:00:00, January 1, 1.
+ */
+ Tizen::Base::DateTime GetSentTime(void) const;
+
+ /**
+ * Gets the type of the message box.
+ *
+ * @since 2.0
+ * @privlevel SYSTEM
+ * @privgroup http://tizen.org/privilege/messaging.sms
+ *
+ * @return The type of the message box
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_OPERATION This operation is allowed only when the message is from the Inbox, Sentbox, or Outbox.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @remarks In case of an error, this method returns the SMS_MESSAGE_BOX_TYPE_NONE value.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ SmsMessageBoxType GetMessageBoxType(void) const;
+
+ /**
+ * Gets the list of the recipients.
+ *
+ * @since 2.0
+ * @privlevel SYSTEM
+ * @privgroup http://tizen.org/privilege/messaging.sms
+ *
+ * @return The list of the recipient
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_OPERATION This operation is allowed only when the message is from the Sentbox or Outbox.
+ * @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.
+ */
+ RecipientList GetRecipientList(void) const;
+
+ /**
+ * Checks whether the message contains more than 160 bytes for the body text.
+ *
+ * @since 2.0
+ *
+ * @privlevel SYSTEM
+ * @privgroup http://tizen.org/privilege/messaging.sms
+ *
+ * @return @c true if this message contains more than 160 bytes for the body text, @n
+ * else @c false
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_OPERATION This operation is allowed only when the message is from the Inbox, Sentbox, or Outbox.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @remarks If the return value is @c true, the SMS message contains more than 160 bytes for the body text. To get the full body text, use SmsManager::GetFullText().
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ bool HasMoreText(void) const;
+
+// private:
+ // private - used only for the incoming message
+ void SetIncomingMessage(const Tizen::Base::String& text, const Tizen::Base::String& senderAddress, const Tizen::Base::DateTime& receivedTime);
+
+ // private - used only for the messages in the inbox
+ void SetInboxMessage(int messageId, const Tizen::Base::String& text, bool hasMoreText, const Tizen::Base::String& senderAddress, const Tizen::Base::DateTime& receivedTime);
+
+ // private - used for the messages in the sentbox or outbox
+ void SetSentboxMessage(int messageId, const Tizen::Base::String& text, bool hasMoreText, const Tizen::Messaging::RecipientList& recipientList, const Tizen::Base::DateTime& sentTime);
+
+ // private - used for the messages in the sentbox or outbox
+ void SetOutboxMessage(int messageId, const Tizen::Base::String& text, bool hasMoreText, const Tizen::Messaging::RecipientList& recipientList, const Tizen::Base::DateTime& sentTime);
+
+public:
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _SmsMessageImpl
+ * @param[in] smsMessage An instance of SmsMessage
+ */
+ static _SmsMessageImpl* GetInstance(SmsMessage& smsMessage);
+
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _SmsMessageImpl
+ * @param[in] smsMessage An instance of SmsMessage
+ */
+ static const _SmsMessageImpl* GetInstance(const SmsMessage& smsMessage);
+
+
+private:
+ Tizen::Base::String __text;
+ int __messageId;
+ SmsMessageBoxType __messageBoxType;
+ Tizen::Base::DateTime __time; // received or sent time
+ Tizen::Base::String __senderAddress; // for receiving a message and retrieving an inbox
+ RecipientList __recipientList; // for retrieving sentbox and outbox
+ bool __hasMoreText; // for checking the SMS message has more text or not. (currently the size retrieved SMS message limited to 160 bytes)
+
+ friend class SmsMessage;
+}; // _SmsMessageImpl
+} }
+
+#endif // _FMSG_INTERNAL_SMS_MESSAGE_IMPL_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_SmsMmsCallbackHandler.cpp
+ * @brief This is the implementation file for the %_SmsMmsCallbackHandler class.
+ *
+ * This file contains the implementation of the %_SmsMmsCallbackHandler class.
+ */
+
+#include <messages.h>
+#include <email.h>
+#include <FBaseInteger.h>
+#include <FBaseSysLog.h>
+#include <FMsgEtwsPrimaryNotification.h>
+#include "FMsg_SmsEvent.h"
+#include "FMsg_SmsEventArg.h"
+#include "FMsg_MmsEvent.h"
+#include "FMsg_MmsEventArg.h"
+#include "FMsg_MsgUtil.h"
+#include "FMsg_SmsMmsCallbackHandler.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Messaging
+{
+
+_SmsMmsCallbackHandler* _SmsMmsCallbackHandler::__pMessageCallbackHandler = 0;
+
+_SmsMmsCallbackHandler::_SmsMmsCallbackHandler(void)
+ : __msgHandle(0)
+ , __cbsSettingsHandle(0)
+{
+
+}
+
+_SmsMmsCallbackHandler::~_SmsMmsCallbackHandler(void)
+{
+ if (__msgHandle)
+ {
+ messages_close_service(__msgHandle);
+ __msgHandle = 0;
+ }
+
+}
+
+_SmsMmsCallbackHandler*
+_SmsMmsCallbackHandler::GetInstance(void)
+{
+ if (!__pMessageCallbackHandler)
+ {
+ __pMessageCallbackHandler = new (std::nothrow) _SmsMmsCallbackHandler();
+ }
+
+ return __pMessageCallbackHandler;
+}
+
+int
+_SmsMmsCallbackHandler::OpenMessageHandle(messages_service_h& messageHandle)
+{
+ int err = MESSAGES_ERROR_NONE;
+
+ if (!__msgHandle)
+ {
+ err = messages_open_service(&__msgHandle);
+ }
+
+ messageHandle = __msgHandle;
+ return err;
+}
+
+int
+_SmsMmsCallbackHandler::OpenCbsSettingsHandle(messages_cb_settings_h& cbsSettingsHandle)
+{
+ int err = MESSAGES_ERROR_NONE;
+
+ if (!__cbsSettingsHandle)
+ {
+ err = messages_cb_load_settings(__msgHandle, &__cbsSettingsHandle);
+ }
+
+ cbsSettingsHandle = __cbsSettingsHandle;
+ return err;
+}
+
+int
+_SmsMmsCallbackHandler::CloseMessageHandle()
+{
+ int err = MESSAGES_ERROR_NONE;
+
+ if (__msgHandle)
+ {
+ err = messages_close_service(__msgHandle);
+ __msgHandle = 0;
+ }
+
+ return err;
+}
+
+void
+_SmsMmsCallbackHandler::SentSmsMessageStatusCallback(messages_sending_result_e status, void* pUserEvent)
+{
+ result r = E_SUCCESS;
+ _SmsEvent* pSmsEvent = static_cast <_SmsEvent*>(pUserEvent);
+ _SmsEventArg* pSmsEventArg = null;
+
+ SysLog(NID_MSG, "SMS message sent status[%d]", status);
+
+ switch (status)
+ {
+ case MESSAGES_SENDING_SUCCEEDED: // Message is sent successfully
+ SysLog(NID_MSG, "MESSAGES_SENDING_SUCCEEDED -> E_SUCCESS");
+ r = E_SUCCESS;
+ break;
+
+ 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;
+
+ default:
+ SysLog(NID_MSG, "default -> E_FAILURE");
+ r = E_FAILURE;
+ SysLog(NID_MSG, "Failed to send the SMS message. error cause: Unknown");
+ break;
+ }
+
+ if (pSmsEvent)
+ {
+ pSmsEventArg = new (std::nothrow) _SmsEventArg(r);
+ if (pSmsEventArg)
+ {
+ pSmsEvent->Fire(*pSmsEventArg);
+ }
+ }
+}
+
+void
+_SmsMmsCallbackHandler::SentMmsMessageStatusCallback(messages_sending_result_e status, void* pUserEvent)
+{
+ result r = E_SUCCESS;
+ _MmsEvent* pMmsEvent = static_cast <_MmsEvent*>(pUserEvent);
+ _MmsEventArg* pMmsEventArg = null;
+
+ SysLog(NID_MSG, "MMS message sent status[%d]", status);
+
+ switch (status)
+ {
+ case MESSAGES_SENDING_SUCCEEDED: // Message is sent successfully
+ SysLog(NID_MSG, "MESSAGES_SENDING_SUCCEEDED -> E_SUCCESS");
+ r = E_SUCCESS;
+ break;
+
+ case MESSAGES_SENDING_FAILED: // Message is not sending
+ SysLog(NID_MSG, "MESSAGES_SENDING_SUCCEEDED -> E_FAILURE");
+ r = E_FAILURE;
+ break;
+
+ default:
+ SysLog(NID_MSG, "default -> E_FAILURE");
+ r = E_FAILURE;
+ break;
+ }
+
+ if (pMmsEvent)
+ {
+ pMmsEventArg = new (std::nothrow) _MmsEventArg(r);
+ if (pMmsEventArg)
+ {
+ pMmsEvent->Fire(*pMmsEventArg);
+ }
+ }
+}
+
+void
+_SmsMmsCallbackHandler::IncomingSmsMessageCallback(messages_message_h incomingMsg, void* pUserParam)
+{
+ _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;
+
+ 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);
+
+ String message(pMsgBody); // porting char* to String
+ String senderAddress(pMsgAddress);
+
+ receivedTime = _MsgUtil::ConvertTime(&tempReceivedTime);
+
+ 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));
+
+ free(pMsgBody);
+ pMsgBody = null;
+ free(pMsgAddress);
+ pMsgAddress = null;
+
+ 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);
+ SysTryReturnVoidResult(NID_MSG, pSmsEventArg != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+ }
+
+ pSmsEvent->Fire(*pSmsEventArg);
+ }
+}
+
+void
+_SmsMmsCallbackHandler::IncomingCbsMessageCallback(messages_cb_message_h incomingMsg, void* pUserParam)
+{
+ _SmsEvent* pSmsEvent = static_cast <_SmsEvent*>(pUserParam);
+ _SmsEventArg* pSmsEventArg = null;
+ char* pMsgBody = null;
+ time_t tempReceivedTime = 0;
+ DateTime receivedTime;
+ bool etwsNotifiation = false;
+ int messgeId = 0;
+ int serialNumber = 0;
+ int length = 0;
+ int dataCodingScheme = 0;
+ messages_message_type_e cbsType;
+ 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);
+
+ 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
+
+ receivedTime = _MsgUtil::ConvertTime(&tempReceivedTime);
+
+ Tizen::Base::Integer dataCodingSchemeTemp(dataCodingScheme);
+
+ if (cbsType == MESSAGES_TYPE_SMS_ETWS_PRIMARY || cbsType == MESSAGES_TYPE_SMS_ETWS_SECONDARY)
+ {
+ etwsNotifiation = true;
+ }
+
+ if (pMsgBody)
+ {
+ free(pMsgBody);
+ pMsgBody = null;
+ }
+ 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)
+{
+ _SmsEvent* pSmsEvent = static_cast <_SmsEvent*>(pUserParam);
+ _SmsEventArg* pSmsEventArg = null;
+ String msgHeader(pHeader);
+ Tizen::Base::ByteBuffer msgBody;
+ msgBody.Construct(bodyLength);
+ msgBody.SetArray((byte*) pBody, 0, bodyLength);
+ msgBody.SetPosition(0);
+
+ SysLog(NID_MSG, "push msg body: [%s]", pBody);
+ SysLog(NID_MSG, "push msg header: [%s]", pHeader);
+ SysLog(NID_MSG, "push body length: [%d]", bodyLength);
+
+ if (pSmsEvent)
+ {
+ pSmsEventArg = new (std::nothrow) _SmsEventArg(msgHeader, msgBody, _SMS_EVENT_TYPE_WAP_PUSH_RECEIVE_RESULT);
+ SysTryReturnVoidResult(NID_MSG, pSmsEventArg != null, E_OUT_OF_MEMORY, "memory allocation failed.");
+ pSmsEvent->Fire(*pSmsEventArg);
+ }
+}
+
+void
+_SmsMmsCallbackHandler::IncomingEtwsMessageCallback(messages_cb_message_h incomingMsg, int etwsWarningType, const char* pEtwsSecurityInfo, void* pUserParam)
+{
+ _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;
+
+ messages_cb_get_time(incomingMsg, &tempReceivedTime);
+ messages_cb_get_message_id(incomingMsg, &messgeId);
+ messages_cb_get_serial_number(incomingMsg, &serialNumber);
+
+ Tizen::Base::Integer serialno(serialNumber);
+ length = serialno.ToString().GetLength();
+
+ msgSerialNumber.Construct(length);
+ msgSerialNumber.SetInt(0, serialNumber);
+ msgSerialNumber.SetPosition(0);
+
+ String etwsSecurityInfo(pEtwsSecurityInfo);
+ length = etwsSecurityInfo.GetLength();
+ msgSecurityInfo.Construct(length);
+ msgSecurityInfo.SetArray((byte*) pEtwsSecurityInfo, 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);
+
+ SysLog(NID_MSG, "cbs msg_id: [%d]", messgeId);
+ SysLog(NID_MSG, "cbs received time: [%s]", ctime(&tempReceivedTime));
+ SysLog(NID_MSG, "cbs etwsWarningType: [%d]", etwsWarningType);
+
+ 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);
+ }
+}
+
+} } // Tizen::Messaging
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_SmsMmsCallbackHandler.h
+ * @brief This is the header file for _SmsMmsCallbackHandler class.
+ *
+ * This header file contains declaration of _SmsMmsCallbackHandler class
+ */
+
+#ifndef _FMSG_INTERNAL_SMS_MMS_CALLBACK_HANDLER_H_
+#define _FMSG_INTERNAL_SMS_MMS_CALLBACK_HANDLER_H_
+
+// includes
+#include <FBaseObject.h>
+#include <FBaseColMultiHashMap.h>
+#include "FMsg_Types.h"
+
+namespace Tizen { namespace Messaging
+{
+
+/**
+* @class _SmsMmsCallbackHandler
+* @brief This class provides methods to use the SMS/MMS call back Handler service
+* @since 2.1
+*
+* This class provides methods to use the SMS/MMS call back Handler service . @n
+*/
+
+// forward declaration
+
+class _SmsMmsCallbackHandler
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.1
+ */
+ virtual ~_SmsMmsCallbackHandler(void);
+
+ // Operation
+public:
+ /**
+ * Gets the instance of SmsMmsCallbackHandler class.
+ *
+ * @since 2.1
+ * @return instance of SmsMmsCallbackHandler class
+ */
+ static _SmsMmsCallbackHandler* GetInstance(void);
+
+ /**
+ * gets the Message Handle for SMS/MMS operation.
+ *
+ * @since 2.1
+ * @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);
+
+ /**
+ * gets the Message Handle for Cbs message operation.
+ *
+ * @since 2.1
+ * @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);
+
+ /**
+ * closes the Message Handle for SMS/MMS operation.
+ *
+ * @since 2.1
+ * @return An error code
+ * @exception MSG_SUCCESS The method was successful.
+ * @exception MSG_ERR_NULL_POINTER Input parameter is NULL.
+ * @exception MSG_ERR_MEMORY_ERROR Memory error.
+ */
+ int CloseMessageHandle(void);
+
+ // for SMS sent status
+ static void SentSmsMessageStatusCallback(messages_sending_result_e status, void* pUserEvent);
+
+ //for MMS sent status
+ static void SentMmsMessageStatusCallback(messages_sending_result_e status, void* pUserEvent);
+
+ // for incoming SMS
+ static void IncomingSmsMessageCallback(messages_message_h incomingMsg, void* pUserParam);
+
+ // for incoming CBS
+ static void IncomingCbsMessageCallback(messages_cb_message_h incomingMsg, void* pUserParam);
+
+ // for incoming Wap push
+ static void IncomingWapPushMessageCallback(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);
+
+ // Life cycle
+private:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.1
+ */
+ _SmsMmsCallbackHandler(void);
+
+private:
+ static _SmsMmsCallbackHandler* __pMessageCallbackHandler;
+ messages_service_h __msgHandle;
+ messages_cb_settings_h __cbsSettingsHandle;
+}; // _SmsMmsCallbackHandler
+
+} } // Tizen::Messaging
+
+#endif // _FMSG_INTERNAL_SMS_MMS_CALLBACK_HANDLER_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_Types.h
+ * @brief This is the header file for Tizen::Messaging namespace.
+ *
+ * This header file contains the types and declarations for the Tizen::Messaging namespace.
+ */
+
+#ifndef _FMSG_INTERNAL_TYPES_H_
+#define _FMSG_INTERNAL_TYPES_H_
+
+#include <unique_ptr.h>
+#include <FBaseDataType.h>
+
+namespace Tizen { namespace Messaging
+{
+
+// recipient count
+#define MAX_SMS_RECIPIENT_COUNT 10
+#define MAX_MMS_RECIPIENT_COUNT 10
+#define MAX_EMAIL_RECIPIENT_COUNT 20
+
+// subject length
+#define MAX_MMS_SUBJECT_LENGTH 40
+#define MAX_EMAIL_SUBJECT_LENGTH 256
+
+// body text length
+#define MAX_SMS_BODY_TEXT_LENGTH 80
+#define MAX_MMS_BODY_TEXT_LENGTH 1000
+#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_EMAIL_FILE_SIZE (5 * 1024 * 1024) // 5MB
+
+// attachment count
+#define MAX_EMAIL_ATTACHMENT_COUNT 20
+
+// address length
+#define MIN_LENGTH_PHONE 3
+#define MAX_LENGTH_PHONE 41
+#define MIN_LENGTH_EMAIL 5 // a@b.c
+#define MAX_LENGTH_EMAIL (64 + 255 + 1) // RFC 2822 - Local(64) + Domain(255) + '@'(1)
+
+// keyword length for retrieving SMS inbox, sentbox, or outbox
+#define MIN_KEYWORD_LENGTH 1
+#define MAX_KEYWORD_LENGTH 30
+
+// Cbs channel name length
+#define MAX_CBS_CHANNEL_NAME_LENGTH 32
+#define MAX_CBS_CHANNEL_RANGE 900
+#define MAX_CBS_CHANNEL_LIMIT 0xFFFF
+
+
+//Detail email message
+#define MAX_EMAIL_MESSAGE_RECEIPT_TYPE 3
+#define MAX_EMAIL_MESSAGE_BODY_TYPE 3
+#define MAX_EMAIL_MESSAGE_PRIORITY 3
+#define MAX_EMAIL_MESSAGE_RETURN_RECEIPT_TYPE 4
+#define MAX_EMAIL_MESSAGE_CLASS 22
+#define MAX_EMAIL_MESSAGE_DIGEST_TYPE 2
+#define MAX_EMAIL_MESSAGE_SMIME_TYPE 4
+
+//
+// @enum MessageType
+// Message types for internal use
+//
+enum _MessageType
+{
+ _MSG_SMS = 0, /**<SMS message */
+ _MSG_MMS, /**<MMS message */
+ _MSG_EMAIL, /**<Email message */
+ _MSG_COMPOSER /**<UI Composer */
+};
+
+//
+// @enum _SmsEventType
+// SMS Event Types for internal use
+//
+enum _SmsEventType
+{
+ _SMS_EVENT_TYPE_NONE = -1,
+ _SMS_EVENT_TYPE_SMS_SEND_RESULT = 0,
+ _SMS_EVENT_TYPE_SMS_TRIGGER = 1,
+ _SMS_EVENT_TYPE_SMS_RECEIVE_RESULT = 2,
+ _SMS_EVENT_TYPE_CBS_RECEIVE_RESULT = 3,
+ _SMS_EVENT_TYPE_ETWS_RECEIVE_RESULT = 4,
+ _SMS_EVENT_TYPE_WAP_PUSH_RECEIVE_RESULT = 5
+};
+
+} } // Tizen::Messaging
+
+#endif // _FMSG_INTERNAL_TYPES_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_WapPushManagerImpl.cpp
+ * @brief This is the implementation file for the %_WapPushManagerImpl class.
+ *
+ * This file contains the implementation of the %_WapPushManagerImpl class.
+ */
+
+// OAF headers
+#include <messages.h>
+#include <FMsgWapPushManager.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include "FMsg_SmsEvent.h"
+#include "FMsg_Types.h"
+#include "FMsg_WapPushManagerImpl.h"
+#include "FMsg_SmsMmsCallbackHandler.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Messaging;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Messaging
+{
+
+_WapPushManagerImpl::_WapPushManagerImpl(void)
+ : __msgHandle(0)
+ , __pWapPushReceiveEvent(null)
+{
+}
+
+_WapPushManagerImpl::_WapPushManagerImpl(const _WapPushManagerImpl& value)
+{
+ __msgHandle = value.__msgHandle;
+ __pWapPushReceiveEvent = value.__pWapPushReceiveEvent;
+}
+
+_WapPushManagerImpl::~_WapPushManagerImpl(void)
+{
+ if (__pWapPushReceiveEvent)
+ {
+ delete __pWapPushReceiveEvent;
+ __pWapPushReceiveEvent = null;
+ }
+}
+
+_WapPushManagerImpl&
+_WapPushManagerImpl::operator =(const _WapPushManagerImpl& rhs)
+{
+ if (this != &rhs)
+ {
+ __msgHandle = rhs.__msgHandle;
+ __pWapPushReceiveEvent = rhs.__pWapPushReceiveEvent;
+ }
+
+ return (*this);
+}
+
+result
+_WapPushManagerImpl::AddWapPushEventListener(const Tizen::Base::String& wapApplicationId, const IWapPushEventListener& listener)
+{
+ result r = E_SUCCESS;
+ int err = MESSAGES_ERROR_NONE;
+ char* pWapAppId = null;
+
+ ClearLastResult();
+
+ pWapAppId = _StringConverter::CopyToCharArrayN(wapApplicationId);
+ SysTryCatch(NID_MSG, pWapAppId != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+
+ // set event
+ if (!__pWapPushReceiveEvent)
+ {
+ __pWapPushReceiveEvent = new (std::nothrow) _SmsEvent();
+ SysTryCatch(NID_MSG, __pWapPushReceiveEvent != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed.");
+
+ // event construction
+ r = __pWapPushReceiveEvent->Construct(_SMS_EVENT_TYPE_WAP_PUSH_RECEIVE_RESULT);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "failed to construct push event");
+ }
+
+ // add listener
+ r = __pWapPushReceiveEvent->AddListener(listener, true);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "failed to add push listner.");
+
+ SysTryCatch(NID_MSG, _SmsMmsCallbackHandler::GetInstance() != null, r = E_OUT_OF_MEMORY, r, "failed to get msg handle.");
+
+ // open message handle
+ err = _SmsMmsCallbackHandler::GetInstance()->OpenMessageHandle(__msgHandle);
+
+ r = ConvertException(err);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to Open Message Handle", GetErrorMessage(r));
+
+ SysLog(NID_MSG, "The value of __msgHandle is [%d]", __msgHandle);
+
+ // check value of msg handle
+ SysTryCatch(NID_MSG, __msgHandle > 0, r = E_SYSTEM, r, "failed to get msg handle.");
+
+ err = messages_push_add_incoming_cb(__msgHandle, pWapAppId, &_SmsMmsCallbackHandler::IncomingWapPushMessageCallback, (void*) __pWapPushReceiveEvent);
+
+ r = ConvertException(err);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to Add WapPush EventListener.", GetErrorMessage(r));
+
+ if (pWapAppId)
+ {
+ delete[] pWapAppId;
+ pWapAppId = null;
+ }
+
+ return r;
+
+CATCH:
+ if (pWapAppId)
+ {
+ delete[] pWapAppId;
+ pWapAppId = null;
+ }
+
+ if (__pWapPushReceiveEvent)
+ {
+ delete __pWapPushReceiveEvent;
+ __pWapPushReceiveEvent = null;
+ }
+
+ return r;
+}
+
+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;
+ __pWapPushReceiveEvent = null;
+ }
+
+ return r;
+
+CATCH:
+ if (pWapAppId)
+ {
+ delete[] pWapAppId;
+ pWapAppId = null;
+ }
+ return r;
+}
+
+result
+_WapPushManagerImpl::RegisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType)
+{
+ result r = E_SUCCESS;
+ int err = MESSAGES_ERROR_NONE;
+ char* pWapAppId = null;
+ char* pContentType = null;
+
+ ClearLastResult();
+
+ pWapAppId = _StringConverter::CopyToCharArrayN(wapApplicationId);
+ SysTryCatch(NID_MSG, pWapAppId != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+
+ pContentType = _StringConverter::CopyToCharArrayN(contentType);
+ SysTryCatch(NID_MSG, pContentType != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+
+ err = messages_push_register(__msgHandle, pContentType, pWapAppId);
+
+ r = ConvertException(err);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to register Condition for wap push.", GetErrorMessage(r));
+
+ if (pWapAppId)
+ {
+ delete[] pWapAppId;
+ pWapAppId = null;
+ }
+
+ if (pContentType)
+ {
+ delete[] pContentType;
+ pContentType = null;
+ }
+ return r;
+
+CATCH:
+ if (pWapAppId)
+ {
+ delete[] pWapAppId;
+ pWapAppId = null;
+ }
+
+ if (pContentType)
+ {
+ delete[] pContentType;
+ pContentType = null;
+ }
+ return r;
+}
+
+result
+_WapPushManagerImpl::UnregisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType)
+{
+ result r = E_SUCCESS;
+ int err = MESSAGES_ERROR_NONE;
+ char* pWapAppId = null;
+ char* pContentType = null;
+
+ ClearLastResult();
+
+ pWapAppId = _StringConverter::CopyToCharArrayN(wapApplicationId);
+ SysTryCatch(NID_MSG, pWapAppId != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+
+ pContentType = _StringConverter::CopyToCharArrayN(contentType);
+ SysTryCatch(NID_MSG, pContentType != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+
+ err = messages_push_deregister(__msgHandle, pContentType, pWapAppId);
+
+ r = ConvertException(err);
+ SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to Unregister Condition for wap push", GetErrorMessage(r));
+
+ if (pWapAppId)
+ {
+ delete[] pWapAppId;
+ pWapAppId = null;
+ }
+
+ if (pContentType)
+ {
+ delete[] pContentType;
+ pContentType = null;
+ }
+ return r;
+
+CATCH:
+ if (pWapAppId)
+ {
+ delete[] pWapAppId;
+ pWapAppId = null;
+ }
+
+ if (pContentType)
+ {
+ delete[] pContentType;
+ pContentType = null;
+ }
+ return r;
+}
+
+result
+_WapPushManagerImpl::ConvertException(int err) const
+{
+ 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_OBJ_ALREADY_EXIST;
+ break;
+
+ case MESSAGES_ERROR_SENDING_FAILED:
+ case MESSAGES_ERROR_OPERATION_FAILED:
+ r = E_FAILURE;
+ break;
+
+ default:
+ r = E_SYSTEM;
+ break;
+ }
+
+ return r;
+}
+
+} }
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+* @if VISPARTNER-OPERATOR
+*
+* @file FMsg_WapPushManagerImpl.h
+* @brief This is the header file for the _WapPushManagerImpl class.
+*
+* @visibility partner-operator
+*
+* This header file contains the declarations of the _WapPushManagerImpl class.
+*
+* @endif
+*/
+
+#ifndef _FMSG_INTERNAL_WAP_PUSH_MANAGER_IMPL_H_
+#define _FMSG_INTERNAL_WAP_PUSH_MANAGER_IMPL_H_
+
+namespace Tizen { namespace Messaging
+{
+
+/**
+* @if VISPARTNER-OPERATOR
+*
+* @class _WapPushManagerImpl
+* @brief This class provides methods to use the WAP push messaging service.
+*
+* @since 2.1
+*
+* @final This class is not intended for extension.
+*
+* @visibility partner-operator
+*
+* @endif
+*/
+
+// forward declaration
+class _SmsEvent;
+
+class _WapPushManagerImpl
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * This is the default constructor for this class.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @endif
+ */
+ _WapPushManagerImpl(void);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @endif
+ */
+ virtual ~_WapPushManagerImpl(void);
+
+public:
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Adds the event listener for receiving WAP push messages regarding specific WAP push application ID.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ * @privlevel user
+ * @privilege http://tizen.org/privilege/wappush
+ *
+ * @return An error code
+ * @param[in] wapApplicationId The X-Wap-Application-Id indicating a WAP push application ID.
+ * @param[in] listener A listener that receives the incoming push messages
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_ALREADY_EXIST The specified @c wapApplicationId is already registered @n
+ * or the listener already exists.
+ * @exception E_INVALID_ARG The specified @c wapApplicationId is invalid. @n
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SYSTEM A system error has occurred.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @see IWapPushEventListener, RemoveWapPushEventListener()
+ *
+ * @endif
+ */
+ result AddWapPushEventListener(const Tizen::Base::String& wapApplicationId, const IWapPushEventListener& listener);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Removes the event listener for receiving WAP push messages regarding specific WAP push application ID.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ * @privlevel user
+ * @privilege http://tizen.org/privilege/wappush
+ *
+ * @return An error code
+ * @param[in] wapApplicationId The X-Wap-Application-Id indicating a WAP push application ID.
+ * @param[in] listener A listener that receives the incoming push messages
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND The specified @c wapApplicationId is not registered. @n
+ * The specified @c listener is not found.
+ * @exception E_INVALID_ARG The specified @c wapApplicationId is invalid.
+ * @exception E_SYSTEM A system error has occurred.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @see IWapPushEventListener, AddWapPushEventListener()
+ *
+ * @endif
+ */
+ result RemoveWapPushEventListener(const Tizen::Base::String& wapApplicationId, const IWapPushEventListener& listener);
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Registers a condition to receive WAP push message.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ * @privlevel user
+ * @privilege http://tizen.org/privilege/wappush
+ *
+ * @return An error code
+ * @param[in] wapApplicationId The X-Wap-Application-Id indicating a WAP push application ID.
+ * @param[in] contentType The MIME content type of the content.
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_INVALID_ARG The specified @c contentType or @c wapApplicationId is invalid.
+ * @exception E_ILLEGAL_ACCESS The application does not have the permission to register the conditions.
+ * @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.1
+ *
+ * @visibility partner-operator
+ * @privlevel user
+ * @privilege http://tizen.org/privilege/wappush
+ *
+ * @return An error code
+ * @param[in] wapApplicationId The X-Wap-Application-Id indicating a WAP push application ID.
+ * @param[in] contentType The MIME content type of the content.
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_INVALID_ARG The specified @c contentType or @c wapApplicationId is invalid.
+ * @exception E_ILLEGAL_ACCESS The application does not have the permission to unregister the conditions.
+ * @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);
+
+ result ConvertException(int err) const;
+
+public:
+ /**
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+ *
+ * @param[in] rhs An instance of _WapPushManagerImpl
+ */
+ _WapPushManagerImpl(const _WapPushManagerImpl& rhs);
+
+ /**
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+ *
+ * @param[in] rhs An instance of _WapPushManagerImpl
+ */
+ _WapPushManagerImpl& operator =(const _WapPushManagerImpl& rhs);
+
+private:
+ messages_service_h __msgHandle;
+ _SmsEvent* __pWapPushReceiveEvent;
+
+}; // _WapPushManagerImpl
+
+} } // Tizen::Messaging
+#endif // _FMSG_INTERNAL_WAP_PUSH_MANAGER_IMPL_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file FMsg_WapPushMessageImpl.cpp
+ * @brief This is the implementation file for the %_WapPushMessageImpl class.
+ *
+ * This file contains the implementation of the %__WapPushMessageImpl class.
+ */
+
+#include <messages.h>
+#include <FMsgWapPushMessage.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FMsg_WapPushMessageImpl.h"
+#include "FMsg_Types.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Messaging;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Messaging
+{
+
+_WapPushMessageImpl::_WapPushMessageImpl(void)
+ : __msgHeader(L"")
+ , __pMsgBody(null)
+{
+ __pMsgBody = new (std::nothrow) ByteBuffer();
+ SysTryReturnVoidResult(NID_MSG, __pMsgBody != null, E_OUT_OF_MEMORY, "memory allocation failed");
+ __pMsgBody->Construct(0);
+ __pMsgBody->SetPosition(0);
+}
+
+_WapPushMessageImpl::_WapPushMessageImpl(const _WapPushMessageImpl& value)
+{
+ __pMsgBody->SetArray(value.__pMsgBody->GetPointer(), 0, value.__pMsgBody->GetLimit());
+ __pMsgBody->SetPosition(0);
+ __msgHeader = value.__msgHeader;
+}
+
+_WapPushMessageImpl::~_WapPushMessageImpl(void)
+{
+ if (__pMsgBody)
+ {
+ delete __pMsgBody;
+ __pMsgBody = null;
+ }
+}
+
+_WapPushMessageImpl&
+_WapPushMessageImpl::operator =(const _WapPushMessageImpl& rhs)
+{
+ if (this != &rhs)
+ {
+ __pMsgBody->SetArray(rhs.__pMsgBody->GetPointer(), 0, rhs.__pMsgBody->GetLimit());
+ __pMsgBody->SetPosition(0);
+ __msgHeader = rhs.__msgHeader;
+ }
+
+ return (*this);
+}
+
+_WapPushMessageImpl::_WapPushMessageImpl(const Tizen::Base::String& header, const Tizen::Base::ByteBuffer& body)
+{
+ __pMsgBody = new (std::nothrow) ByteBuffer();
+ SysTryReturnVoidResult(NID_MSG, __pMsgBody != null, E_OUT_OF_MEMORY, "memory allocation failed");
+ __pMsgBody->Construct(body);
+ __pMsgBody->SetPosition(0);
+ __msgHeader = header;
+}
+
+bool
+_WapPushMessageImpl::Equals(const Tizen::Base::Object& obj) const
+{
+ const _WapPushMessageImpl* p_WapPushMessageImpl = dynamic_cast<const _WapPushMessageImpl*>(&obj);
+ if (!p_WapPushMessageImpl)
+ {
+ SysLog(NID_MSG, "dynamic_cast is failed");
+ return false;
+ }
+
+ // msg header
+ if (__msgHeader != p_WapPushMessageImpl->__msgHeader)
+ {
+ return false;
+ }
+
+ // msg body
+ if (__pMsgBody != p_WapPushMessageImpl->__pMsgBody)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+WapPushMessage*
+_WapPushMessageImpl::CloneN() const
+{
+ WapPushMessage* pWapPushMsg = null;
+ pWapPushMsg = _WapPushMessageImpl::GetWapPushMessageN(__msgHeader, *__pMsgBody);
+
+ return pWapPushMsg;
+}
+
+WapPushMessage*
+_WapPushMessageImpl::GetWapPushMessageN(const Tizen::Base::String& pushMsgHdr, const Tizen::Base::ByteBuffer& pushMsgBody)
+{
+ WapPushMessage* pWapPushMsg = null;
+ result r = E_SUCCESS;
+
+ pWapPushMsg = new (std::nothrow) WapPushMessage(pushMsgHdr, pushMsgBody);
+ SysTryCatch(NID_MSG, pWapPushMsg != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+ SetLastResult(r);
+
+ return pWapPushMsg;
+
+CATCH:
+ SetLastResult(r);
+ return null;
+}
+
+int
+_WapPushMessageImpl::GetHashCode(void) const
+{
+ int hash = 0;
+
+ hash = __msgHeader.GetHashCode() + __pMsgBody->GetHashCode();
+
+ return hash;
+}
+
+Tizen::Base::ByteBuffer*
+_WapPushMessageImpl::GetBodyN(void) const
+{
+ result r = E_SUCCESS;
+ Tizen::Base::ByteBuffer* pMsgBuffer = null;
+
+ ClearLastResult();
+
+ pMsgBuffer = new (std::nothrow) ByteBuffer();
+ SysTryCatch(NID_MSG, pMsgBuffer != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
+
+ r = pMsgBuffer->Construct(*__pMsgBody);
+ r = pMsgBuffer->SetPosition(0);
+
+ SetLastResult(r);
+
+ return pMsgBuffer;
+
+CATCH:
+ SetLastResult(r);
+
+ return null;
+}
+
+Tizen::Base::String
+_WapPushMessageImpl::GetHeader(void) const
+{
+ return __msgHeader;
+}
+
+} }
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+* @if VISPARTNER-OPERATOR
+*
+* @file FMsg_WapPushMessageImpl.h
+* @brief This is the header file for the _WapPushMessageImpl class.
+*
+* @visibility partner-operator
+*
+* This header file contains the declarations of the _WapPushMessageImpl class.
+*
+* @endif
+*/
+
+#ifndef _FMSG_INTERNAL_WAP_PUSH_MESSAGE_IMPL_H_
+#define _FMSG_INTERNAL_WAP_PUSH_MESSAGE_IMPL_H_
+
+namespace Tizen { namespace Messaging
+{
+
+/**
+* @if VISPARTNER-OPERATOR
+*
+* @class _WapPushMessageImpl
+* @brief This class provides methods for handling a WAP push message.
+*
+* @since 2.1
+*
+* @final This class is not intended for extension.
+*
+* @visibility partner-operator
+*
+* The _WapPushMessageImpl class provides methods for handling a WAP push message. @n
+* It allows you to get the header and the body of a WAP push message.
+*
+* @endif
+*/
+class _WapPushMessageImpl
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @endif
+ */
+ virtual ~_WapPushMessageImpl(void);
+
+public:
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the header of the message.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The header of the 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 the message.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The body of the message
+ * @remarks The message body can be any MIME content-type.
+ *
+ * @endif
+ */
+ Tizen::Base::ByteBuffer* GetBodyN(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Compares the specified instance of %_WapPushMessageImpl with this instance.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return @c true, if the values match @n
+ * @c false, otherwise
+ * @param[in] obj The other Object to be compared
+ * @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.1
+ *
+ * @visibility partner-operator
+ *
+ * @return The current instance's hash value
+ *
+ * @endif
+ */
+ virtual int GetHashCode(void) const;
+
+ /**
+ * @if VISPARTNER-OPERATOR
+ *
+ * Gets the copied instance of the class.
+ *
+ * @since 2.1
+ *
+ * @visibility partner-operator
+ *
+ * @return An instance of %_WapPushMessageImpl
+ * @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
+ */
+ WapPushMessage* CloneN(void) const;
+
+ /**
+ * Gets the instance of WapPushMessage Class
+ *
+ * @since 2.1
+ */
+ static WapPushMessage* GetWapPushMessageN(const Tizen::Base::String& pushMsgHdr, const Tizen::Base::ByteBuffer& pushMsgBody);
+
+public:
+ /**
+ * This default constructor is intentionally declared as private so that only the platform can create an instance.
+ *
+ * @since 2.1
+ */
+ _WapPushMessageImpl(void);
+
+ /**
+ * This is the copy constructor for the %_WapPushMessageImpl class. @n
+ * Copying of objects using this copy constructor is allowed.
+ *
+ * @since 2.1
+ *
+ * @param[in] rhs An instance of _WapPushMessageImpl
+ */
+ _WapPushMessageImpl(const _WapPushMessageImpl& 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.
+ *
+ * @return A reference to this instance
+ * @param[in] rhs An instance of _WapPushMessageImpl
+ */
+ _WapPushMessageImpl& operator =(const _WapPushMessageImpl& rhs);
+
+ /**
+ * This constructor is intentionally declared as private so that only the platform can create an instance.
+ *
+ * @param[in] header The header of the received WAP push message
+ * @param[in] body The body of the received WAP push message
+ */
+ _WapPushMessageImpl(const Tizen::Base::String& header, const Tizen::Base::ByteBuffer& body);
+
+private:
+ Tizen::Base::String __msgHeader;
+ Tizen::Base::ByteBuffer* __pMsgBody;
+
+}; // _WapPushMessageImpl
+
+} } // Tizen::Messaging
+#endif // _FMSG_INTERNAL_WAP_PUSH_MESSAGE_IMPL_H_
--- /dev/null
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+/** \r
+ * @file FMsg_IComposerListener.h\r
+ * @brief This is the header file for the %_IComposerListener interface.\r
+ *\r
+ * This header file contains the declarations of the %_IComposerListener interface.\r
+ */\r
+\r
+#ifndef _FMSG_INTERNAL_ICOMPOSER_LISTENER_H_\r
+#define _FMSG_INTERNAL_ICOMPOSER_LISTENER_H_\r
+\r
+// Includes\r
+#include <FBaseDataType.h>\r
+#include <FBaseRtIEventListener.h>\r
+#include <FOspConfig.h>\r
+\r
+namespace Tizen { namespace Messaging {\r
+\r
+ /**\r
+ * @interface _IComposerListener\r
+ * @brief This interface implements a listener to respond to asynchronous composer callbacks.\r
+ * @since 1.0\r
+ */\r
+ class _OSP_EXPORT_ _IComposerListener :\r
+ public Tizen::Base::Runtime::IEventListener\r
+ {\r
+ // Operation\r
+ public: \r
+ /**\r
+ * Called when the message composer is initialized. \r
+ *\r
+ * @param[in] r The result of initializing a composer\r
+ */\r
+ virtual void OnComposerInitialized(result r) = 0;\r
+\r
+ /**\r
+ * Called when the message composer is terminated.\r
+ *\r
+ * @param[in] r The result of terminating a composer\r
+ */\r
+ virtual void OnComposerTerminated(result r) = 0;\r
+ }; // _IComposerListener\r
+\r
+};\r
+};\r
+\r
+#endif // _FMSG_INTERNAL_ICOMPOSER_LISTENER_H_\r