From 025b29282c5626ab6ba9b78c149e639c5d154cca Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Mon, 14 Jan 2002 21:07:46 +0000 Subject: move all functions here, get rid of header files, use e-pilot-settings to 2002-01-14 JP Rosevear * 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 --- calendar/conduits/todo/Makefile.am | 4 +- calendar/conduits/todo/e-todo.conduit.in | 2 +- calendar/conduits/todo/todo-conduit-config.h | 129 ----------- calendar/conduits/todo/todo-conduit.c | 315 +++++++++++++++++++++------ calendar/conduits/todo/todo-conduit.h | 73 ------- 5 files changed, 247 insertions(+), 276 deletions(-) delete mode 100644 calendar/conduits/todo/todo-conduit-config.h delete mode 100644 calendar/conduits/todo/todo-conduit.h (limited to 'calendar/conduits/todo') 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 @@ - + 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 - * JP Rosevear - * - * 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 -#include -#include - -/* 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 #include #include -#include #include +#include #include +#include +#include +#include +#include +#include +#include #include -#define TODO_CONFIG_LOAD 1 -#define TODO_CONFIG_SAVE 1 -#define TODO_CONFIG_DESTROY 1 -#include -#undef TODO_CONFIG_LOAD -#undef TODO_CONFIG_SAVE -#undef TODO_CONFIG_DESTROY - -#include - -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 - * JP Rosevear - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* 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__ */ -- cgit v1.2.3