All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kling, Andreas <Andreas.Kling@peiker.de>
To: ofono@ofono.org
Subject: AW: [PATCH 05/10] hfp_hf_bluez5: Handle NewConnection from BlueZ
Date: Wed, 23 Jan 2013 13:03:34 +0100	[thread overview]
Message-ID: <sig.9735c4f085.B3F251FD87EC894A88C2221EEEBDF54807096F7F55@Exchange> (raw)
In-Reply-To: <1358891005-24688-6-git-send-email-vinicius.gomes@openbossa.org>

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

Hi,

>Parse the essential arguments in the message, in this case only the
>file descriptor, and register the modem if it is not already
>registered. This is necessary because in some cases, we may receive a
>NewConnection call, and the SDP process is still taking place.
>---
> plugins/hfp_hf_bluez5.c | 47 ++++++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 44 insertions(+), 3 deletions(-)
>
>diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
>index 74ca570..39853e3 100644
>--- a/plugins/hfp_hf_bluez5.c
>+++ b/plugins/hfp_hf_bluez5.c
>@@ -24,6 +24,8 @@
> #endif
>
> #include <errno.h>
>+#include <unistd.h>
>+
> #include <glib.h>
>
> #include <gdbus.h>
>@@ -124,11 +126,50 @@ static struct ofono_modem_driver hfp_driver = {
> static DBusMessage *profile_new_connection(DBusConnection *conn,
>                                        DBusMessage *msg, void *user_data)
> {
>+       struct ofono_modem *modem;
>+       DBusMessageIter iter;
>+       GDBusProxy *proxy;
>+       DBusMessageIter entry;
>+       const char *device, *alias;
>+       int fd;
>+
>        DBG("Profile handler NewConnection");
>
>-       return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
>-                                       ".NotImplemented",
>-                                       "Implementation not provided");
>+       if (dbus_message_iter_init(msg, &entry) == FALSE)
>+               goto error;
>+
>+       if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_OBJECT_PATH)
>+               goto error;
>+
>+       dbus_message_iter_get_basic(&entry, &device);
>+
>+       proxy = g_hash_table_lookup(devices_proxies, device);
>+       if (proxy == NULL)
>+               goto error;
>+
>+       if (g_dbus_proxy_get_property(proxy, "Alias", &iter) == FALSE)
>+               alias = "unknown";
>+       else
>+               dbus_message_iter_get_basic(&iter, &alias);
>+
>+       dbus_message_iter_next(&entry);
>+       if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_UNIX_FD)
>+               goto error;
>+
>+       dbus_message_iter_get_basic(&entry, &fd);
>+       if (fd < 0)
>+               goto error;
>+
>+       modem = modem_register(device, alias);
>+       if (modem == NULL)
>+               goto error;
>+
>+       return NULL;
>+
>+error:
>+       close(fd);
>+       return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE ".Rejected",
>+                                       "Invalid arguments in method call");
> }
>
> static DBusMessage *profile_release(DBusConnection *conn,
>--
>1.8.1.1

fd is closed always on error, even if uninitialized

I assume returning NULL is ok here if nothing went wrong?
I'm not familiar with plain dbus API, just using glib gdbus, there I would expect to create an answer to the call.

kind regards

andy

  parent reply	other threads:[~2013-01-23 12:03 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-22 21:43 [PATCH 00/10] HFP Service Level Connection establishment Vinicius Costa Gomes
2013-01-22 21:43 ` [PATCH 01/10] hfp_hf_bluez5: Initial GDBusClient for BlueZ Vinicius Costa Gomes
2013-01-23  4:30   ` Denis Kenzior
2013-01-23 14:16     ` Vinicius Costa Gomes
2013-01-22 21:43 ` [PATCH 02/10] hfp_hf_bluez5: Add GDBusProxy for Bluetooth devices Vinicius Costa Gomes
2013-01-22 21:43 ` [PATCH 03/10] hfp_hf_bluez5: Register modem for HFP AG capable devices Vinicius Costa Gomes
2013-01-23  4:59   ` Denis Kenzior
2013-01-23 14:22     ` Vinicius Costa Gomes
2013-01-22 21:43 ` [PATCH 04/10] hfp_hf_bluez5: Keep track of changes of devices Aliases Vinicius Costa Gomes
2013-01-22 21:43 ` [PATCH 05/10] hfp_hf_bluez5: Handle NewConnection from BlueZ Vinicius Costa Gomes
2013-01-23  4:54   ` Denis Kenzior
2013-01-23 12:03   ` Kling, Andreas [this message]
2013-01-23 14:49     ` AW: " Denis Kenzior
2013-01-23 16:39       ` Vinicius Costa Gomes
2013-01-22 21:43 ` [PATCH 06/10] hfpmodem: Add dynamic hfp_slc_info allocation Vinicius Costa Gomes
2013-01-22 21:43 ` [PATCH 07/10] hfpmodem: Implement hfp_slc_info_free Vinicius Costa Gomes
2013-01-22 21:43 ` [PATCH 08/10] hfp_hf_bluez4: Use hfp_slc_info_free() Vinicius Costa Gomes
2013-01-22 21:43 ` [PATCH 09/10] phonesim: " Vinicius Costa Gomes
2013-01-22 21:43 ` [PATCH 10/10] hfp_hf_bluez5: Add SLC establishment procedure Vinicius Costa Gomes
2013-01-23  5:26   ` Denis Kenzior
2013-01-23 18:27 ` [PATCH v1 00/10] HFP Service Level Connection establishment Vinicius Costa Gomes
2013-01-23 18:27   ` [PATCH v1 01/10] hfp_hf_bluez5: Initial GDBusClient for BlueZ Vinicius Costa Gomes
2013-01-23 20:31     ` Denis Kenzior
2013-01-23 18:27   ` [PATCH v1 02/10] hfp_hf_bluez5: Add GDBusProxy for Bluetooth devices Vinicius Costa Gomes
2013-01-23 20:31     ` Denis Kenzior
2013-01-23 18:27   ` [PATCH v1 03/10] hfp_hf_bluez5: Register modem for HFP AG capable devices Vinicius Costa Gomes
2013-01-23 20:32     ` Denis Kenzior
2013-01-23 18:27   ` [PATCH v1 04/10] hfp_hf_bluez5: Keep track of changes of devices Aliases Vinicius Costa Gomes
2013-01-23 20:32     ` Denis Kenzior
2013-01-23 18:27   ` [PATCH v1 05/10] hfp_hf_bluez5: Handle NewConnection from BlueZ Vinicius Costa Gomes
2013-01-23 20:32     ` Denis Kenzior
2013-01-23 18:27   ` [PATCH v1 06/10] hfpmodem: Add dynamic hfp_slc_info allocation Vinicius Costa Gomes
2013-01-23 20:34     ` Denis Kenzior
2013-01-23 23:04       ` Vinicius Costa Gomes
2013-01-23 18:27   ` [PATCH v1 07/10] hfpmodem: Implement hfp_slc_info_free() Vinicius Costa Gomes
2013-01-23 18:27   ` [PATCH v1 08/10] hfp_hf_bluez4: Use hfp_slc_info_free() Vinicius Costa Gomes
2013-01-23 18:28   ` [PATCH v1 09/10] phonesim: " Vinicius Costa Gomes
2013-01-23 18:28   ` [PATCH v1 10/10] hfp_hf_bluez5: Add SLC establishment procedure Vinicius Costa Gomes

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=sig.9735c4f085.B3F251FD87EC894A88C2221EEEBDF54807096F7F55@Exchange \
    --to=andreas.kling@peiker.de \
    --cc=ofono@ofono.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.