static int bluetooth_sap_probe(const char *device, const char *dev_addr, const char *adapter_addr, const char *alias) { struct ofono_modem *modem; char buf[256]; if (sap_hw_modem == NULL) return -ENODEV; /* We already have this device in our hash, ignore */ if (g_hash_table_lookup(modem_hash, device) != NULL) return -EALREADY; ofono_info("Using device: %s, devaddr: %s, adapter: %s", device, dev_addr, adapter_addr); strcpy(buf, "sap/"); bluetooth_create_path(dev_addr, adapter_addr, buf + 4, sizeof(buf) - 4); modem = ofono_modem_create(buf, "sap"); if (modem == NULL) return -ENOMEM; ofono_modem_set_string(modem, "ServerPath", device); ofono_modem_set_name(modem, alias); ofono_modem_register(modem); g_hash_table_insert(modem_hash, g_strdup(device), modem); return 0; }
static void alias_changed(GDBusProxy *proxy, const char *name, DBusMessageIter *iter, void *user_data) { const char *alias; struct ofono_modem *modem = user_data; if (g_str_equal("Alias", name) == FALSE) return; dbus_message_iter_get_basic(iter, &alias); ofono_modem_set_name(modem, alias); }
static void hfp_hf_set_alias(const char *device, const char *alias) { struct ofono_modem *modem; if (device == NULL || alias == NULL) return; modem = g_hash_table_lookup(modem_hash, device); if (modem == NULL) return; ofono_modem_set_name(modem, alias); }
static int hfp_hf_probe(const char *device, const char *dev_addr, const char *adapter_addr, const char *alias) { struct ofono_modem *modem; struct hfp_data *data; char buf[256]; /* We already have this device in our hash, ignore */ if (g_hash_table_lookup(modem_hash, device) != NULL) return -EALREADY; ofono_info("Using device: %s, devaddr: %s, adapter: %s", device, dev_addr, adapter_addr); strcpy(buf, "hfp/"); bluetooth_create_path(dev_addr, adapter_addr, buf + 4, sizeof(buf) - 4); modem = ofono_modem_create(buf, "hfp"); if (modem == NULL) return -ENOMEM; data = g_try_new0(struct hfp_data, 1); if (data == NULL) goto free; data->handsfree_path = g_strdup(device); if (data->handsfree_path == NULL) goto free; data->handsfree_address = g_strdup(dev_addr); if (data->handsfree_address == NULL) goto free; ofono_modem_set_data(modem, data); ofono_modem_set_name(modem, alias); ofono_modem_register(modem); g_hash_table_insert(modem_hash, g_strdup(device), modem); return 0; free: if (data != NULL) g_free(data->handsfree_path); g_free(data); ofono_modem_remove(modem); return -ENOMEM; }
static struct ofono_modem *modem_register(const char *device, const char *device_address, const char *alias) { struct ofono_modem *modem; char *path; path = g_strconcat("hfp", device, NULL); modem = ofono_modem_create(path, "hfp"); g_free(path); if (modem == NULL) return NULL; ofono_modem_set_string(modem, "Remote", device_address); ofono_modem_set_string(modem, "DevicePath", device); ofono_modem_set_name(modem, alias); ofono_modem_register(modem); return modem; }