[pan2/testing: 264/279] fix servers.xml cert setting
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2/testing: 264/279] fix servers.xml cert setting
- Date: Sat, 3 Dec 2011 22:43:36 +0000 (UTC)
commit 77c8b7047830faf459f60c193abce99b3187a3d8
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date: Mon Nov 28 18:29:13 2011 +0100
fix servers.xml cert setting
pan/data-impl/server.cc | 46 +++++++++++++++++++++++++++-------------------
pan/data/cert-store.cc | 8 ++++++--
pan/gui/gui.cc | 6 +-----
pan/gui/post-ui.cc | 13 +------------
pan/tasks/queue.cc | 6 +++---
5 files changed, 38 insertions(+), 41 deletions(-)
---
diff --git a/pan/data-impl/server.cc b/pan/data-impl/server.cc
index c416896..729c1fa 100644
--- a/pan/data-impl/server.cc
+++ b/pan/data-impl/server.cc
@@ -72,7 +72,6 @@ DataImpl :: add_new_server ()
// add it to the _servers map and give it a default filename
std::ostringstream o;
- //o << file::get_pan_home() << G_DIR_SEPARATOR << "newsrc-" << new_server;
o << "newsrc-" << new_server;
_servers[new_server].newsrc_filename = o.str ();
return new_server;
@@ -113,11 +112,10 @@ DataImpl :: set_server_article_expiration_age (const Quark & server,
int days)
{
Server * s (find_server (server));
- assert (s != 0);
+ assert (s);
s->article_expiration_age = std::max (0, days);
-
}
void
@@ -126,12 +124,11 @@ DataImpl :: set_server_auth (const Quark & server,
const StringView & password)
{
Server * s (find_server (server));
- assert (s != 0);
+ assert (s);
s->username = username;
s->password = password;
-
}
void
@@ -140,7 +137,7 @@ DataImpl :: set_server_addr (const Quark & server,
int port)
{
Server * s (find_server (server));
- assert (s != 0);
+ assert (s);
s->host = host;
s->port = port;
@@ -152,7 +149,7 @@ DataImpl :: set_server_limits (const Quark & server,
int max_connections)
{
Server * s (find_server (server));
- assert (s != 0);
+ assert (s);
s->max_connections = max_connections;
}
@@ -162,7 +159,7 @@ DataImpl :: set_server_rank (const Quark & server,
int rank)
{
Server * s (find_server (server));
- assert (s != 0);
+ assert (s);
s->rank = rank;
}
@@ -172,7 +169,7 @@ DataImpl :: set_server_ssl_support (const Quark & server,
int ssl)
{
Server * s (find_server (server));
- assert (s != 0);
+ assert (s);
s->ssl_support = ssl;
}
@@ -182,8 +179,9 @@ DataImpl :: set_server_cert (const Quark & server,
const StringView & cert)
{
Server * s (find_server (server));
- assert (s != 0);
+ assert (s);
s->cert = cert;
+ debug(s->cert<<" "<<cert);
}
@@ -191,8 +189,9 @@ void
DataImpl :: save_server_info (const Quark& server)
{
Server * s (find_server (server));
- assert (s != 0);
+ assert (s);
save_server_properties (*_data_io);
+
}
bool
@@ -201,12 +200,13 @@ DataImpl :: get_server_auth (const Quark & server,
std::string & setme_password) const
{
const Server * s (find_server (server));
- const bool found (s != 0);
+ const bool found (s);
if (found) {
setme_username = s->username;
setme_password = s->password;
}
return found;
+
}
bool
@@ -215,12 +215,13 @@ DataImpl :: get_server_addr (const Quark & server,
int & setme_port) const
{
const Server * s (find_server (server));
- const bool found (s != 0);
+ const bool found (s);
if (found) {
setme_host = s->host;
setme_port = s->port;
}
return found;
+
}
std::string
@@ -234,6 +235,7 @@ DataImpl :: get_server_address (const Quark& server) const
str = x.str();
}
return str;
+
}
bool
@@ -241,9 +243,10 @@ DataImpl :: get_server_ssl_support (const Quark & server) const
{
bool retval (false);
const Server * s (find_server (server));
- if (s != 0)
+ if (s)
retval = (s->ssl_support != 0);
return retval;
+
}
std::string
@@ -251,10 +254,10 @@ DataImpl :: get_server_cert (const Quark & server) const
{
std::string str;
const Server * s (find_server (server));
- if (s) {
+ if (s)
str = s->cert;
- }
return str;
+
}
int
@@ -262,9 +265,10 @@ DataImpl :: get_server_limits (const Quark & server) const
{
int retval (2);
const Server * s (find_server (server));
- if (s != 0)
+ if (s)
retval = s->max_connections;
return retval;
+
}
int
@@ -272,9 +276,10 @@ DataImpl :: get_server_rank (const Quark & server) const
{
int retval (1);
const Server * s (find_server (server));
- if (s != 0)
+ if (s)
retval = s->rank;
return retval;
+
}
int
@@ -282,11 +287,13 @@ DataImpl :: get_server_article_expiration_age (const Quark & server) const
{
int retval (31);
const Server * s (find_server (server));
- if (s != 0)
+ if (s)
retval = s->article_expiration_age;
return retval;
+
}
+
/***
****
***/
@@ -427,6 +434,7 @@ DataImpl :: save_server_properties (DataIO& data_io) const
*out << indent(depth++) << "<server-properties>\n";
foreach_const (alpha_quarks_t, servers, it) {
const Server* s (find_server (*it));
+ debug("saving server, "<<s->cert);
*out << indent(depth++) << "<server id=\"" << escaped(it->to_string()) << "\">\n";
*out << indent(depth) << "<host>" << escaped(s->host) << "</host>\n"
<< indent(depth) << "<port>" << s->port << "</port>\n"
diff --git a/pan/data/cert-store.cc b/pan/data/cert-store.cc
index accd07e..be372e7 100644
--- a/pan/data/cert-store.cc
+++ b/pan/data/cert-store.cc
@@ -136,6 +136,7 @@ namespace pan
void
CertStore :: remove (const Quark& server)
{
+ debug("remove cert "<<server);
if (_cert_to_server.count(server))
{
_cert_to_server.erase(server);
@@ -169,8 +170,8 @@ namespace pan
bool
CertStore :: add(X509* cert, const Quark& server)
{
+ debug(server<<" "<<cert);
if (!cert || server.empty()) return false;
- debug(cert<<" "<<_data.get_server_address(server));
debug(X509_NAME_oneline(X509_get_issuer_name(cert), 0, 0));
X509_STORE_add_cert(get_store(),cert);
@@ -179,8 +180,9 @@ namespace pan
_certs.insert(server);
_cert_to_server[server] = cert;
- const char* buf(build_cert_name(addr.c_str()).c_str());
+ debug(server<<" "<<addr);
+ const char* buf(build_cert_name(addr.c_str()).c_str());
_data.set_server_cert(server, buf);
_data.save_server_info(server);
@@ -190,6 +192,8 @@ namespace pan
fclose(fp);
chmod (buf, 0600);
+ debug(server<<" "<<buf);
+
valid_cert_added(cert, server.c_str());
return true;
}
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index 33dbcb0..fdaaafe 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -2102,11 +2102,7 @@ GUI :: do_show_cert_failed_dialog(VerifyData* data)
if (GUI::confirm_accept_new_cert_dialog(get_window(_root),d.cert,d.server))
if (!_certstore.add(d.cert, d.server))
Log::add_urgent_va("Error adding certificate of server '%s' to Certificate Store",d.server.c_str());
- else
- {
- _data.set_server_cert(d.server, d.cert_name);
- _data.save_server_info(d.server);
- }
+
X509_free(d.cert); // refcount -1
delete data;
}
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index 78cf7b7..bbd22d7 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -2531,17 +2531,14 @@ PostUI:: on_parts_box_clicked_cb (GtkCellRendererToggle *cell, gchar *path_str,
gboolean enabled;
gtk_tree_model_get_iter (model, &iter, path);
-
gtk_tree_model_get (model, &iter, 0, &part, 1, &enabled, -1);
enabled ^= 1;
if (enabled==0)
data->_upload_ptr->_wanted.erase(part);
else
- {
data->_upload_ptr->_wanted.insert(part);
- }
gtk_list_store_set(GTK_LIST_STORE( model ), &iter, 1, enabled, -1);
gtk_tree_path_free (path);
data->update_parts_tab();
@@ -2824,16 +2821,8 @@ PostUI :: select_parts ()
_upload_ptr = dynamic_cast<TaskUpload*>(set[0]);
if (!_upload_ptr) return;
-
- _total_parts = get_total_parts(_upload_ptr->_filename.c_str());
-// _upload_ptr->_wanted.clear();
-// for (int i=1;i<=_total_parts;++i)
-// _upload_ptr->_wanted.insert(i);
-
- GtkWidget * w;
GtkTreeIter iter;
-
- w = _part_select = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ GtkWidget * w = _part_select = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (_part_select, "delete-event", G_CALLBACK(delete_parts_cb), this);
gtk_window_set_role (GTK_WINDOW(w), "pan-parts-window");
gtk_window_set_title (GTK_WINDOW(w), _("Select Parts"));
diff --git a/pan/tasks/queue.cc b/pan/tasks/queue.cc
index 05a833f..d4b93cd 100644
--- a/pan/tasks/queue.cc
+++ b/pan/tasks/queue.cc
@@ -57,9 +57,9 @@ Queue :: Queue (ServerInfo & server_info,
_downloads_total(0)
{
- tasks_t tasks;
- _archive.load_tasks (tasks);
- add_tasks (tasks, BOTTOM);
+// tasks_t tasks;
+// _archive.load_tasks (tasks);
+// add_tasks (tasks, BOTTOM);
_tasks.add_listener (this);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]