* Implemented SUBSCRIBE and UNSUBSCRIBE commands
authorArt Cancro <ajc@citadel.org>
Mon, 12 Mar 2001 01:27:42 +0000 (01:27 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 12 Mar 2001 01:27:42 +0000 (01:27 +0000)
citadel/ChangeLog
citadel/serv_imap.c
citadel/user_ops.c
citadel/user_ops.h

index 2f8b3aed239cdec75f55f250e5e46cd9c7e8a5d5..5e60e1580bd93da5db92c10cd34a72bdee3fb2c1 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 573.115  2001/03/12 01:27:42  ajc
+ * Implemented SUBSCRIBE and UNSUBSCRIBE commands
+
  Revision 573.114  2001/03/11 23:00:29  ajc
  * Mega sexy hack to deliver express messages THROUGH IMAP!  uber coolness!!
 
@@ -2456,4 +2459,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
-
index fc68ae3b2ecc2f09e7adebd5269a06a5f3177418..6c316d36ad0d4db4465087e3fbef353bc6331319 100644 (file)
@@ -675,6 +675,92 @@ void imap_status(int num_parms, char *parms[]) {
 
 
 
+/*
+ * Implements the SUBSCRIBE command
+ *
+ */
+void imap_subscribe(int num_parms, char *parms[]) {
+       int ret;
+       char roomname[ROOMNAMELEN];
+       char savedroom[ROOMNAMELEN];
+       int msgs, new;
+
+       ret = imap_grabroom(roomname, parms[2]);
+       if (ret != 0) {
+               cprintf("%s NO Invalid mailbox name or location, or access denied\r\n",
+                       parms[0]);
+               return;
+       }
+
+       /*
+        * usergoto() formally takes us to the desired room, which has the side
+        * effect of marking the room as not-zapped ... exactly the effect
+        * we're looking for.
+        */
+       if (IMAP->selected) {
+               strcpy(savedroom, CC->quickroom.QRname);
+       }
+       usergoto(roomname, 0, &msgs, &new);
+
+       /*
+        * If another folder is selected, go back to that room so we can resume
+        * our happy day without violent explosions.
+        */
+       if (IMAP->selected) {
+               usergoto(savedroom, 0, &msgs, &new);
+       }
+
+       cprintf("%s OK SUBSCRIBE completed\r\n", parms[0]);
+}
+
+
+/*
+ * Implements the UNSUBSCRIBE command
+ *
+ */
+void imap_unsubscribe(int num_parms, char *parms[]) {
+       int ret;
+       char roomname[ROOMNAMELEN];
+       char savedroom[ROOMNAMELEN];
+       int msgs, new;
+
+       ret = imap_grabroom(roomname, parms[2]);
+       if (ret != 0) {
+               cprintf("%s NO Invalid mailbox name or location, or access denied\r\n",
+                       parms[0]);
+               return;
+       }
+
+       /*
+        * usergoto() formally takes us to the desired room.
+        */
+       if (IMAP->selected) {
+               strcpy(savedroom, CC->quickroom.QRname);
+       }
+       usergoto(roomname, 0, &msgs, &new);
+
+       /* 
+        * Now make the API call to zap the room
+        */
+       if (CtdlForgetThisRoom() == 0) {
+               cprintf("%s OK UNSUBSCRIBE completed\r\n", parms[0]);
+       }
+       else {
+               cprintf("%s NO You may not unsubscribe from this folder.\r\n",
+                       parms[0]);
+       }
+
+       /*
+        * If another folder is selected, go back to that room so we can resume
+        * our happy day without violent explosions.
+        */
+       if (IMAP->selected) {
+               usergoto(savedroom, 0, &msgs, &new);
+       }
+}
+
+
+
 /*
  * Implements the DELETE command
  *
@@ -724,6 +810,16 @@ void imap_delete(int num_parms, char *parms[]) {
 
 
 
+/*
+ * Implements the RENAME command
+ *
+ */
+void imap_rename(int num_parms, char *parms[]) {
+       cprintf("%s NO The RENAME command is not yet implemented (FIXME)\r\n",
+               parms[0]);
+}
+
+
 
 /* 
  * Main command loop for IMAP sessions.
@@ -841,10 +937,22 @@ void imap_command_loop(void) {
                imap_delete(num_parms, parms);
        }
 
+       else if (!strcasecmp(parms[1], "RENAME")) {
+               imap_rename(num_parms, parms);
+       }
+
        else if (!strcasecmp(parms[1], "STATUS")) {
                imap_status(num_parms, parms);
        }
 
+       else if (!strcasecmp(parms[1], "SUBSCRIBE")) {
+               imap_subscribe(num_parms, parms);
+       }
+
+       else if (!strcasecmp(parms[1], "UNSUBSCRIBE")) {
+               imap_unsubscribe(num_parms, parms);
+       }
+
        else if (IMAP->selected == 0) {
                cprintf("%s BAD no folder selected\r\n", parms[0]);
        }
index b54b73f8087688601e7cbbe9f839528699b1ac1a..17e1c1d1acbad117550f9f1caa777527454cd458 100644 (file)
@@ -903,19 +903,15 @@ void cmd_invt_kick(char *iuser, int op)
 
 
 /*
- * forget (Zap) the current room
+ * Forget (Zap) the current room (API call)
+ * Returns 0 on success
  */
-void cmd_forg(void)
-{
+int CtdlForgetThisRoom(void) {
        struct visit vbuf;
 
-       if (CtdlAccessCheck(ac_logged_in)) {
-               return;
-       }
-
+       /* On some systems, Aides are not allowed to forget rooms */
        if (is_aide() && (config.c_aide_zap == 0)) {
-               cprintf("%d Aides cannot forget rooms.\n", ERROR);
-               return;
+               return(1);
        }
 
        lgetuser(&CC->usersupp, CC->curr_user);
@@ -926,8 +922,30 @@ void cmd_forg(void)
 
        CtdlSetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
        lputuser(&CC->usersupp);
-       cprintf("%d Ok\n", OK);
+
+       /* Return to the Lobby, so we don't end up in an undefined room */
        usergoto(BASEROOM, 0, NULL, NULL);
+       return(0);
+
+}
+
+
+/*
+ * forget (Zap) the current room
+ */
+void cmd_forg(void)
+{
+
+       if (CtdlAccessCheck(ac_logged_in)) {
+               return;
+       }
+
+       if (CtdlForgetThisRoom() == 0) {
+               cprintf("%d Ok\n", OK);
+       }
+       else {
+               cprintf("%d You may not forget this room.\n", ERROR);
+       }
 }
 
 /*
index b023eef299209f8d567f4bce48ab0f672ff05b34..f1edb51f09b4aa4afe7eb59a4225319f8a5fe0b9 100644 (file)
@@ -75,4 +75,4 @@ enum {
 
 
 
-
+int CtdlForgetThisRoom(void);