| OLD | NEW |
| 1 /* | 1 /* |
| 2 * | 2 * |
| 3 * Connection Manager | 3 * Connection Manager |
| 4 * | 4 * |
| 5 * Copyright (C) 2007-2009 Intel Corporation. All rights reserved. | 5 * Copyright (C) 2007-2009 Intel Corporation. All rights reserved. |
| 6 * | 6 * |
| 7 * This program is free software; you can redistribute it and/or modify | 7 * This program is free software; you can redistribute it and/or modify |
| 8 * it under the terms of the GNU General Public License version 2 as | 8 * it under the terms of the GNU General Public License version 2 as |
| 9 * published by the Free Software Foundation. | 9 * published by the Free Software Foundation. |
| 10 * | 10 * |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 | 352 |
| 353 return 0; | 353 return 0; |
| 354 } | 354 } |
| 355 | 355 |
| 356 static DBusHandlerResult task_filter(DBusConnection *connection, | 356 static DBusHandlerResult task_filter(DBusConnection *connection, |
| 357 DBusMessage *message, void *user_data) | 357 DBusMessage *message, void *user_data) |
| 358 { | 358 { |
| 359 struct connman_task *task; | 359 struct connman_task *task; |
| 360 struct notify_data *notify; | 360 struct notify_data *notify; |
| 361 const char *path, *member; | 361 const char *path, *member; |
| 362 DBusMessage *reply = NULL; |
| 362 | 363 |
| 363 if (dbus_message_get_type(message) != DBUS_MESSAGE_TYPE_METHOD_CALL) | 364 if (dbus_message_get_type(message) != DBUS_MESSAGE_TYPE_METHOD_CALL) |
| 364 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | 365 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
| 365 | 366 |
| 366 if (dbus_message_has_interface(message, | 367 if (dbus_message_has_interface(message, |
| 367 CONNMAN_TASK_INTERFACE) == FALSE) | 368 CONNMAN_TASK_INTERFACE) == FALSE) |
| 368 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | 369 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
| 369 | 370 |
| 370 path = dbus_message_get_path(message); | 371 path = dbus_message_get_path(message); |
| 371 if (path == NULL) | 372 if (path == NULL) |
| 372 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | 373 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
| 373 | 374 |
| 374 task = g_hash_table_lookup(task_hash, path); | 375 task = g_hash_table_lookup(task_hash, path); |
| 375 if (task == NULL) | 376 if (task == NULL) |
| 376 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | 377 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
| 377 | 378 |
| 378 » if (dbus_message_get_no_reply(message) == FALSE) { | 379 » member = dbus_message_get_member(message); |
| 379 » » DBusMessage *reply; | 380 » if (member == NULL) |
| 380 » » dbus_bool_t result; | 381 » » goto send_reply; |
| 381 | 382 |
| 383 notify = g_hash_table_lookup(task->notify, member); |
| 384 if (notify == NULL) |
| 385 goto send_reply; |
| 386 |
| 387 if (notify->func) |
| 388 reply = notify->func(task, message, notify->data); |
| 389 |
| 390 send_reply: |
| 391 if (dbus_message_get_no_reply(message) == FALSE && |
| 392 reply == NULL) { |
| 382 reply = dbus_message_new_method_return(message); | 393 reply = dbus_message_new_method_return(message); |
| 383 if (reply == NULL) | 394 if (reply == NULL) |
| 384 return DBUS_HANDLER_RESULT_NEED_MEMORY; | 395 return DBUS_HANDLER_RESULT_NEED_MEMORY; |
| 396 } |
| 397 |
| 398 if (reply != NULL) { |
| 399 dbus_bool_t result; |
| 385 | 400 |
| 386 result = dbus_connection_send(connection, reply, NULL); | 401 result = dbus_connection_send(connection, reply, NULL); |
| 387 | 402 |
| 388 dbus_message_unref(reply); | 403 dbus_message_unref(reply); |
| 389 } | 404 } |
| 390 | 405 |
| 391 member = dbus_message_get_member(message); | |
| 392 if (member == NULL) | |
| 393 return DBUS_HANDLER_RESULT_HANDLED; | |
| 394 | |
| 395 notify = g_hash_table_lookup(task->notify, member); | |
| 396 if (notify == NULL) | |
| 397 return DBUS_HANDLER_RESULT_HANDLED; | |
| 398 | |
| 399 if (notify->func) | |
| 400 notify->func(task, message, notify->data); | |
| 401 | |
| 402 return DBUS_HANDLER_RESULT_HANDLED; | 406 return DBUS_HANDLER_RESULT_HANDLED; |
| 403 } | 407 } |
| 404 | 408 |
| 405 static const char *task_rule = "type=method_call" | 409 static const char *task_rule = "type=method_call" |
| 406 ",interface=" CONNMAN_TASK_INTERFACE; | 410 ",interface=" CONNMAN_TASK_INTERFACE; |
| 407 | 411 |
| 408 int __connman_task_init(void) | 412 int __connman_task_init(void) |
| 409 { | 413 { |
| 410 _DBG_TASK(""); | 414 _DBG_TASK(""); |
| 411 | 415 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 431 dbus_bus_remove_match(connection, task_rule, NULL); | 435 dbus_bus_remove_match(connection, task_rule, NULL); |
| 432 dbus_connection_flush(connection); | 436 dbus_connection_flush(connection); |
| 433 | 437 |
| 434 g_hash_table_destroy(task_hash); | 438 g_hash_table_destroy(task_hash); |
| 435 task_hash = NULL; | 439 task_hash = NULL; |
| 436 | 440 |
| 437 dbus_connection_remove_filter(connection, task_filter, NULL); | 441 dbus_connection_remove_filter(connection, task_filter, NULL); |
| 438 | 442 |
| 439 dbus_connection_unref(connection); | 443 dbus_connection_unref(connection); |
| 440 } | 444 } |
| OLD | NEW |