int DownloadManager::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: downloadComplete(); break; case 1: progress((*reinterpret_cast< int(*)>(_a[1]))); break; case 2: downloadStatus((*reinterpret_cast< float(*)>(_a[1]))); break; case 3: downloadStarted(); break; case 4: cancel(); break; case 5: download((*reinterpret_cast< QUrl(*)>(_a[1]))); break; case 6: pause(); break; case 7: resume(); break; case 8: download((*reinterpret_cast< QNetworkRequest(*)>(_a[1]))); break; case 9: finished(); break; case 10: downloadProgress((*reinterpret_cast< qint64(*)>(_a[1])),(*reinterpret_cast< qint64(*)>(_a[2]))); break; case 11: error((*reinterpret_cast< QNetworkReply::NetworkError(*)>(_a[1]))); break; default: ; } _id -= 12; } return _id; }
InitCode() { void *d1, *d2, *maind; extern void *download(); d1 = download( RPC_io_code, sizeof( RPC_io_code)); d2 = download( RPC_mo_code, sizeof( RPC_io_code)); drop(d1, d2); }
cached<T>::cached(context_t& context, const std::string& collection, const std::string& name) { api::category_traits<api::storage_t>::ptr_type cache; try { cache = api::storage(context, "cache"); } catch(const api::repository_error_t& e) { download(context, collection, name); return; } T& object = static_cast<T&>(*this); try { object = cache->get<T>(collection, name); } catch(const storage_error_t& e) { download(context, collection, name); try { cache->put(collection, name, object, std::vector<std::string>()); } catch(const storage_error_t& e) { throw storage_error_t("unable to cache object '%s' in '%s' - %s", name, collection, e.what()); } return; } m_source = sources::cache; }
void ListEngine::connectDownloader() { connect(this, SIGNAL(download(QUrl,QUrl)), m_parent->downloader(), SLOT(download(QUrl,QUrl))); connect(m_parent->downloader(), SIGNAL(downloadComplete(QUrl,QUrl)), this, SLOT(downloadComplete(QUrl,QUrl))); connect(this, SIGNAL(listDir(QUrl)), m_parent->downloader(), SLOT(listDir(QUrl))); connect(m_parent->downloader(), SIGNAL(listingComplete(QUrl)), this, SLOT(listingComplete(QUrl))); }
void LLUpdateDownloader::Implementation::resume(void) { mCancelled = false; if(isDownloading()) { mClient.downloadError("download in progress"); } mDownloadRecordPath = downloadMarkerPath(); llifstream dataStream(mDownloadRecordPath); if(!dataStream) { mClient.downloadError("no download marker"); return; } LLSDSerialize::fromXMLDocument(mDownloadData, dataStream); if(!mDownloadData.asBoolean()) { mClient.downloadError("no download information in marker"); return; } std::string filePath = mDownloadData["path"].asString(); try { if(LLFile::isfile(filePath)) { llstat fileStatus; LLFile::stat(filePath, &fileStatus); if(fileStatus.st_size != mDownloadData["size"].asInteger()) { resumeDownloading(fileStatus.st_size); } else if(!validateDownload()) { LLFile::remove(filePath); download(LLURI(mDownloadData["url"].asString()), mDownloadData["hash"].asString(), mDownloadData["update_version"].asString(), mDownloadData["required"].asBoolean()); } else { mClient.downloadComplete(mDownloadData); } } else { download(LLURI(mDownloadData["url"].asString()), mDownloadData["hash"].asString(), mDownloadData["update_version"].asString(), mDownloadData["required"].asBoolean()); } } catch(DownloadError & e) { mClient.downloadError(e.what()); } }
RsCollectionDialog::RsCollectionDialog(const QString& CollectionFileName,const std::vector<RsCollectionFile::DLinfo>& dlinfos) : _dlinfos(dlinfos),_filename(CollectionFileName) { setupUi(this) ; setWindowFlags(Qt::Window); // for maximize button setWindowFlags(windowFlags() & ~Qt::WindowMinimizeButtonHint); setWindowTitle(QString("%1 - %2").arg(windowTitle()).arg(QFileInfo(_filename).completeBaseName())); // 1 - add all elements to the list. _fileEntriesTW->setColumnCount(3) ; QTreeWidgetItem *headerItem = _fileEntriesTW->headerItem(); headerItem->setText(0, tr("File")); headerItem->setText(1, tr("Size")); headerItem->setText(2, tr("Hash")); uint32_t size = dlinfos.size(); uint64_t total_size ; uint32_t total_files ; for(uint32_t i=0;i<size;++i) { const RsCollectionFile::DLinfo &dlinfo = dlinfos[i]; QTreeWidgetItem *item = new QTreeWidgetItem; item->setFlags(Qt::ItemIsUserCheckable | item->flags()); item->setCheckState(0, Qt::Checked); item->setData(0, Qt::UserRole, i); item->setText(0, dlinfo.path + "/" + dlinfo.name); item->setText(1, misc::friendlyUnit(dlinfo.size)); item->setText(2, dlinfo.hash); _fileEntriesTW->addTopLevelItem(item); total_size += dlinfo.size ; total_files++ ; } _filename_TL->setText(_filename) ; for (int column = 0; column < _fileEntriesTW->columnCount(); ++column) { _fileEntriesTW->resizeColumnToContents(column); } updateSizes() ; // 2 - connect necessary signals/slots connectUpdate(true); connect(_selectAll_PB,SIGNAL(clicked()),this,SLOT(selectAll())) ; connect(_deselectAll_PB,SIGNAL(clicked()),this,SLOT(deselectAll())) ; connect(_cancel_PB,SIGNAL(clicked()),this,SLOT(cancel())) ; connect(_download_PB,SIGNAL(clicked()),this,SLOT(download())) ; _fileEntriesTW->installEventFilter(this); }
static FILE* open_fpkl() { if (system("mkdir -p /data/FeOS/FPM") != 0) return NULL; time_t srvTime; if (!get_cur_pkgtime(&srvTime)) return NULL; time_t localTime = 0; do { FILE* f = fopen("/data/FeOS/FPM/time", "rb"); if (!f) break; fread(&localTime, sizeof(localTime), 1, f); fclose(f); } while(0); if (srvTime > localTime) { // Need to upgrade! printf("Downloading package list...\n"); if (!download("/fpkg/", "/data/FeOS/FPM/packages.fpkl", NULL)) return NULL; FILE* f = fopen("/data/FeOS/FPM/time", "wb"); if (!f) return NULL; fwrite(&srvTime, sizeof(srvTime), 1, f); fclose(f); } return fopen("/data/FeOS/FPM/packages.fpkl", "rb"); }
int sbcl_bin_download(struct install_options* param) { int result; char* home=configdir(); char* arch=arch_(param); char* uri=get_opt("sbcl-bin-uri",0); cond_printf(1,"sbcl_bin_download\n"); int retry=10; do { param->expand_path=cat(home,"src",SLASH,"sbcl","-",param->version,"-",arch,SLASH,NULL); impls_sbcl_bin.uri=cat(uri?uri:SBCL_BIN_URI ,param->version,"/sbcl-",param->version, "-",arch,"-binary",sbcl_bin_extention(param),NULL); result = download(param); if(!result && param->version_not_specified) { int len = strlen(param->version)-1; if('1'<= param->version[len] && param->version[len] <= '9') { param->version[len]--; s(param->expand_path),s(impls_sbcl_bin.uri); }else if('2' <= param->version[len-1] && param->version[len-1] <= '9') { param->version[len-1]--; param->version[len] = '9'; s(param->expand_path),s(impls_sbcl_bin.uri); }else if('1' == param->version[len-1]) { param->version[len-1] = '9'; param->version[len] = '\0'; s(param->expand_path),s(impls_sbcl_bin.uri); }else{ s(arch),s(home); return 0; } } }while (!result && retry--); s(arch),s(home); return !!result; }
void SlippyMap::invalidate() { if (width <= 0 || height <= 0) return; const QPointF ct = tileForCoordinate(latitude, longitude, zoom); const qreal tx = ct.x(); const qreal ty = ct.y(); // top-left corner of the center tile const int xp = width / 2 - (tx - floor(tx)) * tdim; const int yp = height / 2 - (ty - floor(ty)) * tdim; // first tile vertical and horizontal const int xa = (xp + tdim - 1) / tdim; const int ya = (yp + tdim - 1) / tdim; const int xs = static_cast<int>(tx) - xa; const int ys = static_cast<int>(ty) - ya; // offset for top-left tile m_offset = QPoint(xp - xa * tdim, yp - ya * tdim); // last tile vertical and horizontal const int xe = static_cast<int>(tx) + (width - xp - 1) / tdim; const int ye = static_cast<int>(ty) + (height - yp - 1) / tdim; // build a rect m_tilesRect = QRect(xs, ys, xe - xs + 1, ye - ys + 1); if (m_url.isEmpty()) download(); emit updated(QRect(0, 0, width, height)); }
void CachedImage::_setProperties() { if (!_headReply) return; if (_headReply->error() != QNetworkReply::NoError) { _headReply->deleteLater(); _headReply = nullptr; return; } auto mime = _headReply->header(QNetworkRequest::ContentTypeHeader).toString().split('/'); if (mime.isEmpty()) mime << ""; if (!mime.first().isEmpty() && mime.first().toLower() != "image") qDebug() << "mime:" << mime.first() << "\nurl:" << _url; setExtension(mime.last()); auto length = _headReply->header(QNetworkRequest::ContentLengthHeader).toInt(); _kbytesTotal = length / 1024; emit totalChanged(); _headReply->deleteLater(); _headReply = nullptr; if (_man->autoload(_kbytesTotal)) download(); }
void BrowserDialog::linkClicked(const QUrl& url) { do { if (url.host() != DOWNLOAD_HOST_BASE) { break; } if (url.path() != "/dict/download_cell.php") { break; } QString id = url.queryItemValue("id"); QByteArray name = url.encodedQueryItemValue("name"); QString sname = decodeName(name); m_name = sname; if (!id.isEmpty() && !sname.isEmpty()) { download(url); return; } } while(0); if (url.host() != HOST_BASE) { QMessageBox::information(this, _("Wrong Link"), _("No browsing outside pinyin.sogou.com, now redirect to home page.")); m_ui->webView->load(QUrl(URL_BASE)); } else { m_ui->webView->load(url); } }
void DownloadM::download( QUrl url , QString matchMd5 ) { url0 = url; QFileInfo fileInfo(url.path()); QString filename; filename=fileInfo.fileName(); curentMd5 = matchMd5; dDlSizeAtPause = 0; dCurrentRequest = QNetworkRequest(url); // remove the older file that has the same name if(filename.contains(".pk3", Qt::CaseInsensitive) || filename.contains(".cfg", Qt::CaseInsensitive) || filename.contains(".txt", Qt::CaseInsensitive)) QFile::remove(assetsDir+"/"+filename); else QFile::remove(filename); dFile = new QFile(filename); dFile->open(QIODevice::ReadWrite); downloadTime.start(); download(dCurrentRequest); }
void AssetsUpdateLayer::update(float delta) { if (1 || m_curBigVersion >= m_endBigVersion && m_curSmallVersion >= m_endSmallVersion) { CCLOG("Version check Ok"); unscheduleUpdate(); //MD5Check(); gameEnter(); return; } if (!m_isDownloading && checkUpdate()) { createLayerItem(); char str[128]; sprintf(str, "%s%s%d.%d.%d.zip", SERVER_ADDRESS, ASSETS_SERVER_PATH, m_curBigVersion, m_curMidVersion, m_curSmallVersion + 1); getAssetsManager()->setPackageUrl(str); sprintf(str, "%d.%d.%d", m_curBigVersion, m_curMidVersion, m_curSmallVersion + 1); getAssetsManager()->setVersionFileUrl(str); getAssetsManager()->setStoragePath(m_pathToSave.c_str()); //sprintf(str, Localization::getInstance()->getValueByKey("Loading_download_restBag_num"), m_endSmallVersion - m_curSmallVersion); //m_packegNumberLabel->setString(str); m_curPackageLength = 0; //getAssetsManager()->getPackageLength((long&)m_packageLength); m_isDownloading = true; download(); } }
void LibrariesForm::on_downloadButton_clicked() { int row = selectedRow(); if (row == -1) return; download(librariesModel->get()[row]); }
PixelBox GL3PlusHardwarePixelBuffer::lockImpl( const Image::Box &lockBox, LockOptions options ) { //Allocate memory for the entire image, as the buffer //maynot be freed and be reused in subsequent calls. allocateBuffer( PixelUtil::getMemorySize( mWidth, mHeight, mDepth, mFormat ) ); mBuffer = PixelBox( lockBox.getWidth(), lockBox.getHeight(), lockBox.getDepth(), mFormat, mBuffer.data ); mCurrentLock = mBuffer; mCurrentLock.left = lockBox.left; mCurrentLock.right += lockBox.left; mCurrentLock.top = lockBox.top; mCurrentLock.bottom += lockBox.top; if(options != HardwareBuffer::HBL_DISCARD) { // Download the old contents of the texture download( mCurrentLock ); } mCurrentLockOptions = options; mLockedBox = lockBox; mCurrentLock = mBuffer; return mBuffer; }
std::string Downloader::download(const std::string& url) { std::string result; download(url, my_curl_string_append, &result); return result; }
void DirectoryListing::download(const string& aDir, const string& aTarget, bool highPrio) { dcassert(aDir.size() > 2); dcassert(aDir[aDir.size() - 1] == '\\'); // This should not be PATH_SEPARATOR Directory* d = find(aDir, getRoot()); if(d != NULL) download(d, aTarget, highPrio); }
void unit_test_create_cmds() { std::vector<std::string> articles; for (int i=0; i<10000; ++i) articles.push_back(boost::lexical_cast<std::string>(i)); std::size_t cmd_number = 0; nf::download download({"alt.binaries.foobar"}, articles, "", "test"); nf::session session; session.on_send = [&](const std::string& cmd) { BOOST_REQUIRE(cmd == "BODY " + boost::lexical_cast<std::string>(cmd_number) + "\r\n"); ++cmd_number; }; session.enable_pipelining(true); for (;;) { auto cmds = download.create_commands(); if (!cmds) break; cmds->submit_data_commands(session); session.send_next(); } BOOST_REQUIRE(cmd_number == articles.size()); }
void MetadataDownload::downloadNext() { Out(SYS_GEN|LOG_NOTICE) << "Metadata download, requesting " << pieces.getNumBits() << " pieces" << endl; for (Uint32 i = 0;i < pieces.getNumBits();i++) if (!pieces.get(i)) download(i); }
void Discovery::helperOutput() { m_helper->disconnect( this ); QString line; m_helper->readln( line ); download( KURL( line.stripWhiteSpace() ) ); }
QRegion TCacheResource::download(TTile &tile) { if (!checkTile(tile)) return QRegion(); return download(TPoint(tile.m_pos.x, tile.m_pos.y), tile.getRaster()); }
MiniWeb::MiniWeb(QWidget *parent) : KWebView(parent) { load(QUrl("about:blank")); connect(page(), SIGNAL(linkHovered(QString, QString, QString)), this, SIGNAL(statusBarMessage(QString))); updateConfiguration(); m_vi_mode = true; m_loading = false; connect(this, SIGNAL(loadStarted()), this, SLOT(setLoading())); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setNotLoading(bool))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setStatusLoaded(bool))); connect(this, SIGNAL(urlChanged(QUrl)), this, SLOT(setPageChanged())); connect(this, SIGNAL(linkMiddleOrCtrlClicked(KUrl)), this, SLOT(openInNewWindow(KUrl))); connect(page(), SIGNAL(downloadRequested(QNetworkRequest)), this, SLOT(download(QNetworkRequest))); }
void run() { for (int i = 0; i < itemsToInstall.size(); ++i) { const ModuleList::Module* m = list.findModuleInfo (itemsToInstall[i]); jassert (m != nullptr); if (m != nullptr) { setProgress (i / (double) itemsToInstall.size()); MemoryBlock downloaded; result = download (*m, downloaded); if (result.failed()) break; if (threadShouldExit()) break; result = unzip (*m, downloaded); if (result.failed()) break; } if (threadShouldExit()) break; } }
/* Main */ int main() { int n; while(n != 4){ printf("\nWelcome to the ECE158A FTP Client! What would you like to do?\n\n"); printf("1. Get a remote directory\n2. Send a file\n3. Receive a file\n4. Exit"); printf("\n\nPlease enter the number for the action you want: "); scanf("%d", &n); if(n == 4){ printf("Program will now exit."); break; } else if(n == 1){ displayFolders(); } else if(n == 2){ upload(); } else if(n == 3){ download(); } else { printf("Invalid entry, please enter a number 1-4\n"); } } return 0; }
void dump(cl_command_queue commands, cl_mem variables, int nel, int nelr) { float* h_variables; h_variables = (float*) memalign(AOCL_ALIGNMENT,nelr*NVAR*sizeof(float)); download(commands, h_variables, variables, nelr*NVAR); { std::ofstream file("density.txt"); file << nel << " " << nelr << std::endl; for(int i = 0; i < nel; i++) file << h_variables[i + VAR_DENSITY*nelr] << std::endl; } { std::ofstream file("momentum.txt"); file << nel << " " << nelr << std::endl; for(int i = 0; i < nel; i++) { for(int j = 0; j != NDIM; j++) file << h_variables[i + (VAR_MOMENTUM+j)*nelr] << " "; file << std::endl; } } { std::ofstream file("density_energy.txt"); file << nel << " " << nelr << std::endl; for(int i = 0; i < nel; i++) file << h_variables[i + VAR_DENSITY_ENERGY*nelr] << std::endl; } delete[] h_variables; }
static int lua_download(lua_State *L) { // Flush the lua output (it seems to buffered separately) do_flush(L, "stdout"); do_flush(L, "stderr"); // Extract params luaL_checktype(L, 1, LUA_TFUNCTION); int pcount = lua_gettop(L); const char *url = luaL_checkstring(L, 2); const char *cacert = NULL; if (pcount >= 3 && !lua_isnil(L, 3)) cacert = luaL_checkstring(L, 3); const char *crl = NULL; if (pcount >= 4 && !lua_isnil(L, 4)) crl = luaL_checkstring(L, 4); bool ocsp = lua_toboolean(L, 5); bool ssl = lua_toboolean(L, 6); // Handle the callback struct lua_download_data *data = malloc(sizeof *data); data->L = L; data->callback = register_value(L, 1); // Run the download struct events *events = extract_registry(L, "events"); ASSERT(events); struct wait_id id = download(events, download_callback, data, url, cacert, crl, ocsp, ssl); // Return the ID push_wid(L, &id); return 1; }
void HttpClient::download(const QString &destinationPath, std::function<void (const QString &)> successHandler, std::function<void (const QString &)> errorHandler) { bool debug = d->debug; QFile *file = new QFile(destinationPath); if (file->open(QIODevice::WriteOnly)) { download([=](const QByteArray &data) { file->write(data); }, [=](const QString &) { // 请求结束后释放文件对象 file->flush(); file->close(); file->deleteLater(); if (debug) { qDebug().noquote() << QString("下载完成,保存到: %1").arg(destinationPath); } if (nullptr != successHandler) { successHandler(QString("下载完成,保存到: %1").arg(destinationPath)); } }, errorHandler); } else { // 打开文件出错 if (debug) { qDebug().noquote() << QString("打开文件出错: %1").arg(destinationPath); } if (nullptr != errorHandler) { errorHandler(QString("打开文件出错: %1").arg(destinationPath)); } } }
void BinaryWidget::updateNote() { NoteWidget::updateNote(); if(note->getPath() != path->text()) { QString p = path->text(); if(SettingsDialog::binaryCopy()){ QDir d; d.setCurrent(NotesManager::getInstance()->getPath()); d.mkdir("files"); QDir b(d.absoluteFilePath("files")); if(p.indexOf("http://") == 0){ // download from internet with a dialog tmp_dest = b.absoluteFilePath(p.split("/").last()); download(p); } else if(p != "" && !p.contains(d.absolutePath())){ QString new_p = b.absoluteFilePath(QFileInfo(p).fileName()); QFile(p).copy(new_p); path->setText(new_p); } } NotesManager::getInstance()->getHistory()->addAndExec( new ModifyBinaryPath(note,path->text())); updateBinaryWidget(); note->setModified(true); NotesManager::getInstance()->setNoteModified(); } if(note->getDescription() != description->toPlainText()){ NotesManager::getInstance()->getHistory()->addAndExec( new ModifyBinaryDescription(note,description->toPlainText())); note->setModified(true); NotesManager::getInstance()->setNoteModified(); } }
int myclianttest::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: readyRead(); break; case 1: bytesWritten((*reinterpret_cast< qint64(*)>(_a[1]))); break; case 2: disconnected(); break; case 3: list((*reinterpret_cast< QString(*)>(_a[1]))); break; case 4: connected(); break; case 5: test(); break; case 6: mycomputer((*reinterpret_cast< QString(*)>(_a[1]))); break; case 7: doubleClicked((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 8: doubleClickedServer((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 9: setpath((*reinterpret_cast< QString(*)>(_a[1]))); break; case 10: getpath(); break; case 11: servercomputer((*reinterpret_cast< QByteArray(*)>(_a[1]))); break; case 12: serverfiledown((*reinterpret_cast< QByteArray(*)>(_a[1]))); break; case 13: getserverpath(); break; case 14: download(); break; case 15: Serverclicked((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 16: gotomotherpath(); break; case 17: gotoservermotherpath(); break; default: ; } _id -= 18; } return _id; }
int main(int argc, char *argv[]) { rpc_init(); RPCSession* session = rpc_session(); if(!session) { printf("RPC server not connected\n"); return ERROR_RPC_DISCONNECTED; } rpc = rpc_connect(session->host, session->port, 3, true); if(rpc == NULL) { printf("Failed to connect RPC server\n"); return ERROR_RPC_DISCONNECTED; } int rc; if((rc = download(argc, argv))) { printf("Failed to download file. Error code : %d\n", rc); rpc_disconnect(rpc); return ERROR_CMD_EXECUTE; } while(1) { if(rpc_connected(rpc)) { rpc_loop(rpc); } else { free(rpc); break; } } }