aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/backend/pas/pas-book.c
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2003-10-22 02:49:34 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2003-10-22 02:49:34 +0800
commit653cfffc0e00dfb59b36813c1b45c53d3f773c65 (patch)
tree9b486d5e383ec1391d60973d9cc548be0ef6d9d5 /addressbook/backend/pas/pas-book.c
parent0fb08f3ff81575a4749d851404233f34252dd2f2 (diff)
downloadgsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar
gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.gz
gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.bz2
gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.lz
gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.xz
gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.zst
gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.zip
Merge new-ui-branch to the trunk.
svn path=/trunk/; revision=22965
Diffstat (limited to 'addressbook/backend/pas/pas-book.c')
-rw-r--r--addressbook/backend/pas/pas-book.c830
1 files changed, 287 insertions, 543 deletions
diff --git a/addressbook/backend/pas/pas-book.c b/addressbook/backend/pas/pas-book.c
index dc626e59e1..7b6e0c9a2b 100644
--- a/addressbook/backend/pas/pas-book.c
+++ b/addressbook/backend/pas/pas-book.c
@@ -7,261 +7,68 @@
#include <config.h>
#include <bonobo/bonobo-main.h>
+#include <bonobo/bonobo-arg.h>
#include "e-util/e-list.h"
+#include "ebook/e-contact.h"
+#include "pas-book-view.h"
#include "pas-backend.h"
+#include "pas-backend-card-sexp.h"
#include "pas-marshal.h"
static BonoboObjectClass *pas_book_parent_class;
POA_GNOME_Evolution_Addressbook_Book__vepv pas_book_vepv;
-enum {
- REQUESTS_QUEUED,
- LAST_SIGNAL
-};
-
-static guint pas_book_signals [LAST_SIGNAL];
-
struct _PASBookPrivate {
- PASBackend *backend;
+ PASBackend *backend;
GNOME_Evolution_Addressbook_BookListener listener;
-
- GList *request_queue;
- gint timeout_id;
-
- guint timeout_lock : 1;
+ char *uri;
};
-static gboolean
-pas_book_check_queue (PASBook *book)
-{
- if (book->priv->timeout_lock)
- return TRUE;
-
- book->priv->timeout_lock = TRUE;
-
- if (book->priv->request_queue != NULL) {
- g_signal_emit (book, pas_book_signals [REQUESTS_QUEUED], 0);
- }
-
- if (book->priv->request_queue == NULL) {
- book->priv->timeout_id = 0;
- book->priv->timeout_lock = FALSE;
- bonobo_object_unref (BONOBO_OBJECT (book));
- return FALSE;
- }
-
- book->priv->timeout_lock = FALSE;
-
- return TRUE;
-}
-
-static void
-pas_book_queue_request (PASBook *book, PASRequest *req)
-{
- book->priv->request_queue =
- g_list_append (book->priv->request_queue, req);
-
- if (book->priv->timeout_id == 0) {
- bonobo_object_ref (BONOBO_OBJECT (book));
- book->priv->timeout_id = g_timeout_add (20, (GSourceFunc) pas_book_check_queue, book);
- }
-}
-
-static void
-pas_book_queue_create_card (PASBook *book, const char *vcard)
-{
- PASRequest *req;
-
- req = g_new0 (PASRequest, 1);
- req->op = CreateCard;
- req->create.vcard = g_strdup (vcard);
-
- pas_book_queue_request (book, req);
-}
-
-static void
-pas_book_queue_remove_cards (PASBook *book,
- const GNOME_Evolution_Addressbook_CardIdList *ids)
-{
- PASRequest *req;
- int i;
-
- req = g_new0 (PASRequest, 1);
- req->op = RemoveCards;
- req->remove.ids = NULL;
-
- for (i = 0; i < ids->_length; i ++) {
- req->remove.ids = g_list_append (req->remove.ids, g_strdup (ids->_buffer[i]));
- }
-
- pas_book_queue_request (book, req);
-}
-
-static void
-pas_book_queue_modify_card (PASBook *book, const char *vcard)
-{
- PASRequest *req;
-
- req = g_new0 (PASRequest, 1);
- req->op = ModifyCard;
- req->modify.vcard = g_strdup (vcard);
-
- pas_book_queue_request (book, req);
-}
-
-static void
-pas_book_queue_get_cursor (PASBook *book, const char *search)
-{
- PASRequest *req;
-
- req = g_new0 (PASRequest, 1);
- req->op = GetCursor;
- req->get_cursor.search = g_strdup(search);
-
- pas_book_queue_request (book, req);
-}
-
-static void
-pas_book_queue_get_vcard (PASBook *book, const char *id)
-{
- PASRequest *req;
-
- req = g_new0 (PASRequest, 1);
- req->op = GetVCard;
- req->get_vcard.id = g_strdup(id);
-
- pas_book_queue_request (book, req);
-}
-
-static void
-pas_book_queue_authenticate_user (PASBook *book,
- const char *user, const char *passwd, const char *auth_method)
-{
- PASRequest *req;
-
- req = g_new0 (PASRequest, 1);
- req->op = AuthenticateUser;
- req->auth_user.user = g_strdup(user);
- req->auth_user.passwd = g_strdup(passwd);
- req->auth_user.auth_method = g_strdup(auth_method);
-
- pas_book_queue_request (book, req);
-}
-
-static void
-pas_book_queue_get_supported_fields (PASBook *book)
-{
- PASRequest *req;
-
- req = g_new0 (PASRequest, 1);
- req->op = GetSupportedFields;
-
- pas_book_queue_request (book, req);
-}
-
-static void
-pas_book_queue_get_supported_auth_methods (PASBook *book)
-{
- PASRequest *req;
-
- req = g_new0 (PASRequest, 1);
- req->op = GetSupportedAuthMethods;
-
- pas_book_queue_request (book, req);
-}
-
-
static void
-pas_book_queue_get_book_view (PASBook *book, const GNOME_Evolution_Addressbook_BookViewListener listener, const char *search)
+impl_GNOME_Evolution_Addressbook_Book_open (PortableServer_Servant servant,
+ const CORBA_boolean only_if_exists,
+ CORBA_Environment *ev)
{
- PASRequest *req;
- CORBA_Environment ev;
-
- req = g_new0 (PASRequest, 1);
- req->op = GetBookView;
- req->get_book_view.search = g_strdup(search);
-
- CORBA_exception_init (&ev);
-
- req->get_book_view.listener = bonobo_object_dup_ref(listener, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("pas_book_queue_get_book_view: Exception "
- "duplicating BookViewListener!\n");
- }
+ PASBook *book = PAS_BOOK (bonobo_object (servant));
- CORBA_exception_free (&ev);
+ printf ("impl_GNOME_Evolution_Addressbook_Book_open\n");
- pas_book_queue_request (book, req);
+ pas_backend_open (pas_book_get_backend (book), book, only_if_exists);
}
static void
-pas_book_queue_get_completion_view (PASBook *book, const GNOME_Evolution_Addressbook_BookViewListener listener, const char *search)
+impl_GNOME_Evolution_Addressbook_Book_remove (PortableServer_Servant servant,
+ CORBA_Environment *ev)
{
- PASRequest *req;
- CORBA_Environment ev;
-
- req = g_new0 (PASRequest, 1);
- req->op = GetCompletionView;
- req->get_book_view.search = g_strdup(search);
-
- CORBA_exception_init (&ev);
-
- req->get_book_view.listener = bonobo_object_dup_ref(listener, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("pas_book_queue_get_completion_view: Exception "
- "duplicating BookViewListener!\n");
- }
+ PASBook *book = PAS_BOOK (bonobo_object (servant));
- CORBA_exception_free (&ev);
+ printf ("impl_GNOME_Evolution_Addressbook_Book_open\n");
- pas_book_queue_request (book, req);
+ pas_backend_remove (pas_book_get_backend (book), book);
}
static void
-pas_book_queue_get_changes (PASBook *book, const GNOME_Evolution_Addressbook_BookViewListener listener, const char *change_id)
-{
- PASRequest *req;
- CORBA_Environment ev;
-
- req = g_new0 (PASRequest, 1);
- req->op = GetChanges;
- req->get_changes.change_id= g_strdup(change_id);
-
- CORBA_exception_init (&ev);
-
- req->get_changes.listener = bonobo_object_dup_ref(listener, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("pas_book_queue_get_changes: Exception "
- "duplicating BookViewListener!\n");
- }
-
- CORBA_exception_free (&ev);
-
- pas_book_queue_request (book, req);
-}
-
-static void
-pas_book_queue_check_connection (PASBook *book)
+impl_GNOME_Evolution_Addressbook_Book_getContact (PortableServer_Servant servant,
+ const CORBA_char *id,
+ CORBA_Environment *ev)
{
- PASRequest *req;
+ PASBook *book = PAS_BOOK (bonobo_object (servant));
- req = g_new0 (PASRequest, 1);
- req->op = CheckConnection;
+ printf ("impl_GNOME_Evolution_Addressbook_Book_getContact\n");
- pas_book_queue_request (book, req);
+ pas_backend_get_contact (pas_book_get_backend (book), book, id);
}
static void
-impl_GNOME_Evolution_Addressbook_Book_getVCard (PortableServer_Servant servant,
- const CORBA_char *id,
- CORBA_Environment *ev)
+impl_GNOME_Evolution_Addressbook_Book_getContactList (PortableServer_Servant servant,
+ const CORBA_char *query,
+ CORBA_Environment *ev)
{
PASBook *book = PAS_BOOK (bonobo_object (servant));
- pas_book_queue_get_vcard (book, id);
+ printf ("impl_GNOME_Evolution_Addressbook_Book_getContactList\n");
+
+ pas_backend_get_contact_list (pas_book_get_backend (book), book, query);
}
static void
@@ -273,90 +80,97 @@ impl_GNOME_Evolution_Addressbook_Book_authenticateUser (PortableServer_Servant s
{
PASBook *book = PAS_BOOK (bonobo_object (servant));
- pas_book_queue_authenticate_user (book, user, passwd, auth_method);
+ pas_backend_authenticate_user (pas_book_get_backend (book), book,
+ user, passwd, auth_method);
}
static void
-impl_GNOME_Evolution_Addressbook_Book_addCard (PortableServer_Servant servant,
- const CORBA_char *vcard,
- CORBA_Environment *ev)
+impl_GNOME_Evolution_Addressbook_Book_addContact (PortableServer_Servant servant,
+ const CORBA_char *vcard,
+ CORBA_Environment *ev)
{
PASBook *book = PAS_BOOK (bonobo_object (servant));
- pas_book_queue_create_card (book, (const char *) vcard);
+ pas_backend_create_contact (pas_book_get_backend (book), book, vcard);
}
static void
-impl_GNOME_Evolution_Addressbook_Book_removeCards (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_CardIdList *ids,
- CORBA_Environment *ev)
+impl_GNOME_Evolution_Addressbook_Book_removeContacts (PortableServer_Servant servant,
+ const GNOME_Evolution_Addressbook_ContactIdList *ids,
+ CORBA_Environment *ev)
{
PASBook *book = PAS_BOOK (bonobo_object (servant));
+ int i;
+ GList *id_list = NULL;
+
+ for (i = 0; i < ids->_length; i ++)
+ id_list = g_list_append (id_list, ids->_buffer[i]);
- pas_book_queue_remove_cards (book, ids);
-}
-
-static void
-impl_GNOME_Evolution_Addressbook_Book_modifyCard (PortableServer_Servant servant,
- const CORBA_char *vcard,
- CORBA_Environment *ev)
-{
- PASBook *book = PAS_BOOK (bonobo_object (servant));
+ pas_backend_remove_contacts (pas_book_get_backend (book), book, id_list);
- pas_book_queue_modify_card (book, (const char *) vcard);
+ g_list_free (id_list);
}
static void
-impl_GNOME_Evolution_Addressbook_Book_getCursor (PortableServer_Servant servant,
- const CORBA_char *search,
- CORBA_Environment *ev)
+impl_GNOME_Evolution_Addressbook_Book_modifyContact (PortableServer_Servant servant,
+ const CORBA_char *vcard,
+ CORBA_Environment *ev)
{
PASBook *book = PAS_BOOK (bonobo_object (servant));
- pas_book_queue_get_cursor (book, search);
+ pas_backend_modify_contact (pas_book_get_backend (book), book, vcard);
}
static void
impl_GNOME_Evolution_Addressbook_Book_getBookView (PortableServer_Servant servant,
const GNOME_Evolution_Addressbook_BookViewListener listener,
const CORBA_char *search,
+ const GNOME_Evolution_Addressbook_stringlist* requested_fields,
+ const CORBA_long max_results,
CORBA_Environment *ev)
{
PASBook *book = PAS_BOOK (bonobo_object (servant));
+ PASBackend *backend = pas_book_get_backend (book);
+ PASBackendCardSExp *card_sexp;
+ PASBookView *view;
- pas_book_queue_get_book_view (book, listener, search);
-}
+ g_warning ("impl_GNOME_Evolution_Addressbook_Book_getBookView (%s)\n", search);
+ /* we handle this entirely here, since it doesn't require any
+ backend involvement now that we have pas_book_view_start to
+ actually kick off the search. */
-static void
-impl_GNOME_Evolution_Addressbook_Book_getCompletionView (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_BookViewListener listener,
- const CORBA_char *search,
- CORBA_Environment *ev)
-{
- PASBook *book = PAS_BOOK (bonobo_object (servant));
+ card_sexp = pas_backend_card_sexp_new (search);
+ if (!card_sexp) {
+ pas_book_respond_get_book_view (book, GNOME_Evolution_Addressbook_InvalidQuery, NULL);
+ return;
+ }
+
+ view = pas_book_view_new (backend, listener, search, card_sexp);
- pas_book_queue_get_completion_view (book, listener, search);
+ if (!view) {
+ g_object_unref (card_sexp);
+ pas_book_respond_get_book_view (book, GNOME_Evolution_Addressbook_OtherError, NULL);
+ return;
+ }
+
+
+ pas_backend_add_book_view (backend, view);
+
+ pas_book_respond_get_book_view (book, GNOME_Evolution_Addressbook_Success, view);
+
+ g_object_unref (view);
}
+
static void
impl_GNOME_Evolution_Addressbook_Book_getChanges (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_BookViewListener listener,
const CORBA_char *change_id,
CORBA_Environment *ev)
{
PASBook *book = PAS_BOOK (bonobo_object (servant));
- pas_book_queue_get_changes (book, listener, change_id);
-}
-
-static void
-impl_GNOME_Evolution_Addressbook_Book_checkConnection (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- PASBook *book = PAS_BOOK (bonobo_object (servant));
-
- pas_book_queue_check_connection (book);
+ pas_backend_get_changes (pas_book_get_backend (book), book, change_id);
}
static char *
@@ -379,7 +193,7 @@ impl_GNOME_Evolution_Addressbook_Book_getSupportedFields (PortableServer_Servant
{
PASBook *book = PAS_BOOK (bonobo_object (servant));
- pas_book_queue_get_supported_fields (book);
+ pas_backend_get_supported_fields (pas_book_get_backend (book), book);
}
static void
@@ -388,7 +202,16 @@ impl_GNOME_Evolution_Addressbook_Book_getSupportedAuthMethods (PortableServer_Se
{
PASBook *book = PAS_BOOK (bonobo_object (servant));
- pas_book_queue_get_supported_auth_methods (book);
+ pas_backend_get_supported_auth_methods (pas_book_get_backend (book), book);
+}
+
+static GNOME_Evolution_Addressbook_CallStatus
+impl_GNOME_Evolution_Addressbook_Book_cancelOperation (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ PASBook *book = PAS_BOOK (bonobo_object (servant));
+
+ return pas_backend_cancel_operation (pas_book_get_backend (book), book);
}
/**
@@ -397,87 +220,59 @@ impl_GNOME_Evolution_Addressbook_Book_getSupportedAuthMethods (PortableServer_Se
PASBackend *
pas_book_get_backend (PASBook *book)
{
- g_return_val_if_fail (book != NULL, NULL);
- g_return_val_if_fail (PAS_IS_BOOK (book), NULL);
+ g_return_val_if_fail (book && PAS_IS_BOOK (book), NULL);
return book->priv->backend;
}
-/**
- * pas_book_get_listener:
- */
GNOME_Evolution_Addressbook_BookListener
pas_book_get_listener (PASBook *book)
{
- g_return_val_if_fail (book != NULL, CORBA_OBJECT_NIL);
- g_return_val_if_fail (PAS_IS_BOOK (book), CORBA_OBJECT_NIL);
+ g_return_val_if_fail (book && PAS_IS_BOOK (book), CORBA_OBJECT_NIL);
return book->priv->listener;
}
-/**
- * pas_book_check_pending
- */
-gint
-pas_book_check_pending (PASBook *book)
+const char*
+pas_book_get_uri (PASBook *book)
{
- g_return_val_if_fail (book != NULL, -1);
- g_return_val_if_fail (PAS_IS_BOOK (book), -1);
-
- return g_list_length (book->priv->request_queue);
+ return book->priv->uri;
}
/**
- * pas_book_pop_request:
+ * pas_book_respond_open:
*/
-PASRequest *
-pas_book_pop_request (PASBook *book)
+void
+pas_book_respond_open (PASBook *book,
+ GNOME_Evolution_Addressbook_CallStatus status)
{
- GList *popped;
- PASRequest *req;
-
- g_return_val_if_fail (book != NULL, NULL);
- g_return_val_if_fail (PAS_IS_BOOK (book), NULL);
-
- if (book->priv->request_queue == NULL)
- return NULL;
-
- req = book->priv->request_queue->data;
+ CORBA_Environment ev;
- popped = book->priv->request_queue;
- book->priv->request_queue =
- g_list_remove_link (book->priv->request_queue, popped);
+ CORBA_exception_init (&ev);
+ GNOME_Evolution_Addressbook_BookListener_notifyBookOpened (book->priv->listener, status, &ev);
- g_list_free_1 (popped);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("pas_book_respond_open: Exception "
+ "responding to BookListener!\n");
+ }
- return req;
+ CORBA_exception_free (&ev);
}
/**
- * pas_book_respond_open:
+ * pas_book_respond_remove:
*/
void
-pas_book_respond_open (PASBook *book,
- GNOME_Evolution_Addressbook_BookListener_CallStatus status)
+pas_book_respond_remove (PASBook *book,
+ GNOME_Evolution_Addressbook_CallStatus status)
{
CORBA_Environment ev;
CORBA_exception_init (&ev);
-
- if (status == GNOME_Evolution_Addressbook_BookListener_Success) {
- GNOME_Evolution_Addressbook_BookListener_notifyBookOpened (
- book->priv->listener, status,
- bonobo_object_corba_objref (BONOBO_OBJECT (book)),
- &ev);
- } else {
- GNOME_Evolution_Addressbook_BookListener_notifyBookOpened (
- book->priv->listener, status,
- CORBA_OBJECT_NIL, &ev);
- }
-
+ GNOME_Evolution_Addressbook_BookListener_notifyBookRemoved (book->priv->listener, status, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("pas_book_respond_open: Exception "
+ g_warning ("pas_book_respond_remove: Exception "
"responding to BookListener!\n");
}
@@ -488,16 +283,22 @@ pas_book_respond_open (PASBook *book,
* pas_book_respond_create:
*/
void
-pas_book_respond_create (PASBook *book,
- GNOME_Evolution_Addressbook_BookListener_CallStatus status,
- const char *id)
+pas_book_respond_create (PASBook *book,
+ GNOME_Evolution_Addressbook_CallStatus status,
+ EContact *contact)
{
CORBA_Environment ev;
+ if (status == GNOME_Evolution_Addressbook_Success) {
+ pas_backend_notify_update (book->priv->backend, contact);
+ pas_backend_notify_complete (book->priv->backend);
+ }
+
CORBA_exception_init (&ev);
- GNOME_Evolution_Addressbook_BookListener_notifyCardCreated (
- book->priv->listener, status, (char *)id, &ev);
+ GNOME_Evolution_Addressbook_BookListener_notifyContactCreated (
+ book->priv->listener, status,
+ e_contact_get (contact, E_CONTACT_UID), &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("pas_book_respond_create: Exception "
@@ -508,17 +309,25 @@ pas_book_respond_create (PASBook *book,
}
/**
- * pas_book_respond_remove:
+ * pas_book_respond_remove_contacts:
*/
void
-pas_book_respond_remove (PASBook *book,
- GNOME_Evolution_Addressbook_BookListener_CallStatus status)
+pas_book_respond_remove_contacts (PASBook *book,
+ GNOME_Evolution_Addressbook_CallStatus status,
+ GList *ids)
{
CORBA_Environment ev;
+ GList *i;
CORBA_exception_init (&ev);
- GNOME_Evolution_Addressbook_BookListener_notifyCardsRemoved (
+ if (ids) {
+ for (i = ids; i; i = i->next)
+ pas_backend_notify_remove (book->priv->backend, i->data);
+ pas_backend_notify_complete (book->priv->backend);
+ }
+
+ GNOME_Evolution_Addressbook_BookListener_notifyContactsRemoved (
book->priv->listener, status, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
@@ -533,14 +342,20 @@ pas_book_respond_remove (PASBook *book,
* pas_book_respond_modify:
*/
void
-pas_book_respond_modify (PASBook *book,
- GNOME_Evolution_Addressbook_BookListener_CallStatus status)
+pas_book_respond_modify (PASBook *book,
+ GNOME_Evolution_Addressbook_CallStatus status,
+ EContact *contact)
{
CORBA_Environment ev;
+ if (status == GNOME_Evolution_Addressbook_Success) {
+ pas_backend_notify_update (book->priv->backend, contact);
+ pas_backend_notify_complete (book->priv->backend);
+ }
+
CORBA_exception_init (&ev);
- GNOME_Evolution_Addressbook_BookListener_notifyCardModified (
+ GNOME_Evolution_Addressbook_BookListener_notifyContactModified (
book->priv->listener, status, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
@@ -556,7 +371,7 @@ pas_book_respond_modify (PASBook *book,
*/
void
pas_book_respond_authenticate_user (PASBook *book,
- GNOME_Evolution_Addressbook_BookListener_CallStatus status)
+ GNOME_Evolution_Addressbook_CallStatus status)
{
CORBA_Environment ev;
@@ -575,30 +390,28 @@ pas_book_respond_authenticate_user (PASBook *book,
void
pas_book_respond_get_supported_fields (PASBook *book,
- GNOME_Evolution_Addressbook_BookListener_CallStatus status,
- EList *fields)
+ GNOME_Evolution_Addressbook_CallStatus status,
+ GList *fields)
{
CORBA_Environment ev;
GNOME_Evolution_Addressbook_stringlist stringlist;
int num_fields;
- EIterator *iter;
int i;
+ GList *iter;
CORBA_exception_init (&ev);
- num_fields = e_list_length (fields);
+ num_fields = g_list_length (fields);
stringlist._buffer = CORBA_sequence_CORBA_string_allocbuf (num_fields);
stringlist._maximum = num_fields;
stringlist._length = num_fields;
- iter = e_list_get_iterator (fields);
-
- for (i = 0; e_iterator_is_valid (iter); e_iterator_next (iter), i ++) {
- stringlist._buffer[i] = CORBA_string_dup (e_iterator_get(iter));
+ for (i = 0, iter = fields; iter; iter = iter->next, i ++) {
+ stringlist._buffer[i] = CORBA_string_dup ((char*)iter->data);
}
- g_object_unref (fields);
+ printf ("calling GNOME_Evolution_Addressbook_BookListener_notifySupportedFields\n");
GNOME_Evolution_Addressbook_BookListener_notifySupportedFields (
book->priv->listener, status,
@@ -612,31 +425,27 @@ pas_book_respond_get_supported_fields (PASBook *book,
void
pas_book_respond_get_supported_auth_methods (PASBook *book,
- GNOME_Evolution_Addressbook_BookListener_CallStatus status,
- EList *auth_methods)
+ GNOME_Evolution_Addressbook_CallStatus status,
+ GList *auth_methods)
{
CORBA_Environment ev;
GNOME_Evolution_Addressbook_stringlist stringlist;
int num_auth_methods;
- EIterator *iter;
+ GList *iter;
int i;
CORBA_exception_init (&ev);
- num_auth_methods = e_list_length (auth_methods);
+ num_auth_methods = g_list_length (auth_methods);
stringlist._buffer = CORBA_sequence_CORBA_string_allocbuf (num_auth_methods);
stringlist._maximum = num_auth_methods;
stringlist._length = num_auth_methods;
- iter = e_list_get_iterator (auth_methods);
-
- for (i = 0; e_iterator_is_valid (iter); e_iterator_next (iter), i ++) {
- stringlist._buffer[i] = CORBA_string_dup (e_iterator_get(iter));
+ for (i = 0, iter = auth_methods; iter; iter = iter->next, i ++) {
+ stringlist._buffer[i] = CORBA_string_dup ((char*)iter->data);
}
- g_object_unref (auth_methods);
-
GNOME_Evolution_Addressbook_BookListener_notifySupportedAuthMethods (
book->priv->listener, status,
&stringlist,
@@ -647,30 +456,28 @@ pas_book_respond_get_supported_auth_methods (PASBook *book,
CORBA_free(stringlist._buffer);
}
-/**
- * pas_book_respond_get_cursor:
- */
-void
-pas_book_respond_get_cursor (PASBook *book,
- GNOME_Evolution_Addressbook_BookListener_CallStatus status,
- PASCardCursor *cursor)
-{
- CORBA_Environment ev;
- CORBA_Object object;
-
- CORBA_exception_init (&ev);
-
- object = bonobo_object_corba_objref(BONOBO_OBJECT(cursor));
-
- GNOME_Evolution_Addressbook_BookListener_notifyCursorRequested (
- book->priv->listener, status, object, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("pas_book_respond_get_cursor: Exception "
- "responding to BookListener!\n");
+static void
+view_destroy(gpointer data, GObject *where_object_was)
+{
+ PASBook *book = (PASBook *)data;
+ EIterator *iterator;
+ gboolean success = FALSE;
+ EList *views = pas_backend_get_book_views (book->priv->backend);
+
+ for (iterator = e_list_get_iterator(views);
+ e_iterator_is_valid(iterator);
+ e_iterator_next(iterator)) {
+ const PASBookView *view = e_iterator_get(iterator);
+ if (view == (PASBookView*)where_object_was) {
+ e_iterator_delete(iterator);
+ success = TRUE;
+ break;
+ }
}
-
- CORBA_exception_free (&ev);
+ if (!success)
+ g_warning ("Failed to remove from book_views list");
+ g_object_unref(iterator);
+ g_object_unref(views);
}
/**
@@ -678,15 +485,21 @@ pas_book_respond_get_cursor (PASBook *book,
*/
void
pas_book_respond_get_book_view (PASBook *book,
- GNOME_Evolution_Addressbook_BookListener_CallStatus status,
+ GNOME_Evolution_Addressbook_CallStatus status,
PASBookView *book_view)
{
CORBA_Environment ev;
- CORBA_Object object;
+ CORBA_Object object = CORBA_OBJECT_NIL;
+
+ printf ("pas_book_respond_get_book_view\n");
CORBA_exception_init (&ev);
-
- object = bonobo_object_corba_objref(BONOBO_OBJECT(book_view));
+
+ if (book_view) {
+ object = bonobo_object_corba_objref(BONOBO_OBJECT(book_view));
+
+ g_object_weak_ref (G_OBJECT (book_view), view_destroy, book);
+ }
GNOME_Evolution_Addressbook_BookListener_notifyViewRequested (
book->priv->listener, status, object, &ev);
@@ -700,100 +513,122 @@ pas_book_respond_get_book_view (PASBook *book,
}
/**
- * pas_book_respond_get_book_view:
+ * pas_book_respond_get_contact:
*/
void
-pas_book_respond_get_completion_view (PASBook *book,
- GNOME_Evolution_Addressbook_BookListener_CallStatus status,
- PASBookView *completion_view)
+pas_book_respond_get_contact (PASBook *book,
+ GNOME_Evolution_Addressbook_CallStatus status,
+ char *vcard)
{
CORBA_Environment ev;
- CORBA_Object object;
CORBA_exception_init (&ev);
-
- object = bonobo_object_corba_objref(BONOBO_OBJECT(completion_view));
- GNOME_Evolution_Addressbook_BookListener_notifyViewRequested (
- book->priv->listener, status, object, &ev);
+ GNOME_Evolution_Addressbook_BookListener_notifyContactRequested (book->priv->listener,
+ status,
+ vcard,
+ &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("pas_book_respond_get_completion_view: Exception "
- "responding to BookListener!\n");
- }
+ if (ev._major != CORBA_NO_EXCEPTION)
+ g_message ("could not notify listener of get-contact response");
CORBA_exception_free (&ev);
}
/**
- * pas_book_respond_get_changes:
+ * pas_book_respond_get_contact_list:
*/
void
-pas_book_respond_get_vcard (PASBook *book,
- GNOME_Evolution_Addressbook_BookListener_CallStatus status,
- char *vcard)
+pas_book_respond_get_contact_list (PASBook *book,
+ GNOME_Evolution_Addressbook_CallStatus status,
+ GList *card_list)
{
CORBA_Environment ev;
+ GNOME_Evolution_Addressbook_stringlist stringlist;
+ int num_cards;
+ int i;
+ GList *l;
CORBA_exception_init (&ev);
- GNOME_Evolution_Addressbook_BookListener_notifyCardRequested (
- book->priv->listener, status, vcard, &ev);
+ num_cards = g_list_length (card_list);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("pas_book_respond_get_card: Exception "
- "responding to BookListener!\n");
- }
+ stringlist._buffer = CORBA_sequence_CORBA_string_allocbuf (num_cards);
+ stringlist._maximum = num_cards;
+ stringlist._length = num_cards;
- CORBA_exception_free (&ev);
-}
+ for (i = 0, l = card_list; l; l = l->next, i ++)
+ stringlist._buffer[i] = CORBA_string_dup (l->data);
-/**
- * pas_book_respond_get_changes:
- */
-void
-pas_book_respond_get_changes (PASBook *book,
- GNOME_Evolution_Addressbook_BookListener_CallStatus status,
- PASBookView *book_view)
-{
- CORBA_Environment ev;
- CORBA_Object object;
+ g_list_foreach (card_list, (GFunc)g_free, NULL);
+ g_list_free (card_list);
- CORBA_exception_init (&ev);
-
- object = bonobo_object_corba_objref(BONOBO_OBJECT(book_view));
- GNOME_Evolution_Addressbook_BookListener_notifyChangesRequested (
- book->priv->listener, status, object, &ev);
+ GNOME_Evolution_Addressbook_BookListener_notifyContactListRequested (book->priv->listener,
+ status,
+ &stringlist,
+ &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("pas_book_respond_get_changes: Exception "
- "responding to BookListener!\n");
- }
+ if (ev._major != CORBA_NO_EXCEPTION)
+ g_message ("could not notify listener of get-contact-list response");
CORBA_exception_free (&ev);
+
+ CORBA_free(stringlist._buffer);
}
/**
- * pas_book_report_connection:
+ * pas_book_respond_get_changes:
*/
void
-pas_book_report_connection (PASBook *book,
- gboolean connected)
+pas_book_respond_get_changes (PASBook *book,
+ GNOME_Evolution_Addressbook_CallStatus status,
+ GList *changes)
{
CORBA_Environment ev;
+ GNOME_Evolution_Addressbook_BookChangeList changelist;
+ int num_changes;
+ int i;
+ GList *l;
CORBA_exception_init (&ev);
- GNOME_Evolution_Addressbook_BookListener_notifyConnectionStatus (
- book->priv->listener, (CORBA_boolean) connected, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("pas_book_report_connection: Exception "
- "responding to BookListener!\n");
+ num_changes = g_list_length (changes);
+
+ changelist._buffer = CORBA_sequence_GNOME_Evolution_Addressbook_BookChangeItem_allocbuf (num_changes);
+ changelist._maximum = num_changes;
+ changelist._length = num_changes;
+
+ for (i = 0, l = changes; l; l = l->next, i ++) {
+ GNOME_Evolution_Addressbook_BookChangeItem *change = (GNOME_Evolution_Addressbook_BookChangeItem*)l->data;
+ changelist._buffer[i] = *change;
+ switch (change->_d) {
+ case GNOME_Evolution_Addressbook_ContactAdded:
+ changelist._buffer[i]._u.add_vcard = CORBA_string_dup (change->_u.add_vcard);
+ break;
+ case GNOME_Evolution_Addressbook_ContactModified:
+ changelist._buffer[i]._u.mod_vcard = CORBA_string_dup (change->_u.mod_vcard);
+ break;
+ case GNOME_Evolution_Addressbook_ContactDeleted:
+ changelist._buffer[i]._u.del_id = CORBA_string_dup (change->_u.del_id);
+ break;
+ }
}
+ g_list_foreach (changes, (GFunc)CORBA_free, NULL);
+ g_list_free (changes);
+
+ GNOME_Evolution_Addressbook_BookListener_notifyChangesRequested (book->priv->listener,
+ status,
+ &changelist,
+ &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION)
+ g_message ("could not notify listener of get-changes response");
+
CORBA_exception_free (&ev);
+
+ CORBA_free(changelist._buffer);
}
/**
@@ -821,7 +656,8 @@ pas_book_report_writable (PASBook *book,
static void
pas_book_construct (PASBook *book,
PASBackend *backend,
- GNOME_Evolution_Addressbook_BookListener listener)
+ const char *uri,
+ GNOME_Evolution_Addressbook_BookListener listener)
{
PASBookPrivate *priv;
CORBA_Environment ev;
@@ -830,8 +666,6 @@ pas_book_construct (PASBook *book,
priv = book->priv;
- priv->backend = backend;
-
CORBA_exception_init (&ev);
book->priv->listener = CORBA_Object_duplicate (listener, &ev);
@@ -843,94 +677,31 @@ pas_book_construct (PASBook *book,
CORBA_exception_free (&ev);
- priv->listener = listener;
+ priv->backend = backend;
+ priv->uri = g_strdup (uri);
+
}
/**
* pas_book_new:
*/
PASBook *
-pas_book_new (PASBackend *backend,
+pas_book_new (PASBackend *backend,
+ const char *uri,
GNOME_Evolution_Addressbook_BookListener listener)
{
PASBook *book;
+ char *caps = pas_backend_get_static_capabilities (backend);
- book = g_object_new (PAS_TYPE_BOOK, NULL);
-
- pas_book_construct (book, backend, listener);
+ book = g_object_new (PAS_TYPE_BOOK,
+ "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL),
+ NULL);
- return book;
-}
+ pas_book_construct (book, backend, uri, listener);
-void
-pas_book_free_request (PASRequest *req)
-{
- CORBA_Environment ev;
- switch (req->op) {
- case CreateCard:
- g_free (req->create.id);
- g_free (req->create.vcard);
- break;
- case RemoveCards:
- g_list_foreach (req->remove.ids, (GFunc)g_free, NULL);
- g_list_free (req->remove.ids);
- break;
- case ModifyCard:
- g_free (req->modify.vcard);
- break;
- case GetVCard:
- g_free (req->get_vcard.id);
- break;
- case GetCursor:
- g_free (req->get_cursor.search);
- break;
- case GetBookView:
- g_free (req->get_book_view.search);
- CORBA_exception_init (&ev);
- bonobo_object_release_unref (req->get_book_view.listener, &ev);
+ g_free (caps);
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("pas_book_free_request(GetBookView): could not release the listener");
-
- CORBA_exception_free (&ev);
- break;
- case GetCompletionView:
- g_free (req->get_completion_view.search);
- CORBA_exception_init (&ev);
- bonobo_object_release_unref (req->get_completion_view.listener, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("pas_book_free_request(GetCompletionView): could not release the listener");
-
- CORBA_exception_free (&ev);
- break;
- case GetChanges:
- g_free (req->get_changes.change_id);
- CORBA_exception_init (&ev);
- bonobo_object_release_unref (req->get_changes.listener, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("pas_book_free_request(GetChanges): could not release the listener");
-
- CORBA_exception_free (&ev);
- break;
- case CheckConnection:
- /* nothing to free */
- break;
- case AuthenticateUser:
- g_free (req->auth_user.user);
- g_free (req->auth_user.passwd);
- g_free (req->auth_user.auth_method);
- break;
- case GetSupportedFields:
- /* nothing to free */
- break;
- case GetSupportedAuthMethods:
- /* nothing to free */
- break;
- }
-
- g_free (req);
+ return book;
}
static void
@@ -939,24 +710,8 @@ pas_book_dispose (GObject *object)
PASBook *book = PAS_BOOK (object);
if (book->priv) {
- GList *l;
CORBA_Environment ev;
- for (l = book->priv->request_queue; l != NULL; l = l->next) {
- pas_book_free_request ((PASRequest *)l->data);
- }
- g_list_free (book->priv->request_queue);
-
- /* We should never ever have timeout_id == 0 when we
- get destroyed, unless there is some sort of
- reference counting bug. Still, we do this to try
- to avoid horrible crashes in those situations. */
- if (book->priv->timeout_id) {
- g_warning ("PASBook destroyed with non-zero timeout_id. This shouldn't happen.");
- g_source_remove (book->priv->timeout_id);
- book->priv->timeout_id = 0;
- }
-
CORBA_exception_init (&ev);
CORBA_Object_release (book->priv->listener, &ev);
@@ -965,6 +720,7 @@ pas_book_dispose (GObject *object)
CORBA_exception_free (&ev);
+ g_free (book->priv->uri);
g_free (book->priv);
book->priv = NULL;
}
@@ -981,42 +737,30 @@ pas_book_class_init (PASBookClass *klass)
pas_book_parent_class = g_type_class_peek_parent (klass);
- pas_book_signals [REQUESTS_QUEUED] =
- g_signal_new ("requests_queued",
- G_OBJECT_CLASS_TYPE(object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PASBookClass, requests_queued),
- NULL, NULL,
- pas_marshal_NONE__NONE,
- G_TYPE_NONE, 0);
-
object_class->dispose = pas_book_dispose;
epv = &klass->epv;
- epv->getVCard = impl_GNOME_Evolution_Addressbook_Book_getVCard;
+ epv->open = impl_GNOME_Evolution_Addressbook_Book_open;
+ epv->remove = impl_GNOME_Evolution_Addressbook_Book_remove;
+ epv->getContact = impl_GNOME_Evolution_Addressbook_Book_getContact;
+ epv->getContactList = impl_GNOME_Evolution_Addressbook_Book_getContactList;
epv->authenticateUser = impl_GNOME_Evolution_Addressbook_Book_authenticateUser;
- epv->addCard = impl_GNOME_Evolution_Addressbook_Book_addCard;
- epv->removeCards = impl_GNOME_Evolution_Addressbook_Book_removeCards;
- epv->modifyCard = impl_GNOME_Evolution_Addressbook_Book_modifyCard;
- epv->checkConnection = impl_GNOME_Evolution_Addressbook_Book_checkConnection;
+ epv->addContact = impl_GNOME_Evolution_Addressbook_Book_addContact;
+ epv->removeContacts = impl_GNOME_Evolution_Addressbook_Book_removeContacts;
+ epv->modifyContact = impl_GNOME_Evolution_Addressbook_Book_modifyContact;
epv->getStaticCapabilities = impl_GNOME_Evolution_Addressbook_Book_getStaticCapabilities;
epv->getSupportedFields = impl_GNOME_Evolution_Addressbook_Book_getSupportedFields;
epv->getSupportedAuthMethods = impl_GNOME_Evolution_Addressbook_Book_getSupportedAuthMethods;
- epv->getCursor = impl_GNOME_Evolution_Addressbook_Book_getCursor;
epv->getBookView = impl_GNOME_Evolution_Addressbook_Book_getBookView;
- epv->getCompletionView = impl_GNOME_Evolution_Addressbook_Book_getCompletionView;
epv->getChanges = impl_GNOME_Evolution_Addressbook_Book_getChanges;
+ epv->cancelOperation = impl_GNOME_Evolution_Addressbook_Book_cancelOperation;
}
static void
pas_book_init (PASBook *book)
{
book->priv = g_new0 (PASBookPrivate, 1);
- book->priv->timeout_id = 0;
- book->priv->request_queue = NULL;
- book->priv->timeout_id = 0;
- book->priv->timeout_lock = FALSE;
}
BONOBO_TYPE_FUNC_FULL (