};
static const QString INVALID_LOGIN_STRING = "Invalid login details";
+ static const QString TIMEOUT_STRING = "Request timed out";
static const QString PERSON_REGEXP = "<td class=\"hTd2\">(.*)<b>(.*)</td>";
static const QString YELLOW_REGEXP = "<td class=\"hTd2\">(.*)<span class=\"gray\"\\}>(.*)</td>";
static const QString NUMBER_REGEXP = "<div class=\"callRow\">(.*)</div>";
Eniro::Eniro(Site site, QObject *parent): QObject(parent), site_(site),
username_(""), password_(""), loggedIn_(false), error_(NO_ERROR),
-errorString_(""), maxResults_(10), findNumber_(true),
+errorString_(""), maxResults_(10), timeout_(0), timerId_(0), findNumber_(true),
pendingSearches_(), pendingNumberRequests_()
{
connect(&http_, SIGNAL(requestFinished(int, bool)), this, SLOT(httpReady(int, bool)));
site_ = site;
}
+void Eniro::setTimeout(unsigned int ms)
+{
+ timeout_ = ms;
+ resetTimeout();
+}
+
+void Eniro::resetTimeout()
+{
+ if(timerId_)
+ {
+ killTimer(timerId_);
+ }
+ if(timeout_)
+ {
+ timerId_ = startTimer(timeout_);
+ }
+}
+
+void Eniro::timerEvent(QTimerEvent* t)
+{
+ if(t->timerId() == timerId_)
+ {
+ int currentId = http_.currentId();
+
+ if(currentId)
+ {
+ searchMap::const_iterator it = pendingSearches_.find(currentId);
+
+ if(it != pendingSearches_.end())
+ {
+ QVector <Eniro::Result> results = it.value()->results;
+ SearchDetails details = it.value()->details;
+
+ abort();
+
+ error_ = TIMEOUT;
+ errorString_ = TIMEOUT_STRING;
+
+ emit requestFinished(results, details, true);
+ }
+ }
+
+ }
+}
+
void Eniro::login(QString const& username,
QString const& password)
{
bool Eniro::search(SearchDetails const& details)
{
+ resetTimeout();
+
SearchType type = details.type;
// Only logged in users can use other than person search