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