void SearchLocationID::findNext( const QString& serverConfigFile ) { kdebugf(); connect(&httpClient_, SIGNAL(finished()), this, SLOT(downloadingFinished())); connect(&httpClient_, SIGNAL(error()), this, SLOT(downloadingError())); connect(&httpClient_, SIGNAL(redirected(QString)), this, SLOT(downloadingRedirected(QString))); serverConfigFile_ = serverConfigFile; if (weatherConfig_ != 0) delete weatherConfig_; weatherConfig_ = new PlainConfigFile(WeatherGlobal::getConfigPath(serverConfigFile_)); QString encoding = weatherConfig_->readEntry("Default","Encoding"); decoder_ = QTextCodec::codecForName(encoding.ascii()); host_ = weatherConfig_->readEntry("Name Search","Search host"); httpClient_.setHost(host_); QString encodedCity = city_; encodeUrl(&encodedCity, encoding); url_.sprintf(weatherConfig_->readEntry("Name Search","Search path").ascii() , encodedCity.ascii()); timerTimeout_->start(weather_global->CONNECTION_TIMEOUT, false); timeoutCount_ = weather_global->CONNECTION_COUNT; httpClient_.get(url_); kdebugf2(); }
void SearchLocationID::cancel() { kdebugf(); disconnect(&httpClient_, SIGNAL(finished()), this, SLOT(downloadingFinished())); disconnect(&httpClient_, SIGNAL(error()), this, SLOT(downloadingError())); disconnect(&httpClient_, SIGNAL(redirected(QString)), this, SLOT(downloadingRedirected(QString))); redirected_ = false; kdebugf2(); }
void SearchLocationID::downloadingFinished() { kdebugf(); disconnect(&httpClient_, SIGNAL(finished()), this, SLOT(downloadingFinished())); disconnect(&httpClient_, SIGNAL(error()), this, SLOT(downloadingError())); disconnect(&httpClient_, SIGNAL(redirected(QString)), this, SLOT(downloadingRedirected(QString))); timerTimeout_->stop(); if (redirected_) redirected_ = false; else { const QByteArray &data = httpClient_.data(); QString page = decoder_->toUnicode( data.data(), data.count()); parser_.getSearch(page, weatherConfig_, serverConfigFile_, &results_); // Je�li strona zawiera wszystkie miasta, // trzeba dok�adniej przefiltrowa� if (weatherConfig_->readBoolEntry("Name Search","OnePage")) { CITYSEARCHRESULTS::iterator it, old_it; it = results_.begin(); while (it != results_.end()) { if ((*it).cityName_.find(city_, 0, false) == -1) { old_it = it; ++it; results_.erase(old_it); } else ++it; } } } if (searchAllServers_) findNext(); else emit finished(); kdebugf2(); }
void SearchLocationID::connectionTimeout() { kdebugf(); if (--timeoutCount_ <= 0) { cancel(); downloadingError(); } else { httpClient_.setHost(host_); httpClient_.get(url_); } kdebugf2(); }
void SearchLocationID::downloadingError() { kdebugf(); disconnect(&httpClient_, SIGNAL(finished()), this, SLOT(downloadingFinished())); disconnect(&httpClient_, SIGNAL(error()), this, SLOT(downloadingError())); disconnect(&httpClient_, SIGNAL(redirected(QString)), this, SLOT(downloadingRedirected(QString))); timerTimeout_->stop(); if (searchAllServers_) findNext(); else emit error(host_ + '/' + url_); kdebugf2(); }
/*! If download of a .sis file was successful, starts installing the file. Otherwise a signal indicating an error is emitted. */ void IAPurchase::downloadCompleted(Request::RequestType type, QString productId, QString fileName, int error) { if (error == QNetworkReply::NoError) { // OK switch (type) { case Request::EDownloadSis: { // Symbian SIS downloaded and it's time to install it emit downloaded(productId); emit installingProduct(productId); // Install Symbian sis file QDesktopServices::openUrl(QUrl("file:///" + fileName, QUrl::TolerantMode)); break; } case Request::EProductIds: { // No action break; } }; } else { // ERROR switch (type) { case Request::EDownloadSis: { emit downloadingError(); break; } case Request::EProductIds: { emit iapBackendDataReadError(); break; } }; } }