~leighman/ubuntu/raring/workrave/fix-desktop-file-2

« back to all changes in this revision

Viewing changes to frontend/gtkmm/src/DBusGnomeApplet.cc

  • Committer: Package Import Robot
  • Author(s): Michael Terry
  • Date: 2013-01-24 11:04:41 UTC
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: package-import@ubuntu.com-20130124110441-t06q3xlc7mp4406p
Tags: upstream-1.10
ImportĀ upstreamĀ versionĀ 1.10

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 "DBusGnomeApplet.hh"
 
32
 
 
33
using namespace std;
 
34
using namespace workrave;
 
35
 
 
36
 
 
37
 
 
38
 
 
39
 
 
40
class org_workrave_GnomeAppletInterface_Impl : public org_workrave_GnomeAppletInterface, public DBusBaseTypes
 
41
{
 
42
public:
 
43
  org_workrave_GnomeAppletInterface_Impl(DBus *dbus, const string &service, const string &path);
 
44
 
 
45
  guint32 GetSocketId(    /**/   );
 
46
  void GetSocketId_async(     GetSocketId_slot slot   );
 
47
 
 
48
 
 
49
  guint32 GetSize(    /**/   );
 
50
  void GetSize_async(     GetSize_slot slot   );
 
51
 
 
52
 
 
53
  guint32 GetOrientation(    /**/   );
 
54
  void GetOrientation_async(     GetOrientation_slot slot   );
 
55
 
 
56
 
 
57
  void SetMenuStatus(  const    std::string     &menu  , bool     &status  );
 
58
  void SetMenuStatus_async(      const      std::string     &menu    , bool     &status    , SetMenuStatus_slot slot   );
 
59
 
 
60
 
 
61
  void GetMenuStatus(  const    std::string     &menu  , bool      &status  );
 
62
  void GetMenuStatus_async(      const      std::string     &menu    , GetMenuStatus_slot slot   );
 
63
 
 
64
 
 
65
  void SetMenuActive(  const    std::string     &menu  , bool     &active  );
 
66
  void SetMenuActive_async(      const      std::string     &menu    , bool     &active    , SetMenuActive_slot slot   );
 
67
 
 
68
 
 
69
  void GetMenuActive(  const    std::string     &menu  , bool      &active  );
 
70
  void GetMenuActive_async(      const      std::string     &menu    , GetMenuActive_slot slot   );
 
71
 
 
72
 
 
73
 
 
74
private:
 
75
  typedef sigc::signal<void, DBusError *     , guint32   > GetSocketId_signal;
 
76
  struct GetSocketId_async_closure
 
77
  {
 
78
     class org_workrave_GnomeAppletInterface_Impl *impl;
 
79
     GetSocketId_signal signal;
 
80
  };
 
81
  static void GetSocketId_async_closure_free(void *mem)
 
82
  {
 
83
    delete (GetSocketId_async_closure *)mem;
 
84
  }
 
85
 
 
86
  static void GetSocketId_fcn_static(DBusPendingCall *pending, void *user_data);
 
87
  void GetSocketId_fcn(DBusPendingCall *pending, void *user_data);
 
88
 
 
89
  typedef sigc::signal<void, DBusError *     , guint32   > GetSize_signal;
 
90
  struct GetSize_async_closure
 
91
  {
 
92
     class org_workrave_GnomeAppletInterface_Impl *impl;
 
93
     GetSize_signal signal;
 
94
  };
 
95
  static void GetSize_async_closure_free(void *mem)
 
96
  {
 
97
    delete (GetSize_async_closure *)mem;
 
98
  }
 
99
 
 
100
  static void GetSize_fcn_static(DBusPendingCall *pending, void *user_data);
 
101
  void GetSize_fcn(DBusPendingCall *pending, void *user_data);
 
102
 
 
103
  typedef sigc::signal<void, DBusError *     , guint32   > GetOrientation_signal;
 
104
  struct GetOrientation_async_closure
 
105
  {
 
106
     class org_workrave_GnomeAppletInterface_Impl *impl;
 
107
     GetOrientation_signal signal;
 
108
  };
 
109
  static void GetOrientation_async_closure_free(void *mem)
 
110
  {
 
111
    delete (GetOrientation_async_closure *)mem;
 
112
  }
 
113
 
 
114
  static void GetOrientation_fcn_static(DBusPendingCall *pending, void *user_data);
 
115
  void GetOrientation_fcn(DBusPendingCall *pending, void *user_data);
 
116
 
 
117
  typedef sigc::signal<void, DBusError *   > SetMenuStatus_signal;
 
118
  struct SetMenuStatus_async_closure
 
119
  {
 
120
     class org_workrave_GnomeAppletInterface_Impl *impl;
 
121
     SetMenuStatus_signal signal;
 
122
  };
 
123
  static void SetMenuStatus_async_closure_free(void *mem)
 
124
  {
 
125
    delete (SetMenuStatus_async_closure *)mem;
 
126
  }
 
127
 
 
128
  static void SetMenuStatus_fcn_static(DBusPendingCall *pending, void *user_data);
 
129
  void SetMenuStatus_fcn(DBusPendingCall *pending, void *user_data);
 
130
 
 
131
  typedef sigc::signal<void, DBusError *     , bool     &  > GetMenuStatus_signal;
 
132
  struct GetMenuStatus_async_closure
 
133
  {
 
134
     class org_workrave_GnomeAppletInterface_Impl *impl;
 
135
     GetMenuStatus_signal signal;
 
136
  };
 
137
  static void GetMenuStatus_async_closure_free(void *mem)
 
138
  {
 
139
    delete (GetMenuStatus_async_closure *)mem;
 
140
  }
 
141
 
 
142
  static void GetMenuStatus_fcn_static(DBusPendingCall *pending, void *user_data);
 
143
  void GetMenuStatus_fcn(DBusPendingCall *pending, void *user_data);
 
144
 
 
145
  typedef sigc::signal<void, DBusError *   > SetMenuActive_signal;
 
146
  struct SetMenuActive_async_closure
 
147
  {
 
148
     class org_workrave_GnomeAppletInterface_Impl *impl;
 
149
     SetMenuActive_signal signal;
 
150
  };
 
151
  static void SetMenuActive_async_closure_free(void *mem)
 
152
  {
 
153
    delete (SetMenuActive_async_closure *)mem;
 
154
  }
 
155
 
 
156
  static void SetMenuActive_fcn_static(DBusPendingCall *pending, void *user_data);
 
157
  void SetMenuActive_fcn(DBusPendingCall *pending, void *user_data);
 
158
 
 
159
  typedef sigc::signal<void, DBusError *     , bool     &  > GetMenuActive_signal;
 
160
  struct GetMenuActive_async_closure
 
161
  {
 
162
     class org_workrave_GnomeAppletInterface_Impl *impl;
 
163
     GetMenuActive_signal signal;
 
164
  };
 
165
  static void GetMenuActive_async_closure_free(void *mem)
 
166
  {
 
167
    delete (GetMenuActive_async_closure *)mem;
 
168
  }
 
169
 
 
170
  static void GetMenuActive_fcn_static(DBusPendingCall *pending, void *user_data);
 
171
  void GetMenuActive_fcn(DBusPendingCall *pending, void *user_data);
 
172
 
 
173
 
 
174
 
 
175
 
 
176
 
 
177
 
 
178
  DBus *dbus;
 
179
  string service;
 
180
  string path;
 
181
};
 
182
 
 
183
 
 
184
org_workrave_GnomeAppletInterface_Impl::org_workrave_GnomeAppletInterface_Impl(DBus *dbus, const string &service, const string &path)
 
185
  : dbus(dbus), service(service), path(path)
 
186
{
 
187
}
 
188
 
 
189
org_workrave_GnomeAppletInterface *org_workrave_GnomeAppletInterface::instance(DBus *dbus, const string &service, const string &path)
 
190
{
 
191
  return new org_workrave_GnomeAppletInterface_Impl(dbus, service, path);
 
192
}
 
193
 
 
194
 
 
195
 
 
196
 
 
197
 
 
198
 
 
199
 
 
200
 
 
201
guint32 org_workrave_GnomeAppletInterface_Impl::GetSocketId(    /**/   )
 
202
{
 
203
 
 
204
  DBusMessage *message = NULL;
 
205
  DBusMessage *reply = NULL;
 
206
  DBusPendingCall *pending = NULL;
 
207
 
 
208
  DBusMessageIter reader;
 
209
  DBusMessageIter writer;
 
210
  dbus_bool_t ok;
 
211
 
 
212
    guint32 id;
 
213
 
 
214
  try
 
215
    {
 
216
      message = dbus_message_new_method_call(service.c_str(),
 
217
                                             path.c_str(),
 
218
                                             "org.workrave.GnomeAppletInterface",  "GetSocketId");
 
219
 
 
220
      dbus_message_iter_init_append(message, &writer);
 
221
 
 
222
 
 
223
      if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
 
224
        {
 
225
          throw DBusSystemException("Cannot send");
 
226
        }
 
227
 
 
228
      if (NULL == pending)
 
229
        {
 
230
          throw DBusSystemException("No pending reply");
 
231
        }
 
232
 
 
233
      dbus_connection_flush(dbus->conn());
 
234
 
 
235
      // free message
 
236
      dbus_message_unref(message);
 
237
      message = NULL;
 
238
 
 
239
      // block until we receive a reply
 
240
      dbus_pending_call_block(pending);
 
241
 
 
242
      // get the reply message
 
243
      reply = dbus_pending_call_steal_reply(pending);
 
244
      if (NULL == reply)
 
245
        {
 
246
          throw DBusSystemException("No reply");
 
247
        }
 
248
 
 
249
      // free the pending message handle
 
250
      dbus_pending_call_unref(pending);
 
251
      pending = NULL;
 
252
 
 
253
      ok = dbus_message_iter_init(reply, &reader);
 
254
 
 
255
      get_uint32(&reader, &id);
 
256
 
 
257
    }
 
258
  catch (DBusException)
 
259
    {
 
260
      if (reply != NULL)
 
261
        {
 
262
          dbus_message_unref(reply);
 
263
        }
 
264
 
 
265
      if (message != NULL)
 
266
        {
 
267
          dbus_message_unref(message);
 
268
        }
 
269
 
 
270
      if (pending != NULL)
 
271
        {
 
272
          dbus_pending_call_unref(pending);
 
273
        }
 
274
 
 
275
      throw;
 
276
    }
 
277
 
 
278
  return id;
 
279
 
 
280
}
 
281
 
 
282
 
 
283
void org_workrave_GnomeAppletInterface_Impl::GetSocketId_async(   GetSocketId_slot slot
 
284
  )
 
285
{
 
286
 
 
287
  DBusMessage *message = NULL;
 
288
  DBusPendingCall *pending = NULL;
 
289
 
 
290
  DBusMessageIter writer;
 
291
 
 
292
  try
 
293
    {
 
294
      message = dbus_message_new_method_call(service.c_str(),
 
295
                                             path.c_str(),
 
296
                                             "org.workrave.GnomeAppletInterface",  "GetSocketId");
 
297
 
 
298
      dbus_message_iter_init(message, &writer);
 
299
 
 
300
 
 
301
      if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
 
302
        {
 
303
          throw DBusSystemException("Cannot send");
 
304
        }
 
305
 
 
306
      if (NULL == pending)
 
307
        {
 
308
          throw DBusSystemException("No pending reply");
 
309
        }
 
310
 
 
311
      GetSocketId_async_closure *closure = new GetSocketId_async_closure;
 
312
      closure->impl = this;
 
313
      closure->signal.connect(slot);
 
314
 
 
315
      if (!dbus_pending_call_set_notify(pending,
 
316
                                        org_workrave_GnomeAppletInterface_Impl::GetSocketId_fcn_static,
 
317
                                        closure, GetSocketId_async_closure_free))
 
318
        {
 
319
          throw DBusSystemException("Cannot set notifier");
 
320
        }
 
321
 
 
322
      // free message
 
323
      dbus_message_unref(message);
 
324
      message = NULL;
 
325
    }
 
326
  catch (DBusException)
 
327
    {
 
328
      if (message != NULL)
 
329
        {
 
330
          dbus_message_unref(message);
 
331
        }
 
332
 
 
333
      if (pending != NULL)
 
334
        {
 
335
          dbus_pending_call_unref(pending);
 
336
        }
 
337
 
 
338
      throw;
 
339
    }
 
340
 
 
341
}
 
342
 
 
343
void org_workrave_GnomeAppletInterface_Impl::GetSocketId_fcn_static(DBusPendingCall *pending, void *user_data)
 
344
{
 
345
  GetSocketId_async_closure *closure = (GetSocketId_async_closure *)user_data;
 
346
 
 
347
  closure->impl->GetSocketId_fcn(pending, user_data);
 
348
}
 
349
 
 
350
void org_workrave_GnomeAppletInterface_Impl::GetSocketId_fcn(DBusPendingCall *pending, void *user_data)
 
351
{
 
352
  GetSocketId_async_closure *closure = (GetSocketId_async_closure *)user_data;
 
353
        DBusMessage *reply = NULL;
 
354
  DBusMessageIter reader;
 
355
        DBusError error;
 
356
  dbus_bool_t ok;
 
357
 
 
358
      guint32 id;
 
359
 
 
360
        dbus_error_init(&error);
 
361
 
 
362
  try
 
363
    {
 
364
      reply = dbus_pending_call_steal_reply(pending);
 
365
      if (reply == NULL)
 
366
        {
 
367
          throw DBusSystemException("Cannot get reply");
 
368
        }
 
369
 
 
370
      ok = dbus_message_iter_init(reply, &reader);
 
371
      if (!ok)
 
372
        {
 
373
          throw DBusSystemException("No parameters");
 
374
        }
 
375
 
 
376
      get_uint32(&reader, &id);
 
377
 
 
378
      closure->signal.emit((DBusError *)NULL       , id       );
 
379
    }
 
380
  catch (DBusException)
 
381
    {
 
382
      if (reply != NULL)
 
383
        {
 
384
          dbus_message_unref(reply);
 
385
        }
 
386
 
 
387
      if (pending != NULL)
 
388
        {
 
389
          dbus_pending_call_unref(pending);
 
390
        }
 
391
 
 
392
      throw;
 
393
    }
 
394
}
 
395
 
 
396
 
 
397
 
 
398
 
 
399
 
 
400
 
 
401
guint32 org_workrave_GnomeAppletInterface_Impl::GetSize(    /**/   )
 
402
{
 
403
 
 
404
  DBusMessage *message = NULL;
 
405
  DBusMessage *reply = NULL;
 
406
  DBusPendingCall *pending = NULL;
 
407
 
 
408
  DBusMessageIter reader;
 
409
  DBusMessageIter writer;
 
410
  dbus_bool_t ok;
 
411
 
 
412
    guint32 size;
 
413
 
 
414
  try
 
415
    {
 
416
      message = dbus_message_new_method_call(service.c_str(),
 
417
                                             path.c_str(),
 
418
                                             "org.workrave.GnomeAppletInterface",  "GetSize");
 
419
 
 
420
      dbus_message_iter_init_append(message, &writer);
 
421
 
 
422
 
 
423
      if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
 
424
        {
 
425
          throw DBusSystemException("Cannot send");
 
426
        }
 
427
 
 
428
      if (NULL == pending)
 
429
        {
 
430
          throw DBusSystemException("No pending reply");
 
431
        }
 
432
 
 
433
      dbus_connection_flush(dbus->conn());
 
434
 
 
435
      // free message
 
436
      dbus_message_unref(message);
 
437
      message = NULL;
 
438
 
 
439
      // block until we receive a reply
 
440
      dbus_pending_call_block(pending);
 
441
 
 
442
      // get the reply message
 
443
      reply = dbus_pending_call_steal_reply(pending);
 
444
      if (NULL == reply)
 
445
        {
 
446
          throw DBusSystemException("No reply");
 
447
        }
 
448
 
 
449
      // free the pending message handle
 
450
      dbus_pending_call_unref(pending);
 
451
      pending = NULL;
 
452
 
 
453
      ok = dbus_message_iter_init(reply, &reader);
 
454
 
 
455
      get_uint32(&reader, &size);
 
456
 
 
457
    }
 
458
  catch (DBusException)
 
459
    {
 
460
      if (reply != NULL)
 
461
        {
 
462
          dbus_message_unref(reply);
 
463
        }
 
464
 
 
465
      if (message != NULL)
 
466
        {
 
467
          dbus_message_unref(message);
 
468
        }
 
469
 
 
470
      if (pending != NULL)
 
471
        {
 
472
          dbus_pending_call_unref(pending);
 
473
        }
 
474
 
 
475
      throw;
 
476
    }
 
477
 
 
478
  return size;
 
479
 
 
480
}
 
481
 
 
482
 
 
483
void org_workrave_GnomeAppletInterface_Impl::GetSize_async(   GetSize_slot slot
 
484
  )
 
485
{
 
486
 
 
487
  DBusMessage *message = NULL;
 
488
  DBusPendingCall *pending = NULL;
 
489
 
 
490
  DBusMessageIter writer;
 
491
 
 
492
  try
 
493
    {
 
494
      message = dbus_message_new_method_call(service.c_str(),
 
495
                                             path.c_str(),
 
496
                                             "org.workrave.GnomeAppletInterface",  "GetSize");
 
497
 
 
498
      dbus_message_iter_init(message, &writer);
 
499
 
 
500
 
 
501
      if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
 
502
        {
 
503
          throw DBusSystemException("Cannot send");
 
504
        }
 
505
 
 
506
      if (NULL == pending)
 
507
        {
 
508
          throw DBusSystemException("No pending reply");
 
509
        }
 
510
 
 
511
      GetSize_async_closure *closure = new GetSize_async_closure;
 
512
      closure->impl = this;
 
513
      closure->signal.connect(slot);
 
514
 
 
515
      if (!dbus_pending_call_set_notify(pending,
 
516
                                        org_workrave_GnomeAppletInterface_Impl::GetSize_fcn_static,
 
517
                                        closure, GetSize_async_closure_free))
 
518
        {
 
519
          throw DBusSystemException("Cannot set notifier");
 
520
        }
 
521
 
 
522
      // free message
 
523
      dbus_message_unref(message);
 
524
      message = NULL;
 
525
    }
 
526
  catch (DBusException)
 
527
    {
 
528
      if (message != NULL)
 
529
        {
 
530
          dbus_message_unref(message);
 
531
        }
 
532
 
 
533
      if (pending != NULL)
 
534
        {
 
535
          dbus_pending_call_unref(pending);
 
536
        }
 
537
 
 
538
      throw;
 
539
    }
 
540
 
 
541
}
 
542
 
 
543
void org_workrave_GnomeAppletInterface_Impl::GetSize_fcn_static(DBusPendingCall *pending, void *user_data)
 
544
{
 
545
  GetSize_async_closure *closure = (GetSize_async_closure *)user_data;
 
546
 
 
547
  closure->impl->GetSize_fcn(pending, user_data);
 
548
}
 
549
 
 
550
void org_workrave_GnomeAppletInterface_Impl::GetSize_fcn(DBusPendingCall *pending, void *user_data)
 
551
{
 
552
  GetSize_async_closure *closure = (GetSize_async_closure *)user_data;
 
553
        DBusMessage *reply = NULL;
 
554
  DBusMessageIter reader;
 
555
        DBusError error;
 
556
  dbus_bool_t ok;
 
557
 
 
558
      guint32 size;
 
559
 
 
560
        dbus_error_init(&error);
 
561
 
 
562
  try
 
563
    {
 
564
      reply = dbus_pending_call_steal_reply(pending);
 
565
      if (reply == NULL)
 
566
        {
 
567
          throw DBusSystemException("Cannot get reply");
 
568
        }
 
569
 
 
570
      ok = dbus_message_iter_init(reply, &reader);
 
571
      if (!ok)
 
572
        {
 
573
          throw DBusSystemException("No parameters");
 
574
        }
 
575
 
 
576
      get_uint32(&reader, &size);
 
577
 
 
578
      closure->signal.emit((DBusError *)NULL       , size       );
 
579
    }
 
580
  catch (DBusException)
 
581
    {
 
582
      if (reply != NULL)
 
583
        {
 
584
          dbus_message_unref(reply);
 
585
        }
 
586
 
 
587
      if (pending != NULL)
 
588
        {
 
589
          dbus_pending_call_unref(pending);
 
590
        }
 
591
 
 
592
      throw;
 
593
    }
 
594
}
 
595
 
 
596
 
 
597
 
 
598
 
 
599
 
 
600
 
 
601
guint32 org_workrave_GnomeAppletInterface_Impl::GetOrientation(    /**/   )
 
602
{
 
603
 
 
604
  DBusMessage *message = NULL;
 
605
  DBusMessage *reply = NULL;
 
606
  DBusPendingCall *pending = NULL;
 
607
 
 
608
  DBusMessageIter reader;
 
609
  DBusMessageIter writer;
 
610
  dbus_bool_t ok;
 
611
 
 
612
    guint32 orientation;
 
613
 
 
614
  try
 
615
    {
 
616
      message = dbus_message_new_method_call(service.c_str(),
 
617
                                             path.c_str(),
 
618
                                             "org.workrave.GnomeAppletInterface",  "GetOrientation");
 
619
 
 
620
      dbus_message_iter_init_append(message, &writer);
 
621
 
 
622
 
 
623
      if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
 
624
        {
 
625
          throw DBusSystemException("Cannot send");
 
626
        }
 
627
 
 
628
      if (NULL == pending)
 
629
        {
 
630
          throw DBusSystemException("No pending reply");
 
631
        }
 
632
 
 
633
      dbus_connection_flush(dbus->conn());
 
634
 
 
635
      // free message
 
636
      dbus_message_unref(message);
 
637
      message = NULL;
 
638
 
 
639
      // block until we receive a reply
 
640
      dbus_pending_call_block(pending);
 
641
 
 
642
      // get the reply message
 
643
      reply = dbus_pending_call_steal_reply(pending);
 
644
      if (NULL == reply)
 
645
        {
 
646
          throw DBusSystemException("No reply");
 
647
        }
 
648
 
 
649
      // free the pending message handle
 
650
      dbus_pending_call_unref(pending);
 
651
      pending = NULL;
 
652
 
 
653
      ok = dbus_message_iter_init(reply, &reader);
 
654
 
 
655
      get_uint32(&reader, &orientation);
 
656
 
 
657
    }
 
658
  catch (DBusException)
 
659
    {
 
660
      if (reply != NULL)
 
661
        {
 
662
          dbus_message_unref(reply);
 
663
        }
 
664
 
 
665
      if (message != NULL)
 
666
        {
 
667
          dbus_message_unref(message);
 
668
        }
 
669
 
 
670
      if (pending != NULL)
 
671
        {
 
672
          dbus_pending_call_unref(pending);
 
673
        }
 
674
 
 
675
      throw;
 
676
    }
 
677
 
 
678
  return orientation;
 
679
 
 
680
}
 
681
 
 
682
 
 
683
void org_workrave_GnomeAppletInterface_Impl::GetOrientation_async(   GetOrientation_slot slot
 
684
  )
 
685
{
 
686
 
 
687
  DBusMessage *message = NULL;
 
688
  DBusPendingCall *pending = NULL;
 
689
 
 
690
  DBusMessageIter writer;
 
691
 
 
692
  try
 
693
    {
 
694
      message = dbus_message_new_method_call(service.c_str(),
 
695
                                             path.c_str(),
 
696
                                             "org.workrave.GnomeAppletInterface",  "GetOrientation");
 
697
 
 
698
      dbus_message_iter_init(message, &writer);
 
699
 
 
700
 
 
701
      if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
 
702
        {
 
703
          throw DBusSystemException("Cannot send");
 
704
        }
 
705
 
 
706
      if (NULL == pending)
 
707
        {
 
708
          throw DBusSystemException("No pending reply");
 
709
        }
 
710
 
 
711
      GetOrientation_async_closure *closure = new GetOrientation_async_closure;
 
712
      closure->impl = this;
 
713
      closure->signal.connect(slot);
 
714
 
 
715
      if (!dbus_pending_call_set_notify(pending,
 
716
                                        org_workrave_GnomeAppletInterface_Impl::GetOrientation_fcn_static,
 
717
                                        closure, GetOrientation_async_closure_free))
 
718
        {
 
719
          throw DBusSystemException("Cannot set notifier");
 
720
        }
 
721
 
 
722
      // free message
 
723
      dbus_message_unref(message);
 
724
      message = NULL;
 
725
    }
 
726
  catch (DBusException)
 
727
    {
 
728
      if (message != NULL)
 
729
        {
 
730
          dbus_message_unref(message);
 
731
        }
 
732
 
 
733
      if (pending != NULL)
 
734
        {
 
735
          dbus_pending_call_unref(pending);
 
736
        }
 
737
 
 
738
      throw;
 
739
    }
 
740
 
 
741
}
 
742
 
 
743
void org_workrave_GnomeAppletInterface_Impl::GetOrientation_fcn_static(DBusPendingCall *pending, void *user_data)
 
744
{
 
745
  GetOrientation_async_closure *closure = (GetOrientation_async_closure *)user_data;
 
746
 
 
747
  closure->impl->GetOrientation_fcn(pending, user_data);
 
748
}
 
749
 
 
750
void org_workrave_GnomeAppletInterface_Impl::GetOrientation_fcn(DBusPendingCall *pending, void *user_data)
 
751
{
 
752
  GetOrientation_async_closure *closure = (GetOrientation_async_closure *)user_data;
 
753
        DBusMessage *reply = NULL;
 
754
  DBusMessageIter reader;
 
755
        DBusError error;
 
756
  dbus_bool_t ok;
 
757
 
 
758
      guint32 orientation;
 
759
 
 
760
        dbus_error_init(&error);
 
761
 
 
762
  try
 
763
    {
 
764
      reply = dbus_pending_call_steal_reply(pending);
 
765
      if (reply == NULL)
 
766
        {
 
767
          throw DBusSystemException("Cannot get reply");
 
768
        }
 
769
 
 
770
      ok = dbus_message_iter_init(reply, &reader);
 
771
      if (!ok)
 
772
        {
 
773
          throw DBusSystemException("No parameters");
 
774
        }
 
775
 
 
776
      get_uint32(&reader, &orientation);
 
777
 
 
778
      closure->signal.emit((DBusError *)NULL       , orientation       );
 
779
    }
 
780
  catch (DBusException)
 
781
    {
 
782
      if (reply != NULL)
 
783
        {
 
784
          dbus_message_unref(reply);
 
785
        }
 
786
 
 
787
      if (pending != NULL)
 
788
        {
 
789
          dbus_pending_call_unref(pending);
 
790
        }
 
791
 
 
792
      throw;
 
793
    }
 
794
}
 
795
 
 
796
 
 
797
 
 
798
 
 
799
 
 
800
 
 
801
void org_workrave_GnomeAppletInterface_Impl::SetMenuStatus(  const    std::string     &menu  , bool     &status  )
 
802
{
 
803
 
 
804
  DBusMessage *message = NULL;
 
805
  DBusMessage *reply = NULL;
 
806
  DBusPendingCall *pending = NULL;
 
807
 
 
808
  DBusMessageIter reader;
 
809
  DBusMessageIter writer;
 
810
  dbus_bool_t ok;
 
811
 
 
812
 
 
813
  try
 
814
    {
 
815
      message = dbus_message_new_method_call(service.c_str(),
 
816
                                             path.c_str(),
 
817
                                             "org.workrave.GnomeAppletInterface",  "SetMenuStatus");
 
818
 
 
819
      dbus_message_iter_init_append(message, &writer);
 
820
 
 
821
      put_string(&writer, &menu);
 
822
      put_bool(&writer, &status);
 
823
 
 
824
      if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
 
825
        {
 
826
          throw DBusSystemException("Cannot send");
 
827
        }
 
828
 
 
829
      if (NULL == pending)
 
830
        {
 
831
          throw DBusSystemException("No pending reply");
 
832
        }
 
833
 
 
834
      dbus_connection_flush(dbus->conn());
 
835
 
 
836
      // free message
 
837
      dbus_message_unref(message);
 
838
      message = NULL;
 
839
 
 
840
      // block until we receive a reply
 
841
      dbus_pending_call_block(pending);
 
842
 
 
843
      // get the reply message
 
844
      reply = dbus_pending_call_steal_reply(pending);
 
845
      if (NULL == reply)
 
846
        {
 
847
          throw DBusSystemException("No reply");
 
848
        }
 
849
 
 
850
      // free the pending message handle
 
851
      dbus_pending_call_unref(pending);
 
852
      pending = NULL;
 
853
 
 
854
      ok = dbus_message_iter_init(reply, &reader);
 
855
      if (!ok)
 
856
        {
 
857
          throw DBusSystemException("No parameters");
 
858
        }
 
859
 
 
860
 
 
861
    }
 
862
  catch (DBusException)
 
863
    {
 
864
      if (reply != NULL)
 
865
        {
 
866
          dbus_message_unref(reply);
 
867
        }
 
868
 
 
869
      if (message != NULL)
 
870
        {
 
871
          dbus_message_unref(message);
 
872
        }
 
873
 
 
874
      if (pending != NULL)
 
875
        {
 
876
          dbus_pending_call_unref(pending);
 
877
        }
 
878
 
 
879
      throw;
 
880
    }
 
881
 
 
882
 
 
883
}
 
884
 
 
885
 
 
886
void org_workrave_GnomeAppletInterface_Impl::SetMenuStatus_async(      const      std::string     &menu    , bool     &status  , SetMenuStatus_slot slot
 
887
  )
 
888
{
 
889
 
 
890
  DBusMessage *message = NULL;
 
891
  DBusPendingCall *pending = NULL;
 
892
 
 
893
  DBusMessageIter writer;
 
894
 
 
895
  try
 
896
    {
 
897
      message = dbus_message_new_method_call(service.c_str(),
 
898
                                             path.c_str(),
 
899
                                             "org.workrave.GnomeAppletInterface",  "SetMenuStatus");
 
900
 
 
901
      dbus_message_iter_init(message, &writer);
 
902
 
 
903
      put_string(&writer, &menu);
 
904
      put_bool(&writer, &status);
 
905
 
 
906
      if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
 
907
        {
 
908
          throw DBusSystemException("Cannot send");
 
909
        }
 
910
 
 
911
      if (NULL == pending)
 
912
        {
 
913
          throw DBusSystemException("No pending reply");
 
914
        }
 
915
 
 
916
      SetMenuStatus_async_closure *closure = new SetMenuStatus_async_closure;
 
917
      closure->impl = this;
 
918
      closure->signal.connect(slot);
 
919
 
 
920
      if (!dbus_pending_call_set_notify(pending,
 
921
                                        org_workrave_GnomeAppletInterface_Impl::SetMenuStatus_fcn_static,
 
922
                                        closure, SetMenuStatus_async_closure_free))
 
923
        {
 
924
          throw DBusSystemException("Cannot set notifier");
 
925
        }
 
926
 
 
927
      // free message
 
928
      dbus_message_unref(message);
 
929
      message = NULL;
 
930
    }
 
931
  catch (DBusException)
 
932
    {
 
933
      if (message != NULL)
 
934
        {
 
935
          dbus_message_unref(message);
 
936
        }
 
937
 
 
938
      if (pending != NULL)
 
939
        {
 
940
          dbus_pending_call_unref(pending);
 
941
        }
 
942
 
 
943
      throw;
 
944
    }
 
945
 
 
946
}
 
947
 
 
948
void org_workrave_GnomeAppletInterface_Impl::SetMenuStatus_fcn_static(DBusPendingCall *pending, void *user_data)
 
949
{
 
950
  SetMenuStatus_async_closure *closure = (SetMenuStatus_async_closure *)user_data;
 
951
 
 
952
  closure->impl->SetMenuStatus_fcn(pending, user_data);
 
953
}
 
954
 
 
955
void org_workrave_GnomeAppletInterface_Impl::SetMenuStatus_fcn(DBusPendingCall *pending, void *user_data)
 
956
{
 
957
  SetMenuStatus_async_closure *closure = (SetMenuStatus_async_closure *)user_data;
 
958
        DBusMessage *reply = NULL;
 
959
  DBusMessageIter reader;
 
960
        DBusError error;
 
961
  dbus_bool_t ok;
 
962
 
 
963
 
 
964
        dbus_error_init(&error);
 
965
 
 
966
  try
 
967
    {
 
968
      reply = dbus_pending_call_steal_reply(pending);
 
969
      if (reply == NULL)
 
970
        {
 
971
          throw DBusSystemException("Cannot get reply");
 
972
        }
 
973
 
 
974
      ok = dbus_message_iter_init(reply, &reader);
 
975
 
 
976
 
 
977
      closure->signal.emit((DBusError *)NULL       );
 
978
    }
 
979
  catch (DBusException)
 
980
    {
 
981
      if (reply != NULL)
 
982
        {
 
983
          dbus_message_unref(reply);
 
984
        }
 
985
 
 
986
      if (pending != NULL)
 
987
        {
 
988
          dbus_pending_call_unref(pending);
 
989
        }
 
990
 
 
991
      throw;
 
992
    }
 
993
}
 
994
 
 
995
 
 
996
 
 
997
 
 
998
 
 
999
 
 
1000
void org_workrave_GnomeAppletInterface_Impl::GetMenuStatus(  const    std::string     &menu  , bool      &status  )
 
1001
{
 
1002
 
 
1003
  DBusMessage *message = NULL;
 
1004
  DBusMessage *reply = NULL;
 
1005
  DBusPendingCall *pending = NULL;
 
1006
 
 
1007
  DBusMessageIter reader;
 
1008
  DBusMessageIter writer;
 
1009
  dbus_bool_t ok;
 
1010
 
 
1011
 
 
1012
  try
 
1013
    {
 
1014
      message = dbus_message_new_method_call(service.c_str(),
 
1015
                                             path.c_str(),
 
1016
                                             "org.workrave.GnomeAppletInterface",  "GetMenuStatus");
 
1017
 
 
1018
      dbus_message_iter_init_append(message, &writer);
 
1019
 
 
1020
      put_string(&writer, &menu);
 
1021
 
 
1022
      if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
 
1023
        {
 
1024
          throw DBusSystemException("Cannot send");
 
1025
        }
 
1026
 
 
1027
      if (NULL == pending)
 
1028
        {
 
1029
          throw DBusSystemException("No pending reply");
 
1030
        }
 
1031
 
 
1032
      dbus_connection_flush(dbus->conn());
 
1033
 
 
1034
      // free message
 
1035
      dbus_message_unref(message);
 
1036
      message = NULL;
 
1037
 
 
1038
      // block until we receive a reply
 
1039
      dbus_pending_call_block(pending);
 
1040
 
 
1041
      // get the reply message
 
1042
      reply = dbus_pending_call_steal_reply(pending);
 
1043
      if (NULL == reply)
 
1044
        {
 
1045
          throw DBusSystemException("No reply");
 
1046
        }
 
1047
 
 
1048
      // free the pending message handle
 
1049
      dbus_pending_call_unref(pending);
 
1050
      pending = NULL;
 
1051
 
 
1052
      ok = dbus_message_iter_init(reply, &reader);
 
1053
      if (!ok)
 
1054
        {
 
1055
          throw DBusSystemException("No parameters");
 
1056
        }
 
1057
 
 
1058
      get_bool(&reader, &status);
 
1059
 
 
1060
    }
 
1061
  catch (DBusException)
 
1062
    {
 
1063
      if (reply != NULL)
 
1064
        {
 
1065
          dbus_message_unref(reply);
 
1066
        }
 
1067
 
 
1068
      if (message != NULL)
 
1069
        {
 
1070
          dbus_message_unref(message);
 
1071
        }
 
1072
 
 
1073
      if (pending != NULL)
 
1074
        {
 
1075
          dbus_pending_call_unref(pending);
 
1076
        }
 
1077
 
 
1078
      throw;
 
1079
    }
 
1080
 
 
1081
 
 
1082
}
 
1083
 
 
1084
 
 
1085
void org_workrave_GnomeAppletInterface_Impl::GetMenuStatus_async(      const      std::string     &menu  , GetMenuStatus_slot slot
 
1086
  )
 
1087
{
 
1088
 
 
1089
  DBusMessage *message = NULL;
 
1090
  DBusPendingCall *pending = NULL;
 
1091
 
 
1092
  DBusMessageIter writer;
 
1093
 
 
1094
  try
 
1095
    {
 
1096
      message = dbus_message_new_method_call(service.c_str(),
 
1097
                                             path.c_str(),
 
1098
                                             "org.workrave.GnomeAppletInterface",  "GetMenuStatus");
 
1099
 
 
1100
      dbus_message_iter_init(message, &writer);
 
1101
 
 
1102
      put_string(&writer, &menu);
 
1103
 
 
1104
      if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
 
1105
        {
 
1106
          throw DBusSystemException("Cannot send");
 
1107
        }
 
1108
 
 
1109
      if (NULL == pending)
 
1110
        {
 
1111
          throw DBusSystemException("No pending reply");
 
1112
        }
 
1113
 
 
1114
      GetMenuStatus_async_closure *closure = new GetMenuStatus_async_closure;
 
1115
      closure->impl = this;
 
1116
      closure->signal.connect(slot);
 
1117
 
 
1118
      if (!dbus_pending_call_set_notify(pending,
 
1119
                                        org_workrave_GnomeAppletInterface_Impl::GetMenuStatus_fcn_static,
 
1120
                                        closure, GetMenuStatus_async_closure_free))
 
1121
        {
 
1122
          throw DBusSystemException("Cannot set notifier");
 
1123
        }
 
1124
 
 
1125
      // free message
 
1126
      dbus_message_unref(message);
 
1127
      message = NULL;
 
1128
    }
 
1129
  catch (DBusException)
 
1130
    {
 
1131
      if (message != NULL)
 
1132
        {
 
1133
          dbus_message_unref(message);
 
1134
        }
 
1135
 
 
1136
      if (pending != NULL)
 
1137
        {
 
1138
          dbus_pending_call_unref(pending);
 
1139
        }
 
1140
 
 
1141
      throw;
 
1142
    }
 
1143
 
 
1144
}
 
1145
 
 
1146
void org_workrave_GnomeAppletInterface_Impl::GetMenuStatus_fcn_static(DBusPendingCall *pending, void *user_data)
 
1147
{
 
1148
  GetMenuStatus_async_closure *closure = (GetMenuStatus_async_closure *)user_data;
 
1149
 
 
1150
  closure->impl->GetMenuStatus_fcn(pending, user_data);
 
1151
}
 
1152
 
 
1153
void org_workrave_GnomeAppletInterface_Impl::GetMenuStatus_fcn(DBusPendingCall *pending, void *user_data)
 
1154
{
 
1155
  GetMenuStatus_async_closure *closure = (GetMenuStatus_async_closure *)user_data;
 
1156
        DBusMessage *reply = NULL;
 
1157
  DBusMessageIter reader;
 
1158
        DBusError error;
 
1159
  dbus_bool_t ok;
 
1160
 
 
1161
      bool status;
 
1162
 
 
1163
        dbus_error_init(&error);
 
1164
 
 
1165
  try
 
1166
    {
 
1167
      reply = dbus_pending_call_steal_reply(pending);
 
1168
      if (reply == NULL)
 
1169
        {
 
1170
          throw DBusSystemException("Cannot get reply");
 
1171
        }
 
1172
 
 
1173
      ok = dbus_message_iter_init(reply, &reader);
 
1174
      if (!ok)
 
1175
        {
 
1176
          throw DBusSystemException("No parameters");
 
1177
        }
 
1178
 
 
1179
      get_bool(&reader, &status);
 
1180
 
 
1181
      closure->signal.emit((DBusError *)NULL       , status       );
 
1182
    }
 
1183
  catch (DBusException)
 
1184
    {
 
1185
      if (reply != NULL)
 
1186
        {
 
1187
          dbus_message_unref(reply);
 
1188
        }
 
1189
 
 
1190
      if (pending != NULL)
 
1191
        {
 
1192
          dbus_pending_call_unref(pending);
 
1193
        }
 
1194
 
 
1195
      throw;
 
1196
    }
 
1197
}
 
1198
 
 
1199
 
 
1200
 
 
1201
 
 
1202
 
 
1203
 
 
1204
void org_workrave_GnomeAppletInterface_Impl::SetMenuActive(  const    std::string     &menu  , bool     &active  )
 
1205
{
 
1206
 
 
1207
  DBusMessage *message = NULL;
 
1208
  DBusMessage *reply = NULL;
 
1209
  DBusPendingCall *pending = NULL;
 
1210
 
 
1211
  DBusMessageIter reader;
 
1212
  DBusMessageIter writer;
 
1213
  dbus_bool_t ok;
 
1214
 
 
1215
 
 
1216
  try
 
1217
    {
 
1218
      message = dbus_message_new_method_call(service.c_str(),
 
1219
                                             path.c_str(),
 
1220
                                             "org.workrave.GnomeAppletInterface",  "SetMenuActive");
 
1221
 
 
1222
      dbus_message_iter_init_append(message, &writer);
 
1223
 
 
1224
      put_string(&writer, &menu);
 
1225
      put_bool(&writer, &active);
 
1226
 
 
1227
      if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
 
1228
        {
 
1229
          throw DBusSystemException("Cannot send");
 
1230
        }
 
1231
 
 
1232
      if (NULL == pending)
 
1233
        {
 
1234
          throw DBusSystemException("No pending reply");
 
1235
        }
 
1236
 
 
1237
      dbus_connection_flush(dbus->conn());
 
1238
 
 
1239
      // free message
 
1240
      dbus_message_unref(message);
 
1241
      message = NULL;
 
1242
 
 
1243
      // block until we receive a reply
 
1244
      dbus_pending_call_block(pending);
 
1245
 
 
1246
      // get the reply message
 
1247
      reply = dbus_pending_call_steal_reply(pending);
 
1248
      if (NULL == reply)
 
1249
        {
 
1250
          throw DBusSystemException("No reply");
 
1251
        }
 
1252
 
 
1253
      // free the pending message handle
 
1254
      dbus_pending_call_unref(pending);
 
1255
      pending = NULL;
 
1256
 
 
1257
      ok = dbus_message_iter_init(reply, &reader);
 
1258
      if (!ok)
 
1259
        {
 
1260
          throw DBusSystemException("No parameters");
 
1261
        }
 
1262
 
 
1263
 
 
1264
    }
 
1265
  catch (DBusException)
 
1266
    {
 
1267
      if (reply != NULL)
 
1268
        {
 
1269
          dbus_message_unref(reply);
 
1270
        }
 
1271
 
 
1272
      if (message != NULL)
 
1273
        {
 
1274
          dbus_message_unref(message);
 
1275
        }
 
1276
 
 
1277
      if (pending != NULL)
 
1278
        {
 
1279
          dbus_pending_call_unref(pending);
 
1280
        }
 
1281
 
 
1282
      throw;
 
1283
    }
 
1284
 
 
1285
 
 
1286
}
 
1287
 
 
1288
 
 
1289
void org_workrave_GnomeAppletInterface_Impl::SetMenuActive_async(      const      std::string     &menu    , bool     &active  , SetMenuActive_slot slot
 
1290
  )
 
1291
{
 
1292
 
 
1293
  DBusMessage *message = NULL;
 
1294
  DBusPendingCall *pending = NULL;
 
1295
 
 
1296
  DBusMessageIter writer;
 
1297
 
 
1298
  try
 
1299
    {
 
1300
      message = dbus_message_new_method_call(service.c_str(),
 
1301
                                             path.c_str(),
 
1302
                                             "org.workrave.GnomeAppletInterface",  "SetMenuActive");
 
1303
 
 
1304
      dbus_message_iter_init(message, &writer);
 
1305
 
 
1306
      put_string(&writer, &menu);
 
1307
      put_bool(&writer, &active);
 
1308
 
 
1309
      if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
 
1310
        {
 
1311
          throw DBusSystemException("Cannot send");
 
1312
        }
 
1313
 
 
1314
      if (NULL == pending)
 
1315
        {
 
1316
          throw DBusSystemException("No pending reply");
 
1317
        }
 
1318
 
 
1319
      SetMenuActive_async_closure *closure = new SetMenuActive_async_closure;
 
1320
      closure->impl = this;
 
1321
      closure->signal.connect(slot);
 
1322
 
 
1323
      if (!dbus_pending_call_set_notify(pending,
 
1324
                                        org_workrave_GnomeAppletInterface_Impl::SetMenuActive_fcn_static,
 
1325
                                        closure, SetMenuActive_async_closure_free))
 
1326
        {
 
1327
          throw DBusSystemException("Cannot set notifier");
 
1328
        }
 
1329
 
 
1330
      // free message
 
1331
      dbus_message_unref(message);
 
1332
      message = NULL;
 
1333
    }
 
1334
  catch (DBusException)
 
1335
    {
 
1336
      if (message != NULL)
 
1337
        {
 
1338
          dbus_message_unref(message);
 
1339
        }
 
1340
 
 
1341
      if (pending != NULL)
 
1342
        {
 
1343
          dbus_pending_call_unref(pending);
 
1344
        }
 
1345
 
 
1346
      throw;
 
1347
    }
 
1348
 
 
1349
}
 
1350
 
 
1351
void org_workrave_GnomeAppletInterface_Impl::SetMenuActive_fcn_static(DBusPendingCall *pending, void *user_data)
 
1352
{
 
1353
  SetMenuActive_async_closure *closure = (SetMenuActive_async_closure *)user_data;
 
1354
 
 
1355
  closure->impl->SetMenuActive_fcn(pending, user_data);
 
1356
}
 
1357
 
 
1358
void org_workrave_GnomeAppletInterface_Impl::SetMenuActive_fcn(DBusPendingCall *pending, void *user_data)
 
1359
{
 
1360
  SetMenuActive_async_closure *closure = (SetMenuActive_async_closure *)user_data;
 
1361
        DBusMessage *reply = NULL;
 
1362
  DBusMessageIter reader;
 
1363
        DBusError error;
 
1364
  dbus_bool_t ok;
 
1365
 
 
1366
 
 
1367
        dbus_error_init(&error);
 
1368
 
 
1369
  try
 
1370
    {
 
1371
      reply = dbus_pending_call_steal_reply(pending);
 
1372
      if (reply == NULL)
 
1373
        {
 
1374
          throw DBusSystemException("Cannot get reply");
 
1375
        }
 
1376
 
 
1377
      ok = dbus_message_iter_init(reply, &reader);
 
1378
 
 
1379
 
 
1380
      closure->signal.emit((DBusError *)NULL       );
 
1381
    }
 
1382
  catch (DBusException)
 
1383
    {
 
1384
      if (reply != NULL)
 
1385
        {
 
1386
          dbus_message_unref(reply);
 
1387
        }
 
1388
 
 
1389
      if (pending != NULL)
 
1390
        {
 
1391
          dbus_pending_call_unref(pending);
 
1392
        }
 
1393
 
 
1394
      throw;
 
1395
    }
 
1396
}
 
1397
 
 
1398
 
 
1399
 
 
1400
 
 
1401
 
 
1402
 
 
1403
void org_workrave_GnomeAppletInterface_Impl::GetMenuActive(  const    std::string     &menu  , bool      &active  )
 
1404
{
 
1405
 
 
1406
  DBusMessage *message = NULL;
 
1407
  DBusMessage *reply = NULL;
 
1408
  DBusPendingCall *pending = NULL;
 
1409
 
 
1410
  DBusMessageIter reader;
 
1411
  DBusMessageIter writer;
 
1412
  dbus_bool_t ok;
 
1413
 
 
1414
 
 
1415
  try
 
1416
    {
 
1417
      message = dbus_message_new_method_call(service.c_str(),
 
1418
                                             path.c_str(),
 
1419
                                             "org.workrave.GnomeAppletInterface",  "GetMenuActive");
 
1420
 
 
1421
      dbus_message_iter_init_append(message, &writer);
 
1422
 
 
1423
      put_string(&writer, &menu);
 
1424
 
 
1425
      if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
 
1426
        {
 
1427
          throw DBusSystemException("Cannot send");
 
1428
        }
 
1429
 
 
1430
      if (NULL == pending)
 
1431
        {
 
1432
          throw DBusSystemException("No pending reply");
 
1433
        }
 
1434
 
 
1435
      dbus_connection_flush(dbus->conn());
 
1436
 
 
1437
      // free message
 
1438
      dbus_message_unref(message);
 
1439
      message = NULL;
 
1440
 
 
1441
      // block until we receive a reply
 
1442
      dbus_pending_call_block(pending);
 
1443
 
 
1444
      // get the reply message
 
1445
      reply = dbus_pending_call_steal_reply(pending);
 
1446
      if (NULL == reply)
 
1447
        {
 
1448
          throw DBusSystemException("No reply");
 
1449
        }
 
1450
 
 
1451
      // free the pending message handle
 
1452
      dbus_pending_call_unref(pending);
 
1453
      pending = NULL;
 
1454
 
 
1455
      ok = dbus_message_iter_init(reply, &reader);
 
1456
      if (!ok)
 
1457
        {
 
1458
          throw DBusSystemException("No parameters");
 
1459
        }
 
1460
 
 
1461
      get_bool(&reader, &active);
 
1462
 
 
1463
    }
 
1464
  catch (DBusException)
 
1465
    {
 
1466
      if (reply != NULL)
 
1467
        {
 
1468
          dbus_message_unref(reply);
 
1469
        }
 
1470
 
 
1471
      if (message != NULL)
 
1472
        {
 
1473
          dbus_message_unref(message);
 
1474
        }
 
1475
 
 
1476
      if (pending != NULL)
 
1477
        {
 
1478
          dbus_pending_call_unref(pending);
 
1479
        }
 
1480
 
 
1481
      throw;
 
1482
    }
 
1483
 
 
1484
 
 
1485
}
 
1486
 
 
1487
 
 
1488
void org_workrave_GnomeAppletInterface_Impl::GetMenuActive_async(      const      std::string     &menu  , GetMenuActive_slot slot
 
1489
  )
 
1490
{
 
1491
 
 
1492
  DBusMessage *message = NULL;
 
1493
  DBusPendingCall *pending = NULL;
 
1494
 
 
1495
  DBusMessageIter writer;
 
1496
 
 
1497
  try
 
1498
    {
 
1499
      message = dbus_message_new_method_call(service.c_str(),
 
1500
                                             path.c_str(),
 
1501
                                             "org.workrave.GnomeAppletInterface",  "GetMenuActive");
 
1502
 
 
1503
      dbus_message_iter_init(message, &writer);
 
1504
 
 
1505
      put_string(&writer, &menu);
 
1506
 
 
1507
      if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
 
1508
        {
 
1509
          throw DBusSystemException("Cannot send");
 
1510
        }
 
1511
 
 
1512
      if (NULL == pending)
 
1513
        {
 
1514
          throw DBusSystemException("No pending reply");
 
1515
        }
 
1516
 
 
1517
      GetMenuActive_async_closure *closure = new GetMenuActive_async_closure;
 
1518
      closure->impl = this;
 
1519
      closure->signal.connect(slot);
 
1520
 
 
1521
      if (!dbus_pending_call_set_notify(pending,
 
1522
                                        org_workrave_GnomeAppletInterface_Impl::GetMenuActive_fcn_static,
 
1523
                                        closure, GetMenuActive_async_closure_free))
 
1524
        {
 
1525
          throw DBusSystemException("Cannot set notifier");
 
1526
        }
 
1527
 
 
1528
      // free message
 
1529
      dbus_message_unref(message);
 
1530
      message = NULL;
 
1531
    }
 
1532
  catch (DBusException)
 
1533
    {
 
1534
      if (message != NULL)
 
1535
        {
 
1536
          dbus_message_unref(message);
 
1537
        }
 
1538
 
 
1539
      if (pending != NULL)
 
1540
        {
 
1541
          dbus_pending_call_unref(pending);
 
1542
        }
 
1543
 
 
1544
      throw;
 
1545
    }
 
1546
 
 
1547
}
 
1548
 
 
1549
void org_workrave_GnomeAppletInterface_Impl::GetMenuActive_fcn_static(DBusPendingCall *pending, void *user_data)
 
1550
{
 
1551
  GetMenuActive_async_closure *closure = (GetMenuActive_async_closure *)user_data;
 
1552
 
 
1553
  closure->impl->GetMenuActive_fcn(pending, user_data);
 
1554
}
 
1555
 
 
1556
void org_workrave_GnomeAppletInterface_Impl::GetMenuActive_fcn(DBusPendingCall *pending, void *user_data)
 
1557
{
 
1558
  GetMenuActive_async_closure *closure = (GetMenuActive_async_closure *)user_data;
 
1559
        DBusMessage *reply = NULL;
 
1560
  DBusMessageIter reader;
 
1561
        DBusError error;
 
1562
  dbus_bool_t ok;
 
1563
 
 
1564
      bool active;
 
1565
 
 
1566
        dbus_error_init(&error);
 
1567
 
 
1568
  try
 
1569
    {
 
1570
      reply = dbus_pending_call_steal_reply(pending);
 
1571
      if (reply == NULL)
 
1572
        {
 
1573
          throw DBusSystemException("Cannot get reply");
 
1574
        }
 
1575
 
 
1576
      ok = dbus_message_iter_init(reply, &reader);
 
1577
      if (!ok)
 
1578
        {
 
1579
          throw DBusSystemException("No parameters");
 
1580
        }
 
1581
 
 
1582
      get_bool(&reader, &active);
 
1583
 
 
1584
      closure->signal.emit((DBusError *)NULL       , active       );
 
1585
    }
 
1586
  catch (DBusException)
 
1587
    {
 
1588
      if (reply != NULL)
 
1589
        {
 
1590
          dbus_message_unref(reply);
 
1591
        }
 
1592
 
 
1593
      if (pending != NULL)
 
1594
        {
 
1595
          dbus_pending_call_unref(pending);
 
1596
        }
 
1597
 
 
1598
      throw;
 
1599
    }
 
1600
}
 
1601
 
 
1602
 
 
1603
 
 
1604
 
 
1605
 
 
1606
 
 
1607
 
 
1608