Logo Search packages:      
Sourcecode: pan version File versions  Download package

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

SERVERS

Definition at line 283 of file server.cc.

References pan::file::get_pan_home(), and pan::file::get_text_file_contents().

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

  std::string txt;
  file :: get_text_file_contents (filename, txt);

  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.empty())
    g_markup_parse_context_parse (c, txt.c_str(), txt.size(), &gerr);
  if (gerr) {
    Log::add_err_va (_("Error reading file \"%s\": %s"), filename.c_str(), gerr->message);
    g_clear_error (&gerr);
  }
  g_markup_parse_context_free (c);

  // 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);
    s.newsrc_filename = kv["newsrc"];
    if (s.newsrc_filename.empty()) { // set a default filename
      std::ostringstream o;
      o << file::get_pan_home() << G_DIR_SEPARATOR << "newsrc-" << it->first;
      s.newsrc_filename = o.str ();
    }
  }

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

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index