本文整理汇总了C++中Downloader类的典型用法代码示例。如果您正苦于以下问题:C++ Downloader类的具体用法?C++ Downloader怎么用?C++ Downloader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Downloader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: downloadrequested
void Tab::startDownload(QNetworkReply *reply)
{
std::cout<<"startDownload(QNetworkReply *reply): downloadrequested() signal emitted by the webpage\n";
Downloader *downloader = new Downloader;
if(downloader->handleDownloadRequest(WebView->page()->networkAccessManager(),reply))
downloader->show();
}
示例2: main
//Main
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QScopedPointer<QApplication> app(createApplication(argc, argv));
QmlApplicationViewer viewer;
//system("sudo ifup wlan0");
Downloader d;
d.doDownload("http://www.vesta-tab.com/jo/showId.php");
Object data;
viewer.setCursor(Qt::BlankCursor);
viewer.rootContext()->setContextProperty("image", &data);
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
//viewer.setMainQmlFile("qrc:/main.qml");
viewer.setSource(QUrl("qrc:/qml/BBB/main.qml"));
viewer.showFullScreen();
return app->exec();
}
示例3: GetDownloaderPolicy
void
MediaBase::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error)
{
if (args->GetProperty ()->GetOwnerType() != Type::MEDIABASE) {
FrameworkElement::OnPropertyChanged (args, error);
return;
}
if (args->GetId () == MediaBase::SourceProperty) {
const char *uri = args->GetNewValue() ? args->GetNewValue()->AsString () : NULL;
if (IsAttached () && AllowDownloads ()) {
if (uri && *uri) {
Downloader *dl;
if ((dl = GetDeployment ()->CreateDownloader ())) {
dl->Open ("GET", uri, GetDownloaderPolicy (uri));
SetSource (dl, "");
dl->unref ();
} else {
// we're shutting down
}
} else {
SetSource (NULL, NULL);
}
} else {
source_changed = true;
}
InvalidateMeasure ();
}
NotifyListenersOfPropertyChange (args, error);
}
示例4:
void
Downloader::SendAsync (EventObject *user_data)
{
Downloader *downloader = (Downloader *) user_data;
downloader->SendInternal ();
}
示例5: download
// CURL 下载线程
static void * download(void *arg)
{
//LOG("downloading...\n");
Downloader *downloader = (Downloader *)arg;
downloader->performDownload();
return NULL;
}
示例6: Download
bool Util::Download(RequestParameter param, string file) {
HttpRequest request;
Downloader downloader;
downloader.SetFile(file);
request.SetListener(&downloader);
request.SetRequestParameter(param);
return request.Get(10);
}
示例7: downloadThreadProc
void downloadThreadProc(void *param)
{
Downloader *d = (Downloader *)param;
bool res = d->downloadFiles();
if((!d->downloadCancelled) && d->finishedCallback)
d->finishedCallback(d, res);
}
示例8:
void * Downloader::downloaderThread(void *opaque)
{
Downloader *instance = reinterpret_cast<Downloader *>(opaque);
int canc = vlc_savecancel();
instance->Run();
vlc_restorecancel( canc );
return NULL;
}
示例9: main
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
Downloader *d = Downloader::instance();
qDebug() << "download return code" << d->fetch(QUrl("http://download.cegit.de/kde-windows/installer/config.txt"),"config.txt");
qDebug() << "download return code" << d->fetch(QUrl("http://go.microsoft.com/fwlink/?LinkId=51410&clcid=0x409"),"vcexpress.exe");
qDebug() << "download return code" << d->fetch(QUrl("ftp://ftp.scarlet.be/pub/kde/unstable/3.97/windows/"),"config-ftp.txt");
return 0;
}
示例10: assert
int Downloader::ProgressFileFunction(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) {
assert(clientp);
int percentage = dlnow * 100.0 / dltotal;
if (percentage < 0)
percentage = 0;
if (percentage > 100)
percentage = 100;
Downloader* c = (Downloader *) clientp;
c->ProgressFileCallback((size_t)percentage);
return 0;
}
示例11: main
int main( int argc, char* argv[] )
{
// creating the qt-application object
QApplication qApplication( argc, argv );
qApplication.setQuitOnLastWindowClosed( true );
// creating downloader object, and showing it
Downloader downloader;
downloader.initEnvironement();
downloader.show();
// running the application
return qApplication.exec();
}
示例12: curl_progress
int curl_progress(void *pointer, double dltotal, double dlnow, double ultotal, double ulnow)
{
Q_UNUSED(dltotal);
Q_UNUSED(dlnow);
Q_UNUSED(ultotal);
Q_UNUSED(ulnow);
Downloader *dl = (Downloader *)pointer;
dl->mutex()->lock ();
bool aborted = dl->stream()->aborted;
dl->mutex()->unlock();
if (aborted)
{
return -1;
}
return 0;
}
示例13: curl_easy_init
void Http::Request(const string &url, bool async, bool usePost, const void *data, size_t dataLen, HttpCallback callback,
void *callbackArg, map<std::string, string> *header, int timeout)
{
if( timeout <= 0 ) {
timeout = 60;
}
CURL *handle = curl_easy_init();
Downloader *downloader = new Downloader(handle, callback, callbackArg);
curl_easy_setopt(handle, CURLOPT_URL, url.c_str());
curl_easy_setopt(handle, CURLOPT_TIMEOUT, timeout);
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, writer);
curl_easy_setopt(handle, CURLOPT_FORBID_REUSE, 1);
curl_easy_setopt(handle, CURLOPT_WRITEDATA, downloader);
curl_easy_setopt(handle, CURLOPT_PRIVATE, downloader);
if( usePost ){
curl_easy_setopt(handle, CURLOPT_POST, 1);
curl_easy_setopt(handle, CURLOPT_POSTFIELDSIZE, dataLen);
curl_easy_setopt(handle, CURLOPT_COPYPOSTFIELDS, data);
}
if( header != NULL ) {
struct curl_slist *headers = NULL;
map<string,string>::const_iterator it = header->begin();
for(; it != header->end(); it++ ) {
headers = curl_slist_append(headers, (it->first + ": " + it->second).c_str());
}
curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers);
downloader->setHeaders(headers);
}
if( async ) {
curl_multi_add_handle(m_mcurl, handle);
int running = 0;
curl_multi_perform(m_mcurl, &running);
}else {
int repCode = -1;
CURLcode code = curl_easy_perform(handle);
if ( CURLE_OK == code )
{
curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &repCode);
}
downloader->didFinish(code, repCode);
delete downloader;
}
}
示例14: performNetworkOperation
NetworkResult NetworkFactory::performNetworkOperation(const QString &url, int timeout, const QByteArray &input_data,
const QString &input_content_type, QByteArray &output,
QNetworkAccessManager::Operation operation, bool protected_contents,
const QString &username, const QString &password, bool set_basic_header) {
Downloader downloader;
QEventLoop loop;
NetworkResult result;
QString str(input_data);
downloader.appendRawHeader("Content-Type", input_content_type.toLocal8Bit());
if (set_basic_header) {
QString basic_value = username + ":" + password;
QString header_value = QString("Basic ") + QString(basic_value.toUtf8().toBase64());
downloader.appendRawHeader("Authorization", header_value.toLocal8Bit());
}
// We need to quit event loop when the download finishes.
QObject::connect(&downloader, SIGNAL(completed(QNetworkReply::NetworkError)), &loop, SLOT(quit()));
downloader.manipulateData(url, operation, input_data, timeout, protected_contents, username, password);
loop.exec();
output = downloader.lastOutputData();
result.first = downloader.lastOutputError();
result.second = downloader.lastContentType();
return result;
}
示例15: idpDownloadFiles
bool idpDownloadFiles()
{
downloader.setUI(NULL);
downloader.setUserAgent(userAgent);
downloader.setInternetOptions(internetOptions);
return downloader.downloadFiles();
}