@@ -23,49 +23,68 @@ the new API.
23
23
24
24
### General
25
25
26
- ** Node-gyp**
27
- ` $ npm install -g node-gyp `
28
- [ https://www.npmjs.com/package/node-gyp ] ( https://www.npmjs.com/package/node-gyp )
26
+ * ** Node-gyp**
29
27
30
- ** libdbus **
31
- ` $ sudo apt-get install libdbus-1-dev `
32
- or equivalent for your system
28
+ ```bash
29
+ $ npm install -g node-gyp
30
+ ```
33
31
34
- ** glib2.0**
35
- ` $ sudo apt-get install libglib2.0-dev `
36
- or equivalent for your system
32
+ [https://www.npmjs.com/package/node-gyp](https://www.npmjs.com/package/node-gyp)
33
+
34
+ * ** libdbus**
35
+
36
+ ```bash
37
+ $ sudo apt-get install libdbus-1-dev
38
+ ```
39
+
40
+ or equivalent for your system
41
+
42
+ * ** glib2.0**
43
+
44
+ ```bash
45
+ $ sudo apt-get install libglib2.0-dev
46
+ ```
47
+
48
+ or equivalent for your system
37
49
38
50
### MacOS with MacPorts/HomeBrew
39
51
40
- ** Node-gyp**
41
- ` $ npm install -g node-gyp `
42
- [ https://www.npmjs.com/package/node-gyp ] ( https://www.npmjs.com/package/node-gyp )
52
+ * ** Node-gyp**
53
+
54
+ ```bash
55
+ $ npm install -g node-gyp
56
+ ```
57
+
58
+ [https://www.npmjs.com/package/node-gyp](https://www.npmjs.com/package/node-gyp)
43
59
44
- ** libdbus**
45
- MacPorts: ` $ sudo port install pkg-config dbus `
46
- HomeBrew: ` $ sudo brew install pkg-config dbus `
60
+ * * * libdbus**
61
+ MacPorts: `$ sudo port install pkg-config dbus`
62
+ HomeBrew: `$ sudo brew install pkg-config dbus`
47
63
48
- ** glib2.0**
49
- MacPorts: ` $ sudo port install glib2 `
50
- HomeBrew: ` $ sudo brew install glib `
64
+ * * * glib2.0**
65
+ MacPorts: `$ sudo port install glib2`
66
+ HomeBrew: `$ sudo brew install glib`
51
67
52
68
## Getting Started
69
+
53
70
Best way to get started is by looking at the examples. After the build:
54
71
55
72
1 . Navigate to ` path/to/dbus/examples ` folder
56
- 1 . Run ` node service.js & `
57
- 1 . Run ` node hello.js `
73
+ 2 . Run ` node service.js & `
74
+ 3 . Run ` node hello.js `
58
75
59
76
Work your way through other examples to explore supported functionality.
60
77
61
78
## Note on systems without X11
79
+
62
80
If no X server is running, the module fails when attempting to obtain a D-Bus
63
81
connection at ` DBus.getBus() ` . This can be remedied by setting two environment
64
82
variables manually (the actual bus address might be different):
65
83
66
- process.env.DISPLAY = ':0';
67
- process.env.DBUS_SESSION_BUS_ADDRESS = 'unix:path=/run/dbus/system_bus_socket';
68
-
84
+ ``` javascript
85
+ process .env .DISPLAY = ' :0' ;
86
+ process .env .DBUS_SESSION_BUS_ADDRESS = ' unix:path=/run/dbus/system_bus_socket' ;
87
+ ```
69
88
70
89
## API
71
90
@@ -83,7 +102,7 @@ bus or `"session"` to connect to the session bus.
83
102
84
103
Returns a ` Bus ` .
85
104
86
- ```
105
+ ``` javascript
87
106
var bus = DBus .getBus (' session' );
88
107
```
89
108
@@ -102,15 +121,15 @@ registered._
102
121
103
122
Returns a ` Service ` .
104
123
105
- ```
124
+ ``` javascript
106
125
var service = DBus .registerService (' session' , ' com.example.Library' );
107
126
```
108
127
109
128
#### * DEPRECATED* ` new DBus() `
110
129
111
130
Create a new DBus instance.
112
131
113
- ```
132
+ ``` javascript
114
133
var DBus = require (' dbus' )
115
134
var dbus = new DBus ()
116
135
```
@@ -140,7 +159,7 @@ Get an existing object's interface from a well-known service.
140
159
Once retrieved, ` callback ` will be called with either an error or with an
141
160
` Interface ` .
142
161
143
- ```
162
+ ``` javascript
144
163
bus .getInterface (' com.example.Library' , ' /com/example/Library/authors/DAdams' , ' com.example.Library.Author1' , function (err , interface ) {
145
164
if (err) {
146
165
...
@@ -169,7 +188,7 @@ Get the value of a property.
169
188
Once retrieved ` callback ` will be called with either an error or with the value
170
189
of the property.
171
190
172
- ```
191
+ ``` javascript
173
192
interface .getProperty (' Name' , function (err , name ) {
174
193
});
175
194
```
@@ -184,7 +203,7 @@ Set the value of a property.
184
203
185
204
Once set ` callback ` will be called with either an error or nothing.
186
205
187
- ```
206
+ ``` javascript
188
207
interface .setProperty (' Name' , ' Douglas Adams' , function (err ) {
189
208
});
190
209
```
@@ -199,7 +218,7 @@ Once retrieved `callback` will be called with either an error or with an object
199
218
where the keys are the names of the properties, and the values are the values
200
219
of those properties.
201
220
202
- ```
221
+ ``` javascript
203
222
interface .getProperties (function (err , properties ) {
204
223
console .log (properties .Name );
205
224
});
@@ -219,7 +238,7 @@ Call a method on the interface.
219
238
Once executed, ` callback ` will be called with either an error or with the
220
239
result of the method call.
221
240
222
- ```
241
+ ``` javascript
223
242
interface .AddBook (" The Hitchhiker's Guide to the Galaxy" , { timeout: 1000 }, function (err , result ) {
224
243
})
225
244
```
@@ -237,7 +256,7 @@ Create an object that is exposed over DBus.
237
256
238
257
Returns a ` ServiceObject ` .
239
258
240
- ```
259
+ ``` javascript
241
260
var object = service .createObject (' /com/example/Library/authors/DAdams' );
242
261
```
243
262
@@ -270,7 +289,7 @@ Create an interface on an object.
270
289
271
290
Returns a ` ServiceInterface ` .
272
291
273
- ```
292
+ ``` javascript
274
293
var interface = object .createInterface (' com.example.Library.Author1' );
275
294
```
276
295
@@ -289,7 +308,7 @@ An interface for an object that is exposed over DBus.
289
308
290
309
Add a method that can be called over DBus.
291
310
292
- ```
311
+ ``` javascript
293
312
interface .addMethod (' AddBook' , {
294
313
in: [DBus .Define (String ), DBus .Define (Number )],
295
314
out: [DBus .Define (Number )]
@@ -314,7 +333,7 @@ interface.addMethod('AddBook', {
314
333
315
334
Add a property that can be get, and/or optionally set, over DBus.
316
335
317
- ```
336
+ ``` javascript
318
337
interface .addProperty (' BooksWritten' , {
319
338
type: DBus .Define (Number ),
320
339
getter : function (callback ) {
@@ -348,7 +367,7 @@ interface.addProperty('Name', {
348
367
349
368
Create a DBus signal.
350
369
351
- ```
370
+ ` ` ` javascript
352
371
interface .addSignal (' bookCreated' , {
353
372
types: [DBus .Define (Object )]
354
373
});
@@ -361,7 +380,7 @@ interface.addSignal('bookCreated', {
361
380
362
381
Emit a signal
363
382
364
- ```
383
+ ` ` ` javascript
365
384
interface .emit (' bookCreated' , { name: " The Hitchhiker's Guide to the Galaxy" })
366
385
` ` `
367
386
@@ -383,7 +402,7 @@ A DBus-specific error
383
402
384
403
Create a new error. The name must be a valid error name.
385
404
386
- ```
405
+ ` ` ` javascript
387
406
throw new DBus.Error (' com.example.Library.Error.BookExistsError' , ' The book already exists' );
388
407
` ` `
389
408
0 commit comments