Prevent issues are fixed.
[framework/osp/installer.git] / src / XmlHandler / ManifestGenerator.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17 /**
18  * @file        ManifestGenerator.cpp
19  * @brief       This is the implementation file for %ManifestGenerator class.
20  */
21
22 #include <sys/stat.h>
23
24 #include <FLclLocale.h>
25 #include <FApp_Aul.h>
26 #include <FAppPkg_PackageInfoImpl.h>
27 #include <FIoFile.h>
28
29 #include "ManifestGenerator.h"
30 #include "InstallerUtil.h"
31
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::App;
35 using namespace Tizen::App::Package;
36 using namespace Tizen::Locales;
37 using namespace Tizen::Io;
38
39 ManifestGenerator::ManifestGenerator(void)
40 :__pContext(null)
41 ,__pPackageInfoImpl(null)
42 ,__pWriter(null)
43 {
44 }
45
46 ManifestGenerator::~ManifestGenerator(void)
47 {
48         delete __pWriter;
49         __pWriter = null;
50 }
51
52 bool
53 ManifestGenerator::Construct(InstallationContext* pContext)
54 {
55         __pContext = pContext;
56         __pPackageInfoImpl = pContext->GetPackageInfoImpl();
57
58         __pWriter = new (std::nothrow) XmlWriter;
59         TryReturn(__pWriter, false, "[osp-installer] __pWriter is null.");
60
61         return true;
62 }
63
64 bool
65 ManifestGenerator::Write()
66 {
67         //bool preload = false; //__pContext->IsPreloaded();
68         String xmlPath;
69         String package;
70         String location;
71         _PackageInfoImpl *pPackageInfoImpl = null;
72         pPackageInfoImpl = __pContext->GetPackageInfoImpl();
73         TryReturn(pPackageInfoImpl, false, "[osp-installer] pPackageInfoImpl is null.");
74
75         //if (preload == true)
76         //{
77         //      xmlPath.Format(1024, DIR_RO_PACKAGE_SYSTEM_MANIFEST, __pContext->GetAppId().GetPointer());
78         //      location = L"internal-only";
79         //}
80         //else
81         //{
82         xmlPath.Format(1024, DIR_RW_PACKAGE_SYSTEM_MANIFEST, __pContext->GetAppId().GetPointer());
83         location = L"auto";
84         //}
85
86         package = __pContext->GetAppId();
87
88         __pWriter->Construct(xmlPath);
89
90         __pWriter->StartElement("manifest");
91         __pWriter->WriteAttribute("xmlns", "http://tizen.org/ns/packages");
92         __pWriter->WriteAttribute("package", package);
93         __pWriter->WriteAttribute("type", "tpk");
94         __pWriter->WriteAttribute("version", pPackageInfoImpl->GetAppVersion());
95         __pWriter->WriteAttribute("install-location", location);
96
97         __pWriter->StartElement("label");
98         __pWriter->WriteString(pPackageInfoImpl->GetAppName());
99         __pWriter->EndElement();
100
101         __pWriter->StartElement("author");
102         __pWriter->EndElement();
103
104         __pWriter->StartElement("description");
105         __pWriter->WriteString(pPackageInfoImpl->GetAppDescription());
106         __pWriter->EndElement();
107
108         _PackageAppInfoImpl* pAppInfoImpl = null;
109         ArrayList* pAppList = null;
110         pAppList = pPackageInfoImpl->GetAppInfoList();
111         int appCount = pAppList->GetCount();
112         AppLogTag(OSP_INSTALLER, "Write(): appCount=%d", appCount);
113
114         for (int i = 0 ; i < appCount; i++)
115         {
116                 pAppInfoImpl = dynamic_cast<_PackageAppInfoImpl*>(pAppList->GetAt(i));
117                 if (pAppInfoImpl)
118                 {
119                         WriteApp(i, pAppInfoImpl);
120                 }
121         }
122
123         if (__pContext->__isSubMode == true)
124         {
125                 AppLogTag(OSP_INSTALLER, "Write(): __pContext->__isSubMode is detected");
126                 WriteSubModeApp(appCount);
127         }
128
129         __pWriter->EndElement();
130
131         return true;
132 }
133
134 bool
135 ManifestGenerator::FindFeatureValue(ArrayList* pFeatureList, const String& feature, const String& value) const
136 {
137         TryReturn(pFeatureList, false, "[osp-installer] pFeatureList is null.");
138
139         _AppFeatureInfoImpl* pFeature = null;
140
141         for (int i = 0 ; i < pFeatureList->GetCount(); i++)
142         {
143                 pFeature = dynamic_cast<_AppFeatureInfoImpl*>(pFeatureList->GetAt(i));
144                 if (pFeature)
145                 {
146                         if ((pFeature->GetName() == feature) && (pFeature->GetValue() == value))
147                         {
148                                 AppLogTag(OSP_INSTALLER, "Find - feature=[%ls], value=[%ls]", feature.GetPointer(), value.GetPointer());
149                                 return true;
150                         }
151                 }
152         }
153
154         return false;
155 }
156
157 String
158 ManifestGenerator::GetGlFrameValue(ArrayList* pFeatureList) const
159 {
160         if (pFeatureList == null)
161         {
162                 return "use-system-setting";
163         }
164
165         _AppFeatureInfoImpl* pFeature = null;
166         for (int i = 0 ; i < pFeatureList->GetCount(); i++)
167         {
168                 pFeature = dynamic_cast<_AppFeatureInfoImpl*>(pFeatureList->GetAt(i));
169                 if (pFeature == null)
170                 {
171                         return "use-system-setting";
172                 }
173
174                 if (pFeature->GetName() == L"HwAcceleration" || pFeature->GetName() == L"GlFrame")
175                 {
176                         String value = pFeature->GetValue();
177                         if (value == L"On")
178                         {
179                                 return "use-GL";
180                         }
181                         else if (value == L"Off")
182                         {
183                                 return "not-use-GL";
184                         }
185                 }
186         }
187
188         return "use-system-setting";
189 }
190
191 bool
192 ManifestGenerator::WriteLanguageValue(IMap* pList, const String& element) const
193 {
194         TryReturn(pList, false, "[osp-installer] pNameList is null.");
195
196         IMapEnumerator*         pMapEnum = pList->GetMapEnumeratorN();
197         while (pMapEnum->MoveNext() == E_SUCCESS)
198         {
199                 String* pLanguage = null;
200                 String* pValue = null;
201                 String threeLetterCode;
202                 String countryCode;
203                 String launguage;
204
205                 pLanguage = static_cast<String*> (pMapEnum->GetKey());
206                 pValue = static_cast<String*> (pMapEnum->GetValue());
207
208                 pLanguage->SubString(0, 3, threeLetterCode);
209                 pLanguage->SubString(4, 2, countryCode);
210
211                 LanguageCode code = Locale::StringToLanguageCode(threeLetterCode);
212                 String twoLetterLanguage = Locale::LanguageCodeToTwoLetterLanguageCodeString(code);
213
214                 launguage = twoLetterLanguage + L"-" + countryCode;
215                 launguage.ToLowerCase();
216
217                 if (((*pLanguage) == L"eng-GB") || ((*pLanguage) == L"eng-US"))
218                 {
219                         __pWriter->StartElement(element);
220                         __pWriter->WriteString(*pValue);
221                         __pWriter->EndElement();
222                 }
223
224                 __pWriter->StartElement(element);
225                 __pWriter->WriteAttribute("xml:lang", launguage);
226                 __pWriter->WriteString(*pValue);
227                 __pWriter->EndElement();
228         }
229
230         delete pMapEnum;
231         return true;
232 }
233
234 bool
235 ManifestGenerator::WriteLiveboxes(_PackageAppInfoImpl* pAppInfoImpl) const
236 {
237         TryReturn(__pContext, false, "[osp-installer] __pContext is null.");
238         TryReturn(__pWriter, false, "[osp-installer] __pWriter is null.");
239
240         ArrayList* pLiveboxList = __pContext->GetLiveBoxList();
241         _PackageInfoImpl* pPackageInfoImpl = __pContext->GetPackageInfoImpl();
242         String label("label");
243
244         if (pLiveboxList == null)
245         {
246                 return true;
247         }
248
249         for (int j = 0 ; j < pLiveboxList->GetCount(); j++)
250         {
251                 LiveboxInfo* pLiveboxInfo = dynamic_cast<LiveboxInfo*>(pLiveboxList->GetAt(j));
252                 if (pLiveboxInfo == null)
253                 {
254                         AppLogTag(OSP_INSTALLER, "pLiveboxInfo is null [%d]", j);
255                         continue;
256                 }
257
258                 long long updatePeriod = pLiveboxInfo->GetUpdatePeriod();
259                 String period = LongLong::ToString(updatePeriod/1000);
260                 IMap* pLiveboxNameList = pLiveboxInfo->GetNameList();
261                 ArrayList* pSizeList = pLiveboxInfo->GetSizeList();
262                 String popupEnabled = pLiveboxInfo->GetPopupEnabled();
263
264                 __pWriter->StartElement("livebox");
265
266                 __pWriter->WriteAttribute("appid", pAppInfoImpl->GetPackageName() + "." + pLiveboxInfo->GetName() );
267                 __pWriter->WriteAttribute("period", period);
268                 __pWriter->WriteAttribute("pinup", "false");
269                 __pWriter->WriteAttribute("primary", "true");
270                 __pWriter->WriteAttribute("auto_launch", "false");
271                 __pWriter->WriteAttribute("abi", "osp");
272
273                 WriteLanguageValue(pLiveboxNameList, label);
274
275                 if (pLiveboxInfo->GetIcon().IsEmpty() == false)
276                 {
277                         String liveboxIcon;
278                         liveboxIcon.Format(1024, L"%ls%ls/%ls", pPackageInfoImpl->GetAppRootPath().GetPointer(), DIR_SHARED_RES, pLiveboxInfo->GetIcon().GetPointer());
279
280                         __pWriter->StartElement("icon");
281                         __pWriter->WriteString(liveboxIcon);
282                         __pWriter->EndElement();
283                 }
284
285                 if (pSizeList)
286                 {
287                         __pWriter->StartElement("box");
288                         __pWriter->WriteAttribute("type", "buffer");
289
290                         for (int k = 0 ; k < pSizeList->GetCount(); k++)
291                         {
292                                 String* pSize  = dynamic_cast<String*>(pSizeList->GetAt(k));
293                                 if (pSize == null)
294                                 {
295                                         AppLogTag(OSP_INSTALLER, "pSize is null [%d]", k);
296                                         continue;
297                                 }
298
299                                 __pWriter->StartElement("size");
300                                 __pWriter->WriteString(*pSize);
301                                 __pWriter->EndElement();
302                         }
303                         __pWriter->EndElement();
304                 }
305
306                 popupEnabled.ToLowerCase();
307                 if (popupEnabled == L"true")
308                 {
309                         __pWriter->StartElement("pd");
310                         __pWriter->WriteAttribute("type", "buffer");
311
312                         __pWriter->StartElement("size");
313                         __pWriter->WriteString("720x250");
314                         __pWriter->EndElement();
315
316                         __pWriter->EndElement();
317                 }
318                 __pWriter->EndElement();
319         }
320
321         return true;
322 }
323
324 bool
325 ManifestGenerator::WriteAppControl(_PackageAppInfoImpl* pAppInfoImpl) const
326 {
327         TryReturn(pAppInfoImpl, false, "[osp-installer] pAppInfoImpl is null.");
328
329         ArrayList* pAppControlImplList = pAppInfoImpl->GetAppControlList();
330         TryReturn(pAppControlImplList, false, "[osp-installer] pAppControlImplList is null.");
331
332         _AppControlInfoImpl* pAppControl = dynamic_cast<_AppControlInfoImpl*>(pAppControlImplList->GetAt(0));
333         TryReturn(pAppControl, false, "[osp-installer] pAppControl is null.");
334
335         ArrayList* pCapabilityList = pAppControl->GetCapabilityList();
336         TryReturn(pCapabilityList, false, "[osp-installer] pCapabilityList is null.");
337
338         int capaCount = pCapabilityList->GetCount();
339         for (int capaIndex = 0 ; capaIndex < capaCount; capaIndex++)
340         {
341                 _AppControlCapabilityInfoImpl* pCapability = dynamic_cast<_AppControlCapabilityInfoImpl*>(pCapabilityList->GetAt(capaIndex));
342                 if (pCapability == null) continue;
343
344                 String operationId = pCapability->GetOperationId();
345
346                 ArrayList* pResolutionList = pCapability->GetResolutionList();
347                 int resCount = pResolutionList->GetCount();
348
349                 if (resCount == 0)
350                 {
351                         __pWriter->StartElement("application-service");
352                         __pWriter->StartElement("operation");
353                         __pWriter->WriteAttribute("name", operationId);
354                         __pWriter->EndElement();
355                         __pWriter->EndElement();
356                         continue;
357                 }
358
359                 for (int resIndex = 0 ; resIndex < resCount; resIndex++)
360                 {
361                         __pWriter->StartElement("application-service");
362                         __pWriter->StartElement("operation");
363                         __pWriter->WriteAttribute("name", operationId);
364                         __pWriter->EndElement();
365
366                         _AppControlResolutionInfoImpl* pResolution = dynamic_cast <_AppControlResolutionInfoImpl*>(pResolutionList->GetAt(resIndex));
367                         if (pResolution == null) continue;
368
369                         String* pUriScheme = pResolution->GetUriScheme();
370                         if (pUriScheme && pUriScheme->IsEmpty() == false)
371                         {
372                                 __pWriter->StartElement("uri");
373                                 __pWriter->WriteAttribute("name", *pUriScheme);
374                                 __pWriter->EndElement();
375                         }
376
377                         String* pMimeType = pResolution->GetMimeType();
378                         if (pMimeType && pMimeType->IsEmpty() == false)
379                         {
380                                 __pWriter->StartElement("mime");
381                                 __pWriter->WriteAttribute("name", *pMimeType);
382                                 __pWriter->EndElement();
383                         }
384
385                         __pWriter->EndElement();
386                 }
387         }
388
389         return true;
390 }
391
392 bool
393 ManifestGenerator::WriteCategory(int index) const
394 {
395         IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
396         TryReturn(pAppDataList, true, "[osp-installer] pAppDataList is null");
397
398         AppData* pAppData = null;
399         pAppDataList->GetAt(index, pAppData);
400         TryReturn(pAppData, true, "[osp-installer] pAppData is null");
401
402         IListT<String*>* pCategoryList = pAppData->__pCategoryList;
403         TryReturn(pCategoryList, true, "[osp-installer] pCategoryList is null");
404
405         for (int i = 0; i < pCategoryList->GetCount(); i++)
406         {
407                 String *pStr = null;
408                 pCategoryList->GetAt(i, pStr);
409                 TryReturn(pStr, false, "[osp-installer] pStr is null");
410
411                 AppLogTag(OSP_INSTALLER, "WriteCategory(): Category String=[%ls]", pStr->GetPointer());
412
413                 __pWriter->StartElement("category");
414                 __pWriter->WriteAttribute("name", *pStr);
415                 __pWriter->EndElement();
416         }
417
418         return true;
419 }
420
421 bool
422 ManifestGenerator::FindCategory(int index, const String& category) const
423 {
424         result r = E_SUCCESS;
425
426         IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
427         TryReturn(pAppDataList, false, "[osp-installer] pAppDataList is null");
428
429         AppData* pAppData = null;
430         r = pAppDataList->GetAt(index, pAppData);
431         TryReturn(pAppData, false, "[osp-installer] pAppData is null");
432
433         IListT<String*>* pCategoryList = pAppData->__pCategoryList;
434         TryReturn(pCategoryList, false, "[osp-installer] pCategoryList is null");
435
436         for (int i = 0; i < pCategoryList->GetCount(); i++)
437         {
438                 String *pStr = null;
439                 pCategoryList->GetAt(i, pStr);
440                 TryReturn(pStr, false, "[osp-installer] pStr is null");
441
442                 if (*pStr == category)
443                 {
444                         AppLogTag(OSP_INSTALLER, "FindCategory(): Category is found=[%ls]", pStr->GetPointer());
445                         return true;
446                 }
447
448         }
449
450         return false;
451 }
452
453 bool
454 ManifestGenerator::WriteApp(int index, Tizen::App::Package::_PackageAppInfoImpl* pAppInfoImpl)
455 {
456         _PackageInfoImpl *pPackageInfoImpl = null;
457         pPackageInfoImpl = __pContext->GetPackageInfoImpl();
458
459         IMap* pNameList = pAppInfoImpl->GetNameList();
460         String label("label");
461         String type("c++app");
462         String binaryPath;
463         binaryPath.Format(1024, L"%ls%ls/%ls", pPackageInfoImpl->GetAppRootPath().GetPointer(), DIR_BIN, pAppInfoImpl->GetName().GetPointer());
464
465         if (pAppInfoImpl->GetDefault() == L"True")
466         {
467                 WriteLanguageValue(pNameList, label);
468
469                 if (pAppInfoImpl->GetMainmenuIcon().IsEmpty() == false)
470                 {
471                         String iconPath;
472                         iconPath.Format(1024, L"%ls%ls/%ls", pPackageInfoImpl->GetAppRootPath().GetPointer(), DIR_SHARED_RES, pAppInfoImpl->GetMainmenuIcon().GetPointer());
473
474                         __pWriter->StartElement("icon");
475                         __pWriter->WriteString(iconPath);
476                         __pWriter->EndElement();
477                 }
478         }
479
480         String nodisplay("true");
481         String taskmanage("false");
482         String category;
483
484         if (pAppInfoImpl->GetType() == L"UiApp")
485         {
486                 taskmanage = L"true";
487
488                 if (pAppInfoImpl->IsMainmenuVisible() == true)
489                 {
490                         nodisplay = L"false";
491                 }
492                 else
493                 {
494                         nodisplay = L"true";
495                 }
496
497                 if (FindCategory(index, "http://tizen.org/category/ime") == true)
498                 {
499                         AppLogTag(OSP_INSTALLER, "Write(): [http://tizen.org/category/ime] is detected. taskmanage=false, nodisplay=true");
500                         taskmanage = L"false";
501                         nodisplay = L"true";
502                 }
503         }
504
505         ArrayList* pFeatureList = pAppInfoImpl->GetAppFeatureList();
506         String glFrame = GetGlFrameValue(pFeatureList);
507
508         __pWriter->StartElement("ui-application");
509         __pWriter->WriteAttribute("appid", pAppInfoImpl->GetPackageName());
510         __pWriter->WriteAttribute("exec", binaryPath);
511         __pWriter->WriteAttribute("nodisplay", nodisplay);
512         __pWriter->WriteAttribute("taskmanage", taskmanage);
513         __pWriter->WriteAttribute("multiple", "false");
514         __pWriter->WriteAttribute("type", type);
515         __pWriter->WriteAttribute("hw-acceleration", glFrame);
516
517         WriteCategory(index);
518
519 #if 0
520         if (pAppInfoImpl->GetType() == L"UiApp")
521         {
522                 String nodisplay;
523
524                 if (pAppInfoImpl->IsMainmenuVisible() == true)
525                 {
526                         nodisplay = "false";
527                 }
528                 else
529                 {
530                         nodisplay = "true";
531                 }
532
533                 __pWriter->StartElement("ui-application");
534                 __pWriter->WriteAttribute("appid", pAppInfoImpl->GetPackageName());
535                 __pWriter->WriteAttribute("exec", binaryPath);
536                 __pWriter->WriteAttribute("nodisplay", nodisplay);
537                 __pWriter->WriteAttribute("taskmanage", "true");
538                 __pWriter->WriteAttribute("multiple", "false");
539                 __pWriter->WriteAttribute("type", type);
540         }
541         else if (pAppInfoImpl->GetType() == L"ServiceApp")
542         {
543                 ArrayList* pFeatureList = pAppInfoImpl->GetAppFeatureList();
544                 String onBoot("false");
545                 String autoRestart("false");
546
547                 if (FindFeatureValue(pFeatureList, "LaunchOnBoot", "True") == true)
548                 {
549                         onBoot = L"true";
550                 }
551
552                 if (FindFeatureValue(pFeatureList, "AutoRestart", "True") == true)
553                 {
554                         autoRestart = L"true";
555                 }
556
557                 __pWriter->StartElement("service-application");
558                 __pWriter->WriteAttribute("appid", pAppInfoImpl->GetPackageName());
559                 __pWriter->WriteAttribute("exec", binaryPath);
560                 __pWriter->WriteAttribute("type", type);
561                 __pWriter->WriteAttribute("on-boot", onBoot);
562                 __pWriter->WriteAttribute("auto-restart", autoRestart);
563         }
564         else
565         {
566                 AppLogTag(OSP_INSTALLER, "Type is invalid! [%ls]", pAppInfoImpl->GetType().GetPointer());
567                 return false;
568         }
569         #endif
570
571         WriteLanguageValue(pNameList, label);
572
573         if (pAppInfoImpl->GetMainmenuIcon().IsEmpty() == false)
574         {
575                 String iconPath;
576                 iconPath.Format(1024, L"%ls%ls/%ls", pPackageInfoImpl->GetAppRootPath().GetPointer(), DIR_SHARED_RES, pAppInfoImpl->GetMainmenuIcon().GetPointer());
577
578                 __pWriter->StartElement("icon");
579                 __pWriter->WriteString(iconPath);
580                 __pWriter->EndElement();
581         }
582
583         WriteAppControl(pAppInfoImpl);
584         WriteAppControl(index);
585
586         __pWriter->EndElement();
587
588         if (pAppInfoImpl->GetType() == L"ServiceApp")
589         {
590                 WriteLiveboxes(pAppInfoImpl);
591         }
592
593         return true;
594 }
595
596 bool
597 ManifestGenerator::WriteSubModeApp(int index)
598 {
599         _PackageInfoImpl *pPackageInfoImpl = null;
600         pPackageInfoImpl = __pContext->GetPackageInfoImpl();
601
602         String binaryPath;
603         binaryPath.Format(1024, L"%ls%ls/%ls", pPackageInfoImpl->GetAppRootPath().GetPointer(), DIR_BIN, SUB_MODE_APPCONTROL_NAME);
604
605         String binaryExecPath = binaryPath + ".exe";
606
607         InstallerUtil::Copy(UIAPP_LOADER_PATH, binaryExecPath);
608         InstallerUtil::ChangeMode(binaryExecPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
609
610         if (File::IsFileExist(binaryPath) == true)
611         {
612                 InstallerUtil::Remove(binaryPath);
613         }
614
615         InstallerUtil::CreateSymlink(binaryExecPath, binaryPath);
616
617         IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
618         TryReturn(pAppDataList, false, "[osp-installer] pAppDataList is null");
619
620         AppLogTag(OSP_INSTALLER, "WriteSubModeApp(): appCount=%d", pAppDataList->GetCount());
621
622         AppData* pAppData = null;
623         pAppDataList->GetAt(index, pAppData);
624         TryReturn(pAppData, false, "[osp-installer] pAppData is null");
625
626         PackageId packageId = __pContext->GetAppId();
627         AppId appId = packageId + L"." + SUB_MODE_APPCONTROL_NAME;
628
629         __pWriter->StartElement("ui-application");
630         __pWriter->WriteAttribute("appid", appId);
631         __pWriter->WriteAttribute("exec", binaryPath);
632         __pWriter->WriteAttribute("nodisplay", "true");
633         __pWriter->WriteAttribute("taskmanage", "false");
634         __pWriter->WriteAttribute("multiple", "true");
635         __pWriter->WriteAttribute("type", "c++app");
636
637         WriteAppControl(index);
638
639         __pWriter->EndElement();        // end of "ui-application"
640
641         return true;
642 }
643
644 bool
645 ManifestGenerator::WriteAppControl(int index)
646 {
647         IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
648         TryReturn(pAppDataList, false, "[osp-installer] pAppDataList is null");
649
650         AppData* pAppData = null;
651         pAppDataList->GetAt(index, pAppData);
652         TryReturn(pAppData, false, "[osp-installer] pAppData is null");
653
654         if (pAppData->__pAppControlData)
655         {
656                 if (pAppData->__pAppControlData->__pOperationDataList)
657                 {
658                         int operationCount = pAppData->__pAppControlData->__pOperationDataList->GetCount();
659
660                         for (int i = 0; i < operationCount; i++)
661                         {
662                                 OperationData* pOperationData = null;
663                                 pAppData->__pAppControlData->__pOperationDataList->GetAt(i, pOperationData);
664
665                                 if (pOperationData == null) continue;
666
667                                 __pWriter->StartElement("application-service");
668                                 __pWriter->StartElement("operation");
669                                 __pWriter->WriteAttribute("name", pOperationData->__id);
670                                 __pWriter->EndElement();        // end of "operation"
671
672                                 if (pOperationData->__uri.IsEmpty() == false)
673                                 {
674                                         __pWriter->StartElement("uri");
675                                         __pWriter->WriteAttribute("name", pOperationData->__uri);
676                                         __pWriter->EndElement();
677                                 }
678
679                                 if (pOperationData->__mimeType.IsEmpty() == false)
680                                 {
681                                         __pWriter->StartElement("mime");
682                                         __pWriter->WriteAttribute("name", pOperationData->__mimeType);
683                                         __pWriter->EndElement();
684                                 }
685
686                                 __pWriter->EndElement();        // end of ""application-service""
687                         }
688                 }
689         }
690
691         return true;
692 }
693