aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/conduit/address-conduit.c
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2002-01-17 01:31:05 +0800
committerJP Rosevear <jpr@src.gnome.org>2002-01-17 01:31:05 +0800
commitac62bd148595f30859871925e8c41d827c560485 (patch)
treed61c9510e54741e8df5721a62147f5352025f4de /addressbook/conduit/address-conduit.c
parentaf1b3098c28bbf1ce7cf64131c33ac578a01213b (diff)
downloadgsoc2013-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
Diffstat (limited to 'addressbook/conduit/address-conduit.c')
-rw-r--r--addressbook/conduit/address-conduit.c319
1 files changed, 249 insertions, 70 deletions
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);
}