2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file ManifestGenerator.cpp
19 * @brief This is the implementation file for %ManifestGenerator class.
22 #include <unique_ptr.h>
25 #include <FLclLocale.h>
29 #include "ManifestGenerator.h"
30 #include "InstallerUtil.h"
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::App;
35 using namespace Tizen::Locales;
36 using namespace Tizen::Io;
38 ManifestGenerator::ManifestGenerator(void)
44 ManifestGenerator::~ManifestGenerator(void)
51 ManifestGenerator::Construct(InstallationContext* pContext)
53 __pContext = pContext;
55 __pWriter = new (std::nothrow) XmlWriter;
56 TryReturn(__pWriter, false, "__pWriter is null.");
62 ManifestGenerator::Write()
65 String appSetting(L"false");
67 if (__pContext->__isPreloaded == true)
69 location = L"internal-only";
76 String appSettingPath = __pContext->__rootPath + DIR_SETTING;
77 if (File::IsFileExist(appSettingPath) == true)
79 __pContext->__isAppSetting = true;
83 __pWriter->Construct(__pContext->__coreXmlPath);
85 __pWriter->StartElement("manifest");
86 __pWriter->WriteAttribute("xmlns", "http://tizen.org/ns/packages");
87 __pWriter->WriteAttribute("package", __pContext->__packageId);
88 __pWriter->WriteAttribute("type", "tpk");
89 __pWriter->WriteAttribute("version", __pContext->__version);
90 __pWriter->WriteAttribute("install-location", location);
91 __pWriter->WriteAttribute("root_path", __pContext->__rootPath);
92 __pWriter->WriteAttribute("appsetting", appSetting);
94 __pWriter->StartElement("label");
95 __pWriter->WriteString(__pContext->__displayName);
96 __pWriter->EndElement();
98 __pWriter->StartElement("author");
99 __pWriter->EndElement();
101 __pWriter->StartElement("description");
102 __pWriter->WriteString(__pContext->__description);
103 __pWriter->EndElement();
105 WritePrivileges(__pContext->__pPrivilegeList);
107 IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
108 TryReturn(pAppDataList, false, "pAppDataList is null");
110 int appCount = pAppDataList->GetCount();
111 AppLog("Write(): appCount=%d", appCount);
113 for (int i = 0 ; i < appCount; i++)
115 AppData* pAppData = null;
116 pAppDataList->GetAt(i, pAppData);
117 TryReturn(pAppData, false, "pAppData is null");
119 WriteApp(i, pAppData);
121 if (pAppData->__isSubMode == true)
123 AppLog("Write(): pAppData->__isSubMode is detected");
124 WriteSubModeApp(i, pAppData);
128 __pWriter->EndElement();
134 ManifestGenerator::GetGlFrameValue(HashMap* pFeatureList) const
136 if (pFeatureList == null)
138 return "use-system-setting";
141 std::unique_ptr< IMapEnumerator > pEnum(pFeatureList->GetMapEnumeratorN());
142 TryReturn(pEnum, "use-system-setting", "GetMapEnumeratorN() failed. [%s]", GetErrorMessage(GetLastResult()));
144 while (pEnum->MoveNext() == E_SUCCESS)
146 String* pKey = static_cast< String* > (pEnum->GetKey());
147 TryReturn(pEnum, "use-system-setting", "GetKey() failed. [%s]", GetErrorMessage(GetLastResult()));
149 if ((*pKey) == L"HwAcceleration" || (*pKey) == L"GlFrame")
151 String* pValue = static_cast< String* > (pEnum->GetValue());
152 TryReturn(pEnum, "use-system-setting", "GetValue() failed. [%s]", GetErrorMessage(GetLastResult()));
154 if ((*pValue) == L"On")
158 else if ((*pValue) == L"Off")
165 return "use-system-setting";
169 ManifestGenerator::WriteLanguageValue(IMap* pList, const String& element) const
171 TryReturn(pList, false, "pNameList is null.");
173 IMapEnumerator* pMapEnum = pList->GetMapEnumeratorN();
174 while (pMapEnum->MoveNext() == E_SUCCESS)
176 String* pLanguage = null;
177 String* pValue = null;
178 String threeLetterCode;
182 pLanguage = static_cast<String*> (pMapEnum->GetKey());
183 pValue = static_cast<String*> (pMapEnum->GetValue());
185 pLanguage->SubString(0, 3, threeLetterCode);
186 pLanguage->SubString(4, 2, countryCode);
188 LanguageCode code = Locale::StringToLanguageCode(threeLetterCode);
189 String twoLetterLanguage = Locale::LanguageCodeToTwoLetterLanguageCodeString(code);
191 launguage = twoLetterLanguage + L"-" + countryCode;
192 launguage.ToLowerCase();
194 if (((*pLanguage) == L"eng-GB") || ((*pLanguage) == L"eng-US"))
196 __pWriter->StartElement(element);
197 __pWriter->WriteString(*pValue);
198 __pWriter->EndElement();
201 __pWriter->StartElement(element);
202 __pWriter->WriteAttribute("xml:lang", launguage);
203 __pWriter->WriteString(*pValue);
204 __pWriter->EndElement();
212 ManifestGenerator::WriteLiveboxes(AppData* pAppData) const
214 TryReturn(__pContext, false, "__pContext is null.");
215 TryReturn(__pWriter, false, "__pWriter is null.");
216 TryReturn(pAppData, false, "pAppData is null.");
218 ArrayList* pLiveboxDataList = pAppData->__pLiveboxDataList;
219 String label("label");
221 if (pLiveboxDataList == null)
226 for (int j = 0 ; j < pLiveboxDataList->GetCount(); j++)
228 LiveboxData* pLiveboxData = dynamic_cast<LiveboxData*>(pLiveboxDataList->GetAt(j));
229 if (pLiveboxData == null)
231 AppLog("pLiveboxData is null [%d]", j);
235 long long updatePeriod = pLiveboxData->GetUpdatePeriod();
236 String period = LongLong::ToString(updatePeriod/1000);
237 IMap* pLiveboxNameList = pLiveboxData->GetNameList();
238 IMap* pSizeList = pLiveboxData->GetSizeList();
239 String popupEnabled = pLiveboxData->GetPopupEnabled();
240 String primary = pLiveboxData->__default;
242 __pWriter->StartElement("livebox");
244 __pWriter->WriteAttribute("appid", pAppData->__appId + "." + pLiveboxData->GetProviderName());
245 __pWriter->WriteAttribute("period", period);
246 __pWriter->WriteAttribute("pinup", "false");
248 if (primary.IsEmpty() == false)
250 primary.ToLowerCase();
251 __pWriter->WriteAttribute("primary", primary);
254 __pWriter->WriteAttribute("auto_launch", "false");
255 __pWriter->WriteAttribute("abi", "osp");
257 WriteLanguageValue(pLiveboxNameList, label);
259 String menuIcon = pAppData->__mainmenuIcon;
260 if (menuIcon.IsEmpty() == false)
263 GetIconPath(menuIcon, menuIconPath);
265 __pWriter->StartElement("icon");
266 __pWriter->WriteString(menuIconPath);
267 __pWriter->EndElement();
274 __pWriter->StartElement("box");
275 __pWriter->WriteAttribute("type", "buffer");
277 previewDir.Format(1024, L"%ls%ls", __pContext->__rootPath.GetPointer(), DIR_SHARED_RES);
278 WriteLiveboxSizeValue(pSizeList, "size", previewDir);
280 __pWriter->EndElement();
283 if (pLiveboxData->__configurationAppControlAppId.IsEmpty() == false)
285 __pWriter->StartElement("setup");
286 __pWriter->WriteString(pLiveboxData->__configurationAppControlAppId);
287 __pWriter->EndElement();
290 popupEnabled.ToLowerCase();
291 if (popupEnabled == L"true")
293 __pWriter->StartElement("pd");
294 __pWriter->WriteAttribute("type", "buffer");
296 __pWriter->StartElement("size");
297 __pWriter->WriteString("720x250");
298 __pWriter->EndElement();
300 __pWriter->EndElement();
302 __pWriter->EndElement();
309 ManifestGenerator::WriteLiveboxSizeValue(IMap* pList, const String& element, const String& previewDir) const
311 TryReturn(pList, false, "pList is null.");
313 IMapEnumerator* pMapEnum = pList->GetMapEnumeratorN();
314 TryReturn(pMapEnum, true, "pMapEnum is null.");
316 while (pMapEnum->MoveNext() == E_SUCCESS)
318 String* pSize = static_cast<String*> (pMapEnum->GetKey());
319 String* pPriviewImage = static_cast<String*> (pMapEnum->GetValue());
321 __pWriter->StartElement(element);
322 if (pPriviewImage && (pPriviewImage->IsEmpty() == false))
324 String previewImagePath;
325 previewImagePath.Format(1024, L"%ls/%ls", previewDir.GetPointer(), pPriviewImage->GetPointer());
326 __pWriter->WriteAttribute("preview", previewImagePath);
328 __pWriter->WriteString(*pSize);
329 __pWriter->EndElement();
337 ManifestGenerator::WriteAppControl(AppData* pAppData) const
339 TryReturn(pAppData, false, "pAppData is null.");
341 IListT<_AppControlInfo*>* pAppControlImplList = pAppData->__pAppControlImplList;
342 TryReturn(pAppControlImplList, false, "pAppControlImplList is null.");
344 _AppControlInfo* pAppControl = null;
345 pAppControlImplList->GetAt(0, pAppControl);
346 TryReturn(pAppControl, false, "pAppControl is null.");
348 ArrayList* pCapabilityList = pAppControl->GetCapabilityList();
349 TryReturn(pCapabilityList, false, "pCapabilityList is null.");
351 int capaCount = pCapabilityList->GetCount();
352 for (int capaIndex = 0 ; capaIndex < capaCount; capaIndex++)
354 _AppControlCapabilityInfo* pCapability = dynamic_cast<_AppControlCapabilityInfo*>(pCapabilityList->GetAt(capaIndex));
355 if (pCapability == null) continue;
357 String operationId = pCapability->GetOperationId();
359 ArrayList* pResolutionList = pCapability->GetResolutionList();
360 int resCount = pResolutionList->GetCount();
364 __pWriter->StartElement("application-service");
365 __pWriter->StartElement("operation");
366 __pWriter->WriteAttribute("name", operationId);
367 __pWriter->EndElement();
368 __pWriter->EndElement();
372 for (int resIndex = 0 ; resIndex < resCount; resIndex++)
374 __pWriter->StartElement("application-service");
375 __pWriter->StartElement("operation");
376 __pWriter->WriteAttribute("name", operationId);
377 __pWriter->EndElement();
379 _AppControlResolutionInfo* pResolution = dynamic_cast <_AppControlResolutionInfo*>(pResolutionList->GetAt(resIndex));
380 if (pResolution == null) continue;
382 String* pUriScheme = pResolution->GetUriScheme();
383 if (pUriScheme && pUriScheme->IsEmpty() == false)
385 __pWriter->StartElement("uri");
386 __pWriter->WriteAttribute("name", *pUriScheme);
387 __pWriter->EndElement();
390 String* pMimeType = pResolution->GetMimeType();
391 if (pMimeType && pMimeType->IsEmpty() == false)
393 __pWriter->StartElement("mime");
394 __pWriter->WriteAttribute("name", *pMimeType);
395 __pWriter->EndElement();
398 __pWriter->EndElement();
406 ManifestGenerator::WriteCategory(int index) const
408 IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
409 TryReturn(pAppDataList, true, "pAppDataList is null");
411 AppData* pAppData = null;
412 pAppDataList->GetAt(index, pAppData);
413 TryReturn(pAppData, true, "pAppData is null");
415 IListT<String*>* pCategoryList = pAppData->__pCategoryList;
416 TryReturn(pCategoryList, true, "pCategoryList is null");
418 for (int i = 0; i < pCategoryList->GetCount(); i++)
421 pCategoryList->GetAt(i, pStr);
422 TryReturn(pStr, false, "pStr is null");
424 AppLog("WriteCategory(): Category String=[%ls]", pStr->GetPointer());
426 __pWriter->StartElement("category");
427 __pWriter->WriteAttribute("name", *pStr);
428 __pWriter->EndElement();
435 ManifestGenerator::FindCategory(int index, const String& category) const
437 result r = E_SUCCESS;
439 IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
440 TryReturn(pAppDataList, false, "pAppDataList is null");
442 AppData* pAppData = null;
443 r = pAppDataList->GetAt(index, pAppData);
444 TryReturn(pAppData, false, "pAppData is null");
446 IListT<String*>* pCategoryList = pAppData->__pCategoryList;
447 TryReturn(pCategoryList, false, "pCategoryList is null");
449 for (int i = 0; i < pCategoryList->GetCount(); i++)
452 pCategoryList->GetAt(i, pStr);
453 TryReturn(pStr, false, "pStr is null");
455 if (*pStr == category)
457 AppLog("FindCategory(): Category is found=[%ls]", pStr->GetPointer());
467 ManifestGenerator::WriteApp(int index, AppData* pAppData)
469 IMap* pNameList = pAppData->__pNameList;
470 String label("label");
471 String type("c++app");
473 binaryPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_BIN, pAppData->__name.GetPointer());
475 if (pAppData->__main == L"True")
477 WriteLanguageValue(pNameList, label);
479 if (pAppData->__mainmenuIcon.IsEmpty() == false)
482 GetIconPath(pAppData->__mainmenuIcon, iconPath);
484 __pWriter->StartElement("icon");
485 __pWriter->WriteString(iconPath);
486 __pWriter->EndElement();
490 String nodisplay("true");
491 String taskmanage("false");
493 String mainapp("true");
495 if (pAppData->__type == L"UiApp")
497 if (pAppData->__launchingHistoryVisible.IsEmpty() == true)
499 if (pAppData->__mainmenuVisible == true)
501 taskmanage = L"true";
505 taskmanage = L"false";
511 pAppData->__launchingHistoryVisible.ToLowerCase(history);
512 taskmanage = history;
515 if (pAppData->__mainmenuVisible == true)
517 nodisplay = L"false";
524 const char* pCategory = null;
525 pCategory = TIZEN_CATEGORY_IME;
526 if (FindCategory(index, pCategory) == true)
528 AppLog("Write(): [%s] is detected. taskmanage=false, nodisplay=true", pCategory);
529 taskmanage = L"false";
533 pCategory = TIZEN_CATEGORY_HOMESCREEN;
534 if (FindCategory(index, pCategory) == true)
536 AppLog("Write(): [%s] is detected. taskmanage=false", pCategory);
537 taskmanage = L"false";
540 pCategory = TIZEN_CATEGORY_LOCKSCREEN;
541 if (FindCategory(index, pCategory) == true)
543 AppLog("Write(): [%s] is detected. taskmanage=false", pCategory);
544 taskmanage = L"false";
547 pCategory = TIZEN_CATEGORY_MENUSCREEN;
548 if (FindCategory(index, pCategory) == true)
550 AppLog("Write(): [%s] is detected. taskmanage=false", pCategory);
551 taskmanage = L"false";
555 if (pAppData->__main != L"True")
560 HashMap* pFeatureList = pAppData->__pFeatureList;
561 String glFrame = GetGlFrameValue(pFeatureList);
563 __pWriter->StartElement("ui-application");
564 __pWriter->WriteAttribute("appid", pAppData->__appId);
565 __pWriter->WriteAttribute("exec", binaryPath);
566 __pWriter->WriteAttribute("nodisplay", nodisplay);
567 __pWriter->WriteAttribute("taskmanage", taskmanage);
568 __pWriter->WriteAttribute("multiple", "false");
569 __pWriter->WriteAttribute("type", type);
570 __pWriter->WriteAttribute("hw-acceleration", glFrame);
571 __pWriter->WriteAttribute("mainapp", mainapp);
573 if (pAppData->__permissionType.IsEmpty() == false)
575 String type = pAppData->__permissionType;
578 __pWriter->StartElement("permission");
579 __pWriter->WriteAttribute("type", type);
580 __pWriter->EndElement();
583 HashMap* pMetadataMap = pAppData->__pMetadataMap;
584 if (pMetadataMap->GetCount() > 0)
586 WriteMetadata(pMetadataMap);
589 WriteCategory(index);
592 if (pAppInfoImpl->GetType() == L"UiApp")
596 if (pAppInfoImpl->IsMainmenuVisible() == true)
605 __pWriter->StartElement("ui-application");
606 __pWriter->WriteAttribute("appid", pAppInfoImpl->GetPackageName());
607 __pWriter->WriteAttribute("exec", binaryPath);
608 __pWriter->WriteAttribute("nodisplay", nodisplay);
609 __pWriter->WriteAttribute("taskmanage", "true");
610 __pWriter->WriteAttribute("multiple", "false");
611 __pWriter->WriteAttribute("type", type);
613 else if (pAppInfoImpl->GetType() == L"ServiceApp")
615 ArrayList* pFeatureList = pAppInfoImpl->GetAppFeatureList();
616 String onBoot("false");
617 String autoRestart("false");
619 if (FindFeatureValue(pFeatureList, "LaunchOnBoot", "True") == true)
624 if (FindFeatureValue(pFeatureList, "AutoRestart", "True") == true)
626 autoRestart = L"true";
629 __pWriter->StartElement("service-application");
630 __pWriter->WriteAttribute("appid", pAppInfoImpl->GetPackageName());
631 __pWriter->WriteAttribute("exec", binaryPath);
632 __pWriter->WriteAttribute("type", type);
633 __pWriter->WriteAttribute("on-boot", onBoot);
634 __pWriter->WriteAttribute("auto-restart", autoRestart);
638 AppLog("Type is invalid! [%ls]", pAppInfoImpl->GetType().GetPointer());
643 WriteLanguageValue(pNameList, label);
645 if (pAppData->__mainmenuIcon.IsEmpty() == false)
648 GetIconPath(pAppData->__mainmenuIcon, iconPath);
650 __pWriter->StartElement("icon");
651 __pWriter->WriteString(iconPath);
652 __pWriter->EndElement();
655 if (pAppData->__settingIcon.IsEmpty() == false)
658 GetIconPath(pAppData->__settingIcon, iconPath);
660 __pWriter->StartElement("icon");
661 __pWriter->WriteAttribute("section", "setting");
662 __pWriter->WriteString(iconPath);
663 __pWriter->EndElement();
666 if (pAppData->__notificationIcon.IsEmpty() == false)
669 GetIconPath(pAppData->__notificationIcon, iconPath);
671 __pWriter->StartElement("icon");
672 __pWriter->WriteAttribute("section", "notification");
673 __pWriter->WriteString(iconPath);
674 __pWriter->EndElement();
677 if (pAppData->__legacyAppControls == true)
679 AppLog("Write(): AppControls spec is legacy");
680 WriteAppControl(pAppData);
684 WriteAppControl(index);
687 __pWriter->EndElement(); // end of "ui-application"
689 if (pAppData->__type == L"ServiceApp")
691 WriteLiveboxes(pAppData);
694 WriteAccounts(index);
695 WriteNotifications(index);
701 ManifestGenerator::WriteSubModeApp(int index, AppData* pAppData)
703 // SUB_MODE_APPCONTROL_NAME -> AppName
704 String subBinaryPath;
705 subBinaryPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_BIN, SUB_MODE_APPCONTROL_NAME);
708 binaryPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_BIN, pAppData->__subModeAppName.GetPointer());
710 if (File::IsFileExist(subBinaryPath) == true)
712 InstallerUtil::Remove(subBinaryPath);
714 InstallerUtil::CreateSymlink(binaryPath, subBinaryPath);
716 // SUB_MODE_APPCONTROL_NAME.exe -> AppName.exe
717 String subBinaryExecPath = subBinaryPath + ".exe";
718 String binaryExecPath = binaryPath + ".exe";
720 if (File::IsFileExist(subBinaryExecPath) == true)
722 InstallerUtil::Remove(subBinaryExecPath);
724 InstallerUtil::CreateSymlink(binaryExecPath, subBinaryExecPath);
726 PackageId packageId = __pContext->__packageId;
727 AppId appId = packageId + L"." + SUB_MODE_APPCONTROL_NAME;
729 __pWriter->StartElement("ui-application");
730 __pWriter->WriteAttribute("appid", appId);
731 __pWriter->WriteAttribute("exec", subBinaryPath);
732 __pWriter->WriteAttribute("nodisplay", "true");
733 __pWriter->WriteAttribute("taskmanage", "false");
734 __pWriter->WriteAttribute("multiple", "true");
735 __pWriter->WriteAttribute("type", "c++app");
737 __pWriter->StartElement("label");
738 __pWriter->WriteString(__pContext->__displayName);
739 __pWriter->EndElement();
741 if (pAppData->__mainmenuIcon.IsEmpty() == false)
744 GetIconPath(pAppData->__mainmenuIcon, iconPath);
746 __pWriter->StartElement("icon");
747 __pWriter->WriteString(iconPath);
748 __pWriter->EndElement();
751 WriteAppControl(index, true);
753 __pWriter->EndElement(); // end of "ui-application"
759 ManifestGenerator::WriteAppControl(int index, bool subMode)
761 IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
762 TryReturn(pAppDataList, false, "pAppDataList is null");
764 AppData* pAppData = null;
765 pAppDataList->GetAt(index, pAppData);
766 TryReturn(pAppData, false, "pAppData is null");
768 IListT<AppControlData*>* pAppControlDataList = null;
770 if (subMode == false)
772 pAppControlDataList = pAppData->__pAppControlDataList;
773 TryReturn(pAppControlDataList, false, "pAppControlDataList is null");
777 pAppControlDataList = pAppData->__pSubModeAppControlDataList;
778 TryReturn(pAppControlDataList, false, "pAppControlDataList is null");
781 for (int i = 0; i < pAppControlDataList->GetCount(); i++)
783 __pWriter->StartElement("application-service");
785 AppControlData* pAppControlData = null;
786 pAppControlDataList->GetAt(i, pAppControlData);
787 TryReturn(pAppControlData, false, "pAppControlData is null");
789 IListT<String*>* pOperationList = pAppControlData->__pOperationList;
790 TryReturn(pOperationList, false, "pOperationList is null");
791 for (int sub = 0; sub < pOperationList->GetCount(); sub++)
793 String* pOperation = null;
794 pOperationList->GetAt(sub, pOperation);
795 TryReturn(pOperation, false, "pOperation is null");
797 __pWriter->StartElement("operation");
798 __pWriter->WriteAttribute("name", *pOperation);
799 __pWriter->EndElement(); // end of "operation"
802 IListT<String*>* pMimeTypeList = pAppControlData->__pMimeTypeList;
803 TryReturn(pMimeTypeList, false, "pMimeTypeList is null");
804 for (int sub = 0; sub < pMimeTypeList->GetCount(); sub++)
806 String* pMimeType = null;
807 pMimeTypeList->GetAt(sub, pMimeType);
808 TryReturn(pMimeType, false, "pMimeType is null");
810 if (pMimeType->IsEmpty() == true) continue;
812 __pWriter->StartElement("mime");
813 __pWriter->WriteAttribute("name", *pMimeType);
814 __pWriter->EndElement(); // end of "mime"
817 IListT<String*>* pUriList = pAppControlData->__pUriList;
818 TryReturn(pUriList, false, "pUriList is null");
819 for (int sub = 0; sub < pUriList->GetCount(); sub++)
822 pUriList->GetAt(sub, pUri);
823 TryReturn(pUri, false, "pUri is null");
825 if (pUri->IsEmpty() == true) continue;
827 __pWriter->StartElement("uri");
828 __pWriter->WriteAttribute("name", *pUri);
829 __pWriter->EndElement(); // end of "uri"
832 __pWriter->EndElement(); // end of "application-service"
839 ManifestGenerator::WriteAccounts(int index)
841 IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
842 TryReturn(pAppDataList, false, "pAppDataList is null");
844 AppData* pAppData = null;
845 pAppDataList->GetAt(index, pAppData);
846 TryReturn(pAppData, false, "pAppData is null");
848 IListT<AccountData*>* pAccountDataList = pAppData->__pAccountDataList;
849 TryReturn(pAccountDataList, false, "pAccountDataList is null");
851 int accountCount = pAccountDataList->GetCount();
852 if (accountCount <= 0)
857 __pWriter->StartElement("account");
859 for (int i = 0; i < accountCount; i++)
861 __pWriter->StartElement("account-provider");
863 AccountData* pAccountData = null;
864 pAccountDataList->GetAt(i, pAccountData);
865 TryReturn(pAccountData, false, "pAccountData is null");
867 String multipleAccountsSupport = pAccountData->__multipleAccountsSupport;
868 multipleAccountsSupport.ToLowerCase();
870 __pWriter->WriteAttribute("appid", pAppData->__appId);
871 __pWriter->WriteAttribute("providerid", pAccountData->__providerId);
872 __pWriter->WriteAttribute("multiple-accounts-support", multipleAccountsSupport);
874 String accountIcon = pAccountData->__accountIcon;
875 if (accountIcon.IsEmpty() == false)
877 String accountIconPath;
878 accountIconPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_SHARED_RES, accountIcon.GetPointer());
880 __pWriter->StartElement("icon");
881 __pWriter->WriteAttribute("section", "account");
882 __pWriter->WriteString(accountIconPath);
883 __pWriter->EndElement();
886 String accountSmallIcon = pAccountData->__accountSmallIcon;
887 if (accountSmallIcon.IsEmpty() == false)
889 String accountSmallIconPath;
890 accountSmallIconPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_SHARED_RES, accountSmallIcon.GetPointer());
892 __pWriter->StartElement("icon");
893 __pWriter->WriteAttribute("section", "account-small");
894 __pWriter->WriteString(accountSmallIconPath);
895 __pWriter->EndElement();
898 WriteLanguageValue(pAccountData->__pNameList, L"label");
900 IListT<String*>* pCapabilityList = pAccountData->__pCapabilityList;
901 TryReturn(pCapabilityList, false, "pCapabilityList is null");
903 for (int capa = 0; capa < pCapabilityList->GetCount(); capa++)
905 String* pCapability = null;
906 pCapabilityList->GetAt(capa, pCapability);
907 TryReturn(pCapability, false, "pCapability is null");
909 __pWriter->StartElement("capability");
910 __pWriter->WriteString(*pCapability);
911 __pWriter->EndElement(); // end of "capability"
914 __pWriter->EndElement(); // end of "account-provider"
917 __pWriter->EndElement(); // end of "account"
923 ManifestGenerator::WriteNotifications(int index)
925 IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
926 TryReturn(pAppDataList, false, "pAppDataList is null");
928 AppData* pAppData = null;
929 pAppDataList->GetAt(index, pAppData);
930 TryReturn(pAppData, false, "pAppData is null");
932 HashMap* pNotificationMap = pAppData->__pNotificationMap;
933 TryReturn(pNotificationMap, false, "pNotificationMap is null");
935 int count = pNotificationMap->GetCount();
941 IMapEnumerator* pMapEnum = pNotificationMap->GetMapEnumeratorN();
942 TryReturn(pMapEnum, false, "pMapEnum is null");
944 __pWriter->StartElement("notifications");
945 __pWriter->WriteAttribute("appid", pAppData->__appId);
947 while (pMapEnum->MoveNext() == E_SUCCESS)
950 String* pValue = null;
952 pKey = static_cast<String*> (pMapEnum->GetKey());
953 pValue = static_cast<String*> (pMapEnum->GetValue());
955 __pWriter->StartElement("notification");
956 __pWriter->WriteAttribute("section", *pKey);
957 __pWriter->WriteString(*pValue);
958 __pWriter->EndElement(); // end of "notification"
961 __pWriter->EndElement(); // end of "notifications"
968 ManifestGenerator::WriteMetadata(HashMap* pMetadataMap)
970 std::unique_ptr< IMapEnumerator > pEnum(pMetadataMap->GetMapEnumeratorN());
971 TryReturn(pEnum, false, "GetMapEnumeratorN() failed. [%s]", GetErrorMessage(GetLastResult()));
973 while (pEnum->MoveNext() == E_SUCCESS)
975 String* pKey = static_cast< String* > (pEnum->GetKey());
976 TryReturn(pEnum, false, "GetKey() failed. [%s]", GetErrorMessage(GetLastResult()));
978 String* pValue = static_cast< String* > (pEnum->GetValue());
979 TryReturn(pEnum, false, "GetValue() failed. [%s]", GetErrorMessage(GetLastResult()));
981 __pWriter->StartElement("metadata");
982 __pWriter->WriteAttribute("key", *pKey);
983 __pWriter->WriteAttribute("value", *pValue);
984 __pWriter->EndElement();
991 ManifestGenerator::WritePrivileges(ArrayList* pPrivilegeList)
993 if (pPrivilegeList == null)
998 __pWriter->StartElement("privileges");
1000 for (int i = 0; i < pPrivilegeList->GetCount(); i++)
1002 String* pPrivilege = dynamic_cast < String* >(pPrivilegeList->GetAt(i));
1005 __pWriter->StartElement("privilege");
1006 __pWriter->WriteString(*pPrivilege);
1007 __pWriter->EndElement();
1011 __pWriter->EndElement();
1017 ManifestGenerator::GetIconPath(const String& icon, String& iconPath) const
1019 String tempIconPath;
1020 tempIconPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_SHARED_RES, icon.GetPointer());
1022 if (File::IsFileExist(tempIconPath) == false)
1024 AppLog("fallback, old path = [%ls]", tempIconPath.GetPointer());
1026 String densityXhigh("screen-density-xhigh/");
1027 String densityHigh("screen-density-high/");
1029 if (icon.Contains(densityXhigh) == true)
1031 tempIconPath.Replace(densityXhigh, densityHigh);
1033 else if (icon.Contains(densityHigh) == true)
1035 tempIconPath.Replace(densityHigh, densityXhigh);
1039 AppLog("invalid icon [%ls]", icon.GetPointer());
1043 AppLog("fallback, new path = [%ls]", tempIconPath.GetPointer());
1045 if (File::IsFileExist(tempIconPath) == false)
1047 AppLog("fallback, but file is not found. [%ls]", tempIconPath.GetPointer());
1052 iconPath = tempIconPath;
1054 AppLog("icon[%ls], iconPath[%ls]", icon.GetPointer(), iconPath.GetPointer());