Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[addons] add support for 'never' updating or checking for updates #4287

Merged
merged 7 commits into from
Jun 10, 2014
7 changes: 3 additions & 4 deletions addons/skin.confluence/720p/AddonBrowser.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -98,10 +98,9 @@
<align>center</align> <align>center</align>
<aligny>center</aligny> <aligny>center</aligny>
</control> </control>
<control type="radiobutton" id="5"> <control type="button" id="5">
<description>Enable auto-updates</description> <description>addon-updates</description>
<left>0</left> <textwidth>235</textwidth>
<top>130</top>
<include>ButtonCommonValues</include> <include>ButtonCommonValues</include>
<label>24063</label> <label>24063</label>
</control> </control>
Expand Down
60 changes: 57 additions & 3 deletions language/English/strings.po
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4914,7 +4914,25 @@ msgctxt "#12395"
msgid "Battery level" msgid "Battery level"
msgstr "" msgstr ""


#empty strings from id 12396 to 12599 #. Used on the button to toggle add-on update mode in the Add-on Manager.
#: xbmc/addons/GUIWindowAddonBrowser.cpp
msgctxt "#12396"
msgid "Auto updates: On"
msgstr ""

#. Used on the button to toggle add-on update mode in the Add-on Manager.
#: xbmc/addons/GUIWindowAddonBrowser.cpp
msgctxt "#12397"
msgid "Auto updates: Notify"
msgstr ""

#. Used on the button to toggle add-on update mode in the Add-on Manager.
#: xbmc/addons/GUIWindowAddonBrowser.cpp
msgctxt "#12398"
msgid "Auto updates: Never"
msgstr ""

#empty strings from id 12399 to 12599


#: xbmc/guilib/WindowIDs.h #: xbmc/guilib/WindowIDs.h
msgctxt "#12600" msgctxt "#12600"
Expand Down Expand Up @@ -12101,7 +12119,19 @@ msgctxt "#24054"
msgid "Changelog" msgid "Changelog"
msgstr "" 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" msgctxt "#24059"
msgid "Would you like to enable this Add-on?" msgid "Would you like to enable this Add-on?"
Expand Down Expand Up @@ -12191,7 +12221,31 @@ msgctxt "#24080"
msgid "Try to reconnect?" msgid "Try to reconnect?"
msgstr "" msgstr ""


#empty strings from id 24081 to 24088 #. The label in the add-ons manager for helper add-ons
#: xbmc/addons/addon.cpp
msgctxt "#24081"
msgid "Helper Add-ons"
msgstr ""

#. The label in the add-ons manager for add-on libraries
#: xbmc/addons/addon.cpp
msgctxt "#24082"
msgid "Add-on libraries"
msgstr ""

#. The label in the add-ons manager for information libraries
#: xbmc/addons/addon.cpp
msgctxt "#24083"
msgid "Information libraries"
msgstr ""

#. The label in the add-ons manager for visualisation libraries
#: xbmc/addons/addon.cpp
msgctxt "#24084"
msgid "Visualisation libraries"
msgstr ""

#empty strings from id 24085 to 24088


msgctxt "#24089" msgctxt "#24089"
msgid "Add-on restarts" msgid "Add-on restarts"
Expand Down
12 changes: 10 additions & 2 deletions system/settings/settings.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2981,9 +2981,17 @@
</category> </category>
<category id="general" label="" help="36412"> <category id="general" label="" help="36412">
<group id="1"> <group id="1">
<setting id="general.addonautoupdate" type="boolean" label="0" help="36413"> <setting id="general.addonupdates" type="integer" label="0" help="36413">
<level>4</level> <level>4</level>
<default>true</default> <default>0</default>
<constraints>
<options>
<option label="12396">0</option> <!-- AUTO_UPDATES_ON -->
<option label="12397">1</option> <!-- AUTO_UPDATES_NOTIFY -->
<option label="12398">2</option> <!-- AUTO_UPDATES_NEVER -->
</options>
</constraints>
<control type="spinner" format="string" />
</setting> </setting>
<setting id="general.addonnotifications" type="boolean" label="0" help="36414"> <setting id="general.addonnotifications" type="boolean" label="0" help="36414">
<level>4</level> <level>4</level>
Expand Down
3 changes: 2 additions & 1 deletion xbmc/Application.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5188,7 +5188,8 @@ void CApplication::ProcessSlow()
g_RemoteControl.Initialize(); g_RemoteControl.Initialize();
#endif #endif


if (!m_pPlayer->IsPlayingVideo()) if (!m_pPlayer->IsPlayingVideo() &&
CSettings::Get().GetInt("general.addonupdates") != AUTO_UPDATES_NEVER)
CAddonInstaller::Get().UpdateRepos(); CAddonInstaller::Get().UpdateRepos();


CAEFactory::GarbageCollect(); CAEFactory::GarbageCollect();
Expand Down
8 changes: 4 additions & 4 deletions xbmc/addons/Addon.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ static const TypeMapping types[] =
{"xbmc.metadata.scraper.movies", ADDON_SCRAPER_MOVIES, 24007, "DefaultAddonMovieInfo.png" }, {"xbmc.metadata.scraper.movies", ADDON_SCRAPER_MOVIES, 24007, "DefaultAddonMovieInfo.png" },
{"xbmc.metadata.scraper.musicvideos", ADDON_SCRAPER_MUSICVIDEOS, 24015, "DefaultAddonMusicVideoInfo.png" }, {"xbmc.metadata.scraper.musicvideos", ADDON_SCRAPER_MUSICVIDEOS, 24015, "DefaultAddonMusicVideoInfo.png" },
{"xbmc.metadata.scraper.tvshows", ADDON_SCRAPER_TVSHOWS, 24014, "DefaultAddonTvInfo.png" }, {"xbmc.metadata.scraper.tvshows", ADDON_SCRAPER_TVSHOWS, 24014, "DefaultAddonTvInfo.png" },
{"xbmc.metadata.scraper.library", ADDON_SCRAPER_LIBRARY, 0, "" }, {"xbmc.metadata.scraper.library", ADDON_SCRAPER_LIBRARY, 24083, "" },
{"xbmc.ui.screensaver", ADDON_SCREENSAVER, 24008, "DefaultAddonScreensaver.png" }, {"xbmc.ui.screensaver", ADDON_SCREENSAVER, 24008, "DefaultAddonScreensaver.png" },
{"xbmc.player.musicviz", ADDON_VIZ, 24010, "DefaultAddonVisualization.png" }, {"xbmc.player.musicviz", ADDON_VIZ, 24010, "DefaultAddonVisualization.png" },
{"visualization-library", ADDON_VIZ_LIBRARY, 0, "" }, {"visualization-library", ADDON_VIZ_LIBRARY, 24084, "" },
{"xbmc.python.pluginsource", ADDON_PLUGIN, 24005, "" }, {"xbmc.python.pluginsource", ADDON_PLUGIN, 24005, "" },
{"xbmc.python.script", ADDON_SCRIPT, 24009, "" }, {"xbmc.python.script", ADDON_SCRIPT, 24009, "" },
{"xbmc.python.weather", ADDON_SCRIPT_WEATHER, 24027, "DefaultAddonWeather.png" }, {"xbmc.python.weather", ADDON_SCRIPT_WEATHER, 24027, "DefaultAddonWeather.png" },
{"xbmc.python.lyrics", ADDON_SCRIPT_LYRICS, 24013, "DefaultAddonLyrics.png" }, {"xbmc.python.lyrics", ADDON_SCRIPT_LYRICS, 24013, "DefaultAddonLyrics.png" },
{"xbmc.python.library", ADDON_SCRIPT_LIBRARY, 24014, "" }, {"xbmc.python.library", ADDON_SCRIPT_LIBRARY, 24081, "" },
{"xbmc.python.module", ADDON_SCRIPT_MODULE, 0, "" }, {"xbmc.python.module", ADDON_SCRIPT_MODULE, 24082, "" },
{"xbmc.subtitle.module", ADDON_SUBTITLE_MODULE, 24012, "DefaultAddonSubtitles.png" }, {"xbmc.subtitle.module", ADDON_SUBTITLE_MODULE, 24012, "DefaultAddonSubtitles.png" },
{"xbmc.gui.skin", ADDON_SKIN, 166, "DefaultAddonSkin.png" }, {"xbmc.gui.skin", ADDON_SKIN, 166, "DefaultAddonSkin.png" },
{"xbmc.gui.webinterface", ADDON_WEB_INTERFACE, 199, "DefaultAddonWebSkin.png" }, {"xbmc.gui.webinterface", ADDON_WEB_INTERFACE, 199, "DefaultAddonWebSkin.png" },
Expand Down
18 changes: 17 additions & 1 deletion xbmc/addons/AddonInstaller.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -357,6 +357,22 @@ bool CAddonInstaller::CheckDependencies(const AddonPtr &addon,
return true; return true;
} }


CDateTime CAddonInstaller::LastRepoUpdate() const
{
CDateTime update;
VECADDONS addons;
CAddonMgr::Get().GetAddons(ADDON_REPOSITORY,addons);
for (unsigned int i=0;i<addons.size();++i)
{
CAddonDatabase database;
database.Open();
CDateTime lastUpdate = database.GetRepoTimestamp(addons[i]->ID());
if (lastUpdate.IsValid() && lastUpdate > update)
update = lastUpdate;
}
return update;
}

void CAddonInstaller::UpdateRepos(bool force, bool wait) void CAddonInstaller::UpdateRepos(bool force, bool wait)
{ {
CSingleLock lock(m_critSection); CSingleLock lock(m_critSection);
Expand Down Expand Up @@ -715,7 +731,7 @@ bool CAddonInstallJob::Install(const CStdString &installFrom, const AddonPtr& re


void CAddonInstallJob::OnPostInstall(bool reloadAddon) void CAddonInstallJob::OnPostInstall(bool reloadAddon)
{ {
if (m_addon->Type() < ADDON_VIZ_LIBRARY && CSettings::Get().GetBool("general.addonnotifications")) if (CSettings::Get().GetBool("general.addonnotifications"))
{ {
CGUIDialogKaiToast::QueueNotification(m_addon->Icon(), CGUIDialogKaiToast::QueueNotification(m_addon->Icon(),
m_addon->Name(), m_addon->Name(),
Expand Down
11 changes: 11 additions & 0 deletions xbmc/addons/AddonInstaller.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@


class CAddonDatabase; class CAddonDatabase;


enum {
AUTO_UPDATES_ON = 0,
AUTO_UPDATES_NOTIFY,
AUTO_UPDATES_NEVER,
AUTO_UPDATES_MAX
};

class CAddonInstaller : public IJobCallback class CAddonInstaller : public IJobCallback
{ {
public: public:
Expand Down Expand Up @@ -89,6 +96,10 @@ class CAddonInstaller : public IJobCallback
*/ */
bool HasJob(const CStdString& ID) const; bool HasJob(const CStdString& ID) const;


/*! \brief Fetch the last repository update time.
\return the last time a repository was updated.
*/
CDateTime LastRepoUpdate() const;
void UpdateRepos(bool force = false, bool wait = false); void UpdateRepos(bool force = false, bool wait = false);


void OnJobComplete(unsigned int jobID, bool success, CJob* job); void OnJobComplete(unsigned int jobID, bool success, CJob* job);
Expand Down
4 changes: 2 additions & 2 deletions xbmc/addons/AddonManager.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ bool CAddonMgr::HasAddons(const TYPE &type, bool enabled /*= true*/)


bool CAddonMgr::GetAllAddons(VECADDONS &addons, bool enabled /*= true*/, bool allowRepos /* = false */) bool CAddonMgr::GetAllAddons(VECADDONS &addons, bool enabled /*= true*/, bool allowRepos /* = false */)
{ {
for (int i = ADDON_UNKNOWN+1; i < ADDON_VIZ_LIBRARY; ++i) for (int i = ADDON_UNKNOWN+1; i < ADDON_MAX; ++i)
{ {
if (!allowRepos && ADDON_REPOSITORY == (TYPE)i) if (!allowRepos && ADDON_REPOSITORY == (TYPE)i)
continue; continue;
Expand Down Expand Up @@ -375,7 +375,7 @@ bool CAddonMgr::ReloadSettings(const CStdString &id)
bool CAddonMgr::GetAllOutdatedAddons(VECADDONS &addons, bool getLocalVersion /*= false*/) bool CAddonMgr::GetAllOutdatedAddons(VECADDONS &addons, bool getLocalVersion /*= false*/)
{ {
CSingleLock lock(m_critSection); CSingleLock lock(m_critSection);
for (int i = ADDON_UNKNOWN+1; i < ADDON_VIZ_LIBRARY; ++i) for (int i = ADDON_UNKNOWN+1; i < ADDON_MAX; ++i)
{ {
VECADDONS temp; VECADDONS temp;
if (CAddonMgr::Get().GetAddons((TYPE)i, temp, true)) if (CAddonMgr::Get().GetAddons((TYPE)i, temp, true))
Expand Down
2 changes: 1 addition & 1 deletion xbmc/addons/GUIDialogAddonInfo.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ bool CGUIDialogAddonInfo::SetItem(const CFileItemPtr& item)
else if (m_localAddon) // sanity else if (m_localAddon) // sanity
database.GetRepository(m_localAddon->ID(), addons); database.GetRepository(m_localAddon->ID(), addons);
int tot=0; int tot=0;
for (int i = ADDON_UNKNOWN+1;i<ADDON_VIZ_LIBRARY;++i) for (int i = ADDON_UNKNOWN+1;i<ADDON_MAX;++i)
{ {
int num=0; int num=0;
for (unsigned int j=0;j<addons.size();++j) for (unsigned int j=0;j<addons.size();++j)
Expand Down
40 changes: 30 additions & 10 deletions xbmc/addons/GUIViewStateAddonBrowser.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -26,17 +26,26 @@
#include "view/ViewState.h" #include "view/ViewState.h"
#include "addons/Addon.h" #include "addons/Addon.h"
#include "addons/AddonManager.h" #include "addons/AddonManager.h"
#include "addons/AddonInstaller.h"
#include "AddonDatabase.h" #include "AddonDatabase.h"
#include "utils/StringUtils.h"


using namespace XFILE; using namespace XFILE;
using namespace ADDON; using namespace ADDON;


CGUIViewStateAddonBrowser::CGUIViewStateAddonBrowser(const CFileItemList& items) : CGUIViewState(items) CGUIViewStateAddonBrowser::CGUIViewStateAddonBrowser(const CFileItemList& items) : CGUIViewState(items)
{ {
AddSortMethod(SortByLabel, SortAttributeIgnoreFolders, 551, LABEL_MASKS("%L", "%I", "%L", "")); // Filename, Size | Foldername, empty if (items.IsVirtualDirectoryRoot())
AddSortMethod(SortByDate, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // Filename, Date | Foldername, Date {
SetSortMethod(SortByLabel, SortAttributeIgnoreFolders); AddSortMethod(SortByNone, 551, LABEL_MASKS("%F", "", "%L", ""));

SetSortMethod(SortByNone);
}
else
{
AddSortMethod(SortByLabel, SortAttributeIgnoreFolders, 551, LABEL_MASKS("%L", "%I", "%L", "")); // Filename, Size | Foldername, empty
AddSortMethod(SortByDate, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // Filename, Date | Foldername, Date
SetSortMethod(SortByLabel, SortAttributeIgnoreFolders);
}
SetViewAsControl(DEFAULT_VIEW_AUTO); SetViewAsControl(DEFAULT_VIEW_AUTO);


SetSortOrder(SortOrderAscending); SetSortOrder(SortOrderAscending);
Expand All @@ -57,12 +66,23 @@ VECSOURCES& CGUIViewStateAddonBrowser::GetSources()
{ {
m_sources.clear(); m_sources.clear();


// we always have some enabled addons { // 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; CMediaSource share;
share.strPath = "addons://enabled/"; share.strPath = "addons://outdated/";
share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL; share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
share.strName = g_localizeStrings.Get(24062); share.strName = g_localizeStrings.Get(24043); // "Available updates"
m_sources.push_back(share); m_sources.push_back(share);
} }
CAddonDatabase db; CAddonDatabase db;
Expand All @@ -74,12 +94,12 @@ VECSOURCES& CGUIViewStateAddonBrowser::GetSources()
share.strName = g_localizeStrings.Get(24039); share.strName = g_localizeStrings.Get(24039);
m_sources.push_back(share); m_sources.push_back(share);
} }
if (CAddonMgr::Get().HasOutdatedAddons()) // we always have some enabled addons
{ {
CMediaSource share; CMediaSource share;
share.strPath = "addons://outdated/"; share.strPath = "addons://enabled/";
share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL; share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
share.strName = g_localizeStrings.Get(24043); share.strName = g_localizeStrings.Get(24062);
m_sources.push_back(share); m_sources.push_back(share);
} }
if (CAddonMgr::Get().HasAddons(ADDON_REPOSITORY,true)) if (CAddonMgr::Get().HasAddons(ADDON_REPOSITORY,true))
Expand Down
29 changes: 27 additions & 2 deletions xbmc/addons/GUIWindowAddonBrowser.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ bool CGUIWindowAddonBrowser::OnMessage(CGUIMessage& message)
int iControl = message.GetSenderId(); int iControl = message.GetSenderId();
if (iControl == CONTROL_AUTOUPDATE) if (iControl == CONTROL_AUTOUPDATE)
{ {
CSettings::Get().ToggleBool("general.addonautoupdate"); const CGUIControl *control = GetControl(CONTROL_AUTOUPDATE);
if (control && control->GetControlType() == CGUIControl::GUICONTROL_BUTTON)
CSettings::Get().SetInt("general.addonupdates", (CSettings::Get().GetInt("general.addonupdates")+1) % AUTO_UPDATES_MAX);
else
CSettings::Get().SetInt("general.addonupdates", (CSettings::Get().GetInt("general.addonupdates") == 0) ? 1 : 0);
UpdateButtons();
return true; return true;
} }
else if (iControl == CONTROL_SHUTUP) else if (iControl == CONTROL_SHUTUP)
Expand Down Expand Up @@ -271,7 +276,27 @@ bool CGUIWindowAddonBrowser::OnClick(int iItem)


void CGUIWindowAddonBrowser::UpdateButtons() void CGUIWindowAddonBrowser::UpdateButtons()
{ {
SET_CONTROL_SELECTED(GetID(),CONTROL_AUTOUPDATE, CSettings::Get().GetBool("general.addonautoupdate")); const CGUIControl *control = GetControl(CONTROL_AUTOUPDATE);
if (control && control->GetControlType() == CGUIControl::GUICONTROL_BUTTON)
{ // set label
CSettingInt *setting = (CSettingInt *)CSettings::Get().GetSetting("general.addonupdates");
if (setting)
{
const StaticIntegerSettingOptions& options = setting->GetOptions();
for (StaticIntegerSettingOptions::const_iterator it = options.begin(); it != options.end(); ++it)
{
if (it->second == setting->GetValue())
{
SET_CONTROL_LABEL(CONTROL_AUTOUPDATE, it->first);
break;
}
}
}
}
else
{ // old skin with toggle button - set on if auto updates are on
SET_CONTROL_SELECTED(GetID(),CONTROL_AUTOUPDATE, CSettings::Get().GetInt("general.addonupdates") == AUTO_UPDATES_ON);
}
SET_CONTROL_SELECTED(GetID(),CONTROL_SHUTUP, CSettings::Get().GetBool("general.addonnotifications")); SET_CONTROL_SELECTED(GetID(),CONTROL_SHUTUP, CSettings::Get().GetBool("general.addonnotifications"));
SET_CONTROL_SELECTED(GetID(),CONTROL_FOREIGNFILTER, CSettings::Get().GetBool("general.addonforeignfilter")); SET_CONTROL_SELECTED(GetID(),CONTROL_FOREIGNFILTER, CSettings::Get().GetBool("general.addonforeignfilter"));
CGUIMediaWindow::UpdateButtons(); CGUIMediaWindow::UpdateButtons();
Expand Down
5 changes: 3 additions & 2 deletions xbmc/addons/IAddon.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ namespace ADDON
ADDON_AUDIO, ADDON_AUDIO,
ADDON_IMAGE, ADDON_IMAGE,
ADDON_EXECUTABLE, ADDON_EXECUTABLE,
ADDON_VIZ_LIBRARY, // add noninstallable after this and installable before ADDON_VIZ_LIBRARY,
ADDON_SCRAPER_LIBRARY, ADDON_SCRAPER_LIBRARY,
ADDON_SCRIPT_LIBRARY, ADDON_SCRIPT_LIBRARY,
ADDON_SCRIPT_MODULE ADDON_SCRIPT_MODULE,
ADDON_MAX
} TYPE; } TYPE;


class IAddon; class IAddon;
Expand Down
2 changes: 1 addition & 1 deletion xbmc/addons/Repository.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ bool CRepositoryUpdateJob::DoWork()
!database.IsAddonBlacklisted(newAddon->ID(),newAddon->Version().asString()) && !database.IsAddonBlacklisted(newAddon->ID(),newAddon->Version().asString()) &&
deps_met) deps_met)
{ {
if (CSettings::Get().GetBool("general.addonautoupdate") || addon->Type() >= ADDON_VIZ_LIBRARY) if (CSettings::Get().GetInt("general.addonupdates") == AUTO_UPDATES_ON)
{ {
string referer; string referer;
if (URIUtils::IsInternetStream(newAddon->Path())) if (URIUtils::IsInternetStream(newAddon->Path()))
Expand Down
Loading