~ubuntu-branches/ubuntu/wily/evolution-data-server/wily

« back to all changes in this revision

Viewing changes to camel/camel-filter-search.c

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2015-07-20 13:34:59 UTC
  • mfrom: (1.1.126) (1.2.48 sid)
  • Revision ID: package-import@ubuntu.com-20150720133459-g6y46hnu5ewtoz08
Tags: 3.16.4-0ubuntu2
debian/patches/0001-Bug-752373-Monthly-events-do-not-recur-correctly.patch:
Cherry-pick patch from upstream to fix events not recurring correctly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
2
/*
3
 
 * Authors: Jeffrey Stedfast <fejj@ximian.com>
4
 
 *           Michael Zucchi <NotZed@Ximian.com>
5
 
 *
6
3
 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
7
4
 *
8
 
 * This library is free software you can redistribute it and/or modify it
 
5
 * This library is free software: you can redistribute it and/or modify it
9
6
 * under the terms of the GNU Lesser General Public License as published by
10
7
 * the Free Software Foundation.
11
8
 *
12
9
 * This library is distributed in the hope that it will be useful, but
13
10
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14
 
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 
11
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15
12
 * for more details.
16
13
 *
17
14
 * You should have received a copy of the GNU Lesser General Public License
18
 
 * along with this library; if not, see <http://www.gnu.org/licenses/>.
 
15
 * along with this library. If not, see <http://www.gnu.org/licenses/>.
19
16
 *
 
17
 * Authors: Jeffrey Stedfast <fejj@ximian.com>
 
18
 *          Michael Zucchi <NotZed@Ximian.com>
20
19
 */
21
20
 
22
21
#ifdef HAVE_CONFIG_H
62
61
        gpointer get_message_data;
63
62
        CamelMimeMessage *message;
64
63
        CamelMessageInfo *info;
 
64
        CamelFolder *folder;
65
65
        const gchar *source;
66
66
        GError **error;
67
67
} FilterMessageSearch;
90
90
static CamelSExpResult *get_size (struct _CamelSExp *f, gint argc, struct _CamelSExpResult **argv, FilterMessageSearch *fms);
91
91
static CamelSExpResult *pipe_message (struct _CamelSExp *f, gint argc, struct _CamelSExpResult **argv, FilterMessageSearch *fms);
92
92
static CamelSExpResult *junk_test (struct _CamelSExp *f, gint argc, struct _CamelSExpResult **argv, FilterMessageSearch *fms);
 
93
static CamelSExpResult *message_location (struct _CamelSExp *f, gint argc, struct _CamelSExpResult **argv, FilterMessageSearch *fms);
93
94
 
94
95
/* builtin functions */
95
96
static struct {
121
122
        { "get-size",           (CamelSExpFunc) get_size,           0 },
122
123
        { "pipe-message",       (CamelSExpFunc) pipe_message,       0 },
123
124
        { "junk-test",          (CamelSExpFunc) junk_test,          0 },
 
125
        { "message-location",   (CamelSExpFunc) message_location,   0 }
124
126
};
125
127
 
126
128
static CamelMimeMessage *
1019
1021
        return r;
1020
1022
}
1021
1023
 
 
1024
/* this is copied from Evolution's libemail-engine/e-mail-folder-utils.c */
 
1025
static gchar *
 
1026
mail_folder_uri_build (CamelStore *store,
 
1027
                       const gchar *folder_name)
 
1028
{
 
1029
        const gchar *uid;
 
1030
        gchar *encoded_name;
 
1031
        gchar *encoded_uid;
 
1032
        gchar *uri;
 
1033
 
 
1034
        g_return_val_if_fail (CAMEL_IS_STORE (store), NULL);
 
1035
        g_return_val_if_fail (folder_name != NULL, NULL);
 
1036
 
 
1037
        /* Skip the leading slash, if present. */
 
1038
        if (*folder_name == '/')
 
1039
                folder_name++;
 
1040
 
 
1041
        uid = camel_service_get_uid (CAMEL_SERVICE (store));
 
1042
 
 
1043
        encoded_uid = camel_url_encode (uid, ":;@/");
 
1044
        encoded_name = camel_url_encode (folder_name, "#");
 
1045
 
 
1046
        uri = g_strdup_printf ("folder://%s/%s", encoded_uid, encoded_name);
 
1047
 
 
1048
        g_free (encoded_uid);
 
1049
        g_free (encoded_name);
 
1050
 
 
1051
        return uri;
 
1052
}
 
1053
 
 
1054
static CamelSExpResult *
 
1055
message_location (struct _CamelSExp *f,
 
1056
                  gint argc,
 
1057
                  struct _CamelSExpResult **argv,
 
1058
                  FilterMessageSearch *fms)
 
1059
{
 
1060
        CamelSExpResult *r;
 
1061
        gboolean same = FALSE;
 
1062
 
 
1063
        if (argc != 1 || argv[0]->type != CAMEL_SEXP_RES_STRING)
 
1064
                camel_sexp_fatal_error (f, _("Invalid arguments to (message-location)"));
 
1065
 
 
1066
        if (fms->folder && argv[0]->value.string) {
 
1067
                CamelStore *store;
 
1068
                const gchar *name;
 
1069
                gchar *uri;
 
1070
 
 
1071
                store = camel_folder_get_parent_store (fms->folder);
 
1072
                name = camel_folder_get_full_name (fms->folder);
 
1073
                uri = mail_folder_uri_build (store, name);
 
1074
 
 
1075
                same = g_str_equal (uri, argv[0]->value.string);
 
1076
 
 
1077
                g_free (uri);
 
1078
        }
 
1079
 
 
1080
        r = camel_sexp_result_new (f, CAMEL_SEXP_RES_BOOL);
 
1081
        r->value.boolean = same;
 
1082
 
 
1083
        return r;
 
1084
}
 
1085
 
1022
1086
/**
1023
1087
 * camel_filter_search_match:
1024
1088
 * @session:
1026
1090
 * @data: data for above
1027
1091
 * @info:
1028
1092
 * @source:
 
1093
 * @folder: in which folder the message is stored
1029
1094
 * @expression:
1030
1095
 * @error: return location for a #GError, or %NULL
1031
1096
 *
1038
1103
                           gpointer data,
1039
1104
                           CamelMessageInfo *info,
1040
1105
                           const gchar *source,
 
1106
                           CamelFolder *folder,
1041
1107
                           const gchar *expression,
1042
1108
                           GError **error)
1043
1109
{
1054
1120
        fms.message = NULL;
1055
1121
        fms.info = info;
1056
1122
        fms.source = source;
 
1123
        fms.folder = folder;
1057
1124
        fms.error = &local_error;
1058
1125
 
1059
1126
        sexp = camel_sexp_new ();