git-svn-id: svn://10.65.10.50/branches/R_10_00@23106 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
5821f57476
commit
36d2a2b01a
132
fd/fd0.cpp
132
fd/fd0.cpp
@ -11,7 +11,6 @@
|
|||||||
#include <wx/progdlg.h>
|
#include <wx/progdlg.h>
|
||||||
#include <wx/socket.h>
|
#include <wx/socket.h>
|
||||||
#include <wx/tokenzr.h>
|
#include <wx/tokenzr.h>
|
||||||
#include <wx/xml/xml.h>
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// Utility
|
// Utility
|
||||||
@ -261,6 +260,7 @@ class TEsigner
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool TestFile(const wxString& strFile) const;
|
bool TestFile(const wxString& strFile) const;
|
||||||
|
void Backup(const wxString& strInput, const wxString& strBackup) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool Init(bool on);
|
bool Init(bool on);
|
||||||
@ -389,6 +389,26 @@ bool TEsigner::Init(bool bLoad)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TEsigner::Backup(const wxString& strInput, const wxString& strBackup) const
|
||||||
|
{
|
||||||
|
int mode = 3;
|
||||||
|
if (strBackup.CmpNoCase("Cestino") == 0 || strBackup.CmpNoCase("NULL") == 0 ||
|
||||||
|
strBackup.CmpNoCase("Basket") == 0 || strBackup.CmpNoCase("Trash") == 0)
|
||||||
|
mode = 1;
|
||||||
|
else
|
||||||
|
wxFileName::Mkdir(strBackup, 0777, wxPATH_MKDIR_FULL);
|
||||||
|
|
||||||
|
if (mode & 2)
|
||||||
|
{
|
||||||
|
wxFileName fout = strInput;
|
||||||
|
fout.SetPath(strBackup);
|
||||||
|
if (!wxCopyFile(strInput, fout.GetFullPath()))
|
||||||
|
mode = 0;
|
||||||
|
}
|
||||||
|
if (mode & 1)
|
||||||
|
::wxRemoveFile(strInput);
|
||||||
|
}
|
||||||
|
|
||||||
bool TEsigner::Sign(const wxString& strInput, wxString& strOutput, const wxString& strBackup, int mode)
|
bool TEsigner::Sign(const wxString& strInput, wxString& strOutput, const wxString& strBackup, int mode)
|
||||||
{
|
{
|
||||||
if (m_strPin.Len() < 2)
|
if (m_strPin.Len() < 2)
|
||||||
@ -401,9 +421,9 @@ bool TEsigner::Sign(const wxString& strInput, wxString& strOutput, const wxStrin
|
|||||||
|
|
||||||
wxString strOperation = "S";
|
wxString strOperation = "S";
|
||||||
if (m_bMark && !m_strTSAurl.IsEmpty()) // Firma con marcatura temporale
|
if (m_bMark && !m_strTSAurl.IsEmpty()) // Firma con marcatura temporale
|
||||||
strOperation += "+T"; else
|
strOperation += "+T";
|
||||||
if (wxDirExists(strInput))
|
|
||||||
strOperation += "+D";
|
const bool bIsDir = wxDirExists(strInput);
|
||||||
|
|
||||||
wxString strMethod;
|
wxString strMethod;
|
||||||
if (!m_strDLL.IsEmpty()) // Token
|
if (!m_strDLL.IsEmpty()) // Token
|
||||||
@ -447,7 +467,7 @@ bool TEsigner::Sign(const wxString& strInput, wxString& strOutput, const wxStrin
|
|||||||
TSA_coding = (char*)(const char*)m_strTSAcoding;
|
TSA_coding = (char*)(const char*)m_strTSAcoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strOperation.Find("+D") > 0)
|
if (bIsDir)
|
||||||
{
|
{
|
||||||
if (strOutput.IsEmpty())
|
if (strOutput.IsEmpty())
|
||||||
output = input;
|
output = input;
|
||||||
@ -462,76 +482,43 @@ bool TEsigner::Sign(const wxString& strInput, wxString& strOutput, const wxStrin
|
|||||||
output = (char*)(const char*)strOutput;
|
output = (char*)(const char*)strOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
int res = _SignPDF(operation, method,
|
int res = 0;
|
||||||
|
|
||||||
|
if (bIsDir)
|
||||||
|
{
|
||||||
|
wxArrayString files;
|
||||||
|
const size_t xmls = wxDir::GetAllFiles(strInput, &files, "*.xml", wxDIR_FILES);
|
||||||
|
|
||||||
|
|
||||||
|
wxProgressDialog pd(APPFULLNAME, "Firma dei file in " + strInput);
|
||||||
|
for (size_t i = 0; i < xmls && res == 0; i++)
|
||||||
|
{
|
||||||
|
input = (char*)(const char*)files[i];
|
||||||
|
wxFileName fnOutput = files[i];
|
||||||
|
fnOutput.SetPath(strOutput);
|
||||||
|
fnOutput.SetExt("");
|
||||||
|
output = (char*)(const char*)fnOutput.GetFullPath();
|
||||||
|
res = _SignPDF(operation, method,
|
||||||
input, output, NULL, ext,
|
input, output, NULL, ext,
|
||||||
cer, pem, pfx, dll, pin, NULL, idx,
|
cer, pem, pfx, dll, pin, NULL, idx,
|
||||||
TSA_url, TSA_user, TSA_pwd, TSA_policy, TSA_coding, NULL);
|
TSA_url, TSA_user, TSA_pwd, TSA_policy, TSA_coding, NULL);
|
||||||
|
if (res == 0)
|
||||||
if (strOperation.Find("+D") > 0) // +D only
|
{
|
||||||
|
if (!strBackup.IsEmpty())
|
||||||
|
Backup(files[i], strBackup);
|
||||||
|
if (!pd.Update(i+1))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
wxArrayString files;
|
res = _SignPDF(operation, method,
|
||||||
const size_t results = wxDir::GetAllFiles(output, &files, "*.result", wxDIR_FILES);
|
input, output, NULL, ext,
|
||||||
if (results > 0)
|
cer, pem, pfx, dll, pin, NULL, idx,
|
||||||
{
|
TSA_url, TSA_user, TSA_pwd, TSA_policy, TSA_coding, NULL);
|
||||||
res = 0;
|
if (res == 0 && !strBackup.IsEmpty())
|
||||||
for (size_t i = 0; i < results && res == 0; i++)
|
Backup(strInput, strBackup);
|
||||||
{
|
|
||||||
const wxXmlDocument xml(files[i]);
|
|
||||||
const wxXmlNode* pRoot = xml.GetRoot();
|
|
||||||
if (pRoot != NULL)
|
|
||||||
{
|
|
||||||
const wxXmlNode* pImpronta = pRoot->GetChildren();
|
|
||||||
if (pImpronta != NULL)
|
|
||||||
res = wxAtoi(pImpronta->GetAttribute(wxT("ESITO"), wxT("-1")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mode == 2)
|
|
||||||
{
|
|
||||||
if (strBackup.IsEmpty())
|
|
||||||
mode = 0;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (strBackup.CmpNoCase("Cestino") == 0 || strBackup.CmpNoCase("NULL") == 0 ||
|
|
||||||
strBackup.CmpNoCase("Basket") == 0 || strBackup.CmpNoCase("Trash") == 0)
|
|
||||||
mode = 1;
|
|
||||||
}
|
|
||||||
if (mode == 2)
|
|
||||||
wxFileName::Mkdir(strBackup, 0777, wxPATH_MKDIR_FULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res == 0 && mode != 0)
|
|
||||||
{
|
|
||||||
files.Clear();
|
|
||||||
const size_t n = wxDir::GetAllFiles(input, &files, "*.*", wxDIR_FILES);
|
|
||||||
if (n > 0)
|
|
||||||
{
|
|
||||||
wxString msg;
|
|
||||||
if (mode == 1)
|
|
||||||
msg << "Eliminazione file in " << strInput;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxFileName::Mkdir(strBackup, 0777, wxPATH_MKDIR_FULL);
|
|
||||||
msg << "Copia file in " << strBackup;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxProgressDialog pd(APPFULLNAME, msg, n);
|
|
||||||
for (size_t i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
if (!pd.Update(i+1))
|
|
||||||
break;
|
|
||||||
wxFileName fout = files[i];
|
|
||||||
fout.SetPath(strBackup);
|
|
||||||
bool bRemove = true;
|
|
||||||
if (mode == 2)
|
|
||||||
bRemove = wxCopyFile(files[i], fout.GetFullPath());
|
|
||||||
if (bRemove)
|
|
||||||
wxRemoveFile(files[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
@ -607,9 +594,10 @@ bool TMainDlg::TransferDataToWindow()
|
|||||||
{
|
{
|
||||||
SetProperty("DIR_IN", IniGetString(m_strUser, "DIR_IN"));
|
SetProperty("DIR_IN", IniGetString(m_strUser, "DIR_IN"));
|
||||||
SetProperty("DIR_OUT", IniGetString(m_strUser, "DIR_OUT"));
|
SetProperty("DIR_OUT", IniGetString(m_strUser, "DIR_OUT"));
|
||||||
|
/*
|
||||||
SetProperty("FILE_IN", IniGetString(m_strUser, "FILE_IN"));
|
SetProperty("FILE_IN", IniGetString(m_strUser, "FILE_IN"));
|
||||||
SetProperty("FILE_OUT", IniGetString(m_strUser, "FILE_OUT"));
|
SetProperty("FILE_OUT", IniGetString(m_strUser, "FILE_OUT"));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user