[pan2/testing: 228/279] HAVE_OPENSSL fixes



commit d85fa82fd5695be24dedfdcb17182c9e98679d73
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date:   Mon Nov 7 10:38:43 2011 +0100

    HAVE_OPENSSL fixes

 pan/data-impl/add-server.cc      |   19 +++++++++----------
 pan/gui/gui.cc                   |   15 ++++++++++-----
 pan/gui/gui.h                    |    8 +++++---
 pan/gui/pan.cc                   |    4 ++--
 pan/gui/server-ui.cc             |   14 +++++++-------
 pan/tasks/cert-store.cc          |    8 ++++++--
 pan/tasks/cert-store.h           |   26 +++++++++++++++++++++-----
 pan/tasks/nntp-pool.cc           |    3 +++
 pan/tasks/nntp-pool.h            |    9 +++++----
 pan/tasks/queue.cc               |    1 +
 pan/tasks/queue.h                |    5 ++++-
 pan/tasks/socket-impl-main.cc    |   14 ++++++++++++--
 pan/tasks/socket-impl-main.h     |   13 +++++++------
 pan/tasks/socket-impl-openssl.cc |    4 ++--
 pan/tasks/socket-impl-openssl.h  |   10 ++++++++++
 15 files changed, 104 insertions(+), 49 deletions(-)
---
diff --git a/pan/data-impl/add-server.cc b/pan/data-impl/add-server.cc
index d5e82ac..7de7c75 100644
--- a/pan/data-impl/add-server.cc
+++ b/pan/data-impl/add-server.cc
@@ -61,16 +61,15 @@ int main (int argc, char *argv[])
   // initialize the queue
   TaskArchive null_task_archive;
   WorkerPool pool;
-  CertStore cs(0);
+  CertStore cs;
+  // FIXME : adapt!
+  SocketCreator _socket_creator(cs);
+  Queue queue (data, null_task_archive, &_socket_creator, cs, pool, true, 10);
+  queue.add_task (new TaskGroups (data, servername));
 
-  // FIXME : DBG!
-//  SocketCreator _socket_creator(cs);
-//  Queue queue (data, null_task_archive, &_socket_creator, cs, pool, true, 10);
-//  queue.add_task (new TaskGroups (data, servername));
-//
-//  // start the event loop...
-//  main_loop = g_main_loop_new (NULL, false);
-//  g_timeout_add (2*1000, check_for_tasks_done, &queue);
-//  g_main_loop_run (main_loop);
+  // start the event loop...
+  main_loop = g_main_loop_new (NULL, false);
+  g_timeout_add (2*1000, check_for_tasks_done, &queue);
+  g_main_loop_run (main_loop);
   return 0;
 }
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index ff0a185..a2a86e0 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -352,8 +352,9 @@ GUI :: GUI (Data& data, Queue& queue, ArticleCache& cache, EncodeCache& encode_c
         on_queue_task_active_changed (queue, *(*it), true);
     }
   }
-
+#ifdef HAVE_OPENSSL
   _certstore.add_listener(this);
+#endif
 }
 
 namespace
@@ -364,9 +365,9 @@ namespace
 
 GUI :: ~GUI ()
 {
-
+#ifdef HAVE_OPENSSL
   _certstore.remove_listener(this);
-
+#endif
   const std::string accel_filename (get_accel_filename());
   gtk_accel_map_save (accel_filename.c_str());
   chmod (accel_filename.c_str(), 0600);
@@ -1066,9 +1067,11 @@ void GUI :: do_show_servers_dialog ()
 
 void GUI :: do_show_sec_dialog ()
 {
+#ifdef HAVE_OPENSSL
   GtkWidget * w = sec_dialog_new (_data, _queue, get_window(_root));
   g_signal_connect (w, "destroy", G_CALLBACK(sec_dialog_destroyed_cb), this);
   gtk_widget_show_all (w);
+#endif
 }
 
 
@@ -1303,7 +1306,7 @@ bool GUI::deletion_confirmation_dialog()
   return ret;
 }
 
-
+#ifdef HAVE_OPENSSL
 bool GUI::confirm_accept_new_cert_dialog(X509* cert, const Quark& server)
 {
   bool ret(false);
@@ -1325,6 +1328,7 @@ bool GUI::confirm_accept_new_cert_dialog(X509* cert, const Quark& server)
   gtk_widget_destroy(d);
   return ret;
 }
+#endif
 
 void GUI :: do_delete_article ()
 {
@@ -2085,7 +2089,7 @@ GUI :: on_prefs_string_changed (const StringView& key, const StringView& value)
     prev_path.assign (value.str, value.len);
 }
 
-
+#ifdef HAVE_OPENSSL
 void
 GUI :: on_verify_cert_failed(X509* cert, std::string server, int nr)
 {
@@ -2102,3 +2106,4 @@ GUI :: on_valid_cert_added (X509* cert, std::string server)
 {
 
 }
+#endif
diff --git a/pan/gui/gui.h b/pan/gui/gui.h
index 0a81773..34cbb05 100644
--- a/pan/gui/gui.h
+++ b/pan/gui/gui.h
@@ -24,7 +24,7 @@
 #include <pan/data/article-cache.h>
 #include <pan/data/encode-cache.h>
 #include <pan/tasks/queue.h>
-
+#include <pan/tasks/cert-store.h>
 #include <pan/gui/action-manager.h>
 #include <pan/gui/pan-ui.h>
 #include <pan/gui/prefs.h>
@@ -127,7 +127,9 @@ namespace pan
       virtual void do_supersede_article ();
       virtual void do_delete_article ();
       virtual bool deletion_confirmation_dialog();
+#ifdef HAVE_OPENSSL
       virtual bool confirm_accept_new_cert_dialog(X509*, const Quark&);
+#endif
       virtual void do_clear_article_cache ();
       virtual void do_mark_article_read ();
       virtual void do_mark_article_unread ();
@@ -178,11 +180,11 @@ namespace pan
       virtual void on_queue_size_changed (Queue&, int active, int total);
       virtual void on_queue_online_changed (Queue&, bool online);
       virtual void on_queue_error (Queue&, const StringView& message);
-
+#ifdef HAVE_OPENSSL
     private:  // CertStore::Listener
       virtual void on_verify_cert_failed(X509*, std::string, int);
       virtual void on_valid_cert_added (X509*, std::string);
-
+#endif
     private: // Log::Listener
       virtual void on_log_entry_added (const Log::Entry& e);
       virtual void on_log_cleared () {}
diff --git a/pan/gui/pan.cc b/pan/gui/pan.cc
index a17a999..a96f253 100644
--- a/pan/gui/pan.cc
+++ b/pan/gui/pan.cc
@@ -39,9 +39,9 @@ extern "C" {
 
 #ifdef HAVE_OPENSSL
   #include <pan/tasks/socket-impl-openssl.h>
-  #include <pan/tasks/cert-store.h>
 #endif
 
+#include <pan/tasks/cert-store.h>
 #include <pan/tasks/socket-impl-gio.h>
 #include <pan/tasks/socket-impl-main.h>
 #include <pan/tasks/task-groups.h>
@@ -334,7 +334,7 @@ main (int argc, char *argv[])
     EncodeCache& encode_cache (data.get_encode_cache());
 
     /* init certificate store for SSL */
-    CertStore certstore(0);
+    CertStore certstore;
 
     if (nzb && data.get_servers().empty()) {
       std::cerr << _("Please configure Pan's news servers before using it as an nzb client.") << std::endl;
diff --git a/pan/gui/server-ui.cc b/pan/gui/server-ui.cc
index 8c269d4..4e26f79 100644
--- a/pan/gui/server-ui.cc
+++ b/pan/gui/server-ui.cc
@@ -28,7 +28,7 @@ extern "C" {
 }
 
 #include <pan/usenet-utils/ssl-utils.h>
-#include <pan/icons/pan-pixbufs-internal.h>
+#include <pan/icons/pan-pixbufs.h>
 #include <pan/general/macros.h>
 #include <pan/general/quark.h>
 #include <pan/data/data.h>
@@ -633,6 +633,7 @@ namespace
   }
 }
 
+#ifdef HAVE_OPENSSL
 /* security dialog */
 namespace
 {
@@ -774,6 +775,7 @@ namespace
   }
 
 }
+#endif
 
 GtkWidget*
 pan :: server_list_dialog_new (Data& data, Queue& queue, GtkWindow* parent)
@@ -867,6 +869,7 @@ pan :: render_cert_flag (GtkTreeViewColumn * ,
 GtkWidget*
 pan :: sec_dialog_new (Data& data, Queue& queue, GtkWindow* parent)
 {
+#ifdef HAVE_OPENSSL
   ServerListDialog * d = new ServerListDialog (data, queue);
 
   for (guint i=0; i<ICON_QTY; ++i)
@@ -894,12 +897,6 @@ pan :: sec_dialog_new (Data& data, Queue& queue, GtkWindow* parent)
   w = d->server_tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (d->servers_store));
 
   GtkCellRenderer * r = GTK_CELL_RENDERER (g_object_new (GTK_TYPE_CELL_RENDERER_PIXBUF, "xpad", 2,"ypad", 0,NULL));
-//  GtkTreeViewColumn * col = gtk_tree_view_column_new ();
-//  gtk_tree_view_column_set_resizable (col, false);
-//  gtk_tree_view_column_set_title (col, _("Certificate"));
-//  gtk_tree_view_column_pack_start (col, r, false);
-//  gtk_tree_view_column_set_cell_data_func (col, r, render_cert_flag, 0, 0);
-//  gtk_tree_view_append_column (GTK_TREE_VIEW(w), col);
   GtkTreeViewColumn * column = gtk_tree_view_column_new_with_attributes (_("Certificates"), r, NULL);
   gtk_tree_view_column_set_cell_data_func (column, r, render_cert_flag, 0, 0);
   gtk_tree_view_append_column (GTK_TREE_VIEW(w), column);
@@ -951,4 +948,7 @@ pan :: sec_dialog_new (Data& data, Queue& queue, GtkWindow* parent)
   sec_tree_view_refresh (d);
   button_refresh (d);
   return d->dialog;
+#else
+  return 0;
+#endif
 }
diff --git a/pan/tasks/cert-store.cc b/pan/tasks/cert-store.cc
index 4cc0b84..dbb33aa 100644
--- a/pan/tasks/cert-store.cc
+++ b/pan/tasks/cert-store.cc
@@ -53,6 +53,8 @@ extern "C" {
 
 using namespace pan;
 
+#ifdef HAVE_OPENSSL
+
 namespace pan
 {
 
@@ -158,9 +160,8 @@ CertStore :: remove (const Quark& server)
   }
 }
 
-CertStore :: CertStore (SSL_CTX * ctx) : _ctx(ctx)
+CertStore :: CertStore ()
 {
-  if (ctx) init_me();
   char buf[2048];
   g_snprintf(buf,sizeof(buf),"%s%cssl_certs",file::get_pan_home().c_str(), G_DIR_SEPARATOR);
   file::ensure_dir_exists (buf);
@@ -264,3 +265,6 @@ CertStore :: pretty_print_x509 (char* buf, size_t size, const Quark& server, X50
 
 
 }  // namespace pan
+
+
+#endif
diff --git a/pan/tasks/cert-store.h b/pan/tasks/cert-store.h
index d5be2c8..e50fabe 100644
--- a/pan/tasks/cert-store.h
+++ b/pan/tasks/cert-store.h
@@ -37,13 +37,15 @@
 
 #include <map>
 
+
+
 namespace pan
 {
-#ifdef HAVE_OPENSSL
   class CertStore
   {
+#ifdef HAVE_OPENSSL
     public:
-      CertStore (SSL_CTX*) ;
+      CertStore () ;
       virtual ~CertStore () ;
 
     private:
@@ -104,7 +106,6 @@ namespace pan
     protected:
       friend class SocketCreator;
       void set_ctx(SSL_CTX* c) { _ctx = c; init_me(); }
-
   };
 
   struct mydata_t {
@@ -114,8 +115,23 @@ namespace pan
    CertStore* cs;
    std::string server;
    CertStore::Listener* l;
+#else
+  public:
+    CertStore () {};
+    virtual ~CertStore () {};
+
+    void add_listener (void * l) {}
+    void remove_listener (void * l) {}
+
+    struct Listener
+    {
+      virtual ~Listener() {}
+    };
+#endif   // HAVE_OPENSSL
   };
-#endif
+
 }
 
- #endif
+
+#endif
+
diff --git a/pan/tasks/nntp-pool.cc b/pan/tasks/nntp-pool.cc
index ebcddf3..7b03538 100644
--- a/pan/tasks/nntp-pool.cc
+++ b/pan/tasks/nntp-pool.cc
@@ -41,6 +41,7 @@ NNTP_Pool :: NNTP_Pool (const Quark        & server,
                         ServerInfo         & server_info,
                         SocketCreator      * creator,
                         CertStore          & certstore):
+
   _server_info (server_info),
   _server (server),
   _socket_creator (creator),
@@ -343,6 +344,7 @@ NNTP_Pool :: idle_upkeep ()
 }
 
 
+#ifdef HAVE_OPENSSL
 void
 NNTP_Pool :: on_verify_cert_failed (X509* cert, std::string server, int nr)
 {
@@ -355,3 +357,4 @@ NNTP_Pool :: on_valid_cert_added (X509* cert, std::string server)
 {
   _blacklist.erase(server);
 }
+#endif
diff --git a/pan/tasks/nntp-pool.h b/pan/tasks/nntp-pool.h
index 81b00ac..55d9a9e 100644
--- a/pan/tasks/nntp-pool.h
+++ b/pan/tasks/nntp-pool.h
@@ -27,7 +27,10 @@
 #include <pan/tasks/socket.h>
 #include <pan/tasks/nntp.h>
 #include <pan/tasks/socket-impl-main.h>
-#include <pan/tasks/cert-store.h>
+
+#ifdef HAVE_OPENSSL
+  #include <pan/tasks/cert-store.h>
+#endif
 
 namespace pan
 {
@@ -50,7 +53,6 @@ namespace pan
                  ServerInfo        & server_info,
                  SocketCreator     *,
                  CertStore         & certstore);
-
       virtual ~NNTP_Pool ();
 
       virtual void check_in (NNTP*, Health);
@@ -79,7 +81,7 @@ namespace pan
 
     private: //  NNTP::Listener
       virtual void on_nntp_done (NNTP*, Health, const StringView&);
- #ifdef HAVE_OPENSSL
+#ifdef HAVE_OPENSSL
     private: //  CertStore::Listener
       virtual void on_verify_cert_failed (X509*, std::string, int);
       virtual void on_valid_cert_added (X509* cert, std::string server);
@@ -112,7 +114,6 @@ namespace pan
       typedef std::vector<PoolItem> pool_items_t;
       pool_items_t _pool_items;
       int _active_count;
-
       CertStore& _certstore;
 
     private:
diff --git a/pan/tasks/queue.cc b/pan/tasks/queue.cc
index 4992042..dcbc82f 100644
--- a/pan/tasks/queue.cc
+++ b/pan/tasks/queue.cc
@@ -53,6 +53,7 @@ Queue :: Queue (ServerInfo         & server_info,
   _uploads_total(0),
   _certstore (store)
 {
+
   tasks_t tasks;
   _archive.load_tasks (tasks);
   add_tasks (tasks, BOTTOM);
diff --git a/pan/tasks/queue.h b/pan/tasks/queue.h
index ffb19cc..f390044 100644
--- a/pan/tasks/queue.h
+++ b/pan/tasks/queue.h
@@ -35,7 +35,10 @@
 #include <pan/tasks/encoder.h>
 #include <pan/tasks/task-weak-ordering.h>
 #include <pan/tasks/socket-impl-main.h>
-#include <pan/tasks/cert-store.h>
+
+#ifdef HAVE_OPENSSL
+  #include <pan/tasks/cert-store.h>
+#endif
 
 namespace pan
 {
diff --git a/pan/tasks/socket-impl-main.cc b/pan/tasks/socket-impl-main.cc
index 9b0b87b..c5584aa 100644
--- a/pan/tasks/socket-impl-main.cc
+++ b/pan/tasks/socket-impl-main.cc
@@ -59,11 +59,15 @@ namespace pan
     Socket * socket;
     std::string err;
     bool use_ssl;
+#ifdef HAVE_OPENSSL
     SSL_CTX * context;
     CertStore& store;
-
     ThreadWorker (const StringView& h, int p, Socket::Creator::Listener *l, bool ssl, SSL_CTX* ctx, CertStore& cs):
       host(h), port(p), listener(l), ok(false), socket(0), use_ssl(ssl), context(ctx), store(cs) {}
+#else
+    ThreadWorker (const StringView& h, int p, Socket::Creator::Listener *l):
+      host(h), port(p), listener(l), ok(false), socket(0), use_ssl(false) {}
+#endif
 
     void do_work ()
     {
@@ -135,6 +139,7 @@ SocketCreator :: SocketCreator(CertStore& cs) : store(cs)
 #endif
 }
 
+
 SocketCreator :: ~SocketCreator()
 {
 #ifdef HAVE_OPENSSL
@@ -151,11 +156,15 @@ SocketCreator :: create_socket (const StringView & host,
                                 bool               use_ssl)
 {
     ensure_module_init ();
-
+#ifdef HAVE_OPENSSL
     ThreadWorker * w = new ThreadWorker (host, port, listener, use_ssl, ssl_ctx, store);
+#else
+    ThreadWorker * w = new ThreadWorker (host, port, listener);
+#endif
     threadpool.push_work (w, w, true);
 }
 
+#ifdef HAVE_OPENSSL
 void
 SocketCreator :: on_verify_cert_failed(X509* cert, std::string server, int nr)
 {
@@ -164,3 +173,4 @@ SocketCreator :: on_verify_cert_failed(X509* cert, std::string server, int nr)
 void
 SocketCreator :: on_valid_cert_added (X509* cert, std::string server)
 {}
+#endif
diff --git a/pan/tasks/socket-impl-main.h b/pan/tasks/socket-impl-main.h
index 8776803..cb5a36d 100644
--- a/pan/tasks/socket-impl-main.h
+++ b/pan/tasks/socket-impl-main.h
@@ -40,9 +40,9 @@
   #include <openssl/crypto.h>
   #include <openssl/ssl.h>
   #include "socket-impl-openssl.h"
-  #include "cert-store.h"
 #endif
 
+#include "cert-store.h"
 #include "socket-impl-gio.h"
 
 namespace
@@ -123,11 +123,15 @@ namespace pan
       SocketCreator (CertStore&);
       virtual ~SocketCreator ();
 
-#ifdef HAVE_OPENSSL
+
     private:
+#ifdef HAVE_OPENSSL
       SSL_CTX* ssl_ctx;
-      CertStore & store;
+      // CertStore::Listener
+      virtual void on_verify_cert_failed(X509*, std::string, int);
+      virtual void on_valid_cert_added (X509*, std::string );
 #endif
+      CertStore & store;
 
     public:
       virtual void create_socket (const StringView & host,
@@ -136,9 +140,6 @@ namespace pan
                                   Socket::Creator::Listener * listener,
                                   bool               use_ssl);
 
-      // CertStore::Listener
-      virtual void on_verify_cert_failed(X509*, std::string, int);
-      virtual void on_valid_cert_added (X509*, std::string );
   };
 
 }
diff --git a/pan/tasks/socket-impl-openssl.cc b/pan/tasks/socket-impl-openssl.cc
index 3099826..eeb776b 100644
--- a/pan/tasks/socket-impl-openssl.cc
+++ b/pan/tasks/socket-impl-openssl.cc
@@ -100,8 +100,8 @@ extern "C" {
 using namespace pan;
 
 #ifndef G_OS_WIN32
-extern t_getaddrinfo p_getaddrinfo;
-extern t_freeaddrinfo p_freeaddrinfo;
+extern void* p_getaddrinfo;
+extern void* p_freeaddrinfo;
 #endif
 
 /****
diff --git a/pan/tasks/socket-impl-openssl.h b/pan/tasks/socket-impl-openssl.h
index 4bb9a11..354d249 100644
--- a/pan/tasks/socket-impl-openssl.h
+++ b/pan/tasks/socket-impl-openssl.h
@@ -37,6 +37,7 @@
   #include <openssl/err.h>
 #endif
 
+
 namespace pan
 {
   /**
@@ -44,6 +45,7 @@ namespace pan
    *
    * @ingroup tasks
    */
+#ifdef HAVE_OPENSSL
   class GIOChannelSocketSSL:
     public GIOChannelSocket,
     private CertStore::Listener
@@ -88,6 +90,14 @@ namespace pan
 
     private:
       GIOChannel* ssl_get_iochannel(GIOChannel *handle, gboolean verify=true);
+
+#else
+  class GIOChannelSocketSSL
+  {
+    public:
+      virtual ~GIOChannelSocketSSL ();
+      GIOChannelSocketSSL ();
+#endif  // HAVE_OPENSSL
   };
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]