27 #include <sbIPropertyArray.h>
28 #include <sbIPropertyManager.h>
29 #include <nsITreeView.h>
31 #include <nsAutoPtr.h>
33 #include <nsNetUtil.h>
34 #include <nsServiceManagerUtils.h>
35 #include <nsUnicharUtils.h>
48 mClickHandlers(nsnull)
56 delete mClickHandlers;
64 mImages =
new nsClassHashtable<nsCStringHashKey, nsCString>();
65 NS_ENSURE_TRUE(mImages, NS_ERROR_OUT_OF_MEMORY);
66 mLabels =
new nsClassHashtable<nsCStringHashKey, nsString>();
67 NS_ENSURE_TRUE(mLabels, NS_ERROR_OUT_OF_MEMORY);
68 mClickHandlers =
new nsTHashtable<nsISupportsHashKey>();
69 NS_ENSURE_TRUE(mClickHandlers, NS_ERROR_OUT_OF_MEMORY);
72 mClickHandlers->Init();
74 NS_ENSURE_SUCCESS(rv, rv);
85 nsRefPtr<sbImageLabelLinkPropertyInfo> info =
87 rv = info->Init(mImages, mLabels, mClickHandlers);
88 NS_ENSURE_SUCCESS(rv, rv);
90 NS_ENSURE_SUCCESS(rv, rv);
92 NS_ENSURE_SUCCESS(rv, rv);
94 NS_ENSURE_SUCCESS(rv, rv);
96 NS_ENSURE_SUCCESS(rv, rv);
98 NS_ENSURE_SUCCESS(rv, rv);
100 NS_ENSURE_SUCCESS(rv, rv);
102 NS_ENSURE_SUCCESS(rv, rv);
104 return CallQueryInterface(info.get(), _retval);
111 sbImageLabelLinkPropertyBuilder::AddImage(
const nsACString & aKey,
112 const nsACString & aImageUrl)
114 NS_ENSURE_TRUE(mImages, NS_ERROR_NOT_INITIALIZED);
115 PRBool success = mImages->Put(aKey,
new nsCString(aImageUrl));
116 NS_ENSURE_TRUE(success, NS_ERROR_OUT_OF_MEMORY);
122 sbImageLabelLinkPropertyBuilder::GetImage(
const nsACString & aKey,
123 nsACString & _retval NS_OUTPARAM)
125 NS_ENSURE_TRUE(mImages, NS_ERROR_NOT_INITIALIZED);
127 nsCString
key(aKey), *result;
130 if (mImages->Get(aKey, &result)) {
131 _retval.Assign(*result);
135 if (mImages->Get(nsCString(), &result)) {
136 _retval.Assign(*result);
146 sbImageLabelLinkPropertyBuilder::AddLabel(
const nsACString & aKey,
147 const nsAString & aLabel)
149 NS_ENSURE_TRUE(mLabels, NS_ERROR_NOT_INITIALIZED);
151 nsString
value(aLabel);
153 if (StringBeginsWith(aLabel, NS_LITERAL_STRING(
"&")) &&
154 StringEndsWith(aLabel, NS_LITERAL_STRING(
";")))
160 PRBool success = mLabels->Put(aKey,
new nsString(
value));
161 NS_ENSURE_TRUE(success, NS_ERROR_OUT_OF_MEMORY);
167 sbImageLabelLinkPropertyBuilder::GetLabel(
const nsACString & aKey,
168 nsAString & _retval NS_OUTPARAM)
170 NS_ENSURE_TRUE(mLabels, NS_ERROR_NOT_INITIALIZED);
175 if (mLabels->Get(aKey, &result)) {
176 _retval.Assign(*result);
180 if (mLabels->Get(nsCString(), &result)) {
181 _retval.Assign(*result);
192 sbImageLabelLinkPropertyBuilder::AddClickHandler(
195 NS_ENSURE_TRUE(mClickHandlers, NS_ERROR_NOT_INITIALIZED);
196 nsISupportsHashKey*
entry = mClickHandlers->PutEntry(aCallback);
197 NS_ENSURE_TRUE(entry, NS_ERROR_OUT_OF_MEMORY);
203 sbImageLabelLinkPropertyBuilder::RemoveClickHandler(
206 NS_ENSURE_TRUE(mClickHandlers, NS_ERROR_NOT_INITIALIZED);
207 mClickHandlers->RemoveEntry(aCallback);
PRPackedBool mUserEditable
virtual ~sbImageLabelLinkPropertyBuilder()
PRPackedBool mRemoteReadable
An interface used to describe a metadata property for use by the UI and other sbILibrary interfaces (...
NS_IMPL_ISUPPORTS_INHERITED2(sbImageLabelLinkPropertyBuilder, sbAbstractPropertyBuilder, sbIImageLabelLinkPropertyBuilder, sbIClickablePropertyBuilder) sbImageLabelLinkPropertyBuilder
PRPackedBool mUserViewable
PRPackedBool mRemoteWritable
NS_IMETHOD Get(sbIPropertyInfo **_retval)