Pkgname (tizen id) - not null
[framework/web/wrt-installer.git] / src / jobs / widget_install / task_manifest_file.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /**
17  * @file    task_manifest_file.cpp
18  * @author  Pawel Sikorski (p.sikorski@samgsung.com)
19  * @version
20  * @brief
21  */
22
23 //SYSTEM INCLUDES
24 #include <string>
25 #include <dpl/assert.h>
26 #include <dirent.h>
27 #include <fstream>
28 #include <ail.h>
29
30 //WRT INCLUDES
31 #include <widget_install/task_manifest_file.h>
32 #include <widget_install/job_widget_install.h>
33 #include <widget_install/widget_install_errors.h>
34 #include <widget_install/widget_install_context.h>
35 #include <dpl/wrt-dao-ro/global_config.h>
36 #include <dpl/log/log.h>
37 #include <dpl/file_input.h>
38 #include <dpl/errno_string.h>
39 #include <dpl/file_output.h>
40 #include <dpl/copy.h>
41 #include <dpl/exception.h>
42 #include <dpl/foreach.h>
43 #include <dpl/sstream.h>
44 #include <dpl/string.h>
45 #include <dpl/optional.h>
46 #include <dpl/utils/wrt_utility.h>
47 #include <map>
48 #include <libxml_utils.h>
49 #include <pkgmgr/pkgmgr_parser.h>
50 #include <dpl/localization/LanguageTagsProvider.h>
51
52 #define DEFAULT_ICON_NAME   "icon.png"
53
54 using namespace WrtDB;
55
56 namespace {
57 typedef std::map<DPL::String, DPL::String> LanguageTagMap;
58
59 LanguageTagMap getLanguageTagMap()
60 {
61     LanguageTagMap map;
62
63 #define ADD(tag, l_tag) map.insert(std::make_pair(L ## # tag, L ## # l_tag));
64 #include "languages.def"
65 #undef ADD
66
67     return map;
68 }
69
70 DPL::OptionalString getLangTag(const DPL::String& tag)
71 {
72     static LanguageTagMap TagsMap =
73         getLanguageTagMap();
74
75     DPL::String langTag = tag;
76
77     LogDebug("Trying to map language tag: " << langTag);
78     size_t pos = langTag.find_first_of(L'_');
79     if (pos != DPL::String::npos) {
80         langTag.erase(pos);
81     }
82     DPL::OptionalString ret;
83
84     LanguageTagMap::iterator it = TagsMap.find(langTag);
85     if (it != TagsMap.end()) {
86         ret = it->second;
87     }
88     LogDebug("Mapping IANA Language tag to language tag: " <<
89              langTag << " -> " << ret);
90
91     return ret;
92 }
93 }
94
95 namespace Jobs {
96 namespace WidgetInstall {
97
98 const char * TaskManifestFile::encoding = "UTF-8";
99
100 TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
101     DPL::TaskDecl<TaskManifestFile>(this),
102     m_context(inCont)
103 {
104     if (false == m_context.existingWidgetInfo.isExist) {
105         AddStep(&TaskManifestFile::stepCopyIconFiles);
106         AddStep(&TaskManifestFile::stepCreateExecFile);
107         AddStep(&TaskManifestFile::stepGenerateManifest);
108         AddStep(&TaskManifestFile::stepParseManifest);
109         AddStep(&TaskManifestFile::stepFinalize);
110     } else {
111     // for widget update.
112         AddStep(&TaskManifestFile::stepBackupIconFiles);
113         AddStep(&TaskManifestFile::stepCopyIconFiles);
114         AddStep(&TaskManifestFile::stepGenerateManifest);
115         AddStep(&TaskManifestFile::stepParseUpgradedManifest);
116         AddStep(&TaskManifestFile::stepUpdateFinalize);
117
118         AddAbortStep(&TaskManifestFile::stepAbortIconFiles);
119     }
120 }
121
122 TaskManifestFile::~TaskManifestFile()
123 {
124 }
125
126 void TaskManifestFile::stepCreateExecFile()
127 {
128     std::string exec = m_context.locations->getExecFile();
129     std::string clientExeStr = GlobalConfig::GetWrtClientExec();
130
131     LogInfo("link -s " << clientExeStr << " " << exec);
132     symlink(clientExeStr.c_str(), exec.c_str());
133
134     m_context.job->UpdateProgress(
135         InstallerContext::INSTALL_CREATE_EXECFILE,
136         "Widget execfile creation Finished");
137 }
138
139 void TaskManifestFile::stepCopyIconFiles()
140 {
141     LogDebug("CopyIconFiles");
142
143     //This function copies icon to desktop icon path. For each locale avaliable
144     //which there is at least one icon in widget for, icon file is copied.
145     //Coping prioritize last positions when coping. If there is several icons
146     //with given locale, the one, that will be copied, will be icon
147     //which is declared by <icon> tag later than the others in config.xml of widget
148
149     std::vector<Locale> generatedLocales;
150
151     WrtDB::WidgetRegisterInfo::LocalizedIconList & icons = m_context.widgetConfig.localizationData.icons;
152
153     //reversed: last <icon> has highest priority to be copied if it has given locale (TODO: why was that working that way?)
154     for(WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator icon = icons.rbegin(); icon != icons.rend(); icon++)
155     {
156         FOREACH(locale, icon->availableLocales)
157         {
158             DPL::String src = icon->src;
159             LogDebug("Icon for locale: " << *locale << "is : " << src);
160
161             if(std::find(generatedLocales.begin(), generatedLocales.end(), *locale) != generatedLocales.end())
162             {
163                 LogDebug("Skipping - has that locale");
164                 continue;
165             }
166             else
167             {
168                 generatedLocales.push_back(*locale);
169             }
170
171             std::ostringstream sourceFile;
172             std::ostringstream targetFile;
173
174             sourceFile << m_context.locations->getSourceDir() << "/";
175
176             if (!locale->empty()) {
177                 sourceFile << "locales/" << *locale << "/";
178             }
179
180             sourceFile << src;
181
182             targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
183             targetFile << getIconTargetFilename(*locale);
184
185
186             if (m_context.widgetConfig.packagingType ==
187                     WrtDB::PKG_TYPE_HOSTED_WEB_APP) {
188                 m_context.locations->setIconTargetFilenameForLocale(targetFile.str());
189             }
190
191             LogDebug("Copying icon: " << sourceFile.str() <<
192                      " -> " << targetFile.str());
193
194             icon_list.push_back(targetFile.str());
195
196             Try
197             {
198                 DPL::FileInput input(sourceFile.str());
199                 DPL::FileOutput output(targetFile.str());
200                 DPL::Copy(&input, &output);
201             }
202
203             Catch(DPL::FileInput::Exception::Base)
204             {
205                 // Error while opening or closing source file
206                 //ReThrowMsg(InstallerException::CopyIconFailed, sourceFile.str());
207                 LogError(
208                     "Copying widget's icon failed. Widget's icon will not be"\
209                     "available from Main Screen");
210             }
211
212             Catch(DPL::FileOutput::Exception::Base)
213             {
214                 // Error while opening or closing target file
215                 //ReThrowMsg(InstallerException::CopyIconFailed, targetFile.str());
216                 LogError(
217                     "Copying widget's icon failed. Widget's icon will not be"\
218                     "available from Main Screen");
219             }
220
221             Catch(DPL::CopyFailed)
222             {
223                 // Error while copying
224                 //ReThrowMsg(InstallerException::CopyIconFailed, targetFile.str());
225                 LogError(
226                     "Copying widget's icon failed. Widget's icon will not be"\
227                     "available from Main Screen");
228             }
229         }
230     }
231
232     m_context.job->UpdateProgress(
233         InstallerContext::INSTALL_COPY_ICONFILE,
234         "Widget iconfile copy Finished");
235 }
236
237 void TaskManifestFile::stepBackupIconFiles()
238 {
239     LogDebug("Backup Icon Files");
240
241     backup_dir << m_context.locations->getPackageInstallationDir();
242     backup_dir << "/" << "backup" << "/";
243
244     backupIconFiles();
245
246     m_context.job->UpdateProgress(
247         InstallerContext::INSTALL_BACKUP_ICONFILE,
248         "New Widget icon file backup Finished");
249 }
250
251 void TaskManifestFile::stepAbortIconFiles()
252 {
253     LogDebug("Abrot Icon Files");
254     FOREACH(it, icon_list)
255     {
256         LogDebug("Remove Update Icon : " << (*it));
257         unlink((*it).c_str());
258     }
259
260     std::ostringstream b_icon_dir;
261     b_icon_dir << backup_dir.str() << "icons";
262
263     std::list<std::string> fileList;
264     getFileList(b_icon_dir.str().c_str(), fileList);
265
266     FOREACH(back_icon, fileList)
267     {
268         std::ostringstream res_file;
269         res_file << GlobalConfig::GetUserWidgetDesktopIconPath();
270         res_file << "/" << (*back_icon);
271
272         std::ostringstream backup_file;
273         backup_file << b_icon_dir.str() << "/" << (*back_icon);
274
275         Try
276         {
277             DPL::FileInput input(backup_file.str());
278             DPL::FileOutput output(res_file.str());
279             DPL::Copy(&input, &output);
280         }
281         Catch(DPL::FileInput::Exception::Base)
282         {
283             LogError("Restoration icon File Failed." << backup_file.str()
284                     << " to " << res_file.str());
285         }
286
287         Catch(DPL::FileOutput::Exception::Base)
288         {
289             LogError("Restoration icon File Failed." << backup_file.str()
290                     << " to " << res_file.str());
291         }
292         Catch(DPL::CopyFailed)
293         {
294             LogError("Restoration icon File Failed." << backup_file.str()
295                     << " to " << res_file.str());
296         }
297     }
298 }
299
300 void TaskManifestFile::stepUpdateFinalize()
301 {
302     commitManifest();
303     LogDebug("Finished Update Desktopfile");
304 }
305
306 DPL::String TaskManifestFile::getIconTargetFilename(
307         const DPL::String& languageTag) const
308 {
309     DPL::OStringStream filename;
310     DPL::String pkgname = m_context.widgetConfig.pkgname_NOTNULL;
311
312     filename << DPL::ToUTF8String(pkgname).c_str();
313
314     if (!languageTag.empty()) {
315         DPL::OptionalString tag = getLangTag(languageTag); // translate en -> en_US etc
316         if (tag.IsNull()) { tag = languageTag; }
317         DPL::String locale =
318             LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
319
320        if(locale.empty()) {
321             filename << L"." << languageTag;
322         } else {
323             filename << L"." << locale;
324         }
325     }
326
327     filename << L".png";
328     return filename.str();
329 }
330
331 void TaskManifestFile::stepFinalize()
332 {
333     commitManifest();
334     LogInfo("Finished ManifestFile step");
335 }
336
337
338 void TaskManifestFile::saveLocalizedKey(std::ofstream &file,
339         const DPL::String& key,
340         const DPL::String& languageTag)
341 {
342     DPL::String locale =
343             LanguageTagsProvider::BCP47LanguageTagToLocale(languageTag);
344
345     file << key;
346     if (!locale.empty()) {
347         file << "[" << locale << "]";
348     }
349     file << "=";
350 }
351
352 void TaskManifestFile::updateAilInfo()
353 {
354     // Update ail for desktop
355     std::string cfgPkgname =
356         DPL::ToUTF8String(m_context.widgetConfig.pkgname_NOTNULL);
357     const char* pkgname = cfgPkgname.c_str();
358
359     LogDebug("Update ail desktop : " << pkgname );
360     ail_appinfo_h ai = NULL;
361     ail_error_e ret;
362
363     ret = ail_package_get_appinfo(pkgname, &ai);
364     if (ai) {
365         ail_package_destroy_appinfo(ai);
366     }
367
368     if (AIL_ERROR_NO_DATA == ret) {
369         if (ail_desktop_add(pkgname) < 0) {
370             LogWarning("Failed to add ail desktop : " << pkgname);
371         }
372     } else if (AIL_ERROR_OK == ret) {
373         if (ail_desktop_update(pkgname) < 0) {
374             LogWarning("Failed to update ail desktop : " << pkgname);
375         }
376     }
377 }
378
379 void TaskManifestFile::backupIconFiles()
380 {
381     LogInfo("Backup Icon Files");
382
383     std::ostringstream b_icon_dir;
384     b_icon_dir << backup_dir.str() << "icons";
385
386     LogDebug("Create icon backup folder : " << b_icon_dir.str());
387     WrtUtilMakeDir(b_icon_dir.str());
388
389     std::list<std::string> fileList;
390     getFileList(GlobalConfig::GetUserWidgetDesktopIconPath(), fileList);
391     std::string pkgname = DPL::ToUTF8String(m_context.widgetConfig.pkgname_NOTNULL);
392
393     FOREACH(it, fileList)
394     {
395         if (0 == (strncmp((*it).c_str(), pkgname.c_str(),
396                         strlen(pkgname.c_str())))) {
397             std::ostringstream icon_file, backup_icon;
398             icon_file << GlobalConfig::GetUserWidgetDesktopIconPath();
399             icon_file << "/" << (*it);
400
401             backup_icon << b_icon_dir.str() << "/" << (*it);
402
403             LogDebug("Backup icon file " << icon_file.str() << " to " <<
404                     backup_icon.str());
405             Try
406             {
407                 DPL::FileInput input(icon_file.str());
408                 DPL::FileOutput output(backup_icon.str());
409                 DPL::Copy(&input, &output);
410             }
411             Catch(DPL::FileInput::Exception::Base)
412             {
413                 LogError("Backup Desktop File Failed.");
414                 ReThrowMsg(Exceptions::BackupFailed, icon_file.str());
415             }
416
417             Catch(DPL::FileOutput::Exception::Base)
418             {
419                 LogError("Backup Desktop File Failed.");
420                 ReThrowMsg(Exceptions::BackupFailed, backup_icon.str());
421             }
422             Catch(DPL::CopyFailed)
423             {
424                 LogError("Backup Desktop File Failed.");
425                 ReThrowMsg(Exceptions::BackupFailed, backup_icon.str());
426             }
427             unlink((*it).c_str());
428         }
429     }
430 }
431
432 void TaskManifestFile::getFileList(const char* path,
433         std::list<std::string> &list)
434 {
435     DIR* dir = opendir(path);
436     if (!dir) {
437         LogError("icon directory doesn't exist");
438         ThrowMsg(Exceptions::InternalError, path);
439     }
440
441     struct dirent* d_ent;
442     do {
443         if ((d_ent = readdir(dir))) {
444             if(strcmp(d_ent->d_name, ".") == 0 ||
445                     strcmp(d_ent->d_name, "..") == 0) {
446                 continue;
447             }
448             std::string file_name = d_ent->d_name;
449             list.push_back(file_name);
450         }
451     }while(d_ent);
452     if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
453         LogError("Failed to close dir: " << path << " with error: "
454                 << DPL::GetErrnoString());
455     }
456 }
457
458 void TaskManifestFile::stepGenerateManifest()
459 {
460     DPL::String pkgname = m_context.widgetConfig.pkgname_NOTNULL;
461     manifest_name = pkgname + L".xml";
462     manifest_file += L"/tmp/" + manifest_name;
463
464     //libxml - init and check
465     LibxmlSingleton::Instance().init();
466
467     writeManifest(manifest_file);
468
469     m_context.job->UpdateProgress(
470         InstallerContext::INSTALL_CREATE_MANIFEST,
471         "Widget Manifest Creation Finished");
472 }
473
474 void TaskManifestFile::stepParseManifest()
475 {
476     int code = pkgmgr_parser_parse_manifest_for_installation(
477             DPL::ToUTF8String(manifest_file).c_str(), NULL);
478
479     if(code != 0)
480     {
481         LogError("Manifest parser error: " << code);
482         ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
483     }
484
485     // TODO : It will be removed. AIL update is temporary code request by pkgmgr team.
486     updateAilInfo();
487
488     m_context.job->UpdateProgress(
489         InstallerContext::INSTALL_CREATE_MANIFEST,
490         "Widget Manifest Parsing Finished");
491     LogDebug("Manifest parsed");
492 }
493
494 void TaskManifestFile::stepParseUpgradedManifest()
495 {
496     int code = pkgmgr_parser_parse_manifest_for_upgrade(
497             DPL::ToUTF8String(manifest_file).c_str(), NULL);
498
499     if(code != 0)
500     {
501         LogError("Manifest parser error: " << code);
502         ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
503     }
504
505     // TODO : It will be removed. AIL update is temporary code request by pkgmgr team.
506     updateAilInfo();
507
508     m_context.job->UpdateProgress(
509         InstallerContext::INSTALL_CREATE_MANIFEST,
510         "Widget Manifest Parsing Finished");
511     LogDebug("Manifest parsed");
512 }
513
514 void TaskManifestFile::commitManifest()
515 {
516     LogDebug("Commiting manifest file : " << manifest_file);
517
518     std::ostringstream destFile;
519     destFile << "/opt/share/packages" << "/"; //TODO constant with path
520     destFile << DPL::ToUTF8String(manifest_name);
521     LogInfo("cp " << manifest_file << " " << destFile.str());
522
523     DPL::FileInput input(DPL::ToUTF8String(manifest_file));
524     DPL::FileOutput output(destFile.str());
525     DPL::Copy(&input, &output);
526     LogDebug("Manifest writen to: " << destFile.str());
527
528     //removing temp file
529     unlink((DPL::ToUTF8String(manifest_file)).c_str());
530     manifest_file = DPL::FromUTF8String(destFile.str().c_str());
531 }
532
533 void TaskManifestFile::writeManifest(const DPL::String & path)
534 {
535     LogDebug("Generating manifest file : " << path);
536     Manifest manifest;
537     UiApplication uiApp;
538
539     setWidgetExecPath(uiApp);
540     setWidgetName(manifest, uiApp);
541     setWidgetIcons(uiApp);
542     setWidgetManifest(manifest);
543     setWidgetOtherInfo(uiApp);
544     setAppServiceInfo(uiApp);
545
546     manifest.addUiApplication(uiApp);
547     manifest.generate(path);
548     LogDebug("Manifest file serialized");
549 }
550
551 void TaskManifestFile::setWidgetExecPath(UiApplication & uiApp)
552 {
553     uiApp.setExec(DPL::FromASCIIString(m_context.locations->getExecFile()));
554 }
555
556 void TaskManifestFile::setWidgetName(Manifest & manifest, UiApplication & uiApp)
557 {
558     bool defaultNameSaved = false;
559
560     DPL::OptionalString defaultLocale = m_context.widgetConfig.configInfo.defaultlocale;
561     std::pair<DPL::String, WrtDB::ConfigParserData::LocalizedData> defaultLocalizedData;
562     //labels
563     FOREACH(localizedData, m_context.widgetConfig.configInfo.localizedDataSet)
564     {
565         Locale i = localizedData->first;
566         DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc
567         if (tag.IsNull())
568         {
569             tag = i;
570         }
571         DPL::OptionalString name = localizedData->second.name;
572         generateWidgetName(manifest, uiApp, tag, name, defaultNameSaved);
573
574         //store default locale localized data
575         if(!!defaultLocale && defaultLocale == i)
576         {
577             defaultLocalizedData = *localizedData;
578         }
579     }
580
581     if (!!defaultLocale && !defaultNameSaved)
582     {
583         DPL::OptionalString name = defaultLocalizedData.second.name;
584         generateWidgetName(manifest, uiApp, DPL::OptionalString::Null, name, defaultNameSaved);
585     }
586     //appid
587     DPL::String pkgname;
588
589     pkgname = m_context.widgetConfig.pkgname_NOTNULL;
590     uiApp.setAppid(pkgname);
591
592     //extraid
593     if(!!m_context.widgetConfig.guid) {
594         uiApp.setExtraid(*m_context.widgetConfig.guid);
595     } else {
596         if(!pkgname.empty()) {
597             uiApp.setExtraid(DPL::String(L"http://") + pkgname);
598         }
599     }
600
601     //type
602     uiApp.setType(DPL::FromASCIIString("webapp"));
603     manifest.setType(L"wgt");
604     uiApp.setTaskmanage(true);
605 }
606
607 void TaskManifestFile::generateWidgetName(Manifest & manifest, UiApplication &uiApp, const DPL::OptionalString& tag, DPL::OptionalString name, bool & defaultNameSaved)
608 {
609     if (!!name) {
610         if (!!tag)
611         {
612             DPL::String locale =
613                     LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
614
615             if (!locale.empty()) {
616                 uiApp.addLabel(LabelType(*name,*tag));
617             }
618             else
619             {
620                 uiApp.addLabel(LabelType(*name));
621                 manifest.addLabel(LabelType(*name));
622             }
623         }
624         else
625         {
626             defaultNameSaved = true;
627             uiApp.addLabel(LabelType(*name));
628             manifest.addLabel(LabelType(*name));
629         }
630     }
631 }
632
633 void TaskManifestFile::setWidgetIcons(UiApplication & uiApp)
634 {
635     DPL::String pkgname = m_context.widgetConfig.pkgname_NOTNULL;
636
637     //TODO this file will need to be updated when user locale preferences
638     //changes.
639     bool defaultIconSaved = false;
640
641     DPL::OptionalString defaultLocale = m_context.widgetConfig.configInfo.defaultlocale;
642
643     std::vector<Locale> generatedLocales;
644     WrtDB::WidgetRegisterInfo::LocalizedIconList & icons = m_context.widgetConfig.localizationData.icons;
645
646     //reversed: last <icon> has highest priority to be writen to manifest if it has given locale (TODO: why was that working that way?)
647     for(WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator icon = icons.rbegin(); icon != icons.rend(); icon++)
648     {
649         FOREACH(locale, icon->availableLocales)
650         {
651             if(std::find(generatedLocales.begin(), generatedLocales.end(), *locale) != generatedLocales.end())
652             {
653                 LogDebug("Skipping - has that locale - already in manifest");
654                 continue;
655             }
656             else
657             {
658                 generatedLocales.push_back(*locale);
659             }
660
661             DPL::OptionalString tag = getLangTag(*locale); // translate en -> en_US etc
662             if (tag.IsNull()) { tag = *locale; }
663
664             generateWidgetIcon(uiApp, tag, *locale, defaultIconSaved);
665         }
666     }
667     if (!!defaultLocale && !defaultIconSaved)
668     {
669         generateWidgetIcon(uiApp, DPL::OptionalString::Null,
670                            DPL::String(),
671                            defaultIconSaved);
672     }
673 }
674
675 void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp, const DPL::OptionalString& tag,
676         const DPL::String& language, bool & defaultIconSaved)
677 {
678     DPL::String locale;
679     if (!!tag)
680     {
681         locale = LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
682     }
683     else
684     {
685         defaultIconSaved = true;
686     }
687
688     DPL::String iconText;
689     iconText += getIconTargetFilename(language);
690
691     if(!locale.empty())
692     {
693         uiApp.addIcon(IconType(iconText, locale));
694     }
695     else
696     {
697         uiApp.addIcon(IconType(iconText));
698     }
699 }
700
701 void TaskManifestFile::setWidgetManifest(Manifest & manifest)
702 {
703     manifest.setPackage(m_context.widgetConfig.pkgname_NOTNULL);
704
705     if(!!m_context.widgetConfig.version)
706     {
707         manifest.setVersion(*m_context.widgetConfig.version);
708     }
709     DPL::String email = (!!m_context.widgetConfig.configInfo.authorEmail ?
710                             *m_context.widgetConfig.configInfo.authorEmail : L"");
711     DPL::String href = (!!m_context.widgetConfig.configInfo.authorHref ?
712                             *m_context.widgetConfig.configInfo.authorHref : L"");
713     DPL::String name = (!!m_context.widgetConfig.configInfo.authorName ?
714                             *m_context.widgetConfig.configInfo.authorName : L"");
715     manifest.addAuthor(Author(email,href,L"",name));
716 }
717
718 void TaskManifestFile::setWidgetOtherInfo(UiApplication & uiApp)
719 {
720     uiApp.setNodisplay(false);
721     //TODO
722     //There is no "X-TIZEN-PackageType=wgt"
723     //There is no X-TIZEN-PackageID in manifest "X-TIZEN-PackageID=" << DPL::ToUTF8String(*widgetID).c_str()
724     //There is no Comment in pkgmgr "Comment=Widget application"
725     //that were in desktop file
726 }
727
728 void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp)
729 {
730     WrtDB::ConfigParserData::ServiceInfoList appServiceList = m_context.widgetConfig.configInfo.appServiceList;
731
732     if (appServiceList.empty()) {
733         LogInfo("Widget doesn't contain application service");
734         return;
735     }
736
737     // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image;
738     FOREACH(it, appServiceList) {
739         ApplicationService appService;
740         if (!it->m_operation.empty()) {
741             appService.addOperation(it->m_operation); //TODO: encapsulation?
742         }
743         if (!it->m_scheme.empty()) {
744             appService.addUri(it->m_scheme);
745         }
746         if (!it->m_mime.empty()) {
747             appService.addMime(it->m_mime);
748         }
749         uiApp.addApplicationService(appService);
750     }
751 }
752
753 } //namespace WidgetInstall
754 } //namespace Jobs