Programmi dimostrativi

Per ottenere una versione demo dei programmi si devono ricompilare i programmi
definendo il simbolo _DEMO_.
I files modificati sono:
applicat.cpp applicat.h isam.cpp maskfld.cpp stdtypes.cpp.
Le limitazioni riguardano le date, il numero di record in archivio,
una limitazione a due ore del tempo di utilizzo del programma e l'eliminazione
del possibilita' di usare una ditta diversa dalla 1.


git-svn-id: svn://10.65.10.50/trunk@5682 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1997-12-02 11:57:26 +00:00
parent 2c508021b5
commit 56de750d9f
4 changed files with 112 additions and 12 deletions

@ -7,7 +7,7 @@
#if XVT_OS == XVT_OS_WIN
#include <toolhelp.h>
#endif
#include <applicat.h>
#include <colors.h>
#include <config.h>
@ -159,6 +159,32 @@ long XVT_CALLCONV1 TApplication::task_eh(WINDOW win, EVENT *ep)
case E_CREATE:
if (_application->pre_create())
{
#ifdef _DEMO_
{
const TString16 dname(encode("DATA"));
const TString16 hname(encode("ORA"));
TConfig c(CONFIG_STUDIO, "Main");
TDate data(decode(c.get(dname)));
TDate oggi(TODAY);
real remaining_time(decode(c.get(hname)));
main_app()._start_time = time(NULL);
if (data < oggi)
{
data = oggi;
c.set(dname, encode(data));
c.set(hname, encode("120.00"));
}
else
if (data == oggi)
{
if (remaining_time <= ZERO)
exit(0);
}
else
exit(0);
}
#endif
TTemp_window tw(win);
TString cap;
cap << prassi_spa() << " - " << main_app().get_module_name();
@ -285,6 +311,25 @@ long TApplication::handler(WINDOW win, EVENT* ep)
void TApplication::stop_run()
{
if (_savefirm) prefix().set_codditta(_savefirm);
#ifdef _DEMO_
{
const TString16 hname(encode("ORA"));
TConfig c(CONFIG_STUDIO, "Main");
real remaining_time(decode(c.get(hname)));
if (name() != "ba0100")
{
time_t wt = time(NULL);
int delay = (int) (wt - _start_time);
if (delay < 0)
remaining_time = ZERO;
else
remaining_time -= (delay / 60.0);
c.set(hname, encode(remaining_time.string()));
}
else
message_box("Questo e' un programma dimostrativo.\n Oggi ti rimangono %s minuti di utilizzo.", remaining_time.string(3, 0));
}
#endif
terminate();
xvt_app_destroy();
}
@ -342,6 +387,7 @@ HIDDEN void wake_up_caller()
void TApplication::terminate()
{
wake_up_caller();
close_all_dialogs();
@ -393,14 +439,16 @@ const char* TApplication::get_module_name() const
void TApplication::set_perms()
{
{
#ifndef _DEMO_
_dongle_aut.set(0, TRUE);
for (int i = 1 ; i < ENDAUT; i++)
{
const int af = i - 1;
const bool val = BITTEST(_int_tab0[af / 16], af % 16);
_dongle_aut.set(i, val);
}
}
#endif
_user_aut.set(0, TRUE);
const TString& utente = user();
@ -585,10 +633,12 @@ void TApplication::end_wait()
}
bool TApplication::has_module(int module, int checktype) const
{
{
bool ok = TRUE;
#ifndef _DEMO_
if (checktype == CHK_ALL || checktype == CHK_DONGLE)
ok = _dongle_aut[module];
#endif
if (ok && checktype == CHK_ALL || checktype == CHK_USER)
ok = _user_aut[module];
return ok;
@ -610,6 +660,7 @@ bool TApplication::set_firm(long newfirm)
{
const long oldfirm = get_firm();
#ifndef _DEMO_
if (newfirm < 1)
{
TMask mask("bagn002");
@ -638,6 +689,7 @@ bool TApplication::set_firm(long newfirm)
}
}
}
#endif
if (newfirm == oldfirm || newfirm < 1)
return newfirm > 0;
@ -745,6 +797,9 @@ bool TApplication::firm_change_enabled() const
// @comm Praticamente controlla se e' stato lanciato da ba0 o dal program manager
{
#ifdef _DEMO_
return FALSE;
#else
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
static bool can = 2;
if (can == 2)
@ -769,7 +824,8 @@ bool TApplication::firm_change_enabled() const
#else
return TRUE;
#endif
}
#endif
}
void TApplication::on_firm_change()
{}

@ -32,9 +32,13 @@ class TApplication
// @cmember:(INTERNAL) Numero di argomenti passati all'applicazione
int __argc;
// @cmember:(INTERNAL) Array di argomenti passati all'applicazione
const char** __argv;
const char** __argv;
#ifdef _DEMO_
time_t _start_time;
#else
// @cmember:(INTERNAL) Array di autorizzazione concessa della chiavi
TBit_array _dongle_aut;
#endif
// @cmember:(INTERNAL) Array di autorizzazione concessa all'utente
TBit_array _user_aut;

@ -2,7 +2,7 @@
#define XVT_INCL_NATIVE
#include <xvt.h>
#include <applicat.h>
#include <applicat.h>
#include <colors.h>
#include <controls.h>
#include <defmask.h>
@ -3294,14 +3294,33 @@ bool TDate_field::on_key(KEY key)
{
const TString& data = get_window_data();
if (data.not_empty()) // data not empty
{
{
if (!TDate::isdate(data))
{
error_box("Data errata o formato non valido");
return FALSE;
}
else
{
#ifdef _DEMO_
TDate d(data);
int y = d.year();
if (y & 0x0001) y--;
y >>= 3;
y++;
y /= 10;
if (y >= 25)
{
int m = d.month();
if (m > 3)
d.set_month(rand() % 3 + 1);
}
set_window_data(d.string());
#else
set_window_data(data);
#endif
}
}
}
else
@ -3322,6 +3341,23 @@ bool TDate_field::autosave(TRelation& r)
if (field())
{
const char* td = get();
#ifdef _DEMO_
{
TDate d(td);
int y = d.year();
y += 8;
y /= 25;
y >>= 3;
if (y >= 10)
{
int m = d.month() >> 2;
if (m > 0)
d.set_month(rand() % 3 + 1);
}
td = d.string();
}
#endif
if (right_justified())
{
TDate d(td);

@ -6,7 +6,7 @@
#include <extcdecl.h>
#include <conf.h>
#include <modaut.h>
#include <isamrpc.h>
#include <isamrpc.h>
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
#include <dos.h>
@ -16,7 +16,7 @@
#include <applicat.h>
#include <isam.h>
#include <prefix.h>
#include <codeb.h>
#include <codeb.h>
extern isfdptr *openf;
extern isfdptr *ext_files;
@ -40,7 +40,10 @@ static int _login_status = 0;
//
// @rdesc Numero di serie della chiave
int get_serial_number(const char* appname)
{
{
#ifdef _DEMO_
return 0;
#else
if (_login_status == 0)
{
if (HL_LOGIN(ModAd, DONT_CARE, REFKEY, VERKEY) == STATUS_OK)
@ -79,13 +82,14 @@ int get_serial_number(const char* appname)
}
return SerNo;
#endif
}
// @doc INTERNAL
// @func Inizilizza le variabili globali
void init_global_vars()
{
{
TPrefix& pref = prefix_init();
pref.set("");