[addons] adds 'Check for updates' to the root of the add-ons manager.
authorJonathan Marshall <jmarshall@xbmc.org>
Fri, 28 Feb 2014 20:50:35 +0000 (09:50 +1300)
committerJonathan Marshall <jmarshall@xbmc.org>
Sun, 25 May 2014 01:51:35 +0000 (13:51 +1200)
language/English/strings.po
xbmc/addons/GUIViewStateAddonBrowser.cpp
xbmc/filesystem/AddonsDirectory.cpp

index f4e7c57..f8f365e 100755 (executable)
@@ -12119,7 +12119,19 @@ msgctxt "#24054"
 msgid "Changelog"
 msgstr ""
 
-#empty strings from id 24055 to 24058
+#. Used in the Add-on Manager
+#: xbmc/addons/GUIViewStateAddonBrowser.cpp
+msgctxt "#24055"
+msgid "Check for updates"
+msgstr ""
+
+#. Used in the Add-on Manager to specify last update time
+#: xbmc/addons/GUIViewStateAddonBrowser.cpp
+msgctxt "#24056"
+msgid "Last updated %s"
+msgstr ""
+
+#empty strings from id 24057 to 24058
 
 msgctxt "#24059"
 msgid "Would you like to enable this Add-on?"
index 35426e6..f3dfd17 100644 (file)
@@ -26,7 +26,9 @@
 #include "view/ViewState.h"
 #include "addons/Addon.h"
 #include "addons/AddonManager.h"
+#include "addons/AddonInstaller.h"
 #include "AddonDatabase.h"
+#include "utils/StringUtils.h"
 
 using namespace XFILE;
 using namespace ADDON;
@@ -64,6 +66,17 @@ VECSOURCES& CGUIViewStateAddonBrowser::GetSources()
 {
   m_sources.clear();
 
+  { // check for updates
+    CMediaSource share;
+    share.strPath = "addons://check/";
+    share.m_iDriveType = CMediaSource::SOURCE_TYPE_REMOTE; // hack for sorting
+    share.strName = g_localizeStrings.Get(24055); // "Check for updates"
+    CDateTime lastChecked = CAddonInstaller::Get().LastRepoUpdate();
+    if (lastChecked.IsValid())
+      share.strStatus = StringUtils::Format(g_localizeStrings.Get(24056).c_str(),
+                                            lastChecked.GetAsLocalizedDateTime(false, false).c_str());
+    m_sources.push_back(share);
+  }
   if (CAddonMgr::Get().HasOutdatedAddons())
   {
     CMediaSource share;
index 6b37819..5091487 100644 (file)
@@ -78,10 +78,22 @@ bool CAddonsDirectory::GetDirectory(const CStdString& strPath, CFileItemList &it
   {
     reposAsFolders = false;
     groupAddons = false;
+    // ensure our repos are up to date
+    CAddonInstaller::Get().UpdateRepos(false, true);
     CAddonMgr::Get().GetAllOutdatedAddons(addons);
     items.SetProperty("reponame",g_localizeStrings.Get(24043));
     items.SetLabel(g_localizeStrings.Get(24043));
   }
+  else if (path.GetHostName().Equals("check"))
+  {
+    reposAsFolders = false;
+    groupAddons = false;
+    // force a refresh
+    CAddonInstaller::Get().UpdateRepos(true, true);
+    CAddonMgr::Get().GetAllOutdatedAddons(addons);
+    items.SetProperty("reponame",g_localizeStrings.Get(24055));
+    items.SetLabel(g_localizeStrings.Get(24055));
+  }
   else if (path.GetHostName().Equals("repos"))
   {
     groupAddons = false;
@@ -200,7 +212,8 @@ bool CAddonsDirectory::GetDirectory(const CStdString& strPath, CFileItemList &it
     item->SetLabel(g_localizeStrings.Get(24032));
     items.Add(item);
   }
-  else if (path.GetHostName().Equals("outdated") && items.Size() > 1)
+  else if ((path.GetHostName().Equals("outdated") ||
+            path.GetHostName().Equals("check")) && items.Size() > 1)
   {
     CFileItemPtr item(new CFileItem("addons://update_all/", true));
     item->SetLabel(g_localizeStrings.Get(24122));