changeset 12541:5815ff80f198

fts: Added missing new files for last commit.
author Timo Sirainen <tss@iki.fi>
date Mon, 06 Dec 2010 03:40:41 +0000
parents 3c883e0dcb31
children 8d27401008c9
files src/plugins/fts/fts-mailbox.c src/plugins/fts/fts-mailbox.h
diffstat 2 files changed, 78 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/plugins/fts/fts-mailbox.c	Mon Dec 06 03:40:41 2010 +0000
@@ -0,0 +1,56 @@
+/* Copyright (c) 2006-2010 Dovecot authors, see the included COPYING file */
+
+#include "lib.h"
+#include "mail-storage.h"
+#include "fts-mailbox.h"
+#include "../virtual/virtual-storage.h"
+
+bool fts_mailbox_get_virtual_uid(struct mailbox *box,
+				 const char *backend_mailbox,
+				 uint32_t backend_uidvalidity,
+				 uint32_t backend_uid, uint32_t *uid_r)
+{
+	struct virtual_mailbox *vbox;
+
+	if (strcmp(box->storage->name, VIRTUAL_STORAGE_NAME) != 0)
+		return FALSE;
+
+	vbox = (struct virtual_mailbox *)box;
+	return vbox->vfuncs.get_virtual_uid(box, backend_mailbox,
+					    backend_uidvalidity,
+					    backend_uid, uid_r);
+}
+
+void fts_mailbox_get_virtual_backend_boxes(struct mailbox *box,
+					   ARRAY_TYPE(mailboxes) *mailboxes,
+					   bool only_with_msgs)
+{
+	struct virtual_mailbox *vbox;
+
+	if (strcmp(box->storage->name, VIRTUAL_STORAGE_NAME) != 0)
+		array_append(mailboxes, &box, 1);
+	else {
+		vbox = (struct virtual_mailbox *)box;
+		vbox->vfuncs.get_virtual_backend_boxes(box, mailboxes,
+						       only_with_msgs);
+	}
+}
+
+void fts_mailbox_get_virtual_box_patterns(struct mailbox *box,
+				ARRAY_TYPE(mailbox_virtual_patterns) *includes,
+				ARRAY_TYPE(mailbox_virtual_patterns) *excludes)
+{
+	struct virtual_mailbox *vbox;
+
+	if (strcmp(box->storage->name, VIRTUAL_STORAGE_NAME) != 0) {
+		struct mailbox_virtual_pattern pat;
+
+		memset(&pat, 0, sizeof(pat));
+		pat.ns = mailbox_list_get_namespace(box->list);
+		pat.pattern = box->name;
+		array_append(includes, &pat, 1);
+	} else {
+		vbox = (struct virtual_mailbox *)box;
+		vbox->vfuncs.get_virtual_box_patterns(box, includes, excludes);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/plugins/fts/fts-mailbox.h	Mon Dec 06 03:40:41 2010 +0000
@@ -0,0 +1,22 @@
+#ifndef FTS_MAILBOX_H
+#define FTS_MAILBOX_H
+
+/* If box is a virtual mailbox, look up UID for the given backend message.
+   Returns TRUE if found, FALSE if not. */
+bool fts_mailbox_get_virtual_uid(struct mailbox *box,
+				 const char *backend_mailbox,
+				 uint32_t backend_uidvalidity,
+				 uint32_t backend_uid, uint32_t *uid_r);
+/* If box is a virtual mailbox, return all backend mailboxes. If
+   only_with_msgs=TRUE, return only those mailboxes that have at least one
+   message existing in the virtual mailbox. */
+void fts_mailbox_get_virtual_backend_boxes(struct mailbox *box,
+					   ARRAY_TYPE(mailboxes) *mailboxes,
+					   bool only_with_msgs);
+/* If mailbox is a virtual mailbox, return all mailbox list patterns that
+   are used to figure out which mailboxes belong to the virtual mailbox. */
+void fts_mailbox_get_virtual_box_patterns(struct mailbox *box,
+				ARRAY_TYPE(mailbox_virtual_patterns) *includes,
+				ARRAY_TYPE(mailbox_virtual_patterns) *excludes);
+
+#endif