From 981678913af45cf75f94f237dc035371ea4e8532 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 20 Dec 2002 17:08:30 +0000 Subject: [PATCH] Patch level : 2.0.369 Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione P@rtners 2.0 patch 349 git-svn-id: svn://10.65.10.50/trunk@10709 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ba/autorun.cpp | 7 +- ba/ba1400.cpp | 5 +- ba/ba5100.cpp | 46 ++-- ba/ba5200.cpp | 6 +- ba/ba5300.cpp | 2 +- ba/ba6100.cpp | 97 ++++--- ba/ba6100.h | 1 - ba/ba6101.cpp | 380 +++++++++++++------------- ba/ba6200.cpp | 23 +- ba/bainst38.uml | 2 - ce/ce0900.cpp | 1 + cg/cg0100.cpp | 83 ++---- cg/cg0200.cpp | 100 ++----- cg/cg0300.cpp | 27 +- cg/cg0400.cpp | 224 ++++++---------- cg/cg0500.cpp | 121 ++++----- cg/cg0600.cpp | 24 +- cg/cg1100.cpp | 119 +++------ cg/cg1100a.uml | 4 +- cg/cg1200.cpp | 144 ++++------ cg/cg1300.cpp | 18 +- cg/cg1301.cpp | 5 +- cg/cg1302.cpp | 29 +- cg/cg1303.cpp | 16 +- cg/cg1304.cpp | 9 +- cg/cg1305.cpp | 7 +- cg/cg1306.cpp | 6 +- cg/cg1307.cpp | 88 +++---- cg/cg1308.cpp | 8 +- cg/cg1400.cpp | 46 ++-- cg/cg2102.cpp | 2 +- cg/cg4100.cpp | 1 - cg/cglib01.cpp | 99 ++----- cg/cglib02.cpp | 8 +- cg/cglib04.cpp | 3 +- include/mask.cpp | 16 +- include/netsock.cpp | 34 +-- include/netutils.cpp | 2 +- include/utility.cpp | 2 - server/authoriz.cpp | 70 +++-- server/authoriz.dsp | 36 +-- server/baseserv.cpp | 207 ++++++++------- server/baseserv.dsp | 9 +- server/baseserv.h | 24 +- server/coffee.cpp | 59 ++++- server/coffee.dsp | 17 +- server/dbserver.cpp | 614 +++++++++++++++++++++++++++++++++++++++++++ server/diction.cpp | 96 ++++--- server/diction.dsp | 13 +- server/example.cpp | 29 -- server/lerch.cpp | 269 +++++++++++++++---- server/lerch.dsp | 9 +- server/servers.ini | 8 + server/xml.cpp | 18 +- server/xml.h | 8 +- 55 files changed, 1920 insertions(+), 1381 deletions(-) create mode 100755 server/dbserver.cpp delete mode 100755 server/example.cpp create mode 100755 server/servers.ini diff --git a/ba/autorun.cpp b/ba/autorun.cpp index 33b1ea8eb..f24ec4c92 100755 --- a/ba/autorun.cpp +++ b/ba/autorun.cpp @@ -152,6 +152,7 @@ int VersionYear() { char ver[32]; GetPrivateProfileString("ba", "Versione", "", ver, sizeof(ver), "./eurocampo/zip/install.ini"); + ver[4] = '\0'; return atoi(ver); } @@ -173,6 +174,7 @@ bool DongleTest() bool ok = FALSE; ifstream keys("./eurocampo/zip/dninst.zip", ios::in | ios::nocreate); + if (keys.good()) { char line[256]; @@ -269,6 +271,7 @@ LRESULT CALLBACK MainWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) RECT rct; const char* s1 = "Installa EUROCAMPO in versione commerciale protetta. E' necessario disporre di una chiave di protezione hardware."; const char* s2 = "Installa EUROCAMPO in versione Demo. La versione Demo è priva di protezione hardware ma soggetta ad alcune limitazioni."; + const char* s4 = "Termina installazione"; const char* s5 = "Scelta installazione"; @@ -312,6 +315,7 @@ LRESULT CALLBACK MainWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (DongleTest()) Run("eurocampo\\disk1\\setup.exe"); + } else if (wParam == 1001) { @@ -401,9 +405,11 @@ int PASCAL WinMain (HINSTANCE hInst, HINSTANCE hinstPrev, LPSTR pCmdLine, int nC CreateWindow("BUTTON","Installazione EUROCAMPO", WS_CHILD| WS_VISIBLE ,offx ,offy,256,32, hwndDlg ,(HMENU)1000,hInst,NULL ); + CreateWindow("BUTTON","Installazione EUROCAMPO Demo", WS_CHILD| WS_VISIBLE ,offx ,offy+80,256,32, hwndDlg ,(HMENU)1001,hInst,NULL ); + CreateWindow("BUTTON","Uscita", WS_CHILD| WS_VISIBLE,offx,offy+160,256,32, hwndDlg ,(HMENU)2,hInst,NULL ); @@ -415,4 +421,3 @@ int PASCAL WinMain (HINSTANCE hInst, HINSTANCE hinstPrev, LPSTR pCmdLine, int nC return (msg.wParam); } - diff --git a/ba/ba1400.cpp b/ba/ba1400.cpp index 23bbc0b79..ce0ebaf39 100755 --- a/ba/ba1400.cpp +++ b/ba/ba1400.cpp @@ -570,7 +570,8 @@ void TSet_user_passwd::enable_aut() { const int module = _im->get_module_by_order(i+uns); TToken_string& riga = sf.row(i); - if (module == BAAUT || module == SRAUT) + if (module == BAAUT) + { sf.disable_cell(i,1); riga.add("X",1); @@ -791,4 +792,4 @@ int ba1400(int argc, char** argv) a.run(argc, argv, TR("Configurazione utenti")); } return 0; -} +} \ No newline at end of file diff --git a/ba/ba5100.cpp b/ba/ba5100.cpp index 0cca388fb..e22763f3c 100755 --- a/ba/ba5100.cpp +++ b/ba/ba5100.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -11,8 +12,8 @@ // TSoci_sheet /////////////////////////////////////////////////////////// -const char* const PHYSICAL_HEAD = "Codice|Cognome@30|Nome@20"; -const char* const JURASSIC_HEAD = "Codice|Ragione sociale@50"; +const char* const PHYSICAL_HEAD = HR("Codice|Cognome@30|Nome@20"); +const char* const JURASSIC_HEAD = HR("Codice|Ragione sociale@50"); class TSoci_sheet : public TArray_sheet { @@ -27,7 +28,7 @@ public: }; TSoci_sheet::TSoci_sheet(bool fis) -: TArray_sheet(-1,-1, -4, -4, "Soci", fis ? PHYSICAL_HEAD : JURASSIC_HEAD), +: TArray_sheet(-1,-1, -4, -4, TR("Soci"), fis ? PHYSICAL_HEAD : JURASSIC_HEAD), _physical(fis) {} @@ -166,12 +167,8 @@ bool TQuery_application::do_query() TQuery_socio query(_mask); TSoci_sheet s(query.tipo() == "F"); // Create sheet TRelation fsoci(LF_SOCI); - TLocalisamfile fanag(LF_ANAG); - TLocalisamfile fditte(LF_NDITTE); TRectype& soci = fsoci.curr(); - TRectype& anag = fanag.curr(); - TRectype& ditte = fditte.curr(); soci.zero(); _mask->autosave(fsoci); @@ -179,19 +176,22 @@ bool TQuery_application::do_query() { if (query.test(soci) == 0) { - TString cur_codice = soci.get("CODANAGRSO"), ragsoc(80); - anag.zero(); - anag.put("TIPOA", query.tipo()); - anag.put("CODANAGR", cur_codice); - if (fanag.read() != NOERR) ragsoc = "Anagrafica assente"; - else ragsoc = anag.get("RAGSOC"); + TString ragsoc(80); + TString16 cur_codice = soci.get("CODANAGRSO"); + TString16 key; key << query.tipo() << "|" << cur_codice; + + const TRectype & anag = cache().get(LF_ANAG, key); + if (anag.empty()) + ragsoc = TR("Anagrafica assente"); + else + ragsoc = anag.get("RAGSOC"); s.add_socio(cur_codice, ragsoc); } } if (s.items() == 0) { - warning_box("Nessuna corrispondenza"); + warning_box(TR("Nessuna corrispondenza")); return TRUE; } @@ -201,13 +201,14 @@ bool TQuery_application::do_query() r.restart(); TString codice(r.get()); TString nome(r.get()); + TRectype ditte(LF_NDITTE); TToken_string h(128); h.add("A/P "); - h.add(head(ditte, "CODDITTA", "Codice")); - h.add(head(ditte, "RAGSOC", "Ragione sociale")); - h.add("Carica|Qualifica|740|750"); - h.add(head(soci, "PERCQUAZ", "% Quote")); + h.add(head(ditte, "CODDITTA", TR("Codice"))); + h.add(head(ditte, "RAGSOC", TR("Ragione sociale"))); + h.add(HR("Carica|Qualifica|740|750")); + h.add(head(soci, "PERCQUAZ", TR("% Quote"))); TArray_sheet d(-1,-1, -4, -4, nome, h); soci.zero(); @@ -221,11 +222,10 @@ bool TQuery_application::do_query() if (query.test(soci) != 0) continue; row = soci.get("ATTPREC"); - ditte.zero(); row.add(soci.get("CODDITTA")); - ditte.put("CODDITTA", row.get(1)); - if (fditte.read() != NOERR) - row.add("Ditta assente"); + ditte = cache().get(LF_NDITTE, row.get(1)); + if (ditte.empty()) + row.add(TR("Ditta assente")); else row.add(ditte.get("RAGSOC")); row.add(soci.get("CODCAR")); @@ -246,6 +246,6 @@ bool TQuery_application::do_query() int ba5100(int argc,char* argv[]) { TQuery_application qa; - qa.run(argc, argv, "Ricerca Soci"); + qa.run(argc, argv, TR("Ricerca Soci")); return 0; } diff --git a/ba/ba5200.cpp b/ba/ba5200.cpp index ba61e8163..ebcd6b919 100755 --- a/ba/ba5200.cpp +++ b/ba/ba5200.cpp @@ -81,7 +81,7 @@ HIDDEN bool tiporeg_handler(TMask_field& f, KEY k) if ((k == K_TAB || k == K_ENTER) && app().exist_journal() && (atoi(f.get()) == REG_JOURNAL) ) - return f.error_box("Non e' possibile avere due registri giornale nello stesso anno"); + return f.error_box(TR("Non e' possibile avere due registri giornale nello stesso anno")); return TRUE; } @@ -109,7 +109,7 @@ HIDDEN bool printer_handler(TMask_field& f, KEY k) p.read_configuration(); } else - return f.error_box("Nessun registro selezionato"); + return f.error_box(TR("Nessun registro selezionato")); } } return TRUE; @@ -171,6 +171,6 @@ bool TRegister_app::codsp_handler(TMask_field& f, KEY k) int ba5200(int argc, char* argv[]) { TRegister_app a ; - a.run(argc, argv, "Gestione registri"); + a.run(argc, argv, TR("Gestione registri")); return 0; } diff --git a/ba/ba5300.cpp b/ba/ba5300.cpp index bc4795b6c..4706b1bc1 100755 --- a/ba/ba5300.cpp +++ b/ba/ba5300.cpp @@ -250,7 +250,7 @@ void TRicezioneABICAB::ricevi(const char * path, bool abi, bool cab, bool cab_fu int ba5300(int argc, char* argv[]) { TRicezioneABICAB app; - app.run(argc,argv,"Ricezione ABI e CAB"); + app.run(argc,argv, TR("Ricezione ABI e CAB")); return 0; } diff --git a/ba/ba6100.cpp b/ba/ba6100.cpp index 7ce67213f..81d871518 100755 --- a/ba/ba6100.cpp +++ b/ba/ba6100.cpp @@ -2,6 +2,7 @@ // Stampa anagrafiche // Control code // *********************************************************************** +#include #include #include #include @@ -13,17 +14,13 @@ const TRectype& TAnaprint_app::look_com(const char* cod, const char* sta) { - TRectype& com = _comuni->curr(); - com.zero(); - if (cod && *cod) - { - com.put("COM",cod); - if (sta && *sta) - com.put("STATO",sta); - if (_comuni->read() != NOERR) - com.zero(); - } - return com; + TString16 key; + if (sta && *sta) + key << sta; + key << "|"; + if (cod && *cod) + key << cod; + return cache().get(LF_COMUNI, key); } const char* TAnaprint_app::look_tab(const char* tabname, const char* cod, @@ -192,7 +189,7 @@ void TAnaprint_app::preprocess_etichette() { _surname = _name.mid(30); _surname.trim(); _name = _name.cut(30); _name.trim(); - _sex = get_field(LF_ANAGFIS,"SESSO")[0] == 'M' ? "Sig." : "Sig.ra"; + _sex = get_field(LF_ANAGFIS,"SESSO")[0] == 'M' ? TR("Sig.") : TR("Sig.ra"); } switch (_ind_what) { @@ -299,8 +296,8 @@ bool TAnaprint_app::set_print(int) case BUT_BA6_ELENCO: _pr_type = elenco; // cio' che e' blu collega al modulo anagrafiche - _ana_link = enable_link("Collegamento archivio anagrafiche: ", 'b'); - _dit_link = enable_link("Collegamento archivio ditte: ", 'v'); + _ana_link = enable_link(TR("Collegamento archivio anagrafiche: "), 'b'); + _dit_link = enable_link(TR("Collegamento archivio ditte: "), 'v'); break; case BUT_BA6_SCHEDE: disable_links(); @@ -381,8 +378,8 @@ bool TAnaprint_app::set_print(int) } break; case BUT_BA6_RUBRICHE: - _ana_link = enable_link("Collegamento archivio anagrafiche: ", 'b'); - _dit_link = enable_link("Collegamento archivio ditte: ", 'v'); + _ana_link = enable_link(TR("Collegamento archivio anagrafiche: "), 'b'); + _dit_link = enable_link(TR("Collegamento archivio ditte: "), 'v'); _pr_type = rubriche; break; } @@ -485,9 +482,10 @@ bool TAnaprint_app::user_create() _bk_ditta = _bk_ana = _bk_socio = _bk_attiv = _bk_registro = _bk_unloc = -1; TToken_string rxp(40); - TProgind p(5, "Preparazione archivi\rPrego attendere", FALSE, TRUE); + TProgind p(5, TR("Preparazione archivi\rPrego attendere"), FALSE, TRUE); // setup relation + open_files(LF_COMUNI, LF_ANAG, LF_ANAGFIS, LF_ANAGGIU, LF_NDITTE, 0); _rel_fis = new TRelation(LF_ANAG); _rel_giu = new TRelation(LF_ANAG); _rel_dit = new TRelation(LF_NDITTE); @@ -531,39 +529,37 @@ bool TAnaprint_app::user_create() p.addstatus(1); - _comuni = new TLocalisamfile(LF_COMUNI); - // set translated field values - set_translation(LF_ANAGFIS,"STATCIV","1","Celibe/Nubile"); - set_translation(LF_ANAGFIS,"STATCIV","2","Coniugato/a"); - set_translation(LF_ANAGFIS,"STATCIV","3","Vedovo/a"); - set_translation(LF_ANAGFIS,"STATCIV","4","Separato/a"); - set_translation(LF_ANAGFIS,"STATCIV","5","Divorziato/a"); - set_translation(LF_ANAGFIS,"STATCIV","6","Deceduto/a"); - set_translation(LF_ANAGFIS,"STATCIV","7","Tutelato/a"); - set_translation(LF_ANAGFIS,"STATCIV","8","Figlio/a minore"); - set_translation(LF_ANAGFIS,"TITSTU", "1" ,"Nessuno"); - set_translation(LF_ANAGFIS,"TITSTU", "2" ,"Lic. Elem."); - set_translation(LF_ANAGFIS,"TITSTU", "3" ,"Lic. Media"); - set_translation(LF_ANAGFIS,"TITSTU", "4" ,"Diploma"); - set_translation(LF_ANAGFIS,"TITSTU", "5" ,"Laurea"); - set_translation(LF_ANAGFIS,"SESSO", "M", "Maschio"); - set_translation(LF_ANAGFIS,"SESSO", "F", "Femmina"); - set_translation(LF_NDITTE,"FREQVIVA","M","Mensile"); - set_translation(LF_NDITTE,"FREQVIVA","T","Trimestrale"); - set_translation(LF_NDITTE,"DATLAV","1","Si"); - set_translation(LF_NDITTE,"DATLAV","2","No"); - set_translation(LF_NDITTE,"DATLAV","3","Lavoro Agricolo"); - set_translation(LF_ANAGGIU,"STATOSOC","1","Normale attivita'"); - set_translation(LF_ANAGGIU,"STATOSOC","2","Liquidazione cessata attivita'"); - set_translation(LF_ANAGGIU,"STATOSOC","3","Fallimento o Liquidazione coatta amm."); - set_translation(LF_ANAGGIU,"STATOSOC","4","Estinto"); - set_translation(LF_ANAGGIU,"SITSOC","1","Inizio"); - set_translation(LF_ANAGGIU,"SITSOC","2","Liquidazione"); - set_translation(LF_ANAGGIU,"SITSOC","3","Termine liquidazione"); - set_translation(LF_ANAGGIU,"SITSOC","4","Estinzione"); - set_translation(LF_ANAGGIU,"SITSOC","5","Trasf. IRPEG"); - set_translation(LF_ANAGGIU,"SITSOC","6","Normale"); + set_translation(LF_ANAGFIS,"STATCIV","1",TR("Celibe/Nubile")); + set_translation(LF_ANAGFIS,"STATCIV","2",TR("Coniugato/a")); + set_translation(LF_ANAGFIS,"STATCIV","3",TR("Vedovo/a")); + set_translation(LF_ANAGFIS,"STATCIV","4",TR("Separato/a")); + set_translation(LF_ANAGFIS,"STATCIV","5",TR("Divorziato/a")); + set_translation(LF_ANAGFIS,"STATCIV","6",TR("Deceduto/a")); + set_translation(LF_ANAGFIS,"STATCIV","7",TR("Tutelato/a")); + set_translation(LF_ANAGFIS,"STATCIV","8",TR("Figlio/a minore")); + set_translation(LF_ANAGFIS,"TITSTU", "1" ,TR("Nessuno")); + set_translation(LF_ANAGFIS,"TITSTU", "2" ,TR("Lic. Elem.")); + set_translation(LF_ANAGFIS,"TITSTU", "3" ,TR("Lic. Media")); + set_translation(LF_ANAGFIS,"TITSTU", "4" ,TR("Diploma")); + set_translation(LF_ANAGFIS,"TITSTU", "5" ,TR("Laurea")); + set_translation(LF_ANAGFIS,"SESSO", "M", TR("Maschio")); + set_translation(LF_ANAGFIS,"SESSO", "F", TR("Femmina")); + set_translation(LF_NDITTE,"FREQVIVA","M",TR("Mensile")); + set_translation(LF_NDITTE,"FREQVIVA","T",TR("Trimestrale")); + set_translation(LF_NDITTE,"DATLAV","1",TR("Si")); + set_translation(LF_NDITTE,"DATLAV","2",TR("No")); + set_translation(LF_NDITTE,"DATLAV","3",TR("Lavoro Agricolo")); + set_translation(LF_ANAGGIU,"STATOSOC","1",TR("Normale attivita'")); + set_translation(LF_ANAGGIU,"STATOSOC","2",TR("Liquidazione cessata attivita'")); + set_translation(LF_ANAGGIU,"STATOSOC","3",TR("Fallimento o Liquidazione coatta amm.")); + set_translation(LF_ANAGGIU,"STATOSOC","4",TR("Estinto")); + set_translation(LF_ANAGGIU,"SITSOC","1",TR("Inizio")); + set_translation(LF_ANAGGIU,"SITSOC","2",TR("Liquidazione")); + set_translation(LF_ANAGGIU,"SITSOC","3",TR("Termine liquidazione")); + set_translation(LF_ANAGGIU,"SITSOC","4",TR("Estinzione")); + set_translation(LF_ANAGGIU,"SITSOC","5",TR("Trasf. IRPEG")); + set_translation(LF_ANAGGIU,"SITSOC","6",TR("Normale")); set_fillchar('_'); set_wait_threshold(0); @@ -579,7 +575,6 @@ bool TAnaprint_app::user_destroy() if (_rel_dit) delete _rel_dit; if (_frpos) delete _frpos; - delete _comuni; return TRUE; } @@ -587,6 +582,6 @@ bool TAnaprint_app::user_destroy() int ba6100(int argc, char* argv[]) { TAnaprint_app app; - app.run(argc, argv, "Stampa Anagrafiche"); + app.run(argc, argv, TR("Stampa Anagrafiche")); return 0; } diff --git a/ba/ba6100.h b/ba/ba6100.h index 91304232d..c6294478e 100755 --- a/ba/ba6100.h +++ b/ba/ba6100.h @@ -33,7 +33,6 @@ class TAnaprint_app : public TPrintapp int _cfis2, _cgiu2, _cdit2; int _sort; bool _inclditte; - TLocalisamfile* _comuni; // settings etichette in _ind_what; int _ind_row, _ind_col, _rows_et, _cols_et; diff --git a/ba/ba6101.cpp b/ba/ba6101.cpp index b2762c934..14feb7993 100755 --- a/ba/ba6101.cpp +++ b/ba/ba6101.cpp @@ -13,20 +13,20 @@ void TAnaprint_app::set_scheda_anagiu() int row = 1; - set_row(row++,"SCHEDA SOCIETA'"); + set_row(row++,TR("SCHEDA SOCIETA'")); set_row(row++,""); - set_row(row++,"@bCodice@r@15g@u@pn@25g@r@bRag.Sociale @r@u@50s", + set_row(row++,FR("@bCodice@r@15g@u@pn@25g@r@bRag.Sociale @r@u@50s"), FLD(LF_ANAG,"CODANAGR","@@@@@"), FLD(LF_ANAG,"RAGSOC")); - set_row(row++,"@25g@bEvent. sigla@r@40g@u@20s", + set_row(row++,FR("@25g@bEvent. sigla@r@40g@u@20s"), FLD(LF_ANAGGIU,"SIGLA")); - set_row(row++,"Oggetto soc.@15g@60s", + set_row(row++, FR("Oggetto soc.@15g@60s"), FLD(LF_ANAGGIU,"OGGSOC")); - set_row(row++,"Codice Fiscale@20g@16s@46gPartita IVA @12s", + set_row(row++, FR("Codice Fiscale@20g@16s@46gPartita IVA @12s"), FLD(LF_ANAG,"COFI"), FLD(LF_ANAG,"PAIV")); - set_row(row++,"Riferimento@15g@20s", FLD(LF_ANAGGIU,"PERRIF")); + set_row(row++,FR("Riferimento@15g@20s"), FLD(LF_ANAGGIU,"PERRIF")); set_row(row++,""); - set_row(row++,"Sede legale@20gIndirizzo @35s N. @s", + set_row(row++, FR("Sede legale@20gIndirizzo @35s N. @s"), FLD(LF_ANAG,"INDRES"), FLD(LF_ANAG,"CIVRES")); @@ -37,17 +37,17 @@ void TAnaprint_app::set_scheda_anagiu() TString a = cc.get("DENCOM"); TString b = cc.get("CAPCOM"); TString c = cc.get("PROVCOM"); - set_row(row++,"@20gComune %s %-24s@58gProv. %2s@68gCAP %5s", + set_row(row++,FR("@20gComune %s %-24s@58gProv. %2s@68gCAP %5s"), (const char*)com, (const char*)a, (const char*)c, (const char*)b); - a = sta.empty() ? "Italia" : look_tab("%STA",sta); - set_row(row++,"@20gStato %s",(const char*)a); + a = sta.empty() ? TR("Italia") : look_tab("%STA",sta); + set_row(row++, FR("@20gStato %s"),(const char*)a); - set_row(row++,"@20gTelefono @u@10s@r/@u@30s@r", + set_row(row++, FR("@20gTelefono @u@10s@r/@u@30s@r"), FLD(LF_ANAG,"PTELRF"), FLD(LF_ANAG,"TELRF")); set_row(row++,""); - set_row(row++,"Domicilio fiscale@20gIndirizzo @35s N. @s", + set_row(row++, FR("Domicilio fiscale@20gIndirizzo @35s N. @s"), FLD(LF_ANAG,"INDRF"), FLD(LF_ANAG,"CIVRF")); @@ -56,11 +56,11 @@ void TAnaprint_app::set_scheda_anagiu() a = cc.get("DENCOM"); b = cc.get("CAPCOM"); c = cc.get("PROVCOM"); - set_row(row++,"@20gComune %s %-24s@58gProv. %2s@68gCAP %5s", + set_row(row++,FR("@20gComune %s %-24s@58gProv. %2s@68gCAP %5s"), (const char*)com, (const char*)a, (const char*)c, (const char*)b); set_row(row++,""); - set_row(row++,"Corrispondenza@20gIndirizzo @35s N. @s @35s", + set_row(row++, FR("Corrispondenza@20gIndirizzo @35s N. @s @35s"), FLD(LF_ANAG,"INDCORR"), FLD(LF_ANAG,"CIVCORR"), FLD(LF_ANAG,"LOCCORR")); @@ -72,52 +72,52 @@ void TAnaprint_app::set_scheda_anagiu() b = cc.get("CAPCOM"); c = cc.get("PROVCOM"); - set_row(row++,"@20gComune %s %-24s@58gProv. %2s@68gCAP %5s", + set_row(row++, FR("@20gComune %s %-24s@58gProv. %2s@68gCAP %5s"), (const char*)com, (const char*)a, (const char*)c, (const char*)b); - a = sta.empty() ? "Italia" : look_tab("%STA",sta); - set_row(row++,"@20gStato %s",(const char*)a); + a = sta.empty() ? TR("Italia") : look_tab("%STA",sta); + set_row(row++, FR("@20gStato %s"),(const char*)a); set_row(row++,""); - set_row(row++,"Telex@20g@u@10s@r/@u@30s@r", + set_row(row++, FR("Telex@20g@u@10s@r/@u@30s@r"), FLD(LF_ANAG,"PTLEXRF"), FLD(LF_ANAG,"TLEXRFX")); - set_row(row++,"Telefax@20g@u@10s@r/@u@30s@r", + set_row(row++, FR("Telefax@20g@u@10s@r/@u@30s@r"), FLD(LF_ANAG,"PFAXRF"), FLD(LF_ANAG,"FAXRF")); - set_row(row++,"Posta elettronica@20g@s", FLD(LF_ANAG,"MAIL")); + set_row(row++, FR("Posta elettronica@20g@s"), FLD(LF_ANAG,"MAIL")); set_row(row++,""); - set_row(row++,"Ufficio imposte@20gNumero @pn", + set_row(row++, FR("Ufficio imposte@20gNumero @pn"), FLD(LF_ANAG,"UFFIIDD","@@@")); com = look_tab("%UID",get_field(LF_ANAG, "UFFIIDD"),"S6"); // Comune imposte dirette c = look_tab("%UID",get_field(LF_ANAG, "UFFIIDD"),"S4"); // c.c. Esattoria look_com(com); a = cc.get("DENCOM"); b = cc.get("PROVCOM"); - set_row(row++,"@20gComune %s %-24s@58gProv. %s", + set_row(row++, FR("@20gComune %s %-24s@58gProv. %s"), (const char*)com, (const char*)a, (const char*)b); - set_row(row++,"Ufficio IVA@20gNumero @pn", + set_row(row++,FR("Ufficio IVA@20gNumero @pn"), FLD(LF_ANAG,"UFFIVA","@@@")); com = look_tab("%UIV",get_field(LF_ANAG, "UFFIVA"),"S6"); look_com(com); a = cc.get("DENCOM"); b = cc.get("PROVCOM"); - set_row(row++,"@20gComune %s %-24s@58gProv. %s", + set_row(row++, FR("@20gComune %s %-24s@58gProv. %s"), (const char*)com, (const char*)a, (const char*)b); - set_row(row++,"Esattoria@20gComunale @02s Provinciale @03s C.C. %s", + set_row(row++,FR("Esattoria@20gComunale @02s Provinciale @03s C.C. %s"), FLD(LF_ANAG,"CODCONTR",0,2), FLD(LF_ANAG,"CODCONTR",2,5), (const char*)c); - set_row(row++,"@20gCodice contribuente @8s @2s", + set_row(row++, FR("@20gCodice contribuente @8s @2s"), FLD(LF_ANAG,"CODCONTR", 5, 13), FLD(LF_ANAG,"CODCONTR", 13, 15)); //Qui la stampa dei dati conto fiscale TString16 tipo_stampa; const int tipo = current_cursor()->curr(LF_ANAG).get_int("TIPOSTDEL"); - if (tipo == 0) tipo_stampa = "Delega"; - else if (tipo == 1) tipo_stampa = "Bollettino"; - else tipo_stampa = "Distinta"; - set_row(row++,"Dati conto fiscale @20gTitolare conto fiscale @54g@f @60gTipo stampa %s", + if (tipo == 0) tipo_stampa = TR("Delega"); + else if (tipo == 1) tipo_stampa = TR("Bollettino"); + else tipo_stampa = TR("Distinta"); + set_row(row++,FR("Dati conto fiscale @20gTitolare conto fiscale @54g@f @60gTipo stampa %s"), FLD(LF_ANAG,"TITCF"), (const char*) tipo_stampa); tipo_stampa = current_cursor()->curr(LF_ANAG).get("UFFCONC"); @@ -136,45 +136,43 @@ void TAnaprint_app::set_scheda_anagiu() tipo_stampa = cc.get("UFFCONC"); } } - set_row(row++,"@20gConto fiscale %s @s", + set_row(row++,FR("@20gConto fiscale %s @s"), (const char*)tipo_stampa, FLD(LF_ANAG,"COFI")); TString16 abicab = get_field(LF_ANAG, "CODABI"); if (abicab.not_empty() && abicab != "00000") { - set_row(row++,"@20gABI %s@30g%s", (const char*)abicab, look_tab("%BAN", abicab)); + set_row(row++,FR("@20gABI %s@30g%s"), (const char*)abicab, look_tab("%BAN", abicab)); const TString16 cab = get_field(LF_ANAG, "CODCAB"); if (cab.not_empty() && cab != "00000") { abicab << cab; - set_row(row++,"@20gCAB %s@30g%s", + set_row(row++, FR("@20gCAB %s@30g%s"), (const char*)cab, look_tab("%BAN", abicab)); } } set_row(row++,""); // dati atto costitutivo etc - set_row(row++,"Dati atto costitutivo e statuto"); - set_row(row++,"Estremi@20g@60s", FLD(LF_ANAGGIU,"ESTROMOL")); - set_row(row++,"Omologa@25g@ld@41gData iscrizione@70g@ld", + set_row(row++, TR("Dati atto costitutivo e statuto")); + set_row(row++, FR("Estremi@20g@60s"), FLD(LF_ANAGGIU,"ESTROMOL")); + set_row(row++, FR("Omologa@25g@ld@41gData iscrizione@70g@ld"), FLD(LF_ANAGGIU,"DATAOMOL"), FLD(LF_ANAGGIU,"DATAISCRIZ")); - set_row(row++,"Data costituzione@25g@ld@41gDurata sino@70g@ld", + set_row(row++, FR("Data costituzione@25g@ld@41gDurata sino@70g@ld"), FLD(LF_ANAGGIU,"DATACOST"), FLD(LF_ANAGGIU,"DATASCAD")); TString cod = get_field(LF_ANAGGIU,"COMCOST"); look_com(cod); - set_row(row++,"Luogo costituzione@20g%s %s", (const char*)cod, (const char*)cc.get("DENCOM")); + set_row(row++, FR("Luogo costituzione@20g%s %s"), (const char*)cod, (const char*)cc.get("DENCOM")); - set_row(row++,"Termine appr. bilancio@25g@d@41gApprovazione bilancio@70g@d", + set_row(row++, FR("Termine appr. bilancio@25g@d@41gApprovazione bilancio@70g@d"), FLD(LF_ANAGGIU,"DATATAPPBI"), FLD(LF_ANAGGIU,"DATAAPPBIL")); - set_row(row++,"Scad.org.amministrativo@25g@d@41gScadenza collegio " - "sindacale@70g@d", + set_row(row++, FR("Scad.org.amministrativo@25g@d@41gScadenza collegio sindacale@70g@d"), FLD(LF_ANAGGIU,"DATASORAMM"), FLD(LF_ANAGGIU,"DATASCSIND")); set_row(row++,""); - set_row(row++,"@5gCapit.sociale@24gCapit.versato@47g" - "Fatturato@65gN.azioni@74gValore"); + set_row(row++, FR("@5gCapit.sociale@24gCapit.versato@47gFatturato@65gN.azioni@74gValore")); set_row(row++,"@pn @pn @pn @61g@n @pn", FLD(LF_ANAGGIU,"CAPSOC","###.###.###.###.###"), FLD(LF_ANAGGIU,"CAPVER","###.###.###.###.###"), @@ -183,39 +181,39 @@ void TAnaprint_app::set_scheda_anagiu() FLD(LF_ANAGGIU,"VALNOM","###.###.###.###")); set_row(row++,""); - set_row(row++,"Dati Statistici@20gNon residente@61g@f", + set_row(row++, FR("Dati Statistici@20gNon residente@61g@f"), FLD(LF_ANAG,"SOGGNRES")); - set_row(row++,"@20gEventi naturali eccezionali@61g@s", + set_row(row++, FR("@20gEventi naturali eccezionali@61g@s"), FLD(LF_ANAG,"EVECC")); - set_row(row++,"@20gResidente in zone terremotate@61g@f", + set_row(row++, FR("@20gResidente in zone terremotate@61g@f"), FLD(LF_ANAG,"RESZTERR")); // *TBI* traduzione natura giuridica - set_row(row++,"@20gNatura giuridica@61g@s", + set_row(row++, FR("@20gNatura giuridica@61g@s"), FLD(LF_ANAGGIU,"NATGIU")); - set_row(row++,"@20gStato societa'@51g@20,rt", + set_row(row++, FR("@20gStato societa'@51g@20,rt"), FLD(LF_ANAGGIU,"STATOSOC")); - set_row(row++,"@20gSituazione societa'@51g@20,rt", + set_row(row++, FR("@20gSituazione societa'@51g@20,rt"), FLD(LF_ANAGGIU,"SITSOC")); set_row(row++,""); a = look_tab("%STT",current_cursor()->curr(LF_ANAG).get("CODSTAT1"),"S0"); - set_row(row++,"@20gSigla stat.1 @7s %-50s", + set_row(row++, FR("@20gSigla stat.1 @7s %-50s"), FLD(LF_ANAG,"CODSTAT1"), (const char*)a); a = look_tab("%STT",current_cursor()->curr(LF_ANAG).get("CODSTAT2"),"S0"); - set_row(row++,"@20gSigla stat.2 @7s %-50s", + set_row(row++, FR("@20gSigla stat.2 @7s %-50s"), FLD(LF_ANAG,"CODSTAT2"), (const char*)a); a = look_tab("%STT",current_cursor()->curr(LF_ANAG).get("CODSTAT3"),"S0"); - set_row(row++,"@20gSigla stat.3 @7s %-50s", + set_row(row++, FR("@20gSigla stat.3 @7s %-50s"), FLD(LF_ANAG,"CODSTAT3"), (const char*)a); // NOTE - set_row(row++,"Note"); + set_row(row++, TR("Note")); set_row(row++,"@6g@70s",FLD(LF_ANAGGIU,"NOTE1")); set_row(row++,"@6g@70s",FLD(LF_ANAGGIU,"NOTE2")); set_row(row++,"@6g@70s",FLD(LF_ANAGGIU,"NOTE3")); set_row(row++,"@6g@70s",FLD(LF_ANAGGIU,"NOTE4")); set_row(row++,"@6g@70s",FLD(LF_ANAGGIU,"NOTE5")); row++; - set_row(row++,"Aggiornato il@20g@s", FLD(LF_ANAG, "DATAAGG")); + set_row(row++, FR("Aggiornato il@20g@s"), FLD(LF_ANAG, "DATAAGG")); const int l = printer().rows(); for (int i = 64; i <= l; i++) @@ -229,18 +227,18 @@ void TAnaprint_app::set_scheda_anafis() _bk_ana = set_bookmark(zio); int row = 1; - set_row(row++,"SCHEDA PERSONA FISICA"); + set_row(row++, TR("SCHEDA PERSONA FISICA")); set_row(row++,""); - set_row(row++,"@bCodice @r@u@pn@20g@r@bCognome @r@u@S", + set_row(row++, FR("@bCodice @r@u@pn@20g@r@bCognome @r@u@S"), FLD(LF_ANAG,"CODANAGR","@@@@@"), FLD(LF_ANAG,"RAGSOC",0,29)); - set_row(row++,"@20g@bNome @r@u@s", + set_row(row++, FR("@20g@bNome @r@u@s"), FLD(LF_ANAG,"RAGSOC",30,50)); set_row(row++,""); - set_row(row++,"Codice Fiscale@20g@s@46gPartita IVA @s", + set_row(row++, FR("Codice Fiscale@20g@s@46gPartita IVA @s"), FLD(LF_ANAG,"COFI"), FLD(LF_ANAG,"PAIV")); - set_row(row++,"Cod. Fisc. estero@20g@s", FLD(LF_ANAG,"COFIEST")); - set_row(row++,"Data di nascita@20g@ld@32g@t@46gNazionalita' @s", + set_row(row++, FR("Cod. Fisc. estero@20g@s"), FLD(LF_ANAG,"COFIEST")); + set_row(row++, FR("Data di nascita@20g@ld@32g@t@46gNazionalita' @s"), FLD(LF_ANAGFIS,"DATANASC"), FLD(LF_ANAGFIS,"SESSO"), FLD(LF_ANAGFIS,"NAZION")); TString com = get_field(LF_ANAGFIS, "COMNASC"); @@ -248,11 +246,11 @@ void TAnaprint_app::set_scheda_anafis() TString a = cc.get("DENCOM"); TString b; // CAPCOM TString c = cc.get("PROVCOM"); - set_row(row++,"@20gComune %s %s@58gProv. %s", + set_row(row++, FR("@20gComune %s %s@58gProv. %s"), (const char*)com, (const char*)a, (const char*)c); row++; - set_row(row++,"Residenza@20gIndirizzo @s N. @s", + set_row(row++, FR("Residenza@20gIndirizzo @s N. @s"), FLD(LF_ANAG,"INDRES"), FLD(LF_ANAG,"CIVRES")); com = get_field(LF_ANAG, "COMRES"); @@ -262,19 +260,19 @@ void TAnaprint_app::set_scheda_anafis() b = cc.get("CAPCOM"); c = cc.get("PROVCOM"); - set_row(row++,"@20gComune %s %s@58gProv. %s@68gCAP %s", + set_row(row++, FR("@20gComune %s %s@58gProv. %s@68gCAP %s"), (const char*)com, (const char*)a, (const char*)c, (const char*)b); - a = sta.empty() ? "Italia" : look_tab("%STA",sta); - set_row(row++,"@20gStato %s",(const char*)a); + a = sta.empty() ? TR("Italia") : look_tab("%STA",sta); + set_row(row++, FR("@20gStato %s"),(const char*)a); - set_row(row++,"@20gTelefono @u@s@r/@u@s@r", + set_row(row++, FR("@20gTelefono @u@s@r/@u@s@r"), FLD(LF_ANAG,"PTELRF"), FLD(LF_ANAG,"TELRF")); - set_row(row++,"@20gVariata residenza @f@53gData variazione @s", + set_row(row++, FR("@20gVariata residenza @f@53gData variazione @s"), FLD(LF_ANAG,"VARSLORES"), FLD(LF_ANAG,"DVARSLORES")); row++; - set_row(row++,"Domicilio fiscale@20gIndirizzo @s N. @s", + set_row(row++, FR("Domicilio fiscale@20gIndirizzo @s N. @s"), FLD(LF_ANAG,"INDRF"), FLD(LF_ANAG,"CIVRF")); com = get_field(LF_ANAG, "COMRF"); @@ -284,24 +282,24 @@ void TAnaprint_app::set_scheda_anafis() b = cc.get("CAPCOM"); c = cc.get("PROVCOM"); - set_row(row++,"@20gComune %s %s@58gProv. %s@68gCAP %s", + set_row(row++, FR("@20gComune %s %s@58gProv. %s@68gCAP %s"), (const char*)com, (const char*)a, (const char*)c, (const char*)b); TString flag; const int partic = atoi(get_field(LF_ANAGFIS, "CPARTRF")); switch(partic) { - case 2:flag = "Residente all'estero"; break; - case 3:flag = "Provvedimenti amministrativi"; break; - case 4:flag = "Variata da meno di 60 giorni"; break; - default:flag = "Nessuno"; break; + case 2:flag = TR("Residente all'estero"); break; + case 3:flag = TR("Provvedimenti amministrativi"); break; + case 4:flag = TR("Variata da meno di 60 giorni"); break; + default:flag = TR("Nessuno"); break; }; - set_row(row++,"@20gCasi particolari: %s", (const char*)flag); - set_row(row++,"@20gDomicilio fiscale diverso da sede legale @f", + set_row(row++, FR("@20gCasi particolari: %s"), (const char*)flag); + set_row(row++, FR("@20gDomicilio fiscale diverso da sede legale @f"), FLD(LF_ANAG,"RFDIVERSA")); set_row(row++, ""); - set_row(row++,"Corrispondenza@20gIndirizzo @s N. @s @s", + set_row(row++, FR("Corrispondenza@20gIndirizzo @s N. @s @s"), FLD(LF_ANAG,"INDCORR"), FLD(LF_ANAG,"CIVCORR"), FLD(LF_ANAG, "LOCCORR")); com = get_field(LF_ANAG, "COMCORR"); sta = get_field(LF_ANAG, "STATOCORR"); @@ -310,42 +308,42 @@ void TAnaprint_app::set_scheda_anafis() b = cc.get("CAPCOM"); c = cc.get("PROVCOM"); - set_row(row++,"@20gComune %s %s@58gProv. %s@68gCAP %s", + set_row(row++, FR("@20gComune %s %s@58gProv. %s@68gCAP %s"), (const char*)com, (const char*)a, (const char*)c, (const char*)b); - a = sta.empty() ? "Italia" : look_tab("%STA",sta); - set_row(row++,"@20gStato %s",(const char*)a); + a = sta.empty() ? TR("Italia") : look_tab("%STA",sta); + set_row(row++, FR("@20gStato %s"),(const char*)a); row++; - set_row(row++,"Telex@20g@u@s@r/@u@s@r", + set_row(row++, FR("Telex@20g@u@s@r/@u@s@r"), FLD(LF_ANAG,"PTLEXRF"), FLD(LF_ANAG,"TLEXRFX")); - set_row(row++,"Telefax@20g@u@s@r/@u@s@r", + set_row(row++, FR("Telefax@20g@u@s@r/@u@s@r"), FLD(LF_ANAG,"PFAXRF"), FLD(LF_ANAG,"FAXRF")); - set_row(row++,"Posta elettronica@20g@s",FLD(LF_ANAG,"MAIL")); + set_row(row++, FR("Posta elettronica@20g@s"),FLD(LF_ANAG,"MAIL")); set_row(row++,""); - set_row(row++,"Ufficio imposte@20gNumero @pn", + set_row(row++, FR("Ufficio imposte@20gNumero @pn"), FLD(LF_ANAG,"UFFIIDD","@@@")); com = look_tab("%UID",get_field(LF_ANAG, "UFFIIDD"),"S6"); // Comune imposte dirette c = look_tab("%UID",get_field(LF_ANAG, "UFFIIDD"),"S4"); // c.c. Esattoria look_com(com); a = cc.get("DENCOM"); b = cc.get("PROVCOM"); - set_row(row++,"@20gComune %s %-24s@58gProv. %s", + set_row(row++, FR("@20gComune %s %-24s@58gProv. %s"), (const char*)com, (const char*)a, (const char*)b); - set_row(row++,"Ufficio IVA@20gNumero @pn", + set_row(row++, FR("Ufficio IVA@20gNumero @pn"), FLD(LF_ANAG,"UFFIVA","@@@")); com = look_tab("%UIV",get_field(LF_ANAG, "UFFIVA"),"S6"); look_com(com); a = cc.get("DENCOM"); b = cc.get("PROVCOM"); - set_row(row++,"@20gComune %s %-24s@58gProv. %s", + set_row(row++, FR("@20gComune %s %-24s@58gProv. %s"), (const char*)com, (const char*)a, (const char*)b); - set_row(row++,"Esattoria@20gComunale @02s Provinciale @03s C.C. %s", + set_row(row++, FR("Esattoria@20gComunale @02s Provinciale @03s C.C. %s"), FLD(LF_ANAG,"CODCONTR",0,2), FLD(LF_ANAG,"CODCONTR",2,5), (const char*)c); - set_row(row++,"@20gCodice contribuente @8s @2s", + set_row(row++, FR("@20gCodice contribuente @8s @2s"), FLD(LF_ANAG,"CODCONTR", 5, 13), FLD(LF_ANAG,"CODCONTR", 13, 15)); set_row(row++,""); @@ -373,18 +371,18 @@ void TAnaprint_app::set_scheda_anafis() else a = b = ""; - set_row(row++,"Coniuge @pn@20gCognome %s", + set_row(row++, FR("Coniuge @pn@20gCognome %s"), FLD(LF_ANAGFIS,"CODCONIUGE","@@@@@"), (const char*)a); - set_row(row++,"@20gNome %s", (const char*)b); + set_row(row++, FR("@20gNome %s"), (const char*)b); set_row(row++,""); TString16 tipo_stampa; const int tipo = current_cursor()->curr(LF_ANAG).get_int("TIPOSTDEL"); - if (tipo == 0) tipo_stampa = "Delega"; - else if (tipo == 1) tipo_stampa = "Bollettino"; - else tipo_stampa = "Distinta"; - set_row(row++,"Dati conto fiscale @20gTitolare conto fiscale @54g@f @60gTipo stampa %s", + if (tipo == 0) tipo_stampa = TR("Delega"); + else if (tipo == 1) tipo_stampa = TR("Bollettino"); + else tipo_stampa = TR("Distinta"); + set_row(row++,FR("Dati conto fiscale @20gTitolare conto fiscale @54g@f @60gTipo stampa %s"), FLD(LF_ANAG,"TITCF"), (const char*) tipo_stampa); tipo_stampa = current_cursor()->curr(LF_ANAG).get("UFFCONC"); if (tipo_stampa.empty()) @@ -403,49 +401,49 @@ void TAnaprint_app::set_scheda_anafis() tipo_stampa = cc.get("UFFCONC"); } } - set_row(row++,"@20gConto fiscale %s @s", + set_row(row++, FR("@20gConto fiscale %s @s"), (const char*)tipo_stampa, FLD(LF_ANAG,"COFI")); TString16 abicab = get_field(LF_ANAG, "CODABI"); if (abicab.not_empty() && abicab != "00000") { - set_row(row++,"@20gABI %s@30g%s", (const char*)abicab, look_tab("%BAN", abicab)); + set_row(row++, FR("@20gABI %s@30g%s"), (const char*)abicab, look_tab("%BAN", abicab)); const TString16 cab = get_field(LF_ANAG, "CODCAB"); if (cab.not_empty() && cab != "00000") { abicab << cab; - set_row(row++,"@20gCAB %s@30g%s", + set_row(row++, FR("@20gCAB %s@30g%s"), (const char*)cab, look_tab("%BAN", abicab)); } } set_row(row++,""); - set_row(row++,"Dati Statistici@20gNon residente@53g@f", + set_row(row++, FR("Dati Statistici@20gNon residente@53g@f"), FLD(LF_ANAG,"SOGGNRES")); - set_row(row++,"@20gEventi naturali eccezionali@53g@s", + set_row(row++, FR("@20gEventi naturali eccezionali@53g@s"), FLD(LF_ANAG,"EVECC")); - set_row(row++,"@20gResidente in zone terremotate@53g@f", + set_row(row++, FR("@20gResidente in zone terremotate@53g@f"), FLD(LF_ANAG,"RESZTERR")); - set_row(row++,"@20gStato civile@53g@t", + set_row(row++, FR("@20gStato civile@53g@t"), FLD(LF_ANAGFIS,"STATCIV")); - set_row(row++,"@20gData variazione stato civile@53g@D", + set_row(row++, FR("@20gData variazione stato civile@53g@D"), FLD(LF_ANAGFIS,"DVARSCIV")); - set_row(row++,"@20gTitolo di studio@53g@t", + set_row(row++, FR("@20gTitolo di studio@53g@t"), FLD(LF_ANAGFIS,"TITSTU")); row ++; a = look_tab("%STT", current_cursor()->curr(LF_ANAG).get("CODSTAT1"),"S0"); - set_row(row++,"@20gSigla stat.1 @7s %s", + set_row(row++,FR("@20gSigla stat.1 @7s %s"), FLD(LF_ANAG,"CODSTAT1"), (const char*)a); a = look_tab("%STT",current_cursor()->curr(LF_ANAG).get("CODSTAT2"),"S0"); - set_row(row++,"@20gSigla stat.2 @7s %s", + set_row(row++, FR("@20gSigla stat.2 @7s %s"), FLD(LF_ANAG,"CODSTAT2"), (const char*)a); a = look_tab("%STT",current_cursor()->curr(LF_ANAG).get("CODSTAT3"),"S0"); - set_row(row++,"@20gSigla stat.3 @7s %s", + set_row(row++, FR("@20gSigla stat.3 @7s %s"), FLD(LF_ANAG,"CODSTAT3"), (const char*)a); set_row(row++,""); - set_row(row++,"Aggiornato il@20g@s", FLD(LF_ANAG, "DATAAGG")); + set_row(row++, FR("Aggiornato il@20g@s"), FLD(LF_ANAG, "DATAAGG")); const int l = printer().rows(); for (int i = 50; i <= l; i++) @@ -458,33 +456,33 @@ void TAnaprint_app::set_scheda_ditta() TString zio = current_cursor()->curr(LF_NDITTE).get("RAGSOC"); _bk_ditta = set_bookmark(zio, _pr_what == nditte ? -1 : _bk_ana); - set_row(1,"@bSCHEDA DITTA @r@u@pn@r@20g@bDenominaz. sociale @r@u@s", + set_row(1, FR("@bSCHEDA DITTA @r@u@pn@r@20g@bDenominaz. sociale @r@u@s"), FLD(LF_NDITTE,"CODDITTA","@@@@@"), FLD(LF_NDITTE,"RAGSOC")); - set_row(2,"Albo artigiani@20gIscrizione all'albo @f@55gnum. @s", + set_row(2, FR("Albo artigiani@20gIscrizione all'albo @f@55gnum. @s"), FLD(LF_NDITTE,"ARTIG"), FLD(LF_NDITTE,"NISCRAA")); TString a = look_com(current_cursor()->curr(LF_NDITTE).get("COMAA")).get("DENCOM"); - set_row(3,"@20gLocalita' %s@55gData @D", + set_row(3, FR("@20gLocalita' %s@55gData @D"), (const char*)a, FLD(LF_NDITTE,"DATAISCRAA")); - set_row(4,"Attivita'"); + set_row(4, FR("Attivita'")); a = look_tab("%AIS",current_cursor()-> curr(LF_NDITTE).get("CODATTPREV")); // TBC - set_row(5,"prevalente@20gCod. @pn Desc. %s", + set_row(5, FR("prevalente@20gCod. @pn Desc. %s"), FLD(LF_NDITTE,"CODATTPREV","@@@@@"), (const char*)a); // set_row(6,"@20gGestione piu' attivita'"); - set_row(6,"@20gFrequenza versamenti@54g@t", + set_row(6, FR("@20gFrequenza versamenti@54g@t"), FLD(LF_NDITTE,"FREQVIVA")); - set_row(7,"@20gTenuta contabilita' ordinaria@54g@f", + set_row(7, FR("@20gTenuta contabilita' ordinaria@54g@f"), FLD(LF_NDITTE,"CONTORD")); - set_row(8,"@20gDatore di lavoro@54g@t", + set_row(8, FR("@20gDatore di lavoro@54g@t"), FLD(LF_NDITTE,"DATLAV")); - set_row(9,"@20gData inizio attivita'@54g@D", + set_row(9, FR("@20gData inizio attivita'@54g@D"), FLD(LF_NDITTE,"DINIZIOATT")); long codice = current_cursor()->curr(LF_NDITTE).get_long("FIRMAT"); @@ -496,39 +494,39 @@ void TAnaprint_app::set_scheda_ditta() if (ana.read() == NOERR) firmat = ana.get("RAGSOC"); firmat.strip_d_spaces(); - set_row(10,"Firmatario@20g@s @30g%s",FLD(LF_NDITTE,"FIRMAT"),(const char *)firmat); + set_row(10, FR("Firmatario@20g@s @30g%s"),FLD(LF_NDITTE,"FIRMAT"),(const char *)firmat); codice = current_cursor()->curr(LF_NDITTE).get_long("RAPPR"); ana.put("TIPOA", "F"); ana.put("CODANAGR",codice); if (ana.read() == NOERR) rappr = ana.get("RAGSOC"); rappr.strip_d_spaces(); - set_row(11,"Rappresentante@20g@s @30g%s",FLD(LF_NDITTE,"RAPPR"),(const char *)rappr); + set_row(11, FR("Rappresentante@20g@s @30g%s"),FLD(LF_NDITTE,"RAPPR"),(const char *)rappr); - set_row(12,"Altri dati@20gRiferimento @u@s@r @54gTel. @u@4S@r/@u@S@r", + set_row(12, FR("Altri dati@20gRiferimento @u@s@r @54gTel. @u@4S@r/@u@S@r"), FLD(LF_NDITTE,"PERRIF"), FLD(LF_NDITTE,"PTEL"), FLD(LF_NDITTE,"TEL")); - set_row(13,"@20gGestione magazzino @f", + set_row(13, FR("@20gGestione magazzino @f"), FLD(LF_NDITTE,"REGMAG")); - set_row(14,"@20gNumero unita' locali @n@54gNum.enasarco @s", + set_row(14, FR("@20gNumero unita' locali @n@54gNum.enasarco @s"), FLD(LF_NDITTE,"NULC"), FLD(LF_NDITTE,"NENASARCO")); - set_row(15,"Banca di appoggio"); + set_row(15, TR("Banca di appoggio")); TString16 abicab = get_field(LF_NDITTE, "ABIBAN"); if (abicab.not_empty() && abicab != "00000") { - set_row(15,"@20gABI %s@40g%s", (const char*)abicab, look_tab("%BAN", abicab)); + set_row(15, FR("@20gABI %s@40g%s"), (const char*)abicab, look_tab("%BAN", abicab)); const TString16 cab = get_field(LF_NDITTE, "CABBAN"); if (cab.not_empty() && cab != "00000") { abicab << cab; - set_row(16,"@20gCAB %s@40g%s", + set_row(16, FR("@20gCAB %s@40g%s"), (const char*)cab, look_tab("%BAN", abicab)); } } - set_row(17,"Stato@20g@t",FLD(LF_NDITTE,"STATOSOC")); + set_row(17, FR("Stato@20g@t"),FLD(LF_NDITTE,"STATOSOC")); set_row(18,""); } @@ -537,24 +535,24 @@ void TAnaprint_app::set_scheda_attiv() const TString descr(current_cursor()->curr(LF_ATTIV).get("DESCR")); _bk_attiv = set_bookmark(descr, _bk_ditta); - set_row(1,"@bATTIVITA'@r @s@20g@bDescrizione:@r %s", + set_row(1, FR("@bATTIVITA'@r @s@20g@bDescrizione:@r %s"), FLD(LF_ATTIV,"CODATT","@@@@@"), (const char*)descr); - set_row(2,"@20gRegime agricolo@67g@f", + set_row(2, FR("@20gRegime agricolo@67g@f"), FLD(LF_ATTIV,"REGAGR")); - set_row(3,"@20gRegime speciale agenzie di viaggio (art.74ter)@67g@f", + set_row(3, FR("@20gRegime speciale agenzie di viaggio (art.74ter)@67g@f"), FLD(LF_ATTIV,"REG74TER")); - set_row(4,"@20gAttivita' stagionale@67g@f", + set_row(4, FR("@20gAttivita' stagionale@67g@f"), FLD(LF_ATTIV,"ATTSTAG")); - set_row(5,"@20gAttivita' esercitata in piu' luoghi@67g@f", + set_row(5, FR("@20gAttivita' esercitata in piu' luoghi@67g@f"), FLD(LF_ATTIV,"ESLUOGHID")); - set_row(6,"@20gData inizio attivita'@60g@D", + set_row(6, FR("@20gData inizio attivita'@60g@D"), FLD(LF_ATTIV,"DATAISCIVA")); - set_row(7,"@20gData variazione attivita'@60g@D", + set_row(7, FR("@20gData variazione attivita'@60g@D"), FLD(LF_ATTIV,"DATAVARIVA")); - set_row(8,"@20gData cessazione attivita'@60g@D", + set_row(8, FR("@20gData cessazione attivita'@60g@D"), FLD(LF_ATTIV,"DCESSATT")); - set_row(9,"@20g@bCONSERVAZIONE SCRITTURE CONTABILI@r"); + set_row(9, FR("@20g@bCONSERVAZIONE SCRITTURE CONTABILI@r")); // cerca depositario TString com = get_field(LF_ATTIV,"CODANGRDS"); @@ -585,25 +583,25 @@ void TAnaprint_app::set_scheda_attiv() af.readat(last); af.setkey(k); - set_row(10,"Depositario@20gCodice @pn (%s): %s", + set_row(10,FR("Depositario@20gCodice @pn (%s): %s"), FLD(LF_ATTIV,"CODANGRDS"), c == 'F' ? "p.f." : "p.g.", (const char*)b); - set_row(11,"@20gIndirizzo %s N. %s", (const char*)com, (const char*)z); + set_row(11,FR("@20gIndirizzo %s N. %s"), (const char*)com, (const char*)z); a = exists ? cm.get("DENCOM") : ""; b = exists ? cm.get("PROVCOM") : ""; c = exists ? cm.get("CAPCOM") : ""; set_row(12,"@20gComune %s@58gProv. %s@68gC.a.p. %s", (const char*)a, (const char*)b, (const char*)c); - set_row(13,"@20gTenuta scritture parziali@68g@f", + set_row(13, FR("@20gTenuta scritture parziali@68g@f"), FLD(LF_ATTIV,"TSCRPARZ")); - set_row(14,"Luogo@20gIndirizzo @s N. @s", + set_row(14, FR("Luogo@20gIndirizzo @s N. @s"), FLD(LF_ATTIV,"INDCS"), FLD(LF_ATTIV,"CIVCS")); look_com(get_field(LF_ATTIV,"COMCS")); a = cm.get("DENCOM"); b = cm.get("PROVCOM"); c = cm.get("CAPCOM"); - set_row(15,"@20gComune %s@58gProv. %s@68gC.a.p. %s", + set_row(15, FR("@20gComune %s@58gProv. %s@68gC.a.p. %s"), (const char*)a, (const char*)b, (const char*)c); - set_row(16,"@20gTelefono @s/@s", FLD(LF_ATTIV,"PTELCS"), FLD(LF_ATTIV,"TELCS")); + set_row(16, FR("@20gTelefono @s/@s"), FLD(LF_ATTIV,"PTELCS"), FLD(LF_ATTIV,"TELCS")); set_row(17,""); set_row(18,""); } @@ -619,39 +617,37 @@ void TAnaprint_app::set_scheda_unloc() zio.insert("U.L. ",0); _bk_unloc = set_bookmark(zio, _bk_attiv); - set_row(1,"@bUNITA' LOCALE@20gCodice @r@u@pn@r", + set_row(1, FR("@bUNITA' LOCALE@20gCodice @r@u@pn@r"), FLD(LF_UNLOC,"CODULC","@@@")); - set_row(2,"@20g@bIndirizzo@r@u @s@r@68g@bNumero @r@u@s", + set_row(2, FR("@20g@bIndirizzo@r@u @s@r@68g@bNumero @r@u@s"), FLD(LF_UNLOC,"INDULC"), FLD(LF_UNLOC,"CIVULC")); const TRectype& cc = look_com(get_field(LF_UNLOC,"COMULC")); TString a = cc.get("DENCOM"); TString b = cc.get("PROVCOM"); TString c = cc.get("CAPCOM"); - set_row(3,"@20g@bComune@r@4j@u%s@r@58g@bProv.@r @u%s@r@68g@b" - "C.a.p.@r @u%s", (const char*)a, (const char*)b, (const char*)c); + set_row(3, FR("@20g@bComune@r@4j@u%s@r@58g@bProv.@r @u%s@r@68g@bC.a.p.@r @u%s"), (const char*)a, (const char*)b, (const char*)c); set_row(4,""); - set_row(5,"C.C.I.A.A.@20gNumero@30g@pn", + set_row(5, FR("C.C.I.A.A.@20gNumero@30g@pn"), FLD(LF_UNLOC,"NUMCCIAA","@@@@@@@")); look_com(get_field(LF_UNLOC,"COMCCIAA")); a = cc.get("DENCOM"); - set_row(6,"@20gComune@30g%s", (const char*)a); - set_row(7,"@20gData iscrizione @D@48gData ultima variazione @D", + set_row(6, FR("@20gComune@30g%s"), (const char*)a); + set_row(7, FR("@20gData iscrizione @D@48gData ultima variazione @D"), FLD(LF_UNLOC,"DATAICCIAA"), FLD(LF_UNLOC,"DATAVCCIAA")); set_row(8,""); - set_row(9,"Autorizzazioni@20gN. R.E.C. @30g@pn@41gComunale n. @pn " - "PS n. @pn Altre @s", + set_row(9, FR("Autorizzazioni@20gN. R.E.C. @30g@pn@41gComunale n. @pn PS n. @pn Altre @s"), FLD(LF_UNLOC,"NUMREC","@@@@@@@"), FLD(LF_UNLOC,"AUTCOM","@@@@@"), FLD(LF_UNLOC,"AUTPS","@@@@@@@"), FLD(LF_UNLOC,"ALTAUT")); set_row(10,""); - set_row(11,"Posizioni@20gINPS n.@30g@s INAIL n. @s", + set_row(11, FR("Posizioni@20gINPS n.@30g@s INAIL n. @s"), FLD(LF_UNLOC,"POSINPS"), FLD(LF_UNLOC,"POSINAIL")); set_row(12,""); - set_row(13, "Numero Registro Imprese@30g@pn", + set_row(13, FR("Numero Registro Imprese@30g@pn"), FLD(LF_UNLOC, "REGIMP", "@@ @@@ @@@@ @@@@@@@@@ @")); zio = get_field(LF_UNLOC,"COMTRIB"); @@ -660,12 +656,12 @@ void TAnaprint_app::set_scheda_unloc() b = cc.get("PROVCOM"); c = get_field(LF_UNLOC, "CAPTRIB"); if (c.empty()) c = cc.get("CAPCOM"); - set_row(14,"Comune tribunale@20g%s %s@58gProv. %s@68gC.a.p. %s", + set_row(14, FR("Comune tribunale@20g%s %s@58gProv. %s@68gC.a.p. %s"), (const char*)zio, (const char*)a, (const char*)b, (const char*)c); set_row(15,""); - set_row(16,"Locali destinati"); - set_row(17,"all'attivita'@20gMq.Locali @pn Di cui a magazzino @pn", + set_row(16, TR("Locali destinati")); + set_row(17, FR("all'attivita'@20gMq.Locali @pn Di cui a magazzino @pn"), FLD(LF_UNLOC,"MQULC","@@@@@"), FLD(LF_UNLOC,"MQULCMAG","@@@@@")); set_row(18,""); @@ -693,7 +689,7 @@ void TAnaprint_app::set_scheda_socio() TString paiv(ana.get("PAIV")); const char pre_att = soc.get("ATTPREC")[0]; - TString zio("Socio "); + TString zio(TR("Socio ")); zio << soc.get("CODANAGRSO"); zio << "("; zio << soc.get("TIPOASOC") << "): "; zio << ragsoc; @@ -726,30 +722,30 @@ void TAnaprint_app::set_scheda_socio() anaf->read(); const TRectype& com = look_com(anaf->get("COMNASC")); - set_row(1,"@bSOCIO@r @s / @pn@20g@bCognome@r %s", + set_row(1,FR("@bSOCIO@r @s / @pn@20g@bCognome@r %s"), FLD(LF_SOCI,"TIPOASOC"), FLD(LF_SOCI,"CODANAGRSO","@@@@@"), (const char*)ragsoc1); - set_row(2,"@20g@bNome@r %s@53g@bCod.fisc.@r %s", + set_row(2,FR("@20g@bNome@r %s@53g@bCod.fisc.@r %s"), (const char*)ragsoc2, (const char*)cofi); - set_row(3,"@20g@bSocio anno %s@r ", pre_att == 'P' ? "precedente" : "attuale"); + set_row(3, FR("@20g@bSocio anno %s@r "), pre_att == 'P' ? TR("precedente") : TR("attuale")); set_row(4,""); b1 = anaf->get_date("DATANASC").string(full); b2 = anaf->get("SESSO"); - set_row(5,"Nascita@20gData@30g%S@42gSesso %S", + set_row(5, FR("Nascita@20gData@30g%S@42gSesso %S"), (const char*)b1, (const char*)b2); b1 = com.get("DENCOM"); b2 = com.get("PROVCOM"); - set_row(6,"@20gComune@30g%S@58gProv. %S", + set_row(6, FR("@20gComune@30g%S@58gProv. %S"), (const char*)b1, (const char*)b2); rw = 7; - codconiuge = "Cod.coniuge "; + codconiuge = TR("Cod.coniuge "); codconiuge << anaf->get("CODCONIUGE"); if (_pr_what == anafis) @@ -758,14 +754,14 @@ void TAnaprint_app::set_scheda_socio() } else { - set_row(1,"@bSOCIO@r @S / @pN@20gR.soc. %s", + set_row(1, FR("@bSOCIO@r @S / @pN@20gR.soc. %s"), FLD(LF_SOCI,"TIPOASOC"), FLD(LF_SOCI,"CODANAGRSO","@@@@@"), (const char*)ragsoc); - set_row(2,"@20gCod.fisc. %s P.IVA %s", + set_row(2, FR("@20gCod.fisc. %s P.IVA %s"), (const char*)cofi, (const char*)paiv); - set_row(3,"@20g@bSocio anno %s@r ", pre_att == 'P' ? "precedente" : "attuale"); + set_row(3, FR("@20g@bSocio anno %s@r "), pre_att == 'P' ? TR("precedente") : TR("attuale")); rw = 4; } set_row(rw,""); @@ -778,8 +774,8 @@ void TAnaprint_app::set_scheda_socio() b2 = com.get("PROVCOM"); b3 = com.get("CAPCOM"); - set_row(rw+1,"Residenza@20gIndirizzo %S", (const char*)indres); - set_row(rw+2,"@20gComune %S@58gProv. %S@68gC.a.p. %S", + set_row(rw+1, FR("Residenza@20gIndirizzo %S"), (const char*)indres); + set_row(rw+2, FR("@20gComune %S@58gProv. %S@68gC.a.p. %S"), (const char*)b1, (const char*)b2, (const char*)b3); @@ -789,38 +785,36 @@ void TAnaprint_app::set_scheda_socio() TString car = look_tab("%CRS",soc.get("CODCAR")); TString dataagg(ana.get("DATAAGG")); - set_row(rw+4,"Carica@20gCod. @pN@30g%s@62gScadenza @lD", + set_row(rw+4, FR("Carica@20gCod. @pN@30g%s@62gScadenza @lD"), FLD(LF_SOCI,"CODCAR","@@"), (const char*)car, FLD(LF_SOCI,"SCADCAR")); - set_row(rw+5,"Azioni@20gN.quote @N = @7.3N%% Redd. @7.3N%% Perd. @7.3N%%", + set_row(rw+5, FR("Azioni@20gN.quote @N = @7.3N%% Redd. @7.3N%% Perd. @7.3N%%"), FLD(LF_SOCI,"NQUOTEAZ"), FLD(LF_SOCI,"PERCQUAZ"), FLD(LF_SOCI,"PERCAZREDD"), FLD(LF_SOCI,"PERCAZPERD")); - set_row(rw+6,"@20gTitolo proprieta' @S Emolumento @pN", + set_row(rw+6, FR("@20gTitolo proprieta' @S Emolumento @pN"), FLD(LF_SOCI,"TITPROP"), FLD(LF_SOCI,"EMOLUMENTO","###.###.###.###")); - set_row(rw+7,"%% rit.su dividendi @7.3n%% Tipo azione @s " - "Partecipaz. assemblea @f", + set_row(rw+7, FR("%% rit.su dividendi @7.3n%% Tipo azione @s Partecipaz. assemblea @f"), FLD(LF_SOCI,"PERCRITDIV"), FLD(LF_SOCI,"TIPOAZ"), FLD(LF_SOCI,"PARTASS")); - set_row(rw+8,"Modello 740 @s @57g%s", + set_row(rw+8, FR("Modello 740 @s @57g%s"), FLD(LF_SOCI,"Q740"), (const char*)codconiuge); - set_row(rw+9,"Attiv. prevalente @f@37gQuadro 750 @s @53g" - "Mesi lavorati art.120 c1 @2n", + set_row(rw+9, FR("Attiv. prevalente @f@37gQuadro 750 @s @53gMesi lavorati art.120 c1 @2n"), FLD(LF_SOCI,"ATTPREV"), FLD(LF_SOCI,"QUATTPREV"), FLD(LF_SOCI,"MLAV120C1")); - set_row(rw+10,"@20gRichiesta qualifica @s@53gMesi lavorati art.120 c2 @2n", + set_row(rw+10, FR("@20gRichiesta qualifica @s@53gMesi lavorati art.120 c2 @2n"), FLD(LF_SOCI,"RICQUAL"), FLD(LF_SOCI,"MLAV120C2")); - set_row(rw+11,"Note@20g@s", FLD(LF_SOCI,"NOTE")); - set_row(rw+12,"Data ultimo agg. @20gAnagrafica %s @53gSocio @d", + set_row(rw+11, FR("Note@20g@s"), FLD(LF_SOCI,"NOTE")); + set_row(rw+12, FR("Data ultimo agg. @20gAnagrafica %s @53gSocio @d"), (const char*)dataagg, FLD(LF_SOCI,"DATAAGG")); set_row(rw+13,""); set_row(rw+14,""); @@ -836,7 +830,7 @@ void TAnaprint_app::set_rubriche() // preprocess_page will fill the vars set_row(2,"@32g@35S", FLD(LF_ANAG,"INDRES")); set_row(3,"@32g#-24T CAP #5T PR #2T", &_com, &_cap, &_prov); - set_row(4,"@32gTel. #-36T", &_phone); + set_row(4, FR("@32gTel. #-36T"), &_phone); set_row(5,""); if (_pr_what == nditte) @@ -854,7 +848,7 @@ void TAnaprint_app::set_rubriche() { set_row(1,"@b$[b]@pN$[n]@r@3j@50S", FLD(LF_ANAG,"CODANAGR","@@@@@"), FLD(LF_ANAG,"RAGSOC")); - set_row(4,"@56g Rif @12S", FLD(LF_ANAGGIU,"PERRIF")); + set_row(4, "@56g Rif @12S", FLD(LF_ANAGGIU,"PERRIF")); } } @@ -917,21 +911,17 @@ void TAnaprint_app::set_headers() case anafis: case anagiu: set_background("W1l{1 2 132 2}W4l{1 5 132 5}"); - set_header(1,"@bELENCO PERSONE %s@82gStudio@96gData" - "@101g @> @112g Pag. @#", _pr_what == anafis ? "FISICHE" : - "GIURIDICHE"); - set_header(3,"@iCodice@58gCodice"); - set_header(4,"@iAnagr. Ragione sociale/cognome e nome@58gDitta" - "@66gDenominazione sociale"); + set_header(1, FR("@bELENCO PERSONE %s@82gStudio@96gData@101g @> @112g Pag. @#"), _pr_what == anafis ? TR("FISICHE") : + TR("GIURIDICHE")); + set_header(3, FR("@iCodice@58gCodice")); + set_header(4, FR("@iAnagr. Ragione sociale/cognome e nome@58gDitta@66gDenominazione sociale")); set_header(6,""); break; case nditte: set_background("W1l{1 2 132 2}W4l{1 5 132 5}"); - set_header(1,"@bELENCO DITTE@82gStudio@96gData" - "@101g @> @112g Pag. @#"); - set_header(3,"@iCodice@50gT"); - set_header(4,"@iAnagr. Denominazione sociale@50gP Codice" - "@61gRagione sociale/Cognome e nome"); + set_header(1, FR("@bELENCO DITTE@82gStudio@96gData@101g @> @112g Pag. @#")); + set_header(3, FR("@iCodice@50gT")); + set_header(4, FR("@iAnagr. Denominazione sociale@50gP Codice@61gRagione sociale/Cognome e nome")); set_header(6,""); } printer().headerlen(6); @@ -943,16 +933,16 @@ void TAnaprint_app::set_headers() case anafis: case anagiu: set_background("W1l{1 2 132 2}W4l{1 4 132 4}"); - set_header(1,"@bRUBRICA PERSONE %s@40gStudio@53gData @> pag. @#", - _pr_what == anagiu ? "GIURIDICHE" : "FISICHE"); - set_header(3,"@iCodice Cognome e nome"); + set_header(1, FR("@bRUBRICA PERSONE %s@40gStudio@53gData @> pag. @#"), + _pr_what == anagiu ? TR("GIURIDICHE") : TR("FISICHE")); + set_header(3,FR("@iCodice Cognome e nome")); set_header(5,""); break; case nditte: set_background("W1l{1 2 132 2}W4l{1 4 132 4}"); - set_header(1,"@bRUBRICA DITTE@40gStudio@53gData @> pag. @#"); - set_header(3,"@iCodice Cognome e nome"); + set_header(1, FR("@bRUBRICA DITTE@40gStudio@53gData @> pag. @#")); + set_header(3, FR("@iCodice Cognome e nome")); set_header(5,""); break; } diff --git a/ba/ba6200.cpp b/ba/ba6200.cpp index d44f6b7e6..3c426375b 100755 --- a/ba/ba6200.cpp +++ b/ba/ba6200.cpp @@ -10,7 +10,6 @@ class BA6200_application : public TPrintapp { TRelation* _rel; TMask* _msk; - TLocalisamfile* _comuni; TParagraph_string * _descr_comune; int _cur1, _cur2; @@ -215,11 +214,11 @@ void BA6200_application::crea_intestazione() sep.fill('-'); set_header (1, (const char *) sep); sep = ""; - sep << "Pag. @#"; + sep << FR("Pag. @#"); sep.right_just(132); set_header (2,(const char*) sep); - set_header (2,"@0gARCHIVIO COMUNI@91gSTUDIO@104gDATA"); + set_header (2, FR("@0gARCHIVIO COMUNI@91gSTUDIO@104gDATA")); data_stampa = _data_stampa.string(); set_header (2,"@109g%10s", (const char*) data_stampa); @@ -227,24 +226,19 @@ void BA6200_application::crea_intestazione() sep.fill('-'); set_header (3, (const char *) sep); - set_header(5,"@0gCodice@7gDenominazione@33gProv.@40gCap@45gCd.Istat@54gMont.@60gUff.@67gII.DD.@80gI.V.A.@92gRegi.@98gConc.@104gServ.@110gEsatt."); - set_header (6,"@0g------@7g-------------------------@33g-----@39g-----"); - set_header (6,"@45g--------@54g-----@65g-----------"); - set_header (6,"@78g------------@92g-----@98g-----@104g-----@110g-------"); + set_header(5, FR("@0gCodice@7gDenominazione@33gProv.@40gCap@45gCd.Istat@54gMont.@60gUff.@67gII.DD.@80gI.V.A.@92gRegi.@98gConc.@104gServ.@110gEsatt.")); + set_header (6, FR("@0g------@7g-------------------------@33g-----@39g-----")); + set_header (6, FR("@45g--------@54g-----@65g-----------")); + set_header (6, FR("@78g------------@92g-----@98g-----@104g-----@110g-------")); } bool BA6200_application::user_create() { + open_files(LF_COMUNI, 0); _rel = new TRelation (LF_COMUNI); - _cur1 = add_cursor(new TCursor(_rel,"",1)); - _cur2 = add_cursor(new TCursor(_rel,"",2)); - - _comuni = new TLocalisamfile (LF_COMUNI); - _descr_comune = new TParagraph_string ("",25); - _msk = new TMask("ba6200a"); return TRUE; } @@ -253,7 +247,6 @@ bool BA6200_application::user_destroy() { delete _msk; delete _rel; - delete _comuni; delete _descr_comune; return TRUE; } @@ -261,7 +254,7 @@ bool BA6200_application::user_destroy() int ba6200(int argc, char* argv[]) { BA6200_application a; - a.run(argc, argv, "Stampa Comuni"); + a.run(argc, argv, TR("Stampa Comuni")); return 0; } diff --git a/ba/bainst38.uml b/ba/bainst38.uml index 2e2da3ffd..5ea3c5549 100755 --- a/ba/bainst38.uml +++ b/ba/bainst38.uml @@ -1,8 +1,6 @@ #include "bainst38.h" PAGE "Installazione SV" -1 -1 78 8 -// GROUP 1 = PRE-INSTALLATION -// GROUP 2 = POST-INSTALLATION BOOL F_DEFAULTSDATA BEGIN diff --git a/ce/ce0900.cpp b/ce/ce0900.cpp index 868eb4022..430bc3f17 100755 --- a/ce/ce0900.cpp +++ b/ce/ce0900.cpp @@ -425,6 +425,7 @@ int TConversione_cespiti::conv_tab(const TFilename& ofname, const char* tab) TExternisamfile oldfile(ofname,(bool)FALSE,(bool)FALSE); + TTable* newfile = NULL; TConfig config("ce0900.ini", tab); TAssoc_array& fieldlist = config.list_variables(); diff --git a/cg/cg0100.cpp b/cg/cg0100.cpp index ad26b5513..fc5162d46 100755 --- a/cg/cg0100.cpp +++ b/cg/cg0100.cpp @@ -17,8 +17,6 @@ class TCausali_app : public TRelation_application { TMask* _msk; TRelation *_rel; - TLocalisamfile* _saldi; - TLocalisamfile* _tabcom; bool _pcon_com; bool user_create(); @@ -129,7 +127,6 @@ bool TCausali_app::protected_record(TRectype &rec) if (!_pcon_com ) { TMask* m = get_mask(MODE_MOD); - TLocalisamfile& pconti = _rel->lfile(); const int gruppo = m->get_int(FLD_CM1_GRUPPO); const int conto = m->get_int(FLD_CM1_CONTO); const long sottoc = m->get_long(FLD_CM1_SOTTOCONTO); @@ -137,22 +134,24 @@ bool TCausali_app::protected_record(TRectype &rec) // Se e' un sottoconto posso cancellarlo se non esistono saldi if ((gruppo != 0) && (conto != 0) && (sottoc != 0)) { - _saldi->zero(); - _saldi->put(PCN_GRUPPO, gruppo); - _saldi->put(PCN_CONTO, conto); - _saldi->put(PCN_SOTTOCONTO, sottoc); - _saldi->read(_isgteq); - return _saldi->good() && - gruppo ==_saldi->get_int(PCN_GRUPPO) && - conto ==_saldi->get_int(PCN_CONTO) && - sottoc ==_saldi->get_long(PCN_SOTTOCONTO) && - (_saldi->get_real(SLD_SALDO) != ZERO || _saldi->get_real(SLD_PDARE) != ZERO || - _saldi->get_real(SLD_PAVERE) != ZERO || _saldi->get_real(SLD_SALDOFIN) != ZERO || - _saldi->get_real(SLD_PDAREPRO) != ZERO || _saldi->get_real(SLD_PAVEREPRO) != ZERO); + TLocalisamfile saldi(LF_SALDI); + + saldi.setkey(2); + saldi.put(PCN_GRUPPO, gruppo); + saldi.put(PCN_CONTO, conto); + saldi.put(PCN_SOTTOCONTO, sottoc); + saldi.read(_isgteq); + return saldi.good() && + gruppo == saldi.get_int(PCN_GRUPPO) && conto == saldi.get_int(PCN_CONTO) && sottoc == saldi.get_long(PCN_SOTTOCONTO) && + (saldi.get_real(SLD_SALDO) != ZERO || saldi.get_real(SLD_PDARE) != ZERO || + saldi.get_real(SLD_PAVERE) != ZERO || saldi.get_real(SLD_SALDOFIN) != ZERO || + saldi.get_real(SLD_PDAREPRO) != ZERO || saldi.get_real(SLD_PAVEREPRO) != ZERO); } else { - get_relation()->save_status(); + TLocalisamfile& pconti = _rel->lfile(); + + get_relation()->save_status(); pconti.zero() ; pconti.put(PCN_GRUPPO, gruppo); // Se e' un conto controllo se ha dei sottoconti @@ -283,21 +282,7 @@ HIDDEN bool gruppo_handler(TMask_field& f, KEY key) const int gruppo = m.get_int(FLD_CM1_GRUPPO); const int conto = m.get_int(FLD_CM1_CONTO); const long sottoc = m.get_long(FLD_CM1_SOTTOCONTO); -/* - if (key == K_TAB && gruppo != 0 && conto == 0 && sottoc == 0 && - f.focusdirty() && m.is_running()) - { - TLocalisamfile& pconti = app().get_relation()->lfile(); - pconti.zero() ; - pconti.put(PCN_GRUPPO, gruppo) ; - pconti.setkey(1) ; - if (pconti.read() != NOERR) - { - m.notify_focus_field(FLD_CM1_DESC); - m.stop_run(K_AUTO_ENTER); - } - } -*/ + if (key == K_ENTER) { TLocalisamfile& pconti = app().get_relation()->lfile(); @@ -308,7 +293,7 @@ HIDDEN bool gruppo_handler(TMask_field& f, KEY key) pconti.setkey(1) ; pconti.read(); if (pconti.bad()) - return f.warning_box ("Il gruppo non esiste"); + return f.warning_box (TR("Il gruppo non esiste")); } } @@ -321,22 +306,7 @@ HIDDEN bool conto_handler(TMask_field& f, KEY key) const int gruppo = m.get_int(FLD_CM1_GRUPPO); const int conto = m.get_int(FLD_CM1_CONTO); const long sottoc = m.get_long(FLD_CM1_SOTTOCONTO); -/* - if (key == K_TAB && gruppo != 0 && conto != 0 && sottoc == 0 && - f.focusdirty() && m.is_running()) - { - TLocalisamfile& pconti = app().get_relation()->lfile(); - pconti.zero() ; - pconti.put(PCN_GRUPPO, gruppo); - pconti.put(PCN_CONTO, conto); - pconti.setkey(1) ; - if (pconti.read() != NOERR) - { - m.notify_focus_field(FLD_CM1_DESC); - m.stop_run(K_AUTO_ENTER); - } - } -*/ + if (key == K_ENTER) { TLocalisamfile& pconti = app().get_relation()->lfile(); @@ -349,11 +319,11 @@ HIDDEN bool conto_handler(TMask_field& f, KEY key) pconti.setkey(1) ; pconti.read(); if (pconti.bad()) - return m.field(FLD_CM1_CONTO).warning_box ("Il conto non esiste"); + return m.field(FLD_CM1_CONTO).warning_box (TR("Il conto non esiste")); else { if (pconti.get(PCN_TMCF).not_empty()) - return m.field(FLD_CM1_SOTTOCONTO).warning_box ("Non e' possibile inserire un sottoconto di un conto relativo ad un cliente/fornitore"); + return m.field(FLD_CM1_SOTTOCONTO).warning_box (TR("Non e' possibile inserire un sottoconto di un conto relativo ad un cliente/fornitore")); } } } @@ -375,32 +345,29 @@ HIDDEN bool sottoc_handler(TMask_field& f, KEY key) bool TCausali_app::user_create() { - _rel = new TRelation(LF_PCON); - _saldi = new TLocalisamfile(LF_SALDI); - _saldi->setkey(2); + open_files(LF_PCON, LF_SALDI, LF_TABCOM, LF_ABPCON, 0); _msk = new TMask("cg0100a") ; _msk->set_handler(FLD_CM1_GRUPPO, gruppo_handler); _msk->set_handler(FLD_CM1_CONTO, conto_handler); _msk->set_handler(FLD_CM1_SOTTOCONTO, sottoc_handler); _msk->set_handler(FLD_CM1_TMCF, tmcf_handler); - set_search_field(FH_SOTTOCONTO); + _rel = new TRelation(LF_PCON); + set_search_field(FH_SOTTOCONTO); return TRUE; - } bool TCausali_app::user_destroy() { delete _msk; delete _rel; - delete _saldi; return TRUE; } int cg0100(int argc, char* argv[]) { TCausali_app a ; - a.run(argc, argv, "Piano dei conti"); + a.run(argc, argv, TR("Piano dei conti")); return 0; -} +} \ No newline at end of file diff --git a/cg/cg0200.cpp b/cg/cg0200.cpp index 5b8143141..38e798a52 100755 --- a/cg/cg0200.cpp +++ b/cg/cg0200.cpp @@ -27,11 +27,6 @@ class TClifo_application : public TRelation_application { TMask* _msk; TClifoVI* _rel; - TLocalisamfile* _mov; - TLocalisamfile* _anag; - TLocalisamfile* _fis; - TLocalisamfile* _comuni; - TLocalisamfile* _pcon; bool _lbcn, _gesven, _gessal, _has_cg, _liscatven; bool _savenew; @@ -95,12 +90,13 @@ bool TClifo_application::protected_record(TRectype &rec) TMask* m = get_mask(MODE_MOD); const TString16 tipocf(m->get(F_TIPOCF)); const long codice = atol(m->get(F_CODCF)); + TLocalisamfile mov(LF_MOV); - _mov->curr().zero(); - _mov->curr().put(MOV_TIPO, tipocf); - _mov->curr().put(MOV_CODCF, codice); - _mov->read(); - return tipocf == _mov->get(MOV_TIPO) && codice == atol(_mov->get(MOV_CODCF)); + mov.setkey(3); + mov.curr().put(MOV_TIPO, tipocf); + mov.curr().put(MOV_CODCF, codice); + mov.read(); + return tipocf == mov.get(MOV_TIPO) && codice == atol(mov.get(MOV_CODCF)); } bool TClifo_application::get_next_key(TToken_string& key) @@ -158,7 +154,7 @@ HIDDEN bool no_dup_fis(TMask_field& f, KEY key) if (clifo.good() && (t1 != t || s1 != s)) { - f.message_box("Codice fiscale gia' utilizzato per il codice %c/%ld", + f.message_box(FR("Codice fiscale gia' utilizzato per il codice %c/%ld"), t, s); } } @@ -192,9 +188,10 @@ HIDDEN bool no_dup_iva(TMask_field& f, KEY key) if (clifo.good() && (t1 != t || s1 != s)) { - ok = f.error_box("Partita iva gia' utilizzata per il codice %c/%ld" - "\nsenza avere indicato il valore 4 nell'inserimento in allegato", t, s); + ok = f.error_box(FR("Partita iva gia' utilizzata per il codice %c/%ld" + "\nsenza avere indicato il valore 4 nell'inserimento in allegato"), t, s); } + } return ok; @@ -263,11 +260,11 @@ bool TClifo_application::percip_handler(TMask_field& f, KEY key) if ((c.not_empty() && c != anag.get(ANA_COFI)) || (p.not_empty() && p != anag.get(ANA_PAIV))) - return error_box("Percipiente non corretto: codice fiscale o partita IVA diversa"); + return error_box(TR("Percipiente non corretto: codice fiscale o partita IVA diversa")); const TString r(anag.get(ANA_RAGSOC)); if (key == K_TAB && m.get(F_RAGSOC).empty() && - yesno_box("Ragione sociale mancante: assumo %s", (const char*)r)) + yesno_box(FR("Ragione sociale mancante: assumo %s"), (const char*)r)) { m.set(F_RAGSOC, r.left(30), TRUE); m.set(F_RAGSOCA, r.mid(30), TRUE); @@ -288,11 +285,9 @@ bool TClifo_application::percip_handler(TMask_field& f, KEY key) m.show(-5, app()._lbcn); if (app()._lbcn) { - TLocalisamfile fis(LF_ANAGFIS); + const TRectype & fis = cache().get(LF_ANAGFIS, anag.get(ANA_CODANAGR)); - fis.zero(); - fis.put(ANF_CODANAGR, anag.get(ANA_CODANAGR)); - if (fis.read() == NOERR) + if (!fis.empty()) { if (m.get(F_DATANASC).empty()) m.set(F_DATANASC, fis.get(ANF_DATANASC)); if (m.get(F_COMNASC).empty()) @@ -307,29 +302,7 @@ bool TClifo_application::percip_handler(TMask_field& f, KEY key) return TRUE; } -/*bool TClifo_application::fax_handler(TMask_field& f, KEY k) -{ - bool ok = TRUE; - if (k == K_SPACE) - { - TFilename msg; msg.temp(NULL, "txt"); - ofstream msgf(msg); msgf.close(); - goto_url(msg); - - if (ok) - { - const TMask& m = f.mask(); - const char* tipo = m.get(F_TIPOCF) == "C" ? "Clienti" : "Fornitori"; - const char* codice = m.get(F_CODCF); - TDDE dde; - TString cmd(80); - cmd << "[SetRecipient(" << tipo << ',' << codice << ")]"; - ok = dde.execute("EASYFAX", "FAX", cmd, "bafax"); - } - } - return ok; -} */ bool TClifo_application::email_handler(TMask_field& f, KEY k) { @@ -406,26 +379,24 @@ HIDDEN bool codalleg_handler(TMask_field& f, KEY key) { TMask& m = f.mask(); if (cod == m.get(F_CODCF)) - return error_box("Il codice per allegato coincide con il codice anagrafico"); + return error_box(TR("Il codice per allegato coincide con il codice anagrafico")); const char tipo = m.get(F_TIPOCF)[0]; - TLocalisamfile clifo(LF_CLIFO); - clifo.zero() ; - clifo.put(CLI_TIPOCF, tipo); - clifo.put(CLI_CODCF, cod); - clifo.read() ; - if (clifo.bad()) return FALSE; + TString16 key; key.format("%c|%s", tipo, (const char *) cod); + const TRectype & clifo = cache().get(LF_CLIFO, key); + if (clifo.empty()) + return FALSE; if (clifo.get(CLI_CODALLEG).not_empty()) - return error_box("Codice non utilizzabile: contiene a sua volta un codice per allegato"); + return error_box(TR("Codice non utilizzabile: contiene a sua volta un codice per allegato")); if (clifo.get(CLI_PAIV).empty()) - return error_box("Codice non utilizzabile: privo di partita IVA"); + return error_box(TR("Codice non utilizzabile: privo di partita IVA")); const TString& tipoall = clifo.get(CLI_ALLEG); if (tipoall.not_empty() && tipoall != "1" && tipoall != "4") - return error_box("Codice non utilizzabile: codice inserimento allegato non corretto"); + return error_box(TR("Codice non utilizzabile: codice inserimento allegato non corretto")); } } return TRUE; @@ -668,7 +639,9 @@ TSheet_field& TClifo_application::indsp_sheet() const void TClifo_application::reset_sheet() { - const char* nulla = "|**Nessuno**"; + TToken_string nulla = "|**"; + nulla << TR("Nessuno") << "**"; + TClifo_application& a = app(); a.field_sheet(F_CODINDDOC).destroy(); @@ -790,7 +763,7 @@ bool TClifo_application::indsp_notify(TSheet_field& indsp, int r, KEY key) // To avoid inserts in the middle of the sheet if (r != -1 && indsp.items() > (r+1)) { - error_box("Si possono aggiungere indirizzi solo alla fine"); + error_box(TR("Si possono aggiungere indirizzi solo alla fine")); return FALSE; //Refuse permission } break; @@ -819,20 +792,11 @@ bool TClifo_application::effetti_notify(TSheet_field& pnae, int r, KEY key) bool TClifo_application::user_create() // initvar e arrmask { + open_files(LF_CLIFO, LF_CFVEN, LF_INDSP, LF_TAB, LF_TABCOM, LF_MOV, LF_ANAG, + LF_ANAGFIS, LF_PCON, LF_COMUNI, 0); _has_cg = has_module(CGAUT, CHK_DONGLE); _rel = new TClifoVI; - if (_has_cg) - { - _mov = new TLocalisamfile(LF_MOV); - _mov->setkey(3); - } - else - _mov = NULL; - _anag = new TLocalisamfile(LF_ANAG); - _fis = new TLocalisamfile(LF_ANAGFIS); - _pcon = new TLocalisamfile(LF_PCON); - _comuni = new TLocalisamfile(LF_COMUNI); _msk = new TMask("cg0200a") ; @@ -863,11 +827,6 @@ bool TClifo_application::user_destroy() // releasev e arrmask { delete _msk; delete _rel; - if (_mov) delete _mov; - delete _anag; - delete _fis; - delete _pcon; - delete _comuni; return TRUE; } @@ -875,10 +834,9 @@ int cg0200(int argc, char* argv[]) { TClifo_application a; - a.run(argc, argv, "Clienti/Fornitori"); + a.run(argc, argv, TR("Clienti/Fornitori")); return 0; } - diff --git a/cg/cg0300.cpp b/cg/cg0300.cpp index 2f9885c74..e55f28a80 100755 --- a/cg/cg0300.cpp +++ b/cg/cg0300.cpp @@ -1,4 +1,5 @@ #include +#include #include "cg0.h" #include "cg0300.h" @@ -7,9 +8,6 @@ class CG0300_application : public TRelation_application { TMask* _msk; TRelation *_rel; - TLocalisamfile* _ditte; - TLocalisamfile* _attiv; - TLocalisamfile* _clifo; bool user_create(); bool user_destroy(); @@ -51,18 +49,16 @@ void CG0300_application::init_modify_mode(TMask& m) bool CG0300_application::user_create() { + open_files(LF_ALLEG, LF_NDITTE, LF_ATTIV, LF_CLIFO, 0); _msk = new TMask("cg0300a") ; _rel = new TRelation(LF_ALLEG); - _ditte = new TLocalisamfile(LF_NDITTE); - _attiv = new TLocalisamfile(LF_ATTIV); - _clifo = new TLocalisamfile(LF_CLIFO); - const long ditta = get_firm(); - _msk->set(F_CODDITTA, ditta); - _ditte->zero(); - _ditte->put(N_CODDITTA, ditta); - _ditte->read(); - if (_ditte->good()) - _msk->set(F_CODATT,_ditte->get(N_CODATTPREV)); + const long codditta = get_firm(); + + TString16 key ; key << codditta; + const TRectype & ditta = cache().get(LF_NDITTE, key); + _msk->set(F_CODDITTA, codditta); + if (!ditta.empty()) + _msk->set(F_CODATT, ditta.get(N_CODATTPREV)); return TRUE; } @@ -71,15 +67,12 @@ bool CG0300_application::user_destroy() { delete _msk; delete _rel; - delete _ditte; - delete _attiv; - delete _clifo; return TRUE; } int cg0300(int argc, char* argv[]) { CG0300_application a; - a.run(argc, argv, "Immissione progressivi allegati"); + a.run(argc, argv, TR("Immissione progressivi allegati")); return 0; } diff --git a/cg/cg0400.cpp b/cg/cg0400.cpp index 4d827ea34..4351d6fa8 100755 --- a/cg/cg0400.cpp +++ b/cg/cg0400.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -115,8 +116,6 @@ bool TIva_array::add_riga(const tiporec& tipo, const real& imponibile, class TProgressivi_iva : public TPrintapp { - TTable* _tablia; - TLocalisamfile* _nditte, * _anag, * _com, * _attiv; TMask* _msk; TDate _data; int _sospmsk, _tipoprog, _livelloprog, _tipo_aliq, _tipo_attiv, _annoiva, _i; @@ -132,8 +131,6 @@ class TProgressivi_iva : public TPrintapp Importi _mesi[14]; // Era 13: bestie! I mesi sono da 1 a 13 liste _tipo_lista; - TString TMP; // Ex HIDDEN: bestie! - protected: static bool tipo_handler(TMask_field& f, KEY k); static bool selection_handler(TMask_field& f, KEY k); @@ -194,14 +191,9 @@ bool TProgressivi_iva::is_month_plain(int x, int m, const char f) const char* TProgressivi_iva::desc_attivita(const char* codatt) { - TTable attiv ("%AIS"); - attiv.zero(); - attiv.put("CODTAB", codatt); - if (attiv.read()==NOERR) - TMP = attiv.get("S0"); - else - TMP = ""; - return TMP; + const TRectype & attiv = cache().get("%AIS", codatt); + + return attiv.get("S0"); } void TProgressivi_iva::lordo2netto(const real& totale, real& imponibile, real& imposta, const real& aliquota) @@ -228,50 +220,35 @@ void TProgressivi_iva::lordo2netto(const real& totale, real& imponibile, real& i const char* TProgressivi_iva::desc_iva(const TString& cod) { - if (cod == "{AF") - TMP = "Artt.17c3/74c1"; + return TR("Artt.17c3/74c1"); + else if (cod == "{VA7") - TMP = "Art.40c5/6/8 a.i."; + return TR("Art.40c5/6/8 a.i."); + else { - TTable tab_iva("%IVA"); TString16 codtab; codtab.format("%-4s", (const char*)cod); + const TRectype & iva = cache().get("%IVA", codtab); - tab_iva.zero(); - tab_iva.put("CODTAB", codtab); - if (tab_iva.read()==NOERR) - TMP = tab_iva.get("S0"); - else - TMP = ""; + return iva.get("S0"); } - - return TMP; + return ""; } char TProgressivi_iva::look_lia(long ditta) { - if (ditta == 0l) ditta = get_firm(); + if (ditta <= 0L) ditta = get_firm(); - TString16 y; y.format("%05ld%04d", ditta, _anno); - - _tablia->zero(); - _tablia->put("CODTAB", y); - - if (_tablia->read() != NOERR) - _tablia->zero(); + TString16 key; key.format("%05ld%04d", ditta, _anno); + const TRectype & lia = cache().get("%LIA", key); - return _tablia->get_char("S7"); + return lia.get_char("S7"); } bool TProgressivi_iva::user_create() { - _tablia = new TTable("%LIA"); - _anag = new TLocalisamfile(LF_ANAG); - _nditte = new TLocalisamfile(LF_NDITTE); - _com = new TLocalisamfile(LF_COMUNI); - _attiv = new TLocalisamfile(LF_ATTIV); - + open_files(LF_TABCOM, LF_TAB, LF_ANAG, LF_NDITTE, LF_COMUNI, LF_ATTIV, 0); set_real_picture("###.###.###.###"); set_magic_currency(TRUE); set_print_zero(FALSE); @@ -282,12 +259,6 @@ bool TProgressivi_iva::user_create() bool TProgressivi_iva::user_destroy() { - delete _tablia; - delete _anag; - delete _nditte; - delete _com; - delete _attiv; - return TRUE; } @@ -825,10 +796,6 @@ bool TProgressivi_iva::set_print(int m) break; } -//set_real_picture("###.###.###.###"); -//set_print_zero(FALSE); -//printer().footerlen(5); - return TRUE; } @@ -902,8 +869,9 @@ bool TProgressivi_iva::preprocess_page(int file, int counter) real tot_imposta = ZERO; calcola_totali(tot_impo, tot_imposta); TString dep = ""; - set_row(2,(const char*) dep); - set_row(3,"@8gTotale"); + set_row(2,(const char*) dep); + set_row(3,"@8g%s", TR("Totale")); + set_row(3,"@26g%r", &tot_impo); set_row(3,"@56g%r", &tot_imposta); } @@ -922,8 +890,8 @@ void TProgressivi_iva::prospetto_pagina(TGen_array& gen, TIva_array& iva) int r = 1; TString80 descr; - set_row(++r, "Cod.@40gVENDITE@77gACQUISTI@113gIMPORTAZIONI"); - set_row(++r, "IVA Descrizione@29gImponibile@48gImposta@67gImponibile@86gImposta@105gImponibile@124gImposta"); + set_row(++r, FR("Cod.@40gVENDITE@77gACQUISTI@113gIMPORTAZIONI")); + set_row(++r, FR("IVA Descrizione@29gImponibile@48gImposta@67gImponibile@86gImposta@105gImponibile@124gImposta")); r+=2; for (int k = 0; k < gen.items(); k++) @@ -962,7 +930,7 @@ void TProgressivi_iva::prospetto_pagina(TGen_array& gen, TIva_array& iva) gen.destroy(); r+=2; - set_row(r++, "Totale@24g%r@40g%r@62g%r@78g%r@100g%r@116g%r", + set_row(r++, FR("Totale@24g%r@40g%r@62g%r@78g%r@100g%r@116g%r"), &t_impov,&t_imposv,&t_impoa,&t_imposa,&t_impobd,&t_imposbd); r++; real im, is, d, im1, is1, d1; //inizializzati in cerca_tipo() @@ -972,7 +940,7 @@ void TProgressivi_iva::prospetto_pagina(TGen_array& gen, TIva_array& iva) bool st_riga = FALSE; if (im != ZERO || is != ZERO) { - set_row(r++, "Totali acquisti indeducibili su ricavi esenti@62g%r@78g%r", &im, &is); + set_row(r++, FR("Totali acquisti indeducibili su ricavi esenti@62g%r@78g%r"), &im, &is); st_riga = TRUE; } cerca_tipo(iva,acq_ind_art_19,im,is,d); @@ -983,7 +951,7 @@ void TProgressivi_iva::prospetto_pagina(TGen_array& gen, TIva_array& iva) t_imposbd += is1; if (im != ZERO || is != ZERO || im1 != ZERO || is1 != ZERO) { - set_row(r++, "Totali acquisti indeducibili per ART.19@62g%r@78g%r@100g%r@116g%r", &im, &is, &im1, &is1); + set_row(r++, FR("Totali acquisti indeducibili per ART.19@62g%r@78g%r@100g%r@116g%r"), &im, &is, &im1, &is1); st_riga = TRUE; } cerca_tipo(iva,acq_ind_pass_int,im,is,d); @@ -991,12 +959,12 @@ void TProgressivi_iva::prospetto_pagina(TGen_array& gen, TIva_array& iva) t_imposa += is; if (im != ZERO || is != ZERO) { - set_row(r++, "Totali acquisti indeducibili per passaggi interni@62g%r@78g%r", &im, &is); + set_row(r++, FR("Totali acquisti indeducibili per passaggi interni@62g%r@78g%r"), &im, &is); st_riga = TRUE; } r+=2; if (st_riga) - set_row(r++, "Totale generale IVA@24g%r@40g%r@62g%r@78g%r@100g%r@116g%r", + set_row(r++, FR("Totale generale IVA@24g%r@40g%r@62g%r@78g%r@100g%r@116g%r"), &t_impov,&t_imposv,&t_impoa,&t_imposa,&t_impobd,&t_imposbd); r+=3; const int kk = r; // memorizza riga in cui scrivere "altri dati relativi alla dichiarazione" @@ -1006,91 +974,70 @@ void TProgressivi_iva::prospetto_pagina(TGen_array& gen, TIva_array& iva) cerca_tipo(iva,acq_simp,im,is,d); if (im != ZERO || is != ZERO) { - set_row(r++, "Acquisti in sospensione d'imposta@49g%r@66g%r", &im, &is); + set_row(r++, FR("Acquisti in sospensione d'imposta@49g%r@66g%r"), &im, &is); st_riga = TRUE; } cerca_tipo(iva,vend_simp,im,is,d); if (im != ZERO || is != ZERO) { - set_row(r++, "Vendite in sospensione d'imposta@49g%r@66g%r", &im, &is); + set_row(r++, FR("Vendite in sospensione d'imposta@49g%r@66g%r"), &im, &is); st_riga = TRUE; } cerca_tipo(iva,cess_amm,im,is,d); if (im != ZERO || is != ZERO) { - set_row(r++, "Cessione beni ammortizzabili@49g%r@66g%r", &im, &is); + set_row(r++, FR("Cessione beni ammortizzabili@49g%r@66g%r"), &im, &is); st_riga = TRUE; } cerca_tipo(iva,acq_beni_riv,im,is,d); if (im != ZERO || is != ZERO) { - set_row(r++, "Acquisto beni destinati alla rivendita@49g%r@66g%r", &im, &is); + set_row(r++, FR("Acquisto beni destinati alla rivendita@49g%r@66g%r"), &im, &is); st_riga = TRUE; } cerca_tipo(iva,acq_beni_ammort,im,is,d); if (im != ZERO || is != ZERO) { - set_row(r++, "Acquisto beni ammortizzabili iva detraibile@49g%r@66g%r", &im, &is); + set_row(r++, FR("Acquisto beni ammortizzabili iva detraibile@49g%r@66g%r"), &im, &is); st_riga = TRUE; } cerca_tipo(iva,acq_beni_ammort_nd,im,is,d); if (im != ZERO || is != ZERO) { - set_row(r++, "Acquisto beni ammortizzabili iva non detraibile@49g%r@66g%r", &im, &is); + set_row(r++, FR("Acquisto beni ammortizzabili iva non detraibile@49g%r@66g%r"), &im, &is); st_riga = TRUE; } cerca_tipo(iva,acq_beni_leasing,im,is,d); if (im != ZERO || is != ZERO) { - set_row(r++, "Altri beni strumentali acquisiti in leasing@49g%r@66g%r", &im, &is); + set_row(r++, FR("Altri beni strumentali acquisiti in leasing@49g%r@66g%r"), &im, &is); st_riga = TRUE; } cerca_tipo(iva,acq_amm_ultdetr,im,is,d); if (im != ZERO || is != ZERO) { - set_row(r++, "Acquisto beni soggetti a detrazione (6%%)@49g%r@66g%r@86g%r", &im, &is, &d); + set_row(r++, FR("Acquisto beni soggetti a detrazione (6%%)@49g%r@66g%r@86g%r"), &im, &is, &d); st_riga = TRUE; } if (st_riga) - set_row(kk, "ALTRI DATI RELATIVI ALLA DICHIARAZIONE@54gImponibile@74gImposta@91gDetrazione"); + set_row(kk, FR("ALTRI DATI RELATIVI ALLA DICHIARAZIONE@54gImponibile@74gImposta@91gDetrazione")); iva.destroy(); } -TRectype& look_com (const char* cod, TLocalisamfile *comuni) -{ - comuni->zero(); - comuni->put(COM_COM, cod); - comuni->read(); - if (comuni->bad()) - comuni->zero(); - - return comuni->curr(); -} - void TProgressivi_iva::get_dati_ditta() { - TLocalisamfile nditte(LF_NDITTE); - TLocalisamfile anag(LF_ANAG); TString codanagr; TString tipoa; - nditte.zero(); - nditte.put(NDT_CODDITTA, _codditta); - nditte.read(); + const TRectype & ditta = cache().get(LF_NDITTE, _codditta); - if (nditte.bad()) nditte.zero(); + codanagr = ditta.get(NDT_CODANAGR); + tipoa = ditta.get(NDT_TIPOA); + _ragsoc = ditta.get(NDT_RAGSOC); - codanagr = nditte.get(NDT_CODANAGR); - tipoa = nditte.get(NDT_TIPOA); - _ragsoc = nditte.get(NDT_RAGSOC); - - anag.setkey(1); - anag.zero(); - anag.put (ANA_TIPOA, tipoa); - anag.put (ANA_CODANAGR, codanagr); - anag.read(); - if (anag.bad()) anag.zero(); + TString16 key; key.format("%s|%s", (const char *) tipoa, (const char *) codanagr); + const TRectype & anag = cache().get(LF_ANAG, key); _cofi = anag.get(ANA_COFI); _paiva = anag.get(ANA_PAIV); @@ -1099,7 +1046,8 @@ void TProgressivi_iva::get_dati_ditta() if (_comunefis.empty()) _comunefis = anag.get(ANA_COMRES); - TRectype dep = look_com (_comunefis, _com); + key = "|"; key << _comunefis; + const TRectype & dep = cache().get(LF_COMUNI, key); _comunefis = dep.get(COM_DENCOM); _provfis = dep.get(COM_PROVCOM); @@ -1125,15 +1073,15 @@ int TProgressivi_iva::stampa_intestazione_ditta() get_dati_ditta(); - set_header (r, "Ditta %ld %s %s %s %s %s", _codditta, + set_header (r, FR("Ditta %ld %s %s %s %s %s"), _codditta, (const char*)_ragsoc, (const char*)_viafis, (const char*)_cap, (const char*)_comunefis, (const char*)_provfis); r++; - riga = "Data @> Pag. @#"; + riga = FR("Data @> Pag. @#"); riga.right_just(123); - TString80 dep; dep.format ("Partita iva %s Codice fiscale %s", + TString80 dep; dep.format (FR("Partita iva %s Codice fiscale %s"), (const char*)_paiva, (const char*)_cofi); riga.overwrite(dep); set_header (r, riga); @@ -1151,19 +1099,19 @@ void TProgressivi_iva::setta_intestazione() r = stampa_intestazione_ditta(); if (_livelloprog == 1) - set_header(r++, "Gestione Iva@b@50gPROGRESSIVI IVA PER ALIQUOTA"); - else set_header(r++, "Gestione Iva@b@50gPROGRESSIVI IVA PER ATTIVITA'"); + set_header(r++, FR("Gestione Iva@b@50gPROGRESSIVI IVA PER ALIQUOTA")); + else set_header(r++, FR("Gestione Iva@b@50gPROGRESSIVI IVA PER ATTIVITA'")); r++; - set_header(r++, "Anno liquidazione %d", _annoiva); + set_header(r++, FR("Anno liquidazione %d"), _annoiva); if (_tipoprog == 1) //vendite { if (_livelloprog == 1) { if (_sospmsk == 1) - set_header(r, "Vendite in genere"); - else set_header(r, "Vendite in sospensione d'imposta"); + set_header(r, TR("Vendite in genere")); + else set_header(r, TR("Vendite in sospensione d'imposta")); } - else set_header(r, "Cessione beni da ammortizzare"); + else set_header(r, TR("Cessione beni da ammortizzare")); } else //acquisti { @@ -1171,25 +1119,25 @@ void TProgressivi_iva::setta_intestazione() switch (_tipo_aliq) { case 1: - set_header(r, "Acquisti in genere"); + set_header(r, TR("Acquisti in genere")); break; case 2: - set_header(r, "Acquisti indetraibili su operazioni esenti"); + set_header(r, TR("Acquisti indetraibili su operazioni esenti")); break; case 3: - set_header(r, "Acquisti indetraibili passaggi interni"); + set_header(r, TR("Acquisti indetraibili passaggi interni")); break; case 4: - set_header(r, "Acquisti indetraibili art.19"); + set_header(r, TR("Acquisti indetraibili art.19")); break; case 5: - set_header(r, "Acquisti base di calcolo per la ventilazione"); + set_header(r, TR("Acquisti base di calcolo per la ventilazione")); break; case 6: - set_header(r, "Bolle doganali"); + set_header(r, TR("Bolle doganali")); break; case 7: - set_header(r, "Acquisti in sospensione d'imposta"); + set_header(r, TR("Acquisti in sospensione d'imposta")); break; default: break; @@ -1198,19 +1146,19 @@ void TProgressivi_iva::setta_intestazione() switch (_tipo_attiv) { case 1: - set_header(r, "Acquisti beni per rivendita"); + set_header(r, TR("Acquisti beni per rivendita")); break; case 2: - set_header(r, "Acquisti beni da ammortizzare detraibili"); + set_header(r, TR("Acquisti beni da ammortizzare detraibili")); break; case 3: - set_header(r, "Acquisti beni da ammortizzare non detraibili"); + set_header(r, TR("Acquisti beni da ammortizzare non detraibili")); break; case 4: - set_header(r, "Altri beni strumentali acquisiti in leasing"); + set_header(r, TR("Altri beni strumentali acquisiti in leasing")); break; case 5: - set_header(r, "Acquisti beni da ammortizzare ult.detr. 6%"); + set_header(r, TR("Acquisti beni da ammortizzare ult.detr. 6%")); break; default: break; @@ -1219,8 +1167,9 @@ void TProgressivi_iva::setta_intestazione() r++; if (_livelloprog == 1) set_header(r++, "IVA %s",(const char*) _codivamsk); - else set_header(r++, "ATTIVITA' %s",(const char*)_codattmsk); - set_header(++r, "@31gImponibile@64gImposta"); + else set_header(r++, FR("ATTIVITA' %s"),(const char*)_codattmsk); + set_header(++r, FR("@31gImponibile@64gImposta")); + } void TProgressivi_iva::preprocess_header() @@ -1231,25 +1180,24 @@ void TProgressivi_iva::preprocess_header() TString sep(132); TString ragsoc(50); TString16 descf; + TString16 key; key << _codditta; - TLocalisamfile nditte(LF_NDITTE); - nditte.zero(); - nditte.put(NDT_CODDITTA, _codditta); - if (nditte.read() == NOERR) - ragsoc = nditte.get(NDT_RAGSOC); + const TRectype & ditta = cache().get(LF_NDITTE, key); + + ragsoc = ditta.get(NDT_RAGSOC); - TString80 descr = desc_attivita(_cod_att); + TString80 descr = desc_attivita(_cod_att); reset_header(); char f = look_lia(_codditta); if (f == 'T') - descf = " TRIMESTRALE"; + descf = TR(" TRIMESTRALE"); else if (f == 'M') - descf = " MENSILE"; + descf = TR(" MENSILE"); else descf = ""; - sep << "Ditta " << _codditta; + sep << TR("Ditta ") << _codditta; sep << " " << ragsoc; sep << " " << descf; @@ -1258,35 +1206,36 @@ void TProgressivi_iva::preprocess_header() set_header (soh++, (const char*) sep); sep = ""; - sep << "Data " << _datast; - sep << " Pag. @#"; + sep << TR("Data ") << _datast; + sep << FR(" Pag. @#"); sep.right_just(127); - sep.overwrite ("RIEPILOGO PROGRESSIVI"); + sep.overwrite (TR("RIEPILOGO PROGRESSIVI")); set_header (soh++, (const char*)sep); sep.fill('-'); set_header (soh++, (const char *) sep); - const char* pro_des = _tipo_prog_reg == 'L' ? "liquidazione IVA" : "Volume Affari"; + const char* pro_des = _tipo_prog_reg == 'L' ? TR("liquidazione IVA") : TR("Volume Affari"); TString periodo; if (f == 'M') periodo = itom(_mese); else - periodo.format("%d trimestre", ((_mese-1)/3) +1); + periodo.format(FR("%d trimestre"), ((_mese-1)/3) +1); if (_st_inizio_anno) { if (_mese == 13 || (_mese == 12 && !_prima_pagina)) - set_header(soh++, "Riepilogo progressivi %s annuale %d Cod. Att. %s %s", pro_des, _anno, (const char*) _cod_att, (const char*) descr); + set_header(soh++, FR("Riepilogo progressivi %s annuale %d Cod. Att. %s %s"), pro_des, _anno, (const char*) _cod_att, (const char*) descr); else if (_prima_pagina) - set_header(soh++, "Riepilogo progressivi %s del periodo %s %d Cod. Att. %s %s", pro_des, (const char*) periodo, _anno, (const char*) _cod_att, (const char*) descr); - else set_header(soh++, "Riepilogo progressivi %s al%s: %s %d Cod. Att. %s %s", pro_des, f == 'M' ? " Mese di" : "", (const char*) periodo, _anno, (const char*) _cod_att, (const char*) descr); + set_header(soh++, FR("Riepilogo progressivi %s del periodo %s %d Cod. Att. %s %s"), pro_des, (const char*) periodo, _anno, (const char*) _cod_att, (const char*) descr); + else set_header(soh++, FR("Riepilogo progressivi %s al%s: %s %d Cod. Att. %s %s"), pro_des, f == 'M' ? TR(" Mese di") : "", (const char*) periodo, _anno, (const char*) _cod_att, (const char*) descr); + } - else set_header (soh++, "Riepilogo progressivi %s del periodo %s %d Cod. Att. %s %s", pro_des, (const char*) periodo, _anno, (const char*) _cod_att, (const char*) descr); + else set_header (soh++, FR("Riepilogo progressivi %s del periodo %s %d Cod. Att. %s %s"), pro_des, (const char*) periodo, _anno, (const char*) _cod_att, (const char*) descr); set_header (soh, (const char *) sep); } } @@ -1322,7 +1271,6 @@ return NEXT_PAGE; int cg0400(int argc,char* argv[]) { TProgressivi_iva a; - a.run(argc, argv, "Riepilogo progressivi IVA"); + a.run(argc, argv, TR("Riepilogo progressivi IVA")); return 0; } - diff --git a/cg/cg0500.cpp b/cg/cg0500.cpp index 832cf8a94..6b5f2de05 100755 --- a/cg/cg0500.cpp +++ b/cg/cg0500.cpp @@ -21,7 +21,6 @@ typedef enum { no_descr, acquisto, vendita, incasso_pagamento, class TCaus_app : public TRelation_application { TRelation* _rel; // Relazione principale - TLocalisamfile * _rcaus; TMask* _msk; // Maschera principale @@ -195,15 +194,15 @@ void TCaus_app::causale_vendite() if (_tipo_des != vendita) { int i = 0; - set_descr(i++, "C Clienti"); - set_descr(i++, "C Di ricavo"); - set_descr(i++, "C Iva vendite"); - set_descr(i++, "C Iva non detraibile"); - set_descr(i++, "C Imp. esenti"); - set_descr(i++, "C Imp. non imponibili"); - set_descr(i++, "C Imp. non soggetti"); - set_descr(i++, "C Ritenute fiscali"); - set_descr(i++, "C Ritenute soc."); + set_descr(i++, TR("C Clienti")); + set_descr(i++, TR("C Di ricavo")); + set_descr(i++, TR("C Iva vendite")); + set_descr(i++, TR("C Iva non detraibile")); + set_descr(i++, TR("C Imp. esenti")); + set_descr(i++, TR("C Imp. non imponibili")); + set_descr(i++, TR("C Imp. non soggetti")); + set_descr(i++, TR("C Ritenute fiscali")); + set_descr(i++, TR("C Ritenute soc.")); _tipo_des = vendita; carica_righe_libere(i); } @@ -215,15 +214,15 @@ void TCaus_app::causale_acquisti() if (_tipo_des != acquisto) { int i = 0; - set_descr(i++, "C Fornitori"); - set_descr(i++, "C Di costo"); - set_descr(i++, "C Iva acquisti"); - set_descr(i++, "C Iva non detraibile"); - set_descr(i++, "C Imp. esenti"); - set_descr(i++, "C Imp. non imponibili"); - set_descr(i++, "C Imp. non soggetti"); - set_descr(i++, "C Ritenute fiscali"); - set_descr(i++, "C Ritenute soc."); + set_descr(i++, TR("C Fornitori")); + set_descr(i++, TR("C Di costo")); + set_descr(i++, TR("C Iva acquisti")); + set_descr(i++, TR("C Iva non detraibile")); + set_descr(i++, TR("C Imp. esenti")); + set_descr(i++, TR("C Imp. non imponibili")); + set_descr(i++, TR("C Imp. non soggetti")); + set_descr(i++, TR("C Ritenute fiscali")); + set_descr(i++, TR("C Ritenute soc.")); _tipo_des = acquisto; carica_righe_libere(i); } @@ -234,9 +233,9 @@ void TCaus_app::causale_ritenute() if (_tipo_des != ritenuta_occas) { int i = 0; - set_descr (i++, "Costo"); - set_descr (i++, "Cassa/banca"); - set_descr (i++, "Erario"); + set_descr (i++, TR("Costo")); + set_descr (i++, TR("Cassa/banca")); + set_descr (i++, TR("Erario")); _tipo_des = ritenuta_occas; carica_righe_libere(i); } @@ -247,19 +246,19 @@ void TCaus_app::causale_inc_pag() if (_tipo_des != incasso_pagamento) { int i = 0; - set_descr(i++, "C Clienti/Fornitori"); - set_descr(i++, "C Cassa o banca"); - set_descr(i++, "C Tratta"); - set_descr(i++, "C Ricevuta bancaria"); - set_descr(i++, "C Cessione"); - set_descr(i++, "C Paghero'"); - set_descr(i++, "C Lettera di credito"); - set_descr(i++, "C Tratta accettata"); - set_descr(i++, "C Abbuoni pass./sc."); - set_descr(i++, "C Abbuoni att./sc."); - set_descr(i++, "C Spese e rimborsi"); - set_descr(i++, "C Ritenute fiscali"); - set_descr(i++, "C Differenza cambio"); + set_descr(i++, TR("C Clienti/Fornitori")); + set_descr(i++, TR("C Cassa o banca")); + set_descr(i++, TR("C Tratta")); + set_descr(i++, TR("C Ricevuta bancaria")); + set_descr(i++, TR("C Cessione")); + set_descr(i++, TR("C Paghero'")); + set_descr(i++, TR("C Lettera di credito")); + set_descr(i++, TR("C Tratta accettata")); + set_descr(i++, TR("C Abbuoni pass./sc.")); + set_descr(i++, TR("C Abbuoni att./sc.")); + set_descr(i++, TR("C Spese e rimborsi")); + set_descr(i++, TR("C Ritenute fiscali")); + set_descr(i++, TR("C Differenza cambio")); _tipo_des = incasso_pagamento; carica_righe_libere(i); } @@ -295,15 +294,14 @@ void TCaus_app::set_reg_filter(int f) int TCaus_app::calc_filter(const TString& tpd) { - TTable tabtpd("%TPD"); - tabtpd.put("CODTAB", tpd); + const TRectype & tpd_rec = cache().get("%TPD", tpd); int filtro = 0; - if (tabtpd.read() == NOERR) + if (!tpd_rec.empty()) { - const TipoIVA i = (TipoIVA)tabtpd.get_int("I0"); // IVA acquisti, vendite, generica - const bool corrisp = tabtpd.get_bool("B0"); + const TipoIVA i = (TipoIVA)tpd_rec.get_int("I0"); // IVA acquisti, vendite, generica + const bool corrisp = tpd_rec.get_bool("B0"); if (i == iva_vendite) // vendite { @@ -363,7 +361,7 @@ bool TCaus_app::tipodoc_hndl (TMask_field& f, KEY k) { TRegistro registro(codreg, app().anno_iva()); if (registro.name().empty()) - return f.error_box("Non esiste il registro %s per l'anno %d", + return f.error_box(FR("Non esiste il registro %s per l'anno %d"), (const char *)codreg, app().anno_iva()); } @@ -465,7 +463,7 @@ bool TCaus_app::cod_reg_hndl (TMask_field& f, KEY k) const TRegistro grog(codreg, app().anno_iva()); const TipoIVA ri = grog.iva(); if (i != ri) - return f.error_box("Tipo documento incompatibile con tipo registro"); + return f.error_box(TR("Tipo documento incompatibile con tipo registro")); } } } @@ -512,7 +510,7 @@ bool TCaus_app::sezione_hndl(TMask_field& f, KEY k) { const char sez = f.get()[0]; if (sez != 'A' && sez != 'D') - return f.error_box("E' necessario specificare la sezione D/A"); + return f.error_box(TR("E' necessario specificare la sezione D/A")); } // else // f.reset(); @@ -581,7 +579,8 @@ bool TCaus_app::conto_hndl (TMask_field& f, KEY k) if (!ok) return cfld.error_box( - "%s non valido con registro %s", cf == 'C' ? "Cliente" : "Fornitore", iva2name(tpr)); + FR("%s non valido con registro %s"), cf == 'C' ? TR("Cliente") : TR("Fornitore"), iva2name(tpr)); + } if (sezione == ' ' && sezione_consigliata != ' ') @@ -602,7 +601,7 @@ bool TCaus_app::sottoconto_hndl(TMask_field& f, KEY k) { const TMask& m = f.mask(); const bool ok = m.get(SS_GRUPPO).not_empty() && m.get(SS_CONTO).not_empty(); - if (!ok) return f.error_box("Conto incompleto"); + if (!ok) return f.error_box(TR("Conto incompleto")); } return TRUE; } @@ -688,8 +687,6 @@ void TCaus_app::load_rcaus(TMask& m) { const TString16 cod(_rel->lfile().get(RCA_CODCAUS)); TString d, da(50); - - TTable dpn("%DPN"); const int last = _rcaus_rec->last_row(); for (int i = 1; i <= last; i++) @@ -704,9 +701,9 @@ void TCaus_app::load_rcaus(TMask& m) da.cut(0); if (d.not_empty()) { - dpn.put("CODTAB", d); - if (dpn.read() == NOERR) - da = dpn.get("S0"); + const TRectype & dpn = cache().get("%DPN", d); + + da = dpn.get("S0"); } TBill tc(g,c,s,cf); @@ -719,17 +716,16 @@ bool TCaus_app::fill_sheet(TMask& m) { const TString8 codreg = m.get(F_COD_REG); const TString8 tpd = m.get(F_TIPO_DOC); - const int tpm = m.get_int(F_TIPO_MOV); - const int m770 = m.get_int(F_M_770); + const int tpm = m.get_int(F_TIPO_MOV); + const int m770 = m.get_int(F_M_770); int tpr = m.get_int(F_TIPO_REG); if (!m.is_running()) { TString16 chiave; chiave << anno_iva() << codreg; - TTable reg("REG"); - reg.put("CODTAB", chiave); - if (reg.read() == NOERR) - tpr = reg.get_int("I0"); + const TRectype & reg = cache().get("REG", chiave); + + tpr = reg.get_int("I0"); } // carico le descrizioni fisse nell'array Righe_rcaus @@ -893,11 +889,10 @@ void TCaus_app::on_config_change() bool TCaus_app::user_create() { - _rel = new TRelation (LF_CAUSALI); - _rcaus = new TLocalisamfile(LF_RCAUSALI); - + open_files(LF_CAUSALI, LF_RCAUSALI, LF_TABCOM, LF_TAB, 0); + + _rel = new TRelation (LF_CAUSALI); _rcaus_rec = new TRecord_array(LF_RCAUSALI, RCA_NRIGA); - _msk = new TMask("cg0500a"); _sheet = &(TSheet_field&)_msk->field(F_SHEET_GCS); @@ -922,13 +917,13 @@ bool TCaus_app::user_destroy() delete _rcaus_rec; delete _rcaus; delete _rel; + return TRUE; } int cg0500(int argc, char* argv[]) { TCaus_app a; - a.run(argc, argv, "Tabella causali"); + a.run(argc, argv, TR("Tabella causali")); return 0; -} - +} \ No newline at end of file diff --git a/cg/cg0600.cpp b/cg/cg0600.cpp index 095e62b92..135765e78 100755 --- a/cg/cg0600.cpp +++ b/cg/cg0600.cpp @@ -138,18 +138,18 @@ bool CGTTable_application::check_esercizio(TString& cod, TDate s1, TDate f1) { ret = FALSE; TString errstr(120); - errstr << "Date esercizio errate: \n"; + errstr << TR("Date esercizio errate: \n"); // build error string if (err & 0x01) - errstr << "\n - l'esercizio si sovrappone ad altro gia' esistente"; + errstr << TR("\n - l'esercizio si sovrappone ad altro gia' esistente"); if (err & 0x02) - errstr << "\n - l'esercizio non e' contiguo ad esercizi successivi"; + errstr << TR("\n - l'esercizio non e' contiguo ad esercizi successivi"); if (err & 0x04) - errstr << "\n - l'esercizio non e' contiguo ad esercizi precedenti"; + errstr << TR("\n - l'esercizio non e' contiguo ad esercizi precedenti"); if (!(err & 0x01)) { - errstr << "\nSi desidera registrare ugualmente?"; + errstr << TR("\nSi desidera registrare ugualmente?"); ret = yesno_box(errstr); } else error_box(errstr); @@ -169,8 +169,9 @@ void CGTTable_application::check_sheet() escarr.sort(); - TArray_sheet as(-1,-1,70,20,"Esercizi contabili", - "Codice|Inizio@10|Fine@10|Scarico@10|Chiusura@10|Note@20", + TArray_sheet as(-1,-1,70,20,TR("Esercizi contabili"), + FR("Codice|Inizio@10|Fine@10|Scarico@10|Chiusura@10|Note@20"), + 0x10); @@ -189,7 +190,11 @@ void CGTTable_application::check_sheet() tt->add(e.chiusura().string()); if (i > 0 && e.inizio() != ++s1) - tt->add("*** non contiguo ***"); + { + TString nc; nc << "***" << TR("non contiguo") << "***"; + tt->add(nc); + } + else tt->add(""); s1 = e.fine(); @@ -213,9 +218,8 @@ int cg0600(int argc, char* argv[]) { CGTTable_application a; - a.run(argc, argv, "Gestione tabelle contabili"); + a.run(argc, argv, TR("Gestione tabelle contabili")); return 0; } - diff --git a/cg/cg1100.cpp b/cg/cg1100.cpp index 5fb8af8dd..868beafba 100755 --- a/cg/cg1100.cpp +++ b/cg/cg1100.cpp @@ -203,7 +203,6 @@ void CG1100_application::postclose_print() { if (_tipo_stampa == senza_ana_bil) { - delete _tpcon; delete _relt; } } @@ -330,7 +329,7 @@ void CG1100_application::do_sort() long last = cursor->items(); - TProgind prg (last, "Elaborazione Piano dei Conti... Prego attendere", FALSE, TRUE, 30); + TProgind prg (last, TR("Elaborazione Piano dei Conti... Prego attendere"), FALSE, TRUE, 30); for ( *cursor = 0; cursor->pos() < last; ++(*cursor) ) { @@ -410,7 +409,7 @@ void CG1100_application::do_sort() long last = cursor->items(); - TProgind prg (last, "Elaborazione Piano dei Conti... Prego attendere", FALSE, TRUE, 30); + TProgind prg (last, TR("Elaborazione Piano dei Conti... Prego attendere"), FALSE, TRUE, 30); TString c1(12); @@ -481,7 +480,7 @@ void CG1100_application::prepara_pcon_temp() long items = pcon.items(); - TProgind prog (items,"Elaborazione Piano dei Conti... Prego attendere", FALSE, TRUE, 30); + TProgind prog (items,TR("Elaborazione Piano dei Conti... Prego attendere"), FALSE, TRUE, 30); for (pcon.first(); !pcon.eof(); pcon.next()) { @@ -649,7 +648,7 @@ void CG1100_application::set_con_IV() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gCONTI D' ORDINE ATTIVI"); + set_row (_i++,FR("@0gCONTI D' ORDINE ATTIVI")); set_row (_i++,"@0g%c", app); stampa_classe = FALSE; } @@ -658,7 +657,7 @@ void CG1100_application::set_con_IV() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gATTIVO"); + set_row (_i++,FR("@0gATTIVO")); set_row (_i++,"@0g%c", app); } @@ -666,7 +665,7 @@ void CG1100_application::set_con_IV() { char app = ' '; set_row(_i++,"@0g%c", app); - set_row (_i++,"@0gCONTI D' ORDINE PASSIVI"); + set_row (_i++,FR("@0gCONTI D' ORDINE PASSIVI")); set_row(_i++,"@0g%c", app); stampa_classe = FALSE; } @@ -675,7 +674,7 @@ void CG1100_application::set_con_IV() { char app = ' '; set_row(_i++,"@0g%c", app); - set_row (_i++,"@0gPASSIVO"); + set_row (_i++,FR("@0gPASSIVO")); set_row(_i++,"@0g%c", app); } @@ -683,7 +682,7 @@ void CG1100_application::set_con_IV() { char app = ' '; set_row(_i++,"@0g%c", app); - set_row (_i++,"@0gCONTI D' ORDINE"); + set_row (_i++,FR("@0gCONTI D' ORDINE")); set_row(_i++,"@0g%c", app); stampa_classe = FALSE; } @@ -692,7 +691,7 @@ void CG1100_application::set_con_IV() { char app = ' '; set_row(_i++,"@0g%c", app); - set_row (_i++,"@0gCONTO ECONOMICO"); + set_row (_i++,FR("@0gCONTO ECONOMICO")); set_row(_i++,"@0g%c", app); } } @@ -703,7 +702,7 @@ void CG1100_application::set_con_IV() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gCONTI D' ORDINE ATTIVI"); + set_row (_i++,FR("@0gCONTI D' ORDINE ATTIVI")); set_row (_i++,"@0g%c", app); stampa_classe = FALSE; } @@ -711,7 +710,7 @@ void CG1100_application::set_con_IV() { char app = ' '; set_row(_i++,"@0g%c", app); - set_row (_i++,"@0gCONTI D' ORDINE PASSIVI"); + set_row (_i++,FR("@0gCONTI D' ORDINE PASSIVI")); set_row(_i++,"@0g%c", app); stampa_classe = FALSE; } @@ -761,18 +760,6 @@ void CG1100_application::set_con_IV() _i++; } -/*void CG1100_application::setta_righe_descr(TParagraph_string* str) - { - const char* r; - - while ((r = str->get()) != NULL) - { - set_row (_i,"@14g%s",r); - _i++; - } - _i--; - } */ - void CG1100_application::set_senza_IV_ana() { int i; @@ -853,9 +840,9 @@ void CG1100_application::set_con_ana() long sottoc = rec.get_long(PCN_SOTTOCONTO); bool stsobi = rec.get_bool(PCN_STSOTTAB); if (stsobi) - val = "Si"; + val = TR("Si"); else - val = "No"; + val = TR("No"); descrizione = descrizione_codcbl(codcbl); descr = rec.get(PCN_DESCR); @@ -891,30 +878,6 @@ void CG1100_application::set_con_ana() _i++; } -/********* -void CG1100_application::set_senza_ana() -{ - reset_row (1); - - set_row (1, "$[b]@pn$[n] $[b]@pn$[n] $[b]@pn$[n]", - FLD(LF_PCON, PCN_GRUPPO, "###"), FLD(LF_PCON,PCN_CONTO, "###"), - FLD(LF_PCON, PCN_SOTTOCONTO, "######")); - - set_row (1, "@16g@50s", FLD(LF_PCON,PCN_DESCR) ); - - set_row (1, "@69g@1s", FLD(LF_PCON, PCN_SEZIVD) ); - set_row (1, "@71g@1s", FLD(LF_PCON, PCN_LETTIVD) ); - set_row (1, "@73g#-8t", &_clivd); - set_row (1, "@82g@pn", FLD(LF_PCON, PCN_NUMIVD, "@@") ); - - set_row (1, "@87g@pn", FLD(LF_PCON, PCN_INDBIL, "#") ); - set_row (1, "@92g@1s", FLD(LF_PCON, PCN_TMCF) ); - set_row (1, "@99g@f", FLD(LF_PCON, PCN_STSOTTBIL) ); - set_row (1, "@107g@f", FLD(LF_PCON, PCN_COMPENS) ); - set_row (1, "@120g@1s", FLD(LF_PCON, PCN_SEZSALDI) ); -} -*********/ - void CG1100_application::set_completa() { TRectype& rec = current_cursor()->curr(); @@ -1228,7 +1191,7 @@ bool CG1100_application::set_print(int) _data_stampa = _msk->get(F_DATA_STAMPA); // scegli_cur(); - enable_link("Collegamento Piano dei conti: ", 'b'); + enable_link(TR("Collegamento Piano dei conti: "), 'b'); set_multiple_link(TRUE); _sez_stamp = ' '; @@ -1241,7 +1204,7 @@ bool CG1100_application::set_print(int) reset_footer(); if (_tipo_stampa == con_ana_bil) - set_footer(2,"* Conti collegati ma non trasferibili"); + set_footer(2,TR("* Conti collegati ma non trasferibili")); else set_footer(2,""); @@ -1307,60 +1270,60 @@ void CG1100_application::intesta (stampe tipo) s = ditte.get(NDT_RAGSOC); TString data = _data_stampa.string(); - set_header (soh++, "Ditta : %ld %s@110gData@115g%s Pag. @#", firm, (const char *) s, (const char*) data); + set_header (soh++, FR("Ditta : %ld %s@110gData@115g%s Pag. @#"), firm, (const char *) s, (const char*) data); - set_header (soh,"@0gPIANO DEI CONTI"); + set_header (soh,FR("@0gPIANO DEI CONTI")); switch (tipo) { case completa: - set_header (soh++, "@20gStampa completa per IV direttiva"); + set_header (soh++, FR("@20gStampa completa per IV direttiva")); s.fill('-'); set_header (soh++, (const char *) s); - set_header (soh++, "Conto @59gSez. Classe@75gTipo@86gNo Dettaglio@104gT@107gSpesa@118gDet.alleg.bil."); - set_header (soh++, "Sottoconto @16gDescrizione@61gIV dir.@75gConto@81gC/F@86gBilancio@97gComp.@104gA@107gRicavo@114gSez@118gSot.con * Mov."); + set_header (soh++, FR("Conto @59gSez. Classe@75gTipo@86gNo Dettaglio@104gT@107gSpesa@118gDet.alleg.bil.")); + set_header (soh++, FR("Sottoconto @16gDescrizione@61gIV dir.@75gConto@81gC/F@86gBilancio@97gComp.@104gA@107gRicavo@114gSez@118gSot.con * Mov.")); break; case con_IV_direttiva: - set_header (soh++, "@20gStampa conti riclassificati per IV direttiva"); + set_header (soh++, FR("@20gStampa conti riclassificati per IV direttiva")); s.fill('-'); set_header (soh++, (const char *) s); - set_header (soh++, "@58gCodici Piano@116gSez. e Classe"); - set_header (soh++, "Classe@14gDescrizione@58gdei Conti @73gDescrizione@116gdi segno opposto"); + set_header (soh++, FR("@58gCodici Piano@116gSez. e Classe")); + set_header (soh++, FR("Classe@14gDescrizione@58gdei Conti @73gDescrizione@116gdi segno opposto")); break; case senza_IV_direttiva: - set_header (soh++, "@20gStampa conti non collegati per IV direttiva"); + set_header (soh++, FR("@20gStampa conti non collegati per IV direttiva")); s.fill('-'); set_header (soh++, (const char *) s); - set_header (soh++, "Conto @75gTipo@86gNo Dettaglio@104gT@107gSpesa@118gDet.alleg.bil."); - set_header (soh++, "Sottoconto @16gDescrizione@75gConto@81gC/F@86gBilancio@97gComp.@104gA@107gRicavo@114gSez@118gSot.con * Mov."); + set_header (soh++, FR("Conto @75gTipo@86gNo Dettaglio@104gT@107gSpesa@118gDet.alleg.bil.")); + set_header (soh++, FR("Sottoconto @16gDescrizione@75gConto@81gC/F@86gBilancio@97gComp.@104gA@107gRicavo@114gSez@118gSot.con * Mov.")); break; case completa_bil: - set_header (soh++, "@20gStampa completa per analisi di bilancio"); + set_header (soh++, FR("@20gStampa completa per analisi di bilancio")); s.fill('-'); set_header (soh++, (const char *) s); - set_header (soh++, "Conto@60gCod.tabella@75gTipo@86gNo Dettaglio@104gT@107gSpesa@118gDet.alleg.bil."); - set_header (soh++, "Sottoconto @16gDescrizione@60gAnalis.bil.@75gConto@81gC/F@86gBilancio@97gComp.@104gA@107gRicavo@114gSez@118gSot.con * Mov."); + set_header (soh++, FR("Conto@60gCod.tabella@75gTipo@86gNo Dettaglio@104gT@107gSpesa@118gDet.alleg.bil.")); + set_header (soh++, FR("Sottoconto @16gDescrizione@60gAnalis.bil.@75gConto@81gC/F@86gBilancio@97gComp.@104gA@107gRicavo@114gSez@118gSot.con * Mov.")); break; case con_ana_bil: - set_header (soh++, "@20gStampa conti riclassificati per analisi di bilancio"); + set_header (soh++, FR("@20gStampa conti riclassificati per analisi di bilancio")); s.fill('-'); set_header (soh++, (const char *) s); - set_header (soh++, "Codice @62gCodici Piano@118gDet.alleg.bil."); - set_header (soh++, "Tabella@11gDescrizione@62gdei Conti @78gDescrizione@118gSot.con * Mov."); + set_header (soh++, FR("Codice @62gCodici Piano@118gDet.alleg.bil.")); + set_header (soh++, FR("Tabella@11gDescrizione@62gdei Conti @78gDescrizione@118gSot.con * Mov.")); break; case senza_ana_bil: - set_header (soh++, "@20gStampa conti non collegati per analisi di bilancio"); + set_header (soh++, FR("@20gStampa conti non collegati per analisi di bilancio")); s.fill('-'); set_header (soh++, (const char *) s); - set_header (soh++, "Conto@74gTipo@86gNo Dettaglio@107gSpesa@114gT@116gDett.alleg.bil."); - set_header (soh++, "Sottoconto@16gDescrizione@74gConto@81gC/F@86gBilancio@96gCompensaz.@107gRicavo@114gA@116gSot.con * Movim."); + set_header (soh++, FR("Conto@74gTipo@86gNo Dettaglio@107gSpesa@114gT@116gDett.alleg.bil.")); + set_header (soh++, FR("Sottoconto@16gDescrizione@74gConto@81gC/F@86gBilancio@96gCompensaz.@107gRicavo@114gA@116gSot.con * Movim.")); break; default: @@ -1431,13 +1394,7 @@ bool CG1100_application::user_create() TCursor *cursor = new TCursor (_rel); _cur_c1 = add_cursor (cursor); - -// _tpcon = new TIsamtempfile (LF_PCON, "ab", TRUE); -// _relt = new TRelation (_tpcon); -// TCursor *tcursor = new TCursor (_relt); - -// _cur_c3 = add_cursor (tcursor); - + _rec = new TRectype (cursor->curr()); _pcont_reclen = _rec->len(); @@ -1447,8 +1404,6 @@ bool CG1100_application::user_create() add_file(LF_PCON); - //set_print_zero(); - _tipo_stampa = completa; _salto_pag = FALSE; _bil = new bil_ivd; @@ -1473,6 +1428,6 @@ bool CG1100_application::user_destroy() int cg1100(int argc, char* argv[]) { CG1100_application a; - a.run(argc, argv, "Stampa Piano dei Conti"); + a.run(argc, argv, TR("Stampa Piano dei Conti")); return 0; } diff --git a/cg/cg1100a.uml b/cg/cg1100a.uml index b73df46c3..a9de43fb1 100755 --- a/cg/cg1100a.uml +++ b/cg/cg1100a.uml @@ -46,12 +46,12 @@ BEGIN HELP "Indicare se si desidera un salto pagina ogni volta che cambia il gruppo" END -BUTTON DLG_OK 9 2 +BUTTON DLG_OK 10 2 BEGIN PROMPT -12 -1 "" END -BUTTON DLG_QUIT 9 2 +BUTTON DLG_QUIT 10 2 BEGIN PROMPT -22 -1 "" END diff --git a/cg/cg1200.cpp b/cg/cg1200.cpp index 4abc8858a..78e8bd6dc 100755 --- a/cg/cg1200.cpp +++ b/cg/cg1200.cpp @@ -482,66 +482,52 @@ void TPrintclifo_app::header_elenco() if (ditte.bad()) ditte.zero(); TString s(ditte.get(NDT_RAGSOC)); - set_header(j, "Ditta %ld %s@125gPag @#", firm, (const char*) s); - set_header(j++, "@102gData %s", (const char*) _data_stampa); - /* - if (_pr_what == both) - { - current_cursor()->save_status(); - ++(*current_cursor()); - tipocf = current_cursor()->curr(LF_CLIFO).get_char(CLI_TIPOCF); - --(*current_cursor()); - current_cursor()->restore_status(); - } - else - */ + set_header(j, FR("Ditta %ld %s@125gPag @#"), firm, (const char*) s); + set_header(j++, FR("@102gData %s"), (const char*) _data_stampa); tipocf = current_cursor()->curr(LF_CLIFO).get_char(CLI_TIPOCF); if (tipocf == 'C') - var = "Clienti"; + var = TR("Clienti"); else if (tipocf == 'F') - var = "Fornitori"; + var = TR("Fornitori"); - set_header(j, "Elenco %s",(const char*) var); + set_header(j, FR("Elenco %s"),(const char*) var); if (_sort == 1) - var = "Ordine di codice"; + var = TR("Ordine di codice"); else - var = "Ordine alfabetico"; + var = TR("Ordine alfabetico"); set_header(j, "@30g%s", (const char*) var); if (_mov_only) - set_header(j, "@55gSolo i movimentati"); + set_header(j, FR("@55gSolo i movimentati")); ultimo_codice(_tipocf); - set_header(j++, "@102gUltimo cod.utilizzato %ld" , _codice); + set_header(j++, FR("@102gUltimo cod.utilizzato %ld") , _codice); if (_pr_what != both) { if (_cod_from.not_empty() || _cod_to.not_empty()) { - set_header(j, "Estremi selezione"); + set_header(j, TR("Estremi selezione")); if (_cod_from.not_empty()) - set_header(j, " da %s", (const char*) _cod_from); + set_header(j, FR(" da %s"), (const char*) _cod_from); if (_cod_to.not_empty()) - if (_sort == 1) - set_header(j, " a %s", (const char*) _cod_to); - else - set_header(j, " a %s", (const char*) _cod_to); + set_header(j, FR(" a %s"), (const char*) _cod_to); j++; } } set_header(j++, (const char *)(TString(132).fill('-'))); - set_header(j++, " Codice Ragione sociale"); - set_header(j++, "@9gIndirizzo@56gC.A.P.@63gLocalita'"); - set_header(j++, "@9gTelefoni@90gFAX @115gTelex"); - set_header(j++, "@9gIndirizzo posta elettronica"); - set_header(j++, "@9gLuogo di nascita@45gData@56gPartita IVA Codice fiscale"); - set_header(j++, "@9gConto di costo/ricavo@56gCodice allegato@90gPercipiente 770"); + set_header(j++, TR(" Codice Ragione sociale")); + set_header(j++, FR("@9gIndirizzo@56gC.A.P.@63gLocalita'")); + set_header(j++, FR("@9gTelefoni@90gFAX @115gTelex")); + set_header(j++, FR("@9gIndirizzo posta elettronica")); + set_header(j++, FR("@9gLuogo di nascita@45gData@56gPartita IVA Codice fiscale")); + set_header(j++, FR("@9gConto di costo/ricavo@56gCodice allegato@90gPercipiente 770")); set_header(j, (const char *)(TString(132).fill('-'))); } @@ -559,85 +545,51 @@ void TPrintclifo_app::header_rubriche() ditte.read(); if (ditte.bad()) ditte.zero(); TString s(ditte.get(NDT_RAGSOC)); - set_header(j, "Ditta %ld %s@125gPag @#", firm, (const char*) s); - set_header(j++, "@102gData %s", (const char*) _data_stampa); - /* - if (_pr_what == both) - { - current_cursor()->save_status(); - ++(*current_cursor()); - tipocf = current_cursor()->curr(LF_CLIFO).get_char(CLI_TIPOCF); - --(*current_cursor()); - current_cursor()->restore_status(); - } - else - */ + set_header(j, FR("Ditta %ld %s@125gPag @#"), firm, (const char*) s); + set_header(j++, FR("@102gData %s"), (const char*) _data_stampa); tipocf = current_cursor()->curr(LF_CLIFO).get_char(CLI_TIPOCF); if (tipocf == 'C') - var = "Clienti"; + var = TR("Clienti"); else if (tipocf == 'F') - var = "Fornitori"; + var = TR("Fornitori"); - set_header(j, "Rubrica %s",(const char*) var); + set_header(j, FR("Rubrica %s"),(const char*) var); if (_sort == 1) - var = "Ordine di codice"; + var = TR("Ordine di codice"); else - var = "Ordine alfabetico"; + var = TR("Ordine alfabetico"); set_header(j, "@30g%s", (const char*) var); if (_mov_only) - set_header(j, "@55gSolo i movimentati"); + set_header(j, FR("@55gSolo i movimentati")); ultimo_codice(_tipocf); - set_header(j++, "@102gUltimo cod.utilizzato %ld" , _codice); + set_header(j++, FR("@102gUltimo cod.utilizzato %ld") , _codice); if (_pr_what != both) { if (_cod_from.not_empty() || _cod_to.not_empty()) { - set_header(j, "Estremi selezione"); + set_header(j, TR("Estremi selezione")); if (_cod_from.not_empty()) - set_header(j, " da %s", (const char*) _cod_from); + set_header(j, FR(" da %s"), (const char*) _cod_from); if (_cod_to.not_empty()) - if (_sort == 1) - set_header(j, " a %s", (const char*) _cod_to); - else - set_header(j, " a %s", (const char*) _cod_to); + set_header(j, FR(" a %s"), (const char*) _cod_to); j++; } } set_header(j++, (const char *)(TString(132).fill('-'))); - set_header(j++, " Codice Ragione sociale@60gIndirizzo@100gC.A.P.@106gLocalita'@127gProv."); - set_header(j++, "@9gPartita iva@25gTelefoni"); + set_header(j++, FR(" Codice Ragione sociale@60gIndirizzo@100gC.A.P.@106gLocalita'@127gProv.")); + set_header(j++, FR("@9gPartita iva@25gTelefoni")); set_header(j++, (const char *)(TString(132).fill('-'))); } -/* - void TPrintclifo_app::set_elenco() - { - // body - set_row(1,"$[b]@1s$[n] $[b]@pn$[n] #t", FLD(LF_CLIFO, CLI_TIPOCF), - FLD(LF_CLIFO, CLI_CODCF,"@@@@@@"), &_name); - set_row(2,"@9g#t@56g@s@63g#t @s @s", &_indir, FLD(LF_CLIFO, CLI_CAPCF), - &_localita, FLD(-COMRF_ALIAS,COM_DENCOM), FLD(-COMRF_ALIAS,COM_PROVCOM)); - set_row(3,"@9g#t@90g#t@115g#t", &_telefono, &_fax, &_telex); - set_row(4,"@9g@s @s@45g#t@56g#t@69g#t",FLD(-COMNASC_ALIAS, COM_DENCOM), - FLD(-COMNASC_ALIAS, COM_PROVCOM), &_datanas, &_piva,&_cofi); - set_row(5,"@9g@3n @3n @6n #t@56g@n #t@90g#t",FLD(LF_CLIFO,CLI_GRUPPORIC), - FLD(LF_CLIFO,CLI_CONTORIC), FLD(LF_CLIFO, CLI_SOTTOCRIC),&_d_c_ric, - FLD(LF_CLIFO, CLI_CODALLEG), &_d_alleg, &_cpercip); - - for(int i = 0; i < _interline; i++) - set_row(i+5,""); - } - */ -//modifica del 27/04/1995 void TPrintclifo_app::set_elenco() { set_row(1,"$[b]@1s$[n] $[b]@pn$[n] #t", FLD(LF_CLIFO, CLI_TIPOCF), @@ -729,17 +681,17 @@ void TPrintclifo_app::set_vendite(int f, int c) ///////////////////////////////// // Prints CFVEN information // ///////////////////////////////// - set_header(1, "Ditta %ld %s @102gData @<@125gPag @#", firm, (const char*) s); - set_header(2, "Dati Clienti/Fornitori per Vendite"); + set_header(1, FR("Ditta %ld %s @102gData @<@125gPag @#"), firm, (const char*) s); + set_header(2, FR("Dati Clienti/Fornitori per Vendite")); set_header(3, (const char *)(TString(132).fill('-'))); - set_header(4," Codice Ragione sociale"); - set_header(5,"@9gNote Cli/For @25gLegale per contenz. @46gCat.Finanziaria @63gCat.Vendita @76gAss.Fiscale @93gZona @101gAgente @112gProvvigione"); - set_header(6,"@9gCod.Listino @25gCod. Magazzino @46gSpese da Addeb. @63gBolli @76gSpese incasso" ); - set_header(7,"@9gCli/For ass. @25gCod. Meccanografico @46gGest. Contratto @63gRid. Iva @76gUltimo sollecito @93gUltimo estr. conto @112gTitolo onorifico"); - set_header(8,"@9gSconto @46gSconto Cliente@63gFatt. Sosp. @76gVs. Lettera Esenzione @112gNs. Lettera Esenz."); - set_header(9,"@9gCod. ABI p.e. @25gCod. CAB p.e. @46gInd. Effetti @63gEmiss. Eff. @76gImporto Minimo @93gEffetti non acc. @112gScadenza effetti"); - set_header(10,"@9gInd.Documento @25gInd. Spedizione @46gNote Documento @63gCod.Mezzo @76gPorto @93gVettori"); - set_header(11,"@9gRaggr. ordini @25gImporto Minimo @46gImporto Massimo @63gPriorita ev. @76gTipo Evasione"); + set_header(4,FR(" Codice Ragione sociale")); + set_header(5,FR("@9gNote Cli/For @25gLegale per contenz. @46gCat.Finanziaria @63gCat.Vendita @76gAss.Fiscale @93gZona @101gAgente @112gProvvigione")); + set_header(6,FR("@9gCod.Listino @25gCod. Magazzino @46gSpese da Addeb. @63gBolli @76gSpese incasso") ); + set_header(7,FR("@9gCli/For ass. @25gCod. Meccanografico @46gGest. Contratto @63gRid. Iva @76gUltimo sollecito @93gUltimo estr. conto @112gTitolo onorifico")); + set_header(8,FR("@9gSconto @46gSconto Cliente@63gFatt. Sosp. @76gVs. Lettera Esenzione @112gNs. Lettera Esenz.")); + set_header(9,FR("@9gCod. ABI p.e. @25gCod. CAB p.e. @46gInd. Effetti @63gEmiss. Eff. @76gImporto Minimo @93gEffetti non acc. @112gScadenza effetti")); + set_header(10,FR("@9gInd.Documento @25gInd. Spedizione @46gNote Documento @63gCod.Mezzo @76gPorto @93gVettori")); + set_header(11,FR("@9gRaggr. ordini @25gImporto Minimo @46gImporto Massimo @63gPriorita ev. @76gTipo Evasione")); set_header(12, (const char *)(TString(132).fill('-'))); set_row(1,"$[b]@1s$[n] $[b]@pn$[n] #t", FLD(LF_CLIFO, CLI_TIPOCF), @@ -794,11 +746,11 @@ void TPrintclifo_app::set_vendite(int f, int c) { // Test whether there are any Addresses. If so, prints // the header. set_row(9,""); - set_row(10,"@9gIndirizzi di Spedizione"); + set_row(10,FR("@9gIndirizzi di Spedizione")); set_row(11,"@9g%t",rigs); - set_row(12,"@9gCodice @17gRagione Sociale"); - set_row(13,"@17gIndirizzo @65gC.A.P. @72gLocalita"); - set_row(14,"@17gTelefono @60gFax @102gRiduzione IVA"); + set_row(12,FR("@9gCodice @17gRagione Sociale")); + set_row(13,FR("@17gIndirizzo @65gC.A.P. @72gLocalita")); + set_row(14,FR("@17gTelefono @60gFax @102gRiduzione IVA")); set_row(15,"@9g%t",rigs); } else for (int i=0;i<_interline;i++) @@ -899,7 +851,7 @@ bool TPrintclifo_app::set_print(int) if (_pr_type != etichette) { set_multiple_link(TRUE); - enable_link("Collegamento clienti e fornitori : ", 'b'); + enable_link(TR("Collegamento clienti e fornitori : "), 'b'); } _sort = mask.get_int(RDB_CG12_SORT); @@ -1026,6 +978,6 @@ bool TPrintclifo_app::user_destroy() int cg1200(int argc, char* argv[]) { TPrintclifo_app app; - app.run(argc, argv, "Stampa Clienti/Fornitori"); + app.run(argc, argv, TR("Stampa Clienti/Fornitori")); return 0; } diff --git a/cg/cg1300.cpp b/cg/cg1300.cpp index 3c691d066..f29ae03c4 100755 --- a/cg/cg1300.cpp +++ b/cg/cg1300.cpp @@ -61,7 +61,7 @@ void TAgg_attiv::main_loop() while (msk.run() == K_ENTER) { elabora_mov(); - message_box("Aggiornamento completato"); + message_box(TR("Aggiornamento completato")); } } @@ -78,7 +78,7 @@ void TAgg_attiv::elabora_mov() cursor = 0L; const long nitems = cursor.items(); - TProgind p(nitems ? nitems : 1, "Aggiornamento in corso..." , TRUE, TRUE, 70); + TProgind p(nitems ? nitems : 1, TR("Aggiornamento in corso...") , TRUE, TRUE, 70); for (; cursor.pos() < cursor.items(); ++cursor) { @@ -116,43 +116,43 @@ int cg1300(int argc, char* argv[]) case 'A': { TAgg_attiv a; - a.run(argc, argv, "Aggiornamento tipo attivita' su movimenti iva"); + a.run(argc, argv, TR("Aggiornamento tipo attivita' su movimenti iva")); } break; case 'C': { TAgg_codatt a; - a.run(argc, argv,"Aggiornamento codice attivita'"); + a.run(argc, argv,TR("Aggiornamento codice attivita'")); } break; case 'D': { TAgg_datacomp a; - a.run(argc, argv,"Aggiornamento data competenza"); + a.run(argc, argv,TR("Aggiornamento data competenza")); } break; case 'E': { TAgg_codes a; - a.run(argc, argv,"Aggiornamento codice esercizio"); + a.run(argc, argv,TR("Aggiornamento codice esercizio")); } break; case 'I': { TAgg_opintra a; - a.run(argc, argv, "Aggiornamento flag op. intracomunitarie"); + a.run(argc, argv, TR("Aggiornamento flag op. intracomunitarie")); } break; case 'P': { TAgg_nprot a; - a.run(argc, argv,"Rinumerazione numero di protocollo"); + a.run(argc, argv,TR("Rinumerazione numero di protocollo")); } break; case 'T': { TAgg_tconto a; - a.run(argc, argv, "Aggiornamento tipo conto"); // cg1302 + a.run(argc, argv, TR("Aggiornamento tipo conto")); // cg1302 } break; case 'Z': diff --git a/cg/cg1301.cpp b/cg/cg1301.cpp index ca25996db..2f6eb8230 100755 --- a/cg/cg1301.cpp +++ b/cg/cg1301.cpp @@ -30,7 +30,7 @@ bool TAgg_opintra::menu(MENU_TAG m) while (msk.run() == K_ENTER) { look_mov(); - message_box("Aggiornamento completato"); + message_box(TR("Aggiornamento completato")); //return TRUE; } return FALSE; @@ -51,7 +51,7 @@ void TAgg_opintra::look_mov() cursor = 0L; const long nitems = cursor.items(); - TProgind p(nitems ? nitems : 1, "Aggiornamento in corso..." , TRUE, TRUE, 70); + TProgind p(nitems ? nitems : 1, TR("Aggiornamento in corso...") , TRUE, TRUE, 70); for (; cursor.pos() < cursor.items(); ++cursor) { @@ -60,7 +60,6 @@ void TAgg_opintra::look_mov() if (reg.empty()) continue; const TDate& datareg = mov.get_date(MOV_DATAREG); - // if (datareg < "01-01-93") continue; if (datareg.year() < 1993) continue; // Meglio cosi' const TString16 codcaus(mov.get(MOV_CODCAUS)); diff --git a/cg/cg1302.cpp b/cg/cg1302.cpp index 828562b75..b83e2ca5f 100755 --- a/cg/cg1302.cpp +++ b/cg/cg1302.cpp @@ -14,21 +14,6 @@ const int TAgg_tconto::look_reg (const char* cod, int anno) { -/* - TTable tab_reg("REG"); - TString codtab; - codtab.format("%4d%-3s", anno, cod); - int tipo_reg; - - tab_reg.zero(); - tab_reg.put("CODTAB", codtab); - if (tab_reg.read() == NOERR) - tipo_reg = tab_reg.get_int("I0"); - else - tipo_reg = 0; - - return tipo_reg; -*/ TString16 codtab; codtab.format("%4d%-3s", anno, cod); int tipo_reg = cache().get("REG", codtab).get_int("I0"); @@ -78,7 +63,7 @@ bool TAgg_tconto::set_print(int) void TAgg_tconto::postclose_print() { - message_box("Aggiornamento tipo conto completato:\nE' necessario ricalcolare la liquidazione."); + message_box(TR("Aggiornamento tipo conto completato:\nE' necessario ricalcolare la liquidazione.")); } bool TAgg_tconto::preprocess_page(int file,int counter) @@ -112,7 +97,7 @@ bool TAgg_tconto::preprocess_page(int file,int counter) { if (tc.sospeso()) { - set_row(1, "@4g%7ld@23g%3d@31g%3d@37g%3d@45g%6ld ** Conto sospeso **", + set_row(1, FR("@4g%7ld@23g%3d@31g%3d@37g%3d@45g%6ld ** Conto sospeso **"), numreg, nrigimp, gruppo, conto, sottoconto); return TRUE; } @@ -129,7 +114,7 @@ bool TAgg_tconto::preprocess_page(int file,int counter) } else { - set_row(1, "@4g%7ld@23g%3d@31g%3d@37g%3d@45g%6ld ** Conto inesistente **", + set_row(1, FR("@4g%7ld@23g%3d@31g%3d@37g%3d@45g%6ld ** Conto inesistente **"), numreg, nrigimp, gruppo, conto, sottoconto); return TRUE; } @@ -152,7 +137,7 @@ void TAgg_tconto::setta_intestazione() reset_header(); - sep << "Ditta " << get_firm(); + sep << TR("Ditta ") << get_firm(); sep << " " << ragsoc; sep.left_just(132); @@ -160,14 +145,14 @@ void TAgg_tconto::setta_intestazione() set_header (soh++, (const char*) sep); sep = ""; - sep << "Data @> Pag. @#"; + sep << FR("Data @> Pag. @#"); sep.right_just(127); - sep.overwrite ("AGGIORNAMENTO TIPO CONTO SU MOVIMENTI IVA - Lista errori"); + sep.overwrite (TR("AGGIORNAMENTO TIPO CONTO SU MOVIMENTI IVA - Lista errori")); set_header (soh++, (const char*)sep); sep.fill('-'); set_header (soh++, (const char *) sep); - set_header (soh++, "Numero Registrazione Riga Gruppo Conto Sottoconto"); + set_header (soh++, TR("Numero Registrazione Riga Gruppo Conto Sottoconto")); set_header (soh++, (const char *) sep); set_header (soh, ""); } diff --git a/cg/cg1303.cpp b/cg/cg1303.cpp index 6b4ee0953..72d155957 100755 --- a/cg/cg1303.cpp +++ b/cg/cg1303.cpp @@ -28,12 +28,6 @@ void TAgg_nprot::main_loop() { TMask msk("cg1300b"); -/* - TConfig conf(CONFIG_DITTA); - int annoiva = conf.get_int("AnLiIv"); - msk.set(F_ANNO, annoiva); -*/ - while (msk.run() == K_ENTER) { _anno = msk.get_int(F_ANNO); @@ -51,7 +45,7 @@ bool TAgg_nprot::rinumera_prot(char mode, long last_prot) TString16 s; s.format("%04d%s", _anno, (const char*)_reg); reg.put("CODTAB", s); if (reg.read() != NOERR) - return error_box("Impossibile leggere il registro %s del %d", + return error_box(FR("Impossibile leggere il registro %s del %d"), (const char*)_reg, _anno); TRelation rel (LF_MOV); @@ -65,7 +59,7 @@ bool TAgg_nprot::rinumera_prot(char mode, long last_prot) const long nitems = cursor.items(); if (nitems == 0) - return warning_box("Non ci sono movimenti da rinumerare"); + return warning_box(TR("Non ci sono movimenti da rinumerare")); TConfig cnf(CONFIG_DITTA,"cg"); const bool sc_enabled = cnf.get_bool("GesSal"); @@ -73,7 +67,7 @@ bool TAgg_nprot::rinumera_prot(char mode, long last_prot) cursor.freeze(); cursor = 0L; - TProgind p(nitems, "Elaborazione in corso..." , FALSE, TRUE); + TProgind p(nitems, TR("Elaborazione in corso...") , FALSE, TRUE); long protiva, uprotiva; @@ -111,7 +105,7 @@ bool TAgg_nprot::rinumera_prot(char mode, long last_prot) if (last_prot > 0 && mode == 'N') { if (protiva != last_prot && uprotiva != last_prot) //sono alla fine del file - return error_box("Non esiste la registrazione con protocollo %ld:\nrinumerazione non avvenuta", last_prot); + return error_box(TR("Non esiste la registrazione con protocollo %ld:\nrinumerazione non avvenuta"), last_prot); ++cursor; } } @@ -149,6 +143,6 @@ bool TAgg_nprot::rinumera_prot(char mode, long last_prot) reg.put("I5", nprot + dprot); reg.rewrite(); - return message_box("Rinumerazione numero protocollo completata"); + return message_box(TR("Rinumerazione numero protocollo completata")); } diff --git a/cg/cg1304.cpp b/cg/cg1304.cpp index 762e90b37..ce693c11f 100755 --- a/cg/cg1304.cpp +++ b/cg/cg1304.cpp @@ -34,7 +34,7 @@ bool TAgg_codatt::menu(MENU_TAG m) while (msk.run() == K_ENTER) { - pri = new TProgind(2,"Aggiornamento in corso...",FALSE,TRUE,50); + pri = new TProgind(2,TR("Aggiornamento in corso..."),FALSE,TRUE,50); _pass = msk.get_bool(F_PASS); if (_pass) { @@ -62,7 +62,7 @@ bool TAgg_codatt::menu(MENU_TAG m) //msk.reset(F_DA); //msk.reset(F_A); delete pri; - message_box("Aggiornamento codice attivita' completato"); + message_box(TR("Aggiornamento codice attivita' completato")); } return FALSE; } @@ -128,11 +128,6 @@ void TAgg_codatt::cancella_rec() continue; pla.remove(); } - /*** - TTable rmb("RMB"); - for (rmb.first(); !rmb.eof(); rmb.next()) - rmb.remove(); - ***/ } void TAgg_codatt::aggiorna_att(const char* nome) diff --git a/cg/cg1305.cpp b/cg/cg1305.cpp index a966b776e..9827ec3a2 100755 --- a/cg/cg1305.cpp +++ b/cg/cg1305.cpp @@ -47,7 +47,7 @@ void TAgg_codes::calcola_codes() long nrecs = (long) mov.eod(); int err = NOERR; - TProgind p(nrecs, "Aggiornamento in corso...", TRUE, TRUE, 100); + TProgind p(nrecs, TR("Aggiornamento in corso..."), TRUE, TRUE, 100); TRecord_array righe(LF_RMOV,RMV_NUMRIG); TRecord_array righeiva(LF_RMOVIVA,RMI_NUMRIG); TRectype riga(LF_RMOV); @@ -83,8 +83,7 @@ void TAgg_codes::calcola_codes() } } if (err != NOERR) - warning_box("Aggiornamento codice esercizio interrotta. Rilevato errore %d in riscrittura",err); + warning_box(FR("Aggiornamento codice esercizio interrotta. Rilevato errore %d in riscrittura"),err); else - message_box("Aggiornamento codice esercizio completata. Modificati %ld movimenti.\n" - "E' necessario procedere col ricalcolo saldi", modified_recs); + message_box(FR("Aggiornamento codice esercizio completata. Modificati %ld movimenti.\nE' necessario procedere col ricalcolo saldi"), modified_recs); } diff --git a/cg/cg1306.cpp b/cg/cg1306.cpp index 161b08377..a3fc6af75 100755 --- a/cg/cg1306.cpp +++ b/cg/cg1306.cpp @@ -34,7 +34,7 @@ void TAgg_datacomp::aggiorna_datacomp() TDate datacomp; TDate datareg; int err = NOERR; - TProgind p(nrecs, "Aggiornamento in corso...", TRUE, TRUE, 100); + TProgind p(nrecs, TR("Aggiornamento in corso..."), TRUE, TRUE, 100); for (mov.first(); !mov.eof() && err == NOERR; mov.next()) { @@ -50,7 +50,7 @@ void TAgg_datacomp::aggiorna_datacomp() } if (err != NOERR) - warning_box("Aggiornamento codice esercizio interrotta. Rilevato errore %d in riscrittura",err); + warning_box(FR("Aggiornamento codice esercizio interrotta. Rilevato errore %d in riscrittura"),err); else - message_box("Aggiornamento data competenza completata. Modificati %ld movimenti.",modified_recs); + message_box(FR("Aggiornamento data competenza completata. Modificati %ld movimenti."),modified_recs); } diff --git a/cg/cg1307.cpp b/cg/cg1307.cpp index b1ffe1d83..904306eb3 100755 --- a/cg/cg1307.cpp +++ b/cg/cg1307.cpp @@ -24,7 +24,7 @@ for (int _e##isamfile = isamfile.first(); \ #endif -const char* const APPNAME = "Righe prima nota errate"; +const char* const APPNAME = TR("Righe prima nota errate"); class TElimina_zoppi : public TSkeleton_application { @@ -44,8 +44,6 @@ protected: static bool select_handler(TMask_field& f, KEY k); protected: - void open_files(int logicnum, ...); - TLocalisamfile& file(int num); const char* decode(int num, const char* key, const char* field); virtual void main_loop(); }; @@ -57,10 +55,10 @@ bool TElimina_zoppi::firm_handler(TMask_field& f, KEY k) bool ok = TRUE; if (k == K_F9) { - TArray_sheet sheet(-1, -1, 70, 20, "Scelta ditta", "Codice|Ragione Sociale@50"); + TArray_sheet sheet(-1, -1, 70, 20, TR("Scelta ditta"), HR("Codice|Ragione Sociale@50")); TToken_string row; - - TLocalisamfile& ditte = app().file(LF_NDITTE); + TLocalisamfile ditte(LF_NDITTE); + FOR_EACH_FILE_RECORD(ditte) { const long cod = ditte.get_long(NDT_CODDITTA); @@ -88,35 +86,12 @@ bool TElimina_zoppi::firm_handler(TMask_field& f, KEY k) if (ok) prefix().set_codditta(cod); else - f.error_box("La ditta %05ld non e' attivata per la contabilita'", cod); + f.error_box(FR("La ditta %05ld non e' attivata per la contabilita'"), cod); } return ok; } -void TElimina_zoppi::open_files(int logicnum, ...) -{ - va_list marker; - va_start(marker, logicnum); - while (logicnum > 0) - { - CHECKD(_files.objptr(logicnum) == NULL, "File gia' aperto: ", logicnum); - _files.add(new TLocalisamfile(logicnum), logicnum); - logicnum = va_arg(marker, int); - } -} - -TLocalisamfile& TElimina_zoppi::file(int num) -{ - TLocalisamfile* isam = (TLocalisamfile*)_files.objptr(num); - if (isam == NULL) - { - open_files(num, 0); - isam = (TLocalisamfile*)_files.objptr(num); - } - return *isam; -} - const char* TElimina_zoppi::decode(int num, const char* key, const char* field) { TDecoder* dec = (TDecoder*)_decoders.objptr(num); @@ -131,16 +106,16 @@ const char* TElimina_zoppi::decode(int num, const char* key, const char* field) bool TElimina_zoppi::test_row_file(int lf_rmov, TString_array& arr) { bool ok = TRUE; - TLocalisamfile& mov = app().file(LF_MOV); - TLocalisamfile& row = app().file(lf_rmov); + TLocalisamfile mov(LF_MOV); + TLocalisamfile row(lf_rmov); TString msg; - msg << "Controllo righe "; + msg << TR("Controllo righe "); switch (lf_rmov) { - case LF_RMOV : msg << "contabili"; break; - case LF_RMOVIVA: msg << "iva"; break; - case LF_PARTITE: msg << "saldaconto"; break; + case LF_RMOV : msg << TR("contabili"); break; + case LF_RMOVIVA: msg << TR("iva"); break; + case LF_PARTITE: msg << TR("saldaconto"); break; default: CHECKD(0, "Invalid row file %d", lf_rmov); break; } msg << ": 0"; @@ -258,15 +233,15 @@ bool TElimina_zoppi::test_row_file(int lf_rmov, TString_array& arr) bool TElimina_zoppi::test_scrow_file(int lf_pagsca, TString_array& arr) { bool ok = TRUE; - TLocalisamfile& pagsca = app().file(lf_pagsca); + TLocalisamfile pagsca(lf_pagsca); long found = 0; TString msg; - msg << "Controllo righe "; + msg << TR("Controllo righe "); switch (lf_pagsca) { - case LF_SCADENZE: msg << "scadenze"; break; - case LF_PAGSCA : msg << "pagamento"; break; + case LF_SCADENZE: msg << TR("scadenze"); break; + case LF_PAGSCA : msg << TR("pagamento"); break; default: CHECKD(0, "Invalid row file %d", lf_pagsca); break; } msg << ": 0"; @@ -307,14 +282,14 @@ bool TElimina_zoppi::test_scrow_file(int lf_pagsca, TString_array& arr) riga << lf_pagsca; riga.add(pagsca.get(SCAD_ANNO)); - riga.add("Partita "); riga << pagsca.get(SCAD_NUMPART); + riga.add(TR("Partita ")); riga << pagsca.get(SCAD_NUMPART); riga.add(pagsca.get(SCAD_GRUPPO)); riga.add(pagsca.get(SCAD_CONTO)); riga.add(pagsca.get(SCAD_SOTTOCONTO)); if (lf_pagsca == LF_SCADENZE) - riga.add("Riga scadenze inconsistente"); + riga.add(TR("Riga scadenze inconsistente")); else - riga.add("Riga pagamenti inconsistente"); + riga.add(TR("Riga pagamenti inconsistente")); arr.add(riga); } } @@ -325,12 +300,12 @@ bool TElimina_zoppi::test_scrow_file(int lf_pagsca, TString_array& arr) bool TElimina_zoppi::test_head_file(TString_array& arr) { bool ok = TRUE; - TLocalisamfile& mov = app().file(LF_MOV); - TLocalisamfile& rmov = app().file(LF_RMOV); - TLocalisamfile& rmoviva = app().file(LF_RMOVIVA); + TLocalisamfile mov(LF_MOV); + TLocalisamfile rmov(LF_RMOV); + TLocalisamfile rmoviva(LF_RMOVIVA); TString msg; - msg << "Controllo testate di prima nota: 0"; + msg << TR("Controllo testate di prima nota: 0"); msg.center_just(50); TProgind pi(mov.items(), msg, TRUE, TRUE, 50); @@ -451,7 +426,7 @@ int TElimina_zoppi::kill_game(long numreg, int numrig) int TElimina_zoppi::kill_pagsca(long recno, int lfile) { CHECK(lfile == LF_SCADENZE || lfile == LF_PAGSCA, "Invalid file"); - TLocalisamfile& pagsca = app().file(lfile); + TLocalisamfile pagsca(lfile); int err = pagsca.readat(recno); if (err == NOERR) err = pagsca.remove(); @@ -472,7 +447,7 @@ int TElimina_zoppi::kill_row(long numreg, char tipor, int numrig) default : break; } - TLocalisamfile& rmov= app().file(lf); + TLocalisamfile rmov(lf); rmov.put(RMV_NUMREG, numreg); if (lf != LF_MOV) rmov.put(RMV_NUMRIG, numrig); @@ -487,7 +462,7 @@ bool TElimina_zoppi::select_handler(TMask_field& f, KEY k) bool ok = TRUE; if (k == K_SPACE) { - TArray_sheet sheet(-1, -1, 76, 20, APPNAME, "@1|Codice@6|Riga@5|Anno@R|Importo@20R|Grp@R|Cnt@R|Sottoc@R|Descrizione@50"); + TArray_sheet sheet(-1, -1, 76, 20, APPNAME, HR("@1|Codice@6|Riga@5|Anno@R|Importo@20R|Grp@R|Cnt@R|Sottoc@R|Descrizione@50")); TString_array& arr = sheet.rows_array(); ok = test_row_file(LF_RMOV, arr); if (ok) @@ -506,9 +481,9 @@ bool TElimina_zoppi::select_handler(TMask_field& f, KEY k) { const long total = sheet.checked(); if (total > 0 && - yesno_box("Confermare l'eliminazione di %ld righe.", total)) + yesno_box(FR("Confermare l'eliminazione di %ld righe."), total)) { - TProgind pi(total, "Eliminazione righe...", TRUE, TRUE); + TProgind pi(total, TR("Eliminazione righe..."), TRUE, TRUE); FOR_EACH_ARRAY_ROW(arr, i, riga) { if (sheet.checked(i)) @@ -523,8 +498,7 @@ bool TElimina_zoppi::select_handler(TMask_field& f, KEY k) kill_row(riga->get_long(1), tipor, numrig); } } - message_box("Si consiglia di eseguire il ricalcolo\n" - "dei saldi dal menu di prima nota."); + message_box(TR("Si consiglia di eseguire il ricalcolo\ndei saldi dal menu di prima nota.")); } } } @@ -533,12 +507,10 @@ bool TElimina_zoppi::select_handler(TMask_field& f, KEY k) void TElimina_zoppi::main_loop() { - open_files(LF_CLIFO, LF_NDITTE, LF_PCON, 0); - open_files(LF_MOV, LF_RMOV, LF_RMOVIVA, 0); - open_files(LF_PARTITE, LF_SCADENZE, LF_PAGSCA, 0); + open_files(LF_CLIFO, LF_NDITTE, LF_PCON, LF_MOV, LF_RMOV, LF_RMOVIVA, LF_PARTITE, LF_SCADENZE, LF_PAGSCA, 0); TMask m(APPNAME, 1, 30, 5); - m.add_number(DLG_USER, 0, "Codice ditta ", 1, 1, 5, "BUF"); + m.add_number(DLG_USER, 0, TR("Codice ditta "), 1, 1, 5, "BUF"); m.add_button(DLG_SELECT, 0, "", -12, -1, 10, 2); m.add_button(DLG_QUIT, 0, "", -22, -1, 10, 2); m.set_handler(DLG_USER, firm_handler); diff --git a/cg/cg1308.cpp b/cg/cg1308.cpp index a00614275..0d4e6dcb4 100755 --- a/cg/cg1308.cpp +++ b/cg/cg1308.cpp @@ -28,7 +28,7 @@ bool TImposta_meseliq::prot_handler(TMask_field& f, KEY k) const long da = m.get_long(F_DA); const long a = m.get_long(F_A); if (a < da) - return f.error_box("L'intervallo dei numeri protocollo specificati non e' valido."); + return f.error_box(TR("L'intervallo dei numeri protocollo specificati non e' valido.")); } return TRUE; } @@ -61,7 +61,7 @@ void TImposta_meseliq::main_loop() if (items == 0) continue; - TProgind* pi = new TProgind(c.items(), "Aggiornamento mese liquidazione in corso...", FALSE, TRUE, 50); + TProgind* pi = new TProgind(c.items(), TR("Aggiornamento mese liquidazione in corso..."), FALSE, TRUE, 50); for (c = 0L; c.pos() < items; c+=1L) //scorre i movimenti e li aggiorna { if (c.pos() & 0x7F) @@ -70,13 +70,13 @@ void TImposta_meseliq::main_loop() fl.rewrite(); } delete pi; - warning_box("Aggiornati %ld records.",c.items()); + warning_box(FR("Aggiornati %ld records."),c.items()); } } int setta_meseliq(int argc, char* argv[]) { TImposta_meseliq a; - a.run(argc, argv, "Impostazione mese liq."); + a.run(argc, argv, TR("Impostazione mese liq.")); return 0; } diff --git a/cg/cg1400.cpp b/cg/cg1400.cpp index 4da84fa69..c926f5314 100755 --- a/cg/cg1400.cpp +++ b/cg/cg1400.cpp @@ -53,8 +53,8 @@ bool TStampa_deleghe_IVA::create() _banche = new TTable("%BAN"); - _ditte = new TArray_sheet(3, 3, -3, -3, "Selezione Deleghe da stampare", - "@1|Cod.@5|Ragione Sociale@30|Importo@15R|Interessi@15R|ABI@5|CAB@5|Concessione|Tit. Conto Fis."); + _ditte = new TArray_sheet(3, 3, -3, -3, TR("Selezione Deleghe da stampare"), + HR("@1|Cod.@5|Ragione Sociale@30|Importo@15R|Interessi@15R|ABI@5|CAB@5|Concessione|Tit. Conto Fis.")); _azienda = "" ; _dipendenza = "" ; @@ -165,7 +165,7 @@ int TStampa_deleghe_IVA::select() } else { - warning_box("Nessuna ditta ha deleghe del tipo specificato"); + warning_box(TR("Nessuna ditta ha deleghe del tipo specificato")); res = 2; } @@ -183,15 +183,13 @@ bool TStampa_deleghe_IVA::menu(MENU_TAG) void TStampa_deleghe_IVA::print() { - bool ok = yesno_box("Inserire il modulo prefincato nella stampante " - "e confermare la stampa delle deleghe"); + bool ok = yesno_box(TR("Inserire il modulo prefincato nella stampante e confermare la stampa delle deleghe")); if (ok) { print_deleghe(); if (_stampa_distinte) { - ok = yesno_box("Inserire il modulo in carta bianca nella stampante " - "e confermare la stampa della distinta"); + ok = yesno_box(TR("Inserire il modulo in carta bianca nella stampante e confermare la stampa della distinta")); if (ok) print_distinta(); } } @@ -218,30 +216,30 @@ void TStampa_deleghe_IVA::print_distinta() const bool contofis = _profilo.right(2) == "CF"; if (atol(_azienda)) row.put(_banche->get("S0"), 0); - TString hdr("@bDISTINTA DELEGHE DI VERSAMENTO"); - if (contofis) hdr << " - CONTO FISCALE"; + TString hdr(FR("@bDISTINTA DELEGHE DI VERSAMENTO")); + if (contofis) hdr << TR(" - CONTO FISCALE"); row.put(hdr, contofis ? TAB_SEDE - 8: TAB_SEDE); - row.put("Data @>", 106); - row.put("Pag. @#", 124); + row.put(FR("Data @>"), 106); + row.put(FR("Pag. @#"), 124); printer().setheaderline(0, row); row.reset(); if (atol(_dipendenza)) row.put(_banche->get("S1"), 0); - TString256 t("Dichiarazione "); + TString256 t(TR("Dichiarazione ")); switch (_tipo) { case 2: - t << "annuale :"; break; + t << TR("annuale :"); break; case 3: - t << "articolo 74 : " << itom(_mese); break; + t << TR("articolo 74 : ") << itom(_mese); break; case 4: - t << "cessazione attivita' : " << itom(_mese); break; + t << TR("cessazione attivita' : ") << itom(_mese); break; case 5: - t << "integrativa : " << itom(_mese); break; + t << TR("integrativa : ") << itom(_mese); break; default: - t = "Periodo: " ; t << itom(_mese); break; + t = TR("Periodo: ") ; t << itom(_mese); break; } t << ' ' << _anno; row.put(t, TAB_SEDE); @@ -254,12 +252,12 @@ void TStampa_deleghe_IVA::print_distinta() printer().setheaderline(4, row); row.reset(); - row.put("Ditta", TAB_DITTA); - row.put("Sede" , TAB_SEDE); - row.put("Importo", TAB_IMPORTO+8); + row.put(TR("Ditta"), TAB_DITTA); + row.put(TR("Sede") , TAB_SEDE); + row.put(TR("Importo"), TAB_IMPORTO+8); if (contofis) - row.put("Conto fiscale", TAB_NOTE); // Colonna per il conto fiscale, alla posizione delle note - row.put("Note", contofis ? TAB_NOTE + 22 : TAB_NOTE); + row.put(TR("Conto fiscale"), TAB_NOTE); // Colonna per il conto fiscale, alla posizione delle note + row.put(TR("Note"), contofis ? TAB_NOTE + 22 : TAB_NOTE); printer().setheaderline(3, row); real totale; @@ -305,7 +303,7 @@ void TStampa_deleghe_IVA::print_distinta() row.reset(); printer().print(row); - row.put("@bTotale versamenti :", TAB_SEDE); + row.put(FR("@bTotale versamenti :"), TAB_SEDE); row.put(totale.string("###.###.###.###"), TAB_IMPORTO); printer().print(row); @@ -448,6 +446,6 @@ bool TStampa_deleghe_IVA::print_deleghe() int cg1400(int argc, char* argv[]) { TStampa_deleghe_IVA a; - a.run(argc, argv, "Stampa Versamenti"); + a.run(argc, argv, TR("Stampa Versamenti")); return 0; } diff --git a/cg/cg2102.cpp b/cg/cg2102.cpp index 1a03b37d6..ca60a4963 100755 --- a/cg/cg2102.cpp +++ b/cg/cg2102.cpp @@ -1915,6 +1915,7 @@ bool TPrimanota_application::num_handler(TMask_field& f, KEY key) const TRectype& mov = cache().get(LF_MOV, f.get()); if (!mov.empty()) + { bool ok = TRUE; @@ -3006,4 +3007,3 @@ bool TPrimanota_application::solaiva_handler(TMask_field& f, KEY key) } return TRUE; } - diff --git a/cg/cg4100.cpp b/cg/cg4100.cpp index b372a45f8..61305aaad 100755 --- a/cg/cg4100.cpp +++ b/cg/cg4100.cpp @@ -84,7 +84,6 @@ void CG4100_App::main_loop() _msk = new TMask(_optype == 'S' ? "cg4100b" : "cg4100a"); - if (_optype == 'S') sort_sal(); else diff --git a/cg/cglib01.cpp b/cg/cglib01.cpp index 403a8ad44..f6ae079d6 100755 --- a/cg/cglib01.cpp +++ b/cg/cglib01.cpp @@ -1,12 +1,14 @@ // Esercizi contabili e registri IVA #include +#include #include #include #include #include #include #include +#include #include #include @@ -169,15 +171,15 @@ const char* iva2name(TipoIVA iva) switch(iva) { case nessuna_iva: - i = "Nessuna IVA"; break; + i = TR("Nessuna IVA"); break; case iva_acquisti: - i = "IVA Acquisti"; break; + i = TR("IVA Acquisti"); break; case iva_vendite: - i = "IVA Vendite"; break; + i = TR("IVA Vendite"); break; case iva_generica: - i = "IVA Generica"; break; + i = TR("IVA Generica"); break; default: - i = "IVA ERRATA!"; break; + i = TR("IVA ERRATA!"); break; } return i; } @@ -202,21 +204,6 @@ bool TRegistro::read(const char* cod, int year) if (cod == NULL) cod = ""; -/* int err = ~NOERR; - - TTable reg("REG"); - reg.setkey(1); - if (cod && *cod > ' ') - { - TString16 chiave; chiave.format("%04d%s", year, cod); - reg.put("CODTAB", chiave); - err = reg.read(); - } - _rec = reg.curr(); - - if (err != NOERR) - _rec.zero(); -*/ TString16 chiave; chiave.format("%04d%s", year, cod); _rec = cache().get("REG", chiave); read_att(); @@ -285,7 +272,7 @@ TipoIVA TRegistro::iva() const i = nessuna_iva; break; default: - error_box("Il registro '%s' non e' un registro IVA o contabile: tipo %d", + error_box(FR("Il registro '%s' non e' un registro IVA o contabile: tipo %d"), (const char*)name(), i); i = nessuna_iva; break; @@ -297,17 +284,8 @@ bool TRegistro::read_att() { if (!_att.empty()) return TRUE; + -/* - TLocalisamfile attiv(LF_ATTIV); - attiv.setkey(1); - attiv.put("CODDITTA", prefix().get_codditta()); - attiv.put("CODATT", attivita()); - const int err = attiv.read(); - _att = attiv.curr(); - if (err != NOERR) - _att.zero(); -*/ TString16 chiave; chiave << prefix().get_codditta() << '|' << attivita(); @@ -319,12 +297,6 @@ bool TRegistro::read_att() _prorata.destroy(); -/* - TTable pla("%PLA"); - pla.put("CODTAB", chiave); - if (pla.read() == NOERR) - { -*/ const TRectype & pla = cache().get("%PLA", chiave); if (!pla.empty()) @@ -380,17 +352,11 @@ real TRegistro::prorata(int annodoc) { pr = read_prorata(annopro); if (pr == NULL && annopro != annoiva) - { -// warning_box("Non esistono i dati relativi al prorata per il %d:\n" -// "verra' considerato l'anno %d", annopro, annoiva); pr = read_prorata(annoiva); - } + if (pr == NULL) - { -// warning_box("Non esistono i dati relativi al prorata per il %d:\n" -// "verra' considerato allo 0%%", annoiva); pr = new real(ZERO); - } + _prorata.add(chiave, pr, TRUE); } @@ -573,42 +539,8 @@ real TCodiceIVA::lordo(const real & imponibile, int ndec, const char * codval) c } bool handler_data_cambio(TMask_field& f, KEY k) -{ -/* - if (k == K_TAB && f.focusdirty()) - { - CHECK(f.is_edit(), "Campo non editabile come data cambio"); - TEdit_field& e = (TEdit_field&)f; - TBrowse& b = *e.browse(); - const TRectype& rec = b.cursor()->curr(); - const TString16 codval = rec.get("CODTAB").left(3); - const TString& firmval = TCurrency::get_firm_val(); - real cambio = rec.get("S4"); - if (cambio.is_zero()) - cambio = rec.get_real("R10"); - if (codval.not_empty() && codval != firmval && cambio > ZERO) - { - const TRectype& val = cache().get("%VAL", firmval); - real base = val.get("S4"); - if (base.is_zero()) - base = val.get_real("R10"); - if (base > ZERO && base != 1.0) - { - TToken_string out_fields = b.get_output_fields(); - for (short dlg = short(out_fields.get_int(0)); dlg; dlg = short(out_fields.get_int())) - { - TMask_field& of = f.mask().field(dlg); - if (of.class_id() == CLASS_REAL_FIELD) - { - cambio /= base; - of.set(cambio.string()); - break; - } - } - } - } - } -*/ +{ + return TRUE; } @@ -646,7 +578,7 @@ const TBill& TBill::get(TToken_string& s, int from, int mode) #ifdef DBG if (strchr(" CF", _tipo) == NULL) { - error_box("Tipo conto errato: '%c'", _tipo); + error_box(FR("Tipo conto errato: '%c'"), _tipo); _tipo = ' '; } #endif @@ -930,7 +862,7 @@ const TString& TBill::descrizione() const if ((_descrizione == NULL || _descrizione->blank()) && gruppo() != 0) { if (!myself.find()) - myself.set_description("Sconosciuto"); + myself.set_description(TR("Sconosciuto")); } return _descrizione ? *_descrizione : (const TString&) EMPTY_STRING; @@ -1004,4 +936,3 @@ bool TBill::default_cdc(TString& cdc, TString& fas) const } return ok && cdc.not_empty(); } - diff --git a/cg/cglib02.cpp b/cg/cglib02.cpp index f43e2526f..eae575f2a 100755 --- a/cg/cglib02.cpp +++ b/cg/cglib02.cpp @@ -4,12 +4,13 @@ // Aggiornamento saldi // ///////////////////////////////////////////////////////////////////////////// - -#include +#include +#include #include #include #include +#include #include "cglib01.h" #include "cglib02.h" @@ -798,7 +799,7 @@ void TSaldo_agg::registra() const int err = saldi.rewrite(); if (err != NOERR) - yesnofatal_box("Errore %d nell'aggiornamento del saldo %d %d %ld", + yesnofatal_box(FR("Errore %d nell'aggiornamento del saldo %d %d %ld"), err, tcon.gruppo(), tcon.conto(), tcon.sottoconto()); } @@ -840,4 +841,3 @@ void TSaldo_agg::registra() tcon.saldo_finale() = sf; } } - diff --git a/cg/cglib04.cpp b/cg/cglib04.cpp index b586d9591..0b825bc66 100755 --- a/cg/cglib04.cpp +++ b/cg/cglib04.cpp @@ -27,6 +27,7 @@ HIDDEN TString TEMP; //ritorna falso se la causale non e' significativa /* + bool look_causale (const char* codcaus) { const TFixed_string caus(codcaus); @@ -5342,4 +5343,4 @@ int date2esc(const TDate& d, int* prevesc) if (prevesc) *prevesc = esc.pred(anno); return anno; -} +} \ No newline at end of file diff --git a/include/mask.cpp b/include/mask.cpp index 8761625f6..1bd44a88f 100755 --- a/include/mask.cpp +++ b/include/mask.cpp @@ -253,7 +253,7 @@ void TMask::add_default_tag_buttons() TToken_string tags(_pages * 6); for (int p = 1; p <= _pages; p++) { - tags.add("Pag."); + tags.add(TR("Pag.")); tags << p; } add_tag_buttons(tags); @@ -392,7 +392,7 @@ bool TMask::can_be_closed() const { bool ok = TRUE; if ((edit_mode() || insert_mode()) && dirty() && id2pos(DLG_QUIT) < 0) - ok = yesno_box("Annullare i dati inseriti?"); + ok = yesno_box(TR("Annullare i dati inseriti?")); if (ok) ((TMask*)this)->stop_run(K_FORCE_CLOSE); return FALSE; @@ -2220,8 +2220,8 @@ TTimed_box::~TTimed_box() TTimed_breakbox::TTimed_breakbox(const char * message,int seconds,int x,int y) : TTimed_box("Richiesta di interruzione",message,seconds,DLG_OK,x,y) { - add_button(DLG_CANCEL, 0, "Interrompi", -22, -1, 12, 2,"",0); - add_button(DLG_OK, 0, "Riprova", -12, -1, 12, 2,"",0); + add_button(DLG_CANCEL, 0, TR("Interrompi"), -22, -1, 12, 2,"",0); + add_button(DLG_OK, 0, TR("Riprova"), -12, -1, 12, 2,"",0); } TTimed_breakbox::~TTimed_breakbox() @@ -2238,10 +2238,10 @@ TYesnoallnone_box::TYesnoallnone_box(const char * message, int default_key) add_memo(FIRST_FIELD, 0, "", 1, 0,-1,-3); set(FIRST_FIELD, message); disable(FIRST_FIELD); - add_button(DLG_OK, 0, "Tutti", -14, -1, 8, 2,"",0); - add_button(FIRST_FIELD+1, 0, "Si", -24, -1, 8, 2,"",0).set_exit_key(K_YES); - add_button(FIRST_FIELD+2, 0, "No", -34, -1, 8, 2,"",0).set_exit_key(K_NO); - add_button(DLG_CANCEL, 0, "Nessuno", -44, -1, 8, 2,"",0); + add_button(DLG_OK, 0, TR("Tutti"), -14, -1, 8, 2,"",0); + add_button(FIRST_FIELD+1, 0, TR("Si"), -24, -1, 8, 2,"",0).set_exit_key(K_YES); + add_button(FIRST_FIELD+2, 0, TR("No"), -34, -1, 8, 2,"",0).set_exit_key(K_NO); + add_button(DLG_CANCEL, 0, TR("Nessuno"), -44, -1, 8, 2,"",0); switch (default_key) { case K_ENTER: diff --git a/include/netsock.cpp b/include/netsock.cpp index e0b69d4a6..65a32259b 100755 --- a/include/netsock.cpp +++ b/include/netsock.cpp @@ -484,50 +484,54 @@ public: bool TSocket_connection::Execute(const char* cmd) { - bool ok = GetSocket() != NULL; + skstream* calza = GetSocket(); + bool ok = calza != NULL; if (ok) { const size_t buflen = strlen(cmd)+1; - _socket->sync(); - _socket->write(cmd, buflen); - _socket->flush(); - ok = _socket->good() != 0; + calza->sync(); + calza->write(cmd, buflen); + calza->flush(); + ok = calza->good() != 0; } return ok; } bool TSocket_connection::WriteLine(const char* cmd) { - bool ok = GetSocket() != NULL; + skstream* calza = GetSocket(); + bool ok = calza != 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; + calza->sync(); + calza->write(cmd, buflen); + calza->flush(); + ok = calza->good() != 0; } return ok; } bool TSocket_connection::ReadLine(TString& str) { - bool ok = GetSocket() != NULL; + skstream* calza = GetSocket(); + bool ok = calza != NULL; if (ok) { char *buf = str.get_buffer(4096); - _socket->getline(buf, str.size(), '\n'); + calza->getline(buf, str.size(), '\n'); } return ok; } bool TSocket_connection::Read(byte* buf, size_t size) { - bool ok = GetSocket() != NULL; + skstream* calza = GetSocket(); + bool ok = calza != NULL; if (ok) { - _socket->read(buf, size); - ok = _socket->good() != 0; + calza->read(buf, size); + ok = calza->good() != 0; } return ok; } diff --git a/include/netutils.cpp b/include/netutils.cpp index 40269a5dc..6be491abb 100755 --- a/include/netutils.cpp +++ b/include/netutils.cpp @@ -179,7 +179,7 @@ bool TLanClient::RequestBool(CONNID id, const char* cmd, bool& ok) { size_t dwSize; byte* pData = GetBuffer(dwSize); - ok = *(size_t*)pData != 0; + ok = *pData != 0; ReleaseBuffer(); } return valid; diff --git a/include/utility.cpp b/include/utility.cpp index c68ae359f..81d0b3418 100755 --- a/include/utility.cpp +++ b/include/utility.cpp @@ -480,8 +480,6 @@ __int64 mcd(__int64 a, __int64 b) while (b > 0) { r = a % b; -// if (r == 0) -// break; a = b; b = r; } diff --git a/server/authoriz.cpp b/server/authoriz.cpp index 6e458fe1c..1e53feb02 100755 --- a/server/authoriz.cpp +++ b/server/authoriz.cpp @@ -2,6 +2,11 @@ #include "Dongle.h" +#ifdef WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#endif + /////////////////////////////////////////////////////////// // TUserInfo /////////////////////////////////////////////////////////// @@ -124,6 +129,7 @@ protected: wxString DescribeModule(int m) const; void InitModules(); + wxString GetModulesFilename() const; wxString Garble(unsigned short n, const wxDateTime& date) const; public: @@ -214,9 +220,18 @@ bool TAuthorizationServer::IsMagicName(wxString& strFilename) const return false; } +wxString TAuthorizationServer::GetModulesFilename() const +{ + wxString strAut = "../campo.aut"; + if (!wxFileExists(strAut)) + strAut = "../prassi.aut"; + return strAut; +} + wxString TAuthorizationServer::DescribeModule(int m) const { - wxFileInputStream aut("../campo.aut"); + const wxString strAut = GetModulesFilename(); + wxFileInputStream aut(strAut); wxString line; for (int nModule = 0; !aut.Eof(); nModule++) { @@ -243,10 +258,14 @@ void TAuthorizationServer::GenerateIndex(wxString& strFilename) TXmlItem& title = body.AddChild("h1").AddChild("center"); if (m_Dongle.Ok()) { + TXmlItem& tr = title.AddChild("table").SetAttr("width", "40%").AddChild("tr"); + + TXmlItem& td = tr.AddChild("td").SetAttr("width", "30%"); const bool hard = m_Dongle.hardware() == _dongle_hardlock; - TXmlItem& img = title.AddChild("img"); + TXmlItem& img = td.AddChild("img"); img.SetAttr("src", hard ? "hardlock.gif" : "eutron.gif"); - title << (hard ? "Hardlock EYE" : "Eutron Smartkey"); + + tr.AddChild("td").SetAttr("align", "center").AddChild("h1") << (hard ? "Hardlock EYE" : "Eutron Smartkey"); } else { @@ -264,22 +283,22 @@ void TAuthorizationServer::GenerateIndex(wxString& strFilename) TXmlItem& tr1 = body.AddChild("tr"); TXmlItem& ay = tr1.AddChild("td").AddChild("a"); - ay.SetAttr("href", "year") << "Assistance Year"; + ay.SetAttr("href", "year.htm") << "Assistance Year"; AddNumber(tr1, m_Dongle.YearAssist()); TXmlItem& tr2 = body.AddChild("tr"); TXmlItem& mu = tr2.AddChild("td").AddChild("a"); - mu.SetAttr("href", "maxusers") << "Maximum Users"; + mu.SetAttr("href", "maxusers.htm") << "Maximum Users"; AddNumber(tr2, m_Dongle.MaxUsers()); TXmlItem& tr3 = body.AddChild("tr"); TXmlItem& au = tr3.AddChild("td").AddChild("a"); - au.SetAttr("href", "Users"); au << "Active Users"; + au.SetAttr("href", "Users.htm"); au << "Active Users"; AddNumber(tr3, m_Users.GetCount()); TXmlItem& tr4 = body.AddChild("tr"); TXmlItem& am = tr4.AddChild("td").AddChild("a"); - am.SetAttr("href", "Modules"); am << "Active Modules"; + am.SetAttr("href", "Modules.htm"); am << "Active Modules"; AddNumber(tr4, m_nModules); TXmlItem& tr5 = body.AddChild("tr"); @@ -307,7 +326,8 @@ void TAuthorizationServer::GenerateModules(wxString& strFilename) th.AddChild("th").SetAttr("width", "70%") << "Description"; th.AddChild("th").SetAttr("width", "15%") << "De/Activate"; - wxFileInputStream aut("../campo.aut"); + const wxString strAut = GetModulesFilename(); + wxFileInputStream aut(strAut); wxString line; for (int nModule = 0; !aut.Eof(); nModule++) { @@ -664,7 +684,7 @@ unsigned int TAuthorizationServer::DecodePassword(const wxChar* strPassword) if (*c >= '0' && *c <= '9') { num += *c - '0'; - } + } else { if (*c >= 'A' && *c <= 'Z') @@ -672,16 +692,14 @@ unsigned int TAuthorizationServer::DecodePassword(const wxChar* strPassword) num += *c - 'A' + 10; } else - { - if (*c >= 'a' && *c <= 'z') - num += *c - 'a' + 10; - } + break; // Carattere non valido } len++; } // Per essereva valido deve essere divisibile per 883 if (len >= 5 && (num%883) == 0 && m_strLastPassword != strPassword) { + // Creo la risposta: metà di num reso divisibile per 883 num /= 2; while (num % 883 != 0) num++; @@ -697,13 +715,14 @@ void TAuthorizationServer::ProcessUserLogin(wxString cmd, wxSocketBase& sock) wxChar strUser[16]; wxChar strPassword[16]; wxChar strProgram[16]; - wxString strHost; + cmd.Replace(",", " "); cmd.Replace(")", " "); sscanf(cmd, "UserLogin(%s %s %s)", strUser, strPassword, strProgram); - unsigned long num = 0; + unsigned int num = 0; if (m_Dongle.Connected()) { + // Preliminary GUEST login if (stricmp(strUser,"******")==0 && stricmp(strProgram, "ba0100")==0) { num = 1; @@ -714,14 +733,12 @@ void TAuthorizationServer::ProcessUserLogin(wxString cmd, wxSocketBase& sock) num = 0; else { - if (strcmp(strPassword, "******") == 0) + if (strcmp(strPassword, "******") == 0) // Older 16 bit version num = 1; else - { num = DecodePassword(strPassword); - if (num > 0) - m_Users.AddConnection(sock, strUser); - } + if (num > 0) + m_Users.AddConnection(sock, strUser); } } } @@ -797,8 +814,15 @@ void TAuthorizationServer::ProcessCommand(wxString cmd, wxSocketBase& outs) } } +#define ATOMIC_SEMAPHORE "DONGLE_SERVER_ATOM" + bool TAuthorizationServer::Initialization() { +#ifdef WIN32 + // Add global atom if not already present + if (::GlobalFindAtom(ATOMIC_SEMAPHORE) == NULL) + ::GlobalAddAtom(ATOMIC_SEMAPHORE); // Same as old Frontend.exe +#endif m_Dongle.Login(); InitModules(); @@ -808,6 +832,12 @@ bool TAuthorizationServer::Initialization() bool TAuthorizationServer::Deinitialization() { m_Dongle.Logout(); +#ifdef WIN32 + // Definitely kill global atom + for (ATOM a = ::GlobalFindAtom(ATOMIC_SEMAPHORE); + a != NULL; + a = ::GlobalDeleteAtom(a)); +#endif return true; } diff --git a/server/authoriz.dsp b/server/authoriz.dsp index 958032d2d..4f132fa61 100755 --- a/server/authoriz.dsp +++ b/server/authoriz.dsp @@ -99,7 +99,8 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../include" /I "../../contrib/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" /D WXUSINGDLL=1 /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MDd /W3 /Gm- /GX /ZI /Od /I "\wx233\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" /D WXUSINGDLL=1 /FD /c +# SUBTRACT CPP /YX /Yc /Yu # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" @@ -109,7 +110,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 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 wx22_9d.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /out:"DebugDLL/server.exe" /pdbtype:sept /libpath:"../../lib" /libpath:"../../contrib/lib" +# ADD LINK32 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 \wx233\lib\wxmsw233d.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /out:"../exe/servers/Authoriz.exe" /pdbtype:sept /libpath:"../../lib" /libpath:"../../contrib/lib" !ELSEIF "$(CFG)" == "Authoriz - Win32 Release DLL" @@ -187,6 +188,10 @@ SOURCE=.\html.h # End Source File # Begin Source File +SOURCE=.\mutex.h +# End Source File +# Begin Source File + SOURCE=.\skeylink.h # End Source File # Begin Source File @@ -196,33 +201,6 @@ SOURCE=.\xml.h # End Group # Begin Source File -SOURCE=.\server.rc - -!IF "$(CFG)" == "Authoriz - Win32 Release" - -# ADD BASE RSC /l 0x809 -# ADD RSC /l 0x809 /i "../../include" /i "../../contrib/include" - -!ELSEIF "$(CFG)" == "Authoriz - Win32 Debug" - -# ADD BASE RSC /l 0x809 -# ADD RSC /l 0x410 /i "c:\wx229\wx" /i /wx229/include" " - -!ELSEIF "$(CFG)" == "Authoriz - Win32 Debug DLL" - -# ADD BASE RSC /l 0x809 -# ADD RSC /l 0x809 /i "../../include" /i "../../contrib/include" - -!ELSEIF "$(CFG)" == "Authoriz - Win32 Release DLL" - -# ADD BASE RSC /l 0x809 -# ADD RSC /l 0x809 /i /wx229/include" " - -!ENDIF - -# End Source File -# Begin Source File - SOURCE=..\Lib\skeylink.obj # End Source File # Begin Source File diff --git a/server/baseserv.cpp b/server/baseserv.cpp index 000f6d72e..d4af53c6e 100755 --- a/server/baseserv.cpp +++ b/server/baseserv.cpp @@ -42,6 +42,25 @@ wxDateTime String2Date(const wxString& str) return date; } +wxSocketBase& operator<<(wxSocketBase& outf, const wxChar* str) +{ + if (str && *str) + outf.Write(str, wxStrlen(str)); + return outf; +} + +wxSocketBase& operator<<(wxSocketBase& outf, wxString str) +{ + if (!str.IsEmpty()) + outf.Write(str, str.Length()); + return outf; +} + +wxSocketBase& operator<<(wxSocketBase& outf, size_t num) +{ + return outf << wxString::Format("%u", num); +} + // -------------------------------------------------------------------------- // classes // -------------------------------------------------------------------------- @@ -110,7 +129,7 @@ wxString TBaseServerApp::GetTempFilename() strTmp = m_strTempDir; strTmp += wxString::Format("%s_%d.htm", GetAppName(), m_nTmpCounter); m_nTmpCounter++; - if (m_nTmpCounter >= 8) + if (m_nTmpCounter >= 4) m_nTmpCounter = 0; return strTmp; @@ -151,8 +170,9 @@ TXmlItem& TBaseServerApp::CreatePageBody(TXmlItem& html, wxString header) const head.AddChild("title") << header; TXmlItem& body = html.AddChild("body"); - body.SetAttr("bgcolor", "#E0E080"); - body.SetAttr("background", "back.gif"); + body.SetAttr("bgcolor", "#EFCEAD"); + if (m_bRunning) + body.SetAttr("background", "back.gif"); TXmlItem& title = body.AddChild("table"); title.SetAttr("border", "5"); title.SetAttr("width", "100%"); @@ -218,6 +238,27 @@ bool TBaseServerApp::CanProcessCommand(wxString& cmd, wxSocketBase& outs) return true; } +void TBaseServerApp::SendContent(wxFileInputStream& inf, wxSocketBase& sock) +{ + const size_t nSize = inf.GetSize(); + WriteLog(wxString::Format("Sending %u bytes", nSize)); + + const size_t BUF_TEMP_SIZE = nSize; // was 1024*16 + char* buf = new char[BUF_TEMP_SIZE]; + size_t bytes = BUF_TEMP_SIZE; + size_t nTotalWritten = 0; + while (bytes == BUF_TEMP_SIZE) + { + bytes = inf.Read(buf, bytes).LastRead(); + size_t nWritten = sock.Write(buf, bytes).LastCount(); + nTotalWritten += nWritten; + } + delete buf; + + if (nTotalWritten < nSize) + WriteLog(wxString::Format("I sent %u on %u bytes only.", nTotalWritten, nSize)); +} + void TBaseServerApp::SendFile(wxString strFilename, wxSocketBase& sock) { const bool bFound = wxFileExists(strFilename); @@ -236,12 +277,6 @@ void TBaseServerApp::SendFile(wxString strFilename, wxSocketBase& sock) strFilename = strTmp; } - wxFileInputStream inf(strFilename); - - const size_t nSize = inf.GetSize(); - - WriteLog(wxString::Format("Sending %s (%u bytes)", strFilename, nSize)); - wxString strType; wxSplitPath(strFilename, NULL, NULL, &strType); wxFileType* type = wxTheMimeTypesManager->GetFileTypeFromExtension(strType); @@ -251,48 +286,39 @@ void TBaseServerApp::SendFile(wxString strFilename, wxSocketBase& sock) strType = "text/plain"; const wxDateTime date = ::wxFileModificationTime(strFilename); - wxSocketOutputStream outs(sock); + wxFileInputStream inf(strFilename); + const size_t nSize = inf.GetSize(); + if (bFound) - { - outs << "HTTP/1.1 200 OK" << endl; - } + sock << "HTTP/1.1 200 OK\n"; else - { - outs << "HTTP/1.1 401 Not found" << endl; - } - outs << "Server: " << GetAppName() << endl; - outs << "Host: " << wxGetHostName() << endl; + sock << "HTTP/1.1 401 Not found\n"; + sock << "Server: " << GetAppName() << "\n"; + sock << "Host: " << wxGetFullHostName() << "\n"; if (bFound && m_bRunning) - { - outs << "Connection: keep-alive" << endl; - } + sock << "Connection: keep-alive\n"; else - { - outs << "Connection: close" << endl; - } - outs << "Content-Type: " << strType << endl; - outs << "Content-Length: " << wxString::Format("%u", nSize) << endl; - outs << "Date: " << date.Format("%#c") << endl; - outs << endl; + sock << "Connection: close\n"; + sock << "Content-Type: " << strType << "\n"; + sock << "Content-Length: " << nSize << "\n"; + sock << "Date: " << date.Format("%#c") << "\n"; - const size_t BUF_TEMP_SIZE = 1024*64; - char* buf = new char[BUF_TEMP_SIZE]; - size_t bytes = BUF_TEMP_SIZE; - size_t nTotal = 0; - while (bytes == BUF_TEMP_SIZE) - { - bytes = inf.Read(buf, bytes).LastRead(); - bytes = outs.Write(buf, bytes).LastWrite(); - // if (bytes == BUF_TEMP_SIZE) wxSleep(1); - sock.WaitForWrite(5); - nTotal += bytes; - } - delete buf; + wxDateTime dtFraUnPo = wxDateTime::Now(); + const wxTimeSpan minuto(0, 1, 0); // Zero ore, Un minuto, Zero secondi + dtFraUnPo += minuto; + sock << "Expires: " << dtFraUnPo.Format("%#c") << "\n"; - if (nTotal < nSize) - { - WriteLog(wxString::Format("I sent %u bytes only.", nTotal)); - } + sock << "\n"; + + SendContent(inf, sock); +} + +void TBaseServerApp::SendNotModifiedFile(wxSocketBase& sock) +{ + sock << "HTTP/1.1 304 Not Modified\n"; + sock << "Date: " << wxDateTime::Now().Format("%#c") << "\n"; + sock << "Server: " << GetAppName() << "\n"; + sock << "Connection: close\n"; } const wxChar* TBaseServerApp::GetAppName() const @@ -310,7 +336,7 @@ void TBaseServerApp::ProcessCommand(wxString cmd, wxSocketBase& outs) void TBaseServerApp::OnServerEvent(wxSocketEvent& event) { - wxString s = "OnServerEvent: "; + wxString s = "--- OnServerEvent: "; switch(event.GetSocketEvent()) { @@ -328,11 +354,11 @@ void TBaseServerApp::OnServerEvent(wxSocketEvent& event) wxSocketBase* sock = m_server->Accept(FALSE); if (sock) { - WriteLog("New client connection accepted"); + WriteLog("--- New client connection accepted"); } else { - WriteLog("Error: couldn't accept a new connection"); + WriteLog("### Error: couldn't accept a new connection"); sock->Destroy(); return; } @@ -344,61 +370,53 @@ void TBaseServerApp::OnServerEvent(wxSocketEvent& event) void TBaseServerApp::OnSocketEvent(wxSocketEvent& event) { - wxString s = "OnSocketEvent: "; - wxSocketBase *sock = event.GetSocket(); - - // First, print a message - switch(event.GetSocketEvent()) - { - case wxSOCKET_INPUT : s.Append("wxSOCKET_INPUT\n"); break; - case wxSOCKET_LOST : s.Append("wxSOCKET_LOST\n"); break; - default : s.Append("Unexpected event !\n"); break; - } - - WriteLog(s); - - // Now we process the event + wxSocketBase& sock = *event.GetSocket(); switch(event.GetSocketEvent()) { case wxSOCKET_INPUT: { - const int nOldFlags = sock->GetFlags(); // We disable input events, so that the test doesn't trigger // wxSocketEvent again. - sock->SetNotify(wxSOCKET_LOST_FLAG); - sock->SetFlags(wxSOCKET_NOWAIT); // Non aspettare troppo + sock.SetNotify(wxSOCKET_LOST_FLAG); // Read the data const size_t BUFSIZE = 2048; wxString str; - wxChar* buf = str.GetWriteBuf(BUFSIZE); - memset(buf, 0, BUFSIZE); - const size_t len = sock->Read(buf, BUFSIZE).LastCount(); - str.UngetWriteBuf(len+1); + wxChar* bufStart = str.GetWriteBuf(BUFSIZE); + memset(bufStart, 0, BUFSIZE); + wxChar* buf = bufStart; + + const size_t len = sock.Read(buf, BUFSIZE).LastCount(); + buf += len; + // Attendi la fine del comando HTTP! + if (strncmp(bufStart, "GET ", 4) == 0 || strncmp(bufStart, "POST ", 5) == 0) + { + while (strstr(bufStart, "\r\n\r\n") == NULL) + { + const size_t len = sock.Read(buf, BUFSIZE).LastCount(); + buf += len; + } + } + str.UngetWriteBuf(); WriteLog(str); - sock->SetFlags(nOldFlags); // Ripristina flags - if (CanProcessCommand(str, *sock)) - ProcessCommand(str, *sock); + if (CanProcessCommand(str, sock)) + { + const wxSocketFlags flags = sock.GetFlags(); + sock.SetFlags(wxSOCKET_WAITALL); + ProcessCommand(str, sock); + sock.SetFlags(flags); + } // Enable input events again. - sock->SetNotify(wxSOCKET_LOST_FLAG | wxSOCKET_INPUT_FLAG); + sock.SetNotify(wxSOCKET_LOST_FLAG | wxSOCKET_INPUT_FLAG); break; } case wxSOCKET_LOST: { - // Destroy() should be used instead of delete wherever possible, - // due to the fact that wxSocket uses 'delayed events' (see the - // documentation for wxPostEvent) and we don't want an event to - // arrive to the event handler (the frame, here) after the socket - // has been deleted. Also, we might be doing some other thing with - // the socket at the same time; for example, we might be in the - // middle of a test or something. Destroy() takes care of all - // this for us. - - WriteLog("Deleting socket."); - sock->Destroy(); + WriteLog("--- Deleting socket."); + sock.Destroy(); break; } default: ; @@ -474,6 +492,17 @@ wxString TBaseServerApp::GetDocumentRoot() const bool TBaseServerApp::OnInit() { + m_server = NULL; + m_log = NULL; + + m_SingleInstance = new wxSingleInstanceChecker(GetAppName()); + if (m_SingleInstance->IsAnotherRunning()) + { + delete m_SingleInstance; + m_SingleInstance = NULL; + return false; + } + // Create the address - defaults to localhost:0 initially wxIPV4address addr; addr.Service(GetDefaultPort()); @@ -501,7 +530,6 @@ bool TBaseServerApp::OnInit() m_server->Notify(TRUE); str << GetAppName() << " listening on port " << addr.Service(); - SetConfigString("Running", "1"); m_bRunning = true; } else @@ -519,18 +547,20 @@ bool TBaseServerApp::OnInit() int TBaseServerApp::OnExit() { - Deinitialization(); - if (m_server != NULL) + { + Deinitialization(); + delete m_SingleInstance; delete m_server; + } if (m_log != NULL) { - SetConfigString("Running", ""); wxString str; str << GetAppName() << " shutting down."; WriteLog(str); delete m_log; } + return wxApp::OnExit(); } @@ -584,3 +614,4 @@ int TBaseServerApp::ParseArguments(wxString args, THashTable& hashArgs) const } return hashArgs.GetCount(); } + diff --git a/server/baseserv.dsp b/server/baseserv.dsp index 77a17ab33..487ac6b1f 100755 --- a/server/baseserv.dsp +++ b/server/baseserv.dsp @@ -99,7 +99,8 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../include" /I "../../contrib/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" /D WXUSINGDLL=1 /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "\wx233\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" /D WXUSINGDLL=1 /FD /c +# SUBTRACT CPP /YX /Yc /Yu # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" @@ -109,7 +110,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 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 wx22_9d.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /out:"DebugDLL/server.exe" /pdbtype:sept /libpath:"../../lib" /libpath:"../../contrib/lib" +# ADD LINK32 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 \wx233\lib\wxmsw233d.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /out:"DebugDLL/server.exe" /pdbtype:sept /libpath:"../../lib" /libpath:"../../contrib/lib" !ELSEIF "$(CFG)" == "BaseServ - Win32 Release DLL" @@ -186,12 +187,12 @@ SOURCE=.\server.rc !ELSEIF "$(CFG)" == "BaseServ - Win32 Debug" # ADD BASE RSC /l 0x809 -# ADD RSC /l 0x410 /i "c:\wx229\wx" /i /wx229/include" " +# ADD RSC /l 0x410 /i "c:\wx233\wx" /i /wx229/include" " !ELSEIF "$(CFG)" == "BaseServ - Win32 Debug DLL" # ADD BASE RSC /l 0x809 -# ADD RSC /l 0x809 /i "../../include" /i "../../contrib/include" +# ADD RSC /l 0x809 /i "\wx233\include" !ELSEIF "$(CFG)" == "BaseServ - Win32 Release DLL" diff --git a/server/baseserv.h b/server/baseserv.h index 178ab1c77..59ee81378 100755 --- a/server/baseserv.h +++ b/server/baseserv.h @@ -1,10 +1,10 @@ #include #include +#include #include #include #include "xml.h" - ////////////////////////////////////////////////////////// // Utilities /////////////////////////////////////////////////////////// @@ -12,6 +12,10 @@ wxString Date2String(const wxDateTime& date); wxDateTime String2Date(const wxString& str); +wxSocketBase& operator<<(wxSocketBase& outf, const wxChar* str); +wxSocketBase& operator<<(wxSocketBase& outf, wxString str); +wxSocketBase& operator<<(wxSocketBase& outf, size_t num); + ////////////////////////////////////////////////////////// // THashString /////////////////////////////////////////////////////////// @@ -59,6 +63,8 @@ private: int m_nTmpCounter; protected: + wxSingleInstanceChecker* m_SingleInstance; + // Pure virtual functions! virtual const wxChar* GetAppName() const = 0; virtual void ProcessCommand(wxString cmd, wxSocketBase& outs) = 0; @@ -66,25 +72,31 @@ protected: virtual bool CanProcessCommand(wxString& cmd, wxSocketBase& outs); virtual int GetDefaultPort() const; // Retrieves Port usig GetConfigInt - virtual wxString GetLogFileName() const; // Retrieves Port usig GetConfigString - virtual wxString GetDocumentRoot() const; // Retrieves Port usig GetConfigString + virtual wxString GetDocumentRoot() const; - TXmlItem& AddLogo(TXmlItem& td) const; + virtual TXmlItem& AddLogo(TXmlItem& td) const; + + // Used by SendFile + void SendContent(wxFileInputStream& inf, wxSocketBase& sock); + void SendNotModifiedFile(wxSocketBase& sock); public: // Utilities virtual const wxChar* GetConfigName() const; virtual void SetConfigString(const wxChar* key, const wxChar* val, const wxChar* app = NULL) const; + void SetConfigInt(const wxChar* key, int val, const wxChar* app = NULL) const; virtual wxString GetConfigString(const wxChar* key, const wxChar* def = "", const wxChar* app = NULL) const; int GetConfigInt(const wxChar* key, int def = 0, const wxChar* app = NULL) const; // Uses GetConfigString bool GetConfigBool(const wxChar* key, bool def = false, const wxChar* app = NULL) const; // Uses GetConfigString + virtual wxString GetLogFileName() const; + wxString GetTempFilename(); TXmlItem& CreatePageBody(TXmlItem& html, wxString header = "") const; TXmlItem& AddLinkButton(TXmlItem& body, const wxChar* strCaption, const wxChar* strHref) const; - void SendFile(wxString strFilename, wxSocketBase& outs); - void MessageBox(const wxChar* caption, const wxChar* msg, wxSocketBase& outs); + void SendFile(wxString strFilename, wxSocketBase& sock); + void MessageBox(const wxChar* caption, const wxChar* msg, wxSocketBase& sock); wxString UnformatString(const wxString& strFormString) const; int ParseArguments(wxString args, THashTable& hashArgs) const; diff --git a/server/coffee.cpp b/server/coffee.cpp index cbc339856..4448e4030 100755 --- a/server/coffee.cpp +++ b/server/coffee.cpp @@ -23,6 +23,10 @@ bool TCoffeeServer::IsMagicName(wxString& strFilename) const wxString strName; wxSplitPath(strFilename, NULL, &strName, NULL); strName.MakeLower(); + const int q = strName.Find('?'); + if (q > 0) + strName.Truncate(q); + if (strName == "index") { strFilename = strName; @@ -32,27 +36,68 @@ bool TCoffeeServer::IsMagicName(wxString& strFilename) const { strFilename = GetLogFileName(); } + if (strName == "buy") + { + return true; + } return false; } void TCoffeeServer::GenerateFile(wxString& strFilename) { - wxString strName; + wxString strName, strArgs; wxSplitPath(strFilename, NULL, &strName, NULL); strName.MakeLower(); + const int q = strFilename.Find('?'); + if (q > 0) + strArgs = strFilename.Mid(q+1); + + const char* items[] = { "Coffee", "Cappuccino", "Chocolate", "Milk", "Tea", "Brioche", NULL }; + if (strName == "index") { TXmlItem html; - TXmlItem& body = CreatePageBody(html); + TXmlItem& body = CreatePageBody(html).AddChild("center"); + + body.AddChild("h1") << "Welcome to the virtual coffee machine"; + body.AddChild("br"); + + TXmlItem& table = body.AddChild("table"); + table.SetAttr("width", "50%").SetAttr("border", "1"); + + for (int i = 0; items[i]; i++) + { + TXmlItem& row = table.AddChild("tr"); + TXmlItem& a = row.AddChild("td").AddChild("a"); + a.SetAttr("href", wxString::Format("buy.cgi?%d", i)); + a.AddChild("img").SetAttr("src", "rbutton.gif").SetAttr("border", "0"); + row.AddChild("td") << items[i]; + } - TXmlItem& cen = body.AddChild("h1").AddChild("center"); - cen << "Just Kidding :-)"; - cen.AddChild("br"); - cen.AddChild("img").SetAttr("src", GetConfigString("Icon")); strFilename = GetTempFilename(); - body.Save(strFilename); + html.Save(strFilename); } + + if (strName == "buy") + { + TXmlItem html; + TXmlItem& body = CreatePageBody(html).AddChild("center"); + + const int nItem = atoi(strArgs); + const wxString strItemCode = wxString::Format("Item%d", nItem); + const int nSold = GetConfigInt(strItemCode)+1; + SetConfigInt(strItemCode, nSold); + + body.AddChild("h1") << wxString::Format("%d %ss sold.", nSold, items[nItem]); + body.AddChild("br"); + body.AddChild("h2") << "You'll be billed 1 Euro on your next wage :-)"; + + AddLinkButton(body, "Return to main page", "index.htm"); + strFilename = GetTempFilename(); + html.Save(strFilename); + } + if (strName == "log") { strFilename = GetLogFileName(); diff --git a/server/coffee.dsp b/server/coffee.dsp index bce4f82a1..81bd6cb09 100755 --- a/server/coffee.dsp +++ b/server/coffee.dsp @@ -8,12 +8,12 @@ CFG=Coffee - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE -!MESSAGE NMAKE /f "Coffee.mak". +!MESSAGE NMAKE /f "coffee.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE -!MESSAGE NMAKE /f "Coffee.mak" CFG="Coffee - Win32 Debug" +!MESSAGE NMAKE /f "coffee.mak" CFG="Coffee - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE @@ -99,7 +99,8 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../include" /I "../../contrib/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" /D WXUSINGDLL=1 /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "\wx233\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" /D WXUSINGDLL=1 /FD /c +# SUBTRACT CPP /YX /Yc /Yu # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" @@ -109,7 +110,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 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 wx22_9d.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /out:"DebugDLL/server.exe" /pdbtype:sept /libpath:"../../lib" /libpath:"../../contrib/lib" +# ADD LINK32 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 \wx233\lib\wxmsw233d.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /out:"..\exe\servers\Coffee.exe" /pdbtype:sept /libpath:"../../lib" /libpath:"../../contrib/lib" !ELSEIF "$(CFG)" == "Coffee - Win32 Release DLL" @@ -175,6 +176,10 @@ SOURCE=.\Coffee.h # End Source File # Begin Source File +SOURCE=.\mutex.h +# End Source File +# Begin Source File + SOURCE=.\xml.h # End Source File # End Group @@ -190,12 +195,12 @@ SOURCE=.\server.rc !ELSEIF "$(CFG)" == "Coffee - Win32 Debug" # ADD BASE RSC /l 0x809 -# ADD RSC /l 0x410 /i "c:\wx229\wx" /i /wx229/include" " +# ADD RSC /l 0x410 /i "c:\wx233\wx" /i /wx229/include" " !ELSEIF "$(CFG)" == "Coffee - Win32 Debug DLL" # ADD BASE RSC /l 0x809 -# ADD RSC /l 0x809 /i "../../include" /i "../../contrib/include" +# ADD RSC /l 0x809 /i "\wx233\include" !ELSEIF "$(CFG)" == "Coffee - Win32 Release DLL" diff --git a/server/dbserver.cpp b/server/dbserver.cpp new file mode 100755 index 000000000..a8e4f762e --- /dev/null +++ b/server/dbserver.cpp @@ -0,0 +1,614 @@ +#include "BaseServ.h" + +#include +#include + +/////////////////////////////////////////////////////////// +// TDataBase +/////////////////////////////////////////////////////////// + +class TDataBase : public wxHashTable +{ + wxDbConnectInf m_ci; + wxDb* m_db; + +public: + bool Open(const wxString& dsn, const wxString& user, + const wxString& password, const wxString& path); + bool IsOpen() const; + void Close(); + wxDb& DataBase() { return *m_db; } + + TDataBase(); + virtual ~TDataBase(); +}; + +bool TDataBase::Open(const wxString& dsn, const wxString& user, + const wxString& password, const wxString& path) +{ + Close(); + + m_ci.SetDsn(dsn); + m_ci.SetUserID(user); + m_ci.SetPassword(password); + m_ci.SetDefaultDir(path); + + if (m_ci.AllocHenv()) + { + m_db = ::wxDbGetConnection(&m_ci, false); // Forward only? + if (m_db == NULL) + m_ci.FreeHenv(); + else + { + const wxString strLog = GetServerApp().GetLogFileName(); + if (!strLog.IsEmpty()) + m_db->SetSqlLogging(sqlLogON, strLog, TRUE); + } + } + + return IsOpen(); +} + +void TDataBase::Close() +{ + if (m_db) + { + m_db->SetSqlLogging(sqlLogOFF); + ::wxDbFreeConnection(m_db); + m_db = NULL; + m_ci.FreeHenv(); + } +} + +bool TDataBase::IsOpen() const +{ + return m_db != NULL; +} + +TDataBase::TDataBase() : wxHashTable(wxKEY_STRING), m_db(NULL) +{ + m_ci.Henv = 0; + DeleteContents(true); +} + +TDataBase::~TDataBase() +{ + Close(); +} + +/////////////////////////////////////////////////////////// +// TStudy +/////////////////////////////////////////////////////////// + +class TStudy : public wxHashTable +{ + wxString m_strName, m_strUser, m_strPass, m_strPath; + +public: + TDataBase& DB(long firm); // 0 = COM + TStudy(const char* strName, const char* strUser, const char* strPass, const char* strPath); +}; + +TDataBase& TStudy::DB(long firm) +{ + TDataBase* db = (TDataBase*)Get(firm); + if (db == NULL) + { + wxString strDsn, strPath; + + if (firm > 0) + { + strDsn.sprintf("%s%ld", m_strName, firm); + strPath.sprintf("%s/%05lda", m_strPath, firm); + } + else + { + strDsn = m_strName; + strPath.sprintf("%s/com", m_strPath); + } + + db = new TDataBase; + db->Open(strDsn, m_strUser, m_strPass, strPath); + Put(firm, db); + } + return *db; +} + +TStudy::TStudy(const char* strName, const char* strUser, const char* strPass, const char* strBasePath) + : wxHashTable(wxKEY_INTEGER), m_strName(strName), m_strUser(strUser), m_strPass(strPass) +{ + m_strPath.sprintf("%s/%s", strBasePath, strName); + DeleteContents(true); +} + +/////////////////////////////////////////////////////////// +// TDataBaseServer +/////////////////////////////////////////////////////////// + +class TDataBaseServer : public TBaseServerApp +{ +protected: + virtual const wxChar* GetAppName() const; + virtual void ProcessCommand(wxString cmd, wxSocketBase& outs); + virtual bool Initialization(); + virtual bool Deinitialization(); + +protected: + void AddAsterisk(const wxString& strField, const wxString& strQuery, + TDataBase& db, wxArrayString& arr); + wxString ParseQuery(const wxString& strOriginalQuery, TDataBase& db, wxArrayString& arr); + void WriteTable(const wxString& strDsn, const wxString& strUser, + const wxString& strPass, const wxString& strOriginalQuery, + wxFileOutputStream& out); + + wxString GetSoapParam(const TXmlItem& xmlMethod, const char* strParam); + void SoapProcessQuery(const TXmlItem &xmlMethod, wxFileOutputStream& out); + void SoapProcessMethod(const TXmlItem& xmlMethod, wxFileOutputStream& out); + +public: + bool IsMagicName(wxString& strFilename) const; + + void ProcessFormQuery(const wxString& strFileName, THashTable& hashArgs); + void ProcessFormCommand(wxString cmd, wxSocketBase& outs); + void ProcessSoapCommand(wxString cmd, wxSocketBase& outs); + + void GenerateIndex(wxString& strFilename); + void GenerateSql(wxString& strFilename); + void GenerateFile(wxString& strFilename); +}; + +// Implementare almeno queste due funzioni pure virtuali + +const wxChar* TDataBaseServer::GetAppName() const +{ + return "DataBase"; +} + +bool TDataBaseServer::IsMagicName(wxString& strFilename) const +{ + wxString strName; + wxSplitPath(strFilename, NULL, &strName, NULL); + strName.MakeLower(); + const int q = strName.Find('?'); + if (q > 0) + strName.Truncate(q); + + if (strName == "index" || strName == "sql") + { + strFilename = strName; + return true; + } + if (strName == "log") + { + strFilename = GetLogFileName(); + } + + return false; +} + +void TDataBaseServer::GenerateIndex(wxString& strFilename) +{ + TXmlItem html; + TXmlItem& body = CreatePageBody(html).AddChild("center"); + + TXmlItem& table = body.AddChild("table"); + table.SetAttr("border", "1"); + table.SetAttr("width", "70%"); + + TXmlItem& tr0 = body.AddChild("tr"); + TXmlItem& aq = tr0.AddChild("td").AddChild("a"); + aq.SetAttr("href", "sql.htm"); aq << "SQL query"; + tr0.AddChild("td") << "Perform any SQL query on the selected Data Source"; + + TXmlItem& tr1 = body.AddChild("tr"); + TXmlItem& al = tr1.AddChild("td").AddChild("a"); + al.SetAttr("href", "Log"); al << "Log File"; + tr1.AddChild("td") << "Display current server log"; + + TXmlItem& tr2 = body.AddChild("tr"); + TXmlItem& as = tr2.AddChild("td").AddChild("a"); + as.SetAttr("href", "stop.cgi"); as << "Stop"; + tr2.AddChild("td") << "Stop this database server"; + + strFilename = GetTempFilename(); + html.Save(strFilename); +} + +void TDataBaseServer::GenerateSql(wxString& strFilename) +{ + TXmlItem html; + TXmlItem& body = CreatePageBody(html).AddChild("center"); + + TXmlItem& form = body.AddChild("form"); + form.SetAttr("method", "post"); + form.SetAttr("action", "Query.cgi"); + + TXmlItem& table = form.AddChild("table").SetAttr("width", "70%"); + + TXmlItem& tr0 = table.AddChild("tr"); + tr0.AddChild("td") << "Data Source Name"; + TXmlItem& dsn = tr0.AddChild("td").AddChild("input"); + dsn.SetAttr("type", "string"); dsn.SetAttr("name", "Dsn"); + dsn.SetAttr("value", GetConfigString("Dsn")); + + TXmlItem& tr1 = table.AddChild("tr"); + tr1.AddChild("td") << "User"; + TXmlItem& user = tr1.AddChild("td").AddChild("input"); + user.SetAttr("type", "string"); user.SetAttr("name", "User"); + user.SetAttr("value", GetConfigString("User")); + + TXmlItem& tr2 = table.AddChild("tr"); + tr2.AddChild("td") << "Password"; + TXmlItem& pass = tr2.AddChild("td").AddChild("input"); + pass.SetAttr("type", "password"); pass.SetAttr("name", "User"); + + form.AddChild("br"); + form.AddChild("h3") << "SQL query:"; + TXmlItem& q = form.AddChild("textarea"); + q.SetAttr("name", "Query"); + q.SetAttr("cols", "80"); q.SetAttr("rows", "10"); + + wxString query = GetConfigString("Query"); + q << query; + + form.AddChild("br"); + form.AddChild("br"); + + TXmlItem& sub = form.AddChild("input"); + sub.SetAttr("type", "submit"); + sub.SetAttr("value", "Execute"); + + AddLinkButton(body, "Return to main page", "/"); + + strFilename = GetTempFilename(); + html.Save(strFilename); +} + +void TDataBaseServer::GenerateFile(wxString& strFilename) +{ + wxString strName, strArgs; + wxSplitPath(strFilename, NULL, &strName, NULL); + strName.MakeLower(); + const int q = strFilename.Find('?'); + if (q > 0) + strArgs = strFilename.Mid(q+1); + + if (strName == "index") + GenerateIndex(strFilename); else + if (strName == "sql") + GenerateSql(strFilename); else + if (strName == "log") + strFilename = GetLogFileName(); +} + +void TDataBaseServer::AddAsterisk(const wxString& strField, const wxString& strQuery, + TDataBase& db, wxArrayString& arr) +{ + wxString strTable; + const int nDot = strField.Find(".*"); + if (nDot < 0) + { + const int nFrom = strQuery.Find("FROM "); + if (nFrom > 0) + strTable = strQuery.Mid(nFrom+5); + const int nComma = strTable.Find(','); + const int nSpace = strTable.Find(' '); + int nTrunc = strTable.Length(); + if (nComma > 0) + nTrunc = nComma; + if (nSpace > 0 && nSpace < nTrunc) + nTrunc = nSpace; + strTable.Truncate(nTrunc); + } + else + strTable = strField.Left(nDot); + strTable.Trim(false); strTable.Trim(true); + + UWORD numCols; + wxDbColInf* dci = db.DataBase().GetColumns(strTable, &numCols); + + wxString strFieldName; + for (UWORD i = 0; i < numCols; i++) + { + if (strField == "*") + strFieldName = dci[i].colName; + else + { + strFieldName = strTable; + strFieldName += "."; + strFieldName += dci[i].colName; + } + arr.Add(strFieldName); + } +} + +wxString TDataBaseServer::ParseQuery(const wxString& strOriginalQuery, TDataBase& db, wxArrayString& arr) +{ + wxString strQuery; + + const int nSelect = strOriginalQuery.Find("SELECT "); + const int nFrom = strOriginalQuery.Find("FROM "); + + if (nSelect >= 0 && nFrom > nSelect) + { + wxString strFields = strOriginalQuery.Mid(nSelect+7, nFrom-nSelect-7); + strFields.Trim(false); strFields.Trim(true); + while(!strFields.IsEmpty()) + { + const int nComma = strFields.Find(','); + wxString strField = nComma < 0 ? strFields : strFields.Mid(0, nComma); + strField.Trim(); strField.Trim(false); + if (strField.Find("*") >= 0) + AddAsterisk(strField, strOriginalQuery, db, arr); + else + arr.Add(strField); + if (nComma > 0) + strFields = strFields.Mid(nComma+1); + else + break; + } + strQuery = "SELECT "; + for (size_t i = 0; i < arr.GetCount(); i++) + { + if (i > 0) + strQuery << ","; + strQuery << arr[i]; + } + strQuery << strOriginalQuery.Mid(nFrom-1); + } + else + strQuery = strOriginalQuery; + + return strQuery; +} + +void TDataBaseServer::WriteTable(const wxString& strDsn, const wxString& strUser, + const wxString& strPass, const wxString& strOriginalQuery, + wxFileOutputStream& out) +{ + const clock_t tTotalStart = clock(); + + clock_t tQueryTime = 0; + clock_t tRetrieveTime = 0; + clock_t tTotalTime = 0; + size_t nRecords = 0; + + out << "\n"; + + const wxString strBasePath = GetConfigString("DataPath"); + TStudy s(strDsn, strUser, strPass, strBasePath); + TDataBase& d = s.DB(0); // Ditta/COM + if (d.IsOpen()) + { + wxArrayString arr; + const wxString strQuery = ParseQuery(strOriginalQuery, d, arr); + + wxDb& db = d.DataBase(); + + const clock_t tQueryStart = clock(); + db.ExecSql(strQuery); + tQueryTime = clock() - tQueryStart; + + const int nColumns = arr.GetCount(); + if (nColumns > 0) + { + out << " \n"; + for (int i = 0; i < nColumns; i++) + out << " \n"; + out << " \n"; + + const int bufsize = 33000; + wxChar* buffer = new wxChar[bufsize]; + + const clock_t tRetrieveStart = clock(); + for (nRecords = 0; db.GetNext(); nRecords++) + { + out << " \n"; + for (int c = 1; c <= nColumns; c++) + { + SDWORD cb; + if (db.GetData(c, SQL_C_CHAR, buffer, bufsize, &cb)) + { + if (strcmp(buffer, "1899-12-30") == 0) + *buffer = '\0'; + out << " \n"; + } + else + break; + } + out << " \n"; + } + delete buffer; + tRetrieveTime = clock() - tRetrieveStart; + } + } + out << "
" << arr[i] << "
" << buffer << "
\n"; + + tTotalTime = clock() - tTotalStart; + + WriteLog(wxString::Format("--- %u Records. Query:%u Retrieve:%u Total:%u", + nRecords, tQueryTime, tRetrieveTime, tTotalTime)); +} + +void TDataBaseServer::ProcessFormQuery(const wxString& strFileName, THashTable& hashArgs) +{ + const wxString strDsn = hashArgs.Get("Dsn"); + const wxString strUser = hashArgs.Get("User"); + const wxString strPass = hashArgs.Get("Password"); + const wxString strOriginalQuery = hashArgs.Get("Query"); + + SetConfigString("Dsn", strDsn); + SetConfigString("User", strUser); + + wxString strQuery = strOriginalQuery; + strQuery.Replace("\r\n", " "); + SetConfigString("Query", strQuery); + + wxFileOutputStream out(strFileName); + + out << "\n"; + out << "\n"; + + WriteTable(strDsn, strUser, strPass, strOriginalQuery, out); + + out << "\n"; + out << "\n"; +} + +void TDataBaseServer::ProcessFormCommand(wxString cmd, wxSocketBase& outs) +{ + const int stop = cmd.Find(" HTTP"); + wxString strFileName = cmd.Mid(5, stop-5).Trim(); + + wxString strName, args; + wxSplitPath(strFileName, NULL, &strName, NULL); + + const int pos = cmd.Find("\r\n\r\n"); + if (pos > 0) + args = cmd.Mid(pos+4); + + THashTable hashArgs(13); + ParseArguments(args, hashArgs); + + strFileName = GetTempFilename(); + + if (strName == "Query") + ProcessFormQuery(strFileName, hashArgs); + + SendFile(strFileName, outs); +} + +wxString TDataBaseServer::GetSoapParam(const TXmlItem &xmlMethod, const char* strParam) +{ + wxString val; + const TXmlItem* xml = xmlMethod.FindFirst(strParam); + if (xml != NULL) + val = xml->GetEnclosedText(); + return val; +} + +void TDataBaseServer::SoapProcessQuery(const TXmlItem &xmlMethod, wxFileOutputStream& out) +{ + const wxString dsn = GetSoapParam(xmlMethod, "dsn"); + const wxString usr = GetSoapParam(xmlMethod, "user"); + const wxString pwd = GetSoapParam(xmlMethod, "password"); + const wxString sql = GetSoapParam(xmlMethod, "sql"); + WriteTable(dsn, usr, pwd, sql, out); +} + +void TDataBaseServer::SoapProcessMethod(const TXmlItem &xmlMethod, wxFileOutputStream& out) +{ + wxString str = xmlMethod.GetTag(); + str << "Result"; + out << "<" << str << ">\n"; + + if (xmlMethod.GetTag() == "m:query") + SoapProcessQuery(xmlMethod, out); + + out << "\n"; +} + +void TDataBaseServer::ProcessSoapCommand(wxString cmd, wxSocketBase& sock) +{ + const wxString strFilename = GetTempFilename(); + + if (!strFilename.IsEmpty()) + { + wxFileOutputStream outf(strFilename); + outf << "\n\n"; + + const int soapstart = cmd.Find(" 0) + { + const size_t soaplen = cmd.length() - soapstart; + const char* buff = (const char*)cmd; + buff += soapstart; + wxMemoryInputStream input(buff, soaplen); + TXmlItem query; + if (query.Read(input)) + { + const TXmlItem* pxmlBody = query.FindFirst("SOAP-ENV:Body"); + if (pxmlBody != NULL) for (int m = 0; ; m++) + { + const TXmlItem* pxmlMethod = pxmlBody->GetChild(m); + if (pxmlMethod == NULL) + break; + if (pxmlMethod->GetTag().StartsWith("m:")) + { + SoapProcessMethod(*pxmlMethod, outf); + } + } + } + } + outf << "\n\n"; + } + + wxFileInputStream inf(strFilename); + + sock << "HTTP/1.1 200 OK\n"; + sock << "Server: " << GetAppName() << "\n"; + sock << "Host: " << wxGetFullHostName() << "\n"; + sock << "Connection: keep-alive\n"; + sock << "Content-Type: text/xml; charset=utf-8\n"; + sock << "Content-Length: " << inf.GetSize() << "\n"; + sock << "Date: " << wxDateTime::Now().Format("%#c") << "\n"; + sock << "\n"; + + SendContent(inf, sock); +} + +void TDataBaseServer::ProcessCommand(wxString cmd, wxSocketBase& outs) +{ + if (cmd.StartsWith("GET ")) + { + const int stop = cmd.Find(" HTTP"); + wxString str = cmd.Mid(4, stop-4).Trim(); + if (str == "/") + str += "index.htm"; + wxString strFilename = GetDocumentRoot() + str; + + if (IsMagicName(strFilename)) + GenerateFile(strFilename); + else + { + const int ims = cmd.Find("If-Modified-Since: "); + if (ims > 0) + { + const wxString strDate = cmd.Mid(ims+19, 24); + wxDateTime tIms; + if (tIms.ParseDateTime(strDate)) + { + const wxDateTime tFile = ::wxFileModificationTime(strFilename); + if (tFile <= tIms) + { + SendNotModifiedFile(outs); + return; + } + } + } + } + SendFile(strFilename, outs); + } else + if (cmd.StartsWith("POST ")) + { + if (cmd.Find("SOAPAction") > 0) + ProcessSoapCommand(cmd, outs); + else + ProcessFormCommand(cmd, outs); + } +} + +bool TDataBaseServer::Initialization() +{ + return true; +} + +bool TDataBaseServer::Deinitialization() +{ + wxDbCloseConnections(); + return true; +} + +// Istanziare l'applicazione principale + +IMPLEMENT_APP(TDataBaseServer) diff --git a/server/diction.cpp b/server/diction.cpp index 5e01a1d14..2ee69e64a 100755 --- a/server/diction.cpp +++ b/server/diction.cpp @@ -1,7 +1,5 @@ #include "BaseServ.h" -#include #include -#include #include @@ -45,6 +43,7 @@ public: wxString OriginalEntry(size_t i); wxString TranslatedEntry(size_t i); + void UpdateEntry(size_t i, const wxString& strValue); TDictionary(); @@ -82,11 +81,11 @@ wxString TDictionary::Accentuate(const wxString& str) const bello[a-1] = 'é'; break; case 'i': - bello[a-1] = 'ì'; break; + bello[a-1] = 'ì'; break; case 'o': - bello[a-1] = 'ò'; break; + bello[a-1] = 'ò'; break; case 'u': - bello[a-1] = 'ù'; break; + bello[a-1] = 'ù'; break; default: break; } @@ -288,6 +287,8 @@ protected: virtual const wxChar* GetAppName() const; virtual void ProcessCommand(wxString cmd, wxSocketBase& outs); + size_t FindIndex(const wxString& strKey); + public: bool DoTranslate(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer); bool SoapProcessMethod(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer); @@ -446,7 +447,7 @@ void TDictionaryServer::GenerateFile(wxString& strFilename) table.SetAttr("border", "1"); table.SetAttr("width", "100%"); table.AddChild("caption").AddChild("h1") << wxString::Format("%c", cFilter); - TXmlItem& table_th = table.AddChild("tr"); + TXmlItem& table_th = table.AddChild("thead"); TXmlItem& th0 = table_th.AddChild("th"); TXmlItem& th1 = table_th.AddChild("th"); th1 << "Original text"; @@ -466,6 +467,25 @@ void TDictionaryServer::GenerateFile(wxString& strFilename) html.Save(strFilename); } +// Convert code (B-23) to position (107) +size_t TDictionaryServer::FindIndex(const wxString& strKey) +{ + const wxChar cFirst = toupper(strKey[0]); + const size_t nPos = atoi(strKey.Mid(2)); + size_t nFound = 0; + for (size_t i = 0; i < m_DevotoOli.GetCount(); i++) + { + const wxChar c = toupper(m_DevotoOli.OriginalEntry(i)[0]); + if (c == cFirst) + { + if (nFound == nPos) + break; + nFound++; + } + } + return i; +} + void TDictionaryServer::CallCgi(wxString& strFileName) { wxString strName, strExt, strArgs; @@ -479,26 +499,12 @@ void TDictionaryServer::CallCgi(wxString& strFileName) if (strExt == "cgi") { TXmlItem html; - TXmlItem& body = CreatePageBody(html); + TXmlItem& body = CreatePageBody(html).AddChild("center"); if (strName == "EditEntry") { - // Convert code (B-23) to position (107) - const wxChar cFirst = toupper(strArgs[0]); - const size_t nPos = atoi(strArgs.Mid(2)); - size_t nFound = 0; - for (size_t i = 0; i < m_DevotoOli.GetCount(); i++) - { - const wxChar c = toupper(m_DevotoOli.OriginalEntry(i)[0]); - if (c == cFirst) - { - if (nFound == nPos) - break; - nFound++; - } - } + const size_t i = FindIndex(strArgs); body.AddChild("h2") << "Edit Entry " << strArgs; - body.AddChild("br"); TXmlItem& form = body.AddChild("form"); form.SetAttr("method", "post"); @@ -514,7 +520,7 @@ void TDictionaryServer::CallCgi(wxString& strFileName) TXmlItem& ent = form.AddChild("input"); ent.SetAttr("type", "hidden"); ent.SetAttr("name", "Entry"); - ent.SetAttr("value", wxString::Format("%d", i)); + ent.SetAttr("value", strArgs); TXmlItem& eng = form.AddChild("textarea"); eng.SetAttr("name", "Trans"); @@ -527,6 +533,8 @@ void TDictionaryServer::CallCgi(wxString& strFileName) TXmlItem& sub = form.AddChild("input"); sub.SetAttr("type", "submit"); sub.SetAttr("value", "Update Translation"); + + AddLinkButton(body, "Return to main page", "/"); } if (strName == "TranslateSentence") { @@ -595,18 +603,16 @@ void TDictionaryServer::ProcessSoapCommand(wxString cmd, wxSocketBase& sock) } } const wxString strResult = xmlEnvelope.AsString(); - wxChar strLength[16]; sprintf(strLength, "%d", strResult.Length()); - wxSocketOutputStream outs(sock); - outs << "HTTP/1.1 200 OK" << endl; - outs << "Connection: keep-alive" << endl; - outs << "Content-Length: " << strLength << endl; - outs << "Content-Type: text/xml; charset=utf-8" << endl; - outs << "Date: " << wxDateTime::Now().Format("%#c") << endl; - outs << "Server: " << GetAppName() << endl; - outs << "Host: " << wxGetHostName() << endl; - outs << endl; - outs << strResult; + sock << "HTTP/1.1 200 OK" << endl; + sock << "Connection: keep-alive" << endl; + sock << "Content-Length: " << strResult.Length() << endl; + sock << "Content-Type: text/xml; charset=utf-8" << endl; + sock << "Date: " << wxDateTime::Now().Format("%#c") << endl; + sock << "Server: " << GetAppName() << endl; + sock << "Host: " << wxGetFullHostName() << endl; + sock << endl; + sock << strResult; } void TDictionaryServer::ProcessHttpGet(wxString cmd, wxSocketBase& outs) @@ -629,11 +635,22 @@ void TDictionaryServer::ProcessHttpGet(wxString cmd, wxSocketBase& outs) void TDictionaryServer::ProcessFormUpdateEntry(wxString& strFileName, THashTable& hashArgs) { - const size_t nEntry = atoi(hashArgs.Get("Entry")); + const wxString key = hashArgs.Get("Entry"); + size_t nEntry = FindIndex(key); const wxString strValue = hashArgs.Get("Trans"); m_DevotoOli.UpdateEntry(nEntry, strValue); - strFileName = "dictionary"; - GenerateFile(strFileName); + + TXmlItem html; + TXmlItem& body = CreatePageBody(html).AddChild("center"); + body.AddChild("h2") << "Entry updated!"; + body.AddChild("br"); + + strFileName = "dictionary?"; + strFileName << key[0]; + AddLinkButton(body, "Return to Dictionary", strFileName); + + strFileName = GetTempFilename(); + html.Save(strFileName); } void TDictionaryServer::ProcessFormTranslate(wxString& strFileName, @@ -642,7 +659,7 @@ void TDictionaryServer::ProcessFormTranslate(wxString& strFileName, const wxString strValue = hashArgs.Get("Sentence"); TXmlItem html; - TXmlItem& body = CreatePageBody(html); + TXmlItem& body = CreatePageBody(html).AddChild("center"); body.AddChild("h3") << "Input the text to be translated:"; TXmlItem& form = body.AddChild("form"); @@ -675,6 +692,9 @@ void TDictionaryServer::ProcessFormTranslate(wxString& strFileName, sub.SetAttr("type", "submit"); sub.SetAttr("value", "Translate"); + body.AddChild("br"); + AddLinkButton(body, "Return to main page", "/"); + strFileName = GetTempFilename(); html.Save(strFileName); } diff --git a/server/diction.dsp b/server/diction.dsp index bb65c0e7b..d780b8142 100755 --- a/server/diction.dsp +++ b/server/diction.dsp @@ -99,7 +99,8 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../include" /I "../../contrib/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" /D WXUSINGDLL=1 /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MDd /W3 /Gm- /GX /ZI /Od /I "\wx233\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" /D WXUSINGDLL=1 /FD /c +# SUBTRACT CPP /YX /Yc /Yu # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" @@ -109,7 +110,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 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 wx22_9d.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /out:"DebugDLL/server.exe" /pdbtype:sept /libpath:"../../lib" /libpath:"../../contrib/lib" +# ADD LINK32 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 \wx233\lib\wxmsw233d.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /out:"..\exe\servers\diction.exe" /pdbtype:sept /libpath:"../../lib" /libpath:"../../contrib/lib" !ELSEIF "$(CFG)" == "Diction - Win32 Release DLL" @@ -175,6 +176,10 @@ SOURCE=.\Diction.h # End Source File # Begin Source File +SOURCE=.\mutex.h +# End Source File +# Begin Source File + SOURCE=.\xml.h # End Source File # End Group @@ -190,12 +195,12 @@ SOURCE=.\server.rc !ELSEIF "$(CFG)" == "Diction - Win32 Debug" # ADD BASE RSC /l 0x809 -# ADD RSC /l 0x410 /i "c:\wx229\wx" /i /wx229/include" " +# ADD RSC /l 0x410 /i "c:\wx233\wx" /i /wx229/include" " !ELSEIF "$(CFG)" == "Diction - Win32 Debug DLL" # ADD BASE RSC /l 0x809 -# ADD RSC /l 0x809 /i "../../include" /i "../../contrib/include" +# ADD RSC /l 0x809 /i "\wx233\include" !ELSEIF "$(CFG)" == "Diction - Win32 Release DLL" diff --git a/server/example.cpp b/server/example.cpp deleted file mode 100755 index 807946b4f..000000000 --- a/server/example.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "BaseServ.h" - -class MyServer : public TBaseServerApp -{ -protected: - virtual const wxChar* GetAppName() const; - virtual void ProcessCommand(wxString cmd, wxSocketOutputStream& outs); -}; - -// Implementare almeno queste due funzioni pure virtuali - -const wxChar* MyServer::GetAppName() const -{ - return "MyServer"; -} - -void MyServer::ProcessCommand(wxString cmd, wxSocketOutputStream& outs) -{ - WriteLog("Processing..."); - outs << "\n" - << "

Hello world!

\n" - << "

Http command:

\n" - << "

" << cmd << "

\n" - << "\n"; -} - -// Istanziare l'applicazione principale - -IMPLEMENT_APP(MyServer) diff --git a/server/lerch.cpp b/server/lerch.cpp index 4e14c71e7..6ed0a0d6c 100755 --- a/server/lerch.cpp +++ b/server/lerch.cpp @@ -10,16 +10,26 @@ class TLerchServer : public TBaseServerApp protected: virtual const wxChar* GetAppName() const; virtual void ProcessCommand(wxString cmd, wxSocketBase& outs); + virtual bool Initialization(); + + void AddMiniForm(TXmlItem& tr, const wxChar* action, const wxChar* app, const wxChar* prompt) const; + void EnumerateVariables(const wxString& strApp, wxArrayString& arr) const; + + void CreateServersList(wxArrayString& arr) const; + void KillProcess(const wxString& strApp); public: void GenerateFile(wxString& strFilename); bool IsMagicName(wxString& strFilename) const; bool IsCgiName(wxString strFilename) const; - void CreateServersList(wxArrayString& arr) const; + void ProcessHttpGet(wxString cmd, wxSocketBase& outs); + void ProcessHttpPost(wxString cmd, wxSocketBase& outs); void ProcessFormStart(const THashTable& args, wxSocketBase& sock); void ProcessFormKill(const THashTable& args, wxSocketBase& sock); + void ProcessFormConfig(const THashTable& args, wxSocketBase& sock); + void ProcessFormUpdate(THashTable& args, wxSocketBase& sock); void CallCgi(wxString& strFileName, wxSocketBase& sock); }; @@ -43,8 +53,7 @@ void TLerchServer::CreateServersList(wxArrayString& arr) const { *chiusa = '\0'; wxString str = aperta+1; - if (str != GetAppName()) - arr.Add(str); + arr.Add(str); aperta = strchr(chiusa+1, '['); } else @@ -54,6 +63,21 @@ void TLerchServer::CreateServersList(wxArrayString& arr) const delete buff; } +void TLerchServer::AddMiniForm(TXmlItem& tr, const wxChar* action, const wxChar* app, const wxChar* prompt) const +{ + TXmlItem& td = tr.AddChild("td").SetAttr("width", "15%"); + TXmlItem& form = td.AddChild("center").AddChild("form"); + form.SetAttr("action", action); + + TXmlItem& name = form.AddChild("input"); + name.SetAttr("type", "hidden"); name.SetAttr("name", "App"); + name.SetAttr("value", app); + + TXmlItem& submit = form.AddChild("input"); + submit.SetAttr("type", "submit"); + submit.SetAttr("value", prompt); +} + void TLerchServer::GenerateFile(wxString& strFilename) { TXmlItem html; @@ -74,7 +98,7 @@ void TLerchServer::GenerateFile(wxString& strFilename) ini.SetPath(str); wxString strHost; - ini.Read("Host", &strHost, wxGetHostName()); + ini.Read("Host", &strHost, wxGetFullHostName()); int nPort; ini.Read("Port", &nPort, 3883); @@ -82,8 +106,8 @@ void TLerchServer::GenerateFile(wxString& strFilename) wxString strIcon; ini.Read("Icon", &strIcon, "euro.gif"); - int nRunning; - ini.Read("Running", &nRunning, 0); + const wxSingleInstanceChecker sic(arr[i]); + const bool bRunning = sic.IsAnotherRunning(); TXmlItem& tr = table.AddChild("tr"); TXmlItem& td0 = tr.AddChild("td"); @@ -93,19 +117,12 @@ void TLerchServer::GenerateFile(wxString& strFilename) TXmlItem& img = a.AddChild("img"); img.SetAttr("src", strIcon); img.SetAttr("border", 0); img.SetAttr("alt", arr[i]); - TXmlItem& td1 = tr.AddChild("td"); td1.SetAttr("width", "15%"); - TXmlItem& form = td1.AddChild("center").AddChild("form"); - form.SetAttr("action", nRunning ? "kill.cgi" : "start.cgi"); - - TXmlItem& name = form.AddChild("input"); - name.SetAttr("type", "hidden"); name.SetAttr("name", "App"); - name.SetAttr("value", arr[i]); + AddMiniForm(tr, bRunning ? "kill.cgi" : "start.cgi", arr[i], bRunning ? "Stop" : "Start"); + AddMiniForm(tr, "config.cgi", arr[i], "Configure"); - TXmlItem& submit = form.AddChild("input"); - submit.SetAttr("type", "submit"); - submit.SetAttr("value", nRunning ? "Stop" : "Start"); - - tr.AddChild("td") << arr[i] << " Server"; + TXmlItem& a3 = tr.AddChild("td").AddChild("a"); + a3.SetAttr("href", wxString::Format("http://%s:%d/index.htm", strHost, nPort)); + a3 << arr[i] << " Server"; } html.Save(strFilename); @@ -144,33 +161,40 @@ bool TLerchServer::IsCgiName(wxString strFilename) const void TLerchServer::ProcessFormStart(const THashTable& args, wxSocketBase& sock) { + bool ok = false; + const wxString strApp = args.Get("App"); - const wxString strRun = GetConfigString("Run", "", strApp); - if (wxFileExists(strRun)) + if (!strApp.IsEmpty()) // Dummy test { - wxExecute(strRun); - for (int i = 0; i < 3; i++) + const wxSingleInstanceChecker sic(strApp); + ok = !sic.IsAnotherRunning(); + } + + if (ok) + { + const wxString strRun = GetConfigString("Run", "", strApp); + if (wxFileExists(strRun)) { - wxSleep(3); - if (GetConfigInt("Running", 0, strApp) == 1) - break; + const long nProc = wxExecute(strRun); + if (nProc == 0 || nProc == -1) + MessageBox("ERROR", wxString::Format("Can't run %s executable (%s)", strApp, strRun), sock); + else + MessageBox("Server Started", strApp, sock); } - wxString strFileName = "index"; - GenerateFile(strFileName); - SendFile(strFileName, sock); + else + MessageBox("ERROR", wxString::Format("Can't find %s executable (%s)", strApp, strRun), sock); } else - MessageBox("ERROR", wxString::Format("Can't run %s", strRun), sock); + MessageBox("ERROR", wxString::Format("%s il already running", strApp), sock); } -void TLerchServer::ProcessFormKill(const THashTable& args, wxSocketBase& sock) +void TLerchServer::KillProcess(const wxString& strApp) { - const wxString strApp = args.Get("App"); const wxString strHost = GetConfigString("Host", "localhost", strApp); const int nPort = GetConfigInt("Port", 0, strApp); if (nPort > 0) { - wxIPV4address addr; + wxIPV4address addr; addr.Hostname(strHost); addr.Service(nPort); @@ -178,20 +202,131 @@ void TLerchServer::ProcessFormKill(const THashTable& args, wxSocketBase& sock) if (sock.Connect(addr)) { const wxString str = "GET /stop.cgi HTTP/1.1\r\n\r\n"; - for (int i = 0; i < 3; i++) + sock.Write(str, str.Length()); + if (strHost == "localhost") { - sock.Write(str, str.Length()); - wxSleep(1); - if (GetConfigInt("Running", 0, strApp) == 0) - break; + const wxSingleInstanceChecker sic(strApp); + for (int i = 0; i < 5 && sic.IsAnotherRunning(); i++) + wxSleep(1); } } - - SetConfigString("Running", "0", strApp); } - wxString strFileName = "index"; - GenerateFile(strFileName); - SendFile(strFileName, sock); +} + +void TLerchServer::ProcessFormKill(const THashTable& args, wxSocketBase& sock) +{ + const wxString strApp = args.Get("App"); + if (strApp == GetAppName()) // Stop myself! + { + wxArrayString app; CreateServersList(app); + for (size_t i = 0; i < app.GetCount(); i++) + { + if (app[i] != GetAppName()) // Stop Children only! + { + const wxSingleInstanceChecker sic(app[i]); + if (sic.IsAnotherRunning()) + KillProcess(app[i]); + } + } + } + KillProcess(strApp); + MessageBox("Server stopped", strApp, sock); +} + +void TLerchServer::EnumerateVariables(const wxString& strApp, wxArrayString& arr) const +{ + wxFileInputStream inf(GetConfigName()); + wxString strParagraph = wxString::Format("[%s]", strApp); + wxString str; + + bool bFound = false; + while (inf.Ok()) + { + inf >> str; + if (str == strParagraph) + { + bFound = true; + break; + } + } + + if (bFound) + { + while (inf.Ok()) + { + inf >> str; + if (str.IsEmpty() || str[0] == '[') + break; + const int nEqual = str.Find('='); + if (nEqual > 0) + { + str.Truncate(nEqual); + str.Trim(false); + str.Trim(true); + arr.Add(str); + } + } + arr.Sort(); + } +} + +void TLerchServer::ProcessFormConfig(const THashTable& args, wxSocketBase& sock) +{ + const wxString strApp = args.Get("App"); + wxArrayString arr; + EnumerateVariables(strApp, arr); + + TXmlItem html; + TXmlItem& body = CreatePageBody(html); + + TXmlItem& form = body.AddChild("form"); + form.SetAttr("action", "update.cgi").SetAttr("method", "post"); + + TXmlItem& table = form.AddChild("table").SetAttr("width", "100%").SetAttr("border", "1"); + table.AddChild("caption").AddChild("h2") << strApp; + TXmlItem& thead = table.AddChild("thead"); + thead.AddChild("th").SetAttr("width", "15%") << "Property"; + thead.AddChild("th").SetAttr("width", "85%") << "Value"; + + for (size_t v = 0; v < arr.GetCount(); v++) + { + TXmlItem& tr = table.AddChild("tr"); + tr.AddChild("td") << arr[v]; + TXmlItem& input = tr.AddChild("td").AddChild("input"); + input.SetAttr("type", "text"); input.SetAttr("name", arr[v]); + input.SetAttr("size", "80"); input.SetAttr("maxlength", "256"); + input.SetAttr("value", GetConfigString(arr[v], "", strApp)); + } + + TXmlItem& app = form.AddChild("input").SetAttr("type", "hidden"); + app.SetAttr("name", "App"); app.SetAttr("value", strApp); + + TXmlItem& submit = form.AddChild("br").AddChild("center").AddChild("input"); + submit.SetAttr("type", "submit"); submit.SetAttr("value", "Update Parameters"); + + body.AddChild("br"); + AddLinkButton(body.AddChild("center"), "Return to main page", "/"); + + const wxString strFilename = GetTempFilename(); + html.Save(strFilename); + SendFile(strFilename, sock); +} + +void TLerchServer::ProcessFormUpdate(THashTable& args, wxSocketBase& sock) +{ + const wxString strApp = args.Get("App"); + args.BeginFind(); + for (wxNode* pNode = args.Next(); pNode; pNode = args.Next()) + { + const wxString strKey = pNode->GetKeyString(); + if (strKey != "App") + { + const wxString strVal = args.Get(strKey); + SetConfigString(strKey, strVal, strApp); + } + } + const wxString msg = wxString::Format("%s parameters updated", strApp); + MessageBox("Success!", msg, sock); } void TLerchServer::CallCgi(wxString& strFileName, wxSocketBase& sock) @@ -213,7 +348,11 @@ void TLerchServer::CallCgi(wxString& strFileName, wxSocketBase& sock) if (strName == "start") ProcessFormStart(hashArgs, sock); else if (strName == "kill") - ProcessFormKill(hashArgs, sock); + ProcessFormKill(hashArgs, sock); else + if (strName == "config") + ProcessFormConfig(hashArgs, sock); else + if (strName == "update") + ProcessFormUpdate(hashArgs, sock); } } @@ -236,10 +375,52 @@ void TLerchServer::ProcessHttpGet(wxString cmd, wxSocketBase& outs) } } +void TLerchServer::ProcessHttpPost(wxString cmd, wxSocketBase& outs) +{ + const int stop = cmd.Find(" HTTP"); + wxString strFileName = cmd.Mid(5, stop-5).Trim(); + + wxString strName, args; + wxSplitPath(strFileName, NULL, &strName, NULL); + + const int pos = cmd.Find("\r\n\r\n"); + if (pos > 0) + args = cmd.Mid(pos+4); + + THashTable hashArgs(17); + ParseArguments(args, hashArgs); + + if (strName == "update") + ProcessFormUpdate(hashArgs, outs); +} + void TLerchServer::ProcessCommand(wxString cmd, wxSocketBase& outs) { if (cmd.StartsWith("GET ")) - ProcessHttpGet(cmd, outs); + ProcessHttpGet(cmd, outs); else + if (cmd.StartsWith("POST ")) + ProcessHttpPost(cmd, outs); +} + +bool TLerchServer::Initialization() +{ + wxArrayString arr; CreateServersList(arr); + for (size_t i = 0; i < arr.GetCount(); i++) + { + const wxString& strApp = arr[i]; + const bool bAutorun = GetConfigBool("Autorun", false, strApp); + if (bAutorun) + { + const wxSingleInstanceChecker sic(strApp); + if (!sic.IsAnotherRunning()) + { + wxString strRun = GetConfigString("Run", "", strApp); + if (wxFileExists(strRun)) + wxExecute(strRun); + } + } + } + return true; } // Istanziare l'applicazione principale diff --git a/server/lerch.dsp b/server/lerch.dsp index c6b1c0412..869f687e1 100755 --- a/server/lerch.dsp +++ b/server/lerch.dsp @@ -99,7 +99,8 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../include" /I "../../contrib/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" /D WXUSINGDLL=1 /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "\wx233\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" /D WXUSINGDLL=1 /FD /c +# SUBTRACT CPP /YX /Yc /Yu # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" @@ -109,7 +110,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 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 wx22_9d.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /out:"DebugDLL/server.exe" /pdbtype:sept /libpath:"../../lib" /libpath:"../../contrib/lib" +# ADD LINK32 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 \wx233\lib\wxmsw233d.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /out:"../exe/servers/Lerch.exe" /pdbtype:sept /libpath:"../../lib" /libpath:"../../contrib/lib" !ELSEIF "$(CFG)" == "Lerch - Win32 Release DLL" @@ -190,12 +191,12 @@ SOURCE=.\server.rc !ELSEIF "$(CFG)" == "Lerch - Win32 Debug" # ADD BASE RSC /l 0x809 -# ADD RSC /l 0x410 /i "c:\wx229\wx" /i /wx229/include" " +# ADD RSC /l 0x410 /i "c:\wx233\wx" /i /wx229/include" " !ELSEIF "$(CFG)" == "Lerch - Win32 Debug DLL" # ADD BASE RSC /l 0x809 -# ADD RSC /l 0x809 /i "../../include" /i "../../contrib/include" +# ADD RSC /l 0x809 /i "\wx233\include" !ELSEIF "$(CFG)" == "Lerch - Win32 Release DLL" diff --git a/server/servers.ini b/server/servers.ini new file mode 100755 index 000000000..4a78c2a5b --- /dev/null +++ b/server/servers.ini @@ -0,0 +1,8 @@ +[Coffee] +Running=1 + +[Authorization] +Running=1 + +[Lerch] +Running=1 diff --git a/server/xml.cpp b/server/xml.cpp index b08835cd0..ed706d399 100755 --- a/server/xml.cpp +++ b/server/xml.cpp @@ -1,4 +1,5 @@ #include +#include "wx/mstream.h" #include #include "xml.h" @@ -140,13 +141,20 @@ public: void TXmlAttr::Write(wxOutputStream& outf) const { - if (m_str.IsNumber()) + if (m_str.IsEmpty()) { - outf << m_str; + outf << "\"\""; } else { - outf << "\"" << m_str << "\""; + if (m_str.IsNumber()) + { + outf << m_str; + } + else + { + outf << "\"" << m_str << "\""; + } } } @@ -154,6 +162,8 @@ void TXmlAttr::Write(wxOutputStream& outf) const // TXmlItem /////////////////////////////////////////////////////////// +IMPLEMENT_DYNAMIC_CLASS(TXmlItem, wxObject) + TXmlItem& TXmlItem::SetAttr(const wxChar* strAttr, const wxChar* strVal) { if (m_Attributes == NULL) @@ -162,7 +172,7 @@ TXmlItem& TXmlItem::SetAttr(const wxChar* strAttr, const wxChar* strVal) m_Attributes->DeleteContents(true); } m_Attributes->Delete(strAttr); - m_Attributes->Put(strAttr, new TXmlAttr(strVal)); + m_Attributes->Put(strAttr, new TXmlAttr(strVal)); return *this; } diff --git a/server/xml.h b/server/xml.h index cc198a625..b7e85268f 100755 --- a/server/xml.h +++ b/server/xml.h @@ -1,16 +1,14 @@ #ifndef __XML_H #define __XML_H -#ifndef _WX_WXMMSTREAM_H__ -#include "wx/mstream.h" -#endif - class TXmlItem; typedef bool (*XmlItemCallback)(TXmlItem& item, long jolly); class TXmlItem : public wxObject { + DECLARE_DYNAMIC_CLASS(TXmlItem); + wxString m_strTag, m_strText; wxHashTable* m_Attributes; wxList* m_Children; @@ -20,7 +18,6 @@ protected: int ReadTag(wxInputStream& input); TXmlItem& AddChild(TXmlItem* pItem); - void RemoveLastChild(); public: const wxString& GetTag() const { return m_strTag; } @@ -41,6 +38,7 @@ public: int GetChildren() const; TXmlItem* GetChild(size_t n) const; + void RemoveLastChild(); bool Read(wxInputStream& input); void Write(wxOutputStream& output, int nTab) const;