changed: ScraperInUse to take the ID rather than the ScraperPtr
authorjmarshallnz <jmarshallnz@svn>
Sun, 29 Aug 2010 04:02:12 +0000 (04:02 +0000)
committerjmarshallnz <jmarshallnz@svn>
Sun, 29 Aug 2010 04:02:12 +0000 (04:02 +0000)
added: Addon::IsInUse() to check for in-use addons.

git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@33290 568bbfeb-2a22-0410-94d2-cc84cf5bfa90

xbmc/MusicDatabase.cpp
xbmc/MusicDatabase.h
xbmc/VideoDatabase.cpp
xbmc/VideoDatabase.h
xbmc/addons/Addon.h
xbmc/addons/IAddon.h
xbmc/addons/Scraper.cpp
xbmc/addons/Scraper.h
xbmc/addons/Skin.cpp
xbmc/addons/Skin.h

index 3107ecf..f7de4b7 100644 (file)
@@ -4011,15 +4011,14 @@ bool CMusicDatabase::GetScraperForPath(const CStdString& strPath, ADDON::Scraper
   return false;
 }
 
-bool CMusicDatabase::ScraperInUse(const ADDON::ScraperPtr &scraper) const
+bool CMusicDatabase::ScraperInUse(const CStdString &scraperID) const
 {
   try
   {
     if (NULL == m_pDB.get()) return false;
     if (NULL == m_pDS.get()) return false;
-    if (!scraper) return false;
 
-    CStdString sql = PrepareSQL("select count(1) from content where strScraperPath='%s'",scraper->ID().c_str());
+    CStdString sql = PrepareSQL("select count(1) from content where strScraperPath='%s'",scraperID.c_str());
     if (!m_pDS->query(sql.c_str()) || m_pDS->num_rows() == 0)
       return false;
     bool found = m_pDS->fv(0).get_asInt() > 0;
@@ -4028,7 +4027,7 @@ bool CMusicDatabase::ScraperInUse(const ADDON::ScraperPtr &scraper) const
   }
   catch (...)
   {
-    CLog::Log(LOGERROR, "%s(%s) failed", __FUNCTION__, scraper->ID().c_str());
+    CLog::Log(LOGERROR, "%s(%s) failed", __FUNCTION__, scraperID.c_str());
   }
   return false;
 }
index 72a6b39..45450ff 100644 (file)
@@ -192,10 +192,10 @@ public:
   bool GetScraperForPath(const CStdString& strPath, ADDON::ScraperPtr& info, const ADDON::TYPE &type);
 
   /*! \brief Check whether a given scraper is in use.
-   \param scraper the scraper to check for.
+   \param scraperID the scraper to check for.
    \return true if the scraper is in use, false otherwise.
    */
-  bool ScraperInUse(const ADDON::ScraperPtr &scraper) const;
+  bool ScraperInUse(const CStdString &scraperID) const;
 
   void ExportToXML(const CStdString &xmlFile, bool singleFiles = false, bool images=false, bool overwrite=false);
   void ImportFromXML(const CStdString &xmlFile);
index 3b39eab..de88ddd 100644 (file)
@@ -3181,15 +3181,14 @@ void CVideoDatabase::SetScraperForPath(const CStdString& filePath, const Scraper
   }
 }
 
-bool CVideoDatabase::ScraperInUse(const ADDON::ScraperPtr &scraper) const
+bool CVideoDatabase::ScraperInUse(const CStdString &scraperID) const
 {
   try
   {
     if (NULL == m_pDB.get()) return false;
     if (NULL == m_pDS.get()) return false;
-    if (!scraper) return false;
 
-    CStdString sql = PrepareSQL("select count(1) from path where strScraper='%s'",scraper->ID().c_str());
+    CStdString sql = PrepareSQL("select count(1) from path where strScraper='%s'", scraperID.c_str());
     if (!m_pDS->query(sql.c_str()) || m_pDS->num_rows() == 0)
       return false;
     bool found = m_pDS->fv(0).get_asInt() > 0;
@@ -3198,7 +3197,7 @@ bool CVideoDatabase::ScraperInUse(const ADDON::ScraperPtr &scraper) const
   }
   catch (...)
   {
-    CLog::Log(LOGERROR, "%s(%s) failed", __FUNCTION__, scraper->ID().c_str());
+    CLog::Log(LOGERROR, "%s(%s) failed", __FUNCTION__, scraperID.c_str());
   }
   return false;
 }
index c86bd18..6aa78c4 100644 (file)
@@ -414,10 +414,10 @@ public:
   CONTENT_TYPE GetContentForPath(const CStdString& strPath);
   
   /*! \brief Check whether a given scraper is in use.
-   \param scraper the scraper to check for.
+   \param scraperID the scraper to check for.
    \return true if the scraper is in use, false otherwise.
    */
-  bool ScraperInUse(const ADDON::ScraperPtr &scraper) const;
+  bool ScraperInUse(const CStdString &scraperID) const;
   
   // scanning hashes and paths scanned
   bool SetPathHash(const CStdString &path, const CStdString &hash);
index 709a906..eadf83c 100644 (file)
@@ -153,6 +153,7 @@ public:
   const CStdString ID() const { return m_props.id; }
   const CStdString Name() const { return m_props.name; }
   bool Enabled() const { return m_enabled; }
+  virtual bool IsInUse() const { return false; };
   const AddonVersion Version();
   const CStdString Summary() const { return m_props.summary; }
   const CStdString Description() const { return m_props.description; }
index edbfaff..c7b4248 100644 (file)
@@ -83,6 +83,7 @@ namespace ADDON
     virtual const CStdString ID() const =0;
     virtual const CStdString Name() const =0;
     virtual bool Enabled() const =0;
+    virtual bool IsInUse() const =0;
     virtual const AddonVersion Version() =0;
     virtual const CStdString Summary() const =0;
     virtual const CStdString Description() const =0;
index 9006c64..dae3c76 100644 (file)
@@ -30,6 +30,8 @@
 #include "AdvancedSettings.h"
 #include "FileItem.h"
 #include "XMLUtils.h"
+#include "MusicDatabase.h"
+#include "VideoDatabase.h"
 #include <sstream>
 
 using namespace std;
@@ -311,5 +313,22 @@ bool CScraper::Load()
   return result;
 }
 
+bool CScraper::IsInUse() const
+{
+  if (Supports(CONTENT_ALBUMS) || Supports(CONTENT_ARTISTS))
+  { // music scraper
+    CMusicDatabase db;
+    if (db.Open() && db.ScraperInUse(ID()))
+      return true;
+  }
+  else
+  { // video scraper
+    CVideoDatabase db;
+    if (db.Open() && db.ScraperInUse(ID()))
+      return true;
+  }
+  return false;
+}
+
 }; /* namespace ADDON */
 
index 186f43d..e8b0636 100644 (file)
@@ -87,6 +87,9 @@ namespace ADDON
                                 XFILE::CFileCurl& http,
                                 const std::vector<CStdString>* extras=NULL);
     CScraperParser& GetParser() { return m_parser; }
+
+    bool IsInUse() const;
+
   private:
     CScraper(const CScraper&, const AddonPtr&);
 
index 433b52e..baf154e 100644 (file)
@@ -284,4 +284,10 @@ int CSkinInfo::GetFirstWindow() const
   return startWindow;
 }
 
+bool CSkinInfo::IsInUse() const
+{
+  // Could extend this to prompt for reverting to the standard skin perhaps
+  return g_guiSettings.GetString("lookandfeel.skin") == ID();
+}
+
 } /*namespace ADDON*/
index b626296..b25e161 100644 (file)
@@ -104,6 +104,8 @@ public:
    */
   void GetSkinPaths(std::vector<CStdString> &paths) const;
 
+  bool IsInUse() const;
+
 //  static bool Check(const CStdString& strSkinDir); // checks if everything is present and accounted for without loading the skin
   static double GetMinVersion();
 protected: