~ubuntu-branches/ubuntu/raring/workrave/raring-proposed

« back to all changes in this revision

Viewing changes to common/bin/DBus-client-template.cc

  • Committer: Package Import Robot
  • Author(s): Francois Marier, Francois Marier, Jordi Mallach
  • Date: 2012-05-28 11:29:40 UTC
  • mfrom: (1.2.9)
  • Revision ID: package-import@ubuntu.com-20120528112940-bbbsjkk30fom9s8x
Tags: 1.9.909+abc941eb70-1
[ Francois Marier ]
* New upstream snapshot
  - Drop leak-fix patch (applied upstream)
  - Document how the tarball is built in README.source
* Build GNOME applets and use gsettings
* Massive update of Build-Depends as per configure.ac

* Update README.source with snapshot instructions
* Switch to machine-readable copyright file
* Update alioth git repo links
* Bump debhelper version to 9
* Bump Standards-Version to 3.9.3

[ Jordi Mallach ]
* Avoid references to GNU/Linux in manpage.
* Drop build dependency on libgnet-dev, it's obsolete and unneeded.
* Add myself to Uploaders.
* Rewrite d/rules into dh style.
  - Move all install tweaks to .install files.
  - Install manpages using dh_installman.
* As a side effect, the package installs arch-dependant data in the
  arch triplet directory; add the required Pre-Depends for m-a-support.
* Bring back GNOME Panel applet (for GNOME 3 fallback mode) and ship the
  new GNOME Shell extension (closes: #642514, #666100).
* Add private_dirs.patch: move libworkrave-private and GObject
  Introspection files to a private dir, so they are really out of the
  way, but disable it for now as it breaks the Shell extension.
* Move typelib out of the triplet dir as gobject-introspection is not
  M-A ready yet.
* Enable dh_autoreconf for the above patches.
* Add lintian overrides.
* Add necessary Breaks/Replaces as the xpm icon has moved to workrave-data.
* Prefix all debhelper files with package name.
* Suggest gnome-shell and gnome-panel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// DBus-client-template.hh --- DBUS template
2
 
//
3
 
// Copyright (C) 2007, 2008 Rob Caelers <robc@krandor.nl>
4
 
// All rights reserved.
5
 
//
6
 
// This program is free software: you can redistribute it and/or modify
7
 
// it under the terms of the GNU General Public License as published by
8
 
// the Free Software Foundation, either version 3 of the License, or
9
 
// (at your option) any later version.
10
 
//
11
 
// This program is distributed in the hope that it will be useful,
12
 
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
// GNU General Public License for more details.
15
 
//
16
 
// You should have received a copy of the GNU General Public License
17
 
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 
//
19
 
 
20
 
\#ifdef HAVE_CONFIG_H
21
 
\#include "config.h"
22
 
\#endif
23
 
 
24
 
\#include <string>
25
 
\#include <list>
26
 
\#include <map>
27
 
\#include <deque>
28
 
 
29
 
\#include "DBusBinding.hh"
30
 
\#include "DBusException.hh"
31
 
\#include "${model.include_filename}"
32
 
 
33
 
using namespace std;
34
 
using namespace workrave;
35
 
 
36
 
#for interface in $model.interfaces
37
 
 
38
 
#if interface.condition != ''
39
 
\#if $interface.condition
40
 
#end if
41
 
 
42
 
#for imp in interface.imports
43
 
#for ns in imp.namespaces
44
 
using namespace $ns;
45
 
#end for
46
 
#end for
47
 
 
48
 
#for imp in interface.imports
49
 
#for include in imp.includes
50
 
\#include "${include}"
51
 
#end for
52
 
#end for
53
 
 
54
 
class ${interface.qname}_Impl : public ${interface.qname}, public DBusBaseTypes
55
 
{
56
 
public:
57
 
  ${interface.qname}_Impl(DBus *dbus, const string &service, const string &path);
58
 
  
59
 
  #for $method in interface.methods
60
 
  #slurp
61
 
  $interface.type2csymbol(method.return_type()) ${method.qname}(#slurp
62
 
  #set comma = ''
63
 
  #for p in method.params
64
 
  #if p.direction != 'out' or (not 'return' in p.hint)
65
 
  #if 'const' in p.hint
66
 
  const #slurp
67
 
  #end if
68
 
  $comma $interface.type2csymbol(p.type) #slurp
69
 
  #set comma = ','
70
 
  #end if
71
 
  #if p.direction == 'out'
72
 
    #if 'return' in p.hint
73
 
    /**/ #slurp
74
 
    #slurp                                                             
75
 
    #else if 'ptr' in p.hint
76
 
     *$p.name#slurp
77
 
    #else
78
 
     &$p.name#slurp
79
 
    #end if 
80
 
  #else if p.direction == 'in'
81
 
    #if 'ref' in p.hint
82
 
    &$p.name#slurp
83
 
    #else if 'ptr' in p.hint
84
 
    *$p.name#slurp
85
 
    #else
86
 
    $p.name#slurp
87
 
    #end if 
88
 
  #end if
89
 
  #end for
90
 
  );
91
 
  #slurp
92
 
  void ${method.qname}_async(#slurp
93
 
  #set comma = ''
94
 
  #for p in method.params
95
 
  #if p.direction == 'in'
96
 
    #if 'const' in p.hint
97
 
      const #slurp
98
 
    #end if
99
 
    $comma $interface.type2csymbol(p.type) #slurp
100
 
    #if 'ref' in p.hint
101
 
    &$p.name#slurp
102
 
    #else if 'ptr' in p.hint
103
 
    *$p.name#slurp
104
 
    #else
105
 
    $p.name#slurp
106
 
    #end if 
107
 
    #set comma = ','
108
 
  #end if
109
 
  #end for
110
 
    $comma ${method.name}_slot slot #slurp
111
 
  );
112
 
  #slurp
113
 
 
114
 
 
115
 
  #end for
116
 
  
117
 
private:
118
 
  #for $method in interface.methods
119
 
  typedef sigc::signal<void, DBusError * #slurp
120
 
  #set comma = ','
121
 
  #for p in method.params
122
 
  #if p.direction == 'out'
123
 
    #if 'const' in p.hint
124
 
      const #slurp
125
 
    #end if
126
 
    $comma $interface.type2csymbol(p.type) #slurp
127
 
    #if 'ref' in p.hint
128
 
    &#slurp
129
 
    #else if 'ptr' in p.hint
130
 
    *#slurp
131
 
    #end if 
132
 
    #set comma = ','
133
 
  #end if
134
 
  #end for
135
 
  > ${method.qname}_signal;
136
 
  #slurp
137
 
  struct ${method.qname}_async_closure
138
 
  {
139
 
     class ${interface.qname}_Impl *impl;
140
 
     ${method.qname}_signal signal;
141
 
  };
142
 
  static void ${method.qname}_async_closure_free(void *mem)
143
 
  {
144
 
    delete (${method.qname}_async_closure *)mem;
145
 
  }
146
 
  
147
 
  static void ${method.qname}_fcn_static(DBusPendingCall *pending, void *user_data);
148
 
  void ${method.qname}_fcn(DBusPendingCall *pending, void *user_data);
149
 
 
150
 
  #end for
151
 
  
152
 
  #for enum in $interface.enums
153
 
  void get_${enum.qname}(DBusMessageIter *reader, ${enum.csymbol} *result);
154
 
  void put_${enum.qname}(DBusMessageIter *writer, const ${enum.csymbol} *result);
155
 
  #end for
156
 
 
157
 
  #for struct in $interface.structs
158
 
  void get_${struct.qname}(DBusMessageIter *reader, ${struct.csymbol} *result);
159
 
  void put_${struct.qname}(DBusMessageIter *writer, const ${struct.csymbol} *result);
160
 
  #end for
161
 
 
162
 
  #for seq in $interface.sequences
163
 
  void get_${seq.qname}(DBusMessageIter *reader, ${seq.csymbol} *result);
164
 
  void put_${seq.qname}(DBusMessageIter *writer, const ${seq.csymbol} *result);
165
 
  #end for
166
 
 
167
 
  #for dict in $interface.dictionaries
168
 
  void get_${dict.qname}(DBusMessageIter *reader, ${dict.csymbol} *result);
169
 
  void put_${dict.qname}(DBusMessageIter *writer, const ${dict.csymbol} *result);
170
 
  #end for
171
 
 
172
 
  DBus *dbus;
173
 
  string service;
174
 
  string path;
175
 
};
176
 
 
177
 
 
178
 
${interface.qname}_Impl::${interface.qname}_Impl(DBus *dbus, const string &service, const string &path)
179
 
  : dbus(dbus), service(service), path(path)
180
 
{
181
 
}
182
 
 
183
 
${interface.qname} *${interface.qname}::instance(DBus *dbus, const string &service, const string &path)
184
 
{
185
 
  return new ${interface.qname}_Impl(dbus, service, path);
186
 
}
187
 
 
188
 
 
189
 
#for enum in $interface.enums
190
 
 
191
 
void
192
 
${interface.qname}::get_${enum.qname}(DBusMessageIter *reader, ${enum.csymbol} *result)
193
 
{
194
 
  std::string value;
195
 
        int argtype = dbus_message_iter_get_arg_type(reader);
196
 
 
197
 
  if (argtype != DBUS_TYPE_STRING)
198
 
                throw DBusTypeException("Type mismatch. Excepted string");
199
 
 
200
 
  get_string(reader, &value);
201
 
  
202
 
  #set ifs = 'if'
203
 
  #for e in enum.values
204
 
  $ifs ("$e.name" == value)
205
 
    {
206
 
      *result = $e.csymbol;
207
 
    }
208
 
  #set $ifs = 'else if'
209
 
  #end for
210
 
  else
211
 
    {
212
 
      throw DBusTypeException("Illegal enum value");
213
 
    }
214
 
}
215
 
 
216
 
void
217
 
${interface.qname}::put_${enum.qname}(DBusMessageIter *writer, const ${enum.csymbol} *result)
218
 
{
219
 
  string value;
220
 
  switch (*result)
221
 
    {
222
 
    #for e in enum.values
223
 
    case $e.csymbol:
224
 
      value = "$e.name";
225
 
      break;
226
 
    #end for
227
 
    default:
228
 
      throw DBusTypeException("Illegal enum value");
229
 
    }
230
 
                
231
 
  put_string(writer, &value);
232
 
}
233
 
 
234
 
#end for
235
 
 
236
 
#for struct in $interface.structs
237
 
 
238
 
void
239
 
${interface.qname}::get_${struct.qname}(DBusMessageIter *reader, ${struct.csymbol} *result)
240
 
{
241
 
  DBusMessageIter it;
242
 
  dbus_message_iter_recurse(reader, &it);
243
 
 
244
 
  #for p in struct.fields
245
 
  get_${p.type}(&it, ($interface.type2csymbol(p.type) *) &(result->${p.name}));
246
 
  #end for
247
 
 
248
 
  dbus_message_iter_next(reader);
249
 
}
250
 
 
251
 
void
252
 
${interface.qname}::put_${struct.qname}(DBusMessageIter *writer, const ${struct.csymbol} *result)
253
 
{
254
 
  DBusMessageIter it;
255
 
  dbus_bool_t ok;
256
 
  
257
 
  ok = dbus_message_iter_open_container(writer, DBUS_TYPE_STRUCT, NULL, &it);
258
 
  if (!ok)
259
 
    {
260
 
      throw DBusSystemException("Internal error");
261
 
    }
262
 
 
263
 
  #for p in struct.fields
264
 
  put_${p.type}(&it, ($interface.type2csymbol(p.type) *) &(result->${p.name}));
265
 
  #end for
266
 
 
267
 
  ok = dbus_message_iter_close_container(writer, &it);
268
 
  if (!ok)
269
 
    {
270
 
      throw DBusSystemException("Internal error");
271
 
    }
272
 
}
273
 
 
274
 
#end for
275
 
 
276
 
#for seq in $interface.sequences
277
 
 
278
 
void
279
 
${interface.qname}::get_${seq.qname}(DBusMessageIter *reader, ${seq.csymbol} *result)
280
 
{
281
 
  DBusMessageIter it;
282
 
 
283
 
  dbus_message_iter_recurse(reader, &it);
284
 
  while (dbus_message_iter_has_next(&it))
285
 
  {
286
 
    $interface.type2csymbol(seq.data_type) tmp;
287
 
    get_${seq.data_type}(&it, &tmp);
288
 
    result->push_back(tmp);
289
 
  }
290
 
 
291
 
  dbus_message_iter_next(reader);
292
 
}
293
 
 
294
 
void
295
 
${interface.qname}::put_${seq.qname}(DBusMessageIter *writer, const ${seq.csymbol} *result)
296
 
{
297
 
  DBusMessageIter arr;
298
 
  ${seq.csymbol}::const_iterator it;
299
 
  dbus_bool_t ok;
300
 
  
301
 
  ok = dbus_message_iter_open_container(writer, DBUS_TYPE_ARRAY, "$interface.type2sig(seq.data_type)", &arr);
302
 
  if (!ok)
303
 
    {
304
 
      throw DBusSystemException("Internal error");
305
 
    }
306
 
 
307
 
  for(it = result->begin(); it != result->end(); it++)
308
 
  {
309
 
    put_${seq.data_type}(&arr, &(*it));
310
 
  }
311
 
  
312
 
  ok = dbus_message_iter_close_container(writer, &arr);
313
 
  if (!ok)
314
 
    {
315
 
      throw DBusSystemException("Internal error");
316
 
    }
317
 
}
318
 
#end for
319
 
 
320
 
 
321
 
#for dict in $interface.dictionaries
322
 
 
323
 
void
324
 
${interface.qname}::get_${dict.qname}(DBusMessageIter *reader, ${dict.csymbol} *result)
325
 
{
326
 
  DBusMessageIter arr_it;
327
 
  DBusMessageIter dict_it;
328
 
 
329
 
  dbus_message_iter_recurse(reader, &arr_it);
330
 
  while (dbus_message_iter_has_next(&arr_it))
331
 
  {
332
 
    $interface.type2csymbol(dict.key_type) key;
333
 
    $interface.type2csymbol(dict.value_type) value;
334
 
 
335
 
    dbus_message_iter_recurse(&arr_it, &dict_it);
336
 
    
337
 
    get_${dict.key_type}(&dict_it, &key);
338
 
    get_${dict.value_type}(&dict_it, &value);
339
 
 
340
 
    (*result)[key] = value;
341
 
 
342
 
    dbus_message_iter_next(&arr_it);
343
 
  }
344
 
 
345
 
  dbus_message_iter_next(reader);
346
 
}
347
 
 
348
 
 
349
 
void
350
 
${interface.qname}::put_${dict.qname}(DBusMessageIter *writer, const ${dict.csymbol} *result)
351
 
{
352
 
  DBusMessageIter arr_it;
353
 
  DBusMessageIter dict_it;
354
 
  ${dict.csymbol}::const_iterator it;
355
 
  dbus_bool_t ok;
356
 
  
357
 
  ok = dbus_message_iter_open_container(writer, DBUS_TYPE_ARRAY,
358
 
                                        "$interface.type2sig(dict.value_type)", &arr_it);
359
 
  if (!ok)
360
 
    {
361
 
      throw DBusSystemException("Internal error");
362
 
    }
363
 
 
364
 
  for (it = result->begin(); it != result->end(); it++)
365
 
    {
366
 
      ok = dbus_message_iter_open_container(&arr_it, DBUS_TYPE_DICT_ENTRY, NULL, &dict_it);
367
 
      if (!ok)
368
 
        {
369
 
          throw DBusSystemException("Internal error");
370
 
        }
371
 
    
372
 
      put_${dict.key_type}(&dict_it, &(it->first));
373
 
      put_${dict.value_type}(&dict_it, &(it->second));
374
 
 
375
 
      ok = dbus_message_iter_close_container(&arr_it, &dict_it);
376
 
      if (!ok)
377
 
        {
378
 
          throw DBusSystemException("Internal error");
379
 
        }
380
 
    }
381
 
  
382
 
  ok = dbus_message_iter_close_container(writer, &arr_it);
383
 
  if (!ok)
384
 
    {
385
 
      throw DBusSystemException("Internal error");
386
 
    }
387
 
}
388
 
 
389
 
 
390
 
#end for
391
 
 
392
 
#for method in $interface.methods
393
 
 
394
 
$interface.type2csymbol(method.return_type()) ${interface.qname}_Impl::${method.qname}(#slurp
395
 
  #set comma = ''
396
 
  #for p in method.params
397
 
  #if p.direction != 'out' or (not 'return' in p.hint)
398
 
  #if 'const' in p.hint
399
 
  const #slurp
400
 
  #end if
401
 
  $comma $interface.type2csymbol(p.type) #slurp
402
 
  #set comma = ','
403
 
  #end if
404
 
  #if p.direction == 'out'
405
 
    #if 'return' in p.hint
406
 
    /**/ #slurp
407
 
    #slurp                                                             
408
 
    #else if 'ptr' in p.hint
409
 
     *$p.name#slurp
410
 
    #else
411
 
     &$p.name#slurp
412
 
    #end if 
413
 
  #else if p.direction == 'in'
414
 
    #if 'ref' in p.hint
415
 
    &$p.name#slurp
416
 
    #else if 'ptr' in p.hint
417
 
    *$p.name#slurp
418
 
    #else
419
 
    $p.name#slurp
420
 
    #end if 
421
 
  #end if
422
 
  #end for
423
 
  )
424
 
{
425
 
#if method.condition != ''
426
 
\#if $method.condition
427
 
#end if
428
 
 
429
 
  DBusMessage *message = NULL;
430
 
  DBusMessage *reply = NULL;
431
 
  DBusPendingCall *pending = NULL;
432
 
  
433
 
  DBusMessageIter reader;
434
 
  DBusMessageIter writer;
435
 
  dbus_bool_t ok;
436
 
 
437
 
#set have_in_args = False
438
 
#for p in method.params
439
 
#if p.direction == 'in'
440
 
#set have_in_args = True
441
 
#end if
442
 
#if 'return' in p.hint
443
 
  #if 'ptrtr' in p.hint
444
 
    $interface.type2csymbol(p.type) *${p.name} = NULL;
445
 
  #else
446
 
    $interface.type2csymbol(p.type) ${p.name};
447
 
  #end if
448
 
#end if
449
 
#end for
450
 
  
451
 
  try
452
 
    {
453
 
      message = dbus_message_new_method_call(service.c_str(),
454
 
                                             path.c_str(),
455
 
                                             "$interface.name",  "$method.name"); 
456
 
 
457
 
      dbus_message_iter_init_append(message, &writer);
458
 
 
459
 
  #for arg in method.params:
460
 
  #if arg.direction == 'in'
461
 
  #if 'ptrptr' in p.hint
462
 
      put_${arg.type}(&writer, ${arg.name});
463
 
  #else                                                        
464
 
      put_${arg.type}(&writer, &${arg.name});
465
 
  #end if                                                         
466
 
  #end if
467
 
  #end for
468
 
 
469
 
      if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
470
 
        { 
471
 
          throw DBusSystemException("Cannot send");
472
 
        }
473
 
      
474
 
      if (NULL == pending)
475
 
        { 
476
 
          throw DBusSystemException("No pending reply");
477
 
        }
478
 
      
479
 
      dbus_connection_flush(dbus->conn());
480
 
      
481
 
      // free message
482
 
      dbus_message_unref(message);
483
 
      message = NULL;
484
 
      
485
 
      // block until we receive a reply
486
 
      dbus_pending_call_block(pending);
487
 
      
488
 
      // get the reply message
489
 
      reply = dbus_pending_call_steal_reply(pending);
490
 
      if (NULL == reply)
491
 
        {
492
 
          throw DBusSystemException("No reply");
493
 
        }
494
 
      
495
 
      // free the pending message handle
496
 
      dbus_pending_call_unref(pending);
497
 
      pending = NULL;
498
 
      
499
 
      ok = dbus_message_iter_init(reply, &reader);
500
 
#if have_in_args
501
 
      if (!ok)
502
 
        {
503
 
          throw DBusSystemException("No parameters");
504
 
        }
505
 
#end if
506
 
      
507
 
#for arg in method.params:
508
 
#if $arg.direction == 'out'
509
 
      get_${arg.type}(&reader, &${arg.name});
510
 
#end if
511
 
#end for
512
 
      
513
 
    }
514
 
  catch (DBusException)
515
 
    {
516
 
      if (reply != NULL)
517
 
        {
518
 
          dbus_message_unref(reply);
519
 
        }
520
 
 
521
 
      if (message != NULL)
522
 
        {
523
 
          dbus_message_unref(message);
524
 
        }
525
 
 
526
 
      if (pending != NULL)
527
 
        {
528
 
          dbus_pending_call_unref(pending);
529
 
        }
530
 
      
531
 
      throw;
532
 
    }
533
 
  
534
 
#if method.return_type() != 'void'
535
 
  return $method.return_name();
536
 
#end if
537
 
    
538
 
#if method.condition != ''
539
 
\#else
540
 
    (void) object;
541
 
  
542
 
  reply = dbus_message_new_error(message,
543
 
                                 "org.workrave.NotImplemented",
544
 
                                 "This method is unavailable in current configuration");
545
 
\#endif
546
 
#end if                                                          
547
 
}
548
 
 
549
 
 
550
 
void ${interface.qname}_Impl::${method.qname}_async(#slurp
551
 
  #set comma = ''
552
 
  #for p in method.params
553
 
  #if p.direction == 'in'
554
 
    #if 'const' in p.hint
555
 
      const #slurp
556
 
    #end if
557
 
    $comma $interface.type2csymbol(p.type) #slurp
558
 
    #if 'ref' in p.hint
559
 
    &$p.name#slurp
560
 
    #else if 'ptr' in p.hint
561
 
    *$p.name#slurp
562
 
    #else
563
 
    $p.name#slurp
564
 
    #end if 
565
 
    #set comma = ','
566
 
  #end if
567
 
  #end for
568
 
  $comma ${method.name}_slot slot                                                    
569
 
  )
570
 
{
571
 
#if method.condition != ''
572
 
\#if $method.condition
573
 
#end if
574
 
 
575
 
  DBusMessage *message = NULL;
576
 
  DBusPendingCall *pending = NULL;
577
 
  
578
 
  DBusMessageIter writer;
579
 
 
580
 
  try
581
 
    {
582
 
      message = dbus_message_new_method_call(service.c_str(),
583
 
                                             path.c_str(),
584
 
                                             "$interface.name",  "$method.name"); 
585
 
 
586
 
      dbus_message_iter_init(message, &writer);
587
 
 
588
 
  #for arg in method.params:
589
 
  #if arg.direction == 'in'
590
 
  #if 'ptrptr' in p.hint
591
 
      put_${arg.type}(&writer, ${arg.name});
592
 
  #else                                                        
593
 
      put_${arg.type}(&writer, &${arg.name});
594
 
  #end if                                                         
595
 
  #end if
596
 
  #end for
597
 
 
598
 
      if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
599
 
        { 
600
 
          throw DBusSystemException("Cannot send");
601
 
        }
602
 
      
603
 
      if (NULL == pending)
604
 
        { 
605
 
          throw DBusSystemException("No pending reply");
606
 
        }
607
 
 
608
 
      ${method.qname}_async_closure *closure = new ${method.qname}_async_closure;
609
 
      closure->impl = this;
610
 
      closure->signal.connect(slot);
611
 
      
612
 
      if (!dbus_pending_call_set_notify(pending,
613
 
                                        ${interface.qname}_Impl::${method.qname}_fcn_static,
614
 
                                        closure, ${method.qname}_async_closure_free))
615
 
        {
616
 
          throw DBusSystemException("Cannot set notifier");
617
 
        }
618
 
      
619
 
      // free message
620
 
      dbus_message_unref(message);
621
 
      message = NULL;
622
 
    }
623
 
  catch (DBusException)
624
 
    {
625
 
      if (message != NULL)
626
 
        {
627
 
          dbus_message_unref(message);
628
 
        }
629
 
 
630
 
      if (pending != NULL)
631
 
        {
632
 
          dbus_pending_call_unref(pending);
633
 
        }
634
 
      
635
 
      throw;
636
 
    }
637
 
  
638
 
#if method.condition != ''
639
 
\#else
640
 
    (void) object;
641
 
  
642
 
  reply = dbus_message_new_error(message,
643
 
                                 "org.workrave.NotImplemented",
644
 
                                 "This method is unavailable in current configuration");
645
 
  \#endif
646
 
#end if                                                          
647
 
}
648
 
 
649
 
void ${interface.qname}_Impl::${method.qname}_fcn_static(DBusPendingCall *pending, void *user_data)
650
 
{
651
 
  ${method.qname}_async_closure *closure = (${method.qname}_async_closure *)user_data;
652
 
 
653
 
  closure->impl->${method.qname}_fcn(pending, user_data);
654
 
}
655
 
 
656
 
void ${interface.qname}_Impl::${method.qname}_fcn(DBusPendingCall *pending, void *user_data)
657
 
{
658
 
#if method.condition != ''
659
 
\#if $method.condition
660
 
#end if
661
 
  ${method.qname}_async_closure *closure = (${method.qname}_async_closure *)user_data;
662
 
        DBusMessage *reply = NULL;
663
 
  DBusMessageIter reader;
664
 
        DBusError error;
665
 
  dbus_bool_t ok;
666
 
 
667
 
#set have_out_args = False
668
 
#for p in method.params
669
 
  #if p.direction == 'out'
670
 
    #set have_out_args = True
671
 
    #if 'ptrtr' in p.hint
672
 
      $interface.type2csymbol(p.type) *${p.name} = NULL;
673
 
    #else
674
 
      $interface.type2csymbol(p.type) ${p.name};
675
 
    #end if
676
 
  #end if
677
 
#end for
678
 
  
679
 
        dbus_error_init(&error);
680
 
 
681
 
  try
682
 
    {
683
 
      reply = dbus_pending_call_steal_reply(pending);
684
 
      if (reply == NULL)
685
 
        {
686
 
          throw DBusSystemException("Cannot get reply");
687
 
        }
688
 
      
689
 
      ok = dbus_message_iter_init(reply, &reader);
690
 
#if have_out_args
691
 
      if (!ok)
692
 
        {
693
 
          throw DBusSystemException("No parameters");
694
 
        }
695
 
#end if
696
 
      
697
 
#for arg in method.params:
698
 
#if $arg.direction == 'out'
699
 
      get_${arg.type}(&reader, &${arg.name});
700
 
#end if
701
 
#end for
702
 
 
703
 
      closure->signal.emit((DBusError *)NULL #slurp
704
 
#for p in method.params
705
 
#if p.direction == 'out'
706
 
      , $p.name #slurp
707
 
#end if
708
 
#end for
709
 
      );
710
 
    }
711
 
  catch (DBusException)
712
 
    {
713
 
      if (reply != NULL)
714
 
        {
715
 
          dbus_message_unref(reply);
716
 
        }
717
 
 
718
 
      if (pending != NULL)
719
 
        {
720
 
          dbus_pending_call_unref(pending);
721
 
        }
722
 
      
723
 
      throw;
724
 
    }
725
 
#if method.condition != ''
726
 
\#endif
727
 
#end if
728
 
}                           
729
 
  
730
 
 
731
 
 
732
 
  
733
 
 
734
 
#end for
735
 
 
736
 
 
737
 
#if interface.condition != ''
738
 
\#endif
739
 
#end if                                                          
740
 
 
741
 
#end for