sbLocalDatabaseLibraryFactory.h
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25 */
26 
27 #ifndef __SBLOCALDATABASELIBRARYFACTORY_H__
28 #define __SBLOCALDATABASELIBRARYFACTORY_H__
29 
30 #include <sbIDatabaseQuery.h>
31 #include <sbILibraryFactory.h>
32 
33 #include <nsCOMPtr.h>
34 #include <nsHashKeys.h>
35 #include <nsInterfaceHashtable.h>
36 #include <nsIGenericFactory.h>
37 #include <nsStringGlue.h>
38 
39 #define SB_LOCALDATABASE_LIBRARYFACTORY_TYPE \
40  SB_LOCALDATABASE_LIBRARYFACTORY_DESCRIPTION
41 
42 class nsIFile;
43 class nsILocalFile;
44 class nsIPropertyBag2;
45 class nsIWeakReference;
46 class sbILibrary;
47 
49 {
50 public:
52  NS_DECL_SBILIBRARYFACTORY
53 
54  static NS_METHOD RegisterSelf(nsIComponentManager* aCompMgr,
55  nsIFile* aPath,
56  const char* aLoaderStr,
57  const char* aType,
58  const nsModuleComponentInfo *aInfo);
59 
60  already_AddRefed<nsILocalFile> GetFileForGUID(const nsAString& aGUID);
61  void GetGUIDFromFile(nsILocalFile* aFile,
62  nsAString& aGUID);
63 
64  nsresult CreateLibraryFromDatabase(nsIFile* aDatabase,
65  sbILibrary** _retval,
66  nsIPropertyBag2* aCreationParameters = nsnull,
67  nsString aResourceGUID = EmptyString());
68 
69  nsresult Init();
70 
71 private:
72  nsresult InitalizeLibrary(nsIFile* aDatabaseFile, const nsAString &aResourceGUID);
73 
74  nsresult UpdateLibrary(nsIFile* aDatabaseFile);
75 
76  nsresult SetQueryDatabaseFile(sbIDatabaseQuery* aQuery,
77  nsIFile* aDatabaseFile);
78 
79 private:
80  nsInterfaceHashtable<nsHashableHashKey, nsIWeakReference> mCreatedLibraries;
81 };
82 
83 #endif /* __SBLOCALDATABASELIBRARYFACTORY_H__ */
_updateCookies aPath
void GetGUIDFromFile(nsILocalFile *aFile, nsAString &aGUID)
Factory for new library instances.
already_AddRefed< nsILocalFile > GetFileForGUID(const nsAString &aGUID)
Media library abstraction.
Definition: sbILibrary.idl:82
NS_DECL_ISUPPORTS static NS_DECL_SBILIBRARYFACTORY NS_METHOD RegisterSelf(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *aLoaderStr, const char *aType, const nsModuleComponentInfo *aInfo)
An object responsible for executing SQL queries on the database.
nsresult CreateLibraryFromDatabase(nsIFile *aDatabase, sbILibrary **_retval, nsIPropertyBag2 *aCreationParameters=nsnull, nsString aResourceGUID=EmptyString())