sbAlbumArtScanner.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 :miv */
3 /*
4 //
5 // BEGIN SONGBIRD GPL
6 //
7 // This file is part of the Songbird web player.
8 //
9 // Copyright(c) 2005-2008 POTI, Inc.
10 // http://songbirdnest.com
11 //
12 // This file may be licensed under the terms of of the
13 // GNU General Public License Version 2 (the "GPL").
14 //
15 // Software distributed under the License is distributed
16 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
17 // express or implied. See the GPL for the specific language
18 // governing rights and limitations.
19 //
20 // You should have received a copy of the GPL along with this
21 // program. If not, go to http://www.gnu.org/licenses/gpl.html
22 // or write to the Free Software Foundation, Inc.,
23 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 // END SONGBIRD GPL
26 //
27 */
28 
29 #ifndef __SB_ALBUMARTSCANNER_H__
30 #define __SB_ALBUMARTSCANNER_H__
31 
32 //------------------------------------------------------------------------------
33 //------------------------------------------------------------------------------
34 //
35 // Songbird album art scanner
36 //
37 //------------------------------------------------------------------------------
38 //------------------------------------------------------------------------------
39 
45 //------------------------------------------------------------------------------
46 //
47 // Songbird album art scanner imported services.
48 //
49 //------------------------------------------------------------------------------
50 
51 // Songbird imports.
52 #include <sbIAlbumArtFetcherSet.h>
53 #include <sbIAlbumArtListener.h>
54 #include <sbIAlbumArtScanner.h>
55 #include <sbIAlbumArtService.h>
56 #include <sbIJobCancelable.h>
57 #include <sbIJobProgress.h>
58 #include <sbIJobProgressUI.h>
59 #include <sbILibrary.h>
60 
61 // Mozilla imports.
62 #include <nsCOMArray.h>
63 #include <nsCOMPtr.h>
64 #include <nsIArray.h>
65 #include <nsIClassInfo.h>
66 #include <nsIMutableArray.h>
67 #include <nsIStringBundle.h>
68 #include <nsITimer.h>
69 #include <nsStringGlue.h>
70 #include <nsTArray.h>
71 
72 //------------------------------------------------------------------------------
73 //
74 // Songbird album art scanner defs.
75 //
76 //------------------------------------------------------------------------------
77 
78 //
79 // Songbird album art scanner component defs.
80 //
81 
82 #define SB_ALBUMARTSCANNER_CLASSNAME "sbAlbumArtScanner"
83 #define SB_ALBUMARTSCANNER_CONTRACTID \
84  "@songbirdnest.com/Songbird/album-art/scanner;1"
85 #define SB_ALBUMARTSCANNER_CID \
86  /* {06c6e812-ca0d-4632-8e2d-2b0a8c9b0675} */ \
87  { \
88  0x06c6e812, \
89  0xca0d, \
90  0x4632, \
91  { 0x8e, 0x2d, 0x2b, 0x0a, 0x8c, 0x9b, 0x06, 0x75 } \
92  }
93 
94 // Default values for the timers (milliseconds)
95 #define ALBUMART_SCANNER_INTERVAL 10
96 
97 // Preference keys
98 #define PREF_ALBUMART_SCANNER_BRANCH "songbird.albumart.scanner."
99 #define PREF_ALBUMART_SCANNER_INTERVAL "interval"
100 
101 //------------------------------------------------------------------------------
102 //
103 // Songbird album art scanner classes.
104 //
105 //------------------------------------------------------------------------------
106 
112  public nsIClassInfo,
113  public sbIJobProgressUI,
114  public sbIJobCancelable,
115  public nsITimerCallback,
116  public sbIAlbumArtListener
117 {
118 public:
120  NS_DECL_SBIALBUMARTSCANNER
121  NS_DECL_NSICLASSINFO
122  NS_DECL_SBIJOBPROGRESS
123  NS_DECL_SBIJOBPROGRESSUI
124  NS_DECL_SBIJOBCANCELABLE
125  NS_DECL_NSITIMERCALLBACK
126  NS_DECL_SBIALBUMARTLISTENER
127 
129 
130  virtual ~sbAlbumArtScanner();
131 
132  nsresult Initialize();
133 
134 private:
138  nsresult UpdateProgress();
139 
143  nsresult ProcessAlbum();
144 
148  nsresult GetNextAlbumItems();
149 
157  nsresult MarkRemoteFetchAttempted(sbIMediaItem* aMediaItem);
158 
159  // Timers for doing our work
160  nsCOMPtr<nsITimer> mIntervalTimer;
161  PRInt32 mIntervalTimerValue;
162 
163  // Our fetcher set for scanning for album art
164  nsCOMPtr<sbIAlbumArtFetcherSet> mFetcherSet;
165 
166  // sbIAlbumArtScanner variables
167  PRBool mUpdateArtwork;
168 
169  // sbIJobProgress variables
170  PRUint16 mStatus;
171  nsTArray<nsString> mErrorMessages;
172  nsString mTitleText;
173  nsCOMArray<sbIJobProgressListener> mListeners;
174  PRUint32 mCompletedItemCount;
175  PRUint32 mTotalItemCount;
176 
177  // Info for fetcher we are currently using
178  nsCOMPtr<sbIAlbumArtFetcher> mCurrentFetcher;
179  nsAutoString mCurrentFetcherName;
180  nsAutoString mCurrentAlbumName;
181 
182  // Flag to indicate when we are ready to process the next album
183  PRBool mProcessNextAlbum;
184 
185  // List of items to scan that make up an album
186  nsCOMPtr<nsIMutableArray> mCurrentAlbumItemList;
187 
188  // The MediaView of the MediaList we are scanning.
189  nsCOMPtr<sbIMediaListView> mMediaListView;
190 
191  // String bundle for status messages.
192  nsCOMPtr<nsIStringBundle> mStringBundle;
193 };
194 
195 #endif // __SB_ALBUMARTSCANNER_H__
Interface to control UI aspects of sbIJobProgress.
NS_DECL_ISUPPORTS NS_DECL_SBIALBUMARTSCANNER NS_DECL_NSICLASSINFO NS_DECL_SBIJOBPROGRESS NS_DECL_SBIJOBPROGRESSUI NS_DECL_SBIJOBCANCELABLE NS_DECL_NSITIMERCALLBACK NS_DECL_SBIALBUMARTLISTENER sbAlbumArtScanner()
Interface for an album art scanner. Instantiate as a component instance. It also implements the sbIJo...
A component which is interested in the result of an album art fetch request.
Interface that defines a single item of media in the system.
nsITimerCallback