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");
125 if (pAppData->__isSubModeAllowed == true)
127 AppLog("Write(): WriteSubModeApp()");
128 WriteSubModeApp(i, pAppData);
132 AppLog("Write(): WriteSubModeApp() is skipped because __isSubModeAllowed is false.");
137 __pWriter->EndElement();
143 ManifestGenerator::GetGlFrameValue(HashMap* pFeatureList) const
145 if (pFeatureList == null)
147 return "use-system-setting";
150 std::unique_ptr< IMapEnumerator > pEnum(pFeatureList->GetMapEnumeratorN());
151 TryReturn(pEnum, "use-system-setting", "GetMapEnumeratorN() failed. [%s]", GetErrorMessage(GetLastResult()));
153 while (pEnum->MoveNext() == E_SUCCESS)
155 String* pKey = static_cast< String* > (pEnum->GetKey());
156 TryReturn(pKey, "use-system-setting", "GetKey() failed. [%s]", GetErrorMessage(GetLastResult()));
158 if ((*pKey) == L"HwAcceleration" || (*pKey) == L"GlFrame")
160 String* pValue = static_cast< String* > (pEnum->GetValue());
161 TryReturn(pValue, "use-system-setting", "GetValue() failed. [%s]", GetErrorMessage(GetLastResult()));
163 if ((*pValue) == L"On")
167 else if ((*pValue) == L"Off")
174 return "use-system-setting";
178 ManifestGenerator::WriteLanguageValue(IMap* pList, const String& element) const
180 TryReturn(pList, false, "pNameList is null.");
182 IMapEnumerator* pMapEnum = pList->GetMapEnumeratorN();
183 while (pMapEnum->MoveNext() == E_SUCCESS)
185 String* pLanguage = null;
186 String* pValue = null;
187 String threeLetterCode;
191 pLanguage = static_cast<String*> (pMapEnum->GetKey());
192 pValue = static_cast<String*> (pMapEnum->GetValue());
194 pLanguage->SubString(0, 3, threeLetterCode);
195 pLanguage->SubString(4, 2, countryCode);
197 LanguageCode code = Locale::StringToLanguageCode(threeLetterCode);
198 String twoLetterLanguage = Locale::LanguageCodeToTwoLetterLanguageCodeString(code);
200 launguage = twoLetterLanguage + L"-" + countryCode;
201 launguage.ToLowerCase();
203 if (((*pLanguage) == L"eng-GB") || ((*pLanguage) == L"eng-US"))
205 __pWriter->StartElement(element);
206 __pWriter->WriteString(*pValue);
207 __pWriter->EndElement();
210 __pWriter->StartElement(element);
211 __pWriter->WriteAttribute("xml:lang", launguage);
212 __pWriter->WriteString(*pValue);
213 __pWriter->EndElement();
221 ManifestGenerator::WriteLiveboxes(AppData* pAppData) const
223 TryReturn(__pContext, false, "__pContext is null.");
224 TryReturn(__pWriter, false, "__pWriter is null.");
225 TryReturn(pAppData, false, "pAppData is null.");
227 ArrayList* pLiveboxDataList = pAppData->__pLiveboxDataList;
228 String label("label");
230 if (pLiveboxDataList == null)
235 for (int j = 0 ; j < pLiveboxDataList->GetCount(); j++)
237 LiveboxData* pLiveboxData = dynamic_cast<LiveboxData*>(pLiveboxDataList->GetAt(j));
238 if (pLiveboxData == null)
240 AppLog("pLiveboxData is null [%d]", j);
244 long long updatePeriod = pLiveboxData->GetUpdatePeriod();
245 String period = LongLong::ToString(updatePeriod/1000);
246 IMap* pLiveboxNameList = pLiveboxData->GetNameList();
247 IMap* pSizeList = pLiveboxData->GetSizeList();
248 String popupEnabled = pLiveboxData->GetPopupEnabled();
249 String primary = pLiveboxData->__default;
251 __pWriter->StartElement("livebox");
253 __pWriter->WriteAttribute("appid", pAppData->__appId + "." + pLiveboxData->GetProviderName());
254 __pWriter->WriteAttribute("period", period);
255 __pWriter->WriteAttribute("pinup", "false");
257 if (primary.IsEmpty() == false)
259 primary.ToLowerCase();
260 __pWriter->WriteAttribute("primary", primary);
263 __pWriter->WriteAttribute("auto_launch", "false");
264 __pWriter->WriteAttribute("abi", "osp");
266 WriteLanguageValue(pLiveboxNameList, label);
268 String menuIcon = pAppData->__menuIcon;
269 if (menuIcon.IsEmpty() == false)
272 GetIconPath(menuIcon, menuIconPath);
274 __pWriter->StartElement("icon");
275 __pWriter->WriteString(menuIconPath);
276 __pWriter->EndElement();
283 __pWriter->StartElement("box");
284 __pWriter->WriteAttribute("type", "buffer");
286 previewDir.Format(1024, L"%ls%ls", __pContext->__rootPath.GetPointer(), DIR_SHARED_RES);
287 WriteLiveboxSizeValue(pSizeList, "size", previewDir);
289 __pWriter->EndElement();
292 if (pLiveboxData->__configurationAppControlAppId.IsEmpty() == false)
294 __pWriter->StartElement("setup");
295 __pWriter->WriteString(pLiveboxData->__configurationAppControlAppId);
296 __pWriter->EndElement();
299 popupEnabled.ToLowerCase();
300 if (popupEnabled == L"true")
302 __pWriter->StartElement("pd");
303 __pWriter->WriteAttribute("type", "buffer");
305 __pWriter->StartElement("size");
306 __pWriter->WriteString("720x250");
307 __pWriter->EndElement();
309 __pWriter->EndElement();
311 __pWriter->EndElement();
318 ManifestGenerator::WriteLiveboxSizeValue(IMap* pList, const String& element, const String& previewDir) const
320 TryReturn(pList, false, "pList is null.");
322 IMapEnumerator* pMapEnum = pList->GetMapEnumeratorN();
323 TryReturn(pMapEnum, true, "pMapEnum is null.");
325 while (pMapEnum->MoveNext() == E_SUCCESS)
327 String* pSize = static_cast<String*> (pMapEnum->GetKey());
328 String* pPriviewImage = static_cast<String*> (pMapEnum->GetValue());
330 __pWriter->StartElement(element);
331 if (pPriviewImage && (pPriviewImage->IsEmpty() == false))
333 String previewImagePath;
334 previewImagePath.Format(1024, L"%ls/%ls", previewDir.GetPointer(), pPriviewImage->GetPointer());
335 __pWriter->WriteAttribute("preview", previewImagePath);
337 __pWriter->WriteString(*pSize);
338 __pWriter->EndElement();
346 ManifestGenerator::WriteAppControl(AppData* pAppData) const
348 TryReturn(pAppData, false, "pAppData is null.");
350 IListT<_AppControlInfo*>* pAppControlImplList = pAppData->__pAppControlImplList;
351 TryReturn(pAppControlImplList, false, "pAppControlImplList is null.");
353 _AppControlInfo* pAppControl = null;
354 pAppControlImplList->GetAt(0, pAppControl);
355 TryReturn(pAppControl, false, "pAppControl is null.");
357 ArrayList* pCapabilityList = pAppControl->GetCapabilityList();
358 TryReturn(pCapabilityList, false, "pCapabilityList is null.");
360 int capaCount = pCapabilityList->GetCount();
361 for (int capaIndex = 0 ; capaIndex < capaCount; capaIndex++)
363 _AppControlCapabilityInfo* pCapability = dynamic_cast<_AppControlCapabilityInfo*>(pCapabilityList->GetAt(capaIndex));
364 if (pCapability == null) continue;
366 String operationId = pCapability->GetOperationId();
368 ArrayList* pResolutionList = pCapability->GetResolutionList();
369 int resCount = pResolutionList->GetCount();
373 __pWriter->StartElement("application-service");
374 __pWriter->StartElement("operation");
375 __pWriter->WriteAttribute("name", operationId);
376 __pWriter->EndElement();
377 __pWriter->EndElement();
381 for (int resIndex = 0 ; resIndex < resCount; resIndex++)
383 __pWriter->StartElement("application-service");
384 __pWriter->StartElement("operation");
385 __pWriter->WriteAttribute("name", operationId);
386 __pWriter->EndElement();
388 _AppControlResolutionInfo* pResolution = dynamic_cast <_AppControlResolutionInfo*>(pResolutionList->GetAt(resIndex));
389 if (pResolution == null) continue;
391 String* pUriScheme = pResolution->GetUriScheme();
392 if (pUriScheme && pUriScheme->IsEmpty() == false)
394 __pWriter->StartElement("uri");
395 __pWriter->WriteAttribute("name", *pUriScheme);
396 __pWriter->EndElement();
399 String* pMimeType = pResolution->GetMimeType();
400 if (pMimeType && pMimeType->IsEmpty() == false)
402 __pWriter->StartElement("mime");
403 __pWriter->WriteAttribute("name", *pMimeType);
404 __pWriter->EndElement();
407 __pWriter->EndElement();
415 ManifestGenerator::WriteCategory(int index) const
417 IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
418 TryReturn(pAppDataList, true, "pAppDataList is null");
420 AppData* pAppData = null;
421 pAppDataList->GetAt(index, pAppData);
422 TryReturn(pAppData, true, "pAppData is null");
424 IListT<String*>* pCategoryList = pAppData->__pCategoryList;
425 TryReturn(pCategoryList, true, "pCategoryList is null");
427 for (int i = 0; i < pCategoryList->GetCount(); i++)
430 pCategoryList->GetAt(i, pStr);
431 TryReturn(pStr, false, "pStr is null");
433 AppLog("WriteCategory(): Category String=[%ls]", pStr->GetPointer());
435 __pWriter->StartElement("category");
436 __pWriter->WriteAttribute("name", *pStr);
437 __pWriter->EndElement();
444 ManifestGenerator::FindCategory(int index, const String& category) const
446 result r = E_SUCCESS;
448 IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
449 TryReturn(pAppDataList, false, "pAppDataList is null");
451 AppData* pAppData = null;
452 r = pAppDataList->GetAt(index, pAppData);
453 TryReturn(pAppData, false, "pAppData is null");
455 IListT<String*>* pCategoryList = pAppData->__pCategoryList;
456 TryReturn(pCategoryList, false, "pCategoryList is null");
458 for (int i = 0; i < pCategoryList->GetCount(); i++)
461 pCategoryList->GetAt(i, pStr);
462 TryReturn(pStr, false, "pStr is null");
464 if (*pStr == category)
466 AppLog("FindCategory(): Category is found=[%ls]", pStr->GetPointer());
476 ManifestGenerator::WriteApp(int index, AppData* pAppData)
478 IMap* pNameList = pAppData->__pNameList;
479 String label("label");
480 String type("c++app");
482 binaryPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_BIN, pAppData->__name.GetPointer());
484 if (pAppData->__main.Equals(L"True", false) == true)
486 WriteLanguageValue(pNameList, label);
488 if (pAppData->__menuIcon.IsEmpty() == false)
491 GetIconPath(pAppData->__menuIcon, iconPath);
493 __pWriter->StartElement("icon");
494 __pWriter->WriteString(iconPath);
495 __pWriter->EndElement();
499 String nodisplay("true");
500 String taskmanage("false");
502 String mainapp("true");
504 if (pAppData->__type == L"UiApp")
506 if (pAppData->__launchingHistoryVisible.IsEmpty() == true)
508 if (pAppData->__menuIconVisible == true)
510 taskmanage = L"true";
514 taskmanage = L"false";
520 pAppData->__launchingHistoryVisible.ToLowerCase(history);
521 taskmanage = history;
524 if (pAppData->__menuIconVisible == true)
526 nodisplay = L"false";
533 const char* pCategory = null;
534 pCategory = TIZEN_CATEGORY_IME;
535 if (FindCategory(index, pCategory) == true)
537 AppLog("Write(): [%s] is detected. taskmanage=false, nodisplay=true", pCategory);
538 taskmanage = L"false";
542 pCategory = TIZEN_CATEGORY_HOMESCREEN;
543 if (FindCategory(index, pCategory) == true)
545 AppLog("Write(): [%s] is detected. taskmanage=false", pCategory);
546 taskmanage = L"false";
549 pCategory = TIZEN_CATEGORY_LOCKSCREEN;
550 if (FindCategory(index, pCategory) == true)
552 AppLog("Write(): [%s] is detected. taskmanage=false", pCategory);
553 taskmanage = L"false";
556 pCategory = TIZEN_CATEGORY_MENUSCREEN;
557 if (FindCategory(index, pCategory) == true)
559 AppLog("Write(): [%s] is detected. taskmanage=false", pCategory);
560 taskmanage = L"false";
564 if (pAppData->__main != L"True")
569 HashMap* pFeatureList = pAppData->__pFeatureList;
570 String glFrame = GetGlFrameValue(pFeatureList);
572 __pWriter->StartElement("ui-application");
573 __pWriter->WriteAttribute("appid", pAppData->__appId);
574 __pWriter->WriteAttribute("exec", binaryPath);
575 __pWriter->WriteAttribute("nodisplay", nodisplay);
576 __pWriter->WriteAttribute("taskmanage", taskmanage);
577 __pWriter->WriteAttribute("multiple", "false");
578 __pWriter->WriteAttribute("type", type);
579 __pWriter->WriteAttribute("hw-acceleration", glFrame);
580 __pWriter->WriteAttribute("mainapp", mainapp);
582 if (pAppData->__permissionType.IsEmpty() == false)
584 String type = pAppData->__permissionType;
587 __pWriter->StartElement("permission");
588 __pWriter->WriteAttribute("type", type);
589 __pWriter->EndElement();
592 HashMap* pMetadataMap = pAppData->__pMetadataMap;
593 if (pMetadataMap->GetCount() > 0)
595 WriteMetadata(pMetadataMap);
598 WriteCategory(index);
601 if (pAppInfoImpl->GetType() == L"UiApp")
605 if (pAppInfoImpl->IsMainmenuVisible() == true)
614 __pWriter->StartElement("ui-application");
615 __pWriter->WriteAttribute("appid", pAppInfoImpl->GetPackageName());
616 __pWriter->WriteAttribute("exec", binaryPath);
617 __pWriter->WriteAttribute("nodisplay", nodisplay);
618 __pWriter->WriteAttribute("taskmanage", "true");
619 __pWriter->WriteAttribute("multiple", "false");
620 __pWriter->WriteAttribute("type", type);
622 else if (pAppInfoImpl->GetType() == L"ServiceApp")
624 ArrayList* pFeatureList = pAppInfoImpl->GetAppFeatureList();
625 String onBoot("false");
626 String autoRestart("false");
628 if (FindFeatureValue(pFeatureList, "LaunchOnBoot", "True") == true)
633 if (FindFeatureValue(pFeatureList, "AutoRestart", "True") == true)
635 autoRestart = L"true";
638 __pWriter->StartElement("service-application");
639 __pWriter->WriteAttribute("appid", pAppInfoImpl->GetPackageName());
640 __pWriter->WriteAttribute("exec", binaryPath);
641 __pWriter->WriteAttribute("type", type);
642 __pWriter->WriteAttribute("on-boot", onBoot);
643 __pWriter->WriteAttribute("auto-restart", autoRestart);
647 AppLog("Type is invalid! [%ls]", pAppInfoImpl->GetType().GetPointer());
652 WriteLanguageValue(pNameList, label);
654 if (pAppData->__menuIcon.IsEmpty() == false)
657 GetIconPath(pAppData->__menuIcon, iconPath);
659 __pWriter->StartElement("icon");
660 __pWriter->WriteString(iconPath);
661 __pWriter->EndElement();
664 if (pAppData->__settingIcon.IsEmpty() == false)
667 GetIconPath(pAppData->__settingIcon, iconPath);
669 __pWriter->StartElement("icon");
670 __pWriter->WriteAttribute("section", "setting");
671 __pWriter->WriteString(iconPath);
672 __pWriter->EndElement();
675 if (pAppData->__notificationIcon.IsEmpty() == false)
678 GetIconPath(pAppData->__notificationIcon, iconPath);
680 __pWriter->StartElement("icon");
681 __pWriter->WriteAttribute("section", "notification");
682 __pWriter->WriteString(iconPath);
683 __pWriter->EndElement();
686 if (pAppData->__legacyAppControls == true)
688 AppLog("Write(): AppControls spec is legacy");
689 WriteAppControl(pAppData);
693 WriteAppControl(index);
696 __pWriter->EndElement(); // end of "ui-application"
698 if (pAppData->__type == L"ServiceApp")
700 WriteLiveboxes(pAppData);
703 WriteAccounts(index);
704 WriteNotifications(index);
710 ManifestGenerator::WriteSubModeApp(int index, AppData* pAppData)
712 // SUB_MODE_APPCONTROL_NAME -> AppName
713 String subBinaryPath;
714 subBinaryPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_BIN, SUB_MODE_APPCONTROL_NAME);
717 binaryPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_BIN, pAppData->__subModeAppName.GetPointer());
719 if (File::IsFileExist(subBinaryPath) == true)
721 InstallerUtil::Remove(subBinaryPath);
723 InstallerUtil::CreateSymlink(binaryPath, subBinaryPath);
725 // SUB_MODE_APPCONTROL_NAME.exe -> AppName.exe
726 String subBinaryExecPath = subBinaryPath + ".exe";
727 String binaryExecPath = binaryPath + ".exe";
729 if (File::IsFileExist(subBinaryExecPath) == true)
731 InstallerUtil::Remove(subBinaryExecPath);
733 InstallerUtil::CreateSymlink(binaryExecPath, subBinaryExecPath);
735 PackageId packageId = __pContext->__packageId;
736 AppId appId = packageId + L"." + SUB_MODE_APPCONTROL_NAME;
738 __pWriter->StartElement("ui-application");
739 __pWriter->WriteAttribute("appid", appId);
740 __pWriter->WriteAttribute("exec", subBinaryPath);
741 __pWriter->WriteAttribute("nodisplay", "true");
742 __pWriter->WriteAttribute("taskmanage", "false");
743 __pWriter->WriteAttribute("multiple", "true");
744 __pWriter->WriteAttribute("type", "c++app");
746 __pWriter->StartElement("label");
747 __pWriter->WriteString(__pContext->__displayName);
748 __pWriter->EndElement();
750 if (pAppData->__menuIcon.IsEmpty() == false)
753 GetIconPath(pAppData->__menuIcon, iconPath);
755 __pWriter->StartElement("icon");
756 __pWriter->WriteString(iconPath);
757 __pWriter->EndElement();
760 WriteAppControl(index, true);
762 __pWriter->EndElement(); // end of "ui-application"
768 ManifestGenerator::WriteAppControl(int index, bool subMode)
770 IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
771 TryReturn(pAppDataList, false, "pAppDataList is null");
773 AppData* pAppData = null;
774 pAppDataList->GetAt(index, pAppData);
775 TryReturn(pAppData, false, "pAppData is null");
777 IListT<AppControlData*>* pAppControlDataList = null;
779 if (subMode == false)
781 pAppControlDataList = pAppData->__pAppControlDataList;
782 TryReturn(pAppControlDataList, false, "pAppControlDataList is null");
786 pAppControlDataList = pAppData->__pSubModeAppControlDataList;
787 TryReturn(pAppControlDataList, false, "pAppControlDataList is null");
790 for (int i = 0; i < pAppControlDataList->GetCount(); i++)
792 __pWriter->StartElement("application-service");
794 AppControlData* pAppControlData = null;
795 pAppControlDataList->GetAt(i, pAppControlData);
796 TryReturn(pAppControlData, false, "pAppControlData is null");
798 IListT<String*>* pOperationList = pAppControlData->__pOperationList;
799 TryReturn(pOperationList, false, "pOperationList is null");
800 for (int sub = 0; sub < pOperationList->GetCount(); sub++)
802 String* pOperation = null;
803 pOperationList->GetAt(sub, pOperation);
804 TryReturn(pOperation, false, "pOperation is null");
806 __pWriter->StartElement("operation");
807 __pWriter->WriteAttribute("name", *pOperation);
808 __pWriter->EndElement(); // end of "operation"
811 IListT<String*>* pMimeTypeList = pAppControlData->__pMimeTypeList;
812 TryReturn(pMimeTypeList, false, "pMimeTypeList is null");
813 for (int sub = 0; sub < pMimeTypeList->GetCount(); sub++)
815 String* pMimeType = null;
816 pMimeTypeList->GetAt(sub, pMimeType);
817 TryReturn(pMimeType, false, "pMimeType is null");
819 if (pMimeType->IsEmpty() == true) continue;
821 __pWriter->StartElement("mime");
822 __pWriter->WriteAttribute("name", *pMimeType);
823 __pWriter->EndElement(); // end of "mime"
826 IListT<String*>* pUriList = pAppControlData->__pUriList;
827 TryReturn(pUriList, false, "pUriList is null");
828 for (int sub = 0; sub < pUriList->GetCount(); sub++)
831 pUriList->GetAt(sub, pUri);
832 TryReturn(pUri, false, "pUri is null");
834 if (pUri->IsEmpty() == true) continue;
836 __pWriter->StartElement("uri");
837 __pWriter->WriteAttribute("name", *pUri);
838 __pWriter->EndElement(); // end of "uri"
841 __pWriter->EndElement(); // end of "application-service"
848 ManifestGenerator::WriteAccounts(int index)
850 IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
851 TryReturn(pAppDataList, false, "pAppDataList is null");
853 AppData* pAppData = null;
854 pAppDataList->GetAt(index, pAppData);
855 TryReturn(pAppData, false, "pAppData is null");
857 IListT<AccountData*>* pAccountDataList = pAppData->__pAccountDataList;
858 TryReturn(pAccountDataList, false, "pAccountDataList is null");
860 int accountCount = pAccountDataList->GetCount();
861 if (accountCount <= 0)
866 __pWriter->StartElement("account");
868 for (int i = 0; i < accountCount; i++)
870 __pWriter->StartElement("account-provider");
872 AccountData* pAccountData = null;
873 pAccountDataList->GetAt(i, pAccountData);
874 TryReturn(pAccountData, false, "pAccountData is null");
876 String multipleAccountsSupport = pAccountData->__multipleAccountsSupport;
877 multipleAccountsSupport.ToLowerCase();
879 __pWriter->WriteAttribute("appid", pAppData->__appId);
880 __pWriter->WriteAttribute("providerid", pAccountData->__providerId);
881 __pWriter->WriteAttribute("multiple-accounts-support", multipleAccountsSupport);
883 String accountIcon = pAccountData->__accountIcon;
884 if (accountIcon.IsEmpty() == false)
886 String accountIconPath;
887 accountIconPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_SHARED_RES, accountIcon.GetPointer());
889 __pWriter->StartElement("icon");
890 __pWriter->WriteAttribute("section", "account");
891 __pWriter->WriteString(accountIconPath);
892 __pWriter->EndElement();
895 String accountSmallIcon = pAccountData->__accountSmallIcon;
896 if (accountSmallIcon.IsEmpty() == false)
898 String accountSmallIconPath;
899 accountSmallIconPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_SHARED_RES, accountSmallIcon.GetPointer());
901 __pWriter->StartElement("icon");
902 __pWriter->WriteAttribute("section", "account-small");
903 __pWriter->WriteString(accountSmallIconPath);
904 __pWriter->EndElement();
907 WriteLanguageValue(pAccountData->__pNameList, L"label");
909 IListT<String*>* pCapabilityList = pAccountData->__pCapabilityList;
910 TryReturn(pCapabilityList, false, "pCapabilityList is null");
912 for (int capa = 0; capa < pCapabilityList->GetCount(); capa++)
914 String* pCapability = null;
915 pCapabilityList->GetAt(capa, pCapability);
916 TryReturn(pCapability, false, "pCapability is null");
918 __pWriter->StartElement("capability");
919 __pWriter->WriteString(*pCapability);
920 __pWriter->EndElement(); // end of "capability"
923 __pWriter->EndElement(); // end of "account-provider"
926 __pWriter->EndElement(); // end of "account"
932 ManifestGenerator::WriteNotifications(int index)
934 IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
935 TryReturn(pAppDataList, false, "pAppDataList is null");
937 AppData* pAppData = null;
938 pAppDataList->GetAt(index, pAppData);
939 TryReturn(pAppData, false, "pAppData is null");
941 HashMap* pNotificationMap = pAppData->__pNotificationMap;
942 TryReturn(pNotificationMap, false, "pNotificationMap is null");
944 int count = pNotificationMap->GetCount();
950 IMapEnumerator* pMapEnum = pNotificationMap->GetMapEnumeratorN();
951 TryReturn(pMapEnum, false, "pMapEnum is null");
953 __pWriter->StartElement("notifications");
954 __pWriter->WriteAttribute("appid", pAppData->__appId);
956 while (pMapEnum->MoveNext() == E_SUCCESS)
959 String* pValue = null;
961 pKey = static_cast<String*> (pMapEnum->GetKey());
962 pValue = static_cast<String*> (pMapEnum->GetValue());
964 __pWriter->StartElement("notification");
965 __pWriter->WriteAttribute("section", *pKey);
966 __pWriter->WriteString(*pValue);
967 __pWriter->EndElement(); // end of "notification"
970 __pWriter->EndElement(); // end of "notifications"
977 ManifestGenerator::WriteMetadata(HashMap* pMetadataMap)
979 std::unique_ptr< IMapEnumerator > pEnum(pMetadataMap->GetMapEnumeratorN());
980 TryReturn(pEnum, false, "GetMapEnumeratorN() failed. [%s]", GetErrorMessage(GetLastResult()));
982 while (pEnum->MoveNext() == E_SUCCESS)
984 String* pKey = static_cast< String* > (pEnum->GetKey());
985 TryReturn(pEnum, false, "GetKey() failed. [%s]", GetErrorMessage(GetLastResult()));
987 String* pValue = static_cast< String* > (pEnum->GetValue());
988 TryReturn(pEnum, false, "GetValue() failed. [%s]", GetErrorMessage(GetLastResult()));
990 __pWriter->StartElement("metadata");
991 __pWriter->WriteAttribute("key", *pKey);
992 __pWriter->WriteAttribute("value", *pValue);
993 __pWriter->EndElement();
1000 ManifestGenerator::WritePrivileges(ArrayList* pPrivilegeList)
1002 if (pPrivilegeList == null)
1007 __pWriter->StartElement("privileges");
1009 for (int i = 0; i < pPrivilegeList->GetCount(); i++)
1011 String* pPrivilege = dynamic_cast < String* >(pPrivilegeList->GetAt(i));
1014 __pWriter->StartElement("privilege");
1015 __pWriter->WriteString(*pPrivilege);
1016 __pWriter->EndElement();
1020 __pWriter->EndElement();
1026 ManifestGenerator::GetIconPath(const String& icon, String& iconPath) const
1028 String tempIconPath;
1029 tempIconPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_SHARED_RES, icon.GetPointer());
1031 if (File::IsFileExist(tempIconPath) == false)
1033 AppLog("fallback, old path = [%ls]", tempIconPath.GetPointer());
1035 String densityXhigh("screen-density-xhigh/");
1036 String densityHigh("screen-density-high/");
1038 if (icon.Contains(densityXhigh) == true)
1040 tempIconPath.Replace(densityXhigh, densityHigh);
1042 else if (icon.Contains(densityHigh) == true)
1044 tempIconPath.Replace(densityHigh, densityXhigh);
1048 AppLog("invalid icon [%ls]", icon.GetPointer());
1052 AppLog("fallback, new path = [%ls]", tempIconPath.GetPointer());
1054 if (File::IsFileExist(tempIconPath) == false)
1056 AppLog("fallback, but file is not found. [%ls]", tempIconPath.GetPointer());
1061 iconPath = tempIconPath;
1063 AppLog("icon[%ls], iconPath[%ls]", icon.GetPointer(), iconPath.GetPointer());