static DBusMessage *am_agent_register(DBusConnection *conn, DBusMessage *msg, void *user_data) { const char *sender, *path; unsigned char *codecs; DBusMessageIter iter, array; int length, i; gboolean has_cvsd = FALSE, has_msbc = FALSE; if (agent) return __ofono_error_in_use(msg); sender = dbus_message_get_sender(msg); if (dbus_message_iter_init(msg, &iter) == FALSE) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(&iter, &path); dbus_message_iter_next(&iter); dbus_message_iter_recurse(&iter, &array); dbus_message_iter_get_fixed_array(&array, &codecs, &length); if (length == 0) return __ofono_error_invalid_args(msg); for (i = 0; i < length; i++) { if (codecs[i] == HFP_CODEC_CVSD) has_cvsd = TRUE; else if (codecs[i] == HFP_CODEC_MSBC) has_msbc = TRUE; else return __ofono_error_invalid_args(msg); } DBG("Agent %s registered with the CODECs:%s%s", sender, has_cvsd ? " CVSD" : "", has_msbc ? " mSBC" : ""); if (has_msbc && transparent_sco) has_wideband = TRUE; else { has_wideband = FALSE; DBG("Wideband speech disabled: %s", has_msbc ? "no Transparent SCO support" : "no mSBC support"); } if (has_cvsd == FALSE) { ofono_error("CVSD codec is mandatory"); return __ofono_error_invalid_args(msg); } agent = g_new0(struct agent, 1); agent->owner = g_strdup(sender); agent->path = g_strdup(path); agent->watch = g_dbus_add_disconnect_watch(conn, sender, agent_disconnect, NULL, NULL); return dbus_message_new_method_return(msg); }
static DBusMessage *location_reporting_request(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_location_reporting *lr = data; if (lr->pending != NULL) return __ofono_error_busy(msg); if (lr->enabled) return __ofono_error_in_use(msg); lr->pending = dbus_message_ref(msg); lr->driver->enable(lr, location_reporting_enable_cb, lr); return NULL; }