6 #include <nsISimpleEnumerator.h>
8 #include <nsStringGlue.h>
9 #include <sbIFileMetadataService.h>
10 #include <nsServiceManagerUtils.h>
11 #include <sbIJobProgress.h>
12 #include <nsIMutableArray.h>
13 #include <nsComponentManagerUtils.h>
14 #include <nsArrayUtils.h>
15 #include <sbILibrary.h>
18 NS_ENSURE_ARG_POINTER(aImageLocation);
19 NS_ENSURE_ARG_POINTER(aMediaItem);
22 nsCAutoString imageFileURISpec;
23 rv = aImageLocation->GetSpec(imageFileURISpec);
24 if (NS_SUCCEEDED(rv)) {
25 rv = aMediaItem->SetProperty(
27 NS_ConvertUTF8toUTF16(imageFileURISpec));
28 NS_ENSURE_SUCCESS(rv, rv);
35 NS_ENSURE_ARG_POINTER(aMediaItems);
36 NS_ENSURE_ARG_POINTER(aMediaItems);
39 nsCOMPtr<nsISimpleEnumerator> listEnum;
40 rv = aMediaItems->Enumerate(getter_AddRefs(listEnum));
41 NS_ENSURE_SUCCESS(rv, rv);
43 while (NS_SUCCEEDED(listEnum->HasMoreElements(&hasMore)) && hasMore) {
44 nsCOMPtr<nsISupports>
next;
45 if (NS_SUCCEEDED(listEnum->GetNext(getter_AddRefs(next))) && next) {
46 nsCOMPtr<sbIMediaItem> mediaItem(do_QueryInterface(next));
48 NS_ENSURE_SUCCESS(rv, rv);
56 NS_ENSURE_ARG_POINTER(aMediaItems);
60 rv = aMediaItems->GetLength(&numItems);
61 NS_ENSURE_SUCCESS(rv, rv);
64 nsCOMPtr<sbIMediaItem> mediaItem = do_QueryElementAt(aMediaItems, 0, &rv);
65 NS_ENSURE_SUCCESS(rv, rv);
66 nsCOMPtr<sbILibrary> library;
67 rv = mediaItem->GetLibrary(getter_AddRefs(library));
68 NS_ENSURE_SUCCESS(rv, rv);
69 nsAutoString dontWriteMetadata;
70 rv = library->GetProperty
73 NS_ENSURE_SUCCESS(rv, rv);
74 if (dontWriteMetadata.Equals(NS_LITERAL_STRING(
"1")))
77 nsTArray<nsString> propArray;
80 return NS_ERROR_OUT_OF_MEMORY;
83 nsCOMPtr<nsIStringEnumerator> propsToWrite =
85 NS_ENSURE_TRUE(propsToWrite, NS_ERROR_OUT_OF_MEMORY);
87 nsCOMPtr<sbIFileMetadataService> metadataService =
88 do_GetService(
"@songbirdnest.com/Songbird/FileMetadataService;1", &rv );
89 NS_ENSURE_SUCCESS(rv, rv);
91 nsCOMPtr<sbIJobProgress> job;
92 rv = metadataService->Write(aMediaItems, propsToWrite, getter_AddRefs(job));
93 NS_ENSURE_SUCCESS(rv, rv);
#define SB_PROPERTY_DONT_WRITE_METADATA
nsresult SetItemsArtwork(nsIURI *aImageLocation, nsIArray *aMediaItems)
StringArrayEnumerator prototype hasMore
nsresult WriteImageMetadata(nsIArray *aMediaItems)
nsresult SetItemArtwork(nsIURI *aImageLocation, sbIMediaItem *aMediaItem)
#define SB_PROPERTY_PRIMARYIMAGEURL