Skip to content

Commit a9a2a90

Browse files
authored
Merge pull request #164 from bryanburgers/v1.0.0
Bump version to 1.0.0
2 parents d7ab7ab + 3e02a2d commit a9a2a90

File tree

3 files changed

+248
-3
lines changed

3 files changed

+248
-3
lines changed

MIGRATING.md

Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
# Migrating
2+
3+
Many core APIs changed betwen v0.2.21 and v1.0.0. This document describes how
4+
to upgrade your application or library to use the new APIs when upgrading to
5+
dbus 1.0.0.
6+
7+
8+
## Clients
9+
10+
Migrating node applications and libraries that use this module as a DBus client.
11+
12+
### Getting a bus
13+
14+
In version 1.0.0, you no longer need to instantiate an instance of DBus in
15+
order to get a Bus instance.
16+
17+
v0.2.21:
18+
19+
```
20+
// v0.2.21
21+
var DBus = require('dbus');
22+
var dbus = new DBus();
23+
var bus = dbus.getBus('session');
24+
```
25+
26+
v1.0.0:
27+
28+
```
29+
// v1.0.0
30+
var DBus = require('dbus');
31+
var bus = DBus.getBus('session');
32+
```
33+
34+
### Calling a method
35+
36+
In version 1.0.0, calling a method on a DBus service uses a common node
37+
callback pattern where the first parameter is an error and the second is the
38+
result.
39+
40+
v0.2.21:
41+
42+
```
43+
// v0.2.21
44+
interface.Add.timeout = 1000;
45+
interface.Add.error = function(err) {
46+
// handle error
47+
};
48+
interface.Add.finish = function(result) {
49+
assert(result === 3);
50+
};
51+
interface.Add(1, 2);
52+
```
53+
54+
v1.0.0:
55+
56+
```
57+
// v1.0.0
58+
interface.Add(1, 2, { timeout: 1000 }, function(err, result) {
59+
if (err) {
60+
// handle error
61+
}
62+
63+
assert(result === 3);
64+
});
65+
```
66+
67+
Timeout may be omitted if it is not needed.
68+
69+
```
70+
// v1.0.0
71+
interface.Add(1, 2, function(err, result) {
72+
if (err) {
73+
// handle error
74+
}
75+
76+
assert(result === 3);
77+
});
78+
```
79+
80+
81+
## Services
82+
83+
Migrating node applications and libraries that use this module to create DBus
84+
services.
85+
86+
### Creating a service
87+
88+
In version 1.0.0, you no longer need to instantiate an instance of DBus in
89+
order to get a Service instance.
90+
91+
v0.2.21:
92+
93+
```
94+
// v0.2.21
95+
var DBus = require('dbus');
96+
var dbus = new DBus();
97+
var service = dbus.registerService('session', 'test.dbus.TestService');
98+
```
99+
100+
v1.0.0:
101+
102+
```
103+
// v1.0.0
104+
var DBus = require('dbus');
105+
var service = DBus.registerService('session', 'test.dbus.TestService');
106+
```
107+
108+
### Responding to a method
109+
110+
In v1.0.0, methods use a more typical node callback pattern where an error is
111+
the first parameter and a result is the second parameter.
112+
113+
v0.2.21:
114+
115+
```
116+
// v0.2.21
117+
service.addMethod('MyMethod', { out: DBus.Define(Number) }, function(callback) {
118+
callback(3);
119+
});
120+
```
121+
122+
v1.0.0:
123+
124+
```
125+
// v1.0.0
126+
service.addMethod('MyMethod', { out: DBus.Define(Number) }, function(callback) {
127+
callback(null, 3); // return the result as the second parameter
128+
});
129+
```
130+
131+
### Throwing an error from a method
132+
133+
In v1.0.0, errors can include both the DBus name and a message. Previously,
134+
they could only include the DBus name.
135+
136+
v0.2.21:
137+
138+
```
139+
// v0.2.21
140+
service.addMethod('MyMethod', { out: DBus.Define(Number) }, function(callback) {
141+
callback(new Error('test.dbus.TestService.Error');
142+
});
143+
```
144+
145+
v1.0.0:
146+
147+
```
148+
// v1.0.0
149+
service.addMethod('MyMethod', { out: DBus.Define(Number) }, function(callback) {
150+
callback(new DBus.Error('test.dbus.TestService.Error', 'Human-readable error message'));
151+
});
152+
```
153+
154+
Using a standard error is still possible, and defaults to
155+
[DBUS_ERROR_FAILED][dbuserror].
156+
157+
```
158+
// v1.0.0
159+
service.addMethod('MyMethod', { out: DBus.Define(Number) }, function(callback) {
160+
// Error name defaults to the generic 'org.freedesktop.DBus.Error.Failed'
161+
callback(new Error('Human-readable error message'));
162+
});
163+
```
164+
165+
### Responding to a property
166+
167+
In v1.0.0, properties use a more typical node callback pattern where an error
168+
is the first parameter and a result is the second parameter.
169+
170+
v0.2.21:
171+
172+
```
173+
// v0.2.21
174+
service.addProperty('MyProperty', {
175+
type: DBus.Define(Number),
176+
getter: function(callback) {
177+
callback(3);
178+
}
179+
});
180+
```
181+
182+
v1.0.0:
183+
184+
```
185+
// v1.0.0
186+
service.addProperty('MyProperty', {
187+
type: DBus.Define(Number),
188+
getter: function(callback) {
189+
callback(null, 3); // Return the result as the second parameter.
190+
}
191+
});
192+
```
193+
194+
### Throwing an error from a property
195+
196+
In v1.0.0, errors can include both the DBus name and a message. Previously,
197+
they could only include the DBus name.
198+
199+
v0.2.21:
200+
201+
```
202+
// v0.2.21
203+
service.addProperty('MyProperty', {
204+
type: DBus.Define(Number),
205+
getter: function(callback) {
206+
callback(new Error('test.dbus.TestService.Error');
207+
}
208+
});
209+
```
210+
211+
v1.0.0:
212+
213+
```
214+
// v1.0.0
215+
service.addProperty('MyProperty', {
216+
type: DBus.Define(Number),
217+
getter: function(callback) {
218+
callback(new DBus.Error('test.dbus.TestService.Error', 'Human-readable error message'));
219+
}
220+
});
221+
```
222+
223+
Using a standard error is still possible, and defaults to
224+
[DBUS_ERROR_FAILED][dbuserror].
225+
226+
```
227+
// v1.0.0
228+
service.addProperty('MyProperty', {
229+
type: DBus.Define(Number),
230+
getter: function(callback) {
231+
// Error name defaults to the generic 'org.freedesktop.DBus.Error.Failed'
232+
callback(new Error('Human-readable error message'));
233+
}
234+
});
235+
```
236+
237+
[dbuserror]: https://dbus.freedesktop.org/doc/api/html/group__DBusProtocol.html#gabb62fd6340d0787fbd56ff8dd2f326c7

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ $ npm install dbus
1313
## How To Build
1414
To build, do: `node-gyp configure build` or `npm install`.
1515

16+
## Migrating to version 1.0
17+
18+
The API changed between version 0.2.21 and version 1.0.0. See
19+
[migrating][migrating] for information on how to migrate your application to
20+
the new API.
21+
1622
## Dependencies
1723

1824
### General
@@ -414,3 +420,4 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
414420
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
415421

416422
[spec]: https://dbus.freedesktop.org/doc/dbus-specification.html
423+
[migrating]: MIGRATING.md

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
{
22
"name": "dbus",
3-
"version": "0.2.22",
3+
"version": "1.0.0",
44
"description": "A D-Bus binding for Node",
55
"author": "Shouqun Liu <[email protected]>",
66
"contributors": [
7-
"Fred Chien <[email protected]>"
7+
"Fred Chien <[email protected]>",
8+
"Bryan Burgers <[email protected]>"
89
],
910
"license": "MIT",
1011
"repository": {
1112
"type": "git",
1213
"url": "git://github.com/Shouqun/node-dbus.git"
1314
},
1415
"engines": {
15-
"node": ">= 0.8.0"
16+
"node": ">= 0.12.0"
1617
},
1718
"main": "./lib/dbus",
1819
"scripts": {

0 commit comments

Comments
 (0)