sbAlbumArtModule.cpp
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 :miv */
3 /*
4 //
5 // BEGIN SONGBIRD GPL
6 //
7 // This file is part of the Songbird web player.
8 //
9 // Copyright(c) 2005-2008 POTI, Inc.
10 // http://songbirdnest.com
11 //
12 // This file may be licensed under the terms of of the
13 // GNU General Public License Version 2 (the "GPL").
14 //
15 // Software distributed under the License is distributed
16 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
17 // express or implied. See the GPL for the specific language
18 // governing rights and limitations.
19 //
20 // You should have received a copy of the GPL along with this
21 // program. If not, go to http://www.gnu.org/licenses/gpl.html
22 // or write to the Free Software Foundation, Inc.,
23 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 // END SONGBIRD GPL
26 //
27 */
28 
29 //------------------------------------------------------------------------------
30 //------------------------------------------------------------------------------
31 //
32 // Songbird album art components module.
33 //
34 //------------------------------------------------------------------------------
35 //------------------------------------------------------------------------------
36 
42 //------------------------------------------------------------------------------
43 //
44 // Songbird album art components module imported services.
45 //
46 //------------------------------------------------------------------------------
47 
48 // Local imports.
49 #include "sbAlbumArtFetcherSet.h"
50 #include "sbAlbumArtScanner.h"
51 #include "sbAlbumArtService.h"
52 #include "sbFileAlbumArtFetcher.h"
54 
55 // Mozilla imports.
56 #include <nsICategoryManager.h>
57 #include <nsIGenericFactory.h>
58 #include <nsServiceManagerUtils.h>
59 
60 
61 //------------------------------------------------------------------------------
62 //
63 // Songbird album art service.
64 //
65 //------------------------------------------------------------------------------
66 
68 
69 
70 
74 static NS_METHOD
75 sbAlbumArtServiceRegister(nsIComponentManager* aCompMgr,
76  nsIFile* aPath,
77  const char* aLoaderStr,
78  const char* aType,
79  const nsModuleComponentInfo* aInfo)
80 {
81  nsresult rv;
82 
83  // Get the category manager.
84  nsCOMPtr<nsICategoryManager> categoryManager =
85  do_GetService(NS_CATEGORYMANAGER_CONTRACTID,
86  &rv);
87  NS_ENSURE_SUCCESS(rv, rv);
88 
89  // Add self to the app-startup category.
90  rv = categoryManager->AddCategoryEntry
91  ("app-startup",
94  PR_TRUE,
95  PR_TRUE,
96  nsnull);
97  NS_ENSURE_SUCCESS(rv, rv);
98 
99  return NS_OK;
100 }
101 
102 
107 static NS_METHOD
108 sbAlbumArtServiceUnregister(nsIComponentManager* aCompMgr,
109  nsIFile* aPath,
110  const char* aLoaderStr,
111  const nsModuleComponentInfo* aInfo)
112 {
113  nsresult rv;
114 
115  // Get the category manager.
116  nsCOMPtr<nsICategoryManager> categoryManager =
117  do_GetService(NS_CATEGORYMANAGER_CONTRACTID,
118  &rv);
119  NS_ENSURE_SUCCESS(rv, rv);
120 
121  // Delete self from the app-startup category.
122  rv = categoryManager->DeleteCategoryEntry("app-startup",
124  PR_TRUE);
125  NS_ENSURE_SUCCESS(rv, rv);
126 
127  return NS_OK;
128 }
129 
130 
131 //------------------------------------------------------------------------------
132 //
133 // Songbird album art scanner component
134 //
135 //------------------------------------------------------------------------------
136 
137 // Construct the sbAlbumArtScanner object and call its Initialize method.
139 
140 
141 //------------------------------------------------------------------------------
142 //
143 // Songbird album art fetcher set component.
144 //
145 //------------------------------------------------------------------------------
146 
147 // Construct the sbAlbumArtFetcherSet object and call its Initialize method.
149 
150 
151 //------------------------------------------------------------------------------
152 //
153 // Songbird local file album art fetcher component.
154 //
155 //------------------------------------------------------------------------------
156 
157 // Construct the sbFileAlbumArtFetcher object and call its Initialize method.
159 
160 
165 static NS_METHOD
166 sbFileAlbumArtFetcherRegister(nsIComponentManager* aCompMgr,
167  nsIFile* aPath,
168  const char* aLoaderStr,
169  const char* aType,
170  const nsModuleComponentInfo* aInfo)
171 {
172  nsresult rv;
173 
174  // Get the category manager.
175  nsCOMPtr<nsICategoryManager> categoryManager =
176  do_GetService(NS_CATEGORYMANAGER_CONTRACTID,
177  &rv);
178  NS_ENSURE_SUCCESS(rv, rv);
179 
180  // Add self to the album art fetcher category.
181  rv = categoryManager->AddCategoryEntry
185  PR_TRUE,
186  PR_TRUE,
187  nsnull);
188  NS_ENSURE_SUCCESS(rv, rv);
189 
190  return NS_OK;
191 }
192 
193 
198 static NS_METHOD
199 sbFileAlbumArtFetcherUnregister(nsIComponentManager* aCompMgr,
200  nsIFile* aPath,
201  const char* aLoaderStr,
202  const nsModuleComponentInfo* aInfo)
203 {
204  nsresult rv;
205 
206  // Get the category manager.
207  nsCOMPtr<nsICategoryManager> categoryManager =
208  do_GetService(NS_CATEGORYMANAGER_CONTRACTID,
209  &rv);
210  NS_ENSURE_SUCCESS(rv, rv);
211 
212  // Delete self from the album art fetcher category.
213  rv = categoryManager->DeleteCategoryEntry(SB_ALBUM_ART_FETCHER_CATEGORY,
215  PR_TRUE);
216  NS_ENSURE_SUCCESS(rv, rv);
217 
218  return NS_OK;
219 }
220 
221 //------------------------------------------------------------------------------
222 //
223 // Songbird metadata album art fetcher component.
224 //
225 //------------------------------------------------------------------------------
226 
227 // Construct the sbMetadataAlbumArtFetcher object and call its Initialize
228 // method.
230 
231 
232 
236 static NS_METHOD
237 sbMetadataAlbumArtFetcherRegister(nsIComponentManager* aCompMgr,
238  nsIFile* aPath,
239  const char* aLoaderStr,
240  const char* aType,
241  const nsModuleComponentInfo* aInfo)
242 {
243  nsresult rv;
244 
245  // Get the category manager.
246  nsCOMPtr<nsICategoryManager> categoryManager =
247  do_GetService(NS_CATEGORYMANAGER_CONTRACTID,
248  &rv);
249  NS_ENSURE_SUCCESS(rv, rv);
250 
251  // Add self to the album art fetcher category.
252  rv = categoryManager->AddCategoryEntry
256  PR_TRUE,
257  PR_TRUE,
258  nsnull);
259  NS_ENSURE_SUCCESS(rv, rv);
260 
261  return NS_OK;
262 }
263 
264 
269 static NS_METHOD
270 sbMetadataAlbumArtFetcherUnregister(nsIComponentManager* aCompMgr,
271  nsIFile* aPath,
272  const char* aLoaderStr,
273  const nsModuleComponentInfo* aInfo)
274 {
275  nsresult rv;
276 
277  // Get the category manager.
278  nsCOMPtr<nsICategoryManager> categoryManager =
279  do_GetService(NS_CATEGORYMANAGER_CONTRACTID,
280  &rv);
281  NS_ENSURE_SUCCESS(rv, rv);
282 
283  // Delete self from the album art fetcher category.
284  rv = categoryManager->DeleteCategoryEntry
287  PR_TRUE);
288  NS_ENSURE_SUCCESS(rv, rv);
289 
290  return NS_OK;
291 }
292 
293 
294 //------------------------------------------------------------------------------
295 //
296 // Songbird album art components module registration services.
297 //
298 //------------------------------------------------------------------------------
299 
300 // Module component information.
301 static nsModuleComponentInfo sbAlbumArtComponents[] =
302 {
303  // Album art service component info.
304  {
308  sbAlbumArtServiceConstructor,
311  },
312 
313  // Album art scanner component info.
314  {
318  sbAlbumArtScannerConstructor
319  },
320 
321  // Album art fetcher set component info.
322  {
326  sbAlbumArtFetcherSetConstructor
327  },
328 
329  // Local file album art fetcher component info.
330  {
334  sbFileAlbumArtFetcherConstructor,
337  },
338  // Metadata album art fetcher component info.
339  {
343  sbMetadataAlbumArtFetcherConstructor,
346  }
347 };
348 
349 // NSGetModule
350 NS_IMPL_NSGETMODULE(sbAlbumArtModule, sbAlbumArtComponents)
351 
static NS_METHOD sbFileAlbumArtFetcherRegister(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *aLoaderStr, const char *aType, const nsModuleComponentInfo *aInfo)
return NS_OK
_updateCookies aPath
Songbird Album Art Fetcher Set Definitions.
static NS_METHOD sbFileAlbumArtFetcherUnregister(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *aLoaderStr, const nsModuleComponentInfo *aInfo)
#define SB_METADATAALBUMARTFETCHER_CONTRACTID
#define SB_ALBUMARTSERVICE_CLASSNAME
#define SB_ALBUMARTFETCHERSET_CLASSNAME
static NS_METHOD sbMetadataAlbumArtFetcherRegister(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *aLoaderStr, const char *aType, const nsModuleComponentInfo *aInfo)
#define SB_ALBUMARTSERVICE_CONTRACTID
static NS_METHOD sbAlbumArtServiceRegister(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *aLoaderStr, const char *aType, const nsModuleComponentInfo *aInfo)
#define SB_FILEALBUMARTFETCHER_CONTRACTID
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(sbMockDeviceFirmwareHandler, Init)
#define SB_ALBUMARTFETCHERSET_CID
#define SB_ALBUMARTSERVICE_CID
#define SB_ALBUMARTSCANNER_CID
#define SB_FILEALBUMARTFETCHER_CID
static NS_METHOD sbAlbumArtServiceUnregister(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *aLoaderStr, const nsModuleComponentInfo *aInfo)
#define SB_ALBUMARTFETCHERSET_CONTRACTID
#define SB_METADATAALBUMARTFETCHER_CID
#define SB_FILEALBUMARTFETCHER_CLASSNAME
Songbird Album Art Scanner Definitions.
static nsModuleComponentInfo sbAlbumArtComponents[]
#define SB_ALBUMARTSCANNER_CONTRACTID
#define SB_ALBUM_ART_FETCHER_CATEGORY
NS_IMPL_NSGETMODULE(SongbirdIdentityServiceComponent, sbIdentityServiceComponent)
Songbird Metadata Album Art Fetcher Definitions.
#define SB_METADATAALBUMARTFETCHER_CLASSNAME
NS_GENERIC_FACTORY_CONSTRUCTOR(sbMediaSniffer)
Songbird Album Art Service Definitions.
static NS_METHOD sbMetadataAlbumArtFetcherUnregister(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *aLoaderStr, const nsModuleComponentInfo *aInfo)
Songbird Local File Album Art Fetcher Definitions.
#define SB_ALBUMARTSCANNER_CLASSNAME