diff --git a/CMakeExternals/CTK.cmake b/CMakeExternals/CTK.cmake index c985a36b5a..efc9d75480 100644 --- a/CMakeExternals/CTK.cmake +++ b/CMakeExternals/CTK.cmake @@ -1,124 +1,124 @@ #----------------------------------------------------------------------------- # CTK #----------------------------------------------------------------------------- if(MITK_USE_CTK) # Sanity checks if(DEFINED CTK_DIR AND NOT EXISTS ${CTK_DIR}) message(FATAL_ERROR "CTK_DIR variable is defined but corresponds to non-existing directory") endif() set(proj CTK) set(proj_DEPENDENCIES ) set(CTK_DEPENDS ${proj}) if(NOT DEFINED CTK_DIR) set(revision_tag cbd8b4b4) #IF(${proj}_REVISION_TAG) # SET(revision_tag ${${proj}_REVISION_TAG}) #ENDIF() set(ctk_optional_cache_args ) if(MITK_USE_Python) if(NOT MITK_USE_SYSTEM_PYTHON) list(APPEND proj_DEPENDENCIES Python) endif() list(APPEND ctk_optional_cache_args -DCTK_LIB_Scripting/Python/Widgets:BOOL=ON -DCTK_ENABLE_Python_Wrapping:BOOL=ON -DCTK_APP_ctkSimplePythonShell:BOOL=ON -DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE} -DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIR} -DPYTHON_INCLUDE_DIR2:PATH=${PYTHON_INCLUDE_DIR2} -DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARY} ) else() list(APPEND ctk_optional_cache_args -DCTK_LIB_Scripting/Python/Widgets:BOOL=OFF -DCTK_ENABLE_Python_Wrapping:BOOL=OFF -DCTK_APP_ctkSimplePythonShell:BOOL=OFF ) endif() if(MITK_USE_DCMTK) list(APPEND ctk_optional_cache_args -DDCMTK_DIR:PATH=${DCMTK_DIR} -DDCMTK_CMAKE_DEBUG_POSTFIX:STRING=d ) list(APPEND proj_DEPENDENCIES DCMTK) else() list(APPEND ctk_optional_cache_args -DDCMTK_URL:STRING=${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/CTK_DCMTK_085525e6.tar.gz ) endif() if(CTEST_USE_LAUNCHERS) list(APPEND ctk_optional_cache_args "-DCMAKE_PROJECT_${proj}_INCLUDE:FILEPATH=${CMAKE_ROOT}/Modules/CTestUseLaunchers.cmake" ) endif() set (ctk_qt_args -DCTK_QT_VERSION:STRING=${DESIRED_QT_VERSION}) if (DESIRED_QT_VERSION MATCHES "4") list(APPEND ctk_qt_args -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}) endif() FOREACH(type RUNTIME ARCHIVE LIBRARY) IF(DEFINED CTK_PLUGIN_${type}_OUTPUT_DIRECTORY) LIST(APPEND mitk_optional_cache_args -DCTK_PLUGIN_${type}_OUTPUT_DIRECTORY:PATH=${CTK_PLUGIN_${type}_OUTPUT_DIRECTORY}) ENDIF() ENDFOREACH() ExternalProject_Add(${proj} LIST_SEPARATOR ${sep} #URL https://www.dropbox.com/s/j9ii4udqfa6jn2k/CTK-CGS-2015.06_dcc02437.tar.gz #URL_MD5 1720e40402238619908c55a44d5036ff GIT_REPOSITORY https://github.com/AndreasFetzer/CTK.git GIT_TAG origin/ctk-for-mitk-cgs-workbench-2015.06 UPDATE_COMMAND "" INSTALL_COMMAND "" CMAKE_GENERATOR ${gen} CMAKE_ARGS ${ep_common_args} ${ctk_optional_cache_args} ${ctk_qt_args} # The CTK PluginFramework cannot cope with # a non-empty CMAKE_DEBUG_POSTFIX for the plugin # libraries yet. -DCMAKE_DEBUG_POSTFIX:STRING= -DGit_EXECUTABLE:FILEPATH=${GIT_EXECUTABLE} -DGIT_EXECUTABLE:FILEPATH=${GIT_EXECUTABLE} -DCTK_LIB_CommandLineModules/Backend/LocalProcess:BOOL=ON -DCTK_LIB_CommandLineModules/Frontend/QtGui:BOOL=ON -DCTK_LIB_PluginFramework:BOOL=ON -DCTK_LIB_DICOM/Widgets:BOOL=ON -DCTK_LIB_XNAT/Core:BOOL=ON -DCTK_PLUGIN_org.commontk.eventadmin:BOOL=ON -DCTK_PLUGIN_org.commontk.configadmin:BOOL=ON -DCTK_USE_GIT_PROTOCOL:BOOL=OFF -DDCMTK_URL:STRING=${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/CTK_DCMTK_085525e6.tar.gz # See bug 19073 -DPythonQt_URL:STRING=${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/PythonQt_36ab9c7c.tar.gz - -DqRestAPI_URL:STRING=${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/qRestAPI_4293694a.tar.gz + -DqRestAPI_URL:STRING=https://www.dropbox.com/s/ecrg9mc7ytw40li/qRestAPI_db64f424.tar.gz CMAKE_CACHE_ARGS ${ep_common_cache_args} CMAKE_CACHE_DEFAULT_ARGS ${ep_common_cache_default_args} DEPENDS ${proj_DEPENDENCIES} ) ExternalProject_Get_Property(${proj} binary_dir) set(CTK_DIR ${binary_dir}) #set(CTK_DIR ${ep_prefix}) #mitkFunctionInstallExternalCMakeProject(${proj}) else() mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}") endif() endif() diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatConnectionPreferencePage.cpp b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatConnectionPreferencePage.cpp index 467bb80a8f..ef30250c24 100644 --- a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatConnectionPreferencePage.cpp +++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatConnectionPreferencePage.cpp @@ -1,277 +1,304 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkXnatConnectionPreferencePage.h" #include "org_mitk_gui_qt_xnatinterface_Activator.h" #include "berryIPreferencesService.h" #include "berryPlatform.h" #include #include #include #include #include #include #include #include "ctkXnatSession.h" #include "ctkXnatLoginProfile.h" #include "ctkXnatException.h" #include using namespace berry; QmitkXnatConnectionPreferencePage::QmitkXnatConnectionPreferencePage() : m_Control(0) { } void QmitkXnatConnectionPreferencePage::Init(berry::IWorkbench::Pointer) { } void QmitkXnatConnectionPreferencePage::CreateQtControl(QWidget* parent) { IPreferencesService* prefService = Platform::GetPreferencesService(); berry::IPreferences::Pointer _XnatConnectionPreferencesNode = prefService->GetSystemPreferences()->Node("/XnatConnection"); m_XnatConnectionPreferencesNode = _XnatConnectionPreferencesNode; m_Controls.setupUi(parent); m_Control = new QWidget(parent); m_Control->setLayout(m_Controls.gridLayout); ctkXnatSession* session; try { session = mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatModuleContext()->GetService( mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatModuleContext()->GetServiceReference()); } catch (std::invalid_argument) { session = nullptr; } if (session != nullptr) { if (session->isOpen()) { - m_Controls.testConnectionButton->setText("Disconnect"); + m_Controls.xnatTestConnectionButton->setText("Disconnect"); } else { - m_Controls.testConnectionButton->setText("Connect"); + m_Controls.xnatTestConnectionButton->setText("Connect"); } } const QIntValidator *portV = new QIntValidator(0, 65535, parent); - m_Controls.inPort->setValidator(portV); + m_Controls.inXnatPort->setValidator(portV); const QRegExp hostRx("^(https?)://[^ /](\\S)+$"); const QRegExpValidator *hostV = new QRegExpValidator(hostRx, parent); - m_Controls.inHostAddress->setValidator(hostV); + m_Controls.inXnatHostAddress->setValidator(hostV); - connect(m_Controls.testConnectionButton, SIGNAL(clicked()), this, SLOT(ToggleConnection())); + connect(m_Controls.xnatTestConnectionButton, SIGNAL(clicked()), this, SLOT(ToggleConnection())); - connect(m_Controls.inHostAddress, SIGNAL(editingFinished()), this, SLOT(UrlChanged())); - connect(m_Controls.inDownloadPath, SIGNAL(editingFinished()), this, SLOT(DownloadPathChanged())); + connect(m_Controls.inXnatHostAddress, SIGNAL(editingFinished()), this, SLOT(UrlChanged())); + connect(m_Controls.inXnatDownloadPath, SIGNAL(editingFinished()), this, SLOT(DownloadPathChanged())); + + connect(m_Controls.cbUseNetworkProxy, SIGNAL(toggled(bool)), this, SLOT(onUseNetworkProxy(bool))); + + m_Controls.groupBoxProxySettings->setVisible(m_Controls.cbUseNetworkProxy->isChecked()); this->Update(); } QWidget* QmitkXnatConnectionPreferencePage::GetQtControl() const { return m_Control; } bool QmitkXnatConnectionPreferencePage::PerformOk() { if (!UserInformationEmpty()) { IPreferences::Pointer _XnatConnectionPreferencesNode = m_XnatConnectionPreferencesNode.Lock(); if (_XnatConnectionPreferencesNode.IsNotNull()) { - _XnatConnectionPreferencesNode->Put(m_Controls.hostAddressLabel->text(), m_Controls.inHostAddress->text()); - _XnatConnectionPreferencesNode->Put(m_Controls.portLabel->text(), m_Controls.inPort->text()); - _XnatConnectionPreferencesNode->Put(m_Controls.usernameLabel->text(), m_Controls.inUsername->text()); - _XnatConnectionPreferencesNode->Put(m_Controls.passwortLabel->text(), m_Controls.inPassword->text()); - _XnatConnectionPreferencesNode->Put(m_Controls.downloadPathLabel->text(), m_Controls.inDownloadPath->text()); - + _XnatConnectionPreferencesNode->Put(m_Controls.xnatHostAddressLabel->text(), m_Controls.inXnatHostAddress->text()); + _XnatConnectionPreferencesNode->Put(m_Controls.xnatPortLabel->text(), m_Controls.inXnatPort->text()); + _XnatConnectionPreferencesNode->Put(m_Controls.xnatUsernameLabel->text(), m_Controls.inXnatUsername->text()); + _XnatConnectionPreferencesNode->Put(m_Controls.xnatPasswortLabel->text(), m_Controls.inXnatPassword->text()); + _XnatConnectionPreferencesNode->Put(m_Controls.xnatDownloadPathLabel->text(), m_Controls.inXnatDownloadPath->text()); + + // Network proxy settings + _XnatConnectionPreferencesNode->PutBool(m_Controls.cbUseNetworkProxy->text(), m_Controls.cbUseNetworkProxy->isChecked()); + _XnatConnectionPreferencesNode->Put(m_Controls.proxyAddressLabel->text(), m_Controls.inProxyAddress->text()); + _XnatConnectionPreferencesNode->Put(m_Controls.proxyPortLabel->text(), m_Controls.inProxyPort->text()); + _XnatConnectionPreferencesNode->Put(m_Controls.proxyUsernameLabel->text(), m_Controls.inProxyUsername->text()); + _XnatConnectionPreferencesNode->Put(m_Controls.proxyPasswordLabel->text(), m_Controls.inProxyPassword->text()); _XnatConnectionPreferencesNode->Flush(); return true; } } else { QMessageBox::critical(QApplication::activeWindow(), "Saving Preferences failed", "The connection parameters in XNAT Preferences were empty.\nPlease use the 'Connect' button to validate the connection parameters."); } return false; } void QmitkXnatConnectionPreferencePage::PerformCancel() { } bool QmitkXnatConnectionPreferencePage::UserInformationEmpty() { // To check empty QLineEdits in the following QString errString; - if (m_Controls.inHostAddress->text().isEmpty()) + if (m_Controls.inXnatHostAddress->text().isEmpty()) { errString += "Server Address is empty.\n"; } - if (m_Controls.inUsername->text().isEmpty()) + if (m_Controls.inXnatUsername->text().isEmpty()) { errString += "Username is empty.\n"; } - if (m_Controls.inPassword->text().isEmpty()) + if (m_Controls.inXnatPassword->text().isEmpty()) { errString += "Password is empty.\n"; } // if something is empty if (!errString.isEmpty()) { - m_Controls.testConnectionLabel->setStyleSheet("QLabel { color: red; }"); - m_Controls.testConnectionLabel->setText("Connecting failed.\n" + errString); + m_Controls.xnatTestConnectionLabel->setStyleSheet("QLabel { color: red; }"); + m_Controls.xnatTestConnectionLabel->setText("Connecting failed.\n" + errString); return true; } else { return false; } } void QmitkXnatConnectionPreferencePage::Update() { IPreferences::Pointer _XnatConnectionPreferencesNode = m_XnatConnectionPreferencesNode.Lock(); if (_XnatConnectionPreferencesNode.IsNotNull()) { - m_Controls.inHostAddress->setText(_XnatConnectionPreferencesNode->Get( - m_Controls.hostAddressLabel->text(), m_Controls.inHostAddress->text())); - m_Controls.inPort->setText(_XnatConnectionPreferencesNode->Get( - m_Controls.portLabel->text(), m_Controls.inPort->text())); - m_Controls.inUsername->setText(_XnatConnectionPreferencesNode->Get( - m_Controls.usernameLabel->text(), m_Controls.inUsername->text())); - m_Controls.inPassword->setText(_XnatConnectionPreferencesNode->Get( - m_Controls.passwortLabel->text(), m_Controls.inPassword->text())); - m_Controls.inDownloadPath->setText(_XnatConnectionPreferencesNode->Get( - m_Controls.downloadPathLabel->text(), m_Controls.inDownloadPath->text())); + m_Controls.inXnatHostAddress->setText(_XnatConnectionPreferencesNode->Get( + m_Controls.xnatHostAddressLabel->text(), m_Controls.inXnatHostAddress->text())); + m_Controls.inXnatPort->setText(_XnatConnectionPreferencesNode->Get( + m_Controls.xnatPortLabel->text(), m_Controls.inXnatPort->text())); + m_Controls.inXnatUsername->setText(_XnatConnectionPreferencesNode->Get( + m_Controls.xnatUsernameLabel->text(), m_Controls.inXnatUsername->text())); + m_Controls.inXnatPassword->setText(_XnatConnectionPreferencesNode->Get( + m_Controls.xnatPasswortLabel->text(), m_Controls.inXnatPassword->text())); + m_Controls.inXnatDownloadPath->setText(_XnatConnectionPreferencesNode->Get( + m_Controls.xnatDownloadPathLabel->text(), m_Controls.inXnatDownloadPath->text())); + + // Network proxy settings + m_Controls.cbUseNetworkProxy->setChecked(_XnatConnectionPreferencesNode->GetBool( + m_Controls.cbUseNetworkProxy->text(), false)); + m_Controls.inProxyAddress->setText(_XnatConnectionPreferencesNode->Get( + m_Controls.proxyAddressLabel->text(), m_Controls.inProxyAddress->text())); + m_Controls.inProxyPort->setText(_XnatConnectionPreferencesNode->Get( + m_Controls.proxyPortLabel->text(), m_Controls.inProxyPort->text())); + m_Controls.inProxyUsername->setText(_XnatConnectionPreferencesNode->Get( + m_Controls.proxyUsernameLabel->text(), m_Controls.inProxyUsername->text())); + m_Controls.inProxyPassword->setText(_XnatConnectionPreferencesNode->Get( + m_Controls.proxyPasswordLabel->text(), m_Controls.inProxyPassword->text())); } } void QmitkXnatConnectionPreferencePage::UrlChanged() { - m_Controls.inHostAddress->setStyleSheet("QLineEdit { background-color: white; }"); - QString str = m_Controls.inHostAddress->text(); + m_Controls.inXnatHostAddress->setStyleSheet("QLineEdit { background-color: white; }"); + QString str = m_Controls.inXnatHostAddress->text(); while (str.endsWith("/")) { str = str.left(str.length() - 1); } - m_Controls.inHostAddress->setText(str); + m_Controls.inXnatHostAddress->setText(str); - QUrl url(m_Controls.inHostAddress->text()); + QUrl url(m_Controls.inXnatHostAddress->text()); if (!url.isValid()) { - m_Controls.inHostAddress->setStyleSheet("QLineEdit { background-color: red; }"); + m_Controls.inXnatHostAddress->setStyleSheet("QLineEdit { background-color: red; }"); } } void QmitkXnatConnectionPreferencePage::DownloadPathChanged() { - m_Controls.inDownloadPath->setStyleSheet("QLineEdit { background-color: white; }"); - QString downloadPath = m_Controls.inDownloadPath->text(); + m_Controls.inXnatDownloadPath->setStyleSheet("QLineEdit { background-color: white; }"); + QString downloadPath = m_Controls.inXnatDownloadPath->text(); if (!downloadPath.isEmpty()) { if (downloadPath.lastIndexOf("/") != downloadPath.size() - 1) { downloadPath.append("/"); - m_Controls.inDownloadPath->setText(downloadPath); + m_Controls.inXnatDownloadPath->setText(downloadPath); } - QFileInfo path(m_Controls.inDownloadPath->text()); + QFileInfo path(m_Controls.inXnatDownloadPath->text()); if (!path.isDir()) { - m_Controls.inDownloadPath->setStyleSheet("QLineEdit { background-color: red; }"); + m_Controls.inXnatDownloadPath->setStyleSheet("QLineEdit { background-color: red; }"); } } } +void QmitkXnatConnectionPreferencePage::onUseNetworkProxy(bool status) +{ + m_Controls.groupBoxProxySettings->setVisible(status); +} + void QmitkXnatConnectionPreferencePage::ToggleConnection() { ctkXnatSession* session = 0; try { session = mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatModuleContext()->GetService( mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatModuleContext()->GetServiceReference()); } catch (std::invalid_argument) { if (!UserInformationEmpty()) { PerformOk(); mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatSessionManager()->CreateXnatSession(); session = mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatModuleContext()->GetService( mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatModuleContext()->GetServiceReference()); } } if (session != 0 && session->isOpen()) { mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatSessionManager()->CloseXnatSession(); - m_Controls.testConnectionButton->setText("Connect"); - m_Controls.testConnectionLabel->clear(); + m_Controls.xnatTestConnectionButton->setText("Connect"); + m_Controls.xnatTestConnectionLabel->clear(); } else if (session != 0 && !session->isOpen()) { - m_Controls.testConnectionButton->setEnabled(false); + m_Controls.xnatTestConnectionButton->setEnabled(false); try { mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatSessionManager()->OpenXnatSession(); - m_Controls.testConnectionButton->setText("Disconnect"); - m_Controls.testConnectionLabel->setStyleSheet("QLabel { color: green; }"); - m_Controls.testConnectionLabel->setText("Connecting successful."); + m_Controls.xnatTestConnectionButton->setText("Disconnect"); + m_Controls.xnatTestConnectionLabel->setStyleSheet("QLabel { color: green; }"); + m_Controls.xnatTestConnectionLabel->setText("Connecting successful."); } catch (const ctkXnatAuthenticationException& auth) { - m_Controls.testConnectionLabel->setStyleSheet("QLabel { color: red; }"); - m_Controls.testConnectionLabel->setText("Connecting failed:\nAuthentication error."); + m_Controls.xnatTestConnectionLabel->setStyleSheet("QLabel { color: red; }"); + m_Controls.xnatTestConnectionLabel->setText("Connecting failed:\nAuthentication error."); MITK_INFO << auth.message().toStdString(); mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatSessionManager()->CloseXnatSession(); } catch (const ctkException& e) { - m_Controls.testConnectionLabel->setStyleSheet("QLabel { color: red; }"); - m_Controls.testConnectionLabel->setText("Connecting failed:\nInvalid Server Adress"); + m_Controls.xnatTestConnectionLabel->setStyleSheet("QLabel { color: red; }"); + m_Controls.xnatTestConnectionLabel->setText("Connecting failed:\nInvalid Server Adress"); MITK_INFO << e.message().toStdString(); mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatSessionManager()->CloseXnatSession(); } - m_Controls.testConnectionButton->setEnabled(true); + m_Controls.xnatTestConnectionButton->setEnabled(true); } } diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatConnectionPreferencePage.h b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatConnectionPreferencePage.h index c597dcc6b2..53ae33884b 100644 --- a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatConnectionPreferencePage.h +++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatConnectionPreferencePage.h @@ -1,84 +1,86 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKXNATCONNECTIONPREFERENCEPAGE_H_ #define QMITKXNATCONNECTIONPREFERENCEPAGE_H_ #include "berryIQtPreferencePage.h" #include #include "ui_QmitkXnatConnectionPreferencePageControls.h" class QWidget; class QLineEdit; struct QmitkXnatConnectionPreferencePage : public QObject, public berry::IQtPreferencePage { Q_OBJECT Q_INTERFACES(berry::IPreferencePage) public: QmitkXnatConnectionPreferencePage(); void Init(berry::IWorkbench::Pointer workbench) override; void CreateQtControl(QWidget* widget) override; QWidget* GetQtControl() const override; /// /// \see IPreferencePage::PerformOk() /// virtual bool PerformOk() override; /// /// \see IPreferencePage::PerformCancel() /// virtual void PerformCancel() override; /// /// \see IPreferencePage::Update() /// virtual void Update() override; protected slots: virtual void UrlChanged(); virtual void DownloadPathChanged(); /// /// Toggles the Connection in the Service Registry from opened to closed or the other way around. /// virtual void ToggleConnection(); + virtual void onUseNetworkProxy(bool); + protected: Ui::QmitkXnatConnectionPreferencePageControls m_Controls; QWidget* m_Control; berry::IPreferences::WeakPtr m_XnatConnectionPreferencesNode; private: /// /// Checks if the entered user information is empty. /// virtual bool UserInformationEmpty(); }; #endif /* QMITKXNATCONNECTIONPREFERENCEPAGE_H_ */ diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatConnectionPreferencePageControls.ui b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatConnectionPreferencePageControls.ui index 9b26a9b683..e1d90a0961 100644 --- a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatConnectionPreferencePageControls.ui +++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatConnectionPreferencePageControls.ui @@ -1,143 +1,255 @@ QmitkXnatConnectionPreferencePageControls 0 0 742 - 208 + 349 0 0 653 116 16777215 16777215 Form - - - - Port - - - - - - - <html><head/><body><p>Examples:</p><p>https://central.xnat.org<br/>http://localhost/xnat</p></body></html> - - - http(s):// - - - - - - - - 50 - 16777215 - - - - Standard-Port: 80 - + + - + Use Network Proxy - - - - - - Username - - - - - - - testuser + + true - - - Server Address - + + + XNAT Connection Settings + + + + + + Server Address + + + + + + + <html><head/><body><p>Examples:</p><p>https://central.xnat.org<br/>http://localhost/xnat</p></body></html> + + + http(s):// + + + + + + + Port + + + + + + + + 50 + 16777215 + + + + Standard-Port: 80 + + + + + + + + + + Username + + + + + + + testuser + + + + + + + Password + + + + + + + QLineEdit::Password + + + testpassword + + + + + + + Download Path + + + + + + + + + + Connect + + + + + + + Qt::LeftToRight + + + 1 + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + - - - - Password - - - - - - - QLineEdit::Password - - - testpassword - - - - - - - - - Download Path - + + + Network Proxy Settings + + + + + + + 50 + 16777215 + + + + Standard-Port: 80 + + + + + + + + + + Proxy Password + + + + + + + Proxy Username + + + + + + + <html><head/><body><p>Examples:</p><p>https://central.xnat.org<br/>http://localhost/xnat</p></body></html> + + + http(s):// + + + + + + + Proxy Port + + + + + + + QLineEdit::Password + + + testpassword + + + + + + + testuser + + + + + + + Proxy Server Address + + + + - - - Connect - - - - - - - Qt::LeftToRight - - - 1 + + + Qt::Vertical - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + 20 + 40 + - + diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatSessionManager.cpp b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatSessionManager.cpp index 142fb9cefd..22d18369f8 100644 --- a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatSessionManager.cpp +++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatSessionManager.cpp @@ -1,87 +1,104 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkXnatSessionManager.h" #include "org_mitk_gui_qt_xnatinterface_Activator.h" #include "berryPlatform.h" #include "berryIPreferences.h" #include "mitkLogMacros.h" -#include #include +#include +#include #include "ctkXnatSession.h" #include "ctkXnatException.h" QmitkXnatSessionManager::QmitkXnatSessionManager() : m_Session(0) { } QmitkXnatSessionManager::~QmitkXnatSessionManager() { if(m_SessionRegistration != 0) { m_SessionRegistration.Unregister(); } if(m_Session != 0) { delete m_Session; } } void QmitkXnatSessionManager::OpenXnatSession() { ctkXnatSession* session = mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatModuleContext()->GetService(m_SessionRegistration.GetReference()); if(session == NULL) return; if(!session->isOpen()) { session->open(); } } void QmitkXnatSessionManager::CreateXnatSession() { berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); berry::IPreferences::Pointer nodeConnectionPref = prefService->GetSystemPreferences()->Node("/XnatConnection"); QUrl url(nodeConnectionPref->Get("Server Address", "")); url.setPort(nodeConnectionPref->Get("Port", "").toInt()); ctkXnatLoginProfile profile; profile.setName("Default"); profile.setServerUrl(url); profile.setUserName(nodeConnectionPref->Get("Username", "")); profile.setPassword(nodeConnectionPref->Get("Password", "")); profile.setDefault(true); m_Session = new ctkXnatSession(profile); + if (nodeConnectionPref->Get("Proxy Server Address", "").length() != 0) + { + QNetworkProxy proxy; + proxy.setType(QNetworkProxy::HttpProxy); + proxy.setHostName(nodeConnectionPref->Get("Proxy Server Address", "")); + proxy.setPort(nodeConnectionPref->Get("Proxy Port", "").toUShort()); + + if (nodeConnectionPref->Get("Proxy Username", "").length() != 0 && + nodeConnectionPref->Get("Proxy Password", "").length() != 0) + { + proxy.setUser(nodeConnectionPref->Get("Proxy Username", "")); + proxy.setPassword(nodeConnectionPref->Get("Proxy Password", "")); + } + // Setting the proxy + m_Session->setHttpNetworkProxy(proxy); + } m_SessionRegistration = mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatModuleContext()->RegisterService(m_Session); } void QmitkXnatSessionManager::CloseXnatSession() { ctkXnatSession* session = mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatModuleContext()->GetService(m_SessionRegistration.GetReference()); session->close(); m_SessionRegistration.Unregister(); m_SessionRegistration = 0; delete m_Session; m_Session = 0; }