42 #include "nsArrayEnumerator.h"
43 #include "nsComponentManagerUtils.h"
44 #include "nsIVariant.h"
45 #include "nsIProperty.h"
52 return NS_ERROR_OUT_OF_MEMORY;
56 nsresult rv = hpb->
Init();
73 NS_INTERFACE_MAP_ENTRY(nsIWritablePropertyBag)
74 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIPropertyBag, nsIWritablePropertyBag)
75 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(
nsISupports, nsIWritablePropertyBag)
76 NS_INTERFACE_MAP_ENTRY(nsIPropertyBag2)
77 NS_INTERFACE_MAP_ENTRY(nsIWritablePropertyBag2)
84 if (!mPropertyHash.Init())
85 return NS_ERROR_OUT_OF_MEMORY;
90 sbPropertyBag::HasKey(
const nsAString&
name, PRBool *aResult)
98 sbPropertyBag::Get(
const nsAString& name, nsIVariant* *_retval)
110 return NS_ERROR_FAILURE;
116 sbPropertyBag::SetProperty(
const nsAString& name, nsIVariant *
value)
118 NS_ENSURE_ARG_POINTER(value);
122 return NS_ERROR_FAILURE;
128 sbPropertyBag::DeleteProperty(
const nsAString& name)
135 return NS_ERROR_FAILURE;
172 nsSimpleProperty::GetValue(nsIVariant* *
aValue)
174 NS_IF_ADDREF(*aValue =
mValue);
185 nsIMutableArray *propertyArray =
186 static_cast<nsIMutableArray *
>(userArg);
188 propertyArray->AppendElement(sprop, PR_FALSE);
189 return PL_DHASH_NEXT;
197 nsCOMPtr<nsIMutableArray> propertyArray =
198 do_CreateInstance(
"@songbirdnest.com/moz/xpcom/threadsafe-array;1", &rv);
199 NS_ENSURE_SUCCESS(rv, rv);
201 return NS_ERROR_OUT_OF_MEMORY;
205 return NS_NewArrayEnumerator(_retval, propertyArray);
208 #define IMPL_GETSETPROPERTY_AS(Name, Type) \
210 sbPropertyBag::GetPropertyAs ## Name (const nsAString & prop, Type *_retval) \
212 nsCOMPtr<nsIVariant> v; \
213 nsresult rv = mPropertyHash.Get(prop, getter_AddRefs(v)); \
214 NS_ENSURE_SUCCESS(rv, rv); \
216 return NS_ERROR_NOT_AVAILABLE; \
217 return v->GetAs ## Name(_retval); \
221 sbPropertyBag::SetPropertyAs ## Name (const nsAString & prop, Type value) \
224 nsCOMPtr<nsIWritableVariant> var = \
225 do_CreateInstance("@songbirdnest.com/Songbird/Variant;1", &rv); \
226 NS_ENSURE_SUCCESS(rv, rv); \
228 return NS_ERROR_OUT_OF_MEMORY; \
229 var->SetAs ## Name(value); \
230 return SetProperty(prop, var); \
242 sbPropertyBag::GetPropertyAsAString(const nsAString & prop, nsAString & _retval)
244 nsCOMPtr<nsIVariant> v;
245 nsresult rv = mPropertyHash.Get(prop, getter_AddRefs(v));
246 NS_ENSURE_SUCCESS(rv, rv);
248 return NS_ERROR_NOT_AVAILABLE;
249 return v->GetAsAString(_retval);
253 sbPropertyBag::GetPropertyAsACString(
const nsAString & prop, nsACString & _retval)
255 nsCOMPtr<nsIVariant> v;
257 NS_ENSURE_SUCCESS(rv, rv);
259 return NS_ERROR_NOT_AVAILABLE;
260 return v->GetAsACString(_retval);
264 sbPropertyBag::GetPropertyAsAUTF8String(
const nsAString & prop, nsACString & _retval)
266 nsCOMPtr<nsIVariant> v;
268 NS_ENSURE_SUCCESS(rv, rv);
270 return NS_ERROR_NOT_AVAILABLE;
271 return v->GetAsAUTF8String(_retval);
275 sbPropertyBag::GetPropertyAsInterface(
const nsAString & prop,
279 nsCOMPtr<nsIVariant> v;
281 NS_ENSURE_SUCCESS(rv, rv);
283 return NS_ERROR_NOT_AVAILABLE;
284 nsCOMPtr<nsISupports>
val;
285 rv = v->GetAsISupports(getter_AddRefs(val));
293 return val->QueryInterface(aIID, _retval);
297 sbPropertyBag::SetPropertyAsAString(
const nsAString & prop,
const nsAString & value)
300 nsCOMPtr<nsIWritableVariant> var =
301 do_CreateInstance(
"@songbirdnest.com/Songbird/Variant;1", &rv);
302 NS_ENSURE_SUCCESS(rv, rv);
304 return NS_ERROR_OUT_OF_MEMORY;
305 var->SetAsAString(value);
306 return SetProperty(prop, var);
310 sbPropertyBag::SetPropertyAsACString(
const nsAString & prop,
const nsACString & value)
313 nsCOMPtr<nsIWritableVariant> var =
314 do_CreateInstance(
"@songbirdnest.com/Songbird/Variant;1", &rv);
315 NS_ENSURE_SUCCESS(rv, rv);
317 return NS_ERROR_OUT_OF_MEMORY;
318 var->SetAsACString(value);
319 return SetProperty(prop, var);
323 sbPropertyBag::SetPropertyAsAUTF8String(
const nsAString & prop,
const nsACString & value)
326 nsCOMPtr<nsIWritableVariant> var =
327 do_CreateInstance(
"@songbirdnest.com/Songbird/Variant;1", &rv);
328 NS_ENSURE_SUCCESS(rv, rv);
330 return NS_ERROR_OUT_OF_MEMORY;
331 var->SetAsAUTF8String(value);
332 return SetProperty(prop, var);
336 sbPropertyBag::SetPropertyAsInterface(
const nsAString & prop,
nsISupports* value)
339 nsCOMPtr<nsIWritableVariant> var =
340 do_CreateInstance(
"@songbirdnest.com/Songbird/Variant;1", &rv);
341 NS_ENSURE_SUCCESS(rv, rv);
343 return NS_ERROR_OUT_OF_MEMORY;
344 var->SetAsISupports(value);
345 return SetProperty(prop, var);
PR_STATIC_CALLBACK(PRBool) FindElementCallback(void *aElement
NS_IMPL_ISUPPORTS1(sbDeviceCapabilitiesUtils, sbIDeviceCapabilitiesUtils) sbDeviceCapabilitiesUtils
nsSimpleProperty(const nsAString &aName, nsIVariant *aValue)
nsCOMPtr< nsIVariant > mValue
nsresult SB_NewHashPropertyBag(nsIWritablePropertyBag **_retval)
NS_IMPL_THREADSAFE_RELEASE(sbRequestItem)
NS_IMPL_THREADSAFE_ADDREF(sbRequestItem)
nsInterfaceHashtableMT< nsStringHashKey, nsIVariant > mPropertyHash
PropertyHashToArrayFunc(const nsAString &aKey, nsIVariant *aData, void *userArg)
this _dialogInput val(dateText)
static nsresult GetProperty(nsIPropertyBag2 *aProperties, nsAString const &aProp, nsAString &aValue)
#define IMPL_GETSETPROPERTY_AS(Name, Type)
_updateTextAndScrollDataForFrame aData