Patch level : 10.0
Files correlati : ba0 ba1 Ricompilazione Demo : [ ] Commento : Migliorata gestione dninst.zip git-svn-id: svn://10.65.10.50/trunk@19861 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									6237b1ae22
								
							
						
					
					
						commit
						10b8b17bf4
					
				@ -190,7 +190,7 @@ bool TMenuitem::create(const char* t)
 | 
			
		||||
 | 
			
		||||
  // Controlla lo stato di aggiornamento
 | 
			
		||||
  if (_enabled && is_program())
 | 
			
		||||
    _enabled = !menu().is_dangerous(_action);
 | 
			
		||||
    _enabled = !menu().is_dangerous(_action) && !menu().is_vanished(_action);
 | 
			
		||||
 | 
			
		||||
  return visible;
 | 
			
		||||
} 
 | 
			
		||||
@ -333,14 +333,6 @@ bool TMenuitem::perform_program() const
 | 
			
		||||
  if (ok)
 | 
			
		||||
  {
 | 
			
		||||
    TCurrency::force_cache_update();    // Chiude cache valute
 | 
			
		||||
 | 
			
		||||
    // Anti TASSAN
 | 
			
		||||
    if (_action.starts_with("lv") && is_tassan())
 | 
			
		||||
    {
 | 
			
		||||
      ((TString&)_action) = "lv";
 | 
			
		||||
      ((TString&)_caption) << " lavanderie";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    TExternal_app a(_action);
 | 
			
		||||
 | 
			
		||||
		const bool install_app = _action.starts_with("ba1 -6", true);
 | 
			
		||||
@ -584,6 +576,9 @@ bool TMenu::read(const char* name, TString& root)
 | 
			
		||||
 | 
			
		||||
bool TMenu::read(const char* name) 
 | 
			
		||||
{ 
 | 
			
		||||
  Tdninst dninst;
 | 
			
		||||
  dninst.find_killed(_vanished);
 | 
			
		||||
 | 
			
		||||
  TString root;
 | 
			
		||||
  bool ok = read(name, root); 
 | 
			
		||||
  if (ok && _current == NULL)
 | 
			
		||||
@ -781,8 +776,12 @@ void TMenu::reload_images()
 | 
			
		||||
 | 
			
		||||
bool TMenu::has_module(const char* mod)
 | 
			
		||||
{
 | 
			
		||||
  const word module = dongle().module_name2code(mod);
 | 
			
		||||
  return main_app().has_module(module);
 | 
			
		||||
  TDongle& donkey = dongle();
 | 
			
		||||
  const word module = donkey.module_name2code(mod);
 | 
			
		||||
  bool yes = module == BAAUT;
 | 
			
		||||
  if (!yes && donkey.active(module))
 | 
			
		||||
    yes = main_app().has_module(module) && !is_vanished(mod);
 | 
			
		||||
  return yes;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool TMenu::is_dangerous(const char* mod)
 | 
			
		||||
@ -791,21 +790,28 @@ bool TMenu::is_dangerous(const char* mod)
 | 
			
		||||
  return _dangerous.get_pos(code) >= 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool TMenu::is_vanished(const TString& app)
 | 
			
		||||
{
 | 
			
		||||
  if (_vanished.empty() || app.starts_with("ba"))
 | 
			
		||||
    return false;
 | 
			
		||||
 | 
			
		||||
  if (_vanished.find('*') >= 0)
 | 
			
		||||
    return true;
 | 
			
		||||
  
 | 
			
		||||
  bool yes = _vanished.get_pos(app) >= 0;
 | 
			
		||||
  if (!yes && app[0] != '7' && isdigit(app[0]))
 | 
			
		||||
  {
 | 
			
		||||
    TString4 mod; mod << app[0] << app[1];
 | 
			
		||||
    const int cod = dongle().module_name2code(mod);
 | 
			
		||||
    mod = dongle().module_code2name(cod);
 | 
			
		||||
    yes = _vanished.get_pos(mod) >= 0;
 | 
			
		||||
  }
 | 
			
		||||
  return yes;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
TMenu::TMenu() : _current(NULL), _item(0), _mask_mode(0)
 | 
			
		||||
{ }
 | 
			
		||||
 | 
			
		||||
TMenu::~TMenu()
 | 
			
		||||
{ }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
bool is_tassan()
 | 
			
		||||
{
 | 
			
		||||
  bool yes = false;
 | 
			
		||||
  if (dongle().number() == 202)
 | 
			
		||||
  {
 | 
			
		||||
    const TDate morte(07, 01, 2010); // Giorno della morte del programma
 | 
			
		||||
    const TDate oggi(TODAY);
 | 
			
		||||
    yes = oggi >= morte;
 | 
			
		||||
  }
 | 
			
		||||
  return yes;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										13
									
								
								ba/ba0101.h
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								ba/ba0101.h
									
									
									
									
									
								
							@ -1,10 +1,6 @@
 | 
			
		||||
#ifndef __BA0101_H
 | 
			
		||||
#define __BA0101_H
 | 
			
		||||
 | 
			
		||||
#ifndef __ASSOC_H
 | 
			
		||||
#include <assoc.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef __COLORS_H
 | 
			
		||||
#include <colors.h>
 | 
			
		||||
#endif
 | 
			
		||||
@ -13,15 +9,10 @@
 | 
			
		||||
#include <image.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef __SCANNER_H
 | 
			
		||||
#include <scanner.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef __STACK_H
 | 
			
		||||
#include <stack.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TSubmenu;
 | 
			
		||||
class TMenu;
 | 
			
		||||
 | 
			
		||||
@ -132,7 +123,7 @@ class TMenu : public TAssoc_array
 | 
			
		||||
  
 | 
			
		||||
  TAssoc_array _images;
 | 
			
		||||
 | 
			
		||||
  TToken_string _dangerous;
 | 
			
		||||
  TToken_string _dangerous, _vanished;
 | 
			
		||||
 | 
			
		||||
	TString _last_search;
 | 
			
		||||
	TAssoc_array _ignore_list;
 | 
			
		||||
@ -169,6 +160,7 @@ public:
 | 
			
		||||
  
 | 
			
		||||
  bool has_module(const char* mod);
 | 
			
		||||
  bool is_dangerous(const char* mod);
 | 
			
		||||
  bool is_vanished(const TString& app);
 | 
			
		||||
 | 
			
		||||
  void set_dangerous_modules(const TToken_string& mod)
 | 
			
		||||
  { _dangerous = mod; }
 | 
			
		||||
@ -182,6 +174,5 @@ public:
 | 
			
		||||
 | 
			
		||||
void set_installing_flag();
 | 
			
		||||
bool installing();
 | 
			
		||||
bool is_tassan();
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@ -243,10 +243,6 @@ void TBook_window::set_page_caption(short page, const TString& caption, int icon
 | 
			
		||||
    xvt_notebk_set_tab_title(_ctrl, page, caption);  // Titolo dell'orecchio
 | 
			
		||||
    xvt_notebk_set_tab_icon(_ctrl, page, icon);      // Icona dell'orecchio
 | 
			
		||||
    xvt_notebk_set_page_title(_ctrl, page, caption); // Titolo della finestra
 | 
			
		||||
 | 
			
		||||
    // Anti TASSAN
 | 
			
		||||
    if (caption.find("avand") > 0 && is_tassan())
 | 
			
		||||
      set_logo("lv00");
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										231
									
								
								ba/ba1500.cpp
									
									
									
									
									
								
							
							
						
						
									
										231
									
								
								ba/ba1500.cpp
									
									
									
									
									
								
							@ -141,13 +141,13 @@ void TRequest_form::update_serno(const TString& num)
 | 
			
		||||
  const TDate today(TODAY);
 | 
			
		||||
  TForm_item& data = find_field('H', odd_page, FF_DATARICH);
 | 
			
		||||
  data.set(today.string());
 | 
			
		||||
  const char* hw = "";
 | 
			
		||||
  switch (::dongle().hardware())
 | 
			
		||||
  {
 | 
			
		||||
  case _dongle_hardlock:
 | 
			
		||||
    find_field('H',odd_page,FF_DONGLE_HW).set("HARDLOCK"); break;
 | 
			
		||||
  default:
 | 
			
		||||
    find_field('H',odd_page,FF_DONGLE_HW).set("EUTRON"); break;
 | 
			
		||||
  case _dongle_hardlock: hw = "HARDLOCK"; break;
 | 
			
		||||
  default:               hw = "EUTRON";   break;
 | 
			
		||||
  }
 | 
			
		||||
  find_field('H',odd_page,FF_DONGLE_HW).set(hw);
 | 
			
		||||
  TForm_item& serno = find_field('H', odd_page, FF_DONGLE_SN);
 | 
			
		||||
  serno.set(num);
 | 
			
		||||
}
 | 
			
		||||
@ -157,8 +157,7 @@ void TRequest_form::update_dongle()
 | 
			
		||||
  const TDongle& d = dongle();
 | 
			
		||||
 | 
			
		||||
  TForm_item& year = find_field('H', odd_page, FF_YEAR);
 | 
			
		||||
  TString16 str; 
 | 
			
		||||
  str << "31-12-" << (int)d.year_assist();
 | 
			
		||||
  TString16 str; str << d.year_assist();
 | 
			
		||||
  year.set(str);
 | 
			
		||||
  
 | 
			
		||||
  TForm_item& user = find_field('H', odd_page, FF_NUTENTI);
 | 
			
		||||
@ -168,14 +167,8 @@ void TRequest_form::update_dongle()
 | 
			
		||||
 | 
			
		||||
void TRequest_form::update_os()
 | 
			
		||||
{
 | 
			
		||||
  const char* stros = NULL;
 | 
			
		||||
  switch (xvt_sys_get_os_version())
 | 
			
		||||
  {       
 | 
			
		||||
  case XVT_WS_LINUX : stros = "Linux"; break;
 | 
			
		||||
  case XVT_WS_WIN_95: stros = "Windows 95"; break;
 | 
			
		||||
  case XVT_WS_WIN_98: stros = "Windows 98"; break;
 | 
			
		||||
  default           : stros = "Windows NT/2000/XP"; break;
 | 
			
		||||
  }
 | 
			
		||||
  char stros[256];
 | 
			
		||||
  xvt_sys_get_version(stros, NULL, sizeof(stros));
 | 
			
		||||
 | 
			
		||||
  TForm_item& os = find_field('H', odd_page, FF_OS);
 | 
			
		||||
  os.set(stros);
 | 
			
		||||
@ -252,7 +245,6 @@ protected:
 | 
			
		||||
  void print_request();  
 | 
			
		||||
  void print_answer();
 | 
			
		||||
  void print_status();
 | 
			
		||||
  //void print_listino();
 | 
			
		||||
 | 
			
		||||
public:                       
 | 
			
		||||
  virtual void print();
 | 
			
		||||
@ -261,160 +253,8 @@ public:
 | 
			
		||||
  virtual ~TAttivazione_moduli() { }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
HIDDEN TAttivazione_moduli& app() { return (TAttivazione_moduli&)main_app(); }
 | 
			
		||||
 | 
			
		||||
int round_price(int val)
 | 
			
		||||
{
 | 
			
		||||
  if (val>50000) 
 | 
			
		||||
    val=int((val+9)/10000)*10000;
 | 
			
		||||
  else
 | 
			
		||||
    val=int((val+9)/10)*10;
 | 
			
		||||
  return val;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool TAttivazione_moduli::sh_nposti_handler(TMask_field& fld, KEY key)       
 | 
			
		||||
{
 | 
			
		||||
  if (key == K_TAB && fld.focusdirty())
 | 
			
		||||
  {
 | 
			
		||||
    // default
 | 
			
		||||
    int posti = atoi(fld.get());
 | 
			
		||||
    if (posti<=1)
 | 
			
		||||
      return true;
 | 
			
		||||
    int val = fld.mask().get_int(F_ACQ1);
 | 
			
		||||
    switch (posti)
 | 
			
		||||
    {
 | 
			
		||||
      case 2:
 | 
			
		||||
        val = int(val * .30);     break;
 | 
			
		||||
      case 3:
 | 
			
		||||
        val = int(val * .20);     break;
 | 
			
		||||
      case 5:
 | 
			
		||||
        val = int(val * .15);    break;
 | 
			
		||||
      case 9:
 | 
			
		||||
        val = int(val * .10);     break;
 | 
			
		||||
      case 30:
 | 
			
		||||
        val = int(val * .05);    break;
 | 
			
		||||
      default:
 | 
			
		||||
        val=0;
 | 
			
		||||
    }
 | 
			
		||||
    val = round_price(val);
 | 
			
		||||
    if (fld.mask().field(fld.dlg()+1).empty())
 | 
			
		||||
      fld.mask().field(fld.dlg()+1).set(val) ;  // costo di acquisto
 | 
			
		||||
    val=fld.mask().get_int(fld.dlg()+1);
 | 
			
		||||
    val = int (val * .35);
 | 
			
		||||
    val = round_price(val);
 | 
			
		||||
    fld.mask().field(fld.dlg()+2).set(val) ;     // costo di aggiornamento
 | 
			
		||||
  }
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool TAttivazione_moduli::sh_acquisto_handler(TMask_field& fld, KEY key)
 | 
			
		||||
{
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
bool TAttivazione_moduli::sh_aggiornamento_handler(TMask_field& fld, KEY key)
 | 
			
		||||
{
 | 
			
		||||
  if (key == K_TAB && fld.empty())
 | 
			
		||||
  {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void TAttivazione_moduli::update_listino()
 | 
			
		||||
{
 | 
			
		||||
  TMask msklistino("ba1500b") ;
 | 
			
		||||
  TMask &smask = msklistino.sfield(F_MODULILIST).sheet_mask();
 | 
			
		||||
  for (int c=0; c<6; c++)
 | 
			
		||||
  {
 | 
			
		||||
    smask.set_handler(F_POSTI1+3*c,  sh_nposti_handler    );
 | 
			
		||||
    smask.set_handler(F_ACQ1+3*c,    sh_acquisto_handler  );
 | 
			
		||||
    smask.set_handler(F_AGG1+3*c,    sh_aggiornamento_handler);
 | 
			
		||||
  }
 | 
			
		||||
  load_masklistino(msklistino);
 | 
			
		||||
  if (msklistino.run()==K_ENTER)
 | 
			
		||||
  {
 | 
			
		||||
    save_masklistino(msklistino);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TAttivazione_moduli::load_masklistino(TMask &msklistino)
 | 
			
		||||
{
 | 
			
		||||
  TWait_cursor hourglass;
 | 
			
		||||
  TInstall_ini ini;
 | 
			
		||||
  TDate dt(ini.get("Listino","Main"));
 | 
			
		||||
  if (!dt.empty())
 | 
			
		||||
    msklistino.set(F_DATALIST,dt);
 | 
			
		||||
 | 
			
		||||
  TSheet_field& sf = msklistino.sfield(F_MODULILIST);
 | 
			
		||||
  for (int i = 0; i < sf.items(); i++)
 | 
			
		||||
  {
 | 
			
		||||
    const TString16 modname(_im->get_name_by_order(i));
 | 
			
		||||
    if (modname.empty())
 | 
			
		||||
      break;
 | 
			
		||||
    
 | 
			
		||||
    TToken_string& riga = sf.row(i);
 | 
			
		||||
    riga=modname;
 | 
			
		||||
 | 
			
		||||
    const TFixed_string d(_im->get_description_by_order(i));
 | 
			
		||||
    riga.add(d); 
 | 
			
		||||
    riga.trim();
 | 
			
		||||
    riga.add("1"); // prima colonna = monoutenza
 | 
			
		||||
 | 
			
		||||
    TString_array prices;
 | 
			
		||||
    ini.set_paragraph(modname);
 | 
			
		||||
    ini.list_variables(prices, true,modname,true); // get array sorted by var name
 | 
			
		||||
    FOR_EACH_ARRAY_ROW(prices, v, key)
 | 
			
		||||
    {
 | 
			
		||||
      const TFixed_string price(key->get(0));
 | 
			
		||||
      if (price.compare("Prezzo", 6, true) == 0)
 | 
			
		||||
      {
 | 
			
		||||
        TString16 colonna(price.sub(7,price.len()-1));
 | 
			
		||||
        if (atoi(colonna) != 1)
 | 
			
		||||
          riga.add(colonna);
 | 
			
		||||
        TToken_string valori(key->get(1),',');
 | 
			
		||||
        riga.add(valori.get(0));
 | 
			
		||||
        riga.add(valori.get(1));
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    sf.check_row(i);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TAttivazione_moduli::save_masklistino(TMask &msklistino)
 | 
			
		||||
{
 | 
			
		||||
  TWait_cursor hourglass;
 | 
			
		||||
  TInstall_ini ini;
 | 
			
		||||
  ini.set_paragraph("Main");  
 | 
			
		||||
  ini.set("Listino",msklistino.get(F_DATALIST));
 | 
			
		||||
  TSheet_field& sf = (TSheet_field&)msklistino.field(F_MODULILIST);
 | 
			
		||||
  const int items=sf.items();
 | 
			
		||||
  for (int i = 0; i < items; i++)
 | 
			
		||||
  {
 | 
			
		||||
    TToken_string& riga = sf.row(i);
 | 
			
		||||
    TString tmpstr(riga.get(0));
 | 
			
		||||
    ini.set_paragraph(tmpstr);
 | 
			
		||||
    
 | 
			
		||||
    int nposti;
 | 
			
		||||
    for (int col=0; col < 6; col++)
 | 
			
		||||
    {
 | 
			
		||||
      const char * p=riga.get(3*col+2);
 | 
			
		||||
      if (p==NULL || (nposti=atoi(p))==0 )
 | 
			
		||||
        break;
 | 
			
		||||
      tmpstr = riga.get(3*col+3);
 | 
			
		||||
      if (tmpstr.blank())
 | 
			
		||||
        continue;
 | 
			
		||||
      tmpstr << ',' << riga.get(3*col+4);
 | 
			
		||||
      TString16 varname("Prezzo");
 | 
			
		||||
      varname << '(' << nposti << ')';
 | 
			
		||||
      ini.set(varname,tmpstr);
 | 
			
		||||
      if (ini.new_paragraph())
 | 
			
		||||
        ini.set("Descrizione",riga.get(1));
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int TAttivazione_moduli::build_sheet(bool on)
 | 
			
		||||
{
 | 
			
		||||
  int nmod = 0;
 | 
			
		||||
@ -738,15 +578,6 @@ bool TAttivazione_moduli::print_handler(TMask_field& fld, KEY key)
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
bool TAttivazione_moduli::printlist_handler(TMask_field& fld, KEY key)
 | 
			
		||||
{
 | 
			
		||||
  if (key == K_SPACE)
 | 
			
		||||
    app().print_listino();
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
bool TAttivazione_moduli::aga_handler(TMask_field& fld, KEY key)
 | 
			
		||||
{
 | 
			
		||||
  if (key == K_SPACE)        
 | 
			
		||||
@ -850,47 +681,6 @@ bool TAttivazione_moduli::k_notify(TSheet_field& f, int r, KEY k)
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
bool TAttivazione_moduli::modifica_listino_handler(TMask_field& fld, KEY key)
 | 
			
		||||
{       
 | 
			
		||||
  if (key == K_SPACE)
 | 
			
		||||
    app().update_listino();
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
bool TAttivazione_moduli::aggiorna_listino_handler(TMask_field& fld, KEY key)
 | 
			
		||||
{       
 | 
			
		||||
  bool ok = true;
 | 
			
		||||
  if (key == K_SPACE)
 | 
			
		||||
  {
 | 
			
		||||
    TInstall_ini ini;    
 | 
			
		||||
    TFilename name = ini.get("DiskPath");
 | 
			
		||||
    name.add(ini.default_name());
 | 
			
		||||
    while (!name.exist())
 | 
			
		||||
    {
 | 
			
		||||
      TMask msk(TR("Aggiornamento listino"), 1, -1, -1, 60, 4);
 | 
			
		||||
      msk.add_string(DLG_USER, 0, PR("Percorso "), 1, 1, 50);
 | 
			
		||||
      msk.add_button(DLG_CANCEL, 0, "", -12, -1, 10, 2);
 | 
			
		||||
      msk.add_button(DLG_OK, 0, "", -22, -1, 10, 2);
 | 
			
		||||
      msk.set(DLG_USER, name);
 | 
			
		||||
      if (msk.run() == K_ENTER)
 | 
			
		||||
        name = msk.get(DLG_USER);
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        ok = false;
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    if (ok)
 | 
			
		||||
    {
 | 
			
		||||
      if (ok = ini.update_prices(name))
 | 
			
		||||
        message_box(TR("Listino aggiornato"));
 | 
			
		||||
      else
 | 
			
		||||
        message_box(TR("Listino già aggiornato"));
 | 
			
		||||
    }
 | 
			
		||||
  }  
 | 
			
		||||
  return ok;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TAttivazione_moduli::print_request()
 | 
			
		||||
{
 | 
			
		||||
  TRequest_form form("ba1500a");
 | 
			
		||||
@ -1147,13 +937,6 @@ bool TAttivazione_moduli::create()
 | 
			
		||||
    return error_box(TR("Questo programma non puo' funzionare mentre e' in funzione il server di autorizzazioni"));
 | 
			
		||||
    
 | 
			
		||||
  ok = TApplication::test_assistance_year();
 | 
			
		||||
#ifdef DBG
 | 
			
		||||
  // Backdoor nascosta per la cifratura del dninst.zip
 | 
			
		||||
  // Mettere nella cartella dei programi il file dninst.txt ...
 | 
			
		||||
  // ... e nascera' in automagico il file dninst.zip per Luca
 | 
			
		||||
  if (ok && argc() > 2 && strcmp(argv(2), "-dninst") == 0)
 | 
			
		||||
    ok = false;
 | 
			
		||||
#endif
 | 
			
		||||
  if (!ok)
 | 
			
		||||
  {
 | 
			
		||||
    ok = update_assistance_year();
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										129
									
								
								ba/ba1501.cpp
									
									
									
									
									
								
							
							
						
						
									
										129
									
								
								ba/ba1501.cpp
									
									
									
									
									
								
							@ -1,75 +1,16 @@
 | 
			
		||||
#include <applicat.h>
 | 
			
		||||
#include <config.h>
 | 
			
		||||
#include <dongle.h>
 | 
			
		||||
#include <modaut.h>
 | 
			
		||||
#include <scanner.h>
 | 
			
		||||
#include <utility.h>
 | 
			
		||||
 | 
			
		||||
#include "ba1500.h"
 | 
			
		||||
 | 
			
		||||
HIDDEN void build_key(char* dninst_key)
 | 
			
		||||
{         
 | 
			
		||||
  for (int i = 0; i < 8; i++)  
 | 
			
		||||
    dninst_key[i] = 'A'+ rand() % 26;
 | 
			
		||||
}
 | 
			
		||||
  
 | 
			
		||||
HIDDEN void decode_string(char* dninst_key, char* data)
 | 
			
		||||
{                             
 | 
			
		||||
  build_key(dninst_key);
 | 
			
		||||
	char tmp[1024];
 | 
			
		||||
  int i;
 | 
			
		||||
  for (i = 0; data[i]; i++)
 | 
			
		||||
    tmp[i] = data[i] - (i < 8 ? dninst_key[i] : tmp[i - 8]);
 | 
			
		||||
  tmp[i] = '\0';
 | 
			
		||||
  strcpy(data, tmp); 
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef DBG
 | 
			
		||||
 | 
			
		||||
HIDDEN void encode_string(char* dninst_key, char* data)
 | 
			
		||||
{      
 | 
			
		||||
  build_key(dninst_key);
 | 
			
		||||
  
 | 
			
		||||
	char tmp[1024];
 | 
			
		||||
  int i;
 | 
			
		||||
  for (i = 0; data[i]; i++)
 | 
			
		||||
    tmp[i] = data[i] + (i < 8 ? dninst_key[i] : data[i - 8]);
 | 
			
		||||
  tmp[i] = '\0';
 | 
			
		||||
  strcpy(data, tmp); 
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
HIDDEN bool build_dninst()
 | 
			
		||||
{
 | 
			
		||||
  ifstream inf("dninst.txt", ios::in);
 | 
			
		||||
  if (inf.good())
 | 
			
		||||
  {                   
 | 
			
		||||
    char dninst_key[8] = "";
 | 
			
		||||
  
 | 
			
		||||
    ofstream ouf("dninst.zip", ios::out | ios::binary);
 | 
			
		||||
    char line[256];
 | 
			
		||||
    inf.getline(line, sizeof(line));
 | 
			
		||||
    const int year = atoi(line);
 | 
			
		||||
    CHECKD(year >= 2091 && year <= 3000, "Anno errato:", year);
 | 
			
		||||
    srand(883);  // Inizializza generatore numeri casuali per l'anno
 | 
			
		||||
    encode_string(dninst_key, line);
 | 
			
		||||
    ouf << line << '\n';
 | 
			
		||||
    srand(year); // Inizializza generatore numeri casuali per i moduli
 | 
			
		||||
 | 
			
		||||
    while (!inf.eof())
 | 
			
		||||
    {
 | 
			
		||||
      inf.getline(line, sizeof(line));
 | 
			
		||||
      encode_string(dninst_key, line);
 | 
			
		||||
      ouf << line << '\n';
 | 
			
		||||
    }
 | 
			
		||||
    return true;
 | 
			
		||||
  } 
 | 
			
		||||
  return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
const char* split_ass(const int ass_year)
 | 
			
		||||
{
 | 
			
		||||
	int year = ass_year, number = 0;
 | 
			
		||||
	if (ass_year > 2008)
 | 
			
		||||
	if (ass_year >= 2009)
 | 
			
		||||
	{
 | 
			
		||||
		year = (ass_year/1000)*1000 + (ass_year%1000)/10;
 | 
			
		||||
		number = ass_year%10;
 | 
			
		||||
@ -82,7 +23,6 @@ const char* split_ass(const int ass_year)
 | 
			
		||||
	return tmp;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
HIDDEN bool show_error(const char* str)
 | 
			
		||||
{
 | 
			
		||||
  int app_year, dum1, dum2, dum3;
 | 
			
		||||
@ -97,14 +37,6 @@ HIDDEN bool show_error(const char* str)
 | 
			
		||||
// Copia il file dninst.zip dal CD/server alla cartella corrente
 | 
			
		||||
bool update_dninst(bool force)
 | 
			
		||||
{                             
 | 
			
		||||
#ifdef DBG
 | 
			
		||||
  if (force && main_app().argc() > 2 && strcmp(main_app().argv(2), "-dninst") == 0)
 | 
			
		||||
  {
 | 
			
		||||
    build_dninst();
 | 
			
		||||
    return true;
 | 
			
		||||
  }
 | 
			
		||||
#endif  
 | 
			
		||||
 | 
			
		||||
	//legge dal diskpath di install.ini la directory da cui aggiornarsi;se il dninst.zip di tale..
 | 
			
		||||
	//..directory e' piu' nuovo di quello in locale -> lo copia in locale
 | 
			
		||||
	const TFilename local_name = "setup/dninst.zip";
 | 
			
		||||
@ -134,59 +66,50 @@ bool update_dninst(bool force)
 | 
			
		||||
 | 
			
		||||
bool update_assistance_year()
 | 
			
		||||
{
 | 
			
		||||
  if (dongle().hardware() == _dongle_network)
 | 
			
		||||
  {
 | 
			
		||||
    show_error(TR("Il server di autorizzazioni deve essere disattivato"));
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
  TDongle& donkey = dongle();
 | 
			
		||||
  if (donkey.hardware() == _dongle_network)
 | 
			
		||||
    return show_error(TR("Il server di autorizzazioni deve essere disattivato"));
 | 
			
		||||
 | 
			
		||||
  update_dninst(true);
 | 
			
		||||
 | 
			
		||||
  const TFilename dninst = "setup/dninst.zip";
 | 
			
		||||
  if (dninst.exist())
 | 
			
		||||
  Tdninst dninst;
 | 
			
		||||
  const int dninst_year = dninst.assist_year();
 | 
			
		||||
  if (dninst_year > 0)
 | 
			
		||||
  {
 | 
			
		||||
    char dninst_key[8] = "";
 | 
			
		||||
 | 
			
		||||
    TScanner keys(dninst);  
 | 
			
		||||
    TString& anno = keys.line();
 | 
			
		||||
    srand(883);
 | 
			
		||||
    decode_string(dninst_key, anno.get_buffer());
 | 
			
		||||
    const int ass_year = atoi(anno);
 | 
			
		||||
    //se l'anno di assistenza della versione (dninst.zip) e' piu' grande di quello attualmente registrato sulla...
 | 
			
		||||
    //...chiavetta controlla se il serialnumber della chiavetta e' presente nella lista dei codici...
 | 
			
		||||
    //...validi dentro il dninst.zip
 | 
			
		||||
    if (ass_year > dongle().year_assist())
 | 
			
		||||
    if (dninst_year > donkey.year_assist())
 | 
			
		||||
    {
 | 
			
		||||
      const int serno = get_serial_number();
 | 
			
		||||
      srand(ass_year);
 | 
			
		||||
      while (!keys.eof())
 | 
			
		||||
      TToken_string to_be_killed;
 | 
			
		||||
      if (dninst.find_killed(to_be_killed))
 | 
			
		||||
      {
 | 
			
		||||
        TString& line = keys.line();
 | 
			
		||||
        if (line.empty())
 | 
			
		||||
          break;
 | 
			
		||||
        decode_string(dninst_key, line.get_buffer());
 | 
			
		||||
        const int sn = atoi(line);
 | 
			
		||||
        if (sn == serno || line[0] == '*')
 | 
			
		||||
        donkey.set_year_assist(dninst_year);
 | 
			
		||||
        FOR_EACH_TOKEN(to_be_killed, mod)
 | 
			
		||||
        {
 | 
			
		||||
          dongle().set_year_assist(ass_year);
 | 
			
		||||
          if (dongle().burn())
 | 
			
		||||
          if (strlen(mod) == 2)
 | 
			
		||||
          {
 | 
			
		||||
            return true;  //Complimenti,la chiavetta e' presente nella lista e sara' aggiornato l'anno di assistenza
 | 
			
		||||
            const word aut = donkey.module_name2code(mod);
 | 
			
		||||
            if (aut > BAAUT && aut < ENDAUT)
 | 
			
		||||
              donkey.deactivate(aut);
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
        if (donkey.burn())
 | 
			
		||||
          return true;  // Complimenti,la chiavetta e' presente nella lista e sara' aggiornato l'anno di assistenza
 | 
			
		||||
        else
 | 
			
		||||
          return show_error(FR("Errore di scrittura sulla chiave di protezione"));
 | 
			
		||||
      } //if(sn==serno...
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
            show_error(FR("Errore di scrittura sulla chiave di protezione"));
 | 
			
		||||
            return false;
 | 
			
		||||
          } //if(dongle().burn...
 | 
			
		||||
        } //if(sn==serno...
 | 
			
		||||
      } //while(!keys.eof()...
 | 
			
		||||
        //Non e' riuscito a trovare la chiavetta nell'elenco, non puo' aggiornare automaticamente
 | 
			
		||||
        show_error(TR("Il numero di serie di questa postazione non è presente sul database"));
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    else  //if(ass_year>dongle...
 | 
			
		||||
    {
 | 
			
		||||
      //Se l'anno di assistenza sulla chiave e' maggiore di quello sul dninst segnala l'incongruenza e poi?
 | 
			
		||||
      if (ass_year < dongle().year_assist())
 | 
			
		||||
      if (dninst_year < donkey.year_assist())
 | 
			
		||||
        show_error(TR("L'anno di assistenza sul database e' inferiore a quello registrato sulla chiave di protezione"));
 | 
			
		||||
      //Se l'anno di assistenza coincide con quello sulla chiave -> la chiave ha gia' l'assistenza...
 | 
			
		||||
      //...corretta abilitata e puo' proseguire l'aggiornamento
 | 
			
		||||
 | 
			
		||||
@ -1931,7 +1931,10 @@ long TFascicolator_mask::find_signature(const TFilename& filename, const char* s
 | 
			
		||||
    if (car == signature[compare])
 | 
			
		||||
    {            
 | 
			
		||||
      if (compare == 0)
 | 
			
		||||
        position = infile.tellg()-1L;
 | 
			
		||||
      {
 | 
			
		||||
        position = infile.tellg();
 | 
			
		||||
        position--;
 | 
			
		||||
      }
 | 
			
		||||
      compare++;
 | 
			
		||||
      if (signature[compare] == '\0')
 | 
			
		||||
      {
 | 
			
		||||
 | 
			
		||||
@ -194,7 +194,7 @@ bool TInstaller_mask::is_visible_patch(TConfig& ini) const
 | 
			
		||||
      // Pezza temporanea: assegno OEM noti
 | 
			
		||||
      switch (mod)
 | 
			
		||||
      {
 | 
			
		||||
      case LVAUT: oem = "2,4"; break;
 | 
			
		||||
      case LVAUT: oem = "2"; break;
 | 
			
		||||
      case PEAUT: oem = "3"; break;
 | 
			
		||||
      case COAUT: oem = "5"; break;
 | 
			
		||||
      default: break;
 | 
			
		||||
@ -427,9 +427,16 @@ bool TInstaller_mask::autoload()
 | 
			
		||||
    //se si ritrova dei vecchi file nella directory temporanea, la pulisce per evitare casini
 | 
			
		||||
    ininame = path; ininame.add("*.*");
 | 
			
		||||
    TString_array list;
 | 
			
		||||
    ::list_files(ininame, list);
 | 
			
		||||
    const int cache_files = ::list_files(ininame, list);
 | 
			
		||||
    if (cache_files > 0)
 | 
			
		||||
    {
 | 
			
		||||
      TProgind pi(cache_files, TR("Azzeramento cache"), false, true);
 | 
			
		||||
      FOR_EACH_ARRAY_ROW(list, i, row)
 | 
			
		||||
      {
 | 
			
		||||
        pi.addstatus(1);
 | 
			
		||||
        xvt_fsys_remove_file(*row);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ininame = path;
 | 
			
		||||
    ininame.add(TInstall_ini::default_name());
 | 
			
		||||
@ -437,9 +444,25 @@ bool TInstaller_mask::autoload()
 | 
			
		||||
    {
 | 
			
		||||
      TFilename remote_ini = http_path;
 | 
			
		||||
			remote_ini << TInstall_ini::default_name();
 | 
			
		||||
 | 
			
		||||
      if (remote_ini.full()) // dummy test
 | 
			
		||||
      {
 | 
			
		||||
        TTimerind contacting(30*1000, TR("Connessione al server HTTP..."), false, false);
 | 
			
		||||
        http_get(http_server, remote_ini, ininame);
 | 
			
		||||
 | 
			
		||||
        // Cerca di prelevare anche dninst.zip
 | 
			
		||||
        const char* const local_dninst = "setup/dninst.zip";
 | 
			
		||||
        TFilename remote_dninst = http_path;
 | 
			
		||||
        remote_dninst << local_dninst;
 | 
			
		||||
        if (!http_get(http_server, remote_dninst, local_dninst))
 | 
			
		||||
        {
 | 
			
		||||
          // Se non aggiorno da release riprovo con l'indirizzo dell'OEM
 | 
			
		||||
          remote_dninst = http_default_path();
 | 
			
		||||
          remote_dninst << local_dninst;
 | 
			
		||||
          const int slash = remote_dninst.find('/');
 | 
			
		||||
          if (slash > 0)
 | 
			
		||||
            http_get(remote_dninst.left(slash), remote_dninst.mid(slash), local_dninst);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  } //if(internet...
 | 
			
		||||
 | 
			
		||||
@ -509,16 +509,16 @@ TFields_sheet::~TFields_sheet()
 | 
			
		||||
bool TWizard_mask::file_open(TFilename& fname) const
 | 
			
		||||
{
 | 
			
		||||
  DIRECTORY dir; 
 | 
			
		||||
  FILE_SPEC fs;
 | 
			
		||||
  xvt_fsys_get_dir(&dir); // Save dir
 | 
			
		||||
 | 
			
		||||
  xvt_fsys_get_dir(&dir);
 | 
			
		||||
  xvt_fsys_get_dir(&fs.dir);
 | 
			
		||||
  FILE_SPEC fs;
 | 
			
		||||
  fs.dir = dir;
 | 
			
		||||
  strcpy(fs.type, fname.ext());
 | 
			
		||||
  strcpy(fs.name, fname);
 | 
			
		||||
  strcpy(fs.creator, "WIZ");
 | 
			
		||||
    
 | 
			
		||||
  const bool good = xvt_dm_post_file_open(&fs, TR("Selezionare il file ...")) == FL_OK;
 | 
			
		||||
  xvt_fsys_set_dir(&dir);
 | 
			
		||||
  xvt_fsys_set_dir(&dir); // Restore dir
 | 
			
		||||
                 
 | 
			
		||||
  if (good)                 
 | 
			
		||||
    fname = fs.name;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user