void MediaManager::slotImageFetched( KJob * job ) { KIO::StoredTransferJob *baseJob = qobject_cast<KIO::StoredTransferJob *>( job ); QString remote = d->queue.value(job); d->queue.remove( job ); if ( job->error() ) { kDebug() << "Job error: " << job->error() << "\t" << job->errorString(); QString errMsg = i18n( "Cannot download image from %1.", job->errorString() ); emit fetchError( remote, errMsg ); } else { QPixmap p; if( !baseJob->data().startsWith(QByteArray("<?xml version=\"")) && p.loadFromData( baseJob->data() ) ) { d->cache.insert( remote, p ); emit imageFetched( remote, p ); } else { kDebug()<<"Parse Error: \nBase Url:"<<baseJob->url()<<"\ndata:"<<baseJob->data(); emit fetchError( remote, i18n( "The download failed. The returned file is corrupted." ) ); } } }
void TwitterApiWhoisWidget::avatarFetched(const QString& remoteUrl, const QPixmap& pixmap) { kDebug(); if ( remoteUrl == d->currentPost.author.profileImageUrl ) { QString url = "img://profileImage"; d->wid->document()->addResource( QTextDocument::ImageResource, url, pixmap ); updateHtml(); disconnect( Choqok::MediaManager::self(), SIGNAL( imageFetched(QString,QPixmap)), this, SLOT(avatarFetched(QString, QPixmap) ) ); disconnect( Choqok::MediaManager::self(), SIGNAL(fetchError(QString,QString)), this, SLOT(avatarFetchError(QString,QString)) ); } }
ScanDialog::ScanDialog(QWidget *parent) : QDialog(parent) { setupUi(this); itemsTree->setColumnHidden(1, true); readSettings(); mgr= new QHttpManager(this); mgr->setProgressBar(progressBar); connect(mgr, SIGNAL(fetchLink(QString)), this, SLOT(onFetchLink(QString))); connect(mgr, SIGNAL(fetchFinished()), this, SLOT(onFetchFinished())); connect(mgr, SIGNAL(fetchError(QString)), this, SLOT(onFetchError(QString))); // Enable drops. setAcceptDrops(true); }
void ScanDialog::onFetchFinished() { if (mgr->errorOccurred()) { resetUI(); return; } QStringList found; Scan::youtube(mgr->getData(), found); const int size = found.size(); if (size == 0) { Util::appendLog(logEdit, tr("Nothing found.")); resetUI(); return; } Util::appendLog(logEdit, QString(tr("Found %1 video links.")).arg(size)); if ( !titlesBox->checkState() ) { for (int i=0; i<size; ++i) { QTreeWidgetItem *item = new QTreeWidgetItem(itemsTree); item->setCheckState(0, Qt::Unchecked); for (int j=0; j<2; ++j) item->setText(j, found[i]); } resetUI(); Util::appendLog(logEdit, tr("Done.")); } else { Util::appendLog(logEdit, tr("Fetch titles for the found videos.")); mgrt = new QHttpManager(this); connect(mgrt, SIGNAL(fetchLink(QString)), this, SLOT(onFetchLink(QString))); connect(mgrt, SIGNAL(fetchError(QString)), this, SLOT(onFetchError(QString))); // Note the use of a different slot here. connect(mgrt, SIGNAL(fetchFinished()), this, SLOT(onFetchTitlesFinished())); // Do not set progressbar for this manager. // We'll use fetched/expected for that instead. fetchedTitles = -1; expectedTitles = size; progressBar->setValue(fetchedTitles); progressBar->setMaximum(expectedTitles); videoLinks = found; progressBar->setTextVisible(true); emit onFetchTitlesFinished(); // Start iteration. } }
void TwitterApiWhoisWidget::userInfoReceived(KJob* job) { kDebug(); if(job->error()){ kError()<<"Job Error: "<<job->errorString(); if( Choqok::UI::Global::mainWindow()->statusBar() ) Choqok::UI::Global::mainWindow()->statusBar()->showMessage(job->errorString()); slotCancel(); return; } KIO::StoredTransferJob *stj = qobject_cast<KIO::StoredTransferJob *>(job); // kDebug()<<stj->data(); QJson::Parser parser; bool ok; QVariantMap map = parser.parse(stj->data(), &ok).toMap(); Choqok::Post post; if ( !ok ){ kDebug()<<"JSON parsing failed! Data is:\n\t"<<stj->data(); d->errorMessage = i18n("Cannot load user information."); updateHtml(); showForm(); return; } QString timeStr; d->errorMessage = map["error"].toString(); if( d->errorMessage.isEmpty() ) { //No Error post.author.realName = map["name"].toString(); post.author.userName = map["screen_name"].toString(); post.author.location = map["location"].toString(); post.author.description = map["description"].toString(); post.author.profileImageUrl = map["profile_image_url"].toString(); post.author.homePageUrl = map["url"].toString(); d->timeZone = map["time_zone"].toString(); d->followersCount = map["followers_count"].toString(); d->friendsCount = map["friends_count"].toString(); d->statusesCount = map["statuses_count"].toString(); QVariantMap var = map["status"].toMap(); post.content = var["text"].toString(); post.creationDateTime = d->mBlog->dateFromString(var["created_at"].toString()); post.isFavorited = var["favorited"].toBool(); post.postId = var["id"].toString(); post.replyToPostId = var["in_reply_to_status_id"].toString(); post.replyToUserId = var["in_reply_to_user_id"].toString(); post.replyToUserName = var["in_reply_to_screen_name"].toString(); post.source = var["source"].toString(); d->currentPost = post; } updateHtml(); showForm(); QPixmap *userAvatar = Choqok::MediaManager::self()->fetchImage( post.author.profileImageUrl, Choqok::MediaManager::Async ); if(userAvatar) { d->wid->document()->addResource( QTextDocument::ImageResource, QUrl("img://profileImage"), *(userAvatar) ); } else { connect( Choqok::MediaManager::self(), SIGNAL( imageFetched(QString,QPixmap)), this, SLOT(avatarFetched(QString, QPixmap) ) ); connect( Choqok::MediaManager::self(), SIGNAL(fetchError(QString,QString)), this, SLOT(avatarFetchError(QString,QString)) ); } }
void FetchQueue::slotFetchError(Feed *f) { emit fetchError(f); feedDone(f); }