3
* $Id: panelconfiguracionpacs.cpp 3787 2011-04-29 06:38:01Z tovar $
6
* Copyright 2008-10 MetaEmotion S.L. All rights reserved.
7
* http://ginkgo-cadx.com
9
* This file is licensed under LGPL v3 license.
10
* See License.txt for details
18
#include <main/controllers/dcmtk/dicomservers.h>
19
#include <main/controllers/controladorextensiones.h>
20
#include <main/controllers/dcmtk/dicomnetwork.h>
21
#include <main/controllers/dcmtk/dicomechoassociation.h>
22
#include <main/controllers/controladorlog.h>
23
#include <main/controllers/controladorpermisos.h>
25
#include <wx/msgdlg.h>
26
#include <wx/msgout.h>
27
#include <wx/filename.h>
28
#include <wx/confbase.h>
29
#include <wx/valtext.h>
30
#include <wx/ginkgostyle/ginkgostyle.h>
33
#include <wx/textfile.h>
35
#include <wx/filedlg.h>
37
#include <wx/busyinfo.h>
38
#include <wx/xml/xml.h>
39
#include <api/internacionalizacion.h>
41
#include "panelconfiguracionpacs.h"
45
#include <main/entorno.h>
46
#include <resources/ginkgoresourcemanager.h>
52
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
53
///////////////////////DialogoEditarCertificado//////////////////////////////////////////////////////////////////////////////////
54
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
56
class DialogoEditarCertificado: public DialogoEditarCertificadoBase
59
DialogoEditarCertificado(wxWindow* pParent, const std::string& cert, const std::string& privateKey, bool permitirDefecto): DialogoEditarCertificadoBase(pParent)
62
m_pTextoCertificado->SetValue(wxString::FromUTF8(cert.c_str()));
63
m_pTextoPrivateKey->SetValue(wxString::FromUTF8(privateKey.c_str()));
65
if (permitirDefecto) {
66
m_pCheckDefault->SetValue(cert.size() == 0 && privateKey.size() == 0);
68
m_pCheckDefault->SetValue(false);
69
m_pPanelDefault->Show(false);
70
m_pSepDefault->Show(false);
78
~DialogoEditarCertificado()
81
virtual void OnAceptarClick(wxCommandEvent&)
89
void CargarFichero(bool publicKey)
91
wxFileDialog seleccionarFichero (this, _("Select certificate"), wxT(""), wxT(""), _("PEM files(*.pem;*.key)|*.pem;*.key|All files (*.*)|*.*"),wxFD_FILE_MUST_EXIST|wxFD_OPEN);
92
int response = seleccionarFichero.ShowModal();
93
if (response == wxID_OK) {
94
wxTextFile textFile(seleccionarFichero.GetPath());
95
if (textFile.Open()) {
97
if (!textFile.Eof()) {
98
cadena += textFile.GetNextLine();
99
while(!textFile.Eof()) {
100
cadena += wxT("\n") + textFile.GetNextLine();
104
m_pTextoCertificado->SetValue(cadena);
106
m_pTextoPrivateKey->SetValue(cadena);
113
virtual void OnLoadPrivateClick(wxCommandEvent& )
115
CargarFichero(false);
118
virtual void OnLoadPublicClick(wxCommandEvent& )
123
virtual void OnResetToDefault(wxCommandEvent& )
125
if (m_pPanelDefault->IsShown()) {
126
m_pCheckDefault->SetValue(true);
128
//cargamos el certificado por defecto...
129
#ifdef GINKGO_PUBLIC_KEY
130
m_pTextoCertificado->SetValue(wxString::FromUTF8(GINKGO_PUBLIC_KEY));
132
m_pTextoCertificado->SetValue(wxT(""));
134
#ifdef GINKGO_PRIVATE_KEY
135
m_pTextoPrivateKey->SetValue(wxString::FromUTF8(GINKGO_PRIVATE_KEY));
137
m_pTextoPrivateKey->SetValue(wxT(""));
144
virtual void OnCheckDefault(wxCommandEvent&)
148
virtual void RefrescarEstado()
150
m_pPanelPublic->Enable(!m_pCheckDefault->IsChecked());
151
m_pPanelPublic->Refresh();
152
m_pPanelPrivate->Enable(!m_pCheckDefault->IsChecked());
153
m_pPanelPrivate->Refresh();
155
if (m_pCheckDefault->IsChecked()) {
156
m_pTextoCertificado->SetValue(wxT(""));
157
m_pTextoPrivateKey->SetValue(wxT(""));
161
std::string GetPublicValue()
163
std::string cert(m_pTextoCertificado->GetValue().ToUTF8());
167
std::string GetPrivateValue()
169
std::string cert(m_pTextoPrivateKey->GetValue().ToUTF8());
173
bool GetUseDefaultCert()
175
return m_pCheckDefault->GetValue();
181
std::stringstream sstream;
183
if (!m_pCheckDefault->IsChecked() && m_pCheckDefault->IsShown()) {
184
if (m_pTextoCertificado->GetValue().size() == 0 || m_pTextoPrivateKey->GetValue().size() == 0)
187
sstream << _Std("You have to set private and public key") ;
190
wxMessageBox(wxString::FromUTF8(sstream.str().c_str()),_("Info"),wxOK | wxICON_INFORMATION, this);
199
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
200
///////////////////////DialogoLocalPACS//////////////////////////////////////////////////////////////////////////////////////////
201
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
203
class DialogoLocalPACS: public DialogoLocalPACSBase
206
DialogoLocalPACS(wxWindow* pParent): DialogoLocalPACSBase(pParent)
213
void SetParametros(PanelConfiguracionPACS::TipoConfigLocal& pacsLocal)
215
m_pUseTLS->SetValue(pacsLocal.useTLS);
217
m_pVerifyServer->SetValue(pacsLocal.verifyCredentials);
219
m_certificado = pacsLocal.certificate;
220
m_privateKey = pacsLocal.privateKey;
221
if (m_certificado.size()>0 || m_privateKey.size()>0) {
222
m_pBCert->SetLabel(_("Change ..."));
224
m_pBCert->SetLabel(_("Import ..."));
228
void GetParametros(PanelConfiguracionPACS::TipoConfigLocal& pacsLocal)
230
pacsLocal.useTLS = m_pUseTLS->GetValue();
232
pacsLocal.verifyCredentials = m_pVerifyServer->GetValue();
234
pacsLocal.certificate = m_certificado;
235
pacsLocal.privateKey = m_privateKey;
239
virtual void OnEditCertificate(wxCommandEvent&)
241
DialogoEditarCertificado dlg(this, m_certificado, m_privateKey, false);
244
m_certificado = dlg.GetPublicValue();
245
m_privateKey = dlg.GetPrivateValue();
246
if (m_certificado.size()>0 || m_privateKey.size()>0) {
247
m_pBCert->SetLabel(_("Change ..."));
249
m_pBCert->SetLabel(_("Import ..."));
254
virtual void OnAceptarClick(wxCommandEvent&)
265
std::stringstream sstream;
267
if (m_pUseTLS->GetValue()
268
&& (m_certificado.size() == 0 || m_privateKey.size() == 0))
271
sstream << _Std("If you want to use SSL/TLS you have to set a valid certificate and a valid private key") ;
274
wxMessageBox(wxString::FromUTF8(sstream.str().c_str()),_("Info"),wxOK | wxICON_INFORMATION, this);
280
std::string m_certificado;
281
std::string m_privateKey;
284
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
285
///////////////////////DialogoServidorPACS///////////////////////////////////////////////////////////////////////////////////////
286
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
287
class DialogoServidorPACS: public DialogoServidorPACSBase
290
DialogoServidorPACS(wxWindow* pParent, PanelConfiguracionPACS::TipoConfigLocal& configLocal, const wxString& strPuertoLocal, const wxString& aetLocal) : DialogoServidorPACSBase(pParent), m_configLocal(configLocal)
292
wxTextValidator OnlyNum = wxTextValidator(wxFILTER_NUMERIC);
293
m_pPuerto->SetValidator(OnlyNum);
295
m_pPDU->SetValue(16384);
297
m_aetLocal= aetLocal.ToUTF8();
300
if(strPuertoLocal.ToLong(&puertoLocal)){
301
m_puertoLocal = puertoLocal;
304
m_puertoLocal = 11112;
307
if(!GNC::GCS::ControladorPermisos::Instance()->Get("core.pacs.limits","pacs_tls")) {
308
m_pPanelSeguridad->Show(false);
309
m_notebook1->RemovePage(1);
313
~DialogoServidorPACS()
318
void GetParametros(PanelConfiguracionPACS::TipoPACS& tipoPacs)
320
tipoPacs.id = std::string(m_pId->GetValue().ToUTF8());
321
tipoPacs.aet= std::string(m_pAET->GetValue().ToUTF8());
322
tipoPacs.host = std::string(m_pHost->GetValue().ToUTF8());
323
tipoPacs.puerto = atoi(m_pPuerto->GetValue().ToUTF8());
324
tipoPacs.pdu = m_pPDU->GetValue();
326
tipoPacs.retrieveWithMove = m_pRetrieveMethod->GetSelection() == 0;
327
tipoPacs.retrieveSeries = m_pRetrieveMode->GetSelection() == 0;
329
if(GNC::GCS::ControladorPermisos::Instance()->Get("core.pacs.limits","pacs_tls")) {
330
tipoPacs.useTLS = m_pUseSSL->GetValue();
332
tipoPacs.pacsUser = m_pUser->GetValue().ToUTF8();
333
tipoPacs.pacsPass = m_pPassword->GetValue().ToUTF8();
335
tipoPacs.verifyCredentials = m_pVerifyServer->GetValue();
337
tipoPacs.certificate = m_certificado;
338
tipoPacs.privateKey = m_privateKey;
342
void SetParametros(PanelConfiguracionPACS::TipoPACS& tipoPacs)
344
m_pId->SetValue(wxString::FromUTF8(tipoPacs.id.c_str()));
345
m_pAET->SetValue(wxString::FromUTF8(tipoPacs.aet.c_str()));
346
m_pHost->SetValue(wxString::FromUTF8(tipoPacs.host.c_str()));
347
m_pPuerto->SetValue(wxString::Format(wxT("%d"), tipoPacs.puerto));
348
m_pPDU->SetValue(wxString::Format(wxT("%d"), tipoPacs.pdu));
350
m_pRetrieveMethod->SetSelection(tipoPacs.retrieveWithMove?0:1);
351
m_pRetrieveMode->SetSelection(tipoPacs.retrieveSeries?0:1);
353
if(GNC::GCS::ControladorPermisos::Instance()->Get("core.pacs.limits","pacs_tls")) {
354
m_pUseSSL->SetValue(tipoPacs.useTLS);
355
m_pUser->SetValue(wxString::FromUTF8(tipoPacs.pacsUser.c_str()));
356
m_pPassword->SetValue(wxString::FromUTF8(tipoPacs.pacsPass.c_str()));
358
m_pVerifyServer->SetValue(tipoPacs.verifyCredentials);
360
m_certificado = tipoPacs.certificate;
361
m_privateKey = tipoPacs.privateKey;
365
virtual void OnAdvancedConfiguration(wxCommandEvent&)
367
DialogoEditarCertificado dlg(this, m_certificado, m_privateKey, true);
370
if (dlg.GetUseDefaultCert()) {
371
m_certificado = m_configLocal.certificate;
372
m_privateKey = m_configLocal.privateKey;
375
m_certificado = dlg.GetPublicValue();
376
m_privateKey = dlg.GetPrivateValue();
381
virtual void OnCancelClick(wxCommandEvent &){
386
virtual void OnOkClick(wxCommandEvent &){
396
if(m_pId->GetValue() != wxEmptyString && m_pAET->GetValue() != wxEmptyString && m_pHost->GetValue() != wxEmptyString && m_pPuerto->GetValue() != wxEmptyString){
397
std::stringstream sstream;
398
sstream << _Std("There are this errors: ");
401
if(!m_pPuerto->GetValue().ToLong(&numero)){
403
sstream << _Std("\n- The port must be a positive short integer (16 bits)");
405
if(numero > 32767){//maxshort
407
sstream <<_Std("\n- The port is too large");
411
if(m_pAET->GetLabel().size() >16) {
413
sstream <<_Std("\n- The maximum length of the AET is 16 characters");
416
if (m_pPDU->GetValue() != 0) {
418
if(!m_pPDU->GetValue()){
420
sstream << _Std("\n- The PDU size should be greater than or equal to zero (default = 16384)");
422
if(m_pPDU->GetValue() > MAX_PDU_LENGTH){ // max, viene de esta constante ASC_MAXIMUMPDUSIZE de DCMTK
424
sstream << _Std("\n- The maximum value of the PDU is ") << MAX_PDU_LENGTH << "(" << MAX_PDU_LENGTH/1024 << "K)";
426
if(m_pPDU->GetValue() < MIN_PDU_LENGTH){ // min, viene de esta constante ASC_MINIMUMPDUSIZE de DCMTK
428
sstream << _Std("\n- The minimum value of the PDU is ") << MIN_PDU_LENGTH << "(" << MIN_PDU_LENGTH/1024 << "K)" ;
433
if (m_pUseSSL->GetValue() && ( (m_certificado.size() == 0 || m_privateKey.size() == 0) && (m_configLocal.certificate.size() == 0 || m_configLocal.privateKey.size() == 0 ) ) )
436
sstream << _Std("\n- If you want to use SSL/TLS you have to set a valid certificate and private key") ;
440
wxMessageBox(wxString::FromUTF8(sstream.str().c_str()),_("Info"),wxOK | wxICON_INFORMATION, this);
443
wxMessageBox(_("You must fill in all fields to continue"),_("Info"),wxOK | wxICON_INFORMATION, this);
447
virtual void OnProbarClick(wxCommandEvent &)
451
long pdu = m_pPDU->GetValue();
452
if(m_pPuerto->GetValue().ToLong(&puerto)){
454
EchoAssociation as("C-ECHO");
455
if (m_pUseSSL->GetValue()) {
456
if (m_certificado.empty() || m_privateKey.empty()) {
457
as.SetTLS(m_configLocal.certificate, m_configLocal.privateKey, m_pVerifyServer->GetValue());
460
as.SetTLS(m_certificado, m_privateKey, m_pVerifyServer->GetValue());
463
if (m_pUser->GetValue() != wxEmptyString) {
464
as.SetUserPass(std::string(m_pUser->GetValue().ToUTF8()), std::string(m_pPassword->GetValue().ToUTF8()));
467
wxBusyInfo* info = new wxBusyInfo(_("Testing the connection to the server ..."));
469
std::string aet(m_pAET->GetValue().ToUTF8());
470
std::string host(m_pHost->GetValue().ToUTF8());
472
as.Create(aet, host, puerto, m_aetLocal, UID_VerificationSOPClass);
474
GIL::DICOM::DCMTK::Network* pNetwork = NULL;
476
pNetwork = GIL::DICOM::DCMTK::Network::Instance(this);
481
if(pNetwork != NULL) {
483
pNetwork->InitializeNetwork(as.GetTimeout());
484
cond = pNetwork->ConnectAssociation(&as, pdu);
486
if (as.SendEchoRequest())
488
LOG_DEBUG("C-TEST", _Std("Connection test successful"));
491
wxMessageBox(_("Successful connection test."),_("Info"),wxOK | wxICON_INFORMATION, this);
496
wxMessageBox(_("The service did not respond correctly to the C-ECHO"),_("Error"), wxICON_ERROR, this);
500
LOG_ERROR("C-TEST", _Std("The service did not respond properly:") << cond.text());
503
wxMessageBox(_("The service did not respond correctly to the DICOM standard:") + wxString::FromUTF8(cond.text()), _("Error"), wxICON_ERROR, this);
506
GIL::DICOM::DCMTK::Network::FreeInstance(this);
510
LOG_ERROR("C-TEST", _Std("Unable to connect: Could not start network support."));
513
wxMessageBox(_("Error starting network support"), _("Error"), wxICON_ERROR, this);
520
PanelConfiguracionPACS::TipoConfigLocal& m_configLocal;
523
std::string m_aetLocal;
525
std::string m_certificado;
526
std::string m_privateKey;
530
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
531
///////////////////////PanelConfiguracionPACS////////////////////////////////////////////////////////////////////////////////////
532
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
534
PanelConfiguracionPACS::PanelConfiguracionPACS(wxWindow* pParent,IDialogoConfiguracion* pDialogo): PanelConfiguracionPACSBase(pParent), IPasoConfiguracion(pDialogo)
536
this->m_pTreeListPACS->AddColumn(_("Name"), 200, wxALIGN_LEFT, -1, true, false);
537
this->m_pTreeListPACS->AddColumn(_("Default"), 50, wxALIGN_LEFT, -1, true, false);
540
m_pHelpBitmap->SetBitmap(GinkgoResourcesManager::IconosMenus::GetIcoHelp());
542
if(!GNC::GCS::ControladorPermisos::Instance()->Get("core.pacs.limits","pacs_tls")) {
543
m_pBAdvanced->Show(false);
544
m_pPACSLocal->Layout();
549
m_pTreeListPACS->Connect(wxEVT_COMMAND_TREE_ITEM_ACTIVATED, wxTreeEventHandler( PanelConfiguracionPACS::OnListaPACSDClick ), NULL, this );
550
m_pTreeListPACS->Connect(wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( PanelConfiguracionPACS::OnListaPACSChoice ), NULL, this );
553
PanelConfiguracionPACS::~PanelConfiguracionPACS()
555
m_servidores.clear();
558
void PanelConfiguracionPACS::Recargar()
560
wxConfigBase * config = wxConfigBase::Get();
561
//se actualiza el fichero de configuracion
563
config->SetPath(wxT("/GinkgoCore/PACS/Local"));
566
if(!config->Read(wxT("AET"),&valor,wxT("GINKGO_%IP4"))){
567
config->Write(wxT("AET"),valor);
569
m_pAETLocal->SetValue(valor);
570
m_pAETReal->SetLabel(wxString::FromUTF8( GNC::Entorno::Instance()->ParseAET(std::string(valor.ToUTF8())).substr(0, 16).c_str() ));
572
DicomServer* serverLocal = DicomServerList::Instance()->GetLocalServer();
573
m_pPuertoLocal->SetValue(wxString::Format(wxT("%d"),serverLocal->GetPort()));
575
wxTextValidator OnlyNum = wxTextValidator(wxFILTER_NUMERIC);
576
m_pPuertoLocal->SetValidator(OnlyNum);
578
m_configLocal.useTLS = serverLocal->GetUseTLS();
580
m_configLocal.verifyCredentials = serverLocal->GetverifyCredentials();
581
m_configLocal.privateKey = serverLocal->GetPrivateKey();
582
m_configLocal.certificate = serverLocal->GetCertificate();
585
if(GNC::GCS::ControladorPermisos::Instance()->Get("core.pacs.limits","remote_pacs")) {
586
m_pPACSServers->Enable(true);
589
m_pTreeListPACS->DeleteRoot();
590
wxTreeItemId idRoot = m_pTreeListPACS->AddRoot(wxT("Root"));
591
m_servidores.clear();
593
for (DicomServerHolder* sl = DicomServerList::Instance()->GetList(); sl != NULL; sl = sl->next) {
595
tp.id = sl->server.ID;
596
tp.aet = sl->server.AET;
597
tp.host = sl->server.HostName;
598
tp.isDefault = sl->server.isDefault;
599
tp.puerto = sl->server.Port;
600
tp.pdu = sl->server.PDU;
601
tp.retrieveWithMove = sl->server.retrieveWithMove;
602
tp.retrieveSeries = sl->server.retrieveSeries;
604
tp.useTLS = sl->server.useTLS;
605
tp.pacsUser = sl->server.pacsUser;
606
tp.pacsPass = sl->server.pacsPass;
608
tp.verifyCredentials = sl->server.verifyCredentials;
609
tp.certificate = sl->server.certificate;
610
tp.privateKey = sl->server.privateKey;
611
m_servidores.push_back(tp);
612
wxTreeItemId idItem = m_pTreeListPACS->AppendItem(idRoot, wxString::FromUTF8(tp.id.c_str()));
614
m_pTreeListPACS->SetItemText(idItem, 1, _("Yes"));
616
m_pTreeListPACS->SetItemText(idItem, 1, _("No"));
620
if(m_pTreeListPACS->GetChildrenCount(idRoot) > 0){
621
wxTreeItemIdValue cookie;
622
m_pTreeListPACS->SelectItem(m_pTreeListPACS->GetFirstChild(idRoot, cookie));
624
OnListaPACSChoice(evt);
628
m_pPACSServers->Enable(false);
633
//region "Metodos de IPasoConfiguracion"
634
wxWindow* PanelConfiguracionPACS::GetPanel()
639
std::string PanelConfiguracionPACS::GetTitle()
641
return _Std("PACS Servers");
644
std::string PanelConfiguracionPACS::GetCabecera()
646
return _Std("PACS Server Settings");
649
bool PanelConfiguracionPACS::Validar()
652
std::stringstream sstream;
653
sstream << _Std("They have produced the following errors:");
656
if(!m_pPuertoLocal->GetValue().ToLong(&numero) && m_pPuertoLocal->GetValue().size() > 0){
658
sstream << _Std("\n- The local port must be a positive short integer (16 bits)");
660
if(numero > 32767){//maxshort
662
sstream << _Std("\n- The local port is too large");
666
if(m_pAETReal->GetLabel().size() >16) {
668
sstream << _Std("\n- Maximum length of local AET is 16 characters");
672
wxMessageBox(wxString::FromUTF8(sstream.str().c_str()),_("Info"),wxOK | wxICON_INFORMATION, this);
676
bool PanelConfiguracionPACS::Guardar()
678
wxConfigBase * config = wxConfigBase::Get();
679
//se actualiza el fichero de configuracion
681
config->SetPath(wxT("/GinkgoCore/PACS/Local"));
683
config->Write(wxT("AET"),m_pAETLocal->GetValue());
684
config->Write(wxT("Puerto"),m_pPuertoLocal->GetValue());
687
config->Write(wxT("useTLS"),m_configLocal.useTLS);
688
config->Write(wxT("verifyCredentials"), m_configLocal.verifyCredentials);
689
config->Write(wxT("privateKey"), wxString::FromUTF8(m_configLocal.privateKey.c_str()));
690
config->Write(wxT("certificate"), wxString::FromUTF8(m_configLocal.certificate.c_str()));
692
config->DeleteGroup(wxT("/GinkgoCore/PACS/Servidores"));
693
config->SetPath(wxT("/GinkgoCore/PACS/Servidores"));
695
if(GNC::GCS::ControladorPermisos::Instance()->Get("core.pacs.limits","remote_pacs")) {
699
for(TipoListaPACS::iterator it = m_servidores.begin(); it!= m_servidores.end(); it++,i++){
700
clave = wxString::Format(wxT("Servidor%d/Identificador"),i);
701
valor = wxString::FromUTF8((*it).id.c_str());
702
config->Write(clave,valor);
704
clave = wxString::Format(wxT("Servidor%d/AET"),i);
705
valor = wxString::FromUTF8((*it).aet.c_str());
706
config->Write(clave,valor);
708
clave = wxString::Format(wxT("Servidor%d/Host"),i);
709
valor = wxString::FromUTF8((*it).host.c_str());
710
config->Write(clave,valor);
712
clave = wxString::Format(wxT("Servidor%d/Puerto"),i);
713
config->Write(clave,(*it).puerto);
715
clave = wxString::Format(wxT("Servidor%d/PDU"),i);
716
config->Write(clave,(*it).pdu);
718
clave = wxString::Format(wxT("Servidor%d/isDefault"),i);
719
config->Write(clave,(*it).isDefault);
721
clave = wxString::Format(wxT("Servidor%d/useTLS"),i);
722
config->Write(clave,(*it).useTLS);
724
clave = wxString::Format(wxT("Servidor%d/pacsUser"),i);
725
config->Write(clave,wxString::FromUTF8((*it).pacsUser.c_str()) );
727
clave = wxString::Format(wxT("Servidor%d/pacsPass"),i);
728
config->Write(clave,wxString::FromUTF8((*it).pacsPass.c_str()) );
730
clave = wxString::Format(wxT("Servidor%d/verifyCredentials"),i);
731
config->Write(clave,(*it).verifyCredentials);
733
clave = wxString::Format(wxT("Servidor%d/certificate"),i);
734
config->Write(clave,wxString::FromUTF8((*it).certificate.c_str()) );
736
clave = wxString::Format(wxT("Servidor%d/privateKey"),i);
737
config->Write(clave,wxString::FromUTF8((*it).privateKey.c_str()) );
739
clave = wxString::Format(wxT("Servidor%d/retrieveWithMove"),i);
740
config->Write(clave,(*it).retrieveWithMove );
742
clave = wxString::Format(wxT("Servidor%d/retrieveSeries"),i);
743
config->Write(clave,(*it).retrieveSeries );
745
DicomServerList::Instance()->Reload();
748
DicomServerList::Instance()->FreeInstance();
754
void PanelConfiguracionPACS::Exportar(wxXmlNode* pNodo)
756
wxXmlNode* pPACS = NULL;
757
for(pPACS =pNodo->GetChildren(); pPACS!=NULL; pPACS = pPACS->GetNext()) {
758
if(pPACS->GetName() == wxT("PACS")) {
763
pPACS = new wxXmlNode(pNodo,wxXML_ELEMENT_NODE,wxT("PACS"));
766
wxXmlNode* pLocal = NULL;
767
for(pLocal =pPACS->GetChildren(); pLocal!=NULL; pLocal = pLocal->GetNext()) {
768
if(pLocal->GetName() == wxT("Local")) {
773
pLocal = new wxXmlNode(pPACS,wxXML_ELEMENT_NODE,wxT("Local"));
776
wxXmlNode* nodo = new wxXmlNode(pLocal,wxXML_ELEMENT_NODE,wxT("AET"));
777
new wxXmlNode(nodo,wxXML_TEXT_NODE,wxT(""),m_pAETLocal->GetValue());
779
nodo = new wxXmlNode(pLocal,wxXML_ELEMENT_NODE,wxT("Puerto"));
780
new wxXmlNode(nodo,wxXML_TEXT_NODE,wxT(""),m_pPuertoLocal->GetValue());
782
nodo = new wxXmlNode(pLocal,wxXML_ELEMENT_NODE,wxT("useTLS"));
783
new wxXmlNode(nodo,wxXML_TEXT_NODE,wxT(""),m_configLocal.useTLS?wxT("true"):wxT("false"));
785
nodo = new wxXmlNode(pLocal,wxXML_ELEMENT_NODE,wxT("verifyCredentials"));
786
new wxXmlNode(nodo,wxXML_TEXT_NODE,wxT(""),m_configLocal.verifyCredentials?wxT("true"):wxT("false"));
788
nodo = new wxXmlNode(pLocal,wxXML_ELEMENT_NODE,wxT("privateKey"));
789
new wxXmlNode(nodo,wxXML_TEXT_NODE,wxT(""),wxString::FromUTF8(m_configLocal.privateKey.c_str()));
791
nodo = new wxXmlNode(pLocal,wxXML_ELEMENT_NODE,wxT("certificate"));
792
new wxXmlNode(nodo,wxXML_TEXT_NODE,wxT(""),wxString::FromUTF8(m_configLocal.certificate.c_str()));
794
if(GNC::GCS::ControladorPermisos::Instance()->Get("core.pacs.limits","remote_pacs")) {
796
wxXmlNode* pServidores = NULL;
797
for(pServidores =pPACS->GetChildren(); pServidores!=NULL; pServidores = pServidores->GetNext()) {
798
if(pServidores->GetName() == wxT("Servidores")) {
802
if(pServidores == NULL) {
803
pServidores = new wxXmlNode(pPACS,wxXML_ELEMENT_NODE,wxT("Servidores"));
808
for(TipoListaPACS::iterator it = m_servidores.begin(); it!= m_servidores.end(); it++){
809
wxXmlNode* pTag = new wxXmlNode(pServidores,wxXML_ELEMENT_NODE,wxT("Servidor"));
810
pTag->AddProperty(wxT("Identificador"),wxString::FromUTF8((*it).id.c_str()));
811
pTag->AddProperty(wxT("AET"),wxString::FromUTF8((*it).aet.c_str()));
812
pTag->AddProperty(wxT("Host"),wxString::FromUTF8((*it).host.c_str()));
813
pTag->AddProperty(wxT("Puerto"),wxString::Format(wxT("%d"),(*it).puerto));
814
pTag->AddProperty(wxT("isDefault"), (*it).isDefault?wxT("true"):wxT("false"));
815
pTag->AddProperty(wxT("PDU"),wxString::Format(wxT("%d"),(*it).pdu));
816
pTag->AddProperty(wxT("useTLS"), (*it).useTLS?wxT("true"):wxT("false"));
817
pTag->AddProperty(wxT("pacsUser"), wxString::FromUTF8((*it).pacsUser.c_str()));
818
pTag->AddProperty(wxT("pacsPass"), wxString::FromUTF8((*it).pacsPass.c_str()));
819
pTag->AddProperty(wxT("verifyCredentials"), (*it).verifyCredentials?wxT("true"):wxT("false"));
820
pTag->AddProperty(wxT("certificate"), wxString::FromUTF8((*it).certificate.c_str()));
821
pTag->AddProperty(wxT("privateKey"), wxString::FromUTF8((*it).privateKey.c_str()));
822
pTag->AddProperty(wxT("retrieveWithMove"), (*it).retrieveWithMove?wxT("true"):wxT("false"));
823
pTag->AddProperty(wxT("retrieveSeries"), (*it).retrieveSeries?wxT("true"):wxT("false"));
828
void PanelConfiguracionPACS::Importar(wxXmlNode* pNodo)
830
wxConfigBase * config = wxConfigBase::Get();
831
//se actualiza el fichero de configuracion
833
config->SetPath(wxT("/GinkgoCore/PACS/Local"));
834
config->DeleteEntry(wxT("AET"));
835
config->DeleteEntry(wxT("Puerto"));
837
wxXmlNode* pPACS = NULL;
838
for(pPACS = pNodo->GetChildren(); pPACS != NULL; pPACS = pPACS->GetNext()) {
839
if(pPACS->GetName() == wxT("PACS")) {
844
wxXmlNode* pLocal = NULL;
845
for(pLocal =pPACS->GetChildren(); pLocal!=NULL; pLocal = pLocal->GetNext()) {
846
if(pLocal->GetName() == wxT("Local")) {
851
config->SetPath(wxT("/GinkgoCore/PACS/Local"));
852
for(wxXmlNode* pNodo = pLocal->GetChildren(); pNodo!= NULL; pNodo =pNodo->GetNext())
854
if(pNodo->GetChildren() != NULL) {
855
if(pNodo->GetName() == wxT("AET")) {
856
config->Write(wxT("AET"),pNodo->GetChildren()->GetContent());
858
if(pNodo->GetName() == wxT("Puerto")) {
859
config->Write(wxT("Puerto"),pNodo->GetChildren()->GetContent());
861
if(pNodo->GetName() == wxT("useTLS")) {
862
config->Write(wxT("useTLS"),pNodo->GetChildren()->GetContent()==wxT("true"));
864
if(pNodo->GetName() == wxT("useUserPass")) {
865
config->Write(wxT("useUserPass"),pNodo->GetChildren()->GetContent()==wxT("true"));
867
if(pNodo->GetName() == wxT("pacsUser")) {
868
config->Write(wxT("pacsUser"),pNodo->GetChildren()->GetContent());
870
if(pNodo->GetName() == wxT("pacsPass")) {
871
config->Write(wxT("pacsPass"),pNodo->GetChildren()->GetContent());
873
if(pNodo->GetName() == wxT("verifyCredentials")) {
874
config->Write(wxT("verifyCredentials"),pNodo->GetChildren()->GetContent()==wxT("true"));
876
if(pNodo->GetName() == wxT("privateKey")) {
877
config->Write(wxT("privateKey"),pNodo->GetChildren()->GetContent());
879
if(pNodo->GetName() == wxT("certificate")) {
880
config->Write(wxT("certificate"),pNodo->GetChildren()->GetContent());
887
config->DeleteGroup(wxT("/GinkgoCore/PACS/Servidores"));
888
config->SetPath(wxT("/GinkgoCore/PACS/Servidores"));
890
for(pPACS = pNodo->GetChildren(); pPACS != NULL; pPACS = pPACS->GetNext()) {
891
if(pPACS->GetName() == wxT("PACS")) {
896
wxXmlNode* pServidores = NULL;
897
for(pServidores =pPACS->GetChildren(); pServidores!=NULL; pServidores = pServidores->GetNext()) {
898
if(pServidores->GetName() == wxT("Servidores")) {
902
if(pServidores != NULL) {
905
for(wxXmlNode* pTag=pServidores->GetChildren(); pTag!=NULL; pTag = pTag->GetNext(),i++) {
906
wxString identificador;
907
pTag->GetPropVal(wxT("Identificador"),&identificador);
909
pTag->GetPropVal(wxT("AET"),&aet);
911
pTag->GetPropVal(wxT("Host"),&host);
913
pTag->GetPropVal(wxT("Puerto"),&puerto);
915
if(!pTag->GetPropVal(wxT("PDU"),&pdu)) {
916
std::stringstream sstream;
917
sstream << DEFAULT_PDU_LENGTH;
918
pdu = wxString::FromUTF8(sstream.str().c_str()); //16k es el default
923
tmpStr = pTag->GetPropVal(wxT("isDefault"),wxT("false"));
924
pacsTmp.isDefault = tmpStr == wxT("true");
925
tmpStr = pTag->GetPropVal(wxT("useTLS"),wxT("false"));
926
pacsTmp.useTLS = tmpStr == wxT("true");
927
tmpStr = pTag->GetPropVal(wxT("pacsUser"),wxT(""));
928
pacsTmp.pacsUser = tmpStr.ToUTF8();
929
tmpStr = pTag->GetPropVal(wxT("pacsPass"),wxT(""));
930
pacsTmp.pacsPass = tmpStr.ToUTF8();
931
tmpStr = pTag->GetPropVal(wxT("verifyCredentials"),wxT("false"));
932
pacsTmp.verifyCredentials = tmpStr == wxT("true");
933
tmpStr = pTag->GetPropVal(wxT("certificate"),wxT(""));
934
pacsTmp.certificate = tmpStr.ToUTF8();
935
tmpStr = pTag->GetPropVal(wxT("privateKey"),wxT(""));
936
pacsTmp.privateKey = tmpStr.ToUTF8();
937
tmpStr = pTag->GetPropVal(wxT("retrieveWithMove"),wxT("true"));
938
pacsTmp.retrieveWithMove = tmpStr == wxT("true");
939
tmpStr = pTag->GetPropVal(wxT("retrieveSeries"),wxT("true"));
940
pacsTmp.retrieveSeries = tmpStr == wxT("true");
942
clave = wxString::Format(wxT("Servidor%d/Identificador"),i);
943
config->Write(clave,identificador);
945
clave = wxString::Format(wxT("Servidor%d/AET"),i);
946
config->Write(clave,aet);
948
clave = wxString::Format(wxT("Servidor%d/Host"),i);
949
config->Write(clave,host);
951
clave = wxString::Format(wxT("Servidor%d/Puerto"),i);
952
config->Write(clave,puerto);
954
clave = wxString::Format(wxT("Servidor%d/PDU"),i);
955
config->Write(clave,pdu);
957
clave = wxString::Format(wxT("Servidor%d/useTLS"),i);
958
config->Write(clave,pacsTmp.useTLS);
960
clave = wxString::Format(wxT("Servidor%d/pacsUser"),i);
961
config->Write(clave,wxString::FromUTF8(pacsTmp.pacsUser.c_str()));
963
clave = wxString::Format(wxT("Servidor%d/pacsPass"),i);
964
config->Write(clave,wxString::FromUTF8(pacsTmp.pacsPass.c_str()));
966
clave = wxString::Format(wxT("Servidor%d/verifyCredentials"),i);
967
config->Write(clave,pacsTmp.verifyCredentials);
969
clave = wxString::Format(wxT("Servidor%d/certificate"),i);
970
config->Write(clave,wxString::FromUTF8(pacsTmp.certificate.c_str()) );
972
clave = wxString::Format(wxT("Servidor%d/privateKey"),i);
973
config->Write(clave,wxString::FromUTF8(pacsTmp.privateKey.c_str()) );
975
clave = wxString::Format(wxT("Servidor%d/retrieveWithMove"),i);
976
config->Write(clave,pacsTmp.retrieveWithMove );
978
clave = wxString::Format(wxT("Servidor%d/retrieveSeries"),i);
979
config->Write(clave,pacsTmp.retrieveSeries );
983
DicomServerList::Instance()->Reload();
987
void PanelConfiguracionPACS::OnAdvancedLocal(wxCommandEvent &)
989
DialogoLocalPACS dlg(this);
990
dlg.SetParametros(m_configLocal);
993
dlg.GetParametros(m_configLocal);
994
OnPropiedadCambiada();
998
void PanelConfiguracionPACS::OnListaPACSChoice(wxTreeEvent &){
999
//se carga la descripcion
1000
bool enable = m_pTreeListPACS->GetSelection().IsOk();
1001
m_pEditButton->Enable(enable);
1002
m_pDelButton->Enable(enable);
1003
m_pDefaultButton->Enable(enable);
1006
void PanelConfiguracionPACS::OnListaPACSDClick(wxTreeEvent &)
1012
void PanelConfiguracionPACS::OnNuevoClick(wxCommandEvent &){
1013
DialogoServidorPACS dialogo(this, m_configLocal, m_pPuertoLocal->GetValue(), wxString::FromUTF8( GNC::Entorno::Instance()->ParseAET( std::string(m_pAETLocal->GetValue().ToUTF8()) ).c_str() ) );
1014
dialogo.ShowModal();
1017
dialogo.GetParametros(tp);
1018
if (m_pTreeListPACS->GetChildrenCount(m_pTreeListPACS->GetRootItem()) == 0) {
1019
tp.isDefault = true;
1021
m_servidores.push_back(tp);
1023
wxTreeItemId idItem = m_pTreeListPACS->AppendItem(m_pTreeListPACS->GetRootItem(), wxString::FromUTF8(tp.id.c_str()));
1025
m_pTreeListPACS->SetItemText(idItem, 1, _("Yes"));
1027
m_pTreeListPACS->SetItemText(idItem, 1, _("No"));
1030
m_pTreeListPACS->SelectItem(idItem);
1032
OnListaPACSChoice(evt);
1033
OnPropiedadCambiada();
1037
void PanelConfiguracionPACS::OnEditarClick(wxCommandEvent &){
1038
wxTreeItemId id = m_pTreeListPACS->GetSelection();
1040
std::string idSeleccionado(m_pTreeListPACS->GetItemText(id).ToUTF8());
1042
for(TipoListaPACS::iterator it = m_servidores.begin(); it != m_servidores.end(); it++){
1043
if((*it).id == idSeleccionado){
1044
DialogoServidorPACS dialogo(this, m_configLocal, m_pPuertoLocal->GetValue(), wxString::FromUTF8( GNC::Entorno::Instance()->ParseAET( std::string( m_pAETLocal->GetValue().ToUTF8() ) ).c_str() ) );
1045
dialogo.SetParametros((*it));
1047
dialogo.ShowModal();
1049
dialogo.GetParametros((*it));
1050
//se refresca el combo
1051
m_pTreeListPACS->SetItemText(id,wxString::FromUTF8((*it).id.c_str()));
1052
m_pTreeListPACS->SelectItem(id);
1055
OnListaPACSChoice(evt);
1056
OnPropiedadCambiada();
1063
void PanelConfiguracionPACS::OnEliminarClick(wxCommandEvent &){
1064
wxTreeItemId itemSeleccionado = m_pTreeListPACS->GetSelection();
1065
if(itemSeleccionado.IsOk()){
1066
std::string idSeleccionado(m_pTreeListPACS->GetItemText(itemSeleccionado).ToUTF8());
1067
int answer = wxMessageBox(_("Confirm the removal of the server") + wxString::FromUTF8(idSeleccionado.c_str()), _("Data modified"), wxYES_NO | wxCANCEL, this);
1068
if(answer == wxYES){
1069
for(TipoListaPACS::iterator it = m_servidores.begin(); it != m_servidores.end(); it++){
1070
if((*it).id == idSeleccionado){
1071
m_pTreeListPACS->Delete(itemSeleccionado);
1072
m_servidores.erase(it);
1077
OnListaPACSChoice(evt);
1078
OnPropiedadCambiada();
1083
void PanelConfiguracionPACS::OnSetDefaultClick(wxCommandEvent &)
1085
wxTreeItemId itemSeleccionado = m_pTreeListPACS->GetSelection();
1086
if(itemSeleccionado.IsOk()){
1087
std::string idSeleccionado(m_pTreeListPACS->GetItemText(itemSeleccionado).ToUTF8());
1088
for(TipoListaPACS::iterator it = m_servidores.begin(); it != m_servidores.end(); it++){
1089
if((*it).id == idSeleccionado){
1090
(*it).isDefault = true;
1092
(*it).isDefault = false;
1095
wxTreeItemIdValue cookie;
1096
wxTreeItemId itemActual = m_pTreeListPACS->GetFirstChild(m_pTreeListPACS->GetRootItem(), cookie);
1097
while (itemActual.IsOk())
1099
if (itemActual == itemSeleccionado) {
1100
m_pTreeListPACS->SetItemText(itemActual,1,_("Yes"));
1102
m_pTreeListPACS->SetItemText(itemActual,1,_("No"));
1104
itemActual = m_pTreeListPACS->GetNextChild(m_pTreeListPACS->GetRootItem(), cookie);
1107
OnListaPACSChoice(evt);
1108
OnPropiedadCambiada();
1112
void PanelConfiguracionPACS::OnTextoCambiado(wxCommandEvent & )
1114
m_pAETReal->SetLabel(wxString::FromUTF8( GNC::Entorno::Instance()->ParseAET(std::string(m_pAETLocal->GetValue().ToUTF8())).c_str() ));
1115
OnPropiedadCambiada();
1118
void PanelConfiguracionPACS::OnSize(wxSizeEvent & event){
1119
wxSize oldSize = m_staticTextExplicacion->GetSize();
1121
m_staticTextExplicacion->Freeze();
1122
m_staticTextExplicacion->SetLabel(_("You must configure the local AET, which is used to communicate with the PACS server. The specified port must be opened in the firewall, as it is essential for transfers."));
1123
m_staticTextExplicacion->Wrap( event.GetSize().x-25 );
1124
m_staticTextExplicacion->Thaw();
1127
wxSize newSize = m_staticTextExplicacion->GetSize();
1128
if (newSize != oldSize) {