#include #include "internal.h" #include "mailconf.m" static MAILCONF_HELP_FILE help_milters ("milters"); PUBLIC MILTER::MILTER( const char *_name, const char *_port, const char *_flags) { name = _name; port = _port; flags = _flags; } PUBLIC MILTER::MILTER() { port = "unix:/var/run"; flags = "r"; } PUBLIC int MILTER::edit() { int ret = -1; DIALOG dia; dia.newf_str (MSG_U(F_MILTERNAME,"Mail filter name"),name); dia.last_noempty(); dia.newf_str (MSG_U(F_MILTERPORT,"Listen on port"),port); dia.last_noempty(); dia.newf_str (MSG_U(F_MILTERFLAGS,"Flags"),flags); int nof = 0; while (1){ MENU_STATUS code = dia.edit(MSG_U(T_MILTER,"One mail filter") ,"",help_milters,nof ,MENUBUT_CANCEL|MENUBUT_ACCEPT|MENUBUT_DEL); if (code == MENU_CANCEL || code == MENU_ESCAPE){ break; }else if (code == MENU_DEL){ ret = 1; break; }else if (code == MENU_ACCEPT){ ret = 0; break; } } return ret; } /* Return != 0 if any modification done */ PUBLIC int MILTERS::edit(MAILCONF &conf) { glocal int ret = 0; glocal MAILCONF *conf = &conf; glocal MILTERS *tb = this; (MSG_U(T_MILTERS,"Mail filters") ,MSG_U(I_MILTERS ,"This is the list of currently configured\n" "mail filters.") ,help_milters); newf_head (MSG_U(H_MILTERS,"Name\tSocket\tFlags")); addwhat (MSG_U(I_ADDMILT,"A new mail filter")); sortable(); sortpolicy ("aaa"); for (int i=0; isize(); i++){ MILTER *m = glocal.tb->getitem(i); new_menuitemf (m->name.get(),"%s\t%s",m->port.get(),m->flags.get()); } MILTER *m = glocal.tb->getitem(no); int ok = m->edit(); if (ok >= 0){ if (ok==1){ glocal.tb->remove_del(m); } glocal.ret |= glocal.conf->write() != -1; } MILTER *m = new MILTER; int ok = m->edit(); if (ok == 0){ glocal.tb->add (m); glocal.ret |= glocal.conf->write() != -1; }else{ delete m; } return glocal.ret; }