summaryrefslogtreecommitdiff
path: root/imapcommands.c
diff options
context:
space:
mode:
Diffstat (limited to 'imapcommands.c')
-rw-r--r--imapcommands.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/imapcommands.c b/imapcommands.c
index 1d3dcf36..d231486d 100644
--- a/imapcommands.c
+++ b/imapcommands.c
@@ -738,8 +738,8 @@ int _ic_list(struct ImapSession *self)
pattern = g_strdup_printf("%s%s", self->args[0], self->args[1]);
TRACE(TRACE_INFO, "search with pattern: [%s]",pattern);
-
- result = db_findmailbox_by_regex(ud->userid, pattern, &children, &nchildren, list_is_lsub);
+
+ result = db_getmailbox_list_by_regex(ud->userid, pattern, &children, &nchildren, list_is_lsub, &mb);
if (result == -1) {
dbmail_imap_session_printf(self, "* BYE internal dbase error\r\n");
g_free(children);
@@ -755,17 +755,13 @@ int _ic_list(struct ImapSession *self)
return 1;
}
- mb = g_new0(mailbox_t,1);
-
shown = g_tree_new_full((GCompareDataFunc)dm_strcmpdata,NULL,(GDestroyNotify)g_free,NULL);
for (i = 0; i < nchildren; i++) {
gboolean show = FALSE;
- if ((db_getmailbox_list_result(children[i], ud->userid, mb) != 0))
- continue;
/* Enforce match of mailbox to pattern. */
- if (! listex_match(pattern, mb->name, MAILBOX_SEPARATOR, 0)) {
+ if (! listex_match(pattern, mb[i].name, MAILBOX_SEPARATOR, 0)) {
if (g_str_has_suffix(pattern,"%")) {
/*
If the "%" wildcard is the last character of a mailbox name argument, matching levels
@@ -773,8 +769,8 @@ int _ic_list(struct ImapSession *self)
mailboxes, they are returned with the \Noselect mailbox name attribute
*/
- TRACE(TRACE_DEBUG, "mailbox [%s] doesn't match pattern [%s]", mb->name, pattern);
- char *m = NULL, **p = g_strsplit(mb->name,MAILBOX_SEPARATOR,0);
+ TRACE(TRACE_DEBUG, "mailbox [%s] doesn't match pattern [%s]", mb[i].name, pattern);
+ char *m = NULL, **p = g_strsplit(mb[i].name,MAILBOX_SEPARATOR,0);
int l = g_strv_length(p);
while (l-- > 1) {
if (p[l]) {
@@ -784,10 +780,10 @@ int _ic_list(struct ImapSession *self)
m = g_strjoinv(MAILBOX_SEPARATOR,p);
if (listex_match(pattern, m, MAILBOX_SEPARATOR, 0)) {
- g_free(mb->name);
- mb->name = m;
- mb->no_select = 1;
- mb->no_children = 0;
+ g_free(mb[i].name);
+ mb[i].name = m;
+ mb[i].no_select = 1;
+ mb[i].no_children = 0;
show = TRUE;
break;
}
@@ -799,15 +795,15 @@ int _ic_list(struct ImapSession *self)
show = TRUE;
}
- if (show && (! g_tree_lookup(shown, mb->name))) {
- char *s = g_strdup(mb->name);
+ if (show && (! g_tree_lookup(shown, mb[i].name))) {
+ char *s = g_strdup(mb[i].name);
g_tree_insert(shown, s, s);
plist = NULL;
- if (mb->no_select)
+ if (mb[i].no_select)
plist = g_list_append(plist, g_strdup("\\noselect"));
- if (mb->no_inferiors)
+ if (mb[i].no_inferiors)
plist = g_list_append(plist, g_strdup("\\noinferiors"));
- if (mb->no_children)
+ if (mb[i].no_children)
plist = g_list_append(plist, g_strdup("\\hasnochildren"));
else
plist = g_list_append(plist, g_strdup("\\haschildren"));
@@ -815,14 +811,13 @@ int _ic_list(struct ImapSession *self)
/* show */
pstring = dbmail_imap_plist_as_string(plist);
dbmail_imap_session_printf(self, "* %s %s \"%s\" \"%s\"\r\n", thisname,
- pstring, MAILBOX_SEPARATOR, mb->name);
+ pstring, MAILBOX_SEPARATOR, mb[i].name);
g_list_destroy(plist);
g_free(pstring);
}
}
-
if (children)
g_free(children);