sbLibHal.h
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 #ifndef __SB_LIB_HAL_H__
26 #define __SB_LIB_HAL_H__
27 
28 /* *****************************************************************************
29  *******************************************************************************
30  *
31  * HAL library services.
32  *
33  *******************************************************************************
34  ******************************************************************************/
35 
41 /* *****************************************************************************
42  *
43  * HAL library imported services.
44  *
45  ******************************************************************************/
46 
47 /* Mozilla imports. */
48 #include <nsVoidArray.h>
49 #include <nsTArray.h>
50 
51 /* HAL library API imports. */
52 #include <libhal.h>
53 
54 /* Logging services imports. */
55 #include <sbIPDLog.h>
56 
57 
58 /* *****************************************************************************
59  *
60  * HAL library classes.
61  *
62  ******************************************************************************/
63 
64 /*
65  * sbLibHalCtx class.
66  */
67 
69 {
70  /* *************************************************************************
71  *
72  * Public interface.
73  *
74  **************************************************************************/
75 
76  public:
77 
78  /*
79  * Public libhal context services.
80  */
81 
82  sbLibHalCtx();
83  virtual ~sbLibHalCtx();
84 
85  nsresult Initialize();
86 
87 
88  /*
89  * Public libhal API services.
90  */
91 
92  nsresult SetUserData(
93  void *aUserData);
94 
95  nsresult GetAllDevices(
96  nsCStringArray &aDeviceList);
97 
98  nsresult DevicePropertyExists(
99  const nsACString &aUDI,
100  const char *aKey,
101  PRBool *apExists);
102 
103  nsresult DeviceGetPropertyString(
104  const nsACString &aUDI,
105  const char *aKey,
106  nsCString &aProperty);
107 
108  nsresult DeviceGetPropertyInt(
109  const nsACString &aUDI,
110  const char *aKey,
111  PRUint32 *aProperty);
112 
113  nsresult DeviceGetPropertyBool(
114  const nsACString &aUDI,
115  const char *aKey,
116  PRBool *aProperty);
117 
119  const nsACString &aUDI,
120  const char *aKey,
121  nsTArray<nsCString> &aProperty);
122 
123  nsresult SetDeviceAdded(
124  LibHalDeviceAdded aCallback);
125 
126  nsresult SetDeviceRemoved(
127  LibHalDeviceRemoved aCallback);
128 
129  nsresult SetDevicePropertyModified(
130  LibHalDevicePropertyModified
131  aCallback);
132 
133  nsresult DevicePropertyWatchAll();
134 
135 
136  /*
137  * Public libhal interface services.
138  */
139 
140  nsresult DeviceHasInterface(
141  const nsACString &aUDI,
142  const char *aInterface,
143  PRBool *aHasInterface);
144 
145 
146  /*
147  * Public D-Bus message services.
148  */
149 
150  nsresult DeviceVolumeEject(
151  nsCString &aDeviceUDI);
152 
153  nsresult DeviceVolumeUnmount(
154  nsCString &aDeviceUDI);
155 
156 
157  /* *************************************************************************
158  *
159  * Private interface.
160  *
161  **************************************************************************/
162 
163  private:
164 
165  /*
166  * mpLibHalCtx HAL library API context.
167  * mpDBusConnection HAL library API context connection to D-Bus.
168  */
169 
170  LibHalContext *mpLibHalCtx;
171  DBusConnection *mpDBusConnection;
172 
173 
174  /*
175  * Private D-Bus message services.
176  */
177 
178  nsresult DeviceCallMethod(
179  nsCString &aDeviceUDI,
180  const char *aInterface,
181  const char *aMethod);
182 
183  nsresult DeviceGetMethodRetCode(
184  DBusMessage *apDBusReply,
185  int *apRetCode);
186 };
187 
188 
189 #endif /* __SB_LIB_HAL_H__ */
nsresult SetDevicePropertyModified(LibHalDevicePropertyModified aCallback)
Definition: sbLibHal.cpp:551
nsresult DeviceVolumeEject(nsCString &aDeviceUDI)
Definition: sbLibHal.cpp:679
nsresult GetAllDevices(nsCStringArray &aDeviceList)
Definition: sbLibHal.cpp:190
nsresult DeviceHasInterface(const nsACString &aUDI, const char *aInterface, PRBool *aHasInterface)
Definition: sbLibHal.cpp:623
nsresult DeviceGetPropertyInt(const nsACString &aUDI, const char *aKey, PRUint32 *aProperty)
Definition: sbLibHal.cpp:353
nsresult DevicePropertyWatchAll()
Definition: sbLibHal.cpp:575
nsresult DevicePropertyExists(const nsACString &aUDI, const char *aKey, PRBool *apExists)
Definition: sbLibHal.cpp:247
nsresult SetDeviceRemoved(LibHalDeviceRemoved aCallback)
Definition: sbLibHal.cpp:526
virtual ~sbLibHalCtx()
Definition: sbLibHal.cpp:80
Songbird iPod Device Logging Definitions.
nsresult DeviceVolumeUnmount(nsCString &aDeviceUDI)
Definition: sbLibHal.cpp:697
nsresult DeviceGetPropertyStringList(const nsACString &aUDI, const char *aKey, nsTArray< nsCString > &aProperty)
Definition: sbLibHal.cpp:445
nsresult SetDeviceAdded(LibHalDeviceAdded aCallback)
Definition: sbLibHal.cpp:501
nsresult DeviceGetPropertyBool(const nsACString &aUDI, const char *aKey, PRBool *aProperty)
Definition: sbLibHal.cpp:399
nsresult SetUserData(void *aUserData)
Definition: sbLibHal.cpp:168
nsresult Initialize()
Definition: sbLibHal.cpp:101
nsresult DeviceGetPropertyString(const nsACString &aUDI, const char *aKey, nsCString &aProperty)
Definition: sbLibHal.cpp:306