void ShareProvider::onTransferJobResultReceived(KJob* job) { if (d->m_data.size() == 0) { Q_EMIT finishedError(this, i18n("Service was not available")); return; } KIO::TransferJob *tfJob = qobject_cast<KIO::TransferJob*>(job); if (tfJob) { QString mimeType = tfJob->mimetype(); AbstractSharer *sharer = d->getSharer(); if (sharer) { sharer->parseResponse(d->m_data); if (tfJob->isErrorPage() || sharer->hasError()) { QString errorMessage = sharer->errorMessage(); if (!errorMessage.isEmpty()) { Q_EMIT finishedError(this, errorMessage); } else { Q_EMIT finishedError(this, tfJob->errorString()); } } else { Q_EMIT finishedSuccess(this, sharer->imageUrl().url()); } } } }
void MediaManager::uploadMedium(const KUrl& localUrl, const QString& pluginId) { QString pId = pluginId; if(pId.isEmpty()) pId = Choqok::BehaviorSettings::lastUsedUploaderPlugin(); if(pId.isEmpty()){ emit mediumUploadFailed(localUrl, i18n("No pluginId specified, And last used plugin is null.")); return; } if(!d->uploader){ Plugin *plugin = PluginManager::self()->loadPlugin(pId); d->uploader = qobject_cast<Uploader*>(plugin); } else if(d->uploader->pluginName() != pId) { // kDebug()<<"CREATING A NEW UPLOADER OBJECT"; PluginManager::self()->unloadPlugin(d->uploader->pluginName()); Plugin *plugin = PluginManager::self()->loadPlugin(pId); d->uploader = qobject_cast<Uploader*>(plugin); } if(!d->uploader) return; QByteArray picData; KIO::TransferJob *picJob = KIO::get( localUrl, KIO::Reload, KIO::HideProgressInfo); if( !KIO::NetAccess::synchronousRun(picJob, 0, &picData) ){ kError()<<"Job error: " << picJob->errorString(); KMessageBox::detailedError(UI::Global::mainWindow(), i18n( "Uploading medium failed: cannot read the medium file." ), picJob->errorString() ); return; } if ( picData.count() == 0 ) { kError() << "Cannot read the media file, please check if it exists."; KMessageBox::error( UI::Global::mainWindow(), i18n( "Uploading medium failed: cannot read the medium file." ) ); return; } QByteArray type = KMimeType::findByUrl( localUrl, 0, true )->name().toUtf8(); connect( d->uploader, SIGNAL(mediumUploaded(KUrl,QString)), this, SIGNAL(mediumUploaded(KUrl,QString)) ); connect( d->uploader, SIGNAL(uploadingFailed(KUrl,QString)), this, SIGNAL(mediumUploadFailed(KUrl,QString)) ); d->uploader->upload(localUrl, picData, type); }
void Backend::uploadMedia( BilboMedia * media ) { kDebug() << "Blog Id: " << d->bBlog->id(); QString tmp; switch ( d->bBlog->api() ) { case BilboBlog::BLOGGER1_API: case BilboBlog::GDATA_API: kDebug() << "The Blogger1 and GData API type doesn't support uploading Media files."; tmp = i18n( "Uploading media failed: Your Blog API does not support uploading media objects."); kDebug() << "Emitting sigError..."; Q_EMIT sigMediaError( tmp, media ); return; break; case BilboBlog::METAWEBLOG_API: case BilboBlog::MOVABLETYPE_API: case BilboBlog::WORDPRESSBUGGY_API: KBlog::BlogMedia *m = new KBlog::BlogMedia() ; KBlog::MetaWeblog *MWBlog = qobject_cast<KBlog::MetaWeblog*>( d->kBlog ); m->setMimetype( media->mimeType() ); QByteArray data; KIO::TransferJob *job = KIO::get( media->localUrl(), KIO::Reload, KIO::HideProgressInfo); if( !KIO::NetAccess::synchronousRun(job, 0, &data) ){ kError()<<"Job error: " << job->errorString(); tmp = i18n( "Uploading media failed: Cannot read the media file,\ please check if it exists. Path: %1", media->localUrl().pathOrUrl() ); kDebug() << "Emitting sigError..."; Q_EMIT sigMediaError( tmp, media ); } if ( data.count() == 0 ) { kError() << "Cannot read the media file, please check if it exists."; tmp = i18n( "Uploading media failed: Cannot read the media file,\ please check if it exists. Path: %1", media->localUrl().pathOrUrl() ); kDebug() << "Emitting sigError..."; Q_EMIT sigMediaError( tmp, media ); delete m; return; }
void TestLinkItr::slotJobResult(KJob *job) { kDebug(); m_job = 0; KIO::TransferJob *transfer = static_cast<KIO::TransferJob *>(job); const QString modDate = transfer->queryMetaData("modified"); if (transfer->error() || transfer->isErrorPage()) { kDebug()<<"***********"<<transfer->error()<<" "<<transfer->isErrorPage()<<endl; // can we assume that errorString will contain no entities? QString err = transfer->errorString(); err.replace("\n", " "); setStatus(err); } else { if (!modDate.isEmpty()) setStatus(modDate); else setStatus(i18n("OK")); } holder()->addAffectedBookmark(KBookmark::parentAddress(currentBookmark().address())); delayedEmitNextOne(); }