diff options
author | JP Rosevear <jpr@ximian.com> | 2002-01-17 01:31:05 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2002-01-17 01:31:05 +0800 |
commit | ac62bd148595f30859871925e8c41d827c560485 (patch) | |
tree | d61c9510e54741e8df5721a62147f5352025f4de | |
parent | af1b3098c28bbf1ce7cf64131c33ac578a01213b (diff) | |
download | gsoc2013-evolution-ac62bd148595f30859871925e8c41d827c560485.tar.gz gsoc2013-evolution-ac62bd148595f30859871925e8c41d827c560485.tar.zst gsoc2013-evolution-ac62bd148595f30859871925e8c41d827c560485.zip |
move all functions here, get rid of header files, use e-pilot-settings to
2002-01-16 JP Rosevear <jpr@ximian.com>
* conduit/address-conduit.c: move all functions here, get rid of
header files, use e-pilot-settings to display gui
svn path=/trunk/; revision=15342
-rw-r--r-- | addressbook/ChangeLog | 5 | ||||
-rw-r--r-- | addressbook/conduit/Makefile.am | 4 | ||||
-rw-r--r-- | addressbook/conduit/address-conduit-config.h | 128 | ||||
-rw-r--r-- | addressbook/conduit/address-conduit.c | 319 | ||||
-rw-r--r-- | addressbook/conduit/address-conduit.h | 78 | ||||
-rw-r--r-- | addressbook/conduit/e-address.conduit.in | 2 |
6 files changed, 256 insertions, 280 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index cd90b65a92..ff4a55333e 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,8 @@ +2002-01-16 JP Rosevear <jpr@ximian.com> + + * conduit/address-conduit.c: move all functions here, get rid of + header files, use e-pilot-settings to display gui + 2002-01-15 JP Rosevear <jpr@ximian.com> * gui/component/select-names/select-names.glade: remove misleading diff --git a/addressbook/conduit/Makefile.am b/addressbook/conduit/Makefile.am index d382736b46..7d07d6bc96 100644 --- a/addressbook/conduit/Makefile.am +++ b/addressbook/conduit/Makefile.am @@ -14,9 +14,7 @@ e_address_conduitsdir=$(libdir)/gnome-pilot/conduits e_address_conduits_LTLIBRARIES = libeaddress_conduit.la libeaddress_conduit_la_SOURCES = \ - address-conduit.c \ - address-conduit.h \ - address-conduit-config.h + address-conduit.c libeaddress_conduit_la_LDFLAGS = -module -avoid-version libeaddress_conduit_la_LIBADD = \ diff --git a/addressbook/conduit/address-conduit-config.h b/addressbook/conduit/address-conduit-config.h deleted file mode 100644 index 2387f67ef3..0000000000 --- a/addressbook/conduit/address-conduit-config.h +++ /dev/null @@ -1,128 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution addressbook - Addressbook 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 __ADDR_CONDUIT_CONFIG_H__ -#define __ADDR_CONDUIT_CONFIG_H__ - -#include <gnome.h> -#include <libgpilotdCM/gnome-pilot-conduit-management.h> -#include <gpilotd/gnome-pilot-conduit.h> -#include <libgpilotdCM/gnome-pilot-conduit-config.h> - -/* Configuration info */ -typedef struct _EAddrConduitCfg EAddrConduitCfg; -struct _EAddrConduitCfg { - guint32 pilot_id; - GnomePilotConduitSyncType sync_type; - - gboolean open_secret; - gchar *last_uri; -}; - -#ifdef ADDR_CONFIG_LOAD -/* Loads the configuration data */ -static void -addrconduit_load_configuration (EAddrConduitCfg **c, guint32 pilot_id) -{ - GnomePilotConduitManagement *management; - GnomePilotConduitConfig *config; - gchar prefix[256]; - g_snprintf (prefix, 255, "/gnome-pilot.d/e-address-conduit/Pilot_%u/", - pilot_id); - - *c = g_new0 (EAddrConduitCfg,1); - g_assert (*c != NULL); - - (*c)->pilot_id = pilot_id; - management = gnome_pilot_conduit_management_new ("e_address_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 ADDR_CONFIG_SAVE -/* Saves the configuration data. */ -static void -addrconduit_save_configuration (EAddrConduitCfg *c) -{ - gchar prefix[256]; - - g_snprintf (prefix, 255, "/gnome-pilot.d/e-address-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 ADDR_CONFIG_DUPE -/* Creates a duplicate of the configuration data */ -static EAddrConduitCfg* -addrconduit_dupe_configuration (EAddrConduitCfg *c) -{ - EAddrConduitCfg *retval; - - g_return_val_if_fail (c != NULL, NULL); - - retval = g_new0 (EAddrConduitCfg, 1); - retval->sync_type = c->sync_type; - retval->open_secret = c->open_secret; - - retval->pilot_id = c->pilot_id; - retval->last_uri = g_strdup (c->last_uri); - - return retval; -} -#endif - -#ifdef ADDR_CONFIG_DESTROY -/* Destroy a configuration */ -static void -addrconduit_destroy_configuration (EAddrConduitCfg **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 /* __ADDR_CONDUIT_CONFIG_H__ */ diff --git a/addressbook/conduit/address-conduit.c b/addressbook/conduit/address-conduit.c index 3d6e3eca1f..cd7cb9918b 100644 --- a/addressbook/conduit/address-conduit.c +++ b/addressbook/conduit/address-conduit.c @@ -28,27 +28,22 @@ #include <gnome-xml/parser.h> #include <pi-source.h> #include <pi-socket.h> -#include <pi-file.h> #include <pi-dlp.h> +#include <pi-address.h> #include <ebook/e-book.h> #include <ebook/e-book-util.h> #include <ebook/e-card-types.h> #include <ebook/e-card-cursor.h> #include <ebook/e-card.h> #include <ebook/e-card-simple.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 ADDR_CONFIG_LOAD 1 -#define ADDR_CONFIG_SAVE 1 -#define ADDR_CONFIG_DESTROY 1 -#include "address-conduit-config.h" -#undef ADDR_CONFIG_LOAD -#undef ADDR_CONFIG_SAVE -#undef ADDR_CONFIG_DESTROY - -#include "address-conduit.h" - -static void free_local (EAddrLocalRecord *local); GnomePilotConduit * conduit_get_gpilot_conduit (guint32); void conduit_destroy_gpilot_conduit (GnomePilotConduit*); @@ -134,65 +129,149 @@ static int priority_label [] = { -1 }; -/* Debug routines */ -static char * -print_local (EAddrLocalRecord *local) +typedef struct _EAddrLocalRecord EAddrLocalRecord; +typedef struct _EAddrConduitCfg EAddrConduitCfg; +typedef struct _EAddrConduitContext EAddrConduitContext; + +/* Local Record */ +struct _EAddrLocalRecord { + /* The stuff from gnome-pilot-conduit-standard-abs.h + Must be first in the structure, or instances of this + structure cannot be used by gnome-pilot-conduit-standard-abs. + */ + GnomePilotDesktopRecord local; + + /* The corresponding ECard object */ + ECard *ecard; + + /* pilot-link address structure, used for implementing Transmit. */ + struct Address *addr; +}; + + +static void +addrconduit_destroy_record (EAddrLocalRecord *local) { - static char buff[ 4096 ]; + gtk_object_unref (GTK_OBJECT (local->ecard)); + free_Address (local->addr); + g_free (local->addr); + g_free (local); +} - if (local == NULL) { - sprintf (buff, "[NULL]"); - return buff; - } +/* Configuration */ +struct _EAddrConduitCfg { + guint32 pilot_id; + GnomePilotConduitSyncType sync_type; - if (local->addr) { - g_snprintf (buff, 4096, "['%s' '%s' '%s']", - local->addr->entry[entryLastname] ? - local->addr->entry[entryLastname] : "", - local->addr->entry[entryFirstname] ? - local->addr->entry[entryFirstname] : "", - local->addr->entry[entryCompany] ? - local->addr->entry[entryCompany] : ""); - return buff; - } + gboolean secret; + gchar *last_uri; +}; - return ""; +static EAddrConduitCfg * +addrconduit_load_configuration (guint32 pilot_id) +{ + EAddrConduitCfg *c; + GnomePilotConduitManagement *management; + GnomePilotConduitConfig *config; + gchar prefix[256]; + g_snprintf (prefix, 255, "/gnome-pilot.d/e-address-conduit/Pilot_%u/", + pilot_id); + + c = g_new0 (EAddrConduitCfg,1); + g_assert (c != NULL); + + c->pilot_id = pilot_id; + management = gnome_pilot_conduit_management_new ("e_address_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 (); + + return c; } -static char *print_remote (GnomePilotRecord *remote) +static void +addrconduit_save_configuration (EAddrConduitCfg *c) { - static char buff[ 4096 ]; - struct Address addr; + gchar prefix[256]; - if (remote == NULL) { - sprintf (buff, "[NULL]"); - return buff; - } + g_snprintf (prefix, 255, "/gnome-pilot.d/e-address-conduit/Pilot_%u/", + c->pilot_id); - memset (&addr, 0, sizeof (struct Address)); - unpack_Address (&addr, 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, "['%s' '%s' '%s']", - addr.entry[entryLastname] ? - addr.entry[entryLastname] : "", - addr.entry[entryFirstname] ? - addr.entry[entryFirstname] : "", - addr.entry[entryCompany] ? - addr.entry[entryCompany] : ""); + gnome_config_sync (); + gnome_config_drop_all (); +} - free_Address (&addr); +static EAddrConduitCfg* +addrconduit_dupe_configuration (EAddrConduitCfg *c) +{ + EAddrConduitCfg *retval; - return buff; + g_return_val_if_fail (c != NULL, NULL); + + retval = g_new0 (EAddrConduitCfg, 1); + retval->sync_type = c->sync_type; + retval->secret = c->secret; + + retval->pilot_id = c->pilot_id; + retval->last_uri = g_strdup (c->last_uri); + + return retval; } -/* Context Routines */ +static void +addrconduit_destroy_configuration (EAddrConduitCfg *c) +{ + g_return_if_fail (c != NULL); + + g_free (c->last_uri); + g_free (c); +} + +/* Context */ +struct _EAddrConduitContext { + EAddrConduitCfg *cfg; + GnomePilotDBInfo *dbi; + + EAddrConduitCfg *new_cfg; + GtkWidget *ps; + + struct AddressAppInfo ai; + + EBook *ebook; + GList *cards; + GList *changed; + GHashTable *changed_hash; + GList *locals; + + gboolean address_load_tried; + gboolean address_load_success; + + EPilotMap *map; +}; + static EAddrConduitContext * e_addr_context_new (guint32 pilot_id) { EAddrConduitContext *ctxt = g_new0 (EAddrConduitContext, 1); - addrconduit_load_configuration (&ctxt->cfg, pilot_id); - + ctxt->cfg = addrconduit_load_configuration (pilot_id); + ctxt->new_cfg = addrconduit_dupe_configuration (ctxt->cfg); + ctxt->ps = NULL; ctxt->ebook = NULL; ctxt->cards = NULL; ctxt->changed_hash = NULL; @@ -211,7 +290,7 @@ e_addr_context_destroy (EAddrConduitContext *ctxt) g_return_if_fail (ctxt != NULL); if (ctxt->cfg != NULL) - addrconduit_destroy_configuration (&ctxt->cfg); + addrconduit_destroy_configuration (ctxt->cfg); if (ctxt->ebook != NULL) gtk_object_unref (GTK_OBJECT (ctxt->ebook)); @@ -239,7 +318,7 @@ e_addr_context_destroy (EAddrConduitContext *ctxt) if (ctxt->locals != NULL) { for (l = ctxt->locals; l != NULL; l = l->next) - free_local (l->data); + addrconduit_destroy_record (l->data); g_list_free (ctxt->locals); } @@ -249,6 +328,57 @@ e_addr_context_destroy (EAddrConduitContext *ctxt) g_free (ctxt); } +/* Debug routines */ +static char * +print_local (EAddrLocalRecord *local) +{ + static char buff[ 4096 ]; + + if (local == NULL) { + sprintf (buff, "[NULL]"); + return buff; + } + + if (local->addr) { + g_snprintf (buff, 4096, "['%s' '%s' '%s']", + local->addr->entry[entryLastname] ? + local->addr->entry[entryLastname] : "", + local->addr->entry[entryFirstname] ? + local->addr->entry[entryFirstname] : "", + local->addr->entry[entryCompany] ? + local->addr->entry[entryCompany] : ""); + return buff; + } + + return ""; +} + +static char *print_remote (GnomePilotRecord *remote) +{ + static char buff[ 4096 ]; + struct Address addr; + + if (remote == NULL) { + sprintf (buff, "[NULL]"); + return buff; + } + + memset (&addr, 0, sizeof (struct Address)); + unpack_Address (&addr, remote->record, remote->length); + + g_snprintf (buff, 4096, "['%s' '%s' '%s']", + addr.entry[entryLastname] ? + addr.entry[entryLastname] : "", + addr.entry[entryFirstname] ? + addr.entry[entryFirstname] : "", + addr.entry[entryCompany] ? + addr.entry[entryCompany] : ""); + + free_Address (&addr); + + return buff; +} + /* Addressbok Server routines */ static void add_card_cb (EBook *ebook, EBookStatus status, const char *id, gpointer closure) @@ -617,15 +747,6 @@ compute_status (EAddrConduitContext *ctxt, EAddrLocalRecord *local, const char * } } -static void -free_local (EAddrLocalRecord *local) -{ - gtk_object_unref (GTK_OBJECT (local->ecard)); - free_Address (local->addr); - g_free (local->addr); - g_free (local); -} - static GnomePilotRecord local_record_to_pilot_record (EAddrLocalRecord *local, EAddrConduitContext *ctxt) @@ -689,16 +810,16 @@ local_record_from_ecard (EAddrLocalRecord *local, ECard *ecard, EAddrConduitCont memset (&addr, 0, sizeof (struct Address)); unpack_Address (&addr, record, 0xffff); for (i = 0; i < 5; i++) { - if (addr.entry[entryPhone1 + i]) - local->addr->entry[entryPhone1 + i] = - strdup (addr.entry[entryPhone1 + i]); +// if (addr.entry[entryPhone1 + i]) +// local->addr->entry[entryPhone1 + i] = +// strdup (addr.entry[entryPhone1 + i]); local->addr->phoneLabel[i] = addr.phoneLabel[i]; } local->addr->showPhone = addr.showPhone; for (i = 0; i < 4; i++) { - if (addr.entry[entryCustom1 + i]) - local->addr->entry[entryCustom1 + i] = - strdup (addr.entry[entryCustom1 + i]); +// if (addr.entry[entryCustom1 + i]) +// local->addr->entry[entryCustom1 + i] = +// strdup (addr.entry[entryCustom1 + i]); } free_Address (&addr); } @@ -1499,7 +1620,7 @@ free_match (GnomePilotConduitSyncAbs *conduit, g_return_val_if_fail (local != NULL, -1); - free_local (local); + addrconduit_destroy_record (local); return 0; } @@ -1517,6 +1638,58 @@ prepare (GnomePilotConduitSyncAbs *conduit, return 0; } +/* Pilot Settings Callbacks */ +static void +fill_widgets (EAddrConduitContext *ctxt) +{ + e_pilot_settings_set_secret (E_PILOT_SETTINGS (ctxt->ps), + ctxt->cfg->secret); +} + +static gint +create_settings_window (GnomePilotConduit *conduit, + GtkWidget *parent, + EAddrConduitContext *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, EAddrConduitContext *ctxt) +{ + LOG ("display_settings"); + + fill_widgets (ctxt); +} + +static void +save_settings (GnomePilotConduit *conduit, EAddrConduitContext *ctxt) +{ + LOG ("save_settings"); + + ctxt->new_cfg->secret = + e_pilot_settings_get_secret (E_PILOT_SETTINGS (ctxt->ps)); + + addrconduit_save_configuration (ctxt->new_cfg); +} + +static void +revert_settings (GnomePilotConduit *conduit, EAddrConduitContext *ctxt) +{ + LOG ("revert_settings"); + + addrconduit_save_configuration (ctxt->cfg); + addrconduit_destroy_configuration (ctxt->new_cfg); + ctxt->new_cfg = addrconduit_dupe_configuration (ctxt->cfg); +} + static ORBit_MessageValidationResult accept_all_cookies (CORBA_unsigned_long request_id, CORBA_Principal *principal, @@ -1576,6 +1749,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/addressbook/conduit/address-conduit.h b/addressbook/conduit/address-conduit.h deleted file mode 100644 index 999a60f12b..0000000000 --- a/addressbook/conduit/address-conduit.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution addressbook - Addressbook 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 __ADDR_CONDUIT_H__ -#define __ADDR_CONDUIT_H__ - -#include <sys/types.h> -#include <fcntl.h> -#include <unistd.h> -#include <gnome.h> -#include <pi-address.h> -#include <gpilotd/gnome-pilot-conduit.h> -#include <gpilotd/gnome-pilot-conduit-sync-abs.h> -#include <e-pilot-map.h> - -/* This is the local record structure for the Evolution Addressbook conduit. */ -typedef struct _EAddrLocalRecord EAddrLocalRecord; -struct _EAddrLocalRecord { - /* The stuff from gnome-pilot-conduit-standard-abs.h - Must be first in the structure, or instances of this - structure cannot be used by gnome-pilot-conduit-standard-abs. - */ - GnomePilotDesktopRecord local; - - /* The corresponding ECard object */ - ECard *ecard; - - /* pilot-link address structure, used for implementing Transmit. */ - struct Address *addr; -}; - -/* This is the context for all the GnomeCal conduit methods. */ -typedef struct _EAddrConduitContext EAddrConduitContext; -struct _EAddrConduitContext { - EAddrConduitCfg *cfg; - GnomePilotDBInfo *dbi; - - struct AddressAppInfo ai; - - EBook *ebook; - GList *cards; - GList *changed; - GHashTable *changed_hash; - GList *locals; - - gboolean address_load_tried; - gboolean address_load_success; - - EPilotMap *map; -}; - -#endif /* __ADDR_CONDUIT_H__ */ - - - - - - diff --git a/addressbook/conduit/e-address.conduit.in b/addressbook/conduit/e-address.conduit.in index ac5489b9aa..e5a5ab765e 100644 --- a/addressbook/conduit/e-address.conduit.in +++ b/addressbook/conduit/e-address.conduit.in @@ -4,6 +4,6 @@ <conduit-attribute name="description" value="Synchronizes Addressbook 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-address-conduit.png"/> </gnome-pilot-conduit> |