This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
deb-goldedplus/golded3/gelmsg.cpp

138 lines
4.3 KiB
C++
Raw Normal View History

2000-02-25 11:04:07 +00:00
// ------------------------------------------------------------------
// GoldED+
// Copyright (C) 1990-1999 Odinn Sorensen
// Copyright (C) 1999-2000 Alexander S. Aganichev
// ------------------------------------------------------------------
// This program 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 of the
// License, or (at your option) any later version.
//
// This program 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 this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston,
// MA 02111-1307 USA
// ------------------------------------------------------------------
// $Id$
// ------------------------------------------------------------------
// Load message or header. Save header.
// ------------------------------------------------------------------
#include <golded.h>
// ------------------------------------------------------------------
void ResetMsg(GMsg* msg) {
throw_xfree(msg->references);
throw_xfree(msg->inreplyto);
throw_xfree(msg->messageid);
throw_xfree(msg->txt);
throw_xfree(msg->line);
Line* line = msg->lin;
while(line) {
Line* nextline = line->next;
2000-03-22 17:59:18 +00:00
throw_xdelete(line);
2000-02-25 11:04:07 +00:00
line = nextline;
}
memset(msg, 0, sizeof(GMsg));
}
// ------------------------------------------------------------------
2005-10-20 21:41:32 +00:00
int Area::LoadHdr(GMsg* msg, uint32_t msgno, bool enable_recode) {
2000-02-25 11:04:07 +00:00
ResetMsg(msg);
msg->msgno = msgno;
int retval = area->load_hdr(msg);
if (isecho())
{
if (CFG->akamatchfromto && msg->dest.invalid())
msg->dest = Aka().addr;
else if (CFG->akamatchfromto == ALWAYS)
msg->dest = Aka().addr;
}
2000-02-25 11:04:07 +00:00
// Don't translate charsets if we don't know charset
// Currently, it only mime-decodes, so it's okay.
2000-10-20 11:14:13 +00:00
if(retval and enable_recode) {
// Use default translation by default
int table = LoadCharset(NULL, NULL, 1);
if((table == -1) or not CFG->ignorecharset)
msg->charsetlevel = LoadCharset(AA->Xlatimport(), CFG->xlatlocalset);
2000-10-20 11:14:13 +00:00
else
msg->charsetlevel = LoadCharset(CFG->xlatcharset[table].imp, CFG->xlatcharset[table].exp);
2000-02-25 11:04:07 +00:00
// Charset translate header fields
strxmimecpy(msg->realby, msg->realby, msg->charsetlevel, sizeof(INam), true);
strxmimecpy(msg->realto, msg->realto, msg->charsetlevel, sizeof(INam), true);
strxmimecpy(msg->by , msg->by , msg->charsetlevel, sizeof(INam), true);
strxmimecpy(msg->to , msg->to , msg->charsetlevel, sizeof(INam), true);
2000-02-25 11:04:07 +00:00
if(not (msg->attr.frq() or msg->attr.att() or msg->attr.urq()))
strxmimecpy(msg->re , msg->re , msg->charsetlevel, sizeof(ISub), true);
}
return retval;
}
// ------------------------------------------------------------------
2005-10-20 21:41:32 +00:00
int Area::LoadMsg(GMsg* msg, uint32_t msgno, int margin, int mode) {
2000-02-25 11:04:07 +00:00
ResetMsg(msg);
msg->msgno = msgno;
if(msgno and area->load_msg(msg)) {
if (isecho())
{
if (CFG->akamatchfromto && msg->dest.invalid())
msg->dest = Aka().addr;
else if (CFG->akamatchfromto == ALWAYS)
msg->dest = Aka().addr;
}
2000-02-25 11:04:07 +00:00
if(mode & (GMSG_COPY|GMSG_MOVE)) {
if(not ((mode & GMSG_MOVE) and (mode & GMSG_UNS_NOT_RCV)))
return true;
if(not (msg->attr.uns() and not msg->attr.rcv()))
return true;
}
msg->TextToLines(margin);
return true;
}
return false;
}
// ------------------------------------------------------------------
void Area::SaveHdr(int mode, GMsg* msg) {
// Translate softcr to configured char
2005-10-04 22:43:15 +00:00
if (adat->usesoftcrxlat && EDIT->SoftCrXlat())
{
2000-02-25 11:04:07 +00:00
strchg(msg->by, SOFTCR, EDIT->SoftCrXlat());
strchg(msg->to, SOFTCR, EDIT->SoftCrXlat());
strchg(msg->realby, SOFTCR, EDIT->SoftCrXlat());
strchg(msg->realto, SOFTCR, EDIT->SoftCrXlat());
if(not (msg->attr.frq() or msg->attr.att() or msg->attr.urq()))
strchg(msg->re, SOFTCR, EDIT->SoftCrXlat());
}
area->save_hdr(mode, msg);
UpdateAreadata();
}
// ------------------------------------------------------------------