33 #include <sbIPropertyManager.h>
34 #include <sbIRemoteMediaList.h>
35 #include <sbIMediaListView.h>
36 #include <sbIMediaListViewSelection.h>
38 #include <sbIPropertyBuilder.h>
40 #include <nsAutoPtr.h>
41 #include <nsIDOMElement.h>
42 #include <nsServiceManagerUtils.h>
43 #include <nsStringGlue.h>
51 static PRLogModuleInfo* gRemoteWebPlaylistLog = nsnull;
55 #define LOG(args) PR_LOG(gRemoteWebPlaylistLog, PR_LOG_WARN, args)
71 "classinfo:classDescription",
72 "classinfo:contractID",
74 "classinfo:implementationLanguage",
82 "site:setSelectionByIndex",
83 "site:showColumnBefore",
88 "site:getColumnCount",
90 "site:insertColumnBefore",
92 "site:getColumnPropertyIDByIndex",
118 mRemotePlayer(aRemotePlayer),
119 mPlaylistWidget(aWebPlaylistWidget),
120 mOwnerTab(aTabBrowserTab)
122 NS_ASSERTION( aRemotePlayer,
"Null remote player!" );
123 NS_ASSERTION( aWebPlaylistWidget,
"Null playlist widget!" );
124 NS_ASSERTION( aTabBrowserTab,
"Null playlist widget!" );
127 if (!gRemoteWebPlaylistLog) {
128 gRemoteWebPlaylistLog = PR_NewLogModule(
"sbRemoteWebPlaylist");
130 LOG((
"sbRemoteWebPlaylist::sbRemoteWebPlaylist()"));
144 NS_ENSURE_ARG_POINTER(aRemotePlayer);
147 *aRemotePlayer = nsnull;
152 NS_ENSURE_SUCCESS( rv, rv );
154 remotePlayer.swap( *aRemotePlayer );
168 LOG((
"sbRemoteWebPlaylist::SetMediaList()"));
169 NS_ENSURE_ARG_POINTER(aMediaList);
172 nsCOMPtr<sbIMediaListView> mediaListView;
173 rv = aMediaList->GetView( getter_AddRefs(mediaListView) );
174 if (!mediaListView) {
176 nsCOMPtr<sbIMediaList> webMediaList = do_QueryInterface(aMediaList);
177 NS_ENSURE_TRUE( webMediaList, NS_ERROR_INVALID_ARG );
179 rv = webMediaList->CreateView( nsnull, getter_AddRefs(mediaListView) );
180 NS_ENSURE_TRUE( mediaListView, NS_ERROR_FAILURE );
184 NS_ENSURE_SUCCESS( rv, rv );
187 NS_ENSURE_SUCCESS( rv, rv );
190 rv = Bind( mediaListView, nsnull, PR_FALSE, PR_FALSE );
191 NS_ENSURE_SUCCESS( rv, rv );
195 NS_ENSURE_SUCCESS( rv, rv );
201 NS_ENSURE_SUCCESS( rv, rv );
213 LOG((
"sbRemoteWebPlaylist::GetMediaList()"));
214 NS_ENSURE_ARG_POINTER(aMediaList);
218 nsCOMPtr<sbIMediaListView> mediaListView;
219 rv = GetListView( getter_AddRefs(mediaListView) );
220 NS_ENSURE_SUCCESS( rv, rv );
223 if (!mediaListView) {
224 LOG((
"sbRemoteWebPlaylist::GetMediaList() - NO MEDIA LIST VIEW" ));
226 return NS_ERROR_FAILURE;
236 LOG((
"sbRemoteWebPlaylist::GetSelection()"));
241 nsCOMPtr<sbIMediaListView> mediaListView;
242 nsresult rv = GetListView( getter_AddRefs(mediaListView) );
243 NS_ENSURE_SUCCESS( rv, rv );
245 nsCOMPtr<sbIMediaListViewSelection> viewSelection;
246 mediaListView->GetSelection( getter_AddRefs(viewSelection) );
247 NS_ENSURE_TRUE( viewSelection, NS_ERROR_UNEXPECTED );
251 rv = viewSelection->GetSelectedIndexedMediaItems( getter_AddRefs(selection) );
252 NS_ENSURE_SUCCESS( rv, rv );
255 nsRefPtr<sbRemoteWrappingSimpleEnumerator> wrapped(
257 NS_ENSURE_TRUE( wrapped, NS_ERROR_OUT_OF_MEMORY );
259 rv = wrapped->Init();
260 NS_ENSURE_SUCCESS( rv, rv );
262 NS_ADDREF( *aSelection = wrapped );
267 sbRemoteWebPlaylist::SetSelectionByIndex( PRUint32 aIndex, PRBool aSelected )
269 LOG((
"sbRemoteWebPlaylist::SetSelectionByIndex()"));
273 nsCOMPtr<sbIMediaListView> mediaListView;
274 nsresult rv = GetListView( getter_AddRefs(mediaListView) );
275 NS_ENSURE_SUCCESS( rv, rv );
277 nsCOMPtr<sbIMediaListViewSelection> viewSelection;
278 mediaListView->GetSelection( getter_AddRefs(viewSelection) );
279 NS_ENSURE_TRUE( viewSelection, NS_ERROR_UNEXPECTED );
282 rv = viewSelection->Select(aIndex);
283 NS_ENSURE_SUCCESS(rv, rv);
286 rv = viewSelection->Clear(aIndex);
287 NS_ENSURE_SUCCESS(rv, rv);
296 LOG((
"sbRemoteWebPlaylist::SetSelectionByIndex()"));
297 NS_ENSURE_ARG_POINTER(aWebPlaylist);
303 sbRemoteWebPlaylist::SetHidden(PRBool aHide)
305 LOG((
"sbRemoteWebPlaylist::SetHidden()"));
319 sbRemoteWebPlaylist::GetHidden(PRBool* aHidden)
321 NS_ENSURE_ARG_POINTER(aHidden);
322 LOG((
"sbRemoteWebPlaylist::GetHidden()"));
326 rv =
mOwnerTab->GetOuterPlaylistShowing(&showing);
327 NS_ENSURE_SUCCESS(rv, rv);
static nsresult SB_WrapMediaList(sbRemotePlayer *aRemotePlayer, sbIMediaList *aMediaList, sbIMediaList **aRemoteMediaList)
An interface to control a media list from remote web pages.
#define SB_IMPL_SECURITYCHECKEDCOMP_INIT(_class)
static const char * sPublicMethods[]
NS_IMPL_ISUPPORTS5(sbRemoteWebPlaylist, nsIClassInfo, nsISecurityCheckedComponent, sbISecurityAggregator, sbIRemoteWebPlaylist, sbIPlaylistWidget) NS_IMPL_CI_INTERFACE_GETTER4(sbRemoteWebPlaylist
readonly attribute sbIRemotePlayer remotePlayer
This interface is a composition of many of our other interfaces with the goal of exposing a more web-...
nsresult GetPlaylistWidget(sbIPlaylistWidget **aWebPlaylist)
nsISecurityCheckedComponent
static const char * sPublicWProperties[]
A marker interface for objects that aggregate the security mixin.
nsCOMPtr< sbIPlaylistWidget > mPlaylistWidget
static const char * sPublicRProperties[]
nsRefPtr< sbRemotePlayer > mRemotePlayer
#define SB_IMPL_CLASSINFO_INTERFACES_ONLY(_class)
nsCOMPtr< sbITabBrowserTab > mOwnerTab
readonly attribute nsISimpleEnumerator selection