mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-31 09:21:18 +02:00
opkg_manager: add class with member to set an update status
This commit is contained in:
@@ -233,13 +233,17 @@ int COPKGManager::exec(CMenuTarget* parent, const string &actionKey)
|
|||||||
if (parent)
|
if (parent)
|
||||||
parent->hide();
|
parent->hide();
|
||||||
int r = execCmd(actionKey, CShellWindow::VERBOSE | CShellWindow::ACKNOWLEDGE_EVENT);
|
int r = execCmd(actionKey, CShellWindow::VERBOSE | CShellWindow::ACKNOWLEDGE_EVENT);
|
||||||
if (r) {
|
if (r)
|
||||||
|
{
|
||||||
/* errno is never set properly, the string is totally useless.
|
/* errno is never set properly, the string is totally useless.
|
||||||
showError(g_Locale->getText(LOCALE_OPKG_FAILURE_UPGRADE), strerror(errno), actionKey);
|
showError(g_Locale->getText(LOCALE_OPKG_FAILURE_UPGRADE), strerror(errno), actionKey);
|
||||||
*/
|
*/
|
||||||
showError(g_Locale->getText(LOCALE_OPKG_FAILURE_UPGRADE), NULL, actionKey);
|
showError(g_Locale->getText(LOCALE_OPKG_FAILURE_UPGRADE), NULL, actionKey);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
installed = true;
|
installed = true;
|
||||||
|
}
|
||||||
refreshMenu();
|
refreshMenu();
|
||||||
/* I don't think ending up at the last package in the list is a good idea...
|
/* I don't think ending up at the last package in the list is a good idea...
|
||||||
g_RCInput->postMsg((neutrino_msg_t) CRCInput::RC_up, 0);
|
g_RCInput->postMsg((neutrino_msg_t) CRCInput::RC_up, 0);
|
||||||
@@ -551,11 +555,14 @@ void COPKGManager::initUpdateMessage(bool enable_message)
|
|||||||
f.close();
|
f.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void COPKGManager::setUpdateCheckResult(bool enable_message)
|
void COPKGManager::setUpdateCheckResult(bool enable_message)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> g(opk_mutex);
|
std::lock_guard<std::mutex> g(opk_mutex);
|
||||||
|
|
||||||
checkUpdates(std::string(), enable_message);
|
checkUpdates(std::string(), enable_message);
|
||||||
|
handleUpdateFlagFile();
|
||||||
|
|
||||||
if (num_updates)
|
if (num_updates)
|
||||||
initUpdateMessage(enable_message);
|
initUpdateMessage(enable_message);
|
||||||
else
|
else
|
||||||
@@ -563,6 +570,21 @@ void COPKGManager::setUpdateCheckResult(bool enable_message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COPKGManager::handleUpdateFlagFile()
|
||||||
|
{
|
||||||
|
if (file_exists(HAS_PKG_UPDATE_FLAGFILE))
|
||||||
|
unlink(HAS_PKG_UPDATE_FLAGFILE);
|
||||||
|
|
||||||
|
if (num_updates)
|
||||||
|
{
|
||||||
|
fstream f;
|
||||||
|
f.open(HAS_PKG_UPDATE_FLAGFILE, ios::out);
|
||||||
|
f << num_updates << endl;
|
||||||
|
f.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool COPKGManager::checkUpdates(const std::string & package_name, bool show_progress)
|
bool COPKGManager::checkUpdates(const std::string & package_name, bool show_progress)
|
||||||
{
|
{
|
||||||
if (!hasOpkgSupport() || file_exists("/run/opkg.lock"))
|
if (!hasOpkgSupport() || file_exists("/run/opkg.lock"))
|
||||||
@@ -676,6 +698,7 @@ int COPKGManager::showMenu()
|
|||||||
//upgrade all installed packages
|
//upgrade all installed packages
|
||||||
std::string upd_info = to_string(num_updates) + " " + g_Locale->getText(LOCALE_OPKG_MESSAGEBOX_UPDATES_AVAILABLE);
|
std::string upd_info = to_string(num_updates) + " " + g_Locale->getText(LOCALE_OPKG_MESSAGEBOX_UPDATES_AVAILABLE);
|
||||||
upgrade_forwarder = new CMenuForwarder(LOCALE_OPKG_UPGRADE, true, upd_info.c_str() , this, pm_cmd[CMD_UPGRADE].c_str(), CRCInput::RC_red);
|
upgrade_forwarder = new CMenuForwarder(LOCALE_OPKG_UPGRADE, true, upd_info.c_str() , this, pm_cmd[CMD_UPGRADE].c_str(), CRCInput::RC_red);
|
||||||
|
upgrade_forwarder->OnPaintItem.connect(sigc::bind(sigc::mem_fun(this, &COPKGManager::setUpdateStateIcon2Item), upgrade_forwarder));
|
||||||
upgrade_forwarder->setHint(NEUTRINO_ICON_HINT_SW_UPDATE, LOCALE_MENU_HINT_OPKG_UPGRADE);
|
upgrade_forwarder->setHint(NEUTRINO_ICON_HINT_SW_UPDATE, LOCALE_MENU_HINT_OPKG_UPGRADE);
|
||||||
menu->addItem(upgrade_forwarder);
|
menu->addItem(upgrade_forwarder);
|
||||||
|
|
||||||
@@ -1202,3 +1225,14 @@ bool COPKGManager::isUpgradable(const string& pkg_name)
|
|||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void COPKGManagerExtra::setUpdateStateIcon2Item(CMenuItem *item)
|
||||||
|
{
|
||||||
|
if (!item)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (file_exists(HAS_PKG_UPDATE_FLAGFILE))
|
||||||
|
item->setInfoIconRight(NEUTRINO_ICON_MARKER_UPDATE_AVAILABLE);
|
||||||
|
else
|
||||||
|
item->setInfoIconRight(NEUTRINO_ICON_MARKER_DIALOG_OK);
|
||||||
|
}
|
||||||
|
@@ -38,8 +38,16 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
#define OPKG_MAX_FEEDS 10
|
#define OPKG_MAX_FEEDS 10
|
||||||
|
#define HAS_PKG_UPDATE_FLAGFILE "/tmp/.has_pkg_updates"
|
||||||
|
|
||||||
class COPKGManager : public CMenuTarget
|
class COPKGManagerExtra
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// set update status to passed menu item
|
||||||
|
void setUpdateStateIcon2Item(CMenuItem* item);
|
||||||
|
};
|
||||||
|
|
||||||
|
class COPKGManager : public CMenuTarget, public COPKGManagerExtra
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
struct pkg {
|
struct pkg {
|
||||||
@@ -115,6 +123,7 @@ class COPKGManager : public CMenuTarget
|
|||||||
bool isInstalled(const std::string& pkg_name);
|
bool isInstalled(const std::string& pkg_name);
|
||||||
bool isUpgradable(const std::string& pkg_name);
|
bool isUpgradable(const std::string& pkg_name);
|
||||||
|
|
||||||
|
void handleUpdateFlagFile();
|
||||||
void initUpdateMessage(bool enable_message = true);
|
void initUpdateMessage(bool enable_message = true);
|
||||||
bool removeInfoBarTxt();
|
bool removeInfoBarTxt();
|
||||||
std::mutex opk_mutex;
|
std::mutex opk_mutex;
|
||||||
@@ -195,4 +204,5 @@ class COPKGManager : public CMenuTarget
|
|||||||
bool installPackage(const std::string& pkg_name, std::string options = std::string(), bool force_configure = false);
|
bool installPackage(const std::string& pkg_name, std::string options = std::string(), bool force_configure = false);
|
||||||
bool checkSize(const std::string& pkg_name);
|
bool checkSize(const std::string& pkg_name);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user