Esempio n. 1
0
TasksWindow::TasksWindow( QWidget* parent )
    : CharmWindow( tr( "Tasks Editor" ), parent )
    , m_tasksView( new TasksView( toolBar(), this ) )
{
    setWindowNumber( 1 );
    setWindowIdentifier( QLatin1String( "window_tasks" ) );
    setCentralWidget( m_tasksView );
    setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
    connect( m_tasksView, SIGNAL(emitCommand(CharmCommand*)),
             SIGNAL(emitCommand(CharmCommand*)) );
    connect( m_tasksView, SIGNAL(emitCommandRollback(CharmCommand*)),
             SIGNAL(emitCommandRollback(CharmCommand*)) );
    connect( m_tasksView, SIGNAL(saveConfiguration()),
             SIGNAL(saveConfiguration()) );
}
Esempio n. 2
0
// Handles HTTP GET & POST /config.html requests
void HandleConfig()
{
	// Warning: uses global data
	ControllerData *gd = &GD;

	// NETWORK_UPDATE
	if (gd->switchServer->hasArg("NETWORK_UPDATE"))
	{
		gd->switchServer->arg("SSID").toCharArray(config.ssid, SSID_LEN);
		gd->switchServer->arg("PASS").toCharArray(config.secret, SECRET_LEN);
		gd->switchServer->arg("MDNS").toCharArray(config.MDNSHost, MDNS_HOST_LEN);

		saveConfiguration(&config, sizeof(ConfigurationData));

		// redirect to the same page without arguments
		gd->switchServer->sendHeader("Location", String("/config"), true);
		gd->switchServer->send(302, TEXT_PLAIN, "");

		// Try connecting with new credentials
		WiFi.disconnect();
		WiFiManager::handleWiFiConnectivity();
	}

	// Reboot
	if (gd->switchServer->hasArg("REBOOT"))
	{
		gd->switchServer->send(200, TEXT_PLAIN, "Restarting...");
		ESP.restart();
	}

	// GENERAL_UPDATE
	if (gd->switchServer->hasArg("GENERAL_UPDATE"))
	{
		gd->switchServer->arg("OTA_URL").toCharArray(config.OTA_URL, OTA_URL_LEN);
		saveConfiguration(&config, sizeof(ConfigurationData));
	}

	// CHECK_UPDATE_NOW
	if (gd->switchServer->hasArg("CHECK_UPDATE_NOW"))
	{
		Serial.println("Checking software updates available.");
		checkSoftwareUpdates();
	}

	ESPTemplateProcessor(*gd->switchServer).send(
		String("/config.html"),
		mapConfigParameters);
}
Esempio n. 3
0
void Core::requestFriendship(const QString& friendAddress, const QString& message)
{
    qDebug() << "Core: requesting friendship of "+friendAddress;
    CString cMessage(message);

    int friendId = tox_add_friend(tox, CFriendAddress(friendAddress).data(), cMessage.data(), cMessage.size());
    const QString userId = friendAddress.mid(0, TOX_CLIENT_ID_SIZE * 2);
    if (friendId < 0) {
        emit failedToAddFriend(userId);
    } else {
        // Update our friendAddresses
        bool found=false;
        QList<QString>& friendAddresses = Settings::getInstance().friendAddresses;
        for (QString& addr : friendAddresses)
        {
            if (addr.toUpper().contains(friendAddress))
            {
                addr = friendAddress;
                found = true;
            }
        }
        if (!found)
            friendAddresses.append(friendAddress);
        emit friendAdded(friendId, userId);
    }
    saveConfiguration();
}
Esempio n. 4
0
void Core::saveConfiguration()
{
    if (QThread::currentThread() != coreThread)
        return (void) QMetaObject::invokeMethod(this, "saveConfiguration");

    if (!isReady())
        return;

    ProfileLocker::assertLock();

    QString dir = Settings::getSettingsDirPath();
    QDir directory(dir);
    if (!directory.exists() && !directory.mkpath(directory.absolutePath()))
    {
        qCritical() << "Error while creating directory " << dir;
        return;
    }

    QString profile = Settings::getInstance().getCurrentProfile();

    if (profile == "")
    { // no profile active; this should only happen on startup, if at all
        profile = sanitize(getUsername());

        if (profile == "") // happens on creation of a new Tox ID
            profile = getIDString();

        Settings::getInstance().switchProfile(profile);
    }

    QString path = directory.filePath(profile + TOX_EXT);

    saveConfiguration(path);
}
Esempio n. 5
0
WengoPhone::~WengoPhone() {
    //Deleting created objects
    OWSAFE_DELETE(_userProfileHandler);
    OWSAFE_DELETE(_dtmfThemeManager);
    ////
    saveConfiguration();
}
Esempio n. 6
0
void Core::setStatus(Status status)
{
    TOX_USERSTATUS userstatus;
    switch (status) {
        case Status::Online:
            userstatus = TOX_USERSTATUS_NONE;
            break;
        case Status::Away:
            userstatus = TOX_USERSTATUS_AWAY;
            break;
        case Status::Busy:
            userstatus = TOX_USERSTATUS_BUSY;
            break;
        default:
            userstatus = TOX_USERSTATUS_INVALID;
            break;
    }

    if (tox_set_user_status(tox, userstatus) == 0) {
        saveConfiguration();
        emit statusSet(status);
    } else {
        emit failedToSetStatus(status);
    }
}
Esempio n. 7
0
void CanIO::loadConfiguration()
{
    CanIOConfiguration *config = (CanIOConfiguration *) getConfiguration();

    if (!config) { // as lowest sub-class make sure we have a config object
        config = new CanIOConfiguration();
        setConfiguration(config);
    }

    Device::loadConfiguration(); // call parent
    Logger::info(this, "CAN I/O configuration:");

#ifdef USE_HARD_CODED
    if (false) {
#else
    if (prefsHandler->checksumValid()) { //checksum is good, read in the values stored in EEPROM
#endif
//        prefsHandler->read(EESYS_, &config->);
    } else {
//        config-> = 0;
        saveConfiguration();
    }
//    Logger::info(getId(), "xyz: %d", config->);
}

void CanIO::saveConfiguration()
{
//    prefsHandler->write(EESYS_, config->);
    prefsHandler->saveChecksum();
}
Esempio n. 8
0
void TelescopeControl::deinit()
{
	//Destroy all clients first in order to avoid displaying a TCP error
	deleteAllTelescopes();

	QHash<int, QProcess*>::const_iterator iterator = telescopeServerProcess.constBegin();
	while(iterator != telescopeServerProcess.constEnd())
	{
		int slotNumber = iterator.key();
#ifdef Q_OS_WIN
		telescopeServerProcess[slotNumber]->close();
#else
		telescopeServerProcess[slotNumber]->terminate();
#endif
		telescopeServerProcess[slotNumber]->waitForFinished();
		delete telescopeServerProcess[slotNumber];
		qDebug() << "[TelescopeControl] deinit(): Server process at slot" << slotNumber << "terminated successfully.";

		++iterator;
	}

	//TODO: Decide if it should be saved on change
	//Save the configuration on exit
	saveConfiguration();
}
Esempio n. 9
0
bool ScopeSync::saveConfigurationAs()
{
    File configurationFileDirectory = getConfigurationDirectory();
    
    FileChooser fileChooser("Save Configuration File As...",
                            configurationFileDirectory,
                            "*.configuration");
    
    if (fileChooser.browseForFileToSave(true))
    {
        String fileName = fileChooser.getResult().getFullPathName();

        if (File::isAbsolutePath(fileName))
        {
            configuration->setLastFailedFile(configuration->getFile());
            configuration->setFile(File(fileName));
            getConfigurationRoot().setProperty(Ids::ID, createAlphaNumericUID(), nullptr);
            saveConfiguration();
        }

        applyConfiguration();

        UserSettings::getInstance()->addActionListener(this);
        UserSettings::getInstance()->rebuildFileLibrary(true, false, false);

        return true;
    }
    else
        return false;
}
Esempio n. 10
0
void Input::loadConfiguration()
{
	Gorgon::Core::Log::get().writeFormatted("C++ -> Input::loadConfiguration()\n");
	std::fstream* file;
	file = new std::fstream("data/input.cfg",std::ios::in|std::ios::binary);

	if(!file->is_open())
	{
		Gorgon::Core::Log::get().writeFormatted("C++ -> Input::loadConfiguration(): data/input.cfg ... Error\n");
		createDefaultConfiguration();
		saveConfiguration();
	}
	else
	{
		file->read( (char*)&mKey_start		, sizeof(int) );
		file->read( (char*)&mKey_up			, sizeof(int) );
		file->read( (char*)&mKey_down		, sizeof(int) );
		file->read( (char*)&mKey_left		, sizeof(int) );
		file->read( (char*)&mKey_right		, sizeof(int) );
		file->read( (char*)&mKey_button1	, sizeof(int) );
		file->read( (char*)&mKey_button2	, sizeof(int) );
		file->read( (char*)&mKey_button3	, sizeof(int) );
		file->read( (char*)&mKey_button4	, sizeof(int) );
		file->read( (char*)&mKey_button5	, sizeof(int) );
		file->read( (char*)&mKey_button6	, sizeof(int) );
		file->read( (char*)&mKey_button7	, sizeof(int) );
		file->read( (char*)&mKey_button8	, sizeof(int) );
		Gorgon::Core::Log::get().writeFormatted("C++ -> Input::loadConfiguration(): data/input.cfg ... Done\n");
	}
	file->close();
	delete file;
}
Esempio n. 11
0
  bool CConfiguration::setSensorValue(const int8_t idSensor, T (CSensorConfiguration::*getter)() const,
                      void (CSensorConfiguration::*setter)(const T), const T& newValue)
  {
    std::vector<DSensorConfiguration>::iterator it = std::find_if(
                                                       sensors.begin(), sensors.end(),
                                                       [&](DSensorConfiguration& s){return s->getSensorId() == idSensor;});
    if (it == sensors.end())
    {
      // nie znaleziono czujnika
      return false;
    }
    std::shared_ptr<CSensorConfiguration> s = std::dynamic_pointer_cast<CSensorConfiguration>(*it);
    T currentValue = (*s.*getter)();
    mutex.lock();
    T oldValue = currentValue;
    (*s.*setter)(newValue);

    bool result = saveConfiguration();
    if (!result)
    {
      // nie udal sie zapis - przywroc stare wartosci
      (*s.*setter)(oldValue);
    }
    else
    {
      readConfiguration();
    }
    mutex.unlock();
    return result;
  }
Esempio n. 12
0
Core::~Core()
{
    if (tox) {
        saveConfiguration();
        tox_kill(tox);
    }
}
Esempio n. 13
0
void KviTalApplication::commitData(QSessionManager & manager)
{
	saveConfiguration();
#if defined(COMPILE_KDE4_SUPPORT)
	KApplication::commitData(manager);
#endif //defined(COMPILE_KDE4_SUPPORT)
}
  CConfigurationMock::CConfigurationMock()
  {
    LOG_DEBUG("CConfigurationMock - constructor.");
    idConcentrator = 1;
    sendingPeriod = 8;
    checkingSensorPeriod = 4;
    saveSDCardIfOnlineEnable = false;
    dataPath = ".";

    int warningValue = 25;
    int alarmValue = 35;
    CData warning(EValueType::INT_32, &warningValue);

    CData alarm(EValueType::INT_32, &alarmValue);

    std::string sensorAddr = "127.0.0.1";
    int port = 1502;

    for (int8_t i = 0; i < 2; ++i)
    {

      uint8_t idSensor1 = i;
      bool turnOn = true;

      DSensorConfiguration s(
                  new CSensorConfigurationMock(idSensor1, turnOn, warning, alarm, sensorAddr, port));
      this->sensors.push_back(s);
      port = port + 1;

    }
    serverUrl = "http://localhost:8080/HallMonitorServer/rest/concentrator/post";
    saveConfiguration();
  }
Esempio n. 15
0
ExportNative::~ExportNative(void)
{
    saveConfiguration();

    while (!m_archiveList.isEmpty())
         delete m_archiveList.takeFirst();
    m_archiveList.clear();
}
Esempio n. 16
0
  void Cursynth::processMidi(std::vector<unsigned char>* message) {
    if (message->size() < 3)
      return;

    lock();
    int midi_port = message->at(0);
    int midi_id = message->at(1);
    int midi_val = message->at(2);
    std::string selected_control_name = gui_.getCurrentControl();
    Control* selected_control = controls_.at(selected_control_name);
    if (midi_port >= 144 && midi_port < 160) {
      // A MIDI keyboard key was pressed. Play a note.
      int midi_note = midi_id;
      int midi_velocity = midi_val;

      if (midi_velocity)
        synth_.noteOn(midi_note, (1.0 * midi_velocity) / MIDI_SIZE);
      else
        synth_.noteOff(midi_note);
    }
    else if (midi_port >= 128 && midi_port < 144) {
      // A MIDI keyboard key was released. Release that note.
      int midi_note = midi_id;
      synth_.noteOff(midi_note);
    }
    else if (midi_port == PITCH_BEND_PORT)
      synth_.setPitchWheel((2.0 * midi_val) / (MIDI_SIZE - 1) - 1);
    else if (midi_port == SUSTAIN_PORT && midi_id == SUSTAIN_ID) {
      if (midi_val)
        synth_.sustainOn();
      else
        synth_.sustainOff();
    }
    else if (midi_port < 254) {
      // Must have gotten MIDI from some knob or other control.
      if (state_ == MIDI_LEARN && midi_port < 254) {
        // MIDI learn is armed so map this MIDI signal to the current control.
        eraseMidiLearn(selected_control);

        midi_learn_[midi_id] = selected_control_name;
        selected_control->midi_learn(midi_id);
        state_ = STANDARD;
        gui_.drawControlStatus(selected_control, false);
        saveConfiguration();
      }
      else if (midi_learn_.find(midi_id) != midi_learn_.end()) {
        // MIDI learn is enabled for this control. Change the paired control.
        Control* midi_control = controls_.at(midi_learn_[midi_id]);
        midi_control->setMidi(midi_val);
        gui_.drawControl(midi_control, selected_control == midi_control);
        gui_.drawControlStatus(midi_control, false);
      }

      if (midi_id == MOD_WHEEL_ID)
        synth_.setModWheel(midi_val);
    }
    unlock();
  }
Esempio n. 17
0
void Core::removeFriend(int friendId)
{
    if (tox_del_friend(tox, friendId) == -1) {
        emit failedToRemoveFriend(friendId);
    } else {
        saveConfiguration();
        emit friendRemoved(friendId);
    }
}
Esempio n. 18
0
void NavStars::restoreDefaultConfiguration(void)
{
	// Remove the whole section from the configuration file
	conf->remove("NavigationalStars");
	// Load the default values...
	loadConfiguration();
	// ... then save them.
	saveConfiguration();
}
QDomElement QgsAttributeEditorElement::toDomElement( QDomDocument& doc ) const
{
  QDomElement elem = doc.createElement( typeIdentifier() );
  elem.setAttribute( "name", mName );
  elem.setAttribute( "showLabel", mShowLabel );

  saveConfiguration( elem );
  return elem;
}
MainObject::MainObject(QObject *parent)
  : QObject(parent)
{
  host_player_process=NULL;
  host_formatter_process=NULL;
  WHCmdSwitch *cmd=
    new WHCmdSwitch(qApp->argc(),qApp->argv(),"glassplayerhost",VERSION,
		    GLASSPLAYERHOST_USAGE);
  for(unsigned i=0;i<(cmd->keys());i++) {
    if(!cmd->processed(i)) {
      fprintf(stderr,"glassplayerhost: unknown option\n");
      exit(256);
    }
  }

  //
  // Configuration
  //
  host_config=new Config();
  host_config->load();

  //
  // UDP Interface
  //
  host_udp_control=new UdpControl(this);
  connect(host_udp_control,SIGNAL(changeStreamUrl(const QString &)),
	  this,SLOT(changeStreamUrlData(const QString &)));
  connect(host_udp_control,SIGNAL(changeReceiverName(const QString &)),
	  this,SLOT(changeReceiverNameData(const QString &)));
  connect(host_udp_control,SIGNAL(saveConfiguration()),
	  this,SLOT(saveConfigurationData()));

  //
  // Timer
  //
  host_restart_timer=new QTimer(this);
  host_restart_timer->setSingleShot(true);
  connect(host_restart_timer,SIGNAL(timeout()),this,SLOT(restartData()));

  host_exit_timer=new QTimer(this);
  connect(host_exit_timer,SIGNAL(timeout()),this,SLOT(exitData()));

  host_watchdog_timer=new QTimer(this);
  host_watchdog_timer->setSingleShot(true);
  connect(host_watchdog_timer,SIGNAL(timeout()),this,SLOT(watchdogData()));

  //
  // Configure Signals
  //
  ::signal(SIGHUP,SigHandler);
  ::signal(SIGINT,SigHandler);
  ::signal(SIGTERM,SigHandler);

  host_restart_timer->start(0);
  host_exit_timer->start(1000);
}
Esempio n. 21
0
void Core::acceptFriendRequest(const QString& userId)
{
    int friendId = tox_add_friend_norequest(tox, CUserId(userId).data());
    if (friendId == -1) {
        emit failedToAddFriend(userId);
    } else {
        saveConfiguration();
        emit friendAdded(friendId, userId);
    }
}
Esempio n. 22
0
void TProfanationGame::decreaseVolume()
{
    if (TProfanationGame::gi_volume>0) 
    {
        TProfanationGame::gi_volume-=10;
        if (TProfanationGame::gi_volume<0) TProfanationGame::gi_volume=0;
        setVolume(TProfanationGame::gi_volume);
        saveConfiguration();
    }
}
Esempio n. 23
0
void TProfanationGame::increaseVolume()
{
    if (TProfanationGame::gi_volume<128) 
    {
        TProfanationGame::gi_volume+=10;
        if (TProfanationGame::gi_volume>128) TProfanationGame::gi_volume=128;
        setVolume(TProfanationGame::gi_volume);
        saveConfiguration();
    }
}
Esempio n. 24
0
void Core::setUsername(const QString& username)
{
    CString cUsername(username);

    if (tox_set_name(tox, cUsername.data(), cUsername.size()) == -1) {
        emit failedToSetUsername(username);
    } else {
        saveConfiguration();
        emit usernameSet(username);
    }
}
Esempio n. 25
0
void Core::setStatusMessage(const QString& message)
{
    CString cMessage(message);

    if (tox_set_status_message(tox, cMessage.data(), cMessage.size()) == -1) {
        emit failedToSetStatusMessage(message);
    } else {
        saveConfiguration();
        emit statusMessageSet(message);
    }
}
Esempio n. 26
0
void ELM327Emu::loadConfiguration()
{
    ELM327Configuration *config = (ELM327Configuration *) getConfiguration();

    if (prefsHandler->checksumValid()) { //checksum is good, read in the values stored in EEPROM
        //TODO: implement processing of config params for WIFI
//      prefsHandler->read(EESYS_WIFI0_SSID, &config->ssid);
    } else {
        saveConfiguration();
    }
}
Esempio n. 27
0
/**
* @brief Initializes the device and connects to the network using Activation By Personalization.
* @param devADDR provided by LoRaWAN Network server registration.
* @param appSKey provided by LoRaWAN Network server registration.
* @param nwkSKey provided by LoRaWAN Network server registration.
* @return Returns true if the parameters were valid and able to save settings.
*/
bool RN2483::initABP(const uint8_t devAddr[4], const uint8_t appSKey[16], const uint8_t nwkSKey[16], bool adr)
{
    init();
    if(resetDevice() && setMacParam(STR_DEV_ADDR, devAddr, 4) && setMacParam(STR_APP_SESSION_KEY, appSKey, 16) &&
            setMacParam(STR_NETWORK_SESSION_KEY, nwkSKey, 16) && setMacParam(STR_ADR, BOOL_TO_ONOFF(adr)) &&
            joinABP()) {
        if(saveConfiguration()) {
            return true;
        }
    }
    return false;
}
/*
 * Load configuration data from EEPROM.
 *
 * If not available or the checksum is invalid, default values are chosen.
 */
void BrusaMotorController::loadConfiguration() {
	BrusaMotorControllerConfiguration *config = (BrusaMotorControllerConfiguration *)getConfiguration();

	if(!config) { // as lowest sub-class make sure we have a config object
		config = new BrusaMotorControllerConfiguration();
		setConfiguration(config);
	}

	MotorController::loadConfiguration(); // call parent

#ifdef USE_HARD_CODED
	if (false) {
#else
//	if (prefsHandler->checksumValid()) { //checksum is good, read in the values stored in EEPROM
	if (false) { //TODO: use eeprom, not fixed values
#endif
		Logger::debug(BRUSA_DMC5, (char *)Constants::validChecksum);
//		prefsHandler->read(EEMC_, &config->minimumLevel1);
	} else { //checksum invalid. Reinitialize values and store to EEPROM
		Logger::warn(BRUSA_DMC5, (char *)Constants::invalidChecksum);
		config->maxMechanicalPowerMotor = 50000;
		config->maxMechanicalPowerRegen = 0; //TODO: 50000; don't want regen yet !

		config->dcVoltLimitMotor = 1000;
		config->dcVoltLimitRegen =  0;//TODO: 1000; don't want regen yet !;
		config->dcCurrentLimitMotor = 0;
		config->dcCurrentLimitRegen = 0;
		config->enableOscillationLimiter = false;
		saveConfiguration();
	}
	Logger::debug(BRUSA_DMC5, "Max mech power motor: %d kW, max mech power regen: %d ", config->maxMechanicalPowerMotor, config->maxMechanicalPowerRegen);
	Logger::debug(BRUSA_DMC5, "DC limit motor: %d Volt, DC limit regen: %d Volt", config->dcVoltLimitMotor, config->dcVoltLimitRegen);
	Logger::debug(BRUSA_DMC5, "DC limit motor: %d Amps, DC limit regen: %d Amps", config->dcCurrentLimitMotor, config->dcCurrentLimitRegen);
}

/*
 * Store the current configuration parameters to EEPROM.
 */
void BrusaMotorController::saveConfiguration() {
	BrusaMotorControllerConfiguration *config = (BrusaMotorControllerConfiguration *)getConfiguration();

	MotorController::saveConfiguration(); // call parent

	//TODO: store to eeprom
//	prefsHandler->write(EEMC_, config->maxMechanicalPowerMotor);
//	prefsHandler->write(EEMC_, config->maxMechanicalPowerRegen);
//	prefsHandler->write(EEMC_, config->dcVoltLimitMotor);
//	prefsHandler->write(EEMC_, config->dcVoltLimitRegen);
//	prefsHandler->write(EEMC_, config->dcCurrentLimitMotor);
//	prefsHandler->write(EEMC_, config->dcCurrentLimitRegen);
//	prefsHandler->write(EEMC_, config->enableOscillationLimiter);
	prefsHandler->saveChecksum();
}
Esempio n. 29
0
/**
* @brief Initialise settings and connect to network using Over The Air activation.
* @param devEUI provided by LoRaWAN Network server registration.
* @param appEUI provided by LoRaWAN Network server registration.
* @param appKey provided by LoRaWAN Network server registration.
* @return Returns true if network confirmation and able to save settings.
*/
bool RN2483::initOTAA(const uint8_t devEUI[8], const uint8_t appEUI[8], const uint8_t appKey[16], bool adr)
{
    printf("RN2483: Init OTAA\n");
    init();
    if(resetDevice() && setMacParam(STR_DEV_EUI, devEUI, 8) && setMacParam(STR_APP_EUI, appEUI, 8) &&
            setMacParam(STR_APP_KEY, appKey, 16) && setMacParam(STR_ADR, BOOL_TO_ONOFF(adr)) && joinOTAA()) {
        if(saveConfiguration()) {
            return true;
        }
    }
    return false;
}
Esempio n. 30
0
void PointerCoordinates::restoreDefaultConfiguration(void)
{
	// Remove the whole section from the configuration file
	conf->remove("PointerCoordinates");
	// Load the default values...
	loadConfiguration();
	// ... then save them.
	saveConfiguration();
	// But this doesn't save the color, so...
	conf->beginGroup("PointerCoordinates");
	conf->setValue("text_color", "1,0.5,0");
	conf->endGroup();
}