__FORCE_ALIGN_STACK__ int Download(int ID, const std::string& filename, DownloadEnum::Category cat) { currentDownloadID = ID; // FIXME: Progress is incorrectly updated when rapid is queried to check for existing packages. SetDownloadListener(UpdateProgress); LOG_L(L_DEBUG, "Going to download %s", filename.c_str()); DownloadInit(); const int count = DownloadSearch(cat, filename.c_str()); for (int i = 0; i < count; i++) { DownloadAdd(i); struct downloadInfo dl; if (DownloadGetInfo(i, dl)) { LOG_L(L_DEBUG, "Download info: %s %d", dl.filename, dl.cat); } } int result; LOG_L(L_DEBUG, "Download count: %d", count); // TODO: count will be 1 when archives already exist. We should instead return a different result with DownloadFailed/DownloadFinished? if (count == 0) { // there's nothing to download result = 2; QueueDownloadFailed(ID, result); } else { QueueDownloadStarted(ID); result = DownloadStart(); LOG_L(L_DEBUG, "Download finished %s", filename.c_str()); } DownloadShutdown(); return result; }
__FORCE_ALIGN_STACK__ int Download(int ID, const std::string& filename, DownloadEnum::Category cat) { currentDownloadID = ID; // FIXME: Progress is incorrectly updated when rapid is queried to check for existing packages. SetDownloadListener(UpdateProgress); LOG_L(L_DEBUG, "Going to download %s", filename.c_str()); DownloadInit(); const int count = DownloadSearch(cat, filename.c_str()); for (int i = 0; i < count; i++) { DownloadAdd(i); struct downloadInfo dl; if (DownloadGetInfo(i, dl)) { LOG_L(L_DEBUG, "Download info: %s %d", dl.filename, dl.cat); } } int result; LOG_L(L_DEBUG, "Download count: %d", count); // TODO: count will be 1 when archives already exist. We should instead return a different result with DownloadFailed/DownloadFinished? if (count == 0) { // there's nothing to download result = 2; QueueDownloadFailed(ID, result); } else { LOG_L(L_DEBUG, "Download finished %s", filename.c_str()); QueueDownloadStarted(ID); result = DownloadStart(); // TODO: This works but there are errors spammed as it's trying to clear timers in the main thread, which this is not: // Error: [Watchdog::ClearTimer(id)] Invalid thread 4 (_threadId=(nil)) archiveScanner->ScanAllDirs(); } DownloadShutdown(); return result; }
void MainInitState(int new_state) { state = new_state; debug(("New main state = %d\n", state)); switch (new_state) { case STATE_OFFLINE: DisableGameMenus(); MenuConnect(); OfflineInit(); break; case STATE_CONNECTING: ConnectingInit(); break; case STATE_LOGIN: LoginInit(); break; case STATE_STARTUP: StartupInit(STATE_LOGIN); break; case STATE_TERM: TermInit(); break; case STATE_GAME: GameInit(); break; case STATE_DOWNLOAD: DownloadInit(); break; } }
static int ModulesLoaded(WPARAM, LPARAM) { CMenuItem mi; SET_UID(mi, 0x5ba238de, 0xe16b, 0x4928, 0xa0, 0x70, 0xff, 0x43, 0xf6, 0x1f, 0x16, 0xd4); mi.position = 2000070050; mi.hIcolibItem = icon.hIcolib; mi.name.a = LPGEN("Assign smiley category"); hContactMenuItem = Menu_AddContactMenuItem(&mi); DownloadInit(); //install hooks if enabled InstallDialogBoxHook(); g_SmileyCategories.AddAllProtocolsAsCategory(); g_SmileyCategories.ClearAndLoadAll(); ColourID cid = { sizeof(cid) }; strcpy_s(cid.dbSettingsGroup, "SmileyAdd"); strcpy_s(cid.group, LPGEN("SmileyAdd")); strcpy_s(cid.name, LPGEN("Background color")); strcpy_s(cid.setting, "SelWndBkgClr"); cid.defcolour = GetSysColor(COLOR_WINDOW); ColourRegister(&cid); return 0; }
int main(int argc, char **argv) { show_version(); if (argc<2) show_help(argv[0]); DownloadInit(); bool res=true; while (true) { int option_index = 0; int c = getopt_long(argc, argv, "", long_options, &option_index); if (c == -1) break; switch (c) { case RAPID_DOWNLOAD: { download(CAT_GAME, optarg); break; } case RAPID_VALIDATE: { DownloadRapidValidate(); break; } case FILESYSTEM_DUMPSDP: { DownloadDumpSDP(optarg); break; } case FILESYSTEM_WRITEPATH: { DownloadSetConfig(CONFIG_FILESYSTEM_WRITEPATH, optarg); break; } case HTTP_SEARCH: { search(CAT_ANY, optarg); break; } case HTTP_DOWNLOAD: { if (!download(CAT_ANY, optarg)) res = false; break; } case DOWNLOAD_MAP: { if (!download(CAT_MAP, optarg)) { LOG_ERROR("No map found for %s",optarg); res=false; } break; } case DOWNLOAD_GAME: { if (!download(CAT_GAME, optarg)) { LOG_ERROR("No game found for %s",optarg); res=false; } break; } case SHOW_VERSION: show_version(); break; case DOWNLOAD_ENGINE: { char buf[1024]; snprintf(buf, sizeof(buf), "spring %s", optarg); if (!download(CAT_ENGINE, buf)) { LOG_ERROR("No engine version found for %s",optarg); res=false; } break; } case HELP: default: { show_help(argv[0]); break; } } } if (optind < argc) { while (optind < argc) { if (!download(CAT_ANY, argv[optind])) { LOG_ERROR("No file found for %s",argv[optind]); res=false; } optind++; } } DownloadStart(); DownloadShutdown(); if (res) return 0; return 1; }