void ofxTimeMeasurements::_appExited(ofEventArgs &e){
	saveSettings();
}
Example #2
0
void parse_command(int connfd, CControld::Header * rmessage)
{
	
	if(rmessage->version != CControld::ACTVERSION)
	{
		perror("[controld] wrong version\n");
		return;
	}

	switch (rmessage->cmd)
	{
	case CControld::CMD_SHUTDOWN:
		shutdownBox();
		break;

	case CControld::CMD_SAVECONFIG:
		saveSettings();
		break;

	case CControld::CMD_SETVOLUME:
	case CControld::CMD_SETVOLUME_AVS:
		CControld::commandVolume msg_commandVolume;
		read(connfd, &msg_commandVolume, sizeof(msg_commandVolume));

		if (rmessage->cmd == CControld::CMD_SETVOLUME)
		{
			settings.volume = msg_commandVolume.volume;
			config->setInt32("volume", settings.volume);
			zapit.setVolume(map_volume(msg_commandVolume.volume, false), map_volume(msg_commandVolume.volume, false));
		}
		else
		{
			settings.volume_avs = msg_commandVolume.volume;
			config->setInt32("volume_avs", settings.volume_avs);
			audioControl::setVolume(map_volume(msg_commandVolume.volume, true));
		}
		lcdd.setVolume(msg_commandVolume.volume);
		eventServer->sendEvent(CControldClient::EVT_VOLUMECHANGED, CEventServer::INITID_CONTROLD, &msg_commandVolume.volume, sizeof(msg_commandVolume.volume));
		break;

	case CControld::CMD_MUTE:
		settings.mute = true;
		config->setBool("mute", settings.mute);
		zapit.muteAudio(true);
		lcdd.setMute(true);
		eventServer->sendEvent(CControldClient::EVT_MUTECHANGED, CEventServer::INITID_CONTROLD, &settings.mute, sizeof(settings.mute));
		break;
	case CControld::CMD_MUTE_AVS:
		settings.mute_avs = true;
		config->setBool("mute_avs", settings.mute_avs);
		audioControl::setMute(true);
		lcdd.setMute(true);
		eventServer->sendEvent(CControldClient::EVT_MUTECHANGED, CEventServer::INITID_CONTROLD, &settings.mute_avs, sizeof(settings.mute_avs));
		break;
	case CControld::CMD_UNMUTE:
		settings.mute = false;
		config->setBool("mute", settings.mute);
		zapit.muteAudio(false);
		lcdd.setMute(settings.mute_avs);
		eventServer->sendEvent(CControldClient::EVT_MUTECHANGED, CEventServer::INITID_CONTROLD, &settings.mute_avs, sizeof(settings.mute_avs));
		break;
	case CControld::CMD_UNMUTE_AVS:
		settings.mute_avs = false;
		config->setBool("mute_avs", settings.mute_avs);
		audioControl::setMute(false);
		lcdd.setMute(settings.mute);
		eventServer->sendEvent(CControldClient::EVT_MUTECHANGED, CEventServer::INITID_CONTROLD, &settings.mute, sizeof(settings.mute));
		break;

		case CControld::CMD_SETANALOGMODE:
			CControld::commandAnalogMode msgmd;
			read(connfd, &msgmd, sizeof(msgmd));
			zapit.setAudioMode(msgmd.mode);
			break;
		case CControld::CMD_SETVIDEOFORMAT:
			//printf("[controld] set videoformat\n");
			CControld::commandVideoFormat msg2;
			read(connfd, &msg2, sizeof(msg2));
			setVideoFormat(msg2.format);
			break;
		case CControld::CMD_SETVIDEOOUTPUT:
			//printf("[controld] set videooutput\n");
			CControld::commandVideoOutput msg3;
			read(connfd, &msg3, sizeof(msg3));
			setvideooutput(msg3.output);
			break;
		case CControld::CMD_SETBOXTYPE:
			//printf("[controld] set boxtype\n");    //-------------------dummy!!!!!!!!!!
			CControld::commandBoxType msg4;
			read(connfd, &msg4, sizeof(msg4));
			setBoxType();
			break;
		case CControld::CMD_SETSCARTMODE:
			//printf("[controld] set scartmode\n");
			CControld::commandScartMode msg5;
			read(connfd, &msg5, sizeof(msg5));
			setScartMode(msg5.mode);
			break;
		case CControld::CMD_SETVIDEOPOWERDOWN:
			//printf("[controld] set scartmode\n");
			CControld::commandVideoPowerSave msg10;
			read(connfd, &msg10, sizeof(msg10));
			disableVideoOutput(msg10.powerdown);
			break;

	case CControld::CMD_GETVOLUME:
	case CControld::CMD_GETVOLUME_AVS:
		CControld::responseVolume msg_responseVolume;
		msg_responseVolume.volume = (rmessage->cmd == CControld::CMD_GETVOLUME) ? settings.volume : settings.volume_avs;
		write(connfd, &msg_responseVolume, sizeof(msg_responseVolume));
		break;

	case CControld::CMD_GETMUTESTATUS:
	case CControld::CMD_GETMUTESTATUS_AVS:
		CControld::responseMute msg_responseMute;
		msg_responseMute.mute = (rmessage->cmd == CControld::CMD_GETMUTESTATUS) ? settings.mute : settings.mute_avs;
		write(connfd, &msg_responseMute, sizeof(msg_responseMute));
		break;

		case CControld::CMD_GETVIDEOFORMAT:
			//printf("[controld] get videoformat (fnc)\n");
			CControld::responseVideoFormat msg8;
			msg8.format = settings.videoformat;
			write(connfd,&msg8,sizeof(msg8));
			break;
		case CControld::CMD_GETASPECTRATIO:
			//printf("[controld] get videoformat (fnc)\n");
			CControld::responseAspectRatio msga;
			msga.aspectRatio = aspectRatio;
			write(connfd,&msga,sizeof(msga));
			break;
		case CControld::CMD_GETVIDEOOUTPUT:
			//printf("[controld] get videooutput (fblk)\n");
			CControld::responseVideoOutput msg9;
			msg9.output = settings.videooutput;
			write(connfd,&msg9,sizeof(msg9));
			break;
		case CControld::CMD_GETBOXTYPE:
			//printf("[controld] get boxtype\n");
			CControld::responseBoxType msg0;
			msg0.boxtype = settings.boxtype;
			write(connfd,&msg0,sizeof(msg0));
			break;

		case CControld::CMD_REGISTEREVENT:
			eventServer->registerEvent(connfd);
			break;
		case CControld::CMD_UNREGISTEREVENT:
			eventServer->unRegisterEvent(connfd);
			break;

		default:
			printf("[controld] unknown command\n");
	}
}
void doProfileAutoSelect()
{
	g_autoSelectProfile = !g_autoSelectProfile;
	::SendMessage(nppData._nppHandle, NPPM_SETMENUITEMCHECK, funcItem[g_fiAutoProfile]._cmdID, g_autoSelectProfile ? TRUE : FALSE);
	saveSettings();
}
Example #4
0
void Application::delItemFavorite(int idx)
{
    favModel->delItemFavorite(idx);

    saveSettings();
}
/**
 * @brief edit::on_pushButton_clicked handler for save button
 */
void edit::on_pushButton_clicked()
{
    saveSettings();
    this->close();
    dashb->show();
}
Example #6
0
void Settings::loadSettings(QString name)
{
    _settings = new QSettings("QDChat_", name);
    saveSettings(name);
}
void MainWindow::closeEvent( QCloseEvent *event )
{
    saveSettings();
}
Example #8
0
	void Application::destroyScene()
	{
		saveSettings();

		StateManager::getInstance().rollbackToState(nullptr);

		GridManager::getInstance().shutdown();
		delete GridManager::getInstancePtr();

		PropertyFieldManager::getInstance().shutdown();
		delete PropertyFieldManager::getInstancePtr();

		EditorToolTip::getInstance().shutdown();
		delete EditorToolTip::getInstancePtr();

		ColourManager::getInstance().shutdown();
		delete ColourManager::getInstancePtr();

		BackwardCompatibilityManager::getInstance().shutdown();
		delete BackwardCompatibilityManager::getInstancePtr();

		RecentFilesManager::getInstance().shutdown();
		delete RecentFilesManager::getInstancePtr();

		StateManager::getInstance().shutdown();
		delete StateManager::getInstancePtr();

		GroupMessage::getInstance().shutdown();
		delete GroupMessage::getInstancePtr();

		DialogManager::getInstance().shutdown();
		delete DialogManager::getInstancePtr();

		MessageBoxManager::getInstance().shutdown();
		delete MessageBoxManager::getInstancePtr();

		UndoManager::getInstance().shutdown();
		delete UndoManager::getInstancePtr();

		EditorWidgets::getInstance().shutdown();
		delete EditorWidgets::getInstancePtr();

		WidgetTypes::getInstance().shutdown();
		delete WidgetTypes::getInstancePtr();

		HotKeyManager::getInstance().shutdown();
		delete HotKeyManager::getInstancePtr();

		WidgetCreatorManager::getInstance().shutdown();
		delete WidgetCreatorManager::getInstancePtr();

		WidgetSelectorManager::getInstance().shutdown();
		delete WidgetSelectorManager::getInstancePtr();

		CommandManager::getInstance().shutdown();
		delete CommandManager::getInstancePtr();

		SettingsManager::getInstance().saveSettingsFile("SettingsResult.xml");
		SettingsManager::getInstance().saveUserSettingsFile();
		delete SettingsManager::getInstancePtr();

		std::string subWidgetCategory = MyGUI::SubWidgetManager::getInstance().getCategoryName();
		MyGUI::FactoryManager::getInstance().unregisterFactory<MyGUI::FilterNone>(subWidgetCategory);

		std::string layerCategory = MyGUI::LayerManager::getInstance().getCategoryName();
		MyGUI::FactoryManager::getInstance().unregisterFactory<MyGUI::RTTLayer>(layerCategory);
	}
Example #9
0
MainWindow::~MainWindow()
{
    closeMPQ();
    saveSettings();
    delete ui;
}
Example #10
0
void WHTMLReport::process ()
{
  saveSettings();
  Instrumentation::coverage_method_t coverage_method=CoverageSettings::object().getCoverageMethod();
  int global_coverage_level = global_coverage_level_p->value();

  CSMes::DisplayLevelType_t global_coverage_display_mode=CSMes::DISPLAY_NOTHING;
  if (!statistic_global_coverage_p->isChecked())
    global_coverage_display_mode=CSMes::DISPLAY_NOTHING;
  else if (global_coverage_output_all_level_p->isChecked())
    global_coverage_display_mode=CSMes::ALL_LEVEL;
  else if (global_coverage_output_selected_level_p->isChecked())
    global_coverage_display_mode=CSMes::SELECTED_LEVEL;
  else if (global_coverage_output_selected_level_and_level_1_p->isChecked())
    global_coverage_display_mode=CSMes::SELECTED_LEVEL_AND_LEVEL_1;

  CSMes::DisplayLevelType_t method_coverage_display_mode=CSMes::DISPLAY_NOTHING;
  if (!statistic_method_p->isChecked())
    method_coverage_display_mode=CSMes::DISPLAY_NOTHING;
  else if (methods_output_all_level_p->isChecked())
    method_coverage_display_mode=CSMes::ALL_LEVEL;
  else if (methods_output_selected_level_p->isChecked())
    method_coverage_display_mode=CSMes::SELECTED_LEVEL;
  else if (methods_output_selected_level_and_level_1_p->isChecked())
    method_coverage_display_mode=CSMes::SELECTED_LEVEL_AND_LEVEL_1;
  CSMes::DisplaySortingType_t method_coverage_sorting_mode=CSMes::SORT_NONE;
  if (methods_sorting_coverage_p->isChecked())
    method_coverage_sorting_mode=CSMes::SORT_COVERAGE;
  else if (methods_sorting_name_p->isChecked())
    method_coverage_sorting_mode=CSMes::SORT_NAME;

  CSMes::DisplayLevelType_t execution_coverage_display_mode=CSMes::DISPLAY_NOTHING;
  if (!statistic_executions_p->isChecked())
    execution_coverage_display_mode=CSMes::DISPLAY_NOTHING;
  else if (executions_output_all_level_p->isChecked())
    execution_coverage_display_mode=CSMes::ALL_LEVEL;
  else if (executions_output_selected_level_p->isChecked())
    execution_coverage_display_mode=CSMes::SELECTED_LEVEL;
  else if (executions_output_selected_level_and_level_1_p->isChecked())
    execution_coverage_display_mode=CSMes::SELECTED_LEVEL_AND_LEVEL_1;
  CSMes::DisplaySortingType_t execution_coverage_sorting_mode=CSMes::SORT_NONE;
  if (executions_sorting_coverage_p->isChecked())
    execution_coverage_sorting_mode=CSMes::SORT_COVERAGE;
  else if (executions_sorting_name_p->isChecked())
    execution_coverage_sorting_mode=CSMes::SORT_NAME;

  CSMes::DisplayLevelType_t source_coverage_display_mode=CSMes::DISPLAY_NOTHING;
  if (!statistic_sources_p->isChecked())
    source_coverage_display_mode=CSMes::DISPLAY_NOTHING;
  else if (sources_output_all_level_p->isChecked())
    source_coverage_display_mode=CSMes::ALL_LEVEL;
  else if (sources_output_selected_level_p->isChecked())
    source_coverage_display_mode=CSMes::SELECTED_LEVEL;
  else if (sources_output_selected_level_and_level_1_p->isChecked())
    source_coverage_display_mode=CSMes::SELECTED_LEVEL_AND_LEVEL_1;
  CSMes::DisplaySortingType_t source_coverage_sorting_mode=CSMes::SORT_NONE;
  if (sources_sorting_coverage_p->isChecked())
    source_coverage_sorting_mode=CSMes::SORT_COVERAGE;
  else if (sources_sorting_name_p->isChecked())
    source_coverage_sorting_mode=CSMes::SORT_NAME;

  if (!csmes_p->exportHtmlReport(
        documentType(),
        file(),
        title_p->text(),
        icon_p->text(),
        css_file_p->text(),

        global_coverage_display_mode,
        method_coverage_display_mode,
        method_coverage_sorting_mode,
        source_coverage_display_mode,
        source_coverage_sorting_mode,
        execution_coverage_display_mode,
        execution_coverage_sorting_mode,

        executions_level_p->value(),

        toc_p->isChecked(),
        code_fragments_manually_validated_p->isChecked() && code_fragments_p->isChecked() ,
        code_fragments_unexecuted_p->isChecked() && code_fragments_p->isChecked(),
        code_fragments_executed_p->isChecked() && code_fragments_p->isChecked(),

        executions_filter_active_p->isChecked(),
        executions_filter_min_p->value(),
        executions_filter_max_p->value(),

        sources_filter_active_p->isChecked(),
        sources_filter_min_p->value(),
        sources_filter_max_p->value(),


        methods_filter_active_p->isChecked(),
        methods_filter_min_p->value(),
        methods_filter_max_p->value(),

        executions_watermark_medium_level_p->value(),
        executions_watermark_low_level_p->value(),
        global_coverage_watermark_medium_level_p->value(),
        global_coverage_watermark_low_level_p->value(),

        global_coverage_max_intermediate_levels_p->value(),
        methods_max_intermediate_levels_p->value(),
        executions_max_intermediate_levels_p->value(),
        sources_max_intermediate_levels_p->value(),
        global_coverage_level,
        coverage_method,

        methods_level_p->value(),
        methods_watermark_low_level_p->value(),
        methods_watermark_medium_level_p->value(),
        sources_watermark_low_level_p->value(),
        sources_watermark_medium_level_p->value(),
        CoverageSettings::object().getTestCoverageMode(),
        bargraph_p->isChecked(),
        executed_by_limit_p->value()
          )
          )
          {
            QMessageBox::warning(this,tr("Error"),
                tr("Could not write file '%1'").arg(file()),
                QMessageBox::Close,QMessageBox::NoButton);
            accept();
            return;
          }

  accept();
}
Example #11
0
void WHTMLReport::apply()
{
  saveSettings();
}
Example #12
0
AppConfig::~AppConfig()
{
	saveSettings();
}
Example #13
0
//--------------------------------------------------------------
void testApp::update(){
	// check for waiting messages
    
	while(receiver.hasWaitingMessages()){
        
        lastCmdTime = ofGetElapsedTimeMillis();
        
		// get the next message
		ofxOscMessage m;
                
		receiver.getNextMessage(&m);

        
        if ( m.getAddress() == "/l" ){ // Set a single led
            
            ledData[m.getArgAsInt32(0)].set(m.getArgAsInt32(1), m.getArgAsInt32(2), m.getArgAsInt32(3), 255);
                        
            lastLedCmdTime = ofGetElapsedTimeMillis();
            autoMode = false;
            
        } else if ( m.getAddress() == "/p" ) { // Set all
            
            //if( ofGetElapsedTimeMillis() - lastLedCmdTime > 2 ) {
                                
                int led = 1;
                int section = m.getArgAsInt32(0);
                int start   = section;
                int end     = start+120;
                
                for(int i=start; i<end && i<height; i++) {
                    
                    if(led+2 < m.getNumArgs()) {
                        ledData[i].set(m.getArgAsInt32(led),m.getArgAsInt32(led+1),m.getArgAsInt32(led+2));
                    }
                    
                    led +=3;
                }
                lastLedCmdTime = ofGetElapsedTimeMillis();
                
            //}
            autoMode = false;
            
        } else if ( m.getAddress() == "/c" ) {
            // Compressed data not yet implemented
            if( ofGetElapsedTimeMillis() - lastLedCmdTime > 2 ) {
                
                lastLedCmdTime = ofGetElapsedTimeMillis();
            
            }
            
       
        } else if ( m.getAddress() == "/status" ) {
            
            ofxOscMessage r;
            r.setAddress("/status");
            r.addStringArg(m.getArgAsString(0));
            if(autoMode) {
                r.addIntArg(2);
                r.addStringArg("Not receiving data. Running auto mode.");
            } else {
                r.addIntArg(1);
                r.addStringArg("All good, alive and listening.");
            }
            
            r.addStringArg(hostname);
            sender.sendMessage(r);
            
        } else if ( m.getAddress() == "/debug" ) {
            
            if(m.getArgAsInt32(0) == 1) {
                ofSetLogLevel(OF_LOG_VERBOSE);
            } else {
                ofSetLogLevel(OF_LOG_SILENT);
            }
            
        
        } else if ( m.getAddress() == "/setLength" ) {
            height  = m.getArgAsInt32(0);
            led     = new ofxLEDsLPD8806(height);
            ledData.assign(height,ofColor());
            ofLogNotice() << " Set LED length to " << height;

		} else if ( m.getAddress() == "/setId" ) {
            
            clientId = m.getArgAsInt32(0);
            saveSettings();
            state = STATE_CONNECTED;
            
            ofLogNotice() << " Set ID to " << clientId;

        } else if ( m.getAddress() == "/setMaster" ) {
            
            sender.setup(masterHostname, masterPort);
            masterHostname = m.getArgAsString(0);
            saveSettings();
            
            ofLogNotice() << " Set Master hostname to " << masterHostname;
            
        }
        
	}
    
    if( ofGetElapsedTimeMillis() - lastLedCmdTime > autoModeDelay ) {
        autoMode = true;
        state = STATE_WAITING;
    }
    
    
    if(state == STATE_WAITING) {
        
        if(ofGetElapsedTimeMillis() - helloTime > helloResponseWait) {
            helloTime = ofGetElapsedTimeMillis();
            ofxOscMessage m;
            
            m.setAddress("/hello");
            m.addIntArg(clientId);
            sender.sendMessage(m);
        }
    }

}
Example #14
0
void testApp::s0Events(ofxUIEventArgs &e){
    
    string name = e.widget->getName();
    
    if(e.widget->getKind() == 12){ //no key events whilst text is focussed
        
        ofxUITextInput * t = (ofxUITextInput *) e.widget;
        
        if(t->getTriggerType() == OFX_UI_TEXTINPUT_ON_FOCUS){
            t->setTriggerType(OFX_UI_TEXTINPUT_ON_UNFOCUS);
            isTextFocus = true;
        }else{
            t->setTriggerType(OFX_UI_TEXTINPUT_ON_FOCUS);
            isTextFocus = false;
        }
        
    }
    
    
    if(isMouseDown){
        
        if(!isSaveDialog && !isLoadDialog){
            if(name == "SAVE"){
                confLab->setLabel("CONFIRM SAVE FILE");
                isSaveDialog = true; isLoadDialog = false;
                dialog->setVisible(true);
            }
            
            if(name == "LOAD"){
                isLoadDialog = true; isSaveDialog = false;
                confLab->setLabel("CONFIRM LOAD FILE");
                dialog->setVisible(true);
            }
        }else{
            
            if(isSaveDialog){
                
                if(name == "OK"){
                    saveSettings(fileNameInput->getTextString());
                    dialog->setVisible(false);
                    isSaveDialog = false;
                }else{
                    isSaveDialog = false;
                    dialog->setVisible(false);
                }
            }
            
            if(isLoadDialog){
                
                if(name == "OK"){
                    loadSettings(fileNameInput->getTextString());
                    dialog->setVisible(false);
                    isLoadDialog = false;
                }else{
                    isLoadDialog = false;
                    dialog->setVisible(false);
                }
            }
            
        }
        
        
        
        
    }
    
    
	
}
Example #15
0
void QgsColorDialogV2::closeEvent( QCloseEvent *e )
{
  saveSettings();
  QDialog::closeEvent( e );
}
Example #16
0
bool RTIMUSettings::loadSettings()
{
    char buf[200];
    char key[200];
    char val[200];
    RTFLOAT ftemp;

    //  preset general defaults

    m_imuType = RTIMU_TYPE_AUTODISCOVER;
    m_I2CSlaveAddress = 0;
    m_I2CBus = 1;
    m_fusionType = RTFUSION_TYPE_RTQF;
    m_compassCalValid = false;

    //  MPU9150 defaults

    m_MPU9150GyroAccelSampleRate = 50;
    m_MPU9150CompassSampleRate = 25;
    m_MPU9150GyroAccelLpf = MPU9150_LPF_20;
    m_MPU9150GyroFsr = MPU9150_GYROFSR_1000;
    m_MPU9150AccelFsr = MPU9150_ACCELFSR_8;

    //  GD20HM303D defaults

    m_GD20HM303DGyroSampleRate = L3GD20H_SAMPLERATE_50;
    m_GD20HM303DGyroBW = L3GD20H_BANDWIDTH_1;
    m_GD20HM303DGyroHpf = L3GD20H_HPF_4;
    m_GD20HM303DGyroFsr = L3GD20H_FSR_500;

    m_GD20HM303DAccelSampleRate = LSM303D_ACCEL_SAMPLERATE_50;
    m_GD20HM303DAccelFsr = LSM303D_ACCEL_FSR_8;
    m_GD20HM303DAccelLpf = LSM303D_ACCEL_LPF_50;

    m_GD20HM303DCompassSampleRate = LSM303D_COMPASS_SAMPLERATE_50;
    m_GD20HM303DCompassFsr = LSM303D_COMPASS_FSR_2;

    //  GD20M303DLHC defaults

    m_GD20M303DLHCGyroSampleRate = L3GD20_SAMPLERATE_95;
    m_GD20M303DLHCGyroBW = L3GD20_BANDWIDTH_1;
    m_GD20M303DLHCGyroHpf = L3GD20_HPF_4;
    m_GD20M303DLHCGyroFsr = L3GD20H_FSR_500;

    m_GD20M303DLHCAccelSampleRate = LSM303DLHC_ACCEL_SAMPLERATE_50;
    m_GD20M303DLHCAccelFsr = LSM303DLHC_ACCEL_FSR_8;

    m_GD20M303DLHCCompassSampleRate = LSM303DLHC_COMPASS_SAMPLERATE_30;
    m_GD20M303DLHCCompassFsr = LSM303DLHC_COMPASS_FSR_1_3;

    //  LSM9DS0 defaults

    m_LSM9DS0GyroSampleRate = LSM9DS0_GYRO_SAMPLERATE_95;
    m_LSM9DS0GyroBW = LSM9DS0_GYRO_BANDWIDTH_1;
    m_LSM9DS0GyroHpf = LSM9DS0_GYRO_HPF_4;
    m_LSM9DS0GyroFsr = LSM9DS0_GYRO_FSR_500;

    m_LSM9DS0AccelSampleRate = LSM9DS0_ACCEL_SAMPLERATE_50;
    m_LSM9DS0AccelFsr = LSM9DS0_ACCEL_FSR_8;
    m_LSM9DS0AccelLpf = LSM9DS0_ACCEL_LPF_50;

    m_LSM9DS0CompassSampleRate = LSM9DS0_COMPASS_SAMPLERATE_50;
    m_LSM9DS0CompassFsr = LSM9DS0_COMPASS_FSR_2;

    //  check to see if settings file exists

    if (!(m_fd = fopen(m_filename, "r"))) {
        HAL_INFO("Settings file not found. Using defaults and creating settings file\n");
        return saveSettings();
    }

    while (fgets(buf, 200, m_fd)) {
        if ((buf[0] == '#') || (buf[0] == ' ') || (buf[0] == '\n'))
            // just a comment
            continue;

        if (sscanf(buf, "%[^=]=%s", key, val) != 2) {
            HAL_ERROR1("Bad line in settings file: %s\n", buf);
            fclose(m_fd);
            return false;
        }

        //  now decode keys

        //  general config

        if (strcmp(key, RTIMULIB_IMU_TYPE) == 0) {
            m_imuType = atoi(val);
        } else if (strcmp(key, RTIMULIB_FUSION_TYPE) == 0) {
            m_fusionType = atoi(val);
        } else if (strcmp(key, RTIMULIB_I2C_BUS) == 0) {
            m_I2CBus = atoi(val);
        } else if (strcmp(key, RTIMULIB_I2C_SLAVEADDRESS) == 0) {
            m_I2CSlaveAddress = atoi(val);

        // compass calibration

        } else if (strcmp(key, RTIMULIB_COMPASSCAL_VALID) == 0) {
            m_compassCalValid = strcmp(val, "true") == 0;
        } else if (strcmp(key, RTIMULIB_COMPASSCAL_MINX) == 0) {
            sscanf(val, "%f", &ftemp);
            m_compassCalMin.setX(ftemp);
        } else if (strcmp(key, RTIMULIB_COMPASSCAL_MINY) == 0) {
            sscanf(val, "%f", &ftemp);
            m_compassCalMin.setY(ftemp);
        } else if (strcmp(key, RTIMULIB_COMPASSCAL_MINZ) == 0) {
            sscanf(val, "%f", &ftemp);
            m_compassCalMin.setZ(ftemp);
        } else if (strcmp(key, RTIMULIB_COMPASSCAL_MAXX) == 0) {
            sscanf(val, "%f", &ftemp);
            m_compassCalMax.setX(ftemp);
        } else if (strcmp(key, RTIMULIB_COMPASSCAL_MAXY) == 0) {
            sscanf(val, "%f", &ftemp);
            m_compassCalMax.setY(ftemp);
        } else if (strcmp(key, RTIMULIB_COMPASSCAL_MAXZ) == 0) {
            sscanf(val, "%f", &ftemp);
            m_compassCalMax.setZ(ftemp);

        //  MPU9150 settings

        } else if (strcmp(key, RTIMULIB_MPU9150_GYROACCEL_SAMPLERATE) == 0) {
            m_MPU9150GyroAccelSampleRate = atoi(val);
        } else if (strcmp(key, RTIMULIB_MPU9150_COMPASS_SAMPLERATE) == 0) {
            m_MPU9150CompassSampleRate = atoi(val);
        } else if (strcmp(key, RTIMULIB_MPU9150_GYROACCEL_LPF) == 0) {
            m_MPU9150GyroAccelLpf = atoi(val);
        } else if (strcmp(key, RTIMULIB_MPU9150_GYRO_FSR) == 0) {
            m_MPU9150GyroFsr = atoi(val);
        } else if (strcmp(key, RTIMULIB_MPU9150_ACCEL_FSR) == 0) {
            m_MPU9150AccelFsr = atoi(val);

        //  GD20HM303D settings

        } else if (strcmp(key, RTIMULIB_GD20HM303D_GYRO_SAMPLERATE) == 0) {
            m_GD20HM303DGyroSampleRate = atoi(val);
        } else if (strcmp(key, RTIMULIB_GD20HM303D_GYRO_FSR) == 0) {
            m_GD20HM303DGyroFsr = atoi(val);
        } else if (strcmp(key, RTIMULIB_GD20HM303D_GYRO_HPF) == 0) {
            m_GD20HM303DGyroHpf = atoi(val);
        } else if (strcmp(key, RTIMULIB_GD20HM303D_GYRO_BW) == 0) {
            m_GD20HM303DGyroBW = atoi(val);
        } else if (strcmp(key, RTIMULIB_GD20HM303D_ACCEL_SAMPLERATE) == 0) {
            m_GD20HM303DAccelSampleRate = atoi(val);
        } else if (strcmp(key, RTIMULIB_GD20HM303D_ACCEL_FSR) == 0) {
            m_GD20HM303DAccelFsr = atoi(val);
        } else if (strcmp(key, RTIMULIB_GD20HM303D_ACCEL_LPF) == 0) {
            m_GD20HM303DAccelLpf = atoi(val);
        } else if (strcmp(key, RTIMULIB_GD20HM303D_COMPASS_SAMPLERATE) == 0) {
            m_GD20HM303DCompassSampleRate = atoi(val);
        } else if (strcmp(key, RTIMULIB_GD20HM303D_COMPASS_FSR) == 0) {
            m_GD20HM303DCompassFsr = atoi(val);

        //  GD20M303DLHC settings

        } else if (strcmp(key, RTIMULIB_GD20M303DLHC_GYRO_SAMPLERATE) == 0) {
            m_GD20M303DLHCGyroSampleRate = atoi(val);
        } else if (strcmp(key, RTIMULIB_GD20M303DLHC_GYRO_FSR) == 0) {
            m_GD20M303DLHCGyroFsr = atoi(val);
        } else if (strcmp(key, RTIMULIB_GD20M303DLHC_GYRO_HPF) == 0) {
            m_GD20M303DLHCGyroHpf = atoi(val);
        } else if (strcmp(key, RTIMULIB_GD20M303DLHC_GYRO_BW) == 0) {
            m_GD20M303DLHCGyroBW = atoi(val);
        } else if (strcmp(key, RTIMULIB_GD20M303DLHC_ACCEL_SAMPLERATE) == 0) {
            m_GD20M303DLHCAccelSampleRate = atoi(val);
        } else if (strcmp(key, RTIMULIB_GD20M303DLHC_ACCEL_FSR) == 0) {
            m_GD20M303DLHCAccelFsr = atoi(val);
        } else if (strcmp(key, RTIMULIB_GD20M303DLHC_COMPASS_SAMPLERATE) == 0) {
            m_GD20M303DLHCCompassSampleRate = atoi(val);
        } else if (strcmp(key, RTIMULIB_GD20M303DLHC_COMPASS_FSR) == 0) {
            m_GD20M303DLHCCompassFsr = atoi(val);

        //  LSM9DS0 settings

        } else if (strcmp(key, RTIMULIB_LSM9DS0_GYRO_SAMPLERATE) == 0) {
            m_LSM9DS0GyroSampleRate = atoi(val);
        } else if (strcmp(key, RTIMULIB_LSM9DS0_GYRO_FSR) == 0) {
            m_LSM9DS0GyroFsr = atoi(val);
        } else if (strcmp(key, RTIMULIB_LSM9DS0_GYRO_HPF) == 0) {
            m_LSM9DS0GyroHpf = atoi(val);
        } else if (strcmp(key, RTIMULIB_LSM9DS0_GYRO_BW) == 0) {
            m_LSM9DS0GyroBW = atoi(val);
        } else if (strcmp(key, RTIMULIB_LSM9DS0_ACCEL_SAMPLERATE) == 0) {
            m_LSM9DS0AccelSampleRate = atoi(val);
        } else if (strcmp(key, RTIMULIB_LSM9DS0_ACCEL_FSR) == 0) {
            m_LSM9DS0AccelFsr = atoi(val);
        } else if (strcmp(key, RTIMULIB_LSM9DS0_ACCEL_LPF) == 0) {
            m_LSM9DS0AccelLpf = atoi(val);
        } else if (strcmp(key, RTIMULIB_LSM9DS0_COMPASS_SAMPLERATE) == 0) {
            m_LSM9DS0CompassSampleRate = atoi(val);
        } else if (strcmp(key, RTIMULIB_LSM9DS0_COMPASS_FSR) == 0) {
            m_LSM9DS0CompassFsr = atoi(val);

        //  Handle unrecognized key

        } else {
            HAL_ERROR1("Unrecognized key in settings file: %s\n", buf);
        }
    }
    HAL_INFO1("Settings file %s loaded\n", m_filename);
    fclose(m_fd);
    return saveSettings();                                  // make sure settings file is correct and complete
}
Example #17
0
void ScanDialog::slotDialogFinished()
{
    d->saneWidget->closeDevice();
    saveSettings();
}
Example #18
0
RazorPanel::~RazorPanel()
{
    mLayout->setEnabled(false);
    saveSettings();
    qDeleteAll(mPlugins);
}
Example #19
0
CSV::~CSV ()
{
  saveSettings();
}
Example #20
0
VideoPreview::~VideoPreview() {
	if (set) saveSettings();
}
Example #21
0
void Application::addItemFavorite(QString ioid, int type)
{
    favModel->addFavorite(ioid, type);

    saveSettings();
}
Example #22
0
void MainWindow::commitAppData(QSessionManager &manager)
{
	saveSettings();
}
Example #23
0
void Application::moveFavorite(int idx, int newidx)
{
    favModel->moveFavorite(idx, newidx);

    saveSettings();
}
Example #24
0
void settingswindow::on_btnSave_released()
{
    int savedLanguage = settings.value("Language", 0).toInt();
    int savedDownLimit = settings.value("libtorrent/download_rate_limit", 0).toInt();
    int savedUpLimit = settings.value("libtorrent/upload_rate_limit", 0).toInt();
    bool webEnabled = settings.value("WebInterfaceOn", true).toBool();

    uint savedPort = settings.value("libtorrent/port", 0).toUInt();

    bool needRestart = (ui->cmbLanguage->currentIndex() != savedLanguage);
    bool needRefreshTorrentSettings = ( (ui->numLimitDown->value() != savedDownLimit) ||
                                        (ui->numLimitUp->value() != savedUpLimit) ||
                                        (ui->chkActivateWeb->isChecked() != webEnabled) ||
                                        (static_cast<uint>(ui->numPort->value()) != savedPort));

    saveSettings();

    // send message settings saved to user
    emit sendMessageToStatusBar(QString("Settings saved"));
    qInfo("Settings saved");

    if (needRestart) {
        qDebug("need restart");
        QMessageBox mbox;
//        QString msg = QString("<center>Please restart Tsunami to apply new settings<br/>Do you want to restart now?</center>");
        QString msg = QString("<center>Please restart Tsunami to apply new settings<br/></center>");
        mbox.setText(msg);
        mbox.exec();
//        mbox.setStandardButtons( QMessageBox::Yes | QMessageBox::No );

//        bool proceedWithRestart = false;

//        switch (mbox.exec()) {
//            case QMessageBox::Yes:
//                proceedWithRestart = true;
//                break;
//            default:
//                proceedWithRestart = false;
//                break;
//        }
//        if (proceedWithRestart) {
//            qDebug("restarting");

//            // due to squirrel standard behaviour, qApp->arguments()[0] returs path to a tsunami version older than one just downloaded
//            // retrieve path of tsunami.exe loader outside current path and launch
//            QString fileName = QFileInfo(QCoreApplication::applicationFilePath()).fileName();
//            QDir oldPath(QCoreApplication::applicationDirPath());
//            oldPath.cdUp();
//            QString newPath = oldPath.filePath(fileName);

//            qApp->quit();
//            QProcess::startDetached(newPath, qApp->arguments());
//        } else {
//            if (needRefreshTorrentSettings) {
//                qDebug("send refresh to libtorrent");
//                emit sendRefreshSettings();
//            }
//        }
    } else {
        qDebug("don't need restart");
//        if (needRefreshTorrentSettings) {
//            qDebug("send refresh to libtorrent");
//            emit sendRefreshSettings();
//        }
    }

    if (needRefreshTorrentSettings) {
        qDebug("send refresh to libtorrent");
        emit sendRefreshSettings();
    }

}
Example #25
0
void ccVolumeCalcTool::saveSettingsAndAccept()
{
	saveSettings();
	accept();
}
Example #26
0
void QgsColorDialogV2::on_mButtonBox_accepted()
{
  saveSettings();
  accept();
}
Example #27
0
void DlgPrefModplug::slotApply() {
    applySettings();
    saveSettings();
}
Example #28
0
void QgsColorDialogV2::on_mButtonBox_rejected()
{
  saveSettings();
  reject();
}
EventVideoDownloadsWindow::~EventVideoDownloadsWindow()
{
    saveSettings();
}
error_t httpServerProcessSetConfig(HttpConnection *connection)
{
   error_t error;
   uint_t i;
   size_t n;
   char_t *p;
   char_t *buffer;
   char_t *separator;
   char_t *property;
   char_t *value;
   Settings *newSettings;

   //Point to the scratch buffer
   buffer = connection->buffer;

   //Allocate a memory buffer to hold the new configuration
   newSettings = osAllocMem(sizeof(Settings));
   //Failed to allocate memory?
   if(!newSettings) return ERROR_OUT_OF_MEMORY;

   //Start of exception handling block
   do
   {
      //Retrieve default settings
      error = getDefaultSettings(newSettings);
      //Any error to report?
      if(error) break;

      //Process HTTP request body
      while(1)
      {
         //Read the HTTP request body until an ampersand is encountered
         error = httpReadStream(connection, buffer,
            HTTP_SERVER_BUFFER_SIZE - 1, &n, HTTP_FLAG_BREAK('&'));
         //End of stream detected?
         if(error) break;

         //Properly terminate the string with a NULL character
         buffer[n] = '\0';

         //Remove the trailing ampersand
         if(n > 0 && buffer[n - 1] == '&')
            buffer[--n] = '\0';

         //Decode the percent-encoded string
         error = httpDecodePercentEncodedString(buffer, buffer, HTTP_SERVER_BUFFER_SIZE);
         //Any error detected?
         if(error) break;

         //Check whether a separator is present
         separator = strchr(buffer, '=');

         //Separator found?
         if(separator)
         {
            //Split the line
            *separator = '\0';
            //Get property name and value
            property = strTrimWhitespace(buffer);
            value = strTrimWhitespace(separator + 1);

            //Debug message
            TRACE_DEBUG("[%s]=%s\r\n", property, value);

            //Icecast settings
            if(!strcasecmp(property, "icecastSettingsUrl"))
            {
               //Check resource length
               if(strlen(value) >= sizeof(newSettings->icecast.url))
               {
                  //Report an error
                  error = ERROR_INVALID_SYNTAX;
                  break;
               }

               //Save resource
               strcpy(newSettings->icecast.url, value);
            }
            else if(!strcasecmp(property, "icecastSettingsPort"))
            {
               //Save Icecast server port
               newSettings->icecast.port = strtoul(value, &p, 10);

               //Invalid port number?
               if(*p != '\0')
               {
                  //Report an error
                  error = ERROR_INVALID_SYNTAX;
                  break;
               }
            }
            //LAN settings
            else if(!strcasecmp(property, "lanSettingsMacAddr"))
            {
               //Save MAC address
               error = macStringToAddr(value, &newSettings->lan.macAddr);
               //Invalid address?
               if(error) break;
            }
            else if(!strcasecmp(property, "lanSettingsHostName"))
            {
               //Check the length of the host name
               if(strlen(value) >= sizeof(newSettings->lan.hostname))
               {
                  //Report an error
                  error = ERROR_INVALID_SYNTAX;
                  break;
               }

               //Save host name
               strcpy(newSettings->lan.hostname, value);
            }
            else if(!strcasecmp(property, "lanSettingsEnableDhcp"))
            {
               //Check flag value
               if(!strcasecmp(value, "off"))
               {
                  //DHCP client is disabled
                  newSettings->lan.enableDhcp = FALSE;
               }
               else if(!strcasecmp(value, "on"))
               {
                  //DHCP client is enabled
                  newSettings->lan.enableDhcp = TRUE;
               }
               else
               {
                  //Invalid value
                  error = ERROR_INVALID_SYNTAX;
                  break;
               }
            }
            else if(!strcasecmp(property, "lanSettingsHostAddr"))
            {
               //Save IPv4 host address
               error = ipv4StringToAddr(value, &newSettings->lan.hostAddr);
               //Invalid address?
               if(error) break;
            }
            else if(!strcasecmp(property, "lanSettingsSubnetMask"))
            {
               //Save subnet mask
               error = ipv4StringToAddr(value, &newSettings->lan.subnetMask);
               //Invalid mask?
               if(error) break;
            }
            else if(!strcasecmp(property, "lanSettingsDefaultGateway"))
            {
               //Save default gateway
               error = ipv4StringToAddr(value, &newSettings->lan.defaultGateway);
               //Invalid address?
               if(error) break;
            }
            else if(!strcasecmp(property, "lanSettingsPrimaryDns"))
            {
               //Save primary DNS
               error = ipv4StringToAddr(value, &newSettings->lan.primaryDns);
               //Invalid address?
               if(error) break;
            }
            else if(!strcasecmp(property, "lanSettingsSecondaryDns"))
            {
               //Save secondary DNS
               error = ipv4StringToAddr(value, &newSettings->lan.secondaryDns);
               //Invalid address?
               if(error) break;
            }
            //Proxy settings
            else if(!strcasecmp(property, "proxySettingsEnable"))
            {
               //Check flag value
               if(!strcasecmp(value, "off"))
               {
                  //Proxy server is disabled
                  newSettings->proxy.enable = FALSE;
               }
               else if(!strcasecmp(value, "on"))
               {
                  //Proxy server is enabled
                  newSettings->proxy.enable = TRUE;
               }
               else
               {
                  //Invalid value
                  error = ERROR_INVALID_SYNTAX;
                  break;
               }
            }
            else if(!strcasecmp(property, "proxySettingsName"))
            {
               //Check the length of proxy server name
               if(strlen(value) >= sizeof(newSettings->proxy.name))
               {
                  //Report an error
                  error = ERROR_INVALID_SYNTAX;
                  break;
               }

               //Save proxy server name
               strcpy(newSettings->proxy.name, value);
            }
            else if(!strcasecmp(property, "proxySettingsPort"))
            {
               //Save proxy server port
               newSettings->proxy.port = strtoul(value, &p, 10);

               //Invalid port number?
               if(*p != '\0')
               {
                  //Report an error
                  error = ERROR_INVALID_SYNTAX;
                  break;
               }
            }
         }
      }

      //Check status code
      if(error == NO_ERROR || error == ERROR_END_OF_STREAM)
      {
         //Commit changes
         appSettings = *newSettings;
         //Write settings to non-volatile memory
         error = saveSettings(newSettings);
      }
      else if(error != ERROR_INVALID_SYNTAX)
      {
         //Propagate exception
         break;
      }

      //Point to the scratch buffer
      buffer = connection->buffer + 384;
      //Format XML data
      n = sprintf(buffer, "<data>\r\n  <status>");

      if(error == ERROR_INVALID_SYNTAX)
         n += sprintf(buffer + n, "Invalid configuration!\r\n");
      else if(error != NO_ERROR)
         n += sprintf(buffer + n, "Failed to save settings to non-volatile memory!\r\n");
      else
         n += sprintf(buffer + n, "Settings successfully saved. Please reboot the board.\r\n");

      //Terminate XML data
      n += sprintf(buffer + n, "</status>\r\n</data>\r\n");

      //Format HTTP response header
      connection->response.version = connection->request.version;
      connection->response.statusCode = 200;
      connection->response.keepAlive = connection->request.keepAlive;
      connection->response.noCache = TRUE;
      connection->response.contentType = mimeGetType(".xml");
      connection->response.chunkedEncoding = FALSE;
      connection->response.contentLength = n;

      //Send the header to the client
      error = httpWriteHeader(connection);
      //Any error to report?
      if(error) break;

      //Send response body
      error = httpWriteStream(connection, buffer, n);
      //Any error to report?
      if(error) break;

      //Properly close output stream
      error = httpCloseStream(connection);
      //Any error to report?
      if(error) break;

      //End of exception handling block
   } while(0);

   //Free previously allocated memory
   osFreeMem(newSettings);
   //Return status code
   return error;
}