sbIPDProperties.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 :miv */
3 /*
4 //=BEGIN SONGBIRD GPL
5 //
6 // This file is part of the Songbird web player.
7 //
8 // Copyright(c) 2005-2009 POTI, Inc.
9 // http://www.songbirdnest.com
10 //
11 // This file may be licensed under the terms of of the
12 // GNU General Public License Version 2 (the GPL).
13 //
14 // Software distributed under the License is distributed
15 // on an AS IS basis, WITHOUT WARRANTY OF ANY KIND, either
16 // express or implied. See the GPL for the specific language
17 // governing rights and limitations.
18 //
19 // You should have received a copy of the GPL along with this
20 // program. If not, go to http://www.gnu.org/licenses/gpl.html
21 // or write to the Free Software Foundation, Inc.,
22 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 //
24 //=END SONGBIRD GPL
25 */
26 
27 #ifndef __SB_IPD_PROPERTIES_H__
28 #define __SB_IPD_PROPERTIES_H__
29 
30 //------------------------------------------------------------------------------
31 //------------------------------------------------------------------------------
32 //
33 // iPod device properties defs.
34 //
35 //------------------------------------------------------------------------------
36 //------------------------------------------------------------------------------
37 
43 //------------------------------------------------------------------------------
44 //
45 // iPod device properties imported services.
46 //
47 //------------------------------------------------------------------------------
48 
49 // Local imports.
50 #include "sbIPDUtils.h"
51 
52 // Songbird imports.
53 #include <sbIDeviceProperties.h>
54 
55 // Mozilla imports.
56 #include <nsAutoPtr.h>
57 #include <nsIWritablePropertyBag.h>
58 #include <nsIWritablePropertyBag2.h>
59 
60 
61 //------------------------------------------------------------------------------
62 //
63 // iPod device properties classes.
64 //
65 //------------------------------------------------------------------------------
66 
76 #define SBIPD_FORWARD_SAFE_NSIWRITABLEPROPERTYBAG2_SET(aObj, aMethod, aType) \
77 NS_IMETHOD aMethod(const nsAString& aName, aType aValue) \
78 { \
79  return !aObj ? NS_ERROR_NULL_POINTER : \
80  aObj->SetProperty(aName, sbIPDVariant(aValue).get()); \
81 }
82 
83 
95 #define SBIPD_FORWARD_SAFE_NSIWRITABLEPROPERTYBAG2_SET_VTYPE(aObj, \
96  aMethod, \
97  aType, \
98  aVType) \
99 NS_IMETHOD aMethod(const nsAString& aName, aType aValue) \
100 { \
101  return !aObj ? NS_ERROR_NULL_POINTER : \
102  aObj->SetProperty(aName, sbIPDVariant(aValue, aVType).get()); \
103 }
104 
105 
112 #define SBIPD_FORWARD_SAFE_NSIWRITABLEPROPERTYBAG2(aObj) \
113  SBIPD_FORWARD_SAFE_NSIWRITABLEPROPERTYBAG2_SET(aObj, \
114  SetPropertyAsInt32, \
115  PRInt32) \
116  SBIPD_FORWARD_SAFE_NSIWRITABLEPROPERTYBAG2_SET(aObj, \
117  SetPropertyAsUint32, \
118  PRUint32) \
119  SBIPD_FORWARD_SAFE_NSIWRITABLEPROPERTYBAG2_SET(aObj, \
120  SetPropertyAsInt64, \
121  PRInt64) \
122  SBIPD_FORWARD_SAFE_NSIWRITABLEPROPERTYBAG2_SET(aObj, \
123  SetPropertyAsUint64, \
124  PRUint64) \
125  SBIPD_FORWARD_SAFE_NSIWRITABLEPROPERTYBAG2_SET(aObj, \
126  SetPropertyAsDouble, \
127  double) \
128  SBIPD_FORWARD_SAFE_NSIWRITABLEPROPERTYBAG2_SET(aObj, \
129  SetPropertyAsAString, \
130  const nsAString&) \
131  SBIPD_FORWARD_SAFE_NSIWRITABLEPROPERTYBAG2_SET(aObj, \
132  SetPropertyAsACString, \
133  const nsACString&) \
134  SBIPD_FORWARD_SAFE_NSIWRITABLEPROPERTYBAG2_SET_VTYPE \
135  (aObj, \
136  SetPropertyAsAUTF8String, \
137  const nsACString&, \
138  nsIDataType::VTYPE_UTF8STRING) \
139  SBIPD_FORWARD_SAFE_NSIWRITABLEPROPERTYBAG2_SET_VTYPE \
140  (aObj, \
141  SetPropertyAsBool, \
142  PRBool, \
143  nsIDataType::VTYPE_BOOL) \
144  SBIPD_FORWARD_SAFE_NSIWRITABLEPROPERTYBAG2_SET(aObj, \
145  SetPropertyAsInterface, \
146  nsISupports*)
147 
148 
153 class sbIPDDevice;
154 
156  public nsIWritablePropertyBag,
157  public nsIWritablePropertyBag2
158 {
159  //----------------------------------------------------------------------------
160  //
161  // Public interface.
162  //
163  //----------------------------------------------------------------------------
164 
165 public :
166 
167  //
168  // Inherited interfaces.
169  //
170 
172  NS_DECL_SBIDEVICEPROPERTIES
173  NS_DECL_NSIWRITABLEPROPERTYBAG
174 
175 
176  //
177  // Forwarded interfaces.
178  //
179 
180  NS_FORWARD_SAFE_NSIPROPERTYBAG(mProperties)
181  NS_FORWARD_SAFE_NSIPROPERTYBAG2(mProperties2)
183 
184 
185  //
186  // iPod device properties services.
187  //
188 
189  sbIPDProperties(sbIPDDevice* aDevice);
190 
191  virtual ~sbIPDProperties();
192 
193  nsresult Initialize();
194 
195  void Finalize();
196 
197  nsresult SetPropertyInternal(const nsAString& aName,
198  nsIVariant* aValue);
199 
200 
201  //----------------------------------------------------------------------------
202  //
203  // Private interface.
204  //
205  //----------------------------------------------------------------------------
206 
207 private:
208 
209  //
210  // mDevice Device to which this property set belongs.
211  // Don't refcount to avoid a cycle.
212  // mProperties Storage for device properties.
213  // mProperties2 nsIWritablePropertyBag2 interface to device
214  // properties.
215  //
216 
217  sbIPDDevice* mDevice;
218  nsCOMPtr<nsIWritablePropertyBag>
219  mProperties;
220  nsCOMPtr<nsIWritablePropertyBag2>
221  mProperties2;
222 };
223 
224 
225 #endif // __SB_IPD_PROPERTIES_H__
226 
Songbird iPod Device Utility Definitions.
onPageChanged aValue
Definition: FeedWriter.js:1395
#define SBIPD_FORWARD_SAFE_NSIWRITABLEPROPERTYBAG2(aObj)
this _document this
Definition: FeedWriter.js:1085
_updateCookies aName
nsresult SetPropertyInternal(const nsAString &aName, nsIVariant *aValue)