linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Gustavo F. Padovan" <gustavo@padovan.org>
To: linux-bluetooth@vger.kernel.org
Cc: gustavo@padovan.org
Subject: [PATCH 7/8] Add DebugString Property to Manager
Date: Tue,  8 Jun 2010 04:11:53 -0300	[thread overview]
Message-ID: <1275981114-18019-7-git-send-email-gustavo@padovan.org> (raw)
In-Reply-To: <1275981114-18019-6-git-send-email-gustavo@padovan.org>

---
 src/manager.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/src/manager.c b/src/manager.c
index 66e1511..220a8fe 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -96,6 +96,31 @@ static DBusMessage *set_debug(DBusConnection *conn, DBusMessage *msg,
 	return dbus_message_new_method_return(msg);
 }
 
+static DBusMessage *set_debug_string(DBusConnection *conn, DBusMessage *msg,
+					const char *debug_string, void *data)
+{
+	char *old_string;
+
+	if (!g_utf8_validate(debug_string, -1, NULL)) {
+		error("DebugString change failed: supplied string "
+							"isn't valid UTF-8");
+		return invalid_args(msg);
+	}
+
+	old_string = __btd_get_debug_string();
+
+	if (strcmp((char *)debug_string, old_string) == 0)
+		return dbus_message_new_method_return(msg);
+
+	if (!__btd_set_debug_string((char *)debug_string))
+		return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
+							strerror(ENOMEM));
+	emit_property_changed(connection, "/", MANAGER_INTERFACE,
+				"DebugString", DBUS_TYPE_STRING, &debug_string);
+
+	return dbus_message_new_method_return(msg);
+}
+
 static DBusMessage *default_adapter(DBusConnection *conn,
 					DBusMessage *msg, void *data)
 {
@@ -200,6 +225,7 @@ static DBusMessage *get_properties(DBusConnection *conn,
 	GSList *list;
 	char **array;
 	gboolean debug_value;
+	char *debug_string;
 	int i;
 
 	reply = dbus_message_new_method_return(msg);
@@ -228,6 +254,10 @@ static DBusMessage *get_properties(DBusConnection *conn,
 	debug_value = __btd_debug_enabled();
 	dict_append_entry(&dict, "Debug", DBUS_TYPE_BOOLEAN, &debug_value);
 
+	debug_string = __btd_get_debug_string();
+	dict_append_entry(&dict, "DebugString", DBUS_TYPE_STRING,
+							&debug_string);
+
 	dbus_message_iter_close_container(&iter, &dict);
 
 	return reply;
@@ -262,6 +292,14 @@ static DBusMessage *set_property(DBusConnection *conn,
 		dbus_message_iter_get_basic(&sub, &debug);
 
 		return set_debug(conn, msg, debug, data);
+	} else if (g_str_equal("DebugString", property)) {
+		const char *string;
+
+		if (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_STRING)
+			return invalid_args(msg);
+		dbus_message_iter_get_basic(&sub, &string);
+
+		return set_debug_string(conn, msg, string, data);
 	}
 
 	return invalid_args(msg);
-- 
1.7.1


  reply	other threads:[~2010-06-08  7:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-08  7:11 [PATCH 1/8] Remove ifndef barrier from log.h and btio.h Gustavo F. Padovan
2010-06-08  7:11 ` [PATCH 2/8] log: Remove vinfo function Gustavo F. Padovan
2010-06-08  7:11   ` [PATCH 3/8] Fix regression with debug via SIGUSR2 Gustavo F. Padovan
2010-06-08  7:11     ` [PATCH 4/8] Add Debug property to Manager interface Gustavo F. Padovan
2010-06-08  7:11       ` [PATCH 5/8] Add SetProperty method and Debug read/write property Gustavo F. Padovan
2010-06-08  7:11         ` [PATCH 6/8] log: Add function to get/set debug_string Gustavo F. Padovan
2010-06-08  7:11           ` Gustavo F. Padovan [this message]
2010-06-08  7:11             ` [PATCH 8/8] Document the new Debug and DebugString property Gustavo F. Padovan
2010-06-08  8:05     ` [PATCH 3/8] Fix regression with debug via SIGUSR2 Johan Hedberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1275981114-18019-7-git-send-email-gustavo@padovan.org \
    --to=gustavo@padovan.org \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).