bool DownloadQueue::enqueueDownload(const HTTPRequest & request, const std::string & saveToPath, const DownloadTask::completion_handle_t & completion, const DownloadTask::progress_handle_t & progress){ if (isDownloading(request)){ call_on_main_thread([=]{ if (completion) completion(NetworkTask::StatusUndef, {request});//response code and succeed? should we care? }); return false; } pDownloadTask task(DownloadTask::create(request, saveToPath, [=](NetworkTask::Status status, const HTTPResponse & response){ if (completion) completion(status, response); //remove from queue circulate(); }, progress)); _queue.emplace_back(task); circulate(); return true; }
void do_switch_workspace(int num) { dodo_switch_workspace(num); if(wglobal.current_winobj==NULL || !on_current_workspace(wglobal.current_winobj)){ if(circulate(1)==NULL){ do_set_focus((WThing*)SCREEN); wglobal.current_winobj=NULL; } } }