sbDownloadButtonPropertyInfo.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 #define SB_STRING_BUNDLE_CHROME_URL "chrome://songbird/locale/songbird.properties"
28 
30 #include "sbStandardOperators.h"
31 
32 #include <sbIPropertyArray.h>
33 #include <sbIPropertyManager.h>
34 #include <nsIStringBundle.h>
35 #include <nsITreeView.h>
36 #include <nsServiceManagerUtils.h>
37 
42 
43 /*
44  * The value of download button properties is formatted as follows:
45  *
46  * <mode>|<total size>|<current size>
47  *
48  * mode can be: 0 = none, 1 = new, 2 = starting, 3 = downloading, 4 = paused,
49  5 = complete, 6 = failed
50  * total size and current size are in btyes.
51  *
52  */
54  const nsAString& aDisplayName,
55  const nsAString& aLocalizationKey,
56  const nsAString& aLabel,
57  const nsAString& aRetryLabel,
58  const PRBool aRemoteReadable,
59  const PRBool aRemoteWritable,
60  const PRBool aUserViewable,
61  const PRBool aUserEditable)
62 {
63  mID = aPropertyID;
64  mDisplayName = aDisplayName;
65  mLocalizationKey = aLocalizationKey;
66  mLabel = aLabel;
67  mRetryLabel = aRetryLabel;
68  mUserViewable = aUserViewable;
69  mUserEditable = aUserEditable;
70  mRemoteReadable = aRemoteReadable;
71  mRemoteWritable = aRemoteWritable;
72  mType.AssignLiteral("downloadbutton");
73  mSuppressSelect = PR_TRUE;
74 }
75 
76 nsresult
78 {
79  nsresult rv;
80 
82  NS_ENSURE_SUCCESS(rv, rv);
83 
84  return NS_OK;
85 }
86 
87 // sbITreeViewPropertyInfo
88 
89 NS_IMETHODIMP
90 sbDownloadButtonPropertyInfo::GetImageSrc(const nsAString& aValue,
91  nsAString& _retval)
92 {
93  _retval.Truncate();
94  return NS_OK;
95 }
96 
97 NS_IMETHODIMP
98 sbDownloadButtonPropertyInfo::GetProgressMode(const nsAString& aValue,
99  PRInt32* _retval)
100 {
101  NS_ENSURE_ARG_POINTER(_retval);
102 
104 
105  switch(value.GetMode()) {
110  *_retval = nsITreeView::PROGRESS_NONE;
111  break;
113  *_retval = nsITreeView::PROGRESS_UNDETERMINED;
114  break;
117  *_retval = nsITreeView::PROGRESS_NORMAL;
118  break;
119  }
120 
121  return NS_OK;
122 }
123 
124 NS_IMETHODIMP
125 sbDownloadButtonPropertyInfo::GetCellValue(const nsAString& aValue,
126  nsAString& _retval)
127 {
129 
130  switch(value.GetMode()) {
133  if (value.GetTotal() > 0) {
134  PRFloat64 progress =
135  ((PRFloat64) value.GetCurrent() / (PRFloat64) value.GetTotal()) * 100;
136  _retval.AppendInt((PRUint32) progress);
137  }
138  break;
139  default:
140  _retval.Truncate();
141  }
142 
143  return NS_OK;
144 }
145 
146 NS_IMETHODIMP
147 sbDownloadButtonPropertyInfo::GetRowProperties(const nsAString& aValue,
148  nsAString& _retval)
149 {
150  _retval.Truncate();
151  return NS_OK;
152 }
153 
154 NS_IMETHODIMP
155 sbDownloadButtonPropertyInfo::GetCellProperties(const nsAString& aValue,
156  nsAString& _retval)
157 {
159 
160  switch(value.GetMode()) {
162  _retval.AssignLiteral("button");
163  break;
165  _retval.AssignLiteral("progressNotStarted");
166  break;
168  _retval.AssignLiteral("progressCompleted");
169  break;
171  _retval.AssignLiteral("progressPaused");
172  break;
174  _retval.AssignLiteral("button progressFailed");
175  break;
176  default:
177  _retval.Truncate();
178  }
179 
180  _retval.AppendLiteral(" downloadbutton");
181 
182  return NS_OK;
183 }
184 
185 NS_IMETHODIMP
186 sbDownloadButtonPropertyInfo::GetColumnType(nsAString& _retval)
187 {
188  _retval.AssignLiteral("progressmeter");
189  return NS_OK;
190 }
191 
192 // sbIClickablePropertyInfo
193 
194 NS_IMETHODIMP
195 sbDownloadButtonPropertyInfo::GetSuppressSelect(PRBool* aSuppressSelect)
196 {
197  NS_ENSURE_ARG_POINTER(aSuppressSelect);
198  *aSuppressSelect = mSuppressSelect;
199  return NS_OK;
200 }
201 
202 NS_IMETHODIMP
203 sbDownloadButtonPropertyInfo::SetSuppressSelect(PRBool aSuppressSelect)
204 {
205  mSuppressSelect = aSuppressSelect;
206  return NS_OK;
207 }
208 
209 NS_IMETHODIMP
210 sbDownloadButtonPropertyInfo::IsDisabled(const nsAString& aCurrentValue,
211  PRBool* _retval)
212 {
213  NS_ENSURE_ARG_POINTER(_retval);
214  *_retval = PR_FALSE;
215  return NS_OK;
216 }
217 
218 NS_IMETHODIMP
219 sbDownloadButtonPropertyInfo::HitTest(const nsAString& aCurrentValue,
220  const nsAString& aPart,
221  PRUint32 aBoxWidth,
222  PRUint32 aBoxHeight,
223  PRUint32 aMouseX,
224  PRUint32 aMouseY,
225  PRBool* _retval)
226 {
227  NS_ENSURE_ARG_POINTER(_retval);
228  *_retval = aPart.EqualsLiteral("text");
229  return NS_OK;
230 }
231 
232 /* boolean onClick (in sbIMediaItem aItem,
233  [optional] in nsISupports aEvent,
234  [optional] in nsISupports aContext); */
235 NS_IMETHODIMP
236 sbDownloadButtonPropertyInfo::OnClick(sbIMediaItem *aItem,
237  nsISupports *aEvent,
238  nsISupports *aContext,
239  PRBool *_retval NS_OUTPARAM)
240 {
241  NS_ENSURE_ARG_POINTER(_retval);
242  *_retval = PR_FALSE;
243  return NS_OK;
244 }
245 
246 NS_IMETHODIMP
247 sbDownloadButtonPropertyInfo::GetValueForClick(const nsAString& aCurrentValue,
248  PRUint32 aBoxWidth,
249  PRUint32 aBoxHeight,
250  PRUint32 aMouseX,
251  PRUint32 aMouseY,
252  nsAString& _retval)
253 {
254  return NS_ERROR_NOT_IMPLEMENTED;
255 }
256 
257 // sbIPropertyInfo
258 
259 NS_IMETHODIMP
260 sbDownloadButtonPropertyInfo::Format(const nsAString& aValue,
261  nsAString& _retval)
262 {
264 
265  switch(value.GetMode()) {
267  _retval = mLabel;
268  break;
270  _retval = mRetryLabel;
271  break;
272  default:
273  _retval.Truncate();
274  }
275 
276  return NS_OK;
277 }
278 
return NS_OK
onPageChanged aValue
Definition: FeedWriter.js:1395
The property information specific to clickable properties.
countRef value
Definition: FeedWriter.js:1423
NS_IMPL_ISUPPORTS_INHERITED2(sbDownloadButtonPropertyInfo, sbImmutablePropertyInfo, sbIClickablePropertyInfo, sbITreeViewPropertyInfo) sbDownloadButtonPropertyInfo
Interface that defines a single item of media in the system.
NS_IMETHOD Format(const nsAString &aValue, nsAString &_retval)