From 8691cef4f631a0d09740451f5a4f725511bce8ec Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 12 Jul 2007 18:26:54 +0000 Subject: [PATCH] * Added new view type VIEW_JOURNAL - not yet used by native clients, but Outlook (via the Bynari connector) needs it. * Implemented GETMETADATA so the Connector can learn folder types without the aid of hidden synchronization messages --- citadel/citadel.h | 2 +- citadel/imap_metadata.c | 114 ++++++++++++++++++++++++++++++++++++---- webcit/roomops.c | 4 +- webcit/webcit.h | 2 +- 4 files changed, 108 insertions(+), 14 deletions(-) diff --git a/citadel/citadel.h b/citadel/citadel.h index 92c24fc6c..570b7879b 100644 --- a/citadel/citadel.h +++ b/citadel/citadel.h @@ -282,7 +282,7 @@ enum { #define VIEW_NOTES 5 /* Notes view */ #define VIEW_WIKI 6 /* Wiki view */ #define VIEW_CALBRIEF 7 /* Brief Calendar view */ -#define VIEW_SIEVE 8 /* Sieve manage rules store */ +#define VIEW_JOURNAL 8 /* Journal view (not yet implemented in native clients) */ #ifdef __cplusplus } diff --git a/citadel/imap_metadata.c b/citadel/imap_metadata.c index c9927aa26..6123bf616 100644 --- a/citadel/imap_metadata.c +++ b/citadel/imap_metadata.c @@ -57,28 +57,120 @@ /* - * Implements the GETMETADATA command. + * Implements the SETMETADATA command. * - * This is currently a stub which returns no data, because we are not yet - * using any server annotations. + * This is currently a stub which fools the client into thinking that there + * is no remaining space available to store annotations. */ -void imap_getmetadata(int num_parms, char *parms[]) { +void imap_setmetadata(int num_parms, char *parms[]) { - cprintf("%s OK GETMETADATA complete\r\n", parms[0]); + cprintf("%s NO [METADATA TOOMANY] SETMETADATA failed\r\n", parms[0]); return; } /* - * Implements the SETMETADATA command. + * Implements the GETMETADATA command. * - * This is currently a stub which fools the client into thinking that there - * is no remaining space available to store annotations. + * This is currently a stub which returns no data, because we are not yet + * using any server annotations. */ -void imap_setmetadata(int num_parms, char *parms[]) { +void imap_getmetadata(int num_parms, char *parms[]) { + char roomname[ROOMNAMELEN]; + char savedroom[ROOMNAMELEN]; + int msgs, new; + int ret; - cprintf("%s NO [METADATA TOOMANY] SETMETADATA failed\r\n", parms[0]); + if (num_parms > 5) { + cprintf("%s BAD usage error\r\n", parms[0]); + return; + } + + ret = imap_grabroom(roomname, parms[2], 0); + if (ret != 0) { + cprintf("%s NO Invalid mailbox name or access denied\r\n", + parms[0]); + return; + } + + /* + * usergoto() formally takes us to the desired room. (If another + * folder is selected, save its name so we can return there!!!!!) + */ + if (IMAP->selected) { + strcpy(savedroom, CC->room.QRname); + } + usergoto(roomname, 0, 0, &msgs, &new); + + /* + * Ignore the client's request for a specific metadata. Send them + * what we know: the Kolab-esque folder type. + */ + cprintf("* METADATA "); + imap_strout(parms[2]); + cprintf(" \"/vendor/kolab/folder-type\" (\"value.shared\" \""); + + /* If it's one of our hard-coded default rooms, we know what to do... */ + + if (!strcasecmp(&CC->room.QRname[11], MAILROOM)) { + cprintf("mail.inbox"); + } + else if (!strcasecmp(&CC->room.QRname[11], SENTITEMS)) { + cprintf("mail.sentitems"); + } + else if (!strcasecmp(&CC->room.QRname[11], USERCALENDARROOM)) { + cprintf("event.default"); + } + else if (!strcasecmp(&CC->room.QRname[11], USERCONTACTSROOM)) { + cprintf("contact.default"); + } + else if (!strcasecmp(&CC->room.QRname[11], USERNOTESROOM)) { + cprintf("note.default"); + } + else if (!strcasecmp(&CC->room.QRname[11], USERTASKSROOM)) { + cprintf("task.default"); + } + + /* Otherwise, use the view for this room to determine the type of data. + * We are going with the default view rather than the user's view, because + * the default view almost always defines the actual contents, while the + * user's view might only make changes to presentation. It also saves us + * an extra database access because we don't need to load the visit record. + */ + + else if (CC->room.QRdefaultview == VIEW_CALENDAR) { + cprintf("event"); + } + else if (CC->room.QRdefaultview == VIEW_ADDRESSBOOK) { + cprintf("contact"); + } + else if (CC->room.QRdefaultview == VIEW_TASKS) { + cprintf("task"); + } + else if (CC->room.QRdefaultview == VIEW_NOTES) { + cprintf("note"); + } + else if (CC->room.QRdefaultview == VIEW_JOURNAL) { + cprintf("journal"); + } + + /* If none of the above conditions were met, consider it an ordinary mailbox. */ + else { + cprintf("mail"); + } + + /* "mail.outbox" and "junkemail" are not implemented. */ + + cprintf("\")\r\n"); + + /* + * If a different folder was previously selected, return there now. + */ + if ( (IMAP->selected) && (strcasecmp(roomname, savedroom)) ) { + usergoto(savedroom, 0, 0, &msgs, &new); + } + + cprintf("%s OK GETMETADATA complete\r\n", parms[0]); return; } - diff --git a/webcit/roomops.c b/webcit/roomops.c index 15243a0c8..636334e69 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -10,7 +10,7 @@ char floorlist[128][SIZ]; /**< list of our floor names */ -char *viewdefs[8]; /**< the different kinds of available views */ +char *viewdefs[9]; /**< the different kinds of available views */ /** * \brief initialize the viewdefs with localized strings @@ -24,6 +24,7 @@ void initialize_viewdefs(void) { viewdefs[5] = _("Notes List"); viewdefs[6] = _("Wiki"); viewdefs[7] = _("Calendar List"); + viewdefs[8] = _("Journal"); } /** @@ -42,6 +43,7 @@ int is_view_allowed_as_default(int which_view) case VIEW_NOTES: return(1); case VIEW_WIKI: return(0); /**< because it isn't finished yet */ case VIEW_CALBRIEF: return(0); + case VIEW_JOURNAL: return(0); default: return(0); /**< should never get here */ } } diff --git a/webcit/webcit.h b/webcit/webcit.h index 85f5d8e50..b1d7e2f2c 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -765,7 +765,7 @@ void http_datestring(char *buf, size_t n, time_t xtime); #define VIEW_NOTES 5 /**< Notes view */ #define VIEW_WIKI 6 /**< Wiki view */ #define VIEW_CALBRIEF 7 /**< Brief Calendar view */ - +#define VIEW_JOURNAL 8 /**< Journal view (not yet implemented in webcit) */ /* These should be empty, but we have them for testing */ #define DEFAULT_HTTPAUTH_USER "" -- 2.39.2