sbStatusPropertyInfo.cpp
Go to the documentation of this file.
1 /*
2  *=BEGIN SONGBIRD GPL
3  *
4  * This file is part of the Songbird web player.
5  *
6  * Copyright(c) 2005-2009 POTI, Inc.
7  * http://www.songbirdnest.com
8  *
9  * This file may be licensed under the terms of of the
10  * GNU General Public License Version 2 (the ``GPL'').
11  *
12  * Software distributed under the License is distributed
13  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14  * express or implied. See the GPL for the specific language
15  * governing rights and limitations.
16  *
17  * You should have received a copy of the GPL along with this
18  * program. If not, go to http://www.gnu.org/licenses/gpl.html
19  * or write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  *=END SONGBIRD GPL
23  */
24 
25 
26 #include "sbStatusPropertyInfo.h"
27 #include "sbStatusPropertyValue.h"
28 #include "sbStandardOperators.h"
29 
30 #include <sbIPropertyArray.h>
31 #include <sbIPropertyManager.h>
32 #include <nsIStringBundle.h>
33 #include <nsITreeView.h>
34 #include <nsServiceManagerUtils.h>
35 
36 
40 
41 /*
42  * The value of status properties is formatted as follows:
43  *
44  * <mode>|<current value>
45  *
46  * mode can be: 0 = none, 1 = ripping, 2 = complete, 3 = failed
47  * current value: 0 to 100
48  *
49  */
50 sbStatusPropertyInfo::sbStatusPropertyInfo(const nsAString& aPropertyID,
51  const nsAString& aDisplayName,
52  const nsAString& aLocalizationKey,
53  const nsAString& aLabel,
54  const nsAString& aCompletedLabel,
55  const nsAString& aFailedLabel,
56  const PRBool aRemoteReadable,
57  const PRBool aRemoteWritable,
58  const PRBool aUserViewable,
59  const PRBool aUserEditable)
60 {
61  // sbImmutablePropertyInfo initialization
62  mID = aPropertyID;
63  mDisplayName = aDisplayName;
64  mLocalizationKey = aLocalizationKey;
65  mLabel = aLabel;
66  mCompletedLabel = aCompletedLabel;
67  mFailedLabel = aFailedLabel;
68  mUserViewable = aUserViewable;
69  mUserEditable = aUserEditable;
70  mRemoteReadable = aRemoteReadable;
71  mRemoteWritable = aRemoteWritable;
72  mType.AssignLiteral("status");
73 }
74 
75 nsresult
77 {
78  nsresult rv;
79 
81  NS_ENSURE_SUCCESS(rv, rv);
82 
83  return NS_OK;
84 }
85 
86 // sbITreeViewPropertyInfo
87 
88 NS_IMETHODIMP
89 sbStatusPropertyInfo::GetImageSrc(const nsAString& aValue,
90  nsAString& retval)
91 {
92  retval.Truncate();
93  return NS_OK;
94 }
95 
96 NS_IMETHODIMP
97 sbStatusPropertyInfo::GetProgressMode(const nsAString& aValue,
98  PRInt32* retval)
99 {
100  NS_ENSURE_ARG_POINTER(retval);
101 
103 
104  switch(value.GetMode()) {
109  *retval = nsITreeView::PROGRESS_NONE;
110  break;
112  *retval = nsITreeView::PROGRESS_NORMAL;
113  break;
114  default:
115  NS_WARNING("Unexpected sbStatusPropertyValue mode");
116  *retval = nsITreeView::PROGRESS_UNDETERMINED;
117  break;
118  }
119 
120  return NS_OK;
121 }
122 
123 NS_IMETHODIMP
124 sbStatusPropertyInfo::GetCellValue(const nsAString& aValue,
125  nsAString& retval)
126 {
128  retval.Truncate();
129 
130  if (value.GetMode() == sbStatusPropertyValue::eRipping) {
131  retval.AppendInt(value.GetCurrent());
132  }
133 
134  return NS_OK;
135 }
136 
137 NS_IMETHODIMP
138 sbStatusPropertyInfo::GetRowProperties(const nsAString& aValue,
139  nsAString& retval)
140 {
141  retval.Truncate();
142  return NS_OK;
143 }
144 
145 NS_IMETHODIMP
146 sbStatusPropertyInfo::GetCellProperties(const nsAString& aValue,
147  nsAString& retval)
148 {
150 
151  switch(value.GetMode()) {
153  retval.AssignLiteral("progressCompleted ");
154  break;
156  retval.AssignLiteral("progressFailed ");
157  break;
158  default:
159  retval.Truncate();
160  }
161 
162  retval.AppendLiteral("status");
163 
164  return NS_OK;
165 }
166 
167 NS_IMETHODIMP
168 sbStatusPropertyInfo::GetColumnType(nsAString& retval)
169 {
170  retval.AssignLiteral("progressmeter");
171  return NS_OK;
172 }
173 
174 // sbIPropertyInfo
175 
176 NS_IMETHODIMP
177 sbStatusPropertyInfo::Format(const nsAString& aValue,
178  nsAString& retval)
179 {
181 
182  switch(value.GetMode()) {
184  retval = mLabel;
185  break;
187  retval = mCompletedLabel;
188  break;
190  retval = mFailedLabel;
191  break;
192  default:
193  retval.Truncate();
194  }
195 
196  return NS_OK;
197 }
198 
return NS_OK
onPageChanged aValue
Definition: FeedWriter.js:1395
NS_IMETHOD Format(const nsAString &aValue, nsAString &_retval)
countRef value
Definition: FeedWriter.js:1423
NS_IMPL_ISUPPORTS_INHERITED1(sbStatusPropertyInfo, sbImmutablePropertyInfo, sbITreeViewPropertyInfo) sbStatusPropertyInfo