Patch level : 12.0 904

Files correlati     : ba0
Commento            : Aggiunto controllo formato indirizzo mail da configurazione mail
This commit is contained in:
Simone Palacino 2019-11-28 15:36:51 +01:00
parent e93caf05bb
commit cf71dd1e2a

View File

@ -75,6 +75,7 @@ protected:
static bool menu_find_handler(TMask_field& f, KEY k);
static bool tree_handler(TMask_field& f, KEY k);
static bool explore_handler(TMask_field& f, KEY k);
static bool check_from_field_mail(TMask_field& f, KEY k);
bool choose_colors();
bool choose_editors();
@ -1628,6 +1629,22 @@ void enable_options_menu(bool on)
xvt_menu_update(tw);
}
bool TMenu_application::check_from_field_mail(TMask_field& f, KEY k)
{
if((k == K_ENTER || k == K_TAB) && !f.mask().field(104).get().empty())
{
// Easy check for e-mail address
const TString& addr(f.get());
int pos = addr.find('@');
if (pos != -1 && (pos = addr.find('.', pos)) == -1 || pos == -1)
{
error_box("Inserire un indirizzo e-mail. Formato non valido.");
return false;
}
}
return true;
}
bool TMenu_application::choose_colors()
{
const KEY CTLR = K_CTRL+'R';
@ -2299,6 +2316,7 @@ void TMenu_application::manage_preferred()
void TMenu_application::manage_mail()
{
TMask m("ba0100m");
m.set_handler(106, check_from_field_mail);
TConfig cfg(CONFIG_USER, "Mail");
FOR_EACH_MASK_FIELD(m, i, f) if (f->field())
f->set(f->field()->read(cfg, "Mail"));