Clean-up wrt-installer command and type
authorJihoon Chung <jihoon.chung@samsung.com>
Fri, 5 Apr 2013 13:31:44 +0000 (22:31 +0900)
committerJihoon Chung <jihoon.chung@samsung.com>
Sat, 6 Apr 2013 10:51:48 +0000 (19:51 +0900)
Change-Id: Iafbf41f61e233d4703f37f510a7762103bb46851

packaging/wrt-installer.spec
src/jobs/widget_install/job_widget_install.cpp
src/jobs/widget_install/job_widget_install.h
src/jobs/widget_install/task_commons.h
src/jobs/widget_install/widget_installer_struct.h
src/logic/installer_logic.cpp
src/wrt-installer/CMakeLists.txt
src/wrt-installer/wrt-installer.cpp [moved from src/wrt-installer/wrt_installer.cpp with 95% similarity]
src/wrt-installer/wrt-installer.h [moved from src/wrt-installer/wrt_installer.h with 89% similarity]
src/wrt-installer/wrt_installer_api.cpp
src/wrt-installer/wrt_installer_api.h

index 9470f23..9d2620e 100644 (file)
@@ -64,7 +64,6 @@ LDFLAGS="$LDFLAGS"
 
 cmake . -DCMAKE_INSTALL_PREFIX=/usr \
         -DDPL_LOG=ON \
-        -DCMAKE_PACKAGE_VERSION=%{version} \
         -DCMAKE_BUILD_TYPE=%{?build_type:%build_type} \
         %{?WITH_TESTS:-DWITH_TESTS=%WITH_TESTS}
 make %{?jobs:-j%jobs}
index 9bfad48..d31aa5a 100644 (file)
@@ -291,7 +291,7 @@ ConfigureResult JobWidgetInstall::PrePareInstallation(
     Try
     {
         std::string tempDir =
-            Jobs::WidgetInstall::createTempPath(m_jobStruct.m_preload);
+            Jobs::WidgetInstall::createTempPath(m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_PRELOAD);
 
         m_isDRM = isDRMWidget(widgetPath);
         if (true == m_isDRM) {
@@ -564,13 +564,8 @@ ConfigureResult JobWidgetInstall::checkWidgetUpdate(
 
     m_installerContext.widgetConfig.tzAppid = update.tzAppId;
 
-    WidgetUpdateMode::Type updateTypeCheckBit;
-    updateTypeCheckBit = CalcWidgetUpdatePolicy(update.existingVersion,
-                                                update.incomingVersion);
-    // Calc proceed flag
-    if ((m_jobStruct.updateMode & updateTypeCheckBit) > 0 ||
-        m_jobStruct.updateMode ==
-        WidgetUpdateMode::PolicyDirectoryForceInstall)
+    if (isUpperVersion(update.existingVersion, update.incomingVersion) ||
+        m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_DIRECTORY)
     {
         LogInfo("Whether widget policy allow proceed ok");
         return ConfigureResult::Updated;
@@ -581,34 +576,29 @@ ConfigureResult JobWidgetInstall::checkWidgetUpdate(
     return ConfigureResult::Failed;
 }
 
-WidgetUpdateMode::Type JobWidgetInstall::CalcWidgetUpdatePolicy(
+bool JobWidgetInstall::isUpperVersion(
     const OptionalWidgetVersion &existingVersion,
-    const OptionalWidgetVersion &incomingVersion) const
+    const OptionalWidgetVersion &incomingVersion)
 {
-    // Widget is installed, check versions
+    LogInfo("Existing version = '" << *existingVersion);
+    LogInfo("Incoming version = '" << *incomingVersion);
+
     if (!existingVersion && !incomingVersion) {
-        return WidgetUpdateMode::ExistingVersionEqual;
+        return false;
     } else if (!existingVersion && !!incomingVersion) {
-        return WidgetUpdateMode::ExistingVersionNewer;
+        return false;
     } else if (!!existingVersion && !incomingVersion) {
-        return WidgetUpdateMode::ExistingVersionOlder;
+        return true;
     } else {
-        LogInfo("Existing widget: version = '" << *existingVersion << "'");
-
-        if (!existingVersion->IsWac() && !incomingVersion->IsWac()) {
-            return WidgetUpdateMode::BothVersionsNotStd;
-        } else if (!existingVersion->IsWac()) {
-            return WidgetUpdateMode::ExistingVersionNotStd;
-        } else if (!incomingVersion->IsWac()) {
-            return WidgetUpdateMode::IncomingVersionNotStd;
+        if (!existingVersion->IsWac() || !incomingVersion->IsWac()) {
+            return false;
         } else {
-            // Both versions are WAC-comparable. Do compare.
             if (*incomingVersion == *existingVersion) {
-                return WidgetUpdateMode::ExistingVersionEqual;
+                return false;
             } else if (*incomingVersion > *existingVersion) {
-                return WidgetUpdateMode::ExistingVersionOlder;
+                return true;
             } else {
-                return WidgetUpdateMode::ExistingVersionNewer;
+                return false;
             }
         }
     }
@@ -903,8 +893,7 @@ WrtDB::PackagingType JobWidgetInstall::checkPackageType(
     const std::string &tempPath)
 {
     // Check installation type (direcotory/ or config.xml or widget.wgt)
-    if (WidgetUpdateMode::PolicyDirectoryForceInstall ==
-        m_jobStruct.updateMode)
+    if (m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_DIRECTORY)
     {
         LogDebug("Install directly from directory");
         return PKG_TYPE_DIRECTORY_WEB_APP;
@@ -1041,7 +1030,7 @@ void JobWidgetInstall::setInstallLocationType(
 {
     m_installerContext.locationType = INSTALL_LOCATION_TYPE_NOMAL;
 
-    if (true == m_jobStruct.m_preload) {
+    if (m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_PRELOAD) {
         m_installerContext.locationType =
             INSTALL_LOCATION_TYPE_PRELOAD;
     } else {
index 73c58f1..004a476 100644 (file)
@@ -78,9 +78,9 @@ class JobWidgetInstall :
     static WidgetUpdateInfo detectWidgetUpdate(
         const WrtDB::ConfigParserData &configInfo,
         const WrtDB::TizenAppId &tizenId);
-    WidgetUpdateMode::Type CalcWidgetUpdatePolicy(
+    bool isUpperVersion(
         const OptionalWidgetVersion &existingVersion,
-        const OptionalWidgetVersion &incomingVersion) const;
+        const OptionalWidgetVersion &incomingVersion);
     void setTizenId(const WrtDB::ConfigParserData &configInfo);
     void displayWidgetInfo();
     void configureWidgetLocation(const std::string & widgetPath,
index 6a2f223..c87541d 100644 (file)
@@ -29,8 +29,6 @@ namespace WidgetInstall {
 //TODO make directory like jobs common?
 
 std::string createTempPath(bool preload = false);
-std::string createTempPath(bool preload);
-
 void createTempPath(const std::string& path);
 } // WidgetInstall
 } // Jobs
index 7f35574..e43b791 100644 (file)
@@ -45,51 +45,13 @@ typedef void (*InstallerProgressCallback)(void *userParam,
                                           ProgressPercent percent,
                                           const ProgressDescription &);
 
-namespace WidgetUpdateMode {
+namespace InstallMode {
 enum Type
 {
-    Zero = 0,
-
-    // Bits
-    NotInstalled = 1 << 0,
-    IncomingVersionNotStd = 1 << 1,
-    ExistingVersionNotStd = 1 << 2,
-    BothVersionsNotStd = 1 << 3,
-    ExistingVersionOlder = 1 << 4,
-    ExistingVersionEqual = 1 << 5,
-    ExistingVersionNewer = 1 << 6,
-
-    // Policies
-    PolicyNeverUpdate = NotInstalled,
-
-    PolicyWac = NotInstalled |
-        ExistingVersionOlder,
-
-    PolicyAlwaysInstall = NotInstalled |
-        IncomingVersionNotStd |
-        ExistingVersionNotStd |
-        BothVersionsNotStd |
-        ExistingVersionOlder |
-        ExistingVersionEqual |
-        ExistingVersionNewer,
-
-    PolicyForceInstall = PolicyAlwaysInstall,
-    PolicyDirectoryForceInstall
+    INSTALL_MODE_WGT = 0,
+    INSTALL_MODE_DIRECTORY,
+    INSTALL_MODE_PRELOAD,
 };
-
-inline Type operator | (const Type &a,
-                        const Type &b)
-{
-    return static_cast<Type>(static_cast<unsigned long>(a) |
-                             static_cast<unsigned long>(b));
-}
-
-inline Type operator & (const Type &a,
-                        const Type &b)
-{
-    return static_cast<Type>(static_cast<unsigned long>(a) &
-                             static_cast<unsigned long>(b));
-}
 }
 
 //TODO into namespace
@@ -101,31 +63,28 @@ WidgetInstallCallbackBase;
 //Widget Installation Struct
 struct WidgetInstallationStruct : public WidgetInstallCallbackBase
 {
-    WidgetUpdateMode::Type updateMode;
+    InstallMode::Type m_installMode;
     bool m_quiet;
-    bool m_preload;
     std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrInterface;
 
     // It must be empty-constructible as a parameter of generic event
-    WidgetInstallationStruct() : updateMode(WidgetUpdateMode::Zero),
-        m_quiet(true),
-        m_preload(false)
+    WidgetInstallationStruct() :
+        m_installMode(InstallMode::Type::INSTALL_MODE_WGT),
+        m_quiet(true)
     {}
 
     WidgetInstallationStruct(
         InstallerFinishedCallback finished,
         InstallerProgressCallback progress,
         void *param,
-        WidgetUpdateMode::Type mode,
+        InstallMode::Type mode,
         bool quiet,
-        bool preload,
         std::shared_ptr<PackageManager::IPkgmgrSignal>
         _pkgmgrInterface
         ) :
         WidgetInstallCallbackBase(finished, progress, param),
-        updateMode(mode),
+        m_installMode(mode),
         m_quiet(quiet),
-        m_preload(preload),
         pkgmgrInterface(_pkgmgrInterface)
     {}
 };
index f4b202e..aa9061c 100644 (file)
@@ -195,27 +195,6 @@ void InstallerLogic::InstallDeferredWidgetPackages()
 void InstallerLogic::InstallSingleDeferredPackage()
 {
     LogWarning("Not implemented");
-    //    if (m_packagesToInstall.empty())
-    //        return;
-    //
-    //    // Take single package
-    //    DPL::String widgetPackage = m_packagesToInstall.front();
-    //    m_packagesToInstall.pop_front();
-    //
-    //    // Remove it from DB
-    //    GlobalDAO::RemoveDefferedWidgetPackageInstallation(widgetPackage);
-    //
-    //    // Begin installation
-    //    LogInfo("Installing deferred widget package: " << widgetPackage);
-    //
-    //    // Post installation
-    //    CONTROLLER_POST_EVENT(
-    //        InstallerController,
-    // InstallerControllerEvents::InstallWidgetEvent(
-    //            DPL::ToUTF8String(widgetPackage).c_str(),
-    // WidgetInstallationStruct(
-    //                    &DummyInstallCallback, &DummyProgressCallback, NULL,
-    //                        WidgetUpdateMode::PolicyWac)));
 }
 
 void InstallerLogic::InstallWaitingPlugins()
index aef18ba..7adda4d 100644 (file)
@@ -27,7 +27,7 @@ SET(PKG_MANAGER_DIR
     )
 
 SET(WRT_INSTALLER_SOURCES
-    ${WRT_INSTALLER_DIR}/wrt_installer.cpp
+    ${WRT_INSTALLER_DIR}/wrt-installer.cpp
     ${WRT_INSTALLER_DIR}/wrt_installer_api.cpp
     ${WRT_INSTALLER_DIR}/installer_callbacks_translate.cpp
     ${WRT_INSTALLER_DIR}/plugin_utils.cpp
similarity index 95%
rename from src/wrt-installer/wrt_installer.cpp
rename to src/wrt-installer/wrt-installer.cpp
index c2f4702..1a1a427 100644 (file)
  *    See the License for the specific language governing permissions and
  *    limitations under the License.
  */
-/* @file    wrt_installer.cpp
+/* @file    wrt-installer.cpp
  * @version 1.0
  * @brief   Implementation file for installer
  */
 
-#include "wrt_installer.h"
+#include "wrt-installer.h"
 #include "plugin_utils.h"
 
-#include <cstdlib>
 #include <string>
-#include <fstream>
-#include <unistd.h>
-#include <memory>
+#include <cstring>
+#include <cstdlib>
+#include <dirent.h>
 #include <sys/resource.h>
+
+#include <dpl/log/log.h>
 #include <dpl/optional.h>
-#include <dpl/scoped_free.h>
 #include <dpl/optional_typedefs.h>
 #include <dpl/exception.h>
-#include <dpl/sstream.h>
-#include <vconf.h>
 #include <dpl/wrt-dao-ro/global_config.h>
 #include <dpl/wrt-dao-ro/config_parser_data.h>
-#include <dpl/localization/localization_utils.h>
-#include <dpl/optional_typedefs.h>
 #include <dpl/string.h>
 #include <dpl/abstract_waitable_input_adapter.h>
 #include <dpl/abstract_waitable_output_adapter.h>
 #include <dpl/copy.h>
 #include <dpl/errno_string.h>
 #include <dpl/utils/wrt_global_settings.h>
-#include "option_parser.h"
 #include <parser_runner.h>
 #include <widget_parser.h>
 #include <root_parser.h>
 
-#define NOFILE_CNT_FOR_INSTALLER 9999
+#include <Elementary.h>
+
+#include <pkg-manager/pkgmgr_signal_interface.h>
+#include <pkg-manager/pkgmgr_signal_dummy.h>
+#include <pkg-manager/pkgmgr_signal.h>
 
 using namespace WrtDB;
 
 namespace { // anonymous
-const char AUL_ARG_KEY[] = "widget_arg";
 const char * const PKGMGR_INSTALL_MSG = "Install widget";
 const char * const PKGMGR_UNINSTALL_MSG = "Uninstall widget";
 
-const double BASE_LAYOUT_W = 720.0f;
-const double BASE_LAYOUT_H = 1280.0f;
-
 const char * const CONFIG_XML = "config.xml";
 const char * const HYBRID_CONFIG_XML = "res/wgt/config.xml";
 
+const unsigned int NOFILE_CNT_FOR_INSTALLER = 9999;
+
 struct free_deleter
 {
     void operator()(void* x)
@@ -83,9 +80,8 @@ struct PluginInstallerData
 WrtInstaller::WrtInstaller(int argc, char **argv) :
     Application(argc, argv, "backend", false),
     DPL::TaskDecl<WrtInstaller>(this),
-    m_installPolicy(WRT_WIM_NOT_INSTALLED),
+    m_installMode(WRT_INSTALL_MODE_UNKNOWN),
     m_packagePath(),
-    m_handle(-1),
     m_initialized(false),
     m_numPluginsToInstall(0),
     m_totalPlugins(0),
@@ -93,8 +89,7 @@ WrtInstaller::WrtInstaller(int argc, char **argv) :
     m_installByPkgmgr(false),
     m_quiet(true),
     m_popup(NULL),
-    m_startupPluginInstallation(false),
-    m_preloadWidget(false)
+    m_startupPluginInstallation(false)
 {
     Touch();
     LogDebug("App Created");
@@ -105,6 +100,104 @@ WrtInstaller::~WrtInstaller()
     LogDebug("App Finished");
 }
 
+int WrtInstaller::getReturnStatus() const
+{
+    if (!m_returnStatus) {
+        return RE_SUCCESS;
+    } else {
+        return RE_FAIL;
+    }
+}
+
+WrtInstaller::InstallerPopup::InstallerPopup() :
+    m_win(NULL),
+    m_popup(NULL),
+    m_progressbar(NULL)
+{}
+
+WrtInstaller::InstallerPopup::~InstallerPopup()
+{
+    LogDebug("App Finished");
+}
+
+void WrtInstaller::InstallerPopup::init()
+{
+    LogDebug("Window Init");
+
+    if (m_win == NULL) {
+        // create window
+        m_win = createWin("wrt-installer");
+
+        // create popup
+        m_popup = elm_popup_add(m_win);
+
+        // create progressbar
+        m_progressbar = elm_progressbar_add(m_popup);
+        elm_object_style_set(m_progressbar, "list_progress");
+        elm_progressbar_horizontal_set(m_progressbar, EINA_TRUE);
+        evas_object_size_hint_align_set(m_progressbar, EVAS_HINT_FILL,
+                                        EVAS_HINT_FILL);
+        evas_object_size_hint_weight_set(m_progressbar, EVAS_HINT_EXPAND,
+                                         EVAS_HINT_EXPAND);
+        elm_object_content_set(m_popup, m_progressbar);
+        elm_progressbar_value_set(m_progressbar, 0.0);
+        evas_object_show(m_progressbar);
+
+        evas_object_show(m_popup);
+        evas_object_show(m_win);
+    }
+}
+
+Evas_Object* WrtInstaller::InstallerPopup::createWin(const char *name)
+{
+    Evas_Object *win;
+    win = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
+
+    int w, h;
+    if (!win) {
+        return NULL;
+    }
+
+    elm_win_alpha_set(win, EINA_TRUE);
+    elm_win_title_set(win, name);
+    elm_win_borderless_set(win, EINA_TRUE);
+    elm_win_raise(win);
+
+    ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
+    evas_object_resize(win, w, h);
+    return win;
+}
+
+void WrtInstaller::InstallerPopup::showPopup(void* userdata,
+                                             const DPL::String& pkgMsg,
+                                             ShowResultCallback callback)
+{
+    Evas_Object *btn;
+
+    LogDebug("Result Popup Created");
+    evas_object_del(m_popup);
+    m_popup = NULL;
+
+    m_popup = elm_popup_add(m_win);
+    if (!m_popup) {
+        return;
+    }
+
+    btn = elm_button_add(m_popup);
+    if (!btn) {
+        evas_object_del(m_popup);
+        return;
+    }
+    elm_object_text_set(btn, "OK");
+    evas_object_smart_callback_add(btn, "clicked", callback, userdata);
+    elm_object_part_content_set(m_popup, "button1", btn);
+    elm_object_part_text_set(m_popup, "title,text", "RESULT");
+    elm_object_text_set(m_popup, DPL::ToUTF8String(pkgMsg).c_str());
+
+    evas_object_show(m_popup);
+    evas_object_show(m_win);
+}
+
 void WrtInstaller::OnStop()
 {
     LogInfo("Stopping Dummy Client");
@@ -170,29 +263,19 @@ void WrtInstaller::OnCreate()
             struct stat info;
             if (-1 != stat(m_argv[2], &info) && S_ISDIR(info.st_mode)) {
                 LogInfo("Installing package directly from directory");
-                m_installPolicy = WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL;
+                m_installMode = WRT_INSTALL_MODE_INSTALL_DIRECTORY;
             } else {
                 LogInfo("Installing from regular location");
-                m_installPolicy = WRT_WIM_POLICY_WAC;
+                m_installMode = WRT_INSTALL_MODE_INSTALL_WGT;
             }
             m_packagePath = m_argv[2];
             AddStep(&WrtInstaller::installStep);
-        } else if (arg == "-if" || arg == "--install-force") {
-            if (m_argc != 3) {
-                return showHelpAndQuit();
-            }
-
-            m_packagePath = m_argv[2];
-            m_installPolicy = WRT_WIM_POLICY_FORCE_INSTALL;
-            AddStep(&WrtInstaller::installStep);
         } else if (arg == "-il" || arg == "--install-preload") {
             if (m_argc != 3) {
                 return showHelpAndQuit();
             }
-
             m_packagePath = m_argv[2];
-            m_preloadWidget = true;
-            m_installPolicy = WRT_WIM_POLICY_WAC;
+            m_installMode = WRT_INSTALL_MODE_INSTALL_PRELOAD;
             AddStep(&WrtInstaller::installStep);
         } else if (arg == "-un" || arg == "--uninstall-name") {
             if (m_argc != 3) {
@@ -232,10 +315,10 @@ void WrtInstaller::OnCreate()
             struct stat info;
             if (-1 != stat(m_argv[4], &info) && S_ISDIR(info.st_mode)) {
                 LogInfo("Installing package directly from directory");
-                m_installPolicy = WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL;
+                m_installMode = WRT_INSTALL_MODE_INSTALL_DIRECTORY;
             } else {
                 LogInfo("Installing from regular location");
-                m_installPolicy = WRT_WIM_POLICY_WAC;
+                m_installMode = WRT_INSTALL_MODE_INSTALL_WGT;
             }
             AddStep(&WrtInstaller::installStep);
             break;
@@ -255,23 +338,9 @@ void WrtInstaller::OnCreate()
         WRTInstallerNS::NextStepEvent());
 }
 
-void WrtInstaller::OnReset(bundle *b)
+void WrtInstaller::OnReset(bundle* /*b*/)
 {
-    const char * bundledVal = bundle_get_val(b, AUL_ARG_KEY);
-    if (bundledVal != NULL) {
-        m_bundleValue = bundledVal;
-        LogInfo("Bundled value for (" << AUL_ARG_KEY << ") key received: " <<
-                m_bundleValue);
-    }
-}
-
-int WrtInstaller::getReturnStatus() const
-{
-    if (!m_returnStatus) {
-        return RE_SUCCESS;
-    } else {
-        return RE_FAIL;
-    }
+    LogDebug("OnReset");
 }
 
 void WrtInstaller::OnTerminate()
@@ -298,8 +367,6 @@ void WrtInstaller::showHelpAndQuit()
            "  -p,    --install-plugins                      install plugins\n"
            "  -i,    --install                              "
            "install or update widget package for given path\n"
-           "  -if,   --install-force                        "
-           "install forcibly widget package for given path\n"
            "  -un,   --uninstall-name                       "
            "uninstall widget for given package name\n"
            "  -up,   --uninstall-packagepath                "
@@ -366,9 +433,8 @@ void WrtInstaller::installStep()
                        this, &staticWrtStatusCallback,
                        (!m_quiet || m_installByPkgmgr)
                        ? &staticWrtInstallProgressCallback : NULL,
-                       m_installPolicy,
+                       m_installMode,
                        m_quiet,
-                       m_preloadWidget,
                        pkgmgrSignalInterface);
 }
 
@@ -938,95 +1004,6 @@ void WrtInstaller::staticWrtUninstallProgressCallback(float percent,
     }
 }
 
-WrtInstaller::InstallerPopup::InstallerPopup() :
-    m_win(NULL),
-    m_popup(NULL),
-    m_progressbar(NULL)
-{}
-
-WrtInstaller::InstallerPopup::~InstallerPopup()
-{
-    LogDebug("App Finished");
-}
-
-void WrtInstaller::InstallerPopup::init()
-{
-    LogDebug("Window Init");
-
-    if (m_win == NULL) {
-        // create window
-        m_win = createWin("wrt-installer");
-
-        // create popup
-        m_popup = elm_popup_add(m_win);
-
-        // create progressbar
-        m_progressbar = elm_progressbar_add(m_popup);
-        elm_object_style_set(m_progressbar, "list_progress");
-        elm_progressbar_horizontal_set(m_progressbar, EINA_TRUE);
-        evas_object_size_hint_align_set(m_progressbar, EVAS_HINT_FILL,
-                                        EVAS_HINT_FILL);
-        evas_object_size_hint_weight_set(m_progressbar, EVAS_HINT_EXPAND,
-                                         EVAS_HINT_EXPAND);
-        elm_object_content_set(m_popup, m_progressbar);
-        elm_progressbar_value_set(m_progressbar, 0.0);
-        evas_object_show(m_progressbar);
-
-        evas_object_show(m_popup);
-        evas_object_show(m_win);
-    }
-}
-
-Evas_Object* WrtInstaller::InstallerPopup::createWin(const char *name)
-{
-    Evas_Object *win;
-    win = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
-
-    int w, h;
-    if (!win) {
-        return NULL;
-    }
-
-    elm_win_alpha_set(win, EINA_TRUE);
-    elm_win_title_set(win, name);
-    elm_win_borderless_set(win, EINA_TRUE);
-    elm_win_raise(win);
-
-    ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
-    evas_object_resize(win, w, h);
-    return win;
-}
-
-void WrtInstaller::InstallerPopup::showPopup(void* userdata,
-                                             const DPL::String& pkgMsg,
-                                             ShowResultCallback callback)
-{
-    Evas_Object *btn;
-
-    LogDebug("Result Popup Created");
-    evas_object_del(m_popup);
-    m_popup = NULL;
-
-    m_popup = elm_popup_add(m_win);
-    if (!m_popup) {
-        return;
-    }
-
-    btn = elm_button_add(m_popup);
-    if (!btn) {
-        evas_object_del(m_popup);
-        return;
-    }
-    elm_object_text_set(btn, "OK");
-    evas_object_smart_callback_add(btn, "clicked", callback, userdata);
-    elm_object_part_content_set(m_popup, "button1", btn);
-    elm_object_part_text_set(m_popup, "title,text", "RESULT");
-    elm_object_text_set(m_popup, DPL::ToUTF8String(pkgMsg).c_str());
-
-    evas_object_show(m_popup);
-    evas_object_show(m_win);
-}
-
 void WrtInstaller::showResultCallback(void *data, Evas_Object* /*obj*/,
                                       void* /*event_info*/)
 {
similarity index 89%
rename from src/wrt-installer/wrt_installer.h
rename to src/wrt-installer/wrt-installer.h
index 66fc636..890f42d 100644 (file)
  *    limitations under the License.
  */
 /**
- * @file    wrt_installer.h
+ * @file    wrt-installer.h
  * @version 1.0
  * @brief   Implementation file for installer
  */
-#ifndef WRT_CLIENT_H
-#define WRT_CLIENT_H
+#ifndef WRT_INSTALLER_H
+#define WRT_INSTALLER_H
 
 #include <dpl/application.h>
 #include <dpl/generic_event.h>
 #include <dpl/event/controller.h>
-#include <dpl/type_list.h>
 #include <dpl/task.h>
-#include <dpl/log/log.h>
 #include <dpl/string.h>
 #include <string>
-#include <utilX.h>
 #include <wrt_installer_api.h>
 
-#include <pkg-manager/pkgmgr_signal_interface.h>
-#include <pkg-manager/pkgmgr_signal_dummy.h>
-#include <pkg-manager/pkgmgr_signal.h>
-#include <memory>
-
 namespace WRTInstallerNS { //anonymous
 DECLARE_GENERIC_EVENT_0(QuitEvent)
 DECLARE_GENERIC_EVENT_0(NextStepEvent)
@@ -102,13 +94,10 @@ class WrtInstaller :
     // Installation steps
     void initStep();
     void installStep();
-    void installNewPlugins();
     void installPluginsStep();
     void uninstallPkgNameStep();
     void unistallWgtFileStep();
     void shutdownStep();
-    void registerCallbackStep();
-    void queryListStep();
 
     // Static callbacks
     static void staticWrtInitCallback(WrtErrStatus status,
@@ -134,14 +123,13 @@ class WrtInstaller :
     static void failResultCallback(void *data, Evas_Object *obj,
                                    void *event_info);
 
+    void installNewPlugins();
     bool popupsEnabled() const;
 
     // Private data
     std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrSignalInterface;
-    wrt_widget_install_mode_e m_installPolicy;
-    std::string m_bundleValue;
+    WrtInstallMode m_installMode;
     std::string m_packagePath;
-    int m_handle;
     std::string m_name;
     bool m_initialized;
     size_t m_numPluginsToInstall;
@@ -151,11 +139,8 @@ class WrtInstaller :
     bool m_quiet;
     InstallerPopup *m_popup;
     bool m_startupPluginInstallation;
-    std::string m_webAppConfig;
-    std::string m_webAppIcon;
-    bool m_preloadWidget;
 
     typedef std::list<std::string> PluginPathList;
     DPL::Optional<PluginPathList> m_pluginsPaths;
 };
-#endif // WRT_CLIENT_H
+#endif // WRT_INSTALLER_H
\ No newline at end of file
index 2497b33..671ab98 100644 (file)
 
 using namespace WrtDB;
 
-#undef TRUE
-#undef FALSE
-#define TRUE 0
-#define FALSE -1
-
 #ifdef __cplusplus
 
 #define EXPORT_API __attribute__((visibility("default")))
 extern "C"
 {
 #endif
-inline WidgetUpdateMode::Type translateWidgetUpdateMode(
-    wrt_widget_update_mode_t updateMode)
+inline InstallMode::Type translateInstallMode(
+    WrtInstallMode installMode)
 {
-    if (updateMode == WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL) {
-        return WidgetUpdateMode::PolicyDirectoryForceInstall;
-    }
-
-    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;
+    if (WRT_INSTALL_MODE_INSTALL_WGT == installMode) {
+        return InstallMode::INSTALL_MODE_WGT;
+    } else if (WRT_INSTALL_MODE_INSTALL_DIRECTORY == installMode) {
+        return InstallMode::INSTALL_MODE_DIRECTORY;
+    } else if (WRT_INSTALL_MODE_INSTALL_PRELOAD == installMode) {
+        return InstallMode::INSTALL_MODE_PRELOAD;
     }
-
-    return result;
+    Assert(true && "wrong argument is inputed");
 }
 
 const char PLUGIN_INSTALL_SEMAPHORE[] = "/.wrt_plugin_install_lock";
@@ -201,7 +170,7 @@ void plugin_install_progress_cb(float percent,
             ", Description : " << description);
 }
 
-EXPORT_API int wrt_installer_init(void *userdata,
+EXPORT_API void wrt_installer_init(void *userdata,
                                   WrtInstallerInitCallback callback)
 {
     // Set DPL/LOG MID
@@ -219,7 +188,7 @@ EXPORT_API int wrt_installer_init(void *userdata,
             if (callback) {
                 callback(WRT_INSTALLER_ERROR_FATAL_ERROR, userdata);
             }
-            return TRUE;
+            return;
         }
 
         // Initialize ValidationCore - this must be done before AttachDatabases
@@ -230,15 +199,6 @@ EXPORT_API int wrt_installer_init(void *userdata,
 
         InstallerMainThreadSingleton::Instance().AttachDatabases();
 
-        //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!");
-
         LogInfo("Prepare libxml2 to work in multithreaded program.");
         xmlInitParser();
 
@@ -266,11 +226,10 @@ EXPORT_API int wrt_installer_init(void *userdata,
         DPL::Exception::DisplayKnownException(ex);
         if (callback) {
             callback(WRT_INSTALLER_ERROR_FATAL_ERROR, userdata);
+            return;
         }
-        return FALSE;
     }
-    // OK
-    return TRUE;
+    return;
 }
 
 EXPORT_API void wrt_installer_shutdown()
@@ -303,9 +262,8 @@ EXPORT_API void wrt_install_widget(
     void* userdata,
     WrtInstallerStatusCallback status_cb,
     WrtProgressCallback progress_cb,
-    wrt_widget_update_mode_t update_mode,
+    WrtInstallMode installMode,
     bool quiet,
-    bool preload,
     std::shared_ptr<PackageManager::
                         IPkgmgrSignal> pkgmgrInterface
     )
@@ -322,9 +280,8 @@ EXPORT_API void wrt_install_widget(
                     InstallerCallbacksTranslate::installProgressCallback,
                     new InstallerCallbacksTranslate::StatusCallbackStruct(
                         userdata, status_cb, progress_cb),
-                    translateWidgetUpdateMode(update_mode),
+                    translateInstallMode(installMode),
                     quiet,
-                    preload,
                     pkgmgrInterface)));
     }
     UNHANDLED_EXCEPTION_HANDLER_END
@@ -513,90 +470,6 @@ EXPORT_API void wrt_install_all_plugins(
     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_INSTALLER_ERROR_FATAL_ERROR, 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_INSTALLER_ERROR_FATAL_ERROR, 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_guid(std::string & tzAppid,
-                                               const std::string & guid)
-{
-    try {
-        LogInfo("[WRT-API] GETTING WIDGET PACKAGE NAME BY WidgetID : "
-                << guid);
-
-        WidgetGUID widget_guid = DPL::FromUTF8String(guid);
-        WrtDB::WidgetDAOReadOnly dao(widget_guid);
-        tzAppid = DPL::ToUTF8String(dao.getTzAppId());
-        return WRT_SUCCESS;
-    } catch (WidgetDAOReadOnly::Exception::WidgetNotExist&) {
-        LogError("Error package name is not found");
-        return WRT_INSTALLER_ERROR_FATAL_ERROR;
-    } catch (const DPL::Exception& ex) {
-        LogError("Internal Error during get widget id by package name");
-        DPL::Exception::DisplayKnownException(ex);
-        return WRT_INSTALLER_ERROR_FATAL_ERROR;
-    }
-}
 #ifdef __cplusplus
 }
 #endif
index c8a058c..f5f726d 100644 (file)
  * @brief       This file contains declarations of wrt_installer_api
  */
 
-/*
- * @defgroup wrt_engine_group WebRunTime engine Library
- * @ingroup internet_FW
- * Functions to APIs to access wrt-engine
- */
-
 #ifndef WRT_INSTALLER_API_H_
 #define WRT_INSTALLER_API_H_
 
 extern "C" {
 #endif
 
-/**
- * Callback function type invoked after async init function
- */
 typedef void (*WrtInstallerInitCallback)(WrtErrStatus status,
                                          void *data);
-
-/**
- * Callback function type invoked after async functions
- */
 typedef void (*WrtPluginInstallerStatusCallback)(WrtErrStatus status,
                                                  void *data);
-
-/**
- * Callback function type invoked after async functions
- */
 typedef void (*WrtInstallerStatusCallback)(std::string tizenId,
                                            WrtErrStatus status,
                                            void *data);
-
-/**
- * Callback function type invoked after async functions
- */
 typedef void (*WrtProgressCallback)(float percent,
                                     const char *description,
                                     void *data);
-
-/**
- * Callback function type invoked when all plugin installations are finished
- */
 typedef void (*WrtAllPluginInstalledCallback)(void *userdata);
 
 typedef struct
@@ -78,205 +53,28 @@ typedef struct
     void *user_data;
 } wrt_plugin_data;
 
-/**
- * @fn int wrt_installer_init(void *userdata, WrtInstallerInitCallback callback)
- * @brief Initializes WRT
- *
- * This method is used to initialize wrt-engine.
- * It connects to database, initializes webkit, widget and plugin logic.
- *
- * @param [in]  userdata - User parameters to be passed to the callback
- * @param [in]  callback - The callback function that is launched, after
- *                         wrt initialization.
- *                         The callback is called in the context of the
- *                         application's main loop.
- *
- * @return 0 on success, -1 on failure
- *
- * Sample code:
- * @code
- * int main (int argc, char *argv[])
- * {
- *     init_loop(argc, argv);
- *     printf("Initializing WRT");
- *     wrt_init(NULL, &init_cb);
- *
- *     wait_for_wrt_init();
- *     printf("Starting tests");
- *
- *     int status = DPL_TestRunnerSingleton_Instance().ExecTestRunner(argc,
- *                                                                    argv);
- *
- *     wrt_installer_shutdown();
- *     quit_loop();
- *     return status;
- * }
- * @endcode
- *
- * @see wrt_installer_shutdown
- */
-typedef enum wrt_widget_install_mode_e
+enum WrtInstallMode
 {
-    /**
-     * Raw install bit flags
-     */
-    WRT_WIM_NOT_INSTALLED = (1 << 0),
-    WRT_WIM_INCOMING_VERSION_NOT_STD = (1 << 1),
-    WRT_WIM_EXISTING_VERSION_NOT_STD = (1 << 2),
-    WRT_WIM_BOTH_VERSIONS_NOT_STD = (1 << 3),
-    WRT_WIM_EXISTING_VERSION_OLDER = (1 << 4),
-    WRT_WIM_EXISTING_VERSION_EQUAL = (1 << 5),
-    WRT_WIM_EXISTING_VERSION_NEWER = (1 << 6),
-
-    /**
-     * Update default policies
-     */
-
-    /* Never update policy
-     */
-    WRT_WIM_POLICY_NEVER_UPDATE = WRT_WIM_NOT_INSTALLED,
-
-    /* WAC update policy
-     */
-    WRT_WIM_POLICY_WAC = WRT_WIM_NOT_INSTALLED |
-        WRT_WIM_EXISTING_VERSION_OLDER,
-
-    /* Always update policy
-     */
-    WRT_WIM_POLICY_ALWAYS_INSTALL = WRT_WIM_NOT_INSTALLED |
-        WRT_WIM_INCOMING_VERSION_NOT_STD |
-        WRT_WIM_EXISTING_VERSION_NOT_STD |
-        WRT_WIM_BOTH_VERSIONS_NOT_STD |
-        WRT_WIM_EXISTING_VERSION_OLDER |
-        WRT_WIM_EXISTING_VERSION_EQUAL |
-        WRT_WIM_EXISTING_VERSION_NEWER,
-
-    /* Force install policy
-     */
-    WRT_WIM_POLICY_FORCE_INSTALL = WRT_WIM_POLICY_ALWAYS_INSTALL,
-    /* Installation from directory - forced update
-     */
-    WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL
-} wrt_widget_update_mode_t;
-
-int wrt_installer_init(void *userdata,
-                       WrtInstallerInitCallback callback);
-
-/**
- * @fn void wrt_installer_shutdown(void)
- * @brief Deinitializes WRT
- *
- * This method is used to deinitialize wrt-engine.
- * It deinitializes widget logic, plugin logic, shuts down connection to
- * database, switchs back to single thread and does deinit checks.
- *
- * @return      nothing
- *
- * Sample code:
- * @code
- * int main (int argc, char *argv[])
- * {
- *     init_loop(argc, argv);
- *     printf("Initializing WRT");
- *     wrt_init(NULL, &init_cb);
- *
- *     wait_for_wrt_init();
- *     printf("Starting tests");
- *
- *     int status = DPL_TestRunnerSingleton_Instance().ExecTestRunner(argc,
- *                                                                    argv);
- *
- *     wrt_installer_shutdown();
- *     quit_loop();
- *     return status;
- * }
- * @endcode
- *
- * @see wrt_init
- */
+    WRT_INSTALL_MODE_UNKNOWN = 0,
+    WRT_INSTALL_MODE_INSTALL_WGT,
+    WRT_INSTALL_MODE_INSTALL_DIRECTORY,
+    WRT_INSTALL_MODE_INSTALL_PRELOAD
+};
+
+void wrt_installer_init(
+    void *userdata,
+    WrtInstallerInitCallback callback);
 void wrt_installer_shutdown(void);
-
-/**
- * @fn void wrt_install_widget(const char *widget_package_path,
- *                      void *user_parameter,
- *                      WrtInstallerStatusCallback status_callback,
- *                      WrtProgressCallback progress_callback,
- *                      wrt_widget_update_mode_t update_mode,
- *                      bool quiet,
- *                      bool preload);
- *
- * @brief Installs widget from given path
- *
- * This method is used to install widget from a given path.
- *
- * @param [in]  widget_package_path Path of the widget package.
- * @param [in]  user_parameter      User parameters to be passed to the callback
- * @param [in]  status_cb           Call to this one will be done at the end of
- *                                  operation
- *                                  The callback is called in the context of the
- *                                  application's
- * @param [in]  progress_cb         Callback function to get data of install
- *                                  progress
- *                                  If you don't want to get progress data, this
- *                                  should be NULL
- * @param [in]  install_mode        Installation mode
- * @param [in]  quiet               quiet mode
- * @param [in]  preload             preload widget install
- * @return                          Nothing (status returned in callback).
- *
- * Sample code:
- * @code
- *   wrt_install_widget(path.c_str(),
- *                      NULL,
- *                      install_cb,
- *                      progress_cb,
- *                      WRT_WIM_POLICY_WAC,
- *                      false,
- *                      false);
- * @endcode
- *
- * @see wrt_installer_uninstall_widget
- */
 void wrt_install_widget(
     const char *path,
     void *user_parameter,
     WrtInstallerStatusCallback status_callback,
     WrtProgressCallback progress_callback,
-    wrt_widget_update_mode_t update_mode,
+    WrtInstallMode install_mode,
     bool quiet,
-    bool preload,
     std::shared_ptr<PackageManager::IPkgmgrSignal>
     pkgmgrInterface
     );
-
-/**
- * @fn void wrt_installer_uninstall_widget (const char * const tizenAppid,
- *                                void* userdata,
- *                                WrtInstallerStatusCallback cb)
- * @brief Uninstalls widget using its name
- *
- * This method is used to uninstall the widget specified by its appid.
- * The callback function is called when the uninstall operation is done.
- *
- * @param [in]  tzAppid     - tizen appid
- * @param [in]  userdata    - user parameters to be passed to the callback
- * @param [in]  status_cb   - Call to this one will be done at the end of
- *                            operation
- *                            The callback is called in the context of the
- *                            application's
- * @param [in]  progress_cb - Callback function to get data of install progress
- *                            If you don't want to get progress data, this
- *                            should be NULL
- *
- * @return      nothing (status returned in callback).
- *
- * Sample code:
- * @code //TODO SAMPLE
- *  wrt_installer_uninstall_widget( appId, NULL, uninstall_cb, progress_cb);
- * @endcode
- *
- * @see wrt_installer_install_widget
- */
 void wrt_uninstall_widget (
     const char * const tzAppid,
     void* userdata,
@@ -284,75 +82,13 @@ void wrt_uninstall_widget (
     WrtProgressCallback progress_cb,
     std::shared_ptr<PackageManager::IPkgmgrSignal>
     pkgmgrSignalInterface);
-
-/**
- *  @fn void wrt_install_plugin(const char *pluginDirectory,
- *                              void *userData,
- *                              WrtInstallerStatusCallback statusCallback,
- *                              WrtProgressCallback progressCallback)
- *
- *  @brief Installs plugin from given path
- *
- *  This method installs new plugin from specified location and calls a callback
- *  function when the operation is done.
- *
- *  @param [in] pluginDirectory - plugin directory
- *  @param [in] userData    - user parameters to be passed to the callback
- *  @param [in] statusCallback   - user callback to call after installation
- *  @param [in] progressCallback - user callback to call when plugin
- *                                 installation progress has changed
- *
- *  @return nothing (status returned in callback).
- *
- * Sample code:
- * @code
- *  wrt_install_plugin("/usr/lib/wrt-plugins/",NULL,NULL,NULL);
- * @endcode
- *
- * @see wrt_install_plugin
- */
 void wrt_install_plugin(const char *pluginDirectory,
                         void *userData,
                         WrtPluginInstallerStatusCallback statusCallback,
                         WrtProgressCallback progressCallback);
-
-/**
- * @brief To install plugins for first excution
- *
- * This method install plugins
- *
- * @return nothing
- */
 void wrt_install_all_plugins(WrtAllPluginInstalledCallback installed_cb,
                              void *user_param);
 
-/**
- * @brief To initialize for tests
- *
- * This method is wrt init for tests
- *
- * @return int
- */
-int wrt_installer_init_for_tests(void *userdata,
-                                 WrtInstallerInitCallback callback);
-
-/**
- * @brief To shutdown for tests
- *
- * This method is wrt shutdown for tests
- *
- * @return int
- */
-void wrt_installer_shutdown_for_tests();
-
-/**
- * @brief wrt_get_widget_by_guid Returns tizenAppid by pkg guid (widgetId)
- * @param tzAppid tizen appid argument ot be set
- * @param guid guid that we look for
- * @return error code
- */
-WrtErrStatus wrt_get_widget_by_guid(std::string &tzAppid,
-                                    const std::string &guid);
 #ifdef __cplusplus
 }
 #endif