~ubuntu-branches/ubuntu/wily/dovecot/wily

« back to all changes in this revision

Viewing changes to src/plugins/fts-solr/fts-backend-solr-old.c

  • Committer: Package Import Robot
  • Author(s): Jaldhar H. Vyas
  • Date: 2013-09-09 00:57:32 UTC
  • mfrom: (1.13.11)
  • mto: (4.8.5 experimental) (1.16.1)
  • mto: This revision was merged to the branch mainline in revision 97.
  • Revision ID: package-import@ubuntu.com-20130909005732-dn1eell8srqbhh0e
Tags: upstream-2.2.5
ImportĀ upstreamĀ versionĀ 2.2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2006-2012 Dovecot authors, see the included COPYING file */
 
1
/* Copyright (c) 2006-2013 Dovecot authors, see the included COPYING file */
2
2
 
3
3
#include "lib.h"
4
4
#include "array.h"
6
6
#include "hash.h"
7
7
#include "strescape.h"
8
8
#include "unichar.h"
 
9
#include "http-url.h"
9
10
#include "imap-utf7.h"
10
11
#include "mail-storage-private.h"
11
12
#include "mailbox-list-private.h"
40
41
        bool documents_added;
41
42
};
42
43
 
43
 
static struct solr_connection *solr_conn = NULL;
44
 
 
45
44
static bool is_valid_xml_char(unichar_t chr)
46
45
{
47
46
        /* Valid characters in XML:
151
150
static void solr_quote_http(string_t *dest, const char *str)
152
151
{
153
152
        str_append(dest, "%22");
154
 
        solr_connection_http_escape(solr_conn, dest, str);
 
153
        http_url_escape_param(dest, str);
155
154
        str_append(dest, "%22");
156
155
}
157
156
 
236
235
                *error_r = "Invalid fts_solr setting";
237
236
                return -1;
238
237
        }
239
 
 
240
238
        if (solr_conn == NULL) {
241
 
                solr_conn = solr_connection_init(fuser->set.url,
242
 
                                                 fuser->set.debug);
 
239
                if (solr_connection_init(fuser->set.url, fuser->set.debug,
 
240
                                         &solr_conn, error_r) < 0)
 
241
                        return -1;
243
242
        }
244
243
 
245
244
        str = solr_escape_id_str(_backend->ns->user->username);
285
284
 
286
285
        tmp = t_str_new(64);
287
286
        solr_add_ns_query(tmp, backend, ns, FALSE);
288
 
        solr_connection_http_escape(solr_conn, str, str_c(tmp));
 
287
        http_url_escape_param(str, str_c(tmp));
289
288
}
290
289
 
291
290
static int
354
353
        if (fts_backend_solr_get_last_uid_fallback(backend, box, last_uid_r) < 0)
355
354
                return -1;
356
355
 
357
 
        (void)fts_index_set_last_uid(box, *last_uid_r);
 
356
        fts_index_set_last_uid(box, *last_uid_r);
358
357
        return 0;
359
358
}
360
359
 
473
472
        struct mail_namespace *ns;
474
473
 
475
474
        if (ctx->prev_uid != 0) {
476
 
                (void)fts_index_set_last_uid(ctx->cur_box, ctx->prev_uid);
 
475
                fts_index_set_last_uid(ctx->cur_box, ctx->prev_uid);
477
476
                ctx->prev_uid = 0;
478
477
        }
479
478
 
726
725
{
727
726
        struct solr_result **solr_results;
728
727
        struct fts_result *fts_result;
729
 
        ARRAY_DEFINE(fts_results, struct fts_result);
 
728
        ARRAY(struct fts_result) fts_results;
730
729
        struct mail_namespace *ns;
731
730
        struct mailbox_status status;
732
 
        struct hash_table *mailboxes;
 
731
        HASH_TABLE(char *, struct mailbox *) mailboxes;
733
732
        struct mailbox *box;
734
733
        const char *box_name;
735
734
        char *box_id;
743
742
        else
744
743
                str_append(str, "%22%22");
745
744
 
746
 
        mailboxes = hash_table_create(default_pool, default_pool, 0,
747
 
                                      str_hash, (hash_cmp_callback_t *)strcmp);
 
745
        hash_table_create(&mailboxes, default_pool, 0, str_hash, strcmp);
748
746
        str_append(str, "%2B(");
749
747
        len = str_len(str);
750
748
        for (i = 0; boxes[i] != NULL; i++) {
783
781
                fts_result->scores = solr_results[i]->scores;
784
782
                fts_result->scores_sorted = TRUE;
785
783
        }
786
 
        (void)array_append_space(&fts_results);
 
784
        array_append_zero(&fts_results);
787
785
        result->box_results = array_idx_modifiable(&fts_results, 0);
788
786
        hash_table_destroy(&mailboxes);
789
787
        return 0;