sbRemoteMediaItemStatusEvent.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 
28 #include "sbRemoteAPIUtils.h"
29 #include "sbRemotePlayer.h"
30 
31 #include <sbClassInfoUtils.h>
32 
33 #include <sbIMediaItemStatusEvent.h>
34 
35 #include <nsComponentManagerUtils.h>
36 #include <nsIProgrammingLanguage.h>
37 #include <nsMemory.h>
38 #include <prlog.h>
39 
40 /*
41  * To log this module, set the following environment variable:
42  * NSPR_LOG_MODULES=sbRemoteMediaItemStatusEvent:5
43  */
44 #ifdef PR_LOGGING
45 static PRLogModuleInfo* gRemoteEventLog = nsnull;
46 #endif
47 
48 #undef LOG
49 #define LOG(args) PR_LOG(gRemoteEventLog, PR_LOG_WARN, args)
50 
51 const static char* sPublicWProperties[] = { "" };
52 
53 const static char* sPublicRProperties[] =
54 {
55  // sbIMediaItemStatusEvent
56  "helper:item",
57  "helper:status",
58 
59  // nsIDOMEventTarget
60  "helper:type",
61 
62  // nsIClassInfo
63  "classinfo:classDescription",
64  "classinfo:contractID",
65  "classinfo:classID",
66  "classinfo:implementationLanguage",
67  "classinfo:flags"
68 };
69 
70 const static char* sPublicMethods[] =
71 {
72  // no applicable methods
73  ""
74 };
75 
79  nsIDOMNSEvent,
80  nsIPrivateDOMEvent,
84 
91 
92 SB_IMPL_CLASSINFO_INTERFACES_ONLY(sbRemoteMediaItemStatusEvent)
93 
94 SB_IMPL_SECURITYCHECKEDCOMP_INIT(sbRemoteMediaItemStatusEvent)
95 
96 sbRemoteMediaItemStatusEvent::sbRemoteMediaItemStatusEvent( sbRemotePlayer* aRemotePlayer ) :
97  mRemotePlayer(aRemotePlayer),
98  mStatus( NS_OK )
99 {
100  NS_ASSERTION(aRemotePlayer, "aRemotePlayer is null");
101  MOZ_COUNT_CTOR(sbRemoteMediaItemStatusEvent);
102 #ifdef PR_LOGGING
103  if (!gRemoteEventLog) {
104  gRemoteEventLog = PR_NewLogModule("sbRemoteMediaItemStatusEvent");
105  }
106  LOG(("sbRemoteMediaItemStatusEvent::sbRemoteMediaItemStatusEvent()"));
107 #endif
108 }
109 
111 {
112  MOZ_COUNT_DTOR(sbRemoteMediaItemStatusEvent);
113 }
114 
115 // ---------------------------------------------------------------------------
116 //
117 // sbISecurityAggregator
118 //
119 // ---------------------------------------------------------------------------
120 
121 NS_IMETHODIMP
122 sbRemoteMediaItemStatusEvent::GetRemotePlayer(sbIRemotePlayer * *aRemotePlayer)
123 {
124  NS_ENSURE_STATE(mRemotePlayer);
125  NS_ENSURE_ARG_POINTER(aRemotePlayer);
126 
127  nsresult rv;
128  *aRemotePlayer = nsnull;
129 
130  nsCOMPtr<sbIRemotePlayer> remotePlayer;
131 
132  rv = mRemotePlayer->QueryInterface( NS_GET_IID( sbIRemotePlayer ), getter_AddRefs( remotePlayer ) );
133  NS_ENSURE_SUCCESS( rv, rv );
134 
135  remotePlayer.swap( *aRemotePlayer );
136 
137  return NS_OK;
138 }
139 
141  sbIMediaItem* aMediaItem,
142  PRInt32 aStatus )
143 {
144  NS_ENSURE_ARG( aEvent );
145  NS_ENSURE_ARG( aMediaItem );
146  nsresult rv;
147 
148  mStatus = aStatus;
149 
150  rv = SB_WrapMediaItem(mRemotePlayer, aMediaItem, getter_AddRefs(mWrappedItem));
151  NS_ENSURE_SUCCESS(rv, rv);
152 
153  mEvent = aEvent;
154  mNSEvent = do_QueryInterface( mEvent, &rv );
155  NS_ENSURE_SUCCESS(rv, rv);
156 
157  return NS_OK;
158 }
159 
160 /*** sbIMediaItemStatusEvent ***/
161 /* readonly attribute sbIMediaItem item; */
162 NS_IMETHODIMP sbRemoteMediaItemStatusEvent::GetItem(sbIMediaItem * *aItem)
163 {
164  NS_ENSURE_ARG(aItem);
165 
166  if (!mWrappedItem) {
167  *aItem = nsnull;
168  return NS_OK;
169  }
170  NS_IF_ADDREF(*aItem = mWrappedItem.get());
171  return (*aItem ? NS_OK : NS_ERROR_FAILURE);
172 }
173 
174 /* readonly attribute long status; */
175 NS_IMETHODIMP sbRemoteMediaItemStatusEvent::GetStatus(PRInt32 *aStatus)
176 {
177  NS_ENSURE_ARG(aStatus);
178 
179  *aStatus = mStatus;
180  return NS_OK;
181 }
182 
183 /*** nsIPrivateDOMEvent ***/
184 // this macro forwards a method to the inner event (up to one arg)
185 #define FORWARD_NSIPRIVATEDOMEVENT(_method, _type, _arg, _rettype, _default) \
186  NS_IMETHODIMP_(_rettype) sbRemoteMediaItemStatusEvent::_method( _type _arg ) \
187  { \
188  nsresult rv; \
189  nsCOMPtr<nsIPrivateDOMEvent> inner( do_QueryInterface(mEvent, &rv) ); \
190  NS_ENSURE_SUCCESS(rv, _default); \
191  return inner->_method( _arg ); \
192  }
193 
194 FORWARD_NSIPRIVATEDOMEVENT(DuplicatePrivateData, , , nsresult, rv)
195 FORWARD_NSIPRIVATEDOMEVENT(SetTarget, nsIDOMEventTarget*, aTarget, nsresult, rv)
196 FORWARD_NSIPRIVATEDOMEVENT(IsDispatchStopped, , , PRBool, PR_FALSE)
197 FORWARD_NSIPRIVATEDOMEVENT(GetInternalNSEvent, , , nsEvent*, nsnull)
198 FORWARD_NSIPRIVATEDOMEVENT(SetTrusted, PRBool, aTrusted, nsresult, rv)
static const char * sPublicWProperties[]
NS_IMPL_ISUPPORTS7(sbRemoteMediaItemStatusEvent, nsIClassInfo, nsIDOMEvent, nsIDOMNSEvent, nsIPrivateDOMEvent, nsISecurityCheckedComponent, sbIMediaItemStatusEvent, sbISecurityAggregator) NS_IMPL_CI_INTERFACE_GETTER5(sbRemoteMediaItemStatusEvent
#define SB_IMPL_SECURITYCHECKEDCOMP_INIT(_class)
Definition: sbRemoteAPI.h:82
return NS_OK
#define LOG(args)
static const char * sPublicMethods[]
#define FORWARD_NSIPRIVATEDOMEVENT(_method, _type, _arg, _rettype, _default)
readonly attribute sbIRemotePlayer remotePlayer
This interface is a composition of many of our other interfaces with the goal of exposing a more web-...
A marker interface for objects that aggregate the security mixin.
NS_IMETHOD InitEvent(nsIDOMEvent *, sbIMediaItem *, PRInt32)
NS_INTERFACE_MAP_END NS_IMPL_CI_INTERFACE_GETTER5(sbLocalDatabaseMediaItem, nsIClassInfo, nsISupportsWeakReference, nsIRequestObserver, sbILibraryResource, sbIMediaItem) sbLocalDatabaseMediaItem
static nsresult SB_WrapMediaItem(sbRemotePlayer *aRemotePlayer, sbIMediaItem *aMediaItem, sbIMediaItem **aRemoteMediaItem)
Interface that defines a single item of media in the system.
an interface to maintain information about the last event that occurred
#define SB_IMPL_CLASSINFO_INTERFACES_ONLY(_class)
nsRefPtr< sbRemotePlayer > mRemotePlayer
static const char * sPublicRProperties[]