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
34class QDateTime;
35class QNetworkProxy;
36
37class ctkXnatSessionPrivate;
38
39class ctkXnatFile;
42class ctkXnatObject;
43class ctkXnatResource;
44
51class CTK_XNAT_CORE_EXPORT ctkXnatSession : public QObject
52{
53 Q_OBJECT
54
55public:
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
295public slots:
296 void processResult(QUuid queryId, QList<QVariantMap> parameters);
297 void onProgress(QUuid queryId, double onProgress);
298
299protected:
300 QScopedPointer<ctkXnatSessionPrivate> d_ptr;
301
302private:
303 Q_DECLARE_PRIVATE(ctkXnatSession)
304 Q_DISABLE_COPY(ctkXnatSession)
305 Q_SLOT void emitTimeOut();
306};
307
308#endif
The ctkXnatDataModel class reprents the root object in a XNAT data hierarchy.
A login profile for XNAT sessions.
The ctkXnatSession class reprents a session object associated with a specific XNAT connection.
Q_SIGNAL void sessionAboutToBeClosed()
Signals that the session is about to be closed.
QString version() const
Get the XNAT server version.
ctkXnatLoginProfile loginProfile() const
Get the current login profile for this session object.
void close()
Closes this XNAT session.
void setDefaultDownloadDir(const QString &path)
Sets the default location where files will be saved after being downloaded.
QUrl url() const
Get XNAT server url.
bool isOpen() const
Returns the open state of this XNAT session.
QUuid httpHead(const QString &resourceUri)
Sends a http HEAD request to the xnat instance.
const QMap< QByteArray, QByteArray > httpHeadSync(const QUuid &uuid)
Reads the result of a head request.
Q_SIGNAL void aboutToTimeOut()
Signals that the session will time out in one minute.
void download(const QString &fileName, const QString &resource, const UrlParameters &parameters=UrlParameters(), const HttpRawHeaders &rawHeaders=HttpRawHeaders())
QScopedPointer< ctkXnatSessionPrivate > d_ptr
ctkXnatDataModel * dataModel() const
QList< QVariantMap > httpSync(const QUuid &uuid)
TODO.
QList< ctkXnatObject * > httpResults(const QUuid &uuid, const QString &schemaType)
TODO.
QMap< QByteArray, QByteArray > HttpRawHeaders
QUuid httpPut(const QString &resource, const UrlParameters &parameters=UrlParameters(), const HttpRawHeaders &rawHeaders=HttpRawHeaders())
TODO.
QString password() const
Get the password for this XNAT session.
Q_SIGNAL void timedOut()
Signals that the session has timed out.
void upload(ctkXnatFile *xnatFile, const UrlParameters &parameters=UrlParameters(), const HttpRawHeaders &rawHeaders=HttpRawHeaders())
void setHttpNetworkProxy(const QNetworkProxy &proxy)
Sets a network proxy that will be used to connect with XNAT.
QDateTime expirationDate() const
Get the expiration date for this XNAT session.
void open()
Open a new XNAT session.
void processResult(QUuid queryId, QList< QVariantMap > parameters)
Q_SIGNAL void progress(QUuid, double)
bool exists(const ctkXnatObject *object)
void remove(ctkXnatObject *object)
QUuid httpGet(const QString &resource, const UrlParameters &parameters=UrlParameters(), const HttpRawHeaders &rawHeaders=HttpRawHeaders())
TODO.
QDateTime renew()
Re-new the XNAT session.
QMap< QString, QString > UrlParameters
ctkXnatSession(const ctkXnatLoginProfile &loginProfile)
void onProgress(QUuid queryId, double onProgress)
Q_SIGNAL void sessionRenewed(const QDateTime &expirationDate)
Signals that the session was re-newed.
Q_SIGNAL void sessionOpened()
Signals that the session was just opened.
QString sessionId() const
Get the sessionId for this XNAT session.
QString defaultDownloadDir() const
returns the default download location
QString userName() const
Get the user name for this XNAT session.