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