From 7660a6f5ff19d3d29fdd4ed8eb27e3607e6a9d9f Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sat, 20 Dec 2014 21:04:35 +0100 Subject: [PATCH] COPKGManager: outsource methode for install any package Required for external usage. Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/7520fee2ef691e1013168cb3f988baf0e72843d3 Author: Thilo Graf Date: 2014-12-20 (Sat, 20 Dec 2014) --- src/gui/opkg_manager.cpp | 23 +++++++++++++++++------ src/gui/opkg_manager.h | 1 + 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/gui/opkg_manager.cpp b/src/gui/opkg_manager.cpp index bc9de4384..1476ec05e 100644 --- a/src/gui/opkg_manager.cpp +++ b/src/gui/opkg_manager.cpp @@ -153,13 +153,10 @@ int COPKGManager::exec(CMenuTarget* parent, const string &actionKey) if (fileBrowser.exec((*local_dir).c_str())) { - string pgk_name = fileBrowser.getSelectedFile()->Name; - int r = execCmd(pkg_types[OM_INSTALL] + pgk_name, true, true); + string pkg_name = fileBrowser.getSelectedFile()->Name; + installPackage(pkg_name); + *local_dir = fileBrowser.getCurrentDir(); - if (r) { - showError(g_Locale->getText(LOCALE_OPKG_FAILURE_INSTALL), strerror(errno), pgk_name); - } else - installed = true; refreshMenu(); } return res; @@ -670,3 +667,17 @@ void COPKGManager::showError(const char* local_msg, char* err_message, const str msg += command; DisplayErrorMessage(msg.c_str()); } + +bool COPKGManager::installPackage(const std::string& pkg_name) +{ + int r = execCmd(pkg_types[OM_INSTALL] + pkg_name, true, true); + + if (r){ + showError(g_Locale->getText(LOCALE_OPKG_FAILURE_INSTALL), strerror(errno), pkg_name); + return false; + } + else + installed = true; + + return true; +} diff --git a/src/gui/opkg_manager.h b/src/gui/opkg_manager.h index 3c2298008..3e1c2cf0b 100644 --- a/src/gui/opkg_manager.h +++ b/src/gui/opkg_manager.h @@ -96,5 +96,6 @@ class COPKGManager : public CMenuTarget int exec(CMenuTarget* parent, const std::string & actionKey); static bool hasOpkgSupport(); bool checkUpdates(const std::string & package_name = std::string(), bool show_progress = true); + bool installPackage(const std::string& pkg_name); }; #endif