Redo Filters/Search folder editors to use a shared non ui based library for
making search folders running remotely.
This commit is contained in:
committed by
Matthew Barnes
parent
147687c60f
commit
e758de5b1d
@ -208,6 +208,7 @@ libevolution_calendar_la_LIBADD = \
|
||||
$(top_builddir)/shell/libeshell.la \
|
||||
$(top_builddir)/calendar/gui/dialogs/libcal-dialogs.la \
|
||||
$(top_builddir)/calendar/importers/libevolution-calendar-importers.la \
|
||||
$(top_builddir)/libemail-utils/libemail-utils.la \
|
||||
$(top_builddir)/widgets/e-timezone-dialog/libetimezonedialog.la \
|
||||
$(top_builddir)/widgets/misc/libemiscwidgets.la \
|
||||
$(top_builddir)/widgets/table/libetable.la \
|
||||
|
||||
@ -582,7 +582,11 @@ e_rule_context_add_part_set (ERuleContext *context,
|
||||
g_return_if_fail (append != NULL);
|
||||
g_return_if_fail (next != NULL);
|
||||
|
||||
g_return_if_fail (g_hash_table_lookup (context->part_set_map, setname) == NULL);
|
||||
if ((map = g_hash_table_lookup (context->part_set_map, setname)) != NULL) {
|
||||
g_hash_table_remove (context->part_set_map, setname);
|
||||
free_part_set (map);
|
||||
map = NULL;
|
||||
}
|
||||
|
||||
map = g_malloc0 (sizeof (*map));
|
||||
map->type = part_type;
|
||||
@ -607,7 +611,11 @@ e_rule_context_add_rule_set (ERuleContext *context,
|
||||
g_return_if_fail (append != NULL);
|
||||
g_return_if_fail (next != NULL);
|
||||
|
||||
g_return_if_fail (g_hash_table_lookup (context->rule_set_map, setname) == NULL);
|
||||
if ((map = g_hash_table_lookup (context->rule_set_map, setname)) != NULL) {
|
||||
g_hash_table_remove (context->rule_set_map, setname);
|
||||
free_rule_set (map);
|
||||
map = NULL;
|
||||
}
|
||||
|
||||
map = g_malloc0 (sizeof (*map));
|
||||
map->type = rule_type;
|
||||
|
||||
@ -17,6 +17,9 @@ libmailutilsinclude_HEADERS = \
|
||||
e-signature-list.h \
|
||||
e-signature-utils.h \
|
||||
e-signature.h \
|
||||
em-filter-folder-element.h \
|
||||
em-vfolder-context.h \
|
||||
em-vfolder-rule.h \
|
||||
mail-mt.h \
|
||||
$(NULL)
|
||||
|
||||
@ -26,12 +29,17 @@ libemail_utils_la_SOURCES = \
|
||||
e-signature-list.c \
|
||||
e-signature-utils.c \
|
||||
e-signature.c \
|
||||
em-filter-folder-element.c \
|
||||
em-vfolder-context.c \
|
||||
em-vfolder-rule.c \
|
||||
mail-mt.c \
|
||||
$(NULL)
|
||||
|
||||
libemail_utils_la_LDFLAGS = -avoid-version $(NO_UNDEFINED)
|
||||
|
||||
libemail_utils_la_LIBADD = \
|
||||
$(top_builddir)/filter/libfilter.la \
|
||||
$(top_builddir)/libevolution-utils/libevolution-utils.la \
|
||||
$(EVOLUTION_DATA_SERVER_LIBS) \
|
||||
$(GNOME_PLATFORM_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
@ -32,9 +32,6 @@
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "em-filter-folder-element.h"
|
||||
#include "mail/em-folder-selection-button.h"
|
||||
#include "mail/em-utils.h"
|
||||
#include "shell/e-shell.h"
|
||||
#include "filter/e-filter-part.h"
|
||||
#include "libevolution-utils/e-alert.h"
|
||||
|
||||
@ -43,93 +40,14 @@
|
||||
((obj), EM_TYPE_FILTER_FOLDER_ELEMENT, EMFilterFolderElementPrivate))
|
||||
|
||||
struct _EMFilterFolderElementPrivate {
|
||||
EMailSession *session;
|
||||
gchar *uri;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_SESSION
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (
|
||||
EMFilterFolderElement,
|
||||
em_filter_folder_element,
|
||||
E_TYPE_FILTER_ELEMENT)
|
||||
|
||||
static void
|
||||
filter_folder_element_selected_cb (EMFolderSelectionButton *button,
|
||||
EMFilterFolderElement *ff)
|
||||
{
|
||||
GtkWidget *toplevel;
|
||||
const gchar *uri;
|
||||
|
||||
uri = em_folder_selection_button_get_folder_uri (button);
|
||||
|
||||
g_free (ff->priv->uri);
|
||||
ff->priv->uri = g_strdup (uri);
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (button));
|
||||
gtk_window_present (GTK_WINDOW (toplevel));
|
||||
}
|
||||
|
||||
static void
|
||||
filter_folder_element_set_session (EMFilterFolderElement *element,
|
||||
EMailSession *session)
|
||||
{
|
||||
/* FIXME Dirty hack. Session should be passed in always. */
|
||||
if (session == NULL) {
|
||||
EShell *shell;
|
||||
EShellBackend *shell_backend;
|
||||
EMailBackend *backend;
|
||||
|
||||
shell = e_shell_get_default ();
|
||||
shell_backend = e_shell_get_backend_by_name (shell, "mail");
|
||||
|
||||
backend = E_MAIL_BACKEND (shell_backend);
|
||||
session = e_mail_backend_get_session (backend);
|
||||
}
|
||||
|
||||
g_return_if_fail (E_IS_MAIL_SESSION (session));
|
||||
g_return_if_fail (element->priv->session == NULL);
|
||||
|
||||
element->priv->session = g_object_ref (session);
|
||||
}
|
||||
|
||||
static void
|
||||
filter_folder_element_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
switch (property_id) {
|
||||
case PROP_SESSION:
|
||||
filter_folder_element_set_session (
|
||||
EM_FILTER_FOLDER_ELEMENT (object),
|
||||
g_value_get_object (value));
|
||||
return;
|
||||
}
|
||||
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
filter_folder_element_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
switch (property_id) {
|
||||
case PROP_SESSION:
|
||||
g_value_set_object (
|
||||
value,
|
||||
em_filter_folder_element_get_session (
|
||||
EM_FILTER_FOLDER_ELEMENT (object)));
|
||||
return;
|
||||
}
|
||||
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
filter_folder_element_dispose (GObject *object)
|
||||
@ -138,11 +56,6 @@ filter_folder_element_dispose (GObject *object)
|
||||
|
||||
priv = EM_FILTER_FOLDER_ELEMENT_GET_PRIVATE (object);
|
||||
|
||||
if (priv->session != NULL) {
|
||||
g_object_unref (priv->session);
|
||||
priv->session = NULL;
|
||||
}
|
||||
|
||||
/* Chain up to parent's dispose() method. */
|
||||
G_OBJECT_CLASS (em_filter_folder_element_parent_class)->dispose (object);
|
||||
}
|
||||
@ -233,23 +146,12 @@ filter_folder_element_xml_decode (EFilterElement *fe,
|
||||
static GtkWidget *
|
||||
filter_folder_element_get_widget (EFilterElement *fe)
|
||||
{
|
||||
EMFilterFolderElement *ff = (EMFilterFolderElement *) fe;
|
||||
EMailSession *session;
|
||||
GtkWidget *button;
|
||||
GtkWidget *widget;
|
||||
|
||||
session = em_filter_folder_element_get_session (ff);
|
||||
widget = E_FILTER_ELEMENT_CLASS (em_filter_folder_element_parent_class)->
|
||||
get_widget (fe);
|
||||
|
||||
button = em_folder_selection_button_new (
|
||||
session, _("Select Folder"), NULL);
|
||||
em_folder_selection_button_set_folder_uri (
|
||||
EM_FOLDER_SELECTION_BUTTON (button), ff->priv->uri);
|
||||
gtk_widget_show (button);
|
||||
|
||||
g_signal_connect (
|
||||
button, "selected",
|
||||
G_CALLBACK (filter_folder_element_selected_cb), ff);
|
||||
|
||||
return button;
|
||||
return widget;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -291,8 +193,6 @@ em_filter_folder_element_class_init (EMFilterFolderElementClass *class)
|
||||
g_type_class_add_private (class, sizeof (EMFilterFolderElementPrivate));
|
||||
|
||||
object_class = G_OBJECT_CLASS (class);
|
||||
object_class->set_property = filter_folder_element_set_property;
|
||||
object_class->get_property = filter_folder_element_get_property;
|
||||
object_class->dispose = filter_folder_element_dispose;
|
||||
object_class->finalize = filter_folder_element_finalize;
|
||||
|
||||
@ -305,17 +205,6 @@ em_filter_folder_element_class_init (EMFilterFolderElementClass *class)
|
||||
filter_element_class->build_code = filter_folder_element_build_code;
|
||||
filter_element_class->format_sexp = filter_folder_element_format_sexp;
|
||||
filter_element_class->copy_value = filter_folder_element_copy_value;
|
||||
|
||||
g_object_class_install_property (
|
||||
object_class,
|
||||
PROP_SESSION,
|
||||
g_param_spec_object (
|
||||
"session",
|
||||
NULL,
|
||||
NULL,
|
||||
E_TYPE_MAIL_SESSION,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -325,21 +214,11 @@ em_filter_folder_element_init (EMFilterFolderElement *element)
|
||||
}
|
||||
|
||||
EFilterElement *
|
||||
em_filter_folder_element_new (EMailSession *session)
|
||||
em_filter_folder_element_new ()
|
||||
{
|
||||
g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
|
||||
|
||||
return g_object_new (
|
||||
EM_TYPE_FILTER_FOLDER_ELEMENT,
|
||||
"session", session, NULL);
|
||||
}
|
||||
|
||||
EMailSession *
|
||||
em_filter_folder_element_get_session (EMFilterFolderElement *element)
|
||||
{
|
||||
g_return_val_if_fail (EM_IS_FILTER_FOLDER_ELEMENT (element), NULL);
|
||||
|
||||
return element->priv->session;
|
||||
NULL);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
@ -26,7 +26,6 @@
|
||||
#define EM_FILTER_FOLDER_ELEMENT_H
|
||||
|
||||
#include <filter/e-filter-element.h>
|
||||
#include <libemail-engine/e-mail-session.h>
|
||||
|
||||
/* Standard GObject macros */
|
||||
#define EM_TYPE_FILTER_FOLDER_ELEMENT \
|
||||
@ -63,9 +62,7 @@ struct _EMFilterFolderElementClass {
|
||||
};
|
||||
|
||||
GType em_filter_folder_element_get_type (void);
|
||||
EFilterElement *em_filter_folder_element_new (EMailSession *session);
|
||||
EMailSession * em_filter_folder_element_get_session
|
||||
(EMFilterFolderElement *element);
|
||||
EFilterElement *em_filter_folder_element_new (void);
|
||||
const gchar * em_filter_folder_element_get_uri
|
||||
(EMFilterFolderElement *element);
|
||||
void em_filter_folder_element_set_uri
|
||||
@ -40,7 +40,7 @@
|
||||
((obj), EM_TYPE_VFOLDER_CONTEXT, EMVFolderContextPrivate))
|
||||
|
||||
struct _EMVFolderContextPrivate {
|
||||
EMailSession *session;
|
||||
int foo;
|
||||
};
|
||||
|
||||
enum {
|
||||
@ -53,51 +53,6 @@ G_DEFINE_TYPE (
|
||||
em_vfolder_context,
|
||||
E_TYPE_RULE_CONTEXT)
|
||||
|
||||
static void
|
||||
vfolder_context_set_session (EMVFolderContext *context,
|
||||
EMailSession *session)
|
||||
{
|
||||
g_return_if_fail (E_IS_MAIL_SESSION (session));
|
||||
g_return_if_fail (context->priv->session == NULL);
|
||||
|
||||
context->priv->session = g_object_ref (session);
|
||||
}
|
||||
|
||||
static void
|
||||
vfolder_context_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
switch (property_id) {
|
||||
case PROP_SESSION:
|
||||
vfolder_context_set_session (
|
||||
EM_VFOLDER_CONTEXT (object),
|
||||
g_value_get_object (value));
|
||||
return;
|
||||
}
|
||||
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
vfolder_context_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
switch (property_id) {
|
||||
case PROP_SESSION:
|
||||
g_value_set_object (
|
||||
value,
|
||||
em_vfolder_context_get_session (
|
||||
EM_VFOLDER_CONTEXT (object)));
|
||||
return;
|
||||
}
|
||||
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
vfolder_context_dispose (GObject *object)
|
||||
{
|
||||
@ -105,11 +60,6 @@ vfolder_context_dispose (GObject *object)
|
||||
|
||||
priv = EM_VFOLDER_CONTEXT_GET_PRIVATE (object);
|
||||
|
||||
if (priv->session != NULL) {
|
||||
g_object_unref (priv->session);
|
||||
priv->session = NULL;
|
||||
}
|
||||
|
||||
/* Chain up to parent's dispose() method. */
|
||||
G_OBJECT_CLASS (em_vfolder_context_parent_class)->dispose (object);
|
||||
}
|
||||
@ -129,11 +79,11 @@ vfolder_context_new_element (ERuleContext *context,
|
||||
return e_filter_int_new_type("score", -3, 3);
|
||||
|
||||
if (strcmp (type, "folder") == 0)
|
||||
return em_filter_folder_element_new (priv->session);
|
||||
return em_filter_folder_element_new ();
|
||||
|
||||
/* XXX Legacy type name. Same as "folder" now. */
|
||||
if (strcmp (type, "folder-curi") == 0)
|
||||
return em_filter_folder_element_new (priv->session);
|
||||
return em_filter_folder_element_new ();
|
||||
|
||||
return E_RULE_CONTEXT_CLASS (em_vfolder_context_parent_class)->
|
||||
new_element (context, type);
|
||||
@ -148,23 +98,10 @@ em_vfolder_context_class_init (EMVFolderContextClass *class)
|
||||
g_type_class_add_private (class, sizeof (EMVFolderContextPrivate));
|
||||
|
||||
object_class = G_OBJECT_CLASS (class);
|
||||
object_class->set_property = vfolder_context_set_property;
|
||||
object_class->get_property = vfolder_context_get_property;
|
||||
object_class->dispose = vfolder_context_dispose;
|
||||
|
||||
rule_context_class = E_RULE_CONTEXT_CLASS (class);
|
||||
rule_context_class->new_element = vfolder_context_new_element;
|
||||
|
||||
g_object_class_install_property (
|
||||
object_class,
|
||||
PROP_SESSION,
|
||||
g_param_spec_object (
|
||||
"session",
|
||||
NULL,
|
||||
NULL,
|
||||
E_TYPE_MAIL_SESSION,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -187,18 +124,8 @@ em_vfolder_context_init (EMVFolderContext *context)
|
||||
}
|
||||
|
||||
EMVFolderContext *
|
||||
em_vfolder_context_new (EMailSession *session)
|
||||
em_vfolder_context_new ()
|
||||
{
|
||||
g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
|
||||
|
||||
return g_object_new (
|
||||
EM_TYPE_VFOLDER_CONTEXT, "session", session, NULL);
|
||||
}
|
||||
|
||||
EMailSession *
|
||||
em_vfolder_context_get_session (EMVFolderContext *context)
|
||||
{
|
||||
g_return_val_if_fail (EM_IS_VFOLDER_CONTEXT (context), NULL);
|
||||
|
||||
return context->priv->session;
|
||||
EM_TYPE_VFOLDER_CONTEXT, NULL);
|
||||
}
|
||||
@ -26,7 +26,6 @@
|
||||
#define EM_VFOLDER_CONTEXT_H
|
||||
|
||||
#include <filter/e-rule-context.h>
|
||||
#include <libemail-engine/e-mail-session.h>
|
||||
|
||||
/* Standard GObject macros */
|
||||
#define EM_TYPE_VFOLDER_CONTEXT \
|
||||
@ -64,8 +63,7 @@ struct _EMVFolderContextClass {
|
||||
|
||||
GType em_vfolder_context_get_type (void);
|
||||
EMVFolderContext *
|
||||
em_vfolder_context_new (EMailSession *session);
|
||||
EMailSession * em_vfolder_context_get_session (EMVFolderContext *context);
|
||||
em_vfolder_context_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
380
libemail-utils/em-vfolder-rule.c
Normal file
380
libemail-utils/em-vfolder-rule.c
Normal file
@ -0,0 +1,380 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with the program; if not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Not Zed <notzed@lostzed.mmc.com.au>
|
||||
* Jeffrey Stedfast <fejj@ximian.com>
|
||||
*
|
||||
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include <libevolution-utils/e-alert.h>
|
||||
|
||||
#include <libemail-engine/e-mail-folder-utils.h>
|
||||
|
||||
#include "em-vfolder-context.h"
|
||||
#include "em-vfolder-rule.h"
|
||||
|
||||
#define EM_VFOLDER_RULE_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE \
|
||||
((obj), EM_TYPE_VFOLDER_RULE, EMVFolderRulePrivate))
|
||||
|
||||
#define EM_VFOLDER_RULE_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE \
|
||||
((obj), EM_TYPE_VFOLDER_RULE, EMVFolderRulePrivate))
|
||||
|
||||
struct _EMVFolderRulePrivate {
|
||||
int foo;
|
||||
};
|
||||
|
||||
static gint validate (EFilterRule *, EAlert **alert);
|
||||
static gint vfolder_eq (EFilterRule *fr, EFilterRule *cm);
|
||||
static xmlNodePtr xml_encode (EFilterRule *);
|
||||
static gint xml_decode (EFilterRule *, xmlNodePtr, ERuleContext *f);
|
||||
static void rule_copy (EFilterRule *dest, EFilterRule *src);
|
||||
static GtkWidget *get_widget (EFilterRule *fr, ERuleContext *f);
|
||||
|
||||
/* DO NOT internationalise these strings */
|
||||
static const gchar *with_names[] = {
|
||||
"specific",
|
||||
"local_remote_active",
|
||||
"remote_active",
|
||||
"local"
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (
|
||||
EMVFolderRule,
|
||||
em_vfolder_rule,
|
||||
E_TYPE_FILTER_RULE)
|
||||
|
||||
|
||||
static void
|
||||
vfolder_rule_dispose (GObject *object)
|
||||
{
|
||||
EMVFolderRulePrivate *priv;
|
||||
|
||||
priv = EM_VFOLDER_RULE_GET_PRIVATE (object);
|
||||
|
||||
/* Chain up to parent's dispose() method. */
|
||||
G_OBJECT_CLASS (em_vfolder_rule_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
vfolder_rule_finalize (GObject *object)
|
||||
{
|
||||
EMVFolderRule *rule = EM_VFOLDER_RULE (object);
|
||||
gchar *uri;
|
||||
|
||||
while ((uri = g_queue_pop_head (&rule->sources)) != NULL)
|
||||
g_free (uri);
|
||||
|
||||
/* Chain up to parent's finalize() method. */
|
||||
G_OBJECT_CLASS (em_vfolder_rule_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
em_vfolder_rule_class_init (EMVFolderRuleClass *class)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
EFilterRuleClass *filter_rule_class;
|
||||
|
||||
g_type_class_add_private (class, sizeof (EMVFolderRulePrivate));
|
||||
|
||||
object_class = G_OBJECT_CLASS (class);
|
||||
object_class->dispose = vfolder_rule_dispose;
|
||||
object_class->finalize = vfolder_rule_finalize;
|
||||
|
||||
filter_rule_class = E_FILTER_RULE_CLASS (class);
|
||||
filter_rule_class->validate = validate;
|
||||
filter_rule_class->eq = vfolder_eq;
|
||||
filter_rule_class->xml_encode = xml_encode;
|
||||
filter_rule_class->xml_decode = xml_decode;
|
||||
filter_rule_class->copy = rule_copy;
|
||||
filter_rule_class->get_widget = get_widget;
|
||||
}
|
||||
|
||||
static void
|
||||
em_vfolder_rule_init (EMVFolderRule *rule)
|
||||
{
|
||||
rule->priv = EM_VFOLDER_RULE_GET_PRIVATE (rule);
|
||||
rule->with = EM_VFOLDER_RULE_WITH_SPECIFIC;
|
||||
rule->rule.source = g_strdup ("incoming");
|
||||
}
|
||||
|
||||
EFilterRule *
|
||||
em_vfolder_rule_new ()
|
||||
{
|
||||
return g_object_new (
|
||||
EM_TYPE_VFOLDER_RULE, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
em_vfolder_rule_add_source (EMVFolderRule *rule,
|
||||
const gchar *uri)
|
||||
{
|
||||
g_return_if_fail (EM_IS_VFOLDER_RULE (rule));
|
||||
g_return_if_fail (uri);
|
||||
|
||||
g_queue_push_tail (&rule->sources, g_strdup (uri));
|
||||
|
||||
e_filter_rule_emit_changed (E_FILTER_RULE (rule));
|
||||
}
|
||||
|
||||
const gchar *
|
||||
em_vfolder_rule_find_source (EMVFolderRule *rule,
|
||||
const gchar *uri)
|
||||
{
|
||||
GList *link;
|
||||
|
||||
g_return_val_if_fail (EM_IS_VFOLDER_RULE (rule), NULL);
|
||||
|
||||
/* only does a simple string or address comparison, should
|
||||
* probably do a decoded url comparison */
|
||||
link = g_queue_find_custom (
|
||||
&rule->sources, uri, (GCompareFunc) strcmp);
|
||||
|
||||
return (link != NULL) ? link->data : NULL;
|
||||
}
|
||||
|
||||
void
|
||||
em_vfolder_rule_remove_source (EMVFolderRule *rule,
|
||||
const gchar *uri)
|
||||
{
|
||||
gchar *found;
|
||||
|
||||
g_return_if_fail (EM_IS_VFOLDER_RULE (rule));
|
||||
|
||||
found =(gchar *) em_vfolder_rule_find_source (rule, uri);
|
||||
if (found != NULL) {
|
||||
g_queue_remove (&rule->sources, found);
|
||||
g_free (found);
|
||||
e_filter_rule_emit_changed (E_FILTER_RULE (rule));
|
||||
}
|
||||
}
|
||||
|
||||
const gchar *
|
||||
em_vfolder_rule_next_source (EMVFolderRule *rule,
|
||||
const gchar *last)
|
||||
{
|
||||
GList *link;
|
||||
|
||||
if (last == NULL) {
|
||||
link = g_queue_peek_head_link (&rule->sources);
|
||||
} else {
|
||||
link = g_queue_find (&rule->sources, last);
|
||||
if (link == NULL)
|
||||
link = g_queue_peek_head_link (&rule->sources);
|
||||
else
|
||||
link = g_list_next (link);
|
||||
}
|
||||
|
||||
return (link != NULL) ? link->data : NULL;
|
||||
}
|
||||
|
||||
static gint
|
||||
validate (EFilterRule *fr,
|
||||
EAlert **alert)
|
||||
{
|
||||
g_return_val_if_fail (fr != NULL, 0);
|
||||
g_warn_if_fail (alert == NULL || *alert == NULL);
|
||||
|
||||
if (!fr->name || !*fr->name) {
|
||||
if (alert)
|
||||
*alert = e_alert_new ("mail:no-name-vfolder", NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* We have to have at least one source set in the "specific" case.
|
||||
* Do not translate this string! */
|
||||
if (((EMVFolderRule *) fr)->with == EM_VFOLDER_RULE_WITH_SPECIFIC &&
|
||||
g_queue_is_empty (&((EMVFolderRule *) fr)->sources)) {
|
||||
if (alert)
|
||||
*alert = e_alert_new ("mail:vfolder-no-source", NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return E_FILTER_RULE_CLASS (em_vfolder_rule_parent_class)->validate (fr, alert);
|
||||
}
|
||||
|
||||
static gint
|
||||
queue_eq (GQueue *queue_a,
|
||||
GQueue *queue_b)
|
||||
{
|
||||
GList *link_a;
|
||||
GList *link_b;
|
||||
gint truth = TRUE;
|
||||
|
||||
link_a = g_queue_peek_head_link (queue_a);
|
||||
link_b = g_queue_peek_head_link (queue_b);
|
||||
|
||||
while (truth && link_a != NULL && link_b != NULL) {
|
||||
gchar *uri_a = link_a->data;
|
||||
gchar *uri_b = link_b->data;
|
||||
|
||||
truth = (strcmp (uri_a, uri_b)== 0);
|
||||
|
||||
link_a = g_list_next (link_a);
|
||||
link_b = g_list_next (link_b);
|
||||
}
|
||||
|
||||
return truth && link_a == NULL && link_b == NULL;
|
||||
}
|
||||
|
||||
static gint
|
||||
vfolder_eq (EFilterRule *fr,
|
||||
EFilterRule *cm)
|
||||
{
|
||||
return E_FILTER_RULE_CLASS (em_vfolder_rule_parent_class)->eq (fr, cm)
|
||||
&& queue_eq (
|
||||
&((EMVFolderRule *) fr)->sources,
|
||||
&((EMVFolderRule *) cm)->sources);
|
||||
}
|
||||
|
||||
static xmlNodePtr
|
||||
xml_encode (EFilterRule *fr)
|
||||
{
|
||||
EMVFolderRule *vr =(EMVFolderRule *) fr;
|
||||
xmlNodePtr node, set, work;
|
||||
GList *head, *link;
|
||||
|
||||
node = E_FILTER_RULE_CLASS (em_vfolder_rule_parent_class)->xml_encode (fr);
|
||||
g_return_val_if_fail (node != NULL, NULL);
|
||||
g_return_val_if_fail (vr->with < G_N_ELEMENTS (with_names), NULL);
|
||||
|
||||
set = xmlNewNode(NULL, (const guchar *)"sources");
|
||||
xmlAddChild (node, set);
|
||||
xmlSetProp(set, (const guchar *)"with", (guchar *)with_names[vr->with]);
|
||||
|
||||
head = g_queue_peek_head_link (&vr->sources);
|
||||
for (link = head; link != NULL; link = g_list_next (link)) {
|
||||
const gchar *uri = link->data;
|
||||
|
||||
work = xmlNewNode (NULL, (const guchar *) "folder");
|
||||
xmlSetProp (work, (const guchar *) "uri", (guchar *) uri);
|
||||
xmlAddChild (set, work);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
static void
|
||||
set_with (EMVFolderRule *vr,
|
||||
const gchar *name)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (with_names); i++) {
|
||||
if (!strcmp (name, with_names[i])) {
|
||||
vr->with = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
vr->with = 0;
|
||||
}
|
||||
|
||||
static gint
|
||||
xml_decode (EFilterRule *fr,
|
||||
xmlNodePtr node,
|
||||
ERuleContext *f)
|
||||
{
|
||||
xmlNodePtr set, work;
|
||||
gint result;
|
||||
EMVFolderRule *vr =(EMVFolderRule *) fr;
|
||||
gchar *tmp;
|
||||
|
||||
result = E_FILTER_RULE_CLASS (em_vfolder_rule_parent_class)->
|
||||
xml_decode (fr, node, f);
|
||||
if (result != 0)
|
||||
return result;
|
||||
|
||||
/* handle old format file, vfolder source is in filterrule */
|
||||
if (strcmp(fr->source, "incoming")!= 0) {
|
||||
set_with (vr, fr->source);
|
||||
g_free (fr->source);
|
||||
fr->source = g_strdup("incoming");
|
||||
}
|
||||
|
||||
set = node->children;
|
||||
while (set) {
|
||||
if (!strcmp((gchar *)set->name, "sources")) {
|
||||
tmp = (gchar *)xmlGetProp(set, (const guchar *)"with");
|
||||
if (tmp) {
|
||||
set_with (vr, tmp);
|
||||
xmlFree (tmp);
|
||||
}
|
||||
work = set->children;
|
||||
while (work) {
|
||||
if (!strcmp((gchar *)work->name, "folder")) {
|
||||
tmp = (gchar *)xmlGetProp(work, (const guchar *)"uri");
|
||||
if (tmp) {
|
||||
g_queue_push_tail (&vr->sources, g_strdup (tmp));
|
||||
xmlFree (tmp);
|
||||
}
|
||||
}
|
||||
work = work->next;
|
||||
}
|
||||
}
|
||||
set = set->next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
rule_copy (EFilterRule *dest,
|
||||
EFilterRule *src)
|
||||
{
|
||||
EMVFolderRule *vdest, *vsrc;
|
||||
GList *head, *link;
|
||||
gchar *uri;
|
||||
|
||||
vdest =(EMVFolderRule *) dest;
|
||||
vsrc =(EMVFolderRule *) src;
|
||||
|
||||
while ((uri = g_queue_pop_head (&vdest->sources)) != NULL)
|
||||
g_free (uri);
|
||||
|
||||
head = g_queue_peek_head_link (&vsrc->sources);
|
||||
for (link = head; link != NULL; link = g_list_next (link)) {
|
||||
const gchar *uri = link->data;
|
||||
g_queue_push_tail (&vdest->sources, g_strdup (uri));
|
||||
}
|
||||
|
||||
vdest->with = vsrc->with;
|
||||
|
||||
E_FILTER_RULE_CLASS (em_vfolder_rule_parent_class)->copy (dest, src);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
get_widget (EFilterRule *fr,
|
||||
ERuleContext *rc)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = E_FILTER_RULE_CLASS (em_vfolder_rule_parent_class)->
|
||||
get_widget (fr, rc);
|
||||
|
||||
return widget;
|
||||
}
|
||||
@ -25,7 +25,6 @@
|
||||
#define EM_VFOLDER_RULE_H
|
||||
|
||||
#include <filter/e-filter-rule.h>
|
||||
#include <libemail-engine/e-mail-session.h>
|
||||
|
||||
/* Standard GObject macros */
|
||||
#define EM_TYPE_VFOLDER_RULE \
|
||||
@ -75,8 +74,7 @@ struct _EMVFolderRuleClass {
|
||||
};
|
||||
|
||||
GType em_vfolder_rule_get_type (void);
|
||||
EFilterRule * em_vfolder_rule_new (EMailSession *session);
|
||||
EMailSession * em_vfolder_rule_get_session (EMVFolderRule *rule);
|
||||
EFilterRule * em_vfolder_rule_new ();
|
||||
void em_vfolder_rule_add_source (EMVFolderRule *rule,
|
||||
const gchar *uri);
|
||||
void em_vfolder_rule_remove_source (EMVFolderRule *rule,
|
||||
@ -68,7 +68,7 @@ mailinclude_HEADERS = \
|
||||
em-event.h \
|
||||
em-filter-context.h \
|
||||
em-filter-editor.h \
|
||||
em-filter-folder-element.h \
|
||||
em-filter-editor-folder-element.h \
|
||||
em-filter-rule.h \
|
||||
em-filter-source-element.h \
|
||||
em-folder-properties.h \
|
||||
@ -86,9 +86,9 @@ mailinclude_HEADERS = \
|
||||
em-subscription-editor.h \
|
||||
em-sync-stream.h \
|
||||
em-utils.h \
|
||||
em-vfolder-context.h \
|
||||
em-vfolder-editor-context.h \
|
||||
em-vfolder-editor-rule.h \
|
||||
em-vfolder-editor.h \
|
||||
em-vfolder-rule.h \
|
||||
mail-autofilter.h \
|
||||
mail-guess-servers.h \
|
||||
mail-send-recv.h \
|
||||
@ -133,7 +133,7 @@ libevolution_mail_la_SOURCES = \
|
||||
em-event.c \
|
||||
em-filter-context.c \
|
||||
em-filter-editor.c \
|
||||
em-filter-folder-element.c \
|
||||
em-filter-editor-folder-element.c \
|
||||
em-filter-rule.c \
|
||||
em-filter-source-element.c \
|
||||
em-folder-properties.c \
|
||||
@ -151,9 +151,9 @@ libevolution_mail_la_SOURCES = \
|
||||
em-subscription-editor.c \
|
||||
em-sync-stream.c \
|
||||
em-utils.c \
|
||||
em-vfolder-context.c \
|
||||
em-vfolder-editor-context.c \
|
||||
em-vfolder-editor-rule.c \
|
||||
em-vfolder-editor.c \
|
||||
em-vfolder-rule.c \
|
||||
mail-autofilter.c \
|
||||
mail-guess-servers.c \
|
||||
mail-send-recv.c \
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
#include "em-filter-source-element.h"
|
||||
|
||||
/* For poking into filter-folder guts */
|
||||
#include "em-filter-folder-element.h"
|
||||
#include "em-filter-editor-folder-element.h"
|
||||
|
||||
#define EM_FILTER_CONTEXT_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE \
|
||||
@ -236,7 +236,7 @@ filter_context_new_element (ERuleContext *context,
|
||||
priv = EM_FILTER_CONTEXT_GET_PRIVATE (context);
|
||||
|
||||
if (strcmp (type, "folder") == 0)
|
||||
return em_filter_folder_element_new (priv->session);
|
||||
return em_filter_editor_folder_element_new (priv->session);
|
||||
|
||||
if (strcmp (type, "system-flag") == 0)
|
||||
return e_filter_option_new ();
|
||||
|
||||
230
mail/em-filter-editor-folder-element.c
Normal file
230
mail/em-filter-editor-folder-element.c
Normal file
@ -0,0 +1,230 @@
|
||||
/*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with the program; if not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Not Zed <notzed@lostzed.mmc.com.au>
|
||||
* Jeffrey Stedfast <fejj@ximian.com>
|
||||
*
|
||||
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "em-filter-editor-folder-element.h"
|
||||
#include "mail/em-folder-selection-button.h"
|
||||
#include "mail/em-utils.h"
|
||||
#include "shell/e-shell.h"
|
||||
#include "filter/e-filter-part.h"
|
||||
#include "libevolution-utils/e-alert.h"
|
||||
|
||||
#define EM_FILTER_EDITOR_FOLDER_ELEMENT_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE \
|
||||
((obj), EM_TYPE_FILTER_EDITOR_FOLDER_ELEMENT, EMFilterEditorFolderElementPrivate))
|
||||
|
||||
struct _EMFilterEditorFolderElementPrivate {
|
||||
EMailSession *session;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_SESSION
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (
|
||||
EMFilterEditorFolderElement,
|
||||
em_filter_editor_folder_element,
|
||||
EM_TYPE_FILTER_FOLDER_ELEMENT)
|
||||
|
||||
static void
|
||||
filter_editor_folder_element_set_session (EMFilterEditorFolderElement *element,
|
||||
EMailSession *session)
|
||||
{
|
||||
if (session == NULL) {
|
||||
EShell *shell;
|
||||
EShellBackend *shell_backend;
|
||||
EMailBackend *backend;
|
||||
|
||||
shell = e_shell_get_default ();
|
||||
shell_backend = e_shell_get_backend_by_name (shell, "mail");
|
||||
|
||||
backend = E_MAIL_BACKEND (shell_backend);
|
||||
session = e_mail_backend_get_session (backend);
|
||||
}
|
||||
|
||||
g_return_if_fail (E_IS_MAIL_SESSION (session));
|
||||
g_return_if_fail (element->priv->session == NULL);
|
||||
|
||||
element->priv->session = g_object_ref (session);
|
||||
}
|
||||
|
||||
static void
|
||||
filter_editor_folder_element_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
switch (property_id) {
|
||||
case PROP_SESSION:
|
||||
filter_editor_folder_element_set_session (
|
||||
EM_FILTER_EDITOR_FOLDER_ELEMENT (object),
|
||||
g_value_get_object (value));
|
||||
return;
|
||||
}
|
||||
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
filter_editor_folder_element_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
switch (property_id) {
|
||||
case PROP_SESSION:
|
||||
g_value_set_object (
|
||||
value,
|
||||
em_filter_editor_folder_element_get_session (
|
||||
EM_FILTER_EDITOR_FOLDER_ELEMENT (object)));
|
||||
return;
|
||||
}
|
||||
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
filter_editor_folder_element_selected_cb (EMFolderSelectionButton *button,
|
||||
EMFilterEditorFolderElement *ff)
|
||||
{
|
||||
GtkWidget *toplevel;
|
||||
const gchar *uri;
|
||||
|
||||
uri = em_folder_selection_button_get_folder_uri (button);
|
||||
|
||||
em_filter_folder_element_set_uri ((EMFilterFolderElement *) ff, uri);
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (button));
|
||||
gtk_window_present (GTK_WINDOW (toplevel));
|
||||
}
|
||||
|
||||
static void
|
||||
filter_editor_folder_element_dispose (GObject *object)
|
||||
{
|
||||
EMFilterEditorFolderElementPrivate *priv;
|
||||
|
||||
priv = EM_FILTER_EDITOR_FOLDER_ELEMENT_GET_PRIVATE (object);
|
||||
if (priv->session != NULL) {
|
||||
g_object_unref (priv->session);
|
||||
priv->session = NULL;
|
||||
}
|
||||
|
||||
/* Chain up to parent's dispose() method. */
|
||||
G_OBJECT_CLASS (em_filter_editor_folder_element_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
filter_editor_folder_element_finalize (GObject *object)
|
||||
{
|
||||
EMFilterEditorFolderElementPrivate *priv;
|
||||
|
||||
priv = EM_FILTER_EDITOR_FOLDER_ELEMENT_GET_PRIVATE (object);
|
||||
|
||||
/* Chain up to parent's finalize() method. */
|
||||
G_OBJECT_CLASS (em_filter_editor_folder_element_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
filter_editor_folder_element_get_widget (EFilterElement *fe)
|
||||
{
|
||||
EMFilterEditorFolderElement *ff = (EMFilterEditorFolderElement *) fe;
|
||||
EMailSession *session;
|
||||
GtkWidget *button;
|
||||
|
||||
session = em_filter_editor_folder_element_get_session (ff);
|
||||
|
||||
button = em_folder_selection_button_new (
|
||||
session, _("Select Folder"), NULL);
|
||||
em_folder_selection_button_set_folder_uri (
|
||||
EM_FOLDER_SELECTION_BUTTON (button), em_filter_folder_element_get_uri ((EMFilterFolderElement *) ff));
|
||||
gtk_widget_show (button);
|
||||
|
||||
g_signal_connect (
|
||||
button, "selected",
|
||||
G_CALLBACK (filter_editor_folder_element_selected_cb), ff);
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
static void
|
||||
em_filter_editor_folder_element_class_init (EMFilterEditorFolderElementClass *class)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
EFilterElementClass *filter_element_class;
|
||||
|
||||
g_type_class_add_private (class, sizeof (EMFilterEditorFolderElementPrivate));
|
||||
|
||||
object_class = G_OBJECT_CLASS (class);
|
||||
object_class->set_property = filter_editor_folder_element_set_property;
|
||||
object_class->get_property = filter_editor_folder_element_get_property;
|
||||
object_class->dispose = filter_editor_folder_element_dispose;
|
||||
object_class->finalize = filter_editor_folder_element_finalize;
|
||||
|
||||
filter_element_class = E_FILTER_ELEMENT_CLASS (class);
|
||||
filter_element_class->get_widget = filter_editor_folder_element_get_widget;
|
||||
|
||||
g_object_class_install_property (
|
||||
object_class,
|
||||
PROP_SESSION,
|
||||
g_param_spec_object (
|
||||
"session",
|
||||
NULL,
|
||||
NULL,
|
||||
E_TYPE_MAIL_SESSION,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
||||
static void
|
||||
em_filter_editor_folder_element_init (EMFilterEditorFolderElement *element)
|
||||
{
|
||||
element->priv = EM_FILTER_EDITOR_FOLDER_ELEMENT_GET_PRIVATE (element);
|
||||
}
|
||||
|
||||
EFilterElement *
|
||||
em_filter_editor_folder_element_new (EMailSession *session)
|
||||
{
|
||||
g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
|
||||
|
||||
return g_object_new (
|
||||
EM_TYPE_FILTER_EDITOR_FOLDER_ELEMENT,
|
||||
"session", session, NULL);
|
||||
}
|
||||
|
||||
EMailSession *
|
||||
em_filter_editor_folder_element_get_session (EMFilterEditorFolderElement *element)
|
||||
{
|
||||
g_return_val_if_fail (EM_IS_FILTER_EDITOR_FOLDER_ELEMENT (element), NULL);
|
||||
|
||||
return element->priv->session;
|
||||
}
|
||||
73
mail/em-filter-editor-folder-element.h
Normal file
73
mail/em-filter-editor-folder-element.h
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with the program; if not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Not Zed <notzed@lostzed.mmc.com.au>
|
||||
* Jeelementrey Stedfast <fejj@ximian.com>
|
||||
*
|
||||
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef EM_FILTER_EDITOR_FOLDER_ELEMENT_H
|
||||
#define EM_FILTER_EDITOR_FOLDER_ELEMENT_H
|
||||
|
||||
#include <filter/e-filter-element.h>
|
||||
#include <libemail-utils/em-filter-folder-element.h>
|
||||
#include <libemail-engine/e-mail-session.h>
|
||||
|
||||
/* Standard GObject macros */
|
||||
#define EM_TYPE_FILTER_EDITOR_FOLDER_ELEMENT \
|
||||
(em_filter_editor_folder_element_get_type ())
|
||||
#define EM_FILTER_EDITOR_FOLDER_ELEMENT(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST \
|
||||
((obj), EM_TYPE_FILTER_EDITOR_FOLDER_ELEMENT, EMFilterEditorFolderElement))
|
||||
#define EM_FILTER_EDITOR_FOLDER_ELEMENT_CLASS(cls) \
|
||||
(G_TYPE_CHECK_CLASS_CAST \
|
||||
((cls), EM_TYPE_FILTER_EDITOR_FOLDER_ELEMENT, EMFilterEditorFolderElementClass))
|
||||
#define EM_IS_FILTER_EDITOR_FOLDER_ELEMENT(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE \
|
||||
((obj), EM_TYPE_FILTER_EDITOR_FOLDER_ELEMENT))
|
||||
#define EM_IS_FILTER_EDITOR_FOLDER_ELEMENT_CLASS(cls) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE \
|
||||
((cls), EM_TYPE_FILTER_EDITOR_FOLDER_ELEMENT))
|
||||
#define EM_FILTER_EDITOR_FOLDER_ELEMENT_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS \
|
||||
((obj), EM_TYPE_FILTER_EDITOR_FOLDER_ELEMENT, EMFilterEditorFolderElementClass))
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _EMFilterEditorFolderElement EMFilterEditorFolderElement;
|
||||
typedef struct _EMFilterEditorFolderElementClass EMFilterEditorFolderElementClass;
|
||||
typedef struct _EMFilterEditorFolderElementPrivate EMFilterEditorFolderElementPrivate;
|
||||
|
||||
struct _EMFilterEditorFolderElement {
|
||||
EMFilterFolderElement parent;
|
||||
EMFilterEditorFolderElementPrivate *priv;
|
||||
};
|
||||
|
||||
struct _EMFilterEditorFolderElementClass {
|
||||
EMFilterFolderElementClass parent_class;
|
||||
};
|
||||
|
||||
GType em_filter_editor_folder_element_get_type (void);
|
||||
EFilterElement *em_filter_editor_folder_element_new (EMailSession *session);
|
||||
EMailSession * em_filter_editor_folder_element_get_session
|
||||
(EMFilterEditorFolderElement *element);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* EM_FILTER_EDITOR_FOLDER_ELEMENT_H */
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
#include "misc/e-selectable.h"
|
||||
|
||||
#include "em-vfolder-rule.h"
|
||||
#include "em-vfolder-editor-rule.h"
|
||||
|
||||
#include "libemail-utils/mail-mt.h"
|
||||
#include "libemail-engine/e-mail-folder-utils.h"
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
#include "libevolution-utils/e-alert-dialog.h"
|
||||
#include "e-util/e-dialog-utils.h"
|
||||
|
||||
#include "em-vfolder-rule.h"
|
||||
#include "em-vfolder-editor-rule.h"
|
||||
|
||||
#include "libemail-utils/mail-mt.h"
|
||||
#include "libemail-engine/e-mail-folder-utils.h"
|
||||
@ -655,7 +655,7 @@ em_folder_utils_create_folder (GtkWindow *parent,
|
||||
else
|
||||
skip_slash = folder_name;
|
||||
|
||||
rule = em_vfolder_rule_new (session);
|
||||
rule = em_vfolder_editor_rule_new (session);
|
||||
e_filter_rule_set_name (rule, skip_slash);
|
||||
vfolder_gui_add_rule (EM_VFOLDER_RULE (rule));
|
||||
} else {
|
||||
|
||||
216
mail/em-vfolder-editor-context.c
Normal file
216
mail/em-vfolder-editor-context.c
Normal file
@ -0,0 +1,216 @@
|
||||
/*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with the program; if not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Not Zed <notzed@lostzed.mmc.com.au>
|
||||
* Jeffrey Stedfast <fejj@ximian.com>
|
||||
*
|
||||
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <shell/e-shell.h>
|
||||
#include "mail/em-utils.h"
|
||||
#include "em-vfolder-editor-context.h"
|
||||
#include "em-vfolder-editor-rule.h"
|
||||
#include "filter/e-filter-option.h"
|
||||
#include "filter/e-filter-int.h"
|
||||
|
||||
#include "em-filter-editor-folder-element.h"
|
||||
|
||||
#define EM_VFOLDER_EDITOR_CONTEXT_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE \
|
||||
((obj), EM_TYPE_VFOLDER_EDITOR_CONTEXT, EMVFolderEditorContextPrivate))
|
||||
|
||||
struct _EMVFolderEditorContextPrivate {
|
||||
EMailSession *session;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_SESSION
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (
|
||||
EMVFolderEditorContext,
|
||||
em_vfolder_editor_context,
|
||||
EM_TYPE_VFOLDER_CONTEXT)
|
||||
|
||||
static void
|
||||
vfolder_editor_context_set_session (EMVFolderEditorContext *context,
|
||||
EMailSession *session)
|
||||
{
|
||||
if (session == NULL) {
|
||||
EShell *shell;
|
||||
EShellBackend *shell_backend;
|
||||
EMailBackend *backend;
|
||||
|
||||
shell = e_shell_get_default ();
|
||||
shell_backend = e_shell_get_backend_by_name (shell, "mail");
|
||||
|
||||
backend = E_MAIL_BACKEND (shell_backend);
|
||||
session = e_mail_backend_get_session (backend);
|
||||
}
|
||||
|
||||
g_return_if_fail (E_IS_MAIL_SESSION (session));
|
||||
g_return_if_fail (context->priv->session == NULL);
|
||||
|
||||
context->priv->session = g_object_ref (session);
|
||||
}
|
||||
|
||||
static void
|
||||
vfolder_editor_context_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
switch (property_id) {
|
||||
case PROP_SESSION:
|
||||
vfolder_editor_context_set_session (
|
||||
EM_VFOLDER_EDITOR_CONTEXT (object),
|
||||
g_value_get_object (value));
|
||||
return;
|
||||
}
|
||||
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
vfolder_editor_context_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
switch (property_id) {
|
||||
case PROP_SESSION:
|
||||
g_value_set_object (
|
||||
value,
|
||||
em_vfolder_editor_context_get_session (
|
||||
EM_VFOLDER_EDITOR_CONTEXT (object)));
|
||||
return;
|
||||
}
|
||||
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
vfolder_editor_context_dispose (GObject *object)
|
||||
{
|
||||
EMVFolderEditorContextPrivate *priv;
|
||||
|
||||
priv = EM_VFOLDER_EDITOR_CONTEXT_GET_PRIVATE (object);
|
||||
if (priv->session != NULL) {
|
||||
g_object_unref (priv->session);
|
||||
priv->session = NULL;
|
||||
}
|
||||
|
||||
/* Chain up to parent's dispose() method. */
|
||||
G_OBJECT_CLASS (em_vfolder_editor_context_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static EFilterElement *
|
||||
vfolder_editor_context_new_element (ERuleContext *context,
|
||||
const gchar *type)
|
||||
{
|
||||
EMVFolderEditorContextPrivate *priv;
|
||||
|
||||
priv = EM_VFOLDER_EDITOR_CONTEXT_GET_PRIVATE (context);
|
||||
|
||||
if (strcmp (type, "system-flag") == 0)
|
||||
return e_filter_option_new ();
|
||||
|
||||
if (strcmp (type, "score") == 0)
|
||||
return e_filter_int_new_type("score", -3, 3);
|
||||
|
||||
if (strcmp (type, "folder") == 0)
|
||||
return em_filter_editor_folder_element_new (priv->session);
|
||||
|
||||
/* XXX Legacy type name. Same as "folder" now. */
|
||||
if (strcmp (type, "folder-curi") == 0)
|
||||
return em_filter_editor_folder_element_new (priv->session);
|
||||
|
||||
return E_RULE_CONTEXT_CLASS (em_vfolder_editor_context_parent_class)->
|
||||
new_element (context, type);
|
||||
}
|
||||
|
||||
static void
|
||||
em_vfolder_editor_context_class_init (EMVFolderEditorContextClass *class)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
ERuleContextClass *rule_context_class;
|
||||
|
||||
g_type_class_add_private (class, sizeof (EMVFolderEditorContextPrivate));
|
||||
|
||||
object_class = G_OBJECT_CLASS (class);
|
||||
object_class->set_property = vfolder_editor_context_set_property;
|
||||
object_class->get_property = vfolder_editor_context_get_property;
|
||||
object_class->dispose = vfolder_editor_context_dispose;
|
||||
|
||||
rule_context_class = E_RULE_CONTEXT_CLASS (class);
|
||||
rule_context_class->new_element = vfolder_editor_context_new_element;
|
||||
|
||||
g_object_class_install_property (
|
||||
object_class,
|
||||
PROP_SESSION,
|
||||
g_param_spec_object (
|
||||
"session",
|
||||
NULL,
|
||||
NULL,
|
||||
E_TYPE_MAIL_SESSION,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
||||
static void
|
||||
em_vfolder_editor_context_init (EMVFolderEditorContext *context)
|
||||
{
|
||||
context->priv = EM_VFOLDER_EDITOR_CONTEXT_GET_PRIVATE (context);
|
||||
|
||||
e_rule_context_add_part_set (
|
||||
E_RULE_CONTEXT (context), "partset", E_TYPE_FILTER_PART,
|
||||
(ERuleContextPartFunc) e_rule_context_add_part,
|
||||
(ERuleContextNextPartFunc) e_rule_context_next_part);
|
||||
|
||||
e_rule_context_add_rule_set (
|
||||
E_RULE_CONTEXT (context), "ruleset", EM_TYPE_VFOLDER_EDITOR_RULE,
|
||||
(ERuleContextRuleFunc) e_rule_context_add_rule,
|
||||
(ERuleContextNextRuleFunc) e_rule_context_next_rule);
|
||||
|
||||
E_RULE_CONTEXT (context)->flags =
|
||||
E_RULE_CONTEXT_THREADING | E_RULE_CONTEXT_GROUPING;
|
||||
}
|
||||
|
||||
EMVFolderEditorContext *
|
||||
em_vfolder_editor_context_new (EMailSession *session)
|
||||
{
|
||||
g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
|
||||
|
||||
return g_object_new (
|
||||
EM_TYPE_VFOLDER_EDITOR_CONTEXT, "session", session, NULL);
|
||||
}
|
||||
|
||||
EMailSession *
|
||||
em_vfolder_editor_context_get_session (EMVFolderEditorContext *context)
|
||||
{
|
||||
g_return_val_if_fail (EM_IS_VFOLDER_EDITOR_CONTEXT (context), NULL);
|
||||
|
||||
return context->priv->session;
|
||||
}
|
||||
73
mail/em-vfolder-editor-context.h
Normal file
73
mail/em-vfolder-editor-context.h
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with the program; if not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Not Zed <notzed@lostzed.mmc.com.au>
|
||||
* Jeffrey Stedfast <fejj@ximian.com>
|
||||
*
|
||||
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef EM_VFOLDER_EDITOR_CONTEXT_H
|
||||
#define EM_VFOLDER_EDITOR_CONTEXT_H
|
||||
|
||||
#include <filter/e-rule-context.h>
|
||||
#include <libemail-utils/em-vfolder-context.h>
|
||||
#include <libemail-engine/e-mail-session.h>
|
||||
|
||||
/* Standard GObject macros */
|
||||
#define EM_TYPE_VFOLDER_EDITOR_CONTEXT \
|
||||
(em_vfolder_editor_context_get_type ())
|
||||
#define EM_VFOLDER_EDITOR_CONTEXT(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST \
|
||||
((obj), EM_TYPE_VFOLDER_EDITOR_CONTEXT, EMVFolderEditorContext))
|
||||
#define EM_VFOLDER_EDITOR_CONTEXT_CLASS(cls) \
|
||||
(G_TYPE_CHECK_CLASS_CAST \
|
||||
((cls), EM_TYPE_VFOLDER_EDITOR_CONTEXT, EMVFolderEditorContextClass))
|
||||
#define EM_IS_VFOLDER_EDITOR_CONTEXT(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE \
|
||||
((obj), EM_TYPE_VFOLDER_EDITOR_CONTEXT))
|
||||
#define EM_IS_VFOLDER_EDITOR_CONTEXT_CLASS(cls) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE \
|
||||
((cls), EM_TYPE_VFOLDER_EDITOR_CONTEXT))
|
||||
#define EM_VFOLDER_EDITOR_CONTEXT_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS \
|
||||
((obj), EM_TYPE_VFOLDER_EDITOR_CONTEXT, EMVFolderEditorContextClass))
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _EMVFolderEditorContext EMVFolderEditorContext;
|
||||
typedef struct _EMVFolderEditorContextClass EMVFolderEditorContextClass;
|
||||
typedef struct _EMVFolderEditorContextPrivate EMVFolderEditorContextPrivate;
|
||||
|
||||
struct _EMVFolderEditorContext {
|
||||
EMVFolderContext parent;
|
||||
EMVFolderEditorContextPrivate *priv;
|
||||
};
|
||||
|
||||
struct _EMVFolderEditorContextClass {
|
||||
EMVFolderContextClass parent_class;
|
||||
};
|
||||
|
||||
GType em_vfolder_editor_context_get_type (void);
|
||||
EMVFolderEditorContext *
|
||||
em_vfolder_editor_context_new (EMailSession *session);
|
||||
EMailSession * em_vfolder_editor_context_get_session (EMVFolderEditorContext *context);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* EM_VFOLDER_EDITOR_CONTEXT_H */
|
||||
@ -41,19 +41,19 @@
|
||||
#include "em-folder-selector.h"
|
||||
#include "em-folder-tree.h"
|
||||
#include "em-utils.h"
|
||||
#include "em-vfolder-context.h"
|
||||
#include "em-vfolder-rule.h"
|
||||
#include "em-vfolder-editor-context.h"
|
||||
#include "em-vfolder-editor-rule.h"
|
||||
|
||||
#define EM_VFOLDER_RULE_GET_PRIVATE(obj) \
|
||||
#define EM_VFOLDER_EDITOR_RULE_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE \
|
||||
((obj), EM_TYPE_VFOLDER_RULE, EMVFolderRulePrivate))
|
||||
((obj), EM_TYPE_VFOLDER_EDITOR_RULE, EMVFolderEditorRulePrivate))
|
||||
|
||||
#define EM_VFOLDER_RULE_GET_PRIVATE(obj) \
|
||||
#define EM_VFOLDER_EDITOR_RULE_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE \
|
||||
((obj), EM_TYPE_VFOLDER_RULE, EMVFolderRulePrivate))
|
||||
((obj), EM_TYPE_VFOLDER_EDITOR_RULE, EMVFolderEditorRulePrivate))
|
||||
|
||||
struct _EMVFolderRulePrivate {
|
||||
EMailSession *session;
|
||||
struct _EMVFolderEditorRulePrivate {
|
||||
EMailSession *session;
|
||||
};
|
||||
|
||||
enum {
|
||||
@ -61,28 +61,15 @@ enum {
|
||||
PROP_SESSION
|
||||
};
|
||||
|
||||
static gint validate (EFilterRule *, EAlert **alert);
|
||||
static gint vfolder_eq (EFilterRule *fr, EFilterRule *cm);
|
||||
static xmlNodePtr xml_encode (EFilterRule *);
|
||||
static gint xml_decode (EFilterRule *, xmlNodePtr, ERuleContext *f);
|
||||
static void rule_copy (EFilterRule *dest, EFilterRule *src);
|
||||
static GtkWidget *get_widget (EFilterRule *fr, ERuleContext *f);
|
||||
|
||||
/* DO NOT internationalise these strings */
|
||||
static const gchar *with_names[] = {
|
||||
"specific",
|
||||
"local_remote_active",
|
||||
"remote_active",
|
||||
"local"
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (
|
||||
EMVFolderRule,
|
||||
em_vfolder_rule,
|
||||
E_TYPE_FILTER_RULE)
|
||||
EMVFolderEditorRule,
|
||||
em_vfolder_editor_rule,
|
||||
EM_TYPE_VFOLDER_RULE)
|
||||
|
||||
static void
|
||||
vfolder_rule_set_session (EMVFolderRule *rule,
|
||||
vfolder_editor_rule_set_session (EMVFolderEditorRule *rule,
|
||||
EMailSession *session)
|
||||
{
|
||||
if (session == NULL) {
|
||||
@ -104,15 +91,15 @@ vfolder_rule_set_session (EMVFolderRule *rule,
|
||||
}
|
||||
|
||||
static void
|
||||
vfolder_rule_set_property (GObject *object,
|
||||
vfolder_editor_rule_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
switch (property_id) {
|
||||
case PROP_SESSION:
|
||||
vfolder_rule_set_session (
|
||||
EM_VFOLDER_RULE (object),
|
||||
vfolder_editor_rule_set_session (
|
||||
EM_VFOLDER_EDITOR_RULE (object),
|
||||
g_value_get_object (value));
|
||||
return;
|
||||
}
|
||||
@ -121,7 +108,7 @@ vfolder_rule_set_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
vfolder_rule_get_property (GObject *object,
|
||||
vfolder_editor_rule_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
@ -130,8 +117,8 @@ vfolder_rule_get_property (GObject *object,
|
||||
case PROP_SESSION:
|
||||
g_value_set_object (
|
||||
value,
|
||||
em_vfolder_rule_get_session (
|
||||
EM_VFOLDER_RULE (object)));
|
||||
em_vfolder_editor_rule_get_session (
|
||||
EM_VFOLDER_EDITOR_RULE (object)));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -139,54 +126,44 @@ vfolder_rule_get_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
vfolder_rule_dispose (GObject *object)
|
||||
vfolder_editor_rule_dispose (GObject *object)
|
||||
{
|
||||
EMVFolderRulePrivate *priv;
|
||||
|
||||
priv = EM_VFOLDER_RULE_GET_PRIVATE (object);
|
||||
EMVFolderEditorRulePrivate *priv;
|
||||
|
||||
priv = EM_VFOLDER_EDITOR_RULE_GET_PRIVATE (object);
|
||||
if (priv->session != NULL) {
|
||||
g_object_unref (priv->session);
|
||||
priv->session = NULL;
|
||||
}
|
||||
|
||||
/* Chain up to parent's dispose() method. */
|
||||
G_OBJECT_CLASS (em_vfolder_rule_parent_class)->dispose (object);
|
||||
G_OBJECT_CLASS (em_vfolder_editor_rule_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
vfolder_rule_finalize (GObject *object)
|
||||
vfolder_editor_rule_finalize (GObject *object)
|
||||
{
|
||||
EMVFolderRule *rule = EM_VFOLDER_RULE (object);
|
||||
gchar *uri;
|
||||
|
||||
while ((uri = g_queue_pop_head (&rule->sources)) != NULL)
|
||||
g_free (uri);
|
||||
/* EMVFolderEditorRule *rule = EM_VFOLDER_EDITOR_RULE (object); */
|
||||
|
||||
/* Chain up to parent's finalize() method. */
|
||||
G_OBJECT_CLASS (em_vfolder_rule_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (em_vfolder_editor_rule_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
em_vfolder_rule_class_init (EMVFolderRuleClass *class)
|
||||
em_vfolder_editor_rule_class_init (EMVFolderEditorRuleClass *class)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
EFilterRuleClass *filter_rule_class;
|
||||
|
||||
g_type_class_add_private (class, sizeof (EMVFolderRulePrivate));
|
||||
g_type_class_add_private (class, sizeof (EMVFolderEditorRulePrivate));
|
||||
|
||||
object_class = G_OBJECT_CLASS (class);
|
||||
object_class->set_property = vfolder_rule_set_property;
|
||||
object_class->get_property = vfolder_rule_get_property;
|
||||
object_class->dispose = vfolder_rule_dispose;
|
||||
object_class->finalize = vfolder_rule_finalize;
|
||||
object_class->set_property = vfolder_editor_rule_set_property;
|
||||
object_class->get_property = vfolder_editor_rule_get_property;
|
||||
object_class->dispose = vfolder_editor_rule_dispose;
|
||||
object_class->finalize = vfolder_editor_rule_finalize;
|
||||
|
||||
filter_rule_class = E_FILTER_RULE_CLASS (class);
|
||||
filter_rule_class->validate = validate;
|
||||
filter_rule_class->eq = vfolder_eq;
|
||||
filter_rule_class->xml_encode = xml_encode;
|
||||
filter_rule_class->xml_decode = xml_decode;
|
||||
filter_rule_class->copy = rule_copy;
|
||||
filter_rule_class->get_widget = get_widget;
|
||||
|
||||
g_object_class_install_property (
|
||||
@ -202,267 +179,28 @@ em_vfolder_rule_class_init (EMVFolderRuleClass *class)
|
||||
}
|
||||
|
||||
static void
|
||||
em_vfolder_rule_init (EMVFolderRule *rule)
|
||||
em_vfolder_editor_rule_init (EMVFolderEditorRule *rule)
|
||||
{
|
||||
rule->priv = EM_VFOLDER_RULE_GET_PRIVATE (rule);
|
||||
rule->with = EM_VFOLDER_RULE_WITH_SPECIFIC;
|
||||
rule->rule.source = g_strdup ("incoming");
|
||||
rule->priv = EM_VFOLDER_EDITOR_RULE_GET_PRIVATE (rule);
|
||||
}
|
||||
|
||||
EFilterRule *
|
||||
em_vfolder_rule_new (EMailSession *session)
|
||||
em_vfolder_editor_rule_new (EMailSession *session)
|
||||
{
|
||||
g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
|
||||
|
||||
return g_object_new (
|
||||
EM_TYPE_VFOLDER_RULE, "session", session, NULL);
|
||||
EM_TYPE_VFOLDER_EDITOR_RULE, "session", session, NULL);
|
||||
}
|
||||
|
||||
EMailSession *
|
||||
em_vfolder_rule_get_session (EMVFolderRule *rule)
|
||||
em_vfolder_editor_rule_get_session (EMVFolderEditorRule *rule)
|
||||
{
|
||||
g_return_val_if_fail (EM_IS_VFOLDER_RULE (rule), NULL);
|
||||
|
||||
return rule->priv->session;
|
||||
}
|
||||
|
||||
void
|
||||
em_vfolder_rule_add_source (EMVFolderRule *rule,
|
||||
const gchar *uri)
|
||||
{
|
||||
g_return_if_fail (EM_IS_VFOLDER_RULE (rule));
|
||||
g_return_if_fail (uri);
|
||||
|
||||
g_queue_push_tail (&rule->sources, g_strdup (uri));
|
||||
|
||||
e_filter_rule_emit_changed (E_FILTER_RULE (rule));
|
||||
}
|
||||
|
||||
const gchar *
|
||||
em_vfolder_rule_find_source (EMVFolderRule *rule,
|
||||
const gchar *uri)
|
||||
{
|
||||
GList *link;
|
||||
|
||||
g_return_val_if_fail (EM_IS_VFOLDER_RULE (rule), NULL);
|
||||
|
||||
/* only does a simple string or address comparison, should
|
||||
* probably do a decoded url comparison */
|
||||
link = g_queue_find_custom (
|
||||
&rule->sources, uri, (GCompareFunc) strcmp);
|
||||
|
||||
return (link != NULL) ? link->data : NULL;
|
||||
}
|
||||
|
||||
void
|
||||
em_vfolder_rule_remove_source (EMVFolderRule *rule,
|
||||
const gchar *uri)
|
||||
{
|
||||
gchar *found;
|
||||
|
||||
g_return_if_fail (EM_IS_VFOLDER_RULE (rule));
|
||||
|
||||
found =(gchar *) em_vfolder_rule_find_source (rule, uri);
|
||||
if (found != NULL) {
|
||||
g_queue_remove (&rule->sources, found);
|
||||
g_free (found);
|
||||
e_filter_rule_emit_changed (E_FILTER_RULE (rule));
|
||||
}
|
||||
}
|
||||
|
||||
const gchar *
|
||||
em_vfolder_rule_next_source (EMVFolderRule *rule,
|
||||
const gchar *last)
|
||||
{
|
||||
GList *link;
|
||||
|
||||
if (last == NULL) {
|
||||
link = g_queue_peek_head_link (&rule->sources);
|
||||
} else {
|
||||
link = g_queue_find (&rule->sources, last);
|
||||
if (link == NULL)
|
||||
link = g_queue_peek_head_link (&rule->sources);
|
||||
else
|
||||
link = g_list_next (link);
|
||||
}
|
||||
|
||||
return (link != NULL) ? link->data : NULL;
|
||||
}
|
||||
|
||||
static gint
|
||||
validate (EFilterRule *fr,
|
||||
EAlert **alert)
|
||||
{
|
||||
g_return_val_if_fail (fr != NULL, 0);
|
||||
g_warn_if_fail (alert == NULL || *alert == NULL);
|
||||
|
||||
if (!fr->name || !*fr->name) {
|
||||
if (alert)
|
||||
*alert = e_alert_new ("mail:no-name-vfolder", NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* We have to have at least one source set in the "specific" case.
|
||||
* Do not translate this string! */
|
||||
if (((EMVFolderRule *) fr)->with == EM_VFOLDER_RULE_WITH_SPECIFIC &&
|
||||
g_queue_is_empty (&((EMVFolderRule *) fr)->sources)) {
|
||||
if (alert)
|
||||
*alert = e_alert_new ("mail:vfolder-no-source", NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return E_FILTER_RULE_CLASS (em_vfolder_rule_parent_class)->validate (fr, alert);
|
||||
}
|
||||
|
||||
static gint
|
||||
queue_eq (GQueue *queue_a,
|
||||
GQueue *queue_b)
|
||||
{
|
||||
GList *link_a;
|
||||
GList *link_b;
|
||||
gint truth = TRUE;
|
||||
|
||||
link_a = g_queue_peek_head_link (queue_a);
|
||||
link_b = g_queue_peek_head_link (queue_b);
|
||||
|
||||
while (truth && link_a != NULL && link_b != NULL) {
|
||||
gchar *uri_a = link_a->data;
|
||||
gchar *uri_b = link_b->data;
|
||||
|
||||
truth = (strcmp (uri_a, uri_b)== 0);
|
||||
|
||||
link_a = g_list_next (link_a);
|
||||
link_b = g_list_next (link_b);
|
||||
}
|
||||
|
||||
return truth && link_a == NULL && link_b == NULL;
|
||||
}
|
||||
|
||||
static gint
|
||||
vfolder_eq (EFilterRule *fr,
|
||||
EFilterRule *cm)
|
||||
{
|
||||
return E_FILTER_RULE_CLASS (em_vfolder_rule_parent_class)->eq (fr, cm)
|
||||
&& queue_eq (
|
||||
&((EMVFolderRule *) fr)->sources,
|
||||
&((EMVFolderRule *) cm)->sources);
|
||||
}
|
||||
|
||||
static xmlNodePtr
|
||||
xml_encode (EFilterRule *fr)
|
||||
{
|
||||
EMVFolderRule *vr =(EMVFolderRule *) fr;
|
||||
xmlNodePtr node, set, work;
|
||||
GList *head, *link;
|
||||
|
||||
node = E_FILTER_RULE_CLASS (em_vfolder_rule_parent_class)->xml_encode (fr);
|
||||
g_return_val_if_fail (node != NULL, NULL);
|
||||
g_return_val_if_fail (vr->with < G_N_ELEMENTS (with_names), NULL);
|
||||
|
||||
set = xmlNewNode(NULL, (const guchar *)"sources");
|
||||
xmlAddChild (node, set);
|
||||
xmlSetProp(set, (const guchar *)"with", (guchar *)with_names[vr->with]);
|
||||
|
||||
head = g_queue_peek_head_link (&vr->sources);
|
||||
for (link = head; link != NULL; link = g_list_next (link)) {
|
||||
const gchar *uri = link->data;
|
||||
|
||||
work = xmlNewNode (NULL, (const guchar *) "folder");
|
||||
xmlSetProp (work, (const guchar *) "uri", (guchar *) uri);
|
||||
xmlAddChild (set, work);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
static void
|
||||
set_with (EMVFolderRule *vr,
|
||||
const gchar *name)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (with_names); i++) {
|
||||
if (!strcmp (name, with_names[i])) {
|
||||
vr->with = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
vr->with = 0;
|
||||
}
|
||||
|
||||
static gint
|
||||
xml_decode (EFilterRule *fr,
|
||||
xmlNodePtr node,
|
||||
ERuleContext *f)
|
||||
{
|
||||
xmlNodePtr set, work;
|
||||
gint result;
|
||||
EMVFolderRule *vr =(EMVFolderRule *) fr;
|
||||
gchar *tmp;
|
||||
|
||||
result = E_FILTER_RULE_CLASS (em_vfolder_rule_parent_class)->
|
||||
xml_decode (fr, node, f);
|
||||
if (result != 0)
|
||||
return result;
|
||||
|
||||
/* handle old format file, vfolder source is in filterrule */
|
||||
if (strcmp(fr->source, "incoming")!= 0) {
|
||||
set_with (vr, fr->source);
|
||||
g_free (fr->source);
|
||||
fr->source = g_strdup("incoming");
|
||||
}
|
||||
|
||||
set = node->children;
|
||||
while (set) {
|
||||
if (!strcmp((gchar *)set->name, "sources")) {
|
||||
tmp = (gchar *)xmlGetProp(set, (const guchar *)"with");
|
||||
if (tmp) {
|
||||
set_with (vr, tmp);
|
||||
xmlFree (tmp);
|
||||
}
|
||||
work = set->children;
|
||||
while (work) {
|
||||
if (!strcmp((gchar *)work->name, "folder")) {
|
||||
tmp = (gchar *)xmlGetProp(work, (const guchar *)"uri");
|
||||
if (tmp) {
|
||||
g_queue_push_tail (&vr->sources, g_strdup (tmp));
|
||||
xmlFree (tmp);
|
||||
}
|
||||
}
|
||||
work = work->next;
|
||||
}
|
||||
}
|
||||
set = set->next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
rule_copy (EFilterRule *dest,
|
||||
EFilterRule *src)
|
||||
{
|
||||
EMVFolderRule *vdest, *vsrc;
|
||||
GList *head, *link;
|
||||
gchar *uri;
|
||||
|
||||
vdest =(EMVFolderRule *) dest;
|
||||
vsrc =(EMVFolderRule *) src;
|
||||
|
||||
while ((uri = g_queue_pop_head (&vdest->sources)) != NULL)
|
||||
g_free (uri);
|
||||
|
||||
head = g_queue_peek_head_link (&vsrc->sources);
|
||||
for (link = head; link != NULL; link = g_list_next (link)) {
|
||||
const gchar *uri = link->data;
|
||||
g_queue_push_tail (&vdest->sources, g_strdup (uri));
|
||||
}
|
||||
|
||||
vdest->with = vsrc->with;
|
||||
|
||||
E_FILTER_RULE_CLASS (em_vfolder_rule_parent_class)->copy (dest, src);
|
||||
}
|
||||
|
||||
enum {
|
||||
BUTTON_ADD,
|
||||
BUTTON_REMOVE,
|
||||
@ -685,7 +423,7 @@ get_widget (EFilterRule *fr,
|
||||
GObject *object;
|
||||
gint i;
|
||||
|
||||
widget = E_FILTER_RULE_CLASS (em_vfolder_rule_parent_class)->
|
||||
widget = E_FILTER_RULE_CLASS (em_vfolder_editor_rule_parent_class)->
|
||||
get_widget (fr, rc);
|
||||
|
||||
data = g_malloc0 (sizeof (*data));
|
||||
@ -712,7 +450,7 @@ get_widget (EFilterRule *fr,
|
||||
object = gtk_builder_get_object (builder, "source_model");
|
||||
data->model = GTK_LIST_STORE (object);
|
||||
|
||||
session = em_vfolder_context_get_session (EM_VFOLDER_CONTEXT (rc));
|
||||
session = em_vfolder_editor_context_get_session (EM_VFOLDER_EDITOR_CONTEXT (rc));
|
||||
|
||||
source = NULL;
|
||||
while ((source = em_vfolder_rule_next_source (vr, source))) {
|
||||
81
mail/em-vfolder-editor-rule.h
Normal file
81
mail/em-vfolder-editor-rule.h
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with the program; if not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* NotZed <notzed@ximian.com>
|
||||
* Jeffrey Stedfast <fejj@ximian.com>
|
||||
*
|
||||
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef EM_VFOLDER_EDITOR_RULE_H
|
||||
#define EM_VFOLDER_EDITOR_RULE_H
|
||||
|
||||
#include <filter/e-filter-rule.h>
|
||||
#include <libemail-utils/em-vfolder-rule.h>
|
||||
#include <libemail-engine/e-mail-session.h>
|
||||
|
||||
/* Standard GObject macros */
|
||||
#define EM_TYPE_VFOLDER_EDITOR_RULE \
|
||||
(em_vfolder_editor_rule_get_type ())
|
||||
#define EM_VFOLDER_EDITOR_RULE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST \
|
||||
((obj), EM_TYPE_VFOLDER_EDITOR_RULE, EMVFolderEditorRule))
|
||||
#define EM_VFOLDER_EDITOR_RULE_CLASS(cls) \
|
||||
(G_TYPE_CHECK_CLASS_CAST \
|
||||
((cls), EM_TYPE_VFOLDER_EDITOR_RULE, EMVFolderEditorRuleClass))
|
||||
#define EM_IS_VFOLDER_EDITOR_RULE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE \
|
||||
((obj), EM_TYPE_VFOLDER_EDITOR_RULE))
|
||||
#define EM_IS_VFOLDER_EDITOR_RULE_CLASS(cls) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE \
|
||||
((cls), EM_TYPE_VFOLDER_EDITOR_RULE))
|
||||
#define EM_VFOLDER_EDITOR_RULE_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS \
|
||||
((obj), EM_TYPE_VFOLDER_EDITOR_RULE, EMVFolderEditorRuleClass))
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* perhaps should be bits? */
|
||||
enum _em_vfolder_editor_rule_with_t {
|
||||
EM_VFOLDER_EDITOR_RULE_WITH_SPECIFIC,
|
||||
EM_VFOLDER_EDITOR_RULE_WITH_LOCAL_REMOTE_ACTIVE,
|
||||
EM_VFOLDER_EDITOR_RULE_WITH_REMOTE_ACTIVE,
|
||||
EM_VFOLDER_EDITOR_RULE_WITH_LOCAL
|
||||
};
|
||||
|
||||
typedef struct _EMVFolderEditorRule EMVFolderEditorRule;
|
||||
typedef struct _EMVFolderEditorRuleClass EMVFolderEditorRuleClass;
|
||||
typedef struct _EMVFolderEditorRulePrivate EMVFolderEditorRulePrivate;
|
||||
|
||||
typedef enum _em_vfolder_editor_rule_with_t em_vfolder_editor_rule_with_t;
|
||||
|
||||
struct _EMVFolderEditorRule {
|
||||
EMVFolderRule rule;
|
||||
EMVFolderEditorRulePrivate *priv;
|
||||
};
|
||||
|
||||
struct _EMVFolderEditorRuleClass {
|
||||
EMVFolderRuleClass parent_class;
|
||||
};
|
||||
|
||||
GType em_vfolder_editor_rule_get_type (void);
|
||||
EFilterRule * em_vfolder_editor_rule_new (EMailSession *session);
|
||||
EMailSession * em_vfolder_editor_rule_get_session (EMVFolderEditorRule *rule);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* EM_VFOLDER_EDITOR_RULE_H */
|
||||
@ -34,7 +34,7 @@
|
||||
#include "e-util/e-util-private.h"
|
||||
|
||||
#include "em-vfolder-editor.h"
|
||||
#include "em-vfolder-rule.h"
|
||||
#include "em-vfolder-editor-rule.h"
|
||||
|
||||
G_DEFINE_TYPE (
|
||||
EMVFolderEditor,
|
||||
@ -44,16 +44,16 @@ G_DEFINE_TYPE (
|
||||
static EFilterRule *
|
||||
vfolder_editor_create_rule (ERuleEditor *rule_editor)
|
||||
{
|
||||
EMVFolderContext *context;
|
||||
EMVFolderEditorContext *context;
|
||||
EMailSession *session;
|
||||
EFilterRule *rule;
|
||||
EFilterPart *part;
|
||||
|
||||
context = EM_VFOLDER_CONTEXT (rule_editor->context);
|
||||
session = em_vfolder_context_get_session (context);
|
||||
context = EM_VFOLDER_EDITOR_CONTEXT (rule_editor->context);
|
||||
session = em_vfolder_editor_context_get_session (context);
|
||||
|
||||
/* create a rule with 1 part in it */
|
||||
rule = em_vfolder_rule_new (session);
|
||||
rule = em_vfolder_editor_rule_new (session);
|
||||
part = e_rule_context_next_part (rule_editor->context, NULL);
|
||||
e_filter_rule_add_part (rule, e_filter_part_clone (part));
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
#define EM_VFOLDER_EDITOR_H
|
||||
|
||||
#include "filter/e-rule-editor.h"
|
||||
#include "em-vfolder-context.h"
|
||||
#include "em-vfolder-editor-context.h"
|
||||
|
||||
/* Standard GObject macros */
|
||||
#define EM_TYPE_VFOLDER_EDITOR \
|
||||
|
||||
@ -38,8 +38,8 @@
|
||||
#include "libevolution-utils/e-alert-dialog.h"
|
||||
#include "e-util/e-util-private.h"
|
||||
|
||||
#include "em-vfolder-context.h"
|
||||
#include "em-vfolder-rule.h"
|
||||
#include "em-vfolder-editor-context.h"
|
||||
#include "em-vfolder-editor-rule.h"
|
||||
#include "em-vfolder-editor.h"
|
||||
|
||||
#include "em-filter-context.h"
|
||||
@ -317,9 +317,9 @@ em_vfolder_rule_from_message (EMVFolderContext *context,
|
||||
|
||||
uri = e_mail_folder_uri_from_folder (folder);
|
||||
|
||||
session = em_vfolder_context_get_session (context);
|
||||
session = em_vfolder_editor_context_get_session ((EMVFolderEditorContext *) context);
|
||||
|
||||
rule = em_vfolder_rule_new (session);
|
||||
rule = em_vfolder_editor_rule_new (session);
|
||||
em_vfolder_rule_add_source (EM_VFOLDER_RULE (rule), uri);
|
||||
rule_from_message (rule, E_RULE_CONTEXT (context), msg, flags);
|
||||
|
||||
@ -344,9 +344,9 @@ em_vfolder_rule_from_address (EMVFolderContext *context,
|
||||
|
||||
uri = e_mail_folder_uri_from_folder (folder);
|
||||
|
||||
session = em_vfolder_context_get_session (context);
|
||||
session = em_vfolder_editor_context_get_session ((EMVFolderEditorContext *) context);
|
||||
|
||||
rule = em_vfolder_rule_new (session);
|
||||
rule = em_vfolder_editor_rule_new (session);
|
||||
em_vfolder_rule_add_source (EM_VFOLDER_RULE (rule), uri);
|
||||
rule_from_address (rule, E_RULE_CONTEXT (context), addr, flags);
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
#include <filter/e-filter-rule.h>
|
||||
#include <mail/em-filter-context.h>
|
||||
#include <mail/em-vfolder-context.h>
|
||||
#include <libemail-utils/em-vfolder-context.h>
|
||||
#include <libemail-engine/e-mail-session.h>
|
||||
|
||||
enum {
|
||||
|
||||
@ -42,9 +42,9 @@
|
||||
#include "e-mail-backend.h"
|
||||
#include "em-folder-tree-model.h"
|
||||
#include "em-utils.h"
|
||||
#include "em-vfolder-context.h"
|
||||
#include "em-vfolder-editor-context.h"
|
||||
#include "em-vfolder-editor.h"
|
||||
#include "em-vfolder-rule.h"
|
||||
#include "em-vfolder-editor-rule.h"
|
||||
#include "mail-autofilter.h"
|
||||
#include "mail-vfolder.h"
|
||||
#include "e-mail-ui-session.h"
|
||||
@ -713,7 +713,7 @@ rule_changed (EFilterRule *rule,
|
||||
const gchar *full_name;
|
||||
|
||||
full_name = camel_folder_get_full_name (folder);
|
||||
session = em_vfolder_rule_get_session (EM_VFOLDER_RULE (rule));
|
||||
session = em_vfolder_editor_rule_get_session (EM_VFOLDER_EDITOR_RULE (rule));
|
||||
|
||||
service = camel_session_get_service (
|
||||
CAMEL_SESSION (session), E_MAIL_SESSION_VFOLDER_UID);
|
||||
@ -815,7 +815,7 @@ context_rule_added (ERuleContext *ctx,
|
||||
|
||||
d(printf("rule added: %s\n", rule->name));
|
||||
|
||||
session = em_vfolder_rule_get_session (EM_VFOLDER_RULE (rule));
|
||||
session = em_vfolder_editor_rule_get_session (EM_VFOLDER_EDITOR_RULE (rule));
|
||||
|
||||
service = camel_session_get_service (
|
||||
CAMEL_SESSION (session), E_MAIL_SESSION_VFOLDER_UID);
|
||||
@ -848,7 +848,7 @@ context_rule_removed (ERuleContext *ctx,
|
||||
|
||||
d(printf("rule removed; %s\n", rule->name));
|
||||
|
||||
session = em_vfolder_rule_get_session (EM_VFOLDER_RULE (rule));
|
||||
session = em_vfolder_editor_rule_get_session (EM_VFOLDER_EDITOR_RULE (rule));
|
||||
|
||||
service = camel_session_get_service (
|
||||
CAMEL_SESSION (session), E_MAIL_SESSION_VFOLDER_UID);
|
||||
@ -1043,7 +1043,7 @@ vfolder_load_storage (EMailBackend *backend)
|
||||
|
||||
/* load our rules */
|
||||
user = g_build_filename (config_dir, "vfolders.xml", NULL);
|
||||
context = em_vfolder_context_new (session);
|
||||
context = (EMVFolderContext *) em_vfolder_editor_context_new (session);
|
||||
|
||||
xmlfile = g_build_filename (EVOLUTION_PRIVDATADIR, "vfoldertypes.xml", NULL);
|
||||
if (e_rule_context_load ((ERuleContext *) context,
|
||||
@ -1283,7 +1283,7 @@ vfolder_clone_rule (EMailSession *session,
|
||||
|
||||
g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
|
||||
|
||||
rule = em_vfolder_rule_new (session);
|
||||
rule = em_vfolder_editor_rule_new (session);
|
||||
|
||||
xml = e_filter_rule_xml_encode (in);
|
||||
e_filter_rule_xml_decode (rule, xml, (ERuleContext *) context);
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
#include <filter/e-filter-part.h>
|
||||
#include <filter/e-filter-rule.h>
|
||||
#include <mail/e-mail-backend.h>
|
||||
#include <mail/em-vfolder-rule.h>
|
||||
#include <libemail-utils/em-vfolder-rule.h>
|
||||
#include <shell/e-shell-view.h>
|
||||
|
||||
void vfolder_load_storage (EMailBackend *backend);
|
||||
|
||||
Reference in New Issue
Block a user