diff options
author | Rodrigo Moya <rodrigo@novell.com> | 2004-10-22 01:19:48 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@src.gnome.org> | 2004-10-22 01:19:48 +0800 |
commit | f737b385d7326c888bf0ba3d514b30d5c6c5da95 (patch) | |
tree | 410b11cb22c3dbce08513dbbc70eafd6c294803f /plugins/mail-to-task | |
parent | 7aba0ba1d5025a089303dfa513f3cc92a03bc00a (diff) | |
download | gsoc2013-evolution-f737b385d7326c888bf0ba3d514b30d5c6c5da95.tar gsoc2013-evolution-f737b385d7326c888bf0ba3d514b30d5c6c5da95.tar.gz gsoc2013-evolution-f737b385d7326c888bf0ba3d514b30d5c6c5da95.tar.bz2 gsoc2013-evolution-f737b385d7326c888bf0ba3d514b30d5c6c5da95.tar.lz gsoc2013-evolution-f737b385d7326c888bf0ba3d514b30d5c6c5da95.tar.xz gsoc2013-evolution-f737b385d7326c888bf0ba3d514b30d5c6c5da95.tar.zst gsoc2013-evolution-f737b385d7326c888bf0ba3d514b30d5c6c5da95.zip |
implemented plugin for converting selected mails to tasks.
2004-10-21 Rodrigo Moya <rodrigo@novell.com>
* mail-to-task.c: implemented plugin for converting selected
mails to tasks.
svn path=/trunk/; revision=27682
Diffstat (limited to 'plugins/mail-to-task')
-rw-r--r-- | plugins/mail-to-task/.cvsignore | 5 | ||||
-rw-r--r-- | plugins/mail-to-task/ChangeLog | 4 | ||||
-rw-r--r-- | plugins/mail-to-task/Makefile.am | 11 | ||||
-rw-r--r-- | plugins/mail-to-task/mail-to-task.c | 110 | ||||
-rw-r--r-- | plugins/mail-to-task/org-gnome-mail-to-task.eplug.in | 24 |
5 files changed, 154 insertions, 0 deletions
diff --git a/plugins/mail-to-task/.cvsignore b/plugins/mail-to-task/.cvsignore new file mode 100644 index 0000000000..683d5ddbe2 --- /dev/null +++ b/plugins/mail-to-task/.cvsignore @@ -0,0 +1,5 @@ +.deps +.libs +Makefile +Makefile.in +*.eplug
\ No newline at end of file diff --git a/plugins/mail-to-task/ChangeLog b/plugins/mail-to-task/ChangeLog new file mode 100644 index 0000000000..7e27195076 --- /dev/null +++ b/plugins/mail-to-task/ChangeLog @@ -0,0 +1,4 @@ +2004-10-21 Rodrigo Moya <rodrigo@novell.com> + + * mail-to-task.c: implemented plugin for converting selected + mails to tasks.
\ No newline at end of file diff --git a/plugins/mail-to-task/Makefile.am b/plugins/mail-to-task/Makefile.am new file mode 100644 index 0000000000..c27ceccbc8 --- /dev/null +++ b/plugins/mail-to-task/Makefile.am @@ -0,0 +1,11 @@ +INCLUDES = \ + -I$(top_srcdir) \ + $(EVOLUTION_MAIL_CFLAGS) + +@EVO_PLUGIN_RULE@ + +plugin_DATA = org-gnome-mail-to-task.eplug +plugin_LTLIBRARIES = liborg-gnome-mail-to-task.la + +liborg_gnome_mail_to_task_la_SOURCES = mail-to-task.c +liborg_gnome_mail_to_task_la_LDFLAGS = -module -avoid-version diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c new file mode 100644 index 0000000000..c4b51fd9de --- /dev/null +++ b/plugins/mail-to-task/mail-to-task.c @@ -0,0 +1,110 @@ + +/* Copyright (C) 2004 Michael Zucchi */ + +/* This file is licensed under the GNU GPL v2 or later */ + +/* Add 'copy to clipboard' things to various menu's. + + Uh, so far only to copy mail addresses from mail content */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <glib/gi18n-lib.h> +#include <string.h> +#include <stdio.h> + +#include <gconf/gconf-client.h> +#include <libecal/e-cal.h> +#include <libedataserverui/e-source-selector-dialog.h> +#include "camel/camel-folder.h" +#include "camel/camel-mime-message.h" +#include "mail/em-popup.h" + +static void +do_mail_to_task (EMPopupTargetSelect *t, ESource *tasks_source) +{ + ECal *client; + + /* open the task client */ + client = e_cal_new (tasks_source, E_CAL_SOURCE_TYPE_TODO); + if (e_cal_open (client, FALSE, NULL)) { + int i; + + for (i = 0; i < (t->uids ? t->uids->len : 0); i++) { + CamelMimeMessage *message; + ECalComponent *comp; + ECalComponentText text; + char *str; + GSList sl; + + /* retrieve the message from the CamelFolder */ + message = camel_folder_get_message (t->folder, g_ptr_array_index (t->uids, i), NULL); + if (!message) + continue; + + comp = e_cal_component_new (); + e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_TODO); + e_cal_component_set_uid (comp, camel_mime_message_get_message_id (message)); + + text.value = camel_mime_message_get_subject (message); + text.altrep = NULL; + e_cal_component_set_summary (comp, &text); + + /* FIXME: a better way to get the full body */ + str = camel_mime_message_build_mbox_from (message); + text.value = str; + sl.next = NULL; + sl.data = &text; + e_cal_component_set_description_list (comp, &sl); + + g_free (str); + + /* save the task to the selected source */ + e_cal_create_object (client, e_cal_component_get_icalcomponent (comp), NULL, NULL); + + g_object_unref (comp); + } + } + + /* free memory */ + g_object_unref (client); +} + +void org_gnome_mail_to_task (void *ep, EMPopupTargetSelect *t); + +void +org_gnome_mail_to_task (void *ep, EMPopupTargetSelect *t) +{ + GtkWidget *dialog; + GConfClient *conf_client; + ESourceList *source_list; + + /* ask the user which tasks list to save to */ + conf_client = gconf_client_get_default (); + source_list = e_source_list_new_for_gconf (conf_client, "/apps/evolution/tasks/sources"); + + dialog = e_source_selector_dialog_new (NULL, source_list); + + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) { + ESource *source; + + /* if a source has been selected, perform the mail2task operation */ + source = e_source_selector_dialog_peek_primary_selection (E_SOURCE_SELECTOR_DIALOG (dialog)); + if (source) + do_mail_to_task (t, source); + } + + g_object_unref (conf_client); + g_object_unref (source_list); + gtk_widget_destroy (dialog); +} + +int e_plugin_lib_enable(EPluginLib *ep, int enable); + +int +e_plugin_lib_enable(EPluginLib *ep, int enable) +{ + return 0; +} diff --git a/plugins/mail-to-task/org-gnome-mail-to-task.eplug.in b/plugins/mail-to-task/org-gnome-mail-to-task.eplug.in new file mode 100644 index 0000000000..dd36bb3de8 --- /dev/null +++ b/plugins/mail-to-task/org-gnome-mail-to-task.eplug.in @@ -0,0 +1,24 @@ +<?xml version="1.0"?> +<e-plugin-list> + <e-plugin + type="shlib" + id="org.gnome.evolution.plugin.mailToTask" + location="@PLUGINDIR@/liborg-gnome-mail-to-task.so" + name="Convert a mail message into a task" + description="A plugin which allows the creation of tasks from the contents of a mail message"> + + <!-- hook into the uri popup menu --> + <hook class="org.gnome.evolution.mail.popup:1.0"> + <menu id="org.gnome.evolution.mail.folderview.popup.uri" target="select"> + <item + type="item" + path="71.mail_to_task" + image="stock_tasks" + label="Con_vert to Task" + enable="one" + visible="one" + activate="org_gnome_mail_to_task"/> + </menu> + </hook> + </e-plugin> +</e-plugin-list> |