Przeglądaj źródła

Renamed session time out related variables and signals/slots

Andreas Fetzer 9 lat temu
rodzic
commit
3fb6975a77

+ 3 - 3
Applications/ctkXnatTreeBrowser/ctkXnatTreeBrowserMainWindow.cpp

@@ -101,8 +101,8 @@ void ctkXnatTreeBrowserMainWindow::loginButtonPushed()
       {
         ui->loginButton->setText("Logout");
         ui->loginLabel->setText(QString("Connected: %1").arg(m_Session->url().toString()));
-        this->connect(m_Session, SIGNAL(sessionTimedOut()), this, SLOT(sessionTimedOutMsg()));
-        this->connect(m_Session, SIGNAL(sessionAboutToBeTimedOut()), this, SLOT(sessionTimesOutSoonMsg()));
+        this->connect(m_Session, SIGNAL(timedOut()), this, SLOT(sessionTimedOutMsg()));
+        this->connect(m_Session, SIGNAL(aboutToTimeOut()), this, SLOT(sessionAboutToTimeOutMsg()));
 
         ctkXnatDataModel* dataModel = m_Session->dataModel();
         m_TreeModel->addDataModel(dataModel);
@@ -198,7 +198,7 @@ void ctkXnatTreeBrowserMainWindow::sessionTimedOutMsg()
   QMessageBox::warning(this, "Session Timeout", "The session timed out.");
 }
 
-void ctkXnatTreeBrowserMainWindow::sessionTimesOutSoonMsg()
+void ctkXnatTreeBrowserMainWindow::sessionAboutToTimeOutMsg()
 {
   QMessageBox msgBox;
   msgBox.setIcon(QMessageBox::Warning);

+ 1 - 1
Applications/ctkXnatTreeBrowser/ctkXnatTreeBrowserMainWindow.h

@@ -49,7 +49,7 @@ private Q_SLOTS:
   void addResourceClicked();
   void uploadFileClicked();
   void sessionTimedOutMsg();
-  void sessionTimesOutSoonMsg();
+  void sessionAboutToTimeOutMsg();
 
 private:
   Ui::ctkXnatTreeBrowserMainWindow* ui;

+ 23 - 23
Libs/XNAT/Core/ctkXnatSession.cpp

@@ -72,13 +72,13 @@ public:
 
   QTimer* timer;
 
-  // The time in milliseconds untill the signal sessionAboutToBeTimedOut gets emitted
-  int timeToSessionTimeOutWarning;
+  // The time in milliseconds until the signal aboutToTimeOut gets emitted
+  int timeOutWarningPeriod;
 
-  // The time in milliseconds untill the signal sessionTimedOut gets emitted
+  // The time in milliseconds until the signal timedOut gets emitted
   // Default XNAT session timeout setting. This value will be updated after
   // "updateExpirationDate" is called the first time.
-  int timeToSessionTimedOut = 60000;
+  int timeOutPeriod = 60000;
 
   ctkXnatSessionPrivate(const ctkXnatLoginProfile& loginProfile, ctkXnatSession* q);
   ~ctkXnatSessionPrivate();
@@ -224,10 +224,10 @@ QDateTime ctkXnatSessionPrivate::updateExpirationDate(qRestResult* restResult)
           }
           QByteArray timeSpan = expirationCookie[1];
           timeSpan.chop(1);
-          this->timeToSessionTimeOutWarning = timeSpan.toLong() - this->timeToSessionTimedOut;
+          this->timeOutWarningPeriod = timeSpan.toLong() - this->timeOutPeriod;
           expirationDate = expirationDate.addMSecs(timeSpan.toLong());
           sessionProperties[SESSION_EXPIRATION_DATE] = expirationDate.toString(Qt::ISODate);
-          this->timer->start(this->timeToSessionTimeOutWarning);
+          this->timer->start(this->timeOutWarningPeriod);
           emit q->sessionRenewed(expirationDate);
         }
       }
@@ -377,7 +377,7 @@ void ctkXnatSession::open()
   QScopedPointer<qRestResult> restResult(d->xnat->takeResult(uuid));
   if (restResult)
   {
-    QObject::connect(d->timer, SIGNAL(timeout()), this, SLOT(emitSessionTimeOut()));
+    QObject::connect(d->timer, SIGNAL(timeout()), this, SLOT(emitTimeOut()));
 
     QString sessionId = restResult->result()["content"].toString();
     d->sessionId = sessionId;
@@ -530,7 +530,7 @@ QUuid ctkXnatSession::httpGet(const QString& resource, const ctkXnatSession::Url
 {
   Q_D(ctkXnatSession);
   d->checkSession();
-  d->timer->start(d->timeToSessionTimeOutWarning);
+  d->timer->start(d->timeOutWarningPeriod);
   return d->xnat->get(resource, parameters, rawHeaders);
 }
 
@@ -545,7 +545,7 @@ QList<ctkXnatObject*> ctkXnatSession::httpResults(const QUuid& uuid, const QStri
   {
     d->throwXnatException("Http request failed.");
   }
-  d->timer->start(d->timeToSessionTimeOutWarning);
+  d->timer->start(d->timeOutWarningPeriod);
   return d->results(restResult.data(), schemaType);
 }
 
@@ -554,7 +554,7 @@ QUuid ctkXnatSession::httpPut(const QString& resource, const ctkXnatSession::Url
 {
   Q_D(ctkXnatSession);
   d->checkSession();
-  d->timer->start(d->timeToSessionTimeOutWarning);
+  d->timer->start(d->timeOutWarningPeriod);
   return d->xnat->put(resource, parameters);
 }
 
@@ -583,7 +583,7 @@ const QMap<QByteArray, QByteArray> ctkXnatSession::httpHeadSync(const QUuid &uui
 {
   Q_D(ctkXnatSession);
   QScopedPointer<qRestResult> result (d->xnat->takeResult(uuid));
-  d->timer->start(d->timeToSessionTimeOutWarning);
+  d->timer->start(d->timeOutWarningPeriod);
   if (result == NULL)
   {
     d->throwXnatException("Sending HEAD request failed.");
@@ -596,7 +596,7 @@ QUuid ctkXnatSession::httpHead(const QString& resourceUri)
 {
   Q_D(ctkXnatSession);
   QUuid queryId = d->xnat->head(resourceUri);
-  d->timer->start(d->timeToSessionTimeOutWarning);
+  d->timer->start(d->timeOutWarningPeriod);
   return queryId;
 }
 
@@ -607,7 +607,7 @@ bool ctkXnatSession::exists(const ctkXnatObject* object)
 
   QString query = object->resourceUri();
   bool success = d->xnat->sync(d->xnat->get(query));
-  d->timer->start(d->timeToSessionTimeOutWarning);
+  d->timer->start(d->timeOutWarningPeriod);
 
   return success;
 }
@@ -619,7 +619,7 @@ void ctkXnatSession::remove(ctkXnatObject* object)
 
   QString query = object->resourceUri();
   bool success = d->xnat->sync(d->xnat->del(query));
-  d->timer->start(d->timeToSessionTimeOutWarning);
+  d->timer->start(d->timeOutWarningPeriod);
 
   if (!success)
   {
@@ -637,7 +637,7 @@ void ctkXnatSession::download(const QString& fileName,
 
   QUuid queryId = d->xnat->download(fileName, resource, parameters, rawHeaders);
   d->xnat->sync(queryId);
-  d->timer->start(d->timeToSessionTimeOutWarning);
+  d->timer->start(d->timeOutWarningPeriod);
 }
 
 //----------------------------------------------------------------------------
@@ -666,7 +666,7 @@ void ctkXnatSession::upload(ctkXnatFile *xnatFile,
   QUuid md5QueryID = this->httpGet(md5Query);
   QList<QVariantMap> result = this->httpSync(md5QueryID);
 
-  d->timer->start(d->timeToSessionTimeOutWarning);
+  d->timer->start(d->timeOutWarningPeriod);
 
   QString md5ChecksumRemote ("0");
   // Newly added files are usually at the end of the catalog
@@ -702,7 +702,7 @@ void ctkXnatSession::upload(ctkXnatFile *xnatFile,
     {
       // Remove corrupted file from server
       xnatFile->erase();
-      d->timer->start(d->timeToSessionTimeOutWarning);
+      d->timer->start(d->timeOutWarningPeriod);
       throw ctkXnatException("Upload failed! An error occurred during file upload.");
     }
   }
@@ -720,18 +720,18 @@ void ctkXnatSession::processResult(QUuid queryId, QList<QVariantMap> parameters)
 }
 
 //----------------------------------------------------------------------------
-void ctkXnatSession::emitSessionTimeOut()
+void ctkXnatSession::emitTimeOut()
 {
   Q_D(ctkXnatSession);
 
-  if (d->timer->interval() == d->timeToSessionTimeOutWarning)
+  if (d->timer->interval() == d->timeOutWarningPeriod)
   {
-    d->timer->start(d->timeToSessionTimedOut);
-    emit sessionAboutToBeTimedOut();
+    d->timer->start(d->timeOutPeriod);
+    emit aboutToTimeOut();
   }
-  else if (d->timer->interval() == d->timeToSessionTimedOut)
+  else if (d->timer->interval() == d->timeOutPeriod)
   {
     d->timer->stop();
-    emit sessionTimedOut();
+    emit timedOut();
   }
 }

+ 4 - 4
Libs/XNAT/Core/ctkXnatSession.h

@@ -273,14 +273,14 @@ public:
   Q_SIGNAL void progress(QUuid, double);
 
   /**
-   * @brief Signals that the session is timed out.
+   * @brief Signals that the session has timed out.
    */
-  Q_SIGNAL void sessionTimedOut();
+  Q_SIGNAL void timedOut();
 
   /**
    * @brief Signals that the session will time out in one minute.
    */
-  Q_SIGNAL void sessionAboutToBeTimedOut();
+  Q_SIGNAL void aboutToTimeOut();
 
 public slots:
   void processResult(QUuid queryId, QList<QVariantMap> parameters);
@@ -292,7 +292,7 @@ protected:
 private:
   Q_DECLARE_PRIVATE(ctkXnatSession)
   Q_DISABLE_COPY(ctkXnatSession)
-  Q_SLOT void emitSessionTimeOut();
+  Q_SLOT void emitTimeOut();
 };
 
 #endif