diff options
author | JP Rosevear <jpr@ximian.com> | 2002-01-15 05:07:46 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2002-01-15 05:07:46 +0800 |
commit | 025b29282c5626ab6ba9b78c149e639c5d154cca (patch) | |
tree | c1c5c8b6525f1c873cfe9e35f267cc23f78c9663 /calendar/conduits | |
parent | 4e6779f2fd26ec5b1220b20a786e0dffc4bd0cbf (diff) | |
download | gsoc2013-evolution-025b29282c5626ab6ba9b78c149e639c5d154cca.tar gsoc2013-evolution-025b29282c5626ab6ba9b78c149e639c5d154cca.tar.gz gsoc2013-evolution-025b29282c5626ab6ba9b78c149e639c5d154cca.tar.bz2 gsoc2013-evolution-025b29282c5626ab6ba9b78c149e639c5d154cca.tar.lz gsoc2013-evolution-025b29282c5626ab6ba9b78c149e639c5d154cca.tar.xz gsoc2013-evolution-025b29282c5626ab6ba9b78c149e639c5d154cca.tar.zst gsoc2013-evolution-025b29282c5626ab6ba9b78c149e639c5d154cca.zip |
move all functions here, get rid of header files, use e-pilot-settings to
2002-01-14 JP Rosevear <jpr@ximian.com>
* conduits/calendar/calendar-conduit.c: move all functions here,
get rid of header files, use e-pilot-settings to display gui
* conduits/todo/todo-conduit.c: as above
svn path=/trunk/; revision=15322
Diffstat (limited to 'calendar/conduits')
-rw-r--r-- | calendar/conduits/calendar/Makefile.am | 4 | ||||
-rw-r--r-- | calendar/conduits/calendar/calendar-conduit-config.h | 135 | ||||
-rw-r--r-- | calendar/conduits/calendar/calendar-conduit.c | 327 | ||||
-rw-r--r-- | calendar/conduits/calendar/calendar-conduit.h | 79 | ||||
-rw-r--r-- | calendar/conduits/calendar/e-calendar.conduit.in | 2 | ||||
-rw-r--r-- | calendar/conduits/todo/Makefile.am | 4 | ||||
-rw-r--r-- | calendar/conduits/todo/e-todo.conduit.in | 2 | ||||
-rw-r--r-- | calendar/conduits/todo/todo-conduit-config.h | 129 | ||||
-rw-r--r-- | calendar/conduits/todo/todo-conduit.c | 315 | ||||
-rw-r--r-- | calendar/conduits/todo/todo-conduit.h | 73 |
10 files changed, 502 insertions, 568 deletions
diff --git a/calendar/conduits/calendar/Makefile.am b/calendar/conduits/calendar/Makefile.am index 2b9b8053a8..3cdbca5596 100644 --- a/calendar/conduits/calendar/Makefile.am +++ b/calendar/conduits/calendar/Makefile.am @@ -16,9 +16,7 @@ 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 + calendar-conduit.c libecalendar_conduit_la_LDFLAGS = -module -avoid-version libecalendar_conduit_la_LIBADD = \ diff --git a/calendar/conduits/calendar/calendar-conduit-config.h b/calendar/conduits/calendar/calendar-conduit-config.h deleted file mode 100644 index 4521612034..0000000000 --- a/calendar/conduits/calendar/calendar-conduit-config.h +++ /dev/null @@ -1,135 +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 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 a320e9bb8d..ec6a752b86 100644 --- a/calendar/conduits/calendar/calendar-conduit.c +++ b/calendar/conduits/calendar/calendar-conduit.c @@ -23,7 +23,6 @@ #include <config.h> -#include <liboaf/liboaf.h> #include <bonobo.h> #include <bonobo-conf/bonobo-config-database.h> #include <cal-client/cal-client-types.h> @@ -31,22 +30,16 @@ #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 <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 <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*); @@ -70,69 +63,156 @@ void conduit_destroy_gpilot_conduit (GnomePilotConduit*); #define PILOT_MAX_ADVANCE 99 -/* Debug routines */ -static char * -print_local (ECalLocalRecord *local) +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) { - static char buff[ 4096 ]; + gtk_object_unref (GTK_OBJECT (local->comp)); + free_Appointment (local->appt); + g_free (local->appt); + g_free (local); +} - if (local == NULL) { - sprintf (buff, "[NULL]"); - return buff; - } +/* Configuration */ +struct _ECalConduitCfg { + guint32 pilot_id; + GnomePilotConduitSyncType sync_type; - 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; - } + gboolean secret; + gchar *last_uri; +}; - return ""; +static ECalConduitCfg * +calconduit_load_configuration (guint32 pilot_id) +{ + 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); + + c->secret = gnome_config_get_bool ("secret=FALSE"); + c->last_uri = gnome_config_get_string ("last_uri"); + + gnome_config_pop_prefix (); + + return c; } -static char *print_remote (GnomePilotRecord *remote) +static void +calconduit_save_configuration (ECalConduitCfg *c) { - static char buff[ 4096 ]; - struct Appointment appt; + gchar prefix[256]; - if (remote == NULL) { - sprintf (buff, "[NULL]"); - return buff; - } + g_snprintf (prefix, 255, "/gnome-pilot.d/e-calendar-conduit/Pilot_%u/", c->pilot_id); + gnome_config_push_prefix (prefix); - memset (&appt, 0, sizeof (struct Appointment)); - unpack_Appointment (&appt, remote->record, remote->length); + gnome_config_set_bool ("secret", c->secret); + gnome_config_set_string ("last_uri", c->last_uri); - g_snprintf (buff, 4096, "[%ld %ld '%s' '%s']", - mktime (&appt.begin), - mktime (&appt.end), - appt.description ? - appt.description : "", - appt.note ? - appt.note : ""); + gnome_config_pop_prefix (); - free_Appointment (&appt); + gnome_config_sync (); + gnome_config_drop_all (); +} - return buff; +static ECalConduitCfg* +calconduit_dupe_configuration (ECalConduitCfg *c) +{ + ECalConduitCfg *retval; + + g_return_val_if_fail (c != NULL, NULL); + + 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; } -/* Context Routines */ +static void +calconduit_destroy_configuration (ECalConduitCfg *c) +{ + g_return_if_fail (c != NULL); + + g_free (c->last_uri); + g_free (c); +} + +/* 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; +}; + static ECalConduitContext * e_calendar_context_new (guint32 pilot_id) { - ECalConduitContext *ctxt = g_new0 (ECalConduitContext, 1); - - calconduit_load_configuration (&ctxt->cfg, pilot_id); + ECalConduitContext *ctxt; + 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->dbi = NULL; ctxt->client = NULL; + ctxt->timezone = NULL; ctxt->uids = NULL; - ctxt->changed_hash = NULL; ctxt->changed = NULL; + ctxt->changed_hash = NULL; ctxt->locals = NULL; ctxt->map = NULL; @@ -155,14 +235,17 @@ 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); @@ -170,17 +253,63 @@ e_calendar_context_destroy (ECalConduitContext *ctxt) if (ctxt->locals != NULL) { for (l = ctxt->locals; l != NULL; l = l->next) - free_local (l->data); + calconduit_destroy_record (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); - g_free (ctxt); + return buff; } /* Calendar Server routines */ @@ -505,15 +634,6 @@ 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) @@ -1505,7 +1625,7 @@ free_match (GnomePilotConduitSyncAbs *conduit, g_return_val_if_fail (local != NULL, -1); - free_local (local); + calconduit_destroy_record (local); return 0; } @@ -1523,6 +1643,58 @@ 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, @@ -1562,6 +1734,7 @@ 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); @@ -1582,6 +1755,12 @@ 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/calendar/calendar-conduit.h b/calendar/conduits/calendar/calendar-conduit.h deleted file mode 100644 index 9ea9f3ecac..0000000000 --- a/calendar/conduits/calendar/calendar-conduit.h +++ /dev/null @@ -1,79 +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 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 __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 <libical/src/libical/icaltime.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 appointment structure */ - struct Appointment *appt; -}; - -/* This is the context for all the Evolution Calendar conduit methods. */ -typedef struct _ECalConduitContext ECalConduitContext; -struct _ECalConduitContext { - ECalConduitCfg *cfg; - GnomePilotDBInfo *dbi; - - struct AppointmentAppInfo ai; - - CalClient *client; - - icaltimezone *timezone; - GList *uids; - GList *changed; - GHashTable *changed_hash; - GList *locals; - - EPilotMap *map; -}; - -#endif /* __CALENDAR_CONDUIT_H__ */ - - - - - - diff --git a/calendar/conduits/calendar/e-calendar.conduit.in b/calendar/conduits/calendar/e-calendar.conduit.in index 759a577501..e75d889234 100644 --- a/calendar/conduits/calendar/e-calendar.conduit.in +++ b/calendar/conduits/calendar/e-calendar.conduit.in @@ -4,6 +4,6 @@ <conduit-attribute name="description" value="Synchronizes Calendar with Evolution"/> <conduit-attribute name="default-synctype" value="synchronize"/> <conduit-attribute name="valid-synctypes" value="synchronize copy_from_pilot copy_to_pilot"/> - <conduit-attribute name="settings" value="FALSE"/> + <conduit-attribute name="settings" value="TRUE"/> <conduit-attribute name="icon" value="@datadir@/images/evolution/conduits/48_evo-calendar-conduit.png"/> </gnome-pilot-conduit> diff --git a/calendar/conduits/todo/Makefile.am b/calendar/conduits/todo/Makefile.am index a9f4e73eee..b5ccaf429f 100644 --- a/calendar/conduits/todo/Makefile.am +++ b/calendar/conduits/todo/Makefile.am @@ -16,9 +16,7 @@ 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 + todo-conduit.c libetodo_conduit_la_LDFLAGS = -module -avoid-version libetodo_conduit_la_LIBADD = \ diff --git a/calendar/conduits/todo/e-todo.conduit.in b/calendar/conduits/todo/e-todo.conduit.in index 0dea4d7ae2..a7bea27a8f 100644 --- a/calendar/conduits/todo/e-todo.conduit.in +++ b/calendar/conduits/todo/e-todo.conduit.in @@ -4,6 +4,6 @@ <conduit-attribute name="description" value="Synchronizes ToDo List with Evolution"/> <conduit-attribute name="default-synctype" value="synchronize"/> <conduit-attribute name="valid-synctypes" value="synchronize copy_from_pilot copy_to_pilot"/> - <conduit-attribute name="settings" value="FALSE"/> + <conduit-attribute name="settings" value="TRUE"/> <conduit-attribute name="icon" value="@datadir@/images/evolution/conduits/48_evo-todo-conduit.png"/> </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 3296cd47e3..0000000000 --- a/calendar/conduits/todo/todo-conduit-config.h +++ /dev/null @@ -1,129 +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 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 8b68110847..ec24707596 100644 --- a/calendar/conduits/todo/todo-conduit.c +++ b/calendar/conduits/todo/todo-conduit.c @@ -31,22 +31,17 @@ #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*); @@ -56,10 +51,10 @@ void conduit_destroy_gpilot_conduit (GnomePilotConduit*); #endif #define G_LOG_DOMAIN "etodoconduit" -#define DEBUG_CALCONDUIT 1 -/* #undef DEBUG_CALCONDUIT */ +#define DEBUG_TODOCONDUIT 1 +/* #undef DEBUG_TODOCONDUIT */ -#ifdef DEBUG_CALCONDUIT +#ifdef DEBUG_TODOCONDUIT #define LOG(e...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, e) #else #define LOG(e...) @@ -68,62 +63,137 @@ 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) -/* Debug routines */ -static char * -print_local (EToDoLocalRecord *local) +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) { - static char buff[ 4096 ]; + gtk_object_unref (GTK_OBJECT (local->comp)); + free_ToDo (local->todo); + g_free (local->todo); + g_free (local); +} - if (local == NULL) { - sprintf (buff, "[NULL]"); - return buff; - } +/* Configuration */ +struct _EToDoConduitCfg { + guint32 pilot_id; + GnomePilotConduitSyncType sync_type; - 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; - } + gboolean secret; + gchar *last_uri; +}; - return ""; +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)->secret = gnome_config_get_bool ("secret=FALSE"); + (*c)->last_uri = gnome_config_get_string ("last_uri"); + + gnome_config_pop_prefix (); } -static char *print_remote (GnomePilotRecord *remote) +static void +todoconduit_save_configuration (EToDoConduitCfg *c) { - static char buff[ 4096 ]; - struct ToDo todo; + gchar prefix[256]; - if (remote == NULL) { - sprintf (buff, "[NULL]"); - return buff; - } + g_snprintf (prefix, 255, "/gnome-pilot.d/e-todo-conduit/Pilot_%u/", + c->pilot_id); - memset (&todo, 0, sizeof (struct ToDo)); - unpack_ToDo (&todo, remote->record, remote->length); + 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 (); - 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 : ""); + gnome_config_sync (); + gnome_config_drop_all (); +} - free_ToDo (&todo); - - return buff; +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->secret = c->secret; + retval->last_uri = g_strdup (c->last_uri); + + return retval; } -/* Context Routines */ +static void +todoconduit_destroy_configuration (EToDoConduitCfg *c) +{ + g_return_if_fail (c != NULL); + + g_free (c->last_uri); + g_free (c); +} + +/* Context */ +struct _EToDoConduitContext { + EToDoConduitCfg *cfg; + GnomePilotDBInfo *dbi; + + EToDoConduitCfg *new_cfg; + GtkWidget *ps; + + struct ToDoAppInfo ai; + + CalClient *client; + + icaltimezone *timezone; + GList *uids; + GList *changed; + GHashTable *changed_hash; + GList *locals; + + EPilotMap *map; +}; + static EToDoConduitContext * e_todo_context_new (guint32 pilot_id) { @@ -157,7 +227,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)); @@ -172,7 +242,7 @@ e_todo_context_destroy (EToDoConduitContext *ctxt) if (ctxt->locals != NULL) { for (l = ctxt->locals; l != NULL; l = l->next) - free_local (l->data); + todoconduit_destroy_record (l->data); g_list_free (ctxt->locals); } @@ -185,6 +255,62 @@ 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, @@ -342,15 +468,6 @@ 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) @@ -1089,7 +1206,7 @@ free_match (GnomePilotConduitSyncAbs *conduit, g_return_val_if_fail (local != NULL, -1); - free_local (local); + todoconduit_destroy_record (local); return 0; } @@ -1107,6 +1224,58 @@ 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, @@ -1166,6 +1335,12 @@ 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.h b/calendar/conduits/todo/todo-conduit.h deleted file mode 100644 index d2b1193ffa..0000000000 --- a/calendar/conduits/todo/todo-conduit.h +++ /dev/null @@ -1,73 +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 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_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 <libical/src/libical/icaltime.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; - GnomePilotDBInfo *dbi; - - struct ToDoAppInfo ai; - - CalClient *client; - - icaltimezone *timezone; - GList *uids; - GList *changed; - GHashTable *changed_hash; - GList *locals; - - EPilotMap *map; -}; - -#endif /* __TODO_CONDUIT_H__ */ |