30 #include <nsArrayEnumerator.h>
31 #include <nsAutoPtr.h>
32 #include <nsISimpleEnumerator.h>
41 static PRLogModuleInfo* gPropInfoLog = nsnull;
44 #define LOG(args) PR_LOG(gPropInfoLog, PR_LOG_WARN, args)
46 #define __FUNCTION__ __PRETTY_FUNCTION__
58 const nsAString& aOperatorReadable)
60 , mOperator(aOperator)
61 , mOperatorReadable(aOperatorReadable)
69 NS_IMETHODIMP sbPropertyOperator::GetOperator(nsAString & aOperator)
75 NS_IMETHODIMP sbPropertyOperator::GetOperatorReadable(nsAString & aOperatorReadable)
83 NS_ENSURE_TRUE(
mInitialized == PR_FALSE, NS_ERROR_ALREADY_INITIALIZED);
94 , mSecondarySortLock(nsnull)
95 , mSecondarySort(nsnull)
98 , mDisplayNameLock(nsnull)
99 , mLocalizationKeyLock(nsnull)
100 , mUserViewableLock(nsnull)
101 , mUserViewable(PR_FALSE)
102 , mUserEditableLock(nsnull)
103 , mUserEditable(PR_TRUE)
104 , mOperatorsLock(nsnull)
105 , mRemoteReadableLock(nsnull)
106 , mRemoteReadable(PR_FALSE)
107 , mRemoteWritableLock(nsnull)
108 , mRemoteWritable(PR_FALSE)
109 , mUnitConverterLock(nsnull)
110 , mUnitConverter(nsnull)
111 , mUsedInIdentityLock(nsnull)
112 , mUsedInIdentity(PR_FALSE)
116 gPropInfoLog = PR_NewLogModule(
"sbPropInfo");
120 mSecondarySortLock = PR_NewLock();
122 NS_ASSERTION(mSecondarySortLock,
123 "sbPropertyInfo::mSecondarySortLock failed to create lock!");
125 mIDLock = PR_NewLock();
126 NS_ASSERTION(mIDLock,
127 "sbPropertyInfo::mIDLock failed to create lock!");
129 mTypeLock = PR_NewLock();
130 NS_ASSERTION(mTypeLock,
131 "sbPropertyInfo::mTypeLock failed to create lock!");
133 mDisplayNameLock = PR_NewLock();
134 NS_ASSERTION(mDisplayNameLock,
135 "sbPropertyInfo::mDisplayNameLock failed to create lock!");
137 mLocalizationKeyLock = PR_NewLock();
138 NS_ASSERTION(mLocalizationKeyLock,
139 "sbPropertyInfo::mLocalizationKeyLock failed to create lock!");
141 mUserViewableLock = PR_NewLock();
142 NS_ASSERTION(mUserViewableLock,
143 "sbPropertyInfo::mUserViewableLock failed to create lock!");
145 mUserEditableLock = PR_NewLock();
146 NS_ASSERTION(mUserEditableLock,
147 "sbPropertyInfo::mUserEditableLock failed to create lock!");
149 mOperatorsLock = PR_NewLock();
150 NS_ASSERTION(mOperatorsLock,
151 "sbPropertyInfo::mOperatorsLock failed to create lock!");
153 mRemoteReadableLock = PR_NewLock();
154 NS_ASSERTION(mRemoteReadableLock,
155 "sbPropertyInfo::mRemoteReadableLock failed to create lock!");
157 mRemoteWritableLock = PR_NewLock();
158 NS_ASSERTION(mRemoteWritableLock,
159 "sbPropertyInfo::mRemoteWritableLock failed to create lock!");
161 mUnitConverterLock = PR_NewLock();
162 NS_ASSERTION(mUnitConverterLock,
163 "sbPropertyInfo::mUnitConverterLock failed to create lock!");
165 mUsedInIdentityLock = PR_NewLock();
166 NS_ASSERTION(mUsedInIdentityLock,
167 "sbPropertyInfo::mUsedInIdentityLock failed to create lock!");
226 nsRefPtr<sbPropertyOperator> propOp;
228 rv = sbPropertyInfo::GetOPERATOR_ISSET(op);
229 NS_ENSURE_SUCCESS(rv, rv);
231 NS_ENSURE_TRUE(propOp, NS_ERROR_OUT_OF_MEMORY);
233 NS_ENSURE_SUCCESS(rv, rv);
235 rv = sbPropertyInfo::GetOPERATOR_ISNOTSET(op);
236 NS_ENSURE_SUCCESS(rv, rv);
238 NS_ENSURE_TRUE(propOp, NS_ERROR_OUT_OF_MEMORY);
240 NS_ENSURE_SUCCESS(rv, rv);
245 NS_IMETHODIMP sbPropertyInfo::GetOPERATOR_EQUALS(nsAString & aOPERATOR_EQUALS)
251 NS_IMETHODIMP sbPropertyInfo::GetOPERATOR_NOTEQUALS(nsAString & aOPERATOR_NOTEQUALS)
257 NS_IMETHODIMP sbPropertyInfo::GetOPERATOR_GREATER(nsAString & aOPERATOR_GREATER)
263 NS_IMETHODIMP sbPropertyInfo::GetOPERATOR_GREATEREQUAL(nsAString & aOPERATOR_GREATEREQUAL)
269 NS_IMETHODIMP sbPropertyInfo::GetOPERATOR_LESS(nsAString & aOPERATOR_LESS)
275 NS_IMETHODIMP sbPropertyInfo::GetOPERATOR_LESSEQUAL(nsAString & aOPERATOR_LESSEQUAL)
281 NS_IMETHODIMP sbPropertyInfo::GetOPERATOR_CONTAINS(nsAString & aOPERATOR_CONTAINS)
287 NS_IMETHODIMP sbPropertyInfo::GetOPERATOR_NOTCONTAINS(nsAString & aOPERATOR_NOTCONTAINS)
293 NS_IMETHODIMP sbPropertyInfo::GetOPERATOR_BEGINSWITH(nsAString & aOPERATOR_BEGINSWITH)
299 NS_IMETHODIMP sbPropertyInfo::GetOPERATOR_NOTBEGINSWITH(nsAString & aOPERATOR_NOTBEGINSWITH)
305 NS_IMETHODIMP sbPropertyInfo::GetOPERATOR_ENDSWITH(nsAString & aOPERATOR_ENDSWITH)
311 NS_IMETHODIMP sbPropertyInfo::GetOPERATOR_NOTENDSWITH(nsAString & aOPERATOR_NOTENDSWITH)
317 NS_IMETHODIMP sbPropertyInfo::GetOPERATOR_BETWEEN(nsAString & aOPERATOR_BETWEEN)
323 NS_IMETHODIMP sbPropertyInfo::GetOPERATOR_ISSET(nsAString & aOPERATOR_ISSET)
329 NS_IMETHODIMP sbPropertyInfo::GetOPERATOR_ISNOTSET(nsAString & aOPERATOR_ISNOTSET)
335 NS_IMETHODIMP sbPropertyInfo::SetNullSort(PRUint32 aNullSort)
340 NS_IMETHODIMP sbPropertyInfo::GetNullSort(PRUint32 *aNullSort)
342 NS_ENSURE_ARG_POINTER(aNullSort);
347 NS_IMETHODIMP sbPropertyInfo::SetSecondarySort(
sbIPropertyArray * aSecondarySort)
349 NS_ENSURE_ARG_POINTER(aSecondarySort);
365 return NS_ERROR_ALREADY_INITIALIZED;
372 NS_IMETHODIMP sbPropertyInfo::GetSecondarySort(
sbIPropertyArray * *aSecondarySort)
374 NS_ENSURE_ARG_POINTER(aSecondarySort);
378 NS_IF_ADDREF(*aSecondarySort);
383 NS_IMETHODIMP sbPropertyInfo::GetId(nsAString & aID)
389 NS_IMETHODIMP sbPropertyInfo::SetId(
const nsAString &aID)
391 LOG((
"sbPropertyInfo::SetId(%s)", NS_LossyConvertUTF16toASCII(aID).
get() ));
400 return NS_ERROR_ALREADY_INITIALIZED;
403 NS_IMETHODIMP sbPropertyInfo::GetType(nsAString & aType)
409 NS_IMETHODIMP sbPropertyInfo::SetType(
const nsAString &aType)
413 if(
mType.IsEmpty()) {
418 return NS_ERROR_ALREADY_INITIALIZED;
421 NS_IMETHODIMP sbPropertyInfo::GetDisplayName(nsAString & aDisplayName)
435 NS_IMETHODIMP sbPropertyInfo::SetDisplayName(
const nsAString &aDisplayName)
444 return NS_ERROR_ALREADY_INITIALIZED;
448 NS_IMETHODIMP sbPropertyInfo::GetLocalizationKey(nsAString & aLocalizationKey)
454 aLocalizationKey =
mID;
462 NS_IMETHODIMP sbPropertyInfo::SetLocalizationKey(
const nsAString & aLocalizationKey)
471 return NS_ERROR_ALREADY_INITIALIZED;
475 NS_IMETHODIMP sbPropertyInfo::GetUserViewable(PRBool *aUserViewable)
477 NS_ENSURE_ARG_POINTER(aUserViewable);
485 NS_IMETHODIMP sbPropertyInfo::SetUserViewable(PRBool aUserViewable)
493 NS_IMETHODIMP sbPropertyInfo::GetUserEditable(PRBool *aUserEditable)
495 NS_ENSURE_ARG_POINTER(aUserEditable);
503 NS_IMETHODIMP sbPropertyInfo::SetUserEditable(PRBool aUserEditable)
513 NS_ENSURE_ARG_POINTER(aOperators);
516 return NS_NewArrayEnumerator(aOperators,
mOperators);
520 NS_ENSURE_ARG_POINTER(aOperators);
526 nsCOMPtr<nsISupports>
object;
528 while( NS_SUCCEEDED(aOperators->HasMoreElements(&hasMore)) &&
530 NS_SUCCEEDED(aOperators->GetNext(getter_AddRefs(
object)))) {
532 nsCOMPtr<sbIPropertyOperator> po = do_QueryInterface(
object, &rv);
533 NS_ENSURE_SUCCESS(rv, rv);
536 NS_ENSURE_TRUE(success, NS_ERROR_OUT_OF_MEMORY);
542 NS_IMETHODIMP sbPropertyInfo::GetOperator(
const nsAString & aOperator,
545 NS_ENSURE_ARG_POINTER(_retval);
550 for (PRUint32
i = 0;
i < length;
i++) {
553 NS_ENSURE_SUCCESS(rv, rv);
554 if (op.Equals(aOperator)) {
564 NS_IMETHODIMP sbPropertyInfo::Validate(
const nsAString &
aValue, PRBool *_retval)
566 NS_ENSURE_ARG_POINTER(_retval);
571 NS_IMETHODIMP sbPropertyInfo::Sanitize(
const nsAString &
aValue, nsAString & _retval)
573 return NS_ERROR_NOT_IMPLEMENTED;
576 NS_IMETHODIMP sbPropertyInfo::Format(
const nsAString &
aValue, nsAString & _retval)
582 NS_IMETHODIMP sbPropertyInfo::MakeSearchable(
const nsAString &
aValue, nsAString & _retval)
588 NS_IMETHODIMP sbPropertyInfo::MakeSortable(
const nsAString &
aValue, nsAString & _retval)
593 return MakeSearchable(aValue, _retval);
596 NS_IMETHODIMP sbPropertyInfo::GetRemoteReadable(PRBool *aRemoteReadable)
598 NS_ENSURE_ARG_POINTER(aRemoteReadable);
606 NS_IMETHODIMP sbPropertyInfo::SetRemoteReadable(PRBool aRemoteReadable)
614 NS_IMETHODIMP sbPropertyInfo::GetRemoteWritable(PRBool *aRemoteWritable)
616 NS_ENSURE_ARG_POINTER(aRemoteWritable);
624 NS_IMETHODIMP sbPropertyInfo::SetRemoteWritable(PRBool aRemoteWritable)
634 NS_ENSURE_ARG_POINTER(aUnitConverter);
640 *aUnitConverter = nsnull;
655 NS_IMETHODIMP sbPropertyInfo::GetUsedInIdentity(PRBool *aUsedInIdentity)
657 NS_ENSURE_ARG_POINTER(aUsedInIdentity);
665 NS_IMETHODIMP sbPropertyInfo::SetUsedInIdentity(PRBool aUsedInIdentity)
PRLock * mDisplayNameLock
PRLock * mUnitConverterLock
PRLock * mRemoteWritableLock
#define SB_OPERATOR_NOTEQUALS
virtual ~sbPropertyInfo()
#define SB_OPERATOR_CONTAINS
#define SB_OPERATOR_NOTCONTAINS
#define SB_OPERATOR_ISNOTSET
PRLock * mLocalizationKeyLock
PRLock * mUsedInIdentityLock
NS_IMETHOD SetUnitConverter(sbIPropertyUnitConverter *aUnitConverter)
#define SB_OPERATOR_BEGINSWITH
nsCOMPtr< sbIPropertyUnitConverter > mUnitConverter
#define SB_OPERATOR_GREATER
PRLock * mRemoteReadableLock
#define SB_OPERATOR_EQUALS
NS_DECL_ISUPPORTS NS_DECL_SBIPROPERTYOPERATOR sbPropertyOperator()
#define SB_OPERATOR_LESSEQUAL
nsCOMPtr< sbIPropertyArray > mSecondarySort
PRLock * mUserEditableLock
NS_IMPL_THREADSAFE_ISUPPORTS1(sbDeviceCapsCompatibility, sbIDeviceCapsCompatibility) sbDeviceCapsCompatibility
An interface to represent an operator that may act upon a property.
An interface used to describe a metadata property for use by the UI and other sbILibrary interfaces (...
#define SB_OPERATOR_NOTENDSWITH
NS_IMPL_THREADSAFE_ISUPPORTS2(sbDeviceCapabilities, sbIDeviceCapabilities, nsIClassInfo) NS_IMPL_CI_INTERFACE_GETTER2(sbDeviceCapabilities
#define SB_OPERATOR_ISSET
nsString mLocalizationKey
#define SB_OPERATOR_NOTBEGINSWITH
PRLock * mUserViewableLock
StringArrayEnumerator prototype hasMore
Property unit converter interface This is an interface songbird property converter, used to convert a property value between its various units representations.
#define SB_OPERATOR_GREATEREQUAL
nsCOMArray< sbIPropertyOperator > mOperators
#define SB_OPERATOR_BETWEEN
void Init(in AString aOperator, in aString aOperatorReadable)
Initialize the operator.
#define SB_OPERATOR_ENDSWITH
An interface to carry around arrays of nsIProperty instances. Users of this interface should only QI ...
_getSelectedPageStyle s i
PRLock * mSecondarySortLock
nsString mOperatorReadable
PRPackedBool mInitialized