[addons] prompt if an add-on is used by another and the user attempts to disable it.
authorJonathan Marshall <jmarshall@xbmc.org>
Sat, 9 Nov 2013 01:20:46 +0000 (14:20 +1300)
committerJonathan Marshall <jmarshall@xbmc.org>
Mon, 11 Nov 2013 07:37:40 +0000 (20:37 +1300)
language/English/strings.po
xbmc/addons/GUIDialogAddonInfo.cpp
xbmc/addons/GUIDialogAddonInfo.h

index 3743327..6c84e46 100755 (executable)
@@ -11891,7 +11891,12 @@ msgctxt "#24090"
 msgid "Lock Add-on manager"
 msgstr ""
 
-#empty strings from id 24091 to 24093
+#: xbmc\addons\GUIDialogAddonInfo.cpp
+msgctxt "#24091"
+msgid "This Add-on cannot be disabled"
+msgstr ""
+
+#empty strings from id 24092 to 24093
 
 #: xbmc/addons/guidialogaddoninfo.cpp
 msgctxt "#24094"
index 5cf977c..75f07ec 100644 (file)
@@ -181,12 +181,11 @@ void CGUIDialogAddonInfo::OnInstall()
   Close();
 }
 
-void CGUIDialogAddonInfo::OnUninstall()
+bool CGUIDialogAddonInfo::PromptIfDependency(int heading, int line2)
 {
-  if (!m_localAddon.get())
-    return;
+  if (!m_localAddon)
+    return false;
 
-  // ensure the addon is not a dependency of other installed addons
   VECADDONS addons;
   CStdStringArray deps;
   CAddonMgr::Get().GetAllAddons(addons);
@@ -202,9 +201,20 @@ void CGUIDialogAddonInfo::OnUninstall()
     CStdString strLine0, strLine1;
     StringUtils::JoinString(deps, ", ", strLine1);
     strLine0.Format(g_localizeStrings.Get(24046), m_localAddon->Name().c_str());
-    CGUIDialogOK::ShowAndGetInput(24037, strLine0, strLine1, 24047);
-    return;
+    CGUIDialogOK::ShowAndGetInput(heading, strLine0, strLine1, line2);
+    return true;
   }
+  return false;
+}
+
+void CGUIDialogAddonInfo::OnUninstall()
+{
+  if (!m_localAddon.get())
+    return;
+
+  // ensure the addon is not a dependency of other installed addons
+  if (PromptIfDependency(24037, 24047))
+    return;
 
   // prompt user to be sure
   if (CGUIDialogYesNo::ShowAndGetInput(24037, 750, 0, 0))
@@ -224,6 +234,9 @@ void CGUIDialogAddonInfo::OnEnable(bool enable)
   if (!m_localAddon.get())
     return;
 
+  if (!enable && PromptIfDependency(24075, 24091))
+    return;
+
   CAddonMgr::Get().DisableAddon(m_localAddon->ID(), !enable);
   SetItem(m_item);
   UpdateControls();
index c5dab50..a46eb72 100644 (file)
@@ -59,6 +59,13 @@ protected:
   void OnChangeLog();
   void OnRollback();
 
+  /*! \brief check if the add-on is a dependency of others, and if so prompt the user.
+   \param heading the label for the heading of the prompt dialog
+   \param line2 the action that could not be completed.
+   \return true if prompted, false otherwise.
+   */
+  bool PromptIfDependency(int heading, int line2);
+
   CFileItemPtr m_item;
   ADDON::AddonPtr m_addon;
   ADDON::AddonPtr m_localAddon;