aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorIain Holmes <iain@helixcode.com>2000-10-07 08:58:03 +0800
committerIain Holmes <iain@src.gnome.org>2000-10-07 08:58:03 +0800
commitee625ee5fcc71e9d17fafd53fa17c7cd73558c9f (patch)
treebb93966fd64cce8876fcdbd4b4f9131ea0119c56 /mail
parentb9db2f0137dd06111913dd93d97737542dba026d (diff)
downloadgsoc2013-evolution-ee625ee5fcc71e9d17fafd53fa17c7cd73558c9f.tar
gsoc2013-evolution-ee625ee5fcc71e9d17fafd53fa17c7cd73558c9f.tar.gz
gsoc2013-evolution-ee625ee5fcc71e9d17fafd53fa17c7cd73558c9f.tar.bz2
gsoc2013-evolution-ee625ee5fcc71e9d17fafd53fa17c7cd73558c9f.tar.lz
gsoc2013-evolution-ee625ee5fcc71e9d17fafd53fa17c7cd73558c9f.tar.xz
gsoc2013-evolution-ee625ee5fcc71e9d17fafd53fa17c7cd73558c9f.tar.zst
gsoc2013-evolution-ee625ee5fcc71e9d17fafd53fa17c7cd73558c9f.zip
Fix the locking up of the mail by only calling camel functions from the
2000-10-06 Iain Holmes <iain@helixcode.com> * mail-summary.c: Fix the locking up of the mail by only calling camel functions from the camel thread, and ORBit functions from the GTK thread. Watch for the message-changed signal again. * component-factory.c (summary_fn, component_factory_init): Re-enabled it, cos I think it works again. * mail-display.h: Remove the pb_cache. * Makefile.am: Readd the mail-summary.[ch] files and add the evolution-services library to the link. svn path=/trunk/; revision=5777
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog14
-rw-r--r--mail/Makefile.am3
-rw-r--r--mail/component-factory.c8
-rw-r--r--mail/mail-display.h2
-rw-r--r--mail/mail-summary.c189
5 files changed, 163 insertions, 53 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 6cee2ba28c..ce2dfe1e72 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,17 @@
+2000-10-06 Iain Holmes <iain@helixcode.com>
+
+ * mail-summary.c: Fix the locking up of the mail by only calling
+ camel functions from the camel thread, and ORBit functions from
+ the GTK thread. Watch for the message-changed signal again.
+
+ * component-factory.c (summary_fn, component_factory_init):
+ Re-enabled it, cos I think it works again.
+
+ * mail-display.h: Remove the pb_cache.
+
+ * Makefile.am: Readd the mail-summary.[ch] files and add the
+ evolution-services library to the link.
+
2000-10-06 Chris Toshok <toshok@helixcode.com>
* mail-ops.c (do_scan_subfolders): set the @subscribed_only
diff --git a/mail/Makefile.am b/mail/Makefile.am
index ff988594c0..eaefe9f32b 100644
--- a/mail/Makefile.am
+++ b/mail/Makefile.am
@@ -65,6 +65,8 @@ evolution_mail_SOURCES = \
mail-mlist-magic.h \
mail-ops.c \
mail-ops.h \
+ mail-summary.c \
+ mail-summary.h \
mail-threads.c \
mail-threads.h \
mail-tools.c \
@@ -93,6 +95,7 @@ evolution_mail_LDADD = \
$(top_builddir)/e-util/ename/libename.la \
$(top_builddir)/libibex/libibex.la \
$(top_builddir)/filter/libfilter.la \
+ $(top_builddir)/executive-summary/evolution-services/libevolution-services.la \
$(BONOBO_VFS_GNOME_LIBS) \
$(EXTRA_GNOME_LIBS) \
$(GTKHTML_LIBS) \
diff --git a/mail/component-factory.c b/mail/component-factory.c
index 69f7a4b110..44702245ee 100644
--- a/mail/component-factory.c
+++ b/mail/component-factory.c
@@ -42,10 +42,8 @@
#include "mail-local-storage.h"
#include "component-factory.h"
-#ifdef THIS_WAS_BROKEN_AND_WASTED_TIME
#include <executive-summary/evolution-services/executive-summary-component.h>
#include "mail-summary.h"
-#endif
CamelFolder *drafts_folder = NULL;
CamelFolder *outbox_folder = NULL;
@@ -167,7 +165,6 @@ factory_destroy (BonoboEmbeddable *embeddable,
gtk_main_quit ();
}
-#ifdef THIS_WAS_BROKEN_AND_WASTED_TIME
static BonoboObject *
summary_fn (BonoboGenericFactory *factory, void *closure)
{
@@ -177,7 +174,6 @@ summary_fn (BonoboGenericFactory *factory, void *closure)
NULL, create_summary_view, NULL, NULL);
return BONOBO_OBJECT (summary_component);
}
-#endif
static BonoboObject *
factory_fn (BonoboGenericFactory *factory, void *closure)
@@ -210,9 +206,7 @@ component_factory_init (void)
return;
factory = bonobo_generic_factory_new (COMPONENT_FACTORY_ID, factory_fn, NULL);
-#ifdef THIS_WAS_BROKEN_AND_WASTED_TIME
summary_factory = bonobo_generic_factory_new (SUMMARY_FACTORY_ID, summary_fn, NULL);
-#endif
if (factory == NULL) {
e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
@@ -220,12 +214,10 @@ component_factory_init (void)
exit (1);
}
-#ifdef THIS_WAS_BROKEN_AND_WASTED_TIME
if (summary_factory == NULL) {
e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
_("Cannot initialize Evolution's mail summary component."));
}
-#endif
}
/* FIXME: remove */
diff --git a/mail/mail-display.h b/mail/mail-display.h
index 858cea9f83..f18ef68cba 100644
--- a/mail/mail-display.h
+++ b/mail/mail-display.h
@@ -29,8 +29,6 @@ struct _MailDisplay {
CamelMimeMessage *current_message;
GData **data;
-
- GHashTable *pb_cache;
};
typedef struct {
diff --git a/mail/mail-summary.c b/mail/mail-summary.c
index 619accf24e..e670057ad8 100644
--- a/mail/mail-summary.c
+++ b/mail/mail-summary.c
@@ -28,11 +28,11 @@
#include <bonobo.h>
#include "camel.h"
-
+#include <gnome.h>
#include "mail.h" /* YUCK FIXME */
#include "mail-tools.h"
#include "mail-ops.h"
-#include <gal/widgets/e-gui-utils.h>
+
#include "mail-local-storage.h"
#include <executive-summary/evolution-services/executive-summary-component.h>
@@ -41,41 +41,142 @@ typedef struct {
ExecutiveSummaryComponent *component;
CamelFolder *folder;
- int mailread, mailunread;
+ int mail, unread;
char *html;
} MailSummary;
+#define SUMMARY_IN() g_print ("IN: %s: %d\n", __FUNCTION__, __LINE__);
+#define SUMMARY_OUT() g_print ("OUT: %s: %d\n", __FUNCTION__, __LINE__);
+
+static int queue_len = 0;
+
+#define MAIN_READER main_compipe[0]
+#define MAIN_WRITER main_compipe[1]
+#define DISPATCH_READER dispatch_compipe[0]
+#define DISPATCH_WRITER dispatch_compipe[1]
+
+static int main_compipe[2] = {-1, -1};
+static int dispatch_compipe[2] = {-1, -1};
+
+GIOChannel *summary_chan_reader = NULL;
+
+static void do_changed (MailSummary *summary);
+
+static gboolean
+read_msg (GIOChannel *source,
+ GIOCondition condition,
+ gpointer user_data)
+{
+ MailSummary *summary;
+ int size;
+
+ summary = g_new0 (MailSummary, 1);
+ g_io_channel_read (source, (gchar *) summary,
+ sizeof (MailSummary) / sizeof (gchar), &size);
+
+ if (size != sizeof (MailSummary)) {
+ g_warning (_("Incomplete message written on pipe!"));
+ return TRUE;
+ }
+
+ do_changed (summary);
+ g_free (summary);
+
+ return TRUE;
+}
+
+/* check_compipes: */
+static void
+check_compipes (void)
+{
+ if (MAIN_READER < 0) {
+ if (pipe (main_compipe) < 0) {
+ g_warning ("Call to pipe failed");
+ return;
+ }
+
+ summary_chan_reader = g_io_channel_unix_new (MAIN_READER);
+ g_io_add_watch (summary_chan_reader, G_IO_IN, read_msg, NULL);
+ }
+
+ if (DISPATCH_READER < 0) {
+ if (pipe (dispatch_compipe) < 0) {
+ g_warning ("Call to pipe failed");
+ return;
+ }
+ }
+}
+
/* Temporary functions to create the summary
FIXME: Need TigerT's designs :) */
static void
+do_changed (MailSummary *summary)
+{
+ char *ret_html, *str1;
+ int mail = summary->mail;
+
+ str1 = g_strdup_printf (_("<b>Inbox:</b> %d/%d"),
+ summary->unread, mail);
+
+ ret_html = g_strdup_printf ("<table><tr><td><img src=\"evolution-inbox-mini.png\"></td><td>%s</td></tr></table>", str1);
+ g_free (str1);
+
+ executive_summary_component_update (summary->component, ret_html);
+ g_free (ret_html);
+
+}
+
+/* These two callbacks are called from the Camel thread,
+ which can't make any CORBA calls, or else ORBit locks up,
+ and likewise the thread that can call ORBit, cannot call
+ camel.
+
+ So, when the callbacks are triggered, they generate a MailSummary
+ structure and write this onto a pipe. The ORBit calling thread
+ detects when something is written to the pipe and creates its own
+ MailSummary structure, and calls the appropriate CORBA calls.
+
+ Same theory as mail-threads.c, but a lot less complicated
+ as there is only one way communication, and only one type of message
+*/
+static void
folder_changed_cb (CamelObject *folder,
gpointer event_data,
gpointer user_data)
{
MailSummary *summary;
- char *ret_html, *str1, *str2;
- int mailread, mailunread;
-
+ int mail;
+
+ summary = (MailSummary *) user_data;
+ /* Put the summary data onto a pipe */
+
+ mail = camel_folder_get_message_count (folder);
+ summary->unread = camel_folder_get_unread_message_count (folder);
+ summary->mail = mail;
+
+ write (MAIN_WRITER, summary, sizeof (MailSummary));
+ queue_len++;
+
+ return;
+}
+
+static void
+message_changed_cb (CamelObject *folder,
+ gpointer event_data,
+ gpointer user_data)
+{
+ MailSummary *summary;
+ int mail;
+
summary = (MailSummary *)user_data;
- mailread = camel_folder_get_message_count (CAMEL_FOLDER (folder));
- mailunread = camel_folder_get_unread_message_count (CAMEL_FOLDER (folder));
-
- str1 = g_strdup_printf (_("There %s %d %s."),
- (mailread == 1) ? _("is"): _("are"),
- mailread,
- (mailread == 1) ? _("message"): _("messages"));
- str2 = g_strdup_printf (_("There %s %d unread %s."),
- (mailunread == 1) ? _("is"): _("are"),
- mailunread,
- (mailunread == 1) ? _("message"): _("messages"));
-
- ret_html = g_strdup_printf ("<table><tr><td><img src=\"evolution-inbox-mini.png\"></td><td>%s</td></tr><tr><td><img src=\"evolution-inbox-mini.png\"></td><td>%s</td></tr></table>", str1, str2);
- g_free (str1);
- g_free (str2);
+ summary->unread = camel_folder_get_unread_message_count (folder);
+ summary->mail = camel_folder_get_message_count (folder);
- executive_summary_component_update (summary->component, ret_html);
- g_free (ret_html);
+ write (MAIN_WRITER, summary, sizeof (MailSummary));
+ queue_len++;
+
+ return;
}
char *
@@ -83,43 +184,45 @@ create_summary_view (ExecutiveSummaryComponent *component,
char **title,
void *closure)
{
- char *str1, *str2, *ret_html;
- int mailread, mailunread;
+ char *str1, *ret_html;
+ int mailread, unread;
CamelFolder *folder;
CamelException *ex;
MailSummary *summary;
- ex = camel_exception_new ();
- folder = mail_tool_get_local_inbox (ex);
-
/* Strdup the title */
*title = g_strdup ("Inbox:");
+ mail_tool_camel_lock_up ();
+ ex = camel_exception_new ();
+ folder = mail_tool_get_local_inbox (ex);
+
mailread = camel_folder_get_message_count (folder);
- mailunread = camel_folder_get_unread_message_count (folder);
-
- str1 = g_strdup_printf (_("There %s %d %s."),
- (mailread == 1) ? _("is"): _("are"),
- mailread,
- (mailread == 1) ? _("message"): _("messages"));
- str2 = g_strdup_printf (_("There %s %d unread %s."),
- (mailunread == 1) ? _("is"): _("are"),
- mailunread,
- (mailunread == 1) ? _("message"): _("messages"));
-
- ret_html = g_strdup_printf ("<table><tr><td><img src=\"evolution-inbox-mini.png\"></td><td>%s</td></tr><tr><td><img src=\"evolution-inbox-mini.png\"></td><td>%s</td></tr></table>", str1, str2);
+ unread = camel_folder_get_unread_message_count (folder);
+ mail_tool_camel_lock_down ();
+
+ str1 = g_strdup_printf (_("<b>Inbox:</b>%d/%d"),
+ unread, mailread);
+
+ ret_html = g_strdup_printf ("<table><tr><td><img src=\"evolution-inbox-mini.png\"></td><td>%s</td></tr></table>", str1);
g_free (str1);
- g_free (str2);
summary = g_new (MailSummary, 1);
summary->folder = folder;
summary->html = ret_html;
- summary->mailread = mailread;
- summary->mailunread = mailunread;
+ summary->mail = mailread;
+ summary->unread = unread;
summary->component = component;
+ check_compipes ();
+
+ mail_tool_camel_lock_up ();
camel_object_hook_event (folder, "folder_changed",
(CamelObjectEventHookFunc) folder_changed_cb,
summary);
+ camel_object_hook_event (folder, "message_changed",
+ (CamelObjectEventHookFunc) message_changed_cb,
+ summary);
+ mail_tool_camel_lock_down ();
return ret_html;
}