Patch level : 10.0
Files correlati : xvaga.dll Ricompilazione Demo : [ ] Commento : Supporto per marcatura temporale in sede di firma digitale git-svn-id: svn://10.65.10.50/trunk@18894 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
9bd3d6ed94
commit
42d5e4207c
217
xvaga/xvt_type.h
217
xvaga/xvt_type.h
@ -335,53 +335,36 @@ XVT_COLOR_ACTION_UNSET/* unset the colors */
|
||||
} XVT_COLOR_ACTION;
|
||||
|
||||
typedef struct s_win_def {
|
||||
|
||||
WIN_TYPE wtype; /* WC_* or WO_* type */
|
||||
|
||||
RCT rct;
|
||||
char *text;
|
||||
UNIT_TYPE units;
|
||||
XVT_COLOR_COMPONENT * ctlcolors;
|
||||
union {
|
||||
|
||||
struct s_win_def_win { /* WINDOW's */
|
||||
|
||||
short int menu_rid; /* menu resource id */
|
||||
MENU_ITEM *menu_p; /* pointer to menu tree */
|
||||
long flags; /* WSF_* flags */
|
||||
XVT_FNTID ctl_font_id; /* control font id */
|
||||
|
||||
} win;
|
||||
|
||||
struct s_win_def_dlg { /* DIALOG's */
|
||||
|
||||
long flags; /* WSF_* flags */
|
||||
XVT_FNTID ctl_font_id; /* control font id */
|
||||
|
||||
} dlg;
|
||||
|
||||
struct s_win_def_ctl { /* CONTROL's */
|
||||
|
||||
short int ctrl_id;
|
||||
|
||||
short int icon_id; /* for icons only */
|
||||
long flags; /* CTL_* flags */
|
||||
XVT_FNTID font_id; /* logical font */
|
||||
|
||||
} ctl;
|
||||
|
||||
struct s_win_def_tx { /* text edit objects */
|
||||
|
||||
unsigned short attrib; /* TX_* flags */
|
||||
XVT_FNTID font_id; /* logical font */
|
||||
short margin; /* right margin */
|
||||
short limit; /* max chars */
|
||||
short int tx_id; /* text ID */
|
||||
|
||||
} tx;
|
||||
|
||||
} v;
|
||||
|
||||
WIN_TYPE wtype; /* WC_* or WO_* type */
|
||||
RCT rct;
|
||||
char *text;
|
||||
UNIT_TYPE units;
|
||||
XVT_COLOR_COMPONENT * ctlcolors;
|
||||
union {
|
||||
struct s_win_def_win { /* WINDOW's */
|
||||
short int menu_rid; /* menu resource id */
|
||||
MENU_ITEM *menu_p; /* pointer to menu tree */
|
||||
long flags; /* WSF_* flags */
|
||||
XVT_FNTID ctl_font_id; /* control font id */
|
||||
} win;
|
||||
struct s_win_def_dlg { /* DIALOG's */
|
||||
long flags; /* WSF_* flags */
|
||||
XVT_FNTID ctl_font_id; /* control font id */
|
||||
} dlg;
|
||||
struct s_win_def_ctl { /* CONTROL's */
|
||||
short int ctrl_id;
|
||||
short int icon_id; /* for icons only */
|
||||
long flags; /* CTL_* flags */
|
||||
XVT_FNTID font_id; /* logical font */
|
||||
} ctl;
|
||||
struct s_win_def_tx { /* text edit objects */
|
||||
unsigned short attrib; /* TX_* flags */
|
||||
XVT_FNTID font_id; /* logical font */
|
||||
short margin; /* right margin */
|
||||
short limit; /* max chars */
|
||||
short int tx_id; /* text ID */
|
||||
} tx;
|
||||
} v;
|
||||
} WIN_DEF;
|
||||
|
||||
typedef enum {
|
||||
@ -405,89 +388,69 @@ E_TIMER, /* timer */
|
||||
E_QUIT, /* application shutdown request */
|
||||
E_HELP, /* help invoked */
|
||||
E_USER, /* user defined */
|
||||
E_CXO, /* cxo event */
|
||||
} EVENT_TYPE;
|
||||
|
||||
|
||||
typedef struct s_event {
|
||||
|
||||
EVENT_TYPE type;
|
||||
union {
|
||||
|
||||
struct s_mouse {
|
||||
|
||||
PNT where;
|
||||
BOOLEAN shift;
|
||||
BOOLEAN control;
|
||||
short button;
|
||||
|
||||
} mouse;
|
||||
struct s_char {
|
||||
|
||||
XVT_WCHAR ch;
|
||||
BOOLEAN shift;
|
||||
BOOLEAN control;
|
||||
BOOLEAN virtual_key;
|
||||
unsigned long modifiers;
|
||||
|
||||
} chr;
|
||||
BOOLEAN active;
|
||||
BOOLEAN query;
|
||||
struct s_scroll_info {
|
||||
|
||||
SCROLL_CONTROL what;
|
||||
short pos;
|
||||
|
||||
} scroll;
|
||||
struct s_cmd {
|
||||
|
||||
MENU_TAG tag;
|
||||
BOOLEAN shift;
|
||||
BOOLEAN control;
|
||||
|
||||
} cmd;
|
||||
struct s_size {
|
||||
|
||||
short height;
|
||||
short width;
|
||||
|
||||
} size;
|
||||
struct s_efont {
|
||||
|
||||
XVT_FNTID font_id;
|
||||
|
||||
} font;
|
||||
struct s_ctl {
|
||||
|
||||
short id;
|
||||
CONTROL_INFO ci;
|
||||
|
||||
} ctl;
|
||||
struct s_update {
|
||||
|
||||
RCT rct;
|
||||
|
||||
} update;
|
||||
struct s_timer {
|
||||
|
||||
long id;
|
||||
|
||||
} timer;
|
||||
struct s_user {
|
||||
|
||||
long id;
|
||||
void *ptr;
|
||||
|
||||
} user;
|
||||
struct s_help {
|
||||
|
||||
WINDOW obj;
|
||||
MENU_TAG tag;
|
||||
XVT_HELP_TID tid;
|
||||
|
||||
}help;
|
||||
|
||||
} v;
|
||||
|
||||
} EVENT;
|
||||
EVENT_TYPE type;
|
||||
union _v {
|
||||
struct s_mouse { /* E_MOUSE_DOWN, E_MOUSE_UP, E_MOUSE_MOVE, E_MOUSE_DBL */
|
||||
PNT where; /* location of event (window relative) */
|
||||
BOOLEAN shift; /* shift key down? */
|
||||
BOOLEAN control; /* control or option key down? */
|
||||
short button; /* button number */
|
||||
} mouse;
|
||||
struct s_char { /* E_CHAR */
|
||||
XVT_WCHAR ch; /* wide character */
|
||||
BOOLEAN shift; /* shift key down? */
|
||||
BOOLEAN control; /* control or option key down? */
|
||||
BOOLEAN virtual_key; /* ch contains virtual key or not? */
|
||||
unsigned long modifiers; /* bit field of key modifiers */
|
||||
} chr;
|
||||
BOOLEAN active; /* E_FOCUS: activation? (vs. deactivation) */
|
||||
BOOLEAN query; /* E_QUIT: query only? (app calls quit_OK) */
|
||||
struct s_scroll_info { /* E_VSCROLL, E_HSCROLL */
|
||||
SCROLL_CONTROL what; /* site of activity */
|
||||
short pos; /* thumb position, if SC_THUMB */
|
||||
} scroll;
|
||||
struct s_cmd { /* E_COMMAND */
|
||||
MENU_TAG tag; /* menu item tag */
|
||||
BOOLEAN shift; /* shift key? */
|
||||
BOOLEAN control; /* control or option key? */
|
||||
} cmd;
|
||||
struct s_size { /* E_SIZE */
|
||||
short height; /* new height */
|
||||
short width; /* new width */
|
||||
} size;
|
||||
struct s_efont { /* E_FONT */
|
||||
XVT_FNTID font_id; /* R4 font id of selected font */
|
||||
} font;
|
||||
struct s_ctl { /* E_CONTROL */
|
||||
short id; /* control's ID */
|
||||
CONTROL_INFO ci; /* control info */
|
||||
} ctl;
|
||||
struct s_update { /* E_UPDATE */
|
||||
RCT rct; /* update rectangle */
|
||||
} update;
|
||||
struct s_timer { /* E_TIMER */
|
||||
long id; /* timer ID */
|
||||
} timer;
|
||||
struct s_user { /* E_USER */
|
||||
long id; /* application ID */
|
||||
void *ptr; /* application pointer */
|
||||
} user;
|
||||
struct s_help { /* E_HELP */
|
||||
WINDOW obj; /* help for control, window, dialog */
|
||||
MENU_TAG tag; /* help for menu item */
|
||||
XVT_HELP_TID tid; /* predefined help topic */
|
||||
} help;
|
||||
struct s_cxo { /* E_CXO */
|
||||
long msg_id; /* CXO message id - Unique to each CXO */
|
||||
void * ptr; /* message data pointer */
|
||||
} cxo;
|
||||
} v;
|
||||
} EVENT, *EVENT_PTR;
|
||||
|
||||
typedef unsigned long EVENT_MASK;
|
||||
typedef long (* EVENT_HANDLER) (WINDOW win, EVENT *ep);
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <wx/treectrl.h>
|
||||
#include <wx/vlbox.h>
|
||||
#include <wx/aui/aui.h>
|
||||
#include <wx/propgrid/propgrid.h>
|
||||
#include <wx/propgrid/propgrid.h>
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Utility functions
|
||||
@ -2183,7 +2183,6 @@ void TwxPropertyGrid::SetColors(const XVT_COLOR_COMPONENT* colors)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TwxPropertyGrid::OnPropertyChanged(wxPropertyGridEvent& evt)
|
||||
{
|
||||
TwxWindow* win = wxDynamicCast(GetParent(), TwxWindow);
|
||||
@ -2242,7 +2241,10 @@ static wxColour STR2COLOUR(const char* value)
|
||||
if (n == 3)
|
||||
col = wxColour(r, g, b);
|
||||
else
|
||||
col = wxColour(r & 0xFFFFFF);
|
||||
{
|
||||
CAST_COLOR(r, w); // NON usare wxColour(r) in quanto si aspetta un numero in formato BGR
|
||||
col = w;
|
||||
}
|
||||
}
|
||||
else
|
||||
col = wxColour(value); // Black, White, Yellow, ...
|
||||
@ -2353,10 +2355,8 @@ int xvt_prop_get_data(WINDOW win, XVT_TREEVIEW_NODE node, char* value, int maxle
|
||||
if (strType == "wxColour")
|
||||
{
|
||||
strType = "color";
|
||||
int r, g, b; wxSscanf(str, "(%d,%d,%d)", &r, &g, &b);
|
||||
COLOR rgb = XVT_MAKE_COLOR(r, g, b);
|
||||
if (rgb == 0) rgb = COLOR_BLACK;
|
||||
str.Printf("%ld", rgb);
|
||||
str.RemoveLast(1); // Toglie la )
|
||||
str.Remove(0, 1); // Toglie la (
|
||||
}
|
||||
len = str.Len();
|
||||
if (value != NULL && maxlen > 0)
|
||||
@ -2368,3 +2368,4 @@ int xvt_prop_get_data(WINDOW win, XVT_TREEVIEW_NODE node, char* value, int maxle
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
|
@ -1072,7 +1072,7 @@ int xvt_fsys_get_campo_stp_value(const char* name, char* value, int valsize)
|
||||
int len = xvt_sys_get_profile_string(stpfile, para, "Program", "", path, sizeof(path));
|
||||
if (len <= 0)
|
||||
break;
|
||||
if (path[len-1] == '\\' || path[len-1] == '/')
|
||||
if (wxEndsWithPathSeparator(path))
|
||||
{
|
||||
len--;
|
||||
path[len] = '\0';
|
||||
@ -1202,6 +1202,74 @@ BOOLEAN xvt_fsys_file_md5(const char* path, char* outstr)
|
||||
// Gestione firma digitale
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TwxSignatureDlg : public wxDialog
|
||||
{
|
||||
private:
|
||||
virtual bool TransferDataToWindow();
|
||||
virtual bool TransferDataFromWindow();
|
||||
|
||||
protected:
|
||||
wxTextCtrl* AddString(wxSizer* ctlSizer, int id, const char* label,
|
||||
wxString* str, int nFlags = 0);
|
||||
|
||||
public:
|
||||
wxString m_strUser, m_strPIN;
|
||||
bool m_bMark;
|
||||
|
||||
TwxSignatureDlg();
|
||||
};
|
||||
|
||||
bool TwxSignatureDlg::TransferDataToWindow()
|
||||
{
|
||||
FindWindowById(1001, this)->SetLabel(m_strUser);
|
||||
// FindWindowById(1002, this)->SetLabel(m_strPin); // Non riproporre
|
||||
wxCheckBox* cb = wxStaticCast(FindWindowById(1003, this), wxCheckBox);
|
||||
cb->SetValue(m_bMark);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TwxSignatureDlg::TransferDataFromWindow()
|
||||
{
|
||||
m_strUser = FindWindowById(1001, this)->GetLabel();
|
||||
m_strPIN = FindWindowById(1002, this)->GetLabel();
|
||||
wxCheckBox* cb = wxStaticCast(FindWindowById(1003, this), wxCheckBox);
|
||||
m_bMark = cb->IsEnabled() && cb->GetValue();
|
||||
return !m_strUser.IsEmpty() && !m_strPIN.IsEmpty();
|
||||
}
|
||||
|
||||
wxTextCtrl* TwxSignatureDlg::AddString(wxSizer* ctlSizer, int id, const char* label, wxString* str, int nFlags)
|
||||
{
|
||||
wxStaticText* lbl = new wxStaticText(this, wxID_ANY, label);
|
||||
wxTextCtrl* txt = new wxTextCtrl(this, id, wxEmptyString, wxDefaultPosition, wxSize(120, -1),
|
||||
nFlags, wxTextValidator(wxFILTER_ASCII, str));
|
||||
ctlSizer->Add(lbl, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 4);
|
||||
ctlSizer->Add(txt, 1, wxALIGN_LEFT | wxALL, 4);
|
||||
|
||||
return txt;
|
||||
}
|
||||
|
||||
TwxSignatureDlg::TwxSignatureDlg() : wxDialog(NULL, wxID_ANY, "ESigner", wxDefaultPosition)
|
||||
{
|
||||
wxSizer* ctlSizer = new wxFlexGridSizer(4, 2, 4, 4);
|
||||
AddString(ctlSizer, 1001, "Utente", &m_strUser);
|
||||
AddString(ctlSizer, 1002, "PIN", &m_strPIN, wxTE_PASSWORD);
|
||||
|
||||
wxCheckBox* ctlMark = new wxCheckBox(this, 1003, "Marcatura temporale");
|
||||
if (xvt_net_get_status() <= 0)
|
||||
ctlMark->Disable();
|
||||
ctlSizer->AddSpacer(4);
|
||||
ctlSizer->Add(ctlMark, 0, wxALIGN_LEFT | wxALL, 4);
|
||||
|
||||
wxSizer* ctlButtonSizer = CreateButtonSizer(wxOK | wxCANCEL);
|
||||
|
||||
wxBoxSizer* ctlTopSizer = new wxBoxSizer(wxVERTICAL);
|
||||
ctlTopSizer->Add(ctlSizer, 0, wxALIGN_CENTER);
|
||||
ctlTopSizer->Add(ctlButtonSizer, 0, wxALIGN_CENTER);
|
||||
|
||||
SetSizer(ctlTopSizer);
|
||||
ctlTopSizer->SetSizeHints(this);
|
||||
}
|
||||
|
||||
typedef
|
||||
int (*dllSignMethod) (
|
||||
char *operation, //operazione : S (firma file),
|
||||
@ -1238,102 +1306,170 @@ typedef int (*dllVerifyMethod) (
|
||||
char *resultDescription //parametro di output contenente l'esito della verifica
|
||||
);
|
||||
|
||||
static dllSignMethod _SignPDF = NULL;
|
||||
static dllVerifyMethod _VerifyPDF = NULL;
|
||||
static wxString _strPin, _strDllFile, _strCertificate;
|
||||
|
||||
static BOOLEAN xvt_sign_init(BOOL bLoad)
|
||||
class TEsigner
|
||||
{
|
||||
BOOLEAN ok = FALSE;
|
||||
#ifdef WIN32
|
||||
static HMODULE hESigner = NULL;
|
||||
HMODULE m_hESigner;
|
||||
dllSignMethod _SignPDF;
|
||||
dllVerifyMethod _VerifyPDF;
|
||||
#endif
|
||||
|
||||
wxString m_strUser, m_strPin, m_strDllFile, m_strCertificate;
|
||||
wxString m_strTSAuri, m_strTSAuser, m_strTSApwd, m_strPolicy, m_strTSAcoding;
|
||||
bool m_bMark;
|
||||
|
||||
public:
|
||||
bool Init(bool on);
|
||||
bool Sign(const wxString& strInput, wxString& strOutput);
|
||||
bool Verify(const wxString& strInput);
|
||||
|
||||
TEsigner();
|
||||
~TEsigner();
|
||||
} __TheSigner;
|
||||
|
||||
TEsigner::TEsigner() : m_bMark(false)
|
||||
#ifdef WIN32
|
||||
, m_hESigner(NULL), _SignPDF(NULL), _VerifyPDF(NULL)
|
||||
#endif
|
||||
{}
|
||||
|
||||
TEsigner::~TEsigner()
|
||||
{ Init(false); }
|
||||
|
||||
bool TEsigner::Init(bool bLoad)
|
||||
{
|
||||
bool ok = false;
|
||||
#ifdef WIN32
|
||||
if (bLoad)
|
||||
{
|
||||
if (hESigner == NULL)
|
||||
{
|
||||
hESigner = ::LoadLibrary("esigner.dll");
|
||||
if (hESigner != NULL)
|
||||
{
|
||||
_SignPDF = (dllSignMethod)::GetProcAddress(hESigner, "Sign");
|
||||
_VerifyPDF = (dllVerifyMethod)::GetProcAddress(hESigner, "Verify");
|
||||
_strPin = "";
|
||||
char str[_MAX_PATH] = "";
|
||||
xvt_sys_get_profile_string(NULL, NULL, "Study", "", str, sizeof(str));
|
||||
wxString strConfig; strConfig = str;
|
||||
if (!wxEndsWithPathSeparator(strConfig))
|
||||
strConfig << wxFILE_SEP_PATH;
|
||||
strConfig << "config" << wxFILE_SEP_PATH << wxGetHostName() << ".ini";
|
||||
|
||||
char str[_MAX_PATH] = "";
|
||||
xvt_sys_get_profile_string(NULL, NULL, "Study", "", str, sizeof(str));
|
||||
wxString strConfig; strConfig << str << "/config/" << wxGetHostName() << ".ini";
|
||||
xvt_sys_get_profile_string(strConfig, "fd", "Cert_"+wxGetUserId(), "", str, sizeof(str));
|
||||
if (m_hESigner == NULL)
|
||||
{
|
||||
m_hESigner = ::LoadLibrary("esigner.dll");
|
||||
if (m_hESigner != NULL)
|
||||
{
|
||||
_SignPDF = (dllSignMethod)::GetProcAddress(m_hESigner, "Sign");
|
||||
_VerifyPDF = (dllVerifyMethod)::GetProcAddress(m_hESigner, "Verify");
|
||||
m_strPin.Empty();
|
||||
|
||||
TwxSignatureDlg dlg;
|
||||
if (m_strUser.IsEmpty())
|
||||
m_strUser = wxGetUserId();
|
||||
dlg.m_strUser = m_strUser;
|
||||
dlg.m_bMark = m_bMark;
|
||||
if (dlg.ShowModal() == wxID_OK)
|
||||
{
|
||||
m_strUser = dlg.m_strUser;
|
||||
m_strPin= dlg.m_strPIN;
|
||||
m_bMark = dlg.m_bMark;
|
||||
}
|
||||
else
|
||||
return ok = false;
|
||||
|
||||
xvt_sys_get_profile_string(strConfig, "fd", "Cert_"+m_strUser, "", str, sizeof(str));
|
||||
wxStringTokenizer strDllCert(str, ",");
|
||||
_strDllFile = strDllCert.GetNextToken();
|
||||
_strCertificate = strDllCert.GetNextToken();
|
||||
m_strDllFile = strDllCert.GetNextToken(); m_strDllFile.MakeLower();
|
||||
m_strCertificate = strDllCert.GetNextToken();
|
||||
if (m_strCertificate.IsEmpty() && m_strDllFile.EndsWith(".dll"))
|
||||
m_strCertificate = "0";
|
||||
|
||||
if (m_bMark)
|
||||
{
|
||||
m_strTSAuri = strDllCert.GetNextToken();
|
||||
m_strTSAuser = strDllCert.GetNextToken();
|
||||
m_strTSApwd = strDllCert.GetNextToken();
|
||||
m_strPolicy = strDllCert.GetNextToken();
|
||||
m_strTSAcoding = strDllCert.GetNextToken();
|
||||
if (m_strTSAcoding.IsEmpty())
|
||||
{
|
||||
wxString msg;
|
||||
msg << "Mancano i parametri per la marcatura temporale"
|
||||
<< "\nControllare Cert_" << m_strUser
|
||||
<< " nel paragrafo [fd]\ndel file " << strConfig;
|
||||
xvt_dm_post_warning(msg);
|
||||
m_bMark = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ok = hESigner != NULL && _SignPDF != NULL && _VerifyPDF != NULL;
|
||||
ok = m_hESigner != NULL && _SignPDF != NULL && _VerifyPDF != NULL;
|
||||
if (ok)
|
||||
{
|
||||
ok = wxFileExists(_strDllFile);
|
||||
ok = wxFileExists(m_strDllFile);
|
||||
if (!ok)
|
||||
xvt_dm_post_error("Can't load certificate or driver");
|
||||
{
|
||||
wxString msg;
|
||||
msg << "Impossibile caricare il certificato/driver " << m_strDllFile
|
||||
<< "\nControllare Cert_" << m_strUser
|
||||
<< " nel paragrafo [fd]\ndel file " << strConfig;
|
||||
xvt_dm_post_error(msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
xvt_dm_post_error("Can't load ESigner.dll");
|
||||
xvt_dm_post_error("Impossibile caricare 'ESigner.dll'");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hESigner != NULL)
|
||||
if (m_hESigner != NULL)
|
||||
{
|
||||
::FreeLibrary(hESigner);
|
||||
hESigner = NULL;
|
||||
::FreeLibrary(m_hESigner);
|
||||
m_hESigner = NULL;
|
||||
_SignPDF = NULL;
|
||||
_VerifyPDF = NULL;
|
||||
_strPin = "";
|
||||
m_strPin.Empty();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return ok;
|
||||
}
|
||||
|
||||
BOOLEAN xvt_sign_file(const char* input_name, char* output_name)
|
||||
bool TEsigner::Sign(const wxString& strInput, wxString& strOutput)
|
||||
{
|
||||
wxString strInput = input_name;
|
||||
if (strInput.IsEmpty())
|
||||
{
|
||||
FILE_SPEC fs;
|
||||
xvt_fsys_convert_str_to_fspec(strInput, &fs);
|
||||
if (xvt_dm_post_file_open(&fs, "File") != FL_OK)
|
||||
return FALSE;
|
||||
}
|
||||
strInput.MakeLower();
|
||||
|
||||
if ((_strPin.IsEmpty() || _strDllFile.IsEmpty()) && !xvt_sign_start())
|
||||
return FALSE;
|
||||
if ((m_strPin.IsEmpty() || m_strDllFile.IsEmpty()) && !Init(true))
|
||||
return false;
|
||||
|
||||
const char* ext = strInput.EndsWith(".pdf") ? ".pdf" : "";
|
||||
|
||||
wxString strOutput = output_name;
|
||||
if (strOutput.IsEmpty())
|
||||
{
|
||||
strOutput = strInput.BeforeFirst('.') + ".p7m.pdf";
|
||||
if (output_name != NULL)
|
||||
wxStrncpy(output_name, strOutput, _MAX_PATH);
|
||||
}
|
||||
|
||||
wxString strFile = strOutput;
|
||||
strFile = strFile.BeforeLast('.');
|
||||
|
||||
int res = 0;
|
||||
if (_strDllFile.EndsWith(".dll"))
|
||||
if (m_strDllFile.EndsWith(".dll"))
|
||||
{
|
||||
res = _SignPDF("S", "T", // "S"ignature with "T"oken or smartcard
|
||||
(char*)(const char*)strInput, (char*)(const char*)strOutput,
|
||||
NULL, (char*)ext, NULL, NULL, NULL, (char*)(const char*)_strDllFile,
|
||||
(char*)(const char*)_strPin, NULL, (char*)(const char*)_strCertificate,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
if (m_bMark && !m_strTSAcoding.IsEmpty()) // Firma con marcatura temporale
|
||||
{
|
||||
res = _SignPDF("S", "T", // "S"ignature with "T"oken or smartcard
|
||||
(char*)(const char*)strInput, (char*)(const char*)strFile,
|
||||
NULL, (char*)ext, NULL, NULL, NULL, (char*)(const char*)m_strDllFile,
|
||||
(char*)(const char*)m_strPin, NULL, (char*)(const char*)m_strCertificate,
|
||||
(char*)(const char*)m_strTSAuri, (char*)(const char*)m_strTSAuser,
|
||||
(char*)(const char*)m_strTSApwd, (char*)(const char*)m_strPolicy,
|
||||
(char*)(const char*)m_strTSAcoding, NULL);
|
||||
}
|
||||
else // Firma normale
|
||||
{
|
||||
res = _SignPDF("S", "T", // "S"ignature with "T"oken or smartcard
|
||||
(char*)(const char*)strInput, (char*)(const char*)strFile,
|
||||
NULL, (char*)ext, NULL, NULL, NULL, (char*)(const char*)m_strDllFile,
|
||||
(char*)(const char*)m_strPin, NULL, (char*)(const char*)m_strCertificate,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wxString strFile = strOutput;
|
||||
strFile = strFile.BeforeLast('.');
|
||||
res = _SignPDF("S", "P", // "S"ignature with "P"fx file
|
||||
(char*)(const char*)strInput, (char*)(const char*)strFile,
|
||||
NULL, (char*)ext, NULL, NULL, (char*)(const char*)_strDllFile, NULL,
|
||||
(char*)(const char*)_strPin, NULL, NULL,
|
||||
NULL, (char*)ext, NULL, NULL, (char*)(const char*)m_strDllFile, NULL,
|
||||
(char*)(const char*)m_strPin, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
@ -1356,36 +1492,49 @@ BOOLEAN xvt_sign_file(const char* input_name, char* output_name)
|
||||
return res == 0;
|
||||
}
|
||||
|
||||
bool TEsigner::Verify(const wxString& strInput)
|
||||
{
|
||||
int res = -1;
|
||||
if (Init(!strInput.IsEmpty()))
|
||||
{
|
||||
char file[_MAX_PATH], result[_MAX_PATH];
|
||||
wxStrncpy(file, strInput, _MAX_PATH);
|
||||
res = _VerifyPDF("V", file, NULL, NULL, NULL, result);
|
||||
}
|
||||
return res == 0;
|
||||
}
|
||||
|
||||
BOOLEAN xvt_sign_start()
|
||||
{
|
||||
BOOLEAN ok = xvt_sign_init(TRUE);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
char pin[16] = "";
|
||||
xvt_dm_post_string_prompt("PIN", pin, 15);
|
||||
_strPin = pin;
|
||||
ok = !_strPin.IsEmpty();
|
||||
}
|
||||
return ok;
|
||||
return __TheSigner.Init(true);
|
||||
}
|
||||
|
||||
BOOLEAN xvt_sign_stop()
|
||||
{
|
||||
_strPin = "";
|
||||
xvt_sign_init(FALSE);
|
||||
__TheSigner.Init(false);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN xvt_sign_file(const char* input_name, char* output_name)
|
||||
{
|
||||
wxString strInput = input_name, strOutput = output_name;
|
||||
if (strInput.IsEmpty())
|
||||
{
|
||||
FILE_SPEC fs;
|
||||
xvt_fsys_convert_str_to_fspec(strInput, &fs);
|
||||
if (xvt_dm_post_file_open(&fs, "File") != FL_OK)
|
||||
return false;
|
||||
}
|
||||
strInput.MakeLower();
|
||||
BOOLEAN ok = __TheSigner.Sign(strInput, strOutput);
|
||||
if (ok && output_name != NULL)
|
||||
wxStrncpy(output_name, strOutput, _MAX_PATH);
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN xvt_sign_test(const char* input_name)
|
||||
{
|
||||
if (!xvt_sign_init(input_name != NULL))
|
||||
return FALSE;
|
||||
|
||||
wxString strInput = input_name;
|
||||
if (strInput.IsEmpty())
|
||||
{
|
||||
@ -1394,9 +1543,5 @@ BOOLEAN xvt_sign_test(const char* input_name)
|
||||
if (xvt_dm_post_file_open(&fs, "File") != FL_OK)
|
||||
return FALSE;
|
||||
}
|
||||
strInput.MakeLower();
|
||||
|
||||
char result[_MAX_PATH];
|
||||
int res = _VerifyPDF("V", (char*)(const char*)strInput, NULL, NULL, NULL, result);
|
||||
return res == 0;
|
||||
return __TheSigner.Verify(strInput);
|
||||
}
|
||||
|
@ -207,13 +207,16 @@ ULONG xvt_odbc_execute(XVT_ODBC handle, const char* sql, ODBC_CALLBACK cb, void*
|
||||
|
||||
BOOLEAN xvt_odbc_driver(XVT_ODBC handle, char* str, int max_size)
|
||||
{
|
||||
if (handle != NULL)
|
||||
if (str != NULL && max_size > 8)
|
||||
{
|
||||
const wxDb* db = (const wxDb*)handle;
|
||||
wxStrncpy(str, db->dbInf.driverName, max_size);
|
||||
if (handle != NULL)
|
||||
{
|
||||
const wxDb* db = (const wxDb*)handle;
|
||||
wxStrncpy(str, db->dbInf.driverName, max_size);
|
||||
}
|
||||
else
|
||||
wxStrncpy(str, "ODBC 2.0", max_size);
|
||||
}
|
||||
else
|
||||
wxStrncpy(str, "ODBC 2.0", max_size);
|
||||
return handle != NULL;
|
||||
}
|
||||
|
||||
|
@ -899,36 +899,19 @@ void TwxPDFDC::SetPen( const wxPen& pen )
|
||||
static const char *dotted_dashed = "dasharray {6 6 2 6} dashphase {4}";
|
||||
const char *pdfdash = (char *) NULL;
|
||||
|
||||
unsigned char red = m_pen.GetColour().Red();
|
||||
unsigned char blue = m_pen.GetColour().Blue();
|
||||
unsigned char green = m_pen.GetColour().Green();
|
||||
|
||||
double redPDF = (double)(red) / 255.0;
|
||||
double bluePDF = (double)(blue) / 255.0;
|
||||
double greenPDF = (double)(green) / 255.0;
|
||||
|
||||
int intStyle = m_pen.GetStyle();
|
||||
const double redPDF = m_pen.GetColour().Red() / 255.0;
|
||||
const double greenPDF = m_pen.GetColour().Green() / 255.0;
|
||||
const double bluePDF = m_pen.GetColour().Blue() / 255.0;
|
||||
bool solid = false;
|
||||
|
||||
switch (intStyle)
|
||||
switch (m_pen.GetStyle())
|
||||
{
|
||||
case wxDOT:
|
||||
pdfdash = dotted;
|
||||
break;
|
||||
case wxSHORT_DASH:
|
||||
pdfdash = short_dashed;
|
||||
break;
|
||||
case wxLONG_DASH:
|
||||
pdfdash = long_dashed;
|
||||
break;
|
||||
case wxDOT_DASH:
|
||||
pdfdash = dotted_dashed;
|
||||
break;
|
||||
case wxSOLID:
|
||||
case wxTRANSPARENT:
|
||||
default:
|
||||
solid = true;
|
||||
break;
|
||||
case wxDOT : pdfdash = dotted; break;
|
||||
case wxSHORT_DASH : pdfdash = short_dashed; break;
|
||||
case wxLONG_DASH : pdfdash = long_dashed; break;
|
||||
case wxDOT_DASH : pdfdash = dotted_dashed; break;
|
||||
case wxSOLID :
|
||||
case wxTRANSPARENT:
|
||||
default : solid = true; break;
|
||||
}
|
||||
|
||||
PDF_TRY_DL(m_PDFlib, m_p)
|
||||
@ -936,15 +919,13 @@ void TwxPDFDC::SetPen( const wxPen& pen )
|
||||
wxString strScope = m_PDFlib->PDF_get_parameter(m_p, "scope", 0);
|
||||
if (strScope != "document")
|
||||
{
|
||||
int intWidth = m_pen.GetWidth();
|
||||
|
||||
if (intWidth == 0)
|
||||
intWidth = 1;
|
||||
m_PDFlib->PDF_setlinewidth(m_p, 1000 * intWidth / 1000.0f);
|
||||
if (!solid)
|
||||
m_PDFlib->PDF_setdashpattern(m_p, pdfdash);
|
||||
else
|
||||
double dWidth = m_pen.GetWidth();
|
||||
if (dWidth <= 0) dWidth = 1;
|
||||
m_PDFlib->PDF_setlinewidth(m_p, dWidth);
|
||||
if (solid)
|
||||
m_PDFlib->PDF_setdash(m_p, 0, 0);
|
||||
else
|
||||
m_PDFlib->PDF_setdashpattern(m_p, pdfdash);
|
||||
m_PDFlib->PDF_setcolor(m_p, "stroke", "rgb", redPDF, greenPDF, bluePDF, 0);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user