aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/backend/ebook
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-03-28 11:52:46 +0800
committerChris Lahey <clahey@src.gnome.org>2000-03-28 11:52:46 +0800
commit21e60e238477edd1ad157bd17024d5ea6395e048 (patch)
tree4f251e318f085aecc387c49f052a14f7874c1a1a /addressbook/backend/ebook
parentbd46ea2926e3f244d6d875195363d261f53a4e07 (diff)
downloadgsoc2013-evolution-21e60e238477edd1ad157bd17024d5ea6395e048.tar
gsoc2013-evolution-21e60e238477edd1ad157bd17024d5ea6395e048.tar.gz
gsoc2013-evolution-21e60e238477edd1ad157bd17024d5ea6395e048.tar.bz2
gsoc2013-evolution-21e60e238477edd1ad157bd17024d5ea6395e048.tar.lz
gsoc2013-evolution-21e60e238477edd1ad157bd17024d5ea6395e048.tar.xz
gsoc2013-evolution-21e60e238477edd1ad157bd17024d5ea6395e048.tar.zst
gsoc2013-evolution-21e60e238477edd1ad157bd17024d5ea6395e048.zip
Fixed some warnings.
2000-03-27 Christopher James Lahey <clahey@helixcode.com> * addressbook/backend/ebook/test-card.c: Fixed some warnings. * addressbook/backend/ebook/test-client.c: Added a section to test cursors and returning an id when adding. * addressbook/backend/ebook/e-card-pairs.h: Removed the address pairs since they were added to e-card.c. * addressbook/backend/ebook/e-card.c, addressbook/backend/ebook/e-card.h: Made the set_id function take a const char *. * 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/idl/addressbook.idl, addressbook/backend/pas/pas-backend-file.c, addressbook/backend/pas/pas-book.c, addressbook/backend/pas/pas-book.h: Added a get_all_cards function and made the response to the create_card function include the card id. * addressbook/backend/ebook/Makefile.am: Added e-card-cursor.c and e-card-cursor.h. * addressbook/backend/ebook/e-card-cursor.c, addressbook/backend/ebook/e-card-cursor.h: New class for proxying to an Evolution_CardCursor. * addressbook/backend/pas/Makefile.am: Added pas-card-cursor.c and pas-card-cursor.h. * addressbook/backend/pas/pas-card-cursor.c, addressbook/backend/pas/pas-card-cursor.h: New bonobo class for making an Evolution_CardCursor server. svn path=/trunk/; revision=2205
Diffstat (limited to 'addressbook/backend/ebook')
-rw-r--r--addressbook/backend/ebook/Makefile.am2
-rw-r--r--addressbook/backend/ebook/e-book-listener.c71
-rw-r--r--addressbook/backend/ebook/e-book-listener.h5
-rw-r--r--addressbook/backend/ebook/e-book.c121
-rw-r--r--addressbook/backend/ebook/e-book.h36
-rw-r--r--addressbook/backend/ebook/e-card-cursor.c196
-rw-r--r--addressbook/backend/ebook/e-card-cursor.h33
-rw-r--r--addressbook/backend/ebook/e-card-pairs.h9
-rw-r--r--addressbook/backend/ebook/e-card.c2
-rw-r--r--addressbook/backend/ebook/e-card.h2
-rw-r--r--addressbook/backend/ebook/test-card.c2
-rw-r--r--addressbook/backend/ebook/test-client.c31
12 files changed, 455 insertions, 55 deletions
diff --git a/addressbook/backend/ebook/Makefile.am b/addressbook/backend/ebook/Makefile.am
index 84b85a8099..5619e9ca84 100644
--- a/addressbook/backend/ebook/Makefile.am
+++ b/addressbook/backend/ebook/Makefile.am
@@ -42,6 +42,7 @@ libebook_la_SOURCES = \
$(CORBA_SOURCE) \
e-book-listener.c \
e-book.c \
+ e-card-cursor.c \
e-card.c
libebookincludedir = $(includedir)/backend
@@ -49,6 +50,7 @@ libebookincludedir = $(includedir)/backend
libebookinclude_HEADERS = \
e-book.h \
e-book-listener.h \
+ e-card-cursor.h \
e-card.h
test_client_SOURCES = \
diff --git a/addressbook/backend/ebook/e-book-listener.c b/addressbook/backend/ebook/e-book-listener.c
index 107f71fedc..826a070148 100644
--- a/addressbook/backend/ebook/e-book-listener.c
+++ b/addressbook/backend/ebook/e-book-listener.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Exports the BookListener interface. Maintains a queue of messages
* which come in on the interface.
@@ -109,6 +110,38 @@ e_book_listener_queue_open_progress (EBookListener *listener,
static void
+e_book_listener_queue_create_card_response (EBookListener *listener,
+ EBookStatus status,
+ const char *id)
+{
+ EBookListenerResponse *resp;
+
+ resp = g_new0 (EBookListenerResponse, 1);
+
+ resp->op = CreateCardResponse;
+ resp->status = status;
+ resp->id = g_strdup (id);
+
+ e_book_listener_queue_response (listener, resp);
+}
+
+static void
+e_book_listener_queue_get_cursor_response (EBookListener *listener,
+ EBookStatus status,
+ Evolution_CardCursor cursor)
+{
+ EBookListenerResponse *resp;
+
+ resp = g_new0 (EBookListenerResponse, 1);
+
+ resp->op = GetCursorResponse;
+ resp->status = status;
+ resp->cursor = cursor;
+
+ e_book_listener_queue_response (listener, resp);
+}
+
+static void
e_book_listener_queue_link_status (EBookListener *listener,
gboolean connected)
{
@@ -139,15 +172,17 @@ e_book_listener_queue_generic_event (EBookListener *listener,
}
static void
-impl_BookListener_respond_create_card (PortableServer_Servant servant,
- const Evolution_BookListener_CallStatus status,
- CORBA_Environment *ev)
+impl_BookListener_respond_create_card (PortableServer_Servant servant,
+ const Evolution_BookListener_CallStatus status,
+ const Evolution_CardId id,
+ CORBA_Environment *ev)
{
EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant));
- e_book_listener_queue_generic_response (
- listener, CreateCardResponse,
- e_book_listener_convert_status (status));
+ e_book_listener_queue_create_card_response (
+ listener,
+ e_book_listener_convert_status (status),
+ id);
}
static void
@@ -175,6 +210,28 @@ impl_BookListener_respond_modify_card (PortableServer_Servant servant,
}
static void
+impl_BookListener_respond_get_cursor (PortableServer_Servant servant,
+ const Evolution_BookListener_CallStatus status,
+ const Evolution_CardCursor cursor,
+ CORBA_Environment *ev)
+{
+ EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant));
+ Evolution_CardCursor cursor_copy;
+
+ cursor_copy = CORBA_Object_duplicate (cursor, ev);
+
+ if (ev->_major != CORBA_NO_EXCEPTION) {
+ g_warning ("EBookListener: Exception while duplicating CardCursor!\n");
+ return;
+ }
+
+ e_book_listener_queue_get_cursor_response (
+ listener,
+ e_book_listener_convert_status (status),
+ cursor_copy);
+}
+
+static void
impl_BookListener_respond_open_book (PortableServer_Servant servant,
const Evolution_BookListener_CallStatus status,
const Evolution_Book book,
@@ -446,6 +503,8 @@ e_book_listener_get_epv (void)
epv->respond_remove_card = impl_BookListener_respond_remove_card;
epv->respond_modify_card = impl_BookListener_respond_modify_card;
+ epv->respond_get_cursor = impl_BookListener_respond_get_cursor;
+
epv->report_connection_status = impl_BookListener_report_connection_status;
epv->signal_card_changed = impl_BookListener_signal_card_changed;
diff --git a/addressbook/backend/ebook/e-book-listener.h b/addressbook/backend/ebook/e-book-listener.h
index 62ff8a3e09..27dd0df10f 100644
--- a/addressbook/backend/ebook/e-book-listener.h
+++ b/addressbook/backend/ebook/e-book-listener.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* A client-side GtkObject which exposes the
* Evolution:BookListener interface.
@@ -40,6 +41,7 @@ typedef enum {
CreateCardResponse,
RemoveCardResponse,
ModifyCardResponse,
+ GetCursorResponse,
/* Async events */
CardAddedEvent,
@@ -58,6 +60,9 @@ typedef struct {
/* For OpenBookResponse */
Evolution_Book book;
+ /* For GetCursorResponse */
+ Evolution_CardCursor cursor;
+
/* For OpenProgressEvent */
char *msg;
short percent;
diff --git a/addressbook/backend/ebook/e-book.c b/addressbook/backend/ebook/e-book.c
index b3c2e12b57..e95ff8f751 100644
--- a/addressbook/backend/ebook/e-book.c
+++ b/addressbook/backend/ebook/e-book.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* The Evolution addressbook client object.
*
@@ -97,6 +98,25 @@ e_book_pop_op (EBook *book)
}
static void
+e_book_do_response_create_card (EBook *book,
+ EBookListenerResponse *resp)
+{
+ EBookOp *op;
+
+ op = e_book_pop_op (book);
+
+ if (op == NULL) {
+ g_warning ("e_book_do_response_create_card: Cannot find operation "
+ "in local op queue!\n");
+ return;
+ }
+
+ ((EBookIdCallback) op->cb) (book, resp->status, resp->id, op->closure);
+ g_free (resp->id);
+ g_free (op);
+}
+
+static void
e_book_do_response_generic (EBook *book,
EBookListenerResponse *resp)
{
@@ -115,6 +135,52 @@ e_book_do_response_generic (EBook *book,
}
static void
+e_book_do_response_get_cursor (EBook *book,
+ EBookListenerResponse *resp)
+{
+ CORBA_Environment ev;
+ EBookOp *op;
+ ECardCursor *cursor;
+
+ op = e_book_pop_op (book);
+
+ if (op == NULL) {
+ g_warning ("e_book_do_response_create_card: Cannot find operation "
+ "in local op queue!\n");
+ return;
+ }
+
+ cursor = e_card_cursor_new(resp->cursor);
+
+ ((EBookCursorCallback) op->cb) (book, resp->status, cursor, op->closure);
+
+ /*
+ * Release the remote Evolution_Book in the PAS.
+ */
+ CORBA_exception_init (&ev);
+
+ Bonobo_Unknown_unref (resp->cursor, &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("e_book_do_response_get_curosr: Exception unref'ing "
+ "remote Evolution_CardCursor interface!\n");
+ CORBA_exception_free (&ev);
+ CORBA_exception_init (&ev);
+ }
+
+ CORBA_Object_release (resp->cursor, &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("e_book_do_response_get_cursor: Exception releasing "
+ "remote Evolution_CardCursor interface!\n");
+ }
+
+ CORBA_exception_free (&ev);
+
+ g_free (op);
+}
+
+static void
e_book_do_response_open (EBook *book,
EBookListenerResponse *resp)
{
@@ -205,10 +271,15 @@ e_book_check_listener_queue (EBookListener *listener)
switch (resp->op) {
case CreateCardResponse:
+ e_book_do_response_create_card (book, resp);
+ break;
case RemoveCardResponse:
case ModifyCardResponse:
e_book_do_response_generic (book, resp);
break;
+ case GetCursorResponse:
+ e_book_do_response_get_cursor (book, resp);
+ break;
case OpenBookResponse:
e_book_do_response_open (book, resp);
break;
@@ -541,10 +612,10 @@ e_book_remove_card_by_id (EBook *book,
* e_book_add_card:
*/
gboolean
-e_book_add_card (EBook *book,
- ECard *card,
- EBookCallback cb,
- gpointer closure)
+e_book_add_card (EBook *book,
+ ECard *card,
+ EBookIdCallback cb,
+ gpointer closure)
{
char *vcard;
@@ -579,10 +650,10 @@ e_book_add_card (EBook *book,
* e_book_add_vcard:
*/
gboolean
-e_book_add_vcard (EBook *book,
- const char *vcard,
- EBookCallback cb,
- gpointer closure)
+e_book_add_vcard (EBook *book,
+ const char *vcard,
+ EBookIdCallback cb,
+ gpointer closure)
{
CORBA_Environment ev;
@@ -609,7 +680,7 @@ e_book_add_vcard (EBook *book,
CORBA_exception_free (&ev);
- e_book_queue_op (book, cb, closure);
+ e_book_queue_op (book, (EBookCallback) cb, closure);
return TRUE;
}
@@ -726,6 +797,38 @@ e_book_check_connection (EBook *book)
return TRUE;
}
+gboolean e_book_get_all_cards (EBook *book,
+ EBookCursorCallback cb,
+ gpointer closure)
+{
+ CORBA_Environment ev;
+
+ g_return_val_if_fail (book != NULL, FALSE);
+ g_return_val_if_fail (E_IS_BOOK (book), FALSE);
+
+ if (book->priv->load_state != URILoaded) {
+ g_warning ("e_book_check_connection: No URI loaded!\n");
+ return FALSE;
+ }
+
+ CORBA_exception_init (&ev);
+
+ Evolution_Book_get_all_cards (book->priv->corba_book, &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("e_book_get_all_cards: Exception "
+ "querying list of cards!\n");
+ CORBA_exception_free (&ev);
+ return FALSE;
+ }
+
+ CORBA_exception_free (&ev);
+
+ e_book_queue_op (book, cb, closure);
+
+ return TRUE;
+}
+
/**
* e_book_get_name:
*/
diff --git a/addressbook/backend/ebook/e-book.h b/addressbook/backend/ebook/e-book.h
index 8a3fb311c1..48756ff00c 100644
--- a/addressbook/backend/ebook/e-book.h
+++ b/addressbook/backend/ebook/e-book.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* The Evolution addressbook client object.
*
@@ -14,6 +15,10 @@
#include <e-card.h>
+typedef struct _EBook EBook;
+
+#include <e-card-cursor.h>
+
BEGIN_GNOME_DECLS
typedef enum {
@@ -24,14 +29,15 @@ typedef enum {
E_BOOK_STATUS_CARD_NOT_FOUND
} EBookStatus;
+typedef struct _EBookClass EBookClass;
typedef struct _EBookPrivate EBookPrivate;
-typedef struct {
+struct _EBook {
GtkObject parent;
EBookPrivate *priv;
-} EBook;
+};
-typedef struct {
+struct _EBookClass {
GtkObjectClass parent;
/*
@@ -42,7 +48,7 @@ typedef struct {
void (* card_changed) (const char *id);
void (* card_removed) (const char *id);
void (* card_added) (const char *id);
-} EBookClass;
+};
/* Callbacks for asynchronous functions. */
typedef void (*EBookCallback) (EBook *book, EBookStatus status, gpointer closure);
@@ -50,6 +56,8 @@ typedef void (*EBookOpenProgressCallback) (EBook *book,
const char *status_message,
short percent,
gpointer closure);
+typedef void (*EBookIdCallback) (EBook *book, EBookStatus status, const char *id, gpointer closure);
+typedef void (*EBookCursorCallback) (EBook *book, EBookStatus status, ECardCursor *cursor, gpointer closure);
/* Creating a new addressbook. */
@@ -77,14 +85,14 @@ gboolean e_book_remove_card_by_id (EBook *book,
gpointer closure);
/* Adding cards. */
-gboolean e_book_add_card (EBook *book,
- ECard *card,
- EBookCallback cb,
- gpointer closure);
-gboolean e_book_add_vcard (EBook *book,
- const char *vcard,
- EBookCallback cb,
- gpointer closure);
+gboolean e_book_add_card (EBook *book,
+ ECard *card,
+ EBookIdCallback cb,
+ gpointer closure);
+gboolean e_book_add_vcard (EBook *book,
+ const char *vcard,
+ EBookIdCallback cb,
+ gpointer closure);
/* Modifying cards. */
gboolean e_book_commit_card (EBook *book,
@@ -99,6 +107,10 @@ 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,
+ EBookCursorCallback 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.c b/addressbook/backend/ebook/e-card-cursor.c
new file mode 100644
index 0000000000..7a51698d54
--- /dev/null
+++ b/addressbook/backend/ebook/e-card-cursor.c
@@ -0,0 +1,196 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * e-card-cursor.c: Implements card cursors.
+ *
+ * Author:
+ * Christopher James Lahey <clahey@helixcode.com.
+ */
+
+#include <config.h>
+#include <bonobo.h>
+#include "addressbook.h"
+#include "e-card-cursor.h"
+
+struct _ECardCursorPrivate {
+ Evolution_CardCursor corba_cursor;
+};
+
+/*
+ * A pointer to our parent object class
+ */
+static GtkObjectClass *parent_class;
+
+/*
+ * Implemented GtkObject::destroy
+ */
+static void
+e_card_cursor_destroy (GtkObject *object)
+{
+ ECardCursor *cursor = E_CARD_CURSOR (object);
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+
+ Evolution_CardCursor_unref( cursor->priv->corba_cursor, &ev );
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning("e_card_cursor_destroy: Exception unreffing "
+ "corba cursor.\n");
+ }
+
+ CORBA_exception_free (&ev);
+
+ if ( cursor->priv )
+ g_free ( cursor->priv );
+
+ GTK_OBJECT_CLASS (parent_class)->destroy (object);
+}
+
+/*
+ * CORBA Demo::Echo::echo method implementation
+ */
+long
+e_card_cursor_get_length (ECardCursor *cursor)
+{
+ if ( cursor->priv->corba_cursor != CORBA_OBJECT_NIL ) {
+ CORBA_Environment ev;
+ long ret_val;
+
+ CORBA_exception_init (&ev);
+
+ ret_val = Evolution_CardCursor_get_length(cursor->priv->corba_cursor, &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning("e_card_cursor_get_length: Exception during "
+ "get_length corba call.\n");
+ }
+
+ CORBA_exception_free (&ev);
+
+ return ret_val;
+ }
+ else
+ return 0;
+}
+
+/*
+ * CORBA Demo::Echo::echo method implementation
+ */
+ECard *
+e_card_cursor_get_nth (ECardCursor *cursor,
+ const long n)
+{
+ if ( cursor->priv->corba_cursor != CORBA_OBJECT_NIL ) {
+ CORBA_Environment ev;
+ CORBA_char * ret_val;
+ ECard *card;
+
+ CORBA_exception_init (&ev);
+
+ ret_val = Evolution_CardCursor_get_nth(cursor->priv->corba_cursor, n, &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning("e_card_cursor_get_nth: Exception during "
+ "get_nth corba call.\n");
+ CORBA_exception_free (&ev);
+ CORBA_exception_init (&ev);
+ }
+
+ card = e_card_new(ret_val);
+#if 0
+ CORBA_string__free(ret_val, &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning("e_card_cursor_get_nth: Exception freeing "
+ "string.\n");
+ }
+#endif
+ CORBA_exception_free (&ev);
+
+ return card;
+ }
+ else
+ return e_card_new("");
+}
+
+static void
+e_card_cursor_class_init (ECardCursorClass *klass)
+{
+ GtkObjectClass *object_class = (GtkObjectClass *) klass;
+
+ parent_class = gtk_type_class (bonobo_object_get_type ());
+
+ object_class->destroy = e_card_cursor_destroy;
+}
+
+static void
+e_card_cursor_init (ECardCursor *cursor)
+{
+ cursor->priv = g_new(ECardCursorPrivate, 1);
+ cursor->priv->corba_cursor = CORBA_OBJECT_NIL;
+}
+
+GtkType
+e_card_cursor_get_type (void)
+{
+ static GtkType type = 0;
+
+ if (!type){
+ GtkTypeInfo info = {
+ "ECardCursor",
+ sizeof (ECardCursor),
+ sizeof (ECardCursorClass),
+ (GtkClassInitFunc) e_card_cursor_class_init,
+ (GtkObjectInitFunc) e_card_cursor_init,
+ NULL, /* reserved 1 */
+ NULL, /* reserved 2 */
+ (GtkClassInitFunc) NULL
+ };
+
+ type = gtk_type_unique (gtk_object_get_type (), &info);
+ }
+
+ return type;
+}
+
+ECardCursor *
+e_card_cursor_construct (ECardCursor *cursor,
+ Evolution_CardCursor corba_cursor)
+{
+ CORBA_Environment ev;
+ g_return_val_if_fail (cursor != NULL, NULL);
+ g_return_val_if_fail (E_IS_CARD_CURSOR (cursor), NULL);
+ g_return_val_if_fail (corba_cursor != CORBA_OBJECT_NIL, NULL);
+
+ /*
+ * Initialize cursor
+ */
+ cursor->priv->corba_cursor = corba_cursor;
+
+ CORBA_exception_init (&ev);
+
+ Evolution_CardCursor_ref(corba_cursor, &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning("e_card_cursor_construct: Exception reffing "
+ "corba cursor.\n");
+ }
+
+ CORBA_exception_free (&ev);
+
+ /*
+ * Success: return the GtkType we were given
+ */
+ return cursor;
+}
+
+ECardCursor *
+e_card_cursor_new (Evolution_CardCursor corba_cursor)
+{
+ ECardCursor *cursor;
+
+ cursor = gtk_type_new (e_card_cursor_get_type ());
+
+ return e_card_cursor_construct (cursor,
+ corba_cursor);
+}
diff --git a/addressbook/backend/ebook/e-card-cursor.h b/addressbook/backend/ebook/e-card-cursor.h
index 5477a4f615..3e9523e86f 100644
--- a/addressbook/backend/ebook/e-card-cursor.h
+++ b/addressbook/backend/ebook/e-card-cursor.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
*
* Author:
@@ -6,36 +7,42 @@
* Copyright 2000, Helix Code, Inc.
*/
-#include <gtk/gtkobject.h>
+#ifndef __E_CARD_CURSOR_H__
+#define __E_CARD_CURSOR_H__
+
#include <libgnome/gnome-defs.h>
+#include <gtk/gtk.h>
+#include "addressbook.h"
-#include <e-book.h>
+typedef struct _ECardCursor ECardCursor;
-#ifndef __E_CARD_CURSOR_H__
-#define __E_CARD_CURSOR_H__
+#include <e-book.h>
BEGIN_GNOME_DECLS
typedef struct _ECardCursorPrivate ECardCursorPrivate;
+typedef struct _ECardCursorClass ECardCursorClass;
-typedef struct {
- GtkObject parent;
+struct _ECardCursor {
+ GtkObject parent;
ECardCursorPrivate *priv;
-} ECardCursor;
+};
-typedef struct {
+struct _ECardCursorClass {
GtkObjectClass parent;
-} ECardCursorClass;
+};
/* Creating a new addressbook. */
-ECardCursor *e_card_cursor_new (EBook *book,
- Evolution_CardCursor corba_cursor);
+ECardCursor *e_card_cursor_new (Evolution_CardCursor corba_cursor);
+ECardCursor *e_card_cursor_construct (ECardCursor *cursor,
+ Evolution_CardCursor corba_cursor);
+
GtkType e_card_cursor_get_type (void);
/* Fetching cards. */
-int e_card_cursor_get_length (ECardCursor *cursor);
+long e_card_cursor_get_length (ECardCursor *cursor);
ECard *e_card_cursor_get_nth (ECardCursor *cursor,
- int nth);
+ const long nth);
#define E_CARD_CURSOR_TYPE (e_card_cursor_get_type ())
#define E_CARD_CURSOR(o) (GTK_CHECK_CAST ((o), E_CARD_CURSOR_TYPE, ECardCursor))
#define E_CARD_CURSOR_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CARD_CURSOR_TYPE, ECardCursorClass))
diff --git a/addressbook/backend/ebook/e-card-pairs.h b/addressbook/backend/ebook/e-card-pairs.h
index e9a7f089f7..2c7635b8a4 100644
--- a/addressbook/backend/ebook/e-card-pairs.h
+++ b/addressbook/backend/ebook/e-card-pairs.h
@@ -68,15 +68,6 @@ struct pair prop_lookup[] = {
{ VCCharSetProp, PROP_CHARSET },
{ NULL, PROP_NONE} };
-struct pair addr_pairs[] = {
- { VCDomesticProp, ADDR_DOM },
- { VCInternationalProp, ADDR_INTL },
- { VCPostalProp, ADDR_POSTAL },
- { VCParcelProp, ADDR_PARCEL },
- { VCHomeProp, ADDR_HOME },
- { VCWorkProp, ADDR_WORK },
- { NULL, 0} };
-
struct pair photo_pairs[] = {
{ VCGIFProp, PHOTO_GIF },
{ VCCGMProp, PHOTO_CGM },
diff --git a/addressbook/backend/ebook/e-card.c b/addressbook/backend/ebook/e-card.c
index c259ea5193..282f1fe215 100644
--- a/addressbook/backend/ebook/e-card.c
+++ b/addressbook/backend/ebook/e-card.c
@@ -130,7 +130,7 @@ e_card_get_id (ECard *card)
}
void
-e_card_set_id (ECard *card, char *id)
+e_card_set_id (ECard *card, const char *id)
{
if ( card->id )
g_free(card->id);
diff --git a/addressbook/backend/ebook/e-card.h b/addressbook/backend/ebook/e-card.h
index b5abf34e24..200d4c3b3e 100644
--- a/addressbook/backend/ebook/e-card.h
+++ b/addressbook/backend/ebook/e-card.h
@@ -86,7 +86,7 @@ struct _ECardClass {
ECard *e_card_new (char *vcard);
char *e_card_get_id (ECard *card);
-void e_card_set_id (ECard *card, gchar *character);
+void e_card_set_id (ECard *card, const gchar *character);
char *e_card_get_vcard (ECard *card);
/* Standard Gtk function */
diff --git a/addressbook/backend/ebook/test-card.c b/addressbook/backend/ebook/test-card.c
index 1da02bad18..d032dfe707 100644
--- a/addressbook/backend/ebook/test-card.c
+++ b/addressbook/backend/ebook/test-card.c
@@ -85,7 +85,7 @@ main (int argc, char **argv)
}
#endif
card = e_card_new (cardstr);
- gtk_object_get(card,
+ gtk_object_get(GTK_OBJECT(card),
"full_name", &fname,
"name", &name,
"address", &address,
diff --git a/addressbook/backend/ebook/test-client.c b/addressbook/backend/ebook/test-client.c
index 365019f7bd..945df3f53c 100644
--- a/addressbook/backend/ebook/test-client.c
+++ b/addressbook/backend/ebook/test-client.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#include <config.h>
#include <bonobo.h>
#include <gnome.h>
@@ -47,8 +48,26 @@ init_bonobo (int argc, char **argv)
}
+#if 0
static void
-add_card_cb (EBook *book, EBookStatus status, gpointer closure)
+get_cursor_cb (EBook *book, EBookStatus status, ECardCursor *cursor, gpointer closure)
+{
+ long length = e_card_cursor_get_length(cursor);
+ long i;
+
+ for ( i = 0; i < length; i++ ) {
+ ECard *card = e_card_cursor_get_nth(cursor, i);
+ char *vcard = e_card_get_vcard(card);
+ printf("[%s]\n", vcard);
+ g_free(vcard);
+ gtk_object_unref(GTK_OBJECT(card));
+ }
+ gtk_object_unref(GTK_OBJECT(cursor));
+}
+#endif
+
+static void
+add_card_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure)
{
char *vcard;
ECard *card;
@@ -56,9 +75,11 @@ add_card_cb (EBook *book, EBookStatus status, gpointer closure)
printf ("Status: %d\n", status);
+ printf ("Id: %s\n", id);
+
timer = g_timer_new ();
g_timer_start (timer);
- card = e_book_get_card (book, "foo");
+ card = e_book_get_card (book, id);
g_timer_stop (timer);
vcard = e_card_get_vcard(card);
@@ -66,12 +87,16 @@ add_card_cb (EBook *book, EBookStatus status, gpointer closure)
printf ("[%s]\n", vcard);
g_free(vcard);
gtk_object_unref(GTK_OBJECT(card));
+
+#if 0
+ e_book_get_all_cards(book, get_cursor_cb, NULL);
+#endif
}
static void
book_open_cb (EBook *book, EBookStatus status, gpointer closure)
{
- e_book_add_vcard(book, TEST_VCARD, add_card_cb, NULL);
+ e_book_add_vcard(book, TEST_VCARD, add_card_cb, NULL);
}
static guint