ATLAS Offline Software
Classes | Public Types | Signals | Public Member Functions | Protected Member Functions | Private Slots | Private Attributes | List of all members
VP1WebWatcher Class Reference

#include <VP1WebWatcher.h>

Inheritance diagram for VP1WebWatcher:
Collaboration diagram for VP1WebWatcher:

Classes

class  Imp
 

Public Types

enum  RESULT {
  UNKNOWN, INVALID_URL, CONNECTION_PROBLEMS, NOT_ON_SERVER,
  EXISTS
}
 

Signals

void urlChanged (const QString &url)
 

Public Member Functions

 VP1WebWatcher (int recheckInterval_ms=30000, QObject *parent=0)
 
 VP1WebWatcher (const QStringList &urls, int recheckInterval_ms=30000, QObject *parent=0)
 
virtual ~VP1WebWatcher ()
 
void addUrl (const QString &)
 
void addUrls (const QStringList &)
 
QStringList urls () const
 
bool isWatchingUrl (const QString &) const
 
void removeUrl (const QString &)
 
void removeUrls (const QStringList &)
 
RESULT lastResult (const QString &url)
 
QString lastResultToString (const QString &url)
 
QDateTime lastModTime (const QString &url)
 

Protected Member Functions

void timerEvent (QTimerEvent *)
 

Private Slots

void httpRequestDone (bool)
 

Private Attributes

Impm_d
 

Detailed Description

Definition at line 29 of file VP1WebWatcher.h.

Member Enumeration Documentation

◆ RESULT

Enumerator
UNKNOWN 
INVALID_URL 
CONNECTION_PROBLEMS 
NOT_ON_SERVER 
EXISTS 

Definition at line 49 of file VP1WebWatcher.h.

49  { UNKNOWN,//Might be because no http request was yet done.
51  CONNECTION_PROBLEMS,//Various problems (server not found, no net connection, etc.)
52  NOT_ON_SERVER,//Request returned 404 (file not found on server)
53  EXISTS };//File was found on server

Constructor & Destructor Documentation

◆ VP1WebWatcher() [1/2]

VP1WebWatcher::VP1WebWatcher ( int  recheckInterval_ms = 30000,
QObject *  parent = 0 
)

Definition at line 177 of file VP1WebWatcher.cxx.

178  : QObject(parent), m_d(new Imp(this,recheckInterval_ms))
179 {
180  startTimer(recheckInterval_ms);
181 }

◆ VP1WebWatcher() [2/2]

VP1WebWatcher::VP1WebWatcher ( const QStringList &  urls,
int  recheckInterval_ms = 30000,
QObject *  parent = 0 
)

Definition at line 184 of file VP1WebWatcher.cxx.

185  : QObject(parent), m_d(new Imp(this,recheckInterval_ms))
186 {
187  addUrls(urls);
188  startTimer(recheckInterval_ms);
189 }

◆ ~VP1WebWatcher()

VP1WebWatcher::~VP1WebWatcher ( )
virtual

Definition at line 192 of file VP1WebWatcher.cxx.

193 {
194  while(!m_d->watchedUrls.isEmpty())
195  removeUrl(m_d->watchedUrls.front()->url);
196  delete m_d;
197 }

Member Function Documentation

◆ addUrl()

void VP1WebWatcher::addUrl ( const QString &  )

Definition at line 226 of file VP1WebWatcher.cxx.

227 {
228  // if (isWatchingUrl(u))
229  // return;
230  // Imp::WatchedUrl * wu = new Imp::WatchedUrl(u);
231  // m_d->watchedUrls << wu;
232  // m_d->startDownload(wu);
233 }

◆ addUrls()

void VP1WebWatcher::addUrls ( const QStringList &  )

Definition at line 236 of file VP1WebWatcher.cxx.

237 {
238  // foreach (QString u, l)
239  // addUrl(u);
240 }

◆ httpRequestDone

void VP1WebWatcher::httpRequestDone ( bool  error)
privateslot

Definition at line 200 of file VP1WebWatcher.cxx.

201 {
202  for(Imp::WatchedUrl*wu : m_d->watchedUrls)
203  if (wu->thread && wu->thread->handleDone(error, sender())) {
204  bool changed = wu->lastResult != wu->thread->result();
205  wu->lastResult = wu->thread->result();
206  m_d->ensureEndThread(wu->thread);
207  if (changed)
208  emit urlChanged(wu->url);
209  return;
210  }
211  //We could not find the thread with that http instance. We must
212  //assume it was terminated.
213 }

◆ isWatchingUrl()

bool VP1WebWatcher::isWatchingUrl ( const QString &  u) const

Definition at line 216 of file VP1WebWatcher.cxx.

217 {
218  for (Imp::WatchedUrl*wu : m_d->watchedUrls) {
219  if (wu->url == u)
220  return true;
221  }
222  return false;
223 }

◆ lastModTime()

QDateTime VP1WebWatcher::lastModTime ( const QString &  url)

Definition at line 325 of file VP1WebWatcher.cxx.

326 {
327  for(Imp::WatchedUrl*wu : m_d->watchedUrls)
328  if (wu->url==url) {
329  if (wu->lastResult.startsWith(VP1WebWatcher_PREFIX))
330  return QDateTime();//invalid
331  QString lastmod = wu->lastResult;
332  lastmod = lastmod.simplified();
333  lastmod.chop(4);
334  QDateTime dt(QDateTime::fromString(lastmod,"ddd, dd MMM yyyy hh:mm:ss"));
335  dt.setTimeSpec(Qt::UTC);
336  return dt;
337  }
338  return QDateTime();//invalid
339 }

◆ lastResult()

VP1WebWatcher::RESULT VP1WebWatcher::lastResult ( const QString &  url)

Definition at line 291 of file VP1WebWatcher.cxx.

292 {
293  for(Imp::WatchedUrl*wu : m_d->watchedUrls)
294  if (wu->url==url) {
295  if (wu->lastResult==VP1WebWatcher_UrlInvalid)
296  return INVALID_URL;
297  if (wu->lastResult==VP1WebWatcher_httpProblems)
298  return CONNECTION_PROBLEMS;
299  if (wu->lastResult==VP1WebWatcher_FileNotExist)
300  return NOT_ON_SERVER;
301  if (wu->lastResult==VP1WebWatcher_Unknown)
302  return UNKNOWN;
303  if (wu->lastResult==VP1WebWatcher_ResultNotReady)
304  return UNKNOWN;
305  return EXISTS;
306  }
307  return UNKNOWN;
308 }

◆ lastResultToString()

QString VP1WebWatcher::lastResultToString ( const QString &  url)

Definition at line 311 of file VP1WebWatcher.cxx.

312 {
313  switch (lastResult(url)) {
314  case UNKNOWN: return "UNKNOWN";
315  case INVALID_URL: return "INVALID_URL";
316  case CONNECTION_PROBLEMS: return "CONNECTION_PROBLEMS";
317  case NOT_ON_SERVER: return "NOT_ON_SERVER";
318  case EXISTS: return "EXISTS";
319  default:
320  return "UNKNOWN";
321  }
322 }

◆ removeUrl()

void VP1WebWatcher::removeUrl ( const QString &  )

Definition at line 252 of file VP1WebWatcher.cxx.

253 {
254  // foreach(Imp::WatchedUrl*wu,m_d->watchedUrls)
255  // if (wu->url == u) {
256  // m_d->watchedUrls.removeAll(wu);
257  // delete wu;
258  // return;
259  // }
260 }

◆ removeUrls()

void VP1WebWatcher::removeUrls ( const QStringList &  )

Definition at line 263 of file VP1WebWatcher.cxx.

264 {
265  // foreach (QString u, l)
266  // removeUrl(u);
267 }

◆ timerEvent()

void VP1WebWatcher::timerEvent ( QTimerEvent *  )
protected

Definition at line 270 of file VP1WebWatcher.cxx.

271 {
272  // const unsigned currentTime = QDateTime::currentDateTime().toTime_t();
273  // foreach(Imp::WatchedUrl*wu,m_d->watchedUrls) {
274  // if (!wu->thread) {
275  // m_d->startDownload(wu);
276  // } else {
277  // //Thread is running. Check that it didn't run for too long.
278  // //
279  // //(No matter what, we never restart running thread that have been
280  // //running for less than a second, or no less than twice the
281  // //recheckInterval!)
282  // if (wu->thread->httpStartTime()>0 && currentTime - wu->thread->httpStartTime() > (unsigned(m_d->recheckInterval_ms) * 1000 * 2 + 1000)) {
283  // m_d->ensureEndThread(wu->thread);
284  // m_d->startDownload(wu);
285  // }
286  // }
287  // }
288 }

◆ urlChanged

void VP1WebWatcher::urlChanged ( const QString &  url)
signal

◆ urls()

QStringList VP1WebWatcher::urls ( ) const

Definition at line 243 of file VP1WebWatcher.cxx.

244 {
245  QStringList l;
246  // foreach(Imp::WatchedUrl*wu,m_d->watchedUrls)
247  // l << wu->url;
248  return l;
249 }

Member Data Documentation

◆ m_d

Imp* VP1WebWatcher::m_d
private

Definition at line 68 of file VP1WebWatcher.h.


The documentation for this class was generated from the following files:
VP1WebWatcher::CONNECTION_PROBLEMS
@ CONNECTION_PROBLEMS
Definition: VP1WebWatcher.h:51
VP1WebWatcher::addUrls
void addUrls(const QStringList &)
Definition: VP1WebWatcher.cxx:236
VP1WebWatcher::m_d
Imp * m_d
Definition: VP1WebWatcher.h:67
VP1WebWatcher::NOT_ON_SERVER
@ NOT_ON_SERVER
Definition: VP1WebWatcher.h:52
VP1WebWatcher::INVALID_URL
@ INVALID_URL
Definition: VP1WebWatcher.h:50
VP1WebWatcher::removeUrl
void removeUrl(const QString &)
Definition: VP1WebWatcher.cxx:252
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
physics_parameters.url
string url
Definition: physics_parameters.py:27
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
VP1WebWatcher::lastResult
RESULT lastResult(const QString &url)
Definition: VP1WebWatcher.cxx:291
VP1WebWatcher::urls
QStringList urls() const
Definition: VP1WebWatcher.cxx:243
CaloNoise_fillDB.dt
dt
Definition: CaloNoise_fillDB.py:58
VP1WebWatcher::UNKNOWN
@ UNKNOWN
Definition: VP1WebWatcher.h:49
test_pyathena.parent
parent
Definition: test_pyathena.py:15
PixelConditionsData::fromString
T fromString(const std::string &s)
Definition: PixelConditionsDataStringUtils.h:14
VP1WebWatcher::Imp::watchedUrls
QList< WatchedUrl * > watchedUrls
Definition: VP1WebWatcher.cxx:147
VP1WebWatcher::urlChanged
void urlChanged(const QString &url)
VP1WebWatcher::EXISTS
@ EXISTS
Definition: VP1WebWatcher.h:53
error
Definition: IImpactPoint3dEstimator.h:70
VP1WebWatcher::Imp::ensureEndThread
static void ensureEndThread(HttpThread *&)
Definition: VP1WebWatcher.cxx:150