aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-06-15 23:20:30 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-06-16 02:45:55 +0800
commit333897772f2cf3251915800aff2c836f02095c84 (patch)
tree6e5d9d2c81b0c1bdf3d3e941e09f2a724a2c56fe
parent3acb21484e8b93916641dcd0a9b13fed2488a1ef (diff)
downloadgsoc2013-evolution-333897772f2cf3251915800aff2c836f02095c84.tar
gsoc2013-evolution-333897772f2cf3251915800aff2c836f02095c84.tar.gz
gsoc2013-evolution-333897772f2cf3251915800aff2c836f02095c84.tar.bz2
gsoc2013-evolution-333897772f2cf3251915800aff2c836f02095c84.tar.lz
gsoc2013-evolution-333897772f2cf3251915800aff2c836f02095c84.tar.xz
gsoc2013-evolution-333897772f2cf3251915800aff2c836f02095c84.tar.zst
gsoc2013-evolution-333897772f2cf3251915800aff2c836f02095c84.zip
Remove gnome-pilot integration.
It just doesn't belong in Evolution anymore. We don't support syncing with more modern devices -- see Conduits or SyncEvolution for that -- so it does not make sense for older model Palm Pilot PDAs to be the lone exception. I have repackaged the Evolution-Data-Server conduit modules to be provided by gnome-pilot itself in bug #619315. This should provide eqivalent Palm Pilot syncing functionality; it's just being moved to gnome-pilot. This completely severs our dependency on deprecated GNOME 2.x libraries which were still being dragged in by way of gnome-pilot dependencies. It was also interfereing with our bundling of libgnomecanvas.
-rw-r--r--AUTHORS3
-rw-r--r--README18
-rw-r--r--addressbook/Makefile.am6
-rw-r--r--addressbook/conduit/Makefile.am40
-rw-r--r--addressbook/conduit/address-conduit.c2250
-rw-r--r--addressbook/conduit/e-address.conduit.in9
-rw-r--r--calendar/Makefile.am8
-rw-r--r--calendar/conduits/Makefile.am3
-rw-r--r--calendar/conduits/calendar/Makefile.am43
-rw-r--r--calendar/conduits/calendar/calendar-conduit.c2174
-rw-r--r--calendar/conduits/calendar/e-calendar.conduit.in9
-rw-r--r--calendar/conduits/common/Makefile.am24
-rw-r--r--calendar/conduits/common/libecalendar-common-conduit.c372
-rw-r--r--calendar/conduits/common/libecalendar-common-conduit.h36
-rw-r--r--calendar/conduits/memo/Makefile.am43
-rw-r--r--calendar/conduits/memo/e-memo.conduit.in8
-rw-r--r--calendar/conduits/memo/memo-conduit.c1442
-rw-r--r--calendar/conduits/todo/Makefile.am42
-rw-r--r--calendar/conduits/todo/e-todo.conduit.in9
-rw-r--r--calendar/conduits/todo/todo-conduit.c1634
-rw-r--r--configure.ac85
-rw-r--r--doc/reference/shell/tmpl/eshell-unused.sgml7
-rw-r--r--doc/reference/shell/tmpl/shell-actions.sgml8
-rw-r--r--e-util/Makefile.am54
-rw-r--r--e-util/e-pilot-map.c418
-rw-r--r--e-util/e-pilot-map.h60
-rw-r--r--e-util/e-pilot-util.c119
-rw-r--r--e-util/e-pilot-util.h38
-rwxr-xr-xevolution-zip.in2
-rw-r--r--m4/evo_pilot_link_check.m4117
-rw-r--r--po/POTFILES.in5
-rw-r--r--shell/e-shell-window-actions.c45
-rw-r--r--shell/e-shell-window-actions.h2
-rw-r--r--ui/evolution-shell.ui1
-rw-r--r--widgets/misc/Makefile.am16
-rw-r--r--widgets/misc/e-pilot-settings.c190
-rw-r--r--widgets/misc/e-pilot-settings.h72
37 files changed, 11 insertions, 9401 deletions
diff --git a/AUTHORS b/AUTHORS
index 75e6a26764..80633a8c61 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -42,9 +42,6 @@ Mailer
Notes
Anders Carlsson <andersca@gnu.org>
-Pilot
- JP Rosevear <jpr@ximian.com>
-
Shell
Miguel de Icaza <miguel@ximian.com>
Jason Leach <jleach@ximian.com>
diff --git a/README b/README
index 630339283c..d26b0f7c45 100644
--- a/README
+++ b/README
@@ -72,14 +72,6 @@ dependencies should be compiled in the order they are listed here):
Many distributions ship these as Mozilla development
packages.
- * [Optional] gnome-pilot 2.0 or later
-
- This is only necessary if you want to be able to synchronize
- your Palm device with Evolution.
-
- ftp://ftp.gnome.org/pub/gnome/sources/gnome-pilot
- ftp://ftp.gnome.org/pub/gnome/sources/gnome-pilot-conduits
-
* [Optional] gnome-spell 1.0.1 or later
This is only necessary if you want to have the spell
@@ -147,16 +139,6 @@ OPTIONAL FEATURES
Some optional features can be enabled at compilation time by passing
appropriate flags to the configure script:
- * GNOME Pilot support.
-
- Assuming you have installed gnome-pilot, add the following
- options:
-
- --with-pisock=<prefix> --enable-pilot-conduits=yes
-
- Where <prefix> is the location where pilot-link (a package
- that gnome-pilot depends on) was installed.
-
* SSL support.
Make sure you have Mozilla's NSS nad NSPR libraries
diff --git a/addressbook/Makefile.am b/addressbook/Makefile.am
index ca0916e74d..45802a5ffc 100644
--- a/addressbook/Makefile.am
+++ b/addressbook/Makefile.am
@@ -1,9 +1,5 @@
-if ENABLE_PILOT_CONDUITS
-CONDUIT_SUBDIR = conduit
-endif
-
-SUBDIRS = util printing importers gui tools $(CONDUIT_SUBDIR)
+SUBDIRS = util printing importers gui tools
error_DATA = addressbook.error
errordir = $(privdatadir)/errors
diff --git a/addressbook/conduit/Makefile.am b/addressbook/conduit/Makefile.am
deleted file mode 100644
index 3ac06da3e9..0000000000
--- a/addressbook/conduit/Makefile.am
+++ /dev/null
@@ -1,40 +0,0 @@
-# Address Conduit
-privconduit_LTLIBRARIES = libeaddress_conduit.la
-
-libeaddress_conduit_la_CPPFLAGS = \
- $(AM_CPPFLAGS) \
- -I$(top_srcdir)/e-util \
- -I$(top_builddir)/e-util \
- -I$(top_srcdir)/widgets/misc \
- -I$(top_builddir)/widgets/misc \
- $(EVOLUTION_ADDRESSBOOK_CONDUIT_CFLAGS)
-
-libeaddress_conduit_la_SOURCES = address-conduit.c
-
-libeaddress_conduit_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED)
-
-libeaddress_conduit_la_LIBADD = \
- $(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/e-util/libeconduit.la \
- $(top_builddir)/widgets/misc/libemiscwidgets.la \
- $(EVOLUTION_ADDRESSBOOK_CONDUIT_LIBS)
-
-e-address.conduit: e-address.conduit.in
- sed -e 's^\@privconduitdir\@^$(privconduitdir)^g' \
- -e 's^\@datadir\@^$(datadir)^g' \
- -e 's^\@BASE_VERSION\@^$(BASE_VERSION)^g' \
- $< > $@
-
-conduitdir = $(datadir)/gnome-pilot/conduits/
-conduit_DATA = e-address.conduit
-
-BUILT_SOURCES = $(conduit_DATA)
-CLEANFILES = $(BUILT_SOURCES)
-
-EXTRA_DIST = \
- e-address.conduit.in
-
-dist-hook:
- cd $(distdir); rm -f $(BUILT_SOURCES)
-
--include $(top_srcdir)/git.mk
diff --git a/addressbook/conduit/address-conduit.c b/addressbook/conduit/address-conduit.c
deleted file mode 100644
index 73fb68b0ee..0000000000
--- a/addressbook/conduit/address-conduit.c
+++ /dev/null
@@ -1,2250 +0,0 @@
-/*
- * Evolution addressbook - Address Conduit
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Eskil Heyn Olsen <deity@eskil.dk>
- * JP Rosevear <jpr@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#define G_LOG_DOMAIN "eaddrconduit"
-
-/* Work around deprecated API usage in GnomePilot. */
-#undef GTK_DISABLE_DEPRECATED
-#undef GTK_DISABLE_SINGLE_INCLUDES
-
-#include <glib/gi18n.h>
-#include <libxml/parser.h>
-#include <pi-source.h>
-#include <pi-socket.h>
-#include <pi-dlp.h>
-#include <pi-address.h>
-#include <pi-appinfo.h>
-#include <libedataserver/e-categories.h>
-#include <libedataserver/e-url.h>
-#include <libedataserverui/e-passwords.h>
-#include <libebook/e-book.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-dialog-widgets.h>
-#include <e-pilot-map.h>
-#include <e-pilot-settings.h>
-#include <e-pilot-util.h>
-
-GnomePilotConduit * conduit_get_gpilot_conduit (guint32);
-void conduit_destroy_gpilot_conduit (GnomePilotConduit*);
-
-#define CONDUIT_VERSION "0.1.2"
-
-#define DEBUG_CONDUIT 1
-/* #undef DEBUG_CONDUIT */
-
-#ifdef DEBUG_CONDUIT
-#define LOG(x) x
-#else
-#define LOG(x)
-#endif
-
-#define WARN g_warning
-#define INFO g_message
-#define PILOT_MAX_CATEGORIES 16
-
-enum {
- LABEL_WORK,
- LABEL_HOME,
- LABEL_FAX,
- LABEL_OTHER,
- LABEL_EMAIL,
- LABEL_MAIN,
- LABEL_PAGER,
- LABEL_MOBILE
-};
-
-static EContactField priority [] = {
- E_CONTACT_PHONE_BUSINESS,
- E_CONTACT_PHONE_HOME,
- E_CONTACT_PHONE_BUSINESS_FAX,
- E_CONTACT_EMAIL_1,
- E_CONTACT_PHONE_PAGER,
- E_CONTACT_PHONE_MOBILE,
- E_CONTACT_PHONE_BUSINESS_2,
- E_CONTACT_PHONE_HOME_2,
- E_CONTACT_PHONE_HOME_FAX,
- E_CONTACT_EMAIL_2,
- E_CONTACT_PHONE_OTHER,
- E_CONTACT_PHONE_PRIMARY,
- E_CONTACT_PHONE_OTHER_FAX,
- E_CONTACT_EMAIL_3,
- E_CONTACT_FIELD_LAST
-};
-
-static gint priority_label [] = {
- LABEL_WORK,
- LABEL_HOME,
- LABEL_FAX,
- LABEL_EMAIL,
- LABEL_PAGER,
- LABEL_MOBILE,
- LABEL_WORK,
- LABEL_HOME,
- LABEL_FAX,
- LABEL_EMAIL,
- LABEL_OTHER,
- LABEL_MAIN,
- LABEL_FAX,
- LABEL_EMAIL,
- -1
-};
-
-typedef struct _EAddrLocalRecord EAddrLocalRecord;
-typedef struct _EAddrConduitCfg EAddrConduitCfg;
-typedef struct _EAddrConduitGui EAddrConduitGui;
-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 */
- EContact *contact;
-
- /* pilot-link address structure, used for implementing Transmit. */
- struct Address *addr;
-};
-
-static void
-addrconduit_destroy_record (EAddrLocalRecord *local)
-{
- g_object_unref (local->contact);
- free_Address (local->addr);
- g_free (local->addr);
- g_free (local);
-}
-
-/* Configuration */
-struct _EAddrConduitCfg {
- guint32 pilot_id;
- GnomePilotConduitSyncType sync_type;
-
- ESourceList *source_list;
- ESource *source;
- gboolean secret;
- EContactField default_address;
-
- gchar *last_uri;
-};
-
-/* NOTE: copied from calendar/conduit/common/libecalendar-common-conduit.c
- * Adds a category to the category app info structure (name and ID),
- * sets category->renamed[i] to true if possible to rename.
- *
- * This will be packed and written to the app info block during post_sync.
- *
- * NOTE: cat_to_add MUST be in PCHAR format. Evolution stores categories
- * in UTF-8 format. A conversion must take place before calling
- * this function (see e_pilot_utf8_to_pchar() in e-pilot-util.c)
- */
-static gint
-e_pilot_add_category_if_possible(gchar *cat_to_add, struct CategoryAppInfo *category)
-{
- gint i, j;
- gint retval = 0; /* 0 is the Unfiled category */
- LOG(g_message("e_pilot_add_category_if_possible\n"));
-
- for (i=0; i<PILOT_MAX_CATEGORIES; i++) {
- /* if strlen is 0, then the category is empty
- the PalmOS doesn't let 0-length strings for
- categories */
- if (strlen(category->name[i]) == 0) {
- gint cat_to_add_len;
- gint desktopUniqueID;
-
- cat_to_add_len = strlen(cat_to_add);
- retval = i;
-
- if (cat_to_add_len > 15) {
- gchar tmpstr[17];
- strncpy(tmpstr, cat_to_add,16);
- tmpstr[16] = '\0';
- /* Have to truncate the category name */
- LOG (g_warning ("*** Desktop category '%s' too long for PDA."
- "Truncating to '%s' ***",cat_to_add, tmpstr));
- cat_to_add_len = 15;
- }
-
- /* only 15 characters for category, 16th is
- * '\0' can't do direct mem transfer due to
- * declaration type
- */
- for (j=0; j<cat_to_add_len; j++) {
- category->name[i][j] = cat_to_add[j];
- }
-
- for (j=cat_to_add_len; j<16; j++) {
- category->name[i][j] = '\0';
- }
-
- /* find a desktop id that is not in use between 128 and 255 */
- /* XXX desktopUniqueID should really be used for tracking
- * categories across renaming operations, but as Evo
- * doesn't have a concept of category UIDs or renaming,
- * we don't have much use for it at present.
- */
- for (desktopUniqueID = 128; desktopUniqueID <= 255; desktopUniqueID++) {
- gint found = 0;
- for (j=0; j<PILOT_MAX_CATEGORIES; j++) {
- if (category->ID[j] == desktopUniqueID) {
- found = 1;
- }
- }
- if (found == 0) {
- break;
- }
- if (desktopUniqueID == 255) {
- LOG (g_warning ("*** no more categories available on PC ***"));
- }
- }
- category->ID[i] = desktopUniqueID;
-
- category->renamed[i] = TRUE;
-
- break;
- }
- }
-
- if (retval == 0) {
- LOG (g_warning ("*** not adding category - category list already full ***"));
- }
-
- return retval;
-}
-
-/*
- * conversion from an evolution category to a palm category.
- * we iterate over the list of desktop categories to see if
- * there is matching palm category. If not, we create
- * a new palm category from the first evo category.
- * If a category was not found and could not be created,
- * or if there are no desktop categories, then *pilotCategory
- * is set to zero ("Unfiled").
- */
-static
-void e_pilot_local_category_to_remote(gint * pilotCategory,
- EContact *contact, struct CategoryAppInfo *category,
- const gchar *pilot_charset)
-{
- GList *c_list = NULL, *l;
- gchar * category_string, *first_category = NULL;
- gint i;
- *pilotCategory = 0; /* default to "Unfiled" */
- c_list = e_contact_get (contact, E_CONTACT_CATEGORY_LIST);
- if (c_list) {
- /* remember the first category */
- first_category = e_pilot_utf8_to_pchar((const gchar *)c_list->data, pilot_charset);
- }
- l = c_list;
- while (l && *pilotCategory == 0) {
- /* list != 0, so at least 1 category is assigned */
- category_string = e_pilot_utf8_to_pchar((const gchar *)l->data, pilot_charset);
- for (i=0; i < PILOT_MAX_CATEGORIES; i++) {
- /* only 15 chars + nul in palm category name */
- if (strncmp(category_string,category->name[i], 15) == 0) {
- *pilotCategory = i;
- break;
- }
- }
- g_free(category_string);
- l = l->next;
- }
- if (*pilotCategory == 0 && first_category && *first_category) {
- /* category not available on palm, try to create it */
- /* XXX e_pilot_add_category_if_possible can be called
- * when we're doing a 'copy from pilot'. This should
- * really be avoided.
- */
- *pilotCategory = e_pilot_add_category_if_possible(
- first_category,category);
- g_free(first_category);
- }
- g_list_foreach (c_list, (GFunc)g_free, NULL);
- g_list_free(c_list);
- /*end category*/
-}
-
-/*
- * conversion from a palm category to an evolution category
- */
-static
-void e_pilot_remote_category_to_local(gint pilotCategory,
- EContact *contact, struct CategoryAppInfo *category,
- const gchar *pilot_charset)
-{
- gchar *category_string = NULL;
-
- if (pilotCategory != 0) {
- /* pda has category assigned */
- category_string = e_pilot_utf8_from_pchar(
- category->name[pilotCategory], pilot_charset);
-
- LOG(g_message("PDA Category: %s\n", category_string));
-
- if (e_categories_exist(category_string) == FALSE) {
- /* add if it doesn't exist */
- LOG(g_message("Category created on pc\n"));
- e_categories_add(category_string, NULL, NULL, TRUE);
- }
- }
-
- /* store the data in EContact */
- if (category_string == NULL) {
- /* remove categories from desktop. */
- e_contact_set (contact, E_CONTACT_CATEGORY_LIST, NULL);
- }
- else {
-
- /* Since the first first category is synced with the PDA, add the PDA's
- * category to the beginning of the category list */
- GList *c_list = NULL;
- GList *newcat_in_list;
- c_list = e_contact_get (contact, E_CONTACT_CATEGORY_LIST);
-
- /* remove old item from list so we don't have duplicate entries */
- newcat_in_list = g_list_find_custom(c_list, category_string, (GCompareFunc)strcmp);
- if (newcat_in_list != NULL)
- {
- g_free(newcat_in_list->data);
- c_list = g_list_remove(c_list, newcat_in_list->data);
- }
-
- c_list = g_list_prepend(c_list, category_string);
- e_contact_set (contact, E_CONTACT_CATEGORY_LIST, c_list);
-
- g_list_foreach (c_list, (GFunc)g_free, NULL);
- g_list_free(c_list);
- }
-}
-
-static gchar *
-build_setup_path (const gchar *path, const gchar *key)
-{
- return g_strconcat ("/apps/evolution/conduit", "/", path, "/", key, NULL);
-}
-
-static gboolean
-e_pilot_setup_get_bool (const gchar *path, const gchar *key, gboolean def)
-{
- gboolean res = def;
- gchar *full_path;
- GConfValue *value;
- GConfClient *gconf;
-
- g_return_val_if_fail (path != NULL, res);
- g_return_val_if_fail (key != NULL, res);
-
- gconf = gconf_client_get_default ();
- full_path = build_setup_path (path, key);
-
- value = gconf_client_get (gconf, full_path, NULL);
- if (value) {
- if (value->type == GCONF_VALUE_BOOL)
- res = gconf_value_get_bool (value);
-
- gconf_value_free (value);
- }
-
- g_free (full_path);
- g_object_unref (gconf);
-
- return res;
-}
-
-static void
-e_pilot_setup_set_bool (const gchar *path, const gchar *key, gboolean value)
-{
- GError *error = NULL;
- gchar *full_path;
- GConfClient *gconf;
-
- g_return_if_fail (path != NULL);
- g_return_if_fail (key != NULL);
-
- gconf = gconf_client_get_default ();
- full_path = build_setup_path (path, key);
-
- gconf_client_set_bool (gconf, full_path, value, &error);
-
- g_free (full_path);
- g_object_unref (gconf);
-
- if (error) {
- g_message ("%s: Failed to write: %s", G_STRFUNC, error->message);
- g_error_free (error);
- }
-}
-
-static gchar *
-e_pilot_setup_get_string (const gchar *path, const gchar *key, const gchar *def)
-{
- gchar *res = g_strdup (def);
- gchar *full_path;
- GConfValue *value;
- GConfClient *gconf;
-
- g_return_val_if_fail (path != NULL, res);
- g_return_val_if_fail (key != NULL, res);
-
- gconf = gconf_client_get_default ();
- full_path = build_setup_path (path, key);
-
- value = gconf_client_get (gconf, full_path, NULL);
- if (value) {
- if (value->type == GCONF_VALUE_STRING) {
- g_free (res);
- res = g_strdup (gconf_value_get_string (value));
- }
-
- gconf_value_free (value);
- }
-
- g_free (full_path);
- g_object_unref (gconf);
-
- return res;
-}
-
-static void
-e_pilot_setup_set_string (const gchar *path, const gchar *key, const gchar *value)
-{
- GError *error = NULL;
- gchar *full_path;
- GConfClient *gconf;
-
- g_return_if_fail (path != NULL);
- g_return_if_fail (key != NULL);
- g_return_if_fail (value != NULL);
-
- gconf = gconf_client_get_default ();
- full_path = build_setup_path (path, key);
-
- gconf_client_set_string (gconf, full_path, value, &error);
-
- g_free (full_path);
- g_object_unref (gconf);
-
- if (error) {
- g_message ("%s: Failed to write: %s", G_STRFUNC, error->message);
- g_error_free (error);
- }
-}
-
-static EAddrConduitCfg *
-addrconduit_load_configuration (guint32 pilot_id)
-{
- EAddrConduitCfg *c;
- GnomePilotConduitManagement *management;
- GnomePilotConduitConfig *config;
- gchar *address, prefix[256];
- g_snprintf (prefix, 255, "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 ((gchar *)"e_address_conduit", GNOME_PILOT_CONDUIT_MGMT_ID);
- g_object_ref_sink (management);
- config = gnome_pilot_conduit_config_new (management, pilot_id);
- g_object_ref_sink (config);
- if (!gnome_pilot_conduit_config_is_enabled (config, &c->sync_type))
- c->sync_type = GnomePilotConduitSyncTypeNotSet;
- g_object_unref (config);
- g_object_unref (management);
-
- /* Custom settings */
- if (!e_book_get_addressbooks (&c->source_list, NULL))
- c->source_list = NULL;
- if (c->source_list) {
- c->source = e_pilot_get_sync_source (c->source_list);
- if (!c->source)
- c->source = e_source_list_peek_source_any (c->source_list);
- if (c->source) {
- g_object_ref (c->source);
- } else {
- g_object_unref (c->source_list);
- c->source_list = NULL;
- }
- }
-
- c->secret = e_pilot_setup_get_bool (prefix, "secret", FALSE);
- address = e_pilot_setup_get_string (prefix, "default_address", "business");
- if (!address || !strcmp (address, "business"))
- c->default_address = E_CONTACT_ADDRESS_WORK;
- else if (!strcmp (address, "home"))
- c->default_address = E_CONTACT_ADDRESS_HOME;
- else if (!strcmp (address, "other"))
- c->default_address = E_CONTACT_ADDRESS_OTHER;
- g_free (address);
- c->last_uri = e_pilot_setup_get_string (prefix, "last_uri", NULL);
-
- return c;
-}
-
-static void
-addrconduit_save_configuration (EAddrConduitCfg *c)
-{
- gchar prefix[256];
-
- g_snprintf (prefix, 255, "e-address-conduit/Pilot_%u", c->pilot_id);
-
- e_pilot_set_sync_source (c->source_list, c->source);
- e_pilot_setup_set_bool (prefix, "secret", c->secret);
- switch (c->default_address) {
- case E_CONTACT_ADDRESS_WORK:
- e_pilot_setup_set_string (prefix, "default_address", "business");
- break;
- case E_CONTACT_ADDRESS_HOME:
- e_pilot_setup_set_string (prefix, "default_address", "home");
- break;
- case E_CONTACT_ADDRESS_OTHER:
- e_pilot_setup_set_string (prefix, "default_address", "other");
- break;
- default:
- g_warning ("Unknown default_address value");
- }
- e_pilot_setup_set_string (prefix, "last_uri", c->last_uri ? c->last_uri : "");
-}
-
-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->pilot_id = c->pilot_id;
-
- if (c->source_list)
- retval->source_list = g_object_ref (c->source_list);
- if (c->source)
- retval->source = g_object_ref (c->source);
- retval->secret = c->secret;
- retval->default_address = c->default_address;
- retval->last_uri = g_strdup (c->last_uri);
-
- return retval;
-}
-
-static void
-addrconduit_destroy_configuration (EAddrConduitCfg *c)
-{
- g_return_if_fail (c != NULL);
-
- g_object_unref (c->source_list);
- g_object_unref (c->source);
- g_free (c->last_uri);
- g_free (c);
-}
-
-/* Gui */
-struct _EAddrConduitGui {
- GtkWidget *default_address;
-};
-
-static EAddrConduitGui *
-e_addr_gui_new (EPilotSettings *ps)
-{
- EAddrConduitGui *gui;
- GtkWidget *lbl;
- gint rows, i;
- static const gchar *items[] = {"Business", "Home", "Other", NULL};
-
- g_return_val_if_fail (ps != NULL, NULL);
- g_return_val_if_fail (E_IS_PILOT_SETTINGS (ps), NULL);
-
- gtk_table_resize (GTK_TABLE (ps), E_PILOT_SETTINGS_TABLE_ROWS + 1,
- E_PILOT_SETTINGS_TABLE_COLS);
-
- gui = g_new0 (EAddrConduitGui, 1);
-
- rows = E_PILOT_SETTINGS_TABLE_ROWS;
- lbl = gtk_label_new (_("Default Sync Address:"));
- gtk_misc_set_alignment (GTK_MISC (lbl), 0.0, 0.5);
- gui->default_address = gtk_combo_box_new_text ();
- for (i = 0; items[i] != NULL; i++) {
- gtk_combo_box_append_text (GTK_COMBO_BOX (gui->default_address), items[i]);
- }
- gtk_table_attach_defaults (GTK_TABLE (ps), lbl, 0, 1, rows, rows + 1);
- gtk_table_attach_defaults (GTK_TABLE (ps), gui->default_address, 1, 2, rows, rows + 1);
- gtk_widget_show (lbl);
- gtk_widget_show (gui->default_address);
-
- return gui;
-}
-
-static const gint default_address_map[] = {
- E_CONTACT_ADDRESS_WORK,
- E_CONTACT_ADDRESS_HOME,
- E_CONTACT_ADDRESS_OTHER,
- -1
-};
-
-static void
-e_addr_gui_fill_widgets (EAddrConduitGui *gui, EAddrConduitCfg *cfg)
-{
- g_return_if_fail (gui != NULL);
- g_return_if_fail (cfg != NULL);
-
- e_dialog_combo_box_set (gui->default_address,
- cfg->default_address,
- default_address_map);
-}
-
-static void
-e_addr_gui_fill_config (EAddrConduitGui *gui, EAddrConduitCfg *cfg)
-{
- g_return_if_fail (gui != NULL);
- g_return_if_fail (cfg != NULL);
-
- cfg->default_address = e_dialog_combo_box_get (gui->default_address,
- default_address_map);
-}
-
-static void
-e_addr_gui_destroy (EAddrConduitGui *gui)
-{
- g_free (gui);
-}
-
-/* Context */
-struct _EAddrConduitContext {
- GnomePilotDBInfo *dbi;
-
- EAddrConduitCfg *cfg;
- EAddrConduitCfg *new_cfg;
- EAddrConduitGui *gui;
- GtkWidget *ps;
-
- struct AddressAppInfo ai;
-
- EBook *ebook;
- GList *cards;
- GList *changed;
- GHashTable *changed_hash;
- GList *locals;
-
- EPilotMap *map;
-
- gchar * pilot_charset;
-};
-
-static EAddrConduitContext *
-e_addr_context_new (guint32 pilot_id)
-{
- EAddrConduitContext *ctxt = g_new0 (EAddrConduitContext, 1);
-
- ctxt->cfg = addrconduit_load_configuration (pilot_id);
- ctxt->new_cfg = addrconduit_dupe_configuration (ctxt->cfg);
- ctxt->gui = NULL;
- ctxt->ps = NULL;
- ctxt->ebook = NULL;
- ctxt->cards = NULL;
- ctxt->changed_hash = NULL;
- ctxt->changed = NULL;
- ctxt->locals = NULL;
- ctxt->map = NULL;
- ctxt->pilot_charset = NULL;
-
- return ctxt;
-}
-
-static void
-e_addr_context_destroy (EAddrConduitContext *ctxt)
-{
- GList *l;
-
- g_return_if_fail (ctxt != NULL);
-
- if (ctxt->cfg != NULL)
- addrconduit_destroy_configuration (ctxt->cfg);
- if (ctxt->new_cfg != NULL)
- addrconduit_destroy_configuration (ctxt->new_cfg);
- if (ctxt->gui != NULL)
- e_addr_gui_destroy (ctxt->gui);
-
- if (ctxt->ebook != NULL)
- g_object_unref (ctxt->ebook);
-
- if (ctxt->cards != NULL) {
- for (l = ctxt->cards; l != NULL; l = l->next)
- g_object_unref (l->data);
- g_list_free (ctxt->cards);
- }
-
- if (ctxt->changed_hash != NULL)
- g_hash_table_destroy (ctxt->changed_hash);
-
- if (ctxt->changed != NULL)
- e_book_free_change_list (ctxt->changed);
-
- if (ctxt->locals != NULL) {
- for (l = ctxt->locals; l != NULL; l = l->next)
- addrconduit_destroy_record (l->data);
- g_list_free (ctxt->locals);
- }
-
- if (ctxt->map != NULL)
- e_pilot_map_destroy (ctxt->map);
-
- g_free (ctxt);
-}
-
-/* Debug routines */
-static const gchar *
-print_local (EAddrLocalRecord *local)
-{
- static gchar 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 gchar *print_remote (GnomePilotRecord *remote)
-{
- static gchar buff[ 4096 ];
- struct Address addr;
-#ifdef PILOT_LINK_0_12
- pi_buffer_t * buffer;
-#endif
-
- if (remote == NULL) {
- sprintf (buff, "[NULL]");
- return buff;
- }
-
- memset (&addr, 0, sizeof (struct Address));
-#ifdef PILOT_LINK_0_12
- buffer = pi_buffer_new(DLP_BUF_SIZE);
- if (buffer == NULL) {
- sprintf (buff, "[NULL]");
- return buff;
- }
- if (pi_buffer_append(buffer, remote->record, remote->length)==NULL) {
- sprintf (buff, "[NULL]");
- return buff;
- }
- unpack_Address (&addr, buffer, address_v1);
- pi_buffer_free(buffer);
-#else
- unpack_Address (&addr, remote->record, remote->length);
-#endif
-
- 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;
-}
-
-/* Utility routines */
-static gchar *
-map_name (EAddrConduitContext *ctxt)
-{
- gchar *filename = NULL;
-
- filename = g_strdup_printf ("%s/.evolution/addressbook/local/system/pilot-map-%d.xml", g_get_home_dir (), ctxt->cfg->pilot_id);
-
- return filename;
-}
-
-static GList *
-next_changed_item (EAddrConduitContext *ctxt, GList *changes)
-{
- EBookChange *ebc;
- GList *l;
-
- for (l = changes; l != NULL; l = l->next) {
- ebc = l->data;
-
- if (g_hash_table_lookup (ctxt->changed_hash, e_contact_get_const (ebc->contact, E_CONTACT_UID)))
- return l;
- }
-
- return NULL;
-}
-
-static EContactField
-get_next_mail (EContactField *field)
-{
- if (field == NULL)
- return E_CONTACT_EMAIL_1;
-
- switch (*field) {
- case E_CONTACT_EMAIL_1:
- return E_CONTACT_EMAIL_2;
- case E_CONTACT_EMAIL_2:
- return E_CONTACT_EMAIL_3;
- default:
- break;
- }
-
- return E_CONTACT_FIELD_LAST;
-}
-
-static EContactField
-get_next_home (EContactField *field)
-{
- if (field == NULL)
- return E_CONTACT_PHONE_HOME;
-
- switch (*field) {
- case E_CONTACT_PHONE_HOME:
- return E_CONTACT_PHONE_HOME_2;
- default:
- break;
- }
-
- return E_CONTACT_FIELD_LAST;
-}
-
-static EContactField
-get_next_work (EContactField *field)
-{
- if (field == NULL)
- return E_CONTACT_PHONE_BUSINESS;
-
- switch (*field) {
- case E_CONTACT_PHONE_BUSINESS:
- return E_CONTACT_PHONE_BUSINESS_2;
- default:
- break;
- }
-
- return E_CONTACT_FIELD_LAST;
-}
-
-static EContactField
-get_next_fax (EContactField *field)
-{
- if (field == NULL)
- return E_CONTACT_PHONE_BUSINESS_FAX;
-
- switch (*field) {
- case E_CONTACT_PHONE_BUSINESS_FAX:
- return E_CONTACT_PHONE_HOME_FAX;
- case E_CONTACT_PHONE_HOME_FAX:
- return E_CONTACT_PHONE_OTHER_FAX;
- default:
- break;
- }
-
- return E_CONTACT_FIELD_LAST;
-}
-
-static EContactField
-get_next_other (EContactField *field)
-{
- if (field == NULL)
- return E_CONTACT_PHONE_OTHER;
-
- return E_CONTACT_FIELD_LAST;
-}
-
-static EContactField
-get_next_main (EContactField *field)
-{
- if (field == NULL)
- return E_CONTACT_PHONE_PRIMARY;
-
- return E_CONTACT_FIELD_LAST;
-}
-
-static EContactField
-get_next_pager (EContactField *field)
-{
- if (field == NULL)
- return E_CONTACT_PHONE_PAGER;
-
- return E_CONTACT_FIELD_LAST;
-}
-
-static EContactField
-get_next_mobile (EContactField *field)
-{
- if (field == NULL)
- return E_CONTACT_PHONE_MOBILE;
-
- return E_CONTACT_FIELD_LAST;
-}
-
-static void
-get_next_init (EContactField *next_mail,
- EContactField *next_home,
- EContactField *next_work,
- EContactField *next_fax,
- EContactField *next_other,
- EContactField *next_main,
- EContactField *next_pager,
- EContactField *next_mobile)
-{
- *next_mail = get_next_mail (NULL);
- *next_home = get_next_home (NULL);
- *next_work = get_next_work (NULL);
- *next_fax = get_next_fax (NULL);
- *next_other = get_next_other (NULL);
- *next_main = get_next_main (NULL);
- *next_pager = get_next_pager (NULL);
- *next_mobile = get_next_mobile (NULL);
-}
-
-static gboolean
-is_next_done (EContactField field)
-{
- if (field == E_CONTACT_FIELD_LAST)
- return TRUE;
-
- return FALSE;
-}
-
-static gboolean
-is_syncable (EAddrConduitContext *ctxt, EAddrLocalRecord *local)
-{
- EContactField next_mail, next_home, next_work, next_fax;
- EContactField next_other, next_main, next_pager, next_mobile;
- gboolean syncable = TRUE;
- gint i, l = 0;
-
- /* See if there are fields we can't sync or not in priority order */
- get_next_init (&next_mail, &next_home, &next_work, &next_fax,
- &next_other, &next_main, &next_pager, &next_mobile);
-
- for (i = entryPhone1; i <= entryPhone5 && syncable; i++) {
- gint phonelabel = local->addr->phoneLabel[i - entryPhone1];
- const gchar *phone_str = local->addr->entry[i];
- gboolean empty = !(phone_str && *phone_str);
-
- if (empty)
- continue;
-
- for (; priority_label[l] != -1; l++)
- if (phonelabel == priority_label[l])
- break;
-
- if (priority_label[l] == -1) {
- syncable = FALSE;
- continue;
- }
-
- if (phonelabel == LABEL_EMAIL) {
- if (is_next_done (next_mail) || next_mail != priority[l]) {
- syncable = FALSE;
- break;
- }
- next_mail = get_next_mail (&next_mail);
- } else if (phonelabel == LABEL_HOME) {
- if (is_next_done (next_home) || next_home != priority[l]) {
- syncable = FALSE;
- break;
- }
- next_home = get_next_home (&next_home);
- } else if (phonelabel == LABEL_WORK) {
- if (is_next_done (next_work) || next_work != priority[l]) {
- syncable = FALSE;
- break;
- }
- next_work = get_next_work (&next_work);
- } else if (phonelabel == LABEL_FAX) {
- if (is_next_done (next_fax) || next_fax != priority[l]) {
- syncable = FALSE;
- break;
- }
- next_fax = get_next_fax (&next_fax);
- } else if (phonelabel == LABEL_OTHER) {
- if (is_next_done (next_other) || next_other != priority[l]) {
- syncable = FALSE;
- break;
- }
- next_other = get_next_other (&next_other);
- } else if (phonelabel == LABEL_MAIN) {
- if (is_next_done (next_main) || next_main != priority[l]) {
- syncable = FALSE;
- break;
- }
- next_main = get_next_main (&next_main);
- } else if (phonelabel == LABEL_PAGER) {
- if (is_next_done (next_pager) || next_pager != priority[l]) {
- syncable = FALSE;
- break;
- }
- next_pager = get_next_pager (&next_pager);
- } else if (phonelabel == LABEL_MOBILE) {
- if (is_next_done (next_mobile) || next_mobile != priority[l]) {
- syncable = FALSE;
- break;
- }
- next_mobile = get_next_mobile (&next_mobile);
- }
- }
-
- return syncable;
-}
-
-static void
-set_contact_text (EContact *contact, EContactField field, struct Address address,
- gint entry, const gchar *pilot_charset)
-{
- gchar *text = NULL;
-
- if (address.entry[entry])
- text = e_pilot_utf8_from_pchar (address.entry[entry], pilot_charset);
-
- e_contact_set (contact, field, text);
-
- g_free (text);
-}
-
-static gchar *
-get_entry_text (struct Address address, gint entry, const gchar *pilot_charset)
-{
- if (address.entry[entry])
- return e_pilot_utf8_from_pchar (address.entry[entry], pilot_charset);
-
- return NULL;
-}
-
-static void
-clear_entry_text (struct Address address, gint field)
-{
- if (address.entry[field]) {
- free (address.entry[field]);
- address.entry[field] = NULL;
- }
-}
-
-static void
-compute_status (EAddrConduitContext *ctxt, EAddrLocalRecord *local, const gchar *uid)
-{
- EBookChange *ebc;
-
- local->local.archived = FALSE;
- local->local.secret = FALSE;
-
- ebc = g_hash_table_lookup (ctxt->changed_hash, uid);
-
- if (ebc == NULL) {
- local->local.attr = GnomePilotRecordNothing;
- return;
- }
-
- switch (ebc->change_type) {
- case E_BOOK_CHANGE_CARD_ADDED:
- local->local.attr = GnomePilotRecordNew;
- break;
- case E_BOOK_CHANGE_CARD_MODIFIED:
- local->local.attr = GnomePilotRecordModified;
- break;
- case E_BOOK_CHANGE_CARD_DELETED:
- local->local.attr = GnomePilotRecordDeleted;
- break;
- }
-}
-
-static GnomePilotRecord
-local_record_to_pilot_record (EAddrLocalRecord *local,
- EAddrConduitContext *ctxt)
-{
- GnomePilotRecord p;
-#ifdef PILOT_LINK_0_12
- pi_buffer_t * buffer;
-#else
- static gchar record[0xffff];
-#endif
-
- g_assert (local->addr != NULL );
-
- LOG (g_message ( "local_record_to_pilot_record\n" ));
-
- memset (&p, 0, sizeof (GnomePilotRecord));
-
- p.ID = local->local.ID;
- p.category = local->local.category;
- p.attr = local->local.attr;
- p.archived = local->local.archived;
- p.secret = local->local.secret;
-
- /* Generate pilot record structure */
-
-#ifdef PILOT_LINK_0_12
- buffer = pi_buffer_new(DLP_BUF_SIZE);
- if (buffer == NULL) {
- pi_set_error(ctxt->dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
- return p;
- }
-
- pack_Address (local->addr, buffer, address_v1);
-
- p.record = g_new0(unsigned char, buffer->used);
- p.length = buffer->used;
- memcpy(p.record, buffer->data, buffer->used);
-
- pi_buffer_free(buffer);
-#else
- p.record = (guchar *)record;
- p.length = pack_Address (local->addr, p.record, 0xffff);
-#endif
- return p;
-}
-
-static void
-local_record_from_ecard (EAddrLocalRecord *local, EContact *contact, EAddrConduitContext *ctxt)
-{
- EContactAddress *address = NULL;
- gint phone = entryPhone1;
- gboolean syncable;
- gint i;
-
- g_return_if_fail (local != NULL);
- g_return_if_fail (contact != NULL);
-
- local->contact = g_object_ref (contact);
- local->local.ID = e_pilot_map_lookup_pid (ctxt->map, e_contact_get_const (contact, E_CONTACT_UID), TRUE);
-
- compute_status (ctxt, local, e_contact_get_const (contact, E_CONTACT_UID));
-
- local->addr = g_new0 (struct Address, 1);
-
- /* Handle the fields and category we don't sync by making sure
- * we don't overwrite them
- */
- if (local->local.ID != 0) {
- struct Address addr;
- gint cat = 0;
-#ifdef PILOT_LINK_0_12
- pi_buffer_t * record;
- record = pi_buffer_new(DLP_BUF_SIZE);
- if (record == NULL) {
- pi_set_error(ctxt->dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
- return;
- }
-#else
- gchar record[0xffff];
-#endif
-
- if (dlp_ReadRecordById (ctxt->dbi->pilot_socket,
- ctxt->dbi->db_handle,
-#ifdef PILOT_LINK_0_12
- local->local.ID, record,
- NULL, NULL, &cat) > 0) {
-#else
- local->local.ID, &record,
- NULL, NULL, NULL, &cat) > 0) {
-#endif
- local->local.category = cat;
- memset (&addr, 0, sizeof (struct Address));
-#ifdef PILOT_LINK_0_12
- unpack_Address (&addr, record, address_v1);
-#else
- unpack_Address (&addr, (guchar *)record, 0xffff);
-#endif
- for (i = 0; i < 5; 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]);
- }
- free_Address (&addr);
- }
-#ifdef PILOT_LINK_0_12
- pi_buffer_free (record);
-#endif
- }
-
- /*Category support*/
- e_pilot_local_category_to_remote(&(local->local.category), contact, &(ctxt->ai.category), ctxt->pilot_charset);
-
- local->addr->entry[entryFirstname] = e_pilot_utf8_to_pchar (e_contact_get_const (contact, E_CONTACT_GIVEN_NAME), ctxt->pilot_charset);
- local->addr->entry[entryLastname] = e_pilot_utf8_to_pchar (e_contact_get_const (contact, E_CONTACT_FAMILY_NAME), ctxt->pilot_charset);
- local->addr->entry[entryCompany] = e_pilot_utf8_to_pchar (e_contact_get_const (contact, E_CONTACT_ORG), ctxt->pilot_charset);
- local->addr->entry[entryTitle] = e_pilot_utf8_to_pchar (e_contact_get_const (contact, E_CONTACT_TITLE), ctxt->pilot_charset);
-
- /* See if the default has something in it */
- address = e_contact_get (contact, ctxt->cfg->default_address);
- if (address == NULL) {
- EContactField field;
-
- /* Try to find a non-empty address field */
- for (field = E_CONTACT_FIRST_ADDRESS_ID; field <= E_CONTACT_LAST_ADDRESS_ID; field++) {
- if ((address = e_contact_get (contact, field)))
- break;
- }
- }
-
- if (address) {
- gchar *add;
-
- /* If the address has 2 lines, make sure both get added */
- if (address->ext != NULL &&
- strlen (address->ext) > 0) {
- add = g_strconcat (address->street, "\n", address->ext, NULL);
- LOG (g_warning ("Address has two lines: [%s]\n", add));
- }
- else {
- add = g_strdup (address->street);
- LOG (g_warning ("Address has only one line: [%s]\n", add));
- }
- local->addr->entry[entryAddress] = e_pilot_utf8_to_pchar (add, ctxt->pilot_charset);
- g_free (add);
-
- local->addr->entry[entryCity] = e_pilot_utf8_to_pchar (address->locality, ctxt->pilot_charset);
- local->addr->entry[entryState] = e_pilot_utf8_to_pchar (address->region, ctxt->pilot_charset);
- local->addr->entry[entryZip] = e_pilot_utf8_to_pchar (address->code, ctxt->pilot_charset);
- local->addr->entry[entryCountry] = e_pilot_utf8_to_pchar (address->country, ctxt->pilot_charset);
-
- e_contact_address_free (address);
- }
-
- /* Phone numbers */
-
- /* See if everything is syncable */
- syncable = is_syncable (ctxt, local);
-
- if (syncable) {
- INFO ("Syncable");
-
- /* Sync by priority */
- for (i = 0, phone = entryPhone1;
- priority[i] != E_CONTACT_FIELD_LAST && phone <= entryPhone5; i++) {
- const gchar *phone_str;
-
- phone_str = e_contact_get_const (contact, priority[i]);
- if (phone_str && *phone_str) {
- clear_entry_text (*local->addr, phone);
- local->addr->entry[phone] = e_pilot_utf8_to_pchar (phone_str, ctxt->pilot_charset);
- local->addr->phoneLabel[phone - entryPhone1] = priority_label[i];
- phone++;
- }
- }
- for (; phone <= entryPhone5; phone++)
- local->addr->phoneLabel[phone - entryPhone1] = phone - entryPhone1;
- local->addr->showPhone = 0;
- } else {
- EContactField next_mail, next_home, next_work, next_fax;
- EContactField next_other, next_main, next_pager, next_mobile;
-
- INFO ("Not Syncable");
- get_next_init (&next_mail, &next_home, &next_work, &next_fax,
- &next_other, &next_main, &next_pager, &next_mobile);
-
- /* Not completely syncable, so do the best we can */
- for (i = entryPhone1; i <= entryPhone5; i++) {
- gint phonelabel = local->addr->phoneLabel[i - entryPhone1];
- const gchar *phone_str = NULL;
-
- if (phonelabel == LABEL_EMAIL && !is_next_done (next_mail)) {
- phone_str = e_contact_get_const (contact, next_mail);
- next_mail = get_next_mail (&next_mail);
- } else if (phonelabel == LABEL_HOME && !is_next_done (next_home)) {
- phone_str = e_contact_get_const (contact, next_home);
- next_home = get_next_home (&next_home);
- } else if (phonelabel == LABEL_WORK && !is_next_done (next_work)) {
- phone_str = e_contact_get_const (contact, next_work);
- next_work = get_next_work (&next_work);
- } else if (phonelabel == LABEL_FAX && !is_next_done (next_fax)) {
- phone_str = e_contact_get_const (contact, next_fax);
- next_fax = get_next_fax (&next_fax);
- } else if (phonelabel == LABEL_OTHER && !is_next_done (next_other)) {
- phone_str = e_contact_get_const (contact, next_other);
- next_other = get_next_other (&next_other);
- } else if (phonelabel == LABEL_MAIN && !is_next_done (next_main)) {
- phone_str = e_contact_get_const (contact, next_main);
- next_main = get_next_main (&next_main);
- } else if (phonelabel == LABEL_PAGER && !is_next_done (next_pager)) {
- phone_str = e_contact_get_const (contact, next_pager);
- next_pager = get_next_pager (&next_pager);
- } else if (phonelabel == LABEL_MOBILE && !is_next_done (next_mobile)) {
- phone_str = e_contact_get_const (contact, next_mobile);
- next_mobile = get_next_mobile (&next_mobile);
- }
-
- if (phone_str && *phone_str) {
- clear_entry_text (*local->addr, i);
- local->addr->entry[i] = e_pilot_utf8_to_pchar (phone_str, ctxt->pilot_charset);
- }
- }
- }
-
- /* Note */
- local->addr->entry[entryNote] = e_pilot_utf8_to_pchar (e_contact_get_const (contact, E_CONTACT_NOTE), ctxt->pilot_charset);
-}
-
-static void
-local_record_from_uid (EAddrLocalRecord *local,
- const gchar *uid,
- EAddrConduitContext *ctxt)
-{
- EContact *contact = NULL;
- const gchar *cuid;
- GList *l;
-
- g_assert (local != NULL);
-
- for (l = ctxt->cards; l != NULL; l = l->next) {
- contact = l->data;
-
- /* FIXME Do we need to check for the empty string? */
- if ((cuid = e_contact_get_const (contact, E_CONTACT_UID)) && !strcmp (cuid, uid))
- break;
-
- contact = NULL;
- }
-
- if (contact != NULL) {
- local_record_from_ecard (local, contact, ctxt);
- } else {
- contact = e_contact_new ();
- e_contact_set (contact, E_CONTACT_UID, (gpointer) uid);
- local_record_from_ecard (local, contact, ctxt);
- g_object_unref (contact);
- }
-}
-
-static EContact *
-ecard_from_remote_record(EAddrConduitContext *ctxt,
- GnomePilotRecord *remote,
- EContact *in_contact)
-{
- struct Address address;
- EContact *contact;
- EContactName *name;
- EContactAddress *eaddress;
- EContactField mailing_address;
- gchar *txt, *find, *full_name;
- EContactField next_mail, next_home, next_work, next_fax;
- EContactField next_other, next_main, next_pager, next_mobile;
- gint i;
-#ifdef PILOT_LINK_0_12
- pi_buffer_t * buffer;
-#endif
- g_return_val_if_fail(remote!=NULL,NULL);
- memset (&address, 0, sizeof (struct Address));
-#ifdef PILOT_LINK_0_12
- buffer = pi_buffer_new(DLP_BUF_SIZE);
- if (buffer == NULL) {
- pi_set_error(ctxt->dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
- return NULL;
- }
-
- if (pi_buffer_append(buffer, remote->record, remote->length)==NULL) {
- pi_set_error(ctxt->dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
- return NULL;
- }
- unpack_Address (&address, buffer, address_v1);
- pi_buffer_free(buffer);
-#else
- unpack_Address (&address, remote->record, remote->length);
-#endif
- if (in_contact == NULL)
- contact = e_contact_new ();
- else
- contact = e_contact_duplicate (in_contact);
-
- /*Category support*/
- e_pilot_remote_category_to_local(remote->category, contact, &(ctxt->ai.category), ctxt->pilot_charset);
-
- /* Name */
- name = e_contact_name_new ();
- name->given = get_entry_text (address, entryFirstname, ctxt->pilot_charset);
- name->family = get_entry_text (address, entryLastname, ctxt->pilot_charset);
-
- /* set the name, respecting the pilot's given/family names */
- e_contact_set (contact, E_CONTACT_NAME, name);
- /* now set the full_name */
- full_name = e_contact_name_to_string (name);
- e_contact_set (contact, E_CONTACT_FULL_NAME, full_name);
- e_contact_name_free (name);
-
- /* File As */
- if (!full_name || !*full_name)
- set_contact_text (contact, E_CONTACT_FILE_AS, address, entryCompany, ctxt->pilot_charset);
-
- g_free (full_name);
-
- /* Title and Company */
- set_contact_text (contact, E_CONTACT_TITLE, address, entryTitle, ctxt->pilot_charset);
- set_contact_text (contact, E_CONTACT_ORG, address, entryCompany, ctxt->pilot_charset);
-
- /* Address */
- mailing_address = -1;
- if ((eaddress = e_contact_get (contact, ctxt->cfg->default_address))) {
- mailing_address = ctxt->cfg->default_address;
- e_contact_address_free (eaddress);
- } else {
- for (i = E_CONTACT_FIRST_ADDRESS_ID; i <= E_CONTACT_LAST_ADDRESS_ID; i++) {
- if ((eaddress = e_contact_get (contact, i))) {
- e_contact_address_free (eaddress);
- mailing_address = i;
- break;
- }
- }
- }
-
- if (mailing_address == -1)
- mailing_address = ctxt->cfg->default_address;
-
- eaddress = g_new0 (EContactAddress, 1);
-
- txt = get_entry_text (address, entryAddress, ctxt->pilot_charset);
- if (txt && (find = strchr (txt, '\n')) != NULL) {
- *find = '\0';
- find++;
- } else {
- find = NULL;
- }
-
- eaddress->street = txt;
- eaddress->ext = find != NULL ? g_strdup (find) : g_strdup ("");
- eaddress->locality = get_entry_text (address, entryCity, ctxt->pilot_charset);
- eaddress->region = get_entry_text (address, entryState, ctxt->pilot_charset);
- eaddress->country = get_entry_text (address, entryCountry, ctxt->pilot_charset);
- eaddress->code = get_entry_text (address, entryZip, ctxt->pilot_charset);
-
- e_contact_set (contact, mailing_address, eaddress);
- e_contact_address_free (eaddress);
-
- /* Phone numbers */
- get_next_init (&next_mail, &next_home, &next_work, &next_fax,
- &next_other, &next_main, &next_pager, &next_mobile);
-
- for (i = entryPhone1; i <= entryPhone5; i++) {
- gint phonelabel = address.phoneLabel[i - entryPhone1];
- gchar *phonenum = get_entry_text (address, i, ctxt->pilot_charset);
-
- if (phonelabel == LABEL_EMAIL && !is_next_done (next_mail)) {
- e_contact_set (contact, next_mail, phonenum);
- next_mail = get_next_mail (&next_mail);
- } else if (phonelabel == LABEL_HOME && !is_next_done (next_home)) {
- e_contact_set (contact, next_home, phonenum);
- next_home = get_next_home (&next_home);
- } else if (phonelabel == LABEL_WORK && !is_next_done (next_work)) {
- e_contact_set (contact, next_work, phonenum);
- next_work = get_next_work (&next_work);
- } else if (phonelabel == LABEL_FAX && !is_next_done (next_fax)) {
- e_contact_set (contact, next_fax, phonenum);
- next_fax = get_next_fax (&next_fax);
- } else if (phonelabel == LABEL_OTHER && !is_next_done (next_other)) {
- e_contact_set (contact, next_other, phonenum);
- next_other = get_next_other (&next_other);
- } else if (phonelabel == LABEL_MAIN && !is_next_done (next_main)) {
- e_contact_set (contact, next_main, phonenum);
- next_main = get_next_main (&next_main);
- } else if (phonelabel == LABEL_PAGER && !is_next_done (next_pager)) {
- e_contact_set (contact, next_pager, phonenum);
- next_pager = get_next_pager (&next_pager);
- } else if (phonelabel == LABEL_MOBILE && !is_next_done (next_mobile)) {
- e_contact_set (contact, next_mobile, phonenum);
- next_mobile = get_next_mobile (&next_mobile);
- }
-
- g_free (phonenum);
- }
-
- /* Note */
- set_contact_text (contact, E_CONTACT_NOTE, address, entryNote, ctxt->pilot_charset);
-
- free_Address(&address);
-
- return contact;
-}
-
-static void
-check_for_slow_setting (GnomePilotConduit *c, EAddrConduitContext *ctxt)
-{
- GnomePilotConduitStandard *conduit = GNOME_PILOT_CONDUIT_STANDARD (c);
- gint map_count;
- const gchar *uri;
-
- map_count = g_hash_table_size (ctxt->map->pid_map);
- if (map_count == 0)
- gnome_pilot_conduit_standard_set_slow (conduit, TRUE);
-
- /* Or if the URI's don't match */
- uri = e_book_get_uri (ctxt->ebook);
- LOG (g_message (" Current URI %s (%s)\n", uri, ctxt->cfg->last_uri ? ctxt->cfg->last_uri : "<NONE>"));
- if (ctxt->cfg->last_uri != NULL && strcmp (ctxt->cfg->last_uri, uri)) {
- gnome_pilot_conduit_standard_set_slow (conduit, TRUE);
- e_pilot_map_clear (ctxt->map);
- }
-
- if (gnome_pilot_conduit_standard_get_slow (conduit)) {
- ctxt->map->write_touched_only = TRUE;
- LOG (g_message ( " doing slow sync\n" ));
- } else {
- LOG (g_message ( " doing fast sync\n" ));
- }
-}
-
-static void
-addressbook_authenticate (EBook *book,
- gpointer data)
-{
- gchar *auth;
- const gchar *user;
- gchar *passwd;
- gchar *str_uri;
- gchar *pass_key;
- gchar *auth_domain;
- const gchar *component_name;
- EUri *e_uri;
-
- ESource *source = (ESource *)data;
-
- auth = (gchar *)e_source_get_property (source, "auth");
- auth_domain = (gchar *)e_source_get_property (source, "auth-domain");
- component_name = auth_domain ? auth_domain : "Addressbook";
-
- if (auth && !strcmp ("plain/password", auth))
- user = e_source_get_property (source, "user");
- else
- user = e_source_get_property (source, "email_addr");
- if (!user)
- user = "";
-
- str_uri = e_source_get_uri (source);
- e_uri = e_uri_new (str_uri);
- pass_key = e_uri_to_string (e_uri, FALSE);
- e_uri_free (e_uri);
-
- passwd = e_passwords_get_password (component_name, pass_key);
- if (!passwd)
- passwd = g_strdup ("");
-
- if (book)
- if (!e_book_authenticate_user (book, user, passwd, auth, NULL))
- LOG (g_warning ("Authentication failed"));
- g_free (pass_key);
- g_free (str_uri);
- g_free (passwd);
-
- return;
-}
-
-/* Pilot syncing callbacks */
-static gint
-pre_sync (GnomePilotConduit *conduit,
- GnomePilotDBInfo *dbi,
- EAddrConduitContext *ctxt)
-{
- GnomePilotConduitSyncAbs *abs_conduit;
- EBookQuery *query;
- GList *l;
- gint len;
- gchar *filename;
- gchar *change_id;
- gchar *auth;
- gint num_records, add_records = 0, mod_records = 0, del_records = 0;
-#ifdef PILOT_LINK_0_12
- pi_buffer_t *buffer;
-#else
- guchar *buf;
-#endif
-
- abs_conduit = GNOME_PILOT_CONDUIT_SYNC_ABS (conduit);
-
- LOG (g_message ( "---------------------------------------------------------\n" ));
- LOG (g_message ( "pre_sync: Addressbook Conduit v.%s", CONDUIT_VERSION ));
- /* g_message ("Addressbook Conduit v.%s", CONDUIT_VERSION); */
-
- ctxt->dbi = dbi;
-
-#ifdef PILOT_LINK_0_12
- if (NULL == dbi->pilotInfo->pilot_charset)
- ctxt->pilot_charset = NULL;
- else
- ctxt->pilot_charset = g_strdup(dbi->pilotInfo->pilot_charset);
-#endif
-
- if (ctxt->cfg->source) {
- ctxt->ebook = e_book_new (ctxt->cfg->source, NULL);
- } else {
- ctxt->ebook = e_book_new_default_addressbook (NULL);
- }
- auth = (gchar *)e_source_get_property (ctxt->cfg->source, "auth");
- if (auth) {
- LOG (g_message ("contacts needs authentication\n"));
- g_signal_connect (ctxt->ebook, "auth_required",
- G_CALLBACK (addressbook_authenticate), ctxt->cfg->source);
- }
- if (!ctxt->ebook || !e_book_open (ctxt->ebook, TRUE, NULL)) {
- WARN(_("Could not load address book"));
- gnome_pilot_conduit_error (conduit, _("Could not load address book"));
-
- return -1;
- }
-
- /* Load the uid <--> pilot id mappings */
- filename = map_name (ctxt);
- e_pilot_map_read (filename, &ctxt->map);
- g_free (filename);
-
- /* Get a list of all contacts */
- if (!(query = e_book_query_any_field_contains (""))) {
- LOG (g_warning ("Failed to get EBookQuery"));
- return -1;
- }
-
- if (!e_book_get_contacts (ctxt->ebook, query, &ctxt->cards, NULL)) {
- LOG (g_warning ("Failed to get Contacts"));
- e_book_query_unref (query);
- return -1;
- }
-
- e_book_query_unref (query);
-
- /* Count and hash the changes */
- change_id = g_strdup_printf ("pilot-sync-evolution-addressbook-%d", ctxt->cfg->pilot_id);
- if (!e_book_get_changes (ctxt->ebook, change_id, &ctxt->changed, NULL))
- return -1;
- ctxt->changed_hash = g_hash_table_new (g_str_hash, g_str_equal);
- g_free (change_id);
-
- for (l = ctxt->changed; l != NULL; l = l->next) {
- EBookChange *ebc = l->data;
- const gchar *uid;
-
- uid = e_contact_get_const (ebc->contact, E_CONTACT_UID);
- if (!e_pilot_map_uid_is_archived (ctxt->map, uid)) {
-
- g_hash_table_insert (ctxt->changed_hash, g_strdup (uid), ebc);
-
- switch (ebc->change_type) {
- case E_BOOK_CHANGE_CARD_ADDED:
- add_records++;
- break;
- case E_BOOK_CHANGE_CARD_MODIFIED:
- mod_records++;
- break;
- case E_BOOK_CHANGE_CARD_DELETED:
- del_records++;
- break;
- }
- } else if (ebc->change_type == E_BOOK_CHANGE_CARD_DELETED) {
- e_pilot_map_remove_by_uid (ctxt->map, uid);
- }
- }
-
- /* Set the count information */
- num_records = g_list_length (ctxt->cards);
- gnome_pilot_conduit_sync_abs_set_num_local_records(abs_conduit, num_records);
- gnome_pilot_conduit_sync_abs_set_num_new_local_records (abs_conduit, add_records);
- gnome_pilot_conduit_sync_abs_set_num_updated_local_records (abs_conduit, mod_records);
- gnome_pilot_conduit_sync_abs_set_num_deleted_local_records(abs_conduit, del_records);
-
-#ifdef PILOT_LINK_0_12
- buffer = pi_buffer_new(DLP_BUF_SIZE);
- if (buffer == NULL) {
- return pi_set_error(dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
- }
-
- len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
- DLP_BUF_SIZE, buffer);
-#else
- buf = (guchar *)g_malloc (0xffff);
- len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
- (guchar *)buf, 0xffff);
-#endif
- if (len < 0) {
- WARN (_("Could not read pilot's Address application block"));
- WARN ("dlp_ReadAppBlock(...) = %d", len);
- gnome_pilot_conduit_error (conduit,
- _("Could not read pilot's Address application block"));
- return -1;
- }
-#ifdef PILOT_LINK_0_12
- unpack_AddressAppInfo (&(ctxt->ai), buffer->data, len);
- pi_buffer_free (buffer);
-#else
- unpack_AddressAppInfo (&(ctxt->ai), buf, len);
- g_free (buf);
-#endif
- check_for_slow_setting (conduit, ctxt);
- if (ctxt->cfg->sync_type == GnomePilotConduitSyncTypeCopyToPilot
- || ctxt->cfg->sync_type == GnomePilotConduitSyncTypeCopyFromPilot)
- ctxt->map->write_touched_only = TRUE;
-
- return 0;
-}
-
-static gint
-post_sync (GnomePilotConduit *conduit,
- GnomePilotDBInfo *dbi,
- EAddrConduitContext *ctxt)
-{
- GList *changed;
- gchar *filename, *change_id;
- guchar *buf;
- gint dlpRetVal, len;
-
- LOG (g_message ( "post_sync: Address Conduit v.%s", CONDUIT_VERSION ));
-
- /* Write AppBlock to PDA - updates categories */
- buf = (guchar *)g_malloc (0xffff);
-
- len = pack_AddressAppInfo (&(ctxt->ai), buf, 0xffff);
-
- dlpRetVal = dlp_WriteAppBlock (dbi->pilot_socket, dbi->db_handle,
- (guchar *)buf, len);
-
- g_free (buf);
-
- if (dlpRetVal < 0) {
- WARN ( ("Could not write pilot's Address application block"));
- WARN ("dlp_WriteAppBlock(...) = %d", dlpRetVal);
- /*gnome_pilot_conduit_error (conduit,
- _("Could not write pilot's Address application block"));*/
- return -1;
- }
-
- g_free (ctxt->cfg->last_uri);
- ctxt->cfg->last_uri = g_strdup (e_book_get_uri (ctxt->ebook));
- addrconduit_save_configuration (ctxt->cfg);
-
- filename = map_name (ctxt);
- e_pilot_map_write (filename, ctxt->map);
- g_free (filename);
-
- /* FIX ME ugly hack - our changes musn't count, this does introduce
- * a race condition if anyone changes a record elsewhere during sycnc
- */
- change_id = g_strdup_printf ("pilot-sync-evolution-addressbook-%d", ctxt->cfg->pilot_id);
- if (e_book_get_changes (ctxt->ebook, change_id, &changed, NULL))
- e_book_free_change_list (changed);
- g_free (change_id);
- if (ctxt->pilot_charset)
- g_free (ctxt->pilot_charset);
- LOG (g_message ( "---------------------------------------------------------\n" ));
-
- return 0;
-}
-
-static gint
-set_pilot_id (GnomePilotConduitSyncAbs *conduit,
- EAddrLocalRecord *local,
- guint32 ID,
- EAddrConduitContext *ctxt)
-{
- LOG (g_message ( "set_pilot_id: setting to %d\n", ID ));
-
- e_pilot_map_insert (ctxt->map, ID, e_contact_get_const (local->contact, E_CONTACT_UID), FALSE);
-
- return 0;
-}
-
-static gint
-set_status_cleared (GnomePilotConduitSyncAbs *conduit,
- EAddrLocalRecord *local,
- EAddrConduitContext *ctxt)
-{
- const gchar *uid;
-
- LOG (g_message ( "set_status_cleared: clearing status\n" ));
-
- if ((uid = e_contact_get_const (local->contact, E_CONTACT_UID)))
- g_hash_table_remove (ctxt->changed_hash, uid);
-
- return 0;
-}
-
-static gint
-for_each (GnomePilotConduitSyncAbs *conduit,
- EAddrLocalRecord **local,
- EAddrConduitContext *ctxt)
-{
- static GList *cards, *iterator;
- static gint count;
-
- g_return_val_if_fail (local != NULL, -1);
-
- if (*local == NULL) {
- LOG (g_message ( "beginning for_each" ));
-
- cards = ctxt->cards;
- count = 0;
-
- if (cards != NULL) {
- LOG (g_message ( "iterating over %d records", g_list_length (cards) ));
-
- *local = g_new0 (EAddrLocalRecord, 1);
- local_record_from_ecard (*local, cards->data, ctxt);
- ctxt->locals = g_list_prepend (ctxt->locals, *local);
-
- iterator = cards;
- } else {
- LOG (g_message ( "no events" ));
- (*local) = NULL;
- return 0;
- }
- } else {
- count++;
- if (g_list_next (iterator)) {
- iterator = g_list_next (iterator);
-
- *local = g_new0 (EAddrLocalRecord, 1);
- local_record_from_ecard (*local, iterator->data, ctxt);
- ctxt->locals = g_list_prepend (ctxt->locals, *local);
- } else {
- LOG (g_message ( "for_each ending" ));
-
- /* Tell the pilot the iteration is over */
- *local = NULL;
-
- return 0;
- }
- }
-
- return 0;
-}
-
-static gint
-for_each_modified (GnomePilotConduitSyncAbs *conduit,
- EAddrLocalRecord **local,
- EAddrConduitContext *ctxt)
-{
- static GList *iterator;
- static gint count;
-
- g_return_val_if_fail (local != NULL, 0);
-
- if (*local == NULL) {
- LOG (g_message ( "for_each_modified beginning\n" ));
-
- iterator = ctxt->changed;
-
- count = 0;
-
- iterator = next_changed_item (ctxt, iterator);
- if (iterator != NULL) {
- EBookChange *ebc = iterator->data;
-
- LOG (g_message ( "iterating over %d records", g_hash_table_size (ctxt->changed_hash)));
-
- *local = g_new0 (EAddrLocalRecord, 1);
- local_record_from_ecard (*local, ebc->contact, ctxt);
- ctxt->locals = g_list_prepend (ctxt->locals, *local);
- } else {
- LOG (g_message ( "no events" ));
-
- *local = NULL;
- }
- } else {
- count++;
- iterator = g_list_next (iterator);
- if (iterator && (iterator = next_changed_item (ctxt, iterator))) {
- EBookChange *ebc = iterator->data;
-
- *local = g_new0 (EAddrLocalRecord, 1);
- local_record_from_ecard (*local, ebc->contact, ctxt);
- ctxt->locals = g_list_prepend (ctxt->locals, *local);
- } else {
- LOG (g_message ( "for_each_modified ending" ));
-
- /* Signal the iteration is over */
- *local = NULL;
-
- return 0;
- }
- }
-
- return 0;
-}
-
-static gint
-compare (GnomePilotConduitSyncAbs *conduit,
- EAddrLocalRecord *local,
- GnomePilotRecord *remote,
- EAddrConduitContext *ctxt)
-{
- GnomePilotRecord local_pilot;
- gint retval = 0;
-
- LOG (g_message ("compare: local=%s remote=%s...\n",
- print_local (local), print_remote (remote)));
-
- g_return_val_if_fail (local != NULL, -1);
- g_return_val_if_fail (remote != NULL, -1);
-
- local_pilot = local_record_to_pilot_record (local, ctxt);
-
- if (remote->length != local_pilot.length
- || memcmp (local_pilot.record, remote->record, remote->length))
- retval = 1;
-
- if (retval == 0)
- LOG (g_message ( " equal" ));
- else
- LOG (g_message ( " not equal" ));
-
- return retval;
-}
-
-static gint
-add_record (GnomePilotConduitSyncAbs *conduit,
- GnomePilotRecord *remote,
- EAddrConduitContext *ctxt)
-{
- EContact *contact;
- gint retval = 0;
-
- g_return_val_if_fail (remote != NULL, -1);
-
- LOG (g_message ( "add_record: adding %s to desktop\n", print_remote (remote) ));
-
- contact = ecard_from_remote_record (ctxt, remote, NULL);
-
- /* add the ecard to the server */
- if (!e_book_add_contact (ctxt->ebook, contact, NULL)) {
- WARN ("add_record: failed to add card to ebook\n");
- g_object_unref (contact);
-
- return -1;
- }
-
- e_pilot_map_insert (ctxt->map, remote->ID, e_contact_get (contact, E_CONTACT_UID), FALSE);
-
- g_object_unref (contact);
-
- return retval;
-}
-
-static gint
-replace_record (GnomePilotConduitSyncAbs *conduit,
- EAddrLocalRecord *local,
- GnomePilotRecord *remote,
- EAddrConduitContext *ctxt)
-{
- EContact *new_contact;
- EBookChange *ebc;
- gchar *old_id;
- gint retval = 0;
-
- g_return_val_if_fail (remote != NULL, -1);
-
- LOG (g_message ("replace_record: replace %s with %s\n",
- print_local (local), print_remote (remote)));
-
- old_id = e_contact_get (local->contact, E_CONTACT_UID);
- ebc = g_hash_table_lookup (ctxt->changed_hash, old_id);
-
- new_contact = ecard_from_remote_record (ctxt, remote, local->contact);
- g_object_unref (local->contact);
- local->contact = new_contact;
-
- if (ebc && ebc->change_type == E_BOOK_CHANGE_CARD_DELETED) {
- if (!e_book_add_contact (ctxt->ebook, local->contact, NULL)) {
- WARN (G_STRLOC ": failed to add card\n");
-
- return -1;
- }
-
- } else {
- if (!e_book_commit_contact (ctxt->ebook, local->contact, NULL)) {
- WARN (G_STRLOC ": failed to commit card\n");
-
- return -1;
- }
- }
-
- /* Adding a record causes wombat to assign a new uid so we must tidy */
- if (ebc && ebc->change_type == E_BOOK_CHANGE_CARD_DELETED) {
- const gchar *uid = e_contact_get_const (local->contact, E_CONTACT_UID);
- gboolean arch;
-
- arch = e_pilot_map_uid_is_archived (ctxt->map, uid);
- e_pilot_map_insert (ctxt->map, remote->ID, uid, arch);
-
- ebc = g_hash_table_lookup (ctxt->changed_hash, old_id);
- if (ebc) {
- g_hash_table_remove (ctxt->changed_hash, old_id);
- g_object_unref (ebc->contact);
- g_object_ref (local->contact);
- ebc->contact = local->contact;
- /* FIXME We should possibly be duplicating the uid */
- g_hash_table_insert (ctxt->changed_hash, (gpointer) uid, ebc);
- }
- }
-
- return retval;
-}
-
-static gint
-delete_record (GnomePilotConduitSyncAbs *conduit,
- EAddrLocalRecord *local,
- EAddrConduitContext *ctxt)
-{
- GError *error = NULL;
- gint retval = 0;
-
- g_return_val_if_fail (local != NULL, -1);
- g_return_val_if_fail (local->contact != NULL, -1);
-
- LOG (g_message ( "delete_record: delete %s\n", print_local (local) ));
-
- e_pilot_map_remove_by_uid (ctxt->map, e_contact_get_const (local->contact, E_CONTACT_UID));
- if (!e_book_remove_contact (ctxt->ebook, e_contact_get_const (local->contact, E_CONTACT_UID), &error) && error->code != E_BOOK_ERROR_CONTACT_NOT_FOUND) {
- WARN ("delete_record: failed to delete card in ebook\n");
- g_error_free (error);
-
- retval = -1;
- }
-
- return retval;
-}
-
-static gint
-archive_record (GnomePilotConduitSyncAbs *conduit,
- EAddrLocalRecord *local,
- gboolean archive,
- EAddrConduitContext *ctxt)
-{
- gint retval = 0;
-
- g_return_val_if_fail (local != NULL, -1);
-
- LOG (g_message ( "archive_record: %s\n", archive ? "yes" : "no" ));
-
- e_pilot_map_insert (ctxt->map, local->local.ID, e_contact_get_const (local->contact, E_CONTACT_UID), archive);
-
- return retval;
-}
-
-static gint
-match (GnomePilotConduitSyncAbs *conduit,
- GnomePilotRecord *remote,
- EAddrLocalRecord **local,
- EAddrConduitContext *ctxt)
-{
- const gchar *uid;
-
- LOG (g_message ("match: looking for local copy of %s\n",
- print_remote (remote)));
-
- g_return_val_if_fail (local != NULL, -1);
- g_return_val_if_fail (remote != NULL, -1);
-
- *local = NULL;
- uid = e_pilot_map_lookup_uid (ctxt->map, remote->ID, TRUE);
-
- if (!uid)
- return 0;
-
- LOG (g_message ( " matched\n" ));
-
- *local = g_new0 (EAddrLocalRecord, 1);
- local_record_from_uid (*local, uid, ctxt);
-
- return 0;
-}
-
-static gint
-free_match (GnomePilotConduitSyncAbs *conduit,
- EAddrLocalRecord *local,
- EAddrConduitContext *ctxt)
-{
- LOG (g_message ( "free_match: freeing\n" ));
-
- g_return_val_if_fail (local != NULL, -1);
-
- ctxt->locals = g_list_remove (ctxt->locals, local);
-
- addrconduit_destroy_record (local);
-
- return 0;
-}
-
-static gint
-prepare (GnomePilotConduitSyncAbs *conduit,
- EAddrLocalRecord *local,
- GnomePilotRecord *remote,
- EAddrConduitContext *ctxt)
-{
- LOG (g_message ( "prepare: encoding local %s\n", print_local (local) ));
-
- *remote = local_record_to_pilot_record (local, ctxt);
-
- return 0;
-}
-
-/* Pilot Settings Callbacks */
-static void
-fill_widgets (EAddrConduitContext *ctxt)
-{
- if (ctxt->cfg->source)
- e_pilot_settings_set_source (E_PILOT_SETTINGS (ctxt->ps),
- ctxt->cfg->source);
- e_pilot_settings_set_secret (E_PILOT_SETTINGS (ctxt->ps),
- ctxt->cfg->secret);
-
- e_addr_gui_fill_widgets (ctxt->gui, ctxt->cfg);
-}
-
-static gint
-create_settings_window (GnomePilotConduit *conduit,
- GtkWidget *parent,
- EAddrConduitContext *ctxt)
-{
- LOG (g_message ( "create_settings_window" ));
-
- if (!ctxt->cfg->source_list)
- return -1;
-
- ctxt->ps = e_pilot_settings_new (ctxt->cfg->source_list);
- ctxt->gui = e_addr_gui_new (E_PILOT_SETTINGS (ctxt->ps));
-
- 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 (g_message ( "display_settings" ));
-
- fill_widgets (ctxt);
-}
-
-static void
-save_settings (GnomePilotConduit *conduit, EAddrConduitContext *ctxt)
-{
- LOG (g_message ( "save_settings" ));
-
- if (ctxt->new_cfg->source)
- g_object_unref (ctxt->new_cfg->source);
- ctxt->new_cfg->source = e_pilot_settings_get_source (E_PILOT_SETTINGS (ctxt->ps));
- g_object_ref (ctxt->new_cfg->source);
- ctxt->new_cfg->secret =
- e_pilot_settings_get_secret (E_PILOT_SETTINGS (ctxt->ps));
- e_addr_gui_fill_config (ctxt->gui, ctxt->new_cfg);
-
- addrconduit_save_configuration (ctxt->new_cfg);
-}
-
-static void
-revert_settings (GnomePilotConduit *conduit, EAddrConduitContext *ctxt)
-{
- LOG (g_message ( "revert_settings" ));
-
- addrconduit_save_configuration (ctxt->cfg);
- addrconduit_destroy_configuration (ctxt->new_cfg);
- ctxt->new_cfg = addrconduit_dupe_configuration (ctxt->cfg);
-}
-
-GnomePilotConduit *
-conduit_get_gpilot_conduit (guint32 pilot_id)
-{
- GtkObject *retval;
- EAddrConduitContext *ctxt;
-
- LOG (g_message ( "in address's conduit_get_gpilot_conduit\n" ));
-
- retval = gnome_pilot_conduit_sync_abs_new ((gchar *)"AddressDB", 0x61646472);
- g_assert (retval != NULL);
-
- ctxt = e_addr_context_new (pilot_id);
- g_object_set_data (G_OBJECT (retval), "addrconduit_context", ctxt);
-
- g_signal_connect (retval, "pre_sync", G_CALLBACK (pre_sync), ctxt);
- g_signal_connect (retval, "post_sync", G_CALLBACK (post_sync), ctxt);
-
- g_signal_connect (retval, "set_pilot_id", G_CALLBACK (set_pilot_id), ctxt);
- g_signal_connect (retval, "set_status_cleared", G_CALLBACK (set_status_cleared), ctxt);
-
- g_signal_connect (retval, "for_each", G_CALLBACK (for_each), ctxt);
- g_signal_connect (retval, "for_each_modified", G_CALLBACK (for_each_modified), ctxt);
- g_signal_connect (retval, "compare", G_CALLBACK (compare), ctxt);
-
- g_signal_connect (retval, "add_record", G_CALLBACK (add_record), ctxt);
- g_signal_connect (retval, "replace_record", G_CALLBACK (replace_record), ctxt);
- g_signal_connect (retval, "delete_record", G_CALLBACK (delete_record), ctxt);
- g_signal_connect (retval, "archive_record", G_CALLBACK (archive_record), ctxt);
-
- g_signal_connect (retval, "match", G_CALLBACK (match), ctxt);
- g_signal_connect (retval, "free_match", G_CALLBACK (free_match), ctxt);
-
- g_signal_connect (retval, "prepare", G_CALLBACK (prepare), ctxt);
-
- /* Gui Settings */
- g_signal_connect (retval, "create_settings_window", G_CALLBACK (create_settings_window), ctxt);
- g_signal_connect (retval, "display_settings", G_CALLBACK (display_settings), ctxt);
- g_signal_connect (retval, "save_settings", G_CALLBACK (save_settings), ctxt);
- g_signal_connect (retval, "revert_settings", G_CALLBACK (revert_settings), ctxt);
-
- return GNOME_PILOT_CONDUIT (retval);
-}
-
-void
-conduit_destroy_gpilot_conduit (GnomePilotConduit *conduit)
-{
- EAddrConduitContext *ctxt;
-
- ctxt = g_object_get_data (G_OBJECT (conduit),
- "addrconduit_context");
-
- e_addr_context_destroy (ctxt);
-
- gtk_object_destroy (GTK_OBJECT (conduit));
-}
diff --git a/addressbook/conduit/e-address.conduit.in b/addressbook/conduit/e-address.conduit.in
deleted file mode 100644
index 669a506001..0000000000
--- a/addressbook/conduit/e-address.conduit.in
+++ /dev/null
@@ -1,9 +0,0 @@
-<gnome-pilot-conduit version="1.0">
- <conduit id="e_address_conduit" type="shlib" location="@privconduitdir@/libeaddress_conduit.so"/>
- <name value="EAddress"/>
- <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="TRUE"/>
- <conduit-attribute name="icon" value="@datadir@/images/evolution/conduits/48_evo-address-conduit.png"/>
-</gnome-pilot-conduit>
diff --git a/calendar/Makefile.am b/calendar/Makefile.am
index e8974cdeb5..dfed6e66c7 100644
--- a/calendar/Makefile.am
+++ b/calendar/Makefile.am
@@ -1,10 +1,4 @@
-if ENABLE_PILOT_CONDUITS
-CONDUIT_DIR = conduits
-else
-CONDUIT_DIR =
-endif
-
-SUBDIRS = common importers gui $(CONDUIT_DIR)
+SUBDIRS = common importers gui
error_DATA = calendar.error
errordir = $(privdatadir)/errors
diff --git a/calendar/conduits/Makefile.am b/calendar/conduits/Makefile.am
deleted file mode 100644
index 27abb0962a..0000000000
--- a/calendar/conduits/Makefile.am
+++ /dev/null
@@ -1,3 +0,0 @@
-SUBDIRS = common calendar memo todo
-
--include $(top_srcdir)/git.mk
diff --git a/calendar/conduits/calendar/Makefile.am b/calendar/conduits/calendar/Makefile.am
deleted file mode 100644
index 6a5dc513a2..0000000000
--- a/calendar/conduits/calendar/Makefile.am
+++ /dev/null
@@ -1,43 +0,0 @@
-# Calendar Conduit
-privconduit_LTLIBRARIES = libecalendar_conduit.la
-
-libecalendar_conduit_la_CPPFLAGS = \
- $(AM_CPPFLAGS) \
- -I$(top_srcdir)/e-util \
- -I$(top_builddir)/e-util \
- -I$(top_srcdir)/widgets/misc \
- -I$(top_builddir)/widgets/misc \
- -I$(top_srcdir)/calendar/conduits/common \
- -I$(top_builddir)/calendar/conduits/common \
- $(EVOLUTION_CALENDAR_CONDUIT_CFLAGS)
-
-libecalendar_conduit_la_SOURCES = calendar-conduit.c
-
-libecalendar_conduit_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED)
-
-libecalendar_conduit_la_LIBADD = \
- $(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/e-util/libeconduit.la \
- $(top_builddir)/widgets/misc/libemiscwidgets.la \
- $(top_builddir)/calendar/conduits/common/libecalendar_common_conduit.la \
- $(EVOLUTION_CALENDAR_CONDUIT_LIBS)
-
-e-calendar.conduit: e-calendar.conduit.in
- sed -e 's^\@privconduitdir\@^$(privconduitdir)^g' \
- -e 's^\@datadir\@^$(datadir)^g' \
- -e 's^\@BASE_VERSION\@^$(BASE_VERSION)^g' \
- $< > $@
-
-conduitdir = $(datadir)/gnome-pilot/conduits/
-conduit_DATA = e-calendar.conduit
-
-BUILT_SOURCES = $(conduit_DATA)
-CLEANFILES = $(BUILT_SOURCES)
-
-EXTRA_DIST = \
- e-calendar.conduit.in
-
-dist-hook:
- cd $(distdir); rm -f $(BUILT_SOURCES)
-
--include $(top_srcdir)/git.mk
diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c
deleted file mode 100644
index a2466508ee..0000000000
--- a/calendar/conduits/calendar/calendar-conduit.c
+++ /dev/null
@@ -1,2174 +0,0 @@
-/*
- * Evolution calendar - Calendar Conduit
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Eskil Heyn Olsen <deity@eskil.dk>
- * JP Rosevear <jpr@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#include <config.h>
-
-#define G_LOG_DOMAIN "ecalconduit"
-
-/* Work around deprecated API usage in GnomePilot. */
-#undef GTK_DISABLE_DEPRECATED
-#undef GTK_DISABLE_SINGLE_INCLUDES
-
-#include <glib/gi18n.h>
-#include <libecal/e-cal-types.h>
-#include <libecal/e-cal.h>
-#include <libecal/e-cal-time-util.h>
-#include <libedataserver/e-url.h>
-#include <libedataserverui/e-passwords.h>
-#include <pi-source.h>
-#include <pi-socket.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 <e-pilot-util.h>
-#include <libecalendar-common-conduit.h>
-
-GnomePilotConduit * conduit_get_gpilot_conduit (guint32);
-void conduit_destroy_gpilot_conduit (GnomePilotConduit*);
-
-#define CONDUIT_VERSION "0.1.6"
-
-#define DEBUG_CALCONDUIT 1
-/* #undef DEBUG_CALCONDUIT */
-
-#ifdef DEBUG_CALCONDUIT
-#define LOG(x) x
-#else
-#define LOG(x)
-#endif
-
-#define WARN g_warning
-#define INFO g_message
-
-#define PILOT_MAX_ADVANCE 99
-
-typedef struct _ECalLocalRecord ECalLocalRecord;
-typedef struct _ECalConduitCfg ECalConduitCfg;
-typedef struct _ECalConduitGui ECalConduitGui;
-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 */
- ECalComponent *comp;
-
- /* pilot-link appointment structure */
- struct Appointment *appt;
-};
-
-static void
-calconduit_destroy_record (ECalLocalRecord *local)
-{
- g_object_unref (local->comp);
- free_Appointment (local->appt);
- g_free (local->appt);
- g_free (local);
-}
-
-/* Configuration */
-struct _ECalConduitCfg {
- guint32 pilot_id;
- GnomePilotConduitSyncType sync_type;
-
- ESourceList *source_list;
- ESource *source;
- gboolean secret;
- gboolean multi_day_split;
-
- gchar *last_uri;
-};
-
-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 ((gchar *)"e_calendar_conduit", GNOME_PILOT_CONDUIT_MGMT_ID);
- g_object_ref_sink (management);
- config = gnome_pilot_conduit_config_new (management, pilot_id);
- g_object_ref_sink (config);
- if (!gnome_pilot_conduit_config_is_enabled (config, &c->sync_type))
- c->sync_type = GnomePilotConduitSyncTypeNotSet;
- g_object_unref (config);
- g_object_unref (management);
-
- /* Custom settings */
- g_snprintf (prefix, 255, "e-calendar-conduit/Pilot_%u", pilot_id);
-
- if (!e_cal_get_sources (&c->source_list, E_CAL_SOURCE_TYPE_EVENT, NULL))
- c->source_list = NULL;
- if (c->source_list) {
- c->source = e_pilot_get_sync_source (c->source_list);
- if (!c->source)
- c->source = e_source_list_peek_source_any (c->source_list);
- if (c->source) {
- g_object_ref (c->source);
- } else {
- g_object_unref (c->source_list);
- c->source_list = NULL;
- }
- }
- c->secret = e_pilot_setup_get_bool (prefix, "secret", FALSE);
- c->multi_day_split = e_pilot_setup_get_bool (prefix, "multi_day_split", TRUE);
- if ((c->last_uri = e_pilot_setup_get_string (prefix, "last_uri", NULL)) && !strncmp (c->last_uri, "file://", 7)) {
- gchar *filename = g_filename_from_uri (c->last_uri, NULL, NULL);
- const gchar *path = filename;
- const gchar *home;
-
- home = g_get_home_dir ();
-
- if (!strncmp (path, home, strlen (home))) {
- path += strlen (home);
- if (G_IS_DIR_SEPARATOR (*path))
- path++;
-
- if (!strcmp (path, "evolution/local/Calendar/calendar.ics")) {
- gchar *new_filename =
- g_build_filename (home,
- ".evolution/calendar/local/system/calendar.ics",
- NULL);
- /* need to upgrade the last_uri. yay. */
- g_free (c->last_uri);
- c->last_uri = g_filename_to_uri (new_filename, NULL, NULL);
- g_free (new_filename);
- }
- }
- g_free (filename);
- }
-
- return c;
-}
-
-static void
-calconduit_save_configuration (ECalConduitCfg *c)
-{
- gchar prefix[256];
-
- g_snprintf (prefix, 255, "e-calendar-conduit/Pilot_%u", c->pilot_id);
-
- e_pilot_set_sync_source (c->source_list, c->source);
-
- e_pilot_setup_set_bool (prefix, "secret", c->secret);
- e_pilot_setup_set_bool (prefix, "multi_day_split", c->multi_day_split);
- e_pilot_setup_set_string (prefix, "last_uri", c->last_uri ? c->last_uri : "");
-}
-
-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;
-
- if (c->source_list)
- retval->source_list = g_object_ref (c->source_list);
- if (c->source)
- retval->source = g_object_ref (c->source);
- retval->secret = c->secret;
- retval->multi_day_split = c->multi_day_split;
- retval->last_uri = g_strdup (c->last_uri);
-
- return retval;
-}
-
-static void
-calconduit_destroy_configuration (ECalConduitCfg *c)
-{
- g_return_if_fail (c != NULL);
-
- g_object_unref (c->source_list);
- g_object_unref (c->source);
- g_free (c->last_uri);
- g_free (c);
-}
-
-/* Gui */
-struct _ECalConduitGui {
- GtkWidget *multi_day_split;
-};
-
-static ECalConduitGui *
-e_cal_gui_new (EPilotSettings *ps)
-{
- ECalConduitGui *gui;
- GtkWidget *lbl;
- gint rows;
-
- g_return_val_if_fail (ps != NULL, NULL);
- g_return_val_if_fail (E_IS_PILOT_SETTINGS (ps), NULL);
-
- gtk_table_resize (GTK_TABLE (ps), E_PILOT_SETTINGS_TABLE_ROWS + 1, E_PILOT_SETTINGS_TABLE_COLS);
-
- gui = g_new0 (ECalConduitGui, 1);
-
- rows = E_PILOT_SETTINGS_TABLE_ROWS;
- lbl = gtk_label_new (_("Split Multi-Day Events:"));
- gui->multi_day_split = gtk_check_button_new ();
- gtk_table_attach_defaults (GTK_TABLE (ps), lbl, 0, 1, rows, rows + 1);
- gtk_table_attach_defaults (GTK_TABLE (ps), gui->multi_day_split, 1, 2, rows, rows + 1);
- gtk_widget_show (lbl);
- gtk_widget_show (gui->multi_day_split);
-
- return gui;
-}
-
-static void
-e_cal_gui_fill_widgets (ECalConduitGui *gui, ECalConduitCfg *cfg)
-{
- g_return_if_fail (gui != NULL);
- g_return_if_fail (cfg != NULL);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gui->multi_day_split),
- cfg->multi_day_split);
-}
-
-static void
-e_cal_gui_fill_config (ECalConduitGui *gui, ECalConduitCfg *cfg)
-{
- g_return_if_fail (gui != NULL);
- g_return_if_fail (cfg != NULL);
-
- cfg->multi_day_split = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gui->multi_day_split));
-}
-
-static void
-e_cal_gui_destroy (ECalConduitGui *gui)
-{
- g_free (gui);
-}
-
-/* Context */
-struct _ECalConduitContext {
- GnomePilotDBInfo *dbi;
-
- ECalConduitCfg *cfg;
- ECalConduitCfg *new_cfg;
- ECalConduitGui *gui;
- GtkWidget *ps;
-
- struct AppointmentAppInfo ai;
-
- ECal *client;
-
- icaltimezone *timezone;
- ECalComponent *default_comp;
- GList *comps;
- GList *changed;
- GHashTable *changed_hash;
- GList *locals;
-
- EPilotMap *map;
-
- gchar *pilot_charset;
-};
-
-static ECalConduitContext *
-e_calendar_context_new (guint32 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->ps = NULL;
- ctxt->dbi = NULL;
- ctxt->client = NULL;
- ctxt->timezone = NULL;
- ctxt->default_comp = NULL;
- ctxt->comps = NULL;
- ctxt->changed = NULL;
- ctxt->changed_hash = NULL;
- ctxt->locals = NULL;
- ctxt->map = NULL;
-
- return ctxt;
-}
-
-static gboolean
-e_calendar_context_foreach_change (gpointer key, gpointer value, gpointer data)
-{
- g_free (key);
-
- return TRUE;
-}
-
-static void
-e_calendar_context_destroy (ECalConduitContext *ctxt)
-{
- GList *l;
-
- g_return_if_fail (ctxt != NULL);
-
- if (ctxt->cfg != NULL)
- calconduit_destroy_configuration (ctxt->cfg);
- if (ctxt->new_cfg != NULL)
- calconduit_destroy_configuration (ctxt->new_cfg);
- if (ctxt->gui != NULL)
- e_cal_gui_destroy (ctxt->gui);
-
- if (ctxt->client != NULL)
- g_object_unref (ctxt->client);
- if (ctxt->default_comp != NULL)
- g_object_unref (ctxt->default_comp);
- if (ctxt->comps != NULL) {
- for (l = ctxt->comps; l; l = l->next)
- g_object_unref (l->data);
- g_list_free (ctxt->comps);
- }
-
- if (ctxt->changed != NULL)
- e_cal_free_change_list (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);
- }
-
- if (ctxt->locals != NULL) {
- for (l = ctxt->locals; l != NULL; l = l->next)
- calconduit_destroy_record (l->data);
- g_list_free (ctxt->locals);
- }
-
- if (ctxt->map != NULL)
- e_pilot_map_destroy (ctxt->map);
-}
-
-/* Debug routines */
-static gchar *
-print_local (ECalLocalRecord *local)
-{
- static gchar 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;
- }
-
- strcpy (buff, "");
- return buff;
-}
-
-static gchar *print_remote (GnomePilotRecord *remote)
-{
- static gchar buff[ 4096 ];
- struct Appointment appt;
-#ifdef PILOT_LINK_0_12
- pi_buffer_t * buffer;
-#endif
-
- if (remote == NULL) {
- sprintf (buff, "[NULL]");
- return buff;
- }
-
- memset (&appt, 0, sizeof (struct Appointment));
-#ifdef PILOT_LINK_0_12
- buffer = pi_buffer_new(DLP_BUF_SIZE);
- if (buffer == NULL) {
- sprintf (buff, "[NULL]");
- return buff;
- }
- if (pi_buffer_append(buffer, remote->record, remote->length)==NULL) {
- sprintf (buff, "[NULL]");
- return buff;
- }
-
- unpack_Appointment (&appt, buffer, datebook_v1);
- pi_buffer_free(buffer);
-#else
- unpack_Appointment (&appt, remote->record, remote->length);
-#endif
- 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;
-}
-
-static gchar *
-auth_func_cb (ECal *ecal, const gchar * prompt, const gchar *key, gpointer user_data)
-{
- gchar *password;
- ESource *source;
- const gchar *auth_domain, *component_name;
-
- source = e_cal_get_source (ecal);
- auth_domain = e_source_get_property (source, "auth-domain");
- component_name = auth_domain ? auth_domain : "Calendar";
- password = e_passwords_get_password (component_name, key);
-
- return password;
-}
-
-static gint
-start_calendar_server (ECalConduitContext *ctxt)
-{
- gchar *str_uri = NULL;
- gchar *pass_key = NULL;
- gint retval = 0;
-
- g_return_val_if_fail (ctxt != NULL, -2);
-
- if (ctxt->cfg->source) {
- ctxt->client = e_cal_new (ctxt->cfg->source, E_CAL_SOURCE_TYPE_EVENT);
- /* Set the default timezone on the backend.
- As of Evo. 2.5.x, timezone should be set before
- calling e_cal_open.
- */
-
- if (ctxt->timezone) {
- if (!e_cal_set_default_timezone (ctxt->client, ctxt->timezone, NULL))
- return -1;
- }
-
- if (e_source_get_property (ctxt->cfg->source, "auth")) {
- EUri *e_uri;
-
- LOG (g_message ("Authenticating calendar\n"));
- str_uri = e_source_get_uri (ctxt->cfg->source);
- e_uri = e_uri_new (str_uri);
- pass_key = e_uri_to_string (e_uri, FALSE);
- e_uri_free (e_uri);
- if (ctxt->client)
- e_cal_set_auth_func (ctxt->client, (ECalAuthFunc) auth_func_cb, NULL);
- }
- if (!e_cal_open (ctxt->client, TRUE, NULL))
- retval = -1;
- } else if (!e_cal_open_default (&ctxt->client, E_CAL_SOURCE_TYPE_EVENT, NULL, NULL, NULL)) {
- retval = -1;
- }
- g_free (str_uri);
- g_free (pass_key);
- return retval;
-}
-
-/* Utility routines */
-static icaltimezone *
-get_timezone (ECal *client, const gchar *tzid)
-{
- icaltimezone *timezone = NULL;
-
- timezone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
- if (timezone == NULL)
- e_cal_get_timezone (client, tzid, &timezone, NULL);
-
- return timezone;
-}
-
-static icaltimezone *
-get_default_timezone (void)
-{
- GConfClient *client;
- icaltimezone *timezone = NULL;
- const gchar *key;
- gchar *location;
-
- client = gconf_client_get_default ();
- key = "/apps/evolution/calendar/display/timezone";
- location = gconf_client_get_string (client, key, NULL);
-
- if (location == NULL || *location == '\0') {
- g_free (location);
- location = g_strdup ("UTC");
- }
-
- timezone = icaltimezone_get_builtin_timezone (location);
- g_free (location);
-
- g_object_unref (client);
-
- return timezone;
-}
-
-static gchar *
-map_name (ECalConduitContext *ctxt)
-{
- gchar *filename;
-
- filename = g_strdup_printf ("%s/.evolution/calendar/local/system/pilot-map-calendar-%d.xml",
- g_get_home_dir (), ctxt->cfg->pilot_id);
-
- return filename;
-}
-
-static icalrecurrencetype_weekday
-get_ical_day (gint day)
-{
- switch (day) {
- case 0:
- return ICAL_SUNDAY_WEEKDAY;
- case 1:
- return ICAL_MONDAY_WEEKDAY;
- case 2:
- return ICAL_TUESDAY_WEEKDAY;
- case 3:
- return ICAL_WEDNESDAY_WEEKDAY;
- case 4:
- return ICAL_THURSDAY_WEEKDAY;
- case 5:
- return ICAL_FRIDAY_WEEKDAY;
- case 6:
- return ICAL_SATURDAY_WEEKDAY;
- }
-
- return ICAL_NO_WEEKDAY;
-}
-
-static gint
-get_pilot_day (icalrecurrencetype_weekday wd)
-{
- switch (wd) {
- case ICAL_SUNDAY_WEEKDAY:
- return 0;
- case ICAL_MONDAY_WEEKDAY:
- return 1;
- case ICAL_TUESDAY_WEEKDAY:
- return 2;
- case ICAL_WEDNESDAY_WEEKDAY:
- return 3;
- case ICAL_THURSDAY_WEEKDAY:
- return 4;
- case ICAL_FRIDAY_WEEKDAY:
- return 5;
- case ICAL_SATURDAY_WEEKDAY:
- return 6;
- default:
- return -1;
- }
-}
-
-static gboolean
-is_empty_time (struct tm time)
-{
- if (time.tm_sec || time.tm_min || time.tm_hour
- || time.tm_mday || time.tm_mon || time.tm_year)
- return FALSE;
-
- return TRUE;
-}
-
-static gboolean
-is_all_day (ECal *client, ECalComponentDateTime *dt_start, ECalComponentDateTime *dt_end)
-{
- time_t dt_start_time, dt_end_time;
- icaltimezone *timezone;
-
- if (dt_start->value->is_date && dt_end->value->is_date)
- return TRUE;
-
- timezone = get_timezone (client, dt_start->tzid);
- dt_start_time = icaltime_as_timet_with_zone (*dt_start->value, timezone);
- dt_end_time = icaltime_as_timet_with_zone (*dt_end->value, get_timezone (client, dt_end->tzid));
-
- if (dt_end_time == time_add_day_with_zone (dt_start_time, 1, timezone))
- return TRUE;
-
- return FALSE;
-}
-
-static gboolean
-process_multi_day (ECalConduitContext *ctxt, ECalChange *ccc, GList **multi_comp, GList **multi_ccc)
-{
- ECalComponentDateTime dt_start, dt_end;
- icaltimezone *tz_start, *tz_end;
- time_t event_start, event_end, day_end;
- struct icaltimetype *old_start_value, *old_end_value;
- const gchar *uid;
- gboolean is_date = FALSE;
- gboolean last = FALSE;
- gboolean ret = TRUE;
-
- *multi_ccc = NULL;
- *multi_comp = NULL;
-
- if (ccc->type == E_CAL_CHANGE_DELETED)
- return FALSE;
-
- /* Start time */
- e_cal_component_get_dtstart (ccc->comp, &dt_start);
- if (dt_start.value->is_date)
- tz_start = ctxt->timezone;
- else
- tz_start = get_timezone (ctxt->client, dt_start.tzid);
- event_start = icaltime_as_timet_with_zone (*dt_start.value, tz_start);
-
- e_cal_component_get_dtend (ccc->comp, &dt_end);
- if (dt_end.value->is_date)
- tz_end = ctxt->timezone;
- else
- tz_end = get_timezone (ctxt->client, dt_end.tzid);
- event_end = icaltime_as_timet_with_zone (*dt_end.value, tz_end);
-
- day_end = time_day_end_with_zone (event_start, ctxt->timezone);
- if (day_end >= event_end) {
- ret = FALSE;
- goto cleanup;
- } else if (e_cal_component_has_recurrences (ccc->comp) || !ctxt->cfg->multi_day_split) {
- ret = TRUE;
- goto cleanup;
- }
-
- if (dt_start.value->is_date && dt_end.value->is_date)
- is_date = TRUE;
-
- old_start_value = dt_start.value;
- old_end_value = dt_end.value;
- while (!last) {
- ECalComponent *clone = e_cal_component_clone (ccc->comp);
- icalcomponent *ical_comp = NULL;
- gchar *new_uid = e_cal_component_gen_uid ();
- struct icaltimetype start_value, end_value;
- ECalChange *c = NULL;
-
- if (day_end >= event_end) {
- day_end = event_end;
- last = TRUE;
- }
-
- e_cal_component_set_uid (clone, new_uid);
-
- start_value = icaltime_from_timet_with_zone (event_start, is_date, tz_start);
- dt_start.value = &start_value;
- e_cal_component_set_dtstart (clone, &dt_start);
-
- end_value = icaltime_from_timet_with_zone (day_end, is_date, tz_end);
- dt_end.value = &end_value;
- e_cal_component_set_dtend (clone, &dt_end);
-
- e_cal_component_commit_sequence (clone);
-
- /* FIXME Error handling */
- ical_comp = e_cal_component_get_icalcomponent (clone);
- if (!ical_comp) {
- ret = FALSE;
- g_free (new_uid);
- g_object_unref (clone);
- dt_start.value = old_start_value;
- dt_end.value = old_end_value;
- goto cleanup;
- }
-
- e_cal_create_object (ctxt->client, ical_comp, NULL, NULL);
-
- c = g_new0 (ECalChange, 1);
- c->comp = clone;
- c->type = E_CAL_CHANGE_ADDED;
-
- *multi_ccc = g_list_prepend (*multi_ccc, c);
- *multi_comp = g_list_prepend (*multi_comp, g_object_ref (c->comp));
-
- event_start = day_end;
- day_end = time_day_end_with_zone (event_start, ctxt->timezone);
-
- g_free (new_uid);
- }
- dt_start.value = old_start_value;
- dt_end.value = old_end_value;
-
- e_cal_component_get_uid (ccc->comp, &uid);
- /* FIXME Error handling */
- if (e_cal_component_is_instance (ccc->comp) || e_cal_component_has_recurrences (ccc->comp))
- e_cal_remove_object_with_mod (ctxt->client, uid, NULL, CALOBJ_MOD_ALL, NULL);
- else
- e_cal_remove_object (ctxt->client, uid, NULL);
-
- ccc->type = E_CAL_CHANGE_DELETED;
-
- cleanup:
- e_cal_component_free_datetime (&dt_start);
- e_cal_component_free_datetime (&dt_end);
-
- return ret;
-}
-
-static short
-nth_weekday (gint pos, icalrecurrencetype_weekday weekday)
-{
- g_assert ((pos > 0 && pos <= 5) || (pos == -1));
-
- return ((abs (pos) * 8) + weekday) * (pos < 0 ? -1 : 1);
-}
-
-static GList *
-next_changed_item (ECalConduitContext *ctxt, GList *changes)
-{
- ECalChange *ccc;
- GList *l;
-
- for (l = changes; l != NULL; l = l->next) {
- const gchar *uid;
-
- ccc = l->data;
-
- e_cal_component_get_uid (ccc->comp, &uid);
- if (g_hash_table_lookup (ctxt->changed_hash, uid))
- return l;
- }
-
- return NULL;
-}
-
-static void
-compute_status (ECalConduitContext *ctxt, ECalLocalRecord *local, const gchar *uid)
-{
- ECalChange *ccc;
-
- local->local.archived = FALSE;
- local->local.secret = FALSE;
-
- ccc = g_hash_table_lookup (ctxt->changed_hash, uid);
-
- if (ccc == NULL) {
- local->local.attr = GnomePilotRecordNothing;
- return;
- }
-
- switch (ccc->type) {
- case E_CAL_CHANGE_ADDED:
- local->local.attr = GnomePilotRecordNew;
- break;
-
- case E_CAL_CHANGE_MODIFIED:
- local->local.attr = GnomePilotRecordModified;
- break;
-
- case E_CAL_CHANGE_DELETED:
- local->local.attr = GnomePilotRecordDeleted;
- break;
- }
-}
-
-static gboolean
-rrules_mostly_equal (struct icalrecurrencetype *a, struct icalrecurrencetype *b)
-{
- struct icalrecurrencetype acopy, bcopy;
-
- acopy = *a;
- bcopy = *b;
-
- acopy.until = bcopy.until = icaltime_null_time ();
- acopy.count = bcopy.count = 0;
-
- if (!memcmp (&acopy, &bcopy, sizeof (struct icalrecurrencetype)))
- return TRUE;
-
- return FALSE;
-}
-
-static gboolean
-find_last_cb (ECalComponent *comp, time_t start, time_t end, gpointer data)
-{
- time_t *last = data;
-
- *last = start;
-
- return TRUE;
-}
-
-static GnomePilotRecord
-local_record_to_pilot_record (ECalLocalRecord *local,
- ECalConduitContext *ctxt)
-{
- GnomePilotRecord p;
-#ifdef PILOT_LINK_0_12
- pi_buffer_t * buffer;
-#else
- static gchar record[0xffff];
-#endif
-
- memset(&p, 0, sizeof (p));
-
- g_assert (local->comp != NULL);
- g_assert (local->appt != NULL );
-
- memset (&p, 0, sizeof (GnomePilotRecord));
-
- p.ID = local->local.ID;
- p.category = local->local.category;
- p.attr = local->local.attr;
- p.archived = local->local.archived;
- p.secret = local->local.secret;
-
- /* Generate pilot record structure */
-#ifdef PILOT_LINK_0_12
- buffer = pi_buffer_new(DLP_BUF_SIZE);
- if (buffer == NULL) {
- pi_set_error(ctxt->dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
- return p;
- }
-
- pack_Appointment (local->appt, buffer, datebook_v1);
- p.record = g_new0(unsigned char, buffer->used);
- p.length = buffer->used;
- memcpy(p.record, buffer->data, buffer->used);
-
- pi_buffer_free(buffer);
-#else
- p.record = (guchar *)record;
- p.length = pack_Appointment (local->appt, p.record, 0xffff);
-#endif
- return p;
-}
-
-/*
- * converts a ECalComponent object to a ECalLocalRecord
- */
-static void
-local_record_from_comp (ECalLocalRecord *local, ECalComponent *comp, ECalConduitContext *ctxt)
-{
- const gchar *uid;
- ECalComponentText summary;
- GSList *d_list = NULL, *edl = NULL, *l;
- ECalComponentText *description;
- ECalComponentDateTime dt_start, dt_end;
- ECalComponentClassification classif;
- icaltimezone *default_tz = ctxt->timezone;
- gint i;
-
- g_return_if_fail (local != NULL);
- g_return_if_fail (comp != NULL);
-
- local->comp = comp;
- g_object_ref (comp);
-
- e_cal_component_get_uid (local->comp, &uid);
- local->local.ID = e_pilot_map_lookup_pid (ctxt->map, uid, TRUE);
- compute_status (ctxt, local, uid);
-
- local->appt = g_new0 (struct Appointment, 1);
-
- /* Handle the fields and category we don't sync by making sure
- * we don't overwrite them
- */
- if (local->local.ID != 0) {
- gint cat = 0;
-#ifdef PILOT_LINK_0_12
- struct Appointment appt;
- pi_buffer_t * record;
-
- record = pi_buffer_new(DLP_BUF_SIZE);
- if (record == NULL) {
- pi_set_error(ctxt->dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
- return;
- }
-#else
- struct Appointment appt;
- gchar record[0xffff];
-#endif
- if (dlp_ReadRecordById (ctxt->dbi->pilot_socket,
- ctxt->dbi->db_handle,
-#ifdef PILOT_LINK_0_12
- local->local.ID, record,
- NULL, NULL, &cat) > 0) {
-#else
- local->local.ID, &record,
- NULL, NULL, NULL, &cat) > 0) {
-#endif
- local->local.category = cat;
- memset (&appt, 0, sizeof (struct Appointment));
-#ifdef PILOT_LINK_0_12
- unpack_Appointment (&appt, record, datebook_v1);
-#else
- unpack_Appointment (&appt, (guchar *)record, 0xffff);
-#endif
- local->appt->alarm = appt.alarm;
- local->appt->advance = appt.advance;
- local->appt->advanceUnits = appt.advanceUnits;
- free_Appointment (&appt);
- }
-#ifdef PILOT_LINK_0_12
- pi_buffer_free (record);
-#endif
- }
-
- /*Category support*/
- e_pilot_local_category_to_remote(&(local->local.category), comp, &(ctxt->ai.category), ctxt->pilot_charset);
-
- /* STOP: don't replace these with g_strdup, since free_Appointment
- uses free to deallocate */
- e_cal_component_get_summary (comp, &summary);
- if (summary.value)
- local->appt->description = e_pilot_utf8_to_pchar (summary.value, ctxt->pilot_charset);
-
- e_cal_component_get_description_list (comp, &d_list);
- if (d_list) {
- description = (ECalComponentText *) d_list->data;
- if (description && description->value)
- local->appt->note = e_pilot_utf8_to_pchar (description->value, ctxt->pilot_charset);
- else
- local->appt->note = NULL;
- } else {
- local->appt->note = NULL;
- }
-
- /* Start/End */
- e_cal_component_get_dtstart (comp, &dt_start);
- e_cal_component_get_dtend (comp, &dt_end);
- if (dt_start.value) {
- icaltimezone_convert_time (dt_start.value,
- get_timezone (ctxt->client, dt_start.tzid),
- default_tz);
- local->appt->begin = icaltimetype_to_tm (dt_start.value);
- }
-
- if (dt_start.value && dt_end.value) {
- if (is_all_day (ctxt->client, &dt_start, &dt_end)) {
- local->appt->event = 1;
- } else {
- icaltimezone_convert_time (dt_end.value,
- get_timezone (ctxt->client, dt_end.tzid),
- default_tz);
- local->appt->end = icaltimetype_to_tm (dt_end.value);
- local->appt->event = 0;
- }
- } else {
- local->appt->event = 1;
- }
- e_cal_component_free_datetime (&dt_start);
- e_cal_component_free_datetime (&dt_end);
-
- /* Recurrence Rules */
- local->appt->repeatType = repeatNone;
-
- if (!e_cal_component_is_instance (comp)) {
- if (e_cal_component_has_rrules (comp)) {
- GSList *list;
- struct icalrecurrencetype *recur;
-
- e_cal_component_get_rrule_list (comp, &list);
- recur = list->data;
-
- switch (recur->freq) {
- case ICAL_DAILY_RECURRENCE:
- local->appt->repeatType = repeatDaily;
- break;
- case ICAL_WEEKLY_RECURRENCE:
- local->appt->repeatType = repeatWeekly;
- for (i = 0; i <= 7 && recur->by_day[i] != ICAL_RECURRENCE_ARRAY_MAX; i++) {
- icalrecurrencetype_weekday wd;
-
- wd = icalrecurrencetype_day_day_of_week (recur->by_day[i]);
- local->appt->repeatDays[get_pilot_day (wd)] = 1;
- }
-
- break;
- case ICAL_MONTHLY_RECURRENCE:
- if (recur->by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) {
- local->appt->repeatType = repeatMonthlyByDate;
- break;
- }
-
- /* Not going to work with -ve by_day/by_set_pos other than -1,
- * pilot doesn't support that anyhow */
- local->appt->repeatType = repeatMonthlyByDay;
- switch (recur->by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX ? recur->by_set_pos[0]
- : icalrecurrencetype_day_position (recur->by_day[0])) {
- case 1:
- local->appt->repeatDay = dom1stSun;
- break;
- case 2:
- local->appt->repeatDay = dom2ndSun;
- break;
- case 3:
- local->appt->repeatDay = dom3rdSun;
- break;
- case 4:
- local->appt->repeatDay = dom4thSun;
- break;
- case -1:
- case 5:
- local->appt->repeatDay = domLastSun;
- break;
- }
- local->appt->repeatDay += get_pilot_day (icalrecurrencetype_day_day_of_week (recur->by_day[0]));
- break;
- case ICAL_YEARLY_RECURRENCE:
- local->appt->repeatType = repeatYearly;
- break;
- default:
- break;
- }
-
- if (local->appt->repeatType != repeatNone) {
- local->appt->repeatFrequency = recur->interval;
- }
-
- if (!icaltime_is_null_time (recur->until)) {
- local->appt->repeatForever = 0;
- local->appt->repeatEnd = icaltimetype_to_tm_with_zone (&recur->until,
- icaltimezone_get_utc_timezone (),
- default_tz);
- } else if (recur->count > 0) {
- time_t last = -1;
- struct icaltimetype itt;
-
- /* The palm does not support count recurrences */
- local->appt->repeatForever = 0;
- e_cal_recur_generate_instances (comp, -1, -1, find_last_cb, &last,
- e_cal_resolve_tzid_cb, ctxt->client,
- default_tz);
- itt = icaltime_from_timet_with_zone (last, TRUE, default_tz);
- local->appt->repeatEnd = icaltimetype_to_tm (&itt);
- } else {
- local->appt->repeatForever = 1;
- }
-
- e_cal_component_free_recur_list (list);
- }
-
- /* Exceptions */
- e_cal_component_get_exdate_list (comp, &edl);
- local->appt->exceptions = g_slist_length (edl);
- local->appt->exception = g_new0 (struct tm, local->appt->exceptions);
- for (l = edl, i = 0; l != NULL; l = l->next, i++) {
- ECalComponentDateTime *dt = l->data;
-
- icaltimezone_convert_time (dt->value,
- icaltimezone_get_utc_timezone (),
- default_tz);
- local->appt->exception[i] = icaltimetype_to_tm (dt->value);
- }
- e_cal_component_free_exdate_list (edl);
- }
-
- /* Alarm */
- local->appt->alarm = 0;
- if (e_cal_component_has_alarms (comp)) {
- GList *uids, *l;
- ECalComponentAlarm *alarm;
- ECalComponentAlarmTrigger trigger;
-
- uids = e_cal_component_get_alarm_uids (comp);
- for (l = uids; l != NULL; l = l->next) {
- alarm = e_cal_component_get_alarm (comp, l->data);
- e_cal_component_alarm_get_trigger (alarm, &trigger);
- e_cal_component_alarm_free (alarm);
-
- if (trigger.type == E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START) {
- if (trigger.u.rel_duration.is_neg) {
- local->appt->advanceUnits = advMinutes;
- local->appt->advance =
- trigger.u.rel_duration.minutes
- + trigger.u.rel_duration.hours * 60
- + trigger.u.rel_duration.days * 60 * 24
- + trigger.u.rel_duration.weeks * 7 * 60 * 24;
-
- if (local->appt->advance > PILOT_MAX_ADVANCE) {
- local->appt->advanceUnits = advHours;
- local->appt->advance =
- trigger.u.rel_duration.minutes / 60
- + trigger.u.rel_duration.hours
- + trigger.u.rel_duration.days * 24
- + trigger.u.rel_duration.weeks * 7 * 24;
- }
- if (local->appt->advance > PILOT_MAX_ADVANCE) {
- local->appt->advanceUnits = advDays;
- local->appt->advance =
- trigger.u.rel_duration.minutes / (60 * 24)
- + trigger.u.rel_duration.hours / 24
- + trigger.u.rel_duration.days
- + trigger.u.rel_duration.weeks * 7;
- }
- if (local->appt->advance > PILOT_MAX_ADVANCE)
- local->appt->advance = PILOT_MAX_ADVANCE;
-
- local->appt->alarm = 1;
- break;
- } else if (icaldurationtype_is_null_duration (trigger.u.rel_duration)) {
- local->appt->advanceUnits = advMinutes;
- local->appt->advance = 0;
- local->appt->alarm = 1;
- break;
- }
- }
- }
- cal_obj_uid_list_free (uids);
- }
-
- e_cal_component_get_classification (comp, &classif);
-
- if (classif == E_CAL_COMPONENT_CLASS_PRIVATE)
- local->local.secret = 1;
- else
- local->local.secret = 0;
-
- local->local.archived = 0;
-}
-
-static void
-local_record_from_uid (ECalLocalRecord *local,
- const gchar *uid,
- ECalConduitContext *ctxt)
-{
- ECalComponent *comp;
- icalcomponent *icalcomp;
- GError *error = NULL;
-
- g_assert(local!=NULL);
-
- if (e_cal_get_object (ctxt->client, uid, NULL, &icalcomp, &error)) {
- comp = e_cal_component_new ();
- if (!e_cal_component_set_icalcomponent (comp, icalcomp)) {
- g_object_unref (comp);
- icalcomponent_free (icalcomp);
- return;
- }
-
- local_record_from_comp (local, comp, ctxt);
- g_object_unref (comp);
- } else if (error->code == E_CALENDAR_STATUS_OBJECT_NOT_FOUND) {
- comp = e_cal_component_new ();
- e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT);
- e_cal_component_set_uid (comp, uid);
- local_record_from_comp (local, comp, ctxt);
- g_object_unref (comp);
- } else {
- INFO ("Object did not exist");
- }
-
- g_clear_error (&error);
-}
-
-static ECalComponent *
-comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
- GnomePilotRecord *remote,
- ECalComponent *in_comp,
- ECal *client,
- icaltimezone *timezone,
- struct CategoryAppInfo *category,
- const gchar *pilot_charset)
-{
- ECalComponent *comp;
- struct Appointment appt;
- struct icaltimetype now = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ()), it;
- struct icalrecurrencetype recur;
- ECalComponentText summary = {NULL, NULL};
- ECalComponentDateTime dt = {NULL, NULL};
- GSList *edl = NULL;
- gchar *txt;
- gint pos, i;
-#ifdef PILOT_LINK_0_12
- pi_buffer_t * buffer;
-#endif
- g_return_val_if_fail (remote != NULL, NULL);
-
-#ifdef PILOT_LINK_0_12
- buffer = pi_buffer_new(DLP_BUF_SIZE);
- if (buffer == NULL) {
- return NULL;
- }
-
- if (pi_buffer_append(buffer, remote->record, remote->length)==NULL) {
- return NULL;
- }
-
- unpack_Appointment (&appt, buffer, datebook_v1);
- pi_buffer_free(buffer);
-
-#else
- memset (&appt, 0, sizeof (struct Appointment));
- unpack_Appointment (&appt, remote->record, remote->length);
-#endif
- if (in_comp == NULL) {
- comp = e_cal_component_new ();
- e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT);
- e_cal_component_set_created (comp, &now);
- } else {
- comp = e_cal_component_clone (in_comp);
- }
-
- e_cal_component_set_last_modified (comp, &now);
-
- summary.value = txt = e_pilot_utf8_from_pchar (appt.description, pilot_charset);
- e_cal_component_set_summary (comp, &summary);
- free (txt);
-
- /*Category support*/
- e_pilot_remote_category_to_local(remote->category, comp, category, pilot_charset);
-
- /* The iCal description field */
- if (!appt.note) {
- e_cal_component_set_description_list (comp, NULL);
- } else {
- GSList l;
- ECalComponentText text;
-
- text.value = txt = e_pilot_utf8_from_pchar (appt.note, pilot_charset);
- text.altrep = NULL;
- l.data = &text;
- l.next = NULL;
-
- e_cal_component_set_description_list (comp, &l);
- free (txt);
- }
-
- if (appt.event && !is_empty_time (appt.begin)) {
- it = tm_to_icaltimetype (&appt.begin, TRUE);
- dt.value = &it;
- dt.tzid = NULL;
- e_cal_component_set_dtstart (comp, &dt);
- e_cal_component_set_dtend (comp, &dt);
- } else {
- dt.tzid = icaltimezone_get_tzid (timezone);
-
- if (!is_empty_time (appt.begin)) {
- it = tm_to_icaltimetype (&appt.begin, FALSE);
- dt.value = &it;
- e_cal_component_set_dtstart (comp, &dt);
- }
-
- if (!is_empty_time (appt.end)) {
- it = tm_to_icaltimetype (&appt.end, FALSE);
- dt.value = &it;
- e_cal_component_set_dtend (comp, &dt);
- }
- }
-
- /* Recurrence information */
- icalrecurrencetype_clear (&recur);
-
- switch (appt.repeatType) {
- case repeatNone:
- recur.freq = ICAL_NO_RECURRENCE;
- break;
-
- case repeatDaily:
- recur.freq = ICAL_DAILY_RECURRENCE;
- recur.interval = appt.repeatFrequency;
- break;
-
- case repeatWeekly:
- recur.freq = ICAL_WEEKLY_RECURRENCE;
- recur.interval = appt.repeatFrequency;
-
- pos = 0;
- for (i = 0; i < 7; i++) {
- if (appt.repeatDays[i])
- recur.by_day[pos++] = get_ical_day (i);
- }
-
- break;
-
- case repeatMonthlyByDay:
- recur.freq = ICAL_MONTHLY_RECURRENCE;
- recur.interval = appt.repeatFrequency;
- if (appt.repeatDay < domLastSun)
- recur.by_day[0] = nth_weekday ((appt.repeatDay / 7) + 1,
- get_ical_day (appt.repeatDay % 7));
- else
- recur.by_day[0] = nth_weekday (-1, get_ical_day (appt.repeatDay % 7));
- break;
-
- case repeatMonthlyByDate:
- recur.freq = ICAL_MONTHLY_RECURRENCE;
- recur.interval = appt.repeatFrequency;
- recur.by_month_day[0] = appt.begin.tm_mday;
- break;
-
- case repeatYearly:
- recur.freq = ICAL_YEARLY_RECURRENCE;
- recur.interval = appt.repeatFrequency;
- break;
-
- default:
- g_assert_not_reached ();
- }
-
- if (recur.freq != ICAL_NO_RECURRENCE) {
- GSList *list = NULL, *existing;
- struct icalrecurrencetype *erecur;
-
- /* recurrence start of week */
- recur.week_start = get_ical_day (appt.repeatWeekstart);
-
- if (!appt.repeatForever) {
- recur.until = tm_to_icaltimetype (&appt.repeatEnd, TRUE);
- }
-
- list = g_slist_append (list, &recur);
- e_cal_component_set_rrule_list (comp, list);
-
- /* If the desktop uses count and rrules are
- * equivalent, use count still on the desktop */
- if (!appt.repeatForever && e_cal_component_has_rrules (in_comp)) {
- e_cal_component_get_rrule_list (in_comp, &existing);
- erecur = existing->data;
-
- /* If the rules are otherwise the same and the existing uses count,
- see if they end at the same point */
- if (rrules_mostly_equal (&recur, erecur) &&
- icaltime_is_null_time (erecur->until) && erecur->count > 0) {
- time_t last, elast;
-
- e_cal_recur_generate_instances (comp, -1, -1, find_last_cb, &last,
- e_cal_resolve_tzid_cb, client,
- timezone);
- e_cal_recur_generate_instances (in_comp, -1, -1, find_last_cb, &elast,
- e_cal_resolve_tzid_cb, client,
- timezone);
-
- if (last == elast) {
- recur.until = icaltime_null_time ();
- recur.count = erecur->count;
- e_cal_component_set_rrule_list (comp, list);
- }
- }
- }
-
- g_slist_free (list);
- } else {
- e_cal_component_set_rrule_list (comp, NULL);
- }
-
- /* Exceptions */
- for (i = 0; i < appt.exceptions; i++) {
- struct tm ex;
- ECalComponentDateTime *dt = g_new0 (ECalComponentDateTime, 1);
-
- dt->value = g_new0 (struct icaltimetype, 1);
- dt->tzid = NULL;
-
- ex = appt.exception[i];
- *dt->value = tm_to_icaltimetype (&ex, TRUE);
-
- edl = g_slist_prepend (edl, dt);
- }
- e_cal_component_set_exdate_list (comp, edl);
- e_cal_component_free_exdate_list (edl);
-
- /* Alarm */
- if (appt.alarm) {
- ECalComponentAlarm *alarm = NULL;
- ECalComponentAlarmTrigger trigger;
- gboolean found = FALSE;
-
- if (e_cal_component_has_alarms (comp)) {
- GList *uids, *l;
-
- uids = e_cal_component_get_alarm_uids (comp);
- for (l = uids; l != NULL; l = l->next) {
- alarm = e_cal_component_get_alarm (comp, l->data);
- e_cal_component_alarm_get_trigger (alarm, &trigger);
- if ((trigger.type == E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START
- && trigger.u.rel_duration.is_neg)) {
- found = TRUE;
- break;
- }
- e_cal_component_alarm_free (alarm);
- }
- cal_obj_uid_list_free (uids);
- }
- if (!found)
- alarm = e_cal_component_alarm_new ();
-
- memset (&trigger, 0, sizeof (ECalComponentAlarmTrigger));
- trigger.type = E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START;
- trigger.u.rel_duration.is_neg = 1;
- switch (appt.advanceUnits) {
- case advMinutes:
- trigger.u.rel_duration.minutes = appt.advance;
- break;
- case advHours:
- trigger.u.rel_duration.hours = appt.advance;
- break;
- case advDays:
- trigger.u.rel_duration.days = appt.advance;
- break;
- }
- e_cal_component_alarm_set_trigger (alarm, trigger);
- e_cal_component_alarm_set_action (alarm, E_CAL_COMPONENT_ALARM_DISPLAY);
-
- if (!found)
- e_cal_component_add_alarm (comp, alarm);
- e_cal_component_alarm_free (alarm);
- }
-
- e_cal_component_set_transparency (comp, E_CAL_COMPONENT_TRANSP_NONE);
-
- if (remote->secret)
- e_cal_component_set_classification (comp, E_CAL_COMPONENT_CLASS_PRIVATE);
- else
- e_cal_component_set_classification (comp, E_CAL_COMPONENT_CLASS_PUBLIC);
-
- e_cal_component_commit_sequence (comp);
-
- free_Appointment (&appt);
-
- return comp;
-}
-
-static void
-check_for_slow_setting (GnomePilotConduit *c, ECalConduitContext *ctxt)
-{
- GnomePilotConduitStandard *conduit = GNOME_PILOT_CONDUIT_STANDARD (c);
- gint map_count;
- const gchar *uri;
-
- /* If there are objects but no log */
- map_count = g_hash_table_size (ctxt->map->pid_map);
- if (map_count == 0)
- gnome_pilot_conduit_standard_set_slow (conduit, TRUE);
-
- /* Or if the URI's don't match */
- uri = e_cal_get_uri (ctxt->client);
- LOG (g_message ( " Current URI %s (%s)\n", uri, ctxt->cfg->last_uri ? ctxt->cfg->last_uri : "<NONE>" ));
- if (ctxt->cfg->last_uri != NULL && strcmp (ctxt->cfg->last_uri, uri)) {
- gnome_pilot_conduit_standard_set_slow (conduit, TRUE);
- e_pilot_map_clear (ctxt->map);
- }
-
- if (gnome_pilot_conduit_standard_get_slow (conduit)) {
- ctxt->map->write_touched_only = TRUE;
- LOG (g_message ( " doing slow sync\n" ));
- } else {
- LOG (g_message ( " doing fast sync\n" ));
- }
-}
-
-/* Pilot syncing callbacks */
-static gint
-pre_sync (GnomePilotConduit *conduit,
- GnomePilotDBInfo *dbi,
- ECalConduitContext *ctxt)
-{
- GnomePilotConduitSyncAbs *abs_conduit;
- GList *removed = NULL, *added = NULL, *l;
- gint len;
- guchar *buf;
- gchar *filename, *change_id;
- icalcomponent *icalcomp;
- gint num_records, add_records = 0, mod_records = 0, del_records = 0;
-#ifdef PILOT_LINK_0_12
- pi_buffer_t * buffer;
-#endif
- abs_conduit = GNOME_PILOT_CONDUIT_SYNC_ABS (conduit);
-
- LOG (g_message ( "---------------------------------------------------------\n" ));
- LOG (g_message ( "pre_sync: Calendar Conduit v.%s", CONDUIT_VERSION ));
-
- ctxt->dbi = dbi;
-#ifdef PILOT_LINK_0_12
- if (NULL == dbi->pilotInfo->pilot_charset)
- ctxt->pilot_charset = NULL;
- else
- ctxt->pilot_charset = g_strdup(dbi->pilotInfo->pilot_charset);
-#endif
- ctxt->client = NULL;
-
- /* Get the timezone */
- ctxt->timezone = get_default_timezone ();
- if (ctxt->timezone == NULL)
- return -1;
- LOG (g_message ( " Using timezone: %s", icaltimezone_get_tzid (ctxt->timezone) ));
-
- if (start_calendar_server (ctxt) != 0) {
- WARN(_("Could not start evolution-data-server"));
- gnome_pilot_conduit_error (conduit, _("Could not start evolution-data-server"));
- return -1;
- }
-
- /* Get the default component */
- if (!e_cal_get_default_object (ctxt->client, &icalcomp, NULL))
- return -1;
-
- ctxt->default_comp = e_cal_component_new ();
- if (!e_cal_component_set_icalcomponent (ctxt->default_comp, icalcomp)) {
- g_object_unref (ctxt->default_comp);
- icalcomponent_free (icalcomp);
- return -1;
- }
-
- /* Load the uid <--> pilot id mapping */
- filename = map_name (ctxt);
- e_pilot_map_read (filename, &ctxt->map);
- g_free (filename);
-
- /* Get the local database */
- if (!e_cal_get_object_list_as_comp (ctxt->client, "#t", &ctxt->comps, NULL))
- return -1;
-
- /* Find the added, modified and deleted items */
- change_id = g_strdup_printf ("pilot-sync-evolution-calendar-%d", ctxt->cfg->pilot_id);
- if (!e_cal_get_changes (ctxt->client, change_id, &ctxt->changed, NULL))
- return -1;
- ctxt->changed_hash = g_hash_table_new (g_str_hash, g_str_equal);
- g_free (change_id);
-
- /* See if we need to split up any events */
- for (l = ctxt->changed; l != NULL; l = l->next) {
- ECalChange *ccc = l->data;
- GList *multi_comp = NULL, *multi_ccc = NULL;
-
- if (process_multi_day (ctxt, ccc, &multi_comp, &multi_ccc)) {
- ctxt->comps = g_list_concat (ctxt->comps, multi_comp);
-
- added = g_list_concat (added, multi_ccc);
- removed = g_list_prepend (removed, ccc);
- }
- }
-
- /* Remove the events that were split up */
- ctxt->changed = g_list_concat (ctxt->changed, added);
- for (l = removed; l != NULL; l = l->next) {
- ECalChange *ccc = l->data;
- const gchar *uid;
-
- e_cal_component_get_uid (ccc->comp, &uid);
- if (e_pilot_map_lookup_pid (ctxt->map, uid, FALSE) == 0) {
- ctxt->changed = g_list_remove (ctxt->changed, ccc);
- g_object_unref (ccc->comp);
- g_free (ccc);
- }
- }
- g_list_free (removed);
-
- for (l = ctxt->changed; l != NULL; l = l->next) {
- ECalChange *ccc = l->data;
- const gchar *uid;
-
- e_cal_component_get_uid (ccc->comp, &uid);
- if (!e_pilot_map_uid_is_archived (ctxt->map, uid)) {
-
- g_hash_table_insert (ctxt->changed_hash, g_strdup (uid), ccc);
-
- switch (ccc->type) {
- case E_CAL_CHANGE_ADDED:
- add_records++;
- break;
- case E_CAL_CHANGE_MODIFIED:
- mod_records++;
- break;
- case E_CAL_CHANGE_DELETED:
- del_records++;
- break;
- }
- } else if (ccc->type == E_CAL_CHANGE_DELETED) {
- e_pilot_map_remove_by_uid (ctxt->map, uid);
- }
- }
-
- /* Set the count information */
- num_records = g_list_length (ctxt->comps);
- gnome_pilot_conduit_sync_abs_set_num_local_records(abs_conduit, num_records);
- gnome_pilot_conduit_sync_abs_set_num_new_local_records (abs_conduit, add_records);
- gnome_pilot_conduit_sync_abs_set_num_updated_local_records (abs_conduit, mod_records);
- gnome_pilot_conduit_sync_abs_set_num_deleted_local_records(abs_conduit, del_records);
-
-#ifdef PILOT_LINK_0_12
- buffer = pi_buffer_new(DLP_BUF_SIZE);
- if (buffer == NULL) {
- pi_set_error(dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
- return -1;
- }
-
- len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
- DLP_BUF_SIZE,
- buffer);
-#else
- buf = (guchar *)g_malloc (0xffff);
- len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
- (guchar *)buf, 0xffff);
-#endif
- if (len < 0) {
- WARN (_("Could not read pilot's Calendar application block"));
- WARN ("dlp_ReadAppBlock(...) = %d", len);
- gnome_pilot_conduit_error (conduit,
- _("Could not read pilot's Calendar application block"));
- return -1;
- }
-#ifdef PILOT_LINK_0_12
- buf = g_new0 (unsigned char,buffer->used);
- memcpy(buf, buffer->data, buffer->used);
- pi_buffer_free(buffer);
-#endif
- unpack_AppointmentAppInfo (&(ctxt->ai), buf, len);
- /* unpack_CategoryAppInfo (&(ctxt->ai.category), buf, len); */
- g_free (buf);
-
- check_for_slow_setting (conduit, ctxt);
- if (ctxt->cfg->sync_type == GnomePilotConduitSyncTypeCopyToPilot
- || ctxt->cfg->sync_type == GnomePilotConduitSyncTypeCopyFromPilot)
- ctxt->map->write_touched_only = TRUE;
-
- return 0;
-}
-
-static gint
-post_sync (GnomePilotConduit *conduit,
- GnomePilotDBInfo *dbi,
- ECalConduitContext *ctxt)
-{
- GList *changed;
- gchar *filename, *change_id;
- guchar *buf;
- gint dlpRetVal, len;
-
- LOG (g_message ( "post_sync: Calendar Conduit v.%s", CONDUIT_VERSION ));
-
- /* Write AppBlock to PDA - updates categories */
- buf = (guchar *)g_malloc (0xffff);
-
- len = pack_AppointmentAppInfo (&(ctxt->ai), buf, 0xffff);
-
- dlpRetVal = dlp_WriteAppBlock (dbi->pilot_socket, dbi->db_handle,
- (guchar *)buf, len);
-
- g_free (buf);
-
- if (dlpRetVal < 0) {
- WARN ( ("Could not write pilot's Calendar application block"));
- WARN ("dlp_WriteAppBlock(...) = %d", dlpRetVal);
- /*gnome_pilot_conduit_error (conduit,
- _("Could not write pilot's Calendar application block"));*/
- return -1;
- }
-
- g_free (ctxt->cfg->last_uri);
- ctxt->cfg->last_uri = g_strdup (e_cal_get_uri (ctxt->client));
- calconduit_save_configuration (ctxt->cfg);
-
- filename = map_name (ctxt);
- e_pilot_map_write (filename, ctxt->map);
- g_free (filename);
-
- /* FIX ME ugly hack - our changes musn't count, this does introduce
- * a race condition if anyone changes a record elsewhere during sycnc
- */
- change_id = g_strdup_printf ("pilot-sync-evolution-calendar-%d", ctxt->cfg->pilot_id);
- if (e_cal_get_changes (ctxt->client, change_id, &changed, NULL))
- e_cal_free_change_list (changed);
- g_free (change_id);
- if (ctxt->pilot_charset)
- g_free (ctxt->pilot_charset);
-
- LOG (g_message ( "---------------------------------------------------------\n" ));
-
- return 0;
-}
-
-static gint
-set_pilot_id (GnomePilotConduitSyncAbs *conduit,
- ECalLocalRecord *local,
- guint32 ID,
- ECalConduitContext *ctxt)
-{
- const gchar *uid;
-
- LOG (g_message ( "set_pilot_id: setting to %d\n", ID ));
-
- e_cal_component_get_uid (local->comp, &uid);
- e_pilot_map_insert (ctxt->map, ID, uid, FALSE);
-
- return 0;
-}
-
-static gint
-set_status_cleared (GnomePilotConduitSyncAbs *conduit,
- ECalLocalRecord *local,
- ECalConduitContext *ctxt)
-{
- const gchar *uid;
-
- LOG (g_message ( "set_status_cleared: clearing status\n" ));
-
- e_cal_component_get_uid (local->comp, &uid);
- g_hash_table_remove (ctxt->changed_hash, uid);
-
- return 0;
-}
-
-static gint
-for_each (GnomePilotConduitSyncAbs *conduit,
- ECalLocalRecord **local,
- ECalConduitContext *ctxt)
-{
- static GList *comps, *iterator;
- static gint count;
- GList *unused;
-
- g_return_val_if_fail (local != NULL, -1);
-
- if (*local == NULL) {
- LOG (g_message ( "beginning for_each" ));
-
- comps = ctxt->comps;
- count = 0;
-
- if (comps != NULL) {
- LOG (g_message ( "iterating over %d records", g_list_length (comps)));
-
- *local = g_new0 (ECalLocalRecord, 1);
- local_record_from_comp (*local, comps->data, ctxt);
-
- /* NOTE: ignore the return value, otherwise ctxt->locals
- * gets messed up. The calling function keeps track of
- * the *local variable */
- unused = g_list_prepend (ctxt->locals, *local);
-
- iterator = comps;
- } else {
- LOG (g_message ( "no events" ));
- (*local) = NULL;
- return 0;
- }
- } else {
- count++;
- if (g_list_next (iterator)) {
- iterator = g_list_next (iterator);
-
- *local = g_new0 (ECalLocalRecord, 1);
- local_record_from_comp (*local, iterator->data, ctxt);
-
- /* NOTE: ignore the return value, otherwise ctxt->locals
- * gets messed up. The calling function keeps track of
- * the *local variable */
- unused = g_list_prepend (ctxt->locals, *local);
- } else {
- LOG (g_message ( "for_each ending" ));
-
- /* Tell the pilot the iteration is over */
- *local = NULL;
-
- return 0;
- }
- }
-
- return 0;
-}
-
-static gint
-for_each_modified (GnomePilotConduitSyncAbs *conduit,
- ECalLocalRecord **local,
- ECalConduitContext *ctxt)
-{
- static GList *iterator;
- static gint count;
- GList *unused;
-
- g_return_val_if_fail (local != NULL, -1);
-
- if (*local == NULL) {
- LOG (g_message ( "for_each_modified beginning\n" ));
-
- iterator = ctxt->changed;
-
- count = 0;
-
- LOG (g_message ( "iterating over %d records", g_hash_table_size (ctxt->changed_hash) ));
-
- iterator = next_changed_item (ctxt, iterator);
- if (iterator != NULL) {
- ECalChange *ccc = iterator->data;
-
- *local = g_new0 (ECalLocalRecord, 1);
- local_record_from_comp (*local, ccc->comp, ctxt);
-
- /* NOTE: ignore the return value, otherwise ctxt->locals
- * gets messed up. The calling function keeps track of
- * the *local variable */
- unused = g_list_prepend (ctxt->locals, *local);
- } else {
- LOG (g_message ( "no events" ));
-
- *local = NULL;
- }
- } else {
- count++;
- iterator = g_list_next (iterator);
- if (iterator && (iterator = next_changed_item (ctxt, iterator))) {
- ECalChange *ccc = iterator->data;
-
- *local = g_new0 (ECalLocalRecord, 1);
- local_record_from_comp (*local, ccc->comp, ctxt);
-
- /* NOTE: ignore the return value, otherwise ctxt->locals
- * gets messed up. The calling function keeps track of
- * the *local variable */
- unused = g_list_prepend (ctxt->locals, *local);
- } else {
- LOG (g_message ( "for_each_modified ending" ));
-
- /* Signal the iteration is over */
- *local = NULL;
- }
- }
-
- return 0;
-}
-
-static gint
-compare (GnomePilotConduitSyncAbs *conduit,
- ECalLocalRecord *local,
- GnomePilotRecord *remote,
- ECalConduitContext *ctxt)
-{
- /* used by the quick compare */
- GnomePilotRecord local_pilot;
- gint retval = 0;
-
- LOG (g_message ("compare: local=%s remote=%s...\n",
- print_local (local), print_remote (remote)));
-
- g_return_val_if_fail (local!=NULL,-1);
- g_return_val_if_fail (remote!=NULL,-1);
-
- local_pilot = local_record_to_pilot_record (local, ctxt);
-
- if (remote->length != local_pilot.length
- || memcmp (local_pilot.record, remote->record, remote->length))
- retval = 1;
-
- if (retval == 0)
- LOG (g_message ( " equal" ));
- else
- LOG (g_message ( " not equal" ));
-
- return retval;
-}
-
-static gint
-add_record (GnomePilotConduitSyncAbs *conduit,
- GnomePilotRecord *remote,
- ECalConduitContext *ctxt)
-{
- ECalComponent *comp;
- gchar *uid;
- gint retval = 0;
-
- g_return_val_if_fail (remote != NULL, -1);
-
- LOG (g_message ( "add_record: adding %s to desktop\n", print_remote (remote) ));
-
- comp = comp_from_remote_record (conduit, remote, ctxt->default_comp, ctxt->client, ctxt->timezone, &(ctxt->ai.category), ctxt->pilot_charset);
-
- /* Give it a new UID otherwise it will be the uid of the default comp */
- uid = e_cal_component_gen_uid ();
- e_cal_component_set_uid (comp, uid);
-
- if (!e_cal_create_object (ctxt->client, e_cal_component_get_icalcomponent (comp), NULL, NULL))
- return -1;
-
- e_pilot_map_insert (ctxt->map, remote->ID, uid, FALSE);
-
- g_free (uid);
-
- g_object_unref (comp);
-
- return retval;
-}
-
-static gint
-replace_record (GnomePilotConduitSyncAbs *conduit,
- ECalLocalRecord *local,
- GnomePilotRecord *remote,
- ECalConduitContext *ctxt)
-{
- ECalComponent *new_comp;
- gint retval = 0;
-
- g_return_val_if_fail (remote != NULL, -1);
-
- LOG (g_message ("replace_record: replace %s with %s\n",
- print_local (local), print_remote (remote)));
-
- new_comp = comp_from_remote_record (conduit, remote, local->comp, ctxt->client, ctxt->timezone, &(ctxt->ai.category),
-ctxt->pilot_charset);
- g_object_unref (local->comp);
- local->comp = new_comp;
-
- if (!e_cal_modify_object (ctxt->client, e_cal_component_get_icalcomponent (new_comp),
- CALOBJ_MOD_ALL, NULL))
- return -1;
-
- return retval;
-}
-
-static gint
-delete_record (GnomePilotConduitSyncAbs *conduit,
- ECalLocalRecord *local,
- ECalConduitContext *ctxt)
-{
- const gchar *uid;
-
- g_return_val_if_fail (local != NULL, -1);
- g_assert (local->comp != NULL);
-
- e_cal_component_get_uid (local->comp, &uid);
-
- LOG (g_message ( "delete_record: deleting %s\n", uid ));
-
- e_pilot_map_remove_by_uid (ctxt->map, uid);
- /* FIXME Error handling */
- if (e_cal_component_is_instance (local->comp) || e_cal_component_has_recurrences (local->comp))
- e_cal_remove_object_with_mod (ctxt->client, uid, NULL, CALOBJ_MOD_ALL, NULL);
- else
- e_cal_remove_object (ctxt->client, uid, NULL);
-
- return 0;
-}
-
-static gint
-archive_record (GnomePilotConduitSyncAbs *conduit,
- ECalLocalRecord *local,
- gboolean archive,
- ECalConduitContext *ctxt)
-{
- const gchar *uid;
- gint retval = 0;
-
- g_return_val_if_fail (local != NULL, -1);
-
- LOG (g_message ( "archive_record: %s\n", archive ? "yes" : "no" ));
-
- e_cal_component_get_uid (local->comp, &uid);
- e_pilot_map_insert (ctxt->map, local->local.ID, uid, archive);
-
- return retval;
-}
-
-static gint
-match (GnomePilotConduitSyncAbs *conduit,
- GnomePilotRecord *remote,
- ECalLocalRecord **local,
- ECalConduitContext *ctxt)
-{
- const gchar *uid;
-
- LOG (g_message ("match: looking for local copy of %s\n",
- print_remote (remote)));
-
- g_return_val_if_fail (local != NULL, -1);
- g_return_val_if_fail (remote != NULL, -1);
-
- *local = NULL;
- uid = e_pilot_map_lookup_uid (ctxt->map, remote->ID, TRUE);
-
- if (!uid)
- return 0;
-
- LOG (g_message ( " matched\n" ));
-
- *local = g_new0 (ECalLocalRecord, 1);
- local_record_from_uid (*local, uid, ctxt);
-
- return 0;
-}
-
-static gint
-free_match (GnomePilotConduitSyncAbs *conduit,
- ECalLocalRecord *local,
- ECalConduitContext *ctxt)
-{
- LOG (g_message ( "free_match: freeing\n" ));
-
- g_return_val_if_fail (local != NULL, -1);
-
- ctxt->locals = g_list_remove (ctxt->locals, local);
-
- calconduit_destroy_record (local);
-
- return 0;
-}
-
-static gint
-prepare (GnomePilotConduitSyncAbs *conduit,
- ECalLocalRecord *local,
- GnomePilotRecord *remote,
- ECalConduitContext *ctxt)
-{
- LOG (g_message ( "prepare: encoding local %s\n", print_local (local) ));
-
- *remote = local_record_to_pilot_record (local, ctxt);
-
- return 0;
-}
-
-/* Pilot Settings Callbacks */
-static void
-fill_widgets (ECalConduitContext *ctxt)
-{
- if (ctxt->cfg->source)
- e_pilot_settings_set_source (E_PILOT_SETTINGS (ctxt->ps),
- ctxt->cfg->source);
- e_pilot_settings_set_secret (E_PILOT_SETTINGS (ctxt->ps),
- ctxt->cfg->secret);
-
- e_cal_gui_fill_widgets (ctxt->gui, ctxt->cfg);
-}
-
-static gint
-create_settings_window (GnomePilotConduit *conduit,
- GtkWidget *parent,
- ECalConduitContext *ctxt)
-{
- LOG (g_message ( "create_settings_window" ));
-
- if (!ctxt->cfg->source_list)
- return -1;
-
- ctxt->ps = e_pilot_settings_new (ctxt->cfg->source_list);
- ctxt->gui = e_cal_gui_new (E_PILOT_SETTINGS (ctxt->ps));
-
- 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 (g_message ( "display_settings" ));
-
- fill_widgets (ctxt);
-}
-
-static void
-save_settings (GnomePilotConduit *conduit, ECalConduitContext *ctxt)
-{
- LOG (g_message ( "save_settings" ));
-
- if (ctxt->new_cfg->source)
- g_object_unref (ctxt->new_cfg->source);
- ctxt->new_cfg->source = g_object_ref (e_pilot_settings_get_source (E_PILOT_SETTINGS (ctxt->ps)));
- g_object_ref (ctxt->new_cfg->source);
- ctxt->new_cfg->secret =
- e_pilot_settings_get_secret (E_PILOT_SETTINGS (ctxt->ps));
- e_cal_gui_fill_config (ctxt->gui, ctxt->new_cfg);
-
- calconduit_save_configuration (ctxt->new_cfg);
-}
-
-static void
-revert_settings (GnomePilotConduit *conduit, ECalConduitContext *ctxt)
-{
- LOG (g_message ( "revert_settings" ));
-
- calconduit_save_configuration (ctxt->cfg);
- calconduit_destroy_configuration (ctxt->new_cfg);
- ctxt->new_cfg = calconduit_dupe_configuration (ctxt->cfg);
-}
-
-GnomePilotConduit *
-conduit_get_gpilot_conduit (guint32 pilot_id)
-{
- GtkObject *retval;
- ECalConduitContext *ctxt;
-
- LOG (g_message ( "in calendar's conduit_get_gpilot_conduit\n" ));
-
- retval = gnome_pilot_conduit_sync_abs_new ((gchar *)"DatebookDB", 0x64617465);
- g_assert (retval != NULL);
-
- ctxt = e_calendar_context_new (pilot_id);
- g_object_set_data (G_OBJECT (retval), "calconduit_context", ctxt);
-
- /* Sync signals */
- g_signal_connect (retval, "pre_sync", G_CALLBACK (pre_sync), ctxt);
- g_signal_connect (retval, "post_sync", G_CALLBACK (post_sync), ctxt);
-
- g_signal_connect (retval, "set_pilot_id", G_CALLBACK (set_pilot_id), ctxt);
- g_signal_connect (retval, "set_status_cleared", G_CALLBACK (set_status_cleared), ctxt);
-
- g_signal_connect (retval, "for_each", G_CALLBACK (for_each), ctxt);
- g_signal_connect (retval, "for_each_modified", G_CALLBACK (for_each_modified), ctxt);
- g_signal_connect (retval, "compare", G_CALLBACK (compare), ctxt);
-
- g_signal_connect (retval, "add_record", G_CALLBACK (add_record), ctxt);
- g_signal_connect (retval, "replace_record", G_CALLBACK (replace_record), ctxt);
- g_signal_connect (retval, "delete_record", G_CALLBACK (delete_record), ctxt);
- g_signal_connect (retval, "archive_record", G_CALLBACK (archive_record), ctxt);
-
- g_signal_connect (retval, "match", G_CALLBACK (match), ctxt);
- g_signal_connect (retval, "free_match", G_CALLBACK (free_match), ctxt);
-
- g_signal_connect (retval, "prepare", G_CALLBACK (prepare), ctxt);
-
- /* Gui Settings */
- g_signal_connect (retval, "create_settings_window", G_CALLBACK (create_settings_window), ctxt);
- g_signal_connect (retval, "display_settings", G_CALLBACK (display_settings), ctxt);
- g_signal_connect (retval, "save_settings", G_CALLBACK (save_settings), ctxt);
- g_signal_connect (retval, "revert_settings", G_CALLBACK (revert_settings), ctxt);
-
- return GNOME_PILOT_CONDUIT (retval);
-}
-
-void
-conduit_destroy_gpilot_conduit (GnomePilotConduit *conduit)
-{
- GtkObject *obj = GTK_OBJECT (conduit);
- ECalConduitContext *ctxt;
-
- ctxt = g_object_get_data (G_OBJECT (obj), "calconduit_context");
- e_calendar_context_destroy (ctxt);
-
- gtk_object_destroy (obj);
-}
diff --git a/calendar/conduits/calendar/e-calendar.conduit.in b/calendar/conduits/calendar/e-calendar.conduit.in
deleted file mode 100644
index 6ddcf5761a..0000000000
--- a/calendar/conduits/calendar/e-calendar.conduit.in
+++ /dev/null
@@ -1,9 +0,0 @@
-<gnome-pilot-conduit version="1.0">
- <conduit id="e_calendar_conduit" type="shlib" location="@privconduitdir@/libecalendar_conduit.so"/>
- <name value="ECalendar"/>
- <conduit-attribute name="description" value="Synchronizes Calendar with Evolution @BASE_VERSION@"/>
- <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="TRUE"/>
- <conduit-attribute name="icon" value="@datadir@/images/evolution/conduits/48_evo-calendar-conduit.png"/>
-</gnome-pilot-conduit>
diff --git a/calendar/conduits/common/Makefile.am b/calendar/conduits/common/Makefile.am
deleted file mode 100644
index 89b1288080..0000000000
--- a/calendar/conduits/common/Makefile.am
+++ /dev/null
@@ -1,24 +0,0 @@
-# Calendar Conduit library
-privconduit_LTLIBRARIES = libecalendar_common_conduit.la
-
-libecalendar_common_conduit_la_CPPFLAGS = \
- $(AM_CPPFLAGS) \
- -I$(top_srcdir) \
- -I$(top_srcdir)/e-util \
- -I$(top_builddir)/e-util \
- $(EVOLUTION_CALENDAR_CONDUIT_CFLAGS)
-
-ecalendar_common_conduitincludedir = $(privincludedir)/calendar/conduits/common
-
-ecalendar_common_conduitinclude_HEADERS = libecalendar-common-conduit.h
-
-libecalendar_common_conduit_la_SOURCES = libecalendar-common-conduit.c
-
-libecalendar_common_conduit_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED)
-
-libecalendar_common_conduit_la_LIBADD = \
- $(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/e-util/libeconduit.la \
- $(EVOLUTION_CALENDAR_CONDUIT_LIBS)
-
--include $(top_srcdir)/git.mk
diff --git a/calendar/conduits/common/libecalendar-common-conduit.c b/calendar/conduits/common/libecalendar-common-conduit.c
deleted file mode 100644
index 5a082461c6..0000000000
--- a/calendar/conduits/common/libecalendar-common-conduit.c
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * Evolution calendar - ToDo Conduit
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Tom Billet <mouse256@ulyssis.org>
- * Nathan Owens <pianocomp81@yahoo.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#include <string.h>
-
-#include <libedataserver/e-categories.h>
-#include <e-pilot-util.h>
-#include <pi-appinfo.h>
-#include <glib.h>
-#include <gconf/gconf-client.h>
-
-#include "libecalendar-common-conduit.h"
-
-/*make debugging possible if it's required for a conduit */
-#define LOG(x)
-#ifdef DEBUG_CALCONDUIT
-#define LOG(x) x
-#endif
-#ifdef DEBUG_MEMOCONDUIT
-#define LOG(x) x
-#endif
-#ifdef DEBUG_TODOCONDUIT
-#define LOG(x) x
-#endif
-#ifdef DEBUG_CONDUIT
-#define LOG(x) x
-#endif
-
-/*
- * Adds a category to the category app info structure (name and ID),
- * sets category->renamed[i] to true if possible to rename.
- *
- * This will be packed and written to the app info block during post_sync.
- *
- * NOTE: cat_to_add MUST be in PCHAR format. Evolution stores categories
- * in UTF-8 format. A conversion must take place before calling
- * this function (see e_pilot_utf8_to_pchar() in e-pilot-util.c)
- */
-gint
-e_pilot_add_category_if_possible(gchar *cat_to_add, struct CategoryAppInfo *category)
-{
- gint i, j;
- gint retval = 0; /* 0 is the Unfiled category */
- LOG(g_message("e_pilot_add_category_if_possible\n"));
-
- for (i=0; i<PILOT_MAX_CATEGORIES; i++) {
- /* if strlen is 0, then the category is empty
- the PalmOS doesn't let 0-length strings for
- categories */
- if (strlen(category->name[i]) == 0) {
- gint cat_to_add_len;
- gint desktopUniqueID;
-
- cat_to_add_len = strlen(cat_to_add);
- retval = i;
-
- if (cat_to_add_len > 15) {
- /* Have to truncate the category name */
- cat_to_add_len = 15;
- }
-
- /* only 15 characters for category, 16th is
- * '\0' can't do direct mem transfer due to
- * declaration type
- */
- for (j=0; j<cat_to_add_len; j++) {
- category->name[i][j] = cat_to_add[j];
- }
-
- for (j=cat_to_add_len; j<16; j++) {
- category->name[i][j] = '\0';
- }
-
- /* find a desktop id that is not in use between 128 and 255 */
- for (desktopUniqueID = 128; desktopUniqueID <= 255; desktopUniqueID++) {
- gint found = 0;
- for (j=0; j<PILOT_MAX_CATEGORIES; j++) {
- if (category->ID[i] == desktopUniqueID) {
- found = 1;
- }
- }
- if (found == 0) {
- break;
- }
- if (desktopUniqueID == 255) {
- LOG (g_warning ("*** no more categories available on PC ***"));
- }
- }
- category->ID[i] = desktopUniqueID;
-
- category->renamed[i] = TRUE;
-
- break;
- }
- }
-
- if (retval == 0) {
- LOG (g_warning ("*** not adding category - category list already full ***"));
- }
-
- return retval;
-}
-
-/*
- *conversion from an evolution category to a palm category
- */
-void e_pilot_local_category_to_remote(gint * pilotCategory, ECalComponent *comp, struct CategoryAppInfo *category, const gchar *pilot_charset)
-{
- GSList *c_list = NULL;
- gchar * category_string;
- gint i;
- e_cal_component_get_categories_list (comp, &c_list);
- if (c_list) {
- /* list != 0, so at least 1 category is assigned */
- category_string = e_pilot_utf8_to_pchar((const gchar *)c_list->data, pilot_charset);
- if (c_list->next != 0) {
- LOG (g_message ("Note: item has more categories in evolution, first chosen"));
- }
- i=1;
- while (1) {
- if (strcmp(category_string,category->name[i]) == 0) {
- *pilotCategory = i;
- break;
- }
- i++;
- if (i == PILOT_MAX_CATEGORIES) {
- /* category not available on palm, try to create it */
- *pilotCategory = e_pilot_add_category_if_possible(category_string,category);
- break;
- }
- }
- e_cal_component_free_categories_list(c_list);
- c_list = NULL;
- } else {
- *pilotCategory = 0;
- }
- /*end category*/
-}
-
-/*
- *conversion from a palm category to an evolution category
- */
-void e_pilot_remote_category_to_local(gint pilotCategory, ECalComponent *comp, struct CategoryAppInfo *category, const gchar *pilot_charset)
-{
- gchar *category_string = NULL;
-
- if (pilotCategory != 0) {
- /* pda has category assigned */
- category_string = e_pilot_utf8_from_pchar(category->name[pilotCategory], pilot_charset);
-
- LOG(g_message("Category: %s\n", category_string));
-
- /* TODO The calendar editor page and search bar are not updated until a restart of the evolution client */
- if (e_categories_exist(category_string) == FALSE) {
- /* add if it doesn't exist */
- LOG(g_message("Category created on pc\n"));
- e_categories_add(category_string, NULL, NULL, TRUE);
- }
- }
-
- /* store the data on in evolution */
- if (category_string == NULL) {
- /* note: this space is needed to make sure evolution clears the category */
- e_cal_component_set_categories (comp, " ");
- }
- else {
-
- /* Since only the first category is synced with the PDA, add the PDA's
- * category to the beginning of the category list */
- GSList *c_list = NULL;
- GSList *newcat_in_list;
- e_cal_component_get_categories_list (comp, &c_list);
-
- /* remove old item from list so we don't have duplicate entries */
- newcat_in_list = g_slist_find_custom(c_list, category_string, (GCompareFunc)strcmp);
- if (newcat_in_list != NULL)
- {
- c_list = g_slist_remove(c_list, newcat_in_list->data);
- }
-
- c_list = g_slist_prepend(c_list, category_string);
- e_cal_component_set_categories_list (comp, c_list);
- e_cal_component_free_categories_list(c_list);
- }
-}
-
-static gchar *
-build_setup_path (const gchar *path, const gchar *key)
-{
- return g_strconcat ("/apps/evolution/conduit", "/", path, "/", key, NULL);
-}
-
-gboolean
-e_pilot_setup_get_bool (const gchar *path, const gchar *key, gboolean def)
-{
- gboolean res = def;
- gchar *full_path;
- GConfValue *value;
- GConfClient *gconf;
-
- g_return_val_if_fail (path != NULL, res);
- g_return_val_if_fail (key != NULL, res);
-
- gconf = gconf_client_get_default ();
- full_path = build_setup_path (path, key);
-
- value = gconf_client_get (gconf, full_path, NULL);
- if (value) {
- if (value->type == GCONF_VALUE_BOOL)
- res = gconf_value_get_bool (value);
-
- gconf_value_free (value);
- }
-
- g_free (full_path);
- g_object_unref (gconf);
-
- return res;
-}
-
-void
-e_pilot_setup_set_bool (const gchar *path, const gchar *key, gboolean value)
-{
- GError *error = NULL;
- gchar *full_path;
- GConfClient *gconf;
-
- g_return_if_fail (path != NULL);
- g_return_if_fail (key != NULL);
-
- gconf = gconf_client_get_default ();
- full_path = build_setup_path (path, key);
-
- gconf_client_set_bool (gconf, full_path, value, &error);
-
- g_free (full_path);
- g_object_unref (gconf);
-
- if (error) {
- g_message ("%s: Failed to write: %s", G_STRFUNC, error->message);
- g_error_free (error);
- }
-}
-
-gint
-e_pilot_setup_get_int (const gchar *path, const gchar *key, gint def)
-{
- gint res = def;
- gchar *full_path;
- GConfValue *value;
- GConfClient *gconf;
-
- g_return_val_if_fail (path != NULL, res);
- g_return_val_if_fail (key != NULL, res);
-
- gconf = gconf_client_get_default ();
- full_path = build_setup_path (path, key);
-
- value = gconf_client_get (gconf, full_path, NULL);
- if (value) {
- if (value->type == GCONF_VALUE_INT)
- res = gconf_value_get_int (value);
-
- gconf_value_free (value);
- }
-
- g_free (full_path);
- g_object_unref (gconf);
-
- return res;
-}
-
-void
-e_pilot_setup_set_int (const gchar *path, const gchar *key, gint value)
-{
- GError *error = NULL;
- gchar *full_path;
- GConfClient *gconf;
-
- g_return_if_fail (path != NULL);
- g_return_if_fail (key != NULL);
-
- gconf = gconf_client_get_default ();
- full_path = build_setup_path (path, key);
-
- gconf_client_set_int (gconf, full_path, value, &error);
-
- g_free (full_path);
- g_object_unref (gconf);
-
- if (error) {
- g_message ("%s: Failed to write: %s", G_STRFUNC, error->message);
- g_error_free (error);
- }
-}
-
-gchar *
-e_pilot_setup_get_string (const gchar *path, const gchar *key, const gchar *def)
-{
- gchar *res = g_strdup (def);
- gchar *full_path;
- GConfValue *value;
- GConfClient *gconf;
-
- g_return_val_if_fail (path != NULL, res);
- g_return_val_if_fail (key != NULL, res);
-
- gconf = gconf_client_get_default ();
- full_path = build_setup_path (path, key);
-
- value = gconf_client_get (gconf, full_path, NULL);
- if (value) {
- if (value->type == GCONF_VALUE_STRING) {
- g_free (res);
- res = g_strdup (gconf_value_get_string (value));
- }
-
- gconf_value_free (value);
- }
-
- g_free (full_path);
- g_object_unref (gconf);
-
- return res;
-}
-
-void
-e_pilot_setup_set_string (const gchar *path, const gchar *key, const gchar *value)
-{
- GError *error = NULL;
- gchar *full_path;
- GConfClient *gconf;
-
- g_return_if_fail (path != NULL);
- g_return_if_fail (key != NULL);
- g_return_if_fail (value != NULL);
-
- gconf = gconf_client_get_default ();
- full_path = build_setup_path (path, key);
-
- gconf_client_set_string (gconf, full_path, value, &error);
-
- g_free (full_path);
- g_object_unref (gconf);
-
- if (error) {
- g_message ("%s: Failed to write: %s", G_STRFUNC, error->message);
- g_error_free (error);
- }
-}
diff --git a/calendar/conduits/common/libecalendar-common-conduit.h b/calendar/conduits/common/libecalendar-common-conduit.h
deleted file mode 100644
index 071403ac58..0000000000
--- a/calendar/conduits/common/libecalendar-common-conduit.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#include <libedataserver/e-categories.h>
-#include <libecal/e-cal.h>
-#include <pi-appinfo.h>
-
-#define PILOT_MAX_CATEGORIES 16
-
-gint e_pilot_add_category_if_possible(gchar *cat_to_add, struct CategoryAppInfo *category);
-void e_pilot_local_category_to_remote(gint * pilotCategory, ECalComponent *comp, struct CategoryAppInfo *category, const gchar *pilot_charset);
-void e_pilot_remote_category_to_local(gint pilotCategory, ECalComponent *comp, struct CategoryAppInfo *category, const gchar *pilot_charset);
-
-gboolean e_pilot_setup_get_bool (const gchar *path, const gchar *key, gboolean def);
-void e_pilot_setup_set_bool (const gchar *path, const gchar *key, gboolean value);
-gint e_pilot_setup_get_int (const gchar *path, const gchar *key, gint def);
-void e_pilot_setup_set_int (const gchar *path, const gchar *key, gint value);
-gchar *e_pilot_setup_get_string (const gchar *path, const gchar *key, const gchar *def);
-void e_pilot_setup_set_string (const gchar *path, const gchar *key, const gchar *value);
diff --git a/calendar/conduits/memo/Makefile.am b/calendar/conduits/memo/Makefile.am
deleted file mode 100644
index 84ccf1b9d9..0000000000
--- a/calendar/conduits/memo/Makefile.am
+++ /dev/null
@@ -1,43 +0,0 @@
-# Memo Conduit
-privconduit_LTLIBRARIES = libememo_conduit.la
-
-libememo_conduit_la_CPPFLAGS = \
- $(AM_CPPFLAGS) \
- -I$(top_srcdir)/e-util \
- -I$(top_builddir)/e-util \
- -I$(top_srcdir)/widgets/misc \
- -I$(top_builddir)/widgets/misc \
- -I$(top_srcdir)/calendar/conduits/common \
- -I$(top_builddir)/calendar/conduits/common \
- $(EVOLUTION_CALENDAR_CONDUIT_CFLAGS)
-
-libememo_conduit_la_SOURCES = memo-conduit.c
-
-libememo_conduit_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED)
-
-libememo_conduit_la_LIBADD = \
- $(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/e-util/libeconduit.la \
- $(top_builddir)/widgets/misc/libemiscwidgets.la \
- $(top_builddir)/calendar/conduits/common/libecalendar_common_conduit.la \
- $(EVOLUTION_CALENDAR_CONDUIT_LIBS)
-
-e-memo.conduit: e-memo.conduit.in
- sed -e 's^\@privconduitdir\@^$(privconduitdir)^g' \
- -e 's^\@datadir\@^$(datadir)^g' \
- -e 's^\@BASE_VERSION\@^$(BASE_VERSION)^g' \
- $< > $@
-
-conduitdir = $(datadir)/gnome-pilot/conduits/
-conduit_DATA = e-memo.conduit
-
-BUILT_SOURCES = $(conduit_DATA)
-CLEANFILES = $(BUILT_SOURCES)
-
-EXTRA_DIST = \
- e-memo.conduit.in
-
-dist-hook:
- cd $(distdir); rm -f $(BUILT_SOURCES)
-
--include $(top_srcdir)/git.mk
diff --git a/calendar/conduits/memo/e-memo.conduit.in b/calendar/conduits/memo/e-memo.conduit.in
deleted file mode 100644
index 1cf61436bd..0000000000
--- a/calendar/conduits/memo/e-memo.conduit.in
+++ /dev/null
@@ -1,8 +0,0 @@
-<gnome-pilot-conduit version="1.0">
- <conduit id="e_memo_conduit" type="shlib" location="@privconduitdir@/libememo_conduit.so"/>
- <name value="EMemos"/>
- <conduit-attribute name="description" value="Synchronizes Memo List with Evolution @BASE_VERSION@"/>
- <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="TRUE"/>
-</gnome-pilot-conduit>
diff --git a/calendar/conduits/memo/memo-conduit.c b/calendar/conduits/memo/memo-conduit.c
deleted file mode 100644
index d04e42b156..0000000000
--- a/calendar/conduits/memo/memo-conduit.c
+++ /dev/null
@@ -1,1442 +0,0 @@
-/*
- * Evolution calendar - Memo Conduit
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Eskil Heyn Olsen <deity@eskil.dk>
- * JP Rosevear <jpr@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#define G_LOG_DOMAIN "ememoconduit"
-
-/* Work around deprecated API usage in GnomePilot. */
-#undef GTK_DISABLE_DEPRECATED
-#undef GTK_DISABLE_SINGLE_INCLUDES
-
-#include <glib/gi18n.h>
-#include <libecal/e-cal-types.h>
-#include <libecal/e-cal.h>
-#include <libecal/e-cal-time-util.h>
-#include <libedataserver/e-categories.h>
-#include <pi-source.h>
-#include <pi-socket.h>
-#include <pi-dlp.h>
-#include <pi-memo.h>
-#include <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>
-#include <libecalendar-common-conduit.h>
-
-GnomePilotConduit * conduit_get_gpilot_conduit (guint32);
-void conduit_destroy_gpilot_conduit (GnomePilotConduit*);
-
-#define CONDUIT_VERSION "0.1.6"
-
-#define DEBUG_MEMOCONDUIT 1
-/* #undef DEBUG_MEMOCONDUIT */
-
-#ifdef DEBUG_MEMOCONDUIT
-#define LOG(x) x
-#else
-#define LOG(x)
-#endif
-
-#define WARN g_warning
-#define INFO g_message
-
-typedef struct _EMemoLocalRecord EMemoLocalRecord;
-typedef struct _EMemoConduitCfg EMemoConduitCfg;
-typedef struct _EMemoConduitGui EMemoConduitGui;
-typedef struct _EMemoConduitContext EMemoConduitContext;
-
-/* Local Record */
-struct _EMemoLocalRecord {
- /* 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 */
- ECalComponent *comp;
-
- /* pilot-link memo structure */
- struct Memo *memo;
-};
-
-gint lastDesktopUniqueID;
-
-static void
-memoconduit_destroy_record (EMemoLocalRecord *local)
-{
- g_object_unref (local->comp);
- free_Memo (local->memo);
- g_free (local->memo);
- g_free (local);
-}
-
-/* Configuration */
-struct _EMemoConduitCfg {
- guint32 pilot_id;
- GnomePilotConduitSyncType sync_type;
-
- ESourceList *source_list;
- ESource *source;
- gboolean secret;
- gint priority;
-
- gchar *last_uri;
-};
-
-static EMemoConduitCfg *
-memoconduit_load_configuration (guint32 pilot_id)
-{
- EMemoConduitCfg *c;
- GnomePilotConduitManagement *management;
- GnomePilotConduitConfig *config;
- gchar prefix[256];
-
- g_snprintf (prefix, 255, "e-memo-conduit/Pilot_%u", pilot_id);
-
- c = g_new0 (EMemoConduitCfg,1);
- g_assert (c != NULL);
-
- c->pilot_id = pilot_id;
-
- management = gnome_pilot_conduit_management_new ((gchar *)"e_memo_conduit", GNOME_PILOT_CONDUIT_MGMT_ID);
- g_object_ref_sink (management);
- config = gnome_pilot_conduit_config_new (management, pilot_id);
- g_object_ref_sink (config);
- if (!gnome_pilot_conduit_config_is_enabled (config, &c->sync_type))
- c->sync_type = GnomePilotConduitSyncTypeNotSet;
- g_object_unref (config);
- g_object_unref (management);
-
- /* Custom settings */
- if (!e_cal_get_sources (&c->source_list, E_CAL_SOURCE_TYPE_JOURNAL, NULL))
- c->source_list = NULL;
- if (c->source_list) {
- c->source = e_pilot_get_sync_source (c->source_list);
- if (!c->source)
- c->source = e_source_list_peek_source_any (c->source_list);
- if (c->source) {
- g_object_ref (c->source);
- } else {
- g_object_unref (c->source_list);
- c->source_list = NULL;
- }
- }
-
- c->secret = e_pilot_setup_get_bool (prefix, "secret", FALSE);
- c->priority = e_pilot_setup_get_int (prefix, "priority", 3);
- c->last_uri = e_pilot_setup_get_string (prefix, "last_uri", NULL);
-
- return c;
-}
-
-static void
-memoconduit_save_configuration (EMemoConduitCfg *c)
-{
- gchar prefix[256];
-
- g_snprintf (prefix, 255, "e-memo-conduit/Pilot_%u", c->pilot_id);
-
- e_pilot_set_sync_source (c->source_list, c->source);
- e_pilot_setup_set_bool (prefix, "secret", c->secret);
- e_pilot_setup_set_int (prefix, "priority", c->priority);
- e_pilot_setup_set_string (prefix, "last_uri", c->last_uri ? c->last_uri : "");
-}
-
-static EMemoConduitCfg*
-memoconduit_dupe_configuration (EMemoConduitCfg *c)
-{
- EMemoConduitCfg *retval;
-
- g_return_val_if_fail (c != NULL, NULL);
-
- retval = g_new0 (EMemoConduitCfg, 1);
- retval->sync_type = c->sync_type;
- retval->pilot_id = c->pilot_id;
-
- if (c->source_list)
- retval->source_list = g_object_ref (c->source_list);
- if (c->source)
- retval->source = g_object_ref (c->source);
- retval->secret = c->secret;
- retval->priority = c->priority;
- retval->last_uri = g_strdup (c->last_uri);
-
- return retval;
-}
-
-static void
-memoconduit_destroy_configuration (EMemoConduitCfg *c)
-{
- g_return_if_fail (c != NULL);
-
- g_object_unref (c->source_list);
- g_object_unref (c->source);
- g_free (c->last_uri);
- g_free (c);
-}
-
-/* Context */
-struct _EMemoConduitContext {
- GnomePilotDBInfo *dbi;
-
- EMemoConduitCfg *cfg;
- EMemoConduitCfg *new_cfg;
- GtkWidget *ps;
-
- struct MemoAppInfo ai;
-
- ECal *client;
-
- icaltimezone *timezone;
- ECalComponent *default_comp;
- GList *comps;
- GList *changed;
- GHashTable *changed_hash;
- GList *locals;
-
- EPilotMap *map;
- gchar *pilot_charset;
-};
-
-static EMemoConduitContext *
-e_memo_context_new (guint32 pilot_id)
-{
- EMemoConduitContext *ctxt = g_new0 (EMemoConduitContext, 1);
-
- ctxt->cfg = memoconduit_load_configuration (pilot_id);
- ctxt->new_cfg = memoconduit_dupe_configuration (ctxt->cfg);
- ctxt->ps = NULL;
- ctxt->client = NULL;
- ctxt->timezone = NULL;
- ctxt->default_comp = NULL;
- ctxt->comps = NULL;
- ctxt->changed_hash = NULL;
- ctxt->changed = NULL;
- ctxt->locals = NULL;
- ctxt->map = NULL;
- ctxt->pilot_charset = NULL;
-
- return ctxt;
-}
-
-static gboolean
-e_memo_context_foreach_change (gpointer key, gpointer value, gpointer data)
-{
- g_free (key);
-
- return TRUE;
-}
-
-static void
-e_memo_context_destroy (EMemoConduitContext *ctxt)
-{
- GList *l;
-
- g_return_if_fail (ctxt != NULL);
-
- if (ctxt->cfg != NULL)
- memoconduit_destroy_configuration (ctxt->cfg);
- if (ctxt->new_cfg != NULL)
- memoconduit_destroy_configuration (ctxt->new_cfg);
-
- if (ctxt->client != NULL)
- g_object_unref (ctxt->client);
-
- if (ctxt->default_comp != NULL)
- g_object_unref (ctxt->default_comp);
- if (ctxt->comps != NULL) {
- for (l = ctxt->comps; l; l = l->next)
- g_object_unref (l->data);
- g_list_free (ctxt->comps);
- }
-
- if (ctxt->changed_hash != NULL) {
- g_hash_table_foreach_remove (ctxt->changed_hash, e_memo_context_foreach_change, NULL);
- g_hash_table_destroy (ctxt->changed_hash);
- }
-
- if (ctxt->locals != NULL) {
- for (l = ctxt->locals; l != NULL; l = l->next)
- memoconduit_destroy_record (l->data);
- g_list_free (ctxt->locals);
- }
-
- if (ctxt->changed != NULL)
- e_cal_free_change_list (ctxt->changed);
-
- if (ctxt->map != NULL)
- e_pilot_map_destroy (ctxt->map);
-
- g_free (ctxt);
-}
-
-/* Debug routines */
-static gchar *
-print_local (EMemoLocalRecord *local)
-{
- static gchar buff[ 64 ];
-
- if (local == NULL) {
- sprintf (buff, "[NULL]");
- return buff;
- }
-
- if (local->memo && local->memo->text) {
- g_snprintf (buff, 64, "['%s']",
- local->memo->text ?
- local->memo->text : "");
- return buff;
- }
-
- strcpy (buff, "");
- return buff;
-}
-
-static gchar *print_remote (GnomePilotRecord *remote)
-{
- static gchar buff[ 64 ];
- struct Memo memo;
-#ifdef PILOT_LINK_0_12
- pi_buffer_t *buffer;
-#endif
-
- if (remote == NULL) {
- sprintf (buff, "[NULL]");
- return buff;
- }
-
- memset (&memo, 0, sizeof (struct Memo));
-#ifdef PILOT_LINK_0_12
- buffer = pi_buffer_new(DLP_BUF_SIZE);
- if (buffer == NULL) {
- sprintf (buff, "[NULL]");
- return buff;
- }
- if (pi_buffer_append(buffer, remote->record, remote->length)==NULL) {
- sprintf (buff, "[NULL]");
- return buff;
- }
- unpack_Memo (&memo, buffer, memo_v1);
-
- pi_buffer_free(buffer);
-#else
- unpack_Memo (&memo, remote->record, remote->length);
-#endif
- g_snprintf (buff, 64, "['%s']",
- memo.text ?
- memo.text : "");
-
- free_Memo (&memo);
-
- return buff;
-}
-
-static gint
-start_calendar_server (EMemoConduitContext *ctxt)
-{
- g_return_val_if_fail (ctxt != NULL, -2);
-
- if (ctxt->cfg->source) {
- ctxt->client = e_cal_new (ctxt->cfg->source, E_CAL_SOURCE_TYPE_JOURNAL);
- if (!e_cal_open (ctxt->client, TRUE, NULL))
- return -1;
- } else if (!e_cal_open_default (&ctxt->client, E_CAL_SOURCE_TYPE_JOURNAL, NULL, NULL, NULL)) {
- return -1;
- }
-
- return 0;
-}
-
-static icaltimezone *
-get_default_timezone (void)
-{
- GConfClient *client;
- icaltimezone *timezone = NULL;
- const gchar *key;
- gchar *location;
-
- client = gconf_client_get_default ();
- key = "/apps/evolution/calendar/display/timezone";
- location = gconf_client_get_string (client, key, NULL);
-
- if (location == NULL || *location == '\0') {
- g_free (location);
- location = g_strdup ("UTC");
- }
-
- timezone = icaltimezone_get_builtin_timezone (location);
- g_free (location);
-
- g_object_unref (client);
-
- return timezone;
-}
-
-static gchar *
-map_name (EMemoConduitContext *ctxt)
-{
- gchar *filename;
-
- filename = g_strdup_printf ("%s/.evolution/memos/local/system/pilot-map-memo-%d.xml", g_get_home_dir (), ctxt->cfg->pilot_id);
-
- return filename;
-}
-
-static GList *
-next_changed_item (EMemoConduitContext *ctxt, GList *changes)
-{
- ECalChange *ccc;
- GList *l;
-
- for (l = changes; l != NULL; l = l->next) {
- const gchar *uid;
-
- ccc = l->data;
-
- e_cal_component_get_uid (ccc->comp, &uid);
- if (g_hash_table_lookup (ctxt->changed_hash, uid))
- return l;
- }
-
- return NULL;
-}
-
-static void
-compute_status (EMemoConduitContext *ctxt, EMemoLocalRecord *local, const gchar *uid)
-{
- ECalChange *ccc;
-
- local->local.archived = FALSE;
- local->local.secret = FALSE;
-
- ccc = g_hash_table_lookup (ctxt->changed_hash, uid);
-
- if (ccc == NULL) {
- local->local.attr = GnomePilotRecordNothing;
- return;
- }
-
- switch (ccc->type) {
- case E_CAL_CHANGE_ADDED:
- local->local.attr = GnomePilotRecordNew;
- break;
- case E_CAL_CHANGE_MODIFIED:
- local->local.attr = GnomePilotRecordModified;
- break;
- case E_CAL_CHANGE_DELETED:
- local->local.attr = GnomePilotRecordDeleted;
- break;
- }
-}
-
-static GnomePilotRecord
-local_record_to_pilot_record (EMemoLocalRecord *local,
- EMemoConduitContext *ctxt)
-{
- GnomePilotRecord p;
-#ifdef PILOT_LINK_0_12
- pi_buffer_t * buffer;
-#else
- static gchar record[0xffff];
-#endif
-
- memset(&p, 0, sizeof (p));
-
- g_assert (local->comp != NULL);
- g_assert (local->memo != NULL );
-
- LOG (g_message ( "local_record_to_pilot_record\n" ));
-
- memset (&p, 0, sizeof (GnomePilotRecord));
-
- p.ID = local->local.ID;
- p.category = local->local.category;
- p.attr = local->local.attr;
- p.archived = local->local.archived;
- p.secret = local->local.secret;
-
- /* Generate pilot record structure */
-#ifdef PILOT_LINK_0_12
- buffer = pi_buffer_new(DLP_BUF_SIZE);
- if (buffer == NULL) {
- pi_set_error(ctxt->dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
- return p;
- }
-
- pack_Memo (local->memo, buffer, memo_v1);
- p.record = g_new0(unsigned char, buffer->used);
- p.length = buffer->used;
- memcpy(p.record, buffer->data, buffer->used);
-
- pi_buffer_free(buffer);
-#else
- p.record = (guchar *)record;
- p.length = pack_Memo (local->memo, p.record, 0xffff);
-#endif
- return p;
-}
-
-/*
- * converts a ECalComponent object to a EMemoLocalRecord
- */
-static void
-local_record_from_comp (EMemoLocalRecord *local, ECalComponent *comp, EMemoConduitContext *ctxt)
-{
- const gchar *uid;
- GSList *d_list = NULL;
- ECalComponentText *description;
- ECalComponentClassification classif;
-
- LOG (g_message ( "local_record_from_comp\n" ));
-
- g_return_if_fail (local != NULL);
- g_return_if_fail (comp != NULL);
-
- local->comp = comp;
- g_object_ref (comp);
-
- LOG(fprintf(stderr, "local_record_from_comp: calling e_cal_component_get_uid\n"));
- e_cal_component_get_uid (local->comp, &uid);
- LOG(fprintf(stderr, "local_record_from_comp: got UID - %s, calling e_pilot_map_lookup_pid\n", uid));
- local->local.ID = e_pilot_map_lookup_pid (ctxt->map, uid, TRUE);
- LOG(fprintf(stderr, "local_record_from_comp: local->local.ID == %lu\n", local->local.ID));
-
- compute_status (ctxt, local, uid);
-
- LOG(fprintf(stderr, "local_record_from_comp: local->local.attr: %d\n", local->local.attr));
-
- local->memo = g_new0 (struct Memo,1);
-
- /* Don't overwrite the category */
- if (local->local.ID != 0) {
-#ifdef PILOT_LINK_0_12
- struct Memo memo;
- pi_buffer_t * record;
-#else
- gchar record[0xffff];
-#endif
- gint cat = 0;
-
-#ifdef PILOT_LINK_0_12
- record = pi_buffer_new(DLP_BUF_SIZE);
- if (record == NULL) {
- pi_set_error(ctxt->dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
- return;
- }
-#endif
-
- LOG(fprintf(stderr, "local_record_from_comp: calling dlp_ReadRecordById\n"));
- if (dlp_ReadRecordById (ctxt->dbi->pilot_socket,
- ctxt->dbi->db_handle,
-#ifdef PILOT_LINK_0_12
- local->local.ID, record,
- NULL, NULL, &cat) > 0) {
- local->local.category = cat;
- memset (&memo, 0, sizeof (struct Memo));
- unpack_Memo (&memo, record, memo_v1);
- local->memo->text = strdup (memo.text);
- free_Memo (&memo);
- }
- pi_buffer_free (record);
-#else
- local->local.ID, &record,
- NULL, NULL, NULL, &cat) > 0) {
- local->local.category = cat;
- }
-#endif
- LOG(fprintf(stderr, "local_record_from_comp: done calling dlp_ReadRecordById\n"));
- }
-
- /*Category support*/
- e_pilot_local_category_to_remote(&(local->local.category), comp, &(ctxt->ai.category), ctxt->pilot_charset);
-
- /* STOP: don't replace these with g_strdup, since free_Memo
- uses free to deallocate */
-
- e_cal_component_get_description_list (comp, &d_list);
- if (d_list) {
- description = (ECalComponentText *) d_list->data;
- if (description && description->value) {
- local->memo->text = e_pilot_utf8_to_pchar (description->value, ctxt->pilot_charset);
- }
- else{
- local->memo->text = NULL;
- }
- } else {
- local->memo->text = NULL;
- }
-
- e_cal_component_get_classification (comp, &classif);
-
- if (classif == E_CAL_COMPONENT_CLASS_PRIVATE)
- local->local.secret = 1;
- else
- local->local.secret = 0;
-
- local->local.archived = 0;
-}
-
-static void
-local_record_from_uid (EMemoLocalRecord *local,
- const gchar *uid,
- EMemoConduitContext *ctxt)
-{
- ECalComponent *comp;
- icalcomponent *icalcomp;
- GError *error = NULL;
-
- g_assert(local!=NULL);
-
- LOG(g_message("local_record_from_uid\n"));
-
- if (e_cal_get_object (ctxt->client, uid, NULL, &icalcomp, &error)) {
- comp = e_cal_component_new ();
- if (!e_cal_component_set_icalcomponent (comp, icalcomp)) {
- g_object_unref (comp);
- icalcomponent_free (icalcomp);
- return;
- }
-
- local_record_from_comp (local, comp, ctxt);
- g_object_unref (comp);
- } else if (error->code == E_CALENDAR_STATUS_OBJECT_NOT_FOUND) {
- comp = e_cal_component_new ();
- e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_JOURNAL);
- e_cal_component_set_uid (comp, uid);
- local_record_from_comp (local, comp, ctxt);
- g_object_unref (comp);
- } else {
- INFO ("Object did not exist");
- }
-
- g_clear_error (&error);
-}
-
-static ECalComponent *
-comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
- GnomePilotRecord *remote,
- ECalComponent *in_comp,
- icaltimezone *timezone,
- struct MemoAppInfo *ai,
- const gchar *pilot_charset)
-{
- ECalComponent *comp;
- struct Memo memo;
- struct icaltimetype now;
- icaltimezone *utc_zone;
- gchar *txt, *txt2, *txt3;
- gint i;
-#ifdef PILOT_LINK_0_12
- pi_buffer_t * buffer;
-#endif
- g_return_val_if_fail (remote != NULL, NULL);
-
-#ifdef PILOT_LINK_0_12
- buffer = pi_buffer_new(DLP_BUF_SIZE);
- if (buffer == NULL) {
- return NULL;
- }
-
- if (pi_buffer_append(buffer, remote->record, remote->length)==NULL) {
- return NULL;
- }
-
- unpack_Memo (&memo, buffer, memo_v1);
- pi_buffer_free(buffer);
-#else
- memset (&memo, 0, sizeof (struct Memo));
- unpack_Memo (&memo, remote->record, remote->length);
-#endif
-
- utc_zone = icaltimezone_get_utc_timezone ();
- now = icaltime_from_timet_with_zone (time (NULL), FALSE,
- utc_zone);
-
- if (in_comp == NULL) {
- comp = e_cal_component_new ();
- e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_JOURNAL);
- e_cal_component_set_created (comp, &now);
- } else {
- comp = e_cal_component_clone (in_comp);
- }
-
- e_cal_component_set_last_modified (comp, &now);
-
- /*Category support*/
- e_pilot_remote_category_to_local(remote->category, comp, &(ai->category), pilot_charset);
-
- /* The iCal description field */
- if (!memo.text) {
- e_cal_component_set_comment_list (comp, NULL);
- e_cal_component_set_summary(comp, NULL);
- } else {
- gint idxToUse = -1, ntext = strlen(memo.text);
- gboolean foundNL = FALSE;
- GSList l;
- ECalComponentText text, sumText;
-
- for (i = 0; i<ntext && i<50; i++) {
- if (memo.text[i] == '\n') {
- idxToUse = i;
- foundNL = TRUE;
- break;
- }
- }
-
- if (foundNL == FALSE) {
- if (ntext > 50) {
- txt2 = g_strndup(memo.text, 50);
- }
- else{
- txt2 = g_strdup(memo.text);
-
- }
- }
- else{
- txt2 = g_strndup(memo.text, idxToUse); /* cuts off '\n' */
-
- }
-
- sumText.value = txt3 = e_pilot_utf8_from_pchar(txt2, pilot_charset);
- sumText.altrep = NULL;
-
- text.value = txt = e_pilot_utf8_from_pchar (memo.text, pilot_charset);
- text.altrep = NULL;
- l.data = &text;
- l.next = NULL;
-
- e_cal_component_set_summary(comp, &sumText);
- e_cal_component_set_description_list (comp, &l);
- free (txt);
- g_free(txt2);
- free(txt3);
- }
-
- e_cal_component_set_transparency (comp, E_CAL_COMPONENT_TRANSP_NONE);
-
- if (remote->secret)
- e_cal_component_set_classification (comp, E_CAL_COMPONENT_CLASS_PRIVATE);
- else
- e_cal_component_set_classification (comp, E_CAL_COMPONENT_CLASS_PUBLIC);
-
- e_cal_component_commit_sequence (comp);
-
- free_Memo(&memo);
-
- return comp;
-}
-
-static void
-check_for_slow_setting (GnomePilotConduit *c, EMemoConduitContext *ctxt)
-{
- GnomePilotConduitStandard *conduit = GNOME_PILOT_CONDUIT_STANDARD (c);
- gint map_count;
- const gchar *uri;
-
- /* If there are no objects or objects but no log */
- map_count = g_hash_table_size (ctxt->map->pid_map);
- if (map_count == 0)
- gnome_pilot_conduit_standard_set_slow (conduit, TRUE);
-
- /* Or if the URI's don't match */
- uri = e_cal_get_uri (ctxt->client);
- LOG (g_message ( " Current URI %s (%s)\n", uri, ctxt->cfg->last_uri ? ctxt->cfg->last_uri : "<NONE>" ));
- if (ctxt->cfg->last_uri != NULL && (strcmp (ctxt->cfg->last_uri, uri) != 0)) {
- gnome_pilot_conduit_standard_set_slow (conduit, TRUE);
- e_pilot_map_clear (ctxt->map);
- }
-
- if (gnome_pilot_conduit_standard_get_slow (conduit)) {
- ctxt->map->write_touched_only = TRUE;
- LOG (g_message ( " doing slow sync\n" ));
- } else {
- LOG (g_message ( " doing fast sync\n" ));
- }
-}
-
-/* Pilot syncing callbacks */
-static gint
-pre_sync (GnomePilotConduit *conduit,
- GnomePilotDBInfo *dbi,
- EMemoConduitContext *ctxt)
-{
- GnomePilotConduitSyncAbs *abs_conduit;
- GList *l;
- gint len;
- guchar *buf;
- gchar *filename, *change_id;
- icalcomponent *icalcomp;
- gint num_records, add_records = 0, mod_records = 0, del_records = 0;
-#ifdef PILOT_LINK_0_12
- pi_buffer_t * buffer;
-#endif
-
- abs_conduit = GNOME_PILOT_CONDUIT_SYNC_ABS (conduit);
-
- LOG (g_message ( "---------------------------------------------------------\n" ));
- LOG (g_message ( "pre_sync: Memo Conduit v.%s", CONDUIT_VERSION ));
- g_message ("Memo Conduit v.%s", CONDUIT_VERSION);
-
- ctxt->dbi = dbi;
- ctxt->client = NULL;
-
-#ifdef PILOT_LINK_0_12
- if (NULL == dbi->pilotInfo->pilot_charset)
- ctxt->pilot_charset = NULL;
- else
- ctxt->pilot_charset = g_strdup(dbi->pilotInfo->pilot_charset);
-#endif
-
- if (start_calendar_server (ctxt) != 0) {
- WARN(_("Could not start evolution-data-server"));
- gnome_pilot_conduit_error (conduit, _("Could not start evolution-data-server"));
- return -1;
- }
-
- /* Get the timezone */
- ctxt->timezone = get_default_timezone ();
- if (ctxt->timezone == NULL)
- return -1;
- LOG (g_message ( " Using timezone: %s", icaltimezone_get_tzid (ctxt->timezone) ));
-
- /* Set the default timezone on the backend. */
- if (ctxt->timezone && !e_cal_set_default_timezone (ctxt->client, ctxt->timezone, NULL))
- return -1;
-
- /* Get the default component */
- if (!e_cal_get_default_object (ctxt->client, &icalcomp, NULL))
- return -1;
-
- ctxt->default_comp = e_cal_component_new ();
- if (!e_cal_component_set_icalcomponent (ctxt->default_comp, icalcomp)) {
- g_object_unref (ctxt->default_comp);
- icalcomponent_free (icalcomp);
- return -1;
- }
-
- /* Load the uid <--> pilot id map */
- filename = map_name (ctxt);
- e_pilot_map_read (filename, &ctxt->map);
- g_free (filename);
-
- /* Get the local database */
- if (!e_cal_get_object_list_as_comp (ctxt->client, "#t", &ctxt->comps, NULL))
- return -1;
-
- /* Count and hash the changes */
- change_id = g_strdup_printf ("pilot-sync-evolution-memo-%d", ctxt->cfg->pilot_id);
- if (!e_cal_get_changes (ctxt->client, change_id, &ctxt->changed, NULL))
- return -1;
-
- ctxt->changed_hash = g_hash_table_new (g_str_hash, g_str_equal);
- g_free (change_id);
-
- for (l = ctxt->changed; l != NULL; l = l->next) {
- ECalChange *ccc = l->data;
- const gchar *uid;
-
- e_cal_component_get_uid (ccc->comp, &uid);
- if (!e_pilot_map_uid_is_archived (ctxt->map, uid)) {
-
- g_hash_table_insert (ctxt->changed_hash, g_strdup (uid), ccc);
-
- switch (ccc->type) {
- case E_CAL_CHANGE_ADDED:
- add_records++;
- break;
- case E_CAL_CHANGE_MODIFIED:
- mod_records++;
- break;
- case E_CAL_CHANGE_DELETED:
- del_records++;
- break;
- }
- } else if (ccc->type == E_CAL_CHANGE_DELETED) {
- e_pilot_map_remove_by_uid (ctxt->map, uid);
- }
- }
-
- /* Set the count information */
- num_records = g_list_length (ctxt->comps);
- gnome_pilot_conduit_sync_abs_set_num_local_records(abs_conduit, num_records);
- gnome_pilot_conduit_sync_abs_set_num_new_local_records (abs_conduit, add_records);
- gnome_pilot_conduit_sync_abs_set_num_updated_local_records (abs_conduit, mod_records);
- gnome_pilot_conduit_sync_abs_set_num_deleted_local_records(abs_conduit, del_records);
-
- g_message("num_records: %d\nadd_records: %d\nmod_records: %d\ndel_records: %d\n",
- num_records, add_records, mod_records, del_records);
-
-#ifdef PILOT_LINK_0_12
- buffer = pi_buffer_new(DLP_BUF_SIZE);
- if (buffer == NULL) {
- pi_set_error(dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
- return -1;
- }
-
- len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
- DLP_BUF_SIZE,
- buffer);
-#else
- buf = (guchar *)g_malloc (0xffff);
- len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
- (guchar *)buf, 0xffff);
-#endif
- if (len < 0) {
- WARN (_("Could not read pilot's Memo application block"));
- WARN ("dlp_ReadAppBlock(...) = %d", len);
- gnome_pilot_conduit_error (conduit,
- _("Could not read pilot's Memo application block"));
- return -1;
- }
-#ifdef PILOT_LINK_0_12
- buf = g_new0 (unsigned char,buffer->used);
- memcpy(buf, buffer->data, buffer->used);
- unpack_MemoAppInfo (&(ctxt->ai), buf, len);
- pi_buffer_free(buffer);
-#else
- unpack_MemoAppInfo (&(ctxt->ai), buf, len);
-#endif
-
- g_free (buf);
-
- lastDesktopUniqueID = 128;
-
- check_for_slow_setting (conduit, ctxt);
- if (ctxt->cfg->sync_type == GnomePilotConduitSyncTypeCopyToPilot
- || ctxt->cfg->sync_type == GnomePilotConduitSyncTypeCopyFromPilot)
- ctxt->map->write_touched_only = TRUE;
-
- return 0;
-}
-
-static gint
-post_sync (GnomePilotConduit *conduit,
- GnomePilotDBInfo *dbi,
- EMemoConduitContext *ctxt)
-{
- GList *changed;
- gchar *filename, *change_id;
- guchar *buf;
- gint dlpRetVal, len;
-
- buf = (guchar *)g_malloc (0xffff);
-
- len = pack_MemoAppInfo (&(ctxt->ai), buf, 0xffff);
-
- dlpRetVal = dlp_WriteAppBlock (dbi->pilot_socket, dbi->db_handle,
- (guchar *)buf, len);
-
- g_free (buf);
-
- if (dlpRetVal < 0) {
- WARN (_("Could not write pilot's Memo application block"));
- WARN ("dlp_WriteAppBlock(...) = %d", dlpRetVal);
- gnome_pilot_conduit_error (conduit,
- _("Could not write pilot's Memo application block"));
- return -1;
- }
-
- LOG (g_message ( "post_sync: Memo Conduit v.%s", CONDUIT_VERSION ));
-
- g_free (ctxt->cfg->last_uri);
- ctxt->cfg->last_uri = g_strdup (e_cal_get_uri (ctxt->client));
- memoconduit_save_configuration (ctxt->cfg);
-
- filename = map_name (ctxt);
- e_pilot_map_write (filename, ctxt->map);
- g_free (filename);
-
- /* FIX ME ugly hack - our changes musn't count, this does introduce
- * a race condition if anyone changes a record elsewhere during sycnc
- */
- change_id = g_strdup_printf ("pilot-sync-evolution-memo-%d", ctxt->cfg->pilot_id);
- if (e_cal_get_changes (ctxt->client, change_id, &changed, NULL))
- e_cal_free_change_list (changed);
- g_free (change_id);
- if (ctxt->pilot_charset)
- g_free (ctxt->pilot_charset);
- LOG (g_message ( "---------------------------------------------------------\n" ));
-
- return 0;
-}
-
-static gint
-set_pilot_id (GnomePilotConduitSyncAbs *conduit,
- EMemoLocalRecord *local,
- guint32 ID,
- EMemoConduitContext *ctxt)
-{
- const gchar *uid;
-
- LOG (g_message ( "set_pilot_id: setting to %d\n", ID ));
-
- e_cal_component_get_uid (local->comp, &uid);
- e_pilot_map_insert (ctxt->map, ID, uid, FALSE);
-
- return 0;
-}
-
-static gint
-set_status_cleared (GnomePilotConduitSyncAbs *conduit,
- EMemoLocalRecord *local,
- EMemoConduitContext *ctxt)
-{
- const gchar *uid;
-
- LOG (g_message ( "set_status_cleared: clearing status\n" ));
-
- e_cal_component_get_uid (local->comp, &uid);
- g_hash_table_remove (ctxt->changed_hash, uid);
-
- return 0;
-}
-
-static gint
-for_each (GnomePilotConduitSyncAbs *conduit,
- EMemoLocalRecord **local,
- EMemoConduitContext *ctxt)
-{
- static GList *comps, *iterator;
- static gint count;
- GList *unused;
-
- g_return_val_if_fail (local != NULL, -1);
-
- if (*local == NULL) {
- LOG (g_message ( "beginning for_each" ));
-
- comps = ctxt->comps;
- count = 0;
-
- if (comps != NULL) {
- LOG (g_message ( "for_each: iterating over %d records", g_list_length (comps)));
-
- *local = g_new0 (EMemoLocalRecord, 1);
- local_record_from_comp (*local, comps->data, ctxt);
-
- /* NOTE: ignore the return value, otherwise ctxt->locals
- * gets messed up. The calling function keeps track of
- * the *local variable */
- unused = g_list_prepend (ctxt->locals, *local);
- iterator = comps;
- } else {
- LOG (g_message ( "no events" ));
- (*local) = NULL;
- return 0;
- }
- } else {
- count++;
-
- if (g_list_next (iterator)) {
- iterator = g_list_next (iterator);
-
- *local = g_new0 (EMemoLocalRecord, 1);
- LOG(fprintf(stderr, "for_each: calling local_record_from_comp\n"));
- local_record_from_comp (*local, iterator->data, ctxt);
-
- /* NOTE: ignore the return value, otherwise ctxt->locals
- * gets messed up. The calling function keeps track of
- * the *local variable */
- unused = g_list_prepend (ctxt->locals, *local);
- } else {
- LOG (g_message ( "for_each ending" ));
-
- /* Tell the pilot the iteration is over */
- *local = NULL;
-
- return 0;
- }
- }
-
- return 0;
-}
-
-static gint
-for_each_modified (GnomePilotConduitSyncAbs *conduit,
- EMemoLocalRecord **local,
- EMemoConduitContext *ctxt)
-{
- static GList *iterator;
- static gint count;
- GList *unused;
-
- g_return_val_if_fail (local != NULL, 0);
-
- if (*local == NULL) {
- LOG (g_message ( "for_each_modified beginning\n" ));
-
- iterator = ctxt->changed;
-
- count = 0;
-
- LOG (g_message ( "iterating over %d records", g_hash_table_size (ctxt->changed_hash) ));
-
- iterator = next_changed_item (ctxt, iterator);
- if (iterator != NULL) {
- ECalChange *ccc = iterator->data;
-
- *local = g_new0 (EMemoLocalRecord, 1);
- local_record_from_comp (*local, ccc->comp, ctxt);
-
- /* NOTE: ignore the return value, otherwise ctxt->locals
- * gets messed up. The calling function keeps track of
- * the *local variable */
- unused = g_list_prepend (ctxt->locals, *local);
- } else {
- LOG (g_message ( "no events" ));
-
- *local = NULL;
- }
- } else {
- count++;
-
- iterator = g_list_next (iterator);
- if (iterator && (iterator = next_changed_item (ctxt, iterator))) {
- ECalChange *ccc = iterator->data;
-
- *local = g_new0 (EMemoLocalRecord, 1);
- local_record_from_comp (*local, ccc->comp, ctxt);
-
- /* NOTE: ignore the return value, otherwise ctxt->locals
- * gets messed up. The calling function keeps track of
- * the *local variable */
- unused = g_list_prepend (ctxt->locals, *local);
- } else {
- LOG (g_message ( "for_each_modified ending" ));
-
- /* Signal the iteration is over */
- *local = NULL;
- }
- }
-
- return 0;
-}
-
-static gint
-compare (GnomePilotConduitSyncAbs *conduit,
- EMemoLocalRecord *local,
- GnomePilotRecord *remote,
- EMemoConduitContext *ctxt)
-{
- /* used by the quick compare */
- GnomePilotRecord local_pilot;
- gint retval = 0;
-
- LOG (g_message ("compare: local=%s remote=%s...\n",
- print_local (local), print_remote (remote)));
-
- g_return_val_if_fail (local!=NULL,-1);
- g_return_val_if_fail (remote!=NULL,-1);
-
- local_pilot = local_record_to_pilot_record (local, ctxt);
-
- if (remote->length != local_pilot.length
- || memcmp (local_pilot.record, remote->record, remote->length))
- retval = 1;
-
- if (retval == 0)
- LOG (g_message ( " equal" ));
- else
- LOG (g_message ( " not equal" ));
-
- return retval;
-}
-
-static gint
-add_record (GnomePilotConduitSyncAbs *conduit,
- GnomePilotRecord *remote,
- EMemoConduitContext *ctxt)
-{
- ECalComponent *comp;
- gchar *uid;
- gint retval = 0;
-
- g_return_val_if_fail (remote != NULL, -1);
-
- LOG (g_message ( "add_record: adding %s to desktop\n", print_remote (remote) ));
-
- comp = comp_from_remote_record (conduit, remote, ctxt->default_comp, ctxt->timezone, &(ctxt->ai), ctxt->pilot_charset);
-
- /* Give it a new UID otherwise it will be the uid of the default comp */
- uid = e_cal_component_gen_uid ();
- e_cal_component_set_uid (comp, uid);
-
- if (!e_cal_create_object (ctxt->client, e_cal_component_get_icalcomponent (comp), NULL, NULL))
- return -1;
-
- e_pilot_map_insert (ctxt->map, remote->ID, uid, FALSE);
-
- g_object_unref (comp);
-
- return retval;
-}
-
-static gint
-replace_record (GnomePilotConduitSyncAbs *conduit,
- EMemoLocalRecord *local,
- GnomePilotRecord *remote,
- EMemoConduitContext *ctxt)
-{
- ECalComponent *new_comp;
- gint retval = 0;
-
- g_return_val_if_fail (remote != NULL, -1);
-
- LOG (g_message ("replace_record: replace %s with %s\n",
- print_local (local), print_remote (remote)));
-
- new_comp = comp_from_remote_record (conduit, remote, local->comp, ctxt->timezone, &(ctxt->ai), ctxt->pilot_charset);
- g_object_unref (local->comp);
- local->comp = new_comp;
-
- if (!e_cal_modify_object (ctxt->client, e_cal_component_get_icalcomponent (new_comp),
- CALOBJ_MOD_ALL, NULL))
- return -1;
-
- return retval;
-}
-
-static gint
-delete_record (GnomePilotConduitSyncAbs *conduit,
- EMemoLocalRecord *local,
- EMemoConduitContext *ctxt)
-{
- const gchar *uid;
-
- g_return_val_if_fail (local != NULL, -1);
- g_return_val_if_fail (local->comp != NULL, -1);
-
- e_cal_component_get_uid (local->comp, &uid);
-
- LOG (g_message ( "delete_record: deleting %s", uid ));
-
- e_pilot_map_remove_by_uid (ctxt->map, uid);
- /* FIXME Error handling */
- e_cal_remove_object (ctxt->client, uid, NULL);
-
- return 0;
-}
-
-static gint
-archive_record (GnomePilotConduitSyncAbs *conduit,
- EMemoLocalRecord *local,
- gboolean archive,
- EMemoConduitContext *ctxt)
-{
- const gchar *uid;
- gint retval = 0;
-
- g_return_val_if_fail (local != NULL, -1);
-
- LOG (g_message ( "archive_record: %s\n", archive ? "yes" : "no" ));
-
- e_cal_component_get_uid (local->comp, &uid);
- e_pilot_map_insert (ctxt->map, local->local.ID, uid, archive);
-
- return retval;
-}
-
-static gint
-match (GnomePilotConduitSyncAbs *conduit,
- GnomePilotRecord *remote,
- EMemoLocalRecord **local,
- EMemoConduitContext *ctxt)
-{
- const gchar *uid;
-
- LOG (g_message ("match: looking for local copy of %s\n",
- print_remote (remote)));
-
- g_return_val_if_fail (local != NULL, -1);
- g_return_val_if_fail (remote != NULL, -1);
-
- *local = NULL;
- uid = e_pilot_map_lookup_uid (ctxt->map, remote->ID, TRUE);
-
- if (!uid)
- return 0;
-
- LOG (g_message ( " matched\n" ));
-
- *local = g_new0 (EMemoLocalRecord, 1);
- local_record_from_uid (*local, uid, ctxt);
-
- return 0;
-}
-
-static gint
-free_match (GnomePilotConduitSyncAbs *conduit,
- EMemoLocalRecord *local,
- EMemoConduitContext *ctxt)
-{
- LOG (g_message ( "free_match: freeing\n" ));
-
- g_return_val_if_fail (local != NULL, -1);
-
- ctxt->locals = g_list_remove (ctxt->locals, local);
-
- memoconduit_destroy_record (local);
-
- return 0;
-}
-
-static gint
-prepare (GnomePilotConduitSyncAbs *conduit,
- EMemoLocalRecord *local,
- GnomePilotRecord *remote,
- EMemoConduitContext *ctxt)
-{
- LOG (g_message ( "prepare: encoding local %s\n", print_local (local) ));
-
- *remote = local_record_to_pilot_record (local, ctxt);
-
- return 0;
-}
-
-/* Pilot Settings Callbacks */
-static void
-fill_widgets (EMemoConduitContext *ctxt)
-{
- if (ctxt->cfg->source)
- e_pilot_settings_set_source (E_PILOT_SETTINGS (ctxt->ps),
- ctxt->cfg->source);
- e_pilot_settings_set_secret (E_PILOT_SETTINGS (ctxt->ps),
- ctxt->cfg->secret);
-}
-
-static gint
-create_settings_window (GnomePilotConduit *conduit,
- GtkWidget *parent,
- EMemoConduitContext *ctxt)
-{
- LOG (g_message ( "create_settings_window" ));
-
- if (!ctxt->cfg->source_list)
- return -1;
-
- ctxt->ps = e_pilot_settings_new (ctxt->cfg->source_list);
-
- gtk_container_add (GTK_CONTAINER (parent), ctxt->ps);
- gtk_widget_show (ctxt->ps);
-
- fill_widgets (ctxt);
-
- return 0;
-}
-
-static void
-display_settings (GnomePilotConduit *conduit, EMemoConduitContext *ctxt)
-{
- LOG (g_message ( "display_settings" ));
-
- fill_widgets (ctxt);
-}
-
-static void
-save_settings (GnomePilotConduit *conduit, EMemoConduitContext *ctxt)
-{
- LOG (g_message ( "save_settings" ));
-
- if (ctxt->new_cfg->source)
- g_object_unref (ctxt->new_cfg->source);
- ctxt->new_cfg->source = e_pilot_settings_get_source (E_PILOT_SETTINGS (ctxt->ps));
- g_object_ref (ctxt->new_cfg->source);
- ctxt->new_cfg->secret = e_pilot_settings_get_secret (E_PILOT_SETTINGS (ctxt->ps));
-
- memoconduit_save_configuration (ctxt->new_cfg);
-}
-
-static void
-revert_settings (GnomePilotConduit *conduit, EMemoConduitContext *ctxt)
-{
- LOG (g_message ( "revert_settings" ));
-
- memoconduit_save_configuration (ctxt->cfg);
- memoconduit_destroy_configuration (ctxt->new_cfg);
- ctxt->new_cfg = memoconduit_dupe_configuration (ctxt->cfg);
-}
-
-GnomePilotConduit *
-conduit_get_gpilot_conduit (guint32 pilot_id)
-{
- GtkObject *retval;
- EMemoConduitContext *ctxt;
-
- LOG (g_message ( "in memo's conduit_get_gpilot_conduit\n" ));
-
- retval = gnome_pilot_conduit_sync_abs_new ((gchar *)"MemoDB", 0x6D656D6F);
- g_assert (retval != NULL);
-
- ctxt = e_memo_context_new (pilot_id);
- g_object_set_data (G_OBJECT (retval), "memoconduit_context", ctxt);
-
- g_signal_connect (retval, "pre_sync", G_CALLBACK (pre_sync), ctxt);
- g_signal_connect (retval, "post_sync", G_CALLBACK (post_sync), ctxt);
-
- g_signal_connect (retval, "set_pilot_id", G_CALLBACK (set_pilot_id), ctxt);
- g_signal_connect (retval, "set_status_cleared", G_CALLBACK (set_status_cleared), ctxt);
-
- g_signal_connect (retval, "for_each", G_CALLBACK (for_each), ctxt);
- g_signal_connect (retval, "for_each_modified", G_CALLBACK (for_each_modified), ctxt);
- g_signal_connect (retval, "compare", G_CALLBACK (compare), ctxt);
-
- g_signal_connect (retval, "add_record", G_CALLBACK (add_record), ctxt);
- g_signal_connect (retval, "replace_record", G_CALLBACK (replace_record), ctxt);
- g_signal_connect (retval, "delete_record", G_CALLBACK (delete_record), ctxt);
- g_signal_connect (retval, "archive_record", G_CALLBACK (archive_record), ctxt);
-
- g_signal_connect (retval, "match", G_CALLBACK (match), ctxt);
- g_signal_connect (retval, "free_match", G_CALLBACK (free_match), ctxt);
-
- g_signal_connect (retval, "prepare", G_CALLBACK (prepare), ctxt);
-
- /* Gui Settings */
- g_signal_connect (retval, "create_settings_window", G_CALLBACK (create_settings_window), ctxt);
- g_signal_connect (retval, "display_settings", G_CALLBACK (display_settings), ctxt);
- g_signal_connect (retval, "save_settings", G_CALLBACK (save_settings), ctxt);
- g_signal_connect (retval, "revert_settings", G_CALLBACK (revert_settings), ctxt);
-
- return GNOME_PILOT_CONDUIT (retval);
-}
-
-void
-conduit_destroy_gpilot_conduit (GnomePilotConduit *conduit)
-{
- GtkObject *obj = GTK_OBJECT (conduit);
- EMemoConduitContext *ctxt;
-
- ctxt = g_object_get_data (G_OBJECT (obj), "memoconduit_context");
- e_memo_context_destroy (ctxt);
-
- gtk_object_destroy (obj);
-}
diff --git a/calendar/conduits/todo/Makefile.am b/calendar/conduits/todo/Makefile.am
deleted file mode 100644
index 782067a903..0000000000
--- a/calendar/conduits/todo/Makefile.am
+++ /dev/null
@@ -1,42 +0,0 @@
-# ToDo Conduit
-privconduit_LTLIBRARIES = libetodo_conduit.la
-
-libetodo_conduit_la_CPPFLAGS = \
- $(AM_CPPFLAGS) \
- -I$(top_srcdir)/e-util \
- -I$(top_builddir)/e-util \
- -I$(top_srcdir)/widgets/misc \
- -I$(top_builddir)/widgets/misc \
- -I$(top_srcdir)/calendar/conduits/common \
- -I$(top_builddir)/calendar/conduits/common \
- $(EVOLUTION_CALENDAR_CONDUIT_CFLAGS)
-
-libetodo_conduit_la_SOURCES = todo-conduit.c
-
-libetodo_conduit_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED)
-
-libetodo_conduit_la_LIBADD = \
- $(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/e-util/libeconduit.la \
- $(top_builddir)/widgets/misc/libemiscwidgets.la \
- $(top_builddir)/calendar/conduits/common/libecalendar_common_conduit.la \
- $(EVOLUTION_CALENDAR_CONDUIT_LIBS)
-
-e-todo.conduit: e-todo.conduit.in
- sed -e 's^\@privconduitdir\@^$(privconduitdir)^g' \
- -e 's^\@datadir\@^$(datadir)^g' \
- -e 's^\@BASE_VERSION\@^$(BASE_VERSION)^g' \
- $< > $@
-
-conduitdir = $(datadir)/gnome-pilot/conduits/
-conduit_DATA = e-todo.conduit
-
-BUILT_SOURCES = $(conduit_DATA)
-CLEANFILES = $(BUILT_SOURCES)
-
-EXTRA_DIST = e-todo.conduit.in
-
-dist-hook:
- cd $(distdir); rm -f $(BUILT_SOURCES)
-
--include $(top_srcdir)/git.mk
diff --git a/calendar/conduits/todo/e-todo.conduit.in b/calendar/conduits/todo/e-todo.conduit.in
deleted file mode 100644
index 3b02058c91..0000000000
--- a/calendar/conduits/todo/e-todo.conduit.in
+++ /dev/null
@@ -1,9 +0,0 @@
-<gnome-pilot-conduit version="1.0">
- <conduit id="e_todo_conduit" type="shlib" location="@privconduitdir@/libetodo_conduit.so"/>
- <name value="EToDo"/>
- <conduit-attribute name="description" value="Synchronizes ToDo List with Evolution @BASE_VERSION@"/>
- <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="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.c b/calendar/conduits/todo/todo-conduit.c
deleted file mode 100644
index 59d3ad9b4b..0000000000
--- a/calendar/conduits/todo/todo-conduit.c
+++ /dev/null
@@ -1,1634 +0,0 @@
-/*
- * Evolution calendar - ToDo Conduit
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Eskil Heyn Olsen <deity@eskil.dk>
- * JP Rosevear <jpr@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#define G_LOG_DOMAIN "etodoconduit"
-
-/* Work around deprecated API usage in GnomePilot. */
-#undef GTK_DISABLE_DEPRECATED
-#undef GTK_DISABLE_SINGLE_INCLUDES
-
-#include <glib/gi18n.h>
-#include <libecal/e-cal-types.h>
-#include <libecal/e-cal.h>
-#include <libecal/e-cal-time-util.h>
-#include <libedataserver/e-url.h>
-#include <libedataserverui/e-passwords.h>
-#include <libedataserver/e-categories.h>
-#include <pi-source.h>
-#include <pi-socket.h>
-#include <pi-dlp.h>
-#include <pi-todo.h>
-#include <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>
-#include <libecalendar-common-conduit.h>
-
-GnomePilotConduit * conduit_get_gpilot_conduit (guint32);
-void conduit_destroy_gpilot_conduit (GnomePilotConduit*);
-
-#define CONDUIT_VERSION "0.1.6"
-
-#define DEBUG_TODOCONDUIT 1
-/* #undef DEBUG_TODOCONDUIT */
-
-#ifdef DEBUG_TODOCONDUIT
-#define LOG(x) x
-#else
-#define LOG(x)
-#endif
-
-#define WARN g_warning
-#define INFO g_message
-
-typedef struct _EToDoLocalRecord EToDoLocalRecord;
-typedef struct _EToDoConduitCfg EToDoConduitCfg;
-typedef struct _EToDoConduitGui EToDoConduitGui;
-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 */
- ECalComponent *comp;
-
- /* pilot-link todo structure */
- struct ToDo *todo;
-};
-
-gint lastDesktopUniqueID;
-
-static void
-todoconduit_destroy_record (EToDoLocalRecord *local)
-{
- g_object_unref (local->comp);
- free_ToDo (local->todo);
- g_free (local->todo);
- g_free (local);
-}
-
-/* Configuration */
-struct _EToDoConduitCfg {
- guint32 pilot_id;
- GnomePilotConduitSyncType sync_type;
-
- ESourceList *source_list;
- ESource *source;
- 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, "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 ((gchar *)"e_todo_conduit", GNOME_PILOT_CONDUIT_MGMT_ID);
- g_object_ref_sink (management);
- config = gnome_pilot_conduit_config_new (management, pilot_id);
- g_object_ref_sink (config);
- if (!gnome_pilot_conduit_config_is_enabled (config, &c->sync_type))
- c->sync_type = GnomePilotConduitSyncTypeNotSet;
- g_object_unref (config);
- g_object_unref (management);
-
- /* Custom settings */
- if (!e_cal_get_sources (&c->source_list, E_CAL_SOURCE_TYPE_TODO, NULL))
- c->source_list = NULL;
- if (c->source_list) {
- c->source = e_pilot_get_sync_source (c->source_list);
- if (!c->source)
- c->source = e_source_list_peek_source_any (c->source_list);
- if (c->source) {
- g_object_ref (c->source);
- } else {
- g_object_unref (c->source_list);
- c->source_list = NULL;
- }
- }
-
- c->secret = e_pilot_setup_get_bool (prefix, "secret", FALSE);
- c->priority = e_pilot_setup_get_int (prefix, "priority", 3);
- c->last_uri = e_pilot_setup_get_string (prefix, "last_uri", NULL);
-
- return c;
-}
-
-static void
-todoconduit_save_configuration (EToDoConduitCfg *c)
-{
- gchar prefix[256];
-
- g_snprintf (prefix, 255, "e-todo-conduit/Pilot_%u", c->pilot_id);
-
- e_pilot_set_sync_source (c->source_list, c->source);
- e_pilot_setup_set_bool (prefix, "secret", c->secret);
- e_pilot_setup_set_int (prefix, "priority", c->priority);
- e_pilot_setup_set_string (prefix, "last_uri", c->last_uri ? c->last_uri : "");
-}
-
-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;
-
- if (c->source_list)
- retval->source_list = g_object_ref (c->source_list);
- if (c->source)
- retval->source = g_object_ref (c->source);
- retval->secret = c->secret;
- retval->priority = c->priority;
- retval->last_uri = g_strdup (c->last_uri);
-
- return retval;
-}
-
-static void
-todoconduit_destroy_configuration (EToDoConduitCfg *c)
-{
- g_return_if_fail (c != NULL);
-
- g_object_unref (c->source_list);
- g_object_unref (c->source);
- g_free (c->last_uri);
- g_free (c);
-}
-
-/* Gui */
-struct _EToDoConduitGui {
- GtkWidget *priority;
-};
-
-static EToDoConduitGui *
-e_todo_gui_new (EPilotSettings *ps)
-{
- EToDoConduitGui *gui;
- GtkWidget *lbl;
- GtkObject *adj;
- gint rows;
-
- g_return_val_if_fail (ps != NULL, NULL);
- g_return_val_if_fail (E_IS_PILOT_SETTINGS (ps), NULL);
-
- gtk_table_resize (GTK_TABLE (ps), E_PILOT_SETTINGS_TABLE_ROWS + 1, E_PILOT_SETTINGS_TABLE_COLS);
-
- gui = g_new0 (EToDoConduitGui, 1);
-
- rows = E_PILOT_SETTINGS_TABLE_ROWS;
- lbl = gtk_label_new (_("Default Priority:"));
- gtk_misc_set_alignment (GTK_MISC (lbl), 0.0, 0.5);
- adj = gtk_adjustment_new (1, 1, 5, 1, 5, 0);
- gui->priority = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 1.0, 0);
- gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (gui->priority), TRUE);
- gtk_table_attach_defaults (GTK_TABLE (ps), lbl, 0, 1, rows, rows + 1);
- gtk_table_attach_defaults (GTK_TABLE (ps), gui->priority, 1, 2, rows, rows + 1);
- gtk_widget_show (lbl);
- gtk_widget_show (gui->priority);
-
- return gui;
-}
-
-static void
-e_todo_gui_fill_widgets (EToDoConduitGui *gui, EToDoConduitCfg *cfg)
-{
- g_return_if_fail (gui != NULL);
- g_return_if_fail (cfg != NULL);
-
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (gui->priority), cfg->priority);
-}
-
-static void
-e_todo_gui_fill_config (EToDoConduitGui *gui, EToDoConduitCfg *cfg)
-{
- g_return_if_fail (gui != NULL);
- g_return_if_fail (cfg != NULL);
-
- cfg->priority = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (gui->priority));
-}
-
-static void
-e_todo_gui_destroy (EToDoConduitGui *gui)
-{
- g_free (gui);
-}
-
-/* Context */
-struct _EToDoConduitContext {
- GnomePilotDBInfo *dbi;
-
- EToDoConduitCfg *cfg;
- EToDoConduitCfg *new_cfg;
- EToDoConduitGui *gui;
- GtkWidget *ps;
-
- struct ToDoAppInfo ai;
-
- ECal *client;
-
- icaltimezone *timezone;
- ECalComponent *default_comp;
- GList *comps;
- GList *changed;
- GHashTable *changed_hash;
- GList *locals;
-
- EPilotMap *map;
- gchar *pilot_charset;
-};
-
-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->gui = NULL;
- ctxt->ps = NULL;
- ctxt->client = NULL;
- ctxt->timezone = NULL;
- ctxt->default_comp = NULL;
- ctxt->comps = NULL;
- ctxt->changed_hash = NULL;
- ctxt->changed = NULL;
- ctxt->locals = NULL;
- ctxt->map = NULL;
- ctxt->pilot_charset = NULL;
-
- return ctxt;
-}
-
-static gboolean
-e_todo_context_foreach_change (gpointer key, gpointer value, gpointer data)
-{
- g_free (key);
-
- return TRUE;
-}
-
-static void
-e_todo_context_destroy (EToDoConduitContext *ctxt)
-{
- GList *l;
-
- g_return_if_fail (ctxt != NULL);
-
- if (ctxt->cfg != NULL)
- todoconduit_destroy_configuration (ctxt->cfg);
- if (ctxt->new_cfg != NULL)
- todoconduit_destroy_configuration (ctxt->new_cfg);
- if (ctxt->gui != NULL)
- e_todo_gui_destroy (ctxt->gui);
-
- if (ctxt->client != NULL)
- g_object_unref (ctxt->client);
-
- if (ctxt->default_comp != NULL)
- g_object_unref (ctxt->default_comp);
- if (ctxt->comps != NULL) {
- for (l = ctxt->comps; l; l = l->next)
- g_object_unref (l->data);
- g_list_free (ctxt->comps);
- }
-
- if (ctxt->changed_hash != NULL) {
- g_hash_table_foreach_remove (ctxt->changed_hash, e_todo_context_foreach_change, NULL);
- g_hash_table_destroy (ctxt->changed_hash);
- }
-
- if (ctxt->locals != NULL) {
- for (l = ctxt->locals; l != NULL; l = l->next)
- todoconduit_destroy_record (l->data);
- g_list_free (ctxt->locals);
- }
-
- if (ctxt->changed != NULL)
- e_cal_free_change_list (ctxt->changed);
-
- if (ctxt->map != NULL)
- e_pilot_map_destroy (ctxt->map);
-
- g_free (ctxt);
-}
-
-/* Debug routines */
-static gchar *
-print_local (EToDoLocalRecord *local)
-{
- static gchar 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' %d]",
- 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 : "",
- local->local.category);
- return buff;
- }
-
- strcpy (buff, "");
- return buff;
-}
-
-static gchar *print_remote (GnomePilotRecord *remote, const gchar *pilot_charset)
-{
- static gchar buff[ 4096 ];
- struct ToDo todo;
-#ifdef PILOT_LINK_0_12
- pi_buffer_t * buffer;
-#endif
- if (remote == NULL) {
- sprintf (buff, "[NULL]");
- return buff;
- }
-
- memset (&todo, 0, sizeof (struct ToDo));
-#ifdef PILOT_LINK_0_12
- buffer = pi_buffer_new(DLP_BUF_SIZE);
- if (buffer == NULL) {
- sprintf (buff, "[NULL]");
- return buff;
- }
- if (pi_buffer_append(buffer, remote->record, remote->length)==NULL) {
- sprintf (buff, "[NULL]");
- return buff;
- }
- unpack_ToDo (&todo, buffer, todo_v1);
- pi_buffer_free(buffer);
-#else
- unpack_ToDo (&todo, remote->record, remote->length);
-#endif
- g_snprintf (buff, 4096, "[%d %ld %d %d '%s' '%s' %d]",
- todo.indefinite,
- mktime (&todo.due),
- todo.priority,
- todo.complete,
- todo.description ?
- e_pilot_utf8_from_pchar(todo.description, pilot_charset) : "",
- todo.note ?
- e_pilot_utf8_from_pchar(todo.note, pilot_charset) : "",
- remote->category);
-
- free_ToDo (&todo);
-
- return buff;
-}
-
-static gchar *
-auth_func_cb (ECal *ecal, const gchar * prompt, const gchar *key, gpointer user_data)
-{
- gchar *password;
- ESource *source;
- const gchar *auth_domain, *component_name;
-
- source = e_cal_get_source (ecal);
- auth_domain = e_source_get_property (source, "auth-domain");
- component_name = auth_domain ? auth_domain : "Todo";
- password = e_passwords_get_password (component_name, key);
-
- LOG (g_message ("auth_domain = %s, component_name = %s\n",
- auth_domain, component_name));
- return password;
-}
-
-static gint
-start_calendar_server (EToDoConduitContext *ctxt)
-{
- gchar *str_uri = NULL;
- gchar *pass_key = NULL;
- gint retval = 0;
- g_return_val_if_fail (ctxt != NULL, -2);
-
- if (ctxt->cfg->source) {
- ctxt->client = e_cal_new (ctxt->cfg->source, E_CAL_SOURCE_TYPE_TODO);
- /* Set the default timezone on the backend.
- As of Evo. 2.5.x, timezone should be set before
- calling e_cal_open.
- */
- if (ctxt->timezone && !e_cal_set_default_timezone (ctxt->client, ctxt->timezone, NULL))
- return -1;
-
- LOG (g_message ( " timezone set to : %s", icaltimezone_get_tzid (ctxt->timezone) ));
-
- if (e_source_get_property (ctxt->cfg->source, "auth")) {
- EUri *e_uri;
-
- LOG (g_message ("Authenticating to fetch todo data\n"));
- str_uri = e_source_get_uri (ctxt->cfg->source);
- e_uri = e_uri_new (str_uri);
- pass_key = e_uri_to_string (e_uri, FALSE);
- e_uri_free (e_uri);
- if (ctxt->client)
- e_cal_set_auth_func (ctxt->client, (ECalAuthFunc) auth_func_cb, NULL);
- }
- if (!e_cal_open (ctxt->client, TRUE, NULL))
- retval = -1;
- } else if (!e_cal_open_default (&ctxt->client, E_CAL_SOURCE_TYPE_TODO, NULL, NULL, NULL)) {
- retval = -1;
- }
-
- g_free (str_uri);
- g_free (pass_key);
- return retval;
-}
-
-/* Utility routines */
-static icaltimezone *
-get_timezone (ECal *client, const gchar *tzid)
-{
- icaltimezone *timezone = NULL;
-
- timezone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
- if (timezone == NULL)
- e_cal_get_timezone (client, tzid, &timezone, NULL);
-
- return timezone;
-}
-
-static icaltimezone *
-get_default_timezone (void)
-{
- GConfClient *client;
- icaltimezone *timezone = NULL;
- const gchar *key;
- gchar *location;
-
- client = gconf_client_get_default ();
- key = "/apps/evolution/calendar/display/timezone";
- location = gconf_client_get_string (client, key, NULL);
-
- if (location == NULL || *location == '\0') {
- g_free (location);
- location = g_strdup ("UTC");
- }
-
- timezone = icaltimezone_get_builtin_timezone (location);
- g_free (location);
-
- g_object_unref (client);
-
- return timezone;
-}
-
-static gchar *
-map_name (EToDoConduitContext *ctxt)
-{
- gchar *filename;
-
- filename = g_strdup_printf ("%s/.evolution/tasks/local/system/pilot-map-todo-%d.xml", g_get_home_dir (), ctxt->cfg->pilot_id);
-
- return filename;
-}
-
-static gboolean
-is_empty_time (struct tm time)
-{
- if (time.tm_sec || time.tm_min || time.tm_hour
- || time.tm_mday || time.tm_mon || time.tm_year)
- return FALSE;
-
- return TRUE;
-}
-
-static GList *
-next_changed_item (EToDoConduitContext *ctxt, GList *changes)
-{
- ECalChange *ccc;
- GList *l;
-
- for (l = changes; l != NULL; l = l->next) {
- const gchar *uid;
-
- ccc = l->data;
-
- e_cal_component_get_uid (ccc->comp, &uid);
- if (g_hash_table_lookup (ctxt->changed_hash, uid))
- return l;
- }
-
- return NULL;
-}
-
-static void
-compute_status (EToDoConduitContext *ctxt, EToDoLocalRecord *local, const gchar *uid)
-{
- ECalChange *ccc;
-
- local->local.archived = FALSE;
- local->local.secret = FALSE;
-
- ccc = g_hash_table_lookup (ctxt->changed_hash, uid);
-
- if (ccc == NULL) {
- local->local.attr = GnomePilotRecordNothing;
- return;
- }
-
- switch (ccc->type) {
- case E_CAL_CHANGE_ADDED:
- local->local.attr = GnomePilotRecordNew;
- break;
- case E_CAL_CHANGE_MODIFIED:
- local->local.attr = GnomePilotRecordModified;
- break;
- case E_CAL_CHANGE_DELETED:
- local->local.attr = GnomePilotRecordDeleted;
- break;
- }
-}
-
-static GnomePilotRecord
-local_record_to_pilot_record (EToDoLocalRecord *local,
- EToDoConduitContext *ctxt)
-{
- GnomePilotRecord p;
-#ifdef PILOT_LINK_0_12
- pi_buffer_t * buffer;
-#else
- static gchar record[0xffff];
-#endif
-
- g_assert (local->comp != NULL);
- g_assert (local->todo != NULL );
-
- LOG (g_message ( "local_record_to_pilot_record\n" ));
-
- memset (&p, 0, sizeof (GnomePilotRecord));
-
- memset(&p, 0, sizeof (p));
-
- p.ID = local->local.ID;
- p.category = local->local.category;
- p.attr = local->local.attr;
- p.archived = local->local.archived;
- p.secret = local->local.secret;
-
- /* Generate pilot record structure */
-#ifdef PILOT_LINK_0_12
- buffer = pi_buffer_new(DLP_BUF_SIZE);
- if (buffer == NULL) {
- pi_set_error(ctxt->dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
- return p;
- }
-
- pack_ToDo (local->todo, buffer, todo_v1);
- p.record = g_new0(unsigned char, buffer->used);
- p.length = buffer->used;
- memcpy(p.record, buffer->data, buffer->used);
-
- pi_buffer_free(buffer);
-#else
- p.record = (guchar *)record;
- p.length = pack_ToDo (local->todo, p.record, 0xffff);
-#endif
- return p;
-}
-
-/*
- * converts a ECalComponent object to a EToDoLocalRecord
- */
-static void
-local_record_from_comp (EToDoLocalRecord *local, ECalComponent *comp, EToDoConduitContext *ctxt)
-{
- const gchar *uid;
- gint *priority;
- icalproperty_status status;
- ECalComponentText summary;
- GSList *d_list = NULL;
- ECalComponentText *description;
- ECalComponentDateTime due;
- ECalComponentClassification classif;
- icaltimezone *default_tz = get_default_timezone ();
-
- LOG (g_message ( "local_record_from_comp\n" ));
-
- g_return_if_fail (local != NULL);
- g_return_if_fail (comp != NULL);
-
- local->comp = comp;
- g_object_ref (comp);
-
- e_cal_component_get_uid (local->comp, &uid);
- local->local.ID = e_pilot_map_lookup_pid (ctxt->map, uid, TRUE);
-
- compute_status (ctxt, local, uid);
-
- local->todo = g_new0 (struct ToDo,1);
-
- /* Don't overwrite the category */
- if (local->local.ID != 0) {
- gint cat = 0;
-#ifdef PILOT_LINK_0_12
- pi_buffer_t * record;
- record = pi_buffer_new(DLP_BUF_SIZE);
- if (record == NULL) {
- pi_set_error(ctxt->dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
- return;
- }
-#else
- gchar record[0xffff];
-#endif
-
- if (dlp_ReadRecordById (ctxt->dbi->pilot_socket,
- ctxt->dbi->db_handle,
-#ifdef PILOT_LINK_0_12
- local->local.ID, record,
- NULL, NULL, &cat) > 0) {
-#else
- local->local.ID, &record,
- NULL, NULL, NULL, &cat) > 0) {
-#endif
- local->local.category = cat;
- }
-#ifdef PILOT_LINK_0_12
- pi_buffer_free(record);
-#endif
- }
-
- /*Category support*/
- e_pilot_local_category_to_remote(&(local->local.category), comp, &(ctxt->ai.category), ctxt->pilot_charset);
-
- /* STOP: don't replace these with g_strdup, since free_ToDo
- uses free to deallocate */
- e_cal_component_get_summary (comp, &summary);
- if (summary.value)
- local->todo->description = e_pilot_utf8_to_pchar (summary.value, ctxt->pilot_charset);
-
- e_cal_component_get_description_list (comp, &d_list);
- if (d_list) {
- description = (ECalComponentText *) d_list->data;
- if (description && description->value)
- local->todo->note = e_pilot_utf8_to_pchar (description->value, ctxt->pilot_charset);
- else
- local->todo->note = NULL;
- } else {
- local->todo->note = NULL;
- }
-
- e_cal_component_get_due (comp, &due);
- if (due.value) {
- icaltimezone_convert_time (due.value,
- get_timezone (ctxt->client, due.tzid),
- default_tz);
- local->todo->due = icaltimetype_to_tm (due.value);
- local->todo->indefinite = 0;
- } else {
- local->todo->indefinite = 1;
- }
- e_cal_component_free_datetime (&due);
-
- e_cal_component_get_status (comp, &status);
- if (status == ICAL_STATUS_COMPLETED)
- local->todo->complete = 1;
- else
- local->todo->complete = 0;
-
- e_cal_component_get_priority (comp, &priority);
- if (priority && *priority != 0) {
- if (*priority <= 3)
- local->todo->priority = 1;
- else if (*priority == 4)
- local->todo->priority = 2;
- else if (*priority == 5)
- local->todo->priority = 3;
- else if (*priority <= 7)
- local->todo->priority = 4;
- else
- local->todo->priority = 5;
- } else {
- local->todo->priority = ctxt->cfg->priority;
- }
-
- if (priority)
- e_cal_component_free_priority (priority);
-
- e_cal_component_get_classification (comp, &classif);
-
- if (classif == E_CAL_COMPONENT_CLASS_PRIVATE)
- local->local.secret = 1;
- else
- local->local.secret = 0;
-
- local->local.archived = 0;
-}
-
-static void
-local_record_from_uid (EToDoLocalRecord *local,
- const gchar *uid,
- EToDoConduitContext *ctxt)
-{
- ECalComponent *comp;
- icalcomponent *icalcomp;
- GError *error = NULL;
-
- g_assert(local!=NULL);
-
- LOG(g_message("local_record_from_uid\n"));
-
- if (e_cal_get_object (ctxt->client, uid, NULL, &icalcomp, &error)) {
- comp = e_cal_component_new ();
- if (!e_cal_component_set_icalcomponent (comp, icalcomp)) {
- g_object_unref (comp);
- icalcomponent_free (icalcomp);
- return;
- }
-
- local_record_from_comp (local, comp, ctxt);
- g_object_unref (comp);
- } else if (error->code == E_CALENDAR_STATUS_OBJECT_NOT_FOUND) {
- comp = e_cal_component_new ();
- e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_TODO);
- e_cal_component_set_uid (comp, uid);
- local_record_from_comp (local, comp, ctxt);
- g_object_unref (comp);
- } else {
- INFO ("Object did not exist");
- }
-
- g_clear_error (&error);
-}
-
-static ECalComponent *
-comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
- GnomePilotRecord *remote,
- ECalComponent *in_comp,
- icaltimezone *timezone,
- struct ToDoAppInfo *ai,
- const gchar *pilot_charset)
-{
- ECalComponent *comp;
- struct ToDo todo;
- ECalComponentText summary = {NULL, NULL};
- ECalComponentDateTime dt = {NULL, icaltimezone_get_tzid (timezone)};
- struct icaltimetype due, now;
- icaltimezone *utc_zone;
- gint priority;
- gchar *txt;
-#ifdef PILOT_LINK_0_12
- pi_buffer_t * buffer;
-#endif
-
- g_return_val_if_fail (remote != NULL, NULL);
-
-#ifdef PILOT_LINK_0_12
- buffer = pi_buffer_new(DLP_BUF_SIZE);
- if (buffer == NULL) {
- return NULL;
- }
-
- if (pi_buffer_append(buffer, remote->record, remote->length)==NULL) {
- return NULL;
- }
-
- unpack_ToDo (&todo, buffer, todo_v1);
- pi_buffer_free(buffer);
-#else
- memset (&todo, 0, sizeof (struct ToDo));
- unpack_ToDo (&todo, remote->record, remote->length);
-#endif
-
- utc_zone = icaltimezone_get_utc_timezone ();
- now = icaltime_from_timet_with_zone (time (NULL), FALSE,
- utc_zone);
-
- if (in_comp == NULL) {
- comp = e_cal_component_new ();
- e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_TODO);
- e_cal_component_set_created (comp, &now);
- } else {
- comp = e_cal_component_clone (in_comp);
- }
-
- e_cal_component_set_last_modified (comp, &now);
-
- summary.value = txt = e_pilot_utf8_from_pchar (todo.description, pilot_charset);
- e_cal_component_set_summary (comp, &summary);
- free (txt);
-
- /*Category support*/
- e_pilot_remote_category_to_local(remote->category, comp, &(ai->category), pilot_charset);
-
- /* The iCal description field */
- if (!todo.note) {
- e_cal_component_set_comment_list (comp, NULL);
- } else {
- GSList l;
- ECalComponentText text;
-
- text.value = txt = e_pilot_utf8_from_pchar (todo.note, pilot_charset);
- text.altrep = NULL;
- l.data = &text;
- l.next = NULL;
-
- e_cal_component_set_description_list (comp, &l);
- free (txt);
- }
-
- if (todo.complete) {
- gint percent = 100;
-
- e_cal_component_set_completed (comp, &now);
- e_cal_component_set_percent (comp, &percent);
- e_cal_component_set_status (comp, ICAL_STATUS_COMPLETED);
- } else {
- gint *percent = NULL;
- icalproperty_status status;
-
- e_cal_component_set_completed (comp, NULL);
-
- e_cal_component_get_percent (comp, &percent);
- if (percent == NULL || *percent == 100) {
- gint p = 0;
- e_cal_component_set_percent (comp, &p);
- }
- if (percent != NULL)
- e_cal_component_free_percent (percent);
-
- e_cal_component_get_status (comp, &status);
- if (status == ICAL_STATUS_COMPLETED)
- e_cal_component_set_status (comp, ICAL_STATUS_NEEDSACTION);
- }
-
- if (!todo.indefinite && !is_empty_time (todo.due)) {
- due = tm_to_icaltimetype (&todo.due, TRUE);
- dt.value = &due;
- e_cal_component_set_due (comp, &dt);
- } else
- e_cal_component_set_due (comp, NULL);
-
- switch (todo.priority) {
- case 1:
- priority = 3;
- break;
- case 2:
- priority = 5;
- break;
- case 3:
- priority = 5;
- break;
- case 4:
- priority = 7;
- break;
- default:
- priority = 9;
- }
-
- e_cal_component_set_priority (comp, &priority);
- e_cal_component_set_transparency (comp, E_CAL_COMPONENT_TRANSP_NONE);
-
- if (remote->secret)
- e_cal_component_set_classification (comp, E_CAL_COMPONENT_CLASS_PRIVATE);
- else
- e_cal_component_set_classification (comp, E_CAL_COMPONENT_CLASS_PUBLIC);
-
- e_cal_component_commit_sequence (comp);
-
- free_ToDo(&todo);
-
- return comp;
-}
-
-static void
-check_for_slow_setting (GnomePilotConduit *c, EToDoConduitContext *ctxt)
-{
- GnomePilotConduitStandard *conduit = GNOME_PILOT_CONDUIT_STANDARD (c);
- gint map_count;
- const gchar *uri;
-
- /* If there are no objects or objects but no log */
- map_count = g_hash_table_size (ctxt->map->pid_map);
- if (map_count == 0)
- gnome_pilot_conduit_standard_set_slow (conduit, TRUE);
-
- /* Or if the URI's don't match */
- uri = e_cal_get_uri (ctxt->client);
- LOG (g_message ( " Current URI %s (%s)\n", uri, ctxt->cfg->last_uri ? ctxt->cfg->last_uri : "<NONE>" ));
- if (ctxt->cfg->last_uri != NULL && strcmp (ctxt->cfg->last_uri, uri)) {
- gnome_pilot_conduit_standard_set_slow (conduit, TRUE);
- e_pilot_map_clear (ctxt->map);
- }
-
- if (gnome_pilot_conduit_standard_get_slow (conduit)) {
- ctxt->map->write_touched_only = TRUE;
- LOG (g_message ( " doing slow sync\n" ));
- } else {
- LOG (g_message ( " doing fast sync\n" ));
- }
-}
-
-/* Pilot syncing callbacks */
-static gint
-pre_sync (GnomePilotConduit *conduit,
- GnomePilotDBInfo *dbi,
- EToDoConduitContext *ctxt)
-{
- GnomePilotConduitSyncAbs *abs_conduit;
- GList *l;
- gint len;
- guchar *buf;
- gchar *filename, *change_id;
- icalcomponent *icalcomp;
- gint num_records, add_records = 0, mod_records = 0, del_records = 0;
-#ifdef PILOT_LINK_0_12
- pi_buffer_t * buffer;
-#endif
-
- abs_conduit = GNOME_PILOT_CONDUIT_SYNC_ABS (conduit);
-
- LOG (g_message ( "---------------------------------------------------------\n" ));
- LOG (g_message ( "pre_sync: ToDo Conduit v.%s", CONDUIT_VERSION ));
- g_message ("ToDo Conduit v.%s", CONDUIT_VERSION);
-
- ctxt->dbi = dbi;
- ctxt->client = NULL;
-
-#ifdef PILOT_LINK_0_12
- if (NULL == dbi->pilotInfo->pilot_charset)
- ctxt->pilot_charset = NULL;
- else
- ctxt->pilot_charset = g_strdup(dbi->pilotInfo->pilot_charset);
-#endif
-
- /* Get the timezone */
- ctxt->timezone = get_default_timezone ();
- if (ctxt->timezone == NULL)
- return -1;
- LOG (g_message ( " Using timezone: %s", icaltimezone_get_tzid (ctxt->timezone) ));
-
- if (start_calendar_server (ctxt) != 0) {
- WARN(_("Could not start evolution-data-server"));
- gnome_pilot_conduit_error (conduit, _("Could not start evolution-data-server"));
- return -1;
- }
-
- /* Get the default component */
- if (!e_cal_get_default_object (ctxt->client, &icalcomp, NULL))
- return -1;
- LOG (g_message (" Got default component: %p", (gpointer) icalcomp));
-
- ctxt->default_comp = e_cal_component_new ();
- if (!e_cal_component_set_icalcomponent (ctxt->default_comp, icalcomp)) {
- g_object_unref (ctxt->default_comp);
- icalcomponent_free (icalcomp);
- return -1;
- }
-
- /* Load the uid <--> pilot id map */
- filename = map_name (ctxt);
- e_pilot_map_read (filename, &ctxt->map);
- g_free (filename);
-
- /* Get the local database */
- if (!e_cal_get_object_list_as_comp (ctxt->client, "#t", &ctxt->comps, NULL))
- return -1;
-
- /* Count and hash the changes */
- change_id = g_strdup_printf ("pilot-sync-evolution-todo-%d", ctxt->cfg->pilot_id);
- if (!e_cal_get_changes (ctxt->client, change_id, &ctxt->changed, NULL))
- return -1;
-
- ctxt->changed_hash = g_hash_table_new (g_str_hash, g_str_equal);
- g_free (change_id);
-
- for (l = ctxt->changed; l != NULL; l = l->next) {
- ECalChange *ccc = l->data;
- const gchar *uid;
-
- e_cal_component_get_uid (ccc->comp, &uid);
- if (!e_pilot_map_uid_is_archived (ctxt->map, uid)) {
-
- g_hash_table_insert (ctxt->changed_hash, g_strdup (uid), ccc);
-
- switch (ccc->type) {
- case E_CAL_CHANGE_ADDED:
- add_records++;
- break;
- case E_CAL_CHANGE_MODIFIED:
- mod_records++;
- break;
- case E_CAL_CHANGE_DELETED:
- del_records++;
- break;
- }
- } else if (ccc->type == E_CAL_CHANGE_DELETED) {
- e_pilot_map_remove_by_uid (ctxt->map, uid);
- }
- }
-
- /* Set the count information */
- num_records = g_list_length (ctxt->comps);
- gnome_pilot_conduit_sync_abs_set_num_local_records(abs_conduit, num_records);
- gnome_pilot_conduit_sync_abs_set_num_new_local_records (abs_conduit, add_records);
- gnome_pilot_conduit_sync_abs_set_num_updated_local_records (abs_conduit, mod_records);
- gnome_pilot_conduit_sync_abs_set_num_deleted_local_records(abs_conduit, del_records);
-
- g_message("num_records: %d\nadd_records: %d\nmod_records: %d\ndel_records: %d\n",
- num_records, add_records, mod_records, del_records);
-
-#ifdef PILOT_LINK_0_12
- buffer = pi_buffer_new(DLP_BUF_SIZE);
- if (buffer == NULL) {
- pi_set_error(dbi->pilot_socket, PI_ERR_GENERIC_MEMORY);
- return -1;
- }
- len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
- DLP_BUF_SIZE,
- buffer);
-#else
- buf = (guchar *)g_malloc (0xffff);
- len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
- (guchar *)buf, 0xffff);
-#endif
- if (len < 0) {
- WARN (_("Could not read pilot's ToDo application block"));
- WARN ("dlp_ReadAppBlock(...) = %d", len);
- gnome_pilot_conduit_error (conduit,
- _("Could not read pilot's ToDo application block"));
- return -1;
- }
-
-#ifdef PILOT_LINK_0_12
- buf = g_new0 (unsigned char,buffer->used);
- memcpy(buf, buffer->data,buffer->used);
- pi_buffer_free(buffer);
-#endif
- unpack_ToDoAppInfo (&(ctxt->ai), buf, len);
- g_free (buf);
-
- lastDesktopUniqueID = 128;
-
- check_for_slow_setting (conduit, ctxt);
- if (ctxt->cfg->sync_type == GnomePilotConduitSyncTypeCopyToPilot
- || ctxt->cfg->sync_type == GnomePilotConduitSyncTypeCopyFromPilot)
- ctxt->map->write_touched_only = TRUE;
-
- return 0;
-}
-
-static gint
-post_sync (GnomePilotConduit *conduit,
- GnomePilotDBInfo *dbi,
- EToDoConduitContext *ctxt)
-{
- GList *changed;
- gchar *filename, *change_id;
- guchar *buf;
- gint dlpRetVal, len;
-
- buf = (guchar *)g_malloc (0xffff);
-
- len = pack_ToDoAppInfo (&(ctxt->ai), buf, 0xffff);
-
- dlpRetVal = dlp_WriteAppBlock (dbi->pilot_socket, dbi->db_handle,
- (guchar *)buf, len);
-
- g_free (buf);
-
- if (dlpRetVal < 0) {
- WARN (_("Could not write pilot's ToDo application block"));
- WARN ("dlp_WriteAppBlock(...) = %d", dlpRetVal);
- gnome_pilot_conduit_error (conduit,
- _("Could not write pilot's ToDo application block"));
- return -1;
- }
-
- LOG (g_message ( "post_sync: ToDo Conduit v.%s", CONDUIT_VERSION ));
-
- g_free (ctxt->cfg->last_uri);
- ctxt->cfg->last_uri = g_strdup (e_cal_get_uri (ctxt->client));
- todoconduit_save_configuration (ctxt->cfg);
-
- filename = map_name (ctxt);
- e_pilot_map_write (filename, ctxt->map);
- g_free (filename);
-
- /* FIX ME ugly hack - our changes musn't count, this does introduce
- * a race condition if anyone changes a record elsewhere during sycnc
- */
- change_id = g_strdup_printf ("pilot-sync-evolution-todo-%d", ctxt->cfg->pilot_id);
- if (e_cal_get_changes (ctxt->client, change_id, &changed, NULL))
- e_cal_free_change_list (changed);
- g_free (change_id);
- if (ctxt->pilot_charset)
- g_free (ctxt->pilot_charset);
- LOG (g_message ( "---------------------------------------------------------\n" ));
-
- return 0;
-}
-
-static gint
-set_pilot_id (GnomePilotConduitSyncAbs *conduit,
- EToDoLocalRecord *local,
- guint32 ID,
- EToDoConduitContext *ctxt)
-{
- const gchar *uid;
-
- LOG (g_message ( "set_pilot_id: setting to %d\n", ID ));
-
- e_cal_component_get_uid (local->comp, &uid);
- e_pilot_map_insert (ctxt->map, ID, uid, FALSE);
-
- return 0;
-}
-
-static gint
-set_status_cleared (GnomePilotConduitSyncAbs *conduit,
- EToDoLocalRecord *local,
- EToDoConduitContext *ctxt)
-{
- const gchar *uid;
-
- LOG (g_message ( "set_status_cleared: clearing status\n" ));
-
- e_cal_component_get_uid (local->comp, &uid);
- g_hash_table_remove (ctxt->changed_hash, uid);
-
- return 0;
-}
-
-static gint
-for_each (GnomePilotConduitSyncAbs *conduit,
- EToDoLocalRecord **local,
- EToDoConduitContext *ctxt)
-{
- static GList *comps, *iterator;
- static gint count;
- GList *unused;
-
- g_return_val_if_fail (local != NULL, -1);
-
- if (*local == NULL) {
- LOG (g_message ( "beginning for_each" ));
-
- comps = ctxt->comps;
- count = 0;
-
- if (comps != NULL) {
- LOG (g_message ( "iterating over %d records", g_list_length (comps)));
-
- *local = g_new0 (EToDoLocalRecord, 1);
- local_record_from_comp (*local, comps->data, ctxt);
-
- /* NOTE: ignore the return value, otherwise ctxt->locals
- * gets messed up. The calling function keeps track of
- * the *local variable */
- unused = g_list_prepend (ctxt->locals, *local);
-
- iterator = comps;
- } else {
- LOG (g_message ( "no events" ));
- (*local) = NULL;
- return 0;
- }
- } else {
- count++;
- if (g_list_next (iterator)) {
- iterator = g_list_next (iterator);
-
- *local = g_new0 (EToDoLocalRecord, 1);
- local_record_from_comp (*local, iterator->data, ctxt);
-
- /* NOTE: ignore the return value, otherwise ctxt->locals
- * gets messed up. The calling function keeps track of
- * the *local variable */
- unused = g_list_prepend (ctxt->locals, *local);
- } else {
- LOG (g_message ( "for_each ending" ));
-
- /* Tell the pilot the iteration is over */
- *local = NULL;
-
- return 0;
- }
- }
-
- return 0;
-}
-
-static gint
-for_each_modified (GnomePilotConduitSyncAbs *conduit,
- EToDoLocalRecord **local,
- EToDoConduitContext *ctxt)
-{
- static GList *iterator;
- static gint count;
- GList *unused;
-
- g_return_val_if_fail (local != NULL, 0);
-
- if (*local == NULL) {
- LOG (g_message ( "for_each_modified beginning\n" ));
-
- iterator = ctxt->changed;
-
- count = 0;
-
- LOG (g_message ( "iterating over %d records", g_hash_table_size (ctxt->changed_hash) ));
-
- iterator = next_changed_item (ctxt, iterator);
- if (iterator != NULL) {
- ECalChange *ccc = iterator->data;
-
- *local = g_new0 (EToDoLocalRecord, 1);
- local_record_from_comp (*local, ccc->comp, ctxt);
-
- /* NOTE: ignore the return value, otherwise ctxt->locals
- * gets messed up. The calling function keeps track of
- * the *local variable */
- unused = g_list_prepend (ctxt->locals, *local);
- } else {
- LOG (g_message ( "no events" ));
-
- *local = NULL;
- }
- } else {
- count++;
- iterator = g_list_next (iterator);
- if (iterator && (iterator = next_changed_item (ctxt, iterator))) {
- ECalChange *ccc = iterator->data;
-
- *local = g_new0 (EToDoLocalRecord, 1);
- local_record_from_comp (*local, ccc->comp, ctxt);
-
- /* NOTE: ignore the return value, otherwise ctxt->locals
- * gets messed up. The calling function keeps track of
- * the *local variable */
- unused = g_list_prepend (ctxt->locals, *local);
- } else {
- LOG (g_message ( "for_each_modified ending" ));
-
- /* Signal the iteration is over */
- *local = NULL;
- }
- }
-
- return 0;
-}
-
-static gint
-compare (GnomePilotConduitSyncAbs *conduit,
- EToDoLocalRecord *local,
- GnomePilotRecord *remote,
- EToDoConduitContext *ctxt)
-{
- /* used by the quick compare */
- GnomePilotRecord local_pilot;
- gint retval = 0;
-
- LOG (g_message ("compare: local=%s remote=%s...\n",
- print_local (local), print_remote (remote, ctxt->pilot_charset)));
-
- g_return_val_if_fail (local!=NULL,-1);
- g_return_val_if_fail (remote!=NULL,-1);
-
- local_pilot = local_record_to_pilot_record (local, ctxt);
-
- if (remote->length != local_pilot.length
- || memcmp (local_pilot.record, remote->record, remote->length))
- retval = 1;
-
- if (retval == 0)
- LOG (g_message ( " equal" ));
- else
- LOG (g_message ( " not equal" ));
-
- return retval;
-}
-
-static gint
-add_record (GnomePilotConduitSyncAbs *conduit,
- GnomePilotRecord *remote,
- EToDoConduitContext *ctxt)
-{
- ECalComponent *comp;
- gchar *uid;
- gint retval = 0;
-
- g_return_val_if_fail (remote != NULL, -1);
-
- LOG (g_message ( "add_record: adding %s to desktop\n", print_remote (remote, ctxt->pilot_charset) ));
-
- comp = comp_from_remote_record (conduit, remote, ctxt->default_comp, ctxt->timezone, &(ctxt->ai), ctxt->pilot_charset);
-
- /* Give it a new UID otherwise it will be the uid of the default comp */
- uid = e_cal_component_gen_uid ();
- e_cal_component_set_uid (comp, uid);
-
- if (!e_cal_create_object (ctxt->client, e_cal_component_get_icalcomponent (comp), NULL, NULL))
- return -1;
-
- e_pilot_map_insert (ctxt->map, remote->ID, uid, FALSE);
-
- g_object_unref (comp);
- g_free (uid);
-
- return retval;
-}
-
-static gint
-replace_record (GnomePilotConduitSyncAbs *conduit,
- EToDoLocalRecord *local,
- GnomePilotRecord *remote,
- EToDoConduitContext *ctxt)
-{
- ECalComponent *new_comp;
- gint retval = 0;
-
- g_return_val_if_fail (remote != NULL, -1);
-
- LOG (g_message ("replace_record: replace %s with %s\n",
- print_local (local), print_remote (remote, ctxt->pilot_charset)));
-
- new_comp = comp_from_remote_record (conduit, remote, local->comp, ctxt->timezone, &(ctxt->ai), ctxt->pilot_charset);
- g_object_unref (local->comp);
- local->comp = new_comp;
-
- if (!e_cal_modify_object (ctxt->client, e_cal_component_get_icalcomponent (new_comp),
- CALOBJ_MOD_ALL, NULL))
- return -1;
-
- return retval;
-}
-
-static gint
-delete_record (GnomePilotConduitSyncAbs *conduit,
- EToDoLocalRecord *local,
- EToDoConduitContext *ctxt)
-{
- const gchar *uid;
-
- g_return_val_if_fail (local != NULL, -1);
- g_return_val_if_fail (local->comp != NULL, -1);
-
- e_cal_component_get_uid (local->comp, &uid);
-
- LOG (g_message ( "delete_record: deleting %s\n", uid ));
-
- e_pilot_map_remove_by_uid (ctxt->map, uid);
- /* FIXME Error handling */
- e_cal_remove_object (ctxt->client, uid, NULL);
-
- return 0;
-}
-
-static gint
-archive_record (GnomePilotConduitSyncAbs *conduit,
- EToDoLocalRecord *local,
- gboolean archive,
- EToDoConduitContext *ctxt)
-{
- const gchar *uid;
- gint retval = 0;
-
- g_return_val_if_fail (local != NULL, -1);
-
- LOG (g_message ( "archive_record: %s\n", archive ? "yes" : "no" ));
-
- e_cal_component_get_uid (local->comp, &uid);
- e_pilot_map_insert (ctxt->map, local->local.ID, uid, archive);
-
- return retval;
-}
-
-static gint
-match (GnomePilotConduitSyncAbs *conduit,
- GnomePilotRecord *remote,
- EToDoLocalRecord **local,
- EToDoConduitContext *ctxt)
-{
- const gchar *uid;
-
- LOG (g_message ("match: looking for local copy of %s\n",
- print_remote (remote, ctxt->pilot_charset)));
-
- g_return_val_if_fail (local != NULL, -1);
- g_return_val_if_fail (remote != NULL, -1);
-
- *local = NULL;
- uid = e_pilot_map_lookup_uid (ctxt->map, remote->ID, TRUE);
-
- if (!uid)
- return 0;
-
- LOG (g_message ( " matched\n" ));
-
- *local = g_new0 (EToDoLocalRecord, 1);
- local_record_from_uid (*local, uid, ctxt);
-
- return 0;
-}
-
-static gint
-free_match (GnomePilotConduitSyncAbs *conduit,
- EToDoLocalRecord *local,
- EToDoConduitContext *ctxt)
-{
- LOG (g_message ( "free_match: freeing\n" ));
-
- g_return_val_if_fail (local != NULL, -1);
-
- ctxt->locals = g_list_remove (ctxt->locals, local);
-
- todoconduit_destroy_record (local);
-
- return 0;
-}
-
-static gint
-prepare (GnomePilotConduitSyncAbs *conduit,
- EToDoLocalRecord *local,
- GnomePilotRecord *remote,
- EToDoConduitContext *ctxt)
-{
- LOG (g_message ( "prepare: encoding local %s\n", print_local (local) ));
-
- *remote = local_record_to_pilot_record (local, ctxt);
-
- return 0;
-}
-
-/* Pilot Settings Callbacks */
-static void
-fill_widgets (EToDoConduitContext *ctxt)
-{
- if (ctxt->cfg->source)
- e_pilot_settings_set_source (E_PILOT_SETTINGS (ctxt->ps),
- ctxt->cfg->source);
- e_pilot_settings_set_secret (E_PILOT_SETTINGS (ctxt->ps),
- ctxt->cfg->secret);
-
- e_todo_gui_fill_widgets (ctxt->gui, ctxt->cfg);
-}
-
-static gint
-create_settings_window (GnomePilotConduit *conduit,
- GtkWidget *parent,
- EToDoConduitContext *ctxt)
-{
- LOG (g_message ( "create_settings_window" ));
-
- if (!ctxt->cfg->source_list)
- return -1;
-
- ctxt->ps = e_pilot_settings_new (ctxt->cfg->source_list);
- ctxt->gui = e_todo_gui_new (E_PILOT_SETTINGS (ctxt->ps));
-
- 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 (g_message ( "display_settings" ));
-
- fill_widgets (ctxt);
-}
-
-static void
-save_settings (GnomePilotConduit *conduit, EToDoConduitContext *ctxt)
-{
- LOG (g_message ( "save_settings" ));
-
- if (ctxt->new_cfg->source)
- g_object_unref (ctxt->new_cfg->source);
- ctxt->new_cfg->source = e_pilot_settings_get_source (E_PILOT_SETTINGS (ctxt->ps));
- g_object_ref (ctxt->new_cfg->source);
- ctxt->new_cfg->secret = e_pilot_settings_get_secret (E_PILOT_SETTINGS (ctxt->ps));
- e_todo_gui_fill_config (ctxt->gui, ctxt->new_cfg);
-
- todoconduit_save_configuration (ctxt->new_cfg);
-}
-
-static void
-revert_settings (GnomePilotConduit *conduit, EToDoConduitContext *ctxt)
-{
- LOG (g_message ( "revert_settings" ));
-
- todoconduit_save_configuration (ctxt->cfg);
- todoconduit_destroy_configuration (ctxt->new_cfg);
- ctxt->new_cfg = todoconduit_dupe_configuration (ctxt->cfg);
-}
-
-GnomePilotConduit *
-conduit_get_gpilot_conduit (guint32 pilot_id)
-{
- GtkObject *retval;
- EToDoConduitContext *ctxt;
-
- LOG (g_message ( "in todo's conduit_get_gpilot_conduit\n" ));
-
- retval = gnome_pilot_conduit_sync_abs_new ((gchar *)"ToDoDB", 0x746F646F);
- g_assert (retval != NULL);
-
- ctxt = e_todo_context_new (pilot_id);
- g_object_set_data (G_OBJECT (retval), "todoconduit_context", ctxt);
-
- g_signal_connect (retval, "pre_sync", G_CALLBACK (pre_sync), ctxt);
- g_signal_connect (retval, "post_sync", G_CALLBACK (post_sync), ctxt);
-
- g_signal_connect (retval, "set_pilot_id", G_CALLBACK (set_pilot_id), ctxt);
- g_signal_connect (retval, "set_status_cleared", G_CALLBACK (set_status_cleared), ctxt);
-
- g_signal_connect (retval, "for_each", G_CALLBACK (for_each), ctxt);
- g_signal_connect (retval, "for_each_modified", G_CALLBACK (for_each_modified), ctxt);
- g_signal_connect (retval, "compare", G_CALLBACK (compare), ctxt);
-
- g_signal_connect (retval, "add_record", G_CALLBACK (add_record), ctxt);
- g_signal_connect (retval, "replace_record", G_CALLBACK (replace_record), ctxt);
- g_signal_connect (retval, "delete_record", G_CALLBACK (delete_record), ctxt);
- g_signal_connect (retval, "archive_record", G_CALLBACK (archive_record), ctxt);
-
- g_signal_connect (retval, "match", G_CALLBACK (match), ctxt);
- g_signal_connect (retval, "free_match", G_CALLBACK (free_match), ctxt);
-
- g_signal_connect (retval, "prepare", G_CALLBACK (prepare), ctxt);
-
- /* Gui Settings */
- g_signal_connect (retval, "create_settings_window", G_CALLBACK (create_settings_window), ctxt);
- g_signal_connect (retval, "display_settings", G_CALLBACK (display_settings), ctxt);
- g_signal_connect (retval, "save_settings", G_CALLBACK (save_settings), ctxt);
- g_signal_connect (retval, "revert_settings", G_CALLBACK (revert_settings), ctxt);
-
- return GNOME_PILOT_CONDUIT (retval);
-}
-
-void
-conduit_destroy_gpilot_conduit (GnomePilotConduit *conduit)
-{
- GtkObject *obj = GTK_OBJECT (conduit);
- EToDoConduitContext *ctxt;
-
- ctxt = g_object_get_data (G_OBJECT (obj), "todoconduit_context");
- e_todo_context_destroy (ctxt);
-
- gtk_object_destroy (obj);
-}
diff --git a/configure.ac b/configure.ac
index 4a18cc3959..bcaec4cbb1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,7 +57,6 @@ m4_define([champlain_minimum_version], [0.4])
m4_define([geoclue_minimum_version], [0.11.1])
m4_define([clutter_gtk_minimum_version], [0.10.0])
m4_define([libnotify_minimum_version], [0.3.0])
-m4_define([gnome_pilot_minimum_version], [2.0.16])
m4_define([gweather_minimum_version], [2.25.3])
m4_define([gtkimageview_minimum_version], [1.6])
m4_define([gladeui_minimum_version], [3.0.0])
@@ -647,68 +646,6 @@ PKG_CHECK_MODULES([GTKHTML], [libgtkhtml-3.14 >= libgtkhtml_minimum_version])
AC_SUBST(GTKHTML_CFLAGS)
AC_SUBST(GTKHTML_LIBS)
-dnl ******************************
-dnl Pilot checking
-dnl ******************************
-AC_ARG_ENABLE([pilot-conduits],
- AS_HELP_STRING([--enable-pilot-conduits],
- [Enable support for building pilot conduits.]),,
- [enable_pilot_conduits=no])
-if test "x$enable_pilot_conduits" = "xyes"; then
- PKG_CHECK_MODULES([GNOME_PILOT], [gnome-pilot-2.0 >= gnome_pilot_minimum_version])
-
- CFLAGS_save="$CFLAGS"
- CFLAGS="$CFLAGS $GNOME_PILOT_CFLAGS"
- LIBS_save="$LIBS"
- LIBS="$LIBS $GNOME_PILOT_LIBS $LDFLAGS"
-
- AC_CACHE_CHECK([if pilot-link handles UTF-8 conversions],[ac_cv_pilot_link_utf8],
- AC_RUN_IFELSE([AC_LANG_SOURCE(
- [[ #include <stdlib.h>
- #include <string.h>
- #include <pi-util.h>
-
- int main (){
- const char *utf8 = "\x66\x66\x66\x66\x66\x66\x66\xC2\xA9";
- size_t utf8_real_len = strlen (utf8);
- char *pstring;
- if (convert_ToPilotChar ("UTF-8", utf8, utf8_real_len, &pstring) == -1)
- exit (1);
- return (0);
- }
- ]]
- )],[ac_cv_pilot_link_utf8=yes],[ac_cv_pilot_link_utf8=no],[ac_cv_pilot_link_utf8=no]))
-
- CFLAGS="$CFLAGS_save"
- LIBS="$LIBS_save"
-
- if test "$ac_cv_pilot_link_utf8" = no; then
- AC_MSG_ERROR([evolution requires pilot-link to have working UTF-8 conversion routines])
- fi
-fi
-AM_CONDITIONAL(ENABLE_PILOT_CONDUITS, [test x$enable_pilot_conduits = xyes])
-dnl ******************************
-dnl If pilot conduits are enabled, check version of pilot-link
-dnl ******************************
-if test x$enable_pilot_conduits = xyes; then
- msg_pilot=yes
-
- PILOT_LINK_CHECK(0.11.4)
- AC_SUBST(PILOT_LINK_MAJOR)
- AC_SUBST(PILOT_LINK_MINOR)
- AC_SUBST(PILOT_LINK_MICRO)
- AC_SUBST(PILOT_LINK_PATCH)
- AC_SUBST(PILOT_LINK_VERSION)
-
- if test $PILOT_LINK_MINOR -ge 12; then
- AC_DEFINE(PILOT_LINK_0_12,,[Building against pilot-link 0.12.0 or greater])
- fi
-else
- msg_pilot=no
-fi
-AC_SUBST(GNOME_PILOT_CFLAGS)
-AC_SUBST(GNOME_PILOT_LIBS)
-
dnl ************
dnl Kerberos 5
dnl ************
@@ -1298,12 +1235,6 @@ EVO_SET_COMPILE_FLAGS(EVOLUTION_ADDRESSBOOK, $EVOLUTION_ADDRESSBOOK_DEPS)
AC_SUBST(EVOLUTION_ADDRESSBOOK_CFLAGS)
AC_SUBST(EVOLUTION_ADDRESSBOOK_LIBS)
-if test x$enable_pilot_conduits = xyes; then
-EVO_SET_COMPILE_FLAGS(EVOLUTION_ADDRESSBOOK_CONDUIT, gnome-pilot-2.0 $EVOLUTION_ADDRESSBOOK_DEPS)
-AC_SUBST(EVOLUTION_ADDRESSBOOK_CONDUIT_CFLAGS)
-AC_SUBST(EVOLUTION_ADDRESSBOOK_CONDUIT_LIBS)
-fi
-
dnl ***************
dnl Libnotify Flags
dnl ***************
@@ -1334,12 +1265,6 @@ EVO_SET_COMPILE_FLAGS(EVOLUTION_CALENDAR, libgtkhtml-3.14 libebook-1.2 libecal-1
AC_SUBST(EVOLUTION_CALENDAR_CFLAGS)
AC_SUBST(EVOLUTION_CALENDAR_LIBS)
-if test x$enable_pilot_conduits = xyes; then
-EVO_SET_COMPILE_FLAGS(EVOLUTION_CALENDAR_CONDUIT, gnome-pilot-2.0, $EVOLUTION_CALENDAR_CFLAGS, $EVOLUTION_CALENDAR_LIBS)
-AC_SUBST(EVOLUTION_CALENDAR_CONDUIT_CFLAGS)
-AC_SUBST(EVOLUTION_CALENDAR_CONDUIT_LIBS)
-fi
-
dnl **********
dnl Mail Flags
dnl **********
@@ -1415,9 +1340,6 @@ AC_SUBST(etspecdir)
viewsdir="$privdatadir/views"
AC_SUBST(viewsdir)
-privconduitdir="$privlibdir/conduits"
-AC_SUBST(privconduitdir)
-
dnl For evolution-alarm-notify.desktop
AS_AC_EXPAND(PRIVLIBEXECDIR, "$privlibexecdir")
@@ -1685,7 +1607,6 @@ AC_CONFIG_FILES([ po/Makefile.in
Makefile
a11y/Makefile
addressbook/Makefile
-addressbook/conduit/Makefile
addressbook/gui/Makefile
addressbook/gui/contact-editor/Makefile
addressbook/gui/contact-list-editor/Makefile
@@ -1744,11 +1665,6 @@ widgets/table/Makefile
calendar/Makefile
calendar/importers/Makefile
calendar/common/Makefile
-calendar/conduits/Makefile
-calendar/conduits/common/Makefile
-calendar/conduits/todo/Makefile
-calendar/conduits/calendar/Makefile
-calendar/conduits/memo/Makefile
calendar/gui/Makefile
calendar/gui/alarm-notify/Makefile
calendar/gui/dialogs/Makefile
@@ -1858,7 +1774,6 @@ echo "
NetworkManager: $enable_nm
Windows SENS: $enable_sens
ConnMan: $enable_connman
- Pilot conduits: $msg_pilot
Libnotify: $HAVE_LIBNOTIFY
Kerberos 5: $msg_krb5
SSL support: $msg_ssl
diff --git a/doc/reference/shell/tmpl/eshell-unused.sgml b/doc/reference/shell/tmpl/eshell-unused.sgml
index 93f3a149fa..11fa5036ae 100644
--- a/doc/reference/shell/tmpl/eshell-unused.sgml
+++ b/doc/reference/shell/tmpl/eshell-unused.sgml
@@ -4,6 +4,13 @@
</para>
+<!-- ##### MACRO E_SHELL_WINDOW_ACTION_SYNC_OPTIONS ##### -->
+<para>
+
+</para>
+
+@window:
+
<!-- ##### FUNCTION e_shell_content_get_search_name ##### -->
<para>
diff --git a/doc/reference/shell/tmpl/shell-actions.sgml b/doc/reference/shell/tmpl/shell-actions.sgml
index 30d5291585..9a0878e5eb 100644
--- a/doc/reference/shell/tmpl/shell-actions.sgml
+++ b/doc/reference/shell/tmpl/shell-actions.sgml
@@ -268,14 +268,6 @@ Shell Actions
@window:
-<!-- ##### MACRO E_SHELL_WINDOW_ACTION_SYNC_OPTIONS ##### -->
-<para>
-
-</para>
-
-@window:
-
-
<!-- ##### MACRO E_SHELL_WINDOW_ACTION_WORK_OFFLINE ##### -->
<para>
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index 7df0e0d49e..f1c6131965 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -1,5 +1,4 @@
eutilincludedir = $(privincludedir)/e-util
-econdincludedir = $(privincludedir)/e-conduit
ecpsdir = $(privdatadir)/ecps
ruledir = $(privdatadir)
@@ -7,7 +6,7 @@ if OS_WIN32
PLATFORM_SOURCES = e-win32-reloc.c e-win32-defaults.c e-win32-defaults.h
endif
-privsolib_LTLIBRARIES = libeutil.la libeconduit.la
+privsolib_LTLIBRARIES = libeutil.la
eutilinclude_HEADERS = \
e-account-utils.h \
@@ -85,7 +84,6 @@ libeutil_la_CPPFLAGS = \
-DEVOLUTION_RULEDIR=\"$(ruledir)\" \
-DG_LOG_DOMAIN=\"e-utils\" \
$(GNOME_PLATFORM_CFLAGS) \
- $(GNOME_PILOT_CFLAGS) \
$(E_UTIL_CFLAGS)
libeutil_la_SOURCES = \
@@ -148,65 +146,15 @@ libeutil_la_LDFLAGS = $(NO_UNDEFINED)
libeutil_la_LIBADD = \
$(ICONV_LIBS) \
$(E_UTIL_LIBS) \
- $(GNOME_PILOT_LIBS) \
$(GNOME_PLATFORM_LIBS) \
$(INTLLIBS)
-econdinclude_HEADERS = \
- e-pilot-map.h \
- e-pilot-util.h
-
-pilot_sources = \
- $(econdinclude_HEADERS) \
- e-pilot-map.c \
- e-pilot-util.c
-
-if ENABLE_PILOT_CONDUITS
-pilot_compile = $(pilot_sources)
-else
-pilot_compile = e-html-utils.c
-endif
-
-libeconduit_la_CPPFLAGS = \
- $(AM_CPPFLAGS) \
- -I$(top_srcdir) \
- -I$(top_builddir) \
- -I$(top_srcdir)/widgets \
- -DEVOLUTION_DATADIR=\""$(datadir)"\" \
- -DEVOLUTION_ECPSDIR=\""$(ecpsdir)"\" \
- -DEVOLUTION_ETSPECDIR=\""$(etspecdir)"\" \
- -DEVOLUTION_GALVIEWSDIR=\""$(viewsdir)"\" \
- -DEVOLUTION_HELPDIR=\""$(evolutionhelpdir)"\" \
- -DEVOLUTION_ICONDIR=\""$(icondir)"\" \
- -DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" \
- -DEVOLUTION_LIBDIR=\""$(datadir)"\" \
- -DEVOLUTION_LIBEXECDIR=\""$(privlibexecdir)"\" \
- -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \
- -DEVOLUTION_PLUGINDIR=\""$(plugindir)"\" \
- -DEVOLUTION_PREFIX=\""$(prefix)"\" \
- -DEVOLUTION_PRIVDATADIR=\""$(privdatadir)"\" \
- -DEVOLUTION_SOUNDDIR=\""$(soundsdir)"\" \
- -DEVOLUTION_SYSCONFDIR=\""$(sysconfdir)"\" \
- -DEVOLUTION_TOOLSDIR=\""$(privlibexecdir)"\" \
- -DEVOLUTION_UIDIR=\""$(uidir)"\" \
- -DEVOLUTION_RULEDIR=\"$(ruledir)\" \
- -DG_LOG_DOMAIN=\"e-utils\" \
- $(GNOME_PILOT_CFLAGS) \
- $(E_UTIL_CFLAGS)
-
-libeconduit_la_SOURCES = $(pilot_compile)
-
-libeconduit_la_LDFLAGS = $(NO_UNDEFINED)
-
-libeconduit_la_LIBADD = $(E_UTIL_LIBS) $(GNOME_PILOT_LIBS)
-
error_DATA = e-system.error
errordir = $(privdatadir)/errors
@EVO_PLUGIN_RULE@
EXTRA_DIST = \
e-system.error.xml \
- $(pilot_sources) \
e-marshal.list
BUILT_SOURCES = $(MARSHAL_GENERATED) $(error_DATA)
diff --git a/e-util/e-pilot-map.c b/e-util/e-pilot-map.c
deleted file mode 100644
index 2c047d60f6..0000000000
--- a/e-util/e-pilot-map.c
+++ /dev/null
@@ -1,418 +0,0 @@
-/*
- * Evolution Conduits - Pilot Map routines
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * JP Rosevear <jpr@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#include <string.h>
-#include <stdlib.h>
-
-#include <glib.h>
-#include <libxml/parser.h>
-
-#include <libedataserver/e-xml-utils.h>
-
-#include "e-pilot-map.h"
-
-typedef struct
-{
- gchar *uid;
- gboolean archived;
- gboolean touched;
-} EPilotMapPidNode;
-
-typedef struct
-{
- guint32 pid;
- gboolean archived;
- gboolean touched;
-} EPilotMapUidNode;
-
-typedef struct
-{
- gboolean touched_only;
- xmlNodePtr root;
-} EPilotMapWriteData;
-
-static void
-real_e_pilot_map_insert (EPilotMap *map,
- guint32 pid,
- const gchar *uid,
- gboolean archived,
- gboolean touch)
-{
- gchar *new_uid;
- guint32 *new_pid = NULL;
- EPilotMapPidNode *pnode = NULL;
- EPilotMapUidNode *unode;
-
- g_return_if_fail (map != NULL);
- g_return_if_fail (uid != NULL);
-
- /* Keys */
- if (pid != 0) {
- new_pid = g_new (guint32, 1);
- *new_pid = pid;
- }
- new_uid = g_strdup (uid);
-
- /* Values */
- if (pid != 0) {
- pnode = g_new0 (EPilotMapPidNode, 1);
- pnode->uid = new_uid;
- pnode->archived = archived;
- if (touch)
- pnode->touched = TRUE;
- }
-
- unode = g_new0 (EPilotMapUidNode, 1);
- unode->pid = pid;
- unode->archived = archived;
- if (touch)
- unode->touched = TRUE;
-
- /* Insertion */
- if (pid != 0)
- g_hash_table_insert (map->pid_map, new_pid, pnode);
- g_hash_table_insert (map->uid_map, new_uid, unode);
-}
-
-static void
-map_set_node_timet (xmlNodePtr node, const gchar *name, time_t t)
-{
- gchar *tstring;
-
- tstring = g_strdup_printf ("%ld", t);
- xmlSetProp (node, (guchar *)name, (guchar *)tstring);
- g_free (tstring);
-}
-
-static void
-map_sax_start_element (gpointer data, const xmlChar *name,
- const xmlChar **attrs)
-{
- EPilotMap *map = (EPilotMap *)data;
-
- if (!strcmp ((gchar *)name, "PilotMap")) {
- while (attrs && *attrs != NULL) {
- const xmlChar **val = attrs;
-
- val++;
- if (!strcmp ((gchar *)*attrs, "timestamp"))
- map->since = (time_t)strtoul ((gchar *)*val, NULL, 0);
-
- attrs = ++val;
- }
- }
-
- if (!strcmp ((gchar *)name, "map")) {
- const gchar *uid = NULL;
- guint32 pid = 0;
- gboolean archived = FALSE;
-
- while (attrs && *attrs != NULL) {
- const xmlChar **val = attrs;
-
- val++;
- if (!strcmp ((gchar *)*attrs, "uid"))
- uid = (gchar *)*val;
-
- if (!strcmp ((gchar *)*attrs, "pilot_id"))
- pid = strtoul ((gchar *)*val, NULL, 0);
-
- if (!strcmp ((gchar *)*attrs, "archived"))
- archived = strtoul ((gchar *)*val, NULL, 0)== 1 ? TRUE : FALSE;
-
- attrs = ++val;
- }
-
- g_return_if_fail (uid != NULL);
- g_return_if_fail (pid != 0 || archived);
-
- real_e_pilot_map_insert (map, pid, uid, archived, FALSE);
- }
-}
-
-static void
-map_write_foreach (gpointer key, gpointer value, gpointer data)
-{
- EPilotMapWriteData *wd = data;
- xmlNodePtr root = wd->root;
- gchar *uid = key;
- EPilotMapUidNode *unode = value;
- xmlNodePtr mnode;
-
- if (wd->touched_only && !unode->touched)
- return;
-
- mnode = xmlNewChild (root, NULL, (const guchar *)"map", NULL);
- xmlSetProp (mnode, (const guchar *)"uid", (guchar *)uid);
-
- if (unode->archived) {
- xmlSetProp (mnode, (const guchar *)"archived", (const guchar *)"1");
- } else {
- gchar *pidstr;
-
- pidstr = g_strdup_printf ("%d", unode->pid);
- xmlSetProp (mnode, (const guchar *)"pilot_id", (guchar *)pidstr);
- g_free (pidstr);
- xmlSetProp (mnode, (const guchar *)"archived", (const guchar *)"0");
- }
-}
-
-gboolean
-e_pilot_map_pid_is_archived (EPilotMap *map, guint32 pid)
-{
- EPilotMapPidNode *pnode;
-
- g_return_val_if_fail (map != NULL, FALSE);
-
- pnode = g_hash_table_lookup (map->pid_map, &pid);
-
- if (pnode == NULL)
- return FALSE;
-
- return pnode->archived;
-}
-
-gboolean
-e_pilot_map_uid_is_archived (EPilotMap *map, const gchar *uid)
-{
- EPilotMapUidNode *unode;
-
- g_return_val_if_fail (map != NULL, FALSE);
- g_return_val_if_fail (uid != NULL, FALSE);
-
- unode = g_hash_table_lookup (map->uid_map, uid);
-
- if (unode == NULL)
- return FALSE;
-
- return unode->archived;
-}
-
-void
-e_pilot_map_insert (EPilotMap *map, guint32 pid, const gchar *uid, gboolean archived)
-{
- EPilotMapPidNode *pnode;
- EPilotMapUidNode *unode;
-
- pnode = g_hash_table_lookup (map->pid_map, &pid);
- if (pnode != NULL) {
- /* In case the pid<->uid mapping is not the same anymore */
- g_hash_table_remove (map->uid_map, pnode->uid);
-
- g_hash_table_remove (map->pid_map, &pid);
- }
-
- unode = g_hash_table_lookup (map->uid_map, uid);
- if (unode != NULL) {
- /* In case the pid<->uid mapping is not the same anymore */
- g_hash_table_remove (map->pid_map, &unode->pid);
-
- g_hash_table_remove (map->uid_map, uid);
- }
-
- real_e_pilot_map_insert (map, pid, uid, archived, TRUE);
-}
-
-void
-e_pilot_map_remove_by_pid (EPilotMap *map, guint32 pid)
-{
- EPilotMapPidNode *pnode;
- EPilotMapUidNode *unode;
-
- g_return_if_fail (map != NULL);
-
- pnode = g_hash_table_lookup (map->pid_map, &pid);
- if (pnode == NULL)
- return;
-
- unode = g_hash_table_lookup (map->uid_map, pnode->uid);
- g_return_if_fail (unode != NULL);
-
- g_hash_table_remove (map->uid_map, pnode->uid);
- g_hash_table_remove (map->pid_map, &pid);
-}
-
-void
-e_pilot_map_remove_by_uid (EPilotMap *map, const gchar *uid)
-{
- EPilotMapUidNode *unode;
-
- g_return_if_fail (map != NULL);
- g_return_if_fail (uid != NULL);
-
- unode = g_hash_table_lookup (map->uid_map, uid);
- if (unode == NULL)
- return;
-
- g_hash_table_remove (map->pid_map, &unode->pid);
- g_hash_table_remove (map->uid_map, uid);
-}
-
-guint32
-e_pilot_map_lookup_pid (EPilotMap *map, const gchar *uid, gboolean touch)
-{
- EPilotMapUidNode *unode = NULL;
-
- g_return_val_if_fail (map != NULL, 0);
- g_return_val_if_fail (uid != NULL, 0);
-
- unode = g_hash_table_lookup (map->uid_map, uid);
-
- if (unode == NULL)
- return 0;
-
- if (touch) {
- EPilotMapPidNode *pnode = NULL;
-
- pnode = g_hash_table_lookup (map->pid_map, &unode->pid);
- if (pnode != NULL)
- pnode->touched = TRUE;
- unode->touched = TRUE;
- }
-
- return unode->pid;
-}
-
-const gchar *
-e_pilot_map_lookup_uid (EPilotMap *map, guint32 pid, gboolean touch)
-{
- EPilotMapPidNode *pnode = NULL;
-
- g_return_val_if_fail (map != NULL, NULL);
-
- pnode = g_hash_table_lookup (map->pid_map, &pid);
-
- if (pnode == NULL)
- return NULL;
-
- if (touch) {
- EPilotMapUidNode *unode = NULL;
-
- unode = g_hash_table_lookup (map->uid_map, pnode->uid);
- g_return_val_if_fail (unode != NULL, NULL);
-
- unode->touched = TRUE;
- pnode->touched = TRUE;
- }
-
- return pnode->uid;
-}
-
-gint
-e_pilot_map_read (const gchar *filename, EPilotMap **map)
-{
- xmlSAXHandler handler;
- EPilotMap *new_map;
-
- g_return_val_if_fail (filename != NULL, -1);
- g_return_val_if_fail (map != NULL, -1);
-
- *map = NULL;
- new_map = g_new0 (EPilotMap, 1);
-
- memset (&handler, 0, sizeof (xmlSAXHandler));
- handler.startElement = map_sax_start_element;
-
- new_map->pid_map = g_hash_table_new_full (
- g_int_hash, g_int_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_free);
- new_map->uid_map = g_hash_table_new_full (
- g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_free);
-
- if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
- if (xmlSAXUserParseFile (&handler, new_map, filename) < 0) {
- g_free (new_map);
- return -1;
- }
- }
-
- new_map->write_touched_only = FALSE;
-
- *map = new_map;
-
- return 0;
-}
-
-gint
-e_pilot_map_write (const gchar *filename, EPilotMap *map)
-{
- EPilotMapWriteData wd;
- xmlDocPtr doc;
- gint ret;
-
- g_return_val_if_fail (filename != NULL, -1);
- g_return_val_if_fail (map != NULL, -1);
-
- doc = xmlNewDoc ((const guchar *)"1.0");
- if (doc == NULL) {
- g_warning ("Pilot map file could not be created\n");
- return -1;
- }
- xmlDocSetRootElement (
- doc, xmlNewDocNode (
- doc, NULL, (const guchar *)"PilotMap", NULL));
- map->since = time (NULL);
- map_set_node_timet (xmlDocGetRootElement (doc), "timestamp", map->since);
-
- wd.touched_only = map->write_touched_only;
- wd.root = xmlDocGetRootElement(doc);
- g_hash_table_foreach (map->uid_map, map_write_foreach, &wd);
-
- /* Write the file */
- xmlSetDocCompressMode (doc, 0);
- ret = e_xml_save_file (filename, doc);
- if (ret < 0) {
- g_warning ("Pilot map file '%s' could not be saved\n", filename);
- return -1;
- }
-
- xmlFreeDoc (doc);
-
- return 0;
-}
-
-void
-e_pilot_map_clear (EPilotMap *map)
-{
- g_return_if_fail (map != NULL);
-
- g_hash_table_remove_all (map->pid_map);
- g_hash_table_remove_all (map->uid_map);
-
- map->since = 0;
- map->write_touched_only = FALSE;
-}
-
-void
-e_pilot_map_destroy (EPilotMap *map)
-{
- g_return_if_fail (map != NULL);
-
- g_hash_table_destroy (map->pid_map);
- g_hash_table_destroy (map->uid_map);
- g_free (map);
-}
diff --git a/e-util/e-pilot-map.h b/e-util/e-pilot-map.h
deleted file mode 100644
index 32bcc942bf..0000000000
--- a/e-util/e-pilot-map.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Evolution Conduits - Pilot Map routines
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * JP Rosevear <jpr@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_PILOT_MAP_H
-#define E_PILOT_MAP_H
-
-#include <glib.h>
-#include <time.h>
-
-typedef struct _EPilotMap EPilotMap;
-
-struct _EPilotMap
-{
- GHashTable *pid_map;
- GHashTable *uid_map;
-
- time_t since;
-
- gboolean write_touched_only;
-};
-
-gboolean e_pilot_map_pid_is_archived (EPilotMap *map, guint32 pid);
-gboolean e_pilot_map_uid_is_archived (EPilotMap *map, const gchar *uid);
-
-void e_pilot_map_insert (EPilotMap *map, guint32 pid, const gchar *uid, gboolean archived);
-void e_pilot_map_remove_by_pid (EPilotMap *map, guint32 pid);
-void e_pilot_map_remove_by_uid (EPilotMap *map, const gchar *uid);
-
-guint32 e_pilot_map_lookup_pid (EPilotMap *map, const gchar *uid, gboolean touch);
-const gchar * e_pilot_map_lookup_uid (EPilotMap *map, guint32 pid, gboolean touch);
-
-gint e_pilot_map_read (const gchar *filename, EPilotMap **map);
-gint e_pilot_map_write (const gchar *filename, EPilotMap *map);
-
-void e_pilot_map_clear (EPilotMap *map);
-
-void e_pilot_map_destroy (EPilotMap *map);
-
-#endif /* E_PILOT_MAP_H */
diff --git a/e-util/e-pilot-util.c b/e-util/e-pilot-util.c
deleted file mode 100644
index 3d8d2cddfb..0000000000
--- a/e-util/e-pilot-util.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Evolution Conduits - Pilot Map routines
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * JP Rosevear <jpr@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <time.h>
-#include <libxml/parser.h>
-#include <pi-util.h>
-
-#include "e-pilot-util.h"
-
-gchar *
-e_pilot_utf8_to_pchar (const gchar *string, const gchar *pilot_charset)
-{
- gchar *pstring = NULL;
- gint res;
-
- if (!string)
- return NULL;
-
-#ifdef PILOT_LINK_0_12
- res = convert_ToPilotChar_WithCharset ("UTF-8", string, strlen (string),
- &pstring, pilot_charset);
-#else
- res = convert_ToPilotChar ("UTF-8", string, strlen (string), &pstring);
-#endif
-
- if (res != 0)
- pstring = strdup (string);
-
- return pstring;
-}
-
-gchar *
-e_pilot_utf8_from_pchar (const gchar *string, const gchar *pilot_charset)
-{
- gchar *ustring = NULL;
- gint res;
-
- if (!string)
- return NULL;
-
-#ifdef PILOT_LINK_0_12
- res = convert_FromPilotChar_WithCharset ("UTF-8", string, strlen (string),
- &ustring, pilot_charset);
-#else
- res = convert_FromPilotChar ("UTF-8", string, strlen (string), &ustring);
-#endif
-
- if (res != 0)
- ustring = strdup (string);
-
- return ustring;
-}
-
-ESource *
-e_pilot_get_sync_source (ESourceList *source_list)
-{
- GSList *g;
-
- g_return_val_if_fail (source_list != NULL, NULL);
- g_return_val_if_fail (E_IS_SOURCE_LIST (source_list), NULL);
-
- for (g = e_source_list_peek_groups (source_list); g; g = g->next) {
- ESourceGroup *group = E_SOURCE_GROUP (g->data);
- GSList *s;
-
- for (s = e_source_group_peek_sources (group); s; s = s->next) {
- ESource *source = E_SOURCE (s->data);
-
- if (e_source_get_property (source, "pilot-sync"))
- return source;
- }
- }
-
- return NULL;
-}
-
-void
-e_pilot_set_sync_source (ESourceList *source_list, ESource *source)
-{
- GSList *g;
-
- g_return_if_fail (source_list != NULL);
- g_return_if_fail (E_IS_SOURCE_LIST (source_list));
-
- for (g = e_source_list_peek_groups (source_list); g; g = g->next) {
- GSList *s;
- for (s = e_source_group_peek_sources (E_SOURCE_GROUP (g->data));
- s; s = s->next) {
- e_source_set_property (E_SOURCE (s->data), "pilot-sync", NULL);
- }
- }
-
- if (source)
- e_source_set_property (source, "pilot-sync", "true");
- e_source_list_sync (source_list, NULL);
-}
diff --git a/e-util/e-pilot-util.h b/e-util/e-pilot-util.h
deleted file mode 100644
index 9def45a8d8..0000000000
--- a/e-util/e-pilot-util.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- *
- *Evolution Conduits - Pilot Map routines
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * JP Rosevear <jpr@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#include <libedataserver/e-source-list.h>
-#include <libedataserver/e-source.h>
-
-#ifndef E_PILOT_UTIL_H
-#define E_PILOT_UTIL_H
-
-gchar *e_pilot_utf8_to_pchar (const gchar *string, const gchar *pilot_charset);
-gchar *e_pilot_utf8_from_pchar (const gchar *string, const gchar *pilot_charset);
-
-ESource *e_pilot_get_sync_source (ESourceList *source_list);
-void e_pilot_set_sync_source (ESourceList *source_list, ESource *source);
-
-#endif /* E_PILOT_UTIL_H */
diff --git a/evolution-zip.in b/evolution-zip.in
index 4373f1c2ba..9183c3c52b 100755
--- a/evolution-zip.in
+++ b/evolution-zip.in
@@ -12,7 +12,6 @@ cd @prefix@
rm $ZIP
zip -r $ZIP -@ <<EOF
bin/libeabutil-0.dll
-bin/libeconduit-0.dll
bin/libecontacteditor-0.dll
bin/libecontactlisteditor-0.dll
bin/libefilterbar-0.dll
@@ -63,7 +62,6 @@ fi
rm $DEVZIP
zip -r $DEVZIP -@ <<EOF
lib/libeabutil.dll.a
-lib/libeconduit.dll.a
lib/libecontacteditor.dll.a
lib/libecontactlisteditor.dll.a
lib/libefilterbar.dll.a
diff --git a/m4/evo_pilot_link_check.m4 b/m4/evo_pilot_link_check.m4
deleted file mode 100644
index 5c97fe2a1b..0000000000
--- a/m4/evo_pilot_link_check.m4
+++ /dev/null
@@ -1,117 +0,0 @@
-dnl PILOT_LINK_CHECK
-dnl Adds --with-pisock and determines the verion of the pisock
-#serial 0.1
-AC_SUBST(PISOCK_CFLAGS)
-AC_SUBST(PISOCK_LIBS)
-
-AC_DEFUN([PILOT_LINK_HOOK],[
- AC_ARG_WITH([pisock],
- AS_HELP_STRING([--with-pisock=PREFIX],
- [Specify prefix for pisock files]),
- [
- if test x$withval = xyes; then
- dnl Note that an empty true branch is not valid sh syntax.
- ifelse([$1], [], :, [$1])
- else
- PISOCK_CFLAGS="-I$withval/include"
- incdir="$withval/include"
- PISOCK_LIBS="-L$withval/lib -lpisock -lpisync"
- AC_MSG_CHECKING([for existance of "$withval"/lib/libpisock.so])
- if test -r $withval/lib/libpisock.so; then
- AC_MSG_RESULT([yes])
- else
- AC_MSG_ERROR([Unable to find libpisock. Try http://www.pilot-link.org.])
- fi
- fi
- ])
-
- if test x$PISOCK_CFLAGS = x; then
- AC_CHECK_HEADER(pi-version.h, [incdir="/usr/include"], [
- AC_CHECK_HEADER(libpisock/pi-version.h, [PISOCK_CFLAGS="-I/usr/include/libpisock"
- piversion_include="libpisock/pi-version.h"
- incdir="/usr/include/libpisock"
- ],[
- AC_CHECK_HEADER($prefix/include/pi-version.h, [PISOCK_CFLAGS="-I$prefix/include/libpisock"
- piversion_include="$prefix/include/pi-version.h"
- if test x$PISOCK_LIBDIR = x; then
- incdir="$prefix/include"
- PISOCK_LIBS="-L$prefix/lib -lpisock -lpisync"
- fi
- ],
- AC_MSG_ERROR([Unable to find pi-version.h]))
- ])
- ])
- fi
-
- if test "x$PISOCK_LIBS" = "x"; then
- AC_CHECK_LIB(pisock, pi_accept, [ PISOCK_LIBS="-lpisock -lpisync"],
- [ AC_MSG_ERROR([Unable to find libpisock. Try http://www.pilot-link.org.]) ])
- fi
-
- AC_ARG_ENABLE([pilotlinktest],
- AS_HELP_STRING([--enable-pilotlinktest],
- [Test for correct version of pilot-link]),
- [testplversion="$enableval"],[testplversion=yes]
- )
-
- if test x$piversion_include = x; then
- piversion_include="pi-version.h"
- fi
-
- pi_major=`cat $incdir/pi-version.h|grep '#define PILOT_LINK_VERSION'|sed 's/#define PILOT_LINK_VERSION \([[0-9]]*\)/\1/'`
- pi_minor=`cat $incdir/pi-version.h|grep '#define PILOT_LINK_MAJOR'|sed 's/#define PILOT_LINK_MAJOR \([[0-9]]*\)/\1/'`
- pi_micro=`cat $incdir/pi-version.h|grep '#define PILOT_LINK_MINOR'|sed 's/#define PILOT_LINK_MINOR \([[0-9]]*\)/\1/'`
- pi_patch=`cat $incdir/pi-version.h|grep '#define PILOT_LINK_PATCH'|sed 's/#define PILOT_LINK_PATCH \"\(.*\)\"/\1/'`
-
- PILOT_LINK_MAJOR="$pi_major"
- PILOT_LINK_MINOR="$pi_minor"
- PILOT_LINK_MICRO="$pi_micro"
- PILOT_LINK_PATCH="$pi_patch"
- PILOT_LINK_VERSION="$pi_major.$pi_minor.$pi_micro$pi_patch"
-
- if test x$testplversion = xyes; then
- AC_MSG_CHECKING([for pilot-link version >= $1])
- pl_ma=`echo $1|sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
- pl_mi=`echo $1|sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
- pl_mc=`echo $1|sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
- CFLAGS_save="$CFLAGS"
- CFLAGS="$CFLAGS $PISOCK_CFLAGS"
- AC_TRY_RUN(
- [
- #include <$piversion_include>
- int main(int argc,char *argv[]) {
- if (PILOT_LINK_VERSION == $pl_ma) {
- if (PILOT_LINK_MAJOR == $pl_mi) {
- if (PILOT_LINK_MINOR >= $pl_mc) {
- return 0;
- }
- } else if (PILOT_LINK_MAJOR > $pl_mi) {
- return 0;
- }
- } else if (PILOT_LINK_VERSION > $pl_ma) {
- return 0;
- }
- return 1;
- }
- ],
- [AC_MSG_RESULT([yes (found $PILOT_LINK_VERSION)])],
- [AC_MSG_ERROR([pilot-link >= $1 required])],
- [AC_MSG_WARN([No action taken for crosscompile])]
- )
- CFLAGS="$CFLAGS_save"
- fi
-
- unset piversion_include
- unset pi_verion
- unset pi_major
- unset pi_minor
- unset pi_patch
- unset incdir
- unset pl_mi
- unset pl_ma
- unset pl_ve
-])
-
-AC_DEFUN([PILOT_LINK_CHECK],[
- PILOT_LINK_HOOK($1,[],nofailure)
-])
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 7dec6b07e3..d94632f168 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,7 +1,6 @@
# List of source files containing translatable strings.
# Please keep this list in alphabetic order.
addressbook/addressbook.error.xml
-addressbook/conduit/address-conduit.c
[type: gettext/glade]addressbook/gui/contact-editor/contact-editor.ui
addressbook/gui/contact-editor/e-contact-editor-fullname.c
addressbook/gui/contact-editor/e-contact-editor.c
@@ -40,9 +39,6 @@ addressbook/tools/evolution-addressbook-export.c
addressbook/util/addressbook.c
calendar/calendar.error.xml
calendar/common/authentication.c
-calendar/conduits/calendar/calendar-conduit.c
-calendar/conduits/memo/memo-conduit.c
-calendar/conduits/todo/todo-conduit.c
calendar/gui/alarm-notify/alarm-notify-dialog.c
[type: gettext/glade]calendar/gui/alarm-notify/alarm-notify.ui
calendar/gui/alarm-notify/alarm-queue.c
@@ -473,7 +469,6 @@ widgets/misc/e-import-assistant.c
widgets/misc/e-map.c
widgets/misc/e-online-button.c
widgets/misc/e-paned.c
-widgets/misc/e-pilot-settings.c
widgets/misc/e-popup-action.c
widgets/misc/e-preferences-window.c
widgets/misc/e-search-bar.c
diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c
index 480b99da2b..01e5f3517c 100644
--- a/shell/e-shell-window-actions.c
+++ b/shell/e-shell-window-actions.c
@@ -1328,38 +1328,6 @@ action_switcher_style_cb (GtkRadioAction *action,
}
/**
- * E_SHELL_WINDOW_ACTION_SYNC_OPTIONS:
- * @window: an #EShellWindow
- *
- * Activation of this action opens the Gnome Pilot settings.
- *
- * Main menu item: Edit -> GNOME Pilot Synchronization...
- **/
-static void
-action_sync_options_cb (GtkAction *action,
- EShellWindow *shell_window)
-{
- const gchar *command_line;
- GError *error = NULL;
-
- command_line = "gpilotd-control-applet";
-
- g_debug ("Spawning: %s", command_line);
- g_spawn_command_line_async (command_line, &error);
-
- if (error != NULL) {
- const gchar *message;
-
- if (error->code == G_SPAWN_ERROR_NOENT)
- message = _("GNOME Pilot is not installed.");
- else
- message = _("GNOME Pilot could not be run.");
- e_notice (shell_window, GTK_MESSAGE_ERROR, message);
- g_error_free (error);
- }
-}
-
-/**
* E_SHELL_WINDOW_ACTION_WORK_OFFLINE:
* @window: an #EShellWindow
*
@@ -1618,13 +1586,6 @@ static GtkActionEntry shell_entries[] = {
N_("Submit a bug report using Bug Buddy"),
G_CALLBACK (action_submit_bug_cb) },
- { "sync-options",
- NULL,
- N_("GNOME Pilot _Synchronization..."),
- NULL,
- N_("Set up GNOME Pilot configuration"),
- G_CALLBACK (action_sync_options_cb) },
-
{ "work-offline",
"stock_disconnect",
N_("_Work Offline"),
@@ -2020,12 +1981,6 @@ e_shell_window_actions_init (EShellWindow *shell_window)
if (path == NULL)
gtk_action_set_visible (ACTION (SUBMIT_BUG), FALSE);
g_free (path);
-
- /* Sychronizing your Palm PDA requires gnome-pilot. */
- path = g_find_program_in_path ("gpilotd-control-applet");
- if (path == NULL)
- gtk_action_set_visible (ACTION (SYNC_OPTIONS), FALSE);
- g_free (path);
}
static GList *
diff --git a/shell/e-shell-window-actions.h b/shell/e-shell-window-actions.h
index 616899f61c..a3f752c15e 100644
--- a/shell/e-shell-window-actions.h
+++ b/shell/e-shell-window-actions.h
@@ -103,8 +103,6 @@
E_SHELL_WINDOW_ACTION ((window), "switcher-style-text")
#define E_SHELL_WINDOW_ACTION_SWITCHER_STYLE_USER(window) \
E_SHELL_WINDOW_ACTION ((window), "switcher-style-user")
-#define E_SHELL_WINDOW_ACTION_SYNC_OPTIONS(window) \
- E_SHELL_WINDOW_ACTION ((window), "sync-options")
#define E_SHELL_WINDOW_ACTION_WORK_OFFLINE(window) \
E_SHELL_WINDOW_ACTION ((window), "work-offline")
#define E_SHELL_WINDOW_ACTION_WORK_ONLINE(window) \
diff --git a/ui/evolution-shell.ui b/ui/evolution-shell.ui
index c051668290..97e2f22c4a 100644
--- a/ui/evolution-shell.ui
+++ b/ui/evolution-shell.ui
@@ -34,7 +34,6 @@
<separator/>
<placeholder name='edit-actions'/>
<separator/>
- <menuitem action='sync-options'/>
<placeholder name='administrative-actions'/>
<menuitem action='preferences'/>
</menu>
diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am
index 50d8064af3..21faf33517 100644
--- a/widgets/misc/Makefile.am
+++ b/widgets/misc/Makefile.am
@@ -2,18 +2,9 @@ privsolib_LTLIBRARIES = libemiscwidgets.la
widgetsincludedir = $(privincludedir)/misc
-if ENABLE_PILOT_CONDUITS
-pilot_sources = e-pilot-settings.c
-pilot_headers = e-pilot-settings.h
-else
-pilot_sources =
-pilot_headers =
-endif
-
ui_DATA = e-send-options.ui
widgetsinclude_HEADERS = \
- $(pilot_headers) \
e-account-combo-box.h \
e-account-manager.h \
e-account-tree-view.h \
@@ -90,7 +81,6 @@ libemiscwidgets_la_CPPFLAGS = \
libemiscwidgets_la_SOURCES = \
$(widgetsinclude_HEADERS) \
- $(pilot_sources) \
e-account-combo-box.c \
e-account-manager.c \
e-account-tree-view.c \
@@ -224,10 +214,6 @@ test_preferences_window_LDADD = \
$(GNOME_PLATFORM_LIBS) \
$(E_WIDGETS_LIBS)
-
-EXTRA_DIST = \
- $(ui_DATA) \
- e-pilot-settings.h \
- e-pilot-settings.c
+EXTRA_DIST = $(ui_DATA)
-include $(top_srcdir)/git.mk
diff --git a/widgets/misc/e-pilot-settings.c b/widgets/misc/e-pilot-settings.c
deleted file mode 100644
index e2b90897a0..0000000000
--- a/widgets/misc/e-pilot-settings.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * JP Rosevear <jpr@novell.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-#include <libedataserverui/e-source-combo-box.h>
-#include "e-pilot-settings.h"
-
-struct _EPilotSettingsPrivate
-{
- GtkWidget *source;
- GtkWidget *secret;
- GtkWidget *cat;
- GtkWidget *cat_btn;
-};
-
-static void class_init (EPilotSettingsClass *klass);
-static void init (EPilotSettings *ps);
-
-static GObjectClass *parent_class = NULL;
-
-GType
-e_pilot_settings_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static GTypeInfo info = {
- sizeof (EPilotSettingsClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) class_init,
- NULL, NULL,
- sizeof (EPilotSettings),
- 0,
- (GInstanceInitFunc) init
- };
- type = g_type_register_static (GTK_TYPE_TABLE, "EPilotSettings", &info, 0);
- }
-
- return type;
-}
-
-static void
-class_init (EPilotSettingsClass *klass)
-{
- parent_class = g_type_class_ref (GTK_TYPE_TABLE);
-}
-
-static void
-init (EPilotSettings *ps)
-{
- EPilotSettingsPrivate *priv;
-
- priv = g_new0 (EPilotSettingsPrivate, 1);
-
- ps->priv = priv;
-}
-
-static void
-build_ui (EPilotSettings *ps, ESourceList *source_list)
-{
- EPilotSettingsPrivate *priv;
- GtkWidget *lbl;
-
- priv = ps->priv;
-
- gtk_table_resize (GTK_TABLE (ps), 2, 2);
- gtk_container_set_border_width (GTK_CONTAINER (ps), 4);
- gtk_table_set_col_spacings (GTK_TABLE (ps), 6);
-
- lbl = gtk_label_new (_("Sync with:"));
- gtk_misc_set_alignment (GTK_MISC (lbl), 0.0, 0.5);
- priv->source = e_source_combo_box_new (source_list);
- gtk_table_attach_defaults (GTK_TABLE (ps), lbl, 0, 1, 0, 1);
- gtk_table_attach_defaults (GTK_TABLE (ps), priv->source, 1, 2, 0, 1);
- gtk_widget_show (lbl);
- gtk_widget_show (priv->source);
-
- lbl = gtk_label_new (_("Sync Private Records:"));
- gtk_misc_set_alignment (GTK_MISC (lbl), 0.0, 0.5);
- priv->secret = gtk_check_button_new ();
- gtk_table_attach_defaults (GTK_TABLE (ps), lbl, 0, 1, 1, 2);
- gtk_table_attach_defaults (GTK_TABLE (ps), priv->secret, 1, 2, 1, 2);
- gtk_widget_show (lbl);
- gtk_widget_show (priv->secret);
-
-#if 0
- lbl = gtk_label_new (_("Sync Categories:"));
- gtk_misc_set_alignment (GTK_MISC (lbl), 0.0, 0.5);
- priv->cat = gtk_check_button_new ();
- gtk_table_attach_defaults (GTK_TABLE (ps), lbl, 0, 1, 2, 3);
- gtk_table_attach_defaults (GTK_TABLE (ps), priv->cat, 1, 2, 2, 3);
- gtk_widget_show (lbl);
- gtk_widget_show (priv->cat);
-#endif
-}
-
-
-
-GtkWidget *
-e_pilot_settings_new (ESourceList *source_list)
-{
- EPilotSettings *ps;
-
- ps = g_object_new (E_TYPE_PILOT_SETTINGS, NULL);
-
- build_ui (ps, source_list);
-
- return GTK_WIDGET (ps);
-}
-
-ESource *
-e_pilot_settings_get_source (EPilotSettings *ps)
-{
- EPilotSettingsPrivate *priv;
-
- g_return_val_if_fail (ps != NULL, NULL);
- g_return_val_if_fail (E_IS_PILOT_SETTINGS (ps), NULL);
-
- priv = ps->priv;
-
- return e_source_combo_box_get_active (
- E_SOURCE_COMBO_BOX (priv->source));
-}
-
-void
-e_pilot_settings_set_source (EPilotSettings *ps, ESource *source)
-{
- EPilotSettingsPrivate *priv;
-
- g_return_if_fail (ps != NULL);
- g_return_if_fail (E_IS_PILOT_SETTINGS (ps));
-
- priv = ps->priv;
-
- e_source_combo_box_set_active (
- E_SOURCE_COMBO_BOX (priv->source), source);
-}
-
-gboolean
-e_pilot_settings_get_secret (EPilotSettings *ps)
-{
- EPilotSettingsPrivate *priv;
-
- g_return_val_if_fail (ps != NULL, FALSE);
- g_return_val_if_fail (E_IS_PILOT_SETTINGS (ps), FALSE);
-
- priv = ps->priv;
-
- return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->secret));
-}
-
-void
-e_pilot_settings_set_secret (EPilotSettings *ps, gboolean secret)
-{
- EPilotSettingsPrivate *priv;
-
- g_return_if_fail (ps != NULL);
- g_return_if_fail (E_IS_PILOT_SETTINGS (ps));
-
- priv = ps->priv;
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->secret),
- secret);
-}
-
diff --git a/widgets/misc/e-pilot-settings.h b/widgets/misc/e-pilot-settings.h
deleted file mode 100644
index 0c4fbd7a81..0000000000
--- a/widgets/misc/e-pilot-settings.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * JP Rosevear <jpr@novell.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_PILOT_SETTINGS_H_
-#define _E_PILOT_SETTINGS_H_
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <libedataserver/e-source-list.h>
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define E_TYPE_PILOT_SETTINGS (e_pilot_settings_get_type ())
-#define E_PILOT_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_PILOT_SETTINGS, EPilotSettings))
-#define E_PILOT_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_PILOT_SETTINGS, EPilotSettingsClass))
-#define E_IS_PILOT_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_PILOT_SETTINGS))
-#define E_IS_PILOT_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_PILOT_SETTINGS))
-
-
-typedef struct _EPilotSettings EPilotSettings;
-typedef struct _EPilotSettingsPrivate EPilotSettingsPrivate;
-typedef struct _EPilotSettingsClass EPilotSettingsClass;
-
-#define E_PILOT_SETTINGS_TABLE_ROWS 3
-#define E_PILOT_SETTINGS_TABLE_COLS 3
-
-struct _EPilotSettings {
- GtkTable parent;
-
- EPilotSettingsPrivate *priv;
-};
-
-struct _EPilotSettingsClass {
- GtkTableClass parent_class;
-};
-
-
-GType e_pilot_settings_get_type (void);
-GtkWidget *e_pilot_settings_new (ESourceList *source_list);
-
-ESource *e_pilot_settings_get_source (EPilotSettings *ps);
-void e_pilot_settings_set_source (EPilotSettings *ps, ESource *source);
-
-gboolean e_pilot_settings_get_secret (EPilotSettings *ps);
-void e_pilot_settings_set_secret (EPilotSettings *ps, gboolean secret);
-
-G_END_DECLS
-
-#endif