summaryrefslogtreecommitdiffstats
path: root/serial
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2007-05-18 14:49:45 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2007-05-18 14:49:45 +0000
commit09e244622737c52bb7b9a06420f5c1fc5e7bf446 (patch)
tree35a15855e8cfe14f267afea8f892a2fc9a3e025b /serial
parentd87420bcd319c66010fc36061ea0c354ef117d1d (diff)
serial: removed Connected/Disconnected and added GetInfo
Diffstat (limited to 'serial')
-rw-r--r--serial/port.c50
1 files changed, 35 insertions, 15 deletions
diff --git a/serial/port.c b/serial/port.c
index a433e319..44879ecc 100644
--- a/serial/port.c
+++ b/serial/port.c
@@ -88,25 +88,32 @@ static struct rfcomm_node *find_node_by_name(GSList *nodes, const char *name)
return NULL;
}
-static DBusHandlerResult port_connect(DBusConnection *conn,
+static DBusHandlerResult port_get_address(DBusConnection *conn,
DBusMessage *msg, void *data)
{
- /* FIXME: call port_open() */
+ struct rfcomm_node *node = data;
+ DBusMessage *reply;
+ char bda[18];
+ const char *pbda = bda;
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
+ ba2str(&node->dst, bda);
+ dbus_message_append_args(reply,
+ DBUS_TYPE_STRING, &pbda,
+ DBUS_TYPE_INVALID);
+ return send_message_and_unref(conn, reply);
-static DBusHandlerResult port_disconnect(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
-static DBusHandlerResult port_get_address(DBusConnection *conn,
+static DBusHandlerResult port_get_info(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct rfcomm_node *node = data;
DBusMessage *reply;
+ DBusMessageIter iter, dict;
char bda[18];
const char *pbda = bda;
@@ -114,18 +121,31 @@ static DBusHandlerResult port_get_address(DBusConnection *conn,
if (!reply)
return DBUS_HANDLER_RESULT_NEED_MEMORY;
+ dbus_message_iter_init_append(reply, &iter);
+
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
+
+ dbus_message_iter_append_dict_entry(&dict, "name",
+ DBUS_TYPE_STRING, &node->name);
+
ba2str(&node->dst, bda);
- dbus_message_append_args(reply,
- DBUS_TYPE_STRING, &pbda,
- DBUS_TYPE_INVALID);
- return send_message_and_unref(conn, reply);
+ dbus_message_iter_append_dict_entry(&dict, "address",
+ DBUS_TYPE_STRING, &pbda);
+ dbus_message_iter_append_dict_entry(&dict, "dev_id",
+ DBUS_TYPE_INT16, &node->id);
+
+ dbus_message_iter_close_container(&iter, &dict);
+
+ return send_message_and_unref(conn, reply);
}
static DBusMethodVTable port_methods[] = {
- { "Connect", port_connect, "", "" },
- { "Disconnect", port_disconnect, "", "" },
{ "GetAddress", port_get_address, "", "s" },
+ { "GetInfo", port_get_info, "", "{sv}" },
{ NULL, NULL, NULL, NULL },
};