public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [Bluez-devel] [DBUS PATCH]LastSeen
@ 2006-02-23 17:09 Claudio Takahasi
  2006-02-23 17:23 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Claudio Takahasi @ 2006-02-23 17:09 UTC (permalink / raw)
  To: bluez-devel

[-- Attachment #1: Type: text/plain, Size: 385 bytes --]

Hi Marcel,

Here is the patch to add the last seen service.

I saw that I you implemented the SDP skeleton. At least, it seems to
be more interesting than these mechanical patches :) SDP is most
important feature missing on D-Bus API.


Regards,
Claudio.
--
---------------------------------------------------------
Claudio Takahasi
Instituto Nokia de Tecnologia - INdT

[-- Attachment #2: last-seen01.patch --]
[-- Type: text/x-patch, Size: 1272 bytes --]

Index: hcid/dbus-device.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-device.c,v
retrieving revision 1.11
diff -u -r1.11 dbus-device.c
--- hcid/dbus-device.c	23 Feb 2006 12:48:51 -0000	1.11
+++ hcid/dbus-device.c	23 Feb 2006 17:00:14 -0000
@@ -533,8 +533,35 @@
 
 static DBusMessage* handle_dev_last_seen_req(DBusMessage *msg, void *data)
 {
-	/*FIXME: */
-	return bluez_new_failure_msg(msg, BLUEZ_EDBUS_NOT_IMPLEMENTED);
+	struct hci_dbus_data *dbus_data = data;
+	DBusMessageIter iter;
+	DBusMessage *reply;
+	char filename[PATH_MAX + 1];
+	char addr[18], *addr_ptr, *str;
+
+	get_device_address(dbus_data->dev_id, addr, sizeof(addr));
+
+	snprintf(filename, PATH_MAX, "%s/%s/lastseen", STORAGEDIR, addr);
+
+	dbus_message_iter_init(msg, &iter);
+	dbus_message_iter_get_basic(&iter, &addr_ptr);
+
+	str = textfile_get(filename, addr_ptr);
+
+	if (!str) {
+		reply = bluez_new_failure_msg(msg, BLUEZ_ESYSTEM_OFFSET | ENXIO);
+		goto failed;
+	}
+
+	reply = dbus_message_new_method_return(msg);
+
+	dbus_message_append_args(reply, DBUS_TYPE_STRING, &str,
+				 	DBUS_TYPE_INVALID);
+
+	free(str);
+
+failed:
+	return reply;
 }
 
 static DBusMessage* handle_dev_last_used_req(DBusMessage *msg, void *data)



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-02-23 17:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-23 17:09 [Bluez-devel] [DBUS PATCH]LastSeen Claudio Takahasi
2006-02-23 17:23 ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox