sbCDDevice.cpp
Go to the documentation of this file.
1 /*
2  *=BEGIN SONGBIRD GPL
3  *
4  * This file is part of the Songbird web player.
5  *
6  * Copyright(c) 2005-2011 POTI, Inc.
7  * http://www.songbirdnest.com
8  *
9  * This file may be licensed under the terms of of the
10  * GNU General Public License Version 2 (the ``GPL'').
11  *
12  * Software distributed under the License is distributed
13  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14  * express or implied. See the GPL for the specific language
15  * governing rights and limitations.
16  *
17  * You should have received a copy of the GPL along with this
18  * program. If not, go to http://www.gnu.org/licenses/gpl.html
19  * or write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  *=END SONGBIRD GPL
23  */
24 
25 #include "sbCDDevice.h"
26 
27 #include <nsArrayUtils.h>
28 #include <nsComponentManagerUtils.h>
29 #include <nsIClassInfoImpl.h>
30 #include <nsICryptoHash.h>
31 #include <nsIFileURL.h>
32 #include <nsIGenericFactory.h>
33 #include <nsIPropertyBag2.h>
34 #include <nsIWritablePropertyBag2.h>
35 #include <nsIProgrammingLanguage.h>
36 #include <nsIUUIDGenerator.h>
37 #include <nsMemory.h>
38 #include <nsServiceManagerUtils.h>
39 #include <nsThreadUtils.h>
40 #include <nsILocalFile.h>
41 #include <nsISound.h>
42 
43 #include <sbIDeviceEvent.h>
44 #include <sbILibraryManager.h>
45 #include <sbILocalDatabaseLibrary.h>
46 #include <sbIDeviceErrorMonitor.h>
47 
48 #include <sbArrayUtils.h>
49 #include <sbAutoRWLock.h>
50 #include <sbDeviceContent.h>
51 #include <sbDeviceUtils.h>
52 #include <sbDeviceStatusHelper.h>
54 #include <sbStandardProperties.h>
56 #include <sbVariantUtils.h>
57 #include <sbStringUtils.h>
58 #include <sbDebugUtils.h>
59 
60 /*
61  * To log this module, set the following environment variable:
62  * NSPR_LOG_MODULES=sbCDDevice:5
63  */
64 
70 NS_IMPL_CI_INTERFACE_GETTER3(sbCDDevice, sbIDevice,
71  sbIJobProgressListener,
73 
74 // nsIClassInfo implementation.
75 NS_DECL_CLASSINFO(sbCDDevice)
76 NS_IMPL_THREADSAFE_CI(sbCDDevice)
77 
78 #if _MSC_VER
79 // Disable warning about 'this' used in base member initializer list.
80 #pragma warning(disable: 4355)
81 #endif
82 
83 sbCDDevice::sbCDDevice(const nsID & aControllerId,
84  nsIPropertyBag *aProperties)
85  : mConnectLock(nsnull)
86  , mControllerID(aControllerId)
87  , mCreationProperties(aProperties)
88  , mPrefAutoEject(PR_FALSE)
89  , mPrefNotifySound(PR_FALSE)
90 {
91  mPropertiesLock = nsAutoMonitor::NewMonitor("sbCDDevice::mPropertiesLock");
92  NS_ENSURE_TRUE(mPropertiesLock, );
93 
94  SB_PRLOG_SETUP(sbCDDevice);
95 
96  InitRequestHandler();
97 }
98 
100 {
101  nsresult rv;
102  nsCOMPtr<sbILibrary> lib;
103  if (mDeviceLibrary) {
104  // hold on to the underlying local database library
105  rv = mDeviceLibrary->GetLibrary(getter_AddRefs(lib));
106  if (NS_FAILED(rv)) {
107  lib = nsnull;
108  }
109  rv = mDeviceLibrary->Finalize();
110  NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
111  "sbCDDevice failed to finalize the device library");
112  mDeviceLibrary = nsnull;
113  }
114 
115  if (mPropertiesLock) {
116  nsAutoMonitor::DestroyMonitor(mPropertiesLock);
117  mPropertiesLock = nsnull;
118  }
119 
120  if (lib && !mDeviceLibraryPath.IsEmpty()) {
121  NS_ENSURE_SUCCESS(rv, /* void */);
122  nsCOMPtr<sbILocalDatabaseLibrary> localLib = do_QueryInterface(lib, &rv);
123  NS_ENSURE_SUCCESS(rv, /* void */);
124 
125  nsCOMPtr<nsIURI> uri;
126  rv = localLib->GetDatabaseLocation(getter_AddRefs(uri));
127  NS_ENSURE_SUCCESS(rv, /* void */);
128 
129  nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(uri, &rv);
130  NS_ENSURE_SUCCESS(rv, /* void */);
131 
132  nsCOMPtr<nsIFile> libraryFile;
133  rv = fileURL->GetFile(getter_AddRefs(libraryFile));
134  NS_ENSURE_SUCCESS(rv, /* void */);
135 
136  rv = libraryFile->Append(mDeviceLibraryPath);
137  NS_ENSURE_SUCCESS(rv, /* void */);
138 
139  rv = libraryFile->Remove(PR_FALSE);
140  NS_ENSURE_SUCCESS(rv, /* void */);
141  }
142 
143  if (mConnectLock) {
144  PR_DestroyRWLock(mConnectLock);
145  }
146 }
147 
148 nsresult
149 sbCDDevice::CreateDeviceID(nsID* aDeviceID)
150 {
151  nsresult rv;
152 
153  // Initialize the device ID with zeros.
154  PRUint32* buffer = reinterpret_cast<PRUint32*>(aDeviceID);
155  memset(buffer, 0, sizeof(nsID));
156 
157  // Get the identifier from the CD device
158  nsCString identifier;
159  rv = mCDDevice->GetIdentifier(identifier);
160  NS_ENSURE_SUCCESS(rv, rv);
161 
162  // Hash the identifier
163  *buffer = HashString(identifier);
164 
165  return NS_OK;
166 }
167 
168 nsresult
170 {
171  nsresult rv;
172 
173  // Log progress.
174  LOG("Enter sbCDDevice::InitDevice");
175 
176  // Create the connect lock.
177  NS_ENSURE_FALSE(mConnectLock, NS_ERROR_ALREADY_INITIALIZED);
178  mConnectLock = PR_NewRWLock(PR_RWLOCK_RANK_NONE,
179  "sbCDDevice::mConnectLock");
180  NS_ENSURE_TRUE(mConnectLock, NS_ERROR_OUT_OF_MEMORY);
181 
182  // Create and initialize the device content object.
183  mDeviceContent = sbDeviceContent::New();
184  NS_ENSURE_TRUE(mDeviceContent, NS_ERROR_OUT_OF_MEMORY);
185  rv = mDeviceContent->Initialize();
186  NS_ENSURE_SUCCESS(rv, rv);
187 
188  // Get the sbICDDevice reference
189  nsCOMPtr<nsIVariant> deviceVar;
190  rv = mCreationProperties->GetProperty(NS_LITERAL_STRING("sbICDDevice"),
191  getter_AddRefs(deviceVar));
192  NS_ENSURE_SUCCESS(rv, rv);
193 
194  rv = deviceVar->GetAsISupports(getter_AddRefs(mCDDevice));
195  NS_ENSURE_SUCCESS(rv, rv);
196 
197  // Create the device ID. This depends on mCDDevice being initialised first.
198  rv = CreateDeviceID(&mDeviceID);
199  NS_ENSURE_SUCCESS(rv, rv);
200 
201  // Initialize the device state.
203 
204  // Log progress.
205  LOG("Exit sbCDDevice::InitDevice");
206 
207  return NS_OK;
208 }
209 
210 nsresult sbCDDevice::InitializeProperties()
211 {
212  nsresult rv;
213 
214  mProperties =
215  do_CreateInstance("@songbirdnest.com/Songbird/Device/DeviceProperties;1",
216  &rv);
217  NS_ENSURE_SUCCESS(rv, rv);
218 
219  nsCOMPtr<nsIVariant> var;
220  rv = mCreationProperties->GetProperty(NS_LITERAL_STRING("sbICDDevice"),
221  getter_AddRefs(var));
222  NS_ENSURE_SUCCESS(rv, rv);
223 
224  nsCOMPtr<nsISupports> supports;
225  rv = var->GetAsISupports(getter_AddRefs(supports));
226  NS_ENSURE_SUCCESS(rv, rv);
227 
228  nsCOMPtr<sbICDDevice> cdDevice = do_QueryInterface(supports, &rv);
229  NS_ENSURE_SUCCESS(rv, rv);
230 
231  nsString deviceName;
232  rv = cdDevice->GetName(deviceName);
233  NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "ERROR: Could not get the device name!");
234 
235  // Use the localized "CD Rip" string for the device friendly name. The CD
236  // lookup jobs will update this value once lookup has been completed.
237  rv = mProperties->InitFriendlyName(
238  SBLocalizedString("cdrip.service.default_node_name"));
239  NS_ENSURE_SUCCESS(rv, rv);
240 
241  rv = mProperties->InitDone();
242  NS_ENSURE_SUCCESS(rv, rv);
243 
244  // CD devices are inherently read-only for now
245  nsCOMPtr<nsIPropertyBag2> properties;
246  rv = mProperties->GetProperties(getter_AddRefs(properties));
247  NS_ENSURE_SUCCESS(rv, rv);
248  nsCOMPtr<nsIWritablePropertyBag2> writeProperties =
249  do_QueryInterface(properties, &rv);
250  NS_ENSURE_SUCCESS(rv, rv);
251 
252  writeProperties->SetPropertyAsAString(
253  NS_LITERAL_STRING(SB_DEVICE_PROPERTY_ACCESS_COMPATIBILITY),
254  NS_LITERAL_STRING("ro"));
255  return NS_OK;
256 }
257 
258 /* static */ nsresult
259 sbCDDevice::New(const nsID & aControllerId,
260  nsIPropertyBag *aProperties,
261  sbCDDevice **aOutCDDevice)
262 {
263  NS_ENSURE_ARG_POINTER(aProperties);
264  NS_ENSURE_ARG_POINTER(aOutCDDevice);
265 
266  nsRefPtr<sbCDDevice> device = new sbCDDevice(aControllerId, aProperties);
267  NS_ENSURE_TRUE(device, NS_ERROR_OUT_OF_MEMORY);
268 
269  // Init the device.
270  nsresult rv = device->Init();
271  NS_ENSURE_SUCCESS(rv, rv);
272 
273  // Return the newly created CD device.
274  device.forget(aOutCDDevice);
275 
276  return NS_OK;
277 }
278 
279 // sbIDevice implementation
280 
285 NS_IMETHODIMP
286 sbCDDevice::GetName(nsAString& aName)
287 {
288  // Operate under the properties lock.
289  nsAutoMonitor autoPropertiesLock(mPropertiesLock);
290 
291  return GetNameBase(aName);
292 }
293 
294 
300 NS_IMETHODIMP
301 sbCDDevice::GetProductName(nsAString& aProductName)
302 {
303  // Operate under the properties lock.
304  nsAutoMonitor autoPropertiesLock(mPropertiesLock);
305 
306  return GetProductNameBase("device.cd.default.model.number",
307  aProductName);
308 }
309 
310 
311 /* readonly attribute nsIDPtr controllerId; */
312 NS_IMETHODIMP
313 sbCDDevice::GetControllerId(nsID * *aControllerId)
314 {
315  // Validate parameters.
316  NS_ENSURE_ARG_POINTER(aControllerId);
317 
318  // Allocate an nsID and set it to the controller ID.
319  nsID* pId = static_cast<nsID*>(NS_Alloc(sizeof(nsID)));
320  NS_ENSURE_TRUE(pId, NS_ERROR_OUT_OF_MEMORY);
321  *pId = mControllerID;
322 
323  // Return the ID.
324  *aControllerId = pId;
325 
326  return NS_OK;
327 }
328 
329 /* readonly attribute nsIDPtr id; */
330 NS_IMETHODIMP
331 sbCDDevice::GetId(nsID * *aId)
332 {
333  // Validate parameters.
334  NS_ENSURE_ARG_POINTER(aId);
335 
336  // Allocate an nsID and set it to the device ID.
337  nsID* pId = static_cast<nsID*>(NS_Alloc(sizeof(nsID)));
338  NS_ENSURE_TRUE(pId, NS_ERROR_OUT_OF_MEMORY);
339  *pId = mDeviceID;
340 
341  // Return the ID.
342  *aId = pId;
343 
344  return NS_OK;
345 }
346 
347 nsresult
348 sbCDDevice::CapabilitiesReset()
349 {
350  nsresult rv;
351 
352  // Create the device capabilities object.
353  mCapabilities = do_CreateInstance(SONGBIRD_DEVICECAPABILITIES_CONTRACTID,
354  &rv);
355  NS_ENSURE_SUCCESS(rv, rv);
356  mCapabilities->Init();
357  NS_ENSURE_SUCCESS(rv, rv);
358 
359  PRUint32 functionTypes = sbIDeviceCapabilities::FUNCTION_DEVICE;
360  rv = mCapabilities->SetFunctionTypes(&functionTypes, 1);
361  NS_ENSURE_SUCCESS(rv, rv);
362 
363  // Allow registrars to modify the capabilities
364  rv = RegisterDeviceCapabilities(mCapabilities);
365  NS_ENSURE_SUCCESS(rv, rv);
366 
367  // Complete the device capabilities configuration.
368  rv = mCapabilities->ConfigureDone();
369  NS_ENSURE_SUCCESS(rv, rv);
370 
371  return NS_OK;
372 }
373 
374 /* void connect (); */
375 NS_IMETHODIMP sbCDDevice::Connect()
376 {
377  nsresult rv;
378 
379  // Log progress.
380  LOG("Enter sbCDDevice::Connect\n");
381 
382  // This function should only be called on the main thread.
383  NS_ASSERTION(NS_IsMainThread(), "not on main thread");
384 
385  // Do nothing if device is already connected. If the device is not connected,
386  // nothing should be accessing the "connect lock" fields.
387  {
388  sbAutoReadLock autoConnectLock(mConnectLock);
389  if (mConnected)
390  return NS_OK;
391  }
392 
393  // Set up to auto-disconnect in case of error.
394  SB_CD_DEVICE_AUTO_INVOKE(AutoDisconnect, Disconnect()) autoDisconnect(this);
395 
396  // Invoke the super-class.
397  rv = sbBaseDevice::Connect();
398  NS_ENSURE_SUCCESS(rv, rv);
399 
400  mTranscodeManager = do_ProxiedGetService(
401  "@songbirdnest.com/Songbird/Mediacore/TranscodeManager;1",
402  &rv);
403 
404  // Connect the device capabilities.
405  rv = CapabilitiesReset();
406  NS_ENSURE_SUCCESS(rv, rv);
407 
408  // Mark the device as connected. After this, "connect lock" fields may be
409  // used.
410  {
411  sbAutoWriteLock autoConnectLock(mConnectLock);
412  mConnected = PR_TRUE;
413  }
414 
415  // Create a device volume.
416  nsRefPtr<sbBaseDeviceVolume> volume;
417  rv = sbBaseDeviceVolume::New(getter_AddRefs(volume), this);
418  NS_ENSURE_SUCCESS(rv, rv);
419 
420  // Set the volume GUID.
421  char volumeGUID[NSID_LENGTH];
422  mDeviceID.ToProvidedString(volumeGUID);
423  rv = volume->SetGUID(NS_ConvertUTF8toUTF16(volumeGUID));
424  NS_ENSURE_SUCCESS(rv, rv);
425 
426  // Add the volume.
427  rv = AddVolume(volume);
428  NS_ENSURE_SUCCESS(rv, rv);
429 
430  // Start the request processing.
431  rv = ReqProcessingStart();
432  NS_ENSURE_SUCCESS(rv, rv);
433 
434  // Mount volume.
435  Mount(volume);
436 
437  // Cancel auto-disconnect.
438  autoDisconnect.forget();
439 
440  // Log progress.
441  LOG("Exit sbCDDevice::Connect\n");
442 
443  return NS_OK;
444 }
445 
446 NS_IMETHODIMP
448 {
449  return sbBaseDevice::Disconnect();
450 }
451 
452 nsresult
453 sbCDDevice::DeviceSpecificDisconnect()
454 {
455  // Log progress.
456  LOG("Enter sbCDDevice::DeviceSpecificDisconnect\n");
457 
458  nsresult rv;
459 
460  // This function should only be called on the main thread.
461  NS_ASSERTION(NS_IsMainThread(), "not on main thread");
462 
463  // Remove object references.
464  mTranscodeManager = nsnull;
465 
466  // Dispose of the library
467  nsCOMPtr<sbIDeviceLibrary> deviceLib = mDeviceLibrary.forget();
468  if (deviceLib) {
469  rv = deviceLib->Finalize();
470  NS_ENSURE_SUCCESS(rv, rv);
471  }
472 
473  // Indicate that the device is disconnected.
474  mStatus->ChangeState(STATE_DISCONNECTED);
475 
476  // Unmount and remove the default volume.
477  nsRefPtr<sbBaseDeviceVolume> volume;
478  {
479  nsAutoLock autoVolumeLock(mVolumeLock);
480  volume = mDefaultVolume;
481  }
482  if (volume) {
483  rv = Unmount(volume);
484  NS_ENSURE_SUCCESS(rv, rv);
485  RemoveVolume(volume);
486  }
487 
488  // Mark the device as not connected. After this, "connect lock" fields may
489  // not be used.
490  {
491  sbAutoWriteLock autoConnectLock(mConnectLock);
492  mConnected = PR_FALSE;
493  }
494 
495  // Disconnect the device capabilities.
496  mCapabilities = nsnull;
497 
498  // Log progress.
499  LOG("Exit sbCDDevice::Disconnect\n");
500 
501  return NS_OK;
502 }
503 
504 /* readonly attribute boolean connected; */
505 NS_IMETHODIMP
506 sbCDDevice::GetConnected(PRBool *aConnected)
507 {
508  NS_ENSURE_ARG_POINTER(aConnected);
509  sbAutoReadLock autoConnectLock(mConnectLock);
510  *aConnected = mConnected;
511  return NS_OK;
512 }
513 
514 /* readonly attribute boolean threaded; */
515 NS_IMETHODIMP
516 sbCDDevice::GetThreaded(PRBool *aThreaded)
517 {
518  NS_ENSURE_ARG_POINTER(aThreaded);
519  *aThreaded = PR_TRUE;
520  return NS_OK;
521 }
522 
523 /* nsIVariant getPreference (in AString aPrefName); */
524 NS_IMETHODIMP
525 sbCDDevice::GetPreference(const nsAString & aPrefName, nsIVariant **_retval)
526 {
527  // Transcoding profile-related prefs are global for CD device; not per device.
528  if (StringBeginsWith(aPrefName, NS_LITERAL_STRING("transcode_profile")))
529  {
530  nsCOMPtr<nsIPrefBranch> prefBranch;
532  getter_AddRefs(prefBranch));
533  NS_ENSURE_SUCCESS(rv, rv);
534  return GetPreferenceInternal(prefBranch, aPrefName, _retval);
535  }
536 
537  // Forward call to base class.
538  return sbBaseDevice::GetPreference(aPrefName, _retval);
539 }
540 
541 /* void setPreference (in AString aPrefName, in nsIVariant aPrefValue); */
542 NS_IMETHODIMP
543 sbCDDevice::SetPreference(const nsAString & aPrefName, nsIVariant *aPrefValue)
544 {
545  // Validate arguments.
546  NS_ENSURE_ARG_POINTER(aPrefValue);
547  // Transcoding profile-related prefs are global for CD device; not per device.
548  if (StringBeginsWith(aPrefName, NS_LITERAL_STRING("transcode_profile")))
549  {
550  nsCOMPtr<nsIPrefBranch> prefBranch;
552  getter_AddRefs(prefBranch));
553  NS_ENSURE_SUCCESS(rv, rv);
554  return SetPreferenceInternal(prefBranch, aPrefName, aPrefValue);
555  }
556 
557  // Forward call to base class.
558  return sbBaseDevice::SetPreference(aPrefName, aPrefValue);
559 }
560 
561 /* readonly attribute sbIDeviceCapabilities capabilities; */
562 NS_IMETHODIMP
563 sbCDDevice::GetCapabilities(sbIDeviceCapabilities * *aCapabilities)
564 {
565  NS_ENSURE_ARG_POINTER(aCapabilities);
566  sbAutoReadLock autoConnectLock(mConnectLock);
567  NS_IF_ADDREF(*aCapabilities = mCapabilities);
568  return NS_OK;
569 }
570 
571 /* readonly attribute sbIDeviceContent content; */
572 NS_IMETHODIMP
573 sbCDDevice::GetContent(sbIDeviceContent * *aContent)
574 {
575  NS_ENSURE_ARG_POINTER(aContent);
576  NS_ENSURE_STATE(mDeviceContent);
577  NS_ADDREF(*aContent = mDeviceContent);
578  return NS_OK;
579 }
580 
581 /* attribute sbIDeviceLibrary defaultLibrary; */
582 NS_IMETHODIMP
584 {
585  return sbBaseDevice::GetDefaultLibrary(aDefaultLibrary);
586 }
587 
588 NS_IMETHODIMP
590 {
591  return sbBaseDevice::SetDefaultLibrary(aDefaultLibrary);
592 }
593 
594 /* readonly attribute sbIDeviceLibrary primaryLibrary; */
595 NS_IMETHODIMP
597 {
598  return sbBaseDevice::GetPrimaryLibrary(aPrimaryLibrary);
599 }
600 
601 /* readonly attribute nsIPropertyBag2 parameters; */
602 NS_IMETHODIMP
603 sbCDDevice::GetParameters(nsIPropertyBag2 * *aParameters)
604 {
605  // Validate arguments.
606  NS_ENSURE_ARG_POINTER(aParameters);
607 
608  // Function variables.
609  nsresult rv = CallQueryInterface(mCreationProperties, aParameters);
610  NS_ENSURE_SUCCESS(rv, rv);
611 
612  return NS_OK;
613 }
614 
615 /* readonly attribute sbIDeviceProperties properties; */
616 NS_IMETHODIMP
617 sbCDDevice::GetProperties(sbIDeviceProperties * *aProperties)
618 {
619  // Validate arguments.
620  NS_ENSURE_ARG_POINTER(aProperties);
621 
622  // Operate under the properties lock.
623  nsAutoMonitor autoPropertiesLock(mPropertiesLock);
624 
625  *aProperties = nsnull;
626 
627  // Return results.
628  if (mProperties) {
629  NS_ADDREF(*aProperties = mProperties);
630  } else {
631  return NS_ERROR_UNEXPECTED;
632  }
633 
634  return NS_OK;
635 }
636 
637 /* readonly attribute boolean isDirectTranscoding; */
638 NS_IMETHODIMP
639 sbCDDevice::GetIsDirectTranscoding(PRBool* aIsDirect)
640 {
641  return sbBaseDevice::GetIsDirectTranscoding(aIsDirect);
642 }
643 
644 /* readonly attribute boolean isBusy; */
645 NS_IMETHODIMP
646 sbCDDevice::GetIsBusy(PRBool *aIsBusy)
647 {
648  return sbBaseDevice::GetIsBusy(aIsBusy);
649 }
650 
651 /* readonly attribute boolean canDisconnect; */
652 NS_IMETHODIMP
653 sbCDDevice::GetCanDisconnect(PRBool *aCanDisconnect)
654 {
655  return sbBaseDevice::GetCanDisconnect(aCanDisconnect);
656 }
657 
658 /* readonly attribute sbIDeviceStatus currentStatus; */
659 NS_IMETHODIMP
660 sbCDDevice::GetCurrentStatus(sbIDeviceStatus * *aCurrentStatus)
661 {
662  NS_ENSURE_ARG_POINTER(aCurrentStatus);
663  return mStatus->GetCurrentStatus(aCurrentStatus);
664 }
665 
666 /* readonly attribute boolean supportsReformat; */
667 NS_IMETHODIMP
668 sbCDDevice::GetSupportsReformat(PRBool *aSupportsReformat)
669 {
670  NS_ENSURE_ARG_POINTER(aSupportsReformat);
671  *aSupportsReformat = PR_FALSE;
672  return NS_OK;
673 }
674 
675 /* readonly attribute unsigned long state; */
676 NS_IMETHODIMP
677 sbCDDevice::GetState(PRUint32 *aState)
678 {
679  return sbBaseDevice::GetState(aState);
680 }
681 
682 NS_IMETHODIMP
684 {
685  return sbBaseDevice::SetState(aState);
686 }
687 
688 NS_IMETHODIMP
689 sbCDDevice::GetPreviousState(PRUint32 *aPreviousState)
690 {
691  return sbBaseDevice::GetPreviousState(aPreviousState);
692 }
693 
694 NS_IMETHODIMP
695 sbCDDevice::SubmitRequest(PRUint32 aRequest,
696  nsIPropertyBag2 *aRequestParameters)
697 {
698  // Log progress.
699  LOG("sbCDDevice::SubmitRequest\n");
700 
701  return sbBaseDevice::SubmitRequest(aRequest, aRequestParameters);
702 }
703 
704 /* void cancelRequests (); */
705 NS_IMETHODIMP
707 {
708  nsresult rv;
709 
710  // Check if we are ripping, if we are pop up a dialog to ask the user if
711  // they really want to stop ripping.
712  nsCOMPtr<sbIDeviceStatus> status;
713  rv = GetCurrentStatus(getter_AddRefs(status));
714  NS_ENSURE_SUCCESS(rv, rv);
715 
716  PRUint32 currentState;
717  rv = status->GetCurrentState(&currentState);
718  NS_ENSURE_SUCCESS(rv, rv);
719  if (currentState == sbIDevice::STATE_TRANSCODE) {
720  PRBool abortRip;
721  rv = sbDeviceUtils::QueryUserAbortRip(&abortRip);
722  NS_ENSURE_SUCCESS(rv, rv);
723  if (!abortRip) {
724  return NS_OK;
725  }
726  }
727 
728  // Cancel requests
730  NS_ENSURE_SUCCESS(rv, rv);
731 
732  return NS_OK;
733 }
734 
735 /* void syncLibraries (); */
736 NS_IMETHODIMP
738 {
739  return NS_ERROR_NOT_IMPLEMENTED;
740 }
741 
742 NS_IMETHODIMP
745 {
746  return NS_ERROR_NOT_IMPLEMENTED;
747 }
748 
749 /* void eject (); */
750 NS_IMETHODIMP
752 {
753  NS_ENSURE_TRUE(mCDDevice, NS_ERROR_UNEXPECTED);
754 
755  nsresult rv;
756  rv = mCDDevice->Eject();
757  NS_ENSURE_SUCCESS(rv, rv);
758 
759  return NS_OK;
760 }
761 
762 /* void format (); */
763 NS_IMETHODIMP
765 {
766  return NS_ERROR_NOT_IMPLEMENTED;
767 }
768 
769 /* void setWarningDialogEnabled (in AString aWarning, in boolean aEnabled); */
770 NS_IMETHODIMP
771 sbCDDevice::SetWarningDialogEnabled(const nsAString & aWarning,
772  PRBool aEnabled)
773 {
774  return sbBaseDevice::SetWarningDialogEnabled(aWarning, aEnabled);
775 }
776 
777 /* boolean getWarningDialogEnabled (in AString aWarning); */
778 NS_IMETHODIMP
779 sbCDDevice::GetWarningDialogEnabled(const nsAString & aWarning,
780  PRBool *_retval)
781 {
782  return sbBaseDevice::GetWarningDialogEnabled(aWarning, _retval);
783 }
784 
785 /* void resetWarningDialogs (); */
786 NS_IMETHODIMP
788 {
790 }
791 
792 /* nsIInputStream openInputStream(in nsIURI aURI); */
793 NS_IMETHODIMP
794 sbCDDevice::OpenInputStream(nsIURI* aURI,
795  nsIInputStream** retval)
796 {
797  return sbBaseDevice::OpenInputStream(aURI, retval);
798 }
799 
800 NS_IMETHODIMP
802  sbILibraryChangeset* aExportChangeset)
803 {
804  return sbBaseDevice::ExportToDevice(aDevLibrary, aExportChangeset);
805 }
806 
807 NS_IMETHODIMP
808 sbCDDevice::ImportFromDevice(sbILibrary * aImportToLibrary,
809  sbILibraryChangeset * aImportChangeset)
810 {
811  return sbBaseDevice::ImportFromDevice(aImportToLibrary, aImportChangeset);
812 }
813 
814 nsresult
815 sbCDDevice::Mount(sbBaseDeviceVolume* aVolume)
816 {
817  nsresult rv;
818 
819  // This function must only be called on the main thread.
820  NS_ASSERTION(NS_IsMainThread(), "not on main thread");
821 
822  // Operate under the connect lock.
823  sbAutoReadLock autoConnectLock(mConnectLock);
824  NS_ENSURE_TRUE(mConnected, NS_ERROR_NOT_AVAILABLE);
825 
826  // Do nothing if volume has already been mounted.
827  PRBool isMounted;
828  rv = aVolume->GetIsMounted(&isMounted);
829  NS_ENSURE_SUCCESS(rv, rv);
830  if (isMounted)
831  return NS_OK;
832 
833  // Set the primary and default volume.
834  {
835  nsAutoLock autoVolumeLock(mVolumeLock);
836  if (!mPrimaryVolume)
837  mPrimaryVolume = aVolume;
838  if (!mDefaultVolume)
839  mDefaultVolume = aVolume;
840  }
841 
842  // Make a string out of the device ID.
843  char deviceID[NSID_LENGTH];
844  mDeviceID.ToProvidedString(deviceID);
845 
846  // Create a unique device library ID using the device ID and volumeGUID.
847  // Strip off the braces from the device ID.
848  mDeviceLibraryPath.AssignLiteral("CD");
849  mDeviceLibraryPath.Append(NS_ConvertUTF8toUTF16(deviceID + 1, NSID_LENGTH - 3));
850  mDeviceLibraryPath.AppendLiteral("@devices.library.songbirdnest.com");
851 
852  // Create the device library.
853  nsCOMPtr<sbIDeviceLibrary> deviceLibrary;
854  rv = CreateDeviceLibrary(mDeviceLibraryPath,
855  nsnull,
856  getter_AddRefs(deviceLibrary));
857  NS_ENSURE_SUCCESS(rv, rv);
858 
859  // Set the volume device library.
860  rv = aVolume->SetDeviceLibrary(deviceLibrary);
861  NS_ENSURE_SUCCESS(rv, rv);
862 
863  // Set the main device library.
864  mDeviceLibrary = deviceLibrary;
865 
866  // Get the current CD disc hash.
867  nsAutoString cdDiscHash;
868  rv = GetCDDiscHash(mCDDevice, cdDiscHash);
869  NS_ENSURE_SUCCESS(rv, rv);
870 
871  // Get the previous CD disc hash.
872  nsAutoString prevCDDiscHash;
873  rv = mDeviceLibrary->GetProperty(NS_LITERAL_STRING(SB_PROPERTY_CDDISCHASH),
874  prevCDDiscHash);
875  if (rv == NS_ERROR_NOT_AVAILABLE) {
876  prevCDDiscHash.Truncate();
877  rv = NS_OK;
878  }
879  NS_ENSURE_SUCCESS(rv, rv);
880 
881  if (!cdDiscHash.Equals(prevCDDiscHash)) {
882  // Clear the library out if the CD disc hash is changing.
883  rv = mDeviceLibrary->Clear();
884  NS_ENSURE_SUCCESS(rv, rv);
885  rv = mDeviceLibrary->SetProperty(NS_LITERAL_STRING(SB_PROPERTY_ALBUMNAME),
886  SBVoidString());
887  NS_ENSURE_SUCCESS(rv, rv);
888  rv = mDeviceLibrary->SetProperty(NS_LITERAL_STRING(SB_PROPERTY_CDDISCHASH),
889  SBVoidString());
890  NS_ENSURE_SUCCESS(rv, rv);
891  }
892  else {
893  // Reset status if same disk was inserted again
894  rv = sbDeviceUtils::BulkSetProperty(mDeviceLibrary,
895  NS_LITERAL_STRING(SB_PROPERTY_CDRIP_STATUS),
896  SBVoidString());
897  NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
898  "Failed to reset rip status for CD tracks");
899 
900  rv = sbDeviceUtils::BulkSetProperty(mDeviceLibrary,
901  NS_LITERAL_STRING(SB_PROPERTY_SHOULDRIP),
902  NS_LITERAL_STRING("1"));
903  NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
904  "Failed to reset selection for CD tracks");
905  }
906 
907  // hide the device library.
908  rv = mDeviceLibrary->SetProperty(NS_LITERAL_STRING(SB_PROPERTY_HIDDEN),
909  NS_LITERAL_STRING("1"));
910  NS_ENSURE_SUCCESS(rv, rv);
911 
912  // Update the device properties.
914 
915  // Add the device library.
916  rv = AddLibrary(deviceLibrary);
917  NS_ENSURE_SUCCESS(rv, rv);
918 
919  // Mount the device. It's very important to send the mount request
920  // before checking for setup. If the device isn't already mounting it
921  // will not actually be sync-able because the sync request will be
922  // submitted before we mount.
923  rv = PushRequest(TransferRequest::REQUEST_MOUNT, nsnull, deviceLibrary);
924  NS_ENSURE_SUCCESS(rv, rv);
925 
926  // Indicate that the volume has been mounted in Songbird.
927  rv = aVolume->SetIsMounted(PR_TRUE);
928  NS_ENSURE_SUCCESS(rv, rv);
929 
930  // Release connect lock.
931  autoConnectLock.unlock();
932 
933  return NS_OK;
934 }
935 
936 nsresult
937 sbCDDevice::Unmount(sbBaseDeviceVolume* aVolume)
938 {
939  nsresult rv;
940 
941  // This function must only be called on the main thread.
942  NS_ASSERTION(NS_IsMainThread(), "not on main thread");
943 
944  // Operate under the connect lock.
945  sbAutoReadLock autoConnectLock(mConnectLock);
946  NS_ENSURE_TRUE(mConnected, NS_ERROR_NOT_AVAILABLE);
947 
948  // Get the volume info and mark the volume as no longer mounted.
949  nsRefPtr<sbDeviceStatistics> deviceStatistics;
950  rv = aVolume->GetStatistics(getter_AddRefs(deviceStatistics));
951  NS_ENSURE_SUCCESS(rv, rv);
952  rv = aVolume->SetIsMounted(PR_FALSE);
953  NS_ENSURE_SUCCESS(rv, rv);
954 
955  // Do nothing if media volume not mounted.
956  if (!mDeviceLibrary) {
957  return NS_OK;
958  }
959 
960  // Remove the device library from the device statistics.
961  rv = deviceStatistics->RemoveLibrary(mDeviceLibrary);
962  NS_ENSURE_SUCCESS(rv, rv);
963 
964  // Remove the device library and dispose of it.
965  rv = RemoveLibrary(mDeviceLibrary);
966  NS_ENSURE_SUCCESS(rv, rv);
967 
968  nsCOMPtr<sbILibraryManager> libManager =
969  do_GetService("@songbirdnest.com/Songbird/library/Manager;1", &rv);
970  NS_ENSURE_SUCCESS(rv, rv);
971 
972  rv = libManager->UnregisterLibrary(mDeviceLibrary);
973  NS_ENSURE_SUCCESS(rv, rv);
974 
975  return NS_OK;
976 }
977 
978 PRBool
980 {
981  PRBool aborted = sbBaseDevice::IsRequestAborted();
982 
983  // Abort requests if disc is not inserted.
984  if (!aborted) {
985  PRBool isDiscInserted;
986  nsresult rv = mCDDevice->GetIsDiscInserted(&isDiscInserted);
987  aborted = NS_SUCCEEDED(rv) && !isDiscInserted ? PR_TRUE : PR_FALSE;
988  }
989 
990  return aborted;
991 }
992 
993 // Override base class: we want to return all profiles, not just those supported
994 // by the device (since that's not meaningful for a cd device!)
995 nsresult
996 sbCDDevice::GetSupportedTranscodeProfiles(PRUint32 aType,
997  nsIArray **aSupportedProfiles)
998 {
999  nsresult rv;
1000  nsCOMPtr<nsIArray> profiles;
1002  aSupportedProfiles);
1003  NS_ENSURE_SUCCESS(rv, rv);
1004 
1005  return NS_OK;
1006 }
1007 
1008 // Override base class: CD devices are always read-only, and users won't
1009 // expect otherwise, so popping up a dialog informing them is confusing.
1010 // This overrides the sbBaseDevice::CheckAccess to not throw up the dialog
1011 nsresult
1012 sbCDDevice::CheckAccess(sbIDeviceLibrary* aDevLib)
1013 {
1014  return NS_OK;
1015 }
1016 
1017 nsresult
1018 sbCDDevice::HandleRipEnd()
1019 {
1020  nsresult rv;
1021 
1022  if (!NS_IsMainThread()) {
1023  nsCOMPtr<nsIThreadManager> threadMgr =
1024  do_GetService("@mozilla.org/thread-manager;1", &rv);
1025  NS_ENSURE_SUCCESS(rv, rv);
1026 
1027  nsCOMPtr<nsIThread> mainThread;
1028  rv = threadMgr->GetMainThread(getter_AddRefs(mainThread));
1029  NS_ENSURE_SUCCESS(rv, rv);
1030 
1031  nsCOMPtr<nsIRunnable> runnable =
1032  NS_NEW_RUNNABLE_METHOD(sbCDDevice, this, ProxyHandleRipEnd);
1033  NS_ENSURE_TRUE(runnable, NS_ERROR_FAILURE);
1034 
1035  rv = mainThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
1036  NS_ENSURE_SUCCESS(rv, rv);
1037  }
1038  else {
1039  ProxyHandleRipEnd();
1040  }
1041 
1042  return NS_OK;
1043 }
1044 
1045 void
1046 sbCDDevice::ProxyHandleRipEnd()
1047 {
1048  // Dispatch the event to notify listeners that we've finished the rip job.
1050  sbNewVariant(NS_ISUPPORTS_CAST(sbIDevice*, this)));
1051 
1052  // Check to see if any errors occurred during the transcode.
1053  nsresult rv;
1054  nsCOMPtr<sbIDeviceErrorMonitor> errMonitor =
1055  do_GetService("@songbirdnest.com/device/error-monitor-service;1", &rv);
1056  NS_ENSURE_SUCCESS(rv, /* void */);
1057 
1058  PRBool hasErrors;
1059  rv = errMonitor->DeviceHasErrors(this, EmptyString(), 0, &hasErrors);
1060  NS_ENSURE_SUCCESS(rv, /* void */);
1061 
1062  if (hasErrors) {
1063  // The rip operation has completed, but there were a few errors during
1064  // the transcode. Show those errors now.
1066  NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Could not show user view errors!");
1067 
1068  // Now that we've shown the errors for the user, clear out the errors
1069  // for this device.
1070  rv = errMonitor->ClearErrorsForDevice(this);
1071  NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Could not clear the device errors!");
1072  }
1073  else {
1074  // Check the preferences to see if we should eject
1075  if (mPrefAutoEject) {
1076  // Since we successfully ripped all selected tracks and the user has
1077  // the autoEject preference set, we can eject now.
1078  rv = Eject();
1079  NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Could not eject the CD!");
1080  }
1081 
1082  // if the user wants a sound notification, then beep
1083  if (mPrefNotifySound) {
1084  nsCOMPtr<nsISound> soundInterface =
1085  do_CreateInstance("@mozilla.org/sound;1", &rv);
1086  NS_ENSURE_SUCCESS(rv, /* void */);
1087 
1088  soundInterface->Beep();
1089  }
1090  }
1091 }
1092 
1093 nsresult
1094 sbCDDevice::QueryUserViewErrors()
1095 {
1096  nsresult rv;
1097 
1098  if (!NS_IsMainThread()) {
1099  nsCOMPtr<nsIThreadManager> threadMgr =
1100  do_GetService("@mozilla.org/thread-manager;1", &rv);
1101  NS_ENSURE_SUCCESS(rv, rv);
1102 
1103  nsCOMPtr<nsIThread> mainThread;
1104  rv = threadMgr->GetMainThread(getter_AddRefs(mainThread));
1105  NS_ENSURE_SUCCESS(rv, rv);
1106 
1107  nsCOMPtr<nsIRunnable> runnable =
1108  NS_NEW_RUNNABLE_METHOD(sbCDDevice, this, ProxyQueryUserViewErrors);
1109  NS_ENSURE_TRUE(runnable, NS_ERROR_FAILURE);
1110 
1111  rv = mainThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
1112  NS_ENSURE_SUCCESS(rv, rv);
1113  }
1114  else {
1115  ProxyQueryUserViewErrors();
1116  }
1117 
1118  return NS_OK;
1119 }
1120 
1121 void
1122 sbCDDevice::ProxyQueryUserViewErrors()
1123 {
1125  NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Could not show user view errors!");
1126 }
1127 
1128 nsresult
1129 sbCDDevice::GetCDDiscHash(sbICDDevice* aCDDevice,
1130  nsAString& aCDDiscHash)
1131 {
1132  // Validate arguments.
1133  NS_ENSURE_ARG_POINTER(aCDDevice);
1134 
1135  // Function variables.
1136  nsresult rv;
1137 
1138  // Create a hash object.
1139  nsCOMPtr<nsICryptoHash>
1140  cryptoHash = do_CreateInstance("@mozilla.org/security/hash;1", &rv);
1141  NS_ENSURE_SUCCESS(rv, rv);
1142  rv = cryptoHash->Init(nsICryptoHash::MD5);
1143  NS_ENSURE_SUCCESS(rv, rv);
1144 
1145  // Get the disc TOC.
1146  nsCOMPtr<sbICDTOC> toc;
1147  rv = mCDDevice->GetDiscTOC(getter_AddRefs(toc));
1148  NS_ENSURE_SUCCESS(rv, rv);
1149 
1150  // Get the disc tracks.
1151  nsCOMPtr<nsIArray> tracks;
1152  rv = toc->GetTracks(getter_AddRefs(tracks));
1153  NS_ENSURE_SUCCESS(rv, rv);
1154  PRUint32 trackCount;
1155  rv = tracks->GetLength(&trackCount);
1156  NS_ENSURE_SUCCESS(rv, rv);
1157 
1158  // Add each track offset to the hash.
1159  for (PRUint32 i = 0; i < trackCount; i++) {
1160  // Get the next track.
1161  nsCOMPtr<sbICDTOCEntry> track = do_QueryElementAt(tracks, i, &rv);
1162  NS_ENSURE_SUCCESS(rv, rv);
1163 
1164  // Get the track offset.
1165  PRInt32 frameOffset;
1166  rv = track->GetFrameOffset(&frameOffset);
1167  NS_ENSURE_SUCCESS(rv, rv);
1168 
1169  // Add the track offset to the hash.
1170  rv = cryptoHash->Update(reinterpret_cast<PRUint8 const *>(&frameOffset),
1171  sizeof(PRInt32));
1172  NS_ENSURE_SUCCESS(rv, rv);
1173  }
1174 
1175  // Add the lead out track offset to the hash.
1176  PRInt32 leadOutOffset;
1177  rv = toc->GetLeadOutTrackOffset(&leadOutOffset);
1178  NS_ENSURE_SUCCESS(rv, rv);
1179  rv = cryptoHash->Update(reinterpret_cast<PRUint8 const *>(&leadOutOffset),
1180  sizeof(PRInt32));
1181  NS_ENSURE_SUCCESS(rv, rv);
1182 
1183  // Return results.
1184  nsCString cdDiscHash;
1185  rv = cryptoHash->Finish(PR_TRUE, cdDiscHash);
1186  NS_ENSURE_SUCCESS(rv, rv);
1187  aCDDiscHash.Assign(NS_ConvertASCIItoUTF16(cdDiscHash));
1188 
1189  return NS_OK;
1190 }
static nsresult GetTranscodeProfiles(PRUint32 aType, nsIArray **aProfiles)
PRLock * mVolumeLock
Definition: sbBaseDevice.h:873
NS_IMETHOD GetPreference(const nsAString &aPrefName, nsIVariant **_retval)
#define SB_PROPERTY_SHOULDRIP
nsresult CreateAndDispatchEvent(PRUint32 aType, nsIVariant *aData, PRBool aAsync=PR_TRUE, sbIDeviceEventTarget *aTarget=nsnull)
NS_SCRIPTABLE NS_IMETHOD ResetWarningDialogs(void)
#define SB_PRLOG_SETUP(x)
Definition: sbDebugUtils.h:115
return NS_OK
#define SB_PROPERTY_CDRIP_STATUS
NS_IMETHOD Format(void)
nsresult CreateDeviceLibrary(const nsAString &aId, nsIURI *aLibraryLocation, sbIDeviceLibrary **_retval)
nsAutoPtr< sbDeviceStatusHelper > mStatus
Definition: sbBaseDevice.h:689
#define LOG(args)
[UNIMPLEMENTED UNTIL AFTER 0.3]
NS_IMETHOD GetIsDirectTranscoding(PRBool *aIsDirect)
NS_IMPL_CI_INTERFACE_GETTER3(sbMediaListEnumeratorWrapper, sbIMediaListEnumeratorWrapper, nsISimpleEnumerator, nsIClassInfo)
static nsresult BulkSetProperty(sbIMediaList *aMediaList, const nsAString &aPropertyId, const nsAString &aPropertyValue, sbIPropertyArray *aPropertyFilter=nsnull, PRInt32 *aAbortFlag=nsnull)
NS_IMETHOD GetPrimaryLibrary(sbIDeviceLibrary **aPrimaryLibrary)
NS_IMETHOD GetPreviousState(PRUint32 *aState)
NS_SCRIPTABLE NS_IMETHOD SetWarningDialogEnabled(const nsAString &aWarning, PRBool aEnabled)
NS_SCRIPTABLE NS_IMETHOD OpenInputStream(nsIURI *aURI, nsIInputStream **retval)
nsRefPtr< sbBaseDeviceVolume > mPrimaryVolume
Definition: sbBaseDevice.h:879
nsresult SetIsMounted(PRBool aIsMounted)
static nsresult QueryUserAbortRip(PRBool *aAbort)
NS_SCRIPTABLE NS_IMETHOD GetWarningDialogEnabled(const nsAString &aWarning, PRBool *_retval)
static nsresult QueryUserViewErrors(sbIDevice *aDevice)
nsresult GetPrefBranch(nsIPrefBranch **aPrefBranch)
#define SB_DEVICE_PROPERTY_ACCESS_COMPATIBILITY
#define SB_PROPERTY_HIDDEN
NS_IMPL_THREADSAFE_CI(sbMediaListEnumeratorWrapper)
nsresult GetStatistics(sbDeviceStatistics **aStatistics)
NS_IMETHOD SyncLibraries(void)
const unsigned long EVENT_CDRIP_COMPLETED
Songbird Variant Utility Definitions.
[UNIMPLEMENTED UNTIL AFTER 0.3]
NS_IMETHOD Connect()
nsRefPtr< sbBaseDeviceVolume > mDefaultVolume
Definition: sbBaseDevice.h:880
nsresult GetNameBase(nsAString &aName)
NS_IMPL_THREADSAFE_RELEASE(sbRequestItem)
NS_IMPL_THREADSAFE_ADDREF(sbRequestItem)
nsresult GetIsMounted(PRBool *aIsMounted)
virtual PRBool IsRequestAborted()
NS_IMETHOD GetState(PRUint32 *aState)
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()
#define PREF_CDDEVICE_RIPBRANCH
Definition: sbCDDevice.h:125
virtual ~sbCDDevice()
Definition: sbCDDevice.cpp:99
#define SONGBIRD_DEVICECAPABILITIES_CONTRACTID
NS_IMPL_QUERY_INTERFACE3_CI(sbCDDevice, sbIDevice, sbIJobProgressListener, sbIDeviceEventTarget) NS_IMPL_CI_INTERFACE_GETTER3(sbCDDevice
nsresult GetPreferenceInternal(nsIPrefBranch *aPrefBranch, const nsAString &aPrefName, nsIVariant **_retval)
nsresult ReqProcessingStart()
NS_IMETHOD SupportsMediaItem(sbIMediaItem *aMediaItem, sbIDeviceSupportsItemCallback *aCallback)
const sbCreateProxiedComponent do_ProxiedGetService(const nsCID &aCID, nsresult *error=0)
NS_IMETHOD Eject(void)
NS_DECL_ISUPPORTS static NS_DECL_SBIDEVICECONTENT sbDeviceContent * New()
NS_IMETHOD GetDefaultLibrary(sbIDeviceLibrary **aDefaultLibrary)
#define SB_PROPERTY_CDDISCHASH
_updateTextAndScrollDataForFrame aContent
this _document this
Definition: FeedWriter.js:1085
const unsigned long STATE_IDLE
Definition: sbIDevice.idl:220
NS_IMETHOD Disconnect()
NS_IMETHOD CancelRequests()
Media library abstraction.
Definition: sbILibrary.idl:82
nsresult GetProductNameBase(char const *aDefaultModelNumberString, nsAString &aProductName)
NS_IMETHOD GetIsBusy(PRBool *aIsBusy)
NS_IMETHOD ExportToDevice(sbIDeviceLibrary *aDevLibrary, sbILibraryChangeset *aChangeset)
readonly attribute sbIDeviceProperties properties
Definition: sbIDevice.idl:168
nsresult AddVolume(sbBaseDeviceVolume *aVolume)
nsresult RemoveLibrary(sbIDeviceLibrary *aDevLib)
const unsigned long STATE_TRANSCODE
Definition: sbIDevice.idl:235
PRBool mConnected
Definition: sbBaseDevice.h:728
NS_IMETHOD GetSupportsReformat(PRBool *_retval)
_updateCookies aName
var uri
Definition: FeedWriter.js:1135
#define SB_PROPERTY_ALBUMNAME
#define SB_CD_DEVICE_AUTO_INVOKE(aName, aMethod)
Definition: sbCDDevice.h:417
sbIJobCancelable NS_DECL_CLASSINFO(sbGstreamerMediaInspector)
NS_IMETHOD SubmitRequest(PRUint32 aRequest, nsIPropertyBag2 *aRequestParameters)
NS_IMETHOD GetCanDisconnect(PRBool *aCanDisconnect)
virtual nsresult InitDevice()
Definition: sbCDDevice.cpp:169
Songbird Device Status Services Definitions.
static NS_DECL_ISUPPORTS nsresult New(sbBaseDeviceVolume **aVolume, sbBaseDevice *aDevice)
Implemented to receive notifications from sbIJobProgress interfaces.
static nsresult New(const nsID &aControllerId, nsIPropertyBag *aProperties, sbCDDevice **aOutCDDevice)
Definition: sbCDDevice.cpp:259
Interface that defines a single item of media in the system.
nsresult SetDeviceLibrary(sbIDeviceLibrary *aDeviceLibrary)
NS_IMETHOD ImportFromDevice(sbILibrary *aImportToLibrary, sbILibraryChangeset *aImportChangeset)
restoreWindow aState
NS_DECL_ISUPPORTS NS_DECL_SBIDEVICE NS_DECL_SBIJOBPROGRESSLISTENER NS_DECL_NSICLASSINFO sbCDDevice(const nsID &aControllerId, nsIPropertyBag *aProperties)
Definition: sbCDDevice.cpp:83
nsresult RegisterDeviceCapabilities(sbIDeviceCapabilities *aCapabilities)
NS_IMETHOD SetState(PRUint32 aState)
_getSelectedPageStyle s i
NS_IMETHOD SetPreference(const nsAString &aPrefName, nsIVariant *aPrefValue)
nsresult SetPreferenceInternal(nsIPrefBranch *aPrefBranch, const nsAString &aPrefName, nsIVariant *aPrefValue, PRBool *aHasChanged)
#define SB_UNUSED_IN_RELEASE(decl)
Definition: sbDebugUtils.h:55
virtual PRBool IsRequestAborted()
Definition: sbCDDevice.cpp:979
NS_IMETHOD SetDefaultLibrary(sbIDeviceLibrary *aDefaultLibrary)
const unsigned long STATE_DISCONNECTED
Definition: sbIDevice.idl:231
nsresult RemoveVolume(sbBaseDeviceVolume *aVolume)
nsresult AddLibrary(sbIDeviceLibrary *aDevLib)