~ubuntu-branches/ubuntu/saucy/sflphone/saucy

« back to all changes in this revision

Viewing changes to sflphone-common/libs/dbus-c++/src/dispatcher.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Francois Marier
  • Date: 2010-12-24 16:33:55 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20101224163355-tkvvikqxbrbav6up
Tags: 0.9.11-1
* New upstream release
* Add new build dependencies on libwebkit-dev and libyaml-dev

* Bump Standards-Version up to 3.9.1
* Bump debhelper compatibility to 8
* Patch another typo in the upstream code (lintian notice)

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
using namespace DBus;
39
39
 
40
40
Timeout::Timeout (Timeout::Internal *i)
41
 
        : _int (i)
42
 
{
 
41
        : _int (i) {
43
42
    dbus_timeout_set_data ( (DBusTimeout *) i, this, NULL);
44
43
}
45
44
 
46
 
int Timeout::interval() const
47
 
{
 
45
int Timeout::interval() const {
48
46
    return dbus_timeout_get_interval ( (DBusTimeout *) _int);
49
47
}
50
48
 
51
 
bool Timeout::enabled() const
52
 
{
 
49
bool Timeout::enabled() const {
53
50
    return dbus_timeout_get_enabled ( (DBusTimeout *) _int);
54
51
}
55
52
 
56
 
bool Timeout::handle()
57
 
{
 
53
bool Timeout::handle() {
58
54
    return dbus_timeout_handle ( (DBusTimeout *) _int);
59
55
}
60
56
 
62
58
*/
63
59
 
64
60
Watch::Watch (Watch::Internal *i)
65
 
        : _int (i)
66
 
{
 
61
        : _int (i) {
67
62
    dbus_watch_set_data ( (DBusWatch *) i, this, NULL);
68
63
}
69
64
 
70
 
int Watch::descriptor() const
71
 
{
 
65
int Watch::descriptor() const {
72
66
#if HAVE_WIN32
73
67
    return dbus_watch_get_socket ( (DBusWatch*) _int);
74
68
#else
76
70
#endif
77
71
}
78
72
 
79
 
int Watch::flags() const
80
 
{
 
73
int Watch::flags() const {
81
74
    return dbus_watch_get_flags ( (DBusWatch *) _int);
82
75
}
83
76
 
84
 
bool Watch::enabled() const
85
 
{
 
77
bool Watch::enabled() const {
86
78
    return dbus_watch_get_enabled ( (DBusWatch *) _int);
87
79
}
88
80
 
89
 
bool Watch::handle (int flags)
90
 
{
 
81
bool Watch::handle (int flags) {
91
82
    return dbus_watch_handle ( (DBusWatch *) _int, flags);
92
83
}
93
84
 
94
85
/*
95
86
*/
96
87
 
97
 
dbus_bool_t Dispatcher::Private::on_add_watch (DBusWatch *watch, void *data)
98
 
{
 
88
dbus_bool_t Dispatcher::Private::on_add_watch (DBusWatch *watch, void *data) {
99
89
    Dispatcher *d = static_cast<Dispatcher *> (data);
100
90
 
101
91
    Watch::Internal *w = reinterpret_cast<Watch::Internal *> (watch);
105
95
    return true;
106
96
}
107
97
 
108
 
void Dispatcher::Private::on_rem_watch (DBusWatch *watch, void *data)
109
 
{
 
98
void Dispatcher::Private::on_rem_watch (DBusWatch *watch, void *data) {
110
99
    Dispatcher *d = static_cast<Dispatcher *> (data);
111
100
 
112
101
    Watch *w = static_cast<Watch *> (dbus_watch_get_data (watch));
114
103
    d->rem_watch (w);
115
104
}
116
105
 
117
 
void Dispatcher::Private::on_toggle_watch (DBusWatch *watch, void *data)
118
 
{
 
106
void Dispatcher::Private::on_toggle_watch (DBusWatch *watch, void *data) {
119
107
    Watch *w = static_cast<Watch *> (dbus_watch_get_data (watch));
120
108
 
121
109
    w->toggle();
122
110
}
123
111
 
124
 
dbus_bool_t Dispatcher::Private::on_add_timeout (DBusTimeout *timeout, void *data)
125
 
{
 
112
dbus_bool_t Dispatcher::Private::on_add_timeout (DBusTimeout *timeout, void *data) {
126
113
    Dispatcher *d = static_cast<Dispatcher *> (data);
127
114
 
128
115
    Timeout::Internal *t = reinterpret_cast<Timeout::Internal *> (timeout);
132
119
    return true;
133
120
}
134
121
 
135
 
void Dispatcher::Private::on_rem_timeout (DBusTimeout *timeout, void *data)
136
 
{
 
122
void Dispatcher::Private::on_rem_timeout (DBusTimeout *timeout, void *data) {
137
123
    Dispatcher *d = static_cast<Dispatcher *> (data);
138
124
 
139
125
    Timeout *t = static_cast<Timeout *> (dbus_timeout_get_data (timeout));
141
127
    d->rem_timeout (t);
142
128
}
143
129
 
144
 
void Dispatcher::Private::on_toggle_timeout (DBusTimeout *timeout, void *data)
145
 
{
 
130
void Dispatcher::Private::on_toggle_timeout (DBusTimeout *timeout, void *data) {
146
131
    Timeout *t = static_cast<Timeout *> (dbus_timeout_get_data (timeout));
147
132
 
148
133
    t->toggle();
149
134
}
150
135
 
151
 
void Dispatcher::queue_connection (Connection::Private *cp)
152
 
{
 
136
void Dispatcher::queue_connection (Connection::Private *cp) {
153
137
    _mutex_p.lock();
154
138
    _pending_queue.push_back (cp);
155
139
    _mutex_p.unlock();
156
140
}
157
141
 
158
142
 
159
 
bool Dispatcher::has_something_to_dispatch()
160
 
{
 
143
bool Dispatcher::has_something_to_dispatch() {
161
144
    _mutex_p.lock();
162
145
    bool has_something = false;
163
146
 
173
156
}
174
157
 
175
158
 
176
 
void Dispatcher::dispatch_pending()
177
 
{
 
159
void Dispatcher::dispatch_pending() {
178
160
    _mutex_p.lock();
179
161
 
180
162
    // SEEME: dbus-glib is dispatching only one message at a time to not starve the loop/other things...
199
181
    _mutex_p.unlock();
200
182
}
201
183
 
202
 
void DBus::_init_threading()
203
 
{
 
184
void DBus::_init_threading() {
204
185
#ifdef DBUS_HAS_THREADS_INIT_DEFAULT
205
186
    dbus_threads_init_default();
206
187
#else
219
200
    CondVarWaitTimeoutFn c4,
220
201
    CondVarWakeOneFn c5,
221
202
    CondVarWakeAllFn c6
222
 
)
223
 
{
 
203
) {
224
204
#ifndef DBUS_HAS_RECURSIVE_MUTEX
225
205
    DBusThreadFunctions functions = {
226
206
        DBUS_THREAD_FUNCTIONS_MUTEX_NEW_MASK |