mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 15:32:59 +02:00
opkg_manager: add option for silent screen
Help to control some screen messages, avoids unintended or disturbing messages, e.g. on update checks at background.
This commit is contained in:
@@ -146,6 +146,7 @@ void COPKGManager::init()
|
||||
local_dir = &g_settings.update_dir_opkg;
|
||||
v_bad_pattern = getBadPackagePatternList();
|
||||
CFileHelpers::createDir(OPKG_TMP_DIR);
|
||||
silent = false;
|
||||
}
|
||||
|
||||
COPKGManager::~COPKGManager()
|
||||
@@ -457,34 +458,37 @@ bool COPKGManager::checkUpdates(const std::string & package_name, bool show_prog
|
||||
if (!hasOpkgSupport())
|
||||
return false;
|
||||
|
||||
silent = !show_progress;
|
||||
|
||||
doUpdate();
|
||||
|
||||
bool ret = false;
|
||||
|
||||
size_t i = 0;
|
||||
CProgressWindow status;
|
||||
CProgressWindow *status = NULL;
|
||||
|
||||
if (show_progress){
|
||||
status.showHeader(false);
|
||||
status.paint();
|
||||
status.showStatusMessageUTF(g_Locale->getText(LOCALE_OPKG_UPDATE_READING_LISTS));
|
||||
status.showStatus(25); /* after do_update, we have actually done the hardest work already */
|
||||
status = new CProgressWindow();
|
||||
status->showHeader(false);
|
||||
status->paint();
|
||||
status->showStatusMessageUTF(g_Locale->getText(LOCALE_OPKG_UPDATE_READING_LISTS));
|
||||
status->showStatus(25); /* after do_update, we have actually done the hardest work already */
|
||||
}
|
||||
|
||||
getPkgData(OM_LIST);
|
||||
if (show_progress)
|
||||
status.showStatus(50);
|
||||
status->showStatus(50);
|
||||
getPkgData(OM_LIST_UPGRADEABLE);
|
||||
if (show_progress)
|
||||
status.showStatus(75);
|
||||
status->showStatus(75);
|
||||
|
||||
for (map<string, struct pkg>::iterator it = pkg_map.begin(); it != pkg_map.end(); ++it){
|
||||
dprintf(DEBUG_INFO, "[COPKGManager] [%s - %d] Update check for...%s\n", __func__, __LINE__, it->second.name.c_str());
|
||||
if (show_progress){
|
||||
/* showing the names only makes things *much* slower...
|
||||
status.showStatusMessageUTF(it->second.name);
|
||||
status->showStatusMessageUTF(it->second.name);
|
||||
*/
|
||||
status.showStatus(75 + 25*i / pkg_map.size());
|
||||
status->showStatus(75 + 25*i / pkg_map.size());
|
||||
}
|
||||
|
||||
if (it->second.upgradable){
|
||||
@@ -499,28 +503,41 @@ bool COPKGManager::checkUpdates(const std::string & package_name, bool show_prog
|
||||
}
|
||||
|
||||
if (show_progress){
|
||||
status.showGlobalStatus(100);
|
||||
status.showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_READY)); // UTF-8
|
||||
status.hide();
|
||||
status->showGlobalStatus(100);
|
||||
status->showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_READY)); // UTF-8
|
||||
status->hide();
|
||||
}
|
||||
|
||||
if (status) {
|
||||
delete status; status = NULL;
|
||||
}
|
||||
#if 0
|
||||
pkg_map.clear();
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int COPKGManager::doUpdate()
|
||||
{
|
||||
CHintBox hintBox(LOCALE_MESSAGEBOX_INFO, LOCALE_OPKG_UPDATE_CHECK);
|
||||
hintBox.paint();
|
||||
CHintBox *hintBox = NULL;
|
||||
|
||||
if (!silent ) {
|
||||
hintBox = new CHintBox (LOCALE_MESSAGEBOX_INFO, LOCALE_OPKG_UPDATE_CHECK);
|
||||
hintBox->paint();
|
||||
}
|
||||
|
||||
int r = execCmd(pkg_types[OM_UPDATE], CShellWindow::QUIET);
|
||||
hintBox.hide();
|
||||
|
||||
if (hintBox){
|
||||
hintBox->hide();
|
||||
delete hintBox; hintBox = NULL;
|
||||
}
|
||||
|
||||
if (r) {
|
||||
string msg = string(g_Locale->getText(LOCALE_OPKG_FAILURE_UPDATE));
|
||||
msg += '\n' + tmp_str;
|
||||
DisplayErrorMessage(msg.c_str());
|
||||
if (!silent)
|
||||
DisplayErrorMessage(msg.c_str());
|
||||
return r;
|
||||
}
|
||||
return 0;
|
||||
@@ -984,7 +1001,8 @@ void COPKGManager::showErr(int* res)
|
||||
{
|
||||
string err = to_string(*res);
|
||||
string errtest = err_list[1].id;
|
||||
DisplayErrorMessage(errtest.c_str());
|
||||
if (!silent)
|
||||
DisplayErrorMessage(errtest.c_str());
|
||||
}
|
||||
|
||||
void COPKGManager::showError(const char* local_msg, char* err_message, const string& additional_text)
|
||||
@@ -994,14 +1012,16 @@ void COPKGManager::showError(const char* local_msg, char* err_message, const str
|
||||
msg += string(err_message) + ":\n";
|
||||
if (!additional_text.empty())
|
||||
msg += additional_text;
|
||||
DisplayErrorMessage(msg.c_str());
|
||||
if (!silent)
|
||||
DisplayErrorMessage(msg.c_str());
|
||||
}
|
||||
|
||||
bool COPKGManager::installPackage(const string& pkg_name, string options, bool force_configure)
|
||||
{
|
||||
//check package size...cancel installation if size check failed
|
||||
if (!checkSize(pkg_name)){
|
||||
DisplayErrorMessage(g_Locale->getText(LOCALE_OPKG_MESSAGEBOX_SIZE_ERROR));
|
||||
if (!silent)
|
||||
DisplayErrorMessage(g_Locale->getText(LOCALE_OPKG_MESSAGEBOX_SIZE_ERROR));
|
||||
}
|
||||
else{
|
||||
string opts = " " + options + " ";
|
||||
@@ -1121,6 +1141,7 @@ void COPKGManager::saveConfig()
|
||||
//finally save config file
|
||||
if (!opkg_conf.saveConfig(OPKG_CONFIG_FILE, '\t')){
|
||||
dprintf(DEBUG_NORMAL, "[COPKGManager] [%s - %d] Error: error while saving opkg config file! -> %s\n", __func__, __LINE__, OPKG_CONFIG_FILE);
|
||||
DisplayErrorMessage("Error while saving opkg config file!");
|
||||
if (!silent)
|
||||
DisplayErrorMessage("Error while saving opkg config file!");
|
||||
}
|
||||
}
|
||||
|
@@ -49,6 +49,7 @@ class COPKGManager : public CMenuTarget
|
||||
void loadConfig();
|
||||
struct pkg;
|
||||
void init();
|
||||
bool silent; // Controls some screen messages, eg, avoids unintended or disturbing messages on update checks at background.
|
||||
//config
|
||||
std::string config_src[OPKG_MAX_FEEDS];
|
||||
std::vector<std::string> config_dest;
|
||||
|
Reference in New Issue
Block a user