[shotwell] piwigo: Add option to show the certificate



commit 8560752d671dfa4991dbdba3a4b57afb356efcc5
Author: Jens Georg <mail jensge org>
Date:   Mon Oct 3 14:39:24 2016 +0200

    piwigo: Add option to show the certificate
    
    So the user can inspect the certificate before proceeding
    
    Signed-off-by: Jens Georg <mail jensge org>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=767473

 configure.ac                                       |    2 +-
 plugins/common/RESTSupport.vala                    |    3 +-
 plugins/shotwell-publishing/PiwigoPublishing.vala  |   21 ++++++++++++++++++-
 .../shotwell-publishing/piwigo_ssl_failure_pane.ui |   14 +++++++++++++
 publish.am                                         |    4 +++
 5 files changed, 39 insertions(+), 5 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6164061..05364a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -113,7 +113,7 @@ PKG_CHECK_MODULES(IMPORT, [gee-0.8 >= 0.8.5 glib-2.0 gio-2.0 sqlite3])
 
 PKG_CHECK_MODULES(PUBLISHING, [gobject-2.0 glib-2.0 gexiv2 json-glib-1.0
                                gee-0.8 libsoup-2.4 libxml-2.0 gtk+-3.0
-                               webkit2gtk-4.0])
+                               webkit2gtk-4.0 gcr-3 gcr-ui-3])
 
 PKG_CHECK_MODULES(TRANSITIONS, [gobject-2.0 cairo gio-2.0 gdk-pixbuf-2.0
                                 gdk-3.0])
diff --git a/plugins/common/RESTSupport.vala b/plugins/common/RESTSupport.vala
index 94d5da7..09c28af 100644
--- a/plugins/common/RESTSupport.vala
+++ b/plugins/common/RESTSupport.vala
@@ -192,8 +192,7 @@ public class Transaction {
     }
 
     /* Texts copied from epiphany */
-    public string detailed_error_from_tls_flags () {
-        TlsCertificate cert;
+    public string detailed_error_from_tls_flags (out TlsCertificate cert) {
         TlsCertificateFlags tls_errors;
         this.message.get_https_status (out cert, out tls_errors);
 
diff --git a/plugins/shotwell-publishing/PiwigoPublishing.vala 
b/plugins/shotwell-publishing/PiwigoPublishing.vala
index cc917ad..a7fc0cf 100644
--- a/plugins/shotwell-publishing/PiwigoPublishing.vala
+++ b/plugins/shotwell-publishing/PiwigoPublishing.vala
@@ -1014,6 +1014,7 @@ internal class SSLErrorPane : Spit.Publishing.DialogPane, Object {
     public SSLErrorPane (SessionLoginTransaction transaction,
                          string host) {
         try {
+            TlsCertificate cert;
             this.builder = new Gtk.Builder ();
             this.builder.add_from_resource (Resources.RESOURCE_PATH +
                                             "/piwigo_ssl_failure_pane.ui");
@@ -1024,7 +1025,23 @@ internal class SSLErrorPane : Spit.Publishing.DialogPane, Object {
             label.use_markup = true;
 
             label = this.builder.get_object ("ssl_errors") as Gtk.Label;
-            label.set_text (transaction.detailed_error_from_tls_flags ());
+            var text = transaction.detailed_error_from_tls_flags (out cert);
+            label.set_text (text);
+
+            var info = this.builder.get_object ("default") as Gtk.Button;
+            info.clicked.connect (() => {
+                var simple_cert = new Gcr.SimpleCertificate (cert.certificate.data);
+                var widget = new Gcr.CertificateWidget (simple_cert);
+
+                var dialog = new Gtk.Dialog ();
+                dialog.get_content_area ().add (widget);
+                dialog.add_button ("_OK", Gtk.ResponseType.OK);
+                dialog.set_default_response (Gtk.ResponseType.OK);
+                dialog.set_default_size (640, -1);
+                dialog.show_all ();
+                dialog.run ();
+                dialog.destroy ();
+            });
 
             var proceed = this.builder.get_object ("proceed_button") as Gtk.Button;
             proceed.clicked.connect (() => { this.proceed (); });
@@ -1047,7 +1064,7 @@ internal class SSLErrorPane : Spit.Publishing.DialogPane, Object {
     }
 
     public Gtk.Widget get_default_widget () {
-        return this.builder.get_object ("cancel_button") as Gtk.Widget;
+        return this.builder.get_object ("default") as Gtk.Widget;
     }
 
     public void on_pane_installed () { }
diff --git a/plugins/shotwell-publishing/piwigo_ssl_failure_pane.ui 
b/plugins/shotwell-publishing/piwigo_ssl_failure_pane.ui
index b25828b..8175627 100644
--- a/plugins/shotwell-publishing/piwigo_ssl_failure_pane.ui
+++ b/plugins/shotwell-publishing/piwigo_ssl_failure_pane.ui
@@ -67,9 +67,23 @@
           <object class="GtkButtonBox">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="orientation">vertical</property>
             <property name="spacing">6</property>
             <property name="layout_style">center</property>
             <child>
+              <object class="GtkButton" id="default">
+                <property name="label" translatable="yes">Show the certificate…</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
               <object class="GtkButton" id="proceed_button">
                 <property name="label" translatable="yes">I understand, please _proceed.</property>
                 <property name="visible">True</property>
diff --git a/publish.am b/publish.am
index 194dcb6..ca12b61 100644
--- a/publish.am
+++ b/publish.am
@@ -41,12 +41,16 @@ plugins_shotwell_publishing_shotwell_publishing_la_VALAFLAGS = \
        --pkg shotwell-plugin-dev-1.0 \
        --pkg libxml-2.0 \
        --pkg webkit2gtk-4.0 \
+       --pkg gcr-3 \
+       --pkg gcr-ui-3 \
        --vapidir $(abs_top_srcdir)/plugins
 
 plugins_shotwell_publishing_shotwell_publishing_la_CFLAGS = \
        -DPLUGIN_RESOURCE_PATH='"/org/gnome/Shotwell/Publishing"' \
        $(PLUGIN_CFLAGS) \
        $(COMMON_CFLAGS) \
+       -DGCR_API_SUBJECT_TO_CHANGE \
+       $(PUBLISHING_CFLAGS) \
        -I $(top_srcdir)/plugins
 
 plugins_shotwell_publishing_shotwell_publishing_la_LDFLAGS = \


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