From 8935a551fe93c0b63f3fc35730654a7d31b279a4 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 12 Mar 2001 01:27:42 +0000 Subject: [PATCH] * Implemented SUBSCRIBE and UNSUBSCRIBE commands --- citadel/ChangeLog | 4 +- citadel/serv_imap.c | 108 ++++++++++++++++++++++++++++++++++++++++++++ citadel/user_ops.c | 38 ++++++++++++---- citadel/user_ops.h | 2 +- 4 files changed, 140 insertions(+), 12 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 2f8b3aed2..5e60e1580 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -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 Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/serv_imap.c b/citadel/serv_imap.c index fc68ae3b2..6c316d36a 100644 --- a/citadel/serv_imap.c +++ b/citadel/serv_imap.c @@ -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]); } diff --git a/citadel/user_ops.c b/citadel/user_ops.c index b54b73f80..17e1c1d1a 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -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); + } } /* diff --git a/citadel/user_ops.h b/citadel/user_ops.h index b023eef29..f1edb51f0 100644 --- a/citadel/user_ops.h +++ b/citadel/user_ops.h @@ -75,4 +75,4 @@ enum { - +int CtdlForgetThisRoom(void); -- 2.30.2