summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lord <chris@openedhand.com>2006-12-22 10:48:36 +0000
committerChris Lord <chris@openedhand.com>2006-12-22 10:48:36 +0000
commite1fe553b5006a991a144dd04a579fe5e955ccadc (patch)
treefd3192604249bd22ea5a4fbc8d944f31c66d77e6
parent277b886eb11f4d6a54ef03a9c67a8c8d7d98eaac (diff)
downloadsync-e1fe553b5006a991a144dd04a579fe5e955ccadc.tar.gz
sync-e1fe553b5006a991a144dd04a579fe5e955ccadc.tar.bz2
sync-e1fe553b5006a991a144dd04a579fe5e955ccadc.zip
* configure.ac:
* src/Makefile.am: library-ise libsync * src/build-test.sh: * src/sync-test.c: Add a small test app for sync between eds and google cal * src/sync_group.c: (sync_group_class_init), (sync_group_set_namespace), (sync_group_get_item1), (sync_group_get_item2), (sync_group_get_namespace): Move the dodgy required gconf call to the get_default_env function, make sure the environment (and thus threads) are initialised before trying to create a new group. * src/sync_main.c: (main): Remove the dodgy gconf call, is now in libsync * src/sync_syncml_item.c: (sync_syncml_item_get_member): Explicitly enable and disable all syncable types
-rw-r--r--sync/ChangeLog23
-rw-r--r--sync/configure.ac2
-rw-r--r--sync/src/Makefile.am34
-rwxr-xr-xsync/src/build-test.sh3
-rw-r--r--sync/src/sync-test.c117
-rw-r--r--sync/src/sync_group.c49
-rw-r--r--sync/src/sync_main.c3
-rw-r--r--sync/src/sync_syncml_item.c13
8 files changed, 207 insertions, 37 deletions
diff --git a/sync/ChangeLog b/sync/ChangeLog
index a1d0120..5d1863f 100644
--- a/sync/ChangeLog
+++ b/sync/ChangeLog
@@ -1,3 +1,26 @@
+2006-12-22 Chris Lord <chris@openedhand.com>
+
+ * configure.ac:
+ * src/Makefile.am:
+ library-ise libsync
+
+ * src/build-test.sh:
+ * src/sync-test.c:
+ Add a small test app for sync between eds and google cal
+
+ * src/sync_group.c: (sync_group_class_init),
+ (sync_group_set_namespace), (sync_group_get_item1),
+ (sync_group_get_item2), (sync_group_get_namespace):
+ Move the dodgy required gconf call to the get_default_env function,
+ make sure the environment (and thus threads) are initialised before
+ trying to create a new group.
+
+ * src/sync_main.c: (main):
+ Remove the dodgy gconf call, is now in libsync
+
+ * src/sync_syncml_item.c: (sync_syncml_item_get_member):
+ Explicitly enable and disable all syncable types
+
2006-12-19 Chris Lord <chris@openedhand.com>
* data/sync.glade:
diff --git a/sync/configure.ac b/sync/configure.ac
index 39264b4..7830712 100644
--- a/sync/configure.ac
+++ b/sync/configure.ac
@@ -16,4 +16,6 @@ AC_OUTPUT([
Makefile
data/Makefile
src/Makefile
+src/libsync.pc
])
+
diff --git a/sync/src/Makefile.am b/sync/src/Makefile.am
index 1f328f8..cad3d61 100644
--- a/sync/src/Makefile.am
+++ b/sync/src/Makefile.am
@@ -1,15 +1,33 @@
AM_CPPFLAGS=-DPKGDATADIR=\"$(pkgdatadir)\"
AM_CFLAGS = -Wall -export-dynamic $(SYNC_CFLAGS)
+lib_LTLIBRARIES = libsync.la
+
bin_PROGRAMS = sync
-sync_SOURCES = sync_main.c sync.h sync_group.c sync_group.h sync_item.c \
- sync_item.h sync_evo2_item.c sync_evo2_item.h sync_file_item.c \
- sync_file_item.h sync_syncml_item.c sync_syncml_item.h \
- sync_syncml_server_item.c sync_syncml_server_item.h \
- sync_gcal_item.c sync_gcal_item.h \
- sync_collection.c sync_collection.h
+sync_SOURCES = sync_main.c sync_main.h
+
+libsync_la_SOURCES = \
+ sync_group.c sync_group.h sync_item.c \
+ sync_item.h sync_evo2_item.c sync_evo2_item.h sync_file_item.c \
+ sync_file_item.h sync_syncml_item.c sync_syncml_item.h \
+ sync_syncml_server_item.c sync_syncml_server_item.h \
+ sync_gcal_item.c sync_gcal_item.h \
+ sync_collection.c sync_collection.h
+
+libsync_la_LIBADD = $(DATES_LIBS)
+libsyncincludedir = $(includedir)/sync/
+libsyncinclude_HEADERS = \
+ sync_item.h sync_file_item.h sync_evo2_item.h sync_gcal_item.h \
+ sync_syncml_item.h sync_syncml_server_item.h sync_group.h \
+ sync_collection.h
+
+sync_LDADD = $(SYNC_LIBS) libsync.la
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libsync.pc
+
+EXTRA_DIST=libsync.pc.in sync-test.c build-test.sh
-sync_LDADD = $(SYNC_LIBS)
+MAINTAINERCLEANFILES = config.h.in Makefile.in sync-test
-MAINTAINERCLEANFILES = config.h.in Makefile.in
diff --git a/sync/src/build-test.sh b/sync/src/build-test.sh
new file mode 100755
index 0000000..839a580
--- /dev/null
+++ b/sync/src/build-test.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+gcc -o sync-test sync-test.c `pkg-config --cflags --libs gtk+-2.0 libsync` -Wall -g
diff --git a/sync/src/sync-test.c b/sync/src/sync-test.c
new file mode 100644
index 0000000..49e3114
--- /dev/null
+++ b/sync/src/sync-test.c
@@ -0,0 +1,117 @@
+
+#include <gtk/gtk.h>
+#include <sync/sync_group.h>
+#include <sync/sync_item.h>
+#include <sync/sync_evo2_item.h>
+#include <sync/sync_gcal_item.h>
+
+static GtkWidget *window, *button, *progress, *scrollview, *textview, *vbox;
+
+static void
+finished_cb (SyncGroup *group) {
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress), "Success");
+ gtk_widget_set_sensitive (button, TRUE);
+}
+
+static void
+failed_cb (SyncGroup *group, const gchar *error)
+{
+ finished_cb (group);
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress), "Failed");
+ gtk_text_buffer_set_text (gtk_text_view_get_buffer (
+ GTK_TEXT_VIEW (textview)), error, -1);
+ gtk_widget_show (scrollview);
+}
+
+static void
+clicked_cb (GtkButton *button, SyncGroup *group) {
+ gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
+
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress), "Preparing...");
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), 0);
+
+ sync_group_start (group);
+
+ gtk_widget_hide (scrollview);
+}
+
+static void
+started_cb (SyncGroup *group)
+{
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress),
+ "Synchronising...");
+}
+
+static void
+progress_cb (SyncGroup *group, gdouble fraction)
+{
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), fraction);
+}
+
+int
+main (int argc, char **argv) {
+ SyncItem *item1, *item2;
+ SyncGroup *group;
+ GOptionContext *context;
+ static gchar *user = NULL;
+ static gchar *pass = NULL;
+
+ static GOptionEntry entries[] = {
+ { "user", 'u', 0, G_OPTION_ARG_STRING, &user,
+ "GMail user-name", NULL },
+ { "password", 'p', 0, G_OPTION_ARG_STRING, &pass,
+ "GMail password", NULL },
+ { NULL }
+ };
+
+ context = g_option_context_new (
+ " - A Google calendar synchronisation tool");
+ g_option_context_add_main_entries (context, entries, NULL);
+ g_option_context_add_group (context, gtk_get_option_group (TRUE));
+ g_option_context_parse (context, &argc, &argv, NULL);
+
+ if ((!user) || (!pass)) {
+ g_error ("No username or password specified");
+ return 1;
+ }
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ vbox = gtk_vbox_new (FALSE, 6);
+
+ button = gtk_button_new_with_label ("Synchronise");
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, TRUE, 0);
+
+ progress = gtk_progress_bar_new ();
+ gtk_box_pack_start (GTK_BOX (vbox), progress, FALSE, TRUE, 0);
+
+ scrollview = gtk_scrolled_window_new (NULL, NULL);
+ textview = gtk_text_view_new ();
+ gtk_container_add (GTK_CONTAINER (scrollview), textview);
+ gtk_box_pack_start (GTK_BOX (vbox), scrollview, TRUE, TRUE, 0);
+
+ gtk_container_add (GTK_CONTAINER (window), vbox);
+
+ item1 = sync_evo2_item_new ("Local", NULL, NULL, NULL);
+ item2 = sync_gcal_item_new ("GCal", user, pass);
+ group = sync_group_new_with_items (item1, item2);
+
+ gtk_widget_show_all (window);
+ gtk_widget_hide (scrollview);
+
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (clicked_cb), group);
+ g_signal_connect (G_OBJECT (window), "destroy",
+ G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (G_OBJECT (group), "started",
+ G_CALLBACK (started_cb), NULL);
+ g_signal_connect (G_OBJECT (group), "progress",
+ G_CALLBACK (progress_cb), NULL);
+ g_signal_connect (G_OBJECT (group), "finished",
+ G_CALLBACK (finished_cb), NULL);
+ g_signal_connect (G_OBJECT (group), "failed",
+ G_CALLBACK (failed_cb), NULL);
+
+ gtk_main ();
+
+ return 0;
+}
diff --git a/sync/src/sync_group.c b/sync/src/sync_group.c
index adf9d49..4cf32e9 100644
--- a/sync/src/sync_group.c
+++ b/sync/src/sync_group.c
@@ -200,11 +200,38 @@ sync_group_class_init (SyncGroupClass *klass)
object_class->finalize = sync_group_finalize;
}
+static OSyncEnv *
+sync_group_get_default_env ()
+{
+ if (!default_env) {
+ OSyncError *error = NULL;
+
+ /* FIXME: Must be called due to buggy OpenSync */
+ gconf_client_get_default ();
+
+ /* Threads must be initialised for autostart, do it here */
+ if (!g_thread_supported ()) g_thread_init (NULL);
+
+ default_env = osync_env_new ();
+ g_debug ("Creating new environment");
+ if (!osync_env_initialize (default_env, &error)) {
+ g_error ("Unable to initialise OSyncEnv: %s",
+ osync_error_print (&error));
+ osync_env_free (default_env);
+ default_env = NULL;
+ }
+ }
+
+ return default_env;
+}
+
static void
sync_group_init (SyncGroup *self)
{
SyncGroupPrivate *priv = GROUP_PRIVATE (self);
+ sync_group_get_default_env ();
+
priv->mutex = g_mutex_new ();
priv->namespace = g_strdup ("libsync");
}
@@ -279,28 +306,6 @@ sync_group_get_namespace (SyncGroup *group)
return priv->namespace;
}
-static OSyncEnv *
-sync_group_get_default_env ()
-{
- if (!default_env) {
- OSyncError *error = NULL;
-
- /* Threads must be initialised for autostart, do it here */
- if (!g_thread_supported ()) g_thread_init (NULL);
-
- default_env = osync_env_new ();
- g_debug ("Creating new environment");
- if (!osync_env_initialize (default_env, &error)) {
- g_error ("Unable to initialise OSyncEnv: %s",
- osync_error_print (&error));
- osync_env_free (default_env);
- default_env = NULL;
- }
- }
-
- return default_env;
-}
-
gchar *sync_group_get_name (SyncGroup *group)
{
SyncGroupPrivate *priv = GROUP_PRIVATE (group);
diff --git a/sync/src/sync_main.c b/sync/src/sync_main.c
index 5640d76..7b929b4 100644
--- a/sync/src/sync_main.c
+++ b/sync/src/sync_main.c
@@ -397,9 +397,6 @@ main (int argc, char **argv)
/* g_thread_init (NULL);
gdk_threads_init ();*/
- /* FIXME: Must be called due to buggy OpenSync */
- gconf_client_get_default ();
-
data.xml = glade_xml_new (XML_FILE, NULL, NULL);
if (!data.xml)
g_error ("Could not find interface XML file '%s'", XML_FILE);
diff --git a/sync/src/sync_syncml_item.c b/sync/src/sync_syncml_item.c
index 239332d..11e5048 100644
--- a/sync/src/sync_syncml_item.c
+++ b/sync/src/sync_syncml_item.c
@@ -204,10 +204,15 @@ sync_syncml_item_get_member (SyncItem *item, SyncGroup *group)
osync_conv_nth_objtype (env, i));
if (strcmp (type, sync_syncml_type_to_type_string (
- data->type)) == 0)
- continue;
-
- osync_group_set_objtype_enabled (os_group, type, 0);
+ data->type)) == 0) {
+ g_debug ("Enabling %s type", type);
+ osync_group_set_objtype_enabled (
+ os_group, type, TRUE);
+ } else {
+ g_debug ("Disabling %s type", type);
+ osync_group_set_objtype_enabled (
+ os_group, type, FALSE);
+ }
}
}