Skip to content

Latest commit

 

History

History
695 lines (644 loc) · 18.2 KB

mms_dispatcher.c

File metadata and controls

695 lines (644 loc) · 18.2 KB
 
Feb 17, 2014
Feb 17, 2014
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/*
* Copyright (C) 2013-2014 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include "mms_dispatcher.h"
#include "mms_handler.h"
May 12, 2014
May 12, 2014
17
#include "mms_settings.h"
Feb 17, 2014
Feb 17, 2014
18
19
20
21
22
23
24
25
26
27
28
29
#include "mms_connection.h"
#include "mms_connman.h"
#include "mms_file_util.h"
#include "mms_codec.h"
#include "mms_util.h"
#include "mms_task.h"
#include <errno.h>
/* Logging */
#define MMS_LOG_MODULE_NAME mms_dispatcher_log
#include "mms_lib_log.h"
Feb 19, 2014
Feb 19, 2014
30
#include "mms_error.h"
Feb 17, 2014
Feb 17, 2014
31
32
33
34
MMS_LOG_MODULE_DEFINE("mms-dispatcher");
struct mms_dispatcher {
gint ref_count;
May 12, 2014
May 12, 2014
35
MMSSettings* settings;
Feb 17, 2014
Feb 17, 2014
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
MMSTask* active_task;
MMSTaskDelegate task_delegate;
MMSHandler* handler;
MMSConnMan* cm;
MMSConnection* connection;
MMSConnectionDelegate connection_delegate;
MMSDispatcherDelegate* delegate;
GQueue* tasks;
guint next_run_id;
guint network_idle_id;
};
typedef void (*MMSDispatcherIdleCallbackProc)(MMSDispatcher* disp);
typedef struct mms_dispatcher_idle_callback {
MMSDispatcher* dispatcher;
MMSDispatcherIdleCallbackProc proc;
} MMSDispatcherIdleCallback;
inline static MMSDispatcher*
mms_dispatcher_from_task_delegate(MMSTaskDelegate* delegate)
{ return MMS_CAST(delegate,MMSDispatcher,task_delegate); }
inline static MMSDispatcher*
mms_dispatcher_from_connection_delegate(MMSConnectionDelegate* delegate)
{ return MMS_CAST(delegate,MMSDispatcher,connection_delegate); }
static
void
mms_dispatcher_run(
MMSDispatcher* disp);
/**
* Close the network connection
*/
static
void
mms_dispatcher_close_connection(
MMSDispatcher* disp)
{
if (disp->connection) {
disp->connection->delegate = NULL;
mms_connection_close(disp->connection);
mms_connection_unref(disp->connection);
disp->connection = NULL;
if (!mms_dispatcher_is_active(disp)) {
/* Report to delegate that we are done */
if (disp->delegate && disp->delegate->fn_done) {
disp->delegate->fn_done(disp->delegate, disp);
}
}
}
if (disp->network_idle_id) {
g_source_remove(disp->network_idle_id);
disp->network_idle_id = 0;
}
}
/**
* Run loop callbacks
*/
static
void
mms_dispatcher_callback_free(
gpointer data)
{
MMSDispatcherIdleCallback* call = data;
mms_dispatcher_unref(call->dispatcher);
g_free(call);
}
static
gboolean
mms_dispatcher_idle_callback_cb(
gpointer data)
{
MMSDispatcherIdleCallback* call = data;
call->proc(call->dispatcher);
return FALSE;
}
static
guint
mms_dispatcher_callback_schedule(
MMSDispatcher* disp,
MMSDispatcherIdleCallbackProc proc)
{
MMSDispatcherIdleCallback* call = g_new0(MMSDispatcherIdleCallback,1);
call->dispatcher = mms_dispatcher_ref(disp);
call->proc = proc;
return g_idle_add_full(G_PRIORITY_HIGH, mms_dispatcher_idle_callback_cb,
call, mms_dispatcher_callback_free);
}
static
guint
mms_dispatcher_timeout_callback_schedule(
MMSDispatcher* disp,
guint interval,
MMSDispatcherIdleCallbackProc proc)
{
MMSDispatcherIdleCallback* call = g_new0(MMSDispatcherIdleCallback,1);
call->dispatcher = mms_dispatcher_ref(disp);
call->proc = proc;
return g_timeout_add_seconds_full(G_PRIORITY_DEFAULT, interval,
mms_dispatcher_idle_callback_cb, call, mms_dispatcher_callback_free);
}
/**
* Network idle timeout
*/
static
void
mms_dispatcher_network_idle_run(
MMSDispatcher* disp)
{
MMS_ASSERT(disp->network_idle_id);
disp->network_idle_id = 0;
mms_dispatcher_close_connection(disp);
}
static
void
mms_dispatcher_network_idle_check(
MMSDispatcher* disp)
{
if (disp->connection && !disp->network_idle_id) {
/* Schedule idle inactivity timeout callback */
MMS_VERBOSE("Network connection is inactive");
disp->network_idle_id = mms_dispatcher_timeout_callback_schedule(disp,
May 12, 2014
May 12, 2014
166
disp->settings->config->idle_secs, mms_dispatcher_network_idle_run);
Feb 17, 2014
Feb 17, 2014
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
}
}
static
void
mms_dispatcher_network_idle_cancel(
MMSDispatcher* disp)
{
if (disp->network_idle_id) {
MMS_VERBOSE("Cancel network inactivity timeout");
g_source_remove(disp->network_idle_id);
disp->network_idle_id = 0;
}
}
/**
* Dispatcher run on a fresh stack
*/
static
void
mms_dispatcher_next_run(
MMSDispatcher* disp)
{
MMS_ASSERT(disp->next_run_id);
MMS_ASSERT(!disp->active_task);
disp->next_run_id = 0;
if (!disp->active_task) {
mms_dispatcher_run(disp);
}
}
static
void
mms_dispatcher_next_run_schedule(
MMSDispatcher* disp)
{
if (disp->next_run_id) g_source_remove(disp->next_run_id);
disp->next_run_id = mms_dispatcher_callback_schedule(disp,
mms_dispatcher_next_run);
}
/**
* Set the delegate that receives dispatcher notifications.
* One delegate per dispatcher.
*/
void
mms_dispatcher_set_delegate(
MMSDispatcher* disp,
MMSDispatcherDelegate* delegate)
{
MMS_ASSERT(!disp->delegate || !delegate);
disp->delegate = delegate;
}
/**
* Checks if dispatcher has something to do.
*/
gboolean
mms_dispatcher_is_active(
MMSDispatcher* disp)
{
return disp && (disp->connection || disp->active_task ||
!g_queue_is_empty(disp->tasks));
}
/**
* Picks the next task for processing. Reference is passed to the caller.
* Caller must eventually dereference the task or place it back to the queue.
*/
static
MMSTask*
mms_dispatcher_pick_next_task(
MMSDispatcher* disp)
{
GList* entry;
gboolean connection_in_use = FALSE;
/* Check the current connection */
if (disp->connection) {
/* Don't interfere with the task transmiting the data */
for (entry = disp->tasks->head; entry; entry = entry->next) {
MMSTask* task = entry->data;
if (task->state == MMS_TASK_STATE_TRANSMITTING) {
MMS_ASSERT(!strcmp(task->imsi, disp->connection->imsi));
return NULL;
}
}
/* Look for another task that has use for the existing connection
* before we close it */
for (entry = disp->tasks->head; entry; entry = entry->next) {
MMSTask* task = entry->data;
if (task->state == MMS_TASK_STATE_NEED_CONNECTION ||
task->state == MMS_TASK_STATE_NEED_USER_CONNECTION) {
if (!strcmp(task->imsi, disp->connection->imsi)) {
if (mms_connection_state(disp->connection) ==
MMS_CONNECTION_STATE_OPEN) {
/* Found a task that can use this connection */
g_queue_delete_link(disp->tasks, entry);
mms_dispatcher_network_idle_cancel(disp);
return task;
}
connection_in_use = TRUE;
}
}
}
}
if (connection_in_use) {
/* Connection is needed but isn't open yet, make sure that network
* inactivity timer is off while connection is being established */
mms_dispatcher_network_idle_cancel(disp);
} else {
/* Then look for a task that needs any sort of network connection */
for (entry = disp->tasks->head; entry; entry = entry->next) {
MMSTask* task = entry->data;
if ((task->state == MMS_TASK_STATE_NEED_CONNECTION ||
task->state == MMS_TASK_STATE_NEED_USER_CONNECTION)) {
mms_dispatcher_close_connection(disp);
disp->connection = mms_connman_open_connection(
disp->cm, task->imsi, FALSE);
if (disp->connection) {
disp->connection->delegate = &disp->connection_delegate;
g_queue_delete_link(disp->tasks, entry);
return task;
} else {
mms_task_network_unavailable(task);
}
}
}
}
/* Finally look for a runnable task that doesn't need network */
for (entry = disp->tasks->head; entry; entry = entry->next) {
MMSTask* task = entry->data;
if (task->state == MMS_TASK_STATE_READY ||
task->state == MMS_TASK_STATE_DONE) {
g_queue_delete_link(disp->tasks, entry);
return task;
}
}
/* Nothing found, we are done for now */
return NULL;
}
/**
* Task dispatch loop.
*/
static
void
mms_dispatcher_run(
MMSDispatcher* disp)
{
MMSTask* task;
MMS_ASSERT(!disp->active_task);
while ((task = mms_dispatcher_pick_next_task(disp)) != NULL) {
MMS_DEBUG("%s %s", task->name, mms_task_state_name(task->state));
disp->active_task = task;
switch (task->state) {
case MMS_TASK_STATE_READY:
mms_task_run(task);
break;
case MMS_TASK_STATE_NEED_CONNECTION:
case MMS_TASK_STATE_NEED_USER_CONNECTION:
MMS_ASSERT(disp->connection);
if (mms_connection_is_open(disp->connection)) {
/* Connection is already active, send/receive the data */
mms_task_transmit(task, disp->connection);
}
break;
default:
break;
}
if (task->state == MMS_TASK_STATE_DONE) {
task->delegate = NULL;
mms_task_unref(task);
} else {
g_queue_push_tail(disp->tasks, task);
}
disp->active_task = NULL;
}
if (disp->connection) {
/* Check if network connection is being used */
GList* entry;
gboolean connection_in_use = FALSE;
for (entry = disp->tasks->head; entry; entry = entry->next) {
MMSTask* task = entry->data;
if (task->state == MMS_TASK_STATE_NEED_CONNECTION ||
task->state == MMS_TASK_STATE_NEED_USER_CONNECTION ||
task->state == MMS_TASK_STATE_TRANSMITTING) {
connection_in_use = TRUE;
break;
}
}
if (connection_in_use) {
/* It's in use, disable idle inactivity callback */
mms_dispatcher_network_idle_cancel(disp);
} else {
/* Make sure that network inactivity timer is ticking */
mms_dispatcher_network_idle_check(disp);
}
}
if (!mms_dispatcher_is_active(disp)) {
/* Report to delegate that we are done */
if (disp->delegate && disp->delegate->fn_done) {
disp->delegate->fn_done(disp->delegate, disp);
}
}
}
/**
* Starts task processing.
*/
gboolean
mms_dispatcher_start(
MMSDispatcher* disp)
{
May 12, 2014
May 12, 2014
391
392
const char* root_dir = disp->settings->config->root_dir;
int err = g_mkdir_with_parents(root_dir, MMS_DIR_PERM);
Feb 17, 2014
Feb 17, 2014
393
394
395
396
397
398
if (!err || errno == EEXIST) {
if (!g_queue_is_empty(disp->tasks)) {
mms_dispatcher_next_run_schedule(disp);
return TRUE;
}
} else {
May 12, 2014
May 12, 2014
399
MMS_ERR("Failed to create %s: %s", root_dir, strerror(errno));
Feb 17, 2014
Feb 17, 2014
400
401
402
403
404
405
406
407
408
409
410
411
412
413
}
return FALSE;
}
static
void
mms_dispatcher_queue_task(
MMSDispatcher* disp,
MMSTask* task)
{
task->delegate = &disp->task_delegate;
g_queue_push_tail(disp->tasks, mms_task_ref(task));
}
Feb 19, 2014
Feb 19, 2014
414
static
Feb 17, 2014
Feb 17, 2014
415
gboolean
Feb 19, 2014
Feb 19, 2014
416
mms_dispatcher_queue_and_unref_task(
Feb 17, 2014
Feb 17, 2014
417
MMSDispatcher* disp,
Feb 19, 2014
Feb 19, 2014
418
MMSTask* task)
Feb 17, 2014
Feb 17, 2014
419
420
421
422
423
424
425
426
427
428
{
if (task) {
mms_dispatcher_queue_task(disp, task);
mms_task_unref(task);
return TRUE;
} else {
return FALSE;
}
}
Feb 19, 2014
Feb 19, 2014
429
430
431
432
433
434
435
/**
* Creates a WAP push receive task and adds it to the queue.
*/
gboolean
mms_dispatcher_handle_push(
MMSDispatcher* disp,
const char* imsi,
Feb 19, 2014
Feb 19, 2014
436
437
GBytes* push,
GError** error)
Feb 19, 2014
Feb 19, 2014
438
439
{
return mms_dispatcher_queue_and_unref_task(disp,
May 12, 2014
May 12, 2014
440
mms_task_notification_new(disp->settings, disp->handler,
Feb 19, 2014
Feb 19, 2014
441
imsi, push, error));
Feb 19, 2014
Feb 19, 2014
442
443
}
Feb 17, 2014
Feb 17, 2014
444
445
446
447
448
449
450
451
452
/**
* Creates download task and adds it to the queue.
*/
gboolean
mms_dispatcher_receive_message(
MMSDispatcher* disp,
const char* id,
const char* imsi,
gboolean automatic,
Feb 19, 2014
Feb 19, 2014
453
454
GBytes* bytes,
GError** error)
Feb 17, 2014
Feb 17, 2014
455
456
457
458
459
460
{
gboolean ok = FALSE;
MMSPdu* pdu = mms_decode_bytes(bytes);
if (pdu) {
MMS_ASSERT(pdu->type == MMS_MESSAGE_TYPE_NOTIFICATION_IND);
if (pdu->type == MMS_MESSAGE_TYPE_NOTIFICATION_IND) {
Feb 19, 2014
Feb 19, 2014
461
ok = mms_dispatcher_queue_and_unref_task(disp,
May 12, 2014
May 12, 2014
462
mms_task_retrieve_new(disp->settings, disp->handler,
Feb 19, 2014
Feb 19, 2014
463
id, imsi, pdu, error));
Feb 17, 2014
Feb 17, 2014
464
465
466
}
mms_message_free(pdu);
} else {
Feb 19, 2014
Feb 19, 2014
467
MMS_ERROR(error, MMS_LIB_ERROR_DECODE, "Failed to decode MMS PDU");
Feb 17, 2014
Feb 17, 2014
468
469
470
471
472
473
474
475
476
477
478
479
480
481
}
return ok;
}
/**
* Sends read report
*/
gboolean
mms_dispatcher_send_read_report(
MMSDispatcher* disp,
const char* id,
const char* imsi,
const char* message_id,
const char* to,
Feb 19, 2014
Feb 19, 2014
482
483
MMSReadStatus status,
GError** error)
Feb 17, 2014
Feb 17, 2014
484
{
Feb 19, 2014
Feb 19, 2014
485
return mms_dispatcher_queue_and_unref_task(disp,
May 12, 2014
May 12, 2014
486
mms_task_read_new(disp->settings, disp->handler,
Feb 19, 2014
Feb 19, 2014
487
id, imsi, message_id, to, status, error));
Feb 17, 2014
Feb 17, 2014
488
489
}
Feb 25, 2014
Feb 25, 2014
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
/**
* Sends MMS message
*/
char*
mms_dispatcher_send_message(
MMSDispatcher* disp,
const char* id,
const char* imsi,
const char* to,
const char* cc,
const char* bcc,
const char* subject,
unsigned int flags,
const MMSAttachmentInfo* parts,
unsigned int nparts,
GError** error)
{
char* default_imsi = NULL;
if (!imsi || !imsi[0]) {
/* No IMSI specified - try the default one */
imsi = default_imsi = mms_connman_default_imsi(disp->cm);
}
if (imsi) {
if (mms_dispatcher_queue_and_unref_task(disp,
May 12, 2014
May 12, 2014
514
mms_task_encode_new(disp->settings, disp->handler, id, imsi,
Feb 25, 2014
Feb 25, 2014
515
516
517
518
519
520
521
522
523
524
to, cc, bcc, subject, flags, parts, nparts, error))) {
return default_imsi ? default_imsi : g_strdup(imsi);
}
} else {
MMS_ERROR(error, MMS_LIB_ERROR_NOSIM,
"No IMSI is provided and none is available");
}
return NULL;
}
Feb 17, 2014
Feb 17, 2014
525
526
527
528
529
530
531
532
533
534
535
/**
* Cancels al the activity associated with the specified message
*/
void
mms_dispatcher_cancel(
MMSDispatcher* disp,
const char* id)
{
GList* entry;
for (entry = disp->tasks->head; entry; entry = entry->next) {
MMSTask* task = entry->data;
Mar 21, 2014
Mar 21, 2014
536
if (mms_task_match_id(task, id)) {
Feb 17, 2014
Feb 17, 2014
537
538
539
mms_task_cancel(task);
}
}
Mar 21, 2014
Mar 21, 2014
540
if (mms_task_match_id(disp->active_task, id)) {
Feb 17, 2014
Feb 17, 2014
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
mms_task_cancel(disp->active_task);
}
}
/**
* Connection delegate callbacks
*/
static
void
mms_dispatcher_delegate_connection_state_changed(
MMSConnectionDelegate* delegate,
MMSConnection* conn)
{
MMSDispatcher* disp = mms_dispatcher_from_connection_delegate(delegate);
MMS_CONNECTION_STATE state = mms_connection_state(conn);
Mar 27, 2014
Mar 27, 2014
556
MMS_DEBUG("%s %s", conn->imsi, mms_connection_state_name(conn));
Feb 17, 2014
Feb 17, 2014
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
MMS_ASSERT(conn == disp->connection);
if (state == MMS_CONNECTION_STATE_FAILED ||
state == MMS_CONNECTION_STATE_CLOSED) {
GList* entry;
mms_dispatcher_close_connection(disp);
for (entry = disp->tasks->head; entry; entry = entry->next) {
MMSTask* task = entry->data;
switch (task->state) {
case MMS_TASK_STATE_NEED_CONNECTION:
case MMS_TASK_STATE_NEED_USER_CONNECTION:
case MMS_TASK_STATE_TRANSMITTING:
if (!strcmp(conn->imsi, task->imsi)) {
mms_task_network_unavailable(task);
}
default:
break;
}
}
}
if (!disp->active_task) {
mms_dispatcher_next_run_schedule(disp);
}
}
/**
* Task delegate callbacks
*/
static
void
mms_dispatcher_delegate_task_queue(
MMSTaskDelegate* delegate,
MMSTask* task)
{
MMSDispatcher* disp = mms_dispatcher_from_task_delegate(delegate);
mms_dispatcher_queue_task(disp, task);
if (!disp->active_task) {
mms_dispatcher_next_run_schedule(disp);
}
}
static
void
mms_dispatcher_delegate_task_state_changed(
MMSTaskDelegate* delegate,
MMSTask* task)
{
MMSDispatcher* disp = mms_dispatcher_from_task_delegate(delegate);
if (!disp->active_task) {
mms_dispatcher_next_run_schedule(disp);
}
}
/**
* Creates the dispatcher object. Caller must clal mms_dispatcher_unref
* when it no longer needs it.
*/
MMSDispatcher*
mms_dispatcher_new(
May 12, 2014
May 12, 2014
615
MMSSettings* settings,
Feb 17, 2014
Feb 17, 2014
616
617
618
619
620
MMSConnMan* cm,
MMSHandler* handler)
{
MMSDispatcher* disp = g_new0(MMSDispatcher, 1);
disp->ref_count = 1;
May 12, 2014
May 12, 2014
621
disp->settings = mms_settings_ref(settings);
Feb 17, 2014
Feb 17, 2014
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
disp->tasks = g_queue_new();
disp->handler = mms_handler_ref(handler);
disp->cm = mms_connman_ref(cm);
disp->task_delegate.fn_task_queue =
mms_dispatcher_delegate_task_queue;
disp->task_delegate.fn_task_state_changed =
mms_dispatcher_delegate_task_state_changed;
disp->connection_delegate.fn_connection_state_changed =
mms_dispatcher_delegate_connection_state_changed;
return disp;
}
/**
* Deinitializer
*/
static
void
mms_dispatcher_finalize(
MMSDispatcher* disp)
{
MMSTask* task;
May 12, 2014
May 12, 2014
643
644
const char* root_dir = disp->settings->config->root_dir;
char* msg_dir = g_strconcat(root_dir, "/" MMS_MESSAGE_DIR "/", NULL);
Feb 17, 2014
Feb 17, 2014
645
646
647
648
649
650
651
652
MMS_VERBOSE_("");
mms_dispatcher_close_connection(disp);
while ((task = g_queue_pop_head(disp->tasks)) != NULL) {
task->delegate = NULL;
mms_task_cancel(task);
mms_task_unref(task);
}
g_queue_free(disp->tasks);
May 12, 2014
May 12, 2014
653
mms_settings_unref(disp->settings);
Feb 17, 2014
Feb 17, 2014
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
mms_handler_unref(disp->handler);
mms_connman_unref(disp->cm);
/* Try to remove the message directory */
remove(msg_dir);
g_free(msg_dir);
}
/**
* Reference counting. NULL argument is safely ignored.
*/
MMSDispatcher*
mms_dispatcher_ref(
MMSDispatcher* disp)
{
if (disp) {
MMS_ASSERT(disp->ref_count > 0);
g_atomic_int_inc(&disp->ref_count);
}
return disp;
}
void
mms_dispatcher_unref(
MMSDispatcher* disp)
{
if (disp) {
MMS_ASSERT(disp->ref_count > 0);
if (g_atomic_int_dec_and_test(&disp->ref_count)) {
mms_dispatcher_finalize(disp);
g_free(disp);
}
}
}
/*
* Local Variables:
* mode: C
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/