diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2006-08-21 08:54:58 +0000 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2006-08-21 08:54:58 +0000 |
commit | 46b2bfea1a997ffacc4c46c53532681efdfa4a52 (patch) | |
tree | b1b86d2b9b0335b5b940ebeecb7f07f554b1be83 | |
parent | a40e1911412ced9760813416f162df9ef4f35c88 (diff) |
Remove UnknownAddress error (since it's unnecessary)
-rw-r--r-- | hcid/dbus-adapter.c | 51 | ||||
-rw-r--r-- | hcid/dbus-api.txt | 17 | ||||
-rw-r--r-- | hcid/dbus-error.c | 12 | ||||
-rw-r--r-- | hcid/dbus-sdp.c | 22 | ||||
-rw-r--r-- | hcid/dbus.h | 2 |
5 files changed, 19 insertions, 85 deletions
diff --git a/hcid/dbus-adapter.c b/hcid/dbus-adapter.c index 0feccf0b..29eb9ab1 100644 --- a/hcid/dbus-adapter.c +++ b/hcid/dbus-adapter.c @@ -1351,16 +1351,6 @@ static DBusHandlerResult handle_dev_get_remote_name_req(DBusConnection *conn, DB if (check_address(peer_addr) < 0) return error_invalid_arguments(conn, msg); - /* check if it is a unknown address */ - create_name(filename, PATH_MAX, STORAGEDIR, dbus_data->address, "lastseen"); - - str = textfile_get(filename, peer_addr); - - if (!str) - return error_unknown_address(conn, msg); - - free(str); - /* check if it is in the cache */ create_name(filename, PATH_MAX, STORAGEDIR, dbus_data->address, "names"); @@ -1439,18 +1429,17 @@ static DBusHandlerResult handle_dev_get_remote_alias_req(DBusConnection *conn, D static DBusHandlerResult handle_dev_set_remote_alias_req(DBusConnection *conn, DBusMessage *msg, void *data) { - char filename[PATH_MAX + 1]; struct hci_dbus_data *dbus_data = data; DBusMessage *reply, *signal; DBusError err; - char *str_ptr, *addr_ptr, *find_ptr; + char *alias, *addr; bdaddr_t bdaddr; int ecode; dbus_error_init(&err); dbus_message_get_args(msg, &err, - DBUS_TYPE_STRING, &addr_ptr, - DBUS_TYPE_STRING, &str_ptr, + DBUS_TYPE_STRING, &addr, + DBUS_TYPE_STRING, &alias, DBUS_TYPE_INVALID); if (dbus_error_is_set(&err)) { @@ -1459,24 +1448,14 @@ static DBusHandlerResult handle_dev_set_remote_alias_req(DBusConnection *conn, D return error_invalid_arguments(conn, msg); } - if ((strlen(str_ptr) == 0) || (check_address(addr_ptr) < 0)) { + if ((strlen(alias) == 0) || (check_address(addr) < 0)) { error("Alias change failed: Invalid parameter"); return error_invalid_arguments(conn, msg); } - /* check if it is a unknown address */ - create_name(filename, PATH_MAX, STORAGEDIR, dbus_data->address, "lastseen"); - - find_ptr = textfile_get(filename, addr_ptr); + str2ba(addr, &bdaddr); - if (!find_ptr) - return error_unknown_address(conn, msg); - - free(find_ptr); - - str2ba(addr_ptr, &bdaddr); - - ecode = set_device_alias(dbus_data->dev_id, &bdaddr, str_ptr); + ecode = set_device_alias(dbus_data->dev_id, &bdaddr, alias); if (ecode < 0) return error_failed(conn, msg, -ecode); @@ -1485,8 +1464,8 @@ static DBusHandlerResult handle_dev_set_remote_alias_req(DBusConnection *conn, D return DBUS_HANDLER_RESULT_NEED_MEMORY; signal = dev_signal_factory(dbus_data->dev_id, "RemoteAliasChanged", - DBUS_TYPE_STRING, &addr_ptr, - DBUS_TYPE_STRING, &str_ptr, + DBUS_TYPE_STRING, &addr, + DBUS_TYPE_STRING, &alias, DBUS_TYPE_INVALID); if (signal) { dbus_connection_send(conn, signal, NULL); @@ -1701,8 +1680,7 @@ static DBusHandlerResult handle_dev_create_bonding_req(DBusConnection *conn, DBu auth_requested_cp ar_cp; evt_cmd_status rp; DBusError err; - char *peer_addr = NULL; - char *str; + char *str, *peer_addr = NULL; struct hci_dbus_data *dbus_data = data; struct slist *l; bdaddr_t peer_bdaddr; @@ -1744,15 +1722,6 @@ static DBusHandlerResult handle_dev_create_bonding_req(DBusConnection *conn, DBu return error_bonding_already_exists(conn, msg); } - /* check if the address belongs to the last seen cache */ - create_name(filename, PATH_MAX, STORAGEDIR, dbus_data->address, "lastseen"); - - str = textfile_get(filename, peer_addr); - if (!str) - return error_unknown_address(conn, msg); - - free(str); - dd = hci_open_dev(dbus_data->dev_id); if (dd < 0) return error_no_such_adapter(conn, msg); @@ -1852,7 +1821,7 @@ static DBusHandlerResult handle_dev_cancel_bonding_req(DBusConnection *conn, DBu /* check if there is a pending bonding request */ if (!dbus_data->bonding || bacmp(&dbus_data->bonding->bdaddr, &peer_bdaddr)) { error("No bonding request pending."); - return error_unknown_address(conn, msg); + return error_bonding_not_in_progress(conn, msg); } if (strcmp(dbus_data->requestor_name, dbus_message_get_sender(msg))) diff --git a/hcid/dbus-api.txt b/hcid/dbus-api.txt index dece38e2..35d60264 100644 --- a/hcid/dbus-api.txt +++ b/hcid/dbus-api.txt @@ -77,11 +77,6 @@ Errors Failed Error returned when the requested adapter doesn't exists. This error is similar to ENODEV. - UnknownAddress - - Error returned when the remote address haven't been - seen by a discovery procedure so far. - NotAvailable Error returned when a specified record is not @@ -488,7 +483,6 @@ Methods string GetAddress() Example: "00:11:22:33:44:55", "Nokia 770" Possible errors: org.bluez.Error.InvalidArguments - org.bluez.Error.UnknownAddress org.bluez.Error.RequestDeferred string GetRemoteAlias(string address) @@ -513,7 +507,6 @@ Methods string GetAddress() name. Possible errors: org.bluez.Error.Failed - org.bluez.Error.UnknownAddress org.bluez.Error.InvalidArguments void ClearRemoteAlias(string address) @@ -586,7 +579,6 @@ Methods string GetAddress() Possible errors: org.bluez.Error.Failed org.bluez.Error.InvalidArguments - org.bluez.Error.UnknownAddress org.bluez.Error.AlreadyExists org.bluez.Error.InProgress org.bluez.Error.NoSuchAdapter @@ -606,7 +598,7 @@ Methods string GetAddress() Possible errors: org.bluez.Error.Failed org.bluez.Error.InvalidArguments - org.bluez.Error.UnknownAddress + org.bluez.Error.NotInProgress org.bluez.Error.NotAuthorized org.bluez.Error.NoSuchAdapter @@ -658,7 +650,6 @@ Methods string GetAddress() has been established. Possible errors: org.bluez.Error.InvalidArguments - org.bluez.Error.UnknownAddress org.bluez.Error.NotConnected org.bluez.Error.DoesNotExist @@ -842,8 +833,7 @@ Methods void RegisterDefaultPasskeyAgent(string path) pairing succeeds or fails. The application has to take care of that it reregisters the passkey agent. - Possible errors: org.bluez.Error.UnknownAddress - org.bluez.Error.AlreadyExists + Possible errors: org.bluez.Error.AlreadyExists void UnregisterPasskeyAgent(string path, string address) @@ -856,8 +846,7 @@ Methods void RegisterDefaultPasskeyAgent(string path) wants to removed the passkey agent and don't wanna wait for the automatic timeout. - Possible errors: org.bluez.Error.UnknownAddress - org.bluez.Error.DoesNotExist + Possible errors: org.bluez.Error.DoesNotExist PasskeyAgent hierarchy diff --git a/hcid/dbus-error.c b/hcid/dbus-error.c index 079cedf6..ef59272d 100644 --- a/hcid/dbus-error.c +++ b/hcid/dbus-error.c @@ -90,13 +90,6 @@ DBusHandlerResult error_no_such_adapter(DBusConnection *conn, DBusMessage *msg) "No such adapter")); } -DBusHandlerResult error_unknown_address(DBusConnection *conn, DBusMessage *msg) -{ - return send_reply_and_unref(conn, - dbus_message_new_error(msg, ERROR_INTERFACE ".UnknownAddress", - "Unknown address")); -} - DBusHandlerResult error_not_available(DBusConnection *conn, DBusMessage *msg) { return send_reply_and_unref(conn, @@ -182,6 +175,11 @@ DBusHandlerResult error_bonding_in_progress(DBusConnection *conn, DBusMessage *m return error_in_progress(conn, msg, "Bonding in progress"); } +DBusHandlerResult error_bonding_not_in_progress(DBusConnection *conn, DBusMessage *msg) +{ + return error_not_in_progress(conn, msg, "Bonding is not in progress"); +} + DBusHandlerResult error_authentication_canceled(DBusConnection *conn, DBusMessage *msg) { return send_reply_and_unref(conn, diff --git a/hcid/dbus-sdp.c b/hcid/dbus-sdp.c index edf220a9..caae8184 100644 --- a/hcid/dbus-sdp.c +++ b/hcid/dbus-sdp.c @@ -723,10 +723,8 @@ fail: static DBusHandlerResult get_identifiers(DBusConnection *conn, DBusMessage *msg, void *data) { - char filename[PATH_MAX + 1]; struct hci_dbus_data *dbus_data = data; const char *dst; - char *str; int err = 0; if (!dbus_message_get_args(msg, NULL, @@ -737,15 +735,6 @@ static DBusHandlerResult get_identifiers(DBusConnection *conn, if (find_pending_connect(dst)) return error_service_search_in_progress(conn, msg); - /* check if it is a unknown address */ - snprintf(filename, PATH_MAX, "%s/%s/lastseen", STORAGEDIR, dbus_data->address); - - str = textfile_get(filename, dst); - if (!str) - return error_unknown_address(conn, msg); - - free(str); - if (search_request(conn, msg, dbus_data->dev_id, dst, NULL, &err) < 0) { error("Search request failed: %s (%d)", strerror(err), err); return error_failed(conn, msg, err); @@ -757,7 +746,6 @@ static DBusHandlerResult get_identifiers(DBusConnection *conn, static DBusHandlerResult get_identifiers_by_service(DBusConnection *conn, DBusMessage *msg, void *data) { - char filename[PATH_MAX + 1]; struct hci_dbus_data *dbus_data = data; DBusMessage *reply; DBusMessageIter iter, array_iter; @@ -768,7 +756,6 @@ static DBusHandlerResult get_identifiers_by_service(DBusConnection *conn, char identifier[MAX_IDENTIFIER_LEN]; const char *ptr = identifier; const char *dst, *svc; - char *str; int err = 0, nrec = 0; uint32_t class; uuid_t uuid; @@ -779,15 +766,6 @@ static DBusHandlerResult get_identifiers_by_service(DBusConnection *conn, DBUS_TYPE_INVALID)) return error_invalid_arguments(conn, msg); - /* check if it is a unknown address */ - create_name(filename, PATH_MAX, STORAGEDIR, dbus_data->address, "lastseen"); - - str = textfile_get(filename, dst); - if (!str) - return error_unknown_address(conn, msg); - - free(str); - class = sdp_str2svclass(svc); if (!class) { error("Invalid service class name"); diff --git a/hcid/dbus.h b/hcid/dbus.h index 36c369bc..a1d9f18a 100644 --- a/hcid/dbus.h +++ b/hcid/dbus.h @@ -155,7 +155,6 @@ DBusHandlerResult error_unknown_method(DBusConnection *conn, DBusMessage *msg); DBusHandlerResult error_not_authorized(DBusConnection *conn, DBusMessage *msg); DBusHandlerResult error_out_of_memory(DBusConnection *conn, DBusMessage *msg); DBusHandlerResult error_no_such_adapter(DBusConnection *conn, DBusMessage *msg); -DBusHandlerResult error_unknown_address(DBusConnection *conn, DBusMessage *msg); DBusHandlerResult error_not_available(DBusConnection *conn, DBusMessage *msg); DBusHandlerResult error_request_deferred(DBusConnection *conn, DBusMessage *msg); DBusHandlerResult error_not_connected(DBusConnection *conn, DBusMessage *msg); @@ -164,6 +163,7 @@ DBusHandlerResult error_connection_attempt_failed(DBusConnection *conn, DBusMess DBusHandlerResult error_bonding_already_exists(DBusConnection *conn, DBusMessage *msg); DBusHandlerResult error_bonding_does_not_exist(DBusConnection *conn, DBusMessage *msg); DBusHandlerResult error_bonding_in_progress(DBusConnection *conn, DBusMessage *msg); +DBusHandlerResult error_bonding_not_in_progress(DBusConnection *conn, DBusMessage *msg); DBusHandlerResult error_authentication_canceled(DBusConnection *conn, DBusMessage *msg); DBusHandlerResult error_discover_in_progress(DBusConnection *conn, DBusMessage *msg); DBusHandlerResult error_connect_in_progress(DBusConnection *conn, DBusMessage *msg); |