sbRemoteIndexedMediaItem.cpp
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25  */
26 
27 #include "sbRemoteAPIUtils.h"
29 #include "sbRemotePlayer.h"
30 
31 #include <sbClassInfoUtils.h>
32 #include <sbIMediaItem.h>
33 
34 #include <nsServiceManagerUtils.h>
35 
36 const static char* sPublicWProperties[] = { "" };
37 
38 const static char* sPublicRProperties[] =
39 {
40  // sbIIndexedMediaItem
41  "helper:index",
42  "helper:mediaItem",
43 
44  // nsIClassInfo
45  "classinfo:classDescription",
46  "classinfo:contractID",
47  "classinfo:classID",
48  "classinfo:implementationLanguage",
49  "classinfo:flags"
50 };
51 
52 const static char* sPublicMethods[] = { "" };
53 
59 
60 NS_IMPL_CI_INTERFACE_GETTER4(sbRemoteIndexedMediaItem,
65 
66 SB_IMPL_CLASSINFO_INTERFACES_ONLY(sbRemoteIndexedMediaItem)
67 
68 SB_IMPL_SECURITYCHECKEDCOMP_INIT(sbRemoteIndexedMediaItem)
69 
70 sbRemoteIndexedMediaItem::sbRemoteIndexedMediaItem(sbRemotePlayer* aRemotePlayer,
71  sbIIndexedMediaItem* aIndexedMediaItem) :
72  mRemotePlayer(aRemotePlayer),
73  mIndexedMediaItem(aIndexedMediaItem)
74 {
75  NS_ASSERTION(aRemotePlayer, "Null remote player!");
76  NS_ASSERTION(aIndexedMediaItem, "Null media item!");
77 }
78 
79 // ---------------------------------------------------------------------------
80 //
81 // sbISecurityAggregator
82 //
83 // ---------------------------------------------------------------------------
84 
85 NS_IMETHODIMP sbRemoteIndexedMediaItem::GetRemotePlayer(sbIRemotePlayer * *aRemotePlayer)
86 {
87  NS_ENSURE_STATE(mRemotePlayer);
88  NS_ENSURE_ARG_POINTER(aRemotePlayer);
89 
90  nsresult rv;
91  *aRemotePlayer = nsnull;
92 
93  nsCOMPtr<sbIRemotePlayer> remotePlayer;
94 
95  rv = mRemotePlayer->QueryInterface( NS_GET_IID( sbIRemotePlayer ), getter_AddRefs( remotePlayer ) );
96  NS_ENSURE_SUCCESS( rv, rv );
97 
98  remotePlayer.swap( *aRemotePlayer );
99 
100  return NS_OK;
101 }
102 
103 // ---------------------------------------------------------------------------
104 //
105 // sbIIndexedMediaItem
106 //
107 // ---------------------------------------------------------------------------
108 
109 NS_IMETHODIMP
110 sbRemoteIndexedMediaItem::GetIndex(PRUint32* _retval)
111 {
112  NS_ENSURE_ARG_POINTER(_retval);
113  return mIndexedMediaItem->GetIndex(_retval);
114 }
115 
116 NS_IMETHODIMP
117 sbRemoteIndexedMediaItem::GetMediaItem(sbIMediaItem** _retval)
118 {
119  NS_ENSURE_ARG_POINTER(_retval);
120 
121  nsCOMPtr<sbIMediaItem> mediaItem;
122  nsresult rv = mIndexedMediaItem->GetMediaItem( getter_AddRefs(mediaItem) );
123  NS_ENSURE_SUCCESS(rv, rv);
124 
125  nsCOMPtr<sbIMediaItem> wrappedMediaItem;
127  mediaItem,
128  getter_AddRefs(wrappedMediaItem));
129  NS_ENSURE_SUCCESS(rv, rv);
130 
131  NS_ADDREF(*_retval = wrappedMediaItem);
132  return NS_OK;
133 }
134 
#define SB_IMPL_SECURITYCHECKEDCOMP_INIT(_class)
Definition: sbRemoteAPI.h:82
return NS_OK
static const char * sPublicMethods[]
readonly attribute sbIMediaItem mediaItem
nsRefPtr< sbRemotePlayer > mRemotePlayer
static const char * sPublicWProperties[]
readonly attribute sbIRemotePlayer remotePlayer
This interface is a composition of many of our other interfaces with the goal of exposing a more web-...
nsISecurityCheckedComponent
static const char * sPublicRProperties[]
A marker interface for objects that aggregate the security mixin.
NS_IMPL_ISUPPORTS4(sbRemoteIndexedMediaItem, nsIClassInfo, nsISecurityCheckedComponent, sbIIndexedMediaItem, sbISecurityAggregator) NS_IMPL_CI_INTERFACE_GETTER4(sbRemoteIndexedMediaItem
A container for a media item and its index.
static nsresult SB_WrapMediaItem(sbRemotePlayer *aRemotePlayer, sbIMediaItem *aMediaItem, sbIMediaItem **aRemoteMediaItem)
Interface that defines a single item of media in the system.
nsCOMPtr< sbIIndexedMediaItem > mIndexedMediaItem
#define SB_IMPL_CLASSINFO_INTERFACES_ONLY(_class)