sbRemoteSiteMediaItem.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 "sbRemoteSiteMediaItem.h"
29 #include "sbRemotePlayer.h"
30 
31 #include <prlog.h>
32 #include <sbClassInfoUtils.h>
33 #include <sbStandardProperties.h>
34 
35 /*
36  * To log this module, set the following environment variable:
37  * NSPR_LOG_MODULES=sbRemoteSiteMediaItem:5
38  * LOG_ITEM defined in sbRemoteMediaItem.h/.cpp
39  */
40 #undef LOG
41 #define LOG(args) LOG_ITEM(args)
42 
43 const static char* sPublicWProperties[] = {""};
44 
45 const static char* sPublicRProperties[] =
46 {
47  // sbILibraryResource
48  "site:guid",
49  "site:created",
50  "site:updated",
51 
52  // sbIMediaItem
53  // omitting library since we don't want the user to get back
54  // to the original library
55  "site:isMutable",
56  "site:mediaCreated",
57  "site:mediaUpdated",
58  "site:contentSrc",
59  "site:contentLength",
60  "site:contentType",
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  // sbILibraryResource
73  "site:getProperty",
74  "site:setProperty",
75  "site:equals"
76 
77  // sbIMediaItem
78  // none applicable
79 };
80 
83 
84 NS_IMETHODIMP
85 sbRemoteSiteMediaItemSecurityMixin::CanGetProperty( const nsIID* aIID,
86  const PRUnichar* aPropertyID,
87  char** _retval )
88 {
89  LOG_ITEM(("sbRemoteSiteMediaItemSecurityMixin::CanGetProperty()"));
90  nsresult rv = sbSecurityMixin::CanGetProperty( aIID, aPropertyID, _retval );
91  NS_ENSURE_SUCCESS( rv, rv );
92 
93  if (mPrivileged) {
94  return NS_OK;
95  }
96 
97  nsDependentString propID(aPropertyID);
98  if (propID.EqualsLiteral("contentSrc")) {
99  nsCOMPtr<nsIURI> uri;
100  rv = mMediaItem->GetContentSrc(getter_AddRefs(uri));
101  NS_ENSURE_SUCCESS( rv, rv );
102 
103  PRBool isFileURI;
104  rv = uri->SchemeIs( "file" , &isFileURI );
105  NS_ENSURE_SUCCESS( rv, rv );
106 
107  if (isFileURI) {
108  NS_WARNING("Disallowing access to 'file:' URI from contentSrc attribute");
109  return NS_ERROR_FAILURE;
110  }
111  }
112 
113  return NS_OK;
114 }
115 
118  nsIClassInfo )
119 
123  sbIMediaItem,
126 
127 SB_IMPL_CLASSINFO_INTERFACES_ONLY(sbRemoteSiteMediaItem)
128 
131  (mMediaItem),
133  (mRemotePlayer, mMediaItem) )
134 
135 
136 sbRemoteSiteMediaItem::sbRemoteSiteMediaItem(sbRemotePlayer* aRemotePlayer,
137  sbIMediaItem* aMediaItem) :
138  sbRemoteMediaItem(aRemotePlayer, aMediaItem)
139 {
140  LOG_ITEM(("sbRemoteSiteMediaItem::sbRemoteSiteMediaItem()"));
141  NS_ASSERTION( aMediaItem, "Null media item!" );
142 }
143 
145 {
146  LOG_ITEM(("sbRemoteSiteMediaItem::~sbRemoteSiteMediaItem()"));
147 }
148 
return NS_OK
nsISecurityCheckedComponent
NS_IMPL_ISUPPORTS_INHERITED0(sbRemoteSiteMediaItemSecurityMixin, sbSecurityMixin) NS_IMETHODIMP sbRemoteSiteMediaItemSecurityMixin
NS_IMPL_ISUPPORTS_INHERITED1(sbRemoteSiteMediaItem, sbRemoteMediaItem, nsIClassInfo) NS_IMPL_CI_INTERFACE_GETTER5(sbRemoteSiteMediaItem
static const char * sPublicWProperties[]
A marker interface for objects that aggregate the security mixin.
General interface to data resources.
var uri
Definition: FeedWriter.js:1135
static const char * sPublicRProperties[]
NS_INTERFACE_MAP_END NS_IMPL_CI_INTERFACE_GETTER5(sbLocalDatabaseMediaItem, nsIClassInfo, nsISupportsWeakReference, nsIRequestObserver, sbILibraryResource, sbIMediaItem) sbLocalDatabaseMediaItem
Interface that defines a single item of media in the system.
#define SB_IMPL_SECURITYCHECKEDCOMP_INIT_MIXIN_LIBRES(_class,_mixin, _mixinArgs,_libres, _libresArgs)
Definition: sbRemoteAPI.h:86
#define SB_IMPL_CLASSINFO_INTERFACES_ONLY(_class)
static const char * sPublicMethods[]
#define LOG_ITEM(args)