Tizen 2.1 base
[sdk/ide/native-sample.git] / samples / native / cpp / Sample / Tizen C++ / XmlParserApp / XmlParserApp / project / src / XmlParserApp.cpp
1 //\r
2 // Open Service Platform\r
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
4 //\r
5 // Licensed under the Flora License, Version 1.0 (the License);\r
6 // you may not use this file except in compliance with the License.\r
7 // You may obtain a copy of the License at\r
8 //\r
9 //     http://www.tizenopensource.org/license\r
10 //\r
11 // Unless required by applicable law or agreed to in writing, software\r
12 // distributed under the License is distributed on an AS IS BASIS,\r
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14 // See the License for the specific language governing permissions and\r
15 // limitations under the License.\r
16 //\r
17 //==================================================================\r
18 // APP. Name   : XmlParserApp.cpp\r
19 // Version     : 1.0.0\r
20 // Vendor      : \r
21 // Description : \r
22 //==================================================================\r
23 \r
24 \r
25 #include "XmlParserApp.h"\r
26 #include "FormMgr.h"\r
27 #include "MainListForm.h"\r
28 #include "XmlReader.h"\r
29 \r
30 using namespace Osp::App;\r
31 using namespace Osp::Base;\r
32 using namespace Osp::System;\r
33 using namespace Osp::Ui;\r
34 using namespace Osp::Ui::Controls;\r
35 \r
36 XmlParserApp::XmlParserApp()\r
37 {\r
38 }\r
39 \r
40 XmlParserApp::~XmlParserApp()\r
41 {\r
42 }\r
43 \r
44 Application*\r
45 XmlParserApp::CreateInstance(void)\r
46 {\r
47         // Create the instance through the constructor.\r
48         return new XmlParserApp();\r
49 }\r
50 \r
51 bool\r
52 XmlParserApp::OnAppInitializing(AppRegistry& appRegistry)\r
53 {\r
54         /////////////////////////////////////////////////////////////////////////////////////\r
55         //this codes is automatically inserted by Tizen C++ application wizard.\r
56         Frame* pAppFrame = new Frame();\r
57         pAppFrame->Construct();\r
58         AddFrame(*pAppFrame);\r
59         ////////////////////////////////////////////////////////////////////////////////////\r
60         FormMgr *pFormMgr = new FormMgr();\r
61         int lastFormId = 0;\r
62         String lastFormName("");\r
63         String formIDkey("AppLastFormId");\r
64         String formNamekey("AppLastFormName");\r
65         result r = E_SUCCESS;\r
66 \r
67         pFormMgr->Initialize();\r
68         GetAppFrame()->GetFrame()->AddControl(*pFormMgr);\r
69         r = appRegistry.Get(formIDkey, lastFormId);\r
70         if ( r == E_KEY_NOT_FOUND)\r
71         {\r
72                 lastFormId = FormMgr::REQUEST_MainListForm;\r
73                 appRegistry.Add(formIDkey, lastFormId);\r
74         }\r
75         r = appRegistry.Get(formNamekey, lastFormName);\r
76         if ( r == E_KEY_NOT_FOUND)\r
77         {\r
78                 appRegistry.Add(formNamekey, L"IDF_FORM1");\r
79         }\r
80         pFormMgr->SetStarterForm((RequestId)lastFormId, null);\r
81 \r
82         // Uncomment the following statement to listen to the screen on/off events.\r
83         //PowerManager::SetScreenEventListener(*this);\r
84         return true;\r
85 }\r
86 \r
87 bool\r
88 XmlParserApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)\r
89 {\r
90         // TODO:\r
91         // Deallocate resources allocated by this application for termination.\r
92         // The application's permanent data and context can be saved via appRegistry.\r
93 \r
94         return true;\r
95 }\r
96 \r
97 void\r
98 XmlParserApp::OnForeground(void)\r
99 {\r
100         // TODO:\r
101         // Start or resume drawing when the application is moved to the foreground.\r
102 }\r
103 \r
104 void\r
105 XmlParserApp::OnBackground(void)\r
106 {\r
107         // TODO:\r
108         // Stop drawing when the application is moved to the background.\r
109 }\r
110 \r
111 void\r
112 XmlParserApp::OnLowMemory(void)\r
113 {\r
114         // TODO:\r
115         // Free unused resources or close the application.\r
116 }\r
117 \r
118 void\r
119 XmlParserApp::OnBatteryLevelChanged(BatteryLevel batteryLevel)\r
120 {\r
121         // TODO:\r
122         // Handle any changes in battery level here.\r
123         // Stop using multimedia features(camera, mp3 etc.) if the battery level is CRITICAL.\r
124 }\r
125 \r
126 void\r
127 XmlParserApp::OnScreenOn (void)\r
128 {\r
129         // TODO:\r
130         // Get the released resources or resume the operations that were paused or stopped in OnScreenOff().\r
131 }\r
132 \r
133 void\r
134 XmlParserApp::OnScreenOff (void)\r
135 {\r
136         // TODO:\r
137         //  Unless there is a strong reason to do otherwise, release resources (such as 3D, media, and sensors) to allow the device to enter the sleep mode to save the battery.\r
138         // Invoking a lengthy asynchronous method within this listener method can be risky, because it is not guaranteed to invoke a callback before the device enters the sleep mode.\r
139         // Similarly, do not perform lengthy operations in this listener method. Any operation must be a quick one.\r
140 }\r