Пример #1
1
bool dialog_localsettings::load()
{
    string settingsfile = Glib::get_home_dir() + "/.gutorrent";

    Glib::KeyFile kf;

    if(kf.load_from_file(settingsfile, Glib::KEY_FILE_KEEP_COMMENTS | Glib::KEY_FILE_KEEP_TRANSLATIONS) == false) return false;
    eHost->set_text(kf.get_string("gutorrent", "host"));
    eUserName->set_text(kf.get_string("gutorrent", "username"));
    ePassword->set_text(kf.get_string("gutorrent", "password"));
    sUpdateInterval->set_value(kf.get_integer("gutorrent", "update_interval"));
}
RabbitMQService::RabbitMQService (Glib::KeyFile &confFile) : Service (confFile)
{
  sigset_t mask;
  std::string address;
  int port;

  try {
    address = confFile.get_string (RABBITMQ_GROUP, RABBITMQ_SERVER_ADDRESS);
  } catch (const Glib::KeyFileError &err) {
    GST_WARNING ("Setting default address %s to media server",
                 RABBITMQ_SERVER_ADDRESS_DEFAULT);
    address = RABBITMQ_SERVER_ADDRESS_DEFAULT;
  }

  try {
    port = confFile.get_integer (RABBITMQ_GROUP, RABBITMQ_SERVER_PORT);
    check_port (port);
  } catch (const Glib::KeyFileError &err) {
    GST_WARNING ("Setting default port %d to media server",
                 RABBITMQ_SERVER_PORT_DEFAULT);
    port = RABBITMQ_SERVER_PORT_DEFAULT;
  }

  this->address = address;
  this->port = port;

  setConfig (address, port);
  this->confFile.load_from_data (confFile.to_data() );

  sigemptyset (&mask);
  sigaddset (&mask, SIGCHLD);
  signalHandler = std::shared_ptr <SignalHandler> (new SignalHandler (mask,
                  std::bind (&RabbitMQService::childSignal, this, std::placeholders::_1) ) );
}
Пример #3
0
void Settings::load_settings (Glib::RefPtr<Gio::File> file)
{
  Glib::KeyFile cfg;

  set_defaults();

  try {
    if (!cfg.load_from_file (file->get_path())) {
      std::cout << "Failed to load settings from file '" << file->get_path() << "\n";
      return;
    }
  } catch (const Glib::KeyFileError &err) {
    std::cout << "Exception " << err.what() << " loading settings from file '" << file->get_path() << "\n";
    return;
  }

  std::cout << "parsing config from '" << file->get_path() << "\n";

  for (uint i = 0; i < G_N_ELEMENTS (settings); i++) {
    Glib::ustring group, key;

    if (!get_group_and_key (i, group, key))
      continue;

    if (!cfg.has_key (group, key))
      continue;

    // group & string ...
    switch (settings[i].type) {
    case T_BOOL:
      *PTR_BOOL(this, i) = cfg.get_boolean (group, key);
      break;
    case T_INT:
      *PTR_INT(this, i) = cfg.get_integer (group, key);
      break;
    case T_FLOAT:
    case T_COLOUR_MEMBER:
      *PTR_FLOAT(this, i) = cfg.get_double (group, key);
      break;
    case T_STRING:
      *PTR_STRING(this, i) = cfg.get_string (group, key);
      break;
    default:
      std::cerr << "corrupt setting type\n";
      break;
    }
  }

  GCode.m_impl->loadSettings (cfg);

  m_signal_visual_settings_changed.emit();
  m_signal_update_settings_gui.emit();
}
Пример #4
0
void Window::vApplyPerGameConfig()
{
    std::string sRDBFile = PKGDATADIR "/vba-over.ini";
    if (!Glib::file_test(sRDBFile, Glib::FILE_TEST_EXISTS))
        return;

    char csGameID[5];
    csGameID[0] = rom[0xac];
    csGameID[1] = rom[0xad];
    csGameID[2] = rom[0xae];
    csGameID[3] = rom[0xaf];
    csGameID[4] = '\0';

    Glib::KeyFile oKeyFile;
    oKeyFile.load_from_file(sRDBFile);

    if (!oKeyFile.has_group(csGameID))
        return;

    if (oKeyFile.has_key(csGameID, "rtcEnabled")) {
        bool bRTCEnabled = oKeyFile.get_boolean(csGameID, "rtcEnabled");
        rtcEnable(bRTCEnabled);
    }

    if (oKeyFile.has_key(csGameID, "flashSize")) {
        Glib::ustring sFlashSize = oKeyFile.get_string(csGameID, "flashSize");
        int iFlashSize = atoi(sFlashSize.c_str());
        if (iFlashSize == 0x10000 || iFlashSize == 0x20000)
            flashSetSize(iFlashSize);
    }

    if (oKeyFile.has_key(csGameID, "saveType")) {
        int iSaveType = oKeyFile.get_integer(csGameID, "saveType");
        if (iSaveType >= 0 && iSaveType <= 5)
            cpuSaveType = iSaveType;
    }

    if (oKeyFile.has_key(csGameID, "mirroringEnabled")) {
        mirroringEnable = oKeyFile.get_boolean(csGameID, "mirroringEnabled");
    }
}
Пример #5
0
void PlayerConfiguration::readKeyFile(const Glib::KeyFile& key)
  throw(DaoException, Glib::KeyFileError)
{
  string type, algorithm, color;
  type = key.get_string(m_sectionName, "type");
  m_type = stringToPlayerType(type);
  
  color = key.get_string(m_sectionName, "color");
  m_color = stringToPlayerColor(color);

  if (m_type == PLAYER_COMPUTER)
    {
      algorithm = key.get_string(m_sectionName, "algorithm");
      m_algorithm = stringToPlayerAlgorithm(algorithm);
    }

  m_k[0] = key.get_double(m_sectionName, "k1");
  m_k[1] = key.get_double(m_sectionName, "k2");
  m_k[2] = key.get_double(m_sectionName, "k3");
  m_h = key.get_double(m_sectionName, "h");
  m_depth = key.get_integer(m_sectionName, "depth");
}