Exemplo n.º 1
0
void Settings::save_settings(Glib::RefPtr<Gio::File> file)
{
  Glib::KeyFile cfg;

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

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

    switch (settings[i].type) {
    case T_BOOL:
      cfg.set_boolean (group, key, *PTR_BOOL(this, i));
      break;
    case T_INT:
      cfg.set_integer (group, key, *PTR_INT(this, i));
      break;
    case T_FLOAT:
    case T_COLOUR_MEMBER:
      cfg.set_double (group, key, *PTR_FLOAT(this, i));
      break;
    case T_STRING:
      cfg.set_string (group, key, *PTR_STRING(this, i));
      break;
    default:
      std::cerr << "Can't save setting of unknown type\n";
      break;
    };
  }

  GCode.m_impl->saveSettings (cfg);

  Glib::ustring contents = cfg.to_data();
  Glib::file_set_contents (file->get_path(), contents);
}
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) ) );
}
Exemplo n.º 3
0
bool dialog_localsettings::save()
{
    string settingsfile = Glib::get_home_dir() + "/.gutorrent";

    Glib::KeyFile kf;
    kf.set_string("gutorrent", "host", eHost->get_text());
    kf.set_string("gutorrent", "username", eUserName->get_text());
    kf.set_string("gutorrent", "password", ePassword->get_text());
    kf.set_integer("gutorrent", "update_interval", sUpdateInterval->get_value_as_int());


    ofstream file;
    file.open(settingsfile.c_str(), ios::out | ios::trunc);
    file << kf.to_data();
    file.close();

    return true;
}