50 #include <sbIMediaItemDownloader.h>
54 #include <nsComponentManagerUtils.h>
56 #include <nsIObserverService.h>
74 static PRLogModuleInfo* gMediaItemDownloadServiceLog = nsnull;
75 #define TRACE(args) PR_LOG(gMediaItemDownloadServiceLog, PR_LOG_DEBUG, args)
76 #define LOG(args) PR_LOG(gMediaItemDownloadServiceLog, PR_LOG_WARN, args)
78 #define __FUNCTION__ __PRETTY_FUNCTION__
119 TRACE((
"%s 0x%08x 0x%08x", __FUNCTION__, aMediaItem, aTargetLibrary));
123 NS_ENSURE_ARG_POINTER(aMediaItem);
124 NS_ENSURE_ARG_POINTER(retval);
130 nsCOMPtr<sbIMediaItemDownloader> highestVoteDownloader;
132 PRUint32 downloaderCount = mDownloaderList.Length();
133 for (PRUint32
i = 0;
i < downloaderCount; ++
i) {
137 rv = downloader->Vote(aMediaItem, aTargetLibrary, &vote);
138 NS_ENSURE_SUCCESS(rv, rv);
141 if (vote > highestVote) {
142 highestVoteDownloader = downloader;
148 highestVoteDownloader.forget(retval);
170 sbMediaItemDownloadService::Observe(
nsISupports* aSubject,
172 const PRUnichar*
aData)
175 TRACE((
"%s[%.8x] \"%s\" \"%s\"", __FUNCTION__,
178 NS_ConvertUTF16toUTF8(aData).
get()));
181 TRACE((
"%s[%.8x] \"%s\"", __FUNCTION__,
this, aTopic));
187 if (!strcmp(aTopic,
"app-startup")) {
188 nsCOMPtr<nsIObserverService> obsSvc = do_GetService(
189 "@mozilla.org/observer-service;1", &rv);
190 NS_ENSURE_SUCCESS(rv, rv);
192 rv = obsSvc->AddObserver(
this,
193 "profile-after-change",
195 NS_ENSURE_SUCCESS(rv, rv);
196 }
else if (!strcmp(aTopic,
"profile-after-change")) {
199 NS_ENSURE_SUCCESS(rv, rv);
202 nsCOMPtr<nsIObserverService> obsSvc = do_GetService(
203 "@mozilla.org/observer-service;1", &rv);
204 NS_ENSURE_SUCCESS(rv, rv);
206 rv = obsSvc->RemoveObserver(
this,
207 "profile-after-change");
208 NS_ENSURE_SUCCESS(rv, rv);
232 if (!gMediaItemDownloadServiceLog) {
233 gMediaItemDownloadServiceLog =
234 PR_NewLogModule(
"sbMediaItemDownloadService");
238 TRACE((
"%s[%.8x]", __FUNCTION__,
this));
249 TRACE((
"%s[%.8x]", __FUNCTION__,
this));
263 (nsIComponentManager* aCompMgr,
265 const char* aLoaderStr,
267 const nsModuleComponentInfo* aInfo)
272 nsCOMPtr<nsICategoryManager> categoryManager =
273 do_GetService(NS_CATEGORYMANAGER_CONTRACTID,
275 NS_ENSURE_SUCCESS(rv, rv);
278 rv = categoryManager->AddCategoryEntry
285 NS_ENSURE_SUCCESS(rv, rv);
293 (nsIComponentManager* aCompMgr,
295 const char* aLoaderStr,
296 const nsModuleComponentInfo* aInfo)
301 nsCOMPtr<nsICategoryManager> categoryManager =
302 do_GetService(NS_CATEGORYMANAGER_CONTRACTID,
304 NS_ENSURE_SUCCESS(rv, rv);
307 rv = categoryManager->DeleteCategoryEntry
311 NS_ENSURE_SUCCESS(rv, rv);
329 sbMediaItemDownloadService::Initialize()
331 TRACE((
"%s[%.8x]", __FUNCTION__,
this));
342 NS_ENSURE_SUCCESS(rv, rv);
345 nsTArray<nsCString> entryValueList;
348 NS_ENSURE_SUCCESS(rv, rv);
351 for (PRUint32
i = 0;
i < entryValueList.Length(); ++
i) {
353 nsCOMPtr<sbIMediaItemDownloader>
354 downloader = do_CreateInstance(entryValueList[
i].
get(), &rv);
355 NS_ENSURE_SUCCESS(rv, rv);
358 nsCOMPtr<sbIMediaItemDownloader>*
359 appendedElement = mDownloaderList.AppendElement(downloader);
360 NS_ENSURE_TRUE(appendedElement, NS_ERROR_OUT_OF_MEMORY);
364 mInitialized = PR_TRUE;
367 rv = mServiceManager->SetServiceReady
369 NS_ENSURE_SUCCESS(rv, rv);
381 sbMediaItemDownloadService::Finalize()
383 TRACE((
"%s[%.8x]", __FUNCTION__,
this));
391 mDownloaderList.Clear();
394 mInitialized = PR_FALSE;
Songbird XPCOM Utilities Definitions.
#define SB_SERVICE_MANAGER_CONTRACTID
Media library abstraction.
static nsresult SB_GetCategoryEntryValues(const char *aCategory, nsTArray< nsCString > &aEntryValueList)
_getSelectedPageStyle s i
_updateTextAndScrollDataForFrame aData