Logo Search packages:      
Sourcecode: pan version File versions

void DataImpl::load_server_properties ( const DataIO source  )  [private]

SERVERS

Definition at line 276 of file server.cc.

References pan::DataIO::get_server_filename().

{
  const std::string filename (source.get_server_filename());

  gchar * txt (0);
  gsize len (0);
  g_file_get_contents (filename.c_str(), &txt, &len, 0);

  ServerParseContext spc;
  GMarkupParser p;
  p.start_element = start_element;
  p.end_element = end_element;
  p.text = text;
  p.passthrough = 0;
  p.error = 0;
  GMarkupParseContext* c = g_markup_parse_context_new (&p, (GMarkupParseFlags)0, &spc, 0);
  GError * gerr (0);
  if (txt!=0 && len!=0)
    g_markup_parse_context_parse (c, txt, len, &gerr);
  if (gerr) {
    Log::add_err_va (_("Error loading newsserver information: %s"), gerr->message);
    g_clear_error (&gerr);
  }
  g_markup_parse_context_free (c);
  g_free (txt);

  // populate the servers from the info we loaded...
  _servers.clear ();
  foreach_const (key_to_keyvals_t, spc.data, it) {
    Server& s (_servers[it->first]);
    keyvals_t kv (it->second);
    s.host = kv["host"];
    s.username = kv["username"];
    s.password = kv["password"];
    s.port = to_int (kv["port"], 119);
    s.max_connections = to_int (kv["connection-limit"], 2);
    s.article_expiration_age = to_int(kv["expire-articles-n-days-old"], 31);
    s.rank = to_int(kv["rank"], 1);
  }

  save_server_properties (*const_cast<DataIO*>(&source));
}


Generated by  Doxygen 1.6.0   Back to index