2001-08-17 05:46:24 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
2001-11-10 17:14:16 +00:00
|
|
|
* $Id$
|
2001-08-17 05:46:24 +00:00
|
|
|
* Purpose ...............: Internet email
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
2007-02-25 20:28:00 +00:00
|
|
|
* Copyright (C) 1997-2007
|
2001-08-17 05:46:24 +00:00
|
|
|
*
|
|
|
|
* Michiel Broek FIDO: 2:280/2802
|
|
|
|
* Beekmansbos 10
|
|
|
|
* 1971 BV IJmuiden
|
|
|
|
* the Netherlands
|
|
|
|
*
|
|
|
|
* This file is part of MBSE BBS.
|
|
|
|
*
|
|
|
|
* This BBS is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
* later version.
|
|
|
|
*
|
|
|
|
* MBSE BBS is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with MBSE BBS; see the file COPYING. If not, write to the Free
|
2003-08-15 20:05:34 +00:00
|
|
|
* Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
2001-08-17 05:46:24 +00:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2002-06-30 12:48:44 +00:00
|
|
|
#include "../config.h"
|
2004-02-21 17:22:00 +00:00
|
|
|
#include "../lib/mbselib.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "../lib/mbse.h"
|
2002-01-07 19:16:03 +00:00
|
|
|
#include "../lib/users.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "../lib/msgtext.h"
|
|
|
|
#include "../lib/msg.h"
|
|
|
|
#include "../lib/mbinet.h"
|
|
|
|
#include "exitinfo.h"
|
|
|
|
#include "language.h"
|
|
|
|
#include "mail.h"
|
|
|
|
#include "timeout.h"
|
|
|
|
#include "msgutil.h"
|
2001-11-10 17:14:16 +00:00
|
|
|
#include "input.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "email.h"
|
2001-11-10 17:14:16 +00:00
|
|
|
#include "whoson.h"
|
2004-10-27 11:08:09 +00:00
|
|
|
#include "term.h"
|
2004-11-03 20:48:45 +00:00
|
|
|
#include "ttyio.h"
|
|
|
|
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-10-11 20:49:41 +00:00
|
|
|
extern unsigned int LastNum;
|
2001-08-17 05:46:24 +00:00
|
|
|
extern int Kludges;
|
|
|
|
extern FILE *qf;
|
|
|
|
extern char *Message[];
|
|
|
|
extern int Line;
|
|
|
|
extern int do_mailout;
|
2001-11-02 22:08:33 +00:00
|
|
|
extern int LC_Wrote;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Internal prototypes
|
|
|
|
*/
|
|
|
|
int HasNoEmail(void);
|
2005-10-11 20:49:41 +00:00
|
|
|
int Export_a_Email(unsigned int);
|
2001-08-17 05:46:24 +00:00
|
|
|
int EmailPanel(void);
|
|
|
|
int Save_Email(int);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int HasNoEmail(void)
|
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
if (exitinfo.Email)
|
|
|
|
return FALSE;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
|
|
|
pout(WHITE, BLACK, (char *)"You have no e-mail access");
|
|
|
|
Enter(2);
|
|
|
|
sleep(3);
|
|
|
|
return TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Show message header screen top for reading messages.
|
|
|
|
*/
|
|
|
|
void ShowEmailHdr(void)
|
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
static char Buf1[35], Buf2[35], Buf3[81], temp[81];
|
|
|
|
struct tm *tm;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
Buf1[0] = '\0';
|
|
|
|
Buf2[0] = '\0';
|
|
|
|
Buf3[0] = '\0';
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
clear();
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(temp, 81, " %-70s", sMailbox);
|
2005-08-20 12:27:08 +00:00
|
|
|
pout(BLUE, LIGHTGRAY, temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-10-11 20:49:41 +00:00
|
|
|
snprintf(temp, 81, "#%-5u", Msg.Id);
|
2005-08-20 12:27:08 +00:00
|
|
|
pout(RED, LIGHTGRAY, temp);
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/* Date : */
|
2005-08-20 12:27:08 +00:00
|
|
|
pout(YELLOW, BLACK, (char *) Language(206));
|
2004-11-03 20:48:45 +00:00
|
|
|
tm = gmtime(&Msg.Written);
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(temp, 81, "%02d-%02d-%d %02d:%02d:%02d", tm->tm_mday, tm->tm_mon+1,
|
2001-08-17 05:46:24 +00:00
|
|
|
tm->tm_year+1900, tm->tm_hour, tm->tm_min, tm->tm_sec);
|
2005-08-20 12:27:08 +00:00
|
|
|
pout(LIGHTGREEN, BLACK, temp);
|
|
|
|
colour(LIGHTRED, BLACK);
|
2004-11-03 20:48:45 +00:00
|
|
|
if (Msg.Local) PUTSTR((char *)" Local");
|
|
|
|
if (Msg.Intransit) PUTSTR((char *)" Transit");
|
|
|
|
if (Msg.Private) PUTSTR((char *)" Priv.");
|
|
|
|
if (Msg.Received) PUTSTR((char *)" Rcvd");
|
|
|
|
if (Msg.Sent) PUTSTR((char *)" Sent");
|
|
|
|
if (Msg.KillSent) PUTSTR((char *)" KillSent");
|
|
|
|
if (Msg.ArchiveSent) PUTSTR((char *)" ArchiveSent");
|
|
|
|
if (Msg.Hold) PUTSTR((char *)" Hold");
|
|
|
|
if (Msg.Crash) PUTSTR((char *)" Crash");
|
|
|
|
if (Msg.Immediate) PUTSTR((char *)" Imm.");
|
|
|
|
if (Msg.Direct) PUTSTR((char *)" Dir");
|
|
|
|
if (Msg.Gate) PUTSTR((char *)" Gate");
|
|
|
|
if (Msg.FileRequest) PUTSTR((char *)" Freq");
|
|
|
|
if (Msg.FileAttach) PUTSTR((char *)" File");
|
|
|
|
if (Msg.TruncFile) PUTSTR((char *)" TruncFile");
|
|
|
|
if (Msg.KillFile) PUTSTR((char *)" KillFile");
|
|
|
|
if (Msg.ReceiptRequest) PUTSTR((char *)" RRQ");
|
|
|
|
if (Msg.ConfirmRequest) PUTSTR((char *)" CRQ");
|
|
|
|
if (Msg.Orphan) PUTSTR((char *)" Orphan");
|
|
|
|
if (Msg.Encrypt) PUTSTR((char *)" Crypt");
|
|
|
|
if (Msg.Compressed) PUTSTR((char *)" Comp");
|
|
|
|
if (Msg.Escaped) PUTSTR((char *)" 7bit");
|
|
|
|
if (Msg.ForcePU) PUTSTR((char *)" FPU");
|
|
|
|
if (Msg.Localmail) PUTSTR((char *)" Localmail");
|
|
|
|
if (Msg.Netmail) PUTSTR((char *)" Netmail");
|
|
|
|
if (Msg.Echomail) PUTSTR((char *)" Echomail");
|
|
|
|
if (Msg.News) PUTSTR((char *)" News");
|
|
|
|
if (Msg.Email) PUTSTR((char *)" E-mail");
|
|
|
|
if (Msg.Nodisplay) PUTSTR((char *)" Nodisp");
|
|
|
|
if (Msg.Locked) PUTSTR((char *)" LCK");
|
|
|
|
if (Msg.Deleted) PUTSTR((char *)" Del");
|
|
|
|
Enter(1);
|
|
|
|
|
|
|
|
/* From : */
|
2005-08-20 12:27:08 +00:00
|
|
|
pout(YELLOW, BLACK, (char *) Language(209));
|
2007-03-01 15:20:22 +00:00
|
|
|
colour(LIGHTGREEN, BLACK);
|
|
|
|
PUTSTR(chartran(Msg.From));
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
|
|
|
|
|
|
|
/* To : */
|
2005-08-20 12:27:08 +00:00
|
|
|
pout(YELLOW, BLACK, (char *) Language(208));
|
2007-03-01 15:20:22 +00:00
|
|
|
colour(LIGHTGREEN, BLACK);
|
|
|
|
PUTSTR(chartran(Msg.To));
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/* Subject : */
|
2005-08-20 12:27:08 +00:00
|
|
|
pout(YELLOW, BLACK, (char *) Language(210));
|
2007-03-01 15:20:22 +00:00
|
|
|
colour(LIGHTGREEN, BLACK);
|
|
|
|
PUTSTR(chartran(Msg.Subject));
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
|
|
|
|
|
|
|
if (Msg.Reply)
|
2005-10-11 20:49:41 +00:00
|
|
|
snprintf(Buf1, 35, "\"+\" %s %u", (char *)Language(211), Msg.Reply);
|
2004-11-03 20:48:45 +00:00
|
|
|
if (Msg.Original)
|
2005-10-11 20:49:41 +00:00
|
|
|
snprintf(Buf2, 35, " \"-\" %s %u", (char *)Language(212), Msg.Original);
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(Buf3, 35, "%s%s ", Buf1, Buf2);
|
|
|
|
snprintf(temp, 81, "%78s ", Buf3);
|
2005-08-20 12:27:08 +00:00
|
|
|
pout(YELLOW, BLUE, temp);
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Export a email to file in the users home directory.
|
|
|
|
*/
|
2005-10-11 20:49:41 +00:00
|
|
|
int Export_a_Email(unsigned int Num)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
char *p, temp[21];
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
LastNum = Num;
|
|
|
|
iLineCount = 7;
|
|
|
|
WhosDoingWhat(READ_POST, NULL);
|
|
|
|
Syslog('+', "Export email %d in area %s", Num, sMailbox);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* The area data is already set, so we can do the next things
|
|
|
|
*/
|
|
|
|
if (EmailBase.Total == 0) {
|
|
|
|
Enter(1);
|
|
|
|
/* There are no messages in this area */
|
|
|
|
pout(WHITE, BLACK, (char *) Language(205));
|
|
|
|
Enter(2);
|
|
|
|
sleep(3);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (!Msg_Open(sMailpath)) {
|
|
|
|
WriteError("Error open JAM base %s", sMailpath);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (!Msg_ReadHeader(Num)) {
|
|
|
|
Enter(1);
|
|
|
|
pout(WHITE, BLACK, (char *)Language(77));
|
|
|
|
Msg_Close();
|
|
|
|
Enter(2);
|
|
|
|
sleep(3);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Export the message text to the file in the users home/wrk directory.
|
|
|
|
* Create the filename as <areanum>_<msgnum>.msg The message is
|
|
|
|
* written in M$DOS <cr/lf> format.
|
|
|
|
*/
|
|
|
|
p = calloc(PATH_MAX, sizeof(char));
|
2005-10-11 20:49:41 +00:00
|
|
|
snprintf(p, PATH_MAX, "%s/%s/wrk/%s_%u.msg", CFG.bbs_usersdir, exitinfo.Name, sMailbox, Num);
|
2004-11-03 20:48:45 +00:00
|
|
|
if ((qf = fopen(p, "w")) != NULL) {
|
|
|
|
free(p);
|
|
|
|
p = NULL;
|
|
|
|
if (Msg_Read(Num, 80)) {
|
|
|
|
if ((p = (char *)MsgText_First()) != NULL) {
|
|
|
|
do {
|
|
|
|
if (p[0] == '\001') {
|
|
|
|
if (Kludges) {
|
|
|
|
p[0] = 'a';
|
|
|
|
fprintf(qf, "^%s\r\n", p);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
fprintf(qf, "%s\r\n", p);
|
|
|
|
} while ((p = (char *)MsgText_Next()) != NULL);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
fclose(qf);
|
|
|
|
} else {
|
|
|
|
WriteError("$Can't open %s", p);
|
|
|
|
free(p);
|
|
|
|
}
|
|
|
|
Msg_Close();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Report the result.
|
|
|
|
*/
|
|
|
|
Enter(2);
|
|
|
|
pout(CFG.TextColourF, CFG.TextColourB, (char *) Language(46));
|
2005-10-11 20:49:41 +00:00
|
|
|
snprintf(temp, 21, "%s_%u.msg", sMailbox, Num);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, temp);
|
|
|
|
Enter(2);
|
|
|
|
Pause();
|
|
|
|
return TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save the message to disk.
|
|
|
|
*/
|
|
|
|
int Save_Email(int IsReply)
|
|
|
|
{
|
2002-11-02 14:51:19 +00:00
|
|
|
int i;
|
|
|
|
char *p, *temp;
|
2005-10-11 20:49:41 +00:00
|
|
|
unsigned int crc = -1;
|
|
|
|
int id;
|
2002-11-02 14:51:19 +00:00
|
|
|
FILE *fp;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-02 14:51:19 +00:00
|
|
|
if (Line < 2)
|
|
|
|
return TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-11-02 14:51:19 +00:00
|
|
|
if (!Open_Msgbase(sMailpath, 'w')) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Msg.Arrived = time(NULL) - (gmt_offset((time_t)0) * 60);
|
|
|
|
Msg.Written = Msg.Arrived;
|
|
|
|
Msg.Local = TRUE;
|
|
|
|
Msg.Netmail = TRUE;
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add header lines
|
|
|
|
*/
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(temp, PATH_MAX, "\001Date: %s", rfcdate(Msg.Written));
|
2002-11-02 14:51:19 +00:00
|
|
|
MsgText_Add2(temp);
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(temp, PATH_MAX, "\001From: %s", Msg.From);
|
2002-11-02 14:51:19 +00:00
|
|
|
MsgText_Add2(temp);
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(temp, PATH_MAX, "\001Subject: %s", Msg.Subject);
|
2002-11-02 14:51:19 +00:00
|
|
|
MsgText_Add2(temp);
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(temp, PATH_MAX, "\001Sender: %s", Msg.From);
|
2002-11-02 14:51:19 +00:00
|
|
|
MsgText_Add2(temp);
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(temp, PATH_MAX, "\001To: %s", Msg.To);
|
2002-11-02 14:51:19 +00:00
|
|
|
MsgText_Add2(temp);
|
|
|
|
MsgText_Add2((char *)"\001MIME-Version: 1.0");
|
2005-08-14 12:42:17 +00:00
|
|
|
if (exitinfo.Charset != FTNC_NONE) {
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(temp, PATH_MAX, "\001Content-Type: text/plain; charset=%s", getrfcchrs(exitinfo.Charset));
|
2005-08-14 12:42:17 +00:00
|
|
|
} else {
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(temp, PATH_MAX, "\001Content-Type: text/plain; charset=iso8859-1");
|
2005-08-14 12:42:17 +00:00
|
|
|
}
|
|
|
|
MsgText_Add2(temp);
|
2002-11-02 14:51:19 +00:00
|
|
|
MsgText_Add2((char *)"\001Content-Transfer-Encoding: 8bit");
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(temp, PATH_MAX, "\001X-Mailreader: MBSE BBS %s", VERSION);
|
2002-11-02 14:51:19 +00:00
|
|
|
MsgText_Add2(temp);
|
|
|
|
p = calloc(81, sizeof(char));
|
|
|
|
id = sequencer();
|
2005-10-11 20:49:41 +00:00
|
|
|
snprintf(p, 81, "<%08x@%s>", id, CFG.sysdomain);
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(temp, PATH_MAX, "\001Message-id: %s", p);
|
2002-11-02 14:51:19 +00:00
|
|
|
MsgText_Add2(temp);
|
|
|
|
Msg.MsgIdCRC = upd_crc32(temp, crc, strlen(temp));
|
|
|
|
free(p);
|
|
|
|
|
|
|
|
if (IsReply) {
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(temp, PATH_MAX, "\001In-reply-to: %s", Msg.Replyid);
|
2001-08-17 05:46:24 +00:00
|
|
|
MsgText_Add2(temp);
|
2002-11-02 14:51:19 +00:00
|
|
|
crc = -1;
|
|
|
|
Msg.ReplyCRC = upd_crc32(temp, crc, strlen(temp));
|
|
|
|
} else
|
|
|
|
Msg.ReplyCRC = 0xffffffff;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add message text
|
|
|
|
*/
|
|
|
|
for (i = 1; i < Line; i++) {
|
|
|
|
MsgText_Add2(Message[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add signature.
|
|
|
|
*/
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/%s/.signature", CFG.bbs_usersdir, exitinfo.Name);
|
2002-11-02 14:51:19 +00:00
|
|
|
if ((fp = fopen(temp, "r"))) {
|
|
|
|
Syslog('m', " Add .signature");
|
|
|
|
MsgText_Add2((char *)"");
|
|
|
|
while (fgets(temp, 80, fp)) {
|
|
|
|
Striplf(temp);
|
|
|
|
MsgText_Add2(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-11-02 14:51:19 +00:00
|
|
|
fclose(fp);
|
|
|
|
MsgText_Add2((char *)"");
|
|
|
|
}
|
|
|
|
MsgText_Add2(TearLine());
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save if to disk
|
|
|
|
*/
|
|
|
|
Msg_AddMsg();
|
|
|
|
Msg_UnLock();
|
|
|
|
|
|
|
|
ReadExitinfo();
|
|
|
|
exitinfo.iPosted++;
|
|
|
|
WriteExitinfo();
|
|
|
|
|
|
|
|
do_mailout = TRUE;
|
|
|
|
LC_Wrote = TRUE;
|
|
|
|
|
|
|
|
Syslog('+', "Email (%ld) to \"%s\", \"%s\", in mailbox", Msg.Id, Msg.To, Msg.Subject);
|
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2002-11-02 14:51:19 +00:00
|
|
|
/* Saving message to disk */
|
2005-10-11 20:49:41 +00:00
|
|
|
snprintf(temp, 81, "%s(%d)", (char *) Language(202), Msg.Id);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, temp);
|
|
|
|
Enter(2);
|
2002-11-02 14:51:19 +00:00
|
|
|
sleep(2);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add quick mailscan info
|
|
|
|
*/
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/tmp/netmail.jam", getenv("MBSE_ROOT"));
|
2002-11-02 14:51:19 +00:00
|
|
|
if ((fp = fopen(temp, "a")) != NULL) {
|
2005-10-11 20:49:41 +00:00
|
|
|
fprintf(fp, "%s/%s/mailbox %u\n", CFG.bbs_usersdir, exitinfo.Name, Msg.Id);
|
2002-11-02 14:51:19 +00:00
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(temp);
|
2003-09-14 12:24:18 +00:00
|
|
|
Close_Msgbase(sMailpath);
|
2002-11-02 14:51:19 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-10-11 20:49:41 +00:00
|
|
|
int Read_a_Email(unsigned int Num)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2007-03-01 15:20:22 +00:00
|
|
|
char *p = NULL, *fn, *charset = NULL, *charsin = NULL;
|
2004-11-03 20:48:45 +00:00
|
|
|
lastread LR;
|
2007-09-02 15:04:35 +00:00
|
|
|
unsigned int mycrc;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
LastNum = Num;
|
|
|
|
iLineCount = 7;
|
|
|
|
WhosDoingWhat(READ_POST, NULL);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* The area data is already set, so we can do the next things
|
|
|
|
*/
|
|
|
|
if (EmailBase.Total == 0) {
|
|
|
|
Enter(1);
|
|
|
|
/* There are no messages in this area */
|
|
|
|
pout(WHITE, BLACK, (char *) Language(205));
|
|
|
|
Enter(2);
|
|
|
|
sleep(3);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (!Msg_Open(sMailpath)) {
|
|
|
|
WriteError("Error open JAM base %s", sMailpath);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (!Msg_ReadHeader(Num)) {
|
|
|
|
Enter(1);
|
|
|
|
pout(WHITE, BLACK, (char *)Language(77));
|
|
|
|
Enter(2);
|
|
|
|
Msg_Close();
|
|
|
|
sleep(3);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Fill Quote file in case the user wants to reply. Note that line
|
|
|
|
* wrapping is set lower then normal message read, to create room
|
|
|
|
* for the Quote> strings at the start of each line.
|
|
|
|
*/
|
|
|
|
fn = calloc(PATH_MAX, sizeof(char));
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(fn, PATH_MAX, "%s/%s/.quote", CFG.bbs_usersdir, exitinfo.Name);
|
2004-11-03 20:48:45 +00:00
|
|
|
if ((qf = fopen(fn, "w")) != NULL) {
|
|
|
|
if (Msg_Read(Num, 75)) {
|
|
|
|
if ((p = (char *)MsgText_First()) != NULL)
|
|
|
|
do {
|
|
|
|
if (p[0] == '\001') {
|
2007-03-01 15:20:22 +00:00
|
|
|
/*
|
|
|
|
* Check CHRS kludge
|
|
|
|
*/
|
|
|
|
if (strncmp(p, "\001CHRS: ", 7) == 0) {
|
|
|
|
charset = xstrcpy(p + 7);
|
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* While doing this, store the original Message-id in case
|
|
|
|
* a reply will be made.
|
|
|
|
*/
|
|
|
|
if (strncasecmp(p, "\001Message-id: ", 13) == 0) {
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(Msg.Msgid, 101, "%s", p+13);
|
2004-11-03 20:48:45 +00:00
|
|
|
Syslog('m', "Stored Msgid \"%s\"", Msg.Msgid);
|
|
|
|
}
|
|
|
|
if (Kludges) {
|
|
|
|
p[0] = 'a';
|
|
|
|
fprintf(qf, "^%s\n", p);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
fprintf(qf, "%s\n", p);
|
|
|
|
} while ((p = (char *)MsgText_Next()) != NULL);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
fclose(qf);
|
|
|
|
} else {
|
|
|
|
WriteError("$Can't open %s", p);
|
|
|
|
}
|
|
|
|
free(fn);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2007-03-01 15:20:22 +00:00
|
|
|
if (charset == NULL) {
|
|
|
|
charsin = xstrcpy((char *)"CP437");
|
|
|
|
} else {
|
|
|
|
charsin = xstrcpy(get_ic_ftn(find_ftn_charset(charset)));
|
2007-03-01 15:22:15 +00:00
|
|
|
}
|
2007-03-01 15:20:22 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup character translation
|
|
|
|
*/
|
|
|
|
chartran_init(charsin, get_ic_ftn(exitinfo.Charset), 'b');
|
|
|
|
|
|
|
|
ShowEmailHdr();
|
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Show message text
|
|
|
|
*/
|
|
|
|
colour(CFG.TextColourF, CFG.TextColourB);
|
|
|
|
if (Msg_Read(Num, 79)) {
|
|
|
|
if ((p = (char *)MsgText_First()) != NULL) {
|
|
|
|
do {
|
|
|
|
if (p[0] == '\001') {
|
|
|
|
if (Kludges) {
|
2007-03-01 15:20:22 +00:00
|
|
|
colour(LIGHTGRAY, BLACK);
|
|
|
|
if (p[0] == '\001')
|
|
|
|
p[0] = 'a';
|
|
|
|
PUTSTR(chartran(p));
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2007-02-25 20:28:00 +00:00
|
|
|
if (CheckLine(CFG.TextColourF, CFG.TextColourB, TRUE))
|
2004-11-03 20:48:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
colour(CFG.TextColourF, CFG.TextColourB);
|
|
|
|
if (strchr(p, '>') != NULL)
|
|
|
|
if ((strlen(p) - strlen(strchr(p, '>'))) < 10)
|
|
|
|
colour(CFG.HiliteF, CFG.HiliteB);
|
2007-03-01 15:20:22 +00:00
|
|
|
PUTSTR(chartran(p));
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2007-02-25 20:28:00 +00:00
|
|
|
if (CheckLine(CFG.TextColourF, CFG.TextColourB, TRUE))
|
2004-11-03 20:48:45 +00:00
|
|
|
break;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
} while ((p = (char *)MsgText_Next()) != NULL);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2007-03-01 15:20:22 +00:00
|
|
|
if (charset)
|
|
|
|
free(charset);
|
|
|
|
if (charsin)
|
|
|
|
free(charsin);
|
|
|
|
chartran_close();
|
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Set the Received status on this message.
|
|
|
|
*/
|
|
|
|
if (!Msg.Received) {
|
|
|
|
Syslog('m', "Marking message received");
|
|
|
|
Msg.Received = TRUE;
|
|
|
|
Msg.Read = time(NULL) - (gmt_offset((time_t)0) * 60);
|
|
|
|
if (Msg_Lock(30L)) {
|
|
|
|
Msg_WriteHeader(Num);
|
|
|
|
Msg_UnLock();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Update lastread pointer.
|
|
|
|
*/
|
2007-09-02 15:04:35 +00:00
|
|
|
p = xstrcpy(exitinfo.sUserName);
|
|
|
|
mycrc = StringCRC32(tl(p));
|
|
|
|
free(p);
|
2004-11-03 20:48:45 +00:00
|
|
|
if (Msg_Lock(30L)) {
|
|
|
|
LR.UserID = grecno;
|
2007-09-02 15:04:35 +00:00
|
|
|
LR.UserCRC = mycrc;
|
2004-11-03 20:48:45 +00:00
|
|
|
if (Msg_GetLastRead(&LR) == TRUE) {
|
|
|
|
LR.LastReadMsg = Num;
|
|
|
|
if (Num > LR.HighReadMsg)
|
|
|
|
LR.HighReadMsg = Num;
|
|
|
|
if (LR.HighReadMsg > EmailBase.Highest)
|
|
|
|
LR.HighReadMsg = EmailBase.Highest;
|
2007-09-02 15:04:35 +00:00
|
|
|
LR.UserCRC = mycrc;
|
2004-11-03 20:48:45 +00:00
|
|
|
if (!Msg_SetLastRead(LR))
|
|
|
|
WriteError("Error update lastread");
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Append new lastread pointer
|
|
|
|
*/
|
2007-09-02 15:04:35 +00:00
|
|
|
LR.UserCRC = mycrc;
|
2004-11-03 20:48:45 +00:00
|
|
|
LR.UserID = grecno;
|
|
|
|
LR.LastReadMsg = Num;
|
|
|
|
LR.HighReadMsg = Num;
|
|
|
|
if (!Msg_NewLastRead(LR))
|
|
|
|
WriteError("Can't append lastread");
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
Msg_UnLock();
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
Msg_Close();
|
|
|
|
return TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The panel bar under the message while email reading
|
|
|
|
*/
|
|
|
|
int EmailPanel(void)
|
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
int input;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
WhosDoingWhat(READ_POST, NULL);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/* (A)gain, (N)ext, (L)ast, (R)eply, (E)nter, (D)elete, (Q)uit, e(X)port */
|
|
|
|
pout(WHITE, RED, (char *) Language(214));
|
|
|
|
if (exitinfo.Security.level >= CFG.sysop_access)
|
|
|
|
PUTSTR((char *)", (!)");
|
|
|
|
PUTSTR((char *)": ");
|
|
|
|
alarm_on();
|
|
|
|
input = toupper(Readkey());
|
|
|
|
|
|
|
|
if (input == '!') {
|
|
|
|
if (exitinfo.Security.level >= CFG.sysop_access) {
|
|
|
|
if (Kludges)
|
|
|
|
Kludges = FALSE;
|
|
|
|
else
|
|
|
|
Kludges = TRUE;
|
|
|
|
Read_a_Email(LastNum);
|
|
|
|
}
|
|
|
|
} else if (input == Keystroke(214, 0)) { /* (A)gain */
|
|
|
|
Read_a_Email(LastNum);
|
|
|
|
} else if (input == Keystroke(214, 4)) { /* (P)ost */
|
|
|
|
Write_Email();
|
|
|
|
Read_a_Email(LastNum);
|
|
|
|
} else if (input == Keystroke(214, 2)) { /* (L)ast */
|
|
|
|
if (LastNum > EmailBase.Lowest)
|
|
|
|
LastNum--;
|
|
|
|
Read_a_Email(LastNum);
|
|
|
|
} else if (input == Keystroke(214, 3)) { /* (R)eply */
|
|
|
|
Reply_Email(TRUE);
|
|
|
|
Read_a_Email(LastNum);
|
|
|
|
} else if (input == Keystroke(214, 5)) { /* (Q)uit */
|
|
|
|
/* Quit */
|
|
|
|
pout(WHITE, BLACK, (char *) Language(189));
|
|
|
|
Enter(1);
|
|
|
|
return FALSE;
|
|
|
|
} else if (input == Keystroke(214, 7)) { /* e(X)port */
|
|
|
|
Export_a_Email(LastNum);
|
|
|
|
Read_a_Email(LastNum);
|
|
|
|
} else if (input == '+') {
|
|
|
|
if (Msg.Reply)
|
|
|
|
LastNum = Msg.Reply;
|
|
|
|
Read_a_Email(LastNum);
|
|
|
|
} else if (input == '-') {
|
|
|
|
if (Msg.Original)
|
|
|
|
LastNum = Msg.Original;
|
|
|
|
Read_a_Email(LastNum);
|
|
|
|
} else if (input == Keystroke(214, 6)) { /* (D)elete */
|
2001-08-17 05:46:24 +00:00
|
|
|
// Delete_EmailNum(LastNum);
|
2004-11-03 20:48:45 +00:00
|
|
|
if (LastNum < EmailBase.Highest) {
|
|
|
|
LastNum++;
|
|
|
|
Read_a_Email(LastNum);
|
2001-08-17 05:46:24 +00:00
|
|
|
} else {
|
2004-11-03 20:48:45 +00:00
|
|
|
return FALSE;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
} else {
|
|
|
|
/* Next */
|
2005-08-20 12:27:08 +00:00
|
|
|
pout(WHITE, BLACK, (char *) Language(216));
|
2004-11-03 20:48:45 +00:00
|
|
|
if (LastNum < EmailBase.Highest)
|
|
|
|
LastNum++;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
Read_a_Email(LastNum);
|
|
|
|
}
|
|
|
|
return TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read e-mail, called from the menus
|
|
|
|
*/
|
|
|
|
void Read_Email(void)
|
|
|
|
{
|
2007-09-02 15:04:35 +00:00
|
|
|
char *temp, *p;
|
|
|
|
unsigned int Start, mycrc;
|
2004-11-03 20:48:45 +00:00
|
|
|
lastread LR;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (HasNoEmail())
|
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
|
|
|
temp = calloc(128, sizeof(char));
|
|
|
|
/* Message area \"%s\" contains %lu messages. */
|
2005-10-11 20:49:41 +00:00
|
|
|
snprintf(temp, 128, "\n%s\"%s\" %s%u %s", (char *) Language(221), sMailbox, (char *) Language(222),
|
2004-11-03 20:48:45 +00:00
|
|
|
EmailBase.Total, (char *) Language(223));
|
|
|
|
pout(CFG.TextColourF, CFG.TextColourB, temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Check for lastread pointer, suggest lastread number for start.
|
|
|
|
*/
|
|
|
|
Start = EmailBase.Lowest;
|
2007-09-02 15:04:35 +00:00
|
|
|
p = xstrcpy(exitinfo.sUserName);
|
|
|
|
mycrc = StringCRC32(tl(p));
|
|
|
|
free(p);
|
2004-11-03 20:48:45 +00:00
|
|
|
if (Msg_Open(sMailpath)) {
|
|
|
|
LR.UserID = grecno;
|
2007-09-02 15:04:35 +00:00
|
|
|
LR.UserCRC = mycrc;
|
2004-11-03 20:48:45 +00:00
|
|
|
if (Msg_GetLastRead(&LR))
|
|
|
|
Start = LR.HighReadMsg + 1;
|
|
|
|
else
|
|
|
|
Start = 1;
|
|
|
|
Msg_Close();
|
2001-08-17 05:46:24 +00:00
|
|
|
/*
|
2004-11-03 20:48:45 +00:00
|
|
|
* If we already have read the last message, the pointer is
|
|
|
|
* higher then HighMsgNum, we set it at HighMsgNum to prevent
|
|
|
|
* errors and read that message again.
|
2001-08-17 05:46:24 +00:00
|
|
|
*/
|
2004-11-03 20:48:45 +00:00
|
|
|
if (Start > EmailBase.Highest)
|
|
|
|
Start = EmailBase.Highest;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
|
|
|
/* Please enter a message between */
|
2005-10-11 20:49:41 +00:00
|
|
|
snprintf(temp, 81, "%s(%u - %u)", (char *) Language(224), EmailBase.Lowest, EmailBase.Highest);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(WHITE, BLACK, temp);
|
|
|
|
Enter(1);
|
|
|
|
/* Message number [ */
|
2005-10-11 20:49:41 +00:00
|
|
|
snprintf(temp, 81, "%s%u]: ", (char *) Language(225), Start);
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR(temp);
|
|
|
|
|
|
|
|
colour(CFG.InputColourF, CFG.InputColourB);
|
|
|
|
GetstrC(temp, 80);
|
|
|
|
if ((strcmp(temp, "")) != 0)
|
|
|
|
Start = atoi(temp);
|
|
|
|
free(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (!Read_a_Email(Start))
|
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (EmailBase.Total == 0)
|
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
while(EmailPanel()) {}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reply message, in Msg.From and Msg.Subject must be the
|
|
|
|
* name to reply to and the subject.
|
|
|
|
*/
|
|
|
|
void Reply_Email(int IsReply)
|
|
|
|
{
|
2004-07-10 18:44:35 +00:00
|
|
|
int i, j, x;
|
2005-08-29 12:39:37 +00:00
|
|
|
char to[101], from[101], subj[101], msgid[101], replyto[101], replyaddr[101], *tmp, *buf, qin[9], temp[81];
|
2004-11-03 20:48:45 +00:00
|
|
|
faddr *Dest = NULL;
|
2004-07-10 18:44:35 +00:00
|
|
|
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(from, 101, "%s", Msg.To);
|
|
|
|
snprintf(to, 101, "%s", Msg.From);
|
|
|
|
snprintf(replyto, 101, "%s", Msg.ReplyTo);
|
|
|
|
snprintf(replyaddr, 101, "%s", Msg.ReplyAddr);
|
2004-07-10 18:44:35 +00:00
|
|
|
|
|
|
|
if (strncasecmp(Msg.Subject, "Re:", 3) && IsReply) {
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(subj, 101, "Re: %s", Msg.Subject);
|
2004-07-10 18:44:35 +00:00
|
|
|
} else {
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(subj, 101, "%s", Msg.Subject);
|
2004-07-10 18:44:35 +00:00
|
|
|
}
|
2005-08-10 15:32:42 +00:00
|
|
|
mbse_CleanSubject(subj);
|
2004-07-10 18:44:35 +00:00
|
|
|
Syslog('m', "Reply msg to %s, subject %s", to, subj);
|
|
|
|
Syslog('m', "Msgid was %s", Msg.Msgid);
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(msgid, 101, "%s", Msg.Msgid);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-07-10 18:44:35 +00:00
|
|
|
x = 0;
|
|
|
|
Line = 1;
|
|
|
|
WhosDoingWhat(READ_POST, NULL);
|
|
|
|
clear();
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(temp, 81, " %-70s", sMailbox);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(BLUE, LIGHTGRAY, temp);
|
2005-10-11 20:49:41 +00:00
|
|
|
snprintf(temp, 81, "#%-5u", EmailBase.Highest + 1);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(RED, LIGHTGRAY, temp);
|
|
|
|
Enter(1);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-07-10 18:44:35 +00:00
|
|
|
colour(CFG.HiliteF, CFG.HiliteB);
|
2007-02-26 14:48:22 +00:00
|
|
|
if (utf8)
|
|
|
|
chartran_init((char *)"CP437", (char *)"UTF-8", 'B');
|
|
|
|
PUTSTR(chartran(sLine_str()));
|
|
|
|
chartran_close();
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-07-10 18:44:35 +00:00
|
|
|
for (i = 0; i < (TEXTBUFSIZE + 1); i++)
|
|
|
|
Message[i] = (char *) calloc(MAX_LINE_LENGTH +1, sizeof(char));
|
|
|
|
Line = 1;
|
|
|
|
Msg_New();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(Msg.Replyid, 101, "%s", msgid);
|
|
|
|
snprintf(Msg.ReplyTo, 101, "%s", replyto);
|
|
|
|
snprintf(Msg.ReplyAddr, 101, "%s", replyaddr);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-07-10 18:44:35 +00:00
|
|
|
/* From : */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(YELLOW, BLACK, (char *) Language(209));
|
2004-07-10 18:44:35 +00:00
|
|
|
if (CFG.EmailMode != E_PRMISP) {
|
|
|
|
/*
|
|
|
|
* If not permanent connected to the internet, use fidonet.org style addressing.
|
|
|
|
*/
|
|
|
|
Dest = fido2faddr(CFG.EmailFidoAka);
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(Msg.From, 101, "%s@%s (%s)", exitinfo.sUserName, ascinode(Dest, 0x2f), exitinfo.sUserName);
|
2004-07-10 18:44:35 +00:00
|
|
|
} else {
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(Msg.From, 101, "%s@%s (%s)", exitinfo.Name, CFG.sysdomain, exitinfo.sUserName);
|
2004-07-10 18:44:35 +00:00
|
|
|
}
|
|
|
|
for (i = 0; i < strlen(Msg.From); i++) {
|
|
|
|
if (Msg.From[i] == ' ')
|
|
|
|
Msg.From[i] = '_';
|
|
|
|
if (Msg.From[i] == '@')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pout(CFG.MsgInputColourF, CFG.MsgInputColourB, Msg.From);
|
|
|
|
Enter(1);
|
|
|
|
Syslog('b', "Setting From: %s", Msg.From);
|
|
|
|
|
|
|
|
/* To : */
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(Msg.To, 101, "%s", to);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(YELLOW, BLACK, (char *) Language(208));
|
2004-07-10 18:44:35 +00:00
|
|
|
pout(CFG.MsgInputColourF, CFG.MsgInputColourB, Msg.To);
|
|
|
|
Enter(1);
|
|
|
|
|
|
|
|
/* Enter to keep Subject. */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTRED, BLACK, (char *) Language(219));
|
2004-07-10 18:44:35 +00:00
|
|
|
Enter(1);
|
|
|
|
/* Subject : */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(YELLOW, BLACK, (char *) Language(210));
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(Msg.Subject, 101, "%s", subj);
|
2004-07-10 18:44:35 +00:00
|
|
|
pout(CFG.MsgInputColourF, CFG.MsgInputColourB, Msg.Subject);
|
|
|
|
|
|
|
|
x = strlen(subj);
|
|
|
|
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
|
|
|
|
GetstrP(subj, 50, x);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-07-10 18:44:35 +00:00
|
|
|
if (strlen(subj))
|
|
|
|
strcpy(Msg.Subject, subj);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-07-10 18:44:35 +00:00
|
|
|
Msg.Private = TRUE;
|
|
|
|
Enter(1);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-07-10 18:44:35 +00:00
|
|
|
// Check_Attach();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-07-10 18:44:35 +00:00
|
|
|
/*
|
|
|
|
* Quote original message now, format the original users
|
|
|
|
* initials into qin. If its a name@system.dom the use the
|
|
|
|
* first 8 characters of the name part.
|
|
|
|
*/
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(Message[1], TEXTBUFSIZE +1, "%s wrote to %s:", to, from);
|
2004-07-10 18:44:35 +00:00
|
|
|
memset(&qin, 0, sizeof(qin));
|
|
|
|
if (strchr(to, '@')) {
|
|
|
|
tmp = xstrcpy(strtok(to, "@"));
|
|
|
|
tmp[8] = '\0';
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(qin, 9, "%s", tmp);
|
2004-07-10 18:44:35 +00:00
|
|
|
free(tmp);
|
|
|
|
} else {
|
|
|
|
x = TRUE;
|
|
|
|
j = 0;
|
|
|
|
for (i = 0; i < strlen(to); i++) {
|
|
|
|
if (x && isalpha(to[i])) {
|
|
|
|
qin[j] = to[i];
|
|
|
|
j++;
|
|
|
|
x = FALSE;
|
|
|
|
}
|
|
|
|
if (to[i] == ' ' || to[i] == '.')
|
2001-08-17 05:46:24 +00:00
|
|
|
x = TRUE;
|
2004-07-10 18:44:35 +00:00
|
|
|
if (j == 6)
|
|
|
|
break;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-07-10 18:44:35 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-07-10 18:44:35 +00:00
|
|
|
Line = 2;
|
2005-08-29 12:39:37 +00:00
|
|
|
tmp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
buf = calloc(TEXTBUFSIZE +1, sizeof(char));
|
2004-07-10 18:44:35 +00:00
|
|
|
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(tmp, PATH_MAX, "%s/%s/.quote", CFG.bbs_usersdir, exitinfo.Name);
|
2004-07-10 18:44:35 +00:00
|
|
|
if ((qf = fopen(tmp, "r")) != NULL) {
|
2005-08-29 12:39:37 +00:00
|
|
|
while ((fgets(buf, TEXTBUFSIZE, qf)) != NULL) {
|
2004-07-10 18:44:35 +00:00
|
|
|
Striplf(buf);
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(Message[Line], TEXTBUFSIZE +1, "%s> %s", (char *)qin, buf);
|
2004-07-10 18:44:35 +00:00
|
|
|
Line++;
|
|
|
|
if (Line == TEXTBUFSIZE)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fclose(qf);
|
|
|
|
} else
|
|
|
|
WriteError("$Can't read %s", tmp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-07-10 18:44:35 +00:00
|
|
|
free(buf);
|
|
|
|
free(tmp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-07-10 18:44:35 +00:00
|
|
|
if (Edit_Msg())
|
|
|
|
Save_Email(IsReply);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-07-10 18:44:35 +00:00
|
|
|
for (i = 0; i < (TEXTBUFSIZE + 1); i++)
|
|
|
|
free(Message[i]);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Write_Email(void)
|
|
|
|
{
|
2003-12-16 21:50:32 +00:00
|
|
|
faddr *Dest = NULL;
|
|
|
|
int i;
|
|
|
|
char *orgbox;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
if (HasNoEmail())
|
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
orgbox = xstrcpy(sMailbox);
|
|
|
|
SetEmailArea((char *)"mailbox");
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
WhosDoingWhat(READ_POST, NULL);
|
|
|
|
clear();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
for (i = 0; i < (TEXTBUFSIZE + 1); i++)
|
|
|
|
Message[i] = (char *) calloc(MAX_LINE_LENGTH +1, sizeof(char));
|
|
|
|
Line = 1;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
Msg_New();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2005-08-20 12:27:08 +00:00
|
|
|
colour(LIGHTBLUE, BLACK);
|
2003-12-16 21:50:32 +00:00
|
|
|
/* Posting message in area: */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTBLUE, BLACK, (char *) Language(156));
|
|
|
|
PUTSTR((char *)"\"mailbox\"");
|
|
|
|
Enter(2);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
/* From : */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(YELLOW, BLACK, (char *) Language(157));
|
2003-12-16 21:50:32 +00:00
|
|
|
if (CFG.EmailMode != E_PRMISP) {
|
|
|
|
/*
|
|
|
|
* If not permanent connected to the internet, use fidonet.org style addressing.
|
|
|
|
*/
|
|
|
|
Dest = fido2faddr(CFG.EmailFidoAka);
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(Msg.From, 101, "%s@%s (%s)", exitinfo.sUserName, ascinode(Dest, 0x2f), exitinfo.sUserName);
|
2003-12-16 21:50:32 +00:00
|
|
|
} else
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(Msg.From, 101, "%s@%s (%s)", exitinfo.Name, CFG.sysdomain, exitinfo.sUserName);
|
2003-12-16 21:50:32 +00:00
|
|
|
|
|
|
|
for (i = 0; i < strlen(Msg.From); i++) {
|
|
|
|
if (Msg.From[i] == ' ')
|
|
|
|
Msg.From[i] = '_';
|
|
|
|
if (Msg.From[i] == '@')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.MsgInputColourF, CFG.MsgInputColourB, Msg.From);
|
2003-12-16 21:50:32 +00:00
|
|
|
Syslog('b', "Setting From: %s", Msg.From);
|
|
|
|
Enter(1);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/* To : */
|
|
|
|
pout(YELLOW, BLACK, (char *) Language(158));
|
2003-12-16 21:50:32 +00:00
|
|
|
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
|
2004-11-03 20:48:45 +00:00
|
|
|
alarm_on();
|
2003-12-16 21:50:32 +00:00
|
|
|
GetstrU(Msg.To, 63);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
if ((strcmp(Msg.To, "")) == 0) {
|
|
|
|
for (i = 0; i < (TEXTBUFSIZE + 1); i++)
|
|
|
|
free(Message[i]);
|
|
|
|
SetEmailArea(orgbox);
|
|
|
|
free(orgbox);
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
/* Subject : */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(YELLOW, BLACK, (char *) Language(161));
|
2003-12-16 21:50:32 +00:00
|
|
|
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
|
|
|
|
alarm_on();
|
|
|
|
GetstrP(Msg.Subject, 65, 0);
|
2005-08-10 15:32:42 +00:00
|
|
|
mbse_CleanSubject(Msg.Subject);
|
2003-12-16 21:50:32 +00:00
|
|
|
|
|
|
|
if ((strcmp(Msg.Subject, "")) == 0) {
|
|
|
|
Enter(1);
|
|
|
|
/* Abort Message [y/N] ?: */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CYAN, BLACK, (char *) Language(162));
|
2001-08-17 05:46:24 +00:00
|
|
|
alarm_on();
|
2003-12-16 21:50:32 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (toupper(Readkey()) == Keystroke(162, 0)) {
|
2003-12-16 21:50:32 +00:00
|
|
|
for (i = 0; i < (TEXTBUFSIZE + 1); i++)
|
|
|
|
free(Message[i]);
|
|
|
|
SetEmailArea(orgbox);
|
|
|
|
free(orgbox);
|
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-12-16 21:50:32 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
Msg.Private = TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
if (Edit_Msg()) {
|
|
|
|
Save_Email(FALSE);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
for (i = 0; i < (TEXTBUFSIZE + 1); i++)
|
|
|
|
free(Message[i]);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-16 21:50:32 +00:00
|
|
|
SetEmailArea(orgbox);
|
|
|
|
free(orgbox);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QuickScan_Email(void)
|
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
int FoundMsg = FALSE;
|
2005-10-11 20:49:41 +00:00
|
|
|
int i;
|
2004-11-03 20:48:45 +00:00
|
|
|
char temp[81];
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
iLineCount = 2;
|
|
|
|
WhosDoingWhat(READ_POST, NULL);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (EmailBase.Total == 0) {
|
|
|
|
Enter(1);
|
|
|
|
/* There are no messages in this area. */
|
|
|
|
pout(WHITE, BLACK, (char *) Language(205));
|
|
|
|
Enter(2);
|
|
|
|
sleep(3);
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
clear();
|
|
|
|
/* # From To Subject */
|
|
|
|
poutCR(YELLOW, BLUE, (char *) Language(220));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (Msg_Open(sMailpath)) {
|
|
|
|
for (i = EmailBase.Lowest; i <= EmailBase.Highest; i++) {
|
|
|
|
if (Msg_ReadHeader(i)) {
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-10-11 20:49:41 +00:00
|
|
|
snprintf(temp, 81, "%-6u", Msg.Id);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(WHITE, BLACK, temp);
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(temp, 81, "%s ", padleft(Msg.From, 20, ' '));
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CYAN, BLACK, temp);
|
|
|
|
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(temp, 81, "%s ", padleft(Msg.To, 20, ' '));
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(GREEN, BLACK, temp);
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(temp, 81, "%s", padleft(Msg.Subject, 31, ' '));
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(MAGENTA, BLACK, temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
Enter(1);
|
2004-11-03 20:48:45 +00:00
|
|
|
FoundMsg = TRUE;
|
|
|
|
if (LC(1))
|
|
|
|
break;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
Msg_Close();
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if(!FoundMsg) {
|
|
|
|
Enter(1);
|
|
|
|
/* There are no messages in this area. */
|
|
|
|
pout(LIGHTGREEN, BLACK, (char *) Language(205));
|
|
|
|
Enter(2);
|
|
|
|
sleep(3);
|
|
|
|
}
|
|
|
|
|
|
|
|
iLineCount = 2;
|
|
|
|
Pause();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Trash_Email(void)
|
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
if (HasNoEmail())
|
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Choose_Mailbox(char *Option)
|
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
char *temp;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (HasNoEmail())
|
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (strlen(Option)) {
|
|
|
|
if (!strcmp(Option, "M+")) {
|
|
|
|
if (!strcmp(sMailbox, "mailbox"))
|
|
|
|
SetEmailArea((char *)"archive");
|
|
|
|
else if (!strcmp(sMailbox, "archive"))
|
|
|
|
SetEmailArea((char *)"trash");
|
|
|
|
else if (!strcmp(sMailbox, "trash"))
|
|
|
|
SetEmailArea((char *)"mailbox");
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
if (!strcmp(Option, "M-")) {
|
|
|
|
if (!strcmp(sMailbox, "mailbox"))
|
|
|
|
SetEmailArea((char *)"trash");
|
|
|
|
else if (!strcmp(sMailbox, "trash"))
|
|
|
|
SetEmailArea((char *)"archive");
|
|
|
|
else if (!strcmp(sMailbox, "archive"));
|
|
|
|
SetEmailArea((char *)"mailbox");
|
|
|
|
}
|
|
|
|
Syslog('+', "Emailarea: %s", sMailbox);
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
clear();
|
|
|
|
Enter(1);
|
|
|
|
/* Message areas */
|
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(231));
|
|
|
|
Enter(2);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-20 12:27:08 +00:00
|
|
|
pout(WHITE, BLACK, (char *)" 1"); pout(LIGHTBLUE, BLACK, (char *)" . "); pout(CYAN, BLACK, (char *) Language(467)); Enter(1);
|
|
|
|
pout(WHITE, BLACK, (char *)" 2"); pout(LIGHTBLUE, BLACK, (char *)" . "); pout(CYAN, BLACK, (char *) Language(468)); Enter(1);
|
|
|
|
pout(WHITE, BLACK, (char *)" 3"); pout(LIGHTBLUE, BLACK, (char *)" . "); pout(CYAN, BLACK, (char *) Language(469)); Enter(1);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.MoreF, CFG.MoreB, (char *) Language(470));
|
|
|
|
colour(CFG.InputColourF, CFG.InputColourB);
|
|
|
|
temp = calloc(81, sizeof(char));
|
|
|
|
GetstrC(temp, 7);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
switch (atoi(temp)) {
|
|
|
|
case 1: SetEmailArea((char *)"mailbox");
|
|
|
|
break;
|
|
|
|
case 2: SetEmailArea((char *)"archive");
|
|
|
|
break;
|
|
|
|
case 3: SetEmailArea((char *)"trash");
|
|
|
|
break;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
Syslog('+', "Emailarea: %s", sMailbox);
|
|
|
|
free(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SetEmailArea(char *box)
|
|
|
|
{
|
2005-10-08 21:05:28 +00:00
|
|
|
char *p;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-10-08 21:05:28 +00:00
|
|
|
if (!exitinfo.Email)
|
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-10-08 21:05:28 +00:00
|
|
|
/*
|
|
|
|
* Use a temp variable because this function can be called line SetEmailArea(sMailbox)
|
|
|
|
*/
|
|
|
|
p = xstrcpy(box);
|
|
|
|
snprintf(sMailpath, PATH_MAX, "%s/%s/%s", CFG.bbs_usersdir, exitinfo.Name, p);
|
|
|
|
snprintf(sMailbox, 21, "%s", p);
|
|
|
|
free(p);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get information from the message base
|
|
|
|
*/
|
|
|
|
if (Msg_Open(sMailpath)) {
|
|
|
|
EmailBase.Lowest = Msg_Lowest();
|
|
|
|
EmailBase.Highest = Msg_Highest();
|
|
|
|
EmailBase.Total = Msg_Number();
|
|
|
|
Msg_Close();
|
|
|
|
} else
|
|
|
|
WriteError("Error open JAM %s", sMailpath);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|