Tizen 2.1 base
[sdk/ide/native-sample.git] / samples / native / cpp / Sample / Tizen C++ / SystemApp / SystemApp / project / src / SystemInfoForm.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.tizenopensource.org/license
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 #include "FormManager.h"
19 #include "SystemInfoForm.h"
20 #include "CustomListElement.h"
21
22 using namespace Osp::Base;
23 using namespace Osp::Ui;
24 using namespace Osp::Ui::Controls;
25 using namespace Osp::System;
26 using namespace Osp::Graphics;
27
28 const int NumberOfSystemElement = 21;
29
30 SystemInfoForm::SystemInfoForm(void)
31         : __pListView(null)
32         , listElements()
33 {
34
35 }
36
37 SystemInfoForm::~SystemInfoForm(void)
38 {
39
40 }
41
42 bool
43 SystemInfoForm::Initialize()
44 {
45         Construct(L"IDF_SYSTEM_INFO_FORM");
46         __pListView = new ListView();
47         __pListView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height), true, false);
48         __pListView->SetItemProvider(*this);
49         __pListView->AddListViewItemEventListener(*this);
50
51         listElements.Construct(NumberOfSystemElement);
52
53         AddControl(*__pListView);
54         return true;
55 }
56
57 result
58 SystemInfoForm::OnInitializing(void)
59 {
60         result r = E_SUCCESS;
61
62         Footer* pFooter = GetFooter();
63         FormManager::MakeSystemAppFooter(this, pFooter, FormManager::REQUEST_FORM_SYSTEM_INFO);
64
65         return r;
66 }
67
68 result
69 SystemInfoForm::OnTerminating(void)
70 {
71         result r = E_SUCCESS;
72
73         return r;
74 }
75
76 void
77 SystemInfoForm::OnActionPerformed(const Osp::Ui::Control& source, int actionId)
78 {
79         switch (actionId)
80         {
81         default:
82         {
83                 Frame *pFrame = Osp::App::Application::GetInstance()->GetAppFrame()->GetFrame();
84                 FormManager* pFormManager = static_cast<FormManager*>(pFrame->GetControl(String(L"FormManager")));
85                 if (pFormManager != null)
86                 {
87                         pFormManager->SendUserEvent(static_cast<RequestId>(actionId), null);
88                 }
89                 else
90                 {
91                         AppLog("FormManager getting has failed.");
92                 }
93                 return;
94         }
95         }
96
97         RequestRedraw(true);
98 }
99
100 void
101 SystemInfoForm::OnListViewContextItemStateChanged(Osp::Ui::Controls::ListView& listView,
102         int index,
103         int elementId,
104         Osp::Ui::Controls::ListContextItemStatus state)
105 {
106 }
107
108 void
109 SystemInfoForm::OnListViewItemStateChanged(Osp::Ui::Controls::ListView& listView,
110         int index,
111         int elementId,
112         Osp::Ui::Controls::ListItemStatus status)
113 {
114 }
115
116 void
117 SystemInfoForm::OnListViewItemSwept(Osp::Ui::Controls::ListView& listView,
118         int index,
119         Osp::Ui::Controls::SweepDirection direction)
120 {
121 }
122
123 Osp::Ui::Controls::ListItemBase*
124 SystemInfoForm::CreateItem(int index, int itemWidth)
125 {
126         ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
127         CustomItem* pItem = new CustomItem();
128
129         String szTitle;
130         String szDescription;
131         int nResult;
132         bool bResult;
133         CustomListElement* pCustomListElement;
134         pItem->Construct(Osp::Graphics::Dimension(itemWidth, 100), style);
135
136         switch (index)
137         {
138         case 0:
139         {
140                 szTitle = "APIVersion";
141                 SystemInfo::GetValue(szTitle, szDescription);
142                 break;
143         }
144
145         case 1:
146         {
147                 szTitle = "BluetoothSupported";
148                 SystemInfo::GetValue(szTitle, bResult);
149                 if (bResult == true)
150                         szDescription = "Supported";
151                 else
152                         szDescription = "Unsupported";
153                 break;
154         }
155
156         case 2:
157         {
158                 szTitle = "CameraCount";
159                 SystemInfo::GetValue(szTitle, nResult);
160                 szDescription = "";
161                 szDescription.Append(nResult);
162                 break;
163         }
164
165         case 3:
166         {
167                 szTitle = "GPSSupported";
168                 SystemInfo::GetValue(szTitle, bResult);
169                 if (bResult == true)
170                         szDescription = "Supported";
171                 else
172                         szDescription = "Unsupported";
173                 break;
174         }
175
176         case 4:
177         {
178                 szTitle = "KeyboardType";
179                 SystemInfo::GetValue(szTitle, szDescription);
180                 break;
181         }
182
183         case 5:
184         {
185                 szTitle = "NetworkType";
186                 SystemInfo::GetValue(szTitle, szDescription);
187                 break;
188         }
189
190         case 6:
191         {
192                 szTitle = "OpenGLESVersion";
193                 SystemInfo::GetValue(szTitle, szDescription);
194                 break;
195         }
196
197         case 7:
198         {
199                 szTitle = "PlatformVersion";
200                 SystemInfo::GetValue(szTitle, szDescription);
201                 break;
202         }
203
204         case 8:
205         {
206                 szTitle = "ScreenBitsPerPixel";
207                 SystemInfo::GetValue(szTitle, nResult);
208                 szDescription = "";
209                 szDescription.Append(nResult);
210                 break;
211         }
212
213         case 9:
214         {
215                 szTitle = "ScreenHeight";
216                 SystemInfo::GetValue(szTitle, nResult);
217                 szDescription = "";
218                 szDescription.Append(nResult);
219                 break;
220         }
221
222         case 10:
223         {
224                 szTitle = "ScreenWidth";
225                 SystemInfo::GetValue(szTitle, nResult);
226                 szDescription = "";
227                 szDescription.Append(nResult);
228                 break;
229         }
230
231         case 11:
232         {
233                 szTitle = "WiFiSupported";
234                 SystemInfo::GetValue(szTitle, bResult);
235                 if (bResult == true)
236                         szDescription = "Supported";
237                 else
238                         szDescription = "Unsupported";
239                 break;
240         }
241
242         case 12:
243         {
244                 szTitle = "FmRadioSupported";
245                 SystemInfo::GetValue(szTitle, bResult);
246                 if (bResult == true)
247                         szDescription = "Supported";
248                 else
249                         szDescription = "Unsupported";
250                 break;
251         }
252
253         case 13:
254         {
255                 szTitle = "TvOutSupported";
256                 SystemInfo::GetValue(szTitle, bResult);
257                 if (bResult == true)
258                         szDescription = "Supported";
259                 else
260                         szDescription = "Unsupported";
261                 break;
262         }
263
264         case 14:
265         {
266                 szTitle = "MultiPointTouchCount";
267                 SystemInfo::GetValue(szTitle, nResult);
268                 szDescription = "";
269                 szDescription.Append(nResult);
270                 break;
271         }
272
273         case 15:
274         {
275                 szTitle = "MaxSystemSoundVolume";
276                 SystemInfo::GetValue(szTitle, nResult);
277                 szDescription = "";
278                 szDescription.Append(nResult);
279                 break;
280         }
281
282         case 16:
283         {
284                 szTitle = "MaxMediaSoundVolume";
285                 SystemInfo::GetValue(szTitle, nResult);
286                 szDescription = "";
287                 szDescription.Append(nResult);
288                 break;
289         }
290
291         case 17:
292         {
293                 szTitle = "MaxRingtoneSoundVolume";
294                 SystemInfo::GetValue(szTitle, nResult);
295                 szDescription = "";
296                 szDescription.Append(nResult);
297                 break;
298         }
299
300         case 18:
301         {
302                 szTitle = "MaxNotificationSoundVolume";
303                 SystemInfo::GetValue(szTitle, nResult);
304                 szDescription = "";
305                 szDescription.Append(nResult);
306                 break;
307         }
308
309         case 19:
310         {
311                 szTitle = "NFCSupported";
312                 SystemInfo::GetValue(szTitle, bResult);
313                 if (bResult == true)
314                         szDescription = "Supported";
315                 else
316                         szDescription = "Unsupported";
317                 break;
318         }
319
320         case 20:
321         {
322                 szTitle = "WiFiDirectSupported";
323                 SystemInfo::GetValue(szTitle, bResult);
324                 if (bResult == true)
325                         szDescription = "Supported";
326                 else
327                         szDescription = "Unsupported";
328                 break;
329         }
330
331         default:
332                 break;
333         }
334
335         listElements.RemoveAt(index, true);
336
337         pCustomListElement = new CustomListElement();
338         pCustomListElement->SetTitleDescription(szTitle, szDescription);
339         listElements.InsertAt(*((Object*) pCustomListElement), index);
340         pItem->AddElement(Rectangle(0, 0, GetClientAreaBounds().width, 90), ID_FORMAT_CUSTOM, *(static_cast<ICustomElement*>(pCustomListElement)));
341
342         return pItem;
343 }
344
345 bool
346 SystemInfoForm::DeleteItem(int index, Osp::Ui::Controls::ListItemBase* pItem, int itemWidth)
347 {
348
349         listElements.RemoveAt(index, true);
350         delete pItem;
351         pItem = null;
352
353         return true;
354 }
355
356 int
357 SystemInfoForm::GetItemCount(void)
358 {
359         return NumberOfSystemElement;
360 }