sbBaseMediaItemDownloadJob.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  *=BEGIN SONGBIRD GPL
5  *
6  * This file is part of the Songbird web player.
7  *
8  * Copyright(c) 2005-2010 POTI, Inc.
9  * http://www.songbirdnest.com
10  *
11  * This file may be licensed under the terms of of the
12  * GNU General Public License Version 2 (the ``GPL'').
13  *
14  * Software distributed under the License is distributed
15  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
16  * express or implied. See the GPL for the specific language
17  * governing rights and limitations.
18  *
19  * You should have received a copy of the GPL along with this
20  * program. If not, go to http://www.gnu.org/licenses/gpl.html
21  * or write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23  *
24  *=END SONGBIRD GPL
25  */
26 
27 #ifndef SB_BASE_MEDIA_ITEM_DOWNLOAD_JOB_H_
28 #define SB_BASE_MEDIA_ITEM_DOWNLOAD_JOB_H_
29 
30 //------------------------------------------------------------------------------
31 //------------------------------------------------------------------------------
32 //
33 // Base media item download job defs.
34 //
35 //------------------------------------------------------------------------------
36 //------------------------------------------------------------------------------
37 
43 //------------------------------------------------------------------------------
44 //
45 // Base media item download job imported services.
46 //
47 //------------------------------------------------------------------------------
48 
49 // Songbird imports.
50 #include <sbIFileDownloader.h>
51 #include <sbIJobProgress.h>
52 #include <sbIJobCancelable.h>
53 #include <sbILibrary.h>
54 #include <sbIMediaItem.h>
55 #include <sbIMediaItemDownloadJob.h>
56 #include <sbIPropertyArray.h>
57 #include <sbITemporaryFileFactory.h>
58 
59 // Mozilla imports.
60 #include <nsCOMPtr.h>
61 #include <nsTArray.h>
62 
63 
64 //------------------------------------------------------------------------------
65 //
66 // Base media item download job classes.
67 //
68 //------------------------------------------------------------------------------
69 
70 // Class declarations.
71 class nsIURI;
72 
79  public sbIJobCancelable,
81 {
82  //----------------------------------------------------------------------------
83  //
84  // Public interface.
85  //
86  //----------------------------------------------------------------------------
87 
88 public:
89 
90  //
91  // XPCOM interfaces.
92  //
93 
95  NS_DECL_SBIMEDIAITEMDOWNLOADJOB
96  NS_DECL_SBIJOBPROGRESS
97  NS_DECL_SBIJOBCANCELABLE
98  NS_DECL_SBIFILEDOWNLOADERLISTENER
99 
100 
101  //
102  // Public Base media item download job services.
103  //
104 
108  virtual ~sbBaseMediaItemDownloadJob();
109 
110 
111  //----------------------------------------------------------------------------
112  //
113  // Protected interface.
114  //
115  //----------------------------------------------------------------------------
116 
117 protected:
118 
119  //
120  // mLock Lock used for thread support.
121  // mMediaItem Media item to download.
122  // mProperties Downloaded media item properties array.
123  // mTargetLibrary Library for which the media item will be
124  // downloaded.
125  // mFileDownloader File downloader object.
126  // mTemporaryFileFactory Temporary file factory to use for temporary
127  // files.
128  // mListenerList List of download job listeners.
129  // mStatus Download status.
130  //
131 
132  PRLock* mLock;
133  nsCOMPtr<sbIMediaItem> mMediaItem;
134  nsCOMPtr<sbIMutablePropertyArray>
136  nsCOMPtr<sbILibrary> mTargetLibrary;
137  nsCOMPtr<sbIFileDownloader> mFileDownloader;
138  nsCOMPtr<sbITemporaryFileFactory>
140  nsTArray< nsCOMPtr<sbIJobProgressListener> >
142  PRUint16 mStatus;
143 
144 
153  virtual nsresult Start(nsIURI* aURI);
154 
159  virtual nsresult Stop();
160 
168  virtual nsresult GetDownloadURI(nsIURI** aURI);
169 
173  virtual nsresult Initialize();
174 
185  sbILibrary* aTargetLibrary = nsnull);
186 };
187 
188 
189 #endif // SB_BASE_MEDIA_ITEM_DOWNLOAD_JOB_H_
190 
sbBaseMediaItemDownloadJob(sbIMediaItem *aMediaItem, sbILibrary *aTargetLibrary=nsnull)
nsCOMPtr< sbIMutablePropertyArray > mProperties
virtual nsresult Start(nsIURI *aURI)
nsCOMPtr< sbITemporaryFileFactory > mTemporaryFileFactory
virtual nsresult GetDownloadURI(nsIURI **aURI)
Media library abstraction.
Definition: sbILibrary.idl:82
nsTArray< nsCOMPtr< sbIJobProgressListener > > mListenerList
nsCOMPtr< sbIMediaItem > mMediaItem
NS_DECL_ISUPPORTS NS_DECL_SBIMEDIAITEMDOWNLOADJOB NS_DECL_SBIJOBPROGRESS NS_DECL_SBIJOBCANCELABLE virtual NS_DECL_SBIFILEDOWNLOADERLISTENER ~sbBaseMediaItemDownloadJob()
nsCOMPtr< sbIFileDownloader > mFileDownloader
Interface that defines a single item of media in the system.