Commit 515c5cfa 515c5cfa29ba62b61460d3aa5e76ac6c9b2e0bc1 by Alain Magloire

* imap4d/bye.c: call mailbox_save_attributes() when exiting.

	it will save the attribute flags.
	* imap4d/close.c: Typo.
	* imap4d/logout: Remove the mailbox_close() and mailbox_destroy()
	it is being call imap4d_bye ().
	* imap4d/select.c (imapr3d_select0): call mailbox_save_attributes()
	if a mailbox was already selected.

	Feedback from Sergey for the need of saving the attribute flags
	without expunging.  Note, this is a hack, the code is taken from
	mbox_expunge(mbx_mbox.c) and there is lot of duplication.  But
	since we are moving toward a new mailbox API, the code will be
	rewritten more cleanly in the new API.

	* include/mailutils/mailbox.h: Add proto mailbox_save_attributes()
	* mailbox/include/mailbox0.h: New field in struct _mailbox
	_save_attributes (mailbox_t);
	* mailbox/mailbox.c: New function mailbox_save_attributes ().
	* mailbox/mbx_mbox.c: New function mbox_save_attributes (),
	implement saving the attribute flags in header field "Status:"
1 parent d50a67c3
2001-07-02 Alain Magloire
* imap4d/bye.c: call mailbox_save_attributes() when exiting.
it will save the attribute flags.
* imap4d/close.c: Typo.
* imap4d/logout: Remove the mailbox_close() and mailbox_destroy()
it is being call imap4d_bye ().
* imap4d/select.c (imapr3d_select0): call mailbox_save_attributes()
if a mailbox was already selected.
Feedback from Sergey for the need of saving the attribute flags
without expunging. Note, this is a hack, the code is taken from
mbox_expunge(mbx_mbox.c) and there is lot of duplication. But
since we are moving toward a new mailbox API, the code will be
rewritten more cleanly in the new API.
* include/mailutils/mailbox.h: Add proto mailbox_save_attributes()
* mailbox/include/mailbox0.h: New field in struct _mailbox
_save_attributes (mailbox_t);
* mailbox/mailbox.c: New function mailbox_save_attributes ().
* mailbox/mbx_mbox.c: New function mbox_save_attributes (),
implement saving the attribute flags in header field "Status:"
2001-07-01 Alain Magloire
* mail/util.c (util_strupper): The first implementation was
......
......@@ -26,8 +26,12 @@ imap4d_bye (int reason)
int status = EXIT_FAILURE;
username = (pw) ? pw->pw_name : "Unknown";
mailbox_close (mbox);
mailbox_destroy (&mbox);
if (mbox)
{
mailbox_save_attributes (mbox);
mailbox_close (mbox);
mailbox_destroy (&mbox);
}
switch (reason)
{
......
......@@ -27,8 +27,8 @@ imap4d_close (struct imap4d_command *command, char *arg)
if (! (command->states & state))
return util_finish (command, RESP_BAD, "Wrong state");
/* FIXME: Check and report errors. */
/* The CLOSE command permanently removes form the currentyl selected
mailbox all messages that have the \\Deleted falg set, and returns
/* The CLOSE command permanently removes from the currently selected
mailbox all messages that have the \\Deleted flag set, and returns
to authenticated state from selected state. */
mailbox_expunge (mbox);
/* No messages are removed, and no error is give, if the mailbox is
......
......@@ -30,15 +30,6 @@ imap4d_logout (struct imap4d_command *command, char *arg)
if (util_getword (arg, &sp))
return util_finish (command, RESP_BAD, "Too many args");
util_finish (command, RESP_OK, "Completed");
/* Even if a mailbox is selected, a SELECT, EXAMINE or LOGOUT
command MAY be issued without previously issuing a CLOSE command.
The SELECT, EXAMINE, and LOGOUT commands implictly close the
currently selected mailbox without doing an expunge. */
if (mbox)
{
mailbox_close (mbox);
mailbox_destroy (&mbox);
}
imap4d_bye (OK);
return 0;
}
......
......@@ -44,12 +44,13 @@ imap4d_select0 (struct imap4d_command *command, char *arg, int flags)
if (mailbox_name == NULL || *mailbox_name == '\0')
return util_finish (command, RESP_BAD, "Too few arguments");
/* Even if a mailbox is slected, a SLECT EXAMINE or LOGOUT
/* Even if a mailbox is selected, a SELECT EXAMINE or LOGOUT
command MAY be issued without previously issuing a CLOSE command.
The SELECT, EXAMINE, and LOGUT commands implictly close the
currently selected mailbox withut doing an expunge. */
currently selected mailbox without doing an expunge. */
if (mbox)
{
mailbox_save_attributes (mbox);
mailbox_close (mbox);
mailbox_destroy (&mbox);
/* Destroy the old uid table. */
......@@ -72,7 +73,7 @@ imap4d_select0 (struct imap4d_command *command, char *arg, int flags)
mailbox_name = namespace_getfullpath (mailbox_name, "/");
if (!mailbox_name)
return util_finish (command, RESP_NO, "Couldn't open mailbox");
return util_finish (command, RESP_NO, "Couldn't open mailbox");
if (mailbox_create (&mbox, mailbox_name) == 0
&& mailbox_open (mbox, flags) == 0)
......@@ -102,7 +103,7 @@ imap4d_select_status()
if (state != STATE_SEL)
return;
mailbox_uidvalidity (mbox, &uidvalidity);
mailbox_uidnext (mbox, &uidnext);
mailbox_messages_count (mbox, &count);
......
......@@ -513,7 +513,7 @@ imap4d_readline (FILE *fp)
}
}
while (number > 0);
/* syslog (LOG_INFO, "readline: %s", line); */
/*syslog (LOG_INFO, "readline: %s", line); */
return line;
}
......@@ -669,7 +669,7 @@ util_parse_822_date (char *date, time_t *timep)
struct tm tm;
mu_timezone tz;
const char* p = date;
if (parse822_date_time(&p, date+strlen(date), &tm, &tz) == 0)
{
*timep = mu_tm2time (&tm, &tz);
......@@ -683,7 +683,7 @@ util_parse_ctime_date (const char *date, time_t *timep)
{
struct tm tm;
mu_timezone tz;
if (mu_parse_ctime_date_time(&date, &tm, &tz) == 0)
{
*timep = mu_tm2time (&tm, &tz);
......
......@@ -65,6 +65,7 @@ extern int mailbox_messages_count __P ((mailbox_t, size_t *));
extern int mailbox_messages_recent __P ((mailbox_t, size_t *));
extern int mailbox_message_unseen __P ((mailbox_t, size_t *));
extern int mailbox_expunge __P ((mailbox_t));
extern int mailbox_save_attributes __P ((mailbox_t));
/* Update and scanning. */
extern int mailbox_get_size __P ((mailbox_t, off_t *size));
......
......@@ -82,6 +82,7 @@ struct _mailbox
int (*_messages_recent) __P ((mailbox_t, size_t *num));
int (*_message_unseen) __P ((mailbox_t, size_t *num));
int (*_expunge) __P ((mailbox_t));
int (*_save_attributes) __P ((mailbox_t));
int (*_uidvalidity) __P ((mailbox_t, unsigned long *num));
int (*_uidnext) __P ((mailbox_t, size_t *num));
int (*_get_property) __P ((mailbox_t, property_t *num));
......
......@@ -250,6 +250,14 @@ mailbox_message_unseen (mailbox_t mbox, size_t *num)
}
int
mailbox_save_attributes (mailbox_t mbox)
{
if (mbox == NULL || mbox->_save_attributes == NULL)
return ENOSYS;
return mbox->_save_attributes (mbox);
}
int
mailbox_expunge (mailbox_t mbox)
{
if (mbox == NULL || mbox->_expunge == NULL)
......