summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE206
-rw-r--r--NOTICE4
-rwxr-xr-xdescription.xml11
-rwxr-xr-xproject/data/continents.xml23
-rwxr-xr-xproject/data/map.xml23
-rwxr-xr-xproject/data/tizen.html17
-rw-r--r--project/inc/FormFactory.h21
-rwxr-xr-xproject/inc/HtmlParser.h73
-rwxr-xr-xproject/inc/MainListForm.h51
-rwxr-xr-xproject/inc/XmlParser.h83
-rw-r--r--project/inc/XmlParserApp.h74
-rwxr-xr-xproject/inc/XmlReader.h70
-rwxr-xr-xproject/inc/XmlWriter.h72
-rw-r--r--project/manifest.xml30
-rwxr-xr-xproject/res/eng-GB.xml5
-rwxr-xr-xproject/res/screen-size-normal/IDF_FORM1.xml24
-rw-r--r--project/shared/data/nofile.dummy0
-rwxr-xr-xproject/shared/res/screen-density-xhigh/mainmenu.pngbin0 -> 17581 bytes
-rw-r--r--project/shared/trusted/nofile.dummy0
-rw-r--r--project/src/FormFactory.cpp63
-rw-r--r--project/src/HtmlParser.cpp203
-rwxr-xr-xproject/src/MainListForm.cpp112
-rw-r--r--project/src/XmlParser.cpp511
-rw-r--r--project/src/XmlParserApp.cpp103
-rw-r--r--project/src/XmlParserAppEntry.cpp60
-rw-r--r--project/src/XmlReader.cpp201
-rw-r--r--project/src/XmlWriter.cpp297
-rwxr-xr-xsample.xml34
-rwxr-xr-xscreenshot.pngbin0 -> 8765 bytes
29 files changed, 2371 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..917b21e
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,206 @@
+Flora License
+
+Version 1.0, May, 2012
+
+http://www.tizenopensource.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://www.tizenopensource.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
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
index 0000000..cc326b9
--- /dev/null
+++ b/description.xml
@@ -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> XmlParserApp </SampleName>
+ <SampleVersion>1.0</SampleVersion>
+ <Preview>screenshot.png</Preview>
+ <Description>
+ This sample application demonstrates the features supported by Tizen XML.
+ </Description>
+</Overview>
diff --git a/project/data/continents.xml b/project/data/continents.xml
new file mode 100755
index 0000000..9be078d
--- /dev/null
+++ b/project/data/continents.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!-- This is a comment -->
+<continentlist>
+
+<continent category="Asia">
+ <country lang="kr">South Korea</country>
+ <capital>Seoul</capital>
+ <currency>Won</currency>
+</continent>
+
+<continent category="Europe">
+ <country lang="fr">France</country>
+ <capital>Paris</capital>
+ <currency>Euro</currency>
+</continent>
+
+<continent category="North America">
+ <country lang="en">Canada</country>
+ <capital>Ottawa</capital>
+ <currency>Dollar</currency>
+</continent>
+
+</continentlist> \ No newline at end of file
diff --git a/project/data/map.xml b/project/data/map.xml
new file mode 100755
index 0000000..c305faf
--- /dev/null
+++ b/project/data/map.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<map>
+ <item>
+ <country>United Arab Emirates</country>
+ <capital>Abu Dhabi</capital>
+ </item>
+
+ <item>
+ <country>Nigeria</country>
+ <capital>Abuja</capital>
+ </item>
+
+ <item>
+ <country>Ghana</country>
+ <capital>Accra</capital>
+ </item>
+
+ <item>
+ <country>Pitcairn Islands</country>
+ <capital>Adamstown</capital>
+ </item>
+</map> \ No newline at end of file
diff --git a/project/data/tizen.html b/project/data/tizen.html
new file mode 100755
index 0000000..1b27e5d
--- /dev/null
+++ b/project/data/tizen.html
@@ -0,0 +1,17 @@
+<html>
+<head>
+<base target=contents>
+</head>
+<a name=Title><h2>Tizen Store</h2>
+</a><p><hr></p>
+<p><hr></p>
+
+<dl>
+<a href=http://www.tizen.org>Entertainment!</a><br>
+<a href=http://www.tizen.org>Games!</a><br>
+<a href=http://www.tizen.org>Social!</a><br>
+<a href=http://www.tizen.org>Widgets!</a><br>
+<a href=http://www.tizen.org>Education!</a><br>
+<a href=http://www.tizen.org>Navigation!</a><br>
+</dl>
+</html>
diff --git a/project/inc/FormFactory.h b/project/inc/FormFactory.h
new file mode 100644
index 0000000..0be8e11
--- /dev/null
+++ b/project/inc/FormFactory.h
@@ -0,0 +1,21 @@
+/*
+ * FormFactory.h
+ *
+ * Created on: Sep 25, 2012
+ * Author: lsw2000.lee
+ */
+
+#ifndef _FORM_FACTORY_H_
+#define _FORM_FACTORY_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 /* _FORM_FACTORY_H_ */
diff --git a/project/inc/HtmlParser.h b/project/inc/HtmlParser.h
new file mode 100755
index 0000000..8a46f2a
--- /dev/null
+++ b/project/inc/HtmlParser.h
@@ -0,0 +1,73 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 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://www.tizenopensource.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 _HTML_PARSER_H_
+#define _HTML_PARSER_H_
+
+#include <libxml/HTMLparser.h>
+#include <libxml/tree.h>
+
+#include <FBase.h>
+#include <FUi.h>
+#include <FUiCtrlForm.h>
+
+class HtmlParser
+ : public Tizen::Ui::Controls::Form
+ , public Tizen::Ui::Controls::IListViewItemEventListener
+ , public Tizen::Ui::Controls::IListViewItemProvider
+ , public Tizen::Ui::IActionEventListener
+ , public Tizen::Ui::Controls::IFormBackEventListener
+{
+public:
+ HtmlParser(void);
+ virtual ~HtmlParser(void);
+
+ bool Initialize(void);
+
+ void RunHtmlParser(void);
+ void ExtractHyperLinks(htmlNodePtr pRoot);
+ virtual result OnInitializing(void);
+ virtual result OnTerminating(void);
+
+ //IActionEventListener
+ virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
+
+ // IListViewItemEventListener
+ virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state);
+ virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status);
+ virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction);
+
+ //IListViewItemProvider
+ virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth);
+ virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth);
+ virtual int GetItemCount(void);
+
+ //IFormBackEventListener
+ virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source);
+
+protected:
+ Tizen::Ui::Controls::ListView* _pList;
+ Tizen::Base::Collection::ArrayList* _pItemList;
+
+private:
+ static const int LIST_WIDTH = 720;
+ static const int LIST_HEIGHT = 640;
+
+ static const int ITEM_HEIGHT = 112;
+};
+
+#endif //_HTML_PARSER_H_
diff --git a/project/inc/MainListForm.h b/project/inc/MainListForm.h
new file mode 100755
index 0000000..bfb1fef
--- /dev/null
+++ b/project/inc/MainListForm.h
@@ -0,0 +1,51 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 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://www.tizenopensource.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 _MAINLISTFORM_H_
+#define _MAINLISTFORM_H_
+
+#include <FBase.h>
+#include <FUi.h>
+
+class MainListForm
+ : public Tizen::Ui::Controls::Form
+ , public Tizen::Ui::IActionEventListener
+{
+public:
+ MainListForm(void);
+ virtual ~MainListForm(void);
+ bool Initialize(void);
+
+ virtual result OnInitializing(void);
+ virtual result OnTerminating(void);
+ virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
+
+protected:
+ static const int ID_BUTTON_XMLReader = 102;
+ static const int ID_BUTTON_HTMLParser = 103;
+ static const int ID_BUTTON_XMLParser = 104;
+ static const int ID_BUTTON_XMLWriter = 105;
+
+private:
+ static const int BUTTON_LEFT_RIGHT_MARGIN = 128;
+ static const int BUTTON_TOP_MARGIN = 112;
+ static const int BUTTON_BOTTOM_MARGIN = 38;
+ static const int BUTTON_WIDTH = 480;
+ static const int BUTTON_HEIGHT = 74;
+};
+
+#endif //_MAINLISTFORM_H_
diff --git a/project/inc/XmlParser.h b/project/inc/XmlParser.h
new file mode 100755
index 0000000..2c137f9
--- /dev/null
+++ b/project/inc/XmlParser.h
@@ -0,0 +1,83 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 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://www.tizenopensource.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 _XML_PARSER_H_
+#define _XML_PARSER_H_
+
+#include <FBase.h>
+#include <FUi.h>
+
+class XmlParser
+ : public Tizen::Ui::Controls::Form
+ , public Tizen::Ui::Controls::IListViewItemEventListener
+ , public Tizen::Ui::Controls::IListViewItemProvider
+ , public Tizen::Ui::IActionEventListener
+ , public Tizen::Ui::Controls::IFormBackEventListener
+{
+public:
+ XmlParser(void);
+ virtual ~XmlParser(void);
+ bool Initialize(void);
+
+ virtual result OnInitializing(void);
+ virtual result OnTerminating(void);
+
+ result SAXParse(void);
+ result SAXParseMemory(void);
+
+ //IActionEventListener
+ virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
+
+ // IListViewItemEventListener
+ virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state);
+ virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status);
+ virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction);
+
+ //IListViewItemProvider
+ virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth);
+ virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth);
+ virtual int GetItemCount(void);
+
+ //IFormBackEventListener
+ virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source);
+
+ bool IsFound(void){ return __found;}
+ bool IsCheckContent(void){ return __checkContent;}
+ bool IsPrintCapital(void){ return __printCapital;}
+ void SetFound(bool found){ __found = found;}
+ void SetCheckContent(bool checkContent){ __checkContent = checkContent;}
+ void SetPrintCapital(bool printCapital){ __printCapital = printCapital;}
+
+private:
+ static const int LABEL_WIDTH = 330;
+ static const int LABEL_HEIGHT = 96;
+ static const int LABEL_BOTTOM_MARGIN = 64;
+
+ static const int LIST_HEIGHT = 640;
+
+ static const int ITEM_HEIGHT = 112;
+
+ bool __found;
+ bool __checkContent;
+ bool __printCapital;
+ Tizen::Ui::Controls::ListView* __pList;
+ Tizen::Base::Collection::ArrayList* __pItemList;
+ Tizen::Ui::Controls::Label* __pLabel;
+ Tizen::Base::String __filePath;
+ Tizen::Base::ByteBuffer* __pPath;
+};
+
+#endif //_XML_PARSER_H_
diff --git a/project/inc/XmlParserApp.h b/project/inc/XmlParserApp.h
new file mode 100644
index 0000000..f9de4c7
--- /dev/null
+++ b/project/inc/XmlParserApp.h
@@ -0,0 +1,74 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 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://www.tizenopensource.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 _XML_PARSER_APP_H_
+#define _XML_PARSER_APP_H_
+
+#include <FApp.h>
+#include <FBase.h>
+#include <FSystem.h>
+#include <FUi.h>
+
+/**
+ * [XmlParserApp] application must inherit from Application class
+ * which provides basic features necessary to define an application.
+ */
+class XmlParserApp
+ : public Tizen::App::Application
+ , public Tizen::System::IScreenEventListener
+{
+public:
+ /**
+ * [XmlParserApp] application must have a factory method that creates an instance of itself.
+ */
+ static Tizen::App::Application* CreateInstance(void);
+
+
+public:
+ XmlParserApp(void);
+ ~XmlParserApp(void);
+
+
+public:
+ // Called when the application is initializing.
+ virtual bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry);
+
+ // Called when the application is terminating.
+ virtual bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false);
+
+
+ // Called when the application's frame moves to the top of the screen.
+ virtual void OnForeground(void);
+
+
+ // Called when this application's frame is moved from top of the screen to the background.
+ virtual void OnBackground(void);
+
+ // Called when the system memory is not sufficient to run the application any further.
+ virtual void OnLowMemory(void);
+
+ // Called when the battery level changes.
+ virtual void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel);
+
+ // Called when the screen turns on.
+ virtual void OnScreenOn(void);
+
+ // Called when the screen turns off.
+ virtual void OnScreenOff(void);
+};
+
+#endif //_XML_PARSER_APP_H_
diff --git a/project/inc/XmlReader.h b/project/inc/XmlReader.h
new file mode 100755
index 0000000..39537af
--- /dev/null
+++ b/project/inc/XmlReader.h
@@ -0,0 +1,70 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 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://www.tizenopensource.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 _XML_READER_H_
+#define _XML_READER_H_
+
+#include <FBase.h>
+#include <FUi.h>
+#include <FUiCtrlForm.h>
+
+class XmlReader
+ : public Tizen::Ui::Controls::Form
+ , public Tizen::Ui::Controls::IListViewItemEventListener
+ , public Tizen::Ui::Controls::IListViewItemProvider
+ , public Tizen::Ui::IActionEventListener
+ , public Tizen::Ui::Controls::IFormBackEventListener
+{
+
+public:
+ XmlReader(void);
+ virtual ~XmlReader(void);
+ bool Initialize(void);
+
+ void XmlReaderRun(void);
+
+ virtual result OnInitializing(void);
+ virtual result OnTerminating(void);
+
+ //IActionEventListener
+ virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
+
+ // IListViewItemEventListener
+ virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state);
+ virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status);
+ virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction);
+
+ //IListViewItemProvider
+ virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth);
+ virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth);
+ virtual int GetItemCount(void);
+
+ //IFormBackEventListener
+ virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source);
+
+protected:
+ Tizen::Ui::Controls::ListView* _pList;
+ Tizen::Base::Collection::ArrayList* _pItemList;
+
+private:
+ static const int LIST_WIDTH = 720;
+ static const int LIST_HEIGHT = 640;
+
+ static const int ITEM_HEIGHT = 112;
+};
+
+#endif //_XML_READER_H_
diff --git a/project/inc/XmlWriter.h b/project/inc/XmlWriter.h
new file mode 100755
index 0000000..97fc9fd
--- /dev/null
+++ b/project/inc/XmlWriter.h
@@ -0,0 +1,72 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 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://www.tizenopensource.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 _XML_WRITER_H_
+#define _XML_WRITER_H_
+
+#include <FBase.h>
+#include <FUi.h>
+
+class XmlWriter
+ : public Tizen::Ui::Controls::Form
+ , public Tizen::Ui::Controls::IListViewItemEventListener
+ , public Tizen::Ui::Controls::IListViewItemProvider
+ , public Tizen::Ui::IActionEventListener
+ , public Tizen::Ui::Controls::IFormBackEventListener
+{
+
+public:
+ XmlWriter(void);
+ virtual ~XmlWriter(void);
+ bool Initialize(void);
+
+ result RunXMLWrite(void);
+ void RunXMLParseandDisplay(void);
+ virtual result OnInitializing(void);
+ virtual result OnTerminating(void);
+
+ //IActionEventListener
+ virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
+
+ // IListViewItemEventListener
+ virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state);
+ virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status);
+ virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction);
+
+ //IFormBackEventListener
+ virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source);
+
+ //IListViewItemProvider
+ virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth);
+ virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth);
+ virtual int GetItemCount(void);
+
+protected:
+ Tizen::Ui::Controls::ListView* _pList;
+ Tizen::Base::Collection::ArrayList* _pItemList;
+ static const int ID_BUTTON_WRITE = 905;
+
+private:
+ static const int LIST_WIDTH = 720;
+ static const int LIST_HEIGHT = 640;
+
+ static const int ITEM_HEIGHT = 112;
+
+ bool __display;
+};
+
+#endif //_XML_WRITER_H_
diff --git a/project/manifest.xml b/project/manifest.xml
new file mode 100644
index 0000000..1f16b7d
--- /dev/null
+++ b/project/manifest.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<Manifest xmlns="http://schemas.tizen.org/2012/12/manifest">
+ <Id>$(manifestAppId)</Id>
+ <Version>1.0.0</Version>
+ <Type>C++App</Type>
+ <Author/>
+ <Descriptions>
+ <Description Locale="eng-GB"/>
+ </Descriptions>
+ <Requirements>
+ <Feature Name="http://tizen.org/feature/platform.core.cpu.arch">x86</Feature>
+ <Feature Name="http://tizen.org/feature/platform.core.fpu.arch">vfpv3</Feature>
+ </Requirements>
+ <Apps>
+ <ApiVersion>2.0</ApiVersion>
+ <Privileges/>
+ <UiApp Main="True" MenuIconVisible="True" Name="$(projectName)">
+ <UiScalability BaseScreenSize="Normal" CoordinateSystem="Logical" LogicalCoordinate="720"/>
+ <UiTheme SystemTheme="White"/>
+ <DisplayNames>
+ <DisplayName Locale="eng-GB">$(projectName)</DisplayName>
+ </DisplayNames>
+ <Icons>
+ <Icon Section="MainMenu" Type="Xhigh">mainmenu.png</Icon>
+ </Icons>
+ <LaunchConditions/>
+ <Notifications/>
+ </UiApp>
+ </Apps>
+</Manifest>
diff --git a/project/res/eng-GB.xml b/project/res/eng-GB.xml
new file mode 100755
index 0000000..08a9a95
--- /dev/null
+++ b/project/res/eng-GB.xml
@@ -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.v20110311" Dversion="20100701"/>
diff --git a/project/res/screen-size-normal/IDF_FORM1.xml b/project/res/screen-size-normal/IDF_FORM1.xml
new file mode 100755
index 0000000..7f4862a
--- /dev/null
+++ b/project/res/screen-size-normal/IDF_FORM1.xml
@@ -0,0 +1,24 @@
+<?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="2.0.0.v20110311" Dversion="20100701">
+ <Form id="IDF_FORM1">
+ <property BGColor="" BGColorOpacity="100" Orientation="Automatic" softKey0NormalIcon="" softKey0PressedIcon="" softKey0Text="" softKey1NormalIcon="" softKey1PressedIcon="" softKey1Text="" title="Hello Tizen!" titleAlign="ALIGN_LEFT" titleIcon="" translucentFooter="FALSE" translucentHeader="FALSE" translucentIndicator="FALSE"/>
+ <layout mode="Portrait" style="FORM_STYLE_TITLE|FORM_STYLE_INDICATOR"/>
+ <layout mode="Landscape" style="FORM_STYLE_TITLE|FORM_STYLE_INDICATOR"/>
+ </Form>
+ <Footer>
+ <property BGBitmapPath="" 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="" selectedItemColor="" selectedItemColorOpacity="0" selectedItemTextColor=""/>
+ </Footer>
+ <Header>
+ <property BGBitmapPath="" 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="" selectedItemColor="" selectedItemColorOpacity="0" selectedItemTextColor="" titleIconPath="" titleText="" titleTextColor=""/>
+ </Header>
+ <Button id="IDC_BUTTON_OK" parent="IDF_FORM1">
+ <property NormalBGBitmapPath="" PressedBGBitmapPath="" disableTextColor="" hAlign="ALIGN_CENTER" normalTextColor="" pressedTextColor="" text="OK" vAlign="ALIGN_MIDDLE"/>
+ <layout height="91" mode="Portrait" width="241" x="120" y="236"/>
+ <layout height="103" mode="Landscape" width="401" x="200" y="108"/>
+ </Button>
+</Scene>
diff --git a/project/shared/data/nofile.dummy b/project/shared/data/nofile.dummy
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/project/shared/data/nofile.dummy
diff --git a/project/shared/res/screen-density-xhigh/mainmenu.png b/project/shared/res/screen-density-xhigh/mainmenu.png
new file mode 100755
index 0000000..983c883
--- /dev/null
+++ b/project/shared/res/screen-density-xhigh/mainmenu.png
Binary files differ
diff --git a/project/shared/trusted/nofile.dummy b/project/shared/trusted/nofile.dummy
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/project/shared/trusted/nofile.dummy
diff --git a/project/src/FormFactory.cpp b/project/src/FormFactory.cpp
new file mode 100644
index 0000000..5baded5
--- /dev/null
+++ b/project/src/FormFactory.cpp
@@ -0,0 +1,63 @@
+/*
+ * FormFactory.cpp
+ *
+ * Created on: Sep 25, 2012
+ * Author: lsw2000.lee
+ */
+#include <FUi.h>
+#include "FormFactory.h"
+#include "MainListForm.h"
+#include "XmlReader.h"
+#include "HtmlParser.h"
+#include "XmlParser.h"
+#include "XmlWriter.h"
+
+using namespace Tizen::Ui::Controls;
+
+FormFactory::FormFactory() {
+ // TODO Auto-generated constructor stub
+
+}
+
+FormFactory::~FormFactory() {
+ // TODO Auto-generated destructor stub
+}
+
+Form*
+FormFactory::CreateFormN(const Tizen::Base::String &formId, const Tizen::Ui::Scenes::SceneId &sceneId)
+{
+ Form* pNewForm = null;
+
+ if (formId == L"MainListForm")
+ {
+ MainListForm* pForm = new (std::nothrow) MainListForm();
+ pForm->Initialize();
+ pNewForm = pForm;
+ }
+ else if (formId == L"XmlReaderForm")
+ {
+ XmlReader* pForm = new (std::nothrow) XmlReader();
+ pForm->Initialize();
+ pNewForm = pForm;
+ }
+ else if (formId == L"HtmlParserForm")
+ {
+ HtmlParser* pForm = new (std::nothrow) HtmlParser();
+ pForm->Initialize();
+ pNewForm = pForm;
+ }
+ else if (formId == L"XmlParserForm")
+ {
+ XmlParser* pForm = new (std::nothrow) XmlParser();
+ pForm->Initialize();
+ pNewForm = pForm;
+ }
+ else if (formId == L"XmlWriterForm")
+ {
+ XmlWriter* pForm = new (std::nothrow) XmlWriter();
+ pForm->Initialize();
+ pNewForm = pForm;
+ }
+
+ return pNewForm;
+}
diff --git a/project/src/HtmlParser.cpp b/project/src/HtmlParser.cpp
new file mode 100644
index 0000000..c3000e3
--- /dev/null
+++ b/project/src/HtmlParser.cpp
@@ -0,0 +1,203 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 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://www.tizenopensource.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 <FApp.h>
+#include <FBase.h>
+#include <FGraphics.h>
+#include <FIo.h>
+#include "HtmlParser.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Graphics;
+using namespace Tizen::Io;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+using namespace Tizen::Ui::Scenes;
+
+HtmlParser::HtmlParser(void)
+ : _pList(null)
+ , _pItemList(null)
+{
+}
+
+HtmlParser::~HtmlParser(void)
+{
+}
+
+bool
+HtmlParser::Initialize(void)
+{
+ Construct(FORM_STYLE_NORMAL | FORM_STYLE_HEADER | FORM_STYLE_FOOTER | FORM_STYLE_INDICATOR);
+ return true;
+}
+
+result
+HtmlParser::OnInitializing(void)
+{
+ result r = E_SUCCESS;
+ Rectangle clientRect = GetClientAreaBounds();
+ Header* pHeader = GetHeader();
+ pHeader->SetTitleText("HTML Parser");
+
+ Footer* pFooter = GetFooter();
+ pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
+ pFooter->SetBackButton();
+ SetFormBackEventListener(this);
+
+ _pList = new (std::nothrow) ListView();
+ _pList->Construct(Rectangle(0, 0, LIST_WIDTH, LIST_HEIGHT), true);
+ _pList->SetItemProvider(*this);
+ _pList->AddListViewItemEventListener(*this);
+ _pList->SetTextOfEmptyList(L"");
+ AddControl(*_pList);
+
+ _pItemList = new (std::nothrow) ArrayList();
+ _pItemList->Construct();
+
+ RunHtmlParser();
+
+ return r;
+}
+
+int
+HtmlParser::GetItemCount(void)
+{
+ TryReturn(_pItemList, 0, "_pItemList is null.");
+ return _pItemList->GetCount();
+}
+
+Tizen::Ui::Controls::ListItemBase*
+HtmlParser::CreateItem(int index, int itemWidth)
+{
+ ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
+ SimpleItem* pItem = new (std::nothrow) SimpleItem();
+
+ pItem->Construct(Tizen::Graphics::Dimension(itemWidth, ITEM_HEIGHT), style);
+ Tizen::Base::String* pKey = static_cast< String* >(_pItemList->GetAt(index));
+ TryReturn(pKey, null, "key is empty for index %d",index);
+
+ pItem->SetElement(*pKey, null);
+ return pItem;
+}
+
+bool
+HtmlParser::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
+{
+ delete pItem;
+ pItem = null;
+ return true;
+}
+
+
+void
+HtmlParser::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
+{
+}
+
+void
+HtmlParser::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
+{
+}
+
+void
+HtmlParser::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
+{
+}
+
+
+void
+HtmlParser::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
+{
+}
+
+void
+HtmlParser::RunHtmlParser(void)
+{
+ //Parse html file and build a tree
+ String filepath = App::GetInstance()->GetAppRootPath() + L"data/tizen.html";
+ ByteBuffer* pBuf = Tizen::Base::Utility::StringUtil::StringToUtf8N(filepath);
+ TryReturnVoid(pBuf, "StringToUtf8N failed.");
+
+ htmlNodePtr pRoot =null;
+ htmlDocPtr pDoc = htmlParseFile((const char*) pBuf->GetPointer(), (const char*) "utf-8");
+ TryCatch(pDoc, , "htmlParseFile failed.");
+
+ //Get the root element of the document
+ pRoot = xmlDocGetRootElement(pDoc);
+ TryCatch(pRoot, xmlFreeDoc(pDoc), "xmlDocGetRootElement failed.");
+
+ ExtractHyperLinks(pRoot);
+ _pList->UpdateList();
+ xmlFreeDoc(pDoc);
+
+CATCH:
+ delete pBuf;
+}
+
+/* this functions extracts links present in HTML file and displays*/
+void
+HtmlParser::ExtractHyperLinks(htmlNodePtr pRoot)
+{
+ xmlNodePtr pCurrentElement = null;
+ xmlAttrPtr attr = null;
+
+ for (pCurrentElement = pRoot; pCurrentElement; pCurrentElement = pCurrentElement->next)
+ {
+ if (pCurrentElement->type != XML_ELEMENT_NODE)
+ {
+ continue;
+ }
+ if (xmlStrcasecmp(pCurrentElement->name, (const xmlChar*) "A") == 0)
+ {
+ for (attr = pCurrentElement->properties; attr != null; attr = attr->next)
+ {
+ if (xmlStrcasecmp(attr->name, (const xmlChar*) "HREF") == 0)
+ {
+ String* nodeName = new (std::nothrow) String;
+ Tizen::Base::Utility::StringUtil::Utf8ToString((char*) pCurrentElement->children->content, *nodeName);
+ _pItemList->Add(*nodeName);
+ }
+ }
+ }
+ if (pCurrentElement->children != null)
+ {
+ ExtractHyperLinks(pCurrentElement->children);
+ }
+ }
+}
+
+result
+HtmlParser::OnTerminating(void)
+{
+ if (_pItemList)
+ {
+ _pItemList->RemoveAll(true);
+ delete _pItemList;
+ _pItemList = null;
+ }
+
+ return E_SUCCESS;
+}
+
+void
+HtmlParser::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
+{
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+ pSceneManager->GoBackward(BackwardSceneTransition());
+}
diff --git a/project/src/MainListForm.cpp b/project/src/MainListForm.cpp
new file mode 100755
index 0000000..e1ec1d0
--- /dev/null
+++ b/project/src/MainListForm.cpp
@@ -0,0 +1,112 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 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://www.tizenopensource.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 <FApp.h>
+#include "MainListForm.h"
+#include "XmlReader.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Graphics;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+using namespace Tizen::Ui::Scenes;
+
+MainListForm::MainListForm(void)
+{
+}
+
+MainListForm::~MainListForm(void)
+{
+}
+
+bool
+MainListForm::Initialize(void)
+{
+ Construct(FORM_STYLE_NORMAL | FORM_STYLE_HEADER | FORM_STYLE_INDICATOR);
+ return true;
+}
+
+result
+MainListForm::OnInitializing(void)
+{
+ result r = E_SUCCESS;
+
+ Header* pHeader = GetHeader();
+ pHeader->SetTitleText("XML PARSER APP");
+
+ //For xmlreader
+ Button* pXmlReader = new (std::nothrow) Button();
+ pXmlReader->Construct(Rectangle(BUTTON_LEFT_RIGHT_MARGIN, BUTTON_TOP_MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT), L"XML Reader");
+ pXmlReader->AddActionEventListener(*this);
+ pXmlReader->SetActionId(ID_BUTTON_XMLReader);
+ AddControl(*pXmlReader);
+
+ //For htmlparser
+ Button* pHtmlParser = new (std::nothrow) Button();
+ pHtmlParser->Construct(Rectangle(BUTTON_LEFT_RIGHT_MARGIN, BUTTON_TOP_MARGIN + ( BUTTON_HEIGHT + BUTTON_BOTTOM_MARGIN ), BUTTON_WIDTH, BUTTON_HEIGHT), L"HTML Parser");
+ pHtmlParser->AddActionEventListener(*this);
+ pHtmlParser->SetActionId(ID_BUTTON_HTMLParser);
+ AddControl(*pHtmlParser);
+
+ //For xmlparser
+ Button* pXmlParser = new (std::nothrow) Button();
+ pXmlParser->Construct(Rectangle(BUTTON_LEFT_RIGHT_MARGIN, BUTTON_TOP_MARGIN + 2 * ( BUTTON_HEIGHT + BUTTON_BOTTOM_MARGIN ), BUTTON_WIDTH, BUTTON_HEIGHT), L"XML Parser");
+ pXmlParser->AddActionEventListener(*this);
+ pXmlParser->SetActionId(ID_BUTTON_XMLParser);
+ AddControl(*pXmlParser);
+
+ //For xmlwriter
+ Button* pXmlWriter = new (std::nothrow) Button();
+ pXmlWriter->Construct(Rectangle(BUTTON_LEFT_RIGHT_MARGIN, BUTTON_TOP_MARGIN + 3 * ( BUTTON_HEIGHT + BUTTON_BOTTOM_MARGIN ), BUTTON_WIDTH, BUTTON_HEIGHT), L"XML Writer");
+ pXmlWriter->AddActionEventListener(*this);
+ pXmlWriter->SetActionId(ID_BUTTON_XMLWriter);
+ AddControl(*pXmlWriter);
+ return r;
+}
+
+result
+MainListForm::OnTerminating(void)
+{
+ result r = E_SUCCESS;
+ return r;
+}
+
+void
+MainListForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
+{
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+ AppAssert(pSceneManager);
+
+ switch (actionId)
+ {
+ case ID_BUTTON_XMLReader:
+ pSceneManager->GoForward(ForwardSceneTransition(L"XmlReaderScene"));
+ break;
+ case ID_BUTTON_HTMLParser:
+ pSceneManager->GoForward(ForwardSceneTransition(L"HtmlParserScene"));
+ break;
+ case ID_BUTTON_XMLParser:
+ pSceneManager->GoForward(ForwardSceneTransition(L"XmlParserScene"));
+ break;
+ case ID_BUTTON_XMLWriter:
+ pSceneManager->GoForward(ForwardSceneTransition(L"XmlWriterScene"));
+ break;
+ default:
+ break;
+ }
+}
diff --git a/project/src/XmlParser.cpp b/project/src/XmlParser.cpp
new file mode 100644
index 0000000..8ebb748
--- /dev/null
+++ b/project/src/XmlParser.cpp
@@ -0,0 +1,511 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 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://www.tizenopensource.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 <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xmlstring.h>
+#include <libxml/xpath.h>
+#include <FApp.h>
+#include <FBase.h>
+#include <FGraphics.h>
+#include <FIo.h>
+#include "XmlParser.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Graphics;
+using namespace Tizen::Io;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+using namespace Tizen::Ui::Scenes;
+
+xmlParserInputPtr ResolveEntitySAXFunc(void* ctx, const xmlChar* publicId, const xmlChar* systemId);
+void InternalSubsetSAXFunc(void* ctx, const xmlChar* name, const xmlChar* ExternalID, const xmlChar* SystemID);
+void ExternalSubsetSAXFunc(void* ctx, const xmlChar* name, const xmlChar* ExternalID, const xmlChar* SystemID);
+xmlEntityPtr GetEntitySAXFunc(void* ctx, const xmlChar* name);
+xmlEntityPtr GetParameterEntitySAXFunc(void* ctx, const xmlChar* name);
+void EntityDeclSAXFunc(void* ctx, const xmlChar* name, int type, const xmlChar* publicId, const xmlChar* systemId, xmlChar* content);
+void NotationDeclSAXFunc(void* ctx, const xmlChar* name, const xmlChar* publicId, const xmlChar* systemId);
+void AttributeDeclSAXFunc(void* ctx, const xmlChar* elem, const xmlChar* fullname, int type, int def, const xmlChar* defaultValue, xmlEnumerationPtr tree);
+void ElementDeclSAXFunc(void* ctx, const xmlChar* name, int type, xmlElementContentPtr content);
+void UnparsedEntityDeclSAXFunc(void* ctx, const xmlChar* name, const xmlChar* publicId, const xmlChar* systemId, const xmlChar* notationName);
+void SetDocumentLocatorSAXFunc(void* ctx, xmlSAXLocatorPtr loc);
+void StartDocumentSAXFunc(void* ctx);
+void EndDocumentSAXFunc(void* ctx);
+void StartElementSAXFunc(void* ctx, const xmlChar* name, const xmlChar** atts);
+void EndElementSAXFunc(void* ctx, const xmlChar* name);
+void AttributeSAXFunc(void* ctx, const xmlChar* name, const xmlChar* value);
+void ReferenceSAXFunc(void* ctx, const xmlChar* name);
+void CharactersSAXFunc(void* ctx, const xmlChar* ch, int len);
+void IgnorableWhitespaceSAXFunc(void* ctx, const xmlChar* ch, int len);
+void ProcessingInstructionSAXFunc(void* ctx, const xmlChar* target, const xmlChar* data);
+void CommentSAXFunc(void* ctx, const xmlChar* value);
+void CdataBlockSAXFunc(void* ctx, const xmlChar* value, int len);
+void WarningSAXFunc(void* ctx, const char* msg, ...);
+void ErrorSAXFunc(void* ctx, const char* msg, ...);
+void FatalErrorSAXFunc(void* ctx, const char* msg, ...);
+int IsStandaloneSAXFunc(void* ctx);
+int HasInternalSubsetSAXFunc(void* ctx);
+int HasExternalSubsetSAXFunc(void* ctx);
+
+
+xmlSAXHandler mySaxHandler =
+{
+InternalSubsetSAXFunc,
+IsStandaloneSAXFunc,
+HasInternalSubsetSAXFunc,
+HasExternalSubsetSAXFunc,
+ResolveEntitySAXFunc,
+GetEntitySAXFunc,
+EntityDeclSAXFunc,
+NotationDeclSAXFunc,
+AttributeDeclSAXFunc,
+ElementDeclSAXFunc,
+UnparsedEntityDeclSAXFunc,
+SetDocumentLocatorSAXFunc,
+StartDocumentSAXFunc,
+EndDocumentSAXFunc,
+StartElementSAXFunc,
+EndElementSAXFunc,
+ReferenceSAXFunc,
+CharactersSAXFunc,
+IgnorableWhitespaceSAXFunc,
+ProcessingInstructionSAXFunc,
+CommentSAXFunc,
+WarningSAXFunc,
+ErrorSAXFunc,
+FatalErrorSAXFunc,
+GetParameterEntitySAXFunc,
+CdataBlockSAXFunc,
+ExternalSubsetSAXFunc,
+0,
+null,
+null,
+null,
+null
+};
+
+XmlParser::XmlParser(void)
+ : __found(false)
+ , __checkContent(false)
+ , __printCapital(false)
+ , __pList(null)
+ , __pItemList(null)
+ , __pLabel(null)
+ , __pPath(null)
+{
+}
+
+XmlParser::~XmlParser(void)
+{
+ delete __pPath;
+}
+
+bool
+XmlParser::Initialize(void)
+{
+ Construct(FORM_STYLE_NORMAL | FORM_STYLE_HEADER | FORM_STYLE_FOOTER | FORM_STYLE_INDICATOR);
+ return true;
+}
+
+result
+XmlParser::OnInitializing(void)
+{
+ Rectangle clientRect = GetClientAreaBounds();
+ Header* pHeader = GetHeader();
+ pHeader->SetTitleText("XML Parser");
+ result r = E_FAILURE;
+
+ Footer* pFooter = GetFooter();
+ pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
+ pFooter->SetBackButton();
+ SetFormBackEventListener(this);
+
+ __pLabel = new Label();
+ __pLabel->Construct(Rectangle((clientRect.width - LABEL_WIDTH) / 2, clientRect.height - LABEL_BOTTOM_MARGIN - LABEL_HEIGHT, LABEL_WIDTH, LABEL_HEIGHT), L"");
+ AddControl(*__pLabel);
+
+ // Create xml document
+ __filePath = App::GetInstance()->GetAppRootPath() + L"data/map.xml";
+ __pPath = Tizen::Base::Utility::StringUtil::StringToUtf8N(__filePath);
+ TryReturn(__pPath, GetLastResult(), "Path conversion failed.");
+
+ xmlDocPtr pDocument = xmlParseFile((const char*) __pPath->GetPointer());
+ TryReturn(pDocument, E_FAILURE, "xmlDocPtr conversion failed.");
+
+ xmlNodePtr pRoot = xmlDocGetRootElement(pDocument);
+ TryCatch(pRoot, , "xmlNodePtr conversion failed.");
+
+ __pList = new ListView();
+ __pList->Construct(Rectangle(0, 0, clientRect.width, LIST_HEIGHT), true);
+ __pList->SetItemProvider(*this);
+ __pList->AddListViewItemEventListener(*this);
+ __pList->SetTextOfEmptyList(L"");
+ AddControl(*__pList);
+
+ __pItemList = new ArrayList();
+ __pItemList->Construct();
+
+ for (xmlNodePtr pCurrentElement = pRoot->children; pCurrentElement; pCurrentElement = pCurrentElement->next)
+ {
+ xmlNodePtr pChildElement = null;
+
+ if (pCurrentElement->type == XML_ELEMENT_NODE)
+ {
+ // Get <country> element from <item> element
+ pChildElement = pCurrentElement->children->next;
+
+ if (pChildElement)
+ {
+ String* countryName = new String;
+ // Get content from XML_TEXT_NODE
+ Tizen::Base::Utility::StringUtil::Utf8ToString((char*) pChildElement->children->content, *countryName);
+ __pItemList->Add(*countryName);
+ AppLog("country : %ls\n", (*countryName).GetPointer());
+ }
+ }
+ }
+ __pList->UpdateList();
+ r = E_SUCCESS;
+
+CATCH:
+ xmlFreeDoc(pDocument);
+ return r;
+}
+
+void
+XmlParser::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
+{
+ String key(L"/map/item[]/capital");
+ ByteBuffer* pExpr = null;
+ String capital;
+
+ xmlDocPtr pDocument = null;
+ xmlXPathContextPtr pXpathCtx = null;
+ xmlXPathObjectPtr pXpathObj = null;
+ xmlChar* pContent = null;
+
+ // Create xml document
+ pDocument = xmlParseFile((const char*) __pPath->GetPointer());
+
+ // Create xpath context
+ pXpathCtx = xmlXPathNewContext(pDocument);
+
+ key.Insert(index + 1, 10);
+ // Get an element
+ pExpr = Tizen::Base::Utility::StringUtil::StringToUtf8N(key);
+ pXpathObj = xmlXPathEvalExpression((xmlChar*) pExpr->GetPointer(), pXpathCtx);
+ delete pExpr;
+
+ pContent = pXpathObj->nodesetval->nodeTab[0]->children->content;
+ Tizen::Base::Utility::StringUtil::Utf8ToString((char*) pContent, capital);
+
+ // Clean up
+ xmlXPathFreeObject(pXpathObj);
+ xmlXPathFreeContext(pXpathCtx);
+ xmlFreeDoc(pDocument);
+
+ __pLabel->SetText(capital);
+
+ __pLabel->Draw();
+}
+
+void
+XmlParser::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
+{
+
+}
+
+void
+XmlParser::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
+{
+
+}
+
+int
+XmlParser::GetItemCount(void)
+{
+ TryReturn(__pItemList, 0, "__pItemList is null");
+ return __pItemList->GetCount();
+}
+
+Tizen::Ui::Controls::ListItemBase*
+XmlParser::CreateItem(int index, int itemWidth)
+{
+ ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
+ SimpleItem* pItem = new SimpleItem();
+
+ pItem->Construct(Tizen::Graphics::Dimension(itemWidth, ITEM_HEIGHT), style);
+ Tizen::Base::String* pKey = static_cast< String* >(__pItemList->GetAt(index));
+
+ TryReturn(pKey, null, "Key value is empty for %d", index);
+ pItem->SetElement(*pKey, null);
+ return pItem;
+}
+
+bool
+XmlParser::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
+{
+ delete pItem;
+ pItem = null;
+ return true;
+}
+
+result
+XmlParser::OnTerminating(void)
+{
+ result r = E_SUCCESS;
+ if (__pItemList)
+ {
+ __pItemList->RemoveAll(true);
+ delete __pItemList;
+ __pItemList = null;
+ }
+
+ // TODO: Add your termination code here
+
+ return r;
+}
+
+result
+XmlParser::SAXParse(void)
+{
+ xmlSAXHandlerPtr pMySaxhandler = &mySaxHandler;
+ __found = false;
+ __checkContent = false;
+ __printCapital = false;
+
+ xmlSAXUserParseFile(pMySaxhandler, null, (const char*) __pPath->GetPointer());
+
+ return E_SUCCESS;
+}
+
+
+result
+XmlParser::SAXParseMemory(void)
+{
+ xmlDocPtr pDoc = null;
+ result r = E_SUCCESS;
+ File file;
+ FileAttributes fileAttribute;
+ ByteBuffer buffer;
+
+ r = File::GetAttributes(__filePath, fileAttribute);
+ TryCatch(r == E_SUCCESS, , "Fail to get file attribute");
+
+ r = buffer.Construct((int) fileAttribute.GetFileSize());
+ TryCatch(r == E_SUCCESS, , "Fail to construct buffer");
+
+ r = file.Construct(__filePath, L"r");
+ r = file.Read(buffer);
+ TryCatch(r == E_SUCCESS, , "Fail to read file");
+
+ pDoc = xmlSAXParseMemory(null, (const char*) (buffer.GetPointer()), (int) fileAttribute.GetFileSize(), 0);
+ TryCatch(pDoc != null, , "document is null");
+
+ return E_SUCCESS;
+
+CATCH:
+ return E_FAILURE;
+}
+
+xmlParserInputPtr
+ResolveEntitySAXFunc(void* ctx, const xmlChar* publicId, const xmlChar* systemId)
+{
+ return null;
+}
+
+void
+InternalSubsetSAXFunc(void* ctx, const xmlChar* name, const xmlChar* ExternalID, const xmlChar* SystemID)
+{
+}
+
+void
+ExternalSubsetSAXFunc(void* ctx, const xmlChar* name, const xmlChar* ExternalID, const xmlChar* SystemID)
+{
+}
+
+xmlEntityPtr
+GetEntitySAXFunc(void* ctx, const xmlChar* name)
+{
+ return null;
+}
+
+xmlEntityPtr
+GetParameterEntitySAXFunc(void* ctx, const xmlChar* name)
+{
+ return null;
+}
+
+void
+EntityDeclSAXFunc(void* ctx, const xmlChar* name, int type, const xmlChar* publicId, const xmlChar* systemId, xmlChar* content)
+{
+}
+
+void
+NotationDeclSAXFunc(void* ctx, const xmlChar* name, const xmlChar* publicId, const xmlChar* systemId)
+{
+}
+
+void
+AttributeDeclSAXFunc(void* ctx, const xmlChar* elem, const xmlChar* fullname, int type, int def, const xmlChar* defaultValue, xmlEnumerationPtr tree)
+{
+}
+
+void
+ElementDeclSAXFunc(void* ctx, const xmlChar* name, int type, xmlElementContentPtr content)
+{
+}
+
+void
+UnparsedEntityDeclSAXFunc(void* ctx, const xmlChar* name, const xmlChar* publicId, const xmlChar* systemId, const xmlChar* notationName)
+{
+}
+
+void
+SetDocumentLocatorSAXFunc(void* ctx, xmlSAXLocatorPtr loc)
+{
+}
+
+void
+StartDocumentSAXFunc(void* ctx)
+{
+
+}
+
+void
+EndDocumentSAXFunc(void* ctx)
+{
+}
+
+void
+StartElementSAXFunc(void* ctx, const xmlChar* name, const xmlChar** atts)
+{
+ XmlParser* pXmlParser = static_cast< XmlParser* >(ctx);
+ if (xmlStrcmp(name, (xmlChar*) "country") == 0)
+ {
+ pXmlParser->SetCheckContent(true);
+ }
+ else if (xmlStrcmp(name, (xmlChar*) "capital") == 0)
+ {
+ pXmlParser->SetPrintCapital(true);
+ }
+ else
+ {
+ pXmlParser->SetCheckContent(false);
+ pXmlParser->SetPrintCapital(false);
+ }
+}
+
+void
+EndElementSAXFunc(void* ctx, const xmlChar* name)
+{
+}
+
+void
+AttributeSAXFunc(void* ctx, const xmlChar* name, const xmlChar* value)
+{
+}
+
+void
+ReferenceSAXFunc(void* ctx, const xmlChar* name)
+{
+}
+
+void
+CharactersSAXFunc(void* ctx, const xmlChar* ch, int len)
+{
+ XmlParser* pXmlParser = static_cast< XmlParser* >(ctx);
+ if (pXmlParser->IsCheckContent())
+ {
+ if (xmlStrncmp(ch, (xmlChar*) "Ghana", len) == 0)
+ {
+ pXmlParser->SetFound(true);
+ }
+ }
+ if (pXmlParser->IsFound() && pXmlParser->IsPrintCapital())
+ {
+ AppLog("The capital of Chana is %ls\n", ch);
+ }
+}
+
+void
+IgnorableWhitespaceSAXFunc(void* ctx, const xmlChar* ch, int len)
+{
+}
+
+void
+ProcessingInstructionSAXFunc(void* ctx, const xmlChar* target, const xmlChar* data)
+{
+}
+
+void
+CommentSAXFunc(void* ctx, const xmlChar* value)
+{
+}
+
+void
+CdataBlockSAXFunc(void* ctx, const xmlChar* value, int len)
+{
+}
+
+void
+WarningSAXFunc(void* ctx, const char* msg, ...)
+{
+}
+
+void
+ErrorSAXFunc(void* ctx, const char* msg, ...)
+{
+}
+
+void
+FatalErrorSAXFunc(void* ctx, const char* msg, ...)
+{
+}
+
+int
+IsStandaloneSAXFunc(void* ctx)
+{
+ return 1;
+}
+
+int
+HasInternalSubsetSAXFunc(void* ctx)
+{
+ return 0;
+}
+
+
+int
+HasExternalSubsetSAXFunc(void* ctx)
+{
+ return 0;
+}
+
+void
+XmlParser::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
+{
+}
+
+void
+XmlParser::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
+{
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+ pSceneManager->GoBackward(BackwardSceneTransition());
+}
diff --git a/project/src/XmlParserApp.cpp b/project/src/XmlParserApp.cpp
new file mode 100644
index 0000000..cc3408b
--- /dev/null
+++ b/project/src/XmlParserApp.cpp
@@ -0,0 +1,103 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 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://www.tizenopensource.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 "XmlParserApp.h"
+#include "MainListForm.h"
+#include "XmlReader.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;
+
+XmlParserApp::XmlParserApp(void)
+{
+}
+
+XmlParserApp::~XmlParserApp(void)
+{
+}
+
+Application*
+XmlParserApp::CreateInstance(void)
+{
+ return new XmlParserApp();
+}
+
+bool
+XmlParserApp::OnAppInitializing(AppRegistry& appRegistry)
+{
+ Frame* pAppFrame = new Frame();
+ pAppFrame->Construct();
+ AddFrame(*pAppFrame);
+
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+ AppAssert(pSceneManager);
+ static FormFactory formFactory;
+ pSceneManager->RegisterFormFactory(formFactory);
+ pSceneManager->RegisterScene(L"MainListScene", L"MainListForm", L"");
+ pSceneManager->RegisterScene(L"XmlReaderScene", L"XmlReaderForm", L"");
+ pSceneManager->RegisterScene(L"HtmlParserScene", L"HtmlParserForm", L"");
+ pSceneManager->RegisterScene(L"XmlParserScene", L"XmlParserForm", L"");
+ pSceneManager->RegisterScene(L"XmlWriterScene", L"XmlWriterForm", L"");
+
+ if (pSceneManager->GoForward(ForwardSceneTransition(L"MainListScene")) != E_SUCCESS)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+bool
+XmlParserApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
+{
+ return true;
+}
+
+void
+XmlParserApp::OnForeground(void)
+{
+}
+
+void
+XmlParserApp::OnBackground(void)
+{
+}
+
+void
+XmlParserApp::OnLowMemory(void)
+{
+}
+
+void
+XmlParserApp::OnBatteryLevelChanged(BatteryLevel batteryLevel)
+{
+}
+
+void
+XmlParserApp::OnScreenOn(void)
+{
+}
+
+void
+XmlParserApp::OnScreenOff(void)
+{
+}
diff --git a/project/src/XmlParserAppEntry.cpp b/project/src/XmlParserAppEntry.cpp
new file mode 100644
index 0000000..3170902
--- /dev/null
+++ b/project/src/XmlParserAppEntry.cpp
@@ -0,0 +1,60 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 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://www.tizenopensource.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.
+//
+
+/**
+ * This file contains the Tizen C++ application entry point.
+ */
+#include "XmlParserApp.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 C++ 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(XmlParserApp::CreateInstance, &args);
+ TryLog(r == E_SUCCESS, "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/XmlReader.cpp b/project/src/XmlReader.cpp
new file mode 100644
index 0000000..b8d993f
--- /dev/null
+++ b/project/src/XmlReader.cpp
@@ -0,0 +1,201 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 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://www.tizenopensource.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 <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xmlstring.h>
+#include <libxml/xmlreader.h>
+#include <FApp.h>
+#include <FBase.h>
+#include <FGraphics.h>
+#include <FIo.h>
+#include "XmlReader.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Graphics;
+using namespace Tizen::Io;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+using namespace Tizen::Ui::Scenes;
+
+XmlReader::XmlReader(void)
+ : _pList(null)
+ , _pItemList(null)
+{
+}
+
+XmlReader::~XmlReader(void)
+{
+}
+
+bool
+XmlReader::Initialize(void)
+{
+ Construct(FORM_STYLE_NORMAL | FORM_STYLE_HEADER | FORM_STYLE_FOOTER | FORM_STYLE_INDICATOR);
+ return true;
+}
+
+void
+XmlReader::XmlReaderRun(void)
+{
+ int xmlreadType = 0;
+ int ret = 0;
+
+ //Create xml text reader
+ String filepath = App::GetInstance()->GetAppRootPath() + L"data/continents.xml";
+ ByteBuffer* pBuf = Tizen::Base::Utility::StringUtil::StringToUtf8N(filepath);
+ TryReturnVoid(pBuf, "ByteBuffer is null");
+
+ xmlTextReaderPtr reader = xmlReaderForFile((const char*) pBuf->GetPointer(), NULL, XML_PARSE_HUGE);
+ TryCatch(reader, , "xmlTextReaderPtr is null");
+ TryCatch(_pList, xmlFreeTextReader(reader), "_pList is null");
+
+ ret = xmlTextReaderRead(reader);
+ while (ret == 1)
+ {
+ const xmlChar* value = null;
+ const xmlChar* name = xmlTextReaderConstName(reader); //read node name
+ if (xmlTextReaderHasValue(reader))
+ {
+ value = xmlTextReaderConstValue(reader); //read value
+ }
+ xmlreadType = xmlTextReaderNodeType(reader); //read Node type
+
+ /* Ignore #Text node */
+ if (xmlStrcasecmp(name, (const xmlChar*) "#Text") != 0 && xmlreadType != XML_READER_TYPE_END_ELEMENT)
+ {
+ String* nodeName = new (std::nothrow) String; //Carries node name
+ Tizen::Base::Utility::StringUtil::Utf8ToString((char*) name, *nodeName);
+ _pItemList->Add(*nodeName);
+ }
+ /* Add value if node is not of type XML_READER_TYPE_SIGNIFICANT_WHITESPACE */
+ if ((xmlreadType != XML_READER_TYPE_SIGNIFICANT_WHITESPACE) && (value != null))
+ {
+ String* nodeValue = new (std::nothrow) String; //Carries node value
+ if (value != null)
+ {
+ Tizen::Base::Utility::StringUtil::Utf8ToString((char*) value, *nodeValue);
+ }
+ _pItemList->Add(*nodeValue);
+ }
+ ret = xmlTextReaderRead(reader);
+ }
+
+ _pList->UpdateList();
+ xmlFreeTextReader(reader);
+
+CATCH:
+ delete pBuf;
+}
+
+result
+XmlReader::OnInitializing(void)
+{
+ result r = E_SUCCESS;
+ Header* pHeader = GetHeader();
+ pHeader->SetTitleText("XML Reader");
+
+ Footer* pFooter = GetFooter();
+ pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
+ pFooter->SetBackButton();
+ SetFormBackEventListener(this);
+
+ _pList = new (std::nothrow) ListView();
+ _pList->Construct(Rectangle(0, 0, LIST_WIDTH, LIST_HEIGHT), true);
+ _pList->SetItemProvider(*this);
+ _pList->AddListViewItemEventListener(*this);
+ _pList->SetTextOfEmptyList(L"");
+ AddControl(*_pList);
+
+ _pItemList = new (std::nothrow) ArrayList();
+ _pItemList->Construct();
+
+ XmlReaderRun();
+
+ return r;
+}
+
+int
+XmlReader::GetItemCount(void)
+{
+ TryReturn(_pItemList, 0, "_pItemList is null");
+ return _pItemList->GetCount();
+}
+
+Tizen::Ui::Controls::ListItemBase*
+XmlReader::CreateItem(int index, int itemWidth)
+{
+ ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
+ SimpleItem* pItem = new (std::nothrow) SimpleItem();
+
+ pItem->Construct(Tizen::Graphics::Dimension(itemWidth, ITEM_HEIGHT), style);
+ Tizen::Base::String* key = static_cast< String* >(_pItemList->GetAt(index));
+ TryReturn(key, null, "Key value is empty for %d", index);
+
+ pItem->SetElement(*key, null);
+ return pItem;
+}
+
+bool
+XmlReader::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
+{
+ delete pItem;
+ pItem = null;
+ return true;
+}
+
+void
+XmlReader::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
+{
+}
+
+void
+XmlReader::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
+{
+}
+
+void
+XmlReader::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
+{
+}
+
+void
+XmlReader::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
+{
+}
+
+result
+XmlReader::OnTerminating(void)
+{
+ result r = E_SUCCESS;
+ if (_pItemList)
+ {
+ _pItemList->RemoveAll(true);
+ delete _pItemList;
+ _pItemList = null;
+ }
+ return r;
+}
+
+void
+XmlReader::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
+{
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+ pSceneManager->GoBackward(BackwardSceneTransition());
+}
diff --git a/project/src/XmlWriter.cpp b/project/src/XmlWriter.cpp
new file mode 100644
index 0000000..7e55235
--- /dev/null
+++ b/project/src/XmlWriter.cpp
@@ -0,0 +1,297 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 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://www.tizenopensource.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 <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xmlstring.h>
+#include <libxml/xmlwriter.h>
+#include <FApp.h>
+#include <FBase.h>
+#include <FGraphics.h>
+#include <FIo.h>
+#include "XmlWriter.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Graphics;
+using namespace Tizen::Io;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+using namespace Tizen::Ui::Scenes;
+
+XmlWriter::XmlWriter(void)
+ : _pList(null)
+ , _pItemList(null)
+ , __display(false)
+{
+}
+
+XmlWriter::~XmlWriter(void)
+{
+}
+
+bool
+XmlWriter::Initialize(void)
+{
+ Construct(FORM_STYLE_NORMAL | FORM_STYLE_FOOTER | FORM_STYLE_HEADER | FORM_STYLE_INDICATOR);
+ return true;
+}
+
+result
+XmlWriter::OnInitializing(void)
+{
+ result r = E_SUCCESS;
+ Header* pHeader = GetHeader();
+ pHeader->SetTitleText("XML Writer");
+
+ Footer* pFooter = GetFooter();
+ pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
+
+ FooterItem writeButton;
+ writeButton.Construct(ID_BUTTON_WRITE);
+ writeButton.SetText("Write");
+ pFooter->AddItem(writeButton);
+
+ pFooter->SetBackButton();
+ pFooter->AddActionEventListener(*this);
+ SetFormBackEventListener(this);
+
+ _pList = new (std::nothrow) ListView();
+ _pList->Construct(Rectangle(0, 0, LIST_WIDTH, LIST_HEIGHT), true);
+ _pList->SetItemProvider(*this);
+ _pList->AddListViewItemEventListener(*this);
+ _pList->SetTextOfEmptyList(L"");
+ AddControl(*_pList);
+
+ _pItemList = new (std::nothrow) ArrayList();
+ _pItemList->Construct();
+
+ return r;
+}
+
+int
+XmlWriter::GetItemCount(void)
+{
+ TryReturn(_pItemList, 0, "_pItemList is null");
+ return _pItemList->GetCount();
+}
+
+Tizen::Ui::Controls::ListItemBase*
+XmlWriter::CreateItem(int index, int itemWidth)
+{
+ ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
+ SimpleItem* pItem = new (std::nothrow) SimpleItem();
+
+ pItem->Construct(Tizen::Graphics::Dimension(itemWidth, ITEM_HEIGHT), style);
+ Tizen::Base::String* key = static_cast< String* >(_pItemList->GetAt(index));
+ TryReturn(key, null, "key value is null for index %d", index);
+
+ pItem->SetElement(*key, null);
+ return pItem;
+}
+
+bool
+XmlWriter::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
+{
+ delete pItem;
+ pItem = null;
+ return true;
+}
+
+
+void
+XmlWriter::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
+{
+
+}
+
+void
+XmlWriter::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
+{
+
+}
+
+void
+XmlWriter::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
+{
+
+}
+
+void
+XmlWriter::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
+{
+ result err;
+ switch (actionId)
+ {
+ case ID_BUTTON_WRITE:
+ {
+ err = RunXMLWrite();
+ TryReturnVoid(E_SUCCESS == err , "RunXMLWrite failed.%S", GetErrorMessage(err));
+
+ if(__display && _pItemList)
+ {
+ _pItemList->RemoveAll(true);
+ }
+ __display = false;
+ RunXMLParseandDisplay();
+ Draw();
+ }
+ break;
+ }
+}
+
+
+result
+XmlWriter::RunXMLWrite(void)
+{
+ int rc;
+ result r = E_FAILURE;
+
+ // Create xml document
+ const String filepath = App::GetInstance()->GetAppRootPath() + L"data/writemap.xml";
+
+ ByteBuffer* pBuf = Tizen::Base::Utility::StringUtil::StringToUtf8N(filepath);
+ TryReturn(pBuf, r, "String to ByteBuffer conversion failed.");
+
+ xmlTextWriterPtr writer = xmlNewTextWriterFilename((const char*) pBuf->GetPointer(), 0);
+ TryCatch(writer, , "xmlNewTextWriterFilename Failed!");
+
+ rc = xmlTextWriterStartDocument(writer, null, "ISO-8859-1", null);
+ TryCatch(rc >= 0, , "xmlTextWriterStartDocument Failed!");
+
+ rc = xmlTextWriterStartElement(writer, (xmlChar*) "map");
+ TryCatch(rc >= 0, , "xmlTextWriterStartElement Failed!");
+
+ rc = xmlTextWriterStartElement(writer, (xmlChar*) "item");
+ TryCatch(rc >= 0, , "xmlTextWriterStartElement Failed!");
+
+ rc = xmlTextWriterWriteElement(writer, (xmlChar*) "Country", (xmlChar*) "America");
+ TryCatch(rc >= 0, , "xmlTextWriterWriteElement Failed!");
+
+ rc = xmlTextWriterWriteElement(writer, (xmlChar*) "Capital", (xmlChar*) "Washington D.C.");
+ TryCatch(rc >= 0, , "xmlTextWriterWriteElement Failed!");
+
+ rc = xmlTextWriterEndElement(writer);
+ TryCatch(rc >= 0, , "xmlTextWriterEndElement Failed!");
+
+ rc = xmlTextWriterStartElement(writer, (xmlChar*) "item");
+ TryCatch(rc >= 0, , "xmlTextWriterStartElement Failed!");
+
+ rc = xmlTextWriterWriteElement(writer, (xmlChar*) "Country", (xmlChar*) "England");
+ TryCatch(rc >= 0, , "xmlTextWriterWriteElement Failed!");
+
+ rc = xmlTextWriterWriteElement(writer, (xmlChar*) "Capital", (xmlChar*) "London");
+ TryCatch(rc >= 0, , "xmlTextWriterWriteElement Failed!");
+
+ rc = xmlTextWriterEndElement(writer);
+ TryCatch(rc >= 0, , "xmlTextWriterEndElement Failed!");
+
+ rc = xmlTextWriterStartElement(writer, (xmlChar*) "item");
+ TryCatch(rc >= 0, , "xmlTextWriterStartElement Failed!");
+
+ rc = xmlTextWriterWriteElement(writer, (xmlChar*) "Country", (xmlChar*) "India");
+ TryCatch(rc >= 0, , "xmlTextWriterWriteElement Failed!");
+
+ rc = xmlTextWriterWriteElement(writer, (xmlChar*) "Capital", (xmlChar*) "Delhi");
+ TryCatch(rc >= 0, , "xmlTextWriterWriteElement Failed!");
+
+ rc = xmlTextWriterEndElement(writer);
+ TryCatch(rc >= 0, , "xmlTextWriterEndElement Failed!");
+
+ rc = xmlTextWriterEndElement(writer);
+ TryCatch(rc >= 0, , "xmlTextWriterEndElement Failed!");
+
+ rc = xmlTextWriterEndDocument(writer);
+ TryCatch(rc >= 0, , "xmlTextWriterEndDocument Failed!");
+
+ r = E_SUCCESS;
+
+CATCH:
+ delete pBuf;
+ pBuf = null;
+ if (writer)
+ {
+ xmlFreeTextWriter(writer);
+ }
+ return r;
+}
+
+void
+XmlWriter::RunXMLParseandDisplay(void)
+{
+
+ const String filepath = App::GetInstance()->GetAppRootPath() + L"data/writemap.xml";
+ xmlNodePtr pRoot = null;
+
+ ByteBuffer* pBuf = Tizen::Base::Utility::StringUtil::StringToUtf8N(filepath);
+ TryReturnVoid(pBuf, "StringToUtf8N failed.");
+
+ xmlDocPtr pDocument = xmlParseFile((const char*) pBuf->GetPointer());
+ TryCatch(pBuf, , "xmlParseFile failed.");
+
+ pRoot = xmlDocGetRootElement(pDocument);
+ TryCatch(pRoot, xmlFreeDoc(pDocument), "xmlDocGetRootElement failed.");
+
+ TryCatch(_pList, xmlFreeDoc(pDocument), "_pList is null.");
+
+ for (xmlNodePtr pCurrentElement = pRoot->children; pCurrentElement; pCurrentElement = pCurrentElement->next)
+ {
+ xmlNodePtr pChildElement = null;
+
+ if (pCurrentElement->type == XML_ELEMENT_NODE)
+ {
+ // Get <country> element from <item> element
+ pChildElement = pCurrentElement->children;
+
+ for (; pChildElement; pChildElement = pChildElement->next)
+ {
+ String* textName = new String;
+ Tizen::Base::Utility::StringUtil::Utf8ToString((char*) pChildElement->children->content, *textName);
+ _pItemList->Add(*textName);
+ }
+ }
+ }
+
+ _pList->UpdateList();
+ __display = true;
+ xmlFreeDoc(pDocument);
+CATCH:
+ delete pBuf;
+ pBuf = null;
+
+}
+
+result
+XmlWriter::OnTerminating(void)
+{
+ result r = E_SUCCESS;
+ if (_pItemList)
+ {
+ _pItemList->RemoveAll(true);
+ delete _pItemList;
+ _pItemList = null;
+ }
+ return r;
+}
+
+void
+XmlWriter::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
+{
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+ pSceneManager->GoBackward(BackwardSceneTransition());
+}
diff --git a/sample.xml b/sample.xml
new file mode 100755
index 0000000..b724960
--- /dev/null
+++ b/sample.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<template>
+
+ <slp-property>
+ <property-group>
+ <sample-name>XmlParserApp</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 100755
index 0000000..98fb245
--- /dev/null
+++ b/screenshot.png
Binary files differ