QIHttp.h revision 8e0c2ca3abd721979958f95b9af73b60665478c8
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* QIHttp class declaration & implementation
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#ifndef __QIHttp_h__
#define __QIHttp_h__
/* Qt includes */
#include <QHttp>
#include <QTimer>
/* Time to auto-disconnect if no network answer received. */
static const int MaxWaitTime = 20000;
/* This is QHttp extension to unite different happens errors
* into one already present error processing mechanism. */
{
/* Additional error codes */
enum AdvancedError
{
/* Basic QHttp errors */
/* Advanced QHttp errors */
TimeoutError, /* MaxWaitTime time passed with no response */
PageNotFoundError, /* Corresponds to 404 == not found header */
MovedTemporarilyError /* Corresponds to 302 == moved temporarily response */
};
, mStatusCode (0)
, mErrorCode (NoError)
{
mTimeoutTimer.setSingleShot (true);
}
QString errorString() const
{
switch (mErrorCode)
{
case TimeoutError:
return tr ("Connection timed out");
case PageNotFoundError:
return tr ("Could not locate the file on "
case MovedTemporarilyError:
default:
return QHttp::errorString();
}
}
{
}
{
}
{
}
void timeouted()
{
abort();
}
{
switch (mStatusCode)
{
case 302:
return abort();
case 404:
return abort();
default:
}
}
void processDone (bool aError)
{
if (mErrorCode == NoError)
}
int mStatusCode;
};
#endif // __QIHttp_h__