aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/backend/ebook
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/backend/ebook')
-rw-r--r--addressbook/backend/ebook/.cvsignore25
-rw-r--r--addressbook/backend/ebook/GNOME_Evolution_Addressbook_LDIF_Importer.oaf.in29
-rw-r--r--addressbook/backend/ebook/GNOME_Evolution_Addressbook_VCard_Importer.oaf.in29
-rw-r--r--addressbook/backend/ebook/Makefile.am179
-rw-r--r--addressbook/backend/ebook/TODO2
-rw-r--r--addressbook/backend/ebook/e-book-listener.c830
-rw-r--r--addressbook/backend/ebook/e-book-listener.h109
-rw-r--r--addressbook/backend/ebook/e-book-types.h41
-rw-r--r--addressbook/backend/ebook/e-book-util.c759
-rw-r--r--addressbook/backend/ebook/e-book-util.h94
-rw-r--r--addressbook/backend/ebook/e-book-view-listener.c483
-rw-r--r--addressbook/backend/ebook/e-book-view-listener.h78
-rw-r--r--addressbook/backend/ebook/e-book-view.c351
-rw-r--r--addressbook/backend/ebook/e-book-view.h62
-rw-r--r--addressbook/backend/ebook/e-book.c1500
-rw-r--r--addressbook/backend/ebook/e-book.h152
-rw-r--r--addressbook/backend/ebook/e-card-compare.c704
-rw-r--r--addressbook/backend/ebook/e-card-compare.h72
-rw-r--r--addressbook/backend/ebook/e-card-cursor.c235
-rw-r--r--addressbook/backend/ebook/e-card-cursor.h52
-rw-r--r--addressbook/backend/ebook/e-card-pairs.h118
-rw-r--r--addressbook/backend/ebook/e-card-simple.c1274
-rw-r--r--addressbook/backend/ebook/e-card-simple.h233
-rw-r--r--addressbook/backend/ebook/e-card-types.h101
-rw-r--r--addressbook/backend/ebook/e-card.c2857
-rw-r--r--addressbook/backend/ebook/e-card.h218
-rw-r--r--addressbook/backend/ebook/e-destination.c1690
-rw-r--r--addressbook/backend/ebook/e-destination.h138
-rw-r--r--addressbook/backend/ebook/evolution-ldif-importer.c624
-rw-r--r--addressbook/backend/ebook/evolution-vcard-importer.c260
-rw-r--r--addressbook/backend/ebook/load-gnomecard-addressbook.c91
-rw-r--r--addressbook/backend/ebook/load-pine-addressbook.c172
-rw-r--r--addressbook/backend/ebook/test-card.c206
-rw-r--r--addressbook/backend/ebook/test-client-list.c76
-rw-r--r--addressbook/backend/ebook/test-client.c204
35 files changed, 0 insertions, 14048 deletions
diff --git a/addressbook/backend/ebook/.cvsignore b/addressbook/backend/ebook/.cvsignore
deleted file mode 100644
index deec6ea2e7..0000000000
--- a/addressbook/backend/ebook/.cvsignore
+++ /dev/null
@@ -1,25 +0,0 @@
-.deps
-.libs
-.pure
-Makefile
-Makefile.in
-*.lo
-*.la
-addressbook-stubs.c
-addressbook-skels.c
-addressbook-common.c
-addressbook.h
-test-card
-test-client
-test-client-list
-load-pine-addressbook
-load-gnomecard-addressbook
-evolution-vcard-importer
-evolution-gnomecard-importer
-evolution-ldif-importer
-Evolution-Composer-stubs.c
-Evolution-Composer-skels.c
-Evolution-Composer-common.c
-Evolution-Composer.h
-GNOME_Evolution_Addressbook_VCard_Importer.oaf
-GNOME_Evolution_Addressbook_LDIF_Importer.oaf
diff --git a/addressbook/backend/ebook/GNOME_Evolution_Addressbook_LDIF_Importer.oaf.in b/addressbook/backend/ebook/GNOME_Evolution_Addressbook_LDIF_Importer.oaf.in
deleted file mode 100644
index b022dcde67..0000000000
--- a/addressbook/backend/ebook/GNOME_Evolution_Addressbook_LDIF_Importer.oaf.in
+++ /dev/null
@@ -1,29 +0,0 @@
-<oaf_info>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_LDIF_ImporterFactory"
- type="exe"
- location="evolution-ldif-importer">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/ObjectFactory:1.0"/>
- </oaf_attribute>
-
- <oaf_attribute name="description" type="string"
- _value="Factory to import LDIF files into Evolution."/>
-</oaf_server>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_LDIF_Importer"
- type="factory"
- location="OAFIID:GNOME_Evolution_Addressbook_LDIF_ImporterFactory">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/Evolution/Importer:1.0"/>
- </oaf_attribute>
-
- <oaf_attribute name="evolution:menu-name" type="string"
- value="LDAP Data Interchange Format (.ldif)"/>
- <oaf_attribute name="description" type="string"
- _value="Imports LDIF files into Evolution."/>
-</oaf_server>
-
-</oaf_info>
diff --git a/addressbook/backend/ebook/GNOME_Evolution_Addressbook_VCard_Importer.oaf.in b/addressbook/backend/ebook/GNOME_Evolution_Addressbook_VCard_Importer.oaf.in
deleted file mode 100644
index 9cd4699633..0000000000
--- a/addressbook/backend/ebook/GNOME_Evolution_Addressbook_VCard_Importer.oaf.in
+++ /dev/null
@@ -1,29 +0,0 @@
-<oaf_info>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_VCard_ImporterFactory"
- type="exe"
- location="evolution-vcard-importer">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/ObjectFactory:1.0"/>
- </oaf_attribute>
-
- <oaf_attribute name="description" type="string"
- _value="Factory to import VCard files into Evolution."/>
-</oaf_server>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_VCard_Importer"
- type="factory"
- location="OAFIID:GNOME_Evolution_Addressbook_VCard_ImporterFactory">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/Evolution/Importer:1.0"/>
- </oaf_attribute>
-
- <oaf_attribute name="evolution:menu-name" type="string"
- value="VCard (.vcf, .gcrd)"/>
- <oaf_attribute name="description" type="string"
- _value="Imports VCard files into Evolution."/>
-</oaf_server>
-
-</oaf_info>
diff --git a/addressbook/backend/ebook/Makefile.am b/addressbook/backend/ebook/Makefile.am
deleted file mode 100644
index 29430d93f4..0000000000
--- a/addressbook/backend/ebook/Makefile.am
+++ /dev/null
@@ -1,179 +0,0 @@
-noinst_PROGRAMS = test-card test-client test-client-list
-
-bin_PROGRAMS = evolution-vcard-importer \
- evolution-ldif-importer \
- load-pine-addressbook \
- load-gnomecard-addressbook
-
-CORBA_SOURCE = \
- addressbook.h \
- addressbook-common.c \
- addressbook-stubs.c \
- addressbook-skels.c \
- Evolution-Composer.h \
- Evolution-Composer-common.c \
- Evolution-Composer-skels.c \
- Evolution-Composer-stubs.c
-
-idls = \
- $(srcdir)/../idl/addressbook.idl \
- $(srcdir)/../../../composer/Evolution-Composer.idl
-
-idl_flags = `$(GNOME_CONFIG) --cflags idl` -I $(datadir)/idl
-
-$(CORBA_SOURCE): $(idls)
- $(ORBIT_IDL) -I $(srcdir) $(idls) $(idl_flags)
-
-INCLUDES = \
- -DGNOMELOCALEDIR=\""$(localedir)"\" \
- -DG_LOG_DOMAIN=\"EBook\" \
- -I$(top_srcdir) \
- -I$(top_srcdir)/camel \
- -I$(top_srcdir)/addressbook/backend \
- -I$(top_srcdir)/addressbook/ename \
- -I$(top_builddir)/addressbook/backend \
- -I$(top_builddir)/addressbook/ename \
- -I$(top_builddir)/shell \
- -I$(top_srcdir)/shell \
- $(EVOLUTION_ADDRESSBOOK_CFLAGS)
-
-lib_LTLIBRARIES = libebook.la
-
-libebook_la_SOURCES = \
- $(CORBA_SOURCE) \
- e-book-listener.c \
- e-book-view-listener.c \
- e-book-view.c \
- e-book.c \
- e-book-util.c \
- e-card-cursor.c \
- e-card-simple.c \
- e-card.c \
- e-card-compare.c \
- e-destination.c
-
-libebookincludedir = $(includedir)/evolution/ebook
-
-libebookinclude_HEADERS = \
- e-book-listener.h \
- e-book-types.h \
- e-book-view-listener.h \
- e-book-view.h \
- e-book.h \
- e-book-util.h \
- e-card-cursor.h \
- e-card-simple.h \
- e-card-types.h \
- e-card.h \
- e-card-compare.h \
- e-destination.h
-
-
-#
-# make a static library for use by addressbook's conduit's shared library
-#
-noinst_LTLIBRARIES = libebook-static.la
-libebook_static_la_SOURCES = $(libebook_la_SOURCES)
-libebook_static_la_LDFLAGS = --all-static
-
-
-test_client_SOURCES = \
- test-client.c
-
-test_client_LDADD = \
- libebook.la \
- $(EVOLUTION_ADDRESSBOOK_LIBS) \
- $(top_builddir)/camel/libcamel.la \
- $(top_builddir)/libversit/libversit.a \
- $(top_builddir)/e-util/ename/libename.la \
- $(top_builddir)/e-util/libeutil.la
-
-test_client_list_SOURCES = \
- test-client-list.c
-
-test_client_list_LDADD = \
- libebook.la \
- $(EVOLUTION_ADDRESSBOOK_LIBS) \
- $(top_builddir)/camel/libcamel.la \
- $(top_builddir)/e-util/ename/libename.la \
- $(top_builddir)/libversit/libversit.a \
- $(top_builddir)/e-util/libeutil.la
-
-test_card_SOURCES = \
- test-card.c
-
-test_card_LDADD = \
- libebook.la \
- $(EVOLUTION_ADDRESSBOOK_LIBS) \
- $(top_builddir)/camel/libcamel.la \
- $(top_builddir)/e-util/ename/libename.la \
- $(top_builddir)/libversit/libversit.a \
- $(top_builddir)/e-util/libeutil.la
-
-evolution_vcard_importer_SOURCES = \
- evolution-vcard-importer.c
-
-evolution_vcard_importer_LDADD = \
- libebook.la \
- $(EVOLUTION_ADDRESSBOOK_LIBS) \
- $(top_builddir)/camel/libcamel.la \
- $(top_builddir)/shell/importer/libevolution-importer.la \
- $(DB3_LDADD) \
- $(top_builddir)/e-util/ename/libename.la \
- $(top_builddir)/libversit/libversit.a \
- $(top_builddir)/e-util/libeutil.la
-
-evolution_ldif_importer_SOURCES = \
- evolution-ldif-importer.c
-
-evolution_ldif_importer_LDADD = \
- libebook.la \
- $(EVOLUTION_ADDRESSBOOK_LIBS) \
- $(top_builddir)/camel/libcamel.la \
- $(top_builddir)/shell/importer/libevolution-importer.la \
- $(DB3_LDADD) \
- $(top_builddir)/e-util/ename/libename.la \
- $(top_builddir)/libversit/libversit.a \
- $(top_builddir)/e-util/libeutil.la
-
-load_pine_addressbook_SOURCES = \
- load-pine-addressbook.c
-
-load_pine_addressbook_LDADD = \
- libebook.la \
- $(EVOLUTION_ADDRESSBOOK_LIBS) \
- $(top_builddir)/camel/libcamel.la \
- $(top_builddir)/e-util/ename/libename.la \
- $(top_builddir)/libversit/libversit.a \
- $(top_builddir)/e-util/libeutil.la
-
-
-load_gnomecard_addressbook_SOURCES = \
- load-gnomecard-addressbook.c
-
-load_gnomecard_addressbook_LDADD = \
- libebook.la \
- $(EVOLUTION_ADDRESSBOOK_LIBS) \
- $(top_builddir)/camel/libcamel.la \
- $(top_builddir)/e-util/ename/libename.la \
- $(top_builddir)/libversit/libversit.a \
- $(top_builddir)/e-util/libeutil.la
-
-
-BUILT_SOURCES = $(CORBA_SOURCE)
-CLEANFILES = $(BUILT_SOURCES)
-
-dist-hook:
- cd $(distdir); rm -f $(BUILT_SOURCES)
-
-oafdir = $(datadir)/oaf
-oaf_in_files = GNOME_Evolution_Addressbook_VCard_Importer.oaf.in \
- GNOME_Evolution_Addressbook_LDIF_Importer.oaf.in
-oaf_DATA = $(oaf_in_files:.oaf.in=.oaf)
-
-@XML_I18N_MERGE_OAF_RULE@
-
-# add this back when you add the file to the archive ;)
-# GNOME_Evolution_Addressbook_Pine_Importer.oafinfo
-
-EXTRA_DIST = $(oaf_in_files) $(oaf_DATA)
diff --git a/addressbook/backend/ebook/TODO b/addressbook/backend/ebook/TODO
deleted file mode 100644
index a69703cd92..0000000000
--- a/addressbook/backend/ebook/TODO
+++ /dev/null
@@ -1,2 +0,0 @@
-* Make sure open_book_progress does not use the EBook op queue; make
- sure it works.
diff --git a/addressbook/backend/ebook/e-book-listener.c b/addressbook/backend/ebook/e-book-listener.c
deleted file mode 100644
index ce85ed75ba..0000000000
--- a/addressbook/backend/ebook/e-book-listener.c
+++ /dev/null
@@ -1,830 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Exports the BookListener interface. Maintains a queue of messages
- * which come in on the interface.
- *
- * Author:
- * Nat Friedman (nat@ximian.com)
- *
- * Copyright 2000, Ximian, Inc.
- */
-
-#include <config.h>
-#include <gtk/gtksignal.h>
-#include "e-book-listener.h"
-
-static EBookStatus e_book_listener_convert_status (GNOME_Evolution_Addressbook_BookListener_CallStatus status);
-
-enum {
- RESPONSES_QUEUED,
- LAST_SIGNAL
-};
-
-static guint e_book_listener_signals [LAST_SIGNAL];
-
-static BonoboObjectClass *e_book_listener_parent_class;
-POA_GNOME_Evolution_Addressbook_BookListener__vepv e_book_listener_vepv;
-
-struct _EBookListenerPrivate {
- GList *response_queue;
- gint timeout_id;
-
- guint timeout_lock : 1;
- guint stopped : 1;
-};
-
-static void
-response_free (EBookListenerResponse *resp)
-{
- if (resp == NULL)
- return;
-
- g_free (resp->msg);
- g_free (resp->id);
-
- if (resp->book != CORBA_OBJECT_NIL) {
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- bonobo_object_release_unref (resp->book, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_listener_destroy: "
- "Exception destroying book "
- "in response queue!\n");
- }
-
- CORBA_exception_free (&ev);
- }
-
- if (resp->cursor != CORBA_OBJECT_NIL) {
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- bonobo_object_release_unref (resp->cursor, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_listener_destroy: "
- "Exception destroying cursor "
- "in response queue!\n");
- }
-
- CORBA_exception_free (&ev);
- }
-
- if (resp->book_view != CORBA_OBJECT_NIL) {
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- bonobo_object_release_unref (resp->book_view, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_listener_destroy: "
- "Exception destroying book_view "
- "in response queue!\n");
- }
-
- CORBA_exception_free (&ev);
- }
-
- g_free (resp);
-}
-
-static gboolean
-e_book_listener_check_queue (EBookListener *listener)
-{
- if (listener->priv->timeout_lock)
- return TRUE;
-
- listener->priv->timeout_lock = TRUE;
-
- if (listener->priv->response_queue != NULL && !listener->priv->stopped) {
- gtk_signal_emit (GTK_OBJECT (listener), e_book_listener_signals [RESPONSES_QUEUED]);
- }
-
- if (listener->priv->response_queue == NULL || listener->priv->stopped) {
- listener->priv->timeout_id = 0;
- listener->priv->timeout_lock = FALSE;
- bonobo_object_unref (BONOBO_OBJECT (listener)); /* release the timeout's reference */
- return FALSE;
- }
-
- listener->priv->timeout_lock = FALSE;
- return TRUE;
-}
-
-static void
-e_book_listener_queue_response (EBookListener *listener,
- EBookListenerResponse *response)
-{
- if (response == NULL)
- return;
-
- if (listener->priv->stopped) {
- response_free (response);
- return;
- }
-
- listener->priv->response_queue = g_list_append (listener->priv->response_queue, response);
-
- if (listener->priv->timeout_id == 0) {
-
- /* 20 == an arbitrary small integer */
- listener->priv->timeout_id = g_timeout_add (20, (GSourceFunc) e_book_listener_check_queue, listener);
-
- /* Hold a reference on behalf of the timeout */
- bonobo_object_ref (BONOBO_OBJECT (listener));
-
- }
-}
-
-/* Add, Remove, Modify */
-static void
-e_book_listener_queue_generic_response (EBookListener *listener,
- EBookListenerOperation op,
- EBookStatus status)
-{
- EBookListenerResponse *resp;
-
- if (listener->priv->stopped)
- return;
-
- resp = g_new0 (EBookListenerResponse, 1);
-
- resp->op = op;
- resp->status = status;
-
- e_book_listener_queue_response (listener, resp);
-}
-
-static void
-e_book_listener_queue_open_response (EBookListener *listener,
- EBookStatus status,
- GNOME_Evolution_Addressbook_Book book)
-{
- EBookListenerResponse *resp;
-
- if (listener->priv->stopped)
- return;
-
- resp = g_new0 (EBookListenerResponse, 1);
-
- resp->op = OpenBookResponse;
- resp->status = status;
- resp->book = book;
-
- e_book_listener_queue_response (listener, resp);
-}
-
-static void
-e_book_listener_queue_open_progress (EBookListener *listener,
- const char *msg,
- short percent)
-{
- EBookListenerResponse *resp;
-
- if (listener->priv->stopped)
- return;
-
- resp = g_new0 (EBookListenerResponse, 1);
-
- resp->op = OpenProgressEvent;
- resp->msg = g_strdup (msg);
- resp->percent = percent;
-
- e_book_listener_queue_response (listener, resp);
-}
-
-
-static void
-e_book_listener_queue_create_card_response (EBookListener *listener,
- EBookStatus status,
- const char *id)
-{
- EBookListenerResponse *resp;
-
- if (listener->priv->stopped)
- return;
-
- resp = g_new0 (EBookListenerResponse, 1);
-
- resp->op = CreateCardResponse;
- resp->status = status;
- resp->id = g_strdup (id);
-
- e_book_listener_queue_response (listener, resp);
-}
-
-static void
-e_book_listener_queue_get_vcard_response (EBookListener *listener,
- EBookStatus status,
- const char *vcard)
-{
- EBookListenerResponse *resp;
-
- if (listener->priv->stopped)
- return;
-
- resp = g_new0 (EBookListenerResponse, 1);
-
- resp->op = GetCardResponse;
- resp->status = status;
- resp->vcard = g_strdup (vcard);
-
- e_book_listener_queue_response (listener, resp);
-}
-
-static void
-e_book_listener_queue_get_cursor_response (EBookListener *listener,
- EBookStatus status,
- GNOME_Evolution_Addressbook_CardCursor cursor)
-{
- EBookListenerResponse *resp;
-
- if (listener->priv->stopped)
- return;
-
- resp = g_new0 (EBookListenerResponse, 1);
-
- resp->op = GetCursorResponse;
- resp->status = status;
- resp->cursor = cursor;
-
- e_book_listener_queue_response (listener, resp);
-}
-
-static void
-e_book_listener_queue_get_view_response (EBookListener *listener,
- EBookStatus status,
- GNOME_Evolution_Addressbook_BookView book_view)
-{
- EBookListenerResponse *resp;
-
- if (listener->priv->stopped)
- return;
-
- resp = g_new0 (EBookListenerResponse, 1);
-
- resp->op = GetBookViewResponse;
- resp->status = status;
- resp->book_view = book_view;
-
- e_book_listener_queue_response (listener, resp);
-}
-
-static void
-e_book_listener_queue_get_changes_response (EBookListener *listener,
- EBookStatus status,
- GNOME_Evolution_Addressbook_BookView book_view)
-{
- EBookListenerResponse *resp;
-
- if (listener->priv->stopped)
- return;
-
- resp = g_new0 (EBookListenerResponse, 1);
-
- resp->op = GetChangesResponse;
- resp->status = status;
- resp->book_view = book_view;
-
- e_book_listener_queue_response (listener, resp);
-}
-
-static void
-e_book_listener_queue_link_status (EBookListener *listener,
- gboolean connected)
-{
- EBookListenerResponse *resp;
-
- if (listener->priv->stopped)
- return;
-
- resp = g_new0 (EBookListenerResponse, 1);
-
- resp->op = LinkStatusEvent;
- resp->connected = connected;
-
- e_book_listener_queue_response (listener, resp);
-}
-
-static void
-e_book_listener_queue_writable_status (EBookListener *listener,
- gboolean writable)
-{
- EBookListenerResponse *resp;
-
- if (listener->priv->stopped)
- return;
-
- resp = g_new0 (EBookListenerResponse, 1);
-
- resp->op = WritableStatusEvent;
- resp->writable = writable;
-
- e_book_listener_queue_response (listener, resp);
-}
-
-static void
-e_book_listener_queue_authentication_response (EBookListener *listener,
- EBookStatus status)
-{
- EBookListenerResponse *resp;
-
- if (listener->priv->stopped)
- return;
-
- resp = g_new0 (EBookListenerResponse, 1);
-
- resp->op = AuthenticationResponse;
- resp->status = status;
-
- e_book_listener_queue_response (listener, resp);
-}
-
-static void
-e_book_listener_queue_get_supported_fields_response (EBookListener *listener,
- EBookStatus status,
- const GNOME_Evolution_Addressbook_stringlist *fields)
-{
- EBookListenerResponse *resp;
- int i;
-
- if (listener->priv->stopped)
- return;
-
- resp = g_new0 (EBookListenerResponse, 1);
-
- resp->op = GetSupportedFieldsResponse;
- resp->status = status;
- resp->fields = e_list_new ((EListCopyFunc)g_strdup, (EListFreeFunc)g_free, NULL);
-
- for (i = 0; i < fields->_length; i ++) {
- e_list_append (resp->fields, fields->_buffer[i]);
- }
-
- e_book_listener_queue_response (listener, resp);
-}
-
-static void
-impl_BookListener_respond_create_card (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_BookListener_CallStatus status,
- const GNOME_Evolution_Addressbook_CardId id,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant));
-
- e_book_listener_queue_create_card_response (
- listener,
- e_book_listener_convert_status (status),
- id);
-}
-
-static void
-impl_BookListener_respond_remove_card (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_BookListener_CallStatus status,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant));
-
- e_book_listener_queue_generic_response (
- listener, RemoveCardResponse,
- e_book_listener_convert_status (status));
-}
-
-static void
-impl_BookListener_respond_modify_card (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_BookListener_CallStatus status,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant));
-
- e_book_listener_queue_generic_response (
- listener, ModifyCardResponse,
- e_book_listener_convert_status (status));
-}
-
-static void
-impl_BookListener_respond_get_vcard (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_BookListener_CallStatus status,
- const GNOME_Evolution_Addressbook_VCard card,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant));
-
- e_book_listener_queue_get_vcard_response (
- listener,
- e_book_listener_convert_status (status),
- g_strdup (card));
-}
-
-static void
-impl_BookListener_respond_get_cursor (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_BookListener_CallStatus status,
- const GNOME_Evolution_Addressbook_CardCursor cursor,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant));
- GNOME_Evolution_Addressbook_CardCursor cursor_copy;
-
- cursor_copy = bonobo_object_dup_ref (cursor, ev);
-
- if (ev->_major != CORBA_NO_EXCEPTION) {
- g_warning ("EBookListener: Exception while duplicating CardCursor!\n");
- return;
- }
-
- e_book_listener_queue_get_cursor_response (
- listener,
- e_book_listener_convert_status (status),
- cursor_copy);
-}
-
-static void
-impl_BookListener_respond_get_view (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_BookListener_CallStatus status,
- const GNOME_Evolution_Addressbook_BookView book_view,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant));
- GNOME_Evolution_Addressbook_BookView book_view_copy;
-
- book_view_copy = bonobo_object_dup_ref (book_view, ev);
-
- if (ev->_major != CORBA_NO_EXCEPTION) {
- g_warning ("EBookListener: Exception while duplicating BookView.\n");
- return;
- }
-
- e_book_listener_queue_get_view_response (
- listener,
- e_book_listener_convert_status (status),
- book_view_copy);
-}
-
-static void
-impl_BookListener_respond_get_changes (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_BookListener_CallStatus status,
- const GNOME_Evolution_Addressbook_BookView book_view,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant));
- GNOME_Evolution_Addressbook_BookView book_view_copy;
-
- book_view_copy = bonobo_object_dup_ref (book_view, ev);
-
- if (ev->_major != CORBA_NO_EXCEPTION) {
- g_warning ("EBookListener: Exception while duplicating BookView.\n");
- return;
- }
-
- e_book_listener_queue_get_changes_response (
- listener,
- e_book_listener_convert_status (status),
- book_view_copy);
-}
-
-static void
-impl_BookListener_respond_open_book (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_BookListener_CallStatus status,
- const GNOME_Evolution_Addressbook_Book book,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant));
- GNOME_Evolution_Addressbook_Book book_copy;
-
- book_copy = bonobo_object_dup_ref (book, ev);
-
- if (ev->_major != CORBA_NO_EXCEPTION) {
- g_warning ("EBookListener: Exception while duplicating Book!\n");
- return;
- }
-
- e_book_listener_queue_open_response (
- listener,
- e_book_listener_convert_status (status),
- book_copy);
-}
-
-static void
-impl_BookListener_report_open_book_progress (PortableServer_Servant servant,
- const CORBA_char *status_message,
- const CORBA_short percent,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant));
-
- e_book_listener_queue_open_progress (
- listener, status_message, percent);
-}
-
-static void
-impl_BookListener_respond_authentication_result (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_BookListener_CallStatus status,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant));
-
- e_book_listener_queue_authentication_response (
- listener, status);
-}
-
-static void
-impl_BookListener_response_get_supported_fields (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_BookListener_CallStatus status,
- const GNOME_Evolution_Addressbook_stringlist *fields,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant));
-
- e_book_listener_queue_get_supported_fields_response (
- listener, status, fields);
-}
-
-static void
-impl_BookListener_report_connection_status (PortableServer_Servant servant,
- const CORBA_boolean connected,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant));
-
- e_book_listener_queue_link_status (
- listener, connected);
-}
-
-static void
-impl_BookListener_report_writable (PortableServer_Servant servant,
- const CORBA_boolean writable,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant));
-
- e_book_listener_queue_writable_status (listener, writable);
-}
-
-/**
- * e_book_listener_check_pending:
- * @listener: the #EBookListener
- *
- * Returns: the number of items on the response queue,
- * or -1 if the @listener is isn't an #EBookListener.
- */
-int
-e_book_listener_check_pending (EBookListener *listener)
-{
- g_return_val_if_fail (listener != NULL, -1);
- g_return_val_if_fail (E_IS_BOOK_LISTENER (listener), -1);
-
- return g_list_length (listener->priv->response_queue);
-}
-
-/**
- * e_book_listener_pop_response:
- * @listener: the #EBookListener for which a request is to be popped
- *
- * Returns: an #EBookListenerResponse if there are responses on the
- * queue to be returned; %NULL if there aren't, or if the @listener
- * isn't an EBookListener.
- */
-EBookListenerResponse *
-e_book_listener_pop_response (EBookListener *listener)
-{
- EBookListenerResponse *resp;
- GList *popped;
-
- g_return_val_if_fail (listener != NULL, NULL);
- g_return_val_if_fail (E_IS_BOOK_LISTENER (listener), NULL);
-
- if (listener->priv->response_queue == NULL)
- return NULL;
-
- resp = listener->priv->response_queue->data;
-
- popped = listener->priv->response_queue;
- listener->priv->response_queue =
- g_list_remove_link (listener->priv->response_queue,
- listener->priv->response_queue);
- g_list_free_1 (popped);
-
- return resp;
-}
-
-static EBookStatus
-e_book_listener_convert_status (const GNOME_Evolution_Addressbook_BookListener_CallStatus status)
-{
- switch (status) {
- case GNOME_Evolution_Addressbook_BookListener_Success:
- return E_BOOK_STATUS_SUCCESS;
- case GNOME_Evolution_Addressbook_BookListener_RepositoryOffline:
- return E_BOOK_STATUS_REPOSITORY_OFFLINE;
- case GNOME_Evolution_Addressbook_BookListener_AuthenticationFailed:
- return E_BOOK_STATUS_AUTHENTICATION_FAILED;
- case GNOME_Evolution_Addressbook_BookListener_PermissionDenied:
- return E_BOOK_STATUS_PERMISSION_DENIED;
- case GNOME_Evolution_Addressbook_BookListener_CardNotFound:
- return E_BOOK_STATUS_CARD_NOT_FOUND;
- case GNOME_Evolution_Addressbook_BookListener_CardIdAlreadyExists:
- return E_BOOK_STATUS_CARD_ID_ALREADY_EXISTS;
- case GNOME_Evolution_Addressbook_BookListener_ProtocolNotSupported:
- return E_BOOK_STATUS_PROTOCOL_NOT_SUPPORTED;
- case GNOME_Evolution_Addressbook_BookListener_TLSNotAvailable:
- return E_BOOK_STATUS_TLS_NOT_AVAILABLE;
- case GNOME_Evolution_Addressbook_BookListener_OtherError:
- return E_BOOK_STATUS_OTHER_ERROR;
- default:
- g_warning ("e_book_listener_convert_status: Unknown status "
- "from card server: %d\n", (int) status);
- return E_BOOK_STATUS_UNKNOWN;
-
- }
-}
-
-static EBookListener *
-e_book_listener_construct (EBookListener *listener)
-{
- POA_GNOME_Evolution_Addressbook_BookListener *servant;
- CORBA_Environment ev;
- CORBA_Object obj;
-
- g_assert (listener != NULL);
- g_assert (E_IS_BOOK_LISTENER (listener));
-
- servant = (POA_GNOME_Evolution_Addressbook_BookListener *) g_new0 (BonoboObjectServant, 1);
- servant->vepv = &e_book_listener_vepv;
-
- CORBA_exception_init (&ev);
-
- POA_GNOME_Evolution_Addressbook_BookListener__init ((PortableServer_Servant) servant, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_free (servant);
- CORBA_exception_free (&ev);
-
- return NULL;
- }
-
- CORBA_exception_free (&ev);
-
- obj = bonobo_object_activate_servant (BONOBO_OBJECT (listener), servant);
- if (obj == CORBA_OBJECT_NIL) {
- g_free (servant);
-
- return NULL;
- }
-
- bonobo_object_construct (BONOBO_OBJECT (listener), obj);
-
- return listener;
-}
-
-/**
- * e_book_listener_new:
- * @book: the #EBook for which the listener is to be bound
- *
- * Creates and returns a new #EBookListener for the book.
- *
- * Returns: a new #EBookListener
- */
-EBookListener *
-e_book_listener_new ()
-{
- EBookListener *listener;
- EBookListener *retval;
-
- listener = gtk_type_new (E_BOOK_LISTENER_TYPE);
-
- retval = e_book_listener_construct (listener);
-
- if (retval == NULL) {
- g_warning ("e_book_listener_new: Error constructing "
- "EBookListener!\n");
- bonobo_object_unref (BONOBO_OBJECT (listener));
- return NULL;
- }
-
- return retval;
-}
-
-static void
-e_book_listener_init (EBookListener *listener)
-{
- listener->priv = g_new0 (EBookListenerPrivate, 1);
-}
-
-void
-e_book_listener_stop (EBookListener *listener)
-{
- g_return_if_fail (E_IS_BOOK_LISTENER (listener));
-
- listener->priv->stopped = TRUE;
-}
-
-static void
-e_book_listener_destroy (GtkObject *object)
-{
- EBookListener *listener = E_BOOK_LISTENER (object);
- GList *l;
-
- /* Remove our response queue handler: In theory, this can never happen since we
- always hold a reference to the listener while the timeout is running. */
- if (listener->priv->timeout_id) {
- g_source_remove (listener->priv->timeout_id);
- }
-
- /* Clean up anything still sitting in response_queue */
- for (l = listener->priv->response_queue; l != NULL; l = l->next) {
- EBookListenerResponse *resp = l->data;
-
- response_free (resp);
- }
- g_list_free (listener->priv->response_queue);
-
- g_free (listener->priv);
-
- GTK_OBJECT_CLASS (e_book_listener_parent_class)->destroy (object);
-}
-
-POA_GNOME_Evolution_Addressbook_BookListener__epv *
-e_book_listener_get_epv (void)
-{
- POA_GNOME_Evolution_Addressbook_BookListener__epv *epv;
-
- epv = g_new0 (POA_GNOME_Evolution_Addressbook_BookListener__epv, 1);
-
- epv->notifyOpenBookProgress = impl_BookListener_report_open_book_progress;
- epv->notifyBookOpened = impl_BookListener_respond_open_book;
-
- epv->notifyCardCreated = impl_BookListener_respond_create_card;
- epv->notifyCardRemoved = impl_BookListener_respond_remove_card;
- epv->notifyCardModified = impl_BookListener_respond_modify_card;
-
- epv->notifyAuthenticationResult = impl_BookListener_respond_authentication_result;
- epv->notifySupportedFields = impl_BookListener_response_get_supported_fields;
-
- epv->notifyCardRequested = impl_BookListener_respond_get_vcard;
- epv->notifyCursorRequested = impl_BookListener_respond_get_cursor;
- epv->notifyViewRequested = impl_BookListener_respond_get_view;
- epv->notifyChangesRequested = impl_BookListener_respond_get_changes;
-
- epv->notifyConnectionStatus = impl_BookListener_report_connection_status;
- epv->notifyWritable = impl_BookListener_report_writable;
-
- return epv;
-}
-
-static void
-e_book_listener_corba_class_init (void)
-{
- e_book_listener_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv ();
- e_book_listener_vepv.GNOME_Evolution_Addressbook_BookListener_epv = e_book_listener_get_epv ();
-}
-
-static void
-e_book_listener_class_init (EBookListenerClass *klass)
-{
- GtkObjectClass *object_class = (GtkObjectClass *) klass;
-
- e_book_listener_parent_class = gtk_type_class (bonobo_object_get_type ());
-
- e_book_listener_signals [RESPONSES_QUEUED] =
- gtk_signal_new ("responses_queued",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EBookListenerClass, responses_queued),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- gtk_object_class_add_signals (object_class, e_book_listener_signals, LAST_SIGNAL);
-
- object_class->destroy = e_book_listener_destroy;
-
- e_book_listener_corba_class_init ();
-}
-
-/**
- * e_book_listener_get_type:
- */
-GtkType
-e_book_listener_get_type (void)
-{
- static GtkType type = 0;
-
- if (! type) {
- GtkTypeInfo info = {
- "EBookListener",
- sizeof (EBookListener),
- sizeof (EBookListenerClass),
- (GtkClassInitFunc) e_book_listener_class_init,
- (GtkObjectInitFunc) e_book_listener_init,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- type = gtk_type_unique (bonobo_object_get_type (), &info);
- }
-
- return type;
-}
diff --git a/addressbook/backend/ebook/e-book-listener.h b/addressbook/backend/ebook/e-book-listener.h
deleted file mode 100644
index f546c9a029..0000000000
--- a/addressbook/backend/ebook/e-book-listener.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * A client-side GtkObject which exposes the
- * Evolution:BookListener interface.
- *
- * Author:
- * Nat Friedman (nat@ximian.com)
- *
- * Copyright 2000, Ximian, Inc.
- */
-
-#ifndef __E_BOOK_LISTENER_H__
-#define __E_BOOK_LISTENER_H__
-
-#include <libgnome/gnome-defs.h>
-#include <bonobo/bonobo-object.h>
-#include <ebook/addressbook.h>
-#include <ebook/e-book-types.h>
-#include <e-util/e-list.h>
-
-BEGIN_GNOME_DECLS
-
-typedef struct _EBookListener EBookListener;
-typedef struct _EBookListenerClass EBookListenerClass;
-typedef struct _EBookListenerPrivate EBookListenerPrivate;
-
-struct _EBookListener {
- BonoboObject parent;
- EBookListenerPrivate *priv;
-};
-
-struct _EBookListenerClass {
- BonoboObjectClass parent;
-
- /*
- * Signals
- */
- void (*responses_queued) (void);
-};
-
-typedef enum {
- /* Async responses */
- OpenBookResponse,
- CreateCardResponse,
- RemoveCardResponse,
- ModifyCardResponse,
- GetCardResponse,
- GetCursorResponse,
- GetBookViewResponse,
- GetChangesResponse,
- AuthenticationResponse,
- GetSupportedFieldsResponse,
-
- /* Async events */
- LinkStatusEvent,
- WritableStatusEvent,
- OpenProgressEvent,
-} EBookListenerOperation;
-
-typedef struct {
- EBookListenerOperation op;
-
- /* For most Response notifications */
- EBookStatus status;
-
- /* For OpenBookResponse */
- GNOME_Evolution_Addressbook_Book book;
-
- /* For GetCursorResponse */
- GNOME_Evolution_Addressbook_CardCursor cursor;
-
- /* For GetBookViewReponse */
- GNOME_Evolution_Addressbook_BookView book_view;
-
- /* For GetSupportedFields */
- EList *fields;
-
- /* For OpenProgressEvent */
- char *msg;
- short percent;
-
- /* For LinkStatusEvent */
- gboolean connected;
-
- /* For WritableStatusEvent */
- gboolean writable;
-
- /* For Card[Added|Removed|Modified]Event */
- char *id;
- char *vcard;
-} EBookListenerResponse;
-
-EBookListener *e_book_listener_new (void);
-int e_book_listener_check_pending (EBookListener *listener);
-EBookListenerResponse *e_book_listener_pop_response (EBookListener *listener);
-GtkType e_book_listener_get_type (void);
-void e_book_listener_stop (EBookListener *listener);
-
-POA_GNOME_Evolution_Addressbook_BookListener__epv *e_book_listener_get_epv (void);
-
-#define E_BOOK_LISTENER_TYPE (e_book_listener_get_type ())
-#define E_BOOK_LISTENER(o) (GTK_CHECK_CAST ((o), E_BOOK_LISTENER_TYPE, EBookListener))
-#define E_BOOK_LISTENER_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_BOOK_LISTENER_TYPE, EBookListenerClass))
-#define E_IS_BOOK_LISTENER(o) (GTK_CHECK_TYPE ((o), E_BOOK_LISTENER_TYPE))
-#define E_IS_BOOK_LISTENER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_BOOK_LISTENER_TYPE))
-
-END_GNOME_DECLS
-
-#endif /* ! __E_BOOK_LISTENER_H__ */
diff --git a/addressbook/backend/ebook/e-book-types.h b/addressbook/backend/ebook/e-book-types.h
deleted file mode 100644
index 398e46d74c..0000000000
--- a/addressbook/backend/ebook/e-book-types.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * A client-side GtkObject which exposes the
- * Evolution:BookListener interface.
- *
- * Author:
- * Nat Friedman (nat@ximian.com)
- *
- * Copyright 2000, Ximian, Inc.
- */
-
-#ifndef __E_BOOK_TYPES_H__
-#define __E_BOOK_TYPES_H__
-
-#include <libgnome/gnome-defs.h>
-
-BEGIN_GNOME_DECLS
-
-typedef enum {
- E_BOOK_STATUS_SUCCESS,
- E_BOOK_STATUS_UNKNOWN,
- E_BOOK_STATUS_REPOSITORY_OFFLINE,
- E_BOOK_STATUS_PERMISSION_DENIED,
- E_BOOK_STATUS_CARD_NOT_FOUND,
- E_BOOK_STATUS_CARD_ID_ALREADY_EXISTS,
- E_BOOK_STATUS_PROTOCOL_NOT_SUPPORTED,
- E_BOOK_STATUS_CANCELLED,
- E_BOOK_STATUS_AUTHENTICATION_FAILED,
- E_BOOK_STATUS_TLS_NOT_AVAILABLE,
- E_BOOK_STATUS_OTHER_ERROR
-} EBookStatus;
-
-typedef enum {
- E_BOOK_SIMPLE_QUERY_STATUS_SUCCESS,
- E_BOOK_SIMPLE_QUERY_STATUS_CANCELLED,
- E_BOOK_SIMPLE_QUERY_STATUS_OTHER_ERROR
-} EBookSimpleQueryStatus;
-
-END_GNOME_DECLS
-
-#endif /* ! __E_BOOK_TYPES_H__ */
diff --git a/addressbook/backend/ebook/e-book-util.c b/addressbook/backend/ebook/e-book-util.c
deleted file mode 100644
index d3de9840f8..0000000000
--- a/addressbook/backend/ebook/e-book-util.c
+++ /dev/null
@@ -1,759 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * e-book-util.c
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Developed by Jon Trowbridge <trow@ximian.com>
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA.
- */
-
-#include <config.h>
-#include "e-book-util.h"
-
-#include <gtk/gtkobject.h>
-#include <gtk/gtksignal.h>
-#include <libgnome/gnome-defs.h>
-#include <libgnome/gnome-util.h>
-#include "e-card-compare.h"
-
-typedef struct _CommonBookInfo CommonBookInfo;
-struct _CommonBookInfo {
- EBookCommonCallback cb;
- gpointer closure;
-};
-
-char *
-e_book_expand_uri (const char *uri)
-{
- char *new_uri;
-
- if (!strncmp (uri, "file:", 5)) {
- if (strlen (uri + 7) > 3
- && !strcmp (uri + strlen(uri) - 3, ".db")) {
- /* it's a .db file */
- new_uri = g_strdup (uri);
- }
- else {
- char *file_name;
- /* we assume it's a dir and glom addressbook.db onto the end. */
- file_name = g_concat_dir_and_file(uri + 7, "addressbook.db");
- new_uri = g_strdup_printf("file://%s", file_name);
- g_free(file_name);
- }
- }
- else {
- new_uri = g_strdup (uri);
- }
-
- return new_uri;
-}
-
-static void
-got_uri_book_cb (EBook *book, EBookStatus status, gpointer closure)
-{
- CommonBookInfo *info = (CommonBookInfo *) closure;
-
- if (status == E_BOOK_STATUS_SUCCESS) {
- info->cb (book, info->closure);
- } else {
- info->cb (NULL, info->closure);
- }
- g_free (info);
-}
-
-gboolean
-e_book_load_address_book_by_uri (EBook *book, const char *uri, EBookCallback open_response, gpointer closure)
-{
- gboolean rv;
- char *real_uri;
-
- g_return_val_if_fail (book != NULL, FALSE);
- g_return_val_if_fail (E_IS_BOOK (book), FALSE);
- g_return_val_if_fail (open_response != NULL, FALSE);
-
- real_uri = e_book_expand_uri (uri);
-
- rv = e_book_load_uri (book, real_uri, open_response, closure);
-
- if (!rv) {
- g_warning ("Couldn't load addressbook %s", real_uri);
- }
-
- g_free (real_uri);
-
- return rv;
-}
-
-void
-e_book_use_address_book_by_uri (const char *uri, EBookCommonCallback cb, gpointer closure)
-{
- EBook *book;
- CommonBookInfo *info;
-
- g_return_if_fail (cb != NULL);
-
- info = g_new0 (CommonBookInfo, 1);
- info->cb = cb;
- info->closure = closure;
-
- book = e_book_new ();
- if (! e_book_load_address_book_by_uri (book, uri, got_uri_book_cb, info)) {
- gtk_object_unref (GTK_OBJECT (book));
- g_free (info);
- }
-}
-
-Bonobo_ConfigDatabase
-e_book_get_config_database (CORBA_Environment *ev)
-{
- static Bonobo_ConfigDatabase config_db;
-
- if (config_db == NULL)
- config_db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", ev);
-
- return config_db;
-}
-
-gboolean
-e_book_load_local_address_book (EBook *book, EBookCallback open_response, gpointer closure)
-{
- gchar *filename;
- gchar *uri;
- gboolean rv;
-
- g_return_val_if_fail (book != NULL, FALSE);
- g_return_val_if_fail (E_IS_BOOK (book), FALSE);
- g_return_val_if_fail (open_response != NULL, FALSE);
-
- filename = gnome_util_prepend_user_home ("evolution/local/Contacts/addressbook.db");
- uri = g_strdup_printf ("file://%s", filename);
-
- rv = e_book_load_uri (book, uri, open_response, closure);
-
- if (!rv) {
- g_warning ("Couldn't load local addressbook %s", uri);
- }
-
- g_free (filename);
- g_free (uri);
-
- return rv;
-}
-
-static EBook *common_local_book = NULL;
-
-static void
-got_local_book_cb (EBook *book, EBookStatus status, gpointer closure)
-{
- CommonBookInfo *info = (CommonBookInfo *) closure;
-
- if (status == E_BOOK_STATUS_SUCCESS) {
-
- /* We try not to leak in a race condition where the
- local book got loaded twice. */
-
- if (common_local_book) {
- gtk_object_unref (GTK_OBJECT (book));
- book = common_local_book;
- }
-
- info->cb (book, info->closure);
-
- if (common_local_book == NULL) {
- common_local_book = book;
- }
-
- } else {
-
- info->cb (NULL, info->closure);
-
- }
- g_free (info);
-}
-
-void
-e_book_use_local_address_book (EBookCommonCallback cb, gpointer closure)
-{
- EBook *book;
- CommonBookInfo *info;
-
- g_return_if_fail (cb != NULL);
-
- if (common_local_book != NULL) {
- cb (common_local_book, closure);
- return;
- }
-
- info = g_new0 (CommonBookInfo, 1);
- info->cb = cb;
- info->closure = closure;
-
- book = e_book_new ();
- if (! e_book_load_local_address_book (book, got_local_book_cb, info)) {
- gtk_object_unref (GTK_OBJECT (book));
- g_free (info);
- }
-}
-
-typedef struct {
- gpointer closure;
- EBookCallback open_response;
-} DefaultBookClosure;
-
-static void
-e_book_default_book_open (EBook *book, EBookStatus status, gpointer closure)
-{
- DefaultBookClosure *default_book_closure = closure;
- gpointer user_closure = default_book_closure->closure;
- EBookCallback user_response = default_book_closure->open_response;
-
- g_free (default_book_closure);
-
- /* special case the protocol not supported error, since we
- really only want to failover to the local book in the case
- where there's no installed backend for that protocol. all
- other errors (failure to connect, etc.) should get reported
- to the caller as normal. */
- if (status == E_BOOK_STATUS_PROTOCOL_NOT_SUPPORTED) {
- e_book_load_local_address_book (book, user_response, user_closure);
- }
- else {
- user_response (book, status, user_closure);
- }
-}
-
-gboolean
-e_book_load_default_book (EBook *book, EBookCallback open_response, gpointer closure)
-{
- char *val, *uri;
- gboolean rv;
- CORBA_Environment ev;
- Bonobo_ConfigDatabase config_db;
-
- g_return_val_if_fail (book != NULL, FALSE);
- g_return_val_if_fail (E_IS_BOOK (book), FALSE);
- g_return_val_if_fail (open_response != NULL, FALSE);
-
- CORBA_exception_init (&ev);
- config_db = e_book_get_config_database (&ev);
- val = bonobo_config_get_string (config_db, "/DefaultFolders/contacts_uri", &ev);
- CORBA_exception_free (&ev);
-
- if (val) {
- DefaultBookClosure *default_book_closure = g_new (DefaultBookClosure, 1);
- default_book_closure->closure = closure;
- default_book_closure->open_response = open_response;
-
- /* Sigh. FIXME. */
- if (!strncmp (val, "file:", 5))
- uri = g_strconcat (val, "/addressbook.db", NULL);
- else
- uri = g_strdup (val);
- rv = e_book_load_uri (book, uri,
- e_book_default_book_open, default_book_closure);
- g_free (uri);
- g_free (val);
- }
- else {
- rv = e_book_load_local_address_book (book, open_response, closure);
- }
-
- if (!rv) {
- g_warning ("Couldn't load default addressbook");
- }
-
- return rv;
-}
-
-/*
- *
- * Simple Query Stuff
- *
- */
-
-typedef struct _SimpleQueryInfo SimpleQueryInfo;
-struct _SimpleQueryInfo {
- guint tag;
- EBook *book;
- gchar *query;
- EBookSimpleQueryCallback cb;
- gpointer closure;
- EBookView *view;
- guint add_tag;
- guint seq_complete_tag;
- GList *cards;
- gboolean cancelled;
-};
-
-static void
-book_add_simple_query (EBook *book, SimpleQueryInfo *info)
-{
- GList *pending = gtk_object_get_data (GTK_OBJECT (book), "sq_pending");
- pending = g_list_prepend (pending, info);
- gtk_object_set_data (GTK_OBJECT (book), "sq_pending", pending);
-}
-
-static SimpleQueryInfo *
-book_lookup_simple_query (EBook *book, guint tag)
-{
- GList *pending = gtk_object_get_data (GTK_OBJECT (book), "sq_pending");
- while (pending) {
- SimpleQueryInfo *sq = pending->data;
- if (sq->tag == tag)
- return sq;
- pending = g_list_next (pending);
- }
- return NULL;
-}
-
-static void
-book_remove_simple_query (EBook *book, SimpleQueryInfo *info)
-{
- GList *pending = gtk_object_get_data (GTK_OBJECT (book), "sq_pending");
- GList *i;
-
- for (i=pending; i != NULL; i = g_list_next (i)) {
- if (i->data == info) {
- pending = g_list_remove_link (pending, i);
- g_list_free_1 (i);
- break;
- }
- }
- gtk_object_set_data (GTK_OBJECT (book), "sq_pending", pending);
-}
-
-static guint
-book_issue_tag (EBook *book)
-{
- gpointer ptr = gtk_object_get_data (GTK_OBJECT (book), "sq_tag");
- guint tag = GPOINTER_TO_UINT (ptr);
- if (tag == 0)
- tag = 1;
- gtk_object_set_data (GTK_OBJECT (book), "sq_tag", GUINT_TO_POINTER (tag+1));
- return tag;
-}
-
-static SimpleQueryInfo *
-simple_query_new (EBook *book, const char *query, EBookSimpleQueryCallback cb, gpointer closure)
-{
- SimpleQueryInfo *sq = g_new0 (SimpleQueryInfo, 1);
-
- sq->tag = book_issue_tag (book);
- sq->book = book;
- gtk_object_ref (GTK_OBJECT (book));
- sq->query = g_strdup (query);
- sq->cb = cb;
- sq->closure = closure;
- sq->cancelled = FALSE;
-
- /* Automatically add ourselves to the EBook's pending list. */
- book_add_simple_query (book, sq);
-
- return sq;
-}
-
-static void
-simple_query_disconnect (SimpleQueryInfo *sq)
-{
- if (sq->add_tag) {
- gtk_signal_disconnect (GTK_OBJECT (sq->view), sq->add_tag);
- sq->add_tag = 0;
- }
-
- if (sq->seq_complete_tag) {
- gtk_signal_disconnect (GTK_OBJECT (sq->view), sq->seq_complete_tag);
- sq->seq_complete_tag = 0;
- }
-
- if (sq->view) {
- gtk_object_unref (GTK_OBJECT (sq->view));
- sq->view = NULL;
- }
-}
-
-static void
-simple_query_free (SimpleQueryInfo *sq)
-{
- simple_query_disconnect (sq);
-
- /* Remove ourselves from the EBook's pending list. */
- book_remove_simple_query (sq->book, sq);
-
- g_free (sq->query);
-
- if (sq->book)
- gtk_object_unref (GTK_OBJECT (sq->book));
-
- g_list_foreach (sq->cards, (GFunc) gtk_object_unref, NULL);
- g_list_free (sq->cards);
-
- g_free (sq);
-}
-
-static void
-simple_query_card_added_cb (EBookView *view, const GList *cards, gpointer closure)
-{
- SimpleQueryInfo *sq = closure;
-
- if (sq->cancelled)
- return;
-
- sq->cards = g_list_concat (sq->cards, g_list_copy ((GList *) cards));
- g_list_foreach ((GList *) cards, (GFunc) gtk_object_ref, NULL);
-}
-
-static void
-simple_query_sequence_complete_cb (EBookView *view, gpointer closure)
-{
- SimpleQueryInfo *sq = closure;
-
- /* Disconnect signals, so that we don't pick up any changes to the book that occur
- in our callback */
- simple_query_disconnect (sq);
- if (! sq->cancelled)
- sq->cb (sq->book, E_BOOK_SIMPLE_QUERY_STATUS_SUCCESS, sq->cards, sq->closure);
- simple_query_free (sq);
-}
-
-static void
-simple_query_book_view_cb (EBook *book, EBookStatus status, EBookView *book_view, gpointer closure)
-{
- SimpleQueryInfo *sq = closure;
-
- if (sq->cancelled) {
- simple_query_free (sq);
- return;
- }
-
- if (status != E_BOOK_STATUS_SUCCESS) {
- simple_query_disconnect (sq);
- sq->cb (sq->book, E_BOOK_SIMPLE_QUERY_STATUS_OTHER_ERROR, NULL, sq->closure);
- simple_query_free (sq);
- return;
- }
-
- sq->view = book_view;
- gtk_object_ref (GTK_OBJECT (book_view));
-
- sq->add_tag = gtk_signal_connect (GTK_OBJECT (sq->view),
- "card_added",
- GTK_SIGNAL_FUNC (simple_query_card_added_cb),
- sq);
- sq->seq_complete_tag = gtk_signal_connect (GTK_OBJECT (sq->view),
- "sequence_complete",
- GTK_SIGNAL_FUNC (simple_query_sequence_complete_cb),
- sq);
-}
-
-guint
-e_book_simple_query (EBook *book, const char *query, EBookSimpleQueryCallback cb, gpointer closure)
-{
- SimpleQueryInfo *sq;
-
- g_return_val_if_fail (book && E_IS_BOOK (book), 0);
- g_return_val_if_fail (query, 0);
- g_return_val_if_fail (cb, 0);
-
- sq = simple_query_new (book, query, cb, closure);
- e_book_get_book_view (book, (gchar *) query, simple_query_book_view_cb, sq);
-
- return sq->tag;
-}
-
-void
-e_book_simple_query_cancel (EBook *book, guint tag)
-{
- SimpleQueryInfo *sq;
-
- g_return_if_fail (book && E_IS_BOOK (book));
-
- sq = book_lookup_simple_query (book, tag);
-
- if (sq) {
- sq->cancelled = TRUE;
- sq->cb (sq->book, E_BOOK_SIMPLE_QUERY_STATUS_CANCELLED, NULL, sq->closure);
- } else {
- g_warning ("Simple query tag %d is unknown", tag);
- }
-}
-
-/*
- *
- * Specialized Queries
- *
- */
-
-typedef struct _NameEmailQueryInfo NameEmailQueryInfo;
-struct _NameEmailQueryInfo {
- gchar *name;
- gchar *email;
- EBookSimpleQueryCallback cb;
- gpointer closure;
-};
-
-static void
-name_email_query_info_free (NameEmailQueryInfo *info)
-{
- if (info) {
- g_free (info->name);
- g_free (info->email);
- g_free (info);
- }
-}
-
-static void
-name_and_email_cb (EBook *book, EBookSimpleQueryStatus status, const GList *cards, gpointer closure)
-{
- NameEmailQueryInfo *info = closure;
- GList *filtered_cards = NULL;
-
- while (cards) {
- ECard *card = E_CARD (cards->data);
- if ((info->name == NULL || e_card_compare_name_to_string (card, info->name) >= E_CARD_MATCH_VAGUE)
- && (info->email == NULL || e_card_email_match_string (card, info->email))) {
- filtered_cards = g_list_append (filtered_cards, card);
- }
- cards = g_list_next (cards);
- }
-
- info->cb (book, status, filtered_cards, info->closure);
-
- g_list_free (filtered_cards);
-
- name_email_query_info_free (info);
-}
-
-guint
-e_book_name_and_email_query (EBook *book,
- const gchar *name,
- const gchar *email,
- EBookSimpleQueryCallback cb,
- gpointer closure)
-{
- NameEmailQueryInfo *info;
- gchar *email_query=NULL, *name_query=NULL, *query;
- guint tag;
-
- g_return_val_if_fail (book && E_IS_BOOK (book), 0);
- g_return_val_if_fail (cb != NULL, 0);
-
- if (name && !*name)
- name = NULL;
- if (email && !*email)
- email = NULL;
-
- if (name == NULL && email == NULL)
- return 0;
-
- /* Build our e-mail query.
- * We only query against the username part of the address, to avoid not matching
- * fred@foo.com and fred@mail.foo.com. While their may be namespace collisions
- * in the usernames of everyone out there, it shouldn't be that bad. (Famous last words.)
- */
- if (email) {
- const gchar *t = email;
- while (*t && *t != '@')
- ++t;
- if (*t == '@') {
- email_query = g_strdup_printf ("(beginswith \"email\" \"%.*s@\")", t-email, email);
-
- } else {
- email_query = g_strdup_printf ("(beginswith \"email\" \"%s\")", email);
- }
- }
-
- /* Build our name query.
- * We only do name-query stuff if we don't have an e-mail address. Our basic assumption
- * is that the username part of the email is good enough to keep the amount of stuff returned
- * in the query relatively small.
- */
- if (name && !email) {
- gchar *name_cpy = g_strdup (name), *qjoined;
- gchar **namev;
- gint i, count=0;
-
- g_strstrip (name_cpy);
- namev = g_strsplit (name_cpy, " ", 0);
- for (i=0; namev[i]; ++i) {
- if (*namev[i]) {
- char *str = namev[i];
-
- namev[i] = g_strdup_printf ("(contains \"file_as\" \"%s\")", namev[i]);
- ++count;
-
- g_free (str);
- }
- }
-
- qjoined = g_strjoinv (" ", namev);
- if (count > 1) {
- name_query = g_strdup_printf ("(or %s)", qjoined);
- } else {
- name_query = qjoined;
- qjoined = NULL;
- }
-
- g_free (name_cpy);
- g_strfreev (namev);
- g_free (qjoined);
- }
-
- /* Assemble our e-mail & name queries */
- if (email_query && name_query) {
- query = g_strdup_printf ("(and %s %s)", email_query, name_query);
- } else if (email_query) {
- query = email_query;
- email_query = NULL;
- } else if (name_query) {
- query = name_query;
- name_query = NULL;
- } else
- return 0;
-
- info = g_new0 (NameEmailQueryInfo, 1);
- info->name = g_strdup (name);
- info->email = g_strdup (email);
- info->cb = cb;
- info->closure = closure;
-
- tag = e_book_simple_query (book, query, name_and_email_cb, info);
-
- g_free (email_query);
- g_free (name_query);
- g_free (query);
-
- return tag;
-}
-
-/*
- * Simple nickname query
- */
-
-typedef struct _NicknameQueryInfo NicknameQueryInfo;
-struct _NicknameQueryInfo {
- gchar *nickname;
- EBookSimpleQueryCallback cb;
- gpointer closure;
-};
-
-static void
-nickname_cb (EBook *book, EBookSimpleQueryStatus status, const GList *cards, gpointer closure)
-{
- NicknameQueryInfo *info = closure;
-
- if (info->cb)
- info->cb (book, status, cards, info->closure);
-
- g_free (info->nickname);
- g_free (info);
-}
-
-guint
-e_book_nickname_query (EBook *book,
- const char *nickname,
- EBookSimpleQueryCallback cb,
- gpointer closure)
-{
- NicknameQueryInfo *info;
- gchar *query;
- guint retval;
-
- g_return_val_if_fail (E_IS_BOOK (book), 0);
- g_return_val_if_fail (nickname != NULL, 0);
-
- /* The empty-string case shouldn't generate a warning. */
- if (! *nickname)
- return 0;
-
- info = g_new0 (NicknameQueryInfo, 1);
- info->nickname = g_strdup (nickname);
- info->cb = cb;
- info->closure = closure;
-
- query = g_strdup_printf ("(is \"nickname\" \"%s\")", info->nickname);
-
- retval = e_book_simple_query (book, query, nickname_cb, info);
-
- g_free (query);
-
- return retval;
-}
-
-/*
- * Convenience routine to check for addresses in the local address book.
- */
-
-typedef struct _HaveAddressInfo HaveAddressInfo;
-struct _HaveAddressInfo {
- gchar *email;
- EBookHaveAddressCallback cb;
- gpointer closure;
-};
-
-static void
-have_address_query_cb (EBook *book, EBookSimpleQueryStatus status, const GList *cards, gpointer closure)
-{
- HaveAddressInfo *info = (HaveAddressInfo *) closure;
-
- info->cb (book,
- info->email,
- cards && (status == E_BOOK_SIMPLE_QUERY_STATUS_SUCCESS) ? E_CARD (cards->data) : NULL,
- info->closure);
-
- g_free (info->email);
- g_free (info);
-}
-
-static void
-have_address_book_open_cb (EBook *book, gpointer closure)
-{
- HaveAddressInfo *info = (HaveAddressInfo *) closure;
-
- if (book) {
-
- e_book_name_and_email_query (book, NULL, info->email, have_address_query_cb, info);
-
- } else {
-
- info->cb (NULL, info->email, NULL, info->closure);
-
- g_free (info->email);
- g_free (info);
-
- }
-}
-
-void
-e_book_query_address_locally (const gchar *email,
- EBookHaveAddressCallback cb,
- gpointer closure)
-{
- HaveAddressInfo *info;
-
- g_return_if_fail (email != NULL);
- g_return_if_fail (cb != NULL);
-
- info = g_new0 (HaveAddressInfo, 1);
- info->email = g_strdup (email);
- info->cb = cb;
- info->closure = closure;
-
- e_book_use_local_address_book (have_address_book_open_cb, info);
-}
diff --git a/addressbook/backend/ebook/e-book-util.h b/addressbook/backend/ebook/e-book-util.h
deleted file mode 100644
index 33f90c399f..0000000000
--- a/addressbook/backend/ebook/e-book-util.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * e-book-util.h
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Developed by Jon Trowbridge <trow@ximian.com>
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA.
- */
-
-#ifndef __E_BOOK_UTIL_H__
-#define __E_BOOK_UTIL_H__
-
-#include <libgnome/gnome-defs.h>
-#include "e-book.h"
-#include <bonobo-conf/bonobo-config-database.h>
-#include <bonobo/bonobo-object.h>
-#include <bonobo/bonobo-moniker-util.h>
-
-BEGIN_GNOME_DECLS
-
-/* Callbacks for asynchronous functions. */
-typedef void (*EBookCommonCallback) (EBook *book, gpointer closure);
-typedef void (*EBookSimpleQueryCallback) (EBook *book, EBookSimpleQueryStatus status, const GList *cards, gpointer closure);
-typedef void (*EBookHaveAddressCallback) (EBook *book, const gchar *addr, ECard *card, gpointer closure);
-
-/* expand file:///foo/foo/ to file:///foo/foo/addressbook.db */
-char *e_book_expand_uri (const char *uri);
-gboolean e_book_load_address_book_by_uri (EBook *book,
- const char *uri,
- EBookCallback open_response,
- gpointer closure);
-void e_book_use_address_book_by_uri (const char *uri,
- EBookCommonCallback cb,
- gpointer closure);
-
-gboolean e_book_load_local_address_book (EBook *book,
- EBookCallback open_response,
- gpointer closure);
-void e_book_use_local_address_book (EBookCommonCallback cb,
- gpointer closure);
-gboolean e_book_load_default_book (EBook *book,
- EBookCallback open_response,
- gpointer closure);
-
-/* Bonoboconf database interface. */
-Bonobo_ConfigDatabase e_book_get_config_database (CORBA_Environment *ev);
-
-/* Simple Query Interface. */
-guint e_book_simple_query (EBook *book,
- const char *query,
- EBookSimpleQueryCallback cb,
- gpointer closure);
-void e_book_simple_query_cancel (EBook *book,
- guint tag);
-
-/* Specialized Name/Email Queries */
-guint e_book_name_and_email_query (EBook *book,
- const char *name,
- const char *email,
- EBookSimpleQueryCallback cb,
- gpointer closure);
-guint e_book_nickname_query (EBook *book,
- const char *nickname,
- EBookSimpleQueryCallback cb,
- gpointer closure);
-
-/* Returns the ECard associated to email in the callback,
- or NULL if no match is found in the local address book. */
-void e_book_query_address_locally (const gchar *email,
- EBookHaveAddressCallback cb,
- gpointer closure);
-
-END_GNOME_DECLS
-
-
-#endif /* __E_BOOK_UTIL_H__ */
-
diff --git a/addressbook/backend/ebook/e-book-view-listener.c b/addressbook/backend/ebook/e-book-view-listener.c
deleted file mode 100644
index 9981375631..0000000000
--- a/addressbook/backend/ebook/e-book-view-listener.c
+++ /dev/null
@@ -1,483 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Exports the BookViewListener interface. Maintains a queue of messages
- * which come in on the interface.
- *
- * Author:
- * Nat Friedman (nat@ximian.com)
- *
- * Copyright 2000, Ximian, Inc.
- */
-
-#include <config.h>
-#include <gtk/gtksignal.h>
-#include "e-book-view-listener.h"
-#include "e-book-view.h"
-#include "e-card.h"
-
-enum {
- RESPONSES_QUEUED,
- LAST_SIGNAL
-};
-
-static guint e_book_view_listener_signals [LAST_SIGNAL];
-
-static BonoboObjectClass *e_book_view_listener_parent_class;
-POA_GNOME_Evolution_Addressbook_BookViewListener__vepv e_book_view_listener_vepv;
-
-struct _EBookViewListenerPrivate {
- GList *response_queue;
- gint timeout_id;
-
- guint timeout_lock : 1;
- guint stopped : 1;
-};
-
-static gboolean
-e_book_view_listener_check_queue (EBookViewListener *listener)
-{
- if (listener->priv->timeout_lock)
- return TRUE;
-
- listener->priv->timeout_lock = TRUE;
-
- if (listener->priv->response_queue != NULL && !listener->priv->stopped) {
- gtk_signal_emit (GTK_OBJECT (listener), e_book_view_listener_signals [RESPONSES_QUEUED]);
- }
-
- if (listener->priv->response_queue == NULL || listener->priv->stopped) {
- listener->priv->timeout_id = 0;
- listener->priv->timeout_lock = FALSE;
- bonobo_object_unref (BONOBO_OBJECT (listener));
- return FALSE;
- }
-
- listener->priv->timeout_lock = FALSE;
- return TRUE;
-}
-
-static void
-e_book_view_listener_queue_response (EBookViewListener *listener,
- EBookViewListenerResponse *response)
-{
- if (response == NULL)
- return;
-
- if (listener->priv->stopped) {
- /* Free response and return */
- g_free (response->id);
- g_list_foreach (response->cards, (GFunc) gtk_object_unref, NULL);
- g_list_free (response->cards);
- g_free (response->message);
- g_free (response);
- return;
- }
-
- /* a slight optimization for huge ldap queries. if there's an
- existing Add response on the end of the queue, and we're an
- Add response, we just glom the two lists of cards
- together */
- if (response->op == CardAddedEvent) {
- GList *last = g_list_last (listener->priv->response_queue);
- EBookViewListenerResponse *last_resp = NULL;
-
- if (last) last_resp = last->data;
-
- if (last_resp && last_resp->op == CardAddedEvent ) {
- response->cards = g_list_concat (last_resp->cards, response->cards);
- g_free (response);
- /* there should already be a timeout since the
- queue isn't empty, so we'll just return
- here */
- return;
- }
- else
- listener->priv->response_queue = g_list_append (last, response);
- }
- else
- listener->priv->response_queue = g_list_append (listener->priv->response_queue, response);
-
- if (listener->priv->timeout_id == 0) {
-
- /* Here, 20 == an arbitrary small number */
- listener->priv->timeout_id = g_timeout_add (20, (GSourceFunc) e_book_view_listener_check_queue, listener);
-
- /* Hold a reference to the listener on behalf of the timeout */
- bonobo_object_ref (BONOBO_OBJECT (listener));
- }
-}
-
-/* Add, Remove, Modify */
-static void
-e_book_view_listener_queue_empty_event (EBookViewListener *listener,
- EBookViewListenerOperation op)
-{
- EBookViewListenerResponse *resp;
-
- if (listener->priv->stopped)
- return;
-
- resp = g_new0 (EBookViewListenerResponse, 1);
-
- resp->op = op;
- resp->id = NULL;
- resp->cards = NULL;
- resp->message = NULL;
-
- e_book_view_listener_queue_response (listener, resp);
-}
-
-/* Add, Remove, Modify */
-static void
-e_book_view_listener_queue_id_event (EBookViewListener *listener,
- EBookViewListenerOperation op,
- const char *id)
-{
- EBookViewListenerResponse *resp;
-
- if (listener->priv->stopped)
- return;
-
- resp = g_new0 (EBookViewListenerResponse, 1);
-
- resp->op = op;
- resp->id = g_strdup (id);
- resp->cards = NULL;
- resp->message = NULL;
-
- e_book_view_listener_queue_response (listener, resp);
-}
-
-/* Add, Remove, Modify */
-static void
-e_book_view_listener_queue_sequence_event (EBookViewListener *listener,
- EBookViewListenerOperation op,
- const GNOME_Evolution_Addressbook_VCardList *cards)
-{
- EBookViewListenerResponse *resp;
- int i;
-
- if (listener->priv->stopped)
- return;
-
- resp = g_new0 (EBookViewListenerResponse, 1);
-
- resp->op = op;
- resp->id = NULL;
- resp->cards = NULL;
- resp->message = NULL;
-
- for ( i = 0; i < cards->_length; i++ ) {
- resp->cards = g_list_append(resp->cards, e_card_new(cards->_buffer[i]));
- }
-
- e_book_view_listener_queue_response (listener, resp);
-}
-
-/* Status Message */
-static void
-e_book_view_listener_queue_message_event (EBookViewListener *listener,
- EBookViewListenerOperation op,
- const char *message)
-{
- EBookViewListenerResponse *resp;
-
- if (listener->priv->stopped)
- return;
-
- resp = g_new0 (EBookViewListenerResponse, 1);
-
- resp->op = op;
- resp->id = NULL;
- resp->cards = NULL;
- resp->message = g_strdup(message);
-
- e_book_view_listener_queue_response (listener, resp);
-}
-
-static void
-impl_BookViewListener_notify_card_added (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_VCardList *cards,
- CORBA_Environment *ev)
-{
- EBookViewListener *listener = E_BOOK_VIEW_LISTENER (bonobo_object_from_servant (servant));
-
- e_book_view_listener_queue_sequence_event (
- listener, CardAddedEvent, cards);
-}
-
-static void
-impl_BookViewListener_notify_card_removed (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_CardId id,
- CORBA_Environment *ev)
-{
- EBookViewListener *listener = E_BOOK_VIEW_LISTENER (bonobo_object_from_servant (servant));
-
- e_book_view_listener_queue_id_event (
- listener, CardRemovedEvent, (const char *) id);
-}
-
-static void
-impl_BookViewListener_notify_card_changed (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_VCardList *cards,
- CORBA_Environment *ev)
-{
- EBookViewListener *listener = E_BOOK_VIEW_LISTENER (bonobo_object_from_servant (servant));
-
- e_book_view_listener_queue_sequence_event (
- listener, CardModifiedEvent, cards);
-}
-
-static void
-impl_BookViewListener_notify_sequence_complete (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- EBookViewListener *listener = E_BOOK_VIEW_LISTENER (bonobo_object_from_servant (servant));
-
- e_book_view_listener_queue_empty_event (listener, SequenceCompleteEvent);
-}
-
-static void
-impl_BookViewListener_notify_status_message (PortableServer_Servant servant,
- const char *message,
- CORBA_Environment *ev)
-{
- EBookViewListener *listener = E_BOOK_VIEW_LISTENER (bonobo_object_from_servant (servant));
-
- e_book_view_listener_queue_message_event (listener, StatusMessageEvent, message);
-}
-
-/**
- * e_book_view_listener_check_pending:
- * @listener: the #EBookViewListener
- *
- * Returns: the number of items on the response queue,
- * or -1 if the @listener is isn't an #EBookViewListener.
- */
-int
-e_book_view_listener_check_pending (EBookViewListener *listener)
-{
- g_return_val_if_fail (listener != NULL, -1);
- g_return_val_if_fail (E_IS_BOOK_VIEW_LISTENER (listener), -1);
-
- return g_list_length (listener->priv->response_queue);
-}
-
-/**
- * e_book_view_listener_pop_response:
- * @listener: the #EBookViewListener for which a request is to be popped
- *
- * Returns: an #EBookViewListenerResponse if there are responses on the
- * queue to be returned; %NULL if there aren't, or if the @listener
- * isn't an EBookViewListener.
- */
-EBookViewListenerResponse *
-e_book_view_listener_pop_response (EBookViewListener *listener)
-{
- EBookViewListenerResponse *resp;
- GList *popped;
-
- g_return_val_if_fail (listener != NULL, NULL);
- g_return_val_if_fail (E_IS_BOOK_VIEW_LISTENER (listener), NULL);
-
- if (listener->priv->response_queue == NULL)
- return NULL;
-
- resp = listener->priv->response_queue->data;
-
- popped = listener->priv->response_queue;
- listener->priv->response_queue =
- g_list_remove_link (listener->priv->response_queue,
- listener->priv->response_queue);
- g_list_free_1 (popped);
-
- return resp;
-}
-
-static EBookViewListener *
-e_book_view_listener_construct (EBookViewListener *listener)
-{
- POA_GNOME_Evolution_Addressbook_BookViewListener *servant;
- CORBA_Environment ev;
- CORBA_Object obj;
-
- g_assert (listener != NULL);
- g_assert (E_IS_BOOK_VIEW_LISTENER (listener));
-
- servant = (POA_GNOME_Evolution_Addressbook_BookViewListener *) g_new0 (BonoboObjectServant, 1);
- servant->vepv = &e_book_view_listener_vepv;
-
- CORBA_exception_init (&ev);
-
- POA_GNOME_Evolution_Addressbook_BookViewListener__init ((PortableServer_Servant) servant, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_free (servant);
- CORBA_exception_free (&ev);
-
- return NULL;
- }
-
- CORBA_exception_free (&ev);
-
- obj = bonobo_object_activate_servant (BONOBO_OBJECT (listener), servant);
- if (obj == CORBA_OBJECT_NIL) {
- g_free (servant);
-
- return NULL;
- }
-
- bonobo_object_construct (BONOBO_OBJECT (listener), obj);
-
- return listener;
-}
-
-/**
- * e_book_view_listener_new:
- * @book: the #EBookView for which the listener is to be bound
- *
- * Creates and returns a new #EBookViewListener for the book.
- *
- * Returns: a new #EBookViewListener
- */
-EBookViewListener *
-e_book_view_listener_new ()
-{
- EBookViewListener *listener;
- EBookViewListener *retval;
-
- listener = gtk_type_new (E_BOOK_VIEW_LISTENER_TYPE);
-
- retval = e_book_view_listener_construct (listener);
-
- if (retval == NULL) {
- g_warning ("e_book_view_listener_new: Error constructing "
- "EBookViewListener!\n");
- bonobo_object_unref (BONOBO_OBJECT (listener));
- return NULL;
- }
-
- return retval;
-}
-
-static void
-e_book_view_listener_init (EBookViewListener *listener)
-{
- listener->priv = g_new0 (EBookViewListenerPrivate, 1);
- listener->priv->response_queue = NULL;
- listener->priv->timeout_id = 0;
- listener->priv->timeout_lock = FALSE;
- listener->priv->stopped = FALSE;
-}
-
-void
-e_book_view_listener_stop (EBookViewListener *listener)
-{
- g_return_if_fail (E_IS_BOOK_VIEW_LISTENER (listener));
- listener->priv->stopped = TRUE;
-}
-
-static void
-e_book_view_listener_destroy (GtkObject *object)
-{
- EBookViewListener *listener = E_BOOK_VIEW_LISTENER (object);
- GList *l;
-
- /* Remove our response queue handler: In theory, this can never happen since we
- always hold a reference to the listener while the timeout is running. */
- if (listener->priv->timeout_id) {
- g_source_remove (listener->priv->timeout_id);
- }
-
- /* Clear out the queue */
- for (l = listener->priv->response_queue; l != NULL; l = l->next) {
- EBookViewListenerResponse *resp = l->data;
-
- g_free(resp->id);
-
- g_list_foreach(resp->cards, (GFunc) gtk_object_unref, NULL);
- g_list_free(resp->cards);
- resp->cards = NULL;
-
- g_free (resp->message);
- resp->message = NULL;
-
- g_free (resp);
- }
- g_list_free (listener->priv->response_queue);
-
- g_free (listener->priv);
- listener->priv = NULL;
-
- GTK_OBJECT_CLASS (e_book_view_listener_parent_class)->destroy (object);
-}
-
-POA_GNOME_Evolution_Addressbook_BookViewListener__epv *
-e_book_view_listener_get_epv (void)
-{
- POA_GNOME_Evolution_Addressbook_BookViewListener__epv *epv;
-
- epv = g_new0 (POA_GNOME_Evolution_Addressbook_BookViewListener__epv, 1);
-
- epv->notifyCardChanged = impl_BookViewListener_notify_card_changed;
- epv->notifyCardRemoved = impl_BookViewListener_notify_card_removed;
- epv->notifyCardAdded = impl_BookViewListener_notify_card_added;
- epv->notifySequenceComplete = impl_BookViewListener_notify_sequence_complete;
- epv->notifyStatusMessage = impl_BookViewListener_notify_status_message;
-
- return epv;
-}
-
-static void
-e_book_view_listener_corba_class_init (void)
-{
- e_book_view_listener_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv ();
- e_book_view_listener_vepv.GNOME_Evolution_Addressbook_BookViewListener_epv = e_book_view_listener_get_epv ();
-}
-
-static void
-e_book_view_listener_class_init (EBookViewListenerClass *klass)
-{
- GtkObjectClass *object_class = (GtkObjectClass *) klass;
-
- e_book_view_listener_parent_class = gtk_type_class (bonobo_object_get_type ());
-
- e_book_view_listener_signals [RESPONSES_QUEUED] =
- gtk_signal_new ("responses_queued",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EBookViewListenerClass, responses_queued),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- gtk_object_class_add_signals (object_class, e_book_view_listener_signals, LAST_SIGNAL);
-
- object_class->destroy = e_book_view_listener_destroy;
-
- e_book_view_listener_corba_class_init ();
-}
-
-/**
- * e_book_view_listener_get_type:
- */
-GtkType
-e_book_view_listener_get_type (void)
-{
- static GtkType type = 0;
-
- if (! type) {
- GtkTypeInfo info = {
- "EBookViewListener",
- sizeof (EBookViewListener),
- sizeof (EBookViewListenerClass),
- (GtkClassInitFunc) e_book_view_listener_class_init,
- (GtkObjectInitFunc) e_book_view_listener_init,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- type = gtk_type_unique (bonobo_object_get_type (), &info);
- }
-
- return type;
-}
diff --git a/addressbook/backend/ebook/e-book-view-listener.h b/addressbook/backend/ebook/e-book-view-listener.h
deleted file mode 100644
index d373872ad0..0000000000
--- a/addressbook/backend/ebook/e-book-view-listener.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * A client-side GtkObject which exposes the
- * Evolution:BookViewListener interface.
- *
- * Author:
- * Nat Friedman (nat@ximian.com)
- *
- * Copyright 2000, Ximian, Inc.
- */
-
-#ifndef __E_BOOK_VIEW_LISTENER_H__
-#define __E_BOOK_VIEW_LISTENER_H__
-
-#include <libgnome/gnome-defs.h>
-#include <bonobo/bonobo-object.h>
-#include <addressbook/backend/ebook/addressbook.h>
-
-BEGIN_GNOME_DECLS
-
-typedef struct _EBookViewListener EBookViewListener;
-typedef struct _EBookViewListenerClass EBookViewListenerClass;
-typedef struct _EBookViewListenerPrivate EBookViewListenerPrivate;
-
-struct _EBookViewListener {
- BonoboObject parent;
- EBookViewListenerPrivate *priv;
-};
-
-struct _EBookViewListenerClass {
- BonoboObjectClass parent;
-
- /*
- * Signals
- */
- void (*responses_queued) (void);
-};
-
-typedef enum {
- /* Async events */
- CardAddedEvent,
- CardRemovedEvent,
- CardModifiedEvent,
- SequenceCompleteEvent,
- StatusMessageEvent,
-} EBookViewListenerOperation;
-
-typedef struct {
- EBookViewListenerOperation op;
-
- /* For CardRemovedEvent */
- char *id;
-
- /* For Card[Added|Modified]Event */
- GList *cards; /* Of type ECard. */
-
- /* For StatusMessageEvent */
- char *message;
-
-} EBookViewListenerResponse;
-
-EBookViewListener *e_book_view_listener_new (void);
-int e_book_view_listener_check_pending (EBookViewListener *listener);
-EBookViewListenerResponse *e_book_view_listener_pop_response (EBookViewListener *listener);
-GtkType e_book_view_listener_get_type (void);
-void e_book_view_listener_stop (EBookViewListener *listener);
-
-POA_GNOME_Evolution_Addressbook_BookViewListener__epv *e_book_view_listener_get_epv (void);
-
-#define E_BOOK_VIEW_LISTENER_TYPE (e_book_view_listener_get_type ())
-#define E_BOOK_VIEW_LISTENER(o) (GTK_CHECK_CAST ((o), E_BOOK_VIEW_LISTENER_TYPE, EBookViewListener))
-#define E_BOOK_VIEW_LISTENER_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_BOOK_VIEW_LISTENER_TYPE, EBookViewListenerClass))
-#define E_IS_BOOK_VIEW_LISTENER(o) (GTK_CHECK_TYPE ((o), E_BOOK_VIEW_LISTENER_TYPE))
-#define E_IS_BOOK_VIEW_LISTENER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_BOOK_VIEW_LISTENER_TYPE))
-
-END_GNOME_DECLS
-
-#endif /* ! __E_BOOK_VIEW_LISTENER_H__ */
diff --git a/addressbook/backend/ebook/e-book-view.c b/addressbook/backend/ebook/e-book-view.c
deleted file mode 100644
index 1af893bcd6..0000000000
--- a/addressbook/backend/ebook/e-book-view.c
+++ /dev/null
@@ -1,351 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * The Evolution addressbook client object.
- *
- * Author:
- * Nat Friedman (nat@ximian.com)
- *
- * Copyright 1999, 2000, Ximian, Inc.
- */
-
-#include <config.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtkmarshal.h>
-
-#include "addressbook.h"
-#include "e-card-cursor.h"
-#include "e-book-view-listener.h"
-#include "e-book-view.h"
-#include "e-book.h"
-
-GtkObjectClass *e_book_view_parent_class;
-
-struct _EBookViewPrivate {
- GNOME_Evolution_Addressbook_BookView corba_book_view;
-
- EBook *book;
-
- EBookViewListener *listener;
-
- int responses_queued_id;
-};
-
-enum {
- CARD_CHANGED,
- CARD_REMOVED,
- CARD_ADDED,
- SEQUENCE_COMPLETE,
- STATUS_MESSAGE,
- LAST_SIGNAL
-};
-
-static guint e_book_view_signals [LAST_SIGNAL];
-
-static void
-add_book_iterator (gpointer data, gpointer closure)
-{
- ECard *card = E_CARD (data);
- EBook *book = E_BOOK (closure);
-
- e_card_set_book (card, book);
-}
-
-static void
-e_book_view_do_added_event (EBookView *book_view,
- EBookViewListenerResponse *resp)
-{
- if (book_view->priv->book)
- g_list_foreach (resp->cards, add_book_iterator, book_view->priv->book);
-
- gtk_signal_emit (GTK_OBJECT (book_view), e_book_view_signals [CARD_ADDED],
- resp->cards);
-
- g_list_foreach (resp->cards, (GFunc) gtk_object_unref, NULL);
- g_list_free (resp->cards);
-}
-
-static void
-e_book_view_do_modified_event (EBookView *book_view,
- EBookViewListenerResponse *resp)
-{
- if (book_view->priv->book)
- g_list_foreach (resp->cards, add_book_iterator, book_view->priv->book);
-
- gtk_signal_emit (GTK_OBJECT (book_view), e_book_view_signals [CARD_CHANGED],
- resp->cards);
-
- g_list_foreach (resp->cards, (GFunc) gtk_object_unref, NULL);
- g_list_free (resp->cards);
-}
-
-static void
-e_book_view_do_removed_event (EBookView *book_view,
- EBookViewListenerResponse *resp)
-{
- gtk_signal_emit (GTK_OBJECT (book_view), e_book_view_signals [CARD_REMOVED],
- resp->id);
-
- g_free(resp->id);
-}
-
-static void
-e_book_view_do_complete_event (EBookView *book_view,
- EBookViewListenerResponse *resp)
-{
- gtk_signal_emit (GTK_OBJECT (book_view), e_book_view_signals [SEQUENCE_COMPLETE]);
-}
-
-static void
-e_book_view_do_status_message_event (EBookView *book_view,
- EBookViewListenerResponse *resp)
-{
- gtk_signal_emit (GTK_OBJECT (book_view), e_book_view_signals [STATUS_MESSAGE],
- resp->message);
- g_free(resp->message);
-}
-
-
-/*
- * Reading notices out of the EBookViewListener's queue.
- */
-static void
-e_book_view_check_listener_queue (EBookViewListener *listener, EBookView *book_view)
-{
- EBookViewListenerResponse *resp;
-
- resp = e_book_view_listener_pop_response (listener);
-
- if (resp == NULL)
- return;
-
- switch (resp->op) {
- case CardAddedEvent:
- e_book_view_do_added_event (book_view, resp);
- break;
- case CardModifiedEvent:
- e_book_view_do_modified_event (book_view, resp);
- break;
- case CardRemovedEvent:
- e_book_view_do_removed_event (book_view, resp);
- break;
- case SequenceCompleteEvent:
- e_book_view_do_complete_event (book_view, resp);
- break;
- case StatusMessageEvent:
- e_book_view_do_status_message_event (book_view, resp);
- break;
- default:
- g_error ("EBookView: Unknown operation %d in listener queue!\n",
- resp->op);
- break;
- }
-
- g_free (resp);
-}
-
-static gboolean
-e_book_view_construct (EBookView *book_view, GNOME_Evolution_Addressbook_BookView corba_book_view, EBookViewListener *listener)
-{
- CORBA_Environment ev;
- g_return_val_if_fail (book_view != NULL, FALSE);
- g_return_val_if_fail (E_IS_BOOK_VIEW (book_view), FALSE);
-
- /*
- * Copy in the corba_book_view.
- */
- CORBA_exception_init (&ev);
-
- book_view->priv->corba_book_view = bonobo_object_dup_ref(corba_book_view, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_view_construct: Exception duplicating corba_book_view.\n");
- CORBA_exception_free (&ev);
- book_view->priv->corba_book_view = NULL;
- return FALSE;
- }
-
- CORBA_exception_free (&ev);
-
- /*
- * Create our local BookListener interface.
- */
- book_view->priv->listener = listener;
- book_view->priv->responses_queued_id = gtk_signal_connect (GTK_OBJECT (book_view->priv->listener), "responses_queued",
- e_book_view_check_listener_queue, book_view);
-
- bonobo_object_ref(BONOBO_OBJECT(book_view->priv->listener));
-
- return TRUE;
-}
-
-/**
- * e_book_view_new:
- */
-EBookView *
-e_book_view_new (GNOME_Evolution_Addressbook_BookView corba_book_view, EBookViewListener *listener)
-{
- EBookView *book_view;
-
- book_view = gtk_type_new (E_BOOK_VIEW_TYPE);
-
- if (! e_book_view_construct (book_view, corba_book_view, listener)) {
- gtk_object_unref (GTK_OBJECT (book_view));
- return NULL;
- }
-
- return book_view;
-}
-
-void
-e_book_view_set_book (EBookView *book_view, EBook *book)
-{
- g_return_if_fail (book_view && E_IS_BOOK_VIEW (book_view));
- g_return_if_fail (book && E_IS_BOOK (book));
- g_return_if_fail (book_view->priv->book == NULL);
-
- book_view->priv->book = book;
- gtk_object_ref (GTK_OBJECT (book));
-}
-
-void
-e_book_view_stop (EBookView *book_view)
-{
- g_return_if_fail (book_view && E_IS_BOOK_VIEW (book_view));
- if (book_view->priv->listener)
- e_book_view_listener_stop (book_view->priv->listener);
-}
-
-static void
-e_book_view_init (EBookView *book_view)
-{
- book_view->priv = g_new0 (EBookViewPrivate, 1);
- book_view->priv->book = NULL;
- book_view->priv->corba_book_view = CORBA_OBJECT_NIL;
- book_view->priv->listener = NULL;
- book_view->priv->responses_queued_id = 0;
-}
-
-static void
-e_book_view_destroy (GtkObject *object)
-{
- EBookView *book_view = E_BOOK_VIEW (object);
- CORBA_Environment ev;
-
- if (book_view->priv->book) {
- gtk_object_unref (GTK_OBJECT (book_view->priv->book));
- }
-
- if (book_view->priv->corba_book_view) {
- CORBA_exception_init (&ev);
-
- bonobo_object_release_unref (book_view->priv->corba_book_view, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("EBookView: Exception while releasing BookView\n");
- }
-
- CORBA_exception_free (&ev);
- }
-
- if (book_view->priv->listener) {
- if (book_view->priv->responses_queued_id)
- gtk_signal_disconnect(GTK_OBJECT(book_view->priv->listener),
- book_view->priv->responses_queued_id);
- e_book_view_listener_stop (book_view->priv->listener);
- bonobo_object_unref (BONOBO_OBJECT(book_view->priv->listener));
- }
-
- g_free (book_view->priv);
-
- if (GTK_OBJECT_CLASS (e_book_view_parent_class)->destroy)
- GTK_OBJECT_CLASS (e_book_view_parent_class)->destroy (object);
-}
-
-static void
-e_book_view_class_init (EBookViewClass *klass)
-{
- GtkObjectClass *object_class = (GtkObjectClass *) klass;
-
- e_book_view_parent_class = gtk_type_class (gtk_object_get_type ());
-
- e_book_view_signals [CARD_CHANGED] =
- gtk_signal_new ("card_changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EBookViewClass, card_changed),
- gtk_marshal_NONE__POINTER,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_POINTER);
-
- e_book_view_signals [CARD_ADDED] =
- gtk_signal_new ("card_added",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EBookViewClass, card_added),
- gtk_marshal_NONE__STRING,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_STRING);
-
- e_book_view_signals [CARD_REMOVED] =
- gtk_signal_new ("card_removed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EBookViewClass, card_removed),
- gtk_marshal_NONE__POINTER,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_POINTER);
-
- e_book_view_signals [SEQUENCE_COMPLETE] =
- gtk_signal_new ("sequence_complete",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EBookViewClass, sequence_complete),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- e_book_view_signals [STATUS_MESSAGE] =
- gtk_signal_new ("status_message",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EBookViewClass, status_message),
- gtk_marshal_NONE__STRING,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_STRING);
-
- gtk_object_class_add_signals (object_class, e_book_view_signals,
- LAST_SIGNAL);
-
- klass->card_changed = NULL;
- klass->card_added = NULL;
- klass->card_removed = NULL;
- klass->sequence_complete = NULL;
- klass->status_message = NULL;
-
- object_class->destroy = e_book_view_destroy;
-}
-
-/**
- * e_book_view_get_type:
- */
-GtkType
-e_book_view_get_type (void)
-{
- static GtkType type = 0;
-
- if (! type) {
- GtkTypeInfo info = {
- "EBookView",
- sizeof (EBookView),
- sizeof (EBookViewClass),
- (GtkClassInitFunc) e_book_view_class_init,
- (GtkObjectInitFunc) e_book_view_init,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- type = gtk_type_unique (gtk_object_get_type (), &info);
- }
-
- return type;
-}
diff --git a/addressbook/backend/ebook/e-book-view.h b/addressbook/backend/ebook/e-book-view.h
deleted file mode 100644
index 86326ca5b7..0000000000
--- a/addressbook/backend/ebook/e-book-view.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * The Evolution addressbook client object.
- *
- * Author:
- * Nat Friedman (nat@ximian.com)
- *
- * Copyright 1999, 2000, Ximian, Inc.
- */
-
-#ifndef __E_BOOK_VIEW_H__
-#define __E_BOOK_VIEW_H__
-
-#include <libgnome/gnome-defs.h>
-
-#include <addressbook/backend/ebook/e-card.h>
-#include <addressbook/backend/ebook/e-book-view-listener.h>
-
-BEGIN_GNOME_DECLS
-
-typedef struct _EBookView EBookView;
-typedef struct _EBookViewClass EBookViewClass;
-typedef struct _EBookViewPrivate EBookViewPrivate;
-
-struct _EBook; /* Forward reference */
-
-struct _EBookView {
- GtkObject parent;
- EBookViewPrivate *priv;
-};
-
-struct _EBookViewClass {
- GtkObjectClass parent;
-
- /*
- * Signals.
- */
- void (* card_changed) (EBookView *book_view, const GList *cards);
- void (* card_removed) (EBookView *book_view, const char *id);
- void (* card_added) (EBookView *book_view, const GList *cards);
- void (* sequence_complete) (EBookView *book_view);
- void (* status_message) (EBookView *book_view, const char *message);
-};
-
-/* Creating a new addressbook. */
-EBookView *e_book_view_new (GNOME_Evolution_Addressbook_BookView corba_book_view, EBookViewListener *listener);
-
-GtkType e_book_view_get_type (void);
-
-void e_book_view_set_book (EBookView *book_view, struct _EBook *book);
-
-void e_book_view_stop (EBookView *book_view);
-
-#define E_BOOK_VIEW_TYPE (e_book_view_get_type ())
-#define E_BOOK_VIEW(o) (GTK_CHECK_CAST ((o), E_BOOK_VIEW_TYPE, EBookView))
-#define E_BOOK_VIEW_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_BOOK_VIEW_TYPE, EBookViewClass))
-#define E_IS_BOOK_VIEW(o) (GTK_CHECK_TYPE ((o), E_BOOK_VIEW_TYPE))
-#define E_IS_BOOK_VIEW_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_BOOK_VIEW_TYPE))
-
-END_GNOME_DECLS
-
-#endif /* ! __E_BOOK_VIEW_H__ */
diff --git a/addressbook/backend/ebook/e-book.c b/addressbook/backend/ebook/e-book.c
deleted file mode 100644
index 28308a7016..0000000000
--- a/addressbook/backend/ebook/e-book.c
+++ /dev/null
@@ -1,1500 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * The Evolution addressbook client object.
- *
- * Author:
- * Nat Friedman (nat@ximian.com)
- *
- * Copyright 1999, 2000, Ximian, Inc.
- */
-
-#include <config.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtkmarshal.h>
-#include <libgnome/gnome-defs.h>
-#include <liboaf/liboaf.h>
-
-#include "addressbook.h"
-#include "e-card-cursor.h"
-#include "e-book-listener.h"
-#include "e-book.h"
-
-GtkObjectClass *e_book_parent_class;
-
-#define CARDSERVER_OAF_ID "OAFIID:GNOME_Evolution_Wombat_ServerFactory"
-
-typedef enum {
- URINotLoaded,
- URILoading,
- URILoaded
-} EBookLoadState;
-
-struct _EBookPrivate {
- GList *book_factories;
- GList *iter;
-
- EBookListener *listener;
-
- GNOME_Evolution_Addressbook_Book corba_book;
-
- EBookLoadState load_state;
-
- /*
- * The operation queue. New operations are appended to the
- * end of the queue. When responses come back from the PAS,
- * the op structures are popped off the front of the queue.
- */
- GList *pending_ops;
-
- guint op_tag;
-
- gchar *uri;
-};
-
-enum {
- OPEN_PROGRESS,
- WRITABLE_STATUS,
- LINK_STATUS,
- LAST_SIGNAL
-};
-
-static guint e_book_signals [LAST_SIGNAL];
-
-typedef struct {
- guint tag;
- gboolean active;
- gpointer cb;
- gpointer closure;
- EBookViewListener *listener;
-} EBookOp;
-
-/*
- * Local response queue management.
- */
-
-static void
-e_book_op_free (EBookOp *op)
-{
- if (op->listener) {
- bonobo_object_unref (BONOBO_OBJECT (op->listener));
- op->listener = NULL;
- }
- g_free (op);
-}
-
-static guint
-e_book_queue_op (EBook *book,
- gpointer cb,
- gpointer closure,
- EBookViewListener *listener)
-{
- EBookOp *op;
-
- op = g_new0 (EBookOp, 1);
- op->tag = book->priv->op_tag++;
- op->active = TRUE;
- op->cb = cb;
- op->closure = closure;
- op->listener = listener;
-
- if (op->listener)
- bonobo_object_ref (BONOBO_OBJECT (op->listener));
-
- book->priv->pending_ops =
- g_list_append (book->priv->pending_ops, op);
-
- return op->tag;
-}
-
-/*
- * Local response queue management.
- */
-static void
-e_book_unqueue_op (EBook *book)
-{
- EBookOp *op;
- GList *removed;
-
- removed = g_list_last (book->priv->pending_ops);
-
- if (removed) {
- book->priv->pending_ops = g_list_remove_link (book->priv->pending_ops,
- removed);
- op = removed->data;
- e_book_op_free (op);
- g_list_free_1 (removed);
- book->priv->op_tag--;
- }
-}
-
-static EBookOp *
-e_book_pop_op (EBook *book)
-{
- GList *popped;
- EBookOp *op;
-
- if (book->priv->pending_ops == NULL)
- return NULL;
-
- op = book->priv->pending_ops->data;
-
- popped = book->priv->pending_ops;
- book->priv->pending_ops =
- g_list_remove_link (book->priv->pending_ops,
- book->priv->pending_ops);
-
- g_list_free_1 (popped);
-
- return op;
-}
-
-static gboolean
-e_book_cancel_op (EBook *book, guint tag)
-{
- GList *iter;
- gboolean cancelled = FALSE;
-
- for (iter = book->priv->pending_ops; iter != NULL && !cancelled; iter = g_list_next (iter)) {
- EBookOp *op = iter->data;
- if (op->tag == tag) {
- op->active = FALSE;
- cancelled = TRUE;
- }
- }
-
- return cancelled;
-}
-
-static void
-e_book_do_response_create_card (EBook *book,
- EBookListenerResponse *resp)
-{
- EBookOp *op;
-
- op = e_book_pop_op (book);
-
- if (op == NULL) {
- g_warning ("e_book_do_response_create_card: Cannot find operation "
- "in local op queue!\n");
- return;
- }
-
- if (op->cb)
- ((EBookIdCallback) op->cb) (book, resp->status, resp->id, op->closure);
- g_free (resp->id);
- e_book_op_free (op);
-}
-
-static void
-e_book_do_response_generic (EBook *book,
- EBookListenerResponse *resp)
-{
- EBookOp *op;
-
- op = e_book_pop_op (book);
-
- if (op == NULL) {
- g_warning ("e_book_do_response_generic: Cannot find operation "
- "in local op queue!\n");
- }
-
- if (op->cb)
- ((EBookCallback) op->cb) (book, resp->status, op->closure);
-
- e_book_op_free (op);
-}
-
-static void
-e_book_do_response_get_vcard (EBook *book,
- EBookListenerResponse *resp)
-{
- EBookOp *op;
- ECard *card;
-
- op = e_book_pop_op (book);
-
- if (op == NULL) {
- g_warning ("e_book_do_response_get_vcard: Cannot find operation "
- "in local op queue!\n");
- return;
- }
- if (resp->vcard != NULL) {
-
- card = e_card_new(resp->vcard);
-
- if (card != NULL) {
- e_card_set_book (card, book);
- if (op->cb) {
- if (op->active)
- ((EBookCardCallback) op->cb) (book, resp->status, card, op->closure);
- else
- ((EBookCardCallback) op->cb) (book, E_BOOK_STATUS_CANCELLED, NULL, op->closure);
- }
-
- gtk_object_unref(GTK_OBJECT(card));
- } else {
- ((EBookCursorCallback) op->cb) (book, resp->status, NULL, op->closure);
- }
- } else {
- ((EBookCardCallback) op->cb) (book, resp->status, NULL, op->closure);
- }
-
- g_free (resp->vcard);
- e_book_op_free (op);
-}
-
-static void
-e_book_do_response_get_cursor (EBook *book,
- EBookListenerResponse *resp)
-{
- CORBA_Environment ev;
- EBookOp *op;
- ECardCursor *cursor;
-
- op = e_book_pop_op (book);
-
- if (op == NULL) {
- g_warning ("e_book_do_response_get_cursor: Cannot find operation "
- "in local op queue!\n");
- return;
- }
-
- cursor = e_card_cursor_new(resp->cursor);
-
- if (cursor != NULL) {
- if (op->cb) {
- if (op->active)
- ((EBookCursorCallback) op->cb) (book, resp->status, cursor, op->closure);
- else
- ((EBookCursorCallback) op->cb) (book, E_BOOK_STATUS_CANCELLED, NULL, op->closure);
- }
-
- /*
- * Release the remote GNOME_Evolution_Addressbook_Book in the PAS.
- */
- CORBA_exception_init (&ev);
-
- bonobo_object_release_unref (resp->cursor, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_do_response_get_cursor: Exception releasing "
- "remote GNOME_Evolution_Addressbook_CardCursor interface!\n");
- }
-
- CORBA_exception_free (&ev);
-
- gtk_object_unref(GTK_OBJECT(cursor));
- } else {
- ((EBookCursorCallback) op->cb) (book, E_BOOK_STATUS_CANCELLED, NULL, op->closure);
- }
-
- e_book_op_free (op);
-}
-
-static void
-e_book_do_response_get_view (EBook *book,
- EBookListenerResponse *resp)
-{
- CORBA_Environment ev;
- EBookOp *op;
- EBookView *book_view;
-
- op = e_book_pop_op (book);
-
- if (op == NULL) {
- g_warning ("e_book_do_response_get_view: Cannot find operation "
- "in local op queue!\n");
- return;
- }
-
- book_view = e_book_view_new (resp->book_view, op->listener);
-
- if (book_view != NULL) {
- e_book_view_set_book (book_view, book);
-
- /* Only execute the callback if the operation is still flagged as active (i.e. hasn't
- been cancelled. This is mildly wasteful since we unnecessaryily create the
- book_view, etc... but I'm leery of tinkering with the CORBA magic. */
- if (op->cb) {
- if (op->active)
- ((EBookBookViewCallback) op->cb) (book, resp->status, book_view, op->closure);
- else
- ((EBookBookViewCallback) op->cb) (book, E_BOOK_STATUS_CANCELLED, NULL, op->closure);
- }
-
- /*
- * Release the remote GNOME_Evolution_Addressbook_Book in the PAS.
- */
- CORBA_exception_init (&ev);
-
- bonobo_object_release_unref (resp->book_view, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_do_response_get_view: Exception releasing "
- "remote GNOME_Evolution_Addressbook_BookView interface!\n");
- }
-
- CORBA_exception_free (&ev);
-
- gtk_object_unref(GTK_OBJECT(book_view));
- } else {
- e_book_view_listener_stop (op->listener);
- ((EBookBookViewCallback) op->cb) (book, E_BOOK_STATUS_CANCELLED, NULL, op->closure);
- }
-
- e_book_op_free (op);
-}
-
-static void
-e_book_do_response_get_changes (EBook *book,
- EBookListenerResponse *resp)
-{
- CORBA_Environment ev;
- EBookOp *op;
- EBookView *book_view;
-
- op = e_book_pop_op (book);
-
- if (op == NULL) {
- g_warning ("e_book_do_response_get_changes: Cannot find operation "
- "in local op queue!\n");
- return;
- }
-
- book_view = e_book_view_new (resp->book_view, op->listener);
-
- if (book_view != NULL) {
- e_book_view_set_book (book_view, book);
-
- if (op->cb) {
- if (op->active)
- ((EBookBookViewCallback) op->cb) (book, resp->status, book_view, op->closure);
- else
- ((EBookBookViewCallback) op->cb) (book, E_BOOK_STATUS_CANCELLED, NULL, op->closure);
- }
-
- /*
- * Release the remote GNOME_Evolution_Addressbook_BookView in the PAS.
- */
- CORBA_exception_init (&ev);
-
- bonobo_object_release_unref (resp->book_view, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_do_response_get_changes: Exception releasing "
- "remote GNOME_Evolution_Addressbook_BookView interface!\n");
- }
-
- CORBA_exception_free (&ev);
-
- gtk_object_unref(GTK_OBJECT(book_view));
- } else {
- e_book_view_listener_stop (op->listener);
- ((EBookBookViewCallback) op->cb) (book, E_BOOK_STATUS_CANCELLED, NULL, op->closure);
- }
-
- e_book_op_free (op);
-}
-
-static void
-e_book_do_response_open (EBook *book,
- EBookListenerResponse *resp)
-{
- EBookOp *op;
-
- if (resp->status == E_BOOK_STATUS_SUCCESS) {
- book->priv->corba_book = resp->book;
- book->priv->load_state = URILoaded;
- }
-
- op = e_book_pop_op (book);
-
- if (op == NULL) {
- g_warning ("e_book_do_response_open: Cannot find operation "
- "in local op queue!\n");
- return;
- }
-
- if (op->cb)
- ((EBookCallback) op->cb) (book, resp->status, op->closure);
- e_book_op_free (op);
-}
-
-static void
-e_book_do_progress_event (EBook *book,
- EBookListenerResponse *resp)
-{
- gtk_signal_emit (GTK_OBJECT (book), e_book_signals [OPEN_PROGRESS],
- resp->msg, resp->percent);
-
- g_free (resp->msg);
-}
-
-static void
-e_book_do_link_event (EBook *book,
- EBookListenerResponse *resp)
-{
- gtk_signal_emit (GTK_OBJECT (book), e_book_signals [LINK_STATUS],
- resp->connected);
-}
-
-static void
-e_book_do_writable_event (EBook *book,
- EBookListenerResponse *resp)
-{
- gtk_signal_emit (GTK_OBJECT (book), e_book_signals [WRITABLE_STATUS],
- resp->writable);
-}
-
-static void
-e_book_do_response_get_supported_fields (EBook *book,
- EBookListenerResponse *resp)
-{
- EBookOp *op;
-
- op = e_book_pop_op (book);
-
- if (op == NULL) {
- g_warning ("e_book_do_response_get_supported_fields: Cannot find operation "
- "in local op queue!\n");
- return;
- }
-
- if (op->cb) {
- if (op->active)
- ((EBookFieldsCallback) op->cb) (book, resp->status, resp->fields, op->closure);
- else
- ((EBookFieldsCallback) op->cb) (book, E_BOOK_STATUS_CANCELLED, NULL, op->closure);
- }
-
- e_book_op_free (op);
-}
-
-/*
- * Reading notices out of the EBookListener's queue.
- */
-static void
-e_book_check_listener_queue (EBookListener *listener, EBook *book)
-{
- EBookListenerResponse *resp;
-
- resp = e_book_listener_pop_response (listener);
-
- if (resp == NULL)
- return;
-
- switch (resp->op) {
- case CreateCardResponse:
- e_book_do_response_create_card (book, resp);
- break;
- case RemoveCardResponse:
- case ModifyCardResponse:
- case AuthenticationResponse:
- e_book_do_response_generic (book, resp);
- break;
- case GetCardResponse:
- e_book_do_response_get_vcard (book, resp);
- break;
- case GetCursorResponse:
- e_book_do_response_get_cursor (book, resp);
- break;
- case GetBookViewResponse:
- e_book_do_response_get_view(book, resp);
- break;
- case GetChangesResponse:
- e_book_do_response_get_changes(book, resp);
- break;
- case OpenBookResponse:
- e_book_do_response_open (book, resp);
- break;
- case GetSupportedFieldsResponse:
- e_book_do_response_get_supported_fields (book, resp);
- break;
-
- case OpenProgressEvent:
- e_book_do_progress_event (book, resp);
- break;
- case LinkStatusEvent:
- e_book_do_link_event (book, resp);
- break;
- case WritableStatusEvent:
- e_book_do_writable_event (book, resp);
- break;
- default:
- g_error ("EBook: Unknown operation %d in listener queue!\n",
- resp->op);
- }
-
- g_free (resp);
-}
-
-/**
- * e_book_load_uri:
- */
-
-typedef struct {
- char *uri;
- EBookCallback open_response;
- gpointer closure;
-} EBookLoadURIData;
-
-static void e_book_load_uri_from_factory (EBook *book,
- GNOME_Evolution_Addressbook_BookFactory factory,
- EBookLoadURIData *load_uri_data);
-
-static void
-e_book_load_uri_step (EBook *book, EBookStatus status, EBookLoadURIData *data)
-{
- /* iterate to the next possible CardFactory, or fail
- if it's the last one */
- book->priv->iter = book->priv->iter->next;
- if (book->priv->iter) {
- GNOME_Evolution_Addressbook_BookFactory factory = book->priv->iter->data;
- e_book_load_uri_from_factory (book, factory, data);
- }
- else {
- EBookCallback cb = data->open_response;
- gpointer closure = data->closure;
-
- /* reset the load_state to NotLoaded so people can
- attempt another load_uri on the book. */
- book->priv->load_state = URINotLoaded;
-
- g_free (data);
-
- cb (book, status, closure);
- }
-}
-
-static void
-e_book_load_uri_open_cb (EBook *book, EBookStatus status, EBookLoadURIData *data)
-{
- if (status == E_BOOK_STATUS_SUCCESS) {
- EBookCallback cb = data->open_response;
- gpointer closure = data->closure;
-
- g_free (data);
-
- cb (book, status, closure);
- }
- else {
- e_book_load_uri_step (book, status, data);
- }
-}
-
-static void
-e_book_load_uri_from_factory (EBook *book,
- GNOME_Evolution_Addressbook_BookFactory factory,
- EBookLoadURIData *load_uri_data)
-{
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- e_book_queue_op (book, e_book_load_uri_open_cb, load_uri_data, NULL);
-
- GNOME_Evolution_Addressbook_BookFactory_openBook (
- factory, book->priv->uri,
- bonobo_object_corba_objref (BONOBO_OBJECT (book->priv->listener)),
- &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_load_uri: CORBA exception while opening addressbook!\n");
- e_book_unqueue_op (book);
- CORBA_exception_free (&ev);
- e_book_load_uri_step (book, E_BOOK_STATUS_OTHER_ERROR, load_uri_data);
- }
-
- CORBA_exception_free (&ev);
-
-}
-
-static gboolean
-activate_factories_for_uri (EBook *book, const char *uri)
-{
- CORBA_Environment ev;
- OAF_ServerInfoList *info_list = NULL;
- int i;
- char *protocol, *query, *colon;
- gboolean retval = FALSE;
-
- colon = strchr (uri, ':');
- if (!colon) {
- g_warning ("e_book_load_uri: Unable to determine protocol in the URI\n");
- return FALSE;
- }
-
- protocol = g_strndup (uri, colon-uri);
- query = g_strdup_printf ("repo_ids.has ('IDL:GNOME/Evolution/BookFactory:1.0')"
- " AND addressbook:supported_protocols.has ('%s')", protocol
- );
-
- CORBA_exception_init (&ev);
-
- info_list = oaf_query (query, NULL, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Eeek! Cannot perform OAF query for book factories.");
- CORBA_exception_free (&ev);
- goto shutdown;
- }
-
- if (info_list->_length == 0) {
- g_warning ("Can't find installed BookFactory that handles protocol '%s'.", protocol);
- g_free (protocol);
- g_free (query);
- CORBA_exception_free (&ev);
- goto shutdown;
- }
-
- CORBA_exception_free (&ev);
-
- for (i = 0; i < info_list->_length; i ++) {
- const OAF_ServerInfo *info;
- GNOME_Evolution_Addressbook_BookFactory factory;
-
- info = info_list->_buffer + i;
-
- factory = oaf_activate_from_id (info->iid, 0, NULL, NULL);
-
- if (factory == CORBA_OBJECT_NIL)
- g_warning ("e_book_construct: Could not obtain a handle "
- "to the Personal Addressbook Server with IID `%s'\n", info->iid);
- else
- book->priv->book_factories = g_list_append (book->priv->book_factories,
- factory);
- }
-
- if (!book->priv->book_factories) {
- g_warning ("Couldn't activate any book factories.");
- goto shutdown;
- }
-
- retval = TRUE;
-
- shutdown:
- if (info_list)
- CORBA_free (info_list);
- g_free (query);
- g_free (protocol);
-
- return retval;
-}
-
-gboolean
-e_book_load_uri (EBook *book,
- const char *uri,
- EBookCallback open_response,
- gpointer closure)
-{
- EBookLoadURIData *load_uri_data;
- GNOME_Evolution_Addressbook_BookFactory factory;
-
- g_return_val_if_fail (book != NULL, FALSE);
- g_return_val_if_fail (E_IS_BOOK (book), FALSE);
- g_return_val_if_fail (uri != NULL, FALSE);
- g_return_val_if_fail (open_response != NULL, FALSE);
-
- if (book->priv->load_state != URINotLoaded) {
- g_warning ("e_book_load_uri: Attempted to load a URI "
- "on a book which already has a URI loaded!\n");
- return FALSE;
- }
-
- /* try to find a list of factories that can handle the protocol */
- if (!activate_factories_for_uri (book, uri)) {
- open_response (NULL, E_BOOK_STATUS_PROTOCOL_NOT_SUPPORTED, closure);
- return FALSE;
- }
-
- g_free (book->priv->uri);
- book->priv->uri = g_strdup (uri);
-
- /*
- * Create our local BookListener interface.
- */
- book->priv->listener = e_book_listener_new ();
- if (book->priv->listener == NULL) {
- g_warning ("e_book_load_uri: Could not create EBookListener!\n");
- return FALSE;
- }
-
- gtk_signal_connect (GTK_OBJECT (book->priv->listener), "responses_queued",
- e_book_check_listener_queue, book);
-
- load_uri_data = g_new (EBookLoadURIData, 1);
- load_uri_data->open_response = open_response;
- load_uri_data->closure = closure;
-
- /* initialize the iterator, and load from the first one*/
- book->priv->iter = book->priv->book_factories;
-
- factory = book->priv->iter->data;
-
- e_book_load_uri_from_factory (book, factory, load_uri_data);
-
- book->priv->load_state = URILoading;
-
- /* Now we play the waiting game. */
-
- return TRUE;
-}
-
-/**
- * e_book_unload_uri:
- */
-void
-e_book_unload_uri (EBook *book)
-{
- CORBA_Environment ev;
-
- g_return_if_fail (book != NULL);
- g_return_if_fail (E_IS_BOOK (book));
-
- /*
- * FIXME: Make sure this works if the URI is still being
- * loaded.
- */
- if (book->priv->load_state != URILoaded) {
- g_warning ("e_book_unload_uri: No URI is loaded!\n");
- return;
- }
-
- /*
- * Release the remote GNOME_Evolution_Addressbook_Book in the PAS.
- */
- CORBA_exception_init (&ev);
-
- bonobo_object_release_unref (book->priv->corba_book, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_unload_uri: Exception releasing "
- "remote book interface!\n");
- }
-
- CORBA_exception_free (&ev);
-
- e_book_listener_stop (book->priv->listener);
- bonobo_object_unref (BONOBO_OBJECT (book->priv->listener));
-
- book->priv->listener = NULL;
- book->priv->load_state = URINotLoaded;
-}
-
-const char *
-e_book_get_uri (EBook *book)
-{
- g_return_val_if_fail (book && E_IS_BOOK (book), NULL);
-
- return book->priv->uri;
-}
-
-char *
-e_book_get_static_capabilities (EBook *book)
-{
- CORBA_Environment ev;
- char *temp;
- char *ret_val;
-
- CORBA_exception_init (&ev);
-
- if (book->priv->load_state != URILoaded) {
- g_warning ("e_book_unload_uri: No URI is loaded!\n");
- return g_strdup("");
- }
-
- temp = GNOME_Evolution_Addressbook_Book_getStaticCapabilities(book->priv->corba_book, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_get_static_capabilities: Exception "
- "during get_static_capabilities!\n");
- CORBA_exception_free (&ev);
- return NULL;
- }
-
- ret_val = g_strdup(temp);
- CORBA_free(temp);
-
- CORBA_exception_free (&ev);
-
- return ret_val;
-}
-
-guint
-e_book_get_supported_fields (EBook *book,
- EBookFieldsCallback cb,
- gpointer closure)
-{
- CORBA_Environment ev;
- guint tag;
-
- CORBA_exception_init (&ev);
-
- if (book->priv->load_state != URILoaded) {
- g_warning ("e_book_unload_uri: No URI is loaded!\n");
- return 0;
- }
-
- tag = e_book_queue_op (book, cb, closure, NULL);
-
- GNOME_Evolution_Addressbook_Book_getSupportedFields(book->priv->corba_book, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_get_supported_fields: Exception "
- "during get_supported_fields!\n");
- CORBA_exception_free (&ev);
- e_book_unqueue_op (book);
- return 0;
- }
-
- CORBA_exception_free (&ev);
-
- return tag;
-}
-
-static gboolean
-e_book_construct (EBook *book)
-{
- g_return_val_if_fail (book != NULL, FALSE);
- g_return_val_if_fail (E_IS_BOOK (book), FALSE);
-
- book->priv->book_factories = NULL;
-
- return TRUE;
-}
-
-/**
- * e_book_new:
- */
-EBook *
-e_book_new (void)
-{
- EBook *book;
-
- book = gtk_type_new (E_BOOK_TYPE);
-
- if (! e_book_construct (book)) {
- gtk_object_unref (GTK_OBJECT (book));
- return NULL;
- }
-
- return book;
-}
-
-/* User authentication. */
-
-void
-e_book_authenticate_user (EBook *book,
- const char *user,
- const char *passwd,
- const char *auth_method,
- EBookCallback cb,
- gpointer closure)
-{
- CORBA_Environment ev;
-
- g_return_if_fail (book != NULL);
- g_return_if_fail (E_IS_BOOK (book));
-
- if (book->priv->load_state != URILoaded) {
- g_warning ("e_book_authenticate_user: No URI loaded!\n");
- return;
- }
-
- CORBA_exception_init (&ev);
-
- e_book_queue_op (book, cb, closure, NULL);
-
- GNOME_Evolution_Addressbook_Book_authenticateUser (book->priv->corba_book,
- user,
- passwd,
- auth_method,
- &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_authenticate_user: Exception authenticating user with the PAS!\n");
- CORBA_exception_free (&ev);
- e_book_unqueue_op (book);
- return;
- }
-
- CORBA_exception_free (&ev);
-}
-
-/* Fetching cards */
-
-/**
- * e_book_get_card:
- */
-guint
-e_book_get_card (EBook *book,
- const char *id,
- EBookCardCallback cb,
- gpointer closure)
-{
- CORBA_Environment ev;
- guint tag;
-
- g_return_val_if_fail (book != NULL, 0);
- g_return_val_if_fail (E_IS_BOOK (book), 0);
-
- if (book->priv->load_state != URILoaded) {
- g_warning ("e_book_get_card: No URI loaded!\n");
- return 0;
- }
-
- CORBA_exception_init (&ev);
-
- tag = e_book_queue_op (book, cb, closure, NULL);
-
- GNOME_Evolution_Addressbook_Book_getVCard (book->priv->corba_book, (const GNOME_Evolution_Addressbook_VCard) id, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_get_card: Exception "
- "getting card!\n");
- CORBA_exception_free (&ev);
- e_book_unqueue_op (book);
- return 0;
- }
-
- CORBA_exception_free (&ev);
-
- return tag;
-}
-
-/* Deleting cards. */
-
-/**
- * e_book_remove_card:
- */
-gboolean
-e_book_remove_card (EBook *book,
- ECard *card,
- EBookCallback cb,
- gpointer closure)
-{
- const char *id;
-
- g_return_val_if_fail (book != NULL, FALSE);
- g_return_val_if_fail (E_IS_BOOK (book), FALSE);
- g_return_val_if_fail (card != NULL, FALSE);
- g_return_val_if_fail (E_IS_CARD (card), FALSE);
-
- if (book->priv->load_state != URILoaded) {
- g_warning ("e_book_remove_card: No URI loaded!\n");
- return FALSE;
- }
-
- id = e_card_get_id (card);
- g_assert (id != NULL);
-
- return e_book_remove_card_by_id (book, id, cb, closure);
-}
-
-/**
- * e_book_remove_card_by_id:
- */
-gboolean
-e_book_remove_card_by_id (EBook *book,
- const char *id,
- EBookCallback cb,
- gpointer closure)
-
-{
- CORBA_Environment ev;
-
- g_return_val_if_fail (book != NULL, FALSE);
- g_return_val_if_fail (E_IS_BOOK (book), FALSE);
- g_return_val_if_fail (id != NULL, FALSE);
-
- if (book->priv->load_state != URILoaded) {
- g_warning ("e_book_remove_card_by_id: No URI loaded!\n");
- return FALSE;
- }
-
- CORBA_exception_init (&ev);
-
- e_book_queue_op (book, cb, closure, NULL);
-
- GNOME_Evolution_Addressbook_Book_removeCard (
- book->priv->corba_book, (const GNOME_Evolution_Addressbook_CardId) id, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_remove_card_by_id: CORBA exception "
- "talking to PAS!\n");
- CORBA_exception_free (&ev);
- e_book_unqueue_op (book);
- return FALSE;
- }
-
- CORBA_exception_free (&ev);
-
- return TRUE;
-}
-
-/* Adding cards. */
-
-/**
- * e_book_add_card:
- */
-gboolean
-e_book_add_card (EBook *book,
- ECard *card,
- EBookIdCallback cb,
- gpointer closure)
-
-{
- char *vcard;
- gboolean retval;
-
- g_return_val_if_fail (book != NULL, FALSE);
- g_return_val_if_fail (E_IS_BOOK (book), FALSE);
- g_return_val_if_fail (card != NULL, FALSE);
- g_return_val_if_fail (E_IS_CARD (card), FALSE);
-
- if (book->priv->load_state != URILoaded) {
- g_warning ("e_book_add_card: No URI loaded!\n");
- return FALSE;
- }
-
- vcard = e_card_get_vcard_assume_utf8 (card);
-
- if (vcard == NULL) {
- g_warning ("e_book_add_card: Cannot convert card to VCard string!\n");
- return FALSE;
- }
-
- retval = e_book_add_vcard (book, vcard, cb, closure);
-
- g_free (vcard);
-
- if (card->book && card->book != book)
- gtk_object_unref (GTK_OBJECT (card->book));
- card->book = book;
- gtk_object_ref (GTK_OBJECT (card->book));
-
- return retval;
-}
-
-/**
- * e_book_add_vcard:
- */
-gboolean
-e_book_add_vcard (EBook *book,
- const char *vcard,
- EBookIdCallback cb,
- gpointer closure)
-{
- CORBA_Environment ev;
-
- g_return_val_if_fail (book != NULL, FALSE);
- g_return_val_if_fail (E_IS_BOOK (book), FALSE);
- g_return_val_if_fail (vcard != NULL, FALSE);
-
- if (book->priv->load_state != URILoaded) {
- g_warning ("e_book_add_vcard: No URI loaded!\n");
- return FALSE;
- }
-
- CORBA_exception_init (&ev);
-
- e_book_queue_op (book, (EBookCallback) cb, closure, NULL);
-
- GNOME_Evolution_Addressbook_Book_addCard (
- book->priv->corba_book, (const GNOME_Evolution_Addressbook_VCard) vcard, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_add_vcard: Exception adding card to PAS!\n");
- CORBA_exception_free (&ev);
- e_book_unqueue_op (book);
- return FALSE;
- }
-
- CORBA_exception_free (&ev);
-
- return TRUE;
-}
-
-/* Modifying cards. */
-
-/**
- * e_book_commit_card:
- */
-gboolean
-e_book_commit_card (EBook *book,
- ECard *card,
- EBookCallback cb,
- gpointer closure)
-{
- char *vcard;
- gboolean retval;
-
- g_return_val_if_fail (book != NULL, FALSE);
- g_return_val_if_fail (E_IS_BOOK (book), FALSE);
- g_return_val_if_fail (card != NULL, FALSE);
- g_return_val_if_fail (E_IS_CARD (card), FALSE);
-
- if (book->priv->load_state != URILoaded) {
- g_warning ("e_book_commit_card: No URI loaded!\n");
- return FALSE;
- }
-
- vcard = e_card_get_vcard_assume_utf8 (card);
-
- if (vcard == NULL) {
- g_warning ("e_book_commit_card: Error "
- "getting VCard for card!\n");
- return FALSE;
- }
-
- retval = e_book_commit_vcard (book, vcard, cb, closure);
-
- g_free (vcard);
-
- if (card->book && card->book != book)
- gtk_object_unref (GTK_OBJECT (card->book));
- card->book = book;
- gtk_object_ref (GTK_OBJECT (card->book));
-
- return retval;
-}
-
-/**
- * e_book_commit_vcard:
- */
-gboolean
-e_book_commit_vcard (EBook *book,
- const char *vcard,
- EBookCallback cb,
- gpointer closure)
-{
- CORBA_Environment ev;
-
- g_return_val_if_fail (book != NULL, FALSE);
- g_return_val_if_fail (E_IS_BOOK (book), FALSE);
- g_return_val_if_fail (vcard != NULL, FALSE);
-
- if (book->priv->load_state != URILoaded) {
- g_warning ("e_book_commit_vcard: No URI loaded!\n");
- return FALSE;
- }
-
- CORBA_exception_init (&ev);
-
- e_book_queue_op (book, cb, closure, NULL);
-
- GNOME_Evolution_Addressbook_Book_modifyCard (
- book->priv->corba_book, (const GNOME_Evolution_Addressbook_VCard) vcard, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_commit_vcard: Exception "
- "modifying card in PAS!\n");
- CORBA_exception_free (&ev);
- e_book_unqueue_op (book);
- return FALSE;
- }
-
- CORBA_exception_free (&ev);
-
- return TRUE;
-}
-
-/**
- * e_book_check_connection:
- */
-gboolean
-e_book_check_connection (EBook *book)
-{
- CORBA_Environment ev;
-
- g_return_val_if_fail (book != NULL, FALSE);
- g_return_val_if_fail (E_IS_BOOK (book), FALSE);
-
- if (book->priv->load_state != URILoaded) {
- g_warning ("e_book_check_connection: No URI loaded!\n");
- return FALSE;
- }
-
- CORBA_exception_init (&ev);
-
- GNOME_Evolution_Addressbook_Book_checkConnection (book->priv->corba_book, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_check_connection: Exception "
- "querying the PAS!\n");
- CORBA_exception_free (&ev);
- return FALSE;
- }
-
- CORBA_exception_free (&ev);
-
- return TRUE;
-}
-
-guint
-e_book_get_cursor (EBook *book,
- gchar *query,
- EBookCursorCallback cb,
- gpointer closure)
-{
- CORBA_Environment ev;
- guint tag;
-
- g_return_val_if_fail (book != NULL, 0);
- g_return_val_if_fail (E_IS_BOOK (book), 0);
-
- if (book->priv->load_state != URILoaded) {
- g_warning ("e_book_check_connection: No URI loaded!\n");
- return 0;
- }
-
- CORBA_exception_init (&ev);
-
- tag = e_book_queue_op (book, cb, closure, NULL);
-
- GNOME_Evolution_Addressbook_Book_getCursor (book->priv->corba_book, query, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_get_all_cards: Exception "
- "querying list of cards!\n");
- CORBA_exception_free (&ev);
- e_book_unqueue_op (book);
- return 0;
- }
-
- CORBA_exception_free (&ev);
-
- return tag;
-}
-
-guint
-e_book_get_book_view (EBook *book,
- const gchar *query,
- EBookBookViewCallback cb,
- gpointer closure)
-{
- CORBA_Environment ev;
- EBookViewListener *listener;
- guint tag;
-
- g_return_val_if_fail (book != NULL, 0);
- g_return_val_if_fail (E_IS_BOOK (book), 0);
-
- if (book->priv->load_state != URILoaded) {
- g_warning ("e_book_get_book_view: No URI loaded!\n");
- return 0;
- }
-
- listener = e_book_view_listener_new();
-
- CORBA_exception_init (&ev);
-
- tag = e_book_queue_op (book, cb, closure, listener);
-
- GNOME_Evolution_Addressbook_Book_getBookView (book->priv->corba_book, bonobo_object_corba_objref(BONOBO_OBJECT(listener)), query, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_get_book_view: Exception "
- "getting book_view!\n");
- CORBA_exception_free (&ev);
- e_book_unqueue_op (book);
- return 0;
- }
-
- CORBA_exception_free (&ev);
-
- return tag;
-}
-
-guint
-e_book_get_changes (EBook *book,
- gchar *changeid,
- EBookBookViewCallback cb,
- gpointer closure)
-{
- CORBA_Environment ev;
- EBookViewListener *listener;
- guint tag;
-
- g_return_val_if_fail (book != NULL, 0);
- g_return_val_if_fail (E_IS_BOOK (book), 0);
-
- if (book->priv->load_state != URILoaded) {
- g_warning ("e_book_get_changes: No URI loaded!\n");
- return FALSE;
- }
-
- listener = e_book_view_listener_new();
-
- CORBA_exception_init (&ev);
-
- tag = e_book_queue_op (book, cb, closure, listener);
-
- GNOME_Evolution_Addressbook_Book_getChanges (book->priv->corba_book, bonobo_object_corba_objref(BONOBO_OBJECT(listener)), changeid, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_changes: Exception "
- "getting changes!\n");
- CORBA_exception_free (&ev);
- e_book_unqueue_op (book);
- return 0;
- }
-
- CORBA_exception_free (&ev);
-
- return tag;
-}
-
-/**
- * e_book_cancel
- */
-
-void
-e_book_cancel (EBook *book, guint tag)
-{
- g_return_if_fail (book != NULL);
- g_return_if_fail (E_IS_BOOK (book));
- g_return_if_fail (tag != 0);
-
- /* In an attempt to be useful, we take a bit of extra care in reporting
- errors. This might come in handy someday. */
- if (tag >= book->priv->op_tag)
- g_warning ("Attempt to cancel unassigned operation (%u)", tag);
- else if (! e_book_cancel_op (book, tag))
- g_warning ("Attempt to cancel unknown operation (%u)", tag);
-}
-
-/**
- * e_book_get_name:
- */
-char *
-e_book_get_name (EBook *book)
-{
- CORBA_Environment ev;
- char *retval;
- char *name;
-
- g_return_val_if_fail (book != NULL, NULL);
- g_return_val_if_fail (E_IS_BOOK (book), NULL);
-
- if (book->priv->load_state != URILoaded) {
- g_warning ("e_book_get_name: No URI loaded!\n");
- return NULL;
- }
-
- CORBA_exception_init (&ev);
-
- name = GNOME_Evolution_Addressbook_Book_getName (book->priv->corba_book, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_get_name: Exception getting name from PAS!\n");
- CORBA_exception_free (&ev);
- return NULL;
- }
-
- CORBA_exception_free (&ev);
-
- if (name == NULL) {
- g_warning ("e_book_get_name: Got NULL name from PAS!\n");
- return NULL;
- }
-
- retval = g_strdup (name);
- CORBA_free (name);
-
- return retval;
-}
-
-static void
-e_book_init (EBook *book)
-{
- book->priv = g_new0 (EBookPrivate, 1);
- book->priv->load_state = URINotLoaded;
- book->priv->op_tag = 1;
- book->priv->uri = NULL;
-}
-
-static void
-e_book_destroy (GtkObject *object)
-{
- EBook *book = E_BOOK (object);
- CORBA_Environment ev;
- GList *l;
-
- if (book->priv->load_state == URILoaded)
- e_book_unload_uri (book);
-
- CORBA_exception_init (&ev);
-
- for (l = book->priv->book_factories; l; l = l->next) {
- CORBA_Object_release ((CORBA_Object)l->data, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("EBook: Exception while releasing BookFactory\n");
-
- CORBA_exception_free (&ev);
- CORBA_exception_init (&ev);
- }
- }
-
- g_free (book->priv->uri);
-
- g_free (book->priv);
-
- GTK_OBJECT_CLASS (e_book_parent_class)->destroy (object);
-}
-
-static void
-e_book_class_init (EBookClass *klass)
-{
- GtkObjectClass *object_class = (GtkObjectClass *) klass;
-
- e_book_parent_class = gtk_type_class (gtk_object_get_type ());
-
- e_book_signals [LINK_STATUS] =
- gtk_signal_new ("link_status",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EBookClass, link_status),
- gtk_marshal_NONE__BOOL,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_BOOL);
-
- e_book_signals [WRITABLE_STATUS] =
- gtk_signal_new ("writable_status",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EBookClass, writable_status),
- gtk_marshal_NONE__BOOL,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_BOOL);
-
- gtk_object_class_add_signals (object_class, e_book_signals,
- LAST_SIGNAL);
-
- object_class->destroy = e_book_destroy;
-}
-
-/**
- * e_book_get_type:
- */
-GtkType
-e_book_get_type (void)
-{
- static GtkType type = 0;
-
- if (! type) {
- GtkTypeInfo info = {
- "EBook",
- sizeof (EBook),
- sizeof (EBookClass),
- (GtkClassInitFunc) e_book_class_init,
- (GtkObjectInitFunc) e_book_init,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- type = gtk_type_unique (gtk_object_get_type (), &info);
- }
-
- return type;
-}
diff --git a/addressbook/backend/ebook/e-book.h b/addressbook/backend/ebook/e-book.h
deleted file mode 100644
index 1403a23f60..0000000000
--- a/addressbook/backend/ebook/e-book.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * The Evolution addressbook client object.
- *
- * Author:
- * Nat Friedman (nat@ximian.com)
- *
- * Copyright 1999, 2000, Ximian, Inc.
- */
-
-#ifndef __E_BOOK_H__
-#define __E_BOOK_H__
-
-#include <libgnome/gnome-defs.h>
-
-#include <addressbook/backend/ebook/e-card.h>
-#include <addressbook/backend/ebook/e-card-cursor.h>
-#include <addressbook/backend/ebook/e-book-view.h>
-#include <addressbook/backend/ebook/e-book-types.h>
-
-BEGIN_GNOME_DECLS
-
-typedef struct _EBook EBook;
-typedef struct _EBookClass EBookClass;
-typedef struct _EBookPrivate EBookPrivate;
-
-struct _EBook {
- GtkObject parent;
- EBookPrivate *priv;
-};
-
-struct _EBookClass {
- GtkObjectClass parent;
-
- /*
- * Signals.
- */
- void (* open_progress) (EBook *book, const char *msg, short percent);
- void (* link_status) (EBook *book, gboolean connected);
- void (* writable_status) (EBook *book, gboolean writable);
-};
-
-/* Callbacks for asynchronous functions. */
-typedef void (*EBookCallback) (EBook *book, EBookStatus status, gpointer closure);
-typedef void (*EBookOpenProgressCallback) (EBook *book,
- const char *status_message,
- short percent,
- gpointer closure);
-typedef void (*EBookIdCallback) (EBook *book, EBookStatus status, const char *id, gpointer closure);
-typedef void (*EBookCardCallback) (EBook *book, EBookStatus status, ECard *card, gpointer closure);
-typedef void (*EBookCursorCallback) (EBook *book, EBookStatus status, ECardCursor *cursor, gpointer closure);
-typedef void (*EBookBookViewCallback) (EBook *book, EBookStatus status, EBookView *book_view, gpointer closure);
-typedef void (*EBookFieldsCallback) (EBook *book, EBookStatus status, EList *fields, gpointer closure);
-
-/* Creating a new addressbook. */
-EBook *e_book_new (void);
-
-gboolean e_book_load_uri (EBook *book,
- const char *uri,
- EBookCallback open_response,
- gpointer closure);
-void e_book_unload_uri (EBook *book);
-
-const char *e_book_get_uri (EBook *book);
-
-char *e_book_get_static_capabilities (EBook *book);
-
-guint e_book_get_supported_fields (EBook *book,
- EBookFieldsCallback cb,
- gpointer closure);
-
-
-/* User authentication. */
-void e_book_authenticate_user (EBook *book,
- const char *user,
- const char *passwd,
- const char *auth_method,
- EBookCallback cb,
- gpointer closure);
-
-/* Fetching cards. */
-guint e_book_get_card (EBook *book,
- const char *id,
- EBookCardCallback cb,
- gpointer closure);
-
-/* Deleting cards. */
-gboolean e_book_remove_card (EBook *book,
- ECard *card,
- EBookCallback cb,
- gpointer closure);
-gboolean e_book_remove_card_by_id (EBook *book,
- const char *id,
- EBookCallback cb,
- gpointer closure);
-
-/* Adding cards. */
-gboolean e_book_add_card (EBook *book,
- ECard *card,
- EBookIdCallback cb,
- gpointer closure);
-gboolean e_book_add_vcard (EBook *book,
- const char *vcard,
- EBookIdCallback cb,
- gpointer closure);
-
-/* Modifying cards. */
-gboolean e_book_commit_card (EBook *book,
- ECard *card,
- EBookCallback cb,
- gpointer closure);
-gboolean e_book_commit_vcard (EBook *book,
- const char *vcard,
- EBookCallback cb,
- gpointer closure);
-
-/* Checking to see if we're connected to the card repository. */
-gboolean e_book_check_connection (EBook *book);
-guint e_book_get_cursor (EBook *book,
- char *query,
- EBookCursorCallback cb,
- gpointer closure);
-
-guint e_book_get_book_view (EBook *book,
- const gchar *query,
- EBookBookViewCallback cb,
- gpointer closure);
-
-guint e_book_get_changes (EBook *book,
- char *changeid,
- EBookBookViewCallback cb,
- gpointer closure);
-
-/* Cancel a pending operation. */
-void e_book_cancel (EBook *book,
- guint tag);
-
-
-/* Getting the name of the repository. */
-char *e_book_get_name (EBook *book);
-
-GtkType e_book_get_type (void);
-
-#define E_BOOK_TYPE (e_book_get_type ())
-#define E_BOOK(o) (GTK_CHECK_CAST ((o), E_BOOK_TYPE, EBook))
-#define E_BOOK_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_BOOK_TYPE, EBookClass))
-#define E_IS_BOOK(o) (GTK_CHECK_TYPE ((o), E_BOOK_TYPE))
-#define E_IS_BOOK_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_BOOK_TYPE))
-
-END_GNOME_DECLS
-
-#endif /* ! __E_BOOK_H__ */
diff --git a/addressbook/backend/ebook/e-card-compare.c b/addressbook/backend/ebook/e-card-compare.c
deleted file mode 100644
index a022c4e394..0000000000
--- a/addressbook/backend/ebook/e-card-compare.c
+++ /dev/null
@@ -1,704 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * e-card-compare.c
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Developed by Jon Trowbridge <trow@ximian.com>
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA.
- */
-
-#include <config.h>
-#include <ctype.h>
-#include <gal/unicode/gunicode.h>
-#include "e-book-util.h"
-#include "e-card-compare.h"
-
-/* This is an "optimistic" combiner: the best of the two outcomes is
- selected. */
-static ECardMatchType
-combine_comparisons (ECardMatchType prev,
- ECardMatchType new_info)
-{
- if (new_info == E_CARD_MATCH_NOT_APPLICABLE)
- return prev;
- return (ECardMatchType) MAX ((gint) prev, (gint) new_info);
-}
-
-
-/*** Name comparisons ***/
-
-/* This *so* doesn't belong here... at least not implemented in a
- sucky way like this. But it can be fixed later. */
-
-/* This is very Anglocentric. */
-static gchar *name_synonyms[][2] = {
- { "jon", "john" }, /* Ah, the hacker's perogative */
- { "joseph", "joe" },
- { "robert", "bob" },
- { "gene", "jean" },
- { "jesse", "jessie" },
- { "ian", "iain" },
- { "richard", "dick" },
- { "william", "bill" },
- { "william", "will" },
- { "anthony", "tony" },
- { "michael", "mike" },
- { "eric", "erik" },
- { "elizabeth", "liz" },
- { "jeff", "geoff" },
- { "jeff", "geoffrey" },
- { "tom", "thomas" },
- { "dave", "david" },
- { "jim", "james" },
- { "abigal", "abby" },
- { "amanda", "amy" },
- { "amanda", "manda" },
- { "jennifer", "jenny" },
- { "christopher", "chris" },
- { "rebecca", "becca" },
- { "rebecca", "becky" },
- { "anderson", "andersen" },
- { "johnson", "johnsen" },
- /* We could go on and on... */
- /* We should add soundex here. */
- { NULL, NULL }
-};
-
-static gboolean
-name_fragment_match (const gchar *a, const gchar *b, gboolean strict)
-{
- gint len;
-
- if (!(a && b && *a && *b))
- return FALSE;
-
- /* If we are in 'strict' mode, b must match the beginning of a.
- So "Robert", "Rob" would match, but "Robert", "Robbie" wouldn't.
-
- If strict is FALSE, it is sufficient for the strings to share
- some leading characters. In this case, "Robert" and "Robbie"
- would match, as would "Dave" and "Dan". */
-
- if (strict) {
- len = g_utf8_strlen (b, -1);
- } else {
- len = MIN (g_utf8_strlen (a, -1), g_utf8_strlen (b, -1));
- }
-
- return !g_utf8_strncasecmp (a, b, len);
-}
-
-static gboolean
-name_fragment_match_with_synonyms (const gchar *a, const gchar *b, gboolean strict)
-{
- gint i;
-
- if (!(a && b && *a && *b))
- return FALSE;
-
- if (name_fragment_match (a, b, strict))
- return TRUE;
-
- /* Check for nicknames. Yes, the linear search blows. */
- for (i=0; name_synonyms[i][0]; ++i) {
-
- if (!g_utf8_strcasecmp (name_synonyms[i][0], a)
- && !g_utf8_strcasecmp (name_synonyms[i][1], b))
- return TRUE;
-
- if (!g_utf8_strcasecmp (name_synonyms[i][0], b)
- && !g_utf8_strcasecmp (name_synonyms[i][1], a))
- return TRUE;
- }
-
- return FALSE;
-}
-
-ECardMatchType
-e_card_compare_name_to_string (ECard *card, const gchar *str)
-{
- return e_card_compare_name_to_string_full (card, str, FALSE, NULL, NULL, NULL);
-}
-
-ECardMatchType
-e_card_compare_name_to_string_full (ECard *card, const gchar *str, gboolean allow_partial_matches,
- gint *matched_parts_out, ECardMatchPart *first_matched_part_out, gint *matched_character_count_out)
-{
- gchar **namev, **givenv = NULL, **addv = NULL, **familyv = NULL;
-
- gint matched_parts = E_CARD_MATCH_PART_NONE;
- ECardMatchPart first_matched_part = E_CARD_MATCH_PART_NONE;
- ECardMatchPart this_part_match = E_CARD_MATCH_PART_NOT_APPLICABLE;
- ECardMatchType match_type;
-
- gint match_count = 0, matched_character_count = 0, fragment_count;
- gint i, j;
- gchar *str_cpy, *s;
-
- g_return_val_if_fail (E_IS_CARD (card), E_CARD_MATCH_NOT_APPLICABLE);
- g_return_val_if_fail (card->name != NULL, E_CARD_MATCH_NOT_APPLICABLE);
- g_return_val_if_fail (str != NULL, E_CARD_MATCH_NOT_APPLICABLE);
-
- str_cpy = s = g_strdup (str);
- while (*s) {
- if (*s == ',' || *s == '"')
- *s = ' ';
- ++s;
- }
- namev = g_strsplit (str_cpy, " ", 0);
- g_free (str_cpy);
-
- if (card->name->given)
- givenv = g_strsplit (card->name->given, " ", 0);
- if (card->name->additional)
- addv = g_strsplit (card->name->additional, " ", 0);
- if (card->name->family)
- familyv = g_strsplit (card->name->family, " ", 0);
-
- fragment_count = 0;
- for (i = 0; givenv && givenv[i]; ++i)
- ++fragment_count;
- for (i = 0; addv && addv[i]; ++i)
- ++fragment_count;
- for (i = 0; familyv && familyv[i]; ++i)
- ++fragment_count;
-
- for (i = 0; namev[i] && this_part_match != E_CARD_MATCH_PART_NONE; ++i) {
-
- if (*namev[i]) {
-
- this_part_match = E_CARD_MATCH_PART_NONE;
-
- /* When we are allowing partials, we are strict about the matches we allow.
- Does this make sense? Not really, but it does the right thing for the purposes
- of completion. */
-
- if (givenv && this_part_match == E_CARD_MATCH_PART_NONE) {
- for (j = 0; givenv[j]; ++j) {
- if (name_fragment_match_with_synonyms (givenv[j], namev[i], allow_partial_matches)) {
-
- this_part_match = E_CARD_MATCH_PART_GIVEN_NAME;
-
- /* We remove a piece of a name once it has been matched against, so
- that "john john" won't match "john doe". */
- g_free (givenv[j]);
- givenv[j] = g_strdup ("");
- break;
- }
- }
- }
-
- if (addv && this_part_match == E_CARD_MATCH_PART_NONE) {
- for (j = 0; addv[j]; ++j) {
- if (name_fragment_match_with_synonyms (addv[j], namev[i], allow_partial_matches)) {
-
- this_part_match = E_CARD_MATCH_PART_ADDITIONAL_NAME;
-
- g_free (addv[j]);
- addv[j] = g_strdup ("");
- break;
- }
- }
- }
-
- if (familyv && this_part_match == E_CARD_MATCH_PART_NONE) {
- for (j = 0; familyv[j]; ++j) {
- if (allow_partial_matches ? name_fragment_match_with_synonyms (familyv[j], namev[i], allow_partial_matches)
- : !g_utf8_strcasecmp (familyv[j], namev[i])) {
-
- this_part_match = E_CARD_MATCH_PART_FAMILY_NAME;
-
- g_free (familyv[j]);
- familyv[j] = g_strdup ("");
- break;
- }
- }
- }
-
- if (this_part_match != E_CARD_MATCH_PART_NONE) {
- ++match_count;
- matched_character_count += g_utf8_strlen (namev[i], -1);
- matched_parts |= this_part_match;
- if (first_matched_part == E_CARD_MATCH_PART_NONE)
- first_matched_part = this_part_match;
- }
- }
- }
-
- match_type = E_CARD_MATCH_NONE;
-
- if (this_part_match != E_CARD_MATCH_PART_NONE) {
-
- if (match_count > 0)
- match_type = E_CARD_MATCH_VAGUE;
-
- if (fragment_count == match_count) {
-
- match_type = E_CARD_MATCH_EXACT;
-
- } else if (fragment_count == match_count + 1) {
-
- match_type = E_CARD_MATCH_PARTIAL;
-
- }
- }
-
- if (matched_parts_out)
- *matched_parts_out = matched_parts;
- if (first_matched_part_out)
- *first_matched_part_out = first_matched_part;
- if (matched_character_count_out)
- *matched_character_count_out = matched_character_count;
-
- g_strfreev (namev);
- g_strfreev (givenv);
- g_strfreev (addv);
- g_strfreev (familyv);
-
- return match_type;
-}
-
-ECardMatchType
-e_card_compare_name (ECard *card1, ECard *card2)
-{
- ECardName *a, *b;
- gint matches=0, possible=0;
- gboolean given_match = FALSE, additional_match = FALSE, family_match = FALSE;
-
- g_return_val_if_fail (E_IS_CARD (card1), E_CARD_MATCH_NOT_APPLICABLE);
- g_return_val_if_fail (E_IS_CARD (card2), E_CARD_MATCH_NOT_APPLICABLE);
-
- a = card1->name;
- b = card2->name;
-
- if (a == NULL || b == NULL)
- return E_CARD_MATCH_NOT_APPLICABLE;
-
- if (a->given && b->given) {
- ++possible;
- if (name_fragment_match_with_synonyms (a->given, b->given, FALSE /* both inputs are complete */)) {
- ++matches;
- given_match = TRUE;
- }
- }
-
- if (a->additional && b->additional) {
- ++possible;
- if (name_fragment_match_with_synonyms (a->additional, b->additional, FALSE /* both inputs are complete */)) {
- ++matches;
- additional_match = TRUE;
- }
- }
-
- if (a->family && b->family) {
- ++possible;
- /* We don't allow "loose matching" (i.e. John vs. Jon) on family names */
- if (! g_utf8_strcasecmp (a->family, b->family)) {
- ++matches;
- family_match = TRUE;
- }
- }
-
- /* Now look at the # of matches and try to intelligently map
- an E_CARD_MATCH_* type to it. Special consideration is given
- to family-name matches. */
-
- if (possible == 0)
- return E_CARD_MATCH_NOT_APPLICABLE;
-
- if (possible == 1)
- return family_match ? E_CARD_MATCH_VAGUE : E_CARD_MATCH_NONE;
-
- if (possible == matches)
- return family_match ? E_CARD_MATCH_EXACT : E_CARD_MATCH_PARTIAL;
-
- if (possible == matches+1)
- return family_match ? E_CARD_MATCH_VAGUE : E_CARD_MATCH_NONE;
-
- return E_CARD_MATCH_NONE;
-}
-
-
-/*** Nickname Comparisons ***/
-
-ECardMatchType
-e_card_compare_nickname (ECard *card1, ECard *card2)
-{
- g_return_val_if_fail (card1 && E_IS_CARD (card1), E_CARD_MATCH_NOT_APPLICABLE);
- g_return_val_if_fail (card2 && E_IS_CARD (card2), E_CARD_MATCH_NOT_APPLICABLE);
-
- return E_CARD_MATCH_NOT_APPLICABLE;
-}
-
-
-
-/*** E-mail Comparisons ***/
-
-static gboolean
-match_email_username (const gchar *addr1, const gchar *addr2)
-{
- gint c1, c2;
- if (addr1 == NULL || addr2 == NULL)
- return FALSE;
-
- while (*addr1 && *addr2 && *addr1 != '@' && *addr2 != '@') {
- c1 = isupper (*addr1) ? tolower (*addr1) : *addr1;
- c2 = isupper (*addr2) ? tolower (*addr2) : *addr2;
- if (c1 != c2)
- return FALSE;
- ++addr1;
- ++addr2;
- }
-
- return *addr1 == *addr2;
-}
-
-static gboolean
-match_email_hostname (const gchar *addr1, const gchar *addr2)
-{
- gint c1, c2;
- gboolean seen_at1, seen_at2;
- if (addr1 == NULL || addr2 == NULL)
- return FALSE;
-
- /* Walk to the end of each string. */
- seen_at1 = FALSE;
- if (*addr1) {
- while (*addr1) {
- if (*addr1 == '@')
- seen_at1 = TRUE;
- ++addr1;
- }
- --addr1;
- }
-
- seen_at2 = FALSE;
- if (*addr2) {
- while (*addr2) {
- if (*addr2 == '@')
- seen_at2 = TRUE;
- ++addr2;
- }
- --addr2;
- }
-
- if (!seen_at1 && !seen_at2)
- return TRUE;
- if (!seen_at1 || !seen_at2)
- return FALSE;
-
- while (*addr1 != '@' && *addr2 != '@') {
- c1 = isupper (*addr1) ? tolower (*addr1) : *addr1;
- c2 = isupper (*addr2) ? tolower (*addr2) : *addr2;
- if (c1 != c2)
- return FALSE;
- --addr1;
- --addr2;
- }
-
- /* This will match bob@foo.ximian.com and bob@ximian.com */
- return *addr1 == '.' || *addr2 == '.';
-}
-
-static ECardMatchType
-compare_email_addresses (const gchar *addr1, const gchar *addr2)
-{
- if (addr1 == NULL || addr2 == NULL)
- return E_CARD_MATCH_NOT_APPLICABLE;
-
- if (match_email_username (addr1, addr2))
- return match_email_hostname (addr1, addr2) ? E_CARD_MATCH_EXACT : E_CARD_MATCH_VAGUE;
-
- return E_CARD_MATCH_NONE;
-}
-
-ECardMatchType
-e_card_compare_email (ECard *card1, ECard *card2)
-{
- EIterator *i1, *i2;
- ECardMatchType match = E_CARD_MATCH_NOT_APPLICABLE;
-
- g_return_val_if_fail (card1 && E_IS_CARD (card1), E_CARD_MATCH_NOT_APPLICABLE);
- g_return_val_if_fail (card2 && E_IS_CARD (card2), E_CARD_MATCH_NOT_APPLICABLE);
-
- if (card1->email == NULL || card2->email == NULL)
- return E_CARD_MATCH_NOT_APPLICABLE;
-
- i1 = e_list_get_iterator (card1->email);
- i2 = e_list_get_iterator (card2->email);
-
- /* Do pairwise-comparisons on all of the e-mail addresses. If
- we find an exact match, there is no reason to keep
- checking. */
- e_iterator_reset (i1);
- while (e_iterator_is_valid (i1) && match != E_CARD_MATCH_EXACT) {
- const gchar *addr1 = (const gchar *) e_iterator_get (i1);
-
- e_iterator_reset (i2);
- while (e_iterator_is_valid (i2) && match != E_CARD_MATCH_EXACT) {
- const gchar *addr2 = (const gchar *) e_iterator_get (i2);
-
- match = combine_comparisons (match, compare_email_addresses (addr1, addr2));
-
- e_iterator_next (i2);
- }
-
- e_iterator_next (i1);
- }
-
- gtk_object_unref (GTK_OBJECT (i1));
- gtk_object_unref (GTK_OBJECT (i2));
-
- return match;
-}
-
-ECardMatchType
-e_card_compare_address (ECard *card1, ECard *card2)
-{
- g_return_val_if_fail (card1 && E_IS_CARD (card1), E_CARD_MATCH_NOT_APPLICABLE);
- g_return_val_if_fail (card2 && E_IS_CARD (card2), E_CARD_MATCH_NOT_APPLICABLE);
-
- /* Unimplemented */
-
- return E_CARD_MATCH_NOT_APPLICABLE;
-}
-
-ECardMatchType
-e_card_compare_telephone (ECard *card1, ECard *card2)
-{
- g_return_val_if_fail (card1 && E_IS_CARD (card1), E_CARD_MATCH_NOT_APPLICABLE);
- g_return_val_if_fail (card2 && E_IS_CARD (card2), E_CARD_MATCH_NOT_APPLICABLE);
-
- /* Unimplemented */
-
- return E_CARD_MATCH_NOT_APPLICABLE;
-}
-
-ECardMatchType
-e_card_compare (ECard *card1, ECard *card2)
-{
- ECardMatchType result;
-
- g_return_val_if_fail (card1 && E_IS_CARD (card1), E_CARD_MATCH_NOT_APPLICABLE);
- g_return_val_if_fail (card2 && E_IS_CARD (card2), E_CARD_MATCH_NOT_APPLICABLE);
-
- result = E_CARD_MATCH_NONE;
- result = combine_comparisons (result, e_card_compare_name (card1, card2));
- result = combine_comparisons (result, e_card_compare_nickname (card1, card2));
- result = combine_comparisons (result, e_card_compare_email (card1, card2));
- result = combine_comparisons (result, e_card_compare_address (card1, card2));
- result = combine_comparisons (result, e_card_compare_telephone (card1, card2));
-
- return result;
-}
-
-typedef struct _MatchSearchInfo MatchSearchInfo;
-struct _MatchSearchInfo {
- ECard *card;
- GList *avoid;
- ECardMatchQueryCallback cb;
- gpointer closure;
-};
-
-static void
-match_search_info_free (MatchSearchInfo *info)
-{
- if (info) {
- gtk_object_unref (GTK_OBJECT (info->card));
-
- /* This should already have been deallocated, but just in case... */
- if (info->avoid) {
- g_list_foreach (info->avoid, (GFunc) gtk_object_unref, NULL);
- g_list_free (info->avoid);
- info->avoid = NULL;
- }
-
- g_free (info);
- }
-}
-
-static void
-simple_query_cb (EBook *book, EBookSimpleQueryStatus status, const GList *cards, gpointer closure)
-{
- MatchSearchInfo *info = (MatchSearchInfo *) closure;
- ECardMatchType best_match = E_CARD_MATCH_NONE;
- ECard *best_card = NULL;
- GList *remaining_cards = NULL;
- const GList *i;
-
- if (status != E_BOOK_SIMPLE_QUERY_STATUS_SUCCESS) {
- info->cb (info->card, NULL, E_CARD_MATCH_NONE, info->closure);
- match_search_info_free (info);
- return;
- }
-
- /* remove the cards we're to avoid from the list, if they're present */
- for (i = cards; i != NULL; i = g_list_next (i)) {
- ECard *this_card = E_CARD (i->data);
- GList *iterator;
- gboolean avoid = FALSE;
- for (iterator = info->avoid; iterator; iterator = iterator->next) {
- if (!strcmp (e_card_get_id (iterator->data), e_card_get_id (this_card))) {
- avoid = TRUE;
- break;
- }
- }
- if (!avoid)
- remaining_cards = g_list_prepend (remaining_cards, this_card);
- }
-
- remaining_cards = g_list_reverse (remaining_cards);
-
- for (i = remaining_cards; i != NULL; i = g_list_next (i)) {
- ECard *this_card = E_CARD (i->data);
- ECardMatchType this_match = e_card_compare (info->card, this_card);
- if ((gint)this_match > (gint)best_match) {
- best_match = this_match;
- best_card = this_card;
- }
- }
-
- g_list_free (remaining_cards);
-
- info->cb (info->card, best_card, best_match, info->closure);
- match_search_info_free (info);
-}
-
-#define MAX_QUERY_PARTS 10
-static void
-use_common_book_cb (EBook *book, gpointer closure)
-{
- MatchSearchInfo *info = (MatchSearchInfo *) closure;
- ECard *card = info->card;
- gchar *query_parts[MAX_QUERY_PARTS];
- gint p=0;
- gchar *query, *qj;
- int i;
-
- if (book == NULL) {
- info->cb (info->card, NULL, E_CARD_MATCH_NONE, info->closure);
- match_search_info_free (info);
- return;
- }
-
- if (card->nickname)
- query_parts[p++] = g_strdup_printf ("(beginswith \"nickname\" \"%s\")", card->nickname);
-
-
- if (card->name->given && strlen (card->name->given) > 1)
- query_parts[p++] = g_strdup_printf ("(contains \"full_name\" \"%s\")", card->name->given);
-
- if (card->name->additional && strlen (card->name->additional) > 1)
- query_parts[p++] = g_strdup_printf ("(contains \"full_name\" \"%s\")", card->name->additional);
-
- if (card->name->family && strlen (card->name->family) > 1)
- query_parts[p++] = g_strdup_printf ("(contains \"full_name\" \"%s\")", card->name->family);
-
-
- if (card->email) {
- EIterator *iter = e_list_get_iterator (card->email);
- while (e_iterator_is_valid (iter) && p < MAX_QUERY_PARTS) {
- gchar *addr = g_strdup (e_iterator_get (iter));
- if (addr) {
- gchar *s = addr;
- while (*s) {
- if (*s == '@') {
- *s = '\0';
- break;
- }
- ++s;
- }
- query_parts[p++] = g_strdup_printf ("(beginswith \"email\" \"%s\")", addr);
- g_free (addr);
- }
- e_iterator_next (iter);
- }
- }
-
-
-
- /* Build up our full query from the parts. */
- query_parts[p] = NULL;
- qj = g_strjoinv (" ", query_parts);
- for(i = 0; query_parts[i] != NULL; i++)
- g_free(query_parts[i]);
- if (p > 0) {
- query = g_strdup_printf ("(or %s)", qj);
- g_free (qj);
- } else {
- query = qj;
- }
-
- e_book_simple_query (book, query, simple_query_cb, info);
-
- g_free (query);
-}
-
-void
-e_card_locate_match (ECard *card, ECardMatchQueryCallback cb, gpointer closure)
-{
- MatchSearchInfo *info;
-
- g_return_if_fail (card && E_IS_CARD (card));
- g_return_if_fail (cb != NULL);
-
- info = g_new (MatchSearchInfo, 1);
- info->card = card;
- gtk_object_ref (GTK_OBJECT (card));
- info->cb = cb;
- info->closure = closure;
- info->avoid = NULL;
-
- e_book_use_local_address_book (use_common_book_cb, info);
-}
-
-/**
- * e_card_locate_match_full:
- * @book: The book to look in. If this is NULL, use the main local
- * addressbook.
- * @card: The card to compare to.
- * @avoid: A list of cards to not match. These will not show up in the search.
- * @cb: The function to call.
- * @closure: The closure to add to the call.
- *
- * Look for the best match and return it using the ECardMatchQueryCallback.
- **/
-void
-e_card_locate_match_full (EBook *book, ECard *card, GList *avoid, ECardMatchQueryCallback cb, gpointer closure)
-{
- MatchSearchInfo *info;
-
- g_return_if_fail (card && E_IS_CARD (card));
- g_return_if_fail (cb != NULL);
-
- info = g_new (MatchSearchInfo, 1);
- info->card = card;
- gtk_object_ref (GTK_OBJECT (card));
- info->cb = cb;
- info->closure = closure;
- info->avoid = g_list_copy (avoid);
- g_list_foreach (info->avoid, (GFunc) gtk_object_ref, NULL);
-
- if (book)
- use_common_book_cb (book, info);
- else
- e_book_use_local_address_book (use_common_book_cb, info);
-}
-
diff --git a/addressbook/backend/ebook/e-card-compare.h b/addressbook/backend/ebook/e-card-compare.h
deleted file mode 100644
index 07ccb54e89..0000000000
--- a/addressbook/backend/ebook/e-card-compare.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * e-card-compare.h
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Developed by Jon Trowbridge <trow@ximian.com>
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA.
- */
-
-#ifndef __E_CARD_COMPARE_H__
-#define __E_CARD_COMPARE_H__
-
-#include "e-book.h"
-#include "e-card.h"
-
-typedef enum {
- E_CARD_MATCH_NOT_APPLICABLE = 0,
- E_CARD_MATCH_NONE = 1,
- E_CARD_MATCH_VAGUE = 2,
- E_CARD_MATCH_PARTIAL = 3,
- E_CARD_MATCH_EXACT = 4
-} ECardMatchType;
-
-typedef enum {
- E_CARD_MATCH_PART_NOT_APPLICABLE = -1,
- E_CARD_MATCH_PART_NONE = 0,
- E_CARD_MATCH_PART_GIVEN_NAME = 1<<0,
- E_CARD_MATCH_PART_ADDITIONAL_NAME = 1<<2,
- E_CARD_MATCH_PART_FAMILY_NAME = 1<<3
-} ECardMatchPart;
-
-typedef void (*ECardMatchQueryCallback) (ECard *card, ECard *match, ECardMatchType type, gpointer closure);
-
-ECardMatchType e_card_compare_name_to_string (ECard *card, const gchar *str);
-
-ECardMatchType e_card_compare_name_to_string_full (ECard *card, const gchar *str,
- gboolean allow_partial_matches,
- gint *matched_parts, ECardMatchPart *first_matched_part,
- gint *matched_character_count);
-
-ECardMatchType e_card_compare_name (ECard *card1, ECard *card2);
-ECardMatchType e_card_compare_nickname (ECard *card1, ECard *card2);
-ECardMatchType e_card_compare_email (ECard *card1, ECard *card2);
-ECardMatchType e_card_compare_address (ECard *card1, ECard *card2);
-ECardMatchType e_card_compare_telephone (ECard *card1, ECard *card2);
-
-ECardMatchType e_card_compare (ECard *card1, ECard *card2);
-
-void e_card_locate_match (ECard *card, ECardMatchQueryCallback cb, gpointer closure);
-void e_card_locate_match_full (EBook *book, ECard *card, GList *avoid, ECardMatchQueryCallback cb, gpointer closure);
-
-
-
-#endif /* __E_CARD_COMPARE_H__ */
-
diff --git a/addressbook/backend/ebook/e-card-cursor.c b/addressbook/backend/ebook/e-card-cursor.c
deleted file mode 100644
index 171f83d736..0000000000
--- a/addressbook/backend/ebook/e-card-cursor.c
+++ /dev/null
@@ -1,235 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * e-card-cursor.c: Implements card cursors.
- *
- * Author:
- * Christopher James Lahey <clahey@ximian.com.
- */
-
-#include <config.h>
-#include <gtk/gtkobject.h>
-#include "addressbook.h"
-#include "e-card-cursor.h"
-
-struct _ECardCursorPrivate {
- GNOME_Evolution_Addressbook_CardCursor corba_cursor;
-};
-
-/*
- * A pointer to our parent object class
- */
-static GtkObjectClass *parent_class;
-
-/*
- * Implemented GtkObject::destroy
- */
-static void
-e_card_cursor_destroy (GtkObject *object)
-{
- ECardCursor *cursor = E_CARD_CURSOR (object);
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- GNOME_Evolution_Addressbook_CardCursor_unref( cursor->priv->corba_cursor, &ev );
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning("e_card_cursor_destroy: Exception unreffing "
- "corba cursor.\n");
- CORBA_exception_free (&ev);
- CORBA_exception_init (&ev);
- }
-
- CORBA_Object_release (cursor->priv->corba_cursor, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning("e_card_cursor_destroy: Exception releasing "
- "corba cursor.\n");
- }
-
- CORBA_exception_free (&ev);
-
- if ( cursor->priv )
- g_free ( cursor->priv );
-
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
-/**
- * e_card_cursor_get_length:
- * @cursor: the #ECardCursor whose length is being queried
- *
- * Returns: the number of items the cursor references, or -1 there's
- * an error.
- */
-long
-e_card_cursor_get_length (ECardCursor *cursor)
-{
- if ( cursor->priv->corba_cursor != CORBA_OBJECT_NIL ) {
- CORBA_Environment ev;
- long ret_val;
-
- CORBA_exception_init (&ev);
-
- ret_val = GNOME_Evolution_Addressbook_CardCursor_count (cursor->priv->corba_cursor, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning("e_card_cursor_get_length: Exception during "
- "get_length corba call.\n");
- ret_val = -1;
- }
-
- CORBA_exception_free (&ev);
-
- return ret_val;
- }
- else
- return -1;
-}
-
-/**
- * e_card_cursor_get_nth:
- * @cursor: an #ECardCursor object
- * @n: the index of the item requested
- *
- * Gets an #ECard based on an index.
- *
- * Returns: a new #ECard on success, or %NULL on failure.
- */
-ECard *
-e_card_cursor_get_nth (ECardCursor *cursor,
- const long n)
-{
- if ( cursor->priv->corba_cursor != CORBA_OBJECT_NIL ) {
- CORBA_Environment en;
- CORBA_char *vcard;
- ECard *card;
-
- CORBA_exception_init (&en);
-
- vcard = GNOME_Evolution_Addressbook_CardCursor_getNth(cursor->priv->corba_cursor, n, &en);
-
- if (en._major != CORBA_NO_EXCEPTION) {
- g_warning("e_card_cursor_get_nth: Exception during "
- "get_nth corba call.\n");
- }
-
- CORBA_exception_free (&en);
-
- card = e_card_new (vcard);
-
- CORBA_free(vcard);
-
- return card;
- }
- else
- return e_card_new("");
-}
-
-static void
-e_card_cursor_class_init (ECardCursorClass *klass)
-{
- GtkObjectClass *object_class = (GtkObjectClass *) klass;
-
- parent_class = gtk_type_class (gtk_object_get_type ());
-
- object_class->destroy = e_card_cursor_destroy;
-}
-
-static void
-e_card_cursor_init (ECardCursor *cursor)
-{
- cursor->priv = g_new(ECardCursorPrivate, 1);
- cursor->priv->corba_cursor = CORBA_OBJECT_NIL;
-}
-
-GtkType
-e_card_cursor_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type){
- GtkTypeInfo info = {
- "ECardCursor",
- sizeof (ECardCursor),
- sizeof (ECardCursorClass),
- (GtkClassInitFunc) e_card_cursor_class_init,
- (GtkObjectInitFunc) e_card_cursor_init,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- type = gtk_type_unique (gtk_object_get_type (), &info);
- }
-
- return type;
-}
-
-/**
- * e_card_cursor_construct:
- * @cursor: an #ECardCursor object
- * @corba_cursor: an #GNOME_Evolution_Addressbook_CardCursor
- *
- * Wraps an #GNOME_Evolution_Addressbook_CardCursor object inside the #ECardCursor
- * @cursor object.
- *
- * Returns: a new #ECardCursor on success, or %NULL on failure.
- */
-ECardCursor *
-e_card_cursor_construct (ECardCursor *cursor,
- GNOME_Evolution_Addressbook_CardCursor corba_cursor)
-{
- CORBA_Environment ev;
- g_return_val_if_fail (cursor != NULL, NULL);
- g_return_val_if_fail (E_IS_CARD_CURSOR (cursor), NULL);
- g_return_val_if_fail (corba_cursor != CORBA_OBJECT_NIL, NULL);
-
- CORBA_exception_init (&ev);
-
- /*
- * Initialize cursor
- */
- cursor->priv->corba_cursor = CORBA_Object_duplicate(corba_cursor, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning("e_card_cursor_construct: Exception duplicating "
- "corba cursor.\n");
- CORBA_exception_free (&ev);
- CORBA_exception_init (&ev);
- }
-
- GNOME_Evolution_Addressbook_CardCursor_ref(cursor->priv->corba_cursor, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning("e_card_cursor_construct: Exception reffing "
- "corba cursor.\n");
- }
-
- CORBA_exception_free (&ev);
-
- /*
- * Success: return the GtkType we were given
- */
- return cursor;
-}
-
-/**
- * e_card_cursor_new:
- * @cursor: the #GNOME_Evolution_Addressbook_CardCursor to be wrapped
- *
- * Creates a new #ECardCursor, which wraps an #GNOME_Evolution_Addressbook_CardCursor
- * object.
- *
- * Returns: a new #ECardCursor on success, or %NULL on failure.
- */
-ECardCursor *
-e_card_cursor_new (GNOME_Evolution_Addressbook_CardCursor corba_cursor)
-{
- ECardCursor *cursor;
-
- cursor = gtk_type_new (e_card_cursor_get_type ());
-
- return e_card_cursor_construct (cursor,
- corba_cursor);
-}
diff --git a/addressbook/backend/ebook/e-card-cursor.h b/addressbook/backend/ebook/e-card-cursor.h
deleted file mode 100644
index e042268635..0000000000
--- a/addressbook/backend/ebook/e-card-cursor.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- *
- * Author:
- * Nat Friedman (nat@ximian.com)
- *
- * Copyright 2000, Ximian, Inc.
- */
-
-#ifndef __E_CARD_CURSOR_H__
-#define __E_CARD_CURSOR_H__
-
-#include <gtk/gtkobject.h>
-#include <libgnome/gnome-defs.h>
-#include <addressbook/backend/ebook/addressbook.h>
-#include <addressbook/backend/ebook/e-card.h>
-
-BEGIN_GNOME_DECLS
-
-typedef struct _ECardCursor ECardCursor;
-typedef struct _ECardCursorPrivate ECardCursorPrivate;
-typedef struct _ECardCursorClass ECardCursorClass;
-
-struct _ECardCursor {
- GtkObject parent;
- ECardCursorPrivate *priv;
-};
-
-struct _ECardCursorClass {
- GtkObjectClass parent;
-};
-
-/* Creating a new addressbook. */
-ECardCursor *e_card_cursor_new (GNOME_Evolution_Addressbook_CardCursor corba_cursor);
-ECardCursor *e_card_cursor_construct (ECardCursor *cursor,
- GNOME_Evolution_Addressbook_CardCursor corba_cursor);
-
-GtkType e_card_cursor_get_type (void);
-
-/* Fetching cards. */
-long e_card_cursor_get_length (ECardCursor *cursor);
-ECard *e_card_cursor_get_nth (ECardCursor *cursor,
- const long nth);
-#define E_CARD_CURSOR_TYPE (e_card_cursor_get_type ())
-#define E_CARD_CURSOR(o) (GTK_CHECK_CAST ((o), E_CARD_CURSOR_TYPE, ECardCursor))
-#define E_CARD_CURSOR_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CARD_CURSOR_TYPE, ECardCursorClass))
-#define E_IS_CARD_CURSOR(o) (GTK_CHECK_TYPE ((o), E_CARD_CURSOR_TYPE))
-#define E_IS_CARD_CURSOR_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CARD_CURSOR_TYPE))
-
-END_GNOME_DECLS
-
-#endif /* ! __E_CARD_CURSOR_H__ */
diff --git a/addressbook/backend/ebook/e-card-pairs.h b/addressbook/backend/ebook/e-card-pairs.h
deleted file mode 100644
index f82f948ebb..0000000000
--- a/addressbook/backend/ebook/e-card-pairs.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* GnomeCard - a graphical contact manager.
- *
- * pairs.h: This file is part of GnomeCard.
- *
- * Copyright (C) 1999 The Free Software Foundation
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __E_CARD_PAIRS_H__
-#define __E_CARD_PAIRS_H__
-
-#include <libversit/vcc.h>
-#include <ebook/e-card.h>
-
-
-#if 0
-struct pair
-{
- char *str;
- ECardPropertyType i ;
-};
-
-struct pair prop_lookup[] = {
- { VCFullNameProp, PROP_FNAME },
- { VCNameProp, PROP_NAME },
- { VCPhotoProp, PROP_PHOTO },
- { VCBirthDateProp, PROP_BDAY },
- { VCAdrProp, PROP_DELADDR },
- { VCDeliveryLabelProp, PROP_DELLABEL },
- { VCTelephoneProp, PROP_PHONE },
- { VCEmailAddressProp, PROP_EMAIL },
- { VCMailerProp, PROP_MAILER },
- { VCTimeZoneProp, PROP_TIMEZN },
- { VCGeoProp, PROP_GEOPOS },
- { VCTitleProp, PROP_TITLE },
- { VCBusinessRoleProp, PROP_ROLE },
- { VCLogoProp, PROP_LOGO },
- { VCAgentProp, PROP_AGENT },
- { VCOrgProp, PROP_ORG },
- { VCCategoriesProp, PROP_CATEGORIES },
- { VCCommentProp, PROP_COMMENT },
- { VCLastRevisedProp, PROP_REV },
- { VCPronunciationProp, PROP_SOUND },
- { VCURLProp, PROP_URL },
- { VCUniqueStringProp, PROP_UID },
- { VCVersionProp, PROP_VERSION },
- { VCPublicKeyProp, PROP_KEY },
- { VCValueProp, PROP_VALUE },
- { VCEncodingProp, PROP_ENCODING },
- { VCQuotedPrintableProp, PROP_QUOTED_PRINTABLE },
- { VC8bitProp, PROP_8BIT },
- { VCBase64Prop, PROP_BASE64 },
- { VCLanguageProp, PROP_LANG },
- { VCCharSetProp, PROP_CHARSET },
- { NULL, PROP_NONE} };
-
-struct pair photo_pairs[] = {
- { VCGIFProp, PHOTO_GIF },
- { VCCGMProp, PHOTO_CGM },
- { VCWMFProp, PHOTO_WMF },
- { VCBMPProp, PHOTO_BMP },
- { VCMETProp, PHOTO_MET },
- { VCPMBProp, PHOTO_PMB },
- { VCDIBProp, PHOTO_DIB },
- { VCPICTProp, PHOTO_PICT },
- { VCTIFFProp, PHOTO_TIFF },
- { VCPDFProp, PHOTO_PDF },
- { VCPSProp, PHOTO_PS },
- { VCJPEGProp, PHOTO_JPEG },
- { VCMPEGProp, PHOTO_MPEG },
- { VCMPEG2Prop, PHOTO_MPEG2 },
- { VCAVIProp, PHOTO_AVI },
- { VCQuickTimeProp, PHOTO_QTIME },
- { NULL, 0 } };
-
-struct pair email_pairs[] = {
- { VCAOLProp, EMAIL_AOL },
- { VCAppleLinkProp, EMAIL_APPLE_LINK },
- { VCATTMailProp, EMAIL_ATT },
- { VCCISProp, EMAIL_CIS },
- { VCEWorldProp, EMAIL_EWORLD },
- { VCInternetProp, EMAIL_INET },
- { VCIBMMailProp, EMAIL_IBM },
- { VCMCIMailProp, EMAIL_MCI },
- { VCPowerShareProp, EMAIL_POWERSHARE },
- { VCProdigyProp, EMAIL_PRODIGY },
- { VCTLXProp, EMAIL_TLX },
- { VCX400Prop, EMAIL_X400 },
- { NULL, 0 } };
-
-struct pair sound_pairs[] = {
- { VCAIFFProp, SOUND_AIFF },
- { VCPCMProp, SOUND_PCM },
- { VCWAVEProp, SOUND_WAVE },
- { NULL, 0 } };
-
-struct pair key_pairs[] = {
- { VCX509Prop, KEY_X509 },
- { VCPGPProp, KEY_PGP },
- { NULL, 0 } };
-
-
-#endif
-#endif /* ! __E_CARD_PAIRS_H__ */
diff --git a/addressbook/backend/ebook/e-card-simple.c b/addressbook/backend/ebook/e-card-simple.c
deleted file mode 100644
index 2bf06c8cd9..0000000000
--- a/addressbook/backend/ebook/e-card-simple.c
+++ /dev/null
@@ -1,1274 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- * Arturo Espinosa (arturo@nuclecu.unam.mx)
- * Nat Friedman (nat@ximian.com)
- *
- * Copyright (C) 2000 Ximian, Inc.
- * Copyright (C) 1999 The Free Software Foundation
- */
-
-#include <config.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <gtk/gtkobject.h>
-#include <gal/util/e-unicode-i18n.h>
-#include <gal/util/e-util.h>
-
-#include <libversit/vcc.h>
-#include "e-card-simple.h"
-
-/* Object argument IDs */
-enum {
- ARG_0,
- ARG_CARD,
-};
-
-
-typedef enum _ECardSimpleInternalType ECardSimpleInternalType;
-typedef struct _ECardSimpleFieldData ECardSimpleFieldData;
-
-enum _ECardSimpleInternalType {
- E_CARD_SIMPLE_INTERNAL_TYPE_STRING,
- E_CARD_SIMPLE_INTERNAL_TYPE_DATE,
- E_CARD_SIMPLE_INTERNAL_TYPE_ADDRESS,
- E_CARD_SIMPLE_INTERNAL_TYPE_PHONE,
- E_CARD_SIMPLE_INTERNAL_TYPE_EMAIL,
- E_CARD_SIMPLE_INTERNAL_TYPE_SPECIAL,
- E_CARD_SIMPLE_INTERNAL_TYPE_BOOL,
-};
-
-struct _ECardSimpleFieldData {
- ECardSimpleField field;
- char *ecard_field;
- char *name;
- char *short_name;
- int list_type_index;
- ECardSimpleInternalType type;
-};
-
-/* This order must match the order in the .h. */
-
-/* the ecard_field data below should only be used for TYPE_STRING,
- TYPE_DATE, and TYPE_SPECIAL fields. that is, it's only valid for
- e-cards for those types. it is used as a unique name for fields
- for the get_supported functionality. */
-static ECardSimpleFieldData field_data[] =
-{
- { E_CARD_SIMPLE_FIELD_FILE_AS, "file_as", N_("File As"), "", 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
- { E_CARD_SIMPLE_FIELD_FULL_NAME, "full_name", N_("Name"), N_("Name"), 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
- { E_CARD_SIMPLE_FIELD_EMAIL, "email", N_("Email"), N_("Email"), E_CARD_SIMPLE_EMAIL_ID_EMAIL, E_CARD_SIMPLE_INTERNAL_TYPE_EMAIL },
- { E_CARD_SIMPLE_FIELD_PHONE_PRIMARY, "primary_phone", N_("Primary"), N_("Prim"), E_CARD_SIMPLE_PHONE_ID_PRIMARY, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_ASSISTANT, "assistant_phone", N_("Assistant"), N_("Assistant"),E_CARD_SIMPLE_PHONE_ID_ASSISTANT, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_BUSINESS, "business_phone", N_("Business"), N_("Bus"), E_CARD_SIMPLE_PHONE_ID_BUSINESS, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_CALLBACK, "callback_phone", N_("Callback"), N_("Callback"), E_CARD_SIMPLE_PHONE_ID_CALLBACK, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_COMPANY, "company_phone", N_("Company"), N_("Comp"), E_CARD_SIMPLE_PHONE_ID_COMPANY, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_HOME, "home_phone", N_("Home"), N_("Home"), E_CARD_SIMPLE_PHONE_ID_HOME, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_ORG, "org", N_("Organization"), N_("Org"), 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
- { E_CARD_SIMPLE_FIELD_ADDRESS_BUSINESS, "business_address",N_("Business"), N_("Bus"), E_CARD_SIMPLE_ADDRESS_ID_BUSINESS, E_CARD_SIMPLE_INTERNAL_TYPE_ADDRESS },
- { E_CARD_SIMPLE_FIELD_ADDRESS_HOME, "home_address", N_("Home"), N_("Home"), E_CARD_SIMPLE_ADDRESS_ID_HOME, E_CARD_SIMPLE_INTERNAL_TYPE_ADDRESS },
- { E_CARD_SIMPLE_FIELD_PHONE_MOBILE, "mobile_phone", N_("Mobile"), N_("Mobile"), E_CARD_SIMPLE_PHONE_ID_MOBILE, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_CAR, "car_phone", N_("Car"), N_("Car"), E_CARD_SIMPLE_PHONE_ID_CAR, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_BUSINESS_FAX, "business_fax", N_("Business Fax"), N_("Bus Fax"), E_CARD_SIMPLE_PHONE_ID_BUSINESS_FAX, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_HOME_FAX, "home_fax", N_("Home Fax"), N_("Home Fax"), E_CARD_SIMPLE_PHONE_ID_HOME_FAX, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_BUSINESS_2, "business_phone_2",N_("Business 2"), N_("Bus 2"), E_CARD_SIMPLE_PHONE_ID_BUSINESS_2, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_HOME_2, "home_phone_2", N_("Home 2"), N_("Home 2"), E_CARD_SIMPLE_PHONE_ID_HOME_2, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_ISDN, "isdn", N_("ISDN"), N_("ISDN"), E_CARD_SIMPLE_PHONE_ID_ISDN, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_OTHER, "other_phone", N_("Other"), N_("Other"), E_CARD_SIMPLE_PHONE_ID_OTHER, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_OTHER_FAX, "other_fax", N_("Other Fax"), N_("Other Fax"), E_CARD_SIMPLE_PHONE_ID_OTHER_FAX, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_PAGER, "pager", N_("Pager"), N_("Pager"), E_CARD_SIMPLE_PHONE_ID_PAGER, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_RADIO, "radio", N_("Radio"), N_("Radio"), E_CARD_SIMPLE_PHONE_ID_RADIO, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_TELEX, "telex", N_("Telex"), N_("Telex"), E_CARD_SIMPLE_PHONE_ID_TELEX, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_TTYTDD, "tty", N_("TTY"), N_("TTY"), E_CARD_SIMPLE_PHONE_ID_TTYTDD, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_ADDRESS_OTHER, "other_address", N_("Other"), N_("Other"), E_CARD_SIMPLE_ADDRESS_ID_OTHER, E_CARD_SIMPLE_INTERNAL_TYPE_ADDRESS },
- { E_CARD_SIMPLE_FIELD_EMAIL_2, "email_2", N_("Email 2"), N_("Email 2"), E_CARD_SIMPLE_EMAIL_ID_EMAIL_2, E_CARD_SIMPLE_INTERNAL_TYPE_EMAIL },
- { E_CARD_SIMPLE_FIELD_EMAIL_3, "email_3", N_("Email 3"), N_("Email 3"), E_CARD_SIMPLE_EMAIL_ID_EMAIL_3, E_CARD_SIMPLE_INTERNAL_TYPE_EMAIL },
- { E_CARD_SIMPLE_FIELD_URL, "url", N_("Web Site"), N_("Url"), 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
- { E_CARD_SIMPLE_FIELD_ORG_UNIT, "org_unit", N_("Department"), N_("Dep"), 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
- { E_CARD_SIMPLE_FIELD_OFFICE, "office", N_("Office"), N_("Off"), 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
- { E_CARD_SIMPLE_FIELD_TITLE, "title", N_("Title"), N_("Title"), 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
- { E_CARD_SIMPLE_FIELD_ROLE, "role", N_("Profession"), N_("Prof"), 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
- { E_CARD_SIMPLE_FIELD_MANAGER, "manager", N_("Manager"), N_("Man"), 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
- { E_CARD_SIMPLE_FIELD_ASSISTANT, "assistant", N_("Assistant"), N_("Ass"), 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
- { E_CARD_SIMPLE_FIELD_NICKNAME, "nickname", N_("Nickname"), N_("Nick"), 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
- { E_CARD_SIMPLE_FIELD_SPOUSE, "spouse", N_("Spouse"), N_("Spouse"), 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
- { E_CARD_SIMPLE_FIELD_NOTE, "note", N_("Note"), N_("Note"), 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
- { E_CARD_SIMPLE_FIELD_CALURI, "caluri", N_("Calendar URI"), N_("CALUri"), 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
- { E_CARD_SIMPLE_FIELD_FBURL, "fburl", N_("Free-busy URL"), N_("FBUrl"), 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
- { E_CARD_SIMPLE_FIELD_ANNIVERSARY, "anniversary", N_("Anniversary"), N_("Anniv"), 0, E_CARD_SIMPLE_INTERNAL_TYPE_DATE },
- { E_CARD_SIMPLE_FIELD_BIRTH_DATE, "birth_date", N_("Birth Date"), "", 0, E_CARD_SIMPLE_INTERNAL_TYPE_DATE },
- { E_CARD_SIMPLE_FIELD_MAILER, "mailer", "", "", 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
- { E_CARD_SIMPLE_FIELD_NAME_OR_ORG, "nameororg", "", "", 0, E_CARD_SIMPLE_INTERNAL_TYPE_SPECIAL },
- { E_CARD_SIMPLE_FIELD_CATEGORIES, "categories", N_("Categories"), N_("Categories"), 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
- { E_CARD_SIMPLE_FIELD_FAMILY_NAME, "family_name", N_("Family Name"), N_("Family Name"), 0, E_CARD_SIMPLE_INTERNAL_TYPE_SPECIAL },
- { E_CARD_SIMPLE_FIELD_GIVEN_NAME, "given_name", "Given Name", "Given Name", 0, E_CARD_SIMPLE_INTERNAL_TYPE_SPECIAL },
- { E_CARD_SIMPLE_FIELD_ADDITIONAL_NAME, "additional_name", "Additional Name", "Additional Name", 0, E_CARD_SIMPLE_INTERNAL_TYPE_SPECIAL },
- { E_CARD_SIMPLE_FIELD_NAME_SUFFIX, "name_suffix", "Name Suffix", "Name Suffix", 0, E_CARD_SIMPLE_INTERNAL_TYPE_SPECIAL },
- { E_CARD_SIMPLE_FIELD_WANTS_HTML, "wants_html", "Wants HTML", "Wants HTML", 0, E_CARD_SIMPLE_INTERNAL_TYPE_BOOL },
- { E_CARD_SIMPLE_FIELD_IS_LIST, "list", "Is List", "Is List", 0, E_CARD_SIMPLE_INTERNAL_TYPE_BOOL },
-};
-static int field_data_count = sizeof (field_data) / sizeof (field_data[0]);
-
-static void e_card_simple_init (ECardSimple *simple);
-static void e_card_simple_class_init (ECardSimpleClass *klass);
-
-static void e_card_simple_destroy (GtkObject *object);
-static void e_card_simple_set_arg (GtkObject *object, GtkArg *arg, guint arg_id);
-static void e_card_simple_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
-
-static void fill_in_info(ECardSimple *simple);
-
-ECardPhoneFlags phone_correspondences[] = {
- E_CARD_PHONE_ASSISTANT, /* E_CARD_SIMPLE_PHONE_ID_ASSISTANT, */
- E_CARD_PHONE_WORK | E_CARD_PHONE_VOICE, /* E_CARD_SIMPLE_PHONE_ID_BUSINESS, */
- E_CARD_PHONE_WORK | E_CARD_PHONE_VOICE, /* E_CARD_SIMPLE_PHONE_ID_BUSINESS_2, */
- E_CARD_PHONE_WORK | E_CARD_PHONE_FAX, /* E_CARD_SIMPLE_PHONE_ID_BUSINESS_FAX, */
- E_CARD_PHONE_CALLBACK, /* E_CARD_SIMPLE_PHONE_ID_CALLBACK, */
- E_CARD_PHONE_CAR, /* E_CARD_SIMPLE_PHONE_ID_CAR, */
- E_CARD_PHONE_WORK, /* E_CARD_SIMPLE_PHONE_ID_COMPANY, */
- E_CARD_PHONE_HOME, /* E_CARD_SIMPLE_PHONE_ID_HOME, */
- E_CARD_PHONE_HOME, /* E_CARD_SIMPLE_PHONE_ID_HOME_2, */
- E_CARD_PHONE_HOME | E_CARD_PHONE_FAX, /* E_CARD_SIMPLE_PHONE_ID_HOME_FAX, */
- E_CARD_PHONE_ISDN, /* E_CARD_SIMPLE_PHONE_ID_ISDN, */
- E_CARD_PHONE_CELL, /* E_CARD_SIMPLE_PHONE_ID_MOBILE, */
- E_CARD_PHONE_VOICE, /* E_CARD_SIMPLE_PHONE_ID_OTHER, */
- E_CARD_PHONE_FAX, /* E_CARD_SIMPLE_PHONE_ID_OTHER_FAX, */
- E_CARD_PHONE_PAGER, /* E_CARD_SIMPLE_PHONE_ID_PAGER, */
- E_CARD_PHONE_PREF, /* E_CARD_SIMPLE_PHONE_ID_PRIMARY, */
- E_CARD_PHONE_RADIO, /* E_CARD_SIMPLE_PHONE_ID_RADIO, */
- E_CARD_PHONE_TELEX, /* E_CARD_SIMPLE_PHONE_ID_TELEX, */
- E_CARD_PHONE_TTYTDD, /* E_CARD_SIMPLE_PHONE_ID_TTYTDD, */
-};
-
-char *phone_names[] = {
- NULL, /* E_CARD_SIMPLE_PHONE_ID_ASSISTANT, */
- "Business",
- "Business 2",
- "Business Fax",
- NULL, /* E_CARD_SIMPLE_PHONE_ID_CALLBACK, */
- "Car",
- NULL, /* E_CARD_SIMPLE_PHONE_ID_COMPANY, */
- "Home",
- "Home 2",
- "Home Fax",
- "ISDN",
- "Mobile",
- "Other",
- NULL, /* E_CARD_SIMPLE_PHONE_ID_OTHER_FAX, */
- "Pager",
- "Primary",
- NULL, /* E_CARD_SIMPLE_PHONE_ID_RADIO, */
- NULL, /* E_CARD_SIMPLE_PHONE_ID_TELEX, */
- NULL, /* E_CARD_SIMPLE_PHONE_ID_TTYTDD, */
-};
-
-char *phone_short_names[] = {
- NULL, /* E_CARD_SIMPLE_PHONE_ID_ASSISTANT, */
- "Bus",
- "Bus 2",
- "Bus Fax",
- NULL, /* E_CARD_SIMPLE_PHONE_ID_CALLBACK, */
- "Car",
- NULL, /* E_CARD_SIMPLE_PHONE_ID_COMPANY, */
- "Home",
- "Home 2",
- "Home Fax",
- "ISDN",
- "Mob",
- "Other",
- NULL, /* E_CARD_SIMPLE_PHONE_ID_OTHER_FAX, */
- "Pag",
- "Prim",
- NULL, /* E_CARD_SIMPLE_PHONE_ID_RADIO, */
- NULL, /* E_CARD_SIMPLE_PHONE_ID_TELEX, */
- NULL, /* E_CARD_SIMPLE_PHONE_ID_TTYTDD, */
-};
-
-ECardAddressFlags addr_correspondences[] = {
- E_CARD_ADDR_WORK, /* E_CARD_SIMPLE_ADDRESS_ID_BUSINESS, */
- E_CARD_ADDR_HOME, /* E_CARD_SIMPLE_ADDRESS_ID_HOME, */
- E_CARD_ADDR_POSTAL, /* E_CARD_SIMPLE_ADDRESS_ID_OTHER, */
-};
-
-char *address_names[] = {
- "Business",
- "Home",
- "Other",
-};
-
-/**
- * e_card_simple_get_type:
- * @void:
- *
- * Registers the &ECardSimple class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: The type ID of the &ECardSimple class.
- **/
-GtkType
-e_card_simple_get_type (void)
-{
- static GtkType simple_type = 0;
-
- if (!simple_type) {
- GtkTypeInfo simple_info = {
- "ECardSimple",
- sizeof (ECardSimple),
- sizeof (ECardSimpleClass),
- (GtkClassInitFunc) e_card_simple_class_init,
- (GtkObjectInitFunc) e_card_simple_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- simple_type = gtk_type_unique (gtk_object_get_type (), &simple_info);
- }
-
- return simple_type;
-}
-
-/**
- * e_card_simple_new:
- * @VCard: a string in vCard format
- *
- * Returns: a new #ECardSimple that wraps the @VCard.
- */
-ECardSimple *
-e_card_simple_new (ECard *card)
-{
- ECardSimple *simple = E_CARD_SIMPLE(gtk_type_new(e_card_simple_get_type()));
- gtk_object_set(GTK_OBJECT(simple),
- "card", card,
- NULL);
- return simple;
-}
-
-ECardSimple *
-e_card_simple_duplicate(ECardSimple *simple)
-{
- ECard *card = simple->card ? e_card_duplicate (simple->card) : e_card_new ("");
- ECardSimple *new_simple = e_card_simple_new(card);
- return new_simple;
-}
-
-/**
- * e_card_simple_get_id:
- * @simple: an #ECardSimple
- *
- * Returns: a string representing the id of the simple, which is unique
- * within its book.
- */
-const char *
-e_card_simple_get_id (ECardSimple *simple)
-{
- if (simple->card)
- return e_card_get_id(simple->card);
- else
- return "";
-}
-
-/**
- * e_card_simple_get_id:
- * @simple: an #ECardSimple
- * @id: a id in string format
- *
- * Sets the identifier of a simple, which should be unique within its
- * book.
- */
-void
-e_card_simple_set_id (ECardSimple *simple, const char *id)
-{
- if ( simple->card )
- e_card_set_id(simple->card, id);
-}
-
-/**
- * e_card_simple_get_vcard:
- * @simple: an #ECardSimple
- *
- * Returns: a string in vcard format, which is wrapped by the @simple.
- */
-char *
-e_card_simple_get_vcard (ECardSimple *simple)
-{
- if (simple->card)
- return e_card_get_vcard(simple->card);
- else
- return g_strdup("");
-}
-
-/**
- * e_card_simple_get_vcard_assume_utf8:
- * @simple: an #ECardSimple
- *
- * Returns: a string in vcard format, which is wrapped by the @simple.
- */
-char *
-e_card_simple_get_vcard_assume_utf8 (ECardSimple *simple)
-{
- if (simple->card)
- return e_card_get_vcard_assume_utf8(simple->card);
- else
- return g_strdup("");
-}
-
-static void
-e_card_simple_class_init (ECardSimpleClass *klass)
-{
- GtkObjectClass *object_class;
-
- object_class = GTK_OBJECT_CLASS(klass);
-
- gtk_object_add_arg_type ("ECardSimple::card",
- GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_CARD);
-
- object_class->destroy = e_card_simple_destroy;
- object_class->get_arg = e_card_simple_get_arg;
- object_class->set_arg = e_card_simple_set_arg;
-}
-
-/*
- * ECardSimple lifecycle management and vcard loading/saving.
- */
-
-static void
-e_card_simple_destroy (GtkObject *object)
-{
- ECardSimple *simple;
- int i;
-
- simple = E_CARD_SIMPLE (object);
-
- if (simple->card)
- gtk_object_unref(GTK_OBJECT(simple->card));
- g_list_foreach(simple->temp_fields, (GFunc) g_free, NULL);
- g_list_free(simple->temp_fields);
- simple->temp_fields = NULL;
-
- for(i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i++)
- e_card_phone_unref (simple->phone[i]);
- for(i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i++)
- g_free(simple->email[i]);
- for(i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++)
- e_card_address_label_unref(simple->address[i]);
- for(i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++)
- e_card_delivery_address_unref(simple->delivery[i]);
-}
-
-
-/* Set_arg handler for the simple */
-static void
-e_card_simple_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- ECardSimple *simple;
-
- simple = E_CARD_SIMPLE (object);
-
- switch (arg_id) {
- case ARG_CARD:
- if (simple->card)
- gtk_object_unref(GTK_OBJECT(simple->card));
- g_list_foreach(simple->temp_fields, (GFunc) g_free, NULL);
- g_list_free(simple->temp_fields);
- simple->temp_fields = NULL;
- if (GTK_VALUE_OBJECT(*arg))
- simple->card = E_CARD(GTK_VALUE_OBJECT(*arg));
- else
- simple->card = NULL;
- if(simple->card)
- gtk_object_ref(GTK_OBJECT(simple->card));
- fill_in_info(simple);
- break;
- default:
- return;
- }
-}
-
-/* Get_arg handler for the simple */
-static void
-e_card_simple_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- ECardSimple *simple;
-
- simple = E_CARD_SIMPLE (object);
-
- switch (arg_id) {
- case ARG_CARD:
- e_card_simple_sync_card(simple);
- GTK_VALUE_OBJECT (*arg) = (GtkObject *) simple->card;
- break;
- default:
- arg->type = GTK_TYPE_INVALID;
- break;
- }
-}
-
-
-/**
- * e_card_simple_init:
- */
-static void
-e_card_simple_init (ECardSimple *simple)
-{
- int i;
- simple->card = NULL;
- for(i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i++)
- simple->phone[i] = NULL;
- for(i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i++)
- simple->email[i] = NULL;
- for(i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++)
- simple->address[i] = NULL;
- simple->temp_fields = NULL;
-
- simple->changed = TRUE;
-}
-
-static void
-fill_in_info(ECardSimple *simple)
-{
- ECard *card = simple->card;
- if (card) {
- EList *address_list;
- EList *phone_list;
- EList *email_list;
- EList *delivery_list;
- const ECardPhone *phone;
- const char *email;
- const ECardAddrLabel *address;
- const ECardDeliveryAddress *delivery;
- int i;
-
- EIterator *iterator;
-
- gtk_object_get(GTK_OBJECT(card),
- "address_label", &address_list,
- "address", &delivery_list,
- "phone", &phone_list,
- "email", &email_list,
- NULL);
- for (i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i++) {
- e_card_phone_unref(simple->phone[i]);
- simple->phone[i] = NULL;
- }
- for (iterator = e_list_get_iterator(phone_list); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
- gboolean found = FALSE;
- phone = e_iterator_get(iterator);
- for (i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i ++) {
- if ((phone->flags == phone_correspondences[i]) && (simple->phone[i] == NULL)) {
- simple->phone[i] = e_card_phone_ref(phone);
- found = TRUE;
- break;
- }
- }
- if (found)
- continue;
- for (i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i ++) {
- if (((phone->flags & phone_correspondences[i]) == phone_correspondences[i]) && (simple->phone[i] == NULL)) {
- simple->phone[i] = e_card_phone_ref(phone);
- break;
- }
- }
- }
- gtk_object_unref(GTK_OBJECT(iterator));
-
- for (i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i++) {
- g_free(simple->email[i]);
- simple->email[i] = NULL;
- }
- for (iterator = e_list_get_iterator(email_list); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
- email = e_iterator_get(iterator);
- for (i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i ++) {
- if ((simple->email[i] == NULL)) {
- simple->email[i] = g_strdup(email);
- break;
- }
- }
- }
- gtk_object_unref(GTK_OBJECT(iterator));
-
- for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++) {
- e_card_address_label_unref(simple->address[i]);
- simple->address[i] = NULL;
- }
- for (iterator = e_list_get_iterator(address_list); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
- address = e_iterator_get(iterator);
- for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i ++) {
- if (((address->flags & addr_correspondences[i]) == addr_correspondences[i]) && (simple->address[i] == NULL)) {
- simple->address[i] = e_card_address_label_ref(address);
- break;
- }
- }
- }
- gtk_object_unref(GTK_OBJECT(iterator));
-
- for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++) {
- e_card_delivery_address_unref(simple->delivery[i]);
- simple->delivery[i] = NULL;
- }
- for (iterator = e_list_get_iterator(delivery_list); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
- delivery = e_iterator_get(iterator);
- for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i ++) {
- if (((delivery->flags & addr_correspondences[i]) == addr_correspondences[i]) && (simple->delivery[i] == NULL)) {
- simple->delivery[i] = e_card_delivery_address_ref(delivery);
- break;
- }
- }
- }
- gtk_object_unref(GTK_OBJECT(iterator));
- e_card_free_empty_lists (card);
- }
-}
-
-void
-e_card_simple_sync_card(ECardSimple *simple)
-{
- ECard *card = simple->card;
- if (card && simple->changed) {
- EList *address_list;
- EList *phone_list;
- EList *email_list;
- EList *delivery_list;
- const ECardPhone *phone;
- const ECardAddrLabel *address;
- const ECardDeliveryAddress *delivery;
- const char *email;
- int i;
-
- EIterator *iterator;
-
- gtk_object_get(GTK_OBJECT(card),
- "address_label", &address_list,
- "address", &delivery_list,
- "phone", &phone_list,
- "email", &email_list,
- NULL);
-
- for (iterator = e_list_get_iterator(phone_list); e_iterator_is_valid(iterator); e_iterator_next(iterator) ) {
- int i;
- gboolean found = FALSE;
- phone = e_iterator_get(iterator);
- for (i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i ++) {
- if (phone->flags == phone_correspondences[i]) {
- if (simple->phone[i]) {
- simple->phone[i]->flags = phone_correspondences[i];
- if (simple->phone[i]->number && *simple->phone[i]->number) {
- e_iterator_set(iterator, simple->phone[i]);
- } else {
- e_iterator_delete(iterator);
- }
- e_card_phone_unref(simple->phone[i]);
- simple->phone[i] = NULL;
- found = TRUE;
- break;
- }
- }
- }
- if (found)
- continue;
- for (i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i ++) {
- if ((phone->flags & phone_correspondences[i]) == phone_correspondences[i]) {
- if (simple->phone[i]) {
- simple->phone[i]->flags = phone_correspondences[i];
- if (simple->phone[i]->number && *simple->phone[i]->number) {
- e_iterator_set(iterator, simple->phone[i]);
- } else {
- e_iterator_delete(iterator);
- }
- e_card_phone_unref(simple->phone[i]);
- simple->phone[i] = NULL;
- break;
- }
- }
- }
- }
- gtk_object_unref(GTK_OBJECT(iterator));
- for (i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i ++) {
- if (simple->phone[i]) {
- simple->phone[i]->flags = phone_correspondences[i];
- e_list_append(phone_list, simple->phone[i]);
- e_card_phone_unref(simple->phone[i]);
- simple->phone[i] = NULL;
- }
- }
-
- for (iterator = e_list_get_iterator(email_list); e_iterator_is_valid(iterator); e_iterator_next(iterator) ) {
- int i;
- email = e_iterator_get(iterator);
- for (i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i ++) {
- if (simple->email[i]) {
- if (*simple->email[i]) {
- e_iterator_set(iterator, simple->email[i]);
- } else {
- e_iterator_delete(iterator);
- }
- g_free(simple->email[i]);
- simple->email[i] = NULL;
- break;
- }
- }
- }
- gtk_object_unref(GTK_OBJECT(iterator));
- for (i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i ++) {
- if (simple->email[i]) {
- e_list_append(email_list, simple->email[i]);
- g_free(simple->email[i]);
- simple->email[i] = NULL;
- }
- }
-
- for (iterator = e_list_get_iterator(address_list); e_iterator_is_valid(iterator); e_iterator_next(iterator) ) {
- int i;
- address = e_iterator_get(iterator);
- for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i ++) {
- if ((address->flags & addr_correspondences[i]) == addr_correspondences[i]) {
- if (simple->address[i]) {
- simple->address[i]->flags &= ~E_CARD_ADDR_MASK;
- simple->address[i]->flags |= addr_correspondences[i];
- if (simple->address[i]->data && *simple->address[i]->data) {
- e_iterator_set(iterator, simple->address[i]);
- } else {
- e_iterator_delete(iterator);
- }
- e_card_address_label_unref(simple->address[i]);
- simple->address[i] = NULL;
- break;
- }
- }
- }
- }
- gtk_object_unref(GTK_OBJECT(iterator));
- for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i ++) {
- if (simple->address[i]) {
- simple->address[i]->flags &= ~E_CARD_ADDR_MASK;
- simple->address[i]->flags |= addr_correspondences[i];
- e_list_append(address_list, simple->address[i]);
- e_card_address_label_unref(simple->address[i]);
- simple->address[i] = NULL;
- }
- }
-
- for (iterator = e_list_get_iterator(delivery_list); e_iterator_is_valid(iterator); e_iterator_next(iterator) ) {
- int i;
- delivery = e_iterator_get(iterator);
- for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i ++) {
- if ((delivery->flags & addr_correspondences[i]) == addr_correspondences[i]) {
- if (simple->delivery[i]) {
- simple->delivery[i]->flags &= ~E_CARD_ADDR_MASK;
- simple->delivery[i]->flags |= addr_correspondences[i];
- if (!e_card_delivery_address_is_empty(simple->delivery[i])) {
- e_iterator_set(iterator, simple->delivery[i]);
- } else {
- e_iterator_delete(iterator);
- }
- e_card_delivery_address_unref(simple->delivery[i]);
- simple->delivery[i] = NULL;
- break;
- }
- }
- }
- }
- gtk_object_unref(GTK_OBJECT(iterator));
- for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i ++) {
- if (simple->delivery[i]) {
- simple->delivery[i]->flags &= ~E_CARD_ADDR_MASK;
- simple->delivery[i]->flags |= addr_correspondences[i];
- e_list_append(delivery_list, simple->delivery[i]);
- e_card_delivery_address_unref(simple->delivery[i]);
- simple->delivery[i] = NULL;
- }
- }
- fill_in_info(simple);
- e_card_free_empty_lists (card);
- }
-
- simple->changed = FALSE;
-}
-
-const ECardPhone *e_card_simple_get_phone (ECardSimple *simple,
- ECardSimplePhoneId id)
-{
- return simple->phone[id];
-}
-
-const char *e_card_simple_get_email (ECardSimple *simple,
- ECardSimpleEmailId id)
-{
- return simple->email[id];
-}
-
-const ECardAddrLabel *e_card_simple_get_address (ECardSimple *simple,
- ECardSimpleAddressId id)
-{
- return simple->address[id];
-}
-
-const ECardDeliveryAddress *e_card_simple_get_delivery_address (ECardSimple *simple,
- ECardSimpleAddressId id)
-{
- return simple->delivery[id];
-}
-
-void e_card_simple_set_phone (ECardSimple *simple,
- ECardSimplePhoneId id,
- const ECardPhone *phone)
-{
- e_card_phone_unref(simple->phone[id]);
- simple->phone[id] = e_card_phone_ref(phone);
- simple->changed = TRUE;
-}
-
-void e_card_simple_set_email (ECardSimple *simple,
- ECardSimpleEmailId id,
- const char *email)
-{
- g_free(simple->email[id]);
- simple->email[id] = g_strdup(email);
- simple->changed = TRUE;
-}
-
-void
-e_card_simple_set_address (ECardSimple *simple, ECardSimpleAddressId id, const ECardAddrLabel *address)
-{
- e_card_address_label_unref(simple->address[id]);
- simple->address[id] = e_card_address_label_ref(address);
- e_card_delivery_address_unref(simple->delivery[id]);
- simple->delivery[id] = e_card_delivery_address_from_label(simple->address[id]);
- simple->changed = TRUE;
-}
-
-void e_card_simple_set_delivery_address (ECardSimple *simple,
- ECardSimpleAddressId id,
- const ECardDeliveryAddress *delivery)
-{
- e_card_delivery_address_unref(simple->delivery[id]);
- simple->delivery[id] = e_card_delivery_address_ref(delivery);
- simple->changed = TRUE;
-}
-
-const char *e_card_simple_get_const (ECardSimple *simple,
- ECardSimpleField field)
-{
- char *ret_val = e_card_simple_get(simple, field);
- if (ret_val)
- simple->temp_fields = g_list_prepend(simple->temp_fields, ret_val);
- return ret_val;
-}
-
-char *e_card_simple_get (ECardSimple *simple,
- ECardSimpleField field)
-{
- ECardSimpleInternalType type = field_data[field].type;
- const ECardAddrLabel *addr;
- const ECardPhone *phone;
- const char *string;
- ECardDate *date;
- ECardName *name;
- switch(type) {
- case E_CARD_SIMPLE_INTERNAL_TYPE_STRING:
- if (simple->card) {
- gtk_object_get(GTK_OBJECT(simple->card),
- field_data[field].ecard_field, &string,
- NULL);
- return g_strdup(string);
- } else
- return NULL;
- case E_CARD_SIMPLE_INTERNAL_TYPE_DATE:
- if (simple->card) {
- gtk_object_get(GTK_OBJECT(simple->card),
- field_data[field].ecard_field, &date,
- NULL);
- if (date != NULL) {
- char buf[26];
- struct tm then;
- then.tm_year = date->year;
- then.tm_mon = date->month - 1;
- then.tm_mday = date->day;
- then.tm_hour = 12;
- then.tm_min = 0;
- then.tm_sec = 0;
- e_strftime_fix_am_pm (buf, 26, _("%x"), &then);
- return g_strdup (buf);
- } else {
- return NULL;
- }
- } else
- return NULL;
- case E_CARD_SIMPLE_INTERNAL_TYPE_ADDRESS:
- addr = e_card_simple_get_address(simple,
- field_data[field].list_type_index);
- if (addr)
- return g_strdup(addr->data);
- else
- return NULL;
- case E_CARD_SIMPLE_INTERNAL_TYPE_PHONE:
- phone = e_card_simple_get_phone(simple,
- field_data[field].list_type_index);
- if (phone)
- return g_strdup(phone->number);
- else
- return NULL;
- case E_CARD_SIMPLE_INTERNAL_TYPE_EMAIL:
- string = e_card_simple_get_email(simple,
- field_data[field].list_type_index);
- return g_strdup(string);
- case E_CARD_SIMPLE_INTERNAL_TYPE_BOOL:
- if (simple->card) {
- gboolean boole;
- gtk_object_get (GTK_OBJECT (simple->card),
- field_data[field].ecard_field, &boole,
- NULL);
- if (boole)
- return "true";
- else
- return NULL;
- } else {
- return NULL;
- }
- case E_CARD_SIMPLE_INTERNAL_TYPE_SPECIAL:
- switch (field) {
- case E_CARD_SIMPLE_FIELD_NAME_OR_ORG:
- if (simple->card) {
- gtk_object_get(GTK_OBJECT(simple->card),
- "file_as", &string,
- NULL);
- if (string && *string)
- return g_strdup(string);
- gtk_object_get(GTK_OBJECT(simple->card),
- "full_name", &string,
- NULL);
- if (string && *string)
- return g_strdup(string);
- gtk_object_get(GTK_OBJECT(simple->card),
- "org", &string,
- NULL);
- if (string && *string)
- return g_strdup(string);
- string = e_card_simple_get_email(simple,
- E_CARD_SIMPLE_EMAIL_ID_EMAIL);
- return g_strdup(string);
- } else
- return NULL;
- case E_CARD_SIMPLE_FIELD_FAMILY_NAME:
- if (simple->card) {
- gtk_object_get (GTK_OBJECT(simple->card),
- "name", &name,
- NULL);
- return g_strdup (name->family);
- } else
- return NULL;
- case E_CARD_SIMPLE_FIELD_GIVEN_NAME:
- if (simple->card) {
- gtk_object_get (GTK_OBJECT(simple->card),
- "name", &name,
- NULL);
- return g_strdup (name->given);
- } else
- return NULL;
- case E_CARD_SIMPLE_FIELD_ADDITIONAL_NAME:
- if (simple->card) {
- gtk_object_get (GTK_OBJECT(simple->card),
- "name", &name,
- NULL);
- return g_strdup (name->additional);
- } else
- return NULL;
- case E_CARD_SIMPLE_FIELD_NAME_SUFFIX:
- if (simple->card) {
- gtk_object_get (GTK_OBJECT(simple->card),
- "name", &name,
- NULL);
- return g_strdup (name->suffix);
- } else
- return NULL;
- default:
- return NULL;
- }
- default:
- return NULL;
- }
-}
-
-static char *
-name_to_style(const ECardName *name, char *company, int style)
-{
- char *string;
- char *strings[4], **stringptr;
- char *substring;
- switch (style) {
- case 0:
- stringptr = strings;
- if (name->family && *name->family)
- *(stringptr++) = name->family;
- if (name->given && *name->given)
- *(stringptr++) = name->given;
- *stringptr = NULL;
- string = g_strjoinv(", ", strings);
- break;
- case 1:
- stringptr = strings;
- if (name->given && *name->given)
- *(stringptr++) = name->given;
- if (name->family && *name->family)
- *(stringptr++) = name->family;
- *stringptr = NULL;
- string = g_strjoinv(" ", strings);
- break;
- case 2:
- string = g_strdup(company);
- break;
- case 3: /* Fall Through */
- case 4:
- stringptr = strings;
- if (name->family && *name->family)
- *(stringptr++) = name->family;
- if (name->given && *name->given)
- *(stringptr++) = name->given;
- *stringptr = NULL;
- substring = g_strjoinv(", ", strings);
- if (!(company && *company))
- company = "";
- if (style == 3)
- string = g_strdup_printf("%s (%s)", substring, company);
- else
- string = g_strdup_printf("%s (%s)", company, substring);
- g_free(substring);
- break;
- default:
- string = g_strdup("");
- }
- return string;
-}
-
-static int
-file_as_get_style (ECardSimple *simple)
-{
- char *filestring = e_card_simple_get(simple, E_CARD_SIMPLE_FIELD_FILE_AS);
- char *trystring;
- char *company = e_card_simple_get(simple, E_CARD_SIMPLE_FIELD_ORG);
- ECardName *name = NULL;
- int i;
- int style;
- style = 0;
- if (!company)
- company = g_strdup("");
- if (filestring) {
- gtk_object_get (GTK_OBJECT (simple->card),
- "name", &name,
- NULL);
-
- if (!name) {
- goto end;
- }
-
- style = -1;
-
- for (i = 0; i < 5; i++) {
- trystring = name_to_style(name, company, i);
- if (!strcmp(trystring, filestring)) {
- g_free(trystring);
- style = i;
- goto end;
- }
- g_free(trystring);
- }
- }
- end:
-
- g_free(filestring);
- g_free(company);
-
- return style;
-}
-
-static void
-file_as_set_style(ECardSimple *simple, int style)
-{
- if (style != -1) {
- char *string;
- char *company = e_card_simple_get(simple, E_CARD_SIMPLE_FIELD_ORG);
- ECardName *name;
-
- if (!company)
- company = g_strdup("");
- gtk_object_get (GTK_OBJECT (simple->card),
- "name", &name,
- NULL);
- if (name) {
- string = name_to_style(name, company, style);
- e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_FILE_AS, string);
- g_free(string);
- }
- g_free(company);
- }
-}
-
-void e_card_simple_set (ECardSimple *simple,
- ECardSimpleField field,
- const char *data)
-{
- ECardSimpleInternalType type = field_data[field].type;
- ECardAddrLabel *address;
- ECardPhone *phone;
- int style;
- simple->changed = TRUE;
- switch (field) {
- case E_CARD_SIMPLE_FIELD_FULL_NAME:
- case E_CARD_SIMPLE_FIELD_ORG:
- style = file_as_get_style(simple);
- gtk_object_set(GTK_OBJECT(simple->card),
- field_data[field].ecard_field, data,
- NULL);
- file_as_set_style(simple, style);
- break;
- default:
- switch(type) {
- case E_CARD_SIMPLE_INTERNAL_TYPE_STRING:
- gtk_object_set(GTK_OBJECT(simple->card),
- field_data[field].ecard_field, data,
- NULL);
- break;
- case E_CARD_SIMPLE_INTERNAL_TYPE_DATE:
- break; /* FIXME!!!! */
- case E_CARD_SIMPLE_INTERNAL_TYPE_ADDRESS:
- address = e_card_address_label_new();
- address->data = g_strdup (data);
- e_card_simple_set_address(simple,
- field_data[field].list_type_index,
- address);
- e_card_address_label_unref(address);
- break;
- case E_CARD_SIMPLE_INTERNAL_TYPE_PHONE:
- phone = e_card_phone_new();
- phone->number = g_strdup (data);
- e_card_simple_set_phone(simple,
- field_data[field].list_type_index,
- phone);
- e_card_phone_unref(phone);
- break;
- case E_CARD_SIMPLE_INTERNAL_TYPE_EMAIL:
- e_card_simple_set_email(simple,
- field_data[field].list_type_index,
- data);
- break;
- case E_CARD_SIMPLE_INTERNAL_TYPE_SPECIAL:
- break;
- case E_CARD_SIMPLE_INTERNAL_TYPE_BOOL:
- if (simple->card) {
- gboolean boole = TRUE;
- if (data == NULL)
- boole = FALSE;
- else if (!strcasecmp (data, "false"))
- boole = FALSE;
- gtk_object_set (GTK_OBJECT (simple->card),
- field_data[field].ecard_field, boole,
- NULL);
- }
- break;
- }
- break;
- }
-}
-
-ECardSimpleType e_card_simple_type (ECardSimple *simple,
- ECardSimpleField field)
-{
- ECardSimpleInternalType type = field_data[field].type;
- switch(type) {
- case E_CARD_SIMPLE_INTERNAL_TYPE_STRING:
- case E_CARD_SIMPLE_INTERNAL_TYPE_ADDRESS:
- case E_CARD_SIMPLE_INTERNAL_TYPE_PHONE:
- case E_CARD_SIMPLE_INTERNAL_TYPE_EMAIL:
- default:
- return E_CARD_SIMPLE_TYPE_STRING;
-
- case E_CARD_SIMPLE_INTERNAL_TYPE_BOOL:
- return E_CARD_SIMPLE_TYPE_BOOL;
-
- case E_CARD_SIMPLE_INTERNAL_TYPE_DATE:
- return E_CARD_SIMPLE_TYPE_DATE;
-
- case E_CARD_SIMPLE_INTERNAL_TYPE_SPECIAL:
- return E_CARD_SIMPLE_TYPE_STRING;
- }
-}
-
-const char *e_card_simple_get_ecard_field (ECardSimple *simple,
- ECardSimpleField field)
-{
- return field_data[field].ecard_field;
-}
-
-const char *e_card_simple_get_name (ECardSimple *simple,
- ECardSimpleField field)
-{
- return U_(field_data[field].name);
-}
-
-gboolean
-e_card_simple_get_allow_newlines (ECardSimple *simple,
- ECardSimpleField field)
-{
- ECardSimpleInternalType type = field_data[field].type;
- switch(type) {
- case E_CARD_SIMPLE_INTERNAL_TYPE_STRING:
- case E_CARD_SIMPLE_INTERNAL_TYPE_PHONE:
- case E_CARD_SIMPLE_INTERNAL_TYPE_EMAIL:
- case E_CARD_SIMPLE_INTERNAL_TYPE_BOOL:
- case E_CARD_SIMPLE_INTERNAL_TYPE_DATE:
- case E_CARD_SIMPLE_INTERNAL_TYPE_SPECIAL:
- default:
- switch (field) {
- case E_CARD_SIMPLE_FIELD_NOTE:
- return TRUE;
- default:
- return FALSE;
- }
-
- case E_CARD_SIMPLE_INTERNAL_TYPE_ADDRESS:
- return TRUE;
- }
-}
-
-const char *e_card_simple_get_short_name (ECardSimple *simple,
- ECardSimpleField field)
-{
- return U_(field_data[field].short_name);
-}
-
-void e_card_simple_arbitrary_foreach (ECardSimple *simple,
- ECardSimpleArbitraryCallback *callback,
- gpointer closure)
-{
- if (simple->card) {
- EList *list;
- EIterator *iterator;
- gtk_object_get(GTK_OBJECT(simple->card),
- "arbitrary", &list,
- NULL);
- for (iterator = e_list_get_iterator(list); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
- const ECardArbitrary *arbitrary = e_iterator_get(iterator);
- if (callback)
- (*callback) (arbitrary, closure);
- }
- e_card_free_empty_lists (simple->card);
- }
-}
-
-const ECardArbitrary *e_card_simple_get_arbitrary (ECardSimple *simple,
- const char *key)
-{
- if (simple->card) {
- EList *list;
- EIterator *iterator;
- gtk_object_get(GTK_OBJECT(simple->card),
- "arbitrary", &list,
- NULL);
- for (iterator = e_list_get_iterator(list); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
- const ECardArbitrary *arbitrary = e_iterator_get(iterator);
- if (!strcasecmp(arbitrary->key, key))
- return arbitrary;
- }
- e_card_free_empty_lists (simple->card);
- }
- return NULL;
-}
-
-/* Any of these except key can be NULL */
-void e_card_simple_set_arbitrary (ECardSimple *simple,
- const char *key,
- const char *type,
- const char *value)
-{
- if (simple->card) {
- ECardArbitrary *new_arb;
- EList *list;
- EIterator *iterator;
-
- simple->changed = TRUE;
- gtk_object_get(GTK_OBJECT(simple->card),
- "arbitrary", &list,
- NULL);
- for (iterator = e_list_get_iterator(list); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
- const ECardArbitrary *arbitrary = e_iterator_get(iterator);
- if (!strcasecmp(arbitrary->key, key)) {
- new_arb = e_card_arbitrary_new();
- new_arb->key = g_strdup(key);
- new_arb->type = g_strdup(type);
- new_arb->value = g_strdup(value);
- e_iterator_set(iterator, new_arb);
- e_card_arbitrary_unref(new_arb);
- return;
- }
- }
- new_arb = e_card_arbitrary_new();
- new_arb->key = g_strdup(key);
- new_arb->type = g_strdup(type);
- new_arb->value = g_strdup(value);
- e_list_append(list, new_arb);
- e_card_arbitrary_unref(new_arb);
- }
-}
-
-void
-e_card_simple_set_name (ECardSimple *simple, ECardName *name)
-{
- int style;
- style = file_as_get_style(simple);
- gtk_object_set (GTK_OBJECT (simple->card),
- "name", name,
- NULL);
- file_as_set_style(simple, style);
-}
-
-/* These map between the individual list types and ECardSimpleField */
-ECardSimpleField
-e_card_simple_map_phone_to_field (ECardSimplePhoneId phone_id)
-{
- int i;
-
- g_return_val_if_fail (phone_id < E_CARD_SIMPLE_PHONE_ID_LAST, 0);
-
- for (i = 0; i < field_data_count; i ++)
- if (field_data[i].list_type_index == phone_id
- && field_data[i].type == E_CARD_SIMPLE_INTERNAL_TYPE_PHONE)
- return i;
-
- g_warning ("couldn't find phone id %d, returning 0 (which is almost assuredly incorrect)\n", phone_id);
-
- return 0;
-}
-
-ECardSimpleField
-e_card_simple_map_email_to_field (ECardSimpleEmailId email_id)
-{
- int i;
-
- g_return_val_if_fail (email_id < E_CARD_SIMPLE_EMAIL_ID_LAST, 0);
-
- for (i = 0; i < field_data_count; i ++)
- if (field_data[i].list_type_index == email_id
- && field_data[i].type == E_CARD_SIMPLE_INTERNAL_TYPE_EMAIL)
- return i;
-
- g_warning ("couldn't find email id %d, returning 0 (which is almost assuredly incorrect)\n", email_id);
- return 0;
-}
-
-ECardSimpleField
-e_card_simple_map_address_to_field (ECardSimpleAddressId address_id)
-{
- int i;
-
- g_return_val_if_fail (address_id < E_CARD_SIMPLE_ADDRESS_ID_LAST, 0);
-
- for (i = 0; i < field_data_count; i ++)
- if (field_data[i].list_type_index == address_id
- && field_data[i].type == E_CARD_SIMPLE_INTERNAL_TYPE_ADDRESS)
- return i;
-
- g_warning ("couldn't find address id %d, returning 0 (which is almost assuredly incorrect)\n", address_id);
- return 0;
-}
diff --git a/addressbook/backend/ebook/e-card-simple.h b/addressbook/backend/ebook/e-card-simple.h
deleted file mode 100644
index f0a5b2d613..0000000000
--- a/addressbook/backend/ebook/e-card-simple.h
+++ /dev/null
@@ -1,233 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- * Arturo Espinosa
- * Nat Friedman (nat@ximian.com)
- *
- * Copyright (C) 2000 Ximian, Inc.
- * Copyright (C) 1999 The Free Software Foundation
- */
-
-#ifndef __E_CARD_SIMPLE_H__
-#define __E_CARD_SIMPLE_H__
-
-#include <time.h>
-#include <gtk/gtk.h>
-#include <stdio.h>
-#include <addressbook/backend/ebook/e-card.h>
-#include <addressbook/backend/ebook/e-card-types.h>
-#include <e-util/e-list.h>
-
-#define E_TYPE_CARD_SIMPLE (e_card_simple_get_type ())
-#define E_CARD_SIMPLE(obj) (GTK_CHECK_CAST ((obj), E_TYPE_CARD_SIMPLE, ECardSimple))
-#define E_CARD_SIMPLE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_CARD_SIMPLE, ECardSimpleClass))
-#define E_IS_CARD_SIMPLE(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_CARD_SIMPLE))
-#define E_IS_CARD_SIMPLE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_CARD_SIMPLE))
-
-typedef enum _ECardSimplePhoneId ECardSimplePhoneId;
-typedef enum _ECardSimpleEmailId ECardSimpleEmailId;
-typedef enum _ECardSimpleAddressId ECardSimpleAddressId;
-typedef enum _ECardSimpleType ECardSimpleType;
-typedef enum _ECardSimpleField ECardSimpleField;
-
-enum _ECardSimplePhoneId {
- E_CARD_SIMPLE_PHONE_ID_ASSISTANT,
- E_CARD_SIMPLE_PHONE_ID_BUSINESS,
- E_CARD_SIMPLE_PHONE_ID_BUSINESS_2,
- E_CARD_SIMPLE_PHONE_ID_BUSINESS_FAX,
- E_CARD_SIMPLE_PHONE_ID_CALLBACK,
- E_CARD_SIMPLE_PHONE_ID_CAR,
- E_CARD_SIMPLE_PHONE_ID_COMPANY,
- E_CARD_SIMPLE_PHONE_ID_HOME,
- E_CARD_SIMPLE_PHONE_ID_HOME_2,
- E_CARD_SIMPLE_PHONE_ID_HOME_FAX,
- E_CARD_SIMPLE_PHONE_ID_ISDN,
- E_CARD_SIMPLE_PHONE_ID_MOBILE,
- E_CARD_SIMPLE_PHONE_ID_OTHER,
- E_CARD_SIMPLE_PHONE_ID_OTHER_FAX,
- E_CARD_SIMPLE_PHONE_ID_PAGER,
- E_CARD_SIMPLE_PHONE_ID_PRIMARY,
- E_CARD_SIMPLE_PHONE_ID_RADIO,
- E_CARD_SIMPLE_PHONE_ID_TELEX,
- E_CARD_SIMPLE_PHONE_ID_TTYTDD,
- E_CARD_SIMPLE_PHONE_ID_LAST
-};
-
-/* We need HOME and WORK email addresses here. */
-enum _ECardSimpleEmailId {
- E_CARD_SIMPLE_EMAIL_ID_EMAIL,
- E_CARD_SIMPLE_EMAIL_ID_EMAIL_2,
- E_CARD_SIMPLE_EMAIL_ID_EMAIL_3,
- E_CARD_SIMPLE_EMAIL_ID_LAST
-};
-
-/* Should this include (BILLING/SHIPPING)? */
-enum _ECardSimpleAddressId {
- E_CARD_SIMPLE_ADDRESS_ID_BUSINESS,
- E_CARD_SIMPLE_ADDRESS_ID_HOME,
- E_CARD_SIMPLE_ADDRESS_ID_OTHER,
- E_CARD_SIMPLE_ADDRESS_ID_LAST
-};
-
-enum _ECardSimpleType {
- E_CARD_SIMPLE_TYPE_STRING,
- E_CARD_SIMPLE_TYPE_DATE,
- E_CARD_SIMPLE_TYPE_BOOL,
-};
-
-enum _ECardSimpleField {
- E_CARD_SIMPLE_FIELD_FILE_AS,
- E_CARD_SIMPLE_FIELD_FULL_NAME,
- E_CARD_SIMPLE_FIELD_EMAIL,
- E_CARD_SIMPLE_FIELD_PHONE_PRIMARY,
- E_CARD_SIMPLE_FIELD_PHONE_ASSISTANT,
- E_CARD_SIMPLE_FIELD_PHONE_BUSINESS,
- E_CARD_SIMPLE_FIELD_PHONE_CALLBACK,
- E_CARD_SIMPLE_FIELD_PHONE_COMPANY,
- E_CARD_SIMPLE_FIELD_PHONE_HOME,
- E_CARD_SIMPLE_FIELD_ORG,
- E_CARD_SIMPLE_FIELD_ADDRESS_BUSINESS,
- E_CARD_SIMPLE_FIELD_ADDRESS_HOME,
- E_CARD_SIMPLE_FIELD_PHONE_MOBILE,
- E_CARD_SIMPLE_FIELD_PHONE_CAR,
- E_CARD_SIMPLE_FIELD_PHONE_BUSINESS_FAX,
- E_CARD_SIMPLE_FIELD_PHONE_HOME_FAX,
- E_CARD_SIMPLE_FIELD_PHONE_BUSINESS_2,
- E_CARD_SIMPLE_FIELD_PHONE_HOME_2,
- E_CARD_SIMPLE_FIELD_PHONE_ISDN,
- E_CARD_SIMPLE_FIELD_PHONE_OTHER,
- E_CARD_SIMPLE_FIELD_PHONE_OTHER_FAX,
- E_CARD_SIMPLE_FIELD_PHONE_PAGER,
- E_CARD_SIMPLE_FIELD_PHONE_RADIO,
- E_CARD_SIMPLE_FIELD_PHONE_TELEX,
- E_CARD_SIMPLE_FIELD_PHONE_TTYTDD,
- E_CARD_SIMPLE_FIELD_ADDRESS_OTHER,
- E_CARD_SIMPLE_FIELD_EMAIL_2,
- E_CARD_SIMPLE_FIELD_EMAIL_3,
- E_CARD_SIMPLE_FIELD_URL,
- E_CARD_SIMPLE_FIELD_ORG_UNIT,
- E_CARD_SIMPLE_FIELD_OFFICE,
- E_CARD_SIMPLE_FIELD_TITLE,
- E_CARD_SIMPLE_FIELD_ROLE,
- E_CARD_SIMPLE_FIELD_MANAGER,
- E_CARD_SIMPLE_FIELD_ASSISTANT,
- E_CARD_SIMPLE_FIELD_NICKNAME,
- E_CARD_SIMPLE_FIELD_SPOUSE,
- E_CARD_SIMPLE_FIELD_NOTE,
- E_CARD_SIMPLE_FIELD_CALURI,
- E_CARD_SIMPLE_FIELD_FBURL,
- /* If you add after FBURL, make sure to move LAST_SIMPLE_STRING */
- E_CARD_SIMPLE_FIELD_LAST_SIMPLE_STRING = E_CARD_SIMPLE_FIELD_FBURL,
- E_CARD_SIMPLE_FIELD_ANNIVERSARY,
- E_CARD_SIMPLE_FIELD_BIRTH_DATE,
- E_CARD_SIMPLE_FIELD_MAILER,
- E_CARD_SIMPLE_FIELD_NAME_OR_ORG,
- E_CARD_SIMPLE_FIELD_CATEGORIES,
- E_CARD_SIMPLE_FIELD_FAMILY_NAME,
- E_CARD_SIMPLE_FIELD_GIVEN_NAME,
- E_CARD_SIMPLE_FIELD_ADDITIONAL_NAME,
- E_CARD_SIMPLE_FIELD_NAME_SUFFIX,
- E_CARD_SIMPLE_FIELD_WANTS_HTML,
- E_CARD_SIMPLE_FIELD_IS_LIST,
- E_CARD_SIMPLE_FIELD_LAST
-};
-
-typedef struct _ECardSimple ECardSimple;
-typedef struct _ECardSimpleClass ECardSimpleClass;
-
-struct _ECardSimple {
- GtkObject object;
- ECard *card;
-
- GList *temp_fields;
-
- ECardPhone *phone[E_CARD_SIMPLE_PHONE_ID_LAST];
- char *email[E_CARD_SIMPLE_EMAIL_ID_LAST];
- ECardAddrLabel *address[E_CARD_SIMPLE_ADDRESS_ID_LAST];
- ECardDeliveryAddress *delivery[E_CARD_SIMPLE_ADDRESS_ID_LAST];
-
- gboolean changed;
-};
-
-struct _ECardSimpleClass {
- GtkObjectClass parent_class;
-};
-
-typedef void (*ECardSimpleArbitraryCallback) (const ECardArbitrary *arbitrary, gpointer closure);
-ECardSimple *e_card_simple_new (ECard *card);
-const char *e_card_simple_get_id (ECardSimple *simple);
-void e_card_simple_set_id (ECardSimple *simple,
- const gchar *character);
-char *e_card_simple_get_vcard (ECardSimple *simple);
-char *e_card_simple_get_vcard_assume_utf8 (ECardSimple *simple);
-ECardSimple *e_card_simple_duplicate (ECardSimple *simple);
-char *e_card_simple_get (ECardSimple *simple,
- ECardSimpleField field);
-const char *e_card_simple_get_const (ECardSimple *simple,
- ECardSimpleField field);
-void e_card_simple_set (ECardSimple *simple,
- ECardSimpleField field,
- const char *data);
-ECardSimpleType e_card_simple_type (ECardSimple *simple,
- ECardSimpleField field);
-
-const char *e_card_simple_get_ecard_field (ECardSimple *simple,
- ECardSimpleField field);
-const char *e_card_simple_get_name (ECardSimple *simple,
- ECardSimpleField field);
-const char *e_card_simple_get_short_name (ECardSimple *simple,
- ECardSimpleField field);
-gboolean e_card_simple_get_allow_newlines (ECardSimple *simple,
- ECardSimpleField field);
-
-
-/* Use these only if building lists of specific types. It should be
- * easier to use the above if you consider a phone field to be the
- * same as any other field.
- */
-const ECardPhone *e_card_simple_get_phone (ECardSimple *simple,
- ECardSimplePhoneId id);
-const char *e_card_simple_get_email (ECardSimple *simple,
- ECardSimpleEmailId id);
-const ECardAddrLabel *e_card_simple_get_address (ECardSimple *simple,
- ECardSimpleAddressId id);
-const ECardDeliveryAddress *e_card_simple_get_delivery_address (ECardSimple *simple,
- ECardSimpleAddressId id);
-void e_card_simple_set_phone (ECardSimple *simple,
- ECardSimplePhoneId id,
- const ECardPhone *phone);
-void e_card_simple_set_email (ECardSimple *simple,
- ECardSimpleEmailId id,
- const char *email);
-void e_card_simple_set_address (ECardSimple *simple,
- ECardSimpleAddressId id,
- const ECardAddrLabel *address);
-void e_card_simple_set_delivery_address (ECardSimple *simple,
- ECardSimpleAddressId id,
- const ECardDeliveryAddress *delivery);
-void e_card_simple_arbitrary_foreach (ECardSimple *simple,
- ECardSimpleArbitraryCallback *callback,
- gpointer closure);
-const ECardArbitrary *e_card_simple_get_arbitrary (ECardSimple *simple,
- const char *key);
-/* Any of these except key can be NULL */
-void e_card_simple_set_arbitrary (ECardSimple *simple,
- const char *key,
- const char *type,
- const char *value);
-void e_card_simple_set_name (ECardSimple *simple,
- ECardName *name);
-void e_card_simple_sync_card (ECardSimple *simple);
-
-/* These map between the individual list types and ECardSimpleField */
-ECardSimpleField e_card_simple_map_phone_to_field (ECardSimplePhoneId phone_id);
-ECardSimpleField e_card_simple_map_email_to_field (ECardSimpleEmailId email_id);
-ECardSimpleField e_card_simple_map_address_to_field (ECardSimpleAddressId address_id);
-
-/* Standard Gtk function */
-GtkType e_card_simple_get_type (void);
-
-#endif /* ! __E_CARD_SIMPLE_H__ */
-
-
diff --git a/addressbook/backend/ebook/e-card-types.h b/addressbook/backend/ebook/e-card-types.h
deleted file mode 100644
index 8d35c54924..0000000000
--- a/addressbook/backend/ebook/e-card-types.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors:
- * Arturo Espinosa
- * Nat Friedman (nat@ximian.com)
- *
- * Copyright (C) 2000 Ximian, Inc.
- * Copyright (C) 1999 The Free Software Foundation
- */
-
-#ifndef __E_CARD_TYPES_H__
-#define __E_CARD_TYPES_H__
-
-/* IDENTIFICATION PROPERTIES */
-
-typedef struct {
- gint ref_count;
- char *prefix; /* Mr. */
- char *given; /* John */
- char *additional; /* Quinlan */
- char *family; /* Public */
- char *suffix; /* Esq. */
-} ECardName;
-
-typedef struct {
- int year;
- int month;
- int day;
-} ECardDate;
-
-/* TELECOMMUNICATIONS ADDRESSING PROPERTIES */
-
-typedef enum {
- E_CARD_PHONE_PREF = 1 << 0,
- E_CARD_PHONE_WORK = 1 << 1,
- E_CARD_PHONE_HOME = 1 << 2,
- E_CARD_PHONE_VOICE = 1 << 3,
- E_CARD_PHONE_FAX = 1 << 4,
- E_CARD_PHONE_MSG = 1 << 5,
- E_CARD_PHONE_CELL = 1 << 6,
- E_CARD_PHONE_PAGER = 1 << 7,
- E_CARD_PHONE_BBS = 1 << 8,
- E_CARD_PHONE_MODEM = 1 << 9,
- E_CARD_PHONE_CAR = 1 << 10,
- E_CARD_PHONE_ISDN = 1 << 11,
- E_CARD_PHONE_VIDEO = 1 << 12,
- E_CARD_PHONE_ASSISTANT = 1 << 13,
- E_CARD_PHONE_CALLBACK = 1 << 14,
- E_CARD_PHONE_RADIO = 1 << 15,
- E_CARD_PHONE_TELEX = 1 << 16,
- E_CARD_PHONE_TTYTDD = 1 << 17,
-} ECardPhoneFlags;
-
-typedef struct {
- gint ref_count;
- ECardPhoneFlags flags;
- char *number;
-} ECardPhone;
-
-/* DELIVERY ADDRESSING PROPERTIES */
-
-typedef enum {
- E_CARD_ADDR_HOME = 1 << 0,
- E_CARD_ADDR_WORK = 1 << 1,
- E_CARD_ADDR_POSTAL = 1 << 2,
- E_CARD_ADDR_MASK = 7,
- E_CARD_ADDR_PARCEL = 1 << 3,
- E_CARD_ADDR_DOM = 1 << 4,
- E_CARD_ADDR_INTL = 1 << 5,
- E_CARD_ADDR_DEFAULT = 1 << 6
-} ECardAddressFlags;
-
-typedef struct {
- gint ref_count;
- ECardAddressFlags flags;
-
- char *po;
- char *ext;
- char *street;
- char *city;
- char *region;
- char *code;
- char *country;
-} ECardDeliveryAddress;
-
-typedef struct {
- gint ref_count;
- ECardAddressFlags flags;
- char *data;
-} ECardAddrLabel;
-
-/* ARBITRARY PROPERTIES */
-
-typedef struct {
- gint ref_count;
- char *key;
- char *type;
- char *value;
-} ECardArbitrary;
-
-#endif /* __E_CARD_TYPES_H__ */
diff --git a/addressbook/backend/ebook/e-card.c b/addressbook/backend/ebook/e-card.c
deleted file mode 100644
index 4fd0bb623d..0000000000
--- a/addressbook/backend/ebook/e-card.c
+++ /dev/null
@@ -1,2857 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors:
- * Arturo Espinosa (arturo@nuclecu.unam.mx)
- * Nat Friedman (nat@ximian.com)
- *
- * Copyright (C) 2000 Ximian, Inc.
- * Copyright (C) 1999 The Free Software Foundation
- */
-
-#include <config.h>
-
-#include "e-card.h"
-
-#include <gal/util/e-i18n.h>
-#include <gal/widgets/e-unicode.h>
-
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <math.h>
-
-#include <gtk/gtkobject.h>
-#include <bonobo/bonobo-object-client.h>
-#include <gal/util/e-util.h>
-
-#include <libversit/vcc.h>
-#include "e-util/ename/e-name-western.h"
-#include "e-util/ename/e-address-western.h"
-#include "e-book.h"
-#include "e-destination.h"
-
-#define is_a_prop_of(obj,prop) (isAPropertyOf ((obj),(prop)))
-#define str_val(obj) (the_str = (vObjectValueType (obj))? fakeCString (vObjectUStringZValue (obj)) : calloc (1, 1))
-#define has(obj,prop) (vo = isAPropertyOf ((obj), (prop)))
-
-#define XEV_WANTS_HTML "X-MOZILLA-HTML"
-#define XEV_ARBITRARY "X-EVOLUTION-ARBITRARY"
-#define XEV_LIST "X-EVOLUTION-LIST"
-#define XEV_LIST_SHOW_ADDRESSES "X-EVOLUTION-LIST-SHOW_ADDRESSES"
-#define XEV_RELATED_CONTACTS "X-EVOLUTION-RELATED_CONTACTS"
-
-/* Object argument IDs */
-enum {
- ARG_0,
- ARG_FILE_AS,
- ARG_FULL_NAME,
- ARG_NAME,
- ARG_ADDRESS,
- ARG_ADDRESS_LABEL,
- ARG_PHONE,
- ARG_EMAIL,
- ARG_BIRTH_DATE,
- ARG_URL,
- ARG_ORG,
- ARG_ORG_UNIT,
- ARG_OFFICE,
- ARG_TITLE,
- ARG_ROLE,
- ARG_MANAGER,
- ARG_ASSISTANT,
- ARG_NICKNAME,
- ARG_SPOUSE,
- ARG_ANNIVERSARY,
- ARG_MAILER,
- ARG_CALURI,
- ARG_FBURL,
- ARG_NOTE,
- ARG_RELATED_CONTACTS,
- ARG_CATEGORIES,
- ARG_CATEGORY_LIST,
- ARG_WANTS_HTML,
- ARG_WANTS_HTML_SET,
- ARG_EVOLUTION_LIST,
- ARG_EVOLUTION_LIST_SHOW_ADDRESSES,
- ARG_ARBITRARY,
- ARG_ID,
- ARG_LAST_USE,
- ARG_USE_SCORE,
-};
-
-static void parse(ECard *card, VObject *vobj, char *default_charset);
-static void e_card_init (ECard *card);
-static void e_card_class_init (ECardClass *klass);
-
-static void e_card_destroy (GtkObject *object);
-static void e_card_set_arg (GtkObject *object, GtkArg *arg, guint arg_id);
-static void e_card_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
-
-static void assign_string(VObject *vobj, char *default_charset, char **string);
-
-char *e_v_object_get_child_value(VObject *vobj, char *name, char *default_charset);
-
-static void parse_bday(ECard *card, VObject *object, char *default_charset);
-static void parse_full_name(ECard *card, VObject *object, char *default_charset);
-static void parse_file_as(ECard *card, VObject *object, char *default_charset);
-static void parse_name(ECard *card, VObject *object, char *default_charset);
-static void parse_email(ECard *card, VObject *object, char *default_charset);
-static void parse_phone(ECard *card, VObject *object, char *default_charset);
-static void parse_address(ECard *card, VObject *object, char *default_charset);
-static void parse_address_label(ECard *card, VObject *object, char *default_charset);
-static void parse_url(ECard *card, VObject *object, char *default_charset);
-static void parse_org(ECard *card, VObject *object, char *default_charset);
-static void parse_office(ECard *card, VObject *object, char *default_charset);
-static void parse_title(ECard *card, VObject *object, char *default_charset);
-static void parse_role(ECard *card, VObject *object, char *default_charset);
-static void parse_manager(ECard *card, VObject *object, char *default_charset);
-static void parse_assistant(ECard *card, VObject *object, char *default_charset);
-static void parse_nickname(ECard *card, VObject *object, char *default_charset);
-static void parse_spouse(ECard *card, VObject *object, char *default_charset);
-static void parse_anniversary(ECard *card, VObject *object, char *default_charset);
-static void parse_mailer(ECard *card, VObject *object, char *default_charset);
-static void parse_caluri(ECard *card, VObject *object, char *default_charset);
-static void parse_fburl(ECard *card, VObject *object, char *default_charset);
-static void parse_note(ECard *card, VObject *object, char *default_charset);
-static void parse_related_contacts(ECard *card, VObject *object, char *default_charset);
-static void parse_categories(ECard *card, VObject *object, char *default_charset);
-static void parse_wants_html(ECard *card, VObject *object, char *default_charset);
-static void parse_list(ECard *card, VObject *object, char *default_charset);
-static void parse_list_show_addresses(ECard *card, VObject *object, char *default_charset);
-static void parse_arbitrary(ECard *card, VObject *object, char *default_charset);
-static void parse_id(ECard *card, VObject *object, char *default_charset);
-static void parse_last_use(ECard *card, VObject *object, char *default_charset);
-static void parse_use_score(ECard *card, VObject *object, char *default_charset);
-
-static ECardPhoneFlags get_phone_flags (VObject *vobj);
-static void set_phone_flags (VObject *vobj, ECardPhoneFlags flags);
-static ECardAddressFlags get_address_flags (VObject *vobj);
-static void set_address_flags (VObject *vobj, ECardAddressFlags flags);
-
-typedef void (* ParsePropertyFunc) (ECard *card, VObject *object, char *default_charset);
-
-struct {
- char *key;
- ParsePropertyFunc function;
-} attribute_jump_array[] =
-{
- { VCFullNameProp, parse_full_name },
- { "X-EVOLUTION-FILE-AS", parse_file_as },
- { VCNameProp, parse_name },
- { VCBirthDateProp, parse_bday },
- { VCEmailAddressProp, parse_email },
- { VCTelephoneProp, parse_phone },
- { VCAdrProp, parse_address },
- { VCDeliveryLabelProp, parse_address_label },
- { VCURLProp, parse_url },
- { VCOrgProp, parse_org },
- { "X-EVOLUTION-OFFICE", parse_office },
- { VCTitleProp, parse_title },
- { VCBusinessRoleProp, parse_role },
- { "X-EVOLUTION-MANAGER", parse_manager },
- { "X-EVOLUTION-ASSISTANT", parse_assistant },
- { "NICKNAME", parse_nickname },
- { "X-EVOLUTION-SPOUSE", parse_spouse },
- { "X-EVOLUTION-ANNIVERSARY", parse_anniversary },
- { VCMailerProp, parse_mailer },
- { "CALURI", parse_caluri },
- { "FBURL", parse_fburl },
- { VCNoteProp, parse_note },
- { XEV_RELATED_CONTACTS, parse_related_contacts },
- { "CATEGORIES", parse_categories },
- { XEV_WANTS_HTML, parse_wants_html },
- { XEV_ARBITRARY, parse_arbitrary },
- { VCUniqueStringProp, parse_id },
- { "X-EVOLUTION-LAST-USE", parse_last_use },
- { "X-EVOLUTION-USE-SCORE", parse_use_score },
- { XEV_LIST, parse_list },
- { XEV_LIST_SHOW_ADDRESSES, parse_list_show_addresses },
- { VCUniqueStringProp, parse_id }
-};
-
-/**
- * e_card_get_type:
- * @void:
- *
- * Registers the &ECard class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: The type ID of the &ECard class.
- **/
-GtkType
-e_card_get_type (void)
-{
- static GtkType card_type = 0;
-
- if (!card_type) {
- GtkTypeInfo card_info = {
- "ECard",
- sizeof (ECard),
- sizeof (ECardClass),
- (GtkClassInitFunc) e_card_class_init,
- (GtkObjectInitFunc) e_card_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- card_type = gtk_type_unique (gtk_object_get_type (), &card_info);
- }
-
- return card_type;
-}
-
-ECard *
-e_card_new_with_default_charset (char *vcard, char *default_charset)
-{
- ECard *card = E_CARD(gtk_type_new(e_card_get_type()));
- VObject *vobj = Parse_MIME(vcard, strlen(vcard));
- while(vobj) {
- VObject *next;
- parse(card, vobj, default_charset);
- next = nextVObjectInList(vobj);
- cleanVObject(vobj);
- vobj = next;
- }
- if (card->name == NULL)
- card->name = e_card_name_new();
- if (card->file_as == NULL)
- card->file_as = g_strdup("");
- if (card->fname == NULL)
- card->fname = g_strdup("");
- return card;
-}
-
-/**
- * e_card_new:
- * @vcard: a string in vCard format
- *
- * Returns: a new #ECard that wraps the @vcard.
- */
-ECard *
-e_card_new (char *vcard)
-{
- return e_card_new_with_default_charset (vcard, "UTF-8");
-}
-
-ECard *
-e_card_duplicate(ECard *card)
-{
- char *vcard = e_card_get_vcard_assume_utf8(card);
- ECard *new_card = e_card_new(vcard);
- g_free (vcard);
-
- if (card->book) {
- new_card->book = card->book;
- gtk_object_ref (GTK_OBJECT (new_card->book));
- }
-
- return new_card;
-}
-
-static void
-e_card_get_today (GDate *dt)
-{
- time_t now;
- struct tm *now_tm;
- if (dt == NULL)
- return;
-
- time (&now);
- now_tm = localtime (&now);
-
- g_date_set_dmy (dt, now_tm->tm_mday, now_tm->tm_mon + 1, now_tm->tm_year + 1900);
-}
-
-float
-e_card_get_use_score(ECard *card)
-{
- GDate today, last_use;
- gint days_since_last_use;
-
- g_return_val_if_fail (card != NULL && E_IS_CARD (card), 0);
-
- if (card->last_use == NULL)
- return 0.0;
-
- e_card_get_today (&today);
- g_date_set_dmy (&last_use, card->last_use->day, card->last_use->month, card->last_use->year);
-
- days_since_last_use = g_date_julian (&today) - g_date_julian (&last_use);
-
- /* Apply a seven-day "grace period" to the use score decay. */
- days_since_last_use -= 7;
- if (days_since_last_use < 0)
- days_since_last_use = 0;
-
- return MAX (card->raw_use_score, 0) * exp (- days_since_last_use / 30.0);
-}
-
-void
-e_card_touch(ECard *card)
-{
- GDate today;
- double use_score;
-
- g_return_if_fail (card != NULL && E_IS_CARD (card));
-
- e_card_get_today (&today);
- use_score = e_card_get_use_score (card);
-
- if (card->last_use == NULL)
- card->last_use = g_new (ECardDate, 1);
-
- card->last_use->day = g_date_day (&today);
- card->last_use->month = g_date_month (&today);
- card->last_use->year = g_date_year (&today);
-
- card->raw_use_score = use_score + 1.0;
-}
-
-/**
- * e_card_get_id:
- * @card: an #ECard
- *
- * Returns: a string representing the id of the card, which is unique
- * within its book.
- */
-const char *
-e_card_get_id (ECard *card)
-{
- g_return_val_if_fail (card && E_IS_CARD (card), NULL);
-
- return card->id ? card->id : "";
-}
-
-/**
- * e_card_get_id:
- * @card: an #ECard
- * @id: a id in string format
- *
- * Sets the identifier of a card, which should be unique within its
- * book.
- */
-void
-e_card_set_id (ECard *card, const char *id)
-{
- g_return_if_fail (card && E_IS_CARD (card));
-
- if ( card->id )
- g_free(card->id);
- card->id = g_strdup(id ? id : "");
-}
-
-EBook *
-e_card_get_book (ECard *card)
-{
- g_return_val_if_fail (card && E_IS_CARD (card), NULL);
-
- return card->book;
-}
-
-void
-e_card_set_book (ECard *card, EBook *book)
-{
- g_return_if_fail (card && E_IS_CARD (card));
-
- if (card->book)
- gtk_object_unref (GTK_OBJECT (card->book));
- card->book = book;
- if (card->book)
- gtk_object_ref (GTK_OBJECT (card->book));
-}
-
-gchar *
-e_card_date_to_string (ECardDate *dt)
-{
- if (dt)
- return g_strdup_printf ("%04d-%02d-%02d",
- CLAMP(dt->year, 1000, 9999),
- CLAMP(dt->month, 1, 12),
- CLAMP(dt->day, 1, 31));
- else
- return NULL;
-}
-
-static VObject *
-addPropValueUTF8(VObject *o, const char *p, const char *v)
-{
- VObject *prop = addPropValue (o, p, v);
- for (; *v; v++) {
- if ((*v) & 0x80) {
- addPropValue (prop, "CHARSET", "UTF-8");
- for (; *v; v++) {
- if (*v == '\n') {
- addProp(prop, VCQuotedPrintableProp);
- return prop;
- }
- }
- return prop;
- }
- if (*v == '\n') {
- addProp(prop, VCQuotedPrintableProp);
- for (; *v; v++) {
- if ((*v) & 0x80) {
- addPropValue (prop, "CHARSET", "UTF-8");
- return prop;
- }
- }
- return prop;
- }
- }
- return prop;
-}
-
-static VObject *
-addPropValueQP(VObject *o, const char *p, const char *v)
-{
- VObject *prop = addPropValue (o, p, v);
- for (; *v; v++) {
- if (*v == '\n') {
- addProp(prop, VCQuotedPrintableProp);
- break;
- }
- }
- return prop;
-}
-
-static void
-addPropValueSets (VObject *o, const char *p, const char *v, gboolean assumeUTF8, gboolean *is_ascii, gboolean *has_return)
-{
- addPropValue (o, p, v);
- if (*has_return && (assumeUTF8 || !*is_ascii))
- return;
- if (*has_return) {
- for (; *v; v++) {
- if (*v & 0x80) {
- *is_ascii = FALSE;
- return;
- }
- }
- return;
- }
- if (assumeUTF8 || !*is_ascii) {
- for (; *v; v++) {
- if (*v == '\n') {
- *has_return = TRUE;
- return;
- }
- }
- return;
- }
- for (; *v; v++) {
- if (*v & 0x80) {
- *is_ascii = FALSE;
- for (; *v; v++) {
- if (*v == '\n') {
- *has_return = TRUE;
- return;
- }
- }
- return;
- }
- if (*v == '\n') {
- *has_return = TRUE;
- for (; *v; v++) {
- if (*v & 0x80) {
- *is_ascii = FALSE;
- return;
- }
- }
- return;
- }
- }
- return;
-}
-
-#define ADD_PROP_VALUE(o, p, v) (assumeUTF8 ? (addPropValueQP ((o), (p), (v))) : addPropValueUTF8 ((o), (p), (v)))
-#define ADD_PROP_VALUE_SET_IS_ASCII(o, p, v) (addPropValueSets ((o), (p), (v), assumeUTF8, &is_ascii, &has_return))
-
-
-static VObject *
-e_card_get_vobject (const ECard *card, gboolean assumeUTF8)
-{
- VObject *vobj;
-
- vobj = newVObject (VCCardProp);
-
- if (card->file_as && *card->file_as)
- ADD_PROP_VALUE(vobj, "X-EVOLUTION-FILE-AS", card->file_as);
- else if (card->file_as)
- addProp(vobj, "X-EVOLUTION-FILE_AS");
-
- if (card->fname && *card->fname)
- ADD_PROP_VALUE(vobj, VCFullNameProp, card->fname);
- else if (card->fname)
- addProp(vobj, VCFullNameProp);
-
- if ( card->name && (card->name->prefix || card->name->given || card->name->additional || card->name->family || card->name->suffix) ) {
- VObject *nameprop;
- gboolean is_ascii = TRUE;
- gboolean has_return = FALSE;
- nameprop = addProp(vobj, VCNameProp);
- if ( card->name->prefix )
- ADD_PROP_VALUE_SET_IS_ASCII(nameprop, VCNamePrefixesProp, card->name->prefix);
- if ( card->name->given )
- ADD_PROP_VALUE_SET_IS_ASCII(nameprop, VCGivenNameProp, card->name->given);
- if ( card->name->additional )
- ADD_PROP_VALUE_SET_IS_ASCII(nameprop, VCAdditionalNamesProp, card->name->additional);
- if ( card->name->family )
- ADD_PROP_VALUE_SET_IS_ASCII(nameprop, VCFamilyNameProp, card->name->family);
- if ( card->name->suffix )
- ADD_PROP_VALUE_SET_IS_ASCII(nameprop, VCNameSuffixesProp, card->name->suffix);
- if (has_return)
- addProp(nameprop, VCQuotedPrintableProp);
- if (!(is_ascii || assumeUTF8))
- addPropValue (nameprop, "CHARSET", "UTF-8");
- }
- else if (card->name)
- addProp(vobj, VCNameProp);
-
-
- if ( card->address ) {
- EIterator *iterator = e_list_get_iterator(card->address);
- for ( ; e_iterator_is_valid(iterator) ;e_iterator_next(iterator) ) {
- VObject *addressprop;
- ECardDeliveryAddress *address = (ECardDeliveryAddress *) e_iterator_get(iterator);
- gboolean is_ascii = TRUE;
- gboolean has_return = FALSE;
-
- addressprop = addProp(vobj, VCAdrProp);
-
- set_address_flags (addressprop, address->flags);
- if (address->po)
- ADD_PROP_VALUE_SET_IS_ASCII(addressprop, VCPostalBoxProp, address->po);
- if (address->ext)
- ADD_PROP_VALUE_SET_IS_ASCII(addressprop, VCExtAddressProp, address->ext);
- if (address->street)
- ADD_PROP_VALUE_SET_IS_ASCII(addressprop, VCStreetAddressProp, address->street);
- if (address->city)
- ADD_PROP_VALUE_SET_IS_ASCII(addressprop, VCCityProp, address->city);
- if (address->region)
- ADD_PROP_VALUE_SET_IS_ASCII(addressprop, VCRegionProp, address->region);
- if (address->code)
- ADD_PROP_VALUE_SET_IS_ASCII(addressprop, VCPostalCodeProp, address->code);
- if (address->country)
- ADD_PROP_VALUE_SET_IS_ASCII(addressprop, VCCountryNameProp, address->country);
-
- if (has_return)
- addProp(addressprop, VCQuotedPrintableProp);
- if (!(is_ascii || assumeUTF8))
- addPropValue (addressprop, "CHARSET", "UTF-8");
- }
- gtk_object_unref(GTK_OBJECT(iterator));
- }
-
- if ( card->address_label ) {
- EIterator *iterator = e_list_get_iterator(card->address_label);
- for ( ; e_iterator_is_valid(iterator) ;e_iterator_next(iterator) ) {
- VObject *labelprop;
- ECardAddrLabel *address_label = (ECardAddrLabel *) e_iterator_get(iterator);
- if (address_label->data)
- labelprop = ADD_PROP_VALUE(vobj, VCDeliveryLabelProp, address_label->data);
- else
- labelprop = addProp(vobj, VCDeliveryLabelProp);
-
- set_address_flags (labelprop, address_label->flags);
- }
- gtk_object_unref(GTK_OBJECT(iterator));
- }
-
- if ( card->phone ) {
- EIterator *iterator = e_list_get_iterator(card->phone);
- for ( ; e_iterator_is_valid(iterator) ;e_iterator_next(iterator) ) {
- VObject *phoneprop;
- ECardPhone *phone = (ECardPhone *) e_iterator_get(iterator);
- phoneprop = ADD_PROP_VALUE(vobj, VCTelephoneProp, phone->number);
-
- set_phone_flags (phoneprop, phone->flags);
- }
- gtk_object_unref(GTK_OBJECT(iterator));
- }
-
- if ( card->email ) {
- EIterator *iterator = e_list_get_iterator(card->email);
- for ( ; e_iterator_is_valid(iterator) ;e_iterator_next(iterator) ) {
- VObject *emailprop;
- emailprop = ADD_PROP_VALUE(vobj, VCEmailAddressProp, (char *) e_iterator_get(iterator));
- addProp (emailprop, VCInternetProp);
- }
- gtk_object_unref(GTK_OBJECT(iterator));
- }
-
- if ( card->bday ) {
- char *value;
- value = e_card_date_to_string (card->bday);
- ADD_PROP_VALUE(vobj, VCBirthDateProp, value);
- g_free(value);
- }
-
- if (card->url)
- ADD_PROP_VALUE(vobj, VCURLProp, card->url);
-
- if (card->org || card->org_unit) {
- VObject *orgprop;
- gboolean is_ascii = TRUE;
- gboolean has_return = FALSE;
- orgprop = addProp(vobj, VCOrgProp);
-
- if (card->org)
- ADD_PROP_VALUE_SET_IS_ASCII(orgprop, VCOrgNameProp, card->org);
- if (card->org_unit)
- ADD_PROP_VALUE_SET_IS_ASCII(orgprop, VCOrgUnitProp, card->org_unit);
-
- if (has_return)
- addProp(orgprop, VCQuotedPrintableProp);
- if (!(is_ascii || assumeUTF8))
- addPropValue (orgprop, "CHARSET", "UTF-8");
- }
-
- if (card->office)
- ADD_PROP_VALUE(vobj, "X-EVOLUTION-OFFICE", card->office);
-
- if (card->title)
- ADD_PROP_VALUE(vobj, VCTitleProp, card->title);
-
- if (card->role)
- ADD_PROP_VALUE(vobj, VCBusinessRoleProp, card->role);
-
- if (card->manager)
- ADD_PROP_VALUE(vobj, "X-EVOLUTION-MANAGER", card->manager);
-
- if (card->assistant)
- ADD_PROP_VALUE(vobj, "X-EVOLUTION-ASSISTANT", card->assistant);
-
- if (card->nickname)
- ADD_PROP_VALUE(vobj, "NICKNAME", card->nickname);
-
- if (card->spouse)
- ADD_PROP_VALUE(vobj, "X-EVOLUTION-SPOUSE", card->spouse);
-
- if ( card->anniversary ) {
- char *value;
- value = e_card_date_to_string (card->anniversary);
- ADD_PROP_VALUE(vobj, "X-EVOLUTION-ANNIVERSARY", value);
- g_free(value);
- }
-
- if (card->mailer) {
- ADD_PROP_VALUE(vobj, VCMailerProp, card->mailer);
- }
-
- if (card->caluri)
- addPropValueQP(vobj, "CALURI", card->caluri);
-
- if (card->fburl)
- ADD_PROP_VALUE(vobj, "FBURL", card->fburl);
-
- if (card->note) {
- VObject *noteprop;
-
- noteprop = ADD_PROP_VALUE(vobj, VCNoteProp, card->note);
- }
-
- if (card->last_use) {
- char *value;
- value = e_card_date_to_string (card->last_use);
- ADD_PROP_VALUE (vobj, "X-EVOLUTION-LAST-USE", value);
- g_free (value);
- }
-
- if (card->raw_use_score > 0) {
- char *value;
- value = g_strdup_printf ("%f", card->raw_use_score);
- ADD_PROP_VALUE (vobj, "X-EVOLUTION-USE-SCORE", value);
- g_free (value);
- }
-
- if (card->related_contacts && *card->related_contacts) {
- ADD_PROP_VALUE(vobj, XEV_RELATED_CONTACTS, card->related_contacts);
- }
-
- if (card->categories) {
- EIterator *iterator;
- int length = 0;
- char *string;
- char *stringptr;
- for (iterator = e_list_get_iterator(card->categories); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
- length += strlen(e_iterator_get(iterator)) + 1;
- }
- string = g_new(char, length + 1);
- stringptr = string;
- *stringptr = 0;
- for (e_iterator_reset(iterator); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
- strcpy(stringptr, e_iterator_get(iterator));
- stringptr += strlen(stringptr);
- *stringptr = ',';
- stringptr++;
- *stringptr = 0;
- }
- if (stringptr > string) {
- stringptr --;
- *stringptr = 0;
- }
- ADD_PROP_VALUE (vobj, "CATEGORIES", string);
- g_free(string);
- }
-
- if (card->wants_html_set) {
- ADD_PROP_VALUE (vobj, XEV_WANTS_HTML, card->wants_html ? "TRUE" : "FALSE");
- }
-
- if (card->list) {
- ADD_PROP_VALUE (vobj, XEV_LIST, "TRUE");
- ADD_PROP_VALUE (vobj, XEV_LIST_SHOW_ADDRESSES, card->list_show_addresses ? "TRUE" : "FALSE");
- }
-
- if (card->arbitrary) {
- EIterator *iterator;
- for (iterator = e_list_get_iterator(card->arbitrary); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
- const ECardArbitrary *arbitrary = e_iterator_get(iterator);
- VObject *arb_object;
- if (arbitrary->value) {
- arb_object = ADD_PROP_VALUE (vobj, XEV_ARBITRARY, arbitrary->value);
- } else {
- arb_object = addProp (vobj, XEV_ARBITRARY);
- }
- if (arbitrary->type) {
- ADD_PROP_VALUE (arb_object, "TYPE", arbitrary->type);
- }
- if (arbitrary->key) {
- addProp (arb_object, arbitrary->key);
- }
- }
- }
-
- addPropValueQP (vobj, VCUniqueStringProp, (card->id ? card->id : ""));
-
- return vobj;
-}
-
-/**
- * e_card_get_vcard:
- * @card: an #ECard
- *
- * Returns: a string in vCard format, which is wrapped by the @card.
- */
-char *
-e_card_get_vcard (ECard *card)
-{
- VObject *vobj;
- char *temp, *ret_val;
-
- vobj = e_card_get_vobject (card, FALSE);
- temp = writeMemVObject(NULL, NULL, vobj);
- ret_val = g_strdup(temp);
- free(temp);
- cleanVObject(vobj);
- return ret_val;
-}
-
-char *
-e_card_get_vcard_assume_utf8 (ECard *card)
-{
- VObject *vobj;
- char *temp, *ret_val;
-
- vobj = e_card_get_vobject (card, TRUE);
- temp = writeMemVObject(NULL, NULL, vobj);
- ret_val = g_strdup(temp);
- free(temp);
- cleanVObject(vobj);
- return ret_val;
-}
-
-/**
- * e_card_list_get_vcard:
- * @list: a list of #ECards
- *
- * Returns: a string in vCard format.
- */
-char *
-e_card_list_get_vcard (const GList *list)
-{
- VObject *vobj;
-
- char *temp, *ret_val;
-
- vobj = NULL;
-
- for (; list; list = list->next) {
- VObject *tempvobj;
- ECard *card = list->data;
-
- tempvobj = e_card_get_vobject (card, FALSE);
- addList (&vobj, tempvobj);
- }
- temp = writeMemVObjects(NULL, NULL, vobj);
- ret_val = g_strdup(temp);
- free(temp);
- cleanVObjects(vobj);
- return ret_val;
-}
-
-static void
-parse_file_as(ECard *card, VObject *vobj, char *default_charset)
-{
- if ( card->file_as )
- g_free(card->file_as);
- assign_string(vobj, default_charset, &(card->file_as));
-}
-
-static void
-parse_name(ECard *card, VObject *vobj, char *default_charset)
-{
- e_card_name_unref(card->name);
-
- card->name = e_card_name_new();
-
- card->name->family = e_v_object_get_child_value (vobj, VCFamilyNameProp, default_charset);
- card->name->given = e_v_object_get_child_value (vobj, VCGivenNameProp, default_charset);
- card->name->additional = e_v_object_get_child_value (vobj, VCAdditionalNamesProp, default_charset);
- card->name->prefix = e_v_object_get_child_value (vobj, VCNamePrefixesProp, default_charset);
- card->name->suffix = e_v_object_get_child_value (vobj, VCNameSuffixesProp, default_charset);
-}
-
-static void
-parse_full_name(ECard *card, VObject *vobj, char *default_charset)
-{
- if ( card->fname )
- g_free(card->fname);
- assign_string(vobj, default_charset, &(card->fname));
-}
-
-static void
-parse_email(ECard *card, VObject *vobj, char *default_charset)
-{
- char *next_email;
- EList *list;
-
- assign_string(vobj, default_charset, &next_email);
- gtk_object_get(GTK_OBJECT(card),
- "email", &list,
- NULL);
- e_list_append(list, next_email);
- g_free (next_email);
-}
-
-/* Deal with charset */
-static void
-parse_bday(ECard *card, VObject *vobj, char *default_charset)
-{
- if ( vObjectValueType (vobj) ) {
- char *str = fakeCString (vObjectUStringZValue (vobj));
- if ( card->bday )
- g_free(card->bday);
- card->bday = g_new(ECardDate, 1);
- *(card->bday) = e_card_date_from_string(str);
- free(str);
- }
-}
-
-static void
-parse_phone(ECard *card, VObject *vobj, char *default_charset)
-{
- ECardPhone *next_phone = e_card_phone_new ();
- EList *list;
-
- assign_string(vobj, default_charset, &(next_phone->number));
- next_phone->flags = get_phone_flags(vobj);
-
- gtk_object_get(GTK_OBJECT(card),
- "phone", &list,
- NULL);
- e_list_append(list, next_phone);
- e_card_phone_unref (next_phone);
-}
-
-static void
-parse_address(ECard *card, VObject *vobj, char *default_charset)
-{
- ECardDeliveryAddress *next_addr = e_card_delivery_address_new ();
- EList *list;
-
- next_addr->flags = get_address_flags (vobj);
- next_addr->po = e_v_object_get_child_value (vobj, VCPostalBoxProp, default_charset);
- next_addr->ext = e_v_object_get_child_value (vobj, VCExtAddressProp, default_charset);
- next_addr->street = e_v_object_get_child_value (vobj, VCStreetAddressProp, default_charset);
- next_addr->city = e_v_object_get_child_value (vobj, VCCityProp, default_charset);
- next_addr->region = e_v_object_get_child_value (vobj, VCRegionProp, default_charset);
- next_addr->code = e_v_object_get_child_value (vobj, VCPostalCodeProp, default_charset);
- next_addr->country = e_v_object_get_child_value (vobj, VCCountryNameProp, default_charset);
-
- gtk_object_get(GTK_OBJECT(card),
- "address", &list,
- NULL);
- e_list_append(list, next_addr);
- e_card_delivery_address_unref (next_addr);
-}
-
-static void
-parse_address_label(ECard *card, VObject *vobj, char *default_charset)
-{
- ECardAddrLabel *next_addr = e_card_address_label_new ();
- EList *list;
-
- next_addr->flags = get_address_flags (vobj);
- assign_string(vobj, default_charset, &next_addr->data);
-
- gtk_object_get(GTK_OBJECT(card),
- "address_label", &list,
- NULL);
- e_list_append(list, next_addr);
- e_card_address_label_unref (next_addr);
-}
-
-static void
-parse_url(ECard *card, VObject *vobj, char *default_charset)
-{
- if (card->url)
- g_free(card->url);
- assign_string(vobj, default_charset, &(card->url));
-}
-
-static void
-parse_org(ECard *card, VObject *vobj, char *default_charset)
-{
- char *temp;
-
- temp = e_v_object_get_child_value(vobj, VCOrgNameProp, default_charset);
- g_free(card->org);
- card->org = temp;
-
- temp = e_v_object_get_child_value(vobj, VCOrgUnitProp, default_charset);
- g_free(card->org_unit);
- card->org_unit = temp;
-}
-
-static void
-parse_office(ECard *card, VObject *vobj, char *default_charset)
-{
- if ( card->office )
- g_free(card->office);
- assign_string(vobj, default_charset, &(card->office));
-}
-
-static void
-parse_title(ECard *card, VObject *vobj, char *default_charset)
-{
- if ( card->title )
- g_free(card->title);
- assign_string(vobj, default_charset, &(card->title));
-}
-
-static void
-parse_role(ECard *card, VObject *vobj, char *default_charset)
-{
- if (card->role)
- g_free(card->role);
- assign_string(vobj, default_charset, &(card->role));
-}
-
-static void
-parse_manager(ECard *card, VObject *vobj, char *default_charset)
-{
- if ( card->manager )
- g_free(card->manager);
- assign_string(vobj, default_charset, &(card->manager));
-}
-
-static void
-parse_assistant(ECard *card, VObject *vobj, char *default_charset)
-{
- if ( card->assistant )
- g_free(card->assistant);
- assign_string(vobj, default_charset, &(card->assistant));
-}
-
-static void
-parse_nickname(ECard *card, VObject *vobj, char *default_charset)
-{
- if (card->nickname)
- g_free(card->nickname);
- assign_string(vobj, default_charset, &(card->nickname));
-}
-
-static void
-parse_spouse(ECard *card, VObject *vobj, char *default_charset)
-{
- if ( card->spouse )
- g_free(card->spouse);
- assign_string(vobj, default_charset, &(card->spouse));
-}
-
-/* Deal with charset */
-static void
-parse_anniversary(ECard *card, VObject *vobj, char *default_charset)
-{
- if ( vObjectValueType (vobj) ) {
- char *str = fakeCString (vObjectUStringZValue (vobj));
- if (card->anniversary)
- g_free(card->anniversary);
- card->anniversary = g_new(ECardDate, 1);
- *(card->anniversary) = e_card_date_from_string(str);
- free(str);
- }
-}
-
-static void
-parse_mailer(ECard *card, VObject *vobj, char *default_charset)
-{
- if ( card->mailer )
- g_free(card->mailer);
- assign_string(vobj, default_charset, &(card->mailer));
-}
-
-static void
-parse_caluri(ECard *card, VObject *vobj, char *default_charset)
-{
- g_free(card->caluri);
- assign_string(vobj, default_charset, &(card->caluri));
-}
-
-static void
-parse_fburl(ECard *card, VObject *vobj, char *default_charset)
-{
- g_free(card->fburl);
- assign_string(vobj, default_charset, &(card->fburl));
-}
-
-static void
-parse_note(ECard *card, VObject *vobj, char *default_charset)
-{
- g_free(card->note);
- assign_string(vobj, default_charset, &(card->note));
-}
-
-static void
-parse_related_contacts(ECard *card, VObject *vobj, char *default_charset)
-{
- g_free(card->related_contacts);
- assign_string(vobj, default_charset, &(card->related_contacts));
-}
-
-static void
-add_list_unique(ECard *card, EList *list, char *string)
-{
- char *temp = e_strdup_strip(string);
- EIterator *iterator;
-
- if (!*temp) {
- g_free(temp);
- return;
- }
- for ( iterator = e_list_get_iterator(list); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
- if (!strcmp(e_iterator_get(iterator), temp)) {
- break;
- }
- }
- if (!e_iterator_is_valid(iterator)) {
- e_list_append(list, temp);
- }
- g_free(temp);
- gtk_object_unref(GTK_OBJECT(iterator));
-}
-
-static void
-do_parse_categories(ECard *card, char *str)
-{
- int length = strlen(str);
- char *copy = g_new(char, length + 1);
- int i, j;
- EList *list;
- gtk_object_get(GTK_OBJECT(card),
- "category_list", &list,
- NULL);
- for (i = 0, j = 0; str[i]; i++, j++) {
- switch (str[i]) {
- case '\\':
- i++;
- if (str[i]) {
- copy[j] = str[i];
- } else
- i--;
- break;
- case ',':
- copy[j] = 0;
- add_list_unique(card, list, copy);
- j = -1;
- break;
- default:
- copy[j] = str[i];
- break;
- }
- }
- copy[j] = 0;
- add_list_unique(card, list, copy);
- g_free(copy);
-}
-
-/* Deal with charset */
-static void
-parse_categories(ECard *card, VObject *vobj, char *default_charset)
-{
- if ( vObjectValueType (vobj) ) {
- char *str = fakeCString (vObjectUStringZValue (vobj));
- do_parse_categories(card, str);
- free(str);
- }
-}
-
-/* Deal with charset */
-static void
-parse_wants_html(ECard *card, VObject *vobj, char *default_charset)
-{
- if ( vObjectValueType (vobj) ) {
- char *str = fakeCString (vObjectUStringZValue (vobj));
- if (!strcasecmp(str, "true")) {
- card->wants_html = TRUE;
- card->wants_html_set = TRUE;
- }
- if (!strcasecmp(str, "false")) {
- card->wants_html = FALSE;
- card->wants_html_set = TRUE;
- }
- free(str);
- }
-}
-
-/* Deal with charset */
-static void
-parse_list(ECard *card, VObject *vobj, char *default_charset)
-{
- if ( vObjectValueType (vobj) ) {
- char *str = fakeCString (vObjectUStringZValue (vobj));
- if (!strcasecmp(str, "true")) {
- card->list = TRUE;
- }
- if (!strcasecmp(str, "false")) {
- card->list = FALSE;
- }
- free(str);
- }
-}
-
-/* Deal with charset */
-static void
-parse_list_show_addresses(ECard *card, VObject *vobj, char *default_charset)
-{
- if ( vObjectValueType (vobj) ) {
- char *str = fakeCString (vObjectUStringZValue (vobj));
- if (!strcasecmp(str, "true")) {
- card->list_show_addresses = TRUE;
- }
- if (!strcasecmp(str, "false")) {
- card->list_show_addresses = FALSE;
- }
- free(str);
- }
-}
-
-typedef union ValueItem {
- const char *strs;
- const wchar_t *ustrs;
- unsigned int i;
- unsigned long l;
- void *any;
- VObject *vobj;
-} ValueItem;
-
-struct VObject {
- VObject *next;
- const char *id;
- VObject *prop;
- unsigned short valType;
- ValueItem val;
-};
-
-static void
-parse_arbitrary(ECard *card, VObject *vobj, char *default_charset)
-{
- ECardArbitrary *arbitrary = e_card_arbitrary_new();
- VObjectIterator iterator;
- EList *list;
- for ( initPropIterator (&iterator, vobj); moreIteration(&iterator); ) {
- VObject *temp = nextVObject(&iterator);
- const char *name = vObjectName(temp);
- if (name && !strcmp(name, "TYPE")) {
- g_free(arbitrary->type);
- assign_string(temp, default_charset, &(arbitrary->type));
- } else {
- g_free(arbitrary->key);
- arbitrary->key = g_strdup(name);
- }
- }
-
- assign_string(vobj, default_charset, &(arbitrary->value));
-
- gtk_object_get(GTK_OBJECT(card),
- "arbitrary", &list,
- NULL);
- e_list_append(list, arbitrary);
- e_card_arbitrary_unref(arbitrary);
-}
-
-static void
-parse_id(ECard *card, VObject *vobj, char *default_charset)
-{
- g_free(card->id);
- assign_string(vobj, default_charset, &(card->id));
-}
-
-/* Deal with charset */
-static void
-parse_last_use(ECard *card, VObject *vobj, char *default_charset)
-{
- if ( vObjectValueType (vobj) ) {
- char *str = fakeCString (vObjectUStringZValue (vobj));
- if ( card->last_use )
- g_free(card->last_use);
- card->last_use = g_new(ECardDate, 1);
- *(card->last_use) = e_card_date_from_string(str);
- free(str);
- }
-}
-
-/* Deal with charset */
-static void
-parse_use_score(ECard *card, VObject *vobj, char *default_charset)
-{
- card->raw_use_score = 0;
-
- if ( vObjectValueType (vobj) ) {
- char *str = fakeCString (vObjectUStringZValue (vobj));
- card->raw_use_score = MAX(0, atof (str));
- free (str);
- }
-}
-
-static void
-parse_attribute(ECard *card, VObject *vobj, char *default_charset)
-{
- ParsePropertyFunc function = g_hash_table_lookup(E_CARD_CLASS(GTK_OBJECT(card)->klass)->attribute_jump_table, vObjectName(vobj));
- if ( function )
- function(card, vobj, default_charset);
-}
-
-static void
-parse(ECard *card, VObject *vobj, char *default_charset)
-{
- VObjectIterator iterator;
- initPropIterator(&iterator, vobj);
- while(moreIteration (&iterator)) {
- parse_attribute(card, nextVObject(&iterator), default_charset);
- }
- if (!card->fname) {
- card->fname = g_strdup("");
- }
- if (!card->name) {
- card->name = e_card_name_from_string(card->fname);
- }
- if (!card->file_as) {
- ECardName *name = card->name;
- char *strings[3], **stringptr;
- char *string;
- stringptr = strings;
- if (name->family && *name->family)
- *(stringptr++) = name->family;
- if (name->given && *name->given)
- *(stringptr++) = name->given;
- *stringptr = NULL;
- string = g_strjoinv(", ", strings);
- card->file_as = string;
- }
-}
-
-static void
-e_card_class_init (ECardClass *klass)
-{
- int i;
- GtkObjectClass *object_class;
-
- object_class = GTK_OBJECT_CLASS(klass);
-
- klass->attribute_jump_table = g_hash_table_new(g_str_hash, g_str_equal);
-
- for ( i = 0; i < sizeof(attribute_jump_array) / sizeof(attribute_jump_array[0]); i++ ) {
- g_hash_table_insert(klass->attribute_jump_table, attribute_jump_array[i].key, attribute_jump_array[i].function);
- }
-
- gtk_object_add_arg_type ("ECard::file_as",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_FILE_AS);
- gtk_object_add_arg_type ("ECard::full_name",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_FULL_NAME);
- gtk_object_add_arg_type ("ECard::name",
- GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_NAME);
- gtk_object_add_arg_type ("ECard::address",
- GTK_TYPE_OBJECT, GTK_ARG_READABLE, ARG_ADDRESS);
- gtk_object_add_arg_type ("ECard::address_label",
- GTK_TYPE_OBJECT, GTK_ARG_READABLE, ARG_ADDRESS_LABEL);
- gtk_object_add_arg_type ("ECard::phone",
- GTK_TYPE_OBJECT, GTK_ARG_READABLE, ARG_PHONE);
- gtk_object_add_arg_type ("ECard::email",
- GTK_TYPE_OBJECT, GTK_ARG_READABLE, ARG_EMAIL);
- gtk_object_add_arg_type ("ECard::birth_date",
- GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_BIRTH_DATE);
- gtk_object_add_arg_type ("ECard::url",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_URL);
- gtk_object_add_arg_type ("ECard::org",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_ORG);
- gtk_object_add_arg_type ("ECard::org_unit",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_ORG_UNIT);
- gtk_object_add_arg_type ("ECard::office",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_OFFICE);
- gtk_object_add_arg_type ("ECard::title",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_TITLE);
- gtk_object_add_arg_type ("ECard::role",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_ROLE);
- gtk_object_add_arg_type ("ECard::manager",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_MANAGER);
- gtk_object_add_arg_type ("ECard::assistant",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_ASSISTANT);
- gtk_object_add_arg_type ("ECard::nickname",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_NICKNAME);
- gtk_object_add_arg_type ("ECard::spouse",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_SPOUSE);
- gtk_object_add_arg_type ("ECard::anniversary",
- GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_ANNIVERSARY);
- gtk_object_add_arg_type ("ECard::mailer",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_MAILER);
- gtk_object_add_arg_type ("ECard::caluri",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_CALURI);
- gtk_object_add_arg_type ("ECard::fburl",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_FBURL);
- gtk_object_add_arg_type ("ECard::note",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_NOTE);
- gtk_object_add_arg_type ("ECard::related_contacts",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_RELATED_CONTACTS);
- gtk_object_add_arg_type ("ECard::categories",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_CATEGORIES);
- gtk_object_add_arg_type ("ECard::category_list",
- GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_CATEGORY_LIST);
- gtk_object_add_arg_type ("ECard::wants_html",
- GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_WANTS_HTML);
- gtk_object_add_arg_type ("ECard::wants_html_set",
- GTK_TYPE_BOOL, GTK_ARG_READABLE, ARG_WANTS_HTML);
- gtk_object_add_arg_type ("ECard::list",
- GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_EVOLUTION_LIST);
- gtk_object_add_arg_type ("ECard::list_show_addresses",
- GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_EVOLUTION_LIST_SHOW_ADDRESSES);
- gtk_object_add_arg_type ("ECard::arbitrary",
- GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_ARBITRARY);
- gtk_object_add_arg_type ("ECard::id",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_ID);
- gtk_object_add_arg_type ("ECard::last_use",
- GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_LAST_USE);
- gtk_object_add_arg_type ("ECard::use_score",
- GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_USE_SCORE);
-
-
- object_class->destroy = e_card_destroy;
- object_class->get_arg = e_card_get_arg;
- object_class->set_arg = e_card_set_arg;
-}
-
-ECardPhone *
-e_card_phone_new (void)
-{
- ECardPhone *newphone = g_new(ECardPhone, 1);
-
- newphone->ref_count = 1;
- newphone->number = NULL;
- newphone->flags = 0;
-
- return newphone;
-}
-
-void
-e_card_phone_unref (ECardPhone *phone)
-{
- if (phone) {
- phone->ref_count --;
- if (phone->ref_count == 0) {
- g_free(phone->number);
- g_free(phone);
- }
- }
-}
-
-ECardPhone *
-e_card_phone_ref (const ECardPhone *phone)
-{
- ECardPhone *phone_mutable = (ECardPhone *) phone;
- if (phone_mutable)
- phone_mutable->ref_count ++;
- return phone_mutable;
-}
-
-ECardPhone *
-e_card_phone_copy (const ECardPhone *phone)
-{
- if ( phone ) {
- ECardPhone *phone_copy = e_card_phone_new();
- phone_copy->number = g_strdup(phone->number);
- phone_copy->flags = phone->flags;
- return phone_copy;
- } else
- return NULL;
-}
-
-ECardDeliveryAddress *
-e_card_delivery_address_new (void)
-{
- ECardDeliveryAddress *newaddr = g_new(ECardDeliveryAddress, 1);
-
- newaddr->ref_count = 1;
- newaddr->po = NULL;
- newaddr->ext = NULL;
- newaddr->street = NULL;
- newaddr->city = NULL;
- newaddr->region = NULL;
- newaddr->code = NULL;
- newaddr->country = NULL;
- newaddr->flags = 0;
-
- return newaddr;
-}
-
-void
-e_card_delivery_address_unref (ECardDeliveryAddress *addr)
-{
- if ( addr ) {
- addr->ref_count --;
- if (addr->ref_count == 0) {
- g_free(addr->po);
- g_free(addr->ext);
- g_free(addr->street);
- g_free(addr->city);
- g_free(addr->region);
- g_free(addr->code);
- g_free(addr->country);
- g_free(addr);
- }
- }
-}
-
-ECardDeliveryAddress *
-e_card_delivery_address_ref (const ECardDeliveryAddress *addr)
-{
- ECardDeliveryAddress *addr_mutable = (ECardDeliveryAddress *) addr;
- if (addr_mutable)
- addr_mutable->ref_count ++;
- return addr_mutable;
-}
-
-ECardDeliveryAddress *
-e_card_delivery_address_copy (const ECardDeliveryAddress *addr)
-{
- if ( addr ) {
- ECardDeliveryAddress *addr_copy = e_card_delivery_address_new ();
- addr_copy->po = g_strdup(addr->po );
- addr_copy->ext = g_strdup(addr->ext );
- addr_copy->street = g_strdup(addr->street );
- addr_copy->city = g_strdup(addr->city );
- addr_copy->region = g_strdup(addr->region );
- addr_copy->code = g_strdup(addr->code );
- addr_copy->country = g_strdup(addr->country);
- addr_copy->flags = addr->flags;
- return addr_copy;
- } else
- return NULL;
-}
-
-gboolean
-e_card_delivery_address_is_empty (const ECardDeliveryAddress *addr)
-{
- return (((addr->po == NULL) || (*addr->po == 0)) &&
- ((addr->ext == NULL) || (*addr->ext == 0)) &&
- ((addr->street == NULL) || (*addr->street == 0)) &&
- ((addr->city == NULL) || (*addr->city == 0)) &&
- ((addr->region == NULL) || (*addr->region == 0)) &&
- ((addr->code == NULL) || (*addr->code == 0)) &&
- ((addr->country == NULL) || (*addr->country == 0)));
-}
-
-ECardDeliveryAddress *
-e_card_delivery_address_from_label(const ECardAddrLabel *label)
-{
- ECardDeliveryAddress *addr = e_card_delivery_address_new ();
- EAddressWestern *western = e_address_western_parse (label->data);
-
- addr->po = g_strdup (western->po_box );
- addr->ext = g_strdup (western->extended );
- addr->street = g_strdup (western->street );
- addr->city = g_strdup (western->locality );
- addr->region = g_strdup (western->region );
- addr->code = g_strdup (western->postal_code);
- addr->country = g_strdup (western->country );
- addr->flags = label->flags;
-
- e_address_western_free(western);
-
- return addr;
-}
-
-char *
-e_card_delivery_address_to_string(const ECardDeliveryAddress *addr)
-{
- char *strings[5], **stringptr = strings;
- char *line1, *line22, *line2;
- char *final;
- if (addr->po && *addr->po)
- *(stringptr++) = addr->po;
- if (addr->street && *addr->street)
- *(stringptr++) = addr->street;
- *stringptr = NULL;
- line1 = g_strjoinv(" ", strings);
- stringptr = strings;
- if (addr->region && *addr->region)
- *(stringptr++) = addr->region;
- if (addr->code && *addr->code)
- *(stringptr++) = addr->code;
- *stringptr = NULL;
- line22 = g_strjoinv(" ", strings);
- stringptr = strings;
- if (addr->city && *addr->city)
- *(stringptr++) = addr->city;
- if (line22 && *line22)
- *(stringptr++) = line22;
- *stringptr = NULL;
- line2 = g_strjoinv(", ", strings);
- stringptr = strings;
- if (line1 && *line1)
- *(stringptr++) = line1;
- if (addr->ext && *addr->ext)
- *(stringptr++) = addr->ext;
- if (line2 && *line2)
- *(stringptr++) = line2;
- if (addr->country && *addr->country)
- *(stringptr++) = addr->country;
- *stringptr = NULL;
- final = g_strjoinv("\n", strings);
- g_free(line1);
- g_free(line22);
- g_free(line2);
- return final;
-}
-
-ECardAddrLabel *
-e_card_delivery_address_to_label (const ECardDeliveryAddress *addr)
-{
- ECardAddrLabel *label;
- label = e_card_address_label_new();
- label->flags = addr->flags;
- label->data = e_card_delivery_address_to_string(addr);
-
- return label;
-}
-
-ECardAddrLabel *
-e_card_address_label_new (void)
-{
- ECardAddrLabel *newaddr = g_new(ECardAddrLabel, 1);
-
- newaddr->ref_count = 1;
- newaddr->data = NULL;
- newaddr->flags = 0;
-
- return newaddr;
-}
-
-void
-e_card_address_label_unref (ECardAddrLabel *addr)
-{
- if (addr) {
- addr->ref_count --;
- if (addr->ref_count == 0) {
- g_free(addr->data);
- g_free(addr);
- }
- }
-}
-
-ECardAddrLabel *
-e_card_address_label_ref (const ECardAddrLabel *addr)
-{
- ECardAddrLabel *addr_mutable = (ECardAddrLabel *) addr;
- if (addr_mutable)
- addr_mutable->ref_count ++;
- return addr_mutable;
-}
-
-ECardAddrLabel *
-e_card_address_label_copy (const ECardAddrLabel *addr)
-{
- if ( addr ) {
- ECardAddrLabel *addr_copy = e_card_address_label_new ();
- addr_copy->data = g_strdup(addr->data);
- addr_copy->flags = addr->flags;
- return addr_copy;
- } else
- return NULL;
-}
-
-ECardName *e_card_name_new(void)
-{
- ECardName *newname = g_new(ECardName, 1);
-
- newname->ref_count = 1;
- newname->prefix = NULL;
- newname->given = NULL;
- newname->additional = NULL;
- newname->family = NULL;
- newname->suffix = NULL;
-
- return newname;
-}
-
-void
-e_card_name_unref(ECardName *name)
-{
- if (name) {
- name->ref_count --;
- if (name->ref_count == 0) {
- g_free (name->prefix);
- g_free (name->given);
- g_free (name->additional);
- g_free (name->family);
- g_free (name->suffix);
- g_free (name);
- }
- }
-}
-
-ECardName *
-e_card_name_ref(const ECardName *name)
-{
- ECardName *name_mutable = (ECardName *) name;
- if (name_mutable)
- name_mutable->ref_count ++;
- return name_mutable;
-}
-
-ECardName *
-e_card_name_copy(const ECardName *name)
-{
- if (name) {
- ECardName *newname = e_card_name_new ();
-
- newname->prefix = g_strdup(name->prefix);
- newname->given = g_strdup(name->given);
- newname->additional = g_strdup(name->additional);
- newname->family = g_strdup(name->family);
- newname->suffix = g_strdup(name->suffix);
-
- return newname;
- } else
- return NULL;
-}
-
-
-char *
-e_card_name_to_string(const ECardName *name)
-{
- char *strings[6], **stringptr = strings;
-
- g_return_val_if_fail (name != NULL, NULL);
-
- if (name->prefix && *name->prefix)
- *(stringptr++) = name->prefix;
- if (name->given && *name->given)
- *(stringptr++) = name->given;
- if (name->additional && *name->additional)
- *(stringptr++) = name->additional;
- if (name->family && *name->family)
- *(stringptr++) = name->family;
- if (name->suffix && *name->suffix)
- *(stringptr++) = name->suffix;
- *stringptr = NULL;
- return g_strjoinv(" ", strings);
-}
-
-ECardName *
-e_card_name_from_string(const char *full_name)
-{
- ECardName *name = e_card_name_new ();
- ENameWestern *western = e_name_western_parse (full_name);
-
- name->prefix = g_strdup (western->prefix);
- name->given = g_strdup (western->first );
- name->additional = g_strdup (western->middle);
- name->family = g_strdup (western->last );
- name->suffix = g_strdup (western->suffix);
-
- e_name_western_free(western);
-
- return name;
-}
-
-ECardArbitrary *
-e_card_arbitrary_new(void)
-{
- ECardArbitrary *arbitrary = g_new(ECardArbitrary, 1);
- arbitrary->ref_count = 1;
- arbitrary->key = NULL;
- arbitrary->type = NULL;
- arbitrary->value = NULL;
- return arbitrary;
-}
-
-void
-e_card_arbitrary_unref(ECardArbitrary *arbitrary)
-{
- if (arbitrary) {
- arbitrary->ref_count --;
- if (arbitrary->ref_count == 0) {
- g_free(arbitrary->key);
- g_free(arbitrary->type);
- g_free(arbitrary->value);
- g_free(arbitrary);
- }
- }
-}
-
-ECardArbitrary *
-e_card_arbitrary_copy(const ECardArbitrary *arbitrary)
-{
- if (arbitrary) {
- ECardArbitrary *arb_copy = e_card_arbitrary_new ();
- arb_copy->key = g_strdup(arbitrary->key);
- arb_copy->type = g_strdup(arbitrary->type);
- arb_copy->value = g_strdup(arbitrary->value);
- return arb_copy;
- } else
- return NULL;
-}
-
-ECardArbitrary *
-e_card_arbitrary_ref(const ECardArbitrary *arbitrary)
-{
- ECardArbitrary *arbitrary_mutable = (ECardArbitrary *) arbitrary;
- if (arbitrary_mutable)
- arbitrary_mutable->ref_count ++;
- return arbitrary_mutable;
-}
-
-/* EMail matching */
-static gboolean
-e_card_email_match_single_string (const gchar *a, const gchar *b)
-{
- const gchar *xa = NULL, *xb = NULL;
- gboolean match = TRUE;
-
- for (xa=a; *xa && *xa != '@'; ++xa);
- for (xb=b; *xb && *xb != '@'; ++xb);
-
- if (xa-a != xb-b || *xa != *xb || g_strncasecmp (a, b, xa-a))
- return FALSE;
-
- if (*xa == '\0')
- return TRUE;
-
- /* Find the end of the string, then walk through backwards comparing.
- This is so that we'll match joe@foobar.com and joe@mail.foobar.com.
- */
- while (*xa)
- ++xa;
- while (*xb)
- ++xb;
-
- while (match && *xa != '@' && *xb != '@') {
- match = (tolower (*xa) == tolower (*xb));
- --xa;
- --xb;
- }
-
- match = match && ((tolower (*xa) == tolower (*xb)) || (*xa == '.') || (*xb == '.'));
-
- return match;
-}
-
-gboolean
-e_card_email_match_string (const ECard *card, const gchar *str)
-{
- EIterator *iter;
-
- g_return_val_if_fail (card && E_IS_CARD (card), FALSE);
- g_return_val_if_fail (str != NULL, FALSE);
-
- iter = e_list_get_iterator (card->email);
- for (e_iterator_reset (iter); e_iterator_is_valid (iter); e_iterator_next (iter)) {
- if (e_card_email_match_single_string (e_iterator_get (iter), str))
- return TRUE;
- }
- gtk_object_unref (GTK_OBJECT (iter));
-
- return FALSE;
-}
-
-gint
-e_card_email_find_number (const ECard *card, const gchar *email)
-{
- EIterator *iter;
- gint count = 0;
-
- g_return_val_if_fail (E_IS_CARD (card), -1);
- g_return_val_if_fail (email != NULL, -1);
-
- iter = e_list_get_iterator (card->email);
- for (e_iterator_reset (iter); e_iterator_is_valid (iter); e_iterator_next (iter)) {
- if (!g_strcasecmp (e_iterator_get (iter), email))
- goto finished;
- ++count;
- }
- count = -1;
-
- finished:
- gtk_object_unref (GTK_OBJECT (iter));
-
- return count;
-}
-
-/*
- * ECard lifecycle management and vCard loading/saving.
- */
-
-static void
-e_card_destroy (GtkObject *object)
-{
- ECard *card = E_CARD(object);
- g_free(card->id);
- if (card->book)
- gtk_object_unref (GTK_OBJECT (card->book));
- g_free(card->file_as);
- g_free(card->fname);
- e_card_name_unref(card->name);
- g_free(card->bday);
-
- g_free(card->url);
- g_free(card->org);
- g_free(card->org_unit);
- g_free(card->office);
- g_free(card->title);
- g_free(card->role);
- g_free(card->manager);
- g_free(card->assistant);
- g_free(card->nickname);
- g_free(card->spouse);
- g_free(card->anniversary);
- g_free(card->caluri);
- g_free(card->fburl);
- g_free(card->note);
- g_free(card->related_contacts);
-
- if (card->categories)
- gtk_object_unref(GTK_OBJECT(card->categories));
- if (card->email)
- gtk_object_unref(GTK_OBJECT(card->email));
- if (card->phone)
- gtk_object_unref(GTK_OBJECT(card->phone));
- if (card->address)
- gtk_object_unref(GTK_OBJECT(card->address));
- if (card->address_label)
- gtk_object_unref(GTK_OBJECT(card->address_label));
-}
-
-
-/* Set_arg handler for the card */
-static void
-e_card_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- ECard *card;
-
- card = E_CARD (object);
-
- switch (arg_id) {
- case ARG_FILE_AS:
- g_free(card->file_as);
- card->file_as = g_strdup(GTK_VALUE_STRING(*arg));
- if (card->file_as == NULL)
- card->file_as = g_strdup("");
- break;
-
- case ARG_FULL_NAME:
- g_free(card->fname);
- card->fname = g_strdup(GTK_VALUE_STRING(*arg));
- if (card->fname == NULL)
- card->fname = g_strdup("");
-
- e_card_name_unref (card->name);
- card->name = e_card_name_from_string (card->fname);
- break;
- case ARG_NAME:
- e_card_name_unref (card->name);
- card->name = e_card_name_ref(GTK_VALUE_POINTER(*arg));
- if (card->name == NULL)
- card->name = e_card_name_new();
- if (card->fname == NULL) {
- card->fname = e_card_name_to_string(card->name);
- }
- if (card->file_as == NULL) {
- ECardName *name = card->name;
- char *strings[3], **stringptr;
- char *string;
- stringptr = strings;
- if (name->family && *name->family)
- *(stringptr++) = name->family;
- if (name->given && *name->given)
- *(stringptr++) = name->given;
- *stringptr = NULL;
- string = g_strjoinv(", ", strings);
- card->file_as = string;
- }
- break;
- case ARG_CATEGORIES:
- if (card->categories)
- gtk_object_unref(GTK_OBJECT(card->categories));
- card->categories = NULL;
- if (GTK_VALUE_STRING(*arg))
- do_parse_categories(card, GTK_VALUE_STRING(*arg));
- break;
- case ARG_CATEGORY_LIST:
- if (card->categories)
- gtk_object_unref(GTK_OBJECT(card->categories));
- card->categories = E_LIST(GTK_VALUE_OBJECT(*arg));
- if (card->categories)
- gtk_object_ref(GTK_OBJECT(card->categories));
- break;
- case ARG_BIRTH_DATE:
- g_free(card->bday);
- if (GTK_VALUE_POINTER (*arg)) {
- card->bday = g_new (ECardDate, 1);
- memcpy (card->bday, GTK_VALUE_POINTER (*arg), sizeof (ECardDate));
- } else {
- card->bday = NULL;
- }
- break;
- case ARG_URL:
- g_free(card->url);
- card->url = g_strdup(GTK_VALUE_STRING(*arg));
- break;
- case ARG_ORG:
- g_free(card->org);
- card->org = g_strdup(GTK_VALUE_STRING(*arg));
- break;
- case ARG_ORG_UNIT:
- g_free(card->org_unit);
- card->org_unit = g_strdup(GTK_VALUE_STRING(*arg));
- break;
- case ARG_OFFICE:
- g_free(card->office);
- card->office = g_strdup(GTK_VALUE_STRING(*arg));
- break;
- case ARG_TITLE:
- g_free(card->title);
- card->title = g_strdup(GTK_VALUE_STRING(*arg));
- break;
- case ARG_ROLE:
- g_free(card->role);
- card->role = g_strdup(GTK_VALUE_STRING(*arg));
- break;
- case ARG_MANAGER:
- g_free(card->manager);
- card->manager = g_strdup(GTK_VALUE_STRING(*arg));
- break;
- case ARG_ASSISTANT:
- g_free(card->assistant);
- card->assistant = g_strdup(GTK_VALUE_STRING(*arg));
- break;
- case ARG_NICKNAME:
- g_free(card->nickname);
- card->nickname = g_strdup(GTK_VALUE_STRING(*arg));
- break;
- case ARG_SPOUSE:
- g_free(card->spouse);
- card->spouse = g_strdup(GTK_VALUE_STRING(*arg));
- break;
- case ARG_ANNIVERSARY:
- g_free(card->anniversary);
- if (GTK_VALUE_POINTER (*arg)) {
- card->anniversary = g_new (ECardDate, 1);
- memcpy (card->anniversary, GTK_VALUE_POINTER (*arg), sizeof (ECardDate));
- } else {
- card->anniversary = NULL;
- }
- break;
- case ARG_MAILER:
- g_free(card->mailer);
- card->mailer = g_strdup(GTK_VALUE_STRING(*arg));
- break;
- case ARG_CALURI:
- g_free(card->caluri);
- card->caluri = g_strdup(GTK_VALUE_STRING(*arg));
- break;
- case ARG_FBURL:
- g_free(card->fburl);
- card->fburl = g_strdup(GTK_VALUE_STRING(*arg));
- break;
- case ARG_NOTE:
- g_free (card->note);
- card->note = g_strdup(GTK_VALUE_STRING(*arg));
- break;
- case ARG_RELATED_CONTACTS:
- g_free (card->related_contacts);
- card->related_contacts = g_strdup(GTK_VALUE_STRING(*arg));
- break;
- case ARG_WANTS_HTML:
- card->wants_html = GTK_VALUE_BOOL(*arg);
- card->wants_html_set = TRUE;
- break;
- case ARG_ARBITRARY:
- if (card->arbitrary)
- gtk_object_unref(GTK_OBJECT(card->arbitrary));
- card->arbitrary = E_LIST(GTK_VALUE_OBJECT(*arg));
- if (card->arbitrary)
- gtk_object_ref(GTK_OBJECT(card->arbitrary));
- break;
- case ARG_ID:
- g_free(card->id);
- card->id = g_strdup(GTK_VALUE_STRING(*arg));
- if (card->id == NULL)
- card->id = g_strdup ("");
- break;
- case ARG_LAST_USE:
- g_free(card->last_use);
- if (GTK_VALUE_POINTER (*arg)) {
- card->last_use = g_new (ECardDate, 1);
- memcpy (card->last_use, GTK_VALUE_POINTER (*arg), sizeof (ECardDate));
- } else {
- card->last_use = NULL;
- }
- break;
- case ARG_USE_SCORE:
- card->raw_use_score = GTK_VALUE_FLOAT(*arg);
- break;
- case ARG_EVOLUTION_LIST:
- card->list = GTK_VALUE_BOOL(*arg);
- break;
- case ARG_EVOLUTION_LIST_SHOW_ADDRESSES:
- card->list_show_addresses = GTK_VALUE_BOOL(*arg);
- break;
- default:
- return;
- }
-}
-
-/* Get_arg handler for the card */
-static void
-e_card_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- ECard *card;
-
- card = E_CARD (object);
-
- switch (arg_id) {
- case ARG_FILE_AS:
- GTK_VALUE_STRING (*arg) = card->file_as;
- break;
- case ARG_FULL_NAME:
- GTK_VALUE_STRING (*arg) = card->fname;
- break;
- case ARG_NAME:
- GTK_VALUE_POINTER(*arg) = card->name;
- break;
- case ARG_ADDRESS:
- if (!card->address)
- card->address = e_list_new((EListCopyFunc) e_card_delivery_address_ref,
- (EListFreeFunc) e_card_delivery_address_unref,
- NULL);
- GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(card->address);
- break;
- case ARG_ADDRESS_LABEL:
- if (!card->address_label)
- card->address_label = e_list_new((EListCopyFunc) e_card_address_label_ref,
- (EListFreeFunc) e_card_address_label_unref,
- NULL);
- GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(card->address_label);
- break;
- case ARG_PHONE:
- if (!card->phone)
- card->phone = e_list_new((EListCopyFunc) e_card_phone_ref,
- (EListFreeFunc) e_card_phone_unref,
- NULL);
- GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(card->phone);
- break;
- case ARG_EMAIL:
- if (!card->email)
- card->email = e_list_new((EListCopyFunc) g_strdup,
- (EListFreeFunc) g_free,
- NULL);
- GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(card->email);
- break;
- case ARG_CATEGORIES:
- {
- int i;
- char ** strs;
- int length;
- EIterator *iterator;
- if (!card->categories)
- card->categories = e_list_new((EListCopyFunc) g_strdup,
- (EListFreeFunc) g_free,
- NULL);
- length = e_list_length(card->categories);
- strs = g_new(char *, length + 1);
- for (iterator = e_list_get_iterator(card->categories), i = 0; e_iterator_is_valid(iterator); e_iterator_next(iterator), i++) {
- strs[i] = (char *)e_iterator_get(iterator);
- }
- strs[i] = 0;
- GTK_VALUE_STRING(*arg) = g_strjoinv(", ", strs);
- g_free(strs);
- }
- break;
- case ARG_CATEGORY_LIST:
- if (!card->categories)
- card->categories = e_list_new((EListCopyFunc) g_strdup,
- (EListFreeFunc) g_free,
- NULL);
- GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(card->categories);
- break;
- case ARG_BIRTH_DATE:
- GTK_VALUE_POINTER(*arg) = card->bday;
- break;
- case ARG_URL:
- GTK_VALUE_STRING(*arg) = card->url;
- break;
- case ARG_ORG:
- GTK_VALUE_STRING(*arg) = card->org;
- break;
- case ARG_ORG_UNIT:
- GTK_VALUE_STRING(*arg) = card->org_unit;
- break;
- case ARG_OFFICE:
- GTK_VALUE_STRING(*arg) = card->office;
- break;
- case ARG_TITLE:
- GTK_VALUE_STRING(*arg) = card->title;
- break;
- case ARG_ROLE:
- GTK_VALUE_STRING(*arg) = card->role;
- break;
- case ARG_MANAGER:
- GTK_VALUE_STRING(*arg) = card->manager;
- break;
- case ARG_ASSISTANT:
- GTK_VALUE_STRING(*arg) = card->assistant;
- break;
- case ARG_NICKNAME:
- GTK_VALUE_STRING(*arg) = card->nickname;
- break;
- case ARG_SPOUSE:
- GTK_VALUE_STRING(*arg) = card->spouse;
- break;
- case ARG_ANNIVERSARY:
- GTK_VALUE_POINTER(*arg) = card->anniversary;
- break;
- case ARG_MAILER:
- GTK_VALUE_STRING(*arg) = card->mailer;
- break;
- case ARG_CALURI:
- GTK_VALUE_STRING(*arg) = card->caluri;
- break;
- case ARG_FBURL:
- GTK_VALUE_STRING(*arg) = card->fburl;
- break;
- case ARG_NOTE:
- GTK_VALUE_STRING(*arg) = card->note;
- break;
- case ARG_RELATED_CONTACTS:
- GTK_VALUE_STRING(*arg) = card->related_contacts;
- break;
- case ARG_WANTS_HTML:
- GTK_VALUE_BOOL(*arg) = card->wants_html;
- break;
- case ARG_WANTS_HTML_SET:
- GTK_VALUE_BOOL(*arg) = card->wants_html_set;
- break;
- case ARG_ARBITRARY:
- if (!card->arbitrary)
- card->arbitrary = e_list_new((EListCopyFunc) e_card_arbitrary_ref,
- (EListFreeFunc) e_card_arbitrary_unref,
- NULL);
-
- GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(card->arbitrary);
- break;
- case ARG_ID:
- GTK_VALUE_STRING(*arg) = card->id;
- break;
- case ARG_LAST_USE:
- GTK_VALUE_POINTER(*arg) = card->last_use;
- break;
-
- case ARG_USE_SCORE:
- GTK_VALUE_FLOAT(*arg) = e_card_get_use_score (card);
- break;
- case ARG_EVOLUTION_LIST:
- GTK_VALUE_BOOL(*arg) = card->list;
- break;
- case ARG_EVOLUTION_LIST_SHOW_ADDRESSES:
- GTK_VALUE_BOOL(*arg) = card->list_show_addresses;
- break;
- default:
- arg->type = GTK_TYPE_INVALID;
- break;
- }
-}
-
-
-/**
- * e_card_init:
- */
-static void
-e_card_init (ECard *card)
-{
- card->id = g_strdup("");
-
- card->file_as = NULL;
- card->fname = NULL;
- card->name = NULL;
- card->bday = NULL;
- card->email = NULL;
- card->phone = NULL;
- card->address = NULL;
- card->address_label = NULL;
- card->url = NULL;
- card->org = NULL;
- card->org_unit = NULL;
- card->office = NULL;
- card->title = NULL;
- card->role = NULL;
- card->manager = NULL;
- card->assistant = NULL;
- card->nickname = NULL;
- card->spouse = NULL;
- card->anniversary = NULL;
- card->mailer = NULL;
- card->caluri = NULL;
- card->fburl = NULL;
- card->note = NULL;
- card->related_contacts = NULL;
- card->categories = NULL;
- card->wants_html = FALSE;
- card->wants_html_set = FALSE;
- card->list = FALSE;
- card->list_show_addresses = FALSE;
- card->arbitrary = NULL;
- card->last_use = NULL;
- card->raw_use_score = 0;
-}
-
-GList *
-e_card_load_cards_from_file_with_default_charset(const char *filename, char *default_charset)
-{
- VObject *vobj = Parse_MIME_FromFileName((char *) filename);
- GList *list = NULL;
- while(vobj) {
- VObject *next;
- ECard *card = E_CARD(gtk_type_new(e_card_get_type()));
- parse(card, vobj, default_charset);
- next = nextVObjectInList(vobj);
- cleanVObject(vobj);
- vobj = next;
- list = g_list_prepend(list, card);
- }
- list = g_list_reverse(list);
- return list;
-}
-
-GList *
-e_card_load_cards_from_file(const char *filename)
-{
- return e_card_load_cards_from_file_with_default_charset (filename, "UTF-8");
-}
-
-GList *
-e_card_load_cards_from_string_with_default_charset(const char *str, char *default_charset)
-{
- VObject *vobj = Parse_MIME(str, strlen (str));
- GList *list = NULL;
- while(vobj) {
- VObject *next;
- ECard *card = E_CARD(gtk_type_new(e_card_get_type()));
- parse(card, vobj, default_charset);
- next = nextVObjectInList(vobj);
- cleanVObject(vobj);
- vobj = next;
- list = g_list_prepend(list, card);
- }
- list = g_list_reverse(list);
- return list;
-}
-
-GList *
-e_card_load_cards_from_string(const char *str)
-{
- return e_card_load_cards_from_string_with_default_charset (str, "UTF-8");
-}
-
-void
-e_card_free_empty_lists (ECard *card)
-{
- if (card->address && e_list_length (card->address) == 0) {
- gtk_object_unref (GTK_OBJECT (card->address));
- card->address = NULL;
- }
-
- if (card->address_label && e_list_length (card->address_label) == 0) {
- gtk_object_unref (GTK_OBJECT (card->address_label));
- card->address_label = NULL;
- }
-
- if (card->phone && e_list_length (card->phone) == 0) {
- gtk_object_unref (GTK_OBJECT (card->phone));
- card->phone = NULL;
- }
-
- if (card->email && e_list_length (card->email) == 0) {
- gtk_object_unref (GTK_OBJECT (card->email));
- card->email = NULL;
- }
-
- if (card->categories && e_list_length (card->categories) == 0) {
- gtk_object_unref (GTK_OBJECT (card->categories));
- card->categories = NULL;
- }
-
- if (card->arbitrary && e_list_length (card->arbitrary) == 0) {
- gtk_object_unref (GTK_OBJECT (card->arbitrary));
- card->arbitrary = NULL;
- }
-}
-
-static void
-assign_string(VObject *vobj, char *default_charset, char **string)
-{
- int type = vObjectValueType(vobj);
- char *str;
- char *charset = default_charset;
- gboolean free_charset = FALSE;
- VObject *charset_obj;
-
- if ((charset_obj = isAPropertyOf (vobj, "CHARSET"))) {
- switch (vObjectValueType (charset_obj)) {
- case VCVT_STRINGZ:
- charset = (char *) vObjectStringZValue(charset_obj);
- break;
- case VCVT_USTRINGZ:
- charset = fakeCString (vObjectUStringZValue (charset_obj));
- free_charset = TRUE;
- break;
- }
- }
-
- switch(type) {
- case VCVT_STRINGZ:
- if (strcmp (charset, "UTF-8"))
- *string = e_utf8_from_charset_string (charset, vObjectStringZValue(vobj));
- else
- *string = g_strdup(vObjectStringZValue(vobj));
- break;
- case VCVT_USTRINGZ:
- str = fakeCString (vObjectUStringZValue (vobj));
- if (strcmp (charset, "UTF-8"))
- *string = e_utf8_from_charset_string (charset, str);
- else
- *string = g_strdup(str);
- free(str);
- break;
- default:
- *string = g_strdup("");
- break;
- }
-
- if (free_charset) {
- free (charset);
- }
-}
-
-
-ECardDate
-e_card_date_from_string (const char *str)
-{
- ECardDate date;
- int length;
-
- date.year = 0;
- date.month = 0;
- date.day = 0;
-
- length = strlen(str);
-
- if (length == 10 ) {
- date.year = str[0] * 1000 + str[1] * 100 + str[2] * 10 + str[3] - '0' * 1111;
- date.month = str[5] * 10 + str[6] - '0' * 11;
- date.day = str[8] * 10 + str[9] - '0' * 11;
- } else if ( length == 8 ) {
- date.year = str[0] * 1000 + str[1] * 100 + str[2] * 10 + str[3] - '0' * 1111;
- date.month = str[4] * 10 + str[5] - '0' * 11;
- date.day = str[6] * 10 + str[7] - '0' * 11;
- }
-
- return date;
-}
-
-char *
-e_v_object_get_child_value(VObject *vobj, char *name, char *default_charset)
-{
- char *ret_val;
- VObjectIterator iterator;
- gboolean free_charset = FALSE;
- VObject *charset_obj;
-
- if ((charset_obj = isAPropertyOf (vobj, "CHARSET"))) {
- switch (vObjectValueType (charset_obj)) {
- case VCVT_STRINGZ:
- default_charset = (char *) vObjectStringZValue(charset_obj);
- break;
- case VCVT_USTRINGZ:
- default_charset = fakeCString (vObjectUStringZValue (charset_obj));
- free_charset = TRUE;
- break;
- }
- }
-
- initPropIterator(&iterator, vobj);
- while(moreIteration (&iterator)) {
- VObject *attribute = nextVObject(&iterator);
- const char *id = vObjectName(attribute);
- if ( ! strcmp(id, name) ) {
- assign_string(attribute, default_charset, &ret_val);
- return ret_val;
- }
- }
- if (free_charset)
- free (default_charset);
-
- return NULL;
-}
-
-static struct {
- char *id;
- ECardPhoneFlags flag;
-} phone_pairs[] = {
- { VCPreferredProp, E_CARD_PHONE_PREF },
- { VCWorkProp, E_CARD_PHONE_WORK },
- { VCHomeProp, E_CARD_PHONE_HOME },
- { VCVoiceProp, E_CARD_PHONE_VOICE },
- { VCFaxProp, E_CARD_PHONE_FAX },
- { VCMessageProp, E_CARD_PHONE_MSG },
- { VCCellularProp, E_CARD_PHONE_CELL },
- { VCPagerProp, E_CARD_PHONE_PAGER },
- { VCBBSProp, E_CARD_PHONE_BBS },
- { VCModemProp, E_CARD_PHONE_MODEM },
- { VCCarProp, E_CARD_PHONE_CAR },
- { VCISDNProp, E_CARD_PHONE_ISDN },
- { VCVideoProp, E_CARD_PHONE_VIDEO },
- { "X-EVOLUTION-ASSISTANT", E_CARD_PHONE_ASSISTANT },
- { "X-EVOLUTION-CALLBACK", E_CARD_PHONE_CALLBACK },
- { "X-EVOLUTION-RADIO", E_CARD_PHONE_RADIO },
- { "X-EVOLUTION-TELEX", E_CARD_PHONE_TELEX },
- { "X-EVOLUTION-TTYTDD", E_CARD_PHONE_TTYTDD },
-};
-
-static ECardPhoneFlags
-get_phone_flags (VObject *vobj)
-{
- ECardPhoneFlags ret = 0;
- int i;
-
- for (i = 0; i < sizeof(phone_pairs) / sizeof(phone_pairs[0]); i++) {
- if (isAPropertyOf (vobj, phone_pairs[i].id)) {
- ret |= phone_pairs[i].flag;
- }
- }
-
- return ret;
-}
-
-static void
-set_phone_flags (VObject *vobj, ECardPhoneFlags flags)
-{
- int i;
-
- for (i = 0; i < sizeof(phone_pairs) / sizeof(phone_pairs[0]); i++) {
- if (flags & phone_pairs[i].flag) {
- addProp (vobj, phone_pairs[i].id);
- }
- }
-}
-
-static struct {
- char *id;
- ECardAddressFlags flag;
-} addr_pairs[] = {
- { VCDomesticProp, E_CARD_ADDR_DOM },
- { VCInternationalProp, E_CARD_ADDR_INTL },
- { VCPostalProp, E_CARD_ADDR_POSTAL },
- { VCParcelProp, E_CARD_ADDR_PARCEL },
- { VCHomeProp, E_CARD_ADDR_HOME },
- { VCWorkProp, E_CARD_ADDR_WORK },
- { "PREF", E_CARD_ADDR_DEFAULT },
-};
-
-static ECardAddressFlags
-get_address_flags (VObject *vobj)
-{
- ECardAddressFlags ret = 0;
- int i;
-
- for (i = 0; i < sizeof(addr_pairs) / sizeof(addr_pairs[0]); i++) {
- if (isAPropertyOf (vobj, addr_pairs[i].id)) {
- ret |= addr_pairs[i].flag;
- }
- }
-
- return ret;
-}
-
-static void
-set_address_flags (VObject *vobj, ECardAddressFlags flags)
-{
- int i;
-
- for (i = 0; i < sizeof(addr_pairs) / sizeof(addr_pairs[0]); i++) {
- if (flags & addr_pairs[i].flag) {
- addProp (vobj, addr_pairs[i].id);
- }
- }
-}
-
-#include <Evolution-Composer.h>
-
-#define COMPOSER_OAFID "OAFIID:GNOME_Evolution_Mail_Composer"
-
-void
-e_card_list_send (GList *cards, ECardDisposition disposition)
-{
- BonoboObjectClient *bonobo_server;
- GNOME_Evolution_Composer composer_server;
- CORBA_Environment ev;
-
- if (cards == NULL)
- return;
-
- /* First, I obtain an object reference that represents the Composer. */
- bonobo_server = bonobo_object_activate (COMPOSER_OAFID, 0);
-
- g_return_if_fail (bonobo_server != NULL);
-
- composer_server = bonobo_object_corba_objref (BONOBO_OBJECT (bonobo_server));
-
- CORBA_exception_init (&ev);
-
- if (disposition == E_CARD_DISPOSITION_AS_TO) {
- GNOME_Evolution_Composer_RecipientList *to_list, *cc_list, *bcc_list;
- CORBA_char *subject;
- int to_i, bcc_i;
- GList *iter;
- gint to_length = 0, bcc_length = 0;
-
- /* Figure out how many addresses of each kind we have. */
- for (iter = cards; iter != NULL; iter = g_list_next (iter)) {
- ECard *card = E_CARD (iter->data);
- if (e_card_evolution_list (card)) {
- gint len = card->email ? e_list_length (card->email) : 0;
- if (e_card_evolution_list_show_addresses (card))
- to_length += len;
- else
- bcc_length += len;
- } else {
- if (card->email != NULL)
- ++to_length;
- }
- }
-
- /* Now I have to make a CORBA sequences that represents a recipient list with
- the right number of entries, for the cards. */
- to_list = GNOME_Evolution_Composer_RecipientList__alloc ();
- to_list->_maximum = to_length;
- to_list->_length = to_length;
- if (to_length > 0) {
- to_list->_buffer = CORBA_sequence_GNOME_Evolution_Composer_Recipient_allocbuf (to_length);
- }
-
- cc_list = GNOME_Evolution_Composer_RecipientList__alloc ();
- cc_list->_maximum = cc_list->_length = 0;
-
- bcc_list = GNOME_Evolution_Composer_RecipientList__alloc ();
- bcc_list->_maximum = bcc_length;
- bcc_list->_length = bcc_length;
- if (bcc_length > 0) {
- bcc_list->_buffer = CORBA_sequence_GNOME_Evolution_Composer_Recipient_allocbuf (bcc_length);
- }
-
- to_i = 0;
- bcc_i = 0;
- while (cards != NULL) {
- ECard *card = cards->data;
- EIterator *iterator;
- gchar *name, *addr;
- gboolean is_list, is_hidden, free_name_addr;
- GNOME_Evolution_Composer_Recipient *recipient;
-
- if (card->email != NULL) {
-
- is_list = e_card_evolution_list (card);
- is_hidden = is_list && !e_card_evolution_list_show_addresses (card);
-
- for (iterator = e_list_get_iterator (card->email); e_iterator_is_valid (iterator); e_iterator_next (iterator)) {
-
- if (is_hidden) {
- recipient = &(bcc_list->_buffer[bcc_i]);
- ++bcc_i;
- } else {
- recipient = &(to_list->_buffer[to_i]);
- ++to_i;
- }
-
- name = "";
- addr = "";
- free_name_addr = FALSE;
- if (e_iterator_is_valid (iterator)) {
-
- if (is_list) {
- /* We need to decode the list entries, which are XMLified EDestinations. */
- EDestination *dest = e_destination_import (e_iterator_get (iterator));
- if (dest != NULL) {
- name = g_strdup (e_destination_get_name (dest));
- addr = g_strdup (e_destination_get_email (dest));
- free_name_addr = TRUE;
- gtk_object_unref (GTK_OBJECT (dest));
- }
-
- } else { /* is just a plain old card */
- if (card->name)
- name = e_card_name_to_string (card->name);
- addr = g_strdup ((char *) e_iterator_get (iterator));
- free_name_addr = TRUE;
- }
- }
-
- recipient->name = CORBA_string_dup (name ? name : "");
- recipient->address = CORBA_string_dup (addr ? addr : "");
-
- if (free_name_addr) {
- g_free ((gchar *) name);
- g_free ((gchar *) addr);
- }
-
- /* If this isn't a list, we quit after the first (i.e. the default) address. */
- if (!is_list)
- break;
-
- }
- gtk_object_unref (GTK_OBJECT (iterator));
- }
-
- cards = g_list_next (cards);
- }
-
- subject = CORBA_string_dup ("");
-
- GNOME_Evolution_Composer_setHeaders (composer_server, to_list, cc_list, bcc_list, subject, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_printerr ("gui/e-meeting-edit.c: I couldn't set the composer headers via CORBA! Aagh.\n");
- CORBA_exception_free (&ev);
- return;
- }
-
- CORBA_free (to_list);
- CORBA_free (cc_list);
- CORBA_free (bcc_list);
- CORBA_free (subject);
- }
-
- if (disposition == E_CARD_DISPOSITION_AS_ATTACHMENT) {
- CORBA_char *content_type, *filename, *description;
- GNOME_Evolution_Composer_AttachmentData *attach_data;
- CORBA_boolean show_inline;
- char *tempstr;
-
- GNOME_Evolution_Composer_RecipientList *to_list, *cc_list, *bcc_list;
- CORBA_char *subject;
-
- content_type = CORBA_string_dup ("text/x-vcard");
- filename = CORBA_string_dup ("");
-
- if (cards->next) {
- description = CORBA_string_dup (_("Multiple VCards"));
- } else {
- char *file_as;
-
- gtk_object_get(GTK_OBJECT(cards->data),
- "file_as", &file_as,
- NULL);
-
- tempstr = g_strdup_printf (_("VCard for %s"), file_as);
- description = CORBA_string_dup (tempstr);
- g_free (tempstr);
- }
-
- show_inline = FALSE;
-
- tempstr = e_card_list_get_vcard (cards);
- attach_data = GNOME_Evolution_Composer_AttachmentData__alloc();
- attach_data->_maximum = attach_data->_length = strlen (tempstr);
- attach_data->_buffer = CORBA_sequence_CORBA_char_allocbuf (attach_data->_length);
- strcpy (attach_data->_buffer, tempstr);
- g_free (tempstr);
-
- GNOME_Evolution_Composer_attachData (composer_server,
- content_type, filename, description,
- show_inline, attach_data,
- &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_printerr ("gui/e-meeting-edit.c: I couldn't attach data to the composer via CORBA! Aagh.\n");
- CORBA_exception_free (&ev);
- return;
- }
-
- CORBA_free (content_type);
- CORBA_free (filename);
- CORBA_free (description);
- CORBA_free (attach_data);
-
- to_list = GNOME_Evolution_Composer_RecipientList__alloc ();
- to_list->_maximum = to_list->_length = 0;
-
- cc_list = GNOME_Evolution_Composer_RecipientList__alloc ();
- cc_list->_maximum = cc_list->_length = 0;
-
- bcc_list = GNOME_Evolution_Composer_RecipientList__alloc ();
- bcc_list->_maximum = bcc_list->_length = 0;
-
- if (!cards || cards->next) {
- subject = CORBA_string_dup ("Contact information");
- } else {
- ECard *card = cards->data;
- const gchar *tempstr2;
-
- tempstr2 = NULL;
- gtk_object_get(GTK_OBJECT(card),
- "file_as", &tempstr2,
- NULL);
- if (!tempstr2 || !*tempstr2)
- gtk_object_get(GTK_OBJECT(card),
- "full_name", &tempstr2,
- NULL);
- if (!tempstr2 || !*tempstr2)
- gtk_object_get(GTK_OBJECT(card),
- "org", &tempstr2,
- NULL);
- if (!tempstr2 || !*tempstr2) {
- EList *list;
- EIterator *iterator;
- gtk_object_get(GTK_OBJECT(card),
- "email", &list,
- NULL);
- iterator = e_list_get_iterator (list);
- if (e_iterator_is_valid (iterator)) {
- tempstr2 = e_iterator_get (iterator);
- }
- gtk_object_unref (GTK_OBJECT (iterator));
- }
-
- if (!tempstr2 || !*tempstr2)
- tempstr = g_strdup_printf ("Contact information");
- else
- tempstr = g_strdup_printf ("Contact information for %s", tempstr2);
- subject = CORBA_string_dup (tempstr);
- g_free (tempstr);
- }
-
- GNOME_Evolution_Composer_setHeaders (composer_server, to_list, cc_list, bcc_list, subject, &ev);
-
- CORBA_free (to_list);
- CORBA_free (cc_list);
- CORBA_free (bcc_list);
- CORBA_free (subject);
- }
-
- GNOME_Evolution_Composer_show (composer_server, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_printerr ("gui/e-meeting-edit.c: I couldn't show the composer via CORBA! Aagh.\n");
- CORBA_exception_free (&ev);
- return;
- }
-
- CORBA_exception_free (&ev);
-}
-
-void
-e_card_send (ECard *card, ECardDisposition disposition)
-{
- GList *list;
- list = g_list_prepend (NULL, card);
- e_card_list_send (list, disposition);
- g_list_free (list);
-}
-
-gboolean
-e_card_evolution_list (ECard *card)
-{
- g_return_val_if_fail (card && E_IS_CARD (card), FALSE);
- return card->list;
-}
-
-gboolean
-e_card_evolution_list_show_addresses (ECard *card)
-{
- g_return_val_if_fail (card && E_IS_CARD (card), FALSE);
- return card->list_show_addresses;
-}
-
-typedef struct _CardLoadData CardLoadData;
-struct _CardLoadData {
- gchar *card_id;
- ECardCallback cb;
- gpointer closure;
-};
-
-static void
-get_card_cb (EBook *book, EBookStatus status, ECard *card, gpointer closure)
-{
- CardLoadData *data = (CardLoadData *) closure;
-
- if (data->cb != NULL) {
- if (status == E_BOOK_STATUS_SUCCESS)
- data->cb (card, data->closure);
- else
- data->cb (NULL, data->closure);
- }
-
- g_free (data->card_id);
- g_free (data);
-}
-
-static void
-card_load_cb (EBook *book, EBookStatus status, gpointer closure)
-{
- CardLoadData *data = (CardLoadData *) closure;
-
- if (status == E_BOOK_STATUS_SUCCESS)
- e_book_get_card (book, data->card_id, get_card_cb, closure);
- else {
- data->cb (NULL, data->closure);
- g_free (data->card_id);
- g_free (data);
- }
-}
-
-void
-e_card_load_uri (const gchar *book_uri, const gchar *uid, ECardCallback cb, gpointer closure)
-{
- CardLoadData *data;
- EBook *book;
-
- data = g_new (CardLoadData, 1);
- data->card_id = g_strdup (uid);
- data->cb = cb;
- data->closure = closure;
-
- book = e_book_new ();
- e_book_load_uri (book, book_uri, card_load_cb, data);
-}
diff --git a/addressbook/backend/ebook/e-card.h b/addressbook/backend/ebook/e-card.h
deleted file mode 100644
index 23876bd63a..0000000000
--- a/addressbook/backend/ebook/e-card.h
+++ /dev/null
@@ -1,218 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- * Arturo Espinosa
- * Nat Friedman (nat@ximian.com)
- *
- * Copyright (C) 2000 Ximian, Inc.
- * Copyright (C) 1999 The Free Software Foundation
- */
-
-#ifndef __E_CARD_H__
-#define __E_CARD_H__
-
-#include <time.h>
-#include <gtk/gtkobject.h>
-#include <stdio.h>
-#include <addressbook/backend/ebook/e-card-types.h>
-#include <e-util/e-list.h>
-
-#define E_TYPE_CARD (e_card_get_type ())
-#define E_CARD(obj) (GTK_CHECK_CAST ((obj), E_TYPE_CARD, ECard))
-#define E_CARD_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_CARD, ECardClass))
-#define E_IS_CARD(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_CARD))
-#define E_IS_CARD_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_CARD))
-
-typedef struct _ECard ECard;
-typedef struct _ECardClass ECardClass;
-
-struct _EBook; /* Forward reference */
-
-struct _ECard {
- GtkObject object;
- char *id;
-
- struct _EBook *book; /* The EBook this card is from. */
-
- char *file_as; /* The File As field. */
- char *fname; /* The full name. */
- ECardName *name; /* The structured name. */
- EList *address; /* Delivery addresses (ECardDeliveryAddress *) */
- EList *address_label; /* Delivery address labels
- * (ECardAddrLabel *) */
-
- EList *phone; /* Phone numbers (ECardPhone *) */
- EList *email; /* Email addresses (char *) */
- char *url; /* The person's web page. */
-
- ECardDate *bday; /* The person's birthday. */
-
- char *note;
-
-
- char *org; /* The person's organization. */
- char *org_unit; /* The person's organization unit. */
- char *office; /* The person's office. */
- char *role; /* The person's role w/in his org */
- char *title; /* The person's title w/in his org */
-
- char *manager;
- char *assistant;
-
- char *nickname; /* The person's nickname */
-
- char *spouse; /* The person's spouse. */
- ECardDate *anniversary; /* The person's anniversary. */
-
- char *mailer; /* Mailer */
-
- char *caluri; /* Calendar URI */
- char *fburl; /* Free Busy URL */
-
- gint timezone; /* number of minutes from UTC as an int */
-
- ECardDate *last_use;
- float raw_use_score;
-
- char *related_contacts; /* EDestinationV (serialized) of related contacts. */
-
- EList *categories; /* Categories. */
-
- EList *arbitrary; /* Arbitrary fields. */
-
-
-
- guint32 wants_html : 1; /* Wants html mail. */
- guint32 wants_html_set : 1; /* Wants html mail. */
- guint32 list : 1; /* If the card corresponds to a contact list */
- guint32 list_show_addresses : 1; /* Whether to show the addresses
- in the To: or Bcc: field */
-
-#if 0
- ECardPhoto *logo; /* This person's org's logo. */
-
- ECardPhoto *photo; /* A photo of the person. */
-
- ECard *agent; /* A person who sereves as this
- guy's agent/secretary/etc. */
-
- ECardSound *sound;
-
- ECardKey *key; /* The person's public key. */
- ECardTimeZone *timezn; /* The person's time zone. */
- ECardGeoPos *geopos; /* The person's long/lat. */
-
- ECardRev *rev; /* The time this card was last
- modified. */
-
- EList xtension;
-#endif
-};
-
-struct _ECardClass {
- GtkObjectClass parent_class;
- GHashTable *attribute_jump_table;
-};
-
-
-/* Simple functions */
-ECard *e_card_new (char *vcard); /* Assumes utf8 */
-ECard *e_card_new_with_default_charset (char *vcard,
- char *default_charset);
-const char *e_card_get_id (ECard *card);
-void e_card_set_id (ECard *card,
- const char *character);
-
-struct _EBook *e_card_get_book (ECard *card);
-void e_card_set_book (ECard *card,
- struct _EBook *book);
-char *e_card_get_vcard (ECard *card);
-char *e_card_get_vcard_assume_utf8 (ECard *card);
-char *e_card_list_get_vcard (const GList *list);
-ECard *e_card_duplicate (ECard *card);
-float e_card_get_use_score (ECard *card);
-void e_card_touch (ECard *card);
-
-/* Evolution List convenience functions */
-/* used for encoding uids in email addresses */
-gboolean e_card_evolution_list (ECard *card);
-gboolean e_card_evolution_list_show_addresses (ECard *card);
-
-/* ECardPhone manipulation */
-ECardPhone *e_card_phone_new (void);
-ECardPhone *e_card_phone_copy (const ECardPhone *phone);
-ECardPhone *e_card_phone_ref (const ECardPhone *phone);
-void e_card_phone_unref (ECardPhone *phone);
-
-/* ECardDeliveryAddress manipulation */
-ECardDeliveryAddress *e_card_delivery_address_new (void);
-ECardDeliveryAddress *e_card_delivery_address_copy (const ECardDeliveryAddress *addr);
-ECardDeliveryAddress *e_card_delivery_address_ref (const ECardDeliveryAddress *addr);
-void e_card_delivery_address_unref (ECardDeliveryAddress *addr);
-gboolean e_card_delivery_address_is_empty (const ECardDeliveryAddress *addr);
-char *e_card_delivery_address_to_string (const ECardDeliveryAddress *addr);
-ECardDeliveryAddress *e_card_delivery_address_from_label (const ECardAddrLabel *label);
-ECardAddrLabel *e_card_delivery_address_to_label (const ECardDeliveryAddress *addr);
-
-/* ECardAddrLabel manipulation */
-ECardAddrLabel *e_card_address_label_new (void);
-ECardAddrLabel *e_card_address_label_copy (const ECardAddrLabel *addr);
-ECardAddrLabel *e_card_address_label_ref (const ECardAddrLabel *addr);
-void e_card_address_label_unref (ECardAddrLabel *addr);
-
-/* ECardName manipulation */
-ECardName *e_card_name_new (void);
-ECardName *e_card_name_copy (const ECardName *name);
-ECardName *e_card_name_ref (const ECardName *name);
-void e_card_name_unref (ECardName *name);
-char *e_card_name_to_string (const ECardName *name);
-ECardName *e_card_name_from_string (const char *full_name);
-
-/* ECardDate */
-ECardDate e_card_date_from_string (const gchar *str);
-gchar *e_card_date_to_string (ECardDate *dt);
-
-/* ECardArbitrary manipulation */
-ECardArbitrary *e_card_arbitrary_new (void);
-ECardArbitrary *e_card_arbitrary_copy (const ECardArbitrary *arbitrary);
-ECardArbitrary *e_card_arbitrary_ref (const ECardArbitrary *arbitrary);
-void e_card_arbitrary_unref (ECardArbitrary *arbitrary);
-
-/* ECard email manipulation */
-gboolean e_card_email_match_string (const ECard *card,
- const gchar *str);
-gint e_card_email_find_number (const ECard *card,
- const gchar *email);
-
-/* Specialized functionality */
-GList *e_card_load_cards_from_file (const char *filename);
-GList *e_card_load_cards_from_file_with_default_charset (const char *filename,
- char *default_charset);
-GList *e_card_load_cards_from_string (const char *str);
-GList *e_card_load_cards_from_string_with_default_charset (const char *str,
- char *default_charset);
-void e_card_free_empty_lists (ECard *card);
-
-enum _ECardDisposition {
- E_CARD_DISPOSITION_AS_ATTACHMENT,
- E_CARD_DISPOSITION_AS_TO,
-};
-typedef enum _ECardDisposition ECardDisposition;
-void e_card_send (ECard *card,
- ECardDisposition disposition);
-void e_card_list_send (GList *cards,
- ECardDisposition disposition);
-
-/* Getting ECards via their URIs */
-typedef void (*ECardCallback) (ECard *card, gpointer closure);
-void e_card_load_uri (const gchar *book_uri,
- const gchar *uid,
- ECardCallback cb,
- gpointer closure);
-
-
-/* Standard Gtk function */
-GtkType e_card_get_type (void);
-
-#endif /* ! __E_CARD_H__ */
diff --git a/addressbook/backend/ebook/e-destination.c b/addressbook/backend/ebook/e-destination.c
deleted file mode 100644
index 5cb5fa859f..0000000000
--- a/addressbook/backend/ebook/e-destination.c
+++ /dev/null
@@ -1,1690 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * e-destination.c
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Developed by Jon Trowbridge <trow@ximian.com>
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA.
- */
-
-#include <config.h>
-#include "e-destination.h"
-
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#include <gtk/gtkobject.h>
-#include <gtk/gtkmain.h>
-#include <libgnome/gnome-defs.h>
-#include <libgnome/gnome-i18n.h>
-#include "e-book.h"
-#include "e-book-util.h"
-#include <gal/widgets/e-unicode.h>
-#include <gnome-xml/parser.h>
-#include <gnome-xml/xmlmemory.h>
-#include <camel/camel-internet-address.h>
-
-#define d(x) x
-
-enum {
- CHANGED,
- CARDIFIED,
- LAST_SIGNAL
-};
-
-guint e_destination_signals[LAST_SIGNAL] = { 0 };
-
-struct _EDestinationPrivate {
- gchar *raw;
-
- gchar *book_uri;
- gchar *card_uid;
- ECard *card;
- gint card_email_num;
-
- ECard *old_card;
- gint old_card_email_num;
- gchar *old_textrep;
-
- gchar *name;
- gchar *email;
- gchar *addr;
- gchar *textrep;
-
- GList *list_dests;
-
- guint html_mail_override : 1;
- guint wants_html_mail : 1;
-
- guint show_addresses : 1;
-
- guint has_been_cardified : 1;
- guint allow_cardify : 1;
- guint cannot_cardify : 1;
- guint auto_recipient : 1;
- guint pending_cardification;
-
- guint pending_change : 1;
-
- EBook *cardify_book;
-
- gint freeze_count;
-};
-
-static void e_destination_clear_card (EDestination *);
-static void e_destination_clear_strings (EDestination *);
-
-static GtkObjectClass *parent_class;
-
-static void
-e_destination_destroy (GtkObject *obj)
-{
- EDestination *dest = E_DESTINATION (obj);
-
- e_destination_clear (dest);
-
- if (dest->priv->old_card)
- gtk_object_unref (GTK_OBJECT (dest->priv->old_card));
-
- if (dest->priv->cardify_book)
- gtk_object_unref (GTK_OBJECT (dest->priv->cardify_book));
-
- g_free (dest->priv->old_textrep);
-
- g_free (dest->priv);
-
- if (parent_class->destroy)
- parent_class->destroy (obj);
-}
-
-static void
-e_destination_class_init (EDestinationClass *klass)
-{
- GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
-
- parent_class = GTK_OBJECT_CLASS (gtk_type_class (GTK_TYPE_OBJECT));
-
- object_class->destroy = e_destination_destroy;
-
- e_destination_signals[CHANGED] =
- gtk_signal_new ("changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EDestinationClass, changed),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- e_destination_signals[CARDIFIED] =
- gtk_signal_new ("cardified",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EDestinationClass, cardified),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- gtk_object_class_add_signals (object_class, e_destination_signals, LAST_SIGNAL);
-}
-
-static void
-e_destination_init (EDestination *dest)
-{
- dest->priv = g_new0 (struct _EDestinationPrivate, 1);
-
- dest->priv->allow_cardify = TRUE;
- dest->priv->cannot_cardify = FALSE;
- dest->priv->auto_recipient = FALSE;
- dest->priv->pending_cardification = 0;
-}
-
-GtkType
-e_destination_get_type (void)
-{
- static GtkType dest_type = 0;
-
- if (!dest_type) {
- GtkTypeInfo dest_info = {
- "EDestination",
- sizeof (EDestination),
- sizeof (EDestinationClass),
- (GtkClassInitFunc) e_destination_class_init,
- (GtkObjectInitFunc) e_destination_init,
- NULL, NULL, /* reserved */
- (GtkClassInitFunc) NULL
- };
-
- dest_type = gtk_type_unique (gtk_object_get_type (), &dest_info);
- }
-
- return dest_type;
-}
-
-EDestination *
-e_destination_new (void)
-{
- return E_DESTINATION (gtk_type_new (E_TYPE_DESTINATION));
-}
-
-static void
-e_destination_freeze (EDestination *dest)
-{
- g_return_if_fail (E_IS_DESTINATION (dest));
- g_return_if_fail (dest->priv->freeze_count >= 0);
-
- dest->priv->freeze_count++;
-}
-
-static void
-e_destination_thaw (EDestination *dest)
-{
- g_return_if_fail (E_IS_DESTINATION (dest));
- g_return_if_fail (dest->priv->freeze_count > 0);
-
- dest->priv->freeze_count--;
- if (dest->priv->freeze_count == 0 && dest->priv->pending_change)
- e_destination_changed (dest);
-}
-
-void
-e_destination_changed (EDestination *dest)
-{
- if (dest->priv->freeze_count == 0) {
- gtk_signal_emit (GTK_OBJECT (dest), e_destination_signals[CHANGED]);
- dest->priv->pending_change = FALSE;
- dest->priv->cannot_cardify = FALSE;
-
- } else {
- dest->priv->pending_change = TRUE;
- }
-}
-
-EDestination *
-e_destination_copy (const EDestination *dest)
-{
- EDestination *new_dest;
- GList *iter;
-
- g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL);
-
- new_dest = e_destination_new ();
-
- new_dest->priv->book_uri = g_strdup (dest->priv->book_uri);
- new_dest->priv->card_uid = g_strdup (dest->priv->card_uid);
- new_dest->priv->name = g_strdup (dest->priv->name);
- new_dest->priv->email = g_strdup (dest->priv->email);
- new_dest->priv->addr = g_strdup (dest->priv->addr);
- new_dest->priv->card_email_num = dest->priv->card_email_num;
- new_dest->priv->old_card_email_num = dest->priv->old_card_email_num;
- new_dest->priv->old_textrep = g_strdup (dest->priv->old_textrep);
-
- new_dest->priv->card = dest->priv->card;
- if (new_dest->priv->card)
- gtk_object_ref (GTK_OBJECT (new_dest->priv->card));
-
- new_dest->priv->old_card = dest->priv->old_card;
- if (new_dest->priv->old_card)
- gtk_object_ref (GTK_OBJECT (new_dest->priv->old_card));
-
- new_dest->priv->html_mail_override = dest->priv->html_mail_override;
- new_dest->priv->wants_html_mail = dest->priv->wants_html_mail;
-
- for (iter = dest->priv->list_dests; iter != NULL; iter = g_list_next (iter)) {
- new_dest->priv->list_dests = g_list_append (new_dest->priv->list_dests,
- e_destination_copy (E_DESTINATION (iter->data)));
- }
-
- return new_dest;
-}
-
-static void
-e_destination_clear_card (EDestination *dest)
-{
- if (dest->priv->card) {
- if (dest->priv->old_card)
- gtk_object_unref (GTK_OBJECT (dest->priv->old_card));
-
- dest->priv->old_card = dest->priv->card;
- dest->priv->old_card_email_num = dest->priv->card_email_num;
-
- g_free (dest->priv->old_textrep);
- dest->priv->old_textrep = g_strdup (e_destination_get_textrep (dest));
- }
-
- g_free (dest->priv->book_uri);
- dest->priv->book_uri = NULL;
- g_free (dest->priv->card_uid);
- dest->priv->card_uid = NULL;
-
- dest->priv->card = NULL;
- dest->priv->card_email_num = -1;
-
- g_list_foreach (dest->priv->list_dests, (GFunc) gtk_object_unref, NULL);
- g_list_free (dest->priv->list_dests);
- dest->priv->list_dests = NULL;
-
- dest->priv->allow_cardify = TRUE;
- dest->priv->cannot_cardify = FALSE;
-
- e_destination_cancel_cardify (dest);
-
- e_destination_changed (dest);
-}
-
-static void
-e_destination_clear_strings (EDestination *dest)
-{
- g_free (dest->priv->raw);
- dest->priv->raw = NULL;
-
- g_free (dest->priv->name);
- dest->priv->name = NULL;
-
- g_free (dest->priv->email);
- dest->priv->email = NULL;
-
- g_free (dest->priv->addr);
- dest->priv->addr = NULL;
-
- g_free (dest->priv->textrep);
- dest->priv->textrep = NULL;
-
- e_destination_changed (dest);
-}
-
-void
-e_destination_clear (EDestination *dest)
-{
- g_return_if_fail (dest && E_IS_DESTINATION (dest));
-
- e_destination_freeze (dest);
-
- e_destination_clear_card (dest);
- e_destination_clear_strings (dest);
-
- e_destination_thaw (dest);
-}
-
-static gboolean
-nonempty (const gchar *s)
-{
- gunichar c;
- while (*s) {
- c = g_utf8_get_char (s);
- if (!g_unichar_isspace (c))
- return TRUE;
- s = g_utf8_next_char (s);
- }
- return FALSE;
-}
-
-gboolean
-e_destination_is_empty (const EDestination *dest)
-
-{
- struct _EDestinationPrivate *p;
-
- g_return_val_if_fail (E_IS_DESTINATION (dest), TRUE);
-
- p = dest->priv;
-
- return !(p->card != NULL
- || (p->book_uri && *p->book_uri)
- || (p->card_uid && *p->card_uid)
- || (p->raw && nonempty (p->raw))
- || (p->name && nonempty (p->name))
- || (p->email && nonempty (p->email))
- || (p->addr && nonempty (p->addr))
- || (p->list_dests != NULL));
-}
-
-gboolean
-e_destination_is_valid (const EDestination *dest)
-{
- const char *email;
-
- g_return_val_if_fail (E_IS_DESTINATION (dest), FALSE);
-
- if (e_destination_from_card (dest))
- return TRUE;
-
- email = e_destination_get_email (dest);
-
- /* FIXME: if we really wanted to get fancy here, we could
- check to make sure that the address was valid according to
- rfc822's addr-spec grammar. */
-
- return email && *email && strchr (email, '@');
-}
-
-gboolean
-e_destination_equal (const EDestination *a, const EDestination *b)
-{
- const struct _EDestinationPrivate *pa, *pb;
- const char *na, *nb;
-
- g_return_val_if_fail (E_IS_DESTINATION (a), FALSE);
- g_return_val_if_fail (E_IS_DESTINATION (b), FALSE);
-
- if (a == b)
- return TRUE;
-
- pa = a->priv;
- pb = b->priv;
-
- /* Check equality of cards. */
- if (pa->card || pb->card) {
- if (! (pa->card && pb->card))
- return FALSE;
-
- if (pa->card == pb->card || !strcmp (e_card_get_id (pa->card), e_card_get_id (pb->card)))
- return TRUE;
-
- return FALSE;
- }
-
- /* Just in case name returns NULL */
- na = e_destination_get_name (a);
- nb = e_destination_get_name (b);
- if ((na || nb) && !(na && nb && ! g_utf8_strcasecmp (na, nb)))
- return FALSE;
-
- if (!g_strcasecmp (e_destination_get_email (a), e_destination_get_email (b)))
- return TRUE;
-
- return FALSE;
-}
-
-void
-e_destination_set_card (EDestination *dest, ECard *card, gint email_num)
-{
- g_return_if_fail (dest && E_IS_DESTINATION (dest));
- g_return_if_fail (card && E_IS_CARD (card));
-
- if (dest->priv->card != card || dest->priv->card_email_num != email_num) {
- /* We have to freeze/thaw around these operations so that the 'changed'
- signals don't cause the EDestination's internal state to be altered
- before we can finish setting ->card && ->card_email_num. */
- e_destination_freeze (dest);
- e_destination_clear (dest);
-
- dest->priv->card = card;
- gtk_object_ref (GTK_OBJECT (dest->priv->card));
-
- dest->priv->card_email_num = email_num;
-
- e_destination_changed (dest);
- e_destination_thaw (dest);
- }
-}
-
-void
-e_destination_set_book_uri (EDestination *dest, const gchar *uri)
-{
- g_return_if_fail (dest && E_IS_DESTINATION (dest));
- g_return_if_fail (uri != NULL);
-
- if (dest->priv->book_uri == NULL || strcmp (dest->priv->book_uri, uri)) {
- g_free (dest->priv->book_uri);
- dest->priv->book_uri = g_strdup (uri);
-
- /* If we already have a card, remove it unless it's uri matches the one
- we just set. */
- if (dest->priv->card) {
- EBook *book = e_card_get_book (dest->priv->card);
- if ((!book) || strcmp (uri, e_book_get_uri (book))) {
- gtk_object_unref (GTK_OBJECT (dest->priv->card));
- dest->priv->card = NULL;
- }
- }
-
- e_destination_changed (dest);
- }
-}
-
-void
-e_destination_set_card_uid (EDestination *dest, const gchar *uid, gint email_num)
-{
- g_return_if_fail (dest && E_IS_DESTINATION (dest));
- g_return_if_fail (uid != NULL);
-
- if (dest->priv->card_uid == NULL
- || strcmp (dest->priv->card_uid, uid)
- || dest->priv->card_email_num != email_num) {
-
- g_free (dest->priv->card_uid);
- dest->priv->card_uid = g_strdup (uid);
- dest->priv->card_email_num = email_num;
-
- /* If we already have a card, remove it unless it's uri matches the one
- we just set. */
- if (dest->priv->card && strcmp (uid, e_card_get_id (dest->priv->card))) {
- gtk_object_unref (GTK_OBJECT (dest->priv->card));
- dest->priv->card = NULL;
- }
-
- e_destination_changed (dest);
- }
-}
-
-void
-e_destination_set_name (EDestination *dest, const gchar *name)
-{
- gboolean changed = FALSE;
-
- g_return_if_fail (E_IS_DESTINATION (dest));
-
- if (name == NULL) {
- if (dest->priv->name != NULL) {
- g_free (dest->priv->name);
- dest->priv->name = NULL;
- changed = TRUE;
- }
- } else if (dest->priv->name == NULL || strcmp (dest->priv->name, name)) {
- g_free (dest->priv->name);
- dest->priv->name = g_strdup (name);
- changed = TRUE;
- }
-
- if (changed) {
- g_free (dest->priv->addr);
- dest->priv->addr = NULL;
- g_free (dest->priv->textrep);
- dest->priv->textrep = NULL;
- e_destination_changed (dest);
- }
-}
-
-void
-e_destination_set_email (EDestination *dest, const gchar *email)
-{
- gboolean changed = FALSE;
-
- g_return_if_fail (E_IS_DESTINATION (dest));
-
- if (email == NULL) {
- if (dest->priv->email != NULL) {
- g_free (dest->priv->addr);
- dest->priv->addr = NULL;
- changed = TRUE;
- }
- } else if (dest->priv->email == NULL || strcmp (dest->priv->email, email)) {
- g_free (dest->priv->email);
- dest->priv->email = g_strdup (email);
- changed = TRUE;
- }
-
- if (changed) {
- g_free (dest->priv->addr);
- dest->priv->addr = NULL;
- g_free (dest->priv->textrep);
- dest->priv->textrep = NULL;
- e_destination_changed (dest);
- }
-}
-
-void
-e_destination_set_html_mail_pref (EDestination *dest, gboolean x)
-{
- g_return_if_fail (dest && E_IS_DESTINATION (dest));
-
- dest->priv->html_mail_override = TRUE;
- if (dest->priv->wants_html_mail != x) {
- dest->priv->wants_html_mail = x;
- e_destination_changed (dest);
- }
-}
-
-gboolean
-e_destination_contains_card (const EDestination *dest)
-{
- g_return_val_if_fail (dest && E_IS_DESTINATION (dest), FALSE);
- return dest->priv->card != NULL;
-}
-
-gboolean
-e_destination_from_card (const EDestination *dest)
-{
- g_return_val_if_fail (dest && E_IS_DESTINATION (dest), FALSE);
- return dest->priv->card != NULL || dest->priv->book_uri != NULL || dest->priv->card_uid != NULL;
-}
-
-gboolean
-e_destination_is_auto_recipient (const EDestination *dest)
-{
- g_return_val_if_fail (dest && E_IS_DESTINATION (dest), FALSE);
-
- return dest->priv->auto_recipient;
-}
-
-void
-e_destination_set_auto_recipient (EDestination *dest, gboolean value)
-{
- g_return_if_fail (dest && E_IS_DESTINATION (dest));
-
- dest->priv->auto_recipient = value;
-}
-
-typedef struct _UseCard UseCard;
-struct _UseCard {
- EDestination *dest;
- EDestinationCardCallback cb;
- gpointer closure;
-};
-
-static void
-use_card_cb (ECard *card, gpointer closure)
-{
- UseCard *uc = (UseCard *) closure;
-
- if (card != NULL && uc->dest->priv->card == NULL) {
- uc->dest->priv->card = card;
- gtk_object_ref (GTK_OBJECT (uc->dest->priv->card));
- e_destination_changed (uc->dest);
- }
-
- if (uc->cb) {
- uc->cb (uc->dest, uc->dest->priv->card, uc->closure);
- }
-
- /* We held a copy of the destination during the callback. */
- gtk_object_unref (GTK_OBJECT (uc->dest));
- g_free (uc);
-}
-
-void
-e_destination_use_card (EDestination *dest, EDestinationCardCallback cb, gpointer closure)
-{
- g_return_if_fail (dest && E_IS_DESTINATION (dest));
-
- if (dest->priv->card != NULL) {
- if (cb)
- cb (dest, dest->priv->card, closure);
- } else if (dest->priv->book_uri != NULL && dest->priv->card_uid != NULL) {
- UseCard *uc = g_new (UseCard, 1);
-
- uc->dest = dest;
- /* Hold a reference to the destination during the callback. */
- gtk_object_ref (GTK_OBJECT (uc->dest));
- uc->cb = cb;
- uc->closure = closure;
- e_card_load_uri (dest->priv->book_uri, dest->priv->card_uid, use_card_cb, uc);
- } else {
- if (cb)
- cb (dest, NULL, closure);
- }
-}
-
-ECard *
-e_destination_get_card (const EDestination *dest)
-{
- g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL);
-
- return dest->priv->card;
-}
-
-const gchar *
-e_destination_get_card_uid (const EDestination *dest)
-{
- g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL);
-
- if (dest->priv->card_uid)
- return dest->priv->card_uid;
-
- if (dest->priv->card)
- return e_card_get_id (dest->priv->card);
-
- return NULL;
-}
-
-const gchar *
-e_destination_get_book_uri (const EDestination *dest)
-{
- g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL);
-
- if (dest->priv->book_uri)
- return dest->priv->book_uri;
-
- if (dest->priv->card) {
- EBook *book = e_card_get_book (dest->priv->card);
-
- if (book) {
- return e_book_get_uri (book);
- }
- }
-
- return NULL;
-}
-
-gint
-e_destination_get_email_num (const EDestination *dest)
-{
- g_return_val_if_fail (dest && E_IS_DESTINATION (dest), -1);
-
- if (dest->priv->card == NULL && (dest->priv->book_uri == NULL || dest->priv->card_uid == NULL))
- return -1;
-
- return dest->priv->card_email_num;
-}
-
-const gchar *
-e_destination_get_name (const EDestination *dest)
-{
- struct _EDestinationPrivate *priv;
-
- g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL);
-
- priv = (struct _EDestinationPrivate *)dest->priv; /* cast out const */
-
- if (priv->name == NULL) {
- if (priv->card != NULL) {
- priv->name = e_card_name_to_string (priv->card->name);
-
- if (priv->name == NULL || *priv->name == '\0') {
- g_free (priv->name);
- priv->name = g_strdup (priv->card->file_as);
- }
-
- if (priv->name == NULL || *priv->name == '\0') {
- g_free (priv->name);
- priv->name = g_strdup (e_destination_get_email (dest));
- }
- } else if (priv->raw != NULL) {
- CamelInternetAddress *addr = camel_internet_address_new ();
-
- if (camel_address_unformat (CAMEL_ADDRESS (addr), priv->raw)) {
- const char *camel_name = NULL;
-
- camel_internet_address_get (addr, 0, &camel_name, NULL);
- priv->name = g_strdup (camel_name);
- }
-
- camel_object_unref (CAMEL_OBJECT (addr));
- }
- }
-
- return priv->name;
-
-}
-
-const gchar *
-e_destination_get_email (const EDestination *dest)
-{
- struct _EDestinationPrivate *priv;
-
- g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL);
-
- priv = (struct _EDestinationPrivate *)dest->priv; /* cast out const */
-
- if (priv->email == NULL) {
- if (priv->card != NULL) {
- /* Pull the address out of the card. */
- if (priv->card->email) {
- EIterator *iter = e_list_get_iterator (priv->card->email);
- int n = priv->card_email_num;
-
- if (n >= 0) {
- while (n > 0) {
- e_iterator_next (iter);
- n--;
- }
-
- if (e_iterator_is_valid (iter)) {
- gconstpointer ptr = e_iterator_get (iter);
- priv->email = g_strdup ((char *) ptr);
- }
- }
- }
- } else if (priv->raw != NULL) {
- CamelInternetAddress *addr = camel_internet_address_new ();
-
- if (camel_address_unformat (CAMEL_ADDRESS (addr), priv->raw)) {
- const gchar *camel_email = NULL;
- camel_internet_address_get (addr, 0, NULL, &camel_email);
- priv->email = g_strdup (camel_email);
- }
-
- camel_object_unref (CAMEL_OBJECT (addr));
- }
-
- /* Force e-mail to be non-null... */
- if (priv->email == NULL) {
- priv->email = g_strdup ("");
- }
- }
-
- return priv->email;
-}
-
-const gchar *
-e_destination_get_address (const EDestination *dest)
-{
- struct _EDestinationPrivate *priv;
-
- g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL);
-
- priv = (struct _EDestinationPrivate *)dest->priv; /* cast out const */
-
- if (priv->addr == NULL) {
- CamelInternetAddress *addr = camel_internet_address_new ();
-
- if (e_destination_is_evolution_list (dest)) {
- GList *iter = dest->priv->list_dests;
-
- while (iter) {
- EDestination *list_dest = E_DESTINATION (iter->data);
-
- if (!e_destination_is_empty (list_dest)) {
- camel_internet_address_add (addr,
- e_destination_get_name (list_dest),
- e_destination_get_email (list_dest));
- }
- iter = g_list_next (iter);
- }
-
- priv->addr = camel_address_encode (CAMEL_ADDRESS (addr));
- } else if (priv->raw) {
-
- if (camel_address_unformat (CAMEL_ADDRESS (addr), priv->raw)) {
- priv->addr = camel_address_encode (CAMEL_ADDRESS (addr));
- }
- } else {
- camel_internet_address_add (addr,
- e_destination_get_name (dest),
- e_destination_get_email (dest));
-
- priv->addr = camel_address_encode (CAMEL_ADDRESS (addr));
- }
-
- camel_object_unref (CAMEL_OBJECT (addr));
- }
-
- return priv->addr;
-}
-
-void
-e_destination_set_raw (EDestination *dest, const gchar *raw)
-{
- g_return_if_fail (E_IS_DESTINATION (dest));
- g_return_if_fail (raw != NULL);
-
- if (dest->priv->raw == NULL || strcmp (dest->priv->raw, raw)) {
- e_destination_freeze (dest);
-
- e_destination_clear (dest);
- dest->priv->raw = g_strdup (raw);
- e_destination_changed (dest);
-
- e_destination_thaw (dest);
- }
-}
-
-const gchar *
-e_destination_get_textrep (const EDestination *dest)
-{
- const char *name, *email;
-
- g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL);
-
- if (dest->priv->raw)
- return dest->priv->raw;
-
- name = e_destination_get_name (dest);
- email = e_destination_get_email (dest);
-
- if (e_destination_from_card (dest) && name != NULL)
- return name;
-
- /* Make sure that our address gets quoted properly */
- if (name && email && dest->priv->textrep == NULL) {
- CamelInternetAddress *addr = camel_internet_address_new ();
-
- camel_internet_address_add (addr, name, email);
- g_free (dest->priv->textrep);
- dest->priv->textrep = camel_address_format (CAMEL_ADDRESS (addr));
- camel_object_unref (CAMEL_OBJECT (addr));
- }
-
- if (dest->priv->textrep != NULL)
- return dest->priv->textrep;
-
- if (email)
- return email;
-
- return "";
-}
-
-gboolean
-e_destination_is_evolution_list (const EDestination *dest)
-{
- g_return_val_if_fail (dest && E_IS_DESTINATION (dest), FALSE);
-
- if (dest->priv->list_dests == NULL
- && dest->priv->card != NULL
- && dest->priv->card->email != NULL
- && e_card_evolution_list (dest->priv->card)) {
-
- EIterator *iter = e_list_get_iterator (dest->priv->card->email);
-
- e_iterator_reset (iter);
- while (e_iterator_is_valid (iter)) {
- const char *dest_xml = (const char *) e_iterator_get (iter);
- EDestination *list_dest = e_destination_import (dest_xml);
-
- if (list_dest)
- dest->priv->list_dests = g_list_append (dest->priv->list_dests, list_dest);
- e_iterator_next (iter);
- }
- }
-
- return dest->priv->list_dests != NULL;
-}
-
-gboolean
-e_destination_list_show_addresses (const EDestination *dest)
-{
- g_return_val_if_fail (E_IS_DESTINATION (dest), FALSE);
-
- if (dest->priv->card != NULL)
- return e_card_evolution_list_show_addresses (dest->priv->card);
-
- return dest->priv->show_addresses;
-}
-
-gboolean
-e_destination_get_html_mail_pref (const EDestination *dest)
-{
- g_return_val_if_fail (dest && E_IS_DESTINATION (dest), FALSE);
-
- if (dest->priv->html_mail_override || dest->priv->card == NULL)
- return dest->priv->wants_html_mail;
-
- return dest->priv->card->wants_html;
-}
-
-gboolean
-e_destination_allow_cardification (const EDestination *dest)
-{
- g_return_val_if_fail (E_IS_DESTINATION (dest), FALSE);
-
- return dest->priv->allow_cardify;
-}
-
-void
-e_destination_set_allow_cardification (EDestination *dest, gboolean x)
-{
- g_return_if_fail (E_IS_DESTINATION (dest));
-
- dest->priv->allow_cardify = x;
-}
-
-static void
-set_cardify_book (EDestination *dest, EBook *book)
-{
- if (dest->priv->cardify_book && dest->priv->cardify_book != book) {
- gtk_object_unref (GTK_OBJECT (dest->priv->cardify_book));
- }
-
- dest->priv->cardify_book = book;
-
- if (book)
- gtk_object_ref (GTK_OBJECT (book));
-}
-
-static void
-name_and_email_simple_query_cb (EBook *book, EBookSimpleQueryStatus status, const GList *cards, gpointer closure)
-{
- EDestination *dest = E_DESTINATION (closure);
-
- if (status == E_BOOK_SIMPLE_QUERY_STATUS_SUCCESS && g_list_length ((GList *) cards) == 1) {
- ECard *card = E_CARD (cards->data);
- const char *email = e_destination_get_email (dest);
- int email_num = 0;
-
- if (e_destination_is_valid (dest) && email && *email) {
- email_num = e_card_email_find_number (card, e_destination_get_email (dest));
- }
-
- if (email_num >= 0) {
- const char *book_uri;
-
- book_uri = e_book_get_uri (book);
-
- dest->priv->has_been_cardified = TRUE;
- e_destination_set_card (dest, card, email_num);
- e_destination_set_book_uri (dest, book_uri);
- gtk_signal_emit (GTK_OBJECT (dest), e_destination_signals[CARDIFIED]);
- }
- }
-
- if (!dest->priv->has_been_cardified) {
- dest->priv->cannot_cardify = TRUE;
- }
-
- gtk_object_unref (GTK_OBJECT (dest)); /* drop the reference held by the query */
-}
-
-
-static void
-nickname_simple_query_cb (EBook *book, EBookSimpleQueryStatus status, const GList *cards, gpointer closure)
-{
- EDestination *dest = E_DESTINATION (closure);
-
- if (status == E_BOOK_SIMPLE_QUERY_STATUS_SUCCESS) {
- if (g_list_length ((GList *) cards) == 1) {
- const char *book_uri;
-
- book_uri = e_book_get_uri (book);
-
- dest->priv->has_been_cardified = TRUE;
- e_destination_set_card (dest, E_CARD (cards->data), 0); /* Uses primary e-mail by default. */
- e_destination_set_book_uri (dest, book_uri);
- gtk_signal_emit (GTK_OBJECT (dest), e_destination_signals[CARDIFIED]);
-
- gtk_object_unref (GTK_OBJECT (dest)); /* drop the reference held by the query */
-
- } else {
- /* We can only end up here if we don't look at all like an e-mail address, so
- we do a name-only query on the textrep */
-
- e_book_name_and_email_query (book,
- e_destination_get_textrep (dest),
- NULL,
- name_and_email_simple_query_cb,
- dest);
- }
- } else {
- /* Something went wrong with the query: drop our ref to the destination and return. */
- gtk_object_unref (GTK_OBJECT (dest));
- }
-}
-
-static void
-launch_cardify_query (EDestination *dest)
-{
- if (! e_destination_is_valid (dest)) {
- /* If it doesn't look like an e-mail address, see if it is a nickname. */
- e_book_nickname_query (dest->priv->cardify_book,
- e_destination_get_textrep (dest),
- nickname_simple_query_cb,
- dest);
-
- } else {
- e_book_name_and_email_query (dest->priv->cardify_book,
- e_destination_get_name (dest),
- e_destination_get_email (dest),
- name_and_email_simple_query_cb,
- dest);
- }
-}
-
-static void
-use_local_book_cb (EBook *book, gpointer closure)
-{
- EDestination *dest = E_DESTINATION (closure);
- if (dest->priv->cardify_book == NULL) {
- dest->priv->cardify_book = book;
- gtk_object_ref (GTK_OBJECT (book));
- }
-
- launch_cardify_query (dest);
-}
-
-
-static gboolean
-e_destination_reverting_is_a_good_idea (EDestination *dest)
-{
- const char *textrep;
- int len, old_len;
-
- g_return_val_if_fail (E_IS_DESTINATION (dest), FALSE);
- if (dest->priv->old_textrep == NULL)
- return FALSE;
-
- textrep = e_destination_get_textrep (dest);
-
- len = g_utf8_strlen (textrep, -1);
- old_len = g_utf8_strlen (dest->priv->old_textrep, -1);
-
- if (len <= old_len/2)
- return FALSE;
-
- return TRUE;
-}
-
-void
-e_destination_cardify (EDestination *dest, EBook *book)
-{
- g_return_if_fail (E_IS_DESTINATION (dest));
- g_return_if_fail (book == NULL || E_IS_BOOK (book));
-
- if (e_destination_is_evolution_list (dest))
- return;
-
- if (e_destination_contains_card (dest))
- return;
-
- if (!dest->priv->allow_cardify)
- return;
-
- if (dest->priv->cannot_cardify)
- return;
-
- e_destination_cancel_cardify (dest);
-
- /* In some cases, we can revert to the previous card. */
- if (!e_destination_is_valid (dest)
- && e_destination_reverting_is_a_good_idea (dest)
- && e_destination_revert (dest)) {
- return;
- }
-
- set_cardify_book (dest, book);
-
- /* Handle the case of an EDestination containing a card URL */
- if (e_destination_contains_card (dest)) {
- e_destination_use_card (dest, NULL, NULL);
- return;
- }
-
- /* If we have a book ready, proceed. We hold a reference to ourselves
- until our query is complete. */
- gtk_object_ref (GTK_OBJECT (dest));
- if (dest->priv->cardify_book != NULL) {
- launch_cardify_query (dest);
- } else {
- e_book_use_local_address_book (use_local_book_cb, dest);
- }
-}
-
-static int
-do_cardify_delayed (gpointer ptr)
-{
- EDestination *dest = E_DESTINATION (ptr);
-
- e_destination_cardify (dest, dest->priv->cardify_book);
- return FALSE;
-}
-
-void
-e_destination_cardify_delayed (EDestination *dest, EBook *book, gint delay)
-{
- g_return_if_fail (E_IS_DESTINATION (dest));
- g_return_if_fail (book == NULL || E_IS_BOOK (book));
-
- if (delay < 0)
- delay = 500;
-
- e_destination_cancel_cardify (dest);
-
- set_cardify_book (dest, book);
-
- dest->priv->pending_cardification = gtk_timeout_add (delay, do_cardify_delayed, dest);
-}
-
-void
-e_destination_cancel_cardify (EDestination *dest)
-{
- g_return_if_fail (E_IS_DESTINATION (dest));
-
- if (dest->priv->pending_cardification) {
- gtk_timeout_remove (dest->priv->pending_cardification);
- dest->priv->pending_cardification = 0;
- }
-}
-
-gboolean
-e_destination_uncardify (EDestination *dest)
-{
- char *email;
-
- g_return_val_if_fail (E_IS_DESTINATION (dest), FALSE);
-
- if (!e_destination_contains_card (dest))
- return FALSE;
-
- email = g_strdup (e_destination_get_email (dest));
-
- if (email == NULL)
- return FALSE;
-
- e_destination_freeze (dest);
- e_destination_clear (dest);
- e_destination_set_raw (dest, email);
- g_free (email);
- e_destination_thaw (dest);
-
- return TRUE;
-}
-
-gboolean
-e_destination_revert (EDestination *dest)
-{
- g_return_val_if_fail (E_IS_DESTINATION (dest), FALSE);
-
- if (dest->priv->old_card) {
- ECard *card;
- int card_email_num;
-
- card = dest->priv->old_card;
- card_email_num = dest->priv->old_card_email_num;
-
- dest->priv->old_card = NULL;
- g_free (dest->priv->old_textrep);
- dest->priv->old_textrep = NULL;
-
- e_destination_freeze (dest);
- e_destination_clear (dest);
- e_destination_set_card (dest, card, card_email_num);
- e_destination_thaw (dest);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-/*
- * Destination import/export
- */
-
-gchar *
-e_destination_get_address_textv (EDestination **destv)
-{
- int i, j, len = 0;
- char **strv;
- char *str;
-
- g_return_val_if_fail (destv, NULL);
-
- /* Q: Please tell me this is only for assertion
- reasons. If this is considered to be ok behavior then you
- shouldn't use g_return's. Just a reminder ;-)
-
- A: Yes, this is just an assertion. (Though it does find the
- length of the vector in the process...)
- */
- while (destv[len]) {
- g_return_val_if_fail (E_IS_DESTINATION (destv[len]), NULL);
- len++;
- }
-
- strv = g_new0 (char *, len + 1);
- for (i = 0, j = 0; destv[i]; i++) {
- if (!e_destination_is_empty (destv[i])) {
- const char *addr = e_destination_get_address (destv[i]);
- strv[j++] = addr ? (char *) addr : "";
- }
- }
-
- str = g_strjoinv (", ", strv);
-
- g_free (strv);
-
- return str;
-}
-
-xmlNodePtr
-e_destination_xml_encode (const EDestination *dest)
-{
- xmlNodePtr dest_node;
- const char *str;
-
- g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL);
-
- dest_node = xmlNewNode (NULL, "destination");
-
- str = e_destination_get_name (dest);
- if (str)
- xmlNewTextChild (dest_node, NULL, "name", str);
-
- if (!e_destination_is_evolution_list (dest)) {
- str = e_destination_get_email (dest);
- if (str)
- xmlNewTextChild (dest_node, NULL, "email", str);
- } else {
- GList *iter = dest->priv->list_dests;
-
- while (iter) {
- EDestination *list_dest = E_DESTINATION (iter->data);
- xmlNodePtr list_node = xmlNewNode (NULL, "list_entry");
-
- str = e_destination_get_name (list_dest);
- if (str)
- xmlNewTextChild (list_node, NULL, "name", str);
-
- str = e_destination_get_email (list_dest);
- if (str)
- xmlNewTextChild (list_node, NULL, "email", str);
-
- xmlAddChild (dest_node, list_node);
-
- iter = g_list_next (iter);
- }
-
- xmlNewProp (dest_node, "is_list", "yes");
- xmlNewProp (dest_node, "show_addresses",
- e_destination_list_show_addresses (dest) ? "yes" : "no");
- }
-
- str = e_destination_get_book_uri (dest);
- if (str) {
- xmlNewTextChild (dest_node, NULL, "book_uri", str);
- }
-
- str = e_destination_get_card_uid (dest);
- if (str) {
- char buf[16];
-
- xmlNodePtr uri_node = xmlNewTextChild (dest_node, NULL, "card_uid", str);
- g_snprintf (buf, 16, "%d", e_destination_get_email_num (dest));
- xmlNewProp (uri_node, "email_num", buf);
- }
-
- xmlNewProp (dest_node, "html_mail", e_destination_get_html_mail_pref (dest) ? "yes" : "no");
-
- xmlNewProp (dest_node, "auto_recipient",
- e_destination_is_auto_recipient (dest) ? "yes" : "no");
-
- return dest_node;
-}
-
-gboolean
-e_destination_xml_decode (EDestination *dest, xmlNodePtr node)
-{
- char *name = NULL, *email = NULL, *book_uri = NULL, *card_uid = NULL;
- gboolean is_list = FALSE, show_addr = FALSE, auto_recip = FALSE;
- gboolean html_mail = FALSE;
- GList *list_dests = NULL;
- int email_num = -1;
- char *tmp;
-
- g_return_val_if_fail (dest && E_IS_DESTINATION (dest), FALSE);
- g_return_val_if_fail (node != NULL, FALSE);
-
- if (strcmp (node->name, "destination"))
- return FALSE;
-
- tmp = xmlGetProp (node, "html_mail");
- if (tmp) {
- html_mail = !strcmp (tmp, "yes");
- xmlFree (tmp);
- }
-
- tmp = xmlGetProp (node, "is_list");
- if (tmp) {
- is_list = !strcmp (tmp, "yes");
- xmlFree (tmp);
- }
-
- tmp = xmlGetProp (node, "show_addresses");
- if (tmp) {
- show_addr = !strcmp (tmp, "yes");
- xmlFree (tmp);
- }
-
- tmp = xmlGetProp (node, "auto_recipient");
- if (tmp) {
- auto_recip = !strcmp (tmp, "yes");
- xmlFree (tmp);
- }
-
- node = node->xmlChildrenNode;
- while (node) {
- if (!strcmp (node->name, "name")) {
- tmp = xmlNodeGetContent (node);
- g_free (name);
- name = g_strdup (tmp);
- xmlFree (tmp);
- } else if (!is_list && !strcmp (node->name, "email")) {
- tmp = xmlNodeGetContent (node);
- g_free (email);
- email = g_strdup (tmp);
- xmlFree (tmp);
- } else if (is_list && !strcmp (node->name, "list_entry")) {
- xmlNodePtr subnode = node->xmlChildrenNode;
- char *list_name = NULL, *list_email = NULL;
-
- while (subnode) {
- if (!strcmp (subnode->name, "name")) {
- tmp = xmlNodeGetContent (subnode);
- g_free (list_name);
- list_name = g_strdup (tmp);
- xmlFree (tmp);
- } else if (!strcmp (subnode->name, "email")) {
- tmp = xmlNodeGetContent (subnode);
- g_free (list_email);
- list_email = g_strdup (tmp);
- xmlFree (tmp);
- }
-
- subnode = subnode->next;
- }
-
- if (list_name || list_email) {
- EDestination *list_dest = e_destination_new ();
-
- if (list_name)
- e_destination_set_name (list_dest, list_name);
- if (list_email)
- e_destination_set_email (list_dest, list_email);
-
- g_free (list_name);
- g_free (list_email);
-
- list_dests = g_list_append (list_dests, list_dest);
- }
- } else if (!strcmp (node->name, "book_uri")) {
- tmp = xmlNodeGetContent (node);
- g_free (book_uri);
- book_uri = g_strdup (tmp);
- xmlFree (tmp);
- } else if (!strcmp (node->name, "card_uid")) {
- tmp = xmlNodeGetContent (node);
- g_free (card_uid);
- card_uid = g_strdup (tmp);
- xmlFree (tmp);
-
- tmp = xmlGetProp (node, "email_num");
- email_num = atoi (tmp);
- xmlFree (tmp);
- }
-
- node = node->next;
- }
-
- e_destination_freeze (dest);
-
- e_destination_clear (dest);
-
- if (name) {
- e_destination_set_name (dest, name);
- g_free (name);
- }
- if (email) {
- e_destination_set_email (dest, email);
- g_free (email);
- }
- if (book_uri) {
- e_destination_set_book_uri (dest, book_uri);
- g_free (book_uri);
- }
- if (card_uid) {
- e_destination_set_card_uid (dest, card_uid, email_num);
- g_free (card_uid);
- }
- if (list_dests)
- dest->priv->list_dests = list_dests;
-
- dest->priv->html_mail_override = TRUE;
- dest->priv->wants_html_mail = html_mail;
-
- dest->priv->show_addresses = show_addr;
-
- dest->priv->auto_recipient = auto_recip;
-
- e_destination_thaw (dest);
-
- return TRUE;
-}
-
-/* FIXME: Make utf-8 safe */
-static gchar *
-null_terminate_and_remove_extra_whitespace (xmlChar *xml_in, gint size)
-{
- gboolean skip_white = FALSE;
- char *xml, *r, *w;
-
- if (xml_in == NULL || size <= 0)
- return NULL;
-
- xml = g_strndup (xml_in, size);
- r = w = xml;
-
- while (*r) {
- if (*r == '\n' || *r == '\r') {
- skip_white = TRUE;
- } else {
- gboolean is_space = isspace (*r);
-
- *w = *r;
-
- if (!(skip_white && is_space))
- w++;
- if (!is_space)
- skip_white = FALSE;
- }
- r++;
- }
-
- *w = '\0';
-
- return xml;
-}
-
-gchar *
-e_destination_export (const EDestination *dest)
-{
- xmlNodePtr dest_node;
- xmlDocPtr dest_doc;
- xmlChar *buffer = NULL;
- int size = -1;
- char *str;
-
- g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL);
-
- dest_node = e_destination_xml_encode (dest);
- if (dest_node == NULL)
- return NULL;
-
- dest_doc = xmlNewDoc (XML_DEFAULT_VERSION);
- xmlDocSetRootElement (dest_doc, dest_node);
-
- xmlDocDumpMemory (dest_doc, &buffer, &size);
- xmlFreeDoc (dest_doc);
-
- str = null_terminate_and_remove_extra_whitespace (buffer, size);
- xmlFree (buffer);
-
- return str;
-}
-
-EDestination *
-e_destination_import (const gchar *str)
-{
- EDestination *dest = NULL;
- xmlDocPtr dest_doc;
-
- if (!(str && *str))
- return NULL;
-
- dest_doc = xmlParseMemory ((char *) str, strlen (str));
- if (dest_doc && dest_doc->xmlRootNode) {
- dest = e_destination_new ();
- if (! e_destination_xml_decode (dest, dest_doc->xmlRootNode)) {
- gtk_object_unref (GTK_OBJECT (dest));
- dest = NULL;
- }
- }
- xmlFreeDoc (dest_doc);
-
- return dest;
-}
-
-gchar *
-e_destination_exportv (EDestination **destv)
-{
- xmlDocPtr destv_doc;
- xmlNodePtr destv_node;
- xmlChar *buffer = NULL;
- int i, size = -1;
- char *str;
-
- if (destv == NULL || *destv == NULL)
- return NULL;
-
- destv_doc = xmlNewDoc (XML_DEFAULT_VERSION);
- destv_node = xmlNewNode (NULL, "destinations");
- xmlDocSetRootElement (destv_doc, destv_node);
-
- for (i = 0; destv[i]; i++) {
- if (! e_destination_is_empty (destv[i])) {
- xmlNodePtr dest_node = e_destination_xml_encode (destv[i]);
- if (dest_node)
- xmlAddChild (destv_node, dest_node);
- }
- }
-
- xmlDocDumpMemory (destv_doc, &buffer, &size);
- xmlFreeDoc (destv_doc);
-
- str = null_terminate_and_remove_extra_whitespace (buffer, size);
- xmlFree (buffer);
-
- return str;
-}
-
-EDestination **
-e_destination_importv (const gchar *str)
-{
- GPtrArray *dest_array = NULL;
- xmlDocPtr destv_doc;
- xmlNodePtr node;
- EDestination **destv = NULL;
-
- if (!(str && *str))
- return NULL;
-
- destv_doc = xmlParseMemory ((char *)str, strlen (str));
- if (destv_doc == NULL)
- return NULL;
-
- node = destv_doc->xmlRootNode;
-
- if (strcmp (node->name, "destinations"))
- goto finished;
-
- node = node->xmlChildrenNode;
-
- dest_array = g_ptr_array_new ();
-
- while (node) {
- EDestination *dest;
-
- dest = e_destination_new ();
- if (e_destination_xml_decode (dest, node) && !e_destination_is_empty (dest)) {
- g_ptr_array_add (dest_array, dest);
- } else {
- gtk_object_unref (GTK_OBJECT (dest));
- }
-
- node = node->next;
- }
-
- /* we need destv to be NULL terminated */
- g_ptr_array_add (dest_array, NULL);
-
- destv = (EDestination **) dest_array->pdata;
- g_ptr_array_free (dest_array, FALSE);
-
- finished:
- xmlFreeDoc (destv_doc);
-
- return destv;
-}
-
-EDestination **
-e_destination_list_to_vector_sized (GList *list, int n)
-{
- EDestination **destv;
- int i = 0;
-
- if (n == -1)
- n = g_list_length (list);
-
- if (n == 0)
- return NULL;
-
- destv = g_new (EDestination *, n + 1);
- while (list != NULL && i < n) {
- destv[i] = E_DESTINATION (list->data);
- list->data = NULL;
- i++;
- list = g_list_next (list);
- }
- destv[i] = NULL;
-
- return destv;
-}
-
-EDestination **
-e_destination_list_to_vector (GList *list)
-{
- return e_destination_list_to_vector_sized (list, -1);
-}
-
-void
-e_destination_freev (EDestination **destv)
-{
- int i;
-
- if (destv) {
- for (i = 0; destv[i] != NULL; ++i) {
- gtk_object_unref (GTK_OBJECT (destv[i]));
- }
- g_free (destv);
- }
-
-}
-
-static void
-touch_cb (EBook *book, const gchar *addr, ECard *card, gpointer closure)
-{
- if (book != NULL && card != NULL) {
- e_card_touch (card);
- d(g_message ("Use score for \"%s\" is now %f", addr, e_card_get_use_score (card)));
- e_book_commit_card (book, card, NULL, NULL);
- }
-}
-
-void
-e_destination_touch (EDestination *dest)
-{
- const char *email;
-
- g_return_if_fail (dest && E_IS_DESTINATION (dest));
-
- if (!e_destination_is_auto_recipient (dest)) {
- email = e_destination_get_email (dest);
-
- if (email)
- e_book_query_address_locally (email, touch_cb, NULL);
- }
-}
-
-void
-e_destination_touchv (EDestination **destv)
-{
- int i;
-
- g_return_if_fail (destv != NULL);
-
- for (i = 0; destv[i] != NULL; ++i) {
- e_destination_touch (destv[i]);
- }
-}
diff --git a/addressbook/backend/ebook/e-destination.h b/addressbook/backend/ebook/e-destination.h
deleted file mode 100644
index f545794ab0..0000000000
--- a/addressbook/backend/ebook/e-destination.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * e-destination.h
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Developed by Jon Trowbridge <trow@ximian.com>
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA.
- */
-
-#ifndef __E_DESTINATION_H__
-#define __E_DESTINATION_H__
-
-#include <gtk/gtkobject.h>
-#include <addressbook/backend/ebook/e-card.h>
-#include <addressbook/backend/ebook/e-book.h>
-#include <gnome-xml/tree.h>
-
-#define E_TYPE_DESTINATION (e_destination_get_type ())
-#define E_DESTINATION(o) (GTK_CHECK_CAST ((o), E_TYPE_DESTINATION, EDestination))
-#define E_DESTINATION_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), E_TYPE_DESTINATION, EDestinationClass))
-#define E_IS_DESTINATION(o) (GTK_CHECK_TYPE ((o), E_TYPE_DESTINATION))
-#define E_IS_DESTINATION_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TYPE_DESTINATION))
-
-typedef struct _EDestination EDestination;
-typedef struct _EDestinationClass EDestinationClass;
-
-typedef void (*EDestinationCardCallback) (EDestination *dest, ECard *card, gpointer closure);
-
-struct _EDestinationPrivate;
-
-struct _EDestination {
- GtkObject object;
-
- struct _EDestinationPrivate *priv;
-};
-
-struct _EDestinationClass {
- GtkObjectClass parent_class;
-
- void (*changed) (EDestination *dest);
- void (*cardified) (EDestination *dest);
-};
-
-GtkType e_destination_get_type (void);
-
-
-EDestination *e_destination_new (void);
-void e_destination_changed (EDestination *);
-EDestination *e_destination_copy (const EDestination *);
-void e_destination_clear (EDestination *);
-
-gboolean e_destination_is_empty (const EDestination *);
-gboolean e_destination_is_valid (const EDestination *);
-gboolean e_destination_equal (const EDestination *a, const EDestination *b);
-
-void e_destination_set_card (EDestination *, ECard *card, gint email_num);
-void e_destination_set_book_uri (EDestination *, const gchar *uri);
-void e_destination_set_card_uid (EDestination *, const gchar *uid, gint email_num);
-
-void e_destination_set_name (EDestination *, const gchar *name);
-void e_destination_set_email (EDestination *, const gchar *email);
-
-void e_destination_set_html_mail_pref (EDestination *, gboolean);
-
-gboolean e_destination_contains_card (const EDestination *);
-gboolean e_destination_from_card (const EDestination *);
-
-gboolean e_destination_is_auto_recipient (const EDestination *);
-void e_destination_set_auto_recipient (EDestination *, gboolean value);
-
-void e_destination_use_card (EDestination *, EDestinationCardCallback cb, gpointer closure);
-
-ECard *e_destination_get_card (const EDestination *);
-const gchar *e_destination_get_book_uri (const EDestination *);
-const gchar *e_destination_get_card_uid (const EDestination *);
-gint e_destination_get_email_num (const EDestination *);
-
-const gchar *e_destination_get_name (const EDestination *); /* "Jane Smith" */
-const gchar *e_destination_get_email (const EDestination *); /* "jane@assbarn.com" */
-const gchar *e_destination_get_address (const EDestination *); /* "Jane Smith <jane@assbarn.com>" (or a comma-sep set of such for a list) */
-
-void e_destination_set_raw (EDestination *, const gchar *free_form_string);
-const gchar *e_destination_get_textrep (const EDestination *); /* "Jane Smith" or "jane@assbarn.com" */
-
-gboolean e_destination_is_evolution_list (const EDestination *);
-gboolean e_destination_list_show_addresses (const EDestination *);
-
-/* If true, they want HTML mail. */
-gboolean e_destination_get_html_mail_pref (const EDestination *);
-
-gboolean e_destination_allow_cardification (const EDestination *);
-void e_destination_set_allow_cardification (EDestination *, gboolean);
-void e_destination_cardify (EDestination *, EBook *);
-void e_destination_cardify_delayed (EDestination *, EBook *, gint delay); /* delay < 0: "default" */
-void e_destination_cancel_cardify (EDestination *);
-gboolean e_destination_uncardify (EDestination *);
-
-gboolean e_destination_revert (EDestination *);
-
-gchar *e_destination_get_address_textv (EDestination **);
-
-xmlNodePtr e_destination_xml_encode (const EDestination *dest);
-gboolean e_destination_xml_decode (EDestination *dest, xmlNodePtr node);
-
-gchar *e_destination_export (const EDestination *);
-EDestination *e_destination_import (const gchar *str);
-
-gchar *e_destination_exportv (EDestination **);
-EDestination **e_destination_importv (const gchar *str);
-
-EDestination **e_destination_list_to_vector_sized (GList *, int n);
-EDestination **e_destination_list_to_vector (GList *);
-
-void e_destination_freev (EDestination **);
-
-void e_destination_touch (EDestination *);
-void e_destination_touchv (EDestination **);
-
-
-#endif /* __E_DESTINATION_H__ */
-
diff --git a/addressbook/backend/ebook/evolution-ldif-importer.c b/addressbook/backend/ebook/evolution-ldif-importer.c
deleted file mode 100644
index 60ac899e81..0000000000
--- a/addressbook/backend/ebook/evolution-ldif-importer.c
+++ /dev/null
@@ -1,624 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * LDIF importer. LDIF is the file format of an exported Netscape
- * addressbook.
- *
- * Framework copied from evolution-gnomecard-importer.c
- *
- * Michael M. Morrison (mmorrison@kqcorp.com)
- *
- * Multi-line value support, mailing list support, base64 support, and
- * various fixups: Chris Toshok (toshok@ximian.com)
- */
-
-#include <config.h>
-#include <bonobo.h>
-#include <gnome.h>
-#include <liboaf/liboaf.h>
-#include <stdio.h>
-#include <ctype.h>
-
-#include <e-book.h>
-#include <e-card-simple.h>
-#include <e-destination.h>
-
-#include <importer/evolution-importer.h>
-#include <importer/GNOME_Evolution_Importer.h>
-
-#define COMPONENT_FACTORY_IID "OAFIID:GNOME_Evolution_Addressbook_LDIF_ImporterFactory"
-
-static BonoboGenericFactory *factory = NULL;
-
-static GHashTable *dn_card_hash;
-
-typedef struct {
- char *filename;
- GList *cardlist;
- GList *iterator;
- EBook *book;
- gboolean ready;
-} LDIFImporter;
-
-static struct {
- char *ldif_attribute;
- ECardSimpleField simple_field;
-#define FLAG_ADDRESS 0x01
- int flags;
-}
-ldif_fields[] = {
- { "cn", E_CARD_SIMPLE_FIELD_FULL_NAME },
- { "mail", E_CARD_SIMPLE_FIELD_EMAIL },
-#if 0
- { "givenname", E_CARD_SIMPLE_FIELD_GIVEN_NAME },
-#endif
- { "sn", E_CARD_SIMPLE_FIELD_FAMILY_NAME },
- { "xmozillanickname", E_CARD_SIMPLE_FIELD_NICKNAME },
- { "o", E_CARD_SIMPLE_FIELD_ORG },
- { "locality", 0, FLAG_ADDRESS},
- { "st", 0, FLAG_ADDRESS },
- { "streetaddress", 0, FLAG_ADDRESS },
- { "title", E_CARD_SIMPLE_FIELD_TITLE },
- { "postalcode", 0, FLAG_ADDRESS },
- { "countryname", 0, FLAG_ADDRESS },
- { "telephonenumber", E_CARD_SIMPLE_FIELD_PHONE_BUSINESS},
- { "homephone", E_CARD_SIMPLE_FIELD_PHONE_HOME },
- { "facsimiletelephonenumber", E_CARD_SIMPLE_FIELD_PHONE_BUSINESS_FAX },
- { "ou", E_CARD_SIMPLE_FIELD_ORG_UNIT },
- { "pagerphone", E_CARD_SIMPLE_FIELD_PHONE_PAGER },
- { "cellphone", E_CARD_SIMPLE_FIELD_PHONE_MOBILE },
- { "homeurl", E_CARD_SIMPLE_FIELD_URL },
- { "description", E_CARD_SIMPLE_FIELD_NOTE },
- { "xmozillausehtmlmail", E_CARD_SIMPLE_FIELD_WANTS_HTML }
-};
-static int num_ldif_fields = sizeof(ldif_fields) / sizeof (ldif_fields[0]);
-
-static unsigned char base64_rank[256] = {
- 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255, 62,255,255,255, 63,
- 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,255,255,255, 0,255,255,
- 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,255,255,255,255,255,
- 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-};
-
-/**
- * base64_decode_step: decode a chunk of base64 encoded data
- * @in: input stream
- * @len: max length of data to decode
- * @out: output stream
- * @state: holds the number of bits that are stored in @save
- * @save: leftover bits that have not yet been decoded
- *
- * Decodes a chunk of base64 encoded data
- **/
-static int
-base64_decode_step(unsigned char *in, int len, unsigned char *out, int *state, unsigned int *save)
-{
- register unsigned char *inptr, *outptr;
- unsigned char *inend, c;
- register unsigned int v;
- int i;
-
- inend = in+len;
- outptr = out;
-
- /* convert 4 base64 bytes to 3 normal bytes */
- v=*save;
- i=*state;
- inptr = in;
- while (inptr<inend) {
- c = base64_rank[*inptr++];
- if (c != 0xff) {
- v = (v<<6) | c;
- i++;
- if (i==4) {
- *outptr++ = v>>16;
- *outptr++ = v>>8;
- *outptr++ = v;
- i=0;
- }
- }
- }
-
- *save = v;
- *state = i;
-
- /* quick scan back for '=' on the end somewhere */
- /* fortunately we can drop 1 output char for each trailing = (upto 2) */
- i=2;
- while (inptr>in && i) {
- inptr--;
- if (base64_rank[*inptr] != 0xff) {
- if (*inptr == '=')
- outptr--;
- i--;
- }
- }
-
- /* if i!= 0 then there is a truncation error! */
- return outptr-out;
-}
-
-static int
-base64_decode_simple (char *data, int len)
-{
- int state = 0;
- unsigned int save = 0;
-
- return base64_decode_step ((unsigned char *)data, len,
- (unsigned char *)data, &state, &save);
-}
-
-static GString *
-getValue( char **src )
-{
- GString *dest = g_string_new("");
- char *s = *src;
- gboolean need_base64 = (*s == ':');
-
- copy_line:
- while( *s != 0 && *s != '\n' && *s != '\r' )
- dest = g_string_append_c (dest, *s++);
-
- if (*s == '\r') s++;
- if (*s == '\n') s++;
-
- /* check for continuation here */
- if (*s == ' ') {
- s++;
- goto copy_line;
- }
-
- if (need_base64) {
- int new_len;
- /* it's base64 encoded */
- dest = g_string_erase (dest, 0, 2);
- new_len = base64_decode_simple (dest->str, strlen (dest->str));
- dest = g_string_truncate (dest, new_len);
- }
-
- *src = s;
-
- return dest;
-}
-
-static gboolean
-parseLine( ECardSimple *simple, ECardDeliveryAddress *address, char **buf )
-{
- char *ptr;
- char *colon, *value;
- gboolean field_handled;
- GString *ldif_value;
-
- ptr = *buf;
-
- /* if the string is empty, return */
- if (*ptr == '\0') {
- *buf = NULL;
- return TRUE;
- }
-
- /* skip comment lines */
- if (*ptr == '#') {
- ptr = strchr (ptr, '\n');
- if (!ptr)
- *buf = NULL;
- else
- *buf = ptr + 1;
- return TRUE;
- }
-
- /* first, check for a 'continuation' line */
- if( ptr[0] == ' ' && ptr[1] != '\n' ) {
- g_warning ("unexpected continuation line");
- return FALSE;
- }
-
- colon = (char *)strchr( ptr, ':' );
- if (colon) {
- int i;
-
- *colon = 0;
- value = colon + 1;
- while ( isspace(*value) )
- value++;
-
- ldif_value = getValue(&value );
-
- field_handled = FALSE;
- for (i = 0; i < num_ldif_fields; i ++) {
- if (!g_strcasecmp (ptr, ldif_fields[i].ldif_attribute)) {
- if (ldif_fields[i].flags & FLAG_ADDRESS) {
- if (!g_strcasecmp (ptr, "locality"))
- address->city = g_strdup (ldif_value->str);
- else if (!g_strcasecmp (ptr, "countryname"))
- address->country = g_strdup (ldif_value->str);
- else if (!g_strcasecmp (ptr, "postalcode"))
- address->code = g_strdup (ldif_value->str);
- else if (!g_strcasecmp (ptr, "st"))
- address->region = g_strdup (ldif_value->str);
- else if (!g_strcasecmp (ptr, "streetaddress"))
- address->street = g_strdup (ldif_value->str);
- }
- else {
- e_card_simple_set (simple, ldif_fields[i].simple_field, ldif_value->str);
- printf ("set %s to %s\n", ptr, ldif_value->str);
- }
- field_handled = TRUE;
- break;
- }
- }
-
- /* handle objectclass/dn/member out here */
- if (!field_handled) {
- if (!g_strcasecmp (ptr, "dn"))
- g_hash_table_insert (dn_card_hash, g_strdup(ldif_value->str), simple->card);
- else if (!g_strcasecmp (ptr, "objectclass") && !g_strcasecmp (ldif_value->str, "groupofnames")) {
- e_card_simple_set (simple, E_CARD_SIMPLE_FIELD_IS_LIST, "true");
- }
- else if (!g_strcasecmp (ptr, "member")) {
- EList *email;
- gtk_object_get (GTK_OBJECT (simple->card),
- "email", &email,
- NULL);
- e_list_append (email, ldif_value->str);
- }
- }
-
- /* put the colon back the way it was, just for kicks */
- *colon = ':';
-
- g_string_free (ldif_value, TRUE);
- }
- else {
- g_warning ("unrecognized entry %s", ptr);
- return FALSE;
- }
-
- *buf = value;
-
- return TRUE;
-}
-
-static ECard *
-getNextLDIFEntry( FILE *f )
-{
- ECard *card;
- ECardAddrLabel *label;
- ECardSimple *simple;
- ECardDeliveryAddress *address;
- GString *str;
- char line[1024];
- char *buf;
-
- str = g_string_new ("");
- /* read from the file until we get to a blank line (or eof) */
- while (!feof (f)) {
- if (!fgets (line, sizeof(line), f))
- break;
- if (line[0] == '\n')
- break;
- str = g_string_append (str, line);
- }
-
- if (strlen (str->str) == 0) {
- g_string_free (str, TRUE);
- return NULL;
- }
-
- /* now parse that entry */
- card = e_card_new ("");
- simple = e_card_simple_new (card);
- address = e_card_delivery_address_new ();
-
- buf = str->str;
- while (buf) {
- if (!parseLine (simple, address, &buf)) {
- /* parsing error */
- gtk_object_unref (GTK_OBJECT (simple));
- e_card_delivery_address_unref (address);
- return NULL;
- }
- }
-
-
- /* fill in the address */
- address->flags = E_CARD_ADDR_HOME;
-
- label = e_card_delivery_address_to_label (address);
- e_card_delivery_address_unref (address);
-
- e_card_simple_set_address (simple, E_CARD_SIMPLE_ADDRESS_ID_HOME, label);
-
- e_card_address_label_unref (label);
-
- e_card_simple_sync_card (simple);
-
- g_string_free (str, TRUE);
-
- return card;
-}
-
-static void
-add_card_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure)
-{
- ECard *card = E_CARD(closure);
- char *vcard;
-
- e_card_set_id (card, id);
-
- vcard = e_card_get_vcard(card);
-
- g_print ("Saved card: %s\n", vcard);
- g_free(vcard);
-}
-
-static void
-resolve_list_card (LDIFImporter *gci, ECard *card)
-{
- EList *email;
- EIterator *email_iter;
- char *full_name;
-
- if (!e_card_evolution_list (card))
- return;
-
- gtk_object_get (GTK_OBJECT (card),
- "email", &email,
- "full_name", &full_name,
- NULL);
-
- /* set file_as to full_name so we don't later try and figure
- out a first/last name for the list. */
- if (full_name)
- gtk_object_set (GTK_OBJECT (card),
- "file_as", full_name,
- NULL);
-
- email_iter = e_list_get_iterator (email);
- while (e_iterator_is_valid (email_iter)) {
- const char *dn = e_iterator_get (email_iter);
- ECard *dn_card = g_hash_table_lookup (dn_card_hash, dn);
-
- /* break list chains here, since we don't support them just yet */
- if (dn_card && !e_card_evolution_list (dn_card)) {
- EDestination *dest = e_destination_new ();
- gchar *dest_xml;
- e_destination_set_card (dest, dn_card, 0); /* Hard-wired for default e-mail, since netscape only exports 1 email address */
- dest_xml = e_destination_export (dest);
- gtk_object_unref (GTK_OBJECT (dest));
- if (dest_xml) {
- e_iterator_set (email_iter, dest_xml);
- g_free (dest_xml);
- e_iterator_next (email_iter);
- }
- else {
- e_iterator_delete (email_iter);
- }
- }
- else {
- e_iterator_delete (email_iter);
- }
- }
-}
-
-static void
-book_open_cb (EBook *book, EBookStatus status, gpointer closure)
-{
- LDIFImporter *gci = (LDIFImporter *) closure;
- GList * list = NULL;
- GList * list_list = NULL;
- FILE * file;
- ECard *card;
-
- if(!( file = fopen( gci->filename, "r" ) )) {
- g_warning("!!!Can't open .ldif file");
- return;
- }
-
- dn_card_hash = g_hash_table_new (g_str_hash, g_str_equal);
-
- while ((card = getNextLDIFEntry (file))) {
-
- if (e_card_evolution_list (card))
- list_list = g_list_append (list_list, card);
- else
- list = g_list_append (list, card);
- }
-
- fclose( file );
-
- list = g_list_reverse( list );
- list_list = g_list_reverse (list_list);
- list = g_list_concat (list, list_list);
-
- gci->cardlist = list;
- gci->ready = TRUE;
-}
-
-static void
-ebook_create (LDIFImporter *gci)
-{
- gchar *path, *uri;
-
- gci->book = e_book_new ();
-
- if (!gci->book) {
- printf ("%s: %s(): Couldn't create EBook, bailing.\n",
- __FILE__,
- __FUNCTION__);
- return;
- }
-
- path = g_concat_dir_and_file (g_get_home_dir (),
- "evolution/local/Contacts/addressbook.db");
- uri = g_strdup_printf ("file://%s", path);
- g_free (path);
-
- if (! e_book_load_uri (gci->book, uri, book_open_cb, gci)) {
- printf ("error calling load_uri!\n");
- }
- g_free(uri);
-}
-
-/* EvolutionImporter methods */
-static void
-process_item_fn (EvolutionImporter *importer,
- CORBA_Object listener,
- void *closure,
- CORBA_Environment *ev)
-{
- LDIFImporter *gci = (LDIFImporter *) closure;
- ECard *card;
-
- if (gci->iterator == NULL)
- gci->iterator = gci->cardlist;
-
- if (gci->ready == FALSE) {
- GNOME_Evolution_ImporterListener_notifyResult (listener,
- GNOME_Evolution_ImporterListener_NOT_READY,
- gci->iterator ? TRUE : FALSE,
- ev);
- return;
- }
-
- if (gci->iterator == NULL) {
- GNOME_Evolution_ImporterListener_notifyResult (listener,
- GNOME_Evolution_ImporterListener_UNSUPPORTED_OPERATION,
- FALSE, ev);
- return;
- }
-
- card = gci->iterator->data;
- if (e_card_evolution_list (card))
- resolve_list_card (gci, card);
- e_book_add_card (gci->book, card, add_card_cb, card);
-
- gci->iterator = gci->iterator->next;
-
- GNOME_Evolution_ImporterListener_notifyResult (listener,
- GNOME_Evolution_ImporterListener_OK,
- gci->iterator ? TRUE : FALSE,
- ev);
- if (ev->_major != CORBA_NO_EXCEPTION) {
- g_warning ("Error notifying listeners.");
- }
-
- return;
-}
-
-static char *supported_extensions[2] = {
- ".ldif", NULL
-};
-
-static gboolean
-support_format_fn (EvolutionImporter *importer,
- const char *filename,
- void *closure)
-{
- char *ext;
- int i;
-
- ext = strrchr (filename, '.');
- if (ext == NULL) {
- return FALSE;
- }
-
- for (i = 0; supported_extensions[i] != NULL; i++) {
- if (strcmp (supported_extensions[i], ext) == 0)
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-importer_destroy_cb (GtkObject *object,
- LDIFImporter *gci)
-{
- gtk_main_quit ();
-}
-
-static gboolean
-load_file_fn (EvolutionImporter *importer,
- const char *filename,
- const char *folderpath,
- void *closure)
-{
- LDIFImporter *gci;
-
- gci = (LDIFImporter *) closure;
- gci->filename = g_strdup (filename);
- gci->cardlist = NULL;
- gci->iterator = NULL;
- gci->ready = FALSE;
- ebook_create (gci);
-
- return TRUE;
-}
-
-static BonoboObject *
-factory_fn (BonoboGenericFactory *_factory,
- void *closure)
-{
- EvolutionImporter *importer;
- LDIFImporter *gci;
-
- gci = g_new (LDIFImporter, 1);
- importer = evolution_importer_new (support_format_fn, load_file_fn,
- process_item_fn, NULL, gci);
-
- gtk_signal_connect (GTK_OBJECT (importer), "destroy",
- GTK_SIGNAL_FUNC (importer_destroy_cb), gci);
-
- return BONOBO_OBJECT (importer);
-}
-
-static void
-importer_init (void)
-{
- if (factory != NULL)
- return;
-
- factory = bonobo_generic_factory_new (COMPONENT_FACTORY_IID,
- factory_fn, NULL);
-
- if (factory == NULL) {
- g_error ("Unable to create factory");
- }
-
- bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory));
-}
-
-int
-main (int argc,
- char **argv)
-{
- CORBA_ORB orb;
-
- gnome_init_with_popt_table ("Evolution-LDIF-Importer",
- "0.0", argc, argv, oaf_popt_options, 0,
- NULL);
- orb = oaf_init (argc, argv);
- if (bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE) {
- g_error ("Could not initialize Bonobo.");
- }
-
- importer_init ();
- bonobo_main ();
-
- return 0;
-}
-
-
diff --git a/addressbook/backend/ebook/evolution-vcard-importer.c b/addressbook/backend/ebook/evolution-vcard-importer.c
deleted file mode 100644
index e32593b4fb..0000000000
--- a/addressbook/backend/ebook/evolution-vcard-importer.c
+++ /dev/null
@@ -1,260 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-#include <config.h>
-#include <stdio.h>
-
-#include <liboaf/liboaf.h>
-#include <bonobo/bonobo-context.h>
-#include <bonobo/bonobo-generic-factory.h>
-#include <bonobo/bonobo-main.h>
-
-#include <e-book.h>
-
-#include <importer/evolution-importer.h>
-#include <importer/GNOME_Evolution_Importer.h>
-
-#include <e-util/e-path.h>
-
-#define COMPONENT_FACTORY_IID "OAFIID:GNOME_Evolution_Addressbook_VCard_ImporterFactory"
-
-static BonoboGenericFactory *factory = NULL;
-
-typedef struct {
- char *filename;
- char *folderpath;
- GList *cardlist;
- GList *iterator;
- EBook *book;
- gboolean ready;
-} VCardImporter;
-
-static void
-add_card_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure)
-{
- ECard *card = E_CARD(closure);
- gtk_object_unref(GTK_OBJECT(card));
-}
-
-static void
-book_open_cb (EBook *book, EBookStatus status, gpointer closure)
-{
- VCardImporter *gci = (VCardImporter *) closure;
-
- gci->cardlist = e_card_load_cards_from_file_with_default_charset(gci->filename, "ISO-8859-1");
- gci->ready = TRUE;
-}
-
-static void
-ebook_create (VCardImporter *gci)
-{
- gchar *path, *uri;
- gchar *epath;
-
- gci->book = e_book_new ();
-
- if (!gci->book) {
- printf ("%s: %s(): Couldn't create EBook, bailing.\n",
- __FILE__,
- __FUNCTION__);
- return;
- }
-
- path = g_concat_dir_and_file (g_get_home_dir (), "evolution/local");
- uri = g_strdup_printf ("file://%s", path);
- g_free (path);
-
- epath = e_path_to_physical (uri, gci->folderpath);
- g_free (uri);
- uri = g_strdup_printf ("%s/addressbook.db", epath);
- g_free (epath);
-
- if (! e_book_load_uri (gci->book, uri, book_open_cb, gci)) {
- printf ("error calling load_uri!\n");
- }
- g_free(uri);
-}
-
-/* EvolutionImporter methods */
-static void
-process_item_fn (EvolutionImporter *importer,
- CORBA_Object listener,
- void *closure,
- CORBA_Environment *ev)
-{
- VCardImporter *gci = (VCardImporter *) closure;
- ECard *card;
-
- if (gci->iterator == NULL)
- gci->iterator = gci->cardlist;
-
- if (gci->ready == FALSE) {
- GNOME_Evolution_ImporterListener_notifyResult (listener,
- GNOME_Evolution_ImporterListener_NOT_READY,
- gci->iterator ? TRUE : FALSE,
- ev);
- return;
- }
-
- if (gci->iterator == NULL) {
- GNOME_Evolution_ImporterListener_notifyResult (listener,
- GNOME_Evolution_ImporterListener_UNSUPPORTED_OPERATION,
- FALSE, ev);
- return;
- }
-
- card = gci->iterator->data;
- e_book_add_card (gci->book, card, add_card_cb, card);
-
- gci->iterator = gci->iterator->next;
-
- GNOME_Evolution_ImporterListener_notifyResult (listener,
- GNOME_Evolution_ImporterListener_OK,
- gci->iterator ? TRUE : FALSE,
- ev);
- if (ev->_major != CORBA_NO_EXCEPTION) {
- g_warning ("Error notifying listeners.");
- }
-
- return;
-}
-
-static char *supported_extensions[3] = {
- ".vcf",
- ".gcrd",
- NULL
-};
-
-/* Actually check the contents of this file */
-static gboolean
-check_file_is_vcard (const char *filename)
-{
- FILE *handle;
- char line[4096];
- gboolean result;
-
- handle = fopen (filename, "r");
- if (handle == NULL) {
- g_print ("\n");
- return FALSE;
- }
-
- fgets (line, 4096, handle);
- if (line == NULL) {
- fclose (handle);
- g_print ("\n");
- return FALSE;
- }
-
- if (strncmp (line, "BEGIN:VCARD", 11) == 0) {
- result = TRUE;
- } else {
- result = FALSE;
- }
-
- fclose (handle);
- return result;
-}
-
-static gboolean
-support_format_fn (EvolutionImporter *importer,
- const char *filename,
- void *closure)
-{
- char *ext;
- int i;
-
- ext = strrchr (filename, '.');
- if (ext == NULL) {
- return check_file_is_vcard (filename);
- }
- for (i = 0; supported_extensions[i] != NULL; i++) {
- if (strcmp (supported_extensions[i], ext) == 0)
- return check_file_is_vcard (filename);
- }
-
- return FALSE;
-}
-
-static void
-importer_destroy_cb (GtkObject *object,
- VCardImporter *gci)
-{
- gtk_main_quit ();
-}
-
-static gboolean
-load_file_fn (EvolutionImporter *importer,
- const char *filename,
- const char *folderpath,
- void *closure)
-{
- VCardImporter *gci;
-
- if (check_file_is_vcard (filename) == FALSE) {
- return FALSE;
- }
-
- gci = (VCardImporter *) closure;
- gci->filename = g_strdup (filename);
- gci->folderpath = g_strdup (folderpath);
- gci->cardlist = NULL;
- gci->iterator = NULL;
- gci->ready = FALSE;
- ebook_create (gci);
-
- return TRUE;
-}
-
-static BonoboObject *
-factory_fn (BonoboGenericFactory *_factory,
- void *closure)
-{
- EvolutionImporter *importer;
- VCardImporter *gci;
-
- gci = g_new (VCardImporter, 1);
- importer = evolution_importer_new (support_format_fn, load_file_fn,
- process_item_fn, NULL, gci);
-
- gtk_signal_connect (GTK_OBJECT (importer), "destroy",
- GTK_SIGNAL_FUNC (importer_destroy_cb), gci);
-
- return BONOBO_OBJECT (importer);
-}
-
-static void
-importer_init (void)
-{
- if (factory != NULL)
- return;
-
- factory = bonobo_generic_factory_new (COMPONENT_FACTORY_IID,
- factory_fn, NULL);
-
- if (factory == NULL) {
- g_error ("Unable to create factory");
- }
-
- bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory));
-}
-
-int
-main (int argc,
- char **argv)
-{
- CORBA_ORB orb;
-
- gnome_init_with_popt_table ("Evolution-VCard-Importer",
- PACKAGE, argc, argv, oaf_popt_options, 0,
- NULL);
- orb = oaf_init (argc, argv);
- if (bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE) {
- g_error ("Could not initialize Bonobo.");
- }
-
- importer_init ();
- bonobo_main ();
-
- return 0;
-}
-
-
diff --git a/addressbook/backend/ebook/load-gnomecard-addressbook.c b/addressbook/backend/ebook/load-gnomecard-addressbook.c
deleted file mode 100644
index 6f592a4664..0000000000
--- a/addressbook/backend/ebook/load-gnomecard-addressbook.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-#include <config.h>
-#include <stdio.h>
-#include <glib.h>
-#include <gtk/gtkmain.h>
-#include <libgnome/gnome-defs.h>
-#include <libgnome/gnome-i18n.h>
-#include <libgnome/gnome-util.h>
-#include <libgnomeui/gnome-init.h>
-#include <bonobo/bonobo-main.h>
-#include <liboaf/liboaf.h>
-
-#include "e-book.h"
-
-static CORBA_Environment ev;
-
-static void
-init_bonobo (int argc, char **argv)
-{
- if (bonobo_init (CORBA_OBJECT_NIL, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE)
- g_error (_("Could not initialize Bonobo"));
-}
-
-static void
-add_card_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure)
-{
- ECard *card = E_CARD(closure);
- char *vcard = e_card_get_vcard_assume_utf8(card);
- g_print ("Saved card: %s\n", vcard);
- g_free(vcard);
- gtk_object_unref(GTK_OBJECT(card));
-}
-
-static void
-book_open_cb (EBook *book, EBookStatus status, gpointer closure)
-{
- GList *list = e_card_load_cards_from_file_with_default_charset("gnomecard.vcf", "ISO-8859-1");
- GList *iterator;
- for (iterator = list; iterator; iterator = g_list_next(iterator)) {
- ECard *card = iterator->data;
- e_book_add_card(book, card, add_card_cb, card);
- }
- g_list_free(list);
-}
-
-static guint
-ebook_create (void)
-{
- EBook *book;
- gchar *path, *uri;
-
- book = e_book_new ();
-
- if (!book) {
- printf ("%s: %s(): Couldn't create EBook, bailing.\n",
- __FILE__,
- __FUNCTION__);
- return FALSE;
- }
-
-
- path = g_concat_dir_and_file (g_get_home_dir (),
- "evolution/local/Contacts/addressbook.db");
- uri = g_strdup_printf ("file://%s", path);
- g_free (path);
-
- if (! e_book_load_uri (book, uri, book_open_cb, NULL)) {
- printf ("error calling load_uri!\n");
- }
- g_free(uri);
-
-
- return FALSE;
-}
-
-int
-main (int argc, char **argv)
-{
-
- CORBA_exception_init (&ev);
-
- gnome_init_with_popt_table("blah", "0.0", argc, argv, NULL, 0, NULL);
- oaf_init (argc, argv);
- init_bonobo (argc, argv);
-
- gtk_idle_add ((GtkFunction) ebook_create, NULL);
-
- bonobo_main ();
-
- return 0;
-}
diff --git a/addressbook/backend/ebook/load-pine-addressbook.c b/addressbook/backend/ebook/load-pine-addressbook.c
deleted file mode 100644
index c1d58a88bf..0000000000
--- a/addressbook/backend/ebook/load-pine-addressbook.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-#include <config.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <glib.h>
-#include <gtk/gtkmain.h>
-#include <libgnome/gnome-defs.h>
-#include <libgnome/gnome-i18n.h>
-#include <libgnome/gnome-util.h>
-#include <libgnomeui/gnome-init.h>
-#include <bonobo/bonobo-main.h>
-#include <liboaf/liboaf.h>
-
-#include "e-book.h"
-
-static CORBA_Environment ev;
-
-static void
-init_bonobo (int argc, char **argv)
-{
- if (bonobo_init (CORBA_OBJECT_NIL, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE)
- g_error (_("Could not initialize Bonobo"));
-}
-
-static void
-add_card_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure)
-{
- ECard *card = E_CARD(closure);
- char *vcard = e_card_get_vcard_assume_utf8(card);
- g_print ("Saved card: %s\n", vcard);
- g_free(vcard);
- gtk_object_unref(GTK_OBJECT(card));
-}
-
-static void
-parse_line (EBook *book, char *line)
-{
- char **strings;
- ECardName *name;
- ECard *card;
- EList *list;
-
- card = e_card_new("");
- strings = g_strsplit(line, "\t", 3);
- if (strings[0] && strings[1] && strings[2]) {
- name = e_card_name_from_string(strings[1]);
- gtk_object_set(GTK_OBJECT(card),
- "nickname", strings[0],
- "full_name", strings[1],
- "name", name,
- NULL);
- gtk_object_get(GTK_OBJECT(card),
- "email", &list,
- NULL);
- e_list_append(list, strings[2]);
- e_book_add_card(book, card, add_card_cb, card);
- }
- g_strfreev(strings);
-}
-
-static void
-book_open_cb (EBook *book, EBookStatus status, gpointer closure)
-{
- FILE *fp = fopen (".addressbook", "r");
- char line[2 * 1024];
- int which = 0;
- char *lastline = NULL;
-
- if (!fp) {
- g_warning ("Can't find .addressbook");
- return;
- }
-
- while(fgets(line + which * 1024, 1024, fp)) {
- int length;
- char *thisline = line + which * 1024;
- length = strlen(thisline);
- if (thisline[length - 1] == '\n')
- line[--length] = 0;
- if (lastline && *thisline && isspace(*thisline)) {
- char *temp;
- while(*thisline && isspace(*thisline))
- thisline ++;
- temp = lastline;
- lastline = g_strdup_printf("%s%s", lastline, thisline);
- g_free(temp);
- continue;
- }
- if (lastline) {
- parse_line (book, lastline);
- g_free(lastline);
- }
- lastline = g_strdup(thisline);
- }
-
- if (lastline) {
- parse_line (book, lastline);
- g_free(lastline);
- }
-}
-
-static guint
-ebook_create (void)
-{
- EBook *book;
- gchar *path, *uri;
-
- book = e_book_new ();
-
- if (!book) {
- printf ("%s: %s(): Couldn't create EBook, bailing.\n",
- __FILE__,
- __FUNCTION__);
- return FALSE;
- }
-
-
- path = g_concat_dir_and_file (g_get_home_dir (),
- "evolution/local/Contacts/addressbook.db");
- uri = g_strdup_printf ("file://%s", path);
- g_free (path);
-
- if (! e_book_load_uri (book, uri, book_open_cb, NULL)) {
- printf ("error calling load_uri!\n");
- }
- g_free(uri);
-
-
- return FALSE;
-}
-
-#if 0
-static char *
-read_file (char *name)
-{
- int len;
- char buff[65536];
- char line[1024];
- FILE *f;
-
- f = fopen (name, "r");
- if (f == NULL)
- g_error ("Unable to open %s!\n", name);
-
- len = 0;
- while (fgets (line, sizeof (line), f) != NULL) {
- strcpy (buff + len, line);
- len += strlen (line);
- }
-
- fclose (f);
-
- return g_strdup (buff);
-}
-#endif
-
-int
-main (int argc, char **argv)
-{
-
- CORBA_exception_init (&ev);
-
- gnome_init_with_popt_table("blah", "0.0", argc, argv, NULL, 0, NULL);
- oaf_init (argc, argv);
- init_bonobo (argc, argv);
-
- gtk_idle_add ((GtkFunction) ebook_create, NULL);
-
- bonobo_main ();
-
- return 0;
-}
diff --git a/addressbook/backend/ebook/test-card.c b/addressbook/backend/ebook/test-card.c
deleted file mode 100644
index b17dc62174..0000000000
--- a/addressbook/backend/ebook/test-card.c
+++ /dev/null
@@ -1,206 +0,0 @@
-#include <string.h>
-#include <libgnome/gnome-defs.h>
-#include <libgnomeui/gnome-init.h>
-#include "e-card.h"
-
-#define TEST_VCARD \
-"BEGIN:VCARD
-" \
-"FN:Nat
-" \
-"N:Friedman;Nat;D;Mr.
-" \
-"ORG:Ximian, Inc.
-" \
-"TITLE:Head Geek
-" \
-"ROLE:Programmer/Executive
-" \
-"BDAY:1977-08-06
-" \
-"TEL;WORK:617 679 1984
-" \
-"TEL;CELL:123 456 7890
-" \
-"EMAIL;INTERNET:nat@nat.org
-" \
-"EMAIL;INTERNET:nat@ximian.com
-" \
-"ADR;WORK;POSTAL:P.O. Box 101;;;Any Town;CA;91921-1234;
-" \
-"ADR;HOME;POSTAL;INTL:P.O. Box 202;;;Any Town 2;MI;12344-4321;USA
-" \
-"END:VCARD
-" \
-"
-"
-
-static char *
-read_file (char *name)
-{
- int len;
- char buff[65536];
- char line[1024];
- FILE *f;
-
- f = fopen (name, "r");
- if (f == NULL)
- g_error ("Unable to open %s!\n", name);
-
- len = 0;
- while (fgets (line, sizeof (line), f) != NULL) {
- strcpy (buff + len, line);
- len += strlen (line);
- }
-
- fclose (f);
-
- return g_strdup (buff);
-}
-
-
-
-int
-main (int argc, char **argv)
-{
- char *cardstr;
- ECard *card;
-
- /* Fields */
- char *fname;
- char *org;
- char *org_unit;
- char *title;
- char *role;
- char *nickname;
- char *fburl;
- ECardName *name;
- EList *address;
- EList *phone;
- EList *email;
- EList *arbitrary;
- EIterator *iterator;
- ECardDate *bday;
-
- gnome_init ("TestCard", "0.0", argc, argv);
-
- cardstr = NULL;
- if (argc == 2)
- cardstr = read_file (argv [1]);
-
- if (cardstr == NULL)
- cardstr = TEST_VCARD;
-#if 0
- {
- int i;
- for ( i = 0; i < 100000; i++ ) {
- card = e_card_new (cardstr);
-
- gtk_object_unref (GTK_OBJECT (card));
- }
- }
-#endif
- card = e_card_new_with_default_charset (cardstr, "ISO-8859-1");
- gtk_object_get(GTK_OBJECT(card),
- "full_name", &fname,
- "name", &name,
- "address", &address,
- "phone", &phone,
- "email", &email,
- "org", &org,
- "org_unit", &org_unit,
- "title", &title,
- "role", &role,
- "nickname", &nickname,
- "fburl", &fburl,
- "arbitrary", &arbitrary,
- "birth_date", &bday,
- NULL);
- if ( fname ) {
- printf("Name : %s\n", fname);
- g_free(fname);
- }
- if ( name ) {
- printf("Full Name:\n");
- if ( name->prefix )
- printf(" prefix : %s\n", name->prefix);
- if ( name->given )
- printf(" given : %s\n", name->given);
- if ( name->additional )
- printf(" additional : %s\n", name->additional);
- if ( name->family )
- printf(" family : %s\n", name->family);
- if ( name->suffix )
- printf(" suffix : %s\n", name->suffix);
- }
- if ( org ) {
- printf("Company : %s\n", org);
- }
- if ( org_unit ) {
- printf("Department : %s\n", org_unit);
- }
- if ( title ) {
- printf("Title : %s\n", title);
- }
- if ( role ) {
- printf("Profession : %s\n", role);
- }
- if ( nickname ) {
- printf("Nickname : %s\n", nickname);
- }
- if ( fburl ) {
- printf("Free Busy URL : %s\n", fburl);
- }
- if ( arbitrary ) {
- iterator = e_list_get_iterator(arbitrary);
- for (; e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
- ECardArbitrary *arbitrary = (ECardArbitrary *) e_iterator_get(iterator);
- printf("Arbitrary : %s, %s\n", arbitrary->key, arbitrary->value);
- }
- gtk_object_unref(GTK_OBJECT(iterator));
- }
- if ( bday ) {
- printf("BDay : %4d-%02d-%02d\n", bday->year, bday->month, bday->day);
- }
- if ( email ) {
- iterator = e_list_get_iterator(address);
- for (; e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
- printf("Email : %s\n", (char *) e_iterator_get(iterator));
- }
- gtk_object_unref(GTK_OBJECT(iterator));
- }
- if ( phone ) {
- iterator = e_list_get_iterator(address);
- for (; e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
- ECardPhone *e_card_phone = (ECardPhone *) e_iterator_get(iterator);
- printf("Phone ; %d : %s\n", e_card_phone->flags, e_card_phone->number);
- }
- gtk_object_unref(GTK_OBJECT(iterator));
- }
- if ( address ) {
- iterator = e_list_get_iterator(address);
- for (; e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
- ECardDeliveryAddress *del_address = (ECardDeliveryAddress *) e_iterator_get(iterator);
- printf("Address ; %d:\n", del_address->flags);
- if ( del_address->po )
- printf(" Po : %s\n", del_address->po);
- if ( del_address->ext )
- printf(" Ext : %s\n", del_address->ext);
- if ( del_address->street )
- printf(" Street : %s\n", del_address->street);
- if ( del_address->city )
- printf(" City : %s\n", del_address->city);
- if ( del_address->region )
- printf(" Region : %s\n", del_address->region);
- if ( del_address->code )
- printf(" Code : %s\n", del_address->code);
- if ( del_address->country )
- printf(" Country : %s\n", del_address->country);
- }
- gtk_object_unref(GTK_OBJECT(iterator));
- }
- printf("%s", e_card_get_vcard_assume_utf8(card));
- gtk_object_unref (GTK_OBJECT (card));
-
- return 0;
-}
diff --git a/addressbook/backend/ebook/test-client-list.c b/addressbook/backend/ebook/test-client-list.c
deleted file mode 100644
index 8a38ccf4e1..0000000000
--- a/addressbook/backend/ebook/test-client-list.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-#include <config.h>
-
-#include <glib.h>
-#include <gtk/gtkmain.h>
-#include <libgnome/gnome-defs.h>
-#include <libgnome/gnome-i18n.h>
-#include <libgnomeui/gnome-init.h>
-#include <liboaf/liboaf.h>
-#include <bonobo/bonobo-main.h>
-
-#include "e-book.h"
-
-CORBA_Environment ev;
-
-static void
-init_bonobo (int argc, char **argv)
-{
- gnome_init ("blah", "0.0", argc, argv);
- oaf_init (argc, argv);
-
- if (bonobo_init (CORBA_OBJECT_NIL, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE)
- g_error (_("Could not initialize Bonobo"));
-}
-
-static void
-get_cursor_cb (EBook *book, EBookStatus status, ECardCursor *cursor, gpointer closure)
-{
- long length = e_card_cursor_get_length(cursor);
- long i;
-
- printf ("Length: %d\n", (int) length);
- for ( i = 0; i < length; i++ ) {
- ECard *card = e_card_cursor_get_nth(cursor, i);
- char *vcard = e_card_get_vcard_assume_utf8(card);
- printf("[%s]\n", vcard);
- g_free(vcard);
- gtk_object_unref(GTK_OBJECT(card));
- }
-}
-
-static void
-book_open_cb (EBook *book, EBookStatus status, gpointer closure)
-{
- printf ("Book opened.\n");
- e_book_get_cursor(book, "", get_cursor_cb, NULL);
-}
-
-static guint
-ebook_create (void)
-{
- EBook *book;
-
- book = e_book_new ();
-
- if (! e_book_load_uri (book, "file:/tmp/test.db", book_open_cb, NULL)) {
- printf ("error calling load_uri!\n");
- }
-
-
- return FALSE;
-}
-
-int
-main (int argc, char **argv)
-{
-
- CORBA_exception_init (&ev);
- init_bonobo (argc, argv);
-
- gtk_idle_add ((GtkFunction) ebook_create, NULL);
-
- bonobo_main ();
-
- return 0;
-}
diff --git a/addressbook/backend/ebook/test-client.c b/addressbook/backend/ebook/test-client.c
deleted file mode 100644
index 04f2c5b0e3..0000000000
--- a/addressbook/backend/ebook/test-client.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-#include <config.h>
-#include <glib.h>
-#include <gtk/gtkmain.h>
-#include <libgnome/gnome-defs.h>
-#include <libgnome/gnome-i18n.h>
-#include <libgnomeui/gnome-init.h>
-#include <bonobo/bonobo-main.h>
-#include <liboaf/liboaf.h>
-
-#include "e-book.h"
-#include "e-book-util.h"
-
-#define TEST_VCARD \
-"BEGIN:VCARD
-" \
-"FN:Nat
-" \
-"N:Friedman;Nat;D;Mr.
-" \
-"BDAY:1977-08-06
-" \
-"TEL;WORK:617 679 1984
-" \
-"TEL;CELL:123 456 7890
-" \
-"EMAIL;INTERNET:nat@nat.org
-" \
-"EMAIL;INTERNET:nat@ximian.com
-" \
-"ADR;WORK;POSTAL:P.O. Box 101;;;Any Town;CA;91921-1234;
-" \
-"END:VCARD
-" \
-"
-"
-
-static CORBA_Environment ev;
-static char *cardstr;
-
-static void
-init_bonobo (int argc, char **argv)
-{
- if (bonobo_init (CORBA_OBJECT_NIL, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE)
- g_error (_("Could not initialize Bonobo"));
-}
-
-static void
-get_cursor_cb (EBook *book, EBookStatus status, ECardCursor *cursor, gpointer closure)
-{
- long length = e_card_cursor_get_length(cursor);
- long i;
-
- /* we just added a card, so the length should be >1 */
- printf ("\n%s: %s(): Number of cards is %ld\n",
- __FILE__, __FUNCTION__, length);
- if (length < 1)
- printf ("*** Why isn't this above zero?? ***\n\n");
-
- for ( i = 0; i < length; i++ ) {
- ECard *card = e_card_cursor_get_nth(cursor, i);
- char *vcard = e_card_get_vcard_assume_utf8(card);
- printf("Get all cards callback: [%s]\n", vcard);
- g_free(vcard);
- gtk_object_unref(GTK_OBJECT(card));
- }
-}
-
-static void
-get_card_cb (EBook *book, EBookStatus status, ECard *card, gpointer closure)
-{
- char *vcard;
-
- vcard = e_card_get_vcard_assume_utf8(card);
- printf ("Card added: [%s]\n", vcard);
- g_free(vcard);
- gtk_object_unref(GTK_OBJECT(card));
-
- printf ("Getting cards..\n");
- e_book_get_cursor(book, "", get_cursor_cb, NULL);
- printf ("Done getting all cards.\n");
-}
-
-static void
-add_card_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure)
-{
- GTimer *timer;
-
- printf ("Status: %d\n", status);
-
- printf ("Id: %s\n", id);
-
- timer = g_timer_new ();
- g_timer_start (timer);
- e_book_get_card (book, id, get_card_cb, closure);
- g_timer_stop (timer);
- printf ("%g\n", g_timer_elapsed (timer, NULL));
-}
-
-static void
-get_fields_cb (EBook *book, EBookStatus status, EList *fields, gpointer closure)
-{
- if (fields) {
- EIterator *iter = e_list_get_iterator (fields);
-
- printf ("Supported fields:\n");
-
- for (; e_iterator_is_valid (iter); e_iterator_next (iter)) {
- printf (" %s\n", (char*)e_iterator_get (iter));
- }
-
- gtk_object_unref(GTK_OBJECT(fields));
- }
- else {
- printf ("No supported fields?\n");
- }
-
- e_book_add_vcard(book, cardstr, add_card_cb, NULL);
-}
-
-
-static void
-auth_user_cb (EBook *book, EBookStatus status, gpointer closure)
-{
- printf ("user authenticated\n");
- e_book_get_supported_fields (book, get_fields_cb, closure);
-}
-
-static void
-book_open_cb (EBook *book, EBookStatus status, gpointer closure)
-{
- e_book_authenticate_user (book, "username", "password", "auth_method", auth_user_cb, NULL);
-}
-
-static guint
-ebook_create (void)
-{
- EBook *book;
-
- book = e_book_new ();
-
- if (!book) {
- printf ("%s: %s(): Couldn't create EBook, bailing.\n",
- __FILE__,
- __FUNCTION__);
- return FALSE;
- }
-
-
- if (! e_book_load_default_book (book, book_open_cb, NULL)) {
- printf ("error calling load_uri!\n");
- }
-
-
- return FALSE;
-}
-
-static char *
-read_file (char *name)
-{
- int len;
- char buff[65536];
- char line[1024];
- FILE *f;
-
- f = fopen (name, "r");
- if (f == NULL)
- g_error ("Unable to open %s!\n", name);
-
- len = 0;
- while (fgets (line, sizeof (line), f) != NULL) {
- strcpy (buff + len, line);
- len += strlen (line);
- }
-
- fclose (f);
-
- return g_strdup (buff);
-}
-
-
-int
-main (int argc, char **argv)
-{
-
- CORBA_exception_init (&ev);
-
- gnome_init_with_popt_table ("blah", "0.0", argc, argv, NULL, 0, NULL);
- oaf_init (argc, argv);
- init_bonobo (argc, argv);
-
- cardstr = NULL;
- if (argc == 2)
- cardstr = read_file (argv [1]);
-
- if (cardstr == NULL)
- cardstr = TEST_VCARD;
-
- gtk_idle_add ((GtkFunction) ebook_create, NULL);
-
- bonobo_main ();
-
- return 0;
-}