Selaa lähdekoodia

Changed signal that the session times out always in one minute.
Variable for time that the session times out soon renamed.

Daniel Knorr 10 vuotta sitten
vanhempi
commit
27ef21ebf7
1 muutettua tiedostoa jossa 13 lisäystä ja 14 poistoa
  1. 13 14
      Libs/XNAT/Core/ctkXnatSession.cpp

+ 13 - 14
Libs/XNAT/Core/ctkXnatSession.cpp

@@ -70,10 +70,10 @@ public:
   QTimer* timer;
 
   // The time in milliseconds untill the signal sessionAboutToBeTimedOut gets emitted
-  int timeToSessionTimesOutSoon;
+  int timeToSessionTimeOutWarning;
 
   // The time in milliseconds untill the signal sessionTimedOut gets emitted
-  int timeToSessionTimedOut;
+  int timeToSessionTimedOut = 60000;
 
   ctkXnatSessionPrivate(const ctkXnatLoginProfile& loginProfile, ctkXnatSession* q);
   ~ctkXnatSessionPrivate();
@@ -218,11 +218,10 @@ QDateTime ctkXnatSessionPrivate::updateExpirationDate(qRestResult* restResult)
           }
           QByteArray timeSpan = expirationCookie[1];
           timeSpan.chop(1);
-          this->timeToSessionTimesOutSoon = timeSpan.toInt() / 15 * 14;
-          this->timeToSessionTimedOut = timeSpan.toInt() / 15;
+          this->timeToSessionTimeOutWarning = timeSpan.toLong() - this->timeToSessionTimedOut;
           expirationDate = expirationDate.addMSecs(timeSpan.toLong());
           sessionProperties[SESSION_EXPIRATION_DATE] = expirationDate.toString(Qt::ISODate);
-          this->timer->start(this->timeToSessionTimesOutSoon);
+          this->timer->start(this->timeToSessionTimeOutWarning);
           emit q->sessionRenewed(expirationDate);
         }
       }
@@ -495,7 +494,7 @@ QUuid ctkXnatSession::httpGet(const QString& resource, const ctkXnatSession::Url
 {
   Q_D(ctkXnatSession);
   d->checkSession();
-  d->timer->start(d->timeToSessionTimesOutSoon);
+  d->timer->start(d->timeToSessionTimeOutWarning);
   return d->xnat->get(resource, parameters, rawHeaders);
 }
 
@@ -510,7 +509,7 @@ QList<ctkXnatObject*> ctkXnatSession::httpResults(const QUuid& uuid, const QStri
   {
     d->throwXnatException("Http request failed.");
   }
-  d->timer->start(d->timeToSessionTimesOutSoon);
+  d->timer->start(d->timeToSessionTimeOutWarning);
   return d->results(restResult.data(), schemaType);
 }
 
@@ -541,7 +540,7 @@ bool ctkXnatSession::exists(const ctkXnatObject* object)
 
   QString query = object->resourceUri();
   bool success = d->xnat->sync(d->xnat->get(query));
-  d->timer->start(d->timeToSessionTimesOutSoon);
+  d->timer->start(d->timeToSessionTimeOutWarning);
   return success;
 }
 
@@ -550,7 +549,7 @@ const QMap<QByteArray, QByteArray> ctkXnatSession::httpHeadSync(const QUuid &uui
 {
   Q_D(ctkXnatSession);
   QScopedPointer<qRestResult> result (d->xnat->takeResult(uuid));
-  d->timer->start(d->timeToSessionTimesOutSoon);
+  d->timer->start(d->timeToSessionTimeOutWarning);
   if (result == NULL)
   {
     d->throwXnatException("Sending HEAD request failed.");
@@ -563,7 +562,7 @@ QUuid ctkXnatSession::httpHead(const QString& resourceUri)
 {
   Q_D(ctkXnatSession);
   QUuid queryId = d->xnat->head(resourceUri);
-  d->timer->start(d->timeToSessionTimesOutSoon);
+  d->timer->start(d->timeToSessionTimeOutWarning);
   return queryId;
 }
 
@@ -585,7 +584,7 @@ void ctkXnatSession::save(ctkXnatObject* object)
   qDebug() << "ctkXnatSession::save() query:" << query;
   QUuid queryId = d->xnat->put(query);
   qRestResult* result = d->xnat->takeResult(queryId);
-  d->timer->start(d->timeToSessionTimesOutSoon);
+  d->timer->start(d->timeToSessionTimeOutWarning);
 
   if (!result || !result->error().isNull())
   {
@@ -610,7 +609,7 @@ void ctkXnatSession::remove(ctkXnatObject* object)
 
   QString query = object->resourceUri();
   bool success = d->xnat->sync(d->xnat->del(query));
-  d->timer->start(d->timeToSessionTimesOutSoon);
+  d->timer->start(d->timeToSessionTimeOutWarning);
 
   if (!success)
   {
@@ -628,7 +627,7 @@ void ctkXnatSession::download(const QString& fileName,
 
   QUuid queryId = d->xnat->download(fileName, resource, parameters, rawHeaders);
   d->xnat->sync(queryId);
-  d->timer->start(d->timeToSessionTimesOutSoon);
+  d->timer->start(d->timeToSessionTimeOutWarning);
 }
 
 //----------------------------------------------------------------------------
@@ -643,7 +642,7 @@ void ctkXnatSession::emitSessionTimeOut()
 {
   Q_D(ctkXnatSession);
 
-  if (d->timer->interval() == d->timeToSessionTimesOutSoon)
+  if (d->timer->interval() == d->timeToSessionTimeOutWarning)
   {
     d->timer->start(d->timeToSessionTimedOut);
     emit sessionAboutToBeTimedOut();