[addons] add 'Update all' item to the available updates menu
authorJonathan Marshall <jmarshall@xbmc.org>
Sun, 23 Feb 2014 00:09:18 +0000 (13:09 +1300)
committerJonathan Marshall <jmarshall@xbmc.org>
Sun, 23 Feb 2014 00:18:09 +0000 (13:18 +1300)
language/English/strings.po
xbmc/addons/GUIWindowAddonBrowser.cpp
xbmc/filesystem/AddonsDirectory.cpp

index ba434d9..9c794a6 100755 (executable)
@@ -12223,7 +12223,12 @@ msgctxt "#24121"
 msgid "Enter search string"
 msgstr ""
 
-#empty strings from id 24122 to 24999
+#: xbmc/filesystem/AddonDirectory.cpp
+msgctxt "#24122"
+msgid "Update all"
+msgstr ""
+
+#empty strings from id 24123 to 24999
 
 msgctxt "#25000"
 msgid "Notifications"
index d3156df..4d966b9 100644 (file)
@@ -23,6 +23,7 @@
 #include "addons/Repository.h"
 #include "GUIDialogAddonInfo.h"
 #include "GUIDialogAddonSettings.h"
+#include "dialogs/GUIDialogBusy.h"
 #include "dialogs/GUIDialogYesNo.h"
 #include "dialogs/GUIDialogSelect.h"
 #include "dialogs/GUIDialogFileBrowser.h"
@@ -208,6 +209,20 @@ bool CGUIWindowAddonBrowser::OnContextButton(int itemNumber,
   return CGUIMediaWindow::OnContextButton(itemNumber, button);
 }
 
+class UpdateAddons : public IRunnable
+{
+  virtual void Run()
+  {
+    VECADDONS addons;
+    CAddonMgr::Get().GetAllOutdatedAddons(addons, true); // get local
+    for (VECADDONS::iterator i = addons.begin(); i != addons.end(); ++i)
+    {
+      CStdString referer = StringUtils::Format("Referer=%s-%s.zip",(*i)->ID().c_str(),(*i)->Version().c_str());
+      CAddonInstaller::Get().Install((*i)->ID(), true, referer); // force install
+    }
+  }
+};
+
 bool CGUIWindowAddonBrowser::OnClick(int iItem)
 {
   CFileItemPtr item = m_vecItems->Get(iItem);
@@ -222,6 +237,14 @@ bool CGUIWindowAddonBrowser::OnClick(int iItem)
       CAddonInstaller::Get().InstallFromZip(path);
     return true;
   }
+  if (item->GetPath() == "addons://update_all/")
+  {
+    // fire off a threaded update of all addons
+    UpdateAddons updater;
+    if (CGUIDialogBusy::Wait(&updater))
+      return Update("addons://downloading/");
+    return true;
+  }
   if (!item->m_bIsFolder)
   {
     // cancel a downloading job
index e34ac5b..71a7175 100644 (file)
@@ -200,6 +200,13 @@ 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)
+  {
+    CFileItemPtr item(new CFileItem("addons://update_all/", true));
+    item->SetLabel(g_localizeStrings.Get(24122));
+    item->SetSpecialSort(SortSpecialOnTop);
+    items.Add(item);
+  }
 
   return true;
 }