aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/backend/ebook
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-04-03 23:03:56 +0800
committerChris Lahey <clahey@src.gnome.org>2000-04-03 23:03:56 +0800
commita15df79e225ed290978c0650bc2a193086444707 (patch)
treeeec11ece68e526c9b76a05198104a671b04a85da /addressbook/backend/ebook
parent9e7dabfa8274777916da364b50284cfa51ac9a6f (diff)
downloadgsoc2013-evolution-a15df79e225ed290978c0650bc2a193086444707.tar
gsoc2013-evolution-a15df79e225ed290978c0650bc2a193086444707.tar.gz
gsoc2013-evolution-a15df79e225ed290978c0650bc2a193086444707.tar.bz2
gsoc2013-evolution-a15df79e225ed290978c0650bc2a193086444707.tar.lz
gsoc2013-evolution-a15df79e225ed290978c0650bc2a193086444707.tar.xz
gsoc2013-evolution-a15df79e225ed290978c0650bc2a193086444707.tar.zst
gsoc2013-evolution-a15df79e225ed290978c0650bc2a193086444707.zip
A bit of clean up.
2000-04-03 Christopher James Lahey <clahey@helixcode.com> * addressbook/backend/ebook/e-card-cursor.h, addressbook/backend/ebook/e-card.c: A bit of clean up. * addressbook/backend/ebook/e-book-types.h, addressbook/backend/ebook/e-book-view-listener.c, addressbook/backend/ebook/e-book-view-listener.h, addressbook/backend/ebook/e-book-view.c, addressbook/backend/ebook/e-book-view.h, addressbook/backend/pas/pas-book-view.c, addressbook/backend/pas/pas-book-view.h: New files for live views. * addressbook/backend/ebook/Makefile.am, addressbook/backend/ebook/e-book-listener.c, addressbook/backend/ebook/e-book-listener.h, addressbook/backend/ebook/e-book.c, addressbook/backend/ebook/e-book.h, addressbook/backend/ebook/test-client-list.c, addressbook/backend/ebook/test-client.c, addressbook/backend/pas/pas-backend-file.c, addressbook/backend/pas/pas-book.c, addressbook/backend/pas/pas-book.h, addressbook/backend/idl/addressbook.idl: Added live views and searching to the interface (neither is working yet.) svn path=/trunk/; revision=2280
Diffstat (limited to 'addressbook/backend/ebook')
-rw-r--r--addressbook/backend/ebook/Makefile.am6
-rw-r--r--addressbook/backend/ebook/e-book-listener.c143
-rw-r--r--addressbook/backend/ebook/e-book-listener.h22
-rw-r--r--addressbook/backend/ebook/e-book-types.h29
-rw-r--r--addressbook/backend/ebook/e-book-view-listener.c344
-rw-r--r--addressbook/backend/ebook/e-book-view-listener.h72
-rw-r--r--addressbook/backend/ebook/e-book-view.c280
-rw-r--r--addressbook/backend/ebook/e-book-view.h55
-rw-r--r--addressbook/backend/ebook/e-book.c207
-rw-r--r--addressbook/backend/ebook/e-book.h25
-rw-r--r--addressbook/backend/ebook/e-card-cursor.h6
-rw-r--r--addressbook/backend/ebook/e-card.c4
-rw-r--r--addressbook/backend/ebook/test-client-list.c5
-rw-r--r--addressbook/backend/ebook/test-client.c3
14 files changed, 999 insertions, 202 deletions
diff --git a/addressbook/backend/ebook/Makefile.am b/addressbook/backend/ebook/Makefile.am
index b942ed8bc7..05d07458bf 100644
--- a/addressbook/backend/ebook/Makefile.am
+++ b/addressbook/backend/ebook/Makefile.am
@@ -41,6 +41,8 @@ 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-card-cursor.c \
e-card.c
@@ -48,8 +50,10 @@ libebook_la_SOURCES = \
libebookincludedir = $(includedir)/backend
libebookinclude_HEADERS = \
- e-book.h \
e-book-listener.h \
+ e-book-view-listener.h \
+ e-book-view.h \
+ e-book.h \
e-card-cursor.h \
e-card.h
diff --git a/addressbook/backend/ebook/e-book-listener.c b/addressbook/backend/ebook/e-book-listener.c
index 4f2e278911..d58242dd30 100644
--- a/addressbook/backend/ebook/e-book-listener.c
+++ b/addressbook/backend/ebook/e-book-listener.c
@@ -25,7 +25,6 @@ static BonoboObjectClass *e_book_listener_parent_class;
POA_Evolution_BookListener__vepv e_book_listener_vepv;
struct _EBookListenerPrivate {
- EBook *book;
GList *response_queue;
gint idle_id;
};
@@ -142,31 +141,31 @@ e_book_listener_queue_get_cursor_response (EBookListener *listener,
}
static void
-e_book_listener_queue_link_status (EBookListener *listener,
- gboolean connected)
+e_book_listener_queue_get_view_response (EBookListener *listener,
+ EBookStatus status,
+ Evolution_BookView book_view)
{
EBookListenerResponse *resp;
-
+
resp = g_new0 (EBookListenerResponse, 1);
- resp->op = LinkStatusEvent;
- resp->connected = connected;
-
+ resp->op = GetBookViewResponse;
+ resp->status = status;
+ resp->book_view = book_view;
+
e_book_listener_queue_response (listener, resp);
}
static void
-e_book_listener_queue_generic_event (EBookListener *listener,
- EBookStatus status,
- const char *id)
+e_book_listener_queue_link_status (EBookListener *listener,
+ gboolean connected)
{
EBookListenerResponse *resp;
resp = g_new0 (EBookListenerResponse, 1);
resp->op = LinkStatusEvent;
- resp->status = status;
- resp->id = g_strdup (id);
+ resp->connected = connected;
e_book_listener_queue_response (listener, resp);
}
@@ -232,6 +231,28 @@ impl_BookListener_respond_get_cursor (PortableServer_Servant servant,
}
static void
+impl_BookListener_respond_get_view (PortableServer_Servant servant,
+ const Evolution_BookListener_CallStatus status,
+ const Evolution_BookView book_view,
+ CORBA_Environment *ev)
+{
+ EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant));
+ Evolution_BookView book_view_copy;
+
+ book_view_copy = CORBA_Object_duplicate (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_open_book (PortableServer_Servant servant,
const Evolution_BookListener_CallStatus status,
const Evolution_Book book,
@@ -276,54 +297,6 @@ impl_BookListener_report_connection_status (PortableServer_Servant servant,
listener, connected);
}
-static void
-impl_BookListener_signal_card_added (PortableServer_Servant servant,
- const Evolution_CardId id,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant));
-
- e_book_listener_queue_generic_event (
- listener, CardAddedEvent, (const char *) id);
-}
-
-static void
-impl_BookListener_signal_card_removed (PortableServer_Servant servant,
- const Evolution_CardId id,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant));
-
- e_book_listener_queue_generic_event (
- listener, CardRemovedEvent, (const char *) id);
-}
-
-static void
-impl_BookListener_signal_card_changed (PortableServer_Servant servant,
- const Evolution_CardId id,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant));
-
- e_book_listener_queue_generic_event (
- listener, CardModifiedEvent, (const char *) id);
-}
-
-/**
- * e_book_listener_get_book:
- * @listener: the #EBookListener
- *
- * Returns: the #EBook associated with the @listener.
- */
-EBook *
-e_book_listener_get_book (EBookListener *listener)
-{
- g_return_val_if_fail (listener != NULL, NULL);
- g_return_val_if_fail (E_IS_BOOK_LISTENER (listener), NULL);
-
- return listener->priv->book;
-}
-
/**
* e_book_listener_check_pending:
* @listener: the #EBookListener
@@ -392,7 +365,7 @@ e_book_listener_convert_status (const Evolution_BookListener_CallStatus status)
}
static EBookListener *
-e_book_listener_construct (EBookListener *listener, EBook *book)
+e_book_listener_construct (EBookListener *listener)
{
POA_Evolution_BookListener *servant;
CORBA_Environment ev;
@@ -400,10 +373,6 @@ e_book_listener_construct (EBookListener *listener, EBook *book)
g_assert (listener != NULL);
g_assert (E_IS_BOOK_LISTENER (listener));
- g_assert (book != NULL);
- g_assert (E_IS_BOOK (book));
-
- listener->priv->book = book;
servant = (POA_Evolution_BookListener *) g_new0 (BonoboObjectServant, 1);
servant->vepv = &e_book_listener_vepv;
@@ -441,17 +410,14 @@ e_book_listener_construct (EBookListener *listener, EBook *book)
* Returns: a new #EBookListener
*/
EBookListener *
-e_book_listener_new (EBook *book)
+e_book_listener_new ()
{
EBookListener *listener;
EBookListener *retval;
- g_return_val_if_fail (book != NULL, NULL);
- g_return_val_if_fail (E_IS_BOOK (book), NULL);
-
listener = gtk_type_new (E_BOOK_LISTENER_TYPE);
- retval = e_book_listener_construct (listener, book);
+ retval = e_book_listener_construct (listener);
if (retval == NULL) {
g_warning ("e_book_listener_new: Error constructing "
@@ -497,6 +463,38 @@ e_book_listener_destroy (GtkObject *object)
CORBA_exception_free (&ev);
}
+ if (resp->cursor != CORBA_OBJECT_NIL) {
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+
+ CORBA_Object_release (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);
+
+ CORBA_Object_release (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);
}
g_list_free (listener->priv->response_queue);
@@ -521,13 +519,10 @@ e_book_listener_get_epv (void)
epv->respond_modify_card = impl_BookListener_respond_modify_card;
epv->respond_get_cursor = impl_BookListener_respond_get_cursor;
+ epv->respond_get_view = impl_BookListener_respond_get_view;
epv->report_connection_status = impl_BookListener_report_connection_status;
- epv->signal_card_changed = impl_BookListener_signal_card_changed;
- epv->signal_card_removed = impl_BookListener_signal_card_removed;
- epv->signal_card_added = impl_BookListener_signal_card_added;
-
return epv;
}
diff --git a/addressbook/backend/ebook/e-book-listener.h b/addressbook/backend/ebook/e-book-listener.h
index 27dd0df10f..5707deceb5 100644
--- a/addressbook/backend/ebook/e-book-listener.h
+++ b/addressbook/backend/ebook/e-book-listener.h
@@ -14,26 +14,28 @@
#include <libgnome/gnome-defs.h>
#include <bonobo/bonobo-object.h>
-#include <e-book.h>
#include <addressbook.h>
+#include <e-book-types.h>
BEGIN_GNOME_DECLS
+typedef struct _EBookListener EBookListener;
+typedef struct _EBookListenerClass EBookListenerClass;
typedef struct _EBookListenerPrivate EBookListenerPrivate;
-typedef struct {
+struct _EBookListener {
BonoboObject parent;
EBookListenerPrivate *priv;
-} EBookListener;
+};
-typedef struct {
+struct _EBookListenerClass {
BonoboObjectClass parent;
/*
* Signals
*/
void (*responses_queued) (void);
-} EBookListenerClass;
+};
typedef enum {
/* Async responses */
@@ -42,11 +44,9 @@ typedef enum {
RemoveCardResponse,
ModifyCardResponse,
GetCursorResponse,
+ GetBookViewResponse,
/* Async events */
- CardAddedEvent,
- CardRemovedEvent,
- CardModifiedEvent,
LinkStatusEvent,
OpenProgressEvent,
} EBookListenerOperation;
@@ -63,6 +63,9 @@ typedef struct {
/* For GetCursorResponse */
Evolution_CardCursor cursor;
+ /* For GetBookViewReponse */
+ Evolution_BookView book_view;
+
/* For OpenProgressEvent */
char *msg;
short percent;
@@ -74,8 +77,7 @@ typedef struct {
char *id;
} EBookListenerResponse;
-EBookListener *e_book_listener_new (EBook *book);
-EBook *e_book_listener_get_book (EBookListener *listener);
+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);
diff --git a/addressbook/backend/ebook/e-book-types.h b/addressbook/backend/ebook/e-book-types.h
new file mode 100644
index 0000000000..1d86a5bd4d
--- /dev/null
+++ b/addressbook/backend/ebook/e-book-types.h
@@ -0,0 +1,29 @@
+/* -*- 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@helixcode.com)
+ *
+ * Copyright 2000, Helix Code, 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
+} EBookStatus;
+
+END_GNOME_DECLS
+
+#endif /* ! __E_BOOK_TYPES_H__ */
diff --git a/addressbook/backend/ebook/e-book-view-listener.c b/addressbook/backend/ebook/e-book-view-listener.c
new file mode 100644
index 0000000000..0185f7817d
--- /dev/null
+++ b/addressbook/backend/ebook/e-book-view-listener.c
@@ -0,0 +1,344 @@
+/* -*- 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@helixcode.com)
+ *
+ * Copyright 2000, Helix Code, Inc.
+ */
+
+#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_Evolution_BookViewListener__vepv e_book_view_listener_vepv;
+
+struct _EBookViewListenerPrivate {
+ GList *response_queue;
+ gint idle_id;
+};
+
+static gboolean
+e_book_view_listener_check_queue (EBookViewListener *listener)
+{
+ if (listener->priv->response_queue != NULL) {
+ gtk_signal_emit (GTK_OBJECT (listener),
+ e_book_view_listener_signals [RESPONSES_QUEUED]);
+ }
+
+ if (listener->priv->response_queue == NULL) {
+ listener->priv->idle_id = 0;
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
+e_book_view_listener_queue_response (EBookViewListener *listener,
+ EBookViewListenerResponse *response)
+{
+ listener->priv->response_queue =
+ g_list_append (listener->priv->response_queue,
+ response);
+
+ if (listener->priv->idle_id == 0) {
+ listener->priv->idle_id = g_idle_add (
+ (GSourceFunc) e_book_view_listener_check_queue, listener);
+ }
+}
+
+/* Add, Remove, Modify */
+static void
+e_book_view_listener_queue_id_event (EBookViewListener *listener,
+ EBookViewListenerOperation op,
+ const char *id)
+{
+ EBookViewListenerResponse *resp;
+
+ resp = g_new0 (EBookViewListenerResponse, 1);
+
+ resp->op = op;
+ resp->id = g_strdup (id);
+ resp->cards = 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 Evolution_VCardList *cards)
+{
+ EBookViewListenerResponse *resp;
+ int i;
+
+ resp = g_new0 (EBookViewListenerResponse, 1);
+
+ resp->op = op;
+ resp->id = NULL;
+ resp->cards = 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);
+}
+
+static void
+impl_BookViewListener_signal_card_added (PortableServer_Servant servant,
+ const Evolution_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_signal_card_removed (PortableServer_Servant servant,
+ const Evolution_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_signal_card_changed (PortableServer_Servant servant,
+ const Evolution_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);
+}
+
+/**
+ * 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_Evolution_BookViewListener *servant;
+ CORBA_Environment ev;
+ CORBA_Object obj;
+
+ g_assert (listener != NULL);
+ g_assert (E_IS_BOOK_VIEW_LISTENER (listener));
+
+ servant = (POA_Evolution_BookViewListener *) g_new0 (BonoboObjectServant, 1);
+ servant->vepv = &e_book_view_listener_vepv;
+
+ CORBA_exception_init (&ev);
+
+ POA_Evolution_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");
+ gtk_object_unref (GTK_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->idle_id = 0;
+}
+
+static void
+e_book_view_listener_destroy (GtkObject *object)
+{
+ EBookViewListener *listener = E_BOOK_VIEW_LISTENER (object);
+ GList *l;
+
+ for (l = listener->priv->response_queue; l != NULL; l = l->next) {
+ EBookViewListenerResponse *resp = l->data;
+ if (resp->id)
+ g_free(resp->id);
+ if (resp->cards) {
+ g_list_foreach(resp->cards, (GFunc) gtk_object_unref, NULL);
+ g_list_free(resp->cards);
+ }
+ g_free (resp);
+ }
+ g_list_free (listener->priv->response_queue);
+
+ g_free (listener->priv);
+
+ GTK_OBJECT_CLASS (e_book_view_listener_parent_class)->destroy (object);
+}
+
+POA_Evolution_BookViewListener__epv *
+e_book_view_listener_get_epv (void)
+{
+ POA_Evolution_BookViewListener__epv *epv;
+
+ epv = g_new0 (POA_Evolution_BookViewListener__epv, 1);
+
+ epv->signal_card_changed = impl_BookViewListener_signal_card_changed;
+ epv->signal_card_removed = impl_BookViewListener_signal_card_removed;
+ epv->signal_card_added = impl_BookViewListener_signal_card_added;
+
+ 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.Evolution_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
new file mode 100644
index 0000000000..65d20a3489
--- /dev/null
+++ b/addressbook/backend/ebook/e-book-view-listener.h
@@ -0,0 +1,72 @@
+/* -*- 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@helixcode.com)
+ *
+ * Copyright 2000, Helix Code, 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.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
+} EBookViewListenerOperation;
+
+typedef struct {
+ EBookViewListenerOperation op;
+
+ /* For CardRemovedEvent */
+ char *id;
+
+ /* For Card[Added|Modified]Event */
+ GList *cards; /* Of type ECard. */
+
+} 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);
+
+POA_Evolution_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
new file mode 100644
index 0000000000..e2e9dc2693
--- /dev/null
+++ b/addressbook/backend/ebook/e-book-view.c
@@ -0,0 +1,280 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * The Evolution addressbook client object.
+ *
+ * Author:
+ * Nat Friedman (nat@helixcode.com)
+ *
+ * Copyright 1999, 2000, Helix Code, Inc.
+ */
+
+#include <addressbook.h>
+#include <libgnorba/gnorba.h>
+#include <gtk/gtksignal.h>
+#include <gtk/gtkmarshal.h>
+#include <e-card-cursor.h>
+#include <e-book-view-listener.h>
+#include <e-book-view.h>
+
+GtkObjectClass *e_book_view_parent_class;
+
+struct _EBookViewPrivate {
+ Evolution_BookView corba_book_view;
+
+ EBookViewListener *listener;
+
+ int responses_queued_id;
+};
+
+enum {
+ CARD_CHANGED,
+ CARD_REMOVED,
+ CARD_ADDED,
+ LAST_SIGNAL
+};
+
+static guint e_book_view_signals [LAST_SIGNAL];
+
+static void
+e_book_view_do_added_event (EBookView *book_view,
+ EBookViewListenerResponse *resp)
+{
+ 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)
+{
+ gtk_signal_emit (GTK_OBJECT (book_view), e_book_view_signals [CARD_CHANGED],
+ resp->id);
+
+ g_free (resp->id);
+}
+
+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->cards);
+
+ g_list_foreach (resp->cards, (GFunc) g_free, NULL);
+ g_list_free (resp->cards);
+}
+
+
+/*
+ * 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;
+ default:
+ g_error ("EBookView: Unknown operation %d in listener queue!\n",
+ resp->op);
+ }
+
+ g_free (resp);
+}
+
+static gboolean
+e_book_view_construct (EBookView *book_view, Evolution_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 = CORBA_Object_duplicate(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);
+ return FALSE;
+ }
+
+ Evolution_BookView_ref(book_view->priv->corba_book_view, &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("e_book_view_construct: Exception reffing corba_book_view.\n");
+ CORBA_exception_free (&ev);
+ CORBA_exception_init (&ev);
+ CORBA_Object_release (book_view->priv->corba_book_view, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("e_book_view_construct: Exception releasing 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;
+
+ gtk_object_ref(GTK_OBJECT(book_view->priv->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);
+
+ return TRUE;
+}
+
+/**
+ * e_book_view_new:
+ */
+EBookView *
+e_book_view_new (Evolution_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;
+}
+
+static void
+e_book_view_init (EBookView *book_view)
+{
+ book_view->priv = g_new0 (EBookViewPrivate, 1);
+ 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->corba_book_view) {
+ CORBA_exception_init (&ev);
+
+ Evolution_BookView_unref(book_view->priv->corba_book_view, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("EBookView: Exception while unreffing BookView\n");
+
+ CORBA_exception_free (&ev);
+ CORBA_exception_init (&ev);
+ }
+
+ CORBA_Object_release (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);
+ gtk_object_unref (GTK_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);
+
+ gtk_object_class_add_signals (object_class, e_book_view_signals,
+ LAST_SIGNAL);
+
+ 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
new file mode 100644
index 0000000000..bb042e76f0
--- /dev/null
+++ b/addressbook/backend/ebook/e-book-view.h
@@ -0,0 +1,55 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * The Evolution addressbook client object.
+ *
+ * Author:
+ * Nat Friedman (nat@helixcode.com)
+ *
+ * Copyright 1999, 2000, Helix Code, Inc.
+ */
+
+#ifndef __E_BOOK_VIEW_H__
+#define __E_BOOK_VIEW_H__
+
+#include <libgnome/gnome-defs.h>
+
+#include <e-card.h>
+#include <e-book-view-listener.h>
+
+BEGIN_GNOME_DECLS
+
+typedef struct _EBookView EBookView;
+typedef struct _EBookViewClass EBookViewClass;
+typedef struct _EBookViewPrivate EBookViewPrivate;
+
+struct _EBookView {
+ GtkObject parent;
+ EBookViewPrivate *priv;
+};
+
+struct _EBookViewClass {
+ GtkObjectClass parent;
+
+ /*
+ * Signals.
+ */
+ void (* card_changed) (const GList *id);
+ void (* card_removed) (const char *id);
+ void (* card_added) (const GList *id);
+};
+
+/* Creating a new addressbook. */
+EBookView *e_book_view_new (Evolution_BookView corba_book_view, EBookViewListener *listener);
+
+GtkType e_book_view_get_type (void);
+void e_book_view_get_book_view_listener (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
index ffbf0e78fb..dd4c4bc110 100644
--- a/addressbook/backend/ebook/e-book.c
+++ b/addressbook/backend/ebook/e-book.c
@@ -44,9 +44,6 @@ struct _EBookPrivate {
enum {
OPEN_PROGRESS,
- CARD_CHANGED,
- CARD_REMOVED,
- CARD_ADDED,
LINK_STATUS,
LAST_SIGNAL
};
@@ -56,6 +53,7 @@ static guint e_book_signals [LAST_SIGNAL];
typedef struct {
gpointer cb;
gpointer closure;
+ EBookViewListener *listener;
} EBookOp;
/*
@@ -64,13 +62,15 @@ typedef struct {
static void
e_book_queue_op (EBook *book,
gpointer cb,
- gpointer closure)
+ gpointer closure,
+ EBookViewListener *listener)
{
EBookOp *op;
- op = g_new0 (EBookOp, 1);
- op->cb = cb;
- op->closure = closure;
+ op = g_new0 (EBookOp, 1);
+ op->cb = cb;
+ op->closure = closure;
+ op->listener = listener;
book->priv->pending_ops =
g_list_append (book->priv->pending_ops, op);
@@ -145,7 +145,7 @@ e_book_do_response_get_cursor (EBook *book,
op = e_book_pop_op (book);
if (op == NULL) {
- g_warning ("e_book_do_response_create_card: Cannot find operation "
+ g_warning ("e_book_do_response_get_cursor: Cannot find operation "
"in local op queue!\n");
return;
}
@@ -162,7 +162,7 @@ e_book_do_response_get_cursor (EBook *book,
Bonobo_Unknown_unref (resp->cursor, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_do_response_get_curosr: Exception unref'ing "
+ g_warning ("e_book_do_response_get_cursor: Exception unref'ing "
"remote Evolution_CardCursor interface!\n");
CORBA_exception_free (&ev);
CORBA_exception_init (&ev);
@@ -176,6 +176,57 @@ e_book_do_response_get_cursor (EBook *book,
}
CORBA_exception_free (&ev);
+
+ gtk_object_unref(GTK_OBJECT(cursor));
+
+ g_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);
+
+ ((EBookBookViewCallback) op->cb) (book, resp->status, book_view, op->closure);
+
+ /*
+ * Release the remote Evolution_Book in the PAS.
+ */
+ CORBA_exception_init (&ev);
+
+ Bonobo_Unknown_unref (resp->book_view, &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("e_book_do_response_get_view: Exception unref'ing "
+ "remote Evolution_BookView interface!\n");
+ CORBA_exception_free (&ev);
+ CORBA_exception_init (&ev);
+ }
+
+ CORBA_Object_release (resp->book_view, &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("e_book_do_response_get_view: Exception releasing "
+ "remote Evolution_BookView interface!\n");
+ }
+
+ CORBA_exception_free (&ev);
+
+ gtk_object_unref(GTK_OBJECT(book_view));
+ gtk_object_unref(GTK_OBJECT(op->listener));
g_free (op);
}
@@ -221,48 +272,14 @@ e_book_do_link_event (EBook *book,
resp->connected);
}
-static void
-e_book_do_added_event (EBook *book,
- EBookListenerResponse *resp)
-{
- gtk_signal_emit (GTK_OBJECT (book), e_book_signals [CARD_ADDED],
- resp->id);
-
- g_free (resp->id);
-}
-
-static void
-e_book_do_modified_event (EBook *book,
- EBookListenerResponse *resp)
-{
- gtk_signal_emit (GTK_OBJECT (book), e_book_signals [CARD_CHANGED],
- resp->id);
-
- g_free (resp->id);
-}
-
-static void
-e_book_do_removed_event (EBook *book,
- EBookListenerResponse *resp)
-{
- gtk_signal_emit (GTK_OBJECT (book), e_book_signals [CARD_REMOVED],
- resp->id);
-
- g_free (resp->id);
-}
-
/*
* Reading notices out of the EBookListener's queue.
*/
static void
-e_book_check_listener_queue (EBookListener *listener)
+e_book_check_listener_queue (EBookListener *listener, EBook *book)
{
- EBook *book;
EBookListenerResponse *resp;
-
- book = e_book_listener_get_book (listener);
- g_assert (book != NULL);
resp = e_book_listener_pop_response (listener);
@@ -280,6 +297,9 @@ e_book_check_listener_queue (EBookListener *listener)
case GetCursorResponse:
e_book_do_response_get_cursor (book, resp);
break;
+ case GetBookViewResponse:
+ e_book_do_response_get_view(book, resp);
+ break;
case OpenBookResponse:
e_book_do_response_open (book, resp);
break;
@@ -290,15 +310,6 @@ e_book_check_listener_queue (EBookListener *listener)
case LinkStatusEvent:
e_book_do_link_event (book, resp);
break;
- case CardAddedEvent:
- e_book_do_added_event (book, resp);
- break;
- case CardModifiedEvent:
- e_book_do_modified_event (book, resp);
- break;
- case CardRemovedEvent:
- e_book_do_removed_event (book, resp);
- break;
default:
g_error ("EBook: Unknown operation %d in listener queue!\n",
resp->op);
@@ -349,7 +360,7 @@ e_book_load_uri (EBook *book,
book->priv->load_state = URILoading;
- e_book_queue_op (book, open_response, closure);
+ e_book_queue_op (book, open_response, closure, NULL);
/* Now we play the waiting game. */
@@ -426,14 +437,14 @@ e_book_construct (EBook *book)
/*
* Create our local BookListener interface.
*/
- book->priv->listener = e_book_listener_new (book);
+ book->priv->listener = e_book_listener_new ();
if (book->priv->listener == NULL) {
g_warning ("e_book_construct: Could not create EBookListener!\n");
return FALSE;
}
gtk_signal_connect (GTK_OBJECT (book->priv->listener), "responses_queued",
- e_book_check_listener_queue, NULL);
+ e_book_check_listener_queue, book);
return TRUE;
}
@@ -601,7 +612,7 @@ e_book_remove_card_by_id (EBook *book,
CORBA_exception_free (&ev);
- e_book_queue_op (book, cb, closure);
+ e_book_queue_op (book, cb, closure, NULL);
return TRUE;
}
@@ -670,7 +681,7 @@ e_book_add_vcard (EBook *book,
CORBA_exception_init (&ev);
Evolution_Book_create_card (
- book->priv->corba_book, vcard, &ev);
+ book->priv->corba_book, (const Evolution_VCard) vcard, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("e_book_add_vcard: Exception adding card to PAS!\n");
@@ -680,7 +691,7 @@ e_book_add_vcard (EBook *book,
CORBA_exception_free (&ev);
- e_book_queue_op (book, (EBookCallback) cb, closure);
+ e_book_queue_op (book, (EBookCallback) cb, closure, NULL);
return TRUE;
}
@@ -749,7 +760,7 @@ e_book_commit_vcard (EBook *book,
CORBA_exception_init (&ev);
Evolution_Book_modify_card (
- book->priv->corba_book, vcard, &ev);
+ book->priv->corba_book, (const Evolution_VCard) vcard, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("e_book_commit_vcard: Exception "
@@ -760,7 +771,7 @@ e_book_commit_vcard (EBook *book,
CORBA_exception_free (&ev);
- e_book_queue_op (book, cb, closure);
+ e_book_queue_op (book, cb, closure, NULL);
return TRUE;
}
@@ -797,9 +808,10 @@ e_book_check_connection (EBook *book)
return TRUE;
}
-gboolean e_book_get_all_cards (EBook *book,
- EBookCursorCallback cb,
- gpointer closure)
+gboolean e_book_get_cursor (EBook *book,
+ gchar *query,
+ EBookCursorCallback cb,
+ gpointer closure)
{
CORBA_Environment ev;
@@ -813,7 +825,7 @@ gboolean e_book_get_all_cards (EBook *book,
CORBA_exception_init (&ev);
- Evolution_Book_get_all_cards (book->priv->corba_book, &ev);
+ Evolution_Book_get_cursor (book->priv->corba_book, query, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("e_book_get_all_cards: Exception "
@@ -824,7 +836,43 @@ gboolean e_book_get_all_cards (EBook *book,
CORBA_exception_free (&ev);
- e_book_queue_op (book, cb, closure);
+ e_book_queue_op (book, cb, closure, NULL);
+
+ return TRUE;
+}
+
+gboolean e_book_get_book_view (EBook *book,
+ gchar *query,
+ EBookBookViewCallback cb,
+ gpointer closure)
+{
+ CORBA_Environment ev;
+ EBookViewListener *listener;
+
+ 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_get_book_view: No URI loaded!\n");
+ return FALSE;
+ }
+
+ listener = e_book_view_listener_new();
+
+ CORBA_exception_init (&ev);
+
+ Evolution_Book_get_book_view (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);
+ return FALSE;
+ }
+
+ CORBA_exception_free (&ev);
+
+ e_book_queue_op (book, cb, closure, listener);
return TRUE;
}
@@ -908,33 +956,6 @@ e_book_class_init (EBookClass *klass)
e_book_parent_class = gtk_type_class (gtk_object_get_type ());
- e_book_signals [CARD_CHANGED] =
- gtk_signal_new ("card_changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EBookClass, card_changed),
- gtk_marshal_NONE__POINTER,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_POINTER);
-
- e_book_signals [CARD_ADDED] =
- gtk_signal_new ("card_added",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EBookClass, card_added),
- gtk_marshal_NONE__POINTER,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_POINTER);
-
- e_book_signals [CARD_REMOVED] =
- gtk_signal_new ("card_removed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EBookClass, card_removed),
- gtk_marshal_NONE__POINTER,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_POINTER);
-
e_book_signals [LINK_STATUS] =
gtk_signal_new ("link_status",
GTK_RUN_LAST,
diff --git a/addressbook/backend/ebook/e-book.h b/addressbook/backend/ebook/e-book.h
index 48756ff00c..ae4839ce29 100644
--- a/addressbook/backend/ebook/e-book.h
+++ b/addressbook/backend/ebook/e-book.h
@@ -14,21 +14,13 @@
#include <libgnome/gnome-defs.h>
#include <e-card.h>
-
-typedef struct _EBook EBook;
-
#include <e-card-cursor.h>
+#include <e-book-view.h>
+#include <e-book-types.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
-} EBookStatus;
-
+typedef struct _EBook EBook;
typedef struct _EBookClass EBookClass;
typedef struct _EBookPrivate EBookPrivate;
@@ -58,6 +50,7 @@ typedef void (*EBookOpenProgressCallback) (EBook *book,
gpointer closure);
typedef void (*EBookIdCallback) (EBook *book, EBookStatus status, const char *id, 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);
/* Creating a new addressbook. */
@@ -107,9 +100,15 @@ gboolean e_book_commit_vcard (EBook *book,
/* Checking to see if we're connected to the card repository. */
gboolean e_book_check_connection (EBook *book);
-gboolean e_book_get_all_cards (EBook *book,
+gboolean e_book_get_cursor (EBook *book,
+ char *query,
EBookCursorCallback cb,
- gpointer closure);
+ gpointer closure);
+
+gboolean e_book_get_book_view (EBook *book,
+ char *query,
+ EBookBookViewCallback cb,
+ gpointer closure);
/* Getting the name of the repository. */
char *e_book_get_name (EBook *book);
diff --git a/addressbook/backend/ebook/e-card-cursor.h b/addressbook/backend/ebook/e-card-cursor.h
index 3e9523e86f..664abfa268 100644
--- a/addressbook/backend/ebook/e-card-cursor.h
+++ b/addressbook/backend/ebook/e-card-cursor.h
@@ -13,13 +13,11 @@
#include <libgnome/gnome-defs.h>
#include <gtk/gtk.h>
#include "addressbook.h"
-
-typedef struct _ECardCursor ECardCursor;
-
-#include <e-book.h>
+#include "e-card.h"
BEGIN_GNOME_DECLS
+typedef struct _ECardCursor ECardCursor;
typedef struct _ECardCursorPrivate ECardCursorPrivate;
typedef struct _ECardCursorClass ECardCursorClass;
diff --git a/addressbook/backend/ebook/e-card.c b/addressbook/backend/ebook/e-card.c
index 1cd018f6f7..eb5c315b0f 100644
--- a/addressbook/backend/ebook/e-card.c
+++ b/addressbook/backend/ebook/e-card.c
@@ -115,8 +115,8 @@ e_card_get_type (void)
*
* Returns: a new #ECard that wraps the @vcard.
*/
-ECard
-*e_card_new (char *vcard)
+ECard *
+e_card_new (char *vcard)
{
ECard *card = E_CARD(gtk_type_new(e_card_get_type()));
VObject *vobj = Parse_MIME(vcard, strlen(vcard));
diff --git a/addressbook/backend/ebook/test-client-list.c b/addressbook/backend/ebook/test-client-list.c
index 0d65080c13..0679aec2fe 100644
--- a/addressbook/backend/ebook/test-client-list.c
+++ b/addressbook/backend/ebook/test-client-list.c
@@ -30,7 +30,7 @@ get_cursor_cb (EBook *book, EBookStatus status, ECardCursor *cursor, gpointer cl
long length = e_card_cursor_get_length(cursor);
long i;
- printf ("Length: %d\n", length);
+ 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(card);
@@ -38,14 +38,13 @@ get_cursor_cb (EBook *book, EBookStatus status, ECardCursor *cursor, gpointer cl
g_free(vcard);
gtk_object_unref(GTK_OBJECT(card));
}
- gtk_object_unref(GTK_OBJECT(cursor));
}
static void
book_open_cb (EBook *book, EBookStatus status, gpointer closure)
{
printf ("Book opened.\n");
- e_book_get_all_cards(book, get_cursor_cb, NULL);
+ e_book_get_cursor(book, "", get_cursor_cb, NULL);
}
static guint
diff --git a/addressbook/backend/ebook/test-client.c b/addressbook/backend/ebook/test-client.c
index ffe20ee030..f535d2db1a 100644
--- a/addressbook/backend/ebook/test-client.c
+++ b/addressbook/backend/ebook/test-client.c
@@ -67,7 +67,6 @@ get_cursor_cb (EBook *book, EBookStatus status, ECardCursor *cursor, gpointer cl
g_free(vcard);
gtk_object_unref(GTK_OBJECT(card));
}
- gtk_object_unref(GTK_OBJECT(cursor));
}
static void
@@ -93,7 +92,7 @@ add_card_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure)
gtk_object_unref(GTK_OBJECT(card));
printf ("Getting cards..\n");
- e_book_get_all_cards(book, get_cursor_cb, NULL);
+ e_book_get_cursor(book, "", get_cursor_cb, NULL);
printf ("Done getting all cards.\n");
}