aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorJP Rosevear <jpr@helixcode.com>2000-10-21 05:04:47 +0800
committerJP Rosevear <jpr@src.gnome.org>2000-10-21 05:04:47 +0800
commite2e21e3f7650b33259ae9e60ac8b7f5b78dbb098 (patch)
tree088ece25751c05553fcdab95b759cff99a0280b2 /addressbook
parent06ef60fa04a5b10f5238c9eb39ade9dc152fcb04 (diff)
downloadgsoc2013-evolution-e2e21e3f7650b33259ae9e60ac8b7f5b78dbb098.tar.gz
gsoc2013-evolution-e2e21e3f7650b33259ae9e60ac8b7f5b78dbb098.tar.zst
gsoc2013-evolution-e2e21e3f7650b33259ae9e60ac8b7f5b78dbb098.zip
New structure of file - similar to calendar/todo conduits
2000-10-20 JP Rosevear <jpr@helixcode.com> * conduit/address-conduit.h: New structure of file - similar to calendar/todo conduits * conduit/address-conduit.c: ditto * conduit/address-conduit-config.h: Config stuff for conduit * conduit/.cvsignore: Update * conduit/Makefile.am: Build fixes * conduit/address-conduit-control-applet.desktop: Renamed to e-address-conduit-control-applet.desktop * conduit/address.conduit.in: Renamed to e-address.conduit.in svn path=/trunk/; revision=6081
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog18
-rw-r--r--addressbook/conduit/.cvsignore6
-rw-r--r--addressbook/conduit/Makefile.am58
-rw-r--r--addressbook/conduit/address-conduit-control-applet.c233
-rw-r--r--addressbook/conduit/address-conduit-control-applet.desktop18
-rw-r--r--addressbook/conduit/address-conduit.c1651
-rw-r--r--addressbook/conduit/address-conduit.h110
-rw-r--r--addressbook/conduit/address.conduit.in8
8 files changed, 1002 insertions, 1100 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index c3e6270fac..b4a317d9b5 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,21 @@
+2000-10-20 JP Rosevear <jpr@helixcode.com>
+
+ * conduit/address-conduit.h: New structure of file - similar
+ to calendar/todo conduits
+
+ * conduit/address-conduit.c: ditto
+
+ * conduit/address-conduit-config.h: Config stuff for conduit
+
+ * conduit/.cvsignore: Update
+
+ * conduit/Makefile.am: Build fixes
+
+ * conduit/address-conduit-control-applet.desktop: Renamed
+ to e-address-conduit-control-applet.desktop
+
+ * conduit/address.conduit.in: Renamed to e-address.conduit.in
+
2000-10-19 Christopher James Lahey <clahey@helixcode.com>
* gui/widgets/e-addressbook-view.c (SPEC): Remove Family name
diff --git a/addressbook/conduit/.cvsignore b/addressbook/conduit/.cvsignore
index 6f302c2ac7..67db02346b 100644
--- a/addressbook/conduit/.cvsignore
+++ b/addressbook/conduit/.cvsignore
@@ -3,6 +3,6 @@
*.lo
Makefile.in
Makefile
-libaddress_conduit.la
-address-conduit-control-applet
-address.conduit \ No newline at end of file
+libeaddress_conduit.la
+e-address-conduit-control-applet
+e-address.conduit \ No newline at end of file
diff --git a/addressbook/conduit/Makefile.am b/addressbook/conduit/Makefile.am
index da094e6a72..738710f671 100644
--- a/addressbook/conduit/Makefile.am
+++ b/addressbook/conduit/Makefile.am
@@ -2,52 +2,38 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/addressbook \
-I$(top_srcdir)/addressbook/backend \
- $(BONOBO_GNOME_CFLAGS) \
+ $(BONOBO_VFS_GNOME_CFLAGS) \
$(GNOME_PILOT_CFLAGS)
-bin_PROGRAMS = address-conduit-control-applet
+# Address Capplet
+bin_PROGRAMS = e-address-conduit-control-applet
-address_conduit_control_applet_SOURCES = address-conduit-control-applet.c
+e_address_conduit_control_applet_SOURCES = address-conduit-control-applet.c
-address_conduit_control_applet_LDADD = \
+e_address_conduit_control_applet_LDADD = \
$(CAPPLET_LIBS) \
$(GNOME_LIBDIR) \
- -lgpilotdcm \
- -lgpilotd \
- -lgpilotdconduit \
+ $(GNOME_PILOT_LIBS) \
+ $(PISOCK_LIBDIR) $(PISOCK_LIBS) \
$(GNOME_CAPPLET_LIBS) \
$(BONOBO_VFS_GNOME_LIBS) \
$(GNOME_XML_LIB) \
$(GNOMEUI_LIBS) \
- $(PISOCK_LIBDIR) $(PISOCK_LIBS) \
$(INTLLIBS)
-# address_conduit
-address_conduitsdir=$(libdir)/gnome-pilot/conduits
-address_conduits_LTLIBRARIES = libaddress_conduit.la
+# Address Conduit
+e_address_conduitsdir=$(libdir)/gnome-pilot/conduits
+e_address_conduits_LTLIBRARIES = libeaddress_conduit.la
-libaddress_conduit_la_SOURCES = \
+libeaddress_conduit_la_SOURCES = \
address-conduit.c \
- address-conduit.h
-
-# address-conduit.c: my_gnomecal_idl
-
-address.conduit: address.conduit.in Makefile
- sed -e 's^\@prefix\@^$(prefix)^g' < $(srcdir)/address.conduit.in > address.conduit.tmp \
- && mv address.conduit.tmp address.conduit
+ address-conduit.h \
+ address-conduit-config.h
-#
-# conduit
-#
-
-libaddress_conduit_la_LDFLAGS = \
- -rpath $(libdir)
-
-libaddress_conduit_la_LIBADD = \
+libeaddress_conduit_la_LIBADD = \
$(top_builddir)/addressbook/backend/ebook/libebook-static.la \
$(top_builddir)/e-util/libeutil-static.la \
- $(top_builddir)/addressbook/ename/libename-static.la \
$(top_builddir)/libversit/libversit.la \
$(top_builddir)/libical/src/libical/libical-static.la \
$(BONOBO_VFS_GNOME_LIBS) \
@@ -55,21 +41,31 @@ libaddress_conduit_la_LIBADD = \
$(GNOME_LIBDIR) \
$(GNOME_LIBS)
+e-address.conduit: e-address.conduit.in Makefile
+ sed -e 's^\@prefix\@^$(prefix)^g' < $(srcdir)/e-address.conduit.in > e-address.conduit.tmp \
+ && mv e-address.conduit.tmp e-address.conduit
+
+
ccenterdir = $(datadir)/control-center
ccenterPalmPilotdir = $(ccenterdir)/Peripherals
ccenterConduitsdir = $(ccenterPalmPilotdir)/Conduits
-ccenterConduits_DATA = address-conduit-control-applet.desktop
+ccenterConduits_DATA = e-address-conduit-control-applet.desktop
panelConduitsdir = $(datadir)/gnome/apps/Settings/Peripherals/Conduits
panelConduits_DATA = $(ccenterConduits_DATA)
Conduitdir = $(datadir)/gnome-pilot/conduits/
-Conduit_DATA = address.conduit
+Conduit_DATA = e-address.conduit
EXTRA_DIST = \
- address.conduit.in \
+ e-address.conduit.in \
$(ccenterConduits_DATA)
install-data-local:
$(mkinstalldirs) $(ccenterConduitsdir)
$(mkinstalldirs) $(Conduitdir)
+
+
+
+
+
diff --git a/addressbook/conduit/address-conduit-control-applet.c b/addressbook/conduit/address-conduit-control-applet.c
index 07a6e0042f..3cbdbf8976 100644
--- a/addressbook/conduit/address-conduit-control-applet.c
+++ b/addressbook/conduit/address-conduit-control-applet.c
@@ -1,7 +1,26 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* Control applet ("capplet") for the gnome-pilot address conduit, */
-/* based on */
-/* gpilotd control applet ('capplet') for use with the GNOME control center */
+/* Evolution addressbook - Address Conduit Capplet
+ *
+ * Copyright (C) 1998 Free Software Foundation
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * Authors: Eskil Heyn Olsen <deity@eskil.dk>
+ * JP Rosevear <jpr@helixcode.com>
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
#include <pwd.h>
#include <sys/types.h>
@@ -11,12 +30,17 @@
#include <config.h>
#include <capplet-widget.h>
-#include <libgpilotdCM/gnome-pilot-conduit-management.h>
-#include <libgpilotdCM/gnome-pilot-conduit-config.h>
#include <gpilotd/gnome-pilot-client.h>
-#include "address-conduit.h"
-
+#define ADDR_CONFIG_LOAD 1
+#define ADDR_CONFIG_SAVE 1
+#define ADDR_CONFIG_DUPE 1
+#define ADDR_CONFIG_DESTROY 1
+#include <address-conduit-config.h>
+#undef ADDR_CONFIG_LOAD
+#undef ADDR_CONFIG_SAVE
+#undef ADDR_CONFIG_DUPE
+#undef ADDR_CONFIG_DESTROY
/* tell changes callbacks to ignore changes or not */
static gboolean ignore_changes=FALSE;
@@ -32,21 +56,20 @@ GtkWidget *dialogWindow=NULL;
gboolean activated,org_activation_state;
GnomePilotConduitManagement *conduit;
GnomePilotConduitConfig *conduit_config;
-AddressbookConduitCfg *origState = NULL;
-AddressbookConduitCfg *curState = NULL;
+EAddrConduitCfg *origState = NULL;
+EAddrConduitCfg *curState = NULL;
-static void doTrySettings(GtkWidget *widget, AddressbookConduitCfg *cfg);
-static void doRevertSettings(GtkWidget *widget, AddressbookConduitCfg *cfg);
-static void doSaveSettings(GtkWidget *widget, AddressbookConduitCfg *cfg);
+static void doTrySettings(GtkWidget *widget, EAddrConduitCfg *c);
+static void doRevertSettings(GtkWidget *widget, EAddrConduitCfg *c);
+static void doSaveSettings(GtkWidget *widget, EAddrConduitCfg *c);
-//static void readStateCfg (GtkWidget *w, AddressbookConduitCfg *c);
-static void setStateCfg (GtkWidget *w, AddressbookConduitCfg *c);
+static void setStateCfg (GtkWidget *w, EAddrConduitCfg *c);
gint pilotId;
-CORBA_Environment ev;
static GnomePilotClient *gpc;
+
/* This array must be in the same order as enumerations
in GnomePilotConduitSyncType as they are used as index.
Custom type implies Disabled state.
@@ -59,50 +82,10 @@ static gchar* sync_options[] ={ N_("Disabled"),
N_("Merge To Pilot")};
#define SYNC_OPTIONS_COUNT 6
-
-
-
-/* Saves the configuration data. */
-static void
-addressbookconduit_save_configuration(AddressbookConduitCfg *c)
-{
- gchar prefix[256];
-
- g_snprintf(prefix,255,"/gnome-pilot.d/address-conduit/Pilot_%u/",c->pilotId);
-
- gnome_config_push_prefix(prefix);
- gnome_config_set_bool ("open_secret", c->open_secret);
- gnome_config_pop_prefix();
-
- gnome_config_sync();
- gnome_config_drop_all();
-}
-
-/* Creates a duplicate of the configuration data */
-static AddressbookConduitCfg*
-gcalconduit_dupe_configuration(AddressbookConduitCfg *c) {
- AddressbookConduitCfg *retval;
- g_return_val_if_fail(c!=NULL,NULL);
- retval = g_new0(AddressbookConduitCfg,1);
- retval->sync_type = c->sync_type;
- retval->open_secret = c->open_secret;
- retval->pilotId = c->pilotId;
- return retval;
-}
-
-
static void
-doTrySettings(GtkWidget *widget, AddressbookConduitCfg *c)
+doTrySettings (GtkWidget *widget, EAddrConduitCfg *c)
{
- /*
- readStateCfg (cfgStateWindow, curState);
- if (activated)
- gnome_pilot_conduit_config_enable (conduit_config, GnomePilotConduitSyncTypeCustom);
- else
- gnome_pilot_conduit_config_disable (conduit_config);
- */
-
- if (c->sync_type!=GnomePilotConduitSyncTypeCustom)
+ if (c->sync_type != GnomePilotConduitSyncTypeCustom)
gnome_pilot_conduit_config_enable_with_first_sync (conduit_config,
c->sync_type,
c->sync_type,
@@ -110,43 +93,42 @@ doTrySettings(GtkWidget *widget, AddressbookConduitCfg *c)
else
gnome_pilot_conduit_config_disable (conduit_config);
- addressbookconduit_save_configuration (c);
+ addrconduit_save_configuration (c);
}
-
static void
-doSaveSettings(GtkWidget *widget, AddressbookConduitCfg *cfg)
+doRevertSettings (GtkWidget *widget, EAddrConduitCfg *c)
{
- doTrySettings(widget, cfg);
- addressbookconduit_save_configuration(cfg);
+ activated = org_activation_state;
+ *c = *origState;
+ setStateCfg (cfgStateWindow, c);
+ doTrySettings (widget, c);
}
-
static void
-doCancelSettings(GtkWidget *widget, AddressbookConduitCfg *c)
+doSaveSettings (GtkWidget *widget, EAddrConduitCfg *c)
{
- doSaveSettings (widget, c);
+ *origState = *c;
+ doTrySettings (widget, c);
}
-static void
-doRevertSettings(GtkWidget *widget, AddressbookConduitCfg *cfg)
-{
- activated = org_activation_state;
- setStateCfg (cfgStateWindow, curState);
-}
-
static void
-about_cb (GtkWidget *widget, gpointer data)
+doHelp (GtkWidget *widget, gpointer data)
{
GtkWidget *about;
- const gchar *authors[] = {_("Eskil Heyn Olsen <deity@eskil.dk>"),NULL};
+ const gchar *authors[] = {
+ _("JP Rosevear <jpr@helixcode.com>"),
+ "", _("Original Author:"),
+ _("Eskil Heyn Olsen <deity@eskil.dk>"),
+ NULL};
- about = gnome_about_new (_("Gpilotd address conduit"), VERSION,
- _("(C) 1998 the Free Software Foundation"),
- authors,
- _("Configuration utility for the address conduit.\n"),
- _("gnome-unknown.xpm"));
+ about = gnome_about_new (
+ _("Evolution Addressbook Conduit"), VERSION,
+ _("(C) 1998-2000 the Free Software Foundation and Helix Code"),
+ authors,
+ _("Configuration utility for the evolution addressbook conduit.\n"),
+ _("gnome-unknown.xpm"));
gtk_widget_show (about);
return;
@@ -155,26 +137,16 @@ about_cb (GtkWidget *widget, gpointer data)
/* called by the sync_type GtkOptionMenu */
static void
-sync_action_selection(GtkMenuShell *widget, gpointer unused)
+activate_sync_type (GtkMenuItem *widget, gpointer data)
{
- if (!ignore_changes) {
- capplet_widget_state_changed(CAPPLET_WIDGET (capplet), TRUE);
- }
+ curState->sync_type = GPOINTER_TO_INT (data);
+ if (!ignore_changes)
+ capplet_widget_state_changed (CAPPLET_WIDGET (capplet), TRUE);
}
-/* called by the sync_type GtkOptionMenu */
-static void
-activate_sync_type(GtkMenuItem *widget, gpointer data)
-{
- curState->sync_type = GPOINTER_TO_INT(data);
- if(!ignore_changes)
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-
-static GtkWidget
-*createStateCfgWindow(void)
+static GtkWidget *
+createStateCfgWindow(void)
{
GtkWidget *vbox, *table;
GtkWidget *label;
@@ -205,10 +177,6 @@ static GtkWidget
}
gtk_option_menu_set_menu(GTK_OPTION_MENU(optionMenu),GTK_WIDGET(menu));
- gtk_signal_connect(GTK_OBJECT(menu), "selection-done",
- GTK_SIGNAL_FUNC(sync_action_selection),
- NULL);
-
gtk_box_pack_start(GTK_BOX(table), optionMenu, FALSE, FALSE, 0);
return vbox;
@@ -216,7 +184,7 @@ static GtkWidget
static void
-setStateCfg (GtkWidget *w, AddressbookConduitCfg *c)
+setStateCfg (GtkWidget *w, EAddrConduitCfg *c)
{
GtkOptionMenu *optionMenu;
GtkMenu *menu;
@@ -232,21 +200,6 @@ setStateCfg (GtkWidget *w, AddressbookConduitCfg *c)
ignore_changes = FALSE;
}
-
-#if 0
-static void
-readStateCfg (GtkWidget *w, AddressbookConduitCfg *c)
-{
- /*
- GtkWidget *button;
- button = gtk_object_get_data(GTK_OBJECT(cfg), "conduit_on_off");
- g_assert(button!=NULL);
- activated = GTK_TOGGLE_BUTTON(button)->active;
- */
-}
-#endif /* 0 */
-
-
static void
pilot_capplet_setup(void)
{
@@ -270,10 +223,8 @@ pilot_capplet_setup(void)
GTK_SIGNAL_FUNC(doRevertSettings), curState);
gtk_signal_connect(GTK_OBJECT(capplet), "ok",
GTK_SIGNAL_FUNC(doSaveSettings), curState);
- gtk_signal_connect(GTK_OBJECT(capplet), "cancel",
- GTK_SIGNAL_FUNC(doCancelSettings), curState);
gtk_signal_connect(GTK_OBJECT(capplet), "help",
- GTK_SIGNAL_FUNC(about_cb), NULL);
+ GTK_SIGNAL_FUNC(doHelp), NULL);
setStateCfg (cfgStateWindow, curState);
@@ -350,37 +301,41 @@ main (int argc, char *argv[])
G_LOG_LEVEL_CRITICAL |
G_LOG_LEVEL_WARNING);
- /* we're a capplet */
- gnome_capplet_init ("address conduit control applet", NULL, argc, argv,
+ /* Init capplet */
+ gnome_capplet_init ("Evolution Address conduit control applet",
+ NULL, argc, argv,
NULL, 0, NULL);
-
- gpc = gnome_pilot_client_new();
- gnome_pilot_client_connect_to_daemon(gpc);
- pilotId = get_pilot_id_from_gpilotd();
- if(!pilotId) return -1;
+ /* Setup Client */
+ gpc = gnome_pilot_client_new ();
+ gnome_pilot_client_connect_to_daemon (gpc);
+ pilotId = get_pilot_id_from_gpilotd ();
+ if (!pilotId)
+ return -1;
- /* put all code to set things up in here */
- conduit_load_configuration (&origState, pilotId);
+
+ /* Put all code to set things up in here */
+ conduit = gnome_pilot_conduit_management_new ("e_address_conduit", GNOME_PILOT_CONDUIT_MGMT_ID);
+ if (conduit == NULL)
+ return -1;
- conduit = gnome_pilot_conduit_management_new ("address_conduit", GNOME_PILOT_CONDUIT_MGMT_ID);
- if (conduit == NULL) return -1;
+ addrconduit_load_configuration (&origState, pilotId);
conduit_config = gnome_pilot_conduit_config_new (conduit, pilotId);
- org_activation_state = gnome_pilot_conduit_config_is_enabled (conduit_config,
- &origState->sync_type);
- activated = org_activation_state;
-
- //gpilotd_conduit_mgmt_get_sync_type (conduit, pilotId, &origState->sync_type);
+ org_activation_state = activated =
+ gnome_pilot_conduit_config_is_enabled (conduit_config,
+ &origState->sync_type);
- curState = gcalconduit_dupe_configuration(origState);
+ curState = addrconduit_dupe_configuration (origState);
pilot_capplet_setup ();
-
- /* done setting up, now run main loop */
+ /* Done setting up, now run main loop */
capplet_gtk_main();
-
- gnome_pilot_conduit_management_destroy(conduit);
+ /* Clean up */
+ gnome_pilot_conduit_management_destroy (conduit);
+ addrconduit_destroy_configuration (&origState);
+ addrconduit_destroy_configuration (&curState);
+
return 0;
}
diff --git a/addressbook/conduit/address-conduit-control-applet.desktop b/addressbook/conduit/address-conduit-control-applet.desktop
deleted file mode 100644
index 86828ccbca..0000000000
--- a/addressbook/conduit/address-conduit-control-applet.desktop
+++ /dev/null
@@ -1,18 +0,0 @@
-[Desktop Entry]
-Name=Address conduit
-Name[da]=Udstående
-Name[es]=Enlace de direcciones
-Name[fr]=Conduit Adresses
-Name[no]=Oppgaver
-Name[sv]=Adresser
-Name[tr]=Adres parçasý
-Comment=Configure the address conduit
-Comment[da]=Konfigurér Udstående
-Comment[es]=Configurar el enlace de direcciones
-Comment[fr]=Configuration du conduit Adresses
-Comment[no]=Konfigurér oppgavelisten
-Comment[sv]=Konfigurera adresskanalen
-Comment[tr]=Adres parçasýnýn ayarlarý
-Exec=address-conduit-control-applet --cap-id=1
-Terminal=0
-Type=Application
diff --git a/addressbook/conduit/address-conduit.c b/addressbook/conduit/address-conduit.c
index d863d22af4..2914d6f4b8 100644
--- a/addressbook/conduit/address-conduit.c
+++ b/addressbook/conduit/address-conduit.c
@@ -1,4 +1,26 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* Evolution addressbook - Address Conduit
+ *
+ * Copyright (C) 1998 Free Software Foundation
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * Authors: Eskil Heyn Olsen <deity@eskil.dk>
+ * JP Rosevear <jpr@helixcode.com>
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
#include <config.h>
#include <sys/stat.h>
@@ -8,106 +30,265 @@
#include <signal.h>
#include <errno.h>
+#include <liboaf/liboaf.h>
+#include <bonobo.h>
+#include <gnome-xml/parser.h>
#include <pi-source.h>
#include <pi-socket.h>
#include <pi-file.h>
#include <pi-dlp.h>
-#include <libgnorba/gnorba.h>
-#include <libgnorba/gnome-factory.h>
#include <pi-version.h>
-#include <gpilotd/gnome-pilot-conduit.h>
-#include <gpilotd/gnome-pilot-conduit-standard-abs.h>
-#include <address-conduit.h>
-#include "ebook/e-book-types.h"
+#include <ebook/e-book.h>
+#include <ebook/e-card-cursor.h>
+#include <ebook/e-card.h>
+#include <ebook/e-card-simple.h>
-#include <bonobo.h>
+#define ADDR_CONFIG_LOAD 1
+#define ADDR_CONFIG_DESTROY 1
+#include <address-conduit-config.h>
+#undef ADDR_CONFIG_LOAD
+#undef ADDR_CONFIG_DESTROY
+
+#include <address-conduit.h>
GnomePilotConduit * conduit_get_gpilot_conduit (guint32);
void conduit_destroy_gpilot_conduit (GnomePilotConduit*);
-void local_record_from_ecard (AddressbookLocalRecord *local, ECard *ecard);
-#define CONDUIT_VERSION "0.1"
+#define CONDUIT_VERSION "0.1.0"
#ifdef G_LOG_DOMAIN
#undef G_LOG_DOMAIN
#endif
-#define G_LOG_DOMAIN "addressconduit"
+#define G_LOG_DOMAIN "eaddrconduit"
-/* #define SUPPORT_ARCHIVING 1 */
-#define NEED_OAF_INIT_HACK 1
-#define DEBUG_ADDRESSBOOKCONDUIT 1
+#define DEBUG_CONDUIT 1
+/* #undef DEBUG_CONDUIT */
-#ifdef DEBUG_ADDRESSBOOKCONDUIT
-#define show_exception(e) g_warning ("Exception: %s\n", CORBA_exception_id (e))
-#define LOG(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE, e)
+#ifdef DEBUG_CONDUIT
+#define LOG(e...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, e)
#else
-#define show_exception(e)
#define LOG(e...)
-#endif
+#endif
-#define WARN(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_WARNING, e)
-#define INFO(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE, e)
+#define WARN(e...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, e)
+#define INFO(e...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, e)
-#define catch_ret_val(_env,ret) \
- if (_env._major != CORBA_NO_EXCEPTION) { \
- g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE,"%s:%d: Caught exception",__FILE__,__LINE__); \
- g_warning ("Exception: %s\n", CORBA_exception_id (&(_env))); \
- CORBA_exception_free(&(_env)); \
- return ret; \
- }
+typedef struct {
+ EBookStatus status;
+ char *id;
+} add_card_cons;
+
+/* debug spew DELETE ME */
+static char *
+print_local (EAddrLocalRecord *local)
+{
+ static char buff[ 4096 ];
+ if (local == NULL) {
+ sprintf (buff, "[NULL]");
+ return buff;
+ }
+
+/* if (local->addr && local->addr->description) { */
+/* sprintf (buff, "[%d %ld %d %d '%s' '%s']", */
+/* local->todo->indefinite, */
+/* mktime (& local->todo->due), */
+/* local->todo->priority, */
+/* local->todo->complete, */
+/* local->todo->description, */
+/* local->todo->note); */
+/* return buff; */
+/* } */
+
+ return "";
+}
+
+
+/* debug spew DELETE ME */
+static char *print_remote (GnomePilotRecord *remote)
+{
+ static char buff[ 4096 ];
+ struct Address addr;
+
+ if (remote == NULL) {
+ sprintf (buff, "[NULL]");
+ return buff;
+ }
+
+ memset (&addr, 0, sizeof (struct Address));
+ unpack_Address (&addr, remote->record, remote->length);
+
+ sprintf (buff, "Hi");
+/* sprintf (buff, "[%d %ld %d %d '%s' '%s']", */
+/* todo.indefinite, */
+/* mktime (& todo.due), */
+/* todo.priority, */
+/* todo.complete, */
+/* todo.description, */
+/* todo.note); */
+
+ return buff;
+}
+/* Context Routines */
static void
-status_cb (EBook *ebook, EBookStatus status, gpointer closure)
+e_addr_context_new (EAddrConduitContext **ctxt, guint32 pilot_id)
{
- (*(EBookStatus*)closure) = status;
- gtk_main_quit();
+ *ctxt = g_new0 (EAddrConduitContext,1);
+ g_assert (ctxt!=NULL);
+
+ addrconduit_load_configuration (&(*ctxt)->cfg, pilot_id);
}
+static void
+e_addr_context_destroy (EAddrConduitContext **ctxt)
+{
+ g_return_if_fail (ctxt!=NULL);
+ g_return_if_fail (*ctxt!=NULL);
-/* Destroys any data allocated by gcalconduit_load_configuration
- and deallocates the given configuration. */
-static void
-conduit_destroy_configuration(AddressbookConduitCfg **c)
+ if ((*ctxt)->cfg != NULL)
+ addrconduit_destroy_configuration (&(*ctxt)->cfg);
+
+ g_free (*ctxt);
+ *ctxt = NULL;
+}
+
+/* Map routines */
+static char *
+map_name (EAddrConduitContext *ctxt)
{
- g_return_if_fail(c!=NULL);
- g_return_if_fail(*c!=NULL);
- //g_free(*c); FIX ME
- *c = NULL;
+ char *filename = NULL;
+
+ filename = g_strdup_printf ("%s/evolution/local/Contacts/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);
+}
-/* Given a AddressbookConduitContext**, allocates the structure */
static void
-conduit_new_context(AddressbookConduitContext **ctxt,
- AddressbookConduitCfg *c)
+map_sax_start_element (void *data, const xmlChar *name,
+ const xmlChar **attrs)
{
- *ctxt = g_new0(AddressbookConduitContext,1);
- g_assert(ctxt!=NULL);
- (*ctxt)->cfg = c;
- CORBA_exception_init (&((*ctxt)->ev));
+ EAddrConduitContext *ctxt = (EAddrConduitContext *)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 (EAddrConduitContext *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));
-/* Destroys any data allocated by conduit_new_context
- and deallocates its data. */
+ 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;
+}
+
+/* Addressbok Server routines */
static void
-conduit_destroy_context(AddressbookConduitContext **ctxt)
+add_card_cb (EBook *ebook, EBookStatus status, const char *id, gpointer closure)
{
- g_return_if_fail(ctxt!=NULL);
- g_return_if_fail(*ctxt!=NULL);
+ add_card_cons *cons = (add_card_cons*)closure;
- if ((*ctxt)->cfg!=NULL)
- conduit_destroy_configuration(&((*ctxt)->cfg));
+ cons->status = status;
+ cons->id = g_strdup (id);
- g_free(*ctxt);
- *ctxt = NULL;
+ gtk_main_quit();
}
+static void
+status_cb (EBook *ebook, EBookStatus status, gpointer closure)
+{
+ (*(EBookStatus*)closure) = status;
+ gtk_main_quit();
+}
static void
cursor_cb (EBook *book, EBookStatus status, ECardCursor *cursor, gpointer closure)
{
- AddressbookConduitContext *ctxt = (AddressbookConduitContext*)closure;
+ EAddrConduitContext *ctxt = (EAddrConduitContext*)closure;
if (status == E_BOOK_STATUS_SUCCESS) {
long length;
@@ -132,7 +313,7 @@ cursor_cb (EBook *book, EBookStatus status, ECardCursor *cursor, gpointer closur
static void
book_open_cb (EBook *book, EBookStatus status, gpointer closure)
{
- AddressbookConduitContext *ctxt = (AddressbookConduitContext*)closure;
+ EAddrConduitContext *ctxt = (EAddrConduitContext*)closure;
if (status == E_BOOK_STATUS_SUCCESS) {
e_book_get_cursor (book, "(contains \"full_name\" \"\")", cursor_cb, ctxt);
@@ -144,12 +325,10 @@ book_open_cb (EBook *book, EBookStatus status, gpointer closure)
}
static int
-start_address_server (GnomePilotConduitStandardAbs *conduit,
- AddressbookConduitContext *ctxt)
+start_addressbook_server (EAddrConduitContext *ctxt)
{
gchar *uri, *path;
- g_return_val_if_fail(conduit!=NULL,-2);
g_return_val_if_fail(ctxt!=NULL,-2);
ctxt->ebook = e_book_new ();
@@ -173,106 +352,170 @@ start_address_server (GnomePilotConduitStandardAbs *conduit,
return -1;
}
-/*
- * converts a ECard to a AddressbookLocalRecord
- */
-void
-local_record_from_ecard(AddressbookLocalRecord *local,
- ECard *ecard)
+/* Utility routines */
+static void
+compute_pid (EAddrConduitContext *ctxt, EAddrLocalRecord *local, const char *uid)
{
- guint32 current_status;
-
- g_return_if_fail(local!=NULL);
- g_return_if_fail(ecard!=NULL);
-
- local->ecard = ecard;
- local->local.ID = local->ecard->pilot_id;
-
- gtk_object_get (GTK_OBJECT(ecard),
- "pilot_status", &current_status, NULL);
-
- switch(current_status) {
- case E_CARD_PILOT_STATUS_NONE:
- local->local.attr = GnomePilotRecordNothing;
- break;
- case E_CARD_PILOT_STATUS_MOD:
- local->local.attr = GnomePilotRecordModified;
- break;
- case E_CARD_PILOT_STATUS_DEL:
- local->local.attr = GnomePilotRecordDeleted;
- break;
- }
-
- /* Records without a pilot_id are new */
- if(local->local.ID == 0)
- local->local.attr = GnomePilotRecordNew;
-
- local->local.secret = 0;
-#if 0
- if(obj->class!=NULL)
- if(strcmp(obj->class,"PRIVATE")==0)
- local->local.secret = 1;
-#endif
-
- local->local.archived = 0;
+/* guint32 *pid; */
+
+/* pid = g_hash_table_lookup (ctxt->uid_map, uid); */
+
+/* if (pid) */
+/* local->local.ID = *pid; */
+/* else */
+/* local->local.ID = 0; */
}
-static ECard *
-get_ecard_by_pilot_id (GList *card_list, recordid_t id)
+static void
+compute_status (EAddrConduitContext *ctxt, EAddrLocalRecord *local, const char *uid)
{
- GList *l;
+ local->local.archived = FALSE;
+ local->local.secret = FALSE;
+
+/* if (g_hash_table_lookup (ctxt->added, uid)) */
+/* local->local.attr = GnomePilotRecordNew; */
+/* else if (g_hash_table_lookup (ctxt->modified, uid)) */
+/* local->local.attr = GnomePilotRecordModified; */
+/* else if (g_hash_table_lookup (ctxt->deleted, uid)) */
+/* local->local.attr = GnomePilotRecordDeleted; */
+/* else */
+/* local->local.attr = GnomePilotRecordNothing; */
+}
- for (l = card_list; l; l = l->next) {
- guint32 pilot_id;
- ECard *card = l->data;
+static GnomePilotRecord *
+local_record_to_pilot_record (EAddrLocalRecord *local,
+ EAddrConduitContext *ctxt)
+{
+ GnomePilotRecord *p = NULL;
+
+ g_return_val_if_fail (local != NULL, NULL);
+ g_assert (local->addr != NULL );
+
+ LOG ("local_record_to_remote_record\n");
- if (!card)
- continue;
+ p = g_new0 (GnomePilotRecord, 1);
- gtk_object_get (GTK_OBJECT(card),
- "pilot_id", &pilot_id, NULL);
+ p->ID = local->local.ID;
+ p->category = 0;
+ p->attr = local->local.attr;
+ p->archived = local->local.archived;
+ p->secret = local->local.secret;
- if (pilot_id == id)
- return card;
- }
+ /* Generate pilot record structure */
+ p->record = g_new0 (char,0xffff);
+ p->length = pack_Address (local->addr, p->record, 0xffff);
- return NULL;
+ return p;
}
+#if 0
/*
- * Given a PilotRecord, find the matching record in
- * the addressbook. If no match, return NULL
+ * converts a CalComponent object to a EAddrLocalRecord
*/
-static AddressbookLocalRecord *
-find_record_in_ebook(GnomePilotConduitStandardAbs *conduit,
- PilotRecord *remote,
- AddressbookConduitContext *ctxt)
+static void
+local_record_from_comp (EAddrLocalRecord *local, CalComponent *comp, EAddrConduitContext *ctxt)
{
- AddressbookLocalRecord *loc;
- ECard *ecard;
-
- g_return_val_if_fail(conduit!=NULL,NULL);
- g_return_val_if_fail(remote!=NULL,NULL);
-
- LOG ("requesting %ld", remote->ID);
+ const char *uid;
+ int *priority;
+ struct icaltimetype *completed;
+ CalComponentText summary;
+ GSList *d_list = NULL;
+ CalComponentText *description;
+ CalComponentDateTime due;
+ time_t due_time;
+ CalComponentClassification classif;
+
+ LOG ("local_record_from_comp\n");
+
+ g_return_if_fail (local != NULL);
+ g_return_if_fail (comp != NULL);
+
+ local->comp = comp;
+
+ cal_component_get_uid (local->comp, &uid);
+ compute_pid (ctxt, local, uid);
+ compute_status (ctxt, local, uid);
+
+ local->todo = g_new0 (struct ToDo,1);
+
+ /* STOP: don't replace these with g_strdup, since free_ToDo
+ uses free to deallocate */
+ cal_component_get_summary (comp, &summary);
+ if (summary.value)
+ local->todo->description = strdup ((char *) summary.value);
+
+ cal_component_get_description_list (comp, &d_list);
+ if (d_list) {
+ description = (CalComponentText *) d_list->data;
+ if (description && description->value)
+ local->todo->note = strdup (description->value);
+ else
+ local->todo->note = NULL;
+ } else {
+ local->todo->note = NULL;
+ }
- ecard = get_ecard_by_pilot_id (ctxt->cards, remote->ID);
+ cal_component_get_due (comp, &due);
+ if (due.value) {
+ due_time = icaltime_as_timet (*due.value);
+
+ local->todo->due = *localtime (&due_time);
+ local->todo->indefinite = 0;
+ } else {
+ local->todo->indefinite = 1;
+ }
+
+ cal_component_get_completed (comp, &completed);
+ if (completed) {
+ local->todo->complete = 1;
+ cal_component_free_icaltimetype (completed);
+ }
- if (NULL != ecard) {
- LOG ("Found");
- loc = g_new0(AddressbookLocalRecord,1);
- /* memory allocated in new_from_string is freed in free_match */
- local_record_from_ecard (loc, ecard);
- return loc;
+ cal_component_get_priority (comp, &priority);
+ if (priority) {
+ local->todo->priority = *priority;
+ cal_component_free_priority (priority);
}
+
+ cal_component_get_classification (comp, &classif);
+
+ if (classif == CAL_COMPONENT_CLASS_PRIVATE)
+ local->local.secret = 1;
+ else
+ local->local.secret = 0;
+
+ local->local.archived = 0;
+}
+#endif
- INFO ("Object did not exist");
- return NULL;
+static void
+local_record_from_uid (EAddrLocalRecord *local,
+ char *uid,
+ EAddrConduitContext *ctxt)
+{
+/* CalComponent *comp; */
+/* CalClientGetStatus status; */
+
+/* g_assert(local!=NULL); */
+
+/* status = cal_client_get_object (ctxt->client, uid, &comp); */
+
+/* if (status == CAL_CLIENT_GET_SUCCESS) { */
+/* local_record_from_comp (local, comp, ctxt); */
+/* } else if (status == CAL_CLIENT_GET_NOT_FOUND) { */
+/* comp = cal_component_new (); */
+/* cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); */
+/* cal_component_set_uid (comp, uid); */
+/* local_record_from_comp (local, comp, ctxt); */
+/* } else { */
+/* INFO ("Object did not exist"); */
+/* } */
}
static ECard *
-ecard_from_remote_record(AddressbookConduitContext *ctxt,
- PilotRecord *remote)
+ecard_from_remote_record(EAddrConduitContext *ctxt,
+ GnomePilotRecord *remote,
+ ECard *in_card)
{
struct Address address;
ECard *ecard;
@@ -288,9 +531,13 @@ ecard_from_remote_record(AddressbookConduitContext *ctxt,
memset (&address, 0, sizeof (struct Address));
unpack_Address (&address, remote->record, remote->length);
-
- ecard = e_card_new("");
- simple = e_card_simple_new(ecard);
+ if (in_card == NULL) {
+ ecard = e_card_new("");
+ simple = e_card_simple_new(ecard);
+ } else {
+ ecard = in_card;
+ simple = E_CARD_SIMPLE (ecard);
+ }
#define get(pilotprop) \
(address.entry [(pilotprop)])
@@ -370,814 +617,548 @@ ecard_from_remote_record(AddressbookConduitContext *ctxt,
free_Address(&address);
- gtk_object_set (GTK_OBJECT(ecard), "pilot_id", remote->ID, NULL);
-
gtk_object_unref(GTK_OBJECT(simple));
return ecard;
}
-static ECard*
-merge_ecard_with_remote_record (AddressbookConduitContext *ctxt,
- ECard *ecard,
- PilotRecord *remote)
-{
- return ecard;
-}
-
-typedef struct {
- EBookStatus status;
- char *id;
-} add_card_cons;
-
-static void
-add_card_cb (EBook *ebook, EBookStatus status, const char *id, gpointer closure)
-{
- add_card_cons *cons = (add_card_cons*)closure;
-
- cons->status = status;
- cons->id = g_strdup (id);
-
- gtk_main_quit();
-}
-
-static gint
-update_record (GnomePilotConduitStandardAbs *conduit,
- PilotRecord *remote,
- AddressbookConduitContext *ctxt)
+#if 0
+static CalComponent *
+comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
+ GnomePilotRecord *remote,
+ CalComponent *in_comp)
{
- struct Address address;
- ECard *ecard;
- add_card_cons cons;
-
- g_return_val_if_fail(remote!=NULL,-1);
-
- memset (&address, 0, sizeof (struct Address));
- unpack_Address (&address, remote->record, remote->length);
-
- LOG ("requesting %ld [%s %s]", remote->ID, address.entry[entryFirstname], address.entry[entryLastname]);
- printf ("requesting %ld [%s %s]\n", remote->ID, address.entry[entryFirstname], address.entry[entryLastname]);
-
- ecard = get_ecard_by_pilot_id (ctxt->cards, remote->ID);
-
- if (ecard == NULL) {
-
- LOG ("Object did not exist, creating a new one");
- printf ("Object did not exist, creating a new one\n");
-
- ecard = ecard_from_remote_record (ctxt, remote);
-
- /* add the ecard to the server */
- e_book_add_card (ctxt->ebook, ecard, add_card_cb, &cons);
+ CalComponent *comp;
+ struct ToDo todo;
+ struct icaltimetype now = icaltime_from_timet (time (NULL), FALSE, FALSE);
+ CalComponentText summary = {NULL, NULL};
+ CalComponentText description = {NULL, NULL};
+ CalComponentDateTime dt = {NULL, NULL};
+ struct icaltimetype due;
+ GSList *d_list;
+
+ g_return_val_if_fail (remote != NULL, NULL);
+
+ memset (&todo, 0, sizeof (struct ToDo));
+ unpack_ToDo (&todo, remote->record, remote->length);
+
+ if (in_comp == NULL) {
+ comp = cal_component_new ();
+ cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO);
+ cal_component_set_created (comp, &now);
+ } else {
+ comp = cal_component_clone (in_comp);
+ }
- gtk_main(); /* enter sub mainloop */
+ LOG (" comp_from_remote_record: "
+ "creating from remote %s and comp %s\n",
+ print_remote (remote), cal_component_get_as_string (comp));
- if (cons.status == E_BOOK_STATUS_SUCCESS) {
- ctxt->cards = g_list_append (ctxt->cards,
- e_book_get_card (ctxt->ebook, cons.id));
- g_free (cons.id);
- }
- else
- WARN ("update_record: failed to add card to ebook\n");
- } else {
- EBookStatus commit_status;
+ cal_component_set_last_modified (comp, &now);
- ecard = merge_ecard_with_remote_record (ctxt, ecard, remote);
+ summary.value = todo.description;
+ cal_component_set_summary (comp, &summary);
- e_book_commit_card (ctxt->ebook, ecard, status_cb, &commit_status);
+ description.value = todo.note;
+ d_list = g_slist_append (NULL, &description);
+ cal_component_set_comment_list (comp, d_list);
+ g_slist_free (d_list);
- gtk_main (); /* enter sub mainloop */
+ if (todo.complete) {
+ int percent = 100;
+ cal_component_set_completed (comp, &now);
+ cal_component_set_percent (comp, &percent);
+ }
- if (commit_status != E_BOOK_STATUS_SUCCESS)
- WARN ("update_record: failed to update card in ebook\n");
+ /* FIX ME This is a bit hackish, how else can we tell if there is
+ * no due date set?
+ */
+ if (todo.due.tm_sec || todo.due.tm_min || todo.due.tm_hour
+ || todo.due.tm_mday || todo.due.tm_mon || todo.due.tm_year) {
+ due = icaltime_from_timet (mktime (&todo.due), FALSE, FALSE);
+ dt.value = &due;
+ cal_component_set_due (comp, &dt);
}
+
+ cal_component_set_priority (comp, &todo.priority);
+ cal_component_set_transparency (comp, CAL_COMPONENT_TRANSP_NONE);
- free_Address(&address);
+ if (remote->attr & dlpRecAttrSecret)
+ cal_component_set_classification (comp, CAL_COMPONENT_CLASS_PRIVATE);
+ else
+ cal_component_set_classification (comp, CAL_COMPONENT_CLASS_PUBLIC);
- return 0;
+ cal_component_commit_sequence (comp);
+
+ free_ToDo(&todo);
+
+ return comp;
}
+#endif
-#if 0
static void
-check_for_slow_setting (GnomePilotConduit *c, AddressbookConduitContext *ctxt)
+check_for_slow_setting (GnomePilotConduit *c, EAddrConduitContext *ctxt)
{
- GList *uids;
- unsigned long int entry_number;
-
- uids = cal_client_get_uids (ctxt->client, CALOBJ_TYPE_ADDRESS);
+ int count, map_count;
- entry_number = g_list_length (uids);
+/* count = g_list_length (ctxt->uids); */
+ count = 0;
- LOG (_("Address holds %ld address entries"), entry_number);
- /* If the local base is empty, do a slow sync */
- if (entry_number == 0) {
+ map_count = g_hash_table_size (ctxt->pid_map);
+
+ /* If there are no objects or objects but no log */
+ if ((count == 0) || (count > 0 && map_count == 0)) {
GnomePilotConduitStandard *conduit;
+ LOG (" doing slow sync\n");
conduit = GNOME_PILOT_CONDUIT_STANDARD (c);
gnome_pilot_conduit_standard_set_slow (conduit);
+ } else {
+ LOG (" doing fast sync\n");
}
}
-#endif /* 0 */
+/* Pilot syncing callbacks */
static gint
-pre_sync (GnomePilotConduit *c,
+pre_sync (GnomePilotConduit *conduit,
GnomePilotDBInfo *dbi,
- AddressbookConduitContext *ctxt)
+ EAddrConduitContext *ctxt)
{
- int l;
+ GnomePilotConduitSyncAbs *abs_conduit;
+/* GList *l; */
+ int len;
unsigned char *buf;
- GnomePilotConduitStandardAbs *conduit;
+ char *filename;
+ xmlSAXHandler handler;
+/* gint num_records; */
+
+ abs_conduit = GNOME_PILOT_CONDUIT_SYNC_ABS (conduit);
- conduit = GNOME_PILOT_CONDUIT_STANDARD_ABS(c);
-
- g_message ("Evolution Addressbook Conduit v.%s",CONDUIT_VERSION);
+ LOG ("---------------------------------------------------------\n");
+ LOG ("pre_sync: Addressbook Conduit v.%s", CONDUIT_VERSION);
+ g_message ("Addressbook Conduit v.%s", CONDUIT_VERSION);
ctxt->ebook = NULL;
- if (start_address_server (GNOME_PILOT_CONDUIT_STANDARD_ABS(c), ctxt) != 0) {
- WARN(_("Could not start addressbook server"));
- gnome_pilot_conduit_error(GNOME_PILOT_CONDUIT(c),
- _("Could not start addressbook server"));
+ if (start_addressbook_server (ctxt) != 0) {
+ WARN(_("Could not start wombat server"));
+ gnome_pilot_conduit_error (conduit, _("Could not start wombat"));
return -1;
}
+ /* Load the uid <--> pilot id mappings */
+ ctxt->pid_map = g_hash_table_new (g_int_hash, g_int_equal);
+ ctxt->uid_map = g_hash_table_new (g_str_hash, g_str_equal);
- /* Set the counters for the progress bar crap */
-
- gtk_object_set_data (GTK_OBJECT(c),"dbinfo",dbi);
-
- /* load_records(c); */
-
- buf = (unsigned char*)g_malloc(0xffff);
- if((l=dlp_ReadAppBlock(dbi->pilot_socket,dbi->db_handle,0,(unsigned char *)buf,0xffff)) < 0) {
- WARN(_("Could not read pilot's Address application block"));
- WARN("dlp_ReadAppBlock(...) = %d",l);
- gnome_pilot_conduit_error(GNOME_PILOT_CONDUIT(c),
- _("Could not read pilot's Address application block"));
+ 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;
+ }
+
+ g_free (filename);
+
+ /* Set the count information */
+/* num_records = cal_client_get_n_objects (ctxt->client, CALOBJ_TYPE_TODO); */
+/* gnome_pilot_conduit_sync_abs_set_num_local_records(abs_conduit, num_records); */
+/* num_records = g_hash_table_size (ctxt->added); */
+/* gnome_pilot_conduit_sync_abs_set_num_new_local_records (abs_conduit, num_records); */
+/* num_records = g_hash_table_size (ctxt->modified); */
+/* gnome_pilot_conduit_sync_abs_set_num_updated_local_records (abs_conduit, num_records); */
+/* num_records = g_hash_table_size (ctxt->deleted); */
+/* gnome_pilot_conduit_sync_abs_set_num_deleted_local_records(abs_conduit, num_records); */
+
+ gtk_object_set_data (GTK_OBJECT (conduit), "dbinfo", dbi);
+
+ buf = (unsigned char*)g_malloc (0xffff);
+ len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
+ (unsigned char *)buf, 0xffff);
+
+ if (len < 0) {
+ WARN (_("Could not read pilot's Address application block"));
+ WARN ("dlp_ReadAppBlock(...) = %d", len);
+ gnome_pilot_conduit_error (conduit,
+ _("Could not read pilot's Address application block"));
return -1;
}
- unpack_AddressAppInfo(&(ctxt->ai),buf,l);
- g_free(buf);
-
-#if 0
- check_for_slow_setting(c,ctxt);
-#else
- /* for now just always use the slow sync method */
- gnome_pilot_conduit_standard_set_slow (GNOME_PILOT_CONDUIT_STANDARD (c));
-#endif
-
- return 0;
-}
+ unpack_AddressAppInfo (&(ctxt->ai), buf, len);
+ g_free (buf);
-/**
- * Find (if possible) the local record which matches
- * the given PilotRecord.
- * if successfull, return non-zero and set *local to
- * a non-null value (the located local record),
- * otherwise return 0 and set *local = NULL;
- */
-
-static gint
-match_record (GnomePilotConduitStandardAbs *conduit,
- AddressbookLocalRecord **local,
- PilotRecord *remote,
- AddressbookConduitContext *ctxt)
-{
- LOG ("in match_record");
-
- g_return_val_if_fail(local!=NULL,-1);
- g_return_val_if_fail(remote!=NULL,-1);
+/* check_for_slow_setting (conduit, ctxt); */
- *local = find_record_in_ebook(conduit,remote,ctxt);
-
- if (*local==NULL) return -1;
return 0;
}
-/**
- * Free the data allocated by a previous match_record call.
- * If successfull, return non-zero and ser *local=NULL, otherwise
- * return 0.
- */
static gint
-free_match (GnomePilotConduitStandardAbs *conduit,
- AddressbookLocalRecord **local,
- AddressbookConduitContext *ctxt)
+post_sync (GnomePilotConduit *conduit,
+ GnomePilotDBInfo *dbi,
+ EAddrConduitContext *ctxt)
{
- LOG ("entering free_match");
-
- g_return_val_if_fail(local!=NULL,-1);
- g_return_val_if_fail(*local!=NULL,-1);
+ gchar *filename;
+
+ LOG ("post_sync: Address Conduit v.%s", CONDUIT_VERSION);
+ LOG ("---------------------------------------------------------\n");
- g_free(*local);
+ filename = map_name (ctxt);
+ map_write (ctxt, filename);
+ g_free (filename);
- *local = NULL;
return 0;
}
-#if SUPPORT_ARCHIVING
-/*
- Move to archive and set status to Nothing
- */
static gint
-archive_local (GnomePilotConduitStandardAbs *conduit,
- AddressbookLocalRecord *local,
- AddressbookConduitContext *ctxt)
+set_pilot_id (GnomePilotConduitSyncAbs *conduit,
+ EAddrLocalRecord *local,
+ guint32 ID,
+ EAddrConduitContext *ctxt)
{
- LOG ("entering archive_local");
+ char *new_uid;
+ guint32 *pid = g_new (guint32, 1);
- g_return_val_if_fail(local!=NULL,-1);
+ LOG ("set_pilot_id: setting to %d\n", ID);
+
+ *pid = ID;
+ new_uid = g_strdup (local->ecard->id);
+ g_hash_table_insert (ctxt->pid_map, pid, new_uid);
+ g_hash_table_insert (ctxt->uid_map, new_uid, pid);
- return -1;
+ return 0;
}
-/*
-** used when copying information from the pilot to the desktop. if
-** the archived flag is set to true in the PilotRecord, this method is
-** called.
-**
-** Store in archive and set status to Nothing
-*/
static gint
-archive_remote (GnomePilotConduitStandardAbs *conduit,
- AddressbookLocalRecord *local,
- PilotRecord *remote,
- AddressbookConduitContext *ctxt)
+for_each (GnomePilotConduitSyncAbs *conduit,
+ EAddrLocalRecord **local,
+ EAddrConduitContext *ctxt)
{
- LOG ("entering archive_remote");
+ static GList *cards, *iterator;
+ static int count;
- //g_return_val_if_fail(remote!=NULL,-1);
- //g_return_val_if_fail(local!=NULL,-1);
+ g_return_val_if_fail (local != NULL, -1);
- return -1;
-}
+ if (*local == NULL) {
+ LOG ("beginning for_each");
-/*
-** Called when copying records to the pilot.
-**
-** XXX more here.
-*/
-static gint
-clear_status_archive_local (GnomePilotConduitStandardAbs *conduit,
- AddressbookLocalRecord *local,
- AddressbookConduitContext *ctxt)
-{
- LOG ("entering clear_status_archive_local");
+ cards = ctxt->cards;
+ count = 0;
+
+ if (cards != NULL) {
+ LOG ("iterating over %d records", g_list_length (cards));
- g_return_val_if_fail(local!=NULL,-1);
+ *local = g_new0 (EAddrLocalRecord, 1);
+/* local_record_from_uid (*local, uids->data, ctxt) */;
- return -1;
-}
+ iterator = cards;
+ } else {
+ LOG ("no events");
+ (*local) = NULL;
+ return 0;
+ }
+ } else {
+ count++;
+ if (g_list_next (iterator)) {
+ iterator = g_list_next (iterator);
-/*
-** presumably used to set the archived flag on a local record. not
-** actually used in the gnome-pilot source.
-*/
-static gint
-set_archived (GnomePilotConduitStandardAbs *conduit,
- AddressbookLocalRecord *local,
- gint archived,
- AddressbookConduitContext *ctxt)
-{
- LOG ("entering set_archived");
+ *local = g_new0 (EAddrLocalRecord, 1);
+ local_record_from_uid (*local, iterator->data, ctxt);
+ } else {
+ LOG ("for_each ending");
- g_return_val_if_fail(local!=NULL,-1);
- g_assert(local->ecard!=NULL);
+ /* Tell the pilot the iteration is over */
+ *local = NULL;
- local->local.archived = archived;
- update_address_entry_in_repository (conduit, local->ical, ctxt);
- return 0;
-}
+ return 0;
+ }
+ }
-#endif
+ return 0;
+}
-/*
-** used when copying information from the pilot to the desktop. if
-** the archived flags and deleted flags are not set to true in the
-** PilotRecord, this method is called.
-**
-** Store and set status to Nothing
-*/
static gint
-store_remote (GnomePilotConduitStandardAbs *conduit,
- PilotRecord *remote,
- AddressbookConduitContext *ctxt)
+for_each_modified (GnomePilotConduitSyncAbs *conduit,
+ EAddrLocalRecord **local,
+ EAddrConduitContext *ctxt)
{
- LOG ("entering store_remote");
+/* static GList *changes, *iterator; */
+/* static int count; */
+
+/* g_return_val_if_fail (local != NULL, 0); */
- g_return_val_if_fail(remote!=NULL,-1);
- remote->attr = GnomePilotRecordNothing;
+/* if (*local == NULL) { */
+/* LOG ("beginning for_each_modified: beginning\n"); */
+
+/* changes = ctxt->changed; */
+
+/* count = 0; */
+
+/* if (changes != NULL) { */
+/* CalObjChange *coc = changes->data; */
+
+/* LOG ("iterating over %d records", g_list_length (changes)); */
+
+/* *local = g_new0 (EAddrLocalRecord, 1); */
+/* local_record_from_uid (*local, coc->uid, ctxt); */
+
+/* iterator = changes; */
+/* } else { */
+/* LOG ("no events"); */
+/* (*local) = NULL; */
+/* return 0; */
+/* } */
+/* } else { */
+/* count++; */
+/* if (g_list_next (iterator)) { */
+/* CalObjChange *coc; */
+
+/* iterator = g_list_next (iterator); */
+/* coc = iterator->data; */
+
+/* *local = g_new0 (EAddrLocalRecord, 1); */
+/* local_record_from_uid (*local, coc->uid, ctxt); */
+/* } else { */
+/* LOG ("for_each_modified ending"); */
+
+ /* Tell the pilot the iteration is over */
+/* (*local) = NULL; */
+
+/* return 0; */
+/* } */
+/* } */
- return update_record(conduit,remote,ctxt);
+ return 0;
}
-/*
-** Used when looping over records on the local side of things.
-** function should maintain state such that *local moves along the
-** list of records.
-**
-** return value is 0 if we're done, 1 to continue iterating, and -1 on
-** error.
-*/
static gint
-iterate (GnomePilotConduitStandardAbs *conduit,
- AddressbookLocalRecord **local,
- AddressbookConduitContext *ctxt)
+compare (GnomePilotConduitSyncAbs *conduit,
+ EAddrLocalRecord *local,
+ GnomePilotRecord *remote,
+ EAddrConduitContext *ctxt)
{
- static GList *iterator;
- static int num;
+ /* used by the quick compare */
+ GnomePilotRecord *local_pilot = NULL;
+ int retval = 0;
- g_return_val_if_fail(local!=NULL,-1);
+ LOG ("compare: local=%s remote=%s...\n",
+ print_local (local), print_remote (remote));
- if (*local==NULL) {
- LOG ("beginning iteration");
+ g_return_val_if_fail (local!=NULL,-1);
+ g_return_val_if_fail (remote!=NULL,-1);
- iterator = ctxt->cards;
- num = 0;
-
- LOG ("iterating over %d records", g_list_length (ctxt->cards));
- *local = g_new0(AddressbookLocalRecord, 1);
- local_record_from_ecard (*local, (ECard*)iterator->data);
- } else {
- /* printf ("continuing iteration\n"); */
- num++;
- if(g_list_next(iterator)==NULL) {
- LOG ("ending");
- /** free stuff allocated for iteration */
- g_free((*local));
+/* local_pilot = local_record_to_pilot_record (local, ctxt); */
+ if (!local_pilot)
+ return -1;
- LOG ("iterated over %d records", num);
+ if (remote->length != local_pilot->length
+ || memcmp (local_pilot->record, remote->record, remote->length))
+ retval = 1;
- /* ends iteration */
- (*local) = NULL;
- return 0;
- } else {
- iterator = g_list_next (iterator);
- local_record_from_ecard (*local,(ECard*)(iterator->data));
- }
- }
- return 1;
+ if (retval == 0)
+ LOG (" equal");
+ else
+ LOG (" not equal");
+
+ g_free (local_pilot);
+
+ return retval;
}
-
-/*
-** similar to iterate, except the list of records we iterate over have
-** to have FLAG set and ARCHIVE should match the state of the local
-** record.
-**
-** return value is 0 if we're done, 1 to continue iterating, and -1 on
-** error.
-*/
static gint
-iterate_specific (GnomePilotConduitStandardAbs *conduit,
- AddressbookLocalRecord **local,
- gint flag,
- gint archived,
- AddressbookConduitContext *ctxt)
+add_record (GnomePilotConduitSyncAbs *conduit,
+ GnomePilotRecord *remote,
+ EAddrConduitContext *ctxt)
{
-#ifdef DEBUG_ADDRESSBOOKCONDUIT
- {
- gchar *tmp;
- switch (flag) {
- case GnomePilotRecordNothing: tmp = g_strdup("RecordNothing"); break;
- case GnomePilotRecordModified: tmp = g_strdup("RecordModified"); break;
- case GnomePilotRecordDeleted: tmp = g_strdup("RecordDeleted"); break;
- case GnomePilotRecordNew: tmp = g_strdup("RecordNew"); break;
- default: tmp = g_strdup_printf("0x%x",flag); break;
- }
- printf ("entering iterate_specific(flag = %s)\n", tmp);
- g_free(tmp);
- }
-#endif
- g_return_val_if_fail(local!=NULL,-1);
+ ECard *ecard;
+ char *new_uid;
+ guint32 *pid = g_new (guint32, 1);
+ add_card_cons cons;
+ int retval = 0;
+
+ g_return_val_if_fail (remote != NULL, -1);
- /* iterate until a record meets the criteria */
- while(gnome_pilot_conduit_standard_abs_iterate(conduit,(LocalRecord**)local)) {
- if((*local)==NULL) break;
-#if SUPPORT_ARCHIVING
- if(archived && ((*local)->local.archived==archived)) break;
-#endif
- if(((*local)->local.attr == flag)) break;
- }
+ LOG ("add_record: adding %s to desktop\n", print_remote (remote));
- return (*local)==NULL?0:1;
-}
+ ecard = ecard_from_remote_record (ctxt, remote, NULL);
-/*
-** actually remove the records flagged as deleted from the local
-** store.
-**
-** XXX return value isn't checked by gnome-pilot source.
-*/
-static gint
-purge (GnomePilotConduitStandardAbs *conduit,
- AddressbookConduitContext *ctxt)
-{
- GList *it;
- gint retval = 0;
-
- for (it=ctxt->cards; it;) {
- guint32 current_status;
-
- gtk_object_get (GTK_OBJECT (it->data), "pilot_status",
- &current_status, NULL);
-
- if (current_status == E_CARD_PILOT_STATUS_DEL) {
- EBookStatus remove_status;
-
- e_book_remove_card (ctxt->ebook, it->data, status_cb, &remove_status);
- gtk_main(); /* enter sub loop */
-
- if (remove_status == E_BOOK_STATUS_SUCCESS) {
- GList *l = it;
- it = g_list_next (it);
- gtk_object_unref (GTK_OBJECT (it->data));
- ctxt->cards = g_list_remove_link(ctxt->cards, l);
- g_list_free_1 (l);
- }
- else {
- retval = -1;
- it = g_list_next (it);
- }
- }
- else
- it = g_list_next (it);
+ /* add the ecard to the server */
+ e_book_add_card (ctxt->ebook, ecard, add_card_cb, &cons);
+
+ gtk_main(); /* enter sub mainloop */
+
+ if (cons.status != E_BOOK_STATUS_SUCCESS) {
+ WARN ("add_record: failed to add card to ebook\n");
+ return -1;
}
+ ctxt->cards = g_list_append (ctxt->cards,
+ e_book_get_card (ctxt->ebook, cons.id));
+ g_free (cons.id);
+
+ *pid = remote->ID;
+ new_uid = g_strdup (ecard->id);
+ g_hash_table_insert (ctxt->pid_map, pid, new_uid);
+ g_hash_table_insert (ctxt->uid_map, new_uid, pid);
+
return retval;
}
-
-/*
-** sets the value of the status flag on the local record (deleted,
-** nothing, modified, etc.)
-**
-** XXX return value not checked by gnome-pilot source.
-*/
static gint
-set_status (GnomePilotConduitStandardAbs *conduit,
- AddressbookLocalRecord *local,
- gint status,
- AddressbookConduitContext *ctxt)
+add_archive_record (GnomePilotConduitSyncAbs *conduit,
+ EAddrLocalRecord *local,
+ GnomePilotRecord *remote,
+ EAddrConduitContext *ctxt)
{
- EBookStatus commit_status;
- guint32 ecard_status;
-
- LOG ("entering set_status(status=%d)",status);
-
- g_return_val_if_fail(local!=NULL,-1);
- g_assert(local->ecard!=NULL);
-
- local->local.attr = status;
- switch(status) {
- case GnomePilotRecordDeleted:
- ecard_status = E_CARD_PILOT_STATUS_DEL;
- break;
- case GnomePilotRecordNew:
- case GnomePilotRecordModified:
- ecard_status = E_CARD_PILOT_STATUS_MOD;
- break;
- default:
- ecard_status = E_CARD_PILOT_STATUS_NONE;
- break;
- }
+ int retval = 0;
- gtk_object_set (GTK_OBJECT (local->ecard),
- "pilot_status", ecard_status, NULL);
-
- e_book_commit_card (ctxt->ebook, local->ecard, status_cb,
- &commit_status);
-
- gtk_main (); /* enter sub loop */
+ g_return_val_if_fail (remote != NULL, -1);
+ g_return_val_if_fail (local != NULL, -1);
- if (commit_status != E_BOOK_STATUS_SUCCESS) {
- WARN (_("Error while communicating with address server"));
- }
+ LOG ("add_archive_record: doing nothing with %s\n",
+ print_local (local));
- return 0;
+ return retval;
}
-/*
-** used when writing a record to the pilot. the id is the one
-** assigned to the remote record. storing it in the local record
-** makes it easier to match up local and remote records later on.
-**
-** this should not change the state of the local entry to modified.
-**
-** XXX return value not checked by gnome-pilot source.
-*/
static gint
-set_pilot_id (GnomePilotConduitStandardAbs *conduit,
- AddressbookLocalRecord *local,
- guint32 ID,
- AddressbookConduitContext *ctxt)
+replace_record (GnomePilotConduitSyncAbs *conduit,
+ EAddrLocalRecord *local,
+ GnomePilotRecord *remote,
+ EAddrConduitContext *ctxt)
{
+ ECard *new_ecard;
EBookStatus commit_status;
+ int retval = 0;
+
+ g_return_val_if_fail (remote != NULL, -1);
- LOG ("entering set_pilot_id(id=%d)",ID);
+ LOG ("replace_record: replace %s with %s\n",
+ print_local (local), print_remote (remote));
- g_return_val_if_fail(local!=NULL,-1);
- g_assert(local->ecard!=NULL);
+ new_ecard = ecard_from_remote_record (ctxt, remote, local->ecard);
+ gtk_object_unref (GTK_OBJECT (local->ecard));
+ local->ecard = new_ecard;
- local->local.ID = ID;
-
- gtk_object_set (GTK_OBJECT(local->ecard),
- "pilot_id", local->local.ID, NULL);
e_book_commit_card (ctxt->ebook, local->ecard, status_cb, &commit_status);
+
+ gtk_main (); /* enter sub mainloop */
+
+ if (commit_status != E_BOOK_STATUS_SUCCESS)
+ WARN ("replace_record: failed to update card in ebook\n");
- gtk_main (); /* enter sub loop */
+ gtk_object_unref (GTK_OBJECT (new_ecard));
- if (commit_status == E_BOOK_STATUS_SUCCESS) {
- return 0;
- }
- else {
- WARN ("set_pilot_id failed.\n");
- return -1;
- }
+ return retval;
}
-static int
-get_phone_label_by_name (struct AddressAppInfo *ai,
- const char *name)
+static gint
+delete_record (GnomePilotConduitSyncAbs *conduit,
+ EAddrLocalRecord *local,
+ EAddrConduitContext *ctxt)
{
- int i;
+/* const char *uid; */
- for (i = 0; i < 8 /* the number of pilot address labels */; i ++) {
- if (!strcmp(name, ai->phoneLabels[i]))
- return i;
- }
-
- WARN ("couldn't find pilot label '%s'.\n", name);
- return 0;
-}
+/* g_return_val_if_fail (local != NULL, -1); */
+/* g_assert (local->comp != NULL); */
-static int
-get_phone_label_by_flag (struct AddressAppInfo *ai,
- int flags)
-{
- char *label_to_find;
+/* cal_component_get_uid (local->comp, &uid); */
- if (flags & E_CARD_PHONE_PREF) label_to_find = "Main";
- else if (flags & E_CARD_PHONE_WORK) label_to_find = "Work";
- else if (flags & E_CARD_PHONE_HOME) label_to_find = "Home";
- else if (flags & E_CARD_PHONE_FAX) label_to_find = "Fax";
- else if (flags & E_CARD_PHONE_PAGER) label_to_find = "Pager";
- else if (flags & E_CARD_PHONE_CELL) label_to_find = "Mobile";
- else label_to_find = "Other";
+/* LOG ("delete_record: deleting %s\n", uid); */
- return get_phone_label_by_name (ai, label_to_find);
+/* cal_client_remove_object (ctxt->client, uid); */
+
+ return 0;
}
-/*
-** used to convert between a local record and a remote record. memory
-** allocated during this process should be freed in free_transmit
-** below.
-**
-** XXX return value not checked by gnome-pilot source, but setting
-** *remote to NULL triggers an error.
-*/
static gint
-transmit (GnomePilotConduitStandardAbs *conduit,
- AddressbookLocalRecord *local,
- PilotRecord **remote,
- AddressbookConduitContext *ctxt)
+delete_archive_record (GnomePilotConduitSyncAbs *conduit,
+ EAddrLocalRecord *local,
+ EAddrConduitContext *ctxt)
{
- PilotRecord *p;
- ECardName *ecard_name;
- EList *ecard_phones;
- EList *ecard_emails;
- char *ecard_org, *ecard_note, *ecard_title;
- int phone_entry = entryPhone1;
+ int retval = 0;
- LOG ("entering transmit");
-
g_return_val_if_fail(local!=NULL,-1);
- g_return_val_if_fail(remote!=NULL,-1);
- g_assert(local->ecard!=NULL);
- p = g_new0(PilotRecord,1);
+ LOG ("delete_archive_record: doing nothing\n");
- p->ID = local->local.ID;
- p->attr = local->local.attr;
- p->archived = local->local.archived;
- p->secret = local->local.secret;
-
- local->address = g_new0(struct Address,1);
-
- gtk_object_get (GTK_OBJECT (local->ecard),
- "name", &ecard_name,
- "org", &ecard_org,
- "note", &ecard_note,
- "title", &ecard_title,
- "phone", &ecard_phones,
- "email", &ecard_emails,
- NULL);
-
- /* use strdup instead of g_strdup since free_transmit uses free, not g_free. */
- if (ecard_name) {
- if (ecard_name->given)
- local->address->entry [ entryFirstname ] = strdup (ecard_name->given);
- if (ecard_name->family)
- local->address->entry [ entryLastname ] = strdup (ecard_name->family);
- // e_card_name_free (ecard_name);
- }
-
- if (ecard_org) {
- local->address->entry [ entryCompany ] = strdup (ecard_org);
- }
- if (ecard_title) {
- local->address->entry [ entryTitle ] = strdup (ecard_title);
- }
- if (ecard_emails) {
- EIterator *iterator = e_list_get_iterator (ecard_emails);
- char *email;
-
- if ((email = (char *)e_iterator_get(iterator))) {
- local->address->phoneLabel[phone_entry - entryPhone1] =
- get_phone_label_by_name (&ctxt->ai, "E-mail");
- local->address->entry [ phone_entry ] = strdup (email);
-
- phone_entry++;
- }
- }
- if (ecard_phones) {
- int phone_entry = entryPhone1;
- EIterator *iterator = e_list_get_iterator (ecard_phones);
- ECardPhone *phone;
-
- while ((phone = (ECardPhone*)e_iterator_get(iterator))) {
-
- local->address->phoneLabel[phone_entry - entryPhone1] =
- get_phone_label_by_flag (&ctxt->ai, phone->flags);
- local->address->entry [ phone_entry ] = strdup (phone->number);
-
- /* only store a maximum of 5 numbers (4 if
- there was an email address) */
- if (phone_entry == entryPhone5)
- break;
-
- if (e_iterator_next (iterator) == FALSE)
- break;
-
- phone_entry++;
- }
- }
-
- if (ecard_note) {
- local->address->entry [ entryNote ] = strdup (ecard_note);
- }
-#if 0
- printf ("transmitting address to pilot [%s] complete=%d/%ld\n",
- local->ical->summary==NULL?"NULL":local->ical->summary,
- local->address->complete, local->ical->completed);
-#endif
-
- /* Generate pilot record structure */
- p->record = g_new0(char,0xffff);
- p->length = pack_Address(local->address,p->record,0xffff);
-
- *remote = p;
-
- return 0;
+ return retval;
}
-/*
-** free memory allocated in the transmit signal.
-**
-** XXX return value not checked.
-*/
static gint
-free_transmit (GnomePilotConduitStandardAbs *conduit,
- AddressbookLocalRecord *local,
- PilotRecord **remote,
- AddressbookConduitContext *ctxt)
+match (GnomePilotConduitSyncAbs *conduit,
+ GnomePilotRecord *remote,
+ EAddrLocalRecord **local,
+ EAddrConduitContext *ctxt)
{
- LOG ("entering free_transmit");
+/* char *uid; */
+
+ LOG ("match: looking for local copy of %s\n",
+ print_remote (remote));
+
+ g_return_val_if_fail (local != NULL, -1);
+ g_return_val_if_fail (remote != NULL, -1);
- g_return_val_if_fail(local!=NULL,-1);
- g_return_val_if_fail(remote!=NULL,-1);
+/* *local = NULL; */
+/* uid = g_hash_table_lookup (ctxt->pid_map, &remote->ID); */
+
+/* if (!uid) */
+/* return 0; */
- free_Address(local->address);
- g_free((*remote)->record);
- *remote = NULL;
- return 0;
+/* LOG (" matched\n"); */
+
+/* *local = g_new0 (EAddrLocalRecord, 1); */
+/* local_record_from_uid (*local, uid, ctxt); */
+
+ return 0;
}
-/*
-** used when synching. compare the local and remove record data and
-** determine equality.
-**
-** retval is similar to strcmp: 0 for equality, anything else for
-** inequality (no ordering is imposed).
-*/
static gint
-compare (GnomePilotConduitStandardAbs *conduit,
- AddressbookLocalRecord *local,
- PilotRecord *remote,
- AddressbookConduitContext *ctxt)
+free_match (GnomePilotConduitSyncAbs *conduit,
+ EAddrLocalRecord *local,
+ EAddrConduitContext *ctxt)
{
-#if 0
- /* used by the quick compare */
- PilotRecord *remoteOfLocal;
- int err;
- int retval;
-
- g_message ("entering compare");
- printf ("entering compare\n");
+ LOG ("free_match: freeing\n");
- g_return_val_if_fail (local!=NULL,-1);
- g_return_val_if_fail (remote!=NULL,-1);
+ g_return_val_if_fail (local != NULL, -1);
- err = transmit(conduit,local,&remoteOfLocal,ctxt);
- if (err != 0) return err;
-
- retval = 0;
- if (remote->length == remoteOfLocal->length) {
- if (memcmp(remoteOfLocal->record,remote->record,remote->length)!=0) {
- g_message("compare failed on contents");
- printf ("compare failed on contents\n");
- retval = 1;
-
- /* debug spew */
- {
- struct Address foolocal;
- struct Address fooremote;
-
- unpack_Address (&foolocal,
- remoteOfLocal->record,
- remoteOfLocal->length);
- unpack_Address (&fooremote,
- remote->record,
- remote->length);
-
- printf (" local:[%d %ld %d %d '%s' '%s']\n",
- foolocal.indefinite,
- mktime (& foolocal.due),
- foolocal.priority,
- foolocal.complete,
- foolocal.description,
- foolocal.note);
-
- printf ("remote:[%d %ld %d %d '%s' '%s']\n",
- fooremote.indefinite,
- mktime (& fooremote.due),
- fooremote.priority,
- fooremote.complete,
- fooremote.description,
- fooremote.note);
- }
- }
- } else {
- g_message("compare failed on length");
- printf("compare failed on length\n");
- retval = 1;
- }
+/* gtk_object_unref (GTK_OBJECT (local->comp)); */
+ g_free (local);
- free_transmit(conduit,local,&remoteOfLocal,ctxt);
- return retval;
-#endif /* 0 */
return 0;
}
-/*
-** XXX not actually called from the gnome-pilot source
-*/
static gint
-compare_backup (GnomePilotConduitStandardAbs *conduit,
- AddressbookLocalRecord *local,
- PilotRecord *remote,
- AddressbookConduitContext *ctxt)
+prepare (GnomePilotConduitSyncAbs *conduit,
+ EAddrLocalRecord *local,
+ GnomePilotRecord **remote,
+ EAddrConduitContext *ctxt)
{
- LOG ("entering compare_backup");
+ LOG ("prepare: encoding local %s\n", print_local (local));
- g_return_val_if_fail(local!=NULL,-1);
- g_return_val_if_fail(remote!=NULL,-1);
+/* *remote = local_record_to_pilot_record (local, ctxt); */
- return -1;
+/* if (!*remote) */
+/* return -1; */
+
+ return 0;
}
-/*
-** used when copying from the pilot.
-**
-** delete all records in the local database. this doesn't actually
-** remove the records, merely sets their status to DELETED.
-**
-** return value is < 0 on error, >= 0 on success.
-*/
static gint
-delete_all (GnomePilotConduitStandardAbs *conduit,
- AddressbookConduitContext *ctxt)
+free_prepare (GnomePilotConduitSyncAbs *conduit,
+ EAddrLocalRecord *local,
+ GnomePilotRecord **remote,
+ EAddrConduitContext *ctxt)
{
- GList *it;
+ LOG ("free_prepare: freeing\n");
- for (it=ctxt->cards; it; it = g_list_next (it)) {
- gtk_object_set (GTK_OBJECT (it->data),
- "pilot_status", E_CARD_PILOT_STATUS_DEL, NULL);
- }
+ g_return_val_if_fail (local != NULL, -1);
+ g_return_val_if_fail (remote != NULL, -1);
+
+ g_free (*remote);
+ *remote = NULL;
return 0;
}
-#ifdef NEED_OAF_INIT_HACK
static ORBit_MessageValidationResult
accept_all_cookies (CORBA_unsigned_long request_id,
CORBA_Principal *principal,
@@ -1186,26 +1167,20 @@ accept_all_cookies (CORBA_unsigned_long request_id,
/* allow ALL cookies */
return ORBIT_MESSAGE_ALLOW_ALL;
}
-#endif
+
GnomePilotConduit *
-conduit_get_gpilot_conduit (guint32 pilotId)
+conduit_get_gpilot_conduit (guint32 pilot_id)
{
GtkObject *retval;
- AddressbookConduitCfg *cfg;
- AddressbookConduitContext *ctxt;
+ EAddrConduitContext *ctxt;
- printf ("in address's conduit_get_gpilot_conduit\n");
+ LOG ("in address's conduit_get_gpilot_conduit\n");
-#ifdef NEED_OAF_INIT_HACK
-#ifndef NO_WARNINGS
-#warning "need a better way to do this"
-#endif
/* we need to find wombat with oaf, so make sure oaf
is initialized here. once the desktop is converted
to oaf and gpilotd is built with oaf, this can go away */
- if (! oaf_is_initialized ())
- {
+ if (!oaf_is_initialized ()) {
char *argv[ 1 ] = {"hi"};
oaf_init (1, argv);
@@ -1216,39 +1191,38 @@ conduit_get_gpilot_conduit (guint32 pilotId)
ORBit_set_request_validation_handler (accept_all_cookies);
}
-#endif
- retval = gnome_pilot_conduit_standard_abs_new ("AddressDB",
- 0x61646472);
+ retval = gnome_pilot_conduit_sync_abs_new ("AddressDB", 0x61646472);
g_assert (retval != NULL);
- gnome_pilot_conduit_construct(GNOME_PILOT_CONDUIT(retval),"AddressConduit");
- conduit_load_configuration(&cfg,pilotId);
- gtk_object_set_data (retval,"addressconduit_cfg",cfg);
+ gnome_pilot_conduit_construct (GNOME_PILOT_CONDUIT (retval),
+ "e_addr_conduit");
- conduit_new_context(&ctxt,cfg);
- gtk_object_set_data(GTK_OBJECT(retval),"addressconduit_context",ctxt);
+ e_addr_context_new (&ctxt, pilot_id);
+ gtk_object_set_data (GTK_OBJECT (retval), "addrconduit_context", ctxt);
- gtk_signal_connect (retval, "match_record", (GtkSignalFunc) match_record, ctxt);
- gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, ctxt);
-#ifdef SUPPORT_ARCHIVING
- gtk_signal_connect (retval, "archive_local", (GtkSignalFunc) archive_local, ctxt);
- gtk_signal_connect (retval, "archive_remote", (GtkSignalFunc) archive_remote, ctxt);
- gtk_signal_connect (retval, "set_archived", (GtkSignalFunc) set_archived, ctxt);
- gtk_signal_connect (retval, "clear_status_archive_local", (GtkSignalFunc) clear_status_archive_local, ctxt);
-#endif
- gtk_signal_connect (retval, "store_remote", (GtkSignalFunc) store_remote, ctxt);
- gtk_signal_connect (retval, "iterate", (GtkSignalFunc) iterate, ctxt);
- gtk_signal_connect (retval, "iterate_specific", (GtkSignalFunc) iterate_specific, ctxt);
- gtk_signal_connect (retval, "purge", (GtkSignalFunc) purge, ctxt);
- gtk_signal_connect (retval, "set_status", (GtkSignalFunc) set_status, ctxt);
- gtk_signal_connect (retval, "set_pilot_id", (GtkSignalFunc) set_pilot_id, ctxt);
- gtk_signal_connect (retval, "compare", (GtkSignalFunc) compare, ctxt);
- gtk_signal_connect (retval, "compare_backup", (GtkSignalFunc) compare_backup, ctxt);
- gtk_signal_connect (retval, "free_transmit", (GtkSignalFunc) free_transmit, ctxt);
- gtk_signal_connect (retval, "delete_all", (GtkSignalFunc) delete_all, ctxt);
- gtk_signal_connect (retval, "transmit", (GtkSignalFunc) transmit, ctxt);
gtk_signal_connect (retval, "pre_sync", (GtkSignalFunc) pre_sync, ctxt);
+ gtk_signal_connect (retval, "post_sync", (GtkSignalFunc) post_sync, ctxt);
+
+ gtk_signal_connect (retval, "set_pilot_id", (GtkSignalFunc) set_pilot_id, ctxt);
+
+ gtk_signal_connect (retval, "for_each", (GtkSignalFunc) for_each, ctxt);
+ gtk_signal_connect (retval, "for_each_modified", (GtkSignalFunc) for_each_modified, ctxt);
+ gtk_signal_connect (retval, "compare", (GtkSignalFunc) compare, ctxt);
+
+ gtk_signal_connect (retval, "add_record", (GtkSignalFunc) add_record, ctxt);
+ gtk_signal_connect (retval, "add_archive_record", (GtkSignalFunc) add_archive_record, ctxt);
+
+ gtk_signal_connect (retval, "replace_record", (GtkSignalFunc) replace_record, ctxt);
+
+ gtk_signal_connect (retval, "delete_record", (GtkSignalFunc) delete_record, ctxt);
+ gtk_signal_connect (retval, "delete_archive_record", (GtkSignalFunc) delete_archive_record, ctxt);
+
+ gtk_signal_connect (retval, "match", (GtkSignalFunc) match, ctxt);
+ gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, ctxt);
+
+ gtk_signal_connect (retval, "prepare", (GtkSignalFunc) prepare, ctxt);
+ gtk_signal_connect (retval, "free_prepare", (GtkSignalFunc) free_prepare, ctxt);
return GNOME_PILOT_CONDUIT (retval);
}
@@ -1256,19 +1230,12 @@ conduit_get_gpilot_conduit (guint32 pilotId)
void
conduit_destroy_gpilot_conduit (GnomePilotConduit *conduit)
{
- AddressbookConduitCfg *cc;
- AddressbookConduitContext *ctxt;
-
- cc = GET_CONDUITCFG(conduit);
- ctxt = GET_CONDUITCONTEXT(conduit);
-
- if (ctxt->ebook != NULL) {
- gtk_object_unref (GTK_OBJECT (ctxt->ebook));
- }
+ EAddrConduitContext *ctxt;
- conduit_destroy_configuration (&cc);
+ ctxt = gtk_object_get_data (GTK_OBJECT (conduit),
+ "addrconduit_context");
- conduit_destroy_context (&ctxt);
+ e_addr_context_destroy (&ctxt);
gtk_object_destroy (GTK_OBJECT (conduit));
}
diff --git a/addressbook/conduit/address-conduit.h b/addressbook/conduit/address-conduit.h
index 427e6b8c91..55142d08c2 100644
--- a/addressbook/conduit/address-conduit.h
+++ b/addressbook/conduit/address-conduit.h
@@ -1,86 +1,78 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* Evolution calendar - ToDo Conduit Capplet
+ *
+ * Copyright (C) 1998 Free Software Foundation
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * Authors: Eskil Heyn Olsen <deity@eskil.dk>
+ * JP Rosevear <jpr@helixcode.com>
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
-#ifndef __ADDRESS_CONDUIT_H__
-#define __ADDRESS_CONDUIT_H__
+#ifndef __ADDR_CONDUIT_H__
+#define __ADDR_CONDUIT_H__
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <gnome.h>
-#include <liboaf/liboaf.h>
#include <pi-address.h>
#include <gpilotd/gnome-pilot-conduit.h>
-#include <gpilotd/gnome-pilot-conduit-standard-abs.h>
-#include "ebook/e-card.h"
-#include "ebook/e-card-simple.h"
-#include "ebook/e-book.h"
-#include "ebook/e-book-view.h"
+#include <gpilotd/gnome-pilot-conduit-sync-abs.h>
-/* This is the local record structure for the GnomeCal conduit. */
-typedef struct _AddressbookLocalRecord AddressbookLocalRecord;
-struct _AddressbookLocalRecord {
+/* This is the local record structure for the Evolution ToDo conduit. */
+typedef struct _EAddrLocalRecord EAddrLocalRecord;
+struct _EAddrLocalRecord {
/* The stuff from gnome-pilot-conduit-standard-abs.h
Must be first in the structure, or instances of this
structure cannot be used by gnome-pilot-conduit-standard-abs.
*/
- LocalRecord local;
- /* The corresponding Evolution addressbook object. */
+ GnomePilotDesktopRecord local;
+
+ /* The corresponding ECard object */
ECard *ecard;
- /* pilot-link address structure, used for implementing Transmit. */
- struct Address *address;
-};
-#define ADDRESSBOOK_LOCALRECORD(s) ((AddressbookLocalRecord*)(s))
-
-/* This is the configuration of the GnomeCal conduit. */
-typedef struct _AddressbookConduitCfg AddressbookConduitCfg;
-struct _AddressbookConduitCfg {
- gboolean open_secret;
- guint32 pilotId;
- GnomePilotConduitSyncType sync_type; /* only used by capplet */
+
+ /* pilot-link todo structure, used for implementing Transmit. */
+ struct Address *addr;
};
-#define GET_CONDUITCFG(c) ((AddressbookConduitCfg*)gtk_object_get_data(GTK_OBJECT(c),"addressconduit_cfg"))
-/* This is the context for all the Addressbook conduit methods. */
-typedef struct _AddressbookConduitContext AddressbookConduitContext;
-struct _AddressbookConduitContext {
+/* This is the context for all the GnomeCal conduit methods. */
+typedef struct _EAddrConduitContext EAddrConduitContext;
+struct _EAddrConduitContext {
+ EAddrConduitCfg *cfg;
+
struct AddressAppInfo ai;
- AddressbookConduitCfg *cfg;
+
EBook *ebook;
- // ECardCursor *cursor;
GList *cards;
- /* CalClient *client;*/
- CORBA_Environment ev;
- CORBA_ORB orb;
+
gboolean address_load_tried;
gboolean address_load_success;
- char *address_file;
-};
-#define GET_CONDUITCONTEXT(c) ((AddressbookConduitContext*)gtk_object_get_data(GTK_OBJECT(c),"addressconduit_context"))
-
-
-/* Given a GCalConduitCfg*, allocates the structure and
- loads the configuration data for the given pilot.
- this is defined in the header file because it is used by
- both address-conduit and address-conduit-control-applet,
- and we don't want to export any symbols we don't have to. */
-static void
-conduit_load_configuration(AddressbookConduitCfg **c,
- guint32 pilotId)
-{
- gchar prefix[256];
- g_snprintf(prefix,255,"/gnome-pilot.d/address-conduit/Pilot_%u/",pilotId);
+ time_t since;
- *c = g_new0(AddressbookConduitCfg,1);
- g_assert(*c != NULL);
- gnome_config_push_prefix(prefix);
- (*c)->open_secret = gnome_config_get_bool("open_secret=FALSE");
- (*c)->sync_type = GnomePilotConduitSyncTypeCustom; /* set in capplets main */
- gnome_config_pop_prefix();
-
- (*c)->pilotId = pilotId;
-}
+ GHashTable *uid_map;
+ GHashTable *pid_map;
+};
+
+#endif __ADDR_CONDUIT_H__
+
+
+
+
-#endif __ADDRESS_CONDUIT_H__
diff --git a/addressbook/conduit/address.conduit.in b/addressbook/conduit/address.conduit.in
deleted file mode 100644
index 3a0416fac8..0000000000
--- a/addressbook/conduit/address.conduit.in
+++ /dev/null
@@ -1,8 +0,0 @@
-<gnome-pilot-conduit version="1.0">
-<conduit id="address_conduit" type="shlib" location="@prefix@/lib/gnome-pilot/conduits/libaddress_conduit.so"/>
-<name value="address"/>
-<conduit-attribute name="description" value="Synchronizes with Evolution"/>
-<conduit-attribute name="default-synctype" value="synchronize"/>
-<conduit-attribute name="icon" value="@prefix@/share/pixmaps/gnome-calendar-conduit.png"/>
-<conduit-attribute name="settings" value="TRUE"/>
-</gnome-pilot-conduit>