CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkXnatSession.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  Library: XNAT/Core
4 
5  Copyright (c) University College London,
6  Centre for Medical Image Computing
7 
8  Licensed under the Apache License, Version 2.0 (the "License");
9  you may not use this file except in compliance with the License.
10  You may obtain a copy of the License at
11 
12  http://www.apache.org/licenses/LICENSE-2.0
13 
14  Unless required by applicable law or agreed to in writing, software
15  distributed under the License is distributed on an "AS IS" BASIS,
16  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  See the License for the specific language governing permissions and
18  limitations under the License.
19 
20 =============================================================================*/
21 
22 #ifndef CTKXNATSESSION_H
23 #define CTKXNATSESSION_H
24 
25 #include "ctkXNATCoreExport.h"
26 
27 #include <QScopedPointer>
28 #include <QString>
29 
30 #include <QObject>
31 #include <QVariantMap>
32 #include <QUuid>
33 
34 class QDateTime;
35 class QNetworkProxy;
36 
37 class ctkXnatSessionPrivate;
38 
39 class ctkXnatFile;
41 class ctkXnatDataModel;
42 class ctkXnatObject;
43 class ctkXnatResource;
44 
51 class CTK_XNAT_CORE_EXPORT ctkXnatSession : public QObject
52 {
53  Q_OBJECT
54 
55 public:
56 
57  typedef QMap<QString, QString> UrlParameters;
58  typedef QMap<QByteArray, QByteArray> HttpRawHeaders;
59 
60  ctkXnatSession(const ctkXnatLoginProfile& loginProfile);
62 
74  void open();
75 
79  void close();
80 
85  bool isOpen() const;
86 
92  QString version() const;
93 
101  QDateTime expirationDate() const;
102 
108  QDateTime renew();
109 
115 
123  QUrl url() const;
124 
132  QString userName() const;
133 
141  QString password() const;
142 
148  QString sessionId() const;
149 
161  void setDefaultDownloadDir(const QString& path);
162 
170  void setHttpNetworkProxy(const QNetworkProxy& proxy);
171 
176  QString defaultDownloadDir() const;
177 
179 
189  QUuid httpGet(const QString& resource,
190  const UrlParameters& parameters = UrlParameters(),
191  const HttpRawHeaders& rawHeaders = HttpRawHeaders());
192 
201  QList<ctkXnatObject*> httpResults(const QUuid& uuid, const QString& schemaType);
202 
211  QUuid httpPut(const QString& resource,
212  const UrlParameters& parameters = UrlParameters(),
213  const HttpRawHeaders& rawHeaders = HttpRawHeaders());
214 
222  QList<QVariantMap> httpSync(const QUuid& uuid);
223 
231  const QMap<QByteArray, QByteArray> httpHeadSync(const QUuid& uuid);
232 
233  bool exists(const ctkXnatObject* object);
234 
235  void remove(ctkXnatObject* object);
236 
243  void download(const QString& fileName,
244  const QString& resource,
245  const UrlParameters& parameters = UrlParameters(),
246  const HttpRawHeaders& rawHeaders = HttpRawHeaders());
247 
254  void upload(ctkXnatFile *xnatFile,
255  const UrlParameters& parameters = UrlParameters(),
256  const HttpRawHeaders& rawHeaders = HttpRawHeaders());
257 
263  QUuid httpHead(const QString& resourceUri);
264 
269  Q_SIGNAL void sessionRenewed(const QDateTime& expirationDate);
270 
274  Q_SIGNAL void sessionOpened();
275 
279  Q_SIGNAL void sessionAboutToBeClosed();
280 
281 // Q_SIGNAL void uploadFinished();
282 
283  Q_SIGNAL void progress(QUuid, double);
284 
288  Q_SIGNAL void timedOut();
289 
293  Q_SIGNAL void aboutToTimeOut();
294 
295 public slots:
296  void processResult(QUuid queryId, QList<QVariantMap> parameters);
297  void onProgress(QUuid queryId, double onProgress);
298 
299 protected:
300  QScopedPointer<ctkXnatSessionPrivate> d_ptr;
301 
302 private:
303  Q_DECLARE_PRIVATE(ctkXnatSession)
304  Q_DISABLE_COPY(ctkXnatSession)
305  Q_SLOT void emitTimeOut();
306 };
307 
308 #endif
ctkXnatSession::ctkXnatSession
ctkXnatSession(const ctkXnatLoginProfile &loginProfile)
ctkXnatSession::password
QString password() const
Get the password for this XNAT session.
ctkXnatSession::setDefaultDownloadDir
void setDefaultDownloadDir(const QString &path)
Sets the default location where files will be saved after being downloaded.
ctkXnatSession::httpPut
QUuid httpPut(const QString &resource, const UrlParameters &parameters=UrlParameters(), const HttpRawHeaders &rawHeaders=HttpRawHeaders())
TODO.
ctkXnatSession::remove
void remove(ctkXnatObject *object)
ctkXnatFile
Definition: ctkXnatFile.h:37
ctkXnatSession::aboutToTimeOut
Q_SIGNAL void aboutToTimeOut()
Signals that the session will time out in one minute.
ctkXnatSession::sessionAboutToBeClosed
Q_SIGNAL void sessionAboutToBeClosed()
Signals that the session is about to be closed.
ctkXnatSession::loginProfile
ctkXnatLoginProfile loginProfile() const
Get the current login profile for this session object.
ctkXnatSession::upload
void upload(ctkXnatFile *xnatFile, const UrlParameters &parameters=UrlParameters(), const HttpRawHeaders &rawHeaders=HttpRawHeaders())
ctkXnatSession::exists
bool exists(const ctkXnatObject *object)
ctkXnatObject
Definition: ctkXnatObject.h:45
ctkXnatSession::httpHead
QUuid httpHead(const QString &resourceUri)
Sends a http HEAD request to the xnat instance.
ctkXnatSession::timedOut
Q_SIGNAL void timedOut()
Signals that the session has timed out.
ctkXnatSession::close
void close()
Closes this XNAT session.
ctkXnatSession::version
QString version() const
Get the XNAT server version.
QList
Definition: ctkCmdLineModuleBackend.h:30
ctkXnatSession::processResult
void processResult(QUuid queryId, QList< QVariantMap > parameters)
ctkXnatResource
Definition: ctkXnatResource.h:36
ctkXnatSession::url
QUrl url() const
Get XNAT server url.
ctkXnatSession::d_ptr
QScopedPointer< ctkXnatSessionPrivate > d_ptr
Definition: ctkXnatSession.h:300
ctkXnatSession::httpHeadSync
const QMap< QByteArray, QByteArray > httpHeadSync(const QUuid &uuid)
Reads the result of a head request.
ctkXnatSession::HttpRawHeaders
QMap< QByteArray, QByteArray > HttpRawHeaders
Definition: ctkXnatSession.h:58
ctkXnatSession::httpGet
QUuid httpGet(const QString &resource, const UrlParameters &parameters=UrlParameters(), const HttpRawHeaders &rawHeaders=HttpRawHeaders())
TODO.
ctkXnatSession::httpSync
QList< QVariantMap > httpSync(const QUuid &uuid)
TODO.
ctkXnatDataModel
The ctkXnatDataModel class reprents the root object in a XNAT data hierarchy.
Definition: ctkXnatDataModel.h:40
ctkXnatSession::isOpen
bool isOpen() const
Returns the open state of this XNAT session.
ctkXnatSession::expirationDate
QDateTime expirationDate() const
Get the expiration date for this XNAT session.
ctkXnatSession::sessionId
QString sessionId() const
Get the sessionId for this XNAT session.
ctkXnatSession::userName
QString userName() const
Get the user name for this XNAT session.
ctkXnatSession::UrlParameters
QMap< QString, QString > UrlParameters
Definition: ctkXnatSession.h:57
ctkXnatSession::setHttpNetworkProxy
void setHttpNetworkProxy(const QNetworkProxy &proxy)
Sets a network proxy that will be used to connect with XNAT.
ctkXnatSession::defaultDownloadDir
QString defaultDownloadDir() const
returns the default download location
ctkXnatSession
The ctkXnatSession class reprents a session object associated with a specific XNAT connection.
Definition: ctkXnatSession.h:52
ctkXnatSession::~ctkXnatSession
~ctkXnatSession()
ctkXnatLoginProfile
A login profile for XNAT sessions.
Definition: ctkXnatLoginProfile.h:38
ctkXnatSession::progress
Q_SIGNAL void progress(QUuid, double)
ctkXnatSession::sessionRenewed
Q_SIGNAL void sessionRenewed(const QDateTime &expirationDate)
Signals that the session was re-newed.
ctkXnatSession::httpResults
QList< ctkXnatObject * > httpResults(const QUuid &uuid, const QString &schemaType)
TODO.
ctkXnatSession::onProgress
void onProgress(QUuid queryId, double onProgress)
ctkXnatSession::download
void download(const QString &fileName, const QString &resource, const UrlParameters &parameters=UrlParameters(), const HttpRawHeaders &rawHeaders=HttpRawHeaders())
ctkXnatSession::sessionOpened
Q_SIGNAL void sessionOpened()
Signals that the session was just opened.
ctkXnatSession::open
void open()
Open a new XNAT session.
ctkXnatSession::dataModel
ctkXnatDataModel * dataModel() const
ctkXnatSession::renew
QDateTime renew()
Re-new the XNAT session.