aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2000-11-01 03:39:02 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2000-11-01 03:39:02 +0800
commit84664338374cb9e52d9d33512bebde4708f866a7 (patch)
tree436cdbc448f60a4a161af69c82edb21cb8f711c5
parentb3a536d46bfc6f4ed4524ec6252abfcea2f97423 (diff)
downloadgsoc2013-evolution-84664338374cb9e52d9d33512bebde4708f866a7.tar
gsoc2013-evolution-84664338374cb9e52d9d33512bebde4708f866a7.tar.gz
gsoc2013-evolution-84664338374cb9e52d9d33512bebde4708f866a7.tar.bz2
gsoc2013-evolution-84664338374cb9e52d9d33512bebde4708f866a7.tar.lz
gsoc2013-evolution-84664338374cb9e52d9d33512bebde4708f866a7.tar.xz
gsoc2013-evolution-84664338374cb9e52d9d33512bebde4708f866a7.tar.zst
gsoc2013-evolution-84664338374cb9e52d9d33512bebde4708f866a7.zip
Updated to add an action to set message flags.
2000-10-31 Jeffrey Stedfast <fejj@helixcode.com> * filtertypes.xml: Updated to add an action to set message flags. * filter-driver.c (do_flag): New callback to set message info flags. * filter-element.c (filter_element_set_data): New convenience function to set the data on a FilterElement. * filter-url.c (get_widget): Set the sources list to point to the FilterElement data. svn path=/trunk/; revision=6298
-rw-r--r--filter/ChangeLog13
-rw-r--r--filter/filter-driver.c55
-rw-r--r--filter/filter-element.c6
-rw-r--r--filter/filter-element.h2
-rw-r--r--filter/filter-url.c2
-rw-r--r--filter/filtertypes.xml35
-rw-r--r--filter/libfilter-i18n.h6
7 files changed, 111 insertions, 8 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog
index 11ea73f699..d0c8f3043d 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -1,3 +1,16 @@
+2000-10-31 Jeffrey Stedfast <fejj@helixcode.com>
+
+ * filtertypes.xml: Updated to add an action to set message flags.
+
+ * filter-driver.c (do_flag): New callback to set message info
+ flags.
+
+ * filter-element.c (filter_element_set_data): New convenience
+ function to set the data on a FilterElement.
+
+ * filter-url.c (get_widget): Set the sources list to point to the
+ FilterElement data.
+
2000-10-31 Federico Mena Quintero <federico@helixcode.com>
* filter-rule.c (get_widget): Do not pad around the Name hbox;
diff --git a/filter/filter-driver.c b/filter/filter-driver.c
index 744ca6e526..ac49bf0ac4 100644
--- a/filter/filter-driver.c
+++ b/filter/filter-driver.c
@@ -90,6 +90,7 @@ static ESExpResult *do_move (struct _ESExp *f, int argc, struct _ESExpResult **a
static ESExpResult *do_stop (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *);
static ESExpResult *do_colour (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *);
static ESExpResult *do_score (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *);
+static ESExpResult *do_flag (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *);
/* these are our filter actions - each must have a callback */
static struct {
@@ -104,7 +105,8 @@ static struct {
{ "move-to", (ESExpFunc *) do_move, 0 },
{ "stop", (ESExpFunc *) do_stop, 0 },
{ "set-colour", (ESExpFunc *) do_colour, 0 },
- { "set-score", (ESExpFunc *) do_score, 0 }
+ { "set-score", (ESExpFunc *) do_score, 0 },
+ { "set-flag", (ESExpFunc *) do_flag, 0 }
};
static GtkObjectClass *filter_driver_parent;
@@ -410,6 +412,45 @@ do_score (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *
return NULL;
}
+static ESExpResult *
+do_flag (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *driver)
+{
+ struct _FilterDriverPrivate *p = _PRIVATE (driver);
+
+ d(fprintf (stderr, "setting flag\n"));
+ if (argc > 0 && argv[0]->type == ESEXP_RES_INT) {
+ char *flag;
+
+ switch (argv[0]->value.number) {
+ case CAMEL_MESSAGE_ANSWERED:
+ p->info->flags |= CAMEL_MESSAGE_ANSWERED;
+ flag = "Answered";
+ break;
+ case CAMEL_MESSAGE_DELETED:
+ p->info->flags |= CAMEL_MESSAGE_DELETED;
+ flag = "Deleted";
+ break;
+ case CAMEL_MESSAGE_DRAFT:
+ p->info->flags |= CAMEL_MESSAGE_DRAFT;
+ flag = "Draft";
+ break;
+ case CAMEL_MESSAGE_FLAGGED:
+ p->info->flags |= CAMEL_MESSAGE_FLAGGED;
+ flag = "Flagged";
+ break;
+ case CAMEL_MESSAGE_SEEN:
+ p->info->flags |= CAMEL_MESSAGE_SEEN;
+ flag = "Seen";
+ break;
+ default:
+ flag = "Unknown";
+ }
+ report_status (driver, FILTER_STATUS_ACTION, "Set %s flag", flag);
+ }
+
+ return NULL;
+}
+
static CamelFolder *
open_folder (FilterDriver *driver, const char *folder_url)
{
@@ -478,16 +519,16 @@ filter_driver_status_log (FilterDriver *driver, enum filter_status_t status,
FILE *out = data;
switch(status) {
- case FILTER_STATUS_END: {
+ case FILTER_STATUS_START: {
/* write log header */
time_t t;
char date[50];
char *from = NULL;
char *subject = NULL;
-
+
if (msg) {
- from = camel_mime_message_get_from(msg);
- subject = camel_mime_message_get_subject(msg);
+ from = camel_mime_message_get_from (msg);
+ subject = camel_mime_message_get_subject (msg);
}
time (&t);
@@ -497,7 +538,7 @@ filter_driver_status_log (FilterDriver *driver, enum filter_status_t status,
subject ? subject : "", date);
break;
}
- case FILTER_STATUS_START:
+ case FILTER_STATUS_END:
fprintf (out, "\n");
break;
case FILTER_STATUS_ACTION:
@@ -544,7 +585,7 @@ filter_driver_filter_mbox (FilterDriver *driver, const char *mbox, const char *s
if (st.st_size > 0)
pc = (int)(100.0 * ((double)camel_mime_parser_tell (mp) / (double)st.st_size));
-
+
report_status (driver, FILTER_STATUS_START, "Getting message %d (%d%% of file)", i, pc);
msg = camel_mime_message_new ();
diff --git a/filter/filter-element.c b/filter/filter-element.c
index ad6e133a6a..1084ca6ca0 100644
--- a/filter/filter-element.c
+++ b/filter/filter-element.c
@@ -268,6 +268,12 @@ filter_element_new_type_name (const char *type)
}
}
+void
+filter_element_set_data (FilterElement *fe, gpointer data)
+{
+ fe->data = data;
+}
+
/* default implementations */
static gboolean
validate (FilterElement *fe, gpointer data)
diff --git a/filter/filter-element.h b/filter/filter-element.h
index ce5290c3cb..63befc3969 100644
--- a/filter/filter-element.h
+++ b/filter/filter-element.h
@@ -65,6 +65,8 @@ FilterElement *filter_element_new (void);
FilterElement *filter_element_new_type_name (const char *type);
+void filter_element_set_data (FilterElement *fe, gpointer data);
+
/* methods */
gboolean filter_element_validate (FilterElement *fe, gpointer data);
diff --git a/filter/filter-url.c b/filter/filter-url.c
index d647d38e65..7f507d0dca 100644
--- a/filter/filter-url.c
+++ b/filter/filter-url.c
@@ -188,7 +188,7 @@ static GtkWidget *
get_widget (FilterElement *fe)
{
GtkWidget *combo;
- GList *sources = NULL; /* this needs to be a list of urls */
+ GList *sources = fe->data; /* this needs to be a list of urls */
combo = gtk_combo_new ();
gtk_combo_set_popdown_strings (GTK_COMBO (combo), sources);
diff --git a/filter/filtertypes.xml b/filter/filtertypes.xml
index 07846d731c..9b6946c030 100644
--- a/filter/filtertypes.xml
+++ b/filter/filtertypes.xml
@@ -486,5 +486,40 @@
<code>(set-score ${score})</code>
<input type="score" name="score"/>
</part>
+ <part name="flag">
+ <title>Set Flag</title>
+ <input type="optionlist" name="flag-type">
+ <option value="answered">
+ <title>Answered</title>
+ <code>
+ (set-flag 1)
+ </code>
+ </option>
+ <option value="deleted">
+ <title>Deleted</title>
+ <code>
+ (set-flag 2)
+ </code>
+ </option>
+ <option value="draft">
+ <title>Draft</title>
+ <code>
+ (set-flag 4)
+ </code>
+ </option>
+ <option value="flagged">
+ <title>Flagged</title>
+ <code>
+ (set-flag 8)
+ </code>
+ </option>
+ <option value="seen">
+ <title>Seen</title>
+ <code>
+ (set-flag 16)
+ </code>
+ </option>
+ </input>
+ </part>
</actionset>
</filterdescription>
diff --git a/filter/libfilter-i18n.h b/filter/libfilter-i18n.h
index b85253bd3b..3cac52183b 100644
--- a/filter/libfilter-i18n.h
+++ b/filter/libfilter-i18n.h
@@ -1,11 +1,15 @@
/* Automatically generated. Do not edit. */
+char *s = N_("Answered");
char *s = N_("Assign Colour");
char *s = N_("Assign Score");
char *s = N_("Copy to Folder");
char *s = N_("Date received");
char *s = N_("Date sent");
char *s = N_("Delete");
+char *s = N_("Deleted");
+char *s = N_("Draft");
char *s = N_("Expression");
+char *s = N_("Flagged");
char *s = N_("Forward to Address");
char *s = N_("Message Body");
char *s = N_("Message was received");
@@ -13,7 +17,9 @@ char *s = N_("Message was sent");
char *s = N_("Move to Folder");
char *s = N_("Priority");
char *s = N_("Recipients");
+char *s = N_("Seen");
char *s = N_("Sender");
+char *s = N_("Set Flag");
char *s = N_("Source");
char *s = N_("Specific header");
char *s = N_("Stop Processing");