Patch level : 4.0
Files correlati : ba7 Ricompilazione Demo : [ ] Commento : Aggiunto supporto per log delle transazioni del postino git-svn-id: svn://10.65.10.50/trunk@15245 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
9a36f6bf59
commit
4d8ae81dbe
355
ba/ba7100.cpp
355
ba/ba7100.cpp
@ -6,17 +6,15 @@
|
||||
#include <execp.h>
|
||||
#include <expr.h>
|
||||
#include <golem.h>
|
||||
#include <tabutil.h>
|
||||
#include <netsock.h>
|
||||
#include <prefix.h>
|
||||
#include <tabutil.h>
|
||||
#include <recarray.h>
|
||||
#include <sheet.h>
|
||||
#include <utility.h>
|
||||
#include <viswin.h>
|
||||
#include <browfile.h>
|
||||
|
||||
#define NO_MFC
|
||||
#include <netsock.h>
|
||||
|
||||
#include "ba7.h"
|
||||
#include "ba7100a.h"
|
||||
#define NOT_TRANS -883
|
||||
@ -26,18 +24,17 @@
|
||||
// TConfig utilities
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TString& set_ini_var(int cfg, const char* para,
|
||||
const TString& set_ini_var(int cfg, const char* para,
|
||||
const char* var, const char* val)
|
||||
{
|
||||
static TString80 prev;
|
||||
TConfig ini(cfg, para);
|
||||
prev = ini.get(var);
|
||||
const TString& prev = ini.get(var);
|
||||
if (val != NULL)
|
||||
ini.set(var, val);
|
||||
return prev;
|
||||
return prev.full() ? (get_tmp_string()=prev) : EMPTY_STRING;
|
||||
}
|
||||
|
||||
inline TString& get_ini_var(int cfg, const char* para, const char* var)
|
||||
inline const TString& get_ini_var(int cfg, const char* para, const char* var)
|
||||
{ return set_ini_var(cfg, para, var, NULL); }
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -67,16 +64,16 @@ public:
|
||||
|
||||
bool TMail_box::default_params(TString& server, TString& user,TString& password)
|
||||
{
|
||||
bool ok = TRUE;
|
||||
if (server.empty())
|
||||
bool ok = true;
|
||||
if (server.blank())
|
||||
{
|
||||
server = get_ini_var(CONFIG_INSTALL, "Server", "POP3");
|
||||
if (server.empty())
|
||||
ok = FALSE;
|
||||
ok = false;
|
||||
}
|
||||
if (user.empty())
|
||||
if (user.blank())
|
||||
user = ::user();
|
||||
if (password.empty())
|
||||
if (password.blank())
|
||||
{
|
||||
const TString& pwd = cache().get(LF_USER, user).get("PASSWORD");
|
||||
password = ::decode(pwd);
|
||||
@ -90,22 +87,21 @@ bool TMail_box::logon(const char* ser, const char* usr, const char* pwd)
|
||||
logoff();
|
||||
|
||||
if (!IsOk())
|
||||
return error_box("Impossibile inizializzare il client POP3");
|
||||
return error_box(TR("Impossibile inizializzare il client POP3"));
|
||||
|
||||
TString server(ser);
|
||||
TString user(usr);
|
||||
TString password(pwd);
|
||||
if (!default_params(server, user, password))
|
||||
return error_box("E' necessario specificare un server POP3, un utente ed una password");
|
||||
return error_box(TR("E' necessario specificare un server POP3, un utente ed una password"));
|
||||
|
||||
_connection = QueryConnection("110", server);
|
||||
if (_connection != 0)
|
||||
{
|
||||
TString buf;
|
||||
TString req;
|
||||
TString buf, req;
|
||||
ReadLine(_connection, buf);
|
||||
if (buf[0] != '+')
|
||||
return error_box("Il server POP3 %s non risponde\nRisultato : %s",
|
||||
return error_box(FR("Il server POP3 %s non risponde\nRisultato : %s"),
|
||||
(const char*)server, (const char *)buf);
|
||||
|
||||
buf = "USER "; buf << user << "\r\n";
|
||||
@ -113,7 +109,7 @@ bool TMail_box::logon(const char* ser, const char* usr, const char* pwd)
|
||||
req = buf;
|
||||
ReadLine(_connection, buf);
|
||||
if (buf[0] != '+')
|
||||
return error_box("Il server POP3 %s non accetta l'utente %s\nRichiesta : %sRisultato : %s",
|
||||
return error_box(FR("Il server POP3 %s non accetta l'utente %s\nRichiesta : %sRisultato : %s"),
|
||||
(const char*)server, (const char*)user, (const char *) req, (const char *)buf);
|
||||
|
||||
buf = "PASS "; buf << password << "\r\n";
|
||||
@ -121,14 +117,14 @@ bool TMail_box::logon(const char* ser, const char* usr, const char* pwd)
|
||||
req = buf;
|
||||
ReadLine(_connection, buf);
|
||||
if (buf[0] != '+')
|
||||
return error_box("Il server POP3 %s non accetta la password dell'utente %s\nRichiesta : %sRisultato : %s",
|
||||
return error_box(FR("Il server POP3 %s non accetta la password dell'utente %s\nRichiesta : %sRisultato : %s"),
|
||||
(const char*)server, (const char*)user, (const char *) req, (const char *)buf);
|
||||
}
|
||||
else
|
||||
return error_box("Impossibile contattare il server POP3 %s",
|
||||
return error_box(FR("Impossibile contattare il server POP3 %s"),
|
||||
(const char*)server);
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
void TMail_box::logoff()
|
||||
@ -173,7 +169,7 @@ HIDDEN int str2month(const char* str)
|
||||
int m;
|
||||
for (m = 11; m > 0; m--)
|
||||
{
|
||||
if (stricmp(str, mese[m]) == 0)
|
||||
if (xvt_str_compare_ignoring_case(str, mese[m]) == 0)
|
||||
break;
|
||||
}
|
||||
return m+1;
|
||||
@ -184,7 +180,7 @@ enum EncodingType { enc_plain_text, enc_quoted_printable, enc_base64 };
|
||||
int TMail_box::get(TMail_messages& m)
|
||||
{
|
||||
// Lista dei caratteri validi
|
||||
const char Base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+*";
|
||||
const char* const Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+*";
|
||||
|
||||
// Lista per decodifica dei caratteri validi
|
||||
char Deco64[256];
|
||||
@ -209,9 +205,9 @@ int TMail_box::get(TMail_messages& m)
|
||||
ReadLine(_connection, buf);
|
||||
bool ok = buf[0] == '+';
|
||||
EncodingType encoding = enc_plain_text;
|
||||
bool in_body = FALSE;
|
||||
bool in_section = FALSE;
|
||||
bool buf_already_read = FALSE;
|
||||
bool in_body = false;
|
||||
bool in_section = false;
|
||||
bool buf_already_read = false;
|
||||
boundary.cut(0);
|
||||
|
||||
while (ok)
|
||||
@ -220,12 +216,12 @@ int TMail_box::get(TMail_messages& m)
|
||||
{
|
||||
if (!ReadLine(_connection, buf))
|
||||
{
|
||||
ok = FALSE;
|
||||
ok = false;
|
||||
break; // Unexpected EOF
|
||||
}
|
||||
}
|
||||
else
|
||||
buf_already_read = FALSE;
|
||||
buf_already_read = false;
|
||||
if (buf[0] == '.')
|
||||
{
|
||||
buf.ltrim(1);
|
||||
@ -299,56 +295,56 @@ int TMail_box::get(TMail_messages& m)
|
||||
else
|
||||
{
|
||||
if (buf.find(boundary) >= 0)
|
||||
in_section = TRUE;
|
||||
in_section = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (buf.blank())
|
||||
{
|
||||
in_body = TRUE;
|
||||
in_body = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (buf.compare("From:", 5, TRUE) == 0)
|
||||
if (buf.compare("From:", 5, true) == 0)
|
||||
{
|
||||
buf.ltrim(6); buf.trim();
|
||||
msg.set_sender(buf);
|
||||
continue;
|
||||
}
|
||||
if (buf.compare("To:", 3, TRUE) == 0)
|
||||
if (buf.compare("To:", 3, true) == 0)
|
||||
{
|
||||
buf.ltrim(4); buf.trim();
|
||||
msg.add_recipient(buf);
|
||||
continue;
|
||||
}
|
||||
if (buf.compare("Cc:", 3, TRUE) == 0)
|
||||
if (buf.compare("Cc:", 3, true) == 0)
|
||||
{
|
||||
buf.ltrim(4); buf.trim();
|
||||
msg.add_copy_recipient(buf);
|
||||
continue;
|
||||
}
|
||||
if (buf.compare("Subject:", 8, TRUE) == 0)
|
||||
if (buf.compare("Subject:", 8, true) == 0)
|
||||
{
|
||||
buf.ltrim(9); buf.trim();
|
||||
msg.set_subject(buf);
|
||||
continue;
|
||||
}
|
||||
if (buf.compare("Date:", 5, TRUE) == 0)
|
||||
if (buf.compare("Date:", 5, true) == 0)
|
||||
{
|
||||
TToken_string d(buf.mid(6), ' '); d.trim();
|
||||
int giorno = d.get_int(1);
|
||||
int mese = str2month(d.get());
|
||||
int anno = d.get_int();
|
||||
if (anno < 1000) anno += anno >= 98 ? 1900 : 2000;
|
||||
if (anno < 100) anno += 2000;
|
||||
TString16 ora = d.get();
|
||||
buf.cut(0);
|
||||
buf << anno << '/' << mese << '/' << giorno << ' ' << ora;
|
||||
msg.set_date_time(buf);
|
||||
continue;
|
||||
}
|
||||
if (buf.compare("Content-Transfer-Encoding:", 26, TRUE) == 0)
|
||||
if (buf.compare("Content-Transfer-Encoding:", 26, true) == 0)
|
||||
{
|
||||
if (buf.find("base64") > 0)
|
||||
encoding = enc_base64; else
|
||||
@ -356,7 +352,7 @@ int TMail_box::get(TMail_messages& m)
|
||||
encoding = enc_quoted_printable;
|
||||
continue;
|
||||
}
|
||||
if (buf.compare("Content-Type:", 13, TRUE) == 0)
|
||||
if (buf.compare("Content-Type:", 13, true) == 0)
|
||||
{
|
||||
int bnd = buf.find("oundary="); // Funziona per Boundary e boundary
|
||||
if (bnd < 0)
|
||||
@ -364,7 +360,7 @@ int TMail_box::get(TMail_messages& m)
|
||||
ReadLine(_connection, buf);
|
||||
bnd = buf.find("oundary=");
|
||||
if (bnd < 0)
|
||||
buf_already_read = TRUE;
|
||||
buf_already_read = true;
|
||||
}
|
||||
if (bnd > 0)
|
||||
{
|
||||
@ -434,14 +430,12 @@ TFilter_expr::TFilter_expr(TAutomask& m, int logicnum, const char* expr)
|
||||
if (logicnum < LF_USER || logicnum >= prefix().items())
|
||||
logicnum = LF_TABCOM; // Niente errori fatali, se possibile
|
||||
|
||||
TLocalisamfile isf(logicnum);
|
||||
TRectype& rec = isf.curr();
|
||||
const TRectype rec(logicnum);
|
||||
for (int i = 0; i < numvar(); i++) if (!rec.exist(varname(i)))
|
||||
{
|
||||
_error = 883;
|
||||
TString msg;
|
||||
msg << "Il campo " << varname(i)
|
||||
<< " non appartiene al file " << logicnum;
|
||||
msg.format(FR("Il campo %s non appartiene al file %d"), varname(i), logicnum);
|
||||
print_error(msg);
|
||||
break;
|
||||
}
|
||||
@ -477,12 +471,15 @@ protected:
|
||||
|
||||
TToken_string& get_key1(int lf) const;
|
||||
bool build_key1(int lf, const TString& body, TToken_string& key) const;
|
||||
bool build_key1(const TMail_message& msg, TToken_string& key) const;
|
||||
void find_redundant_messages();
|
||||
|
||||
void track(const TMail_message& msg, const TString& app, const TString& action, int err);
|
||||
bool exec_app(int & err, const TString& appname, TMail_message & msg);
|
||||
|
||||
public:
|
||||
void test_delete();
|
||||
int fill_messages();
|
||||
bool exec_app(int & err, const char * appname, TMail_message & msg);
|
||||
bool save_sheet_line(int& err, int line = -1);
|
||||
void save_all_lines();
|
||||
void auto_save_all();
|
||||
@ -498,15 +495,16 @@ void TMailer_mask::test_delete()
|
||||
{
|
||||
TWait_cursor hourglass;
|
||||
|
||||
xvtil_statbar_set("Eliminazione messaggi POP3...");
|
||||
xvtil_statbar_set(TR("Eliminazione messaggi POP3..."));
|
||||
do_events();
|
||||
|
||||
TSheet_field& sf = sfield(F_MESSAGES);
|
||||
TString16 mailer, id;
|
||||
TString4 mailer;
|
||||
TString16 id;
|
||||
|
||||
TMail_messages mapidel; // Lista dei messaggi MAPI da cancellare
|
||||
|
||||
TMail_box mailbox;
|
||||
TSheet_field& sf = sfield(F_MESSAGES);
|
||||
FOR_EACH_SHEET_ROW_BACK(sf, nrow, row) if (*row->get(0) == 'X')
|
||||
{
|
||||
row->get(sf.cid2index(F_MAILER), mailer);
|
||||
@ -519,7 +517,7 @@ void TMailer_mask::test_delete()
|
||||
break;
|
||||
}
|
||||
if (!mailbox.remove(id))
|
||||
error_box("Impossibile cancellare il messaggio POP3 %s", (const char*)id);
|
||||
error_box(FR("Impossibile cancellare il messaggio POP3 %s"), (const char*)id);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -533,12 +531,12 @@ void TMailer_mask::test_delete()
|
||||
|
||||
if (mapidel.items() > 0)
|
||||
{
|
||||
xvtil_statbar_set("Eliminazione messaggi MAPI...");
|
||||
xvtil_statbar_set(TR("Eliminazione messaggi MAPI..."));
|
||||
do_events();
|
||||
mapidel.remove();
|
||||
}
|
||||
|
||||
xvtil_statbar_set("Pronto");
|
||||
xvtil_statbar_set(TR("Pronto"));
|
||||
do_events();
|
||||
}
|
||||
|
||||
@ -596,12 +594,12 @@ int TMailer_mask::fill_messages()
|
||||
|
||||
if (get_bool(F_MAPI))
|
||||
{
|
||||
xvtil_statbar_set("Ricezione messaggi MAPI...");
|
||||
xvtil_statbar_set(TR("Ricezione messaggi MAPI..."));
|
||||
do_events();
|
||||
totmapi = _box.get();
|
||||
}
|
||||
|
||||
xvtil_statbar_set("Ricezione messaggi POP3...");
|
||||
xvtil_statbar_set(TR("Ricezione messaggi POP3..."));
|
||||
do_events();
|
||||
mailbox.logon(server, user, password);
|
||||
mailbox.get(_box);
|
||||
@ -626,10 +624,12 @@ int TMailer_mask::fill_messages()
|
||||
{
|
||||
mess << *msgrow;
|
||||
if (mess.len() >= 1024)
|
||||
{
|
||||
mess.cut(1024);
|
||||
break;
|
||||
}
|
||||
}
|
||||
row.add(mess, sf.cid2index(F_BODY));
|
||||
row.add(m<totmapi?"MAPI":"POP3", sf.cid2index(F_MAILER));
|
||||
if (m < totmapi)
|
||||
{
|
||||
row.add("MAPI", sf.cid2index(F_MAILER));
|
||||
@ -643,14 +643,14 @@ int TMailer_mask::fill_messages()
|
||||
}
|
||||
sf.force_update();
|
||||
|
||||
xvtil_statbar_set("Pronto");
|
||||
xvtil_statbar_set(TR("Pronto"));
|
||||
|
||||
return sf.items();
|
||||
}
|
||||
|
||||
bool TMailer_mask::file2app(const TString& file, TString& app) const
|
||||
{
|
||||
bool ok = FALSE;
|
||||
bool ok = false;
|
||||
|
||||
const TString* run = (const TString*)_apps.objptr(file);
|
||||
if (run == NULL)
|
||||
@ -680,7 +680,7 @@ bool TMailer_mask::file2app(const TString& file, TString& app) const
|
||||
}
|
||||
}
|
||||
else
|
||||
ok = TRUE;
|
||||
ok = true;
|
||||
|
||||
((TMailer_mask*)this)->_apps.add(file, app); // Fool const
|
||||
}
|
||||
@ -695,17 +695,17 @@ bool TMailer_mask::file2app(const TString& file, TString& app) const
|
||||
bool is_incomplete(const TString& l)
|
||||
{
|
||||
if (l[0] == '[')
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
const char a = l.right(1)[0];
|
||||
if (a == '=')
|
||||
return TRUE;
|
||||
return true;
|
||||
|
||||
const int eq = l.find("= '");
|
||||
if (eq > 0 && eq < 20)
|
||||
return a != '\'';
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
void adjust_long_lines(const TFilename& tmp)
|
||||
@ -713,17 +713,17 @@ void adjust_long_lines(const TFilename& tmp)
|
||||
TFilename dst_name; dst_name.temp();
|
||||
ofstream dst(dst_name);
|
||||
|
||||
bool adjusted = FALSE;
|
||||
bool adjusted = false;
|
||||
|
||||
TScanner org(tmp);
|
||||
while (TRUE)
|
||||
while (true)
|
||||
{
|
||||
const TString& l = org.line();
|
||||
if (l.empty())
|
||||
break;
|
||||
if (is_incomplete(l))
|
||||
{
|
||||
adjusted = TRUE;
|
||||
adjusted = true;
|
||||
dst << l;
|
||||
org.line();
|
||||
char s = l[0];
|
||||
@ -746,49 +746,99 @@ void adjust_long_lines(const TFilename& tmp)
|
||||
dst.close();
|
||||
if (adjusted)
|
||||
fcopy(dst_name, tmp);
|
||||
remove(dst_name);
|
||||
remove_file(dst_name);
|
||||
}
|
||||
|
||||
bool TMailer_mask::exec_app(int & err, const char * appname, TMail_message & msg)
|
||||
void TMailer_mask::track(const TMail_message& msg, const TString& app, const TString& action, int err)
|
||||
{
|
||||
TFilename tmp; tmp.temp();
|
||||
const TString& fname = get(F_TRACKING);
|
||||
if (fname.full())
|
||||
{
|
||||
ofstream outf(tmp);
|
||||
const int items = msg.items();
|
||||
bool long_lines = FALSE;
|
||||
TString message;
|
||||
for (int i = 0; i < items; i++)
|
||||
const char fldsep = '\t';
|
||||
const char recsep = '\n';
|
||||
|
||||
ofstream log(fname, ios::app);
|
||||
|
||||
log << msg.sender() << fldsep;
|
||||
|
||||
log << msg.date() << fldsep;
|
||||
const real t = msg.time();
|
||||
log << t.string("@@:@@:@@") << fldsep;
|
||||
|
||||
TToken_string k1; build_key1(msg, k1);
|
||||
log << k1.get(0) << fldsep;
|
||||
|
||||
const int pipe = k1.find(k1.separator());
|
||||
k1.ltrim(pipe+1);
|
||||
log << k1 << fldsep;
|
||||
|
||||
log << app << fldsep << action << fldsep << err << fldsep;
|
||||
|
||||
log << recsep;
|
||||
}
|
||||
}
|
||||
|
||||
bool TMailer_mask::exec_app(int& err, const TString& appname, TMail_message& msg)
|
||||
{
|
||||
err = NOERR;
|
||||
TString action;
|
||||
if (appname.compare("sink", -1, true) == 0)
|
||||
{
|
||||
FOR_EACH_ARRAY_ROW(msg, r, row)
|
||||
{
|
||||
message = msg.row(i);
|
||||
message.replace('\r', '\n');
|
||||
outf << message;
|
||||
int s = row->find("\nAction");
|
||||
if (s > 0)
|
||||
{
|
||||
s = row->find('=', s);
|
||||
const int e = row->find('\n', s);
|
||||
action = row->sub(s+1, e);
|
||||
action.trim();
|
||||
break;
|
||||
}
|
||||
}
|
||||
outf.close();
|
||||
adjust_long_lines(tmp);
|
||||
|
||||
TConfig ini(tmp, "Transaction");
|
||||
ini.set("From", msg.sender());
|
||||
}
|
||||
|
||||
TString command_line(appname);
|
||||
command_line << " /i" << tmp;
|
||||
TExternal_app app(command_line);
|
||||
err = app.run();
|
||||
xvt_sys_sleep(1000);
|
||||
bool ok = err == NOERR;
|
||||
|
||||
if (ok)
|
||||
else
|
||||
{
|
||||
TConfig ini(tmp, "Transaction");
|
||||
ok = ini.get("Result") == "OK";
|
||||
if (ok)
|
||||
err = 0;
|
||||
else
|
||||
err = ini.get_int("Error");
|
||||
}
|
||||
::remove(tmp);
|
||||
TFilename tmp; tmp.temp();
|
||||
{
|
||||
ofstream outf(tmp);
|
||||
const int items = msg.items();
|
||||
bool long_lines = false;
|
||||
TString message;
|
||||
for (int i = 0; i < items; i++)
|
||||
{
|
||||
message = msg.row(i);
|
||||
message.replace('\r', '\n');
|
||||
outf << message;
|
||||
}
|
||||
outf.close();
|
||||
adjust_long_lines(tmp);
|
||||
|
||||
return ok;
|
||||
TConfig ini(tmp, "Transaction");
|
||||
ini.set("From", msg.sender());
|
||||
action = ini.get("Action");
|
||||
}
|
||||
|
||||
TString command_line(appname);
|
||||
command_line << " /i" << tmp;
|
||||
TExternal_app app(command_line);
|
||||
err = app.run();
|
||||
xvt_sys_sleep(1000);
|
||||
|
||||
if (err == NOERR)
|
||||
{
|
||||
TConfig ini(tmp, "Transaction");
|
||||
if (ini.get("Result") == "OK")
|
||||
err = 0;
|
||||
else
|
||||
err = ini.get_int("Error");
|
||||
}
|
||||
remove_file(tmp);
|
||||
}
|
||||
|
||||
track(msg, appname, action, err);
|
||||
|
||||
return err == NOERR;
|
||||
}
|
||||
|
||||
bool TMailer_mask::save_sheet_line(int& err, int nrow)
|
||||
@ -807,7 +857,7 @@ bool TMailer_mask::save_sheet_line(int& err, int nrow)
|
||||
if (msg.find("[Transaction]") < 0)
|
||||
{
|
||||
err = NOT_TRANS;
|
||||
return FALSE; // It's not a transaction
|
||||
return false; // It's not a transaction
|
||||
}
|
||||
|
||||
TString subj = m.get(F_SUBJECT);
|
||||
@ -821,7 +871,7 @@ bool TMailer_mask::save_sheet_line(int& err, int nrow)
|
||||
if (!file2app(subj, appname)) // It hasn't a valid application
|
||||
{
|
||||
err = NOT_GEST;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
TMail_message& full_msg = _box.msg(nrow);
|
||||
@ -852,7 +902,7 @@ bool TMailer_mask::save_sheet_line(int& err, int nrow)
|
||||
}
|
||||
|
||||
// Restore mail recipient
|
||||
// if (old_mailto.not_empty())
|
||||
// if (old_mailto.full())
|
||||
// set_ini_var(CONFIG_INSTALL, "Main", "MailTo", old_mailto);
|
||||
|
||||
return ok;
|
||||
@ -860,22 +910,22 @@ bool TMailer_mask::save_sheet_line(int& err, int nrow)
|
||||
|
||||
TToken_string& TMailer_mask::get_key1(int lf) const
|
||||
{
|
||||
TString_array& k1 = (TString_array&)_key1; // fool const;
|
||||
if (k1.objptr(lf) == NULL)
|
||||
TString_array& k = (TString_array&)_key1; // Fool constness
|
||||
TToken_string* key = k.rowptr(lf);
|
||||
if (key == NULL)
|
||||
{
|
||||
TLocalisamfile file(lf);
|
||||
const RecDes* recd = file.curr().rec_des(); // Descrizione del record della testata
|
||||
const KeyDes& kd = recd->Ky[0]; // Elenco dei campi della chiave 1
|
||||
TToken_string key;
|
||||
key = new TToken_string; // Creo una nuova entry
|
||||
const RecDes& recd = prefix().get_recdes(lf); // Descrizione del record della testata
|
||||
const KeyDes& kd = recd.Ky[0]; // Elenco dei campi della chiave 1
|
||||
for (int i = 0; i < kd.NkFields; i++)
|
||||
{
|
||||
const int nf = kd.FieldSeq[i] % MaxFields;
|
||||
const RecFieldDes& rf = recd->Fd[nf];
|
||||
key.add(rf.Name);
|
||||
const RecFieldDes& rf = recd.Fd[nf];
|
||||
key->add(rf.Name);
|
||||
}
|
||||
k1.add(key, lf);
|
||||
k.add(key, lf);
|
||||
}
|
||||
return k1.row(lf);
|
||||
return *key;
|
||||
}
|
||||
|
||||
bool TMailer_mask::build_key1(int lf, const TString& body, TToken_string& key) const
|
||||
@ -891,13 +941,13 @@ bool TMailer_mask::build_key1(int lf, const TString& body, TToken_string& key) c
|
||||
field = fld; field.insert("\n");
|
||||
const int start = body.find(field);
|
||||
if (start < 0)
|
||||
return FALSE;
|
||||
return false;
|
||||
const int equal = body.find('=', start);
|
||||
if (equal < 0)
|
||||
return FALSE;
|
||||
return false;
|
||||
const int stop = body.find('\n', equal);
|
||||
if (stop < 0)
|
||||
return FALSE;
|
||||
return false;
|
||||
value = body.sub(equal+1, stop);
|
||||
value.trim();
|
||||
if (value[0] == '"' && value.right(1) == "\"") // Toglie eventuali virgolette
|
||||
@ -907,7 +957,27 @@ bool TMailer_mask::build_key1(int lf, const TString& body, TToken_string& key) c
|
||||
}
|
||||
key.add(value);
|
||||
}
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMailer_mask::build_key1(const TMail_message& msg, TToken_string& key) const
|
||||
{
|
||||
TString body;
|
||||
FOR_EACH_ARRAY_ROW(msg, r, row)
|
||||
body << *row << '\n';
|
||||
|
||||
const TString& subj = msg.subject();
|
||||
int lfile = LF_TAB; // Numero logico del file
|
||||
if (isalpha(subj[0])) // Controlla se la tabella in realtà è comune ed aggiunge il simbolino %
|
||||
{
|
||||
TString4 para; para << '[' << LF_TABCOM << ']';
|
||||
if (body.find(para) > 0)
|
||||
lfile = LF_TABCOM;
|
||||
}
|
||||
else
|
||||
lfile = atoi(subj);
|
||||
|
||||
return build_key1(lfile, body, key);
|
||||
}
|
||||
|
||||
void TMailer_mask::find_redundant_messages()
|
||||
@ -931,7 +1001,7 @@ void TMailer_mask::find_redundant_messages()
|
||||
int lfile = LF_TAB; // Numero logico del file
|
||||
if (isalpha(subj[0])) // Controlla se la tabella in realtà è comune ed aggiunge il simbolino %
|
||||
{
|
||||
TString8 para; para << '[' << LF_TABCOM << ']';
|
||||
TString4 para; para << '[' << LF_TABCOM << ']';
|
||||
if (body.find(para) > 0)
|
||||
lfile = LF_TABCOM;
|
||||
}
|
||||
@ -953,20 +1023,19 @@ void TMailer_mask::save_all_lines()
|
||||
TBrowsefile_field& bf = (TBrowsefile_field&)field(F_LOG);
|
||||
TViswin& vv = bf.vis_win();
|
||||
|
||||
TSheet_field& sf = sfield(F_MESSAGES);
|
||||
TString body, msg;
|
||||
TString msg;
|
||||
|
||||
time_t tempo;
|
||||
time(&tempo);
|
||||
time_t tempo; time(&tempo);
|
||||
const struct tm* d = localtime(&tempo);
|
||||
msg.format("- Inizio elaborazione: %02d-%02d-%04d %02d:%02d:%02d",
|
||||
msg.format(FR("- Inizio elaborazione: %02d-%02d-%04d %02d:%02d:%02d"),
|
||||
d->tm_mday, d->tm_mon+1, 1900+d->tm_year,
|
||||
d->tm_hour, d->tm_min, d->tm_sec);
|
||||
vv.add_line(msg);
|
||||
|
||||
find_redundant_messages();
|
||||
|
||||
bool one_saved = FALSE;
|
||||
bool one_saved = false;
|
||||
TSheet_field& sf = sfield(F_MESSAGES);
|
||||
FOR_EACH_SHEET_ROW(sf, nrow, row)
|
||||
{
|
||||
msg.format("Messaggio %d ", nrow+1);
|
||||
@ -983,7 +1052,7 @@ void TMailer_mask::save_all_lines()
|
||||
|
||||
if (mark <= ' ')
|
||||
{
|
||||
row->get(sf.cid2index(F_BODY), body);
|
||||
TString body; row->get(sf.cid2index(F_BODY), body);
|
||||
if (body.find("[Transaction]") >= 0)
|
||||
{
|
||||
int err = 0;
|
||||
@ -991,7 +1060,7 @@ void TMailer_mask::save_all_lines()
|
||||
if (yes)
|
||||
{
|
||||
msg << "elaborato con successo";
|
||||
one_saved = TRUE;
|
||||
one_saved = true;
|
||||
}
|
||||
else
|
||||
if (err == NOT_GEST)
|
||||
@ -1070,7 +1139,7 @@ bool TMailer_mask::on_field_event(TOperable_field& o, TField_event e, long jolly
|
||||
if (e == se_query_add)
|
||||
{
|
||||
auto_save_all();
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case DLG_USER:
|
||||
@ -1080,16 +1149,16 @@ bool TMailer_mask::on_field_event(TOperable_field& o, TField_event e, long jolly
|
||||
if (!save_sheet_line(err))
|
||||
{
|
||||
if (err == NOT_TRANS)
|
||||
message_box("Messaggio ignorato in quanto transazione non riconosciuta");
|
||||
message_box(TR("Messaggio ignorato: transazione non riconosciuta"));
|
||||
else
|
||||
if (err == NOT_GEST)
|
||||
{
|
||||
TSheet_field& sf = sfield(F_MESSAGES);
|
||||
TMask& m = sf.sheet_mask();
|
||||
error_box("Definire il programma gestore del file %s", (const char*)m.get(F_SUBJECT));
|
||||
error_box(FR("Definire il programma gestore del file %s"), (const char*)m.get(F_SUBJECT));
|
||||
}
|
||||
else
|
||||
message_box("Messaggio non elaborato a causa di un errore (n.ro %d)", err);
|
||||
message_box(FR("Messaggio non elaborato a causa di un errore (n.ro %d)"), err);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1110,7 +1179,7 @@ bool TMailer_mask::on_field_event(TOperable_field& o, TField_event e, long jolly
|
||||
{
|
||||
test_delete();
|
||||
fill_messages();
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1120,7 +1189,7 @@ bool TMailer_mask::on_field_event(TOperable_field& o, TField_event e, long jolly
|
||||
if (e == fe_button)
|
||||
{
|
||||
TMask& m = o.mask();
|
||||
TArray_sheet sht(-1,-1,-4,-4,"Selezione archivio", "Codice@6R|Descrizione archivio@70");
|
||||
TArray_sheet sht(-1,-1,-4,-4,TR("Selezione archivio"), HR("Codice@6R|Descrizione archivio@70"));
|
||||
const TPrefix& pref = prefix();
|
||||
const int total = pref.items();
|
||||
if (total > 0)
|
||||
@ -1166,20 +1235,20 @@ bool TMailer_mask::on_field_event(TOperable_field& o, TField_event e, long jolly
|
||||
TBrowsefile_field& bf = (TBrowsefile_field&)field(F_LOG);
|
||||
TViswin& vv = bf.vis_win();
|
||||
vv.text().print();
|
||||
return FALSE; // Don't close
|
||||
return false; // Don't close
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
void TMailer_mask::save_sheet(TConfig& ini, short dlg, const char* var) const
|
||||
{
|
||||
TSheet_field& sf = sfield(dlg);
|
||||
FOR_EACH_SHEET_ROW(sf, r, row)
|
||||
ini.set(var, *row, NULL, TRUE, r);
|
||||
ini.set(var, *row, NULL, true, r);
|
||||
}
|
||||
|
||||
void TMailer_mask::load_sheet(TConfig& ini, short dlg, const char* var)
|
||||
@ -1196,7 +1265,7 @@ void TMailer_mask::auto_save_all()
|
||||
{
|
||||
TSheet_field& sf = sfield(F_MESSAGES);
|
||||
#ifdef DBG
|
||||
if (sf.items() > 0 && yesno_box("Si desidera eliminare i messaggi processati?"))
|
||||
if (sf.items() > 0 && yesno_box(TR("Si desidera eliminare i messaggi processati?")))
|
||||
#endif
|
||||
test_delete();
|
||||
fill_messages();
|
||||
@ -1236,6 +1305,7 @@ void TMailer_mask::save() const
|
||||
ini.set("User", get(F_USER));
|
||||
ini.set("Password", encode(get(F_PASSWORD)));
|
||||
ini.set("Timer", get(F_TIMER));
|
||||
ini.set("Log", get(F_TRACKING));
|
||||
save_sheet(ini, F_ADDRESSES, "Recipient");
|
||||
save_sheet(ini, F_PARAMS, "Filter");
|
||||
}
|
||||
@ -1247,21 +1317,20 @@ void TMailer_mask::load()
|
||||
set(F_USER, ini.get("User"));
|
||||
set(F_PASSWORD, decode(ini.get("Password")));
|
||||
set(F_TIMER, ini.get_int("Timer"));
|
||||
set(F_TRACKING, ini.get("Log"));
|
||||
load_sheet(ini, F_ADDRESSES, "Recipient");
|
||||
load_sheet(ini, F_PARAMS, "Filter");
|
||||
|
||||
_sequential = ini.get_bool("StopOnError", "ba7");
|
||||
}
|
||||
|
||||
TMailer_mask::TMailer_mask()
|
||||
: TAutomask("ba7100a"),
|
||||
_timer_id(XVT_TIMER_ERROR), _mail_semaphore(0)
|
||||
: TAutomask("ba7100a"), _timer_id(XVT_TIMER_ERROR), _mail_semaphore(0)
|
||||
{
|
||||
load();
|
||||
if (user() != ::dongle().administrator())
|
||||
{
|
||||
disable(- G_SUPERUSER);
|
||||
}
|
||||
TConfig c(CONFIG_DITTA, "ba7");
|
||||
_sequential = c.get_bool("StopOnError");
|
||||
|
||||
const bool is_super = user() == ::dongle().administrator();
|
||||
enable(-G_SUPERUSER, is_super);
|
||||
}
|
||||
|
||||
TMailer_mask::~TMailer_mask()
|
||||
@ -1294,6 +1363,6 @@ void TMailer::main_loop()
|
||||
int ba7100(int argc, char* argv[])
|
||||
{
|
||||
TMailer app;
|
||||
app.run(argc, argv, "Postino");
|
||||
app.run(argc, argv, TR("Postino"));
|
||||
return 0;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
#define F_PASSWORD 203
|
||||
#define F_MAPI 204
|
||||
#define F_TIMER 205
|
||||
#define F_TRACKING 206
|
||||
|
||||
#define F_MESSAGES 210
|
||||
#define F_ADDRESSES 211
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "ba7100a.h"
|
||||
|
||||
TOOLBAR "Toolbar" 0 -3 0 3
|
||||
TOOLBAR "Toolbar" 0 -2 0 2
|
||||
|
||||
BUTTON DLG_SAVEREC 10 2
|
||||
BEGIN
|
||||
@ -18,7 +18,7 @@ END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
PAGE "Ricezione" -1 -1 78 20
|
||||
PAGE "Ricezione" 0 0 0 -2
|
||||
|
||||
BOOLEAN F_MAPI
|
||||
BEGIN
|
||||
@ -57,9 +57,14 @@ BEGIN
|
||||
GROUP G_SUPERUSER
|
||||
END
|
||||
|
||||
SPREADSHEET F_MESSAGES 0 -2
|
||||
STRING F_TRACKING 256 55
|
||||
BEGIN
|
||||
PROMPT 0 2 ""
|
||||
PROMPT 1 2 "Log transazioni (CSV) "
|
||||
END
|
||||
|
||||
SPREADSHEET F_MESSAGES 0 -3
|
||||
BEGIN
|
||||
PROMPT 0 3 ""
|
||||
ITEM "@1"
|
||||
ITEM "Da@40"
|
||||
ITEM "Data@10"
|
||||
@ -81,7 +86,7 @@ END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
PAGE "Spedizione" -1 -1 78 20
|
||||
PAGE "Spedizione" 0 0 0 -2
|
||||
|
||||
TEXT DLG_NULL
|
||||
BEGIN
|
||||
@ -114,9 +119,9 @@ END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
PAGE "Log" -1 -1 78 20
|
||||
PAGE "Log" 0 0 0 -2
|
||||
|
||||
BROWSEFILE F_LOG 0 -3
|
||||
BROWSEFILE F_LOG -1 -2
|
||||
BEGIN
|
||||
PROMPT 0 1 ""
|
||||
END
|
||||
@ -136,9 +141,9 @@ END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
|
||||
ENDMASK
|
||||
|
||||
|
||||
PAGE "Message" -1 -1 78 19
|
||||
|
||||
BOOLEAN F_CHECKED
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include <sheet.h>
|
||||
#include <utility.h>
|
||||
|
||||
#include <direct.h>
|
||||
#include "ba7300.h"
|
||||
|
||||
class TFile_selector : public TAutomask
|
||||
@ -525,7 +524,7 @@ void TMail_flood_app::send_records(TCursor& cur)
|
||||
{
|
||||
TFilename dir; dir.tempdir();
|
||||
dir.add("transpos");
|
||||
::mkdir(dir);
|
||||
make_dir(dir);
|
||||
|
||||
const TRectype& curr = cur.curr();
|
||||
|
||||
@ -561,7 +560,7 @@ void TMail_flood_app::send_records(TCursor& cur)
|
||||
ininame << SLASH << "tr" << i << ".ini";
|
||||
::remove(ininame);
|
||||
}
|
||||
::rmdir(dir);
|
||||
xvt_fsys_rmdir(dir);
|
||||
}
|
||||
|
||||
void TMail_flood_app::fill_rows(const TRectype& parent, int logicnum, TConfig& ini) const
|
||||
|
@ -37,7 +37,7 @@ bool TInstall_SV ::install_com()
|
||||
// riconverte le macro delle date
|
||||
tabstd.dump(tempfile);
|
||||
TScanner scan(tempfile);
|
||||
FILE *dest=fopen((const char *)stdtabname,"w");
|
||||
FILE* dest = fopen(stdtabname,"w");
|
||||
while (TRUE) {
|
||||
TString &line=scan.line();
|
||||
if (line.empty()) break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user