aboutsummaryrefslogtreecommitdiffstats
path: root/my-evolution
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2002-02-02 04:32:08 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2002-02-02 04:32:08 +0800
commit8d91d3461106080ebaefe3f7bac563a1ebecc310 (patch)
tree94370aead37a48733e1e50c6a562e2a2f0782473 /my-evolution
parent8555a05de522d9b185db2f2884b6806fe0d44cf6 (diff)
downloadgsoc2013-evolution-8d91d3461106080ebaefe3f7bac563a1ebecc310.tar.gz
gsoc2013-evolution-8d91d3461106080ebaefe3f7bac563a1ebecc310.tar.zst
gsoc2013-evolution-8d91d3461106080ebaefe3f7bac563a1ebecc310.zip
[Fix a crash that can happen if you have opened multiple views of
the summary and try to go off-line. This is not the correct fix, as the code should really be changed to only use one set of connections for all the views, instead of binding the connections to the view.] * e-summary-factory.c (e_summary_factory_new_control): Call `e_summary_offline_handler_add_summary()' instead of e_summary_offline_handler_set_summary()'. * e-summary-offline-handler.c: Replace member `summary' with `summaries' in the ESummaryOfflineHandlerPriv. This way, instead of assuming that there is only one summary, we keep a list of the summaries. (impl_destroy): Free ->summaries. (e_summary_offline_handler_set_summary): Removed. (e_summary_offline_handler_add_summary): New. Add the summary to ->summaries. Also, connect to the ::destroy handler so we can bookkeep them correctly. (create_connection_list): Made private from e_summary_offline_handler_create_connection_list(). Get a GSList instead of just one summary, and sum up all the connections from it. (impl_prepareForOffline): Use it. (impl__get_isOffline): Return %FALSE if any of the summaries are online, %TRUE otherwise. (impl_goOffline): Call ::set_online on all the summaries. Pass CORBA_OBJECT_NIL for the progress_listener as it doesn't really get used anyways. (impl_goOnline): Likewise. Pass CORBA_OBJECT_NIL, not NULL, for the progress CORBA_Object pointer. svn path=/trunk/; revision=15547
Diffstat (limited to 'my-evolution')
-rw-r--r--my-evolution/ChangeLog34
-rw-r--r--my-evolution/e-summary-factory.c2
-rw-r--r--my-evolution/e-summary-offline-handler.c114
-rw-r--r--my-evolution/e-summary-offline-handler.h10
4 files changed, 117 insertions, 43 deletions
diff --git a/my-evolution/ChangeLog b/my-evolution/ChangeLog
index 3cf2738e72..283a974ce0 100644
--- a/my-evolution/ChangeLog
+++ b/my-evolution/ChangeLog
@@ -1,3 +1,37 @@
+2002-02-01 Ettore Perazzoli <ettore@ximian.com>
+
+ [Fix a crash that can happen if you have opened multiple views of
+ the summary and try to go off-line. This is not the correct fix,
+ as the code should really be changed to only use one set of
+ connections for all the views, instead of binding the connections
+ to the view.]
+
+ * e-summary-factory.c (e_summary_factory_new_control): Call
+ `e_summary_offline_handler_add_summary()' instead of
+ e_summary_offline_handler_set_summary()'.
+
+ * e-summary-offline-handler.c: Replace member `summary' with
+ `summaries' in the ESummaryOfflineHandlerPriv. This way, instead
+ of assuming that there is only one summary, we keep a list of the
+ summaries.
+ (impl_destroy): Free ->summaries.
+ (e_summary_offline_handler_set_summary): Removed.
+ (e_summary_offline_handler_add_summary): New. Add the summary to
+ ->summaries. Also, connect to the ::destroy handler so we can
+ bookkeep them correctly.
+ (create_connection_list): Made private from
+ e_summary_offline_handler_create_connection_list(). Get a GSList
+ instead of just one summary, and sum up all the connections from
+ it.
+ (impl_prepareForOffline): Use it.
+ (impl__get_isOffline): Return %FALSE if any of the summaries are
+ online, %TRUE otherwise.
+ (impl_goOffline): Call ::set_online on all the summaries. Pass
+ CORBA_OBJECT_NIL for the progress_listener as it doesn't really
+ get used anyways.
+ (impl_goOnline): Likewise. Pass CORBA_OBJECT_NIL, not NULL, for
+ the progress CORBA_Object pointer.
+
2002-01-24 Ettore Perazzoli <ettore@ximian.com>
* Makefile.am: Use EVOLUTION_EXECUTIVE_SUMMARY_CFLAGS and
diff --git a/my-evolution/e-summary-factory.c b/my-evolution/e-summary-factory.c
index 52cba39849..9344f70016 100644
--- a/my-evolution/e-summary-factory.c
+++ b/my-evolution/e-summary-factory.c
@@ -138,7 +138,7 @@ e_summary_factory_new_control (const char *uri,
return NULL;
}
- e_summary_offline_handler_set_summary (handler, E_SUMMARY (summary));
+ e_summary_offline_handler_add_summary (handler, E_SUMMARY (summary));
gtk_widget_show (summary);
control = bonobo_control_new (summary);
diff --git a/my-evolution/e-summary-offline-handler.c b/my-evolution/e-summary-offline-handler.c
index d03bf0eb32..da54180981 100644
--- a/my-evolution/e-summary-offline-handler.c
+++ b/my-evolution/e-summary-offline-handler.c
@@ -38,36 +38,62 @@
static BonoboXObjectClass *parent_class = NULL;
struct _ESummaryOfflineHandlerPriv {
- ESummary *summary;
+ GSList *summaries;
GNOME_Evolution_OfflineProgressListener listener_interface;
};
-GNOME_Evolution_ConnectionList *
-e_summary_offline_handler_create_connection_list (ESummary *summary)
+/* ::destroy handler for the bookkeeping of the list of summary views. */
+
+static void
+summary_destroy_callback (GtkObject *object,
+ void *data)
+{
+ ESummaryOfflineHandler *offline_handler;
+ ESummaryOfflineHandlerPriv *priv;
+ ESummary *summary;
+
+ summary = E_SUMMARY (object);
+ offline_handler = E_SUMMARY_OFFLINE_HANDLER (data);
+ priv = offline_handler->priv;
+
+ priv->summaries = g_slist_remove (priv->summaries, summary);
+}
+
+static GNOME_Evolution_ConnectionList *
+create_connection_list (GSList *summaries)
{
GNOME_Evolution_ConnectionList *list;
GList *connections, *p;
+ GSList *sp;
list = GNOME_Evolution_ConnectionList__alloc ();
list->_length = 0;
- list->_maximum = e_summary_count_connections (summary) + 1;
+ list->_maximum = 0;
list->_buffer = CORBA_sequence_GNOME_Evolution_Connection_allocbuf (list->_maximum);
- g_print ("_length: %d\n_maximum: %d\n", list->_length, list->_maximum);
- connections = e_summary_add_connections (summary);
- for (p = connections; p; p = p->next) {
- ESummaryConnectionData *data;
+ /* Count the total number of connections first to make CORBA happy. */
+ for (sp = summaries; sp != NULL; sp = sp->next)
+ list->_maximum += e_summary_count_connections (E_SUMMARY (sp->data)) + 1;
+
+ for (sp = summaries; sp != NULL; sp = sp->next) {
+ ESummary *summary;
+
+ summary = E_SUMMARY (sp->data);
+ connections = e_summary_add_connections (summary);
+ for (p = connections; p != NULL; p = p->next) {
+ ESummaryConnectionData *data;
- data = p->data;
- list->_buffer[list->_length].hostName = CORBA_string_dup (data->hostname);
- list->_buffer[list->_length].type = CORBA_string_dup (data->type);
- list->_length++;
+ data = p->data;
+ list->_buffer[list->_length].hostName = CORBA_string_dup (data->hostname);
+ list->_buffer[list->_length].type = CORBA_string_dup (data->type);
+ list->_length++;
- g_free (data->hostname);
- g_free (data->type);
- g_free (data);
+ g_free (data->hostname);
+ g_free (data->type);
+ g_free (data);
+ }
+ g_list_free (connections);
}
- g_list_free (connections);
return list;
}
@@ -78,10 +104,17 @@ impl__get_isOffline (PortableServer_Servant servant,
CORBA_Environment *ev)
{
ESummaryOfflineHandler *offline_handler;
+ GSList *sp;
offline_handler = E_SUMMARY_OFFLINE_HANDLER (bonobo_object_from_servant (servant));
- if (offline_handler->priv->summary != NULL) {
- return offline_handler->priv->summary->online;
+
+ /* We are offline if all of the views are offline. */
+ for (sp = offline_handler->priv->summaries; sp != NULL; sp = sp->next) {
+ ESummary *summary;
+
+ summary = E_SUMMARY (sp->data);
+ if (summary->online)
+ return FALSE;
}
return TRUE;
@@ -98,14 +131,7 @@ impl_prepareForOffline (PortableServer_Servant servant,
offline_handler = E_SUMMARY_OFFLINE_HANDLER (bonobo_object_from_servant (servant));
priv = offline_handler->priv;
- if (priv->summary != NULL) {
- *active_connection_list = e_summary_offline_handler_create_connection_list (priv->summary);
- } else {
- *active_connection_list = GNOME_Evolution_ConnectionList__alloc ();
- (*active_connection_list)->_length = 0;
- (*active_connection_list)->_maximum = 0;
- (*active_connection_list)->_buffer = CORBA_sequence_GNOME_Evolution_Connection_allocbuf (0);
- }
+ *active_connection_list = create_connection_list (priv->summaries);
}
static void
@@ -122,7 +148,7 @@ went_offline (ESummary *summary,
g_return_if_fail (offline_handler != NULL);
priv = offline_handler->priv;
- connection_list = e_summary_offline_handler_create_connection_list (summary);
+ connection_list = create_connection_list (priv->summaries);
CORBA_exception_init (&ev);
@@ -143,14 +169,20 @@ impl_goOffline (PortableServer_Servant servant,
{
ESummaryOfflineHandler *offline_handler;
ESummaryOfflineHandlerPriv *priv;
+ GSList *sp;
offline_handler = E_SUMMARY_OFFLINE_HANDLER (bonobo_object_from_servant (servant));
priv = offline_handler->priv;
- if (priv->summary != NULL) {
- priv->listener_interface = CORBA_Object_duplicate (progress_listener, ev);
-
- e_summary_set_online (priv->summary, progress_listener, FALSE, went_offline, offline_handler);
+ /* FIXME: If we have a progress already, then something is wrong and we
+ should raise an exception. */
+ priv->listener_interface = CORBA_Object_duplicate (progress_listener, &ev);
+
+ for (sp = priv->summaries; sp != NULL; sp = sp->next) {
+ ESummary *summary;
+
+ summary = E_SUMMARY (sp->data);
+ e_summary_set_online (summary, CORBA_OBJECT_NIL, FALSE, went_offline, offline_handler);
}
}
@@ -159,10 +191,15 @@ impl_goOnline (PortableServer_Servant servant,
CORBA_Environment *ev)
{
ESummaryOfflineHandler *offline_handler;
+ GSList *sp;
offline_handler = E_SUMMARY_OFFLINE_HANDLER (bonobo_object_from_servant (servant));
- if (offline_handler->priv->summary != NULL) {
- e_summary_set_online (offline_handler->priv->summary, NULL, TRUE, NULL, NULL);
+
+ for (sp = offline_handler->priv->summaries; sp != NULL; sp = sp->next) {
+ ESummary *summary;
+
+ summary = E_SUMMARY (sp->data);
+ e_summary_set_online (summary, CORBA_OBJECT_NIL, TRUE, NULL, NULL);
}
}
@@ -188,7 +225,7 @@ impl_destroy (GtkObject *object)
CORBA_exception_free (&ev);
}
- gtk_object_unref (GTK_OBJECT (priv->summary));
+ g_slist_free (priv->summaries);
offline_handler->priv = NULL;
g_free (priv);
@@ -237,15 +274,18 @@ e_summary_offline_handler_new (void)
}
void
-e_summary_offline_handler_set_summary (ESummaryOfflineHandler *handler,
+e_summary_offline_handler_add_summary (ESummaryOfflineHandler *handler,
ESummary *summary)
{
g_return_if_fail (handler != NULL);
g_return_if_fail (summary != NULL);
g_return_if_fail (IS_E_SUMMARY (summary));
- handler->priv->summary = summary;
- gtk_object_ref (GTK_OBJECT (summary));
+ handler->priv->summaries = g_slist_prepend (handler->priv->summaries,
+ summary);
+
+ gtk_signal_connect (GTK_OBJECT (summary), "destroy",
+ GTK_SIGNAL_FUNC (summary_destroy_callback), handler);
}
BONOBO_X_TYPE_FUNC_FULL (ESummaryOfflineHandler, GNOME_Evolution_Offline, PARENT_TYPE, e_summary_offline_handler);
diff --git a/my-evolution/e-summary-offline-handler.h b/my-evolution/e-summary-offline-handler.h
index 56575f88c3..3e08de38bf 100644
--- a/my-evolution/e-summary-offline-handler.h
+++ b/my-evolution/e-summary-offline-handler.h
@@ -61,11 +61,11 @@ struct _ESummaryOfflineHandlerClass {
};
-GtkType e_summary_offline_handler_get_type (void);
-ESummaryOfflineHandler *e_summary_offline_handler_new (void);
-void e_summary_offline_handler_set_summary (ESummaryOfflineHandler *handler,
- ESummary *summary);
-GNOME_Evolution_ConnectionList *e_summary_offline_handler_create_connection_list (ESummary *summary);
+GtkType e_summary_offline_handler_get_type (void);
+ESummaryOfflineHandler *e_summary_offline_handler_new (void);
+
+void e_summary_offline_handler_add_summary (ESummaryOfflineHandler *handler,
+ ESummary *summary);
#ifdef __cplusplus
}