Fax server
git-svn-id: svn://10.65.10.50/trunk@3258 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
4bb131e5cf
commit
620fe209fc
131
ba/bafax.cpp
131
ba/bafax.cpp
@ -61,6 +61,8 @@ class TFax_data : public TAssoc_array
|
||||
{
|
||||
public:
|
||||
void set(const char* key, const char* value);
|
||||
const char* get(const char* key) const;
|
||||
|
||||
void set_file(const char* file) { set("FILELIST", file); }
|
||||
char* get_char_star(const char* name) const;
|
||||
|
||||
@ -85,8 +87,24 @@ void TFax_data::set(const char* key, const char* value)
|
||||
add(key, TString(value), TRUE);
|
||||
}
|
||||
|
||||
char* TFax_data::get_char_star(const char* name) const
|
||||
const char* TFax_data::get(const char* key) const
|
||||
{
|
||||
const TString* s = (const TString*)((TAssoc_array*)this)->objptr(key);
|
||||
return s ? (const char*)*s : "";
|
||||
}
|
||||
|
||||
|
||||
char* TFax_data::get_char_star(const char* name) const
|
||||
{
|
||||
if (stricmp(name, "FULLDESTFAX") == 0)
|
||||
{
|
||||
TString num(24);
|
||||
num << get("DIALING");
|
||||
num << get("PREFIX");
|
||||
num << get("DESTFAX");
|
||||
((TFax_data*)this)->set(name, num);
|
||||
}
|
||||
|
||||
const TString* s = (const TString*)((TAssoc_array*)this)->objptr(name);
|
||||
return s ? (char*)(const char*)*s : "";
|
||||
}
|
||||
@ -238,7 +256,7 @@ protected:
|
||||
bool exec_command(const TString& comm, TToken_string& args);
|
||||
void handle_fax_message(word wparam, long lparam);
|
||||
void handle_drop_files(word wparam);
|
||||
|
||||
|
||||
// @cmember Ritorna TRUE se il server non e' in attesa di nessun lavoro
|
||||
bool can_close() const;
|
||||
|
||||
@ -262,6 +280,8 @@ public:
|
||||
bool set_destination(const TString& tipo, const TString& codice, TFax_data& data) const;
|
||||
bool push_destination(const TString& tipo, const TString& codice);
|
||||
|
||||
void auto_configure();
|
||||
|
||||
TDDE_fax();
|
||||
virtual ~TDDE_fax();
|
||||
};
|
||||
@ -294,12 +314,23 @@ public:
|
||||
|
||||
TFax_mask::TFax_mask(TDDE_fax* fax)
|
||||
: TMask("bafax01"), _fax(fax)
|
||||
{
|
||||
{
|
||||
const char* pippe[] = { "DESTFAX", "FROMFAX", "PREFIX", NULL };
|
||||
|
||||
for (int i = fields()-1; i >= 0; i--)
|
||||
{
|
||||
TMask_field& f = fld(i);
|
||||
if (f.in_group(1))
|
||||
{
|
||||
f.set_handler(code_handler);
|
||||
const TFieldref* c = f.field();
|
||||
if (c != NULL)
|
||||
{
|
||||
for (int p = 0; pippe[p] != NULL; p++)
|
||||
if (c->name() == pippe[p])
|
||||
f.allow_pipe();
|
||||
}
|
||||
}
|
||||
else
|
||||
if (f.in_group(2))
|
||||
f.set_handler(button_handler);
|
||||
@ -479,6 +510,7 @@ bool TLog_mask::log_notify(TSheet_field& s, int, KEY k)
|
||||
const char* strid = s.row(i).get(0);
|
||||
unsigned long id; sscanf(strid, "%lu", &id);
|
||||
m._fax->log_delete(log, id);
|
||||
do_events();
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
@ -569,31 +601,29 @@ TDDE_fax::TDDE_fax()
|
||||
: _pappinfo(NULL), _log_mask(NULL), _fax_mask(NULL),
|
||||
_close_when_idle(FALSE)
|
||||
{
|
||||
/*
|
||||
const bool already = initiate(get_app_name(), "");
|
||||
if (already)
|
||||
{
|
||||
terminate();
|
||||
xvt_statbar_set("C'e' gia' un server in esecuzione");
|
||||
beep();
|
||||
return;
|
||||
}
|
||||
else
|
||||
*/
|
||||
_pappinfo = FaxRegisterApp(get_app_name(), hwnd());
|
||||
if (_pappinfo)
|
||||
{
|
||||
start_server(); // Inizia DDE server
|
||||
FaxSubscribe(_pappinfo, SUBSCRIBE_LOG_ALL); // Connettiti a Faxman
|
||||
update_all_logs(); // Aggiorna tutte le code
|
||||
DragAcceptFiles((HWND)hwnd(), TRUE); // Attiva Drag'n'drop
|
||||
}
|
||||
else
|
||||
{
|
||||
_pappinfo = FaxRegisterApp(get_app_name(), hwnd());
|
||||
if (_pappinfo)
|
||||
{
|
||||
DragAcceptFiles((HWND)hwnd(), TRUE); // Attiva Drag'n'drop
|
||||
|
||||
FaxSubscribe(_pappinfo, SUBSCRIBE_LOG_ALL); // Connettiti a FAxman
|
||||
update_all_logs();
|
||||
|
||||
start_server(); // Inizia DDE server
|
||||
}
|
||||
else
|
||||
{
|
||||
xvt_statbar_set("Impossibile connettersi a FAXMAN");
|
||||
beep();
|
||||
}
|
||||
}
|
||||
xvt_statbar_set("Impossibile connettersi a FAXMAN");
|
||||
beep();
|
||||
}
|
||||
}
|
||||
|
||||
TDDE_fax::~TDDE_fax()
|
||||
@ -669,6 +699,8 @@ bool TDDE_fax::do_execute(word id, const TString& cmd)
|
||||
return ok;
|
||||
}
|
||||
|
||||
// Genera il nome di un file temporaneo e gli cambia l'estensione:
|
||||
// se esiste gia' ripete il ciclo.
|
||||
void TDDE_fax::choose_temp_name(TFilename& name) const
|
||||
{
|
||||
do
|
||||
@ -815,9 +847,6 @@ bool TDDE_fax::send_next_fax()
|
||||
#endif
|
||||
|
||||
tw.maximize();
|
||||
|
||||
if (_port.first_one() < 0)
|
||||
warning_box("Non c'e nessun modem-fax collegato");
|
||||
|
||||
CHECK(_fax_mask == NULL, "Double fax mask");
|
||||
_fax_mask = new TFax_mask(this);
|
||||
@ -835,7 +864,7 @@ bool TDDE_fax::send_next_fax()
|
||||
PSEND_FAX sf = &_send_fax;
|
||||
FaxInitSendStruct(_pappinfo, sf);
|
||||
|
||||
sf->szDestFax = data.get_char_star("DESTFAX");
|
||||
sf->szDestFax = data.get_char_star("FULLDESTFAX");
|
||||
sf->szDestName = data.get_char_star("DESTNAME");
|
||||
sf->szToCompany = data.get_char_star("DESTFIRM");
|
||||
|
||||
@ -954,29 +983,31 @@ void TDDE_fax::update_all_logs()
|
||||
_failed.destroy();
|
||||
_complete.destroy();
|
||||
|
||||
if (FaxLogInit(_pappinfo, SUBSCRIBE_LOG_PENDING) < MAXITERATORS) {
|
||||
while (FaxLogNext(_pappinfo, &tmpsf) == LOGERR_CONTINUEIT) {
|
||||
if (FaxLogInit(_pappinfo, SUBSCRIBE_LOG_PENDING) < MAXITERATORS)
|
||||
{
|
||||
while (FaxLogNext(_pappinfo, &tmpsf) == LOGERR_CONTINUEIT)
|
||||
do_custom_message(WM_FAXMSG, FAXLOGADD, (LPARAM)&tmpsf);
|
||||
}
|
||||
}
|
||||
|
||||
if (FaxLogInit(_pappinfo, SUBSCRIBE_LOG_SENDING) < MAXITERATORS) {
|
||||
while (FaxLogNext(_pappinfo, &tmpsf) == LOGERR_CONTINUEIT) {
|
||||
if (FaxLogInit(_pappinfo, SUBSCRIBE_LOG_SENDING) < MAXITERATORS)
|
||||
{
|
||||
while (FaxLogNext(_pappinfo, &tmpsf) == LOGERR_CONTINUEIT)
|
||||
do_custom_message(WM_FAXMSG, FAXLOGADD, (LPARAM)&tmpsf);
|
||||
}
|
||||
}
|
||||
|
||||
if (FaxLogInit(_pappinfo, SUBSCRIBE_LOG_COMPLETE) < MAXITERATORS) {
|
||||
while (FaxLogNext(_pappinfo, &tmpsf) == LOGERR_CONTINUEIT) {
|
||||
if (FaxLogInit(_pappinfo, SUBSCRIBE_LOG_COMPLETE) < MAXITERATORS)
|
||||
{
|
||||
while (FaxLogNext(_pappinfo, &tmpsf) == LOGERR_CONTINUEIT)
|
||||
do_custom_message(WM_FAXMSG, FAXLOGADD, (LPARAM)&tmpsf);
|
||||
}
|
||||
}
|
||||
|
||||
if (FaxLogInit(_pappinfo, SUBSCRIBE_LOG_FAILED) < MAXITERATORS) {
|
||||
while (FaxLogNext(_pappinfo, &tmpsf) == LOGERR_CONTINUEIT) {
|
||||
if (FaxLogInit(_pappinfo, SUBSCRIBE_LOG_FAILED) < MAXITERATORS)
|
||||
{
|
||||
while (FaxLogNext(_pappinfo, &tmpsf) == LOGERR_CONTINUEIT)
|
||||
do_custom_message(WM_FAXMSG, FAXLOGADD, (LPARAM)&tmpsf);
|
||||
}
|
||||
}
|
||||
|
||||
FaxEnumDevices(_pappinfo);
|
||||
}
|
||||
|
||||
void TDDE_fax::update_log(int log)
|
||||
@ -997,6 +1028,13 @@ void TDDE_fax::log_delete(int log, unsigned long id)
|
||||
FaxLogDelete(_pappinfo, id, log);
|
||||
}
|
||||
|
||||
void TDDE_fax::auto_configure()
|
||||
{
|
||||
const int err = FaxAddDevice(_pappinfo, 0);
|
||||
if (err == 0)
|
||||
error_box("Impossibile trovare il server Faxman");
|
||||
}
|
||||
|
||||
bool TDDE_fax::run_mask()
|
||||
{
|
||||
const bool ok = _log_mask == NULL;
|
||||
@ -1178,10 +1216,12 @@ bool TFax_server::create()
|
||||
const bool ok = _fax->ok();
|
||||
if (ok)
|
||||
{
|
||||
TTemp_window w(TASK_WIN);
|
||||
w.iconize();
|
||||
bool show_status = FALSE;
|
||||
|
||||
if (argc() > 3)
|
||||
if (argc() == 2)
|
||||
show_status = stricmp(argv(1), "-S") == 0;
|
||||
|
||||
if (argc() > 2)
|
||||
{
|
||||
const TString tipo = argv(1);
|
||||
const TString codice = argv(2);
|
||||
@ -1201,6 +1241,16 @@ bool TFax_server::create()
|
||||
msg = mb.next_s(topic);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_status)
|
||||
{
|
||||
dispatch_e_menu(MENU_ITEM(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
TTemp_window w(TASK_WIN);
|
||||
w.iconize();
|
||||
}
|
||||
}
|
||||
else
|
||||
destroy(); // Non verrebbe mai chiamata
|
||||
@ -1226,6 +1276,9 @@ bool TFax_server::menu(MENU_TAG mt)
|
||||
case MENU_ITEM(1):
|
||||
_fax->run_mask();
|
||||
break;
|
||||
case MENU_ITEM(2):
|
||||
_fax->auto_configure();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
11
ba/bafax.url
11
ba/bafax.url
@ -1,6 +1,13 @@
|
||||
#define APPNAME EASYFAX
|
||||
#define QAPPNAME "EASYFAX"
|
||||
|
||||
#include <default.url>
|
||||
|
||||
MENU TASK_MENUBAR
|
||||
SUBMENU MENU_FILE "~File"
|
||||
ITEM MENU_ITEM(1) "~Stato"
|
||||
SUBMENU MENU_FILE "~File"
|
||||
SUBMENU BAR_ITEM(1) "~Modem/Fax"
|
||||
|
||||
MENU BAR_ITEM(1)
|
||||
ITEM MENU_ITEM(1) "~Stato"
|
||||
ITEM MENU_ITEM(2) "~Azzera"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user