[Release] wrt-installer_0.1.53
[framework/web/wrt-installer.git] / src / wrt-installer / wrt_installer_api.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 9921fdf..83b5172
@@ -30,6 +30,7 @@
 #include <dpl/assert.h>
 #include <dpl/semaphore.h>
 #include <dpl/sstream.h>
+#include <dpl/errno_string.h>
 #include <libxml/parser.h>
 #include <vconf.h>
 
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
 #include <vcore/VCore.h>
 #include <installer_main_thread.h>
+#include <wrt_install_mode.h>
 
 using namespace WrtDB;
 
-#undef TRUE
-#undef FALSE
-#define TRUE 0
-#define FALSE -1
-
-#ifdef __cplusplus
-
-#define EXPORT_API __attribute__((visibility("default")))
-extern "C"
+static std::string cutOffFileName(const std::string& path)
 {
-#endif
-    inline WidgetUpdateMode::Type translateWidgetUpdateMode(
-            wrt_widget_update_mode_t updateMode)
-    {
-        WidgetUpdateMode::Type result = WidgetUpdateMode::Zero;
-
-        if (updateMode & WRT_WIM_NOT_INSTALLED) {
-            result = result | WidgetUpdateMode::NotInstalled;
-        }
-
-        if (updateMode & WRT_WIM_INCOMING_VERSION_NOT_STD) {
-            result = result | WidgetUpdateMode::IncomingVersionNotStd;
-        }
-
-        if (updateMode & WRT_WIM_EXISTING_VERSION_NOT_STD) {
-            result = result | WidgetUpdateMode::ExistingVersionNotStd;
-        }
-
-        if (updateMode & WRT_WIM_BOTH_VERSIONS_NOT_STD) {
-            result = result | WidgetUpdateMode::BothVersionsNotStd;
-        }
-
-        if (updateMode & WRT_WIM_EXISTING_VERSION_OLDER) {
-            result = result | WidgetUpdateMode::ExistingVersionOlder;
-        }
-
-        if (updateMode & WRT_WIM_EXISTING_VERSION_EQUAL) {
-            result = result | WidgetUpdateMode::ExistingVersionEqual;
-        }
-
-        if (updateMode & WRT_WIM_EXISTING_VERSION_NEWER) {
-            result = result | WidgetUpdateMode::ExistingVersionNewer;
-        }
-
-        return result;
-    }
-
-    const char PLUGIN_INSTALL_SEMAPHORE[] = "/.wrt_plugin_install_lock";
-    static int wrt_count_plugin;
-
-    static std::string cutOffFileName(const std::string& path)
-    {
-        size_t found = path.find_last_of("/");
-        if (found == std::string::npos) {
-            return path;
-        } else {
-            return path.substr(0, found);
-        }
+    size_t found = path.find_last_of("/");
+    if (found == std::string::npos) {
+        return path;
+    } else {
+        return path.substr(0, found);
     }
+}
 
-    static bool checkPath(const std::string& path)
-    {
-        struct stat st;
-        if (0 == stat(path.c_str(), &st) && S_ISDIR(st.st_mode)) {
-            return true;
-        }
-        LogError("Cannot access directory [ " << path << " ]");
-        return false;
+static bool checkPath(const std::string& path)
+{
+    struct stat st;
+    if (0 == stat(path.c_str(), &st) && S_ISDIR(st.st_mode)) {
+        return true;
     }
+    LogError("Cannot access directory [ " << path << " ]");
+    return false;
+}
 
-    static bool checkPaths()
-    {
-        bool if_ok = true;
-        if_ok &= (checkPath(cutOffFileName(
-                GlobalConfig::GetWrtDatabaseFilePath())));
-        if (!if_ok) {
-            LogError(
-                "Path <" << GlobalConfig::GetWrtDatabaseFilePath() <<
-                "> does not exist.");
-        }
-
-        if_ok &= (checkPath(GlobalConfig::GetDevicePluginPath()));
-        if (!if_ok) {
-            LogError(
-                "Path <" << GlobalConfig::GetDevicePluginPath() <<
-                "> does not exist.");
-        }
+static bool checkPaths()
+{
+    bool if_ok = true;
 
-        if_ok &= (checkPath(GlobalConfig::GetFactoryInstalledWidgetPath()));
-        if (!if_ok) {
-            LogError(
-                "Path <" << GlobalConfig::GetFactoryInstalledWidgetPath() <<
-                "> does not exist.");
-        }
+    if_ok &= (checkPath(cutOffFileName(GlobalConfig::GetWrtDatabaseFilePath())));
+    if_ok &= (checkPath(GlobalConfig::GetDevicePluginPath()));
+    if_ok &= (checkPath(GlobalConfig::GetUserInstalledWidgetPath()));
+    if_ok &= (checkPath(GlobalConfig::GetUserPreloadedWidgetPath()));
 
-        if_ok &= (checkPath(GlobalConfig::GetUserInstalledWidgetPath()));
-        if (!if_ok) {
-            LogError(
-                "Path <" << GlobalConfig::GetUserInstalledWidgetPath() <<
-                "> does not exist.");
-        }
-        return if_ok;
-    }
+    return if_ok;
+}
 
-    void plugin_install_status_cb(WrtErrStatus status,
-                                  void* userparam)
-    {
-        Assert(userparam);
+void wrt_installer_init(void *userdata,
+                                  WrtInstallerInitCallback callback)
+{
+    // Set DPL/LOG MID
+    DPL::Log::LogSystemSingleton::Instance().SetTag("WRT");
 
-        wrt_plugin_data *plugin_data = static_cast<wrt_plugin_data*>(userparam);
+    try {
+        LogInfo("[WRT-API] INITIALIZING WRT INSTALLER...");
+        LogInfo("[WRT-API] BUILD: " << __TIMESTAMP__);
 
-        if (--wrt_count_plugin < 1) {
-            LogDebug("All plugins installation completed");
+        // Touch InstallerController Singleton
+        InstallerMainThreadSingleton::Instance().TouchArchitecture();
 
-            LogDebug("Call SetAllinstallpluginsCallback");
-            plugin_data->plugin_installed_cb(plugin_data->user_data);
-        }
-
-        if (status == WRT_SUCCESS) {
-            LogInfo(
-                "plugin installation is successful: " <<
-                plugin_data->plugin_path);
+        // Check paths
+        if (!checkPaths()) {
+            if (callback) {
+                callback(WRT_INSTALLER_ERROR_FATAL_ERROR, userdata);
+            }
             return;
         }
 
-        LogError("Fail to install plugin : " << plugin_data->plugin_path);
-
-        switch (status) {
-        case WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH:
-            LogError("Failed : Plugin install path is wrong");
-            break;
-        case WRT_PLUGIN_INSTALLER_ERROR_METAFILE:
-            LogError("Failed : Plugin Metafile Error");
-            break;
-        case WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED:
-            LogError("Failed : This Plugin is already installed");
-            break;
-        case WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR:
-            LogError("Failed : Library Error. Missing symbol or structures");
-            break;
-        case WRT_PLUGIN_INSTALLER_ERROR_WAITING:
-            LogError("Failed : Waiting for plugin dependencies");
-            break;
-        case WRT_PLUGIN_INSTALLER_ERROR_LOCK:
-            LogError("Failed : Lock Error");
-            break;
-        case WRT_PLUGIN_INSTALLER_ERROR_UNKNOWN:
-            LogError("Failed : Unkown Error");
-            break;
-        default:
-            break;
-        }
-    }
-
-    void plugin_install_progress_cb(float percent,
-                                    const char* description,
-                                    void* userdata)
-    {
-        char *plugin_path = static_cast<char*>(userdata);
-
-        LogInfo("Install plugin : " << plugin_path <<
-                ", Progress : " << percent <<
-                ", Description : " << description);
-    }
-
-    EXPORT_API int wrt_installer_init(void *userdata,
-                            WrtInstallerInitCallback callback)
-    {
-        // Set DPL/LOG MID
-        DPL::Log::LogSystemSingleton::Instance().SetTag("WRT");
-
-        try
-        {
-            LogInfo("[WRT-API] INITIALIZING WRT INSTALLER...");
-            LogInfo("[WRT-API] BUILD: " << __TIMESTAMP__);
-
-            // Touch InstallerController Singleton
-            InstallerMainThreadSingleton::Instance().TouchArchitecture();
-
-            // Check paths
-            if (!checkPaths()) {
-                if (callback) {
-                    callback(WRT_ERROR_NO_PATH, userdata);
-                }
-                return TRUE;
-            }
-
-            // Initialize ValidationCore - this must be done before AttachDatabases
-            ValidationCore::VCoreInit(
-                    std::string(GlobalConfig::GetFingerprintListFile()),
-                    std::string(GlobalConfig::GetFingerprintListSchema()),
-                    std::string(GlobalConfig::GetVCoreDatabaseFilePath()));
-
-            InstallerMainThreadSingleton::Instance().AttachDatabases();
+        // Initialize ValidationCore - this must be done before AttachDatabases
+        ValidationCore::VCoreInit(
+            std::string(GlobalConfig::GetFingerprintListFile()),
+            std::string(GlobalConfig::GetFingerprintListSchema()),
+            std::string(GlobalConfig::GetVCoreDatabaseFilePath()));
 
-            //checking for correct DB version
-//            if (!WrtDB::WrtDatabase::CheckTableExist(DB_CHECKSUM_STR)) {
-//                LogError("WRONG VERSION OF WRT DATABASE");
-//                Assert(false && "WRONG VERSION OF WRT DATABASE");
-//                return FALSE;
-//            }
-            LogWarning("Database check not implemented!");
+        InstallerMainThreadSingleton::Instance().AttachDatabases();
 
-            LogInfo("Prepare libxml2 to work in multithreaded program.");
-            xmlInitParser();
+        LogInfo("Prepare libxml2 to work in multithreaded program.");
+        xmlInitParser();
 
-            // Initialize Language Subtag registry
-            LanguageSubtagRstTreeSingleton::Instance().Initialize();
+        // Initialize Language Subtag registry
+        LanguageSubtagRstTreeSingleton::Instance().Initialize();
 
-            // Installer init
-            CONTROLLER_POST_SYNC_EVENT(
-                    Logic::InstallerController,
-                    InstallerControllerEvents::
-                    InitializeEvent());
+        // Installer init
+        CONTROLLER_POST_SYNC_EVENT(
+            Logic::InstallerController,
+            InstallerControllerEvents::
+                InitializeEvent());
 
-            // Install deferred widget packages
-            CONTROLLER_POST_EVENT(
-                    Logic::InstallerController,
-                    InstallerControllerEvents::
-                    InstallDeferredWidgetPackagesEvent());
+        // Install deferred widget packages
+        CONTROLLER_POST_EVENT(
+            Logic::InstallerController,
+            InstallerControllerEvents::
+                InstallDeferredWidgetPackagesEvent());
 
-            if (callback) {
-                LogInfo("[WRT-API] WRT INSTALLER INITIALIZATION CALLBACK");
-                callback(WRT_SUCCESS, userdata);
-            }
+        if (callback) {
+            LogInfo("[WRT-API] WRT INSTALLER INITIALIZATION CALLBACK");
+            callback(WRT_SUCCESS, userdata);
         }
-        catch (const DPL::Exception& ex)
-        {
-            LogError("Internal Error during Init:");
-            DPL::Exception::DisplayKnownException(ex);
-            if (callback) {
-                callback(WRT_ERROR_INTERNAL, userdata);
-            }
-            return FALSE;
+    } catch (const DPL::Exception& ex) {
+        LogError("Internal Error during Init:");
+        DPL::Exception::DisplayKnownException(ex);
+        if (callback) {
+            callback(WRT_INSTALLER_ERROR_FATAL_ERROR, userdata);
+            return;
         }
-        // OK
-        return TRUE;
     }
+    return;
+}
 
-    EXPORT_API void wrt_installer_shutdown()
-    {
-        try
-        {
-            LogInfo("[WRT-API] DEINITIALIZING WRT INSTALLER...");
-
-            // Installer termination
-            CONTROLLER_POST_SYNC_EVENT(
-                    Logic::InstallerController,
-                    InstallerControllerEvents::
-                    TerminateEvent());
-
-            InstallerMainThreadSingleton::Instance().DetachDatabases();
-
-            // This must be done after DetachDatabase
-            ValidationCore::VCoreDeinit();
-
-            // Global deinit check
-            LogInfo("Cleanup libxml2 global values.");
-            xmlCleanupParser();
-
-        }
-        catch (const DPL::Exception& ex)
-        {
-            LogError("Internal Error during Shutdown:");
-            DPL::Exception::DisplayKnownException(ex);
-        }
+void wrt_installer_shutdown()
+{
+    try {
+        LogInfo("[WRT-API] DEINITIALIZING WRT INSTALLER...");
+
+        // Installer termination
+        CONTROLLER_POST_SYNC_EVENT(
+            Logic::InstallerController,
+            InstallerControllerEvents::
+                TerminateEvent());
+
+        InstallerMainThreadSingleton::Instance().DetachDatabases();
+
+        // This must be done after DetachDatabase
+        ValidationCore::VCoreDeinit();
+
+        // Global deinit check
+        LogInfo("Cleanup libxml2 global values.");
+        xmlCleanupParser();
+    } catch (const DPL::Exception& ex) {
+        LogError("Internal Error during Shutdown:");
+        DPL::Exception::DisplayKnownException(ex);
     }
+}
 
-    EXPORT_API void wrt_install_widget(const char *path,
-                                       void* userdata,
-                                       WrtInstallerStatusCallback status_cb,
-                                       WrtProgressCallback progress_cb,
-                                       wrt_widget_update_mode_t update_mode,
-                                       bool quiet)
+void wrt_install_widget(
+    const char *path,
+    void* userdata,
+    WrtInstallerStatusCallback status_cb,
+    WrtProgressCallback progress_cb,
+    InstallMode installMode,
+    std::shared_ptr<PackageManager::
+                        IPkgmgrSignal> pkgmgrInterface
+    )
+{
+    UNHANDLED_EXCEPTION_HANDLER_BEGIN
     {
-        UNHANDLED_EXCEPTION_HANDLER_BEGIN
-        {
-            LogInfo("[WRT-API] INSTALL WIDGET: " << path);
-            // Post installation event
-            CONTROLLER_POST_EVENT(
-                Logic::InstallerController,
-                InstallerControllerEvents::InstallWidgetEvent(
-                    path, WidgetInstallationStruct(
-                        InstallerCallbacksTranslate::installFinishedCallback,
-                        InstallerCallbacksTranslate::installProgressCallback,
-                        new InstallerCallbacksTranslate::StatusCallbackStruct(
-                            userdata, status_cb, progress_cb),
-                        translateWidgetUpdateMode(update_mode),
-                        quiet)));
-        }
-        UNHANDLED_EXCEPTION_HANDLER_END
+        if (InstallMode::InstallTime::PRELOAD == installMode.installTime) {
+            DPL::Log::OldStyleLogProvider *oldStyleProvider =
+                new DPL::Log::OldStyleLogProvider(false, false, false, true,
+                        false, true);
+            DPL::Log::LogSystemSingleton::Instance().AddProvider(oldStyleProvider);
+        }
+
+        LogInfo("[WRT-API] INSTALL WIDGET: " << path);
+        // Post installation event
+        CONTROLLER_POST_EVENT(
+            Logic::InstallerController,
+            InstallerControllerEvents::InstallWidgetEvent(
+                path, WidgetInstallationStruct(
+                    InstallerCallbacksTranslate::installFinishedCallback,
+                    InstallerCallbacksTranslate::installProgressCallback,
+                    new InstallerCallbacksTranslate::StatusCallbackStruct(
+                        userdata, status_cb, progress_cb),
+                    installMode,
+                    pkgmgrInterface)));
     }
+    UNHANDLED_EXCEPTION_HANDLER_END
+}
 
-    EXPORT_API void wrt_uninstall_widget(int widget_handle,
-                                         void* userdata,
-                                         WrtInstallerStatusCallback status_cb,
-                                         WrtProgressCallback progress_cb)
+void wrt_uninstall_widget(
+    const char * const tzAppid,
+    void* userdata,
+    WrtInstallerStatusCallback status_cb,
+    WrtProgressCallback progress_cb,
+    std::shared_ptr<PackageManager::
+                        IPkgmgrSignal> pkgmgrSignalInterface)
+{
+    UNHANDLED_EXCEPTION_HANDLER_BEGIN
     {
-        UNHANDLED_EXCEPTION_HANDLER_BEGIN
-        {
-            LogInfo("[WRT-API] UNINSTALL WIDGET: " << widget_handle);
-            // Post uninstallation event
-            CONTROLLER_POST_EVENT(
-                Logic::InstallerController,
-                InstallerControllerEvents::UninstallWidgetEvent(
-                    widget_handle,
-                    WidgetUninstallationStruct(
-                        InstallerCallbacksTranslate::uninstallFinishedCallback,
-                        InstallerCallbacksTranslate::installProgressCallback,
-                        new InstallerCallbacksTranslate::StatusCallbackStruct(
-                            userdata, status_cb, progress_cb))));
-        }
-        UNHANDLED_EXCEPTION_HANDLER_END
+        std::string tizenAppid(tzAppid);
+        LogInfo("[WRT-API] UNINSTALL WIDGET: " << tizenAppid);
+        // Post uninstallation event
+        CONTROLLER_POST_EVENT(
+            Logic::InstallerController,
+            InstallerControllerEvents::UninstallWidgetEvent(
+                tizenAppid,
+                WidgetUninstallationStruct(
+                    InstallerCallbacksTranslate::uninstallFinishedCallback,
+                    InstallerCallbacksTranslate::installProgressCallback,
+                    new InstallerCallbacksTranslate::StatusCallbackStruct(
+                        userdata, status_cb, progress_cb),
+                    pkgmgrSignalInterface
+                    )
+                )
+            );
     }
+    UNHANDLED_EXCEPTION_HANDLER_END
+}
 
-    EXPORT_API void wrt_install_plugin(
-        const char *pluginDir,
-        void *user_param,
-        WrtPluginInstallerStatusCallback status_cb,
-        WrtProgressCallback progress_cb)
+void wrt_install_plugin(
+    const char *pluginDir,
+    void *user_param,
+    WrtPluginInstallerStatusCallback status_cb,
+    WrtProgressCallback progress_cb)
+{
+    UNHANDLED_EXCEPTION_HANDLER_BEGIN
     {
-        UNHANDLED_EXCEPTION_HANDLER_BEGIN
-        {
-            LogInfo("[WRT-API] INSTALL PLUGIN: " << pluginDir);
-            //Private data for status callback
-            //Resource is free in pluginInstallFinishedCallback
-            InstallerCallbacksTranslate::PluginStatusCallbackStruct*
-            callbackStruct =
-                new InstallerCallbacksTranslate::PluginStatusCallbackStruct(
-                    user_param, status_cb, progress_cb);
-
-            CONTROLLER_POST_EVENT(
-                Logic::InstallerController,
-                InstallerControllerEvents::InstallPluginEvent(
-                    std::string(pluginDir),
-                    PluginInstallerStruct(
-                        InstallerCallbacksTranslate::
+        LogInfo("[WRT-API] INSTALL PLUGIN: " << pluginDir);
+        //Private data for status callback
+        //Resource is free in pluginInstallFinishedCallback
+        InstallerCallbacksTranslate::PluginStatusCallbackStruct*
+        callbackStruct =
+            new InstallerCallbacksTranslate::PluginStatusCallbackStruct(
+                user_param, status_cb, progress_cb);
+
+        CONTROLLER_POST_EVENT(
+            Logic::InstallerController,
+            InstallerControllerEvents::InstallPluginEvent(
+                std::string(pluginDir),
+                PluginInstallerStruct(
+                    InstallerCallbacksTranslate::
                         pluginInstallFinishedCallback,
-                        InstallerCallbacksTranslate::
+                    InstallerCallbacksTranslate::
                         installProgressCallback, callbackStruct)));
-        }
-        UNHANDLED_EXCEPTION_HANDLER_END
-    }
-
-    EXPORT_API void wrt_install_all_plugins(
-        WrtAllPluginInstalledCallback installed_cb,
-        void *user_param)
-    {
-        UNHANDLED_EXCEPTION_HANDLER_BEGIN
-        {
-            std::string installRequest =
-                std::string(GlobalConfig::GetPluginInstallInitializerName());
-
-            LogDebug("Install new plugins");
-
-            Try {
-                DPL::Semaphore lock(PLUGIN_INSTALL_SEMAPHORE);
-            }
-            Catch(DPL::Semaphore::Exception::Base){
-                LogError("Failed to create installation lock");
-                return;
-            }
-
-            struct stat tmp;
-
-            if (-1 == stat(installRequest.c_str(), &tmp) ||
-                    !S_ISREG(tmp.st_mode))
-            {
-                if (ENOENT == errno) {
-                    LogDebug("Plugin installation not required");
-
-                    LogDebug("Call SetAllinstallPluginCallback");
-                    installed_cb(user_param);
-
-                    DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE);
-                    return;
-                }
-                LogWarning("Opening installation request file failed");
-            }
-
-            std::string PLUGIN_PATH =
-                std::string(GlobalConfig::GetDevicePluginPath());
-
-            DIR *dir;
-            dir = opendir(PLUGIN_PATH.c_str());
-            if (!dir) {
-                DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE);
-                return;
-            }
-
-            LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
-            struct dirent* libdir;
-
-            errno = 0;
-
-            std::list<std::string> pluginsPaths;
-
-            while ((libdir = readdir(dir)) != 0) {
-                if (strcmp(libdir->d_name, ".") == 0 ||
-                    strcmp(libdir->d_name, "..") == 0)
-                {
-                    continue;
-                }
-
-                std::string path = PLUGIN_PATH;
-                path += "/";
-                path += libdir->d_name;
-
-                struct stat tmp;
-
-                if (stat(path.c_str(), &tmp) == -1) {
-                    LogError("Failed to open file" << path);
-                    continue;
-                }
-
-                if (!S_ISDIR(tmp.st_mode)) {
-                    LogError("Not a directory" << path);
-                    continue;
-                }
-
-                pluginsPaths.push_back(path);
-            }
-
-            wrt_count_plugin = pluginsPaths.size();
-
-            FOREACH(it, pluginsPaths) {
-                wrt_plugin_data *plugin_data = new wrt_plugin_data;
-
-                plugin_data->plugin_installed_cb = installed_cb;
-                plugin_data->plugin_path = const_cast<char*>(it->c_str());
-                plugin_data->user_data = user_param;
-
-                wrt_install_plugin(
-                    it->c_str(), static_cast<void*>(plugin_data),
-                    plugin_install_status_cb,
-                    plugin_install_progress_cb);
-            }
-
-            if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
-                LogError("Failed to close dir: " << dir);
-            }
-
-            if (0 != unlink(installRequest.c_str())) {
-                LogError("Failed to remove file initializing plugin "
-                         "installation");
-            }
-
-            Try {
-                DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE);
-            }
-            Catch(DPL::Semaphore::Exception::Base){
-                LogInfo("Failed to remove installation lock");
-            }
-        }
-        UNHANDLED_EXCEPTION_HANDLER_END
-    }
-
-    EXPORT_API int wrt_installer_init_for_tests(void *userdata,
-                            WrtInstallerInitCallback callback)
-    {
-        // Set DPL/LOG MID
-        DPL::Log::LogSystemSingleton::Instance().SetTag("WRT");
-
-        try
-        {
-            LogInfo("[WRT-API] INITIALIZING WRT INSTALLER...");
-            LogInfo("[WRT-API] BUILD: " << __TIMESTAMP__);
-
-            // Touch InstallerController Singleton
-            InstallerMainThreadSingleton::Instance().
-                TouchArchitectureOnlyInstaller();
-
-            // Check paths
-            if (!checkPaths()) {
-                if (callback) {
-                    callback(WRT_ERROR_NO_PATH, userdata);
-                }
-                return TRUE;
-            }
-
-            CONTROLLER_POST_SYNC_EVENT(
-                    Logic::InstallerController,
-                    InstallerControllerEvents::
-                    InitializeEvent());
-
-            if (callback) {
-                LogInfo("[WRT-API] WRT INSTALLER INITIALIZATION CALLBACK");
-                callback(WRT_SUCCESS, userdata);
-            }
-        }
-        catch (const DPL::Exception& ex)
-        {
-            LogError("Internal Error during Init:");
-            DPL::Exception::DisplayKnownException(ex);
-            if (callback) {
-                callback(WRT_ERROR_INTERNAL, userdata);
-            }
-            return FALSE;
-        }
-
-        // OK
-        return TRUE;
-    }
-
-    EXPORT_API void wrt_installer_shutdown_for_tests()
-    {
-        try
-        {
-            LogInfo("[WRT-API] DEINITIALIZING WRT INSTALLER...");
-
-            // Installer termination
-            CONTROLLER_POST_SYNC_EVENT(
-                    Logic::InstallerController,
-                    InstallerControllerEvents::
-                    TerminateEvent());
-
-            // Global deinit check
-            LogInfo("Cleanup libxml2 global values.");
-            xmlCleanupParser();
-        }
-        catch (const DPL::Exception& ex)
-        {
-            LogError("Internal Error during Shutdown:");
-            DPL::Exception::DisplayKnownException(ex);
-        }
-    }
-
-    EXPORT_API WrtErrStatus wrt_get_widget_by_pkgname(const std::string pkgname,
-            int *widget_handle)
-    {
-        try
-        {
-            LogInfo("[WRT-API] GETTING WIDGET HANDLE BY PKG NAME : "
-                    << pkgname);
-
-            WidgetHandle handle = WidgetDAOReadOnly::getHandle(
-                    DPL::FromASCIIString(pkgname));
-            *widget_handle = static_cast<int>(handle);
-            return WRT_SUCCESS;
-        }
-        catch (WidgetDAOReadOnly::Exception::WidgetNotExist)
-        {
-            LogError("Error package name is not found");
-            return WRT_ERROR_PKGNAME_NOT_FOUND;
-        }
-        catch (const DPL::Exception& ex)
-        {
-            LogError("Internal Error during get widget id by package name");
-            DPL::Exception::DisplayKnownException(ex);
-            return WRT_ERROR_INTERNAL;
-        }
-    }
-
-    EXPORT_API WrtErrStatus wrt_get_widget_by_guid(const std::string guid,
-            int *widget_handle)
-    {
-        try
-        {
-            LogInfo("[WRT-API] GETTING WIDGET HANDLE BY WidgetID : "
-                    << guid);
-
-            WidgetGUID widget_guid = DPL::FromUTF8String(guid);
-            WidgetHandle handle = WidgetDAOReadOnly::getHandle(widget_guid);
-            *widget_handle = static_cast<int>(handle);
-            return WRT_SUCCESS;
-        }
-        catch (WidgetDAOReadOnly::Exception::WidgetNotExist)
-        {
-            LogError("Error package name is not found");
-            return WRT_ERROR_PKGNAME_NOT_FOUND;
-        }
-        catch (const DPL::Exception& ex)
-        {
-            LogError("Internal Error during get widget id by package name");
-            DPL::Exception::DisplayKnownException(ex);
-            return WRT_ERROR_INTERNAL;
-        }
     }
-#ifdef __cplusplus
+    UNHANDLED_EXCEPTION_HANDLER_END
 }
-#endif