34 #include <nsIDOMParser.h>
35 #include <nsIFileURL.h>
36 #include <nsIMutableArray.h>
37 #include <nsIPropertyBag2.h>
40 #include <nsIVariant.h>
41 #include <nsIPrefService.h>
42 #include <nsIPrefBranch.h>
43 #include <nsIProxyObjectManager.h>
45 #include <nsAppDirectoryServiceDefs.h>
46 #include <nsArrayUtils.h>
47 #include <nsAutoLock.h>
48 #include <nsAutoPtr.h>
49 #include <nsComponentManagerUtils.h>
51 #include <nsDirectoryServiceUtils.h>
53 #include <nsNetUtil.h>
54 #include <nsServiceManagerUtils.h>
55 #include <nsThreadUtils.h>
56 #include <nsIDOMDocument.h>
57 #include <nsIDOMElement.h>
58 #include <nsIDOMNodeList.h>
59 #include <nsIDOMWindow.h>
60 #include <nsIPromptService.h>
61 #include <nsIScriptSecurityManager.h>
62 #include <nsISupportsPrimitives.h>
63 #include <nsIWritablePropertyBag.h>
64 #include <nsIWritablePropertyBag2.h>
65 #include <nsIXMLHttpRequest.h>
67 #include <sbIDeviceContent.h>
68 #include <sbIDeviceCapabilities.h>
69 #include <sbIDeviceInfoRegistrar.h>
70 #include <sbIDeviceLibraryMediaSyncSettings.h>
71 #include <sbIDeviceLibrarySyncDiff.h>
72 #include <sbIDeviceLibrarySyncSettings.h>
73 #include <sbIDeviceEvent.h>
74 #include <sbIDeviceHelper.h>
75 #include <sbIDeviceManager.h>
76 #include <sbIDeviceProperties.h>
77 #include <sbIDownloadDevice.h>
78 #include <sbIJobCancelable.h>
79 #include <sbILibrary.h>
80 #include <sbILibraryDiffingService.h>
81 #include <sbILibraryUtils.h>
82 #include <sbILocalDatabaseSmartMediaList.h>
83 #include <sbIMediacoreManager.h>
84 #include <sbIMediacorePlaybackControl.h>
85 #include <sbIMediacoreSequencer.h>
86 #include <sbIMediacoreStatus.h>
87 #include <sbIMediaFileManager.h>
88 #include <sbIMediaInspector.h>
89 #include <sbIMediaItem.h>
90 #include <sbIMediaItemController.h>
91 #include <sbIMediaItemDownloader.h>
92 #include <sbIMediaItemDownloadJob.h>
93 #include <sbIMediaItemDownloadService.h>
94 #include <sbIMediaList.h>
95 #include <sbIOrderableMediaList.h>
96 #include <sbIPrompter.h>
97 #include <sbIPropertyManager.h>
98 #include <sbIPropertyUnitConverter.h>
99 #include <nsISupportsPrimitives.h>
100 #include <sbITranscodeManager.h>
101 #include <sbITranscodeAlbumArt.h>
102 #include <sbITranscodingConfigurator.h>
108 #include <sbFileUtils.h>
146 PRLogModuleInfo* gBaseDeviceLog = nsnull;
147 #define LOG(args) PR_LOG(gBaseDeviceLog, PR_LOG_WARN, args)
148 #define TRACE(args) PR_LOG(gBaseDeviceLog, PR_LOG_DEBUG, args)
150 #define __FUNCTION__ __PRETTY_FUNCTION__
153 #define LOG(args) do{ } while(0)
154 #define TRACE(args) do { } while(0)
158 #define PREF_DEVICE_PREFERENCES_BRANCH "songbird.device."
159 #define PREF_DEVICE_LIBRARY_BASE "library."
160 #define PREF_WARNING "warning."
161 #define PREF_ORGANIZE_PREFIX "media_management.library."
162 #define PREF_ORGANIZE_ENABLED "media_management.library.enabled"
163 #define PREF_ORGANIZE_DIR_FORMAT "media_management.library.format.dir"
164 #define PREF_ORGANIZE_FILE_FORMAT "media_management.library.format.file"
165 #define SB_PROPERTY_UILIMITTYPE "http://songbirdnest.com/data/1.0#uiLimitType"
166 #define RANDOM_LISTNAME "device.error.not_enough_freespace.random_playlist_name"
169 #define PREF_ORGANIZE_DIR_FORMAT_DEFAULT \
170 SB_PROPERTY_ARTISTNAME "," FILE_PATH_SEPARATOR "," SB_PROPERTY_ALBUMNAME
172 #define BATCH_TIMEOUT 200
173 #define BYTES_PER_10MB (10 * 1000 * 1000)
187 TRACE((
"%s", __FUNCTION__));
188 NS_ENSURE_ARG_POINTER(aDevice);
189 NS_ENSURE_ARG_POINTER(aProperties);
191 nsCOMPtr<sbIDeviceProperties> deviceProperties;
192 nsresult rv = aDevice->GetProperties(getter_AddRefs(deviceProperties));
193 NS_ENSURE_SUCCESS(rv, rv);
195 rv = deviceProperties->GetProperties(aProperties);
196 NS_ENSURE_SUCCESS(rv, rv);
204 nsIWritablePropertyBag ** aProperties)
206 NS_ENSURE_ARG_POINTER(aDevice);
207 NS_ENSURE_ARG_POINTER(aProperties);
212 nsCOMPtr<nsIPropertyBag2> roDeviceProperties;
214 NS_ENSURE_SUCCESS(rv, rv);
216 return CallQueryInterface(roDeviceProperties, aProperties);
226 NS_DECL_SBIMEDIALISTENUMERATIONLISTENER
237 NS_ENSURE_ARG_POINTER(_retval);
242 NS_IMETHODIMP MediaListListenerAttachingEnumerator::OnEnumeratedItem(
sbIMediaList*,
246 NS_ENSURE_ARG_POINTER(aItem);
247 NS_ENSURE_ARG_POINTER(_retval);
248 NS_ENSURE_TRUE(mDevice, NS_ERROR_NOT_INITIALIZED);
252 nsCOMPtr<sbIMediaList> list(do_QueryInterface(aItem, &rv));
253 NS_ENSURE_SUCCESS(rv, rv);
256 NS_ENSURE_SUCCESS(rv, rv);
263 NS_IMETHODIMP MediaListListenerAttachingEnumerator::OnEnumerationEnd(
sbIMediaList*,
274 NS_DECL_SBIMEDIALISTENUMERATIONLISTENER
276 PRBool mHideMediaLists;
277 nsString mHideMediaListsStringValue;
285 : mHideMediaLists(aHideMediaLists)
287 mHideMediaListsStringValue = (mHideMediaLists == PR_TRUE) ?
288 NS_LITERAL_STRING(
"1") :
289 NS_LITERAL_STRING(
"0");
292 NS_IMETHODIMP ShowMediaListEnumerator::OnEnumerationBegin(
sbIMediaList*,
295 NS_ENSURE_ARG_POINTER(_retval);
300 NS_IMETHODIMP ShowMediaListEnumerator::OnEnumeratedItem(
sbIMediaList*,
304 NS_ENSURE_ARG_POINTER(aItem);
305 NS_ENSURE_ARG_POINTER(_retval);
308 mHideMediaListsStringValue);
309 NS_ENSURE_SUCCESS(rv, rv);
316 NS_IMETHODIMP ShowMediaListEnumerator::OnEnumerationEnd(
sbIMediaList*,
327 PRUint32 aOtherIndex,
334 request->
item = aItem;
335 request->
list = aList;
336 request->
index = aIndex;
341 nsCOMPtr<sbIMediaItem> localItem = do_QueryInterface(aItem, &rv);
344 nsString contentType;
345 localItem->GetContentType(contentType);
347 if (contentType.EqualsLiteral(
"audio")) {
350 else if (contentType.EqualsLiteral(
"video")) {
353 else if (contentType.EqualsLiteral(
"image")) {
382 nsCOMPtr<sbILibrary> libTest = do_QueryInterface(list);
383 return libTest ? PR_FALSE : PR_TRUE;
387 transcodeProfile(nsnull),
388 contentSrcSet(PR_FALSE),
389 destinationMediaPresent(PR_FALSE),
390 destinationCompatibility(COMPAT_SUPPORTED),
397 NS_IF_RELEASE(transcodeProfile);
419 if (!gBaseDeviceLog) {
420 gBaseDeviceLog = PR_NewLogModule(
"sbBaseDevice" );
424 #if defined(__GNUC__) && !defined(DEBUG)
425 PRBool __attribute__((unused)) success;
430 mStateLock = nsAutoLock::NewLock(__FILE__
"::mStateLock");
431 NS_ASSERTION(
mStateLock,
"Failed to allocate state lock");
440 __FILE__
"::mConnectLock");
441 NS_ASSERTION(
mConnectLock,
"Failed to allocate connection lock");
444 mVolumeLock = nsAutoLock::NewLock(
"sbBaseDevice::mVolumeLock");
445 NS_ASSERTION(
mVolumeLock,
"Failed to allocate volume lock");
449 NS_ASSERTION(success,
"Failed to initialize track source table");
453 NS_ASSERTION(success,
"Failed to initialize volume GUID table");
456 NS_ASSERTION(success,
"Failed to initialize volume library GUID table");
460 NS_ASSERTION(success,
"Failed to initialize organize prefs hashtable");
463 NS_ASSERTION(success,
"Failed to initialize list listener hashtable");
523 if (rv == NS_ERROR_NOT_AVAILABLE) {
524 NS_WARNING(
"Attempting to disconnect twice");
527 NS_ENSURE_SUCCESS(rv, rv);
534 nsIPropertyBag2 *aRequestParameters)
536 nsRefPtr<TransferRequest> transferRequest;
539 getter_AddRefs(transferRequest));
540 NS_ENSURE_SUCCESS(rv, rv);
543 NS_ENSURE_SUCCESS(rv, rv);
553 nsCOMPtr<sbIDeviceContent>
content;
554 rv = GetContent(getter_AddRefs(content));
555 NS_ENSURE_SUCCESS(rv, rv);
557 nsCOMPtr<nsIArray> libraries;
558 rv = content->GetLibraries(getter_AddRefs(libraries));
559 NS_ENSURE_SUCCESS(rv, rv);
561 PRUint32 libraryCount;
562 rv = libraries->GetLength(&libraryCount);
563 NS_ENSURE_SUCCESS(rv, rv);
565 for (PRUint32 index = 0; index < libraryCount; ++index) {
566 nsCOMPtr<sbIDeviceLibrary> deviceLib =
567 do_QueryElementAt(libraries, index, &rv);
568 NS_ENSURE_SUCCESS(rv, rv);
570 rv = deviceLib->Sync();
571 NS_ENSURE_SUCCESS(rv, rv);
581 PRUint32 aOtherIndex,
584 NS_ENSURE_TRUE(aType != 0, NS_ERROR_INVALID_ARG);
594 NS_ENSURE_TRUE(req, NS_ERROR_OUT_OF_MEMORY);
597 NS_ENSURE_SUCCESS(rv, rv);
618 NS_ENSURE_ARG_POINTER(aRequest);
619 NS_ENSURE_ARG_POINTER(aTemporaryFileFactory);
625 nsCOMPtr<sbITemporaryFileFactory>
627 if (!temporaryFileFactory) {
630 NS_ENSURE_SUCCESS(rv, rv);
635 temporaryFileFactory.forget(aTemporaryFileFactory);
644 nsAString
const & aMessage,
649 NS_ASSERTION(aDevice,
"aDevice null in DispatchDownloadError");
653 errorInfo[
"message"] = nsString(aMessage);
654 NS_ENSURE_SUCCESS(errorInfo.
rv(), errorInfo.
rv());
655 errorInfo[
"item"] = aItem;
656 NS_ENSURE_SUCCESS(errorInfo.rv(), errorInfo.rv());
662 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"Failed to dispatch download error");
676 PRUint32 aBatchCount,
683 mDownloadJob(nsnull),
684 mItem(aRequest->item)
692 if (mDevice && mItem) {
693 nsString errorMessage;
694 nsCOMPtr<nsIStringEnumerator> errorEnumerator;
697 rv = mDownloadJob->GetErrorCount(&errors);
698 if (NS_SUCCEEDED(rv) && errors) {
699 rv = mDownloadJob->GetErrorMessages(getter_AddRefs(errorEnumerator));
700 if (NS_SUCCEEDED(rv)) {
702 rv = errorEnumerator->HasMore(&more);
703 if (NS_SUCCEEDED(rv) && more) {
705 errorEnumerator->GetNext(message);
706 if (!errorMessage.IsEmpty()) {
707 errorMessage.Append(NS_LITERAL_STRING(
"\n"));
709 errorMessage.Append(message);
715 if (errorMessage.IsEmpty()) {
717 errorMessage = bundle.
Get(
"device.error.download",
718 "Download of media failed.");
730 mDownloadJob = aDownloadJob;
743 if (NS_SUCCEEDED(aResult)) {
752 nsCOMPtr<sbIMediaItemDownloadJob> mDownloadJob;
759 PRUint32 aBatchCount,
763 NS_ENSURE_ARG_POINTER(aRequest);
764 NS_ENSURE_ARG_POINTER(aDeviceStatusHelper);
777 nsRefPtr<sbBaseDeviceVolume> volume;
778 nsCOMPtr<sbIDeviceLibrary> deviceLibrary;
781 NS_ENSURE_SUCCESS(rv, rv);
782 rv = volume->GetDeviceLibrary(getter_AddRefs(deviceLibrary));
783 NS_ENSURE_SUCCESS(rv, rv);
786 nsCOMPtr<sbIMediaItemDownloadService> downloadService =
787 do_GetService(
"@songbirdnest.com/Songbird/MediaItemDownloadService;1",
789 NS_ENSURE_SUCCESS(rv, rv);
793 nsCOMPtr<sbIMediaItemDownloader> downloader;
794 rv = downloadService->GetDownloader(aRequest->
item,
796 getter_AddRefs(downloader));
797 NS_ENSURE_SUCCESS(rv, rv);
810 nsCOMPtr<sbIMediaItemDownloadJob> downloadJob;
811 rv = downloader->CreateDownloadJob(aRequest->
item,
813 getter_AddRefs(downloadJob));
814 NS_ENSURE_SUCCESS(rv, rv);
819 nsCOMPtr<sbITemporaryFileFactory> temporaryFileFactory;
821 getter_AddRefs(temporaryFileFactory));
822 NS_ENSURE_SUCCESS(rv, rv);
823 rv = downloadJob->SetTemporaryFileFactory(temporaryFileFactory);
824 NS_ENSURE_SUCCESS(rv, rv);
827 nsCOMPtr<sbIJobProgress>
829 NS_ENSURE_SUCCESS(rv, rv);
832 nsCOMPtr<sbIJobCancelable> cancel = do_QueryInterface(downloadJobProgress);
833 sbAutoJobCancel autoCancel(cancel);
838 nsRefPtr<sbDeviceProgressListener>
listener;
841 aDeviceStatusHelper);
842 NS_ENSURE_SUCCESS(rv, rv);
843 rv = downloadJobProgress->AddJobProgressListener(listener);
844 NS_ENSURE_SUCCESS(rv, rv);
847 rv = downloadJob->Start();
848 NS_ENSURE_SUCCESS(rv, rv);
851 PRBool isComplete = PR_FALSE;
852 while (!isComplete) {
854 nsAutoMonitor monitor(stopWaitMonitor);
862 isComplete = listener->IsComplete();
874 nsCOMPtr<nsIStringEnumerator> errorMessages;
875 rv = downloadJob->GetErrorMessages(getter_AddRefs(errorMessages));
876 NS_ENSURE_SUCCESS(rv, rv);
879 rv = errorMessages->HasMore(&hasMore);
880 NS_ENSURE_SUCCESS(rv, rv);
884 errorMessages = nsnull;
885 autoComplete.
SetResult(NS_ERROR_FAILURE);
886 return NS_ERROR_FAILURE;
891 rv = downloadJob->GetDownloadedFile(getter_AddRefs(aRequest->
downloadedFile));
892 NS_ENSURE_SUCCESS(rv, rv);
896 rv = downloadJob->GetProperties(getter_AddRefs(properties));
897 NS_ENSURE_SUCCESS(rv, rv);
900 rv = aRequest->
item->SetProperties(properties);
901 NS_ENSURE_SUCCESS(rv, rv);
905 nsCOMPtr<nsIURI> downloadedFileURI;
907 getter_AddRefs(downloadedFileURI));
908 NS_ENSURE_SUCCESS(rv, rv);
910 NS_ENSURE_SUCCESS(rv, rv);
919 const nsAString & aPrefName,
920 nsIVariant **_retval)
922 NS_ENSURE_ARG_POINTER(aPrefBranch);
923 NS_ENSURE_ARG_POINTER(_retval);
924 NS_ENSURE_FALSE(aPrefName.IsEmpty(), NS_ERROR_INVALID_ARG);
927 NS_ConvertUTF16toUTF8 prefNameUTF8(aPrefName);
931 rv = aPrefBranch->GetPrefType(prefNameUTF8.get(), &prefType);
932 NS_ENSURE_SUCCESS(rv, rv);
935 nsCOMPtr<nsIWritableVariant> writableVariant =
936 do_CreateInstance(
"@songbirdnest.com/Songbird/Variant;1", &rv);
937 NS_ENSURE_SUCCESS(rv, rv);
941 case nsIPrefBranch::PREF_INVALID: {
942 rv = writableVariant->SetAsEmpty();
943 NS_ENSURE_SUCCESS(rv, rv);
946 case nsIPrefBranch::PREF_STRING: {
948 rv = aPrefBranch->GetCharPref(prefNameUTF8.get(), &_value);
949 NS_ENSURE_SUCCESS(rv, rv);
955 rv = writableVariant->SetAsACString(value);
956 NS_ENSURE_SUCCESS(rv, rv);
959 case nsIPrefBranch::PREF_INT: {
961 rv = aPrefBranch->GetIntPref(prefNameUTF8.get(), &
value);
962 NS_ENSURE_SUCCESS(rv, rv);
964 rv = writableVariant->SetAsInt32(value);
965 NS_ENSURE_SUCCESS(rv, rv);
968 case nsIPrefBranch::PREF_BOOL: {
970 rv = aPrefBranch->GetBoolPref(prefNameUTF8.get(), &
value);
971 NS_ENSURE_SUCCESS(rv, rv);
973 rv = writableVariant->SetAsBool(value);
974 NS_ENSURE_SUCCESS(rv, rv);
979 return CallQueryInterface(writableVariant, _retval);
985 NS_ENSURE_ARG_POINTER(_retval);
986 NS_ENSURE_FALSE(aPrefName.IsEmpty(), NS_ERROR_INVALID_ARG);
990 if (aPrefName.Equals(NS_LITERAL_STRING(
"capabilities"))) {
995 nsCOMPtr<nsIPrefBranch> prefBranch;
997 NS_ENSURE_SUCCESS(rv, rv);
1005 NS_ENSURE_ARG_POINTER(aPrefValue);
1006 NS_ENSURE_FALSE(aPrefName.IsEmpty(), NS_ERROR_INVALID_ARG);
1010 nsCOMPtr<nsIPrefBranch> prefBranch;
1012 NS_ENSURE_SUCCESS(rv, rv);
1018 const nsAString & aPrefName,
1019 nsIVariant *aPrefValue)
1021 NS_ENSURE_ARG_POINTER(aPrefValue);
1022 NS_ENSURE_FALSE(aPrefName.IsEmpty(), NS_ERROR_INVALID_ARG);
1025 PRBool hasChanged = PR_FALSE;
1027 NS_ENSURE_SUCCESS(rv, rv);
1034 nsCOMPtr<sbIDeviceManager2> devMgr =
1035 do_GetService(
"@songbirdnest.com/Songbird/DeviceManager;2", &rv);
1036 NS_ENSURE_SUCCESS(rv, rv);
1041 NS_ENSURE_SUCCESS(rv, rv);
1048 const nsAString& aPrefName,
1049 nsIVariant* aPrefValue,
1050 PRBool* aHasChanged)
1053 nsCOMPtr<nsIPrefBranch> prefBranch;
1055 NS_ENSURE_SUCCESS(rv, rv);
1061 const nsAString& aPrefName,
1062 nsIVariant* aPrefValue,
1063 PRBool* aHasChanged)
1065 NS_ENSURE_ARG_POINTER(aPrefValue);
1066 NS_ENSURE_FALSE(aPrefName.IsEmpty(), NS_ERROR_INVALID_ARG);
1069 NS_ConvertUTF16toUTF8 prefNameUTF8(aPrefName);
1073 rv = aPrefValue->GetDataType(&dataType);
1074 NS_ENSURE_SUCCESS(rv, rv);
1078 rv = aPrefBranch->GetPrefType(prefNameUTF8.get(), &prefType);
1079 NS_ENSURE_SUCCESS(rv, rv);
1081 PRBool hasChanged = PR_FALSE;
1084 case nsIDataType::VTYPE_INT8:
1085 case nsIDataType::VTYPE_INT16:
1086 case nsIDataType::VTYPE_INT32:
1087 case nsIDataType::VTYPE_INT64:
1088 case nsIDataType::VTYPE_UINT8:
1089 case nsIDataType::VTYPE_UINT16:
1090 case nsIDataType::VTYPE_UINT32:
1091 case nsIDataType::VTYPE_UINT64:
1092 case nsIDataType::VTYPE_FLOAT:
1093 case nsIDataType::VTYPE_DOUBLE:
1096 PRInt32 oldValue,
value;
1097 rv = aPrefValue->GetAsInt32(&value);
1098 NS_ENSURE_SUCCESS(rv, rv);
1100 if (prefType != nsIPrefBranch::PREF_INT) {
1101 hasChanged = PR_TRUE;
1103 rv = aPrefBranch->GetIntPref(prefNameUTF8.get(), &oldValue);
1104 if (NS_SUCCEEDED(rv) && oldValue !=
value) {
1105 hasChanged = PR_TRUE;
1109 rv = aPrefBranch->SetIntPref(prefNameUTF8.get(),
value);
1110 NS_ENSURE_SUCCESS(rv, rv);
1115 case nsIDataType::VTYPE_BOOL:
1118 PRBool oldValue,
value;
1119 rv = aPrefValue->GetAsBool(&value);
1120 NS_ENSURE_SUCCESS(rv, rv);
1122 if (prefType != nsIPrefBranch::PREF_BOOL) {
1123 hasChanged = PR_TRUE;
1125 rv = aPrefBranch->GetBoolPref(prefNameUTF8.get(), &oldValue);
1126 if (NS_SUCCEEDED(rv) && oldValue !=
value) {
1127 hasChanged = PR_TRUE;
1131 rv = aPrefBranch->SetBoolPref(prefNameUTF8.get(),
value);
1132 NS_ENSURE_SUCCESS(rv, rv);
1137 case nsIDataType::VTYPE_VOID:
1138 case nsIDataType::VTYPE_EMPTY:
1141 if (prefType != nsIPrefBranch::PREF_INVALID) {
1142 rv = aPrefBranch->ClearUserPref(prefNameUTF8.get());
1143 NS_ENSURE_SUCCESS(rv, rv);
1144 hasChanged = PR_TRUE;
1154 rv = aPrefValue->GetAsACString(value);
1155 NS_ENSURE_SUCCESS(rv, rv);
1157 if (prefType != nsIPrefBranch::PREF_STRING) {
1158 hasChanged = PR_TRUE;
1161 rv = aPrefBranch->GetCharPref(prefNameUTF8.get(), &oldValue);
1162 if (NS_SUCCEEDED(rv)) {
1163 if (!(value.Equals(oldValue))) {
1164 hasChanged = PR_TRUE;
1170 rv = aPrefBranch->SetCharPref(prefNameUTF8.get(), value.get());
1171 NS_ENSURE_SUCCESS(rv, rv);
1179 *aHasChanged = hasChanged;
1185 PRBool* aHasPreference)
1188 NS_ENSURE_ARG_POINTER(aHasPreference);
1194 nsCOMPtr<nsIVariant> prefValue;
1196 NS_ENSURE_SUCCESS(rv, rv);
1198 *aHasPreference = PR_FALSE;
1204 rv = prefValue->GetDataType(&dataType);
1205 NS_ENSURE_SUCCESS(rv, rv);
1206 if ((dataType == nsIDataType::VTYPE_EMPTY) ||
1207 (dataType == nsIDataType::VTYPE_VOID)) {
1208 *aHasPreference = PR_FALSE;
1213 *aHasPreference = PR_TRUE;
1221 *aIsDirect = PR_TRUE;
1228 NS_ENSURE_ARG_POINTER(aIsBusy);
1229 NS_ENSURE_TRUE(
mStateLock, NS_ERROR_NOT_INITIALIZED);
1236 *aIsBusy = PR_FALSE;
1249 NS_ENSURE_ARG_POINTER(aCanDisconnect);
1250 NS_ENSURE_TRUE(
mStateLock, NS_ERROR_NOT_INITIALIZED);
1259 *aCanDisconnect = PR_TRUE;
1263 *aCanDisconnect = PR_FALSE;
1272 NS_ENSURE_ARG_POINTER(aState);
1293 NS_ENSURE_ARG_POINTER(aState);
1294 NS_ENSURE_TRUE(
mStateLock, NS_ERROR_NOT_INITIALIZED);
1305 PRBool stateChanged = PR_FALSE;
1310 NS_ENSURE_TRUE(
mStateLock, NS_ERROR_NOT_INITIALIZED);
1322 stateChanged = PR_TRUE;
1333 nsCOMPtr<nsIWritableVariant> var =
1334 do_CreateInstance(
"@songbirdnest.com/Songbird/Variant;1", &rv);
1335 NS_ENSURE_SUCCESS(rv, rv);
1336 rv = var->SetAsUint32(aState);
1337 NS_ENSURE_SUCCESS(rv, rv);
1346 return mStatus->ChangeState(aState);
1350 nsIURI* aLibraryLocation,
1353 NS_ENSURE_ARG_POINTER(_retval);
1356 NS_ENSURE_TRUE(devLib, NS_ERROR_OUT_OF_MEMORY);
1359 NS_ENSURE_SUCCESS(rv, rv);
1361 rv = CallQueryInterface(devLib.get(), _retval);
1362 NS_ENSURE_SUCCESS(rv, rv);
1369 const nsAString& aId,
1370 nsIURI* aLibraryLocation)
1372 NS_ENSURE_ARG_POINTER(aDevLib);
1374 nsresult rv = aDevLib->Initialize(aId);
1375 NS_ENSURE_SUCCESS(rv, rv);
1380 NS_LITERAL_STRING(
"1"));
1381 NS_ENSURE_SUCCESS(rv, rv);
1384 NS_LITERAL_STRING(
"1"));
1385 NS_ENSURE_SUCCESS(rv, rv);
1387 if (!mLibraryListener) {
1388 nsRefPtr<sbBaseDeviceLibraryListener> libListener =
1390 NS_ENSURE_TRUE(libListener, NS_ERROR_OUT_OF_MEMORY);
1392 rv = libListener->Init(
this);
1393 NS_ENSURE_SUCCESS(rv, rv);
1395 libListener.swap(mLibraryListener);
1398 rv = aDevLib->AddDeviceLibraryListener(mLibraryListener);
1399 NS_ENSURE_SUCCESS(rv, rv);
1402 rv = InitializeDeviceLibraryPreferences(aDevLib);
1403 NS_ENSURE_SUCCESS(rv, rv);
1412 NS_ENSURE_ARG_POINTER(aDevLib);
1418 nsAutoString libraryPreferenceBase;
1420 NS_ENSURE_SUCCESS(rv, rv);
1423 nsAutoString organizeEnabledPref = libraryPreferenceBase;
1431 nsAutoString organizeDirFormatPref = libraryPreferenceBase;
1435 NS_ENSURE_SUCCESS(rv, rv);
1440 NS_ENSURE_SUCCESS(rv, rv);
1451 enumerateInfo.
device =
this;
1452 enumerateInfo.
library = aDevLib;
1454 (sbBaseDevice::EnumerateFinalizeMediaListListeners,
1460 aDevLib->Finalize();
1467 NS_ENSURE_ARG_POINTER(aDevLib);
1474 NS_ENSURE_SUCCESS(rv, rv);
1477 nsCOMPtr<sbIDeviceContent>
content;
1478 rv = GetContent(getter_AddRefs(content));
1479 NS_ENSURE_SUCCESS(rv, rv);
1482 nsRefPtr<sbBaseDeviceVolume> volume;
1484 NS_ENSURE_SUCCESS(rv, rv);
1486 NS_ENSURE_SUCCESS(rv, rv);
1489 rv = content->AddLibrary(aDevLib);
1490 NS_ENSURE_SUCCESS(rv, rv);
1500 NS_ENSURE_SUCCESS(rv, rv);
1504 nsAutoString defaultLibraryGUID;
1505 nsCOMPtr<nsIVariant> defaultLibraryGUIDPref;
1506 rv =
GetPreference(NS_LITERAL_STRING(
"default_library_guid"),
1507 getter_AddRefs(defaultLibraryGUIDPref));
1508 NS_ENSURE_SUCCESS(rv, rv);
1509 rv = defaultLibraryGUIDPref->GetAsAString(defaultLibraryGUID);
1510 NS_ENSURE_SUCCESS(rv, rv);
1513 nsAutoString libraryGUID;
1514 rv = aDevLib->GetGuid(libraryGUID);
1515 NS_ENSURE_SUCCESS(rv, rv);
1519 if (libraryGUID.Equals(defaultLibraryGUID)) {
1521 NS_ENSURE_SUCCESS(rv, rv);
1527 NS_ENSURE_SUCCESS(rv, rv);
1535 NS_ENSURE_ARG_POINTER(aDevLib);
1541 nsCOMPtr<nsIPropertyBag2> deviceProperties;
1543 NS_ENSURE_SUCCESS(rv, rv);
1546 nsAutoString accessCompatibility;
1547 rv = deviceProperties->GetPropertyAsAString
1549 accessCompatibility);
1551 accessCompatibility.Truncate();
1554 if (!accessCompatibility.Equals(NS_LITERAL_STRING(
"ro")))
1559 nsCOMPtr<sbIPrompter>
1561 NS_ENSURE_SUCCESS(rv, rv);
1564 PRBool canChangeAccess = PR_FALSE;
1565 rv = deviceProperties->GetPropertyAsBool
1569 canChangeAccess = PR_FALSE;
1572 nsAutoString deviceName;
1573 rv = GetName(deviceName);
1574 NS_ENSURE_SUCCESS(rv, rv);
1581 nsTArray<nsString> params;
1582 params.AppendElement(deviceName);
1583 if (canChangeAccess) {
1592 PRUint32 buttonFlags = 0;
1593 PRInt32 changeAccessButtonIndex = -1;
1594 if (canChangeAccess) {
1595 changeAccessButtonIndex = 0;
1596 buttonFlags += nsIPromptService::BUTTON_POS_0 *
1597 nsIPromptService::BUTTON_TITLE_IS_STRING;
1598 buttonFlags += nsIPromptService::BUTTON_POS_1 *
1599 nsIPromptService::BUTTON_TITLE_IS_STRING;
1601 buttonFlags += nsIPromptService::BUTTON_POS_0 *
1602 nsIPromptService::BUTTON_TITLE_OK;
1610 PRInt32 buttonPressed;
1611 rv = prompter->ConfirmEx(nsnull,
1621 NS_ENSURE_SUCCESS(rv, rv);
1624 if (canChangeAccess && (buttonPressed == changeAccessButtonIndex)) {
1626 nsCOMPtr<nsIWritablePropertyBag>
1627 writeDeviceProperties = do_QueryInterface(deviceProperties, &rv);
1628 accessCompatibility = NS_LITERAL_STRING(
"rw");
1629 NS_ENSURE_SUCCESS(rv, rv);
1630 writeDeviceProperties->SetProperty
1641 NS_ENSURE_ARG_POINTER(aDevLib);
1647 nsCOMPtr<sbIDeviceContent>
content;
1648 rv = GetContent(getter_AddRefs(content));
1649 NS_ENSURE_SUCCESS(rv, rv);
1655 PRUint32 libraryCount;
1656 nsCOMPtr<nsIArray> libraries;
1657 rv = content->GetLibraries(getter_AddRefs(libraries));
1658 NS_ENSURE_SUCCESS(rv, rv);
1659 rv = libraries->GetLength(&libraryCount);
1660 NS_ENSURE_SUCCESS(rv, rv);
1664 for (PRUint32
i = 0;
i < libraryCount; ++
i) {
1665 nsCOMPtr<sbIDeviceLibrary> library = do_QueryElementAt(libraries,
i, &rv);
1666 NS_ENSURE_SUCCESS(rv, rv);
1667 if (library != aDevLib) {
1668 defaultLibrary = library;
1673 NS_ENSURE_SUCCESS(rv, rv);
1678 rv = aDevLib->GetGuid(guid);
1679 NS_ASSERTION(NS_SUCCEEDED(rv),
"Failed to get device library.");
1684 rv = content->RemoveLibrary(aDevLib);
1685 NS_ENSURE_SUCCESS(rv, rv);
1692 const nsAString& aPropertyID,
1693 const nsAString& aPropertyValue)
1695 NS_ENSURE_ARG_POINTER(aLibrary);
1699 nsAutoString currentPropertyValue;
1700 rv = aLibrary->GetProperty(aPropertyID, currentPropertyValue);
1701 NS_ENSURE_SUCCESS(rv, rv);
1704 if (!aPropertyValue.Equals(currentPropertyValue)) {
1705 rv = aLibrary->SetProperty(aPropertyID, aPropertyValue);
1706 NS_ENSURE_SUCCESS(rv, rv);
1722 nsRefPtr<sbBaseDeviceVolume> volume;
1725 NS_ENSURE_SUCCESS(rv, rv);
1751 NS_ENSURE_ARG_POINTER(aList);
1757 nsCOMPtr<sbILibrary> library = do_QueryInterface(aList);
1758 NS_ASSERTION(!library,
1759 "Should not call sbBaseDevice::ListenToList on a library!");
1764 nsCOMPtr<sbIMediaList> list = do_QueryInterface(aList, &rv);
1765 NS_ENSURE_SUCCESS(rv, rv);
1775 nsRefPtr<sbBaseDeviceMediaListListener>
listener =
1777 NS_ENSURE_TRUE(listener, NS_ERROR_OUT_OF_MEMORY);
1779 rv = listener->Init(
this);
1780 NS_ENSURE_SUCCESS(rv, rv);
1782 rv = list->AddListener(listener,
1786 NS_ENSURE_SUCCESS(rv, rv);
1791 listener->SetIgnoreListener(PR_TRUE);
1797 PLDHashOperator sbBaseDevice::EnumerateFinalizeMediaListListeners
1799 nsRefPtr<sbBaseDeviceMediaListListener>&
aData,
1805 EnumerateFinalizeMediaListListenersInfo*
1807 static_cast<EnumerateFinalizeMediaListListenersInfo*
>(
aClosure);
1808 nsCOMPtr<sbILibrary> library = enumerateInfo->library;
1811 nsCOMPtr<sbIMediaList> mediaList = do_QueryInterface(aKey, &rv);
1812 NS_ENSURE_SUCCESS(rv, PL_DHASH_STOP);
1815 nsCOMPtr<sbILibrary> mediaListLibrary;
1817 rv = mediaList->GetLibrary(getter_AddRefs(mediaListLibrary));
1818 NS_ENSURE_SUCCESS(rv, PL_DHASH_STOP);
1819 rv = mediaListLibrary->Equals(library, &equals);
1820 NS_ENSURE_SUCCESS(rv, PL_DHASH_STOP);
1822 return PL_DHASH_NEXT;
1825 mediaList->RemoveListener(aData);
1827 return PL_DHASH_REMOVE;
1830 PLDHashOperator sbBaseDevice::EnumerateIgnoreMediaListListeners(
nsISupports* aKey,
1831 nsRefPtr<sbBaseDeviceMediaListListener> aData,
1835 PRBool *ignore =
static_cast<PRBool *
>(
aClosure);
1837 rv = aData->SetIgnoreListener(*ignore);
1838 NS_ENSURE_SUCCESS(rv, PL_DHASH_STOP);
1840 return PL_DHASH_NEXT;
1848 if (aIgnoreListener)
1868 NS_ENSURE_ARG_POINTER(aLibrary);
1871 NS_ENSURE_TRUE(enumerator, NS_ERROR_OUT_OF_MEMORY);
1873 nsresult rv = aLibrary->EnumerateItemsByProperty(NS_LITERAL_STRING(
SB_PROPERTY_ISLIST),
1874 NS_LITERAL_STRING(
"1"),
1893 NS_ENSURE_ARG_POINTER(aLibrary);
1894 NS_ENSURE_ARG_POINTER(aItem);
1901 nsresult rv = aLibrary->Remove(aItem);
1911 PRUint32* aContentType)
1914 NS_ENSURE_ARG_POINTER(aMediaItem);
1915 NS_ENSURE_ARG_POINTER(aContentType);
1923 PRUint32 sampleRate;
1928 if (rv == NS_ERROR_NOT_AVAILABLE) {
1930 return NS_ERROR_NOT_AVAILABLE;
1933 NS_ENSURE_SUCCESS(rv, rv);
1947 NS_ENSURE_ARG_POINTER(aRequest);
1948 NS_ENSURE_ARG_POINTER(aURI);
1960 nsAutoString originURL;
1963 if (NS_SUCCEEDED(rv)) {
1966 NS_ENSURE_SUCCESS(rv, rv);
1971 rv = aRequest->
item->SetContentSrc(aURI);
1972 NS_ENSURE_SUCCESS(rv, rv);
1982 nsIPropertyBag2 *aRequestParameters,
1985 NS_ENSURE_ARG_POINTER(aRequestParameters);
1986 NS_ENSURE_ARG_POINTER(aTransferRequest);
1991 nsCOMPtr<sbIMediaItem> item;
1992 nsCOMPtr<sbIMediaList> list;
1993 nsCOMPtr<nsISupports>
data;
1998 rv = aRequestParameters->GetPropertyAsInterface(NS_LITERAL_STRING(
"item"),
2000 getter_AddRefs(item));
2001 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"No item present in request parameters.");
2003 rv = aRequestParameters->GetPropertyAsInterface(NS_LITERAL_STRING(
"list"),
2005 getter_AddRefs(list));
2006 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"No list present in request parameters.");
2008 rv = aRequestParameters->GetPropertyAsInterface(NS_LITERAL_STRING(
"data"),
2010 getter_AddRefs(data));
2011 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"No data present in request parameters.");
2013 NS_WARN_IF_FALSE(item || list || data,
2014 "No data of any kind given in request."
2015 "This request will most likely fail.");
2017 rv = aRequestParameters->GetPropertyAsUint32(NS_LITERAL_STRING(
"index"),
2023 rv = aRequestParameters->GetPropertyAsUint32(NS_LITERAL_STRING(
"otherIndex"),
2035 NS_ENSURE_TRUE(req, NS_ERROR_OUT_OF_MEMORY);
2037 req.forget(aTransferRequest);
2050 nsCOMPtr<sbIDeviceManager2> manager =
2051 do_GetService(
"@songbirdnest.com/Songbird/DeviceManager;2", &rv);
2052 NS_ENSURE_SUCCESS(rv, rv);
2054 nsCOMPtr<sbIDeviceStatus> status;
2055 rv = GetCurrentStatus(getter_AddRefs(status));
2056 NS_ENSURE_SUCCESS(rv, rv);
2060 rv = status->GetCurrentSubState(&subState);
2061 NS_ENSURE_SUCCESS(rv, rv);
2064 nsCOMPtr<sbIDeviceEvent> deviceEvent;
2065 rv = manager->CreateEvent(aType,
2067 static_cast<sbIDevice*>(
this),
2070 getter_AddRefs(deviceEvent));
2071 NS_ENSURE_SUCCESS(rv, rv);
2075 return aTarget->DispatchEvent(deviceEvent, aAsync, &dispatched);
2076 return DispatchEvent(deviceEvent, aAsync, &dispatched);
2088 do_GetService(
"@songbirdnest.com/Songbird/DeviceManager;2", &rv);
2089 NS_ENSURE_SUCCESS(rv, rv);
2091 return CreateAndDispatchEvent(aType, aData, aAsync, eventTarget);
2096 nsACString & aFilename) {
2099 nsCString extension;
2101 nsCOMPtr<nsIURI> sourceContentURI;
2102 rv = aItem->GetContentSrc(getter_AddRefs(sourceContentURI));
2103 NS_ENSURE_SUCCESS(rv, rv);
2105 nsCOMPtr<nsIURL> sourceContentURL = do_QueryInterface(sourceContentURI, &rv);
2106 if (NS_SUCCEEDED(rv)) {
2107 rv = sourceContentURL->GetFileBaseName(filename);
2108 NS_ENSURE_SUCCESS(rv, rv);
2111 rv = sourceContentURL->GetFileExtension(extension);
2112 NS_ENSURE_SUCCESS(rv, rv);
2116 rv = sourceContentURI->GetSpec(spec);
2117 NS_ENSURE_SUCCESS(rv, rv);
2119 PRInt32 lastSlash = spec.RFind(
"/");
2120 if (lastSlash == -1) {
2123 PRInt32 lastPeriod = spec.RFind(
".");
2124 if (lastPeriod == -1 || lastPeriod < lastSlash) {
2125 lastPeriod = spec.Length();
2127 filename = Substring(spec, lastSlash + 1, lastPeriod - lastSlash - 1);
2128 extension = Substring(spec, lastPeriod + 1, spec.Length() - lastPeriod - 1);
2130 aFilename = filename;
2131 if (!extension.IsEmpty()) {
2132 aFilename += NS_LITERAL_CSTRING(
".");
2133 aFilename += extension;
2140 nsIFile **aUniqueFile,
2141 nsIURI **aUniqueURI)
2143 NS_ENSURE_ARG_POINTER(aURI);
2148 nsCOMPtr<nsIURI> uniqueURI;
2149 rv = aURI->Clone(getter_AddRefs(uniqueURI));
2150 NS_ENSURE_SUCCESS(rv, rv);
2153 nsCOMPtr<nsIFileURL> uniqueFileURL = do_QueryInterface(uniqueURI, &rv);
2154 NS_ENSURE_SUCCESS(rv, rv);
2157 nsCOMPtr<nsIFile> uniqueFile;
2159 NS_ENSURE_SUCCESS(rv, rv);
2160 rv = uniqueFileURL->GetFile(getter_AddRefs(uniqueFile));
2161 NS_ENSURE_SUCCESS(rv, rv);
2164 PRBool alreadyExists;
2165 rv = uniqueFile->Exists(&alreadyExists);
2166 NS_ENSURE_SUCCESS(rv, rv);
2170 for (PRUint32 uniqueIndex = 1;
2171 alreadyExists && (uniqueIndex < 10000);
2174 rv = aURI->Clone(getter_AddRefs(uniqueURI));
2175 NS_ENSURE_SUCCESS(rv, rv);
2178 uniqueFileURL = do_QueryInterface(uniqueURI, &rv);
2179 NS_ENSURE_SUCCESS(rv, rv);
2182 nsCAutoString fileBaseName;
2183 rv = uniqueFileURL->GetFileBaseName(fileBaseName);
2184 NS_ENSURE_SUCCESS(rv, rv);
2187 fileBaseName.Append(
" (");
2188 fileBaseName.AppendInt(uniqueIndex);
2189 fileBaseName.Append(
")");
2190 rv = uniqueFileURL->SetFileBaseName(fileBaseName);
2191 NS_ENSURE_SUCCESS(rv, rv);
2195 NS_ENSURE_SUCCESS(rv, rv);
2196 rv = uniqueFileURL->GetFile(getter_AddRefs(uniqueFile));
2197 NS_ENSURE_SUCCESS(rv, rv);
2200 rv = uniqueFile->Exists(&alreadyExists);
2201 NS_ENSURE_SUCCESS(rv, rv);
2204 if (!alreadyExists) {
2205 rv = uniqueFile->Create(nsIFile::NORMAL_FILE_TYPE,
2207 if (rv == NS_ERROR_FILE_ALREADY_EXISTS) {
2208 alreadyExists = PR_TRUE;
2211 NS_ENSURE_SUCCESS(rv, rv);
2217 uniqueFile.forget(aUniqueFile);
2219 uniqueURI.forget(aUniqueURI);
2228 NS_ENSURE_ARG_POINTER(aItem);
2229 NS_ENSURE_ARG_POINTER(_retval);
2233 nsCOMPtr<sbIMediaFileManager> fileMan =
2235 NS_ENSURE_SUCCESS(rv, rv);
2239 rv = fileMan->Init(nsnull);
2240 NS_ENSURE_SUCCESS(rv, rv);
2243 nsCOMPtr<nsIFile> mediaPath;
2244 rv = fileMan->GetManagedPath(aItem,
2248 getter_AddRefs(mediaPath));
2249 NS_ENSURE_SUCCESS(rv, rv);
2251 nsCOMPtr<nsIFile> parentDir;
2252 rv = mediaPath->GetParent(getter_AddRefs(parentDir));
2253 NS_ENSURE_SUCCESS(rv, rv);
2255 PRBool fileExists = PR_FALSE;
2256 rv = parentDir->Exists(&fileExists);
2257 NS_ENSURE_SUCCESS(rv, rv);
2259 rv = parentDir->Create(nsIFile::DIRECTORY_TYPE, 0755);
2260 NS_ENSURE_SUCCESS(rv, rv);
2263 nsCOMPtr<nsIURI> mediaURI;
2264 rv =
sbNewFileURI(mediaPath, getter_AddRefs(mediaURI));
2265 NS_ENSURE_SUCCESS(rv, rv);
2272 NS_ENSURE_SUCCESS(rv, rv);
2282 NS_ENSURE_SUCCESS(rv, rv);
2291 NS_ENSURE_SUCCESS(rv, rv);
2318 NS_ENSURE_SUCCESS(rv, rv);
2320 nsCOMPtr<sbIDeviceStatus> status;
2321 rv = GetCurrentStatus(getter_AddRefs(status));
2322 NS_ENSURE_SUCCESS(rv, rv);
2325 NS_ENSURE_SUCCESS(rv, rv);
2329 NS_ENSURE_SUCCESS(rv, rv);
2335 NS_ENSURE_SUCCESS(rv, rv);
2347 PRUint32 deviceState;
2348 return NS_FAILED(
GetState(&deviceState)) ||
2356 while (start != target && start != end) {
2365 LOG((
" sbBaseDevice::EnsureSpaceForWrite++\n"));
2372 NS_ENSURE_SUCCESS(rv, rv);
2385 : mDevice(aDevice) {
2386 NS_ADDREF(NS_ISUPPORTS_CAST(
sbIDevice*, mDevice));
2396 NS_ISUPPORTS_CAST(
sbIDevice*, mDevice)->Release();
2404 NS_ENSURE_TRUE(
mStatus, NS_ERROR_OUT_OF_MEMORY);
2407 NS_ASSERTION(NS_IsMainThread(),
2408 "base device init not on main thread, implement proxying");
2409 if (!NS_IsMainThread()) {
2413 return NS_DispatchToMainThread(
event, NS_DISPATCH_SYNC);
2419 nsCOMPtr<nsISupportsWeakReference> manager =
2420 do_GetService(
"@songbirdnest.com/Songbird/DeviceManager;2", &rv);
2421 NS_ENSURE_SUCCESS(rv, rv);
2424 if (NS_FAILED(rv)) {
2430 NS_ENSURE_SUCCESS(rv, rv);
2437 NS_ENSURE_SUCCESS(rv, rv);
2441 NS_ENSURE_SUCCESS(rv, rv);
2444 NS_ENSURE_SUCCESS(rv, rv);
2462 PRInt64* aFreeMusicSpace)
2465 NS_ENSURE_ARG_POINTER(aFreeMusicSpace);
2471 PRInt64 musicAvailableSpace;
2473 NS_ENSURE_SUCCESS(rv, rv);
2476 nsCOMPtr<nsIPropertyBag2> deviceProperties;
2478 NS_ENSURE_SUCCESS(rv, rv);
2481 PRInt64 musicUsedSpace;
2482 nsAutoString musicUsedSpaceStr;
2483 rv = aLibrary->GetProperty
2486 NS_ENSURE_SUCCESS(rv, rv);
2488 NS_ENSURE_SUCCESS(rv, rv);
2491 if (musicAvailableSpace >= musicUsedSpace)
2492 *aFreeMusicSpace = musicAvailableSpace - musicUsedSpace;
2494 *aFreeMusicSpace = 0;
2501 PRInt64* aMusicAvailableSpace)
2504 NS_ENSURE_ARG_POINTER(aMusicAvailableSpace);
2510 nsCOMPtr<nsIPropertyBag2> deviceProperties;
2512 NS_ENSURE_SUCCESS(rv, rv);
2516 nsAutoString capacityStr;
2519 NS_ENSURE_SUCCESS(rv, rv);
2521 NS_ENSURE_SUCCESS(rv, rv);
2524 PRInt64 musicAvailableSpace;
2527 static_cast<PRInt64>(100);
2529 musicAvailableSpace = capacity;
2533 *aMusicAvailableSpace = musicAvailableSpace;
2540 PRBool aReportErrors,
2543 NS_ENSURE_ARG_POINTER(aMediaItem);
2544 NS_ENSURE_ARG_POINTER(_retval);
2549 if (aReportErrors) {
2552 NS_ENSURE_SUCCESS(rv, rv);
2554 *_retval = PR_FALSE;
2568 TRACE((
"%s[%p]", __FUNCTION__,
this));
2570 NS_ENSURE_ARG_POINTER(aVolume);
2576 nsAutoString volumeGUID;
2577 rv = aVolume->
GetGUID(volumeGUID);
2578 NS_ENSURE_SUCCESS(rv, rv);
2581 NS_ENSURE_TRUE(
mVolumeList.AppendElement(aVolume), NS_ERROR_OUT_OF_MEMORY);
2583 NS_ERROR_OUT_OF_MEMORY);
2588 nsCOMPtr<sbIDeviceProperties> deviceProperties;
2589 rv = GetProperties(getter_AddRefs(deviceProperties));
2590 NS_ENSURE_SUCCESS(rv, rv);
2592 PRBool isHidden = PR_FALSE;
2593 rv = deviceProperties->GetHidden(&isHidden);
2594 if (NS_SUCCEEDED(rv) && isHidden) {
2595 rv = deviceProperties->SetHidden(PR_FALSE);
2596 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"Could not mark device as not hidden!");
2606 NS_ENSURE_ARG_POINTER(aVolume);
2610 PRBool isVolumeListEmpty = PR_FALSE;
2613 nsAutoString libraryGUID;
2614 nsCOMPtr<sbIDeviceLibrary> library;
2616 NS_ENSURE_SUCCESS(rv, rv);
2618 library->GetGuid(libraryGUID);
2621 nsAutoString volumeGUID;
2622 rv = aVolume->
GetGUID(volumeGUID);
2623 NS_ENSURE_SUCCESS(rv, rv);
2628 if (!libraryGUID.IsEmpty())
2637 if (isVolumeListEmpty) {
2638 nsCOMPtr<sbIDeviceProperties> deviceProperties;
2639 rv = GetProperties(getter_AddRefs(deviceProperties));
2640 NS_ENSURE_SUCCESS(rv, rv);
2642 rv = deviceProperties->SetHidden(PR_TRUE);
2643 NS_ENSURE_SUCCESS(rv, rv);
2654 NS_ENSURE_ARG_POINTER(aItem);
2655 NS_ENSURE_ARG_POINTER(aVolume);
2661 nsAutoString libraryGUID;
2662 nsCOMPtr<sbILibrary> library;
2663 rv = aItem->GetLibrary(getter_AddRefs(library));
2664 NS_ENSURE_SUCCESS(rv, rv);
2665 rv = library->GetGuid(libraryGUID);
2666 NS_ENSURE_SUCCESS(rv, rv);
2669 nsRefPtr<sbBaseDeviceVolume> volume;
2673 getter_AddRefs(volume));
2674 NS_ENSURE_TRUE(present, NS_ERROR_NOT_AVAILABLE);
2678 volume.forget(aVolume);
2691 (nsIDOMDocument** aDeviceSettingsDocument)
2694 NS_ENSURE_ARG_POINTER(aDeviceSettingsDocument);
2695 *aDeviceSettingsDocument = nsnull;
2701 (nsIFile* aDeviceSettingsFile,
2702 nsIDOMDocument** aDeviceSettingsDocument)
2705 NS_ENSURE_ARG_POINTER(aDeviceSettingsFile);
2706 NS_ENSURE_ARG_POINTER(aDeviceSettingsDocument);
2713 rv = aDeviceSettingsFile->Exists(&exists);
2714 NS_ENSURE_SUCCESS(rv, rv);
2716 *aDeviceSettingsDocument = nsnull;
2721 nsCAutoString deviceSettingsURISpec;
2722 nsCOMPtr<nsIURI> deviceSettingsURI;
2723 rv = NS_NewFileURI(getter_AddRefs(deviceSettingsURI), aDeviceSettingsFile);
2724 NS_ENSURE_SUCCESS(rv, rv);
2725 rv = deviceSettingsURI->GetSpec(deviceSettingsURISpec);
2726 NS_ENSURE_SUCCESS(rv, rv);
2729 nsCOMPtr<nsIXMLHttpRequest>
2730 xmlHttpRequest = do_CreateInstance(NS_XMLHTTPREQUEST_CONTRACTID, &rv);
2731 NS_ENSURE_SUCCESS(rv, rv);
2732 nsCOMPtr<nsIScriptSecurityManager> ssm =
2733 do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
2734 NS_ENSURE_SUCCESS(rv, rv);
2735 nsCOMPtr<nsIPrincipal> principal;
2736 rv = ssm->GetSystemPrincipal(getter_AddRefs(principal));
2737 NS_ENSURE_SUCCESS(rv, rv);
2738 rv = xmlHttpRequest->Init(principal, nsnull, nsnull, nsnull);
2739 NS_ENSURE_SUCCESS(rv, rv);
2742 rv = xmlHttpRequest->OpenRequest(NS_LITERAL_CSTRING(
"GET"),
2743 deviceSettingsURISpec,
2747 NS_ENSURE_SUCCESS(rv, rv);
2748 rv = xmlHttpRequest->Send(nsnull);
2749 NS_ENSURE_SUCCESS(rv, rv);
2750 rv = xmlHttpRequest->GetResponseXML(aDeviceSettingsDocument);
2751 NS_ENSURE_SUCCESS(rv, rv);
2758 (nsTArray<PRUint8>& aDeviceSettingsContent,
2759 nsIDOMDocument** aDeviceSettingsDocument)
2762 NS_ENSURE_ARG_POINTER(aDeviceSettingsDocument);
2768 nsCOMPtr<nsIDOMParser> domParser = do_CreateInstance(NS_DOMPARSER_CONTRACTID,
2770 NS_ENSURE_SUCCESS(rv, rv);
2771 rv = domParser->ParseFromBuffer(aDeviceSettingsContent.Elements(),
2772 aDeviceSettingsContent.Length(),
2774 aDeviceSettingsDocument);
2775 NS_ENSURE_SUCCESS(rv, rv);
2786 NS_ASSERTION(NS_IsMainThread(),
"not on main thread");
2790 nsCOMPtr<nsIDOMDocument> deviceSettingsDocument;
2792 NS_ENSURE_SUCCESS(rv, rv);
2793 if (!deviceSettingsDocument)
2798 NS_ENSURE_SUCCESS(rv, rv);
2807 NS_ENSURE_ARG_POINTER(aDeviceSettingsDocument);
2814 (aDeviceSettingsDocument,
2816 NS_ENSURE_SUCCESS(rv, rv);
2820 NS_ENSURE_SUCCESS(rv, rv);
2824 NS_ENSURE_SUCCESS(rv, rv);
2831 (nsIDOMDocument* aDeviceSettingsDocument,
2832 const nsAString& aPropertyName)
2835 NS_ENSURE_ARG_POINTER(aDeviceSettingsDocument);
2836 NS_ENSURE_TRUE(StringBeginsWith(aPropertyName,
2838 NS_ERROR_INVALID_ARG);
2846 NS_ASSERTION(NS_IsMainThread(),
"not on main thread");
2849 nsAutoString propertyNameSuffix(Substring(aPropertyName,
2853 nsCOMPtr<nsIDOMElement> deviceSettingElement;
2854 nsCOMPtr<nsIDOMNodeList> elementList;
2855 nsCOMPtr<nsIDOMNode> elementNode;
2856 PRUint32 elementCount;
2857 rv = aDeviceSettingsDocument->GetElementsByTagNameNS
2860 getter_AddRefs(elementList));
2861 NS_ENSURE_SUCCESS(rv, rv);
2862 rv = elementList->GetLength(&elementCount);
2863 NS_ENSURE_SUCCESS(rv, rv);
2864 if (elementCount > 0) {
2865 rv = elementList->Item(0, getter_AddRefs(elementNode));
2866 NS_ENSURE_SUCCESS(rv, rv);
2867 deviceSettingElement = do_QueryInterface(elementNode, &rv);
2868 NS_ENSURE_SUCCESS(rv, rv);
2872 if (!deviceSettingElement)
2876 nsAutoString propertyValue;
2877 rv = deviceSettingElement->GetAttribute(NS_LITERAL_STRING(
"value"),
2879 NS_ENSURE_SUCCESS(rv, rv);
2880 rv = ApplyDeviceSettingsToProperty(aPropertyName,
2882 NS_ENSURE_SUCCESS(rv, rv);
2889 nsIVariant* aPropertyValue)
2897 (nsIDOMDocument* aDeviceSettingsDocument)
2900 NS_ENSURE_ARG_POINTER(aDeviceSettingsDocument);
2903 nsAutoPtr<nsString> folderURL;
2904 PRBool needMediaFolderUpdate = PR_FALSE;
2912 NS_ENSURE_TRUE(deviceXMLInfo, NS_ERROR_OUT_OF_MEMORY);
2913 rv = deviceXMLInfo->Read(aDeviceSettingsDocument);
2914 NS_ENSURE_SUCCESS(rv, rv);
2915 rv = deviceXMLInfo->GetDeviceInfoPresent(&present);
2916 NS_ENSURE_SUCCESS(rv, rv);
2921 for (PRUint32
i = 0;
2928 nsAutoPtr<nsString> folderURL(
new nsString());
2929 NS_ENSURE_TRUE(folderURL, NS_ERROR_OUT_OF_MEMORY);
2932 rv = deviceXMLInfo->GetDeviceFolder(folderContentType, *folderURL);
2933 NS_ENSURE_SUCCESS(rv, rv);
2934 if (!folderURL->IsEmpty()) {
2935 success = mMediaFolderURLTable.Put(folderContentType, folderURL);
2936 NS_ENSURE_TRUE(success, NS_ERROR_OUT_OF_MEMORY);
2938 needMediaFolderUpdate = PR_TRUE;
2942 nsString excludedFolders;
2943 rv = deviceXMLInfo->GetExcludedFolders(excludedFolders);
2944 NS_ENSURE_SUCCESS(rv, rv);
2947 nsCOMPtr<nsIWritablePropertyBag> deviceProperties;
2949 NS_ENSURE_SUCCESS(rv, rv);
2951 if (!excludedFolders.IsEmpty()) {
2952 LOG((
"Excluded Folders: %s",
2953 NS_LossyConvertUTF16toASCII(excludedFolders).BeginReading()));
2955 rv = deviceProperties->SetProperty(
2958 NS_ENSURE_SUCCESS(rv, rv);
2962 nsCOMPtr<nsIArray> importRules;
2963 rv = deviceXMLInfo->GetImportRules(getter_AddRefs(importRules));
2964 NS_ENSURE_SUCCESS(rv, rv);
2968 nsCOMPtr<nsIWritablePropertyBag2> devProps2 =
2969 do_QueryInterface(deviceProperties, &rv);
2970 NS_ENSURE_SUCCESS(rv, rv);
2971 rv = devProps2->SetPropertyAsInterface(
2974 NS_ENSURE_SUCCESS(rv, rv);
2979 if (needMediaFolderUpdate)
2980 UpdateMediaFolders();
2986 PRBool supportsFormat;
2987 rv = deviceXMLInfo->GetDoesDeviceSupportReformat(&supportsFormat);
2988 NS_ENSURE_SUCCESS(rv, rv);
2990 rv = deviceProperties->SetProperty(
2993 NS_ENSURE_SUCCESS(rv, rv);
3000 (nsIDOMDocument* aDeviceSettingsDocument)
3003 NS_ENSURE_ARG_POINTER(aDeviceSettingsDocument);
3009 nsCOMPtr<sbIDeviceCapabilities> deviceCaps;
3011 aDeviceSettingsDocument,
3013 NS_ENSURE_SUCCESS(rv, rv);
3018 mCapabilities = deviceCaps;
3043 TRACE((
"%s[%p]", __FUNCTION__,
this));
3048 NS_ENSURE_SUCCESS(rv, rv);
3052 NS_ENSURE_SUCCESS(rv, rv);
3081 nsTArray< nsRefPtr<sbBaseDeviceVolume> > volumeList;
3087 TRACE((
"%s[%p] (%u volumes)", __FUNCTION__,
this, volumeList.Length()));
3090 for (PRUint32
i = 0;
i < volumeList.Length();
i++) {
3092 nsRefPtr<sbBaseDeviceVolume> volume = volumeList[
i];
3096 rv = volume->GetIsMounted(&isMounted);
3097 NS_ENSURE_SUCCESS(rv, rv);
3100 nsString volumeGuid;
3101 rv = volume->GetGUID(volumeGuid);
3102 if (NS_FAILED(rv)) volumeGuid.AssignLiteral(
"<unknown guid>");
3103 TRACE((
"%s[%p] - volume %s not mounted",
3106 NS_ConvertUTF16toUTF8(volumeGuid).
get()));
3112 nsCOMPtr<sbIDeviceLibrary> deviceLibrary;
3113 nsRefPtr<sbDeviceStatistics> deviceStatistics;
3114 rv = volume->GetDeviceLibrary(getter_AddRefs(deviceLibrary));
3115 NS_ENSURE_SUCCESS(rv, rv);
3116 rv = volume->GetStatistics(getter_AddRefs(deviceStatistics));
3117 NS_ENSURE_SUCCESS(rv, rv);
3124 NS_ENSURE_SUCCESS(rv, rv);
3125 TRACE((
"%s[%p]: %s = %u",
3129 deviceStatistics->AudioCount()));
3134 NS_ENSURE_SUCCESS(rv, rv);
3135 TRACE((
"%s[%p]: %s = %llu",
3139 deviceStatistics->AudioUsed()));
3144 NS_ENSURE_SUCCESS(rv, rv);
3145 TRACE((
"%s[%p]: %s = %llu",
3149 deviceStatistics->AudioPlayTime()));
3154 NS_ENSURE_SUCCESS(rv, rv);
3155 TRACE((
"%s[%p]: %s = %u",
3159 deviceStatistics->VideoCount()));
3164 NS_ENSURE_SUCCESS(rv, rv);
3165 TRACE((
"%s[%p]: %s = %llu",
3169 deviceStatistics->VideoUsed()));
3174 NS_ENSURE_SUCCESS(rv, rv);
3175 TRACE((
"%s[%p]: %s = %llu",
3179 deviceStatistics->VideoPlayTime()));
3184 NS_ENSURE_SUCCESS(rv, rv);
3185 TRACE((
"%s[%p]: %s = %u",
3189 deviceStatistics->ImageCount()));
3194 NS_ENSURE_SUCCESS(rv, rv);
3195 TRACE((
"%s[%p]: %s = %llu",
3199 deviceStatistics->ImageUsed()));
3214 nsTArray< nsRefPtr<sbBaseDeviceVolume> > volumeList;
3221 for (PRUint32
i = 0;
i < volumeList.Length();
i++) {
3240 NS_ENSURE_ARG_POINTER(aVolume);
3246 nsCOMPtr<sbIDeviceLibrary> deviceLibrary;
3248 NS_ENSURE_SUCCESS(rv, rv);
3251 nsAutoString displayCapacity;
3252 nsAutoString capacity;
3253 if (deviceLibrary) {
3254 rv = deviceLibrary->GetProperty
3257 if (NS_SUCCEEDED(rv) && !capacity.IsEmpty()) {
3259 nsCOMPtr<sbIPropertyUnitConverter> storageConverter =
3261 NS_ENSURE_SUCCESS(rv, rv);
3262 rv = storageConverter->AutoFormat(capacity, -1, 1, displayCapacity);
3263 NS_ENSURE_SUCCESS(rv, rv);
3268 PRBool storageRemovable = PR_FALSE;
3271 NS_ENSURE_SUCCESS(rv, rv);
3272 if (removable >= 0) {
3273 storageRemovable = (removable != 0);
3277 PRUint32 volumeIndex;
3282 NS_ASSERTION(volumeIndex !=
mVolumeList.NoIndex,
"Volume not found");
3283 storageRemovable = (volumeIndex != 0);
3287 nsAutoString libraryName;
3288 nsTArray<nsString> libraryNameParams;
3289 libraryNameParams.AppendElement(displayCapacity);
3290 if (!storageRemovable) {
3291 if (!displayCapacity.IsEmpty()) {
3301 if (!displayCapacity.IsEmpty()) {
3312 if (deviceLibrary) {
3313 nsAutoString currentLibraryName;
3314 rv = deviceLibrary->GetName(currentLibraryName);
3315 NS_ENSURE_SUCCESS(rv, rv);
3316 if (!currentLibraryName.Equals(libraryName)) {
3317 rv = deviceLibrary->SetName(libraryName);
3318 NS_ENSURE_SUCCESS(rv, rv);
3337 prefKey.Append(aWarning);
3340 nsCOMPtr<nsIWritableVariant> var =
3341 do_CreateInstance(
"@songbirdnest.com/Songbird/Variant;1", &rv);
3342 NS_ENSURE_SUCCESS(rv, rv);
3344 rv = var->SetAsBool(aEnabled);
3345 NS_ENSURE_SUCCESS(rv, rv);
3348 NS_ENSURE_SUCCESS(rv, rv);
3355 NS_ENSURE_ARG_POINTER(_retval);
3361 prefKey.Append(aWarning);
3363 nsCOMPtr<nsIVariant> var;
3365 NS_ENSURE_SUCCESS(rv, rv);
3369 rv = var->GetDataType(&dataType);
3370 NS_ENSURE_SUCCESS(rv, rv);
3372 if (dataType == nsIDataType::VTYPE_EMPTY ||
3373 dataType == nsIDataType::VTYPE_VOID)
3378 rv = var->GetAsBool(_retval);
3379 NS_ENSURE_SUCCESS(rv, rv);
3390 nsCOMPtr<nsIPrefBranch> prefBranch;
3392 NS_ENSURE_SUCCESS(rv, rv);
3398 rv = prefBranch->DeleteBranch(NS_ConvertUTF16toUTF8(prefKey).
get());
3399 NS_ENSURE_SUCCESS(rv, rv);
3405 nsIInputStream** retval)
3407 return NS_ERROR_NOT_AVAILABLE;
3413 NS_ENSURE_ARG_POINTER(aPrefBranch);
3417 PRBool
const isMainThread = NS_IsMainThread();
3420 nsCOMPtr<nsIPrefService> prefService;
3422 if (!isMainThread) {
3424 NS_ENSURE_SUCCESS(rv, rv);
3428 NS_ENSURE_SUCCESS(rv, rv);
3431 nsCOMPtr<nsIThread>
target;
3432 rv = NS_GetMainThread(getter_AddRefs(target));
3433 NS_ENSURE_SUCCESS(rv, rv);
3436 nsCOMPtr<nsIPrefBranch> prefBranch;
3437 rv = prefService->GetBranch(aPrefBranchName, getter_AddRefs(prefBranch));
3438 NS_ENSURE_SUCCESS(rv, rv);
3441 if (!isMainThread) {
3442 nsCOMPtr<nsIPrefBranch> proxy;
3446 nsIProxyObjectManager::INVOKE_SYNC |
3447 nsIProxyObjectManager::FORCE_PROXY_CREATION,
3448 getter_AddRefs(proxy));
3449 NS_ENSURE_SUCCESS(rv, rv);
3450 prefBranch.swap(proxy);
3453 prefBranch.forget(aPrefBranch);
3465 NS_ENSURE_SUCCESS(rv, rv);
3468 char idString[NSID_LENGTH];
3469 id->ToProvidedString(idString);
3474 aRoot.Append(idString);
3475 aRoot.AppendLiteral(
".preferences.");
3482 NS_ENSURE_ARG_POINTER(aPrefBranch);
3488 NS_ENSURE_SUCCESS(rv, rv);
3496 NS_ENSURE_ARG_POINTER(aLibrary);
3497 NS_ENSURE_ARG_POINTER(aPrefBranch);
3501 nsCAutoString prefKey;
3503 NS_ENSURE_SUCCESS(rv, rv);
3506 nsAutoString libraryGUID;
3507 rv = aLibrary->GetGuid(libraryGUID);
3508 NS_ENSURE_SUCCESS(rv, rv);
3509 prefKey.Append(
".library.");
3510 prefKey.Append(NS_ConvertUTF16toUTF8(libraryGUID));
3511 prefKey.Append(
".");
3517 nsIVariant* aPrefValue)
3520 NS_ENSURE_ARG_POINTER(aPrefValue);
3529 if (isLibraryPreference) {
3531 nsCOMPtr<sbIDeviceLibrary> library;
3532 nsAutoString libraryPrefBase;
3533 nsAutoString libraryPrefName;
3535 getter_AddRefs(library),
3537 NS_ENSURE_SUCCESS(rv, rv);
3539 NS_ENSURE_SUCCESS(rv, rv);
3543 NS_ENSURE_SUCCESS(rv, rv);
3551 return StringBeginsWith(aPrefName,
3557 nsAString& aLibraryPrefBase)
3563 nsCOMPtr<sbIDeviceContent>
content;
3564 rv = GetContent(getter_AddRefs(content));
3565 NS_ENSURE_SUCCESS(rv, rv);
3566 nsCOMPtr<nsIArray> libraryList;
3567 rv = content->GetLibraries(getter_AddRefs(libraryList));
3568 NS_ENSURE_SUCCESS(rv, rv);
3571 PRUint32 libraryCount;
3572 rv = libraryList->GetLength(&libraryCount);
3573 NS_ENSURE_SUCCESS(rv, rv);
3574 for (PRUint32
i = 0;
i < libraryCount;
i++) {
3576 nsCOMPtr<sbIDeviceLibrary> library = do_QueryElementAt(libraryList,
i, &rv);
3577 NS_ENSURE_SUCCESS(rv, rv);
3581 rv = library->GetGuid(guid);
3582 NS_ENSURE_SUCCESS(rv, rv);
3585 nsAutoString libraryPrefBase;
3587 NS_ENSURE_SUCCESS(rv, rv);
3588 if (StringBeginsWith(aPrefName, libraryPrefBase)) {
3590 library.forget(aLibrary);
3591 aLibraryPrefBase.Assign(libraryPrefBase);
3597 return NS_ERROR_NOT_AVAILABLE;
3601 const nsAString& aLibraryPrefName,
3602 nsIVariant** aPrefValue)
3605 NS_ENSURE_ARG_POINTER(aLibrary);
3611 nsAutoString libraryPrefBase;
3613 NS_ENSURE_SUCCESS(rv, rv);
3619 const nsAString& aLibraryPrefName,
3620 nsIVariant** aPrefValue)
3623 nsAutoString prefName(aLibraryPrefBase);
3624 prefName.Append(aLibraryPrefName);
3631 const nsAString& aLibraryPrefName,
3632 nsIVariant* aPrefValue)
3637 nsAutoLock preferenceLock(mPreferenceLock);
3640 nsAutoString prefBase;
3641 rv = GetLibraryPreferenceBase(aLibrary, prefBase);
3642 NS_ENSURE_SUCCESS(rv, rv);
3645 PRBool applyAll = PR_FALSE;
3646 if (aLibraryPrefName.IsEmpty())
3651 aLibraryPrefName.EqualsLiteral(
"music_limit_percent") ||
3652 aLibraryPrefName.EqualsLiteral(
"use_music_limit_percent"))
3655 PRBool shouldLimitMusicSpace = PR_FALSE;
3656 rv = GetShouldLimitMusicSpace(prefBase, &shouldLimitMusicSpace);
3657 if (NS_SUCCEEDED(rv) && shouldLimitMusicSpace) {
3658 PRUint32 musicLimitPercent = 100;
3659 rv = GetMusicLimitSpacePercent(prefBase, &musicLimitPercent);
3660 if (NS_SUCCEEDED(rv)) {
3662 mMusicLimitPercent = musicLimitPercent;
3667 mMusicLimitPercent = 100;
3671 return ApplyLibraryOrganizePreference(aLibrary,
3679 const nsAString& aLibraryPrefName,
3680 const nsAString& aLibraryPrefBase,
3681 nsIVariant* aPrefValue)
3684 PRBool applyAll = aLibraryPrefName.IsEmpty();
3686 if (!applyAll && !StringBeginsWith(aLibraryPrefName,
3692 nsString prefBase(aLibraryPrefBase);
3693 if (prefBase.IsEmpty()) {
3695 rv = GetLibraryPreferenceBase(aLibrary, prefBase);
3696 NS_ENSURE_SUCCESS(rv, rv);
3699 nsString guidString;
3700 rv = aLibrary->GetGuid(guidString);
3701 NS_ENSURE_SUCCESS(rv, rv);
3704 libraryGuid.Parse(NS_LossyConvertUTF16toASCII(guidString).
get());
3705 NS_ENSURE_TRUE(success, NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA);
3707 nsAutoPtr<OrganizeData> libraryDataReleaser;
3709 PRBool found = mOrganizeLibraryPrefs.Get(libraryGuid, &libraryData);
3712 libraryDataReleaser = libraryData;
3714 NS_ENSURE_TRUE(libraryData, NS_ERROR_OUT_OF_MEMORY);
3717 nsCOMPtr<nsIVariant> prefValue = aPrefValue;
3722 if (applyAll || !prefValue) {
3723 rv = GetLibraryPreference(prefBase,
3725 getter_AddRefs(prefValue));
3731 rv = prefValue->GetDataType(&dataType);
3732 if (NS_SUCCEEDED(rv) && dataType == nsIDataType::VTYPE_BOOL) {
3734 NS_ENSURE_SUCCESS(rv, rv);
3741 if (applyAll || !prefValue) {
3742 rv = GetLibraryPreference(prefBase,
3744 getter_AddRefs(prefValue));
3750 rv = prefValue->GetDataType(&dataType);
3751 if (NS_SUCCEEDED(rv) && dataType != nsIDataType::VTYPE_EMPTY) {
3752 rv = prefValue->GetAsACString(libraryData->
dirFormat);
3753 NS_ENSURE_SUCCESS(rv, rv);
3760 if (applyAll || !prefValue) {
3761 rv = GetLibraryPreference(prefBase,
3763 getter_AddRefs(prefValue));
3769 rv = prefValue->GetDataType(&dataType);
3770 if (NS_SUCCEEDED(rv) && dataType != nsIDataType::VTYPE_EMPTY) {
3771 rv = prefValue->GetAsACString(libraryData->
fileFormat);
3772 NS_ENSURE_SUCCESS(rv, rv);
3778 success = mOrganizeLibraryPrefs.Put(libraryGuid, libraryData);
3779 NS_ENSURE_TRUE(success, NS_ERROR_OUT_OF_MEMORY);
3780 libraryDataReleaser.forget();
3787 (
const nsAString& aPrefName,
3788 nsAString& aLibraryPrefName)
3793 nsAutoString libraryPrefBase;
3794 rv = GetPreferenceLibrary(aPrefName, nsnull, libraryPrefBase);
3795 NS_ENSURE_SUCCESS(rv, rv);
3797 return GetLibraryPreferenceName(aPrefName, libraryPrefBase, aLibraryPrefName);
3801 (
const nsAString& aPrefName,
3802 const nsAString& aLibraryPrefBase,
3803 nsAString& aLibraryPrefName)
3806 NS_ENSURE_TRUE(StringBeginsWith(aPrefName, aLibraryPrefBase),
3807 NS_ERROR_ILLEGAL_VALUE);
3810 aLibraryPrefName.Assign(Substring(aPrefName, aLibraryPrefBase.Length()));
3816 nsAString& aPrefBase)
3819 NS_ENSURE_ARG_POINTER(aLibrary);
3826 rv = aLibrary->GetGuid(guid);
3827 NS_ENSURE_SUCCESS(rv, rv);
3831 aPrefBase.Append(guid);
3832 aPrefBase.AppendLiteral(
".");
3840 NS_ENSURE_ARG_POINTER(aCapabilities);
3845 nsCOMPtr<nsIDOMDocument> domDocument;
3847 NS_ENSURE_SUCCESS(rv, rv);
3851 nsCOMPtr<sbIDeviceCapabilities> deviceCapabilities;
3853 (getter_AddRefs(deviceCapabilities),
3856 NS_ENSURE_SUCCESS(rv, rv);
3859 if (deviceCapabilities) {
3861 NS_ENSURE_TRUE(capabilitiesVariant.
get(), NS_ERROR_FAILURE);
3862 NS_ADDREF(*aCapabilities = capabilitiesVariant.
get());
3869 NS_ENSURE_TRUE(capabilitiesVariant.
get(), NS_ERROR_FAILURE);
3870 NS_ADDREF(*aCapabilities = capabilitiesVariant.
get());
3877 NS_ENSURE_ARG_POINTER(aLocalDeviceDir);
3882 nsCOMPtr<nsIFile> localDeviceDir;
3884 getter_AddRefs(localDeviceDir));
3885 NS_ENSURE_SUCCESS(rv, rv);
3886 rv = localDeviceDir->Append(NS_LITERAL_STRING(
"devices"));
3887 NS_ENSURE_SUCCESS(rv, rv);
3888 rv = localDeviceDir->Exists(&exists);
3889 NS_ENSURE_SUCCESS(rv, rv);
3891 rv = localDeviceDir->Create(nsIFile::DIRECTORY_TYPE,
3893 NS_ENSURE_SUCCESS(rv, rv);
3899 NS_ENSURE_SUCCESS(rv, rv);
3902 char idString[NSID_LENGTH];
3903 id->ToProvidedString(idString);
3907 nsAutoString deviceSubDirName;
3908 deviceSubDirName.Assign(NS_LITERAL_STRING(
"device"));
3909 deviceSubDirName.Append(NS_ConvertUTF8toUTF16(idString + 1, NSID_LENGTH - 3));
3912 PRUnichar *begin, *end;
3913 for (deviceSubDirName.BeginWriting(&begin, &end); begin < end; ++begin) {
3914 if (*begin & (~0x7F)) {
3915 *begin = PRUnichar(
'_');
3918 deviceSubDirName.StripChars(FILE_ILLEGAL_CHARACTERS
3923 rv = localDeviceDir->Append(deviceSubDirName);
3924 NS_ENSURE_SUCCESS(rv, rv);
3925 rv = localDeviceDir->Exists(&exists);
3926 NS_ENSURE_SUCCESS(rv, rv);
3928 rv = localDeviceDir->Create(nsIFile::DIRECTORY_TYPE,
3931 if (NS_FAILED(rv)) {
3933 nsresult rv2 = localDeviceDir->GetPath(path);
3934 if (NS_FAILED(rv2)) path.AssignLiteral(
"<unknown>");
3935 TRACE((
"%s[%p]: Failed to create device directory %s",
3938 NS_ConvertUTF16toUTF8(path).BeginReading()));
3941 NS_ENSURE_SUCCESS(rv, rv);
3945 localDeviceDir.forget(aLocalDeviceDir);
3961 nsCOMPtr<nsIWritablePropertyBag2> syncCompleteParams =
3962 do_CreateInstance(NS_HASH_PROPERTY_BAG_CONTRACTID, &rv);
3963 NS_ENSURE_SUCCESS(rv, rv);
3965 nsCOMPtr<nsISupportsPRUint64> timestamp =
3966 do_CreateInstance(NS_SUPPORTS_PRUINT64_CONTRACTID, &rv);
3967 NS_ENSURE_SUCCESS(rv, rv);
3969 PRUint64
now = PR_Now();
3970 rv = timestamp->SetData(now);
3971 NS_ENSURE_SUCCESS(rv, rv);
3973 rv = syncCompleteParams->SetPropertyAsInterface(NS_LITERAL_STRING(
"data"),
3975 NS_ENSURE_SUCCESS(rv, rv);
3977 rv = syncCompleteParams->SetPropertyAsInterface(NS_LITERAL_STRING(
"list"),
3979 NS_ENSURE_SUCCESS(rv, rv);
3982 syncCompleteParams);
3983 NS_ENSURE_SUCCESS(rv, rv);
3992 NS_ENSURE_ARG_POINTER(aRequest);
3998 NS_ENSURE_SUCCESS(rv, rv);
4001 nsCOMPtr<sbILibraryChangeset> exportChangeset;
4002 nsCOMPtr<sbILibraryChangeset> importChangeset;
4004 getter_AddRefs(exportChangeset),
4005 getter_AddRefs(importChangeset));
4006 NS_ENSURE_SUCCESS(rv, rv);
4014 NS_ENSURE_SUCCESS(rv, rv);
4016 nsCOMPtr<sbIDeviceStatus> status;
4017 rv = GetCurrentStatus(getter_AddRefs(status));
4018 NS_ENSURE_SUCCESS(rv, rv);
4021 NS_ENSURE_SUCCESS(rv, rv);
4024 NS_ENSURE_SUCCESS(rv, rv);
4029 nsCOMPtr<sbIDeviceLibrary> devLib = do_QueryInterface(aRequest->
list, &rv);
4030 NS_ENSURE_SUCCESS(rv, rv);
4033 NS_ENSURE_SUCCESS(rv, rv);
4035 nsCOMPtr<sbILibrary> mainLib;
4037 NS_ASSERTION(NS_SUCCEEDED(rv),
"Failed to get the main library");
4040 NS_ENSURE_SUCCESS(rv, rv);
4043 NS_ENSURE_SUCCESS(rv, rv);
4049 rv = GetCapabilities(getter_AddRefs(capabilities));
4050 NS_ENSURE_SUCCESS(rv, rv);
4054 rv = capabilities->SupportsContent(
4058 NS_ENSURE_SUCCESS(rv, rv);
4061 nsCOMPtr<sbIDeviceLibrarySyncSettings> syncSettings;
4062 rv = devLib->GetSyncSettings(getter_AddRefs(syncSettings));
4063 NS_ENSURE_SUCCESS(rv, rv);
4065 nsCOMPtr<sbIDeviceLibraryMediaSyncSettings> imageSyncSettings;
4067 getter_AddRefs(imageSyncSettings));
4068 NS_ENSURE_SUCCESS(rv, rv);
4070 PRUint32 imageMgmtType;
4071 rv = imageSyncSettings->GetMgmtType(&imageMgmtType);
4072 NS_ENSURE_SUCCESS(rv, rv);
4074 PRBool imageSyncEnabled = (imageMgmtType !=
4079 if (!isSupported || !imageSyncEnabled) {
4085 nsCOMPtr<nsIWritablePropertyBag2> requestParams =
4086 do_CreateInstance(NS_HASH_PROPERTY_BAG_CONTRACTID, &rv);
4087 NS_ENSURE_SUCCESS(rv, rv);
4089 rv = requestParams->SetPropertyAsInterface
4090 (NS_LITERAL_STRING(
"list"),
4092 NS_ENSURE_SUCCESS(rv, rv);
4094 NS_ENSURE_SUCCESS(rv, rv);
4102 NS_ENSURE_ARG_POINTER(aRequest);
4109 nsCOMPtr<nsISupportsPRUint64> timestamp =
4110 do_QueryInterface(aRequest->
data, &rv);
4111 NS_ENSURE_SUCCESS(rv, rv);
4114 rv = timestamp->GetData(&ts);
4115 NS_ENSURE_SUCCESS(rv, rv);
4118 nsCOMPtr<sbIMediaList> list = aRequest->
list;
4119 NS_ENSURE_TRUE(list, NS_ERROR_FAILURE);
4121 sbAutoString timestampStr((PRUint64)(ts / PR_MSEC_PER_SEC));
4124 NS_ENSURE_SUCCESS(rv, rv);
4134 NS_ASSERTION(aChangeset,
"aChangeset must not be null");
4135 NS_ASSERTION(aLibrary,
"aLibrary must not be null");
4139 nsCOMPtr<nsIArray> changes;
4140 rv = aChangeset->GetChanges(getter_AddRefs(changes));
4141 NS_ENSURE_SUCCESS(rv, rv);
4144 rv = changes->GetLength(&length);
4145 NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && length > 0, NS_ERROR_NOT_AVAILABLE);
4147 nsCOMPtr<sbILibraryChange> change = do_QueryElementAt(changes, 0, &rv);
4148 NS_ENSURE_SUCCESS(rv, rv);
4150 nsCOMPtr<sbIMediaItem> item;
4151 rv = change->GetSourceItem(getter_AddRefs(item));
4152 NS_ENSURE_SUCCESS(rv, rv);
4154 rv = item->GetLibrary(aLibrary);
4155 NS_ENSURE_SUCCESS(rv, rv);
4165 PRInt64 aAvailableSpace)
4168 NS_ENSURE_ARG_POINTER(aSrcLib);
4169 NS_ENSURE_ARG_POINTER(aDstLib);
4175 nsCOMPtr<sbIDeviceLibrarySyncSettings> syncSettings;
4176 rv = aDstLib->GetSyncSettings(getter_AddRefs(syncSettings));
4177 NS_ENSURE_SUCCESS(rv, rv);
4179 nsCOMPtr<sbIDeviceLibraryMediaSyncSettings> mediaSyncSettings;
4185 rv = syncSettings->GetMediaSettings(
i, getter_AddRefs(mediaSyncSettings));
4186 NS_ENSURE_SUCCESS(rv, rv);
4188 rv = mediaSyncSettings->ClearSelectedPlaylists();
4189 NS_ENSURE_SUCCESS(rv, rv);
4191 rv = mediaSyncSettings->SetMgmtType(
4193 NS_ENSURE_SUCCESS(rv, rv);
4196 rv = aDstLib->SetSyncSettings(syncSettings);
4197 NS_ENSURE_SUCCESS(rv, rv);
4203 nsCOMPtr<sbIMediaList> syncMediaList;
4204 rv = SyncCreateSyncMediaList(aSrcLib,
4207 getter_AddRefs(syncMediaList));
4210 NS_ENSURE_SUCCESS(rv, rv);
4216 rv = SyncToMediaList(aDstLib, syncMediaList);
4217 NS_ENSURE_SUCCESS(rv, rv);
4225 PRInt64 aAvailableSpace,
4229 NS_ENSURE_ARG_POINTER(aSrcLib);
4230 NS_ENSURE_ARG_POINTER(aSyncMediaList);
4235 nsCOMPtr<sbIMutablePropertyArray> propertyArray =
4237 NS_ENSURE_SUCCESS(rv, rv);
4239 nsCOMPtr<sbIDeviceLibrary> devLib;
4241 NS_ENSURE_SUCCESS(rv, rv);
4243 rv = devLib->GetGuid(guid);
4244 NS_ENSURE_SUCCESS(rv, rv);
4246 rv = propertyArray->AppendProperty(
4249 NS_ENSURE_SUCCESS(rv, rv);
4250 rv = propertyArray->AppendProperty(
4252 NS_LITERAL_STRING(
"2"));
4253 NS_ENSURE_SUCCESS(rv, rv);
4254 rv = propertyArray->AppendProperty(
4256 NS_LITERAL_STRING(
"1"));
4257 NS_ENSURE_SUCCESS(rv, rv);
4259 nsCOMPtr<nsIArray> randomMediaList;
4260 rv = aSrcLib->GetItemsByProperties(propertyArray,
4261 getter_AddRefs(randomMediaList));
4262 if (rv != NS_ERROR_NOT_AVAILABLE) {
4263 NS_ENSURE_SUCCESS(rv, rv);
4267 rv = randomMediaList->GetLength(&length);
4268 NS_ENSURE_SUCCESS(rv, rv);
4270 NS_WARN_IF_FALSE(length < 2,
"Multiple random sync'ing playlists");
4271 nsCOMPtr<sbIMediaList> syncMediaList;
4273 rv = randomMediaList->QueryElementAt(0,
4275 getter_AddRefs(syncMediaList));
4276 NS_ENSURE_SUCCESS(rv, rv);
4280 PRInt64 totalSyncSize = 0;
4282 rv = syncMediaList->GetLength(&itemCount);
4283 NS_ENSURE_SUCCESS(rv, rv);
4284 for (PRUint32
i = 0;
i < itemCount; ++
i) {
4286 nsCOMPtr<sbIMediaItem> mediaItem;
4287 rv = syncMediaList->GetItemByIndex(
i, getter_AddRefs(mediaItem));
4288 NS_ENSURE_SUCCESS(rv, rv);
4291 nsCOMPtr<sbIMediaList> mediaList = do_QueryInterface(mediaItem, &rv);
4292 if (NS_SUCCEEDED(rv))
4297 PRUint64 writeLength;
4305 totalSyncSize += writeLength;
4308 if (totalSyncSize <= aAvailableSpace) {
4310 syncMediaList.forget(aSyncMediaList);
4325 NS_ENSURE_SUCCESS(rv, rv);
4331 rv = syncMediaList->SetProperty(
4333 NS_LITERAL_STRING(
""));
4338 nsCOMPtr<nsIThread>
target;
4339 rv = NS_GetMainThread(getter_AddRefs(target));
4340 NS_ENSURE_SUCCESS(rv, rv);
4342 nsCOMPtr<sbILibrary> proxiedLibrary;
4345 NS_PROXY_SYNC | NS_PROXY_ALWAYS,
4346 getter_AddRefs(proxiedLibrary));
4347 NS_ENSURE_SUCCESS(rv, rv);
4349 rv = proxiedLibrary->CreateMediaList(NS_LITERAL_STRING(
"smart"),
4351 getter_AddRefs(syncMediaList));
4352 NS_ENSURE_SUCCESS(rv, rv);
4355 nsString deviceName;
4356 rv = GetName(deviceName);
4357 NS_ENSURE_SUCCESS(rv, rv);
4361 nsTArray<nsString> listNameParams;
4362 listNameParams.AppendElement(deviceName);
4366 NS_LITERAL_STRING(
"Autofill"),
4368 NS_ENSURE_SUCCESS(rv, rv);
4370 nsString uniqueName;
4374 NS_ENSURE_SUCCESS(rv, rv);
4376 rv = syncMediaList->SetName(uniqueName);
4377 NS_ENSURE_SUCCESS(rv, rv);
4379 nsCOMPtr<sbILocalDatabaseSmartMediaList> randomList =
4380 do_QueryInterface(syncMediaList, &rv);
4381 NS_ENSURE_SUCCESS(rv, rv);
4385 nsCOMPtr<sbIPropertyOperator> equal;
4387 NS_ENSURE_SUCCESS(rv, rv);
4389 nsCOMPtr<sbILocalDatabaseSmartMediaListCondition> condition;
4392 NS_LITERAL_STRING(
"audio"),
4395 getter_AddRefs(condition));
4396 NS_ENSURE_SUCCESS(rv, rv);
4399 NS_ENSURE_SUCCESS(rv, rv);
4401 rv = randomList->SetLimitType(
4403 NS_ENSURE_SUCCESS(rv, rv);
4407 nsString uiLimitType;
4408 uiLimitType.AssignLiteral(
"GB");
4413 NS_ENSURE_SUCCESS(rv, rv);
4415 rv = randomList->SetLimit(syncSpace);
4416 NS_ENSURE_SUCCESS(rv, rv);
4418 rv = randomList->SetRandomSelection(PR_TRUE);
4419 NS_ENSURE_SUCCESS(rv, rv);
4422 rv = randomList->Rebuild();
4423 NS_ENSURE_SUCCESS(rv, rv);
4426 syncMediaList.forget(aSyncMediaList);
4436 NS_ENSURE_ARG_POINTER(aDstLib);
4437 NS_ENSURE_ARG_POINTER(aMediaList);
4442 PRUint16 contentType;
4443 rv = aMediaList->GetListContentType(&contentType);
4444 NS_ENSURE_SUCCESS(rv, rv);
4445 NS_ENSURE_SUCCESS(contentType > 0, NS_ERROR_FAILURE);
4447 nsCOMPtr<sbIDeviceLibrarySyncSettings> syncSettings;
4448 rv = aDstLib->GetSyncSettings(getter_AddRefs(syncSettings));
4449 NS_ENSURE_SUCCESS(rv, rv);
4451 nsCOMPtr<sbIDeviceLibraryMediaSyncSettings> audioMediaSyncSettings;
4453 getter_AddRefs(audioMediaSyncSettings));
4454 NS_ENSURE_SUCCESS(rv, rv);
4456 nsCOMPtr<sbIDeviceLibraryMediaSyncSettings> videoMediaSyncSettings;
4458 getter_AddRefs(videoMediaSyncSettings));
4459 NS_ENSURE_SUCCESS(rv, rv);
4461 nsCOMPtr<nsIMutableArray> syncList =
4462 do_CreateInstance(
"@songbirdnest.com/moz/xpcom/threadsafe-array;1", &rv);
4463 NS_ENSURE_SUCCESS(rv, rv);
4465 rv = syncList->AppendElement(aMediaList, PR_FALSE);
4466 NS_ENSURE_SUCCESS(rv, rv);
4469 rv = audioMediaSyncSettings->SetSelectedPlaylists(syncList);
4470 NS_ENSURE_SUCCESS(rv, rv);
4471 rv = videoMediaSyncSettings->ClearSelectedPlaylists();
4472 NS_ENSURE_SUCCESS(rv, rv);
4475 rv = videoMediaSyncSettings->SetSelectedPlaylists(syncList);
4476 NS_ENSURE_SUCCESS(rv, rv);
4477 rv = audioMediaSyncSettings->ClearSelectedPlaylists();
4478 NS_ENSURE_SUCCESS(rv, rv);
4481 rv = audioMediaSyncSettings->SetMgmtType(
4483 NS_ENSURE_SUCCESS(rv, rv);
4486 if (contentType == sbIMediaList::CONTENTTYPE_AUDIO)
4490 rv = videoMediaSyncSettings->SetMgmtType(mgmtType);
4491 NS_ENSURE_SUCCESS(rv, rv);
4493 rv = aDstLib->SetSyncSettings(syncSettings);
4494 NS_ENSURE_SUCCESS(rv, rv);
4502 NS_ASSERTION(aChange,
"aChange must not be null");
4506 nsCOMPtr<sbIMediaItem> source;
4507 rv = aChange->GetSourceItem(getter_AddRefs(source));
4508 NS_ENSURE_SUCCESS(rv, rv);
4512 PRUint64 writeLength;
4521 rv = aChange->GetOperation(&operation);
4522 NS_ENSURE_SUCCESS(rv, 0);
4524 switch (operation) {
4529 nsCOMPtr<sbIMediaItem> destinationItem;
4530 rv = aChange->GetDestinationItem(getter_AddRefs(destinationItem));
4531 NS_ENSURE_SUCCESS(rv, 0);
4533 PRInt64 destinationLength;
4534 rv = destinationItem->GetContentLength(&destinationLength);
4535 NS_ENSURE_SUCCESS(rv, writeLength);
4537 return writeLength - destinationLength;
4541 NS_WARNING(
"sbILibraryChange::DELETED not supported");
4545 NS_WARNING(
"Unexpected change operation");
4556 PRInt64 aAvailableSpace,
4557 PRUint32& aLastChangeThatFit,
4558 PRInt64& aTotalSyncSize)
4561 NS_ENSURE_ARG_POINTER(aChangeset);
4569 nsCOMPtr<nsIArray> changes;
4570 rv = aChangeset->GetChanges(getter_AddRefs(changes));
4571 NS_ENSURE_SUCCESS(rv, rv);
4574 rv = changes->GetLength(&length);
4575 NS_ENSURE_SUCCESS(rv, rv);
4576 for (PRUint32
i = 0;
i < length; ++
i) {
4581 nsCOMPtr<sbILibraryChange> change = do_QueryElementAt(changes,
i, &rv);
4582 NS_ENSURE_SUCCESS(rv, rv);
4588 rv = change->GetItemIsList(&isList);
4589 NS_ENSURE_SUCCESS(rv, 0);
4594 nsCOMPtr<sbIMediaItem> mediaItem;
4595 rv = change->GetSourceItem(getter_AddRefs(mediaItem));
4596 NS_ENSURE_SUCCESS(rv, rv);
4598 nsCOMPtr<nsISupports> supports = do_QueryInterface(mediaItem);
4600 if (aTotalSyncSize <= aAvailableSpace) {
4601 aLastChangeThatFit =
i;
4611 PRInt64* aAvailableSpace)
4614 NS_ENSURE_ARG_POINTER(aLibrary);
4615 NS_ENSURE_ARG_POINTER(aAvailableSpace);
4621 nsCOMPtr<nsIPropertyBag2> deviceProperties;
4623 NS_ENSURE_SUCCESS(rv, rv);
4627 nsAutoString freeSpaceStr;
4630 NS_ENSURE_SUCCESS(rv, rv);
4632 NS_ENSURE_SUCCESS(rv, rv);
4635 PRInt64 musicUsedSpace;
4636 nsAutoString musicUsedSpaceStr;
4637 rv = aLibrary->GetProperty
4640 NS_ENSURE_SUCCESS(rv, rv);
4642 NS_ENSURE_SUCCESS(rv, rv);
4645 PRUint32 trackCount;
4646 rv = aLibrary->GetLength(&trackCount);
4647 NS_ENSURE_SUCCESS(rv, rv);
4652 PRInt64 availableSpace = freeSpace + musicUsedSpace;
4655 PRInt64 musicAvailableSpace;
4657 NS_ENSURE_SUCCESS(rv, rv);
4658 if (availableSpace >= musicAvailableSpace)
4659 availableSpace = musicAvailableSpace;
4662 *aAvailableSpace = availableSpace;
4670 PRUint32 aMediaType,
4671 PRUint32 * aMgmtType,
4673 nsIMutableArray * aSelectedPlaylists)
4675 NS_ENSURE_ARG_POINTER(aSyncSettings);
4676 NS_ENSURE_ARG_POINTER(aMgmtType);
4677 NS_ENSURE_ARG_POINTER(aImport);
4678 NS_ENSURE_ARG_POINTER(aSelectedPlaylists);
4682 nsCOMPtr<sbIDeviceLibraryMediaSyncSettings>
settings;
4683 rv = aSyncSettings->GetMediaSettings(aMediaType,
4684 getter_AddRefs(settings));
4685 NS_ENSURE_SUCCESS(rv, rv);
4687 rv = settings->GetMgmtType(aMgmtType);
4688 NS_ENSURE_SUCCESS(rv, rv);
4691 nsCOMPtr<nsIArray> playlists;
4692 rv = settings->GetSelectedPlaylists(getter_AddRefs(playlists));
4693 NS_ENSURE_SUCCESS(rv, rv);
4695 aSelectedPlaylists);
4696 NS_ENSURE_SUCCESS(rv, rv);
4699 rv = settings->GetImport(aImport);
4700 NS_ENSURE_SUCCESS(rv, rv);
4712 NS_ENSURE_ARG_POINTER(aRequest);
4713 NS_ENSURE_ARG_POINTER(aExportChangeset);
4714 NS_ENSURE_ARG_POINTER(aImportChangeset);
4720 nsCOMPtr<sbILibrary> mainLib = do_QueryInterface(aRequest->
item, &rv);
4721 NS_ENSURE_SUCCESS(rv, rv);
4722 nsCOMPtr<sbIDeviceLibrary> devLib = do_QueryInterface(aRequest->
list, &rv);
4723 NS_ENSURE_SUCCESS(rv, rv);
4725 nsCOMPtr<sbIDeviceLibrarySyncSettings> syncSettings;
4726 rv = devLib->GetSyncSettings(getter_AddRefs(syncSettings));
4727 NS_ENSURE_SUCCESS(rv, rv);
4729 nsCOMPtr<nsIMutableArray> selectedPlaylists =
4730 do_CreateInstance(
"@songbirdnest.com/moz/xpcom/threadsafe-array;1", &rv);
4732 PRUint32 audioMgmtType;
4734 rv = GetMediaSettingsValues(syncSettings,
4739 NS_ENSURE_SUCCESS(rv, rv);
4741 PRUint32 videoMgmtType;
4743 rv = GetMediaSettingsValues(syncSettings,
4748 NS_ENSURE_SUCCESS(rv, rv);
4751 PRUint32 exportAllMediaTypes = 0;
4759 PRUint32 importAllMediaTypes = 0;
4765 nsCOMPtr<sbIDeviceLibrarySyncDiff> syncDiff =
4768 rv = syncDiff->GenerateSyncLists(exportAllMediaTypes,
4769 importAllMediaTypes,
4775 NS_ENSURE_SUCCESS(rv, rv);
4782 nsIArray * aMediaLists)
4784 NS_ENSURE_ARG_POINTER(aLibrary);
4785 NS_ENSURE_ARG_POINTER(aMediaLists);
4791 rv = aMediaLists->GetLength(&count);
4792 NS_ENSURE_SUCCESS(rv, rv);
4794 for (PRUint32
i = 0;
i <
count;
i++) {
4798 nsCOMPtr<sbILibraryChange> change =
4799 do_QueryElementAt(aMediaLists,
i, &rv);
4801 nsCOMPtr<sbIMediaItem> libMediaItem;
4802 rv = change->GetSourceItem(getter_AddRefs(libMediaItem));
4803 NS_ENSURE_SUCCESS(rv, rv);
4805 nsCOMPtr<sbIMediaList> libMediaList = do_QueryInterface(libMediaItem, &rv);
4806 NS_ENSURE_SUCCESS(rv, rv);
4810 rv = libMediaList->GetName(listName);
4811 NS_ENSURE_SUCCESS(rv, rv);
4813 nsCOMPtr<sbIMutablePropertyArray>
properties =
4815 NS_ENSURE_SUCCESS(rv, rv);
4819 NS_ENSURE_SUCCESS(rv, rv);
4822 nsCOMPtr<sbIMediaList> newMediaList;
4823 rv = aLibrary->CreateMediaList(NS_LITERAL_STRING(
"simple"),
4825 getter_AddRefs(newMediaList));
4826 NS_ENSURE_SUCCESS(rv, rv);
4831 NS_ENSURE_SUCCESS(rv, rv);
4834 NS_ENSURE_SUCCESS(rv, rv);
4843 NS_ENSURE_ARG_POINTER(aMediaLists);
4848 rv = aMediaLists->GetLength(&count);
4849 NS_ENSURE_SUCCESS(rv, rv);
4851 for (PRUint32
i = 0;
i <
count;
i++) {
4856 nsCOMPtr<sbILibraryChange> change =
4857 do_QueryElementAt(aMediaLists,
i, &rv);
4858 if (NS_FAILED(rv)) {
4859 NS_WARNING(
"Unable to retrieve update change from array");
4862 nsCOMPtr<sbIMediaItem> destItem;
4863 rv = change->GetDestinationItem(getter_AddRefs(destItem));
4864 NS_ENSURE_SUCCESS(rv, rv);
4866 nsCOMPtr<sbIMediaList> destList = do_QueryInterface(destItem , &rv);
4867 NS_ENSURE_SUCCESS(rv, rv);
4869 rv = destList->Clear();
4870 NS_ENSURE_SUCCESS(rv, rv);
4872 nsCOMPtr<sbIMediaItem> sourceItem;
4873 rv = change->GetSourceItem(getter_AddRefs(sourceItem));
4874 NS_ENSURE_SUCCESS(rv, rv);
4876 nsCOMPtr<sbIMediaList> sourceList = do_QueryInterface(sourceItem, &rv);
4877 NS_ENSURE_SUCCESS(rv, rv);
4880 rv = sourceList->GetName(name);
4881 NS_ENSURE_SUCCESS(rv, rv);
4883 rv = destList->SetName(name);
4884 NS_ENSURE_SUCCESS(rv, rv);
4888 NS_ENSURE_SUCCESS(rv, rv);
4898 NS_ENSURE_ARG_POINTER(aDevLibrary);
4899 NS_ENSURE_ARG_POINTER(aChangeset);
4905 if (NS_FAILED(rv)) {
4909 NS_ENSURE_SUCCESS(rv, rv);
4911 nsCOMPtr<sbIDeviceStatus> status;
4912 rv = GetCurrentStatus(getter_AddRefs(status));
4913 NS_ENSURE_SUCCESS(rv, rv);
4916 NS_ENSURE_SUCCESS(rv, rv);
4921 nsCOMPtr<nsIMutableArray> addMediaLists =
4922 do_CreateInstance(
"@songbirdnest.com/moz/xpcom/threadsafe-array;1", &rv);
4923 NS_ENSURE_SUCCESS(rv, rv);
4924 nsCOMPtr<nsIMutableArray> removeItemList =
4925 do_CreateInstance(
"@songbirdnest.com/moz/xpcom/threadsafe-array;1", &rv);
4926 NS_ENSURE_SUCCESS(rv, rv);
4927 nsCOMPtr<nsIMutableArray> addItemList =
4928 do_CreateInstance(
"@songbirdnest.com/moz/xpcom/threadsafe-array;1", &rv);
4929 NS_ENSURE_SUCCESS(rv, rv);
4930 nsCOMPtr<nsIMutableArray> updateMediaLists =
4931 do_CreateInstance(
"@songbirdnest.com/moz/xpcom/threadsafe-array;1", &rv);
4932 NS_ENSURE_SUCCESS(rv, rv);
4937 nsCOMPtr<nsIArray> changeList;
4938 PRUint32 changeCount;
4939 rv = aChangeset->GetChanges(getter_AddRefs(changeList));
4940 NS_ENSURE_SUCCESS(rv, rv);
4941 rv = changeList->GetLength(&changeCount);
4942 NS_ENSURE_SUCCESS(rv, rv);
4945 for (PRUint32
i = 0;
i < changeCount;
i++) {
4950 nsCOMPtr<sbILibraryChange> change = do_QueryElementAt(changeList,
i, &rv);
4951 NS_ENSURE_SUCCESS(rv, rv);
4955 rv = change->GetOperation(&operation);
4956 NS_ENSURE_SUCCESS(rv, rv);
4960 rv = change->GetItemIsList(&itemIsList);
4961 NS_ENSURE_SUCCESS(rv, rv);
4964 if (itemIsList && !playlistsSupported) {
4977 nsCOMPtr<sbIMediaItem> srcItem;
4978 rv = change->GetSourceItem(getter_AddRefs(srcItem));
4979 NS_ENSURE_SUCCESS(rv, rv);
4982 nsCOMPtr<sbIMediaList> mediaList = do_QueryInterface(srcItem,
4984 NS_ENSURE_SUCCESS(rv, rv);
4988 rv = mediaList->GetIsEmpty(&isEmpty);
4989 NS_ENSURE_SUCCESS(rv, rv);
4992 rv = addMediaLists->AppendElement(change, PR_FALSE);
4993 NS_ENSURE_SUCCESS(rv, rv);
4996 rv = addItemList->AppendElement(srcItem, PR_FALSE);
4997 NS_ENSURE_SUCCESS(rv, rv);
5003 nsCOMPtr<sbIMediaItem> destItem;
5004 rv = change->GetDestinationItem(getter_AddRefs(destItem));
5005 NS_ENSURE_SUCCESS(rv, rv);
5007 nsCOMPtr<sbIMediaItem> srcItem;
5008 rv = change->GetSourceItem(getter_AddRefs(srcItem));
5009 NS_ENSURE_SUCCESS(rv, rv);
5012 nsCOMPtr<sbIMediaList> mediaList = do_QueryInterface(srcItem, &rv);
5013 NS_ENSURE_SUCCESS(rv, rv);
5016 rv = mediaList->GetIsEmpty(&isEmpty);
5017 NS_ENSURE_SUCCESS(rv, rv);
5025 nsCOMPtr<sbIMediaList> destItemAsList = do_QueryInterface(destItem);
5026 NS_ENSURE_SUCCESS(rv, rv);
5028 if (destItemAsList) {
5029 rv = updateMediaLists->AppendElement(change, PR_FALSE);
5030 NS_ENSURE_SUCCESS(rv, rv);
5036 rv = change->GetProperties(getter_AddRefs(properties));
5037 NS_ENSURE_SUCCESS(rv, rv);
5039 nsCOMPtr<nsISimpleEnumerator> propEnum;
5040 rv = properties->Enumerate(getter_AddRefs(propEnum));
5041 NS_ENSURE_SUCCESS(rv, rv);
5044 while (NS_SUCCEEDED(propEnum->HasMoreElements(&hasMoreElements)) &&
5046 nsCOMPtr<sbIPropertyChange> propertyChange;
5048 rv = propEnum->GetNext(getter_AddRefs(propertyChange));
5049 NS_ENSURE_SUCCESS(rv, rv);
5051 nsString propertyId;
5052 nsString propertyValue;
5054 rv = propertyChange->GetId(propertyId);
5055 NS_ENSURE_SUCCESS(rv, rv);
5057 rv = propertyChange->GetNewValue(propertyValue);
5058 NS_ENSURE_SUCCESS(rv, rv);
5060 rv = destItem->SetProperty(propertyId, propertyValue);
5061 NS_ENSURE_SUCCESS(rv, rv);
5075 nsCOMPtr<nsISimpleEnumerator> itemEnum;
5076 rv = removeItemList->Enumerate(getter_AddRefs(itemEnum));
5077 NS_ENSURE_SUCCESS(rv, rv);
5078 rv = aDevLibrary->RemoveSome(itemEnum);
5079 NS_ENSURE_SUCCESS(rv, rv);
5082 rv = addItemList->Enumerate(getter_AddRefs(itemEnum));
5083 NS_ENSURE_SUCCESS(rv, rv);
5084 rv = aDevLibrary->AddSome(itemEnum);
5085 NS_ENSURE_SUCCESS(rv, rv);
5090 NS_LITERAL_STRING(
"1"));
5091 NS_ASSERTION(NS_SUCCEEDED(rv),
"Failed to remove partial added items");
5096 NS_ENSURE_SUCCESS(rv, rv);
5099 NS_ENSURE_SUCCESS(rv, rv);
5107 TRACE((
"%s", __FUNCTION__));
5108 NS_ENSURE_ARG_POINTER(aMediaItem);
5118 nsAutoString originItemGuid;
5121 NS_ENSURE_SUCCESS(rv, rv);
5127 nsAutoString wasInMainLibrary;
5128 rv = aMediaItem->GetProperty(
5131 NS_ENSURE_SUCCESS(rv, rv);
5134 nsAutoString isInMainLibrary;
5135 if (originItemGuid.IsEmpty()) {
5136 isInMainLibrary.AppendInt(0);
5139 nsCOMPtr<sbIMediaItem> originItem;
5143 mMainLibrary->GetMediaItem(originItemGuid, getter_AddRefs(originItem));
5144 isInMainLibrary.AppendInt(originItem != NULL);
5148 if (isInMainLibrary != wasInMainLibrary) {
5149 rv = aMediaItem->SetProperty(
5152 NS_ENSURE_SUCCESS(rv, rv);
5161 TRACE((
"%s", __FUNCTION__));
5162 NS_ENSURE_ARG_POINTER(aEject);
5166 sbPrefBranch prefBranch(
"songbird.device.dialog.", &rv);
5167 NS_ENSURE_SUCCESS(rv, rv);
5169 PRBool hide_dialog = prefBranch.
GetBoolPref(
"eject_while_playing", PR_FALSE);
5178 nsCOMPtr<sbIPrompter> prompter =
5179 do_GetService(
"@songbirdnest.com/Songbird/Prompter;1");
5180 NS_ENSURE_SUCCESS(rv, rv);
5181 rv = prompter->SetWaitForWindow(PR_TRUE);
5182 NS_ENSURE_SUCCESS(rv, rv);
5188 nsString
const& title = bundle.
Get(
"device.dialog.eject_while_playing.title");
5191 nsString deviceName;
5192 rv = GetName(deviceName);
5193 NS_ENSURE_SUCCESS(rv, rv);
5196 nsTArray<nsString> formatParams;
5197 formatParams.AppendElement(deviceName);
5199 bundle.
Format(
"device.dialog.eject_while_playing.message", formatParams);
5202 nsString
const&
eject = bundle.
Get(
"device.dialog.eject_while_playing.eject");
5205 nsString
const&
check =
5206 bundle.
Get(
"device.dialog.eject_while_playing.dontask");
5210 rv = prompter->ConfirmEx(nsnull, title.get(), message.get(),
5211 (nsIPromptService::BUTTON_POS_0 *
5212 nsIPromptService::BUTTON_TITLE_IS_STRING) +
5213 (nsIPromptService::BUTTON_POS_1 *
5214 nsIPromptService::BUTTON_TITLE_CANCEL), eject.get(), nsnull, nsnull,
5215 check.get(), &hide_dialog, &accept);
5216 NS_ENSURE_SUCCESS(rv, rv);
5221 rv = prefBranch.
SetBoolPref(
"eject_while_playing", hide_dialog);
5222 NS_ENSURE_SUCCESS(rv, rv);
5236 nsIURI* aContentSrcBaseURI,
5237 nsIURI* aWriteSrcURI,
5238 nsIURI ** aContentSrc)
5240 TRACE((
"%s", __FUNCTION__));
5242 NS_ENSURE_ARG_POINTER(aWriteDstItem);
5243 NS_ENSURE_ARG_POINTER(aContentSrcBaseURI);
5244 NS_ENSURE_ARG_POINTER(aContentSrc);
5247 nsString kIllegalChars =
5248 NS_ConvertASCIItoUTF16(FILE_ILLEGAL_CHARACTERS);
5249 nsCOMPtr<nsIURI> writeSrcURI = aWriteSrcURI;
5255 nsCOMPtr<sbIMediaItem> writeSrcItem;
5257 getter_AddRefs(writeSrcItem));
5258 if (NS_FAILED(rv)) {
5261 rv = aWriteDstItem->GetContentSrc(getter_AddRefs(writeSrcURI));
5262 NS_ENSURE_SUCCESS(rv, rv);
5266 rv = writeSrcItem->GetContentSrc(getter_AddRefs(writeSrcURI));
5267 NS_ENSURE_SUCCESS(rv, rv);
5272 nsCOMPtr<nsIFile> writeSrcFile;
5273 nsCOMPtr<nsIFileURL> writeSrcFileURL = do_QueryInterface(writeSrcURI, &rv);
5274 if (NS_SUCCEEDED(rv)) {
5276 rv = writeSrcFileURL->GetFile(getter_AddRefs(writeSrcFile));
5277 NS_ENSURE_SUCCESS(rv, rv);
5280 PRBool fileExists = PR_FALSE;
5281 rv = writeSrcFile->Exists(&fileExists);
5282 NS_ENSURE_SUCCESS(rv, rv);
5290 nsCOMPtr<sbILibrary> destLibrary;
5291 rv = aWriteDstItem->GetLibrary(getter_AddRefs(destLibrary));
5292 NS_ENSURE_SUCCESS(rv, rv);
5294 rv = DeleteItem(destLibrary, aWriteDstItem);
5295 NS_ENSURE_SUCCESS(rv, rv);
5297 return NS_ERROR_NOT_AVAILABLE;
5302 nsCOMPtr<sbILibrary> destLibrary;
5303 rv = aWriteDstItem->GetLibrary(getter_AddRefs(destLibrary));
5304 NS_ENSURE_SUCCESS(rv, rv);
5305 nsString destLibGuidStr;
5306 rv = destLibrary->GetGuid(destLibGuidStr);
5307 NS_ENSURE_SUCCESS(rv, rv);
5310 destLibGuid.Parse(NS_LossyConvertUTF16toASCII(destLibGuidStr).
get());
5313 success = mOrganizeLibraryPrefs.Get(destLibGuid, &organizeData);
5316 nsCOMPtr<nsIFile> contentSrcFile;
5318 nsCOMPtr<nsIFileURL> baseFileUrl =
5319 do_QueryInterface(aContentSrcBaseURI, &rv);
5320 NS_ENSURE_SUCCESS(rv, rv);
5321 nsCOMPtr<nsIFile> baseFile;
5322 rv = baseFileUrl->GetFile(getter_AddRefs(baseFile));
5323 NS_ENSURE_SUCCESS(rv, rv);
5326 nsCOMPtr<sbIMediaFileManager> fileMgr =
5328 NS_ENSURE_SUCCESS(rv, rv);
5330 NS_NAMED_LITERAL_STRING(KEY_MEDIA_FOLDER,
"media-folder");
5331 NS_NAMED_LITERAL_STRING(KEY_FILE_FORMAT,
"file-format");
5332 NS_NAMED_LITERAL_STRING(KEY_DIR_FORMAT,
"dir-format");
5333 nsCOMPtr<nsIWritablePropertyBag2> writableBag =
5334 do_CreateInstance(
"@songbirdnest.com/moz/xpcom/sbpropertybag;1");
5335 NS_ENSURE_TRUE(writableBag, NS_ERROR_OUT_OF_MEMORY);
5336 rv = writableBag->SetPropertyAsInterface(KEY_MEDIA_FOLDER, baseFile);
5337 NS_ENSURE_SUCCESS(rv, rv);
5338 rv = writableBag->SetPropertyAsACString(KEY_FILE_FORMAT, organizeData->
fileFormat);
5339 NS_ENSURE_SUCCESS(rv, rv);
5340 rv = writableBag->SetPropertyAsACString(KEY_DIR_FORMAT, organizeData->
dirFormat);
5341 NS_ENSURE_SUCCESS(rv, rv);
5342 rv = fileMgr->Init(writableBag);
5343 NS_ENSURE_SUCCESS(rv, rv);
5345 rv = fileMgr->GetManagedPath(aWriteDstItem,
5348 getter_AddRefs(contentSrcFile));
5349 NS_ENSURE_SUCCESS(rv, rv);
5351 nsCOMPtr<nsIFile> parentDir;
5352 rv = contentSrcFile->GetParent(getter_AddRefs(parentDir));
5353 NS_ENSURE_SUCCESS(rv, rv);
5354 rv = parentDir->Create(nsIFile::DIRECTORY_TYPE, 0755);
5355 if (rv != NS_ERROR_FILE_ALREADY_EXISTS) {
5356 NS_ENSURE_SUCCESS(rv, rv);
5362 nsAutoString writeSrcFileName;
5364 nsCOMPtr<nsIFile> canonicalFile;
5365 nsCOMPtr<sbILibraryUtils> libUtils =
5366 do_GetService(
"@songbirdnest.com/Songbird/library/Manager;1", &rv);
5367 rv = libUtils->GetCanonicalPath(writeSrcFile,
5368 getter_AddRefs(canonicalFile));
5369 NS_ENSURE_SUCCESS(rv, rv);
5370 rv = canonicalFile->GetLeafName(writeSrcFileName);
5371 NS_ENSURE_SUCCESS(rv, rv);
5376 NS_ENSURE_SUCCESS(rv, rv);
5377 nsCAutoString fileName;
5378 rv = writeSrcURL->GetFileName(fileName);
5379 NS_ENSURE_SUCCESS(rv, rv);
5380 writeSrcFileName = NS_ConvertUTF8toUTF16(fileName);
5387 nsCOMPtr<nsIFileURL>
5388 contentSrcBaseFileURL = do_QueryInterface(aContentSrcBaseURI, &rv);
5389 NS_ENSURE_SUCCESS(rv, rv);
5390 nsCOMPtr<nsIFile> contentSrcBaseFile;
5391 rv = contentSrcBaseFileURL->GetFile(getter_AddRefs(contentSrcBaseFile));
5392 NS_ENSURE_SUCCESS(rv, rv);
5395 rv = contentSrcBaseFile->Clone(getter_AddRefs(contentSrcFile));
5396 NS_ENSURE_SUCCESS(rv, rv);
5399 rv = contentSrcFile->Append(writeSrcFileName);
5400 NS_ENSURE_SUCCESS(rv, rv);
5405 rv = contentSrcFile->Exists(&exists);
5406 NS_ENSURE_SUCCESS(rv, rv);
5411 PRUint32 permissions;
5412 nsCOMPtr<nsIFile> parent;
5413 rv = contentSrcFile->GetParent(getter_AddRefs(parent));
5414 NS_ENSURE_SUCCESS(rv, rv);
5415 rv = parent->GetPermissions(&permissions);
5416 NS_ENSURE_SUCCESS(rv, rv);
5419 rv = contentSrcFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, permissions);
5420 NS_ENSURE_SUCCESS(rv, rv);
5424 NS_ENSURE_SUCCESS(rv, rv);
5434 nsRefPtr<MediaListListenerAttachingEnumerator> enumerator =
5437 NS_ENSURE_TRUE(enumerator, NS_ERROR_OUT_OF_MEMORY);
5440 NS_LITERAL_STRING(
"1"),
5443 NS_ENSURE_SUCCESS(rv, rv);
5449 TRACE((
"%s", __FUNCTION__));
5455 NS_ENSURE_SUCCESS(rv, rv);
5467 NS_ENSURE_SUCCESS(rv, rv);
5471 nsITimer::TYPE_ONE_SHOT);
5472 NS_ENSURE_SUCCESS(rv, rv);
5481 TRACE((
"%s", __FUNCTION__));
5489 TRACE((
"%s", __FUNCTION__));
5496 nsCOMPtr<sbIPrompter>
5498 NS_ENSURE_SUCCESS(rv, rv);
5499 nsCOMPtr<nsIDOMWindow> dialogWindow;
5500 rv = prompter->OpenDialog
5503 (
"chrome://songbird/content/xul/device/deviceSetupDialog.xul"),
5504 NS_LITERAL_STRING(
"DeviceSetup"),
5505 NS_LITERAL_STRING(
"chrome,centerscreen,modal=yes,titlebar=no"),
5507 getter_AddRefs(dialogWindow));
5508 NS_ENSURE_SUCCESS(rv, rv);
5516 TRACE((
"%s", __FUNCTION__));
5523 nsCOMPtr<nsICategoryManager> catMgr =
5524 do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
5525 NS_ENSURE_SUCCESS(rv, rv);
5527 nsCOMPtr<nsISimpleEnumerator> enumerator;
5529 getter_AddRefs(enumerator));
5530 NS_ENSURE_SUCCESS(rv, rv);
5534 rv = enumerator->HasMoreElements(&hasMore);
5535 NS_ENSURE_SUCCESS(rv, rv);
5538 nsCOMPtr<nsISupports> supports;
5539 rv = enumerator->GetNext(getter_AddRefs(supports));
5540 NS_ENSURE_SUCCESS(rv, rv);
5542 nsCOMPtr<nsISupportsCString>
data = do_QueryInterface(supports, &rv);
5543 NS_ENSURE_SUCCESS(rv, rv);
5545 nsCString entryName;
5546 rv = data->GetData(entryName);
5547 NS_ENSURE_SUCCESS(rv, rv);
5549 nsCString contractId;
5552 getter_Copies(contractId));
5553 NS_ENSURE_SUCCESS(rv, rv);
5555 nsCOMPtr<sbIDeviceInfoRegistrar> infoRegistrar =
5556 do_CreateInstance(contractId.get(), &rv);
5557 NS_ENSURE_SUCCESS(rv, rv);
5560 rv = infoRegistrar->InterestedInDevice(
this, &interested);
5561 NS_ENSURE_SUCCESS(rv, rv);
5564 rv = infoRegistrar->GetType(&type);
5565 NS_ENSURE_SUCCESS(rv, rv);
5572 rv = enumerator->HasMoreElements(&hasMore);
5573 NS_ENSURE_SUCCESS(rv, rv);
5581 TRACE((
"%s", __FUNCTION__));
5588 NS_ENSURE_SUCCESS(rv, rv);
5591 nsCOMPtr<nsIWritablePropertyBag> deviceProperties;
5593 NS_ENSURE_SUCCESS(rv, rv);
5596 nsString defaultName;
5598 NS_ENSURE_SUCCESS(rv, rv);
5600 LOG((
"Default Name: %s", NS_ConvertUTF16toUTF8(defaultName).
get()));
5602 if (!defaultName.IsEmpty()) {
5603 rv = deviceProperties->SetProperty(
5606 NS_ENSURE_SUCCESS(rv, rv);
5610 for (PRUint32
i = 0;
5617 nsAutoPtr<nsString> folderURL(
new nsString());
5618 NS_ENSURE_TRUE(folderURL, NS_ERROR_OUT_OF_MEMORY);
5621 rv =
mInfoRegistrar->GetDeviceFolder(
this, folderContentType, *folderURL);
5622 NS_ENSURE_SUCCESS(rv, rv);
5623 if (!folderURL->IsEmpty()) {
5625 NS_ENSURE_TRUE(success, NS_ERROR_OUT_OF_MEMORY);
5630 nsString excludedFolders;
5632 NS_ENSURE_SUCCESS(rv, rv);
5634 LOG((
"Excluded Folders: %s",
5635 NS_LossyConvertUTF16toASCII(excludedFolders).BeginReading()));
5637 if (!excludedFolders.IsEmpty()) {
5638 rv = deviceProperties->SetProperty(
5641 NS_ENSURE_SUCCESS(rv, rv);
5645 nsCOMPtr<nsIArray> importRules;
5646 rv =
mInfoRegistrar->GetImportRules(
this, getter_AddRefs(importRules));
5647 NS_ENSURE_SUCCESS(rv, rv);
5651 nsCOMPtr<nsIWritablePropertyBag2> devProps2 =
5652 do_QueryInterface(deviceProperties, &rv);
5653 NS_ENSURE_SUCCESS(rv, rv);
5654 rv = devProps2->SetPropertyAsInterface(
5657 NS_ENSURE_SUCCESS(rv, rv);
5664 PRBool supportsFormat;
5665 rv =
mInfoRegistrar->GetDoesDeviceSupportReformat(
this, &supportsFormat);
5666 NS_ENSURE_SUCCESS(rv, rv);
5668 rv = deviceProperties->SetProperty(
5671 NS_ENSURE_SUCCESS(rv, rv);
5683 TRACE((
"%s", __FUNCTION__));
5684 NS_ENSURE_ARG_POINTER(aCapabilities);
5689 NS_ENSURE_SUCCESS(rv, rv);
5693 NS_ENSURE_SUCCESS(rv, rv);
5705 NS_ENSURE_ARG_POINTER(aMediaItem);
5706 NS_ENSURE_ARG_POINTER(aCallback);
5709 nsRefPtr<sbDeviceSupportsItemHelper> helper =
5711 NS_ENSURE_TRUE(helper, NS_ERROR_OUT_OF_MEMORY);
5712 rv = helper->Init(aMediaItem,
this, aCallback);
5713 NS_ENSURE_SUCCESS(rv, rv);
5715 if (!NS_IsMainThread()) {
5716 nsCOMPtr<nsIRunnable> runnable =
5719 RunSupportsMediaItem);
5720 NS_ENSURE_TRUE(runnable, NS_ERROR_OUT_OF_MEMORY);
5721 rv = NS_DispatchToMainThread(runnable);
5722 NS_ENSURE_SUCCESS(rv, rv);
5725 helper->RunSupportsMediaItem();
5733 PRBool aReportErrors,
5737 NS_ENSURE_ARG_POINTER(aMediaItem);
5738 NS_ENSURE_ARG_POINTER(_retval);
5739 if (NS_IsMainThread()) {
5741 NS_ENSURE_ARG_POINTER(aCallback);
5747 nsString contentType;
5748 rv = aMediaItem->GetContentType(contentType);
5749 NS_ENSURE_SUCCESS(rv, rv);
5750 if (contentType.Equals(NS_LITERAL_STRING(
"image"))) {
5752 nsCString sourceFileExtension;
5753 nsCOMPtr<nsIURI> sourceURI;
5754 rv = aMediaItem->GetContentSrc(getter_AddRefs(sourceURI));
5755 NS_ENSURE_SUCCESS(rv, rv);
5756 nsCOMPtr<nsIFileURL> sourceFileURL = do_QueryInterface(sourceURI, &rv);
5757 NS_ENSURE_SUCCESS(rv, rv);
5758 rv = sourceFileURL->GetFileExtension(sourceFileExtension);
5759 NS_ENSURE_SUCCESS(rv, rv);
5760 ToLowerCase(sourceFileExtension);
5763 nsTArray<nsString> fileExtensionList;
5768 NS_ENSURE_SUCCESS(rv, rv);
5771 *_retval = fileExtensionList.Contains
5772 (NS_ConvertUTF8toUTF16(sourceFileExtension));
5779 NS_ENSURE_SUCCESS(rv, rv);
5784 PRUint32
const transcodeType =
5786 bool needsTranscoding =
false;
5803 nsCOMPtr<nsIURI> inputUri;
5804 rv = aMediaItem->GetContentSrc(getter_AddRefs(inputUri));
5805 NS_ENSURE_SUCCESS(rv, rv);
5807 nsCOMPtr<sbIDeviceTranscodingConfigurator> configurator;
5809 getter_AddRefs(configurator));
5810 NS_ENSURE_SUCCESS(rv, rv);
5812 rv = configurator->SetInputUri(inputUri);
5813 NS_ENSURE_SUCCESS(rv, rv);
5814 nsCOMPtr<sbIDevice> device =
5815 do_QueryInterface(NS_ISUPPORTS_CAST(
sbIDevice*,
this), &rv);
5816 NS_ENSURE_SUCCESS(rv, rv);
5817 rv = configurator->SetDevice(device);
5818 NS_ENSURE_SUCCESS(rv, rv);
5820 rv = configurator->DetermineOutputType();
5821 if (NS_SUCCEEDED(rv)) {
5837 nsCOMPtr<sbIMediaInspector> inspector;
5839 NS_ENSURE_SUCCESS(rv, rv);
5841 NS_ENSURE_SUCCESS(rv, rv);
5842 rv = inspector->InspectMediaAsync(aMediaItem);
5843 NS_ENSURE_SUCCESS(rv, rv);
5844 return NS_ERROR_IN_PROGRESS;
5847 nsCOMPtr<sbIMediaFormat> mediaFormat;
5850 getter_AddRefs(mediaFormat));
5851 NS_ENSURE_SUCCESS(rv, rv);
5857 *_retval = (NS_SUCCEEDED(rv) && !needsTranscoding);
5890 nsCOMPtr<sbIMediaItem> mediaItem = request->
item;
5895 NS_ENSURE_SUCCESS(rv, rv);
5897 if (trackType.IsEmpty())
5900 PRBool isSupported = PR_FALSE;
5905 nsRefPtr<sbDeviceStreamingHandler>
listener;
5909 NS_ENSURE_SUCCESS(rv, rv);
5911 rv = listener->CheckTransferable();
5912 NS_ENSURE_SUCCESS(rv, rv);
5915 PRBool isComplete = PR_FALSE;
5916 while (!isComplete) {
5918 nsAutoMonitor monitor(stopWaitMonitor);
5924 isComplete = listener->IsComplete();
5932 isSupported = listener->IsStreamingItemSupported();
5934 NS_ERROR_OUT_OF_MEMORY);
5953 NS_ENSURE_ARG_POINTER(aDefaultLibrary);
5961 NS_ENSURE_ARG_POINTER(aDefaultLibrary);
5969 nsCOMPtr<nsIArray> libraries;
5970 nsCOMPtr<sbIDeviceContent>
content;
5972 rv = GetContent(getter_AddRefs(content));
5973 NS_ENSURE_SUCCESS(rv, rv);
5974 rv = content->GetLibraries(getter_AddRefs(libraries));
5975 NS_ENSURE_SUCCESS(rv, rv);
5976 rv = libraries->IndexOf(0, aDefaultLibrary, &index);
5977 if (rv == NS_ERROR_FAILURE) {
5979 rv = NS_ERROR_ILLEGAL_VALUE;
5981 NS_ENSURE_SUCCESS(rv, rv);
5985 rv = aDefaultLibrary->GetGuid(guid);
5986 NS_ENSURE_SUCCESS(rv, rv);
5987 rv =
SetPreference(NS_LITERAL_STRING(
"default_library_guid"),
5989 NS_ENSURE_SUCCESS(rv, rv);
5993 NS_ENSURE_SUCCESS(rv, rv);
6005 NS_ENSURE_ARG_POINTER(aPrimaryLibrary);
6007 *aPrimaryLibrary = nsnull;
6015 nsIArray **aSupportedProfiles)
6019 aSupportedProfiles);
6024 const nsAString& aPropertyName,
6025 nsIVariant** aPropertyValue)
6027 TRACE((
"%s", __FUNCTION__));
6030 NS_ENSURE_ARG_POINTER(aPropertyValue);
6036 nsCOMPtr<sbITranscodeProfile> transcodeProfile;
6039 getter_AddRefs(transcodeProfile));
6040 NS_ENSURE_SUCCESS(rv, rv);
6043 nsCOMPtr<nsISimpleEnumerator> propEnumerator;
6045 rv = transcodeProfile->GetAudioProperties(getter_AddRefs(properties));
6046 NS_ENSURE_SUCCESS(rv, rv);
6047 rv = properties->Enumerate(getter_AddRefs(propEnumerator));
6048 NS_ENSURE_SUCCESS(rv, rv);
6051 PRBool more = PR_FALSE;
6052 rv = propEnumerator->HasMoreElements(&more);
6053 NS_ENSURE_SUCCESS(rv, rv);
6056 nsCOMPtr<sbITranscodeProfileProperty> property;
6057 rv = propEnumerator->GetNext(getter_AddRefs(property));
6058 NS_ENSURE_SUCCESS(rv, rv);
6061 nsAutoString profilePropName;
6062 rv =
property->GetPropertyName(profilePropName);
6063 NS_ENSURE_SUCCESS(rv, rv);
6066 if (profilePropName.Equals(aPropertyName)) {
6067 rv =
property->GetValue(aPropertyValue);
6068 NS_ENSURE_SUCCESS(rv, rv);
6073 rv = propEnumerator->HasMoreElements(&more);
6074 NS_ENSURE_SUCCESS(rv, rv);
6078 *aPropertyValue = nsnull;
6085 const nsAString& aErrorMessage)
6087 TRACE((
"%s", __FUNCTION__));
6088 NS_ENSURE_ARG_POINTER(aMediaItem);
6092 nsCOMPtr<nsIWritablePropertyBag2> bag =
6093 do_CreateInstance(
"@songbirdnest.com/moz/xpcom/sbpropertybag;1", &rv);
6094 NS_ENSURE_SUCCESS(rv, rv);
6096 rv = bag->SetPropertyAsAString(NS_LITERAL_STRING(
"message"), aErrorMessage);
6097 NS_ENSURE_SUCCESS(rv, rv);
6098 rv = bag->SetPropertyAsInterface(NS_LITERAL_STRING(
"item"), aMediaItem);
6099 NS_ENSURE_SUCCESS(rv, rv);
6104 if (NS_SUCCEEDED(rv)) {
6105 nsCOMPtr<sbITranscodeError> transcodeError;
6109 getter_AddRefs(transcodeError));
6110 NS_ENSURE_SUCCESS(rv, rv);
6111 rv = bag->SetPropertyAsInterface(NS_LITERAL_STRING(
"transcode-error"),
6113 NS_ENSURE_SUCCESS(rv, rv);
6118 NS_ENSURE_SUCCESS(rv, rv);
6126 nsIMutableArray *aArray,
6127 PRUint32 numMimeTypes,
6132 for (PRUint32
i = 0;
i < numMimeTypes;
i++) {
6134 PRUint32 formatTypeCount;
6135 rv = aCapabilities->GetFormatTypes(aContentType,
6136 NS_ConvertASCIItoUTF16(mimeTypes[
i]),
6139 NS_ENSURE_SUCCESS(rv, rv);
6142 for (PRUint32 formatIndex = 0;
6143 formatIndex < formatTypeCount;
6146 nsCOMPtr<sbIImageFormatType> constraints =
6147 do_QueryInterface(formatTypes[formatIndex], &rv);
6148 NS_ENSURE_SUCCESS(rv, rv);
6150 rv = aArray->AppendElement(constraints, PR_FALSE);
6151 NS_ENSURE_SUCCESS(rv, rv);
6161 TRACE((
"%s", __FUNCTION__));
6163 nsCOMPtr<nsIMutableArray> formatConstraints =
6165 NS_ENSURE_SUCCESS(rv, rv);
6168 rv = GetCapabilities(getter_AddRefs(capabilities));
6169 NS_ENSURE_SUCCESS(rv, rv);
6172 PRUint32 numMimeTypes;
6174 &numMimeTypes, &mimeTypes);
6175 NS_ENSURE_SUCCESS(rv, rv);
6184 NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(numMimeTypes, mimeTypes);
6185 NS_ENSURE_SUCCESS (rv, rv);
6187 NS_ADDREF (*aFormats = formatConstraints);
6193 PRBool *aOutShouldLimitSpace)
6195 TRACE((
"%s", __FUNCTION__));
6196 NS_ENSURE_ARG_POINTER(aOutShouldLimitSpace);
6197 *aOutShouldLimitSpace = PR_FALSE;
6200 nsCOMPtr<nsIVariant> shouldEnableVar;
6202 NS_LITERAL_STRING(
"use_music_limit_percent"),
6203 getter_AddRefs(shouldEnableVar));
6204 NS_ENSURE_SUCCESS(rv, rv);
6206 return shouldEnableVar->GetAsBool(aOutShouldLimitSpace);
6211 PRUint32 *aOutLimitPercentage)
6213 TRACE((
"%s", __FUNCTION__));
6214 NS_ENSURE_ARG_POINTER(aOutLimitPercentage);
6215 *aOutLimitPercentage = 100;
6218 nsCOMPtr<nsIVariant> prefValue;
6220 NS_LITERAL_STRING(
"music_limit_percent"),
6221 getter_AddRefs(prefValue));
6222 NS_ENSURE_SUCCESS(rv, rv);
6224 return prefValue->GetAsUint32(aOutLimitPercentage);
6230 TRACE((
"%s", __FUNCTION__));
6240 nsCOMPtr<sbIMediacoreManager> mediacoreManager =
6242 NS_ENSURE_SUCCESS(rv, rv);
6244 nsCOMPtr<sbIMediacoreSequencer> sequencer;
6245 rv = mediacoreManager->GetSequencer(getter_AddRefs(sequencer));
6246 NS_ENSURE_SUCCESS(rv, rv);
6249 nsCOMPtr<sbIMediaItem> mediaItem;
6250 rv = sequencer->GetCurrentItem(getter_AddRefs(mediaItem));
6251 NS_ENSURE_SUCCESS(rv, rv);
6258 nsCOMPtr<sbILibrary> library;
6259 rv = mediaItem->GetLibrary(getter_AddRefs(library));
6260 NS_ENSURE_SUCCESS(rv, rv);
6265 NS_ENSURE_SUCCESS(rv, rv);
6268 nsCOMPtr<sbIMediacoreStatus> status;
6269 rv = mediacoreManager->GetStatus(getter_AddRefs(status));
6270 NS_ENSURE_SUCCESS(rv, rv);
6273 rv = status->GetState(&state);
6274 NS_ENSURE_SUCCESS(rv, rv);
6285 NS_ENSURE_SUCCESS(rv, rv);
6290 nsCOMPtr<sbIMediacorePlaybackControl> playbackControl;
6291 rv = mediacoreManager->GetPlaybackControl(getter_AddRefs(playbackControl));
6292 NS_ENSURE_SUCCESS(rv, rv);
6294 rv = playbackControl->Stop();
6295 NS_ENSURE_SUCCESS(rv, rv);
6304 TRACE((
"%s", __FUNCTION__));
6305 return NS_ERROR_NOT_IMPLEMENTED;
6311 TRACE((
"%s", __FUNCTION__));
6312 NS_ENSURE_ARG_POINTER(_retval);
6313 *_retval = PR_FALSE;
6316 nsCOMPtr<nsIPropertyBag2> deviceProperties;
6318 NS_ENSURE_SUCCESS(rv, rv);
6320 rv = deviceProperties->GetPropertyAsBool(
6323 NS_ENSURE_SUCCESS(rv, rv);
6331 TRACE((
"%s", __FUNCTION__));
6337 NS_ENSURE_SUCCESS(rv, rv);
6341 NS_ENSURE_SUCCESS(rv, rv);
6343 rv = properties->GetPropertyAsAString
6345 NS_ENSURE_SUCCESS(rv, rv);
6352 NS_ENSURE_SUCCESS(rv, rv);
6354 rv = properties->GetPropertyAsAString
6357 NS_ENSURE_SUCCESS(rv, rv);
6362 return GetProductName(aName);
6367 nsAString& aProductName)
6369 TRACE((
"%s [%s]", __FUNCTION__, aDefaultModelNumberString));
6370 NS_ENSURE_ARG_POINTER(aDefaultModelNumberString);
6378 NS_ENSURE_SUCCESS(rv, rv);
6381 nsAutoString vendorName;
6384 NS_ENSURE_SUCCESS(rv, rv);
6387 rv = properties->GetPropertyAsAString
6390 NS_ENSURE_SUCCESS(rv, rv);
6394 nsAutoString modelNumber;
6397 NS_ENSURE_SUCCESS(rv, rv);
6400 rv = properties->GetPropertyAsAString(
6403 NS_ENSURE_SUCCESS(rv, rv);
6405 if (modelNumber.IsEmpty()) {
6411 if (!vendorName.IsEmpty() &&
6412 !StringBeginsWith(modelNumber, vendorName)) {
6413 nsTArray<nsString> params;
6414 NS_ENSURE_TRUE(params.AppendElement(vendorName), NS_ERROR_OUT_OF_MEMORY);
6415 NS_ENSURE_TRUE(params.AppendElement(modelNumber), NS_ERROR_OUT_OF_MEMORY);
6418 productName.Assign(modelNumber);
6422 aProductName.Assign(productName);
6433 nsRefPtr<sbAutoIgnoreWatchFolderPath> autoWFPathIgnore =
6435 NS_ENSURE_TRUE(autoWFPathIgnore, NS_ERROR_OUT_OF_MEMORY);
6437 nsCOMPtr<nsIFileURL> destURL =
6438 do_QueryInterface(aURI, &rv);
6439 if (NS_FAILED(rv)) {
6444 rv = destURL->GetFile(getter_AddRefs(destFile));
6445 if (NS_FAILED(rv)) {
6450 rv = destFile->GetPath(destPath);
6451 NS_ENSURE_SUCCESS(rv, rv);
6453 rv = autoWFPathIgnore->Init(destPath);
6454 NS_ENSURE_SUCCESS(rv, rv);
6456 autoWFPathIgnore.forget(aIgnorePath);
6466 nsCOMPtr<nsIPropertyBag2> deviceProperties;
6468 NS_ENSURE_SUCCESS(rv, rv);
6470 nsString excludedFolderStrings;
6471 rv = deviceProperties->GetPropertyAsAString(
6473 excludedFolderStrings);
6474 if (rv != NS_ERROR_NOT_AVAILABLE) {
6475 NS_ENSURE_SUCCESS(rv, rv);
6477 NS_LITERAL_STRING(
","),
6488 LOG((
"DEVICE FOLDERS:\n========================================\n"));
6499 static const char* contentTypeNameList[] = {
6511 const char* contentTypeName;
6512 char contentTypeString[32];
6513 if (aKey < NS_ARRAY_LENGTH(contentTypeNameList)) {
6514 contentTypeName = contentTypeNameList[aKey];
6517 sprintf(contentTypeString,
"0x%08x", aKey);
6518 contentTypeName = contentTypeString;
6523 LOG((
" %s: %s\n", contentTypeName, NS_ConvertUTF16toUTF8(*aData).get()));
6526 return PL_DHASH_NEXT;
6531 nsCOMPtr<nsIMutableArray> & aItems,
6534 NS_ENSURE_TRUE(aList, PL_DHASH_NEXT);
6535 NS_ENSURE_TRUE(aItems, PL_DHASH_NEXT);
6544 nsCOMPtr<nsISimpleEnumerator> enumerator;
6545 nsresult rv = aItems->Enumerate(getter_AddRefs(enumerator));
6546 NS_ENSURE_SUCCESS(rv, PL_DHASH_STOP);
6548 nsCOMPtr<sbIMediaList> list = do_QueryInterface(aList);
6550 rv = list->RemoveSome(enumerator);
6551 NS_ENSURE_SUCCESS(rv, PL_DHASH_NEXT);
6554 return PL_DHASH_NEXT;
6566 mDevice->SetIgnoreMediaListListeners(PR_FALSE);
6567 mDevice->mLibraryListener->SetIgnoreListener(PR_FALSE);
6574 NS_ENSURE_ARG_POINTER(aChange);
6575 NS_ENSURE_ARG_POINTER(aMediaList);
6579 nsCOMPtr<nsIArray> items;
6580 rv = aChange->GetListItems(getter_AddRefs(items));
6582 if (NS_FAILED(rv)) {
6583 nsCOMPtr<sbIMediaItem> srcItem;
6584 rv = aChange->GetSourceItem(getter_AddRefs(srcItem));
6585 NS_ENSURE_SUCCESS(rv, rv);
6587 nsCOMPtr<sbIMediaList> srcList = do_QueryInterface(srcItem, &rv);
6589 nsRefPtr<sbMediaListEnumArrayHelper> enumHelper =
6591 NS_ENSURE_TRUE(enumHelper, NS_ERROR_OUT_OF_MEMORY);
6593 rv = srcList->EnumerateAllItems(
6596 NS_ENSURE_SUCCESS(rv, rv);
6598 rv = enumHelper->GetMediaItemsArray(getter_AddRefs(items));
6599 NS_ENSURE_SUCCESS(rv, rv);
6601 nsCOMPtr<nsISimpleEnumerator> enumerator;
6602 rv = items->Enumerate(getter_AddRefs(enumerator));
6603 NS_ENSURE_SUCCESS(rv, rv);
6605 rv = aMediaList->AddSome(enumerator);
6606 NS_ENSURE_SUCCESS(rv, rv);
6633 switch ((*iter)->GetType()) {
friend class sbDeviceImages
#define SB_DEVICE_PROPERTY_ACCESS_COMPATIBILITY_MUTABLE
nsCOMPtr< nsIWeakReference > mParentEventTarget
nsCOMPtr< nsIFile > downloadedFile
#define PREF_ORGANIZE_PREFIX
NS_IMETHOD GetPreference(const nsAString &aPrefName, nsIVariant **_retval)
nsresult GetLocalDeviceDir(nsIFile **aLocalDeviceDir)
const unsigned long DELETED
#define SB_DEVICE_PROPERTY_MUSIC_TOTAL_PLAY_TIME
nsresult UpdateVolumeNames()
nsresult HasPreference(nsAString &aPrefName, PRBool *aHasPreference)
#define PREF_DEVICE_LIBRARY_BASE
nsresult GetMediaInspector(sbIMediaInspector **_retval)
nsresult SyncProduceChangeset(TransferRequest *aRequest, sbILibraryChangeset **aExportChangeset, sbILibraryChangeset **aImportChangeset)
nsresult CreateAndDispatchEvent(PRUint32 aType, nsIVariant *aData, PRBool aAsync=PR_TRUE, sbIDeviceEventTarget *aTarget=nsnull)
NS_SCRIPTABLE NS_IMETHOD ResetWarningDialogs(void)
nsresult SetPreferenceInternalNoNotify(const nsAString &aPrefName, nsIVariant *aPrefValue, PRBool *aPrefChanged)
nsresult DownloadRequestItem(TransferRequest *aRequest, PRUint32 aBatchCount, sbDeviceStatusHelper *aDeviceStatusHelper)
#define SB_DEVICE_PROPERTY_IMAGE_USED_SPACE
#define SB_PROPERTY_MEDIALISTNAME
static nsresult LinkCopy(sbIMediaItem *aOriginal, sbIMediaItem *aCopy)
Links a copy to its original. It will take into account the libraries the items belong to...
nsresult SBGetLocalizedFormattedString(nsAString &aString, const nsAString &aKey, const nsTArray< nsString > &aParams, const nsAString &aDefault, class nsIStringBundle *aStringBundle)
nsresult GetLibraryPreferenceBase(sbIDeviceLibrary *aLibrary, nsAString &aPrefBase)
nsresult CreateDeviceLibrary(const nsAString &aId, nsIURI *aLibraryLocation, sbIDeviceLibrary **_retval)
nsAutoPtr< sbDeviceStatusHelper > mStatus
#define SB_PROPERTY_TRACKTYPE
#define SB_DEVICE_PROPERTY_MUSIC_USED_SPACE
PRBool IsPlaylist() const
NS_DECL_ISUPPORTS static NS_DECL_SBIJOBPROGRESSLISTENER nsresult New(sbDeviceProgressListener **aDeviceProgressListener, PRMonitor *aCompleteNotifyMonitor=nsnull, sbDeviceStatusHelper *aDeviceStatusHelper=nsnull)
[UNIMPLEMENTED UNTIL AFTER 0.3]
nsresult DeferredSetupDevice()
nsresult GetExcludedFolders(nsTArray< nsString > &aExcludedFolders)
#define SB_PROPERTY_ORIGINURL
T find_iterator(T start, T end, T target)
NS_IMETHOD GetIsDirectTranscoding(PRBool *aIsDirect)
static TransferRequest * New(PRUint32 aType, sbIMediaItem *aItem, sbIMediaList *aList, PRUint32 aIndex, PRUint32 aOtherIndex, nsISupports *aData)
const PRUint32 CONTENT_IMAGE
nsresult CopyChangedMediaItemsToMediaList(sbILibraryChange *aChange, sbIMediaList *aMediaList)
readonly attribute sbIDeviceContent content
PRLock * mPreviousStateLock
sbDownloadAutoComplete(sbDeviceStatusHelper *aStatus, sbDeviceStatusHelper::Operation aOperation, TransferRequest *aRequest, PRUint32 aBatchCount, sbBaseDevice *aDevice)
nsRefPtr< sbDeviceRequestThreadQueue > mRequestThreadQueue
nsresult SyncMainLibraryFlag(sbIMediaItem *aMediaItem)
nsresult GetMusicFreeSpace(sbILibrary *aLibrary, PRInt64 *aFreeMusicSpace)
nsresult SB_NewTranscodeError(const nsAString &aMessageWithItem, const nsAString &aMessageWithoutItem, const nsAString &aDetails, const nsAString &aUri, sbIMediaItem *aMediaItem, sbITranscodeError **_retval)
#define SB_STORAGEPROPERTYUNITCONVERTER_CONTRACTID
#define SB_DEFAULT_FILE_PERMISSIONS
const unsigned long EVENT_DEVICE_LIBRARY_ADDED
virtual nsresult UpdateProperty(const nsAString &aName)
const NS_PREFSERVICE_CONTRACTID
static nsresult SetLinkedSyncPartner(sbIDevice *aDevice)
NS_IMETHOD GetPrimaryLibrary(sbIDeviceLibrary **aPrimaryLibrary)
static nsRefPtr< sbBaseDeviceMediaListListener > void * aClosure
nsresult ListenToMediaLists(sbILibrary *aLibrary)
#define PREF_ORGANIZE_ENABLED
NS_IMETHOD GetPreviousState(PRUint32 *aState)
nsresult GetDeviceWriteDestURI(sbIMediaItem *aWriteDstItem, nsIURI *aContentSrcBaseURI, nsIURI *aWriteSrcURI, nsIURI **aDestinationURI)
nsresult sbAppendnsIArray(nsIArray *aSrc, nsIMutableArray *aDest, PRBool aWeak=PR_FALSE, PRUint32 aElementsToCopy=0)
virtual nsresult ChangeState(PRUint32 aState)
NS_SCRIPTABLE NS_IMETHOD SetWarningDialogEnabled(const nsAString &aWarning, PRBool aEnabled)
#define SB_DEVICE_PROPERTY_VIDEO_ITEM_COUNT
nsresult AddMediaLists(sbILibrary *aLibrary, nsIArray *aMediaLists)
NS_SCRIPTABLE NS_IMETHOD OpenInputStream(nsIURI *aURI, nsIInputStream **retval)
nsRefPtr< sbBaseDeviceVolume > mPrimaryVolume
#define SB_DEVICE_INFO_REGISTRAR_CATEGORY
nsString Get(const nsAString &aKey, const nsAString &aDefault=SBVoidString())
nsresult CreateTransferRequest(PRUint32 aRequestType, nsIPropertyBag2 *aRequestParameters, TransferRequest **aTransferRequest)
NS_SCRIPTABLE NS_IMETHOD GetWarningDialogEnabled(const nsAString &aWarning, PRBool *_retval)
nsString Format(const nsAString &aKey, nsTArray< nsString > &aParams, const nsAString &aDefault=SBVoidString())
nsresult GetShouldLimitMusicSpace(const nsAString &aPrefBase, PRBool *aOutShouldLimitSpace)
nsresult InitJobProgress(sbIMediaInspector *aInspector, PRUint32 aTranscodeType)
#define SB_DEVICE_PROPERTY_VIDEO_TOTAL_PLAY_TIME
nsCOMPtr< sbIDeviceLibrary > mDefaultLibrary
virtual nsresult ApplyLibraryOrganizePreference(sbIDeviceLibrary *aLibrary, const nsAString &aLibraryPrefName, const nsAString &aLibraryPrefBase, nsIVariant *aPrefValue)
#define SB_DEVICE_PROPERTY_SUPPORTS_REFORMAT
#define SB_THREADSAFE_ARRAY_CONTRACTID
nsresult GetPrefBranch(nsIPrefBranch **aPrefBranch)
static bool IsItemDRMProtected(sbIMediaItem *aMediaItem)
#define SB_DEVICE_PROPERTY_ACCESS_COMPATIBILITY
nsCOMPtr< sbILibrary > mMainLibrary
#define SB_PROPERTY_HIDDEN
Songbird Job Utility Definitions.
nsresult SetBoolPref(const char *aKey, PRBool aValue)
CompatibilityType destinationCompatibility
void nsString_ReplaceChar(nsAString &aString, const nsAString &aOldChars, const PRUnichar aNewChar)
nsresult ReqProcessingStop(nsIRunnable *aShutdownAction)
nsresult SendSyncCompleteRequest()
const unsigned long TRANSCODE_TYPE_AUDIO
nsresult UpdateStreamingItemSupported(Batch &aBatch)
nsresult ChangeState(PRUint32 aState)
nsresult InitializeDeviceLibraryPreferences(sbDeviceLibrary *aDevLib)
static nsresult GetOriginItem(sbIMediaItem *aItem, sbIMediaItem **_retval)
PRUint32 mCanTranscodeAudio
nsRefPtr< sbBaseDeviceLibraryListener > mLibraryListener
nsresult do_GetProxyForObject(nsIEventTarget *aTarget, REFNSIID aIID, nsISupports *aObj, PRInt32 aProxyType, void **aProxyObject)
#define SB_DEVICE_PROPERTY_EXCLUDED_FOLDERS
NS_IMETHOD SyncLibraries(void)
#define SB_DEVICE_PROPERTY_MANUFACTURER
void SetDownloadJob(sbIMediaItemDownloadJob *aDownloadJob)
Songbird Variant Utility Definitions.
friend class sbDeviceTranscoding
nsresult SyncCreateAndSyncToList(sbILibrary *aSrcLib, sbIDeviceLibrary *aDstLib, PRInt64 aAvailableSpace)
#define SONGBIRD_PROMPTER_CONTRACTID
static nsresult DispatchDownloadError(sbBaseDevice *aDevice, nsAString const &aMessage, sbIMediaItem *aItem)
virtual nsresult GetDeviceSettingsDocument(class nsIDOMDocument **aDeviceSettingsDocument)
nsresult SyncGetSyncItemSizes(sbIDeviceLibrary *aDestLibrary, sbILibraryChangeset *aChangeset, PRInt64 aAvailableSpace, PRUint32 &aLastChangeThatFit, PRInt64 &aTotalSyncSize)
#define SB_DEVICE_PROPERTY_DEFAULT_NAME
const unsigned long MEDIATYPE_AUDIO
static nsresult QueryUserSpaceExceeded(sbIDevice *aDevice, sbIDeviceLibrary *aLibrary, PRInt64 aSpaceNeeded, PRInt64 aSpaceAvailable, PRBool *aAbort)
static nsresult AddAlbumArtFormats(PRUint32 aContentType, sbIDeviceCapabilities *aCapabilities, nsIMutableArray *aArray, PRUint32 numMimeTypes, char **mimeTypes)
#define SB_PROPERTY_ISSORTABLE
const unsigned long EVENT_DEVICE_FILE_MISSING
nsRefPtr< sbBaseDeviceVolume > mDefaultVolume
nsresult ListenToList(sbIMediaList *aList)
nsresult GetCapabilitiesPreference(nsIVariant **aCapabilities)
PRUint32 mInfoRegistrarType
nsresult RegisterDeviceInfo()
nsresult GetNameBase(nsAString &aName)
virtual nsresult ApplyDeviceSettingsDocument()
const PRUint32 CONTENT_PLAYLIST
sbDeviceTranscoding * mDeviceTranscoding
friend class sbBaseDeviceInitHelper
static sbDeviceRequestThreadQueue * New()
#define SB_DEVICE_PROPERTY_IMPORT_RULES
#define PREF_ORGANIZE_DIR_FORMAT
const unsigned long MEDIATYPE_IMAGE
static const PRUint32 SYNC_PLAYLIST_AVAILABLE_PCT
const unsigned long MEDIATYPE_VIDEO
#define SB_PROPERTY_LAST_SYNC_TIME
static PLDHashOperator RemoveLibraryEnumerator(nsISupports *aList, nsCOMPtr< nsIMutableArray > &aItems, void *aUserArg)
const unsigned long REQUEST_READ
const unsigned long TRANSCODE_TYPE_AUDIO_VIDEO
virtual PRBool IsRequestAborted()
#define SB_DEVICE_PROPERTY_MUSIC_ITEM_COUNT
const unsigned long STATE_UPLOAD_PAUSED
nsresult ApplyDeviceSettingsToProperty(class nsIDOMDocument *aDeviceSettingsDocument, const nsAString &aPropertyName)
nsresult GetLibraryPreferenceName(const nsAString &aPrefName, nsAString &aLibraryPrefName)
const PRUint32 CONTENT_VIDEO
NS_IMETHOD GetState(PRUint32 *aState)
readonly attribute sbIDeviceCapabilities capabilities
sbDeviceTranscoding * GetDeviceTranscoding() const
nsresult PushRequest(const PRUint32 aType, sbIMediaItem *aItem=nsnull, sbIMediaList *aList=nsnull, PRUint32 aIndex=PR_UINT32_MAX, PRUint32 aOtherIndex=PR_UINT32_MAX, nsISupports *aData=nsnull)
virtual nsresult UpdateProperties()
nsresult GetDeviceTranscodingProperty(PRUint32 aTranscodeType, const nsAString &aPropertyName, nsIVariant **aPropertyValue)
virtual nsresult ApplyPreference(const nsAString &aPrefName, nsIVariant *aPrefValue)
nsresult SyncGetSyncAvailableSpace(sbILibrary *aLibrary, PRInt64 *aAvailableSpace)
nsresult UpdateLibraryProperty(sbILibrary *aLibrary, const nsAString &aPropertyID, const nsAString &aPropertyValue)
const_iterator end() const
nsresult GetPrefBranchRoot(nsACString &aRoot)
nsresult GetMediaFormat(PRUint32 aTranscodeType, sbIMediaItem *aMediaItem, sbIMediaFormat **aMediaFormat)
nsresult GetPreferenceInternal(nsIPrefBranch *aPrefBranch, const nsAString &aPrefName, nsIVariant **_retval)
void SetIsCountable(bool aIsCountable)
nsresult ReqProcessingStart()
const unsigned long REQUEST_WRITE
const unsigned long STATE_DOWNLOADING
nsresult GetLibraryPreference(sbIDeviceLibrary *aLibrary, const nsAString &aLibraryPrefName, nsIVariant **aPrefValue)
Songbird Device Progress Listener Definitions.
const unsigned long REQUEST_DELETE
NS_IMETHOD SupportsMediaItem(sbIMediaItem *aMediaItem, sbIDeviceSupportsItemCallback *aCallback)
virtual nsresult InitDevice()
virtual nsresult CheckAccess(sbIDeviceLibrary *aDevLib)
nsresult GetGUID(nsAString &aGUID)
nsresult GetMusicLimitSpacePercent(const nsAString &aPrefBase, PRUint32 *aOutLimitPercentage)
const sbCreateProxiedComponent do_ProxiedGetService(const nsCID &aCID, nsresult *error=0)
#define SB_PROPERTY_UILIMITTYPE
static nsresult GetDeviceWriteLength(sbIDeviceLibrary *aDeviceLibrary, sbIMediaItem *aMediaItem, PRUint64 *aWriteLength)
RequestItems::const_iterator const_iterator
sbMainThreadQueryInterface do_MainThreadQueryInterface(nsISupports *aSupports, nsresult *aResult=nsnull)
nsresult UnignoreMediaItem(sbIMediaItem *aItem)
NS_IMETHOD GetDefaultLibrary(sbIDeviceLibrary **aDefaultLibrary)
readonly attribute AString name
const unsigned long STATE_CANCEL
static bool ArePlaylistsSupported(sbIDevice *aDevice)
virtual nsresult ApplyLibraryPreference(sbIDeviceLibrary *aLibrary, const nsAString &aLibraryPrefName, nsIVariant *aPrefValue)
nsresult GetRequestTemporaryFileFactory(TransferRequest *aRequest, sbITemporaryFileFactory **aTemporaryFileFactory)
#define SB_PROPERTY_CONTENTTYPE
void SetResult(nsresult aResult)
~sbDownloadAutoComplete()
nsresult HandleSyncCompletedRequest(TransferRequest *aRequest)
virtual nsresult InitializeProperties()
virtual nsresult GetItemContentType(sbIMediaItem *aMediaItem, PRUint32 *aContentType)
void nsString_Split(const nsAString &aString, const nsAString &aDelimiter, nsTArray< nsString > &aSubStringArray)
sbBaseDeviceInitHelper(sbBaseDevice *aDevice)
const unsigned long REQUEST_SYNC_COMPLETE
static nsresult sbInvalidateFileURLCache(nsIFileURL *aFileURL)
nsCOMPtr< nsITimer > mDeferredSetupDeviceTimer
const unsigned long EVENT_DEVICE_TRANSCODE_ERROR
nsresult PromptForEjectDuringPlayback(PRBool *aEject)
nsresult RegenerateMediaURL(sbIMediaItem *aItem, nsIURI **_retval)
#define SB_DEVICE_PROPERTY_BASE
nsInterfaceHashtableMT< nsStringHashKey, sbBaseDeviceVolume > mVolumeGUIDTable
nsDataHashtableMT< nsISupportsHashKey, nsRefPtr< sbBaseDeviceMediaListListener > > mMediaListListeners
PRUint32 mMusicLimitPercent
#define SB_TEMPORARYFILEFACTORY_CONTRACTID
#define SB_DEVICE_PROPERTY_NS
_dialogDatepicker settings
static nsresult GetFormatTypeForItem(sbIMediaItem *aItem, sbExtensionToContentFormatEntry_t &aFormatType, PRUint32 &aBitRate, PRUint32 &aSampleRate)
For a media item, get format information describing it (extension, mime type, etc.
nsresult GetPreferenceLibrary(const nsAString &aPrefName, sbIDeviceLibrary **aLibrary, nsAString &aLibraryPrefBase)
nsresult SyncCreateSyncMediaList(sbILibrary *aSrcLib, sbIDeviceLibrary *aDstLib, PRInt64 aAvailableSpace, sbIMediaList **aSyncMediaList)
#define SB_DEVICE_PROPERTY_IMAGE_ITEM_COUNT
const unsigned long STATE_IDLE
const unsigned long EVENT_DEVICE_LIBRARY_REMOVED
const unsigned long SYNC_TYPE_AUDIO
static nsresult SuggestUniqueNameForPlaylist(sbILibrary *aLibrary, nsAString const &aListName, nsAString &aName)
Suggest a unique name for playlist.
bool CheckAndResetRequestAbort()
NS_IMETHOD CancelRequests()
nsCOMPtr< sbIDeviceInfoRegistrar > mInfoRegistrar
#define SB_DEVICE_PROPERTY_CAPACITY
nsresult GetRemovable(PRInt32 *aRemovable)
#define PREF_DEVICE_PREFERENCES_BRANCH
#define SB_PROPERTY_ORIGIN_IS_IN_MAIN_LIBRARY
virtual nsresult SupportsMediaItemDRM(sbIMediaItem *aMediaItem, PRBool aReportErrors, PRBool *_retval)
PRUint32 mPerTrackOverhead
const unsigned long MODIFIED
nsresult GetDeviceLibrary(sbIDeviceLibrary **aDeviceLibrary)
#define SB_PROPERTY_DEVICE_LIBRARY_GUID
#define SB_DEVICE_PROPERTY_NAME
Media library abstraction.
nsresult GetProductNameBase(char const *aDefaultModelNumberString, nsAString &aProductName)
attribute unsigned long state
const unsigned long EVENT_DEVICE_STATE_CHANGED
NS_IMETHOD GetIsBusy(PRBool *aIsBusy)
nsresult SetIgnoreMediaListListeners(PRBool aIgnoreListener)
const unsigned long STATE_MOUNTING
nsresult ApplyDeviceSettingsDeviceInfo(class nsIDOMDocument *aDeviceSettingsDocument)
nsresult CreateAndDispatchDeviceManagerEvent(PRUint32 aType, nsIVariant *aData, PRBool aAsync=PR_TRUE)
NS_IMETHOD ExportToDevice(sbIDeviceLibrary *aDevLibrary, sbILibraryChangeset *aChangeset)
readonly attribute sbIDeviceProperties properties
Songbird String Bundle Definitions.
nsresult AddVolume(sbBaseDeviceVolume *aVolume)
nsresult RemoveLibrary(sbIDeviceLibrary *aDevLib)
nsresult SetMediaListsHidden(sbIMediaList *aLibrary, PRBool aHidden)
nsClassHashtable< nsUint32HashKey, nsString > mMediaFolderURLTable
nsTArray< nsRefPtr< sbBaseDeviceVolume > > mVolumeList
SimpleArrayEnumerator prototype hasMoreElements
nsresult SyncToMediaList(sbIDeviceLibrary *aDstLib, sbIMediaList *aMediaList)
void SetResult(nsresult aResult)
const PRUint32 FUNCTION_IMAGE_DISPLAY
nsresult IgnoreMediaItem(sbIMediaItem *aItem)
NS_IMETHOD GetSupportsReformat(PRBool *_retval)
nsresult ProcessInfoRegistrars()
static nsresult DeleteByProperty(sbIMediaList *aMediaList, nsAString const &aProperty, nsAString const &aValue)
#define PREF_ORGANIZE_DIR_FORMAT_DEFAULT
nsresult UpdateMediaLists(nsIArray *aMediaLists)
nsresult SetIgnoreLibraryListener(PRBool aIgnoreListener)
nsresult DeleteItem(sbIMediaList *aLibrary, sbIMediaItem *aItem)
const unsigned long STATE_SYNCING
StringArrayEnumerator prototype hasMore
#define SONGBIRD_DEVICELIBRARYSYNCDIFF_CONTRACTID
const unsigned long REQUEST_IMAGESYNC
const unsigned long EVENT_DEVICE_DOWNLOAD_ERROR
static nsresult DoesItemNeedTranscoding(sbExtensionToContentFormatEntry_t &aFormatType, PRUint32 &aBitRate, PRUint32 &aSampleRate, sbIDevice *aDevice, bool &aNeedsTranscoding)
Determine if an item needs transcoding.
const PRUint32 CONTENT_AUDIO
nsresult CreateUniqueMediaFile(nsIURI *aFileURI, nsIFile **aUniqueFile, nsIURI **aUniqueFileURI)
nsDataHashtableMT< nsStringHashKey, PRBool > mTrackSourceTable
NS_IMETHOD SubmitRequest(PRUint32 aRequest, nsIPropertyBag2 *aRequestParameters)
NS_IMETHOD GetCanDisconnect(PRBool *aCanDisconnect)
const unsigned long SYNC_TYPE_VIDEO
static const PRUint32 DEFAULT_PER_TRACK_OVERHEAD
virtual nsresult UpdateVolumeName(sbBaseDeviceVolume *aVolume)
nsresult UpdateDefaultLibrary(sbIDeviceLibrary *aDevLib)
PRInt64 nsString_ToInt64(const nsAString &str, nsresult *rv)
sbDeviceImages * mDeviceImages
nsresult HandleSyncRequest(TransferRequest *aRequest)
static nsresult GetPropertyBag(sbIDevice *aDevice, nsIPropertyBag2 **aProperties)
Songbird Device Status Services Definitions.
const unsigned long STATE_DOWNLOAD_PAUSED
readonly attribute nsIDPtr id
const unsigned long EVENT_DEVICE_PREFS_CHANGED
nsresult IgnoreWatchFolderPath(nsIURI *aURI, sbAutoIgnoreWatchFolderPath **aIgnorePath)
virtual nsresult ApplyDeviceSettings(class nsIDOMDocument *aDeviceSettingsDocument)
nsresult GetSupportedAlbumArtFormats(nsIArray **aFormats)
attribute sbIDeviceLibrary defaultLibrary
nsresult EnsureSpaceForWrite(sbILibraryChangeset *aChangeset, sbIDeviceLibrary *aDevLibrary)
#define SB_PROPERTY_LISTTYPE
static const PRUint32 sbBaseDeviceSupportedFolderContentTypeList[]
NS_IMPL_ISUPPORTS1(MediaListListenerAttachingEnumerator, sbIMediaListEnumerationListener) NS_IMETHODIMP MediaListListenerAttachingEnumerator
nsresult SetPreviousState(PRUint32 aState)
nsresult GetMainLibrary(sbILibrary **aMainLibrary)
virtual nsresult GetSupportedTranscodeProfiles(PRUint32 aType, nsIArray **aSupportedProfiles)
static void DeferredSetupDevice(nsITimer *aTimer, void *aClosure)
nsCOMPtr< sbIMediaItem > item
AutoListenerIgnore(sbBaseDevice *aDevice)
static nsresult GetWritableDeviceProperties(sbIDevice *aDevice, nsIWritablePropertyBag **aProperties)
virtual nsresult GenerateFilename(sbIMediaItem *aItem, nsACString &aFilename)
nsresult ApplyDeviceSettingsToCapabilities(class nsIDOMDocument *aDeviceSettingsDocument)
const unsigned long EVENT_DEVICE_DEFAULT_LIBRARY_CHANGED
nsresult GetVolumeForItem(sbIMediaItem *aItem, sbBaseDeviceVolume **aVolume)
nsCOMPtr< sbITemporaryFileFactory > temporaryFileFactory
virtual nsresult UpdateMediaFolders()
static nsresult GetCapabilities(sbIDeviceCapabilities **aCapabilities, nsIDOMDocument *aDocument, sbIDevice *aDevice=nsnull)
nsresult DispatchTranscodeErrorEvent(sbIMediaItem *aMediaItem, const nsAString &aErrorMessage)
virtual nsresult UpdateStatisticsProperties()
static const PRUint32 DEFER_DEVICE_SETUP_DELAY
#define SB_PROPERTY_ISLIST
nsresult InitializeDeviceLibrary(sbDeviceLibrary *aDevLib, const nsAString &aId, nsIURI *aLibraryLocation)
static PRUint32 GetEqualOperator(sbIPropertyOperator **aOperator)
void SBWriteRequestSplitBatches(const sbBaseDevice::Batch &aInput, sbBaseDevice::Batch &aNonTranscodeItems, sbBaseDevice::Batch &aTranscodeItems, sbBaseDevice::Batch &aPlaylistItems)
NS_IMETHOD ImportFromDevice(sbILibrary *aImportToLibrary, sbILibraryChangeset *aImportChangeset)
#define SB_DEVICE_PROPERTY_MODEL
void SetType(PRUint32 aType)
#define SB_PROPERTY_CONTENTURL
nsresult RegisterDeviceCapabilities(sbIDeviceCapabilities *aCapabilities)
NS_IMETHOD SetState(PRUint32 aState)
nsClassHashtableMT< nsIDHashKey, OrganizeData > mOrganizeLibraryPrefs
nsInterfaceHashtableMT< nsStringHashKey, sbBaseDeviceVolume > mVolumeLibraryGUIDTable
nsresult sbNewFileURI(nsIFile *aFile, nsIURI **aURI)
NS_DECL_ISUPPORTS static NS_DECL_SBIMEDIAITEMCONTROLLERLISTENER nsresult New(sbDeviceStreamingHandler **aDeviceStreamingHandler, sbIMediaItem *aMediaItem, PRMonitor *aCompleteNotifyMonitor)
#define SB_PROPERTY_ORIGINITEMGUID
nsCOMPtr< sbIMediaList > list
#define SB_DEFAULT_DIRECTORY_PERMISSIONS
nsresult GetMusicAvailableSpace(sbILibrary *aLibrary, PRInt64 *aMusicAvailableSpace)
Songbird Device XML Info Definitions.
_getSelectedPageStyle s i
const unsigned long MEDIATYPE_COUNT
readonly attribute AString productName
const_iterator begin() const
static nsresult GetTranscodingConfigurator(PRUint32 aTranscodeType, sbIDeviceTranscodingConfigurator **aConfigurator)
PRUint32 mCanTranscodeVideo
#define PREF_ORGANIZE_FILE_FORMAT
#define SB_DEVICE_PROPERTY_VIDEO_USED_SPACE
NS_IMETHOD SetPreference(const nsAString &aPrefName, nsIVariant *aPrefValue)
void FinalizeDeviceLibrary(sbIDeviceLibrary *aDevLib)
Songbird Device Streaming handler Definitions.
PRInt32 mIgnoreMediaListCount
nsresult SetPreferenceInternal(nsIPrefBranch *aPrefBranch, const nsAString &aPrefName, nsIVariant *aPrefValue, PRBool *aHasChanged)
static PLDHashOperator LogDeviceFoldersEnum(const unsigned int &aKey, nsString *aData, void *aUserArg)
static PRUint32 GetTranscodeType(sbIMediaItem *aMediaItem)
const unsigned long ADDED
NS_IMETHOD SetDefaultLibrary(sbIDeviceLibrary *aDefaultLibrary)
nsresult SelectTranscodeProfile(PRUint32 aTranscodeType, sbITranscodeProfile **aProfile)
Select a transcode profile to use when transcoding to this device.
_updateTextAndScrollDataForFrame aData
friend class sbDeviceSupportsItemHelper
static nsresult AddSupportedFileExtensions(sbIDevice *aDevice, PRUint32 aContentType, nsTArray< nsString > &aFileExtensionList)
static nsRefPtr< sbBaseDeviceMediaListListener > & aData
nsCOMPtr< nsISupports > data
const unsigned long STATE_DISCONNECTED
PRInt64 GetChangeSize(sbIDeviceLibrary *aDestLibrary, sbILibraryChange *aChange)
nsresult UpdateOriginAndContentSrc(TransferRequest *aRequest, nsIURI *aURI)
virtual nsresult OnDefaultLibraryChanged()
void push_back(sbRequestItem *aItem)
PRBool GetIsLibraryPreference(const nsAString &aPrefName)
#define SB_DEVICE_PROPERTY_FREE_SPACE
virtual nsresult GetSupportedTranscodeProfiles(PRUint32 aType, nsIArray **aSupportedProfiles)
nsresult RemoveVolume(sbBaseDeviceVolume *aVolume)
PRBool GetBoolPref(const char *aKey, PRBool aDefault)
nsresult AddLibrary(sbIDeviceLibrary *aDevLib)