sbIMediaItemDownloader.idl
Go to the documentation of this file.
1 /* -*- Mode: IDL; 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 // Mozilla imports.
28 #include "nsISupports.idl"
29 
30 // Interface declarations.
31 interface sbILibrary;
32 interface sbIMediaItem;
33 interface sbIMediaItemDownloadJob;
34 
50 [scriptable, uuid(65b0423e-1dd2-11b2-8f1d-8a6e9596b52a)]
52 {
53  //
54  // Downloader vote defs.
55  //
56  // When voting to download a media item, downloaders may use one of these
57  // downloader vote constants. Downloaders may return whatever vote value they
58  // deem appropriate. These constants are provided as a guideline.
59  //
60 
64  const unsigned long VOTE_NONE = 0;
65 
69  const unsigned long VOTE_SCHEME = 100;
70 
74  const unsigned long VOTE_HOST = 200;
75 
79  const unsigned long VOTE_WHOLE_URL = 300;
80 
84  const unsigned long VOTE_MEDIA_ITEM_PROPERTIES = 400;
85 
92  const unsigned long VOTE_TARGET_LIBRARY = 500;
93 
94 
109  unsigned long vote(in sbIMediaItem aMediaItem,
110  in sbILibrary aTargetLibrary);
111 
123  unsigned long long getDownloadSize(in sbIMediaItem aMediaItem,
124  in sbILibrary aTargetLibrary);
125 
138  in sbILibrary aTargetLibrary);
139 };
140 
141 
142 //
143 // C++ defs.
144 //
145 
146 %{C++
147 
148 #include <nsIComponentManager.h>
149 #include <nsICategoryManager.h>
150 #include <nsIGenericFactory.h>
151 #include <nsIServiceManager.h>
152 
153 #include <nsCOMPtr.h>
154 #include <nsServiceManagerUtils.h>
155 #include <nsStringGlue.h>
156 #include <nsXPCOMCID.h>
157 
158 class nsIFile;
159 struct nsModuleComponentInfo;
160 
161 #define SB_MEDIA_ITEM_DOWNLOADER_CATEGORY "songbird-media-item-downloader"
162 
184 #define SB_MEDIA_ITEM_DOWNLOADER_REGISTERSELF(_name) \
185  \
186  NS_METHOD _name##RegisterSelf(nsIComponentManager* aCompMgr, \
187  nsIFile* aPath, \
188  const char* registryLocation, \
189  const char* componentType, \
190  const nsModuleComponentInfo* info); \
191  \
192  NS_METHOD _name##UnregisterSelf(nsIComponentManager* aCompMgr, \
193  nsIFile* aPath, \
194  const char* registryLocation, \
195  const nsModuleComponentInfo* info);
196 
200 #define SB_MEDIA_ITEM_DOWNLOADER_REGISTERSELF_IMPL(_name) \
201  \
202  NS_METHOD \
203  _name##RegisterSelf(nsIComponentManager* aCompMgr, \
204  nsIFile* aPath, \
205  const char* registryLocation, \
206  const char* componentType, \
207  const nsModuleComponentInfo* info) \
208  { \
209  nsresult rv; \
210  nsCOMPtr<nsICategoryManager> catMan = \
211  do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv); \
212  NS_ENSURE_SUCCESS(rv, rv); \
213  nsCAutoString prevEntry; \
214  rv = catMan->AddCategoryEntry(SB_MEDIA_ITEM_DOWNLOADER_CATEGORY, \
215  info->mContractID, \
216  info->mContractID, \
217  PR_TRUE, PR_TRUE, \
218  getter_Copies(prevEntry)); \
219  NS_ENSURE_SUCCESS(rv, rv); \
220  NS_WARN_IF_FALSE(prevEntry.IsEmpty(), \
221  "Another downloader was registered with that id!"); \
222  return NS_OK; \
223  } \
224  \
225  NS_METHOD \
226  _name##UnregisterSelf(nsIComponentManager* aCompMgr, \
227  nsIFile* aPath, \
228  const char* registryLocation, \
229  const nsModuleComponentInfo* info) \
230  { \
231  nsresult rv; \
232  nsCOMPtr<nsICategoryManager> catMan = \
233  do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv); \
234  NS_ENSURE_SUCCESS(rv, rv); \
235  rv = catMan->DeleteCategoryEntry(SB_MEDIA_ITEM_DOWNLOADER_CATEGORY, \
236  info->mContractID, \
237  PR_TRUE); \
238  NS_ENSURE_SUCCESS(rv, rv); \
239  return NS_OK; \
240  }
241 %}
242 
sbIMediaItemDownloadJob createDownloadJob(in sbIMediaItem aMediaItem, in sbILibrary aTargetLibrary)
unsigned long long getDownloadSize(in sbIMediaItem aMediaItem, in sbILibrary aTargetLibrary)
var uuid
function C(H)
const unsigned long VOTE_WHOLE_URL
Media library abstraction.
Definition: sbILibrary.idl:82
unsigned long vote(in sbIMediaItem aMediaItem, in sbILibrary aTargetLibrary)
const unsigned long VOTE_TARGET_LIBRARY
Interface that defines a single item of media in the system.
const unsigned long VOTE_SCHEME
const unsigned long VOTE_MEDIA_ITEM_PROPERTIES