diff options
author | nobody <nobody@localhost> | 2001-01-12 00:04:13 +0800 |
---|---|---|
committer | nobody <nobody@localhost> | 2001-01-12 00:04:13 +0800 |
commit | 9739536b4fde31bc150175df0accd8294c9ee09e (patch) | |
tree | d85b68359c2b29573feb055cb4a8269e5aa3bc56 /calendar/conduits | |
parent | f753547d5d281b34587430a88a1dc1934d65c889 (diff) | |
download | gsoc2013-evolution-9739536b4fde31bc150175df0accd8294c9ee09e.tar.gz gsoc2013-evolution-9739536b4fde31bc150175df0accd8294c9ee09e.tar.zst gsoc2013-evolution-9739536b4fde31bc150175df0accd8294c9ee09e.zip |
This commit was manufactured by cvs2svn to create tag 'BONOBO_0_33'.BONOBO_0_33
svn path=/tags/BONOBO_0_33/; revision=7389
Diffstat (limited to 'calendar/conduits')
19 files changed, 0 insertions, 3535 deletions
diff --git a/calendar/conduits/.cvsignore b/calendar/conduits/.cvsignore deleted file mode 100644 index b840c21800..0000000000 --- a/calendar/conduits/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile.in -Makefile
\ No newline at end of file diff --git a/calendar/conduits/Makefile.am b/calendar/conduits/Makefile.am deleted file mode 100644 index 906ea61971..0000000000 --- a/calendar/conduits/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = calendar todo diff --git a/calendar/conduits/calendar/.cvsignore b/calendar/conduits/calendar/.cvsignore deleted file mode 100644 index 83c86fa189..0000000000 --- a/calendar/conduits/calendar/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -Makefile.in -Makefile -.deps -e-calendar.conduit -*.lo -.libs -libecalendar_conduit.la -e-calendar-conduit-control-applet diff --git a/calendar/conduits/calendar/Makefile.am b/calendar/conduits/calendar/Makefile.am deleted file mode 100644 index 0acb102db1..0000000000 --- a/calendar/conduits/calendar/Makefile.am +++ /dev/null @@ -1,68 +0,0 @@ -INCLUDES = \ - -I$(top_srcdir) \ - -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) \ - $(PISOCK_INCLUDEDIR) \ - $(GNOME_PILOT_CFLAGS) - -# Calendar Capplet -bin_PROGRAMS = e-calendar-conduit-control-applet - -e_calendar_conduit_control_applet_SOURCES = calendar-conduit-control-applet.c - -e_calendar_conduit_control_applet_LDADD = \ - $(CAPPLET_LIBS) \ - $(GNOME_LIBDIR) \ - $(GNOME_PILOT_LIBS) \ - $(PISOCK_LIBDIR) $(PISOCK_LIBS) \ - $(GNOME_CAPPLET_LIBS) \ - $(BONOBO_VFS_GNOME_LIBS) \ - $(GNOME_XML_LIB) \ - $(GNOMEUI_LIBS) \ - $(INTLLIBS) - -# Calendar Conduit -e_calendar_conduitsdir=$(libdir)/gnome-pilot/conduits -e_calendar_conduits_LTLIBRARIES = libecalendar_conduit.la - -libecalendar_conduit_la_SOURCES = \ - calendar-conduit.c \ - calendar-conduit.h \ - calendar-conduit-config.h - -libecalendar_conduit_la_LIBADD = \ - $(top_builddir)/calendar/cal-client/libcal-client-static.la \ - $(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) \ - $(GNOME_LIBS) - -e-calendar.conduit: e-calendar.conduit.in Makefile - sed -e 's^\@prefix\@^$(prefix)^g' < $(srcdir)/e-calendar.conduit.in > e-calendar.conduit.tmp \ - && mv e-calendar.conduit.tmp e-calendar.conduit - -ccenterdir = $(datadir)/control-center -ccenterPalmPilotdir = $(ccenterdir)/Peripherals -ccenterConduitsdir = $(ccenterPalmPilotdir)/Conduits -ccenterConduits_DATA = e-calendar-conduit-control-applet.desktop - -panelConduitsdir = $(datadir)/gnome/apps/Settings/Peripherals/Conduits -panelConduits_DATA = $(ccenterConduits_DATA) - -Conduitdir = $(datadir)/gnome-pilot/conduits/ -Conduit_DATA = e-calendar.conduit - -EXTRA_DIST = \ - e-calendar.conduit.in \ - $(ccenterConduits_DATA) - -install-data-local: - $(mkinstalldirs) $(ccenterConduitsdir) - $(mkinstalldirs) $(Conduitdir) diff --git a/calendar/conduits/calendar/calendar-conduit-config.h b/calendar/conduits/calendar/calendar-conduit-config.h deleted file mode 100644 index d0ba28dbb1..0000000000 --- a/calendar/conduits/calendar/calendar-conduit-config.h +++ /dev/null @@ -1,120 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution calendar - Calendar Conduit Configuration - * - * 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 __CAL_CONDUIT_CONFIG_H__ -#define __CAL_CONDUIT_CONFIG_H__ - -#include <gnome.h> -#include <libgpilotdCM/gnome-pilot-conduit-management.h> -#include <libgpilotdCM/gnome-pilot-conduit-config.h> - -/* Configuration info */ -typedef struct _ECalConduitCfg ECalConduitCfg; -struct _ECalConduitCfg { - gboolean open_secret; - guint32 pilot_id; - GnomePilotConduitSyncType sync_type; /* only used by capplet */ -}; - -#ifdef CAL_CONFIG_LOAD -/* Loads the configuration data */ -static void -calconduit_load_configuration (ECalConduitCfg **c, guint32 pilot_id) -{ - gchar prefix[256]; - g_snprintf (prefix, 255, "/gnome-pilot.d/e-todo-conduit/Pilot_%u/", - pilot_id); - - *c = g_new0 (ECalConduitCfg,1); - g_assert (*c != NULL); - - gnome_config_push_prefix (prefix); - (*c)->open_secret = gnome_config_get_bool ("open_secret=FALSE"); - - /* set in capplets main */ - (*c)->sync_type = GnomePilotConduitSyncTypeCustom; - gnome_config_pop_prefix (); - - (*c)->pilot_id = pilot_id; -} -#endif - -#ifdef CAL_CONFIG_SAVE -/* Saves the configuration data. */ -static void -calconduit_save_configuration (ECalConduitCfg *c) -{ - gchar prefix[256]; - - g_snprintf (prefix, 255, "/gnome-pilot.d/e-todo-conduit/Pilot_%u/", - c->pilot_id); - - 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 (); -} -#endif - -#ifdef CAL_CONFIG_DUPE -/* Creates a duplicate of the configuration data */ -static ECalConduitCfg* -calconduit_dupe_configuration (ECalConduitCfg *c) -{ - ECalConduitCfg *retval; - - g_return_val_if_fail (c != NULL, NULL); - - retval = g_new0 (ECalConduitCfg, 1); - retval->sync_type = c->sync_type; - retval->open_secret = c->open_secret; - retval->pilot_id = c->pilot_id; - - return retval; -} -#endif - -#ifdef CAL_CONFIG_DESTROY -/* Destroy a configuration */ -static void -calconduit_destroy_configuration (ECalConduitCfg **c) -{ - g_return_if_fail (c != NULL); - g_return_if_fail (*c != NULL); - - g_free (*c); - *c = NULL; -} -#endif - -#endif __CAL_CONDUIT_CONFIG_H__ - - - - - - - diff --git a/calendar/conduits/calendar/calendar-conduit-control-applet.c b/calendar/conduits/calendar/calendar-conduit-control-applet.c deleted file mode 100644 index ecd8d84e65..0000000000 --- a/calendar/conduits/calendar/calendar-conduit-control-applet.c +++ /dev/null @@ -1,342 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution calendar - Calendar 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> -#include <signal.h> -#include <gnome.h> - -#include <config.h> -#include <capplet-widget.h> - -#include <gpilotd/gnome-pilot-client.h> - -#define CAL_CONFIG_LOAD 1 -#define CAL_CONFIG_SAVE 1 -#define CAL_CONFIG_DUPE 1 -#define CAL_CONFIG_DESTROY 1 -#include <calendar-conduit-config.h> -#undef CAL_CONFIG_LOAD -#undef CAL_CONFIG_SAVE -#undef CAL_CONFIG_DUPE -#undef CAL_CONFIG_DESTROY - -/* tell changes callbacks to ignore changes or not */ -static gboolean ignore_changes=FALSE; - -/* capplet widget */ -static GtkWidget *capplet=NULL; - -/* host/device/pilot configuration windows */ -GtkWidget *cfgOptionsWindow=NULL; -GtkWidget *cfgStateWindow=NULL; -GtkWidget *dialogWindow=NULL; - -gboolean activated,org_activation_state; -GnomePilotConduitManagement *conduit; -GnomePilotConduitConfig *conduit_config; -ECalConduitCfg *origState = NULL; -ECalConduitCfg *curState = NULL; - -static void doTrySettings(GtkWidget *widget, ECalConduitCfg *c); -static void doRevertSettings(GtkWidget *widget, ECalConduitCfg *c); -static void doSaveSettings(GtkWidget *widget, ECalConduitCfg *c); - -static void setStateCfg (GtkWidget *w, ECalConduitCfg *c); - -gint pilotId; -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. -*/ -static gchar* sync_options[] ={ N_("Disabled"), - N_("Synchronize"), - N_("Copy From Pilot"), - N_("Copy To Pilot"), - N_("Merge From Pilot"), - N_("Merge To Pilot")}; -#define SYNC_OPTIONS_COUNT 6 - -static void -doTrySettings (GtkWidget *widget, ECalConduitCfg *c) -{ - if (c->sync_type != GnomePilotConduitSyncTypeCustom) - gnome_pilot_conduit_config_enable_with_first_sync (conduit_config, - c->sync_type, - c->sync_type, - TRUE); - else - gnome_pilot_conduit_config_disable (conduit_config); - - calconduit_save_configuration (c); -} - -static void -doRevertSettings (GtkWidget *widget, ECalConduitCfg *c) -{ - activated = org_activation_state; - *c = *origState; - setStateCfg (cfgStateWindow, c); - doTrySettings (widget, c); -} - -static void -doSaveSettings (GtkWidget *widget, ECalConduitCfg *c) -{ - *origState = *c; - doTrySettings (widget, c); -} - - -static void -doHelp (GtkWidget *widget, gpointer data) -{ - GtkWidget *about; - const gchar *authors[] = { - _("JP Rosevear <jpr@helixcode.com>"), - "", _("Original Author:"), - _("Eskil Heyn Olsen <deity@eskil.dk>"), - NULL}; - - about = gnome_about_new ( - _("Evolution Calendar Conduit"), VERSION, - _("(C) 1998-2000 the Free Software Foundation and Helix Code"), - authors, - _("Configuration utility for the evolution calendar conduit.\n"), - _("gnome-unknown.xpm")); - gtk_widget_show (about); - - return; -} - - -/* 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) -{ - GtkWidget *vbox, *table; - GtkWidget *label; - GtkWidget *optionMenu,*menuItem; - GtkMenu *menu; - gint i; - - vbox = gtk_vbox_new(FALSE, GNOME_PAD); - - table = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, GNOME_PAD); - - label = gtk_label_new(_("Synchronize Action")); - gtk_box_pack_start(GTK_BOX(table), label, FALSE, FALSE, GNOME_PAD); - - optionMenu=gtk_option_menu_new(); - gtk_object_set_data(GTK_OBJECT(vbox), "conduit_state", optionMenu); - menu = GTK_MENU(gtk_menu_new()); - - for (i=0; i<SYNC_OPTIONS_COUNT;i++) { - sync_options[i]=_(sync_options[i]); - menuItem = gtk_menu_item_new_with_label(sync_options[i]); - gtk_widget_show(menuItem); - gtk_signal_connect(GTK_OBJECT(menuItem),"activate", - GTK_SIGNAL_FUNC(activate_sync_type), - GINT_TO_POINTER(i)); - gtk_menu_append(menu,menuItem); - } - - gtk_option_menu_set_menu(GTK_OPTION_MENU(optionMenu),GTK_WIDGET(menu)); - gtk_box_pack_start(GTK_BOX(table), optionMenu, FALSE, FALSE, 0); - - return vbox; -} - - -static void -setStateCfg (GtkWidget *w, ECalConduitCfg *c) -{ - GtkOptionMenu *optionMenu; - GtkMenu *menu; - - optionMenu = gtk_object_get_data (GTK_OBJECT(w), "conduit_state"); - g_assert (optionMenu != NULL); - menu = GTK_MENU (gtk_option_menu_get_menu (optionMenu)); - - ignore_changes = TRUE; - /* Here were are relying on the items in menu being the same - order as in GnomePilotConduitSyncType. */ - gtk_option_menu_set_history (optionMenu, (int) c->sync_type); - ignore_changes = FALSE; -} - - -static void -pilot_capplet_setup(void) -{ - GtkWidget *frame, *table; - - capplet = capplet_widget_new(); - - table = gtk_table_new(1, 2, FALSE); - gtk_container_border_width(GTK_CONTAINER(table), GNOME_PAD); - gtk_container_add(GTK_CONTAINER(capplet), table); - - frame = gtk_frame_new(_("Conduit state")); - gtk_container_border_width(GTK_CONTAINER(frame), GNOME_PAD_SMALL); - gtk_table_attach_defaults(GTK_TABLE(table), frame, 0, 1, 0, 1); - cfgStateWindow = createStateCfgWindow(); - gtk_container_add(GTK_CONTAINER(frame), cfgStateWindow); - - gtk_signal_connect(GTK_OBJECT(capplet), "try", - GTK_SIGNAL_FUNC(doTrySettings), curState); - gtk_signal_connect(GTK_OBJECT(capplet), "revert", - GTK_SIGNAL_FUNC(doRevertSettings), curState); - gtk_signal_connect(GTK_OBJECT(capplet), "ok", - GTK_SIGNAL_FUNC(doSaveSettings), curState); - gtk_signal_connect(GTK_OBJECT(capplet), "help", - GTK_SIGNAL_FUNC(doHelp), NULL); - - - setStateCfg (cfgStateWindow, curState); - - gtk_widget_show_all (capplet); -} - - -static void -run_error_dialog(gchar *mesg,...) -{ - char tmp[80]; - va_list ap; - - va_start(ap,mesg); - vsnprintf(tmp,79,mesg,ap); - dialogWindow = gnome_message_box_new(mesg,GNOME_MESSAGE_BOX_ERROR,GNOME_STOCK_BUTTON_OK,NULL); - gnome_dialog_run_and_close(GNOME_DIALOG(dialogWindow)); - va_end(ap); -} - - -static gint -get_pilot_id_from_gpilotd() -{ - GList *pilots=NULL; - gint pilot; - int i,err; - - i=0; - /* we don't worry about leaking here, so pilots isn't freed */ - switch(err = gnome_pilot_client_get_pilots(gpc,&pilots)) { - case GPILOTD_OK: { - if(pilots) { - for(i=0;i<g_list_length(pilots);i++) { - g_message("pilot %d = \"%s\"",i,(gchar*)g_list_nth(pilots,i)->data); - } - if(i==0) { - run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first.")); - return -1; - } else { - gnome_pilot_client_get_pilot_id_by_name(gpc, - pilots->data, /* this is the first pilot */ - &pilot); - if(i>1) { - g_message("too many pilots..."); - /* need a choose here */ - } - return pilot; - } - } else { - run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first.")); - return -1; - } - break; - } - case GPILOTD_ERR_NOT_CONNECTED: - run_error_dialog(_("Not connected to the gnome-pilot daemon")); - return -1; - break; - default: - g_warning("gnome_pilot_client_get_pilot_ids(...) = %d",err); - run_error_dialog(_("An error occured when trying to fetch\npilot list from the gnome-pilot daemon")); - return -1; - break; - } -} - - -int -main (int argc, char *argv[]) -{ - g_log_set_always_fatal (G_LOG_LEVEL_ERROR | - G_LOG_LEVEL_CRITICAL | - G_LOG_LEVEL_WARNING); - - /* Init capplet */ - gnome_capplet_init ("Evolution Calendar conduit control applet", - NULL, argc, argv, - NULL, 0, NULL); - - /* 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 = gnome_pilot_conduit_management_new ("e_calendar_conduit", GNOME_PILOT_CONDUIT_MGMT_ID); - if (conduit == NULL) - return -1; - - calconduit_load_configuration (&origState, pilotId); - conduit_config = gnome_pilot_conduit_config_new (conduit, pilotId); - org_activation_state = activated = - gnome_pilot_conduit_config_is_enabled (conduit_config, - &origState->sync_type); - - curState = calconduit_dupe_configuration (origState); - - pilot_capplet_setup (); - - /* Done setting up, now run main loop */ - capplet_gtk_main(); - - /* Clean up */ - gnome_pilot_conduit_management_destroy (conduit); - calconduit_destroy_configuration (&origState); - calconduit_destroy_configuration (&curState); - - return 0; -} diff --git a/calendar/conduits/calendar/calendar-conduit-control-applet.desktop b/calendar/conduits/calendar/calendar-conduit-control-applet.desktop deleted file mode 100644 index b15e8f940c..0000000000 --- a/calendar/conduits/calendar/calendar-conduit-control-applet.desktop +++ /dev/null @@ -1,21 +0,0 @@ -[Desktop Entry] -Name=Calendar conduit -Name[pt_BR]=Conduit calendário -Name[da]=Gnome kalender -Name[es]=Enlace de calendario -Name[fr]=Conduit Calendrier -Name[no]=GNOME kalender -Name[sv]=Kalenderkanal -Name[tr]=Takvim parçasý -Comment=Configure the GnomeCal conduit -Comment[pt_BR]=Configurar o conduit GnomeCal -Comment[da]=Konfigurér GnomeCal-komponent -Comment[es]=Configurar el enlace de calendario -Comment[fr]=Configuration du conduit calendrier -Comment[no]=Konfigurér GnomeCal-komponent -Comment[sv]=Konfigurera GnomeCal-kanalen -Comment[tr]=GnomeCal takvim parçasý ayarlarý -Exec=calendar-conduit-control-applet --cap-id=1 -Terminal=0 -Type=Application -Icon=gnome-calendar-conduit.png diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c deleted file mode 100644 index 27163b9eeb..0000000000 --- a/calendar/conduits/calendar/calendar-conduit.c +++ /dev/null @@ -1,1198 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution calendar - Calendar 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 <liboaf/liboaf.h> -#include <bonobo.h> -#include <cal-client/cal-client-types.h> -#include <cal-client/cal-client.h> -#include <cal-util/timeutil.h> -#include <pi-source.h> -#include <pi-socket.h> -#include <pi-file.h> -#include <pi-dlp.h> -#include <libical/src/libical/icaltypes.h> -#include <e-pilot-util.h> - -#define CAL_CONFIG_LOAD 1 -#define CAL_CONFIG_DESTROY 1 -#include <calendar-conduit-config.h> -#undef CAL_CONFIG_LOAD -#undef CAL_CONFIG_DESTROY - -#include <calendar-conduit.h> - -GnomePilotConduit * conduit_get_gpilot_conduit (guint32); -void conduit_destroy_gpilot_conduit (GnomePilotConduit*); - -#define CONDUIT_VERSION "0.1.5" -#ifdef G_LOG_DOMAIN -#undef G_LOG_DOMAIN -#endif -#define G_LOG_DOMAIN "ecalconduit" - -#define DEBUG_CALCONDUIT 1 -/* #undef DEBUG_CALCONDUIT */ - -#ifdef DEBUG_CALCONDUIT -#define LOG(e...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, e) -#else -#define LOG(e...) -#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) - -/* Debug routines */ -static char * -print_local (ECalLocalRecord *local) -{ - static char buff[ 4096 ]; - - if (local == NULL) { - sprintf (buff, "[NULL]"); - return buff; - } - - if (local->appt && local->appt->description) { - sprintf (buff, "[%ld %ld '%s' '%s']", - mktime (&local->appt->begin), - mktime (&local->appt->end), - local->appt->description, - local->appt->note); - return buff; - } - - return ""; -} - -static char *print_remote (GnomePilotRecord *remote) -{ - static char buff[ 4096 ]; - struct Appointment appt; - - if (remote == NULL) { - sprintf (buff, "[NULL]"); - return buff; - } - - memset (&appt, 0, sizeof (struct Appointment)); - unpack_Appointment (&appt, remote->record, remote->length); - - sprintf (buff, "[%ld %ld '%s' '%s']", - mktime (&appt.begin), - mktime (&appt.end), - appt.description, - appt.note); - - return buff; -} - -/* Context Routines */ -static ECalConduitContext * -e_calendar_context_new (guint32 pilot_id) -{ - ECalConduitContext *ctxt = g_new0 (ECalConduitContext, 1); - - calconduit_load_configuration (&ctxt->cfg, pilot_id); - - return ctxt; -} - -static void -e_calendar_context_foreach_change (gpointer key, gpointer value, gpointer data) -{ - g_free (key); -} - -static void -e_calendar_context_destroy (ECalConduitContext *ctxt) -{ - g_return_if_fail (ctxt != NULL); - - if (ctxt->cfg != NULL) - calconduit_destroy_configuration (&ctxt->cfg); - - if (ctxt->client != NULL) - gtk_object_unref (GTK_OBJECT (ctxt->client)); - - if (ctxt->calendar_file) - g_free (ctxt->calendar_file); - - if (ctxt->uids) - cal_obj_uid_list_free (ctxt->uids); - - if (ctxt->changed_hash) - g_hash_table_foreach (ctxt->changed_hash, e_calendar_context_foreach_change, NULL); - - if (ctxt->changed) - cal_client_change_list_free (ctxt->changed); - - if (ctxt->map) - e_pilot_map_destroy (ctxt->map); - - g_free (ctxt); -} - -/* Calendar Server routines */ -static void -start_calendar_server_cb (GtkWidget *cal_client, - CalClientLoadStatus status, - ECalConduitContext *ctxt) -{ - CalClient *client = CAL_CLIENT (cal_client); - - LOG (" entering start_calendar_server_load_cb, tried=%d\n", - ctxt->calendar_load_tried); - - if (status == CAL_CLIENT_LOAD_SUCCESS) { - ctxt->calendar_load_success = TRUE; - LOG (" success\n"); - gtk_main_quit (); /* end the sub event loop */ - } else { - if (ctxt->calendar_load_tried) { - LOG (" load and create of calendar failed\n"); - gtk_main_quit (); /* end the sub event loop */ - return; - } - - cal_client_create_calendar (client, ctxt->calendar_file); - ctxt->calendar_load_tried = TRUE; - } -} - -static int -start_calendar_server (ECalConduitContext *ctxt) -{ - - g_return_val_if_fail (ctxt != NULL, -2); - - ctxt->client = cal_client_new (); - - /* FIX ME */ - ctxt->calendar_file = g_concat_dir_and_file (g_get_home_dir (), - "evolution/local/Calendar/calendar.ics"); - - gtk_signal_connect (GTK_OBJECT (ctxt->client), "cal_loaded", - start_calendar_server_cb, ctxt); - - LOG (" calling cal_client_load_calendar\n"); - cal_client_load_calendar (ctxt->client, ctxt->calendar_file); - - /* run a sub event loop to turn cal-client's async load - notification into a synchronous call */ - gtk_main (); - - if (ctxt->calendar_load_success) - return 0; - - return -1; -} - -/* Utility routines */ -static char * -map_name (ECalConduitContext *ctxt) -{ - char *filename; - - filename = g_strdup_printf ("%s/evolution/local/Calendar/pilot-map-calendar-%d.xml", g_get_home_dir (), ctxt->cfg->pilot_id); - - return filename; -} - -static icalrecurrencetype_weekday -get_ical_day (int day) -{ - switch (day) { - case 0: - return ICAL_SUNDAY_WEEKDAY; - case 1: - return ICAL_MONDAY_WEEKDAY; - case 2: - return ICAL_TUESDAY_WEEKDAY; - case 3: - return ICAL_WEDNESDAY_WEEKDAY; - case 4: - return ICAL_THURSDAY_WEEKDAY; - case 5: - return ICAL_FRIDAY_WEEKDAY; - case 6: - return ICAL_SATURDAY_WEEKDAY; - } - - return ICAL_NO_WEEKDAY; -} - -static int -get_pilot_day (icalrecurrencetype_weekday wd) -{ - switch (wd) { - case ICAL_SUNDAY_WEEKDAY: - return 0; - case ICAL_MONDAY_WEEKDAY: - return 1; - case ICAL_TUESDAY_WEEKDAY: - return 2; - case ICAL_WEDNESDAY_WEEKDAY: - return 3; - case ICAL_THURSDAY_WEEKDAY: - return 4; - case ICAL_FRIDAY_WEEKDAY: - return 5; - case ICAL_SATURDAY_WEEKDAY: - return 6; - default: - return -1; - } -} - -static gboolean -is_empty_time (struct tm time) -{ - if (time.tm_sec || time.tm_min || time.tm_hour - || time.tm_mday || time.tm_mon || time.tm_year) - return FALSE; - - return TRUE; -} - -static short -nth_weekday (int pos, icalrecurrencetype_weekday weekday) -{ - g_assert (pos > 0 && pos <= 5); - - return (pos << 3) | (int) weekday; -} - -static GList * -next_changed_item (ECalConduitContext *ctxt, GList *changes) -{ - CalClientChange *ccc; - GList *l; - - for (l = changes; l != NULL; l = l->next) { - const char *uid; - - ccc = l->data; - - cal_component_get_uid (ccc->comp, &uid); - if (g_hash_table_lookup (ctxt->changed_hash, uid)) - return l; - } - - return NULL; -} - -static void -compute_status (ECalConduitContext *ctxt, ECalLocalRecord *local, const char *uid) -{ - CalClientChange *ccc; - - local->local.archived = FALSE; - local->local.secret = FALSE; - - ccc = g_hash_table_lookup (ctxt->changed_hash, uid); - - if (ccc == NULL) { - local->local.attr = GnomePilotRecordNothing; - return; - } - - switch (ccc->type) { - case CAL_CLIENT_CHANGE_ADDED: - local->local.attr = GnomePilotRecordNew; - break; - - case CAL_CLIENT_CHANGE_MODIFIED: - local->local.attr = GnomePilotRecordModified; - break; - - case CAL_CLIENT_CHANGE_DELETED: - local->local.attr = GnomePilotRecordDeleted; - break; - } -} - -static GnomePilotRecord -local_record_to_pilot_record (ECalLocalRecord *local, - ECalConduitContext *ctxt) -{ - GnomePilotRecord p; - - g_assert (local->comp != NULL); - g_assert (local->appt != NULL ); - - p.ID = local->local.ID; - p.category = 0; - p.attr = local->local.attr; - p.archived = local->local.archived; - p.secret = local->local.secret; - - /* Generate pilot record structure */ - p.record = g_new0 (char, 0xffff); - p.length = pack_Appointment (local->appt, p.record, 0xffff); - - return p; -} - -/* - * converts a CalComponent object to a ECalLocalRecord - */ -static void -local_record_from_comp (ECalLocalRecord *local, CalComponent *comp, ECalConduitContext *ctxt) -{ - const char *uid; - CalComponentText summary; - GSList *d_list = NULL; - CalComponentText *description; - CalComponentDateTime dt; - time_t dt_time; - CalComponentClassification classif; - int i; - - g_return_if_fail (local != NULL); - g_return_if_fail (comp != NULL); - - local->comp = comp; - - cal_component_get_uid (local->comp, &uid); - local->local.ID = e_pilot_map_lookup_pid (ctxt->map, uid); - compute_status (ctxt, local, uid); - - local->appt = g_new0 (struct Appointment, 1); - - /* STOP: don't replace these with g_strdup, since free_Appointment - uses free to deallocate */ - cal_component_get_summary (comp, &summary); - if (summary.value) - local->appt->description = e_pilot_utf8_to_pchar (summary.value); - - cal_component_get_description_list (comp, &d_list); - if (d_list) { - description = (CalComponentText *) d_list->data; - if (description && description->value) - local->appt->note = e_pilot_utf8_to_pchar (description->value); - else - local->appt->note = NULL; - } else { - local->appt->note = NULL; - } - - cal_component_get_dtstart (comp, &dt); - if (dt.value) { - dt_time = icaltime_as_timet (*dt.value); - - local->appt->begin = *localtime (&dt_time); - } - - cal_component_get_dtend (comp, &dt); - if (dt.value && time_add_day (dt_time, 1) != icaltime_as_timet (*dt.value)) { - dt_time = icaltime_as_timet (*dt.value); - - local->appt->end = *localtime (&dt_time); - local->appt->event = 0; - } else { - local->appt->event = 1; - } - - /* Recurrence Rules */ - local->appt->repeatType = repeatNone; - - if (cal_component_has_rrules (comp)) { - GSList *list; - struct icalrecurrencetype *recur; - - cal_component_get_rrule_list (comp, &list); - recur = list->data; - - switch (recur->freq) { - case ICAL_DAILY_RECURRENCE: - local->appt->repeatType = repeatDaily; - break; - case ICAL_WEEKLY_RECURRENCE: - local->appt->repeatType = repeatWeekly; - for (i = 0; i <= 7 && recur->by_day[i] != ICAL_RECURRENCE_ARRAY_MAX; i++) { - icalrecurrencetype_weekday wd; - - wd = icalrecurrencetype_day_day_of_week (recur->by_day[i]); - local->appt->repeatDays[get_pilot_day (wd)] = 1; - } - - break; - case ICAL_MONTHLY_RECURRENCE: - if (recur->by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { - local->appt->repeatType = repeatMonthlyByDate; - break; - } - - /* FIX ME Not going to work with -ve by_day */ - local->appt->repeatType = repeatMonthlyByDay; - switch (icalrecurrencetype_day_position (recur->by_day[0])) { - case 1: - local->appt->repeatDay = dom1stSun; - break; - case 2: - local->appt->repeatDay = dom2ndSun; - break; - case 3: - local->appt->repeatDay = dom3rdSun; - break; - case 4: - local->appt->repeatDay = dom4thSun; - break; - case 5: - local->appt->repeatDay = domLastSun; - break; - } - local->appt->repeatDay += get_pilot_day (icalrecurrencetype_day_day_of_week (recur->by_day[0])); - break; - case ICAL_YEARLY_RECURRENCE: - local->appt->repeatType = repeatYearly; - break; - default: - break; - } - - if (local->appt->repeatType != repeatNone) { - local->appt->repeatFrequency = recur->interval; - } - - if (icaltime_is_null_time (recur->until)) { - local->appt->repeatForever = 1; - } else { - local->appt->repeatForever = 0; - dt_time = icaltime_as_timet (recur->until); - local->appt->repeatEnd = *localtime (&dt_time); - } - - cal_component_free_recur_list (list); - } - - 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; -} - -static void -local_record_from_uid (ECalLocalRecord *local, - const char *uid, - ECalConduitContext *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_EVENT); - cal_component_set_uid (comp, uid); - local_record_from_comp (local, comp, ctxt); - } else { - INFO ("Object did not exist"); - } -} - -static CalComponent * -comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, - GnomePilotRecord *remote, - CalComponent *in_comp) -{ - CalComponent *comp; - struct Appointment appt; - struct icaltimetype now = icaltime_from_timet (time (NULL), FALSE, TRUE), it; - struct icalrecurrencetype recur; - int pos, i; - CalComponentText summary = {NULL, NULL}; - CalComponentDateTime dt = {NULL, NULL}; - char *txt; - - g_return_val_if_fail (remote != NULL, NULL); - - memset (&appt, 0, sizeof (struct Appointment)); - unpack_Appointment (&appt, remote->record, remote->length); - - if (in_comp == NULL) { - comp = cal_component_new (); - cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT); - cal_component_set_created (comp, &now); - } else { - comp = cal_component_clone (in_comp); - } - - cal_component_set_last_modified (comp, &now); - - summary.value = txt = e_pilot_utf8_from_pchar (appt.description); - cal_component_set_summary (comp, &summary); - free (txt); - - /* The iCal description field */ - if (!appt.note) { - cal_component_set_comment_list (comp, NULL); - } else { - GSList l; - CalComponentText text; - - text.value = txt = e_pilot_utf8_from_pchar (appt.note); - text.altrep = NULL; - l.data = &text; - l.next = NULL; - - cal_component_set_description_list (comp, &l); - free (txt); - } - - if (!is_empty_time (appt.begin)) { - it = icaltime_from_timet (mktime (&appt.begin), FALSE, TRUE); - dt.value = ⁢ - cal_component_set_dtstart (comp, &dt); - } - - if (appt.event) { - time_t t = mktime (&appt.begin); - - t = time_day_end (t); - it = icaltime_from_timet (t, FALSE, TRUE); - dt.value = ⁢ - cal_component_set_dtend (comp, &dt); - } else if (!is_empty_time (appt.end)) { - it = icaltime_from_timet (mktime (&appt.end), FALSE, TRUE); - dt.value = ⁢ - cal_component_set_dtend (comp, &dt); - } - - /* Recurrence information */ - icalrecurrencetype_clear (&recur); - - switch (appt.repeatType) { - case repeatNone: - recur.freq = ICAL_NO_RECURRENCE; - break; - - case repeatDaily: - recur.freq = ICAL_DAILY_RECURRENCE; - recur.interval = appt.repeatFrequency; - break; - - case repeatWeekly: - recur.freq = ICAL_WEEKLY_RECURRENCE; - recur.interval = appt.repeatFrequency; - - pos = 0; - for (i = 0; i < 7; i++) { - if (appt.repeatDays[i]) - recur.by_day[pos++] = get_ical_day (i); - } - - break; - - case repeatMonthlyByDay: - recur.freq = ICAL_MONTHLY_RECURRENCE; - recur.interval = appt.repeatFrequency; - recur.by_day[0] = nth_weekday (appt.repeatDay / 5, get_ical_day (appt.repeatDay % 5 - 1)); - break; - - case repeatMonthlyByDate: - recur.freq = ICAL_MONTHLY_RECURRENCE; - recur.interval = appt.repeatFrequency; - recur.by_month_day[0] = appt.begin.tm_mday; - break; - - case repeatYearly: - recur.freq = ICAL_YEARLY_RECURRENCE; - recur.interval = appt.repeatFrequency; - break; - - default: - g_assert_not_reached (); - } - - if (recur.freq != ICAL_NO_RECURRENCE) { - GSList *list = NULL; - - /* recurrence start of week */ - recur.week_start = get_ical_day (appt.repeatWeekstart); - - if (!appt.repeatForever) { - time_t t = mktime (&appt.repeatEnd); - t = time_add_day (t, 1); - recur.until = icaltime_from_timet (t, FALSE, TRUE); - } - - list = g_slist_append (list, &recur); - cal_component_set_rrule_list (comp, list); - g_slist_free (list); - } else { - cal_component_set_rrule_list (comp, NULL); - } - - cal_component_set_transparency (comp, CAL_COMPONENT_TRANSP_NONE); - - if (remote->attr & dlpRecAttrSecret) - cal_component_set_classification (comp, CAL_COMPONENT_CLASS_PRIVATE); - else - cal_component_set_classification (comp, CAL_COMPONENT_CLASS_PUBLIC); - - cal_component_commit_sequence (comp); - - free_Appointment (&appt); - - return comp; -} - -static void -update_comp (GnomePilotConduitSyncAbs *conduit, CalComponent *comp, - ECalConduitContext *ctxt) -{ - gboolean success; - - g_return_if_fail (conduit != NULL); - g_return_if_fail (comp != NULL); - - success = cal_client_update_object (ctxt->client, comp); - - if (!success) - WARN (_("Error while communicating with calendar server")); -} - -static void -check_for_slow_setting (GnomePilotConduit *c, ECalConduitContext *ctxt) -{ - int count, map_count; - - count = g_list_length (ctxt->uids); - map_count = g_hash_table_size (ctxt->map->pid_map); - - /* If there are no objects or objects but no log */ - if (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"); - } -} - -/* Pilot syncing callbacks */ -static gint -pre_sync (GnomePilotConduit *conduit, - GnomePilotDBInfo *dbi, - ECalConduitContext *ctxt) -{ - GnomePilotConduitSyncAbs *abs_conduit; - GList *l; - int len; - unsigned char *buf; - char *filename, *change_id; - gint num_records, add_records = 0, mod_records = 0, del_records = 0; - - abs_conduit = GNOME_PILOT_CONDUIT_SYNC_ABS (conduit); - - LOG ("---------------------------------------------------------\n"); - LOG ("pre_sync: Calendar Conduit v.%s", CONDUIT_VERSION); - g_message ("Calendar Conduit v.%s", CONDUIT_VERSION); - - ctxt->client = NULL; - - if (start_calendar_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 mapping */ - filename = map_name (ctxt); - e_pilot_map_read (filename, &ctxt->map); - g_free (filename); - - /* Get the local database */ - ctxt->uids = cal_client_get_uids (ctxt->client, CALOBJ_TYPE_EVENT); - - /* Find the added, modified and deleted items */ - change_id = g_strdup_printf ("pilot-sync-evolution-calendar-%d", ctxt->cfg->pilot_id); - ctxt->changed = cal_client_get_changes (ctxt->client, CALOBJ_TYPE_EVENT, change_id); - ctxt->changed_hash = g_hash_table_new (g_str_hash, g_str_equal); - - for (l = ctxt->changed; l != NULL; l = l->next) { - CalClientChange *ccc = l->data; - const char *uid; - - cal_component_get_uid (ccc->comp, &uid); - if (!e_pilot_map_uid_is_archived (ctxt->map, uid)) { - - g_hash_table_insert (ctxt->changed_hash, g_strdup (uid), ccc); - - switch (ccc->type) { - case CAL_CLIENT_CHANGE_ADDED: - add_records++; - break; - case CAL_CLIENT_CHANGE_MODIFIED: - mod_records++; - break; - case CAL_CLIENT_CHANGE_DELETED: - del_records++; - break; - } - } - } - - /* 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); - gnome_pilot_conduit_sync_abs_set_num_new_local_records (abs_conduit, add_records); - gnome_pilot_conduit_sync_abs_set_num_updated_local_records (abs_conduit, mod_records); - gnome_pilot_conduit_sync_abs_set_num_deleted_local_records(abs_conduit, del_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 Calendar application block")); - WARN ("dlp_ReadAppBlock(...) = %d", len); - gnome_pilot_conduit_error (conduit, - _("Could not read pilot's Calendar application block")); - return -1; - } - unpack_AppointmentAppInfo (&(ctxt->ai), buf, len); - g_free (buf); - - check_for_slow_setting (conduit, ctxt); - - return 0; -} - -static gint -post_sync (GnomePilotConduit *conduit, - GnomePilotDBInfo *dbi, - ECalConduitContext *ctxt) -{ - GList *changed; - gchar *filename, *change_id; - - LOG ("post_sync: Calendar Conduit v.%s", CONDUIT_VERSION); - LOG ("---------------------------------------------------------\n"); - - filename = map_name (ctxt); - e_pilot_map_write (filename, ctxt->map); - g_free (filename); - - /* FIX ME ugly hack - our changes musn't count, this does introduce - * a race condition if anyone changes a record elsewhere during sycnc - */ - change_id = g_strdup_printf ("pilot-sync-evolution-calendar-%d", ctxt->cfg->pilot_id); - changed = cal_client_get_changes (ctxt->client, CALOBJ_TYPE_EVENT, change_id); - cal_client_change_list_free (changed); - - return 0; -} - -static gint -set_pilot_id (GnomePilotConduitSyncAbs *conduit, - ECalLocalRecord *local, - guint32 ID, - ECalConduitContext *ctxt) -{ - const char *uid; - - LOG ("set_pilot_id: setting to %d\n", ID); - - cal_component_get_uid (local->comp, &uid); - e_pilot_map_insert (ctxt->map, ID, uid, FALSE); - - return 0; -} - -static gint -set_status_cleared (GnomePilotConduitSyncAbs *conduit, - ECalLocalRecord *local, - ECalConduitContext *ctxt) -{ - const char *uid; - - LOG ("set_status_cleared: clearing status\n"); - - cal_component_get_uid (local->comp, &uid); - g_hash_table_remove (ctxt->changed_hash, uid); - - return 0; -} - -static gint -for_each (GnomePilotConduitSyncAbs *conduit, - ECalLocalRecord **local, - ECalConduitContext *ctxt) -{ - static GList *uids, *iterator; - static int count; - - g_return_val_if_fail (local != NULL, -1); - - if (*local == NULL) { - LOG ("beginning for_each"); - - uids = ctxt->uids; - count = 0; - - if (uids != NULL) { - LOG ("iterating over %d records", g_list_length (uids)); - - *local = g_new0 (ECalLocalRecord, 1); - local_record_from_uid (*local, uids->data, ctxt); - - iterator = uids; - } else { - LOG ("no events"); - (*local) = NULL; - return 0; - } - } else { - count++; - if (g_list_next (iterator)) { - iterator = g_list_next (iterator); - - *local = g_new0 (ECalLocalRecord, 1); - local_record_from_uid (*local, iterator->data, ctxt); - } else { - LOG ("for_each ending"); - - /* Tell the pilot the iteration is over */ - *local = NULL; - - return 0; - } - } - - return 0; -} - -static gint -for_each_modified (GnomePilotConduitSyncAbs *conduit, - ECalLocalRecord **local, - ECalConduitContext *ctxt) -{ - static GList *iterator; - static int count; - - g_return_val_if_fail (local != NULL, 0); - - if (*local == NULL) { - LOG ("beginning for_each_modified: beginning\n"); - - iterator = ctxt->changed; - - count = 0; - - LOG ("iterating over %d records", g_hash_table_size (ctxt->changed_hash)); - - iterator = next_changed_item (ctxt, iterator); - if (iterator != NULL) { - CalClientChange *ccc = iterator->data; - - LOG ("iterating over %d records", g_hash_table_size (ctxt->changed_hash)); - - *local = g_new0 (ECalLocalRecord, 1); - local_record_from_comp (*local, ccc->comp, ctxt); - } else { - LOG ("no events"); - - *local = NULL; - } - } else { - count++; - iterator = g_list_next (iterator); - if (iterator && (iterator = next_changed_item (ctxt, iterator))) { - CalClientChange *ccc = iterator->data; - - *local = g_new0 (ECalLocalRecord, 1); - local_record_from_comp (*local, ccc->comp, ctxt); - } else { - LOG ("for_each_modified ending"); - - /* Signal the iteration is over */ - *local = NULL; - } - } - - return 0; -} - -static gint -compare (GnomePilotConduitSyncAbs *conduit, - ECalLocalRecord *local, - GnomePilotRecord *remote, - ECalConduitContext *ctxt) -{ - /* used by the quick compare */ - GnomePilotRecord local_pilot; - int retval = 0; - - LOG ("compare: local=%s remote=%s...\n", - print_local (local), print_remote (remote)); - - g_return_val_if_fail (local!=NULL,-1); - g_return_val_if_fail (remote!=NULL,-1); - - local_pilot = local_record_to_pilot_record (local, ctxt); - - if (remote->length != local_pilot.length - || memcmp (local_pilot.record, remote->record, remote->length)) - retval = 1; - - if (retval == 0) - LOG (" equal"); - else - LOG (" not equal"); - - return retval; -} - -static gint -add_record (GnomePilotConduitSyncAbs *conduit, - GnomePilotRecord *remote, - ECalConduitContext *ctxt) -{ - CalComponent *comp; - const char *uid; - int retval = 0; - - g_return_val_if_fail (remote != NULL, -1); - - LOG ("add_record: adding %s to desktop\n", print_remote (remote)); - - comp = comp_from_remote_record (conduit, remote, NULL); - update_comp (conduit, comp, ctxt); - - cal_component_get_uid (comp, &uid); - - e_pilot_map_insert (ctxt->map, remote->ID, uid, FALSE); - - return retval; -} - -static gint -replace_record (GnomePilotConduitSyncAbs *conduit, - ECalLocalRecord *local, - GnomePilotRecord *remote, - ECalConduitContext *ctxt) -{ - CalComponent *new_comp; - int retval = 0; - - g_return_val_if_fail (remote != NULL, -1); - - LOG ("replace_record: replace %s with %s\n", - print_local (local), print_remote (remote)); - - new_comp = comp_from_remote_record (conduit, remote, local->comp); - gtk_object_unref (GTK_OBJECT (local->comp)); - local->comp = new_comp; - update_comp (conduit, local->comp, ctxt); - - return retval; -} - -static gint -delete_record (GnomePilotConduitSyncAbs *conduit, - ECalLocalRecord *local, - ECalConduitContext *ctxt) -{ - const char *uid; - - g_return_val_if_fail (local != NULL, -1); - g_assert (local->comp != NULL); - - cal_component_get_uid (local->comp, &uid); - - LOG ("delete_record: deleting %s\n", uid); - - cal_client_remove_object (ctxt->client, uid); - - return 0; -} - -static gint -archive_record (GnomePilotConduitSyncAbs *conduit, - ECalLocalRecord *local, - gboolean archive, - ECalConduitContext *ctxt) -{ - const char *uid; - int retval = 0; - - g_return_val_if_fail (local != NULL, -1); - - LOG ("archive_record: %s\n", archive ? "yes" : "no"); - - cal_component_get_uid (local->comp, &uid); - e_pilot_map_insert (ctxt->map, local->local.ID, uid, archive); - - return retval; -} - -static gint -match (GnomePilotConduitSyncAbs *conduit, - GnomePilotRecord *remote, - ECalLocalRecord **local, - ECalConduitContext *ctxt) -{ - const 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); - - *local = NULL; - uid = e_pilot_map_lookup_uid (ctxt->map, remote->ID); - - if (!uid) - return 0; - - LOG (" matched\n"); - - *local = g_new0 (ECalLocalRecord, 1); - local_record_from_uid (*local, uid, ctxt); - - return 0; -} - -static gint -free_match (GnomePilotConduitSyncAbs *conduit, - ECalLocalRecord *local, - ECalConduitContext *ctxt) -{ - LOG ("free_match: freeing\n"); - - g_return_val_if_fail (local != NULL, -1); - - gtk_object_unref (GTK_OBJECT (local->comp)); - g_free (local); - - return 0; -} - -static gint -prepare (GnomePilotConduitSyncAbs *conduit, - ECalLocalRecord *local, - GnomePilotRecord *remote, - ECalConduitContext *ctxt) -{ - LOG ("prepare: encoding local %s\n", print_local (local)); - - *remote = local_record_to_pilot_record (local, ctxt); - - return 0; -} - -static ORBit_MessageValidationResult -accept_all_cookies (CORBA_unsigned_long request_id, - CORBA_Principal *principal, - CORBA_char *operation) -{ - /* allow ALL cookies */ - return ORBIT_MESSAGE_ALLOW_ALL; -} - - -GnomePilotConduit * -conduit_get_gpilot_conduit (guint32 pilot_id) -{ - GtkObject *retval; - ECalConduitContext *ctxt; - - LOG ("in calendar's conduit_get_gpilot_conduit\n"); - - /* 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 ()) { - char *argv[ 1 ] = {"hi"}; - oaf_init (1, argv); - - if (bonobo_init (CORBA_OBJECT_NIL, - CORBA_OBJECT_NIL, - CORBA_OBJECT_NIL) == FALSE) - g_error (_("Could not initialize Bonobo")); - - ORBit_set_request_validation_handler (accept_all_cookies); - } - - retval = gnome_pilot_conduit_sync_abs_new ("DatebookDB", 0x64617465); - g_assert (retval != NULL); - - gnome_pilot_conduit_construct (GNOME_PILOT_CONDUIT (retval), - "e_calendar_conduit"); - - ctxt = e_calendar_context_new (pilot_id); - gtk_object_set_data (GTK_OBJECT (retval), "calconduit_context", 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, "set_status_cleared", (GtkSignalFunc) set_status_cleared, 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, "replace_record", (GtkSignalFunc) replace_record, ctxt); - gtk_signal_connect (retval, "delete_record", (GtkSignalFunc) delete_record, ctxt); - gtk_signal_connect (retval, "archive_record", (GtkSignalFunc) 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); - - return GNOME_PILOT_CONDUIT (retval); -} - -void -conduit_destroy_gpilot_conduit (GnomePilotConduit *conduit) -{ - GtkObject *obj = GTK_OBJECT (conduit); - ECalConduitContext *ctxt; - - ctxt = gtk_object_get_data (obj, "calconduit_context"); - e_calendar_context_destroy (ctxt); - - gtk_object_destroy (obj); -} diff --git a/calendar/conduits/calendar/calendar-conduit.h b/calendar/conduits/calendar/calendar-conduit.h deleted file mode 100644 index 3b998716a2..0000000000 --- a/calendar/conduits/calendar/calendar-conduit.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution calendar - Calendar 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. - */ - -#ifndef __CALENDAR_CONDUIT_H__ -#define __CALENDAR_CONDUIT_H__ - -#include <sys/types.h> -#include <fcntl.h> -#include <unistd.h> -#include <gnome.h> -#include <pi-datebook.h> -#include <gpilotd/gnome-pilot-conduit.h> -#include <gpilotd/gnome-pilot-conduit-sync-abs.h> -#include <cal-client/cal-client.h> -#include <e-pilot-map.h> - -/* This is the local record structure for the Evolution Calendar conduit. */ -typedef struct _ECalLocalRecord ECalLocalRecord; -struct _ECalLocalRecord { - /* 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. - */ - GnomePilotDesktopRecord local; - - /* The corresponding Comp object */ - CalComponent *comp; - - /* pilot-link todo structure */ - struct Appointment *appt; -}; - -/* This is the context for all the Evolution Calendar conduit methods. */ -typedef struct _ECalConduitContext ECalConduitContext; -struct _ECalConduitContext { - ECalConduitCfg *cfg; - - struct AppointmentAppInfo ai; - - CalClient *client; - char *calendar_file; - gboolean calendar_load_tried; - gboolean calendar_load_success; - - time_t since; - GList *uids; - GList *changed; - GHashTable *changed_hash; - - EPilotMap *map; -}; - -#endif __CALENDAR_CONDUIT_H__ - - - - - - diff --git a/calendar/conduits/calendar/e-calendar-conduit-control-applet.desktop b/calendar/conduits/calendar/e-calendar-conduit-control-applet.desktop deleted file mode 100644 index 51ee34d2bd..0000000000 --- a/calendar/conduits/calendar/e-calendar-conduit-control-applet.desktop +++ /dev/null @@ -1,19 +0,0 @@ -[Desktop Entry] -Name=Evolution Calendar conduit -Name[da]=Gnome kalender -Name[es]=Enlace con el calendario de Evolution -Name[fr]=Conduit Calendrier -Name[no]=GNOME kalender -Name[sv]=Kalenderkanal -Name[tr]=Takvim parçasý -Comment=Configure the GnomeCal conduit -Comment[da]=Konfigurér GnomeCal-komponent -Comment[es]=Configurar el enlace con GnomeCal -Comment[fr]=Configuration du conduit calendrier -Comment[no]=Konfigurér GnomeCal-komponent -Comment[sv]=Konfigurera GnomeCal-kanalen -Comment[tr]=GnomeCal takvim parçasý ayarlarý -Exec=e-calendar-conduit-control-applet --cap-id=1 -Terminal=0 -Type=Application -Icon=gnome-calendar-conduit.png diff --git a/calendar/conduits/calendar/e-calendar.conduit.in b/calendar/conduits/calendar/e-calendar.conduit.in deleted file mode 100644 index 6143978e8b..0000000000 --- a/calendar/conduits/calendar/e-calendar.conduit.in +++ /dev/null @@ -1,8 +0,0 @@ -<gnome-pilot-conduit version="1.0"> -<conduit id="e_calendar_conduit" type="shlib" location="@prefix@/lib/gnome-pilot/conduits/libecalendar_conduit.so"/> -<name value="ECalendar"/> -<conduit-attribute name="description" value="Synchronizes Calendar 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> diff --git a/calendar/conduits/todo/.cvsignore b/calendar/conduits/todo/.cvsignore deleted file mode 100644 index 6b94f92c38..0000000000 --- a/calendar/conduits/todo/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -Makefile.in -Makefile -.deps -.libs -*.lo -*.la -e-todo-conduit-control-applet -e-todo.conduit diff --git a/calendar/conduits/todo/Makefile.am b/calendar/conduits/todo/Makefile.am deleted file mode 100644 index b0df8e91a4..0000000000 --- a/calendar/conduits/todo/Makefile.am +++ /dev/null @@ -1,81 +0,0 @@ -INCLUDES = \ - -I$(top_srcdir) \ - -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) \ - $(PISOCK_INCLUDEDIR) \ - $(GNOME_PILOT_CFLAGS) - -# ToDo Capplet -bin_PROGRAMS = e-todo-conduit-control-applet - -e_todo_conduit_control_applet_SOURCES = todo-conduit-control-applet.c - -e_todo_conduit_control_applet_LDADD = \ - $(CAPPLET_LIBS) \ - $(GNOME_LIBDIR) \ - $(GNOME_PILOT_LIBS) \ - $(PISOCK_LIBDIR) $(PISOCK_LIBS) \ - $(GNOME_CAPPLET_LIBS) \ - $(BONOBO_VFS_GNOME_LIBS) \ - $(GNOME_XML_LIB) \ - $(GNOMEUI_LIBS) \ - $(INTLLIBS) - -# ToDo Conduit -e_todo_conduitsdir=$(libdir)/gnome-pilot/conduits -e_todo_conduits_LTLIBRARIES = libetodo_conduit.la - -libetodo_conduit_la_SOURCES = \ - todo-conduit.c \ - todo-conduit.h \ - todo-conduit-config.h - -libetodo_conduit_la_LIBADD = \ - $(top_builddir)/calendar/cal-client/libcal-client-static.la \ - $(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) \ - $(UNICODE_LIBS) \ - $(GNOME_LIBDIR) \ - $(GNOME_LIBS) - -e-todo.conduit: e-todo.conduit.in Makefile - sed -e 's^\@prefix\@^$(prefix)^g' < $(srcdir)/e-todo.conduit.in > e-todo.conduit.tmp \ - && mv e-todo.conduit.tmp e-todo.conduit - - -ccenterdir = $(datadir)/control-center -ccenterPalmPilotdir = $(ccenterdir)/Peripherals -ccenterConduitsdir = $(ccenterPalmPilotdir)/Conduits -ccenterConduits_DATA = e-todo-conduit-control-applet.desktop - -panelConduitsdir = $(datadir)/gnome/apps/Settings/Peripherals/Conduits -panelConduits_DATA = $(ccenterConduits_DATA) - -Conduitdir = $(datadir)/gnome-pilot/conduits/ -Conduit_DATA = e-todo.conduit - -EXTRA_DIST = \ - e-todo.conduit.in \ - $(ccenterConduits_DATA) - -install-data-local: - $(mkinstalldirs) $(ccenterConduitsdir) - $(mkinstalldirs) $(Conduitdir) - - - - - - - - - - - diff --git a/calendar/conduits/todo/e-todo-conduit-control-applet.desktop b/calendar/conduits/todo/e-todo-conduit-control-applet.desktop deleted file mode 100644 index 2d392f322b..0000000000 --- a/calendar/conduits/todo/e-todo-conduit-control-applet.desktop +++ /dev/null @@ -1,18 +0,0 @@ -[Desktop Entry] -Name=Evolution ToDo conduit -Name[da]=Udstående -Name[es]=Enlace con el componente `Por Hacer' de Evolution -Name[fr]=Conduit Evolution `A Faire' -Name[no]=Oppgaver -Name[sv]=Att göra-lista -Name[tr]=Yapýlacaklar parçasý -Comment=Configure the todo conduit -Comment[da]=Konfigurér Udstående -Comment[es]=Configurar el enlace con el componente `Por Hacer' -Comment[fr]=Configuration du conduit `A Faire' -Comment[no]=Konfigurér oppgavelisten -Comment[sv]=Konfigurerar att göra-listan -Comment[tr]=Yapýlacaklar parçasý ayarlarý -Exec=e-todo-conduit-control-applet --cap-id=1 -Terminal=0 -Type=Application diff --git a/calendar/conduits/todo/e-todo.conduit.in b/calendar/conduits/todo/e-todo.conduit.in deleted file mode 100644 index 40e6fd620c..0000000000 --- a/calendar/conduits/todo/e-todo.conduit.in +++ /dev/null @@ -1,8 +0,0 @@ -<gnome-pilot-conduit version="1.0"> -<conduit id="e_todo_conduit" type="shlib" location="@prefix@/lib/gnome-pilot/conduits/libetodo_conduit.so"/> -<name value="EToDo"/> -<conduit-attribute name="description" value="Synchronizes ToDo List 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> diff --git a/calendar/conduits/todo/todo-conduit-config.h b/calendar/conduits/todo/todo-conduit-config.h deleted file mode 100644 index fe7b1dbafa..0000000000 --- a/calendar/conduits/todo/todo-conduit-config.h +++ /dev/null @@ -1,120 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution calendar - ToDo Conduit Configuration - * - * 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 __TODO_CONDUIT_CONFIG_H__ -#define __TODO_CONDUIT_CONFIG_H__ - -#include <gnome.h> -#include <libgpilotdCM/gnome-pilot-conduit-management.h> -#include <libgpilotdCM/gnome-pilot-conduit-config.h> - -/* Configuration info */ -typedef struct _EToDoConduitCfg EToDoConduitCfg; -struct _EToDoConduitCfg { - gboolean open_secret; - guint32 pilot_id; - GnomePilotConduitSyncType sync_type; /* only used by capplet */ -}; - -#ifdef TODO_CONFIG_LOAD -/* Load the configuration data */ -static void -todoconduit_load_configuration (EToDoConduitCfg **c, guint32 pilot_id) -{ - gchar prefix[256]; - g_snprintf (prefix, 255, "/gnome-pilot.d/e-todo-conduit/Pilot_%u/", - pilot_id); - - *c = g_new0 (EToDoConduitCfg,1); - g_assert (*c != NULL); - - gnome_config_push_prefix (prefix); - (*c)->open_secret = gnome_config_get_bool ("open_secret=FALSE"); - - /* set in capplets main */ - (*c)->sync_type = GnomePilotConduitSyncTypeCustom; - gnome_config_pop_prefix (); - - (*c)->pilot_id = pilot_id; -} -#endif - -#ifdef TODO_CONFIG_SAVE -/* Saves the configuration data. */ -static void -todoconduit_save_configuration (EToDoConduitCfg *c) -{ - gchar prefix[256]; - - g_snprintf (prefix, 255, "/gnome-pilot.d/e-todo-conduit/Pilot_%u/", - c->pilot_id); - - 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 (); -} -#endif - -#ifdef TODO_CONFIG_DUPE -/* Creates a duplicate of the configuration data */ -static EToDoConduitCfg* -todoconduit_dupe_configuration (EToDoConduitCfg *c) -{ - EToDoConduitCfg *retval; - - g_return_val_if_fail (c != NULL, NULL); - - retval = g_new0 (EToDoConduitCfg, 1); - retval->sync_type = c->sync_type; - retval->open_secret = c->open_secret; - retval->pilot_id = c->pilot_id; - - return retval; -} -#endif - -#ifdef TODO_CONFIG_DESTROY -/* Destroy a configuration */ -static void -todoconduit_destroy_configuration (EToDoConduitCfg **c) -{ - g_return_if_fail (c != NULL); - g_return_if_fail (*c != NULL); - - g_free (*c); - *c = NULL; -} -#endif - -#endif __TODO_CONDUIT_CONFIG_H__ - - - - - - - diff --git a/calendar/conduits/todo/todo-conduit-control-applet.c b/calendar/conduits/todo/todo-conduit-control-applet.c deleted file mode 100644 index 7140522b55..0000000000 --- a/calendar/conduits/todo/todo-conduit-control-applet.c +++ /dev/null @@ -1,341 +0,0 @@ -/* -*- 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. - */ - -#include <pwd.h> -#include <sys/types.h> -#include <signal.h> -#include <gnome.h> - -#include <config.h> -#include <capplet-widget.h> - -#include <gpilotd/gnome-pilot-client.h> - -#define TODO_CONFIG_LOAD 1 -#define TODO_CONFIG_SAVE 1 -#define TODO_CONFIG_DUPE 1 -#define TODO_CONFIG_DESTROY 1 -#include <todo-conduit-config.h> -#undef TODO_CONFIG_LOAD -#undef TODO_CONFIG_SAVE -#undef TODO_CONFIG_DUPE -#undef TODO_CONFIG_DESTROY - -/* tell changes callbacks to ignore changes or not */ -static gboolean ignore_changes=FALSE; - -/* capplet widget */ -static GtkWidget *capplet=NULL; - -/* host/device/pilot configuration windows */ -GtkWidget *cfgOptionsWindow=NULL; -GtkWidget *cfgStateWindow=NULL; -GtkWidget *dialogWindow=NULL; - -gboolean activated,org_activation_state; -GnomePilotConduitManagement *conduit; -GnomePilotConduitConfig *conduit_config; -EToDoConduitCfg *origState = NULL; -EToDoConduitCfg *curState = NULL; - -static void doTrySettings(GtkWidget *widget, EToDoConduitCfg *c); -static void doRevertSettings(GtkWidget *widget, EToDoConduitCfg *c); -static void doSaveSettings(GtkWidget *widget, EToDoConduitCfg *c); - -static void setStateCfg (GtkWidget *w, EToDoConduitCfg *c); - -gint pilotId; -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. -*/ -static gchar* sync_options[] ={ N_("Disabled"), - N_("Synchronize"), - N_("Copy From Pilot"), - N_("Copy To Pilot"), - N_("Merge From Pilot"), - N_("Merge To Pilot")}; -#define SYNC_OPTIONS_COUNT 6 - -static void -doTrySettings (GtkWidget *widget, EToDoConduitCfg *c) -{ - if (c->sync_type != GnomePilotConduitSyncTypeCustom) - gnome_pilot_conduit_config_enable_with_first_sync (conduit_config, - c->sync_type, - c->sync_type, - TRUE); - else - gnome_pilot_conduit_config_disable (conduit_config); - - todoconduit_save_configuration (c); -} - -static void -doRevertSettings (GtkWidget *widget, EToDoConduitCfg *c) -{ - activated = org_activation_state; - *c = *origState; - setStateCfg (cfgStateWindow, c); - doTrySettings (widget, c); -} - -static void -doSaveSettings (GtkWidget *widget, EToDoConduitCfg *c) -{ - *origState = *c; - doTrySettings (widget, c); -} - - -static void -doHelp (GtkWidget *widget, gpointer data) -{ - GtkWidget *about; - const gchar *authors[] = { - _("JP Rosevear <jpr@helixcode.com>"), - "", _("Original Author:"), - _("Eskil Heyn Olsen <deity@eskil.dk>"), - NULL}; - - about = gnome_about_new ( - _("Evolution ToDo Conduit"), VERSION, - _("(C) 1998-2000 the Free Software Foundation and Helix Code"), - authors, - _("Configuration utility for the evolution todo conduit.\n"), - _("gnome-unknown.xpm")); - gtk_widget_show (about); - - return; -} - - -/* 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) -{ - GtkWidget *vbox, *table; - GtkWidget *label; - GtkWidget *optionMenu,*menuItem; - GtkMenu *menu; - gint i; - - vbox = gtk_vbox_new(FALSE, GNOME_PAD); - - table = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, GNOME_PAD); - - label = gtk_label_new(_("Synchronize Action")); - gtk_box_pack_start(GTK_BOX(table), label, FALSE, FALSE, GNOME_PAD); - - optionMenu=gtk_option_menu_new(); - gtk_object_set_data(GTK_OBJECT(vbox), "conduit_state", optionMenu); - menu = GTK_MENU(gtk_menu_new()); - - for (i=0; i<SYNC_OPTIONS_COUNT;i++) { - sync_options[i]=_(sync_options[i]); - menuItem = gtk_menu_item_new_with_label(sync_options[i]); - gtk_widget_show(menuItem); - gtk_signal_connect(GTK_OBJECT(menuItem),"activate", - GTK_SIGNAL_FUNC(activate_sync_type), - GINT_TO_POINTER(i)); - gtk_menu_append(menu,menuItem); - } - - gtk_option_menu_set_menu(GTK_OPTION_MENU(optionMenu),GTK_WIDGET(menu)); - gtk_box_pack_start(GTK_BOX(table), optionMenu, FALSE, FALSE, 0); - - return vbox; -} - - -static void -setStateCfg (GtkWidget *w, EToDoConduitCfg *c) -{ - GtkOptionMenu *optionMenu; - GtkMenu *menu; - - optionMenu = gtk_object_get_data (GTK_OBJECT(w), "conduit_state"); - g_assert (optionMenu != NULL); - menu = GTK_MENU (gtk_option_menu_get_menu (optionMenu)); - - ignore_changes = TRUE; - /* Here were are relying on the items in menu being the same - order as in GnomePilotConduitSyncType. */ - gtk_option_menu_set_history (optionMenu, (int) c->sync_type); - ignore_changes = FALSE; -} - -static void -pilot_capplet_setup(void) -{ - GtkWidget *frame, *table; - - capplet = capplet_widget_new(); - - table = gtk_table_new(1, 2, FALSE); - gtk_container_border_width(GTK_CONTAINER(table), GNOME_PAD); - gtk_container_add(GTK_CONTAINER(capplet), table); - - frame = gtk_frame_new(_("Conduit state")); - gtk_container_border_width(GTK_CONTAINER(frame), GNOME_PAD_SMALL); - gtk_table_attach_defaults(GTK_TABLE(table), frame, 0, 1, 0, 1); - cfgStateWindow = createStateCfgWindow(); - gtk_container_add(GTK_CONTAINER(frame), cfgStateWindow); - - gtk_signal_connect(GTK_OBJECT(capplet), "try", - GTK_SIGNAL_FUNC(doTrySettings), curState); - gtk_signal_connect(GTK_OBJECT(capplet), "revert", - GTK_SIGNAL_FUNC(doRevertSettings), curState); - gtk_signal_connect(GTK_OBJECT(capplet), "ok", - GTK_SIGNAL_FUNC(doSaveSettings), curState); - gtk_signal_connect(GTK_OBJECT(capplet), "help", - GTK_SIGNAL_FUNC(doHelp), NULL); - - - setStateCfg (cfgStateWindow, curState); - - gtk_widget_show_all (capplet); -} - - -static void -run_error_dialog(gchar *mesg,...) -{ - char tmp[80]; - va_list ap; - - va_start(ap,mesg); - vsnprintf(tmp,79,mesg,ap); - dialogWindow = gnome_message_box_new(mesg,GNOME_MESSAGE_BOX_ERROR,GNOME_STOCK_BUTTON_OK,NULL); - gnome_dialog_run_and_close(GNOME_DIALOG(dialogWindow)); - va_end(ap); -} - - -static gint -get_pilot_id_from_gpilotd() -{ - GList *pilots=NULL; - gint pilot; - int i,err; - - i=0; - /* we don't worry about leaking here, so pilots isn't freed */ - switch(err = gnome_pilot_client_get_pilots(gpc,&pilots)) { - case GPILOTD_OK: { - if(pilots) { - for(i=0;i<g_list_length(pilots);i++) { - g_message("pilot %d = \"%s\"",i,(gchar*)g_list_nth(pilots,i)->data); - } - if(i==0) { - run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first.")); - return -1; - } else { - gnome_pilot_client_get_pilot_id_by_name(gpc, - pilots->data, /* this is the first pilot */ - &pilot); - if(i>1) { - g_message("too many pilots..."); - /* need a choose here */ - } - return pilot; - } - } else { - run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first.")); - return -1; - } - break; - } - case GPILOTD_ERR_NOT_CONNECTED: - run_error_dialog(_("Not connected to the gnome-pilot daemon")); - return -1; - break; - default: - g_warning("gnome_pilot_client_get_pilot_ids(...) = %d",err); - run_error_dialog(_("An error occured when trying to fetch\npilot list from the gnome-pilot daemon")); - return -1; - break; - } -} - - -int -main (int argc, char *argv[]) -{ - g_log_set_always_fatal (G_LOG_LEVEL_ERROR | - G_LOG_LEVEL_CRITICAL | - G_LOG_LEVEL_WARNING); - - /* Init capplet */ - gnome_capplet_init ("Evolution ToDo conduit control applet", - NULL, argc, argv, - NULL, 0, NULL); - - /* 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 = gnome_pilot_conduit_management_new ("e_todo_conduit", GNOME_PILOT_CONDUIT_MGMT_ID); - if (conduit == NULL) - return -1; - - todoconduit_load_configuration (&origState, pilotId); - conduit_config = gnome_pilot_conduit_config_new (conduit, pilotId); - org_activation_state = activated = - gnome_pilot_conduit_config_is_enabled (conduit_config, - &origState->sync_type); - - curState = todoconduit_dupe_configuration (origState); - - pilot_capplet_setup (); - - /* Done setting up, now run main loop */ - capplet_gtk_main(); - - /* Clean up */ - gnome_pilot_conduit_management_destroy (conduit); - todoconduit_destroy_configuration (&origState); - todoconduit_destroy_configuration (&curState); - - return 0; -} diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c deleted file mode 100644 index d232b88173..0000000000 --- a/calendar/conduits/todo/todo-conduit.c +++ /dev/null @@ -1,1013 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution calendar - ToDo 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 <liboaf/liboaf.h> -#include <bonobo.h> -#include <cal-client/cal-client-types.h> -#include <cal-client/cal-client.h> -#include <cal-util/timeutil.h> -#include <pi-source.h> -#include <pi-socket.h> -#include <pi-file.h> -#include <pi-dlp.h> -#include <libical/src/libical/icaltypes.h> -#include <e-pilot-util.h> - -#define TODO_CONFIG_LOAD 1 -#define TODO_CONFIG_DESTROY 1 -#include <todo-conduit-config.h> -#undef TODO_CONFIG_LOAD -#undef TODO_CONFIG_DESTROY - -#include <todo-conduit.h> - -GnomePilotConduit * conduit_get_gpilot_conduit (guint32); -void conduit_destroy_gpilot_conduit (GnomePilotConduit*); - -#define CONDUIT_VERSION "0.1.4" -#ifdef G_LOG_DOMAIN -#undef G_LOG_DOMAIN -#endif -#define G_LOG_DOMAIN "etodoconduit" - -#define DEBUG_CALCONDUIT 1 -/* #undef DEBUG_CALCONDUIT */ - -#ifdef DEBUG_CALCONDUIT -#define LOG(e...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, e) -#else -#define LOG(e...) -#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) - -/* Debug routines */ -static char * -print_local (EToDoLocalRecord *local) -{ - static char buff[ 4096 ]; - - if (local == NULL) { - sprintf (buff, "[NULL]"); - return buff; - } - - if (local->todo && local->todo->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 ""; -} - -static char *print_remote (GnomePilotRecord *remote) -{ - static char buff[ 4096 ]; - struct ToDo todo; - - if (remote == NULL) { - sprintf (buff, "[NULL]"); - return buff; - } - - memset (&todo, 0, sizeof (struct ToDo)); - unpack_ToDo (&todo, remote->record, remote->length); - - 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 EToDoConduitContext * -e_todo_context_new (guint32 pilot_id) -{ - EToDoConduitContext *ctxt = g_new0 (EToDoConduitContext, 1); - - todoconduit_load_configuration (&ctxt->cfg, pilot_id); - - return ctxt; -} - -static void -e_todo_context_foreach_change (gpointer key, gpointer value, gpointer data) -{ - g_free (key); -} - -static void -e_todo_context_destroy (EToDoConduitContext *ctxt) -{ - g_return_if_fail (ctxt != NULL); - - if (ctxt->cfg != NULL) - todoconduit_destroy_configuration (&ctxt->cfg); - - if (ctxt->client != NULL) - gtk_object_unref (GTK_OBJECT (ctxt->client)); - - if (ctxt->calendar_file) - g_free (ctxt->calendar_file); - - if (ctxt->uids) - cal_obj_uid_list_free (ctxt->uids); - - if (ctxt->changed_hash) - g_hash_table_foreach (ctxt->changed_hash, e_todo_context_foreach_change, NULL); - - if (ctxt->changed) - cal_client_change_list_free (ctxt->changed); - - if (ctxt->map) - e_pilot_map_destroy (ctxt->map); - - g_free (ctxt); -} - -/* Calendar Server routines */ -static void -start_calendar_server_cb (GtkWidget *cal_client, - CalClientLoadStatus status, - EToDoConduitContext *ctxt) -{ - CalClient *client = CAL_CLIENT (cal_client); - - LOG (" entering start_calendar_server_load_cb, tried=%d\n", - ctxt->calendar_load_tried); - - if (status == CAL_CLIENT_LOAD_SUCCESS) { - ctxt->calendar_load_success = TRUE; - LOG (" success\n"); - gtk_main_quit (); /* end the sub event loop */ - } else { - if (ctxt->calendar_load_tried) { - LOG (" load and create of calendar failed\n"); - gtk_main_quit (); /* end the sub event loop */ - return; - } - - cal_client_create_calendar (client, ctxt->calendar_file); - ctxt->calendar_load_tried = TRUE; - } -} - -static int -start_calendar_server (EToDoConduitContext *ctxt) -{ - - g_return_val_if_fail (ctxt != NULL, -2); - - ctxt->client = cal_client_new (); - - /* FIX ME */ - ctxt->calendar_file = g_concat_dir_and_file (g_get_home_dir (), - "evolution/local/Calendar/calendar.ics"); - - gtk_signal_connect (GTK_OBJECT (ctxt->client), "cal_loaded", - start_calendar_server_cb, ctxt); - - LOG (" calling cal_client_load_calendar\n"); - cal_client_load_calendar (ctxt->client, ctxt->calendar_file); - - /* run a sub event loop to turn cal-client's async load - notification into a synchronous call */ - gtk_main (); - - if (ctxt->calendar_load_success) - return 0; - - return -1; -} - -/* Utility routines */ -static char * -map_name (EToDoConduitContext *ctxt) -{ - char *filename; - - filename = g_strdup_printf ("%s/evolution/local/Calendar/pilot-map-todo-%d.xml", g_get_home_dir (), ctxt->cfg->pilot_id); - - return filename; -} - -static gboolean -is_empty_time (struct tm time) -{ - if (time.tm_sec || time.tm_min || time.tm_hour - || time.tm_mday || time.tm_mon || time.tm_year) - return FALSE; - - return TRUE; -} - -static GList * -next_changed_item (EToDoConduitContext *ctxt, GList *changes) -{ - CalClientChange *ccc; - GList *l; - - for (l = changes; l != NULL; l = l->next) { - const char *uid; - - ccc = l->data; - - cal_component_get_uid (ccc->comp, &uid); - if (g_hash_table_lookup (ctxt->changed_hash, uid)) - return l; - } - - return NULL; -} - -static void -compute_status (EToDoConduitContext *ctxt, EToDoLocalRecord *local, const char *uid) -{ - CalClientChange *ccc; - - local->local.archived = FALSE; - local->local.secret = FALSE; - - ccc = g_hash_table_lookup (ctxt->changed_hash, uid); - - if (ccc == NULL) { - local->local.attr = GnomePilotRecordNothing; - return; - } - - switch (ccc->type) { - case CAL_CLIENT_CHANGE_ADDED: - local->local.attr = GnomePilotRecordNew; - break; - case CAL_CLIENT_CHANGE_MODIFIED: - local->local.attr = GnomePilotRecordModified; - break; - case CAL_CLIENT_CHANGE_DELETED: - local->local.attr = GnomePilotRecordDeleted; - break; - } -} - -static GnomePilotRecord -local_record_to_pilot_record (EToDoLocalRecord *local, - EToDoConduitContext *ctxt) -{ - GnomePilotRecord p; - - g_assert (local->comp != NULL); - g_assert (local->todo != NULL ); - - LOG ("local_record_to_pilot_record\n"); - - p.ID = local->local.ID; - p.category = 0; - p.attr = local->local.attr; - p.archived = local->local.archived; - p.secret = local->local.secret; - - /* Generate pilot record structure */ - p.record = g_new0 (char, 0xffff); - p.length = pack_ToDo (local->todo, p.record, 0xffff); - - return p; -} - -/* - * converts a CalComponent object to a EToDoLocalRecord - */ -static void -local_record_from_comp (EToDoLocalRecord *local, CalComponent *comp, EToDoConduitContext *ctxt) -{ - 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); - local->local.ID = e_pilot_map_lookup_pid (ctxt->map, 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 = e_pilot_utf8_to_pchar (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 = e_pilot_utf8_to_pchar (description->value); - else - local->todo->note = NULL; - } else { - local->todo->note = NULL; - } - - 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); - } - - 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; -} - -static void -local_record_from_uid (EToDoLocalRecord *local, - const char *uid, - EToDoConduitContext *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 CalComponent * -comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, - GnomePilotRecord *remote, - CalComponent *in_comp) -{ - CalComponent *comp; - struct ToDo todo; - struct icaltimetype now = icaltime_from_timet (time (NULL), FALSE, TRUE); - CalComponentText summary = {NULL, NULL}; - CalComponentDateTime dt = {NULL, NULL}; - struct icaltimetype due; - char *txt; - - 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); - } - - cal_component_set_last_modified (comp, &now); - - summary.value = txt = e_pilot_utf8_from_pchar (todo.description); - cal_component_set_summary (comp, &summary); - free (txt); - - /* The iCal description field */ - if (!todo.note) { - cal_component_set_comment_list (comp, NULL); - } else { - GSList l; - CalComponentText text; - - text.value = txt = e_pilot_utf8_from_pchar (todo.note); - text.altrep = NULL; - l.data = &text; - l.next = NULL; - - cal_component_set_description_list (comp, &l); - free (txt); - } - - if (todo.complete) { - int percent = 100; - cal_component_set_completed (comp, &now); - cal_component_set_percent (comp, &percent); - } - - if (!is_empty_time (todo.due)) { - due = icaltime_from_timet (mktime (&todo.due), FALSE, TRUE); - 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); - - if (remote->attr & dlpRecAttrSecret) - cal_component_set_classification (comp, CAL_COMPONENT_CLASS_PRIVATE); - else - cal_component_set_classification (comp, CAL_COMPONENT_CLASS_PUBLIC); - - cal_component_commit_sequence (comp); - - free_ToDo(&todo); - - return comp; -} - -static void -update_comp (GnomePilotConduitSyncAbs *conduit, CalComponent *comp, - EToDoConduitContext *ctxt) -{ - gboolean success; - - g_return_if_fail (conduit != NULL); - g_return_if_fail (comp != NULL); - - success = cal_client_update_object (ctxt->client, comp); - - if (!success) - WARN (_("Error while communicating with calendar server")); -} - -static void -check_for_slow_setting (GnomePilotConduit *c, EToDoConduitContext *ctxt) -{ - int count, map_count; - - count = g_list_length (ctxt->uids); - map_count = g_hash_table_size (ctxt->map->pid_map); - - /* If there are no objects or objects but no log */ - if (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"); - } -} - -/* Pilot syncing callbacks */ -static gint -pre_sync (GnomePilotConduit *conduit, - GnomePilotDBInfo *dbi, - EToDoConduitContext *ctxt) -{ - GnomePilotConduitSyncAbs *abs_conduit; - GList *l; - int len; - unsigned char *buf; - char *filename, *change_id; - gint num_records, add_records = 0, mod_records = 0, del_records = 0; - - abs_conduit = GNOME_PILOT_CONDUIT_SYNC_ABS (conduit); - - LOG ("---------------------------------------------------------\n"); - LOG ("pre_sync: ToDo Conduit v.%s", CONDUIT_VERSION); - g_message ("ToDo Conduit v.%s", CONDUIT_VERSION); - - ctxt->client = NULL; - - if (start_calendar_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 map */ - filename = map_name (ctxt); - e_pilot_map_read (filename, &ctxt->map); - g_free (filename); - - /* Get the local database */ - ctxt->uids = cal_client_get_uids (ctxt->client, CALOBJ_TYPE_TODO); - - /* Count and hash the changes */ - change_id = g_strdup_printf ("pilot-sync-evolution-todo-%d", ctxt->cfg->pilot_id); - ctxt->changed = cal_client_get_changes (ctxt->client, CALOBJ_TYPE_TODO, change_id); - ctxt->changed_hash = g_hash_table_new (g_str_hash, g_str_equal); - - for (l = ctxt->changed; l != NULL; l = l->next) { - CalClientChange *ccc = l->data; - const char *uid; - - cal_component_get_uid (ccc->comp, &uid); - if (!e_pilot_map_uid_is_archived (ctxt->map, uid)) { - - g_hash_table_insert (ctxt->changed_hash, g_strdup (uid), ccc); - - switch (ccc->type) { - case CAL_CLIENT_CHANGE_ADDED: - add_records++; - break; - case CAL_CLIENT_CHANGE_MODIFIED: - mod_records++; - break; - case CAL_CLIENT_CHANGE_DELETED: - del_records++; - break; - } - } - } - - /* 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); - gnome_pilot_conduit_sync_abs_set_num_new_local_records (abs_conduit, add_records); - gnome_pilot_conduit_sync_abs_set_num_updated_local_records (abs_conduit, mod_records); - gnome_pilot_conduit_sync_abs_set_num_deleted_local_records(abs_conduit, del_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 ToDo application block")); - WARN ("dlp_ReadAppBlock(...) = %d", len); - gnome_pilot_conduit_error (conduit, - _("Could not read pilot's ToDo application block")); - return -1; - } - unpack_ToDoAppInfo (&(ctxt->ai), buf, len); - g_free (buf); - - check_for_slow_setting (conduit, ctxt); - - return 0; -} - -static gint -post_sync (GnomePilotConduit *conduit, - GnomePilotDBInfo *dbi, - EToDoConduitContext *ctxt) -{ - GList *changed; - gchar *filename, *change_id; - - LOG ("post_sync: ToDo Conduit v.%s", CONDUIT_VERSION); - LOG ("---------------------------------------------------------\n"); - - filename = map_name (ctxt); - e_pilot_map_write (filename, ctxt->map); - g_free (filename); - - /* FIX ME ugly hack - our changes musn't count, this does introduce - * a race condition if anyone changes a record elsewhere during sycnc - */ - change_id = g_strdup_printf ("pilot-sync-evolution-todo-%d", ctxt->cfg->pilot_id); - changed = cal_client_get_changes (ctxt->client, CALOBJ_TYPE_TODO, change_id); - cal_client_change_list_free (changed); - - return 0; -} - -static gint -set_pilot_id (GnomePilotConduitSyncAbs *conduit, - EToDoLocalRecord *local, - guint32 ID, - EToDoConduitContext *ctxt) -{ - const char *uid; - - LOG ("set_pilot_id: setting to %d\n", ID); - - cal_component_get_uid (local->comp, &uid); - e_pilot_map_insert (ctxt->map, ID, uid, FALSE); - - return 0; -} - -static gint -set_status_cleared (GnomePilotConduitSyncAbs *conduit, - EToDoLocalRecord *local, - EToDoConduitContext *ctxt) -{ - const char *uid; - - LOG ("set_status_cleared: clearing status\n"); - - cal_component_get_uid (local->comp, &uid); - g_hash_table_remove (ctxt->changed_hash, uid); - - return 0; -} - -static gint -for_each (GnomePilotConduitSyncAbs *conduit, - EToDoLocalRecord **local, - EToDoConduitContext *ctxt) -{ - static GList *uids, *iterator; - static int count; - - g_return_val_if_fail (local != NULL, -1); - - if (*local == NULL) { - LOG ("beginning for_each"); - - uids = ctxt->uids; - count = 0; - - if (uids != NULL) { - LOG ("iterating over %d records", g_list_length (uids)); - - *local = g_new0 (EToDoLocalRecord, 1); - local_record_from_uid (*local, uids->data, ctxt); - - iterator = uids; - } else { - LOG ("no events"); - (*local) = NULL; - return 0; - } - } else { - count++; - if (g_list_next (iterator)) { - iterator = g_list_next (iterator); - - *local = g_new0 (EToDoLocalRecord, 1); - local_record_from_uid (*local, iterator->data, ctxt); - } else { - LOG ("for_each ending"); - - /* Tell the pilot the iteration is over */ - *local = NULL; - - return 0; - } - } - - return 0; -} - -static gint -for_each_modified (GnomePilotConduitSyncAbs *conduit, - EToDoLocalRecord **local, - EToDoConduitContext *ctxt) -{ - static GList *iterator; - static int count; - - g_return_val_if_fail (local != NULL, 0); - - if (*local == NULL) { - LOG ("beginning for_each_modified: beginning\n"); - - iterator = ctxt->changed; - - count = 0; - - LOG ("iterating over %d records", g_hash_table_size (ctxt->changed_hash)); - - iterator = next_changed_item (ctxt, iterator); - if (iterator != NULL) { - CalClientChange *ccc = iterator->data; - - LOG ("iterating over %d records", g_hash_table_size (ctxt->changed_hash)); - - *local = g_new0 (EToDoLocalRecord, 1); - local_record_from_comp (*local, ccc->comp, ctxt); - } else { - LOG ("no events"); - - *local = NULL; - } - } else { - count++; - iterator = g_list_next (iterator); - if (iterator && (iterator = next_changed_item (ctxt, iterator))) { - CalClientChange *ccc = iterator->data; - - *local = g_new0 (EToDoLocalRecord, 1); - local_record_from_comp (*local, ccc->comp, ctxt); - } else { - LOG ("for_each_modified ending"); - - /* Signal the iteration is over */ - *local = NULL; - } - } - - return 0; -} - -static gint -compare (GnomePilotConduitSyncAbs *conduit, - EToDoLocalRecord *local, - GnomePilotRecord *remote, - EToDoConduitContext *ctxt) -{ - /* used by the quick compare */ - GnomePilotRecord local_pilot; - int retval = 0; - - LOG ("compare: local=%s remote=%s...\n", - print_local (local), print_remote (remote)); - - g_return_val_if_fail (local!=NULL,-1); - g_return_val_if_fail (remote!=NULL,-1); - - local_pilot = local_record_to_pilot_record (local, ctxt); - - if (remote->length != local_pilot.length - || memcmp (local_pilot.record, remote->record, remote->length)) - retval = 1; - - if (retval == 0) - LOG (" equal"); - else - LOG (" not equal"); - - return retval; -} - -static gint -add_record (GnomePilotConduitSyncAbs *conduit, - GnomePilotRecord *remote, - EToDoConduitContext *ctxt) -{ - CalComponent *comp; - const char *uid; - int retval = 0; - - g_return_val_if_fail (remote != NULL, -1); - - LOG ("add_record: adding %s to desktop\n", print_remote (remote)); - - comp = comp_from_remote_record (conduit, remote, NULL); - update_comp (conduit, comp, ctxt); - - cal_component_get_uid (comp, &uid); - - e_pilot_map_insert (ctxt->map, remote->ID, uid, FALSE); - - return retval; -} - -static gint -replace_record (GnomePilotConduitSyncAbs *conduit, - EToDoLocalRecord *local, - GnomePilotRecord *remote, - EToDoConduitContext *ctxt) -{ - CalComponent *new_comp; - int retval = 0; - - g_return_val_if_fail (remote != NULL, -1); - - LOG ("replace_record: replace %s with %s\n", - print_local (local), print_remote (remote)); - - new_comp = comp_from_remote_record (conduit, remote, local->comp); - gtk_object_unref (GTK_OBJECT (local->comp)); - local->comp = new_comp; - update_comp (conduit, local->comp, ctxt); - - return retval; -} - -static gint -delete_record (GnomePilotConduitSyncAbs *conduit, - EToDoLocalRecord *local, - EToDoConduitContext *ctxt) -{ - const char *uid; - - g_return_val_if_fail (local != NULL, -1); - g_return_val_if_fail (local->comp != NULL, -1); - - cal_component_get_uid (local->comp, &uid); - - LOG ("delete_record: deleting %s\n", uid); - - cal_client_remove_object (ctxt->client, uid); - - return 0; -} - -static gint -archive_record (GnomePilotConduitSyncAbs *conduit, - EToDoLocalRecord *local, - gboolean archive, - EToDoConduitContext *ctxt) -{ - const char *uid; - int retval = 0; - - g_return_val_if_fail (local != NULL, -1); - - LOG ("archive_record: %s\n", archive ? "yes" : "no"); - - cal_component_get_uid (local->comp, &uid); - e_pilot_map_insert (ctxt->map, local->local.ID, uid, archive); - - return retval; -} - -static gint -match (GnomePilotConduitSyncAbs *conduit, - GnomePilotRecord *remote, - EToDoLocalRecord **local, - EToDoConduitContext *ctxt) -{ - const 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); - - *local = NULL; - uid = e_pilot_map_lookup_uid (ctxt->map, remote->ID); - - if (!uid) - return 0; - - LOG (" matched\n"); - - *local = g_new0 (EToDoLocalRecord, 1); - local_record_from_uid (*local, uid, ctxt); - - return 0; -} - -static gint -free_match (GnomePilotConduitSyncAbs *conduit, - EToDoLocalRecord *local, - EToDoConduitContext *ctxt) -{ - LOG ("free_match: freeing\n"); - - g_return_val_if_fail (local != NULL, -1); - - gtk_object_unref (GTK_OBJECT (local->comp)); - g_free (local); - - return 0; -} - -static gint -prepare (GnomePilotConduitSyncAbs *conduit, - EToDoLocalRecord *local, - GnomePilotRecord *remote, - EToDoConduitContext *ctxt) -{ - LOG ("prepare: encoding local %s\n", print_local (local)); - - *remote = local_record_to_pilot_record (local, ctxt); - - return 0; -} - -static ORBit_MessageValidationResult -accept_all_cookies (CORBA_unsigned_long request_id, - CORBA_Principal *principal, - CORBA_char *operation) -{ - /* allow ALL cookies */ - return ORBIT_MESSAGE_ALLOW_ALL; -} - - -GnomePilotConduit * -conduit_get_gpilot_conduit (guint32 pilot_id) -{ - GtkObject *retval; - EToDoConduitContext *ctxt; - - LOG ("in todo's conduit_get_gpilot_conduit\n"); - - /* 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 ()) { - char *argv[ 1 ] = {"hi"}; - oaf_init (1, argv); - - if (bonobo_init (CORBA_OBJECT_NIL, - CORBA_OBJECT_NIL, - CORBA_OBJECT_NIL) == FALSE) - g_error (_("Could not initialize Bonobo")); - - ORBit_set_request_validation_handler (accept_all_cookies); - } - - retval = gnome_pilot_conduit_sync_abs_new ("ToDoDB", 0x746F646F); - g_assert (retval != NULL); - - gnome_pilot_conduit_construct (GNOME_PILOT_CONDUIT (retval), - "e_todo_conduit"); - - ctxt = e_todo_context_new (pilot_id); - gtk_object_set_data (GTK_OBJECT (retval), "todoconduit_context", 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, "set_status_cleared", (GtkSignalFunc) set_status_cleared, 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, "replace_record", (GtkSignalFunc) replace_record, ctxt); - gtk_signal_connect (retval, "delete_record", (GtkSignalFunc) delete_record, ctxt); - gtk_signal_connect (retval, "archive_record", (GtkSignalFunc) 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); - - return GNOME_PILOT_CONDUIT (retval); -} - -void -conduit_destroy_gpilot_conduit (GnomePilotConduit *conduit) -{ - GtkObject *obj = GTK_OBJECT (conduit); - EToDoConduitContext *ctxt; - - ctxt = gtk_object_get_data (obj, "todoconduit_context"); - e_todo_context_destroy (ctxt); - - gtk_object_destroy (obj); -} diff --git a/calendar/conduits/todo/todo-conduit.h b/calendar/conduits/todo/todo-conduit.h deleted file mode 100644 index 80245b11b0..0000000000 --- a/calendar/conduits/todo/todo-conduit.h +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- 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 __TODO_CONDUIT_H__ -#define __TODO_CONDUIT_H__ - -#include <sys/types.h> -#include <fcntl.h> -#include <unistd.h> -#include <gnome.h> -#include <pi-todo.h> -#include <gpilotd/gnome-pilot-conduit.h> -#include <gpilotd/gnome-pilot-conduit-sync-abs.h> -#include <cal-client/cal-client.h> -#include <e-pilot-map.h> - -/* This is the local record structure for the Evolution ToDo conduit. */ -typedef struct _EToDoLocalRecord EToDoLocalRecord; -struct _EToDoLocalRecord { - /* 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. - */ - GnomePilotDesktopRecord local; - - /* The corresponding Comp object */ - CalComponent *comp; - - /* pilot-link todo structure */ - struct ToDo *todo; -}; - -/* This is the context for all the Evolution ToDo conduit methods. */ -typedef struct _EToDoConduitContext EToDoConduitContext; -struct _EToDoConduitContext { - EToDoConduitCfg *cfg; - - struct ToDoAppInfo ai; - - CalClient *client; - char *calendar_file; - gboolean calendar_load_tried; - gboolean calendar_load_success; - - GList *uids; - GList *changed; - GHashTable *changed_hash; - - EPilotMap *map; -}; - -#endif __TODO_CONDUIT_H__ - - - - - - |