diff options
Diffstat (limited to 'calendar/conduits')
-rw-r--r-- | calendar/conduits/calendar/calendar-conduit-config.h | 135 | ||||
-rw-r--r-- | calendar/conduits/calendar/calendar-conduit.c | 328 | ||||
-rw-r--r-- | calendar/conduits/todo/todo-conduit-config.h | 129 | ||||
-rw-r--r-- | calendar/conduits/todo/todo-conduit.c | 328 |
4 files changed, 410 insertions, 510 deletions
diff --git a/calendar/conduits/calendar/calendar-conduit-config.h b/calendar/conduits/calendar/calendar-conduit-config.h new file mode 100644 index 0000000000..4521612034 --- /dev/null +++ b/calendar/conduits/calendar/calendar-conduit-config.h @@ -0,0 +1,135 @@ +/* -*- 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 Ximian, Inc. + * + * Authors: Eskil Heyn Olsen <deity@eskil.dk> + * JP Rosevear <jpr@ximian.com> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * 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 { + guint32 pilot_id; + GnomePilotConduitSyncType sync_type; + + gboolean open_secret; + gchar *last_uri; +}; + +#ifdef CAL_CONFIG_LOAD +/* Loads the configuration data */ +static void +calconduit_load_configuration (ECalConduitCfg **c, guint32 pilot_id) +{ + GnomePilotConduitManagement *management; + GnomePilotConduitConfig *config; + gchar prefix[256]; + g_snprintf (prefix, 255, "/gnome-pilot.d/e-calendar-conduit/Pilot_%u/", + pilot_id); + + *c = g_new0 (ECalConduitCfg,1); + g_assert (*c != NULL); + + (*c)->pilot_id = pilot_id; + + management = gnome_pilot_conduit_management_new ("e_calendar_conduit", GNOME_PILOT_CONDUIT_MGMT_ID); + config = gnome_pilot_conduit_config_new (management, pilot_id); + if (!gnome_pilot_conduit_config_is_enabled (config, &(*c)->sync_type)) + (*c)->sync_type = GnomePilotConduitSyncTypeNotSet; + gtk_object_unref (GTK_OBJECT (config)); + gtk_object_unref (GTK_OBJECT (management)); + + /* Custom settings */ + gnome_config_push_prefix (prefix); + + (*c)->open_secret = gnome_config_get_bool ("open_secret=FALSE"); + (*c)->last_uri = gnome_config_get_string ("last_uri"); + + gnome_config_pop_prefix (); +} +#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-calendar-conduit/Pilot_%u/", + c->pilot_id); + + gnome_config_push_prefix (prefix); + gnome_config_set_bool ("open_secret", c->open_secret); + gnome_config_set_string ("last_uri", c->last_uri); + 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->pilot_id = c->pilot_id; + + retval->open_secret = c->open_secret; + retval->last_uri = g_strdup (c->last_uri); + + 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)->last_uri); + g_free (*c); + *c = NULL; +} +#endif + +#endif /* __CAL_CONDUIT_CONFIG_H__ */ + + + + + + + diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c index f86e753232..a320e9bb8d 100644 --- a/calendar/conduits/calendar/calendar-conduit.c +++ b/calendar/conduits/calendar/calendar-conduit.c @@ -23,6 +23,7 @@ #include <config.h> +#include <liboaf/liboaf.h> #include <bonobo.h> #include <bonobo-conf/bonobo-config-database.h> #include <cal-client/cal-client-types.h> @@ -30,16 +31,22 @@ #include <cal-util/timeutil.h> #include <pi-source.h> #include <pi-socket.h> +#include <pi-file.h> #include <pi-dlp.h> -#include <pi-datebook.h> -#include <gpilotd/gnome-pilot-conduit.h> -#include <gpilotd/gnome-pilot-conduit-sync-abs.h> -#include <libgpilotdCM/gnome-pilot-conduit-management.h> -#include <libgpilotdCM/gnome-pilot-conduit-config.h> -#include <e-pilot-map.h> -#include <e-pilot-settings.h> +#include <libical/src/libical/icaltypes.h> #include <e-pilot-util.h> +#define CAL_CONFIG_LOAD 1 +#define CAL_CONFIG_SAVE 1 +#define CAL_CONFIG_DESTROY 1 +#include <calendar-conduit-config.h> +#undef CAL_CONFIG_LOAD +#undef CAL_CONFIG_SAVE +#undef CAL_CONFIG_DESTROY + +#include <calendar-conduit.h> + +static void free_local (ECalLocalRecord *local); GnomePilotConduit * conduit_get_gpilot_conduit (guint32); void conduit_destroy_gpilot_conduit (GnomePilotConduit*); @@ -63,157 +70,69 @@ void conduit_destroy_gpilot_conduit (GnomePilotConduit*); #define PILOT_MAX_ADVANCE 99 -typedef struct _ECalLocalRecord ECalLocalRecord; -typedef struct _ECalConduitCfg ECalConduitCfg; -typedef struct _ECalConduitContext ECalConduitContext; - -/* Local Record */ -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 appointment structure */ - struct Appointment *appt; -}; - -static void -calconduit_destroy_record (ECalLocalRecord *local) -{ - gtk_object_unref (GTK_OBJECT (local->comp)); - free_Appointment (local->appt); - g_free (local->appt); - g_free (local); -} - -/* Configuration */ -struct _ECalConduitCfg { - guint32 pilot_id; - GnomePilotConduitSyncType sync_type; - - gboolean secret; - gchar *last_uri; -}; - -static ECalConduitCfg * -calconduit_load_configuration (guint32 pilot_id) +/* Debug routines */ +static char * +print_local (ECalLocalRecord *local) { - ECalConduitCfg *c; - GnomePilotConduitManagement *management; - GnomePilotConduitConfig *config; - gchar prefix[256]; - - c = g_new0 (ECalConduitCfg, 1); - g_assert (c != NULL); - - /* Pilot ID */ - c->pilot_id = pilot_id; - - /* Sync Type */ - management = gnome_pilot_conduit_management_new ("e_calendar_conduit", GNOME_PILOT_CONDUIT_MGMT_ID); - config = gnome_pilot_conduit_config_new (management, pilot_id); - if (!gnome_pilot_conduit_config_is_enabled (config, &c->sync_type)) - c->sync_type = GnomePilotConduitSyncTypeNotSet; - gtk_object_unref (GTK_OBJECT (config)); - gtk_object_unref (GTK_OBJECT (management)); - - /* Custom settings */ - g_snprintf (prefix, 255, "/gnome-pilot.d/e-calendar-conduit/Pilot_%u/", pilot_id); - gnome_config_push_prefix (prefix); + static char buff[ 4096 ]; - c->secret = gnome_config_get_bool ("secret=FALSE"); - c->last_uri = gnome_config_get_string ("last_uri"); + if (local == NULL) { + sprintf (buff, "[NULL]"); + return buff; + } - gnome_config_pop_prefix (); + if (local->appt && local->appt->description) { + g_snprintf (buff, 4096, "[%ld %ld '%s' '%s']", + mktime (&local->appt->begin), + mktime (&local->appt->end), + local->appt->description ? + local->appt->description : "", + local->appt->note ? + local->appt->note : ""); + return buff; + } - return c; + return ""; } -static void -calconduit_save_configuration (ECalConduitCfg *c) +static char *print_remote (GnomePilotRecord *remote) { - gchar prefix[256]; - - g_snprintf (prefix, 255, "/gnome-pilot.d/e-calendar-conduit/Pilot_%u/", c->pilot_id); - gnome_config_push_prefix (prefix); - - gnome_config_set_bool ("secret", c->secret); - gnome_config_set_string ("last_uri", c->last_uri); - - gnome_config_pop_prefix (); - - gnome_config_sync (); - gnome_config_drop_all (); -} + static char buff[ 4096 ]; + struct Appointment appt; -static ECalConduitCfg* -calconduit_dupe_configuration (ECalConduitCfg *c) -{ - ECalConduitCfg *retval; + if (remote == NULL) { + sprintf (buff, "[NULL]"); + return buff; + } - g_return_val_if_fail (c != NULL, NULL); + memset (&appt, 0, sizeof (struct Appointment)); + unpack_Appointment (&appt, remote->record, remote->length); - retval = g_new0 (ECalConduitCfg, 1); - retval->pilot_id = c->pilot_id; - retval->sync_type = c->sync_type; - retval->secret = c->secret; - retval->last_uri = g_strdup (c->last_uri); - - return retval; -} + g_snprintf (buff, 4096, "[%ld %ld '%s' '%s']", + mktime (&appt.begin), + mktime (&appt.end), + appt.description ? + appt.description : "", + appt.note ? + appt.note : ""); -static void -calconduit_destroy_configuration (ECalConduitCfg *c) -{ - g_return_if_fail (c != NULL); + free_Appointment (&appt); - g_free (c->last_uri); - g_free (c); + return buff; } -/* Context */ -struct _ECalConduitContext { - ECalConduitCfg *cfg; - GnomePilotDBInfo *dbi; - - ECalConduitCfg *new_cfg; - GtkWidget *ps; - - struct AppointmentAppInfo ai; - - CalClient *client; - - icaltimezone *timezone; - GList *uids; - GList *changed; - GHashTable *changed_hash; - GList *locals; - - EPilotMap *map; -}; - +/* Context Routines */ static ECalConduitContext * e_calendar_context_new (guint32 pilot_id) { - ECalConduitContext *ctxt; + ECalConduitContext *ctxt = g_new0 (ECalConduitContext, 1); + + calconduit_load_configuration (&ctxt->cfg, pilot_id); - ctxt = g_new0 (ECalConduitContext, 1); - g_assert (ctxt != NULL); - - ctxt->cfg = calconduit_load_configuration (pilot_id); - ctxt->new_cfg = calconduit_dupe_configuration (ctxt->cfg); - ctxt->ps = NULL; - ctxt->dbi = NULL; ctxt->client = NULL; - ctxt->timezone = NULL; ctxt->uids = NULL; - ctxt->changed = NULL; ctxt->changed_hash = NULL; + ctxt->changed = NULL; ctxt->locals = NULL; ctxt->map = NULL; @@ -236,17 +155,14 @@ e_calendar_context_destroy (ECalConduitContext *ctxt) g_return_if_fail (ctxt != NULL); if (ctxt->cfg != NULL) - calconduit_destroy_configuration (ctxt->cfg); + calconduit_destroy_configuration (&ctxt->cfg); if (ctxt->client != NULL) gtk_object_unref (GTK_OBJECT (ctxt->client)); - + if (ctxt->uids != NULL) cal_obj_uid_list_free (ctxt->uids); - - if (ctxt->changed != NULL) - cal_client_change_list_free (ctxt->changed); - + if (ctxt->changed_hash != NULL) { g_hash_table_foreach_remove (ctxt->changed_hash, e_calendar_context_foreach_change, NULL); g_hash_table_destroy (ctxt->changed_hash); @@ -254,63 +170,17 @@ e_calendar_context_destroy (ECalConduitContext *ctxt) if (ctxt->locals != NULL) { for (l = ctxt->locals; l != NULL; l = l->next) - calconduit_destroy_record (l->data); + free_local (l->data); g_list_free (ctxt->locals); } + + if (ctxt->changed != NULL) + cal_client_change_list_free (ctxt->changed); if (ctxt->map != NULL) e_pilot_map_destroy (ctxt->map); -} - -/* 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) { - g_snprintf (buff, 4096, "[%ld %ld '%s' '%s']", - mktime (&local->appt->begin), - mktime (&local->appt->end), - local->appt->description ? - local->appt->description : "", - local->appt->note ? - 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); - - g_snprintf (buff, 4096, "[%ld %ld '%s' '%s']", - mktime (&appt.begin), - mktime (&appt.end), - appt.description ? - appt.description : "", - appt.note ? - appt.note : ""); - - free_Appointment (&appt); - return buff; + g_free (ctxt); } /* Calendar Server routines */ @@ -635,6 +505,15 @@ compute_status (ECalConduitContext *ctxt, ECalLocalRecord *local, const char *ui } } +static void +free_local (ECalLocalRecord *local) +{ + gtk_object_unref (GTK_OBJECT (local->comp)); + free_Appointment (local->appt); + g_free (local->appt); + g_free (local); +} + static GnomePilotRecord local_record_to_pilot_record (ECalLocalRecord *local, ECalConduitContext *ctxt) @@ -1626,7 +1505,7 @@ free_match (GnomePilotConduitSyncAbs *conduit, g_return_val_if_fail (local != NULL, -1); - calconduit_destroy_record (local); + free_local (local); return 0; } @@ -1644,58 +1523,6 @@ prepare (GnomePilotConduitSyncAbs *conduit, return 0; } -/* Pilot Settings Callbacks */ -static void -fill_widgets (ECalConduitContext *ctxt) -{ - e_pilot_settings_set_secret (E_PILOT_SETTINGS (ctxt->ps), - ctxt->cfg->secret); -} - -static gint -create_settings_window (GnomePilotConduit *conduit, - GtkWidget *parent, - ECalConduitContext *ctxt) -{ - LOG ("create_settings_window"); - - ctxt->ps = e_pilot_settings_new (); - gtk_container_add (GTK_CONTAINER (parent), ctxt->ps); - gtk_widget_show (ctxt->ps); - - fill_widgets (ctxt); - - return 0; -} -static void -display_settings (GnomePilotConduit *conduit, ECalConduitContext *ctxt) -{ - LOG ("display_settings"); - - fill_widgets (ctxt); -} - -static void -save_settings (GnomePilotConduit *conduit, ECalConduitContext *ctxt) -{ - LOG ("save_settings"); - - ctxt->new_cfg->secret = - e_pilot_settings_get_secret (E_PILOT_SETTINGS (ctxt->ps)); - - calconduit_save_configuration (ctxt->new_cfg); -} - -static void -revert_settings (GnomePilotConduit *conduit, ECalConduitContext *ctxt) -{ - LOG ("revert_settings"); - - calconduit_save_configuration (ctxt->cfg); - calconduit_destroy_configuration (ctxt->new_cfg); - ctxt->new_cfg = calconduit_dupe_configuration (ctxt->cfg); -} - static ORBit_MessageValidationResult accept_all_cookies (CORBA_unsigned_long request_id, CORBA_Principal *principal, @@ -1735,7 +1562,6 @@ conduit_get_gpilot_conduit (guint32 pilot_id) ctxt = e_calendar_context_new (pilot_id); gtk_object_set_data (GTK_OBJECT (retval), "calconduit_context", ctxt); - /* Sync signals */ gtk_signal_connect (retval, "pre_sync", (GtkSignalFunc) pre_sync, ctxt); gtk_signal_connect (retval, "post_sync", (GtkSignalFunc) post_sync, ctxt); @@ -1756,12 +1582,6 @@ conduit_get_gpilot_conduit (guint32 pilot_id) gtk_signal_connect (retval, "prepare", (GtkSignalFunc) prepare, ctxt); - /* Gui Settings */ - gtk_signal_connect (retval, "create_settings_window", (GtkSignalFunc) create_settings_window, ctxt); - gtk_signal_connect (retval, "display_settings", (GtkSignalFunc) display_settings, ctxt); - gtk_signal_connect (retval, "save_settings", (GtkSignalFunc) save_settings, ctxt); - gtk_signal_connect (retval, "revert_settings", (GtkSignalFunc) revert_settings, ctxt); - return GNOME_PILOT_CONDUIT (retval); } diff --git a/calendar/conduits/todo/todo-conduit-config.h b/calendar/conduits/todo/todo-conduit-config.h new file mode 100644 index 0000000000..3296cd47e3 --- /dev/null +++ b/calendar/conduits/todo/todo-conduit-config.h @@ -0,0 +1,129 @@ +/* -*- 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 Ximian, Inc. + * + * Authors: Eskil Heyn Olsen <deity@eskil.dk> + * JP Rosevear <jpr@ximian.com> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * 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 { + guint32 pilot_id; + GnomePilotConduitSyncType sync_type; /* only used by capplet */ + + gboolean open_secret; + gchar *last_uri; +}; + +#ifdef TODO_CONFIG_LOAD +/* Load the configuration data */ +static void +todoconduit_load_configuration (EToDoConduitCfg **c, guint32 pilot_id) +{ + GnomePilotConduitManagement *management; + GnomePilotConduitConfig *config; + 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); + + (*c)->pilot_id = pilot_id; + + management = gnome_pilot_conduit_management_new ("e_todo_conduit", GNOME_PILOT_CONDUIT_MGMT_ID); + config = gnome_pilot_conduit_config_new (management, pilot_id); + if (!gnome_pilot_conduit_config_is_enabled (config, &(*c)->sync_type)) + (*c)->sync_type = GnomePilotConduitSyncTypeNotSet; + gtk_object_unref (GTK_OBJECT (config)); + gtk_object_unref (GTK_OBJECT (management)); + + /* Custom settings */ + gnome_config_push_prefix (prefix); + + (*c)->open_secret = gnome_config_get_bool ("open_secret=FALSE"); + (*c)->last_uri = gnome_config_get_string ("last_uri"); + + gnome_config_pop_prefix (); +} +#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_set_string ("last_uri", c->last_uri); + 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->pilot_id = c->pilot_id; + + retval->open_secret = c->open_secret; + retval->last_uri = g_strdup (c->last_uri); + + 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)->last_uri); + g_free (*c); + *c = NULL; +} +#endif + +#endif /* __TODO_CONDUIT_CONFIG_H__ */ + diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c index 0363a4e3ce..8b68110847 100644 --- a/calendar/conduits/todo/todo-conduit.c +++ b/calendar/conduits/todo/todo-conduit.c @@ -31,17 +31,22 @@ #include <cal-util/timeutil.h> #include <pi-source.h> #include <pi-socket.h> +#include <pi-file.h> #include <pi-dlp.h> -#include <pi-todo.h> #include <libical/src/libical/icaltypes.h> -#include <gpilotd/gnome-pilot-conduit.h> -#include <gpilotd/gnome-pilot-conduit-sync-abs.h> -#include <libgpilotdCM/gnome-pilot-conduit-management.h> -#include <libgpilotdCM/gnome-pilot-conduit-config.h> -#include <e-pilot-map.h> -#include <e-pilot-settings.h> #include <e-pilot-util.h> +#define TODO_CONFIG_LOAD 1 +#define TODO_CONFIG_SAVE 1 +#define TODO_CONFIG_DESTROY 1 +#include <todo-conduit-config.h> +#undef TODO_CONFIG_LOAD +#undef TODO_CONFIG_SAVE +#undef TODO_CONFIG_DESTROY + +#include <todo-conduit.h> + +static void free_local (EToDoLocalRecord *local); GnomePilotConduit * conduit_get_gpilot_conduit (guint32); void conduit_destroy_gpilot_conduit (GnomePilotConduit*); @@ -51,10 +56,10 @@ void conduit_destroy_gpilot_conduit (GnomePilotConduit*); #endif #define G_LOG_DOMAIN "etodoconduit" -#define DEBUG_TODOCONDUIT 1 -/* #undef DEBUG_TODOCONDUIT */ +#define DEBUG_CALCONDUIT 1 +/* #undef DEBUG_CALCONDUIT */ -#ifdef DEBUG_TODOCONDUIT +#ifdef DEBUG_CALCONDUIT #define LOG(e...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, e) #else #define LOG(e...) @@ -63,153 +68,69 @@ void conduit_destroy_gpilot_conduit (GnomePilotConduit*); #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) -typedef struct _EToDoLocalRecord EToDoLocalRecord; -typedef struct _EToDoConduitCfg EToDoConduitCfg; -typedef struct _EToDoConduitContext EToDoConduitContext; - -/* Local Record */ -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; -}; - -static void -todoconduit_destroy_record (EToDoLocalRecord *local) -{ - gtk_object_unref (GTK_OBJECT (local->comp)); - free_ToDo (local->todo); - g_free (local->todo); - g_free (local); -} - -/* Configuration */ -struct _EToDoConduitCfg { - guint32 pilot_id; - GnomePilotConduitSyncType sync_type; - - gboolean secret; - gint priority; - - gchar *last_uri; -}; - -static EToDoConduitCfg * -todoconduit_load_configuration (guint32 pilot_id) -{ - EToDoConduitCfg *c; - GnomePilotConduitManagement *management; - GnomePilotConduitConfig *config; - 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); - - c->pilot_id = pilot_id; - - management = gnome_pilot_conduit_management_new ("e_todo_conduit", GNOME_PILOT_CONDUIT_MGMT_ID); - config = gnome_pilot_conduit_config_new (management, pilot_id); - if (!gnome_pilot_conduit_config_is_enabled (config, &c->sync_type)) - c->sync_type = GnomePilotConduitSyncTypeNotSet; - gtk_object_unref (GTK_OBJECT (config)); - gtk_object_unref (GTK_OBJECT (management)); - - /* Custom settings */ - gnome_config_push_prefix (prefix); - - c->secret = gnome_config_get_bool ("secret=FALSE"); - c->priority = gnome_config_get_int ("priority=1"); - c->last_uri = gnome_config_get_string ("last_uri"); - - gnome_config_pop_prefix (); - - return c; -} - -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 ("secret", c->secret); - gnome_config_set_int ("priority", c->priority); - gnome_config_set_string ("last_uri", c->last_uri); - gnome_config_pop_prefix (); - - gnome_config_sync (); - gnome_config_drop_all (); -} - -static EToDoConduitCfg* -todoconduit_dupe_configuration (EToDoConduitCfg *c) +/* Debug routines */ +static char * +print_local (EToDoLocalRecord *local) { - EToDoConduitCfg *retval; - - g_return_val_if_fail (c != NULL, NULL); + static char buff[ 4096 ]; - retval = g_new0 (EToDoConduitCfg, 1); - retval->sync_type = c->sync_type; - retval->pilot_id = c->pilot_id; + if (local == NULL) { + sprintf (buff, "[NULL]"); + return buff; + } - retval->secret = c->secret; - retval->priority = c->priority; - retval->last_uri = g_strdup (c->last_uri); + if (local->todo && local->todo->description) { + g_snprintf (buff, 4096, "[%d %ld %d %d '%s' '%s']", + local->todo->indefinite, + mktime (& local->todo->due), + local->todo->priority, + local->todo->complete, + local->todo->description ? + local->todo->description : "", + local->todo->note ? + local->todo->note : ""); + return buff; + } - return retval; + return ""; } -static void -todoconduit_destroy_configuration (EToDoConduitCfg *c) +static char *print_remote (GnomePilotRecord *remote) { - g_return_if_fail (c != NULL); - - g_free (c->last_uri); - g_free (c); -} + static char buff[ 4096 ]; + struct ToDo todo; -/* Context */ -struct _EToDoConduitContext { - EToDoConduitCfg *cfg; - GnomePilotDBInfo *dbi; + if (remote == NULL) { + sprintf (buff, "[NULL]"); + return buff; + } - EToDoConduitCfg *new_cfg; - GtkWidget *ps; - - struct ToDoAppInfo ai; + memset (&todo, 0, sizeof (struct ToDo)); + unpack_ToDo (&todo, remote->record, remote->length); - CalClient *client; + g_snprintf (buff, 4096, "[%d %ld %d %d '%s' '%s']", + todo.indefinite, + mktime (&todo.due), + todo.priority, + todo.complete, + todo.description ? + todo.description : "", + todo.note ? + todo.note : ""); - icaltimezone *timezone; - GList *uids; - GList *changed; - GHashTable *changed_hash; - GList *locals; + free_ToDo (&todo); - EPilotMap *map; -}; + return buff; +} +/* Context Routines */ static EToDoConduitContext * e_todo_context_new (guint32 pilot_id) { EToDoConduitContext *ctxt = g_new0 (EToDoConduitContext, 1); - ctxt->cfg = todoconduit_load_configuration (pilot_id); - ctxt->new_cfg = todoconduit_dupe_configuration (ctxt->cfg); - ctxt->ps = NULL; + todoconduit_load_configuration (&ctxt->cfg, pilot_id); + ctxt->client = NULL; ctxt->uids = NULL; ctxt->changed_hash = NULL; @@ -236,7 +157,7 @@ e_todo_context_destroy (EToDoConduitContext *ctxt) g_return_if_fail (ctxt != NULL); if (ctxt->cfg != NULL) - todoconduit_destroy_configuration (ctxt->cfg); + todoconduit_destroy_configuration (&ctxt->cfg); if (ctxt->client != NULL) gtk_object_unref (GTK_OBJECT (ctxt->client)); @@ -251,7 +172,7 @@ e_todo_context_destroy (EToDoConduitContext *ctxt) if (ctxt->locals != NULL) { for (l = ctxt->locals; l != NULL; l = l->next) - todoconduit_destroy_record (l->data); + free_local (l->data); g_list_free (ctxt->locals); } @@ -264,62 +185,6 @@ e_todo_context_destroy (EToDoConduitContext *ctxt) g_free (ctxt); } -/* 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) { - g_snprintf (buff, 4096, "[%d %ld %d %d '%s' '%s']", - local->todo->indefinite, - mktime (& local->todo->due), - local->todo->priority, - local->todo->complete, - local->todo->description ? - local->todo->description : "", - local->todo->note ? - 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); - - g_snprintf (buff, 4096, "[%d %ld %d %d '%s' '%s']", - todo.indefinite, - mktime (&todo.due), - todo.priority, - todo.complete, - todo.description ? - todo.description : "", - todo.note ? - todo.note : ""); - - free_ToDo (&todo); - - return buff; -} - - /* Calendar Server routines */ static void start_calendar_server_cb (CalClient *cal_client, @@ -477,6 +342,15 @@ compute_status (EToDoConduitContext *ctxt, EToDoLocalRecord *local, const char * } } +static void +free_local (EToDoLocalRecord *local) +{ + gtk_object_unref (GTK_OBJECT (local->comp)); + free_ToDo (local->todo); + g_free (local->todo); + g_free (local); +} + static GnomePilotRecord local_record_to_pilot_record (EToDoLocalRecord *local, EToDoConduitContext *ctxt) @@ -1215,7 +1089,7 @@ free_match (GnomePilotConduitSyncAbs *conduit, g_return_val_if_fail (local != NULL, -1); - todoconduit_destroy_record (local); + free_local (local); return 0; } @@ -1233,58 +1107,6 @@ prepare (GnomePilotConduitSyncAbs *conduit, return 0; } -/* Pilot Settings Callbacks */ -static void -fill_widgets (EToDoConduitContext *ctxt) -{ - e_pilot_settings_set_secret (E_PILOT_SETTINGS (ctxt->ps), - ctxt->cfg->secret); -} - -static gint -create_settings_window (GnomePilotConduit *conduit, - GtkWidget *parent, - EToDoConduitContext *ctxt) -{ - LOG ("create_settings_window"); - - ctxt->ps = e_pilot_settings_new (); - gtk_container_add (GTK_CONTAINER (parent), ctxt->ps); - gtk_widget_show (ctxt->ps); - - fill_widgets (ctxt); - - return 0; -} -static void -display_settings (GnomePilotConduit *conduit, EToDoConduitContext *ctxt) -{ - LOG ("display_settings"); - - fill_widgets (ctxt); -} - -static void -save_settings (GnomePilotConduit *conduit, EToDoConduitContext *ctxt) -{ - LOG ("save_settings"); - - ctxt->new_cfg->secret = - e_pilot_settings_get_secret (E_PILOT_SETTINGS (ctxt->ps)); - - todoconduit_save_configuration (ctxt->new_cfg); -} - -static void -revert_settings (GnomePilotConduit *conduit, EToDoConduitContext *ctxt) -{ - LOG ("revert_settings"); - - todoconduit_save_configuration (ctxt->cfg); - todoconduit_destroy_configuration (ctxt->new_cfg); - ctxt->new_cfg = todoconduit_dupe_configuration (ctxt->cfg); -} - static ORBit_MessageValidationResult accept_all_cookies (CORBA_unsigned_long request_id, CORBA_Principal *principal, @@ -1344,12 +1166,6 @@ conduit_get_gpilot_conduit (guint32 pilot_id) gtk_signal_connect (retval, "prepare", (GtkSignalFunc) prepare, ctxt); - /* Gui Settings */ - gtk_signal_connect (retval, "create_settings_window", (GtkSignalFunc) create_settings_window, ctxt); - gtk_signal_connect (retval, "display_settings", (GtkSignalFunc) display_settings, ctxt); - gtk_signal_connect (retval, "save_settings", (GtkSignalFunc) save_settings, ctxt); - gtk_signal_connect (retval, "revert_settings", (GtkSignalFunc) revert_settings, ctxt); - return GNOME_PILOT_CONDUIT (retval); } |