diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2007-05-14 12:28:55 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2007-05-14 12:28:55 +0000 |
commit | 57704487a484a6d599f12cee65b63f8daa7ecf8b (patch) | |
tree | b71512e03576db402100b5af5761c3c0f68c079c | |
parent | 772f25e26e1d1c5982855eefd59b51c7e4aaab95 (diff) |
Add method to retrieve adapter address
-rw-r--r-- | network/connection.c | 29 | ||||
-rw-r--r-- | network/network-api.txt | 48 |
2 files changed, 51 insertions, 26 deletions
diff --git a/network/connection.c b/network/connection.c index d565fea2..9062c419 100644 --- a/network/connection.c +++ b/network/connection.c @@ -313,15 +313,36 @@ static int l2cap_connect(struct network_conn *nc) return 0; } +static DBusHandlerResult get_adapter(DBusConnection *conn, DBusMessage *msg, + void *data) +{ + struct network_conn *nc = data; + DBusMessage *reply; + char addr[18]; + const char *paddr = addr; + + ba2str(&nc->src, addr); + + reply = dbus_message_new_method_return(msg); + if (!reply) + return DBUS_HANDLER_RESULT_NEED_MEMORY; + + dbus_message_append_args(reply, DBUS_TYPE_STRING, &paddr, + DBUS_TYPE_INVALID); + + return send_message_and_unref(conn, reply); +} + static DBusHandlerResult get_address(DBusConnection *conn, DBusMessage *msg, void *data) { struct network_conn *nc = data; DBusMessage *reply; - char raddr[18]; - const char *paddr = raddr; + char addr[18]; + const char *paddr = addr; + + ba2str(&nc->dst, addr); - ba2str(&nc->dst, raddr); reply = dbus_message_new_method_return(msg); if (!reply) return DBUS_HANDLER_RESULT_NEED_MEMORY; @@ -570,6 +591,7 @@ static void connection_unregister(DBusConnection *conn, void *data) } static DBusMethodVTable connection_methods[] = { + { "GetAdapter", get_adapter, "", "s" }, { "GetAddress", get_address, "", "s" }, { "GetUUID", get_uuid, "", "s" }, { "GetName", get_name, "", "s" }, @@ -698,4 +720,3 @@ gboolean connection_has_pending(DBusConnection *conn, const char *path) return (nc->state == CONNECTING); } - diff --git a/network/network-api.txt b/network/network-api.txt index f88679d6..aa562d74 100644 --- a/network/network-api.txt +++ b/network/network-api.txt @@ -14,16 +14,16 @@ Methods string CreateServer(string uuid) Creates a network server object (GN or NAP). - Possible errors:org.bluez.network.Error.AlreadyExists - org.bluez.network.Error.NotSupported - org.bluez.network.Error.ConnectionAttemptFailed - org.bluez.network.Error.Failed + Possible errors: org.bluez.network.Error.AlreadyExists + org.bluez.network.Error.NotSupported + org.bluez.network.Error.ConnectionAttemptFailed + org.bluez.network.Error.Failed void RemoveServer(string path) Removes the network server object for given path. - Possible errors:org.bluez.network.Error.DoesNotExist - org.bluez.network.Error.Failed + Possible errors: org.bluez.network.Error.DoesNotExist + org.bluez.network.Error.Failed array{string} ListServers() @@ -34,17 +34,17 @@ Methods string CreateServer(string uuid) Returns server path. - Possible errors:org.bluez.network.Error.DoesNotExist - org.bluez.network.Error.Failed + Possible errors: org.bluez.network.Error.DoesNotExist + org.bluez.network.Error.Failed string CreateConnection(string address, string uuid) Creates a network connection object(NAP or GN). - Possible errors:org.bluez.network.Error.AlreadyExists - org.bluez.network.Error.NotSupported - org.bluez.network.Error.ConnectionAttemptFailed - org.bluez.network.Error.Failed + Possible errors: org.bluez.network.Error.AlreadyExists + org.bluez.network.Error.NotSupported + org.bluez.network.Error.ConnectionAttemptFailed + org.bluez.network.Error.Failed void RemoveConnection(string path) @@ -90,14 +90,14 @@ Methods string GetUUID() Enable server and updates service record. - Possible errors:org.bluez.network.Error.AlreadyExists - org.bluez.network.Error.Failed + Possible errors: org.bluez.network.Error.AlreadyExists + org.bluez.network.Error.Failed void Disable() Disable server and remove service record. - Possible errors:org.bluez.network.Error.Failed + Possible errors: org.bluez.network.Error.Failed void SetName(string name) @@ -139,7 +139,11 @@ Network Connection hierarchy (experimental) Interface org.bluez.network.Connection Object path /org/bluez/network/connection* -Methods string GetAddress() +Methods string GetAdapter() + + Returns the Bluetooth address of the adapter. + + string GetAddress() Returns the Bluetooth address of the ending point. @@ -152,33 +156,33 @@ Methods string GetAddress() Returns the string representation of connected host. - Possible errors:org.bluez.network.Error.Failed + Possible errors: org.bluez.network.Error.Failed string GetDescription() Returns the string description of connected host. - Possible errors:org.bluez.network.Error.Failed + Possible errors: org.bluez.network.Error.Failed string GetInterface() Returns the string network interface. - Possible errors:org.bluez.network.Error.Failed + Possible errors: org.bluez.network.Error.Failed string Connect() Connects to host and return the network interface created. - Possible errors:org.bluez.network.Error.ConnectionAttemptFailed - org.bluez.network.Error.Failed + Possible errors: org.bluez.network.Error.ConnectionAttemptFailed + org.bluez.network.Error.Failed void Disconnect() Disconnects to host. - Possible errors:org.bluez.network.Error.Failed + Possible errors: org.bluez.network.Error.Failed bool IsConnected() |