aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xbmc/Application.cpp63
-rw-r--r--xbmc/Application.h1
-rw-r--r--xbmc/addons/AddonManager.cpp17
-rw-r--r--xbmc/addons/AddonManager.h3
4 files changed, 84 insertions, 0 deletions
diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp
index 63ecac13bf..e8fd212f15 100644
--- a/xbmc/Application.cpp
+++ b/xbmc/Application.cpp
@@ -3902,6 +3902,10 @@ bool CApplication::OnMessage(CGUIMessage& message)
// show info dialog about moved configuration files if needed
ShowAppMigrationMessage();
+ // offer enabling addons at kodi startup that are disabled due to
+ // e.g. os package manager installation on linux
+ ConfigureAndEnableAddons();
+
m_bInitializing = false;
if (message.GetSenderId() == WINDOW_SETTINGS_PROFILES)
@@ -4179,6 +4183,65 @@ void CApplication::ShowAppMigrationMessage()
}
}
+void CApplication::ConfigureAndEnableAddons()
+{
+ std::vector<std::shared_ptr<IAddon>>
+ disabledAddons; /*!< Installed addons, but not auto-enabled via manifest */
+
+ auto& addonMgr = CServiceBroker::GetAddonMgr();
+
+ if (addonMgr.GetDisabledAddons(disabledAddons) && !disabledAddons.empty())
+ {
+ // only look at disabled addons with disabledReason == NONE
+ // usually those are installed from package managers or manually. omit add-ons of type dependecy
+ // also try to enable add-ons with disabledReason == INCOMPATIBLE at startup
+
+ for (const auto& addon : disabledAddons)
+ {
+ if (addonMgr.IsAddonDisabledWithReason(addon->ID(), ADDON::AddonDisabledReason::INCOMPATIBLE))
+ {
+ auto addonInfo = addonMgr.GetAddonInfo(addon->ID());
+ if (addonInfo && addonMgr.IsCompatible(addonInfo))
+ {
+ CLog::Log(LOGDEBUG, "CApplication::{}: enabling the compatible version of [{}].",
+ __FUNCTION__, addon->ID());
+ addonMgr.EnableAddon(addon->ID());
+ }
+ continue;
+ }
+
+ if (addonMgr.IsAddonDisabledExcept(addon->ID(), ADDON::AddonDisabledReason::NONE) ||
+ CAddonType::IsDependencyType(addon->MainType()))
+ {
+ continue;
+ }
+
+ if (HELPERS::ShowYesNoDialogLines(CVariant{24039}, // Disabled add-ons
+ CVariant{24059}, // Would you like to enable this add-on?
+ CVariant{addon->Name()}) == DialogResponse::YES)
+ {
+ if (addon->HasSettings())
+ {
+ if (CGUIDialogAddonSettings::ShowForAddon(addon))
+ {
+ // only enable if settings dialog hasn't been cancelled
+ addonMgr.EnableAddon(addon->ID());
+ }
+ }
+ else
+ {
+ addonMgr.EnableAddon(addon->ID());
+ }
+ }
+ else
+ {
+ // user chose not to configure/enable so we're not asking anymore
+ addonMgr.UpdateDisabledReason(addon->ID(), ADDON::AddonDisabledReason::USER);
+ }
+ }
+ }
+}
+
void CApplication::Process()
{
// dispatch the messages generated by python or other threads to the current window
diff --git a/xbmc/Application.h b/xbmc/Application.h
index 050f11afc0..5460794eab 100644
--- a/xbmc/Application.h
+++ b/xbmc/Application.h
@@ -207,6 +207,7 @@ public:
void ActivateScreenSaver(bool forceType = false);
void CloseNetworkShares();
+ void ConfigureAndEnableAddons();
void ShowAppMigrationMessage();
void Process() override;
void ProcessSlow();
diff --git a/xbmc/addons/AddonManager.cpp b/xbmc/addons/AddonManager.cpp
index 0e4098e7d2..5c415f41f4 100644
--- a/xbmc/addons/AddonManager.cpp
+++ b/xbmc/addons/AddonManager.cpp
@@ -795,6 +795,22 @@ bool CAddonMgr::DisableAddon(const std::string& id, AddonDisabledReason disabled
return true;
}
+bool CAddonMgr::UpdateDisabledReason(const std::string& id, AddonDisabledReason newDisabledReason)
+{
+ CSingleLock lock(m_critSection);
+ if (!IsAddonDisabled(id))
+ return false;
+ if (!m_database.DisableAddon(id, newDisabledReason))
+ return false;
+
+ m_disabled[id] = newDisabledReason;
+
+ // success
+ CLog::Log(LOGDEBUG, "CAddonMgr: DisabledReason for {} updated to {}", id,
+ static_cast<int>(newDisabledReason));
+ return true;
+}
+
bool CAddonMgr::EnableSingle(const std::string& id)
{
CSingleLock lock(m_critSection);
@@ -810,6 +826,7 @@ bool CAddonMgr::EnableSingle(const std::string& id)
{
CLog::Log(LOGERROR, "Add-on '%s' is not compatible with Kodi", addon->ID().c_str());
CServiceBroker::GetEventLog().AddWithNotification(EventPtr(new CNotificationEvent(addon->Name(), 24152, EventLevel::Error)));
+ UpdateDisabledReason(addon->ID(), AddonDisabledReason::INCOMPATIBLE);
return false;
}
diff --git a/xbmc/addons/AddonManager.h b/xbmc/addons/AddonManager.h
index 346ae3ef96..cf40fa7c00 100644
--- a/xbmc/addons/AddonManager.h
+++ b/xbmc/addons/AddonManager.h
@@ -226,6 +226,9 @@ namespace ADDON
/*! \brief Disable an addon. Returns true on success, false on failure. */
bool DisableAddon(const std::string& ID, AddonDisabledReason disabledReason);
+ /*! \brief Updates reason for a disabled addon. Returns true on success, false on failure. */
+ bool UpdateDisabledReason(const std::string& id, AddonDisabledReason newDisabledReason);
+
/*! \brief Enable an addon. Returns true on success, false on failure. */
bool EnableAddon(const std::string& ID);