void GatherInfoThread::doRun() { auto wildc = gcRefPtr<WildcardManager>::create(); wildc->onNeedSpecialEvent += delegate(&onNeedWCEvent); uint32 prog = 0; onProgUpdateEvent(prog); getUserCore()->getItemManager()->retrieveItemInfo(getItemId(), 0, wildc, MCFBranch::BranchFromInt(getMcfBranch()), MCFBuild::BuildFromInt(getMcfBuild())); if (isStopped()) return; auto item = getItemInfo(); if (!item) throw gcException(ERR_INVALIDDATA, "The item handle was null (gather info failed)"); uint32 itemId = item->getId().getItem(); onCompleteEvent(itemId); }
void IPCUninstallBranch::registerFunctions() { #ifndef DESURA_CLIENT REG_FUNCTION_VOID( IPCUninstallBranch, pause ); REG_FUNCTION_VOID( IPCUninstallBranch, unpause ); REG_FUNCTION_VOID( IPCUninstallBranch, stop ); REG_FUNCTION_VOID( IPCUninstallBranch, start ); LINK_EVENT( onProgressIPCEvent, uint64 ); LINK_EVENT( onErrorEvent, gcException ); LINK_EVENT_VOID( onCompleteEvent ); #else REG_EVENT( onProgressIPCEvent ); REG_EVENT( onErrorEvent ); REG_EVENT_VOID( onCompleteEvent ); onProgressIPCEvent += delegate(this, &IPCUninstallBranch::onProgress); #endif }
void Entry::recalcCharBoxes(const std::string& text) { int lastTextIndex = int(text.size()); CalcBoxesTextDelegate delegate(lastTextIndex); os::draw_text(nullptr, font(), base::utf8_const_iterator(text.begin()), base::utf8_const_iterator(text.end()), gfx::ColorNone, gfx::ColorNone, 0, 0, &delegate); m_boxes = delegate.boxes(); if (!m_boxes.empty()) { m_boxes.back().to = lastTextIndex; } // A last box for the last position CharBox box; box.codepoint = 0; box.from = box.to = lastTextIndex; m_boxes.push_back(box); }
void MedianFilter::applyToGrayscale(FilterManager* filterMgr) { const Image* src = filterMgr->getSourceImage(); uint16_t* dst_address = (uint16_t*)filterMgr->getDestinationAddress(); Target target = filterMgr->getTarget(); int color, k, a; GetPixelsDelegateGrayscale delegate(m_channel); int x = filterMgr->getX(); int x2 = x+filterMgr->getWidth(); int y = filterMgr->getY(); for (; x<x2; ++x) { // Avoid the non-selected region if (filterMgr->skipPixel()) { ++dst_address; continue; } delegate.reset(); get_neighboring_pixels<GrayscaleTraits>(src, x, y, m_width, m_height, m_width/2, m_height/2, m_tiledMode, delegate); color = image_getpixel_fast<GrayscaleTraits>(src, x, y); if (target & TARGET_GRAY_CHANNEL) { std::sort(m_channel[0].begin(), m_channel[0].end()); k = m_channel[0][m_ncolors/2]; } else k = _graya_getv(color); if (target & TARGET_ALPHA_CHANNEL) { std::sort(m_channel[1].begin(), m_channel[1].end()); a = m_channel[1][m_ncolors/2]; } else a = _graya_geta(color); *(dst_address++) = _graya(k, a); } }
// constructor DlgFatal::DlgFatal(const std::vector<std::string>& callstack, const std::string& message) { Font().set("arial"); m_pTex = D3D().loadTextureFromResource("Skull", RT_BITMAP); m_pBox = new UITextBox; m_pBox->setSize(Point2(0.85f, 0.375f)); m_pBox->setPos(Point2(0.075f, 0.1875f)); m_pBox->setInputEnabled(false); m_pBox->setAlign(UITextBox::CENTER); m_pBox->setVAlign(UITextBox::VCENTER); m_pBox->setWrap(true); m_pBox->setFont("smallarial"); m_pBox->setText(join(callstack, " <- ") + message); m_pButton = new UIButton; m_pButton->onClick = delegate(&DlgFatal::onExit); m_pButton->setText("Exit And Cry"); m_pButton->setPos(Point2(m_pBox->pos().x + ((m_pBox->size().x - m_pButton->size().x) * 0.5f), 0.75f - m_pButton->size().y - 0.025f)); }
bool VerifyServiceTask::installMissingFiles() { bool res = false; VSInstallMissing task; m_pCurTask = &task; setupCurTask(); task.onProgressEvent += delegate(this, &VerifyServiceTask::onProgress); try { res = task.doTask(); } catch (gcException) { } m_pCurTask = NULL; return res; }
void AssignNameOverlay::updatePosition() { if (!index().isValid()) { return; } QRect rect = delegate()->pixmapRect(); if (rect.width() < m_widget->minimumSizeHint().width()) { int offset = (m_widget->minimumSizeHint().width() - rect.width()) / 2; rect.adjust(-offset, 0, offset, 0); } QRect visualRect = m_view->visualRect(index()); rect.translate(visualRect.topLeft()); m_widget->setFixedSize(rect.width(), rect.height()); m_widget->move(rect.topLeft()); }
/*---------------------------------------------------------------------- | main +---------------------------------------------------------------------*/ int main(int argc, char** argv) { // setup Neptune logging NPT_LogManager::GetDefault().Configure("plist:.level=FINE;.handlers=ConsoleHandler;.ConsoleHandler.colors=off;.ConsoleHandler.filter=63"); NPT_COMPILER_UNUSED(argc); // parse command line ParseCommandLine(argv); // setup device PLT_MediaConnect* connect( new PLT_MediaConnect("Platinum")); connect->SetByeByeFirst(false); // setup delegate NPT_Reference<PLT_FileMediaConnectDelegate> delegate( new PLT_FileMediaConnectDelegate("/", Options.path)); connect->SetDelegate((PLT_MediaServerDelegate*)delegate.AsPointer()); PLT_UPnP upnp; PLT_DeviceHostReference device(connect); upnp.AddDevice(device); if (NPT_FAILED(upnp.Start())) return 1; char buf[256]; while (gets(buf)) { if (*buf == 'q') { break; } } upnp.Stop(); return 0; }
bool VSDownloadMissing::doTask() { m_hMcf->getNewProvider() += delegate(this, &VSDownloadMissing::onNewProvider); try { MCFCore::Misc::UserCookies uc; getWebCore()->setMCFCookies(&uc); m_hMcf->getDownloadProviders(getWebCore()->getMCFDownloadUrl(), &uc); m_hMcf->dlFilesFromWeb(); } catch (gcException &except) { onErrorEvent(except); return false; } if (isStopped()) return false; return checkComplex(); }
void CParticlesObject::shedule_Update (u32 _dt) { inherited::shedule_Update (_dt); if(g_dedicated_server) return; // Update if (m_bDead) return; u32 dt = Device.dwTimeGlobal - dwLastTime; if (dt) { if (0){//.psDeviceFlags.test(mtParticles)) { //. AlexMX comment this line// NO UNCOMMENT - DON'T WORK PROPERLY mt_dt = dt; fastdelegate::FastDelegate0<> delegate (this,&CParticlesObject::PerformAllTheWork_mt); Device.seqParallel.push_back (delegate); } else { mt_dt = 0; IParticleCustom* V = smart_cast<IParticleCustom*>(renderable.visual); VERIFY(V); V->OnFrame (dt); } dwLastTime = Device.dwTimeGlobal; } UpdateSpatial (); }
void MainApp::logIn(const char* user, const char* pass) { gcTrace("User: {0}", user); std::lock_guard<std::mutex> a(m_UserLock); safe_delete(g_pUserHandle); gcString path = UTIL::OS::getAppDataPath(); g_pUserHandle = (UserCore::UserI*)UserCore::FactoryBuilderUC(USERCORE); g_pUserHandle->init(path.c_str(), m_strServiceProvider.c_str()); try { //need to do this here as news items will be passed onlogin g_pUserHandle->getNewsUpdateEvent() += delegate(this, &MainApp::onNewsUpdate); g_pUserHandle->getGiftUpdateEvent() += delegate((MainAppNoUI*)this, &MainAppNoUI::onGiftUpdate); g_pUserHandle->getNeedCvarEvent() += delegate(this, &MainApp::onNeedCvar); g_pUserHandle->lockDelete(); g_pUserHandle->logIn(user, pass); g_pUserHandle->unlockDelete(); #ifndef DEBUG if (gc_enable_api_debugging.getBool()) g_pUserHandle->getWebCore()->enableDebugging(); #endif } catch (gcException) { g_pUserHandle->logOut(); g_pUserHandle->getNewsUpdateEvent() -= delegate(this, &MainApp::onNewsUpdate); g_pUserHandle->getGiftUpdateEvent() -= delegate((MainAppNoUI*)this, &MainAppNoUI::onGiftUpdate); g_pUserHandle->getNeedCvarEvent() -= delegate(this, &MainApp::onNeedCvar); g_pUserHandle->unlockDelete(); g_pUserHandle->logOut(false, false); safe_delete(g_pUserHandle); throw; } }
void SrtmTile::Init(string const & dir, ms::LatLon const & coord) { Invalidate(); string const base = GetBase(coord); string const cont = dir + base + ".SRTMGL1.hgt.zip"; string file = base + ".hgt"; UnzipMemDelegate delegate(m_data); try { ZipFileReader::UnzipFile(cont, file, delegate); } catch (ZipFileReader::LocateZipException const & e) { // Sometimes packed file has different name. See N39E051 measure. file = base + ".SRTMGL1.hgt"; ZipFileReader::UnzipFile(cont, file, delegate); } if (!delegate.m_completed) { LOG(LWARNING, ("Can't decompress SRTM file:", cont)); Invalidate(); return; } if (m_data.size() != kSrtmTileSize) { LOG(LWARNING, ("Bad decompressed SRTM file size:", cont, m_data.size())); Invalidate(); return; } m_valid = true; }
void HGTController::doDownload() { //header should be saved all ready so appened to it m_hFile.open(m_szFile, UTIL::FS::FILE_APPEND); m_hFile.seek(0); HttpHandle wc(m_szUrl.c_str()); //wc->getProgressEvent() += delegate(this, &HGTController::onProgress); wc->getWriteEvent() += delegate(this, &HGTController::onWriteMemory); for (size_t x=0; x<m_vSuperBlockList.size(); x++) { m_pCurBlock = m_vSuperBlockList[x]; wc->cleanUp(); wc->setDownloadRange(m_pCurBlock->offset, m_pCurBlock->size); try { m_hFile.seek(m_pCurBlock->vBlockList[0]->fileOffset); wc->getWeb(); } catch (gcException &e) { onErrorEvent(e); nonBlockStop(); } } size_t fsSize = m_rvFileList.size(); for (size_t x=0; x<fsSize; x++) { if (!HasAllFlags(m_rvFileList[x]->getFlags(), MCFFileI::FLAG_CANUSEDIFF)) m_rvFileList[x]->addFlag(MCFFileI::FLAG_COMPLETE); } }
bool ViewNavigationDelegate::ClickElementsByClass(const char* className) { EAW_ASSERT(className); if(!className || !className[0]) return false; IOverlayInputClient* pOverlayInputClient = mView->GetOverlayInputClient(); if(pOverlayInputClient) pOverlayInputClient->OnFocusChangeEvent(false); bool elementClicked = false; WebCore::Frame* pFrame = mView->GetFrame(); while(pFrame) { WebCore::Document* document = pFrame->document(); EAW_ASSERT(document); ClickElementsByIdOrClassDelegate delegate(className, false); if (document) { DOMWalker<ClickElementsByIdOrClassDelegate> walker(document, delegate); } elementClicked = delegate.GetReturnValue(); if(elementClicked) break; pFrame = pFrame->tree()->traverseNext(); } return elementClicked; }
void Connection::replaceAdapter(net::SocketAdapter* adapter) { TraceS(this) << "Replace adapter: " << adapter << endl; if (_adapter) { TraceS(this) << "Replace adapter: Delete existing: " << _adapter << endl; Outgoing.emitter.detach(_adapter); _socket->removeReceiver(_adapter); _adapter->removeReceiver(this); _adapter->setSender(nullptr); deleteLater<net::SocketAdapter>(_adapter); // delete _adapter; _adapter = nullptr; } if (adapter) { // Attach ourselves to the given ConnectionAdapter (should already be set) //assert(adapter->recvAdapter() == this); //assert(adapter->sendAdapter() == _socket.get()); adapter->addReceiver(this); // ConnectionAdapter output goes to the Socket adapter->setSender(_socket.get()); // Attach the ConnectionAdapter to receive Socket callbacks // The adapter will process raw packets into HTTP or WebSocket // frames depending on the adapter rype. _socket->addReceiver(adapter); // The Outgoing stream pumps data into the ConnectionAdapter, // which in turn proxies to the output Socket Outgoing.emitter += delegate(adapter, &net::SocketAdapter::sendPacket); _adapter = adapter; } }
void TagsLineEditOverlay::updatePosition() { if (!m_index.isValid() || !m_widget) { return; } QRect thumbrect = delegate()->ratingRect(); //kDebug() << "updatePosition called, probably a mouseover : " << thumbrect; QRect rect = thumbrect; if (rect.width() > addTagsLineEdit()->width() ) { int offset = (rect.width() - addTagsLineEdit()->width()) / 2; rect.adjust(offset, 0, -offset, 0); } QRect visualRect = m_view->visualRect(m_index); rect.translate(visualRect.topLeft()); m_widget->setFixedSize(rect.width() + 2, rect.height() + 5); m_widget->move(rect.topLeft()); m_widget->setFocus(); }
void SVGForeignObjectPainter::paint(const PaintInfo& paintInfo) { if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection) return; PaintInfo paintInfoBeforeFiltering(paintInfo); paintInfoBeforeFiltering.updateCullRect( m_layoutSVGForeignObject.localSVGTransform()); SVGTransformContext transformContext( paintInfoBeforeFiltering.context, m_layoutSVGForeignObject, m_layoutSVGForeignObject.localSVGTransform()); Optional<FloatClipRecorder> clipRecorder; if (SVGLayoutSupport::isOverflowHidden(&m_layoutSVGForeignObject)) clipRecorder.emplace(paintInfoBeforeFiltering.context, m_layoutSVGForeignObject, paintInfoBeforeFiltering.phase, m_layoutSVGForeignObject.viewportRect()); SVGPaintContext paintContext(m_layoutSVGForeignObject, paintInfoBeforeFiltering); bool continueRendering = true; if (paintContext.paintInfo().phase == PaintPhaseForeground) continueRendering = paintContext.applyClipMaskAndFilterIfNecessary(); if (continueRendering) { // Paint all phases of FO elements atomically as though the FO element // established its own stacking context. The delegate forwards calls to // paint() in LayoutObject::paintAllPhasesAtomically() to // BlockPainter::paint(), instead of m_layoutSVGForeignObject.paint() (which // would call this method again). BlockPainterDelegate delegate(m_layoutSVGForeignObject); ObjectPainter(delegate).paintAllPhasesAtomically(paintContext.paintInfo(), LayoutPoint()); } }
void UMcfEx::downloadMcf() { uint32 prog = 0; onProgressEvent(prog); if (m_szUrl == "") { ::MessageBox(NULL, "Invalid Download URL.", "Desura: Error", MB_OK); exit(-1); } if (m_szFile == L"") { ::MessageBox(NULL, "Invalid MCF file path.", "Desura: Error", MB_OK); exit(-1); } HttpHandle wc(m_szUrl.c_str()); wc->setOutFile(gcString(m_szFile).c_str()); wc->getProgressEvent() += delegate((UMcf*)this, &UMcf::updateAllCB); try { wc->getWebToFile(); } catch (gcException &e) { char msg[255]; _snprintf_s(msg, 255, _TRUNCATE, "Failed to download Desura Files. \n\n%s [%d.%d]", e.getErrMsg(), e.getErrId(), e.getSecErrId()); ::MessageBox(NULL, msg, "Desura: Error", MB_OK); exit(-1); } m_sHeader->setBuild(MCFBuild::BuildFromInt(m_iAppBuild)); m_sHeader->setId(m_iAppId); }
void MainApp::logIn(const char* user, const char* pass) { Thread::AutoLock a(m_UserLock); safe_delete(g_pUserHandle); gcString path = UTIL::OS::getAppDataPath(); g_pUserHandle = (UserCore::UserI*)UserCore::FactoryBuilderUC(USERCORE); g_pUserHandle->init(path.c_str()); try { //need to do this here as news items will be passed onlogin *g_pUserHandle->getNewsUpdateEvent() += delegate(this, &MainApp::onNewsUpdate); *g_pUserHandle->getGiftUpdateEvent() += delegate(this, &MainApp::onGiftUpdate); *g_pUserHandle->getNeedCvarEvent() += delegate(this, &MainApp::onNeedCvar); g_pUserHandle->lockDelete(); g_pUserHandle->logIn(user, pass); g_pUserHandle->unlockDelete(); #ifndef DEBUG if (gc_enable_api_debugging.getBool()) g_pUserHandle->getWebCore()->enableDebugging(); #endif } catch (gcException) { g_pUserHandle->logOut(); *g_pUserHandle->getNewsUpdateEvent() -= delegate(this, &MainApp::onNewsUpdate); *g_pUserHandle->getGiftUpdateEvent() -= delegate(this, &MainApp::onGiftUpdate); *g_pUserHandle->getNeedCvarEvent() -= delegate(this, &MainApp::onNeedCvar); g_pUserHandle->unlockDelete(); safe_delete(g_pUserHandle); throw; } }
bool UIComplexModServiceTask::initService() { m_OldBranch = getItemInfo()->getInstalledBranch(); m_OldBuild = getItemInfo()->getInstalledBuild(); UserCore::Item::ItemInfo* parentInfo = getParentItemInfo(); if (getItemInfo()->getInstalledModId().isOk()) parentInfo = getItemInfo(); if (!parentInfo) { onComplete(); return false; } m_idLastInstalledMod = parentInfo->getInstalledModId(); getUserCore()->getItemManager()->setInstalledMod(parentInfo->getId(), DesuraId()); if (!m_idLastInstalledMod.isOk()) { onComplete(); return false; } UserCore::Item::ItemInfo* modInfo = dynamic_cast<UserCore::Item::ItemInfo*>(getUserCore()->getItemManager()->findItemInfo(m_idLastInstalledMod)); if (!modInfo) { gcException eModNoExist(ERR_NULLHANDLE, "Installed mod doesnt exist in database!\n"); onErrorEvent(eModNoExist); return false; } m_pIPCCL = getServiceMain()->newComplexLaunch(); if (!m_pIPCCL) { gcException eFailedUninstall (ERR_NULLHANDLE, "Failed to create uninstall complex branch mcf service!\n"); onErrorEvent(eFailedUninstall); return false; } UserCore::MCFManager *mm = UserCore::GetMCFManager(); gcString installPath = modInfo->getPath(); gcString parPath = mm->getMcfBackup(parentInfo->getId(), m_idLastInstalledMod); gcString modMcfPath; if (m_idLastInstalledMod == getItemInfo()->getId()) modMcfPath = getBranchMcf(modInfo->getId(), m_OldBranch, m_OldBuild); else modMcfPath = getBranchMcf(modInfo->getId(), modInfo->getInstalledBranch(), modInfo->getInstalledBuild()); if (m_uiCompleteAction == CA_UNINSTALL) modInfo->resetInstalledMcf(); m_pIPCCL->onCompleteEvent += delegate(this, &UIComplexModServiceTask::onComplete); m_pIPCCL->onProgressEvent += delegate(this, &UIComplexModServiceTask::onProgress); m_pIPCCL->onErrorEvent += delegate((UIBaseServiceTask*)this, &UIBaseServiceTask::onServiceError); m_pIPCCL->startRemove(modMcfPath.c_str(), parPath.c_str(), installPath.c_str(), getItemInfo()->getInstallScriptPath()); return true; }
void PeerListController::restoreState( std::unique_ptr<PeerListState> state) { delegate()->peerListRestoreState(std::move(state)); }
std::unique_ptr<PeerListState> PeerListController::saveState() const { return delegate()->peerListSaveState(); }
void PeerListController::peerListSearchRefreshRows() { delegate()->peerListRefreshRows(); }
void WGTWorker::run() { m_szUrl = m_pProvMng->getUrl(m_uiId); if (m_szUrl == "NULL") { Warning(gcString("Mcf Download Thread [{0}] failed to get valid url for download.\n", m_uiId)); return; } gcString name = m_pProvMng->getName(m_uiId); m_pMcfCon = new MCFCore::Misc::MCFServerCon(); m_pMcfCon->setDPInformation(name.c_str()); m_pMcfCon->onProgressEvent += delegate(this, &WGTWorker::onProgress); while (!isStopped()) { uint32 status = m_pCT->getStatus(m_uiId); uint32 pauseCount = 0; bool isPaused= (status == MCFCore::Thread::BaseMCFThread::SF_STATUS_PAUSE); if (isPaused) m_pMcfCon->onPause(); while (status == MCFCore::Thread::BaseMCFThread::SF_STATUS_PAUSE) { if (pauseCount > 30000 && m_pMcfCon->isConnected()) m_pMcfCon->disconnect(); gcSleep(500); pauseCount += 500; status = m_pCT->getStatus(m_uiId); } if (isPaused) { gcString name = m_pProvMng->getName(m_uiId); m_pMcfCon->setDPInformation(name.c_str()); } if (status == MCFCore::Thread::BaseMCFThread::SF_STATUS_STOP) break; m_ErrorMutex.lock(); if (m_bError) { requestNewUrl(m_Error); m_bError = false; } m_ErrorMutex.unlock(); if (status == MCFCore::Thread::BaseMCFThread::SF_STATUS_CONTINUE) doDownload(); } m_pProvMng->removeAgent(m_uiId); m_DeleteMutex.lock(); safe_delete(m_pMcfCon); m_DeleteMutex.unlock(); //need to do this incase we are the last thread and the controller is stuck on the wait mutex m_pCT->pokeThread(); }
void operator()(message& x) override { CAF_LOG_TRACE(CAF_ARG(x)); delegate(x); }
def(void, Write, RdString str) { size_t written = delegate(this->stream, write, String_GetRdBuffer(str)); assert(written == str.len); }
void operator()(error& x) override { CAF_LOG_TRACE(CAF_ARG(x)); delegate(x); }
int main(int argc, char** argv) { if(argc<4) { printf("Usage: ./wserver cert-file priv-key-file pub-key-file.\n"); exit(0); } else { CERTFILE = argv[1]; KEYFILE = argv[2]; PUBFILE = argv[3]; const char* PROMPT = "Enter password for Old Key file: "; if(argc == 5) { OLDKEY = argv[4]; PASSWORD = getpass(PROMPT); OLDPASS = (char*) calloc(1, strlen(PASSWORD)+1); strcpy(OLDPASS, PASSWORD); } PROMPT = "Enter password for Key file: "; PASSWORD = getpass(PROMPT); } int sock,s; BIO *sbio; SSL_CTX *ctx; SSL *ssl; int r; pid_t pid; char buf[BUFSIZZ]; char *owner = (char*) calloc(1,256); ctx=initialize_ctx(CERTFILE,KEYFILE,PASSWORD); load_dh_params(ctx,DHFILE); sock=tcp_listen(); if((s=accept(sock,0,0))<0) err_exit("Problem accepting"); sbio=BIO_new_socket(s,BIO_NOCLOSE); ssl=SSL_new(ctx); SSL_set_bio(ssl,sbio,sbio); SSL_set_verify(ssl,SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT,0); if((r=SSL_accept(ssl)<=0)) berr_exit("SSL accept error"); if(check_cert(ssl, ctx, &owner)<=0) { send_data(ssl, "Revoked"); printf("Connection Closed.\n"); close_SSL(ssl, sock); destroy_ctx(ctx); exit(0); } send_data(ssl, "Approved"); printf("User connected: %s\n", owner); if((pid=fork())){ close(s); } else { if(argc == 5) {recrypt();} while(1){ memset((void*)buf, 0, BUFSIZZ); if(rec_data(buf, ssl)>0) { printf("Command received: %s\n", buf); if(starts_with(buf, "PUT")){ put_file(ssl, buf, owner); } else if(starts_with(buf, "GET")){ get_file(ssl, buf, owner); } else if(starts_with(buf, "DELEGATE")){ delegate(ssl, buf, owner); } else if(starts_with(buf, "END")){ close_SSL(ssl, sock); break; } else { printf("Command not recognized\n"); } } else{ perror("Error receiving command\n"); break; } } } destroy_ctx(ctx); exit(0); }
void operator()(const none_t& x) override { CAF_LOG_TRACE(CAF_ARG(x)); delegate(x); }
void CreateMCFThread::compareBranches(std::vector<UserCore::Item::BranchInfo*> &vBranchList) { uint64 lastSize = 0; //uint32 lastIndex = 0; unused variable McfHandle lastMcf; m_hMCFile->setHeader(getItemId(), MCFBranch(), MCFBuild()); m_hMCFile->getHeader()->setParent(0); for (size_t x=0; x<vBranchList.size(); x++) { if (isStopped()) return; UserCore::Item::BranchInfo* bi = vBranchList[x]; McfHandle tempMcf; tempMcf->setHeader(getItemId(), bi->getBranchId(), MCFBuild()); tempMcf->getErrorEvent() += delegate(&onErrorEvent); try { MCFCore::Misc::UserCookies uc; getWebCore()->setMCFCookies(&uc); tempMcf->getDownloadProviders(getWebCore()->getMCFDownloadUrl(), &uc); } catch (gcException &except) { Warning(gcString("CreateMCF: Failed to get download providers for mcf: {0}\n", except)); continue; } if (tempMcf->getHeader()->getBuild() > 0) { try { tempMcf->dlHeaderFromWeb(); } catch (gcException &except) { Warning(gcString("CreateMCF: Failed to get dlHeaderFromWeb for mcf: {0}\n", except)); continue; } uint64 totalSize = 0; uint32 fileCount = 0; m_hMCFile->getPatchStats(tempMcf.handle(), &totalSize, &fileCount); if (lastSize == 0 || totalSize < lastSize) { lastSize = totalSize; //lastIndex = x; lastMcf.setHandle(tempMcf.releaseHandle()); // if there are no files just use this one if (fileCount == 0) break; } } } MCFBuild build = lastMcf->getHeader()->getBuild(); MCFBranch branch = lastMcf->getHeader()->getBranch(); m_hMCFile->setHeader(getItemId(), branch, build); if (build > 0) m_hMCFile->getHeader()->addFlags( MCFCore::MCFHeaderI::FLAG_PARTFILE ); else m_hMCFile->getHeader()->delFlags( MCFCore::MCFHeaderI::FLAG_PARTFILE ); m_hMCFile->getHeader()->setParent(lastMcf->getHeader()->getBuild()); m_hMCFile->makePatch(lastMcf.handle()); }