gboolean manager_init(void) { DBusError err; DBG(""); dbus_error_init(&err); connection = g_dbus_setup_bus(DBUS_BUS_SESSION, OBEXD_SERVICE, &err); if (connection == NULL) { if (dbus_error_is_set(&err) == TRUE) { fprintf(stderr, "%s\n", err.message); dbus_error_free(&err); } else fprintf(stderr, "Can't register with session bus\n"); return FALSE; } g_dbus_attach_object_manager(connection); return g_dbus_register_interface(connection, OBEX_BASE_PATH, OBEX_MANAGER_INTERFACE, manager_methods, NULL, NULL, NULL, NULL); }
int hcid_dbus_init(void) { DBusConnection *conn; DBusError err; dbus_error_init(&err); conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, BLUEZ_NAME, &err); if (!conn) { if (error != NULL && dbus_error_is_set(&err)) { dbus_error_free(&err); return -EIO; } return -EALREADY; } if (g_dbus_set_disconnect_function(conn, disconnect_callback, NULL, NULL) == FALSE) { dbus_connection_unref(conn); return -EIO; } if (!manager_init(conn, "/")) return -EIO; set_dbus_connection(conn); return 0; }
int main(int argc, char *argv[]) { GDBusClient *client; guint signal; signal = setup_signalfd(); if (signal == 0) return -errno; connection = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, NULL); main_loop = g_main_loop_new(NULL, FALSE); g_dbus_attach_object_manager(connection); printf("gatt-service unique name: %s\n", dbus_bus_get_unique_name(connection)); create_services(); client = g_dbus_client_new(connection, "org.bluez", "/org/bluez"); g_dbus_client_set_connect_watch(client, connect_handler, NULL); g_main_loop_run(main_loop); g_dbus_client_unref(client); g_source_remove(signal); g_slist_free_full(services, g_free); dbus_connection_unref(connection); return 0; }
int main(int argc, char *argv[]) { GDBusClient *client; int status; bt_shell_init(argc, argv, NULL); bt_shell_set_menu(&main_menu); bt_shell_set_prompt(PROMPT_OFF); dbus_conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, NULL); client = g_dbus_client_new(dbus_conn, "org.bluez", "/org/bluez"); g_dbus_client_set_connect_watch(client, connect_handler, NULL); g_dbus_client_set_disconnect_watch(client, disconnect_handler, NULL); g_dbus_client_set_proxy_handlers(client, proxy_added, proxy_removed, property_changed, NULL); status = bt_shell_run(); g_dbus_client_unref(client); dbus_connection_unref(dbus_conn); return status; }
static char *gdbus_create_paired_device(const char *adapter, const char *bdaddr, const char *oobdata, const char *oobrole, int len) { DBusMessage *message, *reply, *adapter_reply; DBusMessageIter iter; char *object_path; conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, NULL); /* printf("Dbus conn: %x\n", conn); */ if (conn == NULL) return NULL; if (adapter == NULL) { message = dbus_message_new_method_call("org.bluez", "/", "org.bluez.Manager", "DefaultAdapter"); adapter_reply = dbus_connection_send_with_reply_and_block(conn, message, -1, NULL ); if (adapter_reply == NULL) { printf("Bluetoothd or adapter unavailable\n"); return NULL; } else { dbus_message_unref(adapter_reply); } if (dbus_message_get_args(adapter_reply, NULL, DBUS_TYPE_OBJECT_PATH, &adapter, DBUS_TYPE_INVALID) == FALSE ) return NULL; } printf("Bluetoothd adapter path: %s\n", adapter); message = dbus_message_new_method_call("org.bluez", adapter, "org.bluez.Adapter", "CreateOOBDevice"); dbus_message_iter_init_append(message, &iter); dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &bdaddr); dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &oobrole); dbus_message_iter_append_basic(&iter, DBUS_TYPE_ARRAY, &oobdata); reply = dbus_connection_send_with_reply_and_block(conn, message, -1, NULL ); if (!reply) return NULL; if (dbus_message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID) == FALSE) return NULL; dbus_message_unref(reply); dbus_connection_unref(conn); return object_path; }
int main(int argc, char *argv[]) { DBusConnection *conn; DBusError err; struct sigaction sa; main_loop = g_main_loop_new(NULL, FALSE); dbus_error_init(&err); conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, &err); if (conn == NULL) { if (dbus_error_is_set(&err) == TRUE) { fprintf(stderr, "%s\n", err.message); dbus_error_free(&err); } else fprintf(stderr, "Can't register with system bus\n"); exit(1); } openlog("supplicant", LOG_NDELAY | LOG_PERROR, LOG_USER); g_dbus_set_disconnect_function(conn, disconnect_callback, NULL, NULL); memset(&sa, 0, sizeof(sa)); sa.sa_handler = sig_term; sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); syslog(LOG_INFO, "Startup"); if (supplicant_register(&callbacks) < 0) { syslog(LOG_ERR, "Failed to init supplicant"); goto done; } g_main_loop_run(main_loop); supplicant_unregister(&callbacks); done: syslog(LOG_INFO, "Exit"); dbus_connection_unref(conn); g_main_loop_unref(main_loop); closelog(); return 0; }
int main(int argc, char *argv[]) { GOptionContext *context; GError *error = NULL; DBusConnection *dbus_conn; GDBusClient *client; guint signal; context = g_option_context_new(NULL); g_option_context_add_main_entries(context, options, NULL); if (g_option_context_parse(context, &argc, &argv, &error) == FALSE) { if (error != NULL) { g_printerr("%s\n", error->message); g_error_free(error); } else g_printerr("An unknown error occurred\n"); exit(1); } g_option_context_free(context); if (option_version == TRUE) { g_print("%s\n", VERSION); exit(0); } main_loop = g_main_loop_new(NULL, FALSE); dbus_conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, NULL); signal = setup_signalfd(); client = g_dbus_client_new(dbus_conn, "org.bluez", "/org/bluez"); g_dbus_client_set_connect_watch(client, connect_handler, client); g_dbus_client_set_disconnect_watch(client, disconnect_handler, NULL); g_main_loop_run(main_loop); g_dbus_client_unref(client); g_source_remove(signal); dbus_connection_unref(dbus_conn); g_main_loop_unref(main_loop); return 0; }
int hcid_dbus_init(void) { DBusConnection *conn; conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, BLUEZ_NAME, NULL); if (!conn) return -1; if (g_dbus_set_disconnect_function(conn, disconnect_callback, NULL, NULL) == FALSE) { dbus_connection_unref(conn); return -1; } if (!manager_init(conn, "/")) return -1; set_dbus_connection(conn); return 0; }
static guint bluetooth_connect(const char *source, const char *destination, const char *service, uint16_t port, obc_transport_func func, void *user_data) { struct bluetooth_session *session; static guint id = 0; DBG(""); if (destination == NULL) return 0; session = g_try_malloc0(sizeof(*session)); if (session == NULL) return 0; session->id = ++id; session->func = func; session->user_data = user_data; session->conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, NULL); if (session->conn == NULL) { g_free(session); return 0; } session->service = g_strdup(service); str2ba(destination, &session->dst); if (find_adapter(session, source) < 0) { g_free(session); return 0; } sessions = g_slist_prepend(sessions, session); return session->id; }
int main(int argc, char *argv[]) { GOptionContext *context; GError *error = NULL; DBusConnection *conn; DBusError err; guint signal; context = g_option_context_new(NULL); g_option_context_add_main_entries(context, options, NULL); if (!g_option_context_parse(context, &argc, &argv, &error)) { if (error) { g_printerr("%s\n", error->message); g_error_free(error); } else g_printerr("An unknown error occurred\n"); exit(1); } g_option_context_free(context); if (option_version) { printf("%s\n", VERSION); exit(0); } if (option_detach) { if (daemon(0, 0)) { perror("Can't start daemon"); exit(1); } } if (mkdir(VPN_STATEDIR, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0) { if (errno != EEXIST) perror("Failed to create state directory"); } /* * At some point the VPN stuff is migrated into VPN_STORAGEDIR * and this mkdir() call can be removed. */ if (mkdir(STORAGEDIR, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0) { if (errno != EEXIST) perror("Failed to create storage directory"); } if (mkdir(VPN_STORAGEDIR, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0) { if (errno != EEXIST) perror("Failed to create VPN storage directory"); } umask(0077); main_loop = g_main_loop_new(NULL, FALSE); signal = setup_signalfd(); dbus_error_init(&err); conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, VPN_SERVICE, &err); if (!conn) { if (dbus_error_is_set(&err)) { fprintf(stderr, "%s\n", err.message); dbus_error_free(&err); } else fprintf(stderr, "Can't register with system bus\n"); exit(1); } g_dbus_set_disconnect_function(conn, disconnect_callback, NULL, NULL); __connman_log_init(argv[0], option_debug, option_detach, false, "Connection Manager VPN daemon", VERSION); __connman_dbus_init(conn); __connman_inotify_init(); __connman_storage_init(); if (!option_config) config_init(CONFIGMAINFILE); else config_init(option_config); __connman_agent_init(); __vpn_provider_init(option_routes); __vpn_manager_init(); __vpn_ipconfig_init(); __vpn_rtnl_init(); __connman_task_init(); __connman_plugin_init(option_plugin, option_noplugin); __vpn_config_init(); __vpn_rtnl_start(); g_free(option_plugin); g_free(option_noplugin); g_main_loop_run(main_loop); g_source_remove(signal); __vpn_config_cleanup(); __connman_plugin_cleanup(); __connman_task_cleanup(); __vpn_rtnl_cleanup(); __vpn_ipconfig_cleanup(); __vpn_manager_cleanup(); __vpn_provider_cleanup(); __connman_agent_cleanup(); __connman_storage_cleanup(); __connman_inotify_cleanup(); __connman_dbus_cleanup(); __connman_log_cleanup(false); dbus_connection_unref(conn); g_main_loop_unref(main_loop); g_free(option_debug); return 0; }
int main(int argc, char **argv) { GOptionContext *context; GError *err = NULL; DBusConnection *conn; DBusError error; guint signal; #ifdef NEED_THREADS if (g_thread_supported() == FALSE) g_thread_init(NULL); #endif context = g_option_context_new(NULL); g_option_context_add_main_entries(context, options, NULL); if (g_option_context_parse(context, &argc, &argv, &err) == FALSE) { if (err != NULL) { g_printerr("%s\n", err->message); g_error_free(err); return 1; } g_printerr("An unknown error occurred\n"); return 1; } g_option_context_free(context); if (option_version == TRUE) { printf("%s\n", VERSION); exit(0); } if (option_detach == TRUE) { if (daemon(0, 0)) { perror("Can't start daemon"); return 1; } } event_loop = g_main_loop_new(NULL, FALSE); #ifdef NEED_THREADS if (dbus_threads_init_default() == FALSE) { fprintf(stderr, "Can't init usage of threads\n"); exit(1); } #endif signal = setup_signalfd(); __ofono_log_init(argv[0], option_debug, option_detach, option_backtrace); dbus_error_init(&error); conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, OFONO_SERVICE, &error); if (conn == NULL) { if (dbus_error_is_set(&error) == TRUE) { ofono_error("Unable to hop onto D-Bus: %s", error.message); dbus_error_free(&error); } else { ofono_error("Unable to hop onto D-Bus"); } goto cleanup; } g_dbus_set_disconnect_function(conn, system_bus_disconnected, NULL, NULL); __ofono_dbus_init(conn); __ofono_modemwatch_init(); __ofono_manager_init(); __ofono_plugin_init(option_plugin, option_noplugin); g_free(option_plugin); g_free(option_noplugin); g_main_loop_run(event_loop); __ofono_plugin_cleanup(); __ofono_manager_cleanup(); __ofono_modemwatch_cleanup(); __ofono_dbus_cleanup(); dbus_connection_unref(conn); cleanup: g_source_remove(signal); g_main_loop_unref(event_loop); __ofono_log_cleanup(option_backtrace); return 0; }
int main(int argc, char **argv) { GOptionContext *context; GError *error = NULL; DBusConnection *conn; DBusError err; guint watch; struct sigaction sa; #ifdef NEED_THREADS if (g_thread_supported() == FALSE) g_thread_init(NULL); #endif context = g_option_context_new(NULL); g_option_context_add_main_entries(context, options, NULL); if (g_option_context_parse(context, &argc, &argv, &error) == FALSE) { if (error != NULL) { g_printerr("%s\n", error->message); g_error_free(error); } else g_printerr("An unknown error occurred\n"); exit(1); } g_option_context_free(context); if (option_version == TRUE) { printf("%s\n", VERSION); exit(0); } main_loop = g_main_loop_new(NULL, FALSE); #ifdef NEED_THREADS if (dbus_threads_init_default() == FALSE) { fprintf(stderr, "Can't init usage of threads\n"); exit(1); } #endif dbus_error_init(&err); conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, &err); if (conn == NULL) { if (dbus_error_is_set(&err) == TRUE) { fprintf(stderr, "%s\n", err.message); dbus_error_free(&err); } else fprintf(stderr, "Can't register with system bus\n"); exit(1); } g_dbus_set_disconnect_function(conn, disconnect_callback, NULL, NULL); memset(&sa, 0, sizeof(sa)); sa.sa_handler = sig_term; sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); watch = g_dbus_add_service_watch(conn, OFONO_SERVICE, ofono_connect, ofono_disconnect, NULL, NULL); g_main_loop_run(main_loop); g_dbus_remove_watch(conn, watch); if (ofono_running == TRUE) ofono_disconnect(conn, NULL); dbus_connection_unref(conn); g_main_loop_unref(main_loop); return 0; }
int main(int argc, char *argv[]) { GOptionContext *context; GError *error = NULL; DBusConnection *conn; DBusError err; struct sigaction sa; mode_t old_umask; #ifdef NEED_THREADS if (g_thread_supported() == FALSE) g_thread_init(NULL); #endif context = g_option_context_new(NULL); g_option_context_add_main_entries(context, options, NULL); if (g_option_context_parse(context, &argc, &argv, &error) == FALSE) { if (error != NULL) { g_printerr("%s\n", error->message); g_error_free(error); } else g_printerr("An unknown error occurred\n"); exit(1); } g_option_context_free(context); if (option_version == TRUE) { printf("%s\n", VERSION); exit(0); } if (option_detach == TRUE) { if (daemon(0, 0)) { perror("Can't start daemon"); exit(1); } } if (mkdir(STATEDIR, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0) { if (errno != EEXIST) perror("Failed to create state directory"); } if (mkdir(STORAGEDIR, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0) { if (errno != EEXIST) perror("Failed to create storage directory"); } old_umask = umask(077); main_loop = g_main_loop_new(NULL, FALSE); #ifdef NEED_THREADS if (dbus_threads_init_default() == FALSE) { fprintf(stderr, "Can't init usage of threads\n"); exit(1); } #endif dbus_error_init(&err); conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, CONNMAN_SERVICE, &err); if (conn == NULL) { if (dbus_error_is_set(&err) == TRUE) { fprintf(stderr, "%s\n", err.message); dbus_error_free(&err); } else fprintf(stderr, "Can't register with system bus\n"); exit(1); } g_dbus_set_disconnect_function(conn, disconnect_callback, NULL, NULL); if (option_compat == TRUE) { if (g_dbus_request_name(conn, NM_SERVICE, NULL) == FALSE) { fprintf(stderr, "Can't register compat service\n"); option_compat = FALSE; } } __connman_log_init(option_detach, option_debug ? DBG_ANY : 0); if (option_selftest == TRUE) { if (__connman_selftest() < 0) { connman_error("Self testing routines failed"); goto selftest; } } __connman_dbus_init(conn); __connman_storage_init(); __connman_element_init(option_device, option_nodevice); __connman_agent_init(); __connman_manager_init(option_compat); __connman_profile_init(); __connman_resolver_init(); __connman_ipconfig_init(); __connman_rtnl_init(); __connman_udev_init(); __connman_task_init(); __connman_plugin_init(option_plugin, option_noplugin); __connman_element_start(); g_free(option_device); g_free(option_plugin); g_free(option_nodevice); g_free(option_noplugin); memset(&sa, 0, sizeof(sa)); sa.sa_handler = sig_term; sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); g_main_loop_run(main_loop); __connman_element_stop(); __connman_plugin_cleanup(); __connman_task_cleanup(); __connman_udev_cleanup(); __connman_rtnl_cleanup(); __connman_ipconfig_cleanup(); __connman_resolver_cleanup(); __connman_profile_cleanup(); __connman_manager_cleanup(); __connman_agent_cleanup(); __connman_element_cleanup(); __connman_storage_cleanup(); __connman_dbus_cleanup(); selftest: __connman_log_cleanup(); dbus_connection_unref(conn); g_main_loop_unref(main_loop); return 0; }
int main(int argc, char *argv[]) { GOptionContext *context; GError *error = NULL; DBusConnection *conn; DBusError err; guint signal; #ifdef NEED_THREADS if (g_thread_supported() == FALSE) g_thread_init(NULL); #endif context = g_option_context_new(NULL); g_option_context_add_main_entries(context, options, NULL); if (g_option_context_parse(context, &argc, &argv, &error) == FALSE) { if (error != NULL) { g_printerr("%s\n", error->message); g_error_free(error); } else g_printerr("An unknown error occurred\n"); exit(1); } g_option_context_free(context); if (option_version == TRUE) { printf("%s\n", VERSION); exit(0); } if (option_detach == TRUE) { if (daemon(0, 0)) { perror("Can't start daemon"); exit(1); } } if (mkdir(STATEDIR, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0) { if (errno != EEXIST) perror("Failed to create state directory"); } if (mkdir(STORAGEDIR, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0) { if (errno != EEXIST) perror("Failed to create storage directory"); } umask(0077); main_loop = g_main_loop_new(NULL, FALSE); #ifdef NEED_THREADS if (dbus_threads_init_default() == FALSE) { fprintf(stderr, "Can't init usage of threads\n"); exit(1); } #endif signal = setup_signalfd(); dbus_error_init(&err); conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, CONNMAN_SERVICE, &err); if (conn == NULL) { if (dbus_error_is_set(&err) == TRUE) { fprintf(stderr, "%s\n", err.message); dbus_error_free(&err); } else fprintf(stderr, "Can't register with system bus\n"); exit(1); } g_dbus_set_disconnect_function(conn, disconnect_callback, NULL, NULL); __connman_log_init(argv[0], option_debug, option_detach, option_backtrace, "Connection Manager", VERSION); __connman_dbus_init(conn); if (option_config == NULL) config_init(CONFIGMAINFILE); else config_init(option_config); __connman_inotify_init(); __connman_technology_init(); __connman_notifier_init(); __connman_agent_init(); __connman_service_init(); __connman_provider_init(); __connman_network_init(); __connman_device_init(option_device, option_nodevice); __connman_ippool_init(); __connman_iptables_init(); __connman_firewall_init(); __connman_nat_init(); __connman_tethering_init(); __connman_counter_init(); __connman_manager_init(); __connman_config_init(); __connman_stats_init(); __connman_clock_init(); __connman_resolver_init(option_dnsproxy); __connman_ipconfig_init(); __connman_rtnl_init(); __connman_task_init(); __connman_proxy_init(); __connman_detect_init(); __connman_session_init(); __connman_timeserver_init(); __connman_connection_init(); __connman_plugin_init(option_plugin, option_noplugin); __connman_rtnl_start(); __connman_dhcp_init(); __connman_dhcpv6_init(); __connman_wpad_init(); __connman_wispr_init(); __connman_rfkill_init(); g_free(option_config); g_free(option_device); g_free(option_plugin); g_free(option_nodevice); g_free(option_noplugin); #ifdef SYSTEMD /* Tell systemd that we have started up */ if( option_systemd ) sd_notify(0, "READY=1"); #endif g_main_loop_run(main_loop); g_source_remove(signal); __connman_rfkill_cleanup(); __connman_wispr_cleanup(); __connman_wpad_cleanup(); __connman_dhcpv6_cleanup(); __connman_dhcp_cleanup(); __connman_session_cleanup(); __connman_plugin_cleanup(); __connman_provider_cleanup(); __connman_connection_cleanup(); __connman_timeserver_cleanup(); __connman_detect_cleanup(); __connman_proxy_cleanup(); __connman_task_cleanup(); __connman_rtnl_cleanup(); __connman_resolver_cleanup(); __connman_clock_cleanup(); __connman_stats_cleanup(); __connman_config_cleanup(); __connman_manager_cleanup(); __connman_counter_cleanup(); __connman_tethering_cleanup(); __connman_nat_cleanup(); __connman_firewall_cleanup(); __connman_iptables_cleanup(); __connman_ippool_cleanup(); __connman_device_cleanup(); __connman_network_cleanup(); __connman_service_cleanup(); __connman_agent_cleanup(); __connman_ipconfig_cleanup(); __connman_notifier_cleanup(); __connman_technology_cleanup(); __connman_inotify_cleanup(); __connman_dbus_cleanup(); __connman_log_cleanup(option_backtrace); dbus_connection_unref(conn); g_main_loop_unref(main_loop); if (connman_settings.pref_timeservers != NULL) g_strfreev(connman_settings.pref_timeservers); g_free(connman_settings.auto_connect); g_free(connman_settings.preferred_techs); g_strfreev(connman_settings.fallback_nameservers); g_strfreev(connman_settings.blacklisted_interfaces); g_strfreev(connman_settings.tethering_technologies); g_free(option_debug); return 0; }
struct obc_session *obc_session_create(const char *source, const char *destination, const char *service, uint8_t channel, const char *owner, session_callback_t function, void *user_data) { struct obc_session *session; struct callback_data *callback; struct pending_req *req; struct obc_driver *driver; if (destination == NULL) return NULL; session = session_find(source, destination, service, channel, owner); if (session) { obc_session_ref(session); goto proceed; } driver = obc_driver_find(service); if (!driver) return NULL; session = g_try_malloc0(sizeof(*session)); if (session == NULL) return NULL; session->refcount = 1; session->channel = channel; session->conn = dbus_bus_get(DBUS_BUS_SESSION, NULL); if (session->conn == NULL) { session_free(session); return NULL; } session->conn_system = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, NULL); if (session->conn_system == NULL) { session_free(session); return NULL; } if (source == NULL) bacpy(&session->src, BDADDR_ANY); else str2ba(source, &session->src); str2ba(destination, &session->dst); session->driver = driver; DBG("driver %s", driver->service); proceed: callback = g_try_malloc0(sizeof(*callback)); if (callback == NULL) { obc_session_unref(session); return NULL; } callback->session = obc_session_ref(session); callback->func = function; callback->data = user_data; if (source) { req = send_method_call(session->conn_system, BT_BUS_NAME, BT_PATH, BT_MANAGER_IFACE, "FindAdapter", manager_reply, callback, DBUS_TYPE_STRING, &source, DBUS_TYPE_INVALID); } else { req = send_method_call(session->conn_system, BT_BUS_NAME, BT_PATH, BT_MANAGER_IFACE, "DefaultAdapter", manager_reply, callback, DBUS_TYPE_INVALID); } if (!req) { obc_session_unref(session); g_free(callback); return NULL; } session->pending_calls = g_slist_prepend(session->pending_calls, req); if (owner) obc_session_set_owner(session, owner, owner_disconnected); return session; }