]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/ctdlproto/serv_rooms.c
Migrated the EINF and RINF commands to the new data format. No changes were made...
[citadel.git] / citadel / modules / ctdlproto / serv_rooms.c
index 9df142cd04b96579a7c74468fbca82dccc2824d7..e437bd79448345a4ff0ebc0383a33b86f1f897c6 100644 (file)
@@ -708,29 +708,20 @@ void cmd_seta(char *new_ra)
 }
 
 /* 
- * retrieve info file for this room
+ * Retrieve info file for this room (this ought to be upgraded to handle non-plain-text)
  */
-void cmd_rinf(char *gargs)
+void cmd_rinf(char *argbuf)
 {
-       char filename[PATH_MAX];
-       char buf[SIZ];
-       FILE *info_fp;
-
-       assoc_file_name(filename, sizeof filename, &CC->room, ctdl_info_dir);
-       info_fp = fopen(filename, "r");
-
-       if (info_fp == NULL) {
-               cprintf("%d No info file.\n", ERROR + FILE_NOT_FOUND);
-               return;
+       struct CtdlMessage *msg = CtdlFetchMessage(CC->room.msgnum_info, 1, 1);
+       if (msg != NULL) {
+               cprintf("%d Info:\n", LISTING_FOLLOWS);
+               CtdlOutputPreLoadedMsg(msg, MT_CITADEL, HEADERS_NONE, 0, 0, 0);
+               CM_Free(msg);
+               cprintf("000\n");
        }
-       cprintf("%d Info:\n", LISTING_FOLLOWS);
-       while (fgets(buf, sizeof buf, info_fp) != NULL) {
-               if (!IsEmptyStr(buf))
-                       buf[strlen(buf) - 1] = 0;
-               cprintf("%s\n", buf);
+       else {
+               cprintf("%d No info file.\n", ERROR + FILE_NOT_FOUND);
        }
-       cprintf("000\n");
-       fclose(info_fp);
 }
 
 
@@ -895,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;
@@ -911,28 +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 */
-       CCC->room.QRinfo = CCC->room.QRhighest + 1L;
-       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, "");
 }