Handle 'mouse-event' attribute differently according to configuration of web-provider...
[framework/web/wrt-installer.git] / src / jobs / widget_install / task_manifest_file.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 67a4f4e..18ddf7e
@@ -21,6 +21,7 @@
  */
 
 //SYSTEM INCLUDES
+#include <unistd.h>
 #include <string>
 #include <dpl/assert.h>
 #include <dirent.h>
@@ -32,6 +33,8 @@
 #include <widget_install/job_widget_install.h>
 #include <widget_install/widget_install_errors.h>
 #include <widget_install/widget_install_context.h>
+#include <web_provider_livebox_info.h>
+#include <web_provider_plugin_info.h>
 #include <dpl/wrt-dao-ro/global_config.h>
 #include <dpl/log/log.h>
 #include <dpl/file_input.h>
@@ -63,7 +66,7 @@ LanguageTagMap getLanguageTagMap()
 {
     LanguageTagMap map;
 
-#define ADD(tag, l_tag) map.insert(std::make_pair(L ## # tag, L ## # l_tag));
+#define ADD(tag, l_tag) map.insert(std::make_pair(L###tag, L###l_tag));
 #include "languages.def"
 #undef ADD
 
@@ -97,23 +100,15 @@ DPL::OptionalString getLangTag(const DPL::String& tag)
 
 namespace Jobs {
 namespace WidgetInstall {
-
 const char * TaskManifestFile::encoding = "UTF-8";
 
 TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
     DPL::TaskDecl<TaskManifestFile>(this),
-    m_context(inCont)
+    m_context(inCont),
+    writer(NULL)
 {
-    if (false == m_context.existingWidgetInfo.isExist) {
-        AddStep(&TaskManifestFile::stepCopyIconFiles);
-        AddStep(&TaskManifestFile::stepCreateExecFile);
-        AddStep(&TaskManifestFile::stepGenerateManifest);
-        AddStep(&TaskManifestFile::stepParseManifest);
-        AddStep(&TaskManifestFile::stepFinalize);
-
-        AddAbortStep(&TaskManifestFile::stepAbortParseManifest);
-    } else {
-    // for widget update.
+    if (m_context.isUpdateMode) {
+        // for widget update.
         AddStep(&TaskManifestFile::stepBackupIconFiles);
         AddStep(&TaskManifestFile::stepCopyIconFiles);
         AddStep(&TaskManifestFile::stepGenerateManifest);
@@ -121,24 +116,84 @@ TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
         AddStep(&TaskManifestFile::stepUpdateFinalize);
 
         AddAbortStep(&TaskManifestFile::stepAbortIconFiles);
+    } else {
+        AddStep(&TaskManifestFile::stepCopyIconFiles);
+        AddStep(&TaskManifestFile::stepCreateExecFile);
+        AddStep(&TaskManifestFile::stepGenerateManifest);
+        AddStep(&TaskManifestFile::stepParseManifest);
+        AddStep(&TaskManifestFile::stepFinalize);
+
+        AddAbortStep(&TaskManifestFile::stepAbortParseManifest);
     }
 }
 
 TaskManifestFile::~TaskManifestFile()
-{
-}
+{}
 
 void TaskManifestFile::stepCreateExecFile()
 {
     std::string exec = m_context.locations->getExecFile();
     std::string clientExeStr = GlobalConfig::GetWrtClientExec();
 
-    LogInfo("link -s " << clientExeStr << " " << exec);
-    symlink(clientExeStr.c_str(), exec.c_str());
+#ifdef MULTIPROCESS_SERVICE_SUPPORT
+    //default widget
+    std::stringstream postfix;
+    postfix << AppControlPrefix::PROCESS_PREFIX << 0;
+    std::string controlExec = exec;
+    controlExec.append(postfix.str());
+
+    errno = 0;
+    if (symlink(clientExeStr.c_str(), controlExec.c_str()) != 0)
+    {
+        int error = errno;
+        if (error)
+            LogPedantic("Failed to make a symbolic name for a file "
+                    << "[" <<  DPL::GetErrnoString(error) << "]");
+        ThrowMsg(Exceptions::FileOperationFailed,
+                "Symbolic link creating is not done.");
+    }
+
+    // app-control widgets
+    unsigned int indexMax = 0;
+    FOREACH(it, m_context.widgetConfig.configInfo.appControlList) {
+        if (it->m_index > indexMax) {
+            indexMax = it->m_index;
+        }
+    }
 
+    for (std::size_t i = 1; i <= indexMax; ++i) {
+        std::stringstream postfix;
+        postfix << AppControlPrefix::PROCESS_PREFIX << i;
+        std::string controlExec = exec;
+        controlExec.append(postfix.str());
+        errno = 0;
+        if (symlink(clientExeStr.c_str(), controlExec.c_str()) != 0) {
+            int error = errno;
+            if (error) {
+                LogPedantic("Failed to make a symbolic name for a file "
+                    << "[" <<  DPL::GetErrnoString(error) << "]");
+            }
+            ThrowMsg(Exceptions::FileOperationFailed,
+                     "Symbolic link creating is not done.");
+        }
+    }
+#else
+    //default widget
+    LogInfo("link -s " << clientExeStr << " " << exec);
+    errno = 0;
+    if (symlink(clientExeStr.c_str(), exec.c_str()) != 0)
+    {
+        int error = errno;
+        if (error)
+            LogPedantic("Failed to make a symbolic name for a file "
+                    << "[" <<  DPL::GetErrnoString(error) << "]");
+        ThrowMsg(Exceptions::FileOperationFailed,
+                "Symbolic link creating is not done.");
+    }
+#endif
     m_context.job->UpdateProgress(
-        InstallerContext::INSTALL_CREATE_EXECFILE,
-        "Widget execfile creation Finished");
+            InstallerContext::INSTALL_CREATE_EXECFILE,
+            "Widget execfile creation Finished");
 }
 
 void TaskManifestFile::stepCopyIconFiles()
@@ -149,27 +204,32 @@ void TaskManifestFile::stepCopyIconFiles()
     //which there is at least one icon in widget for, icon file is copied.
     //Coping prioritize last positions when coping. If there is several icons
     //with given locale, the one, that will be copied, will be icon
-    //which is declared by <icon> tag later than the others in config.xml of widget
+    //which is declared by <icon> tag later than the others in config.xml of
+    // widget
 
     std::vector<Locale> generatedLocales;
 
-    WrtDB::WidgetRegisterInfo::LocalizedIconList & icons = m_context.widgetConfig.localizationData.icons;
+    WrtDB::WidgetRegisterInfo::LocalizedIconList & icons =
+        m_context.widgetConfig.localizationData.icons;
 
-    //reversed: last <icon> has highest priority to be copied if it has given locale (TODO: why was that working that way?)
-    for(WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator icon = icons.rbegin(); icon != icons.rend(); icon++)
+    //reversed: last <icon> has highest priority to be copied if it has given
+    // locale (TODO: why was that working that way?)
+    for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator
+         icon = icons.rbegin();
+         icon != icons.rend();
+         ++icon)
     {
         FOREACH(locale, icon->availableLocales)
         {
             DPL::String src = icon->src;
             LogDebug("Icon for locale: " << *locale << "is : " << src);
 
-            if(std::find(generatedLocales.begin(), generatedLocales.end(), *locale) != generatedLocales.end())
+            if (std::find(generatedLocales.begin(), generatedLocales.end(),
+                          *locale) != generatedLocales.end())
             {
                 LogDebug("Skipping - has that locale");
                 continue;
-            }
-            else
-            {
+            } else {
                 generatedLocales.push_back(*locale);
             }
 
@@ -187,10 +247,11 @@ void TaskManifestFile::stepCopyIconFiles()
             targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
             targetFile << getIconTargetFilename(*locale);
 
-
             if (m_context.widgetConfig.packagingType ==
-                    WrtDB::PKG_TYPE_HOSTED_WEB_APP) {
-                m_context.locations->setIconTargetFilenameForLocale(targetFile.str());
+                WrtDB::PKG_TYPE_HOSTED_WEB_APP)
+            {
+                m_context.locations->setIconTargetFilenameForLocale(
+                    targetFile.str());
             }
 
             LogDebug("Copying icon: " << sourceFile.str() <<
@@ -208,27 +269,30 @@ void TaskManifestFile::stepCopyIconFiles()
             Catch(DPL::FileInput::Exception::Base)
             {
                 // Error while opening or closing source file
-                //ReThrowMsg(InstallerException::CopyIconFailed, sourceFile.str());
+                //ReThrowMsg(InstallerException::CopyIconFailed,
+                // sourceFile.str());
                 LogError(
-                    "Copying widget's icon failed. Widget's icon will not be"\
+                    "Copying widget's icon failed. Widget's icon will not be" \
                     "available from Main Screen");
             }
 
             Catch(DPL::FileOutput::Exception::Base)
             {
                 // Error while opening or closing target file
-                //ReThrowMsg(InstallerException::CopyIconFailed, targetFile.str());
+                //ReThrowMsg(InstallerException::CopyIconFailed,
+                // targetFile.str());
                 LogError(
-                    "Copying widget's icon failed. Widget's icon will not be"\
+                    "Copying widget's icon failed. Widget's icon will not be" \
                     "available from Main Screen");
             }
 
             Catch(DPL::CopyFailed)
             {
                 // Error while copying
-                //ReThrowMsg(InstallerException::CopyIconFailed, targetFile.str());
+                //ReThrowMsg(InstallerException::CopyIconFailed,
+                // targetFile.str());
                 LogError(
-                    "Copying widget's icon failed. Widget's icon will not be"\
+                    "Copying widget's icon failed. Widget's icon will not be" \
                     "available from Main Screen");
             }
         }
@@ -286,18 +350,18 @@ void TaskManifestFile::stepAbortIconFiles()
         Catch(DPL::FileInput::Exception::Base)
         {
             LogError("Restoration icon File Failed." << backup_file.str()
-                    << " to " << res_file.str());
+                                                     << " to " << res_file.str());
         }
 
         Catch(DPL::FileOutput::Exception::Base)
         {
             LogError("Restoration icon File Failed." << backup_file.str()
-                    << " to " << res_file.str());
+                                                     << " to " << res_file.str());
         }
         Catch(DPL::CopyFailed)
         {
             LogError("Restoration icon File Failed." << backup_file.str()
-                    << " to " << res_file.str());
+                                                     << " to " << res_file.str());
         }
     }
 }
@@ -309,7 +373,7 @@ void TaskManifestFile::stepUpdateFinalize()
 }
 
 DPL::String TaskManifestFile::getIconTargetFilename(
-        const DPL::String& languageTag) const
+    const DPL::String& languageTag) const
 {
     DPL::OStringStream filename;
     TizenAppId appid = m_context.widgetConfig.tzAppid;
@@ -317,12 +381,15 @@ DPL::String TaskManifestFile::getIconTargetFilename(
     filename << DPL::ToUTF8String(appid).c_str();
 
     if (!languageTag.empty()) {
-        DPL::OptionalString tag = getLangTag(languageTag); // translate en -> en_US etc
-        if (tag.IsNull()) { tag = languageTag; }
+        DPL::OptionalString tag = getLangTag(languageTag); // translate en ->
+                                                           // en_US etc
+        if (tag.IsNull()) {
+            tag = languageTag;
+        }
         DPL::String locale =
             LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
 
-       if(locale.empty()) {
+        if (locale.empty()) {
             filename << L"." << languageTag;
         } else {
             filename << L"." << locale;
@@ -339,13 +406,12 @@ void TaskManifestFile::stepFinalize()
     LogInfo("Finished ManifestFile step");
 }
 
-
 void TaskManifestFile::saveLocalizedKey(std::ofstream &file,
-        const DPL::String& key,
-        const DPL::String& languageTag)
+                                        const DPL::String& key,
+                                        const DPL::String& languageTag)
 {
     DPL::String locale =
-            LanguageTagsProvider::BCP47LanguageTagToLocale(languageTag);
+        LanguageTagsProvider::BCP47LanguageTagToLocale(languageTag);
 
     file << key;
     if (!locale.empty()) {
@@ -354,33 +420,6 @@ void TaskManifestFile::saveLocalizedKey(std::ofstream &file,
     file << "=";
 }
 
-void TaskManifestFile::updateAilInfo()
-{
-    // Update ail for desktop
-    std::string cfgAppid =
-        DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
-    const char* appid = cfgAppid.c_str();
-
-    LogDebug("Update ail desktop : " << appid);
-    ail_appinfo_h ai = NULL;
-    ail_error_e ret;
-
-    ret = ail_package_get_appinfo(appid, &ai);
-    if (ai) {
-        ail_package_destroy_appinfo(ai);
-    }
-
-    if (AIL_ERROR_NO_DATA == ret) {
-        if (ail_desktop_add(appid) < 0) {
-            LogWarning("Failed to add ail desktop : " << appid);
-        }
-    } else if (AIL_ERROR_OK == ret) {
-        if (ail_desktop_update(appid) < 0) {
-            LogWarning("Failed to update ail desktop : " << appid);
-        }
-    }
-}
-
 void TaskManifestFile::backupIconFiles()
 {
     LogInfo("Backup Icon Files");
@@ -398,7 +437,8 @@ void TaskManifestFile::backupIconFiles()
     FOREACH(it, fileList)
     {
         if (0 == (strncmp((*it).c_str(), appid.c_str(),
-                        strlen(appid.c_str())))) {
+                          strlen(appid.c_str()))))
+        {
             std::ostringstream icon_file, backup_icon;
             icon_file << GlobalConfig::GetUserWidgetDesktopIconPath();
             icon_file << "/" << (*it);
@@ -406,7 +446,7 @@ void TaskManifestFile::backupIconFiles()
             backup_icon << b_icon_dir.str() << "/" << (*it);
 
             LogDebug("Backup icon file " << icon_file.str() << " to " <<
-                    backup_icon.str());
+                     backup_icon.str());
             Try
             {
                 DPL::FileInput input(icon_file.str());
@@ -435,28 +475,38 @@ void TaskManifestFile::backupIconFiles()
 }
 
 void TaskManifestFile::getFileList(const char* path,
-        std::list<std::string> &list)
+                                   std::list<std::string> &list)
 {
     DIR* dir = opendir(path);
     if (!dir) {
         LogError("icon directory doesn't exist");
-        ThrowMsg(Exceptions::InternalError, path);
+        ThrowMsg(Exceptions::FileOperationFailed, path);
     }
 
-    struct dirent* d_ent;
-    do {
-        if ((d_ent = readdir(dir))) {
-            if(strcmp(d_ent->d_name, ".") == 0 ||
-                    strcmp(d_ent->d_name, "..") == 0) {
-                continue;
-            }
-            std::string file_name = d_ent->d_name;
-            list.push_back(file_name);
+    struct dirent entry;
+    struct dirent *result;
+    int return_code;
+    errno = 0;
+    for (return_code = readdir_r(dir, &entry, &result);
+            result != NULL && return_code == 0;
+            return_code = readdir_r(dir, &entry, &result))
+    {
+        if (strcmp(entry.d_name, ".") == 0 ||
+            strcmp(entry.d_name, "..") == 0)
+        {
+            continue;
         }
-    }while(d_ent);
+        std::string file_name = entry.d_name;
+        list.push_back(file_name);
+    }
+
+    if (return_code != 0 || errno != 0) {
+        LogError("readdir_r() failed with " << DPL::GetErrnoString());
+    }
+
     if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
         LogError("Failed to close dir: " << path << " with error: "
-                << DPL::GetErrnoString());
+                                         << DPL::GetErrnoString());
     }
 }
 
@@ -481,15 +531,11 @@ void TaskManifestFile::stepParseManifest()
     int code = pkgmgr_parser_parse_manifest_for_installation(
             DPL::ToUTF8String(manifest_file).c_str(), NULL);
 
-    if(code != 0)
-    {
+    if (code != 0) {
         LogError("Manifest parser error: " << code);
-        ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
+        ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code);
     }
 
-    // TODO : It will be removed. AIL update is temporary code request by pkgmgr team.
-    updateAilInfo();
-
     m_context.job->UpdateProgress(
         InstallerContext::INSTALL_CREATE_MANIFEST,
         "Widget Manifest Parsing Finished");
@@ -501,15 +547,11 @@ void TaskManifestFile::stepParseUpgradedManifest()
     int code = pkgmgr_parser_parse_manifest_for_upgrade(
             DPL::ToUTF8String(manifest_file).c_str(), NULL);
 
-    if(code != 0)
-    {
+    if (code != 0) {
         LogError("Manifest parser error: " << code);
-        ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
+        ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code);
     }
 
-    // TODO : It will be removed. AIL update is temporary code request by pkgmgr team.
-    updateAilInfo();
-
     m_context.job->UpdateProgress(
         InstallerContext::INSTALL_CREATE_MANIFEST,
         "Widget Manifest Parsing Finished");
@@ -521,7 +563,13 @@ void TaskManifestFile::commitManifest()
     LogDebug("Commiting manifest file : " << manifest_file);
 
     std::ostringstream destFile;
-    destFile << "/opt/share/packages" << "/"; //TODO constant with path
+    if (m_context.job->getInstallerStruct().m_installMode
+            == InstallMode::INSTALL_MODE_PRELOAD)
+    {
+        destFile << "/usr/share/packages" << "/"; //TODO constant with path
+    } else {
+        destFile << "/opt/share/packages" << "/"; //TODO constant with path
+    }
     destFile << DPL::ToUTF8String(manifest_name);
     LogInfo("cp " << manifest_file << " " << destFile.str());
 
@@ -541,66 +589,130 @@ void TaskManifestFile::writeManifest(const DPL::String & path)
     Manifest manifest;
     UiApplication uiApp;
 
+#ifdef MULTIPROCESS_SERVICE_SUPPORT
+    //default widget content
+    std::stringstream postfix;
+    // index 0 is reserved
+    postfix << AppControlPrefix::PROCESS_PREFIX << 0;
+    setWidgetExecPath(uiApp, postfix.str());
+    setWidgetName(manifest, uiApp);
+    setWidgetIds(manifest, uiApp);
+    setWidgetIcons(uiApp);
+    setWidgetDescription(manifest);
+    setWidgetManifest(manifest);
+    setWidgetOtherInfo(uiApp);
+    setAppCategory(uiApp);
+    setLiveBoxInfo(manifest);
+    setAccount(manifest);
+    setPrivilege(manifest);
+    manifest.addUiApplication(uiApp);
+
+    //app-control content
+    ConfigParserData::AppControlInfoList appControlList =
+        m_context.widgetConfig.configInfo.appControlList;
+    FOREACH(it, appControlList) {
+        UiApplication uiApp;
+
+        uiApp.setTaskmanage(true);
+        uiApp.setNodisplay(true);
+#ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
+        uiApp.setTaskmanage(ConfigParserData::AppControlInfo::Disposition::INLINE != it->m_disposition);
+        uiApp.setMultiple(ConfigParserData::AppControlInfo::Disposition::INLINE == it->m_disposition);
+#endif
+        std::stringstream postfix;
+        postfix << AppControlPrefix::PROCESS_PREFIX << it->m_index;
+        setWidgetExecPath(uiApp, postfix.str());
+        setWidgetName(manifest, uiApp);
+        setWidgetIds(manifest, uiApp);
+        setWidgetIcons(uiApp);
+        setAppControlInfo(uiApp, *it);
+        setAppCategory(uiApp);
+        manifest.addUiApplication(uiApp);
+    }
+#else
+    //default widget content
     setWidgetExecPath(uiApp);
     setWidgetName(manifest, uiApp);
+    setWidgetIds(manifest, uiApp);
     setWidgetIcons(uiApp);
     setWidgetManifest(manifest);
     setWidgetOtherInfo(uiApp);
-    setAppServiceInfo(uiApp);
-    setAppControlInfo(uiApp);
+    setAppControlsInfo(uiApp);
     setAppCategory(uiApp);
     setLiveBoxInfo(manifest);
+    setAccount(manifest);
+    setPrivilege(manifest);
 
     manifest.addUiApplication(uiApp);
+#endif
+
     manifest.generate(path);
     LogDebug("Manifest file serialized");
 }
 
-void TaskManifestFile::setWidgetExecPath(UiApplication & uiApp)
+void TaskManifestFile::setWidgetExecPath(UiApplication & uiApp,
+                                         const std::string &postfix)
 {
-    uiApp.setExec(DPL::FromASCIIString(m_context.locations->getExecFile()));
+    std::string exec = m_context.locations->getExecFile();
+    if (!postfix.empty()) {
+        exec.append(postfix);
+    }
+    LogDebug("exec = " << exec);
+    uiApp.setExec(DPL::FromASCIIString(exec));
 }
 
-void TaskManifestFile::setWidgetName(Manifest & manifest, UiApplication & uiApp)
+void TaskManifestFile::setWidgetName(Manifest & manifest,
+                                     UiApplication & uiApp)
 {
     bool defaultNameSaved = false;
 
-    DPL::OptionalString defaultLocale = m_context.widgetConfig.configInfo.defaultlocale;
-    std::pair<DPL::String, WrtDB::ConfigParserData::LocalizedData> defaultLocalizedData;
+    DPL::OptionalString defaultLocale =
+        m_context.widgetConfig.configInfo.defaultlocale;
+    std::pair<DPL::String,
+              WrtDB::ConfigParserData::LocalizedData> defaultLocalizedData;
     //labels
     FOREACH(localizedData, m_context.widgetConfig.configInfo.localizedDataSet)
     {
         Locale i = localizedData->first;
         DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc
-        if (tag.IsNull())
-        {
+        if (tag.IsNull()) {
             tag = i;
         }
         DPL::OptionalString name = localizedData->second.name;
         generateWidgetName(manifest, uiApp, tag, name, defaultNameSaved);
 
         //store default locale localized data
-        if(!!defaultLocale && defaultLocale == i)
-        {
+        if (!!defaultLocale && defaultLocale == i) {
             defaultLocalizedData = *localizedData;
         }
     }
 
-    if (!!defaultLocale && !defaultNameSaved)
-    {
+    if (!!defaultLocale && !defaultNameSaved) {
         DPL::OptionalString name = defaultLocalizedData.second.name;
-        generateWidgetName(manifest, uiApp, DPL::OptionalString::Null, name, defaultNameSaved);
+        generateWidgetName(manifest,
+                           uiApp,
+                           DPL::OptionalString::Null,
+                           name,
+                           defaultNameSaved);
     }
+}
+
+void TaskManifestFile::setWidgetIds(Manifest & manifest,
+                                    UiApplication & uiApp,
+                                    const std::string &postfix)
+{
     //appid
     TizenAppId appid = m_context.widgetConfig.tzAppid;
+    if (!postfix.empty()) {
+        appid = DPL::FromUTF8String(DPL::ToUTF8String(appid).append(postfix));
+    }
     uiApp.setAppid(appid);
 
-
     //extraid
-    if(!!m_context.widgetConfig.guid) {
+    if (!!m_context.widgetConfig.guid) {
         uiApp.setExtraid(*m_context.widgetConfig.guid);
     } else {
-        if(!appid.empty()) {
+        if (!appid.empty()) {
             uiApp.setExtraid(DPL::String(L"http://") + appid);
         }
     }
@@ -610,25 +722,24 @@ void TaskManifestFile::setWidgetName(Manifest & manifest, UiApplication & uiApp)
     manifest.setType(L"wgt");
 }
 
-void TaskManifestFile::generateWidgetName(Manifest & manifest, UiApplication &uiApp, const DPL::OptionalString& tag, DPL::OptionalString name, bool & defaultNameSaved)
+void TaskManifestFile::generateWidgetName(Manifest & manifest,
+                                          UiApplication &uiApp,
+                                          const DPL::OptionalString& tag,
+                                          DPL::OptionalString name,
+                                          bool & defaultNameSaved)
 {
     if (!!name) {
-        if (!!tag)
-        {
+        if (!!tag) {
             DPL::String locale =
-                    LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
+                LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
 
             if (!locale.empty()) {
-                uiApp.addLabel(LabelType(*name,*tag));
-            }
-            else
-            {
+                uiApp.addLabel(LabelType(*name, *tag));
+            } else {
                 uiApp.addLabel(LabelType(*name));
                 manifest.addLabel(LabelType(*name));
             }
-        }
-        else
-        {
+        } else {
             defaultNameSaved = true;
             uiApp.addLabel(LabelType(*name));
             manifest.addLabel(LabelType(*name));
@@ -642,63 +753,103 @@ void TaskManifestFile::setWidgetIcons(UiApplication & uiApp)
     //changes.
     bool defaultIconSaved = false;
 
-    DPL::OptionalString defaultLocale = m_context.widgetConfig.configInfo.defaultlocale;
+    DPL::OptionalString defaultLocale =
+        m_context.widgetConfig.configInfo.defaultlocale;
 
     std::vector<Locale> generatedLocales;
-    WrtDB::WidgetRegisterInfo::LocalizedIconList & icons = m_context.widgetConfig.localizationData.icons;
-
-    //reversed: last <icon> has highest priority to be writen to manifest if it has given locale (TODO: why was that working that way?)
-    for(WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator icon = icons.rbegin(); icon != icons.rend(); icon++)
+    WrtDB::WidgetRegisterInfo::LocalizedIconList & icons =
+        m_context.widgetConfig.localizationData.icons;
+
+    //reversed: last <icon> has highest priority to be writen to manifest if it
+    // has given locale (TODO: why was that working that way?)
+    for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator
+         icon = icons.rbegin();
+         icon != icons.rend();
+         ++icon)
     {
         FOREACH(locale, icon->availableLocales)
         {
-            if(std::find(generatedLocales.begin(), generatedLocales.end(), *locale) != generatedLocales.end())
+            if (std::find(generatedLocales.begin(), generatedLocales.end(),
+                          *locale) != generatedLocales.end())
             {
                 LogDebug("Skipping - has that locale - already in manifest");
                 continue;
-            }
-            else
-            {
+            } else {
                 generatedLocales.push_back(*locale);
             }
 
-            DPL::OptionalString tag = getLangTag(*locale); // translate en -> en_US etc
-            if (tag.IsNull()) { tag = *locale; }
+            DPL::OptionalString tag = getLangTag(*locale); // translate en ->
+                                                           // en_US etc
+            if (tag.IsNull()) {
+                tag = *locale;
+            }
 
             generateWidgetIcon(uiApp, tag, *locale, defaultIconSaved);
         }
     }
-    if (!!defaultLocale && !defaultIconSaved)
-    {
+    if (!!defaultLocale && !defaultIconSaved) {
         generateWidgetIcon(uiApp, DPL::OptionalString::Null,
                            DPL::String(),
                            defaultIconSaved);
     }
 }
 
-void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp, const DPL::OptionalString& tag,
-        const DPL::String& language, bool & defaultIconSaved)
+void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp,
+                                          const DPL::OptionalString& tag,
+                                          const DPL::String& language,
+                                          bool & defaultIconSaved)
 {
     DPL::String locale;
-    if (!!tag)
-    {
+    if (!!tag) {
         locale = LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
-    }
-    else
-    {
+    } else {
         defaultIconSaved = true;
     }
 
     DPL::String iconText;
     iconText += getIconTargetFilename(language);
 
-    if(!locale.empty())
-    {
+    if (!locale.empty()) {
         uiApp.addIcon(IconType(iconText, locale));
+    } else {
+        uiApp.addIcon(IconType(iconText));
     }
-    else
+    std::ostringstream iconPath;
+    iconPath << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
+    iconPath << getIconTargetFilename(locale);
+     m_context.job->SendProgressIconPath(iconPath.str());
+}
+
+void TaskManifestFile::setWidgetDescription(Manifest & manifest)
+{
+    FOREACH(localizedData, m_context.widgetConfig.configInfo.localizedDataSet)
     {
-        uiApp.addIcon(IconType(iconText));
+        Locale i = localizedData->first;
+        DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc
+        if (tag.IsNull()) {
+            tag = i;
+        }
+        DPL::OptionalString description = localizedData->second.description;
+        generateWidgetDescription(manifest, tag, description);
+    }
+}
+
+void TaskManifestFile::generateWidgetDescription(Manifest & manifest,
+                                                 const DPL::OptionalString& tag,
+                                                  DPL::OptionalString description)
+{
+    if (!!description) {
+        if (!!tag) {
+            DPL::String locale =
+                LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
+            if (!locale.empty()) {
+                manifest.addDescription(DescriptionType(*description, locale));
+            } else {
+                manifest.addDescription(DescriptionType(*description));
+            }
+        } else {
+            manifest.addDescription(DescriptionType(*description));
+        }
     }
 }
 
@@ -706,67 +857,41 @@ void TaskManifestFile::setWidgetManifest(Manifest & manifest)
 {
     manifest.setPackage(m_context.widgetConfig.tzPkgid);
 
-    if(!!m_context.widgetConfig.version)
-    {
+    if (!!m_context.widgetConfig.version) {
         manifest.setVersion(*m_context.widgetConfig.version);
     }
     DPL::String email = (!!m_context.widgetConfig.configInfo.authorEmail ?
-                            *m_context.widgetConfig.configInfo.authorEmail : L"");
+                         *m_context.widgetConfig.configInfo.authorEmail : L"");
     DPL::String href = (!!m_context.widgetConfig.configInfo.authorHref ?
-                            *m_context.widgetConfig.configInfo.authorHref : L"");
+                        *m_context.widgetConfig.configInfo.authorHref : L"");
     DPL::String name = (!!m_context.widgetConfig.configInfo.authorName ?
-                            *m_context.widgetConfig.configInfo.authorName : L"");
-    manifest.addAuthor(Author(email,href,L"",name));
+                        *m_context.widgetConfig.configInfo.authorName : L"");
+    manifest.addAuthor(Author(email, href, L"", name));
 }
 
 void TaskManifestFile::setWidgetOtherInfo(UiApplication & uiApp)
 {
     FOREACH(it, m_context.widgetConfig.configInfo.settingsList)
     {
-         if(!strcmp(DPL::ToUTF8String(it->m_name).c_str(), ST_NODISPLAY)) {
-             if(!strcmp(DPL::ToUTF8String(it->m_value).c_str(), ST_TRUE)) {
+        if (!strcmp(DPL::ToUTF8String(it->m_name).c_str(), ST_NODISPLAY)) {
+            if (!strcmp(DPL::ToUTF8String(it->m_value).c_str(), ST_TRUE)) {
                 uiApp.setNodisplay(true);
                 uiApp.setTaskmanage(false);
-             }
-             else {
+            } else {
                 uiApp.setNodisplay(false);
                 uiApp.setTaskmanage(true);
             }
-         }
-     }
+        }
+    }
     //TODO
     //There is no "X-TIZEN-PackageType=wgt"
-    //There is no X-TIZEN-PackageID in manifest "X-TIZEN-PackageID=" << DPL::ToUTF8String(*widgetID).c_str()
+    //There is no X-TIZEN-PackageID in manifest "X-TIZEN-PackageID=" <<
+    // DPL::ToUTF8String(*widgetID).c_str()
     //There is no Comment in pkgmgr "Comment=Widget application"
     //that were in desktop file
 }
 
-void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp)
-{
-    WrtDB::ConfigParserData::ServiceInfoList appServiceList = m_context.widgetConfig.configInfo.appServiceList;
-
-    if (appServiceList.empty()) {
-        LogInfo("Widget doesn't contain application service");
-        return;
-    }
-
-    // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image;
-    FOREACH(it, appServiceList) {
-        AppControl appControl;
-        if (!it->m_operation.empty()) {
-            appControl.addOperation(it->m_operation); //TODO: encapsulation?
-        }
-        if (!it->m_scheme.empty()) {
-            appControl.addUri(it->m_scheme);
-        }
-        if (!it->m_mime.empty()) {
-            appControl.addMime(it->m_mime);
-        }
-        uiApp.addAppControl(appControl);
-    }
-}
-
-void TaskManifestFile::setAppControlInfo(UiApplication & uiApp)
+void TaskManifestFile::setAppControlsInfo(UiApplication & uiApp)
 {
     WrtDB::ConfigParserData::AppControlInfoList appControlList =
         m_context.widgetConfig.configInfo.appControlList;
@@ -776,24 +901,31 @@ void TaskManifestFile::setAppControlInfo(UiApplication & uiApp)
         return;
     }
 
-    // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image;
+     // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image;
     FOREACH(it, appControlList) {
-        AppControl appControl;
-        if (!it->m_operation.empty()) {
-            appControl.addOperation(it->m_operation); //TODO: encapsulation?
-        }
-        if (!it->m_uriList.empty()) {
-            FOREACH(uri, it->m_uriList) {
-                appControl.addUri(*uri);
-            }
+        setAppControlInfo(uiApp, *it);
+    }
+}
+
+void TaskManifestFile::setAppControlInfo(UiApplication & uiApp,
+                                         const WrtDB::ConfigParserData::AppControlInfo & service)
+{
+    // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image;
+    AppControl appControl;
+    if (!service.m_operation.empty()) {
+        appControl.addOperation(service.m_operation); //TODO: encapsulation?
+    }
+    if (!service.m_uriList.empty()) {
+        FOREACH(uri, service.m_uriList) {
+            appControl.addUri(*uri);
         }
-        if (!it->m_mimeList.empty()) {
-            FOREACH(mime, it->m_mimeList) {
-                appControl.addMime(*mime);
-            }
+    }
+    if (!service.m_mimeList.empty()) {
+        FOREACH(mime, service.m_mimeList) {
+            appControl.addMime(*mime);
         }
-        uiApp.addAppControl(appControl);
     }
+    uiApp.addAppControl(appControl);
 }
 
 void TaskManifestFile::setAppCategory(UiApplication &uiApp)
@@ -819,14 +951,12 @@ void TaskManifestFile::stepAbortParseManifest()
     int code = pkgmgr_parser_parse_manifest_for_uninstallation(
             DPL::ToUTF8String(manifest_file).c_str(), NULL);
 
-    if (0 != code)
-    {
+    if (0 != code) {
         LogWarning("Manifest parser error: " << code);
-        ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
+        ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code);
     }
     int ret = unlink(DPL::ToUTF8String(manifest_file).c_str());
-    if (0 != ret)
-    {
+    if (0 != ret) {
         LogWarning("No manifest file found: " << manifest_file);
     }
 }
@@ -838,14 +968,13 @@ void TaskManifestFile::setLiveBoxInfo(Manifest& manifest)
         LiveBoxInfo liveBox;
         DPL::Optional<WrtDB::ConfigParserData::LiveboxInfo> ConfigInfo = *it;
         DPL::String appid = m_context.widgetConfig.tzAppid;
-        size_t found;
 
-        if(ConfigInfo->m_liveboxId != L"") {
-            found = ConfigInfo->m_liveboxId.find_last_of(L".");
-            if(found != std::string::npos) {
-                if(0 == ConfigInfo->m_liveboxId.compare(0, found, appid))
+        if (ConfigInfo->m_liveboxId != L"") {
+            size_t found = ConfigInfo->m_liveboxId.find_last_of(L".");
+            if (found != std::string::npos) {
+                if (0 == ConfigInfo->m_liveboxId.compare(0, found, appid)) {
                     liveBox.setLiveboxId(ConfigInfo->m_liveboxId);
-                else {
+                else {
                     DPL::String liveboxId =
                         appid + DPL::String(L".") + ConfigInfo->m_liveboxId;
                     liveBox.setLiveboxId(liveboxId);
@@ -857,58 +986,93 @@ void TaskManifestFile::setLiveBoxInfo(Manifest& manifest)
             }
         }
 
-        if(ConfigInfo->m_primary != L"")
+        if (ConfigInfo->m_primary != L"") {
             liveBox.setPrimary(ConfigInfo->m_primary);
+        }
 
-        if(ConfigInfo->m_autoLaunch == L"true")
-            liveBox.setAutoLaunch(appid);
-
-        if(ConfigInfo->m_updatePeriod != L"")
+        if (ConfigInfo->m_updatePeriod != L"") {
             liveBox.setUpdatePeriod(ConfigInfo->m_updatePeriod);
+        }
 
-        if(ConfigInfo->m_label != L"")
+        if (ConfigInfo->m_label != L"") {
             liveBox.setLabel(ConfigInfo->m_label);
+        }
 
         DPL::String defaultLocale
-            = DPL::FromUTF8String(m_context.locations->getPackageInstallationDir())
-            + DPL::String(L"/res/wgt/");
+            = DPL::FromUTF8String(
+                    m_context.locations->getPackageInstallationDir())
+                + DPL::String(L"/res/wgt/");
 
-        if(ConfigInfo->m_icon!=L"") {
-            liveBox.setIcon(defaultLocale+ConfigInfo->m_icon);
+        if (ConfigInfo->m_icon != L"") {
+            liveBox.setIcon(defaultLocale + ConfigInfo->m_icon);
         }
 
-        if (ConfigInfo->m_boxInfo.m_boxSrc.empty() || ConfigInfo->m_boxInfo.m_boxSize.empty()) {
+        if (ConfigInfo->m_boxInfo.m_boxSrc.empty() ||
+            ConfigInfo->m_boxInfo.m_boxSize.empty())
+        {
             LogInfo("Widget doesn't contain box");
             return;
         } else {
             BoxInfoType box;
             if (!ConfigInfo->m_boxInfo.m_boxSrc.empty()) {
-                if((0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 4, L"http"))
-                        || (0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 5, L"https")))
+                if ((0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 4, L"http"))
+                    || (0 ==
+                        ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 5, L"https")))
+                {
                     box.boxSrc = ConfigInfo->m_boxInfo.m_boxSrc;
-                else
+                } else {
                     box.boxSrc = defaultLocale + ConfigInfo->m_boxInfo.m_boxSrc;
+                }
             }
 
             if (ConfigInfo->m_boxInfo.m_boxMouseEvent == L"true") {
-                box.boxMouseEvent = ConfigInfo->m_boxInfo.m_boxMouseEvent;
+                std::string boxType;
+                if (ConfigInfo->m_type == L"") {
+                    // in case of default livebox
+                    boxType = web_provider_livebox_get_default_type();
+                } else {
+                    boxType = DPL::ToUTF8String(ConfigInfo->m_type);
+                }
+
+                int box_scrollable =
+                    web_provider_plugin_get_box_scrollable(boxType.c_str());
+
+                if (box_scrollable) {
+                    box.boxMouseEvent = L"true";
+                } else {
+                    box.boxMouseEvent = L"false";
+                }
             } else {
                 box.boxMouseEvent = L"false";
             }
 
-            std::list<std::pair<DPL::String,DPL::String>> BoxSizeList
+            if (ConfigInfo->m_boxInfo.m_boxTouchEffect == L"true") {
+                box.boxTouchEffect = L"true";
+            } else {
+                box.boxTouchEffect= L"false";
+            }
+
+            std::list<std::pair<DPL::String, DPL::String> > BoxSizeList
                 = ConfigInfo->m_boxInfo.m_boxSize;
             FOREACH(im, BoxSizeList) {
                 std::pair<DPL::String, DPL::String> boxSize = *im;
-                if(!boxSize.second.empty())
+                if (!boxSize.second.empty()) {
                     boxSize.second = defaultLocale + boxSize.second;
+                }
                 box.boxSize.push_back(boxSize);
             }
 
             if (!ConfigInfo->m_boxInfo.m_pdSrc.empty()
-                    && !ConfigInfo->m_boxInfo.m_pdWidth.empty()
-                    && !ConfigInfo->m_boxInfo.m_pdHeight.empty()) {
-                box.pdSrc = defaultLocale + ConfigInfo->m_boxInfo.m_pdSrc;
+                && !ConfigInfo->m_boxInfo.m_pdWidth.empty()
+                && !ConfigInfo->m_boxInfo.m_pdHeight.empty())
+            {
+                if ((0 == ConfigInfo->m_boxInfo.m_pdSrc.compare(0, 4, L"http"))
+                    || (0 == ConfigInfo->m_boxInfo.m_pdSrc.compare(0, 5, L"https")))
+                {
+                    box.pdSrc = ConfigInfo->m_boxInfo.m_pdSrc;
+                } else {
+                    box.pdSrc = defaultLocale + ConfigInfo->m_boxInfo.m_pdSrc;
+                }
                 box.pdWidth = ConfigInfo->m_boxInfo.m_pdWidth;
                 box.pdHeight = ConfigInfo->m_boxInfo.m_pdHeight;
             }
@@ -916,7 +1080,65 @@ void TaskManifestFile::setLiveBoxInfo(Manifest& manifest)
         }
         manifest.addLivebox(liveBox);
     }
+}
+
+void TaskManifestFile::setAccount(Manifest& manifest)
+{
+    WrtDB::ConfigParserData::AccountProvider account =
+        m_context.widgetConfig.configInfo.accountProvider;
+
+    AccountProviderType provider;
+
+    if (account.m_iconSet.empty()) {
+        LogInfo("Widget doesn't contain Account");
+        return;
+    }
+    if (account.m_multiAccountSupport) {
+        provider.multiAccount = L"ture";
+    } else {
+        provider.multiAccount = L"false";
+    }
+    provider.appid = m_context.widgetConfig.tzAppid;
+
+    FOREACH(it, account.m_iconSet) {
+        std::pair<DPL::String, DPL::String> icon;
+
+        if (it->first == ConfigParserData::IconSectionType::DefaultIcon) {
+            icon.first = L"account";
+        } else if (it->first == ConfigParserData::IconSectionType::SmallIcon) {
+            icon.first = L"account-small";
+        }
+        icon.second = it->second;
+
+        provider.icon.push_back(icon);
+    }
+
+    FOREACH(it, account.m_displayNameSet) {
+        provider.name.push_back(LabelType(it->second, it->first));
+    }
+
+    FOREACH(it, account.m_capabilityList) {
+        provider.capability.push_back(*it);
+    }
+
+    Account accountInfo;
+    accountInfo.addAccountProvider(provider);
+    manifest.addAccount(accountInfo);
+}
+
+void TaskManifestFile::setPrivilege(Manifest& manifest)
+{
+    WrtDB::ConfigParserData::PrivilegeList privileges =
+        m_context.widgetConfig.configInfo.privilegeList;
+
+    PrivilegeType privilege;
+
+    FOREACH(it, privileges)
+    {
+        privilege.addPrivilegeName(it->name);
+    }
 
+    manifest.addPrivileges(privilege);
 }
 
 } //namespace WidgetInstall