bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2004-2018 Dovecot authors, see the included COPYING file */
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen#include "lib.h"
ff7257145f317d6ca44a9402427bb74c34b999a9Timo Sirainen#include "array.h"
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen#include "mail-index-private.h"
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen#include "mail-index-view-private.h"
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen
a94936bafd127680184da114c6a177b37ff656e5Timo Sirainenstatic void dummy_view_close(struct mail_index_view *view ATTR_UNUSED)
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen{
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen i_assert(view->refcount == 0);
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen
ff7257145f317d6ca44a9402427bb74c34b999a9Timo Sirainen array_free(&view->module_contexts);
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen i_free(view);
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen}
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainenstatic uint32_t
a94936bafd127680184da114c6a177b37ff656e5Timo Sirainendummy_view_get_message_count(struct mail_index_view *view ATTR_UNUSED)
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen{
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen return (uint32_t)-3;
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen}
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainenstatic struct mail_index_view_vfuncs dummy_view_vfuncs = {
a94936bafd127680184da114c6a177b37ff656e5Timo Sirainen dummy_view_close,
a94936bafd127680184da114c6a177b37ff656e5Timo Sirainen dummy_view_get_message_count,
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen NULL,
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen NULL,
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen NULL,
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen NULL,
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen NULL,
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen NULL,
5278c93bd7105c32ac7ec37f36015d5950f6cbcaTimo Sirainen NULL,
3fe9483b2b412a14493e3120751b0e99ecfe9388Timo Sirainen NULL,
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen NULL
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen};
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen
2ddd140bcecd9f8b7f2686b419cdfaa5d5d3a9e8Timo Sirainenstruct mail_index_view *mail_index_dummy_view_open(struct mail_index *index)
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen{
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen struct mail_index_view *view;
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen view = i_new(struct mail_index_view, 1);
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen view->refcount = 1;
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainen view->v = dummy_view_vfuncs;
2ddd140bcecd9f8b7f2686b419cdfaa5d5d3a9e8Timo Sirainen view->index = index;
ff7257145f317d6ca44a9402427bb74c34b999a9Timo Sirainen i_array_init(&view->module_contexts,
ff7257145f317d6ca44a9402427bb74c34b999a9Timo Sirainen I_MIN(5, mail_index_module_register.id));
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen return view;
e8acc691a14a6d0884c5ca9aa4d8507f1e082040Timo Sirainen}