39.1.88
by Ted Gould
Adding copyright headers |
1 |
/*
|
2 |
Copyright 2012 Canonical Ltd.
|
|
3 |
||
4 |
Authors:
|
|
5 |
Ted Gould <ted@canonical.com>
|
|
6 |
||
7 |
This program is free software: you can redistribute it and/or modify it
|
|
8 |
under the terms of the GNU General Public License version 3, as published
|
|
9 |
by the Free Software Foundation.
|
|
10 |
||
11 |
This program is distributed in the hope that it will be useful, but
|
|
12 |
WITHOUT ANY WARRANTY; without even the implied warranties of
|
|
13 |
MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
|
14 |
PURPOSE. See the GNU General Public License for more details.
|
|
15 |
||
16 |
You should have received a copy of the GNU General Public License along
|
|
17 |
with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
18 |
*/
|
|
19 |
||
39.1.6
by Ted Gould
Adding in a template task |
20 |
#ifdef HAVE_CONFIG_H
|
21 |
#include "config.h" |
|
22 |
#endif
|
|
23 |
||
39.1.8
by Ted Gould
Setup single includes |
24 |
#include "dbus-test.h" |
39.1.22
by Ted Gould
Setting up the wait for |
25 |
#include <gio/gio.h> |
39.1.6
by Ted Gould
Adding in a template task |
26 |
|
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
27 |
typedef struct { |
39.1.15
by Ted Gould
Setting up the returning of passed based on the inversion stuff |
28 |
DbusTestTaskReturn return_type; |
39.1.22
by Ted Gould
Setting up the wait for |
29 |
|
39.1.16
by Ted Gould
Setting up the wait_for variable |
30 |
gchar * wait_for; |
89.1.2
by Ted Gould
Ensure that we can wait on the right bus as well |
31 |
DbusTestServiceBus wait_for_bus; |
39.1.22
by Ted Gould
Setting up the wait for |
32 |
guint wait_task; |
39.1.18
by Ted Gould
Handling all the naming issues |
33 |
|
34 |
gchar * name; |
|
35 |
gchar * name_padded; |
|
39.1.58
by Ted Gould
Normalize the name lengths on the tasks so that we can have pretty tasks |
36 |
glong padding_cnt; |
39.1.23
by Ted Gould
Going through the run process |
37 |
|
38 |
gboolean been_run; |
|
44.2.3
by Ted Gould
Storing the value in the private structure |
39 |
gboolean wait_until_complete; |
84.1.2
by Ted Gould
Allow a task to specify where it should go |
40 |
|
41 |
DbusTestServiceBus preferred_bus; |
|
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
42 |
} DbusTestTaskPrivate; |
39.1.6
by Ted Gould
Adding in a template task |
43 |
|
39.1.37
by Ted Gould
Adding a state changed signal for tasks |
44 |
/* Signals */
|
45 |
enum { |
|
46 |
STATE_CHANGED, |
|
47 |
LAST_SIGNAL /* Don't touch! */ |
|
48 |
};
|
|
49 |
||
39.1.6
by Ted Gould
Adding in a template task |
50 |
static void dbus_test_task_class_init (DbusTestTaskClass *klass); |
51 |
static void dbus_test_task_init (DbusTestTask *self); |
|
52 |
static void dbus_test_task_dispose (GObject *object); |
|
53 |
static void dbus_test_task_finalize (GObject *object); |
|
54 |
||
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
55 |
G_DEFINE_TYPE_WITH_PRIVATE (DbusTestTask, dbus_test_task, G_TYPE_OBJECT); |
39.1.6
by Ted Gould
Adding in a template task |
56 |
|
39.1.37
by Ted Gould
Adding a state changed signal for tasks |
57 |
static guint signals[LAST_SIGNAL] = {0}; |
58 |
||
39.1.6
by Ted Gould
Adding in a template task |
59 |
static void |
60 |
dbus_test_task_class_init (DbusTestTaskClass *klass) |
|
61 |
{
|
|
62 |
GObjectClass *object_class = G_OBJECT_CLASS (klass); |
|
63 |
||
64 |
object_class->dispose = dbus_test_task_dispose; |
|
65 |
object_class->finalize = dbus_test_task_finalize; |
|
66 |
||
39.1.13
by Ted Gould
Adding some subclassable functions |
67 |
klass->run = NULL; |
68 |
klass->get_state = NULL; |
|
69 |
klass->get_passed = NULL; |
|
70 |
||
39.1.37
by Ted Gould
Adding a state changed signal for tasks |
71 |
signals[STATE_CHANGED] = g_signal_new(DBUS_TEST_TASK_SIGNAL_STATE_CHANGED, |
72 |
G_TYPE_FROM_CLASS (klass), |
|
73 |
G_SIGNAL_RUN_LAST, |
|
74 |
G_STRUCT_OFFSET (DbusTestTaskClass, state_changed), |
|
75 |
NULL, NULL, |
|
76 |
g_cclosure_marshal_VOID__INT, |
|
77 |
G_TYPE_NONE, 1, G_TYPE_INT, G_TYPE_NONE); |
|
78 |
||
39.1.6
by Ted Gould
Adding in a template task |
79 |
return; |
80 |
}
|
|
81 |
||
82 |
static void |
|
83 |
dbus_test_task_init (DbusTestTask *self) |
|
84 |
{
|
|
39.1.18
by Ted Gould
Handling all the naming issues |
85 |
static gint task_count = 0; |
86 |
||
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
87 |
DbusTestTaskPrivate *priv = dbus_test_task_get_instance_private(self); |
88 |
||
89 |
priv->return_type = DBUS_TEST_TASK_RETURN_NORMAL; |
|
90 |
||
91 |
priv->wait_for = NULL; |
|
92 |
priv->wait_for_bus = DBUS_TEST_SERVICE_BUS_BOTH; |
|
93 |
priv->wait_task = 0; |
|
94 |
||
95 |
priv->name = g_strdup_printf("task-%d", task_count++); |
|
96 |
priv->name_padded = NULL; |
|
97 |
priv->padding_cnt = 0; |
|
98 |
||
99 |
priv->been_run = FALSE; |
|
100 |
priv->wait_until_complete = FALSE; |
|
101 |
||
102 |
priv->preferred_bus = DBUS_TEST_SERVICE_BUS_BOTH; |
|
84.1.2
by Ted Gould
Allow a task to specify where it should go |
103 |
|
39.1.6
by Ted Gould
Adding in a template task |
104 |
return; |
105 |
}
|
|
106 |
||
107 |
static void |
|
108 |
dbus_test_task_dispose (GObject *object) |
|
109 |
{
|
|
39.1.22
by Ted Gould
Setting up the wait for |
110 |
g_return_if_fail(DBUS_TEST_IS_TASK(object)); |
111 |
DbusTestTask * self = DBUS_TEST_TASK(object); |
|
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
112 |
DbusTestTaskPrivate *priv = dbus_test_task_get_instance_private(self); |
39.1.22
by Ted Gould
Setting up the wait for |
113 |
|
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
114 |
if (priv->wait_task != 0) { |
115 |
g_bus_unwatch_name(priv->wait_task); |
|
116 |
priv->wait_task = 0; |
|
39.1.22
by Ted Gould
Setting up the wait for |
117 |
}
|
39.1.6
by Ted Gould
Adding in a template task |
118 |
|
119 |
G_OBJECT_CLASS (dbus_test_task_parent_class)->dispose (object); |
|
120 |
return; |
|
121 |
}
|
|
122 |
||
123 |
static void |
|
124 |
dbus_test_task_finalize (GObject *object) |
|
125 |
{
|
|
39.1.21
by Ted Gould
Make sure to clean up after ourselves |
126 |
g_return_if_fail(DBUS_TEST_IS_TASK(object)); |
127 |
DbusTestTask * self = DBUS_TEST_TASK(object); |
|
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
128 |
DbusTestTaskPrivate *priv = dbus_test_task_get_instance_private(self); |
129 |
||
130 |
g_print("%s: Shutting down\n", priv->name); |
|
131 |
||
132 |
g_free(priv->name); |
|
133 |
g_free(priv->name_padded); |
|
134 |
g_free(priv->wait_for); |
|
39.1.6
by Ted Gould
Adding in a template task |
135 |
|
136 |
G_OBJECT_CLASS (dbus_test_task_parent_class)->finalize (object); |
|
137 |
return; |
|
138 |
}
|
|
39.1.14
by Ted Gould
Taking the prototypes and making them into 'functions' |
139 |
|
140 |
DbusTestTask * |
|
141 |
dbus_test_task_new (void) |
|
142 |
{
|
|
39.1.20
by Ted Gould
Now we can start to create these little guys |
143 |
DbusTestTask * task = g_object_new(DBUS_TEST_TYPE_TASK, |
144 |
NULL); |
|
39.1.14
by Ted Gould
Taking the prototypes and making them into 'functions' |
145 |
|
39.1.20
by Ted Gould
Now we can start to create these little guys |
146 |
return task; |
39.1.14
by Ted Gould
Taking the prototypes and making them into 'functions' |
147 |
}
|
148 |
||
149 |
void
|
|
150 |
dbus_test_task_set_name (DbusTestTask * task, const gchar * name) |
|
151 |
{
|
|
39.1.18
by Ted Gould
Handling all the naming issues |
152 |
g_return_if_fail(DBUS_TEST_IS_TASK(task)); |
153 |
||
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
154 |
DbusTestTaskPrivate *priv = dbus_test_task_get_instance_private(task); |
155 |
||
156 |
g_free(priv->name); |
|
157 |
g_free(priv->name_padded); |
|
158 |
||
159 |
priv->name = g_strdup(name); |
|
160 |
if (priv->padding_cnt != 0 && priv->name != NULL) { |
|
161 |
gchar * fillstr = g_strnfill(priv->padding_cnt - g_utf8_strlen(priv->name, -1), ' '); |
|
162 |
priv->name_padded = g_strconcat(priv->name, fillstr, NULL); |
|
39.1.18
by Ted Gould
Handling all the naming issues |
163 |
g_free(fillstr); |
164 |
} else { |
|
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
165 |
priv->name_padded = NULL; |
39.1.18
by Ted Gould
Handling all the naming issues |
166 |
}
|
39.1.14
by Ted Gould
Taking the prototypes and making them into 'functions' |
167 |
|
168 |
return; |
|
169 |
}
|
|
170 |
||
171 |
void
|
|
39.1.58
by Ted Gould
Normalize the name lengths on the tasks so that we can have pretty tasks |
172 |
dbus_test_task_set_name_spacing (DbusTestTask * task, glong chars) |
39.1.14
by Ted Gould
Taking the prototypes and making them into 'functions' |
173 |
{
|
39.1.18
by Ted Gould
Handling all the naming issues |
174 |
g_return_if_fail(DBUS_TEST_IS_TASK(task)); |
175 |
||
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
176 |
DbusTestTaskPrivate *priv = dbus_test_task_get_instance_private(task); |
177 |
||
178 |
g_free(priv->name_padded); |
|
179 |
priv->padding_cnt = chars; |
|
180 |
||
181 |
g_return_if_fail(priv->padding_cnt >= g_utf8_strlen(priv->name, -1)); |
|
182 |
||
183 |
if (chars != 0 && priv->name != NULL) { |
|
184 |
gchar * fillstr = g_strnfill(priv->padding_cnt - g_utf8_strlen(priv->name, -1), ' '); |
|
185 |
priv->name_padded = g_strconcat(priv->name, fillstr, NULL); |
|
39.1.18
by Ted Gould
Handling all the naming issues |
186 |
g_free(fillstr); |
187 |
} else { |
|
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
188 |
priv->name_padded = NULL; |
39.1.18
by Ted Gould
Handling all the naming issues |
189 |
}
|
39.1.14
by Ted Gould
Taking the prototypes and making them into 'functions' |
190 |
|
191 |
return; |
|
192 |
}
|
|
193 |
void
|
|
194 |
dbus_test_task_set_wait_for (DbusTestTask * task, const gchar * dbus_name) |
|
195 |
{
|
|
89.1.2
by Ted Gould
Ensure that we can wait on the right bus as well |
196 |
return dbus_test_task_set_wait_for_bus(task, dbus_name, DBUS_TEST_SERVICE_BUS_BOTH); |
197 |
}
|
|
198 |
||
199 |
void
|
|
200 |
dbus_test_task_set_wait_for_bus (DbusTestTask * task, const gchar * dbus_name, DbusTestServiceBus bus) |
|
201 |
{
|
|
39.1.16
by Ted Gould
Setting up the wait_for variable |
202 |
g_return_if_fail(DBUS_TEST_IS_TASK(task)); |
203 |
||
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
204 |
DbusTestTaskPrivate *priv = dbus_test_task_get_instance_private(task); |
205 |
||
206 |
if (priv->wait_for != NULL) { |
|
207 |
g_free(priv->wait_for); |
|
208 |
priv->wait_for = NULL; |
|
209 |
priv->wait_for_bus = DBUS_TEST_SERVICE_BUS_BOTH; |
|
39.1.16
by Ted Gould
Setting up the wait_for variable |
210 |
}
|
211 |
||
212 |
if (dbus_name == NULL) { |
|
213 |
return; |
|
214 |
}
|
|
215 |
||
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
216 |
priv->wait_for = g_strdup(dbus_name); |
217 |
priv->wait_for_bus = bus; |
|
39.1.14
by Ted Gould
Taking the prototypes and making them into 'functions' |
218 |
|
219 |
return; |
|
220 |
}
|
|
221 |
||
222 |
void
|
|
223 |
dbus_test_task_set_return (DbusTestTask * task, DbusTestTaskReturn ret) |
|
224 |
{
|
|
39.1.17
by Ted Gould
Setting the return type |
225 |
g_return_if_fail(DBUS_TEST_IS_TASK(task)); |
226 |
||
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
227 |
DbusTestTaskPrivate *priv = dbus_test_task_get_instance_private(task); |
228 |
||
229 |
if (ret != priv->return_type && dbus_test_task_get_state(task) == DBUS_TEST_TASK_STATE_FINISHED) { |
|
39.1.17
by Ted Gould
Setting the return type |
230 |
g_warning("Changing return type after the task has finished"); |
231 |
}
|
|
232 |
||
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
233 |
priv->return_type = ret; |
39.1.14
by Ted Gould
Taking the prototypes and making them into 'functions' |
234 |
return; |
235 |
}
|
|
236 |
||
237 |
void
|
|
238 |
dbus_test_task_print (DbusTestTask * task, const gchar * message) |
|
239 |
{
|
|
39.1.19
by Ted Gould
Flesh out printing |
240 |
g_return_if_fail(DBUS_TEST_IS_TASK(task)); |
241 |
g_return_if_fail(message != NULL); |
|
242 |
||
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
243 |
DbusTestTaskPrivate *priv = dbus_test_task_get_instance_private(task); |
244 |
||
245 |
gchar * name = priv->name; |
|
246 |
if (priv->name_padded != NULL) { |
|
247 |
name = priv->name_padded; |
|
39.1.19
by Ted Gould
Flesh out printing |
248 |
}
|
249 |
||
39.1.63
by Ted Gould
Make sure to add the newline, g_print is fun! |
250 |
g_print("%s: %s\n", name, message); |
39.1.14
by Ted Gould
Taking the prototypes and making them into 'functions' |
251 |
|
252 |
return; |
|
253 |
}
|
|
254 |
||
255 |
DbusTestTaskState
|
|
256 |
dbus_test_task_get_state (DbusTestTask * task) |
|
257 |
{
|
|
39.1.24
by Ted Gould
Fleshing out getting the state of where we are. |
258 |
g_return_val_if_fail(DBUS_TEST_IS_TASK(task), DBUS_TEST_TASK_STATE_FINISHED); |
259 |
||
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
260 |
DbusTestTaskPrivate *priv = dbus_test_task_get_instance_private(task); |
261 |
||
262 |
if (priv->wait_task != 0) { |
|
39.1.24
by Ted Gould
Fleshing out getting the state of where we are. |
263 |
return DBUS_TEST_TASK_STATE_WAITING; |
264 |
}
|
|
265 |
||
266 |
DbusTestTaskClass * klass = DBUS_TEST_TASK_GET_CLASS(task); |
|
267 |
if (klass->get_state != NULL) { |
|
268 |
return klass->get_state(task); |
|
269 |
}
|
|
270 |
||
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
271 |
if (priv->been_run) { |
39.1.24
by Ted Gould
Fleshing out getting the state of where we are. |
272 |
return DBUS_TEST_TASK_STATE_FINISHED; |
273 |
} else { |
|
274 |
return DBUS_TEST_TASK_STATE_INIT; |
|
275 |
}
|
|
39.1.14
by Ted Gould
Taking the prototypes and making them into 'functions' |
276 |
}
|
277 |
||
39.1.46
by Ted Gould
Take return type into account in in seeing if things are finished |
278 |
DbusTestTaskReturn
|
279 |
dbus_test_task_get_return (DbusTestTask * task) |
|
280 |
{
|
|
281 |
g_return_val_if_fail(DBUS_TEST_IS_TASK(task), DBUS_TEST_TASK_RETURN_IGNORE); |
|
282 |
||
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
283 |
DbusTestTaskPrivate *priv = dbus_test_task_get_instance_private(task); |
284 |
||
285 |
return priv->return_type; |
|
39.1.46
by Ted Gould
Take return type into account in in seeing if things are finished |
286 |
}
|
287 |
||
39.1.22
by Ted Gould
Setting up the wait for |
288 |
static void |
44.1.10
by Ted Gould
Trying to turn on -Wextra to figure out what's up with Jenkins. Don't think there's huge value, but might as well commit. |
289 |
wait_for_found (G_GNUC_UNUSED GDBusConnection * connection, G_GNUC_UNUSED const gchar * name, G_GNUC_UNUSED const gchar * name_owner, gpointer user_data) |
39.1.22
by Ted Gould
Setting up the wait for |
290 |
{
|
39.1.23
by Ted Gould
Going through the run process |
291 |
g_return_if_fail(DBUS_TEST_IS_TASK(user_data)); |
292 |
DbusTestTask * task = DBUS_TEST_TASK(user_data); |
|
293 |
||
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
294 |
DbusTestTaskPrivate *priv = dbus_test_task_get_instance_private(task); |
295 |
||
296 |
g_bus_unwatch_name(priv->wait_task); |
|
297 |
priv->wait_task = 0; |
|
39.1.23
by Ted Gould
Going through the run process |
298 |
|
299 |
DbusTestTaskClass * klass = DBUS_TEST_TASK_GET_CLASS(task); |
|
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
300 |
priv->been_run = TRUE; |
39.1.23
by Ted Gould
Going through the run process |
301 |
if (klass->run != NULL) { |
302 |
klass->run(task); |
|
303 |
} else { |
|
39.1.41
by Ted Gould
Emit waiting and completion signals with no run function |
304 |
g_signal_emit(G_OBJECT(task), signals[STATE_CHANGED], 0, DBUS_TEST_TASK_STATE_FINISHED, NULL); |
39.1.23
by Ted Gould
Going through the run process |
305 |
}
|
39.1.22
by Ted Gould
Setting up the wait for |
306 |
|
307 |
return; |
|
308 |
}
|
|
309 |
||
39.1.14
by Ted Gould
Taking the prototypes and making them into 'functions' |
310 |
void
|
311 |
dbus_test_task_run (DbusTestTask * task) |
|
312 |
{
|
|
39.1.22
by Ted Gould
Setting up the wait for |
313 |
g_return_if_fail(DBUS_TEST_IS_TASK(task)); |
314 |
||
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
315 |
DbusTestTaskPrivate *priv = dbus_test_task_get_instance_private(task); |
316 |
||
39.1.22
by Ted Gould
Setting up the wait for |
317 |
/* We're going to process the waiting at this level if we've been
|
318 |
asked to do so */
|
|
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
319 |
if (priv->wait_for != NULL) { |
89.1.2
by Ted Gould
Ensure that we can wait on the right bus as well |
320 |
GBusType bustype = G_BUS_TYPE_SESSION; |
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
321 |
if (priv->wait_for_bus == DBUS_TEST_SERVICE_BUS_BOTH && |
322 |
priv->preferred_bus == DBUS_TEST_SERVICE_BUS_SYSTEM) { |
|
89.1.2
by Ted Gould
Ensure that we can wait on the right bus as well |
323 |
bustype = G_BUS_TYPE_SYSTEM; |
324 |
}
|
|
325 |
||
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
326 |
priv->wait_task = g_bus_watch_name(bustype, |
327 |
priv->wait_for, |
|
39.1.22
by Ted Gould
Setting up the wait for |
328 |
G_BUS_NAME_WATCHER_FLAGS_NONE, |
329 |
wait_for_found, |
|
330 |
NULL, |
|
331 |
task, |
|
332 |
NULL); |
|
39.1.41
by Ted Gould
Emit waiting and completion signals with no run function |
333 |
g_signal_emit(G_OBJECT(task), signals[STATE_CHANGED], 0, DBUS_TEST_TASK_STATE_WAITING, NULL); |
39.1.22
by Ted Gould
Setting up the wait for |
334 |
return; |
335 |
}
|
|
39.1.14
by Ted Gould
Taking the prototypes and making them into 'functions' |
336 |
|
39.1.23
by Ted Gould
Going through the run process |
337 |
DbusTestTaskClass * klass = DBUS_TEST_TASK_GET_CLASS(task); |
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
338 |
priv->been_run = TRUE; |
39.1.23
by Ted Gould
Going through the run process |
339 |
if (klass->run != NULL) { |
340 |
klass->run(task); |
|
341 |
} else { |
|
39.1.41
by Ted Gould
Emit waiting and completion signals with no run function |
342 |
g_signal_emit(G_OBJECT(task), signals[STATE_CHANGED], 0, DBUS_TEST_TASK_STATE_FINISHED, NULL); |
39.1.23
by Ted Gould
Going through the run process |
343 |
}
|
344 |
||
39.1.14
by Ted Gould
Taking the prototypes and making them into 'functions' |
345 |
return; |
346 |
}
|
|
347 |
||
348 |
gboolean
|
|
349 |
dbus_test_task_passed (DbusTestTask * task) |
|
350 |
{
|
|
39.1.15
by Ted Gould
Setting up the returning of passed based on the inversion stuff |
351 |
g_return_val_if_fail(DBUS_TEST_IS_TASK(task), FALSE); |
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
352 |
DbusTestTaskPrivate *priv = dbus_test_task_get_instance_private(task); |
353 |
||
354 |
g_return_val_if_fail(priv->been_run, FALSE); |
|
39.1.15
by Ted Gould
Setting up the returning of passed based on the inversion stuff |
355 |
|
356 |
/* If we don't care, we always pass */
|
|
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
357 |
if (priv->return_type == DBUS_TEST_TASK_RETURN_IGNORE) { |
39.1.15
by Ted Gould
Setting up the returning of passed based on the inversion stuff |
358 |
return TRUE; |
359 |
}
|
|
360 |
||
361 |
DbusTestTaskClass * klass = DBUS_TEST_TASK_GET_CLASS(task); |
|
362 |
if (klass->get_passed == NULL) { |
|
363 |
return FALSE; |
|
364 |
}
|
|
365 |
||
366 |
gboolean subret = klass->get_passed(task); |
|
367 |
||
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
368 |
if (priv->return_type == DBUS_TEST_TASK_RETURN_INVERT) { |
39.1.15
by Ted Gould
Setting up the returning of passed based on the inversion stuff |
369 |
return !subret; |
370 |
}
|
|
371 |
||
372 |
return subret; |
|
39.1.14
by Ted Gould
Taking the prototypes and making them into 'functions' |
373 |
}
|
39.1.52
by Ted Gould
Adding some accessors for internal variables |
374 |
|
375 |
const gchar * |
|
376 |
dbus_test_task_get_name (DbusTestTask * task) |
|
377 |
{
|
|
378 |
g_return_val_if_fail(DBUS_TEST_IS_TASK(task), NULL); |
|
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
379 |
DbusTestTaskPrivate *priv = dbus_test_task_get_instance_private(task); |
39.1.52
by Ted Gould
Adding some accessors for internal variables |
380 |
|
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
381 |
return priv->name; |
39.1.52
by Ted Gould
Adding some accessors for internal variables |
382 |
}
|
383 |
||
384 |
const gchar * |
|
385 |
dbus_test_task_get_wait_for (DbusTestTask * task) |
|
386 |
{
|
|
387 |
g_return_val_if_fail(DBUS_TEST_IS_TASK(task), NULL); |
|
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
388 |
DbusTestTaskPrivate *priv = dbus_test_task_get_instance_private(task); |
39.1.52
by Ted Gould
Adding some accessors for internal variables |
389 |
|
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
390 |
return priv->wait_for; |
39.1.52
by Ted Gould
Adding some accessors for internal variables |
391 |
}
|
44.2.2
by Ted Gould
Set up a coulpe of function to set the flag on wether we should complete this task. |
392 |
|
393 |
/**
|
|
394 |
* dbus_test_task_set_wait_finished:
|
|
395 |
* @task: Task to adjust the value on
|
|
396 |
* @wait_till_complete: Set this task to wait until complete
|
|
397 |
* even if we don't care about the return value.
|
|
398 |
*
|
|
399 |
* If this task has the value of its return set to ignore this
|
|
400 |
* means we won't exit early.
|
|
401 |
*/
|
|
402 |
void
|
|
403 |
dbus_test_task_set_wait_finished (DbusTestTask * task, gboolean wait_till_complete) |
|
404 |
{
|
|
44.2.3
by Ted Gould
Storing the value in the private structure |
405 |
g_return_if_fail(DBUS_TEST_IS_TASK(task)); |
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
406 |
DbusTestTaskPrivate *priv = dbus_test_task_get_instance_private(task); |
44.2.3
by Ted Gould
Storing the value in the private structure |
407 |
|
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
408 |
priv->wait_until_complete = wait_till_complete; |
44.2.2
by Ted Gould
Set up a coulpe of function to set the flag on wether we should complete this task. |
409 |
|
410 |
return; |
|
411 |
}
|
|
412 |
||
413 |
/**
|
|
414 |
* dbus_test_task_set_wait_finished:
|
|
415 |
* @task: Task to get the value from
|
|
416 |
*
|
|
417 |
* Check to see if we should wait on this taks irregardless
|
|
418 |
* of whether we care about the return value.
|
|
419 |
*/
|
|
420 |
gboolean
|
|
421 |
dbus_test_task_get_wait_finished (DbusTestTask * task) |
|
422 |
{
|
|
44.2.3
by Ted Gould
Storing the value in the private structure |
423 |
g_return_val_if_fail(DBUS_TEST_IS_TASK(task), FALSE); |
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
424 |
DbusTestTaskPrivate *priv = dbus_test_task_get_instance_private(task); |
44.2.2
by Ted Gould
Set up a coulpe of function to set the flag on wether we should complete this task. |
425 |
|
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
426 |
return priv->wait_until_complete; |
44.2.2
by Ted Gould
Set up a coulpe of function to set the flag on wether we should complete this task. |
427 |
}
|
84.1.2
by Ted Gould
Allow a task to specify where it should go |
428 |
|
429 |
/**
|
|
430 |
* dbus_test_task_set_bus:
|
|
431 |
* @task: Task to get the bus from
|
|
432 |
* @bus: Preferred bus for this task
|
|
433 |
*
|
|
434 |
* Set which bus this task prefers to be on.
|
|
435 |
*/
|
|
436 |
void
|
|
437 |
dbus_test_task_set_bus (DbusTestTask * task, DbusTestServiceBus bus) |
|
438 |
{
|
|
439 |
g_return_if_fail(DBUS_TEST_IS_TASK(task)); |
|
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
440 |
DbusTestTaskPrivate *priv = dbus_test_task_get_instance_private(task); |
84.1.2
by Ted Gould
Allow a task to specify where it should go |
441 |
|
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
442 |
priv->preferred_bus = bus; |
84.1.2
by Ted Gould
Allow a task to specify where it should go |
443 |
}
|
444 |
||
445 |
/**
|
|
446 |
* dbus_test_task_get_bus:
|
|
447 |
* @task: Task to get the bus from
|
|
448 |
*
|
|
449 |
* Check to see which bus this task prefers to be on.
|
|
450 |
*/
|
|
451 |
DbusTestServiceBus
|
|
452 |
dbus_test_task_get_bus (DbusTestTask * task) |
|
453 |
{
|
|
454 |
g_return_val_if_fail(DBUS_TEST_IS_TASK(task), DBUS_TEST_SERVICE_BUS_BOTH); |
|
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
455 |
DbusTestTaskPrivate *priv = dbus_test_task_get_instance_private(task); |
84.1.2
by Ted Gould
Allow a task to specify where it should go |
456 |
|
100.1.1
by Mike Gabriel
libdbustest: port to new GObject private ABI |
457 |
return priv->preferred_bus; |
84.1.2
by Ted Gould
Allow a task to specify where it should go |
458 |
}
|