30 #ifndef __SB_LIBRARYMANAGER_H__
31 #define __SB_LIBRARYMANAGER_H__
33 #include <nsIObserver.h>
34 #include <nsIThreadManager.h>
35 #include <sbILibrary.h>
36 #include <sbILibraryManager.h>
37 #include <sbILibraryUtils.h>
39 #include <nsCategoryCache.h>
40 #include <nsAutoLock.h>
42 #include <nsHashKeys.h>
43 #include <nsClassHashtable.h>
44 #include <nsInterfaceHashtable.h>
46 #include <sbILibraryLoader.h>
50 #define SB_PREFBRANCH_LIBRARY "songbird.library."
52 #define SB_PREF_MAIN_LIBRARY SB_PREFBRANCH_LIBRARY "main"
53 #define SB_PREF_WEB_LIBRARY SB_PREFBRANCH_LIBRARY "web"
54 #define SB_PREF_PLAYQUEUE_LIBRARY SB_PREFBRANCH_LIBRARY "playqueue"
56 class nsIComponentManager;
58 class nsIRDFDataSource;
63 struct nsModuleComponentInfo;
70 struct sbLibraryInfo {
71 sbLibraryInfo(PRBool aLoadAtStartup = PR_FALSE)
73 loadAtStartup(aLoadAtStartup)
76 nsCOMPtr<sbILibrary> library;
88 NS_DECL_SBILIBRARYMANAGER
89 NS_DECL_SBILIBRARYUTILS
93 static NS_METHOD
RegisterSelf(nsIComponentManager* aCompMgr,
95 const char* aLoaderStr,
97 const nsModuleComponentInfo *aInfo);
104 static PLDHashOperator PR_CALLBACK
105 AddLibrariesToCOMArrayCallback(nsStringHashKey::KeyType aKey,
106 sbLibraryInfo* aEntry,
109 static PLDHashOperator PR_CALLBACK
110 AddStartupLibrariesToCOMArrayCallback(nsStringHashKey::KeyType aKey,
111 sbLibraryInfo* aEntry,
114 static PLDHashOperator PR_CALLBACK
115 AddListenersToCOMArrayCallback(nsISupportsHashKey::KeyType aKey,
119 static PLDHashOperator PR_CALLBACK
120 AssertAllLibrariesCallback(nsStringHashKey::KeyType aKey,
121 sbLibraryInfo* aEntry,
124 static nsresult AssertLibrary(nsIRDFDataSource* aDataSource,
127 static nsresult UnassertLibrary(nsIRDFDataSource* aDataSource,
130 nsresult GenerateDataSource();
132 void NotifyListenersLibraryRegistered(
sbILibrary* aLibrary);
134 void NotifyListenersLibraryUnregistered(
sbILibrary* aLibrary);
136 void InvokeLoaders();
138 nsresult SetLibraryLoadsAtStartupInternal(
sbILibrary* aLibrary,
139 PRBool aLoadAtStartup,
140 sbLibraryInfo** aInfo);
146 nsClassHashtable<nsStringHashKey, sbLibraryInfo> mLibraryTable;
152 nsCOMPtr<nsIRDFDataSource> mDataSource;
157 nsInterfaceHashtable<nsISupportsHashKey, sbILibraryManagerListener> mListeners;
162 nsCategoryCache<sbILibraryLoader> mLoaderCache;
164 nsCOMPtr<sbILibraryLoader> mCurrentLoader;
168 nsCOMPtr<nsIThreadManager> mThreadManager;
Manages the lifecycle of libraries in the system.
NS_DECL_ISUPPORTS NS_DECL_NSIOBSERVER NS_DECL_SBILIBRARYMANAGER NS_DECL_SBILIBRARYUTILS sbLibraryManager()
Factory for new library instances.
nsresult Init()
Register with the Observer Service.
Manages the lifecycle of libraries in the system.
Media library abstraction.
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
static NS_METHOD RegisterSelf(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *aLoaderStr, const char *aType, const nsModuleComponentInfo *aInfo)
Set of library utilities.