sbSimpleButtonPropertyBuilder.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 
29 
30 #include <nsAutoPtr.h>
31 
32 #include <sbIPropertyArray.h>
33 #include <sbIPropertyManager.h>
34 #include <nsIStringBundle.h>
35 
39 
40 NS_IMETHODIMP
42 {
43  NS_ENSURE_ARG_POINTER(_retval);
44  NS_ENSURE_STATE(!mPropertyID.IsEmpty());
45 
46  nsString displayName;
47  nsresult rv = GetFinalDisplayName(displayName);
48  NS_ENSURE_SUCCESS(rv, rv);
49 
50  PRBool hasLabel = PR_FALSE;
51  nsString label;
52  if (!mLabelKey.IsEmpty()) {
53  rv = GetStringFromName(mBundle, mLabelKey, label);
54  NS_ENSURE_SUCCESS(rv, rv);
55  hasLabel = PR_TRUE;
56  }
57  else {
58  if (!mLabel.IsEmpty()) {
59  label = mLabel;
60  hasLabel = PR_TRUE;
61  }
62  }
63 
64  nsRefPtr<sbSimpleButtonPropertyInfo> pi =
65  new sbSimpleButtonPropertyInfo(mPropertyID,
66  displayName,
67  mDisplayNameKey,
68  hasLabel,
69  label,
70  mRemoteReadable,
71  mRemoteWritable,
72  mUserViewable,
73  mUserEditable);
74  NS_ENSURE_TRUE(pi, NS_ERROR_OUT_OF_MEMORY);
75 
76  rv = pi->Init();
77  NS_ENSURE_SUCCESS(rv, rv);
78 
79  NS_ADDREF(*_retval = pi);
80  return NS_OK;
81 }
82 
83 NS_IMETHODIMP
84 sbSimpleButtonPropertyBuilder::GetLabel(nsAString& aLabel)
85 {
86  aLabel = mLabel;
87  return NS_OK;
88 }
89 NS_IMETHODIMP
90 sbSimpleButtonPropertyBuilder::SetLabel(const nsAString& aLabel)
91 {
92  mLabel = aLabel;
93  return NS_OK;
94 }
95 
96 NS_IMETHODIMP
97 sbSimpleButtonPropertyBuilder::GetLabelKey(nsAString& aLabelKey)
98 {
99  aLabelKey = mLabelKey;
100  return NS_OK;
101 }
102 NS_IMETHODIMP
103 sbSimpleButtonPropertyBuilder::SetLabelKey(const nsAString& aLabelKey)
104 {
105  mLabelKey = aLabelKey;
106  return NS_OK;
107 }
108 
NS_IMPL_ISUPPORTS_INHERITED1(sbSimpleButtonPropertyBuilder, sbAbstractPropertyBuilder, sbISimpleButtonPropertyBuilder) NS_IMETHODIMP sbSimpleButtonPropertyBuilder
return NS_OK
this _contentSandbox label
Definition: FeedWriter.js:814
An interface used to describe a metadata property for use by the UI and other sbILibrary interfaces (...