From 6942173bf77609e1df73912f66238f44f2fa9c11 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Thu, 13 Nov 2014 12:01:44 +0100 Subject: [PATCH] COPKGManager: add function to get status for new package updates --- src/gui/opkg_manager.cpp | 21 +++++++++++++++++++++ src/gui/opkg_manager.h | 1 + 2 files changed, 22 insertions(+) diff --git a/src/gui/opkg_manager.cpp b/src/gui/opkg_manager.cpp index b4a88e93b..e05486e40 100644 --- a/src/gui/opkg_manager.cpp +++ b/src/gui/opkg_manager.cpp @@ -250,6 +250,27 @@ void COPKGManager::updateMenu() menu->setFooter(COPKGManagerFooterButtons, COPKGManagerFooterButtonCount); } +bool COPKGManager::hasUpdates() +{ + if (!hasOpkgSupport()) + return false; + + bool ret = false; + + getPkgData(OM_LIST); + getPkgData(OM_LIST_UPGRADEABLE); + + for (map::iterator it = pkg_map.begin(); it != pkg_map.end(); it++){ + if (it->second.upgradable){ + dprintf(DEBUG_INFO, "[neutrino opkg] Update packages available...\n"); + ret = true; + } + } + + pkg_map.clear(); + return ret; +} + void COPKGManager::refreshMenu() { list_installed_done = false, list_upgradeable_done = false; diff --git a/src/gui/opkg_manager.h b/src/gui/opkg_manager.h index fe9be2c71..bfbda558f 100644 --- a/src/gui/opkg_manager.h +++ b/src/gui/opkg_manager.h @@ -86,5 +86,6 @@ class COPKGManager : public CMenuTarget int exec(CMenuTarget* parent, const std::string & actionKey); static bool hasOpkgSupport(); + bool hasUpdates(); }; #endif