* Added new view type VIEW_JOURNAL - not yet used by
authorArt Cancro <ajc@citadel.org>
Thu, 12 Jul 2007 18:26:54 +0000 (18:26 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 12 Jul 2007 18:26:54 +0000 (18:26 +0000)
  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
citadel/imap_metadata.c
webcit/roomops.c
webcit/webcit.h

index 92c24fc6c8132ae66fb736226a4a1e02f3382cf5..570b7879b023bf91d271e4f3997538e7a18362d7 100644 (file)
@@ -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
 }
index c9927aa26f0e5ba047bf508e60da00ea1b3c8f49..6123bf6169d42cd251d8aa9089424244b3e8365c 100644 (file)
 
 
 /*
- * 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;
 }
 
-
index 15243a0c88a152d800bdbd202623c321ec93e5eb..636334e69298927d0ffa1f13e6c645796bfe2f95 100644 (file)
@@ -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 */
        }
 }
index 85f5d8e50c60e56bba1856c9cf379ec85aa9d6f8..b1d7e2f2c60afecaa4c6c2aa8442be8cb704bc2b 100644 (file)
@@ -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  ""