aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/conduits
diff options
context:
space:
mode:
authorJP Rosevear <jpr@helixcode.com>2000-10-24 02:38:33 +0800
committerJP Rosevear <jpr@src.gnome.org>2000-10-24 02:38:33 +0800
commitab6f0dd67eb151c78a0acd716939e3015822582a (patch)
tree0dc7a7af1f3010ca27a082fb80cada68c98a85a4 /calendar/conduits
parent27f51ae4e98b5c13dccc67d434028fb147f314d3 (diff)
downloadgsoc2013-evolution-ab6f0dd67eb151c78a0acd716939e3015822582a.tar
gsoc2013-evolution-ab6f0dd67eb151c78a0acd716939e3015822582a.tar.gz
gsoc2013-evolution-ab6f0dd67eb151c78a0acd716939e3015822582a.tar.bz2
gsoc2013-evolution-ab6f0dd67eb151c78a0acd716939e3015822582a.tar.lz
gsoc2013-evolution-ab6f0dd67eb151c78a0acd716939e3015822582a.tar.xz
gsoc2013-evolution-ab6f0dd67eb151c78a0acd716939e3015822582a.tar.zst
gsoc2013-evolution-ab6f0dd67eb151c78a0acd716939e3015822582a.zip
Add libeconduit-static.la
2000-10-23 JP Rosevear <jpr@helixcode.com> * conduits/calendar/Makefile.am: Add libeconduit-static.la * conduits/calendar/calendar-conduit.c (post_sync): Use e_pilot_map_write (pre_sync): Use e_pilot_map_read svn path=/trunk/; revision=6119
Diffstat (limited to 'calendar/conduits')
-rw-r--r--calendar/conduits/calendar/Makefile.am2
-rw-r--r--calendar/conduits/calendar/calendar-conduit.c136
2 files changed, 15 insertions, 123 deletions
diff --git a/calendar/conduits/calendar/Makefile.am b/calendar/conduits/calendar/Makefile.am
index 25282d9c53..d421a710b0 100644
--- a/calendar/conduits/calendar/Makefile.am
+++ b/calendar/conduits/calendar/Makefile.am
@@ -3,6 +3,7 @@ INCLUDES = \
-I$(top_srcdir)/calendar \
-I$(top_srcdir)/libical/src/libical \
-I$(top_builddir)/libical/src/libical \
+ -I$(top_builddir)/e-util \
$(BONOBO_VFS_GNOME_CFLAGS) \
$(GNOME_PILOT_CFLAGS)
@@ -36,6 +37,7 @@ libecalendar_conduit_la_LIBADD = \
$(top_builddir)/calendar/cal-util/libcal-util-static.la \
$(top_builddir)/libversit/libversit.la \
$(top_builddir)/libical/src/libical/libical-static.la \
+ $(top_builddir)/e-util/libeconduit-static.la \
$(BONOBO_VFS_GNOME_LIBS) \
$(PISOCK_LIBDIR) $(PISOCK_LIBS) \
$(GNOME_LIBDIR) \
diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c
index 7452e0f911..945c384b21 100644
--- a/calendar/conduits/calendar/calendar-conduit.c
+++ b/calendar/conduits/calendar/calendar-conduit.c
@@ -41,6 +41,7 @@
#include <pi-dlp.h>
#include <pi-version.h>
#include <libical/src/libical/icaltypes.h>
+#include <e-pilot-map.h>
#define CAL_CONFIG_LOAD 1
#define CAL_CONFIG_DESTROY 1
@@ -146,120 +147,6 @@ e_calendar_context_destroy (ECalConduitContext **ctxt)
*ctxt = NULL;
}
-/* Map routines */
-static char *
-map_name (ECalConduitContext *ctxt)
-{
- char *filename;
-
- filename = g_strdup_printf ("%s/evolution/local/Calendar/pilot-map-%d.xml", g_get_home_dir (), ctxt->cfg->pilot_id);
-
- return filename;
-}
-
-static void
-map_set_node_timet (xmlNodePtr node, const char *name, time_t t)
-{
- char *tstring;
-
- tstring = g_strdup_printf ("%ld", t);
- xmlSetProp (node, name, tstring);
-}
-
-static void
-map_sax_start_element (void *data, const xmlChar *name,
- const xmlChar **attrs)
-{
- ECalConduitContext *ctxt = (ECalConduitContext *)data;
-
- if (!strcmp (name, "PilotMap")) {
- while (attrs && *attrs != NULL) {
- const xmlChar **val = attrs;
-
- val++;
- if (!strcmp (*attrs, "timestamp"))
- ctxt->since = (time_t)strtoul (*val, NULL, 0);
-
- attrs = ++val;
- }
- }
-
- if (!strcmp (name, "map")) {
- char *uid = NULL;
- guint32 *pid = g_new (guint32, 1);
-
- *pid = 0;
-
- while (attrs && *attrs != NULL) {
- const xmlChar **val = attrs;
-
- val++;
- if (!strcmp (*attrs, "uid"))
- uid = g_strdup (*val);
-
- if (!strcmp (*attrs, "pilot_id"))
- *pid = strtoul (*val, NULL, 0);
-
- attrs = ++val;
- }
-
- if (uid && *pid != 0) {
- g_hash_table_insert (ctxt->pid_map, pid, uid);
- g_hash_table_insert (ctxt->uid_map, uid, pid);
- } else {
- g_free (pid);
- }
- }
-}
-
-static void
-map_write_foreach (gpointer key, gpointer value, gpointer data)
-{
- xmlNodePtr root = data;
- xmlNodePtr mnode;
- unsigned long *pid = key;
- const char *uid = value;
- char *pidstr;
-
- mnode = xmlNewChild (root, NULL, "map", NULL);
- xmlSetProp (mnode, "uid", uid);
- pidstr = g_strdup_printf ("%lu", *pid);
- xmlSetProp (mnode, "pilot_id", pidstr);
- g_free (pidstr);
-}
-
-static int
-map_write (ECalConduitContext *ctxt, char *filename)
-{
- xmlDocPtr doc;
- int ret;
-
- if (ctxt->pid_map == NULL)
- return 0;
-
- doc = xmlNewDoc ("1.0");
- if (doc == NULL) {
- WARN ("Pilot map file could not be created\n");
- return -1;
- }
- doc->root = xmlNewDocNode(doc, NULL, "PilotMap", NULL);
- map_set_node_timet (doc->root, "timestamp", time (NULL));
-
- g_hash_table_foreach (ctxt->pid_map, map_write_foreach, doc->root);
-
- /* Write the file */
- xmlSetDocCompressMode (doc, 0);
- ret = xmlSaveFile (filename, doc);
- if (ret < 0) {
- g_warning ("Pilot map file '%s' could not be saved\n", filename);
- return -1;
- }
-
- xmlFreeDoc (doc);
-
- return 0;
-}
-
/* Calendar Server routines */
static void
start_calendar_server_cb (GtkWidget *cal_client,
@@ -316,6 +203,16 @@ start_calendar_server (ECalConduitContext *ctxt)
}
/* Utility routines */
+static char *
+map_name (ECalConduitContext *ctxt)
+{
+ char *filename;
+
+ filename = g_strdup_printf ("%s/evolution/local/Calendar/pilot-map-%d.xml", g_get_home_dir (), ctxt->cfg->pilot_id);
+
+ return filename;
+}
+
static icalrecurrencetype_weekday
get_ical_day (int day)
{
@@ -743,14 +640,7 @@ pre_sync (GnomePilotConduit *conduit,
ctxt->uid_map = g_hash_table_new (g_str_hash, g_str_equal);
filename = map_name (ctxt);
- if (g_file_exists (filename)) {
- memset (&handler, 0, sizeof (xmlSAXHandler));
- handler.startElement = map_sax_start_element;
-
- if (xmlSAXUserParseFile (&handler, ctxt, filename) < 0)
- return -1;
- }
-
+ e_pilot_map_read (filename, ctxt->pid_map, ctxt->uid_map, &ctxt->since);
g_free (filename);
/* Find the added, modified and deleted items */
@@ -819,7 +709,7 @@ post_sync (GnomePilotConduit *conduit,
LOG ("---------------------------------------------------------\n");
filename = map_name (ctxt);
- map_write (ctxt, filename);
+ e_pilot_map_write (filename, ctxt->pid_map);
g_free (filename);
return 0;