Skip to contentSkip to conversation

Implements the OBEX server/SyncML binding for syncEvolution (http://syncevolution.org/).

PATCH New Forrest Zhao 1 participant 1 message Oct 21, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Implements the OBEX server/SyncML binding for syncEvolution (http://syncevolution.org/).

OBEX/SyncML binding spec is at http://www.openmobilealliance.net/
Technical/release_program/docs/Common/V1_2_1-20070813-A/OMA-TS-SyncML_OBEXBinding-V1_2-20070221-A.pdf
---
This is the refined patch according to Patrick's comments.

 Makefile.am         |    2 +-
 src/main.c          |   17 ++-
 src/manager.c       |   33 +++++
 src/obex.c          |   47 +++++--
 src/obex.h          |   10 ++
 src/syncevolution.c |  362 +++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 458 insertions(+), 13 deletions(-)
 create mode 100644 src/syncevolution.c
Makefile.am +1 -1
index 63f7478..49817ee 100644
@@ -31,7 +31,7 @@ src_obexd_SOURCES = $(gdbus_sources) \
 			src/main.c src/obexd.h src/plugin.h src/plugin.c \
 			src/logging.h src/logging.c src/btio.h src/btio.c \
 			src/dbus.h src/manager.c src/obex.h src/obex.c \
-			src/opp.c src/ftp.c src/pbap.c \
+			src/opp.c src/ftp.c src/pbap.c src/syncevolution.c \
 			src/bluetooth.h src/bluetooth.c \
 			src/phonebook.h src/phonebook.c
 
src/main.c +15 -2
index abd2bcc..520973f 100644
@@ -53,6 +53,7 @@
 #define OPP_CHANNEL	9
 #define FTP_CHANNEL	10
 #define PBAP_CHANNEL	15
+#define SYNCEVOLUTION_CHANNEL	16
 #define PCSUITE_CHANNEL	24
 
 #define DEFAULT_ROOT_PATH "/tmp"
@@ -172,6 +173,7 @@ static gboolean option_ftp = FALSE;
 static gboolean option_pbap = FALSE;
 static gboolean option_pcsuite = FALSE;
 static gboolean option_symlinks = FALSE;
+static gboolean option_syncevolution = FALSE;
 
 static GOptionEntry options[] = {
 	{ "nodaemon", 'n', G_OPTION_FLAG_REVERSE,
@@ -199,6 +201,8 @@ static GOptionEntry options[] = {
 				"Enable Phonebook Access server" },
 	{ "pcsuite", 's', 0, G_OPTION_ARG_NONE, &option_pcsuite,
 				"Enable PC Suite Services server" },
+	{ "syncevolution", 'e', 0, G_OPTION_ARG_NONE, &option_syncevolution,
+				"Enable OBEX server for SyncEvolution" },
 	{ NULL },
 };
 
@@ -337,9 +341,9 @@ int main(int argc, char *argv[])
 		log_option |= LOG_PERROR;
 
 	if (option_opp == FALSE && option_ftp == FALSE &&
-						option_pbap == FALSE) {
+		option_pbap == FALSE && option_syncevolution == FALSE) {
 		fprintf(stderr, "No server selected (use either "
-					"--opp or --ftp or both)\n");
+				"--opp, --ftp, --pbap or --syncevolution)\n");
 		exit(EXIT_FAILURE);
 	}
 
@@ -408,6 +412,15 @@ int main(int argc, char *argv[])
 				option_capability);
 	}
 
+	/* FIXME: move "SyncEvolution" from ServiceName to ProviderName */
+	if (option_syncevolution == TRUE) {
+		services |= OBEX_SYNCEVOLUTION;
+		bluetooth_init(OBEX_SYNCEVOLUTION, "OBEX server for SyncML,"
+				" using SyncEvolution", NULL,
+				SYNCEVOLUTION_CHANNEL, TRUE, FALSE, FALSE,
+				NULL);
+	}
+
 	if (option_devnode)
 		devnode_setup();
 
src/manager.c +33 -0
index 24ed3db..c36ecfd 100644
@@ -216,6 +216,35 @@ static const gchar *pcsuite_record =
   </attribute>									\
 </record>";
 
+static const gchar *syncevolution_record =
+"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>					\
+<record>									\
+ <attribute id=\"0x0001\">							\
+    <sequence>									\
+      <uuid value=\"00000002-0000-1000-8000-0002ee000002\"/>			\
+    </sequence>									\
+ </attribute>									\
+										\
+ <attribute id=\"0x0004\">							\
+    <sequence>									\
+      <sequence>								\
+        <uuid value=\"0x0100\"/>						\
+      </sequence>								\
+      <sequence>								\
+        <uuid value=\"0x0003\"/>						\
+        <uint8 value=\"%u\" name=\"channel\"/>					\
+      </sequence>								\
+      <sequence>								\
+        <uuid value=\"0x0008\"/>						\
+      </sequence>								\
+    </sequence>									\
+ </attribute>									\
+										\
+ <attribute id=\"0x0100\">							\
+    <text value=\"%s\" name=\"name\"/>						\
+ </attribute>									\
+</record>";
+
 #define TRANSFER_INTERFACE OPENOBEX_SERVICE ".Transfer"
 #define SESSION_INTERFACE OPENOBEX_SERVICE ".Session"
 
@@ -525,6 +554,10 @@ static gchar *create_xml_record(const char *name,
 	case OBEX_PCSUITE:
 		xml = g_markup_printf_escaped(pcsuite_record, channel, name);
 		break;
+	case OBEX_SYNCEVOLUTION:
+		xml = g_markup_printf_escaped(syncevolution_record, channel,
+								name);
+		break;
 	default:
 		xml = NULL;
 		break;
src/obex.c +37 -10

118 lines not on this page · raw message

src/obex.h +10 -0
index 94a273e..b9af4ed 100644
@@ -27,6 +27,7 @@
 #include <config.h>
 #endif
 
+#include <dbus/dbus.h>
 #include <glib.h>
 
 #include "phonebook.h"
@@ -36,6 +37,7 @@
 #define OBEX_BIP	(1 << 3)
 #define OBEX_PBAP	(1 << 4)
 #define OBEX_PCSUITE	(1 << 5)
+#define OBEX_SYNCEVOLUTION	(1 << 6)
 
 #define OBJECT_SIZE_UNKNOWN -1
 #define OBJECT_SIZE_DELETE -2
@@ -86,6 +88,9 @@ struct obex_session {
 	obex_t		*obex;
 	struct phonebook_context *pbctx;
 	gboolean	finished;
+	DBusConnection	*dbus_conn;
+	gchar		*conn_obj;
+	gboolean	reply_received;
 };
 
 gint obex_session_start(GIOChannel *io, struct server *server);
@@ -106,6 +111,11 @@ gboolean pbap_phonebook_context_create(struct obex_session *session);
 void pbap_phonebook_context_destroy(struct obex_session *session);
 struct obex_session *pbap_get_session(struct phonebook_context *context);
 
+gboolean synce_connect(struct obex_session *os);
+void synce_put(obex_t *obex, obex_object_t *obj);
+void synce_get(obex_t *obex, obex_object_t *obj);
+void synce_destroy(struct obex_session *os);
+
 gint os_prepare_get(struct obex_session *os, gchar *file, guint32 *size);
 gint os_prepare_put(struct obex_session *os);
 
src/syncevolution.c new file +362 -0

362 lines not on this page · raw message

Signature · 1 line
1.5.4.5