void TlenAvatarService::avatarReady(ContactAccountData *contactAccountData, const QByteArray &avatar) { InProgress.removeAll(contactAccountData); if (avatar.isNull()) return; emit avatarFetched(contactAccountData, avatar); qDebug() << "Tlen Have Avatar" << contactAccountData->id(); }
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)) ); } }
void TlenAvatarFetcher::avatarDownloaded(int id, bool error) { QImage image; QPixmap pixmap; // 200 OK and buffer not empty if (!MyAvatarBuffer.data().isEmpty() && (MyHttp->lastResponse()).statusCode() == 200) { //MyContactAccountData->avatar().setNextUpdate(QDateTime::fromTime_t(QDateTime::currentDateTime().toTime_t() + 7200)); emit avatarFetched(MyContactAccountData, MyAvatarBuffer.buffer()); } deleteLater(); }
void JabberAvatarPepFetcher::failed() { emit avatarFetched(MyContact, false); }
void JabberAvatarPepFetcher::done() { emit avatarFetched(MyContact, true); }
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)) ); } }