Mercurial > projects > dbus-d
comparison dbus-d-javatests/dsrc/GenIntf.d @ 0:a5576806d36d
recreate repository without any libs for lightweight repository
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 20 Oct 2007 18:07:18 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a5576806d36d |
---|---|
1 /** | |
2 * Generated with TioLink | |
3 * TioLink was written by Frank Benoit <benoit@tionex.de> | |
4 * http://www.dsource.org/projects/tiolink | |
5 * | |
6 * File type: D programming language source code | |
7 */ | |
8 module GenIntf; | |
9 | |
10 public import org.freedesktop.dbus.Struct; | |
11 public import org.freedesktop.dbus.Variant; | |
12 | |
13 import org.freedesktop.dbus.DBus; | |
14 import org.freedesktop.dbus.c.Connection : DBusConnection; | |
15 import org.freedesktop.dbus.c.Message : DBusMessage; | |
16 import org.freedesktop.dbus.c.Shared : DBusHandlerResult; | |
17 | |
18 | |
19 // DBus interfaces | |
20 public interface DBusInterface { | |
21 // org | |
22 public interface org { | |
23 // org.freedesktop | |
24 public interface freedesktop { | |
25 // org.freedesktop.DBus | |
26 public interface DBus { | |
27 // org.freedesktop.DBus.Peer | |
28 public interface Peer { | |
29 public void Ping(); | |
30 public char[] GetMachineId(); | |
31 } | |
32 // org.freedesktop.DBus.Introspectable | |
33 public interface Introspectable { | |
34 public char[] Introspect(); | |
35 } | |
36 // org.freedesktop.DBus.Properties | |
37 public interface Properties { | |
38 public DBusVariant Get(in char[] intf_name,in char[] prop_name ); | |
39 public void Set(in char[] intf_name,in char[] prop_name,in DBusVariant prop ); | |
40 public DBusVariant[ char[] ] GetAll(in char[] intf_name ); | |
41 } | |
42 } | |
43 // org.freedesktop.SampleInterface | |
44 public interface SampleInterface { | |
45 public void Frobate(in int foo,out char[] bar,out char[][ uint ] baz ); | |
46 public DBusVariant Bazify(in Struct!( int, int, uint ) bar ); | |
47 public void Mogrify(in Struct!( int, int, DBusVariant[] ) bar ); | |
48 } | |
49 } | |
50 } | |
51 // filetree | |
52 public interface filetree { | |
53 // filetree.DataFileSystem | |
54 public interface DataFileSystem { | |
55 public DBusObject[] getRoots(); | |
56 } | |
57 // filetree.DataItem | |
58 public interface DataItem { | |
59 public DBusObject[] getChilds(); | |
60 public bool isFolder(); | |
61 public bool isDrive(); | |
62 public char[] getName(); | |
63 } | |
64 } | |
65 } | |
66 | |
67 | |
68 // DBusObject | |
69 public class DBusObject : DBusObjectImpl, DBusInterface.org.freedesktop.DBus.Introspectable { | |
70 this(){ | |
71 super(); | |
72 } | |
73 public char[] Introspect(){ | |
74 return super.Introspect(); | |
75 } | |
76 } | |
77 | |
78 | |
79 private void init_introspectionData(){ | |
80 registerIntrospectionData( | |
81 DBusInterface.org.freedesktop.DBus.Peer.classinfo, | |
82 `<interface name="org.freedesktop.DBus.Peer">\n` | |
83 ` <method name="Ping">\n` | |
84 ` </method>\n` | |
85 ` <method name="GetMachineId">\n` | |
86 ` <annotation name="org.dsource.tiolink.Returns" value="machine_uuid" />\n` | |
87 ` <arg name="machine_uuid" type="s" direction="out" />\n` | |
88 ` </method>\n` | |
89 `</interface>\n`); | |
90 registerIntrospectionData( | |
91 DBusInterface.org.freedesktop.DBus.Introspectable.classinfo, | |
92 `<interface name="org.freedesktop.DBus.Introspectable">\n` | |
93 ` <method name="Introspect">\n` | |
94 ` <annotation name="org.dsource.tiolink.Returns" value="xml_data" />\n` | |
95 ` <arg name="xml_data" type="s" direction="out" />\n` | |
96 ` </method>\n` | |
97 `</interface>\n`); | |
98 registerIntrospectionData( | |
99 DBusInterface.org.freedesktop.DBus.Properties.classinfo, | |
100 `<interface name="org.freedesktop.DBus.Properties">\n` | |
101 ` <method name="Get">\n` | |
102 ` <annotation name="org.dsource.tiolink.Returns" value="prop" />\n` | |
103 ` <arg name="intf_name" type="s" direction="in" />\n` | |
104 ` <arg name="prop_name" type="s" direction="in" />\n` | |
105 ` <arg name="prop" type="v" direction="out" />\n` | |
106 ` </method>\n` | |
107 ` <method name="Set">\n` | |
108 ` <arg name="intf_name" type="s" direction="in" />\n` | |
109 ` <arg name="prop_name" type="s" direction="in" />\n` | |
110 ` <arg name="prop" type="v" direction="in" />\n` | |
111 ` </method>\n` | |
112 ` <method name="GetAll">\n` | |
113 ` <annotation name="org.dsource.tiolink.Returns" value="allprops" />\n` | |
114 ` <arg name="intf_name" type="s" direction="in" />\n` | |
115 ` <arg name="allprops" type="a{sv}" direction="out" />\n` | |
116 ` </method>\n` | |
117 `</interface>\n`); | |
118 registerIntrospectionData( | |
119 DBusInterface.org.freedesktop.SampleInterface.classinfo, | |
120 `<interface name="org.freedesktop.SampleInterface">\n` | |
121 ` <method name="Frobate">\n` | |
122 ` <annotation name="org.freedesktop.DBus.Deprecated" value="true" />\n` | |
123 ` <arg name="foo" type="i" direction="in" />\n` | |
124 ` <arg name="bar" type="s" direction="out" />\n` | |
125 ` <arg name="baz" type="a{us}" direction="out" />\n` | |
126 ` </method>\n` | |
127 ` <method name="Bazify">\n` | |
128 ` <annotation name="org.dsource.tiolink.Returns" value="bar" />\n` | |
129 ` <arg name="bar" type="(iiu)" direction="in" />\n` | |
130 ` <arg name="bar" type="v" direction="out" />\n` | |
131 ` </method>\n` | |
132 ` <method name="Mogrify">\n` | |
133 ` <arg name="bar" type="(iiav)" direction="in" />\n` | |
134 ` </method>\n` | |
135 `</interface>\n`); | |
136 registerIntrospectionData( | |
137 DBusInterface.filetree.DataFileSystem.classinfo, | |
138 `<interface name="filetree.DataFileSystem">\n` | |
139 ` <method name="getRoots">\n` | |
140 ` <annotation name="org.dsource.tiolink.Returns" value="roots" />\n` | |
141 ` <arg name="roots" type="ao" direction="out" />\n` | |
142 ` </method>\n` | |
143 `</interface>\n`); | |
144 registerIntrospectionData( | |
145 DBusInterface.filetree.DataItem.classinfo, | |
146 `<interface name="filetree.DataItem">\n` | |
147 ` <method name="getChilds">\n` | |
148 ` <annotation name="org.dsource.tiolink.Returns" value="childs" />\n` | |
149 ` <arg name="childs" type="ao" direction="out" />\n` | |
150 ` </method>\n` | |
151 ` <method name="isFolder">\n` | |
152 ` <annotation name="org.dsource.tiolink.Returns" value="res" />\n` | |
153 ` <arg name="res" type="b" direction="out" />\n` | |
154 ` </method>\n` | |
155 ` <method name="isDrive">\n` | |
156 ` <annotation name="org.dsource.tiolink.Returns" value="res" />\n` | |
157 ` <arg name="res" type="b" direction="out" />\n` | |
158 ` </method>\n` | |
159 ` <method name="getName">\n` | |
160 ` <annotation name="org.dsource.tiolink.Returns" value="res" />\n` | |
161 ` <arg name="res" type="s" direction="out" />\n` | |
162 ` </method>\n` | |
163 `</interface>\n`); | |
164 } | |
165 private DBusHandlerResult intfHandler__org_freedesktop_DBus_Peer( DBusConnection* conn, DBusMessage* message, void* user_data ){ | |
166 DBusInterface.org.freedesktop.DBus.Peer o = cast(DBusInterface.org.freedesktop.DBus.Peer)cast(Object)user_data; | |
167 if( o is null || !checkIntf( "org.freedesktop.DBus.Peer", message) ) | |
168 return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | |
169 | |
170 try{ | |
171 char[METHOD_SIG_MAXLENGTH] buf; | |
172 switch( methodSignature( message, buf ) ){ | |
173 case "Ping|": | |
174 { | |
175 o.Ping(); | |
176 sendReply( conn, message ); | |
177 } | |
178 break; | |
179 case "GetMachineId|": | |
180 { | |
181 Struct!( char[] ) po; | |
182 po.t[0] = o.GetMachineId(); | |
183 sendReplyData!( char[] )( conn, message, po ); | |
184 } | |
185 break; | |
186 default: | |
187 return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | |
188 } | |
189 } | |
190 catch( Exception e ){ | |
191 sendException( conn, message, e ); | |
192 } | |
193 return DBusHandlerResult.DBUS_HANDLER_RESULT_HANDLED; | |
194 } | |
195 | |
196 private DBusHandlerResult intfHandler__org_freedesktop_DBus_Introspectable( DBusConnection* conn, DBusMessage* message, void* user_data ){ | |
197 DBusInterface.org.freedesktop.DBus.Introspectable o = cast(DBusInterface.org.freedesktop.DBus.Introspectable)cast(Object)user_data; | |
198 if( o is null || !checkIntf( "org.freedesktop.DBus.Introspectable", message) ) | |
199 return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | |
200 | |
201 try{ | |
202 char[METHOD_SIG_MAXLENGTH] buf; | |
203 switch( methodSignature( message, buf ) ){ | |
204 case "Introspect|": | |
205 { | |
206 Struct!( char[] ) po; | |
207 po.t[0] = o.Introspect(); | |
208 sendReplyData!( char[] )( conn, message, po ); | |
209 } | |
210 break; | |
211 default: | |
212 return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | |
213 } | |
214 } | |
215 catch( Exception e ){ | |
216 sendException( conn, message, e ); | |
217 } | |
218 return DBusHandlerResult.DBUS_HANDLER_RESULT_HANDLED; | |
219 } | |
220 | |
221 private DBusHandlerResult intfHandler__org_freedesktop_DBus_Properties( DBusConnection* conn, DBusMessage* message, void* user_data ){ | |
222 DBusInterface.org.freedesktop.DBus.Properties o = cast(DBusInterface.org.freedesktop.DBus.Properties)cast(Object)user_data; | |
223 if( o is null || !checkIntf( "org.freedesktop.DBus.Properties", message) ) | |
224 return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | |
225 | |
226 try{ | |
227 char[METHOD_SIG_MAXLENGTH] buf; | |
228 switch( methodSignature( message, buf ) ){ | |
229 case "Get|ss": | |
230 { | |
231 Struct!( char[], char[] ) pi = getCallValues!( char[], char[] )( message ); | |
232 Struct!( DBusVariant ) po; | |
233 po.t[0] = o.Get( pi.t[0], pi.t[1] ); | |
234 sendReplyData!( DBusVariant )( conn, message, po ); | |
235 } | |
236 break; | |
237 case "Set|ssv": | |
238 { | |
239 Struct!( char[], char[], DBusVariant ) pi = getCallValues!( char[], char[], DBusVariant )( message ); | |
240 o.Set( pi.t[0], pi.t[1], pi.t[2] ); | |
241 sendReply( conn, message ); | |
242 } | |
243 break; | |
244 case "GetAll|s": | |
245 { | |
246 Struct!( char[] ) pi = getCallValues!( char[] )( message ); | |
247 Struct!( DBusVariant[ char[] ] ) po; | |
248 po.t[0] = o.GetAll( pi.t[0] ); | |
249 sendReplyData!( DBusVariant[ char[] ] )( conn, message, po ); | |
250 } | |
251 break; | |
252 default: | |
253 return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | |
254 } | |
255 } | |
256 catch( Exception e ){ | |
257 sendException( conn, message, e ); | |
258 } | |
259 return DBusHandlerResult.DBUS_HANDLER_RESULT_HANDLED; | |
260 } | |
261 | |
262 private DBusHandlerResult intfHandler__org_freedesktop_SampleInterface( DBusConnection* conn, DBusMessage* message, void* user_data ){ | |
263 DBusInterface.org.freedesktop.SampleInterface o = cast(DBusInterface.org.freedesktop.SampleInterface)cast(Object)user_data; | |
264 if( o is null || !checkIntf( "org.freedesktop.SampleInterface", message) ) | |
265 return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | |
266 | |
267 try{ | |
268 char[METHOD_SIG_MAXLENGTH] buf; | |
269 switch( methodSignature( message, buf ) ){ | |
270 case "Frobate|i": | |
271 { | |
272 Struct!( int ) pi = getCallValues!( int )( message ); | |
273 Struct!( char[], char[][ uint ] ) po; | |
274 o.Frobate( pi.t[0], po.t[0], po.t[1] ); | |
275 sendReplyData!( char[], char[][ uint ] )( conn, message, po ); | |
276 } | |
277 break; | |
278 case "Bazify|(iiu)": | |
279 { | |
280 Struct!( Struct!( int, int, uint ) ) pi = getCallValues!( Struct!( int, int, uint ) )( message ); | |
281 Struct!( DBusVariant ) po; | |
282 po.t[0] = o.Bazify( pi.t[0] ); | |
283 sendReplyData!( DBusVariant )( conn, message, po ); | |
284 } | |
285 break; | |
286 case "Mogrify|(iiav)": | |
287 { | |
288 Struct!( Struct!( int, int, DBusVariant[] ) ) pi = getCallValues!( Struct!( int, int, DBusVariant[] ) )( message ); | |
289 o.Mogrify( pi.t[0] ); | |
290 sendReply( conn, message ); | |
291 } | |
292 break; | |
293 default: | |
294 return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | |
295 } | |
296 } | |
297 catch( Exception e ){ | |
298 sendException( conn, message, e ); | |
299 } | |
300 return DBusHandlerResult.DBUS_HANDLER_RESULT_HANDLED; | |
301 } | |
302 | |
303 private DBusHandlerResult intfHandler__filetree_DataFileSystem( DBusConnection* conn, DBusMessage* message, void* user_data ){ | |
304 DBusInterface.filetree.DataFileSystem o = cast(DBusInterface.filetree.DataFileSystem)cast(Object)user_data; | |
305 if( o is null || !checkIntf( "filetree.DataFileSystem", message) ) | |
306 return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | |
307 | |
308 try{ | |
309 char[METHOD_SIG_MAXLENGTH] buf; | |
310 switch( methodSignature( message, buf ) ){ | |
311 case "getRoots|": | |
312 { | |
313 Struct!( DBusObject[] ) po; | |
314 po.t[0] = o.getRoots(); | |
315 sendReplyData!( DBusObject[] )( conn, message, po ); | |
316 } | |
317 break; | |
318 default: | |
319 return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | |
320 } | |
321 } | |
322 catch( Exception e ){ | |
323 sendException( conn, message, e ); | |
324 } | |
325 return DBusHandlerResult.DBUS_HANDLER_RESULT_HANDLED; | |
326 } | |
327 | |
328 private DBusHandlerResult intfHandler__filetree_DataItem( DBusConnection* conn, DBusMessage* message, void* user_data ){ | |
329 DBusInterface.filetree.DataItem o = cast(DBusInterface.filetree.DataItem)cast(Object)user_data; | |
330 if( o is null || !checkIntf( "filetree.DataItem", message) ) | |
331 return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | |
332 | |
333 try{ | |
334 char[METHOD_SIG_MAXLENGTH] buf; | |
335 switch( methodSignature( message, buf ) ){ | |
336 case "getChilds|": | |
337 { | |
338 Struct!( DBusObject[] ) po; | |
339 po.t[0] = o.getChilds(); | |
340 sendReplyData!( DBusObject[] )( conn, message, po ); | |
341 } | |
342 break; | |
343 case "isFolder|": | |
344 { | |
345 Struct!( bool ) po; | |
346 po.t[0] = o.isFolder(); | |
347 sendReplyData!( bool )( conn, message, po ); | |
348 } | |
349 break; | |
350 case "isDrive|": | |
351 { | |
352 Struct!( bool ) po; | |
353 po.t[0] = o.isDrive(); | |
354 sendReplyData!( bool )( conn, message, po ); | |
355 } | |
356 break; | |
357 case "getName|": | |
358 { | |
359 Struct!( char[] ) po; | |
360 po.t[0] = o.getName(); | |
361 sendReplyData!( char[] )( conn, message, po ); | |
362 } | |
363 break; | |
364 default: | |
365 return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | |
366 } | |
367 } | |
368 catch( Exception e ){ | |
369 sendException( conn, message, e ); | |
370 } | |
371 return DBusHandlerResult.DBUS_HANDLER_RESULT_HANDLED; | |
372 } | |
373 | |
374 private void init_handlers(){ | |
375 registerHandler( | |
376 DBusInterface.org.freedesktop.DBus.Peer.classinfo, | |
377 & intfHandler__org_freedesktop_DBus_Peer ); | |
378 registerHandler( | |
379 DBusInterface.org.freedesktop.DBus.Introspectable.classinfo, | |
380 & intfHandler__org_freedesktop_DBus_Introspectable ); | |
381 registerHandler( | |
382 DBusInterface.org.freedesktop.DBus.Properties.classinfo, | |
383 & intfHandler__org_freedesktop_DBus_Properties ); | |
384 registerHandler( | |
385 DBusInterface.org.freedesktop.SampleInterface.classinfo, | |
386 & intfHandler__org_freedesktop_SampleInterface ); | |
387 registerHandler( | |
388 DBusInterface.filetree.DataFileSystem.classinfo, | |
389 & intfHandler__filetree_DataFileSystem ); | |
390 registerHandler( | |
391 DBusInterface.filetree.DataItem.classinfo, | |
392 & intfHandler__filetree_DataItem ); | |
393 } | |
394 | |
395 static this(){ | |
396 init_introspectionData(); | |
397 init_handlers(); | |
398 } | |
399 |