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);
61  ~ctkXnatSession();
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 
114  ctkXnatLoginProfile loginProfile() const;
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 
178  ctkXnatDataModel* dataModel() const;
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
A login profile for XNAT sessions.
The ctkXnatSession class reprents a session object associated with a specific XNAT connection.
QMap< QString, QString > UrlParameters
The ctkXnatDataModel class reprents the root object in a XNAT data hierarchy.
QMap< QByteArray, QByteArray > HttpRawHeaders
QScopedPointer< ctkXnatSessionPrivate > d_ptr