bool PostEntry::uploadMediaFiles( Backend *backend ) { kDebug(); bool localBackend = false; bool result = true; if( !backend ) { localBackend = true; backend = new Backend( d->mCurrentPostBlogId, this ); } QList<BilboMedia*> lImages = localImages(); if( lImages.size()>0 ) { showProgressBar(); QList<BilboMedia*>::iterator it = lImages.begin(); QList<BilboMedia*>::iterator endIt = lImages.end(); for ( ; it != endIt; ++it ) { BilboMedia *media = (*it); SyncUploader *uploader = new SyncUploader(this); if( uploader->uploadMedia( backend, media ) ){ replaceImageSrc( media->localUrl().url(), media->remoteUrl().url()); } else { QString err = i18n( "Uploading the media file %1 failed.\n%2", media->name(), uploader->errorMessage()); emit postPublishingDone( true, err ); result = false; break; } uploader->deleteLater(); } d->mCurrentPost.setContent( htmlContent() ); } if(localBackend) backend->deleteLater(); return result; }
void videoFetch::run(){ std::ofstream fout; std::string fileName; for(std::set<std::string>::iterator it = this->start; it != this->end;){ std::auto_ptr<std::string> htmlContent(this->getHtmlContent(*it)); if(htmlContent->find("verificationImage") != std::string::npos){ continue; } std::auto_ptr<std::vector<std::pair<std::string, std::string> > > urlExtensionVector(htmlParser::getDownloadUrlExtension(*htmlContent)); if(urlExtensionVector.get() == NULL){ it++; continue; } for(std::vector<std::pair<std::string, std::string> >::iterator it2 = urlExtensionVector->begin(); it2 != urlExtensionVector->end(); it2++){ fileName = *it + "." + it2->second; fout.open(fileName.c_str(), std::ios_base::out | std::ios_base::trunc | std::ios_base::binary); int videoBinData = this->getVideoUsingCurl(it2->first, fout); fout.close(); if(videoBinData != 0){ std::remove(fileName.c_str()); continue; }else{ break; } } it++; } }
void PostEntry::setCurrentPostFromEditor() { if( d->isPostContentModified ) { kDebug(); const QString& str = htmlContent(); d->mCurrentPost.setContent( str ); d->isPostContentModified = false; connect( this, SIGNAL(textChanged()), this, SLOT(slotPostModified()) ); } }
void PostEntry::setCurrentPostFromEditor() { if (d->isPostContentModified) { const QString &str = htmlContent(); d->mCurrentPost.setContent(str); d->isPostContentModified = false; connect(this, &PostEntry::textChanged, this, &PostEntry::slotPostModified); } }