Tizen 2.0 Release 2.0_release
authorHyungKyu Song <hk76.song@samsung.com>
Fri, 15 Feb 2013 06:11:18 +0000 (15:11 +0900)
committerHyungKyu Song <hk76.song@samsung.com>
Fri, 15 Feb 2013 06:11:18 +0000 (15:11 +0900)
28 files changed:
LICENSE.Flora [new file with mode: 0644]
NOTICE [new file with mode: 0644]
description.xml [new file with mode: 0755]
project/data/MyCard.data [new file with mode: 0644]
project/inc/FormFactory.h [new file with mode: 0644]
project/inc/MainForm.h [new file with mode: 0644]
project/inc/MyCardForm.h [new file with mode: 0644]
project/inc/MyCardManager.h [new file with mode: 0644]
project/inc/NfcController.h [new file with mode: 0644]
project/inc/NfcP2pBump.h [new file with mode: 0644]
project/inc/VcardTranslator.h [new file with mode: 0644]
project/manifest.xml [new file with mode: 0644]
project/res/eng-GB.xml [new file with mode: 0644]
project/res/screen-size-normal/IDF_MAINFORM.xml [new file with mode: 0644]
project/res/screen-size-normal/IDF_MYCARDFORM.xml [new file with mode: 0644]
project/shared/data/nofile.dummy [new file with mode: 0644]
project/shared/res/screen-density-xhigh/mainmenu.png [new file with mode: 0644]
project/shared/trusted/nofile.dummy [new file with mode: 0644]
project/src/FormFactory.cpp [new file with mode: 0644]
project/src/MainForm.cpp [new file with mode: 0644]
project/src/MyCardForm.cpp [new file with mode: 0644]
project/src/MyCardManager.cpp [new file with mode: 0644]
project/src/NfcController.cpp [new file with mode: 0644]
project/src/NfcP2pBump.cpp [new file with mode: 0644]
project/src/NfcP2pBumpEntry.cpp [new file with mode: 0644]
project/src/VcardTranslator.cpp [new file with mode: 0644]
sample.xml [new file with mode: 0755]
screenshot.png [new file with mode: 0644]

diff --git a/LICENSE.Flora b/LICENSE.Flora
new file mode 100644 (file)
index 0000000..9c95663
--- /dev/null
@@ -0,0 +1,206 @@
+Flora License
+
+Version 1.0, May, 2012
+
+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 Compatibility Definition Document
+and passes the Compatibility Test Suite 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.
+
+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.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://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.
+
diff --git a/NOTICE b/NOTICE
new file mode 100644 (file)
index 0000000..3997999
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,4 @@
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Flora License, Version 1.
+Please, see the LICENSE file for Flora License terms and conditions.
+
diff --git a/description.xml b/description.xml
new file mode 100755 (executable)
index 0000000..201b94c
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?> 
+<?xml-stylesheet type="text/xsl" href="../../../../description.xsl"?>
+
+<Overview version="0.17.1">
+  <SampleName>NfcP2pBump</SampleName>
+  <SampleVersion>1.0</SampleVersion>
+  <Preview>screenshot.png</Preview>
+  <Description>
+This sample application demonstrates how you can use the Near Field Communication (NFC) P2P service.
+  </Description>
+</Overview>
diff --git a/project/data/MyCard.data b/project/data/MyCard.data
new file mode 100644 (file)
index 0000000..5657a08
--- /dev/null
@@ -0,0 +1,3 @@
+Unknown
+Unknown
+Unknown
\ No newline at end of file
diff --git a/project/inc/FormFactory.h b/project/inc/FormFactory.h
new file mode 100644 (file)
index 0000000..294854a
--- /dev/null
@@ -0,0 +1,31 @@
+//
+// Tizen Native SDK
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.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://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.
+//
+
+#ifndef FORMFACTORY_H_
+#define FORMFACTORY_H_
+
+#include <FUiScenesIFormFactory.h>
+
+class FormFactory: public Tizen::Ui::Scenes::IFormFactory {
+public:
+       FormFactory();
+       virtual ~FormFactory();
+
+       virtual Tizen::Ui::Controls::Form* CreateFormN(const Tizen::Base::String &formId, const Tizen::Ui::Scenes::SceneId &sceneId);
+};
+
+#endif /* FORMFACTORY_H_ */
diff --git a/project/inc/MainForm.h b/project/inc/MainForm.h
new file mode 100644 (file)
index 0000000..c5bfdee
--- /dev/null
@@ -0,0 +1,66 @@
+//
+// Tizen Native SDK
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.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://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.
+//
+
+#ifndef _MAIN_FORM_H_
+#define _MAIN_FORM_H_
+
+#include <FBase.h>
+#include <FUi.h>
+#include <FNet.h>
+#include "MyCardForm.h"
+#include "NfcController.h"
+
+class MainForm
+       : public Tizen::Ui::Controls::Form
+       , public Tizen::Ui::IActionEventListener
+{
+
+public:
+       MainForm(void);
+       virtual ~MainForm(void);
+       bool Initialize(void);
+
+public:
+       // from Form
+       virtual result OnInitializing(void);
+       virtual result OnTerminating(void);
+
+       // from IActionEventListener
+       virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
+
+       void ChangeActivationButton(bool isActivate);
+       void ShowNameCard(const Tizen::Base::String& name, const Tizen::Base::String& number, const Tizen::Base::String& address);
+
+protected:
+       static const int ID_ACTIVATE = 101;
+       static const int ID_MY_CARD = 102;
+       static const int ID_DELETE_CARD = 103;
+       static const int MSGBOX_TIMEOUT = 2000;
+
+private:
+       Tizen::Ui::Controls::FooterItem __leftFooterItem;
+       Tizen::Ui::Controls::FooterItem __rightFooterItem;
+       Tizen::Ui::Controls::Label* __pCardStatus;
+       Tizen::Ui::Controls::EditField* __pNameField;
+       Tizen::Ui::Controls::EditField* __pNumberField;
+       Tizen::Ui::Controls::EditField* __pAddressField;
+       Tizen::Ui::Controls::Button* __pDeleteNameCard;
+
+       NfcController __nfcController;
+};
+
+#endif  //_MAIN_FORM_H_
diff --git a/project/inc/MyCardForm.h b/project/inc/MyCardForm.h
new file mode 100644 (file)
index 0000000..0217260
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// Tizen Native SDK
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.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://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.
+//
+
+#ifndef _WRITE_FORM_H_
+#define _WRITE_FORM_H_
+
+#include <FBase.h>
+#include <FUi.h>
+#include "MyCardManager.h"
+#include "NfcController.h"
+
+class MyCardForm
+       : public Tizen::Ui::Controls::Form
+       , public Tizen::Ui::Controls::IFormBackEventListener
+       , public Tizen::Ui::IActionEventListener
+       , public Tizen::Ui::Scenes::ISceneEventListener
+{
+
+public:
+       MyCardForm(void);
+       virtual ~MyCardForm(void);
+
+       bool Initialize(void);
+       // from Form
+       virtual result OnInitializing(void);
+       virtual result OnTerminating(void);
+
+       // from IActionEventListener
+       virtual void OnActionPerformed(const Control& source, int actionId);
+
+       // from IFormBackEventListener
+       virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source);
+
+       // from ISceneEventListener
+       virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
+                                                                  const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs);
+       virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
+                                                                       const Tizen::Ui::Scenes::SceneId& nextSceneId);
+
+protected:
+       static const int ID_SAVE = 501;
+       static const int MSGBOX_TIMEOUT = 2000;
+
+private:
+       Tizen::Ui::Controls::EditField* __pNameField;
+       Tizen::Ui::Controls::EditField* __pPhoneNumberField;
+       Tizen::Ui::Controls::EditField* __pEmailAddressField;
+       Tizen::Ui::Controls::FooterItem __leftFooterItem;
+
+       NfcController* __pNfcController;
+};
+
+#endif
diff --git a/project/inc/MyCardManager.h b/project/inc/MyCardManager.h
new file mode 100644 (file)
index 0000000..c0630d4
--- /dev/null
@@ -0,0 +1,36 @@
+//
+// Tizen Native SDK
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.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://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.
+//
+
+#ifndef _MY_CARD_MANAGER_H_
+#define _MY_CARD_MANAGER_H_
+
+#include <FBase.h>
+
+class MyCardManager
+{
+public:
+       static result ReadNameCardFromFile(Tizen::Base::String& name, Tizen::Base::String& number,
+                       Tizen::Base::String& address);
+       static result WriteNameCardToFile(const Tizen::Base::String& name, const Tizen::Base::String& number,
+                       const Tizen::Base::String& address);
+
+private:
+       MyCardManager(void);
+       ~MyCardManager(void);
+};
+
+#endif // _MY_CARD_MANAGER_H_
diff --git a/project/inc/NfcController.h b/project/inc/NfcController.h
new file mode 100644 (file)
index 0000000..f7cb035
--- /dev/null
@@ -0,0 +1,65 @@
+//
+// Tizen Native SDK
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.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://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.
+//
+
+#ifndef _NFC_CONTROLLER_H_
+#define _NFC_CONTROLLER_H_
+
+#include <FBase.h>
+#include <FNet.h>
+
+class MainForm;
+
+class NfcController
+       : public Tizen::Base::Object
+       , public Tizen::Net::Nfc::INfcManagerEventListener
+       , public Tizen::Net::Nfc::INdefMessageDiscoveryEventListener
+       , public Tizen::Net::Nfc::INdefPushManagerListener
+       , public Tizen::Net::Nfc::INfcDeviceDiscoveryEventListener
+{
+public:
+       NfcController(MainForm* pMainForm);
+       ~NfcController(void);
+
+       bool Initialize(void);
+       void ToggleNfcActivation(void);
+       void RegisterPushMessage(const Tizen::Base::String& name, const Tizen::Base::String& number, const Tizen::Base::String& address);
+       void UnregisterPushMessage(void);
+       bool IsNfcActivated(void);
+
+       //from INfcManagerEventListener
+       virtual void OnNfcActivated(result r);
+       virtual void OnNfcDeactivated(result r);
+
+       //from INdefMessageDiscoveryEventListener
+       virtual void OnNdefMessageDetectedN(Tizen::Net::Nfc::NdefMessage* pMessage);
+
+       //from INdefPushManagerListener
+       virtual void OnNdefPushMessageSent(result r);
+
+       //INfcDeviceDiscoveryEventListener
+       virtual void OnNfcDeviceDetected(void);
+       virtual void OnNfcDeviceLost(void);
+
+private:
+       MainForm* __pMainForm;
+       Tizen::Net::Nfc::NfcManager* __pNfcManager;
+       Tizen::Net::Nfc::NdefPushManager* __pNdefPushManager;
+
+       MyCardManager* __pMyCardManager;
+};
+
+#endif // _NFC_CONTROLLER_H_
diff --git a/project/inc/NfcP2pBump.h b/project/inc/NfcP2pBump.h
new file mode 100644 (file)
index 0000000..e2dc76d
--- /dev/null
@@ -0,0 +1,48 @@
+//
+// Tizen Native SDK
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.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://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.
+//
+
+#ifndef _NFC_P2P_BUMP_H_
+#define _NFC_P2P_BUMP_H_
+
+#include <FApp.h>
+#include <FBase.h>
+#include <FSystem.h>
+#include <FUi.h>
+
+class NfcP2pBump
+       : public Tizen::App::Application
+       , public Tizen::System::IScreenEventListener
+{
+public:
+       static Tizen::App::Application* CreateInstance(void);
+
+public:
+       NfcP2pBump(void);
+       ~NfcP2pBump(void);
+
+public:
+       virtual bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry);
+       virtual bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false);
+       virtual void OnForeground(void);
+       virtual void OnBackground(void);
+       virtual void OnLowMemory(void);
+       virtual void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel);
+       virtual void OnScreenOn(void);
+       virtual void OnScreenOff(void);
+};
+
+#endif
diff --git a/project/inc/VcardTranslator.h b/project/inc/VcardTranslator.h
new file mode 100644 (file)
index 0000000..6539ad1
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// Tizen Native SDK
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.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://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.
+//
+
+#ifndef _VCARD_TRANSLATOR_H_
+#define _VCARD_TRANSLATOR_H_
+
+#include <FBase.h>
+#include <FNet.h>
+
+class VcardTranslator
+{
+public:
+       static Tizen::Net::Nfc::NdefMessage* ConvertStringToVcardN(const Tizen::Base::String& name, const Tizen::Base::String& number,
+                       const Tizen::Base::String& address);
+       static result ConvertVcardToString(const Tizen::Net::Nfc::NdefMessage* pMsg,Tizen::Base::String& name, Tizen::Base::String& number,
+                       Tizen::Base::String& address);
+
+private:
+       VcardTranslator();
+       ~VcardTranslator();
+};
+
+#endif // _VCARD_TRANSLATOR_H_
diff --git a/project/manifest.xml b/project/manifest.xml
new file mode 100644 (file)
index 0000000..54b851b
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<Manifest xmlns="http://schemas.tizen.org/2012/12/manifest">
+    <Id>$(manifestAppId)</Id>
+    <Version>2.0.0</Version>
+    <Type>C++App</Type>
+    <Author/>
+    <Descriptions/>
+    <Url/>
+    <Apps>
+        <ApiVersion>2.0</ApiVersion>
+        <Privileges>
+            <Privilege>http://tizen.org/privilege/nfc.tag</Privilege>
+            <Privilege>http://tizen.org/privilege/nfc.common</Privilege>
+            <Privilege>http://tizen.org/privilege/nfc.p2p</Privilege>
+            <Privilege>http://tizen.org/privilege/nfc.admin</Privilege>
+        </Privileges>
+        <UiApp Main="True" Name="$(projectName)" MenuIconVisible="True">
+            <UiScalability BaseScreenSize="Normal" CoordinateSystem="Logical" LogicalCoordinate="480"/>
+            <UiTheme SystemTheme="White"/>
+            <DisplayNames>
+                <DisplayName Locale="eng-GB">$(projectName)</DisplayName>
+            </DisplayNames>
+            <Icons>
+                <Icon Section="MainMenu" Type="Xhigh">mainmenu.png</Icon>
+            </Icons>
+            <AppControls/>
+            <LaunchConditions/>
+            <Notifications/>
+        </UiApp>
+    </Apps>
+</Manifest>
diff --git a/project/res/eng-GB.xml b/project/res/eng-GB.xml
new file mode 100644 (file)
index 0000000..8a33d58
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+       This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.v20110404" Dversion="20100701"/>
diff --git a/project/res/screen-size-normal/IDF_MAINFORM.xml b/project/res/screen-size-normal/IDF_MAINFORM.xml
new file mode 100644 (file)
index 0000000..046d5d5
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+       This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<!DOCTYPE Scene SYSTEM "UIForm.dtd">
+
+<Scene Bversion="3.0.0.201210311640" Dversion="20120315">
+    <LogicalCoordinate>480</LogicalCoordinate>
+    <Form id="IDF_MAINFORM">
+        <property backgroundColor="" backgroundColorOpacity="100" orientation="Portrait" softKey0NormalIcon="" softKey0PressedIcon="" softKey0Text="" softKey1NormalIcon="" softKey1PressedIcon="" softKey1Text="" title="" titleAlign="ALIGN_LEFT" titleIcon="" translucentFooter="false" translucentHeader="false" translucentIndicator="false"/>
+        <layout mode="Portrait" style="FORM_STYLE_INDICATOR|FORM_STYLE_HEADER|FORM_STYLE_FOOTER" type="NONE"/>
+        <layout mode="Landscape" style="FORM_STYLE_INDICATOR|FORM_STYLE_HEADER|FORM_STYLE_FOOTER" type="NONE"/>
+    </Form>
+    <Footer>
+        <property backgroundBitmapPath="" color="" colorOpacity="0" disabledButtonColor="" disabledButtonColorOpacity="0" disabledButtonTextColor="" disabledItemColor="" disabledItemColorOpacity="0" disabledItemTextColor="" footerStyle="FOOTER_STYLE_TAB" highlightedButtonColor="" highlightedButtonColorOpacity="0" highlightedButtonTextColor="" highlightedItemColor="" highlightedItemColorOpacity="0" highlightedItemTextColor="" normalButtonColor="" normalButtonColorOpacity="0" normalButtonTextColor="" normalItemColor="" normalItemColorOpacity="0" normalItemTextColor="" pressedButtonColor="" pressedButtonColorOpacity="0" pressedButtonTextColor="" pressedItemColor="" pressedItemColorOpacity="0" pressedItemTextColor="" selectedItemColor="" selectedItemColorOpacity="0" selectedItemTextColor="" showBackButton="false"/>
+        <itemSet/>
+    </Footer>
+    <Header>
+        <property backgroundBitmapPath="" color="" colorOpacity="0" descriptionText="" descriptionTextColor="" disabledButtonColor="" disabledButtonColorOpacity="0" disabledButtonTextColor="" disabledItemColor="" disabledItemColorOpacity="0" disabledItemTextColor="" headerStyle="HEADER_STYLE_TITLE" highlightedButtonColor="" highlightedButtonColorOpacity="0" highlightedButtonTextColor="" highlightedItemColor="" highlightedItemColorOpacity="0" highlightedItemTextColor="" normalButtonColor="" normalButtonColorOpacity="0" normalButtonTextColor="" normalItemColor="" normalItemColorOpacity="0" normalItemTextColor="" pressedButtonColor="" pressedButtonColorOpacity="0" pressedButtonTextColor="" pressedItemColor="" pressedItemColorOpacity="0" pressedItemTextColor="" selectedItemColor="" selectedItemColorOpacity="0" selectedItemTextColor="" titleIconPath="" titleText="NFC P2P BUMP" titleTextColor=""/>
+        <itemSet/>
+    </Header>
+    <Label id="IDC_CARD_STATUS" parent="IDF_MAINFORM">
+        <property backgroundBitmapPath="" backgroundColor="" backgroundColorOpacity="0" horizontalAlign="ALIGN_LEFT" text="" textColor="" textSize="22" textStyle="LABEL_TEXT_STYLE_NORMAL" verticalAlign="ALIGN_TOP"/>
+        <layout height="166" mode="Portrait" width="447" x="16" y="260"/>
+        <layout height="54" mode="Landscape" width="798" x="1" y="160"/>
+    </Label>
+    <Button id="IDC_BUTTON1" parent="IDF_MAINFORM">
+        <property disableTextColor="" disabledBitmapPath="" disabledColor="" disabledColorOpacity="100" highlightedBGBitmapPath="" highlightedColor="" highlightedColorOpacity="100" highlightedTextColor="" horizontalAlign="ALIGN_CENTER" normalBGBitmapPath="" normalBitmapPath="" normalColor="" normalColorOpacity="100" normalTextColor="" pressedBGBitmapPath="" pressedBitmapPath="" pressedColor="" pressedColorOpacity="100" pressedTextColor="" text="" textSize="22" verticalAlign="ALIGN_MIDDLE"/>
+        <layout height="71" mode="Portrait" width="447" x="16" y="541"/>
+        <layout height="48" mode="Landscape" width="745" x="28" y="261"/>
+    </Button>
+    <EditField id="IDC_NAME_FIELD" parent="IDF_MAINFORM">
+        <property disabledBGBitmapPath="" disabledColor="" disabledColorOpacity="100" disabledTextColor="" ellipsisPosition="ELLIPSIS_POSITION_END" enableClear="false" groupStyle="GROUP_STYLE_NONE" guideText="" guideTextColor="" highlightedBGBitmapPath="" highlightedColor="" highlightedColorOpacity="100" highlightedTextColor="" horizontalMargin="10" inputStyle="INPUT_STYLE_FULLSCREEN" keypadAction="" keypadEnabled="false" limitLength="100" linkTextColor="" lowerCaseMode="false" normalBGBitmapPath="" normalColor="" normalColorOpacity="100" normalTextColor="" pressedBGBitmapPath="" pressedColor="" pressedColorOpacity="100" text="" textHorizontalAlignment="ALIGNMENT_LEFT" textSize="30" titleStyle="EDIT_FIELD_TITLE_STYLE_TOP" titleText="" titleTextColor="" verticalMargin="10" viewMode="false"/>
+        <layout height="104" mode="Portrait" style="EDIT_FIELD_STYLE_NORMAL" width="447" x="16" y="70"/>
+        <layout height="102" mode="Landscape" style="EDIT_FIELD_STYLE_NORMAL" width="745" x="26" y="0"/>
+    </EditField>
+    <EditField id="IDC_NUMBER_FIELD" parent="IDF_MAINFORM">
+        <property disabledBGBitmapPath="" disabledColor="" disabledColorOpacity="100" disabledTextColor="" ellipsisPosition="ELLIPSIS_POSITION_END" enableClear="false" groupStyle="GROUP_STYLE_NONE" guideText="" guideTextColor="" highlightedBGBitmapPath="" highlightedColor="" highlightedColorOpacity="100" highlightedTextColor="" horizontalMargin="10" inputStyle="INPUT_STYLE_FULLSCREEN" keypadAction="" keypadEnabled="false" limitLength="100" linkTextColor="" lowerCaseMode="false" normalBGBitmapPath="" normalColor="" normalColorOpacity="100" normalTextColor="" pressedBGBitmapPath="" pressedColor="" pressedColorOpacity="100" text="" textHorizontalAlignment="ALIGNMENT_LEFT" textSize="30" titleStyle="EDIT_FIELD_TITLE_STYLE_TOP" titleText="" titleTextColor="" verticalMargin="10" viewMode="false"/>
+        <layout height="104" mode="Portrait" style="EDIT_FIELD_STYLE_NORMAL" width="447" x="16" y="224"/>
+        <layout height="102" mode="Landscape" style="EDIT_FIELD_STYLE_NORMAL" width="745" x="26" y="84"/>
+    </EditField>
+    <EditField id="IDC_ADDRESS_FIELD" parent="IDF_MAINFORM">
+        <property disabledBGBitmapPath="" disabledColor="" disabledColorOpacity="100" disabledTextColor="" ellipsisPosition="ELLIPSIS_POSITION_END" enableClear="false" groupStyle="GROUP_STYLE_NONE" guideText="" guideTextColor="" highlightedBGBitmapPath="" highlightedColor="" highlightedColorOpacity="100" highlightedTextColor="" horizontalMargin="10" inputStyle="INPUT_STYLE_FULLSCREEN" keypadAction="" keypadEnabled="false" limitLength="100" linkTextColor="" lowerCaseMode="false" normalBGBitmapPath="" normalColor="" normalColorOpacity="100" normalTextColor="" pressedBGBitmapPath="" pressedColor="" pressedColorOpacity="100" text="" textHorizontalAlignment="ALIGNMENT_LEFT" textSize="30" titleStyle="EDIT_FIELD_TITLE_STYLE_TOP" titleText="" titleTextColor="" verticalMargin="10" viewMode="false"/>
+        <layout height="104" mode="Portrait" style="EDIT_FIELD_STYLE_NORMAL" width="447" x="16" y="371"/>
+        <layout height="102" mode="Landscape" style="EDIT_FIELD_STYLE_NORMAL" width="745" x="26" y="166"/>
+    </EditField>
+</Scene>
diff --git a/project/res/screen-size-normal/IDF_MYCARDFORM.xml b/project/res/screen-size-normal/IDF_MYCARDFORM.xml
new file mode 100644 (file)
index 0000000..2f45ecd
--- /dev/null
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+       This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<!DOCTYPE Scene SYSTEM "UIForm.dtd">
+
+<Scene Bversion="3.0.0.201211051355" Dversion="20120315">
+    <LogicalCoordinate>480</LogicalCoordinate>
+    <Form id="IDF_MYCARDFORM">
+        <property backgroundColor="" backgroundColorOpacity="100" orientation="Portrait" softKey0NormalIcon="" softKey0PressedIcon="" softKey0Text="" softKey1NormalIcon="" softKey1PressedIcon="" softKey1Text="" title="" titleAlign="ALIGN_CENTER" titleIcon="" translucentFooter="false" translucentHeader="false" translucentIndicator="false"/>
+        <layout mode="Portrait" style="FORM_STYLE_INDICATOR|FORM_STYLE_HEADER|FORM_STYLE_FOOTER" type="NONE"/>
+        <layout mode="Landscape" style="FORM_STYLE_INDICATOR|FORM_STYLE_HEADER|FORM_STYLE_FOOTER" type="NONE"/>
+    </Form>
+    <Footer>
+        <property backgroundBitmapPath="" color="" colorOpacity="0" disabledButtonColor="" disabledButtonColorOpacity="0" disabledButtonTextColor="" disabledItemColor="" disabledItemColorOpacity="0" disabledItemTextColor="" footerStyle="FOOTER_STYLE_TAB" highlightedButtonColor="" highlightedButtonColorOpacity="0" highlightedButtonTextColor="" highlightedItemColor="" highlightedItemColorOpacity="0" highlightedItemTextColor="" normalButtonColor="" normalButtonColorOpacity="0" normalButtonTextColor="" normalItemColor="" normalItemColorOpacity="0" normalItemTextColor="" pressedButtonColor="" pressedButtonColorOpacity="0" pressedButtonTextColor="" pressedItemColor="" pressedItemColorOpacity="0" pressedItemTextColor="" selectedItemColor="" selectedItemColorOpacity="0" selectedItemTextColor="" showBackButton="false"/>
+        <itemSet/>
+    </Footer>
+    <Header>
+        <property backgroundBitmapPath="" color="" colorOpacity="0" descriptionText="" descriptionTextColor="" disabledButtonColor="" disabledButtonColorOpacity="0" disabledButtonTextColor="" disabledItemColor="" disabledItemColorOpacity="0" disabledItemTextColor="" headerStyle="HEADER_STYLE_TITLE" highlightedButtonColor="" highlightedButtonColorOpacity="0" highlightedButtonTextColor="" highlightedItemColor="" highlightedItemColorOpacity="0" highlightedItemTextColor="" normalButtonColor="" normalButtonColorOpacity="0" normalButtonTextColor="" normalItemColor="" normalItemColorOpacity="0" normalItemTextColor="" pressedButtonColor="" pressedButtonColorOpacity="0" pressedButtonTextColor="" pressedItemColor="" pressedItemColorOpacity="0" pressedItemTextColor="" selectedItemColor="" selectedItemColorOpacity="0" selectedItemTextColor="" titleIconPath="" titleText="MY CARD" titleTextColor=""/>
+        <itemSet/>
+    </Header>
+    <EditField id="IDC_EDITFIELD1" parent="IDF_MYCARDFORM">
+        <property disabledBGBitmapPath="" disabledColor="" disabledColorOpacity="100" disabledTextColor="" ellipsisPosition="ELLIPSIS_POSITION_END" enableClear="false" groupStyle="GROUP_STYLE_NONE" guideText="" guideTextColor="" highlightedBGBitmapPath="" highlightedColor="" highlightedColorOpacity="100" highlightedTextColor="" horizontalMargin="10" inputStyle="INPUT_STYLE_FULLSCREEN" keypadAction="" keypadEnabled="true" limitLength="100" linkTextColor="" lowerCaseMode="false" normalBGBitmapPath="" normalColor="" normalColorOpacity="100" normalTextColor="" pressedBGBitmapPath="" pressedColor="" pressedColorOpacity="100" text="" textHorizontalAlignment="ALIGNMENT_LEFT" textSize="30" titleStyle="EDIT_FIELD_TITLE_STYLE_NONE" titleText="" titleTextColor="" verticalMargin="10" viewMode="false"/>
+        <layout height="103" mode="Portrait" style="EDIT_FIELD_STYLE_NORMAL" width="420" x="30" y="76"/>
+        <layout height="61" mode="Landscape" style="EDIT_FIELD_STYLE_NORMAL" width="700" x="50" y="0"/>
+    </EditField>
+    <EditField id="IDC_EDITFIELD2" parent="IDF_MYCARDFORM">
+        <property disabledBGBitmapPath="" disabledColor="" disabledColorOpacity="100" disabledTextColor="" ellipsisPosition="ELLIPSIS_POSITION_END" enableClear="false" groupStyle="GROUP_STYLE_NONE" guideText="" guideTextColor="" highlightedBGBitmapPath="" highlightedColor="" highlightedColorOpacity="100" highlightedTextColor="" horizontalMargin="10" inputStyle="INPUT_STYLE_FULLSCREEN" keypadAction="" keypadEnabled="true" limitLength="100" linkTextColor="" lowerCaseMode="false" normalBGBitmapPath="" normalColor="" normalColorOpacity="100" normalTextColor="" pressedBGBitmapPath="" pressedColor="" pressedColorOpacity="100" text="" textHorizontalAlignment="ALIGNMENT_LEFT" textSize="30" titleStyle="EDIT_FIELD_TITLE_STYLE_NONE" titleText="" titleTextColor="" verticalMargin="10" viewMode="false"/>
+        <layout height="102" mode="Portrait" style="EDIT_FIELD_STYLE_PHONE_NUMBER" width="420" x="30" y="269"/>
+        <layout height="60" mode="Landscape" style="EDIT_FIELD_STYLE_PHONE_NUMBER" width="700" x="50" y="64"/>
+    </EditField>
+    <EditField id="IDC_EDITFIELD3" parent="IDF_MYCARDFORM">
+        <property disabledBGBitmapPath="" disabledColor="" disabledColorOpacity="100" disabledTextColor="" ellipsisPosition="ELLIPSIS_POSITION_END" enableClear="false" groupStyle="GROUP_STYLE_NONE" guideText="" guideTextColor="" highlightedBGBitmapPath="" highlightedColor="" highlightedColorOpacity="100" highlightedTextColor="" horizontalMargin="10" inputStyle="INPUT_STYLE_FULLSCREEN" keypadAction="" keypadEnabled="true" limitLength="100" linkTextColor="" lowerCaseMode="false" normalBGBitmapPath="" normalColor="" normalColorOpacity="100" normalTextColor="" pressedBGBitmapPath="" pressedColor="" pressedColorOpacity="100" text="" textHorizontalAlignment="ALIGNMENT_LEFT" textSize="30" titleStyle="EDIT_FIELD_TITLE_STYLE_NONE" titleText="" titleTextColor="" verticalMargin="10" viewMode="false"/>
+        <layout height="104" mode="Portrait" style="EDIT_FIELD_STYLE_EMAIL" width="420" x="30" y="459"/>
+        <layout height="74" mode="Landscape" style="EDIT_FIELD_STYLE_EMAIL" width="700" x="50" y="144"/>
+    </EditField>
+    <Label id="IDC_LABEL1" parent="IDF_MYCARDFORM">
+        <property backgroundBitmapPath="" backgroundColor="#E5E5E5" backgroundColorOpacity="0" horizontalAlign="ALIGN_LEFT" text="Name" textColor="" textSize="22" textStyle="LABEL_TEXT_STYLE_NORMAL" verticalAlign="ALIGN_TOP"/>
+        <layout height="29" mode="Portrait" width="123" x="24" y="36"/>
+        <layout height="17" mode="Landscape" width="221" x="50" y="0"/>
+    </Label>
+    <Label id="IDC_LABEL2" parent="IDF_MYCARDFORM">
+        <property backgroundBitmapPath="" backgroundColor="#E5E5E5" backgroundColorOpacity="0" horizontalAlign="ALIGN_LEFT" text="Phone number" textColor="" textSize="22" textStyle="LABEL_TEXT_STYLE_NORMAL" verticalAlign="ALIGN_TOP"/>
+        <layout height="29" mode="Portrait" width="194" x="24" y="226"/>
+        <layout height="17" mode="Landscape" width="221" x="50" y="66"/>
+    </Label>
+    <Label id="IDC_LABEL3" parent="IDF_MYCARDFORM">
+        <property backgroundBitmapPath="" backgroundColor="#E5E5E5" backgroundColorOpacity="0" horizontalAlign="ALIGN_LEFT" text="e-mail address" textColor="" textSize="22" textStyle="LABEL_TEXT_STYLE_NORMAL" verticalAlign="ALIGN_TOP"/>
+        <layout height="31" mode="Portrait" width="164" x="24" y="412"/>
+        <layout height="18" mode="Landscape" width="370" x="50" y="158"/>
+    </Label>
+</Scene>
diff --git a/project/shared/data/nofile.dummy b/project/shared/data/nofile.dummy
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/project/shared/res/screen-density-xhigh/mainmenu.png b/project/shared/res/screen-density-xhigh/mainmenu.png
new file mode 100644 (file)
index 0000000..983c883
Binary files /dev/null and b/project/shared/res/screen-density-xhigh/mainmenu.png differ
diff --git a/project/shared/trusted/nofile.dummy b/project/shared/trusted/nofile.dummy
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/project/src/FormFactory.cpp b/project/src/FormFactory.cpp
new file mode 100644 (file)
index 0000000..1c149af
--- /dev/null
@@ -0,0 +1,60 @@
+//
+// Tizen Native SDK
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.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://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.
+//
+
+#include <FUi.h>
+#include "FormFactory.h"
+#include "MainForm.h"
+#include "MyCardForm.h"
+
+using namespace Tizen::Ui::Controls;
+using namespace Tizen::Ui::Scenes;
+
+FormFactory::FormFactory()
+{
+
+}
+
+FormFactory::~FormFactory()
+{
+
+}
+
+Form*
+FormFactory::CreateFormN(const Tizen::Base::String &formId, const Tizen::Ui::Scenes::SceneId &sceneId)
+{
+       Form* pNewForm = null;
+       SceneManager* pSceneManager = SceneManager::GetInstance();
+       AppAssert(pSceneManager);
+
+       if (formId == L"MainForm")
+       {
+               MainForm* pForm = new (std::nothrow) MainForm();
+               pForm->Initialize();
+               pNewForm = pForm;
+       }
+       else if (formId == L"MyCardForm")
+       {
+               MyCardForm* pForm = new (std::nothrow) MyCardForm();
+               pForm->Initialize();
+               pSceneManager->AddSceneEventListener(sceneId, *pForm);
+               pNewForm = pForm;
+       }
+
+       return pNewForm;
+}
+
+
diff --git a/project/src/MainForm.cpp b/project/src/MainForm.cpp
new file mode 100644 (file)
index 0000000..c43efd0
--- /dev/null
@@ -0,0 +1,222 @@
+//
+// Tizen Native SDK
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.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://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.
+//
+
+#include <new>
+#include <FGraphics.h>
+#include <FMedia.h>
+#include "NfcP2pBump.h"
+#include "MainForm.h"
+#include "MyCardManager.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+using namespace Tizen::Ui::Scenes;
+using namespace Tizen::App;
+using namespace Tizen::Net::Nfc;
+using namespace Tizen::Graphics;
+
+MainForm::MainForm(void)
+       : __leftFooterItem()
+       , __rightFooterItem()
+       , __pCardStatus(null)
+       , __pNameField(null)
+       , __pNumberField(null)
+       , __pAddressField(null)
+       , __pDeleteNameCard(null)
+       , __nfcController(this)
+{
+
+}
+
+MainForm::~MainForm(void)
+{
+
+}
+
+bool
+MainForm::Initialize(void)
+{
+       bool result = false;
+
+       Construct(L"IDF_MAINFORM");
+
+       result = __nfcController.Initialize();
+       TryReturn(result == true, false, "Nfc resources are not available.");
+
+       return true;
+}
+
+result
+MainForm::OnInitializing(void)
+{
+       result r = E_SUCCESS;
+
+       __pCardStatus = static_cast< Label* >(GetControl(L"IDC_CARD_STATUS"));
+       __pCardStatus->SetTextConfig(30, LABEL_TEXT_STYLE_BOLD);
+       __pCardStatus->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
+       __pCardStatus->SetTextColor(Tizen::Graphics::Color::GetColor(COLOR_ID_BLACK));
+       __pCardStatus->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
+       __pCardStatus->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
+       __pCardStatus->SetText(L"Bump to share name card");
+
+       __pNameField = static_cast< EditField* >(GetControl(L"IDC_NAME_FIELD"));
+       __pNameField->SetShowState(false);
+       __pNumberField = static_cast< EditField* >(GetControl(L"IDC_NUMBER_FIELD"));
+       __pNumberField->SetShowState(false);
+       __pAddressField = static_cast< EditField* >(GetControl(L"IDC_ADDRESS_FIELD"));
+       __pAddressField->SetShowState(false);
+
+       __pDeleteNameCard = static_cast< Button* >(GetControl(L"IDC_BUTTON1"));
+       __pDeleteNameCard->SetText(L"Delete");
+       __pDeleteNameCard->SetActionId(ID_DELETE_CARD);
+       __pDeleteNameCard->SetTextColor(Tizen::Graphics::Color::GetColor(COLOR_ID_RED));
+       __pDeleteNameCard->SetShowState(false);
+       __pDeleteNameCard->AddActionEventListener(*this);
+
+       Footer* pFooter = GetFooter();
+       if (pFooter != null)
+       {
+               pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
+               r = __leftFooterItem.Construct(ID_ACTIVATE);
+
+               //Find whether NFC is active or not.
+               if (__nfcController.IsNfcActivated() == true)
+               {
+                       r = __leftFooterItem.SetText("Deactivate");
+               }
+               else
+               {
+                       r = __leftFooterItem.SetText("Activate");
+               }
+               r = pFooter->AddItem(__leftFooterItem);
+               r = __rightFooterItem.Construct(ID_MY_CARD);
+               r = __rightFooterItem.SetText("My Card");
+               r = pFooter->AddItem(__rightFooterItem);
+               pFooter->AddActionEventListener(*this);
+       }
+       //Disables the launch popup message by Conditional NFC App Launch.
+       NfcManager::SetLaunchPopupEnabled(false);
+
+       return r;
+}
+
+result
+MainForm::OnTerminating(void)
+{
+       result r = E_SUCCESS;
+
+       return r;
+}
+void
+MainForm::ShowNameCard(const Tizen::Base::String& name, const Tizen::Base::String& number, const Tizen::Base::String& address)
+{
+       __pCardStatus->SetShowState(false);
+
+       __pNameField->SetTitleText("Name");
+       __pNameField->SetText(name);
+       __pNameField->SetShowState(true);
+
+       __pNumberField->SetTitleText("Phone number");
+       __pNumberField->SetText(number);
+       __pNumberField->SetShowState(true);
+
+       __pAddressField->SetTitleText("e-mail address");
+       __pAddressField->SetText(address);
+       __pAddressField->SetShowState(true);
+
+       __pDeleteNameCard->SetShowState(true);
+
+       RequestRedraw();
+}
+
+void
+MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
+{
+       SceneManager* pSceneManager = SceneManager::GetInstance();
+       AppAssert(pSceneManager);
+       ArrayList* pParams = null;
+       pParams = new (std::nothrow) ArrayList();
+
+       switch (actionId)
+       {
+       case ID_ACTIVATE:
+               __nfcController.ToggleNfcActivation();
+               break;
+
+       case ID_MY_CARD:
+               //Go to MyCard scene
+               AppLog("MyCard Button Clicked");
+               pParams->Add(__nfcController);
+               pSceneManager->GoForward(ForwardSceneTransition(L"MyCardScene"), pParams);
+
+               break;
+
+       case ID_DELETE_CARD:
+               AppLog("Delete Button Clicked");
+               __pCardStatus->SetShowState(true);
+               __pNameField->SetShowState(false);
+               __pNumberField->SetShowState(false);
+               __pAddressField->SetShowState(false);
+               __pDeleteNameCard->SetShowState(false);
+
+               RequestRedraw();
+               break;
+
+       default:
+               break;
+       }
+}
+void
+MainForm::ChangeActivationButton(bool isActivate)
+{
+       Footer* pFooter = GetFooter();
+       MessageBox messageBox;
+       int modalResult = 0;
+
+       //Change the text of left footer item when NFC state is changed.
+       if (isActivate)
+       {
+               AppLog("NFC Activated");
+               __leftFooterItem.SetText("Deactivate");
+               if (pFooter != null)
+               {
+                       pFooter->RemoveItemAt(0);
+                       pFooter->InsertItemAt(0, __leftFooterItem);
+                       RequestRedraw();
+               }
+               messageBox.Construct(L"NFC Activate", L"NFC Successfully\n Activated.", MSGBOX_STYLE_NONE, MSGBOX_TIMEOUT);
+               // Call ShowAndWait - draw, show itself and process events
+               messageBox.ShowAndWait(modalResult);
+       }
+       else
+       {
+               AppLog("NFC Deactivated");
+               __leftFooterItem.SetText("Activate");
+               if (pFooter != null)
+               {
+                       pFooter->RemoveItemAt(0);
+                       pFooter->InsertItemAt(0, __leftFooterItem);
+                       RequestRedraw();
+               }
+               messageBox.Construct(L"NFC Deactivate", L"NFC Successfully\n Deactivated.", MSGBOX_STYLE_NONE, MSGBOX_TIMEOUT);
+               // Call ShowAndWait - draw, show itself and process events
+               messageBox.ShowAndWait(modalResult);
+       }
+}
diff --git a/project/src/MyCardForm.cpp b/project/src/MyCardForm.cpp
new file mode 100644 (file)
index 0000000..acd23ef
--- /dev/null
@@ -0,0 +1,168 @@
+//
+// Tizen Native SDK
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.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://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.
+//
+
+#include <new>
+#include "MyCardForm.h"
+#include "MyCardManager.h"
+#include <FApp.h>
+#include <FGraphics.h>
+#include <FText.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+using namespace Tizen::Ui::Scenes;
+using namespace Tizen::App;
+using namespace Tizen::Graphics;
+using namespace Tizen::Text;
+
+MyCardForm::MyCardForm(void)
+       : __pNameField(null)
+       , __pPhoneNumberField(null)
+       , __pEmailAddressField(null)
+       , __leftFooterItem()
+       , __pNfcController(null)
+{
+
+}
+
+MyCardForm::~MyCardForm(void)
+{
+
+}
+
+bool
+MyCardForm::Initialize(void)
+{
+       Form::Construct(L"IDF_MYCARDFORM");
+
+       return true;
+}
+
+result
+MyCardForm::OnInitializing(void)
+{
+       String myName;
+       String myPhoneNumber;
+       String myEmailAddress;
+       result r = E_SUCCESS;
+
+       SetName(L"MyCardForm");
+
+       r = MyCardManager::ReadNameCardFromFile(myName, myPhoneNumber, myEmailAddress);
+       TryReturn(r == E_SUCCESS, r, "[%s] Failed to read namecard from file.", GetErrorMessage(r));
+
+       //Get handle of edit field, and set text by name of user.
+       __pNameField = static_cast<EditField *>(GetControl(L"IDC_EDITFIELD1"));
+       TryReturn(__pNameField != null, r = E_FAILURE, "getting handle to edit filed __pNameField failed by %s.", GetErrorMessage(r));
+       __pNameField->SetText(myName);
+
+       //Get handle of edit field, and set text by phone number of user.
+       __pPhoneNumberField = static_cast<EditField *>(GetControl(L"IDC_EDITFIELD2"));
+       TryReturn(__pPhoneNumberField != null, r = E_FAILURE, "getting handle to edit filed __pPhoneNumberField failed by %s.", GetErrorMessage(r));
+       __pPhoneNumberField->SetText(myPhoneNumber);
+
+       //Get handle of edit field, and set text by e-mail address of user.
+       __pEmailAddressField = static_cast<EditField *>(GetControl(L"IDC_EDITFIELD3"));
+       TryReturn(__pEmailAddressField != null, r = E_FAILURE, "getting handle to edit filed __pEmailAddressField failed by %s.", GetErrorMessage(r));
+       __pEmailAddressField->SetText(myEmailAddress);
+
+       Footer* pFooter = GetFooter();
+       if (pFooter != null)
+       {
+               pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
+               r = __leftFooterItem.Construct(ID_SAVE);
+               r = __leftFooterItem.SetText("Save");
+               r = pFooter->AddItem(__leftFooterItem);
+
+               pFooter->SetBackButton();
+               SetFormBackEventListener(this);
+               pFooter->AddActionEventListener(*this);
+       }
+
+       return r;
+}
+
+result
+MyCardForm::OnTerminating(void)
+{
+       result r = E_SUCCESS;
+
+       // TODO: Add your termination code here
+
+       return r;
+}
+
+void
+MyCardForm::OnActionPerformed(const Control& source, int actionId)
+{
+       MessageBox messageBox;
+       result r = E_SUCCESS;
+       int modalResult = 0;
+
+       SceneManager* pSceneManager = SceneManager::GetInstance();
+       AppAssert(pSceneManager);
+       ArrayList* pParams = null;
+       pParams = new (std::nothrow) ArrayList();
+
+       switch (actionId)
+       {
+       case ID_SAVE:
+               AppLog("Save Button Pressed");
+               r = MyCardManager::WriteNameCardToFile(__pNameField->GetText(), __pPhoneNumberField->GetText(), __pEmailAddressField->GetText());
+               TryReturnVoid(r == E_SUCCESS, "[%s] Failed to write namecard to file.",GetErrorMessage(r));
+
+               messageBox.Construct(L"My Card", L"Save success", MSGBOX_STYLE_NONE, MSGBOX_TIMEOUT);
+               messageBox.ShowAndWait(modalResult);
+
+               //Register push message when save button is pressed
+               __pNfcController->RegisterPushMessage(__pNameField->GetText(), __pPhoneNumberField->GetText(), __pEmailAddressField->GetText());
+               pSceneManager->GoBackward(BackwardSceneTransition());
+               break;
+
+       default:
+               break;
+       }
+}
+
+void
+MyCardForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
+                                                          const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
+{
+       if(pArgs)
+       {
+               __pNfcController = (NfcController*)pArgs->GetAt(0);
+
+               delete pArgs;
+       }
+}
+
+void
+MyCardForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
+                                                               const Tizen::Ui::Scenes::SceneId& nextSceneId)
+{
+
+}
+
+void
+MyCardForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
+{
+       //Go to Main scene when back button is clicked
+       SceneManager* pSceneManager = SceneManager::GetInstance();
+       pSceneManager->GoBackward(BackwardSceneTransition());
+}
diff --git a/project/src/MyCardManager.cpp b/project/src/MyCardManager.cpp
new file mode 100644 (file)
index 0000000..2b4ed65
--- /dev/null
@@ -0,0 +1,103 @@
+//
+// Tizen Native SDK
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.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://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.
+//
+
+#include <new>
+#include <FApp.h>
+#include <FIo.h>
+#include "MyCardManager.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::App;
+using namespace Tizen::Io;
+
+const wchar_t* NFC_BUMP_MY_CARD_INFO_PATH = L"data/MyCard.data";
+
+MyCardManager::MyCardManager(void)
+
+{
+
+}
+
+MyCardManager::~MyCardManager(void)
+{
+
+}
+
+result
+MyCardManager::ReadNameCardFromFile(Tizen::Base::String& name, Tizen::Base::String& number, Tizen::Base::String& address)
+{
+       File file;
+       String buffer;
+       int length;
+       result r = E_SUCCESS;
+
+       r = file.Construct(App::GetInstance()->GetAppRootPath() + NFC_BUMP_MY_CARD_INFO_PATH, "r", false);
+       TryReturn(r == E_SUCCESS, r, "Failed to open the file.");
+
+       r = file.Seek(FILESEEKPOSITION_BEGIN, 0);
+       TryReturn(r == E_SUCCESS, r, "Failed to repositions the file pointer.");
+
+       //read user's name from data file
+       r = file.Read(buffer);
+       TryReturn(r == E_SUCCESS, r, "Failed to read my name from file.");
+
+       length = buffer.GetLength();
+       buffer.SubString(0, length - 1, name);
+       buffer.Clear();
+
+       //read user's phone number from data file
+       r = file.Read(buffer);
+       TryReturn(r == E_SUCCESS, r, "Failed to read my phone number from file.");
+
+       length = buffer.GetLength();
+       buffer.SubString(0, length - 1, number);
+       buffer.Clear();
+
+       //read user's e-mail address from data file
+       r = file.Read(buffer);
+       TryReturn(r == E_SUCCESS, r, "Failed to read my e-mail address from file.");
+
+       length = buffer.GetLength();
+       buffer.SubString(0, length, address);
+
+       return r;
+}
+
+result
+MyCardManager::WriteNameCardToFile(const Tizen::Base::String& name, const Tizen::Base::String& number,
+               const Tizen::Base::String& address)
+{
+       File file;
+       result r = E_SUCCESS;
+
+       r = file.Construct(App::GetInstance()->GetAppRootPath() + NFC_BUMP_MY_CARD_INFO_PATH, "w", false);
+       TryReturn(r == E_SUCCESS, r, "Failed to open the file.");
+
+       r = file.Seek(FILESEEKPOSITION_BEGIN, 0);
+       TryReturn(r == E_SUCCESS, r, "Failed to repositions the file pointer.");
+
+       r = file.Write(name + "\n");
+       TryReturn(r == E_SUCCESS, r, "Failed to write my name to file.");
+
+       r = file.Write(number + "\n");
+       TryReturn(r == E_SUCCESS, r, "Failed to write my phone number to file.");
+
+       r = file.Write(address);
+       TryReturn(r == E_SUCCESS, r, "Failed to write my e-mail address to file.");
+
+       return r;
+}
diff --git a/project/src/NfcController.cpp b/project/src/NfcController.cpp
new file mode 100644 (file)
index 0000000..b9e3e2e
--- /dev/null
@@ -0,0 +1,200 @@
+//
+// Tizen Native SDK
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.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://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.
+//
+
+#include <new>
+#include "MainForm.h"
+#include "NfcController.h"
+#include "MyCardManager.h"
+#include "VcardTranslator.h"
+#include <FApp.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::App;
+using namespace Tizen::Net::Nfc;
+
+NfcController::NfcController(MainForm* pMainForm)
+       : __pMainForm(pMainForm)
+       , __pNfcManager(null)
+       , __pNdefPushManager(null)
+{
+
+}
+
+NfcController::~NfcController(void)
+{
+       delete __pNfcManager;
+       delete __pNdefPushManager;
+}
+
+bool
+NfcController::Initialize(void)
+{
+       result r = E_SUCCESS;
+
+       //initialize the instance of NfcManager class and add listener.
+       __pNfcManager = new (std::nothrow) NfcManager();
+       r = __pNfcManager->Construct(*this);
+       TryReturn(r == E_SUCCESS, false, "NfcManager::Construct() failed");
+
+       r = __pNfcManager->AddNdefMessageDiscoveryEventListener(*this, NdefRecordType(NDEF_TNF_ALL));
+       TryReturn(r == E_SUCCESS, false, "NfcManager::AddNdefMessageDiscoveryEventListener() has failed.");
+
+       r = __pNfcManager->AddDeviceDiscoveryEventListener(*this);
+       TryReturn(r == E_SUCCESS, false, "NfcManager::AddDeviceDiscoveryEventListener() has failed.");
+
+       //initialize the instance of NfcPushManager class and set listener.
+       __pNdefPushManager = new (std::nothrow) NdefPushManager();
+       r = __pNdefPushManager->SetNdefPushManagerListener(this);
+       TryReturn(r == E_SUCCESS, false, "NdefPushManager::SetNdefPushManagerListener() has failed.");
+
+       return true;
+}
+
+void
+NfcController::ToggleNfcActivation(void)
+{
+       result r = E_SUCCESS;
+
+       //check whether NFC is active or not.
+       if (__pNfcManager->IsActivated() == true)
+       {
+               AppLog("Deactivate Button is clicked!!");
+
+               //deactivate NFC when current state is activate.
+               r = __pNfcManager->Deactivate();
+               TryReturnVoid(r == E_SUCCESS, "Failed to deactivate NFC %s", GetErrorMessage(r));
+       }
+       else
+       {
+               AppLog("Activate Button is clicked!!");
+
+               //activate NFC when current state is deactivate.
+               r = __pNfcManager->Activate();
+               TryReturnVoid(r == E_SUCCESS, "Failed to activate NFC %s", GetErrorMessage(r));
+       }
+}
+
+void
+NfcController::RegisterPushMessage(const Tizen::Base::String& name, const Tizen::Base::String& number,
+               const Tizen::Base::String& address)
+{
+       NdefMessage* pMsg = VcardTranslator::ConvertStringToVcardN(name, number, address);
+
+       //register the NDEF message and set message description
+       __pNdefPushManager->RegisterNdefPushMessage(*pMsg, "My Namecard");
+
+       pMsg->RemoveAllRecords(true);
+       delete pMsg;
+}
+
+void
+NfcController::UnregisterPushMessage(void)
+{
+       //unregister the NDEF message
+       __pNdefPushManager->UnregisterNdefPushMessage();
+}
+
+bool
+NfcController::IsNfcActivated(void)
+{
+       //return the current NFC state.
+       return __pNfcManager->IsActivated();
+}
+
+void
+NfcController::OnNdefMessageDetectedN(Tizen::Net::Nfc::NdefMessage* pMessage)
+{
+       String name;
+       String number;
+       String address;
+       result r = E_SUCCESS;
+
+       //convert from NDEF message(contains V-Card format) to string items when NDEF message is detected.
+       AppLog("NDEF message detected");
+       r = VcardTranslator::ConvertVcardToString(pMessage, name, number, address);
+       TryLog(!IsFailed(r), "Failed to translate V-card to String format.");
+
+       if(!IsFailed(r))
+       {
+               //show opponent's namecard information in Main scene.
+               __pMainForm->ShowNameCard(name, number, address);
+       }
+       pMessage->RemoveAllRecords(true);
+       delete pMessage;
+}
+
+void
+NfcController::OnNdefPushMessageSent(result r)
+{
+       AppLog("Push NDEF message was sent");
+}
+
+void
+NfcController::OnNfcDeviceDetected(void)
+{
+       //convert from string items to NDEF message(contains V-Card format) when other P2P device is detected.
+       String name;
+       String number;
+       String address;
+       result r = E_SUCCESS;
+
+       AppLog("Device detected");
+
+       r = MyCardManager::ReadNameCardFromFile(name, number, address);
+       TryReturnVoid(r == E_SUCCESS, "Failed to read namecard from file.");
+
+       NdefMessage* pMsg = VcardTranslator::ConvertStringToVcardN(name, number, address);
+
+       //push NDEF message to other device.
+       __pNdefPushManager->Push(*pMsg);
+
+       pMsg->RemoveAllRecords(true);
+       delete pMsg;
+}
+
+void
+NfcController::OnNfcDeviceLost(void)
+{
+       AppLog("Device lost");
+}
+
+void
+NfcController::OnNfcActivated(result r)
+{
+       if (IsFailed(r))
+       {
+               AppLog("NFC Activation failed");
+       }
+       else
+       {
+               __pMainForm->ChangeActivationButton(true);
+       }
+}
+
+void
+NfcController::OnNfcDeactivated(result r)
+{
+       if (IsFailed(r))
+       {
+               AppLog("NFC Deactivation failed");
+       }
+       else
+       {
+               __pMainForm->ChangeActivationButton(false);
+       }
+}
+
diff --git a/project/src/NfcP2pBump.cpp b/project/src/NfcP2pBump.cpp
new file mode 100644 (file)
index 0000000..1f372eb
--- /dev/null
@@ -0,0 +1,100 @@
+//
+// Tizen Native SDK
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.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://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.
+//
+
+#include <new>
+#include "NfcP2pBump.h"
+#include "MainForm.h"
+#include "FormFactory.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::System;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+using namespace Tizen::Ui::Scenes;
+
+NfcP2pBump::NfcP2pBump()
+{
+}
+
+NfcP2pBump::~NfcP2pBump()
+{
+}
+
+Application*
+NfcP2pBump::CreateInstance(void)
+{
+       return new (std::nothrow) NfcP2pBump();
+}
+
+bool
+NfcP2pBump::OnAppInitializing(AppRegistry& appRegistry)
+{
+       Frame* pFrame = new Frame();
+       pFrame->Construct();
+       pFrame->SetName(L"NfcP2pBump");
+       AddFrame(*pFrame);
+
+       SceneManager* pSceneManager = SceneManager::GetInstance();
+       AppAssert(pSceneManager);
+       static FormFactory formFactory;
+       pSceneManager->RegisterFormFactory(formFactory);
+       pSceneManager->RegisterScene(L"MainScene", L"MainForm", L"");
+       pSceneManager->RegisterScene(L"MyCardScene", L"MyCardForm", L"");
+
+       if (pSceneManager->GoForward(ForwardSceneTransition(L"MainScene")) != E_SUCCESS)
+       {
+               return false;
+       }
+       return true;
+}
+
+bool
+NfcP2pBump::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
+{
+       return true;
+}
+
+void
+NfcP2pBump::OnForeground(void)
+{
+}
+
+void
+NfcP2pBump::OnBackground(void)
+{
+}
+
+void
+NfcP2pBump::OnLowMemory(void)
+{
+}
+
+void
+NfcP2pBump::OnBatteryLevelChanged(BatteryLevel batteryLevel)
+{
+}
+
+void
+NfcP2pBump::OnScreenOn(void)
+{
+}
+
+void
+NfcP2pBump::OnScreenOff(void)
+{
+}
diff --git a/project/src/NfcP2pBumpEntry.cpp b/project/src/NfcP2pBumpEntry.cpp
new file mode 100644 (file)
index 0000000..c164db8
--- /dev/null
@@ -0,0 +1,56 @@
+//
+// Tizen Native SDK
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.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://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.
+//
+
+#include "NfcP2pBump.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif // __cplusplus
+
+_EXPORT_ int OspMain(int argc, char *pArgv[]);
+
+/**
+ * The entry function of Tizen application called by the operating system.
+ */
+int
+OspMain(int argc, char* pArgv[])
+{
+       result r = E_SUCCESS;
+
+       AppLog("Application started.");
+       ArrayList args;
+       args.Construct();
+       for (int i = 0; i < argc; i++)
+       {
+               args.Add(*(new (std::nothrow) String(pArgv[i])));
+       }
+
+       r = Tizen::App::Application::Execute(NfcP2pBump::CreateInstance, &args);
+       TryLog(!IsFailed(r), "Application execution failed-[%s].", GetErrorMessage(r));
+
+       args.RemoveAll(true);
+       AppLog("Application finished.");
+
+       return static_cast< int >(r);
+}
+#ifdef __cplusplus
+}
+#endif // __cplusplus
diff --git a/project/src/VcardTranslator.cpp b/project/src/VcardTranslator.cpp
new file mode 100644 (file)
index 0000000..ec2e36c
--- /dev/null
@@ -0,0 +1,129 @@
+//
+// Tizen Native SDK
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.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://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.
+//
+
+#include <new>
+#include "VcardTranslator.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::App;
+using namespace Tizen::Net::Nfc;
+
+VcardTranslator::VcardTranslator(void)
+{
+}
+
+VcardTranslator::~VcardTranslator(void)
+{
+}
+
+NdefMessage*
+VcardTranslator::ConvertStringToVcardN(const Tizen::Base::String& name, const Tizen::Base::String& number,
+               const Tizen::Base::String& address)
+{
+       String strPayload;
+
+       strPayload += L"BEGIN:VCARD\nVERSION:2.1\nFN:" + name + "\nTEL;CELL:" + number + "\nEMAIL;PREF;INTERNET:"
+                       + address + "\nEND:VCARD\n";
+
+       ByteBuffer* pPayload = Tizen::Base::Utility::StringUtil::StringToUtf8N(strPayload);
+
+       NdefMessage* pMsg = new (std::nothrow) NdefMessage();
+       NdefRecordType recordType(NDEF_TNF_MIME_MEDIA);
+       recordType.SetName(L"text/x-vCard");
+       NdefRecord* pRecord = new (std::nothrow) NdefRecord(recordType);
+       pRecord->SetRecordType(recordType);
+       pRecord->SetPayload(*pPayload);
+       pMsg->AppendRecord(*pRecord);
+       delete pPayload;
+
+       return pMsg;
+}
+
+result
+VcardTranslator::ConvertVcardToString(const NdefMessage* pMsg, Tizen::Base::String& name, Tizen::Base::String& number,
+               Tizen::Base::String& address)
+{
+       String textPayload;
+       ByteBuffer* pPayloadData = null;
+       char* pDataString = null;
+
+       String myName;
+       String myNumber;
+       String myAddress;
+
+       String vCardNameStart(L"FN:");
+       String vCardNumberStart(L"TEL;CELL:");
+       String vCardAddressStart(L"EMAIL;PREF;INTERNET:");
+
+       int lastIndex = 0;
+       int startIndexOfName = 0;
+       int endIndexOfName = 0;
+
+       int startIndexOfNumber = 0;
+       int endIndexOfNumber = 0;
+
+       int startIndexOfEmail = 0;
+       int endIndexOfEmail = 0;
+
+       NdefRecord* pRecord = pMsg->GetRecordAt(0);
+
+       pPayloadData = pRecord->GetPayload();
+       TryReturn(pPayloadData != null, E_INVALID_FORMAT, "Payload is empty.");
+
+       lastIndex = pPayloadData->GetRemaining();
+       pDataString = new char[lastIndex + 1];
+
+       memcpy(pDataString, pPayloadData->GetPointer(), lastIndex);
+       pDataString[lastIndex] = '\0';
+       StringUtil::Utf8ToString(pDataString, textPayload);
+
+       delete[] pDataString;
+
+       if(textPayload.StartsWith("BEGIN:VCARD\n",0))
+       {
+               AppLog("This NDEF message contains Vcard format...");
+
+               textPayload.IndexOf(vCardNameStart, 0, startIndexOfName);
+               textPayload.IndexOf("\n", startIndexOfName, endIndexOfName);
+               textPayload.SubString(startIndexOfName + vCardNameStart.GetLength(),
+                               endIndexOfName - startIndexOfName - vCardNameStart.GetLength(), myName);
+
+               textPayload.IndexOf(vCardNumberStart, 0, startIndexOfNumber);
+               textPayload.IndexOf("\n", startIndexOfNumber, endIndexOfNumber);
+               textPayload.SubString(startIndexOfNumber + vCardNumberStart.GetLength(),
+                               endIndexOfNumber - startIndexOfNumber - vCardNumberStart.GetLength(), myNumber);
+
+               textPayload.IndexOf(vCardAddressStart, 0, startIndexOfEmail);
+               textPayload.IndexOf("\n", startIndexOfEmail, endIndexOfEmail);
+               textPayload.SubString(startIndexOfEmail + vCardAddressStart.GetLength(),
+                               endIndexOfEmail - startIndexOfEmail - vCardAddressStart.GetLength(), myAddress);
+
+               name = myName;
+               number = myNumber;
+               address = myAddress;
+
+               return E_SUCCESS;
+       }
+       else
+       {
+               AppLog("This NDEF message not contains V-card format...");
+
+               return E_INVALID_FORMAT;
+       }
+
+}
diff --git a/sample.xml b/sample.xml
new file mode 100755 (executable)
index 0000000..6c3fb46
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<template>
+                
+       <slp-property>
+               <property-group>
+                       <sample-name>NfcP2pBump</sample-name>
+                       <category>Sample</category>
+                       <sdk-version>1.00</sdk-version>
+                       <project-type>org.tizen.nativecpp.buildArtefactType.app</project-type>                  
+                       <sample-description>description.xml</sample-description>
+               </property-group>
+       </slp-property>
+       
+       <process type="org.tizen.nativeappcommon.TizenCopyFolder">
+               <simple name="projectName" value="$(projectName)"/>
+               <simple name="folderPath" value="project"/>
+               <complex-array name="replaceableFiles">
+                 <element>
+                               <simple name="sourcePath" value="manifest.xml"/>
+                               <simple name="targetPath" value="manifest.xml"/>
+                               <simple name="replaceable" value = "true"/>
+                       </element>
+               </complex-array>
+       </process>
+       <process type="org.tizen.nativecpp.SetDefaultFrameworks">
+               <simple name="projectName" value="$(projectName)"/>
+               <complex-array name="frameworkList">
+                       <element>
+                               <simple name="framework" value="osp"/>
+                       </element>
+               </complex-array>
+       </process>
+       
+</template>
diff --git a/screenshot.png b/screenshot.png
new file mode 100644 (file)
index 0000000..5a7efb1
Binary files /dev/null and b/screenshot.png differ