[Evolution-hackers] Patch to enable send mail from calendar alarms
- From: Ronald Kuetemeier <ronald kuetemeier com>
- To: evolution-hackers <evolution-hackers lists ximian com>
- Subject: [Evolution-hackers] Patch to enable send mail from calendar alarms
- Date: Wed, 01 Oct 2003 18:21:47 -0600
Hi Guys,
sorry this is a rather large patch. But most of it is busy work.
It enables sending mail from calendar alarms. I used a rather ugly work
around to wait for the shell if it's not running to get a shell
component, it's necessary at least for my SMP machine. If you know a
better way let me know.
Any comments are welcome.
Ronald
--- evolution-1.4.5-org/shell/Evolution-ShellComponent.idl Wed Mar 26 09:13:10 2003
+++ evolution-1.4.5/shell/Evolution-ShellComponent.idl Wed Oct 1 12:41:03 2003
@@ -164,6 +164,12 @@
shell can quit safely. (This is meant to be used for
confirmations before quitting.) */
oneway void requestQuit (in ShellComponentListener listener);
+
+ /* Create a composer */
+ Composer getComposer (in string gnome_evolution_composer_oafiid)
+ raises (UnsupportedType);
+
+
};
interface ShellComponentListener {
--- evolution-1.4.5-org/shell/Evolution.idl Sat Mar 9 20:05:52 2002
+++ evolution-1.4.5/shell/Evolution.idl Wed Oct 1 12:41:03 2003
@@ -15,6 +15,7 @@
#include <Evolution-Activity.idl>
#include <Evolution-ConfigControl.idl>
#include <Evolution-Session.idl>
+#include "../composer/Evolution-Composer.idl"
#include <Evolution-ShellComponent.idl>
#include <Evolution-ShellComponentDnd.idl>
#include <Evolution-Offline.idl>
--- evolution-1.4.5-org/shell/evolution-shell-component.c Mon Aug 11 09:48:20 2003
+++ evolution-1.4.5/shell/evolution-shell-component.c Wed Oct 1 12:41:03 2003
@@ -71,6 +71,7 @@
EvolutionShellComponentGetDndSelectionFn get_dnd_selection_fn;
EvolutionShellComponentRequestQuitFn request_quit_fn;
+ EvolutionShellComponentGetComposerFn getComposer_fn;
EvolutionShellClient *owner_client;
GSList *user_creatable_item_types; /* UserCreatableItemType */
@@ -559,6 +560,37 @@
return CORBA_Object_duplicate (bonobo_object_corba_objref (BONOBO_OBJECT (control)), ev);
}
+
+static GNOME_Evolution_Composer
+impl_getComposer (PortableServer_Servant servant,
+ const CORBA_char *gnome_evolution_composer_oafiid,
+ CORBA_Environment *ev)
+{
+ BonoboObject *bonobo_object;
+ EvolutionShellComponent *shell_component;
+ EvolutionShellComponentPrivate *priv;
+ EvolutionShellComponentResult result;
+ GNOME_Evolution_Composer composer_server;
+
+ bonobo_object = bonobo_object_from_servant (servant);
+ shell_component = EVOLUTION_SHELL_COMPONENT (bonobo_object);
+ priv = shell_component->priv;
+
+ result = (* priv->getComposer_fn) (shell_component,gnome_evolution_composer_oafiid ,
+ &composer_server, priv->closure);
+
+ if (result != EVOLUTION_SHELL_COMPONENT_OK) {
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+ ex_GNOME_Evolution_ShellComponent_UnsupportedType,
+ NULL);
+
+ return CORBA_OBJECT_NIL;
+ }
+
+ return CORBA_Object_duplicate (composer_server, ev);
+}
+
+
static void
impl_handleExternalURI (PortableServer_Servant servant,
const CORBA_char *uri,
@@ -990,6 +1022,7 @@
epv->unpopulateFolderContextMenu = impl_unpopulateFolderContextMenu;
epv->userCreateNewItem = impl_userCreateNewItem;
epv->sendReceive = impl_sendReceive;
+ epv->getComposer = impl_getComposer;
epv->requestQuit = impl_requestQuit;
shell_component_class = EVOLUTION_SHELL_COMPONENT_CLASS (object_class);
@@ -1038,6 +1071,7 @@
EvolutionShellComponentUnpopulateFolderContextMenuFn unpopulate_folder_context_menu_fn,
EvolutionShellComponentGetDndSelectionFn get_dnd_selection_fn,
EvolutionShellComponentRequestQuitFn request_quit_fn,
+ EvolutionShellComponentGetComposerFn getComposer_fn,
void *closure)
{
EvolutionShellComponentPrivate *priv;
@@ -1057,7 +1091,7 @@
priv->unpopulate_folder_context_menu_fn = unpopulate_folder_context_menu_fn;
priv->get_dnd_selection_fn = get_dnd_selection_fn;
priv->request_quit_fn = request_quit_fn;
-
+ priv->getComposer_fn = getComposer_fn;
priv->closure = closure;
for (i = 0; folder_types[i].name != NULL; i++) {
@@ -1104,6 +1138,7 @@
EvolutionShellComponentUnpopulateFolderContextMenuFn unpopulate_folder_context_menu_fn,
EvolutionShellComponentGetDndSelectionFn get_dnd_selection_fn,
EvolutionShellComponentRequestQuitFn request_quit_fn,
+ EvolutionShellComponentGetComposerFn getComposer_fn,
void *closure)
{
EvolutionShellComponent *new;
@@ -1123,6 +1158,7 @@
unpopulate_folder_context_menu_fn,
get_dnd_selection_fn,
request_quit_fn,
+ getComposer_fn,
closure);
return new;
--- evolution-1.4.5-org/shell/evolution-shell-component.h Mon Apr 7 09:42:15 2003
+++ evolution-1.4.5/shell/evolution-shell-component.h Wed Oct 1 12:41:03 2003
@@ -119,6 +119,14 @@
typedef gboolean (* EvolutionShellComponentRequestQuitFn) (EvolutionShellComponent *shell_component,
void *closure);
+
+typedef EvolutionShellComponentResult (* EvolutionShellComponentGetComposerFn)
+ (EvolutionShellComponent *shell_component,
+ const char *gnome_evolution_composer_oafiid,
+ GNOME_Evolution_Composer *composer,
+ void *closure);
+
+
struct _EvolutionShellComponentFolderType {
char *name;
char *icon_name;
@@ -183,6 +191,7 @@
EvolutionShellComponentUnpopulateFolderContextMenuFn unpopulate_folder_context_menu_fn,
EvolutionShellComponentGetDndSelectionFn get_dnd_selection_fn,
EvolutionShellComponentRequestQuitFn request_quit_fn,
+ EvolutionShellComponentGetComposerFn getComposer_fn,
void *closure);
EvolutionShellComponent *evolution_shell_component_new (const EvolutionShellComponentFolderType folder_types[],
const char *external_uri_schemas[],
@@ -194,6 +203,7 @@
EvolutionShellComponentUnpopulateFolderContextMenuFn unpopulate_folder_context_menu_fn,
EvolutionShellComponentGetDndSelectionFn get_dnd_selection_fn,
EvolutionShellComponentRequestQuitFn request_quit_fn,
+ EvolutionShellComponentGetComposerFn getComposer_fn,
void *closure);
EvolutionShellClient *evolution_shell_component_get_owner (EvolutionShellComponent *shell_component);
--- evolution-1.4.5-org/shell/evolution-test-component.c Thu Feb 6 15:00:33 2003
+++ evolution-1.4.5/shell/evolution-test-component.c Wed Oct 1 13:18:44 2003
@@ -658,6 +658,7 @@
create_view_fn,
NULL, NULL, NULL, NULL, NULL, NULL,
request_quit_fn,
+ NULL,
NULL);
g_signal_connect (shell_component, "owner_set",
--- evolution-1.4.5-org/calendar/gui/calendar-component.c Mon Apr 28 11:59:23 2003
+++ evolution-1.4.5/calendar/gui/calendar-component.c Wed Oct 1 12:41:03 2003
@@ -716,6 +716,7 @@
NULL, /* unpopulate_folder_context_menu_fn */
NULL, /* get_dnd_selection_fn */
request_quit,
+ NULL,
NULL /* closure */);
/* Offline handler */
--- evolution-1.4.5-org/addressbook/gui/component/addressbook-component.c Fri Jul 25 09:44:09 2003
+++ evolution-1.4.5/addressbook/gui/component/addressbook-component.c Wed Oct 1 12:41:03 2003
@@ -566,6 +566,7 @@
NULL, NULL,
get_dnd_selection,
request_quit,
+ NULL,
NULL);
destination_interface = evolution_shell_component_dnd_destination_folder_new (destination_folder_handle_motion,
--- evolution-1.4.5-org/my-evolution/component-factory.c Thu May 15 09:46:01 2003
+++ evolution-1.4.5/my-evolution/component-factory.c Wed Oct 1 12:41:03 2003
@@ -137,7 +137,7 @@
NULL, NULL,
NULL, NULL,
NULL, NULL,
- NULL, NULL);
+ NULL, NULL,NULL);
g_signal_connect (shell_component, "owner_set", G_CALLBACK (owner_set_cb), NULL);
g_signal_connect (shell_component, "owner_unset", G_CALLBACK (owner_unset_cb), NULL);
--- evolution-1.4.5-org/calendar/gui/dialogs/alarm-options.c Fri Jul 25 09:44:19 2003
+++ evolution-1.4.5/calendar/gui/dialogs/alarm-options.c Wed Oct 1 15:55:19 2003
@@ -649,7 +649,7 @@
e_destination_freev (destv);
/* Description */
- text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dialog->dalarm_description));
+ text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dialog->malarm_description));
gtk_text_buffer_get_start_iter (text_buffer, &text_iter_start);
gtk_text_buffer_get_end_iter (text_buffer, &text_iter_end);
str = gtk_text_buffer_get_text (text_buffer, &text_iter_start, &text_iter_end, FALSE);
--- evolution-1.4.5-org/calendar/gui/alarm-notify/alarm-queue.c Thu May 15 09:43:22 2003
+++ evolution-1.4.5/calendar/gui/alarm-notify/alarm-queue.c Wed Oct 1 16:25:54 2003
@@ -24,7 +24,6 @@
#include <string.h>
#include <glib.h>
-#include <bonobo-activation/bonobo-activation.h>
#include <bonobo/bonobo-object.h>
#include <gtk/gtksignal.h>
#include <gtk/gtkbox.h>
@@ -44,6 +43,10 @@
#include "config-data.h"
#include "save.h"
+#include <Evolution.h>
+#include <bonobo/bonobo-exception.h>
+#include <bonobo/bonobo-moniker-util.h>
+#include <unistd.h>
/* Whether the queueing system has been initialized */
@@ -122,6 +125,8 @@
static void load_alarms_for_today (ClientAlarms *ca);
static void midnight_refresh_cb (gpointer alarm_id, time_t trigger, gpointer data);
+const gchar * strip_mailto (const gchar *address);
+
/* Queues an alarm trigger for midnight so that we can load the next day's worth
* of alarms.
@@ -829,30 +834,239 @@
display_notification (trigger, cqa, alarm_id, FALSE);
}
-/* Performs notification of a mail alarm */
-static void
-mail_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id)
+
+const gchar *
+strip_mailto (const gchar *address)
{
- GtkWidget *dialog;
- GtkWidget *label;
+ if (address == NULL)
+ return NULL;
+
+ if (!g_strncasecmp (address, "mailto:", 7))
+ address += 7;
+
+ return address;
+}
- /* FIXME */
- display_notification (trigger, cqa, alarm_id, FALSE);
+static GNOME_Evolution_Composer_RecipientList *
+comp_to_list (CalComponentAlarm *comp)
+{
+ GNOME_Evolution_Composer_RecipientList *to_list;
+ GNOME_Evolution_Composer_Recipient *recipient;
+ GSList *attendees ,*l;
+ gint len;
+
+ cal_component_alarm_get_attendee_list (comp, &attendees);
+
+ len = g_slist_length (attendees);
+ if (len <= 0) {
+ return NULL;
+ }
+
+ to_list = GNOME_Evolution_Composer_RecipientList__alloc ();
+ to_list->_maximum = len;
+ to_list->_length = 0;
+ to_list->_buffer = CORBA_sequence_GNOME_Evolution_Composer_Recipient_allocbuf (len);
+
+ for (l = attendees; l != NULL; l = l->next) {
+ CalComponentAttendee *att = l->data;
+
+ recipient = &(to_list->_buffer[to_list->_length]);
+ if (att->cn)
+ recipient->name = CORBA_string_dup (att->cn);
+ else
+ recipient->name = CORBA_string_dup ("");
+
+ recipient->address = CORBA_string_dup (strip_mailto (att->value));
+
+ to_list->_length++;
+ }
+ cal_component_free_attendee_list (attendees);
+
+
+ CORBA_sequence_set_release (to_list, TRUE);
+
+ return to_list;
+}
+
+/* return alarm summary text */
+static const char *
+get_summary(CalComponent *comp)
+{
+ CalComponentText text;
+ cal_component_get_summary (comp, &text);
+ if (text.value)
+ return text.value;
+ else
+ return _("No description available.");
+}
+
+
+static int
+sendmail(CompQueuedAlarms *cqa, gpointer alarm_id)
+{
+ static char *GNOME_EVOLUTION_COMPOSER_OAFIID = "OAFIID:GNOME_Evolution_Mail_Composer";
+ static char *GNOME_EVOLUTION_SHELL_OAFIID = "OAFIID:GNOME_Evolution_Shell";
+
+ GNOME_Evolution_Composer composer_server;
+ GNOME_Evolution_Shell shell;
+ GNOME_Evolution_ShellComponent shell_component;
+
+ QueuedAlarm *qa;
+ CalComponent *comp = NULL;
+ CalComponentAlarm *alarm;
+ CalComponentText description;
+ GNOME_Evolution_Composer_RecipientList *to_list = NULL;
+ GNOME_Evolution_Composer_RecipientList *cc_list = NULL;
+ GNOME_Evolution_Composer_RecipientList *bcc_list = NULL;
+ CORBA_char *subject = NULL, *body = NULL, *content_type = NULL;
+ CORBA_char *from = NULL;
+ char *summary;
+ CORBA_Environment ev;
+ gboolean retval = FALSE;
+ GString *mail_text;
+ int i = 0;
+
+
+ CORBA_exception_init (&ev);
+ /* Obtain an object reference for the shell. */
+ shell = bonobo_activation_activate_from_id (GNOME_EVOLUTION_SHELL_OAFIID, 0, NULL, &ev);
+
+ if (BONOBO_EX (&ev)) {
+ g_warning ("Could not activate shell: %s", bonobo_exception_get_text (&ev));
+ CORBA_exception_free (&ev);
+ return FALSE;
+ }
+
+ /* Ugly hack to wait for the shell to be ready (if not running) , at least on my SMP system */
+ for(i = 2;i <= 10;i++){
+ /* Obtain an object reference for the component.*/
+ CORBA_exception_init (&ev);
+ shell_component = GNOME_Evolution_Shell_getComponentByType(shell,"mail",&ev);
+
+ if (! BONOBO_EX (&ev)) {
+ break;
+ }
+
+ if(i == 10 && BONOBO_EX (&ev)){
+ g_warning ("Could not activate shell_component: %s", bonobo_exception_get_text (&ev));
+ CORBA_exception_free (&ev);
+ return FALSE;
+ }
+
+ sleep(i);
+ }
+
+
+
+ /* Obtain an object reference for the composer */
+ CORBA_exception_init (&ev);
+ composer_server = GNOME_Evolution_ShellComponent_getComposer(shell_component,GNOME_EVOLUTION_COMPOSER_OAFIID,&ev);
+ if (BONOBO_EX (&ev)) {
+ g_warning ("Could not activate composer: %s", bonobo_exception_get_text (&ev));
+ CORBA_exception_free (&ev);
+ return FALSE;
+ }
+
+ comp = cqa->alarms->comp;
+ qa = lookup_queued_alarm (cqa, alarm_id);
+ if (!qa)
+ goto cleanup;
+
+ alarm = cal_component_get_alarm (comp, qa->instance->auid);
+ g_assert (alarm != NULL);
- dialog = gtk_dialog_new_with_buttons (_("Warning"),
- NULL, 0,
- GTK_STOCK_OK, GTK_RESPONSE_CANCEL,
- NULL);
- label = gtk_label_new (_("Evolution does not support calendar reminders with\n"
- "email notifications yet, but this reminder was\n"
- "configured to send an email. Evolution will display\n"
- "a normal reminder dialog box instead."));
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label, TRUE, TRUE, 4);
+
+ /* Recipients */
+ to_list = comp_to_list (alarm);
+
+ if(to_list == NULL){
+ goto cleanup;
+ }
- gtk_dialog_run (GTK_DIALOG (dialog));
+ cal_component_alarm_get_description (alarm, &description);
+ cal_component_alarm_free (alarm);
+
+ cc_list = GNOME_Evolution_Composer_RecipientList__alloc ();
+ cc_list->_maximum = cc_list->_length = 0;
+ bcc_list = GNOME_Evolution_Composer_RecipientList__alloc ();
+ bcc_list->_maximum = bcc_list->_length = 0;
+
+ /* Subject information */
+ subject = CORBA_string_dup("Reminder");
+
+ /* From address; use default*/
+ from = CORBA_string_dup("");
+
+ GNOME_Evolution_Composer_setHeaders (composer_server, from, to_list, cc_list, bcc_list, subject, &ev);
+ if (BONOBO_EX (&ev)) {
+ g_warning ("Unable to set composer headers while sending summary message");
+ goto cleanup;
+ }
+
+ /* Content type */
+ content_type = CORBA_string_dup("text/plain");
+
+ if (description.value) {
+ mail_text = g_string_new(get_summary(comp));
+ g_string_append(mail_text,"\n\n");
+ g_string_append(mail_text,description.value);
+ summary = CORBA_string_dup(mail_text->str);
+ g_string_free(mail_text,TRUE);
+ } else
+ summary = CORBA_string_dup(get_summary(comp));
+
+
+ GNOME_Evolution_Composer_setBody (composer_server, summary, content_type, &ev);
+ if (BONOBO_EX (&ev)) {
+ g_warning ("Unable to place summary message in composer");
+ goto cleanup;
+ }
+
+ GNOME_Evolution_Composer_send (composer_server, &ev);
+ if (BONOBO_EX (&ev))
+ g_warning ("Unable to send summary message");
+ else
+ retval = TRUE;
+ return retval;
+
+ cleanup:
+ CORBA_exception_free (&ev);
+
+ if (comp != NULL)
+ gtk_object_unref (GTK_OBJECT (comp));
+ if (to_list != NULL)
+ CORBA_free (to_list);
+ if (cc_list != NULL)
+ CORBA_free (cc_list);
+ if (bcc_list != NULL)
+ CORBA_free (bcc_list);
+ if (from != NULL)
+ CORBA_free (from);
+ if (subject != NULL)
+ CORBA_free (subject);
+ if (body != NULL)
+ CORBA_free (body);
+ if (content_type != NULL)
+ CORBA_free (content_type);
+
+ return FALSE;
}
+
+
+
+
+/* Performs notification of a mail alarm */
+static void
+mail_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id)
+{
+ sendmail( cqa, alarm_id);
+ return;
+
+}
+
+
/* Performs notification of a procedure alarm */
static gboolean
procedure_notification_dialog (const char *cmd, const char *url)
--- evolution-1.4.5-org/calendar/gui/alarm-notify/Makefile.am Thu Jun 12 11:03:27 2003
+++ evolution-1.4.5/calendar/gui/alarm-notify/Makefile.am Wed Oct 1 12:41:03 2003
@@ -1,15 +1,24 @@
CORBA_GENERATED_H = \
- evolution-calendar.h
+ evolution-calendar.h \
+ Evolution.h
+
CORBA_GENERATED_C = \
evolution-calendar-common.c \
evolution-calendar-skels.c \
- evolution-calendar-stubs.c
+ evolution-calendar-stubs.c \
+ Evolution-common.c \
+ Evolution-skels.c \
+ Evolution-stubs.c
+
CORBA_GENERATED = $(CORBA_GENERATED_C) $(CORBA_GENERATED_H)
-idls = $(top_srcdir)/calendar/idl/evolution-calendar.idl
+idls = \
+ $(top_srcdir)/shell/Evolution.idl \
+ $(top_srcdir)/calendar/idl/evolution-calendar.idl
idl_flags = $(IDL_INCLUDES)
$(CORBA_GENERATED_H): $(idls)
+ $(ORBIT_IDL) $(idl_flags) $(top_srcdir)/shell/Evolution.idl
$(ORBIT_IDL) $(idl_flags) $(top_srcdir)/calendar/idl/evolution-calendar.idl
$(CORBA_GENERATED_C): $(CORBA_GENERATED_H)
--- evolution-1.4.5-org/calendar/ChangeLog Thu Sep 11 10:19:04 2003
+++ evolution-1.4.5/calendar/ChangeLog Wed Oct 1 18:10:26 2003
@@ -1,3 +1,12 @@
+2003-9-30 Ronald Kuetemeier ronald kuetemeier com
+
+ * gui/calendar-component.c
+ * gui/alarm-notify/alarm-queue.c
+ * gui/dialogs/alarm-options.c
+ * gui/alarm-notify/Makefile.am
+ * pcs/cal-backend-file.c
+ added sendmail capability to alarm-queue and enabled email for alarms
+
2003-09-11 Frederic Crozat <fcrozat mandrakesoft com>
* conduits/todo/Makefile.am:
--- evolution-1.4.5-org/shell/ChangeLog Fri Sep 12 12:40:53 2003
+++ evolution-1.4.5/shell/ChangeLog Wed Oct 1 18:07:03 2003
@@ -1,3 +1,12 @@
+2003-9-30 Ronald Kuetemeier ronald kuetemeier com
+
+ * Evolution-ShellComponent.idl
+ * Evolution.idl
+ * evolution-shell-component.c
+ * evolution-shell-component.h
+ * evolution-test-component.c
+ added getComposer
+
2003-09-12 Frederic Crozat <fcrozat mandrakesoft com>
* e-config-upgrade.c: (utf8_reencode), (upgrade_xml_1_2_rec),
--- evolution-1.4.5-org/mail/ChangeLog Fri Sep 12 12:40:39 2003
+++ evolution-1.4.5/mail/ChangeLog Wed Oct 1 18:04:34 2003
@@ -1,3 +1,8 @@
+2003-9-30 Ronald Kuetemeier ronald kuetemeier com
+
+ * component-factory.c
+ implemented getComposer
+
2003-09-11 Jeffrey Stedfast <fejj ximian com>
* mail-format.c (handle_text_plain): Don't set inend until after
--- evolution-1.4.5-org/addressbook/ChangeLog Fri Sep 12 12:39:07 2003
+++ evolution-1.4.5/addressbook/ChangeLog Wed Oct 1 18:09:06 2003
@@ -1,3 +1,8 @@
+2003-9-30 Ronald Kuetemeier ronald kuetemeier com
+
+ * /gui/component/addressbook-component.c
+ added NULL for new getComposer function
+
2003-09-05 Dan Winship <danw ximian com>
* gui/component/select-names/Makefile.am: Make libeselectnames.la
--- evolution-1.4.5-org/my-evolution/ChangeLog Thu Sep 11 10:20:44 2003
+++ evolution-1.4.5/my-evolution/ChangeLog Wed Oct 1 18:09:59 2003
@@ -1,3 +1,8 @@
+2003-9-30 Ronald Kuetemeier ronald kuetemeier com
+
+ * component-factory.c
+ added NULL for new getComposer function
+
2003-09-08 Calvin Liu <calvin liu sun com>
** For bug #48175
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]