diff options
author | jmarshallnz <jmarshallnz@svn> | 2010-08-29 04:02:12 +0000 |
---|---|---|
committer | jmarshallnz <jmarshallnz@svn> | 2010-08-29 04:02:12 +0000 |
commit | 0a8239234ff6b4de6e05137c4844632388db993f (patch) | |
tree | 6ac558016535bd50144090837a4d8f44841d27a6 | |
parent | 4e6ee0a1f9856fdc880703fb12faddc0e0c562d3 (diff) |
changed: ScraperInUse to take the ID rather than the ScraperPtr
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
-rw-r--r-- | xbmc/MusicDatabase.cpp | 7 | ||||
-rw-r--r-- | xbmc/MusicDatabase.h | 4 | ||||
-rw-r--r-- | xbmc/VideoDatabase.cpp | 7 | ||||
-rw-r--r-- | xbmc/VideoDatabase.h | 4 | ||||
-rw-r--r-- | xbmc/addons/Addon.h | 1 | ||||
-rw-r--r-- | xbmc/addons/IAddon.h | 1 | ||||
-rw-r--r-- | xbmc/addons/Scraper.cpp | 19 | ||||
-rw-r--r-- | xbmc/addons/Scraper.h | 3 | ||||
-rw-r--r-- | xbmc/addons/Skin.cpp | 6 | ||||
-rw-r--r-- | xbmc/addons/Skin.h | 2 |
10 files changed, 42 insertions, 12 deletions
diff --git a/xbmc/MusicDatabase.cpp b/xbmc/MusicDatabase.cpp index 3107ecff97..f7de4b76a5 100644 --- a/xbmc/MusicDatabase.cpp +++ b/xbmc/MusicDatabase.cpp @@ -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; } diff --git a/xbmc/MusicDatabase.h b/xbmc/MusicDatabase.h index 72a6b3908e..45450ff190 100644 --- a/xbmc/MusicDatabase.h +++ b/xbmc/MusicDatabase.h @@ -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); diff --git a/xbmc/VideoDatabase.cpp b/xbmc/VideoDatabase.cpp index 3b39eaba10..de88ddd541 100644 --- a/xbmc/VideoDatabase.cpp +++ b/xbmc/VideoDatabase.cpp @@ -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; } diff --git a/xbmc/VideoDatabase.h b/xbmc/VideoDatabase.h index c86bd1897c..6aa78c4f31 100644 --- a/xbmc/VideoDatabase.h +++ b/xbmc/VideoDatabase.h @@ -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); diff --git a/xbmc/addons/Addon.h b/xbmc/addons/Addon.h index 709a90624d..eadf83ca16 100644 --- a/xbmc/addons/Addon.h +++ b/xbmc/addons/Addon.h @@ -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; } diff --git a/xbmc/addons/IAddon.h b/xbmc/addons/IAddon.h index edbfafff62..c7b424830a 100644 --- a/xbmc/addons/IAddon.h +++ b/xbmc/addons/IAddon.h @@ -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; diff --git a/xbmc/addons/Scraper.cpp b/xbmc/addons/Scraper.cpp index 9006c64a78..dae3c760d4 100644 --- a/xbmc/addons/Scraper.cpp +++ b/xbmc/addons/Scraper.cpp @@ -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 */ diff --git a/xbmc/addons/Scraper.h b/xbmc/addons/Scraper.h index 186f43d7d2..e8b063677b 100644 --- a/xbmc/addons/Scraper.h +++ b/xbmc/addons/Scraper.h @@ -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&); diff --git a/xbmc/addons/Skin.cpp b/xbmc/addons/Skin.cpp index 433b52ebd9..baf154e0db 100644 --- a/xbmc/addons/Skin.cpp +++ b/xbmc/addons/Skin.cpp @@ -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*/ diff --git a/xbmc/addons/Skin.h b/xbmc/addons/Skin.h index b626296b6e..b25e161196 100644 --- a/xbmc/addons/Skin.h +++ b/xbmc/addons/Skin.h @@ -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: |