From bbd1b98b4ae41bf16d3ac9635f4267689ff40818 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 6 Feb 2001 02:09:41 +0000 Subject: [PATCH] * citadel.rc: changed the default for local_screen_dimensions to 1, since Internet users now outnumber dialup users 100 to 0. * room_ops.c: added a really_create option to create_room(). Also moved the generation of personal namespace into that function. MODULE OWNERS PLEASE CHECK YOUR CALLS TO AVOID MULTIPLE NAMESPACING!! * room_ops.c: fixed a bug in cgetfloor() that left bad pointers around * serv_imap.c: finished the CREATE command (finally) --- citadel/ChangeLog | 10 ++++++++ citadel/citadel.rc | 4 +-- citadel/citserver.c | 8 +++--- citadel/control.c | 2 +- citadel/imap_tools.c | 6 ++++- citadel/msgbase.c | 2 +- citadel/room_ops.c | 45 ++++++++++++++++++++++------------ citadel/room_ops.h | 3 ++- citadel/serv_chat.c | 6 ++--- citadel/serv_expire.c | 2 +- citadel/serv_ical.c | 2 +- citadel/serv_imap.c | 5 +++- citadel/serv_smtp.c | 2 +- citadel/serv_vcard.c | 2 +- citadel/techdoc/citadelapi.txt | 7 +++++- citadel/user_ops.c | 2 +- 16 files changed, 73 insertions(+), 35 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 5c3d526cd..1469ac352 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,13 @@ $Log$ + Revision 573.84 2001/02/06 02:09:38 ajc + * citadel.rc: changed the default for local_screen_dimensions to 1, since + Internet users now outnumber dialup users 100 to 0. + * room_ops.c: added a really_create option to create_room(). Also moved the + generation of personal namespace into that function. MODULE OWNERS PLEASE + CHECK YOUR CALLS TO AVOID MULTIPLE NAMESPACING!! + * room_ops.c: fixed a bug in cgetfloor() that left bad pointers around + * serv_imap.c: finished the CREATE command (finally) + Revision 573.83 2001/02/05 05:20:22 ajc * Made some changes to functions which translate between Citadel room names and IMAP folder names. They're still buggy. @@ -2375,3 +2384,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/citadel.rc b/citadel/citadel.rc index 786a2a36c..f982a180e 100644 --- a/citadel/citadel.rc +++ b/citadel/citadel.rc @@ -13,7 +13,7 @@ # messages. If you want the external editor to be used by default, be sure # to reflect this in the command set below. # -editor=vi +editor=pico # If you define PRINTCMD, it will be a pipe through which messages are # printed when the user hits the

rint key after a message. @@ -31,7 +31,7 @@ editor=vi # work for dialup connections. Generally you should set this to 1 for a # private copy of the client or 0 for a shared copy of the client. # -local_screen_dimensions=0 +local_screen_dimensions=1 # ANSI_COLOR should be set to on/off/auto/user to control the use of # color on the screen. If it is set to "auto" then an autodetect will be diff --git a/citadel/citserver.c b/citadel/citserver.c index 08f4c4f8c..d63c092cf 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -65,10 +65,10 @@ void master_startup(void) { check_ref_counts(); lprintf(7, "Creating base rooms (if necessary)\n"); - create_room(BASEROOM, 0, "", 0); - create_room(AIDEROOM, 3, "", 0); - create_room(SYSCONFIGROOM, 3, "", 0); - create_room(config.c_twitroom, 0, "", 0); + create_room(BASEROOM, 0, "", 0, 1); + create_room(AIDEROOM, 3, "", 0, 1); + create_room(SYSCONFIGROOM, 3, "", 0, 1); + create_room(config.c_twitroom, 0, "", 0, 1); lprintf(7, "Seeding the pseudo-random number generator...\n"); gettimeofday(&tv, NULL); diff --git a/citadel/control.c b/citadel/control.c index 7666c53ab..dd056611b 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -275,7 +275,7 @@ void cmd_conf(char *argbuf) { aide_message(buf); if (strlen(config.c_logpages) > 0) - create_room(config.c_logpages, 3, "", 0); + create_room(config.c_logpages, 3, "", 0, 1); } else if (!strcasecmp(cmd, "GETSYS")) { diff --git a/citadel/imap_tools.c b/citadel/imap_tools.c index 043f67648..8d887b685 100644 --- a/citadel/imap_tools.c +++ b/citadel/imap_tools.c @@ -109,7 +109,8 @@ void imap_mailboxname(char *buf, int bufsize, struct quickroom *qrbuf) { */ else { fl = cgetfloor(qrbuf->QRfloor); - lprintf(9, "floor %d: %s\n", qrbuf->QRfloor, fl->f_name); /* FIXME take out */ + lprintf(9, "Floor %d: \n", qrbuf->QRfloor); + lprintf(9, " %s\n", fl->f_name); /* FIXME take out */ snprintf(buf, bufsize, "%s|%s", fl->f_name, qrbuf->QRname); @@ -161,8 +162,11 @@ int imap_roomname(char *rbuf, int bufsize, char *foldername) { } } + /* since we don't allow multi-level yet, fail. extract(rbuf, buf, 1); return(0); + */ + return(-1); } safestrncpy(rbuf, foldername, bufsize); diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 4de51bae3..5addba640 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -2562,7 +2562,7 @@ void CtdlWriteObject(char *req_room, /* Room to stuff it in */ if (getroom(&qrbuf, roomname) != 0) { create_room(roomname, ( (is_mailbox != NULL) ? 4 : 3 ), - "", 0); + "", 0, 1); } /* If the caller specified this object as unique, delete all * other objects of this type that are currently in the room. diff --git a/citadel/room_ops.c b/citadel/room_ops.c index 8825e3508..f3598b4e9 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -289,7 +289,7 @@ struct floor *cgetfloor(int floor_num) { static int initialized = 0; int i; - if (!initialized) { + if (initialized == 0) { for (i=0; i 0) qrbuf.QRflags = (qrbuf.QRflags | QR_PRIVATE); if (new_room_type == 1) @@ -1254,6 +1255,16 @@ unsigned create_room(char *new_room_name, if (new_room_type == 4) qrbuf.QRflags = (qrbuf.QRflags | QR_MAILBOX); + /* If the user is requesting a personal room, set up the room + * name accordingly (prepend the user number) + */ + if (new_room_type == 4) { + MailboxName(qrbuf.QRname, &CC->usersupp, new_room_name); + } + else { + safestrncpy(qrbuf.QRname, new_room_name, sizeof qrbuf.QRname); + } + /* If the room is private, and the system administrator has elected * to automatically grant room aide privileges, do so now; otherwise, * set the room aide to undefined. @@ -1264,6 +1275,14 @@ unsigned create_room(char *new_room_name, qrbuf.QRroomaide = (-1L); } + /* + * If the caller is only interested in testing whether this will work, + * return now without creating the room. + */ + if (!really_create) return (qrbuf.QRflags); + + cdb_begin_transaction(); + qrbuf.QRnumber = get_new_room_number(); qrbuf.QRhighest = 0L; /* No messages in this room yet */ time(&qrbuf.QRgen); /* Use a timestamp as the generation number */ qrbuf.QRfloor = new_room_floor; @@ -1285,6 +1304,7 @@ unsigned create_room(char *new_room_name, lputuser(&CC->usersupp); /* resume our happy day */ + cdb_end_transaction(); return (qrbuf.QRflags); } @@ -1352,17 +1372,10 @@ void cmd_cre8(char *args) return; } - /* If the user is requesting a personal room, set up the room - * name accordingly (prepend the user number) - */ - if (new_room_type == 4) { - sprintf(aaa, "%010ld.%s", - CC->usersupp.usernum, new_room_name); - strcpy(new_room_name, aaa); - } - /* Check to make sure the requested room name doesn't already exist */ - if (getroom(&qrbuf, new_room_name) == 0) { + newflags = create_room(new_room_name, + new_room_type, new_room_pass, new_room_floor, 0); + if (newflags == 0) { cprintf("%d '%s' already exists.\n", ERROR + ALREADY_EXISTS, qrbuf.QRname); return; @@ -1373,8 +1386,10 @@ void cmd_cre8(char *args) return; } + /* If we reach this point, the room needs to be created. */ + newflags = create_room(new_room_name, - new_room_type, new_room_pass, new_room_floor); + new_room_type, new_room_pass, new_room_floor, 1); /* post a message in Aide> describing the new room */ safestrncpy(aaa, new_room_name, sizeof aaa); diff --git a/citadel/room_ops.h b/citadel/room_ops.h index 06a951b2f..a3aca8918 100644 --- a/citadel/room_ops.h +++ b/citadel/room_ops.h @@ -35,7 +35,8 @@ void cmd_kill (char *argbuf); unsigned create_room(char *new_room_name, int new_room_type, char *new_room_pass, - int new_room_floor); + int new_room_floor, + int really_create); void cmd_cre8 (char *args); void cmd_einf (char *ok); void cmd_lflr (void); diff --git a/citadel/serv_chat.c b/citadel/serv_chat.c index edff3d93a..1de7699af 100644 --- a/citadel/serv_chat.c +++ b/citadel/serv_chat.c @@ -571,14 +571,14 @@ int send_express_message(char *lun, char *x_user, char *x_msg) logmsg->cm_fields['M'] = strdoop(x_msg); MailboxName(roomname, &CC->usersupp, PAGELOGROOM); - create_room(roomname, 4, "", 0); + create_room(roomname, 4, "", 0, 1); msgnum = CtdlSaveMsg(logmsg, "", roomname, MES_LOCAL); if (strlen(config.c_logpages) > 0) { - create_room(config.c_logpages, 3, "", 0); + create_room(config.c_logpages, 3, "", 0, 1); CtdlSaveMsgPointerInRoom(config.c_logpages, msgnum, 0); } while (sl != NULL) { - create_room(sl->roomname, 4, "", 0); + create_room(sl->roomname, 4, "", 0, 1); CtdlSaveMsgPointerInRoom(sl->roomname, msgnum, 0); sptr = sl->next; phree(sl); diff --git a/citadel/serv_expire.c b/citadel/serv_expire.c index 7ebb33e65..682c0c1a3 100644 --- a/citadel/serv_expire.c +++ b/citadel/serv_expire.c @@ -319,7 +319,7 @@ void do_user_purge(struct usersupp *us, void *data) { struct quickroom qrbuf; char mailboxname[ROOMNAMELEN]; MailboxName(mailboxname, us, MAILROOM); - create_room(mailboxname, 4, "", 0); + create_room(mailboxname, 4, "", 0, 1); if (getroom(&qrbuf, mailboxname) != 0) return; lprintf(9, "Got %s\n", qrbuf.QRname); */ diff --git a/citadel/serv_ical.c b/citadel/serv_ical.c index 8d4d5d58f..d854702ce 100644 --- a/citadel/serv_ical.c +++ b/citadel/serv_ical.c @@ -50,7 +50,7 @@ void ical_create_room(void) /* Create the room if it doesn't already exist */ MailboxName(roomname, &CC->usersupp, USERCALENDARROOM); - create_room(roomname, 4, "", 0); + create_room(roomname, 4, "", 0, 1); /* Set expiration policy to manual; otherwise objects will be lost! */ if (lgetroom(&qr, roomname)) { lprintf(3, "Couldn't get the user calendar room!\n"); diff --git a/citadel/serv_imap.c b/citadel/serv_imap.c index 0e776b63a..ff344aa96 100644 --- a/citadel/serv_imap.c +++ b/citadel/serv_imap.c @@ -414,7 +414,10 @@ void imap_create(int num_parms, char *parms[]) { newroomtype = 0; /* public folder */ } - ret = create_room(roomname, newroomtype, "", floornum); + lprintf(7, "Create new room <%s> on floor <%d> with type <%d>\n", + roomname, floornum, newroomtype); + + ret = create_room(roomname, newroomtype, "", floornum, 1); if (ret == 0) { cprintf("%s NO Mailbox already exists, or create failed\r\n", parms[0]); diff --git a/citadel/serv_smtp.c b/citadel/serv_smtp.c index 927d8206d..1e54b7f07 100644 --- a/citadel/serv_smtp.c +++ b/citadel/serv_smtp.c @@ -1475,7 +1475,7 @@ char *Dynamic_Module_Init(void) smtp_greeting, smtp_command_loop); - create_room(SMTP_SPOOLOUT_ROOM, 3, "", 0); + create_room(SMTP_SPOOLOUT_ROOM, 3, "", 0, 1); CtdlRegisterSessionHook(smtp_do_queue, EVT_TIMER); return "$Id$"; } diff --git a/citadel/serv_vcard.c b/citadel/serv_vcard.c index be8d89c84..07d93c6f7 100644 --- a/citadel/serv_vcard.c +++ b/citadel/serv_vcard.c @@ -470,7 +470,7 @@ char *Dynamic_Module_Init(void) CtdlRegisterProtoHook(cmd_regi, "REGI", "Enter registration info"); CtdlRegisterProtoHook(cmd_greg, "GREG", "Get registration info"); CtdlRegisterUserHook(vcard_purge, EVT_PURGEUSER); - create_room(ADDRESS_BOOK_ROOM, 3, "", 0); + create_room(ADDRESS_BOOK_ROOM, 3, "", 0, 1); return "$Id$"; } diff --git a/citadel/techdoc/citadelapi.txt b/citadel/techdoc/citadelapi.txt index db5744814..2a810bff1 100644 --- a/citadel/techdoc/citadelapi.txt +++ b/citadel/techdoc/citadelapi.txt @@ -178,7 +178,8 @@ contain: unsigned create_room(char *new_room_name, int new_room_type, char *new_room_pass, - int new_room_floor) + int new_room_floor, + int really_create) This function is used to create a new room. new_room_name should be set to the desired name for the new room. new_room_type should be set to 0 for a @@ -188,6 +189,10 @@ a type 2 (passworded) room, new_room_pass should be set to the desired password. new_room_floor should be set to the number of the floor upon which the new room should reside. + If the room is really to be created, set really_create to 1. Otherwise, the +caller may merely check to see if it's possible to create the room without +actually creating it by setting really_create to 0. + create_room() returns the flags associated with the new room (as in the data structure item quickroom.QRflags). If the room cannot be created (for example, a room with the name already exists), it returns 0. diff --git a/citadel/user_ops.c b/citadel/user_ops.c index cf39c2403..7d86b2c05 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -675,7 +675,7 @@ int create_user(char *newusername) } /* give the user a private mailbox */ MailboxName(mailboxname, &CC->usersupp, MAILROOM); - create_room(mailboxname, 4, "", 0); + create_room(mailboxname, 4, "", 0, 1); rec_log(CL_NEWUSER, CC->curr_user); return (0); -- 2.39.2