aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog12
-rw-r--r--addressbook/backend/ebook/e-book-listener.c10
-rw-r--r--addressbook/backend/ebook/e-book-listener.h13
-rw-r--r--addressbook/backend/ebook/e-book.c140
4 files changed, 113 insertions, 62 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index a720f63274..dbb085268e 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,5 +1,17 @@
2001-06-11 Christopher James Lahey <clahey@ximian.com>
+ * backend/ebook/e-book-listener.c, backend/ebook/e-book-listener.h
+ (e_book_listener_unpop_response): Added this function to put a
+ response back into the queue.
+
+ * backend/ebook/e-book.c (e_book_check_listener_queue,
+ e_book_queue_op): Handle the case where the op hasn't been queued
+ yet when we get the response. In this case we unpop the response.
+ Also, when queueing an op, we check to see if there are any
+ responses waiting.
+
+2001-06-11 Christopher James Lahey <clahey@ximian.com>
+
* backend/ebook/e-card-compare.c, backend/ebook/e-card-compare.h
(e_card_locate_match_full): Added this function to let you do
slightly more complicated searches.
diff --git a/addressbook/backend/ebook/e-book-listener.c b/addressbook/backend/ebook/e-book-listener.c
index f9d4f67f97..98ae9820a3 100644
--- a/addressbook/backend/ebook/e-book-listener.c
+++ b/addressbook/backend/ebook/e-book-listener.c
@@ -468,6 +468,16 @@ e_book_listener_pop_response (EBookListener *listener)
return resp;
}
+void
+e_book_listener_unpop_response (EBookListener *listener,
+ EBookListenerResponse *resp)
+{
+ g_return_if_fail (listener != NULL);
+ g_return_if_fail (E_IS_BOOK_LISTENER (listener));
+
+ listener->priv->response_queue = g_list_prepend (listener->priv->response_queue, resp);
+}
+
static EBookStatus
e_book_listener_convert_status (const GNOME_Evolution_Addressbook_BookListener_CallStatus status)
{
diff --git a/addressbook/backend/ebook/e-book-listener.h b/addressbook/backend/ebook/e-book-listener.h
index 84cdfecced..ae79dd1748 100644
--- a/addressbook/backend/ebook/e-book-listener.h
+++ b/addressbook/backend/ebook/e-book-listener.h
@@ -88,12 +88,15 @@ typedef struct {
char *id;
} EBookListenerResponse;
-EBookListener *e_book_listener_new (void);
-int e_book_listener_check_pending (EBookListener *listener);
-EBookListenerResponse *e_book_listener_pop_response (EBookListener *listener);
-GtkType e_book_listener_get_type (void);
+EBookListener *e_book_listener_new (void);
+int e_book_listener_check_pending (EBookListener *listener);
+EBookListenerResponse *e_book_listener_pop_response (EBookListener *listener);
+void e_book_listener_unpop_response (EBookListener *listener,
+ EBookListenerResponse *response);
-POA_GNOME_Evolution_Addressbook_BookListener__epv *e_book_listener_get_epv (void);
+GtkType e_book_listener_get_type (void);
+
+POA_GNOME_Evolution_Addressbook_BookListener__epv *e_book_listener_get_epv (void);
#define E_BOOK_LISTENER_TYPE (e_book_listener_get_type ())
#define E_BOOK_LISTENER(o) (GTK_CHECK_CAST ((o), E_BOOK_LISTENER_TYPE, EBookListener))
diff --git a/addressbook/backend/ebook/e-book.c b/addressbook/backend/ebook/e-book.c
index a5231f8303..5217d6ef90 100644
--- a/addressbook/backend/ebook/e-book.c
+++ b/addressbook/backend/ebook/e-book.c
@@ -64,6 +64,8 @@ typedef struct {
EBookViewListener *listener;
} EBookOp;
+static gboolean check_listener_queue_idle (gpointer closure);
+
/*
* Local response queue management.
*/
@@ -75,6 +77,8 @@ e_book_queue_op (EBook *book,
{
EBookOp *op;
+ g_print ("Queue Op\n");
+
op = g_new0 (EBookOp, 1);
op->tag = book->priv->op_tag++;
op->active = TRUE;
@@ -85,6 +89,11 @@ e_book_queue_op (EBook *book,
book->priv->pending_ops =
g_list_append (book->priv->pending_ops, op);
+ if (e_book_listener_check_pending (book->priv->listener)) {
+ gtk_object_ref (GTK_OBJECT (book));
+ g_idle_add (check_listener_queue_idle, book);
+ }
+
return op->tag;
}
@@ -94,6 +103,8 @@ e_book_pop_op (EBook *book)
GList *popped;
EBookOp *op;
+ g_print ("Pop Op\n");
+
if (book->priv->pending_ops == NULL)
return NULL;
@@ -126,7 +137,7 @@ e_book_cancel_op (EBook *book, guint tag)
return cancelled;
}
-static void
+static gboolean
e_book_do_response_create_card (EBook *book,
EBookListenerResponse *resp)
{
@@ -135,18 +146,17 @@ e_book_do_response_create_card (EBook *book,
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;
+ return FALSE;
}
if (op->cb)
((EBookIdCallback) op->cb) (book, resp->status, resp->id, op->closure);
g_free (resp->id);
g_free (op);
+ return TRUE;
}
-static void
+static gboolean
e_book_do_response_generic (EBook *book,
EBookListenerResponse *resp)
{
@@ -155,17 +165,17 @@ e_book_do_response_generic (EBook *book,
op = e_book_pop_op (book);
if (op == NULL) {
- g_warning ("e_book_do_response_generic: Cannot find operation "
- "in local op queue!\n");
+ return FALSE;
}
if (op->cb)
((EBookCallback) op->cb) (book, resp->status, op->closure);
g_free (op);
+ return TRUE;
}
-static void
+static gboolean
e_book_do_response_get_cursor (EBook *book,
EBookListenerResponse *resp)
{
@@ -176,9 +186,7 @@ e_book_do_response_get_cursor (EBook *book,
op = e_book_pop_op (book);
if (op == NULL) {
- g_warning ("e_book_do_response_get_cursor: Cannot find operation "
- "in local op queue!\n");
- return;
+ return FALSE;
}
cursor = e_card_cursor_new(resp->cursor);
@@ -207,11 +215,12 @@ e_book_do_response_get_cursor (EBook *book,
gtk_object_unref(GTK_OBJECT(cursor));
g_free (op);
+ return TRUE;
}
-static void
+static gboolean
e_book_do_response_get_view (EBook *book,
EBookListenerResponse *resp)
{
@@ -222,9 +231,7 @@ e_book_do_response_get_view (EBook *book,
op = e_book_pop_op (book);
if (op == NULL) {
- g_warning ("e_book_do_response_get_view: Cannot find operation "
- "in local op queue!\n");
- return;
+ return FALSE;
}
book_view = e_book_view_new(resp->book_view, op->listener);
@@ -257,9 +264,10 @@ e_book_do_response_get_view (EBook *book,
bonobo_object_unref(BONOBO_OBJECT(op->listener));
g_free (op);
+ return TRUE;
}
-static void
+static gboolean
e_book_do_response_get_changes (EBook *book,
EBookListenerResponse *resp)
{
@@ -270,9 +278,7 @@ e_book_do_response_get_changes (EBook *book,
op = e_book_pop_op (book);
if (op == NULL) {
- g_warning ("e_book_do_response_get_changes: Cannot find operation "
- "in local op queue!\n");
- return;
+ return FALSE;
}
book_view = e_book_view_new (resp->book_view, op->listener);
@@ -302,30 +308,53 @@ e_book_do_response_get_changes (EBook *book,
bonobo_object_unref(BONOBO_OBJECT(op->listener));
g_free (op);
+ return TRUE;
}
-static void
+static gboolean
e_book_do_response_open (EBook *book,
EBookListenerResponse *resp)
{
EBookOp *op;
+ op = e_book_pop_op (book);
+
+ if (op == NULL) {
+ return FALSE;
+ }
+
if (resp->status == E_BOOK_STATUS_SUCCESS) {
book->priv->corba_book = resp->book;
book->priv->load_state = URILoaded;
}
+ if (op->cb)
+ ((EBookCallback) op->cb) (book, resp->status, op->closure);
+ g_free (op);
+ return TRUE;
+}
+
+static gboolean
+e_book_do_response_get_supported_fields (EBook *book,
+ EBookListenerResponse *resp)
+{
+ EBookOp *op;
+
op = e_book_pop_op (book);
if (op == NULL) {
- g_warning ("e_book_do_response_open: Cannot find operation "
- "in local op queue!\n");
- return;
+ return FALSE;
+ }
+
+ if (op->cb) {
+ if (op->active)
+ ((EBookFieldsCallback) op->cb) (book, resp->status, resp->fields, op->closure);
+ else
+ ((EBookFieldsCallback) op->cb) (book, E_BOOK_STATUS_CANCELLED, NULL, op->closure);
}
- if (op->cb)
- ((EBookCallback) op->cb) (book, resp->status, op->closure);
g_free (op);
+ return TRUE;
}
static void
@@ -354,30 +383,6 @@ e_book_do_writable_event (EBook *book,
resp->writable);
}
-static void
-e_book_do_response_get_supported_fields (EBook *book,
- EBookListenerResponse *resp)
-{
- EBookOp *op;
-
- op = e_book_pop_op (book);
-
- if (op == NULL) {
- g_warning ("e_book_do_response_get_supported_fields: Cannot find operation "
- "in local op queue!\n");
- return;
- }
-
- if (op->cb) {
- if (op->active)
- ((EBookFieldsCallback) op->cb) (book, resp->status, resp->fields, op->closure);
- else
- ((EBookFieldsCallback) op->cb) (book, E_BOOK_STATUS_CANCELLED, NULL, op->closure);
- }
-
- g_free (op);
-}
-
/*
* Reading notices out of the EBookListener's queue.
*/
@@ -385,6 +390,7 @@ static void
e_book_check_listener_queue (EBookListener *listener, EBook *book)
{
EBookListenerResponse *resp;
+ gboolean handled = FALSE;
resp = e_book_listener_pop_response (listener);
@@ -393,46 +399,66 @@ e_book_check_listener_queue (EBookListener *listener, EBook *book)
switch (resp->op) {
case CreateCardResponse:
- e_book_do_response_create_card (book, resp);
+ handled = e_book_do_response_create_card (book, resp);
break;
case RemoveCardResponse:
case ModifyCardResponse:
case AuthenticationResponse:
- e_book_do_response_generic (book, resp);
+ handled = e_book_do_response_generic (book, resp);
break;
case GetCursorResponse:
- e_book_do_response_get_cursor (book, resp);
+ handled = e_book_do_response_get_cursor (book, resp);
break;
case GetBookViewResponse:
- e_book_do_response_get_view(book, resp);
+ handled = e_book_do_response_get_view(book, resp);
break;
case GetChangesResponse:
- e_book_do_response_get_changes(book, resp);
+ handled = e_book_do_response_get_changes(book, resp);
break;
case OpenBookResponse:
- e_book_do_response_open (book, resp);
+ handled = e_book_do_response_open (book, resp);
break;
case GetSupportedFieldsResponse:
- e_book_do_response_get_supported_fields (book, resp);
+ handled = e_book_do_response_get_supported_fields (book, resp);
break;
case OpenProgressEvent:
e_book_do_progress_event (book, resp);
+ handled = TRUE;
break;
case LinkStatusEvent:
e_book_do_link_event (book, resp);
+ handled = TRUE;
break;
case WritableStatusEvent:
e_book_do_writable_event (book, resp);
+ handled = TRUE;
break;
default:
g_error ("EBook: Unknown operation %d in listener queue!\n",
resp->op);
+ handled = TRUE;
+ break;
}
- g_free (resp);
+ if (handled)
+ g_free (resp);
+ else
+ e_book_listener_unpop_response (listener, resp);
}
+static gboolean
+check_listener_queue_idle (gpointer closure)
+{
+ EBook *book = closure;
+ if (!GTK_OBJECT_DESTROYED (GTK_OBJECT (book))) {
+ e_book_check_listener_queue (book->priv->listener, book);
+ }
+ gtk_object_unref (GTK_OBJECT (book));
+ return FALSE;
+}
+
+
/**
* e_book_load_uri:
*/