2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
23 #include "dbwrappers/Database.h"
24 #include "TextureCacheJob.h"
25 #include "playlists/SmartPlayList.h"
29 class CTextureRule : public CDatabaseQueryRule
33 virtual ~CTextureRule() {};
35 static void GetAvailableFields(std::vector<std::string> &fieldList);
37 virtual int TranslateField(const char *field) const;
38 virtual CStdString TranslateField(int field) const;
39 virtual CStdString GetField(int field, const CStdString& type) const;
40 virtual FIELD_TYPE GetFieldType(int field) const;
43 class CTextureDatabase : public CDatabase, public IDatabaseQueryRuleFactory
47 virtual ~CTextureDatabase();
50 bool GetCachedTexture(const CStdString &originalURL, CTextureDetails &details);
51 bool AddCachedTexture(const CStdString &originalURL, const CTextureDetails &details);
52 bool SetCachedTextureValid(const CStdString &originalURL, bool updateable);
53 bool ClearCachedTexture(const CStdString &originalURL, CStdString &cacheFile);
54 bool ClearCachedTexture(int textureID, CStdString &cacheFile);
55 bool IncrementUseCount(const CTextureDetails &details);
57 /*! \brief Invalidate a previously cached texture
58 Invalidates the texture hash, and sets the texture update time to the current time so that
59 next texture load it will be re-cached.
60 \param url texture path
62 bool InvalidateCachedTexture(const CStdString &originalURL);
64 /*! \brief Get a texture associated with the given path
65 Used for retrieval of previously discovered images to save
66 stat() on the filesystem all the time
67 \param url path that may be associated with a texture
68 \param type type of image to look for
69 \return URL of the texture associated with the given path
71 CStdString GetTextureForPath(const CStdString &url, const CStdString &type);
73 /*! \brief Set a texture associated with the given path
74 Used for setting of previously discovered images to save
75 stat() on the filesystem all the time. Should be used to set
76 the actual image path, not the cached image path (the image will be
78 \param url path that was used to find the texture
79 \param type type of image to associate
80 \param texture URL of the texture to associate with the path
82 void SetTextureForPath(const CStdString &url, const CStdString &type, const CStdString &texture);
84 /*! \brief Clear a texture associated with the given path
85 \param url path that was used to find the texture
86 \param type type of image to associate
87 \param texture URL of the texture to associate with the path
88 \sa GetTextureForPath, SetTextureForPath
90 void ClearTextureForPath(const CStdString &url, const CStdString &type);
92 bool GetTextures(CVariant &items, const Filter &filter);
95 virtual CDatabaseQueryRule *CreateRule() const;
96 virtual CDatabaseQueryRuleCombination *CreateCombination() const;
98 /*! \brief retrieve a hash for the given url
99 Computes a hash of the current url to use for lookups in the database
100 \param url url to hash
101 \return a hash for this url
103 unsigned int GetURLHash(const CStdString &url) const;
105 virtual bool CreateTables();
106 virtual bool UpdateOldVersion(int version);
107 virtual int GetMinVersion() const { return 13; };
108 const char *GetBaseDBName() const { return "Textures"; };