static BUFFY *buffy_new (const char *path)
{
BUFFY* buffy;
-#ifdef USE_SIDEBAR
char rp[PATH_MAX] = "";
char *r = NULL;
-#endif
buffy = (BUFFY *) safe_calloc (1, sizeof (BUFFY));
strfcpy (buffy->path, path, sizeof (buffy->path));
-#ifdef USE_SIDEBAR
r = realpath (path, rp);
strfcpy (buffy->realpath, r ? rp : path, sizeof (buffy->realpath));
-#endif
buffy->next = NULL;
buffy->magic = 0;
char buf[_POSIX_PATH_MAX];
struct stat sb;
char f1[PATH_MAX];
-#ifndef USE_SIDEBAR
- char f2[PATH_MAX];
-#endif
- char *p, *q;
+ char *p;
while (MoreArgs (s))
{
p = realpath (buf, f1);
for (tmp = &Incoming; *tmp; tmp = &((*tmp)->next))
{
-#ifdef USE_SIDEBAR
- q = (*tmp)->realpath;
- if (mutt_strcmp (p ? p : buf, q) == 0)
-#else
- q = realpath ((*tmp)->path, f2);
- if (mutt_strcmp (p ? p : buf, q ? q : (*tmp)->path) == 0)
-#endif
+ if (mutt_strcmp (p ? p : buf, (*tmp)->realpath) == 0)
{
dprint(3,(debugfile,"mailbox '%s' already registered as '%s'\n", buf, (*tmp)->path));
break;
typedef struct buffy_t
{
char path[_POSIX_PATH_MAX];
-#ifdef USE_SIDEBAR
- char realpath[_POSIX_PATH_MAX];
-#endif
+ char realpath[_POSIX_PATH_MAX]; /* used for duplicate detection, context comparison,
+ and the sidebar */
off_t size;
struct buffy_t *next;
#ifdef USE_SIDEBAR
}
mutt_expand_path (buf, sizeof (buf));
-#ifdef USE_SIDEBAR
- mutt_sb_set_open_buffy (buf);
-#endif
if (mx_get_magic (buf) <= 0)
{
mutt_error (_("%s is not a mailbox."), buf);
else
menu->current = 0;
+#ifdef USE_SIDEBAR
+ mutt_sb_set_open_buffy ();
+#endif
+
mutt_clear_error ();
mutt_buffy_check(1); /* force the buffy check after we have changed
the folder */
imap_qualify_path (buf, sizeof (buf), &mx, idata->mailbox);
FREE (&(ctx->path));
+ FREE (&(ctx->realpath));
ctx->path = safe_strdup (buf);
+ ctx->realpath = safe_strdup (ctx->path);
idata->ctx = ctx;
int main (int argc, char **argv)
{
-#ifdef USE_SIDEBAR
- char folder[PATH_MAX] = "";
-#else
char folder[_POSIX_PATH_MAX] = "";
-#endif
char *subject = NULL;
char *includeFile = NULL;
char *draftFile = NULL;
strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
mutt_expand_path (folder, sizeof (folder));
-#ifdef USE_SIDEBAR
- {
- char tmpfolder[PATH_MAX] = "";
- strfcpy (tmpfolder, folder, sizeof (tmpfolder));
- if (!realpath (tmpfolder, folder))
- strfcpy (folder, tmpfolder, sizeof (tmpfolder));
- }
-#endif
-
mutt_str_replace (&CurrentFolder, folder);
mutt_str_replace (&LastFolder, folder);
|| !explicit_folder)
{
#ifdef USE_SIDEBAR
- mutt_sb_set_open_buffy (folder);
+ mutt_sb_set_open_buffy ();
#endif
mutt_index_menu ();
if (Context)
typedef struct _context
{
char *path;
+ char *realpath; /* used for buffy comparison and the sidebar */
FILE *fp;
time_t atime;
time_t mtime;
ctx = safe_malloc (sizeof (CONTEXT));
memset (ctx, 0, sizeof (CONTEXT));
ctx->path = safe_strdup (path);
+ if (! (ctx->realpath = realpath (ctx->path, NULL)) )
+ ctx->realpath = safe_strdup (ctx->path);
ctx->msgnotreadyet = -1;
ctx->collapsed = 0;
FREE (&ctx->hdrs);
FREE (&ctx->v2r);
FREE (&ctx->path);
+ FREE (&ctx->realpath);
FREE (&ctx->pattern);
if (ctx->limit_pattern)
mutt_pattern_free (&ctx->limit_pattern);
return -1;
FREE (&ctx->path);
+ FREE (&ctx->realpath);
ctx->path = safe_strdup (buf);
+ ctx->realpath = safe_strdup (ctx->path);
pop_data = safe_calloc (1, sizeof (POP_DATA));
pop_data->conn = conn;
if (!b)
return src;
- int c = Context && (mutt_strcmp (Context->path, b->path) == 0);
+ int c = Context && (mutt_strcmp (Context->realpath, b->realpath) == 0);
optional = flags & M_FORMAT_OPTIONAL;
(b == HilBuffy) || (b->msg_flagged > 0))
continue;
- if (Context && (strcmp (b->path, Context->path) == 0))
+ if (Context && (mutt_strcmp (b->realpath, Context->realpath) == 0))
/* Spool directory */
continue;
SETCOLOR(MT_COLOR_NORMAL);
move (first_row + row, 0);
- if (Context && Context->path &&
- (!strcmp (b->path, Context->path)||
- !strcmp (b->realpath, Context->path)))
+ if (Context && Context->realpath &&
+ !mutt_strcmp (b->realpath, Context->realpath))
{
b->msg_unread = Context->unread;
b->msg_count = Context->msgcount;
for (; b; b = b->next)
{
- if (!strcmp (b->path, ctx->path) ||
- !strcmp (b->realpath, ctx->path))
+ if (!mutt_strcmp (b->realpath, ctx->realpath))
{
b->msg_unread = ctx->unread;
b->msg_count = ctx->msgcount;
}
/**
- * mutt_sb_set_open_buffy - Set the OpnBuffy based on a mailbox path
- * @path: Mailbox path
+ * mutt_sb_set_open_buffy - Set the OpnBuffy based on a the global Context
*
* Search through the list of mailboxes. If a BUFFY has a matching path, set
* OpnBuffy to it.
*/
-BUFFY *mutt_sb_set_open_buffy (const char *path)
+BUFFY *mutt_sb_set_open_buffy (void)
{
/* Even if the sidebar is hidden */
BUFFY *b = Incoming;
- if (!path || !b)
- return NULL;
-
OpnBuffy = NULL;
+ if (!Context || !b)
+ return NULL;
+
for (; b; b = b->next)
{
- if (!strcmp (b->path, path) ||
- !strcmp (b->realpath, path))
+ if (!mutt_strcmp (b->realpath, Context->realpath))
{
OpnBuffy = b;
HilBuffy = b;
{
/* This might happen if the user "unmailboxes *", then
* "mailboxes" our current mailbox back again */
- if (mutt_strcmp (b->path, Context->path) == 0)
+ if (mutt_strcmp (b->realpath, Context->realpath) == 0)
OpnBuffy = b;
}
}
void mutt_sb_init (void);
void mutt_sb_notify_mailbox (BUFFY *b, int created);
void mutt_sb_set_buffystats (const CONTEXT *ctx);
-BUFFY * mutt_sb_set_open_buffy (const char *path);
+BUFFY * mutt_sb_set_open_buffy (void);
#endif /* SIDEBAR_H */