Applied latest source code
[apps/native/preloaded/Settings.git] / src / StDownloadedApplicationForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                StDownloadedApplicationForm.cpp
19  * @brief               This is the implementation file for DownloadedApplicationForm class.
20  */
21
22 #include <FIo.h>
23 #include "StDownloadedApplicationForm.h"
24 #include "StResourceManager.h"
25 #include "StSettingScenesList.h"
26 #include "StTypes.h"
27
28 using namespace Tizen::App;
29 using namespace Tizen::App::Package;
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Base::Utility;
33 using namespace Tizen::Graphics;
34 using namespace Tizen::Io;
35 using namespace Tizen::Ui;
36 using namespace Tizen::Ui::Controls;
37 using namespace Tizen::Ui::Scenes;
38
39 static const wchar_t* ID_RELATIVE_SETTING_XML_FILE_PATH = L"/setting/setting.xml";
40 static const wchar_t* ID_APPLICATION_DEFAULT_FOLDER_PATH = L"/opt/apps/";
41
42 static const int ID_GROUP_COUNT = 1;
43
44 DownloadedApplicationForm::DownloadedApplicationForm(void)
45         : __pDownloadAppIdKeyList(null)
46         , __pAppIdHashMap(null)
47         , __pAppIconPathHashMap(null)
48 {
49 }
50
51 DownloadedApplicationForm::~DownloadedApplicationForm(void)
52 {
53 }
54
55 void
56 DownloadedApplicationForm::CreateFooter(void)
57 {
58         Footer* pFooter = GetFooter();
59         AppAssert(pFooter);
60
61         pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
62         pFooter->AddActionEventListener(*this);
63
64         SetFormBackEventListener(this);
65 }
66
67 result
68 DownloadedApplicationForm::OnInitializing(void)
69 {
70         CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_DOWNLOADED_APPLICATIONS"));
71         CreateTableView();
72         SetAppIdListFromPackageManager();
73         UpdateTableViewAndNoContent();
74
75         return E_SUCCESS;
76 }
77
78 result
79 DownloadedApplicationForm::OnTerminating(void)
80 {
81         RemoveAllDownLoadAppIdKeyList();
82         RemoveAllAppIdList();
83         int controlCount = GetControlCount();
84         for (int i = 0; i < controlCount; i++)
85         {
86                 RemoveControl(GetControl(0));
87         }
88         __pTableView = null;
89
90         SetFormBackEventListener(null);
91         return E_SUCCESS;
92 }
93
94 void
95 DownloadedApplicationForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
96 {
97         if (pArgs != null)
98         {
99                 delete pArgs;
100         }
101         RemoveAllDownLoadAppIdKeyList();
102         SetAppIdListFromPackageManager();
103
104         UpdateTableViewAndNoContent();
105 }
106
107 void
108 DownloadedApplicationForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
109 {
110 }
111
112 void
113 DownloadedApplicationForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
114 {
115         SceneManager* pSceneManager = SceneManager::GetInstance();
116         AppAssert(pSceneManager);
117
118         pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
119 }
120
121 int
122 DownloadedApplicationForm::GetGroupCount(void)
123 {
124         AppLogDebug("ENTER");
125
126         return ID_GROUP_COUNT;
127 }
128
129 int
130 DownloadedApplicationForm::GetItemCount(int groupIndex)
131 {
132         int itemCount = GetDownLoadAppCount();
133
134         AppLogDebug("GetItemCount %d", itemCount);
135
136         return itemCount;
137 }
138
139 TableViewGroupItem*
140 DownloadedApplicationForm::CreateGroupItem(int groupIndex, int itemWidth)
141 {
142         AppLogDebug("ENTER");
143
144         int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
145         int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
146         LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
147         Rectangle itemRectangle;
148         String groupText;
149         Label* pLabel = null;
150         int fontSize = GetFontSize();
151
152         TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
153
154         yItemOffset = H_GROUP_INDEX_NO_HELP_TEXT_GAP;
155         itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
156
157         itemRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
158         itemRectangle.y = yItemOffset;
159         itemRectangle.width = itemWidth;
160         itemRectangle.height = itemHeight;
161
162         RelativeLayout relativeLayout;
163         relativeLayout.Construct();
164
165         pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
166         pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
167
168         pLabel = new (std::nothrow) Label();
169         pLabel->Construct(itemRectangle, groupText);
170         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
171         pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
172         pLabel->SetTextConfig(fontSize, style);
173         pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
174
175         pItem->AddControl(pLabel);
176         relativeLayout.SetMargin(*pLabel, itemRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
177         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
178         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
179         pItem->SetEnabled(false);
180
181         return pItem;
182 }
183
184 TableViewItem*
185 DownloadedApplicationForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
186 {
187         AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
188
189         Rectangle itemIconRectangle;
190         Rectangle itemMainRectangle;
191         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
192         String itemMainText;
193         String fontReturnValue;
194         Label* pLabel = null;
195         Bitmap* pBitmap;
196
197         int fontSize = GetFontSize();
198         int itemHeight = H_GROUP_ITEM_DEFAULT_LABEL;
199         ItemTypeIconAndOneLine(itemIconRectangle, itemMainRectangle);
200
201         String appIdKey = GetDownLoadAppIdKeyAt(itemIndex);
202         String iconPath = GetAppSettingIconPathFromAppIdListAt(appIdKey);
203
204         itemMainText = GetDownLoadAppNameAt(itemIndex);
205
206         if (iconPath.IsEmpty() == true)
207         {
208                 pBitmap = ResourceManager::GetBitmapN(IDB_DEFAULT_ICON);
209         }
210         else
211         {
212                 pBitmap = ResourceManager::GetApplicationBitmapN(iconPath);
213         }
214         TableViewItem* pItem = new (std::nothrow) TableViewItem();
215
216         RelativeLayout relativeLayout;
217         relativeLayout.Construct();
218
219         pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
220         pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
221
222         pLabel = new (std::nothrow) Label();
223         pLabel->Construct(itemIconRectangle, L"");
224         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
225         pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
226         pLabel->SetBackgroundBitmap(*pBitmap);
227
228         pItem->AddControl(pLabel);
229
230         pLabel = new (std::nothrow) Label();
231         pLabel->Construct(itemMainRectangle, itemMainText);
232         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
233         pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
234         pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
235         pLabel->SetTextColor(COLOR_MAIN_TEXT);
236
237         pItem->AddControl(pLabel);
238         relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, 0, 0, 0);
239         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
240         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
241
242         return pItem;
243 }
244
245 bool
246 DownloadedApplicationForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
247 {
248         AppLogDebug("ENTER");
249
250         delete pItem;
251         pItem = null;
252
253         return true;
254 }
255
256 bool
257 DownloadedApplicationForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
258 {
259         AppLogDebug("ENTER");
260
261         delete pItem;
262         pItem = null;
263
264         return true;
265 }
266
267 void
268 DownloadedApplicationForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
269 {
270         AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
271
272         SceneManager* pSceneManager = SceneManager::GetInstance();
273         AppAssert(pSceneManager);
274
275         ArrayList* pArgs = null;
276
277         String appIdKey = GetDownLoadAppIdKeyAt(itemIndex);
278         if (appIdKey.IsEmpty() == true)
279         {
280                 AppLogDebug("GetDownLoadAppIdKeyAt[%d] fail", itemIndex);
281         }
282
283         String appSettingFilepath = GetAppSettingFilePathFromAppIdListAt(appIdKey);
284         if (appSettingFilepath.IsEmpty() == true)
285         {
286                 AppLogDebug("GetAppSettingFilePathFromAppIdListAt[%ls] fail", appIdKey.GetPointer());
287         }
288
289         pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
290         if (pArgs == null)
291         {
292                 AppLogDebug("pArgs is null");
293         }
294
295         result r = pArgs->Construct();
296         if (IsFailed(r))
297         {
298                 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
299         }
300
301         pArgs->Add(new (std::nothrow) String(appIdKey));
302         pArgs->Add(new (std::nothrow) String(appSettingFilepath));
303
304         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_XML_PARSER, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
305 }
306
307 int
308 DownloadedApplicationForm::GetDefaultGroupItemHeight(void)
309 {
310         return H_GROUP_INDEX_NO_TITLE_DEFAULT;
311 }
312
313 int
314 DownloadedApplicationForm::GetDefaultItemHeight(void)
315 {
316         return H_GROUP_ITEM_DEFAULT;
317 }
318
319 void
320 DownloadedApplicationForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
321 {
322 }
323
324 void
325 DownloadedApplicationForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
326 {
327         Invalidate(true);
328 }
329
330 void
331 DownloadedApplicationForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
332 {
333 }
334
335 void
336 DownloadedApplicationForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
337 {
338 }
339
340 void
341 DownloadedApplicationForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
342 {
343         Label* pLabel = static_cast<Label*>(this->GetControl(NO_CONTENTS, false));
344         if (pLabel != null)
345         {
346                 Rectangle clientRect = GetClientAreaBounds();
347                 Rectangle labelBound = pLabel->GetBounds();
348
349                 int xPos = (clientRect.width / LINE_COUNT_2) - (labelBound.width / LINE_COUNT_2);
350                 int yPos = (clientRect.height / LINE_COUNT_2) -(labelBound.height / LINE_COUNT_2);
351
352                 pLabel->SetBounds(Rectangle(xPos, yPos, labelBound.width, labelBound.height));
353                 yPos = yPos + pLabel->GetBounds().height;
354                 Label* pTextLabel = static_cast<Label*>(this->GetControl(NO_CONTENTS_TEXT, false));
355                 if (pTextLabel != null)
356                 {
357                         pTextLabel->SetBounds(Rectangle(0, yPos, clientRect.width, pTextLabel->GetBounds().height));
358                 }
359         }
360         Invalidate(true);
361 }
362
363 void
364 DownloadedApplicationForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
365 {
366         if (requestId == REFRESH_REQUEST_EVENT)
367         {
368                 if (__pTableView)
369                 {
370                         RemoveAllDownLoadAppIdKeyList();
371                         SetAppIdListFromPackageManager();
372                         __pTableView->UpdateTableView();
373                 }
374                 if (pArgs)
375                 {
376                         pArgs->RemoveAll(true);
377                         delete pArgs;
378                 }
379         }
380 }
381
382 result
383 DownloadedApplicationForm::SetDownLoadAppIdKeyList(void)
384 {
385         RemoveAllDownLoadAppIdKeyList();
386
387         if (__pAppIdHashMap == null)
388         {
389                 AppLogDebug("__pAppIdHashMap is null");
390                 return E_FAILURE;
391         }
392
393         __pDownloadAppIdKeyList = __pAppIdHashMap->GetKeysN();
394         if (__pDownloadAppIdKeyList == null)
395         {
396                 AppLogDebug("__pDownloadAppIdKeyList is null");
397                 return E_FAILURE;
398         }
399
400         return E_SUCCESS;
401 }
402
403 void
404 DownloadedApplicationForm::RemoveAllDownLoadAppIdKeyList(void)
405 {
406         if (__pDownloadAppIdKeyList != null)
407         {
408                 __pDownloadAppIdKeyList->RemoveAll();
409                 delete __pDownloadAppIdKeyList;
410                 __pDownloadAppIdKeyList = null;
411         }
412 }
413
414 result
415 DownloadedApplicationForm::SetAppIdListFromPackageManager(void)
416 {
417         RemoveAllAppIdList();
418
419         __pAppIdHashMap = new (std::nothrow) HashMap();
420         if (__pAppIdHashMap == null)
421         {
422                 AppLogDebug("__pAppIdHashMap is null");
423                 return E_FAILURE;
424         }
425
426         result r = __pAppIdHashMap->Construct();
427         if (IsFailed(r))
428         {
429                 AppLogDebug("Construct fail [%s]", GetErrorMessage(GetLastResult()));
430                 RemoveAllAppIdList();
431                 return E_FAILURE;
432         }
433
434         __pAppIconPathHashMap = new (std::nothrow) HashMap();
435         if (__pAppIconPathHashMap == null)
436         {
437                 AppLogDebug("__pAppIconPathHashMap is null");
438                 return E_FAILURE;
439         }
440         r = __pAppIconPathHashMap->Construct();
441         if (IsFailed(r))
442         {
443                 AppLogDebug("Construct fail [%s]", GetErrorMessage(GetLastResult()));
444                 RemoveAllAppIdList();
445                 return E_FAILURE;
446         }
447
448         IList* pList = null;
449         PackageManager* pPackageManager = PackageManager::GetInstance();
450         if (pPackageManager == null)
451         {
452                 AppLogDebug("pPackageManager is null");
453                 RemoveAllAppIdList();
454                 return E_FAILURE;
455         }
456
457         HashMap packageFilterMap;
458         r = packageFilterMap.Construct();
459         if (IsFailed(r))
460         {
461                 AppLogDebug("pPackageFilter Construct fail");
462         }
463
464         String* pKey = new (std::nothrow) String("http://tizen.org/package/appsetting");
465         Boolean* pValue = new (std::nothrow) Boolean(true);
466
467         r = packageFilterMap.Add(pKey, pValue);
468         if (IsFailed(r))
469         {
470                 AppLogDebug("packageFilterMap add Fail");
471         }
472
473         pList = pPackageManager->GetPackageInfoListN(packageFilterMap);
474         if (pList == null)
475         {
476                 AppLogDebug("pList is null");
477                 RemoveAllAppIdList();
478                 return E_FAILURE;
479         }
480
481         IEnumerator* pEnumerator = pList->GetEnumeratorN();
482         if (pEnumerator == null)
483         {
484                 AppLogDebug("pEnumerator is null");
485                 pList->RemoveAll();
486                 delete pList;
487                 RemoveAllAppIdList();
488                 return E_FAILURE;
489         }
490
491         bool isFindXml = false;
492         UiApp* pApp = UiApp::GetInstance();
493         AppAssert(pApp);
494
495         while (pEnumerator->MoveNext() == E_SUCCESS)
496         {
497                 PackageInfo* pPackage = static_cast<PackageInfo*>(pEnumerator->GetCurrent());
498                 if (pPackage != null && pPackage->GetType() == PACKAGE_TYPE_TPK)
499                 {
500                         String path(ID_APPLICATION_DEFAULT_FOLDER_PATH);
501                         path.Append(pPackage->GetId());
502
503                         path.Append(ID_RELATIVE_SETTING_XML_FILE_PATH);
504
505                         if ((File::IsFileExist(path) == true)
506                                 && (!pApp->GetAppId().Contains(pPackage->GetId())))
507                         {
508                                 String key(pPackage->GetDisplayName());
509                                 key.Append(L":");
510                                 key.Append(pPackage->GetId());
511
512                                 String currentAppId = pPackage->GetMainAppId();
513                                 PackageAppInfo* pPackageInfo = static_cast<PackageAppInfo*>(pPackage->GetPackageAppInfoN(currentAppId));
514
515                                 bool isIME = false;
516                                 IList* pCategoryList = pPackageInfo->GetAppCategoryListN();
517                                 if (pCategoryList)
518                                 {
519                                         for (int i=0; i<pCategoryList->GetCount(); ++i)
520                                         {
521                                                 String* pCategory = static_cast<String*>(pCategoryList->GetAt(i));
522                                                 if (pCategory->Equals(L"http://tizen.org/category/ime", false))
523                                                 {
524                                                         isIME = true;
525                                                         break;
526                                                 }
527                                         }
528                                 }
529
530                                 if (isIME)
531                                 {
532                                         delete pPackageInfo;
533                                         continue;
534                                 }
535
536                                 String iconPath = pPackageInfo->GetAppMenuIconPath();
537
538                                 __pAppIdHashMap->Add(new (std::nothrow) String(key), new (std::nothrow) String(path));
539                                 __pAppIconPathHashMap->Add(new (std::nothrow) String(key), new (std::nothrow) String(iconPath));
540                                 isFindXml = true;
541                         }
542                 }
543         }
544         delete pEnumerator;
545         delete pList;
546
547         if (isFindXml == false)
548         {
549                 RemoveAllAppIdList();
550                 return E_FAILURE;
551         }
552
553         r = SetDownLoadAppIdKeyList();
554         if (IsFailed(r))
555         {
556                 RemoveAllDownLoadAppIdKeyList();
557                 RemoveAllAppIdList();
558                 return E_FAILURE;
559         }
560
561         packageFilterMap.RemoveAll(true);
562         return E_SUCCESS;
563 }
564
565
566 void
567 DownloadedApplicationForm::RemoveAllAppIdList(void)
568 {
569         if (__pAppIdHashMap != null)
570         {
571                 __pAppIdHashMap->RemoveAll();
572                 delete __pAppIdHashMap;
573                 __pAppIdHashMap = null;
574         }
575
576         if (__pAppIconPathHashMap != null)
577         {
578                 __pAppIconPathHashMap->RemoveAll();
579                 delete __pAppIconPathHashMap;
580                 __pAppIconPathHashMap = null;
581         }
582 }
583
584 Tizen::Base::String
585 DownloadedApplicationForm::GetAppSettingFilePathFromAppIdListAt(Tizen::Base::String key)
586 {
587         String appSettingFilePath;
588         if (__pAppIdHashMap == null)
589         {
590                 AppLogDebug("__pAppIdHashMap is null");
591                 return appSettingFilePath;
592         }
593
594         bool isFind = false;
595         result r = __pAppIdHashMap->ContainsKey(key, isFind);
596         if ((isFind == false)
597                 || (IsFailed(r)))
598         {
599                 if (isFind == false)
600                 {
601                         AppLogDebug("key[%ls] is not found", key.GetPointer());
602                 }
603                 else
604                 {
605                         AppLogDebug("ContainsKey fail [%s]", GetErrorMessage(r));
606                 }
607                 return appSettingFilePath;
608         }
609
610         String* pValue = static_cast<String*>(__pAppIdHashMap->GetValue(key));
611         if (pValue == null)
612         {
613                 AppLogDebug("pValue is null");
614                 return appSettingFilePath;
615         }
616
617         appSettingFilePath.Append(*pValue);
618         return appSettingFilePath;
619 }
620
621 Tizen::Base::String
622 DownloadedApplicationForm::GetDownLoadAppNameAt(unsigned int index)
623 {
624         String appName;
625         if (__pDownloadAppIdKeyList == null)
626         {
627                 AppLogDebug("__pDownloadAppIdKeyList is null");
628                 return appName;
629         }
630
631         String* pAppKey = static_cast<String*>(__pDownloadAppIdKeyList->GetAt(index));
632         if (pAppKey == null)
633         {
634                 AppLogDebug("pAppKey is null");
635                 return appName;
636         }
637
638         StringTokenizer stringTokenizer(*pAppKey, L":");
639         result r = stringTokenizer.GetNextToken(appName);
640         if (IsFailed(r))
641         {
642                 AppLogDebug("GetNextToken fail[%s]",GetErrorMessage(r));
643                 return appName;
644         }
645
646         return appName;
647 }
648
649 Tizen::Base::String
650 DownloadedApplicationForm::GetDownLoadAppIdKeyAt(unsigned int index)
651 {
652         String appIdKey;
653         if (__pDownloadAppIdKeyList == null)
654         {
655                 AppLogDebug("__pDownloadAppIdKeyList is null");
656                 return appIdKey;
657         }
658
659         String* pAppKey = static_cast<String*>(__pDownloadAppIdKeyList->GetAt(index));
660         if (pAppKey == null)
661         {
662                 AppLogDebug("pAppKey is null");
663                 return appIdKey;
664         }
665
666         appIdKey.Append(*pAppKey);
667
668         return appIdKey;
669 }
670
671 unsigned int
672 DownloadedApplicationForm::GetDownLoadAppCount(void)
673 {
674         unsigned int downLoadAppCount = 0;
675         if (__pDownloadAppIdKeyList == null)
676         {
677                 AppLogDebug("__pDownloadAppIdKeyList is null");
678                 return downLoadAppCount;
679         }
680
681         downLoadAppCount = __pDownloadAppIdKeyList->GetCount();
682         return downLoadAppCount;
683 }
684
685 Tizen::Base::String
686 DownloadedApplicationForm::GetAppSettingIconPathFromAppIdListAt(Tizen::Base::String& id)
687 {
688         String iconPath;
689
690         if (__pAppIconPathHashMap)
691         {
692                 if (__pAppIconPathHashMap->ContainsKey(id) == true)
693                 {
694                         iconPath = *(static_cast<String*>(__pAppIconPathHashMap->GetValue((id))));
695                 }
696         }
697         return iconPath;
698 }
699
700 void
701 DownloadedApplicationForm::UpdateTableViewAndNoContent(void)
702 {
703         bool createTableView = false;
704         if (__pTableView != null)
705         {
706                 if (GetDownLoadAppCount() != 0)
707                 {
708                         __pTableView->UpdateTableView();
709                         return;
710                 }
711         }
712         else
713         {
714                 if (GetDownLoadAppCount() != 0)
715                 {
716                         createTableView = true;
717                 }
718         }
719
720         if (__pTableView != null)
721         {
722                 int tableViewControlCount = __pTableView->GetControlCount();
723                 for (int i = 0; i < tableViewControlCount; i++)
724                 {
725                         __pTableView->RemoveControl(__pTableView->GetControl(0));
726                 }
727 //                      __pTableView->RemoveAllControls();
728                 __pTableView = null;
729         }
730         int controlCount = GetControlCount();
731         for (int i = 0; i < controlCount; i++)
732         {
733                 RemoveControl(GetControl(0));
734         }
735 //      RemoveAllControls();
736
737         if (createTableView)
738         {
739                 CreateTableView();
740                 __pTableView->UpdateTableView();
741         }
742         else
743         {
744                 Label* pLabel = static_cast<Label*>(this->GetControl(NO_CONTENTS, false));
745                 if (pLabel == null)
746                 {
747                         Rectangle clientRect = GetClientAreaBounds();
748                         Bitmap* pBitmp = ResourceManager::GetBitmapN(IDB_NO_CONTENTS);
749
750                         int bitmapWidth = pBitmp->GetWidth();
751                         int bitmapHeight = pBitmp->GetHeight();
752                         String labelText = ResourceManager::GetString(L"IDS_ST_BODY_NO_CONTENT");
753                         Color textColor = COLOR_HELP_TEXT_TYPE_03_NORMAL;
754                         int noContentTextHeight = GetHeightForStringArea(labelText, bitmapWidth, 32);
755
756                         int xPos = (clientRect.width / LINE_COUNT_2) - (bitmapWidth / DIVIDE_BY_TWO);
757                         int yPos = (clientRect.height / LINE_COUNT_2) - ((bitmapHeight + noContentTextHeight) / DIVIDE_BY_TWO);
758
759                         Label* pLabel = new (std::nothrow) Label();
760                         pLabel->Construct(Rectangle(xPos, yPos, bitmapWidth, bitmapHeight), L"");
761                         pLabel->SetName(NO_CONTENTS);
762                         pLabel->SetBackgroundBitmap(*pBitmp);
763
764                         yPos = yPos + bitmapHeight;
765
766                         Label* pLabelNoContents = new (std::nothrow) Label();
767                         pLabelNoContents->Construct(Rectangle(0, yPos, clientRect.width, noContentTextHeight), L"");
768                         pLabelNoContents->SetName(NO_CONTENTS_TEXT);
769                         pLabelNoContents->SetTextColor(textColor);
770                         pLabelNoContents->SetText(labelText);
771
772                         AddControl(pLabel);
773                         AddControl(pLabelNoContents);
774                 }
775         }
776 }