--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET (this_target osp-nfc)
+
+SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/cmake_build_tmp/output)
+
+INCLUDE_DIRECTORIES(
+ inc
+ src
+ src/inc
+ /usr/include/chromium
+ /usr/include/glib-2.0
+ /usr/lib/glib-2.0/include
+ /usr/include/system
+ /usr/include/network
+ /usr/include/osp
+ /usr/include/osp/app
+ /usr/include/osp/base
+ /usr/include/osp/io
+ /usr/include/osp/net
+ /usr/include/osp/security
+ /usr/include/osp/system
+ )
+
+SET (${this_target}_SOURCE_FILES
+ src/FNetNfcNdefMessage.cpp
+ src/FNetNfcNdefRecord.cpp
+ src/FNetNfcNdefRecordType.cpp
+ src/FNetNfcNdefTagConnection.cpp
+ src/FNetNfcNfcManager.cpp
+ src/FNetNfcNfcTag.cpp
+ src/FNetNfcTagConnection.cpp
+ src/FNetNfcNdefPushManager.cpp
+ src/FNetNfc_NdefMessageDiscoveryEvent.cpp
+ src/FNetNfc_NdefMessageDiscoveryEventArg.cpp
+ src/FNetNfc_NdefMessageImpl.cpp
+ src/FNetNfc_NdefMessageUtil.cpp
+ src/FNetNfc_NdefRecordImpl.cpp
+ src/FNetNfc_NdefRecordTypeImpl.cpp
+ src/FNetNfc_NfcIpcMessages.cpp
+ src/FNetNfc_NfcIpcProxy.cpp
+ src/FNetNfc_NfcManagerEvent.cpp
+ src/FNetNfc_NfcManagerEventArg.cpp
+ src/FNetNfc_NfcManagerImpl.cpp
+ src/FNetNfc_NfcSystemAdapter.cpp
+ src/FNetNfc_NfcTagDiscoveryEvent.cpp
+ src/FNetNfc_NfcTagDiscoveryEventArg.cpp
+ src/FNetNfc_NfcTagImpl.cpp
+ src/FNetNfc_TagConnectionEvent.cpp
+ src/FNetNfc_TagConnectionEventArg.cpp
+ src/FNetNfc_TagConnectionImpl.cpp
+ src/FNetNfc_NdefPushManagerImpl.cpp
+ src/FNetNfc_NfcDeviceDiscoveryEvent.cpp
+ src/FNetNfc_NfcDeviceDiscoveryEventArg.cpp
+ src/FNetNfc_NdefPushManagerEventArg.cpp
+ src/FNetNfc_NdefPushManagerEvent.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-net" )
+TARGET_LINK_LIBRARIES(${this_target} "-lcapi-network-nfc" )
+TARGET_LINK_LIBRARIES(${this_target} "-lpthread" )
+
+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/net FILES_MATCHING PATTERN "*.h")
+
+SET(PC_NAME ${this_target})
+SET(VERSION ${FULLVER})
+SET(PC_LDFLAGS -l${this_target})
+
+# 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
+Flora License
+
+Version 1.1, April, 2013
+
+http://floralicense.org/license/
+
+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.
+
+"Tizen Certified Platform" shall mean a software platform that complies
+with the standards set forth in the Tizen Compliance Specification
+and passes the Tizen Compliance Tests as defined from time to time
+by the Tizen Technical Steering Group and certified by the Tizen
+Association or its designated agent.
+
+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
+solely as incorporated into a Tizen Certified Platform, 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 solely
+as incorporated into a Tizen Certified Platform 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 pursuant to the copyright license
+above, in any medium, with or without modifications, and in Source or
+Object form, provided that You meet the following conditions:
+
+ 1. You must give any other recipients of the Work or Derivative Works
+ a copy of this License; and
+ 2. You must cause any modified files to carry prominent notices stating
+ that You changed the files; and
+ 3. 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
+ 4. 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
+ and your own copyright statement or terms and conditions do not conflict
+ the conditions stated in the License including section 3.
+
+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 Flora License to your work
+
+To apply the Flora 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 Flora License, Version 1.1 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://floralicense.org/license/
+
+ 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) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE file for Apache License terms and conditions.
+
+Several source codes may have its original copyright owner and/or
+be licensed under other than Apache License, Version 2, say, Flora License, Version 1.1
+Please, see copyright and license comments section in the header of each file,
+and the LICENSE.Flora for Flora License, Version 1.1 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 FNetNfc.h
+ * @brief This is the header file for the %Nfc namespace.
+ *
+ * This header file contains the declarations and descriptions of the %Nfc namespace.
+ */
+#ifndef _FNET_NFC_H_
+#define _FNET_NFC_H_
+
+#include <FNetNfcNfcTypes.h>
+#include <FNetNfcNdefRecordType.h>
+#include <FNetNfcNdefRecord.h>
+#include <FNetNfcNdefMessage.h>
+#include <FNetNfcNfcTag.h>
+#include <FNetNfcTagConnection.h>
+#include <FNetNfcNdefTagConnection.h>
+#include <FNetNfcNfcManager.h>
+#include <FNetNfcNdefPushManager.h>
+#include <FNetNfcINfcTagDiscoveryEventListener.h>
+#include <FNetNfcINdefMessageDiscoveryEventListener.h>
+#include <FNetNfcINfcManagerEventListener.h>
+#include <FNetNfcITagConnectionListener.h>
+#include <FNetNfcINdefTagConnectionListener.h>
+#include <FNetNfcINfcDeviceDiscoveryEventListener.h>
+#include <FNetNfcINdefPushManagerListener.h>
+
+namespace Tizen { namespace Net
+{
+/**
+ * @namespace Tizen::Net::Nfc
+ * @brief This namespace contains classes and interfaces for Near Field Communication (NFC) services.
+ * @since 2.0
+ *
+ * @remarks @b Header @b %file: @b \#include @b <FNet.h> @n
+ * @b Library: @b osp-nfc
+ *
+ * The %Nfc namespace contains various classes and interfaces for Near Field Communication (NFC) programming
+ * that enables devices to share information within a distance of less than @c 4 centimeters.
+ *
+ * For more information on the NFC namespace features, see
+ * <a href="../org.tizen.native.appprogramming/html/guide/net/nfc.htm">NFC Guide</a>.
+ *
+ *
+ * The following diagram illustrates the relationships between the classes belonging to the %Nfc namespace.
+ * @image html net_nfc_using_the_apis_classdiagram.png
+ *
+ */
+namespace Nfc
+{
+} } } // Tizen::Net::Nfc
+#endif // _FNET_NFC_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 FNetNfcINdefMessageDiscoveryEventListener.h
+ * @brief This is the header file for the %INdefMessageDiscoveryEventListener interface.
+ *
+ * This header file contains the declarations of the %INdefMessageDiscoveryEventListener interface.
+ */
+
+#ifndef _FNET_NFC_INDEF_MESSAGE_DISCOVERY_EVENT_LISTENER_H_
+#define _FNET_NFC_INDEF_MESSAGE_DISCOVERY_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+class NdefMessage;
+
+/**
+ * @interface INdefMessageDiscoveryEventListener
+ * @brief This interface provides a listener for the events related to an NDEF message discovery.
+ *
+ * @since 2.0
+ *
+ * The %INdefMessageDiscoveryEventListener interface specifies the methods used for creating notifications about an
+ * NDEF message discovered from a target tag.
+ *
+ * For more information on the class features, see
+ * <a href="../org.tizen.native.appprogramming/html/guide/net/nfc.htm">NFC Guide</a>.
+ */
+class _OSP_EXPORT_ INdefMessageDiscoveryEventListener
+ : public Tizen::Base::Runtime::IEventListener
+{
+public:
+ /**
+ * This polymorphic destructor should be overridden if required. @n
+ * This way, the destructors of the derived classes are called when the destructor of this interface is called.
+ *
+ * @since 2.0
+ */
+ virtual ~INdefMessageDiscoveryEventListener(void) {}
+
+ /**
+ * Called to notify the application when an NDEF message, that includes NDEF records with the specified filter
+ * type, is detected.
+ *
+ * @since 2.0
+ *
+ * @param[in] pMessage The detected NDEF message
+ * @remarks
+ * - This method can be used for providing read-only access to the data on the target without opening a
+ * connection to it.
+ * - The input NdefMessage object must be deleted by the application after use, even outside this
+ * method. The NdefMessage::RemoveAllRecords() method must be called with @c true as the input value
+ * immediately before the %NdefMessage object is deleted.
+ */
+ virtual void OnNdefMessageDetectedN(NdefMessage* pMessage) = 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 INdefMessageDiscoveryEventListener_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 INdefMessageDiscoveryEventListener_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 INdefMessageDiscoveryEventListener_Reserved3(void) {}
+}; // INdefMessageDiscoveryEventListener
+
+} } } // Tizen::Net::Nfc
+
+#endif // _FNET_NFC_INDEF_MESSAGE_DISCOVERY_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 FNetNfcINdefPushManagerListener.h
+ * @brief This is the header file for the %INdefPushManagerListener interface.
+ *
+ * This header file contains the declarations of the %INdefPushManagerListener interface.
+ */
+
+#ifndef _FNET_NFC_INDEF_PUSH_MANAGER_LISTENER_H_
+#define _FNET_NFC_INDEF_PUSH_MANAGER_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FBaseResult.h>
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+/**
+ * @interface INdefPushManagerListener
+ * @brief This interface provides a listener for the events related to %NfcPushManager.
+ * @since 2.0
+ *
+ * The %INdefPushManagerListener interface specifies the methods used for receiving the status of a pushed NDEF
+ * message asynchronously.
+ *
+ * For more information on the class features, see
+ * <a href="../org.tizen.native.appprogramming/html/guide/net/nfc.htm">NFC Guide</a>.
+ */
+class _OSP_EXPORT_ INdefPushManagerListener
+ : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+ /**
+ * This polymorphic destructor should be overridden if required. @n
+ * This way, the destructors of the derived classes are called when the destructor of this interface is called.
+ *
+ * @since 2.0
+ */
+ virtual ~INdefPushManagerListener(void) {}
+
+ /**
+ * Called when a push operation to the target device is completed.
+ *
+ * @since 2.0
+ *
+ * @param[in] r The result of a pushed NDEF message @n
+ * The following exceptions may be given through this parameter.
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_NOT_RESPONDING The device is not responding.
+ * @exception E_OPERATION_FAILED The operation has failed.
+ */
+ virtual void OnNdefPushMessageSent(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 INdefPushManagerListener_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 INdefPushManagerListener_Reserved2(void) {}
+}; // INdefPushManagerListener
+
+} } } // Tizen::Net::Nfc
+
+#endif // _FNET_NFC_INDEF_PUSH_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.
+//
+/**
+ * @file FNetNfcINdefTagConnectionListener.h
+ * @brief This is the header file for the %INdefTagConnectionListener interface.
+ *
+ * This header file contains the declarations of the %INdefTagConnectionListener interface.
+ */
+
+#ifndef _FNET_NFC_INDEF_TAG_CONNECTION_LISTENER_H_
+#define _FNET_NFC_INDEF_TAG_CONNECTION_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FBaseResult.h>
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+class NdefMessage;
+
+/**
+ * @interface INdefTagConnectionListener
+ * @brief This interface provides a listener for the events related to an NDEF tag connection.
+ *
+ * @since 2.0
+ *
+ * The %INdefTagConnectionListener interface specifies the methods used for creating notifications about the result
+ * of an action performed for NdefTagConnection, such as reading and writing the NDEF data.
+ *
+ * For more information on the class features, see
+ * <a href="../org.tizen.native.appprogramming/html/guide/net/nfc.htm">NFC Guide</a>.
+ */
+class _OSP_EXPORT_ INdefTagConnectionListener
+ : public Tizen::Base::Runtime::IEventListener
+{
+public:
+ /**
+ * This polymorphic destructor should be overridden if required. @n
+ * This way, the destructors of the derived classes are called when the destructor of this interface is called.
+ *
+ * @since 2.0
+ */
+ virtual ~INdefTagConnectionListener(void) {}
+
+ /**
+ * Called to notify the application when a read operation from the target tag is completed.
+ *
+ * @since 2.0
+ *
+ * @param[in] pMessage The read NdefMessage object, @n
+ * else @c null if it fails
+ * @param[in] r An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_DATA_NOT_FOUND The target tag has no NDEF record.
+ * @exception E_INVALID_FORMAT The read data cannot be formulated to the NDEF message.
+ * @exception E_NOT_RESPONDING The target tag is not responding.
+ * @exception E_SYSTEM A system error has occurred.
+ * @remarks The input NdefMessage object must be deleted by the application after use, even outside this
+ * method. The NdefMessage::RemoveAllRecords() method must be called with @c true as the input value
+ * right before the %NdefMessage object is deleted.
+ * @see NdefTagConnection::Read()
+ */
+ virtual void OnNdefReadCompletedN(NdefMessage* pMessage, result r) = 0;
+
+ /**
+ * Called to notify the application when a write operation on the target tag is completed.
+ *
+ * @since 2.0
+ *
+ * @param[in] r An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_ILLEGAL_ACCESS Either of the following conditions has occurred:
+ * - The write operation on the target tag is denied.
+ * - The target tag is locked or protected for the write operation.
+ * @exception E_STORAGE_FULL The storage capacity of the target tag has reached the maximum limit.
+ * @exception E_NOT_RESPONDING The target tag is not responding.
+ * @exception E_SYSTEM A system error has occurred.
+ * @see NdefTagConnection::Write()
+ */
+ virtual void OnNdefWriteCompleted(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 INdefTagConnectionListener_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 INdefTagConnectionListener_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 INdefTagConnectionListener_Reserved3(void) {}
+}; // INdefTagConnectionListener
+
+} } } // Tizen::Net::Nfc
+
+#endif // _FNET_NFC_INDEF_TAG_CONNECTION_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 FNetNfcINfcDeviceDiscoveryEventListener.h
+ * @brief This is the header file for the %INfcDeviceDiscoveryEventListener interface.
+ *
+ * This header file contains the declarations of the %INfcDeviceDiscoveryEventListener interface.
+ */
+
+#ifndef _FNET_NFC_INFC_DEVICE_DISCOVERY_EVENT_LISTENER_H_
+#define _FNET_NFC_INFC_DEVICE_DISCOVERY_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FBaseResult.h>
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+/**
+ * @interface INfcDeviceDiscoveryEventListener
+ * @brief This interface provides a listener for the events related to a device discovery.
+ * @since 2.0
+ *
+ * The %INfcDeviceDiscoveryEventListener interface specifies the methods used for creating notifications
+ * about detecting a device.
+ *
+ * For more information on the class features, see
+ * <a href="../org.tizen.native.appprogramming/html/guide/net/nfc.htm">NFC Guide</a>.
+ */
+class _OSP_EXPORT_ INfcDeviceDiscoveryEventListener
+ : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+ /**
+ * This polymorphic destructor should be overridden if required. @n
+ * This way, the destructors of the derived classes are called when the destructor of this interface is called.
+ *
+ * @since 2.0
+ */
+ virtual ~INfcDeviceDiscoveryEventListener(void) {}
+
+ /**
+ * Called to notify the application when a device is detected.
+ *
+ * @since 2.0
+ */
+ virtual void OnNfcDeviceDetected(void) = 0;
+
+ /**
+ * Called to notify the application when a device is lost.
+ *
+ * @since 2.0
+ */
+ virtual void OnNfcDeviceLost(void) = 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 INfcDeviceDiscoveryEventListener_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 INfcDeviceDiscoveryEventListener_Reserved2(void) {}
+}; // INfcDeviceDiscoveryEventListener
+
+} } } // Tizen::Net::Nfc
+
+#endif // _FNET_NFC_INFC_DEVICE_DISCOVERY_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 FNetNfcINfcManagerEventListener.h
+ * @brief This is the header file for the %INfcManagerEventListener interface.
+ *
+ * This header file contains the declarations of the %INfcManagerEventListener interface.
+ */
+
+#ifndef _FNET_NFC_INFC_MANAGER_EVENT_LISTENER_H_
+#define _FNET_NFC_INFC_MANAGER_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FBaseResult.h>
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+/**
+ * @interface INfcManagerEventListener
+ * @brief This interface provides a listener for the events related to the Near field Communication (NFC)
+ * manager.
+ *
+ * @since 2.0
+ *
+ * The %INfcManagerEventListener interface specifies the methods used for creating notifications about a change in
+ * the NfcManager's status.
+ *
+ * For more information on the class features, see
+ * <a href="../org.tizen.native.appprogramming/html/guide/net/nfc.htm">NFC Guide</a>.
+ */
+class _OSP_EXPORT_ INfcManagerEventListener
+ : public Tizen::Base::Runtime::IEventListener
+{
+public:
+ /**
+ * This polymorphic destructor should be overridden if required. @n
+ * This way, the destructors of the derived classes are called when the destructor of this interface is called.
+ *
+ * @since 2.0
+ */
+ virtual ~INfcManagerEventListener(void) {}
+
+ /**
+ * Called to notify when the NFC feature is activated on the device.
+ *
+ * @since 2.0
+ *
+ * @param[in] r The activation status
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ virtual void OnNfcActivated(result r) = 0;
+
+ /**
+ * Called to notify when the NFC feature is deactivated on the device.
+ *
+ * @since 2.0
+ *
+ * @param[in] r The deactivation status
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ virtual void OnNfcDeactivated(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 INfcManagerEventListener_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 INfcManagerEventListener_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 INfcManagerEventListener_Reserved3(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 INfcManagerEventListener_Reserved4(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 INfcManagerEventListener_Reserved5(void) {}
+
+}; // INfcManagerEventListener
+
+} } } // Tizen::Net::Nfc
+
+#endif // _FNET_NFC_INFC_MANAGER_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 FNetNfcINfcTagDiscoveryEventListener.h
+ * @brief This is the header file for the %INfcTagDiscoveryEventListener interface.
+ *
+ * This header file contains the declarations of the %INfcTagDiscoveryEventListener interface.
+ */
+
+#ifndef _FNET_NFC_INFC_TAG_DISCOVERY_EVENT_LISTENER_H_
+#define _FNET_NFC_INFC_TAG_DISCOVERY_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+class TagConnection;
+
+/**
+ * @interface INfcTagDiscoveryEventListener
+ * @brief This interface provides a listener for the events related to a tag discovery.
+ *
+ * @since 2.0
+ *
+ * The %INfcTagDiscoveryEventListener interface specifies the methods used for creating notifications about
+ * detecting a target tag.
+ *
+ * For more information on the class features, see
+ * <a href="../org.tizen.native.appprogramming/html/guide/net/nfc.htm">NFC Guide</a>.
+ */
+class _OSP_EXPORT_ INfcTagDiscoveryEventListener
+ : public Tizen::Base::Runtime::IEventListener
+{
+public:
+ /**
+ * This polymorphic destructor should be overridden if required. @n
+ * This way, the destructors of the derived classes are called when the destructor of this interface is called.
+ *
+ * @since 2.0
+ */
+ virtual ~INfcTagDiscoveryEventListener(void) {}
+
+ /**
+ * Called to notify the application when a tag is detected by the device.
+ *
+ * @since 2.0
+ *
+ * @param[in] pConnection The connection established with the detected tag
+ * @remarks TagConnection is inherited by NdefTagConnection if the current attached tag supports NDEF
+ * operations. To verify this, use TagConnection::IsNdefConnection().
+ */
+ virtual void OnNfcTagDetectedN(TagConnection* pConnection) = 0;
+
+ /**
+ * Called to notify the application when a tag is lost by the device.
+ *
+ * @since 2.0
+ *
+ * @remarks The operations of TagConnection returned by OnNfcTagDetectedN() are not processed further after
+ * this event is called, that is, the target tag is lost. Moreover, the %TagConnection object cannot be
+ * reused even though the same tag is detected again by the device.
+ */
+ virtual void OnNfcTagLost(void) = 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 INfcTagDiscoveryEventListener_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 INfcTagDiscoveryEventListener_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 INfcTagDiscoveryEventListener_Reserved3(void) {}
+}; // INfcTagDiscoveryEventListener
+
+} } } // Tizen::Net::Nfc
+
+#endif // _FNET_NFC_INFC_TAG_DISCOVERY_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 FNetNfcITagConnectionListener.h
+ * @brief This is the header file for the %ITagConnectionListener interface.
+ *
+ * This header file contains the declarations of the %ITagConnectionListener interface.
+ */
+
+#ifndef _FNET_NFC_ITAG_CONNECTION_LISTENER_H_
+#define _FNET_NFC_ITAG_CONNECTION_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FBaseResult.h>
+
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+} }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+/**
+ * @interface ITagConnectionListener
+ * @brief This interface provides a listener for the events related to a tag connection.
+ *
+ * @since 2.0
+ *
+ * The %ITagConnectionListener interface provides methods that are used for creating notifications about the result of
+ * an action performed for TagConnection, such as sending a command.
+ *
+ * For more information on the class features, see
+ * <a href="../org.tizen.native.appprogramming/html/guide/net/nfc.htm">NFC Guide</a>.
+ */
+class _OSP_EXPORT_ ITagConnectionListener
+ : public Tizen::Base::Runtime::IEventListener
+{
+public:
+ /**
+ * This polymorphic destructor should be overridden if required. @n
+ * This way, the destructors of the derived classes are called when the destructor of this interface is called.
+ *
+ * @since 2.0
+ */
+ virtual ~ITagConnectionListener(void) {}
+
+ /**
+ * Called to notify the application when a response is received from a remote tag.
+ *
+ * @since 2.0
+ *
+ * @param[in] pResponse The response of the command as a Tizen::Base::ByteBuffer object, @n
+ * else @c null if it fails
+ * @param[in] r An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_ILLEGAL_ACCESS The sent command is denied by the target. @n
+ * The target tag is locked or protected for executing the command.
+ * @exception E_NOT_RESPONDING The target tag is not responding.
+ * @exception E_SYSTEM A system error has occurred.
+ * @remarks The input response (@c pResponse) must be deleted by the application to prevent memory leak.
+ * @see TagConnection::SendCommand()
+ */
+ virtual void OnNfcResponseReceivedN(Tizen::Base::ByteBuffer* pResponse, 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 ITagConnectionListener_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 ITagConnectionListener_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 ITagConnectionListener_Reserved3(void) {}
+}; // ITagConnectionListener
+
+} } } // Tizen::Net::Nfc
+
+#endif // _FNET_NFC_ITAG_CONNECTION_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 FNetNfcNdefMessage.h
+ * @brief This is the header file for the %NdefMessage class.
+ *
+ * This header file contains the declarations of the %NdefMessage class.
+ */
+
+#ifndef _FNET_NFC_NDEF_MESSAGE_H_
+#define _FNET_NFC_NDEF_MESSAGE_H_
+
+#include <FBaseObject.h>
+#include <FBaseResult.h>
+
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+class String;
+} }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+class _NdefMessageImpl;
+class NdefRecord;
+
+/**
+ * @class NdefMessage
+ * @brief This class represents an NDEF message.
+ *
+ * @since 2.0
+ *
+ * The %NdefMessage class represents an NDEF message. An NDEF message is composed of @c 1 or more NDEF records. Therefore,
+ * this class has NdefRecord instances and provides operations to manipulate the list of those instances. These
+ * operations are very similar to those of the Tizen::Base::Collection::IList class.
+ *
+ * If a new NDEF record is inserted, the uniqueness of its payload identifier is checked. This class also provides
+ * methods which convert %NdefMessage to Tizen::Base::ByteBuffer and vice versa.
+ *
+ * For more information on the class features, see
+ * <a href="../org.tizen.native.appprogramming/html/guide/net/nfc.htm">NFC Guide</a>.
+ */
+class _OSP_EXPORT_ NdefMessage
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.0
+ */
+ NdefMessage(void);
+
+ /**
+ * Copying of objects using this copy assignment operator is allowed.
+ *
+ * @since 2.0
+ *
+ * @param[in] value An instance of %NdefMessage to copy
+ * @remarks This method performs a deep copy.
+ */
+ NdefMessage(const NdefMessage& value);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~NdefMessage(void);
+
+ /**
+ * Compares the specified instance with the current instance.
+ *
+ * @since 2.0
+ *
+ * @return @c true if the specified instance of Tizen::Base::Object is equal to the current %NdefMessage instance, @n
+ * else @c false
+ * @param[in] obj The object to compare
+ * @remark Two %NdefMessage instances are equal only if they contain the same NdefRecord instances in the
+ * same order.
+ */
+ 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;
+
+ /**
+ * Gets the number of NDEF records in this NDEF message.
+ *
+ * @since 2.0
+ *
+ * @return The number of NDEF records
+ */
+ int GetRecordsCount(void) const;
+
+ /**
+ * Searches for an NdefRecord object in this class. @n
+ * Gets the index of the %NdefRecord object if the record is present.
+ *
+ * @since 2.0
+ *
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND The specified record is not found.
+ * @remarks This method verifies the equality of its pointers, but does not check the content of the specified
+ * record.
+ */
+ result IndexOf(const NdefRecord& record, int& index) const;
+
+ /**
+ * Gets the NdefRecord object from the specified location.
+ *
+ * @since 2.0
+ *
+ * @return The requested NdefRecord object, @n
+ * else @c null if the index is not valid
+ * @param[in] index The index of the NDEF record to get
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_RANGE Either of the following conditions has occurred:
+ * - The specified @c index is outside the bounds of the record list.
+ * - The specified @c index is either greater than or equal to the number of elements.
+ * - The specified @c index is less than @c 0.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ NdefRecord* GetRecordAt(int index) const;
+
+ /**
+ * Gets the NdefRecord object with the specified payload identifier.
+ *
+ * @since 2.0
+ *
+ * @return The requested NdefRecord object, @n
+ * else @c null if no record matches
+ * @param[in] payloadId The payload identifier of the NDEF record to get
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND The specified @c payloadId is not found in any of the NDEF records.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ NdefRecord* GetRecord(const Tizen::Base::String& payloadId) const;
+
+ /**
+ * Appends the specified NDEF record at the end of the last record in the NDEF message.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] record The NDEF record to append
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified NDEF record is invalid. @n
+ * For example, the record has the same payload identifier as the other records in
+ * this NDEF message.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @remarks This method performs a shallow copy. It adds just the pointer and not the NdefRecord instance.
+ */
+ result AppendRecord(const NdefRecord& record);
+
+ /**
+ * Inserts the specified NDEF record in the NDEF message at the specified location.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] record The NDEF record to insert
+ * @param[in] index The index at which the NDEF record is inserted
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_RANGE Either of the following conditions has occurred:
+ * - The specified @c index is outside the bounds of the record list.
+ * - The specified @c index is greater than the number of elements.
+ * - The specified @c index is less than @c 0.
+ * @exception E_INVALID_ARG The specified NDEF record is invalid. @n
+ * For example, the record has the same payload identifier as the other records in
+ * this NDEF message.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @remarks
+ * - The NDEF records that appear after the insertion point move downwards to accommodate the inserted
+ * NDEF record.
+ * - This method performs a shallow copy. It adds just the pointer and not the NdefRecord instance.
+ */
+ result InsertRecordAt(const NdefRecord& record, int index);
+
+ /**
+ * Replaces the NDEF record from the specified location with the specified NDEF record.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] record The NDEF record to set
+ * @param[in] index The index at which the NDEF record is set
+ * @param[in] deallocate Set to @c true to deallocate the replaced record, @n
+ * else @c false
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_RANGE Either of the following conditions has occurred:
+ * - The specified @c index is outside the bounds of the record list.
+ * - The specified @c index is either greater than or equal to the number of elements.
+ * - The specified @c index is less than @c 0.
+ * @exception E_INVALID_ARG The specified NDEF record is invalid. @n
+ * For example, the record has the same payload identifier as the other records in
+ * this NDEF message.
+ * @remarks This method performs a shallow copy. It adds just the pointer and not the NdefRecord instance.
+ */
+ result SetRecordAt(const NdefRecord& record, int index, bool deallocate = false);
+
+ /**
+ * Removes the NDEF record from the specified location.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] index The index from where the NDEF record is removed
+ * @param[in] deallocate Set to @c true to deallocate the record, @n
+ * else @c false
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_RANGE Either of the following conditions has occurred:
+ * - The specified @c index is outside the bounds of the record list.
+ * - The specified @c index is either greater than or equal to the number of elements.
+ * - The specified @c index is less than @c 0.
+ * @remarks The NDEF records that appear after the deletion point move upwards to occupy the vacated spot.
+ */
+ result RemoveRecordAt(int index, bool deallocate = false);
+
+ /**
+ * Removes all the records in the NDEF message. @n
+ * If the specified @c deallocate is set to @c true, it deallocates all the NdefRecord instances in the
+ * message.
+ *
+ * @since 2.0
+ *
+ * @param[in] deallocate Set to @c true to deallocate the record, @n
+ * else @c false
+ */
+ void RemoveAllRecords(bool deallocate = false);
+
+ /**
+ * Converts the entire NDEF message with all the NDEF records into a byte sequence as per the NDEF specification.
+ *
+ * @since 2.0
+ *
+ * @return The NDEF message as a Tizen::Base::ByteBuffer, @n
+ * else @c null if the conversion fails
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_DATA The specified NDEF message does not contain any NDEF records.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SYSTEM A system error has occurred.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ Tizen::Base::ByteBuffer* ToByteBufferN(void) const;
+
+ /**
+ * Gets a new instance of the NDEF message from the specified Tizen::Base::ByteBuffer.
+ *
+ * @since 2.0
+ *
+ * @return The instance of the created NDEF message, @n
+ * else @c null if the conversion fails
+ * @param[in] buffer The NDEF message as a byte sequence
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_FORMAT The specified @c buffer cannot be formulated to the NDEF message.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SYSTEM A system error has occurred.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ static NdefMessage* GetInstanceN(const Tizen::Base::ByteBuffer& buffer);
+
+ /**
+ * Assigns the value of a specified instance to the current instance of %NdefMessage.
+ *
+ * @since 2.0
+ *
+ * @return A reference to the %NdefMessage instance
+ * @param[in] rhs A reference to the %NdefMessage instance to copy
+ */
+ NdefMessage& operator =(const NdefMessage& rhs);
+
+private:
+ _NdefMessageImpl* __pImpl;
+
+ friend class _NdefMessageImpl;
+
+}; // NdefMessage
+
+} } } // Tizen::Net::Nfc
+
+#endif // _FNET_NFC_NDEF_MESSAGE_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.1 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// 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 FNetNfcNdefPushManager.h
+ * @brief This is the header file for the %NdefPushManager class.
+ *
+ * This header file contains the declarations of the %NdefPushManager class.
+ */
+#ifndef _FNET_NFC_NDEF_PUSH_MANAGER_H_
+#define _FNET_NFC_NDEF_PUSH_MANAGER_H_
+
+#include <FBaseObject.h>
+#include <FBaseResult.h>
+#include <FAppTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+} }
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IMap;
+}
+} }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+class INdefPushManagerListener;
+class NdefMessage;
+class _NdefPushManagerImpl;
+
+/**
+ * @class NdefPushManager
+ * @brief This class provides methods for pushing an NDEF message to a device.
+ *
+ * @since 2.0
+ *
+ * @final This class is not intended for extension.
+ *
+ * The %NdefPushManager class provides methods for pushing an NDEF message to a device.
+ *
+ * For more information on the class features, see
+ * <a href="../org.tizen.native.appprogramming/html/guide/net/nfc.htm">NFC Guide</a>.
+ *
+ * The following example demonstrates how to use the %NdefPushManager class.
+ *
+ * @code
+ * // MyClass.h
+ * #include <FNet.h>
+
+ * class MyClass
+ * : public Tizen::Net::Nfc::INfcManagerEventListener
+ * , public Tizen::Net::Nfc::INdefPushManagerListener
+ * , public Tizen::Net::Nfc::INfcDeviceDiscoveryEventListener
+ * {
+ * public:
+ * // The method declarations are hidden for the sake of simplicity
+ *
+ * private:
+ * Tizen::Net::Nfc::NfcManager* __pNfcManager;
+ * Tizen::Net::Nfc::NdefPushManager* __pNdefPushManager;
+ * };
+ *
+ * // MyClass.cpp
+ * #include "MyClass.h"
+ *
+ * using namespace Tizen::Net::Nfc;
+ *
+ * MyClass::MyClass(void)
+ * : __pNfcManager(null)
+ * , __pNdefPushManager(null)
+ * {
+ * __pNfcManager = new NfcManager();
+ * __pNdefPushManager = new NdefPushManager();
+ * }
+ *
+ * MyClass::~MyClass(void)
+ * {
+ * // Removes the device discovery event listener instance.
+ * __pNfcManager->RemoveDeviceDiscoveryEventListener(*this);
+ *
+ * delete __pNfcManager;
+ * delete __pNdefPushManager;
+ * }
+ *
+ * void
+ * MyClass::PushNdefMessageSample(void)
+ * {
+ * // Creates the NfcManager instance and registers the manager event listener
+ * __pNfcManager->Construct(*this);
+ *
+ * // Adds the device discovery event listener instance for the device discovery events.
+ * __pNfcManager->AddDeviceDiscoveryEventListener(*this);
+ *
+ * // Sets a listener for receiving the result of pushing an NDEF message.
+ * __pNdefPushManager->SetNdefPushManagerListener(this);
+ * }
+ *
+ * // This method is invoked when an NFC device is detected
+ * void
+ * MyClass::OnNfcDeviceDetected(void)
+ * {
+ * NdefMessage message;
+ * // Fills up the NdefMessage object here
+ *
+ * __pNdefPushManager->Push(message);
+ * }
+ *
+ * // This method is invoked when the NFC device is lost
+ * void
+ * MyClass::OnNfcDeviceLost(void)
+ * {
+ *
+ * }
+ *
+ * // This method is invoked when the push operation to the target device is completed.
+ * void
+ * MyClass::OnNdefPushMessageSent(result r)
+ * {
+ * if (r == E_SUCCESS)
+ * {
+ * // Pushing NdefMessage is successful
+ * }
+ * }
+ * @endcode
+ */
+class _OSP_EXPORT_ NdefPushManager
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.0
+ */
+ NdefPushManager(void);
+
+ /**
+ * This destructor overrides Object::~Object().
+ *
+ * @since 2.0
+ */
+ ~NdefPushManager(void);
+
+ /**
+ * Sets a listener for receiving the result of pushing an NDEF message.
+ *
+ * @since 2.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/nfc.p2p
+ * @feature %http://tizen.org/feature/network.nfc
+ *
+ * @return An error code
+ * @param[in] pListener An instance of INdefPushManagerListener @n
+ * If it is @c null, it resets the listener.
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_UNSUPPORTED_OPERATION The Emulator or target device does not support the required feature.
+ * For more information, see
+ * <a href="../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm">
+ * Application Filtering</a>.
+ * @exception E_OPERATION_FAILED The operation has failed.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_USER_NOT_CONSENTED The user has blocked the application from calling this method. @b Since: @b 2.1
+ * @remarks Before calling this method, check whether the feature is supported by
+ * Tizen::System::SystemInfo::GetValue(const Tizen::Base::String&, bool&).
+ */
+ result SetNdefPushManagerListener(INdefPushManagerListener* pListener);
+
+ /**
+ * Pushes the NDEF message.
+ *
+ * @since 2.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/nfc.p2p
+ * @feature %http://tizen.org/feature/network.nfc
+ *
+ * @return An error code
+ * @param[in] message The NDEF message to send
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_DEVICE_BUSY The device is processing a preceding job.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_INVALID_STATE This instance is in an invalid state. @n
+ * For example, the NFC feature is not activated or a peer device is not
+ * attached.
+ * @exception E_INVALID_ARG The specified @c message is invalid. @n
+ * For example, it does not contain any NDEF records.
+ * @exception E_UNSUPPORTED_OPERATION The Emulator or target device does not support the required feature.
+ * For more information, see
+ * <a href="../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm">
+ * Application Filtering</a>.
+ * @exception E_OPERATION_FAILED The operation has failed.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_USER_NOT_CONSENTED The user has blocked the application from calling this method. @b Since: @b 2.1
+ * @remarks Before calling this method, check whether the feature is supported by
+ * Tizen::System::SystemInfo::GetValue(const Tizen::Base::String&, bool&).
+ */
+ result Push(const NdefMessage& message);
+
+ /**
+ * Activates the Reserved Push feature that sends a preselected NDEF message to the connected NFC peer device on
+ * behalf of the application.
+ *
+ * @since 2.1
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/nfcmanager
+ * @feature %http://tizen.org/feature/network.nfc and %http://tizen.org/feature/network.nfc.reserved_push @n
+ * Both the features are required.
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n
+ * For example, Reserved Push is already activated.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_UNSUPPORTED_OPERATION The Emulator or target device does not support the required feature.
+ * For more information, see
+ * <a href="../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm">
+ * Application Filtering</a>.
+ * @exception E_SYSTEM The method cannot proceed due to a severe system error.
+ * @remarks Before calling this method, check whether the feature is supported by
+ * Tizen::System::SystemInfo::GetValue(const Tizen::Base::String&, bool&).
+ * @see <a href="../org.tizen.native.appprogramming/html/guide/net/nfc_reserved_push.htm">
+ * The NFC Reserved Push guide</a>
+ */
+ result ActivateReservedPush(void);
+
+ /**
+ * Deactivates the Reserved Push feature that sends a preselected NDEF message to the connected NFC peer device on
+ * behalf of the application.
+ *
+ * @since 2.1
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/nfcmanager
+ * @feature %http://tizen.org/feature/network.nfc and %http://tizen.org/feature/network.nfc.reserved_push @n
+ * Both the features are required.
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified
+ * operation. @n
+ * For example, Reserved Push is already deactivated.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_UNSUPPORTED_OPERATION The Emulator or target device does not support the required feature.
+ * For more information, see
+ * <a href="../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm">
+ * Application Filtering</a>.
+ * @exception E_SYSTEM The method cannot proceed due to a severe system error.
+ * @remarks Before calling this method, check whether the feature is supported by
+ * Tizen::System::SystemInfo::GetValue(const Tizen::Base::String&, bool&).
+ * @see <a href="../org.tizen.native.appprogramming/html/guide/net/nfc_reserved_push.htm">
+ * The NFC Reserved Push guide</a>
+ */
+ result DeactivateReservedPush(void);
+
+ /**
+ * Checks whether the Reserved Push feature is activated.
+ *
+ * @since 2.1
+ *
+ * @return @c true if Reserved Push is activated, @n
+ * else @c false
+ */
+ bool IsReservedPushActivated(void) const;
+
+ /**
+ * Gets the information of all the Reserved Push candidates. @n Each element of the result Tizen::Base::Collection::IMap consists of the package ID
+ * of the application that registered the NDEF message and the description about the registered NDEF message.
+ *
+ * @since 2.1
+ *
+ * @return A Tizen::Base::Collection::IMap that contains the package ID and message description pairs, @n
+ * else @c null if it fails
+ * @remarks The key of the returned Tizen::Base::Collection::IMap should be cast to the Tizen::App::PackageId pointer and the value should
+ * be cast to the Tizen::Base::String pointer.
+ */
+ Tizen::Base::Collection::IMap* GetReservedPushCandidatesN(void) const;
+
+ /**
+ * Picks out an NDEF message from all the Reserved Push candidates by the application ID. @n The selected NDEF message is
+ * pushed when a peer device is detected.
+ *
+ * @since 2.1
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/nfcmanager
+ * @feature %http://tizen.org/feature/network.nfc and %http://tizen.org/feature/network.nfc.reserved_push @n
+ * Both the features are required.
+ *
+ * @return An error code
+ * @param[in] packageId The package ID of the application that registered the NDEF message to push
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND The specified @c packageId is not found in the Reserved Push candidate list.
+ * @exception E_UNSUPPORTED_OPERATION The Emulator or target device does not support the required feature.
+ * For more information, see
+ * <a href="../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm">
+ * Application Filtering</a>.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_SYSTEM The method cannot proceed due to a severe system error.
+ *
+ * @remarks
+ * - Only one message can be selected to push. So the previously selected message is replaced
+ * by the new one.
+ * - Before calling this method, check whether the feature is supported by
+ * Tizen::System::SystemInfo::GetValue(const Tizen::Base::String&, bool&).
+ * @see <a href="../org.tizen.native.appprogramming/html/guide/net/nfc_reserved_push.htm">
+ * The NFC Reserved Push guide</a>
+ */
+ result PickReservedPushMessage(const Tizen::App::PackageId& packageId);
+
+ /**
+ * Gets the owner application ID of the picked NDEF message from all the Reserved Push candidates.
+ *
+ * @since 2.1
+ * @feature %http://tizen.org/feature/network.nfc and %http://tizen.org/feature/network.nfc.reserved_push @n
+ * Both the features are required.
+ *
+ * @return The package ID of the application which is the owner of the picked Reserved Push message, @n
+ * else an empty string if an error occurs
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND There is no element in the Reserved Push candidate list.
+ * @exception E_UNSUPPORTED_OPERATION The Emulator or target device does not support the required feature.
+ * For more information, see
+ * <a href="../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm">
+ * Application Filtering</a>.
+ * @exception E_SYSTEM The method cannot proceed due to a severe system error.
+ * @remarks
+ * - The specific error code can be accessed using the GetLastResult() method.
+ * - Before calling this method, check whether the feature is supported by
+ * Tizen::System::SystemInfo::GetValue(const Tizen::Base::String&, bool&).
+ * @see <a href="../org.tizen.native.appprogramming/html/guide/net/nfc_reserved_push.htm">
+ * The NFC Reserved Push guide</a>
+ */
+ Tizen::App::PackageId GetPickedReservedPushMessage(void) const;
+
+ /**
+ * Registers an NDEF message as a Reserved Push candidate. @n
+ * If the message is picked out from the candidates, it is pushed to the detected peer device when the home screen
+ * or the main menu is on top of the screen in the local device.
+ *
+ * @since 2.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/nfc.p2p
+ * @feature %http://tizen.org/feature/network.nfc and %http://tizen.org/feature/network.nfc.reserved_push @n
+ * Both the features are required.
+ *
+ * @return An error code
+ * @param[in] message The NDEF message to register
+ * @param[in] description The description for the NDEF message to register @n
+ * This description can be used in the Reserved Push UI, for example, the UI for
+ * getting the user's consent to send the registered message.
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c message is invalid. @n
+ * For example, it does not contain any NDEF records.
+ * @exception E_UNSUPPORTED_OPERATION The Emulator or target device does not support the required feature.
+ * For more information, see
+ * <a href="../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm">
+ * Application Filtering</a>.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_USER_NOT_CONSENTED The user has blocked the application from calling this method. @b Since: @b 2.1
+ * @exception E_SYSTEM The method cannot proceed due to a severe system error.
+ * @remarks
+ * - An application can register only one NDEF message. So the previously registered message is
+ * replaced by the new one.
+ * - The registered NDEF message is pushed only if it is selected by the user through the Setting
+ * application.
+ * - Before calling this method, check whether the feature is supported by
+ * Tizen::System::SystemInfo::GetValue(const Tizen::Base::String&, bool&).
+ * @see <a href="../org.tizen.native.appprogramming/html/guide/net/nfc_reserved_push.htm">
+ * The NFC Reserved Push guide</a>
+ */
+ static result RegisterNdefPushMessage(const NdefMessage& message, const Tizen::Base::String& description);
+
+ /**
+ * Unregisters an NDEF message from the Reserved Push candidates.
+ *
+ * @since 2.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/nfc.p2p
+ * @feature %http://tizen.org/feature/network.nfc and %http://tizen.org/feature/network.nfc.reserved_push @n
+ * Both the features are required.
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_UNSUPPORTED_OPERATION The Emulator or target device does not support the required feature.
+ * For more information, see
+ * <a href="../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm">
+ * Application Filtering</a>.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_USER_NOT_CONSENTED The user has blocked the application from calling this method. @b Since: @b 2.1
+ * @exception E_SYSTEM The method cannot proceed due to a severe system error.
+ * @remarks Before calling this method, check whether the feature is supported by
+ * Tizen::System::SystemInfo::GetValue(const Tizen::Base::String&, bool&).
+ * @see <a href="../org.tizen.native.appprogramming/html/guide/net/nfc_reserved_push.htm">
+ * The NFC Reserved Push guide</a>
+ */
+ static result UnregisterNdefPushMessage(void);
+
+private:
+ //
+ // The implementation of this copy constructor is intentionally blank to prohibit copying of objects.
+ //
+ NdefPushManager(const NdefPushManager& value);
+
+ //
+ // The implementation of this copy assignment operator is intentionally blank to prohibit copying of objects.
+ //
+ NdefPushManager& operator =(const NdefPushManager& value);
+
+private:
+ _NdefPushManagerImpl* __pImpl;
+
+ friend class _NdefPushManagerImpl;
+}; // NdefPushManager
+
+} } } // Tizen::Net::Nfc
+
+#endif // _FNET_NFC_NDEF_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 FNetNfcNdefRecord.h
+ * @brief This is the header file for the %NdefRecord class.
+ *
+ * This header file contains the declarations of the %NdefRecord class.
+ */
+
+#ifndef _FNET_NFC_NDEF_RECORD_H_
+#define _FNET_NFC_NDEF_RECORD_H_
+
+#include <FBaseObject.h>
+#include <FBaseResult.h>
+
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+class String;
+} }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+class _NdefRecordImpl;
+class NdefMessage;
+class NdefRecordType;
+
+/**
+ * @class NdefRecord
+ * @brief This class represents an NDEF record.
+ *
+ * @since 2.0
+ *
+ * The %NdefRecord class represents an NDEF record, including certain attributes such as the type, the payload, and the
+ * payload identifier. It provides operations to manipulate them. However, this class does not expose all the
+ * attributes of an NDEF record. Some attributes defined in the NDEF specification are hidden because they are not
+ * important for applications. @n
+ * The NDEF record may contain an NDEF message in the payload. It can be converted from a Tizen::Base::ByteBuffer
+ * instance to an NdefMessage instance through the NdefMessage::GetInstanceN() method.
+ *
+ * For more information on the class features, see
+ * <a href="../org.tizen.native.appprogramming/html/guide/net/nfc.htm">NFC Guide</a>.
+ */
+class _OSP_EXPORT_ NdefRecord
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * Initializes this instance of %NdefRecord with the specified parameter.
+ *
+ * @since 2.0
+ *
+ * @param[in] recordType The specified NDEF record type
+ */
+ NdefRecord(const NdefRecordType& recordType);
+
+ /**
+ * Copying of objects using this copy constructor is allowed.
+ *
+ * @since 2.0
+ *
+ * @param[in] value An instance of %NdefRecord to copy
+ * @remarks This method performs a deep copy.
+ */
+ NdefRecord(const NdefRecord& value);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~NdefRecord(void);
+
+ /**
+ * Compares the specified instance with the current instance.
+ *
+ * @since 2.0
+ *
+ * @return @c true if the specified instance of Tizen::Base::Object is equal to the current %NdefRecord instance, @n
+ * else @c false
+ * @param[in] obj The object to compare
+ * @remark Two %NdefRecord instances are equal only if they contain the same NdefRecordType instance,
+ * payload ID, and payload.
+ */
+ 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;
+
+ /**
+ * Gets the payload identifier for this NDEF record.
+ *
+ * @since 2.0
+ *
+ * @return The identifier of the payload, @n
+ * else an empty string if the identifier does not exist in the NDEF record
+ */
+ Tizen::Base::String GetPayloadId(void) const;
+
+ /**
+ * Gets the payload in this record as Tizen::Base::ByteBuffer.
+ *
+ * @since 2.0
+ *
+ * @return The payload, @n
+ * else @c null if the NDEF record does not have the payload
+ * @remarks If the payload is modified after it is fetched, the payload of this record also changes.
+ */
+ Tizen::Base::ByteBuffer* GetPayload(void) const;
+
+ /**
+ * Gets the record type of the NDEF record.
+ *
+ * @since 2.0
+ *
+ * @return The record type of the NDEF record
+ */
+ NdefRecordType GetRecordType(void) const;
+
+ /**
+ * Sets the record type of the NDEF record.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] type The record type to set
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified input parameter is invalid. @n
+ * For example, @c NDEF_TNF_EMPTY is not allowed as the input value if the identifier
+ * is not an empty string or the payload is not @c null.
+ */
+ result SetRecordType(NdefRecordType& type);
+
+ /**
+ * Sets the identifier of the payload.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] id The identifier of the payload
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_OPERATION This operation is not allowed if the type name format of this record is
+ * @c NDEF_TNF_EMPTY.
+ * @exception E_INVALID_ARG The specified identifier is not unique compared to the other records in
+ * the same NDEF message.
+ * @exception E_INVALID_ENCODING_RANGE The specified input string contains code points that are outside the
+ * bounds specified by the US_ASCII encoding scheme.
+ * @exception E_MAX_EXCEEDED The length of @c id exceeds @c 256 characters.
+ * @remarks The identifier is compared with other records only if this NDEF record is already included in an
+ * NDEF message.
+ */
+ result SetPayloadId(const Tizen::Base::String& id);
+
+ /**
+ * Sets the specified data in the payload of this NDEF record.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] payload The specified payload data
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_OPERATION This operation is not allowed if the type name format of this record is
+ * @c NDEF_TNF_EMPTY.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_INVALID_ARG The @c payload is invalid. @n
+ * For example, @c payload is not constructed.
+ * @remarks The view of the specified @c payload is copied and the data is shared. Therefore, if the
+ * data of @c payload is modified after setting, the data of the payload in this record also changes.
+ */
+ result SetPayload(const Tizen::Base::ByteBuffer& payload);
+
+ /**
+ * Assigns the value of the specified instance to the current instance of %NdefRecord.
+ *
+ * @since 2.0
+ *
+ * @return A reference to the %NdefRecord instance
+ * @param[in] rhs A reference to the %NdefRecord instance to copy
+ */
+ NdefRecord& operator =(const NdefRecord& rhs);
+
+private:
+ //
+ // This default constructor is intentionally declared as private so that only the platform can create an instance.
+ //
+ NdefRecord(void);
+
+private:
+ _NdefRecordImpl* __pImpl;
+
+ friend class _NdefRecordImpl;
+
+}; // NdefRecord
+
+} } } // Tizen::Net::Nfc
+
+#endif // _FNET_NFC_NDEF_RECORD_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 FNetNfcNdefRecordType.h
+ * @brief This is the header file for the %NdefRecordType class.
+ *
+ * This header file contains the declarations of the %NdefRecordType class.
+ */
+
+#ifndef _FNET_NFC_NDEF_RECORD_TYPE_H_
+#define _FNET_NFC_NDEF_RECORD_TYPE_H_
+
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FNetNfcNfcTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+} }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+class _NdefRecordTypeImpl;
+
+/**
+ * @if OSPDEPREC
+ * Defines the NDEF RTD Smart Poster type.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This object is provided only for backward compatibility and will be deleted in the near future.
+ * Use @c NFC_NDEF_RTD_SMART_POSTER instead of this object.
+ * @since 2.0
+ * @endif
+ */
+_OSP_EXPORT_ extern const Tizen::Base::String NDEF_RTD_SMART_POSTER;
+
+/**
+ * Defines the NDEF RTD Smart Poster type. ("Sp")
+ *
+ * @since 2.0
+ */
+_OSP_EXPORT_ extern const wchar_t NFC_NDEF_RTD_SMART_POSTER[];
+
+/**
+ * @if OSPDEPREC
+ * Defines the NDEF RTD %Text type.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This object is provided only for backward compatibility and will be deleted in the near future.
+ * Use @c NFC_NDEF_RTD_TEXT instead of this object.
+ * @since 2.0
+ * @endif
+ */
+_OSP_EXPORT_ extern const Tizen::Base::String NDEF_RTD_TEXT;
+
+/**
+ * Defines the NDEF RTD %Text type. ("T")
+ *
+ * @since 2.0
+ */
+_OSP_EXPORT_ extern const wchar_t NFC_NDEF_RTD_TEXT[];
+
+/**
+ * @if OSPDEPREC
+ * Defines the NDEF RTD URI type.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This object is provided only for backward compatibility and will be deleted in the near future.
+ * Use @c NFC_NDEF_RTD_URI instead of this object.
+ * @since 2.0
+ * @endif
+ */
+_OSP_EXPORT_ extern const Tizen::Base::String NDEF_RTD_URI;
+
+/**
+ * Defines the NDEF RTD URI type. ("U")
+ *
+ * @since 2.0
+ */
+_OSP_EXPORT_ extern const wchar_t NFC_NDEF_RTD_URI[];
+
+/**
+ * @class NdefRecordType
+ * @brief This class represents the type of an NDEF record.
+ *
+ * @since 2.0
+ *
+ * The %NdefRecordType class represents the type of an NDEF record. It encapsulates the name and the name format of an
+ * NDEF record type. @n
+ * The name format is represented by the enumeration type, Tizen::Net::Nfc::NdefRecordTypeNameFormat. The name is
+ * encoded using the US_ASCII character set and follows the rules defined by the NFC forum RTDs and RFCs. The name does
+ * not include the prefix @c "urn:nfc:wkt:" and @c "urn:nfc:ext:" defined by the NFC forum.
+ *
+ * For more information on the class features, see
+ * <a href="../org.tizen.native.appprogramming/html/guide/net/nfc.htm">NFC Guide</a>.
+ */
+
+class _OSP_EXPORT_ NdefRecordType
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * This is the default constructor for this class. @n
+ * Initializes this instance of %NdefRecordType with the specified parameter.
+ *
+ * @since 2.0
+ *
+ * @param[in] format The NDEF record type name format
+ */
+ NdefRecordType(NdefRecordTypeNameFormat format = NDEF_TNF_EMPTY);
+
+ /**
+ * Copying of objects using this copy constructor is allowed.
+ *
+ * @since 2.0
+ *
+ * @param[in] recordType An instance of %NdefRecordType to copy
+ */
+ NdefRecordType(const NdefRecordType& recordType);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~NdefRecordType(void);
+
+ /**
+ * Copying of objects using this copy assignment operator is allowed.
+ *
+ * @since 2.0
+ *
+ * @param[in] rhs An instance of %NdefRecordType to copy
+ */
+ NdefRecordType& operator =(const NdefRecordType& rhs);
+
+ /**
+ * Compares the specified instance of Tizen::Base::Object with the current instance of %NdefRecordType.
+ *
+ * @since 2.0
+ *
+ * @return @c true if the values match, @n
+ * else @c false
+ * @param[in] obj The Tizen::Base::Object to compare
+ * @remarks The method returns @c false if the specified object is not an %NdefRecordType instance. @n
+ * Additionally, the comparison rules for the record type name are different depending on the Type
+ * Name Format (TNF) value, as follows: @n
+ * <table border=1 cellpadding="1" cellspacing="1">
+ * <tr>
+ * <th>Type Name Format (TNF) value</th>
+ * <th>The comparison rule for the record type name</th>
+ * </tr>
+ * <tr>
+ * <td>NDEF_TNF_WELL_KNOWN</td>
+ * <td>Compares a name, character by character in a case-sensitive manner </td>
+ * </tr>
+ * <tr>
+ * <td>NDEF_TNF_MIME_MEDIA </td>
+ * <td>Compares a name, character by character in a case-insensitive manner until the first semi-colon (;)
+ * appears </td>
+ * </tr>
+ * <tr>
+ * <td>NDEF_TNF_ABSOLUTE_URI </td>
+ * <td>The reserved characters must be percent encoded and the hexadecimal digits are normalized to upper-case
+ * letters. The URI scheme and host parts of the URI must be normalized to lower case. After this, the URIs
+ * are compared character by character in a case-sensitive manner.</td>
+ * </tr>
+ * <tr>
+ * <td>NDEF_TNF_EXTERNAL </td>
+ * <td>Compares a name, character by character in a case-insensitive manner </td>
+ * </tr>
+ * <tr>
+ * <td>NDEF_TNF_EMPTY | NDEF_TNF_UNKNOWN </td>
+ * <td>Both record type names must be empty </td>
+ * </tr>
+ * </table>
+ */
+ 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
+ * @remarks The two equal %NdefRecordType instances return the same hash value.
+ */
+ virtual int GetHashCode(void) const;
+
+ /**
+ * Gets the name format of this record type.
+ *
+ * @since 2.0
+ *
+ * @return The name format of this record type
+ */
+ NdefRecordTypeNameFormat GetNameFormat(void) const;
+
+ /**
+ * Gets the name of this record type.
+ *
+ * @since 2.0
+ *
+ * @return The name of this record type, @n
+ * else an empty string if the name format is ::NDEF_TNF_EMPTY or ::NDEF_TNF_UNKNOWN
+ * @remarks
+ * - The name does not have the prefix @c "urn:nfc:wkt:" and @c "urn:nfc:ext:" defined by the
+ * NFC forum.
+ * - In case of ::NDEF_TNF_ABSOLUTE_URI name format, this method returns the name in the same format as
+ * it is given in the constructor, that is, with or without percent encoding.
+ * - The name consists of the characters encoded using the US_ASCII character set.
+ */
+ Tizen::Base::String GetName(void) const;
+
+ /**
+ * Sets the name of this record type.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] name The name of this record type @n
+ * The input name must not have the prefix defined by the NFC forum such as @c "urn:nfc:wkt:" and
+ * @c "urn:nfc:ext:".
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_OPERATION This operation is not allowed if the name format is ::NDEF_TNF_EMPTY,
+ * ::NDEF_TNF_UNKNOWN, or ::NDEF_TNF_ALL.
+ * @exception E_INVALID_ENCODING_RANGE The specified input string contains the code points that are outside
+ * the bounds specified by the US_ASCII encoding scheme.
+ * @exception E_INVALID_FORMAT The specified format of the @c name is invalid as per the
+ * specifications defined for each type of the name format.
+ * @exception E_MAX_EXCEEDED The length of the name exceeds @c 256 characters.
+ */
+ result SetName(const Tizen::Base::String& name);
+
+private:
+ _NdefRecordTypeImpl* __pImpl;
+
+ friend class _NdefRecordTypeImpl;
+
+}; // NdefRecordType
+
+} } } // Tizen::Net::Nfc
+
+#endif // _FNET_NFC_NDEF_RECORD_TYPE_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 FNetNfcNdefTagConnection.h
+ * @brief This is the header file for the %NdefTagConnection class.
+ *
+ * This header file contains the declarations of the %NdefTagConnection class.
+ */
+
+#ifndef _FNET_NFC_NDEF_TAG_CONNECTION_H_
+#define _FNET_NFC_NDEF_TAG_CONNECTION_H_
+
+#include <FBaseResult.h>
+#include <FNetNfcTagConnection.h>
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+class _NdefTagConnectionImpl;
+class NdefMessage;
+class INdefTagConnectionListener;
+
+/**
+ * @class NdefTagConnection
+ * @brief This class represents the connection with an NFC tag that has NDEF data.
+ *
+ * @since 2.0
+ *
+ * The %NdefTagConnection class provides the mechanism to communicate with a tag that has NFC Data Exchange Format
+ * (NDEF) data and supports NDEF message operations. @n
+ * This class can be derived from the TagConnection class. Use the IsNdefConnection() method to check the availability
+ * of the derivation. @n
+ * Use the Read() and Write() methods to read and write the NDEF data. After the completion of the read and write
+ * operations, the response is received by the INdefTagConnectionListener::OnNdefReadCompletedN() and
+ * INdefTagConnectionListener::OnNdefWriteCompleted() event handlers, respectively.
+ *
+ * For more information on the class features, see
+ * <a href="../org.tizen.native.appprogramming/html/guide/net/nfc.htm">NFC Guide</a>.
+ *
+ * The following example demonstrates how to use the %NdefTagConnection class.
+ * @code
+ * // MyClass.h
+ * #include <FNet.h>
+ *
+ * class MyClass
+ * : public Tizen::Net::Nfc::INfcManagerEventListener
+ * , public Tizen::Net::Nfc::INfcTagDiscoveryEventListener
+ * , public Tizen::Net::Nfc::INdefTagConnectionListener
+ * {
+ * public:
+ * void WriteNdefMessageSample(void);
+ * virtual void OnNfcTagDetectedN(Tizen::Net::Nfc::TagConnection* pConnection);
+ * virtual void OnNfcTagLost(void);
+ * virtual void OnNdefWriteCompleted(result r);
+ * // Other methods are hidden for the sake of simplicity.
+ *
+ * private:
+ * Tizen::Net::Nfc::NfcManager* __pNfcManager;
+ * Tizen::Net::Nfc::NdefTagConnection* __pNdefConnection;
+ * };
+ *
+ * // MyClass.cpp
+ * #include "MyClass.h"
+ *
+ * using namespace Tizen::Net::Nfc;
+ *
+ * MyClass::MyClass(void)
+ * : __pNfcManager(null)
+ * , __pNdefConnection(null)
+ * {
+ * __pNfcManager = new NfcManager();
+ * }
+ *
+ * MyClass::~MyClass(void)
+ * {
+ * // Removes the tag discovery event listener for all the NDEF tag types
+ * __pNfcManager->RemoveTagDiscoveryEventListener(*this, NFC_TAG_TYPE_ALL_NDEF_COMPATIBLE);
+ *
+ * delete __pNfcManager;
+ * }
+ *
+ * void
+ * MyClass::WriteNdefMessageSample(void)
+ * {
+ * // Creates NfcManager instance and registers the manager event listener
+ * __pNfcManager->Construct(*this);
+ *
+ * // Adds the tag discovery event listener for all the NDEF tag types
+ * __pNfcManager->AddTagDiscoveryEventListener(*this, NFC_TAG_TYPE_ALL_NDEF_COMPATIBLE);
+ * }
+ *
+ * // This method is invoked when a new NDEF tag is detected
+ * void
+ * MyClass::OnNfcTagDetectedN(TagConnection* pConnection)
+ * {
+ * // Checks whether the connection supports NDEF operations,
+ * // but the evaluation result of the below code is always true in this example
+ * if (pConnection->IsNdefConnection())
+ * {
+ * __pNdefConnection = dynamic_cast<NdefTagConnection*>(pConnection);
+ *
+ * // Registers the NDEF tag connection listener
+ * __pNdefConnection->SetNdefTagConnectionListener(this);
+ *
+ * NdefMessage message;
+ * // Fills up the NdefMessage object here
+ *
+ * __pNdefConnection->Write(message);
+ * }
+ * }
+ *
+ * // This method is invoked when the target tag is lost
+ * void
+ * MyClass::OnNfcTagLost(void)
+ * {
+ * // The acquired NdefTagConnection should be deallocated
+ * delete __pNdefConnection;
+ * }
+ *
+ * // This method is invoked when the write request is completed
+ * void
+ * MyClass::OnNdefWriteCompleted(result r)
+ * {
+ * if (r == E_SUCCESS)
+ * {
+ * // Writing NdefMessage is successful
+ * }
+ * }
+ * @endcode
+ */
+class _OSP_EXPORT_ NdefTagConnection
+ : public TagConnection
+{
+public:
+ /**
+ * Checks whether the connection supports the NDEF message operations.
+ *
+ * @since 2.0
+ *
+ * @return @c true if the connection supports the NDEF message operations, @n
+ * else @c false
+ */
+ virtual bool IsNdefConnection(void) const;
+
+ /**
+ * Sets a listener for receiving the result of reading or writing on this NDEF tag connection.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] pListener The listener to add
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM A system error has occurred.
+ * @remarks At the most, one event listener can be registered. If the input parameter is @c null, the listener
+ * that is currently registered gets unregistered.
+ */
+ result SetNdefTagConnectionListener(INdefTagConnectionListener* pListener);
+
+ /**
+ * Reads the NDEF data from the NDEF tag.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_IN_PROGRESS The read process is in progress.
+ * @exception E_CONNECTION_BUSY The connection is busy. Therefore, the method cannot process the read request.
+ * @exception E_CONNECTION_FAILED The connection to the tag has closed or has failed.
+ * @exception E_SYSTEM A system error has occurred.
+ * @see INdefTagConnectionListener::OnNdefReadCompletedN()
+ */
+ result Read(void);
+
+ /**
+ * Writes the NDEF data to the NDEF tag.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] message The NDEF message to write to the target
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c message is invalid. @n
+ * For example, it does not contain any NDEF records.
+ * @exception E_IN_PROGRESS The write process is in progress.
+ * @exception E_CONNECTION_BUSY The connection is busy. Therefore, the method cannot process the write request.
+ * @exception E_CONNECTION_FAILED The connection to the tag has closed or has failed.
+ * @exception E_SYSTEM A system error has occurred.
+ * @see INdefTagConnectionListener::OnNdefWriteCompleted()
+ */
+ result Write(const NdefMessage& message);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~NdefTagConnection(void);
+
+private:
+ //
+ // This default constructor is intentionally declared as private so that only the platform can create an instance.
+ //
+ NdefTagConnection(void);
+
+ //
+ // The implementation of this copy constructor is intentionally blank to prohibit copying of objects.
+ //
+ NdefTagConnection(const NdefTagConnection& value);
+
+ //
+ // The implementation of this copy assignment operator is intentionally blank to prohibit copying of objects.
+ //
+ NdefTagConnection& operator =(const NdefTagConnection& value);
+
+private:
+ _NdefTagConnectionImpl* __pNdefImpl;
+
+ friend class _TagConnectionImpl;
+ friend class _NdefTagConnectionImpl;
+
+}; // NdefTagConnection
+
+} } } // Tizen::Net::Nfc
+
+#endif // _FNET_NFC_NDEF_TAG_CONNECTION_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 FNetNfcNfcManager.h
+ * @brief This is the header file for the %NfcManager class.
+ *
+ * This header file contains the declarations of the %NfcManager class.
+ */
+#ifndef _FNET_NFC_NFC_MANAGER_H_
+#define _FNET_NFC_NFC_MANAGER_H_
+
+#include <FBaseObject.h>
+#include <FBaseResult.h>
+#include <FNetNfcNfcTypes.h>
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+class INfcManagerEventListener;
+class INfcTransactionEventListener;
+class INfcTagDiscoveryEventListener;
+class INdefMessageDiscoveryEventListener;
+class INfcDeviceDiscoveryEventListener;
+class NdefMessage;
+class NdefRecordType;
+class TagConnection;
+class _NfcManagerImpl;
+
+/**
+ * @class NfcManager
+ * @brief This is the manager class for the NFC features.
+ *
+ * @since 2.0
+ *
+ * The %NfcManager class is the manager class for the NFC features that include methods for enabling and disabling the
+ * NFC feature of a device and the mechanism for establishing a connection with the detected tag. It is also used to
+ * detect NFC tags and NDEF messages. @n
+ * There are two ways to get the TagConnection instance established with the detected tag. @n
+ * @li Use the INfcTagDiscoveryEventListener::OnNfcTagDetectedN() method that is invoked immediately when the target
+ * tag is detected.
+ * @li Invoke the GetCurrentTagConnectionN() method after the tag is detected.
+ *
+ * If the target tag is lost, the INfcTagDiscoveryEventListener::OnNfcTagLost() method is called and the old
+ * %TagConnection instance becomes invalid. Therefore, the operations performed by the %TagConnection class are not
+ * processed anymore. Moreover, the %TagConnection instance cannot be used again even if the same tags are detected
+ * again by the device.
+ *
+ * For more information on the class features, see
+ * <a href="../org.tizen.native.appprogramming/html/guide/net/nfc.htm">NFC Guide</a>.
+ *
+ * The following example demonstrates how to use the %NfcManager class.
+ *
+ * @code
+ * // MyClass.h
+ * #include <FNet.h>
+ *
+ * class MyClass
+ * : public Tizen::Net::Nfc::INfcManagerEventListener
+ * , public Tizen::Net::Nfc::INfcTagDiscoveryEventListener
+ * , public Tizen::Net::Nfc::INdefMessageDiscoveryEventListener
+ * {
+ * public:
+ * // The method declarations are hidden for the sake of simplicity
+ *
+ * private:
+ * Tizen::Net::Nfc::NfcManager* __pNfcManager;
+ * Tizen::Net::Nfc::TagConnection* __pConnection;
+ * };
+ *
+ * // MyClass.cpp
+ * #include "MyClass.h"
+ *
+ * using namespace Tizen::Net::Nfc;
+ *
+ * MyClass::MyClass(void)
+ * : __pNfcManager(null)
+ * , __pConnection(null)
+ * {
+ * __pNfcManager = new NfcManager();
+ * }
+ *
+ * MyClass::~MyClass(void)
+ * {
+ * // Removes the tag discovery event listener for all the NFC tag types
+ * __pNfcManager->RemoveTagDiscoveryEventListener(*this, NFC_TAG_TYPE_ALL);
+ * // Removes the NDEF message discovery event listener for all the TNF types
+ * __pNfcManager->RemoveNdefMessageDiscoveryEventListener(*this, NdefRecordType(NDEF_TNF_ALL));
+ *
+ * delete __pNfcManager;
+ * }
+ *
+ * void
+ * MyClass::DiscoverySample(void)
+ * {
+ * // Creates the NfcManager instance and registers the manager event listener
+ * __pNfcManager->Construct(*this);
+ *
+ * if (__pNfcManager->IsTagConnected())
+ * {
+ * // This is the way to get the connection already established with the detected tag
+ * __pConnection = __pNfcManager->GetCurrentTagConnectionN();
+ *
+ * // Performs connection operations here
+ * }
+ *
+ * // Adds the tag discovery event listener for all the NFC tag types
+ * // This is the method to establish the connection with tags that are detected hereafter
+ * __pNfcManager->AddTagDiscoveryEventListener(*this, NFC_TAG_TYPE_ALL);
+ *
+ * // Adds the NDEF message discovery event listener for all the TNF types
+ * // This is the method to get NDEF messages that are detected hereafter
+ * __pNfcManager->AddNdefMessageDiscoveryEventListener(*this, NdefRecordType(NDEF_TNF_ALL));
+ * }
+ *
+ * // This method is invoked when a new tag is detected
+ * void
+ * MyClass::OnNfcTagDetectedN(TagConnection* pConnection)
+ * {
+ * __pConnection = pConnection;
+ *
+ * // Performs connection operations here
+ * }
+ *
+ * // This method is invoked when the target tag is lost
+ * void
+ * MyClass::OnNfcTagLost(void)
+ * {
+ * // The acquired TagConnection should be deallocated
+ * delete __pConnection;
+ * }
+ *
+ * // This method is invoked when a new NDEF message is detected
+ * void
+ * MyClass::OnNdefMessageDetectedN(NdefMessage* pMessage)
+ * {
+ * // Manipulates the received message here
+ *
+ * // Deallocates the received NdefMessage
+ * pMessage->RemoveAllRecords(true);
+ * delete pMessage;
+ * }
+ * @endcode
+ */
+class _OSP_EXPORT_ NfcManager
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * The object is not fully constructed after this constructor is called. @n
+ * For full construction, the Construct() method must be called right after calling this constructor.
+ *
+ * @since 2.0
+ */
+ NfcManager(void);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~NfcManager(void);
+
+ /**
+ * Initializes this instance of %NfcManager with the specified @c listener.
+ *
+ * @since 2.0
+ * @feature %http://tizen.org/feature/network.nfc
+ *
+ * @return An error code
+ * @param[in] listener The INfcManagerEventListener instance to add
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_UNSUPPORTED_OPERATION The Emulator or target device does not support the required feature.
+ * For more information, see
+ * <a href="../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm">
+ * Application Filtering</a>.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SYSTEM A system error has occurred.
+ * @remarks Before calling this method, check whether the feature is supported by
+ * Tizen::System::SystemInfo::GetValue(const Tizen::Base::String&, bool&).
+ */
+ result Construct(INfcManagerEventListener& listener);
+
+ /**
+ * Activates the NFC feature of the device.
+ *
+ * @since 2.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/nfc.admin
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_IN_PROGRESS The activation process is in progress.
+ * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified
+ * operation. @n
+ * For example, the NFC feature is already activated.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_USER_NOT_CONSENTED The user has blocked the application from calling this method. @b Since: @b 2.1
+ * @exception E_SYSTEM A system error has occurred.
+ * @see INfcManagerEventListener::OnNfcActivated()
+ */
+ result Activate(void);
+
+ /**
+ * Deactivates the NFC feature of the device.
+ *
+ * @since 2.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/nfc.admin
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_IN_PROGRESS The deactivation process is in progress.
+ * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified
+ * operation. @n
+ * For example, the NFC feature is already deactivated.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_USER_NOT_CONSENTED The user has blocked the application from calling this method. @b Since: @b 2.1
+ * @exception E_SYSTEM A system error has occurred.
+ * @see INfcManagerEventListener::OnNfcDeactivated()
+ */
+ result Deactivate(void);
+
+ /**
+ * Checks whether the NFC feature is activated.
+ *
+ * @since 2.0
+ *
+ * @return @c true if the NFC feature is activated, @n
+ * else @c false
+ */
+ bool IsActivated(void) const;
+
+ /**
+ * Checks whether an NFC tag is currently connected to the device.
+ *
+ * @since 2.0
+ *
+ * @return @c true if the NFC tag is currently connected, @n
+ * else @c false
+ */
+ bool IsTagConnected(void) const;
+
+ /**
+ * Gets a tag connection with the currently detected tag.
+ *
+ * @since 2.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/nfc.tag
+ *
+ * @return The tag connection with the currently detected tag, @n
+ * else @c null if no tag is connected or the connection fails
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_STATE This instance is in an invalid state. @n
+ * For example, this instance has not been constructed as yet or the NFC
+ * feature is not activated.
+ * @exception E_CONNECTION_FAILED The connection to the tag has closed or has failed.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_USER_NOT_CONSENTED The user has blocked the application from calling this method. @b Since: @b 2.1
+ * @exception E_SYSTEM A system error has occurred.
+ * @remarks
+ * - The NdefTagConnection class can inherit the TagConnection class if the currently detected tag
+ * supports NDEF operations. To check whether the %TagConnection class is inherited, use the
+ * TagConnection::IsNdefConnection() method.
+ * - The specific error code can be accessed using the GetLastResult() method.
+ */
+ TagConnection* GetCurrentTagConnectionN(void) const;
+
+ /**
+ * Adds the specified INfcTagDiscoveryEventListener instance for the tag events with the specified tag type.
+ *
+ * @since 2.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/nfc.tag
+ *
+ * @return An error code
+ * @param[in] listener The listener to add
+ * @param[in] type The tag type for which the listener is added
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_ALREADY_EXIST The listener with the specified type is already added.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_USER_NOT_CONSENTED The user has blocked the application from calling this method. @b Since: @b 2.1
+ * @exception E_SYSTEM A system error has occurred.
+ * @remarks This method can be invoked several times with different Tizen::Net::Nfc::NfcTagType values for the
+ * same listener instance. In this case, the listener is called if the specified type of the target
+ * tag matches with any one of the registered type.
+ */
+ result AddTagDiscoveryEventListener(INfcTagDiscoveryEventListener& listener, NfcTagType type);
+
+ /**
+ * Removes the specified INfcTagDiscoveryEventListener instance. @n
+ * The removed listener cannot listen to the events that are fired.
+ *
+ * @since 2.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/nfc.tag
+ *
+ * @return An error code
+ * @param[in] listener The listener to remove
+ * @param[in] type The tag type for which the listener is removed
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND The listener with the specified type is not found.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_USER_NOT_CONSENTED The user has blocked the application from calling this method. @b Since: @b 2.1
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ result RemoveTagDiscoveryEventListener(INfcTagDiscoveryEventListener& listener, NfcTagType type);
+
+ /**
+ * Adds the specified INdefMessageDiscoveryEventListener instance for the events related to an NDEF message that
+ * includes the NDEF record with the specified type.
+ *
+ * @since 2.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/nfc.common
+ *
+ * @return An error code
+ * @param[in] listener The listener to add
+ * @param[in] type The type of the NDEF record for which the listener is added
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c type is invalid. @n
+ * For example, the name of the record type is an empty string if the name
+ * format is ::NDEF_TNF_WELL_KNOWN, ::NDEF_TNF_MIME_MEDIA, ::NDEF_TNF_ABSOLUTE_URI,
+ * or ::NDEF_TNF_EXTERNAL.
+ * @exception E_OBJ_ALREADY_EXIST The listener with the specified @c type is already added.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_USER_NOT_CONSENTED The user has blocked the application from calling this method. @b Since: @b 2.1
+ * @exception E_SYSTEM A system error has occurred.
+ * @remarks
+ * - This method can be invoked several times with different NdefRecordType values for the same
+ * listener instance. In this case, the listener is called if the record type in the detected NDEF
+ * records matches with one of the registered types.
+ * - In case of a MIME %Media type such as Type Name Format (TNF), asterisks can be used in the type name
+ * for wildcard matching, such as @htmlonly "image/*" @endhtmlonly.
+ */
+ result AddNdefMessageDiscoveryEventListener(INdefMessageDiscoveryEventListener& listener, const NdefRecordType& type);
+
+ /**
+ * Removes the specified INdefMessageDiscoveryEventListener instance. @n
+ * The removed listener cannot listen to the events that are fired.
+ *
+ * @since 2.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/nfc.common
+ *
+ * @return An error code
+ * @param[in] listener The listener to remove
+ * @param[in] type The type of the NDEF record for which the listener is removed
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c type is invalid. @n
+ * For example, the name of the record type is an empty string if the name
+ * format is ::NDEF_TNF_WELL_KNOWN, ::NDEF_TNF_MIME_MEDIA, ::NDEF_TNF_ABSOLUTE_URI,
+ * or ::NDEF_TNF_EXTERNAL.
+ * @exception E_OBJ_NOT_FOUND The listener with the specified @c type is not found.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_USER_NOT_CONSENTED The user has blocked the application from calling this method. @b Since: @b 2.1
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ result RemoveNdefMessageDiscoveryEventListener(INdefMessageDiscoveryEventListener& listener, const NdefRecordType& type);
+
+ /**
+ * Adds the specified INfcDeviceDiscoveryEventListener instance for the device discovery events.
+ *
+ * @since 2.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/nfc.p2p
+ *
+ * @return An error code
+ * @param[in] listener The listener to add
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_ALREADY_EXIST The listener has already been added.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_USER_NOT_CONSENTED The user has blocked the application from calling this method. @b Since: @b 2.1
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ result AddDeviceDiscoveryEventListener(INfcDeviceDiscoveryEventListener& listener);
+
+ /**
+ * Removes the specified INfcDeviceDiscoveryEventListener instance. @n
+ * The removed listener cannot listen to the events that are fired.
+ *
+ * @since 2.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/nfc.p2p
+ *
+ * @return An error code
+ * @param[in] listener The listener to remove
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND The listener is not found.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_USER_NOT_CONSENTED The user has blocked the application from calling this method. @b Since: @b 2.1
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ result RemoveDeviceDiscoveryEventListener(INfcDeviceDiscoveryEventListener& listener);
+
+ /**
+ * Checks whether a peer device has been detected.
+ *
+ * @since 2.0
+ *
+ * @return @c true if a peer device has been detected, @n
+ * else @c false
+ */
+ bool IsDeviceDetected(void) const;
+
+
+ /**
+ * Gets the cached NDEF message when the tag is detected.
+ *
+ * @since 2.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/nfc.common
+ * @feature %http://tizen.org/feature/network.nfc
+ *
+ * @return The cached NdefMessage instance, @n
+ * else @c null if it fails
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_UNSUPPORTED_OPERATION The Emulator or target device does not support the required feature.
+ * For more information, see
+ * <a href="../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm">
+ * Application Filtering</a>.
+ * @exception E_ILLEGAL_ACCESS This operation is not allowed. @n
+ * This exception is currently not in use.
+ * @exception E_INVALID_FORMAT The cached data cannot be converted to the NDEF message.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_USER_NOT_CONSENTED The user has blocked the application from calling this method. @b Since: @b 2.1
+ * @exception E_SYSTEM A system error has occurred.
+ * @remarks
+ * - The input NdefMessage instance should be deleted by the application after it is used, even
+ * outside this method. The NdefMessage::RemoveAllRecords() method should be called with @c true as
+ * the input value immediately before the %NdefMessage instance is deleted.
+ * - The specific error code can be accessed using the GetLastResult() method.
+ * - Before calling this method, check whether the feature is supported by
+ * Tizen::System::SystemInfo::GetValue(const Tizen::Base::String&, bool&).
+ * @see <a href="../org.tizen.native.appprogramming/html/guide/net/conditional_nfc_app_launch.htm">
+ * The Conditional NFC App Launch guide</a>
+ * @see Tizen::App::AppManager::RegisterAppLaunch()
+ */
+ static NdefMessage* GetCachedNdefMessageN(void);
+
+ /**
+ * Enables or disables the Conditional NFC %App Launch pop-up. @n
+ * The pop-up includes all kinds of UI components that the system raises about NFC as well as a pop-up for
+ * selecting the launching application when a tag is detected.
+ *
+ * @since 2.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/nfc.common
+ * @feature %http://tizen.org/feature/network.nfc
+ *
+ * @return An error code
+ * @param[in] enable Set to @c true to enable the Conditional NFC %App Launch pop-up, @n
+ * else @c false
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_UNSUPPORTED_OPERATION The Emulator or target device does not support the required feature.
+ * For more information, see
+ * <a href="../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm">
+ * Application Filtering</a>.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_USER_NOT_CONSENTED The user has blocked the application from calling this method. @b Since: @b 2.1
+ * @exception E_SYSTEM A system error has occurred.
+ * @remarks
+ * - Note that this method is used to enable or disable the launch pop-up when the application is in
+ * the foreground. Although the application disables the launch pop-up by invoking this method, it
+ * is automatically enabled when the application goes to the background. The launch pop-up is
+ * enabled by default.
+ * - Before calling this method, check whether the feature is supported by
+ * Tizen::System::SystemInfo::GetValue(const Tizen::Base::String&, bool&).
+ * @see <a href="../org.tizen.native.appprogramming/html/guide/net/conditional_nfc_app_launch.htm">
+ * The Conditional NFC App Launch guide</a>
+ */
+ static result SetLaunchPopupEnabled(bool enable);
+
+private:
+ //
+ // The implementation of this copy constructor is intentionally blank to prohibit copying of objects.
+ //
+ NfcManager(const NfcManager& value);
+
+ //
+ // The implementation of this copy assignment operator is intentionally blank to prohibit copying of objects.
+ //
+ NfcManager& operator =(const NfcManager& value);
+
+private:
+ _NfcManagerImpl* __pImpl;
+
+ friend class _NfcManagerImpl;
+}; // NfcManager
+
+} } } // Tizen::Net::Nfc
+
+#endif // _FNET_NFC_NFC_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 FNetNfcNfcTag.h
+ * @brief This is the header file for the %NfcTag class.
+ *
+ * This header file contains the declarations of the %NfcTag class.
+ */
+
+#ifndef _FNET_NFC_NFC_TAG_H_
+#define _FNET_NFC_NFC_TAG_H_
+
+#include <FBaseObject.h>
+#include <FBaseResult.h>
+#include <FNetNfcNfcTypes.h>
+
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+namespace Collection
+{
+template<class Type> class IListT;
+}
+} }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+class _NfcTagImpl;
+
+/**
+ * @class NfcTag
+ * @brief This class represents an NFC target tag.
+ *
+ * @since 2.0
+ *
+ * The %NfcTag class provides information about a detected NFC tag. @n
+ * This class has multiple tag types for the target tag. For example, the GetTagTypeList() method returns a list of tag
+ * types that include ::NFC_TAG_TYPE_MIFARE_UL and ::NFC_TAG_TYPE_FORUM_TYPE_2, because the tag is a Mifare Ultralight tag
+ * and it is also an NFC Forum tag type 2.
+ *
+ * For more information on the class features, see
+ * <a href="../org.tizen.native.appprogramming/html/guide/net/nfc.htm">NFC Guide</a>.
+ */
+class _OSP_EXPORT_ NfcTag
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * Gets the list of tag types.
+ *
+ * @since 2.0
+ *
+ * @return The list of tag types @n
+ * The return list includes single or multiple tags. For example, if the target tag is Mifare
+ * Ultralight tag type and the NFC Forum tag 2 type, the list includes @c NFC_TAG_TYPE_MIFARE_UL and
+ * @c NFC_TAG_TYPE_FORUM_TYPE_2.
+ */
+ const Tizen::Base::Collection::IListT <NfcTagType>* GetTagTypeList(void) const;
+
+ /**
+ * Checks whether a tag has the specified tag type.
+ *
+ * @since 2.0
+ *
+ * @return @c true if the tag has the specified tag type, @n
+ * else @c false
+ * @param[in] type The tag type to check
+ */
+ bool HasTagType(NfcTagType type) const;
+
+ /**
+ * Gets the ID of a tag.
+ *
+ * @since 2.0
+ *
+ * @return The ID of the tag, @n
+ * else @c null if the tag has no ID
+ * @remarks Most tags have a unique ID (UID) or a random ID (RID) that is generated every time they are
+ * discovered. Some tags, however, do not have any ID.
+ */
+ const Tizen::Base::ByteBuffer* GetId(void) const;
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~NfcTag(void);
+
+private:
+ //
+ // This default constructor is intentionally declared as private so that only the platform can create an instance.
+ //
+ NfcTag(void);
+
+ //
+ // The implementation of this copy constructor is intentionally blank to prohibit copying of objects.
+ //
+ NfcTag(const NfcTag& value);
+
+ //
+ // The implementation of this copy assignment operator is intentionally blank to prohibit copying of objects.
+ //
+ NfcTag& operator =(const NfcTag& value);
+
+private:
+ _NfcTagImpl* __pImpl;
+
+ friend class _NfcTagImpl;
+
+}; // NfcTag
+
+} } } // Tizen::Net::Nfc
+
+#endif // _FNET_NFC_NFC_TAG_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 FNetNfcNfcTypes.h
+* @brief This is the header file for defining types in the %Nfc namespace.
+*
+* This header file contains the definition of common types and enumerators for the NFC features.
+*/
+#ifndef _FNET_NFC_NFC_TYPES_H_
+#define _FNET_NFC_NFC_TYPES_H_
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+/**
+ * @enum NfcTagType
+ *
+ * Defines the types of NFC tags.
+ *
+ * @since 2.0
+ */
+enum NfcTagType
+{
+ NFC_TAG_TYPE_UNKNOWN = 0x00, /**< The unknown tag type
+ * @remarks This type should not be used for event filtering
+ * purposes as the input argument of
+ * NfcManager::AddTagDiscoveryEventListener().
+ */
+ NFC_TAG_TYPE_ISO14443_3A, /**< The ISO14443 Part 3A tag type @n
+ * For example, the Mifare UL, the Mifare Classic, and the Mifare DESFire
+ * tags belong to this type.
+ */
+ NFC_TAG_TYPE_ISO14443_3B, /**< The ISO14443 Part 3B tag type @n
+ * For example, the Picopass 2K/32K tags belong to this type.
+ */
+ NFC_TAG_TYPE_FELICA, /**< The FeliCa tag type */
+ NFC_TAG_TYPE_ISO15693, /**< The ISO15693 general RFID tag type */
+ NFC_TAG_TYPE_TOPAZ_JEWEL, /**< The Topaz/Jewel tag type */
+ NFC_TAG_TYPE_MIFARE_UL, /**< The Mifare Ultralight/Ultralight C tag type */
+ NFC_TAG_TYPE_MIFARE_CLASSIC, /**< The Mifare Classic (1K/4K) tag type */
+ NFC_TAG_TYPE_ISO14443_4, /**< The ISO14443 Part 4 tag type @n
+ * For example, the Mifare DESFire tag belongs to this type.
+ */
+ NFC_TAG_TYPE_FORUM_TYPE_1, /**< The NFC forum type 1 */
+ NFC_TAG_TYPE_FORUM_TYPE_2, /**< The NFC forum type 2 */
+ NFC_TAG_TYPE_FORUM_TYPE_3, /**< The NFC forum type 3 */
+ NFC_TAG_TYPE_FORUM_TYPE_4, /**< The NFC forum type 4 */
+ NFC_TAG_TYPE_ALL_NDEF_COMPATIBLE = 0xfe, /**< The all NDEF compatible tag type
+ * @remarks This type should be used only for event filtering as the
+ * input argument of
+ * NfcManager::AddTagDiscoveryEventListener().
+ */
+ NFC_TAG_TYPE_ALL = 0xff, /**< The all tag type
+ * @remarks This type should be used only for event filtering as the
+ * input argument of
+ * NfcManager::AddTagDiscoveryEventListener().
+ */
+};
+
+/**
+ * @enum NdefRecordTypeNameFormat
+ *
+ * Defines the type name formats of an NDEF record.
+ *
+ * @since 2.0
+ */
+// Refer to NFCForum-TS-NDEF_1.0
+enum NdefRecordTypeNameFormat
+{
+ NDEF_TNF_EMPTY = 0x00, /**< The empty record type */
+ NDEF_TNF_WELL_KNOWN = 0x01, /**< The NFC forum-defined record type */
+ NDEF_TNF_MIME_MEDIA = 0x02, /**< The RFC2046 MIME media record type */
+ NDEF_TNF_ABSOLUTE_URI = 0x03, /**< The absolute URI record type */
+ NDEF_TNF_EXTERNAL = 0x04, /**< The user-defined record type (application specific) */
+ NDEF_TNF_UNKNOWN = 0x05, /**< The unknown record type */
+ NDEF_TNF_ALL = 0xff, /**< The all record type
+ * @remarks This type should be used only for event filtering as the
+ * input argument of
+ * NfcManager::AddNdefMessageDiscoveryEventListener().
+ */
+};
+
+} } } // Tizen::Net::Nfc
+
+#endif // _FNET_NFC_NFC_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 FNetNfcTagConnection.h
+ * @brief This is the header file for the %TagConnection class.
+ *
+ * This header file contains the declarations of the %TagConnection class.
+ */
+
+#ifndef _FNET_NFC_TAG_CONNECTION_H_
+#define _FNET_NFC_TAG_CONNECTION_H_
+
+#include <FBaseObject.h>
+#include <FBaseResult.h>
+
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+} }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+class NfcTag;
+class _TagConnectionImpl;
+class ITagConnectionListener;
+
+/**
+ * @class TagConnection
+ * @brief This class represents the connection with an NFC tag. It provides a mechanism to communicate with the NFC
+ * tag through ISO14443 or in a general Radio Frequency Identification (RFID) manner.
+ *
+ * @since 2.0
+ *
+ * The %TagConnection class represents the connection with an NFC tag. It provides a mechanism to communicate with
+ * the NFC tag through ISO14443 or in a general Radio Frequency Identification (RFID) manner. @n
+ * The class has an NfcTag instance that represents the target tag. This class can be inherited by the
+ * NdefTagConnection class if the target tag supports the NFC Data Exchange Format (NDEF) operations.
+ *
+ * For more information on the class features, see
+ * <a href="../org.tizen.native.appprogramming/html/guide/net/nfc.htm">NFC Guide</a>.
+ *
+ * The following example demonstrates how to use the %TagConnection class.
+ *
+ * @code
+ * // MyClass.h
+ * #include <FNet.h>
+ *
+ * class MyClass
+ * : public Tizen::Net::Nfc::INfcManagerEventListener
+ * , public Tizen::Net::Nfc::INfcTagDiscoveryEventListener
+ * , public Tizen::Net::Nfc::ITagConnectionListener
+ * {
+ * public:
+ * // Method declarations are hidden for the sake of simplicity.
+ *
+ * private:
+ * Tizen::Net::Nfc::NfcManager* __pNfcManager;
+ * Tizen::Net::Nfc::TagConnection* __pConnection;
+ * };
+ *
+ * // MyClass.cpp
+ * #include "MyClass.h"
+ *
+ * using namespace Tizen::Net::Nfc;
+ *
+ * MyClass::MyClass(void)
+ * : __pNfcManager(null)
+ * , __pConnection(null)
+ * {
+ * __pNfcManager = new NfcManager();
+ * }
+ *
+ * MyClass::~MyClass(void)
+ * {
+ * // Removes the tag discovery event listener for the ISO14443-4 tag type.
+ * __pNfcManager->RemoveTagDiscoveryEventListener(*this, NFC_TAG_TYPE_ISO14443_4);
+ *
+ * delete __pNfcManager;
+ * }
+ *
+ * void
+ * MyClass::SendApduCommandSample(void)
+ * {
+ * // Creates an instance of NfcManager and registers the manager event listener
+ * __pNfcManager->Construct(*this);
+ *
+ * // Adds the tag discovery event listener for the ISO14443-4 tag type
+ * __pNfcManager->AddTagDiscoveryEventListener(*this, NFC_TAG_TYPE_ISO14443_4);
+ * }
+ *
+ * // This method is invoked when a new ISO14443-4 tag like a Mifare DESFire is detected
+ * void
+ * MyClass::OnNfcTagDetectedN(TagConnection* pConnection)
+ * {
+ * // Checks whether the connection supports ISO14443-4,
+ * // but the evaluation result of the below code is always true in this example
+ * if (pConnection->GetTargetTag()->HasTagType(NFC_TAG_TYPE_ISO14443_4))
+ * {
+ * __pConnection = pConnection;
+ *
+ * // Registers the tag connection listener
+ * __pConnection->SetTagConnectionListener(this);
+ *
+ * Tizen::Base::ByteBuffer command;
+ * // Makes an APDU(ISO7816-4) command here
+ *
+ * __pConnection->SendCommand(command);
+ * }
+ * }
+ *
+ * // This method is invoked when the target tag is lost
+ * void
+ * MyClass::OnNfcTagLost(void)
+ * {
+ * // The acquired TagConnection should be deallocated
+ * delete __pConnection;
+ * }
+ *
+ * // This method is invoked when the response of the command is received
+ * void
+ * MyClass::OnNfcResponseReceivedN(Tizen::Base::ByteBuffer* pResponse, result r)
+ * {
+ * if (r == E_SUCCESS)
+ * {
+ * // Uses the response data here
+ *
+ * // Deallocates the response data
+ * delete pResponse;
+ * }
+ * }
+ * @endcode
+ */
+class _OSP_EXPORT_ TagConnection
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * Checks whether the connection supports the NDEF message operations.
+ *
+ * @since 2.0
+ *
+ * @return @c true if the connection supports the NDEF message operations, @n
+ * else @c false
+ */
+ virtual bool IsNdefConnection(void) const;
+
+ /**
+ * Gets the target tag object with which this connection is established.
+ *
+ * @since 2.0
+ *
+ * @return The tag object
+ */
+ const NfcTag* GetTargetTag(void) const;
+
+ /**
+ * Sets a listener for receiving the response of a command sent on this tag connection.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] pListener The listener to add @n
+ * If it is @c null, the listener that is already registered gets unregistered.
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM A system error has occurred.
+ * @remarks Only one event listener can be registered.
+ */
+ result SetTagConnectionListener(ITagConnectionListener* pListener);
+
+ /**
+ * Sends the specified @c command to the target tag.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] command The command to send
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified @c command is invalid.
+ * @exception E_IN_PROGRESS The previous send request is in progress.
+ * @exception E_CONNECTION_BUSY The connection is busy. Therefore, the method cannot process the send request.
+ * @exception E_CONNECTION_FAILED The connection to the tag has closed or has failed.
+ * @exception E_SYSTEM A system error has occurred.
+ * @see ITagConnectionListener::OnNfcResponseReceivedN()
+ */
+ result SendCommand(const Tizen::Base::ByteBuffer& command);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~TagConnection(void);
+
+protected:
+ //
+ // This method is for internal use only. Using this method can cause behavioral, security-related,
+ // and consistency-related issues in the application.
+ //
+ // This is the default constructor for this class.
+ //
+ // @since 2.0
+ //
+ TagConnection(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 TagConnection_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 TagConnection_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 TagConnection_Reserved3(void) {}
+
+private:
+ //
+ // The implementation of this copy constructor is intentionally blank to prohibit copying of objects.
+ //
+ TagConnection(const TagConnection& value);
+
+ //
+ // The implementation of this copy assignment operator is intentionally blank to prohibit copying of objects.
+ //
+ TagConnection& operator =(const TagConnection& value);
+
+protected:
+ //
+ // This variable is for internal use only. Using this variable can cause behavioral,
+ // security-related, and consistency-related issues in the application.
+ //
+ // The point for indicating the implementation object.
+ //
+ // @since 2.0
+ //
+ _TagConnectionImpl* _pImpl;
+
+ friend class _TagConnectionImpl;
+
+}; // TagConnection
+
+} } } // Tizen::Net::Nfc
+
+#endif // _FNET_NFC_TAG_CONNECTION_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-nfc
+Summary: osp nfc library
+Version: 1.2.2.0
+Release: 2
+Group: System/Libraries
+License: Apache-2.0, Flora-1.1
+Source0: %{name}-%{version}.tar.gz
+BuildRequires: cmake
+BuildRequires: pkgconfig(chromium)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(capi-system-device)
+BuildRequires: pkgconfig(capi-network-nfc)
+BuildRequires: pkgconfig(osp-appfw)
+BuildRequires: osp-appfw-internal-devel
+BuildRequires: pkgconfig(osp-net)
+BuildRequires: osp-net-internal-devel
+
+# runtime requires
+Requires: osp-appfw
+Requires: osp-net
+
+%description
+osp nfc library
+
+%package devel
+Summary: osp nfc library (Development)
+Group: TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+osp nfc library (DEV)
+
+%package internal-devel
+Summary: osp nfc library (Internal)
+Group: TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description internal-devel
+osp nfc library (Internal-DEV)
+
+%package debug
+Summary: osp nfc library (Development)
+Group: TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description debug
+osp nfc library (DEV)
+
+%prep
+%setup -q
+
+%build
+%if 0%{?tizen_build_binary_release_type_eng}
+CXXFLAGS="$CXXFLAGS -D_SECURE_LOG"
+%endif
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+%ifarch %{ix86}
+%if 0%{?simulator}
+CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_OSP_EMUL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+%else
+CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ " cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+%endif
+%else
+%if 0%{?tizen_build_binary_release_type_eng}
+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_SECURE_LOG -D_OSP_ARMEL_" 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
+%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.Flora %{buildroot}/usr/share/license/%{name}
+cat %{_builddir}/%{name}-%{version}/LICENSE.APLv2.0 >> %{buildroot}/usr/share/license/%{name}
+
+%make_install
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest osp-nfc.manifest
+/usr/share/license/%{name}
+%{_libdir}/osp/*.so*
+
+%files devel
+%{_includedir}/osp/*.h
+%{_libdir}/pkgconfig/osp-nfc.pc
+
+%files internal-devel
+%{_includedir}/osp/net/*.h
+
+%files debug
+%{_libdir}/osp/debug/*.so*
--- /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 FNetNfcNdefMessage.cpp
+// @brief This is the implementation file for NdefMessage class.
+//
+// This file contains the implementation of NdefMessage class.
+//
+
+#include <FBaseByteBuffer.h>
+#include <FBaseColIList.h>
+#include <FNetNfcNdefMessage.h>
+#include <FNetNfcNdefRecord.h>
+#include <FBaseSysLog.h>
+#include "FNetNfc_NdefMessageImpl.h"
+#include "FNetNfc_NdefMessageUtil.h"
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+NdefMessage::NdefMessage(void)
+ : __pImpl(null)
+{
+ __pImpl = new (std::nothrow) _NdefMessageImpl;
+ SysTryReturnVoidResult(NID_NET_NFC, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+}
+
+NdefMessage::NdefMessage(const NdefMessage& value)
+ : __pImpl(null)
+{
+ __pImpl = new (std::nothrow) _NdefMessageImpl(*(value.__pImpl));
+ SysTryReturnVoidResult(NID_NET_NFC, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+NdefMessage::~NdefMessage(void)
+{
+ if (__pImpl != null)
+ {
+ delete __pImpl;
+ }
+}
+
+bool
+NdefMessage::Equals(const Tizen::Base::Object& obj) const
+{
+ const NdefMessage* pOther = dynamic_cast <const NdefMessage*>(&obj);
+
+ if (pOther == null)
+ {
+ return false;
+ }
+
+ if (pOther == this)
+ {
+ return true;
+ }
+
+ return(__pImpl->Equals(*(pOther->__pImpl)));
+}
+
+int
+NdefMessage::GetHashCode() const
+{
+ return __pImpl->GetHashCode();
+}
+
+result
+NdefMessage::AppendRecord(const NdefRecord& record)
+{
+ return __pImpl->AppendRecord(record);
+}
+
+int
+NdefMessage::GetRecordsCount() const
+{
+ return __pImpl->GetRecordsCount();
+}
+
+NdefRecord*
+NdefMessage::GetRecordAt(int index) const
+{
+ return __pImpl->GetRecordAt(index);
+}
+
+NdefRecord*
+NdefMessage::GetRecord(const Tizen::Base::String& payloadId) const
+{
+ return __pImpl->GetRecord(payloadId);
+}
+
+result
+NdefMessage::IndexOf(const NdefRecord& record, int& index) const
+{
+ return __pImpl->IndexOf(record, index);
+}
+
+result
+NdefMessage::InsertRecordAt(const NdefRecord& record, int index)
+{
+ return __pImpl->InsertRecordAt(record, index);
+}
+
+result
+NdefMessage::RemoveRecordAt(int index, bool deallocate)
+{
+ return __pImpl->RemoveRecordAt(index, deallocate);
+}
+
+result
+NdefMessage::SetRecordAt(const NdefRecord& record, int index, bool deallocate)
+{
+ return __pImpl->SetRecordAt(record, index, deallocate);
+}
+
+void
+NdefMessage::RemoveAllRecords(bool deallocate)
+{
+ __pImpl->RemoveAllRecords(deallocate);
+}
+
+Tizen::Base::ByteBuffer*
+NdefMessage::ToByteBufferN() const
+{
+ return __pImpl->ToByteBufferN(*this);
+}
+
+NdefMessage*
+NdefMessage::GetInstanceN(const Tizen::Base::ByteBuffer& buffer)
+{
+ return _NdefMessageUtil::ToNdefMessageN(buffer);
+}
+
+NdefMessage&
+NdefMessage::operator =(const NdefMessage& rhs)
+{
+ if (this != &rhs)
+ {
+ *__pImpl = *rhs.__pImpl;
+ }
+
+ return *this;
+}
+
+} } } // Tizen::Net::Nfc
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.1 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// 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 FNetNfcNdefPushManager.cpp
+// @brief This is the implementation file for %NdefPushManager class.
+//
+// This file contains the implementation of %NdefPushManager class.
+//
+
+#include <FNetNfcNdefPushManager.h>
+#include <FNetNfcINdefPushManagerListener.h>
+#include <FNetNfcNdefMessage.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FBaseColIMap.h>
+#include <FSec_AccessController.h>
+#include <FSys_SystemInfoImpl.h>
+#include "FNetNfc_NdefPushManagerImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::System;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+NdefPushManager::NdefPushManager(void)
+ : __pImpl(null)
+{
+ result r = E_SUCCESS;
+ bool isSupported = false;
+
+ r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/network.nfc", isSupported);
+ SysTryReturnVoidResult(NID_NET_NFC, (r == E_SUCCESS) && (isSupported == true), E_UNSUPPORTED_OPERATION,
+ "[E_UNSUPPORTED_OPERATION] NFC is not supported.");
+
+ __pImpl = new (std::nothrow) _NdefPushManagerImpl;
+ SysTryReturnVoidResult(NID_NET_NFC, __pImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+NdefPushManager::~NdefPushManager(void)
+{
+ delete __pImpl;
+}
+
+result
+NdefPushManager::SetNdefPushManagerListener(INdefPushManagerListener* pListener)
+{
+ result r = E_SUCCESS;
+ bool isSupported = false;
+
+ r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/network.nfc", isSupported);
+ SysTryReturnResult(NID_NET_NFC, (r == E_SUCCESS) && (isSupported == true), E_UNSUPPORTED_OPERATION, "NFC is not supported.");
+
+ // Privilege check
+ r = _AccessController::CheckUserPrivilege(_PRV_NFC_P2P);
+ r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY, E_USER_NOT_CONSENTED);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "The application is not permitted to call this method.");
+
+ r = __pImpl->SetNdefPushManagerListener(pListener);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to add the callback to _NfcSystemAdapter.");
+
+ return r;
+}
+
+result
+NdefPushManager::Push(const NdefMessage& message)
+{
+ result r = E_SUCCESS;
+ bool isSupported = false;
+
+ r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/network.nfc", isSupported);
+ SysTryReturnResult(NID_NET_NFC, (r == E_SUCCESS) && (isSupported == true), E_UNSUPPORTED_OPERATION, "NFC is not supported.");
+
+ SysTryReturnResult(NID_NET_NFC, message.GetRecordsCount() != 0, E_INVALID_ARG,
+ "Invalid argument is used. NDEF message does not contain any NDEF records");
+
+ // Privilege check
+ r = _AccessController::CheckUserPrivilege(_PRV_NFC_P2P);
+ r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY, E_USER_NOT_CONSENTED);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "The application is not permitted to call this method.");
+
+ r = __pImpl->Push(message);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to push NDEF message.");
+
+ return r;
+}
+
+result
+NdefPushManager::RegisterNdefPushMessage(const NdefMessage& message, const Tizen::Base::String& description)
+{
+ result r = E_SUCCESS;
+ bool isSupported = false;
+
+ r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/network.nfc", isSupported);
+ SysTryReturnResult(NID_NET_NFC, (r == E_SUCCESS) && (isSupported == true), E_UNSUPPORTED_OPERATION, "NFC is not supported.");
+
+ // Privilege check
+ r = _AccessController::CheckUserPrivilege(_PRV_NFC_P2P);
+ r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY, E_USER_NOT_CONSENTED);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "The application is not permitted to call this method.");
+
+ return _NdefPushManagerImpl::RegisterNdefPushMessage(message, description);
+}
+
+result
+NdefPushManager::UnregisterNdefPushMessage(void)
+{
+ result r = E_SUCCESS;
+ bool isSupported = false;
+
+ r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/network.nfc", isSupported);
+ SysTryReturnResult(NID_NET_NFC, (r == E_SUCCESS) && (isSupported == true), E_UNSUPPORTED_OPERATION, "NFC is not supported.");
+
+ // Privilege check
+ r = _AccessController::CheckUserPrivilege(_PRV_NFC_P2P);
+ r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY, E_USER_NOT_CONSENTED);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "The application is not permitted to call this method.");
+
+ return _NdefPushManagerImpl::UnregisterNdefPushMessage();
+}
+
+result
+NdefPushManager::ActivateReservedPush(void)
+{
+ result r = E_SUCCESS;
+ bool isSupported = false;
+
+ r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/network.nfc", isSupported);
+ SysTryReturnResult(NID_NET_NFC, (r == E_SUCCESS) && (isSupported == true), E_UNSUPPORTED_OPERATION, "NFC is not supported.");
+
+ r = __pImpl->ActivateReservedPush(); // Privilege check is done by connectivity service daemon
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to activate the Reserved Push.");
+
+ return r;
+}
+
+result
+NdefPushManager::DeactivateReservedPush(void)
+{
+ result r = E_SUCCESS;
+ bool isSupported = false;
+
+ r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/network.nfc", isSupported);
+ SysTryReturnResult(NID_NET_NFC, (r == E_SUCCESS) && (isSupported == true), E_UNSUPPORTED_OPERATION, "NFC is not supported.");
+
+ r = __pImpl->DeactivateReservedPush(); // Privilege check is done by connectivity service daemon
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to deactivate the Reserved Push.");
+
+ return r;
+}
+
+bool
+NdefPushManager::IsReservedPushActivated(void) const
+{
+ result r = E_SUCCESS;
+ bool isSupported = false;
+
+ r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/network.nfc", isSupported);
+ SysTryReturn(NID_NET_NFC, (r == E_SUCCESS) && (isSupported == true), false, E_UNSUPPORTED_OPERATION,
+ "[E_UNSUPPORTED_OPERATION] NFC is not supported.");
+
+ return __pImpl->IsReservedPushActivated();
+}
+
+Tizen::Base::Collection::IMap*
+NdefPushManager::GetReservedPushCandidatesN(void) const
+{
+ result r = E_SUCCESS;
+ bool isSupported = false;
+
+ r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/network.nfc", isSupported);
+ SysTryReturn(NID_NET_NFC, (r == E_SUCCESS) && (isSupported == true), null, E_UNSUPPORTED_OPERATION,
+ "[E_UNSUPPORTED_OPERATION] NFC is not supported.");
+
+ return __pImpl->GetReservedPushCandidatesN();
+}
+
+result
+NdefPushManager::PickReservedPushMessage(const Tizen::App::AppId& appId)
+{
+ result r = E_SUCCESS;
+ bool isSupported = false;
+
+ r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/network.nfc", isSupported);
+ SysTryReturnResult(NID_NET_NFC, (r == E_SUCCESS) && (isSupported == true), E_UNSUPPORTED_OPERATION, "NFC is not supported.");
+
+ r = __pImpl->PickReservedPushMessage(appId); // Privilege check is done by connectivity service daemon
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to pick the Reserved Push message from the candidates.");
+
+ return r;
+}
+
+Tizen::App::AppId
+NdefPushManager::GetPickedReservedPushMessage(void) const
+{
+ result r = E_SUCCESS;
+ bool isSupported = false;
+
+ r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/network.nfc", isSupported);
+ SysTryReturn(NID_NET_NFC, (r == E_SUCCESS) && (isSupported == true), String(L""), E_UNSUPPORTED_OPERATION,
+ "[E_UNSUPPORTED_OPERATION] NFC is not supported.");
+
+ return __pImpl->GetPickedReservedPushMessage();
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfcNdefRecord.cpp
+// @brief This is the implementation file for NdefRecord class.
+//
+// This file contains the implementation of NdefRecord class.
+//
+
+#include <FNetNfcNdefRecord.h>
+#include <FNetNfcNdefMessage.h>
+#include <FNetNfcNdefRecordType.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include "FNetNfc_NdefRecordImpl.h"
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+NdefRecord::NdefRecord(const NdefRecord& value)
+ : __pImpl(null)
+{
+ __pImpl = new (std::nothrow) _NdefRecordImpl(*(value.__pImpl));
+ SysTryReturnVoidResult(NID_NET_NFC, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+NdefRecord::NdefRecord(const NdefRecordType& recordType)
+ : __pImpl(null)
+{
+ __pImpl = new (std::nothrow) _NdefRecordImpl(recordType);
+ SysTryReturnVoidResult(NID_NET_NFC, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+NdefRecord::~NdefRecord(void)
+{
+ delete __pImpl;
+}
+
+bool
+NdefRecord::Equals(const Tizen::Base::Object& obj) const
+{
+ const NdefRecord* pOther = dynamic_cast <const NdefRecord*>(&obj);
+
+ if (pOther == null)
+ {
+ return false;
+ }
+
+ if (pOther == this)
+ {
+ return true;
+ }
+
+ return(__pImpl->Equals(*(pOther->__pImpl)));
+}
+
+int
+NdefRecord::GetHashCode() const
+{
+ return __pImpl->GetHashCode();
+}
+
+Tizen::Base::String
+NdefRecord::GetPayloadId() const
+{
+ return __pImpl->GetPayloadId();
+}
+
+Tizen::Base::ByteBuffer*
+NdefRecord::GetPayload() const
+{
+ return __pImpl->GetPayload();
+}
+
+NdefRecordType
+NdefRecord::GetRecordType() const
+{
+ return __pImpl->GetRecordType();
+}
+
+result
+NdefRecord::SetRecordType(NdefRecordType& type)
+{
+ return __pImpl->SetRecordType(type);
+}
+
+result
+NdefRecord::SetPayloadId(const Tizen::Base::String& id)
+{
+ return __pImpl->SetPayloadId(id);
+}
+
+result
+NdefRecord::SetPayload(const Tizen::Base::ByteBuffer& payload)
+{
+ return __pImpl->SetPayload(payload);
+}
+
+NdefRecord&
+NdefRecord::operator =(const NdefRecord& rhs)
+{
+ if (this != &rhs)
+ {
+ *__pImpl = *rhs.__pImpl;
+ }
+
+ return *this;
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfcNdefRecordType.cpp
+// @brief This is the implementation file for NdefRecordType class.
+//
+// This file contains the implementation of NdefRecordType class.
+//
+
+#include <FBaseErrors.h>
+#include <FBaseString.h>
+#include <FNetNfcNdefRecordType.h>
+#include <FBaseSysLog.h>
+#include "FNetNfc_NdefRecordTypeImpl.h"
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+const wchar_t NFC_NDEF_RTD_SMART_POSTER[] = L"Sp";
+const wchar_t NFC_NDEF_RTD_TEXT[] = L"T";
+const wchar_t NFC_NDEF_RTD_URI[] = L"U";
+
+NdefRecordType::NdefRecordType(NdefRecordTypeNameFormat format)
+ : __pImpl(null)
+{
+ __pImpl = new (std::nothrow) _NdefRecordTypeImpl(format);
+ SysTryReturnVoidResult(NID_NET_NFC, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+NdefRecordType::NdefRecordType(const NdefRecordType& recordType)
+ : __pImpl(null)
+{
+ if (recordType.__pImpl != null)
+ {
+ __pImpl = new (std::nothrow) _NdefRecordTypeImpl(*recordType.__pImpl);
+ SysTryReturnVoidResult(NID_NET_NFC, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ }
+}
+
+NdefRecordType::~NdefRecordType(void)
+{
+ delete __pImpl;
+}
+
+NdefRecordType&
+NdefRecordType::operator =(const NdefRecordType& rhs)
+{
+ if (this != &rhs)
+ {
+ *__pImpl = *rhs.__pImpl;
+ }
+
+ return *this;
+}
+
+bool
+NdefRecordType::Equals(const Tizen::Base::Object& obj) const
+{
+ return __pImpl->Equals(obj);
+}
+
+int
+NdefRecordType::GetHashCode() const
+{
+ return __pImpl->GetHashCode();
+}
+
+NdefRecordTypeNameFormat
+NdefRecordType::GetNameFormat(void) const
+{
+ return __pImpl->GetNameFormat();
+}
+
+Tizen::Base::String
+NdefRecordType::GetName(void) const
+{
+ return __pImpl->GetName();
+}
+
+result
+NdefRecordType::SetName(const Tizen::Base::String& name)
+{
+ return __pImpl->SetName(name);
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfcNdefTagConnection.cpp
+// @brief This is the implementation file for NdefTagConnection class.
+//
+// This file contains the implementation of NdefTagConnection class.
+//
+
+#include <FNetNfcNdefTagConnection.h>
+#include <FNetNfcINdefTagConnectionListener.h>
+#include <FNetNfcNdefMessage.h>
+#include <FBaseSysLog.h>
+#include "FNetNfc_TagConnectionImpl.h"
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+NdefTagConnection::NdefTagConnection(void)
+ : __pNdefImpl(null)
+{
+ // This class uses not __pNdefImpl but _pImpl of its parent class, TagConnection.
+ // __pNdefImpl, however, is just reserved for later use.
+
+ // NOTICE:
+ // This constructor is a private method, so it must be called by only _TagConnectionImpl class which is a friend class of
+ // this class. _TagConnectionImpl class definitely assigns its instance to _pImpl after generating NdefTagConnection instance.
+}
+
+NdefTagConnection::~NdefTagConnection(void)
+{
+}
+
+bool
+NdefTagConnection::IsNdefConnection(void) const
+{
+ return true;
+}
+
+result
+NdefTagConnection::SetNdefTagConnectionListener(INdefTagConnectionListener* pListener)
+{
+ return _pImpl->SetNdefTagConnectionListener(pListener);
+}
+
+result
+NdefTagConnection::Read(void)
+{
+ return _pImpl->Read();
+}
+
+result
+NdefTagConnection::Write(const NdefMessage& message)
+{
+ return _pImpl->Write(message);
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfcNfcManager.cpp
+// @brief This is the implementation file for NfcManager class.
+//
+// This file contains the implementation of NfcManager class.
+//
+
+#include <FBaseColHashMap.h>
+#include <FNetNfcNfcManager.h>
+#include <FNetNfcINdefMessageDiscoveryEventListener.h>
+#include <FNetNfcINfcManagerEventListener.h>
+#include <FNetNfcINfcTagDiscoveryEventListener.h>
+#include <FNetNfcNdefRecordType.h>
+#include <FNetNfcTagConnection.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include <FSys_SystemInfoImpl.h>
+#include "FNetNfc_NfcManagerImpl.h"
+#include "FNetNfc_NdefMessageUtil.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::System;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+NfcManager::NfcManager(void)
+ : __pImpl(null)
+{
+}
+
+NfcManager::~NfcManager(void)
+{
+ delete __pImpl;
+}
+
+result
+NfcManager::Construct(INfcManagerEventListener& listener)
+{
+ result r = E_SUCCESS;
+ bool isNfcSupported = false;
+
+ r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/network.nfc", isNfcSupported);
+ SysTryReturnResult(NID_NET_NFC, (r == E_SUCCESS) && (isNfcSupported == true), E_UNSUPPORTED_OPERATION, "NFC is not supported.");
+
+ SysAssertf(__pImpl == null,
+ "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+
+ __pImpl = new (std::nothrow) _NfcManagerImpl;
+
+ SysTryReturnResult(NID_NET_NFC, __pImpl != null, E_OUT_OF_MEMORY, "Creating __pImpl instance failed.");
+
+ r = __pImpl->Construct(listener);
+ r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+
+ if (r != E_SUCCESS)
+ {
+ delete __pImpl;
+ __pImpl = null;
+
+ SysLogException(NID_NET_NFC, r,
+ "[%s] Internal error occurred on construction of a NfcManager instance.", GetErrorMessage(r));
+ }
+
+ return r;
+}
+
+result
+NfcManager::Activate(void)
+{
+ result r = E_SUCCESS;
+
+ // Privilege check
+ r = _AccessController::CheckUserPrivilege(_PRV_NFC_ADMIN);
+ r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY, E_USER_NOT_CONSENTED);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "The application is not permitted to call this method.");
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pImpl->Activate();
+}
+
+result
+NfcManager::Deactivate(void)
+{
+ result r = E_SUCCESS;
+
+ // Privilege check
+ r = _AccessController::CheckUserPrivilege(_PRV_NFC_ADMIN);
+ r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY, E_USER_NOT_CONSENTED);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "The application is not permitted to call this method.");
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pImpl->Deactivate();
+}
+
+bool
+NfcManager::IsActivated(void) const
+{
+ SysTryReturn(NID_NET_NFC, __pImpl != null, false, E_SYSTEM, "NfcManager is not constructed.");
+
+ return __pImpl->IsActivated();
+}
+
+bool
+NfcManager::IsTagConnected(void) const
+{
+ SysTryReturn(NID_NET_NFC, __pImpl != null, false, E_SYSTEM, "NfcManager is not constructed.");
+
+ return __pImpl->IsTagConnected();
+}
+
+TagConnection*
+NfcManager::GetCurrentTagConnectionN(void) const
+{
+ result r = E_SUCCESS;
+
+ ClearLastResult();
+
+ // Privilege check
+ r = _AccessController::CheckUserPrivilege(_PRV_NFC_TAG);
+ r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY, E_USER_NOT_CONSENTED);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pImpl->GetCurrentTagConnectionN();
+}
+
+NdefMessage*
+NfcManager::GetCachedNdefMessageN(void)
+{
+ result r = E_SUCCESS;
+ bool isNfcSupported = false;
+
+ ClearLastResult();
+
+ r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/network.nfc", isNfcSupported);
+ SysTryReturn(NID_NET_NFC, (r == E_SUCCESS) && (isNfcSupported == true), null, E_UNSUPPORTED_OPERATION,
+ "[E_UNSUPPORTED_OPERATION] NFC is not supported.");
+
+ // Privilege check
+ r = _AccessController::CheckUserPrivilege(_PRV_NFC_COMMON);
+ r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY, E_USER_NOT_CONSENTED);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
+
+ return _NfcManagerImpl::GetCachedNdefMessageN();
+}
+
+result
+NfcManager::SetLaunchPopupEnabled(bool enable)
+{
+ result r = E_SUCCESS;
+ bool isNfcSupported = false;
+
+ r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/network.nfc", isNfcSupported);
+ SysTryReturnResult(NID_NET_NFC, (r == E_SUCCESS) && (isNfcSupported == true), E_UNSUPPORTED_OPERATION, "NFC is not supported.");
+
+ // Privilege check
+ r = _AccessController::CheckUserPrivilege(_PRV_NFC_COMMON);
+ r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY, E_USER_NOT_CONSENTED);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "The application is not permitted to call this method.");
+
+ return _NfcManagerImpl::SetLaunchPopupEnabled(enable);
+}
+
+result
+NfcManager::AddTagDiscoveryEventListener(INfcTagDiscoveryEventListener& listener, NfcTagType type)
+{
+ result r = E_SUCCESS;
+
+ // Privilege check
+ r = _AccessController::CheckUserPrivilege(_PRV_NFC_TAG);
+ r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY, E_USER_NOT_CONSENTED);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "The application is not permitted to call this method.");
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pImpl->AddTagDiscoveryEventListener(listener, type);
+}
+
+result
+NfcManager::RemoveTagDiscoveryEventListener(INfcTagDiscoveryEventListener& listener, NfcTagType type)
+{
+ result r = E_SUCCESS;
+
+ // Privilege check
+ r = _AccessController::CheckUserPrivilege(_PRV_NFC_TAG);
+ r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY, E_USER_NOT_CONSENTED);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "The application is not permitted to call this method.");
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pImpl->RemoveTagDiscoveryEventListener(listener, type);
+}
+
+result
+NfcManager::AddNdefMessageDiscoveryEventListener(INdefMessageDiscoveryEventListener& listener, const NdefRecordType& type)
+{
+ result r = E_SUCCESS;
+
+ // Privilege check
+ r = _AccessController::CheckUserPrivilege(_PRV_NFC_COMMON);
+ r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY, E_USER_NOT_CONSENTED);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "The application is not permitted to call this method.");
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pImpl->AddNdefMessageDiscoveryEventListener(listener, type);
+}
+
+result
+NfcManager::RemoveNdefMessageDiscoveryEventListener(INdefMessageDiscoveryEventListener& listener,
+ const NdefRecordType& type)
+{
+ result r = E_SUCCESS;
+
+ // Privilege check
+ r = _AccessController::CheckUserPrivilege(_PRV_NFC_COMMON);
+ r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY, E_USER_NOT_CONSENTED);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "The application is not permitted to call this method.");
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pImpl->RemoveNdefMessageDiscoveryEventListener(listener, type);
+}
+
+
+result
+NfcManager::AddDeviceDiscoveryEventListener(INfcDeviceDiscoveryEventListener& listener)
+{
+ result r = E_SUCCESS;
+
+ // Privilege check
+ r = _AccessController::CheckUserPrivilege(_PRV_NFC_P2P);
+ r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY, E_USER_NOT_CONSENTED);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "The application is not permitted to call this method.");
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pImpl->AddDeviceDiscoveryEventListener(listener);
+}
+
+result
+NfcManager::RemoveDeviceDiscoveryEventListener(INfcDeviceDiscoveryEventListener& listener)
+{
+ result r = E_SUCCESS;
+
+ // Privilege check
+ r = _AccessController::CheckUserPrivilege(_PRV_NFC_P2P);
+ r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY, E_USER_NOT_CONSENTED);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "The application is not permitted to call this method.");
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pImpl->RemoveDeviceDiscoveryEventListener(listener);
+}
+
+bool
+NfcManager::IsDeviceDetected(void) const
+{
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pImpl->IsDeviceDetected();
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfcNfcTag.cpp
+// @brief This is the implementation file for NfcTag class.
+//
+// This file contains the implementation of NfcTag class.
+//
+
+#include <FNetNfcNfcTag.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseSysLog.h>
+#include "FNetNfc_NfcTagImpl.h"
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+NfcTag::NfcTag(void)
+ : __pImpl(null)
+{
+ // NOTICE:
+ // This constructor is a private method, so it must be called by only _NfcTagImpl class which is a friend class of this class.
+ // _NfcTagImpl class definitely assigns its instance to __pImpl after generating NfcTag instance.
+}
+
+NfcTag::~NfcTag(void)
+{
+ delete __pImpl;
+}
+
+const Tizen::Base::Collection::IListT <NfcTagType>*
+NfcTag::GetTagTypeList(void) const
+{
+ return __pImpl->GetTagTypeList();
+}
+
+bool
+NfcTag::HasTagType(NfcTagType type) const
+{
+ return __pImpl->HasTagType(type);
+}
+
+const Tizen::Base::ByteBuffer*
+NfcTag::GetId(void) const
+{
+ return __pImpl->GetId();
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfcTagConnection.cpp
+// @brief This is the implementation file for TagConnection class.
+//
+// This file contains the implementation of TagConnection class.
+//
+
+#include <FBaseByteBuffer.h>
+#include <FNetNfcTagConnection.h>
+#include <FNetNfcITagConnectionListener.h>
+#include <FNetNfcNfcTag.h>
+#include <FBaseSysLog.h>
+#include "FNetNfc_TagConnectionImpl.h"
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+TagConnection::TagConnection(void)
+ : _pImpl(null)
+{
+ // NOTICE:
+ // This constructor is a private method, so it must be called by only _TagConnectionImpl class which is a friend class of
+ // this class. _TagConnectionImpl class definitely assigns its instance to _pImpl after generating NdefTagConnection instance.
+}
+
+TagConnection::~TagConnection(void)
+{
+ delete _pImpl;
+}
+
+bool
+TagConnection::IsNdefConnection(void) const
+{
+ return false;
+}
+
+const NfcTag*
+TagConnection::GetTargetTag(void) const
+{
+ return _pImpl->GetTargetTag();
+}
+
+result
+TagConnection::SetTagConnectionListener(ITagConnectionListener* pListener)
+{
+ return _pImpl->SetTagConnectionListener(pListener);
+}
+
+result
+TagConnection::SendCommand(const Tizen::Base::ByteBuffer& command)
+{
+ return _pImpl->SendCommand(command);
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfc_INfcDeviceDiscoveryEventListener.h
+ * @brief This is the header file for the _INfcDeviceDiscoveryEventListener interface.
+ *
+ * This header file contains the declaration of the _INfcDeviceDiscoveryEventListener interface.
+ *
+ */
+#ifndef _FNET_NFC_INTERNAL_INFC_DEVICE_DISCOVERY_EVENT_LISTENER_H_
+#define _FNET_NFC_INTERNAL_INFC_DEVICE_DISCOVERY_EVENT_LISTENER_H_
+
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+/**
+ * @interface _INfcDeviceDiscoveryEventListener
+ * @brief This interface provides a listener for the events related to the NFC manager status.
+ *
+ * The _INfcDeviceDiscoveryEventListener interface specifies the event listener methods invoked by _NfcSystemAdapter for
+ * notifying NFC peer device discovery events.
+ */
+
+class _INfcDeviceDiscoveryEventListener
+{
+public:
+ /**
+ * This is the virtual destructor for this class.
+ */
+ virtual ~_INfcDeviceDiscoveryEventListener(void) {}
+
+ /**
+ * Called to notify when a device is detected.
+ */
+ virtual void OnNfcDeviceDetected(void) = 0;
+
+ /**
+ * Called to notify when the device is lost.
+ */
+ virtual void OnNfcDeviceLost(void) = 0;
+
+}; // _INfcDeviceDiscoveryEventListener
+
+} } }
+
+#endif // _FNET_NFC_INTERNAL_INFC_DEVICE_DISCOVERY_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 FNetNfcNdefMessageDiscoveryEvent.cpp
+// @brief This is the implementation file for _NdefMessageDiscoveryEvent class.
+//
+// This file contains the implementation of _NdefMessageDiscoveryEvent class.
+//
+
+#include <FBaseRtIEventListener.h>
+#include <FBaseSysLog.h>
+#include <FBaseRtIEventArg.h>
+#include <FNetNfcNdefMessage.h>
+#include <FNetNfcINdefMessageDiscoveryEventListener.h>
+#include "FNetNfc_NdefMessageDiscoveryEvent.h"
+#include "FNetNfc_NdefMessageDiscoveryEventArg.h"
+#include "FNetNfc_NdefMessageImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+_NdefMessageDiscoveryEvent::_NdefMessageDiscoveryEvent(void)
+{
+}
+
+_NdefMessageDiscoveryEvent::~_NdefMessageDiscoveryEvent(void)
+{
+}
+
+result
+_NdefMessageDiscoveryEvent::Construct(void)
+{
+ return _Event::Initialize();
+}
+
+void
+_NdefMessageDiscoveryEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
+{
+ INdefMessageDiscoveryEventListener* pEventListener = null;
+ const _NdefMessageDiscoveryEventArg* pEventArg = null;
+ const NdefMessage* pSrcMessage = null;
+ NdefMessage* pDstMessage = null;
+
+ pEventListener = dynamic_cast <INdefMessageDiscoveryEventListener*>(&listener);
+ SysTryReturnVoidResult(NID_NET_NFC, pEventListener != null, E_SYSTEM, "[E_SYSTEM] A dynamic casting failure.");
+
+ pEventArg = dynamic_cast <const _NdefMessageDiscoveryEventArg*>(&arg);
+ SysTryReturnVoidResult(NID_NET_NFC, pEventArg != null, E_SYSTEM, "[E_SYSTEM] A dynamic casting failure.");
+
+ pSrcMessage = pEventArg->GetNdefMessage();
+ SysTryReturnVoidResult(NID_NET_NFC, pSrcMessage != null, E_SYSTEM, "[E_SYSTEM] No NDEF message.");
+
+ // If the numuber of the registered listeners is only one - most of cases, do shallow copy for better performance.
+ // Otherwise, do deep copy.
+ if (_Event::GetListenerCount() == 1)
+ {
+ pDstMessage = _NdefMessageImpl::GetCloneSharingPayloadN(*pSrcMessage);
+ SysTryReturnVoidResult(NID_NET_NFC, pDstMessage != null, GetLastResult(),
+ "[%s] Copying an NDEF message failed.", GetErrorMessage(GetLastResult()));
+ }
+ else
+ {
+ pDstMessage = new (std::nothrow) NdefMessage(*pSrcMessage); // deep copy
+ SysTryReturnVoidResult(NID_NET_NFC, pDstMessage != null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ }
+
+ pEventListener->OnNdefMessageDetectedN(pDstMessage); // transfer the ownershipt to the listener
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfcNdefMessageDiscoveryEvent.h
+ * @brief This is the header file for the _NdefMessageDiscoveryEvent class.
+ *
+ * This header file contains declaration of the _NdefMessageDiscoveryEvent class.
+ * The _NdefMessageDiscoveryEvent class can call methods of INdefMessageDiscoveryEventListener class.
+ */
+#ifndef _FNET_NFC_INTERNAL_NDEF_MESSAGE_DISCOVERY_EVENT_H_
+#define _FNET_NFC_INTERNAL_NDEF_MESSAGE_DISCOVERY_EVENT_H_
+
+#include <FOspConfig.h>
+#include <FBaseResult.h>
+#include <FBaseRt_Event.h>
+
+namespace Tizen { namespace Base { namespace Runtime
+{
+class IEventArg;
+class IEventListener;
+} } }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+/**
+ * @class _NdefMessageDiscoveryEvent
+ * @brief This class handles the events related to the discovery of NDEF message.
+ *
+ * When an NDEF message is discovered, the _NdefMessageDiscoveryEvent object finds a INdefMessageDiscoveryEventListener
+ * object and calls an appropriate method of the listener.
+ */
+class _NdefMessageDiscoveryEvent
+ : public Tizen::Base::Runtime::_Event
+{
+public:
+ /**
+ * This is the default constructor.
+ */
+ _NdefMessageDiscoveryEvent();
+
+ /**
+ * This is the class destructor.
+ */
+ virtual ~_NdefMessageDiscoveryEvent(void);
+
+ /**
+ * Initializes a new instance of the class
+ *
+ */
+ result Construct(void);
+
+protected:
+ /**
+ * Calls the specified listener's method with the specified argument when event is generated.
+ *
+ * @param[in] listener The event listener which will be received the event
+ * @param[in] arg The event argument to be passed by
+ */
+ void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+ _NdefMessageDiscoveryEvent(const _NdefMessageDiscoveryEvent& value);
+ _NdefMessageDiscoveryEvent& operator =(const _NdefMessageDiscoveryEvent& value);
+
+}; // _NdefMessageDiscoveryEvent
+
+} } } //Tizen::Net::Nfc
+#endif // _FNET_NFC_INTERNAL_NDEF_MESSAGE_DISCOVERY_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 FNetNfc_NdefMessageDiscoveryEventArg.cpp
+// @brief This is the implementation file for _NdefMessageDiscoveryEventArg class.
+//
+// This file contains the implementation of _NdefMessageDiscoveryEventArg class.
+//
+
+#include <FBaseSysLog.h>
+#include <FNetNfcNdefMessage.h>
+#include "FNetNfc_NdefMessageDiscoveryEventArg.h"
+#include "FNetNfc_NdefMessageImpl.h"
+
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+_NdefMessageDiscoveryEventArg::_NdefMessageDiscoveryEventArg(const NdefMessage& message)
+ : __pNdefMessage(null)
+{
+ // The payload is copied shallowly for better performance
+ __pNdefMessage = _NdefMessageImpl::GetCloneSharingPayloadN(message);
+ SysTryReturnVoidResult(NID_NET_NFC, __pNdefMessage != null, GetLastResult(),
+ "[%s] Copying an NDEF message failed.", GetErrorMessage(GetLastResult()));
+}
+
+_NdefMessageDiscoveryEventArg::~_NdefMessageDiscoveryEventArg(void)
+{
+ if (__pNdefMessage)
+ {
+ __pNdefMessage->RemoveAllRecords(true);
+ delete __pNdefMessage;
+ }
+}
+
+Tizen::Net::Nfc::NdefMessage*
+_NdefMessageDiscoveryEventArg::GetNdefMessage(void) const
+{
+ return __pNdefMessage;
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfcNdefMessageArg.h
+ * @brief This is the header file for the _NdefMessageDiscoveryEventArg class.
+ *
+ * This header file contains declaration of the _NdefMessageDiscoveryEventArg class.
+ */
+#ifndef _FNET_NFC_INTERNAL_NDEF_MESSAGE_DISCOVERY_EVENT_ARG_H_
+#define _FNET_NFC_INTERNAL_NDEF_MESSAGE_DISCOVERY_EVENT_ARG_H_
+
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FBaseRtIEventArg.h>
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+// Forward declaration
+class NdefMessage;
+
+/**
+ * @class _NdefMessageDiscoveryEventArg
+ * @brief This class is used as an argument of methods of the _NdefMessageDiscoveryEvent class.
+ *
+ * When an NDEF message is discovered, the INdefMessageDiscoveryEventListener objects registered to the event are called
+ * with this argument class.
+ */
+class _NdefMessageDiscoveryEventArg
+ : public Tizen::Base::Object
+ , public Tizen::Base::Runtime::IEventArg
+{
+public:
+ /**
+ * This is the constructor.
+ * @param[in] message The detected NDEF message
+ */
+ _NdefMessageDiscoveryEventArg(const NdefMessage& message);
+
+ /**
+ * This is the class destructor.
+ */
+ ~_NdefMessageDiscoveryEventArg(void);
+
+ /**
+ * Gets the NDEF Message .
+ *
+ * @return The detected NDEF message
+ */
+ NdefMessage* GetNdefMessage(void) const;
+
+private:
+ _NdefMessageDiscoveryEventArg(const _NdefMessageDiscoveryEventArg& value);
+ _NdefMessageDiscoveryEventArg& operator =(const _NdefMessageDiscoveryEventArg& value);
+
+private:
+ NdefMessage* __pNdefMessage;
+
+}; // _NdefMessageDiscoveryEventArg
+
+} } } //Tizen::Net::Nfc
+#endif // _FNET_NFC_INTERNAL_NDEF_MESSAGE_DISCOVERY_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 FNetNfc_NdefMessageImpl.cpp
+// @brief This is the implementation file for _NdefMessageImpl class.
+//
+// This file contains the implementation of _NdefMessageImpl class.
+//
+
+#include <FBaseColIList.h>
+#include <FBaseColLinkedList.h>
+#include <FBaseByteBuffer.h>
+#include <FNetNfcNdefRecordType.h>
+#include <FNetNfcNdefRecord.h>
+#include <FBaseSysLog.h>
+#include "FNetNfc_NdefMessageImpl.h"
+#include "FNetNfc_NdefMessageUtil.h"
+#include "FNetNfc_NdefRecordImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+_NdefMessageImpl::_NdefMessageImpl(void)
+ : __pRecordList(null)
+{
+ unique_ptr<LinkedList, AllElementsDeleter> pRecordList(new (std::nothrow) LinkedList());
+ SysTryReturnVoidResult(NID_NET_NFC, pRecordList != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ __pRecordList = move(pRecordList);
+}
+
+_NdefMessageImpl::_NdefMessageImpl(const _NdefMessageImpl& value)
+{
+ IList* pSourceList = value.__pRecordList.get();
+ int srcRecordCount = pSourceList->GetCount();
+
+ unique_ptr<LinkedList, AllElementsDeleter> pRecordList(new (std::nothrow) LinkedList());
+ SysTryReturnVoidResult(NID_NET_NFC, pRecordList != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ for (int i = 0; i < srcRecordCount; i++)
+ {
+ NdefRecord* pSrcRecord = dynamic_cast<NdefRecord*>(pSourceList->GetAt(i));
+ SysTryReturnVoidResult(NID_NET_NFC, pSrcRecord != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system.");
+
+ NdefRecord* pNewRecord = new (std::nothrow) NdefRecord(*pSrcRecord);
+ SysTryReturnVoidResult(NID_NET_NFC, pNewRecord != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ pRecordList->Add(*pNewRecord);
+ }
+ __pRecordList = move(pRecordList);
+}
+
+_NdefMessageImpl::~_NdefMessageImpl(void)
+{
+
+}
+
+bool
+_NdefMessageImpl::Equals(const Tizen::Base::Object& obj) const
+{
+ const _NdefMessageImpl* pOther = dynamic_cast <const _NdefMessageImpl*>(&obj);
+
+ if (pOther == null)
+ {
+ return false;
+ }
+
+ if (pOther == this)
+ {
+ return true;
+ }
+
+ return __pRecordList->Equals(*(pOther->__pRecordList));
+}
+
+int
+_NdefMessageImpl::GetHashCode(void) const
+{
+ return __pRecordList->GetHashCode();
+}
+
+result
+_NdefMessageImpl::AppendRecord(const NdefRecord& record)
+{
+ result r = E_SUCCESS;
+ String recordId;
+ NdefRecordType recordType;
+ NdefRecordTypeNameFormat tnf = NDEF_TNF_EMPTY;
+ String typeName;
+
+ recordId = record.GetPayloadId();
+
+ if (!recordId.IsEmpty())
+ {
+ // Checks whether the same id already exists or not
+ NdefRecord* pRecord = GetRecord(recordId);
+ SysTryReturnResult(NID_NET_NFC, pRecord == null, E_INVALID_ARG, "Invalid argument is used. NDEF record with the same payload identifier already exists.");
+ }
+
+ recordType = record.GetRecordType();
+ tnf = recordType.GetNameFormat();
+ typeName = recordType.GetName();
+
+ if (((tnf == NDEF_TNF_WELL_KNOWN) || (tnf == NDEF_TNF_MIME_MEDIA) || (tnf == NDEF_TNF_ABSOLUTE_URI) ||
+ (tnf == NDEF_TNF_EXTERNAL))
+ && typeName.IsEmpty())
+ {
+ SysLogException(NID_NET_NFC, E_INVALID_ARG,
+ "Invalid argument is used. The NDEF record to be appended has an empty string as the type name.");
+ return E_INVALID_ARG;
+ }
+
+ // Propagates the result (E_SUCCESS or E_OUT_OF_MEMORY)
+ r = __pRecordList->Add(record);
+
+ // Makes a link to NdefMesasge
+ _NdefRecordImpl::SetMessageImpl(record, this);
+
+ return r;
+}
+
+int
+_NdefMessageImpl::GetRecordsCount() const
+{
+ return __pRecordList->GetCount();
+}
+
+NdefRecord*
+_NdefMessageImpl::GetRecordAt(int index) const
+{
+ return dynamic_cast<NdefRecord*>(__pRecordList->GetAt(index));
+}
+
+NdefRecord*
+_NdefMessageImpl::GetRecord(const Tizen::Base::String& payloadId) const
+{
+ int count = __pRecordList->GetCount();
+ NdefRecord* pRecord = null;
+ ClearLastResult();
+
+ for (int i = 0; i < count; i++)
+ {
+ pRecord = dynamic_cast<NdefRecord*>(__pRecordList->GetAt(i));
+ if (pRecord && pRecord->GetPayloadId() == payloadId)
+ {
+ return pRecord;
+ }
+ }
+
+ SetLastResult(E_OBJ_NOT_FOUND);
+ return null;
+}
+
+result
+_NdefMessageImpl::IndexOf(const NdefRecord& record, int& index) const
+{
+ return __pRecordList->IndexOf(record, index);
+}
+
+result
+_NdefMessageImpl::InsertRecordAt(const NdefRecord& record, int index)
+{
+ result r = E_SUCCESS;
+ String recordId;
+ NdefRecordType recordType;
+ NdefRecordTypeNameFormat tnf = NDEF_TNF_EMPTY;
+ String typeName;
+
+ recordId = record.GetPayloadId();
+
+ if (!recordId.IsEmpty())
+ {
+ // Checks whether the same id already exists or not
+ NdefRecord* pRecord = GetRecord(recordId);
+ SysTryReturnResult(NID_NET_NFC, pRecord == null, E_INVALID_ARG, "Invalid argument is used. NDEF record with the same payload identifier already exists.");
+ }
+
+ recordType = record.GetRecordType();
+ tnf = recordType.GetNameFormat();
+ typeName = recordType.GetName();
+
+ if (((tnf == NDEF_TNF_WELL_KNOWN) || (tnf == NDEF_TNF_MIME_MEDIA) || (tnf == NDEF_TNF_ABSOLUTE_URI) ||
+ (tnf == NDEF_TNF_EXTERNAL))
+ && typeName.IsEmpty())
+ {
+ SysLogException(NID_NET_NFC, E_INVALID_ARG,
+ "Invalid argument is used. The NDEF record to be appended has an empty string as the type name.");
+ return E_INVALID_ARG;
+ }
+
+ // Propagates the result (E_SUCCESS, E_OUT_OF_RANGE, or E_OUT_OF_MEMORY)
+ r = __pRecordList->InsertAt(record, index);
+
+ // Makes a link to NdefMesasge
+ if (r == E_SUCCESS)
+ {
+ _NdefRecordImpl::SetMessageImpl(record, this);
+ }
+
+
+ return r;
+}
+
+result
+_NdefMessageImpl::RemoveRecordAt(int index, bool deallocate)
+{
+ result r = E_OUT_OF_RANGE;
+ NdefRecord* pPrivNdefRecord = null;
+
+ pPrivNdefRecord = dynamic_cast<NdefRecord*>(__pRecordList->GetAt(index));
+
+ if (pPrivNdefRecord)
+ {
+ // Propagates the result (E_SUCCESS or E_OUT_OF_RANGE)
+ r = __pRecordList->RemoveAt(index, deallocate);
+
+ // Removes the link to NdefMesasge
+ if (r == E_SUCCESS && deallocate == false)
+ {
+ _NdefRecordImpl::SetMessageImpl(*pPrivNdefRecord, null);
+ }
+ }
+
+ return r;
+}
+
+result
+_NdefMessageImpl::SetRecordAt(const NdefRecord& record, int index, bool deallocate)
+{
+ result r = E_OUT_OF_RANGE;
+ NdefRecord* pPrivNdefRecord = null;
+ String recordId;
+ NdefRecordType recordType;
+ NdefRecordTypeNameFormat tnf = NDEF_TNF_EMPTY;
+ String typeName;
+
+ recordId = record.GetPayloadId();
+
+ if (!recordId.IsEmpty())
+ {
+ // Checks whether the same id already exists or not
+ NdefRecord* pRecord = GetRecord(recordId);
+
+ if (pRecord)
+ {
+ int searchIndex = -1;
+ result res = E_SUCCESS;
+ res = __pRecordList->IndexOf(*pRecord, searchIndex);
+ SysTryReturnResult(NID_NET_NFC, searchIndex == index, E_INVALID_ARG,
+ "Invalid argument is used. NDEF record with the same payload identifier already exists.");
+ }
+ }
+
+ recordType = record.GetRecordType();
+ tnf = recordType.GetNameFormat();
+ typeName = recordType.GetName();
+
+ if (((tnf == NDEF_TNF_WELL_KNOWN) || (tnf == NDEF_TNF_MIME_MEDIA) || (tnf == NDEF_TNF_ABSOLUTE_URI) ||
+ (tnf == NDEF_TNF_EXTERNAL))
+ && typeName.IsEmpty())
+ {
+ SysLogException(NID_NET_NFC, E_INVALID_ARG,
+ "Invalid argument is used. The NDEF record to be appended has an empty string as the type name.");
+ return E_INVALID_ARG;
+ }
+
+ pPrivNdefRecord = dynamic_cast<NdefRecord*>( __pRecordList->GetAt(index));
+
+ if (pPrivNdefRecord)
+ {
+ // Propagates the result (E_SUCCESS or E_OUT_OF_RANGE)
+ r = __pRecordList->SetAt(record, index, deallocate);
+ if (r == E_SUCCESS)
+ {
+ _NdefRecordImpl::SetMessageImpl(record, this);
+
+ // Remove the link to NdefMesasge
+ if (deallocate == false)
+ {
+ _NdefRecordImpl::SetMessageImpl(*pPrivNdefRecord, null);
+ }
+ }
+ }
+
+ return r;
+}
+
+void
+_NdefMessageImpl::RemoveAllRecords(bool deallocate)
+{
+ int count = __pRecordList->GetCount();
+ NdefRecord* pPrivNdefRecord = null;
+
+ // Removes the link to NdefMesasge
+ if (deallocate == false)
+ {
+ for (int i = 0; i < count; i++)
+ {
+ pPrivNdefRecord = dynamic_cast<NdefRecord*>(__pRecordList->GetAt(i));
+
+ if (pPrivNdefRecord)
+ {
+ _NdefRecordImpl::SetMessageImpl(*pPrivNdefRecord, null);
+ }
+ }
+ }
+
+ __pRecordList->RemoveAll(deallocate);
+}
+
+ByteBuffer*
+_NdefMessageImpl::ToByteBufferN(const NdefMessage& message) const
+{
+ return _NdefMessageUtil::ToByteBufferN(message);
+}
+
+_NdefMessageImpl&
+_NdefMessageImpl::operator =(const _NdefMessageImpl& rhs)
+{
+ IList* pSourceList = null;
+ unique_ptr<LinkedList, AllElementsDeleter> pTempList;
+ int recordCount = 0;
+
+ if (this != &rhs)
+ {
+ pSourceList = rhs.__pRecordList.get();
+ pTempList.reset(new (std::nothrow) LinkedList());
+ SysTryReturn(NID_NET_NFC, pTempList != null, *this, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ recordCount = pSourceList->GetCount();
+
+ for (int i = 0; i < recordCount; i++)
+ {
+ NdefRecord* pSrcRecord = static_cast<NdefRecord*>(pSourceList->GetAt(i));
+ NdefRecord* pNewRecord = new (std::nothrow) NdefRecord(*pSrcRecord);
+ SysTryReturn(NID_NET_NFC, pNewRecord != null, *this, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ pTempList->Add(*pNewRecord);
+ }
+ __pRecordList.reset(pTempList.release());
+ }
+
+ return *this;
+}
+
+NdefMessage*
+_NdefMessageImpl::GetCloneSharingPayloadN(const NdefMessage& srcMessage)
+{
+ result r = E_SUCCESS;
+ const NdefRecord* pSrcRecord = null;
+ const ByteBuffer* pSrcPayload = null;
+ unique_ptr<NdefMessage, _NdefMessageDeleter> pDstMessage;
+ unique_ptr<NdefRecord> pDstRecord;
+ int recordCount = 0;
+
+ pDstMessage.reset(new (std::nothrow) NdefMessage());
+ SysTryReturn(NID_NET_NFC, pDstMessage != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ recordCount = srcMessage.GetRecordsCount();
+ for (int i = 0; i < recordCount; i++)
+ {
+ pSrcRecord = srcMessage.GetRecordAt(i);
+ pDstRecord.reset(new (std::nothrow) NdefRecord(pSrcRecord->GetRecordType()));
+ SysTryReturn(NID_NET_NFC, pDstRecord != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ pDstRecord->SetPayloadId(pSrcRecord->GetPayloadId());
+ pSrcPayload = pSrcRecord->GetPayload();
+ if (pSrcPayload != null)
+ {
+ pDstRecord->SetPayload(*pSrcPayload); // shallow copy
+ }
+
+ r = pDstMessage->AppendRecord(*pDstRecord); // transfer the ownership of pDstRecord to pDstMessage
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, null, r, "[%s] Adding a new NdefRecord failed.", GetErrorMessage(r));
+ pDstRecord.release();
+ }
+
+ return pDstMessage.release();
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfc_NdefMessageUtil.cpp
+// @brief This is the implementation file for _NdefMessageUtil Class.
+//
+// This file contains the implementation of _NdefMessageUtil Class.
+//
+
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseColLinkedList.h>
+#include <FBaseUtilStringUtil.h>
+#include <FBaseCharacter.h>
+#include <FNetNfcNdefRecord.h>
+#include <FNetNfcNdefRecordType.h>
+#include <FBaseSysLog.h>
+#include "FNetNfc_NdefMessageUtil.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+enum _NDEFRercodFlags
+{
+ NDEF_IL = 0x08, // idLen is present.
+ NDEF_SR = 0x10, // Short record.
+ NDEF_CF = 0x20, // Chunk flag.
+ NDEF_ME = 0x40, // Message end.
+ NDEF_MB = 0x80 // Message begin.
+};
+
+static const int MINIMUM_RECORD_SIZE = 3;
+static const String DNS_SYMBOLS(L".-");
+static const String OTHER_SYMBOLS(L"()+,-:=@;$_!*'.");
+
+
+_NdefMessageUtil::_NdefMessageUtil(void)
+{
+}
+
+_NdefMessageUtil::~_NdefMessageUtil(void)
+{
+}
+
+result
+ParseRecord(NdefRecordType& recordtype, bool& cf, String& payloadId, ByteBuffer& buf_payload, Tizen::Base::ByteBuffer& data)
+{
+ result r = E_SUCCESS;
+ String typeName;
+ char* pType = null;
+ char* pId = null;
+ byte flags = 0;
+ byte tnf = 0;
+ byte idLen = 0;
+ unsigned int payloadLen = 0;
+ bool isShortRecord = false;
+ bool isIdLenExist = false;
+
+ r = data.GetByte(flags);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to get Bytes from Byte Buffer");
+
+ // The first byte
+ //
+ // +____+____+____+____+____+____+____+____+
+ // | MB | ME | CF | SR | IL | TNF |
+ // +____+____+____+____+____+____+____+____+
+ //
+
+ tnf = flags & 0x07;
+
+ NdefRecordType recordType = NdefRecordType((NdefRecordTypeNameFormat) tnf);
+
+ isIdLenExist = flags & NDEF_IL;
+ isShortRecord = flags & NDEF_SR;
+ cf = flags & NDEF_CF;
+
+ // The second byte
+ byte typeLen = 0;
+ r = data.GetByte(typeLen);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to get Bytes from Byte Buffer");
+
+ // The third byte
+ if (isShortRecord == true)
+ {
+ r = data.GetByte(flags);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to get Bytes from Byte Buffer");
+ payloadLen = (unsigned int) flags;
+ }
+ else
+ {
+ byte temp = 0;
+ for (int i = 3; i >= 0; i--)
+ {
+ r = data.GetByte(temp);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to get Bytes from Byte Buffer");
+ payloadLen |= (temp << 8 * i);
+ }
+ }
+
+ // ID Length.
+ if (isIdLenExist == true)
+ {
+ r = data.GetByte(idLen);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to get Bytes from Byte Buffer");
+ }
+
+ // Type
+ pType = new (std::nothrow) char[typeLen + 1];
+ SysTryCatch(NID_NET_NFC, pType != null, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ if (typeLen > 0)
+ {
+ r = data.GetArray((byte*) pType, 0, (int) typeLen);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] Unable to get Array from Byte Buffer");
+ }
+ pType[typeLen] = '\0';
+ typeName.Append(pType);
+ delete[] pType;
+ pType = null;
+
+ if (recordType.GetNameFormat() != NDEF_TNF_EMPTY)
+ {
+ recordType.SetName(typeName);
+ }
+ recordtype = recordType;
+
+ if (isIdLenExist == true && idLen > 0)
+ {
+ pId = new (std::nothrow) char[idLen + 1];
+ SysTryCatch(NID_NET_NFC, pId != null, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] Insufficient Memory");
+ r = data.GetArray((byte*) pId, 0, (int) idLen);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] Unable to get Array from Byte Buffer");
+ pId[idLen] = '\0';
+ String temp(pId);
+
+ delete[] pId;
+ pId = null;
+ payloadId = temp;
+ }
+ if (payloadLen > 0)
+ {
+ buf_payload.Construct(payloadLen);
+
+ SysTryCatch(NID_NET_NFC, data.GetRemaining() >= (int) payloadLen, r = E_SYSTEM, r, "[E_SYSTEM] Unable to get payload");
+
+ r = buf_payload.SetArray(data.GetPointer(), data.GetPosition(), payloadLen);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] Unable to set Array from Byte Buffer");
+ // Move Current Position as paylaod length
+ data.SetPosition(data.GetPosition() + payloadLen);
+ buf_payload.SetPosition(0);
+ }
+
+ SysLog(NID_NET_NFC, "Record: [TNF:0x%02X, Chunk:%s, SR(Short Record):%s, ID:%s, Payload:%dbytes]",
+ tnf, cf ? "Yes" : "No", isShortRecord ? "Yes" : "No", isIdLenExist ? "Exist" : "Not Exist", payloadLen);
+
+ return r;
+
+CATCH:
+ if (pType)
+ {
+ delete[] pType;
+ }
+
+ if (pId)
+ {
+ delete[] pId;
+ }
+
+ return r;
+}
+
+Tizen::Base::ByteBuffer*
+_NdefMessageUtil::ToByteBufferN(const NdefMessage& ndefMessage)
+{
+ result r = E_SUCCESS;
+
+ ByteBuffer* pMessage = null;
+ ByteBuffer* pId = null;
+ ByteBuffer* pType = null;
+
+ byte flags = 0;
+ int messageSize = 0;
+ int payloadLen = 0;
+
+ int recordCount = ndefMessage.GetRecordsCount();
+
+ if (recordCount == 0)
+ {
+ SetLastResult(E_INVALID_DATA);
+ SysLog(NID_NET_NFC, "The NDEF message does not contain any NDEF records");
+ return null;
+ }
+
+ ByteBuffer* pRecords = new (std::nothrow) ByteBuffer[recordCount];
+ SysTryCatch(NID_NET_NFC, pRecords != null, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ for (int i = 0; i < recordCount; i++)
+ {
+ bool sr = false;
+ bool il = false;
+ flags = 0;
+
+ // first record
+ if (i == 0)
+ {
+ flags |= NDEF_MB;
+ }
+
+ // last record
+ if (i == recordCount - 1)
+ {
+ flags |= NDEF_ME;
+ }
+
+ NdefRecord* pRecord = ndefMessage.GetRecordAt(i);
+ SysTryCatch(NID_NET_NFC, pRecord != null, r = E_SYSTEM, r, "Record is invalid");
+
+ const ByteBuffer* pPayload = pRecord->GetPayload();
+ if (pPayload)
+ {
+ payloadLen = pPayload->GetRemaining();
+ if (payloadLen < 256)
+ {
+ sr = true;
+ flags |= NDEF_SR;
+ }
+ }
+ else
+ {
+ payloadLen = 0;
+ sr = true;
+ flags |= NDEF_SR;
+ }
+
+ String id = pRecord->GetPayloadId();
+
+ unsigned char idLen = id.GetLength();
+
+ if (idLen > 0)
+ {
+ flags |= NDEF_IL;
+ il = true;
+ }
+ NdefRecordType recordtype = pRecord->GetRecordType();
+ NdefRecordTypeNameFormat tnf = recordtype.GetNameFormat();
+ flags |= tnf;
+
+ String typeName = recordtype.GetName();
+
+ byte typeLen = typeName.GetLength();
+
+ int recordSize = 0;
+ recordSize = 1 + //first byte flags
+ 1 + //type length
+ ((sr == true) ? 1 : 4) + //payload length
+ ((il == true) ? 1 : 0) + //id length
+ typeLen + //type
+ idLen + //id
+ payloadLen; // payload
+
+ SysLog(NID_NET_NFC, "Record: [TNF:0x%02X, SR(Short Record):%s, ID:%s, Payload:%dbytes]",
+ tnf, sr ? "Yes" : "No", il ? "Exist" : "Not Exist", payloadLen);
+
+ r = pRecords[i].Construct(recordSize);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ // Set Flags
+ r = pRecords[i].SetByte(flags);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] A system error has been occurred.");
+
+ // Set Type Length
+ r = pRecords[i].SetByte(typeLen);
+
+ // Set Payload Length
+ if (sr == true)
+ {
+ r = pRecords[i].SetByte((byte) payloadLen);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] A system error has been occurred.");
+ }
+ else
+ {
+ for (int j = 3; j >= 0; j--)
+ {
+ byte temp = (byte) ((payloadLen >> 8 * j) & 0x000000ff);
+ SysLog(NID_NET_NFC, "PayloadLen = %d, byte[%d] = %x", payloadLen, 3 - j, temp);
+ r = pRecords[i].SetByte(temp);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] A system error has been occurred.");
+ }
+ }
+
+ //Set Id Length
+ if (il == true)
+ {
+ r = pRecords[i].SetByte(idLen);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] A system error has been occurred.");
+ }
+
+ //set type name
+ if (typeLen > 0)
+ {
+ pType = Tizen::Base::Utility::StringUtil::StringToUtf8N(typeName);
+ if (pType != null)
+ {
+ r = pRecords[i].SetArray(pType->GetPointer(), 0, typeLen);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] A system error has been occurred.");
+ delete pType;
+ pType = null;
+ }
+ }
+
+ //set id name
+ if (il == true)
+ {
+ pId = Tizen::Base::Utility::StringUtil::StringToUtf8N(id);
+ if (pId != null)
+ {
+ r = pRecords[i].SetArray(pId->GetPointer(), 0, idLen);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] A system error has been occurred.");
+ delete pId;
+ pId = null;
+ }
+ }
+
+ //set Payload
+ if (pPayload)
+ {
+ r = pRecords[i].SetArray(pPayload->GetPointer(), 0, payloadLen);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] A system error has been occurred.");
+ }
+
+ pRecords[i].SetPosition(0);
+ messageSize += recordSize;
+ }
+
+ pMessage = new (std::nothrow) ByteBuffer();
+ SysTryCatch(NID_NET_NFC, pMessage != null, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ r = pMessage->Construct(messageSize);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] A system error has been occurred.");
+
+ for (int i = 0; i < recordCount; i++)
+ {
+ r = pMessage->CopyFrom(pRecords[i]);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] A system error has been occurred.");
+ }
+ pMessage->Flip();
+
+ delete[] pRecords;
+
+ SetLastResult(E_SUCCESS);
+ return pMessage;
+
+CATCH:
+ SetLastResult(r);
+
+ delete[] pRecords;
+ delete pId;
+ delete pType;
+ delete pMessage;
+
+ return null;
+}
+
+NdefMessage*
+_NdefMessageUtil::ToNdefMessageN(const Tizen::Base::ByteBuffer& buffer)
+{
+
+ result r = E_SUCCESS;
+ ByteBuffer* pBuffer = null;
+ NdefMessage* pNdefMessage = null;
+ NdefRecord* pRecord = null;
+ LinkedList* pChunkedPayloadList = null;
+ ByteBuffer* pPayload = null;
+
+ int size = buffer.GetRemaining();
+ SysTryCatch(NID_NET_NFC, size > 0, r = E_INVALID_FORMAT, r, "[E_INVALID_FORMAT] Cannot be formulated to NDEF message");
+
+ // copy view of buffer
+ pBuffer = new (std::nothrow) ByteBuffer;
+ SysTryCatch(NID_NET_NFC, pBuffer != null, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] Memory Insufficient");
+ r = pBuffer->Construct(buffer);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] A failure occurred from the underlying system");
+
+ // New NdefMessage
+ pNdefMessage = new (std::nothrow) NdefMessage();
+ SysTryCatch(NID_NET_NFC, pNdefMessage != null, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ while (pBuffer->GetRemaining() >= MINIMUM_RECORD_SIZE)
+ {
+
+ NdefRecordType recordType;
+ bool cf = false;
+ String payloadId;
+
+ pPayload = new (std::nothrow) ByteBuffer();
+ SysTryCatch(NID_NET_NFC, pPayload != null, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ r = ParseRecord(recordType, cf, payloadId, *pPayload, *pBuffer);
+ if (r != E_SUCCESS)
+ {
+ break;
+ }
+
+ pRecord = new (std::nothrow) NdefRecord(recordType);
+ SysTryCatch(NID_NET_NFC, pRecord != null, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ if (payloadId.IsEmpty() == false)
+ {
+ r = pRecord->SetPayloadId(payloadId);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, , r, "");
+ }
+
+ // TODO: Handle Only 0x00~Ox05
+ // Chunk Assembly
+ if (cf == 1)
+ {
+ int payloadLen = 0;
+ ByteBuffer* pAssembledPayload = null;
+
+ pChunkedPayloadList = new (std::nothrow) LinkedList();
+ SysTryCatch(NID_NET_NFC, pChunkedPayloadList != null, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ int chunkedPayloadLen = pPayload->GetRemaining();
+
+ payloadLen += chunkedPayloadLen;
+
+ pChunkedPayloadList->Add(*pPayload);
+
+ do
+ {
+ pPayload = new (std::nothrow) ByteBuffer();
+ SysTryCatch(NID_NET_NFC, pPayload != null, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ r = ParseRecord(recordType, cf, payloadId, *pPayload, *pBuffer);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, r = E_INVALID_FORMAT, r,
+ "[E_INVALID_FORMAT] Cannot be formulated to NDEF message");
+ SysTryCatch(NID_NET_NFC,
+ recordType.GetNameFormat() == 0x06, r = E_INVALID_FORMAT, r,
+ "[E_INVALID_FORMAT] Cannot be formulated to NDEF message");
+
+ pChunkedPayloadList->Add(*pPayload);
+ payloadLen += chunkedPayloadLen;
+
+ }
+ while (cf == 1);
+
+ // Assemble Payload;
+ pAssembledPayload = new (std::nothrow) ByteBuffer();
+ SysTryCatch(NID_NET_NFC, pAssembledPayload != null, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ pAssembledPayload->Construct(payloadLen);
+ for (int i = 0; i < pChunkedPayloadList->GetCount(); i++)
+ {
+ r = pAssembledPayload->CopyFrom(*((ByteBuffer*) (pChunkedPayloadList->GetAt(i))));
+ }
+
+ r = pRecord->SetPayload(*pAssembledPayload);
+ delete pAssembledPayload;
+
+ r = pNdefMessage->AppendRecord(*pRecord);
+
+ pChunkedPayloadList->RemoveAll(true);
+ delete pChunkedPayloadList;
+ pChunkedPayloadList = null;
+
+ }
+ else
+ {
+ r = pRecord->SetPayload(*pPayload);
+ delete pPayload;
+ pPayload = null;
+ r = pNdefMessage->AppendRecord(*pRecord);
+ }
+
+
+ }
+
+ SysTryCatch(NID_NET_NFC,
+ pNdefMessage->GetRecordsCount() != 0, r = E_INVALID_FORMAT, r,
+ "[E_INVALID_FORMAT] Cannot be formulated to NDEF message");
+
+ delete pBuffer;
+ pBuffer = null;
+ SetLastResult(E_SUCCESS);
+ return pNdefMessage;
+
+CATCH:
+ SetLastResult(r);
+
+ if (pPayload)
+ {
+ delete pPayload;
+ }
+
+ if (pBuffer)
+ {
+ delete pBuffer;
+ }
+ if (pNdefMessage)
+ {
+ pNdefMessage->RemoveAllRecords(true);
+ delete pNdefMessage;
+ }
+
+ // Not appended record
+ if (pRecord != null)
+ {
+ delete pRecord;
+ pRecord = null;
+ }
+
+ if (pChunkedPayloadList)
+ {
+ pChunkedPayloadList->RemoveAll(true);
+ delete pChunkedPayloadList;
+ pChunkedPayloadList = null;
+ }
+ return null;
+}
+
+bool
+IsValidMIMEChar(const Tizen::Base::String& name)
+{
+ wchar_t chr = 0;
+ int index = 0;
+
+ String unSupportedSymbols = "\"()/:;<=>&\\";
+
+ for (int i = 0; i < name.GetLength(); i++)
+ {
+ name.GetCharAt(i, chr);
+ unSupportedSymbols.IndexOf(chr, 0, index);
+ SysTryReturn(NID_NET_NFC, index == -1, false, E_SYSTEM, "Name contains unsupported character");
+ }
+
+ return true;
+}
+
+bool
+IsValidMIMEType(const Tizen::Base::String& name)
+{
+ //Assume that there won't be "Content Type:" prefix for MIME type name
+
+ int index = 0;
+ int indexSubType = 0;
+ String type;
+ String subType;
+ result r = E_SUCCESS;
+
+ r = name.IndexOf(L"/", 0, index);
+ SysTryReturn(NID_NET_NFC, index != -1, false, E_SYSTEM, "Cannot find type seperator");
+
+
+ r = name.IndexOf(L";", index, indexSubType);
+ if (IsFailed(r))
+ {
+ SysLog(NID_NET_NFC, "Cannot find type ';'");
+ }
+
+ r = name.SubString(0, index, type);
+ if (indexSubType != -1)
+ {
+ r = name.SubString(index + 1, (indexSubType - index - 1), subType);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, false, E_SYSTEM, "Failed to get Substring");
+ }
+ else
+ {
+ r = name.SubString(index + 1, subType);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, false, E_SYSTEM, "Failed to get Substring");
+ }
+
+ SysTryReturn(NID_NET_NFC, IsValidMIMEChar(type), false, E_SYSTEM, "Invalid Type");
+ SysTryReturn(NID_NET_NFC, IsValidMIMEChar(subType), false, E_SYSTEM, "Invalid Subtype");
+
+ return true;
+}
+
+bool
+IsValidDnsChar(const Tizen::Base::String& name)
+{
+ wchar_t chr = 0;
+ int index = 0;
+ for (int i = 0; i < name.GetLength(); i++)
+ {
+ name.GetCharAt(i, chr);
+
+ if (Character::IsDigit(chr) || Character::IsLetter(chr))
+ {
+ continue;
+ }
+
+ DNS_SYMBOLS.IndexOf(chr, 0, index);
+ SysTryReturn(NID_NET_NFC, index != -1, false, E_SYSTEM, "Name contains non-WTK Character");
+ }
+ return true;
+}
+
+bool
+IsValidWktChar(const Tizen::Base::String& name)
+{
+ wchar_t chr = 0;
+ int index = 0;
+
+ for (int i = 0; i < name.GetLength(); i++)
+ {
+ name.GetCharAt(i, chr);
+
+ if (Character::IsDigit(chr) || Character::IsLetter(chr))
+ {
+ continue;
+ }
+
+ OTHER_SYMBOLS.IndexOf(chr, 0, index);
+ SysTryReturn(NID_NET_NFC, index != -1, false, E_SYSTEM, "Name contains non-WTK Character");
+ }
+ return true;
+}
+
+bool
+IsValidExtName(const Tizen::Base::String& name)
+{
+ result r = E_SUCCESS;
+
+ String dnsPart;
+ String namePart;
+ int index = 0;
+
+ // Currently, name doesn't contain prefix
+ // SysTryLogReturn (NID_NET_NFC,(name.StartsWith(PREFIX_EXT,0) && name.GetLength() > PREFIX_EXT.GetLength()),
+ // false, "Name doesn't contain prefix urn:nfc:wkt: "));
+
+
+ r = name.IndexOf(L":", 0, index);
+ SysTryReturn(NID_NET_NFC, index > 0 && index < (name.GetLength() - 1), false, E_SYSTEM, "Name doesn't contain ':'");
+
+ r = name.SubString(0, index, dnsPart);
+ r = name.SubString(index + 1, namePart);
+
+ SysTryReturn(NID_NET_NFC, IsValidDnsChar(dnsPart), false, E_SYSTEM, "Invalid DNS Part");
+ SysTryReturn(NID_NET_NFC, IsValidWktChar(namePart), false, E_SYSTEM, "Invalid Name Part");
+
+ return true;
+}
+
+bool
+IsValidWKTName(const Tizen::Base::String& name)
+{
+ wchar_t chr = 0;
+
+ // Currently, name doesn't contain prefix
+ // SysTryLogReturn (MID,FNETNFC,(name.StartsWith(PREFIX_WKT,0) && name.GetLength() > PREFIX_WKT.GetLength()),
+ // false, "Name doesn't contain prefix urn:nfc:wkt: "));
+
+
+ // First symbol must be a letter or digit only
+ name.GetCharAt(0, chr);
+ SysTryReturn(NID_NET_NFC, Character::IsLetter(chr) || Character::IsDigit(
+ chr), false, E_SYSTEM, "First symbol must be a letter or digit only");
+
+ SysTryReturn(NID_NET_NFC, IsValidWktChar(name), false, E_SYSTEM, "Invalid WKT name");
+
+ return true;
+}
+
+bool
+_NdefMessageUtil::IsValidRecordType(NdefRecordTypeNameFormat type, const Tizen::Base::String& name)
+{
+ switch (type)
+ {
+ case NDEF_TNF_EMPTY:
+ case NDEF_TNF_UNKNOWN:
+ return true;
+
+ case NDEF_TNF_WELL_KNOWN:
+ return IsValidWKTName(name);
+
+ case NDEF_TNF_MIME_MEDIA:
+ return IsValidMIMEType(name);
+
+ case NDEF_TNF_ABSOLUTE_URI:
+ return true;
+
+ case NDEF_TNF_EXTERNAL:
+ return IsValidExtName(name);
+
+ default:
+ SysLog(NID_NET_NFC, "Unknown record type name format: %d ", type);
+ return false;
+ }
+
+}
+
+IList*
+_NdefMessageUtil::GetEquivalentRecordTypesN(const NdefRecordType& recordType)
+{
+
+ result r = E_SUCCESS;
+
+ NdefRecordTypeNameFormat tnf = recordType.GetNameFormat();
+ NdefRecordType* pRecordType = null;
+ LinkedList* pList = null;
+ String name;
+ int subTypeStartIndex = 0;
+ int subTypeEndIndex = 0;
+ String type;
+ String subType;
+ String mimeName;
+
+ pList = new (std::nothrow) LinkedList();
+ SysTryCatch(NID_NET_NFC, pList != null, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ switch (tnf)
+ {
+ case NDEF_TNF_EMPTY:
+ case NDEF_TNF_WELL_KNOWN:
+ case NDEF_TNF_ABSOLUTE_URI:
+ case NDEF_TNF_EXTERNAL:
+ case NDEF_TNF_UNKNOWN:
+ pRecordType = new (std::nothrow) NdefRecordType(recordType);
+ SysTryCatch(NID_NET_NFC, pRecordType != null, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ pList->Add(*pRecordType);
+ break;
+
+ case NDEF_TNF_MIME_MEDIA:
+ name = recordType.GetName();
+
+ pRecordType = new (std::nothrow) NdefRecordType(recordType);
+ SysTryCatch(NID_NET_NFC, pRecordType != null, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ pList->Add(*pRecordType);
+
+ if (name.StartsWith(L"*", 0) == false)
+ {
+ r = name.IndexOf(L"/", 0, subTypeStartIndex);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] name doesn't contain '/'");
+
+ r = name.SubString(0, subTypeStartIndex, type);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] A system error occurred on getting the type");
+
+ r = name.IndexOf(L";", subTypeStartIndex, subTypeEndIndex);
+ if (r == E_SUCCESS)
+ {
+ r = name.SubString(subTypeStartIndex + 1, (subTypeEndIndex - subTypeStartIndex - 1), subType);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] A system error occurred on getting substring");
+ }
+ else
+ {
+ r = name.SubString(subTypeStartIndex + 1, subType);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] A system error occurred on getting substring");
+ }
+
+ if (subType.Equals(L"*", false) == false)
+ {
+ // Add "type/*"
+ pRecordType = new (std::nothrow) NdefRecordType(NDEF_TNF_MIME_MEDIA);
+ SysTryCatch(NID_NET_NFC, pRecordType != null, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ mimeName.Append(type);
+ mimeName.Append("/*");
+ pRecordType->SetName(mimeName);
+ pList->Add(*pRecordType);
+ }
+
+ // Add */*
+ pRecordType = new (std::nothrow) NdefRecordType(NDEF_TNF_MIME_MEDIA);
+ SysTryCatch(NID_NET_NFC, pRecordType != null, r = E_OUT_OF_MEMORY, r, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ pRecordType->SetName(L"*/*");
+ pList->Add(*pRecordType);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return pList;
+
+CATCH:
+ if (pList != null)
+ {
+ pList->RemoveAll(true);
+ delete pList;
+ pList = null;
+ }
+
+ return null;
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfc_NdefPushManagerEvent.cpp
+// @brief This is the implementation file for _NdefPushManagerEvent class.
+//
+// This file contains the implementation of _NdefPushManagerEvent class.
+//
+
+#include <FBaseRtIEventListener.h>
+#include <FBaseSysLog.h>
+#include <FBaseRtIEventArg.h>
+#include <FNetNfcINdefPushManagerListener.h>
+#include "FNetNfc_NdefPushManagerEvent.h"
+#include "FNetNfc_NdefPushManagerEventArg.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+_NdefPushManagerEvent::_NdefPushManagerEvent(void)
+{
+}
+
+_NdefPushManagerEvent::~_NdefPushManagerEvent(void)
+{
+}
+
+result
+_NdefPushManagerEvent::Construct(void)
+{
+ return _Event::Initialize();
+}
+
+void
+_NdefPushManagerEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
+{
+ result r = E_SUCCESS;
+
+ INdefPushManagerListener* pListener = dynamic_cast <INdefPushManagerListener*>(&listener);
+ SysTryReturnVoidResult(NID_NET_NFC, pListener != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system.");
+
+ const _NdefPushManagerEventArg* pArg = dynamic_cast <const _NdefPushManagerEventArg*>(&arg);
+ SysTryReturnVoidResult(NID_NET_NFC, pArg != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system.");
+
+ r = pArg->GetResult();
+
+ pListener->OnNdefPushMessageSent(r);
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfc_NdefPushManagerEvent.h
+ * @brief This is the header file for the _NdefPushManagerEvent class.
+ *
+ * This header file contains declaration of the _NdefPushManagerEvent class.
+ * The _NdefPushManagerEvent class can call methods of INdefMessageDiscoveryEventListener class.
+ */
+#ifndef _FNET_NFC_INTERNAL_NDEF_PUSH_MANAGER_EVENT_H_
+#define _FNET_NFC_INTERNAL_NDEF_PUSH_MANAGER_EVENT_H_
+
+#include <FOspConfig.h>
+#include <FBaseResult.h>
+#include <FBaseRt_Event.h>
+
+namespace Tizen { namespace Base { namespace Runtime
+{
+class IEventArg;
+class IEventListener;
+} } }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+/**
+ * @class _NdefPushManagerEvent
+ * @brief This class handles the events related to the push of NDEF message.
+ *
+ * When an NDEF message is pushed, the _NdefPushManagerEvent object finds a %INdefPushManagerListener
+ * object and calls an appropriate method of the listener.
+ */
+class _NdefPushManagerEvent
+ : public Tizen::Base::Runtime::_Event
+{
+public:
+ /**
+ * This is the default constructor.
+ */
+ _NdefPushManagerEvent(void);
+
+ /**
+ * This is the class destructor.
+ */
+ virtual ~_NdefPushManagerEvent(void);
+
+ /**
+ * Initializes a new instance of the class
+ *
+ */
+ result Construct(void);
+
+protected:
+ /**
+ * Calls the specified listener's method with the specified argument when event is generated.
+ *
+ * @param[in] listener The event listener which will be received the event
+ * @param[in] arg The event argument to be passed by
+ */
+ void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+ _NdefPushManagerEvent(const _NdefPushManagerEvent& value);
+ _NdefPushManagerEvent& operator =(const _NdefPushManagerEvent& value);
+}; // _NdefPushManagerEvent
+
+} } } //Tizen::Net::Nfc
+#endif // _FNET_NFC_INTERNAL_NDEF_PUSH_MANAGER_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 FNetNfc_NdefPushManagerEventArg.cpp
+// @brief This is the implementation file for _NdefPushManagerEventArg class.
+//
+// This file contains the implementation of _NdefPushManagerEventArg class.
+//
+
+#include <FBaseSysLog.h>
+#include "FNetNfc_NdefPushManagerEventArg.h"
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+_NdefPushManagerEventArg::_NdefPushManagerEventArg(result r)
+ : __r(r)
+{
+}
+
+_NdefPushManagerEventArg::~_NdefPushManagerEventArg(void)
+{
+}
+
+result
+_NdefPushManagerEventArg::GetResult(void) const
+{
+ return __r;
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfc_NdefPushManagerEventArg.h
+ * @brief This is the header file for the _NdefMessageDiscoveryEventArg class.
+ *
+ * This header file contains declaration of the _NdefMessageDiscoveryEventArg class.
+ */
+#ifndef _FNET_NFC_INTERNAL_NDEF_PUSH_MANAGER_EVENT_ARG_H_
+#define _FNET_NFC_INTERNAL_NDEF_PUSH_MANAGER_EVENT_ARG_H_
+
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FBaseRtIEventArg.h>
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+/**
+ * @class _NdefMessageDiscoveryEventArg
+ * @brief This class is used as an argument of methods of the _NdefMessageDiscoveryEvent class.
+ *
+ * When an NDEF message is discovered, the INdefMessageDiscoveryEventListener objects registered to the event are called
+ * with this argument class.
+ */
+class _NdefPushManagerEventArg
+ : public Tizen::Base::Object
+ , public Tizen::Base::Runtime::IEventArg
+{
+public:
+ /**
+ * This is the constructor.
+ *
+ * @param[in] r The sent result.
+ */
+ _NdefPushManagerEventArg(result r);
+
+ /**
+ * This is the class destructor.
+ */
+ ~_NdefPushManagerEventArg(void);
+
+ /**
+ * Gets the sent result.
+ *
+ * @return The sent result
+ */
+ result GetResult(void) const;
+
+private:
+ _NdefPushManagerEventArg(void);
+ _NdefPushManagerEventArg(const _NdefPushManagerEventArg& value);
+ _NdefPushManagerEventArg& operator =(const _NdefPushManagerEventArg& value);
+
+private:
+ result __r;
+
+}; // _NdefPushManagerEventArg
+
+} } } //Tizen::Net::Nfc
+#endif // _FNET_NFC_INTERNAL_NDEF_PUSH_MANAGER_EVENT_ARG_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.1 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// 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 FNetNfc_NdefPushManagerImpl.cpp
+// @brief This is the implementation file for _NdefPushManagerImpl class.
+//
+// This file contains the implementation of _NdefPushManagerImpl class.
+//
+
+#include <unique_ptr.h>
+#include <FAppTypes.h>
+#include <FBaseSysLog.h>
+#include <FNetNfcINdefPushManagerListener.h>
+#include <FNetNfcNdefMessage.h>
+#include "FNetNfc_NfcIpcProxy.h"
+#include "FNetNfc_NdefMessageUtil.h"
+#include "FNetNfc_NdefPushManagerImpl.h"
+#include "FNetNfc_NdefPushManagerEvent.h"
+#include "FNetNfc_NdefPushManagerEventArg.h"
+#include "FNetNfc_NfcSystemAdapter.h"
+
+using namespace std;
+using namespace Tizen::App;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+_NdefPushManagerImpl::_NdefPushManagerImpl(void)
+ : __pSystemAdapter(null)
+ , __pPushEvent(null)
+ , __pPreviousListener(null)
+ , __stateMutex()
+ , __currentState(_NDEF_PUSH_MANAGER_STATE_DISABLED)
+{
+ result r = E_SUCCESS;
+
+ r = __stateMutex.Create();
+ SysTryReturnVoidResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Failed to create the state mutex.");
+
+ // Create the NfcSystemAdapter
+ __pSystemAdapter = _NfcSystemAdapter::GetInstance();
+ SysTryReturnVoidResult(NID_NET_NFC, __pSystemAdapter != null, E_SYSTEM,
+ "[E_SYSTEM] Failed to get the instance of _NfcSystemAdapter.");
+
+ // Create the Push Manager Event
+ unique_ptr<_NdefPushManagerEvent> pPushEvent(new (std::nothrow) _NdefPushManagerEvent());
+ SysTryReturnVoidResult(NID_NET_NFC, pPushEvent != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ r = pPushEvent->Construct();
+ SysTryReturnVoidResult(NID_NET_NFC, r == E_SUCCESS, r,
+ "[%s] Propagating. Construct of an event instance failed.", GetErrorMessage(r));
+
+ r = __pSystemAdapter->AddNdefPushManagerImpl(this);
+ SysTryReturnVoidResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed to add the callack to _NfcSystemAdapter.");
+
+ r = __pSystemAdapter->AddNfcDeviceDiscoveryEventListener(this);
+ SysTryReturnVoidResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed to add the callack to _NfcSystemAdapter.");
+
+ // get the current state
+ __stateMutex.Acquire();
+
+ if (__pSystemAdapter->IsDeviceDetected())
+ {
+ __currentState = _NDEF_PUSH_MANAGER_STATE_CONNECTED;
+ }
+
+ __stateMutex.Release();
+
+ __pPushEvent = pPushEvent.release();
+}
+
+_NdefPushManagerImpl::~_NdefPushManagerImpl(void)
+{
+ if (__pSystemAdapter != null)
+ {
+ __pSystemAdapter->RemoveNdefPushManagerImpl(this);
+ __pSystemAdapter->RemoveNfcDeviceDiscoveryEventListener(this);
+ }
+
+ delete __pPushEvent;
+}
+
+result
+_NdefPushManagerImpl::SetNdefPushManagerListener(INdefPushManagerListener* pListener)
+{
+ result r = E_SUCCESS;
+
+ SysTryReturnResult(NID_NET_NFC, __pPreviousListener != pListener, E_SUCCESS, "the listener instance is already registered.");
+
+ if (__pPreviousListener != null)
+ {
+ // remove the previous INdefPushManagerListener instance from the _NfcPushManagerEvent.
+ r = __pPushEvent->RemoveListener(*__pPreviousListener);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed to remove the previous INdefPushManagerListener.");
+ SysLog(NID_NET_NFC, "Removing the previous INdefPushManagerListener is successful.");
+ __pPreviousListener = null;
+ }
+
+ if (pListener != null)
+ {
+ // add the specified new INdefPushManagerListener instance to the _NfcPushManagerEvent.
+ r = __pPushEvent->AddListener(*pListener, true);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed to add the new INdefPushManagerListener.");
+ SysLog(NID_NET_NFC, "Adding the new INdefPushManagerListener is successful.");
+ __pPreviousListener = pListener;
+ }
+
+ return r;
+}
+
+result
+_NdefPushManagerImpl::Push(const NdefMessage& message)
+{
+ SysLog(NID_NET_NFC, "EntryPoint, [CurrentState:%s]", GetStringOfCurrentState());
+
+ result r = E_SUCCESS;
+
+ __stateMutex.Acquire();
+
+ switch (__currentState)
+ {
+ case _NDEF_PUSH_MANAGER_STATE_CONNECTED:
+ r = __pSystemAdapter->Push(message);
+ if (r == E_SUCCESS)
+ {
+ __currentState = _NDEF_PUSH_MANAGER_PUSH_REQUESTED;
+ }
+ break;
+
+ case _NDEF_PUSH_MANAGER_PUSH_REQUESTED:
+ r = E_DEVICE_BUSY;
+ break;
+
+ case _NDEF_PUSH_MANAGER_STATE_DISABLED:
+ default:
+ r = E_INVALID_STATE;
+ break;
+ }
+
+ __stateMutex.Release();
+
+ if (r != E_SUCCESS)
+ {
+ SysLogException(NID_NET_NFC, r, "[%s] exception occurred on pushing the specified NDEF message.", GetErrorMessage(r));
+ }
+
+ SysLog(NID_NET_NFC, "ExitPoint, [CurrentState:%s], [result:%s]", GetStringOfCurrentState(), GetErrorMessage(r));
+
+ return r;
+}
+
+result
+_NdefPushManagerImpl::ActivateReservedPush(void)
+{
+ result r = E_SUCCESS;
+ _NfcIpcProxy* pProxy = null;
+
+ pProxy = _NfcIpcProxy::GetInstance();
+ SysTryReturnResult(NID_NET_NFC, pProxy != null, E_SYSTEM, "Creating _NfcIpcProxy has failed.");
+
+ r = pProxy->ActivateReservedPush();
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating.");
+
+ return E_SUCCESS;
+}
+
+result
+_NdefPushManagerImpl::DeactivateReservedPush(void)
+{
+ result r = E_SUCCESS;
+ _NfcIpcProxy* pProxy = null;
+
+ pProxy = _NfcIpcProxy::GetInstance();
+ SysTryReturnResult(NID_NET_NFC, pProxy != null, E_SYSTEM, "Creating _NfcIpcProxy has failed.");
+
+ r = pProxy->DeactivateReservedPush();
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating.");
+
+ return E_SUCCESS;
+}
+
+bool
+_NdefPushManagerImpl::IsReservedPushActivated(void) const
+{
+ _NfcIpcProxy* pProxy = null;
+
+ pProxy = _NfcIpcProxy::GetInstance();
+ SysTryReturn(NID_NET_NFC, pProxy != null, false, E_SYSTEM, "[E_SYSTEM] Creating _NfcIpcProxy has failed.");
+
+ return pProxy->IsReservedPushActivated();
+}
+
+Tizen::Base::Collection::IMap*
+_NdefPushManagerImpl::GetReservedPushCandidatesN(void) const
+{
+ _NfcIpcProxy* pProxy = null;
+
+ pProxy = _NfcIpcProxy::GetInstance();
+ SysTryReturn(NID_NET_NFC, pProxy != null, false, E_SYSTEM, "[E_SYSTEM] Creating _NfcIpcProxy has failed.");
+
+ return pProxy->GetReservedPushCandidatesN();
+}
+
+result
+_NdefPushManagerImpl::PickReservedPushMessage(const Tizen::App::AppId& appId)
+{
+ result r = E_SUCCESS;
+ _NfcIpcProxy* pProxy = null;
+
+ pProxy = _NfcIpcProxy::GetInstance();
+ SysTryReturnResult(NID_NET_NFC, pProxy != null, E_SYSTEM, "Creating _NfcIpcProxy has failed.");
+
+ r = pProxy->PickReservedPushMessage(appId);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating.");
+
+ return E_SUCCESS;
+}
+
+Tizen::App::AppId
+_NdefPushManagerImpl::GetPickedReservedPushMessage(void) const
+{
+ result r = E_SUCCESS;
+ _NfcIpcProxy* pProxy = null;
+ AppId ownerAppId;
+
+ ClearLastResult();
+ pProxy = _NfcIpcProxy::GetInstance();
+ SysTryReturn(NID_NET_NFC, pProxy != null, ownerAppId, E_SYSTEM, "[E_SYSTEM] Creating _NfcIpcProxy has failed.");
+
+ r = pProxy->GetPickedReservedPushMessage(ownerAppId);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, ownerAppId, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ return ownerAppId;
+}
+
+void
+_NdefPushManagerImpl::OnNdefPushMessageSent(result r)
+{
+ SysLog(NID_NET_NFC, "EntryPoint, [CurrentState:%s], [result:%s]", GetStringOfCurrentState(), GetErrorMessage(r));
+
+ bool isFired = false;
+
+ __stateMutex.Acquire();
+
+ if (__currentState == _NDEF_PUSH_MANAGER_PUSH_REQUESTED)
+ {
+ __currentState = _NDEF_PUSH_MANAGER_STATE_CONNECTED;
+ isFired = true;
+
+ _NdefPushManagerEventArg* pArg = new (std::nothrow) _NdefPushManagerEventArg(r);
+ SysTryReturnVoidResult(NID_NET_NFC, pArg != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ __pPushEvent->FireAsync(*pArg);
+ }
+
+ __stateMutex.Release();
+
+ SysLog(NID_NET_NFC, "ExitPoint, [CurrentState:%s], [PUSH_SENT_Event:%s]",
+ GetStringOfCurrentState(), isFired ? "Fired" : "NotFired");
+}
+
+void
+_NdefPushManagerImpl::OnNfcDeviceDetected(void)
+{
+ SysLog(NID_NET_NFC, "EntryPoint, [CurrentState:%s]", GetStringOfCurrentState());
+
+ __stateMutex.Acquire();
+
+ if (__currentState == _NDEF_PUSH_MANAGER_STATE_DISABLED)
+ {
+ __currentState = _NDEF_PUSH_MANAGER_STATE_CONNECTED;
+ }
+
+ __stateMutex.Release();
+
+ SysLog(NID_NET_NFC, "ExitPoint, [CurrentState:%s]", GetStringOfCurrentState());
+}
+
+void
+_NdefPushManagerImpl::OnNfcDeviceLost(void)
+{
+ SysLog(NID_NET_NFC, "EntryPoint, [CurrentState:%s]", GetStringOfCurrentState());
+
+ __stateMutex.Acquire();
+
+ if ((__currentState == _NDEF_PUSH_MANAGER_STATE_CONNECTED) || (__currentState == _NDEF_PUSH_MANAGER_PUSH_REQUESTED))
+ {
+ __currentState = _NDEF_PUSH_MANAGER_STATE_DISABLED;
+ }
+
+ __stateMutex.Release();
+
+ SysLog(NID_NET_NFC, "ExitPoint, [CurrentState:%s]", GetStringOfCurrentState());
+}
+
+result
+_NdefPushManagerImpl::RegisterNdefPushMessage(const NdefMessage& message, const Tizen::Base::String& description)
+{
+ result r = E_SUCCESS;
+ _NfcIpcProxy* pProxy = null;
+ ByteBuffer* pMessageBuffer = null;
+
+ SysTryReturnResult(NID_NET_NFC, message.GetRecordsCount() != 0, E_INVALID_ARG,
+ "Invalid argument is used. NDEF message does not contain any NDEF records");
+
+ pProxy = _NfcIpcProxy::GetInstance();
+ SysTryReturnResult(NID_NET_NFC, pProxy != null, E_SYSTEM, "Creating _NfcIpcProxy has failed.");
+
+ pMessageBuffer = _NdefMessageUtil::ToByteBufferN(message);
+ SysTryReturn(NID_NET_NFC, pMessageBuffer != null, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
+
+ r = pProxy->RegisterNdefPushMessage(*pMessageBuffer, description);
+ if (r != E_SUCCESS)
+ {
+ SysLogException(NID_NET_NFC, E_SYSTEM, "[E_SYSTEM] Registering the NDEF push message has failed.");
+ }
+ else
+ {
+ SysLog(NID_NET_NFC, "Registering the NDEF push message is successful.");
+ }
+
+ delete pMessageBuffer;
+
+ return r;
+}
+
+result
+_NdefPushManagerImpl::UnregisterNdefPushMessage(void)
+{
+ result r = E_SUCCESS;
+ _NfcIpcProxy* pProxy = null;
+
+ pProxy = _NfcIpcProxy::GetInstance();
+ SysTryReturnResult(NID_NET_NFC, pProxy != null, E_SYSTEM, "Creating _NfcIpcProxy has failed.");
+
+ r = pProxy->UnregisterNdefPushMessage();
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Unregistering the NDEF push message has failed.");
+
+ SysLog(NID_NET_NFC, "Unregistering the NDEF push message is successful.");
+
+ return E_SUCCESS;
+}
+
+const char*
+_NdefPushManagerImpl::GetStringOfCurrentState(void) const
+{
+ const char* pStateString = null;
+
+ switch (__currentState)
+ {
+ case _NDEF_PUSH_MANAGER_STATE_DISABLED:
+ pStateString = "DISABLED";
+ break;
+
+ case _NDEF_PUSH_MANAGER_STATE_CONNECTED:
+ pStateString = "CONNECTED";
+ break;
+
+ case _NDEF_PUSH_MANAGER_PUSH_REQUESTED:
+ pStateString = "PUSH_REQUESTED";
+ break;
+
+ default:
+ pStateString = "";
+ break;
+ }
+
+ return pStateString;
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfcNdefRecordImpl.cpp
+// @brief This is the implementation file for _NdefRecordImpl class.
+//
+// This file contains the implementation of _NdefRecordImpl class.
+//
+
+#include <FBaseByteBuffer.h>
+#include <FBaseString.h>
+#include <FTextAsciiEncoding.h>
+#include <FNetNfcNdefRecord.h>
+#include <FNetNfcNdefMessage.h>
+#include <FBaseSysLog.h>
+#include "FNetNfc_NdefRecordImpl.h"
+#include "FNetNfc_NdefMessageUtil.h"
+#include "FNetNfc_NdefMessageImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Text;
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+_NdefRecordImpl::_NdefRecordImpl(void)
+ : __type()
+ , __id()
+ , __pPayload(null)
+ , __pMessageImpl(null)
+{
+}
+
+_NdefRecordImpl::_NdefRecordImpl(const NdefRecordType& recordType)
+ : __type(recordType)
+ , __id()
+ , __pPayload(null)
+ , __pMessageImpl(null)
+{
+}
+
+_NdefRecordImpl::_NdefRecordImpl(const _NdefRecordImpl& value)
+ : __type(value.__type)
+ , __id(value.__id)
+ , __pPayload(null)
+ , __pMessageImpl(null)
+{
+ (void) CopyPayloadFrom(value.__pPayload.get());
+}
+
+_NdefRecordImpl::~_NdefRecordImpl(void)
+{
+
+}
+
+bool
+_NdefRecordImpl::Equals(const Tizen::Base::Object& obj) const
+{
+ const _NdefRecordImpl* pOther = dynamic_cast <const _NdefRecordImpl*>(&obj);
+
+ if (pOther == null)
+ {
+ return false;
+ }
+
+ if (pOther == this)
+ {
+ return true;
+ }
+
+ if ((__type.Equals(pOther->__type) == true) && (__id.Equals(pOther->__id) == true))
+ {
+ if ((__pPayload == null) && (pOther->__pPayload == null))
+ {
+ return true;
+ }
+ else if ((__pPayload != null) && (pOther->__pPayload != null))
+ {
+ return __pPayload->Equals(*(pOther->__pPayload));
+ }
+ }
+
+ return false;
+}
+
+int
+_NdefRecordImpl::GetHashCode(void) const
+{
+ int value = 0;
+
+ value = __type.GetHashCode();
+ value ^= __id.GetHashCode();
+ value ^= __pPayload->GetHashCode();
+
+ return value;
+}
+
+Tizen::Base::String
+_NdefRecordImpl::GetPayloadId(void) const
+{
+ return __id;
+}
+
+Tizen::Base::ByteBuffer*
+_NdefRecordImpl::GetPayload(void) const
+{
+ return __pPayload.get();
+}
+
+NdefRecordType
+_NdefRecordImpl::GetRecordType(void) const
+{
+ return __type;
+}
+
+result
+_NdefRecordImpl::SetRecordType(NdefRecordType& type)
+{
+ NdefRecordTypeNameFormat tnf = type.GetNameFormat();
+
+ if (tnf == NDEF_TNF_ALL)
+ {
+ return E_INVALID_ARG;
+ }
+ else if (tnf == NDEF_TNF_EMPTY)
+ {
+ if ((__id.GetLength() > 0) || (__pPayload != null))
+ {
+ return E_INVALID_ARG;
+ }
+ }
+
+ __type = type;
+
+ return E_SUCCESS;
+}
+
+result
+_NdefRecordImpl::SetPayloadId(const Tizen::Base::String& id)
+{
+ result r = E_SUCCESS;
+ NdefRecord* pNdefRecord = null;
+
+ SysTryReturnResult(NID_NET_NFC, __type.GetNameFormat() != NDEF_TNF_EMPTY, E_INVALID_OPERATION, "The record type is NDEF_TNF_EMPTY.");
+
+ SysTryReturnResult(NID_NET_NFC, id.GetLength() < 256, E_MAX_EXCEEDED, "The length of the id should be less than 256.");
+
+ if (id.IsEmpty() == false)
+ {
+ // check if id includes non US-ASCII character or not
+ AsciiEncoding ascii;
+ ByteBuffer* pBuff = ascii.GetBytesN(id);
+ r = GetLastResult();
+ SysTryReturnResult(NID_NET_NFC, pBuff != null, E_INVALID_ENCODING_RANGE, "Name contains characters outside US-ASCII range");
+ delete pBuff;
+
+ // checks the uniqueness of id among all records in the NDEF message and return E_INVALID_ARG.
+ if (__pMessageImpl != null)
+ {
+ pNdefRecord = __pMessageImpl->GetRecord(id);
+ SysTryReturnResult(NID_NET_NFC, (pNdefRecord == null || pNdefRecord->__pImpl == this), E_INVALID_ARG,
+ "Invalid argument is used. The id already exists in the other records of the same NDEF message.");
+ }
+ }
+ __id = id;
+
+ return r;
+}
+
+result
+_NdefRecordImpl::SetPayload(const Tizen::Base::ByteBuffer& payload)
+{
+ result r = E_SUCCESS;
+ unique_ptr<ByteBuffer> pTempPayload;
+
+ SysTryReturnResult(NID_NET_NFC, __type.GetNameFormat() != NDEF_TNF_EMPTY, E_INVALID_OPERATION, "The record type is NDEF_TNF_EMPTY");
+
+ pTempPayload.reset(new (std::nothrow) ByteBuffer());
+ SysTryReturnResult(NID_NET_NFC, pTempPayload != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ // Propagates the result (E_SUCCESS or E_INVALID_ARG)
+ r = pTempPayload->Construct(payload);
+
+ if (r == E_SUCCESS)
+ {
+ //makes the position same as that of specified payload
+ pTempPayload->SetPosition(payload.GetPosition());
+
+ __pPayload.reset(pTempPayload.release());
+ }
+
+ return r;
+}
+
+void
+_NdefRecordImpl::SetMessageImpl(const NdefRecord& record, const _NdefMessageImpl* pNdefMessageImpl)
+{
+ record.__pImpl->__pMessageImpl = const_cast <_NdefMessageImpl*>(pNdefMessageImpl);
+}
+
+_NdefRecordImpl&
+_NdefRecordImpl::operator =(const _NdefRecordImpl& rhs)
+{
+ result r = E_SUCCESS;
+
+ if (this != &rhs)
+ {
+ r = CopyPayloadFrom(rhs.__pPayload.get());
+
+ if (!IsFailed(r))
+ {
+ __type = rhs.__type;
+ __id = rhs.__id;
+ }
+ }
+
+ return *this;
+}
+
+result
+_NdefRecordImpl::CopyPayloadFrom(const Tizen::Base::ByteBuffer* pPayload)
+{
+ ByteBuffer tempView;
+ std::unique_ptr<ByteBuffer> pNewPayload;
+ result r = E_SUCCESS;
+
+ if (pPayload)
+ {
+ // Creates view of payload to use CopyFrom.
+ tempView.Construct(*pPayload);
+
+ // Creates a new payload from the view.
+ unique_ptr<ByteBuffer> pNewPayload(new (std::nothrow) ByteBuffer);
+
+ if (pNewPayload)
+ {
+ pNewPayload->Construct(pPayload->GetCapacity());
+ pNewPayload->CopyFrom(tempView);
+ pNewPayload->SetPosition(pPayload->GetPosition());
+ pNewPayload->SetLimit(pPayload->GetLimit());
+
+ // Changes the member variable to the new payload after completely generated.
+ __pPayload.reset(pNewPayload.release());
+ }
+ else
+ {
+ r = E_OUT_OF_MEMORY;
+ SysLogException(NID_NET_NFC, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ }
+ }
+ else
+ {
+ __pPayload.reset();
+ }
+
+ return r;
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfcNdefRecordTypeImpl.cpp
+// @brief This is the implementation file for _NdefRecordTypeImpl class.
+//
+// This file contains the implementation of _NdefRecordTypeImpl class.
+//
+
+#include <FBaseByteBuffer.h>
+#include <FBaseUtilUri.h>
+#include <FNetNfcNdefRecordType.h>
+#include <FTextAsciiEncoding.h>
+#include <FBaseSysLog.h>
+#include "FNetNfc_NdefRecordTypeImpl.h"
+#include "FNetNfc_NdefMessageUtil.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Text;
+
+static const String NDEF_TNF_WELL_KNOWN_PREFIX("urn:nfc:wkt:");
+static const String NDEF_TNF_EXTERNAL_PREFIX("urn:nfc:ext:");
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+_NdefRecordTypeImpl::_NdefRecordTypeImpl(void)
+ : __format(NDEF_TNF_EMPTY)
+ , __name(L"")
+{
+}
+
+_NdefRecordTypeImpl::_NdefRecordTypeImpl(NdefRecordTypeNameFormat format)
+ : __format(format)
+ , __name(L"")
+{
+}
+
+_NdefRecordTypeImpl::_NdefRecordTypeImpl(const _NdefRecordTypeImpl& value)
+ : __format(value.__format)
+ , __name(value.__name)
+{
+}
+
+_NdefRecordTypeImpl::~_NdefRecordTypeImpl(void)
+{
+}
+
+_NdefRecordTypeImpl&
+_NdefRecordTypeImpl::operator =(const _NdefRecordTypeImpl& rhs)
+{
+ if (this != &rhs)
+ {
+ __format = rhs.__format;
+ __name = rhs.__name;
+ }
+
+ return *this;
+}
+
+
+bool
+_NdefRecordTypeImpl::Equals(const Tizen::Base::Object& obj) const
+{
+ int index1 = 0;
+ int index2 = 0;
+ String subType1;
+ String subType2;
+ Uri uri1;
+ Uri uri2;
+ result r = E_SUCCESS;
+
+ const NdefRecordType* pTarget = dynamic_cast <const NdefRecordType*>(&obj);
+
+ if (pTarget == null)
+ {
+ return false; // Invalid class type; fails to down-cast Object to NdefRecordType instance
+ }
+
+ NdefRecordTypeNameFormat format = pTarget->GetNameFormat();
+ String name = pTarget->GetName();
+
+ if (__format != format)
+ {
+ return false;
+ }
+
+ switch (format)
+ {
+ case NDEF_TNF_WELL_KNOWN:
+ // character-by-character in case-sensitive manner.
+ return name.Equals(__name, true);
+
+ case NDEF_TNF_MIME_MEDIA:
+ // character-by-character in case-insensitive manner up to the first ";"
+ r = name.IndexOf(';', 0, index1);
+ r = __name.IndexOf(';', 0, index2);
+
+ if (index1 != -1 && index2 != -1)
+ {
+ r = name.SubString(0, index1, subType1);
+ r = __name.SubString(0, index2, subType2);
+ return subType1.Equals(subType2, false);
+ }
+ else if (index1 != -1)
+ {
+ r = name.SubString(0, index1, subType1);
+ return subType1.Equals(__name, false);
+
+ }
+ else if (index2 != -1)
+ {
+ r = __name.SubString(0, index2, subType2);
+ return name.Equals(subType2, false);
+ }
+ else
+ {
+ return name.Equals(__name, false);
+ }
+
+ break;
+
+ // Reserved characters must be percent-encoded and the hexadecimal digits in those normalized to upper-case letters.
+ // URI The scheme and host parts of the URI must be normalized to lower-case.
+ // After this the URIs are compared in the character-by-character in case-sensitive manner
+ case NDEF_TNF_ABSOLUTE_URI:
+ // should be implemented
+ r = uri1.SetUri(name);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, false, r, "[%s] URI error has been occurred.", GetErrorMessage(r));
+ r = uri2.SetUri(__name);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, false, r, "[%s] URI error has been occurred.", GetErrorMessage(r));
+ return uri1.Equals(uri2);
+
+ // character-by-character in case-insensitive manner
+ case NDEF_TNF_EXTERNAL:
+ if (name.Equals(__name, false))
+ {
+ return true;
+ }
+ break;
+
+ // Both record type names must be empty string
+ case NDEF_TNF_EMPTY:
+ case NDEF_TNF_UNKNOWN:
+ case NDEF_TNF_ALL:
+ if (name.IsEmpty() == true && __name.IsEmpty() == true)
+ {
+ return true;
+ }
+ break;
+
+ default:
+ return false;
+ }
+ return false;
+
+}
+
+// HashCode value MUST be equal if the Record type is equal
+int
+_NdefRecordTypeImpl::GetHashCode() const
+{
+ int index1 = 0;
+ String name1;
+ Uri uri1;
+ result r = E_SUCCESS;
+
+ switch (__format)
+ {
+ case NDEF_TNF_WELL_KNOWN:
+ return __name.GetHashCode() ^ __format;
+
+ case NDEF_TNF_MIME_MEDIA:
+ r = __name.IndexOf(';', 0, index1);
+
+ if (r == E_SUCCESS)
+ {
+ r = __name.SubString(0, index1, name1);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, -1, r, "[%s] MIME type error has been occurred.", GetErrorMessage(r));
+ name1.ToLowerCase();
+ }
+ else
+ {
+ r = __name.ToLowerCase(name1);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, -1, r, "[%s] MIME type error has been occurred.", GetErrorMessage(r));
+ }
+
+ return name1.GetHashCode() ^ __format;
+
+ case NDEF_TNF_ABSOLUTE_URI:
+ // should be implemented
+ r = uri1.SetUri(__name);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, -1, r, "[%s] URI type error has been occurred.", GetErrorMessage(r));
+ return uri1.GetHashCode() ^ __format;
+
+ // character-by-character in case-insensitive manner
+ case NDEF_TNF_EXTERNAL:
+ r = __name.ToLowerCase(name1);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, -1, r, "[%s] External type error has been occurred.", GetErrorMessage(r));
+ return name1.GetHashCode() ^ __format;
+
+ // Both record type names must be empty string
+ case NDEF_TNF_EMPTY:
+ case NDEF_TNF_UNKNOWN:
+ case NDEF_TNF_ALL:
+ return __format;
+
+ default:
+ return -1;
+ }
+}
+
+NdefRecordTypeNameFormat
+_NdefRecordTypeImpl::GetNameFormat() const
+{
+ return __format;
+}
+
+Tizen::Base::String
+_NdefRecordTypeImpl::GetName() const
+{
+ return __name;
+}
+
+result
+_NdefRecordTypeImpl::SetName(const Tizen::Base::String& name)
+{
+ bool isValid = false;
+ AsciiEncoding ascii;
+ ByteBuffer* pBuff = null;
+
+ SysTryReturnResult(NID_NET_NFC, (__format != NDEF_TNF_EMPTY) && (__format != NDEF_TNF_UNKNOWN) && (__format != NDEF_TNF_ALL),
+ E_INVALID_OPERATION, " The record type is NDEF_TNF_EMPTY or NDEF_TNF_UNKNOWN");
+
+ SysTryReturnResult(NID_NET_NFC, name.GetLength() < 256, E_MAX_EXCEEDED, "The length of the name should be less than 256");
+
+ if (name.IsEmpty())
+ {
+ SysLogException(NID_NET_NFC, E_INVALID_FORMAT, "[E_INVALID_FORMAT] The type name to be set is an empty string.");
+ return E_INVALID_FORMAT;
+ }
+ else
+ {
+ // check if name includes non US-ASCII character or not
+ pBuff = ascii.GetBytesN(name);
+ SysTryReturnResult(NID_NET_NFC, pBuff != null, E_INVALID_ENCODING_RANGE, "Name contains characters outside US-ASCII range");
+ delete pBuff;
+
+ isValid = _NdefMessageUtil::IsValidRecordType(__format, name);
+ SysTryReturnResult(NID_NET_NFC, isValid == true, E_INVALID_FORMAT, "Invalid name");
+
+ }
+
+ __name = name;
+
+ return E_SUCCESS;
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfc_NfcDeviceDiscoveryEvent.cpp
+// @brief This is the implementation file for _NfcDeviceDiscoveryEvent class.
+//
+// This file contains the implementation of _NfcDeviceDiscoveryEvent class.
+//
+
+#include <FBaseRtIEventListener.h>
+#include <FNetNfcINfcDeviceDiscoveryEventListener.h>
+#include <FBaseSysLog.h>
+#include <FBaseRt_Event.h>
+#include "FNetNfc_NfcDeviceDiscoveryEvent.h"
+#include "FNetNfc_NfcDeviceDiscoveryEventArg.h"
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+_NfcDeviceDiscoveryEvent::_NfcDeviceDiscoveryEvent(void)
+{
+}
+
+_NfcDeviceDiscoveryEvent::~_NfcDeviceDiscoveryEvent(void)
+{
+}
+
+result
+_NfcDeviceDiscoveryEvent::Construct(void)
+{
+ return _Event::Initialize();
+}
+
+void
+_NfcDeviceDiscoveryEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+ _NfcDeviceDiscoveryEventType type;
+
+ INfcDeviceDiscoveryEventListener* pEventListener = dynamic_cast <INfcDeviceDiscoveryEventListener*>(&listener);
+ SysTryReturnVoidResult(NID_NET_NFC, pEventListener != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system.");
+
+ const _NfcDeviceDiscoveryEventArg* pEventArg = dynamic_cast <const _NfcDeviceDiscoveryEventArg*>(&arg);
+ SysTryReturnVoidResult(NID_NET_NFC, pEventArg != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system.");
+
+ type = pEventArg->GetType();
+
+ switch (type)
+ {
+ case _NFC_DEVICE_DISCOVERY_EVENT_TYPE_DETECTED:
+ pEventListener->OnNfcDeviceDetected();
+ break;
+
+ case _NFC_DEVICE_DISCOVERY_EVENT_TYPE_LOST:
+ pEventListener->OnNfcDeviceLost();
+ break;
+
+ default:
+ break;
+ }
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfc_NfcDeviceDiscoveryEvent.h
+ * @brief This is the header file for the _NfcDeviceDiscoveryEvent class.
+ *
+ * This header file contains declaration of the _NfcDeviceDiscoveryEvent class.
+ * The _NfcDeviceDiscoveryEvent class can call methods of a INfcDeviceDiscoveryEventListener class.
+ */
+#ifndef _FNET_NFC_INTERNAL_NFC_DEVICE_DISCOVERY_EVENT_H_
+#define _FNET_NFC_INTERNAL_NFC_DEVICE_DISCOVERY_EVENT_H_
+
+#include <FOspConfig.h>
+#include <FBaseResult.h>
+#include <FBaseRt_Event.h>
+
+// Forward declaration
+namespace Tizen { namespace Base { namespace Runtime
+{
+class IEventArg;
+class IEventListener;
+} } }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+/**
+ * @class _NfcDeviceDiscoveryEvent
+ * @brief This class handles the events related to the discovery of NFC P2P device.
+ *
+ * When a NFC P2P device is discovered, the _NfcDeviceDiscoveryEvent object finds a INfcDeviceDiscoveryEventListener object and
+ * calls an appropriate method of the listener.
+ */
+class _NfcDeviceDiscoveryEvent
+ : public Tizen::Base::Runtime::_Event
+{
+public:
+ /**
+ * This is the default constructor.
+ */
+ _NfcDeviceDiscoveryEvent();
+
+ /**
+ * This is the class destructor.
+ */
+ virtual ~_NfcDeviceDiscoveryEvent(void);
+
+ /**
+ * Initializes a new instance of the class
+ *
+ */
+ result Construct(void);
+
+protected:
+ /**
+ * Calls the specified listener's method with the specified argument when event is generated.
+ *
+ * @param[in] listener The event listener which will be received the event
+ * @param[in] arg The event argument to be passed by
+ */
+ void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+ _NfcDeviceDiscoveryEvent(const _NfcDeviceDiscoveryEvent& value);
+ _NfcDeviceDiscoveryEvent& operator =(const _NfcDeviceDiscoveryEvent& value);
+
+}; // _NfcDeviceDiscoveryEvent
+
+} } } //Tizen::Net::Nfc
+#endif // _FNET_NFC_INTERNAL_NFC_DEVICE_DISCOVERY_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 FNetNfc_NfcDeviceDiscoveryEventArg.cpp
+// @brief This is the implementation file for _NfcDeviceDiscoveryEventArg class.
+//
+// This file contains the implementation of _NfcDeviceDiscoveryEventArg class.
+//
+
+#include <FNetNfcNdefMessage.h>
+#include <FNetNfcNdefRecord.h>
+#include <FNetNfcNdefRecordType.h>
+#include <FBaseSysLog.h>
+#include "FNetNfc_NfcDeviceDiscoveryEventArg.h"
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+_NfcDeviceDiscoveryEventArg::_NfcDeviceDiscoveryEventArg(void)
+ : __eventType(_NFC_DEVICE_DISCOVERY_EVENT_TYPE_LOST)
+{
+}
+
+_NfcDeviceDiscoveryEventArg::_NfcDeviceDiscoveryEventArg(_NfcDeviceDiscoveryEventType type)
+ : __eventType(type)
+{
+}
+
+_NfcDeviceDiscoveryEventArg::~_NfcDeviceDiscoveryEventArg(void)
+{
+}
+
+_NfcDeviceDiscoveryEventType
+_NfcDeviceDiscoveryEventArg::GetType(void) const
+{
+ return __eventType;
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfc_NfcDeviceDiscoveryEventArg.h
+ * @brief This is the header file for the _NfcDeviceDiscoveryEventArg class.
+ *
+ * This header file contains declaration of the _NfcDeviceDiscoveryEventArg class.
+ */
+#ifndef _FNET_NFC_INTERNAL_NFC_DEVICE_DISCOVERY_EVENT_ARG_H_
+#define _FNET_NFC_INTERNAL_NFC_DEVICE_DISCOVERY_EVENT_ARG_H_
+
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FBaseRtIEventArg.h>
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+/**
+ * @enum _NfcDeviceDiscoveryEventType
+ *
+ * Type for specifying the device event
+ */
+enum _NfcDeviceDiscoveryEventType
+{
+ _NFC_DEVICE_DISCOVERY_EVENT_TYPE_DETECTED, /**< For notifying NFC device detected */
+ _NFC_DEVICE_DISCOVERY_EVENT_TYPE_LOST /**< For notifying NFC device lost */
+};
+
+
+/**
+ * @class _NfcDeviceDiscoveryEventArg
+ * @brief This class is used as an argument of methods of the _NfcDeviceDiscoveryEvent class.
+ *
+ * When a P2P device is discovered, the INfcDeviceDiscoveryEventListener objects registered to the event are called
+ * with this argument class.
+ */
+class _NfcDeviceDiscoveryEventArg
+ : public Tizen::Base::Object
+ , public Tizen::Base::Runtime::IEventArg
+{
+public:
+ /**
+ * This is the constructor.
+ */
+ _NfcDeviceDiscoveryEventArg(void);
+
+ /**
+ * This is the constructor.
+ *
+ * @param[in] type The device discovery event type
+ */
+ _NfcDeviceDiscoveryEventArg(_NfcDeviceDiscoveryEventType type);
+
+ /**
+ * This is the class destructor.
+ */
+ ~_NfcDeviceDiscoveryEventArg(void);
+
+ /**
+ * Gets the device discovery event type.
+ *
+ * @return The device discovery event type
+ */
+ _NfcDeviceDiscoveryEventType GetType(void) const;
+
+private:
+ _NfcDeviceDiscoveryEventArg(const _NfcDeviceDiscoveryEventArg& rhs);
+ _NfcDeviceDiscoveryEventArg& operator =(const _NfcDeviceDiscoveryEventArg& rhs);
+
+private:
+ _NfcDeviceDiscoveryEventType __eventType;
+}; // _NfcDeviceDiscoveryEventArg
+
+} } } //Tizen::Net::Nfc
+#endif // _FNET_NFC_INTERNAL_NFC_DEVICE_DISCOVERY_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 FNetNfc_NfcIpcMessages
+ * @brief This is the generator of IPC messages for the Connectivity service daemon.
+ */
+
+#define IPC_MESSAGE_IMPL
+#include "FNetNfc_ConnectivityIpcMessages.h"
+
+// Generate constructors.
+#include <ipc/struct_constructor_macros.h>
+#include "FNetNfc_ConnectivityIpcMessages.h"
+
+// Generate destructors.
+#include <ipc/struct_destructor_macros.h>
+#include "FNetNfc_ConnectivityIpcMessages.h"
+
+// Generate param traits write methods.
+#include <ipc/param_traits_write_macros.h>
+namespace IPC {
+#include "FNetNfc_ConnectivityIpcMessages.h"
+} // namespace IPC
+
+// Generate param traits read methods.
+#include <ipc/param_traits_read_macros.h>
+namespace IPC {
+#include "FNetNfc_ConnectivityIpcMessages.h"
+} // namespace IPC
--- /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 FNetNfc_NfcIpcProxy.cpp
+// @brief This is the implementation file for the %_NfcIpcProxy class.
+//
+// This file contains the implementation of the %_NfcIpcProxy class.
+//
+
+#include <FBaseSysLog.h>
+#include <FBaseString.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseColHashMap.h>
+#include <FIo_IpcClient.h>
+#include "FNetNfc_NfcIpcProxy.h"
+#include "FNetNfc_ConnectivityIpcMessages.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+typedef IMapEnumeratorT<String, String> _NfcCandidatesMapEnumerator;
+_NfcIpcProxy* _NfcIpcProxy::__pSingleton = null;
+
+_NfcIpcProxy::_NfcIpcProxy(void) :
+ __pIpcClient(null)
+{
+}
+
+_NfcIpcProxy::~_NfcIpcProxy(void)
+{
+ delete __pIpcClient;
+}
+
+result
+_NfcIpcProxy::Construct(void)
+{
+ result r = E_SUCCESS;
+
+ unique_ptr<_IpcClient> pIpcClient(new (std::nothrow) _IpcClient);
+ SysTryReturnResult(NID_NET_NFC, pIpcClient != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = pIpcClient->Construct(NFC_CONNECTIVITY_IPC_SERVER_NAME, null);
+
+ SysLog(NID_NET_NFC, "An instance of the Nfc IPC Proxy has been constructed.");
+
+ __pIpcClient = pIpcClient.release();
+
+ return r;
+}
+
+void
+_NfcIpcProxy::InitSingleton(void)
+{
+ unique_ptr<_NfcIpcProxy> pInst(new (std::nothrow) _NfcIpcProxy());
+ SysTryReturnVoidResult(NID_NET_NFC, pInst, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ result r = pInst->Construct();
+ SysTryReturnVoidResult(NID_NET_NFC, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ __pSingleton = pInst.release();
+ std::atexit(DestroySingleton);
+}
+
+void
+_NfcIpcProxy::DestroySingleton(void)
+{
+ delete __pSingleton;
+}
+
+_NfcIpcProxy*
+_NfcIpcProxy::GetInstance(void)
+{
+ static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+ if (!__pSingleton)
+ {
+ ClearLastResult();
+ pthread_once(&onceBlock, InitSingleton);
+ result r = GetLastResult();
+ if (IsFailed(r))
+ {
+ onceBlock = PTHREAD_ONCE_INIT;
+ }
+ }
+
+ return __pSingleton;
+}
+
+result
+_NfcIpcProxy::InitializeNfc(void) const
+{
+ result r = E_SUCCESS;
+ IPC::Message* pMessage = null;
+ unsigned long ret = 0;
+
+ pMessage = new (std::nothrow) ConnectivityNfcServiceMsg_initialize(&ret);
+ SysTryReturnResult(NID_NET_NFC, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = __pIpcClient->SendRequest(*pMessage);
+ delete pMessage;
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS && ret == E_SUCCESS, E_SYSTEM, "A system error occurred.");
+
+ SysLog(NID_NET_NFC, "Initializing the NFC of osp-connectivity-service through IPC is successful.");
+
+ return E_SUCCESS;
+}
+
+result
+_NfcIpcProxy::RegisterNdefPushMessage(const Tizen::Base::ByteBuffer& message, const Tizen::Base::String& description) const
+{
+ result r = E_SUCCESS;
+ IPC::Message* pMessage = null;
+ unsigned long ret = 0;
+
+ pMessage = new (std::nothrow) ConnectivityNfcServiceMsg_registerPushMessage(message, description, &ret);
+ SysTryReturnResult(NID_NET_NFC, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = __pIpcClient->SendRequest(*pMessage);
+ delete pMessage;
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS && ret == E_SUCCESS, E_SYSTEM, "A system error occurred.");
+
+ SysLog(NID_NET_NFC, "Registering the NDEF push message to osp-connectivity-service through IPC is successful.");
+
+ return E_SUCCESS;
+}
+
+result
+_NfcIpcProxy::UnregisterNdefPushMessage(void) const
+{
+ result r = E_SUCCESS;
+ IPC::Message* pMessage = null;
+ unsigned long ret = 0;
+
+ pMessage = new (std::nothrow) ConnectivityNfcServiceMsg_unregisterPushMessage(&ret);
+ SysTryReturnResult(NID_NET_NFC, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = __pIpcClient->SendRequest(*pMessage);
+ delete pMessage;
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS && ret == E_SUCCESS, E_SYSTEM, "A system error occurred.");
+
+ SysLog(NID_NET_NFC, "Unregistering the NDEF push message from osp-connectivity-service through IPC is successful.");
+
+ return E_SUCCESS;
+}
+
+result
+_NfcIpcProxy::ActivateReservedPush(void)
+{
+ result r = E_SUCCESS;
+ IPC::Message* pMessage = null;
+ unsigned long ret = 0;
+
+ pMessage = new (std::nothrow) ConnectivityNfcServiceMsg_activateReservedPush(&ret);
+ SysTryReturnResult(NID_NET_NFC, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = __pIpcClient->SendRequest(*pMessage);
+ delete pMessage;
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "A system error occurred.");
+ SysTryReturnResult(NID_NET_NFC, ret == E_SUCCESS, ret, "Propagating through IPC.");
+
+ SysLog(NID_NET_NFC, "Activating Reserved Push through IPC is successful.");
+
+ return E_SUCCESS;
+}
+
+result
+_NfcIpcProxy::DeactivateReservedPush(void)
+{
+ result r = E_SUCCESS;
+ IPC::Message* pMessage = null;
+ unsigned long ret = 0;
+
+ pMessage = new (std::nothrow) ConnectivityNfcServiceMsg_deactivateReservedPush(&ret);
+ SysTryReturnResult(NID_NET_NFC, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = __pIpcClient->SendRequest(*pMessage);
+ delete pMessage;
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "A system error occurred.");
+ SysTryReturnResult(NID_NET_NFC, ret == E_SUCCESS, ret, "Propagating through IPC.");
+
+ SysLog(NID_NET_NFC, "Deactivating Reserved Push through IPC is successful.");
+
+ return E_SUCCESS;
+}
+
+bool
+_NfcIpcProxy::IsReservedPushActivated(void) const
+{
+ result r = E_SUCCESS;
+ IPC::Message* pMessage = null;
+ bool isActivated = 0;
+
+ pMessage = new (std::nothrow) ConnectivityNfcServiceMsg_isReservedPushActivated(&isActivated);
+ SysTryReturn(NID_NET_NFC, pMessage != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ r = __pIpcClient->SendRequest(*pMessage);
+ delete pMessage;
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
+
+ SysLog(NID_NET_NFC, "The result of checking through IPC is %s.", isActivated ? "activated" : "deactivated");
+
+ return isActivated;
+}
+
+Tizen::Base::Collection::IMap*
+_NfcIpcProxy::GetReservedPushCandidatesN(void) const
+{
+ result r = E_SUCCESS;
+ IPC::Message* pMessage = null;
+ unique_ptr<HashMap> pCandidatesHashMap;
+ unique_ptr<_StringMap> pCandidates;
+ unique_ptr<String> pAppPkgId;
+ unique_ptr<String> pMsgDesc;
+ unsigned long ret = 0;
+
+ pCandidates.reset(new (std::nothrow) _StringMap());
+ SysTryReturn(NID_NET_NFC, pCandidates != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ pCandidatesHashMap.reset(new (std::nothrow) HashMap(SingleObjectDeleter));
+ SysTryReturn(NID_NET_NFC, pCandidatesHashMap != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ pCandidatesHashMap->Construct();
+
+ pMessage = new (std::nothrow) ConnectivityNfcServiceMsg_getReservedPushCandidates(pCandidates.get(), &ret);
+ SysTryReturn(NID_NET_NFC, pMessage != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ r = __pIpcClient->SendRequest(*pMessage);
+ delete pMessage;
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
+ SysTryReturn(NID_NET_NFC, ret == E_SUCCESS, null, ret, "[%s] Propagating through IPC.", GetErrorMessage(ret));
+
+ SysLog(NID_NET_NFC, "Getting the Reserved Push candidate list through IPC is successful.");
+
+ unique_ptr<_NfcCandidatesMapEnumerator> pCandidatesEnum(pCandidates->GetMapEnumeratorN());
+
+ while (pCandidatesEnum->MoveNext() == E_SUCCESS)
+ {
+ pAppPkgId.reset(new (std::nothrow) String());
+ SysTryReturn(NID_NET_NFC, pAppPkgId != null, null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ pMsgDesc.reset(new (std::nothrow) String());
+ SysTryReturn(NID_NET_NFC, pMsgDesc != null, null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ pCandidatesEnum->GetKey(*pAppPkgId);
+ pCandidatesEnum->GetValue(*pMsgDesc);
+ pCandidatesHashMap->Add(pAppPkgId.release(), pMsgDesc.release());
+ }
+
+ return pCandidatesHashMap.release();
+}
+
+result
+_NfcIpcProxy::PickReservedPushMessage(const Tizen::App::AppId& appId)
+{
+ result r = E_SUCCESS;
+ IPC::Message* pMessage = null;
+ unsigned long ret = 0;
+
+ pMessage = new (std::nothrow) ConnectivityNfcServiceMsg_pickReservedPushMessage(appId, &ret);
+ SysTryReturnResult(NID_NET_NFC, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = __pIpcClient->SendRequest(*pMessage);
+ delete pMessage;
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "A system error occurred.");
+ SysTryReturnResult(NID_NET_NFC, ret == E_SUCCESS, ret, "Propagating through IPC.");
+
+ SysLog(NID_NET_NFC, "Picking the Reserved Push message through IPC is successful.");
+
+ return E_SUCCESS;
+}
+
+result
+_NfcIpcProxy::GetPickedReservedPushMessage(Tizen::App::AppId& appId) const
+{
+ result r = E_SUCCESS;
+ IPC::Message* pMessage = null;
+ unsigned long ret = 0;
+
+ pMessage = new (std::nothrow) ConnectivityNfcServiceMsg_getPickedReservedPushMessage(&appId, &ret);
+ SysTryReturnResult(NID_NET_NFC, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = __pIpcClient->SendRequest(*pMessage);
+ delete pMessage;
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "A system error occurred.");
+ SysTryReturnResult(NID_NET_NFC, ret == E_SUCCESS, ret, "Propagating through IPC.");
+
+ SysLog(NID_NET_NFC, "The owner ID of the picked Reserved Push message obtained through IPC is [%ls].", appId.GetPointer());
+
+ return E_SUCCESS;
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfc_NfcIpcProxy.h
+ * @brief This is the header file for the %_NfcIpcProxy class.
+ *
+ * This header file contains the declarations of the %_NfcIpcProxy class.
+ */
+
+#ifndef _FNET_NFC_INTERNAL_NFC_IPC_PROXY_H_
+#define _FNET_NFC_INTERNAL_NFC_IPC_PROXY_H_
+
+#include <cstdlib>
+#include <pthread.h>
+#include <unique_ptr.h>
+#include <FAppTypes.h>
+#include <FBaseObject.h>
+#include <FBaseResult.h>
+
+// Forward declaration
+namespace Tizen { namespace Io
+{
+class _IpcClient;
+} }
+
+// Forward declaration
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+class String;
+} }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+/**
+ * @class _NfcIpcProxy
+ * @brief This class represents an IPC proxy for %Nfc service.
+ *
+ * This class represents an IPC proxy for %Nfc service to communicate with Connectivity service daemon.
+ */
+class _NfcIpcProxy
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * Gets the instance.
+ *
+ * @return The pointer to %_NfcIpcProxy
+ */
+ static _NfcIpcProxy* GetInstance(void);
+
+ /**
+ * Initialize Nfc of osp-connectivity-service daemon through IPC.
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_SYSTEM A system error occurred.
+ */
+ result InitializeNfc(void) const;
+
+ /**
+ * Registers an NDEF message to be pushed through IPC.
+ *
+ * @return An error code
+ * @param[in] message The NDEF message to be registered
+ * @param[in] description The description for the NDEF message to be registered
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ result RegisterNdefPushMessage(const Tizen::Base::ByteBuffer& message, const Tizen::Base::String& description) const;
+
+ /**
+ * Unregisters an NDEF message registered through IPC.
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ result UnregisterNdefPushMessage(void) const;
+
+ /**
+ * Activates Reserved Push feature through IPC.
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified
+ * operation. @n
+ * For example, Reserved Push is already activated.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_SYSTEM The method cannot proceed due to a severe system error.
+ */
+ result ActivateReservedPush(void);
+
+ /**
+ * Deactivates Reserved Push feature through IPC.
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified
+ * operation. @n
+ * For example, Reserved Push is already deactivated.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_SYSTEM The method cannot proceed due to a severe system error.
+ */
+ result DeactivateReservedPush(void);
+
+ /**
+ * Checks whether Reserved Push feature is activated through IPC.
+ *
+ * @return @c true if Reserved Push is activated, @n
+ * else @c false
+ */
+ bool IsReservedPushActivated(void) const;
+
+ /**
+ * Gets information of all the Reserved Push candidates through IPC.
+ *
+ * @return An IMap containing the pairs of application ID and message description if successful, @n
+ * else @c null
+ */
+ Tizen::Base::Collection::IMap* GetReservedPushCandidatesN(void) const;
+
+ /**
+ * Picks out an NDEF message among all Reserved Push candidates by application ID through IPC.
+ *
+ * @return An error code
+ * @param[in] appId The ID of the application which registered the NDEF message to push
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND The specified @c appId is not found in the Reserved Push candidate list.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_SYSTEM The method cannot proceed due to a severe system error.
+ */
+ result PickReservedPushMessage(const Tizen::App::AppId& appId);
+
+ /**
+ * Gets the owner application ID of the picked NDEF message among all Reserved Push candidates through IPC.
+ *
+ * @return An error code
+ * @param[out] appId The ID of the application which is the owner of the picked Reserved Push
+ * message
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND There is no element in the Reserved Push candidate list.
+ * @exception E_SYSTEM The method cannot proceed due to a severe system error.
+ */
+ result GetPickedReservedPushMessage(Tizen::App::AppId& appId) const;
+
+private:
+ _NfcIpcProxy(void);
+ virtual ~_NfcIpcProxy(void);
+ result Construct(void);
+ static void InitSingleton(void);
+ static void DestroySingleton(void);
+
+ _NfcIpcProxy(const _NfcIpcProxy& value);
+ _NfcIpcProxy& operator =(const _NfcIpcProxy& rhs);
+
+private:
+ Tizen::Io::_IpcClient* __pIpcClient;
+ static _NfcIpcProxy* __pSingleton;
+ friend class std::default_delete< _NfcIpcProxy >;
+}; // _NfcIpcProxy
+
+} } }
+#endif // _FNET_NFC_INTERNAL_NFC_IPC_PROXY_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 FNetNfcManagerEvent.cpp
+// @brief This is the implementation file for _NfcManagerEvent class.
+//
+// This file contains the implementation of _NfcManagerEvent class.
+//
+
+#include <FBaseRtIEventListener.h>
+#include <FBaseSysLog.h>
+#include <FBaseRtIEventArg.h>
+#include "FNetNfc_NfcManagerEvent.h"
+#include "FNetNfc_NfcManagerEventArg.h"
+#include "FNetNfcINfcManagerEventListener.h"
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+_NfcManagerEvent::_NfcManagerEvent(void)
+{
+}
+
+_NfcManagerEvent::~_NfcManagerEvent(void)
+{
+}
+
+result
+_NfcManagerEvent::Construct(void)
+{
+ return _Event::Initialize();
+}
+
+void
+_NfcManagerEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+ _NfcManagerEventType status;
+ result r = E_SUCCESS;
+
+ INfcManagerEventListener* pEventListener = dynamic_cast <INfcManagerEventListener*>(&listener);
+ SysTryReturnVoidResult(NID_NET_NFC, pEventListener != null, E_SYSTEM, "[E_SYSTEM] Failed to get the listener.");
+
+ const _NfcManagerEventArg* pEventArg = dynamic_cast <const _NfcManagerEventArg*>(&arg);
+ SysTryReturnVoidResult(NID_NET_NFC, pEventArg != null, E_SYSTEM, "[E_SYSTEM] Failed to get the listener argument.");
+
+ status = pEventArg->GetEventType();
+ r = pEventArg->GetResult();
+
+ switch (status)
+ {
+ case _NFC_MGR_EVENT_TYPE_ACTIVATED:
+ pEventListener->OnNfcActivated(r);
+ break;
+
+ case _NFC_MGR_EVENT_TYPE_DEACTIVATED:
+ pEventListener->OnNfcDeactivated(r);
+ break;
+
+ default:
+ break;
+ }
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfcNfcManagerEvent.h
+ * @brief This is the header file for the _NfcManagerEvent class.
+ *
+ * This header file contains declaration of the _NfcManagerEvent class.
+ * The _NfcManagerEvent class can call methods of a INfcManagerEventListener class.
+ */
+#ifndef _FNET_NFC_INTERNAL_NFC_MANAGER_EVENT_H_
+#define _FNET_NFC_INTERNAL_NFC_MANAGER_EVENT_H_
+
+#include <FOspConfig.h>
+#include <FBaseResult.h>
+#include <FBaseRt_Event.h>
+
+// Forward declaration
+namespace Tizen { namespace Base { namespace Runtime
+{
+class IEventArg;
+class IEventListener;
+} } }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+/**
+ * @class _NfcManagerEvent
+ * @brief This class handles the events related to the NFC Manager(Agent) status.
+ *
+ * When the NFC Manager's status is changed, the _NfcManagerEvent object finds a INfcManagerEventListener object and
+ * calls an appropriate method of the listener.
+ */
+class _NfcManagerEvent
+ : public Tizen::Base::Runtime::_Event
+{
+public:
+ /**
+ * This is the default constructor.
+ *
+ * @remarks After creating an instance of this class, you must explicitly call the construction method to
+ * initialize the instance.
+ * @see Construct
+ */
+ _NfcManagerEvent();
+
+ /**
+ * This is the class destructor.
+ */
+ virtual ~_NfcManagerEvent(void);
+
+ /**
+ * Initializes a new instance of the class
+ *
+ */
+ result Construct(void);
+
+protected:
+ /**
+ * Calls the specified listener's method with the specified argument when event is generated.
+ *
+ * @param[in] listener The event listener which will be received the event
+ * @param[in] arg The event argument to be passed by
+ */
+ void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+ _NfcManagerEvent(const _NfcManagerEvent& value);
+ _NfcManagerEvent& operator =(const _NfcManagerEvent& value);
+
+}; // _NfcManagerEvent
+
+} } } //Tizen::Net::Nfc
+#endif // _FNET_NFC_INTERNAL_NFC_MANAGER_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 FNetNfcManagerEventArg.h
+// @brief This is the implementation file for _NfcManagerEventArg Class.
+//
+// This file contains the implementation of _NfcManagerEventArg Class.
+//
+
+#include "FNetNfc_NfcManagerEventArg.h"
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+//
+// This is a class constructor for _NFC_MGR_EVENT_TYPE_ACTIVATED and _NFC_MGR_EVENT_TYPE_DEACTIVATED event.
+//
+_NfcManagerEventArg::_NfcManagerEventArg(_NfcManagerEventType type, result r)
+ : __type(type)
+ , __result(r)
+{
+}
+
+_NfcManagerEventArg::~_NfcManagerEventArg(void)
+{
+}
+
+_NfcManagerEventType
+_NfcManagerEventArg::GetEventType(void) const
+{
+ return __type;
+}
+
+result
+_NfcManagerEventArg::GetResult(void) const
+{
+ return __result;
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfcManagerEventArg.h
+ * @brief This is the header file for the _NfcManagerEventArg class.
+ *
+ * This header file contains declaration of the _NfcManagerEventArg class.
+ */
+#ifndef _FNET_NFC_INTERNAL_NFC_MANAGER_EVENT_ARG_H_
+#define _FNET_NFC_INTERNAL_NFC_MANAGER_EVENT_ARG_H_
+
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FBaseResult.h>
+#include <FBaseRtIEventArg.h>
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+/**
+ * @enum _NfcManagerEventType
+ *
+ * Type for specifying the type of NFC status
+ */
+enum _NfcManagerEventType
+{
+ _NFC_MGR_EVENT_TYPE_ACTIVATED, /**< For notifying activation */
+ _NFC_MGR_EVENT_TYPE_DEACTIVATED /**< For notifying deactivation */
+};
+
+/**
+ * @class _NfcManagerEventArg
+ * @brief This class is used as an argument of methods of the _NfcManagerEvent class.
+ *
+ * When the NFC Manager's status is changed, the INfcManagerEventListener objects registered to the event are called
+ * with this argument class.
+ */
+class _NfcManagerEventArg
+ : public Tizen::Base::Object
+ , public Tizen::Base::Runtime::IEventArg
+{
+public:
+ /**
+ * This is a class constructor for _NFC_MGR_EVENT_TYPE_ACTIVATED and _NFC_MGR_EVENT_TYPE_DEACTIVATED event.
+ *
+ * @param[in] type The type of the event
+ * @param[in] r The result of the event
+ * @exception E_SUCCESS The action was successful.
+ * @exception E_SYSTEM The action failed due to a system error.
+ */
+ _NfcManagerEventArg(_NfcManagerEventType type, result r);
+
+ /**
+ * This is the class destructor.
+ *
+ */
+ ~_NfcManagerEventArg(void);
+
+ /**
+ * Gets the tag event type.
+ *
+ * @return The type of the event
+ */
+ _NfcManagerEventType GetEventType(void) const;
+
+ /**
+ * Gets the action result.
+ *
+ * @return The error code
+ */
+ result GetResult(void) const;
+
+private:
+ _NfcManagerEventArg(const _NfcManagerEventArg& value);
+ _NfcManagerEventArg& operator =(const _NfcManagerEventArg& value);
+
+private:
+ _NfcManagerEventType __type;
+ result __result;
+
+}; // _NfcManagerEventArg
+
+} } } //Tizen::Net::Nfc
+#endif // _FNET_NFC_INTERNAL_NFC_MANAGER_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 FNetNfcNfcManagerAgent.cpp
+// @brief This is the implementation file for _NfcManagerAgent class.
+//
+// This file contains the implementation of _NfcManagerAgent class.
+//
+
+#include <unique_ptr.h>
+#include <FBaseColHashMap.h>
+#include <FBaseColHashMapT.h>
+#include <FBaseColLinkedList.h>
+#include <FBaseColLinkedListT.h>
+#include <FBaseInteger.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseSysLog.h>
+#include <FNetNfcINfcManagerEventListener.h>
+#include <FNetNfcINfcTagDiscoveryEventListener.h>
+#include <FNetNfcINdefMessageDiscoveryEventListener.h>
+#include <FNetNfcINfcDeviceDiscoveryEventListener.h>
+#include <FNetNfcTagConnection.h>
+#include <FNetNfcNdefRecord.h>
+#include <FNetNfcNdefRecordType.h>
+#include "FNetNfc_NfcManagerImpl.h"
+#include "FNetNfc_NfcManagerEvent.h"
+#include "FNetNfc_NfcManagerEventArg.h"
+#include "FNetNfc_NfcTagDiscoveryEvent.h"
+#include "FNetNfc_NfcTagDiscoveryEventArg.h"
+#include "FNetNfc_NdefMessageDiscoveryEvent.h"
+#include "FNetNfc_NdefMessageDiscoveryEventArg.h"
+#include "FNetNfc_NdefMessageUtil.h"
+#include "FNetNfc_NfcTagImpl.h"
+#include "FNetNfc_TagConnectionImpl.h"
+#include "FNetNfc_NfcSystemAdapter.h"
+#include "FNetNfc_NfcDeviceDiscoveryEvent.h"
+#include "FNetNfc_NfcDeviceDiscoveryEventArg.h"
+
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+typedef HashMapT<INfcTagDiscoveryEventListener*, _NfcTagDiscoveryEvent*> _NfcTagEventMap;
+typedef IMapEnumeratorT<INfcTagDiscoveryEventListener*, _NfcTagDiscoveryEvent*> _NfcTagEventMapEnumerator;
+typedef HashMapT<INdefMessageDiscoveryEventListener*, _NdefMessageDiscoveryEvent*> _NdefMsgEventMap;
+typedef IMapEnumeratorT<INdefMessageDiscoveryEventListener*, _NdefMessageDiscoveryEvent*> _NdefMsgEventMapEnumerator;
+
+_NfcManagerImpl::_NfcManagerImpl(void)
+ : __pSystemAdapter(null)
+ , __pCurrentTagImpl(null)
+ , __pMgrEvent(null)
+ , __pTagConditionMap(null)
+ , __pNdefConditionMap(null)
+ , __pDeviceDiscoveryEvent(null)
+ , __stateMutex()
+ , __currentState(_NFC_MANAGER_STATE_DISABLED)
+{
+}
+
+_NfcManagerImpl::~_NfcManagerImpl(void)
+{
+ if (__pSystemAdapter != null)
+ {
+ __pSystemAdapter->RemoveNfcManagerImpl(this);
+ __pSystemAdapter->RemoveNfcTagDiscoveryEventListener(this);
+ __pSystemAdapter->RemoveNfcDeviceDiscoveryEventListener(this);
+ }
+
+ delete __pCurrentTagImpl;
+ delete __pMgrEvent;
+
+ if (__pTagConditionMap)
+ {
+ unique_ptr<IList> pTagConditionList(__pTagConditionMap->GetValuesN());
+ unique_ptr<IEnumerator> pTagConditionEnum(pTagConditionList->GetEnumeratorN());
+ while (pTagConditionEnum->MoveNext() == E_SUCCESS)
+ {
+ _NfcTagEventMap* pEventMap = dynamic_cast <_NfcTagEventMap*> (pTagConditionEnum->GetCurrent());
+ if (pEventMap)
+ {
+ unique_ptr<IListT<_NfcTagDiscoveryEvent*> > pEventList(pEventMap->GetValuesN());
+ unique_ptr<IEnumeratorT<_NfcTagDiscoveryEvent*> > pEventEnum(pEventList->GetEnumeratorN());
+ while (pEventEnum->MoveNext() == E_SUCCESS)
+ {
+ _NfcTagDiscoveryEvent* pEvent = null;
+ pEventEnum->GetCurrent(pEvent);
+ delete pEvent;
+ }
+ }
+ }
+ delete __pTagConditionMap;
+ }
+
+ if (__pNdefConditionMap)
+ {
+ unique_ptr<IList> pNdefConditionList(__pNdefConditionMap->GetValuesN());
+ unique_ptr<IEnumerator> pNdefConditionEnum(pNdefConditionList->GetEnumeratorN());
+ while (pNdefConditionEnum->MoveNext() == E_SUCCESS)
+ {
+ _NdefMsgEventMap* pEventMap = dynamic_cast <_NdefMsgEventMap*> (pNdefConditionEnum->GetCurrent());
+ if (pEventMap)
+ {
+ unique_ptr<IListT<_NdefMessageDiscoveryEvent*> > pEventList(pEventMap->GetValuesN());
+ unique_ptr<IEnumeratorT<_NdefMessageDiscoveryEvent*> > pEventEnum(pEventList->GetEnumeratorN());
+ while (pEventEnum->MoveNext() == E_SUCCESS)
+ {
+ _NdefMessageDiscoveryEvent* pEvent = null;
+ pEventEnum->GetCurrent(pEvent);
+ delete pEvent;
+ }
+ }
+ }
+ delete __pNdefConditionMap;
+ }
+
+ delete __pDeviceDiscoveryEvent;
+}
+
+result
+_NfcManagerImpl::Construct(INfcManagerEventListener& listener)
+{
+ result r = E_SUCCESS;
+ unique_ptr<HashMap> pTagConditionMap;
+ unique_ptr<HashMap> pNdefConditionMap;
+ unique_ptr<_NfcManagerEvent> pMgrEvent;
+ unique_ptr<_NfcDeviceDiscoveryEvent> pDevEvent;
+
+ r = __stateMutex.Create();
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed to create the state mutex.");
+
+ // Create the Mananger Event and add the specified listener to it
+ pMgrEvent.reset(new (std::nothrow) _NfcManagerEvent());
+ SysTryReturnResult(NID_NET_NFC, pMgrEvent != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = pMgrEvent->Construct();
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating. Construct of an event instance failed.");
+
+ r = pMgrEvent->AddListener(listener, true);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating. Adding a new listener has failed.");
+
+ // Create the Device Discovery Event
+ pDevEvent.reset(new (std::nothrow) _NfcDeviceDiscoveryEvent());
+ SysTryReturnResult(NID_NET_NFC, pDevEvent != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = pDevEvent->Construct();
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating. Construct of an event instance failed.");
+
+ // Create the tag condition map which includes a TNF value as the key (condition) and an event map as the value.
+ pTagConditionMap.reset(new (std::nothrow) HashMap(SingleObjectDeleter));
+ SysTryReturnResult(NID_NET_NFC, pTagConditionMap != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = pTagConditionMap->Construct();
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Construct of the tag condition map failed.");
+
+ // Create the NDEF condition map which includes a NDEF record type as the key (condition) and an event map as the value.
+ pNdefConditionMap.reset(new (std::nothrow) HashMap(SingleObjectDeleter));
+ SysTryReturnResult(NID_NET_NFC, pNdefConditionMap != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = pNdefConditionMap->Construct();
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Construct of the NDEF condition map failed.");
+
+ // Create the NfcSystemAdapter
+ __pSystemAdapter = _NfcSystemAdapter::GetInstance();
+ SysTryReturnResult(NID_NET_NFC, __pSystemAdapter != null, E_SYSTEM, "Failed to get the instance of _NfcSystemAdapter.");
+
+ // Adds the callback to _NfcSystemManager
+ r = __pSystemAdapter->AddNfcManagerImpl(this);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed to register the callback to _NfcSystemAdapter.");
+
+ r = __pSystemAdapter->AddNfcTagDiscoveryEventListener(this);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed to register the callback to _NfcSystemAdapter.");
+
+ r = __pSystemAdapter->AddNfcDeviceDiscoveryEventListener(this);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed to register the callback to _NfcSystemAdapter.");
+
+ // get the current state of the manager
+ __stateMutex.Acquire();
+
+ if (__pSystemAdapter->IsActivated())
+ {
+ if (__pSystemAdapter->IsTagConnected())
+ {
+ __currentState = _NFC_MANAGER_STATE_CONNECTED;
+
+ // get the target tag if it is connected with the device
+ __pCurrentTagImpl = __pSystemAdapter->GetCurrentTagImplN();
+ if (__pCurrentTagImpl)
+ {
+ // display the information of the connected tag
+ PrintTag(*__pCurrentTagImpl);
+ }
+ else
+ {
+ SysLog(NID_NET_NFC, "Failed to get the connected tag in spite of the connected state!");
+ }
+ }
+ else if (__pSystemAdapter->IsDeviceDetected())
+ {
+ __currentState = _NFC_MANAGER_STATE_CONNECTED;
+ }
+ else
+ {
+ __currentState = _NFC_MANAGER_STATE_IDLE;
+ }
+ }
+
+ __stateMutex.Release();
+
+ __pMgrEvent = pMgrEvent.release();
+ __pDeviceDiscoveryEvent = pDevEvent.release();
+ __pTagConditionMap = pTagConditionMap.release();
+ __pNdefConditionMap = pNdefConditionMap.release();
+
+ return E_SUCCESS;
+}
+
+result
+_NfcManagerImpl::Activate(void)
+{
+ SysLog(NID_NET_NFC, "EntryPoint, [CurrentState:%s]", GetStringOfCurrentState());
+
+ result r = E_SUCCESS;
+
+ __stateMutex.Acquire();
+
+ switch (__currentState)
+ {
+ case _NFC_MANAGER_STATE_DISABLED:
+ r = __pSystemAdapter->Activate();
+ if (r == E_SUCCESS)
+ {
+ __currentState = _NFC_MANAGER_STATE_ACTIVATING;
+ }
+ break;
+
+ case _NFC_MANAGER_STATE_ACTIVATING:
+ r = E_IN_PROGRESS;
+ break;
+
+ default:
+ r = E_INVALID_OPERATION;
+ break;
+ }
+
+ __stateMutex.Release();
+
+ if (r != E_SUCCESS)
+ {
+ SysLogException(NID_NET_NFC, r, "[%s] exception occurred on activating NFC.", GetErrorMessage(r));
+ }
+
+ SysLog(NID_NET_NFC, "ExitPoint, [CurrentState:%s], [result:%s]", GetStringOfCurrentState(), GetErrorMessage(r));
+
+ return r;
+}
+
+result
+_NfcManagerImpl::Deactivate(void)
+{
+ SysLog(NID_NET_NFC, "EntryPoint, [CurrentState:%s]", GetStringOfCurrentState());
+
+ result r = E_SUCCESS;
+
+ __stateMutex.Acquire();
+
+ switch (__currentState)
+ {
+ case _NFC_MANAGER_STATE_IDLE:
+ case _NFC_MANAGER_STATE_CONNECTED:
+ r = __pSystemAdapter->Deactivate();
+ if (r == E_SUCCESS)
+ {
+ __currentState = _NFC_MANAGER_STATE_DEACTIVATING;
+ }
+ break;
+
+ case _NFC_MANAGER_STATE_DEACTIVATING:
+ r = E_IN_PROGRESS;
+ break;
+
+ default:
+ r = E_INVALID_OPERATION;
+ break;
+ }
+
+ __stateMutex.Release();
+
+ if (r != E_SUCCESS)
+ {
+ SysLogException(NID_NET_NFC, r, "[%s] exception occurred on deactivating NFC.", GetErrorMessage(r));
+ }
+
+ SysLog(NID_NET_NFC, "ExitPoint, [CurrentState:%s], [result:%s]", GetStringOfCurrentState(), GetErrorMessage(r));
+
+ return r;
+}
+
+bool
+_NfcManagerImpl::IsActivated(void) const
+{
+ if ((__currentState == _NFC_MANAGER_STATE_IDLE) || (__currentState == _NFC_MANAGER_STATE_CONNECTED))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+bool
+_NfcManagerImpl::IsTagConnected(void) const
+{
+ if ((__currentState == _NFC_MANAGER_STATE_CONNECTED) && (__pSystemAdapter->IsTagConnected()))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+bool
+_NfcManagerImpl::IsDeviceDetected(void) const
+{
+ if ((__currentState == _NFC_MANAGER_STATE_CONNECTED) && (__pSystemAdapter->IsDeviceDetected()))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+TagConnection*
+_NfcManagerImpl::GetCurrentTagConnectionN(void) const
+{
+ TagConnection* pCurrentConnection = null;
+
+ ClearLastResult();
+
+ SysTryReturn(NID_NET_NFC, IsActivated(), null, E_INVALID_STATE, "[E_INVALID_STATE] NFC is not activated.");
+ SysTryReturn(NID_NET_NFC, (IsTagConnected() && __pCurrentTagImpl), null, E_CONNECTION_FAILED,
+ "[E_CONNECTION_FAILED] There is no connection established.");
+
+ pCurrentConnection = _TagConnectionImpl::GetTagConnectionN(*__pCurrentTagImpl);
+ SysTryReturn(NID_NET_NFC, pCurrentConnection != null, null, E_SYSTEM, "[E_SYSTEM] System error occurred.");
+
+ return pCurrentConnection;
+}
+
+result
+_NfcManagerImpl::AddTagDiscoveryEventListener(INfcTagDiscoveryEventListener& listener, NfcTagType type)
+{
+ result r = E_SUCCESS;
+ _NfcTagEventMap* pEventMap = null;
+
+ pEventMap = dynamic_cast <_NfcTagEventMap*> (__pTagConditionMap->GetValue(Integer(type)));
+
+ if (pEventMap == null)
+ {
+ // this condition - the specified tag type - is registered first time,
+ // therefore, create a new event map which is related with the specified tag type.
+ unique_ptr<_NfcTagEventMap> pNewEventMap(new (std::nothrow) _NfcTagEventMap());
+ SysTryReturnResult(NID_NET_NFC, pNewEventMap != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = pNewEventMap->Construct();
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Construct of an event map instance failed.");
+
+ unique_ptr<Integer> pKey(new (std::nothrow) Integer(type));
+ SysTryReturnResult(NID_NET_NFC, pKey != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = __pTagConditionMap->Add(*pKey, *pNewEventMap);
+ r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Internal map error. Adding a new event map has failed.");
+
+ pKey.release();
+ pEventMap = pNewEventMap.release();
+ }
+ else
+ {
+ // if the event instance with the specified listener already exists, the adding operation fails
+ // because only one listener can be added in the event.
+ _NfcTagDiscoveryEvent* pEvent = null;
+ r = pEventMap->GetValue(&listener, pEvent);
+ SysTryReturnResult(NID_NET_NFC, pEvent == null, E_OBJ_ALREADY_EXIST,
+ "The listener with the specified type was already added.");
+ }
+
+ unique_ptr<_NfcTagDiscoveryEvent> pNewEvent(new (std::nothrow) _NfcTagDiscoveryEvent());
+ SysTryReturnResult(NID_NET_NFC, pNewEvent != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = pNewEvent->Construct();
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Construct of an event instance failed.");
+
+ // add a new event to the event map.
+ // this event must include only the specified listener.
+ r = pNewEvent->AddListener(listener, true);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Adding a new listener has failed.");
+
+ r = pEventMap->Add(&listener, pNewEvent.get());
+ r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Internal map error. Adding a new listener has failed.");
+
+ pNewEvent.release();
+
+ return E_SUCCESS;
+}
+
+result
+_NfcManagerImpl::RemoveTagDiscoveryEventListener(INfcTagDiscoveryEventListener& listener, NfcTagType type)
+{
+ result r = E_SUCCESS;
+ _NfcTagEventMap* pEventMap = null;
+ _NfcTagDiscoveryEvent* pEvent = null;
+
+ // find the event map which is related with the specified tag type.
+ pEventMap = dynamic_cast <_NfcTagEventMap*> (__pTagConditionMap->GetValue(Integer(type)));
+ SysTryReturnResult(NID_NET_NFC, pEventMap != null, E_OBJ_NOT_FOUND, "The listener with the specified type was not found.");
+
+ // find the event which is related with the specified listener.
+ r = pEventMap->GetValue(&listener, pEvent);
+ SysTryReturnResult(NID_NET_NFC, r != E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "The listener with the specified type was not found.");
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Removing the listener has failed.");
+
+ // remove the event from the event map.
+ r = pEventMap->Remove(&listener);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Removing the listener has failed.");
+
+ delete pEvent;
+
+ // if the event map has no event, delete it from the condition map.
+ if (pEventMap->GetCount() == 0)
+ {
+ (void) __pTagConditionMap->Remove(Integer(type)); // ignore the result of removal
+ }
+
+ return E_SUCCESS;
+}
+
+result
+_NfcManagerImpl::AddNdefMessageDiscoveryEventListener(INdefMessageDiscoveryEventListener& listener,
+ const NdefRecordType& recordType)
+{
+ result r = E_SUCCESS;
+ _NdefMsgEventMap* pEventMap = null;
+
+ NdefRecordTypeNameFormat tnf = recordType.GetNameFormat();
+ if ((tnf == NDEF_TNF_WELL_KNOWN) || (tnf == NDEF_TNF_MIME_MEDIA) ||
+ (tnf == NDEF_TNF_ABSOLUTE_URI) || (tnf == NDEF_TNF_EXTERNAL))
+ {
+ SysTryReturnResult(NID_NET_NFC, recordType.GetName().IsEmpty() == false, E_INVALID_ARG,
+ "The empty string as a record type name is not allowed.");
+ }
+
+ pEventMap = dynamic_cast <_NdefMsgEventMap*> (__pNdefConditionMap->GetValue(recordType));
+
+ if (pEventMap == null)
+ {
+ // this condition - the specified record type - is registered first time,
+ // therefore, create a new event map which is related with the specified record type.
+ unique_ptr<_NdefMsgEventMap> pNewEventMap(new (std::nothrow) _NdefMsgEventMap());
+ SysTryReturnResult(NID_NET_NFC, pNewEventMap != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = pNewEventMap->Construct();
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Construct of an event map instance failed.");
+
+ unique_ptr<NdefRecordType> pKey(new (std::nothrow) NdefRecordType(recordType));
+ SysTryReturnResult(NID_NET_NFC, pKey != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = __pNdefConditionMap->Add(*pKey, *pNewEventMap);
+ r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Internal map error. Adding a new event map has failed.");
+
+ pKey.release();
+ pEventMap = pNewEventMap.release();
+ }
+ else
+ {
+ // if the event instance with the specified listner already exists, the adding operation fails
+ // because only one listener can be added in the event.
+ _NdefMessageDiscoveryEvent* pEvent = null;
+ r = pEventMap->GetValue(&listener, pEvent);
+ SysTryReturnResult(NID_NET_NFC, pEvent == null, E_OBJ_ALREADY_EXIST,
+ "The listener with the specified type was already added.");
+ }
+
+ unique_ptr<_NdefMessageDiscoveryEvent> pNewEvent(new (std::nothrow) _NdefMessageDiscoveryEvent());
+ SysTryReturnResult(NID_NET_NFC, pNewEvent != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = pNewEvent->Construct();
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Construct of an event instance failed.");
+
+ // add a new event to the event map.
+ // this event must include only the specified listener.
+ r = pNewEvent->AddListener(listener, true);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Adding a new listener has failed.");
+
+ r = pEventMap->Add(&listener, pNewEvent.get());
+ r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Internal map error. Adding a new listener has failed.");
+
+ pNewEvent.release();
+
+ return E_SUCCESS;
+}
+
+result
+_NfcManagerImpl::RemoveNdefMessageDiscoveryEventListener(INdefMessageDiscoveryEventListener& listener,
+ const NdefRecordType& recordType)
+{
+ result r = E_SUCCESS;
+ _NdefMsgEventMap* pEventMap = null;
+ _NdefMessageDiscoveryEvent* pEvent = null;
+
+ NdefRecordTypeNameFormat tnf = recordType.GetNameFormat();
+ if ((tnf == NDEF_TNF_WELL_KNOWN) || (tnf == NDEF_TNF_MIME_MEDIA) ||
+ (tnf == NDEF_TNF_ABSOLUTE_URI) || (tnf == NDEF_TNF_EXTERNAL))
+ {
+ SysTryReturnResult(NID_NET_NFC, recordType.GetName().IsEmpty() == false, E_INVALID_ARG,
+ "The empty string as a record type name is not allowed.");
+ }
+
+ // find the event map which is related with the specified record type.
+ pEventMap = dynamic_cast <_NdefMsgEventMap*> (__pNdefConditionMap->GetValue(recordType));
+ SysTryReturnResult(NID_NET_NFC, pEventMap != null, E_OBJ_NOT_FOUND, "The listener with the specified type was not found.");
+
+ // find the event which is related with the specified listener.
+ r = pEventMap->GetValue(&listener, pEvent);
+ SysTryReturnResult(NID_NET_NFC, r != E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "The listener with the specified type was not found.");
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Removing the listener has failed.");
+
+ // remove the event from the event map.
+ r = pEventMap->Remove(&listener);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Removing the listener has failed.");
+
+ delete pEvent;
+
+ // if the event map has no event, delete it from the condition map.
+ if (pEventMap->GetCount() == 0)
+ {
+ (void) __pNdefConditionMap->Remove(recordType); // ignore the result of removal
+ }
+
+ return E_SUCCESS;
+}
+
+result
+_NfcManagerImpl::AddDeviceDiscoveryEventListener(INfcDeviceDiscoveryEventListener& listener)
+{
+ result r = E_SUCCESS;
+
+ r = __pDeviceDiscoveryEvent->AddListener(listener, true);
+ SysTryReturnResult(NID_NET_NFC, r != E_OBJ_ALREADY_EXIST, r, "The listener was already added.");
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Adding a new listener has failed.");
+
+ return E_SUCCESS;
+}
+
+result
+_NfcManagerImpl::RemoveDeviceDiscoveryEventListener(INfcDeviceDiscoveryEventListener& listener)
+{
+ result r = E_SUCCESS;
+
+ r = __pDeviceDiscoveryEvent->RemoveListener(listener);
+ SysTryReturnResult(NID_NET_NFC, r != E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "The listener was not found.");
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Removing the listener has failed.");
+
+ return E_SUCCESS;
+}
+
+void
+_NfcManagerImpl::OnNfcActivated(result r)
+{
+ SysLog(NID_NET_NFC, "EntryPoint, [CurrentState:%s], [result:%s]", GetStringOfCurrentState(), GetErrorMessage(r));
+
+ bool isFired = false;
+
+ __stateMutex.Acquire();
+
+ switch (__currentState)
+ {
+ case _NFC_MANAGER_STATE_DISABLED:
+ if (r == E_SUCCESS)
+ {
+ __currentState = _NFC_MANAGER_STATE_IDLE;
+ isFired = true;
+ }
+ break;
+
+ case _NFC_MANAGER_STATE_ACTIVATING:
+ if (r == E_SUCCESS)
+ {
+ __currentState = _NFC_MANAGER_STATE_IDLE;
+ }
+ else
+ {
+ __currentState = _NFC_MANAGER_STATE_DISABLED;
+ }
+ isFired = true;
+ break;
+
+ default:
+ break;
+ }
+
+ __stateMutex.Release();
+
+ if (isFired)
+ {
+ if (r != E_SUCCESS)
+ {
+ SysLogException(NID_NET_NFC, r, "[%s] exception occurred during activating NFC.", GetErrorMessage(r));
+ }
+
+ _NfcManagerEventArg* pArg = new (std::nothrow) _NfcManagerEventArg(_NFC_MGR_EVENT_TYPE_ACTIVATED, r);
+ SysTryReturnVoidResult(NID_NET_NFC, pArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ __pMgrEvent->FireAsync(*pArg);
+ }
+
+ SysLog(NID_NET_NFC, "ExitPoint, [CurrentState:%s], [ACTIVATED_Event:%s]",
+ GetStringOfCurrentState(), isFired ? "Fired" : "NotFired");
+}
+
+void
+_NfcManagerImpl::OnNfcDeactivated(result r)
+{
+ SysLog(NID_NET_NFC, "EntryPoint, [CurrentState:%s], [result:%s]", GetStringOfCurrentState(), GetErrorMessage(r));
+
+ bool isFired = false;
+
+ __stateMutex.Acquire();
+
+ switch (__currentState)
+ {
+ case _NFC_MANAGER_STATE_IDLE:
+ case _NFC_MANAGER_STATE_CONNECTED:
+ if (r == E_SUCCESS)
+ {
+ __currentState = _NFC_MANAGER_STATE_DISABLED;
+ isFired = true;
+ }
+ break;
+
+ case _NFC_MANAGER_STATE_DEACTIVATING:
+ if (r == E_SUCCESS)
+ {
+ __currentState = _NFC_MANAGER_STATE_DISABLED;
+ }
+ else
+ {
+ __currentState = _NFC_MANAGER_STATE_IDLE;
+ }
+ isFired = true;
+ break;
+
+ default:
+ break;
+ }
+
+ __stateMutex.Release();
+
+ if (isFired)
+ {
+ if (r != E_SUCCESS)
+ {
+ SysLogException(NID_NET_NFC, r, "[%s] exception occurred during deactivating NFC.", GetErrorMessage(r));
+ }
+
+ _NfcManagerEventArg* pArg = new (std::nothrow) _NfcManagerEventArg(_NFC_MGR_EVENT_TYPE_DEACTIVATED, r);
+ SysTryReturnVoidResult(NID_NET_NFC, pArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ __pMgrEvent->FireAsync(*pArg);
+ }
+
+ SysLog(NID_NET_NFC, "ExitPoint, [CurrentState:%s], [DEACTIVATED_Event:%s]",
+ GetStringOfCurrentState(), isFired ? "Fired" : "NotFired");
+}
+
+void
+_NfcManagerImpl::OnNdefMessageDetected(const NdefMessage& message)
+{
+ SysLog(NID_NET_NFC, "EntryPoint, [CurrentState:%s]", GetStringOfCurrentState());
+
+ bool isFired = false;
+
+ if ((__currentState == _NFC_MANAGER_STATE_DEACTIVATING)
+ || (__currentState == _NFC_MANAGER_STATE_IDLE)
+ || (__currentState == _NFC_MANAGER_STATE_CONNECTED))
+ {
+ isFired = SendNdefMessageDetectedEvent(message);
+ }
+
+ SysLog(NID_NET_NFC, "ExitPoint, [CurrentState:%s], [MSG_DETECTED_Event:%s]",
+ GetStringOfCurrentState(), isFired ? "Fired" : "NotFired");
+}
+
+void
+_NfcManagerImpl::OnNfcTagDetected(void)
+{
+ SysLog(NID_NET_NFC, "EntryPoint, [CurrentState:%s]", GetStringOfCurrentState());
+
+ bool isFired = false;
+
+ // changes the current state and state information.
+ __stateMutex.Acquire();
+
+ if (__currentState == _NFC_MANAGER_STATE_IDLE)
+ {
+ __currentState = _NFC_MANAGER_STATE_CONNECTED;
+
+ delete __pCurrentTagImpl;
+ __pCurrentTagImpl = __pSystemAdapter->GetCurrentTagImplN();
+
+ if (__pCurrentTagImpl != null)
+ {
+ // display the information of the connected tag
+ PrintTag(*__pCurrentTagImpl);
+
+ // send events to listeners
+ isFired = SendTagDiscoveryEvent(*__pCurrentTagImpl, true);
+ }
+ else
+ {
+ SysLogException(NID_NET_NFC, E_SYSTEM, "[E_SYSTEM] Failed to get the connected tag in spite of the connected state!");
+ }
+ }
+ // ignore the event in other states
+
+ __stateMutex.Release();
+
+ SysLog(NID_NET_NFC, "ExitPoint, [CurrentState:%s], [TAG_DETECTED_Event:%s]",
+ GetStringOfCurrentState(), isFired ? "Fired" : "NotFired");
+}
+
+void
+_NfcManagerImpl::OnNfcTagLost(void)
+{
+ SysLog(NID_NET_NFC, "EntryPoint, [CurrentState:%s]", GetStringOfCurrentState());
+
+ bool isFired = false;
+
+ __stateMutex.Acquire();
+
+ if ((__currentState == _NFC_MANAGER_STATE_CONNECTED) || (__currentState == _NFC_MANAGER_STATE_DEACTIVATING))
+ {
+ if (__currentState == _NFC_MANAGER_STATE_CONNECTED)
+ {
+ __currentState = _NFC_MANAGER_STATE_IDLE;
+ }
+
+ if (__pCurrentTagImpl != null)
+ {
+ // send events to listeners
+ isFired = SendTagDiscoveryEvent(*__pCurrentTagImpl, false);
+ delete __pCurrentTagImpl;
+ __pCurrentTagImpl = null;
+ }
+ }
+ // ignore the event in other states
+
+ __stateMutex.Release();
+
+ SysLog(NID_NET_NFC, "ExitPoint, [CurrentState:%s], [TAG_LOST_Event:%s]",
+ GetStringOfCurrentState(), isFired ? "Fired" : "NotFired");
+}
+
+void
+_NfcManagerImpl::OnNfcDeviceDetected(void)
+{
+ SysLog(NID_NET_NFC, "EntryPoint, [CurrentState:%s]", GetStringOfCurrentState());
+
+ bool isFired = false;
+
+ __stateMutex.Acquire();
+
+ if (__currentState == _NFC_MANAGER_STATE_IDLE)
+ {
+ __currentState = _NFC_MANAGER_STATE_CONNECTED;
+ isFired = true;
+ }
+ // ignore the event in other states
+
+ __stateMutex.Release();
+
+ if (isFired)
+ {
+ _NfcDeviceDiscoveryEventArg* pArg = new (std::nothrow)
+ _NfcDeviceDiscoveryEventArg(_NFC_DEVICE_DISCOVERY_EVENT_TYPE_DETECTED);
+ SysTryReturnVoidResult(NID_NET_NFC, pArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ __pDeviceDiscoveryEvent->FireAsync(*pArg);
+ }
+
+ SysLog(NID_NET_NFC, "ExitPoint, [CurrentState:%s], [DEV_DETECTED_Event:%s]",
+ GetStringOfCurrentState(), isFired ? "Fired" : "NotFired");
+}
+
+void
+_NfcManagerImpl::OnNfcDeviceLost(void)
+{
+ SysLog(NID_NET_NFC, "EntryPoint, [CurrentState:%s]", GetStringOfCurrentState());
+
+ bool isFired = false;
+
+ __stateMutex.Acquire();
+
+ if ((__currentState == _NFC_MANAGER_STATE_CONNECTED) || (__currentState == _NFC_MANAGER_STATE_DEACTIVATING))
+ {
+ if (__currentState == _NFC_MANAGER_STATE_CONNECTED)
+ {
+ __currentState = _NFC_MANAGER_STATE_IDLE;
+ }
+ isFired = true;
+ }
+ // ignore the event in other states
+
+ __stateMutex.Release();
+
+ if (isFired)
+ {
+ _NfcDeviceDiscoveryEventArg* pArg = new (std::nothrow) _NfcDeviceDiscoveryEventArg(_NFC_DEVICE_DISCOVERY_EVENT_TYPE_LOST);
+ SysTryReturnVoidResult(NID_NET_NFC, pArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ __pDeviceDiscoveryEvent->FireAsync(*pArg);
+ }
+
+ SysLog(NID_NET_NFC, "ExitPoint, [CurrentState:%s], [DEV_LOST_Event:%s]",
+ GetStringOfCurrentState(), isFired ? "Fired" : "NotFired");
+}
+
+NdefMessage*
+_NfcManagerImpl::GetCachedNdefMessageN(void)
+{
+ return _NfcSystemAdapter::GetCachedNdefMessageN();
+}
+
+result
+_NfcManagerImpl::SetLaunchPopupEnabled(bool enable)
+{
+ result r = E_SYSTEM;
+
+ r = _NfcSystemAdapter::GetInstance()->SetLaunchPopupEnabled(enable);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, r, r, "[%s] error occurred on %s the launch popup.",
+ GetErrorMessage(r), enable ? "enabling" : "disabling");
+
+ return E_SUCCESS;
+}
+
+bool
+_NfcManagerImpl::SendTagDiscoveryEvent(const _NfcTagImpl& tag, bool isDetected)
+{
+ result r = E_SUCCESS;
+ bool isFired = false;
+ _NfcTagEventMap* pEventMap = null;
+ ArrayListT<NfcTagType> conditionList;
+ LinkedListT<INfcTagDiscoveryEventListener*> firedList;
+
+ // make the list which includes all conditions related to this tag.
+ r = conditionList.Construct(*(tag.GetTagTypeList()));
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, false, E_SYSTEM, "[E_SYSTEM] Internal list error.");
+
+ if (tag.IsNdefSupported())
+ {
+ conditionList.Add(NFC_TAG_TYPE_ALL_NDEF_COMPATIBLE);
+ }
+ conditionList.Add(NFC_TAG_TYPE_ALL);
+
+ unique_ptr< IEnumeratorT<NfcTagType> > pConditionEnum(conditionList.GetEnumeratorN());
+ // interate all related tag types and notify events for each tag type
+ while (pConditionEnum->MoveNext() == E_SUCCESS)
+ {
+ NfcTagType type;
+ pConditionEnum->GetCurrent(type);
+
+ pEventMap = dynamic_cast <_NfcTagEventMap*> (__pTagConditionMap->GetValue(Integer(type)));
+ if (pEventMap != null)
+ {
+ unique_ptr<_NfcTagEventMapEnumerator> pEventMapEnum(pEventMap->GetMapEnumeratorN());
+ while (pEventMapEnum->MoveNext() == E_SUCCESS)
+ {
+ INfcTagDiscoveryEventListener* pListener = null;
+ pEventMapEnum->GetKey(pListener);
+
+ if (firedList.Contains(pListener) == false)
+ {
+ _NfcTagDiscoveryEvent* pEvent = null;
+ pEventMapEnum->GetValue(pEvent);
+
+ // make the event arg instance
+ _NfcTagDiscoveryEventArg* pArg = null;
+ if (isDetected)
+ {
+ pArg = new (std::nothrow) _NfcTagDiscoveryEventArg(tag); // for the detected event
+ }
+ else
+ {
+ pArg = new (std::nothrow) _NfcTagDiscoveryEventArg(); // for the lost event
+ }
+ SysTryReturn(NID_NET_NFC, pArg != null, false, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ // fire the event if the listener is found in at first time
+ pEvent->FireAsync(*pArg);
+ firedList.Add(pListener);
+ }
+ }
+
+ isFired = true;
+ }
+ }
+
+ return isFired;
+}
+
+bool
+_NfcManagerImpl::SendNdefMessageDetectedEvent(const NdefMessage& message)
+{
+ bool isFired = false;
+ _NdefMsgEventMap* pEventMap = null;
+ LinkedList conditionList(SingleObjectDeleter);
+ LinkedListT<INdefMessageDiscoveryEventListener*> firedList;
+
+ // make the list which includes all conditions related to this tag.
+ int recordCount = message.GetRecordsCount();
+
+ for (int i = 0; i < recordCount; i++)
+ {
+ const NdefRecord* pRecord = message.GetRecordAt(i);
+ NdefRecordType recordType = pRecord->GetRecordType();
+
+ // get all equivalent record type which are the same condition as this record type.
+ IList* pKeyList = _NdefMessageUtil::GetEquivalentRecordTypesN(recordType);
+ SysTryReturn(NID_NET_NFC, pKeyList != null, false, E_SYSTEM, "[E_SYSTEM] Getting equivalent record types failed.");
+
+ (void) conditionList.AddItems(*pKeyList); // shallow copy, ignore the result.
+ delete pKeyList;
+ }
+
+ NdefRecordType* pAllRecordType = new NdefRecordType(NDEF_TNF_ALL);
+ SysTryReturn(NID_NET_NFC, pAllRecordType != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ conditionList.Add(*pAllRecordType);
+
+ unique_ptr<IEnumerator> pConditionEnum(conditionList.GetEnumeratorN());
+ // interate all related tag types and notify events for each tag type
+ while (pConditionEnum->MoveNext() == E_SUCCESS)
+ {
+ NdefRecordType* pType = dynamic_cast<NdefRecordType*> (pConditionEnum->GetCurrent());
+ SysTryReturn(NID_NET_NFC, pType != null, false, E_SYSTEM, "[E_SYSTEM] Internal list error.");
+
+ pEventMap = dynamic_cast <_NdefMsgEventMap*> (__pNdefConditionMap->GetValue(*pType));
+ if (pEventMap != null)
+ {
+ unique_ptr<_NdefMsgEventMapEnumerator> pEventMapEnum(pEventMap->GetMapEnumeratorN());
+ while (pEventMapEnum->MoveNext() == E_SUCCESS)
+ {
+ INdefMessageDiscoveryEventListener* pListener = null;
+ pEventMapEnum->GetKey(pListener);
+
+ if (firedList.Contains(pListener) == false)
+ {
+ _NdefMessageDiscoveryEvent* pEvent = null;
+ pEventMapEnum->GetValue(pEvent);
+
+ // make the event arg instance
+ _NdefMessageDiscoveryEventArg* pArg = new (std::nothrow) _NdefMessageDiscoveryEventArg(message);
+ SysTryReturn(NID_NET_NFC, pArg != null, false, GetLastResult(),
+ "[%s] Propagating. Creating EventArg failed.", GetErrorMessage(GetLastResult()));
+
+ // fire the event if the listener is found in at first time
+ pEvent->FireAsync(*pArg);
+ firedList.Add(pListener);
+ }
+ }
+
+ isFired = true;
+ }
+ }
+
+ return isFired;
+}
+
+const char*
+_NfcManagerImpl::GetStringOfCurrentState(void) const
+{
+ const char* pStateString = null;
+
+ switch (__currentState)
+ {
+ case _NFC_MANAGER_STATE_DISABLED:
+ pStateString = "DISABLED";
+ break;
+
+ case _NFC_MANAGER_STATE_ACTIVATING:
+ pStateString = "ACTIVATING";
+ break;
+
+ case _NFC_MANAGER_STATE_DEACTIVATING:
+ pStateString = "DEACTIVATING";
+ break;
+
+ case _NFC_MANAGER_STATE_IDLE:
+ pStateString = "IDLE";
+ break;
+
+ case _NFC_MANAGER_STATE_CONNECTED:
+ pStateString = "CONNECTED";
+ break;
+
+ default:
+ pStateString = "";
+ break;
+ }
+
+ return pStateString;
+}
+
+const char*
+_NfcManagerImpl::GetStringOfTagType(NfcTagType tagType) const
+{
+ const char* pTypeString = null;
+
+ switch (tagType)
+ {
+ case NFC_TAG_TYPE_UNKNOWN:
+ pTypeString = "Unknown";
+ break;
+
+ case NFC_TAG_TYPE_ISO14443_3A:
+ pTypeString = "ISO14443-3A";
+ break;
+
+ case NFC_TAG_TYPE_ISO14443_3B:
+ pTypeString = "ISO14443-3B";
+ break;
+
+ case NFC_TAG_TYPE_FELICA:
+ pTypeString = "FeliCa";
+ break;
+
+ case NFC_TAG_TYPE_ISO15693:
+ pTypeString = "ISO15693";
+ break;
+
+ case NFC_TAG_TYPE_TOPAZ_JEWEL:
+ pTypeString = "Topaz/Jewel";
+ break;
+
+ case NFC_TAG_TYPE_MIFARE_UL:
+ pTypeString = "Mifare Ultralight";
+ break;
+
+ case NFC_TAG_TYPE_MIFARE_CLASSIC:
+ pTypeString = "Mifare Classic";
+ break;
+
+ case NFC_TAG_TYPE_ISO14443_4:
+ pTypeString = "ISO14443-4";
+ break;
+
+ case NFC_TAG_TYPE_FORUM_TYPE_1:
+ pTypeString = "Forum Type 1";
+ break;
+
+ case NFC_TAG_TYPE_FORUM_TYPE_2:
+ pTypeString = "Forum Type 2";
+ break;
+
+ case NFC_TAG_TYPE_FORUM_TYPE_3:
+ pTypeString = "Forum Type 3";
+ break;
+
+ case NFC_TAG_TYPE_FORUM_TYPE_4:
+ pTypeString = "Forum Type 4";
+ break;
+
+ case NFC_TAG_TYPE_ALL_NDEF_COMPATIBLE:
+ pTypeString = "All NDEF compatible types";
+ break;
+
+ case NFC_TAG_TYPE_ALL:
+ pTypeString = "All types";
+ break;
+
+ default:
+ pTypeString = "";
+ break;
+ }
+
+ return pTypeString;
+}
+
+void
+_NfcManagerImpl::ConvertByteToString(const Tizen::Base::ByteBuffer* pSrcBytes, Tizen::Base::String& hexString) const
+{
+ String tempHex;
+ byte b = 0x00;
+ int count = 0;
+
+ hexString.Clear();
+ count = pSrcBytes->GetRemaining();
+
+ for (int i = pSrcBytes->GetPosition(); i < count; i++)
+ {
+ pSrcBytes->GetByte(i, b);
+ tempHex.Format(3, L"%02X", b);
+ hexString.Append(tempHex);
+ hexString.Append(L" ");
+ }
+}
+
+void
+_NfcManagerImpl::PrintTag(const _NfcTagImpl& tag) const
+{
+ const ByteBuffer* pTagIdByte = null;
+ String tagIdStr(L"null");
+ const IListT <NfcTagType>* pTagTypeList = null;
+ int count = 0;
+ NfcTagType tagType = NFC_TAG_TYPE_UNKNOWN;
+
+ pTagIdByte = tag.GetId();
+ if (pTagIdByte)
+ {
+ ConvertByteToString(pTagIdByte, tagIdStr);
+ }
+ SysLog(NID_NET_NFC, "[Tag] ID : %ls", tagIdStr.GetPointer());
+
+ pTagTypeList = tag.GetTagTypeList();
+ count = pTagTypeList->GetCount();
+
+ for (int i = 0; i < count; i++)
+ {
+ pTagTypeList->GetAt(i, tagType);
+ SysLog(NID_NET_NFC, "[Tag] Type : %s", GetStringOfTagType(tagType));
+ }
+
+ SysLog(NID_NET_NFC, "[Tag] %s format", tag.IsNdefSupported() ? "NDEF" : "No NDEF");
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfc_NfcSystemAdapter.cpp
+// @brief This is the implementation file for _NfcSystemAdapter class.
+//
+// This file contains the implementation of _NfcSystemAdapter class.
+//
+
+#include <FBaseByteBuffer.h>
+#include <FBaseSysLog.h>
+#include <FBaseColLinkedListT.h>
+#include <FNetNfcNdefMessage.h>
+#include "FNetNfc_NfcIpcProxy.h"
+#include "FNetNfc_NfcSystemAdapter.h"
+#include "FNetNfc_NfcTagImpl.h"
+#include "FNetNfc_NdefMessageUtil.h"
+#include "FNetNfc_NfcManagerImpl.h"
+#include "FNetNfc_TagConnectionImpl.h"
+#include "FNetNfc_NdefPushManagerImpl.h"
+#include "FNetNfc_INfcTagDiscoveryEventListener.h"
+#include "FNetNfc_INfcDeviceDiscoveryEventListener.h"
+
+#ifdef _NfcConvertErrorResult
+#undef _NfcConvertErrorResult
+#endif
+#define _NfcConvertErrorResult(condition, r, value) \
+ do \
+ { \
+ if (condition) { \
+ r = value; \
+ } \
+ } while (0);
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Net::Nfc;
+
+_NfcSystemAdapter* _NfcSystemAdapter::__pSingleton = null;
+
+static const char* KEY_TAG_ID_ISO14443_3A = "UID";
+static const char* KEY_TAG_ID_ISO14443_3B = "UID";
+static const char* KEY_TAG_ID_FELICA = "IDm";
+static const char* KEY_TAG_ID_ISO15693 = "UID";
+
+const bool _NFC_ACTIVATE = true;
+const bool _NFC_DEACTIVATE = false;
+const int _NFC_ID_BUFFER_MAX = 10;
+
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+struct _NfcTagIdPair
+{
+ _NfcTagIdPair(void)
+ : pTagIdKey(null)
+ , tagIdValue()
+ {
+ tagIdValue.Construct(_NFC_ID_BUFFER_MAX);
+ }
+
+ const char* pTagIdKey;
+ Tizen::Base::ByteBuffer tagIdValue;
+};
+
+_NfcSystemAdapter::_NfcSystemAdapter(void)
+ : __pTagDiscListenerList(null)
+ , __pDevDiscListenerList(null)
+ , __pMgrImplList(null)
+ , __pConnImplList(null)
+ , __pPushMgrImplList(null)
+ , __tagHandle(null)
+ , __p2pTargetHandle(null)
+ , __isConnected(false)
+ , __pIpcProxy(null)
+{
+}
+
+_NfcSystemAdapter::~_NfcSystemAdapter(void)
+{
+ int res = NFC_ERROR_NONE;
+
+ // unset callback
+ nfc_manager_unset_activation_changed_cb();
+ nfc_manager_unset_tag_discovered_cb();
+ nfc_manager_unset_ndef_discovered_cb();
+ nfc_manager_unset_p2p_target_discovered_cb();
+
+ // deinitialize
+ res = nfc_manager_deinitialize();
+ if (res != NFC_ERROR_NONE)
+ {
+ SysLogException(NID_NET_NFC, E_SYSTEM, "[E_SYSTEM] Failed to de-initialize the nfc manager [0x%08X]", res);
+ }
+
+ delete __pTagDiscListenerList;
+ delete __pDevDiscListenerList;
+ delete __pMgrImplList;
+ delete __pConnImplList;
+ delete __pPushMgrImplList;
+
+ __pSingleton = null;
+}
+
+result
+_NfcSystemAdapter::Construct(void)
+{
+ result r = E_SUCCESS;
+ int res = NFC_ERROR_NONE;
+
+ unique_ptr< LinkedListT<_INfcTagDiscoveryEventListener*> >
+ pTagDiscListenerList(new (std::nothrow) LinkedListT<_INfcTagDiscoveryEventListener*>());
+ SysTryReturnResult(NID_NET_NFC, pTagDiscListenerList != null, E_OUT_OF_MEMORY, "Failure to create LinkedList instance.");
+
+ unique_ptr< LinkedListT<_INfcDeviceDiscoveryEventListener*> >
+ pDevDiscListenerList(new (std::nothrow) LinkedListT<_INfcDeviceDiscoveryEventListener*>());
+ SysTryReturnResult(NID_NET_NFC, pDevDiscListenerList != null, E_OUT_OF_MEMORY, "Failure to create LinkedList instance.");
+
+ unique_ptr< LinkedListT<_NfcManagerImpl*> > pMgrImplList(new (std::nothrow) LinkedListT<_NfcManagerImpl*>());
+ SysTryReturnResult(NID_NET_NFC, pMgrImplList != null, E_OUT_OF_MEMORY, "Failure to create LinkedList instance.");
+
+ unique_ptr< LinkedListT<_TagConnectionImpl*> > pConnImplList(new (std::nothrow) LinkedListT<_TagConnectionImpl*>());
+ SysTryReturnResult(NID_NET_NFC, pConnImplList != null, E_OUT_OF_MEMORY, "Failure to create LinkedList instance.");
+
+ unique_ptr< LinkedListT<_NdefPushManagerImpl*> > pPushMgrImplList(new (std::nothrow) LinkedListT<_NdefPushManagerImpl*>());
+ SysTryReturnResult(NID_NET_NFC, pPushMgrImplList != null, E_OUT_OF_MEMORY, "Failure to create LinkedList instance.");
+
+ // initialize the underlying system
+ res = nfc_manager_initialize_sync();
+ SysTryReturnResult(NID_NET_NFC, res == NFC_ERROR_NONE, E_SYSTEM, "Failed to initialize the NFC from the result.");
+ SysLog(NID_NET_NFC, "nfc_manager_initialize_sync() is invoked successfully.");
+
+ __pIpcProxy = _NfcIpcProxy::GetInstance();
+ SysTryReturnResult(NID_NET_NFC, __pIpcProxy != null, E_SYSTEM, "Failed to create _NfcIpcProxy.");
+
+ r = __pIpcProxy->InitializeNfc();
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM,
+ "Failed to initialize the NFC service of osp-connectivity-service.");
+
+ // set the response callback
+ nfc_manager_set_activation_changed_cb(&OnNfcActivationChanged, this);
+ nfc_manager_set_tag_discovered_cb(&OnNfcTagDiscovered, this);
+ nfc_manager_set_ndef_discovered_cb(&OnNdefMessageDiscovered, this);
+ nfc_manager_set_p2p_target_discovered_cb(&OnNfcTargetDiscovered, this);
+
+ __pTagDiscListenerList = pTagDiscListenerList.release();
+ __pDevDiscListenerList = pDevDiscListenerList.release();
+ __pMgrImplList = pMgrImplList.release();
+ __pConnImplList = pConnImplList.release();
+ __pPushMgrImplList = pPushMgrImplList.release();
+
+ return r;
+}
+
+void
+_NfcSystemAdapter::InitSingleton(void)
+{
+ unique_ptr<_NfcSystemAdapter> pInst(new (std::nothrow) _NfcSystemAdapter());
+ SysTryReturnVoidResult(NID_NET_NFC, pInst != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ result r = pInst->Construct();
+ SysTryReturnVoidResult(NID_NET_NFC, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ __pSingleton = pInst.release();
+ std::atexit(DestroySingleton);
+}
+
+void
+_NfcSystemAdapter::DestroySingleton(void)
+{
+ delete __pSingleton;
+}
+
+_NfcSystemAdapter*
+_NfcSystemAdapter::GetInstance(void)
+{
+ static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+ if (!__pSingleton)
+ {
+ ClearLastResult();
+ pthread_once(&onceBlock, InitSingleton);
+ result r = GetLastResult();
+ if (IsFailed(r))
+ {
+ onceBlock = PTHREAD_ONCE_INIT;
+ }
+ }
+
+ return __pSingleton;
+}
+
+result
+_NfcSystemAdapter::Activate(void)
+{
+ int res = NFC_ERROR_NONE;
+
+ // turn on the NFC
+ res = nfc_manager_set_activation(_NFC_ACTIVATE, &OnNfcActivationCompleted, (void*)&_NFC_ACTIVATE);
+ SysTryReturnResult(NID_NET_NFC, res == NFC_ERROR_NONE, E_SYSTEM, "Failed to turn on the NFC [0x%08X]", res);
+
+ SysLog(NID_NET_NFC, "nfc_manager_set_activation(true) is successful.");
+
+ return E_SUCCESS;
+}
+
+result
+_NfcSystemAdapter::Deactivate(void)
+{
+ int res = NFC_ERROR_NONE;
+
+ // turn off the NFC
+ res = nfc_manager_set_activation(_NFC_DEACTIVATE, &OnNfcActivationCompleted, (void*)&_NFC_DEACTIVATE);
+ SysTryReturnResult(NID_NET_NFC, res == NFC_ERROR_NONE, E_SYSTEM, "Failed to turn off the NFC [0x%08X]", res);
+
+ SysLog(NID_NET_NFC, "nfc_manager_set_activation(false) is successful.");
+
+ return E_SUCCESS;
+}
+
+bool
+_NfcSystemAdapter::IsActivated(void) const
+{
+ bool result = false;
+
+ // get nfc state
+ result = nfc_manager_is_activated();
+
+ SysLog(NID_NET_NFC, "the result of nfc_manager_is_activated() is [%s].", result ? "true" : "false");
+
+ return result;
+}
+
+bool
+_NfcSystemAdapter::IsTagConnected(void)
+{
+ nfc_tag_h tagHandle = NULL;
+
+ if (nfc_manager_get_connected_tag(&tagHandle) != NFC_ERROR_NONE)
+ {
+ return false;
+ }
+
+ __tagHandle = tagHandle;
+
+ return true;
+}
+
+bool
+_NfcSystemAdapter::IsDeviceDetected(void)
+{
+ nfc_p2p_target_h devHandle = NULL;
+
+ if (nfc_manager_get_connected_target(&devHandle) != NFC_ERROR_NONE)
+ {
+ return false;
+ }
+
+ __p2pTargetHandle = devHandle;
+
+ return true;
+}
+
+_NfcTagImpl*
+_NfcSystemAdapter::GetCurrentTagImplN(void)
+{
+ int res = NFC_ERROR_NONE;
+ nfc_tag_h currentTagHandle = null;
+
+ res = nfc_manager_get_connected_tag(¤tTagHandle);
+ SysTryReturn(NID_NET_NFC, res == NFC_ERROR_NONE, null, E_SYSTEM, "[E_SYSTEM] Failed to get the connected Tag [0x%08X].", res);
+
+ __tagHandle = currentTagHandle;
+
+ return GetNfcTagImplN(currentTagHandle);
+}
+
+result
+_NfcSystemAdapter::AddNfcTagDiscoveryEventListener(_INfcTagDiscoveryEventListener* pListener)
+{
+ result r = E_SUCCESS;
+ bool isContained = false;
+
+ isContained = __pTagDiscListenerList->Contains(pListener);
+ SysTryReturnResult(NID_NET_NFC, isContained == false, E_OBJ_ALREADY_EXIST,
+ "the _INfcTagDiscoveryEventListener instance is already added.");
+
+ r = __pTagDiscListenerList->Add(pListener);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating.");
+
+ return E_SUCCESS;
+}
+
+result
+_NfcSystemAdapter::RemoveNfcTagDiscoveryEventListener(_INfcTagDiscoveryEventListener* pListener)
+{
+ result r = E_SUCCESS;
+
+ r = __pTagDiscListenerList->Remove(pListener);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating.");
+
+ return E_SUCCESS;
+}
+
+result
+_NfcSystemAdapter::AddNfcDeviceDiscoveryEventListener(_INfcDeviceDiscoveryEventListener* pListener)
+{
+ result r = E_SUCCESS;
+ bool isContained = false;
+
+ isContained = __pDevDiscListenerList->Contains(pListener);
+ SysTryReturnResult(NID_NET_NFC, isContained == false, E_OBJ_ALREADY_EXIST,
+ "the _INfcDeviceDiscoveryEventListener instance is already added.");
+
+ r = __pDevDiscListenerList->Add(pListener);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating.");
+
+ return E_SUCCESS;
+}
+
+result
+_NfcSystemAdapter::RemoveNfcDeviceDiscoveryEventListener(_INfcDeviceDiscoveryEventListener* pListener)
+{
+ result r = E_SUCCESS;
+
+ r = __pDevDiscListenerList->Remove(pListener);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating.");
+
+ return E_SUCCESS;
+}
+
+result
+_NfcSystemAdapter::AddNfcManagerImpl(_NfcManagerImpl* pImpl)
+{
+ result r = E_SUCCESS;
+ bool isContained = false;
+
+ isContained = __pMgrImplList->Contains(pImpl);
+ SysTryReturnResult(NID_NET_NFC, isContained == false, E_OBJ_ALREADY_EXIST, "the _NfcManagerImpl instance is already added.");
+
+ r = __pMgrImplList->Add(pImpl);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating.");
+
+ return E_SUCCESS;
+}
+
+result
+_NfcSystemAdapter::RemoveNfcManagerImpl(_NfcManagerImpl* pImpl)
+{
+ result r = E_SUCCESS;
+
+ r = __pMgrImplList->Remove(pImpl);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating.");
+
+ return E_SUCCESS;
+}
+
+result
+_NfcSystemAdapter::AddTagConnectionImpl(_TagConnectionImpl* pImpl)
+{
+ result r = E_SUCCESS;
+ bool isContained = false;
+
+ isContained = __pConnImplList->Contains(pImpl);
+ SysTryReturnResult(NID_NET_NFC, isContained == false, E_OBJ_ALREADY_EXIST,
+ "the _TagConnectionImpl instance is already added.");
+
+ r = __pConnImplList->Add(pImpl);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating.");
+
+ return E_SUCCESS;
+}
+
+result
+_NfcSystemAdapter::RemoveTagConnectionImpl(_TagConnectionImpl* pImpl)
+{
+ result r = E_SUCCESS;
+
+ r = __pConnImplList->Remove(pImpl);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating.");
+
+ return E_SUCCESS;
+}
+
+result
+_NfcSystemAdapter::AddNdefPushManagerImpl(_NdefPushManagerImpl* pImpl)
+{
+ result r = E_SUCCESS;
+ bool isContained = false;
+
+ isContained = __pPushMgrImplList->Contains(pImpl);
+ SysTryReturnResult(NID_NET_NFC, isContained == false, E_OBJ_ALREADY_EXIST,
+ "the _NdefPushManagerImpl instance is already added.");
+
+ r = __pPushMgrImplList->Add(pImpl);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating.");
+
+ return E_SUCCESS;
+}
+
+result
+_NfcSystemAdapter::RemoveNdefPushManagerImpl(_NdefPushManagerImpl* pImpl)
+{
+ result r = E_SUCCESS;
+
+ r = __pPushMgrImplList->Remove(pImpl);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating.");
+
+ return E_SUCCESS;
+}
+
+result
+_NfcSystemAdapter::SendCommand(const Tizen::Base::ByteBuffer& command)
+{
+ result r = E_SUCCESS;
+ int res = NFC_ERROR_NONE;
+ int length = 0;
+ byte* pBuffer = null;
+
+ length = command.GetRemaining();
+ pBuffer = (byte*)(command.GetPointer()) + command.GetPosition();
+
+ // transceive a low level command
+ res = nfc_tag_transceive(__tagHandle, pBuffer, length, &OnNfcResponseReceived, null);
+ _NfcConvertErrorResult(res != NFC_ERROR_NONE, r, E_SYSTEM);
+ _NfcConvertErrorResult(res == NFC_ERROR_INVALID_PARAMETER, r, E_INVALID_ARG);
+ _NfcConvertErrorResult(res == NFC_ERROR_OUT_OF_MEMORY, r, E_OUT_OF_MEMORY);
+ _NfcConvertErrorResult(res == NFC_ERROR_DEVICE_BUSY, r, E_CONNECTION_BUSY);
+ _NfcConvertErrorResult(res == NFC_ERROR_TIMED_OUT, r, E_CONNECTION_FAILED);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to transceive data. [0x%08X]", res);
+
+ return E_SUCCESS;
+}
+
+result
+_NfcSystemAdapter::Read(void)
+{
+ result r = E_SUCCESS;
+ int res = NFC_ERROR_NONE;
+
+ // read the tag
+ res = nfc_tag_read_ndef(__tagHandle, &OnNdefReadCompleted, null);
+ _NfcConvertErrorResult(res != NFC_ERROR_NONE, r, E_SYSTEM);
+ _NfcConvertErrorResult(res == NFC_ERROR_OUT_OF_MEMORY, r, E_OUT_OF_MEMORY);
+ _NfcConvertErrorResult(res == NFC_ERROR_DEVICE_BUSY, r, E_CONNECTION_BUSY);
+ _NfcConvertErrorResult(res == NFC_ERROR_TIMED_OUT, r, E_CONNECTION_FAILED);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to read NDEF message. [0x%08X]", res);
+
+ return E_SUCCESS;
+}
+
+result
+_NfcSystemAdapter::Write(const NdefMessage& message)
+{
+ result r = E_SUCCESS;
+ int res = NFC_ERROR_NONE;
+ nfc_ndef_message_h ndefMessageH = NULL;
+ unsigned int length = 0;
+
+ // convert NdefMessage to ByteBuffer
+ unique_ptr<ByteBuffer> pByteBuffer(message.ToByteBufferN());
+ SysTryReturnResult(NID_NET_NFC, pByteBuffer != null, E_SYSTEM, "Failed to convert NdefMessage to ByteBuffer.");
+
+ length = pByteBuffer->GetCapacity();
+
+ // convert the NDEF message to byte array type
+ res = nfc_ndef_message_create_from_rawdata(&ndefMessageH, pByteBuffer->GetPointer(), length);
+ _NfcConvertErrorResult(res != NFC_ERROR_NONE, r, E_SYSTEM);
+ _NfcConvertErrorResult(res == NFC_ERROR_INVALID_PARAMETER, r, E_INVALID_ARG);
+ _NfcConvertErrorResult(res == NFC_ERROR_OUT_OF_MEMORY, r, E_OUT_OF_MEMORY);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to convert to NDEF raw data. [0x%08X]", res);
+
+ res = nfc_tag_write_ndef(__tagHandle, ndefMessageH, &OnNdefWriteCompleted, null);
+ nfc_ndef_message_destroy(ndefMessageH); // free the resources. (the result is ignored)
+ _NfcConvertErrorResult(res != NFC_ERROR_NONE, r, E_SYSTEM);
+ _NfcConvertErrorResult(res == NFC_ERROR_INVALID_PARAMETER, r, E_INVALID_ARG);
+ _NfcConvertErrorResult(res == NFC_ERROR_DEVICE_BUSY, r, E_CONNECTION_BUSY);
+ _NfcConvertErrorResult(res == NFC_ERROR_TIMED_OUT, r, E_CONNECTION_FAILED);
+ _NfcConvertErrorResult(res == NFC_ERROR_OUT_OF_MEMORY, r, E_OUT_OF_MEMORY);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to write NDEF data. [0x%08X]", res);
+
+ return E_SUCCESS;
+}
+
+result
+_NfcSystemAdapter::Push(const NdefMessage& message)
+{
+ SysTryReturnResult(NID_NET_NFC, __p2pTargetHandle != null, E_INVALID_STATE,
+ "[E_INVALID_STATE] The NFC feature is not activated or a peer device is not attached.");
+
+ int res = NFC_ERROR_NONE;
+ result r = E_SUCCESS;
+ nfc_ndef_message_h ndefMessageH = NULL;
+ unsigned int length = 0;
+
+ // convert NdefMessage to ByteBuffer
+ unique_ptr<ByteBuffer> pByteBuffer(message.ToByteBufferN());
+ SysTryReturnResult(NID_NET_NFC, pByteBuffer != null, E_OPERATION_FAILED,
+ "[E_OPERATION_FAILED] Failed to convert NdefMessage to ByteBuffer.");
+
+ length = pByteBuffer->GetCapacity();
+
+ // convert the NDEF message to byte array type
+ res = nfc_ndef_message_create_from_rawdata(&ndefMessageH, pByteBuffer->GetPointer(), length);
+ _NfcConvertErrorResult(res != NFC_ERROR_NONE, r, E_OPERATION_FAILED);
+ _NfcConvertErrorResult(res == NFC_ERROR_INVALID_PARAMETER, r, E_INVALID_ARG);
+ _NfcConvertErrorResult(res == NFC_ERROR_OUT_OF_MEMORY, r, E_OUT_OF_MEMORY);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to convert to NDEF raw data. [0x%08X]", res);
+
+ res = nfc_p2p_send(__p2pTargetHandle, ndefMessageH, &OnNdefMessageSent, this);
+ nfc_ndef_message_destroy(ndefMessageH); // free the resources. (the result is ignored)
+ _NfcConvertErrorResult(res != NFC_ERROR_NONE, r, E_OPERATION_FAILED);
+ _NfcConvertErrorResult(res == NFC_ERROR_INVALID_PARAMETER, r, E_INVALID_ARG);
+ _NfcConvertErrorResult(res == NFC_ERROR_DEVICE_BUSY, r, E_DEVICE_BUSY);
+ _NfcConvertErrorResult(res == NFC_ERROR_OUT_OF_MEMORY, r, E_OUT_OF_MEMORY);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to send NDEF data. [0x%08X]", res);
+
+ return E_SUCCESS;
+}
+
+result
+_NfcSystemAdapter::SetLaunchPopupEnabled(bool enable)
+{
+ int res = NFC_ERROR_NONE;
+ result r = E_SUCCESS;
+
+ res = nfc_manager_set_system_handler_enable(enable);
+ _NfcConvertErrorResult(res != NFC_ERROR_NONE, r, E_SYSTEM);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to %s system handler. [0x%08X]", enable ? "enabling" : "disabling", res);
+
+ return r;
+}
+
+void
+_NfcSystemAdapter::OnNfcActivationCompleted(nfc_error_e error, void* pUserData)
+{
+ SysLog(NID_NET_NFC, "NFC Activation Completed CB is invoked.");
+
+ _NfcSystemAdapter* pAdapter = _NfcSystemAdapter::GetInstance();
+ bool activated = *((bool*)pUserData);
+
+ // notify the event only in error cases
+ if (error != NFC_ERROR_NONE)
+ {
+ IEnumeratorT<_NfcManagerImpl*>* pEnum = pAdapter->__pMgrImplList->GetEnumeratorN();
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ _NfcManagerImpl* pImpl = null;
+ pEnum->GetCurrent(pImpl); // ignore the result because success is guaranteed
+
+ if (activated == true)
+ {
+ pImpl->OnNfcActivated(E_SYSTEM);
+ }
+ else
+ {
+ pImpl->OnNfcDeactivated(E_SYSTEM);
+ }
+ }
+ delete pEnum;
+ }
+}
+
+void
+_NfcSystemAdapter::OnNfcActivationChanged(bool activated, void* pUserData)
+{
+ SysLog(NID_NET_NFC, "NFC Activation Status Changed CB is invoked.");
+
+ _NfcSystemAdapter* pAdapter = static_cast< _NfcSystemAdapter* >(pUserData);
+
+ // TODO: temporary code BEGIN ================================================
+ // send the tag/device lost event if the tag/device connection has been established
+ if ((activated == false) && (pAdapter->__isConnected == true))
+ {
+ if (pAdapter->__tagHandle != NULL)
+ {
+ OnNfcTagDiscovered(NFC_DISCOVERED_TYPE_DETACHED, pAdapter->__tagHandle, pAdapter);
+ }
+ else if (pAdapter->__p2pTargetHandle != NULL)
+ {
+ OnNfcTargetDiscovered(NFC_DISCOVERED_TYPE_DETACHED, pAdapter->__p2pTargetHandle, pAdapter);
+ }
+ }
+ // TODO: temporary code END ================================================
+
+
+ IEnumeratorT<_NfcManagerImpl*>* pEnum = pAdapter->__pMgrImplList->GetEnumeratorN();
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ _NfcManagerImpl* pImpl = null;
+ pEnum->GetCurrent(pImpl); // ignore the result because success is guaranteed
+
+ if (activated == true)
+ {
+ pImpl->OnNfcActivated(E_SUCCESS);
+ }
+ else
+ {
+ pImpl->OnNfcDeactivated(E_SUCCESS);
+ }
+ }
+ delete pEnum;
+}
+
+void
+_NfcSystemAdapter::OnNfcResponseReceived(nfc_error_e res, byte* pReadData, int length, void* pUserData)
+{
+ SysLog(NID_NET_NFC, "NFC Command Response CB is invoked.");
+
+ _NfcSystemAdapter* pAdapter = _NfcSystemAdapter::GetInstance();
+ result r = E_SUCCESS;
+ unique_ptr<ByteBuffer> pResponse;
+
+ // convert the error code
+ _NfcConvertErrorResult(pReadData == NULL || res != NFC_ERROR_NONE, r, E_SYSTEM);
+ _NfcConvertErrorResult(res == NFC_ERROR_SECURITY_RESTRICTED, r, E_ILLEGAL_ACCESS);
+ _NfcConvertErrorResult(res == NFC_ERROR_DEVICE_BUSY || res == NFC_ERROR_TIMED_OUT, r, E_NOT_RESPONDING);
+
+ if (pReadData != NULL)
+ {
+ pResponse.reset(new (std::nothrow) ByteBuffer());
+ SysTryReturnVoidResult(NID_NET_NFC, pResponse != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ pResponse->Construct(length);
+ pResponse->SetArray(pReadData, 0, length);
+ pResponse->SetPosition(0);
+ }
+
+ IEnumeratorT<_TagConnectionImpl*>* pEnum = pAdapter->__pConnImplList->GetEnumeratorN();
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ _TagConnectionImpl* pImpl = null;
+ pEnum->GetCurrent(pImpl); // ignore the result because success is guaranteed
+
+ pImpl->OnNfcResponseReceived(pResponse.get(), r);
+ }
+ delete pEnum;
+}
+
+void
+_NfcSystemAdapter::OnNdefReadCompleted(nfc_error_e res, nfc_ndef_message_h message, void* pUserData)
+{
+ SysLog(NID_NET_NFC, "NFC NDEF Read Completed CB is invoked.");
+
+ _NfcSystemAdapter* pAdapter = _NfcSystemAdapter::GetInstance();
+ result r = E_SUCCESS;
+ unique_ptr<NdefMessage, _NdefMessageDeleter> pNdefMessage;
+
+ // convert the error code
+ _NfcConvertErrorResult(message == NULL || res != NFC_ERROR_NONE, r, E_SYSTEM);
+ _NfcConvertErrorResult(res == NFC_ERROR_NO_NDEF_MESSAGE, r, E_DATA_NOT_FOUND);
+ _NfcConvertErrorResult(res == NFC_ERROR_NOT_NDEF_FORMAT, r, E_INVALID_FORMAT);
+ _NfcConvertErrorResult(res == NFC_ERROR_DEVICE_BUSY || res == NFC_ERROR_TIMED_OUT, r, E_NOT_RESPONDING);
+
+ if (r == E_SUCCESS)
+ {
+ pNdefMessage.reset(pAdapter->GetNdefMessageN(message));
+ r = GetLastResult();
+ }
+
+ IEnumeratorT<_TagConnectionImpl*>* pEnum = pAdapter->__pConnImplList->GetEnumeratorN();
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ _TagConnectionImpl* pImpl = null;
+ pEnum->GetCurrent(pImpl); // ignore the result because success is guaranteed
+
+ pImpl->OnNdefReadCompleted(pNdefMessage.get(), r);
+ }
+ delete pEnum;
+}
+
+void
+_NfcSystemAdapter::OnNdefWriteCompleted(nfc_error_e res, void* pUserData)
+{
+ SysLog(NID_NET_NFC, "NFC NDEF Write Completed CB is invoked.");
+
+ _NfcSystemAdapter* pAdapter = _NfcSystemAdapter::GetInstance();
+ result r = E_SUCCESS;
+
+ // convert the error code
+ _NfcConvertErrorResult(res != NFC_ERROR_NONE, r, E_SYSTEM);
+ _NfcConvertErrorResult(res == NFC_ERROR_NO_SPACE_ON_NDEF, r, E_STORAGE_FULL);
+ _NfcConvertErrorResult(res == NFC_ERROR_DEVICE_BUSY || res == NFC_ERROR_TIMED_OUT, r, E_NOT_RESPONDING);
+ _NfcConvertErrorResult(res == NFC_ERROR_READ_ONLY_NDEF || res == NFC_ERROR_SECURITY_RESTRICTED, r, E_ILLEGAL_ACCESS);
+
+ IEnumeratorT<_TagConnectionImpl*>* pEnum = pAdapter->__pConnImplList->GetEnumeratorN();
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ _TagConnectionImpl* pImpl = null;
+ pEnum->GetCurrent(pImpl); // ignore the result because success is guaranteed
+
+ pImpl->OnNdefWriteCompleted(r);
+ }
+ delete pEnum;
+}
+
+void
+_NfcSystemAdapter::OnNfcTagDiscovered(nfc_discovered_type_e type, nfc_tag_h tag, void* pUserData)
+{
+ _NfcSystemAdapter* pAdapter = static_cast<_NfcSystemAdapter*>(pUserData);
+
+ if (type == NFC_DISCOVERED_TYPE_ATTACHED)
+ {
+ SysLog(NID_NET_NFC, "NFC Tag Discovered CB is invoked. (Detected)");
+ // TODO: the following statement is a temporary code
+ pAdapter->__isConnected = true;
+ pAdapter->__tagHandle = tag;
+ }
+ else if (type == NFC_DISCOVERED_TYPE_DETACHED)
+ {
+ SysLog(NID_NET_NFC, "NFC Tag Discovered CB is invoked. (Lost)");
+ // TODO: the following statement is a temporary code
+ pAdapter->__isConnected = false;
+ pAdapter->__tagHandle = NULL;
+ }
+
+ IEnumeratorT<_INfcTagDiscoveryEventListener*>* pEnum = pAdapter->__pTagDiscListenerList->GetEnumeratorN();
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ _INfcTagDiscoveryEventListener* pListener = null;
+ pEnum->GetCurrent(pListener); // ignore the result because success is guaranteed
+
+ if (type == NFC_DISCOVERED_TYPE_ATTACHED)
+ {
+ pListener->OnNfcTagDetected();
+ }
+ else if (type == NFC_DISCOVERED_TYPE_DETACHED)
+ {
+ pListener->OnNfcTagLost();
+ }
+ }
+ delete pEnum;
+}
+
+void
+_NfcSystemAdapter::OnNfcTargetDiscovered(nfc_discovered_type_e type, nfc_p2p_target_h target, void* pUserData)
+{
+ _NfcSystemAdapter* pAdapter = static_cast<_NfcSystemAdapter*>(pUserData);
+
+ if (type == NFC_DISCOVERED_TYPE_ATTACHED)
+ {
+ SysLog(NID_NET_NFC, "NFC Target Discovered CB is invoked. (Detected)");
+ // set the callback to receive NDEF message from the peer device
+ nfc_p2p_set_data_received_cb(target, &OnNdefMessageReceived, pAdapter);
+ // TODO: the following statement is a temporary code
+ pAdapter->__isConnected = true;
+ // set the P2P target handle
+ pAdapter->__p2pTargetHandle = target;
+ }
+ else if (type == NFC_DISCOVERED_TYPE_DETACHED)
+ {
+ SysLog(NID_NET_NFC, "NFC Target Discovered CB is invoked. (Lost)");
+ // unset the callback to receive NDEF message
+ nfc_p2p_unset_data_received_cb(pAdapter->__p2pTargetHandle);
+ // TODO: the following statement is a temporary code
+ pAdapter->__isConnected = false;
+ // initialize(nullify) the P2P target handle
+ pAdapter->__p2pTargetHandle = null;
+ }
+ // ignore other cases
+
+ IEnumeratorT<_INfcDeviceDiscoveryEventListener*>* pEnum = pAdapter->__pDevDiscListenerList->GetEnumeratorN();
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ _INfcDeviceDiscoveryEventListener* pListener = null;
+ pEnum->GetCurrent(pListener); // ignore the result because success is guaranteed
+
+ if (type == NFC_DISCOVERED_TYPE_ATTACHED)
+ {
+ pListener->OnNfcDeviceDetected();
+ }
+ else if (type == NFC_DISCOVERED_TYPE_DETACHED)
+ {
+ pListener->OnNfcDeviceLost();
+ }
+ }
+ delete pEnum;
+}
+
+bool
+_NfcSystemAdapter::OnNfcKeyRetrieved(const char* pKey, const unsigned char* pValue, int valueSize, void* pUserData)
+{
+ _NfcTagIdPair* pTagIdPair = static_cast<_NfcTagIdPair*>(pUserData);
+
+ if (strcmp(pKey, pTagIdPair->pTagIdKey) == 0)
+ {
+ pTagIdPair->tagIdValue.SetArray((byte*) pValue, 0, valueSize);
+ pTagIdPair->tagIdValue.Flip();
+ return false;
+ }
+
+ return true;
+}
+
+void
+_NfcSystemAdapter::OnNdefMessageDiscovered(nfc_ndef_message_h message, void* pUserData)
+{
+ SysLog(NID_NET_NFC, "The NDEF message discovered CB is called.");
+
+ _NfcSystemAdapter* pAdapter = static_cast< _NfcSystemAdapter* >(pUserData);
+ unique_ptr<NdefMessage, _NdefMessageDeleter> pNdefMessage(pAdapter->GetNdefMessageN(message));
+ SysTryReturnVoidResult(NID_NET_NFC, pNdefMessage != null, GetLastResult(),
+ "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+ IEnumeratorT<_NfcManagerImpl*>* pEnum = pAdapter->__pMgrImplList->GetEnumeratorN();
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ _NfcManagerImpl* pImpl = null;
+ pEnum->GetCurrent(pImpl); // ignore the result because success is guaranteed
+
+ pImpl->OnNdefMessageDetected(*pNdefMessage);
+ }
+ delete pEnum;
+}
+
+void
+_NfcSystemAdapter::OnNdefMessageReceived(nfc_p2p_target_h target, nfc_ndef_message_h message, void* pUserData)
+{
+ _NfcSystemAdapter* pAdapter = static_cast< _NfcSystemAdapter* >(pUserData);
+ pAdapter->OnNdefMessageDiscovered(message, pAdapter);
+}
+
+void
+_NfcSystemAdapter::OnNdefMessageSent(nfc_error_e res, void* pUserData)
+{
+ _NfcSystemAdapter* pAdapter = static_cast< _NfcSystemAdapter* >(pUserData);
+ result r = E_SUCCESS;
+
+ SysLog(NID_NET_NFC, "The NDEF message sent CB is called.");
+
+ // convert the error code
+ _NfcConvertErrorResult(res != NFC_ERROR_NONE, r, E_OPERATION_FAILED);
+ _NfcConvertErrorResult(res == NFC_ERROR_DEVICE_BUSY || res == NFC_ERROR_TIMED_OUT, r, E_NOT_RESPONDING);
+
+ IEnumeratorT<_NdefPushManagerImpl*>* pEnum = pAdapter->__pPushMgrImplList->GetEnumeratorN();
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ _NdefPushManagerImpl* pImpl = null;
+ pEnum->GetCurrent(pImpl); // ignore the result because success is guaranteed
+
+ pImpl->OnNdefPushMessageSent(r);
+ }
+ delete pEnum;
+}
+
+NdefMessage*
+_NfcSystemAdapter::GetCachedNdefMessageN(void)
+{
+ int res = NFC_ERROR_NONE;
+ result r = E_SUCCESS;
+ nfc_ndef_message_h msgHandle = null;
+ NdefMessage* pCachedMessage = null;
+
+ res = nfc_manager_get_cached_message(&msgHandle);
+ _NfcConvertErrorResult(res != NFC_ERROR_NONE, r, E_SYSTEM);
+ _NfcConvertErrorResult(res == NFC_ERROR_OUT_OF_MEMORY, r, E_OUT_OF_MEMORY);
+ _NfcConvertErrorResult(res == NFC_ERROR_INVALID_NDEF_MESSAGE, r, E_INVALID_FORMAT);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, null, r,
+ "[%s] Failed to get the cached NDEF message. [0x%08X]", GetErrorMessage(r), res);
+
+ pCachedMessage = GetNdefMessageN(msgHandle);
+ r = GetLastResult();
+ nfc_ndef_message_destroy(msgHandle);
+
+ return pCachedMessage;
+}
+
+NdefMessage*
+_NfcSystemAdapter::GetNdefMessageN(const nfc_ndef_message_h& messageHandle)
+{
+ int res = NFC_ERROR_NONE;
+ result r = E_SUCCESS;
+ byte* pTempBuffer = null;
+ unsigned int bufSize = 0;
+ ByteBuffer byteMessage;
+
+ ClearLastResult();
+
+ // get the handle of the raw data of NDEF message
+ res = nfc_ndef_message_get_rawdata(messageHandle, &pTempBuffer, &bufSize);
+ _NfcConvertErrorResult(pTempBuffer == NULL || res != NFC_ERROR_NONE, r, E_SYSTEM);
+ _NfcConvertErrorResult(res == NFC_ERROR_INVALID_NDEF_MESSAGE, r, E_INVALID_FORMAT);
+ _NfcConvertErrorResult(res == NFC_ERROR_OUT_OF_MEMORY, r, E_OUT_OF_MEMORY);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, null, r,
+ "[%s] Failed to get the raw data of the NDEF message. [0x%08X]", GetErrorMessage(r), res);
+
+ byteMessage.Construct(pTempBuffer, 0, bufSize, bufSize); // shallow copy
+
+ // convert byte buffer to NdefMessage
+ return _NdefMessageUtil::ToNdefMessageN(byteMessage);
+}
+
+_NfcTagImpl*
+_NfcSystemAdapter::GetNfcTagImplN(nfc_tag_h tagHandle)
+{
+ ////////////////////////////////////////////////////////////////////////////////
+ // in the /usr/include/nfc-common-lib/net_nfc_typedef_private.h file directory
+ // net_nfc_sIso14443AInfo_t::Uid
+ // net_nfc_sIso14443BInfo_t::AtqB::AtqResInfo::Pupi
+ // net_nfc_sFelicaInfo_t::IDm
+ // net_nfc_sIso15693Info_t::Uid
+ ////////////////////////////////////////////////////////////////////////////////
+ int res = NFC_ERROR_NONE;
+ nfc_tag_type_e type;
+ _NfcTagIdPair tagIdPair;
+ Tizen::Base::Collection::ArrayListT<NfcTagType> tagTypes;
+ bool isNdefSupport = false;
+ bool isUnknownTagType = false;
+
+ // check if the tag supports NDEF format
+ res = nfc_tag_is_support_ndef(tagHandle, &isNdefSupport);
+ SysTryReturn(NID_NET_NFC, res == NFC_ERROR_NONE, null, E_SYSTEM,
+ "[E_SYSTEM] net_nfc_get_tag_ndef_support() is failed. [0x%08X]", res);
+ // construct the list
+ tagTypes.Construct();
+
+ // get tag type
+ nfc_tag_get_type(tagHandle, &type);
+ switch (type)
+ {
+ case NFC_ISO14443_4A_PICC:
+ case NFC_ISO14443_A_PICC:
+ SysLog(NID_NET_NFC, "[NET_NFC_ISO14443_4A_PICC] or [NET_NFC_ISO14443_A_PICC] type");
+
+ tagIdPair.pTagIdKey = KEY_TAG_ID_ISO14443_3A;
+ res = nfc_tag_foreach_information(tagHandle, &OnNfcKeyRetrieved, &tagIdPair);
+ SysTryReturn(NID_NET_NFC, res == NFC_ERROR_NONE, null, E_SYSTEM,
+ "[E_SYSTEM] net_nfc_get_tag_info_value() is failed. [0x%08X]", res);
+
+ // add types
+ tagTypes.Add(NFC_TAG_TYPE_ISO14443_3A);
+ tagTypes.Add(NFC_TAG_TYPE_ISO14443_4);
+ if (isNdefSupport)
+ {
+ tagTypes.Add(NFC_TAG_TYPE_FORUM_TYPE_4);
+ }
+ break;
+ case NFC_ISO14443_4B_PICC:
+ case NFC_ISO14443_B_PICC:
+ // TODO: should check this case means the ISO14443-3B or not
+ SysLog(NID_NET_NFC, "[NET_NFC_ISO14443_B_PICC | NET_NFC_ISO14443_4B_PICC] type");
+
+ tagIdPair.pTagIdKey = KEY_TAG_ID_ISO14443_3B;
+ res = nfc_tag_foreach_information(tagHandle, &OnNfcKeyRetrieved, &tagIdPair);
+ SysTryReturn(NID_NET_NFC, res == NFC_ERROR_NONE, null, E_SYSTEM,
+ "[E_SYSTEM] net_nfc_get_tag_info_value() is failed. [0x%08X]", res);
+
+ // add types
+ tagTypes.Add(NFC_TAG_TYPE_ISO14443_3B);
+ tagTypes.Add(NFC_TAG_TYPE_ISO14443_4);
+ if (isNdefSupport)
+ {
+ tagTypes.Add(NFC_TAG_TYPE_FORUM_TYPE_4);
+ }
+ break;
+ case NFC_ISO14443_3A_PICC:
+ SysLog(NID_NET_NFC, "NET_NFC_ISO14443_3A_PICC type");
+
+ tagIdPair.pTagIdKey = KEY_TAG_ID_ISO14443_3A;
+ res = nfc_tag_foreach_information(tagHandle, &OnNfcKeyRetrieved, &tagIdPair);
+ SysTryReturn(NID_NET_NFC, res == NFC_ERROR_NONE, null, E_SYSTEM,
+ "[E_SYSTEM] net_nfc_get_tag_info_value() is failed. [0x%08X]", res);
+
+ // add types
+ tagTypes.Add(NFC_TAG_TYPE_ISO14443_3A);
+ break;
+ case NFC_ISO15693_PICC:
+ SysLog(NID_NET_NFC, "NET_NFC_ISO15693_PICC type");
+
+ tagIdPair.pTagIdKey = KEY_TAG_ID_ISO15693;
+ res = nfc_tag_foreach_information(tagHandle, &OnNfcKeyRetrieved, &tagIdPair);
+ SysTryReturn(NID_NET_NFC, res == NFC_ERROR_NONE, null, E_SYSTEM,
+ "[E_SYSTEM] net_nfc_get_tag_info_value() is failed. [0x%08X]", res);
+
+ // add type
+ tagTypes.Add(NFC_TAG_TYPE_ISO15693);
+ break;
+ case NFC_MIFARE_ULTRA_PICC: // Mifare Ultralight
+ SysLog(NID_NET_NFC, "NET_NFC_MIFARE_ULTRA_PICC type");
+
+ tagIdPair.pTagIdKey = KEY_TAG_ID_ISO14443_3A;
+ res = nfc_tag_foreach_information(tagHandle, &OnNfcKeyRetrieved, &tagIdPair);
+ SysTryReturn(NID_NET_NFC, res == NFC_ERROR_NONE, null, E_SYSTEM,
+ "[E_SYSTEM]net_nfc_get_tag_info_value() is failed. [0x%08X]", res);
+
+ // add types
+ tagTypes.Add(NFC_TAG_TYPE_ISO14443_3A);
+ tagTypes.Add(NFC_TAG_TYPE_MIFARE_UL);
+ if (isNdefSupport)
+ {
+ tagTypes.Add(NFC_TAG_TYPE_FORUM_TYPE_2);
+ }
+ break;
+ case NFC_MIFARE_MINI_PICC:
+ case NFC_MIFARE_1K_PICC:
+ case NFC_MIFARE_4K_PICC:
+ SysLog(NID_NET_NFC, "[NET_NFC_MIFARE_MINI_PICC|NET_NFC_MIFARE_1K_PICC|NET_NFC_MIFARE_4K_PICC] Mifare classic type");
+
+ tagIdPair.pTagIdKey = KEY_TAG_ID_ISO14443_3A;
+ res = nfc_tag_foreach_information(tagHandle, &OnNfcKeyRetrieved, &tagIdPair);
+ SysTryReturn(NID_NET_NFC, res == NFC_ERROR_NONE, null, E_SYSTEM,
+ "[E_SYSTEM] net_nfc_get_tag_info_value() is failed. [0x%08X]", res);
+
+ // add types
+ tagTypes.Add(NFC_TAG_TYPE_ISO14443_3A);
+ tagTypes.Add(NFC_TAG_TYPE_MIFARE_CLASSIC);
+ break;
+ case NFC_FELICA_PICC:
+ SysLog(NID_NET_NFC, "NET_NFC_FELICA_PICC type");
+
+ tagIdPair.pTagIdKey = KEY_TAG_ID_FELICA;
+ res = nfc_tag_foreach_information(tagHandle, &OnNfcKeyRetrieved, &tagIdPair);
+ SysTryReturn(NID_NET_NFC, res == NFC_ERROR_NONE, null, E_SYSTEM,
+ "[E_SYSTEM] net_nfc_get_tag_info_value() is failed. [0x%08X]", res);
+
+ // add types
+ tagTypes.Add(NFC_TAG_TYPE_FELICA);
+ if (isNdefSupport)
+ {
+ tagTypes.Add(NFC_TAG_TYPE_FORUM_TYPE_3);
+ }
+
+ break;
+ case NFC_JEWEL_PICC:
+ SysLog(NID_NET_NFC, "NET_NFC_JEWEL_PICC type");
+
+ tagIdPair.pTagIdKey = KEY_TAG_ID_ISO14443_3A;
+ res = nfc_tag_foreach_information(tagHandle, &OnNfcKeyRetrieved, &tagIdPair);
+ SysTryReturn(NID_NET_NFC, res == NFC_ERROR_NONE, null, E_SYSTEM,
+ "[E_SYSTEM] net_nfc_get_tag_info_value() is failed. [0x%08X]", res);
+
+ // add types
+ tagTypes.Add(NFC_TAG_TYPE_ISO14443_3A);
+ tagTypes.Add(NFC_TAG_TYPE_TOPAZ_JEWEL);
+ if (isNdefSupport)
+ {
+ tagTypes.Add(NFC_TAG_TYPE_FORUM_TYPE_1);
+ }
+ break;
+ case NFC_MIFARE_DESFIRE_PICC:
+ SysLog(NID_NET_NFC, "NET_NFC_MIFARE_DESFIRE_PICC type");
+
+ tagIdPair.pTagIdKey = KEY_TAG_ID_ISO14443_3A;
+ res = nfc_tag_foreach_information(tagHandle, &OnNfcKeyRetrieved, &tagIdPair);
+ SysTryReturn(NID_NET_NFC, res == NFC_ERROR_NONE, null, E_SYSTEM,
+ "[E_SYSTEM] net_nfc_get_tag_info_value() is failed. [0x%08X]", res);
+
+ // add types
+ tagTypes.Add(NFC_TAG_TYPE_ISO14443_3A);
+ tagTypes.Add(NFC_TAG_TYPE_ISO14443_4);
+ if (isNdefSupport)
+ {
+ tagTypes.Add(NFC_TAG_TYPE_FORUM_TYPE_4);
+ }
+ break;
+ case NFC_ISO14443_BPRIME_PICC:
+ case NFC_GENERIC_PICC:
+ // TODO: find the way how to get the ID of B Prime tag
+ SysLog(NID_NET_NFC, "[NET_NFC_GENERIC_PICC | NET_NFC_ISO14443_A_PICC] type. Map these types to UNKNOWN tag type");
+ tagTypes.Add(NFC_TAG_TYPE_UNKNOWN);
+ isUnknownTagType = true;
+ break;
+ case NFC_NFCIP1_TARGET: // p2p type
+ case NFC_NFCIP1_INITIATOR: // p2p type
+ default:
+ SysLog(NID_NET_NFC, "[NET_NFC_NFCIP1_TARGET | NET_NFC_NFCIP1_INITIATOR] NOT a Tag Type - p2p type (%d)", type);
+ return null;
+ }
+
+ return new _NfcTagImpl(tagIdPair.tagIdValue, tagTypes, isNdefSupport);
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNet_NfcSystemAdapter.h
+ * @brief This is the header file for _NfcSystemAdapter class.
+ */
+#ifndef _FNET_NFC_INTERNAL_NFC_SYSTEM_ADAPTER_H_
+#define _FNET_NFC_INTERNAL_NFC_SYSTEM_ADAPTER_H_
+
+#include <nfc.h>
+#include <cstdlib>
+#include <pthread.h>
+#include <unique_ptr.h>
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FNetNfcNfcTypes.h>
+#include "FNetNfc_NdefMessageUtil.h"
+
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+namespace Collection
+{
+template<class Type> class LinkedListT;
+}
+} }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+// Forward declaration
+class NdefMessage;
+class _NfcTagImpl;
+class _INfcTagDiscoveryEventListener;
+class _INfcDeviceDiscoveryEventListener;
+class _NfcManagerImpl;
+class _TagConnectionImpl;
+class _NdefPushManagerImpl;
+class _NfcIpcProxy;
+
+/**
+ * @class _NfcSystemAdapter
+ * @brief This class provides functions related to deliver the system events to the listeners such as _NfcManagerImpl.
+ * This class is a type of singleton, therefore only one instance should be allowed.
+ */
+class _NfcSystemAdapter
+ : public Tizen::Base::Object
+{
+
+public:
+ /**
+ * Creates an instance of this class if there is no instance in this application context.
+ * Gets the exist instance because this class is a singleton, otherwise.
+ *
+ * @return the instance of this class
+ */
+ static _NfcSystemAdapter* GetInstance(void);
+
+ /**
+ * Adds the specified %_INfcTagDiscoveryEventListener instance for the NFC tag discovery events.
+ *
+ * @return An error code
+ * @param[in] pListener The %_INfcTagDiscoveryEventListener instance to be added
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_ALREADY_EXIST The listener was already added.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ */
+ result AddNfcTagDiscoveryEventListener(_INfcTagDiscoveryEventListener* pListener);
+
+ /**
+ * Removes the specified %_INfcTagDiscoveryEventListener instance.
+ *
+ * @return An error code
+ * @param[in] pListener The %_INfcTagDiscoveryEventListener instance to be removed
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND The listener was not found.
+ */
+ result RemoveNfcTagDiscoveryEventListener(_INfcTagDiscoveryEventListener* pListener);
+
+ /**
+ * Adds the specified %_INfcDeviceDiscoveryEventListener instance for the NFC peer device discovery events.
+ *
+ * @return An error code
+ * @param[in] pListener The %_INfcDeviceDiscoveryEventListener instance to be added
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_ALREADY_EXIST The listener was already added.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ */
+ result AddNfcDeviceDiscoveryEventListener(_INfcDeviceDiscoveryEventListener* pListener);
+
+ /**
+ * Removes the specified %_INfcDeviceDiscoveryEventListener instance.
+ *
+ * @return An error code
+ * @param[in] pListener The %_INfcDeviceDiscoveryEventListener instance to be removed
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND The listener was not found.
+ */
+ result RemoveNfcDeviceDiscoveryEventListener(_INfcDeviceDiscoveryEventListener* pListener);
+
+ /**
+ * Adds the specified %_NfcManagerImpl instance for the NFC discovery events.
+ *
+ * @return An error code
+ * @param[in] pImpl The %_NfcManagerImpl instance to be added
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_ALREADY_EXIST The listener was already added.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ */
+ result AddNfcManagerImpl(_NfcManagerImpl* pImpl);
+
+ /**
+ * Removes the specified %_NfcManagerImpl instance.
+ *
+ * @return An error code
+ * @param[in] pImpl The %_NfcManagerImpl instance to be removed
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND The listener was not found.
+ */
+ result RemoveNfcManagerImpl(_NfcManagerImpl* pImpl);
+
+ /**
+ * Adds the specified %_TagConnectionImpl instance for the NFC Read/Write mode events.
+ *
+ * @return An error code
+ * @param[in] pImpl The %_TagConnectionImpl instance to be added
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_ALREADY_EXIST The listener was already added.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ */
+ result AddTagConnectionImpl(_TagConnectionImpl* pImpl);
+
+ /**
+ * Removes the specified %_TagConnectionImpl instance.
+ *
+ * @return An error code
+ * @param[in] pImpl The %_TagConnectionImpl instance to be removed
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND The listener was not found.
+ */
+ result RemoveTagConnectionImpl(_TagConnectionImpl* pImpl);
+
+ /**
+ * Adds the specified %_NdefPushManagerImpl instance for the NFC P2P mode, especially NDEF push, events.
+ *
+ * @return An error code
+ * @param[in] pImpl The %_NdefPushManagerImpl instance to be added
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_ALREADY_EXIST The listener was already added.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ */
+ result AddNdefPushManagerImpl(_NdefPushManagerImpl* pImpl);
+
+ /**
+ * Removes the specified %_NdefPushManagerImpl instance.
+ *
+ * @return An error code
+ * @param[in] pImpl The %_NdefPushManagerImpl instance to be removed
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND The listener was not found.
+ */
+ result RemoveNdefPushManagerImpl(_NdefPushManagerImpl* pImpl);
+
+ /**
+ * Activate NFC feature.
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_SYSTEM A system error occurred.
+ */
+ result Activate(void);
+
+ /**
+ * Deactivate NFC feature.
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_SYSTEM A system error occurred.
+ */
+ result Deactivate(void);
+
+ /**
+ * Checks whether the NFC feature is activated.
+ *
+ * @return @c true, if the NFC feature is activated @n
+ * @c false, otherwise
+ */
+ bool IsActivated(void) const;
+
+ /**
+ * Checks whether an NFC tag is currently connected with the device.
+ *
+ * @return @c true, if an NFC tag is currently connected @n
+ * @c false, otherwise
+ */
+ bool IsTagConnected(void);
+
+ /**
+ * Checks whether an NFC peer device is currently connected with this device.
+ *
+ * @return @c true, if an NFC peer device is currently connected @n
+ * @c false, otherwise
+ */
+ bool IsDeviceDetected(void);
+
+ /**
+ * Gets the Impl instance of the current detected tag.
+ *
+ * @return the Impl instance of the current detected tag, @n
+ * @c null if the getting fails
+ */
+ _NfcTagImpl* GetCurrentTagImplN(void);
+
+ /**
+ * Sends the raw data to the current detected tag.
+ *
+ * @return An error code
+ * @param[in] command Command to be sent to the tag
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_ARG The input @c command is invalid.
+ * @exception E_CONNECTION_BUSY The connection is busy, so cannot process the send request.
+ * @exception E_CONNECTION_FAILED The connection to the tag is closed or fails.
+ * @exception E_SYSTEM A system error occurred.
+ * @see INfcConnectionInternalEventListener::OnNfcResponseReceivedN()
+ */
+ result SendCommand(const Tizen::Base::ByteBuffer& command);
+
+ /**
+ * Reads NDEF data from an NDEF tag.
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_CONNECTION_BUSY The connection is busy, so cannot process the read request.
+ * @exception E_CONNECTION_FAILED The connection to the tag is closed or fails.
+ * @exception E_SYSTEM A system error occurred.
+ * @see INfcConnectionInternalEventListener::OnNdefReadCompletedN()
+ */
+ result Read(void);
+
+ /**
+ * Writes NDEF data to an NDEF tag.
+ *
+ * @return An error code
+ * @param[in] message NDEF message to be written to the target
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_ARG The input @c message is invalid.
+ * @exception E_CONNECTION_BUSY The connection is busy, so cannot process the write request.
+ * @exception E_CONNECTION_FAILED The connection to the tag is closed or fails.
+ * @exception E_SYSTEM A system error occurred.
+ * @see INfcConnectionInternalEventListener::OnNdefWriteCompleted()
+ */
+ result Write(const NdefMessage& message);
+
+ /**
+ * Pushes the NDEF message.
+ *
+ * @return An error code
+ * @param[in] message The NDEF message to be sent
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_DEVICE_BUSY The device is processing preceding job.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_INVALID_STATE This instance is in an invalid state. @n
+ * For example, the NFC feature is not activated @n
+ * or a peer device is not attached.
+ * @exception E_OPERATION_FAILED The operation has failed.
+ */
+ result Push(const NdefMessage& message);
+
+ /**
+ * Enables or disables the Conditional NFC App Launch pop-up.
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ result SetLaunchPopupEnabled(bool enable);
+
+ /**
+ * Callback to notify that the NFC activation or deactivation is completed.
+ */
+ static void OnNfcActivationCompleted(nfc_error_e error, void* pUserData);
+
+ /**
+ * Callback to notify that the NFC activation status is changed.
+ */
+ static void OnNfcActivationChanged(bool activated, void* pUserData);
+
+ /**
+ * Callback to notify the peer device is detected or lost.
+ */
+ static void OnNfcTargetDiscovered(nfc_discovered_type_e type, nfc_p2p_target_h target, void* pUserData);
+
+ /**
+ * Callback to notify that Nfc activation is changed.
+ */
+ static void OnNfcResponseReceived(nfc_error_e res, byte* pReadData, int length, void* pUserData);
+
+ /**
+ * Callback to notify that ndef read is completed.
+ */
+ static void OnNdefReadCompleted(nfc_error_e res, nfc_ndef_message_h message, void* pUserData);
+
+ /**
+ * Callback to notify that ndef write is completed.
+ */
+ static void OnNdefWriteCompleted(nfc_error_e res, void* pUserData);
+
+ /**
+ * Callback to notify that nfc tag is detected or lost.
+ */
+ static void OnNfcTagDiscovered(nfc_discovered_type_e type, nfc_tag_h tag, void* pUserData);
+
+ /**
+ * Callback to notify that nfc tag key is retrieved.
+ */
+ static bool OnNfcKeyRetrieved(const char* pKey, const unsigned char* pValue, int valueSize, void* pUserData);
+
+ /**
+ * Callback to notify that ndef message is discovered.
+ */
+ static void OnNdefMessageDiscovered(nfc_ndef_message_h message, void* pUserData);
+
+ /**
+ * Callback to notify that ndef message is received from a peer device.
+ */
+ static void OnNdefMessageReceived(nfc_p2p_target_h target, nfc_ndef_message_h message, void* pUserData);
+
+ /**
+ * Callback to notify that NDEF push is completed.
+ */
+ static void OnNdefMessageSent(nfc_error_e res, void* pUserData);
+
+ /**
+ * Gets the NDEF message cached when the tag is detected.
+ *
+ * @return The cached %NdefMessage instance, @n
+ * else @c null if the method is not successful
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_ILLEGAL_ACCESS This operation is not allowed because the application is not launched by
+ * Conditional %App Launch.
+ * @exception E_INVALID_FORMAT The cached data cannot be converted to the NDEF message.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ static NdefMessage* GetCachedNdefMessageN(void);
+
+private:
+ _NfcSystemAdapter(void);
+ _NfcSystemAdapter(const _NfcSystemAdapter& value);
+ ~_NfcSystemAdapter(void);
+
+ _NfcSystemAdapter& operator =(const _NfcSystemAdapter& value);
+ result Construct(void);
+
+ static NdefMessage* GetNdefMessageN(const nfc_ndef_message_h& messageHandle);
+ _NfcTagImpl* GetNfcTagImplN(nfc_tag_h tagHandle);
+ static void InitSingleton(void);
+ static void DestroySingleton(void);
+
+private:
+ Tizen::Base::Collection::LinkedListT<_INfcTagDiscoveryEventListener*>* __pTagDiscListenerList;
+ Tizen::Base::Collection::LinkedListT<_INfcDeviceDiscoveryEventListener*>* __pDevDiscListenerList;
+ Tizen::Base::Collection::LinkedListT<_NfcManagerImpl*>* __pMgrImplList;
+ Tizen::Base::Collection::LinkedListT<_TagConnectionImpl*>* __pConnImplList;
+ Tizen::Base::Collection::LinkedListT<_NdefPushManagerImpl*>* __pPushMgrImplList;
+ nfc_tag_h __tagHandle;
+ nfc_p2p_target_h __p2pTargetHandle;
+ bool __isConnected; // TODO: temporary defined due to get the current tag connection state.
+ static _NfcSystemAdapter* __pSingleton;
+ _NfcIpcProxy* __pIpcProxy;
+
+friend class std::default_delete< _NfcSystemAdapter >;
+}; // _NfcSystemAdapter
+
+} } }
+#endif // _FNET_NFC_INTERNAL_NFC_SYSTEM_ADAPTER_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 FNetNfcTagDiscoveryEvent.cpp
+// @brief This is the implementation file for _NfcTagDiscoveryEvent class.
+//
+// This file contains the implementation of _NfcTagDiscoveryEvent class.
+//
+
+#include <FBaseRtIEventListener.h>
+#include <FNetNfcINfcTagDiscoveryEventListener.h>
+#include <FBaseSysLog.h>
+#include <FBaseRt_Event.h>
+#include "FNetNfc_NfcTagDiscoveryEvent.h"
+#include "FNetNfc_NfcTagDiscoveryEventArg.h"
+#include "FNetNfc_NfcTagImpl.h"
+#include "FNetNfc_TagConnectionImpl.h"
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+_NfcTagDiscoveryEvent::_NfcTagDiscoveryEvent(void)
+{
+}
+
+_NfcTagDiscoveryEvent::~_NfcTagDiscoveryEvent(void)
+{
+}
+
+result
+_NfcTagDiscoveryEvent::Construct(void)
+{
+ return _Event::Initialize();
+}
+
+void
+_NfcTagDiscoveryEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+ result r = E_SUCCESS;
+
+ INfcTagDiscoveryEventListener* pEventListener = dynamic_cast <INfcTagDiscoveryEventListener*>(&listener);
+ SysTryReturnVoidResult(NID_NET_NFC, pEventListener != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system.");
+
+
+ const _NfcTagDiscoveryEventArg* pEventArg = dynamic_cast <const _NfcTagDiscoveryEventArg*>(&arg);
+ SysTryReturnVoidResult(NID_NET_NFC, pEventArg != null, E_SYSTEM, "[E_SYSTEM] A failure occurred from the underlying system.");
+
+ const _NfcTagImpl* pTagImpl = null;
+ TagConnection* pConnection = null;
+
+ _NfcTagDiscoveryEventType eventType = pEventArg->GetEventType();
+
+ switch (eventType)
+ {
+ case _NFC_TAG_DISCOVERY_EVENT_TYPE_DETECTED:
+ pTagImpl = pEventArg->GetTagImpl();
+ pConnection = _TagConnectionImpl::GetTagConnectionN(*pTagImpl);
+
+ if (pConnection)
+ {
+ pEventListener->OnNfcTagDetectedN(pConnection);
+ }
+ else
+ {
+ r = E_SYSTEM;
+ SysLog(NID_NET_NFC, "[E_SYSTEM] A system error has been occurred.");
+ }
+
+ break;
+
+ case _NFC_TAG_DISCOVERY_EVENT_TYPE_LOST:
+ pEventListener->OnNfcTagLost();
+ break;
+
+ default:
+ break;
+ }
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfcTagDiscoveryEvent.h
+ * @brief This is the header file for the _NfcTagDiscoveryEvent class.
+ *
+ * This header file contains declaration of the _NfcTagDiscoveryEvent class.
+ * The _NfcTagDiscoveryEvent class can call methods of a INfcTagDiscoveryEventListener class.
+ */
+#ifndef _FNET_NFC_INTERNAL_NFC_TAG_DISCOVERY_EVENT_H_
+#define _FNET_NFC_INTERNAL_NFC_TAG_DISCOVERY_EVENT_H_
+
+#include <FOspConfig.h>
+#include <FBaseResult.h>
+#include <FBaseRt_Event.h>
+
+// Forward declaration
+namespace Tizen { namespace Base { namespace Runtime
+{
+class IEventArg;
+class IEventListener;
+} } }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+/**
+ * @class _NfcTagDiscoveryEvent
+ * @brief This class handles the events related to the discovery of NFC tag.
+ *
+ * When an NFC tag is discovered, the _NfcTagDiscoveryEvent object finds a INfcTagDiscoveryEventListener object and
+ * calls an appropriate method of the listener.
+ */
+class _NfcTagDiscoveryEvent
+ : public Tizen::Base::Runtime::_Event
+{
+public:
+ /**
+ * This is the default constructor.
+ */
+ _NfcTagDiscoveryEvent();
+
+ /**
+ * This is the class destructor.
+ */
+ virtual ~_NfcTagDiscoveryEvent(void);
+
+ /**
+ * Initializes a new instance of the class
+ *
+ */
+ result Construct(void);
+
+protected:
+ /**
+ * Calls the specified listener's method with the specified argument when event is generated.
+ *
+ * @param[in] listener The event listener which will be received the event
+ * @param[in] arg The event argument to be passed by
+ */
+ void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+ _NfcTagDiscoveryEvent(const _NfcTagDiscoveryEvent& value);
+ _NfcTagDiscoveryEvent& operator =(const _NfcTagDiscoveryEvent& value);
+
+}; // _NfcTagDiscoveryEvent
+
+} } } //Tizen::Net::Nfc
+#endif // _FNET_NFC_INTERNAL_NFC_TAG_DISCOVERY_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 FNetNfcTagDiscoveryEventArg.cpp
+// @brief This is the implementation file for _NfcTagDiscoveryEventArg class.
+//
+// This file contains the implementation of _NfcTagDiscoveryEventArg class.
+//
+
+#include <FBaseSysLog.h>
+#include "FNetNfc_NfcTagDiscoveryEventArg.h"
+#include "FNetNfc_NfcTagImpl.h"
+
+using namespace std;
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+_NfcTagDiscoveryEventArg::_NfcTagDiscoveryEventArg(void)
+ : __eventType(_NFC_TAG_DISCOVERY_EVENT_TYPE_LOST)
+ , __pTagImpl(null)
+{
+}
+
+_NfcTagDiscoveryEventArg::_NfcTagDiscoveryEventArg(const _NfcTagImpl& tagImpl)
+ : __eventType(_NFC_TAG_DISCOVERY_EVENT_TYPE_DETECTED)
+ , __pTagImpl(null)
+{
+ __pTagImpl = new (std::nothrow) _NfcTagImpl(tagImpl);
+ SysTryReturnVoidResult(NID_NET_NFC, __pTagImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+_NfcTagDiscoveryEventArg::~_NfcTagDiscoveryEventArg(void)
+{
+ delete __pTagImpl;
+}
+
+_NfcTagDiscoveryEventType
+_NfcTagDiscoveryEventArg::GetEventType(void) const
+{
+ return __eventType;
+}
+
+const _NfcTagImpl*
+_NfcTagDiscoveryEventArg::GetTagImpl(void) const
+{
+ return __pTagImpl;
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfcTagDiscoveryEventArg.h
+ * @brief This is the header file for the _NfcTagDiscoveryEventArg class.
+ *
+ * This header file contains declaration of the _NfcTagDiscoveryEventArg class.
+ */
+#ifndef _FNET_NFC_INTERNAL_NFC_TAG_DISCOVERY_EVENT_ARG_H_
+#define _FNET_NFC_INTERNAL_NFC_TAG_DISCOVERY_EVENT_ARG_H_
+
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FNetNfcNfcTypes.h>
+#include <FBaseRtIEventArg.h>
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+// Forward declaration
+class _NfcTagImpl;
+
+/**
+ * @enum _NfcTagDiscoveryEventType
+ *
+ * Defines the type of the tag discovery event.
+ */
+enum _NfcTagDiscoveryEventType
+{
+ _NFC_TAG_DISCOVERY_EVENT_TYPE_DETECTED,
+ _NFC_TAG_DISCOVERY_EVENT_TYPE_LOST
+};
+
+/**
+ * @class _NfcTagDiscoveryEventArg
+ * @brief This class is used as an argument of methods of the _NfcTagDiscoveryEvent class.
+ *
+ * When an NFC tag is discovered, the INfcTagDiscoveryEventListener objects registered to the event are called
+ * with this argument class.
+ */
+class _NfcTagDiscoveryEventArg
+ : public Tizen::Base::Object
+ , public Tizen::Base::Runtime::IEventArg
+{
+public:
+ /**
+ * This is the default constructor for the detached event.
+ */
+ _NfcTagDiscoveryEventArg(void);
+
+ /**
+ * This is the constructor for the detected event.
+ *
+ * @param[in] tagImpl The impl instance of the detected tag
+ */
+ _NfcTagDiscoveryEventArg(const _NfcTagImpl& tagImpl);
+
+ /**
+ * This is the class destructor.
+ */
+ ~_NfcTagDiscoveryEventArg(void);
+
+ /**
+ * Gets the type of this event.
+ *
+ * @return The type of the event
+ */
+ _NfcTagDiscoveryEventType GetEventType(void) const;
+
+ /**
+ * Gets the Impl instance of the detected tag.
+ *
+ * @return The Impl instance of the detected tag
+ */
+ const _NfcTagImpl* GetTagImpl(void) const;
+
+private:
+ _NfcTagDiscoveryEventArg(const _NfcTagDiscoveryEventArg& value);
+ _NfcTagDiscoveryEventArg& operator =(const _NfcTagDiscoveryEventArg& value);
+
+private:
+ _NfcTagDiscoveryEventType __eventType;
+ _NfcTagImpl* __pTagImpl;
+
+}; // _NfcTagDiscoveryEventArg
+
+} } } //Tizen::Net::Nfc
+#endif // _FNET_NFC_INTERNAL_NFC_TAG_DISCOVERY_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 FNetNfcNfcTagImpl.cpp
+// @brief This is the implementation file for _NfcTagImpl class.
+//
+// This file contains the implementation of _NfcTagImpl class.
+//
+
+#include <unique_ptr.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseSysLog.h>
+#include <FNetNfcNfcTag.h>
+#include "FNetNfc_NfcTagImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+_NfcTagImpl::_NfcTagImpl(const Tizen::Base::ByteBuffer& tagId, const Tizen::Base::Collection::IListT <NfcTagType>& types,
+ bool isNdefSupported)
+ : __tagId()
+ , __tagTypeList()
+ , __isNdefSupported(isNdefSupported)
+{
+ __tagId.Construct(tagId);
+ __tagTypeList.Construct(types);
+}
+
+_NfcTagImpl::_NfcTagImpl(const _NfcTagImpl& value)
+ : __tagId()
+ , __tagTypeList()
+ , __isNdefSupported(value.__isNdefSupported)
+{
+ __tagId.Construct(value.__tagId);
+ __tagTypeList.Construct(value.__tagTypeList);
+}
+
+_NfcTagImpl::~_NfcTagImpl(void)
+{
+}
+
+bool
+_NfcTagImpl::HasTagType(NfcTagType type) const
+{
+ return __tagTypeList.Contains(type);
+}
+
+const Tizen::Base::Collection::IListT <NfcTagType>*
+_NfcTagImpl::GetTagTypeList(void) const
+{
+ return &__tagTypeList;
+}
+
+const Tizen::Base::ByteBuffer*
+_NfcTagImpl::GetId(void) const
+{
+ return &__tagId;
+}
+
+bool
+_NfcTagImpl::IsNdefSupported(void) const
+{
+ return __isNdefSupported;
+}
+
+NfcTag*
+_NfcTagImpl::GetNfcTagN(const _NfcTagImpl& impl)
+{
+ unique_ptr<NfcTag> pTag(new (std::nothrow) NfcTag());
+ SysTryReturn(NID_NET_NFC, pTag != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ unique_ptr<_NfcTagImpl> pImpl(new (std::nothrow) _NfcTagImpl(impl));
+ SysTryReturn(NID_NET_NFC, pImpl != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ pTag->__pImpl = pImpl.release();
+
+ return pTag.release();
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfcTagConnectionEvent.cpp
+ * @brief This is the implementation file for _TagConnectionEvent class.
+ *
+ * This file contains the implementation of _TagConnectionEvent class.
+ */
+
+#include <FBaseByteBuffer.h>
+#include <FBaseRtIEventListener.h>
+#include <FBaseSysLog.h>
+#include <FBaseRtIEventArg.h>
+#include <FNetNfcNdefMessage.h>
+#include <FNetNfcITagConnectionListener.h>
+#include <FNetNfcINdefTagConnectionListener.h>
+#include "FNetNfc_TagConnectionEvent.h"
+#include "FNetNfc_TagConnectionEventArg.h"
+#include "FNetNfc_NdefMessageImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+_TagConnectionEvent::_TagConnectionEvent(void)
+{
+}
+
+_TagConnectionEvent::~_TagConnectionEvent(void)
+{
+}
+
+result
+_TagConnectionEvent::Construct(void)
+{
+ return _Event::Initialize();
+}
+
+void
+_TagConnectionEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+ result actionResult = E_SUCCESS;
+ const _TagConnectionEventArg* pEventArg = null;
+ ITagConnectionListener* pConnListener = null;
+ INdefTagConnectionListener* pNdefConnListener = null;
+ _TagConnectionEventType type;
+
+ pEventArg = dynamic_cast <const _TagConnectionEventArg*>(&arg);
+ SysTryReturnVoidResult(NID_NET_NFC, pEventArg != null, E_SYSTEM, "[E_SYSTEM] A dynamic casting failure.");
+
+ type = pEventArg->GetEventType();
+ actionResult = pEventArg->GetResult();
+
+ switch (type)
+ {
+ case _TAG_CON_EVENT_TYPE_READ_COMPLETED:
+ {
+ SysLog(NID_NET_NFC, "_TAG_CON_EVENT_TYPE_READ_COMPLETED");
+
+ const NdefMessage* pSrcMessage = null;
+ NdefMessage* pDstMessage = null;
+
+ pNdefConnListener = dynamic_cast <INdefTagConnectionListener*>(&listener);
+ SysTryReturnVoidResult(NID_NET_NFC, pNdefConnListener != null, E_SYSTEM, "[E_SYSTEM] A dynamic casting failure.");
+
+ pSrcMessage = pEventArg->GetNdefMessage();
+ if (pSrcMessage != null)
+ {
+ // The payloads are copied shallowly because this event is sent to only one listener
+ pDstMessage = _NdefMessageImpl::GetCloneSharingPayloadN(*pSrcMessage);
+ SysTryReturnVoidResult(NID_NET_NFC, pDstMessage != null, GetLastResult(),
+ "[%s] Copying an NDEF message failed.", GetErrorMessage(GetLastResult()));
+ }
+
+ pNdefConnListener->OnNdefReadCompletedN(pDstMessage, actionResult); // transfer the ownership of pDesMessage
+ }
+ break;
+
+ case _TAG_CON_EVENT_TYPE_WRITE_COMPLETED:
+ SysLog(NID_NET_NFC, "_TAG_CON_EVENT_TYPE_WRITE_COMPLETED");
+
+ pNdefConnListener = dynamic_cast <INdefTagConnectionListener*>(&listener);
+ SysTryReturnVoidResult(NID_NET_NFC, pNdefConnListener != null, E_SYSTEM, "[E_SYSTEM] A dynamic casting failure.");
+
+ pNdefConnListener->OnNdefWriteCompleted(actionResult);
+ break;
+
+ case _TAG_CON_EVENT_TYPE_RESPONSE_RECEIVED:
+ {
+ SysLog(NID_NET_NFC, "_TAG_CON_EVENT_TYPE_RESPONSE_RECEIVED");
+
+ const ByteBuffer* pSrcResponseBuf = pEventArg->GetResponse();
+ ByteBuffer* pDstResponseBuf = null;
+
+ pConnListener = dynamic_cast <ITagConnectionListener*>(&listener);
+ SysTryReturnVoidResult(NID_NET_NFC, pConnListener != null, E_SYSTEM, "[E_SYSTEM] A dynamic casting failure.");
+
+ if (pSrcResponseBuf != null)
+ {
+ pDstResponseBuf = new (std::nothrow) ByteBuffer;
+ SysTryReturnVoidResult(NID_NET_NFC, pDstResponseBuf != null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ // The response data is copied shallowly because this event is sent to only one listener
+ pDstResponseBuf->Construct(*pSrcResponseBuf);
+ }
+
+ pConnListener->OnNfcResponseReceivedN(pDstResponseBuf, actionResult);
+ }
+ break;
+
+ default:
+ SysLogException(NID_NET_NFC, E_SYSTEM, "[E_SYSTEM] Unknown event type.");
+ break;
+ }
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfcTagConnectionEvent.h
+ * @brief This is the header file for the _TagConnectionEvent class.
+ *
+ * This header file contains declaration of the _TagConnectionEvent class.
+ * The _TagConnectionEvent class can call methods of a INfcTagConnectionEventListener class.
+ */
+#ifndef _FNET_NFC_INTERNAL_TAG_CONNECTION_EVENT_H_
+#define _FNET_NFC_INTERNAL_TAG_CONNECTION_EVENT_H_
+
+#include <FOspConfig.h>
+#include <FBaseResult.h>
+#include <FBaseRt_Event.h>
+
+// Forward declaration
+namespace Tizen { namespace Base { namespace Runtime
+{
+class IEventArg;
+class IEventListener;
+} } }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+/**
+ * @class _TagConnectionEvent
+ * @brief This class handles the events related to the connection with NFC tag.
+ *
+ * When the connection with the detected NFC tag is established and the events are detected from it, the
+ * _TagConnectionEvent object finds a ITagConnectionEventListner object and calls an appropriate method of the listener.
+ */
+class _TagConnectionEvent
+ : public Tizen::Base::Runtime::_Event
+{
+public:
+ /**
+ * This is the default constructor.
+ */
+ _TagConnectionEvent();
+
+ /**
+ * This is the class destructor.
+ */
+ virtual ~_TagConnectionEvent(void);
+
+ /**
+ * Initializes a new instance of the class
+ */
+ result Construct(void);
+
+protected:
+ /**
+ * Calls the specified listener's method with the specified argument when event is generated.
+ *
+ * @param[in] listener The event listener which will be received the event
+ * @param[in] arg The event argument to be passed by
+ */
+ void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+ _TagConnectionEvent(const _TagConnectionEvent& value);
+ _TagConnectionEvent& operator =(const _TagConnectionEvent& value);
+
+}; // _TagConnectionEvent
+
+} } } //Tizen::Net::Nfc
+#endif // _FNET_NFC_INTERNAL_TAG_CONNECTION_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 FNetNfcTagConnectionEventArg.cpp
+// @brief This is the implementation file for _TagConnectionEventArg class.
+//
+// This file contains the implementation of _TagConnectionEventArg class.
+//
+
+#include <FBaseByteBuffer.h>
+#include <FBaseRtIEventListener.h>
+#include <FBaseSysLog.h>
+#include <FNetNfcNdefMessage.h>
+#include "FNetNfc_TagConnectionEventArg.h"
+#include "FNetNfc_NdefMessageImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+_TagConnectionEventArg::_TagConnectionEventArg(const NdefMessage* pMessage, result r)
+ : __eventType(_TAG_CON_EVENT_TYPE_READ_COMPLETED)
+ , __pRecievedMessage(null)
+ , __pResponseData(null)
+ , __result(r)
+{
+ if (pMessage != null)
+ {
+ // The payload is copied shallowly for better performance
+ __pRecievedMessage = _NdefMessageImpl::GetCloneSharingPayloadN(*pMessage);
+ SysTryReturnVoidResult(NID_NET_NFC, __pRecievedMessage != null, GetLastResult(),
+ "[%s] Copying an NDEF message failed.", GetErrorMessage(GetLastResult()));
+ }
+}
+
+_TagConnectionEventArg::_TagConnectionEventArg(result r)
+ : __eventType(_TAG_CON_EVENT_TYPE_WRITE_COMPLETED)
+ , __pRecievedMessage(null)
+ , __pResponseData(null)
+ , __result(r)
+{
+}
+
+_TagConnectionEventArg::_TagConnectionEventArg(const Tizen::Base::ByteBuffer* pResponse, result r)
+ : __eventType(_TAG_CON_EVENT_TYPE_RESPONSE_RECEIVED)
+ , __pRecievedMessage(null)
+ , __pResponseData(null)
+ , __result(r)
+{
+ if (pResponse != null)
+ {
+ // shallow copy
+ __pResponseData = new (std::nothrow) ByteBuffer;
+ SysTryReturnVoidResult(NID_NET_NFC, __pResponseData != null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ __pResponseData->Construct(*pResponse);
+ }
+}
+
+_TagConnectionEventArg::~_TagConnectionEventArg(void)
+{
+ if (__pRecievedMessage)
+ {
+ __pRecievedMessage->RemoveAllRecords(true);
+ delete __pRecievedMessage;
+ }
+
+ delete __pResponseData;
+}
+
+_TagConnectionEventType
+_TagConnectionEventArg::GetEventType(void) const
+{
+ return __eventType;
+}
+
+NdefMessage*
+_TagConnectionEventArg::GetNdefMessage(void) const
+{
+ return __pRecievedMessage;
+}
+
+Tizen::Base::ByteBuffer*
+_TagConnectionEventArg::GetResponse(void) const
+{
+ return __pResponseData;
+}
+
+result
+_TagConnectionEventArg::GetResult(void) const
+{
+ return __result;
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfcTagConnectionEventArg.h
+ * @brief This is the header file for the _TagConectionEventArg Class.
+ *
+ * This header file contains declaration of the _TagConectionEventArg Class.
+ */
+#ifndef _FNET_NFC_INTERNAL_TAG_CONNECTION_EVENT_ARG_H_
+#define _FNET_NFC_INTERNAL_TAG_CONNECTION_EVENT_ARG_H_
+
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FBaseResult.h>
+#include <FBaseRtIEventArg.h>
+
+// Forward declaration
+namespace Tizen { namespace Base { namespace Runtime
+{
+class ByteBuffer;
+class IEventListener;
+} } }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+// Forward declaration
+class NdefMessage;
+
+/**
+ * @enum _TagConnectionEventType
+ *
+ * Defines the type of the tag connection event.
+ */
+enum _TagConnectionEventType
+{
+ _TAG_CON_EVENT_TYPE_READ_COMPLETED,
+ _TAG_CON_EVENT_TYPE_WRITE_COMPLETED,
+ _TAG_CON_EVENT_TYPE_RESPONSE_RECEIVED
+};
+
+/**
+ * @class _TagConnectionEvent
+ * @brief This class is used as an argument of methods of the _TagConnectionEvent class.
+ *
+ * When the connection with the detected NFC tag is established and the events are detected from it, the
+ * ITagConnectionEventListner objects registered to the event are called with this argument class.
+ */
+class _TagConnectionEventArg
+ : public Tizen::Base::Object
+ , public Tizen::Base::Runtime::IEventArg
+{
+public:
+ /**
+ * This is the constructor for _TAG_CON_EVENT_TYPE_READ_COMPLETED.
+ */
+ _TagConnectionEventArg(const NdefMessage* pMessage, result r);
+
+ /**
+ * This is the constructor for _TAG_CON_EVENT_TYPE_WRITE_COMPLETED.
+ */
+ _TagConnectionEventArg(result r);
+
+ /**
+ * This is the constructor for _TAG_CON_EVENT_TYPE_RESPONSE_RECEIVED.
+ */
+ _TagConnectionEventArg(const Tizen::Base::ByteBuffer* pResponse, result r);
+
+ /**
+ * This is the class destructor.
+ */
+ ~_TagConnectionEventArg(void);
+
+ /**
+ * Gets the tag event type.
+ *
+ * @return The type of the event
+ */
+ _TagConnectionEventType GetEventType(void) const;
+
+ /**
+ * Gets the NDEF Message.
+ *
+ * @return The detected NDEF message
+ */
+ NdefMessage* GetNdefMessage(void) const;
+
+ /**
+ * Gets the response data.
+ *
+ * @return The response data
+ */
+ Tizen::Base::ByteBuffer* GetResponse(void) const;
+
+ /**
+ * Gets the action result.
+ *
+ * @return The error code
+ */
+ result GetResult(void) const;
+
+private:
+ _TagConnectionEventArg(const _TagConnectionEventArg& value);
+ _TagConnectionEventArg& operator =(const _TagConnectionEventArg& value);
+
+private:
+ _TagConnectionEventType __eventType;
+ NdefMessage* __pRecievedMessage;
+ Tizen::Base::ByteBuffer* __pResponseData;
+ result __result;
+
+}; // _TagConnectionEventArg
+
+} } } //Tizen::Net::Nfc
+#endif // _FNET_NFC_INTERNAL_TAG_CONNECTION_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 FNetNfcTagConnectionImpl.cpp
+// @brief This is the implementation file for _TagConnectionImpl class.
+//
+// This file contains the implementation of _TagConnectionImpl class.
+//
+
+#include <unique_ptr.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseSysLog.h>
+#include <FNetNfcNfcTag.h>
+#include <FNetNfcTagConnection.h>
+#include <FNetNfcITagConnectionListener.h>
+#include <FNetNfcINdefTagConnectionListener.h>
+#include <FNetNfcNdefMessage.h>
+#include <FNetNfcNdefTagConnection.h>
+#include "FNetNfc_NfcTagImpl.h"
+#include "FNetNfc_TagConnectionImpl.h"
+#include "FNetNfc_TagConnectionEvent.h"
+#include "FNetNfc_TagConnectionEventArg.h"
+#include "FNetNfc_NfcSystemAdapter.h"
+
+using namespace std;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+_TagConnectionImpl::_TagConnectionImpl(void)
+ : __pTargetTag(null)
+ , __pSystemAdapter(null)
+ , __pConnEvent(null)
+ , __pTagPreviousListener(null)
+ , __pNdefTagPreviousListener(null)
+ , __stateMutex()
+ , __currentState(_TAG_CONNECTION_STATE_CONNECTED)
+{
+}
+
+_TagConnectionImpl::~_TagConnectionImpl(void)
+{
+ if (__pSystemAdapter)
+ {
+ __pSystemAdapter->RemoveTagConnectionImpl(this);
+ __pSystemAdapter->RemoveNfcTagDiscoveryEventListener(this);
+ }
+
+ delete __pTargetTag;
+ delete __pConnEvent;
+}
+
+result
+_TagConnectionImpl::Construct(const _NfcTagImpl& tagImpl)
+{
+ result r = E_SUCCESS;
+
+ r = __stateMutex.Create();
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Internal error occurred on initializing the tag connection.");
+
+ __pSystemAdapter = _NfcSystemAdapter::GetInstance();
+ SysTryReturnResult(NID_NET_NFC, __pSystemAdapter != null, E_SYSTEM,
+ "Internal error occurred on initializing the tag connection.");
+
+ // Create the Tag Connection Event
+ unique_ptr<_TagConnectionEvent> pConnEvent(new (std::nothrow) _TagConnectionEvent());
+ SysTryReturnResult(NID_NET_NFC, pConnEvent != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = pConnEvent->Construct();
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating. Construct of an event instance failed.");
+
+ r = __pSystemAdapter->AddTagConnectionImpl(this);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed to add the callack to _NfcSystemAdapter.");
+
+ r = __pSystemAdapter->AddNfcTagDiscoveryEventListener(this);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed to add the callack to _NfcSystemAdapter.");
+
+ __pTargetTag = _NfcTagImpl::GetNfcTagN(tagImpl);
+ SysTryReturnResult(NID_NET_NFC, __pTargetTag != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ // the current state is definately conntected state because this class is instantiated by the platform.
+
+ __pConnEvent = pConnEvent.release();
+
+ return E_SUCCESS;
+}
+
+const NfcTag*
+_TagConnectionImpl::GetTargetTag(void) const
+{
+ return __pTargetTag;
+}
+
+result
+_TagConnectionImpl::SetTagConnectionListener(ITagConnectionListener* pListener)
+{
+ result r = E_SUCCESS;
+
+ SysTryReturnResult(NID_NET_NFC, __pTagPreviousListener != pListener, E_SUCCESS,
+ "the listener instance is already registered.");
+
+ if (__pTagPreviousListener != null)
+ {
+ // remove the previous ITagConnectionListener instance from the _TagConnectionEvent.
+ r = __pConnEvent->RemoveListener(*__pTagPreviousListener);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed to remove the previous ITagConnectionListener.");
+ SysLog(NID_NET_NFC, "Removing the previous ITagConnectionListener is successful.");
+ __pTagPreviousListener = null;
+ }
+
+ if (pListener != null)
+ {
+ // add the specified new ITagConnectionListener instance to the _TagConnectionEvent.
+ r = __pConnEvent->AddListener(*pListener, true);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed to add the new ITagConnectionListener.");
+ SysLog(NID_NET_NFC, "Adding the new ITagConnectionListener is successful.");
+ __pTagPreviousListener = pListener;
+ }
+
+ return r;
+}
+
+result
+_TagConnectionImpl::SetNdefTagConnectionListener(INdefTagConnectionListener* pListener)
+{
+ result r = E_SUCCESS;
+
+ SysTryReturnResult(NID_NET_NFC, __pNdefTagPreviousListener != pListener, E_SUCCESS,
+ "the listener instance is already registered.");
+
+ if (__pNdefTagPreviousListener != null)
+ {
+ // remove the previous INdefTagConnectionListener instance from the _TagConnectionEvent.
+ r = __pConnEvent->RemoveListener(*__pNdefTagPreviousListener);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed to remove the previous INdefTagConnectionListener.");
+ SysLog(NID_NET_NFC, "Removing the previous INdefTagConnectionListener is successful.");
+ __pNdefTagPreviousListener = null;
+ }
+
+ if (pListener != null)
+ {
+ // add the specified new INdefTagConnectionListener instance to the _TagConnectionEvent.
+ r = __pConnEvent->AddListener(*pListener, true);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed to add the new INdefTagConnectionListener.");
+ SysLog(NID_NET_NFC, "Adding the new INdefTagConnectionListener is successful.");
+ __pNdefTagPreviousListener = pListener;
+ }
+
+ return r;
+}
+
+result
+_TagConnectionImpl::SendCommand(const Tizen::Base::ByteBuffer& command)
+{
+ SysLog(NID_NET_NFC, "EntryPoint, [CurrentState:%s]", GetStringOfCurrentState());
+
+ result r = E_SUCCESS;
+
+ SysTryReturnResult(NID_NET_NFC, command.GetRemaining() != 0, E_INVALID_ARG, "Invalid argument is used. command is empty");
+
+ __stateMutex.Acquire();
+
+ switch (__currentState)
+ {
+ case _TAG_CONNECTION_STATE_DISABLED:
+ r = E_CONNECTION_FAILED;
+ break;
+
+ case _TAG_CONNECTION_STATE_CONNECTED:
+ r = __pSystemAdapter->SendCommand(command);
+ if (r == E_SUCCESS)
+ {
+ __currentState = _TAG_CONNECTION_STATE_SEND_REQUESTED;
+ }
+ break;
+
+ case _TAG_CONNECTION_STATE_SEND_REQUESTED:
+ r = E_IN_PROGRESS;
+ break;
+
+ case _TAG_CONNECTION_STATE_READ_REQUESTED:
+ case _TAG_CONNECTION_STATE_WRITE_REQUESTED:
+ r = E_CONNECTION_BUSY;
+ break;
+
+ default:
+ r = E_SYSTEM;
+ break;
+ }
+
+ __stateMutex.Release();
+
+ if (r != E_SUCCESS)
+ {
+ SysLogException(NID_NET_NFC, r, "[%s] exception occurred on sending a command to the target tag.", GetErrorMessage(r));
+ }
+
+ SysLog(NID_NET_NFC, "ExitPoint, [CurrentState:%s], [result:%s]", GetStringOfCurrentState(), GetErrorMessage(r));
+
+ return r;
+}
+
+result
+_TagConnectionImpl::Read(void)
+{
+ SysLog(NID_NET_NFC, "EntryPoint, [CurrentState:%s]", GetStringOfCurrentState());
+
+ result r = E_SUCCESS;
+
+ __stateMutex.Acquire();
+
+ switch (__currentState)
+ {
+ case _TAG_CONNECTION_STATE_DISABLED:
+ r = E_CONNECTION_FAILED;
+ break;
+
+ case _TAG_CONNECTION_STATE_CONNECTED:
+ r = __pSystemAdapter->Read();
+ if (r == E_SUCCESS)
+ {
+ __currentState = _TAG_CONNECTION_STATE_READ_REQUESTED;
+ }
+ break;
+
+ case _TAG_CONNECTION_STATE_READ_REQUESTED:
+ r = E_IN_PROGRESS;
+ break;
+
+ case _TAG_CONNECTION_STATE_SEND_REQUESTED:
+ case _TAG_CONNECTION_STATE_WRITE_REQUESTED:
+ r = E_CONNECTION_BUSY;
+ break;
+
+ default:
+ r = E_SYSTEM;
+ break;
+ }
+
+ __stateMutex.Release();
+
+ if (r != E_SUCCESS)
+ {
+ SysLogException(NID_NET_NFC, r, "[%s] exception occurred on reading the NDEF message from the target tag.", GetErrorMessage(r));
+ }
+
+ SysLog(NID_NET_NFC, "ExitPoint, [CurrentState:%s], [result:%s]", GetStringOfCurrentState(), GetErrorMessage(r));
+
+ return r;
+}
+
+result
+_TagConnectionImpl::Write(const NdefMessage& message)
+{
+ SysLog(NID_NET_NFC, "EntryPoint, [CurrentState:%s]", GetStringOfCurrentState());
+
+ result r = E_SUCCESS;
+
+ SysTryReturnResult(NID_NET_NFC, message.GetRecordsCount() != 0, E_INVALID_ARG,
+ "Invalid argument is used. NDEF message does not contain any NDEF records");
+
+ __stateMutex.Acquire();
+
+ switch (__currentState)
+ {
+ case _TAG_CONNECTION_STATE_DISABLED:
+ r = E_CONNECTION_FAILED;
+ break;
+
+ case _TAG_CONNECTION_STATE_CONNECTED:
+ r = __pSystemAdapter->Write(message);
+ if (r == E_SUCCESS)
+ {
+ __currentState = _TAG_CONNECTION_STATE_WRITE_REQUESTED;
+ }
+ break;
+
+ case _TAG_CONNECTION_STATE_WRITE_REQUESTED:
+ r = E_IN_PROGRESS;
+ break;
+
+ case _TAG_CONNECTION_STATE_SEND_REQUESTED:
+ case _TAG_CONNECTION_STATE_READ_REQUESTED:
+ r = E_CONNECTION_BUSY;
+ break;
+
+ default:
+ r = E_SYSTEM;
+ break;
+ }
+
+ __stateMutex.Release();
+
+ if (r != E_SUCCESS)
+ {
+ SysLogException(NID_NET_NFC, r, "[%s] exception occurred on writing an NDEF message from the target tag.", GetErrorMessage(r));
+ }
+
+ SysLog(NID_NET_NFC, "ExitPoint, [CurrentState:%s], [result:%s]", GetStringOfCurrentState(), GetErrorMessage(r));
+
+ return r;
+}
+
+TagConnection*
+_TagConnectionImpl::GetTagConnectionN(const _NfcTagImpl& tagImpl)
+{
+ result r = E_SUCCESS;
+ unique_ptr<TagConnection> pConnection;
+ unique_ptr<_TagConnectionImpl> pConnectionImpl;
+
+ if (tagImpl.IsNdefSupported())
+ {
+ pConnection.reset(new (std::nothrow) NdefTagConnection());
+ }
+ else
+ {
+ pConnection.reset(new (std::nothrow) TagConnection());
+ }
+ SysTryReturn(NID_NET_NFC, pConnection != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ pConnectionImpl.reset(new (std::nothrow) _TagConnectionImpl());
+ SysTryReturn(NID_NET_NFC, pConnectionImpl != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ // Invokes the construct method of TagConnection because TagConnection and NdefTagConnection use the common impl class.
+ r = pConnectionImpl->Construct(tagImpl);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, null, r,
+ "[%s] Propagating. Making TagConnection instance failed.", GetErrorMessage(r));
+
+ pConnection->_pImpl = pConnectionImpl.release();
+
+ return pConnection.release();
+}
+
+void
+_TagConnectionImpl::OnNdefReadCompleted(const NdefMessage* pMessage, result r)
+{
+ SysLog(NID_NET_NFC, "EntryPoint, [CurrentState:%s], [result:%s]", GetStringOfCurrentState(), GetErrorMessage(r));
+
+ bool isFired = false;
+
+ __stateMutex.Acquire();
+
+ if (__currentState == _TAG_CONNECTION_STATE_READ_REQUESTED)
+ {
+ __currentState = _TAG_CONNECTION_STATE_CONNECTED;
+ isFired = true;
+ }
+
+ __stateMutex.Release();
+
+ if (isFired)
+ {
+ if (r != E_SUCCESS)
+ {
+ SysLogException(NID_NET_NFC, r, "[%s] exception occurred during the NDEF read operation.", GetErrorMessage(r));
+ }
+
+ _TagConnectionEventArg* pArg = new (std::nothrow) _TagConnectionEventArg(pMessage, r);
+ SysTryReturnVoidResult(NID_NET_NFC, pArg != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ __pConnEvent->FireAsync(*pArg);
+ }
+
+ SysLog(NID_NET_NFC, "ExitPoint, [CurrentState:%s], [READ_COMPLETED_Event:%s]",
+ GetStringOfCurrentState(), isFired ? "Fired" : "NotFired");
+}
+
+void
+_TagConnectionImpl::OnNdefWriteCompleted(result r)
+{
+ SysLog(NID_NET_NFC, "EntryPoint, [CurrentState:%s], [result:%s]", GetStringOfCurrentState(), GetErrorMessage(r));
+
+ bool isFired = false;
+
+ __stateMutex.Acquire();
+
+ if (__currentState == _TAG_CONNECTION_STATE_WRITE_REQUESTED)
+ {
+ __currentState = _TAG_CONNECTION_STATE_CONNECTED;
+ isFired = true;
+ }
+
+ __stateMutex.Release();
+
+ if (isFired)
+ {
+ if (r != E_SUCCESS)
+ {
+ SysLogException(NID_NET_NFC, r, "[%s] exception occurred during the NDEF write operation.", GetErrorMessage(r));
+ }
+
+ _TagConnectionEventArg* pArg = new (std::nothrow) _TagConnectionEventArg(r);
+ SysTryReturnVoidResult(NID_NET_NFC, pArg != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ __pConnEvent->FireAsync(*pArg);
+ }
+
+ SysLog(NID_NET_NFC, "ExitPoint, [CurrentState:%s], [WRITE_COMPLETED_Event:%s]",
+ GetStringOfCurrentState(), isFired ? "Fired" : "NotFired");
+}
+
+void
+_TagConnectionImpl::OnNfcResponseReceived(const Tizen::Base::ByteBuffer* pResponse, result r)
+{
+ SysLog(NID_NET_NFC, "EntryPoint, [CurrentState:%s], [result:%s]", GetStringOfCurrentState(), GetErrorMessage(r));
+
+ bool isFired = false;
+
+ __stateMutex.Acquire();
+
+ if (__currentState == _TAG_CONNECTION_STATE_SEND_REQUESTED)
+ {
+ __currentState = _TAG_CONNECTION_STATE_CONNECTED;
+ isFired = true;
+ }
+
+ __stateMutex.Release();
+
+ if (isFired)
+ {
+ if (r != E_SUCCESS)
+ {
+ SysLogException(NID_NET_NFC, r, "[%s] exception occurred during the send operation.", GetErrorMessage(r));
+ }
+
+ _TagConnectionEventArg* pArg = new (std::nothrow) _TagConnectionEventArg(pResponse, r);
+ SysTryReturnVoidResult(NID_NET_NFC, pArg != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ __pConnEvent->FireAsync(*pArg);
+ }
+
+ SysLog(NID_NET_NFC, "ExitPoint, [CurrentState:%s], [RESPONSE_RECV_Event:%s]",
+ GetStringOfCurrentState(), isFired ? "Fired" : "NotFired");
+}
+
+void
+_TagConnectionImpl::OnNfcTagDetected(void)
+{
+ // ignore
+}
+
+void
+_TagConnectionImpl::OnNfcTagLost(void)
+{
+ SysLog(NID_NET_NFC, "EntryPoint, [CurrentState:%s]", GetStringOfCurrentState());
+
+ __stateMutex.Acquire();
+
+ if (__currentState != _TAG_CONNECTION_STATE_DISABLED)
+ {
+ __currentState = _TAG_CONNECTION_STATE_DISABLED;
+ }
+
+ __stateMutex.Release();
+
+ SysLog(NID_NET_NFC, "ExitPoint, [CurrentState:%s]", GetStringOfCurrentState());
+}
+
+const char*
+_TagConnectionImpl::GetStringOfCurrentState(void) const
+{
+ const char* pStateString = null;
+
+ switch (__currentState)
+ {
+ case _TAG_CONNECTION_STATE_DISABLED:
+ pStateString = "DISABLED";
+ break;
+
+ case _TAG_CONNECTION_STATE_CONNECTED:
+ pStateString = "CONNECTED";
+ break;
+
+ case _TAG_CONNECTION_STATE_SEND_REQUESTED:
+ pStateString = "SEND_REQUESTED";
+ break;
+
+ case _TAG_CONNECTION_STATE_READ_REQUESTED:
+ pStateString = "READ_REQUESTED";
+ break;
+
+ case _TAG_CONNECTION_STATE_WRITE_REQUESTED:
+ pStateString = "WRITE_REQUESTED";
+ break;
+
+ default:
+ pStateString = "";
+ break;
+ }
+
+ return pStateString;
+}
+
+} } } // Tizen::Net::Nfc
--- /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 FNetNfc_ConnectivityIpcMessages.h
+ * @brief This is the header file for the Connectivity service daemon's IPC messages.
+ *
+ * This header file contains the declarations of the IPC messages for the Connectivity service daemon.
+ */
+
+#include <ipc/ipc_message_macros.h>
+#include <FIo_IpcCommonParamTraits.h>
+#include <FIo_IpcMessageStart.h>
+
+#ifndef NFC_CONNECTIVITY_IPC_SERVER_NAME
+#define NFC_CONNECTIVITY_IPC_SERVER_NAME "osp.net.nfc.ipcserver.connectivity"
+#endif
+
+#define IPC_MESSAGE_START ConnectivityNfcServiceMsgStart
+
+// Client -> Server (sync)
+IPC_SYNC_MESSAGE_CONTROL0_1(ConnectivityNfcServiceMsg_initialize, unsigned long /* result */)
+IPC_SYNC_MESSAGE_CONTROL2_1(ConnectivityNfcServiceMsg_registerPushMessage, Tizen::Base::ByteBuffer /* message */, Tizen::Base::String /* description */, unsigned long /* result */)
+IPC_SYNC_MESSAGE_CONTROL0_1(ConnectivityNfcServiceMsg_unregisterPushMessage, unsigned long /* result */)
+IPC_SYNC_MESSAGE_CONTROL0_1(ConnectivityNfcServiceMsg_activateReservedPush, unsigned long /* result */)
+IPC_SYNC_MESSAGE_CONTROL0_1(ConnectivityNfcServiceMsg_deactivateReservedPush, unsigned long /* result */)
+IPC_SYNC_MESSAGE_CONTROL0_1(ConnectivityNfcServiceMsg_isReservedPushActivated, bool /* isActivated */)
+IPC_SYNC_MESSAGE_CONTROL0_2(ConnectivityNfcServiceMsg_getReservedPushCandidates, Tizen::Io::_StringMap /* candidates */, unsigned long /* result */)
+IPC_SYNC_MESSAGE_CONTROL1_1(ConnectivityNfcServiceMsg_pickReservedPushMessage, Tizen::Base::String /* appId */, unsigned long /* result */)
+IPC_SYNC_MESSAGE_CONTROL0_2(ConnectivityNfcServiceMsg_getPickedReservedPushMessage, Tizen::Base::String /* appId */, unsigned long /* 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 FNetNfc_INfcTagDiscoveryEventListener.h
+ * @brief This is the header file for the _INfcTagDiscoveryEventListener interface.
+ *
+ * This header file contains the declaration of the _INfcTagDiscoveryEventListener interface.
+ *
+ */
+#ifndef _FNET_NFC_INTERNAL_INFC_TAG_DISCOVERY_EVENT_LISTENER_H_
+#define _FNET_NFC_INTERNAL_INFC_TAG_DISCOVERY_EVENT_LISTENER_H_
+
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+/**
+ * @interface _INfcTagDiscoveryEventListener
+ * @brief This interface provides a listener for the events related to the NFC manager status.
+ *
+ * The _INfcTagDiscoveryEventListener interface specifies the event listener methods invoked by _NfcSystemAdapter for
+ * notifying NFC tag discovery events.
+ */
+
+class _INfcTagDiscoveryEventListener
+{
+public:
+ /**
+ * This is the virtual destructor for this class.
+ */
+ virtual ~_INfcTagDiscoveryEventListener(void) {}
+
+ /**
+ * Called to notify when a tag is detected by the device.
+ */
+ virtual void OnNfcTagDetected(void) = 0;
+
+ /**
+ * Called to notify when the tag is lost by the device.
+ */
+ virtual void OnNfcTagLost(void) = 0;
+
+}; // _INfcTagDiscoveryEventListener
+
+} } }
+
+#endif // _FNET_NFC_INTERNAL_INFC_TAG_DISCOVERY_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 FNetNfcNdefMessageImpl.h
+ * @brief This is the header file for the _NdefMessageImpl class.
+ *
+ * This header file contains the declarations of the _NdefMessageImpl class.
+ */
+
+#ifndef _FNET_NFC_INTERNAL_NDEF_MESSAGE_IMPL_H_
+#define _FNET_NFC_INTERNAL_NDEF_MESSAGE_IMPL_H_
+
+#include <unique_ptr.h>
+#include <FBaseColAllElementsDeleter.h>
+#include <FBaseObject.h>
+#include <FOspConfig.h>
+#include <FNetNfcNfcTypes.h>
+#include <FBaseDataType.h>
+
+// Forward declaration
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+class String;
+namespace Collection
+{
+class LinkedList;
+}
+} }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+// Forward declaration
+class NdefRecordType;
+class NdefRecord;
+
+/**
+ * @class _NdefMessageImpl
+ * @brief This class provides information and performs operations on a NDEF Message
+ */
+class _OSP_EXPORT_ _NdefMessageImpl
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * This is the default constructor for this class.
+ */
+ _NdefMessageImpl(void);
+
+ /**
+ * This is copy constructor for this class.
+ *
+ * @param[in] value An instance of _NdefMessageImpl
+ * @remarks It performs a deep copy.
+ */
+ _NdefMessageImpl(const _NdefMessageImpl& value);
+
+ /**
+ * This is the destructor for this class.
+ */
+ ~_NdefMessageImpl(void);
+
+ /**
+ * Compares the calling instance with the specified instance.
+ *
+ * @return @c true if the specified instance of %Object is equal to the calling %_NdefMessageImpl instance, @n
+ * else @c false
+ * @param[in] obj The object to compare
+ * @remark Two %_NdefMessageImpl instances are equal only if they contain the same %NdefRecord instances in
+ * the same order.
+ */
+ virtual bool Equals(const Tizen::Base::Object& obj) const;
+
+ /**
+ * Gets the hash value of the current instance.
+ *
+ * @return The hash value of the current instance
+ */
+ virtual int GetHashCode(void) const;
+
+ /**
+ * Gets the number of NDEF records in the NDEF message.
+ *
+ * @return The number of NDEF records
+ */
+ int GetRecordsCount() const;
+
+ /**
+ * Searches for an NdefRecord instance in the NDEF message. @n
+ * Gets the index of the NdefRecord instance if found.
+ *
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_OBJ_NOT_FOUND The specified @c record was not found.
+ * @remarks This method checks the equality of the pointers.
+ */
+ result IndexOf(const NdefRecord& record, int& index) const;
+
+ /**
+ * Gets the NdefRecord object at the specified location.
+ *
+ * @return The requested NdefRecord object, @c null if the index is not valid
+ * @param[in] index The index of the NDEF record to get
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the record list. @n
+ * The specified @c index is either equal to or greater than the number of
+ * elements or less than zero.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ NdefRecord* GetRecordAt(int index) const;
+
+ /**
+ * Gets the NdefRecord object with the specified payload identifier.
+ *
+ * @return The requested NdefRecord object, @c null if no record is matched.
+ * @param[in] payloadId The payload identifier of the NDEF record to get
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_OBJ_NOT_FOUND The @id was not found in any NDEF records.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ NdefRecord* GetRecord(const Tizen::Base::String& payloadId) const;
+
+ /**
+ * Appends the specified NDEF record after the last NDEF record in the NDEF message.
+ *
+ * @return An error code
+ * @param[in] record The NDEF record to add
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_ARG The specified NDEF record has the same payload identifier as other records in
+ * this NDEF message.
+ * @exception E_OUT_OF_MEMORY Insufficient memory.
+ * @remarks This method performs a shallow copy. It adds just the pointer; not the NdefRecord instance itself.
+ */
+ result AppendRecord(const NdefRecord& record);
+
+ /**
+ * Inserts the specified NDEF record into the NDEF message at the specified location.
+ *
+ * @return An error code
+ * @param[in] record An NDEF record to insert
+ * @param[in] index The index at which the NDEF record should be inserted
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the record list. @n
+ * The specified @c index is either equal to or greater than the number of
+ * elements or less than zero.
+ * @exception E_INVALID_ARG The specified NDEF record has the same payload identifier as other records in
+ * this NDEF message.
+ * @exception E_OUT_OF_MEMORY Insufficient memory.
+ * @remarks The NDEF records that follow the insertion point move down to accommodate the inserted NDEF
+ * record. @n
+ * This method performs a shallow copy. It adds just the pointer; not the NdefRecord instance itself.
+ */
+ result InsertRecordAt(const NdefRecord& record, int index);
+
+ /**
+ * Removes the NDEF record at the specified location.
+ *
+ * @return An error code
+ * @param[in] index The index at which the NDEF record should be removed
+ * @param[in] deallocate Set to @c true to deallocate the record @c false, otherwise
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the record list. @n
+ * The specified @c index is either equal to or greater than the number of
+ * elements or less than zero.
+ * @remarks The NDEF records that follow the deletion point move up to occupy the vacated spot.
+ */
+ result RemoveRecordAt(int index, bool deallocate);
+
+ /**
+ * Replaces the NDEF record at the specified location with the specified NDEF record.
+ *
+ * @return An error code
+ * @param[in] record An NDEF record to set
+ * @param[in] index The index at which the NDEF record should be set
+ * @param[in] deallocate Set to @c true to deallocate the replaced record @c false, otherwise
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the record list. @n
+ * The specified @c index is either equal to or greater than the number of
+ * elements or less than zero.
+ * @exception E_INVALID_ARG The specified NDEF record has the same payload identifier as other records in
+ * this NDEF message.
+ * @remarks This method performs a shallow copy. It adds just the pointer; not the NdefRecord instance itself.
+ */
+ result SetRecordAt(const NdefRecord& record, int index, bool deallocate);
+
+ /**
+ * Remove all records in the NDEF message.
+ * If the specified @c deallocate is set to @c true, it deallocates all the NdefRecord instance in the message.
+ *
+ * @param[in] deallocate Set to @c true to deallocate the record @c false, otherwise
+ */
+ void RemoveAllRecords(bool deallocate);
+
+ /**
+ * Gets the whole NDEF message with all the NDEF records as a ByteBuffer.
+ *
+ * @return The NDEF message as a ByteBuffer, @c null if the getting fails.
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_DATA The NDEF message does not contain any NDEF records.
+ * @exception E_OUT_OF_MEMORY Insufficient memory.
+ * @exception E_SYSTEM A system error occurred.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ Tizen::Base::ByteBuffer* ToByteBufferN(const NdefMessage& message) const;
+
+ /**
+ * This assignment operator copies the values from the specified instance of %_NdefMessageImpl to the calling
+ * instance of %_NdefMessageImpl.
+ *
+ * @return A reference to the %_NdefMessageImpl instance
+ * @param[in] rhs A reference to the %_NdefMessageImpl instance to copy
+ */
+ _NdefMessageImpl& operator =(const _NdefMessageImpl& value);
+
+ /**
+ * Gets the copied instance of the specified NdefMessage.
+ * The payloads of all records are copied shallowly.
+ *
+ * @return A copied NdefMessage instance
+ * @param[in] srcMessage An instance of _NdefMessageImpl
+ */
+ static NdefMessage* GetCloneSharingPayloadN(const NdefMessage& srcMessage);
+
+private:
+ std::unique_ptr<Tizen::Base::Collection::LinkedList, Tizen::Base::Collection::AllElementsDeleter> __pRecordList;
+}; // _NdefMessageImpl
+
+} } } // Tizen::Net::Nfc
+#endif // _FNET_NFC_INTERNAL_NDEF_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 FNetNfcINdefMessageUtil.h
+ * @brief This is the header file for _NdefMessageUtil.
+ *
+ * This header file contains the declarations of the _NdefMessageUtil class.
+ */
+#ifndef _FNET_NFC_INTERNAL_NDEF_MESSAGE_UTIL_H_
+#define _FNET_NFC_INTERNAL_NDEF_MESSAGE_UTIL_H_
+
+#include <FNetNfcNfcTypes.h>
+#include <FNetNfcNdefMessage.h>
+
+// Forward declaration
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+class String;
+namespace Collection
+{
+class IList;
+}
+} }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+// Forward declaration
+class NdefRecordType;
+
+struct _NdefMessageDeleter
+{
+ void operator()(NdefMessage* pNdefMessage)
+ {
+ pNdefMessage->RemoveAllRecords(true);
+ delete pNdefMessage;
+ }
+};
+/**
+ * @class _NdefMessageUtil
+ * @brief Utility class of the NDEF Message.
+ */
+class _OSP_EXPORT_ _NdefMessageUtil
+{
+public:
+ /**
+ * Converts the whole NDEF message with all the NDEF records to a ByteBuffer
+ *
+ * @return NDEF message as a ByteBuffer
+ * @param[in] message NDEF message to be converted
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_OUT_OF_MEMORY Insufficient memory
+ * @exception E_SYSTEM A failure occurred from the underlying system.
+ */
+ static Tizen::Base::ByteBuffer* ToByteBufferN(const NdefMessage& ndefMessage);
+
+ /**
+ * Generates the NDEF message from ByteBuffer
+ *
+ * @return An NDEF message as a NdefMessage instance
+ * @param[in] buffer NDEF message as a ByteBuffer to be converted
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_FORMAT The record payload can not be formulated to NDEF message.
+ * @exception E_OUT_OF_MEMORY Insufficient memory.
+ * @exception E_SYSTEM A system error occurred.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ static NdefMessage* ToNdefMessageN(const Tizen::Base::ByteBuffer& buffer);
+
+
+ /**
+ * Checks whether Record type name is valid with specified record type name format
+ *
+ * @return @c true, if the name is valid @n
+ * @c false, otherwise
+ * @param[in] type NdefRecordTypeNameFormat
+ * @param[in] name Record type name to be checked
+ */
+ static bool IsValidRecordType(NdefRecordTypeNameFormat type, const Tizen::Base::String& name);
+
+ /**
+ * Gets the equivalent record type list
+ *
+ * @return list of record types equivalent to specified record type
+ * @param[in] recordType NdefRecordType
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_OUT_OF_MEMORY Insufficient memory
+ * @exception E_SYSTEM A failure occurred from the underlying system.
+ */
+ static Tizen::Base::Collection::IList* GetEquivalentRecordTypesN(const NdefRecordType& recordType);
+
+private:
+ _NdefMessageUtil(void);
+ ~_NdefMessageUtil(void);
+ _NdefMessageUtil(const _NdefMessageUtil& value);
+ _NdefMessageUtil& operator =(const _NdefMessageUtil& value);
+
+}; // _NdefMessageUtil
+
+} } }
+#endif // _FNET_NFC_INTERNAL_NDEF_MESSAGE_UTIL_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.1 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// 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 FNetNfc_NdefPushManagerImpl.h
+ * @brief This is the header file for the _NdefPushManagerImpl Class.
+ *
+ * This header file contains the declarations of the _NdefPushManagerImpl Class.
+ */
+#ifndef _FNET_NFC_INTERNAL_NDEF_PUSH_MANAGER_IMPL_H_
+#define _FNET_NFC_INTERNAL_NDEF_PUSH_MANAGER_IMPL_H_
+
+#include <FBaseObject.h>
+#include <FBaseRtMutex.h>
+#include <FAppTypes.h>
+#include "FNetNfc_INfcDeviceDiscoveryEventListener.h"
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IMap;
+}
+} }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+// Forward declaration
+class _NfcSystemAdapter;
+class NdefMessage;
+class INdefPushManagerListener;
+class _NdefPushManagerEvent;
+
+/**
+ * @enum _TagConnectionStateType
+ *
+ * Defines the states of the NfcManager.
+ */
+enum _NdefPushManagerStateType
+{
+ _NDEF_PUSH_MANAGER_STATE_DISABLED,
+ _NDEF_PUSH_MANAGER_STATE_CONNECTED,
+ _NDEF_PUSH_MANAGER_PUSH_REQUESTED
+};
+
+/**
+ * @class _NdefPushManagerImpl
+ * @brief This class provides information and performs operations of a _NdefPushManagerImpl.
+ */
+class _OSP_EXPORT_ _NdefPushManagerImpl
+ : public Tizen::Base::Object
+ , public _INfcDeviceDiscoveryEventListener
+{
+
+public:
+ /**
+ * This is the default constructor for this class.
+ */
+ _NdefPushManagerImpl(void);
+
+ /**
+ * This is the destructor for this class.
+ */
+ ~_NdefPushManagerImpl(void);
+
+ /**
+ * Sets a listener for receiving the result of pushing an NDEF message.
+ *
+ * @return An error code
+ * @param[in] pListener The %INdefPushManagerListener instance to be added
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_OPERATION_FAILED The operation has failed.
+ */
+ result SetNdefPushManagerListener(INdefPushManagerListener* pListener);
+
+ /**
+ * Pushes the NDEF message.
+ *
+ * @return An error code
+ * @param[in] message The NDEF message to be sent
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_DEVICE_BUSY The device is processing preceding job.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_INVALID_STATE This instance is in an invalid state. @n
+ * For example, the NFC feature is not activated @n
+ * or a peer device is not attached.
+ * @exception E_OPERATION_FAILED The operation has failed.
+ */
+ result Push(const NdefMessage& message);
+
+ /**
+ * Activates Reserved Push feature which sends the preselected NDEF message to the connected NFC peer device on
+ * behalf of the application.
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified
+ * operation. @n
+ * For example, Reserved Push is already activated.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_SYSTEM The method cannot proceed due to a severe system error.
+ */
+ result ActivateReservedPush(void);
+
+ /**
+ * Deactivates Reserved Push feature which sends the preselected NDEF message to the connected NFC peer device on
+ * behalf of the application.
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified
+ * operation. @n
+ * For example, Reserved Push is already deactivated.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_SYSTEM The method cannot proceed due to a severe system error.
+ */
+ result DeactivateReservedPush(void);
+
+ /**
+ * Checks whether Reserved Push feature is activated.
+ *
+ * @return @c true if Reserved Push is activated, @n
+ * else @c false
+ */
+ bool IsReservedPushActivated(void) const;
+
+ /**
+ * Gets information of all the Reserved Push candidates. Each element of the result IMap consists of the ID of
+ * application which registered the NDEF message and the description about the registered NDEF message.
+ *
+ * @return An IMap containing the pairs of application ID and message description if successful, @n
+ * else @c null
+ * @remarks The key of the returned IMap should be casted to Tizen::App:AppId pointer and the value should be
+ * casted to Tizen::Base::String pointer by the new one.
+ */
+ Tizen::Base::Collection::IMap* GetReservedPushCandidatesN(void) const;
+
+ /**
+ * Picks out an NDEF message among all Reserved Push candidates by application ID. The selected NDEF message is
+ * pushed when a peer device is detected.
+ *
+ * @return An error code
+ * @param[in] appId The ID of the application which registered the NDEF message to push
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND The specified @c appId is not found in the Reserved Push candidate list.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_SYSTEM The method cannot proceed due to a severe system error.
+ * @remarks The only one message can be selected to push. So the previously selected message will be replaced
+ * by the new one.
+ */
+ result PickReservedPushMessage(const Tizen::App::AppId& appId);
+
+ /**
+ * Gets the owner application ID of the picked NDEF message among all Reserved Push candidates.
+ *
+ * @return The ID of the application which is the owner of the picked Reserved Push message @n
+ * else an empty string if an error occurs
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND There is no element in the Reserved Push candidate list.
+ * @exception E_SYSTEM The method cannot proceed due to a severe system error.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ Tizen::App::AppId GetPickedReservedPushMessage(void) const;
+
+ /**
+ * Callback method which implements _INdefPushManagerListener
+ */
+ void OnNdefPushMessageSent(result r);
+
+ /**
+ * Callback method to notify that the target device is detected.
+ */
+ virtual void OnNfcDeviceDetected(void);
+
+ /**
+ * Callback method to notify that the target device is lost.
+ */
+ virtual void OnNfcDeviceLost(void);
+
+ /**
+ * Registers an NDEF message to be pushed if the home screen or the main menu is on top of the screen in the local
+ * device when a peer device is detected.
+ *
+ * @return An error code
+ * @param[in] message The NDEF message to be registered
+ * @param[in] description The description for the NDEF message to be registered
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The input @c message is invalid. @n
+ * For example, it does not contain any NDEF records.
+ * @exception E_SYSTEM A system error has occurred.
+ * @remarks An application can register only one NDEF message. So the previously registered message will be
+ * replaced by the new one.
+ */
+ static result RegisterNdefPushMessage(const NdefMessage& message, const Tizen::Base::String& description);
+
+ /**
+ * Unregisters an NDEF message if the NDEF message to be pushed is registered.
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ static result UnregisterNdefPushMessage(void);
+
+private:
+ _NdefPushManagerImpl(const _NdefPushManagerImpl& rhs);
+ _NdefPushManagerImpl& operator =(const _NdefPushManagerImpl& rhs);
+
+ const char* GetStringOfCurrentState(void) const;
+
+private:
+ _NfcSystemAdapter* __pSystemAdapter;
+ _NdefPushManagerEvent* __pPushEvent;
+ INdefPushManagerListener* __pPreviousListener;
+ Tizen::Base::Runtime::Mutex __stateMutex;
+ _NdefPushManagerStateType __currentState;
+
+}; // _NdefPushManagerImpl
+
+} } }
+#endif // _FNET_NFC_INTERNAL_NDEF_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 FNetNfcNdefRecordImpl.h
+ * @brief This is the header file for the NdefRecordImpl class.
+ *
+ * This header file contains the declarations of the NdefRecordImpl class.
+ */
+
+#ifndef _FNET_NFC_INTERNAL_NDEF_RECORD_IMPL_H_
+#define _FNET_NFC_INTERNAL_NDEF_RECORD_IMPL_H_
+
+#include <unique_ptr.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FOspConfig.h>
+#include <FNetNfcNfcTypes.h>
+#include <FNetNfcNdefRecordType.h>
+
+// Forward declaration
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+} }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+// Forward declaration
+class NdefMessage;
+class NdefRecord;
+class _NdefMessageImpl;
+
+/**
+ * @class _NdefRecordImpl
+ * @brief This class provides information and performs operations on a NDEF Record
+ */
+class _OSP_EXPORT_ _NdefRecordImpl
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * This constructor initializes this instance of _NdefRecordImpl with the specified record type.
+ *
+ * @param[in] recordType A specified NDEF record type
+ */
+ _NdefRecordImpl(const NdefRecordType& recordType);
+
+ /**
+ * This is a copy constructor for this class.
+ *
+ * @param[in] value An instance of _NdefRecordImpl
+ * @remarks It performs a deep copy.
+ */
+ _NdefRecordImpl(const _NdefRecordImpl& value);
+
+ /**
+ * This is the destructor for this class.
+ */
+ ~_NdefRecordImpl(void);
+
+ /**
+ * Compares the calling instance with the specified instance.
+ *
+ * @return @c true if the specified instance of %Object is equal to the calling %_NdefRecordImpl instance, @n
+ * else @c false
+ * @param[in] obj The object to compare
+ * @remark Two %_NdefRecordImpl instances are equal only if they contain the same record type, payload ID, and payload.
+ */
+ virtual bool Equals(const Tizen::Base::Object& obj) const;
+
+ /**
+ * Gets the hash value of the current instance.
+ *
+ * @return The hash value of the current instance
+ */
+ virtual int GetHashCode(void) const;
+
+ /**
+ * Gets the identifier for the record payload.
+ *
+ * @return The identifier of the payload @n
+ * An empty string if the identifier does not exist in the NDEF record.
+ */
+ Tizen::Base::String GetPayloadId(void) const;
+
+ /**
+ * Gets the payload in the NDEF record as ByteBuffer.
+ *
+ * @return The payload, @c null if the NDEF record does not have it
+ */
+ Tizen::Base::ByteBuffer* GetPayload(void) const;
+
+ /**
+ * Gets the record type of this NDEF record
+ *
+ * @return NdefRecordType
+ */
+ NdefRecordType GetRecordType(void) const;
+
+ /**
+ * Sets the record type of this NDEF record.
+ *
+ * @return An error code
+ * @param[in] type The record type to set
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_ARG Setting the record type with NDEF_TNF_EMPTY is not allowed
+ * if the ID is not an empty string or the payload is not null.
+ */
+ result SetRecordType(NdefRecordType& type);
+
+ /**
+ * Sets the identifier for the payload.
+ *
+ * @return An error code
+ * @param[in] id The identifier of the payload
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_OPERATION Setting the payload identifier is not allowed if the name format of the record type is
+ * NDEF_TNF_EMPTY.
+ * @exception E_INVALID_ARG The specified identifier is the same as other records in this NDEF message.
+ * @exception E_MAX_EXCEEDED The length of the id exceeds 256 bytes.
+ */
+ result SetPayloadId(const Tizen::Base::String& id);
+
+ /**
+ * Sets the given data into the payload of this class.
+ *
+ * @return An error code
+ * @param[in] payload The payload data
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_OPERATION Setting the payload is not allowed if the name format of the record type is
+ * NDEF_TNF_EMPTY.
+ * @exception E_OUT_OF_MEMORY Insufficient memory.
+ * @exception E_INVALID_ARG A specified input parameter is invalid. @n
+ * The source payload is not constructed.
+ */
+ result SetPayload(const Tizen::Base::ByteBuffer& payload);
+
+ static void SetMessageImpl(const NdefRecord& record, const _NdefMessageImpl* pNdefMessageImpl);
+
+ /**
+ * This assignment operator copies the values from the specified instance of %_NdefRecordImpl to the calling instance of
+ * %_NdefRecordImpl.
+ *
+ * @return A reference to the %_NdefRecordImpl instance
+ * @param[in] rhs A reference to the %_NdefRecordImpl instance to copy
+ */
+ _NdefRecordImpl& operator =(const _NdefRecordImpl& value);
+
+private:
+ //
+ // This is the default constructor for this class.
+ //
+ _NdefRecordImpl(void);
+
+ result CopyPayloadFrom(const Tizen::Base::ByteBuffer* pPayload);
+
+private:
+ NdefRecordType __type;
+ Tizen::Base::String __id;
+ std::unique_ptr<Tizen::Base::ByteBuffer> __pPayload;
+ _NdefMessageImpl* __pMessageImpl;
+
+}; // _NdefRecordImpl
+
+} } } // Tizen::Net::Nfc
+#endif // _FNET_NFC_INTERNAL_NDEF_RECORD_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 FNetNfcNdefRecordTypeImpl.h
+ * @brief This is the header file for the _NdefRecordTypeImpl class.
+ *
+ * This header file contains the declarations of the _NdefRecordTypeImpl class.
+ */
+
+#ifndef _FNET_NFC_INTERNAL_NDEF_RECORD_TYPE_IMPL_H_
+#define _FNET_NFC_INTERNAL_NDEF_RECORD_TYPE_IMPL_H_
+
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FOspConfig.h>
+#include <FNetNfcNfcTypes.h>
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+// Forward declaration
+class NdefRecordType;
+
+/**
+ * @class _NdefRecordTypeImpl
+ * @brief This class encapsulates the type of an NDEF record
+ */
+class _OSP_EXPORT_ _NdefRecordTypeImpl
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * This is a constructor for this class.
+ * This constructor initializes the name format with the specified parameter.
+ *
+ * @param[in] format NDEF record type name format
+ */
+ _NdefRecordTypeImpl(NdefRecordTypeNameFormat format);
+
+ /**
+ * This is a copy constructor for this class.
+ *
+ * @param[in] value An instance of %_NdefRecordTypeImpl
+ */
+ _NdefRecordTypeImpl(const _NdefRecordTypeImpl& value);
+
+ /**
+ * This is the destructor for this class.
+ */
+ ~_NdefRecordTypeImpl(void);
+
+ /**
+ * Compares two record types
+ *
+ * @return @c true, if record types are equal,@n
+ * @c false, otherwise
+ * @param[in] obj record type that this record type is compared to
+ *
+ * @remarks
+ * <table border=1 cellpadding="1" cellspacing="1">
+ * <tr>
+ * <th>Record type format name</th>
+ * <th>Comparison rule for record type name</th>
+ * </tr>
+ * <tr>
+ * <td>NDEF_TNF_WELL_KNOWN</td>
+ * <td>character-by-character in case-sensitive manner. </td>
+ * </tr>
+ * <tr>
+ * <td>NDEF_TNF_MIME_MEDIA </td>
+ * <td>character-by-character in case-insensitive manner up to the first ";"</td>
+ * </tr>
+ * <tr>
+ * <td>NDEF_TNF_ABSOLUTE_URI </td>
+ * <td>Reserved characters must be percent-encoded and the hexadecimal digits in those normalized to upper-case
+ * letters. URI The scheme and host parts of the URI must be normalized to lower-case. After this the URIs are
+ * compared in the character-by-character in case-sensitive manner </td>
+ * </tr>
+ * <tr>
+ * <td>NDEF_TNF_EXTERNAL </td>
+ * <td>character-by-character in case-insensitive manner</td>
+ * </tr>
+ * <tr>
+ * <td>NDEF_TNF_EMPTY | NDEF_TNF_UNKNOWN </td>
+ * <td>Both record type names must be null</td>
+ * </tr>
+ * </table>
+ */
+ virtual bool Equals(const Tizen::Base::Object& obj) const;
+
+ /**
+ * Gets the hash value of the current instance.
+ *
+ * @return An integer value indicating the hash value of the current instance
+ * @remarks Two Equal instances should return the same hash value.
+ */
+ virtual int GetHashCode(void) const;
+
+ /**
+ * Gets the name format of this record type.
+ *
+ * @return The name format of this record type
+ */
+ NdefRecordTypeNameFormat GetNameFormat(void) const;
+
+ /**
+ * Gets the name of this record type.
+ *
+ * @return The name of this record type, An empty string if the name format is NDEF_TNF_EMPTY or
+ * NDEF_TNF_UNKNOWN
+ * @remarks The returned name does not have any prefix defined in the NFC Forum. @n
+ * If the name format of this record type is NDEF_TNF_ABSOLUTE_URI, this method returns the name in
+ * the same format as it was given in the constructor (with or without percent-encoding). The name
+ * consists of characters encoded using US_ASCII character set.
+ */
+ Tizen::Base::String GetName(void) const;
+
+ /**
+ * Sets the name of this record type.
+ *
+ * @return An error code
+ * @param[in] name The name of this record type
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_OPERATION This operation is not allowed if the name format is NDEF_TNF_EMPTY,
+ * NDEF_TNF_UNKNOWN, or NDEF_TNF_ALL.
+ * @exception E_INVALID_ENCODING_RANGE The specified input string contains code points that are outside the
+ * bounds specified by the US_ASCII encoding scheme.
+ * @exception E_INVALID_FORMAT The format of the specified name is invalid according to the
+ * specification of each type name format.
+ * @exception E_MAX_EXCEEDED The length of the name exceeds 256 characters.
+ * @remarks The input name must not have the prefix defined by the NFC forum such as @c "urn:nfc:wkt:" and
+ * @c "urn:nfc:ext:".
+ */
+ result SetName(const Tizen::Base::String& name);
+
+ /**
+ * This assignment operator copies the values from the specified instance of %_NdefRecordTypeImpl to the calling instance of
+ * %_NdefRecordTypeImpl.
+ *
+ * @return A reference to the %_NdefRecordTypeImpl instance
+ * @param[in] rhs A reference to the %_NdefRecordTypeImpl instance to copy
+ */
+ _NdefRecordTypeImpl& operator =(const _NdefRecordTypeImpl& value);
+
+private:
+ _NdefRecordTypeImpl(void);
+
+private:
+ NdefRecordTypeNameFormat __format;
+ Tizen::Base::String __name;
+}; // _NdefRecordTypeImpl
+
+} } } // Tizen::Net::Nfc
+#endif // _FNET_NFC_INTERNAL_NDEF_RECORD_TYPE_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 FNetNfc_NfcManagerImpl.h
+ * @brief This is the header file for the _NfcManagerImpl Class.
+ *
+ * This header file contains the declarations of the _NfcManagerImpl Class.
+ */
+#ifndef FNET_NFC_INTERNAL_NFC_MANAGER_IMPL_H
+#define FNET_NFC_INTERNAL_NFC_MANAGER_IMPL_H
+
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FBaseRtMutex.h>
+#include <FNetNfcNfcTypes.h>
+#include "FNetNfc_INfcTagDiscoveryEventListener.h"
+#include "FNetNfc_INfcDeviceDiscoveryEventListener.h"
+
+// Forward declaration
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+class Integer;
+} }
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class HashMap;
+} } }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+// Forward declaration
+class INfcManagerEventListener;
+class INfcTagDiscoveryEventListener;
+class INfcDeviceDiscoveryEventListener;
+class INdefMessageDiscoveryEventListener;
+class NdefRecordType;
+class TagConnection;
+class _NfcTagImpl;
+class _NfcSystemAdapter;
+class _NfcManagerEvent;
+class _NfcDeviceDiscoveryEvent;
+
+/**
+ * @class _NfcManagerImpl
+ * @brief This class provides information and performs operations of a _NfcManagerImpl.
+ */
+class _OSP_EXPORT_ _NfcManagerImpl
+ : public Tizen::Base::Object
+ , public _INfcTagDiscoveryEventListener
+ , public _INfcDeviceDiscoveryEventListener
+{
+ //
+ // @enum _NfcManagerStateType
+ //
+ // Defines the states of the NfcManager.
+ //
+ enum _NfcManagerStateType
+ {
+ _NFC_MANAGER_STATE_DISABLED,
+ _NFC_MANAGER_STATE_ACTIVATING,
+ _NFC_MANAGER_STATE_DEACTIVATING,
+ _NFC_MANAGER_STATE_IDLE,
+ _NFC_MANAGER_STATE_CONNECTED
+ };
+
+public:
+ /**
+ * This is the default constructor for this class.
+ */
+ _NfcManagerImpl(void);
+
+ /**
+ * This is the destructor for this class.
+ */
+ ~_NfcManagerImpl(void);
+
+ /**
+ * Initializes this instance of _NfcManagerImpl.
+ *
+ * @return An error code
+ * @param[in] listener The listener to be added
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_OUT_OF_MEMORY Insufficient memory.
+ * @exception E_SYSTEM A system error occurred.
+ */
+ result Construct(INfcManagerEventListener& listener);
+
+ /**
+ * Activates NFC feature.
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_STATE This instance is in an invalid state.
+ * @exception E_IN_PROGRESS The activation process is in progress.
+ * @exception E_SYSTEM A system error occurred.
+ */
+ result Activate(void);
+
+
+ /**
+ * Deactivates NFC feature.
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_STATE This instance is in an invalid state.
+ * @exception E_IN_PROGRESS The deactivation process is in progress.
+ * @exception E_SYSTEM A system error occurred.
+ */
+ result Deactivate(void);
+
+ /**
+ * Checks whether the NFC feature is activated.
+ *
+ * @return @c true, if the NFC feature is activated @n
+ * @c false, otherwise
+ */
+ bool IsActivated(void) const;
+
+ /**
+ * Checks whether an NFC tag is currently connected with the device.
+ *
+ * @return @c true, if an NFC tag is currently connected @n
+ * @c false, otherwise
+ */
+ bool IsTagConnected(void) const;
+
+ /**
+ * Checks whether peer device has been detected.
+ *
+ * @return @c true if peer device has been detected, @n
+ * else @c false
+ */
+ bool IsDeviceDetected(void) const;
+
+ /**
+ * Gets the tag connection with the currently detected tag.
+ *
+ * @return The tag connection with the currently detected tag @n
+ * @c null if no tag is connected or the getting fails
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_STATE This instance is in an invalid state.
+ * @exception E_CONNECTION_FAILED The connection with the tag is closed or fails.
+ * @exception E_OUT_OF_MEMORY Insufficient memory.
+ * @exception E_SYSTEM A system error occurred.
+ */
+ TagConnection* GetCurrentTagConnectionN(void) const;
+
+ /**
+ * Adds a listener instance for tag events with the specified tag type.
+ *
+ * @return An error code
+ * @param[in] listener The listener to be added
+ * @param[in] type The connection type the application is interested in
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_SYSTEM A system error occurred.
+ */
+ result AddTagDiscoveryEventListener(INfcTagDiscoveryEventListener& listener, NfcTagType type);
+
+ /**
+ * Removes the specified listener instance.
+ *
+ * @return An error code
+ * @param[in] listener The listener to be removed
+ * @param[in] type The tag type the application is not interested in any more
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_OBJ_NOT_FOUND The listener was not found.
+ * @exception E_SYSTEM A system error occurred.
+ */
+ result RemoveTagDiscoveryEventListener(INfcTagDiscoveryEventListener& listener, NfcTagType type);
+
+ /**
+ * Adds a listener instance for events about an NDEF message
+ * which includes the NDEF record with the specified type.
+ *
+ * @return An error code
+ * @param[in] listener The listener to be added
+ * @param[in] type The type of the NDEF record which the application is interested in
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_SYSTEM A system error occurred.
+ */
+ result AddNdefMessageDiscoveryEventListener(INdefMessageDiscoveryEventListener& listener, const NdefRecordType& type);
+
+ /**
+ * Removes message listener from the specified NDEF record type
+ *
+ * @return An error code
+ * @param[in] listener The listener to be removed
+ * @param[in] type The type of the NDEF record which the application is not interested in any more
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_OBJ_NOT_FOUND The listener was not found.
+ * @exception E_SYSTEM A system error occurred.
+ */
+ result RemoveNdefMessageDiscoveryEventListener(INdefMessageDiscoveryEventListener& listener, const NdefRecordType& type);
+
+ /**
+ * Adds the specified %INfcDeviceDiscoveryEventListener instance for the device discovery events.
+ *
+ * @return An error code
+ * @param[in] listener The listener to be added
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_ALREADY_EXIST The listener was already added.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ result AddDeviceDiscoveryEventListener(INfcDeviceDiscoveryEventListener& listener);
+
+ /**
+ * Removes the specified %INfcDeviceDiscoveryEventListener instance. @n
+ * The removed listener cannot listen to the events that are fired.
+ *
+ * @return An error code
+ * @param[in] listener The listener to be removed
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND The listener was not found.
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ result RemoveDeviceDiscoveryEventListener(INfcDeviceDiscoveryEventListener& listener);
+
+ /**
+ * Callback method to notify that the NFC is activated.
+ */
+ void OnNfcActivated(result r);
+
+ /**
+ * Callback method to notify that the NFC is deactivated.
+ */
+ void OnNfcDeactivated(result r);
+
+ /**
+ * Callback method which implements _INfcManagerEventListener
+ */
+ void OnNdefMessageDetected(const NdefMessage& message);
+
+ /**
+ * Callback method to notify that the target tag is detected.
+ */
+ virtual void OnNfcTagDetected(void);
+
+ /**
+ * Callback method to notify that the target tag is lost.
+ */
+ virtual void OnNfcTagLost(void);
+
+ /**
+ * Callback method to notify that the target device is detected.
+ */
+ virtual void OnNfcDeviceDetected(void);
+
+ /**
+ * Callback method to notify that the target device is lost.
+ */
+ virtual void OnNfcDeviceLost(void);
+
+ /**
+ * Gets the NDEF message cached when the tag is detected.
+ *
+ * @return The cached %NdefMessage instance, @n
+ * else @c null if the method is not successful
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_ILLEGAL_ACCESS This operation is not allowed because the application is not launched by
+ * Conditional %App Launch.
+ * @exception E_INVALID_FORMAT The cached data cannot be converted to the NDEF message.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ static NdefMessage* GetCachedNdefMessageN(void);
+
+ /**
+ * Enables or disables the Conditional NFC %App Launch pop-up. @n
+ * The pop-up includes all kinds of UI components that the system raises about NFC as well as a pop-up for
+ * selecting the launching application when a tag is detected.
+ *
+ * @return An error code
+ * @param[in] enable Set to @c true to enable the Conditional NFC %App Launch pop-up, @n
+ * else @c false
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ static result SetLaunchPopupEnabled(bool enable);
+
+private:
+ _NfcManagerImpl(const _NfcManagerImpl& value);
+ _NfcManagerImpl& operator =(const _NfcManagerImpl& value);
+
+ bool SendTagDiscoveryEvent(const _NfcTagImpl& tag, bool isDetected);
+ bool SendNdefMessageDetectedEvent(const NdefMessage& message);
+ const char* GetStringOfCurrentState(void) const;
+ const char* GetStringOfTagType(NfcTagType tagType) const;
+ void ConvertByteToString(const Tizen::Base::ByteBuffer* pSrcBytes, Tizen::Base::String& hexString) const;
+ void PrintTag(const _NfcTagImpl& tag) const;
+
+private:
+ _NfcSystemAdapter* __pSystemAdapter;
+ _NfcTagImpl* __pCurrentTagImpl;
+ _NfcManagerEvent* __pMgrEvent;
+ Tizen::Base::Collection::HashMap* __pTagConditionMap; // key: NfcTagType, value: event map
+ Tizen::Base::Collection::HashMap* __pNdefConditionMap; // key: NdefRecordType, value: event map
+ _NfcDeviceDiscoveryEvent* __pDeviceDiscoveryEvent;
+ Tizen::Base::Runtime::Mutex __stateMutex;
+ _NfcManagerStateType __currentState;
+}; // _NfcManagerImpl
+
+} } }
+#endif // FNET_NFC_INTERNAL_NFC_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 FNetNfcNfcTagImpl.h
+ * @brief This is the header file for the _NfcTagImpl class.
+ *
+ * This header file contains the declarations of the _NfcTagImpl class.
+ */
+
+#ifndef _FNET_NFC_INTERNAL_NFC_TAG_IMPL_H_
+#define _FNET_NFC_INTERNAL_NFC_TAG_IMPL_H_
+
+#include <FBaseByteBuffer.h>
+#include <FBaseColArrayListT.h>
+#include <FBaseColAllElementsDeleter.h>
+#include <FBaseObject.h>
+#include <FOspConfig.h>
+#include <FNetNfcNfcTypes.h>
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+// Forward declaration
+class NfcTag;
+
+/**
+ * @class _NfcTagImpl
+ * @brief This class provides information about the target tag.
+ */
+class _OSP_EXPORT_ _NfcTagImpl
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * This is a constructor for this class.
+ *
+ * @param[in] tagId The ID of the tag
+ * @param[in] types The types of the tag
+ * @param[in] isNdefSupported Set to @c true if the tag supports the NDEF message operations, @n
+ * else @c false
+ */
+ _NfcTagImpl(const Tizen::Base::ByteBuffer& tagId, const Tizen::Base::Collection::IListT <NfcTagType>& types, bool isNdefSupported);
+
+ /**
+ * This is a copy constructor for this class.
+ *
+ * @param[in] value An instance of _NfcTagImpl
+ */
+ _NfcTagImpl(const _NfcTagImpl& value);
+
+ /**
+ * This is the destructor for this class.
+ */
+ ~_NfcTagImpl(void);
+
+ /**
+ * Gets the list of the tag types.
+ *
+ * @return The list of tag types
+ */
+ const Tizen::Base::Collection::IListT <NfcTagType>* GetTagTypeList(void) const;
+
+ /**
+ * Checks whether the tag has the specified type.
+ *
+ * @return @c true if the target has the specified type, @n
+ * @c false otherwise
+ * @param[in] type The tag type to be checked
+ */
+ bool HasTagType(NfcTagType type) const;
+
+ /**
+ * Gets the ID of the tag.
+ *
+ * @return The ID of the tag
+ * @c null if the tag has no ID
+ */
+ const Tizen::Base::ByteBuffer* GetId(void) const;
+
+ /**
+ * Checks whether the tag supports the NDEF message operations.
+ */
+ bool IsNdefSupported(void) const;
+
+ /**
+ * This is the factory method for NfcTag class.
+ *
+ * @return The NfcTag object according to the specified _NfcTagImpl instance,
+ * @c null if the getting fails due to the insufficient memory
+ * @param[in] tagImpl The impl instance of the detected tag
+ */
+ static NfcTag* GetNfcTagN(const _NfcTagImpl& tagImpl);
+
+private:
+ _NfcTagImpl(void);
+ _NfcTagImpl& operator =(const _NfcTagImpl& value);
+
+private:
+ Tizen::Base::ByteBuffer __tagId;
+ Tizen::Base::Collection::ArrayListT <NfcTagType> __tagTypeList;
+ bool __isNdefSupported;
+}; // _NfcTagImpl
+
+} } } // Tizen::Net::Nfc
+#endif // _FNET_NFC_INTERNAL_NFC_TAG_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 FNetNfcTagConnectionImpl.h
+ * @brief This is the header file for the _TagConnectionImpl class.
+ *
+ * This header file contains the declarations of the _TagConnectionImpl class.
+ */
+
+#ifndef _FNET_NFC_INTERNAL_TAG_CONNECTION_IMPL_H_
+#define _FNET_NFC_INTERNAL_TAG_CONNECTION_IMPL_H_
+
+#include <FBaseObject.h>
+#include <FBaseRtMutex.h>
+#include <FOspConfig.h>
+#include "FNetNfc_INfcTagDiscoveryEventListener.h"
+
+// Forward declaration
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+} }
+
+namespace Tizen { namespace Net { namespace Nfc
+{
+
+// Forward declaration
+class NfcTag;
+class _NfcTagImpl;
+class NdefMessage;
+class TagConnection;
+class ITagConnectionListener;
+class INdefTagConnectionListener;
+class _NfcSystemAdapter;
+class _TagConnectionEvent;
+
+/**
+ * @enum _TagConnectionStateType
+ *
+ * Defines the states of the NfcManager.
+ */
+enum _TagConnectionStateType
+{
+ _TAG_CONNECTION_STATE_DISABLED,
+ _TAG_CONNECTION_STATE_CONNECTED,
+ _TAG_CONNECTION_STATE_SEND_REQUESTED,
+ _TAG_CONNECTION_STATE_READ_REQUESTED,
+ _TAG_CONNECTION_STATE_WRITE_REQUESTED,
+};
+
+/**
+ * @class _TagConnectionImpl
+ * @brief This class provides information about tag connection and performs operations for Non-NDEF tag such as
+ * ISO14443-4 compliant tag and general RFID tag.
+ */
+class _OSP_EXPORT_ _TagConnectionImpl
+ : public Tizen::Base::Object
+ , public _INfcTagDiscoveryEventListener
+{
+public:
+ /**
+ * This is the destructor for this class.
+ */
+ ~_TagConnectionImpl(void);
+
+ /**
+ * Gets the target tag object.
+ *
+ * @return The target tag object
+ */
+ const NfcTag* GetTargetTag(void) const;
+
+ /**
+ * Sets a listener for event about the result of sending command on tag connection.
+ *
+ * @return An error code
+ * @param[in] pListener The listener to be added
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_SYSTEM A system error occurred.
+ * @remarks Only one event listener is able to be set.
+ * If the input parameter is @c null, the listener already set is unregistered.
+ */
+ result SetTagConnectionListener(ITagConnectionListener* pListener);
+
+ /**
+ * Sets a listener for event about the result of reading or writing on NDEF tag connection.
+ *
+ * @return An error code
+ * @param[in] pListener The listener to be added
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_SYSTEM A system error occurred.
+ * @remarks Only one event listener is able to be set.
+ * If the input parameter is @c null, the listener already set is unregistered.
+ */
+ result SetNdefTagConnectionListener(INdefTagConnectionListener* pListener);
+
+ /**
+ * Sends the specified command to the target tag.
+ *
+ * @return An error code
+ * @param[in] command The command to be sent
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_ARG The input @c command is invalid.
+ * @exception E_IN_PROGRESS The previous send request is in progress.
+ * @exception E_CONNECTION_BUSY The connection is busy, so cannot process the send request.
+ * @exception E_CONNECTION_FAILED The connection to the tag is closed or fails.
+ * @exception E_SYSTEM A system error occurred.
+ */
+ result SendCommand(const Tizen::Base::ByteBuffer& command);
+
+ /**
+ * Reads NDEF data from the NDEF tag.
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_IN_PROGRESS The read process is in progress.
+ * @exception E_CONNECTION_BUSY The connection is busy, so cannot process the read request.
+ * @exception E_CONNECTION_FAILED The connection to the tag is closed or fails.
+ * @exception E_SYSTEM A system error occurred.
+ */
+ result Read(void);
+
+ /**
+ * Writes NDEF data to the NDEF tag.
+ *
+ * @return An error code
+ * @param[in] message NDEF message to be written to the target
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_INVALID_ARG The input @c message is invalid.
+ * For example, it does not contain any NDEF records.
+ * @exception E_IN_PROGRESS The write process is in progress.
+ * @exception E_CONNECTION_BUSY The connection is busy, so cannot process the write request.
+ * @exception E_CONNECTION_FAILED The connection to the tag is closed or fails.
+ * @exception E_SYSTEM A system error occurred.
+ */
+ result Write(const NdefMessage& message);
+
+ /**
+ * Callback method to notify that the read operation from the target tag is completed.
+ */
+ void OnNdefReadCompleted(const NdefMessage* pMessage, result r);
+
+ /**
+ * Callback method to notify that the write operation on the target tag is completed.
+ */
+ void OnNdefWriteCompleted(result r);
+
+ /**
+ * Callback method to notify that the response is received from the remote tag.
+ */
+ void OnNfcResponseReceived(const Tizen::Base::ByteBuffer* pResponse, result r);
+
+ /**
+ * Callback method to notify that the target tag is detected.
+ */
+ virtual void OnNfcTagDetected(void);
+
+ /**
+ * Callback method to notify that the target tag is lost.
+ */
+ virtual void OnNfcTagLost(void);
+
+ /**
+ * This is the factory method for TagConnection class.
+ *
+ * @return The TagConnection object according to the specified target tag and connection type,
+ * @c null if the getting fails due to the insufficient memory
+ * @param[in] tagImpl The impl instance of the target tag
+ */
+ static TagConnection* GetTagConnectionN(const _NfcTagImpl& tagImpl);
+
+private:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @remark After creating an instance of the _TagConnectionImpl class, Construct() methods must be called explicitly to initialize this instance.
+ * @see Construct()
+ */
+ _TagConnectionImpl(void);
+
+ _TagConnectionImpl(const _TagConnectionImpl& value);
+ _TagConnectionImpl& operator =(const _TagConnectionImpl& value);
+
+ /**
+ * Initializes this instance of NdefTagConnection.
+ *
+ * @return An error code
+ * @param[in] tagImpl The impl instance of the target tag
+ * @exception E_SUCCESS The method was successful.
+ * @exception E_OUT_OF_MEMORY Insufficient memory.
+ * @exception E_SYSTEM Internal initialization procedure failed.
+ */
+ result Construct(const _NfcTagImpl& tagImpl);
+
+ const char* GetStringOfCurrentState(void) const;
+
+private:
+ NfcTag* __pTargetTag;
+ _NfcSystemAdapter* __pSystemAdapter;
+ _TagConnectionEvent* __pConnEvent;
+ ITagConnectionListener* __pTagPreviousListener;
+ INdefTagConnectionListener* __pNdefTagPreviousListener;
+ Tizen::Base::Runtime::Mutex __stateMutex;
+ _TagConnectionStateType __currentState;
+
+}; // _TagConnectionImpl
+
+} } } // Tizen::Net::Nfc
+#endif // _FNET_NFC_INTERNAL_TAG_CONNECTION_IMPL_H_