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 appSettingXmlPath = __pContext->__rootPath + DIR_SETTING + L"/setting." + __pContext->__version + L".xml";
77 if (File::IsFileExist(appSettingXmlPath) == 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);
93 __pWriter->WriteAttribute("storeclient-id", __pContext->__storeClientId);
95 __pWriter->StartElement("label");
96 __pWriter->WriteString(__pContext->__displayName);
97 __pWriter->EndElement();
99 __pWriter->StartElement("author");
100 __pWriter->EndElement();
102 __pWriter->StartElement("description");
103 __pWriter->WriteString(__pContext->__description);
104 __pWriter->EndElement();
106 WritePrivileges(__pContext->__pPrivilegeList);
108 IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
109 TryReturn(pAppDataList, false, "pAppDataList is null");
111 int appCount = pAppDataList->GetCount();
112 AppLog("Write(): appCount=%d", appCount);
114 for (int i = 0 ; i < appCount; i++)
116 AppData* pAppData = null;
117 pAppDataList->GetAt(i, pAppData);
118 TryReturn(pAppData, false, "pAppData is null");
120 WriteApp(i, pAppData);
122 if (pAppData->__isSubMode == true)
124 AppLog("Write(): pAppData->__isSubMode is detected");
126 if (pAppData->__isSubModeAllowed == true)
128 AppLog("Write(): WriteSubModeApp()");
129 WriteSubModeApp(i, pAppData);
133 AppLog("Write(): WriteSubModeApp() is skipped because __isSubModeAllowed is false.");
138 __pWriter->EndElement();
144 ManifestGenerator::GetGlFrameValue(HashMap* pFeatureList) const
146 if (pFeatureList == null)
148 return "use-system-setting";
151 std::unique_ptr< IMapEnumerator > pEnum(pFeatureList->GetMapEnumeratorN());
152 TryReturn(pEnum, "use-system-setting", "GetMapEnumeratorN() failed. [%s]", GetErrorMessage(GetLastResult()));
154 while (pEnum->MoveNext() == E_SUCCESS)
156 String* pKey = static_cast< String* > (pEnum->GetKey());
157 TryReturn(pKey, "use-system-setting", "GetKey() failed. [%s]", GetErrorMessage(GetLastResult()));
159 if ((*pKey) == L"HwAcceleration" || (*pKey) == L"GlFrame")
161 String* pValue = static_cast< String* > (pEnum->GetValue());
162 TryReturn(pValue, "use-system-setting", "GetValue() failed. [%s]", GetErrorMessage(GetLastResult()));
164 if ((*pValue) == L"On")
168 else if ((*pValue) == L"Off")
175 return "use-system-setting";
179 ManifestGenerator::WriteLanguageValue(IMap* pList, const String& element) const
181 TryReturn(pList, false, "pNameList is null.");
183 IMapEnumerator* pMapEnum = pList->GetMapEnumeratorN();
184 while (pMapEnum->MoveNext() == E_SUCCESS)
186 String* pLanguage = null;
187 String* pValue = null;
188 String threeLetterCode;
192 pLanguage = static_cast<String*> (pMapEnum->GetKey());
193 pValue = static_cast<String*> (pMapEnum->GetValue());
195 pLanguage->SubString(0, 3, threeLetterCode);
196 pLanguage->SubString(4, 2, countryCode);
198 LanguageCode code = Locale::StringToLanguageCode(threeLetterCode);
199 String twoLetterLanguage = Locale::LanguageCodeToTwoLetterLanguageCodeString(code);
201 launguage = twoLetterLanguage + L"-" + countryCode;
202 launguage.ToLowerCase();
204 if (((*pLanguage) == L"eng-GB") || ((*pLanguage) == L"eng-US"))
206 __pWriter->StartElement(element);
207 __pWriter->WriteString(*pValue);
208 __pWriter->EndElement();
211 __pWriter->StartElement(element);
212 __pWriter->WriteAttribute("xml:lang", launguage);
213 __pWriter->WriteString(*pValue);
214 __pWriter->EndElement();
222 ManifestGenerator::WriteLiveboxes(AppData* pAppData) const
224 TryReturn(__pContext, false, "__pContext is null.");
225 TryReturn(__pWriter, false, "__pWriter is null.");
226 TryReturn(pAppData, false, "pAppData is null.");
228 ArrayList* pLiveboxDataList = pAppData->__pLiveboxDataList;
229 String label("label");
231 if (pLiveboxDataList == null)
236 for (int j = 0 ; j < pLiveboxDataList->GetCount(); j++)
238 LiveboxData* pLiveboxData = dynamic_cast<LiveboxData*>(pLiveboxDataList->GetAt(j));
239 if (pLiveboxData == null)
241 AppLog("pLiveboxData is null [%d]", j);
245 long long updatePeriod = pLiveboxData->GetUpdatePeriod();
246 String period = LongLong::ToString(updatePeriod/1000);
247 IMap* pLiveboxNameList = pLiveboxData->GetNameList();
248 IMap* pSizeList = pLiveboxData->GetSizeList();
249 String popupEnabled = pLiveboxData->GetPopupEnabled();
250 String primary = pLiveboxData->__default;
252 __pWriter->StartElement("livebox");
254 __pWriter->WriteAttribute("appid", pAppData->__appId + "." + pLiveboxData->GetProviderName());
255 __pWriter->WriteAttribute("period", period);
256 __pWriter->WriteAttribute("pinup", "false");
258 if (primary.IsEmpty() == false)
260 primary.ToLowerCase();
261 __pWriter->WriteAttribute("primary", primary);
264 __pWriter->WriteAttribute("auto_launch", "false");
265 __pWriter->WriteAttribute("abi", "osp");
267 WriteLanguageValue(pLiveboxNameList, label);
269 String menuIcon = pAppData->__menuIcon;
270 if (menuIcon.IsEmpty() == false)
273 GetIconPath(menuIcon, menuIconPath);
275 __pWriter->StartElement("icon");
276 __pWriter->WriteString(menuIconPath);
277 __pWriter->EndElement();
284 __pWriter->StartElement("box");
285 __pWriter->WriteAttribute("type", "buffer");
287 previewDir.Format(1024, L"%ls%ls", __pContext->__rootPath.GetPointer(), DIR_SHARED_RES);
288 WriteLiveboxSizeValue(pSizeList, "size", previewDir);
290 __pWriter->EndElement();
293 if (pLiveboxData->__configurationAppControlAppId.IsEmpty() == false)
295 __pWriter->StartElement("setup");
296 __pWriter->WriteString(pLiveboxData->__configurationAppControlAppId);
297 __pWriter->EndElement();
300 popupEnabled.ToLowerCase();
301 if (popupEnabled == L"true")
303 __pWriter->StartElement("pd");
304 __pWriter->WriteAttribute("type", "buffer");
306 __pWriter->StartElement("size");
307 __pWriter->WriteString("720x250");
308 __pWriter->EndElement();
310 __pWriter->EndElement();
312 __pWriter->EndElement();
319 ManifestGenerator::IsValidLiveboxSize(const String& size) const
327 else if (size == "4x1"
332 if (__pContext->__privilegeLevel == PRIVILEGE_LEVEL_PLATFORM || __pContext->__isPreloaded == true)
341 ManifestGenerator::WriteLiveboxSizeValue(IMap* pList, const String& element, const String& previewDir) const
343 TryReturn(pList, false, "pList is null.");
345 std::unique_ptr< IMapEnumerator > pMapEnum(pList->GetMapEnumeratorN());
346 TryReturn(pMapEnum, true, "pMapEnum is null.");
348 while (pMapEnum->MoveNext() == E_SUCCESS)
350 String* pSize = static_cast< String* > (pMapEnum->GetKey());
351 TryReturn(pSize, false, "GetKey() failed. [%s]", GetErrorMessage(GetLastResult()));
353 if(IsValidLiveboxSize(*pSize) == false)
355 AppLog("The size %ls is ignored, because it's invalid for privilege level(%d) of the app.", pSize->GetPointer(), __pContext->__privilegeLevel);
359 String* pPriviewImage = static_cast< String* > (pMapEnum->GetValue());
361 __pWriter->StartElement(element);
362 if (pPriviewImage && pPriviewImage->IsEmpty() == false)
364 String previewImagePath;
365 previewImagePath.Format(1024, L"%ls/%ls", previewDir.GetPointer(), pPriviewImage->GetPointer());
366 __pWriter->WriteAttribute("preview", previewImagePath);
368 __pWriter->WriteString(*pSize);
369 __pWriter->EndElement();
376 ManifestGenerator::WriteAppControl(AppData* pAppData) const
378 TryReturn(pAppData, false, "pAppData is null.");
380 IListT<_AppControlInfo*>* pAppControlImplList = pAppData->__pAppControlImplList;
381 TryReturn(pAppControlImplList, false, "pAppControlImplList is null.");
383 _AppControlInfo* pAppControl = null;
384 pAppControlImplList->GetAt(0, pAppControl);
385 TryReturn(pAppControl, false, "pAppControl is null.");
387 ArrayList* pCapabilityList = pAppControl->GetCapabilityList();
388 TryReturn(pCapabilityList, false, "pCapabilityList is null.");
390 int capaCount = pCapabilityList->GetCount();
391 for (int capaIndex = 0 ; capaIndex < capaCount; capaIndex++)
393 _AppControlCapabilityInfo* pCapability = dynamic_cast<_AppControlCapabilityInfo*>(pCapabilityList->GetAt(capaIndex));
394 if (pCapability == null) continue;
396 String operationId = pCapability->GetOperationId();
398 ArrayList* pResolutionList = pCapability->GetResolutionList();
399 int resCount = pResolutionList->GetCount();
403 __pWriter->StartElement("application-service");
404 __pWriter->StartElement("operation");
405 __pWriter->WriteAttribute("name", operationId);
406 __pWriter->EndElement();
407 __pWriter->EndElement();
411 for (int resIndex = 0 ; resIndex < resCount; resIndex++)
413 __pWriter->StartElement("application-service");
414 __pWriter->StartElement("operation");
415 __pWriter->WriteAttribute("name", operationId);
416 __pWriter->EndElement();
418 _AppControlResolutionInfo* pResolution = dynamic_cast <_AppControlResolutionInfo*>(pResolutionList->GetAt(resIndex));
419 if (pResolution == null) continue;
421 String* pUriScheme = pResolution->GetUriScheme();
422 if (pUriScheme && pUriScheme->IsEmpty() == false)
424 __pWriter->StartElement("uri");
425 __pWriter->WriteAttribute("name", *pUriScheme);
426 __pWriter->EndElement();
429 String* pMimeType = pResolution->GetMimeType();
430 if (pMimeType && pMimeType->IsEmpty() == false)
432 __pWriter->StartElement("mime");
433 __pWriter->WriteAttribute("name", *pMimeType);
434 __pWriter->EndElement();
437 __pWriter->EndElement();
445 ManifestGenerator::WriteCategory(int index) const
447 IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
448 TryReturn(pAppDataList, true, "pAppDataList is null");
450 AppData* pAppData = null;
451 pAppDataList->GetAt(index, pAppData);
452 TryReturn(pAppData, true, "pAppData is null");
454 IListT<String*>* pCategoryList = pAppData->__pCategoryList;
455 TryReturn(pCategoryList, true, "pCategoryList is null");
457 for (int i = 0; i < pCategoryList->GetCount(); i++)
460 pCategoryList->GetAt(i, pStr);
461 TryReturn(pStr, false, "pStr is null");
463 AppLog("WriteCategory(): Category String=[%ls]", pStr->GetPointer());
465 __pWriter->StartElement("category");
466 __pWriter->WriteAttribute("name", *pStr);
467 __pWriter->EndElement();
474 ManifestGenerator::FindCategory(int index, const String& category) const
476 result r = E_SUCCESS;
478 IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
479 TryReturn(pAppDataList, false, "pAppDataList is null");
481 AppData* pAppData = null;
482 r = pAppDataList->GetAt(index, pAppData);
483 TryReturn(pAppData, false, "pAppData is null");
485 IListT<String*>* pCategoryList = pAppData->__pCategoryList;
486 TryReturn(pCategoryList, false, "pCategoryList is null");
488 for (int i = 0; i < pCategoryList->GetCount(); i++)
491 pCategoryList->GetAt(i, pStr);
492 TryReturn(pStr, false, "pStr is null");
494 if (*pStr == category)
496 AppLog("FindCategory(): Category is found=[%ls]", pStr->GetPointer());
506 ManifestGenerator::WriteApp(int index, AppData* pAppData)
508 IMap* pNameList = pAppData->__pNameList;
509 String label("label");
510 String type("c++app");
512 binaryPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_BIN, pAppData->__name.GetPointer());
514 if (pAppData->__main.Equals(L"True", false) == true)
516 WriteLanguageValue(pNameList, label);
518 if (pAppData->__menuIcon.IsEmpty() == false)
521 GetIconPath(pAppData->__menuIcon, iconPath);
523 __pWriter->StartElement("icon");
524 __pWriter->WriteString(iconPath);
525 __pWriter->EndElement();
529 String nodisplay("true");
530 String taskmanage("false");
532 String mainapp("true");
534 if (pAppData->__type == L"UiApp")
536 if (pAppData->__launchingHistoryVisible.IsEmpty() == true)
538 if (pAppData->__menuIconVisible == true)
540 taskmanage = L"true";
544 taskmanage = L"false";
550 pAppData->__launchingHistoryVisible.ToLowerCase(history);
551 taskmanage = history;
554 if (pAppData->__menuIconVisible == true)
556 nodisplay = L"false";
563 const char* pCategory = null;
564 pCategory = TIZEN_CATEGORY_IME;
565 if (FindCategory(index, pCategory) == true)
567 AppLog("Write(): [%s] is detected. taskmanage=false, nodisplay=true", pCategory);
568 taskmanage = L"false";
573 if ((pAppData->__main != L"True") || (__pContext->__isHybridService == true))
578 HashMap* pFeatureList = pAppData->__pFeatureList;
579 String glFrame = GetGlFrameValue(pFeatureList);
581 __pWriter->StartElement("ui-application");
582 __pWriter->WriteAttribute("appid", pAppData->__appId);
583 __pWriter->WriteAttribute("exec", binaryPath);
584 __pWriter->WriteAttribute("nodisplay", nodisplay);
585 __pWriter->WriteAttribute("taskmanage", taskmanage);
586 __pWriter->WriteAttribute("multiple", "false");
587 __pWriter->WriteAttribute("type", type);
588 __pWriter->WriteAttribute("hw-acceleration", glFrame);
589 __pWriter->WriteAttribute("mainapp", mainapp);
591 if (pAppData->__permissionType.IsEmpty() == false)
593 String type = pAppData->__permissionType;
596 __pWriter->StartElement("permission");
597 __pWriter->WriteAttribute("type", type);
598 __pWriter->EndElement();
601 HashMap* pMetadataMap = pAppData->__pMetadataMap;
602 if (pMetadataMap->GetCount() > 0)
604 WriteMetadata(pMetadataMap);
607 WriteCategory(index);
610 if (pAppInfoImpl->GetType() == L"UiApp")
614 if (pAppInfoImpl->IsMainmenuVisible() == true)
623 __pWriter->StartElement("ui-application");
624 __pWriter->WriteAttribute("appid", pAppInfoImpl->GetPackageName());
625 __pWriter->WriteAttribute("exec", binaryPath);
626 __pWriter->WriteAttribute("nodisplay", nodisplay);
627 __pWriter->WriteAttribute("taskmanage", "true");
628 __pWriter->WriteAttribute("multiple", "false");
629 __pWriter->WriteAttribute("type", type);
631 else if (pAppInfoImpl->GetType() == L"ServiceApp")
633 ArrayList* pFeatureList = pAppInfoImpl->GetAppFeatureList();
634 String onBoot("false");
635 String autoRestart("false");
637 if (FindFeatureValue(pFeatureList, "LaunchOnBoot", "True") == true)
642 if (FindFeatureValue(pFeatureList, "AutoRestart", "True") == true)
644 autoRestart = L"true";
647 __pWriter->StartElement("service-application");
648 __pWriter->WriteAttribute("appid", pAppInfoImpl->GetPackageName());
649 __pWriter->WriteAttribute("exec", binaryPath);
650 __pWriter->WriteAttribute("type", type);
651 __pWriter->WriteAttribute("on-boot", onBoot);
652 __pWriter->WriteAttribute("auto-restart", autoRestart);
656 AppLog("Type is invalid! [%ls]", pAppInfoImpl->GetType().GetPointer());
661 WriteLanguageValue(pNameList, label);
663 if (pAppData->__menuIcon.IsEmpty() == false)
666 GetIconPath(pAppData->__menuIcon, iconPath);
668 __pWriter->StartElement("icon");
669 __pWriter->WriteString(iconPath);
670 __pWriter->EndElement();
673 if (pAppData->__settingIcon.IsEmpty() == false)
676 GetIconPath(pAppData->__settingIcon, iconPath);
678 __pWriter->StartElement("icon");
679 __pWriter->WriteAttribute("section", "setting");
680 __pWriter->WriteString(iconPath);
681 __pWriter->EndElement();
684 if (pAppData->__notificationIcon.IsEmpty() == false)
687 GetIconPath(pAppData->__notificationIcon, iconPath);
689 __pWriter->StartElement("icon");
690 __pWriter->WriteAttribute("section", "notification");
691 __pWriter->WriteString(iconPath);
692 __pWriter->EndElement();
695 if (pAppData->__legacyAppControls == true)
697 AppLog("Write(): AppControls spec is legacy");
698 WriteAppControl(pAppData);
702 WriteAppControl(index);
705 __pWriter->EndElement(); // end of "ui-application"
707 if (pAppData->__type == L"ServiceApp")
709 WriteLiveboxes(pAppData);
712 WriteAccounts(index);
713 WriteNotifications(index);
719 ManifestGenerator::WriteSubModeApp(int index, AppData* pAppData)
721 // SUB_MODE_APPCONTROL_NAME -> AppName
722 String subBinaryPath;
723 subBinaryPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_BIN, SUB_MODE_APPCONTROL_NAME);
726 binaryPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_BIN, pAppData->__subModeAppName.GetPointer());
728 if (File::IsFileExist(subBinaryPath) == true)
730 InstallerUtil::Remove(subBinaryPath);
732 InstallerUtil::CreateSymlink(binaryPath, subBinaryPath);
734 // SUB_MODE_APPCONTROL_NAME.exe -> AppName.exe
735 String subBinaryExecPath = subBinaryPath + ".exe";
736 String binaryExecPath = binaryPath + ".exe";
738 if (File::IsFileExist(subBinaryExecPath) == true)
740 InstallerUtil::Remove(subBinaryExecPath);
742 InstallerUtil::CreateSymlink(binaryExecPath, subBinaryExecPath);
744 PackageId packageId = __pContext->__packageId;
745 AppId appId = packageId + L"." + SUB_MODE_APPCONTROL_NAME;
747 HashMap* pFeatureList = pAppData->__pFeatureList;
748 String glFrame = GetGlFrameValue(pFeatureList);
750 __pWriter->StartElement("ui-application");
751 __pWriter->WriteAttribute("appid", appId);
752 __pWriter->WriteAttribute("exec", subBinaryPath);
753 __pWriter->WriteAttribute("nodisplay", "true");
754 __pWriter->WriteAttribute("taskmanage", "false");
755 __pWriter->WriteAttribute("multiple", "true");
756 __pWriter->WriteAttribute("type", "c++app");
757 __pWriter->WriteAttribute("hw-acceleration", glFrame);
759 __pWriter->StartElement("label");
760 __pWriter->WriteString(__pContext->__displayName);
761 __pWriter->EndElement();
763 if (pAppData->__menuIcon.IsEmpty() == false)
766 GetIconPath(pAppData->__menuIcon, iconPath);
768 __pWriter->StartElement("icon");
769 __pWriter->WriteString(iconPath);
770 __pWriter->EndElement();
773 WriteAppControl(index, true);
775 __pWriter->EndElement(); // end of "ui-application"
781 ManifestGenerator::WriteAppControl(int index, bool subMode)
783 IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
784 TryReturn(pAppDataList, false, "pAppDataList is null");
786 AppData* pAppData = null;
787 pAppDataList->GetAt(index, pAppData);
788 TryReturn(pAppData, false, "pAppData is null");
790 IListT<AppControlData*>* pAppControlDataList = null;
792 if (subMode == false)
794 pAppControlDataList = pAppData->__pAppControlDataList;
795 TryReturn(pAppControlDataList, false, "pAppControlDataList is null");
799 pAppControlDataList = pAppData->__pSubModeAppControlDataList;
800 TryReturn(pAppControlDataList, false, "pAppControlDataList is null");
803 for (int i = 0; i < pAppControlDataList->GetCount(); i++)
805 __pWriter->StartElement("application-service");
807 AppControlData* pAppControlData = null;
808 pAppControlDataList->GetAt(i, pAppControlData);
809 TryReturn(pAppControlData, false, "pAppControlData is null");
811 IListT<String*>* pOperationList = pAppControlData->__pOperationList;
812 TryReturn(pOperationList, false, "pOperationList is null");
813 for (int sub = 0; sub < pOperationList->GetCount(); sub++)
815 String* pOperation = null;
816 pOperationList->GetAt(sub, pOperation);
817 TryReturn(pOperation, false, "pOperation is null");
819 __pWriter->StartElement("operation");
820 __pWriter->WriteAttribute("name", *pOperation);
821 __pWriter->EndElement(); // end of "operation"
824 IListT<String*>* pMimeTypeList = pAppControlData->__pMimeTypeList;
825 TryReturn(pMimeTypeList, false, "pMimeTypeList is null");
826 for (int sub = 0; sub < pMimeTypeList->GetCount(); sub++)
828 String* pMimeType = null;
829 pMimeTypeList->GetAt(sub, pMimeType);
830 TryReturn(pMimeType, false, "pMimeType is null");
832 if (pMimeType->IsEmpty() == true) continue;
834 __pWriter->StartElement("mime");
835 __pWriter->WriteAttribute("name", *pMimeType);
836 __pWriter->EndElement(); // end of "mime"
839 IListT<String*>* pUriList = pAppControlData->__pUriList;
840 TryReturn(pUriList, false, "pUriList is null");
841 for (int sub = 0; sub < pUriList->GetCount(); sub++)
844 pUriList->GetAt(sub, pUri);
845 TryReturn(pUri, false, "pUri is null");
847 if (pUri->IsEmpty() == true) continue;
849 __pWriter->StartElement("uri");
850 __pWriter->WriteAttribute("name", *pUri);
851 __pWriter->EndElement(); // end of "uri"
854 __pWriter->EndElement(); // end of "application-service"
861 ManifestGenerator::WriteAccounts(int index)
863 IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
864 TryReturn(pAppDataList, false, "pAppDataList is null");
866 AppData* pAppData = null;
867 pAppDataList->GetAt(index, pAppData);
868 TryReturn(pAppData, false, "pAppData is null");
870 IListT<AccountData*>* pAccountDataList = pAppData->__pAccountDataList;
871 TryReturn(pAccountDataList, false, "pAccountDataList is null");
873 int accountCount = pAccountDataList->GetCount();
874 if (accountCount <= 0)
879 __pWriter->StartElement("account");
881 for (int i = 0; i < accountCount; i++)
883 __pWriter->StartElement("account-provider");
885 AccountData* pAccountData = null;
886 pAccountDataList->GetAt(i, pAccountData);
887 TryReturn(pAccountData, false, "pAccountData is null");
889 String multipleAccountsSupport = pAccountData->__multipleAccountsSupport;
890 multipleAccountsSupport.ToLowerCase();
892 __pWriter->WriteAttribute("appid", pAppData->__appId);
893 __pWriter->WriteAttribute("providerid", pAccountData->__providerId);
894 __pWriter->WriteAttribute("multiple-accounts-support", multipleAccountsSupport);
896 String accountIcon = pAccountData->__accountIcon;
897 if (accountIcon.IsEmpty() == false)
899 String accountIconPath;
900 accountIconPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_SHARED_RES, accountIcon.GetPointer());
902 __pWriter->StartElement("icon");
903 __pWriter->WriteAttribute("section", "account");
904 __pWriter->WriteString(accountIconPath);
905 __pWriter->EndElement();
908 String accountSmallIcon = pAccountData->__accountSmallIcon;
909 if (accountSmallIcon.IsEmpty() == false)
911 String accountSmallIconPath;
912 accountSmallIconPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_SHARED_RES, accountSmallIcon.GetPointer());
914 __pWriter->StartElement("icon");
915 __pWriter->WriteAttribute("section", "account-small");
916 __pWriter->WriteString(accountSmallIconPath);
917 __pWriter->EndElement();
920 WriteLanguageValue(pAccountData->__pNameList, L"label");
922 IListT<String*>* pCapabilityList = pAccountData->__pCapabilityList;
923 TryReturn(pCapabilityList, false, "pCapabilityList is null");
925 for (int capa = 0; capa < pCapabilityList->GetCount(); capa++)
927 String* pCapability = null;
928 pCapabilityList->GetAt(capa, pCapability);
929 TryReturn(pCapability, false, "pCapability is null");
931 __pWriter->StartElement("capability");
932 __pWriter->WriteString(*pCapability);
933 __pWriter->EndElement(); // end of "capability"
936 __pWriter->EndElement(); // end of "account-provider"
939 __pWriter->EndElement(); // end of "account"
945 ManifestGenerator::WriteNotifications(int index)
947 IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
948 TryReturn(pAppDataList, false, "pAppDataList is null");
950 AppData* pAppData = null;
951 pAppDataList->GetAt(index, pAppData);
952 TryReturn(pAppData, false, "pAppData is null");
954 HashMap* pNotificationMap = pAppData->__pNotificationMap;
955 TryReturn(pNotificationMap, false, "pNotificationMap is null");
957 int count = pNotificationMap->GetCount();
963 IMapEnumerator* pMapEnum = pNotificationMap->GetMapEnumeratorN();
964 TryReturn(pMapEnum, false, "pMapEnum is null");
966 __pWriter->StartElement("notifications");
967 __pWriter->WriteAttribute("appid", pAppData->__appId);
969 while (pMapEnum->MoveNext() == E_SUCCESS)
972 String* pValue = null;
974 pKey = static_cast<String*> (pMapEnum->GetKey());
975 pValue = static_cast<String*> (pMapEnum->GetValue());
977 __pWriter->StartElement("notification");
978 __pWriter->WriteAttribute("section", *pKey);
979 __pWriter->WriteString(*pValue);
980 __pWriter->EndElement(); // end of "notification"
983 __pWriter->EndElement(); // end of "notifications"
990 ManifestGenerator::WriteMetadata(HashMap* pMetadataMap)
992 std::unique_ptr< IMapEnumerator > pEnum(pMetadataMap->GetMapEnumeratorN());
993 TryReturn(pEnum, false, "GetMapEnumeratorN() failed. [%s]", GetErrorMessage(GetLastResult()));
995 while (pEnum->MoveNext() == E_SUCCESS)
997 String* pKey = static_cast< String* > (pEnum->GetKey());
998 TryReturn(pEnum, false, "GetKey() failed. [%s]", GetErrorMessage(GetLastResult()));
1000 String* pValue = static_cast< String* > (pEnum->GetValue());
1001 TryReturn(pEnum, false, "GetValue() failed. [%s]", GetErrorMessage(GetLastResult()));
1003 __pWriter->StartElement("metadata");
1004 __pWriter->WriteAttribute("key", *pKey);
1005 __pWriter->WriteAttribute("value", *pValue);
1006 __pWriter->EndElement();
1013 ManifestGenerator::WritePrivileges(ArrayList* pPrivilegeList)
1015 if (pPrivilegeList == null)
1020 __pWriter->StartElement("privileges");
1022 for (int i = 0; i < pPrivilegeList->GetCount(); i++)
1024 String* pPrivilege = dynamic_cast < String* >(pPrivilegeList->GetAt(i));
1027 __pWriter->StartElement("privilege");
1028 __pWriter->WriteString(*pPrivilege);
1029 __pWriter->EndElement();
1033 __pWriter->EndElement();
1039 ManifestGenerator::GetIconPath(const String& icon, String& iconPath) const
1041 String tempIconPath;
1042 tempIconPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_SHARED_RES, icon.GetPointer());
1044 if (File::IsFileExist(tempIconPath) == false)
1046 AppLog("fallback, old path = [%ls]", tempIconPath.GetPointer());
1048 String densityXhigh("screen-density-xhigh/");
1049 String densityHigh("screen-density-high/");
1051 if (icon.Contains(densityXhigh) == true)
1053 tempIconPath.Replace(densityXhigh, densityHigh);
1055 else if (icon.Contains(densityHigh) == true)
1057 tempIconPath.Replace(densityHigh, densityXhigh);
1061 AppLog("invalid icon [%ls]", icon.GetPointer());
1065 AppLog("fallback, new path = [%ls]", tempIconPath.GetPointer());
1067 if (File::IsFileExist(tempIconPath) == false)
1069 AppLog("fallback, but file is not found. [%ls]", tempIconPath.GetPointer());
1074 iconPath = tempIconPath;
1076 AppLog("icon[%ls], iconPath[%ls]", icon.GetPointer(), iconPath.GetPointer());