Fixes for recursive opendir
[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             if (m_context.locations->browserRequest())
186             {
187                 m_context.locations->setIconTargetFilenameForLocale(targetFile.str());
188             }
189
190             LogDebug("Copying icon: " << sourceFile.str() <<
191                      " -> " << targetFile.str());
192
193             icon_list.push_back(targetFile.str());
194
195             Try
196             {
197                 DPL::FileInput input(sourceFile.str());
198                 DPL::FileOutput output(targetFile.str());
199                 DPL::Copy(&input, &output);
200             }
201
202             Catch(DPL::FileInput::Exception::Base)
203             {
204                 // Error while opening or closing source file
205                 //ReThrowMsg(InstallerException::CopyIconFailed, sourceFile.str());
206                 LogError(
207                     "Copying widget's icon failed. Widget's icon will not be"\
208                     "available from Main Screen");
209             }
210
211             Catch(DPL::FileOutput::Exception::Base)
212             {
213                 // Error while opening or closing target file
214                 //ReThrowMsg(InstallerException::CopyIconFailed, targetFile.str());
215                 LogError(
216                     "Copying widget's icon failed. Widget's icon will not be"\
217                     "available from Main Screen");
218             }
219
220             Catch(DPL::CopyFailed)
221             {
222                 // Error while copying
223                 //ReThrowMsg(InstallerException::CopyIconFailed, targetFile.str());
224                 LogError(
225                     "Copying widget's icon failed. Widget's icon will not be"\
226                     "available from Main Screen");
227             }
228         }
229     }
230
231     m_context.job->UpdateProgress(
232         InstallerContext::INSTALL_COPY_ICONFILE,
233         "Widget iconfile copy Finished");
234 }
235
236 void TaskManifestFile::stepBackupIconFiles()
237 {
238     LogDebug("Backup Icon Files");
239
240     backup_dir << m_context.locations->getPackageInstallationDir();
241     backup_dir << "/" << "backup" << "/";
242
243     backupIconFiles();
244
245     m_context.job->UpdateProgress(
246         InstallerContext::INSTALL_BACKUP_ICONFILE,
247         "New Widget icon file backup Finished");
248 }
249
250 void TaskManifestFile::stepAbortIconFiles()
251 {
252     LogDebug("Abrot Icon Files");
253     FOREACH(it, icon_list)
254     {
255         LogDebug("Remove Update Icon : " << (*it));
256         unlink((*it).c_str());
257     }
258
259     std::ostringstream b_icon_dir;
260     b_icon_dir << backup_dir.str() << "icons";
261
262     std::list<std::string> fileList;
263     getFileList(b_icon_dir.str().c_str(), fileList);
264
265     FOREACH(back_icon, fileList)
266     {
267         std::ostringstream res_file;
268         res_file << GlobalConfig::GetUserWidgetDesktopIconPath();
269         res_file << "/" << (*back_icon);
270
271         std::ostringstream backup_file;
272         backup_file << b_icon_dir.str() << "/" << (*back_icon);
273
274         Try
275         {
276             DPL::FileInput input(backup_file.str());
277             DPL::FileOutput output(res_file.str());
278             DPL::Copy(&input, &output);
279         }
280         Catch(DPL::FileInput::Exception::Base)
281         {
282             LogError("Restoration icon File Failed." << backup_file.str()
283                     << " to " << res_file.str());
284         }
285
286         Catch(DPL::FileOutput::Exception::Base)
287         {
288             LogError("Restoration icon File Failed." << backup_file.str()
289                     << " to " << res_file.str());
290         }
291         Catch(DPL::CopyFailed)
292         {
293             LogError("Restoration icon File Failed." << backup_file.str()
294                     << " to " << res_file.str());
295         }
296     }
297 }
298
299 void TaskManifestFile::stepUpdateFinalize()
300 {
301     commitManifest();
302     LogDebug("Finished Update Desktopfile");
303 }
304
305 DPL::String TaskManifestFile::getIconTargetFilename(
306         const DPL::String& languageTag) const
307 {
308     DPL::OStringStream filename;
309     DPL::Optional<DPL::String> pkgname = m_context.widgetConfig.pkgname;
310     if (pkgname.IsNull()) {
311         ThrowMsg(Exceptions::InternalError, "No Package name exists.");
312     }
313
314     filename << DPL::ToUTF8String(*pkgname).c_str();
315
316     if (!languageTag.empty()) {
317         DPL::OptionalString tag = getLangTag(languageTag); // translate en -> en_US etc
318         if (tag.IsNull()) { tag = languageTag; }
319         DPL::String locale =
320             LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
321
322        if(locale.empty()) {
323             filename << L"." << languageTag;
324         } else {
325             filename << L"." << locale;
326         }
327     }
328
329     filename << L".png";
330     return filename.str();
331 }
332
333 void TaskManifestFile::stepFinalize()
334 {
335     commitManifest();
336     LogInfo("Finished ManifestFile step");
337 }
338
339
340 void TaskManifestFile::saveLocalizedKey(std::ofstream &file,
341         const DPL::String& key,
342         const DPL::String& languageTag)
343 {
344     DPL::String locale =
345             LanguageTagsProvider::BCP47LanguageTagToLocale(languageTag);
346
347     file << key;
348     if (!locale.empty()) {
349         file << "[" << locale << "]";
350     }
351     file << "=";
352 }
353
354 void TaskManifestFile::updateAilInfo()
355 {
356     // Update ail for desktop
357     std::string cfgPkgname =
358         DPL::ToUTF8String(*m_context.widgetConfig.pkgname);
359     const char* pkgname = cfgPkgname.c_str();
360
361     LogDebug("Update ail desktop : " << pkgname );
362     ail_appinfo_h ai = NULL;
363     ail_error_e ret;
364
365     ret = ail_package_get_appinfo(pkgname, &ai);
366     if (ai) {
367         ail_package_destroy_appinfo(ai);
368     }
369
370     if (AIL_ERROR_NO_DATA == ret) {
371         if (ail_desktop_add(pkgname) < 0) {
372             LogDebug("Failed to add ail desktop : " << pkgname);
373         }
374     } else if (AIL_ERROR_OK == ret) {
375         if (ail_desktop_update(pkgname) < 0) {
376             LogDebug("Failed to update ail desktop : " << pkgname);
377         }
378     }
379 }
380
381 void TaskManifestFile::backupIconFiles()
382 {
383     LogInfo("Backup Icon Files");
384
385     std::ostringstream b_icon_dir;
386     b_icon_dir << backup_dir.str() << "icons";
387
388     LogDebug("Create icon backup folder : " << b_icon_dir.str());
389     WrtUtilMakeDir(b_icon_dir.str());
390
391     std::list<std::string> fileList;
392     getFileList(GlobalConfig::GetUserWidgetDesktopIconPath(), fileList);
393     std::string pkgname = DPL::ToUTF8String(*m_context.widgetConfig.pkgname);
394
395     FOREACH(it, fileList)
396     {
397         if (0 == (strncmp((*it).c_str(), pkgname.c_str(),
398                         strlen(pkgname.c_str())))) {
399             std::ostringstream icon_file, backup_icon;
400             icon_file << GlobalConfig::GetUserWidgetDesktopIconPath();
401             icon_file << "/" << (*it);
402
403             backup_icon << b_icon_dir.str() << "/" << (*it);
404
405             LogDebug("Backup icon file " << icon_file.str() << " to " <<
406                     backup_icon.str());
407             Try
408             {
409                 DPL::FileInput input(icon_file.str());
410                 DPL::FileOutput output(backup_icon.str());
411                 DPL::Copy(&input, &output);
412             }
413             Catch(DPL::FileInput::Exception::Base)
414             {
415                 LogError("Backup Desktop File Failed.");
416                 ReThrowMsg(Exceptions::BackupFailed, icon_file.str());
417             }
418
419             Catch(DPL::FileOutput::Exception::Base)
420             {
421                 LogError("Backup Desktop File Failed.");
422                 ReThrowMsg(Exceptions::BackupFailed, backup_icon.str());
423             }
424             Catch(DPL::CopyFailed)
425             {
426                 LogError("Backup Desktop File Failed.");
427                 ReThrowMsg(Exceptions::BackupFailed, backup_icon.str());
428             }
429             unlink((*it).c_str());
430         }
431     }
432 }
433
434 void TaskManifestFile::getFileList(const char* path,
435         std::list<std::string> &list)
436 {
437     DIR* dir = opendir(path);
438     if (!dir) {
439         LogError("icon directory doesn't exist");
440         ThrowMsg(Exceptions::InternalError, path);
441     }
442
443     struct dirent* d_ent;
444     do {
445         if ((d_ent = readdir(dir))) {
446             if(strcmp(d_ent->d_name, ".") == 0 ||
447                     strcmp(d_ent->d_name, "..") == 0) {
448                 continue;
449             }
450             std::string file_name = d_ent->d_name;
451             list.push_back(file_name);
452         }
453     }while(d_ent);
454     if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
455         LogError("Failed to close dir: " << path << " with error: "
456                 << DPL::GetErrnoString());
457     }
458 }
459
460 void TaskManifestFile::stepGenerateManifest()
461 {
462     DPL::String pkgname = *m_context.widgetConfig.pkgname;
463     manifest_name = pkgname + L".xml";
464     manifest_file += L"/tmp/" + manifest_name;
465
466     //libxml - init and check
467     LibxmlSingleton::Instance().init();
468
469     writeManifest(manifest_file);
470
471     m_context.job->UpdateProgress(
472         InstallerContext::INSTALL_CREATE_MANIFEST,
473         "Widget Manifest Creation Finished");
474 }
475
476 void TaskManifestFile::stepParseManifest()
477 {
478     int code = pkgmgr_parser_parse_manifest_for_installation(
479             DPL::ToUTF8String(manifest_file).c_str(), NULL);
480
481     if(code != 0)
482     {
483         LogError("Manifest parser error: " << code);
484         ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
485     }
486
487     // TODO : It will be removed. AIL update is temporary code request by pkgmgr team.
488     updateAilInfo();
489
490     m_context.job->UpdateProgress(
491         InstallerContext::INSTALL_CREATE_MANIFEST,
492         "Widget Manifest Parsing Finished");
493     LogDebug("Manifest parsed");
494 }
495
496 void TaskManifestFile::stepParseUpgradedManifest()
497 {
498     int code = pkgmgr_parser_parse_manifest_for_upgrade(
499             DPL::ToUTF8String(manifest_file).c_str(), NULL);
500
501     if(code != 0)
502     {
503         LogError("Manifest parser error: " << code);
504         ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
505     }
506
507     // TODO : It will be removed. AIL update is temporary code request by pkgmgr team.
508     updateAilInfo();
509
510     m_context.job->UpdateProgress(
511         InstallerContext::INSTALL_CREATE_MANIFEST,
512         "Widget Manifest Parsing Finished");
513     LogDebug("Manifest parsed");
514 }
515
516 void TaskManifestFile::commitManifest()
517 {
518     LogDebug("Commiting manifest file : " << manifest_file);
519
520     std::ostringstream destFile;
521     destFile << "/opt/share/packages" << "/"; //TODO constant with path
522     destFile << DPL::ToUTF8String(manifest_name);
523     LogInfo("cp " << manifest_file << " " << destFile.str());
524
525     DPL::FileInput input(DPL::ToUTF8String(manifest_file));
526     DPL::FileOutput output(destFile.str());
527     DPL::Copy(&input, &output);
528     LogDebug("Manifest writen to: " << destFile.str());
529
530     //removing temp file
531     unlink((DPL::ToUTF8String(manifest_file)).c_str());
532     manifest_file = DPL::FromUTF8String(destFile.str().c_str());
533 }
534
535 void TaskManifestFile::writeManifest(const DPL::String & path)
536 {
537     LogDebug("Generating manifest file : " << path);
538     Manifest manifest;
539     UiApplication uiApp;
540
541     setWidgetExecPath(uiApp);
542     setWidgetName(manifest, uiApp);
543     setWidgetIcons(uiApp);
544     setWidgetManifest(manifest);
545     setWidgetOtherInfo(uiApp);
546     setAppServiceInfo(uiApp);
547
548     manifest.addUiApplication(uiApp);
549     manifest.generate(path);
550     LogDebug("Manifest file serialized");
551 }
552
553 void TaskManifestFile::setWidgetExecPath(UiApplication & uiApp)
554 {
555     uiApp.setExec(DPL::FromASCIIString(m_context.locations->getExecFile()));
556 }
557
558 void TaskManifestFile::setWidgetName(Manifest & manifest, UiApplication & uiApp)
559 {
560     bool defaultNameSaved = false;
561
562     DPL::OptionalString defaultLocale = m_context.widgetConfig.configInfo.defaultlocale;
563     std::pair<DPL::String, WrtDB::ConfigParserData::LocalizedData> defaultLocalizedData;
564     //labels
565     FOREACH(localizedData, m_context.widgetConfig.configInfo.localizedDataSet)
566     {
567         Locale i = localizedData->first;
568         DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc
569         if (tag.IsNull())
570         {
571             tag = i;
572         }
573         DPL::OptionalString name = localizedData->second.name;
574         generateWidgetName(manifest, uiApp, tag, name, defaultNameSaved);
575
576         //store default locale localized data
577         if(!!defaultLocale && defaultLocale == i)
578         {
579             defaultLocalizedData = *localizedData;
580         }
581     }
582
583     if (!!defaultLocale && !defaultNameSaved)
584     {
585         DPL::OptionalString name = defaultLocalizedData.second.name;
586         generateWidgetName(manifest, uiApp, DPL::OptionalString::Null, name, defaultNameSaved);
587     }
588     //appid
589     DPL::String pkgname;
590     if(!!m_context.widgetConfig.pkgname)
591     {
592         pkgname = *m_context.widgetConfig.pkgname;
593         uiApp.setAppid(pkgname);
594     }
595
596     //extraid
597     if(!!m_context.widgetConfig.guid) {
598         uiApp.setExtraid(*m_context.widgetConfig.guid);
599     } else {
600         if(!pkgname.empty()) {
601             uiApp.setExtraid(DPL::String(L"http://") + pkgname);
602         }
603     }
604
605     //type
606     uiApp.setType(DPL::FromASCIIString("webapp"));
607     manifest.setType(L"wgt");
608     uiApp.setTaskmanage(true);
609 }
610
611 void TaskManifestFile::generateWidgetName(Manifest & manifest, UiApplication &uiApp, const DPL::OptionalString& tag, DPL::OptionalString name, bool & defaultNameSaved)
612 {
613     if (!!name) {
614         if (!!tag)
615         {
616             DPL::String locale =
617                     LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
618
619             if (!locale.empty()) {
620                 uiApp.addLabel(LabelType(*name,*tag));
621             }
622             else
623             {
624                 uiApp.addLabel(LabelType(*name));
625                 manifest.addLabel(LabelType(*name));
626             }
627         }
628         else
629         {
630             defaultNameSaved = true;
631             uiApp.addLabel(LabelType(*name));
632             manifest.addLabel(LabelType(*name));
633         }
634     }
635 }
636
637 void TaskManifestFile::setWidgetIcons(UiApplication & uiApp)
638 {
639     DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
640     if (pkgname.IsNull()) {
641         ThrowMsg(Exceptions::InternalError, "No Package name exists.");
642     }
643
644     //TODO this file will need to be updated when user locale preferences
645     //changes.
646     bool defaultIconSaved = false;
647
648     DPL::OptionalString defaultLocale = m_context.widgetConfig.configInfo.defaultlocale;
649
650     std::vector<Locale> generatedLocales;
651     WrtDB::WidgetRegisterInfo::LocalizedIconList & icons = m_context.widgetConfig.localizationData.icons;
652
653     //reversed: last <icon> has highest priority to be writen to manifest if it has given locale (TODO: why was that working that way?)
654     for(WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator icon = icons.rbegin(); icon != icons.rend(); icon++)
655     {
656         FOREACH(locale, icon->availableLocales)
657         {
658             if(std::find(generatedLocales.begin(), generatedLocales.end(), *locale) != generatedLocales.end())
659             {
660                 LogDebug("Skipping - has that locale - already in manifest");
661                 continue;
662             }
663             else
664             {
665                 generatedLocales.push_back(*locale);
666             }
667
668             DPL::OptionalString tag = getLangTag(*locale); // translate en -> en_US etc
669             if (tag.IsNull()) { tag = *locale; }
670
671             generateWidgetIcon(uiApp, tag, *locale, defaultIconSaved);
672         }
673     }
674     if (!!defaultLocale && !defaultIconSaved)
675     {
676         generateWidgetIcon(uiApp, DPL::OptionalString::Null,
677                            DPL::String(),
678                            defaultIconSaved);
679     }
680 }
681
682 void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp, const DPL::OptionalString& tag,
683         const DPL::String& language, bool & defaultIconSaved)
684 {
685     DPL::String locale;
686     if (!!tag)
687     {
688         locale = LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
689     }
690     else
691     {
692         defaultIconSaved = true;
693     }
694
695     DPL::String iconText;
696     iconText += getIconTargetFilename(language);
697
698     if(!locale.empty())
699     {
700         uiApp.addIcon(IconType(iconText, locale));
701     }
702     else
703     {
704         uiApp.addIcon(IconType(iconText));
705     }
706 }
707
708 void TaskManifestFile::setWidgetManifest(Manifest & manifest)
709 {
710     if(!!m_context.widgetConfig.pkgname)
711     {
712         manifest.setPackage(*m_context.widgetConfig.pkgname);
713     }
714     if(!!m_context.widgetConfig.version)
715     {
716         manifest.setVersion(*m_context.widgetConfig.version);
717     }
718     DPL::String email = (!!m_context.widgetConfig.configInfo.authorEmail ?
719                             *m_context.widgetConfig.configInfo.authorEmail : L"");
720     DPL::String href = (!!m_context.widgetConfig.configInfo.authorHref ?
721                             *m_context.widgetConfig.configInfo.authorHref : L"");
722     DPL::String name = (!!m_context.widgetConfig.configInfo.authorName ?
723                             *m_context.widgetConfig.configInfo.authorName : L"");
724     manifest.addAuthor(Author(email,href,L"",name));
725 }
726
727 void TaskManifestFile::setWidgetOtherInfo(UiApplication & uiApp)
728 {
729     uiApp.setNodisplay(false);
730     //TODO
731     //There is no "X-TIZEN-PackageType=wgt"
732     //There is no X-TIZEN-PackageID in manifest "X-TIZEN-PackageID=" << DPL::ToUTF8String(*widgetID).c_str()
733     //There is no Comment in pkgmgr "Comment=Widget application"
734     //that were in desktop file
735 }
736
737 void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp)
738 {
739     WrtDB::ConfigParserData::ServiceInfoList appServiceList = m_context.widgetConfig.configInfo.appServiceList;
740
741     if (appServiceList.empty()) {
742         LogInfo("Widget doesn't contain application service");
743         return;
744     }
745
746     // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image;
747     FOREACH(it, appServiceList) {
748         ApplicationService appService;
749         if (!it->m_operation.empty()) {
750             appService.addOperation(it->m_operation); //TODO: encapsulation?
751         }
752         if (!it->m_scheme.empty()) {
753             appService.addUri(it->m_scheme);
754         }
755         if (!it->m_mime.empty()) {
756             appService.addMime(it->m_mime);
757         }
758         uiApp.addApplicationService(appService);
759     }
760 }
761
762 } //namespace WidgetInstall
763 } //namespace Jobs