27 #ifndef __SB_IPD_DEVICE_H__
28 #define __SB_IPD_DEVICE_H__
57 #include <sbIDatabaseQuery.h>
58 #include <sbIDeviceContent.h>
59 #include <sbIDeviceLibrary.h>
60 #include <sbILibraryManager.h>
61 #include <sbIPropertyArray.h>
62 #include <sbIPropertyManager.h>
66 #include <nsIClassInfo.h>
67 #include <nsIFileProtocolHandler.h>
68 #include <nsIRunnable.h>
69 #include <nsIStringBundle.h>
70 #include <nsIThread.h>
210 #define IPOD_LOCALE_BUNDLE_PATH "chrome://ipod/locale/IPodDevice.properties"
211 #define IPOD_STATS_UPDATE_PERIOD 500
288 nsIPropertyBag* aProperties);
332 nsresult ConnectInternal();
351 static const int TypeTrack = 1;
352 static const int TypePlaylist = 2;
354 static const char SBIDDelimiter =
':';
361 nsresult MapInitialize();
370 nsresult IDMapAdd(nsAString& aSBID,
373 nsresult IDMapRemove(guint64 aIPodID);
375 nsresult IDMapGet(nsAString& aSBID,
376 nsTArray<guint64>& aIPodIDList);
378 nsresult IDMapGet(nsAString& aSBID,
381 nsresult IDMapGet(guint64 aIPodID,
384 nsresult IDMapGet(guint64 aIPodID,
385 nsAString& aLibraryGUID,
386 nsAString& aResourceGUID);
388 nsresult IDMapGet(guint64 aIPodID,
401 nsresult IPodItemGetID(
void* aIPodItem,
405 nsresult DecodeSBID(
const nsAString& aSBID,
406 nsAString& aLibraryGUID,
407 nsAString& aResourceGUID);
409 nsresult EncodeSBID(nsAString& aSBID,
410 const nsAString& aLibraryGUID,
411 const nsAString& aResourceGUID);
414 const char* aQueryStr,
432 static const PRUint32 REQUEST_WRITE_PREFS =
434 static const PRUint32 REQUEST_SET_PROPERTY =
436 static const PRUint32 REQUEST_SET_PREF =
450 SetNamedValueRequest(PRUint32 aType)
452 SetType(REQUEST_SET_PROPERTY);
455 nsCOMPtr<nsIVariant>
value;
462 virtual nsresult ProcessBatch(
Batch & aBatch);
464 void ReqHandleMount(TransferRequest* aRequest);
466 void ReqHandleWrite(TransferRequest* aRequest, PRUint32 aBatchCount);
468 void ReqHandleWriteTrack(TransferRequest* aRequest, PRUint32 aBatchCount);
470 void ReqHandleWritePlaylistTrack(TransferRequest* aRequest);
472 void ReqHandleDelete(TransferRequest* aRequest,
473 PRUint32 aBatchCount);
475 void ReqHandleDeleteTrack(TransferRequest* aRequest,
476 PRUint32 aBatchCount);
478 void ReqHandleDeletePlaylistTrack(TransferRequest* aRequest);
480 void ReqHandleDeletePlaylist(TransferRequest* aRequest);
482 void ReqHandleWipe(TransferRequest* aRequest);
484 void ReqHandleNewPlaylist(TransferRequest* aRequest);
486 void ReqHandleUpdate(TransferRequest* aRequest);
488 void ReqHandleMovePlaylistTrack(TransferRequest* aRequest);
490 void ReqHandleFactoryReset(TransferRequest* aRequest);
492 void ReqHandleWritePrefs(TransferRequest* aRequest);
494 void ReqHandleSetProperty(TransferRequest* aRequest);
496 void ReqHandleSetPref(SetNamedValueRequest* aRequest);
502 nsresult ReqPushSetNamedValue(
int aType,
503 const nsAString&
aName,
517 nsresult ImportTracks();
522 Itdb_Track** aTrack);
526 nsresult DeleteTrack(Itdb_Track* aTrack);
528 nsresult WipeDevice();
531 Itdb_Track** aTrack);
538 void SetTrackProperties(Itdb_Track* aTrack,
544 nsresult GetTrackProperties(Itdb_Track* aTrack,
547 nsresult GetTrackProperties(Itdb_Track* aTrack,
548 nsIMutableArray* aPropertiesArrayArray);
550 nsresult TrackUpdateProperties(
sbIMediaItem* aMediaItem,
551 Itdb_Track* aTrack = NULL);
554 const char* aPropName,
558 const char* aPropName,
562 const char* aPropName,
563 const nsAString& aProp);
566 const char* aPropName,
570 const char* aPropName,
574 const char* aPropName,
578 const char* aPropName,
582 const char* aPropName,
586 const char* aPropName,
590 const char* aPropName,
594 const char* aPropName,
598 const char* aPropName,
602 const char* aPropName,
606 const char* aPropName,
610 const char* aPropName,
614 const char* aPropName,
618 const char* aPropName,
622 const char* aPropName,
626 const char* aPropName,
637 nsresult GetTrackURI(Itdb_Track* aTrack,
640 nsresult TrackGetFile(Itdb_Track* aTrack,
641 nsIFile** aTrackFile);
648 nsresult ImportTrackBatch(Itdb_Track** aTrackBatch,
649 PRUint32 aBatchCount);
651 static nsresult ImportTrackBatch1(
nsISupports* aUserData);
653 nsresult ImportTrackBatch2(Itdb_Track** aTrackBatch,
654 PRUint32 aBatchCount);
656 void RemoveTrackFromAllPlaylists(Itdb_Track* aTrack);
675 static const PRUint32 TrackBatchSize = 100;
682 nsresult ImportPlaylists();
684 nsresult ImportPlaylist(Itdb_Playlist*
aPlaylist);
690 nsresult ImportPlaylistTracks(Itdb_Playlist*
aPlaylist,
693 nsresult ImportPlaylistTrackBatch(
sbIMediaList* aMediaList,
694 Itdb_Track** aTrackBatch,
695 PRUint32 aBatchCount);
707 nsresult PlaylistUpdateProperties(
sbIMediaList* aMediaList,
729 nsresult ProcessOTGPlaylists();
731 nsresult SetOTGPlaylistName(Itdb_Playlist*
aPlaylist,
732 PRUint32 aPlaylistIndex);
756 nsTArray<PRUint32> mFPUserIDList;
763 nsresult FPConnect();
767 nsresult FPCheckTrackAuth(Itdb_Track* aTrack);
769 nsresult FPSetupTrackInfo(nsIFile* aTrackFile,
777 nsresult FPGetKeyInfo();
779 nsresult FPGetTrackAuthInfo(Itdb_Track* aTrack,
781 nsAString& aAccountName,
782 nsAString& aUserName);
791 nsresult DBConnect();
795 nsresult LibraryConnect();
797 void LibraryDisconnect();
799 nsresult InitSysInfo();
822 PRBool mPrefConnected;
823 Itdb_Prefs* mIPodPrefs;
824 PRBool mIPodPrefsDirty;
825 nsTArray<guint64> mSyncPlaylistList;
826 PRBool mSyncPlaylistListDirty;
833 nsresult PrefInitialize();
837 nsresult PrefConnect();
839 void PrefDisconnect();
846 nsresult GetMgmtType(PRUint32* aMgmtType);
848 nsresult SetMgmtType(PRUint32 aMgmtType);
850 nsresult GetIsSetUp(PRBool* aIsSetUp);
852 nsresult SetIsSetUp(PRBool aIsSetUp);
854 nsresult GetSyncPlaylistList(nsIArray** aPlaylistList);
856 nsresult SetSyncPlaylistList(nsIArray* aPlaylistList);
868 nsresult PrefConnectIPodPrefs();
870 void PrefDisconnectIPodPrefs();
872 nsresult PrefInitializeSyncPartner();
885 nsresult SyncFromIPodTracks();
887 nsresult SyncFromIPodTrack(Itdb_Track* aTrack);
894 nsresult SyncFromDevice();
896 nsresult SyncFromOTGPlaylists();
912 PRIntervalTime mStatsUpdatePeriod;
913 PRIntervalTime mLastStatsUpdate;
920 nsresult StatsInitialize();
922 void StatsFinalize();
924 void StatsUpdate(PRBool aForceUpdate);
937 nsCOMPtr<nsISupports> mIPodEventHandler;
944 nsresult CreateAndDispatchFairPlayEvent(PRUint32 aType,
946 nsAString& aAccountName,
947 nsAString& aUserName,
949 PRBool aAsync = PR_TRUE);
993 PRRWLock* mConnectLock;
998 nsCOMPtr<sbIDeviceContent> mDeviceContent;
999 nsRefPtr<sbIPDLibrary> mDeviceLibrary;
1000 nsCOMPtr<sbIMediaList> mDeviceLibraryML;
1001 nsCOMPtr<nsIPropertyBag> mCreationProperties;
1002 nsCOMPtr<nsIPropertyBag2> mCreationProperties2;
1003 nsRefPtr<sbIPDProperties> mProperties;
1004 nsCOMPtr<sbIDeviceCapabilities>
1007 Itdb_iTunesDB* mITDB;
1009 Itdb_Device* mITDBDevice;
1010 Itdb_Playlist* mMasterPlaylist;
1012 nsCOMPtr<nsIFileProtocolHandler>
1013 mFileProtocolHandler;
1014 nsCOMPtr<sbIPropertyManager> mPropertyManager;
1015 nsCOMPtr<sbILibraryManager> mLibraryManager;
1016 nsCOMPtr<nsIStringBundle> mLocale;
1019 nsString mFirewireGUID;
1021 nsString mMountPath;
1022 nsCOMPtr<sbILibrary> mSBMainLib;
1023 nsCOMPtr<sbIMediaList> mSBMainML;
1030 nsresult ImportDatabase();
1034 nsresult CapabilitiesConnect();
1039 nsresult CreateDeviceID(nsID* aDeviceID);
1041 nsresult AddNSIDHash(
unsigned char* aBuffer,
1043 nsIPropertyBag2* aPropBag,
1044 const nsAString& aProp);
1046 PRBool IsFileSystemSupported();
1048 nsresult SetUpIfNeeded();
1080 nsIRunnable** aEvent);
1097 nsRefPtr<sbIPDDevice> mDevice;
1129 mValue->mIPDStatus->
Idle(),
1136 mValue2->DeleteTrack(mValue),
1179 #define SB_IPD_DEVICE_AUTO_INVOKE(aName, aMethod) \
1180 SB_AUTO_CLASS(aName, sbIPDDevice*, mValue, mValue->aMethod, mValue = nsnull)
1183 #endif // __SB_IPD_DEVICE_H__
friend class sbIPDAutoTrack
virtual nsresult InitializeProperties()
friend class sbIPDAutoIdle
Songbird iPod Device Properties Definitions.
virtual nsresult DeviceSpecificDisconnect()
Songbird iPod Device Status Definitions.
NS_DECL_ISUPPORTS NS_DECL_SBIDEVICE NS_DECL_NSICLASSINFO sbIPDDevice(const nsID &aControllerID, nsIPropertyBag *aProperties)
const char * sbIPDSupportedAudioMediaList[]
nsresult SetIgnoreListener(PRBool aIgnoreListener)
SB_AUTO_CLASS2(sbIPDAutoTrack, Itdb_Track *, sbIPDDevice *, mValue, mValue2->DeleteTrack(mValue), mValue=NULL)
NS_DECL_ISUPPORTS static NS_DECL_NSIRUNNABLE nsresult New(sbIPDDevice *aDevice, nsIRunnable **aEvent)
PRUint32 sbIPDSupportedAudioMediaListLength
An interface to carry around arrays of nsIProperty instances Note that implementations of the interfa...
friend class sbIPDAutoDBFlush
const unsigned long REQUEST_FLAG_USER
readonly attribute AString name
Songbird iPod Device Library Definitions.
SB_AUTO_CLASS(sbIPDAutoDBFlush, sbIPDDevice *, mValue, mValue->DBFlush(), mValue=nsnull)
Media library abstraction.
nsresult SetIgnoreMediaListListeners(PRBool aIgnoreListener)
An object containing the results of a database SELECT query.
const unsigned long REQUEST_FLAG_WRITE
sbRequestThreadQueue::Batch Batch
PRUint32 sbIPDSupportedMediaListLength
An object responsible for executing SQL queries on the database.
An interface to carry around arrays of nsIProperty instances. Users of this interface should only QI ...
const char * sbIPDSupportedMediaList[]