int dhcp(char iface[6]) { int r=0; char command[50],bad[18]; FILE *cmd,*ssid; printf("\nTrying to automatically configure %s on BSSID: %s...",iface,ap); snprintf(command,50,"/sbin/dhcpcd -t 10 -n %s",iface); cmd=popen(command,"r"); r=pclose(cmd); if (r==1) { printf("Error\nNo DHCP on this Network.\n"); addbad(ap); return(2); } printf("done.\n"); r=internet(iface); if(r==0) { return(2); } return (0); }
int HttpDownLoad_real( std::string& tmp_file, const std::string& url, const std::string& file, std::function<void(double)> callback) { HINTERNET hSession = InternetOpen(_T("HTTPDOWNLOAD"), INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); scloud::ScopeGuard session([hSession]{InternetCloseHandle(hSession);}); if (!hSession) { session.cancel(); return GetLastError(); } HINTERNET hInternet = InternetOpenUrl(hSession, url.c_str(), NULL, 0 , INTERNET_FLAG_RAW_DATA, 0 ); scloud::ScopeGuard internet([hInternet]{InternetCloseHandle(hInternet);}); if (!hInternet) { internet.cancel(); return GetLastError(); } //get http return code. char szContent[32] = {0}; DWORD dwInfoSize = 32; HttpQueryInfoA(hInternet, HTTP_QUERY_STATUS_CODE, szContent, &dwInfoSize, NULL); int ret = StrToIntA(szContent); if (ret >= 400) { return ret; } //get file size ZeroMemory(szContent, 32); dwInfoSize = 32; HttpQueryInfoA(hInternet, HTTP_QUERY_CONTENT_LENGTH, szContent, &dwInfoSize, NULL); __int64 size = 0; StrToInt64ExA(szContent, 10, &size); if (size <= 0) { return ERROR_CONTENT_LENGTH_LESS_THAN_ZERO; } TCHAR szTmpFile[MAX_PATH] = {0}; if (!tmp_file.empty()) { lstrcpy(szTmpFile, tmp_file.c_str()); } else { TCHAR szTmpPath[MAX_PATH] = {0}; GetTempPath(MAX_PATH, szTmpPath); if (0 == GetTempFileName(szTmpPath, _T("http"), 0, szTmpFile)) { return GetLastError(); } } tmp_file = szTmpFile; HANDLE hFile = CreateFile(szTmpFile, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); scloud::ScopeGuard create_file([hFile]{CloseHandle(hFile);}); if (INVALID_HANDLE_VALUE == hFile) { create_file.cancel(); return GetLastError(); } LARGE_INTEGER large_int = {0}; GetFileSizeEx(hFile, &large_int); if (large_int.QuadPart > size) { return ERROR_TMP_FILE_TOO_BIG; } if (large_int.QuadPart > 0) { if (INVALID_SET_FILE_POINTER == SetFilePointer(hFile, 0, NULL, FILE_END)) { return GetLastError(); } if (INVALID_SET_FILE_POINTER == InternetSetFilePointer( hInternet, large_int.LowPart, NULL, FILE_BEGIN, 0)) { return GetLastError(); } } __int64 rsize = large_int.QuadPart; for(;rsize < size;) { char buf[512] = {0}; DWORD dwRead = 0; if (!InternetReadFile(hInternet, buf, 512, &dwRead)) { return GetLastError(); } if (dwRead == 0) { return ERROR_WTF_NO_DATA; } for(DWORD dwOnce=0; dwRead != dwOnce;) { DWORD dwWritten = 0; if (0 == WriteFile(hFile, buf+dwOnce, dwRead-dwOnce, &dwWritten, NULL)) return GetLastError(); dwOnce += dwWritten; } rsize += dwRead; if (rsize == size) break; if (callback) callback((double)rsize/size); } if (rsize == size) { create_file.cancel(); CloseHandle(hFile); SetFileAttributes(file.c_str(), FILE_ATTRIBUTE_NORMAL); DeleteFile(file.c_str()); if (MoveFile(szTmpFile, file.c_str())) { //succeed. if (callback) callback(1.0); return 0; } } return GetLastError(); }
int appdrawer() { int browser_x = 30; int browser_text_x = 52; int calc_x = 105; int calc_text_x = 127; int clock_x = 180; int clock_text_x = 202; int fm_x = 255; int fm_text_x = 277; int gallery_x = 330; int gallery_text_x = 352; int game_icon = 405; int game_text_icon = 427; int messenger_x = 30; int messenger_text_x = 52; int music_x = 105; int music_text_x = 127; int settings_x = 180; int settings_test_x = 202; int umd_x = 255; int umd_text_x = 277; //loads appdrawer icons appdrawer_loadImages(); if (!ic_launcher_clock || !backdrop) debugDisplay(); oslSetFont(Roboto); while (!osl_quit) { LowMemExit(); oslStartDrawing(); controls(); oslDrawImage(background); if (eDesktopActivator == 1) { navbarButtons(1); battery(370,2,3); if ((cursor->y <= 16) || (cursor->y >= 226)) { digitaltime(420,4,0,hrTime); } else if (cursor->y >= 16 && cursor->y <= 226) { digitaltime(420,-10,0,hrTime); } } else if (eDesktopActivator == 0) { navbarButtons(0); battery(370,2,1); digitaltime(420,4,0,hrTime); } if (DARK == 0) oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, INTRAFONT_ALIGN_CENTER); else oslIntraFontSetStyle(Roboto, fontSize, WHITE, 0, INTRAFONT_ALIGN_CENTER); oslDrawImageXY(backdrop, 1, 15); oslDrawImageXY(ic_launcher_browser, browser_x, 40); oslDrawStringf(browser_text_x, 90, "%s", lang_appDrawer[language][0]); oslDrawImageXY(ic_launcher_calculator, calc_x, 40); oslDrawStringf(calc_text_x, 90, "%s", lang_appDrawer[language][1]); oslDrawImageXY(ic_launcher_clock, clock_x, 40); oslDrawStringf(clock_text_x, 90, "%s", lang_appDrawer[language][2]); oslDrawImageXY(ic_launcher_filemanager, fm_x, 40); oslDrawStringf(fm_text_x, 90,"%s", lang_appDrawer[language][3]); oslDrawImageXY(ic_launcher_gallery, gallery_x, 40); oslDrawStringf(gallery_text_x, 90, "%s", lang_appDrawer[language][4]); oslDrawImageXY(ic_launcher_game, game_icon, 40); oslDrawStringf(game_text_icon, 90, "%s", lang_appDrawer[language][5]); oslDrawImageXY(ic_launcher_messenger, messenger_x, 130); oslDrawStringf(messenger_text_x, 185, "%s", lang_appDrawer[language][6]); oslDrawImageXY(ic_launcher_apollo, music_x, 130); oslDrawStringf(music_text_x, 185, "%s", lang_appDrawer[language][7]); oslDrawImageXY(ic_launcher_settings, settings_x, 130); oslDrawStringf(settings_test_x, 185, "%s", lang_appDrawer[language][8]); oslDrawImageXY(ic_launcher_umd, umd_x, 132); oslDrawStringf(umd_text_x, 185, "%s", lang_appDrawer[language][9]); androidQuickSettings(); volumeController(); appHighlight(1); oslDrawImage(cursor); if (osl_keys->pressed.square) { powermenu(); } if (osl_keys->pressed.L) { oslPlaySound(Lock, 1); lockscreen(); } if (osl_keys->pressed.circle) { appdrawer_deleteImages(); home(); } if (cursor->x >= 15 && cursor->x <= 75 && cursor->y >= 25 && cursor->y <= 85 && osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); appdrawer_deleteImages(); internet(); } if (experimentalF == 1) { // WIP calculator if (cursor->x >= 100 && cursor->x <= 140 && cursor->y >= 25 && cursor->y <= 85 && osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); appdrawer_deleteImages(); calculator(); } } if (cursor->x >= 160 && cursor->x <= 225 && cursor->y >= 25 && cursor->y <= 85 && osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); appdrawer_deleteImages(); pspclock(); } if (cursor->x >= 245 && cursor->x <= 295 && cursor->y >= 25 && cursor->y <= 85 && osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); appdrawer_deleteImages(); filemanage(); } if (cursor->x >= 320 && cursor->x <= 370 && cursor->y >= 25 && cursor->y <= 85 && osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); appdrawer_deleteImages(); galleryApp(); } if (cursor->x >= 390 && cursor->x <= 450 && cursor->y >= 25 && cursor->y <= 85 && osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); appdrawer_deleteImages(); gameApp(); } if (experimentalF == 1) { //WIP ad-hoc messenger application if (cursor->x >= 15 && cursor->x <= 75 && cursor->y >= 115 && cursor->y <= 180 && osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); appdrawer_deleteImages(); messenger(); } } if (cursor->x >= 100 && cursor->x <= 140 && cursor->y >= 115 && cursor->y <= 180 && osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); appdrawer_deleteImages(); mp3player(); } if (cursor->x >= 160 && cursor->x <= 225 && cursor->y >= 115 && cursor->y <= 180 && osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); appdrawer_deleteImages(); settingsMenu(); } if (cursor->x >= 245 && cursor->x <= 295 && cursor->y >= 115 && cursor->y <= 180 && osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); launchUMD("disc0:/PSP_GAME/SYSDIR/EBOOT.BIN"); } if (cursor->x >= 137 && cursor->x <= 200 && cursor->y >= 237 && cursor->y <= 271 && osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); appdrawer_deleteImages(); home(); } if (cursor->x >= 200 && cursor->x <= 276 && cursor->y >= 237 && cursor->y <= 271 && osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); appdrawer_deleteImages(); home(); } if (cursor->x >= 276 && cursor->x <= 340 && cursor->y >= 237 && cursor->y <= 271 && osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); multitask(); } captureScreenshot(); oslEndDrawing(); oslEndFrame(); oslSyncFrame(); } return 0; }