1
// DBus-client-template.hh --- DBUS template
3
// Copyright (C) 2007, 2008 Rob Caelers <robc@krandor.nl>
4
// All rights reserved.
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.
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.
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/>.
29
#include "DBusBinding.hh"
30
#include "DBusException.hh"
31
#include "DBusGnomeApplet.hh"
34
using namespace workrave;
40
class org_workrave_GnomeAppletInterface_Impl : public org_workrave_GnomeAppletInterface, public DBusBaseTypes
43
org_workrave_GnomeAppletInterface_Impl(DBus *dbus, const string &service, const string &path);
45
guint32 GetSocketId( /**/ );
46
void GetSocketId_async( GetSocketId_slot slot );
49
guint32 GetSize( /**/ );
50
void GetSize_async( GetSize_slot slot );
53
guint32 GetOrientation( /**/ );
54
void GetOrientation_async( GetOrientation_slot slot );
57
void SetMenuStatus( const std::string &menu , bool &status );
58
void SetMenuStatus_async( const std::string &menu , bool &status , SetMenuStatus_slot slot );
61
void GetMenuStatus( const std::string &menu , bool &status );
62
void GetMenuStatus_async( const std::string &menu , GetMenuStatus_slot slot );
65
void SetMenuActive( const std::string &menu , bool &active );
66
void SetMenuActive_async( const std::string &menu , bool &active , SetMenuActive_slot slot );
69
void GetMenuActive( const std::string &menu , bool &active );
70
void GetMenuActive_async( const std::string &menu , GetMenuActive_slot slot );
75
typedef sigc::signal<void, DBusError * , guint32 > GetSocketId_signal;
76
struct GetSocketId_async_closure
78
class org_workrave_GnomeAppletInterface_Impl *impl;
79
GetSocketId_signal signal;
81
static void GetSocketId_async_closure_free(void *mem)
83
delete (GetSocketId_async_closure *)mem;
86
static void GetSocketId_fcn_static(DBusPendingCall *pending, void *user_data);
87
void GetSocketId_fcn(DBusPendingCall *pending, void *user_data);
89
typedef sigc::signal<void, DBusError * , guint32 > GetSize_signal;
90
struct GetSize_async_closure
92
class org_workrave_GnomeAppletInterface_Impl *impl;
93
GetSize_signal signal;
95
static void GetSize_async_closure_free(void *mem)
97
delete (GetSize_async_closure *)mem;
100
static void GetSize_fcn_static(DBusPendingCall *pending, void *user_data);
101
void GetSize_fcn(DBusPendingCall *pending, void *user_data);
103
typedef sigc::signal<void, DBusError * , guint32 > GetOrientation_signal;
104
struct GetOrientation_async_closure
106
class org_workrave_GnomeAppletInterface_Impl *impl;
107
GetOrientation_signal signal;
109
static void GetOrientation_async_closure_free(void *mem)
111
delete (GetOrientation_async_closure *)mem;
114
static void GetOrientation_fcn_static(DBusPendingCall *pending, void *user_data);
115
void GetOrientation_fcn(DBusPendingCall *pending, void *user_data);
117
typedef sigc::signal<void, DBusError * > SetMenuStatus_signal;
118
struct SetMenuStatus_async_closure
120
class org_workrave_GnomeAppletInterface_Impl *impl;
121
SetMenuStatus_signal signal;
123
static void SetMenuStatus_async_closure_free(void *mem)
125
delete (SetMenuStatus_async_closure *)mem;
128
static void SetMenuStatus_fcn_static(DBusPendingCall *pending, void *user_data);
129
void SetMenuStatus_fcn(DBusPendingCall *pending, void *user_data);
131
typedef sigc::signal<void, DBusError * , bool & > GetMenuStatus_signal;
132
struct GetMenuStatus_async_closure
134
class org_workrave_GnomeAppletInterface_Impl *impl;
135
GetMenuStatus_signal signal;
137
static void GetMenuStatus_async_closure_free(void *mem)
139
delete (GetMenuStatus_async_closure *)mem;
142
static void GetMenuStatus_fcn_static(DBusPendingCall *pending, void *user_data);
143
void GetMenuStatus_fcn(DBusPendingCall *pending, void *user_data);
145
typedef sigc::signal<void, DBusError * > SetMenuActive_signal;
146
struct SetMenuActive_async_closure
148
class org_workrave_GnomeAppletInterface_Impl *impl;
149
SetMenuActive_signal signal;
151
static void SetMenuActive_async_closure_free(void *mem)
153
delete (SetMenuActive_async_closure *)mem;
156
static void SetMenuActive_fcn_static(DBusPendingCall *pending, void *user_data);
157
void SetMenuActive_fcn(DBusPendingCall *pending, void *user_data);
159
typedef sigc::signal<void, DBusError * , bool & > GetMenuActive_signal;
160
struct GetMenuActive_async_closure
162
class org_workrave_GnomeAppletInterface_Impl *impl;
163
GetMenuActive_signal signal;
165
static void GetMenuActive_async_closure_free(void *mem)
167
delete (GetMenuActive_async_closure *)mem;
170
static void GetMenuActive_fcn_static(DBusPendingCall *pending, void *user_data);
171
void GetMenuActive_fcn(DBusPendingCall *pending, void *user_data);
184
org_workrave_GnomeAppletInterface_Impl::org_workrave_GnomeAppletInterface_Impl(DBus *dbus, const string &service, const string &path)
185
: dbus(dbus), service(service), path(path)
189
org_workrave_GnomeAppletInterface *org_workrave_GnomeAppletInterface::instance(DBus *dbus, const string &service, const string &path)
191
return new org_workrave_GnomeAppletInterface_Impl(dbus, service, path);
201
guint32 org_workrave_GnomeAppletInterface_Impl::GetSocketId( /**/ )
204
DBusMessage *message = NULL;
205
DBusMessage *reply = NULL;
206
DBusPendingCall *pending = NULL;
208
DBusMessageIter reader;
209
DBusMessageIter writer;
216
message = dbus_message_new_method_call(service.c_str(),
218
"org.workrave.GnomeAppletInterface", "GetSocketId");
220
dbus_message_iter_init_append(message, &writer);
223
if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
225
throw DBusSystemException("Cannot send");
230
throw DBusSystemException("No pending reply");
233
dbus_connection_flush(dbus->conn());
236
dbus_message_unref(message);
239
// block until we receive a reply
240
dbus_pending_call_block(pending);
242
// get the reply message
243
reply = dbus_pending_call_steal_reply(pending);
246
throw DBusSystemException("No reply");
249
// free the pending message handle
250
dbus_pending_call_unref(pending);
253
ok = dbus_message_iter_init(reply, &reader);
255
get_uint32(&reader, &id);
258
catch (DBusException)
262
dbus_message_unref(reply);
267
dbus_message_unref(message);
272
dbus_pending_call_unref(pending);
283
void org_workrave_GnomeAppletInterface_Impl::GetSocketId_async( GetSocketId_slot slot
287
DBusMessage *message = NULL;
288
DBusPendingCall *pending = NULL;
290
DBusMessageIter writer;
294
message = dbus_message_new_method_call(service.c_str(),
296
"org.workrave.GnomeAppletInterface", "GetSocketId");
298
dbus_message_iter_init(message, &writer);
301
if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
303
throw DBusSystemException("Cannot send");
308
throw DBusSystemException("No pending reply");
311
GetSocketId_async_closure *closure = new GetSocketId_async_closure;
312
closure->impl = this;
313
closure->signal.connect(slot);
315
if (!dbus_pending_call_set_notify(pending,
316
org_workrave_GnomeAppletInterface_Impl::GetSocketId_fcn_static,
317
closure, GetSocketId_async_closure_free))
319
throw DBusSystemException("Cannot set notifier");
323
dbus_message_unref(message);
326
catch (DBusException)
330
dbus_message_unref(message);
335
dbus_pending_call_unref(pending);
343
void org_workrave_GnomeAppletInterface_Impl::GetSocketId_fcn_static(DBusPendingCall *pending, void *user_data)
345
GetSocketId_async_closure *closure = (GetSocketId_async_closure *)user_data;
347
closure->impl->GetSocketId_fcn(pending, user_data);
350
void org_workrave_GnomeAppletInterface_Impl::GetSocketId_fcn(DBusPendingCall *pending, void *user_data)
352
GetSocketId_async_closure *closure = (GetSocketId_async_closure *)user_data;
353
DBusMessage *reply = NULL;
354
DBusMessageIter reader;
360
dbus_error_init(&error);
364
reply = dbus_pending_call_steal_reply(pending);
367
throw DBusSystemException("Cannot get reply");
370
ok = dbus_message_iter_init(reply, &reader);
373
throw DBusSystemException("No parameters");
376
get_uint32(&reader, &id);
378
closure->signal.emit((DBusError *)NULL , id );
380
catch (DBusException)
384
dbus_message_unref(reply);
389
dbus_pending_call_unref(pending);
401
guint32 org_workrave_GnomeAppletInterface_Impl::GetSize( /**/ )
404
DBusMessage *message = NULL;
405
DBusMessage *reply = NULL;
406
DBusPendingCall *pending = NULL;
408
DBusMessageIter reader;
409
DBusMessageIter writer;
416
message = dbus_message_new_method_call(service.c_str(),
418
"org.workrave.GnomeAppletInterface", "GetSize");
420
dbus_message_iter_init_append(message, &writer);
423
if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
425
throw DBusSystemException("Cannot send");
430
throw DBusSystemException("No pending reply");
433
dbus_connection_flush(dbus->conn());
436
dbus_message_unref(message);
439
// block until we receive a reply
440
dbus_pending_call_block(pending);
442
// get the reply message
443
reply = dbus_pending_call_steal_reply(pending);
446
throw DBusSystemException("No reply");
449
// free the pending message handle
450
dbus_pending_call_unref(pending);
453
ok = dbus_message_iter_init(reply, &reader);
455
get_uint32(&reader, &size);
458
catch (DBusException)
462
dbus_message_unref(reply);
467
dbus_message_unref(message);
472
dbus_pending_call_unref(pending);
483
void org_workrave_GnomeAppletInterface_Impl::GetSize_async( GetSize_slot slot
487
DBusMessage *message = NULL;
488
DBusPendingCall *pending = NULL;
490
DBusMessageIter writer;
494
message = dbus_message_new_method_call(service.c_str(),
496
"org.workrave.GnomeAppletInterface", "GetSize");
498
dbus_message_iter_init(message, &writer);
501
if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
503
throw DBusSystemException("Cannot send");
508
throw DBusSystemException("No pending reply");
511
GetSize_async_closure *closure = new GetSize_async_closure;
512
closure->impl = this;
513
closure->signal.connect(slot);
515
if (!dbus_pending_call_set_notify(pending,
516
org_workrave_GnomeAppletInterface_Impl::GetSize_fcn_static,
517
closure, GetSize_async_closure_free))
519
throw DBusSystemException("Cannot set notifier");
523
dbus_message_unref(message);
526
catch (DBusException)
530
dbus_message_unref(message);
535
dbus_pending_call_unref(pending);
543
void org_workrave_GnomeAppletInterface_Impl::GetSize_fcn_static(DBusPendingCall *pending, void *user_data)
545
GetSize_async_closure *closure = (GetSize_async_closure *)user_data;
547
closure->impl->GetSize_fcn(pending, user_data);
550
void org_workrave_GnomeAppletInterface_Impl::GetSize_fcn(DBusPendingCall *pending, void *user_data)
552
GetSize_async_closure *closure = (GetSize_async_closure *)user_data;
553
DBusMessage *reply = NULL;
554
DBusMessageIter reader;
560
dbus_error_init(&error);
564
reply = dbus_pending_call_steal_reply(pending);
567
throw DBusSystemException("Cannot get reply");
570
ok = dbus_message_iter_init(reply, &reader);
573
throw DBusSystemException("No parameters");
576
get_uint32(&reader, &size);
578
closure->signal.emit((DBusError *)NULL , size );
580
catch (DBusException)
584
dbus_message_unref(reply);
589
dbus_pending_call_unref(pending);
601
guint32 org_workrave_GnomeAppletInterface_Impl::GetOrientation( /**/ )
604
DBusMessage *message = NULL;
605
DBusMessage *reply = NULL;
606
DBusPendingCall *pending = NULL;
608
DBusMessageIter reader;
609
DBusMessageIter writer;
616
message = dbus_message_new_method_call(service.c_str(),
618
"org.workrave.GnomeAppletInterface", "GetOrientation");
620
dbus_message_iter_init_append(message, &writer);
623
if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
625
throw DBusSystemException("Cannot send");
630
throw DBusSystemException("No pending reply");
633
dbus_connection_flush(dbus->conn());
636
dbus_message_unref(message);
639
// block until we receive a reply
640
dbus_pending_call_block(pending);
642
// get the reply message
643
reply = dbus_pending_call_steal_reply(pending);
646
throw DBusSystemException("No reply");
649
// free the pending message handle
650
dbus_pending_call_unref(pending);
653
ok = dbus_message_iter_init(reply, &reader);
655
get_uint32(&reader, &orientation);
658
catch (DBusException)
662
dbus_message_unref(reply);
667
dbus_message_unref(message);
672
dbus_pending_call_unref(pending);
683
void org_workrave_GnomeAppletInterface_Impl::GetOrientation_async( GetOrientation_slot slot
687
DBusMessage *message = NULL;
688
DBusPendingCall *pending = NULL;
690
DBusMessageIter writer;
694
message = dbus_message_new_method_call(service.c_str(),
696
"org.workrave.GnomeAppletInterface", "GetOrientation");
698
dbus_message_iter_init(message, &writer);
701
if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
703
throw DBusSystemException("Cannot send");
708
throw DBusSystemException("No pending reply");
711
GetOrientation_async_closure *closure = new GetOrientation_async_closure;
712
closure->impl = this;
713
closure->signal.connect(slot);
715
if (!dbus_pending_call_set_notify(pending,
716
org_workrave_GnomeAppletInterface_Impl::GetOrientation_fcn_static,
717
closure, GetOrientation_async_closure_free))
719
throw DBusSystemException("Cannot set notifier");
723
dbus_message_unref(message);
726
catch (DBusException)
730
dbus_message_unref(message);
735
dbus_pending_call_unref(pending);
743
void org_workrave_GnomeAppletInterface_Impl::GetOrientation_fcn_static(DBusPendingCall *pending, void *user_data)
745
GetOrientation_async_closure *closure = (GetOrientation_async_closure *)user_data;
747
closure->impl->GetOrientation_fcn(pending, user_data);
750
void org_workrave_GnomeAppletInterface_Impl::GetOrientation_fcn(DBusPendingCall *pending, void *user_data)
752
GetOrientation_async_closure *closure = (GetOrientation_async_closure *)user_data;
753
DBusMessage *reply = NULL;
754
DBusMessageIter reader;
760
dbus_error_init(&error);
764
reply = dbus_pending_call_steal_reply(pending);
767
throw DBusSystemException("Cannot get reply");
770
ok = dbus_message_iter_init(reply, &reader);
773
throw DBusSystemException("No parameters");
776
get_uint32(&reader, &orientation);
778
closure->signal.emit((DBusError *)NULL , orientation );
780
catch (DBusException)
784
dbus_message_unref(reply);
789
dbus_pending_call_unref(pending);
801
void org_workrave_GnomeAppletInterface_Impl::SetMenuStatus( const std::string &menu , bool &status )
804
DBusMessage *message = NULL;
805
DBusMessage *reply = NULL;
806
DBusPendingCall *pending = NULL;
808
DBusMessageIter reader;
809
DBusMessageIter writer;
815
message = dbus_message_new_method_call(service.c_str(),
817
"org.workrave.GnomeAppletInterface", "SetMenuStatus");
819
dbus_message_iter_init_append(message, &writer);
821
put_string(&writer, &menu);
822
put_bool(&writer, &status);
824
if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
826
throw DBusSystemException("Cannot send");
831
throw DBusSystemException("No pending reply");
834
dbus_connection_flush(dbus->conn());
837
dbus_message_unref(message);
840
// block until we receive a reply
841
dbus_pending_call_block(pending);
843
// get the reply message
844
reply = dbus_pending_call_steal_reply(pending);
847
throw DBusSystemException("No reply");
850
// free the pending message handle
851
dbus_pending_call_unref(pending);
854
ok = dbus_message_iter_init(reply, &reader);
857
throw DBusSystemException("No parameters");
862
catch (DBusException)
866
dbus_message_unref(reply);
871
dbus_message_unref(message);
876
dbus_pending_call_unref(pending);
886
void org_workrave_GnomeAppletInterface_Impl::SetMenuStatus_async( const std::string &menu , bool &status , SetMenuStatus_slot slot
890
DBusMessage *message = NULL;
891
DBusPendingCall *pending = NULL;
893
DBusMessageIter writer;
897
message = dbus_message_new_method_call(service.c_str(),
899
"org.workrave.GnomeAppletInterface", "SetMenuStatus");
901
dbus_message_iter_init(message, &writer);
903
put_string(&writer, &menu);
904
put_bool(&writer, &status);
906
if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
908
throw DBusSystemException("Cannot send");
913
throw DBusSystemException("No pending reply");
916
SetMenuStatus_async_closure *closure = new SetMenuStatus_async_closure;
917
closure->impl = this;
918
closure->signal.connect(slot);
920
if (!dbus_pending_call_set_notify(pending,
921
org_workrave_GnomeAppletInterface_Impl::SetMenuStatus_fcn_static,
922
closure, SetMenuStatus_async_closure_free))
924
throw DBusSystemException("Cannot set notifier");
928
dbus_message_unref(message);
931
catch (DBusException)
935
dbus_message_unref(message);
940
dbus_pending_call_unref(pending);
948
void org_workrave_GnomeAppletInterface_Impl::SetMenuStatus_fcn_static(DBusPendingCall *pending, void *user_data)
950
SetMenuStatus_async_closure *closure = (SetMenuStatus_async_closure *)user_data;
952
closure->impl->SetMenuStatus_fcn(pending, user_data);
955
void org_workrave_GnomeAppletInterface_Impl::SetMenuStatus_fcn(DBusPendingCall *pending, void *user_data)
957
SetMenuStatus_async_closure *closure = (SetMenuStatus_async_closure *)user_data;
958
DBusMessage *reply = NULL;
959
DBusMessageIter reader;
964
dbus_error_init(&error);
968
reply = dbus_pending_call_steal_reply(pending);
971
throw DBusSystemException("Cannot get reply");
974
ok = dbus_message_iter_init(reply, &reader);
977
closure->signal.emit((DBusError *)NULL );
979
catch (DBusException)
983
dbus_message_unref(reply);
988
dbus_pending_call_unref(pending);
1000
void org_workrave_GnomeAppletInterface_Impl::GetMenuStatus( const std::string &menu , bool &status )
1003
DBusMessage *message = NULL;
1004
DBusMessage *reply = NULL;
1005
DBusPendingCall *pending = NULL;
1007
DBusMessageIter reader;
1008
DBusMessageIter writer;
1014
message = dbus_message_new_method_call(service.c_str(),
1016
"org.workrave.GnomeAppletInterface", "GetMenuStatus");
1018
dbus_message_iter_init_append(message, &writer);
1020
put_string(&writer, &menu);
1022
if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
1024
throw DBusSystemException("Cannot send");
1027
if (NULL == pending)
1029
throw DBusSystemException("No pending reply");
1032
dbus_connection_flush(dbus->conn());
1035
dbus_message_unref(message);
1038
// block until we receive a reply
1039
dbus_pending_call_block(pending);
1041
// get the reply message
1042
reply = dbus_pending_call_steal_reply(pending);
1045
throw DBusSystemException("No reply");
1048
// free the pending message handle
1049
dbus_pending_call_unref(pending);
1052
ok = dbus_message_iter_init(reply, &reader);
1055
throw DBusSystemException("No parameters");
1058
get_bool(&reader, &status);
1061
catch (DBusException)
1065
dbus_message_unref(reply);
1068
if (message != NULL)
1070
dbus_message_unref(message);
1073
if (pending != NULL)
1075
dbus_pending_call_unref(pending);
1085
void org_workrave_GnomeAppletInterface_Impl::GetMenuStatus_async( const std::string &menu , GetMenuStatus_slot slot
1089
DBusMessage *message = NULL;
1090
DBusPendingCall *pending = NULL;
1092
DBusMessageIter writer;
1096
message = dbus_message_new_method_call(service.c_str(),
1098
"org.workrave.GnomeAppletInterface", "GetMenuStatus");
1100
dbus_message_iter_init(message, &writer);
1102
put_string(&writer, &menu);
1104
if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
1106
throw DBusSystemException("Cannot send");
1109
if (NULL == pending)
1111
throw DBusSystemException("No pending reply");
1114
GetMenuStatus_async_closure *closure = new GetMenuStatus_async_closure;
1115
closure->impl = this;
1116
closure->signal.connect(slot);
1118
if (!dbus_pending_call_set_notify(pending,
1119
org_workrave_GnomeAppletInterface_Impl::GetMenuStatus_fcn_static,
1120
closure, GetMenuStatus_async_closure_free))
1122
throw DBusSystemException("Cannot set notifier");
1126
dbus_message_unref(message);
1129
catch (DBusException)
1131
if (message != NULL)
1133
dbus_message_unref(message);
1136
if (pending != NULL)
1138
dbus_pending_call_unref(pending);
1146
void org_workrave_GnomeAppletInterface_Impl::GetMenuStatus_fcn_static(DBusPendingCall *pending, void *user_data)
1148
GetMenuStatus_async_closure *closure = (GetMenuStatus_async_closure *)user_data;
1150
closure->impl->GetMenuStatus_fcn(pending, user_data);
1153
void org_workrave_GnomeAppletInterface_Impl::GetMenuStatus_fcn(DBusPendingCall *pending, void *user_data)
1155
GetMenuStatus_async_closure *closure = (GetMenuStatus_async_closure *)user_data;
1156
DBusMessage *reply = NULL;
1157
DBusMessageIter reader;
1163
dbus_error_init(&error);
1167
reply = dbus_pending_call_steal_reply(pending);
1170
throw DBusSystemException("Cannot get reply");
1173
ok = dbus_message_iter_init(reply, &reader);
1176
throw DBusSystemException("No parameters");
1179
get_bool(&reader, &status);
1181
closure->signal.emit((DBusError *)NULL , status );
1183
catch (DBusException)
1187
dbus_message_unref(reply);
1190
if (pending != NULL)
1192
dbus_pending_call_unref(pending);
1204
void org_workrave_GnomeAppletInterface_Impl::SetMenuActive( const std::string &menu , bool &active )
1207
DBusMessage *message = NULL;
1208
DBusMessage *reply = NULL;
1209
DBusPendingCall *pending = NULL;
1211
DBusMessageIter reader;
1212
DBusMessageIter writer;
1218
message = dbus_message_new_method_call(service.c_str(),
1220
"org.workrave.GnomeAppletInterface", "SetMenuActive");
1222
dbus_message_iter_init_append(message, &writer);
1224
put_string(&writer, &menu);
1225
put_bool(&writer, &active);
1227
if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
1229
throw DBusSystemException("Cannot send");
1232
if (NULL == pending)
1234
throw DBusSystemException("No pending reply");
1237
dbus_connection_flush(dbus->conn());
1240
dbus_message_unref(message);
1243
// block until we receive a reply
1244
dbus_pending_call_block(pending);
1246
// get the reply message
1247
reply = dbus_pending_call_steal_reply(pending);
1250
throw DBusSystemException("No reply");
1253
// free the pending message handle
1254
dbus_pending_call_unref(pending);
1257
ok = dbus_message_iter_init(reply, &reader);
1260
throw DBusSystemException("No parameters");
1265
catch (DBusException)
1269
dbus_message_unref(reply);
1272
if (message != NULL)
1274
dbus_message_unref(message);
1277
if (pending != NULL)
1279
dbus_pending_call_unref(pending);
1289
void org_workrave_GnomeAppletInterface_Impl::SetMenuActive_async( const std::string &menu , bool &active , SetMenuActive_slot slot
1293
DBusMessage *message = NULL;
1294
DBusPendingCall *pending = NULL;
1296
DBusMessageIter writer;
1300
message = dbus_message_new_method_call(service.c_str(),
1302
"org.workrave.GnomeAppletInterface", "SetMenuActive");
1304
dbus_message_iter_init(message, &writer);
1306
put_string(&writer, &menu);
1307
put_bool(&writer, &active);
1309
if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
1311
throw DBusSystemException("Cannot send");
1314
if (NULL == pending)
1316
throw DBusSystemException("No pending reply");
1319
SetMenuActive_async_closure *closure = new SetMenuActive_async_closure;
1320
closure->impl = this;
1321
closure->signal.connect(slot);
1323
if (!dbus_pending_call_set_notify(pending,
1324
org_workrave_GnomeAppletInterface_Impl::SetMenuActive_fcn_static,
1325
closure, SetMenuActive_async_closure_free))
1327
throw DBusSystemException("Cannot set notifier");
1331
dbus_message_unref(message);
1334
catch (DBusException)
1336
if (message != NULL)
1338
dbus_message_unref(message);
1341
if (pending != NULL)
1343
dbus_pending_call_unref(pending);
1351
void org_workrave_GnomeAppletInterface_Impl::SetMenuActive_fcn_static(DBusPendingCall *pending, void *user_data)
1353
SetMenuActive_async_closure *closure = (SetMenuActive_async_closure *)user_data;
1355
closure->impl->SetMenuActive_fcn(pending, user_data);
1358
void org_workrave_GnomeAppletInterface_Impl::SetMenuActive_fcn(DBusPendingCall *pending, void *user_data)
1360
SetMenuActive_async_closure *closure = (SetMenuActive_async_closure *)user_data;
1361
DBusMessage *reply = NULL;
1362
DBusMessageIter reader;
1367
dbus_error_init(&error);
1371
reply = dbus_pending_call_steal_reply(pending);
1374
throw DBusSystemException("Cannot get reply");
1377
ok = dbus_message_iter_init(reply, &reader);
1380
closure->signal.emit((DBusError *)NULL );
1382
catch (DBusException)
1386
dbus_message_unref(reply);
1389
if (pending != NULL)
1391
dbus_pending_call_unref(pending);
1403
void org_workrave_GnomeAppletInterface_Impl::GetMenuActive( const std::string &menu , bool &active )
1406
DBusMessage *message = NULL;
1407
DBusMessage *reply = NULL;
1408
DBusPendingCall *pending = NULL;
1410
DBusMessageIter reader;
1411
DBusMessageIter writer;
1417
message = dbus_message_new_method_call(service.c_str(),
1419
"org.workrave.GnomeAppletInterface", "GetMenuActive");
1421
dbus_message_iter_init_append(message, &writer);
1423
put_string(&writer, &menu);
1425
if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
1427
throw DBusSystemException("Cannot send");
1430
if (NULL == pending)
1432
throw DBusSystemException("No pending reply");
1435
dbus_connection_flush(dbus->conn());
1438
dbus_message_unref(message);
1441
// block until we receive a reply
1442
dbus_pending_call_block(pending);
1444
// get the reply message
1445
reply = dbus_pending_call_steal_reply(pending);
1448
throw DBusSystemException("No reply");
1451
// free the pending message handle
1452
dbus_pending_call_unref(pending);
1455
ok = dbus_message_iter_init(reply, &reader);
1458
throw DBusSystemException("No parameters");
1461
get_bool(&reader, &active);
1464
catch (DBusException)
1468
dbus_message_unref(reply);
1471
if (message != NULL)
1473
dbus_message_unref(message);
1476
if (pending != NULL)
1478
dbus_pending_call_unref(pending);
1488
void org_workrave_GnomeAppletInterface_Impl::GetMenuActive_async( const std::string &menu , GetMenuActive_slot slot
1492
DBusMessage *message = NULL;
1493
DBusPendingCall *pending = NULL;
1495
DBusMessageIter writer;
1499
message = dbus_message_new_method_call(service.c_str(),
1501
"org.workrave.GnomeAppletInterface", "GetMenuActive");
1503
dbus_message_iter_init(message, &writer);
1505
put_string(&writer, &menu);
1507
if (!dbus_connection_send_with_reply(dbus->conn(), message, &pending, -1))
1509
throw DBusSystemException("Cannot send");
1512
if (NULL == pending)
1514
throw DBusSystemException("No pending reply");
1517
GetMenuActive_async_closure *closure = new GetMenuActive_async_closure;
1518
closure->impl = this;
1519
closure->signal.connect(slot);
1521
if (!dbus_pending_call_set_notify(pending,
1522
org_workrave_GnomeAppletInterface_Impl::GetMenuActive_fcn_static,
1523
closure, GetMenuActive_async_closure_free))
1525
throw DBusSystemException("Cannot set notifier");
1529
dbus_message_unref(message);
1532
catch (DBusException)
1534
if (message != NULL)
1536
dbus_message_unref(message);
1539
if (pending != NULL)
1541
dbus_pending_call_unref(pending);
1549
void org_workrave_GnomeAppletInterface_Impl::GetMenuActive_fcn_static(DBusPendingCall *pending, void *user_data)
1551
GetMenuActive_async_closure *closure = (GetMenuActive_async_closure *)user_data;
1553
closure->impl->GetMenuActive_fcn(pending, user_data);
1556
void org_workrave_GnomeAppletInterface_Impl::GetMenuActive_fcn(DBusPendingCall *pending, void *user_data)
1558
GetMenuActive_async_closure *closure = (GetMenuActive_async_closure *)user_data;
1559
DBusMessage *reply = NULL;
1560
DBusMessageIter reader;
1566
dbus_error_init(&error);
1570
reply = dbus_pending_call_steal_reply(pending);
1573
throw DBusSystemException("Cannot get reply");
1576
ok = dbus_message_iter_init(reply, &reader);
1579
throw DBusSystemException("No parameters");
1582
get_bool(&reader, &active);
1584
closure->signal.emit((DBusError *)NULL , active );
1586
catch (DBusException)
1590
dbus_message_unref(reply);
1593
if (pending != NULL)
1595
dbus_pending_call_unref(pending);