$Log$
+ Revision 591.108 2002/09/03 04:42:15 ajc
+ * Added MSG4 support to client-side IPC
+ * Moved HTML-to-text conversion to the client side
+
Revision 591.107 2002/09/02 20:40:34 ajc
* Automation work for setup
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
citadel$(EXEEXT): ipc_c_tcp.o citadel.o rooms.o routines.o \
routines2.o messages.o screen.o citadel_ipc.o \
- client_passwords.o md5.o client_crypto.o \
+ client_passwords.o md5.o client_crypto.o html.o \
commands.o client_chat.o tools.o $(LIBOBJS)
$(CC) ipc_c_tcp.o citadel.o rooms.o routines.o \
routines2.o messages.o screen.o citadel_ipc.o \
- commands.o client_chat.o tools.o \
+ commands.o client_chat.o tools.o html.o \
client_passwords.o md5.o client_crypto.o \
$(LIBOBJS) $(LDFLAGS) -o citadel $(LIBS)
char floorlist[128][SIZ]; /* names of floors */
int termn8 = 0; /* Set to nonzero to cause a logoff */
int secure; /* Set to nonzero when wire is encrypted */
+int can_do_msg4 = 0; /* Set to nonzero if the server can handle MSG4 commands */
extern char express_msgs; /* express messages waiting! */
extern int rc_ansi_color; /* ansi color value from citadel.rc */
(server_is_local ? "local" : CITADEL),
(supplied_hostname) ? supplied_hostname : "", buf);
/* (locate_host(buf), buf)); */
+
+ /* Tell the server what our preferred content formats are */
+ if ((CtdlIPCSpecifyPreferredFormats(buf, "text/html|text/plain") / 100 )== 2) {
+ can_do_msg4 = 1;
+ }
}
char buf[SIZ], username[SIZ], roomname[SIZ], fromhost[SIZ];
char flags[SIZ];
char actual_user[SIZ], actual_room[SIZ], actual_host[SIZ];
- char tbuf[SIZ], clientsoft[SIZ];
+ char clientsoft[SIZ];
time_t timenow = 0;
time_t idletime, idlehours, idlemins, idlesecs;
int last_session = (-1);
void sighandler(int which_sig);
void do_system_configuration(void);
extern int secure;
+extern int can_do_msg4;
#endif
#include "citadel.h"
#include "citadel_ipc.h"
+#include "citadel_decls.h"
#include "client_crypto.h"
#include "tools.h"
if (!*mret) return -1;
if (!msgnum) return -1;
- sprintf(aaa, "MSG%c %ld|%d", as_mime ? '2' : '0', msgnum, headers);
+ strcpy(mret[0]->content_type, "");
+ sprintf(aaa, "MSG%d %ld|%d", as_mime, msgnum, headers);
ret = CtdlIPCGenericCommand(aaa, NULL, 0, &bbb, &bbbsize, cret);
if (ret / 100 == 1) {
- if (!as_mime) {
+ if (as_mime != 2) {
strcpy(mret[0]->mime_chosen, "1"); /* Default chosen-part is "1" */
while (strlen(bbb) > 4 && bbb[4] == '=') {
extract_token(aaa, bbb, 0, '\n');
}
/* Eliminate "text\n" */
remove_token(bbb, 0, '\n');
+
+ /* If doing a MIME thing, pull out the extra headers */
+ if (as_mime == 4) {
+ do {
+ if (!strncasecmp(bbb, "Content-type: ", 14)) {
+ extract_token(mret[0]->content_type, bbb, 0, '\n');
+ strcpy(mret[0]->content_type,
+ &mret[0]->content_type[14]);
+ striplt(mret[0]->content_type);
+ }
+ remove_token(bbb, 0, '\n');
+ } while ((bbb[0] != 0) && (bbb[0] != '\n'));
+ }
+
+
}
if (strlen(bbb)) {
/* Strip trailing whitespace */
}
+/* MSGP */
+int CtdlIPCSpecifyPreferredFormats(char *cret, char *formats) {
+ register int ret;
+ char cmd[SIZ];
+
+ snprintf(cmd, sizeof cmd, "MSGP %s", formats);
+ ret = CtdlIPCGenericCommand(cmd, NULL, 0, NULL, NULL, cret);
+ return ret;
+}
+
+
+
/* READ */
int CtdlIPCReadDownload(void **buf, size_t bytes, char *cret)
{
char nhdr; /* Suppress message header? */
char anonymous; /* An anonymous message */
char mime_chosen[SIZ]; /* Chosen MIME part to output */
+ char content_type[SIZ]; /* How would you like that? */
};
int CtdlIPCSetMessageSeen(long msgnum, int seen, char *cret);
int CtdlIPCStartEncryption(char *cret);
int CtdlIPCDirectoryLookup(const char *address, char *cret);
+int CtdlIPCSpecifyPreferredFormats(char *cret, char *formats);
/* ************************************************************************** */
/* Stuff below this line is not for public consumption */
{
#ifdef HAVE_OPENSSL
int a;
- int r; /* IPC response code */
+ /* int r; */ /* IPC response code */
char buf[SIZ];
SSL_METHOD *ssl_method;
DH *dh;
error_printf("Server can't start TLS: %s\n", buf);
return 0;
}
+
/* New code
r = CtdlIPCStartEncryption(buf);
if (r / 100 != 2) {
if (inbuf[i]==9) inbuf[i]=32;
if ((inbuf[i]<32) || (inbuf[i]>126))
strcpy(&inbuf[i], &inbuf[i+1]);
+ }
+ for (i=0; i<strlen(inbuf); ++i) {
while ((inbuf[i]==32)&&(inbuf[i+1]==32))
strcpy(&inbuf[i], &inbuf[i+1]);
}
for (i = 0; i<strlen(outbuf); ++i) {
if ( (i<(screenwidth-2)) && (outbuf[i]=='\n')) {
strncat(outptr, outbuf, i+1);
- strcat(outptr, "\n");
+ /* strcat(outptr, "\n"); */
if (do_citaformat)
strcat(outptr, " ");
strcpy(outbuf, &outbuf[i+1]);
} while (done_reading == 0);
strcat(outptr, outbuf);
- strcat(outptr, "\n");
+ striplt(outptr);
+ if (outptr[strlen(outptr)-1] != '\n') strcat(outptr, "\n");
return outptr;
#include <stdarg.h>
#include "citadel.h"
+#include "citadel_decls.h"
#include "messages.h"
#include "commands.h"
#include "rooms.h"
#include "tools.h"
+#include "html.h"
#include "citadel_ipc.h"
#ifndef HAVE_SNPRINTF
#include "snprintf.h"
int nhdr = 0;
struct ctdlipcmessage *message = NULL;
int r; /* IPC response code */
+ char *converted_text = NULL;
sigcaught = 0;
sttybbs(1);
strcpy(reply_to, NO_REPLY_TO);
strcpy(reply_subject, "");
- r = CtdlIPCGetSingleMessage(num, (pagin == READ_HEADER ? 1 : 0), 0,
- &message, buf);
+ r = CtdlIPCGetSingleMessage(num, (pagin == READ_HEADER ? 1 : 0),
+ (can_do_msg4 ? 4 : 0),
+ &message, buf);
if (r / 100 != 1) {
err_printf("*** msg #%ld: %d %s\n", num, r, buf);
++lines_printed;
/******* end of header output, start of message text output *******/
+ /*
+ * Convert HTML to plain text, formatting for the actual width
+ * of the client screen.
+ */
+ if (!strcasecmp(message->content_type, "text/html")) {
+ converted_text = html_to_ascii(message->text, screenwidth, 0);
+ if (converted_text != NULL) {
+ free(message->text);
+ message->text = converted_text;
+ format_type = 1;
+ }
+ }
+
+ /*
+ * Here we go
+ */
if (format_type == 0) {
fr = fmout(screenwidth, NULL, message->text, dest,
((pagin == 1) ? 1 : 0), screenheight, (-1), 1);