* $Id$
*
* IMAP server for the Citadel system
- * Copyright (C) 2000-2007 by Art Cancro and others.
+ * Copyright (C) 2000-2009 by Art Cancro and others.
* This code is released under the terms of the GNU General Public License.
*
* WARNING: the IMAP protocol is badly designed. No implementation of it
* is perfect. Indeed, with so much gratuitous complexity, *all* IMAP
* implementations have bugs.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "sysdep.h"
#include "citserver.h"
#include "support.h"
#include "config.h"
-#include "room_ops.h"
#include "user_ops.h"
#include "policy.h"
#include "database.h"
* Check to see if the room's contents have changed.
* If not, we can avoid this rescan.
*/
- getroom(&CC->room, CC->room.QRname);
+ CtdlGetRoom(&CC->room, CC->room.QRname);
if (IMAP->last_mtime == CC->room.QRmtime) { /* No changes! */
return;
}
char pass[256];
int result;
+ memset(pass, 0, sizeof(pass));
CtdlDecodeBase64(decoded_authstring, cmd, strlen(cmd));
safestrncpy(ident, decoded_authstring, sizeof ident);
safestrncpy(user, &decoded_authstring[strlen(ident) + 1], sizeof user);
{
char buf[SIZ];
+ memset(buf, 0, sizeof(buf));
CtdlDecodeBase64(buf, cmd, SIZ);
if (CtdlTryPassword(buf) == pass_ok) {
cprintf("%s OK authentication succeeded\r\n", IMAP->authseq);
roomflags = (i & 0xff00);
/* First try a regular match */
- c = getroom(&QRscratch, towhere);
+ c = CtdlGetRoom(&QRscratch, towhere);
/* Then try a mailbox name match */
if (c != 0) {
MailboxName(augmented_roomname, sizeof augmented_roomname,
&CC->user, towhere);
- c = getroom(&QRscratch, augmented_roomname);
+ c = CtdlGetRoom(&QRscratch, augmented_roomname);
if (c == 0)
strcpy(towhere, augmented_roomname);
}
imap_do_expunge();
/*
- * usergoto() formally takes us to the desired room, happily returning
+ * CtdlUserGoto() formally takes us to the desired room, happily returning
* the number of messages and number of new messages.
*/
memcpy(&CC->room, &QRscratch, sizeof(struct ctdlroom));
- usergoto(NULL, 0, 0, &msgs, &new);
+ CtdlUserGoto(NULL, 0, 0, &msgs, &new);
IMAP->selected = 1;
if (!strcasecmp(parms[1], "EXAMINE")) {
/* Show all floors as shared namespaces. Neato! */
cprintf("(");
for (i = 0; i < MAXFLOORS; ++i) {
- fl = cgetfloor(i);
+ fl = CtdlGetCachedFloor(i);
if (fl->f_flags & F_INUSE) {
if (floors > 0) cprintf(" ");
cprintf("(");
int newroomview = 0;
char *notification_message = NULL;
+ if (num_parms < 3) {
+ cprintf("%s NO A foder name must be specified\r\n", parms[0]);
+ return;
+ }
+
if (strchr(parms[2], '\\') != NULL) {
- cprintf("%s NO Invalid character in folder name\r\n",
- parms[0]);
+ cprintf("%s NO Invalid character in folder name\r\n", parms[0]);
CtdlLogPrintf(CTDL_DEBUG, "invalid character in folder name\n");
return;
}
CtdlLogPrintf(CTDL_INFO, "Create new room <%s> on floor <%d> with type <%d>\n",
roomname, floornum, newroomtype);
- ret = create_room(roomname, newroomtype, "", floornum, 1, 0, newroomview);
+ ret = CtdlCreateRoom(roomname, newroomtype, "", floornum, 1, 0, newroomview);
if (ret == 0) {
/*** DO NOT CHANGE THIS ERROR MESSAGE IN ANY WAY! BYNARI CONNECTOR DEPENDS ON IT! ***/
cprintf("%s NO Mailbox already exists, or create failed\r\n", parms[0]);
((ret & QR_PRIVATE) ? " [private]" : ""),
((ret & QR_GUESSNAME) ? " [hidden]" : "")
);
- aide_message(notification_message, "Room Creation Message");
+ CtdlAideMessage(notification_message, "Room Creation Message");
free(notification_message);
}
CtdlLogPrintf(CTDL_DEBUG, "imap_create() completed\n");
}
/* First try a regular match */
- c = getroom(&QRscratch, roomname);
+ c = CtdlGetRoom(&QRscratch, roomname);
/* Then try a mailbox name match */
if (c != 0) {
MailboxName(augmented_roomname, sizeof augmented_roomname,
&CC->user, roomname);
- c = getroom(&QRscratch, augmented_roomname);
+ c = CtdlGetRoom(&QRscratch, augmented_roomname);
if (c == 0)
strcpy(roomname, augmented_roomname);
}
char savedroom[ROOMNAMELEN];
int msgs, new;
- ret = imap_grabroom(roomname, parms[2], 0);
+ ret = imap_grabroom(roomname, parms[2], 1);
if (ret != 0) {
cprintf
("%s NO Invalid mailbox name or location, or access denied\r\n",
}
/*
- * usergoto() formally takes us to the desired room, happily returning
+ * CtdlUserGoto() formally takes us to the desired room, happily returning
* the number of messages and number of new messages. (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);
+ CtdlUserGoto(roomname, 0, 0, &msgs, &new);
/*
* Tell the client what it wants to know. In fact, tell it *more* than
* our happy day without violent explosions.
*/
if (IMAP->selected) {
- usergoto(savedroom, 0, 0, &msgs, &new);
+ CtdlUserGoto(savedroom, 0, 0, &msgs, &new);
}
/*
}
/*
- * usergoto() formally takes us to the desired room, which has the side
+ * CtdlUserGoto() 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->room.QRname);
}
- usergoto(roomname, 0, 0, &msgs, &new);
+ CtdlUserGoto(roomname, 0, 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, 0, &msgs, &new);
+ CtdlUserGoto(savedroom, 0, 0, &msgs, &new);
}
cprintf("%s OK SUBSCRIBE completed\r\n", parms[0]);
char savedroom[ROOMNAMELEN];
int msgs, new;
- ret = imap_grabroom(roomname, parms[2], 0);
+ ret = imap_grabroom(roomname, parms[2], 1);
if (ret != 0) {
cprintf
("%s NO Invalid mailbox name or location, or access denied\r\n",
}
/*
- * usergoto() formally takes us to the desired room.
+ * CtdlUserGoto() formally takes us to the desired room.
*/
if (IMAP->selected) {
strcpy(savedroom, CC->room.QRname);
}
- usergoto(roomname, 0, 0, &msgs, &new);
+ CtdlUserGoto(roomname, 0, 0, &msgs, &new);
/*
* Now make the API call to zap the room
* our happy day without violent explosions.
*/
if (IMAP->selected) {
- usergoto(savedroom, 0, 0, &msgs, &new);
+ CtdlUserGoto(savedroom, 0, 0, &msgs, &new);
}
}
}
/*
- * usergoto() formally takes us to the desired room, happily returning
+ * CtdlUserGoto() formally takes us to the desired room, happily returning
* the number of messages and number of new messages. (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);
+ CtdlUserGoto(roomname, 0, 0, &msgs, &new);
/*
* Now delete the room.
*/
if (CtdlDoIHavePermissionToDeleteThisRoom(&CC->room)) {
- schedule_room_for_deletion(&CC->room);
+ CtdlScheduleRoomForDeletion(&CC->room);
cprintf("%s OK DELETE completed\r\n", parms[0]);
} else {
cprintf("%s NO Can't delete this folder.\r\n", parms[0]);
* our happy day without violent explosions.
*/
if (IMAP->selected) {
- usergoto(savedroom, 0, 0, &msgs, &new);
+ CtdlUserGoto(savedroom, 0, 0, &msgs, &new);
}
}
* (already did that) and create a new inbox.
*/
if (!strcasecmp(parms[2], "INBOX")) {
- create_room(MAILROOM, 4, "", 0, 1, 0, VIEW_MAILBOX);
+ CtdlCreateRoom(MAILROOM, 4, "", 0, 1, 0, VIEW_MAILBOX);
}
/* Otherwise, do the subfolders. Build a list of rooms to rename... */
irlparms.oldname = parms[2];
irlparms.newname = parms[3];
irlparms.irl = &irl;
- ForEachRoom(imap_rename_backend, (void *) &irlparms);
+ CtdlForEachRoom(imap_rename_backend, (void *) &irlparms);
/* ... and now rename them. */
while (irl != NULL) {
parms[3],
CC->curr_user
);
- aide_message(buf, "IMAP folder rename");
+ CtdlAideMessage(buf, "IMAP folder rename");
cprintf("%s OK RENAME completed\r\n", parms[0]);
}