Add Always option for AKAMATCHFROMTO token. Patch from Ianos Gnatiuc 2:5030/830.17

This commit is contained in:
Stas Degteff 2005-09-21 10:02:53 +00:00
parent 3fc1ea9736
commit a48566e71e
6 changed files with 50 additions and 4 deletions

View File

@ -686,7 +686,7 @@ CfgGed::CfgGed() {
adeptxbbsuserno = 0;
addressbookadd = YES;
addresslookupfirst = false;
akamatchfromto = false;
akamatchfromto = NO;
areaautoid = AUTOID_LONG;
areacopydirect = false;
areacopyaddid = false;

View File

@ -176,7 +176,7 @@ void CfgAkamatch() {
// ------------------------------------------------------------------
void CfgAkamatchfromto() {
CFG->akamatchfromto = (0 != GetYesno(val));
CFG->akamatchfromto = GetYesno(val);
}
// ------------------------------------------------------------------

View File

@ -140,7 +140,7 @@ public:
int adeptxbbsuserno;
std::vector<gaka> aka;
std::vector<AkaMatchG> akamatch;
bool akamatchfromto;
int akamatchfromto;
int areaautoid;
Echo areacfmreplyto;
bool areacopydirect;

View File

@ -54,6 +54,14 @@ int Area::LoadHdr(GMsg* msg, ulong msgno, bool enable_recode) {
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;
}
// Don't translate charsets if we don't know charset
// Currently, it only mime-decodes, so it's okay.
if(retval and enable_recode) {
@ -84,6 +92,15 @@ int Area::LoadMsg(GMsg* msg, ulong msgno, int margin, int mode) {
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;
}
if(mode & (GMSG_COPY|GMSG_MOVE)) {
if(not ((mode & GMSG_MOVE) and (mode & GMSG_UNS_NOT_RCV)))
return true;

View File

@ -30,6 +30,7 @@
// ------------------------------------------------------------------
static std::vector<int> post_xparea;
bool akamatchreply = false;
// ------------------------------------------------------------------
@ -873,11 +874,36 @@ void MakeMsg(int mode, GMsg* omsg, bool ignore_replyto) {
if(AA->Akamatching()) {
// ... but only if we did NOT change aka manually
if(AA->Aka().addr.equals(AA->aka())) {
Addr aka_addr = AA->Aka().addr;
if (CFG->akamatchfromto)
{
bool useto = true;
std::vector<gaka>::iterator a;
for (a = CFG->aka.begin(); useto && (a != CFG->aka.end()); a++)
{
if(omsg->orig.equals(a->addr))
useto = false;
}
if (useto)
{
for (a = CFG->aka.begin(); a != CFG->aka.end(); a++)
if(omsg->dest.equals(a->addr))
{
akamatchreply = true;
break;
}
}
}
if (CFG->akamatchfromto && akamatchreply)
aka_addr = omsg->dest;
else
aka_addr = AA->Aka().addr;
AkaMatch(&aka_addr, &omsg->orig);
AA->SetAka(aka_addr);
}
@ -1208,6 +1234,7 @@ void MakeMsg(int mode, GMsg* omsg, bool ignore_replyto) {
// Restore original aka
AA->SetAka(origaka);
akamatchreply = false;
ResetMsg(omsg);
ResetMsg(cmpmsg);

View File

@ -27,6 +27,8 @@
#include <golded.h>
#include <gwinput.h>
extern bool akamatchreply;
// ------------------------------------------------------------------
@ -215,7 +217,7 @@ int AkaMatch(ftn_addr* match, const ftn_addr* addr) {
if(match->equals(a->addr))
{
if (CFG->akamatchfromto)
if (CFG->akamatchfromto && akamatchreply)
return aka;
else
matchaka = aka;