void MetaEditor::reject() { WriteSettings(); QDialog::reject(); }
void ClipboardHistorySelector::reject() { WriteSettings(); QDialog::reject(); }
Preferences::~Preferences () { /* Write settings to the file before dying */ WriteSettings(); }
//----------------------------------------------------------------------------- // Purpose: // Input : wParam - // lParam - // Output : LRESULT //----------------------------------------------------------------------------- LRESULT CTextureBrowser::OnTextureWindowDblClk(WPARAM wParam, LPARAM lParam) { WriteSettings(); SaveAndExit(); return(0); }
EditTOC::~EditTOC() { WriteSettings(); }
void MainWindow::closeEvent(QCloseEvent *event) { WriteSettings(); QMainWindow::closeEvent(event); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTextureBrowser::OnCancel() { WriteSettings(); SaveAndExit(); CDialog::OnCancel(); }
// Destructor HeadingSelector::~HeadingSelector() { WriteSettings(); UnlockHTMLResources(); }
SpellcheckEditor::~SpellcheckEditor() { WriteSettings(); }
void CNetworkInterfaceLinux::SetSettings(NetworkAssignment& assignment, std::string& ipAddress, std::string& networkMask, std::string& defaultGateway, std::string& essId, std::string& key, EncMode& encryptionMode) { #if defined(TARGET_LINUX) FILE* fr = fopen("/etc/network/interfaces", "r"); if (!fr) { // TODO return; } FILE* fw = fopen("/tmp/interfaces.temp", "w"); if (!fw) { // TODO fclose(fr); return; } char* line = NULL; size_t linel = 0; std::string s; bool foundInterface = false; bool dataWritten = false; while (getdelim(&line, &linel, '\n', fr) > 0) { std::vector<std::string> tokens; s = line; StringUtils::TrimLeft(s, " \t"); StringUtils::TrimRight(s," \n"); // skip comments if (!foundInterface && (s.empty() || s[0] == '#')) { fprintf(fw, "%s", line); continue; } // look for "iface <interface name> inet" StringUtils::Tokenize(s, tokens, " "); if (tokens.size() == 2 && StringUtils::EqualsNoCase(tokens[0], "auto") && StringUtils::EqualsNoCase(tokens[1], GetName())) { continue; } else if (!foundInterface && tokens.size() == 4 && StringUtils::EqualsNoCase(tokens[0], "iface") && StringUtils::EqualsNoCase(tokens[1], GetName()) && StringUtils::EqualsNoCase(tokens[2], "inet")) { foundInterface = true; WriteSettings(fw, assignment, ipAddress, networkMask, defaultGateway, essId, key, encryptionMode); dataWritten = true; } else if (foundInterface && tokens.size() == 4 && StringUtils::EqualsNoCase(tokens[0], "iface")) { foundInterface = false; fprintf(fw, "%s", line); } else if (!foundInterface) { fprintf(fw, "%s", line); } } free(line); if (!dataWritten && assignment != NETWORK_DISABLED) { fprintf(fw, "\n"); WriteSettings(fw, assignment, ipAddress, networkMask, defaultGateway, essId, key, encryptionMode); } fclose(fr); fclose(fw); // Rename the file if (rename("/tmp/interfaces.temp", "/etc/network/interfaces") < 0) { // TODO return; } std::string cmd = "/sbin/ifdown " + GetName(); if (system(cmd.c_str()) != 0) CLog::Log(LOGERROR, "Unable to stop interface %s", GetName().c_str()); else CLog::Log(LOGINFO, "Stopped interface %s", GetName().c_str()); if (assignment != NETWORK_DISABLED) { cmd = "/sbin/ifup " + GetName(); if (system(cmd.c_str()) != 0) CLog::Log(LOGERROR, "Unable to start interface %s", GetName().c_str()); else CLog::Log(LOGINFO, "Started interface %s", GetName().c_str()); } #endif }
void DisplayDialog() { GtkWidget *dialog; int return_value; GtkWidget *msg_box, *log_box, *dump_box, *main_box; GtkWidget *msg_frame, *log_frame, *dump_frame, *main_frame; GtkWidget *msg_console_check, *msg_key_check, *msg_voice_check, *msg_dma_check; GtkWidget *msg_autodma_check, *msg_overrun_check, *msg_cache_check; GtkWidget *log_access_check, *log_dma_check, *log_wave_check; GtkWidget *dump_core_check, *dump_mem_check, *dump_reg_check; ReadSettings(); // Create the widgets dialog = gtk_dialog_new_with_buttons ( "Spu2-X Config", NULL, // parent window (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), "OK", GTK_RESPONSE_ACCEPT, "Cancel", GTK_RESPONSE_REJECT, NULL); main_box = gtk_hbox_new(false, 5); main_frame = gtk_frame_new ("Spu2-X Config"); gtk_container_add (GTK_CONTAINER(main_frame), main_box); // Message Section msg_box = gtk_vbox_new(false, 5); msg_console_check = gtk_check_button_new_with_label("Show In Console"); msg_key_check = gtk_check_button_new_with_label("KeyOn/Off Events"); msg_voice_check = gtk_check_button_new_with_label("Voice Stop Events"); msg_dma_check = gtk_check_button_new_with_label("DMA Operations"); msg_autodma_check = gtk_check_button_new_with_label("AutoDMA Operations"); msg_overrun_check = gtk_check_button_new_with_label("Buffer Over/Underruns"); msg_cache_check = gtk_check_button_new_with_label("ADPCM Cache Statistics"); gtk_container_add(GTK_CONTAINER(msg_box), msg_console_check); gtk_container_add(GTK_CONTAINER(msg_box), msg_key_check); gtk_container_add(GTK_CONTAINER(msg_box), msg_voice_check); gtk_container_add(GTK_CONTAINER(msg_box), msg_dma_check); gtk_container_add(GTK_CONTAINER(msg_box), msg_autodma_check); gtk_container_add(GTK_CONTAINER(msg_box), msg_overrun_check); gtk_container_add(GTK_CONTAINER(msg_box), msg_cache_check); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msg_console_check), _MsgToConsole); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msg_key_check), _MsgKeyOnOff); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msg_voice_check), _MsgVoiceOff); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msg_dma_check), _MsgDMA); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msg_autodma_check), _MsgAutoDMA); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msg_overrun_check), _MsgOverruns); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msg_cache_check), _MsgCache); msg_frame = gtk_frame_new ("Message/Log Options"); gtk_container_add (GTK_CONTAINER(msg_frame), msg_box); // Log Section log_box = gtk_vbox_new(false, 5); log_access_check = gtk_check_button_new_with_label("Log Register/DMA Actions"); log_dma_check = gtk_check_button_new_with_label("Log DMA Writes"); log_wave_check = gtk_check_button_new_with_label("Log Audio Output"); gtk_container_add(GTK_CONTAINER(log_box), log_access_check); gtk_container_add(GTK_CONTAINER(log_box), log_dma_check); gtk_container_add(GTK_CONTAINER(log_box), log_wave_check); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(log_access_check), _AccessLog); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(log_dma_check), _DMALog); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(log_wave_check), _WaveLog); log_frame = gtk_frame_new ("Log Options"); gtk_container_add (GTK_CONTAINER(log_frame), log_box); // Dump Section dump_box = gtk_vbox_new(false, 5); dump_core_check = gtk_check_button_new_with_label("Dump Core and Voice State"); dump_mem_check = gtk_check_button_new_with_label("Dump Memory Contents"); dump_reg_check = gtk_check_button_new_with_label("Dump Register Data"); gtk_container_add(GTK_CONTAINER(dump_box), dump_core_check); gtk_container_add(GTK_CONTAINER(dump_box), dump_mem_check); gtk_container_add(GTK_CONTAINER(dump_box), dump_reg_check); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dump_core_check), _CoresDump); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dump_mem_check), _MemDump); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dump_reg_check), _RegDump); dump_frame = gtk_frame_new ("Dumps (on close)"); gtk_container_add (GTK_CONTAINER(dump_frame), dump_box); // Add everything gtk_container_add (GTK_CONTAINER(main_box), msg_frame); gtk_container_add (GTK_CONTAINER(main_box), log_frame); gtk_container_add (GTK_CONTAINER(main_box), dump_frame); // Add all our widgets, and show everything we've added to the dialog. gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_frame); gtk_widget_show_all (dialog); return_value = gtk_dialog_run (GTK_DIALOG (dialog)); if (return_value == GTK_RESPONSE_ACCEPT) { _MsgToConsole = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msg_console_check)); _MsgKeyOnOff = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msg_key_check)); _MsgVoiceOff = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msg_voice_check)); _MsgDMA = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msg_dma_check)); _MsgAutoDMA = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msg_autodma_check)); _MsgOverruns = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msg_overrun_check)); _MsgCache = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msg_cache_check)); _AccessLog = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(log_access_check)); _DMALog = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(log_dma_check)); _WaveLog = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(log_wave_check)); _CoresDump = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dump_core_check)); _MemDump = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dump_mem_check)); _RegDump = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dump_reg_check)); } gtk_widget_destroy (dialog); WriteSettings(); }
static BOOL CALLBACK DialogProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { int wmId; //wchar_t temp[384]={0}; switch(uMsg) { case WM_PAINT: return FALSE; case WM_INITDIALOG: { EnableControls( hWnd ); // Debugging / Logging Flags: SET_CHECK(IDC_DEBUG, DebugEnabled); SET_CHECK(IDC_MSGSHOW, _MsgToConsole); SET_CHECK(IDC_MSGKEY, _MsgKeyOnOff); SET_CHECK(IDC_MSGVOICE,_MsgVoiceOff); SET_CHECK(IDC_MSGDMA, _MsgDMA); SET_CHECK(IDC_MSGADMA, _MsgAutoDMA); SET_CHECK(IDC_DBG_OVERRUNS, _MsgOverruns ); SET_CHECK(IDC_DBG_CACHE, _MsgCache ); SET_CHECK(IDC_LOGREGS, _AccessLog); SET_CHECK(IDC_LOGDMA, _DMALog); SET_CHECK(IDC_LOGWAVE, _WaveLog); SET_CHECK(IDC_DUMPCORE,_CoresDump); SET_CHECK(IDC_DUMPMEM, _MemDump); SET_CHECK(IDC_DUMPREGS,_RegDump); SET_CHECK(IDC_DEBUG_VISUAL,_visual_debug_enabled); ShowWindow( GetDlgItem( hWnd, IDC_MSG_PUBLIC_BUILD ), !IsDevBuild ); } break; case WM_COMMAND: wmId = LOWORD(wParam); // Parse the menu selections: switch (wmId) { case IDOK: WriteSettings(); EndDialog(hWnd,0); break; case IDCANCEL: EndDialog(hWnd,0); break; HANDLE_CHECKNB(IDC_MSGSHOW,_MsgToConsole); EnableMessages( hWnd ); break; HANDLE_CHECK(IDC_MSGKEY,_MsgKeyOnOff); HANDLE_CHECK(IDC_MSGVOICE,_MsgVoiceOff); HANDLE_CHECK(IDC_MSGDMA,_MsgDMA); HANDLE_CHECK(IDC_MSGADMA,_MsgAutoDMA); break; HANDLE_CHECK(IDC_DBG_OVERRUNS,_MsgOverruns); HANDLE_CHECK(IDC_DBG_CACHE,_MsgCache); HANDLE_CHECK(IDC_LOGREGS,_AccessLog); HANDLE_CHECK(IDC_LOGDMA, _DMALog); HANDLE_CHECK(IDC_LOGWAVE,_WaveLog); HANDLE_CHECK(IDC_DUMPCORE,_CoresDump); HANDLE_CHECK(IDC_DUMPMEM, _MemDump); HANDLE_CHECK(IDC_DUMPREGS,_RegDump); HANDLE_CHECK(IDC_DEBUG_VISUAL,_visual_debug_enabled); default: return FALSE; } break; default: return FALSE; } return TRUE; }
void page_response(HttpHeader *header){ bool reset=FALSE; bool prepare=TRUE; char* action=header->action; OUTD("action=%s",action); Ql_memset(__data_buf,0,4096); Ql_memset(__s_buf,0,10240); if (Ql_strstr(header->action, "/")) { get_main_page( __est_connection ? "System state is start":"System state stop"); OUTD("main page",NULL); } else if (Ql_strstr(action,"reboot")) { get_rebot_page(); reset=TRUE; } else if (Ql_strstr(action,"settings?")) { char* pch=NULL; char* last=NULL; //OUTD("parse setting action:%s",pch); pch=strtok_r(action+9,"&",&last); //OUTD("parse command:%s",pch); while (pch!=NULL) { setCommand(pch); pch=strtok_r(NULL,"&",&last); //OUTD("parse command:%s",pch); } WriteSettings(); ReadSettings(); get_main_page("Save settings controller is OK"); } else if (Ql_strstr(action,"date?")) { bool sdt=SetLocDate(action+5); get_main_page(sdt ? "Set date and time is OK":"Error set date and time"); } else if (Ql_strstr(action,"stop")) { StopEstConnection(); get_main_page("Recive command Stop"); } else if (Ql_strstr(action,"run")) { nSTATE=STATE_EST_SOCKET_CREATE; get_main_page("Recive command Start"); } else if (Ql_strstr(action,"log")) { u16 size=0; ReadLogFile(&size); Ql_sprintf(__s_buf,__download_page,size); //Ql_strcpy(&__s_buf[Ql_strlen(__s_buf)],__buf_log); Ql_memcpy(&__s_buf[Ql_strlen(__s_buf)],__buf_log,size); OUTD("__download_page:%d file size:%d buffer-len:%d",Ql_strlen(__download_page),size,Ql_strlen(__s_buf)); prepare=FALSE; } else if (Ql_strstr(action, "autorize")) { Ql_sprintf(__s_buf,__autorize,0); prepare=FALSE; OUTD("set autorize",NULL); } else { get_error_page(); Ql_sprintf(__s_buf,__error_page,0); prepare=FALSE; } if (prepare) { //if (header->set_cookie) { // Ql_sprintf(__s_buf, __ok_page, Ql_strlen(__data_buf),"\r\nSet-Cookie: __ztp=987654321\r\n"); //} Ql_sprintf(__s_buf, __ok_page, Ql_strlen(__data_buf)); Ql_strcpy(&__s_buf[Ql_strlen(__s_buf)],__data_buf); OUTD("sbuf:%d dbuf:%d",Ql_strlen(__s_buf),Ql_strlen(__data_buf)); } if (reset) { Ql_Sleep(10000); Ql_Reset(0); } }
void ReadSettings() { // For some reason this can be called before we know what ini file we're writing to. // Lets not try to read it if that happens. if (!pathSet) { FileLog("Read called without the path set.\n"); return; } Interpolation = CfgReadInt( L"MIXING",L"Interpolation", 4 ); EffectsDisabled = CfgReadBool( L"MIXING", L"Disable_Effects", false ); postprocess_filter_dealias = CfgReadBool( L"MIXING", L"DealiasFilter", false ); FinalVolume = ((float)CfgReadInt( L"MIXING", L"FinalVolume", 100 )) / 100; if ( FinalVolume > 1.0f) FinalVolume = 1.0f; AdvancedVolumeControl = CfgReadBool(L"MIXING", L"AdvancedVolumeControl", false); VolumeAdjustCdb = CfgReadFloat(L"MIXING", L"VolumeAdjustC(dB)", 0); VolumeAdjustFLdb = CfgReadFloat(L"MIXING", L"VolumeAdjustFL(dB)", 0); VolumeAdjustFRdb = CfgReadFloat(L"MIXING", L"VolumeAdjustFR(dB)", 0); VolumeAdjustBLdb = CfgReadFloat(L"MIXING", L"VolumeAdjustBL(dB)", 0); VolumeAdjustBRdb = CfgReadFloat(L"MIXING", L"VolumeAdjustBR(dB)", 0); VolumeAdjustSLdb = CfgReadFloat(L"MIXING", L"VolumeAdjustSL(dB)", 0); VolumeAdjustSRdb = CfgReadFloat(L"MIXING", L"VolumeAdjustSR(dB)", 0); VolumeAdjustLFEdb = CfgReadFloat(L"MIXING", L"VolumeAdjustLFE(dB)", 0); VolumeAdjustC = powf(10, VolumeAdjustCdb / 10); VolumeAdjustFL = powf(10, VolumeAdjustFLdb / 10); VolumeAdjustFR = powf(10, VolumeAdjustFRdb / 10); VolumeAdjustBL = powf(10, VolumeAdjustBLdb / 10); VolumeAdjustBR = powf(10, VolumeAdjustBRdb / 10); VolumeAdjustSL = powf(10, VolumeAdjustSLdb / 10); VolumeAdjustSR = powf(10, VolumeAdjustSRdb / 10); VolumeAdjustLFE = powf(10, VolumeAdjustLFEdb / 10); delayCycles = CfgReadInt(L"DEBUG", L"DelayCycles", 4); wxString temp; CfgReadStr( L"OUTPUT", L"Output_Module", temp, PortaudioOut->GetIdent() ); OutputModule = FindOutputModuleById( temp.c_str() );// find the driver index of this module // find current API #ifdef __linux__ CfgReadStr( L"PORTAUDIO", L"HostApi", temp, L"ALSA" ); OutputAPI = -1; if (temp == L"ALSA") OutputAPI = 0; if (temp == L"OSS") OutputAPI = 1; if (temp == L"JACK") OutputAPI = 2; #else CfgReadStr( L"PORTAUDIO", L"HostApi", temp, L"OSS" ); OutputAPI = -1; if (temp == L"OSS") OutputAPI = 0; #endif #ifdef __linux__ CfgReadStr( L"SDL", L"HostApi", temp, L"pulseaudio" ); SdlOutputAPI = -1; #if SDL_MAJOR_VERSION >= 2 // YES It sucks ... for (int i = 0; i < SDL_GetNumAudioDrivers(); ++i) { if (!temp.Cmp(wxString(SDL_GetAudioDriver(i), wxConvUTF8))) SdlOutputAPI = i; } #endif #endif SndOutLatencyMS = CfgReadInt(L"OUTPUT",L"Latency", 300); SynchMode = CfgReadInt( L"OUTPUT", L"Synch_Mode", 0); PortaudioOut->ReadSettings(); #ifdef __linux__ SDLOut->ReadSettings(); #endif SoundtouchCfg::ReadSettings(); DebugConfig::ReadSettings(); // Sanity Checks // ------------- Clampify( SndOutLatencyMS, LATENCY_MIN, LATENCY_MAX ); WriteSettings(); spuConfig->Flush(); }