subscribed mailboxes from the server and add them to the buffy list.
short showparents = 0;
int noselect;
int noinferiors;
+ int save_lsub;
IMAP_MBOX mx;
if (imap_parse_path (path, &mx))
return -1;
}
+ save_lsub = option (OPTIMAPCHECKSUBSCRIBED);
+ unset_option (OPTIMAPCHECKSUBSCRIBED);
strfcpy (list_cmd, option (OPTIMAPLSUB) ? "LSUB" : "LIST", sizeof (list_cmd));
if (!(idata = imap_conn_find (&(mx.account), 0)))
}
}
+ if (save_lsub)
+ set_option (OPTIMAPCHECKSUBSCRIBED);
+
FREE (&mx.mbox);
return 0;
fail:
+ if (save_lsub)
+ set_option (OPTIMAPCHECKSUBSCRIBED);
FREE (&mx.mbox);
return -1;
}
/*
* Copyright (C) 1996-8 Michael R. Elkins <me@mutt.org>
* Copyright (C) 1996-9 Brandon Long <blong@fiction.net>
- * Copyright (C) 1999-2002 Brendan Cully <brendan@kublai.com>
+ * Copyright (C) 1999-2005 Brendan Cully <brendan@kublai.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
static void cmd_make_sequence (IMAP_DATA* idata);
static void cmd_parse_capabilities (IMAP_DATA* idata, char* s);
static void cmd_parse_expunge (IMAP_DATA* idata, const char* s);
+static void cmd_parse_lsub (IMAP_DATA* idata, char* s);
static void cmd_parse_fetch (IMAP_DATA* idata, char* s);
static void cmd_parse_myrights (IMAP_DATA* idata, char* s);
}
else if (ascii_strncasecmp ("CAPABILITY", s, 10) == 0)
cmd_parse_capabilities (idata, s);
+ else if (ascii_strncasecmp ("LSUB", s, 4) == 0)
+ cmd_parse_lsub (idata, s);
else if (ascii_strncasecmp ("MYRIGHTS", s, 8) == 0)
cmd_parse_myrights (idata, s);
else if (ascii_strncasecmp ("BYE", s, 3) == 0)
}
}
+static void cmd_parse_lsub (IMAP_DATA* idata, char* s)
+{
+ char buf[STRING];
+ char errstr[STRING];
+ BUFFER err, token;
+ ciss_url_t url;
+ char *ep;
+
+ if (!option (OPTIMAPCHECKSUBSCRIBED))
+ return;
+
+ s = imap_next_word (s); /* flags */
+
+ if (*s != '(')
+ {
+ dprint (1, (debugfile, "Bad LSUB response\n"));
+ return;
+ }
+
+ s++;
+ ep = s;
+ for (ep = s; *ep && *ep != ')'; ep++)
+ ;
+ do
+ {
+ if (!ascii_strncasecmp (s, "\\NoSelect", 9))
+ return;
+ if (*s != ')')
+ s = imap_next_word (s);
+ } while (s != ep);
+
+ s = imap_next_word (s); /* delim */
+ s = imap_next_word (s); /* name */
+
+ if (s)
+ {
+ imap_unmunge_mbox_name (s);
+ dprint (2, (debugfile, "Subscribing to %s\n", s));
+
+ strfcpy (buf, "mailboxes \"", sizeof (buf));
+ mutt_account_tourl (&idata->conn->account, &url);
+ url.path = s;
+ if (!mutt_strcmp (url.user, ImapUser))
+ url.user = NULL;
+ url_ciss_tostring (&url, buf + 11, sizeof (buf) - 10, 0);
+ safe_strcat (buf, sizeof (buf), "\"");
+ memset (&token, 0, sizeof (token));
+ err.data = errstr;
+ err.dsize = sizeof (errstr);
+ if (mutt_parse_rc_line (buf, &token, &err))
+ dprint (1, (debugfile, "Error adding subscribed mailbox: %s\n", errstr));
+ FREE (&token.data);
+ }
+ else
+ dprint (1, (debugfile, "Bad LSUB response\n"));
+}
+
/* cmd_parse_myrights: set rights bits according to MYRIGHTS response */
static void cmd_parse_myrights (IMAP_DATA* idata, char* s)
{
FREE (&idata->capstr);
}
if (idata->state == IMAP_AUTHENTICATED)
+ {
imap_get_delim (idata);
-
+ if (option (OPTIMAPCHECKSUBSCRIBED))
+ {
+ mutt_message _("Checking mailbox subscriptions");
+ imap_exec (idata, "LSUB \"\" \"*\"", 0);
+ }
+ }
+
return idata;
}
** try them. Authentication methods are either 'login' or the right
** side of an IMAP 'AUTH=xxx' capability string, eg 'digest-md5', 'gssapi'
** or 'cram-md5'. This parameter is case-insensitive. If this
- ** parameter is unset (the default) mutt will try all available methods,
+ ** parameter is \fIunset\fP (the default) mutt will try all available methods,
** in order from most-secure to least-secure.
** .pp
** Example: set imap_authenticators="gssapi:cram-md5:login"
** the previous methods are unavailable. If a method is available but
** authentication fails, mutt will not connect to the IMAP server.
*/
+ { "imap_check_subscribed", DT_BOOL, R_NONE, OPTIMAPCHECKSUBSCRIBED, 0 },
+ /*
+ ** .pp
+ ** When \fIset\fP, mutt will fetch the set of subscribed folders from
+ ** your server on connection, and add them to the set of mailboxes
+ ** it polls for new mail. See also the ``$mailboxes'' and
+ ** ``$unmailboxes'' commands.
+ */
{ "imap_delim_chars", DT_STR, R_NONE, UL &ImapDelimChars, UL "/." },
/*
** .pp
{ "imap_pass", DT_STR, R_NONE, UL &ImapPass, UL 0 },
/*
** .pp
- ** Specifies the password for your IMAP account. If unset, Mutt will
+ ** Specifies the password for your IMAP account. If \fIunset\fP, Mutt will
** prompt you for your password when you invoke the fetch-mail function.
** \fBWarning\fP: you should only use this option when you are on a
** fairly secure machine, because the superuser can read your muttrc even
{ "imap_passive", DT_BOOL, R_NONE, OPTIMAPPASSIVE, 1 },
/*
** .pp
- ** When set, mutt will not open new IMAP connections to check for new
+ ** When \fIset\fP, mutt will not open new IMAP connections to check for new
** mail. Mutt will only check for new mail over existing IMAP
** connections. This is useful if you don't want to be prompted to
** user/password pairs on mutt invocation, or if opening the connection
{ "imap_peek", DT_BOOL, R_NONE, OPTIMAPPEEK, 1 },
/*
** .pp
- ** If set, mutt will avoid implicitly marking your mail as read whenever
+ ** When \fIset\fP, mutt will avoid implicitly marking your mail as read whenever
** you fetch a message from the server. This is generally a good thing,
** but can make closing an IMAP folder somewhat slower. This option
** exists to appease speed freaks.
{ "imap_servernoise", DT_BOOL, R_NONE, OPTIMAPSERVERNOISE, 1 },
/*
** .pp
- ** When set, mutt will display warning messages from the IMAP
+ ** When \fIset\fP, mutt will display warning messages from the IMAP
** server as error messages. Since these messages are often
** harmless, or generated due to configuration problems on the
** server which are out of the users' hands, you may wish to suppress
OPTHIDETOPMISSING,
OPTIGNORELISTREPLYTO,
#ifdef USE_IMAP
+ OPTIMAPCHECKSUBSCRIBED,
OPTIMAPLSUB,
OPTIMAPPASSIVE,
OPTIMAPPEEK,