Handle 'mouse-event' attribute differently according to configuration of web-provider...
[framework/web/wrt-installer.git] / src / jobs / widget_install / task_manifest_file.cpp
index 593c326..18ddf7e 100644 (file)
  */
 
 //SYSTEM INCLUDES
+#include <unistd.h>
 #include <string>
 #include <dpl/assert.h>
 #include <dirent.h>
-#include<fstream>
+#include <fstream>
 #include <ail.h>
 
 //WRT INCLUDES
 #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>
+#include <dpl/errno_string.h>
 #include <dpl/file_output.h>
 #include <dpl/copy.h>
 #include <dpl/exception.h>
 #include <map>
 #include <libxml_utils.h>
 #include <pkgmgr/pkgmgr_parser.h>
+#include <dpl/localization/LanguageTagsProvider.h>
+
+#define DEFAULT_ICON_NAME   "icon.png"
 
 using namespace WrtDB;
 
 namespace {
 typedef std::map<DPL::String, DPL::String> LanguageTagMap;
 
+const char* const ST_TRUE = "true";
+const char* const ST_NODISPLAY = "nodisplay";
+
 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
 
@@ -90,177 +100,201 @@ 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::stepCreateDesktopFile);
-        AddStep(&TaskManifestFile::stepGenerateManifest);
-        AddStep(&TaskManifestFile::stepParseManifest);
-        AddStep(&TaskManifestFile::stepCreateExecFile);
-        AddStep(&TaskManifestFile::stepFinalize);
-    } else {
-    // for widget update.
+    if (m_context.isUpdateMode) {
+        // for widget update.
         AddStep(&TaskManifestFile::stepBackupIconFiles);
         AddStep(&TaskManifestFile::stepCopyIconFiles);
-        //AddStep(&TaskManifestFile::stepUpdateDesktopFile);
         AddStep(&TaskManifestFile::stepGenerateManifest);
         AddStep(&TaskManifestFile::stepParseUpgradedManifest);
         AddStep(&TaskManifestFile::stepUpdateFinalize);
 
         AddAbortStep(&TaskManifestFile::stepAbortIconFiles);
-        //AddAbortStep(&TaskManifestFile::stepAbortDesktopFile);
+    } else {
+        AddStep(&TaskManifestFile::stepCopyIconFiles);
+        AddStep(&TaskManifestFile::stepCreateExecFile);
+        AddStep(&TaskManifestFile::stepGenerateManifest);
+        AddStep(&TaskManifestFile::stepParseManifest);
+        AddStep(&TaskManifestFile::stepFinalize);
+
+        AddAbortStep(&TaskManifestFile::stepAbortParseManifest);
     }
 }
 
 TaskManifestFile::~TaskManifestFile()
-{
-}
-
-
-void TaskManifestFile::stepCreateDesktopFile()
-{
-    DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
-    desktop_name << pkgname << ".desktop";
-    desktop_file << "/tmp/" << desktop_name.str();
-    LogInfo("desktop file : " << desktop_file.str());
-    std::ofstream file(desktop_file.str().c_str());
-
-    saveWidgetType(file);
-    saveWidgetExecPath(file);
-    saveWidgetName(file);
-    saveWidgetIcons(file);
-    saveWidgetVersion(file);
-    saveWidgetOtherInfo(file);
-    saveAppServiceInfo(file);
-
-    file.close();
-
-    moveDesktopFile();
-
-    m_context.job->UpdateProgress(
-        InstallerContext::INSTALL_CREATE_DESKTOP,
-        "Widget Desktop Creation Finished");
-}
+{}
 
 void TaskManifestFile::stepCreateExecFile()
 {
-    //ln -s /usr/bin/wrt-client {widget-handle}
+    std::string exec = m_context.locations->getExecFile();
+    std::string clientExeStr = GlobalConfig::GetWrtClientExec();
 
-    std::ostringstream real_path;
-    DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
-    if (pkgname.IsNull()) {
-        ThrowMsg(Exceptions::InternalError, "No Package name exists.");
-    }
+#ifdef MULTIPROCESS_SERVICE_SUPPORT
+    //default widget
+    std::stringstream postfix;
+    postfix << AppControlPrefix::PROCESS_PREFIX << 0;
+    std::string controlExec = exec;
+    controlExec.append(postfix.str());
 
-    real_path << GlobalConfig::GetUserInstalledWidgetPath() << "/";
-    real_path << pkgname << "/";
-    real_path << GlobalConfig::GetUserWidgetExecPath() << "/" <<
-    m_context.widgetHandle;
-    std::string clientExeStr = GlobalConfig::GetWrtClientExec();
+    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.");
+    }
 
-    LogInfo("link -s " << clientExeStr << " " << real_path.str());
-    symlink(clientExeStr.c_str(), real_path.str().c_str());
+    // 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()
 {
     LogDebug("CopyIconFiles");
 
-    DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
-    if (pkgname.IsNull()) {
-        ThrowMsg(Exceptions::InternalError, "No Package name exists.");
-    }
+    //This function copies icon to desktop icon path. For each locale avaliable
+    //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
 
-    Assert(!!m_context.widgetHandle);
-    WidgetDAOReadOnly dao(*m_context.widgetHandle);
-    WidgetDAOReadOnly::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
-    WidgetDAOReadOnly::WidgetIconList list = dao.getIconList();
-    FOREACH(it, locList)
+    std::vector<Locale> generatedLocales;
+
+    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)
     {
-        DPL::String i = it->widgetLocale;
-        DPL::OptionalString src;
-        FOREACH(icon, list)
+        FOREACH(locale, icon->availableLocales)
         {
-            if (icon->iconId == it->iconId) {
-                src = icon->iconSrc;
-            }
-        }
-        LogDebug("Icon for locale: " << i << "is : " << src);
+            DPL::String src = icon->src;
+            LogDebug("Icon for locale: " << *locale << "is : " << src);
 
-        std::ostringstream sourceFile;
-        std::ostringstream targetFile;
+            if (std::find(generatedLocales.begin(), generatedLocales.end(),
+                          *locale) != generatedLocales.end())
+            {
+                LogDebug("Skipping - has that locale");
+                continue;
+            } else {
+                generatedLocales.push_back(*locale);
+            }
 
-        if (!!src) {
-            sourceFile << GlobalConfig::GetUserInstalledWidgetPath() << "/";
-            sourceFile << pkgname << "/";
-            sourceFile << GlobalConfig::GetWidgetSrcPath() << "/";
+            std::ostringstream sourceFile;
+            std::ostringstream targetFile;
 
-            targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
+            sourceFile << m_context.locations->getSourceDir() << "/";
 
-            if (!i.empty()) {
-                sourceFile << "locales/" << i << "/";
+            if (!locale->empty()) {
+                sourceFile << "locales/" << *locale << "/";
             }
-            sourceFile << *src;
-            targetFile << getIconTargetFilename(i);
 
-        } else {
-            //Use WRT default (not from the widget) only if widget default (not
-            // localized) doesn't exist.
-            if (i.empty()) {
-                LogError("Using Default Icon for widget");
-                sourceFile << GlobalConfig::GetUserWidgetDefaultIconFile();
-            } else {
-                continue;
+            sourceFile << src;
+
+            targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
+            targetFile << getIconTargetFilename(*locale);
+
+            if (m_context.widgetConfig.packagingType ==
+                WrtDB::PKG_TYPE_HOSTED_WEB_APP)
+            {
+                m_context.locations->setIconTargetFilenameForLocale(
+                    targetFile.str());
             }
-        }
 
-        LogDebug("Copying icon: " << sourceFile.str() <<
-                 " -> " << targetFile.str());
+            LogDebug("Copying icon: " << sourceFile.str() <<
+                     " -> " << targetFile.str());
 
-        icon_list.push_back(targetFile.str());
+            icon_list.push_back(targetFile.str());
 
-        Try
-        {
-            DPL::FileInput input(sourceFile.str());
-            DPL::FileOutput output(targetFile.str());
-            DPL::Copy(&input, &output);
-        }
+            Try
+            {
+                DPL::FileInput input(sourceFile.str());
+                DPL::FileOutput output(targetFile.str());
+                DPL::Copy(&input, &output);
+            }
 
-        Catch(DPL::FileInput::Exception::Base)
-        {
-            // Error while opening or closing source file
-            //ReThrowMsg(InstallerException::CopyIconFailed, sourceFile.str());
-            LogError(
-                "Copying widget's icon failed. Widget's icon will not be"\
-                "available from Main Screen");
-        }
+            Catch(DPL::FileInput::Exception::Base)
+            {
+                // Error while opening or closing source file
+                //ReThrowMsg(InstallerException::CopyIconFailed,
+                // sourceFile.str());
+                LogError(
+                    "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());
-            LogError(
-                "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());
+                LogError(
+                    "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());
-            LogError(
-                "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());
+                LogError(
+                    "Copying widget's icon failed. Widget's icon will not be" \
+                    "available from Main Screen");
+            }
         }
     }
 
@@ -272,14 +306,8 @@ void TaskManifestFile::stepCopyIconFiles()
 void TaskManifestFile::stepBackupIconFiles()
 {
     LogDebug("Backup Icon Files");
-    DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
-    desktop_name << pkgname << ".desktop";
-
-    desktop_file << GlobalConfig::GetUserWidgetDesktopPath() << "/";
-    desktop_file << desktop_name.str();
 
-    backup_dir << GlobalConfig::GetUserInstalledWidgetPath();
-    backup_dir << "/" << m_context.widgetConfig.pkgname;
+    backup_dir << m_context.locations->getPackageInstallationDir();
     backup_dir << "/" << "backup" << "/";
 
     backupIconFiles();
@@ -289,31 +317,6 @@ void TaskManifestFile::stepBackupIconFiles()
         "New Widget icon file backup Finished");
 }
 
-
-void TaskManifestFile::stepUpdateDesktopFile()
-{
-    LogDebug("Update Desktop File");
-    backupDesktopFile();
-
-    std::ofstream file(desktop_file.str().c_str(), std::ios::trunc);
-
-    saveWidgetType(file);
-    saveWidgetExecPath(file);
-    saveWidgetName(file);
-    saveWidgetIcons(file);
-    saveWidgetVersion(file);
-    saveWidgetOtherInfo(file);
-    saveAppServiceInfo(file);
-
-    file.close();
-
-    updateAilInfo();
-
-    m_context.job->UpdateProgress(
-        InstallerContext::INSTALL_UPDATE_DESKTOP,
-        "New Widget desktop file update Finished");
-}
-
 void TaskManifestFile::stepAbortIconFiles()
 {
     LogDebug("Abrot Icon Files");
@@ -347,260 +350,46 @@ 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());
         }
     }
 }
 
 void TaskManifestFile::stepUpdateFinalize()
 {
+    commitManifest();
     LogDebug("Finished Update Desktopfile");
 }
 
-void TaskManifestFile::stepAbortDesktopFile()
-{
-    LogDebug("Abort desktop backup ");
-
-    std::ifstream backupFile(bp_desktop_file.str().c_str());
-    std::ofstream file(desktop_file.str().c_str(), std::ios::trunc);
-
-    while(!backupFile.eof()) {
-        char contents[256] = {0, };
-
-        backupFile.getline(contents, sizeof(contents));
-        file << contents << std::endl;
-    }
-    backupFile.close();
-    file.close();
-
-    updateAilInfo();
-
-    m_context.job->UpdateProgress(
-        InstallerContext::INSTALL_UPDATE_DESKTOP,
-        "New Widget desktop file update Finished");
-}
-
-void TaskManifestFile::moveDesktopFile()
-{
-    std::ostringstream destFile;
-    destFile << GlobalConfig::GetUserWidgetDesktopPath() << "/";
-    destFile << desktop_name.str();
-    LogInfo("cp " << desktop_file.str() << " " << destFile.str());
-    Try
-    {
-        DPL::FileInput input(desktop_file.str());
-        DPL::FileOutput output(destFile.str());
-        DPL::Copy(&input, &output);
-    }
-
-    Catch(DPL::FileInput::Exception::Base)
-    {
-        // Error while opening or closing source file
-        //        ReThrowMsg(InstallerException::CopyIconFailed,
-        //                   desktop_file.str());
-        LogError(
-            "Creating Desktop File 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,
-        //                   destFile.str());
-        LogError(
-            "Creating Desktop File Failed. Widget's icon will not be available"\
-            "from Main Screen");
-    }
-
-    Catch(DPL::CopyFailed)
-    {
-        // Error while copying
-        //        ReThrowMsg(InstallerException::CopyIconFailed,
-        //                   destFile.str());
-        LogError(
-            "Creating Desktop File Failed. Widget's icon will not be available"\
-            "from Main Screen");
-    }
-
-    updateAilInfo();
-
-    //removing temp file
-    unlink(desktop_file.str().c_str());
-}
-
-void TaskManifestFile::saveWidgetType(std::ofstream &file)
-{
-    file << "Type=" << "Application" << std::endl;
-}
-
-void TaskManifestFile::saveWidgetExecPath(std::ofstream &file)
-{
-    DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
-    if (pkgname.IsNull()) {
-        ThrowMsg(Exceptions::InternalError, "No Package name exists.");
-    }
-
-    file << "Exec=";
-    file << GlobalConfig::GetUserInstalledWidgetPath() << "/";
-    file << pkgname << "/";
-    file << GlobalConfig::GetUserWidgetExecPath() << "/";
-    file << m_context.widgetHandle << std::endl;
-}
-
-void TaskManifestFile::saveWidgetVersion(std::ofstream &file)
-{
-    DPL::OptionalString widget_version = m_context.widgetConfig.version;
-    file << "Version=" << widget_version << std::endl;
-}
-
-void TaskManifestFile::saveWidgetName(std::ofstream &file)
-{
-    Assert(!!m_context.widgetHandle);
-    WidgetDAOReadOnly dao(*m_context.widgetHandle);
-    LanguageTagsList languageTags(dao.getLanguageTags());
-    bool defaultNameSaved = false;
-    auto generateWidgetName = [&] (const DPL::OptionalString& tag,
-                                   const DPL::OptionalString& language)
-    {
-        DPL::OptionalString name = dao.getLocalizedInfo(*language).name;
-        if (!!name) {
-            if (!!tag)
-            {
-                saveLocalizedKey(file, L"Name", *tag);
-            }
-            else
-            {
-                file << "Name=";
-                defaultNameSaved = true;
-            }
-            file << *name;
-            file << std::endl;
-        }
-    };
-
-    FOREACH(i, languageTags)
-    {
-        DPL::OptionalString tag = getLangTag(*i);// translate en -> en_US etc
-        if (tag.IsNull()) { tag = *i; }
-
-        generateWidgetName(tag, *i);
-
-    }
-    DPL::OptionalString defaultLocale = dao.getDefaultlocale();
-    if (!!defaultLocale && !defaultNameSaved)
-    {
-        generateWidgetName(DPL::OptionalString::Null, *defaultLocale);
-    }
-}
-
-void TaskManifestFile::saveWidgetIcons(std::ofstream &file)
-{
-    DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
-    if (pkgname.IsNull()) {
-        ThrowMsg(Exceptions::InternalError, "No Package name exists.");
-    }
-
-    //TODO this file will need to be updated when user locale preferences
-    //changes.
-    Assert(!!m_context.widgetHandle);
-    WidgetDAOReadOnly dao(*m_context.widgetHandle);
-
-    WidgetDAOReadOnly::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
-    WidgetDAOReadOnly::WidgetIconList list = dao.getIconList();
-
-    LanguageTagsList languageTags(dao.getLanguageTags());
-    bool defaultIconSaved = false;
-
-
-    auto generateWidgetIcon = [&] (const DPL::OptionalString& tag,
-                                   const DPL::String& language,
-                                   int iconId)
-    {
-        if (!!tag)
-        {
-            saveLocalizedKey(file, L"Icon", *tag);
-        }
-        else
-        {
-            file << "Icon=";
-            defaultIconSaved = true;
-        }
-
-        DPL::OptionalString src;
-        FOREACH(icon, list)
-        {
-            if (icon->iconId == iconId) {
-                src = icon->iconSrc;
-            }
-        }
-        if (!!src) {
-            //If menuscreen need use absolute path of widget's icon, comment out
-            //the following lines.
-
-            file << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
-            file << getIconTargetFilename(language) << std::endl;
-        }
-    };
-
-    FOREACH(it, locList)
-    {
-        DPL::String i = it->widgetLocale;
-        DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc
-        if (tag.IsNull()) { tag = i; }
-
-        generateWidgetIcon(tag, i, it->iconId);
-
-    }
-    DPL::OptionalString defaultLocale = dao.getDefaultlocale();
-    if (!!defaultLocale && !defaultIconSaved)
-    {
-        int iconId = -1;
-        FOREACH(it, locList)
-        {
-            if (it->widgetLocale == *defaultLocale)
-            {
-                iconId = it->iconId;
-            }
-        }
-        if (-1 != iconId)
-        {
-            generateWidgetIcon(DPL::OptionalString::Null,
-                               DPL::String(),
-                               iconId);
-        }
-    }
-}
-
 DPL::String TaskManifestFile::getIconTargetFilename(
-        const DPL::String& languageTag) const
+    const DPL::String& languageTag) const
 {
     DPL::OStringStream filename;
-    DPL::Optional<DPL::String> pkgname = m_context.widgetConfig.pkgname;
-    if (pkgname.IsNull()) {
-        ThrowMsg(Exceptions::InternalError, "No Package name exists.");
-    }
+    TizenAppId appid = m_context.widgetConfig.tzAppid;
 
-    filename << DPL::ToUTF8String(*pkgname).c_str();
+    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 =
-            LocalizationUtils::BCP47LanguageTagToLocale(*tag);
+            LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
 
-       if(locale.empty()) {
+        if (locale.empty()) {
             filename << L"." << languageTag;
         } else {
             filename << L"." << locale;
@@ -611,74 +400,18 @@ DPL::String TaskManifestFile::getIconTargetFilename(
     return filename.str();
 }
 
-void TaskManifestFile::saveWidgetOtherInfo(std::ofstream &file)
-{
-    DPL::Optional<DPL::String> widgetID = m_context.widgetConfig.guid;
-
-    //    /* network */
-    //    strncat(desktop, format_network, strlen(format_network));
-    //    //TODO -- get the network value from the widget
-    //    strncat(desktop, "True", 4);
-    //    strncat(desktop, line, strlen(line));
-
-    /* Comment */
-    file << "Comment=Widget application" << std::endl;
-
-    /* bg_schedule */
-    //file << "BG_SCHEDULE=True" << std::endl;
-
-    /* visible */
-    file << "nodisplay=FALSE" << std::endl;
-
-    file << "X-TIZEN-PackageType=wgt" << std::endl;
-    if (!widgetID.IsNull()) {
-        file << "X-TIZEN-PackageID=" << DPL::ToUTF8String(*widgetID).c_str() << std::endl;
-    }
-}
-
-void TaskManifestFile::saveAppServiceInfo(std::ofstream &file)
-{
-    Assert(!!m_context.widgetHandle);
-    WidgetDAOReadOnly dao(*m_context.widgetHandle);
-    WidgetApplicationServiceList appServiceList;
-    dao.getAppServiceList(appServiceList);
-
-    if (appServiceList.empty()) {
-        LogInfo("Widget doesn't contain application service");
-        return;
-    }
-
-    // x-tizen-svc=http://tizen.org/appsvc/operation/pick|NULL|image;
-    file << "X-TIZEN-SVC=";
-    FOREACH(it, appServiceList) {
-        if (appServiceList.begin() != it) {
-            file << ";";
-        }
-        file << DPL::ToUTF8String(it->operation).c_str() << "|";
-        if (it->scheme.empty()) {
-            file << "NULL" << "|";
-        } else {
-            file << DPL::ToUTF8String(it->scheme).c_str() << "|";
-        }
-        if (it->mime.empty()) {
-            file << "NULL";
-        } else {
-            file << DPL::ToUTF8String(it->mime).c_str();
-        }
-    }
-}
-
 void TaskManifestFile::stepFinalize()
 {
+    commitManifest();
     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 =
-        LocalizationUtils::BCP47LanguageTagToLocale(languageTag);
+        LanguageTagsProvider::BCP47LanguageTagToLocale(languageTag);
 
     file << key;
     if (!locale.empty()) {
@@ -687,33 +420,6 @@ void TaskManifestFile::saveLocalizedKey(std::ofstream &file,
     file << "=";
 }
 
-void TaskManifestFile::updateAilInfo()
-{
-    // Update ail for desktop
-    std::string cfgPkgname =
-        DPL::ToUTF8String(*m_context.widgetConfig.pkgname);
-    const char* pkgname = cfgPkgname.c_str();
-
-    LogDebug("Update ail desktop : " << pkgname );
-    ail_appinfo_h ai = NULL;
-    ail_error_e ret;
-
-    ret = ail_package_get_appinfo(pkgname, &ai);
-    if (ai) {
-        ail_package_destroy_appinfo(ai);
-    }
-    
-    if (AIL_ERROR_NO_DATA == ret) {
-        if (ail_desktop_add(pkgname) < 0) {
-            LogDebug("Failed to add ail desktop : " << pkgname);
-        }
-    } else if (AIL_ERROR_OK == ret) {
-        if (ail_desktop_update(pkgname) < 0) {
-            LogDebug("Failed to update ail desktop : " << pkgname);
-        }
-    }
-}
-
 void TaskManifestFile::backupIconFiles()
 {
     LogInfo("Backup Icon Files");
@@ -722,16 +428,17 @@ void TaskManifestFile::backupIconFiles()
     b_icon_dir << backup_dir.str() << "icons";
 
     LogDebug("Create icon backup folder : " << b_icon_dir.str());
-    _WrtMakeDir(b_icon_dir.str().c_str(), 0755, WRT_FILEUTILS_RECUR);
+    WrtUtilMakeDir(b_icon_dir.str());
 
     std::list<std::string> fileList;
     getFileList(GlobalConfig::GetUserWidgetDesktopIconPath(), fileList);
-    std::string pkgname = DPL::ToUTF8String(*m_context.widgetConfig.pkgname);
-    
+    std::string appid = DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
+
     FOREACH(it, fileList)
     {
-        if (0 == (strncmp((*it).c_str(), pkgname.c_str(),
-                        strlen(pkgname.c_str())))) {
+        if (0 == (strncmp((*it).c_str(), appid.c_str(),
+                          strlen(appid.c_str()))))
+        {
             std::ostringstream icon_file, backup_icon;
             icon_file << GlobalConfig::GetUserWidgetDesktopIconPath();
             icon_file << "/" << (*it);
@@ -739,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());
@@ -767,74 +474,52 @@ void TaskManifestFile::backupIconFiles()
     }
 }
 
-void TaskManifestFile::backupDesktopFile()
+void TaskManifestFile::getFileList(const char* path,
+                                   std::list<std::string> &list)
 {
-    LogInfo("Backup Desktop File");
-
-    std::ostringstream b_desktop_dir;
-    b_desktop_dir << backup_dir.str() <<  "desktop";
-
-    LogDebug("Create desktop file backup folder : " << b_desktop_dir.str());
-    _WrtMakeDir(b_desktop_dir.str().c_str(), 0755, WRT_FILEUTILS_RECUR);
-
-    bp_desktop_file << b_desktop_dir.str() << "/" << desktop_name.str();
-
-    Try
-    {
-        DPL::FileInput input(desktop_file.str());
-        DPL::FileOutput output(bp_desktop_file.str());
-        DPL::Copy(&input, &output);
+    DIR* dir = opendir(path);
+    if (!dir) {
+        LogError("icon directory doesn't exist");
+        ThrowMsg(Exceptions::FileOperationFailed, path);
     }
 
-    Catch(DPL::FileInput::Exception::Base)
+    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))
     {
-        ReThrowMsg(Exceptions::BackupFailed, desktop_file.str());
+        if (strcmp(entry.d_name, ".") == 0 ||
+            strcmp(entry.d_name, "..") == 0)
+        {
+            continue;
+        }
+        std::string file_name = entry.d_name;
+        list.push_back(file_name);
     }
 
-    Catch(DPL::FileOutput::Exception::Base)
-    {
-        ReThrowMsg(Exceptions::BackupFailed, bp_desktop_file.str());
+    if (return_code != 0 || errno != 0) {
+        LogError("readdir_r() failed with " << DPL::GetErrnoString());
     }
-    Catch(DPL::CopyFailed)
-    {
-        ReThrowMsg(Exceptions::BackupFailed, bp_desktop_file.str());
-    }
-}
 
-void TaskManifestFile::getFileList(const char* path,
-        std::list<std::string> &list)
-{
-    DIR* dir = opendir(path);
-    if (!dir) {
-        LogError("icon directory doesn't exist");
-        ThrowMsg(Exceptions::InternalError, path);
+    if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
+        LogError("Failed to close dir: " << path << " with error: "
+                                         << DPL::GetErrnoString());
     }
-
-    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);
-        }
-    }while(d_ent);
 }
 
 void TaskManifestFile::stepGenerateManifest()
 {
-    DPL::String pkgname = *m_context.widgetConfig.pkgname;
-    manifest_name = pkgname + L".xml";
+    TizenPkgId pkgid = m_context.widgetConfig.tzPkgid;
+    manifest_name = pkgid + L".xml";
     manifest_file += L"/tmp/" + manifest_name;
 
     //libxml - init and check
     LibxmlSingleton::Instance().init();
 
     writeManifest(manifest_file);
-    validateManifest();
-    commitManifest();
 
     m_context.job->UpdateProgress(
         InstallerContext::INSTALL_CREATE_MANIFEST,
@@ -846,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");
@@ -866,47 +547,29 @@ 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");
     LogDebug("Manifest parsed");
 }
 
-void TaskManifestFile::validateManifest()
-{
-    int code = pkgmgr_parser_check_manifest_validation(
-            DPL::ToUTF8String(manifest_name).c_str());
-
-    if(code != 0)
-    {
-        LogError("Manifest validation error");
-        //TODO: manifest files are not yet validating properly because of href
-        // attribute in author element (incompatible types in W3C spec. and
-        // manifest spec.)
-        //ThrowMsg(ManifestValidationError, "Validation returncode: " << code);
-    }
-
-    m_context.job->UpdateProgress(
-        InstallerContext::INSTALL_CREATE_MANIFEST,
-        "Widget Manifest Validation Finished");
-    LogDebug("Manifest validated");
-}
-
 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());
 
@@ -926,97 +589,157 @@ 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);
+    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)
 {
-    DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
-    if (pkgname.IsNull()) {
-        ThrowMsg(Exceptions::InternalError, "No Package name exists.");
+    std::string exec = m_context.locations->getExecFile();
+    if (!postfix.empty()) {
+        exec.append(postfix);
     }
-
-    std::ostringstream path;
-    path << GlobalConfig::GetUserInstalledWidgetPath() << "/" << *pkgname << "/";
-    path << GlobalConfig::GetUserWidgetExecPath() << "/" << *m_context.widgetHandle;
-    uiApp.setExec(DPL::FromASCIIString(path.str()));
+    LogDebug("exec = " << exec);
+    uiApp.setExec(DPL::FromASCIIString(exec));
 }
 
-void TaskManifestFile::setWidgetName(Manifest & manifest, UiApplication & uiApp)
+void TaskManifestFile::setWidgetName(Manifest & manifest,
+                                     UiApplication & uiApp)
 {
-    Assert(!!m_context.widgetHandle);
-    WidgetDAOReadOnly dao(*m_context.widgetHandle);
-    LanguageTagsList languageTags(dao.getLanguageTags());
     bool defaultNameSaved = false;
 
+    DPL::OptionalString defaultLocale =
+        m_context.widgetConfig.configInfo.defaultlocale;
+    std::pair<DPL::String,
+              WrtDB::ConfigParserData::LocalizedData> defaultLocalizedData;
     //labels
-    FOREACH(i, languageTags)
+    FOREACH(localizedData, m_context.widgetConfig.configInfo.localizedDataSet)
     {
-        DPL::OptionalString tag = getLangTag(*i); // translate en -> en_US etc
-        if (tag.IsNull())
-        {
-            tag = *i;
+        Locale i = localizedData->first;
+        DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc
+        if (tag.IsNull()) {
+            tag = i;
         }
-        DPL::OptionalString name = dao.getLocalizedInfo(*i).name;
+        DPL::OptionalString name = localizedData->second.name;
         generateWidgetName(manifest, uiApp, tag, name, defaultNameSaved);
+
+        //store default locale localized data
+        if (!!defaultLocale && defaultLocale == i) {
+            defaultLocalizedData = *localizedData;
+        }
     }
-    DPL::OptionalString defaultLocale = dao.getDefaultlocale();
-    if (!!defaultLocale && !defaultNameSaved)
-    {
-        DPL::OptionalString name = dao.getLocalizedInfo(*defaultLocale).name;
-        generateWidgetName(manifest, uiApp, DPL::OptionalString::Null, name, defaultNameSaved);
+
+    if (!!defaultLocale && !defaultNameSaved) {
+        DPL::OptionalString name = defaultLocalizedData.second.name;
+        generateWidgetName(manifest,
+                           uiApp,
+                           DPL::OptionalString::Null,
+                           name,
+                           defaultNameSaved);
     }
+}
+
+void TaskManifestFile::setWidgetIds(Manifest & manifest,
+                                    UiApplication & uiApp,
+                                    const std::string &postfix)
+{
     //appid
-    DPL::String pkgname;
-    if(!!m_context.widgetConfig.pkgname)
-    {
-        pkgname = *m_context.widgetConfig.pkgname;
-        uiApp.setAppid(pkgname);
+    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(!pkgname.empty()) {
-            uiApp.setExtraid(DPL::String(L"http://") + pkgname);
+        if (!appid.empty()) {
+            uiApp.setExtraid(DPL::String(L"http://") + appid);
         }
     }
 
     //type
     uiApp.setType(DPL::FromASCIIString("webapp"));
     manifest.setType(L"wgt");
-    uiApp.setTaskmanage(true);
 }
 
-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 =
-                LocalizationUtils::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));
@@ -1026,131 +749,396 @@ void TaskManifestFile::generateWidgetName(Manifest & manifest, UiApplication &ui
 
 void TaskManifestFile::setWidgetIcons(UiApplication & uiApp)
 {
-    DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
-    if (pkgname.IsNull()) {
-        ThrowMsg(Exceptions::InternalError, "No Package name exists.");
-    }
-
     //TODO this file will need to be updated when user locale preferences
     //changes.
-    Assert(!!m_context.widgetHandle);
-    WidgetDAOReadOnly dao(*m_context.widgetHandle);
-
-    WidgetDAOReadOnly::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
-    WidgetDAOReadOnly::WidgetIconList list = dao.getIconList();
     bool defaultIconSaved = false;
 
-    FOREACH(it, locList)
-    {
-        DPL::String i = it->widgetLocale;
-        DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc
-        if (tag.IsNull()) { tag = i; }
+    DPL::OptionalString defaultLocale =
+        m_context.widgetConfig.configInfo.defaultlocale;
 
-        generateWidgetIcon(uiApp, tag, i, it->iconId, list, defaultIconSaved);
-    }
-    DPL::OptionalString defaultLocale = dao.getDefaultlocale();
-    if (!!defaultLocale && !defaultIconSaved)
+    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)
     {
-        int iconId = -1;
-        FOREACH(it, locList)
+        FOREACH(locale, icon->availableLocales)
         {
-            if (it->widgetLocale == *defaultLocale)
+            if (std::find(generatedLocales.begin(), generatedLocales.end(),
+                          *locale) != generatedLocales.end())
             {
-                iconId = it->iconId;
+                LogDebug("Skipping - has that locale - already in manifest");
+                continue;
+            } else {
+                generatedLocales.push_back(*locale);
             }
+
+            DPL::OptionalString tag = getLangTag(*locale); // translate en ->
+                                                           // en_US etc
+            if (tag.IsNull()) {
+                tag = *locale;
+            }
+
+            generateWidgetIcon(uiApp, tag, *locale, defaultIconSaved);
         }
-        if (-1 != iconId)
-        {
-            generateWidgetIcon(uiApp, DPL::OptionalString::Null,
-                               DPL::String(),
-                               iconId,
-                               list,
-                               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, int iconId, const WrtDB::WidgetDAOReadOnly::WidgetIconList & list, bool & defaultIconSaved)
+void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp,
+                                          const DPL::OptionalString& tag,
+                                          const DPL::String& language,
+                                          bool & defaultIconSaved)
 {
     DPL::String locale;
-    if (!!tag)
-    {
-        locale = LocalizationUtils::BCP47LanguageTagToLocale(*tag);
-    }
-    else
-    {
+    if (!!tag) {
+        locale = LanguageTagsProvider::BCP47LanguageTagToLocale(*tag);
+    } else {
         defaultIconSaved = true;
     }
 
-    DPL::OptionalString src;
-    FOREACH(icon, list)
+    DPL::String iconText;
+    iconText += getIconTargetFilename(language);
+
+    if (!locale.empty()) {
+        uiApp.addIcon(IconType(iconText, locale));
+    } else {
+        uiApp.addIcon(IconType(iconText));
+    }
+    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)
     {
-        if (icon->iconId == iconId) {
-            src = icon->iconSrc;
+        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);
     }
-    if (!!src) {
-        DPL::String iconText;
-        iconText += /*DPL::FromASCIIString(GlobalConfig::GetUserWidgetDesktopIconPath()) + L"/" +*/ getIconTargetFilename(language);
-        if(!locale.empty())
-        {
-            uiApp.addIcon(IconType(iconText,locale));
-        }
-        else
-        {
-            uiApp.addIcon(IconType(iconText));
+}
+
+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));
         }
     }
 }
 
 void TaskManifestFile::setWidgetManifest(Manifest & manifest)
 {
-    if(!!m_context.widgetConfig.pkgname)
-    {
-        manifest.setPackage(*m_context.widgetConfig.pkgname);
-    }
-    if(!!m_context.widgetConfig.version)
-    {
+    manifest.setPackage(m_context.widgetConfig.tzPkgid);
+
+    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)
 {
-    uiApp.setNodisplay(false);
-    //TODO(t.iwanek):
-    //There is no "X-TIZEN-PackageType=wgt", there is not field in manifest
-    //There is no X-TIZEN-PackageID in manifest "X-TIZEN-PackageID=" << DPL::ToUTF8String(*widgetID).c_str()
+    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)) {
+                uiApp.setNodisplay(true);
+                uiApp.setTaskmanage(false);
+            } 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 Comment in pkgmgr "Comment=Widget application"
+    //that were in desktop file
+}
+
+void TaskManifestFile::setAppControlsInfo(UiApplication & uiApp)
+{
+    WrtDB::ConfigParserData::AppControlInfoList appControlList =
+        m_context.widgetConfig.configInfo.appControlList;
+
+    if (appControlList.empty()) {
+        LogInfo("Widget doesn't contain app control");
+        return;
+    }
+
+     // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image;
+    FOREACH(it, appControlList) {
+        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 (!service.m_mimeList.empty()) {
+        FOREACH(mime, service.m_mimeList) {
+            appControl.addMime(*mime);
+        }
+    }
+    uiApp.addAppControl(appControl);
+}
+
+void TaskManifestFile::setAppCategory(UiApplication &uiApp)
+{
+    WrtDB::ConfigParserData::CategoryList categoryList =
+        m_context.widgetConfig.configInfo.categoryList;
+
+    if (categoryList.empty()) {
+        LogInfo("Widget doesn't contain application category");
+        return;
+    }
+    FOREACH(it, categoryList) {
+        if (!(*it).empty()) {
+            uiApp.addAppCategory(*it);
+        }
+    }
+}
+
+void TaskManifestFile::stepAbortParseManifest()
+{
+    LogError("[Parse Manifest] Abroting....");
+
+    int code = pkgmgr_parser_parse_manifest_for_uninstallation(
+            DPL::ToUTF8String(manifest_file).c_str(), NULL);
+
+    if (0 != code) {
+        LogWarning("Manifest parser error: " << code);
+        ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code);
+    }
+    int ret = unlink(DPL::ToUTF8String(manifest_file).c_str());
+    if (0 != ret) {
+        LogWarning("No manifest file found: " << manifest_file);
+    }
+}
+
+void TaskManifestFile::setLiveBoxInfo(Manifest& manifest)
+{
+    FOREACH(it, m_context.widgetConfig.configInfo.m_livebox) {
+        LogInfo("setLiveBoxInfo");
+        LiveBoxInfo liveBox;
+        DPL::Optional<WrtDB::ConfigParserData::LiveboxInfo> ConfigInfo = *it;
+        DPL::String appid = m_context.widgetConfig.tzAppid;
+
+        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 {
+                    DPL::String liveboxId =
+                        appid + DPL::String(L".") + ConfigInfo->m_liveboxId;
+                    liveBox.setLiveboxId(liveboxId);
+                }
+            } else {
+                DPL::String liveboxId =
+                    appid + DPL::String(L".") + ConfigInfo->m_liveboxId;
+                liveBox.setLiveboxId(liveboxId);
+            }
+        }
+
+        if (ConfigInfo->m_primary != L"") {
+            liveBox.setPrimary(ConfigInfo->m_primary);
+        }
+
+        if (ConfigInfo->m_updatePeriod != L"") {
+            liveBox.setUpdatePeriod(ConfigInfo->m_updatePeriod);
+        }
+
+        if (ConfigInfo->m_label != L"") {
+            liveBox.setLabel(ConfigInfo->m_label);
+        }
+
+        DPL::String defaultLocale
+            = 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_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")))
+                {
+                    box.boxSrc = ConfigInfo->m_boxInfo.m_boxSrc;
+                } else {
+                    box.boxSrc = defaultLocale + ConfigInfo->m_boxInfo.m_boxSrc;
+                }
+            }
+
+            if (ConfigInfo->m_boxInfo.m_boxMouseEvent == L"true") {
+                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";
+            }
+
+            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()) {
+                    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())
+            {
+                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;
+            }
+            liveBox.setBox(box);
+        }
+        manifest.addLivebox(liveBox);
+    }
 }
 
-void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp)
+void TaskManifestFile::setAccount(Manifest& manifest)
 {
-    Assert(!!m_context.widgetHandle);
-    WidgetDAOReadOnly dao(*m_context.widgetHandle);
-    WidgetApplicationServiceList appServiceList;
-    dao.getAppServiceList(appServiceList);
+    WrtDB::ConfigParserData::AccountProvider account =
+        m_context.widgetConfig.configInfo.accountProvider;
 
-    if (appServiceList.empty()) {
-        LogInfo("Widget doesn't contain application service");
+    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));
+    }
 
-    // x-tizen-svc=http://tizen.org/appsvc/operation/pick|NULL|image;
-    FOREACH(it, appServiceList) {
-        ApplicationService appService;
-        appService.addOperation(it->operation);
-        appService.addOperation(it->scheme);
-        appService.addOperation(it->mime);
-        uiApp.addApplicationService(appService);
+    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