aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/ChangeLog25
-rw-r--r--addressbook/backend/ebook/e-book.c30
-rw-r--r--addressbook/backend/ebook/e-book.h1
-rw-r--r--addressbook/gui/widgets/e-addressbook-model.c27
-rw-r--r--addressbook/gui/widgets/e-addressbook-model.h3
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c17
6 files changed, 101 insertions, 2 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 998093b84a..754524c209 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,5 +1,30 @@
2002-08-29 Chris Toshok <toshok@ximian.com>
+ [ fixes #20347 ]
+ * gui/widgets/e-addressbook-view.c (e_addressbook_view_init): hook
+ up the backend_died signal.
+ (backend_died): new function, pop up an error dialog saying the
+ backend died.
+
+ * gui/widgets/e-addressbook-model.c (backend_died): new function,
+ emit the backend_died signal.
+ (e_addressbook_model_class_init): create the backend_died signal.
+ (e_addressbook_model_init): init backend_died_id
+ (e_addressbook_model_set_arg): disconnect the backend_died signal
+ from the old book and hook it up to the new book.
+
+ * gui/widgets/e-addressbook-model.h: add the backend_died signal.
+
+ * backend/ebook/e-book.c (backend_died_cb): new function, emit the
+ backend_died signal.
+ (e_book_do_response_open): create the component listener and hook
+ up the backend_died signal.
+ (e_book_destroy): disconnect the component listener and unref it.
+
+ * backend/ebook/e-book.h: add backend_died signal.
+
+2002-08-29 Chris Toshok <toshok@ximian.com>
+
* backend/pas/pas-backend-card-sexp.c (is_helper): use strcasecmp
here, since all the other helpers use case insensitive
comparisons.
diff --git a/addressbook/backend/ebook/e-book.c b/addressbook/backend/ebook/e-book.c
index fd9f233d8c..cad203ad44 100644
--- a/addressbook/backend/ebook/e-book.c
+++ b/addressbook/backend/ebook/e-book.c
@@ -18,6 +18,7 @@
#include "e-card-cursor.h"
#include "e-book-listener.h"
#include "e-book.h"
+#include "e-util/e-component-listener.h"
GtkObjectClass *e_book_parent_class;
@@ -34,6 +35,7 @@ struct _EBookPrivate {
GList *iter;
EBookListener *listener;
+ EComponentListener *comp_listener;
GNOME_Evolution_Addressbook_Book corba_book;
@@ -55,6 +57,7 @@ enum {
OPEN_PROGRESS,
WRITABLE_STATUS,
LINK_STATUS,
+ BACKEND_DIED,
LAST_SIGNAL
};
@@ -397,6 +400,15 @@ e_book_do_response_get_changes (EBook *book,
}
static void
+backend_died_cb (EComponentListener *cl, gpointer user_data)
+{
+ EBook *book = user_data;
+
+ book->priv->load_state = URINotLoaded;
+ gtk_signal_emit (GTK_OBJECT (book), e_book_signals [BACKEND_DIED]);
+}
+
+static void
e_book_do_response_open (EBook *book,
EBookListenerResponse *resp)
{
@@ -405,6 +417,10 @@ e_book_do_response_open (EBook *book,
if (resp->status == E_BOOK_STATUS_SUCCESS) {
book->priv->corba_book = resp->book;
book->priv->load_state = URILoaded;
+
+ book->priv->comp_listener = e_component_listener_new (book->priv->corba_book, 0);
+ gtk_signal_connect (GTK_OBJECT (book->priv->comp_listener), "component_died",
+ GTK_SIGNAL_FUNC (backend_died_cb), book);
}
op = e_book_pop_op (book);
@@ -1474,6 +1490,12 @@ e_book_destroy (GtkObject *object)
}
}
+ if (book->priv->comp_listener) {
+ gtk_signal_disconnect_by_data (GTK_OBJECT (book->priv->comp_listener), book);
+ gtk_object_unref (GTK_OBJECT (book->priv->comp_listener));
+ book->priv->comp_listener = NULL;
+ }
+
g_free (book->priv->uri);
g_free (book->priv);
@@ -1506,6 +1528,14 @@ e_book_class_init (EBookClass *klass)
GTK_TYPE_NONE, 1,
GTK_TYPE_BOOL);
+ e_book_signals [BACKEND_DIED] =
+ gtk_signal_new ("backend_died",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EBookClass, backend_died),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+
gtk_object_class_add_signals (object_class, e_book_signals,
LAST_SIGNAL);
diff --git a/addressbook/backend/ebook/e-book.h b/addressbook/backend/ebook/e-book.h
index e917279775..be90f52c04 100644
--- a/addressbook/backend/ebook/e-book.h
+++ b/addressbook/backend/ebook/e-book.h
@@ -38,6 +38,7 @@ struct _EBookClass {
void (* open_progress) (EBook *book, const char *msg, short percent);
void (* link_status) (EBook *book, gboolean connected);
void (* writable_status) (EBook *book, gboolean writable);
+ void (* backend_died) (EBook *book);
};
/* Callbacks for asynchronous functions. */
diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c
index 881a8e4eed..7f59c2313c 100644
--- a/addressbook/gui/widgets/e-addressbook-model.c
+++ b/addressbook/gui/widgets/e-addressbook-model.c
@@ -44,6 +44,7 @@ enum {
CARD_CHANGED,
MODEL_CHANGED,
STOP_STATE_CHANGED,
+ BACKEND_DIED,
LAST_SIGNAL
};
@@ -260,6 +261,14 @@ writable_status (EBook *book,
}
static void
+backend_died (EBook *book,
+ EAddressbookModel *model)
+{
+ gtk_signal_emit (GTK_OBJECT (model),
+ e_addressbook_model_signals [BACKEND_DIED]);
+}
+
+static void
e_addressbook_model_class_init (GtkObjectClass *object_class)
{
parent_class = gtk_type_class (PARENT_TYPE);
@@ -347,6 +356,14 @@ e_addressbook_model_class_init (GtkObjectClass *object_class)
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
+ e_addressbook_model_signals [BACKEND_DIED] =
+ gtk_signal_new ("backend_died",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EAddressbookModelClass, backend_died),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+
gtk_object_class_add_signals (object_class, e_addressbook_model_signals, LAST_SIGNAL);
}
@@ -363,6 +380,7 @@ e_addressbook_model_init (GtkObject *object)
model->modify_card_id = 0;
model->status_message_id = 0;
model->writable_status_id = 0;
+ model->backend_died_id = 0;
model->sequence_complete_id = 0;
model->data = NULL;
model->data_count = 0;
@@ -481,9 +499,13 @@ e_addressbook_model_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
if (model->writable_status_id)
gtk_signal_disconnect(GTK_OBJECT (model->book),
model->writable_status_id);
-
model->writable_status_id = 0;
+ if (model->backend_died_id)
+ gtk_signal_disconnect(GTK_OBJECT (model->book),
+ model->backend_died_id);
+ model->backend_died_id = 0;
+
gtk_object_unref(GTK_OBJECT(model->book));
}
model->book = E_BOOK(GTK_VALUE_OBJECT (*arg));
@@ -495,6 +517,9 @@ e_addressbook_model_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
gtk_signal_connect (GTK_OBJECT(model->book),
"writable_status",
writable_status, model);
+ gtk_signal_connect (GTK_OBJECT(model->book),
+ "backend_died",
+ backend_died, model);
}
break;
case ARG_QUERY:
diff --git a/addressbook/gui/widgets/e-addressbook-model.h b/addressbook/gui/widgets/e-addressbook-model.h
index 57644dbca6..eb1004499a 100644
--- a/addressbook/gui/widgets/e-addressbook-model.h
+++ b/addressbook/gui/widgets/e-addressbook-model.h
@@ -29,7 +29,7 @@ struct _EAddressbookModel {
int data_count;
int allocated_count;
- int create_card_id, remove_card_id, modify_card_id, status_message_id, writable_status_id, sequence_complete_id;
+ int create_card_id, remove_card_id, modify_card_id, status_message_id, writable_status_id, sequence_complete_id, backend_died_id;
guint search_in_progress : 1;
guint editable : 1;
@@ -53,6 +53,7 @@ struct _EAddressbookModelClass {
void (*card_changed) (EAddressbookModel *model, gint index);
void (*model_changed) (EAddressbookModel *model);
void (*stop_state_changed) (EAddressbookModel *model);
+ void (*backend_died) (EAddressbookModel *model);
};
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index c8052b4216..f12a324953 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -83,6 +83,7 @@ static void search_result (GtkObject *object, EBookViewStatus status, EAddr
static void folder_bar_message (GtkObject *object, const gchar *status, EAddressbookView *eav);
static void stop_state_changed (GtkObject *object, EAddressbookView *eav);
static void writable_status (GtkObject *object, gboolean writable, EAddressbookView *eav);
+static void backend_died (GtkObject *object, EAddressbookView *eav);
static void command_state_change (EAddressbookView *eav);
static void alphabet_state_change (EAddressbookView *eav, gunichar letter);
@@ -252,6 +253,11 @@ e_addressbook_view_init (EAddressbookView *eav)
GTK_SIGNAL_FUNC (writable_status),
eav);
+ gtk_signal_connect (GTK_OBJECT(eav->model),
+ "backend_died",
+ GTK_SIGNAL_FUNC (backend_died),
+ eav);
+
eav->editable = FALSE;
eav->book = NULL;
eav->query = g_strdup (SHOW_ALL_SEARCH);
@@ -1361,6 +1367,17 @@ alphabet_state_change (EAddressbookView *eav, gunichar letter)
}
static void
+backend_died (GtkObject *object, EAddressbookView *eav)
+{
+ char *message = g_strdup_printf (_("The addressbook backend for\n%s\nhas crashed. "
+ "You will have to restart Evolution in order "
+ "to use it again"),
+ e_book_get_uri (eav->book));
+ gnome_error_dialog_parented (message, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (eav))));
+ g_free (message);
+}
+
+static void
create_table_view (EAddressbookView *view)
{
ETableModel *adapter;