aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2001-08-14 10:17:04 +0800
committerChris Lahey <clahey@src.gnome.org>2001-08-14 10:17:04 +0800
commit476458f355b639cb725188d9d8e767affa71f4ab (patch)
tree8d6686abbf6334ad7b65aa8ea15895d58e88b6bd
parent3157a507b2074766bbd88300cec543a28418d443 (diff)
downloadgsoc2013-evolution-476458f355b639cb725188d9d8e767affa71f4ab.tar.gz
gsoc2013-evolution-476458f355b639cb725188d9d8e767affa71f4ab.tar.zst
gsoc2013-evolution-476458f355b639cb725188d9d8e767affa71f4ab.zip
Changed get_card to be asyncronous.
2001-08-13 Christopher James Lahey <clahey@ximian.com> * backend/ebook/e-book-listener.c, backend/ebook/e-book-listener.h, backend/ebook/e-book.c, backend/ebook/e-book.h, backend/idl/addressbook.idl, backend/pas/pas-backend-file.c, backend/pas/pas-book.c, backend/pas/pas-book.h: Changed get_card to be asyncronous. * backend/ebook/e-card.c, backend/ebook/test-client.c: Changed these to deal with the new get_card functionality. svn path=/trunk/; revision=11984
-rw-r--r--addressbook/ChangeLog11
-rw-r--r--addressbook/backend/ebook/e-book-listener.c58
-rw-r--r--addressbook/backend/ebook/e-book-listener.h2
-rw-r--r--addressbook/backend/ebook/e-book.c117
-rw-r--r--addressbook/backend/ebook/e-book.h15
-rw-r--r--addressbook/backend/ebook/e-card.c15
-rw-r--r--addressbook/backend/ebook/test-client.c28
-rw-r--r--addressbook/backend/idl/addressbook.idl17
-rw-r--r--addressbook/backend/pas/pas-backend-file.c107
-rw-r--r--addressbook/backend/pas/pas-book.c74
-rw-r--r--addressbook/backend/pas/pas-book.h13
11 files changed, 218 insertions, 239 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index f4cba44ebb..049435e2ca 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,14 @@
+2001-08-13 Christopher James Lahey <clahey@ximian.com>
+
+ * backend/ebook/e-book-listener.c,
+ backend/ebook/e-book-listener.h, backend/ebook/e-book.c,
+ backend/ebook/e-book.h, backend/idl/addressbook.idl,
+ backend/pas/pas-backend-file.c, backend/pas/pas-book.c,
+ backend/pas/pas-book.h: Changed get_card to be asyncronous.
+
+ * backend/ebook/e-card.c, backend/ebook/test-client.c: Changed
+ these to deal with the new get_card functionality.
+
2001-08-11 Kjartan Maraas <kmaraas@gnome.org>
* gui/component/select-names/e-select-names.c: Mark a string for translation.
diff --git a/addressbook/backend/ebook/e-book-listener.c b/addressbook/backend/ebook/e-book-listener.c
index 285c6646b2..aa05a87a2b 100644
--- a/addressbook/backend/ebook/e-book-listener.c
+++ b/addressbook/backend/ebook/e-book-listener.c
@@ -149,6 +149,25 @@ e_book_listener_queue_create_card_response (EBookListener *listener,
}
static void
+e_book_listener_queue_get_vcard_response (EBookListener *listener,
+ EBookStatus status,
+ const char *vcard)
+{
+ EBookListenerResponse *resp;
+
+ if (listener->priv->stopped)
+ return;
+
+ resp = g_new0 (EBookListenerResponse, 1);
+
+ resp->op = GetCardResponse;
+ resp->status = status;
+ resp->vcard = g_strdup (vcard);
+
+ e_book_listener_queue_response (listener, resp);
+}
+
+static void
e_book_listener_queue_get_cursor_response (EBookListener *listener,
EBookStatus status,
GNOME_Evolution_Addressbook_CardCursor cursor)
@@ -319,6 +338,20 @@ impl_BookListener_respond_modify_card (PortableServer_Servant servant,
}
static void
+impl_BookListener_respond_get_vcard (PortableServer_Servant servant,
+ const GNOME_Evolution_Addressbook_BookListener_CallStatus status,
+ const GNOME_Evolution_Addressbook_VCard card,
+ CORBA_Environment *ev)
+{
+ EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant));
+
+ e_book_listener_queue_get_vcard_response (
+ listener,
+ e_book_listener_convert_status (status),
+ g_strdup (card));
+}
+
+static void
impl_BookListener_respond_get_cursor (PortableServer_Servant servant,
const GNOME_Evolution_Addressbook_BookListener_CallStatus status,
const GNOME_Evolution_Addressbook_CardCursor cursor,
@@ -692,24 +725,25 @@ e_book_listener_get_epv (void)
{
POA_GNOME_Evolution_Addressbook_BookListener__epv *epv;
- epv = g_new0 (POA_GNOME_Evolution_Addressbook_BookListener__epv, 1);
+ epv = g_new0 (POA_GNOME_Evolution_Addressbook_BookListener__epv, 1);
- epv->notifyOpenBookProgress = impl_BookListener_report_open_book_progress;
- epv->notifyBookOpened = impl_BookListener_respond_open_book;
+ epv->notifyOpenBookProgress = impl_BookListener_report_open_book_progress;
+ epv->notifyBookOpened = impl_BookListener_respond_open_book;
- epv->notifyCardCreated = impl_BookListener_respond_create_card;
- epv->notifyCardRemoved = impl_BookListener_respond_remove_card;
- epv->notifyCardModified = impl_BookListener_respond_modify_card;
+ epv->notifyCardCreated = impl_BookListener_respond_create_card;
+ epv->notifyCardRemoved = impl_BookListener_respond_remove_card;
+ epv->notifyCardModified = impl_BookListener_respond_modify_card;
epv->notifyAuthenticationResult = impl_BookListener_respond_authentication_result;
- epv->notifySupportedFields = impl_BookListener_response_get_supported_fields;
+ epv->notifySupportedFields = impl_BookListener_response_get_supported_fields;
- epv->notifyCursorRequested = impl_BookListener_respond_get_cursor;
- epv->notifyViewRequested = impl_BookListener_respond_get_view;
- epv->notifyChangesRequested = impl_BookListener_respond_get_changes;
+ epv->notifyCardRequested = impl_BookListener_respond_get_vcard;
+ epv->notifyCursorRequested = impl_BookListener_respond_get_cursor;
+ epv->notifyViewRequested = impl_BookListener_respond_get_view;
+ epv->notifyChangesRequested = impl_BookListener_respond_get_changes;
- epv->notifyConnectionStatus = impl_BookListener_report_connection_status;
- epv->notifyWritable = impl_BookListener_report_writable;
+ epv->notifyConnectionStatus = impl_BookListener_report_connection_status;
+ epv->notifyWritable = impl_BookListener_report_writable;
return epv;
}
diff --git a/addressbook/backend/ebook/e-book-listener.h b/addressbook/backend/ebook/e-book-listener.h
index 16cb518ce5..f546c9a029 100644
--- a/addressbook/backend/ebook/e-book-listener.h
+++ b/addressbook/backend/ebook/e-book-listener.h
@@ -44,6 +44,7 @@ typedef enum {
CreateCardResponse,
RemoveCardResponse,
ModifyCardResponse,
+ GetCardResponse,
GetCursorResponse,
GetBookViewResponse,
GetChangesResponse,
@@ -86,6 +87,7 @@ typedef struct {
/* For Card[Added|Removed|Modified]Event */
char *id;
+ char *vcard;
} EBookListenerResponse;
EBookListener *e_book_listener_new (void);
diff --git a/addressbook/backend/ebook/e-book.c b/addressbook/backend/ebook/e-book.c
index 0046ad1730..1d5baf33a3 100644
--- a/addressbook/backend/ebook/e-book.c
+++ b/addressbook/backend/ebook/e-book.c
@@ -203,6 +203,44 @@ e_book_do_response_generic (EBook *book,
}
static void
+e_book_do_response_get_vcard (EBook *book,
+ EBookListenerResponse *resp)
+{
+ EBookOp *op;
+ ECard *card;
+
+ op = e_book_pop_op (book);
+
+ if (op == NULL) {
+ g_warning ("e_book_do_response_get_vcard: Cannot find operation "
+ "in local op queue!\n");
+ return;
+ }
+ if (resp->vcard != NULL) {
+
+ card = e_card_new(resp->vcard);
+
+ if (card != NULL) {
+ if (op->cb) {
+ if (op->active)
+ ((EBookCardCallback) op->cb) (book, resp->status, card, op->closure);
+ else
+ ((EBookCardCallback) op->cb) (book, E_BOOK_STATUS_CANCELLED, NULL, op->closure);
+ }
+
+ gtk_object_unref(GTK_OBJECT(card));
+ } else {
+ ((EBookCursorCallback) op->cb) (book, resp->status, NULL, op->closure);
+ }
+ } else {
+ ((EBookCardCallback) op->cb) (book, resp->status, NULL, op->closure);
+ }
+
+ g_free (resp->vcard);
+ e_book_op_free (op);
+}
+
+static void
e_book_do_response_get_cursor (EBook *book,
EBookListenerResponse *resp)
{
@@ -451,6 +489,9 @@ e_book_check_listener_queue (EBookListener *listener, EBook *book)
case AuthenticationResponse:
e_book_do_response_generic (book, resp);
break;
+ case GetCardResponse:
+ e_book_do_response_get_vcard (book, resp);
+ break;
case GetCursorResponse:
e_book_do_response_get_cursor (book, resp);
break;
@@ -744,80 +785,40 @@ e_book_authenticate_user (EBook *book,
/**
* e_book_get_card:
*/
-ECard *
-e_book_get_card (EBook *book,
- const char *id)
+guint
+e_book_get_card (EBook *book,
+ const char *id,
+ EBookCardCallback cb,
+ gpointer closure)
{
- char *vcard;
- ECard *card;
+ CORBA_Environment ev;
+ guint tag;
- g_return_val_if_fail (book != NULL, NULL);
- g_return_val_if_fail (E_IS_BOOK (book), NULL);
+ g_return_val_if_fail (book != NULL, 0);
+ g_return_val_if_fail (E_IS_BOOK (book), 0);
if (book->priv->load_state != URILoaded) {
g_warning ("e_book_get_card: No URI loaded!\n");
- return NULL;
- }
-
- vcard = e_book_get_vcard (book, id);
-
- if (vcard == NULL) {
- g_warning ("e_book_get_card: Got bogus VCard from PAS!\n");
- return NULL;
- }
-
- card = e_card_new (vcard);
- g_free(vcard);
-
- e_card_set_id(card, id);
- card->book = book;
- gtk_object_ref (GTK_OBJECT (card->book));
-
- return card;
-}
-
-/**
- * e_book_get_vcard:
- */
-char *
-e_book_get_vcard (EBook *book,
- const char *id)
-{
- CORBA_Environment ev;
- char *retval;
- char *vcard;
-
- g_return_val_if_fail (book != NULL, NULL);
- g_return_val_if_fail (E_IS_BOOK (book), NULL);
-
- if (book->priv->load_state != URILoaded) {
- g_warning ("e_book_get_vcard: No URI loaded!\n");
- return NULL;
+ return 0;
}
CORBA_exception_init (&ev);
- vcard = GNOME_Evolution_Addressbook_Book_getVCard (book->priv->corba_book,
- (GNOME_Evolution_Addressbook_CardId) id,
- &ev);
+ tag = e_book_queue_op (book, cb, closure, NULL);
+
+ GNOME_Evolution_Addressbook_Book_getVCard (book->priv->corba_book, (const GNOME_Evolution_Addressbook_VCard) id, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_get_vcard: Exception getting VCard from PAS!\n");
+ g_warning ("e_book_get_card: Exception "
+ "getting card!\n");
CORBA_exception_free (&ev);
- return NULL;
+ e_book_unqueue_op (book);
+ return 0;
}
CORBA_exception_free (&ev);
- if (vcard == NULL || strlen (vcard) == 0) {
- g_warning ("e_book_get_vcard: Got NULL VCard from PAS!\n");
- return NULL;
- }
-
- retval = g_strdup (vcard);
- CORBA_free (vcard);
-
- return retval;
+ return tag;
}
/* Deleting cards. */
diff --git a/addressbook/backend/ebook/e-book.h b/addressbook/backend/ebook/e-book.h
index 1c9386cfa7..cf90c8c57d 100644
--- a/addressbook/backend/ebook/e-book.h
+++ b/addressbook/backend/ebook/e-book.h
@@ -46,10 +46,11 @@ 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);
+typedef void (*EBookIdCallback) (EBook *book, EBookStatus status, const char *id, gpointer closure);
+typedef void (*EBookCardCallback) (EBook *book, EBookStatus status, ECard *card, 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);
-typedef void (*EBookFieldsCallback) (EBook *book, EBookStatus status, EList *fields, gpointer closure);
+typedef void (*EBookFieldsCallback) (EBook *book, EBookStatus status, EList *fields, gpointer closure);
/* Creating a new addressbook. */
EBook *e_book_new (void);
@@ -77,10 +78,10 @@ void e_book_authenticate_user (EBook *book,
gpointer closure);
/* Fetching cards. */
-ECard *e_book_get_card (EBook *book,
- const char *id);
-char *e_book_get_vcard (EBook *book,
- const char *id);
+guint e_book_get_card (EBook *book,
+ const char *id,
+ EBookCardCallback cb,
+ gpointer closure);
/* Deleting cards. */
gboolean e_book_remove_card (EBook *book,
diff --git a/addressbook/backend/ebook/e-card.c b/addressbook/backend/ebook/e-card.c
index 4b85c33868..5c1efb42f5 100644
--- a/addressbook/backend/ebook/e-card.c
+++ b/addressbook/backend/ebook/e-card.c
@@ -4171,13 +4171,9 @@ struct _CardLoadData {
};
static void
-card_load_cb (EBook *book, EBookStatus status, gpointer closure)
+card_get_cb (EBook *book, EBookStatus status, ECard *card, gpointer closure)
{
CardLoadData *data = (CardLoadData *) closure;
- ECard *card = NULL;
-
- if (status == E_BOOK_STATUS_SUCCESS)
- card = e_book_get_card (book, data->card_id);
if (data->cb != NULL)
data->cb (card, data->closure);
@@ -4186,6 +4182,15 @@ card_load_cb (EBook *book, EBookStatus status, gpointer closure)
g_free (data);
}
+static void
+card_load_cb (EBook *book, EBookStatus status, gpointer closure)
+{
+ CardLoadData *data = (CardLoadData *) closure;
+
+ if (status == E_BOOK_STATUS_SUCCESS)
+ e_book_get_card (book, data->card_id, card_get_cb, closure);
+}
+
void
e_card_load_uri (const gchar *uri, ECardCallback cb, gpointer closure)
{
diff --git a/addressbook/backend/ebook/test-client.c b/addressbook/backend/ebook/test-client.c
index 6ffa099ab3..cc7572c24c 100644
--- a/addressbook/backend/ebook/test-client.c
+++ b/addressbook/backend/ebook/test-client.c
@@ -66,10 +66,23 @@ get_cursor_cb (EBook *book, EBookStatus status, ECardCursor *cursor, gpointer cl
}
static void
-add_card_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure)
+get_card_cb (EBook *book, EBookStatus status, ECard *card, gpointer closure)
{
char *vcard;
- ECard *card;
+
+ vcard = e_card_get_vcard(card);
+ printf ("Card added: [%s]\n", vcard);
+ g_free(vcard);
+ gtk_object_unref(GTK_OBJECT(card));
+
+ printf ("Getting cards..\n");
+ e_book_get_cursor(book, "", get_cursor_cb, NULL);
+ printf ("Done getting all cards.\n");
+}
+
+static void
+add_card_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure)
+{
GTimer *timer;
printf ("Status: %d\n", status);
@@ -78,18 +91,9 @@ add_card_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure)
timer = g_timer_new ();
g_timer_start (timer);
- card = e_book_get_card (book, id);
+ e_book_get_card (book, id, get_card_cb, closure);
g_timer_stop (timer);
-
- vcard = e_card_get_vcard(card);
printf ("%g\n", g_timer_elapsed (timer, NULL));
- printf ("Card added: [%s]\n", vcard);
- g_free(vcard);
- gtk_object_unref(GTK_OBJECT(card));
-
- printf ("Getting cards..\n");
- e_book_get_cursor(book, "", get_cursor_cb, NULL);
- printf ("Done getting all cards.\n");
}
static void
diff --git a/addressbook/backend/idl/addressbook.idl b/addressbook/backend/idl/addressbook.idl
index 7562b148a2..342482d573 100644
--- a/addressbook/backend/idl/addressbook.idl
+++ b/addressbook/backend/idl/addressbook.idl
@@ -45,19 +45,7 @@ module Addressbook {
/*
* Fetching cards in the addresbook.
*/
- VCard getVCard (in CardId id);
-
- /*
- * Permissions. the first form is general write
- * permission (whether or not the user can add or
- * remove or modify any entry in the addressbook.)
- *
- * if can_write returns TRUE, can_write_card can still
- * return FALSE if the user doesn't have permission to
- * modify/remove that specific card.
- */
- boolean isWriteable ();
- boolean isCardWriteable (in CardId Id);
+ void getVCard (in CardId id);
void authenticateUser (in string user, in string passwd);
@@ -123,6 +111,8 @@ module Addressbook {
void notifyBookOpened (in CallStatus status, in Book book);
+ void notifyCardRequested (in CallStatus status, in VCard card);
+
void notifyCursorRequested (in CallStatus status, in CardCursor cursor);
void notifyViewRequested (in CallStatus status, in BookView view);
@@ -168,4 +158,3 @@ module Addressbook {
};
};
};
-
diff --git a/addressbook/backend/pas/pas-backend-file.c b/addressbook/backend/pas/pas-backend-file.c
index 56ce7dcd3d..f385f45ad7 100644
--- a/addressbook/backend/pas/pas-backend-file.c
+++ b/addressbook/backend/pas/pas-backend-file.c
@@ -600,13 +600,13 @@ pas_backend_file_search (PASBackendFile *bf,
if (card_count >= card_threshold) {
cards = g_list_reverse (cards);
pas_book_view_notify_add (view->book_view, cards);
- /* Clean up the handed-off data. */
+ /* Clean up the handed-off data. */
g_list_foreach (cards, (GFunc)g_free, NULL);
g_list_free (cards);
cards = NULL;
card_count = 0;
- /* Yeah, this scheme is over-complicated. But I like it. */
+ /* Yeah, this scheme is overly complicated. But I like it. */
if (card_threshold < card_threshold_max) {
card_threshold = MIN (2*card_threshold, card_threshold_max);
}
@@ -1024,6 +1024,39 @@ pas_backend_file_build_all_cards_list(PASBackend *backend,
}
static void
+pas_backend_file_process_get_vcard (PASBackend *backend,
+ PASBook *book,
+ PASRequest *req)
+{
+ PASBackendFile *bf;
+ DB *db;
+ DBT id_dbt, vcard_dbt;
+ int db_error = 0;
+ char *card;
+ GNOME_Evolution_Addressbook_BookListener_CallStatus status;
+
+ bf = PAS_BACKEND_FILE (pas_book_get_backend (book));
+ db = bf->priv->file_db;
+
+ string_to_dbt (req->id, &id_dbt);
+ memset (&vcard_dbt, 0, sizeof (vcard_dbt));
+
+ db_error = db->get (db, NULL, &id_dbt, &vcard_dbt, 0);
+
+ if (db_error == 0) {
+ card = vcard_dbt.data;
+ status = GNOME_Evolution_Addressbook_BookListener_Success;
+ } else {
+ card = NULL;
+ status = GNOME_Evolution_Addressbook_BookListener_CardNotFound;
+ }
+
+ pas_book_respond_get_vcard (book,
+ status,
+ card);
+}
+
+static void
pas_backend_file_process_get_cursor (PASBackend *backend,
PASBook *book,
PASRequest *req)
@@ -1242,37 +1275,6 @@ pas_backend_file_process_get_supported_fields (PASBackend *backend,
fields);
}
-static gboolean
-can_write (PASBackend *backend)
-{
- PASBackendFile *bf = PAS_BACKEND_FILE (backend);
- char *path = pas_backend_file_extract_path_from_uri (bf->priv->uri);
- gboolean retval;
-
- retval = (access (path, W_OK) != -1);
-
- g_free (path);
-
- return retval;
-}
-
-static gboolean
-pas_backend_file_can_write (PASBook *book)
-{
- PASBackend* backend = pas_book_get_backend (book);
-
- return can_write(backend);
-}
-
-static gboolean
-pas_backend_file_can_write_card (PASBook *book,
- const char *id)
-{
- PASBackend* backend = pas_book_get_backend (book);
-
- return can_write(backend);
-}
-
static void
pas_backend_file_process_client_requests (PASBook *book)
{
@@ -1301,6 +1303,10 @@ pas_backend_file_process_client_requests (PASBook *book)
case CheckConnection:
pas_backend_file_process_check_connection (backend, book, req);
break;
+
+ case GetVCard:
+ pas_backend_file_process_get_vcard (backend, book, req);
+ break;
case GetCursor:
pas_backend_file_process_get_cursor (backend, book, req);
@@ -1336,35 +1342,6 @@ pas_backend_file_book_destroy_cb (PASBook *book, gpointer data)
pas_backend_remove_client (PAS_BACKEND (backend), book);
}
-static char *
-pas_backend_file_get_vcard (PASBook *book, const char *id)
-{
- PASBackendFile *bf;
- DBT id_dbt, vcard_dbt;
- DB *db;
- int db_error;
-
- bf = PAS_BACKEND_FILE (pas_book_get_backend (book));
- db = bf->priv->file_db;
-
- string_to_dbt (id, &id_dbt);
- memset (&vcard_dbt, 0, sizeof (vcard_dbt));
-
- db_error = db->get (db, NULL, &id_dbt, &vcard_dbt, 0);
- if (db_error == 0) {
- /* success */
- return g_strdup (vcard_dbt.data);
- }
- else if (db_error == 1) {
- /* key was not in file */
- return g_strdup (""); /* XXX */
- }
- else /* if (db_error < 0)*/ {
- /* error */
- return g_strdup (""); /* XXX */
- }
-}
-
static gboolean
pas_backend_file_upgrade_db (PASBackendFile *bf, char *old_version)
{
@@ -1565,11 +1542,7 @@ pas_backend_file_add_client (PASBackend *backend,
bf = PAS_BACKEND_FILE (backend);
- book = pas_book_new (
- backend, listener,
- pas_backend_file_get_vcard,
- pas_backend_file_can_write,
- pas_backend_file_can_write_card);
+ book = pas_book_new (backend, listener);
if (!book) {
if (!bf->priv->clients)
diff --git a/addressbook/backend/pas/pas-book.c b/addressbook/backend/pas/pas-book.c
index ec8842135d..4461d63c44 100644
--- a/addressbook/backend/pas/pas-book.c
+++ b/addressbook/backend/pas/pas-book.c
@@ -23,9 +23,6 @@ static guint pas_book_signals [LAST_SIGNAL];
struct _PASBookPrivate {
PASBackend *backend;
GNOME_Evolution_Addressbook_BookListener listener;
- PASBookGetVCardFn get_vcard;
- PASBookCanWriteFn can_write;
- PASBookCanWriteCardFn can_write_card;
GList *request_queue;
gint idle_id;
@@ -107,6 +104,18 @@ pas_book_queue_get_cursor (PASBook *book, const char *search)
}
static void
+pas_book_queue_get_vcard (PASBook *book, const char *id)
+{
+ PASRequest *req;
+
+ req = g_new0 (PASRequest, 1);
+ req->op = GetVCard;
+ req->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)
{
@@ -191,45 +200,14 @@ pas_book_queue_check_connection (PASBook *book)
pas_book_queue_request (book, req);
}
-static CORBA_char *
+static void
impl_GNOME_Evolution_Addressbook_Book_getVCard (PortableServer_Servant servant,
const GNOME_Evolution_Addressbook_CardId id,
CORBA_Environment *ev)
{
- PASBook *book = PAS_BOOK (bonobo_object_from_servant (servant));
- char *vcard;
- CORBA_char *retval;
-
- vcard = (book->priv->get_vcard) (book, (const char *) id);
- retval = CORBA_string_dup (vcard);
- g_free (vcard);
-
- return retval;
-}
-
-static CORBA_boolean
-impl_GNOME_Evolution_Addressbook_Book_isWriteable (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- PASBook *book = PAS_BOOK (bonobo_object_from_servant (servant));
- CORBA_boolean retval;
-
- retval = (book->priv->can_write) (book);
-
- return retval;
-}
-
-static CORBA_boolean
-impl_GNOME_Evolution_Addressbook_Book_isCardWriteable (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_CardId id,
- CORBA_Environment *ev)
-{
- PASBook *book = PAS_BOOK (bonobo_object_from_servant (servant));
- CORBA_boolean retval;
-
- retval = (book->priv->can_write_card) (book, (const char *) id);
+ PASBook *book = PAS_BOOK (bonobo_object_from_servant (servant));
- return retval;
+ pas_book_queue_get_vcard (book, id);
}
static void
@@ -681,10 +659,7 @@ pas_book_report_writable (PASBook *book,
static gboolean
pas_book_construct (PASBook *book,
PASBackend *backend,
- GNOME_Evolution_Addressbook_BookListener listener,
- PASBookGetVCardFn get_vcard,
- PASBookCanWriteFn can_write,
- PASBookCanWriteCardFn can_write_card)
+ GNOME_Evolution_Addressbook_BookListener listener)
{
POA_GNOME_Evolution_Addressbook_Book *servant;
CORBA_Environment ev;
@@ -693,9 +668,6 @@ pas_book_construct (PASBook *book,
g_assert (book != NULL);
g_assert (PAS_IS_BOOK (book));
g_assert (listener != CORBA_OBJECT_NIL);
- g_assert (get_vcard != NULL);
- g_assert (can_write != NULL);
- g_assert (can_write_card != NULL);
servant = (POA_GNOME_Evolution_Addressbook_Book *) g_new0 (BonoboObjectServant, 1);
servant->vepv = &pas_book_vepv;
@@ -730,9 +702,6 @@ pas_book_construct (PASBook *book,
CORBA_exception_free (&ev);
book->priv->listener = listener;
- book->priv->get_vcard = get_vcard;
- book->priv->can_write = can_write;
- book->priv->can_write_card = can_write_card;
book->priv->backend = backend;
return TRUE;
@@ -743,20 +712,15 @@ pas_book_construct (PASBook *book,
*/
PASBook *
pas_book_new (PASBackend *backend,
- GNOME_Evolution_Addressbook_BookListener listener,
- PASBookGetVCardFn get_vcard,
- PASBookCanWriteFn can_write,
- PASBookCanWriteCardFn can_write_card)
+ GNOME_Evolution_Addressbook_BookListener listener)
{
PASBook *book;
g_return_val_if_fail (listener != CORBA_OBJECT_NIL, NULL);
- g_return_val_if_fail (get_vcard != NULL, NULL);
book = gtk_type_new (pas_book_get_type ());
- if (! pas_book_construct (book, backend, listener,
- get_vcard, can_write, can_write_card)) {
+ if (! pas_book_construct (book, backend, listener)) {
gtk_object_unref (GTK_OBJECT (book));
return NULL;
@@ -802,8 +766,6 @@ pas_book_get_epv (void)
epv = g_new0 (POA_GNOME_Evolution_Addressbook_Book__epv, 1);
epv->getVCard = impl_GNOME_Evolution_Addressbook_Book_getVCard;
- epv->isWriteable = impl_GNOME_Evolution_Addressbook_Book_isWriteable;
- epv->isCardWriteable = impl_GNOME_Evolution_Addressbook_Book_isCardWriteable;
epv->authenticateUser = impl_GNOME_Evolution_Addressbook_Book_authenticateUser;
epv->addCard = impl_GNOME_Evolution_Addressbook_Book_addCard;
epv->removeCard = impl_GNOME_Evolution_Addressbook_Book_removeCard;
diff --git a/addressbook/backend/pas/pas-book.h b/addressbook/backend/pas/pas-book.h
index 6cb6268553..6f5832d914 100644
--- a/addressbook/backend/pas/pas-book.h
+++ b/addressbook/backend/pas/pas-book.h
@@ -28,6 +28,7 @@ typedef enum {
CreateCard,
RemoveCard,
ModifyCard,
+ GetVCard,
GetCursor,
GetBookView,
GetChanges,
@@ -60,15 +61,11 @@ typedef struct {
void (*requests_queued) (void);
} PASBookClass;
-typedef char * (*PASBookGetVCardFn) (PASBook *book, const char *id);
typedef gboolean (*PASBookCanWriteFn) (PASBook *book);
typedef gboolean (*PASBookCanWriteCardFn) (PASBook *book, const char *id);
PASBook *pas_book_new (PASBackend *backend,
- GNOME_Evolution_Addressbook_BookListener listener,
- PASBookGetVCardFn get_vcard,
- PASBookCanWriteFn can_write,
- PASBookCanWriteCardFn can_write_card);
+ GNOME_Evolution_Addressbook_BookListener listener);
PASBackend *pas_book_get_backend (PASBook *book);
GNOME_Evolution_Addressbook_BookListener pas_book_get_listener (PASBook *book);
int pas_book_check_pending (PASBook *book);
@@ -94,6 +91,9 @@ void pas_book_respond_get_cursor (PASBook
void pas_book_respond_get_book_view (PASBook *book,
GNOME_Evolution_Addressbook_BookListener_CallStatus status,
PASBookView *book_view);
+void pas_book_respond_get_vcard (PASBook *book,
+ GNOME_Evolution_Addressbook_BookListener_CallStatus status,
+ char *vcard);
void pas_book_respond_get_changes (PASBook *book,
GNOME_Evolution_Addressbook_BookListener_CallStatus status,
PASBookView *book_view);
@@ -103,9 +103,6 @@ void pas_book_report_connection (PASBook
void pas_book_report_writable (PASBook *book,
gboolean writable);
-gboolean pas_book_can_write (PASBook *book);
-gboolean pas_book_can_write_card (PASBook *book,
- const char *id);
GtkType pas_book_get_type (void);
#define PAS_BOOK_TYPE (pas_book_get_type ())