void FetchResponse::fetch(ScriptExecutionContext& context, const String& url, const Dictionary& dictionary, FetchPromise&& promise) { ExceptionCode ec = 0; RefPtr<FetchRequest> fetchRequest = FetchRequest::create(context, url, dictionary, ec); if (ec) { promise.reject(ec); return; } ASSERT(fetchRequest); startFetching(context, *fetchRequest, WTFMove(promise)); }
void SearchFetcher::populate() { if (search=="") return; //refreshUrl=""; QUrl url("http://search.twitter.com/search.json"); if (firstFetch) url.addQueryItem("rpp",QString::number(firstFetchCount)); if (sinceId!="") url.addQueryItem("since_id",sinceId); url.addQueryItem("q",search); // QMessageBox::information (0,"assdf",sinceId+":"+url.toString()); doHttpBit(url); emit startFetching(); inProgressCount++; }
void UserGroupFetcher::populate() { // manager.get(QNetworkRequest(QUrl("http://twitter.com/statuses/public_timeline.xml"))); QString endBit=""; if (state) { doHttpBit("https://api.twitter.com/1/"+user+"/lists.xml",user,pass,"name="+myGroup->name); } else { if (cursor!="") endBit = "?cursor="+cursor; if (!myGroup) { doHttpBit("https://api.twitter.com/1/"+user+"/lists.xml"+endBit,user,pass,""); } else { doHttpBit("https://api.twitter.com/1/"+myGroup->ownerScreenName+"/"+myGroup->slug+"/members.xml"+endBit,user,pass,""); } } emit startFetching(); inProgressCount++; }
/** * Constructor */ QTweetUserStream::QTweetUserStream(QObject *parent) : QObject(parent), m_oauthTwitter(0), m_reply(0), m_backofftimer(new QTimer(this)), m_timeoutTimer(new QTimer(this)), m_streamTryingReconnect(false) { m_backofftimer->setInterval(20000); m_backofftimer->setSingleShot(true); connect(m_backofftimer, SIGNAL(timeout()), this, SLOT(startFetching())); m_timeoutTimer->setInterval(90000); connect(m_timeoutTimer, SIGNAL(timeout()), this, SLOT(replyTimeout())); #ifdef STREAM_LOGGER m_streamLog.setFileName("streamlog.txt"); m_streamLog.open(QIODevice::WriteOnly | QIODevice::Text); #endif }
void TTRssFetcher::finishedSetAction() { if (!processResponse()) { return; } auto db = DatabaseManager::instance(); DatabaseManager::Action action = actionsList.takeFirst(); db->removeActionsByIdAndType(action.id1, action.type); emit uploadProgress(uploadProggressTotal - actionsList.size(), uploadProggressTotal); if (actionsList.isEmpty()) { startFetching(); } else { setAction(); } }
/** * Called when connection is finished. Reconnects. */ void QTweetUserStream::replyFinished() { qDebug() << "User stream closed "; m_streamTryingReconnect = true; if (!m_reply->error()) { //no error, reconnect qDebug() << "No error, reconnect"; m_reply->deleteLater(); m_reply = 0; startFetching(); } else { //error qDebug() << "Error: " << m_reply->error() << ", " << m_reply->errorString(); m_reply->deleteLater(); m_reply = 0; //if (m_backofftimer->interval() < 20001) { // m_backofftimer->start(); // return; //} //increase back off interval int nextInterval = 2 * m_backofftimer->interval(); if (nextInterval > 300000) { m_backofftimer->setInterval(300000); emit failureConnect(); } m_backofftimer->setInterval(nextInterval); m_backofftimer->start(); qDebug() << "Exp backoff interval: " << nextInterval; } }
void UserTweetFetcher::populate() { QString endbit=""; if (firstFetch) { endbit="?count="+QString::number(firstFetchCount); firstFetch=false; } if (lastId!="") { // endbit="?count=200&since_id="+tmpLastId; endbit="?since_id="+lastId; } if (statusPage>1) endbit="?page="+QString::number(statusPage); if (statusPage==1) { emit startFetching(); inProgressCount++; tmpLastId=lastId; } doHttpBit("https://api.twitter.com/statuses/home_timeline.xml"+endbit,user,pass,""); statusPage++; }