aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/backend/pas/pas-book-view.c
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/pas/pas-book-view.c
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/pas/pas-book-view.c')
-rw-r--r--addressbook/backend/pas/pas-book-view.c243
1 files changed, 243 insertions, 0 deletions
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;
+}
+