int __near_agent_init(void) { DBG(""); connection = near_dbus_get_connection(); if (!connection) return -1; g_dbus_register_interface(connection, NFC_PATH, NFC_AGENT_MANAGER_INTERFACE, manager_methods, NULL, NULL, NULL, NULL); /* * Legacy interface, for backward compatibility only. * To be removed after 0.16. */ g_dbus_register_interface(connection, "/", "org.neard.Manager", manager_methods, NULL, NULL, NULL, NULL); ndef_app_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, ndef_agent_free); ho_agent_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, handover_agent_free); return 0; }
static gboolean register_characteristic(const char *chr_uuid, const uint8_t *value, int vlen, const char **props, const char *desc_uuid, const char **desc_props, const char *service_path) { struct characteristic *chr; struct descriptor *desc; static int id = 1; chr = g_new0(struct characteristic, 1); chr->uuid = g_strdup(chr_uuid); chr->value = g_memdup(value, vlen); chr->vlen = vlen; chr->props = props; chr->service = g_strdup(service_path); chr->path = g_strdup_printf("%s/characteristic%d", service_path, id++); if (!g_dbus_register_interface(connection, chr->path, GATT_CHR_IFACE, chr_methods, NULL, chr_properties, chr, chr_iface_destroy)) { printf("Couldn't register characteristic interface\n"); chr_iface_destroy(chr); return FALSE; } if (!desc_uuid) return TRUE; desc = g_new0(struct descriptor, 1); desc->uuid = g_strdup(desc_uuid); desc->chr = chr; desc->props = desc_props; desc->path = g_strdup_printf("%s/descriptor%d", chr->path, id++); if (!g_dbus_register_interface(connection, desc->path, GATT_DESCRIPTOR_IFACE, desc_methods, NULL, desc_properties, desc, desc_iface_destroy)) { printf("Couldn't register descriptor interface\n"); g_dbus_unregister_interface(connection, chr->path, GATT_CHR_IFACE); desc_iface_destroy(desc); return FALSE; } return TRUE; }
dbus_bool_t manager_init(DBusConnection *conn, const char *path) { connection = conn; if (hcid_dbus_use_experimental()) { debug("Registering experimental manager interface"); g_dbus_register_interface(conn, "/", MANAGER_INTERFACE, manager_methods, manager_signals, NULL, NULL, NULL); } return g_dbus_register_interface(conn, path, MANAGER_INTERFACE, old_manager_methods, old_manager_signals, NULL, NULL, NULL); }
int proxy_register(DBusConnection *conn, struct btd_adapter *btd_adapter) { struct serial_adapter *adapter; const char *path; adapter = find_adapter(adapters, btd_adapter); if (adapter) return -EINVAL; adapter = g_new0(struct serial_adapter, 1); adapter->conn = dbus_connection_ref(conn); adapter->btd_adapter = btd_adapter_ref(btd_adapter); path = adapter_get_path(btd_adapter); if (!g_dbus_register_interface(conn, path, SERIAL_MANAGER_INTERFACE, manager_methods, manager_signals, NULL, adapter, manager_path_unregister)) { error("Failed to register %s interface to %s", SERIAL_MANAGER_INTERFACE, path); return -1; } register_stored(adapter); adapters = g_slist_append(adapters, adapter); debug("Registered interface %s on path %s", SERIAL_MANAGER_INTERFACE, path); return 0; }
static int register_proxy_object(struct serial_proxy *prx, char *outpath, size_t size) { struct serial_adapter *adapter = prx->adapter; char path[MAX_PATH_LENGTH + 1]; snprintf(path, MAX_PATH_LENGTH, "%s/proxy%d", adapter_get_path(adapter->btd_adapter), sk_counter++); if (!g_dbus_register_interface(adapter->conn, path, SERIAL_PROXY_INTERFACE, proxy_methods, NULL, NULL, prx, proxy_path_unregister)) { error("D-Bus failed to register %s path", path); return -1; } prx->path = g_strdup(path); adapter->proxies = g_slist_append(adapter->proxies, prx); if (outpath) strncpy(outpath, path, size); debug("Registered proxy: %s", path); return 0; }
/* * Indicate oFono that a SMS driver is ready for operation * * This is called after ofono_sms_create() was done and the modem * driver determined that a modem supports SMS correctly. Once this * call succeeds, the D-BUS interface for SMS goes live. */ void ofono_sms_register(struct ofono_sms *sms) { DBusConnection *conn = ofono_dbus_get_connection(); struct ofono_modem *modem = __ofono_atom_get_modem(sms->atom); const char *path = __ofono_atom_get_path(sms->atom); struct ofono_sim *sim; if (!g_dbus_register_interface(conn, path, OFONO_MESSAGE_MANAGER_INTERFACE, sms_manager_methods, sms_manager_signals, NULL, sms, NULL)) { ofono_error("Could not create %s interface", OFONO_MESSAGE_MANAGER_INTERFACE); return; } ofono_modem_add_interface(modem, OFONO_MESSAGE_MANAGER_INTERFACE); sms->mw_watch = __ofono_modem_add_atom_watch(modem, OFONO_ATOM_TYPE_MESSAGE_WAITING, mw_watch, sms, NULL); sms->netreg_watch = __ofono_modem_add_atom_watch(modem, OFONO_ATOM_TYPE_NETREG, netreg_watch, sms, NULL); sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem); /* * If we have a sim atom, we can uniquely identify the SIM, * otherwise create an sms assembly which doesn't backup the fragment * store. */ if (sim) { const char *imsi; imsi = ofono_sim_get_imsi(sim); sms->assembly = sms_assembly_new(imsi); sms->sr_assembly = status_report_assembly_new(imsi); sms_load_settings(sms, imsi); } else { sms->assembly = sms_assembly_new(NULL); sms->sr_assembly = status_report_assembly_new(NULL); sms->bearer = 3; /* Default to CS then PS */ } if (sms->driver->bearer_set) sms->driver->bearer_set(sms, sms->bearer, bearer_init_callback, sms); sms_restore_tx_queue(sms); sms->text_handlers = __ofono_watchlist_new(g_free); sms->datagram_handlers = __ofono_watchlist_new(g_free); __ofono_atom_register(sms->atom, sms_unregister); }
int __connmanctl_vpn_agent_register(DBusConnection *connection) { char *path = agent_path(); int result; if (vpn_agent_request.registered == true) { fprintf(stderr, "VPN Agent already registered\n"); return -EALREADY; } agent_connection = connection; if (!g_dbus_register_interface(connection, path, VPN_AGENT_INTERFACE, vpn_agent_methods, NULL, NULL, &vpn_agent_request, NULL)) { fprintf(stderr, "Error: Failed to register VPN Agent " "callbacks\n"); return 0; } result = __connmanctl_dbus_method_call(connection, VPN_SERVICE, VPN_PATH, "net.connman.vpn.Manager", "RegisterAgent", vpn_agent_register_return, connection, append_path, path); if (result != -EINPROGRESS) { g_dbus_unregister_interface(connection, agent_path(), VPN_AGENT_INTERFACE); fprintf(stderr, "Error: Failed to register VPN Agent\n"); } return result; }
static void sms_watch(struct ofono_atom *atom, enum ofono_atom_watch_condition cond, void *data) { struct push_notification *pn = data; DBusConnection *conn = ofono_dbus_get_connection(); if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) { g_dbus_unregister_interface(conn, ofono_modem_get_path(pn->modem), PUSH_NOTIFICATION_INTERFACE); return; } DBG("registered"); pn->sms = __ofono_atom_get_data(atom); if (!g_dbus_register_interface(conn, ofono_modem_get_path(pn->modem), PUSH_NOTIFICATION_INTERFACE, push_notification_methods, NULL, NULL, pn, push_notification_cleanup)) { ofono_error("Could not create %s interface", PUSH_NOTIFICATION_INTERFACE); return; } ofono_modem_add_interface(pn->modem, PUSH_NOTIFICATION_INTERFACE); }
void agent_register(DBusConnection *conn, GDBusProxy *manager, const char *capability) { if (agent_registered == TRUE) { bt_shell_printf("Agent is already registered\n"); return; } agent_capability = capability; if (g_dbus_register_interface(conn, AGENT_PATH, AGENT_INTERFACE, methods, NULL, NULL, NULL, NULL) == FALSE) { bt_shell_printf("Failed to register agent object\n"); return; } if (g_dbus_proxy_method_call(manager, "RegisterAgent", register_agent_setup, register_agent_reply, conn, NULL) == FALSE) { bt_shell_printf("Failed to call register agent method\n"); return; } agent_capability = NULL; }
int connman_peer_register(struct connman_peer *peer) { int index; DBG("peer %p", peer); if (peer->path && peer->registered) return -EALREADY; index = connman_device_get_index(peer->device); peer->ipconfig = create_ipconfig(index, peer); if (!peer->ipconfig) return -ENOMEM; peer->path = get_peer_path(peer->device, peer->identifier); DBG("path %s", peer->path); g_hash_table_insert(peers_table, peer->path, peer); g_dbus_register_interface(connection, peer->path, CONNMAN_PEER_INTERFACE, peer_methods, peer_signals, NULL, peer, NULL); peer->registered = true; peer_added(peer); return 0; }
static struct gatt_service *primary_register(DBusConnection *conn, struct btd_device *device, struct gatt_primary *prim, int psm) { struct gatt_service *gatt; const char *device_path; device_path = device_get_path(device); gatt = g_new0(struct gatt_service, 1); gatt->dev = btd_device_ref(device); gatt->prim = prim; gatt->psm = psm; gatt->conn = dbus_connection_ref(conn); gatt->path = g_strdup_printf("%s/service%04x", device_path, prim->range.start); g_dbus_register_interface(gatt->conn, gatt->path, CHAR_INTERFACE, prim_methods, NULL, NULL, gatt, NULL); gatt->chars = load_characteristics(gatt, prim->range.start); g_slist_foreach(gatt->chars, register_characteristic, gatt->path); return gatt; }
struct media_player *media_player_controller_create(const char *path, uint16_t id) { struct media_player *mp; mp = g_new0(struct media_player, 1); mp->device = g_strdup(path); mp->path = g_strdup_printf("%s/player%u", path, id); mp->settings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); mp->track = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); mp->progress = g_timer_new(); if (!g_dbus_register_interface(btd_get_dbus_connection(), mp->path, MEDIA_PLAYER_INTERFACE, media_player_methods, media_player_signals, media_player_properties, mp, NULL)) { error("D-Bus failed to register %s path", mp->path); media_player_destroy(mp); return NULL; } DBG("%s", mp->path); return mp; }
static struct monitor *register_monitor(struct btd_device *device) { const char *path = device_get_path(device); struct monitor *monitor; char *level; monitor = find_monitor(device); if (monitor != NULL) return monitor; level = read_proximity_config(device, "LinkLossAlertLevel"); monitor = g_new0(struct monitor, 1); monitor->device = btd_device_ref(device); monitor->linklosslevel = (level ? : g_strdup("high")); monitor->signallevel = g_strdup("unknown"); monitor->immediatelevel = g_strdup("none"); monitors = g_slist_append(monitors, monitor); if (g_dbus_register_interface(btd_get_dbus_connection(), path, PROXIMITY_INTERFACE, NULL, NULL, monitor_device_properties, monitor, monitor_destroy) == FALSE) { error("D-Bus failed to register %s interface", PROXIMITY_INTERFACE); monitor_destroy(monitor); return NULL; } DBG("Registered interface %s on path %s", PROXIMITY_INTERFACE, path); return monitor; }
int client_manager_init(void) { DBusError derr; struct obc_module *module; dbus_error_init(&derr); conn = manager_dbus_get_connection(); if (conn == NULL) { error("Can't get client D-Bus connection"); return -1; } if (g_dbus_register_interface(conn, CLIENT_PATH, CLIENT_INTERFACE, client_methods, NULL, NULL, NULL, NULL) == FALSE) { error("Can't register client interface"); dbus_connection_unref(conn); conn = NULL; return -1; } for (module = modules; module && module->init; module++) { if (module->init() < 0) continue; DBG("Module %s loaded", module->name); } return 0; }
static struct network_peer *create_peer(struct btd_device *device, const char *path, bdaddr_t *src, bdaddr_t *dst) { struct network_peer *peer; peer = g_new0(struct network_peer, 1); peer->device = btd_device_ref(device); peer->path = g_strdup(path); bacpy(&peer->src, src); bacpy(&peer->dst, dst); if (g_dbus_register_interface(connection, path, NETWORK_PEER_INTERFACE, connection_methods, connection_signals, NULL, peer, path_unregister) == FALSE) { error("D-Bus failed to register %s interface", NETWORK_PEER_INTERFACE); peer_free(peer); return NULL; } DBG("Registered interface %s on path %s", NETWORK_PEER_INTERFACE, path); return peer; }
void gatt_register_profile(DBusConnection *conn, GDBusProxy *proxy, wordexp_t *w) { GList *l; l = g_list_find_custom(managers, proxy, match_proxy); if (!l) { rl_printf("Unable to find GattManager proxy\n"); return; } if (g_dbus_register_interface(conn, PROFILE_PATH, PROFILE_INTERFACE, methods, NULL, NULL, NULL, NULL) == FALSE) { rl_printf("Failed to register profile object\n"); return; } if (g_dbus_proxy_method_call(l->data, "RegisterProfile", register_profile_setup, register_profile_reply, w, NULL) == FALSE) { rl_printf("Failed register profile\n"); return; } }
static struct descriptor *descriptor_create(struct gatt_db_attribute *attr, struct characteristic *chrc) { struct descriptor *desc; desc = new0(struct descriptor, 1); desc->chrc = chrc; desc->attr = attr; desc->handle = gatt_db_attribute_get_handle(attr); bt_uuid_to_uuid128(gatt_db_attribute_get_type(attr), &desc->uuid); desc->path = g_strdup_printf("%s/desc%04x", chrc->path, desc->handle); if (!g_dbus_register_interface(btd_get_dbus_connection(), desc->path, GATT_DESCRIPTOR_IFACE, descriptor_methods, NULL, descriptor_properties, desc, descriptor_free)) { error("Unable to register GATT descriptor with handle 0x%04x", desc->handle); descriptor_free(desc); return NULL; } DBG("Exported GATT characteristic descriptor: %s", desc->path); if (uuid_cmp(&desc->uuid, GATT_CHARAC_EXT_PROPER_UUID)) chrc->ext_props_handle = desc->handle; return desc; }
static int hfp_ag_init(void) { DBusConnection *conn = ofono_dbus_get_connection(); if (DBUS_TYPE_UNIX_FD < 0) return -EBADF; /* Registers External Profile handler */ if (!g_dbus_register_interface(conn, HFP_AG_EXT_PROFILE_PATH, BLUEZ_PROFILE_INTERFACE, profile_methods, NULL, NULL, NULL, NULL)) { ofono_error("Register Profile interface failed: %s", HFP_AG_EXT_PROFILE_PATH); return -EIO; } sim_hash = g_hash_table_new(g_direct_hash, g_direct_equal); modemwatch_id = __ofono_modemwatch_add(modem_watch, NULL, NULL); __ofono_modem_foreach(call_modemwatch, NULL); connection_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, connection_destroy); return 0; }
static int map_probe(struct obc_session *session) { struct map_data *map; const char *path; path = obc_session_get_path(session); DBG("%s", path); map = g_try_new0(struct map_data, 1); if (!map) return -ENOMEM; map->session = obc_session_ref(session); map->messages = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, map_msg_remove); set_notification_registration(map, true); if (!g_dbus_register_interface(conn, path, MAP_INTERFACE, map_methods, NULL, NULL, map, map_free)) { map_free(map); return -ENOMEM; } return 0; }
static struct serial_device *create_serial_device(DBusConnection *conn, const char *path, bdaddr_t *src, bdaddr_t *dst) { struct serial_device *device; device = g_new0(struct serial_device, 1); device->conn = dbus_connection_ref(conn); bacpy(&device->dst, dst); bacpy(&device->src, src); device->path = g_strdup(path); if (!g_dbus_register_interface(conn, path, SERIAL_PORT_INTERFACE, port_methods, NULL, NULL, device, path_unregister)) { error("D-Bus failed to register %s interface", SERIAL_PORT_INTERFACE); serial_device_free(device); return NULL; } debug("Registered interface %s on path %s", SERIAL_PORT_INTERFACE, path); return device; }
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); }
static struct control *control_init(struct btd_service *service) { struct control *control; struct btd_device *dev = btd_service_get_device(service); control = find_control(dev); if (control != NULL) return control; control = g_new0(struct control, 1); if (!g_dbus_register_interface(btd_get_dbus_connection(), device_get_path(dev), AUDIO_CONTROL_INTERFACE, control_methods, NULL, control_properties, control, path_unregister)) { g_free(control); return NULL; } DBG("Registered interface %s on path %s", AUDIO_CONTROL_INTERFACE, device_get_path(dev)); control->dev = dev; control->avctp_id = avctp_add_state_cb(dev, state_changed, control); devices = g_slist_prepend(devices, control); return control; }
static int register_interface(const char *path, struct btd_adapter *adapter) { struct service_adapter *serv_adapter; DBG("path %s", path); serv_adapter = g_try_new0(struct service_adapter, 1); if (serv_adapter == NULL) return -ENOMEM; serv_adapter->adapter = adapter; serv_adapter->pending_list = NULL; if (g_dbus_register_interface(connection, path, SERVICE_INTERFACE, service_methods, NULL, NULL, serv_adapter, path_unregister) == FALSE) { error("D-Bus failed to register %s interface", SERVICE_INTERFACE); g_free(serv_adapter); return -EIO; } DBG("Registered interface %s on path %s", SERVICE_INTERFACE, path); if (serv_adapter->adapter == NULL) serv_adapter_any = serv_adapter; return 0; }
static struct input_device *input_device_new(DBusConnection *conn, struct btd_device *device, const char *path, const bdaddr_t *src, const bdaddr_t *dst, const uint32_t handle) { struct input_device *idev; char name[249], src_addr[18], dst_addr[18]; idev = g_new0(struct input_device, 1); bacpy(&idev->src, src); bacpy(&idev->dst, dst); idev->device = btd_device_ref(device); idev->path = g_strdup(path); idev->conn = dbus_connection_ref(conn); idev->handle = handle; ba2str(src, src_addr); ba2str(dst, dst_addr); if (read_device_name(src_addr, dst_addr, name) == 0) idev->name = g_strdup(name); if (g_dbus_register_interface(conn, idev->path, INPUT_DEVICE_INTERFACE, device_methods, device_signals, NULL, idev, device_unregister) == FALSE) { error("Failed to register interface %s on path %s", INPUT_DEVICE_INTERFACE, path); input_device_free(idev); return NULL; } DBG("Registered interface %s on path %s", INPUT_DEVICE_INTERFACE, idev->path); return idev; }
const char *obc_session_register(struct obc_session *session, GDBusDestroyFunction destroy) { if (session->path) return session->path; session->path = g_strdup_printf("%s/session%ju", SESSION_BASEPATH, counter++); if (g_dbus_register_interface(session->conn, session->path, SESSION_INTERFACE, session_methods, NULL, NULL, session, destroy) == FALSE) goto fail; if (session->driver->probe && session->driver->probe(session) < 0) { g_dbus_unregister_interface(session->conn, session->path, SESSION_INTERFACE); goto fail; } DBG("Session(%p) registered %s", session, session->path); return session->path; fail: g_free(session->path); session->path = NULL; return NULL; }
static struct network_peer *create_peer(struct btd_device *device) { struct network_peer *peer; const char *path; peer = g_new0(struct network_peer, 1); peer->device = btd_device_ref(device); path = device_get_path(device); if (g_dbus_register_interface(btd_get_dbus_connection(), path, NETWORK_PEER_INTERFACE, connection_methods, NULL, connection_properties, peer, path_unregister) == FALSE) { error("D-Bus failed to register %s interface", NETWORK_PEER_INTERFACE); peer_free(peer); return NULL; } DBG("Registered interface %s on path %s", NETWORK_PEER_INTERFACE, path); return peer; }
static int nmcompat_init(void) { DBG(""); connection = connman_dbus_get_connection(); if (connection == NULL) return -1; if (g_dbus_request_name(connection, NM_SERVICE, NULL) == FALSE) { connman_error("nmcompat: failed register service\n"); return -1; } if (connman_notifier_register(¬ifier) < 0) { connman_error("nmcompat: failed to register notifier"); return -1; } if (g_dbus_register_interface(connection, NM_PATH, DBUS_PROPERTIES_INTERFACE, methods, signals, NULL, NULL, NULL) == FALSE) { connman_error("nmcompat: failed to register " DBUS_PROPERTIES_INTERFACE); return -1; } return 0; }
int telephony_init(uint32_t disabled_features, uint32_t disabled_supp_features, enum batt_info_source batt, void *batt_param, gchar *last_number_path) { uint32_t features = AG_FEATURE_REJECT_A_CALL | AG_FEATURE_ENHANCED_CALL_STATUS | AG_FEATURE_EXTENDED_ERROR_RESULT_CODES; DBG(""); features &= ~disabled_features; if (batt != BATT_INFO_DEFAULT) DBG("Ignoring non-default battery info source. "); if (last_number_path != NULL) DBG("Ignoring non-NULL last number path. "); connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); if (g_dbus_register_interface(connection, TELEPHONY_DUMMY_PATH, TELEPHONY_DUMMY_IFACE, dummy_methods, dummy_signals, NULL, NULL, NULL) == FALSE) { error("telephony-dummy interface %s init failed on path %s", TELEPHONY_DUMMY_IFACE, TELEPHONY_DUMMY_PATH); return -1; } telephony_ready_ind(features, dummy_indicators, BTRH_NOT_SUPPORTED, chld_str); return 0; }
int input_device_register(struct btd_service *service) { struct btd_device *device = btd_service_get_device(service); const char *path = device_get_path(device); struct input_device *idev; DBG("%s", path); idev = input_device_new(service); if (!idev) return -EINVAL; if (g_dbus_register_interface(btd_get_dbus_connection(), idev->path, INPUT_INTERFACE, NULL, NULL, input_properties, idev, NULL) == FALSE) { error("Unable to register %s interface", INPUT_INTERFACE); input_device_free(idev); return -EINVAL; } btd_service_set_user_data(service, idev); return 0; }
static void read_adv_features_callback(uint8_t status, uint16_t length, const void *param, void *user_data) { struct btd_advertising *manager = user_data; const struct mgmt_rp_read_adv_features *feat = param; if (status || !param) { error("Failed to read advertising features: %s (0x%02x)", mgmt_errstr(status), status); return; } if (length < sizeof(*feat)) { error("Wrong size of read adv features response"); return; } manager->max_adv_len = feat->max_adv_data_len; manager->max_ads = feat->max_instances; if (manager->max_ads == 0) return; if (!g_dbus_register_interface(btd_get_dbus_connection(), adapter_get_path(manager->adapter), LE_ADVERTISING_MGR_IFACE, methods, NULL, NULL, manager, NULL)) error("Failed to register " LE_ADVERTISING_MGR_IFACE); }