mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 16:31:11 +02:00
COPKGManager: add member showError to show handled error message on screen
This commit is contained in:
@@ -51,7 +51,7 @@
|
|||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <alloca.h>
|
#include <alloca.h>
|
||||||
|
#include <errno.h>
|
||||||
/* later this can be changed to just "opkg" */
|
/* later this can be changed to just "opkg" */
|
||||||
#define OPKG_CL "opkg-cl"
|
#define OPKG_CL "opkg-cl"
|
||||||
|
|
||||||
@@ -137,10 +137,7 @@ int COPKGManager::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
parent->hide();
|
parent->hide();
|
||||||
int r = execCmd(actionKey, true, true);
|
int r = execCmd(actionKey, true, true);
|
||||||
if (r) {
|
if (r) {
|
||||||
std::string loc = g_Locale->getText(LOCALE_OPKG_FAILURE_UPGRADE);
|
showError(g_Locale->getText(LOCALE_OPKG_FAILURE_UPGRADE), strerror(errno), actionKey);
|
||||||
char rs[strlen(loc.c_str()) + 20];
|
|
||||||
snprintf(rs, sizeof(rs), loc.c_str(), r);
|
|
||||||
DisplayErrorMessage(rs);
|
|
||||||
} else
|
} else
|
||||||
installed = true;
|
installed = true;
|
||||||
refreshMenu();
|
refreshMenu();
|
||||||
@@ -163,10 +160,7 @@ int COPKGManager::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
}
|
}
|
||||||
int r = execCmd(pkg_types[OM_INSTALL] + force + actionKey, true, true);
|
int r = execCmd(pkg_types[OM_INSTALL] + force + actionKey, true, true);
|
||||||
if (r) {
|
if (r) {
|
||||||
std::string err = g_Locale->getText(LOCALE_OPKG_FAILURE_INSTALL);
|
showError(g_Locale->getText(LOCALE_OPKG_FAILURE_INSTALL), strerror(errno), pkg_types[OM_INSTALL] + force + actionKey);
|
||||||
char rs[strlen(err.c_str()) + 20];
|
|
||||||
snprintf(rs, sizeof(rs), err.c_str(), r);
|
|
||||||
DisplayErrorMessage(rs);
|
|
||||||
} else
|
} else
|
||||||
installed = true;
|
installed = true;
|
||||||
refreshMenu();
|
refreshMenu();
|
||||||
@@ -265,10 +259,7 @@ int COPKGManager::showMenu()
|
|||||||
|
|
||||||
int r = execCmd(pkg_types[OM_UPDATE]);
|
int r = execCmd(pkg_types[OM_UPDATE]);
|
||||||
if (r) {
|
if (r) {
|
||||||
std::string loc = g_Locale->getText(LOCALE_OPKG_FAILURE_UPDATE);
|
showError(g_Locale->getText(LOCALE_OPKG_FAILURE_UPDATE), strerror(errno), pkg_types[OM_UPDATE]);
|
||||||
char rs[strlen(loc.c_str()) + 20];
|
|
||||||
snprintf(rs, sizeof(rs), loc.c_str(), r);
|
|
||||||
DisplayErrorMessage(rs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getPkgData(OM_LIST);
|
getPkgData(OM_LIST);
|
||||||
@@ -357,7 +348,7 @@ void COPKGManager::getPkgData(const int pkg_content_id)
|
|||||||
|
|
||||||
FILE *f = popen(pkg_types[pkg_content_id].c_str(), "r");
|
FILE *f = popen(pkg_types[pkg_content_id].c_str(), "r");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
DisplayErrorMessage("Command failed");
|
showError("Internal Error", strerror(errno), pkg_types[pkg_content_id]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,3 +414,11 @@ fprintf(stderr, "execCmd(%s)\n", cmdstr);
|
|||||||
return WEXITSTATUS(r);
|
return WEXITSTATUS(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void COPKGManager::showError(const char* local_msg, char* sys_msg, const string& command)
|
||||||
|
{
|
||||||
|
string msg = local_msg ? string(local_msg) + "\n" : "";
|
||||||
|
msg += string(sys_msg) + ":\n";
|
||||||
|
msg += command;
|
||||||
|
DisplayErrorMessage(msg.c_str());
|
||||||
|
}
|
||||||
|
@@ -68,6 +68,7 @@ class COPKGManager : public CMenuTarget
|
|||||||
void updateMenu();
|
void updateMenu();
|
||||||
void refreshMenu();
|
void refreshMenu();
|
||||||
bool badpackage(std::string &s);
|
bool badpackage(std::string &s);
|
||||||
|
void showError(const char* local_msg, char* sys_msg, const std::string& command);
|
||||||
|
|
||||||
struct pkg {
|
struct pkg {
|
||||||
std::string name;
|
std::string name;
|
||||||
|
Reference in New Issue
Block a user