Mercurial > dovecot > original-hg > dovecot-1.2
comparison src/plugins/trash/trash-plugin.c @ 5577:1fd9616157e4 HEAD
Updated to support namespaces
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 17 Apr 2007 21:00:48 +0300 |
parents | 67b8d61c988f |
children | 6074e9e6059d |
comparison
equal
deleted
inserted
replaced
5576:36ebd0fe2076 | 5577:1fd9616157e4 |
---|---|
2 | 2 |
3 #include "lib.h" | 3 #include "lib.h" |
4 #include "array.h" | 4 #include "array.h" |
5 #include "istream.h" | 5 #include "istream.h" |
6 #include "home-expand.h" | 6 #include "home-expand.h" |
7 #include "mail-namespace.h" | |
7 #include "mail-search.h" | 8 #include "mail-search.h" |
8 #include "quota-private.h" | 9 #include "quota-private.h" |
9 #include "quota-plugin.h" | 10 #include "quota-plugin.h" |
10 #include "trash-plugin.h" | 11 #include "trash-plugin.h" |
11 | 12 |
92 | 93 |
93 *received_time_r = mail_get_received_date(trash->mail); | 94 *received_time_r = mail_get_received_date(trash->mail); |
94 return 1; | 95 return 1; |
95 } | 96 } |
96 | 97 |
98 static void trash_find_storage(struct trash_mailbox *trash) | |
99 { | |
100 struct mail_storage *const *storages; | |
101 unsigned int i, count; | |
102 | |
103 storages = array_get("a_set->storages, &count); | |
104 for (i = 0; i < count; i++) { | |
105 if (mail_namespace_update_name(storages[i]->ns, &trash->name)) { | |
106 trash->storage = storages[i]; | |
107 return; | |
108 } | |
109 } | |
110 i_fatal("trash: Namespace not found for mailbox '%s'", trash->name); | |
111 } | |
112 | |
97 static int trash_try_clean_mails(struct quota_transaction_context *ctx, | 113 static int trash_try_clean_mails(struct quota_transaction_context *ctx, |
98 uint64_t size_needed) | 114 uint64_t size_needed) |
99 { | 115 { |
100 struct trash_mailbox *trashes; | 116 struct trash_mailbox *trashes; |
101 unsigned int i, j, count, oldest_idx; | 117 unsigned int i, j, count, oldest_idx; |
111 oldest = (time_t)-1; | 127 oldest = (time_t)-1; |
112 for (j = i; j < count; j++) { | 128 for (j = i; j < count; j++) { |
113 if (trashes[j].priority != trashes[i].priority) | 129 if (trashes[j].priority != trashes[i].priority) |
114 break; | 130 break; |
115 | 131 |
116 if (trashes[j].storage == NULL) { | 132 if (trashes[j].storage == NULL) |
117 /* FIXME: this is really ugly. it'll do however | 133 trash_find_storage(&trashes[j]); |
118 until we get proper namespace support for | |
119 lib-storage. */ | |
120 struct mail_storage *const *storage; | |
121 | |
122 storage = array_idx("a_set->storages, 0); | |
123 trashes[j].storage = *storage; | |
124 } | |
125 | 134 |
126 ret = trash_clean_mailbox_get_next(&trashes[j], | 135 ret = trash_clean_mailbox_get_next(&trashes[j], |
127 &received); | 136 &received); |
128 if (ret < 0) | 137 if (ret < 0) |
129 goto __err; | 138 goto __err; |