From 2626e55c60386f4527a7a5722a4564dd9cb369fc Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 19 Apr 2016 18:15:38 -0400 Subject: [PATCH] Migrated the EINF and RINF commands to the new data format. No changes were made to the wire protocol. --- citadel/modules/bio/serv_bio.c | 3 +- citadel/modules/ctdlproto/serv_rooms.c | 49 +++++++++++++------------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/citadel/modules/bio/serv_bio.c b/citadel/modules/bio/serv_bio.c index 071df1113..2436cbfe7 100644 --- a/citadel/modules/bio/serv_bio.c +++ b/citadel/modules/bio/serv_bio.c @@ -51,6 +51,7 @@ void cmd_ebio(char *cmdbuf) { char userconfigroomname[ROOMNAMELEN]; CtdlMailboxName(userconfigroomname, sizeof userconfigroomname, &CC->user, USERCONFIGROOM); long new_msgnum = quickie_message("Citadel", NULL, NULL, userconfigroomname, ChrPtr(NewProfile), FMT_RFC822, "Profile submitted with EBIO command"); + FreeStrBuf(&NewProfile); CtdlGetUserLock(&CC->user, CC->curr_user); CC->user.msgnum_bio = new_msgnum; CtdlPutUserLock(&CC->user); @@ -58,8 +59,6 @@ void cmd_ebio(char *cmdbuf) { syslog(LOG_DEBUG, "Deleting old message %ld from %s", old_msgnum, userconfigroomname); CtdlDeleteMessages(userconfigroomname, &old_msgnum, 1, ""); } - - FreeStrBuf(&NewProfile); } diff --git a/citadel/modules/ctdlproto/serv_rooms.c b/citadel/modules/ctdlproto/serv_rooms.c index 09fb30061..e437bd794 100644 --- a/citadel/modules/ctdlproto/serv_rooms.c +++ b/citadel/modules/ctdlproto/serv_rooms.c @@ -886,14 +886,13 @@ void cmd_cre8(char *args) } - +/* + * Upload the room banner text for this room. + * This should be amended to handle content types other than plain text. + */ void cmd_einf(char *ok) { /* enter info file for current room */ - struct CitContext *CCC = CC; - FILE *fp; - char infofilename[SIZ]; char buf[SIZ]; - unbuffer_output(); if (CtdlAccessCheck(ac_room_aide)) return; @@ -902,27 +901,27 @@ void cmd_einf(char *ok) cprintf("%d Ok.\n", CIT_OK); return; } - assoc_file_name(infofilename, sizeof infofilename, &CCC->room, ctdl_info_dir); - CTDL_syslog(LOG_DEBUG, "opening %s", infofilename); - fp = fopen(infofilename, "w"); - CTDLM_syslog(LOG_DEBUG, "checking"); - if (fp == NULL) { - cprintf("%d Cannot open %s: %s\n", - ERROR + INTERNAL_ERROR, infofilename, strerror(errno)); - return; + + StrBuf *NewBanner = NewStrBufPlain("Content-type: text/plain; charset=UTF-8\nContent-transfer-encoding: 8bit\n\n", -1); + + cprintf("%d Transmit new banner in plain text now.\n", SEND_LISTING); + while(client_getln(buf, sizeof buf) >= 0 && strcmp(buf,"000")) { + StrBufAppendBufPlain(NewBanner, buf, -1, 0); + StrBufAppendBufPlain(NewBanner, HKEY("\n"), 0); } - cprintf("%d Send info...\n", SEND_LISTING); - - do { - client_getln(buf, sizeof buf); - if (strcmp(buf, "000")) - fprintf(fp, "%s\n", buf); - } while (strcmp(buf, "000")); - fclose(fp); - - /* now update the room index so people will see our new info */ - CtdlGetRoomLock(&CCC->room, CCC->room.QRname); /* lock so no one steps on us */ - CtdlPutRoomLock(&CCC->room); + + // We have read the new banner from the user , now save it + long new_msgnum = quickie_message("Citadel", NULL, NULL, SYSCONFIGROOM, ChrPtr(NewBanner), FMT_RFC822, "Banner submitted with EINF command"); + FreeStrBuf(&NewBanner); + + // Update the room record with a pointer to our new banner + CtdlGetRoomLock(&CC->room, CC->room.QRname); + long old_msgnum = CC->room.msgnum_info; + CC->room.msgnum_info = new_msgnum; + CtdlPutRoomLock(&CC->room); + + // Delete the old one + CtdlDeleteMessages(SYSCONFIGROOM, &old_msgnum, 1, ""); } -- 2.30.2