diff options
| author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-06-16 19:43:09 +0000 | 
|---|---|---|
| committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-06-16 19:43:09 +0000 | 
| commit | bbec31284f7e4e960c07bddd9fd1d7ee5c990118 (patch) | |
| tree | 2c4172e283aec7f871f416c400d020fbfc29f796 | |
| parent | 64f07dce7cd9d689fd589908b20a70756b66e243 (diff) | |
Remove calls to RequestAuthorization.
| -rw-r--r-- | audio/manager.c | 91 | ||||
| -rw-r--r-- | network/server.c | 100 | 
2 files changed, 5 insertions, 186 deletions
| diff --git a/audio/manager.c b/audio/manager.c index 630d6017..242f16bb 100644 --- a/audio/manager.c +++ b/audio/manager.c @@ -1183,19 +1183,6 @@ static void auth_cb(DBusError *derr, void *user_data)  	}  } -static void auth_cb_old(DBusPendingCall *call, void *data) -{ -	DBusMessage *reply = dbus_pending_call_steal_reply(call); -	DBusError err; - -	dbus_error_init(&err); -	dbus_set_error_from_message(&err, reply); -	auth_cb(&err, data); -	dbus_error_free(&err); - -	dbus_message_unref(reply); -} -  static void ag_io_cb(GIOChannel *chan, int err, const bdaddr_t *src,  			const bdaddr_t *dst, gpointer data)  { @@ -1232,13 +1219,12 @@ static void ag_io_cb(GIOChannel *chan, int err, const bdaddr_t *src,  		goto drop;  	} -	if (service_req_auth(&device->src, &device->dst, uuid, auth_cb, +	if (!service_req_auth(&device->src, &device->dst, uuid, auth_cb,  				device) == 0) -		headset_set_state(device, HEADSET_STATE_CONNECT_IN_PROGRESS); -	else if (!manager_authorize(&device->dst, uuid, auth_cb_old, device, -				NULL))  		headset_close_rfcomm(device); +	headset_set_state(device, HEADSET_STATE_CONNECT_IN_PROGRESS); +  	return;  drop: @@ -1543,77 +1529,6 @@ struct audio_device *manager_get_connected_device(void)  	return NULL;  } -void manager_cancel_authorize(bdaddr_t *dba, const char *uuid, -				DBusPendingCall *pending) -{ -	DBusMessage *cancel; -	char addr[18], *address = addr; - -	if (pending) -		dbus_pending_call_cancel(pending); - -	cancel = dbus_message_new_method_call("org.bluez", "/org/bluez", -						"org.bluez.Database", -						"CancelAuthorizationRequest"); -	if (!cancel) { -		error("Unable to allocate new method call"); -		return; -	} - -	ba2str(dba, addr); - -	dbus_message_append_args(cancel, DBUS_TYPE_STRING, &address, -					DBUS_TYPE_STRING, &uuid, -					DBUS_TYPE_INVALID); - -	dbus_connection_send(connection, cancel, NULL); - -	dbus_message_unref(cancel); -} - -gboolean manager_authorize(const bdaddr_t *dba, const char *uuid, -				DBusPendingCallNotifyFunction cb, -				void *user_data, -				DBusPendingCall **pending) -{ -	DBusMessage *auth; -	char address[18], *addr_ptr = address; -	DBusPendingCall *p; - -	ba2str(dba, address); - -	debug("Requesting authorization for device %s, UUID %s", -			address, uuid); - -	auth = dbus_message_new_method_call("org.bluez", "/org/bluez", -						"org.bluez.Database", -						"RequestAuthorization"); -	if (!auth) { -		error("Unable to allocate RequestAuthorization method call"); -		return FALSE; -	} - -	dbus_message_append_args(auth, DBUS_TYPE_STRING, &addr_ptr, -					DBUS_TYPE_STRING, &uuid, -					DBUS_TYPE_INVALID); - -	if (!dbus_connection_send_with_reply(connection, auth, &p, -1)) { -		error("Sending of authorization request failed"); -		dbus_message_unref(auth); -		return FALSE; -	} - -	dbus_pending_call_set_notify(p, cb, user_data, NULL); -	if (pending) -		*pending = p; -	else -		dbus_pending_call_unref(p); - -	dbus_message_unref(auth); - -	return TRUE; -} -  struct audio_device *manager_find_device(const bdaddr_t *bda, const char *interface,  					gboolean connected)  { diff --git a/network/server.c b/network/server.c index 8c0a84cf..7d951765 100644 --- a/network/server.c +++ b/network/server.c @@ -310,30 +310,6 @@ static ssize_t send_bnep_ctrl_rsp(int sk, uint16_t val)  	return send(sk, &rsp, sizeof(rsp), 0);  } -static void cancel_authorization_old() -{ -	DBusMessage *msg; -	const char *uuid; - -	msg = dbus_message_new_method_call("org.bluez", "/org/bluez", -						"org.bluez.Database", -						"CancelAuthorizationRequest"); -	if (!msg) { -		error("Unable to allocate new method call"); -		return; -	} - -	uuid = bnep_uuid(setup->dst_role); -	dbus_message_append_args(msg, -			DBUS_TYPE_STRING, &setup->address, -			DBUS_TYPE_STRING, &uuid, -			DBUS_TYPE_INVALID); - -	dbus_connection_send(connection, msg, NULL); - -	dbus_message_unref(msg); -} -  static int server_connadd(struct network_server *ns, int nsk,  			const gchar *address, uint16_t dst_role)  { @@ -372,42 +348,6 @@ static int server_connadd(struct network_server *ns, int nsk,  	return 0;  } -static void req_auth_cb_old(DBusPendingCall *pcall, void *user_data) -{ -	struct network_server *ns = user_data; -	DBusMessage *reply = dbus_pending_call_steal_reply(pcall); -	DBusError derr; -	uint16_t val; - -	if (!setup) { -		info("Authorization cancelled: Client exited"); -		return; -	} - -	dbus_error_init(&derr); -	if (dbus_set_error_from_message(&derr, reply)) { -		error("Access denied: %s", derr.message); -		if (dbus_error_has_name(&derr, DBUS_ERROR_NO_REPLY)) { -			cancel_authorization_old(); -		} -		dbus_error_free(&derr); -		val = BNEP_CONN_NOT_ALLOWED; -		goto done; -	} - -	if (server_connadd(ns, setup->nsk, -			setup->address, setup->dst_role) < 0) -		val = BNEP_CONN_NOT_ALLOWED; -	else -		val = BNEP_SUCCESS; - -done: -	send_bnep_ctrl_rsp(setup->nsk, val); -	dbus_message_unref(reply); -	setup_session_free(setup); -	setup = NULL; -} -  static void req_auth_cb(DBusError *derr, void *user_data)  {  	struct network_server *ns = user_data; @@ -441,40 +381,6 @@ done:  	setup = NULL;  } -static int req_auth_old(const char *address, const char *uuid, void *user_data) -{ -	DBusMessage *msg; -	DBusPendingCall *pending; - -	msg = dbus_message_new_method_call("org.bluez", "/org/bluez", -				"org.bluez.Database", "RequestAuthorization"); -	if (!msg) { -		error("Unable to allocate new RequestAuthorization method call"); -		return -ENOMEM; -	} - -	debug("Requesting authorization for %s UUID:%s", address, uuid); - -	dbus_message_append_args(msg, -			DBUS_TYPE_STRING, &address, -			DBUS_TYPE_STRING, &uuid, -			DBUS_TYPE_INVALID); - -	if (dbus_connection_send_with_reply(connection, -				msg, &pending, -1) == FALSE) { -		error("Sending of authorization request failed"); -		dbus_message_unref(msg); -		return -EACCES; -	} - -	dbus_pending_call_set_notify(pending, -			req_auth_cb_old, user_data, NULL); -	dbus_pending_call_unref(pending); -	dbus_message_unref(msg); - -	return 0; -} -  static int authorize_connection(struct network_server *ns, const char *address)  {  	const char *uuid; @@ -485,10 +391,8 @@ static int authorize_connection(struct network_server *ns, const char *address)  	str2ba(address, &dst);  	ret_val = service_req_auth(&ns->src, &dst, uuid, req_auth_cb, ns); -	if (ret_val < 0) -		return req_auth_old(address, uuid, ns); -	else -		return ret_val; + +	return ret_val;  }  static uint16_t inline bnep_setup_chk(uint16_t dst_role, uint16_t src_role) | 
