X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fwrt-installer%2Fwrt_installer.cpp;h=425d655acf654f10647c900d9a5183b14dd0d98c;hb=5d0b581548563b0b271382c1aedb900ff055cd42;hp=354cb5a37d6f5095217caacfd2a0d83fc356bda3;hpb=396a8ea6951d10ef313b6078f80330e4c4294abd;p=framework%2Fweb%2Fwrt-installer.git diff --git a/src/wrt-installer/wrt_installer.cpp b/src/wrt-installer/wrt_installer.cpp index 354cb5a..425d655 100644 --- a/src/wrt-installer/wrt_installer.cpp +++ b/src/wrt-installer/wrt_installer.cpp @@ -49,7 +49,8 @@ #include #include #include -#include + + #define NOFILE_CNT_FOR_INSTALLER 9999 @@ -89,7 +90,8 @@ WrtInstaller::WrtInstaller(int argc, char **argv) : m_installByPkgmgr(false), m_quiet(true), m_popup(NULL), - m_startupPluginInstallation(false) + m_startupPluginInstallation(false), + m_preloadWidget(false) { Touch(); LogDebug("App Created"); @@ -113,6 +115,12 @@ void WrtInstaller::OnCreate() std::string arg = m_argv[0]; + pkgmgrSignalInterface = std::static_pointer_cast( + std::shared_ptr( + new PackageManager::PkgmgrSignalDummy() + ) + ); + if (arg.empty()) { return showHelpAndQuit(); } @@ -147,8 +155,17 @@ void WrtInstaller::OnCreate() return showHelpAndQuit(); } + 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; + } + else + { + LogInfo("Installing from regular location"); + m_installPolicy = WRT_WIM_POLICY_WAC; + } m_packagePath = m_argv[2]; - m_installPolicy = WRT_WIM_POLICY_WAC; AddStep(&WrtInstaller::installStep); } else if (arg == "-if" || arg == "--install-force") { if (m_argc != 3) { @@ -158,6 +175,15 @@ void WrtInstaller::OnCreate() 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; + AddStep(&WrtInstaller::installStep); } else if (arg == "-un" || arg == "--uninstall-name") { if (m_argc != 3) { return showHelpAndQuit(); @@ -184,16 +210,31 @@ void WrtInstaller::OnCreate() using namespace PackageManager; m_installByPkgmgr = true; - PkgmgrSignalSingleton::Instance().initialize(m_argc, m_argv); - m_quiet = PkgmgrSignalSingleton::Instance().isNoPopupRequired(); + auto pkgmgrSignal = std::shared_ptr( + new PackageManager::PkgmgrSignal() + ); + + pkgmgrSignal->initialize(m_argc, m_argv); + m_quiet = pkgmgrSignal->isNoPopupRequired(); LogDebug("backend m_quiet"<getRequestedType(); + pkgmgrSignalInterface = + std::static_pointer_cast(pkgmgrSignal); switch (reqType) { case PKGMGR_REQ_INSTALL: m_packagePath = m_argv[4]; - m_installPolicy = WRT_WIM_POLICY_WAC; + 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; + } + else + { + LogInfo("Installing from regular location"); + m_installPolicy = WRT_WIM_POLICY_WAC; + } AddStep(&WrtInstaller::installStep); break; case PKGMGR_REQ_UNINSTALL: @@ -324,7 +365,9 @@ void WrtInstaller::installStep() (!m_quiet || m_installByPkgmgr) ? &staticWrtInstallProgressCallback : NULL, m_installPolicy, - m_quiet); + m_quiet, + m_preloadWidget, + pkgmgrSignalInterface); } void WrtInstaller::installPluginsStep() @@ -405,7 +448,8 @@ void WrtInstaller::uninstallPkgNameStep() LogDebug("Package name : " << m_name); wrt_uninstall_widget(m_name.c_str(), this, &staticWrtStatusCallback, (!m_quiet || m_installByPkgmgr) - ? &staticWrtUninstallProgressCallback : NULL); + ? &staticWrtUninstallProgressCallback : NULL, + pkgmgrSignalInterface); } void WrtInstaller::uninstallGuidStep() @@ -416,7 +460,8 @@ void WrtInstaller::uninstallGuidStep() if (status == WRT_SUCCESS) { LogDebug("Guid : " << m_name); wrt_uninstall_widget(pkgname.c_str(), this, &staticWrtStatusCallback, - !m_quiet ? &staticWrtUninstallProgressCallback : NULL); + !m_quiet ? &staticWrtUninstallProgressCallback : NULL, + pkgmgrSignalInterface); } else { printf("failed: can not uninstall widget\n"); LogError("Fail to uninstalling widget... "); @@ -463,7 +508,8 @@ void WrtInstaller::unistallWgtFileStep() if (status == WRT_SUCCESS) { LogDebug("Pkgname from packagePath : " << pkgname); wrt_uninstall_widget(pkgname.c_str(), this, &staticWrtStatusCallback, - !m_quiet ? &staticWrtUninstallProgressCallback : NULL); + !m_quiet ? &staticWrtUninstallProgressCallback : NULL, + pkgmgrSignalInterface); } else { LogError("Fail to uninstalling widget... "); m_returnStatus = -1; @@ -906,44 +952,48 @@ bool WrtInstaller::popupsEnabled() const int main(int argc, char *argv[]) { - // Output on stdout will be flushed after every newline character, - // even if it is redirected to a pipe. This is useful for running - // from a script and parsing output. - // (Standard behavior of stdlib is to use full buffering when - // redirected to a pipe, which means even after an end of line - // the output may not be flushed). - setlinebuf(stdout); - - // Check and re-set the file open limitation - struct rlimit rlim; - if (getrlimit(RLIMIT_NOFILE, &rlim) != -1) { - LogDebug("RLIMIT_NOFILE sft(" << rlim.rlim_cur << ")" ); - LogDebug("RLIMIT_NOFILE hrd(" << rlim.rlim_max << ")" ); - - if (rlim.rlim_cur < NOFILE_CNT_FOR_INSTALLER) { - rlim.rlim_cur = NOFILE_CNT_FOR_INSTALLER; - rlim.rlim_max = NOFILE_CNT_FOR_INSTALLER; - if (setrlimit(RLIMIT_NOFILE, &rlim) == -1) { - LogError("setrlimit is fail!!"); + UNHANDLED_EXCEPTION_HANDLER_BEGIN + { + // Output on stdout will be flushed after every newline character, + // even if it is redirected to a pipe. This is useful for running + // from a script and parsing output. + // (Standard behavior of stdlib is to use full buffering when + // redirected to a pipe, which means even after an end of line + // the output may not be flushed). + setlinebuf(stdout); + + // Check and re-set the file open limitation + struct rlimit rlim; + if (getrlimit(RLIMIT_NOFILE, &rlim) != -1) { + LogDebug("RLIMIT_NOFILE sft(" << rlim.rlim_cur << ")" ); + LogDebug("RLIMIT_NOFILE hrd(" << rlim.rlim_max << ")" ); + + if (rlim.rlim_cur < NOFILE_CNT_FOR_INSTALLER) { + rlim.rlim_cur = NOFILE_CNT_FOR_INSTALLER; + rlim.rlim_max = NOFILE_CNT_FOR_INSTALLER; + if (setrlimit(RLIMIT_NOFILE, &rlim) == -1) { + LogError("setrlimit is fail!!"); + } } + } else { + LogError("getrlimit is fail!!"); } - } else { - LogError("getrlimit is fail!!"); - } - // set evas backend type for emulator - // popup isn't showed in the emulator, - // if backend isn't set to SW backend - if (GlobalSettings::IsEmulator()) { - if (setenv("ELM_ENGINE", "x11", 1)) { - LogDebug("Enable backend"); + // set evas backend type for emulator + // popup isn't showed in the emulator, + // if backend isn't set to SW backend + if (GlobalSettings::IsEmulator()) { + if (setenv("ELM_ENGINE", "x11", 1)) { + LogDebug("Enable backend"); + } } - } - WrtInstaller app(argc, argv); - int ret = app.Exec(); - LogDebug("App returned: " << ret); - ret = app.getReturnStatus(); - LogDebug("WrtInstaller returned: " << ret); - return ret; + WrtInstaller app(argc, argv); + int ret = app.Exec(); + LogDebug("App returned: " << ret); + ret = app.getReturnStatus(); + LogDebug("WrtInstaller returned: " << ret); + return ret; + } + UNHANDLED_EXCEPTION_HANDLER_END }