Patch level : 4.0
Files correlati : ba7 Ricompilazione Demo : [ ] Commento : Nuovo postino con supporto con supporto protocollo di trasferimento CNP git-svn-id: svn://10.65.10.50/trunk@15507 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
15778c5f1c
commit
6538171fce
145
ba/ba7100.cpp
145
ba/ba7100.cpp
@ -1,5 +1,6 @@
|
|||||||
#include <applicat.h>
|
#include <applicat.h>
|
||||||
#include <automask.h>
|
#include <automask.h>
|
||||||
|
#include <browfile.h>
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <defmask.h>
|
#include <defmask.h>
|
||||||
#include <dongle.h>
|
#include <dongle.h>
|
||||||
@ -7,13 +8,11 @@
|
|||||||
#include <expr.h>
|
#include <expr.h>
|
||||||
#include <golem.h>
|
#include <golem.h>
|
||||||
#include <netsock.h>
|
#include <netsock.h>
|
||||||
#include <prefix.h>
|
|
||||||
#include <tabutil.h>
|
|
||||||
#include <recarray.h>
|
#include <recarray.h>
|
||||||
#include <sheet.h>
|
#include <sheet.h>
|
||||||
|
#include <tabutil.h>
|
||||||
#include <utility.h>
|
#include <utility.h>
|
||||||
#include <viswin.h>
|
#include <viswin.h>
|
||||||
#include <browfile.h>
|
|
||||||
|
|
||||||
#include "ba7.h"
|
#include "ba7.h"
|
||||||
#include "ba7100a.h"
|
#include "ba7100a.h"
|
||||||
@ -24,8 +23,7 @@
|
|||||||
// TConfig utilities
|
// TConfig utilities
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
const 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)
|
||||||
const char* var, const char* val)
|
|
||||||
{
|
{
|
||||||
TConfig ini(cfg, para);
|
TConfig ini(cfg, para);
|
||||||
const TString& prev = ini.get(var);
|
const TString& prev = ini.get(var);
|
||||||
@ -480,6 +478,7 @@ protected:
|
|||||||
|
|
||||||
void track(const TMail_message& msg, const TString& app, const TString& action, int err);
|
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);
|
bool exec_app(int & err, const TString& appname, TMail_message & msg);
|
||||||
|
void scan_dir(const TFilename& dir, TMail_messages& box) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void test_delete();
|
void test_delete();
|
||||||
@ -499,20 +498,24 @@ void TMailer_mask::test_delete()
|
|||||||
{
|
{
|
||||||
TWait_cursor hourglass;
|
TWait_cursor hourglass;
|
||||||
|
|
||||||
xvtil_statbar_set(TR("Eliminazione messaggi POP3..."));
|
xvtil_statbar_set(TR("Eliminazione messaggi..."));
|
||||||
do_events();
|
do_events();
|
||||||
|
|
||||||
|
TSheet_field& sf = sfield(F_MESSAGES);
|
||||||
|
const int sender_pos = sf.cid2index(F_SENDER);
|
||||||
|
const int mailer_pos = sf.cid2index(F_MAILER);
|
||||||
|
const int msgid_pos = sf.cid2index(F_ID);
|
||||||
TString4 mailer;
|
TString4 mailer;
|
||||||
TString16 id;
|
TString id;
|
||||||
|
|
||||||
TMail_messages mapidel; // Lista dei messaggi MAPI da cancellare
|
TMail_messages mapidel; // Lista dei messaggi MAPI da cancellare
|
||||||
|
|
||||||
TMail_box mailbox;
|
TMail_box mailbox;
|
||||||
TSheet_field& sf = sfield(F_MESSAGES);
|
|
||||||
FOR_EACH_SHEET_ROW_BACK(sf, nrow, row) if (*row->get(0) == 'X')
|
FOR_EACH_SHEET_ROW_BACK(sf, nrow, row) if (*row->get(0) == 'X')
|
||||||
{
|
{
|
||||||
row->get(sf.cid2index(F_MAILER), mailer);
|
row->get(mailer_pos, mailer);
|
||||||
row->get(sf.cid2index(F_ID), id);
|
row->get(msgid_pos, id);
|
||||||
|
bool deleted = false;
|
||||||
if (mailer == "POP3")
|
if (mailer == "POP3")
|
||||||
{
|
{
|
||||||
if (!mailbox.ok())
|
if (!mailbox.ok())
|
||||||
@ -520,18 +523,39 @@ void TMailer_mask::test_delete()
|
|||||||
if (!mailbox.logon(get(F_SERVER), get(F_USER), get(F_PASSWORD)))
|
if (!mailbox.logon(get(F_SERVER), get(F_USER), get(F_PASSWORD)))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!mailbox.remove(id))
|
deleted = mailbox.remove(id);
|
||||||
error_box(FR("Impossibile cancellare il messaggio POP3 %s"), (const char*)id);
|
} else
|
||||||
}
|
if (mailer == "CNP")
|
||||||
else
|
{
|
||||||
|
TFilename file;
|
||||||
|
row->get(sender_pos, file); // Cartella di provenienza
|
||||||
|
file.add(id);
|
||||||
|
file.ext("ini");
|
||||||
|
deleted = xvt_fsys_removefile(file) != 0;
|
||||||
|
} else
|
||||||
|
if (mailer == "MAPI")
|
||||||
{
|
{
|
||||||
TMail_message* msg = new TMail_message("");
|
TMail_message* msg = new TMail_message("");
|
||||||
msg->set_id(id);
|
msg->set_id(id);
|
||||||
mapidel.add(msg);
|
mapidel.add(msg);
|
||||||
|
deleted = true;
|
||||||
|
}
|
||||||
|
if (deleted)
|
||||||
|
{
|
||||||
|
_box.destroy(nrow);
|
||||||
|
sf.destroy(nrow);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TString err = TR("Impossibile cancellare il messaggio");
|
||||||
|
err << ' ' << id;
|
||||||
|
xvtil_statbar_set(err);
|
||||||
|
do_events();
|
||||||
|
beep(2); // Error sound
|
||||||
}
|
}
|
||||||
sf.destroy(nrow);
|
|
||||||
}
|
}
|
||||||
mailbox.logoff();
|
if (mailbox.ok())
|
||||||
|
mailbox.logoff();
|
||||||
|
|
||||||
if (mapidel.items() > 0)
|
if (mapidel.items() > 0)
|
||||||
{
|
{
|
||||||
@ -579,13 +603,67 @@ void TMailer_mask::expand_tabs(TMail_message& msg, const int tab) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TMailer_mask::scan_dir(const TFilename& dir, TMail_messages& box) const
|
||||||
|
{
|
||||||
|
TString_array msg;
|
||||||
|
TFilename mask(dir);
|
||||||
|
mask.add("*.ini");
|
||||||
|
::list_files(mask, msg);
|
||||||
|
|
||||||
|
TString subject, text, strdata;
|
||||||
|
TToken_string id(_MAX_FNAME, '_');
|
||||||
|
FOR_EACH_ARRAY_ROW(msg, r, row)
|
||||||
|
{
|
||||||
|
const int size = fsize(*row);
|
||||||
|
if (size > 128 && size < 48*1024)
|
||||||
|
{
|
||||||
|
char* buffer = text.get_buffer(size);
|
||||||
|
TScanner scanner(*row);
|
||||||
|
scanner.read(buffer, size);
|
||||||
|
buffer[size] = '\0';
|
||||||
|
|
||||||
|
subject.cut(0);
|
||||||
|
int parc = text.find(']'); // fine primo paragrafo
|
||||||
|
if (parc > 0)
|
||||||
|
{
|
||||||
|
int para = text.find('[', parc+1);
|
||||||
|
if (para > 0)
|
||||||
|
{
|
||||||
|
parc = text.find(']', para+1);
|
||||||
|
if (parc > 0)
|
||||||
|
subject = text.sub(para+1, parc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (subject.full())
|
||||||
|
{
|
||||||
|
xvt_fsys_parse_pathname (*row, NULL, NULL, id.get_buffer(), NULL, NULL);
|
||||||
|
|
||||||
|
TMail_message* msg = new TMail_message(user(), subject, text, dir);
|
||||||
|
msg->set_id(id);
|
||||||
|
|
||||||
|
if (id.items() == 3) // Nome file in formato YYMMDD_HHMMSS_NN.ini
|
||||||
|
{
|
||||||
|
strdata = id.get(0); strdata.insert("20");
|
||||||
|
const TDate data(strdata);
|
||||||
|
const long hhmmss = id.get_long(1);
|
||||||
|
msg->set_date_time(data, hhmmss);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
msg->set_date_time(TDate(TODAY));
|
||||||
|
|
||||||
|
box.add(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int TMailer_mask::fill_messages()
|
int TMailer_mask::fill_messages()
|
||||||
{
|
{
|
||||||
TWait_cursor hourglass;
|
TWait_cursor hourglass;
|
||||||
|
|
||||||
TString server(get(F_SERVER));
|
TFilename server(get(F_SERVER));
|
||||||
TString user(get(F_USER));
|
TString16 user(get(F_USER));
|
||||||
TString password(get(F_PASSWORD));
|
TString16 password(get(F_PASSWORD));
|
||||||
TMail_box mailbox;
|
TMail_box mailbox;
|
||||||
if (mailbox.default_params(server, user, password))
|
if (mailbox.default_params(server, user, password))
|
||||||
{
|
{
|
||||||
@ -603,11 +681,23 @@ int TMailer_mask::fill_messages()
|
|||||||
totmapi = _box.get();
|
totmapi = _box.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
xvtil_statbar_set(TR("Ricezione messaggi POP3..."));
|
TString4 mailer;
|
||||||
do_events();
|
if (isalpha(server[0]) && server[1] == ':' && is_slash(server[2]) && server.exist())
|
||||||
mailbox.logon(server, user, password);
|
{
|
||||||
mailbox.get(_box);
|
mailer = "CNP";
|
||||||
mailbox.logoff();
|
xvtil_statbar_set(TR("Ricezione messaggi CNP ..."));
|
||||||
|
do_events();
|
||||||
|
scan_dir(server, _box);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mailer = "POP3";
|
||||||
|
xvtil_statbar_set(TR("Ricezione messaggi POP3..."));
|
||||||
|
do_events();
|
||||||
|
mailbox.logon(server, user, password);
|
||||||
|
mailbox.get(_box);
|
||||||
|
mailbox.logoff();
|
||||||
|
}
|
||||||
|
|
||||||
TSheet_field& sf = sfield(F_MESSAGES);
|
TSheet_field& sf = sfield(F_MESSAGES);
|
||||||
sf.destroy();
|
sf.destroy();
|
||||||
@ -641,8 +731,11 @@ int TMailer_mask::fill_messages()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
row.add("POP3", sf.cid2index(F_MAILER));
|
row.add(mailer, sf.cid2index(F_MAILER));
|
||||||
row.add(m-totmapi+1, sf.cid2index(F_ID));
|
if (mailer == "CNP")
|
||||||
|
row.add(msg.id(), sf.cid2index(F_ID));
|
||||||
|
else
|
||||||
|
row.add(m-totmapi+1, sf.cid2index(F_ID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sf.force_update();
|
sf.force_update();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user