aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--filter/ChangeLog9
-rw-r--r--filter/filter-source.c116
-rw-r--r--filter/filtertypes.xml6
-rw-r--r--filter/libfilter-i18n.h36
4 files changed, 94 insertions, 73 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog
index df9b4d0e06..ab0408dc26 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -1,3 +1,12 @@
+2001-07-09 Jon Trowbridge <trow@ximian.com>
+
+ * filter-source.c (filter_source_get_sources): Bonobo-conf-ified.
+ Removed /home/trow hard-wiring. :)
+ (xml_encode): Encode things properly.
+ (xml_decode): Decode things properly.
+ (get_widget): Ignore accounts w/o source URLs.
+ (clone): Set the ->name in our copy.
+
2001-07-05 Jeffrey Stedfast <fejj@ximian.com>
* rule-editor.c (rule_delete): Select the most appropriate filter
diff --git a/filter/filter-source.c b/filter/filter-source.c
index dff970b9a5..5111a0b106 100644
--- a/filter/filter-source.c
+++ b/filter/filter-source.c
@@ -26,12 +26,20 @@
*/
#include <config.h>
+#include "filter-source.h"
+
#include <gtk/gtk.h>
#include <gnome.h>
#include <gal/widgets/e-unicode.h>
#include <e-util/e-url.h>
#include <e-util/e-sexp.h>
-#include "filter-source.h"
+#include <bonobo/bonobo-object.h>
+#include <bonobo/bonobo-generic-factory.h>
+#include <bonobo/bonobo-context.h>
+#include <bonobo/bonobo-moniker-util.h>
+#include <bonobo/bonobo-exception.h>
+#include <bonobo-conf/bonobo-config-database.h>
+
typedef struct _SourceInfo SourceInfo;
struct _SourceInfo {
@@ -155,7 +163,6 @@ static void
xml_create (FilterElement *fe, xmlNodePtr node)
{
/* Call parent implementation */
-
((FilterElementClass *)parent_class)->xml_create (fe, node);
}
@@ -167,19 +174,11 @@ xml_encode (FilterElement *fe)
FilterSource *fs = (FilterSource *) fe;
value = xmlNewNode (NULL, "value");
- /*
- xmlSetProp (value, "name", fe->name);
- g_message ("fe->name: [%s]", fe->name);
- */
-
- /* FIXME */
- xmlSetProp (value, "name", "uri");
-
-
- xmlSetProp (value, "type", "source");
+ xmlSetProp (value, "name", fe->name);
+ xmlSetProp (value, "type", "uri");
if (fs->priv->current_url)
- xmlSetProp (value, "uri", fs->priv->current_url);
+ xmlNewTextChild (value, NULL, "uri", fs->priv->current_url);
return value;
}
@@ -189,13 +188,13 @@ xml_decode (FilterElement *fe, xmlNodePtr node)
{
FilterSource *fs = (FilterSource *) fe;
gchar *value;
-
- xmlFree (fe->name);
- fe->name = xmlGetProp (node, "name");
- value = xmlGetProp (node, "uri");
- xmlFree (fs->priv->current_url);
- fs->priv->current_url = value;
-
+
+ node = node->childs;
+ if (node && node->name && !strcmp (node->name, "uri")) {
+ g_free (fs->priv->current_url);
+ fs->priv->current_url = xmlNodeGetContent (node);
+ }
+
return 0;
}
@@ -206,6 +205,8 @@ clone (FilterElement *fe)
FilterSource *cpy = filter_source_new ();
GList *i;
+ ((FilterElement *)cpy)->name = g_strdup (fe->name);
+
cpy->priv->current_url = g_strdup (fs->priv->current_url);
for (i = fs->priv->sources; i != NULL; i = g_list_next (i)) {
@@ -243,28 +244,33 @@ get_widget (FilterElement *fe)
index = 0;
current_index = -1;
+
for (i = fs->priv->sources; i != NULL; i = g_list_next (i)) {
SourceInfo *info = (SourceInfo *) i->data;
gchar *label, *native_label;
- if (first == NULL)
- first = info;
-
- label = g_strdup_printf ("%s <%s>", info->name, info->address);
- native_label = e_utf8_to_gtk_string (GTK_WIDGET (menu), label);
- item = gtk_menu_item_new_with_label (native_label);
- g_free (label);
- g_free (native_label);
-
- gtk_object_set_data (GTK_OBJECT (item), "source", info);
- gtk_signal_connect (GTK_OBJECT (item), "activate", GTK_SIGNAL_FUNC (source_changed), fs);
- gtk_menu_append (GTK_MENU (menu), item);
- gtk_widget_show (item);
-
- if (fs->priv->current_url && e_url_equal (info->url, fs->priv->current_url))
- current_index = index;
-
- ++index;
+ if (info->url != NULL) {
+
+ if (first == NULL)
+ first = info;
+
+ label = g_strdup_printf ("%s <%s>", info->name, info->address);
+ native_label = e_utf8_to_gtk_string (GTK_WIDGET (menu), label);
+ item = gtk_menu_item_new_with_label (native_label);
+ g_free (label);
+ g_free (native_label);
+
+ gtk_object_set_data (GTK_OBJECT (item), "source", info);
+ gtk_signal_connect (GTK_OBJECT (item), "activate", GTK_SIGNAL_FUNC (source_changed), fs);
+ gtk_menu_append (GTK_MENU (menu), item);
+ gtk_widget_show (item);
+
+ if (fs->priv->current_url && e_url_equal (info->url, fs->priv->current_url)) {
+ current_index = index;
+ }
+
+ ++index;
+ }
}
omenu = gtk_option_menu_new ();
@@ -288,7 +294,7 @@ get_widget (FilterElement *fe)
static void
build_code (FilterElement *fe, GString *out, struct _FilterPart *ff)
{
- g_message ("build_code: [%s]", out->str);
+ /* We are doing nothing on purpose. */
}
static void
@@ -296,7 +302,6 @@ format_sexp (FilterElement *fe, GString *out)
{
FilterSource *fs = (FilterSource *) fe;
- g_message ("format_sexp: [%s](%d)", out->str, out->len);
e_sexp_encode_string (out, fs->priv->current_url);
}
@@ -315,34 +320,41 @@ filter_source_add_source (FilterSource *fs, const gchar *name, const gchar *addr
fs->priv->sources = g_list_append (fs->priv->sources, info);
}
-/* Bad hack; copies some code from mail-config.c */
static void
filter_source_get_sources (FilterSource *fs)
{
- gchar *str;
+ Bonobo_ConfigDatabase db;
+ CORBA_Environment ev;
gint i, len;
- str = g_strdup_printf ("=%s/config/Mail=/Accounts/", "/home/trow/evolution");
- gnome_config_push_prefix (str);
- g_free (str);
+ CORBA_exception_init (&ev);
+ db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev);
+
+ if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) {
+ CORBA_exception_free (&ev);
+ return;
+ }
+
+ CORBA_exception_free (&ev);
- len = gnome_config_get_int ("num");
+ len = bonobo_config_get_long_with_default (db, "/Mail/Accounts/num", 0, NULL);
+
for (i = 0; i < len; ++i) {
gchar *path;
gchar *name;
gchar *addr;
gchar *url;
- path = g_strdup_printf ("identity_name_%d", i);
- name = gnome_config_get_string (path);
+ path = g_strdup_printf ("/Mail/Accounts/identity_name_%d", i);
+ name = bonobo_config_get_string (db, path, NULL);
g_free (path);
- path = g_strdup_printf ("identity_address_%d", i);
- addr = gnome_config_get_string (path);
+ path = g_strdup_printf ("/Mail/Accounts/identity_address_%d", i);
+ addr = bonobo_config_get_string (db, path, NULL);
g_free (path);
- path = g_strdup_printf ("source_url_%d", i);
- url = gnome_config_get_string (path);
+ path = g_strdup_printf ("/Mail/Accounts/source_url_%d", i);
+ url = bonobo_config_get_string (db, path, NULL);
g_free (path);
filter_source_add_source (fs, name, addr, url);
diff --git a/filter/filtertypes.xml b/filter/filtertypes.xml
index 6b8ebff00f..e40ca760ec 100644
--- a/filter/filtertypes.xml
+++ b/filter/filtertypes.xml
@@ -559,17 +559,17 @@
<option value="is">
<title>is</title>
<code>
- (match-all (= (get-source) ${uri}))
+ (match-all (= (get-source) ${source}))
</code>
</option>
<option value="is-not">
<title>is not</title>
<code>
- (match-all (not (= (get-source) ${uri})))
+ (match-all (not (= (get-source) ${source})))
</code>
</option>
</input>
- <input type="source" name="uri"/>
+ <input type="source" name="source"/>
</part>
</partset>
diff --git a/filter/libfilter-i18n.h b/filter/libfilter-i18n.h
index 0c05212bc4..74d53fefe9 100644
--- a/filter/libfilter-i18n.h
+++ b/filter/libfilter-i18n.h
@@ -1,40 +1,24 @@
/* Automatically generated. Do not edit. */
-char *s = N_("after");
char *s = N_("Assign Color");
char *s = N_("Assign Score");
char *s = N_("Attachments");
-char *s = N_("before");
-char *s = N_("contains");
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_("does not contain");
-char *s = N_("does not end with");
-char *s = N_("does not exist");
-char *s = N_("does not sound like");
-char *s = N_("does not start with");
char *s = N_("Do Not Exist");
char *s = N_("Draft");
-char *s = N_("ends with");
char *s = N_("Exist");
-char *s = N_("exists");
char *s = N_("Expression");
char *s = N_("Forward to Address");
char *s = N_("Important");
-char *s = N_("is");
-char *s = N_("is greater than");
-char *s = N_("is less than");
-char *s = N_("is not");
char *s = N_("Mailing list");
char *s = N_("Message Body");
char *s = N_("Message Header");
char *s = N_("Message was received");
char *s = N_("Message was sent");
char *s = N_("Move to Folder");
-char *s = N_("on or after");
-char *s = N_("on or before");
char *s = N_("Read");
char *s = N_("Recipients");
char *s = N_("Regex Match");
@@ -43,12 +27,28 @@ char *s = N_("Score");
char *s = N_("Sender");
char *s = N_("Set Status");
char *s = N_("Size (kB)");
-char *s = N_("sounds like");
char *s = N_("Source Account");
char *s = N_("Specific header");
-char *s = N_("starts with");
char *s = N_("Status");
char *s = N_("Stop Processing");
char *s = N_("Subject");
+char *s = N_("after");
+char *s = N_("before");
+char *s = N_("contains");
+char *s = N_("does not contain");
+char *s = N_("does not end with");
+char *s = N_("does not exist");
+char *s = N_("does not sound like");
+char *s = N_("does not start with");
+char *s = N_("ends with");
+char *s = N_("exists");
+char *s = N_("is greater than");
+char *s = N_("is less than");
+char *s = N_("is not");
+char *s = N_("is");
+char *s = N_("on or after");
+char *s = N_("on or before");
+char *s = N_("sounds like");
+char *s = N_("starts with");
char *s = N_("was after");
char *s = N_("was before");