sbRemoteMediaItem.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 "sbRemoteMediaItem.h"
28 #include "sbRemotePlayer.h"
30 
31 #include <prlog.h>
32 #include <sbClassInfoUtils.h>
33 #include <sbIPropertyManager.h>
34 #include <sbILibrary.h>
35 #include <nsServiceManagerUtils.h>
36 
37 /*
38  * To log this module, set the following environment variable:
39  * NSPR_LOG_MODULES=sbRemoteMediaItem:5
40  */
41 #ifdef PR_LOGGING
42 PRLogModuleInfo* gRemoteMediaItemLog = nsnull;
43 #endif
44 
45 #undef LOG
46 #define LOG(args) LOG_ITEM(args)
47 
48 const static char* sPublicWProperties[] = { "" };
49 
50 const static char* sPublicRProperties[] =
51 {
52  // sbILibraryResource
53  "library_read:guid",
54  "library_read:created",
55  "library_read:updated",
56 
57  // sbIMediaItem
58  // omitting library since we don't want the user to get back
59  // to the original library
60  "library_read:isMutable",
61  "library_read:mediaCreated",
62  "library_read:mediaUpdated",
63  "library_read:contentLength",
64  "library_read:contentType",
65 
66  // nsIClassInfo
67  "classinfo:classDescription",
68  "classinfo:contractID",
69  "classinfo:classID",
70  "classinfo:implementationLanguage",
71  "classinfo:flags"
72 };
73 
74 const static char* sPublicMethods[] =
75 {
76  // sbILibraryResource
77  "library_read:getProperty",
78  "library_write:setProperty",
79  "library_read:equals"
80 
81  // sbIMediaItem
82  // none applicable
83 };
84 
92 
99 
100 SB_IMPL_CLASSINFO_INTERFACES_ONLY(sbRemoteMediaItem)
101 
104  (mRemotePlayer, mMediaItem) )
105 
106 sbRemoteMediaItem::sbRemoteMediaItem(sbRemotePlayer* aRemotePlayer,
107  sbIMediaItem* aMediaItem) :
108  mRemotePlayer(aRemotePlayer),
109  mMediaItem(aMediaItem)
110 {
111  NS_ASSERTION(aRemotePlayer, "Null remote player!");
112  NS_ASSERTION(aMediaItem, "Null media item!");
113 
114 #ifdef PR_LOGGING
115  if (!gRemoteMediaItemLog) {
116  gRemoteMediaItemLog = PR_NewLogModule("sbRemoteMediaItem");
117  }
118  LOG_ITEM(("sbRemoteMediaItem::sbRemoteMediaItem()"));
119 #endif
120 }
121 
123 {
124  LOG_ITEM(("sbRemoteMediaItem::~sbRemoteMediaItem()"));
125 }
126 
127 // ---------------------------------------------------------------------------
128 //
129 // sbISecurityAggregator
130 //
131 // ---------------------------------------------------------------------------
132 
133 NS_IMETHODIMP
134 sbRemoteMediaItem::GetRemotePlayer(sbIRemotePlayer * *aRemotePlayer)
135 {
136  LOG_ITEM(( "sbRemoteMediaItem::GetRemotePlayer()"));
137  NS_ENSURE_STATE(mRemotePlayer);
138  NS_ENSURE_ARG_POINTER(aRemotePlayer);
139 
140  nsresult rv;
141  *aRemotePlayer = nsnull;
142 
143  nsCOMPtr<sbIRemotePlayer> remotePlayer;
144 
145  rv = mRemotePlayer->QueryInterface( NS_GET_IID( sbIRemotePlayer ), getter_AddRefs( remotePlayer ) );
146  NS_ENSURE_SUCCESS( rv, rv );
147 
148  remotePlayer.swap( *aRemotePlayer );
149 
150  return NS_OK;
151 }
152 
153 // ---------------------------------------------------------------------------
154 //
155 // sbIWrappedMediaItem
156 //
157 // ---------------------------------------------------------------------------
158 
159 already_AddRefed<sbIMediaItem>
161 {
162  LOG_ITEM(( "sbRemoteMediaItem::GetMediaItem()"));
163  sbIMediaItem* item = mMediaItem;
164  NS_ADDREF(item);
165  return item;
166 }
167 
static const char * sPublicWProperties[]
return NS_OK
NS_IMPL_ISUPPORTS6(sbRemoteMediaItem, nsIClassInfo, nsISecurityCheckedComponent, sbISecurityAggregator, sbIMediaItem, sbIWrappedMediaItem, sbILibraryResource) NS_IMPL_CI_INTERFACE_GETTER5(sbRemoteMediaItem
readonly attribute sbIRemotePlayer remotePlayer
This interface is a composition of many of our other interfaces with the goal of exposing a more web-...
nsCOMPtr< sbIMediaItem > mMediaItem
nsISecurityCheckedComponent
virtual already_AddRefed< sbIMediaItem > GetMediaItem()
static const char * sPublicMethods[]
A marker interface for objects that aggregate the security mixin.
General interface to data resources.
static const char * sPublicRProperties[]
nsRefPtr< sbRemotePlayer > mRemotePlayer
NS_INTERFACE_MAP_END NS_IMPL_CI_INTERFACE_GETTER5(sbLocalDatabaseMediaItem, nsIClassInfo, nsISupportsWeakReference, nsIRequestObserver, sbILibraryResource, sbIMediaItem) sbLocalDatabaseMediaItem
#define SB_IMPL_SECURITYCHECKEDCOMP_INIT_LIBRES(_class, _libres, _libresArgs)
Definition: sbRemoteAPI.h:94
Interface that defines a single item of media in the system.
#define SB_IMPL_CLASSINFO_INTERFACES_ONLY(_class)
#define LOG_ITEM(args)