From: Dmitriy Paliy <dmitriy.paliy@gmail.com>
To: linux-bluetooth@vger.kernel.org, luiz.dentz@gmail.com
Cc: Dmitriy Paliy <dmitriy.paliy@nokia.com>
Subject: [PATCH 2/6] Split up session_create in separate functions
Date: Tue, 28 Jun 2011 00:39:37 +0300 [thread overview]
Message-ID: <1309210781-2674-3-git-send-email-dmitriy.paliy@nokia.com> (raw)
In-Reply-To: <1309210781-2674-1-git-send-email-dmitriy.paliy@nokia.com>
Connection of RFCOMM and SDP are extracted from session_create function
into session_connect. Such allows making asynchronous calls before
creating connections.
---
client/session.c | 41 ++++++++++++++++++++++++-----------------
1 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/client/session.c b/client/session.c
index 4a4922f..4016e35 100644
--- a/client/session.c
+++ b/client/session.c
@@ -534,6 +534,29 @@ static struct session_data *session_find(const char *source,
return NULL;
}
+static int session_connect(struct session_data *session,
+ struct callback_data *callback)
+{
+ int err;
+
+ if (session->obex) {
+ g_idle_add(connection_complete, callback);
+ err = 0;
+ } else if (session->channel > 0) {
+ session->io = rfcomm_connect(&session->src, &session->dst,
+ session->channel,
+ rfcomm_callback,
+ callback);
+ err = (session->io == NULL) ? -EINVAL : 0;
+ } else {
+ callback->sdp = service_connect(&session->src, &session->dst,
+ service_callback, callback);
+ err = (callback->sdp == NULL) ? -ENOMEM : 0;
+ }
+
+ return err;
+}
+
struct session_data *session_create(const char *source,
const char *destination,
const char *service,
@@ -544,7 +567,6 @@ struct session_data *session_create(const char *source,
{
struct session_data *session;
struct callback_data *callback;
- int err;
if (destination == NULL)
return NULL;
@@ -613,22 +635,7 @@ proceed:
callback->func = function;
callback->data = user_data;
- if (session->obex) {
- g_idle_add(connection_complete, callback);
- err = 0;
- } else if (session->channel > 0) {
- session->io = rfcomm_connect(&session->src, &session->dst,
- session->channel,
- rfcomm_callback,
- callback);
- err = (session->io == NULL) ? -EINVAL : 0;
- } else {
- callback->sdp = service_connect(&session->src, &session->dst,
- service_callback, callback);
- err = (callback->sdp == NULL) ? -ENOMEM : 0;
- }
-
- if (err < 0) {
+ if (session_connect(session, callback) < 0) {
session_unref(session);
g_free(callback);
return NULL;
--
1.7.4.1
next prev parent reply other threads:[~2011-06-27 21:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-27 21:39 [RFC] Add adapter session request/release to obex-client Dmitriy Paliy
2011-06-27 21:39 ` [PATCH 1/6] Add system bus connection in obex-client Dmitriy Paliy
2011-06-27 21:39 ` Dmitriy Paliy [this message]
2011-06-27 21:39 ` [PATCH 3/6] Add handling of system D-Bus method calls Dmitriy Paliy
2011-06-27 21:39 ` [PATCH 4/6] Add adapter ReleaseSession to obex-client Dmitriy Paliy
2011-06-28 7:42 ` Luiz Augusto von Dentz
2011-06-27 21:39 ` [PATCH 5/6] Add FindAdapter method call " Dmitriy Paliy
2011-06-28 7:48 ` Luiz Augusto von Dentz
2011-06-27 21:39 ` [PATCH 6/6] Code clean-up: remove unnecessary brackets Dmitriy Paliy
2011-06-28 7:59 ` Luiz Augusto von Dentz
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=1309210781-2674-3-git-send-email-dmitriy.paliy@nokia.com \
--to=dmitriy.paliy@gmail.com \
--cc=dmitriy.paliy@nokia.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
/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