Omit the 'Idle' and 'From host' columns from
authorArt Cancro <ajc@citadel.org>
Thu, 10 May 2007 03:59:58 +0000 (03:59 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 10 May 2007 03:59:58 +0000 (03:59 +0000)
the wholist when displaying on narrow screens (fewer than
50 columns).  This may look better on certain mobile devices.

citadel/citadel.c
citadel/imap_list.c

index 37b65790bb2a14e0d0a819aad60161e743003dc7..92bf86b54292491432d867832b4cdc06f742c303 100644 (file)
@@ -1212,9 +1212,11 @@ void who_is_online(CtdlIPC *ipc, int longlist)
 
        if (!longlist) {
                color(BRIGHT_WHITE);
-               pprintf("           User Name               Room           Idle        From host\n");
+               pprintf("           User Name               Room          ");
+               if (screenwidth >= 50) pprintf(" Idle        From host\n");
                color(DIM_WHITE);
-               pprintf("   ------------------------- -------------------- ---- ------------------------\n");
+               pprintf("   ------------------------- --------------------");
+               if (screenwidth >= 50) pprintf(" ---- ------------------------\n");
        }
        r = CtdlIPCOnlineUsers(ipc, &listing, &timenow, buf);
        listing = SortOnlineUsers(listing);
@@ -1238,14 +1240,9 @@ void who_is_online(CtdlIPC *ipc, int longlist)
                        idlesecs = (idletime - (idlehours * 3600) - (idlemins * 60));
 
                        if (idletime > rc_idle_threshold) {
-                               /*
-                               while (strlen(roomname) < 20) {
-                                       strcat(roomname, " ");
-                               }
-                               strcpy(&roomname[14], "[idle]");
-                               */
-                               if (skipidle)
+                               if (skipidle) {
                                        isidle = 1;
+                               }
                        }
 
                        if (longlist) {
@@ -1274,47 +1271,52 @@ void who_is_online(CtdlIPC *ipc, int longlist)
                                pprintf("\n");
 
                        } else {
-                   if (isidle == 0) {
-                               if (extract_int(buf, 0) == last_session) {
-                                       pprintf("        ");
-                               } else {
+                               if (isidle == 0) {
+                                       if (extract_int(buf, 0) == last_session) {
+                                               pprintf("        ");
+                                       }
+                                       else {
+                                               color(BRIGHT_MAGENTA);
+                                               pprintf("%-3s", flags);
+                                       }
+                                       last_session = extract_int(buf, 0);
+                                       color(BRIGHT_CYAN);
+                                       pprintf("%-25s ", username);
                                        color(BRIGHT_MAGENTA);
-                                       pprintf("%-3s", flags);
-                               }
-                               last_session = extract_int(buf, 0);
-                               color(BRIGHT_CYAN);
-                               pprintf("%-25s ", username);
-                               color(BRIGHT_MAGENTA);
-                               roomname[20] = 0;
-                               pprintf("%-20s ", roomname);
-                               if (idletime > rc_idle_threshold) {
-                                       /* over 1000d, must be gone fishing */
-                                       if (idlehours > 23999) {
-                                               pprintf("fish");
-                                       /* over 10 days */
-                                       } else if (idlehours > 239) {
-                                               pprintf("%3ldd",
-                                                       idlehours / 24);
-                                       /* over 10 hours */
-                                       } else if (idlehours > 9) {
-                                               pprintf("%1ldd%02ld",
-                                                       idlehours / 24,
-                                                       idlehours % 24);
-                                       /* less than 10 hours */
-                                       } else {
-                                               pprintf("%1ld:%02ld",
-                                                       idlehours, idlemins);
+                                       roomname[20] = 0;
+                                       pprintf("%-20s", roomname);
+
+                                       if (screenwidth >= 50) {
+                                               pprintf(" ");
+                                               if (idletime > rc_idle_threshold) {
+                                                       /* over 1000d, must be gone fishing */
+                                                       if (idlehours > 23999) {
+                                                               pprintf("fish");
+                                                       /* over 10 days */
+                                                       } else if (idlehours > 239) {
+                                                               pprintf("%3ldd", idlehours / 24);
+                                                       /* over 10 hours */
+                                                       } else if (idlehours > 9) {
+                                                               pprintf("%1ldd%02ld",
+                                                                       idlehours / 24,
+                                                                       idlehours % 24);
+                                                       /* less than 10 hours */
+                                                       }
+                                                       else {
+                                                               pprintf("%1ld:%02ld", idlehours, idlemins);
+                                                       }
+                                               }
+                                               else {
+                                                       pprintf("    ");
+                                               }
+                                               pprintf(" ");
+                                               color(BRIGHT_CYAN);
+                                               fromhost[24] = '\0';
+                                               pprintf("%-24s", fromhost);
                                        }
-                               }
-                               else {
-                                       pprintf("    ");
-                               }
-                               pprintf(" ");
-                               color(BRIGHT_CYAN);
-                               fromhost[24] = '\0';
-                               pprintf("%-24s\n", fromhost);
-                               color(DIM_WHITE);
-                       }
+                                       pprintf("\n");
+                                       color(DIM_WHITE);
+                               }
                        }
                }
        }
index 648ff5c8ad40e21693aedcb9347e7b5d345f62de..118843301d8af19edf89109fadf95859bb08d80c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id:$
+ * $Id$
  *
  * Implements the LIST and LSUB commands.
  *
@@ -79,7 +79,7 @@ void imap_list_floors(char *verb, int num_patterns, char **patterns)
                                }
                        }
                        if (match) {
-                               cprintf("* %s (\\NoSelect) \"/\" ", verb);
+                               cprintf("* %s (\\NoSelect \\HasChildren) \"/\" ", verb);
                                imap_strout(fl->f_name);
                                cprintf("\r\n");
                        }
@@ -109,6 +109,7 @@ void imap_listroom(struct ctdlroom *qrbuf, void *data)
        int num_patterns;
        char **patterns;
        int return_subscribed;
+       int return_children;
        int i = 0;
        int match = 0;
 
@@ -119,6 +120,7 @@ void imap_listroom(struct ctdlroom *qrbuf, void *data)
        num_patterns = (int) data_for_callback[2];
        patterns = (char **) data_for_callback[3];
        return_subscribed = (int) data_for_callback[4];
+       return_children = (int) data_for_callback[5];
 
        /* Only list rooms to which the user has access!! */
        yes_output_this_room = 0;
@@ -131,6 +133,19 @@ void imap_listroom(struct ctdlroom *qrbuf, void *data)
                }
        }
 
+       /* Warning: ugly hack.
+        * We don't have any way to determine the presence of child mailboxes
+        * without refactoring this entire module.  So we're just going to return
+        * the \HasChildren attribute for every room.
+        * We'll fix this later when we have time.
+        */
+       if (return_children) {
+               if (strlen(return_options) > 0) {
+                       strcat(return_options, " ");
+               }
+               strcat(return_options, "\\HasChildren");
+       }
+
        if (subscribed_rooms_only) {
                if (ra & UA_KNOWN) {
                        yes_output_this_room = 1;
@@ -168,7 +183,7 @@ void imap_list(int num_parms, char *parms[])
        int subscribed_rooms_only = 0;
        char verb[16];
        int i, j, paren_nest;
-       char *data_for_callback[5];
+       char *data_for_callback[6];
        int num_patterns = 1;
        char *patterns[MAX_PATTERNS];
        int selection_left = (-1);
@@ -180,6 +195,7 @@ void imap_list(int num_parms, char *parms[])
        int patterns_right = 3;
        int extended_list_in_use = 0;
        int return_subscribed = 0;
+       int return_children = 0;
 
        if (num_parms < 4) {
                cprintf("%s BAD arguments invalid\r\n", parms[0]);
@@ -202,13 +218,19 @@ void imap_list(int num_parms, char *parms[])
        /*
         * In order to implement draft-ietf-imapext-list-extensions-18
         * ("LIST Command Extensions") we need to:
-        * 1. Extract "selection options" (DONE, but we don't do anything with it yet.  We
-        *                                 need to implement SUBSCRIBED, and RECURSIVEMATCH,
-        *                                 and silently ignore REMOTE)
-        * 2. Extract "return options" (DONE, but so far we only implement the SUBSCRIBED
-        *                              option; we also need to implement the CHILDREN
-        *                              return option.)
-        * 3. Determine whether there is more than one match pattern (DONE)
+        *
+        * 1. Extract "selection options"
+        *                              (Extraction: done
+        *                              SUBSCRIBED option: done
+        *                              RECURSIVEMATCH option: not done yet
+        *                              REMOTE: safe to silently ignore)
+        *
+        * 2. Extract "return options"
+        *                              (Extraction: done
+        *                              SUBSCRIBED option: done
+        *                              CHILDREN option: done, but needs a non-ugly rewrite)
+        *
+        * 3. Determine whether there is more than one match pattern (done)
         */
 
        /*
@@ -233,6 +255,32 @@ void imap_list(int num_parms, char *parms[])
                }
        }
 
+       /* If selection options were found, do something with them.
+        */
+       if ((selection_left > 0) && (selection_right >= selection_left)) {
+
+               /* Strip off the outer parentheses */
+               if (parms[selection_left][0] == '(') {
+                       strcpy(parms[selection_left], &parms[selection_left][1]);
+               }
+               if (parms[selection_right][strlen(parms[selection_right])-1] == ')') {
+                       parms[selection_right][strlen(parms[selection_right])-1] = 0;
+               }
+
+               for (i=selection_left; i<=selection_right; ++i) {
+
+                       if (!strcasecmp(parms[i], "SUBSCRIBED")) {
+                               subscribed_rooms_only = 1;
+                       }
+
+                       if (!strcasecmp(parms[i], "RECURSIVEMATCH")) {
+                               /* FIXME - do this! */
+                       }
+
+               }
+
+       }
+
        /* The folder root appears immediately after the selection options,
         * or in position 2 if no selection options were specified.
         */
@@ -292,6 +340,9 @@ void imap_list(int num_parms, char *parms[])
                        if (!strcasecmp(parms[i], "SUBSCRIBED")) {
                                return_subscribed = 1;
                        }
+                       if (!strcasecmp(parms[i], "CHILDREN")) {
+                               return_children = 1;
+                       }
 
                        if (paren_nest == 0) {
                                return_right = i;       /* found end of patterns */
@@ -307,6 +358,7 @@ void imap_list(int num_parms, char *parms[])
        data_for_callback[2] = (char *) num_patterns;
        data_for_callback[3] = (char *) patterns;
        data_for_callback[4] = (char *) return_subscribed;
+       data_for_callback[5] = (char *) return_children;
 
        /* The non-extended LIST command is required to treat an empty
         * ("" string) mailbox name argument as a special request to return the