From: Bartosz Szatkowski <bulislaw@linux.com>
To: linux-bluetooth@vger.kernel.org
Cc: Bartosz Szatkowski <bulislaw@linux.com>
Subject: [PATCH obexd 2/6] Add basic support for MAP client in obex-client
Date: Thu, 8 Dec 2011 14:07:54 +0100 [thread overview]
Message-ID: <1323349678-17905-2-git-send-email-bulislaw@linux.com> (raw)
In-Reply-To: <1323349678-17905-1-git-send-email-bulislaw@linux.com>
---
Makefile.am | 1 +
client/manager.c | 2 +
client/map.c | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++++
client/map.h | 24 +++++++++
doc/client-api.txt | 9 ++++
5 files changed, 171 insertions(+), 0 deletions(-)
create mode 100644 client/map.c
create mode 100644 client/map.h
diff --git a/Makefile.am b/Makefile.am
index bdb961f..c371f8a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -120,6 +120,7 @@ client_obex_client_SOURCES = $(gdbus_sources) $(gobex_sources) \
client/pbap.h client/pbap.c \
client/ftp.h client/ftp.c \
client/opp.h client/opp.c \
+ client/map.h client/map.c \
client/transfer.h client/transfer.c \
client/agent.h client/agent.c \
client/driver.h client/driver.c \
diff --git a/client/manager.c b/client/manager.c
index dfb282b..f6628d7 100644
--- a/client/manager.c
+++ b/client/manager.c
@@ -42,6 +42,7 @@
#include "ftp.h"
#include "pbap.h"
#include "sync.h"
+#include "map.h"
#define CLIENT_SERVICE "org.openobex.client"
@@ -567,6 +568,7 @@ static struct target_module {
{ "ftp", ftp_init, ftp_exit },
{ "pbap", pbap_init, pbap_exit },
{ "sync", sync_init, sync_exit },
+ { "map", map_init, map_exit },
{ }
};
diff --git a/client/map.c b/client/map.c
new file mode 100644
index 0000000..bee49c5
--- /dev/null
+++ b/client/map.c
@@ -0,0 +1,135 @@
+/*
+ *
+ * OBEX Client
+ *
+ * Copyright (C) 2011 Bartosz Szatkowski <bulislaw@linux.com> for Comarch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <errno.h>
+#include <glib.h>
+#include <gdbus.h>
+
+#include "log.h"
+
+#include "map.h"
+#include "transfer.h"
+#include "session.h"
+#include "driver.h"
+
+#define OBEX_MAS_UUID \
+ "\xBB\x58\x2B\x40\x42\x0C\x11\xDB\xB0\xDE\x08\x00\x20\x0C\x9A\x66"
+#define OBEX_MAS_UUID_LEN 16
+
+#define MAP_INTERFACE "org.openobex.MessageAccess"
+#define MAS_UUID "00001132-0000-1000-8000-00805f9b34fb"
+
+struct map_data {
+ struct obc_session *session;
+ DBusMessage *msg;
+};
+
+static DBusConnection *conn = NULL;
+
+static GDBusMethodTable map_methods[] = {
+ { }
+};
+
+static void map_free(void *data)
+{
+ struct map_data *map = data;
+
+ obc_session_unref(map->session);
+ g_free(map);
+}
+
+static int map_probe(struct obc_session *session)
+{
+ struct map_data *map;
+ const char *path;
+
+ path = obc_session_get_path(session);
+
+ DBG("%s", path);
+
+ map = g_try_new0(struct map_data, 1);
+ if (!map)
+ return -ENOMEM;
+
+ map->session = obc_session_ref(session);
+
+ if (!g_dbus_register_interface(conn, path, MAP_INTERFACE, map_methods,
+ NULL, NULL, map, map_free)) {
+ map_free(map);
+
+ return -ENOMEM;
+ }
+
+ return 0;
+}
+
+static void map_remove(struct obc_session *session)
+{
+ const char *path = obc_session_get_path(session);
+
+ DBG("%s", path);
+
+ g_dbus_unregister_interface(conn, path, MAP_INTERFACE);
+}
+
+static struct obc_driver map = {
+ .service = "MAP",
+ .uuid = MAS_UUID,
+ .target = OBEX_MAS_UUID,
+ .target_len = OBEX_MAS_UUID_LEN,
+ .probe = map_probe,
+ .remove = map_remove
+};
+
+int map_init(void)
+{
+ int err;
+
+ DBG("");
+
+ conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+ if (!conn)
+ return -EIO;
+
+ err = obc_driver_register(&map);
+ if (err < 0) {
+ dbus_connection_unref(conn);
+ conn = NULL;
+ return err;
+ }
+
+ return 0;
+}
+
+void map_exit(void)
+{
+ DBG("");
+
+ dbus_connection_unref(conn);
+ conn = NULL;
+
+ obc_driver_unregister(&map);
+}
diff --git a/client/map.h b/client/map.h
new file mode 100644
index 0000000..86f6b95
--- /dev/null
+++ b/client/map.h
@@ -0,0 +1,24 @@
+/*
+ *
+ * OBEX Client
+ *
+ * Copyright (C) 2011 Bartosz Szatkowski <bulislaw@linux.com> for Comarch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+int map_init(void);
+void map_exit(void);
diff --git a/doc/client-api.txt b/doc/client-api.txt
index 3e61cf7..ee8951f 100644
--- a/doc/client-api.txt
+++ b/doc/client-api.txt
@@ -251,6 +251,15 @@ Methods void SetLocation(string location)
Send an entire Phonebook Object store to remote device
+Message Access hierarchy
+=========================
+
+Service org.openobex.client
+Interface org.openobex.MessageAccess
+Object path [variable prefix]/{session0,session1,...}
+
+Methods
+
Transfer hierarchy
==================
--
1.7.4.1
next prev parent reply other threads:[~2011-12-08 13:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-08 13:07 [PATCH obexd 1/6] gobex: Add translating error codes to strings Bartosz Szatkowski
2011-12-08 13:07 ` Bartosz Szatkowski [this message]
2011-12-08 13:07 ` [PATCH obexd 3/6] Add support for SetFolder in MAP client Bartosz Szatkowski
2011-12-09 13:22 ` Johan Hedberg
2011-12-09 13:58 ` Bartosz Szatkowski
2011-12-08 13:07 ` [PATCH obexd 4/6] Add simple helper for " Bartosz Szatkowski
2011-12-08 13:07 ` [PATCH obexd 5/6] Add basic support for MAP folder listing Bartosz Szatkowski
2011-12-08 13:07 ` [PATCH obexd 6/6] Add support for PullMessagesListing in MAP client Bartosz Szatkowski
-- strict thread matches above, loose matches on Subject: below --
2011-12-05 11:41 [PATCH obexd 1/6] gobex: Add translating error codes to strings Bartosz Szatkowski
2011-12-05 11:41 ` [PATCH obexd 2/6] Add basic support for MAP client in obex-client Bartosz Szatkowski
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=1323349678-17905-2-git-send-email-bulislaw@linux.com \
--to=bulislaw@linux.com \
--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 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.