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