Skip to contentSkip to conversation

obexd/client: Add client session properties

PATCH In review [email protected] 3 participants 3 messages Jul 5, 2013 – Jul 8, 2013 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 obexd/client: Add client session properties

From: Martin <[email protected]>

---
 obexd/client/session.c |   38 ++++++++++++++++++++++++++++++++------
 1 file changed, 32 insertions(+), 6 deletions(-)
obexd/client/session.c +32 -6
index 8d32ed0..e9cbf00 100644
@@ -630,9 +630,6 @@ static gboolean get_source(const GDBusPropertyTable *property,
 {
 	struct obc_session *session = data;
 
-	if (session->source == NULL)
-		return FALSE;
-
 	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING,
 							&session->source);
 
@@ -675,10 +672,35 @@ static const GDBusMethodTable session_methods[] = {
 	{ }
 };
 
+static gboolean get_target(const GDBusPropertyTable *property,
+					DBusMessageIter *iter, void *data)
+{
+	struct obc_session *session = data;
+	char *uuid;
+
+	uuid = g_strdup(session->driver->uuid);
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &uuid);
+	g_free(uuid);
+
+	return TRUE;
+}
+
+static gboolean session_target_exists(const GDBusPropertyTable *property,
+								void *data)
+{
+	struct obc_session *session = data;
+	if (session->driver)
+		return session->driver->uuid ? TRUE : FALSE;
+
+	return FALSE;
+}
+
 static const GDBusPropertyTable session_properties[] = {
 	{ "Source", "s", get_source, NULL, source_exists },
 	{ "Destination", "s", get_destination },
 	{ "Channel", "y", get_channel },
+	{ "Target", "s", get_target, NULL, session_target_exists },
 	{ }
 };
 
@@ -854,9 +876,13 @@ const char *obc_session_register(struct obc_session *session,
 	session->path = g_strdup_printf("%s/session%ju",
 						SESSION_BASEPATH, counter++);
 
-	if (g_dbus_register_interface(session->conn, session->path,
-					SESSION_INTERFACE, session_methods,
-					NULL, NULL, session, destroy) == FALSE)
+	if (g_dbus_register_interface(session->conn,
+					session->path,
+					SESSION_INTERFACE,
+					session_methods,
+					NULL,
+					session_properties,
+					session, destroy) == FALSE)
 		goto fail;
 
 	if (session->driver->probe && session->driver->probe(session) < 0) {
Signature · 1 line
1.7.10.4
#1 lore raw

Hi Martin,

Quoted 1 line · On Fri, Jul 5, 2013 at 12:38 PM, <[email protected]> wrote:

From: Martin <[email protected]>

Please add a description why are the changes necessary.

Quoted 9 lines
---
 obexd/client/session.c |   38 ++++++++++++++++++++++++++++++++------
 1 file changed, 32 insertions(+), 6 deletions(-)
obexd/client/session.c +0 -0
index 8d32ed0..e9cbf00 100644

obexd/client/session.c static gboolean get_source(const GDBusPropertyTable *property, · line 634

Quoted 5 lines
obexd/client/session.c +0 -2
@@ -630,9 +630,6 @@ static gboolean get_source(const GDBusPropertyTable *property,
 {
        struct obc_session *session = data;
 
-       if (session->source == NULL)
-               return FALSE;

I guess you haven't read carefully may comments from the last time, did you? This should not be necessary here, otherwise create another patch.

Quoted 4 lines
obexd/client/session.c +0 -0
        dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING,
                                                        &session->source);
 

obexd/client/session.c static const GDBusMethodTable session_methods[] = { · line 681

Quoted 10 lines
obexd/client/session.c +7 -0
@@ -675,10 +672,35 @@ static const GDBusMethodTable session_methods[] = {
        { }
 };
 
+static gboolean get_target(const GDBusPropertyTable *property,
+                                       DBusMessageIter *iter, void *data)
+{
+       struct obc_session *session = data;
+       char *uuid;
+
+       uuid = g_strdup(session->driver->uuid);

You don't really need a copy here, just use session->driver->uuid directly.

Quoted 29 lines
obexd/client/session.c +17 -1
+       dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &uuid);
+       g_free(uuid);
+
+       return TRUE;
+}
+
+static gboolean session_target_exists(const GDBusPropertyTable *property,
+                                                               void *data)
+{
+       struct obc_session *session = data;
+       if (session->driver)
+               return session->driver->uuid ? TRUE : FALSE;
+
+       return FALSE;
+}
+
 static const GDBusPropertyTable session_properties[] = {
        { "Source", "s", get_source, NULL, source_exists },
        { "Destination", "s", get_destination },
        { "Channel", "y", get_channel },
+       { "Target", "s", get_target, NULL, session_target_exists },
        { }
 };
 
@@ -854,9 +876,13 @@ const char *obc_session_register(struct obc_session *session,
        session->path = g_strdup_printf("%s/session%ju",
                                                SESSION_BASEPATH, counter++);
 
-       if (g_dbus_register_interface(session->conn, session->path,

obexd/client/session.c const char *obc_session_register(struct obc_session *session, · line 886

Quoted 10 lines
obexd/client/session.c +7 -2
-                                       SESSION_INTERFACE, session_methods,
-                                       NULL, NULL, session, destroy) == FALSE)
+       if (g_dbus_register_interface(session->conn,
+                                       session->path,
+                                       SESSION_INTERFACE,
+                                       session_methods,
+                                       NULL,
+                                       session_properties,
+                                       session, destroy) == FALSE)
                goto fail;

Im not sure why you are reformatting the lines above, they were fine according to codestyle and even if they were not you should not mix changes that are not related to the patch.

--
Luiz Augusto von Dentz

#2 lore raw
Quoted 27 lines

-----Original Message-----
From: [email protected] [mailto:linux-bluetooth- [email protected]] On Behalf Of Luiz Augusto von Dentz
Sent: Friday, July 05, 2013 18:04
To: [email protected]
Cc: [email protected]
Subject: Re: [PATCH] obexd/client: Add client session properties

Hi Martin,

Quoted 1 line · On Fri, Jul 5, 2013 at 12:38 PM, <[email protected]> wrote:

From: Martin <[email protected]>

Please add a description why are the changes necessary.

Quoted 12 lines
---
 obexd/client/session.c |   38 ++++++++++++++++++++++++++++++++------
 1 file changed, 32 insertions(+), 6 deletions(-)
obexd/client/session.c index renamed from obexd/client/session.c +0 -0

8d32ed0..e9cbf00 100644

obexd/client/session.c +0 -0
@@ -630,9 +630,6 @@ static gboolean get_source(const
 GDBusPropertyTable *property,  {
        struct obc_session *session = data;
 
Quoted 5 lines

obexd/client/session.c static gboolean get_source(const GDBusPropertyTable *property, · line 634

Quoted 2 lines
obexd/client/session.c +0 -2
-       if (session->source == NULL)
-               return FALSE;

I guess you haven't read carefully may comments from the last time, did you? This should not be necessary here, otherwise create another patch.

Looks like I lost your last mail, could you repeat that. For others comments, I will resend the patch. Thanks!