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 
36 class ctkXnatSessionPrivate;
37 
38 class ctkXnatFile;
40 class ctkXnatDataModel;
41 class ctkXnatObject;
42 class ctkXnatResource;
43 
50 class CTK_XNAT_CORE_EXPORT ctkXnatSession : public QObject
51 {
52  Q_OBJECT
53 
54 public:
55 
56  typedef QMap<QString, QString> UrlParameters;
57  typedef QMap<QByteArray, QByteArray> HttpRawHeaders;
58 
59  ctkXnatSession(const ctkXnatLoginProfile& loginProfile);
60  ~ctkXnatSession();
61 
73  void open();
74 
78  void close();
79 
84  bool isOpen() const;
85 
91  QString version() const;
92 
100  QDateTime expirationDate() const;
101 
107  QDateTime renew();
108 
113  ctkXnatLoginProfile loginProfile() const;
114 
122  QUrl url() const;
123 
131  QString userName() const;
132 
140  QString password() const;
141 
147  QString sessionId() const;
148 
160  void setDefaultDownloadDir(const QString& path);
161 
166  QString defaultDownloadDir() const;
167 
168  ctkXnatDataModel* dataModel() const;
169 
179  QUuid httpGet(const QString& resource,
180  const UrlParameters& parameters = UrlParameters(),
181  const HttpRawHeaders& rawHeaders = HttpRawHeaders());
182 
191  QList<ctkXnatObject*> httpResults(const QUuid& uuid, const QString& schemaType);
192 
201  QUuid httpPut(const QString& resource,
202  const UrlParameters& parameters = UrlParameters(),
203  const HttpRawHeaders& rawHeaders = HttpRawHeaders());
204 
212  QList<QVariantMap> httpSync(const QUuid& uuid);
213 
221  const QMap<QByteArray, QByteArray> httpHeadSync(const QUuid& uuid);
222 
223  bool exists(const ctkXnatObject* object);
224 
225  void remove(ctkXnatObject* object);
226 
233  void download(const QString& fileName,
234  const QString& resource,
235  const UrlParameters& parameters = UrlParameters(),
236  const HttpRawHeaders& rawHeaders = HttpRawHeaders());
237 
244  void upload(ctkXnatFile *xnatFile,
245  const UrlParameters& parameters = UrlParameters(),
246  const HttpRawHeaders& rawHeaders = HttpRawHeaders());
247 
253  QUuid httpHead(const QString& resourceUri);
254 
259  Q_SIGNAL void sessionRenewed(const QDateTime& expirationDate);
260 
264  Q_SIGNAL void sessionOpened();
265 
269  Q_SIGNAL void sessionAboutToBeClosed();
270 
271 // Q_SIGNAL void uploadFinished();
272 
273  Q_SIGNAL void progress(QUuid, double);
274 
275 public slots:
276  void processResult(QUuid queryId, QList<QVariantMap> parameters);
277  void onProgress(QUuid queryId, double onProgress);
278 
279 protected:
280  QScopedPointer<ctkXnatSessionPrivate> d_ptr;
281 
282 private:
283  Q_DECLARE_PRIVATE(ctkXnatSession)
284  Q_DISABLE_COPY(ctkXnatSession)
285 };
286 
287 #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