X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Finstmsg%2Fserv_instmsg.c;h=b150a9167dcdbb701288d0153ec18a04dfb2e6f4;hb=c4609169aa7baf208848e72c16d33a3f892353b8;hp=d84ce6244070503ba26030954d58b9410ab7ef37;hpb=cbefcb9d9b85519fd1b098f622255ea318e78fd7;p=citadel.git diff --git a/citadel/modules/instmsg/serv_instmsg.c b/citadel/modules/instmsg/serv_instmsg.c index d84ce6244..b150a9167 100644 --- a/citadel/modules/instmsg/serv_instmsg.c +++ b/citadel/modules/instmsg/serv_instmsg.c @@ -1,7 +1,7 @@ /* * This module handles instant messaging between users. * - * Copyright (c) 1987-2012 by the citadel.org team + * Copyright (c) 1987-2015 by the citadel.org team * * This program is open source software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3. @@ -11,6 +11,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ + #include "sysdep.h" #include #include @@ -110,9 +111,6 @@ void log_instant_message(struct CitContext *me, struct CitContext *them, char *m this_im->next = imlist; imlist = this_im; StrBufAppendBufPlain(this_im->conversation, HKEY( - "Content-type: text/html\r\n" - "Content-transfer-encoding: 7bit\r\n" - "\r\n" "\r\n" ), 0); } @@ -177,7 +175,7 @@ void cmd_gexp(char *argbuf) { (long)ptr->timestamp, /* time sent */ ptr->flags, /* flags */ ptr->sender, /* sender of msg */ - config.c_nodename, /* static for now (and possibly deprecated) */ + CtdlGetConfigStr("c_nodename"), /* static for now (and possibly deprecated) */ ptr->sender_email /* email or jid of sender */ ); @@ -245,7 +243,7 @@ int send_instant_message(char *lun, char *lem, char *x_user, char *x_msg) int do_send = 0; /* 1 = send message; 0 = only check for valid recipient */ static int serial_number = 0; /* this keeps messages from getting logged twice */ - if (strlen(x_msg) > 0) { + if (!IsEmptyStr(x_msg)) { do_send = 1; } @@ -446,6 +444,7 @@ void flush_individual_conversation(struct imlog *im) { struct CtdlMessage *msg; long msgnum = 0; char roomname[ROOMNAMELEN]; + StrBuf *MsgBuf, *FullMsgBuf; StrBufAppendBufPlain(im->conversation, HKEY( "\r\n" @@ -453,22 +452,35 @@ void flush_individual_conversation(struct imlog *im) { ), 0 ); + MsgBuf = StrBufRFC2047encodeMessage(im->conversation); + FlushStrBuf(im->conversation); + FullMsgBuf = NewStrBufPlain(NULL, StrLength(im->conversation) + 100); + + StrBufAppendBufPlain(FullMsgBuf, HKEY( + "Content-type: text/html; charset=UTF-8\r\n" + "Content-Transfer-Encoding: quoted-printable\r\n" + "\r\n" + ), 0); + StrBufAppendBuf (FullMsgBuf, MsgBuf, 0); + FreeStrBuf(&MsgBuf); + msg = malloc(sizeof(struct CtdlMessage)); memset(msg, 0, sizeof(struct CtdlMessage)); msg->cm_magic = CTDLMESSAGE_MAGIC; msg->cm_anon_type = MES_NORMAL; msg->cm_format_type = FMT_RFC822; if (!IsEmptyStr(im->usernames[0])) { - msg->cm_fields['A'] = strdup(im->usernames[0]); + CM_SetField(msg, eAuthor, im->usernames[0], strlen(im->usernames[0])); } else { - msg->cm_fields['A'] = strdup("Citadel"); + CM_SetField(msg, eAuthor, HKEY("Citadel")); } if (!IsEmptyStr(im->usernames[1])) { - msg->cm_fields['R'] = strdup(im->usernames[1]); + CM_SetField(msg, eRecipient, im->usernames[1], strlen(im->usernames[1])); } - msg->cm_fields['O'] = strdup(PAGELOGROOM); - msg->cm_fields['N'] = strdup(NODENAME); - msg->cm_fields['M'] = SmashStrBuf(&im->conversation); /* we own this memory now */ + + CM_SetField(msg, eOriginalRoom, HKEY(PAGELOGROOM)); + CM_SetField(msg, eNodeName, CtdlGetConfigStr("c_nodename"), strlen(CtdlGetConfigStr("c_nodename"))); + CM_SetAsFieldSB(msg, eMesageText, &FullMsgBuf); /* we own this memory now */ /* Start with usernums[1] because it's guaranteed to be higher than usernums[0], * so if there's only one party, usernums[0] will be zero but usernums[1] won't. @@ -482,7 +494,7 @@ void flush_individual_conversation(struct imlog *im) { snprintf(roomname, sizeof roomname, "%010ld.%s", im->usernums[1], PAGELOGROOM); CtdlCreateRoom(roomname, 5, "", 0, 1, 1, VIEW_BBS); msgnum = CtdlSubmitMsg(msg, NULL, roomname, 0); - CtdlFreeMessage(msg); + CM_Free(msg); /* If there is a valid user number in usernums[0], save a copy for them too. */ if (im->usernums[0] > 0) { @@ -492,9 +504,9 @@ void flush_individual_conversation(struct imlog *im) { } /* Finally, if we're logging instant messages globally, do that now. */ - if (!IsEmptyStr(config.c_logpages)) { - CtdlCreateRoom(config.c_logpages, 3, "", 0, 1, 1, VIEW_BBS); - CtdlSaveMsgPointerInRoom(config.c_logpages, msgnum, 0, NULL); + if (!IsEmptyStr(CtdlGetConfigStr("c_logpages"))) { + CtdlCreateRoom(CtdlGetConfigStr("c_logpages"), 3, "", 0, 1, 1, VIEW_BBS); + CtdlSaveMsgPointerInRoom(CtdlGetConfigStr("c_logpages"), msgnum, 0, NULL); } }