aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
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
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')
-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
-rw-r--r--addressbook/backend/idl/addressbook.idl50
-rw-r--r--addressbook/backend/pas/Makefile.am10
-rw-r--r--addressbook/backend/pas/pas-backend-file.c69
-rw-r--r--addressbook/backend/pas/pas-book-view.c243
-rw-r--r--addressbook/backend/pas/pas-book-view.h49
-rw-r--r--addressbook/backend/pas/pas-book.c132
-rw-r--r--addressbook/backend/pas/pas-book.h70
21 files changed, 1502 insertions, 322 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");
}
diff --git a/addressbook/backend/idl/addressbook.idl b/addressbook/backend/idl/addressbook.idl
index 5fd0dbbf2e..44987a76fb 100644
--- a/addressbook/backend/idl/addressbook.idl
+++ b/addressbook/backend/idl/addressbook.idl
@@ -12,30 +12,62 @@
module Evolution {
typedef string CardId;
+ typedef string VCard;
+ typedef sequence<VCard> VCardList;
interface CardCursor : Bonobo::Unknown {
long get_length ();
string get_nth (in long n);
};
+ /*
+ * A book view is a live view of a book. It's either a view
+ * of all the cards in the book or a view of a query. When
+ * created, it will get a series of signal_card_added calls
+ * for all objects in the initial set. After that, it will
+ * get added, removed, or changed signals whenever the book
+ * changes (if it affects the set of viewed cards.)
+ */
+ interface BookViewListener : Bonobo::Unknown {
+ void signal_card_added (in VCardList cards);
+ void signal_card_removed (in CardId id);
+ void signal_card_changed (in VCardList cards);
+ };
+
+ interface BookView : Bonobo::Unknown {
+ };
+
interface Book : Bonobo::Unknown {
/*
* Fetching cards in the addresbook.
*/
- string get_vcard (in CardId id);
+ VCard get_vcard (in CardId id);
/*
* Adding and deleting cards in the book.
*/
- void create_card (in string vcard);
+ void create_card (in VCard vcard);
void remove_card (in CardId Id);
-
+
/*
* Modifying cards in the addressbook.
*/
- void modify_card (in string vcard);
-
- void get_all_cards ();
+ void modify_card (in VCard vcard);
+
+ /*
+ * These two functions return a cursor to the book
+ * listener. This is for people who want a snapshot
+ * of the addressbook. The syntax for the query
+ * string is not yet defined.
+ */
+ void get_cursor (in string query);
+
+ /*
+ * These two functions return a book view to the book
+ * listener. This is for people who want a live view
+ * of the addressbook.
+ */
+ void get_book_view(in BookViewListener listener, in string query);
void check_connection ();
@@ -63,6 +95,8 @@ module Evolution {
void respond_get_cursor (in CallStatus status, in CardCursor cursor);
+ void respond_get_view (in CallStatus status, in BookView view);
+
/**
* report_connection_status:
*
@@ -73,10 +107,6 @@ module Evolution {
* being asked.
*/
void report_connection_status (in boolean connected);
-
- void signal_card_added (in CardId id);
- void signal_card_removed (in CardId id);
- void signal_card_changed (in CardId id);
};
interface BookFactory : Bonobo::Unknown {
diff --git a/addressbook/backend/pas/Makefile.am b/addressbook/backend/pas/Makefile.am
index 3d3dd6f082..f2cf0ffef9 100644
--- a/addressbook/backend/pas/Makefile.am
+++ b/addressbook/backend/pas/Makefile.am
@@ -40,19 +40,21 @@ pas_libs = \
libpas_la_SOURCES = \
$(CORBA_SOURCE) \
- pas-book.c \
pas-book-factory.c \
- pas-backend.c \
+ pas-book-view.c \
+ pas-book.c \
pas-backend-file.c \
+ pas-backend.c \
pas-card-cursor.c
libpasincludedir = $(includedir)/backend
libpasinclude_HEADERS = \
- pas-book.h \
pas-book-factory.h \
- pas-backend.h \
+ pas-book-view.h \
+ pas-book.h \
pas-backend-file.h \
+ pas-backend.h \
pas-card-cursor.h
wombat_SOURCES = \
diff --git a/addressbook/backend/pas/pas-backend-file.c b/addressbook/backend/pas/pas-backend-file.c
index 0fd172c844..18b8de104e 100644
--- a/addressbook/backend/pas/pas-backend-file.c
+++ b/addressbook/backend/pas/pas-backend-file.c
@@ -119,7 +119,9 @@ pas_backend_file_process_create_card (PASBackend *backend,
db_error = db->put (db, &id_dbt, &vcard_dbt, 0);
if (0 == db_error) {
+#if 0
pas_book_notify_add(book, id);
+#endif
pas_book_respond_create (
book,
@@ -158,7 +160,9 @@ pas_backend_file_process_remove_card (PASBackend *backend,
db_error = db->del (db, &id_dbt, 0);
if (0 == db_error) {
+#if 0
pas_book_notify_remove (book, req->id);
+#endif
pas_book_respond_remove (
book,
@@ -193,8 +197,9 @@ pas_backend_file_process_modify_card (PASBackend *backend,
db_error = db->put (db, &id_dbt, &vcard_dbt, 0);
if (0 == db_error) {
-
+#if 0
pas_book_notify_change (book, req->id);
+#endif
pas_book_respond_modify (
book,
@@ -250,7 +255,57 @@ pas_backend_file_build_all_cards_list(PASBackend *backend,
}
static void
-pas_backend_file_process_get_all_cards (PASBackend *backend,
+pas_backend_file_process_get_cursor (PASBackend *backend,
+ PASBook *book,
+ PASRequest *req)
+{
+ /*
+ PASBackendFile *bf = PAS_BACKEND_FILE (backend);
+ DB *db = bf->priv->file_db;
+ DBT id_dbt, vcard_dbt;
+ */
+ CORBA_Environment ev;
+ int db_error = 0;
+ PASBackendFileCursorPrivate *cursor_data;
+ PASCardCursor *cursor;
+ Evolution_Book corba_book;
+
+ cursor_data = g_new(PASBackendFileCursorPrivate, 1);
+ cursor_data->backend = backend;
+ cursor_data->book = book;
+
+ pas_backend_file_build_all_cards_list(backend, cursor_data);
+
+ corba_book = bonobo_object_corba_objref(BONOBO_OBJECT(book));
+
+ CORBA_exception_init(&ev);
+
+ Evolution_Book_ref(corba_book, &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning("pas_backend_file_process_get_cursor: Exception reffing "
+ "corba book.\n");
+ }
+
+ CORBA_exception_free(&ev);
+
+ cursor = pas_card_cursor_new(get_length,
+ get_nth,
+ cursor_data);
+
+ gtk_signal_connect(GTK_OBJECT(cursor), "destroy",
+ GTK_SIGNAL_FUNC(cursor_destroy), cursor_data);
+
+ pas_book_respond_get_cursor (
+ book,
+ (db_error == 0
+ ? Evolution_BookListener_Success
+ : Evolution_BookListener_CardNotFound),
+ cursor);
+}
+
+static void
+pas_backend_file_process_get_book_view (PASBackend *backend,
PASBook *book,
PASRequest *req)
{
@@ -278,7 +333,7 @@ pas_backend_file_process_get_all_cards (PASBackend *backend,
Evolution_Book_ref(corba_book, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning("pas_backend_file_process_get_all_cards: Exception reffing "
+ g_warning("pas_backend_file_process_get_book_view: Exception reffing "
"corba book.\n");
}
@@ -338,8 +393,12 @@ pas_backend_file_process_client_requests (PASBook *book)
pas_backend_file_process_check_connection (backend, book, req);
break;
- case GetAllCards:
- pas_backend_file_process_get_all_cards (backend, book, req);
+ case GetCursor:
+ pas_backend_file_process_get_cursor (backend, book, req);
+ break;
+
+ case GetBookView:
+ pas_backend_file_process_get_book_view (backend, book, req);
break;
}
diff --git a/addressbook/backend/pas/pas-book-view.c b/addressbook/backend/pas/pas-book-view.c
new file mode 100644
index 0000000000..fc706bc897
--- /dev/null
+++ b/addressbook/backend/pas/pas-book-view.c
@@ -0,0 +1,243 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * pas-book-view.c
+ *
+ * Copyright 2000, Helix Code, Inc.
+ */
+
+#include <glib.h>
+#include "pas-book-view.h"
+
+static BonoboObjectClass *pas_book_view_parent_class;
+POA_Evolution_BookView__vepv pas_book_view_vepv;
+
+struct _PASBookViewPrivate {
+ Evolution_BookViewListener listener;
+};
+
+/**
+ * pas_book_view_notify_change:
+ */
+void
+pas_book_view_notify_change (PASBookView *book_view,
+ const GList *cards)
+{
+ CORBA_Environment ev;
+ gint i, length;
+ CORBA_sequence_Evolution_VCard card_sequence;
+
+ length = g_list_length((GList *) cards);
+
+ card_sequence._buffer = CORBA_sequence_Evolution_VCard_allocbuf(length);
+ card_sequence._maximum = length;
+ card_sequence._length = length;
+
+ for ( i = 0; cards; cards = g_list_next(cards), i++ ) {
+ card_sequence._buffer[i] = (char *) cards->data;
+ }
+
+ CORBA_exception_init (&ev);
+
+ Evolution_BookViewListener_signal_card_changed (
+ book_view->priv->listener, &card_sequence, &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("pas_book_view_notify_change: Exception signaling BookListener!\n");
+ }
+
+ CORBA_exception_free (&ev);
+
+ CORBA_free(card_sequence._buffer);
+}
+
+/**
+ * pas_book_view_notify_remove:
+ */
+void
+pas_book_view_notify_remove (PASBookView *book_view,
+ const char *id)
+{
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+
+ Evolution_BookViewListener_signal_card_removed (
+ book_view->priv->listener, (Evolution_CardId) id, &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("pas_book_view_notify_remove: Exception signaling BookListener!\n");
+ }
+
+ CORBA_exception_free (&ev);
+}
+
+/**
+ * pas_book_view_notify_add:
+ */
+void
+pas_book_view_notify_add (PASBookView *book_view,
+ const GList *cards)
+{
+ CORBA_Environment ev;
+ gint i, length;
+ CORBA_sequence_Evolution_VCard card_sequence;
+
+ length = g_list_length((GList *)cards);
+
+ card_sequence._buffer = CORBA_sequence_Evolution_VCard_allocbuf(length);
+ card_sequence._maximum = length;
+ card_sequence._length = length;
+
+ for ( i = 0; cards; cards = g_list_next(cards), i++ ) {
+ card_sequence._buffer[i] = (char *) cards->data;
+ }
+
+ CORBA_exception_init (&ev);
+
+ Evolution_BookViewListener_signal_card_added (
+ book_view->priv->listener, &card_sequence, &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("pas_book_view_notify_add: Exception signaling BookListener!\n");
+ }
+
+ CORBA_exception_free (&ev);
+
+ CORBA_free(card_sequence._buffer);
+}
+
+static gboolean
+pas_book_view_construct (PASBookView *book_view,
+ Evolution_BookViewListener listener)
+{
+ POA_Evolution_BookView *servant;
+ CORBA_Environment ev;
+ CORBA_Object obj;
+
+ g_assert (book_view != NULL);
+ g_assert (PAS_IS_BOOK_VIEW (book_view));
+ g_assert (listener != CORBA_OBJECT_NIL);
+
+ servant = (POA_Evolution_BookView *) g_new0 (BonoboObjectServant, 1);
+ servant->vepv = &pas_book_view_vepv;
+
+ CORBA_exception_init (&ev);
+
+ POA_Evolution_BookView__init ((PortableServer_Servant) servant, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_free (servant);
+ CORBA_exception_free (&ev);
+
+ return FALSE;
+ }
+
+ CORBA_exception_free (&ev);
+
+ obj = bonobo_object_activate_servant (BONOBO_OBJECT (book_view), servant);
+ if (obj == CORBA_OBJECT_NIL) {
+ g_free (servant);
+
+ return FALSE;
+ }
+
+ bonobo_object_construct (BONOBO_OBJECT (book_view), obj);
+
+ book_view->priv->listener = listener;
+
+ return TRUE;
+}
+
+/**
+ * pas_book_view_new:
+ */
+PASBookView *
+pas_book_view_new (Evolution_BookViewListener listener)
+{
+ PASBookView *book_view;
+
+ g_return_val_if_fail (listener != CORBA_OBJECT_NIL, NULL);
+
+ book_view = gtk_type_new (pas_book_view_get_type ());
+
+ if (! pas_book_view_construct (book_view, listener)) {
+ gtk_object_unref (GTK_OBJECT (book_view));
+
+ return NULL;
+ }
+
+ return book_view;
+}
+
+static void
+pas_book_view_destroy (GtkObject *object)
+{
+ PASBookView *book_view = PAS_BOOK_VIEW (object);
+
+ g_free (book_view->priv);
+
+ GTK_OBJECT_CLASS (pas_book_view_parent_class)->destroy (object);
+}
+
+static POA_Evolution_BookView__epv *
+pas_book_view_get_epv (void)
+{
+ POA_Evolution_BookView__epv *epv;
+
+ epv = g_new0 (POA_Evolution_BookView__epv, 1);
+
+ return epv;
+
+}
+
+static void
+pas_book_view_corba_class_init (void)
+{
+ pas_book_view_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv ();
+ pas_book_view_vepv.Evolution_BookView_epv = pas_book_view_get_epv ();
+}
+
+static void
+pas_book_view_class_init (PASBookViewClass *klass)
+{
+ GtkObjectClass *object_class = (GtkObjectClass *) klass;
+
+ pas_book_view_parent_class = gtk_type_class (bonobo_object_get_type ());
+
+ object_class->destroy = pas_book_view_destroy;
+
+ pas_book_view_corba_class_init ();
+}
+
+static void
+pas_book_view_init (PASBookView *book_view)
+{
+ book_view->priv = g_new0 (PASBookViewPrivate, 1);
+ book_view->priv->listener = CORBA_OBJECT_NIL;
+}
+
+/**
+ * pas_book_view_get_type:
+ */
+GtkType
+pas_book_view_get_type (void)
+{
+ static GtkType type = 0;
+
+ if (! type) {
+ GtkTypeInfo info = {
+ "PASBookView",
+ sizeof (PASBookView),
+ sizeof (PASBookViewClass),
+ (GtkClassInitFunc) pas_book_view_class_init,
+ (GtkObjectInitFunc) pas_book_view_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/pas/pas-book-view.h b/addressbook/backend/pas/pas-book-view.h
new file mode 100644
index 0000000000..b742b2ba1a
--- /dev/null
+++ b/addressbook/backend/pas/pas-book-view.h
@@ -0,0 +1,49 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * A wrapper object which exports the Evolution_Book CORBA interface
+ * and which maintains a request queue.
+ *
+ * Author:
+ * Nat Friedman (nat@helixcode.com)
+ *
+ * Copyright 2000, Helix Code, Inc.
+ */
+
+#ifndef __PAS_BOOK_VIEW_H__
+#define __PAS_BOOK_VIEW_H__
+
+#include <bonobo/bonobo-object.h>
+#include <libgnome/gnome-defs.h>
+#include <addressbook.h>
+
+typedef struct _PASBookView PASBookView;
+typedef struct _PASBookViewClass PASBookViewClass;
+typedef struct _PASBookViewPrivate PASBookViewPrivate;
+
+struct _PASBookView {
+ BonoboObject parent_object;
+ PASBookViewPrivate *priv;
+};
+
+struct _PASBookViewClass {
+ BonoboObjectClass parent_class;
+};
+
+PASBookView *pas_book_view_new (Evolution_BookViewListener listener);
+
+void pas_book_view_notify_change (PASBookView *book_view,
+ const GList *cards);
+void pas_book_view_notify_remove (PASBookView *book_view,
+ const char *id);
+void pas_book_view_notify_add (PASBookView *book_view,
+ const GList *cards);
+
+GtkType pas_book_view_get_type (void);
+
+#define PAS_BOOK_VIEW_TYPE (pas_book_view_get_type ())
+#define PAS_BOOK_VIEW(o) (GTK_CHECK_CAST ((o), PAS_BOOK_VIEW_TYPE, PASBookView))
+#define PAS_BOOK_VIEW_CLASS(k) (GTK_CHECK_CLASS_CAST((k), PAS_BOOK_VIEW_FACTORY_TYPE, PASBookViewClass))
+#define PAS_IS_BOOK_VIEW(o) (GTK_CHECK_TYPE ((o), PAS_BOOK_VIEW_TYPE))
+#define PAS_IS_BOOK_VIEW_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), PAS_BOOK_VIEW_TYPE))
+
+#endif /* ! __PAS_BOOK_VIEW_H__ */
diff --git a/addressbook/backend/pas/pas-book.c b/addressbook/backend/pas/pas-book.c
index f571bc4044..47e5508654 100644
--- a/addressbook/backend/pas/pas-book.c
+++ b/addressbook/backend/pas/pas-book.c
@@ -91,12 +91,37 @@ pas_book_queue_modify_card (PASBook *book, const char *vcard)
}
static void
-pas_book_queue_get_all_cards (PASBook *book)
+pas_book_queue_get_cursor (PASBook *book, const char *search)
{
PASRequest *req;
- req = g_new0 (PASRequest, 1);
- req->op = GetAllCards;
+ req = g_new0 (PASRequest, 1);
+ req->op = GetCursor;
+ req->search = g_strdup(search);
+
+ pas_book_queue_request (book, req);
+}
+
+static void
+pas_book_queue_get_book_view (PASBook *book, const Evolution_BookViewListener listener, const char *search)
+{
+ PASRequest *req;
+ CORBA_Environment ev;
+
+ req = g_new0 (PASRequest, 1);
+ req->op = GetBookView;
+ req->search = g_strdup(search);
+
+ CORBA_exception_init (&ev);
+
+ req->listener = CORBA_Object_duplicate(listener, &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("pas_book_queue_get_book_view: Exception "
+ "duplicating BookViewListener!\n");
+ }
+
+ CORBA_exception_free (&ev);
pas_book_queue_request (book, req);
}
@@ -130,12 +155,12 @@ impl_Evolution_Book_get_vcard (PortableServer_Servant servant,
static void
impl_Evolution_Book_create_card (PortableServer_Servant servant,
- const CORBA_char *vcard,
+ const Evolution_VCard vcard,
CORBA_Environment *ev)
{
PASBook *book = PAS_BOOK (bonobo_object_from_servant (servant));
- pas_book_queue_create_card (book, vcard);
+ pas_book_queue_create_card (book, (const char *) vcard);
}
static void
@@ -150,21 +175,33 @@ impl_Evolution_Book_remove_card (PortableServer_Servant servant,
static void
impl_Evolution_Book_modify_card (PortableServer_Servant servant,
- const CORBA_char *vcard,
+ const Evolution_VCard vcard,
CORBA_Environment *ev)
{
PASBook *book = PAS_BOOK (bonobo_object_from_servant (servant));
- pas_book_queue_modify_card (book, vcard);
+ pas_book_queue_modify_card (book, (const char *) vcard);
}
static void
-impl_Evolution_Book_get_all_cards (PortableServer_Servant servant,
- CORBA_Environment *ev)
+impl_Evolution_Book_get_cursor (PortableServer_Servant servant,
+ const CORBA_char *search,
+ CORBA_Environment *ev)
{
PASBook *book = PAS_BOOK (bonobo_object_from_servant (servant));
- pas_book_queue_get_all_cards (book);
+ pas_book_queue_get_cursor (book, search);
+}
+
+static void
+impl_Evolution_Book_get_book_view (PortableServer_Servant servant,
+ const Evolution_BookViewListener listener,
+ const CORBA_char *search,
+ CORBA_Environment *ev)
+{
+ PASBook *book = PAS_BOOK (bonobo_object_from_servant (servant));
+
+ pas_book_queue_get_book_view (book, listener, search);
}
static void
@@ -363,86 +400,48 @@ pas_book_respond_get_cursor (PASBook *book,
}
/**
- * pas_book_report_connection:
+ * pas_book_respond_get_cursor:
*/
void
-pas_book_report_connection (PASBook *book,
- gboolean connected)
+pas_book_respond_get_book_view (PASBook *book,
+ Evolution_BookListener_CallStatus status,
+ PASBookView *book_view)
{
CORBA_Environment ev;
+ CORBA_Object object;
CORBA_exception_init (&ev);
+
+ object = bonobo_object_corba_objref(BONOBO_OBJECT(book_view));
- Evolution_BookListener_report_connection_status (
- book->priv->listener, (CORBA_boolean) connected, &ev);
+ Evolution_BookListener_respond_get_view (
+ book->priv->listener, status, object, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("pas_book_report_connection: Exception "
+ g_warning ("pas_book_respond_get_cursor: Exception "
"responding to BookListener!\n");
}
CORBA_exception_free (&ev);
}
-
-/**
- * pas_book_notify_change:
- */
-void
-pas_book_notify_change (PASBook *book,
- const char *id)
-{
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- Evolution_BookListener_signal_card_changed (
- book->priv->listener, (Evolution_CardId) id, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("pas_book_notify_change: Exception signaling BookListener!\n");
- }
-
- CORBA_exception_free (&ev);
-}
-
/**
- * pas_book_notify_remove:
- */
-void
-pas_book_notify_remove (PASBook *book,
- const char *id)
-{
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- Evolution_BookListener_signal_card_removed (
- book->priv->listener, (Evolution_CardId) id, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("pas_book_notify_remove: Exception signaling BookListener!\n");
- }
-
- CORBA_exception_free (&ev);
-}
-
-/**
- * pas_book_notify_add:
+ * pas_book_report_connection:
*/
void
-pas_book_notify_add (PASBook *book,
- const char *id)
+pas_book_report_connection (PASBook *book,
+ gboolean connected)
{
CORBA_Environment ev;
CORBA_exception_init (&ev);
- Evolution_BookListener_signal_card_added (
- book->priv->listener, (Evolution_CardId) id, &ev);
+ Evolution_BookListener_report_connection_status (
+ book->priv->listener, (CORBA_boolean) connected, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("pas_book_notify_add: Exception signaling BookListener!\n");
+ g_warning ("pas_book_report_connection: Exception "
+ "responding to BookListener!\n");
}
CORBA_exception_free (&ev);
@@ -550,7 +549,8 @@ pas_book_get_epv (void)
epv->remove_card = impl_Evolution_Book_remove_card;
epv->modify_card = impl_Evolution_Book_modify_card;
epv->check_connection = impl_Evolution_Book_check_connection;
- epv->get_all_cards = impl_Evolution_Book_get_all_cards;
+ epv->get_cursor = impl_Evolution_Book_get_cursor;
+ epv->get_book_view = impl_Evolution_Book_get_book_view;
return epv;
diff --git a/addressbook/backend/pas/pas-book.h b/addressbook/backend/pas/pas-book.h
index ab0dced4e4..8d92f6a266 100644
--- a/addressbook/backend/pas/pas-book.h
+++ b/addressbook/backend/pas/pas-book.h
@@ -15,6 +15,7 @@
#include <bonobo/bonobo-object.h>
#include <libgnome/gnome-defs.h>
#include <addressbook.h>
+#include <pas-book-view.h>
typedef struct _PASBook PASBook;
typedef struct _PASBookPrivate PASBookPrivate;
@@ -26,14 +27,17 @@ typedef enum {
CreateCard,
RemoveCard,
ModifyCard,
- GetAllCards,
+ GetCursor,
+ GetBookView,
CheckConnection
} PASOperation;
typedef struct {
- PASOperation op;
- char *id;
- char *vcard;
+ PASOperation op;
+ char *id;
+ char *vcard;
+ char *search;
+ Evolution_BookViewListener listener;
} PASRequest;
struct _PASBook {
@@ -50,37 +54,33 @@ typedef struct {
typedef char * (*PASBookGetVCardFn) (PASBook *book, const char *id);
-PASBook *pas_book_new (PASBackend *backend,
- Evolution_BookListener listener,
- PASBookGetVCardFn get_vcard);
-PASBackend *pas_book_get_backend (PASBook *book);
-Evolution_BookListener pas_book_get_listener (PASBook *book);
-int pas_book_check_pending (PASBook *book);
-PASRequest *pas_book_pop_request (PASBook *book);
-
-void pas_book_respond_open (PASBook *book,
- Evolution_BookListener_CallStatus status);
-void pas_book_respond_create (PASBook *book,
- Evolution_BookListener_CallStatus status,
- const char *id);
-void pas_book_respond_remove (PASBook *book,
- Evolution_BookListener_CallStatus status);
-void pas_book_respond_modify (PASBook *book,
- Evolution_BookListener_CallStatus status);
-void pas_book_respond_get_cursor (PASBook *book,
- Evolution_BookListener_CallStatus status,
- PASCardCursor *cursor);
-void pas_book_report_connection (PASBook *book,
- gboolean connected);
-
-void pas_book_notify_change (PASBook *book,
- const char *id);
-void pas_book_notify_remove (PASBook *book,
- const char *id);
-void pas_book_notify_add (PASBook *book,
- const char *id);
-
-GtkType pas_book_get_type (void);
+PASBook *pas_book_new (PASBackend *backend,
+ Evolution_BookListener listener,
+ PASBookGetVCardFn get_vcard);
+PASBackend *pas_book_get_backend (PASBook *book);
+Evolution_BookListener pas_book_get_listener (PASBook *book);
+int pas_book_check_pending (PASBook *book);
+PASRequest *pas_book_pop_request (PASBook *book);
+
+void pas_book_respond_open (PASBook *book,
+ Evolution_BookListener_CallStatus status);
+void pas_book_respond_create (PASBook *book,
+ Evolution_BookListener_CallStatus status,
+ const char *id);
+void pas_book_respond_remove (PASBook *book,
+ Evolution_BookListener_CallStatus status);
+void pas_book_respond_modify (PASBook *book,
+ Evolution_BookListener_CallStatus status);
+void pas_book_respond_get_cursor (PASBook *book,
+ Evolution_BookListener_CallStatus status,
+ PASCardCursor *cursor);
+void pas_book_respond_get_book_view (PASBook *book,
+ Evolution_BookListener_CallStatus status,
+ PASBookView *book_view);
+void pas_book_report_connection (PASBook *book,
+ gboolean connected);
+
+GtkType pas_book_get_type (void);
#define PAS_BOOK_TYPE (pas_book_get_type ())
#define PAS_BOOK(o) (GTK_CHECK_CAST ((o), PAS_BOOK_TYPE, PASBook))