27 #include <sbILibrary.h>
28 #include <sbIPropertyInfo.h>
29 #include <sbIPropertyManager.h>
34 #include <nsServiceManagerUtils.h>
41 PRLogModuleInfo* gRemoteLibResLog = nsnull;
49 mRemotePlayer(aRemotePlayer),
50 mMediaItem(aMediaItem)
52 NS_ASSERTION( aRemotePlayer,
"Null remote player!" );
53 NS_ASSERTION( aMediaItem,
"Null media item!" );
56 if (!gRemoteLibResLog) {
57 gRemoteLibResLog = PR_NewLogModule(
"sbRemoteLibraryResource");
59 LOG_RES((
"sbRemoteLibraryResource::sbRemoteLibraryResource()"));
64 LOG_RES((
"sbRemoteLibraryResource::~sbRemoteLibraryResource()"));
76 NS_ENSURE_TRUE(
mMediaItem, NS_ERROR_NULL_POINTER );
77 LOG_RES((
"sbRemoteLibraryResource::GetProperty(%s)",
78 NS_LossyConvertUTF16toASCII(aID).
get() ));
83 nsCOMPtr<sbIPropertyManager> propertyManager =
84 do_GetService(
"@songbirdnest.com/Songbird/Properties/PropertyManager;1",
86 NS_ENSURE_SUCCESS( rv, rv );
89 nsCOMPtr<sbIPropertyInfo> propertyInfo;
90 rv = propertyManager->GetPropertyInfo( aID, getter_AddRefs(propertyInfo) );
91 NS_ENSURE_SUCCESS( rv, rv );
95 rv = propertyInfo->GetRemoteReadable(&readable);
96 NS_ENSURE_SUCCESS( rv, rv );
100 LOG_RES((
"Attempting to get a property's (%s) value that is not allowed "
101 "to be read from the remote API!",
102 NS_LossyConvertUTF16toASCII(aID).
get() ));
104 return NS_ERROR_FAILURE;
110 NS_ENSURE_SUCCESS( rv, rv );
117 if ( StringBeginsWith( propVal, NS_LITERAL_STRING(
"file:") ) ) {
118 LOG_RES((
"sbRemoteLibraryResource::GetProperty() - "
119 "Disallowing access to 'file:' URI." ));
121 propVal.AssignLiteral(
"__BLOCKED__");
123 LOG_RES((
"sbRemoteLibraryResource::GetProperty() - "
124 "Allowing access to non-file value: %s",
125 NS_LossyConvertUTF16toASCII(propVal).
get() ));
129 _retval.Assign(propVal);
137 LOG_RES((
"sbRemoteLibraryResource::SetProperty( %s, %s )",
138 NS_LossyConvertUTF16toASCII(aID).
get(),
139 NS_LossyConvertUTF16toASCII(aValue).
get() ));
141 NS_ASSERTION(
mMediaItem,
"SetProperty called before Initialization" );
146 nsCOMPtr<sbIPropertyManager> propertyManager =
147 do_GetService(
"@songbirdnest.com/Songbird/Properties/PropertyManager;1",
149 NS_ENSURE_SUCCESS( rv, rv );
154 rv = propertyManager->HasProperty( aID, &hasProp );
158 nsCOMPtr<sbIPropertyInfo> propertyInfo;
159 rv = propertyManager->GetPropertyInfo( aID, getter_AddRefs(propertyInfo) );
160 NS_ENSURE_SUCCESS( rv, rv );
165 PRBool writable = PR_FALSE;
166 rv = propertyInfo->GetRemoteWritable(&writable);
167 NS_ENSURE_SUCCESS( rv, rv );
172 LOG_RES((
"Attempting to set a property's (%s) value that is not allowed "
173 "to be set from the remote API!",
174 NS_LossyConvertUTF16toASCII(aID).
get() ));
175 return NS_ERROR_FAILURE;
180 rv = propertyInfo->SetRemoteWritable(PR_TRUE);
181 NS_ENSURE_SUCCESS( rv, rv );
183 rv = propertyInfo->SetRemoteReadable(PR_TRUE);
184 NS_ENSURE_SUCCESS( rv, rv );
189 NS_ENSURE_SUCCESS( rv, rv );
191 nsCOMPtr<sbILibrary> library;
192 rv =
mMediaItem->GetLibrary( getter_AddRefs(library) );
193 NS_ENSURE_SUCCESS( rv, rv );
204 LOG_RES((
"sbRemoteLibraryResource::SetProperties()"));
205 NS_ENSURE_ARG_POINTER( aProperties );
206 NS_ASSERTION(
mMediaItem,
"SetProperties called before Initialization" );
208 nsresult rv =
mMediaItem->SetProperties(aProperties);
209 NS_ENSURE_SUCCESS( rv, rv );
211 nsCOMPtr<sbILibrary> library;
212 rv =
mMediaItem->GetLibrary( getter_AddRefs(library) );
213 NS_ENSURE_SUCCESS( rv, rv );
virtual ~sbRemoteLibraryResource()
#define SB_PROPERTY_ORIGINURL
NS_IMETHOD GetProperty(const nsAString &aID, nsAString &_retval)
nsCOMPtr< sbIMediaItem > mMediaItem
NS_IMETHOD SetProperties(sbIPropertyArray *aProperties)
General interface to data resources.
NS_IMPL_ISUPPORTS1(sbRemoteLibraryResource, sbILibraryResource) sbRemoteLibraryResource
nsRefPtr< sbRemotePlayer > mRemotePlayer
NS_IMETHOD SetProperty(const nsAString &aID, const nsAString &aValue)
#define SB_PROPERTY_COPYRIGHTURL
An interface to carry around arrays of nsIProperty instances. Users of this interface should only QI ...
#define SB_PROPERTY_PRIMARYIMAGEURL