+/*
+ * 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
*
+/*
+ * 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.
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]);
}
/*
- * 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);
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);
+ }
}
/*