27 #ifndef SBITUNESIMPORTER_H_
28 #define SBITUNESIMPORTER_H_
34 #include <nsDataHashtable.h>
35 #include <nsIRunnable.h>
36 #include <nsStringAPI.h>
38 #include <sbILibraryImporter.h>
39 #include <sbIiTunesXMLParserListener.h>
59 #ifdef SB_ENABLE_TEST_HARNESS
65 #define SBITUNESIMPORTER_CONTRACTID \
66 "@songbirdnest.com/Songbird/ITunesImporter;1"
67 #define SBITUNESIMPORTER_CLASSNAME \
68 "iTunes Library Importer"
70 #define SBITUNESIMPORTER_CID \
71 { 0x56202248, 0xe7ab, 0x4e45, { 0xbf, 0xf3, 0xf2, 0x96, 0x84, 0x46, 0x88, 0xc4 } }
91 NS_DECL_SBILIBRARYIMPORTER
92 NS_DECL_SBIITUNESXMLPARSERLISTENER
106 static PRUint32
const BATCH_SIZE = 100;
110 static PRUint32
const DATA_FORMAT_VERSION = 2;
113 typedef nsCOMPtr<nsIThread> nsIThreadPtr;
115 typedef nsCOMPtr<sbIAlbumArtFetcherSet> sbIAlbumArtFetcherSetPtr;
116 typedef nsCOMPtr<sbIMediacoreTypeSniffer> sbIMediacoreTypeSnifferPtr;
117 typedef nsCOMPtr<nsIInputStream> nsIInputStreamPtr;
118 typedef nsCOMPtr<nsIIOService> nsIIOServicePtr;
119 typedef nsCOMPtr<sbILibraryImporterListener> sbILibraryImporterListenerPtr;
121 typedef nsCOMPtr<sbILocalDatabaseLibrary> sbILocalDatabaseLibraryPtr;
122 #ifdef SB_ENABLE_TEST_HARNESS
123 typedef nsCOMPtr<sbITimingService> sbITimingServicePtr;
125 typedef nsRefPtr<sbiTunesXMLParser> sbiTunesXMLParserPtr;
129 typedef std::auto_ptr<sbiTunesImporterStatus> sbiTunesImporterStatusPtr;
133 typedef nsDataHashtable<nsStringHashKey, nsString> StringMap;
138 typedef std::vector<iTunesTrack *> TrackBatch;
143 typedef std::map<nsString, nsString> TrackIDMap;
148 typedef std::map<nsString, PRUint32> TracksByID;
160 nsIIOService * aIOService,
166 nsCOMPtr<nsIURI> mURI;
172 sbIAlbumArtFetcherSetPtr mAlbumArtFetcher;
180 PRInt32 mDataFormatVersion;
184 PRBool mFoundChanges;
193 PRBool mImportPlaylists;
197 nsIIOServicePtr mIOService;
201 nsIInputStreamPtr mStream;
210 nsString miTunesLibID;
219 sbILocalDatabaseLibraryPtr mLDBLibrary;
227 nsString mLibraryPath;
231 sbILibraryImporterListenerPtr mListener;
235 PRUint32 mMissingMediaCount;
243 sbiTunesXMLParserPtr mParser;
247 nsString mPlaylistAction;
251 nsString mPlaylistBlacklist;
255 nsString mSongbirdFolderID;
259 sbiTunesImporterStatusPtr mStatus;
263 #ifdef SB_ENABLE_TEST_HARNESS
264 sbITimingServicePtr mTimingService;
269 nsString mTimingServiceIdentifier;
273 PRUint32 mTrackCount;
277 TrackBatch mTrackBatch;
281 TrackIDMap mTrackIDMap;
285 sbIMediacoreTypeSnifferPtr mTypeSniffer;
289 PRUint32 mUnsupportedMediaCount;
303 nsAString
const & aLibPath,
309 static void DestructiTunesTrack(iTunesTrack * aTrack);
313 nsresult GetDirtyPlaylistAction(nsAString
const & aPlaylistName,
314 nsAString & aAction);
328 PRUint32 aTrackIdsCount,
335 nsresult ProcessCreatedItems(
336 nsIArray * aCreatedItems,
337 TracksByID
const & aTrackMap);
343 nsresult ProcessNewItems(TracksByID & aTrackMap,
344 nsIArray ** aNewItems);
352 nsresult ProcessPlaylistItems(
sbIMediaList * aMediaList,
354 PRUint32 aTrackIdsCount);
358 nsresult ProcessTrackBatch();
362 nsresult ProcessUpdates();
372 PRBool ShouldImportPlaylist(
sbIStringMap * aProperties);
376 nsresult UpdateProgress();
Interface for importing external libraries.
nsCOMPtr< nsIArray > mProperties
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
Interface for an album art fetcher set. Instantiate as a component instance.
Media library abstraction.
An interface for running simple, time based, profiling.
An interface to carry around arrays of nsIProperty instances. Users of this interface should only QI ...
nsCOMPtr< sbILibrary > sbILibraryPtr
NS_DECL_ISUPPORTS NS_DECL_SBILIBRARYIMPORTER NS_DECL_SBIITUNESXMLPARSERLISTENER sbiTunesImporter()