aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/ChangeLog127
-rw-r--r--addressbook/backend/ebook/e-book-listener.c8
-rw-r--r--addressbook/backend/ebook/e-book-view-listener.c36
-rw-r--r--addressbook/backend/ebook/e-book-view-listener.h6
-rw-r--r--addressbook/backend/ebook/e-book-view.c7
-rw-r--r--addressbook/backend/ebook/e-book-view.h2
-rw-r--r--addressbook/backend/ebook/e-book.c97
-rw-r--r--addressbook/backend/ebook/e-book.h6
8 files changed, 243 insertions, 46 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index e913e1f81a..35fc69f3d0 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,130 @@
+2003-02-08 Chris Toshok <toshok@ximian.com>
+
+ [ huge change, all for 1 little performance problem :) fixes #18207 ]
+ * gui/widgets/e-addressbook-model.c (get_view): use
+ e_book_check_static_capability here to make things a little
+ prettier.
+ (remove_card): complain about my life, and add code to use one
+ "model_changed" signal if we get back a list of cards instead of
+ multiple "card_removed" signals.
+
+ * gui/widgets/e-addressbook-model.h: little clean up.
+
+ * gui/widgets/e-addressbook-view.c (delete): write a bulk-remove
+ case for this. if the backend supports it, send all the ids at
+ once. otherwise loop over the ids.
+ (e_addressbook_view_delete_selection): fake a CardAndBook
+ structure and call delete, instead of duplicating the code in 2
+ places.
+
+ * gui/component/addressbook.c (delete_contact_cb): don't call
+ e_contact_editor_confirm_delete here, it's handled by the
+ EAddressbookView.
+
+ * backend/pas/pas-card-cursor.c (pas_card_cursor_construct): fix a
+ compiler warning about a stupid crash.
+
+ * backend/pas/pas-book.h (PASOperation): RemoveCard ->
+ RemoveCards.
+ (PASRemoveCardsReques): char *id -> GList *ids.
+ (PASRequest): PASRemoveCardRequest -> PASRemoveCardsRequest.
+
+ * backend/pas/pas-book.c (pas_book_queue_remove_cards): build up a
+ GList from the id sequence.
+ (pas_book_respond_remove): notifyCardRemoved ->
+ notifyCardsRemoved.
+ (impl_GNOME_Evolution_Addressbook_Book_removeCards): rename.
+ (pas_book_free_request): free the idlist for RemoveCards.
+ (pas_book_class_init): removeCard -> removeCards.
+
+ * backend/pas/pas-book-view.h: change prototype for
+ pas_book_view_notify_remove, and add prototype for
+ pas_book_view_notify_remove_1.
+
+ * backend/pas/pas-book-view.c (pas_book_view_notify_remove_1):
+ build up a list and call pas_book_view_notify_remove.
+ (pas_book_view_notify_remove): build up the corba id sequence and
+ call BookViewListener::notifyCardsRemoved.
+
+ * backend/pas/pas-backend.h: remove_card -> remove_cards.
+
+ * backend/pas/pas-backend.c (pas_backend_remove_cards): rename
+ from _remove_card.
+ (process_client_requests): RemoveCard -> RemoveCards and
+ _remove_card -> _remove_cards.
+
+ * backend/pas/pas-backend-ldap.c (check_schema_support):
+ g_strcasecmp -> g_ascii_strcasecmp.
+ (remove_card_handler): _remove => _remove_1.
+ (modify_card_modify_handler): same.
+ (pas_backend_ldap_process_remove_cards): rename from _remove_card.
+ (pas_backend_ldap_class_init): _remove_card -> _remove_cards.
+
+ * backend/pas/pas-backend-file.c (pas_backend_file_class_init):
+ remove_card -> remove_cards.
+ (pas_backend_file_get_static_capabilities): add "bulk-removes".
+ (pas_backend_file_process_remove_cards): rewrite this function
+ largely, so that it handles lists of ids. first we loop through
+ and for every successful deletion we build a list of deleted
+ ECards. Then for each view we build a list (a subset of the
+ deleted ECard list) and pass back that list to the view.
+ (pas_backend_file_process_modify_card): use _remove_1 instead of
+ _remove.
+ (ecard_matches_search): new function.
+
+ * backend/pas/pas-backend-card-sexp.c
+ (pas_backend_card_sexp_match_vcard): rewrite in terms of
+ _match_ecard.
+ (pas_backend_card_sexp_match_ecard): new function, the guts from
+ _match_vcard.
+
+ * backend/pas/pas-backend-card-sexp.h: add prototype for
+ pas_backend_card_sexp_match_ecard.
+
+ * backend/idl/addressbook.idl: the card removal stuff now takes
+ CardIdList.
+
+ * backend/ebook/e-book.c (e_book_get_static_capabilities): cache
+ successful capability queries (since they're static).
+ (e_book_check_static_capability): new, convenience function to
+ check if a particular capability is supported.
+ (e_book_remove_card_by_id): build a single element GList and call
+ e_book_remove_cards.
+ (e_book_remove_cards): build up a CORBA sequence from the GList
+ and call Book::removeCards.
+ (e_book_dispose): free the cached capabilities string.
+
+ * backend/ebook/e-book.h: add new prototypes for
+ e_book_check_static_capability and e_book_remove_cards.
+
+ * backend/ebook/e-book-view.h (struct _EBookViewClass): rename
+ "card_removed" signal to "cards_removed".
+
+ * backend/ebook/e-book-view.c (e_book_view_do_removed_event): id
+ -> ids, and free the id list.
+ (e_book_view_check_listener_queue): CardRemovedEvent ->
+ CardsRemovedEvent.
+
+ * backend/ebook/e-book-view-listener.c
+ (e_book_view_listener_queue_response): free the id list.
+ (e_book_view_listener_queue_idlist_event): new function, used for
+ cards_removed.
+ (e_book_view_listener_queue_status_event): id -> ids.
+ (e_book_view_listener_queue_sequence_event): same.
+ (e_book_view_listener_queue_message_event): same.
+ (impl_BookViewListener_notify_cards_removed): call
+ queue_idlist_event.
+ (e_book_view_listener_dispose): free the id list.
+ (e_book_view_listener_class_init): track change to idl call.
+
+ * backend/ebook/e-book-view-listener.h
+ (EBookViewListenerOperation): CardRemovedEvent ->
+ CardsRemovedEvent.
+ (EBookViewListenerResponse): char *id -> GList *ids.
+
+ * backend/ebook/e-book-listener.c
+ (impl_BookListener_respond_remove_cards): rename from remove_card.
+
2003-02-06 Chris Toshok <toshok@ximian.com>
* gui/component/e-address-popup.c (email_table_save_card_cb):
diff --git a/addressbook/backend/ebook/e-book-listener.c b/addressbook/backend/ebook/e-book-listener.c
index ecb9c0e9a8..9d6d876045 100644
--- a/addressbook/backend/ebook/e-book-listener.c
+++ b/addressbook/backend/ebook/e-book-listener.c
@@ -408,9 +408,9 @@ impl_BookListener_respond_create_card (PortableServer_Servant
}
static void
-impl_BookListener_respond_remove_card (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_BookListener_CallStatus status,
- CORBA_Environment *ev)
+impl_BookListener_respond_remove_cards (PortableServer_Servant servant,
+ const GNOME_Evolution_Addressbook_BookListener_CallStatus status,
+ CORBA_Environment *ev)
{
EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant));
@@ -777,7 +777,7 @@ e_book_listener_class_init (EBookListenerClass *klass)
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->notifyCardsRemoved = impl_BookListener_respond_remove_cards;
epv->notifyCardModified = impl_BookListener_respond_modify_card;
epv->notifyAuthenticationResult = impl_BookListener_respond_authentication_result;
epv->notifySupportedFields = impl_BookListener_response_get_supported_fields;
diff --git a/addressbook/backend/ebook/e-book-view-listener.c b/addressbook/backend/ebook/e-book-view-listener.c
index fe50cf037b..668c442a9a 100644
--- a/addressbook/backend/ebook/e-book-view-listener.c
+++ b/addressbook/backend/ebook/e-book-view-listener.c
@@ -67,7 +67,8 @@ e_book_view_listener_queue_response (EBookViewListener *listener,
if (listener->priv->stopped) {
/* Free response and return */
- g_free (response->id);
+ g_list_foreach (response->ids, (GFunc)g_free, NULL);
+ g_list_free (response->ids);
g_list_foreach (response->cards, (GFunc) g_object_unref, NULL);
g_list_free (response->cards);
g_free (response->message);
@@ -124,7 +125,7 @@ e_book_view_listener_queue_status_event (EBookViewListener *listener,
resp->op = op;
resp->status = status;
- resp->id = NULL;
+ resp->ids = NULL;
resp->cards = NULL;
resp->message = NULL;
@@ -133,11 +134,12 @@ e_book_view_listener_queue_status_event (EBookViewListener *listener,
/* Add, Remove, Modify */
static void
-e_book_view_listener_queue_id_event (EBookViewListener *listener,
- EBookViewListenerOperation op,
- const char *id)
+e_book_view_listener_queue_idlist_event (EBookViewListener *listener,
+ EBookViewListenerOperation op,
+ const GNOME_Evolution_Addressbook_CardIdList *ids)
{
EBookViewListenerResponse *resp;
+ int i;
if (listener->priv->stopped)
return;
@@ -146,10 +148,14 @@ e_book_view_listener_queue_id_event (EBookViewListener *listener,
resp->op = op;
resp->status = E_BOOK_VIEW_STATUS_SUCCESS;
- resp->id = g_strdup (id);
+ resp->ids = NULL;
resp->cards = NULL;
resp->message = NULL;
+ for (i = 0; i < ids->_length; i ++) {
+ resp->ids = g_list_prepend (resp->ids, g_strdup (ids->_buffer[i]));
+ }
+
e_book_view_listener_queue_response (listener, resp);
}
@@ -169,7 +175,7 @@ e_book_view_listener_queue_sequence_event (EBookViewListener *listener,
resp->op = op;
resp->status = E_BOOK_VIEW_STATUS_SUCCESS;
- resp->id = NULL;
+ resp->ids = NULL;
resp->cards = NULL;
resp->message = NULL;
@@ -195,7 +201,7 @@ e_book_view_listener_queue_message_event (EBookViewListener *listener,
resp->op = op;
resp->status = E_BOOK_VIEW_STATUS_SUCCESS;
- resp->id = NULL;
+ resp->ids = NULL;
resp->cards = NULL;
resp->message = g_strdup(message);
@@ -214,14 +220,13 @@ impl_BookViewListener_notify_card_added (PortableServer_Servant servant,
}
static void
-impl_BookViewListener_notify_card_removed (PortableServer_Servant servant,
- const CORBA_char* id,
- CORBA_Environment *ev)
+impl_BookViewListener_notify_cards_removed (PortableServer_Servant servant,
+ const GNOME_Evolution_Addressbook_CardIdList *ids,
+ CORBA_Environment *ev)
{
EBookViewListener *listener = E_BOOK_VIEW_LISTENER (bonobo_object (servant));
- e_book_view_listener_queue_id_event (
- listener, CardRemovedEvent, (const char *) id);
+ e_book_view_listener_queue_idlist_event (listener, CardsRemovedEvent, ids);
}
static void
@@ -388,7 +393,8 @@ e_book_view_listener_dispose (GObject *object)
for (l = listener->priv->response_queue; l != NULL; l = l->next) {
EBookViewListenerResponse *resp = l->data;
- g_free(resp->id);
+ g_list_foreach (resp->ids, (GFunc)g_free, NULL);
+ g_list_free (resp->ids);
g_list_foreach(resp->cards, (GFunc) g_object_unref, NULL);
g_list_free(resp->cards);
@@ -430,7 +436,7 @@ e_book_view_listener_class_init (EBookViewListenerClass *klass)
epv = &klass->epv;
epv->notifyCardChanged = impl_BookViewListener_notify_card_changed;
- epv->notifyCardRemoved = impl_BookViewListener_notify_card_removed;
+ epv->notifyCardsRemoved = impl_BookViewListener_notify_cards_removed;
epv->notifyCardAdded = impl_BookViewListener_notify_card_added;
epv->notifySequenceComplete = impl_BookViewListener_notify_sequence_complete;
epv->notifyStatusMessage = impl_BookViewListener_notify_status_message;
diff --git a/addressbook/backend/ebook/e-book-view-listener.h b/addressbook/backend/ebook/e-book-view-listener.h
index f12fdca779..fd1c1395a7 100644
--- a/addressbook/backend/ebook/e-book-view-listener.h
+++ b/addressbook/backend/ebook/e-book-view-listener.h
@@ -48,7 +48,7 @@ struct _EBookViewListenerClass {
typedef enum {
/* Async events */
CardAddedEvent,
- CardRemovedEvent,
+ CardsRemovedEvent,
CardModifiedEvent,
SequenceCompleteEvent,
StatusMessageEvent,
@@ -60,8 +60,8 @@ typedef struct {
/* For SequenceComplete */
EBookViewStatus status;
- /* For CardRemovedEvent */
- char *id;
+ /* For CardsRemovedEvent */
+ GList *ids;
/* For Card[Added|Modified]Event */
GList *cards; /* Of type ECard. */
diff --git a/addressbook/backend/ebook/e-book-view.c b/addressbook/backend/ebook/e-book-view.c
index 007f052297..e1f4b1623c 100644
--- a/addressbook/backend/ebook/e-book-view.c
+++ b/addressbook/backend/ebook/e-book-view.c
@@ -82,9 +82,10 @@ e_book_view_do_removed_event (EBookView *book_view,
EBookViewListenerResponse *resp)
{
g_signal_emit (book_view, e_book_view_signals [CARD_REMOVED], 0,
- resp->id);
+ resp->ids);
- g_free(resp->id);
+ g_list_foreach (resp->ids, (GFunc) g_free, NULL);
+ g_list_free (resp->ids);
}
static void
@@ -125,7 +126,7 @@ e_book_view_check_listener_queue (EBookViewListener *listener, EBookView *book_v
case CardModifiedEvent:
e_book_view_do_modified_event (book_view, resp);
break;
- case CardRemovedEvent:
+ case CardsRemovedEvent:
e_book_view_do_removed_event (book_view, resp);
break;
case SequenceCompleteEvent:
diff --git a/addressbook/backend/ebook/e-book-view.h b/addressbook/backend/ebook/e-book-view.h
index 98eee4cde3..bd7a97d1d5 100644
--- a/addressbook/backend/ebook/e-book-view.h
+++ b/addressbook/backend/ebook/e-book-view.h
@@ -43,7 +43,7 @@ struct _EBookViewClass {
* Signals.
*/
void (* card_changed) (EBookView *book_view, const GList *cards);
- void (* card_removed) (EBookView *book_view, const char *id);
+ void (* card_removed) (EBookView *book_view, const GList *ids);
void (* card_added) (EBookView *book_view, const GList *cards);
void (* sequence_complete) (EBookView *book_view, EBookViewStatus status);
void (* status_message) (EBookView *book_view, const char *message);
diff --git a/addressbook/backend/ebook/e-book.c b/addressbook/backend/ebook/e-book.c
index fff07bcfb9..7cdca25d95 100644
--- a/addressbook/backend/ebook/e-book.c
+++ b/addressbook/backend/ebook/e-book.c
@@ -35,6 +35,9 @@ struct _EBookPrivate {
GList *book_factories;
GList *iter;
+ char *cap;
+ gboolean cap_queried;
+
EBookListener *listener;
EComponentListener *comp_listener;
@@ -836,32 +839,52 @@ e_book_get_uri (EBook *book)
char *
e_book_get_static_capabilities (EBook *book)
{
- CORBA_Environment ev;
- char *temp;
- char *ret_val;
+ if (!book->priv->cap_queried) {
+ CORBA_Environment ev;
+ char *temp;
- CORBA_exception_init (&ev);
+ CORBA_exception_init (&ev);
- if (book->priv->load_state != URILoaded) {
- g_warning ("e_book_unload_uri: No URI is loaded!\n");
- return g_strdup("");
- }
+ if (book->priv->load_state != URILoaded) {
+ g_warning ("e_book_unload_uri: No URI is loaded!\n");
+ return g_strdup("");
+ }
- temp = GNOME_Evolution_Addressbook_Book_getStaticCapabilities(book->priv->corba_book, &ev);
+ temp = GNOME_Evolution_Addressbook_Book_getStaticCapabilities(book->priv->corba_book, &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("e_book_get_static_capabilities: Exception "
+ "during get_static_capabilities!\n");
+ CORBA_exception_free (&ev);
+ return g_strdup("");
+ }
+
+ book->priv->cap = g_strdup(temp);
+ book->priv->cap_queried = TRUE;
+
+ CORBA_free(temp);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("e_book_get_static_capabilities: Exception "
- "during get_static_capabilities!\n");
CORBA_exception_free (&ev);
- return g_strdup("");
}
- ret_val = g_strdup(temp);
- CORBA_free(temp);
+ return g_strdup (book->priv->cap);
+}
- CORBA_exception_free (&ev);
+gboolean
+e_book_check_static_capability (EBook *book, const char *cap)
+{
+ gboolean rv = FALSE;
+ char *caps = e_book_get_static_capabilities (book);
+ if (!caps)
+ return FALSE;
+
+ /* XXX this is an inexact test but it works for our use */
+ if (strstr (caps, cap))
+ rv = TRUE;
+
+ g_free (caps);
- return ret_val;
+ return rv;
}
guint
@@ -1077,11 +1100,32 @@ e_book_remove_card_by_id (EBook *book,
gpointer closure)
{
+ GList *list = NULL;
+ gboolean rv;
+
+ list = g_list_prepend (list, (char*)id);
+
+ rv = e_book_remove_cards (book, list, cb, closure);
+
+ g_list_free (list);
+
+ return rv;
+}
+
+gboolean
+e_book_remove_cards (EBook *book,
+ GList *ids,
+ EBookCallback cb,
+ gpointer closure)
+{
+ GNOME_Evolution_Addressbook_CardIdList idlist;
CORBA_Environment ev;
+ GList *l;
+ int num_ids, i;
g_return_val_if_fail (book != NULL, FALSE);
g_return_val_if_fail (E_IS_BOOK (book), FALSE);
- g_return_val_if_fail (id != NULL, FALSE);
+ g_return_val_if_fail (ids != NULL, FALSE);
if (book->priv->load_state != URILoaded) {
g_warning ("e_book_remove_card_by_id: No URI loaded!\n");
@@ -1092,8 +1136,16 @@ e_book_remove_card_by_id (EBook *book,
e_book_queue_op (book, cb, closure, NULL);
- GNOME_Evolution_Addressbook_Book_removeCard (
- book->priv->corba_book, (const GNOME_Evolution_Addressbook_CardId) id, &ev);
+ num_ids = g_list_length (ids);
+ idlist._buffer = CORBA_sequence_GNOME_Evolution_Addressbook_CardId_allocbuf (num_ids);
+ idlist._maximum = num_ids;
+ idlist._length = num_ids;
+
+ for (l = ids, i = 0; l; l=l->next, i ++) {
+ idlist._buffer[i] = CORBA_string_dup (l->data);
+ }
+
+ GNOME_Evolution_Addressbook_Book_removeCards (book->priv->corba_book, &idlist, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("e_book_remove_card_by_id: CORBA exception "
@@ -1105,9 +1157,12 @@ e_book_remove_card_by_id (EBook *book,
CORBA_exception_free (&ev);
+ CORBA_free(idlist._buffer);
+
return TRUE;
}
+
/* Adding cards. */
/**
@@ -1557,6 +1612,8 @@ e_book_dispose (GObject *object)
book->priv->comp_listener = NULL;
}
+ g_free (book->priv->cap);
+
g_free (book->priv->uri);
g_free (book->priv);
diff --git a/addressbook/backend/ebook/e-book.h b/addressbook/backend/ebook/e-book.h
index bee3a24907..d2c5a7bce4 100644
--- a/addressbook/backend/ebook/e-book.h
+++ b/addressbook/backend/ebook/e-book.h
@@ -74,6 +74,7 @@ void e_book_unload_uri (EBook *book);
const char *e_book_get_uri (EBook *book);
char *e_book_get_static_capabilities (EBook *book);
+gboolean e_book_check_static_capability (EBook *book, const char *cap);
guint e_book_get_supported_fields (EBook *book,
EBookFieldsCallback cb,
@@ -107,6 +108,11 @@ gboolean e_book_remove_card_by_id (EBook *book,
EBookCallback cb,
gpointer closure);
+gboolean e_book_remove_cards (EBook *book,
+ GList *id_list,
+ EBookCallback cb,
+ gpointer closure);
+
/* Adding cards. */
gboolean e_book_add_card (EBook *book,
ECard *card,