Patch level : aga 2.0 patch 335

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Riportata la versione Partners 2.0 patch 335


git-svn-id: svn://10.65.10.50/trunk@10496 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2002-09-13 14:56:23 +00:00
parent e4c4b79fbe
commit 6e0d5b4275
49 changed files with 1381 additions and 851 deletions

View File

@ -6,6 +6,7 @@
#include <config.h> #include <config.h>
#include <controls.h> #include <controls.h>
#include <currency.h> #include <currency.h>
#include <diction.h>
#include <dongle.h> #include <dongle.h>
#include <execp.h> #include <execp.h>
#include <image.h> #include <image.h>
@ -358,6 +359,7 @@ TColor_mask::TColor_mask()
TConfig color(CONFIG_USER, "Colors"); TConfig color(CONFIG_USER, "Colors");
_color = color.list_variables(); _color = color.list_variables();
set(113, color.get_bool("Campi3D") ? "X" : ""); set(113, color.get_bool("Campi3D") ? "X" : "");
set(115, color.get_bool("SmallIcons") ? "X" : "");
} }
PNT TColor_mask::log2dev(long x, long y) const PNT TColor_mask::log2dev(long x, long y) const
@ -439,6 +441,7 @@ void TColor_mask::save_colors()
FOR_EACH_ASSOC_STRING(_color, obj, key, str) FOR_EACH_ASSOC_STRING(_color, obj, key, str)
colors.set(key, str); colors.set(key, str);
colors.set("Campi3D", get_bool(113) ? "X" : ""); colors.set("Campi3D", get_bool(113) ? "X" : "");
colors.set("SmallIcons", get_bool(115) ? "X" : "");
} }
COLOR TColor_mask::get_color_entry(const char* name) const COLOR TColor_mask::get_color_entry(const char* name) const
@ -685,6 +688,7 @@ void TMenuitem::create(const char* t)
start = get_next_string(t, start, _caption, brace); start = get_next_string(t, start, _caption, brace);
start = get_next_string(t, start, _action, _type); start = get_next_string(t, start, _action, _type);
start = get_next_string(t, start, flags, brace); start = get_next_string(t, start, flags, brace);
_caption = dictionary_translate(_caption);
for (int i = flags.len()-1; i >= 0; i--) for (int i = flags.len()-1; i >= 0; i--)
{ {
@ -874,7 +878,10 @@ void TSubmenu::read(TScanner& scanner)
char brace; char brace;
if (line.compare("Caption", 7, TRUE) == 0) if (line.compare("Caption", 7, TRUE) == 0)
get_next_string(line, 8, _caption, brace); else {
get_next_string(line, 8, _caption, brace);
_caption = dictionary_translate(_caption);
} else
if (line.compare("Module", 6, TRUE) == 0) if (line.compare("Module", 6, TRUE) == 0)
{ {
const int equal = line.find('='); const int equal = line.find('=');
@ -1109,7 +1116,7 @@ TImage& TMenu::image(const char* name)
{ {
image = (TTimed_image*)_images.objptr(_default_bmp); image = (TTimed_image*)_images.objptr(_default_bmp);
if (image == NULL) if (image == NULL)
fatal_box("Impossibile trovare l'immagine %s", (const char*)_default_bmp); fatal_box("%s %s", TR("Impossibile trovare l'immagine"), (const char*)_default_bmp);
} }
if (_images.items() > 3) if (_images.items() > 3)
@ -1317,13 +1324,13 @@ int TMenu_application::do_level()
mask.disable(id); mask.disable(id);
} }
TEdit_field& ef = mask.add_string(DLG_USER, 0, "Cerca ", 1, -3, 50, "", 50); TEdit_field& ef = mask.add_string(DLG_USER, 0, PR("Cerca "), 1, -3, 50, "", 50);
ef.set_handler(menu_find_handler); ef.set_handler(menu_find_handler);
const bool top = _menu.at_top(); const bool top = _menu.at_top();
TButton_field& bf = mask.add_button(DLG_QUIT, 0, "Fine", -12, -1, bwidth, 2); TButton_field& bf = mask.add_button(DLG_QUIT, 0, TR("Fine"), -12, -1, bwidth, 2);
if (!top) if (!top)
mask.add_button(DLG_CANCEL, 0, "Menu precedente", -22, -1, bwidth, 2); mask.add_button(DLG_CANCEL, 0, TR("Menu precedente"), -22, -1, bwidth, 2);
mask.first_focus(101+_menu.selected()); mask.first_focus(101+_menu.selected());
@ -1360,10 +1367,9 @@ void TMenu_application::test_temp()
TString_array files; TString_array files;
const int count = list_files(dir, files); const int count = list_files(dir, files);
if (count > 0 && yesno_box("Cancellare %d file temporane%c in %s?", if (count > 0 && yesno_box(TR("Cancellare tutti i file temporanei in %s?"), dir.path()))
count, (count > 1) ? 'i' : 'o', dir.path()))
{ {
TProgind bar(count, "Cancellazione file temporanei", TRUE, TRUE); TProgind bar(count, TR("Cancellazione file temporanei"), TRUE, TRUE);
for (int i = count-1; i >= 0; i--) for (int i = count-1; i >= 0; i--)
{ {
if (bar.iscancelled()) break; if (bar.iscancelled()) break;
@ -1475,8 +1481,9 @@ bool TMenu_application::check_user()
ok = !users.get_bool("CONNECTED"); ok = !users.get_bool("CONNECTED");
if (!ok) if (!ok)
{ {
ok = yesno_box("L'utente %s risulta essere gia' collegato\n" ok = yesno_box("%s\n%s",
"Si desidera continuare ugualmente?", (const char*)utente); TR("L'utente risulta essere già collegato"),
TR("Si desidera continuare ugualmente?"));
} }
if (ok) if (ok)
@ -1485,15 +1492,15 @@ bool TMenu_application::check_user()
users.read(_isequal); users.read(_isequal);
if (users.get("AUTSTR") == "CONVERTING") if (users.get("AUTSTR") == "CONVERTING")
{ {
TString msg = "E' in corso una conversione archivi:\n"; TString msg; msg << TR("E' in corso una conversione archivi") << ":\n";
if (utente == dongle().administrator()) if (utente == dongle().administrator())
{ {
msg << "Si desidera continuare ugualmente?"; msg << TR("Si desidera continuare ugualmente?");
ok = yesno_box(msg); ok = yesno_box(msg);
} }
else else
{ {
msg << "Accesso negato."; msg << TR("Accesso negato.");
ok = error_box(msg); ok = error_box(msg);
} }
} }
@ -1505,12 +1512,12 @@ bool TMenu_application::check_user()
dongle().logout(); dongle().logout();
ok = get_serial_number() >= 0; ok = get_serial_number() >= 0;
if (!ok) if (!ok)
error_box("Probabilmente e' stato superato il numero massimo di utenti"); error_box(TR("Probabilmente e' stato superato il numero massimo di utenti"));
} }
} }
else else
{ {
error_box("Utente e/o password errata:\nfare attenzione alle maiuscole"); error_box(TR("Utente e/o password errata: fare attenzione alle maiuscole"));
m.set(F_PASSWORD,""); m.set(F_PASSWORD,"");
} }
@ -1602,7 +1609,7 @@ bool TMenu_application::test_programs()
remote_name.add("install.ini"); remote_name.add("install.ini");
if (remote_name.exist()) if (remote_name.exist())
{ {
TProgind pi(3, "Controllo aggiornamento programmi", FALSE, TRUE); TProgind pi(3, TR("Controllo aggiornamento programmi"), FALSE, TRUE);
TConfig remote_install(remote_name, "Main"); TConfig remote_install(remote_name, "Main");
TAssoc_array my_modules, his_modules; TAssoc_array my_modules, his_modules;
pi.addstatus(1); pi.addstatus(1);
@ -1637,7 +1644,7 @@ bool TMenu_application::test_programs()
if (more) if (more)
break; break;
if (dangerous.empty() || if (dangerous.empty() ||
(!more && !yesno_box("Si desidera aggiornare i moduli adesso?"))) (!more && !yesno_box(TR("Si desidera aggiornare i moduli adesso?"))))
break; break;
app.run(FALSE, TRUE, TRUE, TRUE); app.run(FALSE, TRUE, TRUE, TRUE);
more = TRUE; // ricontrolla more = TRUE; // ricontrolla
@ -1654,12 +1661,12 @@ bool TMenu_application::create()
#ifdef _DEMO_ #ifdef _DEMO_
{ {
TMask w("ATTENZIONE", 1, 68, 12); TMask w(TR("ATTENZIONE"), 1, 68, 12);
w.add_static(DLG_NULL, 0 ,"@bATTENZIONE" , 30 , 1); w.add_static(DLG_NULL, 0 , PR("@bATTENZIONE") , 30 , 1);
w.add_static(DLG_NULL, 0 ,"Questo programma è in versione dimostrativa." , 1 , 3); w.add_static(DLG_NULL, 0 , TR("Questo programma è in versione dimostrativa.") , 1 , 3);
w.add_static(DLG_NULL, 0 ,"Non si possono memorizzare date con mese successivo a Marzo." , 1 , 5); w.add_static(DLG_NULL, 0 , TR("Non si possono memorizzare date con mese successivo a Marzo.") , 1 , 5);
w.add_static(DLG_NULL, 0 ,"Il programma funziona circa per due ore ogni giorno." , 1 , 7); w.add_static(DLG_NULL, 0 , TR("Il programma funziona circa per due ore ogni giorno.") , 1 , 7);
w.add_static(DLG_NULL, 0 ,"Il numero di registrazioni è stato limitato ad un migliaio." , 1 , 9); w.add_static(DLG_NULL, 0 , TR("Il numero di registrazioni è stato limitato ad un migliaio.") , 1 , 9);
w.add_button(DLG_OK, 0, "", -11, -1, 10, 2); w.add_button(DLG_OK, 0, "", -11, -1, 10, 2);
w.run(); w.run();
} }
@ -1767,7 +1774,7 @@ HIDDEN bool browse_file_handler(TMask_field& f, KEY k)
DIRECTORY dir; DIRECTORY dir;
xvt_fsys_get_dir(&dir); xvt_fsys_get_dir(&dir);
const int err = xvt_dm_post_file_open(&fs, "Selezione programma"); const int err = xvt_dm_post_file_open(&fs, TR("Selezione programma"));
xvt_fsys_set_dir(&dir); xvt_fsys_set_dir(&dir);
if (err == FL_OK) if (err == FL_OK)
{ {
@ -1861,18 +1868,17 @@ HIDDEN bool study_handler(TMask_field& f, KEY k)
path.add("com"); path.add("com");
path.add("dir.gen"); path.add("dir.gen");
if (!path.exist()) if (!path.exist())
ok = f.error_box("La directory %s non e' uno studio valido!", ok = f.error_box("%s %s", (const char*)f.get(), TR("non e' uno studio valido!"));
(const char*)f.get());
} }
return ok; return ok;
} }
bool TMenu_application::choose_study() bool TMenu_application::choose_study()
{ {
TMask m("Scelta studio", 1, 60, 5); TMask m(TR("Scelta studio"), 1, 60, 5);
m.add_button(DLG_OK, 0, "", -12, -1, 10, 2); m.add_button(DLG_OK, 0, "", -12, -1, 10, 2);
m.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2); m.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2);
m.add_string(DLG_USER, 0, "Studio ", 1, 1, 50); m.add_string(DLG_USER, 0, PR("Studio "), 1, 1, 50);
m.set_handler(DLG_USER, study_handler); m.set_handler(DLG_USER, study_handler);
m.set(DLG_USER, prefix().get_studio()); m.set(DLG_USER, prefix().get_studio());
bool ok = m.run() == K_ENTER; bool ok = m.run() == K_ENTER;
@ -2381,7 +2387,7 @@ void TMenu_application::add_to_preferred()
} }
} }
else else
error_box("Non e' possibile memorizzare piu' di %d preferenze", maxpref); error_box(TR("Non e' possibile memorizzare piu' di %d preferenze"), maxpref);
} }
class TPreferred_mask : public TAutomask class TPreferred_mask : public TAutomask
@ -2498,15 +2504,15 @@ int TMenu_application::do_tree()
tree_fld.set_handler(tree_handler); tree_fld.set_handler(tree_handler);
RCT rct; tree_fld.get_rect(rct); RCT rct; tree_fld.get_rect(rct);
TMask_field& sf = mask.add_static(DLG_NULL, 0, "Cerca", -2, 0); TMask_field& sf = mask.add_static(DLG_NULL, 0, TR("Cerca"), -2, 0);
TEdit_field& ef = mask.add_string(DLG_USER, 0, "", -2, 1, 50, "", bwidth); TEdit_field& ef = mask.add_string(DLG_USER, 0, "", -2, 1, 50, "", bwidth);
ef.set_handler(tree_find_handler); ef.set_handler(tree_find_handler);
TButton_field& mf = mask.add_button(102, 0, "Menu principale", -1, 2, bwidth, 2); TButton_field& mf = mask.add_button(102, 0, TR("Menu Principale"), -1, 2, bwidth, 2);
mf.set_handler(tree_shrink_handler); mf.set_handler(tree_shrink_handler);
TButton_field& bf = mask.add_button(DLG_QUIT, 0, "Fine", -56, -1, bwidth/2, 2); TButton_field& bf = mask.add_button(DLG_QUIT, 0, TR("Fine"), -56, -1, bwidth/2, 2);
mask.first_focus(101); mask.first_focus(101);
KEY key = mask.run(); KEY key = mask.run();
@ -2583,11 +2589,11 @@ int main(int argc, char** argv)
if (menu.exist()) if (menu.exist())
{ {
TMenu_application *ma = new TMenu_application(menu); TMenu_application *ma = new TMenu_application(menu);
ma->run(argc, argv, "Menu Principale"); ma->run(argc, argv, TR("Menu Principale"));
delete ma; delete ma;
} }
else else
error_box("Non esiste il menu %s", (const char*)menu); error_box(TR("Non esiste il menu %s"), (const char*)menu);
return 0; return 0;
} }

View File

@ -1,6 +1,6 @@
#include "ba0100a.h" #include "ba0100a.h"
PAGE "Selezione utente" -1 -1 30 7 PAGE "Selezione utente" -1 -1 30 6
STRING F_USER 8 STRING F_USER 8
BEGIN BEGIN

View File

@ -87,12 +87,17 @@ END
BOOLEAN 113 BOOLEAN 113
BEGIN BEGIN
PROMPT 2 -1 "Campi 3D" PROMPT 2 18 "Campi 3D"
END
BOOLEAN 115
BEGIN
PROMPT 2 17 "Icone alternative"
END END
BUTTON 114 10 2 BUTTON 114 10 2
BEGIN BEGIN
PROMPT 19 -1 "Font" PROMPT 20 -1 "Font"
END END
GROUPBOX DLG_NULL 14 8 GROUPBOX DLG_NULL 14 8

View File

@ -428,29 +428,6 @@ void TFconv_ini::export_module(const char* module, const char* summary)
} }
} }
///////////////////////////////////////////////////////////
// TAuto_token_string
///////////////////////////////////////////////////////////
/*
TAuto_token_string& TAuto_token_string::create(const char* ts)
{
// Copia la stringa
set(ts);
// Calcola il separatore
for (const char* s = get_buffer(); *s; s++)
{
if (strchr("|;,!^&+\t\n", *s) != NULL)
{
separator(*s);
break;
}
}
return *this;
}
*/
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Maschera composizione del modulo // Maschera composizione del modulo
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////

View File

@ -1166,7 +1166,7 @@ bool TInstaller_mask::on_key(KEY key)
TInstaller_mask::TInstaller_mask() TInstaller_mask::TInstaller_mask()
: TArray_sheet(0, 0, 0, 0, "Installazione", : TArray_sheet(0, 0, 0, 0, "Installazione",
"@1C|Modulo@30|Cod.|Versione da\ninstallare@11|Livello\nPatch@8|Data\nRilascio@10|Versione\nInstallata@10|Livello\nPatch@8|Data\nInstallazione@13|Aggiornamento", "@1|Modulo@30|Cod.|Versione da\ninstallare@11|Livello\nPatch@8|Data\nRilascio@10|Versione\nInstallata@10|Livello\nPatch@8|Data\nInstallazione@13|Aggiornamento",
0x18, 3) 0x18, 3)
{ {
_curr_mask = this; _curr_mask = this;
@ -1212,7 +1212,7 @@ TInstaller_mask::~TInstaller_mask()
switch (_reboot_program) switch (_reboot_program)
{ {
case NEW_MENU: case NEW_MENU:
msg << "sono stati aggiornati i menu'"; msg << "sono stati aggiornati i menu";
default: default:
if (ba0exfile.exist()) if (ba0exfile.exist())
{ {
@ -1220,7 +1220,7 @@ TInstaller_mask::~TInstaller_mask()
msg << " e "; msg << " e ";
else else
msg << "e' stato "; msg << "e' stato ";
msg << "aggiornato il navigatore dei menu'"; msg << "aggiornato il navigatore dei menu";
} }
if (ba1exfile.exist()) if (ba1exfile.exist())
{ {

View File

@ -31,7 +31,7 @@ public:
bool TDevotoOli_mask::something_selected() const bool TDevotoOli_mask::something_selected() const
{ {
TSheet_field& sheet = sfield(F_MODULES); TSheet_field& sheet = sfield(F_MODULES);
FOR_EACH_SHEET_ROW_BACK(sheet, i, row) FOR_EACH_SHEET_ROW(sheet, i, row)
if (row->get_char(0) > ' ') if (row->get_char(0) > ' ')
break; break;
return i >= 0; return i >= 0;

View File

@ -52,6 +52,6 @@ bool TComuni_app::user_destroy()
int ba4100(int argc, char* argv[]) int ba4100(int argc, char* argv[])
{ {
TComuni_app a ; TComuni_app a ;
a.run(argc, argv, "Anagrafica Comuni"); a.run(argc, argv, TR("Anagrafica Comuni"));
return 0; return 0;
} }

View File

@ -708,6 +708,6 @@ int ba4200(int argc, char* argv[])
TApplication::check_parameters(argc, argv); TApplication::check_parameters(argc, argv);
const char ta = (argc > 2 && toupper(*argv[2]) == 'G') ? 'G' : 'F'; const char ta = (argc > 2 && toupper(*argv[2]) == 'G') ? 'G' : 'F';
TPersone_app a(ta); TPersone_app a(ta);
a.run(argc, argv, "Anagrafica Persone"); a.run(argc, argv, TR("Anagrafica Persone"));
return 0; return 0;
} }

View File

@ -194,6 +194,7 @@ public:
void change_ca7(TRectype& rec) const; void change_ca7(TRectype& rec) const;
void convert_quadst() const; void convert_quadst() const;
TConversione_archivi() : _oldditta(0), _codditta(0), _error(0) {} TConversione_archivi() : _oldditta(0), _codditta(0), _error(0) {}
}; };
@ -929,7 +930,7 @@ void TConversione_archivi::rebuild_dir_indexes()
d.get(i); d.get(i);
TFilename s(d.name()); TFilename s(d.name());
s.ext("dbf"); s.ext("dbf");
if (f.is_valid() == NOERR && fexist(s)) if (f.is_valid(true) == NOERR && fexist(s))
{ {
TSystemisamfile f(i); TSystemisamfile f(i);
f.packindex(); f.packindex();
@ -1840,4 +1841,3 @@ int main(int argc,char** argv)
return 0; return 0;
} }

View File

@ -869,15 +869,20 @@ bool TBill::find()
bool TBill::read(TRectype &r) bool TBill::read(TRectype &r)
{ {
TLocalisamfile pcon(LF_PCON); bool ok = FALSE;
pcon.put(PCN_GRUPPO, _gruppo);
pcon.put(PCN_CONTO, _conto);
pcon.put(PCN_SOTTOCONTO, _sottoconto);
const int err = pcon.read(); if (tipo() <= ' ' || sottoconto() <= 0)
if (err == NOERR) {
TString16 key; key.format("%d|%d|%ld", gruppo(), conto(), sottoconto());
const TRectype& pcon = cache().get(LF_PCON, key);
if (!pcon.empty())
{
r = pcon;
ok = TRUE;
}
}
if (ok)
{ {
r = pcon.curr();
_tipo_cr = r.get_int(PCN_TIPOSPRIC); _tipo_cr = r.get_int(PCN_TIPOSPRIC);
_sezione = r.get_char(PCN_SEZSALDI); _sezione = r.get_char(PCN_SEZSALDI);
set_description(r.get(PCN_DESCR)); set_description(r.get(PCN_DESCR));
@ -886,7 +891,7 @@ bool TBill::read(TRectype &r)
else else
r.zero(); r.zero();
return err == NOERR; return ok;
} }
int TBill::tipo_att() int TBill::tipo_att()
@ -946,8 +951,7 @@ char TBill::sezione() const
// Certified 99% (uses __tmp_string) // Certified 99% (uses __tmp_string)
const char* TBill::string(int mode) const const char* TBill::string(int mode) const
{ {
TFixed_string s(&__tmp_string[256], 80); TString& s = get_tmp_string(80);
s.cut(0);
if (mode & 0x4) if (mode & 0x4)
{ {

View File

@ -237,6 +237,8 @@ long TApplication::task_eh(WINDOW win, EVENT *ep)
xvt_menu_set_tree(win, menu); xvt_menu_set_tree(win, menu);
xvt_res_free_menu_tree(menu); xvt_res_free_menu_tree(menu);
} }
if (dictionary_active())
xvt_menu_translate_tree(win, dictionary_translate_menu_item);
// Setta la caption della task window // Setta la caption della task window
TString cap; TString cap;
@ -251,9 +253,6 @@ long TApplication::task_eh(WINDOW win, EVENT *ep)
// Crea il banner iniziale // Crea il banner iniziale
create_backdrop(); create_backdrop();
#if defined(DBG) && XVT_OS == XVT_OS_SCOUNIX
message_box("Attach to process %d ...", getpid());
#endif
do_events(); do_events();
os_allow_another_instance(); os_allow_another_instance();
} }
@ -414,7 +413,7 @@ void TApplication::stop_run()
c.set(hname, encode(remaining_time.string())); c.set(hname, encode(remaining_time.string()));
} }
else else
message_box("Questo e' un programma dimostrativo.\n Oggi rimangono %s minuti di utilizzo.", remaining_time.string(3, 0)); message_box(TR("Questo e' un programma dimostrativo.\nOggi rimangono %s minuti di utilizzo."), remaining_time.string(3, 0));
} }
#endif #endif
terminate(); terminate();
@ -478,6 +477,8 @@ void TApplication::terminate()
printer_destroy(); printer_destroy();
dictionary_close();
customize_controls(FALSE); // Rilascio eventuali DLL customize_controls(FALSE); // Rilascio eventuali DLL
} }
@ -520,7 +521,7 @@ const char* TApplication::get_module_name() const
} }
if (!ok) if (!ok)
{ {
error_box("Il modulo '%s' non e' autorizzato per l'utente %s", (const char*)module, ((const char*)user())); error_box(TR("Il modulo '%s' non e' autorizzato per l'utente %s"), (const char*)module, ((const char*)user()));
module.cut(0); module.cut(0);
} }
} }
@ -650,12 +651,12 @@ void TApplication::run(
if (sn < 0) if (sn < 0)
{ {
error_box("Probabilmente non e' stata inserita la chiave di protezione"); error_box(TR("Probabilmente non e' stata inserita la chiave di protezione"));
return; return;
} }
if (!test_assistance_year()) if (!test_assistance_year())
{ {
error_box("Probabilmente e' necessario attivare il contratto di assistenza"); error_box(TR("Probabilmente e' necessario attivare il contratto di assistenza"));
return; return;
} }
@ -702,7 +703,7 @@ void TApplication::about() const
if (get_version_info(year, release, tag, patch)) if (get_version_info(year, release, tag, patch))
{ {
message_box("Versione %d.%02d\nProgramma %s\nN.ro di serie %u-%02d.%03d \nUtente %s", message_box(TR("Versione %d.%02d\nProgramma %s\nN.ro di serie %u-%02d.%03d \nUtente %s"),
year, release, (const char*)n.name(), ser_no, tag, patch, (const char*)user()); year, release, (const char*)n.name(), ser_no, tag, patch, (const char*)user());
} }
else else
@ -791,8 +792,8 @@ bool TApplication::build_firm_data(long codditta, bool flagcom)
exist = fexist(s); exist = fexist(s);
} }
if (exist) if (exist)
return message_box("Direttorio dati danneggiato, impossibile attivare la ditta %ld", codditta); return message_box(TR("Direttorio dati danneggiato, impossibile attivare la ditta %ld"), codditta);
if (!yesno_box("Gli archivi della ditta %ld non esistono: si desidera generarli?", codditta)) if (!yesno_box(TR("Gli archivi della ditta %ld non esistono: si desidera generarli?"), codditta))
return FALSE; return FALSE;
TLocalisamfile ditte(LF_NDITTE); TLocalisamfile ditte(LF_NDITTE);
@ -800,24 +801,24 @@ bool TApplication::build_firm_data(long codditta, bool flagcom)
ditte.put("CODDITTA",codditta); ditte.put("CODDITTA",codditta);
if (ditte.read(_isequal,_testandlock) == _islocked) if (ditte.read(_isequal,_testandlock) == _islocked)
{ {
message_box("Archivi della ditta %ld in fase di creazione da parte di un altro utente.",codditta); message_box(TR("Archivi della ditta %ld in fase di creazione da parte di un altro utente."),codditta);
return FALSE; return FALSE;
} }
set_autoload_new_files(yesno_box("Si desidera precaricare gli archivi standard")); set_autoload_new_files(yesno_box(TR("Si desidera precaricare gli archivi standard")));
s = s.path(); s.rtrim(1); s = s.path(); s.rtrim(1);
if (!fexist(s) && !make_dir(s)) if (!fexist(s) && !make_dir(s))
return error_box("Impossibile creare il direttorio della ditta %ld (%s)", return error_box(TR("Impossibile creare il direttorio della ditta %ld (%s)"),
codditta, (const char*)s); codditta, (const char*)s);
s << ndir; s << ndir;
if (!fcopy(&ndir[1], s)) if (!fcopy(&ndir[1], s))
return error_box("Impossibile copiare il file %s della ditta %ld", return error_box(TR("Impossibile copiare il file %s della ditta %ld"),
&ndir[1], codditta); &ndir[1], codditta);
s = s.path(); s << ntrc; s = s.path(); s << ntrc;
if (!fcopy(&ntrc[1], s)) if (!fcopy(&ntrc[1], s))
return error_box("Impossibile copiare il file %s della ditta %ld", return error_box(TR("Impossibile copiare il file %s della ditta %ld"),
ntrc, codditta); ntrc, codditta);
TDir dir, dir1; TDir dir, dir1;
@ -844,7 +845,7 @@ bool TApplication::build_firm_data(long codditta, bool flagcom)
dir.put(LF_DIR, _nordir, _sysdirop); dir.put(LF_DIR, _nordir, _sysdirop);
rec.zero(); rec.zero();
} }
TString mess("Generazione archivi della ditta "); mess << codditta; TString mess(TR("Generazione archivi della ditta ")); mess << codditta;
TProgind p(maxeod0 ? maxeod0 : 1, mess, FALSE, TRUE, 70); TProgind p(maxeod0 ? maxeod0 : 1, mess, FALSE, TRUE, 70);
for (int i = LF_DIR + 1; i <= maxeod0; i++) for (int i = LF_DIR + 1; i <= maxeod0; i++)

View File

@ -9,6 +9,10 @@
#include <strings.h> #include <strings.h>
#endif #endif
#ifndef __DICTION_H
#include <diction.h>
#endif
#define MSG_AI "AI" // message auto_insert (relapp) #define MSG_AI "AI" // message auto_insert (relapp)
#define MSG_FS "FS" // message filtered start (relapp) #define MSG_FS "FS" // message filtered start (relapp)
#define MSG_LN "LN" // message link (printapp -> relapp) #define MSG_LN "LN" // message link (printapp -> relapp)

View File

@ -360,3 +360,73 @@ TAssoc_array & TAssoc_array::copy(
return * this; return * this;
} }
///////////////////////////////////////////////////////////
// TCache
// Un simpatico contenitore che può dimenticare i contenuti
// a patto che riusciate a fornire un metodo per ricrearli!
///////////////////////////////////////////////////////////
TObject* TCache::key2obj(const char* key)
{
NFCHECK("Pure key2obj function not implemented");
return new TString(key); // Place holder
}
void TCache::discarding(const THash_object* obj)
{
// Nothing to do normally
}
TObject* TCache::objptr(const TString& key)
{
const int hv = key.hash() % _data.size();
THash_object* ho = (THash_object*)_data.objptr(hv);
TObject* obj = NULL;
if (ho != NULL && ho->key() == key)
{
obj = &ho->obj();
}
else
{
obj = key2obj(key);
if (obj != NULL)
{
if (ho != NULL)
{
discarding(ho);
_data.destroy(hv);
}
ho = new THash_object(key, obj);
_data.add(ho, hv);
}
}
return obj;
}
TObject* TCache::objptr(size_t s)
{
TString16 key; key.format("%10lu", s);
return objptr(key);
}
void TCache::destroy()
{
for (int i = _data.last(); i >= 0; i--)
{
THash_object* ho = (THash_object*)_data.objptr(i);
if (ho != NULL)
{
discarding(ho);
_data.destroy(i);
}
}
}
TCache::TCache(size_t size) : _data(size > 0 ? size : HASH_SIZE)
{ }
TCache::~TCache()
{
destroy();
}

View File

@ -148,6 +148,23 @@ public:
{ destroy(); } { destroy(); }
}; };
class TCache : public TObject
{
TArray _data;
protected:
virtual void discarding(const THash_object* obj);
virtual TObject* key2obj(const char* key) pure;
public:
TObject* objptr(const TString& key);
TObject* objptr(size_t nkey);
void destroy(); // Not very useful, but who knows?
TCache(size_t size = 0); // 883 assigned by default
virtual ~TCache();
};
#define FOR_EACH_ASSOC_STRING(__ass, __obj, __key, __str) \ #define FOR_EACH_ASSOC_STRING(__ass, __obj, __key, __str) \
const char *__key, *__str; __ass.restart(); \ const char *__key, *__str; __ass.restart(); \
for (THash_object* __obj = __ass.get_hashobj(); \ for (THash_object* __obj = __ass.get_hashobj(); \

View File

@ -26,6 +26,7 @@ COLOR FOCUS_COLOR = NORMAL_COLOR;
COLOR FOCUS_BACK_COLOR = COLOR_YELLOW; COLOR FOCUS_BACK_COLOR = COLOR_YELLOW;
bool CAMPI_SCAVATI = TRUE; bool CAMPI_SCAVATI = TRUE;
bool AUTOSELECT = FALSE; bool AUTOSELECT = FALSE;
bool SMALL_ICONS=FALSE;
#ifndef STX_DATA #ifndef STX_DATA
// Very deep hacking // Very deep hacking
@ -118,7 +119,17 @@ bool TPicture_array::add(short id)
TImage* i = (TImage*)objptr(id); TImage* i = (TImage*)objptr(id);
if (i == NULL) if (i == NULL)
{ {
i = new TImage(id); if (SMALL_ICONS)
{
ignore_xvt_errors(TRUE);
i = new TImage(10000+id);
ignore_xvt_errors(FALSE);
if (!i->ok())
i->load(id);
}
else
i = new TImage(id);
if (i->ok()) if (i->ok())
{ {
i->convert_transparent_color(BTN_BACK_COLOR); i->convert_transparent_color(BTN_BACK_COLOR);
@ -135,14 +146,10 @@ bool TPicture_array::add(short id)
void TPicture_array::reload() void TPicture_array::reload()
{ {
for (int id = last(); id >= 0; id--) for (short id = last(); id > 0; id--) if (exist(id))
{ {
TImage* i = (TImage*)objptr(id); destroy(id);
if (i) add(id);
{
i->load(id);
i->convert_transparent_color(BTN_BACK_COLOR);
}
} }
} }
@ -288,6 +295,7 @@ void customize_colors()
TOOL_BACK_COLOR = colors.get_color("ToolBack", NULL, -1, MASK_DARK_COLOR); TOOL_BACK_COLOR = colors.get_color("ToolBack", NULL, -1, MASK_DARK_COLOR);
CAMPI_SCAVATI = colors.get_bool("Campi3D", NULL, -1, CAMPI_SCAVATI); CAMPI_SCAVATI = colors.get_bool("Campi3D", NULL, -1, CAMPI_SCAVATI);
AUTOSELECT = colors.get_bool("AutoSelect", NULL, -1, AUTOSELECT); AUTOSELECT = colors.get_bool("AutoSelect", NULL, -1, AUTOSELECT);
SMALL_ICONS = colors.get_bool("SmallIcons", NULL, -1, SMALL_ICONS);
xi_set_pref(XI_PREF_COLOR_LIGHT, MASK_LIGHT_COLOR); xi_set_pref(XI_PREF_COLOR_LIGHT, MASK_LIGHT_COLOR);
xi_set_pref(XI_PREF_COLOR_CTRL, MASK_BACK_COLOR); xi_set_pref(XI_PREF_COLOR_CTRL, MASK_BACK_COLOR);
@ -1368,7 +1376,7 @@ void TButton_control::create(WINDOW win, short cid,
{ {
bool bold; bool bold;
COLOR color; COLOR color;
TString txt(text); TString80 txt(text); txt.trim();
char mnemonic = '\0'; char mnemonic = '\0';
int underscore = -1; int underscore = -1;
@ -1562,30 +1570,6 @@ void TPushbutton_control::set_bmp(short bmp_up, short bmp_dn)
else else
_bmp_up = _bmp_dn = 0; _bmp_up = _bmp_dn = 0;
_obj->v.btn->drawable = _bmp_up > 0; _obj->v.btn->drawable = _bmp_up > 0;
/*
if (bmp_up > 0)
{
XI_BITMAP* b1 = xi_bitmap_create_res(bmp_up, XI_BITMAP_NORMAL);
xi_bitmap_background_set(b1, BTN_BACK_COLOR);
xi_bitmap_hcenter_set(b1, TRUE);
xi_bitmap_vcenter_set(b1, TRUE);
xi_set_bitmap(_obj, b1);
if (bmp_dn <= 0)
bmp_dn = bmp_up;
}
else
xi_set_bitmap(_obj, NULL);
if (bmp_dn > 0)
{
XI_BITMAP* b2 = xi_bitmap_create_res(bmp_dn, XI_BITMAP_NORMAL);
xi_bitmap_background_set(b2, BTN_BACK_COLOR);
xi_bitmap_hcenter_set(b2, TRUE);
xi_bitmap_vcenter_set(b2, TRUE);
xi_set_down_bitmap(_obj, b2);
}
else
xi_set_down_bitmap(_obj, NULL);
*/
} }
void TPushbutton_control::update() void TPushbutton_control::update()
@ -1623,39 +1607,62 @@ void TPushbutton_control::update()
if (bmp > 0) if (bmp > 0)
{ {
const TImage& i = _picture->image(bmp); const TImage& i = _picture->image(bmp);
int x = (rct.right + rct.left - i.width()) / 2; if (!SMALL_ICONS || i.width() > i.height()*2)
int y = (rct.bottom + rct.top - i.height()) / 2; {
if (_obj->v.btn->down) int x = (rct.right + rct.left - i.width()) / 2;
{ int y = (rct.bottom + rct.top - i.height()) / 2;
x += 2; if (_obj->v.btn->down)
y += 2; {
} x += 2;
y += 2;
}
i.draw(win, x, y); i.draw(win, x, y);
if (!(attrib & XI_ATR_ENABLED)) if (!(attrib & XI_ATR_ENABLED))
{ {
CPEN pen; CPEN pen;
pen.width = 1; pen.width = 1;
pen.pat = PAT_SOLID; pen.pat = PAT_SOLID;
pen.style = P_SOLID; pen.style = P_SOLID;
pen.color = BTN_BACK_COLOR; pen.color = BTN_BACK_COLOR;
xvt_dwin_set_cpen(win, &pen); xvt_dwin_set_cpen(win, &pen);
for (int py = y + i.height(); py >= y; py -= 2) for (int py = y + i.height(); py >= y; py -= 2)
{ {
PNT p; p.v = py; p.h = x; PNT p; p.v = py; p.h = x;
xvt_dwin_draw_set_pos(win, p); xvt_dwin_draw_set_pos(win, p);
p.h += i.width(); p.h += i.width();
xvt_dwin_draw_line(win, p); xvt_dwin_draw_line(win, p);
} }
for (int px = x + i.width(); px >= x; px -= 2) for (int px = x + i.width(); px >= x; px -= 2)
{ {
PNT p; p.v = y; p.h = px; PNT p; p.v = y; p.h = px;
xvt_dwin_draw_set_pos(win, p); xvt_dwin_draw_set_pos(win, p);
p.v += i.height(); p.v += i.height();
xvt_dwin_draw_line(win, p); xvt_dwin_draw_line(win, p);
} }
} }
}
else
{
const char* cap = caption();
int width = i.width();
if (*cap)
width += xvt_dwin_get_text_width(win, cap, -1) + 1;
int x = (rct.right + rct.left - width) / 2 + _obj->v.btn->down;
int y = (rct.bottom + rct.top - i.height()) / 2 + _obj->v.btn->down;
i.draw(win, x, y);
if (*cap)
{
const int height = xvt_dwin_get_font_size_mapped(win);
x += i.width()+1;
y = (rct.top + rct.bottom + height) / 2 + _obj->v.btn->down;
xvt_dwin_set_fore_color(win, (attrib & XI_ATR_ENABLED) ? NORMAL_COLOR : DISABLED_COLOR);
xvt_dwin_draw_text(win, x, y, cap, -1);
}
}
} }
#ifdef XI_R4 #ifdef XI_R4
xi_set_clip(xiwin, NULL); xi_set_clip(xiwin, NULL);

View File

@ -4,18 +4,22 @@
#define __DATE_CPP #define __DATE_CPP
#include <date.h> #include <date.h>
#include <diction.h>
#include <real.h> #include <real.h>
#include <strings.h> #include <strings.h>
#define DAYYEAR 365 #define DAYYEAR 365
#define DAYBIAS 36525L #define DAYBIAS 36525L
static const byte _days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool is_leap(int year)
{ return (year % 4) == 0; }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Utility functions // Utility functions
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
HIDDEN const byte _days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
TDate::TDate(const TDate &d) : _val(d._val) TDate::TDate(const TDate &d) : _val(d._val)
{} {}
@ -27,9 +31,10 @@ TDate::TDate(long l) : _val(l)
if (time(&lt) == -1) if (time(&lt) == -1)
return; return;
struct tm * timeloc = localtime(&lt); struct tm * timeloc = localtime(&lt);
if (timeloc == NULL) if (timeloc != NULL)
fatal_box("Impossibile reperire la data corrente del sistema."); _val = makedata(timeloc->tm_mday, timeloc->tm_mon+1, timeloc->tm_year + 1900);
_val = makedata(timeloc->tm_mday, timeloc->tm_mon+1, timeloc->tm_year + 1900); else
_val = NULLDATE;
} }
else else
{ {
@ -53,8 +58,7 @@ TDate::TDate(long l) : _val(l)
wd += DAYBIAS; wd += DAYBIAS;
} }
int m, y, leap; int m, y, leap;
for(y = 0; wd > DAYYEAR + (leap = is_leap(y)); y++)
for(y = 0; wd > DAYYEAR + (leap = ((y % 4 ) == 0)); y++)
wd -= (DAYYEAR + leap); wd -= (DAYYEAR + leap);
for(m = 0; wd > (_days_in_month[m] + (leap && (m == 1))); m++) for(m = 0; wd > (_days_in_month[m] + (leap && (m == 1))); m++)
wd -= (_days_in_month[m] + (leap && (m == 1))); wd -= (_days_in_month[m] + (leap && (m == 1)));
@ -119,22 +123,9 @@ int TDate::last_day(int month, int year)
// son ventotto case uno // son ventotto case uno
// per default ce n'ha trentuno"); // per default ce n'ha trentuno");
{ {
int d; int d = _days_in_month[month-1];
switch(month) if (month == 2 && is_leap(year) == 0)
{ d++;
case 4:
case 6:
case 9:
case 11:
d = 30;
break;
case 2:
d = year % 4 ? 28 : 29;
break;
default:
d = 31;
break;
}
return d; return d;
} }
@ -296,7 +287,7 @@ char* TDate::string(
else if (monthf == quarter) else if (monthf == quarter)
{ {
if (ord < m_date) ord = ma_date; if (ord < m_date) ord = ma_date;
mf.format("%do trimestre", (month() / 3) + 1); mf.format("%s %d", TR("trimestre"), (month()/3)+1);
} }
else else
mf.format(monthf == brief ? "%d" : "%02d", month()); mf.format(monthf == brief ? "%d" : "%02d", month());
@ -662,11 +653,13 @@ const char* itom(
// mese corrispondente a tale cifra (es. 15 = "Marzo") // mese corrispondente a tale cifra (es. 15 = "Marzo")
{ {
CHECK(m>=1, "Il mese indicato deve essere un numero da 1 a 12 "); CHECK(m>=1, "Il mese indicato deve essere un numero da 1 a 12 ");
const char* nomi[12] = const char* const nomi[12] =
{ {
"Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", TR("Gennaio"), TR("Febbraio"), TR("Marzo"),
"Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre" TR("Aprile"), TR("Maggio"), TR("Giugno"),
}; TR("Luglio"), TR("Agosto"), TR("Settembre"),
TR("Ottobre"), TR("Novembre"), TR("Dicembre")
};
return nomi[(m-1) % 12]; return nomi[(m-1) % 12];
} }
@ -681,8 +674,9 @@ const char* itow(
// giorno corrispondente a tale cifra (es. 15 = "Lunedi") // giorno corrispondente a tale cifra (es. 15 = "Lunedi")
{ {
CHECKD(d >= 1 && d <= 7, "Bad week day ", d); CHECKD(d >= 1 && d <= 7, "Bad week day ", d);
const char* nomi[7] = const char* const nomi[7] =
{ "Lunedi", "Martedi", "Mercoledi", "Giovedi", "Venerdi", "Sabato", "Domenica" }; { TR("Lunedì"), TR("Martedì"), TR("Mercoledì"), TR("Giovedì"),
TR("Venerdì"), TR("Sabato"), TR("Domenica") };
return nomi[(d-1) % 7]; return nomi[(d-1) % 7];
} }

306
include/diction.cpp Executable file
View File

@ -0,0 +1,306 @@
/*
<xml>
<dictionary>
<entry module="ba">
<ita>Attezione: premere OK per cancellare</ita>
<eng>Atension: pres OK to dilit</eng>
</entry>
</dictionary>
</xml>
*/
#include <xvt.h>
#include <config.h>
#include <diction.h>
#include <netsock.h>
#include <scanner.h>
#include <utility.h>
///////////////////////////////////////////////////////////
// TTraduttore
///////////////////////////////////////////////////////////
class TTraduttore : public TCache
{
TString _str;
TSocketClient _client;
CONNID _connection;
protected:
virtual TObject* key2obj(const char* key);
public:
bool active() const { return _connection != 0; }
const char* translate(const char* sentence);
TTraduttore();
virtual ~TTraduttore();
};
TObject* TTraduttore::key2obj(const char* key)
{
const char* const prefix = "<sentence>";
const char* const posfix = "</sentence>";
_str.cut(0);
_str << "<m:Translate>\n"
<< prefix << unesc(key) << posfix << '\n'
<< "</m:Translate>\n";
if (_client.HttpSoap(_connection, _str))
{
_str.cut(0);
size_t size;
const TFixed_string buf((const char*)_client.GetBuffer(size));
int start = buf.find("<sentence");
if (start > 0)
start = buf.find('>', start+1)+1;
if (start > 0)
{
const int stop = buf.find('<', start);
if (stop > 0)
_str = esc(buf.sub(start, stop));
}
// _client.ReleaseBuffer(); // Non perdiamo tempo in 'ste cose
}
else
return NULL;
return _str.dup();
}
const char* TTraduttore::translate(const char* sentence)
{
if (sentence && *sentence && active())
{
TString str = sentence; str.trim();
bool has_letters = false;
for (int i = 0; str[i]; i++)
{
if (isalpha(str[i]))
{
has_letters = true;
break;
}
}
if (has_letters)
{
TString* trans = (TString*)objptr(str);
if (trans != NULL && trans->not_empty())
sentence = (const char*)*trans;
}
}
return sentence;
}
TTraduttore::TTraduttore() : _connection(0)
{
TConfig ini(CONFIG_INSTALL, "Server");
const TString& server = ini.get("Dictionary");
if (server.not_empty())
_connection = _client.QueryConnection("", server);
}
TTraduttore::~TTraduttore()
{
// Autoclose connection
}
static TTraduttore* _DevotoOli = NULL;
const char* dictionary_translate(const char* sentence)
{
if (_DevotoOli == NULL)
_DevotoOli = new TTraduttore;
return _DevotoOli->translate(sentence);
}
const char* dictionary_translate_macro(const char* sentence)
{
if (memcmp(sentence, TO_BE_TRANSLATED, 4) == 0)
sentence = dictionary_translate(sentence+4);
return sentence;
}
char strip_accelerator(TString& str)
{
char tilde= '\0';
for (int i = 0; str[i]; i++)
{
if (str[i] == '~' || str[i] == '&')
{
tilde = str[i+1];
str.strip("~&");
break;
}
}
return tilde;
}
void restore_accelerator(TString& str, char acc, char tilde)
{
if (acc > ' ')
{
int newtilde = 0;
for (int m = 0; str[m]; m++)
{
if (toupper(str[m]) == acc)
{
newtilde = m;
break;
}
}
const char s[2] = { tilde, '\0' };
str.insert(s, newtilde);
}
}
// len - Effect
// -1 - No length limit
// 0 - Exactly same lenght as original
// >0 - Maximum specified length
const char* dictionary_translate_prompt(const char* prompt, int maxlen)
{
if (prompt && *prompt && dictionary_active())
{
TString& str = get_tmp_string();
str = prompt;
TString8 prefix;
if (str[0] == '@')
{
prefix = str.left(2); // Usually bold = @b
str.ltrim(2);
}
const char matilde = strip_accelerator(str); // Ricorda tasto rapido
const int oldlen = str.len(); // Memorizza vecchia lunghezza
str = dictionary_translate(str);
if (maxlen >= 0)
{
const int limit = maxlen == 0 ? oldlen : maxlen;
if (str.len() > limit)
{
// Abbrevio all'ultima consonante
for (int i = limit-2; i > 0; i--)
{
if (strchr("aeiou", str[i]) == NULL)
{
str.cut(i+1);
str << '.';
break;
}
}
if (i <= 0)
str.cut(limit);
}
if (maxlen == 0 && str.len() < limit)
str.left_just(limit);
}
restore_accelerator(str, matilde, '~');
str.insert(prefix);
return str;
}
return prompt;
}
const char* dictionary_translate_macro_prompt(const char* sentence, int maxlen)
{
if (memcmp(sentence, TO_BE_TRANSLATED, 4) == 0)
sentence = dictionary_translate_prompt(sentence+4, maxlen);
return sentence;
}
const char* dictionary_translate_header(const char* head)
{
if (head && *head && dictionary_active())
{
TString str = head;
const int at = str.rfind('@');
if (at >= 0)
{
TString8 postfix;
postfix = str.mid(at);
str.cut(at);
str = dictionary_translate(str);
str << postfix;
return str;
}
if (str.right(1)[0] == ' ')
return dictionary_translate_prompt(head);
return dictionary_translate(head);
}
return head;
}
const char* dictionary_translate_macro_header(const char* head)
{
if (memcmp(head, TO_BE_TRANSLATED, 4) == 0)
head = dictionary_translate_header(head+4);
return head;
}
const char* dictionary_translate_menu_item(const char* text)
{
TString& str = get_tmp_string();
str = text;
const char matilde = strip_accelerator(str);
TString16 posfix;
int start = str.find('\t');
if (start < 0)
start = str.find("...");
if (start > 0)
{
posfix = str.mid(start);
str.cut(start);
}
const char* newtext = dictionary_translate(str);
if (str != newtext)
{
str = newtext;
restore_accelerator(str, matilde, '&');
if (posfix.not_empty())
str << posfix;
return str;
}
return text;
}
void dictionary_translate_menu(MENU_ITEM* menu)
{
if (menu && dictionary_active()) for (int m = 0; menu[m].tag != 0; m++)
{
MENU_ITEM& mi = menu[m];
if (!mi.separator)
{
const char* newtext = dictionary_translate_menu_item(mi.text);
if (strlen(newtext) > strlen(mi.text)) // Posso sovrascrivere?
mi.text = xvt_mem_realloc(mi.text, strlen(newtext)+1);
strcpy(mi.text, newtext);
if (mi.child)
dictionary_translate_menu(mi.child);
}
}
}
bool dictionary_active()
{
return _DevotoOli != NULL && _DevotoOli->active();
}
void dictionary_close()
{
if (_DevotoOli != NULL)
{
delete _DevotoOli;
_DevotoOli = NULL;
}
}

28
include/diction.h Executable file
View File

@ -0,0 +1,28 @@
#ifndef __DICTION_H
#define __DICTION_H
#define TO_BE_TRANSLATED "\03\02\01\00"
#define ALREADY_TRANSLATED "\01\02\03\00"
#ifndef XVT_INCL_XVT
typedef unsigned long WINDOW;
#endif
const char* dictionary_translate(const char* sentence);
const char* dictionary_translate_macro(const char* sentence);
const char* dictionary_translate_prompt(const char* prompt, int maxlen = 0);
const char* dictionary_translate_macro_prompt(const char* prompt, int maxlen = 0);
const char* dictionary_translate_header(const char* head);
const char* dictionary_translate_macro_header(const char* head);
const char* dictionary_translate_menu_item(const char* menu);
void dictionary_translate_menu(WINDOW win);
bool dictionary_active();
void dictionary_close();
#define TR(str) dictionary_translate_macro(TO_BE_TRANSLATED##str)
#define PR(str) dictionary_translate_macro_prompt(TO_BE_TRANSLATED##str)
#define BR(str) dictionary_translate_macro_prompt(TO_BE_TRANSLATED##str, -1)
#define HR(str) dictionary_translate_macro_header(TO_BE_TRANSLATED##str)
#endif

View File

@ -1367,7 +1367,7 @@ bool TMail_messages::remove()
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Obsolete DDE management // Obsolete DDE management
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
/*
#include <dde.h> #include <dde.h>
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -1580,3 +1580,4 @@ void TDDE::terminate()
} }
} }
*/

View File

@ -3,12 +3,12 @@
#include <checks.h> #include <checks.h>
#include <isamrpc.h> #include <isamrpc.h>
#define NO_MFC #define XVAGA
#include <netsock.h> #include <netsock.h>
static TSocketClient* _client = NULL; static TSocketClient* _client = NULL;
static DWORD _connection = 0; static CONNID _connection = 0;
bool rpc_Start() bool rpc_Start()
{ {
@ -44,7 +44,7 @@ bool rpc_Call(const char* cmd)
return ok; return ok;
} }
char* rpc_Request(const char* cmd, DWORD& size, real& total) char* rpc_Request(const char* cmd, size_t& size, real& total)
{ {
CHECK(_connection, "Server not connected"); CHECK(_connection, "Server not connected");
const clock_t start = clock(); const clock_t start = clock();
@ -60,7 +60,7 @@ static TString _rpc_string;
inline bool BoolCall() inline bool BoolCall()
{ {
CHECK(_connection, "Server not connected"); CHECK(_connection, "Server not connected");
BOOL yes; bool yes;
bool ok = _client->RequestBool(_connection, _rpc_call, yes) != 0; bool ok = _client->RequestBool(_connection, _rpc_call, yes) != 0;
if (!ok) if (!ok)
{ {
@ -176,7 +176,7 @@ bool rpc_DongleHasModule(word af)
bool rpc_DongleModules(TBit_array& ba) bool rpc_DongleModules(TBit_array& ba)
{ {
DWORD size; size_t size;
real time; real time;
word* buff = (word*)rpc_Request("DongleModules()", size, time); word* buff = (word*)rpc_Request("DongleModules()", size, time);
@ -240,7 +240,7 @@ bool rpc_UserLogin(const char* server, const char* user,
cmd << "UserLogin(" << user << ")"; cmd << "UserLogin(" << user << ")";
_rpc_call.format("UserLogin(%s,%s,%s)", user, password, application); _rpc_call.format("UserLogin(%s,%s,%s)", user, password, application);
BOOL logged = FALSE; bool logged = FALSE;
bool connected = _client->RequestBool(_connection, _rpc_call, logged) != 0; bool connected = _client->RequestBool(_connection, _rpc_call, logged) != 0;
if (connected) if (connected)
{ {
@ -293,12 +293,12 @@ bool http_get(const char* server,
if (!client.IsOk()) if (!client.IsOk())
return error_box("Impossibile inizializzare il client HTTP"); return error_box("Impossibile inizializzare il client HTTP");
unsigned long connection = client.QueryConnection("80", server); CONNID connection = client.QueryConnection("80", server);
bool ok = connection != 0; bool ok = connection != 0;
if (ok) if (ok)
{ {
ok = client.HttpGetFile(remote_file, local_file) != 0; ok = client.HttpGetFile(connection, remote_file, local_file) != 0;
client.RemoveConnection(connection); client.RemoveConnection(connection);
} }
return ok; return ok;
@ -314,7 +314,7 @@ bool http_dir(const char* server, const char* remote_dir, TString_array& list)
bool ok = connection != 0; bool ok = connection != 0;
if (ok) if (ok)
{ {
ok = client.HttpGetDir(remote_dir, list) != 0; ok = client.HttpGetDir(connection, remote_dir, list) != 0;
client.RemoveConnection(connection); client.RemoveConnection(connection);
} }

View File

@ -156,6 +156,7 @@
#define LF_EXTERNAL 1000 // Files with id >= are considered to be externals #define LF_EXTERNAL 1000 // Files with id >= are considered to be externals
#define CNF_GENERAL 10000 #define CNF_GENERAL 10000
#define CNF_STUDIO CNF_GENERAL + 1 #define CNF_STUDIO CNF_GENERAL + 1
#define CNF_DITTA CNF_GENERAL + 2 #define CNF_DITTA CNF_GENERAL + 2
@ -168,4 +169,3 @@

View File

@ -4,6 +4,7 @@
#include <controls.h> #include <controls.h>
#include <browfile.h> #include <browfile.h>
#include <colors.h> #include <colors.h>
#include <diction.h>
#include <msksheet.h> #include <msksheet.h>
#include <os_dep.h> #include <os_dep.h>
#include <prefix.h> #include <prefix.h>
@ -180,8 +181,8 @@ void TMask::read_mask(
CHECKD(_pages < MAX_PAGES, "Maschera con troppe pagine: ", _pages); CHECKD(_pages < MAX_PAGES, "Maschera con troppe pagine: ", _pages);
WINDOW w = read_page(scanner, FALSE); WINDOW w = read_page(scanner, FALSE);
TString title(80); TString80 title;
xvt_vobj_get_title(w, (char*)(const char*)title, title.size()); xvt_vobj_get_title(w, title.get_buffer(), title.size());
captions.add(title); captions.add(title);
_pagewin[_pages++] = w; _pagewin[_pages++] = w;
@ -945,7 +946,7 @@ WINDOW TMask::read_page(
static int tooly; static int tooly;
static RCT rect; static RCT rect;
TString title(scanner.string()); const TString title = dictionary_translate(scanner.string());
RCT r; RCT r;
if (toolwin()) if (toolwin())

View File

@ -3,6 +3,7 @@
#include <colors.h> #include <colors.h>
#include <controls.h> #include <controls.h>
#include <diction.h>
#include <execp.h> #include <execp.h>
#include <expr.h> #include <expr.h>
#include <msksheet.h> #include <msksheet.h>
@ -320,7 +321,7 @@ bool TMask_field::parse_item(TScanner& scanner)
{ {
_ctl_data._x = scanner.integer(); _ctl_data._x = scanner.integer();
_ctl_data._y = scanner.integer(); _ctl_data._y = scanner.integer();
_ctl_data._prompt = scanner.string(); _ctl_data._prompt = dictionary_translate_prompt(scanner.string(), is_editable() ? 0 : -1);
return TRUE; return TRUE;
} }
@ -1059,23 +1060,23 @@ void TButton_field::create(WINDOW parent)
{ {
case DLG_OK: case DLG_OK:
if (_ctl_data._prompt.empty() || _ctl_data._prompt == "Conferma") if (_ctl_data._prompt.empty() || _ctl_data._prompt == "Conferma")
_ctl_data._prompt = "~Conferma"; _ctl_data._prompt = BR("~Conferma");
_exit_key = K_ENTER; _exit_key = K_ENTER;
if (_ctl_data._bmp_up == 0 && _ctl_data._prompt == "~Conferma") if (_ctl_data._bmp_up == 0 && _ctl_data._prompt == BR("~Conferma"))
_ctl_data._bmp_up = BMP_OK; _ctl_data._bmp_up = BMP_OK;
break; break;
case DLG_CANCEL: case DLG_CANCEL:
if (_ctl_data._prompt.empty()) if (_ctl_data._prompt.empty())
_ctl_data._prompt = "Annulla"; _ctl_data._prompt = BR("Annulla");
_virtual_key = _exit_key = K_ESC; _virtual_key = _exit_key = K_ESC;
if (_ctl_data._bmp_up == 0 && _ctl_data._prompt == "Annulla") if (_ctl_data._bmp_up == 0 && _ctl_data._prompt == BR("Annulla"))
_ctl_data._bmp_up = BMP_CANCEL; _ctl_data._bmp_up = BMP_CANCEL;
break; break;
case DLG_DELREC: case DLG_DELREC:
if (_ctl_data._prompt.empty() || _ctl_data._prompt == "Elimina") if (_ctl_data._prompt.empty() || _ctl_data._prompt == "Elimina")
_ctl_data._prompt = "~Elimina"; _ctl_data._prompt = BR("~Elimina");
_exit_key = K_DEL; _exit_key = K_DEL;
if (_ctl_data._bmp_up == 0 && _ctl_data._prompt == "~Elimina") if (_ctl_data._bmp_up == 0 && _ctl_data._prompt == BR("~Elimina"))
{ {
_ctl_data._bmp_up = BMP_DELREC; _ctl_data._bmp_up = BMP_DELREC;
_ctl_data._bmp_dn = BMP_DELRECDN; _ctl_data._bmp_dn = BMP_DELRECDN;
@ -1083,17 +1084,17 @@ void TButton_field::create(WINDOW parent)
break; break;
case DLG_PRINT: case DLG_PRINT:
if (_ctl_data._prompt.empty() || _ctl_data._prompt == "Stampa") if (_ctl_data._prompt.empty() || _ctl_data._prompt == "Stampa")
_ctl_data._prompt = "~Stampa"; _ctl_data._prompt = BR("~Stampa");
_exit_key = K_ENTER; _exit_key = K_ENTER;
if (_ctl_data._bmp_up <= 0 && _ctl_data._prompt == "~Stampa") if (_ctl_data._bmp_up <= 0 && _ctl_data._prompt == BR("~Stampa"))
_ctl_data._bmp_up = BMP_PRINT; _ctl_data._bmp_up = BMP_PRINT;
break; break;
case DLG_QUIT: case DLG_QUIT:
if (_ctl_data._prompt.empty()) if (_ctl_data._prompt.empty())
_ctl_data._prompt = "Fine"; _ctl_data._prompt = BR("Fine");
_virtual_key = K_F4; _virtual_key = K_F4;
_exit_key = K_QUIT; _exit_key = K_QUIT;
if (_ctl_data._bmp_up <= 0 && _ctl_data._prompt == "Fine") if (_ctl_data._bmp_up <= 0 && _ctl_data._prompt == BR("Fine"))
{ {
_ctl_data._bmp_up = BMP_QUIT; _ctl_data._bmp_up = BMP_QUIT;
_ctl_data._bmp_dn = BMP_QUITDN; _ctl_data._bmp_dn = BMP_QUITDN;
@ -1338,7 +1339,8 @@ bool TEditable_field::parse_item(TScanner& scanner)
if (scanner.key() == "WA") if (scanner.key() == "WA")
{ {
set_warning(scanner.string()); const char* msg = dictionary_translate(scanner.string());
set_warning(msg);
return TRUE; return TRUE;
} }
@ -1866,9 +1868,8 @@ TBrowse::~TBrowse()
// Certified 100% // Certified 100%
void TBrowse::parse_display(TScanner& scanner) void TBrowse::parse_display(TScanner& scanner)
{ {
const char* s; const char* s = scanner.string();
s = scanner.string(); _head.add(dictionary_translate_header(s));
_head.add(s);
s = scanner.line(); s = scanner.line();
_items.add(s); _items.add(s);
} }
@ -2294,12 +2295,9 @@ bool TBrowse::do_link(bool insert)
{ {
TString nm(_insert.mid(1)); TString nm(_insert.mid(1));
if (nm.compare("tb", 2, TRUE) == 0) // Programma gestione tabelle if (nm.compare("tb", 2, TRUE) == 0) // Programma gestione tabelle
{
_cursor->file().get_relapp(app); _cursor->file().get_relapp(app);
}
else // Programma generico di browse/edit else // Programma generico di browse/edit
app.format("ba3 -3 %s %d", (const char*)nm, _cursor->file().num()); app.format("ba3 -3 %s %d", (const char*)nm, _cursor->file().num());
// Obbligatorio usare la format globale
} }
else else
{ {
@ -4216,7 +4214,7 @@ void TList_field::read_item(TScanner& scanner)
TToken_string ts(scanner.string()); TToken_string ts(scanner.string());
_codes.add(ts.get()); _codes.add(ts.get());
const char* v = ts.get(); const char* v = dictionary_translate_prompt(ts.get(), _ctl_data._width);
_values.add(v); _values.add(v);
CHECKS(v == NULL || strlen(v) <= (word)_ctl_data._width, "List item is too long:", v); CHECKS(v == NULL || strlen(v) <= (word)_ctl_data._width, "List item is too long:", v);
@ -4306,9 +4304,18 @@ void TList_field::add_list()
csafe = _codes; _codes = ""; csafe = _codes; _codes = "";
vsafe = _values; _values = ""; vsafe = _values; _values = "";
} }
/*
_codes.add("01|02|03|04|05|06|07|08|09|10|11|12"); _codes.add("01|02|03|04|05|06|07|08|09|10|11|12");
_values.add("Gennaio|Febbraio|Marzo|Aprile|Maggio|Giugno|" _values.add("Gennaio|Febbraio|Marzo|Aprile|Maggio|Giugno|"
"Luglio|Agosto|Settembre|Ottobre|Novembre|Dicembre"); "Luglio|Agosto|Settembre|Ottobre|Novembre|Dicembre");
*/
for (int i = 1; i <= 12; i++)
{
char num[4]; sprintf(num, "%02d", i);
_codes.add(num);
_values.add(itom(i));
}
if (atoi(csafe) > 0) if (atoi(csafe) > 0)
{ {
_codes.add(csafe); _codes.add(csafe);

View File

@ -3,6 +3,7 @@
#define XVT_INCL_NATIVE #define XVT_INCL_NATIVE
#include <progind.h> #include <progind.h>
#include <config.h> #include <config.h>
#include <agasys.h>
// skstream.h // skstream.h
// Copyright (C) 1995, 1996 by John C. Wang. All Rights Reserved. // Copyright (C) 1995, 1996 by John C. Wang. All Rights Reserved.
@ -456,16 +457,134 @@ int sockbuf::sync()
// end of skstreams // end of skstreams
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
#define NO_MFC
#define CObject TObject
#define CString TString
#define CStringArray TString_array
#include "NetSock.h" #include "NetSock.h"
#include <windows.h> class TSocket_connection : public TConnection
{
TString _server;
skstream::service _service;
static TLanManager* pSocketManager = NULL; skstream* _socket;
static skstream* cur_socket = NULL;
protected:
bool connect();
public:
virtual bool Execute(const char* cmd);
bool WriteLine(const char* cmd);
bool ReadLine(TString& str);
bool Read(byte* buf, size_t size);
skstream* GetSocket();
TSocket_connection(TLanManager* lm, const char* service, const char* server);
~TSocket_connection();
};
bool TSocket_connection::Execute(const char* cmd)
{
bool ok = GetSocket() != NULL;
if (ok)
{
const size_t buflen = strlen(cmd)+1;
_socket->sync();
_socket->write(cmd, buflen);
_socket->flush();
ok = _socket->good() != 0;
}
return ok;
}
bool TSocket_connection::WriteLine(const char* cmd)
{
bool ok = GetSocket() != NULL;
if (ok)
{
const size_t buflen = strlen(cmd); // Unica differenza da Execute
_socket->sync();
_socket->write(cmd, buflen);
_socket->flush();
ok = _socket->good() != 0;
}
return ok;
}
bool TSocket_connection::ReadLine(TString& str)
{
bool ok = GetSocket() != NULL;
if (ok)
{
char *buf = str.get_buffer(4096);
_socket->getline(buf, str.size(), '\n');
}
return ok;
}
bool TSocket_connection::Read(byte* buf, size_t size)
{
bool ok = GetSocket() != NULL;
if (ok)
{
_socket->read(buf, size);
ok = _socket->good() != 0;
}
return ok;
}
bool TSocket_connection::connect()
{
if (_socket != NULL)
delete _socket;
_socket = new skstream(_server, _service);
if (_socket->is_open())
SetId((CONNID)_socket);
else
{
delete _socket;
_socket = NULL;
SetId(0);
}
return _socket != NULL;
}
skstream* TSocket_connection::GetSocket()
{
if (_socket == NULL || !_socket->is_open())
connect();
return _socket;
}
TSocket_connection::TSocket_connection(TLanManager* lm,
const char* service, const char* server)
: TConnection(lm, 0), _socket(NULL)
{
_service = (skstream::service)((service && *service) ? atoi(service) : 0);
_server = server;
int pos = _server.find("://");
if (pos > 0)
_server.ltrim(pos+3);
pos = _server.rfind(':');
if (pos >= 0)
{
_service = (skstream::service)atoi(_server.mid(pos+1));
_server.cut(pos);
}
if (_server.blank() || stricmp(_server, "localhost") == 0)
_server = "127.0.0.1";
connect();
}
TSocket_connection::~TSocket_connection()
{
if (_socket)
delete _socket;
}
TSocketClient::TSocketClient() TSocketClient::TSocketClient()
: m_pData(NULL), m_dwSize(0) : m_pData(NULL), m_dwSize(0)
@ -475,95 +594,23 @@ TSocketClient::~TSocketClient()
{ {
ReleaseBuffer(); ReleaseBuffer();
RemoveAllConnections(); RemoveAllConnections();
ShutDown();
} }
BOOL TSocketClient::Boot() TConnection* TSocketClient::OnQueryConnection(const char* service, const char* server)
{ {
return TRUE; TSocket_connection* pConnection = new TSocket_connection(this, service, server);
} if (pConnection->Id() == 0)
{
BOOL TSocketClient::ShutDown() delete pConnection;
{ pConnection = NULL;
pSocketManager = NULL; }
if (cur_socket)
{
delete cur_socket;
cur_socket = NULL;
}
return TRUE;
}
BOOL TSocketClient::OnRemoveConnection(DWORD id)
{
if (cur_socket)
{
delete cur_socket;
cur_socket = NULL;
}
return TRUE;
}
TConnection* TSocketClient::OnQueryConnection(const char* service,
const char* server)
{
if (pSocketManager == NULL)
Boot();
TConnection* pConnection = NULL;
if (cur_socket == NULL)
{
int porta = service != NULL ? atoi(service) : 0;
TString strServer = server;
int pos = strServer.find("://");
if (pos > 0)
strServer.ltrim(pos+3);
pos = strServer.rfind(':');
if (pos > 0)
{
porta = atoi(strServer.mid(pos+1));
strServer.cut(pos);
}
if (strServer.empty() || stricmp(strServer, "localhost") == 0)
strServer = "127.0.0.1";
cur_socket = new skstream(strServer, (skstream::service)porta);
if (cur_socket->is_open())
pConnection = OnCreateConnection((DWORD)cur_socket);
else
{
delete cur_socket;
cur_socket = NULL;
}
}
return pConnection; return pConnection;
} }
BOOL TSocketClient::Execute(DWORD id, const char* cmd) bool TSocketClient::Request(CONNID id, const char* cmd)
{ {
BOOL ok = cur_socket != NULL && cur_socket->is_open(); static bool semaphore = FALSE;
if (ok) bool ok = FALSE;
{
const int buflen = strlen(cmd)+1;
cur_socket->sync();
cur_socket->write(cmd, buflen);
cur_socket->flush();
ok = cur_socket->good();
}
return ok;
}
BOOL TSocketClient::Request(DWORD id, const char* cmd)
{
static BOOL semaphore = FALSE;
BOOL ok = FALSE;
if (!semaphore) if (!semaphore)
{ {
@ -573,14 +620,14 @@ BOOL TSocketClient::Request(DWORD id, const char* cmd)
ok = Execute(id, cmd); ok = Execute(id, cmd);
if (ok) if (ok)
{ {
TSocket_connection* conn = (TSocket_connection*)GetConnection(id);
m_dwSize = 0; m_dwSize = 0;
cur_socket->read((char*)&m_dwSize, sizeof(m_dwSize)); conn->Read((byte*)&m_dwSize, sizeof(m_dwSize));
ok = m_dwSize > 0; ok = m_dwSize > 0;
if (ok) if (ok)
{ {
m_pData = new BYTE[m_dwSize]; m_pData = new byte[m_dwSize];
cur_socket->read(m_pData, (int)m_dwSize); ok = conn->Read(m_pData, m_dwSize);
ok = cur_socket->good();
} }
} }
@ -589,63 +636,61 @@ BOOL TSocketClient::Request(DWORD id, const char* cmd)
return ok; return ok;
} }
BYTE* TSocketClient::GetBuffer(DWORD& dwSize) byte* TSocketClient::GetBuffer(size_t& dwSize)
{ {
dwSize = m_dwSize; dwSize = m_dwSize;
return m_pData; return m_pData;
} }
BOOL TSocketClient::WriteLine(DWORD, const char* str) bool TSocketClient::WriteLine(CONNID id, const char* str)
{ {
if (!cur_socket->is_open()) TSocket_connection* conn = (TSocket_connection*)GetConnection(id);
return FALSE; if (conn)
return conn->WriteLine(str);
return FALSE;
}
if (str && *str) bool TSocketClient::ReadLine(CONNID id, TString& str)
{
TSocket_connection* conn = (TSocket_connection*)GetConnection(id);
if (conn)
return conn->ReadLine(str);
return FALSE;
}
void TSocketClient::ReleaseBuffer()
{
if (m_pData)
{ {
cur_socket->sync(); delete m_pData;
cur_socket->write(str, strlen(str)); m_pData = NULL;
cur_socket->flush(); m_dwSize = 0;
} }
return cur_socket->good();
} }
BOOL TSocketClient::ReadLine(DWORD, TString& str) bool TSocketClient::HttpGetFile(CONNID id, const char* remote, const char* local)
{ {
char *buf = str.get_buffer(4096); bool ok = FALSE;
cur_socket->getline(buf, str.size(), '\n');
return TRUE;
}
BOOL TSocketClient::HttpGetFile(const char* remote, const char* local)
{
if (cur_socket == NULL || !cur_socket->is_open())
return FALSE;
BOOL ok = FALSE;
TString buf(4096); TString buf(4096);
buf << "GET " << remote << " HTTP/1.0\r\n\r\n"; buf << "GET " << remote << " HTTP/1.0\r\n\r\n";
cur_socket->sync(); if (WriteLine(id, buf))
cur_socket->write(buf, buf.len());
cur_socket->flush();
if (cur_socket->good())
{ {
const clock_t start = clock(); const clock_t start = clock();
long size = 0; long size = 0;
for (int r = 0; !cur_socket->eof(); r++) for (int r = 0; ; r++)
{ {
cur_socket->getline(buf.get_buffer(), buf.size(), '\n'); ReadLine(id, buf);
if (buf.blank()) if (buf.blank())
break; break;
if (r == 0 && buf.find("404") > 0) if (r == 0 && buf.find("404") > 0)
return FALSE; // File not found return FALSE; // File not found
if (buf.compare("Content-length:", 15, TRUE) == 0) if (buf.compare("Content-length:", 15, TRUE) == 0)
{ {
const int colon = buf.find(':'); const int colon = buf.find(':');
size = atol(buf.mid(colon+1)); size = atol(buf.mid(colon+1));
} }
} }
ofstream outfile(local, ios::out | ios::binary); ofstream outfile(local, ios::out | ios::binary);
@ -661,6 +706,7 @@ BOOL TSocketClient::HttpGetFile(const char* remote, const char* local)
TProgind pi(size, msg, TRUE, TRUE); TProgind pi(size, msg, TRUE, TRUE);
long total = 0; long total = 0;
skstream* cur_socket = ((TSocket_connection*)GetConnection(id))->GetSocket();
while (!cur_socket->eof()) while (!cur_socket->eof())
{ {
cur_socket->read(buf.get_buffer(), buf.size()); cur_socket->read(buf.get_buffer(), buf.size());
@ -700,10 +746,10 @@ BOOL TSocketClient::HttpGetFile(const char* remote, const char* local)
return ok; return ok;
} }
BOOL TSocketClient::HttpGetDir(const char* remote, TString_array& list) bool TSocketClient::HttpGetDir(CONNID id, const char* remote, TString_array& list)
{ {
TFilename local; local.temp(); TFilename local; local.temp();
const BOOL ok = HttpGetFile(remote, local); const bool ok = HttpGetFile(id, remote, local);
if (ok) if (ok)
{ {
ifstream s(local); ifstream s(local);
@ -733,12 +779,65 @@ BOOL TSocketClient::HttpGetDir(const char* remote, TString_array& list)
return ok; return ok;
} }
void TSocketClient::ReleaseBuffer() bool TSocketClient::HttpSoap(CONNID id, const char* cmd)
{ {
if (m_pData) bool ok = false;
TSocket_connection* conn = (TSocket_connection*)GetConnection(id);
if (conn == NULL)
return ok;
if (cmd == NULL || *cmd == '\0')
return ok;
char hostname[64];
aga_get_host_name(hostname, sizeof(hostname));
TString content(256);
content = cmd;
if (content.find("<SOAP-ENV") < 0) // Controllo se c'è tutto
{
content.insert("<SOAP-ENV:Envelope>\n<SOAP-ENV:Body>\n");
content << "</SOAP-ENV:Body>\n</SOAP-ENV:Envelope>\r\n";
}
TString buf(4096);
buf << "POST / HTTP/1.1\n"
<< "User-Agent: Campo\n"
<< "Host: " << hostname << "\n"
<< "Content-Type: text/xml; charset=utf-8\n"
<< "Content-length: " << content.len() << "\n"
<< "SOAPAction: \"/\"\r\n\r\n"
<< content;
if (conn->WriteLine(buf))
{ {
delete m_pData; skstream* cur_socket = conn->GetSocket();
m_pData = NULL;
m_dwSize = 0; unsigned long size = 0;
} for (int r = 0; !cur_socket->eof(); r++)
{
conn->ReadLine(buf);
if (buf.blank())
break;
if (buf.compare("Content-length:", 15, TRUE) == 0)
{
const int colon = buf.find(':');
size = atol(buf.mid(colon+1));
}
}
if (size > 0)
{
if (size >= m_dwSize)
{
ReleaseBuffer();
m_dwSize = size+1;
m_pData = new BYTE[m_dwSize];
}
memset(m_pData, 0, m_dwSize);
cur_socket->read(m_pData, size);
ok = true;
}
}
return ok;
} }

View File

@ -5,28 +5,26 @@
#include "NetUtils.h" #include "NetUtils.h"
#endif #endif
class TConnection;
class TSocketServer : public TLanServer class TSocketServer : public TLanServer
{ {
BYTE* m_pData; byte* m_pData;
DWORD m_dwSize; unsigned int m_dwSize;
protected: // TLanManager protected: // TLanManager
virtual BOOL Boot(); virtual bool Boot();
virtual BOOL ShutDown(); virtual bool ShutDown();
virtual BOOL OnRemoveConnection(DWORD id); virtual bool OnRemoveConnection(CONNID id);
public: public:
BYTE* GetBuffer(DWORD dwSize); byte* GetBuffer(size_t dwSize);
const BYTE* GetData() const { return m_pData; } const byte* GetData() const { return m_pData; }
BOOL OnConnect(const CString& topic); bool OnConnect(const TString& topic);
void OnConnectConfirm(DWORD id); void OnConnectConfirm(CONNID id);
public: public:
virtual BOOL IsOk() const; virtual bool IsOk() const;
TSocketServer(const char* name); TSocketServer(const char* name);
virtual ~TSocketServer(); virtual ~TSocketServer();
@ -34,30 +32,24 @@ public:
class TSocketClient : public TLanClient class TSocketClient : public TLanClient
{ {
BYTE* m_pData; byte* m_pData;
DWORD m_dwSize; size_t m_dwSize;
protected: // TLanManager
virtual BOOL Boot();
virtual BOOL ShutDown();
virtual OnRemoveConnection(DWORD id);
protected: // TLanClient protected: // TLanClient
virtual TConnection* OnQueryConnection(const char* service, virtual TConnection* OnQueryConnection(const char* service, const char* server);
const char* server);
public: public:
virtual BOOL Execute(DWORD id, const char* cmd); virtual bool Request(CONNID id, const char* cmd);
virtual BOOL Request(DWORD id, const char* cmd); virtual byte* GetBuffer(size_t& dwSize);
virtual BYTE* GetBuffer(DWORD& dwSize);
virtual void ReleaseBuffer(); virtual void ReleaseBuffer();
virtual BOOL IsOk() const { return TRUE; } virtual bool IsOk() const { return TRUE; }
BOOL WriteLine(DWORD id, const char* str); bool WriteLine(CONNID id, const char* str);
BOOL ReadLine(DWORD id, TString& str); bool ReadLine(CONNID id, TString& str);
BOOL HttpGetFile(const char* remote, const char* local); bool HttpGetFile(CONNID id, const char* remote, const char* local);
BOOL HttpGetDir(const char* remote, TString_array& list); bool HttpGetDir(CONNID id, const char* remote, TString_array& list);
bool HttpSoap(CONNID id, const char* query);
TSocketClient(); TSocketClient();
virtual ~TSocketClient(); virtual ~TSocketClient();

View File

@ -1,4 +1,3 @@
#define NO_MFC
#include "NetUtils.h" #include "NetUtils.h"
TLanManager::TLanManager() TLanManager::TLanManager()
@ -9,72 +8,55 @@ TLanManager::~TLanManager()
RemoveAllConnections(); RemoveAllConnections();
} }
TConnection* TLanManager::OnCreateConnection(DWORD id) TConnection* TLanManager::OnCreateConnection(CONNID id)
{ {
return new TConnection(this, id); return new TConnection(this, id);
} }
BOOL TLanManager::HasConnections() const bool TLanManager::HasConnections() const
{ {
#ifdef NO_MFC
return m_mapConn.items() > 0; return m_mapConn.items() > 0;
#else
return m_mapConn.GetCount() > 0;
#endif
} }
BOOL TLanManager::Request(DWORD id, const char* cmd) bool TLanManager::Request(CONNID id, const char* cmd)
{ {
TConnection* conn = GetConnection(id) ; TConnection* conn = GetConnection(id) ;
return conn ? conn->Request(cmd) : FALSE; return conn ? conn->Request(cmd) : FALSE;
} }
BOOL TLanManager::Execute(DWORD id, const char* cmd) bool TLanManager::Execute(CONNID id, const char* cmd)
{ {
TConnection* conn = GetConnection(id) ; TConnection* conn = GetConnection(id) ;
return conn ? conn->Execute(cmd) : FALSE; return conn ? conn->Execute(cmd) : FALSE;
} }
// Physically disconnect // Physically disconnect
BOOL TLanManager::OnRemoveConnection(DWORD id) bool TLanManager::OnRemoveConnection(CONNID id)
{ {
return id != NULL; return TRUE;
} }
DWORD TLanManager::AddConnection(TConnection* pConn) CONNID TLanManager::AddConnection(TConnection* pConn)
{ {
DWORD id = 0; CONNID id = 0;
if (pConn) if (pConn)
{ {
id = pConn->Id(); id = pConn->Id();
#ifdef NO_MFC
TString16 key; key.format("%lu", id); TString16 key; key.format("%lu", id);
m_mapConn.add(key, pConn, TRUE); m_mapConn.add(key, pConn, TRUE);
#else
TConnection* c;
BOOL ok = m_mapConn.Lookup(id, c);
if (ok)
delete c;
m_mapConn.SetAt(id, pConn);
#endif
} }
return id; return id;
} }
BOOL TLanManager::RemoveConnection(DWORD id) bool TLanManager::RemoveConnection(CONNID id)
{ {
TConnection* pConn = GetConnection(id); TConnection* pConn = GetConnection(id);
BOOL ok = FALSE; bool ok = FALSE;
if (pConn != NULL && OnRemoveConnection(id)) if (pConn != NULL && OnRemoveConnection(id))
{ {
#ifdef NO_MFC
TString16 key; key.format("%lu", id); TString16 key; key.format("%lu", id);
m_mapConn.remove(key); m_mapConn.remove(key);
#else
delete pConn;
VERIFY(m_mapConn.RemoveKey(id));
#endif
ok = TRUE; ok = TRUE;
} }
@ -83,36 +65,17 @@ BOOL TLanManager::RemoveConnection(DWORD id)
void TLanManager::RemoveAllConnections() void TLanManager::RemoveAllConnections()
{ {
TConnection* pConn;
#ifdef NO_MFC
m_mapConn.restart(); m_mapConn.restart();
for (pConn = (TConnection*)m_mapConn.get(); pConn; pConn = (TConnection*)m_mapConn.get()) for (TConnection* pConn = (TConnection*)m_mapConn.get();
pConn != NULL; pConn = (TConnection*)m_mapConn.get())
OnRemoveConnection(pConn->Id()); OnRemoveConnection(pConn->Id());
m_mapConn.destroy(); m_mapConn.destroy();
#else
for (POSITION pos = m_mapConn.GetStartPosition(); pos != NULL;)
{
DWORD key;
m_mapConn.GetNextAssoc(pos, key, pConn);
{
OnRemoveConnection(pConn->Id());
delete pConn;
}
}
m_mapConn.RemoveAll();
#endif
} }
TConnection* TLanManager::GetConnection(DWORD id) const TConnection* TLanManager::GetConnection(CONNID id) const
{ {
TConnection* pConn = NULL;
#ifdef NO_MFC
TString16 key; key.format("%lu", id); TString16 key; key.format("%lu", id);
pConn = (TConnection*)m_mapConn.objptr(key); TConnection* pConn = (TConnection*)m_mapConn.objptr(key);
#else
m_mapConn.Lookup(id, pConn);
#endif
return pConn; return pConn;
} }
@ -121,20 +84,11 @@ int TLanManager::ForEachConnection(ConnectionFunction f, void* pJolly)
int result = 0; int result = 0;
TConnection* pConn; TConnection* pConn;
#ifdef NO_MFC
m_mapConn.restart(); m_mapConn.restart();
for (pConn = (TConnection*)m_mapConn.get(); for (pConn = (TConnection*)m_mapConn.get();
pConn != NULL; pConn != NULL;
pConn = (TConnection*)m_mapConn.get()) pConn = (TConnection*)m_mapConn.get())
result += f(*pConn, pJolly); result += f(*pConn, pJolly);
#else
DWORD key;
for (POSITION pos = m_mapConn.GetStartPosition(); pos != NULL; )
{
m_mapConn.GetNextAssoc(pos, key, pConn);
result += f(*pConn, pJolly);
}
#endif
return result; return result;
} }
@ -143,96 +97,89 @@ int TLanManager::ForEachConnection(ConnectionFunction f, void* pJolly)
// TLanServer // TLanServer
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
BYTE* TLanServer::GetBufferSetString(const char* str) byte* TLanServer::GetBufferSetString(const char* str)
{ {
if (str == NULL) if (str == NULL)
str = ""; str = "";
const size_t dwSize = strlen(str)+1; const size_t dwSize = strlen(str)+1;
BYTE* buff = GetBuffer(dwSize); byte* buff = GetBuffer(dwSize);
memcpy(buff, str, dwSize); memcpy(buff, str, dwSize);
return buff; return buff;
} }
BYTE* TLanServer::GetBufferSetBool(BOOL n) byte* TLanServer::GetBufferSetBool(bool n)
{ {
const size_t dwSize = sizeof(DWORD); const size_t dwSize = sizeof(size_t);
BYTE* buff = GetBuffer(dwSize); byte* buff = GetBuffer(dwSize);
*(DWORD*)buff = n ? -1 : 0; *(size_t*)buff = n ? -1 : 0;
return buff; return buff;
} }
BYTE* TLanServer::GetBufferSetInteger(long n) byte* TLanServer::GetBufferSetInteger(long n)
{ {
const size_t dwSize = sizeof(DWORD); const size_t dwSize = sizeof(size_t);
BYTE* buff = GetBuffer(dwSize); byte* buff = GetBuffer(dwSize);
*(DWORD*)buff = n; *(size_t*)buff = n;
return buff; return buff;
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TLanClient // TLanClient
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
DWORD TLanClient::QueryConnection(const char* service, CONNID TLanClient::QueryConnection(const char* service, const char* server)
const char* server)
{ {
TConnection* pConn = OnQueryConnection(service, server); TConnection* pConn = OnQueryConnection(service, server);
return AddConnection(pConn) ; return AddConnection(pConn) ;
} }
BOOL TLanClient::Execute(DWORD id, const char* cmd) bool TLanClient::Execute(CONNID id, const char* cmd)
{ {
return FALSE; TConnection* pConn = GetConnection(id);
return pConn ? pConn->Execute(cmd) : FALSE;
} }
BOOL TLanClient::Request(DWORD id, const char* cmd) bool TLanClient::Request(CONNID id, const char* cmd)
{ {
return FALSE; TConnection* pConn = GetConnection(id);
return pConn ? pConn->Request(cmd) : FALSE;
} }
BOOL TLanClient::RequestString(DWORD id, const char* cmd, CString& res) bool TLanClient::RequestString(CONNID id, const char* cmd, TString& res)
{ {
BOOL valid = Request(id, cmd); bool valid = Request(id, cmd);
if (valid) if (valid)
{ {
DWORD dwSize; size_t dwSize;
BYTE* pData = GetBuffer(dwSize); byte* pData = GetBuffer(dwSize);
#ifdef NO_MFC
char* ptr = res.get_buffer((int)dwSize); char* ptr = res.get_buffer((int)dwSize);
memcpy(ptr, pData, (size_t)dwSize); memcpy(ptr, pData, (size_t)dwSize);
#else
char* ptr = res.GetBuffer((int)dwSize);
memcpy(ptr, pData, dwSize);
res.ReleaseBuffer();
#endif
ReleaseBuffer(); ReleaseBuffer();
} }
return valid; return valid;
} }
BOOL TLanClient::RequestInteger(DWORD id, const char* cmd, long& num) bool TLanClient::RequestInteger(CONNID id, const char* cmd, long& num)
{ {
BOOL valid = Request(id, cmd); bool valid = Request(id, cmd);
if (valid) if (valid)
{ {
DWORD dwSize; size_t dwSize;
BYTE* pData = GetBuffer(dwSize); byte* pData = GetBuffer(dwSize);
num = *(long*)pData; num = *(long*)pData;
ReleaseBuffer(); ReleaseBuffer();
} }
return valid; return valid;
} }
bool TLanClient::RequestBool(CONNID id, const char* cmd, bool& ok)
BOOL TLanClient::RequestBool(DWORD id, const char* cmd, BOOL& ok)
{ {
BOOL valid = Request(id, cmd); bool valid = Request(id, cmd);
if (valid) if (valid)
{ {
DWORD dwSize; size_t dwSize;
BYTE* pData = GetBuffer(dwSize); byte* pData = GetBuffer(dwSize);
ok = *(DWORD*)pData != 0; ok = *(size_t*)pData != 0;
ReleaseBuffer(); ReleaseBuffer();
} }
return valid; return valid;
@ -242,7 +189,7 @@ BOOL TLanClient::RequestBool(DWORD id, const char* cmd, BOOL& ok)
// TConnection // TConnection
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
TConnection::TConnection(TLanManager* pManager, DWORD id) TConnection::TConnection(TLanManager* pManager, CONNID id)
: m_pManager(pManager), m_dwId(id) : m_pManager(pManager), m_dwId(id)
{ {
} }
@ -253,25 +200,17 @@ TConnection::~TConnection()
TLanServer& TConnection::Server() const TLanServer& TConnection::Server() const
{ {
#ifdef NO_MFC
CHECK(Manager().IsServer(), "Can't cast client to server"); CHECK(Manager().IsServer(), "Can't cast client to server");
#else return (TLanServer&)Manager();
ASSERT(Manager().IsServer());
#endif
return (TLanServer&)Manager();
} }
int TConnection::ParseCommand(const char* cmd, CStringArray& argv) int TConnection::ParseCommand(const char* cmd, TString_array& argv)
{ {
#ifdef NO_MFC
argv.destroy(); argv.destroy();
#else
argv.RemoveAll();
#endif
BOOL is_quoted = FALSE; bool is_quoted = FALSE;
char end_quote = '\0'; char end_quote = '\0';
CString token; TString token;
const char* token_start = NULL; const char* token_start = NULL;
for (char* c = (char*)cmd; *c; c++) for (char* c = (char*)cmd; *c; c++)
@ -302,19 +241,11 @@ int TConnection::ParseCommand(const char* cmd, CStringArray& argv)
*c = '\0'; *c = '\0';
token = token_start; token = token_start;
*c = old; *c = old;
#ifdef NO_MFC
token.rtrim(); token.rtrim();
#else
token.TrimRight();
#endif
} }
} }
#ifdef NO_MFC
argv.add(token); argv.add(token);
#else
argv.Add(token);
#endif
token_start = NULL; token_start = NULL;
token = ""; token = "";
@ -322,7 +253,7 @@ int TConnection::ParseCommand(const char* cmd, CStringArray& argv)
continue; continue;
} }
if (*c == '"' || *c == '\'' || *c == '|' || BYTE(*c) >= 254) if (*c == '"' || *c == '\'' || *c == '|' || byte(*c) >= 254)
{ {
end_quote = *c; end_quote = *c;
token_start = c+1; token_start = c+1;
@ -334,22 +265,18 @@ int TConnection::ParseCommand(const char* cmd, CStringArray& argv)
} }
} }
#ifdef NO_MFC
return argv.items(); return argv.items();
#else
return argv.GetSize();
#endif
} }
BOOL TConnection::Execute(const char* cmd) bool TConnection::Execute(const char* cmd)
{ {
CStringArray argv; TString_array argv;
return ParseCommand(cmd, argv) > 0; return ParseCommand(cmd, argv) > 0;
} }
BOOL TConnection::Request(const char* cmd) bool TConnection::Request(const char* cmd)
{ {
CStringArray argv; TString_array argv;
return ParseCommand(cmd, argv) > 0; return ParseCommand(cmd, argv) > 0;
} }

View File

@ -1,48 +1,37 @@
#ifndef __NETUTILS_H__ #ifndef __NETUTILS_H__
#define __NETUTILS_H__ #define __NETUTILS_H__
#ifdef NO_MFC
#define BOOL int
#define BYTE unsigned char
#define DWORD unsigned long
#define CObject TObject
#define CString TString
#define CStringArray TString_array
#include "assoc.h" #include "assoc.h"
#endif
class TConnection; class TConnection;
typedef unsigned long CONNID;
typedef int (*ConnectionFunction)(TConnection& conn, void* pJolly); typedef int (*ConnectionFunction)(TConnection& conn, void* pJolly);
class TLanManager : public CObject class TLanManager : public TObject
{ {
#ifdef NO_MFC
TAssoc_array m_mapConn; TAssoc_array m_mapConn;
#else
CMap<DWORD, DWORD, TConnection*, TConnection*> m_mapConn;
#endif
protected: protected:
DWORD AddConnection(TConnection* pConn); CONNID AddConnection(TConnection* pConn);
virtual TConnection* OnCreateConnection(DWORD id); virtual TConnection* OnCreateConnection(CONNID id);
virtual BOOL OnRemoveConnection(DWORD id); virtual bool OnRemoveConnection(CONNID id);
public: public:
virtual BOOL IsServer() const { return FALSE; } virtual bool IsServer() const { return FALSE; }
virtual BOOL IsClient() const { return FALSE; } virtual bool IsClient() const { return FALSE; }
virtual BOOL IsOk() const { return FALSE; } virtual bool IsOk() const { return FALSE; }
virtual BOOL Execute(DWORD id, const char* cmd); virtual bool Execute(CONNID id, const char* cmd);
virtual BOOL Request(DWORD id, const char* cmd); virtual bool Request(CONNID id, const char* cmd);
int ForEachConnection(ConnectionFunction f, void* pJolly); int ForEachConnection(ConnectionFunction f, void* pJolly);
BOOL HasConnections() const; bool HasConnections() const;
TConnection* GetConnection(DWORD id) const; TConnection* GetConnection(CONNID id) const;
BOOL RemoveConnection(DWORD id); bool RemoveConnection(CONNID id);
void RemoveAllConnections(); void RemoveAllConnections();
TLanManager(); TLanManager();
@ -51,17 +40,17 @@ public:
class TLanServer : public TLanManager class TLanServer : public TLanManager
{ {
CString m_strName; TString m_strName;
public: public:
const CString& Name() const { return m_strName; } const TString& Name() const { return m_strName; }
virtual BOOL IsServer() const { return TRUE; } virtual bool IsServer() const { return TRUE; }
virtual BYTE* GetBuffer(DWORD dwSize) = 0; virtual byte* GetBuffer(unsigned int dwSize) pure;
BYTE* GetBufferSetString(const char* str); byte* GetBufferSetString(const char* str);
BYTE* GetBufferSetBool(BOOL ok); byte* GetBufferSetBool(bool ok);
BYTE* GetBufferSetInteger(long n); byte* GetBufferSetInteger(long n);
TLanServer(const char* name) : m_strName(name) { } TLanServer(const char* name) : m_strName(name) { }
virtual ~TLanServer() { } virtual ~TLanServer() { }
@ -70,46 +59,46 @@ public:
class TLanClient : public TLanManager class TLanClient : public TLanManager
{ {
protected: protected:
virtual TConnection* OnQueryConnection(const char* service, virtual TConnection* OnQueryConnection(const char* service, const char* server) pure;
const char* server) = 0;
public: public:
virtual BOOL IsClient() const { return TRUE; } virtual bool IsClient() const { return TRUE; }
DWORD QueryConnection(const char* service, CONNID QueryConnection(const char* service, const char* server = NULL);
const char* server = NULL);
virtual BOOL Execute(DWORD id, const char* cmd); virtual bool Execute(CONNID id, const char* cmd);
virtual BOOL Request(DWORD id, const char* cmd); virtual bool Request(CONNID id, const char* cmd);
virtual BYTE* GetBuffer(DWORD& dwSize) = 0; virtual byte* GetBuffer(unsigned int& dwSize) = 0;
virtual void ReleaseBuffer() = 0; virtual void ReleaseBuffer() = 0;
BOOL RequestString(DWORD id, const char* cmd, CString& res); bool RequestString(CONNID id, const char* cmd, TString& res);
BOOL RequestInteger(DWORD id, const char* cmd, long& num); bool RequestInteger(CONNID id, const char* cmd, long& num);
BOOL RequestBool(DWORD id, const char* cmd, BOOL& ok); bool RequestBool(CONNID id, const char* cmd, bool& ok);
}; };
class TConnection : public CObject class TConnection : public TObject
{ {
TLanManager* m_pManager; TLanManager* m_pManager;
DWORD m_dwId; CONNID m_dwId;
protected: protected:
int ParseCommand(const char* cmd, CStringArray& argv); int ParseCommand(const char* cmd, TString_array& argv);
void SetId(CONNID id) { m_dwId = id; } // Internal use only
public: public:
DWORD Id() const { return m_dwId; } CONNID Id() const { return m_dwId; }
TLanManager& Manager() const { return *m_pManager; } TLanManager& Manager() const { return *m_pManager; }
TLanServer& Server() const; TLanServer& Server() const;
virtual BOOL Execute(const char* cmd); virtual bool Execute(const char* cmd);
virtual BOOL Request(const char* cmd); virtual bool Request(const char* cmd);
BOOL ReturnBool(int b) const { return Server().GetBufferSetBool(b) != NULL; } bool ReturnBool(bool b) const { return Server().GetBufferSetBool(b) != NULL; }
BOOL ReturnInteger(long n) const { return Server().GetBufferSetInteger(n) != NULL; } bool ReturnInteger(long n) const { return Server().GetBufferSetInteger(n) != NULL; }
BOOL ReturnString(const CString& s) const { return Server().GetBufferSetString(s) != NULL; } bool ReturnString(const TString& s) const { return Server().GetBufferSetString(s) != NULL; }
TConnection(TLanManager* lm, DWORD id); TConnection(TLanManager* lm, CONNID id);
virtual ~TConnection(); virtual ~TConnection();
}; };

View File

@ -881,14 +881,9 @@ void TPrinter::init_formlen(
_formwidth=(mincol+maxcol)/2; _formwidth=(mincol+maxcol)/2;
} }
if (isfax()) _horz_offset = (_formwidth > 80) ? (int)(pw - w)/2 : 0;
_horz_offset = 56; if (_horz_offset < 0)
else _horz_offset = 0;
{
_horz_offset = (_formwidth > 80) ? (int)(pw - w)/2 : 0;
if (_horz_offset < 0)
_horz_offset = 0;
}
} }
else else
{ {
@ -1018,19 +1013,6 @@ TPrinter::TPrinter()
_finker = _isgraphics && _fink_mode ? NULL : new TPrint_intersector(_fink, _formlen); _finker = _isgraphics && _fink_mode ? NULL : new TPrint_intersector(_fink, _formlen);
} }
bool TPrinter::isfax() const
{
bool fax = FALSE;
#ifndef XVAGA
if (_printertype == winprinter)
{
const char* name = (const char*)((TPrinter*)this)->get_printrcd() + 4;
fax = strncmp(name, "FaxMan", 6) == 0;
}
#endif
return fax;
}
// @doc EXTERNAL // @doc EXTERNAL
// @mfunc Legge la configurazione della stampante // @mfunc Legge la configurazione della stampante
@ -1532,9 +1514,6 @@ bool TPrinter::open()
// prepare text object for new text // prepare text object for new text
_txt.destroy(); _txt.destroy();
_txt.interactive(FALSE); _txt.interactive(FALSE);
if (isfax())
start_fax_server();
} }
} }
@ -2007,39 +1986,3 @@ int TPrinter::calc_num_cols() const
return numcols; return numcols;
} }
///////////////////////////////////////////////////////////
// Gestione fax
///////////////////////////////////////////////////////////
bool TPrinter::start_fax_server() const
{
TDDE dde;
return dde.execute("EASYFAX", "FAX", "", "bafax");
}
void TPrinter::close_fax_server() const
{
TDDE dde;
const bool running = dde.initiate("EASYFAX", "FAX");
if (running)
dde.execute("[FileClose]");
}
bool TPrinter::send_fax(const char* tipo, const char* codice)
{
bool ok = isopen() && isfax();
if (ok)
{
if (tipo && codice)
{
TString cmd;
cmd << "[SetRecipient(" << tipo << ',' << codice << ")]";
TDDE dde;
dde.execute("EASYFAX", "FAX", cmd, "bafax");
}
close(); // termina la stampa corrente e la spedisce
open(); // riapre la stampante
}
return ok;
}

View File

@ -324,9 +324,6 @@ protected:
// @cmember Salva i parametri di configurazione correnti // @cmember Salva i parametri di configurazione correnti
void save_configuration(); void save_configuration();
// @cmember Chiude il fax server
void close_fax_server() const;
// @access Public Member // @access Public Member
public: public:
@ -598,12 +595,6 @@ public:
void set_offset(int a, int b) { _l_offset=a; _c_offset=b;} void set_offset(int a, int b) { _l_offset=a; _c_offset=b;}
// @cmember ritorna la riga di background se si stampa in modo testo // @cmember ritorna la riga di background se si stampa in modo testo
const char* background_chars(int l) const; const char* background_chars(int l) const;
// @cmember Ritorna TRUE se la stampante e' un fax
bool isfax() const;
// @cmember Lancia il fax server
bool start_fax_server() const;
// @cmember Spedisce la stampa attuale via fax
bool send_fax(const char* tipo, const char* codice);
// @cmember Ritorna la dimensione dei caratteri da stampare // @cmember Ritorna la dimensione dei caratteri da stampare
int get_char_size() const int get_char_size() const

View File

@ -30,7 +30,8 @@ TIndwin::TIndwin(long max, const char* txt, bool cancel, bool bar, int div)
: _text(NULL), _cancel(NULL), _bar(0), : _text(NULL), _cancel(NULL), _bar(0),
_status(0L), _max(max), _flags(0x0) _status(0L), _max(max), _flags(0x0)
{ {
if (_max <= 0) _max = 1; if (_max <= 0)
_max = 1;
TToken_string testo(txt, '\n'); TToken_string testo(txt, '\n');
word maxlen = div; word maxlen = div;

View File

@ -1654,6 +1654,7 @@ bool TRelation_application::load_transaction()
error_box("Ditta inesistente: %ld", firm); error_box("Ditta inesistente: %ld", firm);
} }
if (_curr_transaction == TRANSACTION_RUN) if (_curr_transaction == TRANSACTION_RUN)
@ -1889,4 +1890,3 @@ bool TRelation_application::mask2mail(const TMask& m)
} }
return ok; return ok;
} }

View File

@ -4,6 +4,7 @@
#include <colors.h> #include <colors.h>
#include <config.h> #include <config.h>
#include <controls.h> #include <controls.h>
#include <diction.h>
#include <relation.h> #include <relation.h>
#include <sheet.h> #include <sheet.h>
#include <urldefid.h> #include <urldefid.h>
@ -985,18 +986,18 @@ TSheet::TSheet(short x, short y, short dx, short dy,
fields_array().add(qf); fields_array().add(qf);
_sheet = qf->sheet(); _sheet = qf->sheet();
if (!(buttons & 0x10)) add_button(DLG_SELECT, "~Selezione", K_ENTER); if (!(buttons & 0x10)) add_button(DLG_SELECT, TR("~Selezione"), K_ENTER);
if (check_enabled()) if (check_enabled())
{ {
add_button(DLG_USER, "~Tutti", 0); add_button(DLG_USER, TR("~Tutti"), 0);
set_handler(DLG_USER, tutti_handler); set_handler(DLG_USER, tutti_handler);
} }
if (buttons & 0x01) add_button(DLG_LINK, "~Gestione", K_CTRL+'G'); if (buttons & 0x01) add_button(DLG_LINK, TR("~Gestione"), K_CTRL+'G');
if (buttons & 0x02) add_button(DLG_NEWREC, "~Nuovo", K_INS, BMP_NEWREC, BMP_NEWRECDN); if (buttons & 0x02) add_button(DLG_NEWREC, TR("~Nuovo"), K_INS, BMP_NEWREC, BMP_NEWRECDN);
if (buttons & 0x04) add_button(DLG_DELREC, "~Elimina", K_DEL, BMP_DELREC, BMP_DELRECDN); if (buttons & 0x04) add_button(DLG_DELREC, "", K_DEL);
if (buttons & 0x08) add_button(DLG_QUIT, "Fine", K_ESC); if (buttons & 0x08) add_button(DLG_QUIT, "", K_ESC);
else add_button(DLG_CANCEL, "Annulla", K_ESC); else add_button(DLG_CANCEL, "", K_ESC);
} }
TSheet::~TSheet() TSheet::~TSheet()
@ -1466,6 +1467,7 @@ void TBrowse_sheet::handler(
MENU_ITEM* menu = xvt_res_get_menu(BROWSE_BAR); MENU_ITEM* menu = xvt_res_get_menu(BROWSE_BAR);
if (menu) if (menu)
{ {
dictionary_translate_menu(menu);
const PNT& p = ep->v.mouse.where; const PNT& p = ep->v.mouse.where;
RCT cr; xvt_vobj_get_client_rect(win, &cr); RCT cr; xvt_vobj_get_client_rect(win, &cr);
XVT_POPUP_ALIGNMENT pa = XVT_POPUP_CENTER; XVT_POPUP_ALIGNMENT pa = XVT_POPUP_CENTER;

View File

@ -630,6 +630,11 @@ int TString::compare(
return res; return res;
} }
bool TString::starts_with(const char* s, bool ignorecase) const
{
return compare(s, strlen(s), ignorecase) == 0;
}
// Certified 100% // Certified 100%
// @doc EXTERNAL // @doc EXTERNAL

View File

@ -258,6 +258,8 @@ public:
bool match(const char* pat) const; bool match(const char* pat) const;
// @cmember Compara due stringhe (o i primi max caratteri) // @cmember Compara due stringhe (o i primi max caratteri)
int compare(const char* s, int max = -1, bool ignorecase = FALSE) const; int compare(const char* s, int max = -1, bool ignorecase = FALSE) const;
// @cmember Controlla se la strinvga comincia per s
bool starts_with(const char* s, bool ignorecase = FALSE) const;
}; };
// @doc EXTERNAL // @doc EXTERNAL

View File

@ -334,18 +334,14 @@ const char* itor(
// @func Permette di codificare i caratteri di escape // @func Permette di codificare i caratteri di escape
// //
// @rdesc Ritorna il carattere codificato // @rdesc Ritorna il carattere codificato
const char *esc( const char* esc(
const char* s) // @parm Carattere da codificare const char* s) // @parm Stringa da codificare
// @comm Viene utilizzata soprattuto in UNIX.
{ {
const char *s1 = s; const char *s1 = s == NULL ? "" : s;
char *s2 = __tmp_string; char* encoded = get_tmp_string().get_buffer(strlen(s));
int base; char* s2 = encoded;
while (*s1)
if (s1) {
while (*s1)
{
if (*s1 == '\\') if (*s1 == '\\')
{ {
s1++; s1++;
@ -359,48 +355,84 @@ const char *esc(
case 't' : *s2++ = '\t'; break; case 't' : *s2++ = '\t'; break;
default : default :
{ {
if (isdigit(*s1)) if (isdigit(*s1))
{ {
if (*s1 == '0') int base = 10;
{ if (*s1 == '0')
s1++; {
if (tolower(*s1) == 'x') s1++;
{ if (tolower(*s1) == 'x')
s1++; {
base = 16; s1++;
} base = 16;
else base = 8; }
} else
else base = 10; base = 8;
*s2 = 0; }
char c = tolower(*s1); *s2 = 0;
while (isdigit(c) || (base == 16 && c >= 'a' && c <= 'f')) char c = tolower(*s1);
{ while (isdigit(c) || (base == 16 && c >= 'a' && c <= 'f'))
*s2 *= base; {
if (isdigit(*s1)) *s2 += (*s1 - 48); *s2 *= base;
else *s2 += (*s1 - 'a' + 10) & 0x0F; if (isdigit(*s1)) *s2 += (*s1 - 48);
s1++; else *s2 += (*s1 - 'a' + 10) & 0x0F;
c = tolower(*s1); s1++;
} c = tolower(*s1);
s2++; s1--; }
} s2++; s1--;
else *s2++ = *s1; }
} else *s2++ = *s1;
}
}
else
if (*s1 == '^')
{
s1++;
*s2++ = (tolower(*s1) - 'a' + 1);
} }
else *s2++ = *s1 ; }
s1++;
} }
else
if (*s1 == '^')
{
s1++;
*s2++ = (tolower(*s1) - 'a' + 1);
}
else *s2++ = *s1 ;
s1++;
}
*s2 = '\0'; *s2 = '\0';
return(__tmp_string); return encoded;
} }
const char* unesc(
const char* s) // @parm Stringa da decodificare
{
char *decoded = get_tmp_string().get_buffer(strlen(s)*4);
char* s2 = decoded;
for (const char *s1 = s; *s1; s1++)
{
const char& c = *s1;
if (c >= '\0' && c < ' ')
{
switch(c)
{
case '\n':
*s2++ = '\\'; *s2++ = 'n';
break;
case '\r':
*s2++ = '\\'; *s2++ = 'r';
break;
case '\t':
*s2++ = '\\'; *s2++ = 't';
break;
default:
*s2++ = '\\'; *s2++ = '0'; *s2++ = 'x';
sprintf(s2, "%02x", int(c)); s2 += 2;
break;
}
}
else
*s2++ = c;
}
*s2 = '\0';
return decoded;
}
HIDDEN const char * const encryption_key = "QSECOFR-"; HIDDEN const char * const encryption_key = "QSECOFR-";
// @doc EXTERNAL // @doc EXTERNAL

View File

@ -35,7 +35,8 @@ inline bool is_not_slash(
char s) // @parm Carattere da confrontare char s) // @parm Carattere da confrontare
{ return s != '\\' && s != '/'; } { return s != '\\' && s != '/'; }
const char* esc(const char*); const char* esc(const char* str); // Trasforma le sequenze "\n" nel carattere '\n'
const char* unesc(const char* str); // Trasforma i caratteri '\n' nella sequenza "\n"
#define ODD(x) (x & 1) #define ODD(x) (x & 1)
#define EVEN(x) !(x & 1) #define EVEN(x) !(x & 1)

View File

@ -1749,12 +1749,6 @@ int TStampaEC_application::print_ec(TEC_Game_list* games)
{ {
f.ultima_pagina(); f.ultima_pagina();
printer().formfeed(); printer().formfeed();
if (printer().isfax())
{
const char* tipo = clf.get_char(CLI_TIPOCF) == 'C' ? "Clienti" : "Fornitori";
const char* codice = clf.get(CLI_CODCF);
printer().send_fax(tipo, codice);
}
} }
else else
update_numec(clf, -1); update_numec(clf, -1);

View File

@ -187,12 +187,6 @@ int TStampaSol_application::print_sol()
{ {
f.ultima_pagina(); f.ultima_pagina();
printer().formfeed(); printer().formfeed();
if (printer().isfax())
{
const char* tipo = clf.get_char(CLI_TIPOCF) ? "Clienti" : "Fornitori";
const char* codice = clf.get(CLI_CODCF);
printer().send_fax(tipo, codice);
}
} }
return one_printed ? 1 : 0; return one_printed ? 1 : 0;

View File

@ -1,12 +1,19 @@
#include "wx/wx.h" #include <wx/wx.h>
#include "wx/wfstream.h" #include <wx/wfstream.h>
#include "wx/protocol/http.h" #include <wx/socket.h>
#include <wx/config.h>
#include <wx/msw/iniconf.h>
#include <ctype.h> #include <ctype.h>
#include "Soap.h" #include "Soap.h"
#include "Diction.h" #include "Diction.h"
//////////////////////////////////////////////////////////
// TDictionaryEntry
///////////////////////////////////////////////////////////
class TDictionaryEntry : public wxObject class TDictionaryEntry : public wxObject
{ {
public: public:
@ -14,6 +21,21 @@ public:
TDictionaryEntry(const wxChar* str) : m_str(str) { } TDictionaryEntry(const wxChar* str) : m_str(str) { }
}; };
//////////////////////////////////////////////////////////
// Sorted array of TDictionaryEntry
///////////////////////////////////////////////////////////
static int CompareNodes(wxNode** n1, wxNode** n2)
{
return strcmp((*n1)->GetKeyString(), (*n2)->GetKeyString());
}
WX_DEFINE_ARRAY(wxNode*, TArrayOfNodes);
//////////////////////////////////////////////////////////
// TDictionary
///////////////////////////////////////////////////////////
class TDictionary : public wxHashTable class TDictionary : public wxHashTable
{ {
bool m_bDirty; bool m_bDirty;
@ -21,18 +43,27 @@ class TDictionary : public wxHashTable
protected: protected:
wxString Accentuate(const wxString& str) const; wxString Accentuate(const wxString& str) const;
const TDictionaryEntry* AddEntry(const wxString& ita, const wxChar* eng); const TDictionaryEntry* AddEntry(const wxString& ita, const wxChar* eng);
wxString GetFileName() const;
static bool FillCallback(TXmlItem& item, long jolly); static bool FillCallback(TXmlItem& item, long jolly);
bool Load(); bool Load();
public: public:
wxString Translate(const wxString& ita); wxString Translate(const wxString& ita, const wxString& lan);
TDictionary(); TDictionary();
~TDictionary(); ~TDictionary();
}; };
static TDictionary DevotoOli; static TDictionary DevotoOli;
wxString TDictionary::GetFileName() const
{
wxIniConfig ini("", "", "./server.ini");
ini.SetPath("/Dictionary");
wxString fname = ini.Read("FileName", "campo.dic");
return fname;
}
wxString TDictionary::Accentuate(const wxString& str) const wxString TDictionary::Accentuate(const wxString& str) const
{ {
const int pos = str.Find('\''); const int pos = str.Find('\'');
@ -114,7 +145,7 @@ bool TDictionary::FillCallback(TXmlItem& item, long jolly)
bool TDictionary::Load() bool TDictionary::Load()
{ {
wxFileInputStream inf("Campo.dic"); wxFileInputStream inf(GetFileName());
if (inf.Ok()) if (inf.Ok())
{ {
TXmlItem item; TXmlItem item;
@ -126,7 +157,7 @@ bool TDictionary::Load()
return GetCount() > 0; return GetCount() > 0;
} }
wxString TDictionary::Translate(const wxString& ita) wxString TDictionary::Translate(const wxString& ita, const wxString& lan)
{ {
if (GetCount() == 0) if (GetCount() == 0)
Load(); Load();
@ -153,11 +184,18 @@ TDictionary::~TDictionary()
if (m_bDirty) if (m_bDirty)
{ {
wxFileOutputStream outf("Campo.dic"); // Fill an array of nodes and sort them out
outf << "<xml><dictionary>\n"; TArrayOfNodes arr;
BeginFind(); BeginFind();
for (wxNode* pNode = Next(); pNode != NULL; pNode = Next()) for (wxNode* pNode = Next(); pNode != NULL; pNode = Next())
arr.Add(pNode);
arr.Sort(CompareNodes);
wxFileOutputStream outf(GetFileName());
outf << "<xml><dictionary>\n";
for (size_t i = 0; i < arr.GetCount(); i++)
{ {
const wxNode* pNode = arr[i];
outf << " <entry>\n"; outf << " <entry>\n";
outf << " <ita>" << pNode->GetKeyString() << "</ita>\n"; outf << " <ita>" << pNode->GetKeyString() << "</ita>\n";
outf << " <eng>" << ((TDictionaryEntry*)pNode->GetData())->m_str << "</eng>\n"; outf << " <eng>" << ((TDictionaryEntry*)pNode->GetData())->m_str << "</eng>\n";
@ -170,15 +208,14 @@ TDictionary::~TDictionary()
bool DoTranslate(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer) bool DoTranslate(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer)
{ {
const TXmlItem* xmlSentence = xmlMethod.FindFirst("sentence"); const TXmlItem* xmlSentence = xmlMethod.FindFirst("sentence");
if (xmlSentence != NULL) // const TXmlItem* xmlLanguage = xmlMethod.FindFirst("language");
if (xmlSentence != NULL /* && xmlLanguage != NULL */)
{ {
const TXmlItem* xmlItalian = xmlSentence->GetChild(0); const wxString ita = xmlSentence->GetEnclosedText();
if (xmlItalian != NULL) const wxString lan; // = xmlLanguage->GetEnclosedText();
{ wxString result = DevotoOli.Translate(ita, lan);
wxString result = DevotoOli.Translate(xmlItalian->GetText()); xmlAnswer.AddSoapString("sentence", result);
xmlAnswer.AddSoapString("sentence", result); return true;
return true;
}
} }
return false; return false;
} }

View File

@ -16,9 +16,12 @@
// headers // headers
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// For compilers that support precompilation, includes "wx/wx.h". #include <wx/wx.h>
#include "wx/wx.h" #include <wx/socket.h>
#include "wx/socket.h"
#include <wx/config.h>
#include <wx/msw/iniconf.h>
#include "soap.h" #include "soap.h"
@ -36,16 +39,22 @@ public:
// Define a new frame type: this is going to be our main frame // Define a new frame type: this is going to be our main frame
class SoapFrame : public wxFrame class SoapFrame : public wxFrame
{ {
clock_t m_last_text;
public: public:
SoapFrame(); SoapFrame();
~SoapFrame(); ~SoapFrame();
// event handlers (these functions should _not_ be virtual) // event handlers (these functions should _not_ be virtual)
void OnQuit(wxCommandEvent& event); void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event); void OnAbout(wxCommandEvent& event);
void OnServerEvent(wxSocketEvent& event); void OnServerEvent(wxSocketEvent& event);
void OnSocketEvent(wxSocketEvent& event); void OnSocketEvent(wxSocketEvent& event);
// Roba mia
void AppendText(const wxChar* str);
int GetDefaultPort() const;
void ProcessSoapCommand(wxSocketBase *sock); void ProcessSoapCommand(wxSocketBase *sock);
// convenience functions // convenience functions
@ -118,51 +127,77 @@ bool SoapServerApp::OnInit()
// main frame // main frame
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
int SoapFrame::GetDefaultPort() const
{
int nPort = 3883;
wxIniConfig ini("", "", "./campo.ini");
ini.SetPath("/Server");
const wxString str = ini.Read("Dictionary", "");
const int colon = str.Find(':');
if (colon > 0)
nPort = atoi(str.Mid(colon+1));
return nPort;
}
void SoapFrame::AppendText(const wxChar* str)
{
const clock_t now = clock();
if (now - m_last_text > 60000)
m_text->SetValue(str);
else
m_text->AppendText(str);
m_last_text = now;
}
// frame constructor // frame constructor
SoapFrame::SoapFrame() : wxFrame((wxFrame *)NULL, -1, SoapFrame::SoapFrame() : wxFrame((wxFrame *)NULL, -1, "Soap Server",
_("Soap Server"), wxDefaultPosition, wxSize(300, 300))
wxDefaultPosition, wxSize(300, 200))
{ {
// Give the frame an icon // Give the frame an icon
SetIcon(wxICON(mondrian)); SetIcon(wxICON(mondrian));
// Make menus // Make menus
m_menuFile = new wxMenu(); m_menuFile = new wxMenu();
m_menuFile->Append(SERVER_ABOUT, _("&About...\tCtrl-A"), _("Show about dialog")); m_menuFile->Append(SERVER_ABOUT, "&About...\tCtrl-A", "Show about dialog");
m_menuFile->AppendSeparator(); m_menuFile->AppendSeparator();
m_menuFile->Append(SERVER_QUIT, _("E&xit\tAlt-X"), _("Quit server")); m_menuFile->Append(SERVER_QUIT, "E&xit\tAlt-X", "Quit server");
// Append menus to the menubar // Append menus to the menubar
m_menuBar = new wxMenuBar(); m_menuBar = new wxMenuBar();
m_menuBar->Append(m_menuFile, _("&File")); m_menuBar->Append(m_menuFile, "&File");
SetMenuBar(m_menuBar); SetMenuBar(m_menuBar);
// Make a textctrl for logging
m_text = new wxTextCtrl(this, -1,
"Welcome to SOAP Server\n",
wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxTE_READONLY);
// Status bar // Status bar
CreateStatusBar(2); CreateStatusBar(2);
// Make a textctrl for logging
m_text = new wxTextCtrl(this, -1,
_("Welcome to SOAP Server\n"),
wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxTE_READONLY);
// Create the address - defaults to localhost:0 initially // Create the address - defaults to localhost:0 initially
wxIPV4address addr; wxIPV4address addr;
addr.Service(3000); addr.Service(GetDefaultPort());
// Create the socket // Create the socket
m_server = new wxSocketServer(addr); m_server = new wxSocketServer(addr);
m_last_text = clock();
// We use Ok() here to see if the server is really listening // We use Ok() here to see if the server is really listening
if (! m_server->Ok()) if (! m_server->Ok())
{ {
m_text->AppendText(_("Could not listen at the specified port !\n\n")); wxString str;
str << "Could not listen to port " << addr.Service() << "\n\n";
AppendText(str);
return; return;
} }
else else
{ {
m_text->AppendText(_("Server listening.\n\n")); wxString str;
str << "Server listening on port " << addr.Service() << "\n\n";
AppendText(str);
} }
// Setup the event handler and subscribe to connection events // Setup the event handler and subscribe to connection events
@ -191,45 +226,41 @@ void SoapFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
void SoapFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) void SoapFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{ {
wxMessageBox(_("Soap Server\n(c) 2002 by Aga\n"), wxMessageBox("Soap Server\n(c) 2002 by Aga\n",
_("About Soap Server"), "About Soap Server",
wxOK | wxICON_INFORMATION, this); wxOK | wxICON_INFORMATION, this);
} }
void SoapFrame::ProcessSoapCommand(wxSocketBase *sock) void SoapFrame::ProcessSoapCommand(wxSocketBase *sock)
{ {
m_text->SetValue(_("Processing begins\n\n"));
sock->SetFlags(wxSOCKET_NOWAIT); sock->SetFlags(wxSOCKET_NOWAIT);
// Read the data // Read the data
char buf[4096]; memset(buf, 0, sizeof(buf)); wxChar buf[4096]; memset(buf, 0, sizeof(buf));
unsigned int len = sock->Read(buf, sizeof(buf)).LastCount(); unsigned int len = sock->Read(buf, sizeof(buf)).LastCount();
m_text->AppendText(_(buf)); AppendText(buf);
wxString strAnswer = SoapProcessMessage(buf, len); wxString strAnswer = SoapProcessMessage(buf, len);
m_text->AppendText(_("\nSending response\n\n")); AppendText("\n\n");
m_text->AppendText(_(strAnswer)); AppendText(strAnswer);
// Write it back // Write it back
sock->Write(strAnswer, strAnswer.Length()); sock->Write(strAnswer, strAnswer.Length());
m_text->AppendText(_("\n\nProcessing ends\n\n"));
} }
void SoapFrame::OnServerEvent(wxSocketEvent& event) void SoapFrame::OnServerEvent(wxSocketEvent& event)
{ {
wxString s = _("OnServerEvent: "); wxString s = "OnServerEvent: ";
wxSocketBase *sock; wxSocketBase *sock;
switch(event.GetSocketEvent()) switch(event.GetSocketEvent())
{ {
case wxSOCKET_CONNECTION : s.Append(_("wxSOCKET_CONNECTION\n")); break; case wxSOCKET_CONNECTION : s.Append("wxSOCKET_CONNECTION\n"); break;
default : s.Append(_("Unexpected event !\n")); break; default : s.Append("Unexpected event !\n"); break;
} }
m_text->AppendText(s); AppendText(s);
// Accept new connection if there is one in the pending // Accept new connection if there is one in the pending
// connections queue, else exit. We use Accept(FALSE) for // connections queue, else exit. We use Accept(FALSE) for
@ -240,11 +271,11 @@ void SoapFrame::OnServerEvent(wxSocketEvent& event)
if (sock) if (sock)
{ {
m_text->AppendText(_("New client connection accepted\n\n")); AppendText("New client connection accepted\n\n");
} }
else else
{ {
m_text->AppendText(_("Error: couldn't accept a new connection\n\n")); AppendText("Error: couldn't accept a new connection\n\n");
sock->Destroy(); sock->Destroy();
return; return;
} }
@ -259,18 +290,18 @@ void SoapFrame::OnServerEvent(wxSocketEvent& event)
void SoapFrame::OnSocketEvent(wxSocketEvent& event) void SoapFrame::OnSocketEvent(wxSocketEvent& event)
{ {
wxString s = _("OnSocketEvent: "); wxString s = "OnSocketEvent: ";
wxSocketBase *sock = event.GetSocket(); wxSocketBase *sock = event.GetSocket();
// First, print a message // First, print a message
switch(event.GetSocketEvent()) switch(event.GetSocketEvent())
{ {
case wxSOCKET_INPUT : s.Append(_("wxSOCKET_INPUT\n")); break; case wxSOCKET_INPUT : s.Append("wxSOCKET_INPUT\n"); break;
case wxSOCKET_LOST : s.Append(_("wxSOCKET_LOST\n")); break; case wxSOCKET_LOST : s.Append("wxSOCKET_LOST\n"); break;
default : s.Append(_("Unexpected event !\n")); break; default : s.Append("Unexpected event !\n"); break;
} }
m_text->AppendText(s); AppendText(s);
// Now we process the event // Now we process the event
switch(event.GetSocketEvent()) switch(event.GetSocketEvent())
@ -300,7 +331,7 @@ void SoapFrame::OnSocketEvent(wxSocketEvent& event)
// middle of a test or something. Destroy() takes care of all // middle of a test or something. Destroy() takes care of all
// this for us. // this for us.
m_text->AppendText(_("Deleting socket.\n\n")); AppendText("Deleting socket.\n\n");
sock->Destroy(); sock->Destroy();
break; break;
} }
@ -315,6 +346,6 @@ void SoapFrame::OnSocketEvent(wxSocketEvent& event)
void SoapFrame::UpdateStatusBar() void SoapFrame::UpdateStatusBar()
{ {
wxString s; wxString s;
s.Printf(_("%d clients connected"), m_numClients); s.Printf("%d clients connected", m_numClients);
SetStatusText(s, 1); SetStatusText(s, 1);
} }

View File

@ -236,18 +236,20 @@ TXmlItem& TXmlItem::AddChild(const wxChar* strTagName)
return i; return i;
} }
TXmlItem& TXmlItem::AddSoapString(const wxChar* name, const wxChar* value) TXmlItem& TXmlItem::AddSoapString(const wxChar* name, const wxChar* value, bool typized)
{ {
TXmlItem& xmlVar = AddChild(name); TXmlItem& xmlVar = AddChild(name);
xmlVar.SetAttr("xsi:type", "xsd:string"); if (typized)
xmlVar.SetAttr("xsi:type", "xsd:string");
xmlVar.AddChild("").SetText(value); xmlVar.AddChild("").SetText(value);
return xmlVar; return xmlVar;
} }
TXmlItem& TXmlItem::AddSoapInt(const wxChar* name, int value) TXmlItem& TXmlItem::AddSoapInt(const wxChar* name, int value, bool typized)
{ {
TXmlItem& xmlVar = AddChild(name); TXmlItem& xmlVar = AddChild(name);
xmlVar.SetAttr("xsi:type", "xsd:int"); if (typized)
xmlVar.SetAttr("xsi:type", "xsd:int");
wxString str; str += value; wxString str; str += value;
xmlVar.AddChild("").SetText(str); xmlVar.AddChild("").SetText(str);
return xmlVar; return xmlVar;
@ -302,6 +304,26 @@ TXmlItem* TXmlItem::ForEach(XmlItemCallback cb, long jolly)
return NULL; return NULL;
} }
static bool GetEnclosedTextCallback(TXmlItem& item, long jolly)
{
wxString* strText = (wxString*)jolly;
const wxString& str = item.GetText();
if (!str.IsEmpty())
{
if (!strText->IsEmpty())
*strText << " ";
*strText << str;
}
return false;
}
wxString TXmlItem::GetEnclosedText() const
{
wxString text;
((TXmlItem*)this)->ForEach(GetEnclosedTextCallback, (long)&text);
return text;
}
void TXmlItem::Write(wxOutputStream& outf, int tab) const void TXmlItem::Write(wxOutputStream& outf, int tab) const
{ {
if (!GetTag().IsEmpty()) if (!GetTag().IsEmpty())
@ -347,7 +369,6 @@ wxString TXmlItem::AsString() const
char* buf = str.GetWriteBuf(nSize); char* buf = str.GetWriteBuf(nSize);
memset(buf, 0, nSize); memset(buf, 0, nSize);
wxMemoryOutputStream outf(buf, nSize); wxMemoryOutputStream outf(buf, nSize);
// outf << "<?xml Version=\"1.0\" ?>"; // Non dovrebbe servire a nulla
Write(outf); Write(outf);
str.UngetWriteBuf(); str.UngetWriteBuf();
if (buf[nSize-1] == '\0') if (buf[nSize-1] == '\0')
@ -357,7 +378,7 @@ wxString TXmlItem::AsString() const
return str; return str;
} }
bool FindFirstCallback(TXmlItem& item, long jolly) static bool FindFirstCallback(TXmlItem& item, long jolly)
{ {
const wxChar* strTag = (const wxChar*)jolly; const wxChar* strTag = (const wxChar*)jolly;
return item.GetTag() == strTag; return item.GetTag() == strTag;
@ -417,8 +438,7 @@ wxString SoapProcessMessage(const char* buf, unsigned int len)
break; break;
if (pxmlMethod->GetTag().StartsWith("m:")) if (pxmlMethod->GetTag().StartsWith("m:"))
{ {
wxString str; wxString str = pxmlMethod->GetTag(); str += "Result";
str = pxmlMethod->GetTag(); str += "Result";
TXmlItem& xmlAnswer = xmlBody.AddChild(str); TXmlItem& xmlAnswer = xmlBody.AddChild(str);
SoapProcessMethod(*pxmlMethod, xmlAnswer); SoapProcessMethod(*pxmlMethod, xmlAnswer);
} }
@ -433,10 +453,8 @@ wxString SoapProcessMessage(const char* buf, unsigned int len)
strAnswer += "Connection: close\n"; strAnswer += "Connection: close\n";
strAnswer += "Content-Length: "; strAnswer += strLength; strAnswer += "Content-Length: "; strAnswer += strLength;
strAnswer += "\nContent-Type: text/xml; charset=utf-8\n"; strAnswer += "\nContent-Type: text/xml; charset=utf-8\n";
strAnswer += "Date: "; strAnswer += "Date: "; strAnswer += wxDateTime::Now().Format("%#c");
strAnswer += wxDateTime::Now().Format("%#c"); strAnswer += "\nServer: "; strAnswer += wxGetHostName();
strAnswer += "\nServer: ";
strAnswer += wxGetHostName();
strAnswer += "\r\n\r\n"; strAnswer += "\r\n\r\n";
strAnswer += strResult; strAnswer += strResult;

View File

@ -28,13 +28,14 @@ public:
const wxString& GetText() const { return m_strText; } const wxString& GetText() const { return m_strText; }
void SetText(const wxChar* str) { m_strText = str; } void SetText(const wxChar* str) { m_strText = str; }
wxString GetEnclosedText() const;
void SetAttr(const wxChar* strAttr, const wxChar* strVal); void SetAttr(const wxChar* strAttr, const wxChar* strVal);
wxString GetAttr(const wxChar* strAttr) const; wxString GetAttr(const wxChar* strAttr) const;
TXmlItem& AddChild(const wxChar* strTag); TXmlItem& AddChild(const wxChar* strTag);
TXmlItem& AddSoapString(const wxChar* name, const wxChar* value); TXmlItem& AddSoapString(const wxChar* name, const wxChar* value, bool typized = false);
TXmlItem& AddSoapInt(const wxChar* name, int value); TXmlItem& AddSoapInt(const wxChar* name, int value, bool typized = false);
int GetChildren() const; int GetChildren() const;
TXmlItem* GetChild(size_t n) const; TXmlItem* GetChild(size_t n) const;

Binary file not shown.

View File

@ -1,38 +0,0 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: SoapServ - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "c:\temp\RSPA1C2.TMP" with contents
[
/nologo /MTd /W3 /Gm /GX /ZI /Od /I "\wx229\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FR"Debug/" /Fo"Debug/" /Fd"Debug/" /FD /c
"C:\U\GUY\R020200\SOAP\server.cpp"
]
Creating command line "cl.exe @c:\temp\RSPA1C2.TMP"
Creating temporary file "c:\temp\RSPA1C3.TMP" with contents
[
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxd.lib xpmd.lib pngd.lib zlibd.lib jpegd.lib tiffd.lib /nologo /subsystem:windows /incremental:yes /pdb:"Debug/server.pdb" /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /nodefaultlib:"msvcrt.lib" /out:"Debug/server.exe" /pdbtype:sept /libpath:"/wx229/lib"
.\Debug\Diction.obj
.\Debug\server.obj
.\Debug\soap.obj
.\Debug\server.res
]
Creating command line "link.exe @c:\temp\RSPA1C3.TMP"
<h3>Output Window</h3>
Compiling...
server.cpp
Linking...
Creating command line "bscmake.exe /nologo /o"Debug/SoapServ.bsc" .\Debug\Diction.sbr .\Debug\server.sbr .\Debug\soap.sbr"
Creating browse info file...
<h3>Output Window</h3>
<h3>Results</h3>
server.exe - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

View File

@ -193,7 +193,7 @@ bool TScontrino_mask::save_ini(KEY k)
bool TScontrino_mask::send_er400_data(bool extra) bool TScontrino_mask::send_er400_data(bool extra)
{ {
TSheet_field& sheet = sfield(F_SHEET); /* TSheet_field& sheet = sfield(F_SHEET);
const int rows = sheet.items(); const int rows = sheet.items();
if (rows <= 0) if (rows <= 0)
return FALSE; return FALSE;
@ -277,7 +277,7 @@ bool TScontrino_mask::send_er400_data(bool extra)
cmd << m.get(101) << ']'; cmd << m.get(101) << ']';
smart.execute(cmd); smart.execute(cmd);
smart.terminate(); smart.terminate();*/
return TRUE; return TRUE;
} }

View File

@ -220,3 +220,12 @@ void OsWin32_DrawBitmap(unsigned int hBitmap, unsigned int hDC,
} }
} }
void OsWin32_Beep(int severity)
{
switch (severity)
{
case 0: MessageBeep(MB_OK); break;
case 1: MessageBeep(MB_ICONEXCLAMATION); break;
default: MessageBeep(MB_ICONSTOP); break;
}
}

View File

@ -1,6 +1,9 @@
void OsWin32_Beep(int severity);
bool OsWin32_CheckPrinterInfo(const void* data, unsigned int size); bool OsWin32_CheckPrinterInfo(const void* data, unsigned int size);
void* OsWin32_ConvertFromNativePrinterInfo(void* hGlobal, unsigned int& nSize); void* OsWin32_ConvertFromNativePrinterInfo(void* hGlobal, unsigned int& nSize);
void* OsWin32_ConvertToNativePrinterInfo(void* data, unsigned int nSize); void* OsWin32_ConvertToNativePrinterInfo(void* data, unsigned int nSize);
void OsWin32_DrawBitmap(unsigned int hBitmap, unsigned int hDC,
int xd, int yd, int wd, int hd, int xs, int ys, int ws, int hs);
int OsWin32_EnumerateFamilies(unsigned int hDC, char** families, int max_count); int OsWin32_EnumerateFamilies(unsigned int hDC, char** families, int max_count);
int OsWin32_EnumerateSizes(unsigned int hDC, const char* name, long* sizes, short* scalable, int max_count); int OsWin32_EnumerateSizes(unsigned int hDC, const char* name, long* sizes, short* scalable, int max_count);
void OsWin32_SetCaptionStyle(unsigned int handle, bool set); void OsWin32_SetCaptionStyle(unsigned int handle, bool set);
@ -8,7 +11,5 @@ void* OsWin32_GetPrinterInfo(int& size, const char* printer);
void OsWin32_SetClippingRect(unsigned int hDC, int x, int y, int w, int h); void OsWin32_SetClippingRect(unsigned int hDC, int x, int y, int w, int h);
void OsWin32_StretchBlt(unsigned int hDst, int xd, int yd, int wd, int hd, void OsWin32_StretchBlt(unsigned int hDst, int xd, int yd, int wd, int hd,
unsigned int hSrc, int xs, int ys, int ws, int hs); unsigned int hSrc, int xs, int ys, int ws, int hs);
void OsWin32_DrawBitmap(unsigned int hBitmap, unsigned int hDC,
int xd, int yd, int wd, int hd, int xs, int ys, int ws, int hs);
void OsWin32_UpdateWindow(unsigned int handle); void OsWin32_UpdateWindow(unsigned int handle);

View File

@ -674,12 +674,22 @@ void TwxWindow::DoXvtEvent(EVENT& e)
void TwxWindow::OnChar(wxKeyEvent& event) void TwxWindow::OnChar(wxKeyEvent& event)
{ {
static bool bDot2Comma = FALSE; static bool bSkipNextDotKey = FALSE;
EVENT e; memset(&e, 0, sizeof(EVENT)); EVENT e; memset(&e, 0, sizeof(EVENT));
e.type = E_CHAR; e.type = E_CHAR;
int k = event.GetKeyCode(); int k = event.GetKeyCode();
if (bSkipNextDotKey)
{
bSkipNextDotKey = FALSE;
if (k == '.')
{
event.Skip();
return;
}
}
switch (k) switch (k)
{ {
case WXK_ALT: case WXK_ALT:
@ -698,9 +708,9 @@ void TwxWindow::OnChar(wxKeyEvent& event)
return; return;
case WXK_NUMPAD_DECIMAL: // ??? Non arriva mai case WXK_NUMPAD_DECIMAL: // ??? Non arriva mai
case WXK_DECIMAL: // ??? Arriva sia '.' sia WXK_DECIMAL=340 case WXK_DECIMAL: // ??? Arriva sia '.' sia WXK_DECIMAL=340
event.Skip(); k = ',';
bDot2Comma = TRUE; bSkipNextDotKey = TRUE;
return; break;
case WXK_DOWN : k = K_DOWN; break; case WXK_DOWN : k = K_DOWN; break;
case WXK_LEFT : k = K_LEFT; break; case WXK_LEFT : k = K_LEFT; break;
case WXK_NEXT : k = K_NEXT; break; case WXK_NEXT : k = K_NEXT; break;
@ -711,13 +721,6 @@ void TwxWindow::OnChar(wxKeyEvent& event)
if (event.ShiftDown()) if (event.ShiftDown())
k = K_BTAB; k = K_BTAB;
break; break;
case '.':
if (bDot2Comma)
{
k = ',';
bDot2Comma = FALSE;
}
break;
default: default:
if (k >= WXK_F1 && k <= WXK_F24) if (k >= WXK_F1 && k <= WXK_F24)
k = K_F1 + k - WXK_F1; k = K_F1 + k - WXK_F1;
@ -782,6 +785,7 @@ void TwxWindow::OnMouseDown(wxMouseEvent& event)
e.v.mouse.button = event.RightDown() ? 1 : 0; e.v.mouse.button = event.RightDown() ? 1 : 0;
e.v.mouse.control = event.ControlDown(); e.v.mouse.control = event.ControlDown();
e.v.mouse.shift = event.ShiftDown(); e.v.mouse.shift = event.ShiftDown();
int x, y; event.GetPosition(&x, &y); int x, y; event.GetPosition(&x, &y);
e.v.mouse.where.h = x; e.v.mouse.where.h = x;
e.v.mouse.where.v = y; e.v.mouse.where.v = y;
@ -1291,8 +1295,24 @@ void xvt_ctl_set_checked(WINDOW Win, BOOLEAN Check)
// Debug functions // Debug functions
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
void xvt_debug_printf(const char* fmt, const char* str) void xvt_debug_printf(const char* fmt, ...)
{ SORRY_BOX(); } {
#ifndef NDEBUG
static FILE* f = NULL;
if (f == NULL)
f = fopen("trace.log", "w");
if (f != NULL)
{
char msg[256];
va_list argptr;
va_start(argptr,fmt);
vsprintf(msg,fmt,argptr);
va_end(argptr);
fprintf(f, "%s\n", msg);
fflush(f);
}
#endif
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Common dialogs // Common dialogs
@ -1310,7 +1330,7 @@ void xvt_dm_post_error(char *fmt)
void xvt_dm_post_fatal_exit(char *fmt) void xvt_dm_post_fatal_exit(char *fmt)
{ wxLogFatalError(fmt); } { wxLogFatalError(fmt); }
FL_STATUS xvt_dm_post_file_open(FILE_SPEC *fsp, char *msg) FL_STATUS xvt_dm_post_file_open(FILE_SPEC *fsp, const char *msg)
{ {
const int flags = wxOPEN | wxHIDE_READONLY | wxFILE_MUST_EXIST; const int flags = wxOPEN | wxHIDE_READONLY | wxFILE_MUST_EXIST;
wxString path = fsp->dir.path; wxString path = fsp->dir.path;
@ -1327,7 +1347,7 @@ FL_STATUS xvt_dm_post_file_open(FILE_SPEC *fsp, char *msg)
return FL_OK; return FL_OK;
} }
FL_STATUS xvt_dm_post_file_save(FILE_SPEC *fsp, char *msg) FL_STATUS xvt_dm_post_file_save(FILE_SPEC *fsp, const char *msg)
{ {
const int flags = wxSAVE | wxHIDE_READONLY; const int flags = wxSAVE | wxHIDE_READONLY;
wxString path = fsp->dir.path; wxString path = fsp->dir.path;
@ -1561,7 +1581,7 @@ void xvt_dwin_draw_set_pos(WINDOW win, PNT pnt)
dc._pnt.y = pnt.v; dc._pnt.y = pnt.v;
} }
void xvt_dwin_draw_text(WINDOW win, int x, int y, char *s, int len) void xvt_dwin_draw_text(WINDOW win, int x, int y, const char *s, int len)
{ {
if (s && *s && len != 0) if (s && *s && len != 0)
{ {
@ -1622,7 +1642,7 @@ long xvt_dwin_get_font_size_mapped(WINDOW win)
return height; return height;
} }
int xvt_dwin_get_text_width(WINDOW win, char *s, int len) int xvt_dwin_get_text_width(WINDOW win, const char *s, int len)
{ {
int width = 0, height; int width = 0, height;
@ -2229,7 +2249,10 @@ void xvt_image_transfer(XVT_IMAGE dstimage, XVT_IMAGE srcimage, RCT *dstrctp, RC
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
DATA_PTR xvt_mem_alloc(size_t size) DATA_PTR xvt_mem_alloc(size_t size)
{ return (DATA_PTR)malloc(size); } {
DATA_PTR ptr = (DATA_PTR)malloc(size);
return ptr;
}
void xvt_mem_free(DATA_PTR p) void xvt_mem_free(DATA_PTR p)
{ free(p); } { free(p); }
@ -2303,6 +2326,46 @@ MENU_ITEM* xvt_menu_get_tree(WINDOW win)
return m; return m;
} }
static TranslateMenu(wxMenu* pMenu, TRANSLATE_CALLBACK tc)
{
wxMenuItemList& list = pMenu->GetMenuItems();
for (unsigned i = 0; i < list.GetCount(); i++)
{
wxMenuItem* mi = list[i];
if (!mi->IsSeparator())
{
const char* ita = mi->GetText();
const char* eng = tc(ita);
mi->SetText(eng);
wxMenu* pMenu = mi->GetSubMenu();
if (pMenu != NULL)
TranslateMenu(pMenu, tc);
}
}
}
void xvt_menu_translate_tree(WINDOW win, TRANSLATE_CALLBACK tc)
{
if (win == TASK_WIN)
{
TTaskWin& w = *(TTaskWin*)win;
wxMenuBar* pMenuBar = w.GetMenuBar();
if (pMenuBar != NULL)
{
for (int m = pMenuBar->GetMenuCount()-1; m >= 0; m--)
{
const char* ita = pMenuBar->GetLabelTop(m);
const char* eng = tc(ita);
pMenuBar->SetLabelTop(m, eng);
wxMenu* pMenu = pMenuBar->GetMenu(m);
TranslateMenu(pMenu, tc);
}
// w.SetMenuBar(pMenuBar);
}
}
}
void xvt_menu_set_font_sel(WINDOW win, XVT_FNTID font_id) void xvt_menu_set_font_sel(WINDOW win, XVT_FNTID font_id)
{ /* Ignored */ } { /* Ignored */ }
@ -2470,8 +2533,9 @@ void xvt_res_free_menu_tree(MENU_ITEM* tree)
XVT_IMAGE xvt_res_get_image(int rid) XVT_IMAGE xvt_res_get_image(int rid)
{ {
const wxString strFileName = ::GetResourceName("Image", rid); const wxString strFileName = ::GetResourceName("Image", rid);
XVT_ASSERT(!strFileName.IsEmpty()); const bool ok = !strFileName.IsEmpty();
return xvt_image_read(strFileName); XVT_ASSERT(ok);
return ok ? xvt_image_read(strFileName) : NULL;
} }
static int SplitString(const wxString& str, wxArrayString& a) static int SplitString(const wxString& str, wxArrayString& a)
@ -2575,7 +2639,7 @@ char* xvt_res_get_str(int rid, char *s, int sz_s)
XVT_ASSERT(s != NULL && sz_s > 0); XVT_ASSERT(s != NULL && sz_s > 0);
const wxString str = ::GetResourceName("String", rid); const wxString str = ::GetResourceName("String", rid);
strncpy(s, str, sz_s); strncpy(s, str, sz_s);
s[sz_s] = '\0'; s[sz_s-1] = '\0';
return s; return s;
} }
@ -2689,7 +2753,11 @@ void xvt_sbar_set_range(WINDOW win, SCROLL_TYPE t, int min, int max)
void xvt_scr_beep(void) void xvt_scr_beep(void)
{ {
#ifdef WIN32
OsWin32_Beep(0);
#else
wxBell(); wxBell();
#endif
} }
WINDOW xvt_scr_get_focus_topwin(void) WINDOW xvt_scr_get_focus_topwin(void)

View File

@ -52,13 +52,13 @@ void xvt_ctl_check_radio_button(WINDOW Win, WINDOW* Wins, int NbrWindows);
WINDOW xvt_ctl_create_def(WIN_DEF *win_def_p, WINDOW parent_win, long app_data); WINDOW xvt_ctl_create_def(WIN_DEF *win_def_p, WINDOW parent_win, long app_data);
void xvt_ctl_set_checked(WINDOW Win, BOOLEAN Check); void xvt_ctl_set_checked(WINDOW Win, BOOLEAN Check);
void xvt_debug_printf(const char* fmt, const char* str); void xvt_debug_printf(const char* fmt, ...);
ASK_RESPONSE xvt_dm_post_ask(const char* Btn1, const char*Btn2, const char* Btn3, const char* xin_buffer); ASK_RESPONSE xvt_dm_post_ask(const char* Btn1, const char*Btn2, const char* Btn3, const char* xin_buffer);
void xvt_dm_post_error(char *fmt); void xvt_dm_post_error(char *fmt);
void xvt_dm_post_fatal_exit(char *fmt); void xvt_dm_post_fatal_exit(char *fmt);
FL_STATUS xvt_dm_post_file_open(FILE_SPEC *fsp, char *msg); FL_STATUS xvt_dm_post_file_open(FILE_SPEC *fsp, const char *msg);
FL_STATUS xvt_dm_post_file_save(FILE_SPEC *fsp, char *msg); FL_STATUS xvt_dm_post_file_save(FILE_SPEC *fsp, const char *msg);
BOOLEAN xvt_dm_post_font_sel(WINDOW win, XVT_FNTID font_id, PRINT_RCD *precp, unsigned long reserved); BOOLEAN xvt_dm_post_font_sel(WINDOW win, XVT_FNTID font_id, PRINT_RCD *precp, unsigned long reserved);
void xvt_dm_post_note(char *fmt); void xvt_dm_post_note(char *fmt);
BOOLEAN xvt_dm_post_page_setup(PRINT_RCD *precp); BOOLEAN xvt_dm_post_page_setup(PRINT_RCD *precp);
@ -73,13 +73,13 @@ void xvt_dwin_draw_pie(WINDOW win, RCT *rctp, int start_x, int start_y,
void xvt_dwin_draw_polygon(WINDOW win, PNT *lpnts, int npnts); void xvt_dwin_draw_polygon(WINDOW win, PNT *lpnts, int npnts);
void xvt_dwin_draw_rect(WINDOW win, RCT *rctp); void xvt_dwin_draw_rect(WINDOW win, RCT *rctp);
void xvt_dwin_draw_set_pos(WINDOW win, PNT pnt); void xvt_dwin_draw_set_pos(WINDOW win, PNT pnt);
void xvt_dwin_draw_text(WINDOW win, int x, int y, char *s, int len); void xvt_dwin_draw_text(WINDOW win, int x, int y, const char *s, int len);
RCT* xvt_dwin_get_clip(WINDOW win, RCT* rct); RCT* xvt_dwin_get_clip(WINDOW win, RCT* rct);
DRAW_CTOOLS* xvt_dwin_get_draw_ctools(WINDOW win, DRAW_CTOOLS *ctoolsp); DRAW_CTOOLS* xvt_dwin_get_draw_ctools(WINDOW win, DRAW_CTOOLS *ctoolsp);
XVT_FNTID xvt_dwin_get_font(WINDOW win); XVT_FNTID xvt_dwin_get_font(WINDOW win);
void xvt_dwin_get_font_metrics(WINDOW win, int *leadingp, int *ascentp, int *descentp); void xvt_dwin_get_font_metrics(WINDOW win, int *leadingp, int *ascentp, int *descentp);
long xvt_dwin_get_font_size_mapped(WINDOW win); long xvt_dwin_get_font_size_mapped(WINDOW win);
int xvt_dwin_get_text_width(WINDOW win, char *s, int len); int xvt_dwin_get_text_width(WINDOW win, const char *s, int len);
void xvt_dwin_invalidate_rect(WINDOW win, RCT *rctp); void xvt_dwin_invalidate_rect(WINDOW win, RCT *rctp);
BOOLEAN xvt_dwin_is_update_needed(WINDOW Win, RCT* rctp); BOOLEAN xvt_dwin_is_update_needed(WINDOW Win, RCT* rctp);
void xvt_dwin_scroll_rect(WINDOW win, RCT *rctp, int dh, int dv); void xvt_dwin_scroll_rect(WINDOW win, RCT *rctp, int dh, int dv);
@ -156,6 +156,9 @@ void xvt_menu_set_item_enabled(WINDOW win, MENU_TAG tag, BOOLEAN enable);
void xvt_menu_set_item_title(WINDOW win, MENU_TAG tag, char* text); void xvt_menu_set_item_title(WINDOW win, MENU_TAG tag, char* text);
void xvt_menu_set_tree(WINDOW win, MENU_ITEM* tree); void xvt_menu_set_tree(WINDOW win, MENU_ITEM* tree);
void xvt_menu_update(WINDOW win); void xvt_menu_update(WINDOW win);
// Added by Guy
typedef const char* TRANSLATE_CALLBACK(const char* ita);
void xvt_menu_translate_tree(WINDOW win, TRANSLATE_CALLBACK tc);
short xvt_palet_add_colors(XVT_PALETTE palet, COLOR *colorsp, short numcolors); short xvt_palet_add_colors(XVT_PALETTE palet, COLOR *colorsp, short numcolors);
short xvt_palet_add_colors_from_image(XVT_PALETTE palet, XVT_IMAGE image); short xvt_palet_add_colors_from_image(XVT_PALETTE palet, XVT_IMAGE image);