[seahorse] Fix exporter vala implementation



commit e67cf9afbd068dd90c077dae163c23fee841769e
Author: Stef Walter <stefw gnome org>
Date:   Sun Apr 21 22:08:59 2013 +0200

    Fix exporter vala implementation
    
     * Implement pkcs11 exporter in vala

 common/seahorse-exportable.vala            |    8 +-
 common/seahorse-exporter.vala              |   10 +-
 libseahorse/seahorse-application.c         |    5 +-
 libseahorse/seahorse-util.h                |    2 -
 pgp/seahorse-gpgme-exporter.c              |   23 ++-
 pgp/seahorse-gpgme-key.c                   |    9 +
 pkcs11/.gitignore                          |    3 +
 pkcs11/Makefile.am                         |   31 +++-
 pkcs11/certificate-der-exporter.vala       |   88 ++++++++++
 pkcs11/pkcs11-module.vala                  |   29 ++++
 pkcs11/seahorse-certificate-der-exporter.c |  245 ----------------------------
 pkcs11/seahorse-certificate-der-exporter.h |   41 -----
 pkcs11/seahorse-certificate.c              |   14 ++-
 pkcs11/seahorse-pkcs11-backend.c           |    3 +
 pkcs11/seahorse-pkcs11.c                   |   23 ---
 pkcs11/seahorse-pkcs11.h                   |   37 ----
 pkcs11/seahorse-private-key.c              |    9 +
 po/POTFILES.in                             |    2 +-
 po/POTFILES.skip                           |    1 +
 ssh/seahorse-ssh-exporter.c                |   23 ++-
 ssh/seahorse-ssh-key.c                     |    9 +
 21 files changed, 241 insertions(+), 374 deletions(-)
---
diff --git a/common/seahorse-exportable.vala b/common/seahorse-exportable.vala
index 57974ad..0df7d5b 100644
--- a/common/seahorse-exportable.vala
+++ b/common/seahorse-exportable.vala
@@ -146,7 +146,7 @@ public interface Exportable : GLib.Object {
                                }
                        }
 
-                       string directory = null;
+                       string? directory = null;
                        GLib.File? file;
                        Exporter? exporter;
 
@@ -164,6 +164,8 @@ public interface Exportable : GLib.Object {
                                loop.quit();
                        });
 
+                       loop.run();
+
                        exporter.export_to_file.end(result);
                        foreach (var e in exporter.get_objects()) {
                                pending.remove(e);
@@ -185,7 +187,7 @@ public interface Exportable : GLib.Object {
 
        public static bool prompt(GLib.List<Exporter> exporters,
                                  Gtk.Window? parent,
-                                 ref string directory,
+                                 ref string? directory,
                                  out GLib.File chosen_file,
                                  out Exporter chosen_exporter) {
                var chooser = new Gtk.FileChooserDialog(null, parent, Gtk.FileChooserAction.SAVE,
@@ -231,11 +233,13 @@ public interface Exportable : GLib.Object {
                        chosen_file = chooser.get_file();
                        chosen_exporter = filters.lookup(chooser.get_filter());
                        directory = chooser.get_current_folder();
+                       chooser.destroy();
                        return true;
                }
 
                chosen_file = null;
                chosen_exporter = null;
+               chooser.destroy();
                return false;
        }
 }
diff --git a/common/seahorse-exporter.vala b/common/seahorse-exporter.vala
index 3450a65..219c7d0 100644
--- a/common/seahorse-exporter.vala
+++ b/common/seahorse-exporter.vala
@@ -29,12 +29,14 @@ public enum ExporterType {
        TEXTUAL
 }
 
+public const string BAD_FILENAME_CHARS = "/\\<>|:?;";
+
 public interface Exporter : GLib.Object {
-       public abstract string filename { get; }
+       public abstract string filename { owned get; }
 
        public abstract string content_type { get; }
 
-       public abstract Gtk.FileFilter file_filter { get; }
+       public abstract Gtk.FileFilter file_filter { owned get; }
 
        public abstract unowned GLib.List<weak GLib.Object> get_objects();
 
@@ -74,9 +76,11 @@ public interface Exporter : GLib.Object {
                                         bool overwrite,
                                         GLib.Cancellable? cancellable) throws GLib.Error {
 
-               uchar[] bytes = yield this.export(cancellable);
+               uchar[] bytes;
                GLib.File out = file;
 
+               bytes = yield this.export(cancellable);
+
                /*
                 * When not trying to overwrite we pass an invalid etag. This way
                 * if the file exists, it will not match the etag, and we'll be
diff --git a/libseahorse/seahorse-application.c b/libseahorse/seahorse-application.c
index a799cad..e76a171 100644
--- a/libseahorse/seahorse-application.c
+++ b/libseahorse/seahorse-application.c
@@ -30,7 +30,6 @@
 #include "gkr/seahorse-gkr.h"
 #include "pgp/seahorse-pgp.h"
 #include "ssh/seahorse-ssh.h"
-#include "pkcs11/seahorse-pkcs11.h"
 
 #include "seahorse-search-provider.h"
 
@@ -91,6 +90,10 @@ seahorse_application_finalize (GObject *gobject)
        G_OBJECT_CLASS (seahorse_application_parent_class)->finalize (gobject);
 }
 
+#ifdef WITH_PKCS11
+void seahorse_pkcs11_backend_initialize (void);
+#endif
+
 static void
 seahorse_application_startup (GApplication *application)
 {
diff --git a/libseahorse/seahorse-util.h b/libseahorse/seahorse-util.h
index 103c576..29d0fcb 100644
--- a/libseahorse/seahorse-util.h
+++ b/libseahorse/seahorse-util.h
@@ -33,8 +33,6 @@
 
 typedef guint64 SeahorseVersion;
 
-#define SEAHORSE_BAD_FILENAME_CHARS  "/\\<>|:?;"
-
 gchar*      seahorse_util_get_date_string           (const time_t time);
 gchar*      seahorse_util_get_display_date_string   (const time_t time);
 
diff --git a/pgp/seahorse-gpgme-exporter.c b/pgp/seahorse-gpgme-exporter.c
index 9ee3e65..78a7054 100644
--- a/pgp/seahorse-gpgme-exporter.c
+++ b/pgp/seahorse-gpgme-exporter.c
@@ -72,8 +72,9 @@ G_DEFINE_TYPE_WITH_CODE (SeahorseGpgmeExporter, seahorse_gpgme_exporter, G_TYPE_
 );
 
 static gchar *
-calc_filename (SeahorseGpgmeExporter *self)
+seahorse_gpgme_exporter_get_filename (SeahorseExporter* exporter)
 {
+       SeahorseGpgmeExporter *self = SEAHORSE_GPGME_EXPORTER (exporter);
        const gchar *basename = NULL;
        gchar *filename;
 
@@ -97,8 +98,9 @@ calc_filename (SeahorseGpgmeExporter *self)
 }
 
 static const gchar *
-calc_content_type (SeahorseGpgmeExporter *self)
+seahorse_gpgme_exporter_get_content_type (SeahorseExporter* exporter)
 {
+       SeahorseGpgmeExporter *self = SEAHORSE_GPGME_EXPORTER (exporter);
        if (self->armor)
                return "application/pgp-keys";
        else
@@ -106,8 +108,9 @@ calc_content_type (SeahorseGpgmeExporter *self)
 }
 
 static GtkFileFilter *
-calc_file_filter (SeahorseGpgmeExporter *self)
+seahorse_gpgme_exporter_get_file_filter (SeahorseExporter* exporter)
 {
+       SeahorseGpgmeExporter *self = SEAHORSE_GPGME_EXPORTER (exporter);
        GtkFileFilter *filter = gtk_file_filter_new ();
 
        if (self->armor) {
@@ -137,16 +140,17 @@ seahorse_gpgme_exporter_get_property (GObject *object,
                                       GParamSpec *pspec)
 {
        SeahorseGpgmeExporter *self = SEAHORSE_GPGME_EXPORTER (object);
+       SeahorseExporter *exporter = SEAHORSE_EXPORTER (object);
 
        switch (prop_id) {
        case PROP_FILENAME:
-               g_value_take_string (value, calc_filename (self));
+               g_value_take_string (value, seahorse_gpgme_exporter_get_filename (exporter));
                break;
        case PROP_CONTENT_TYPE:
-               g_value_set_string (value, calc_content_type (self));
+               g_value_set_string (value, seahorse_gpgme_exporter_get_content_type (exporter));
                break;
        case PROP_FILE_FILTER:
-               g_value_take_object (value, calc_file_filter (self));
+               g_value_take_object (value, seahorse_gpgme_exporter_get_file_filter (exporter));
                break;
        case PROP_ARMOR:
                g_value_set_boolean (value, self->armor);
@@ -171,6 +175,9 @@ seahorse_gpgme_exporter_set_property (GObject *object,
        switch (prop_id) {
        case PROP_ARMOR:
                self->armor = g_value_get_boolean (value);
+               g_object_notify (G_OBJECT (self), "filename");
+               g_object_notify (G_OBJECT (self), "file-filter");
+               g_object_notify (G_OBJECT (self), "content-type");
                break;
        case PROP_SECRET:
                self->secret = g_value_get_boolean (value);
@@ -233,6 +240,7 @@ seahorse_gpgme_exporter_add_object (SeahorseExporter *exporter,
                        return FALSE;
 
                self->objects = g_list_append (self->objects, g_object_ref (key));
+               g_object_notify (G_OBJECT (self), "filename");
                return TRUE;
        }
 
@@ -401,6 +409,9 @@ seahorse_gpgme_exporter_iface_init (SeahorseExporterIface *iface)
        iface->export = seahorse_gpgme_exporter_export_async;
        iface->export_finish = seahorse_gpgme_exporter_export_finish;
        iface->get_objects = seahorse_gpgme_exporter_get_objects;
+       iface->get_filename = seahorse_gpgme_exporter_get_filename;
+       iface->get_content_type = seahorse_gpgme_exporter_get_content_type;
+       iface->get_file_filter = seahorse_gpgme_exporter_get_file_filter;
 }
 
 SeahorseExporter *
diff --git a/pgp/seahorse-gpgme-key.c b/pgp/seahorse-gpgme-key.c
index e3c726d..9566423 100644
--- a/pgp/seahorse-gpgme-key.c
+++ b/pgp/seahorse-gpgme-key.c
@@ -593,10 +593,19 @@ seahorse_gpgme_key_create_exporters (SeahorseExportable *exportable,
        return result;
 }
 
+static gboolean
+seahorse_gpgme_key_get_exportable (SeahorseExportable *exportable)
+{
+       gboolean can;
+       g_object_get (exportable, "exportable", &can, NULL);
+       return can;
+}
+
 static void
 seahorse_gpgme_key_exportable_iface (SeahorseExportableIface *iface)
 {
        iface->create_exporters = seahorse_gpgme_key_create_exporters;
+       iface->get_exportable = seahorse_gpgme_key_get_exportable;
 }
 
 /* -----------------------------------------------------------------------------
diff --git a/pkcs11/.gitignore b/pkcs11/.gitignore
index dbccd65..7b2d02c 100644
--- a/pkcs11/.gitignore
+++ b/pkcs11/.gitignore
@@ -1,3 +1,6 @@
 /.*
 /Makefile.in
 /Makefile
+/*.c
+!/seahorse-*.c
+/seahorse-pkcs11.h
diff --git a/pkcs11/Makefile.am b/pkcs11/Makefile.am
index 6ea55a9..5d61c6d 100644
--- a/pkcs11/Makefile.am
+++ b/pkcs11/Makefile.am
@@ -1,3 +1,4 @@
+NULL =
 
 uidir = $(datadir)/seahorse/ui/
 localedir = $(datadir)/locale
@@ -13,11 +14,31 @@ INCLUDES = -I$(top_builddir) \
        -DEXECDIR=\""$(seahorselibexecbindir)"\" \
        -DGETTEXT_PACKAGE=\""seahorse\""
 
-noinst_LTLIBRARIES = libseahorse-pkcs11.la
+noinst_LTLIBRARIES = \
+       libvala-code.la \
+       libseahorse-pkcs11.la
+
+AM_VALAFLAGS = \
+       $(VALA_FLAGS) \
+       --use-header \
+       --header=seahorse-pkcs11.h \
+       --vapidir $(top_builddir)/common \
+       --pkg common \
+       --pkg gtk+-3.0 \
+       --pkg gcr-3 \
+       $(NULL)
+
+libvala_code_la_SOURCES = \
+       certificate-der-exporter.vala \
+       pkcs11-module.vala \
+       $(NULL)
+
+libvala_code_la_CFLAGS = \
+       -include config.h -w \
+       $(NULL)
 
 libseahorse_pkcs11_la_SOURCES = \
        seahorse-certificate.c seahorse-certificate.h \
-       seahorse-certificate-der-exporter.c seahorse-certificate-der-exporter.h \
        seahorse-pkcs11-backend.c seahorse-pkcs11-backend.h \
        seahorse-pkcs11-deleter.c seahorse-pkcs11-deleter.h \
        seahorse-pkcs11-helpers.c seahorse-pkcs11-helpers.h \
@@ -25,13 +46,13 @@ libseahorse_pkcs11_la_SOURCES = \
        seahorse-pkcs11-key-deleter.c seahorse-pkcs11-key-deleter.h \
        seahorse-pkcs11-properties.c seahorse-pkcs11-properties.h \
        seahorse-pkcs11-request.c seahorse-pkcs11-request.h \
-       seahorse-pkcs11.c seahorse-pkcs11.h \
        seahorse-private-key.c seahorse-private-key.h \
        seahorse-token.c seahorse-token.h
 
 libseahorse_pkcs11_la_LIBADD = \
        $(top_builddir)/common/libcommon.la \
        $(top_builddir)/libseahorse/libseahorse.la \
+       libvala-code.la \
        $(GCR_LIBS)
 
 ui_DATA = \
@@ -39,4 +60,6 @@ ui_DATA = \
        seahorse-pkcs11-request.xml
 
 EXTRA_DIST = \
-       $(ui_DATA)
+       $(ui_DATA) \
+       seahorse-pkcs11.h \
+       $(NULL)
diff --git a/pkcs11/certificate-der-exporter.vala b/pkcs11/certificate-der-exporter.vala
new file mode 100644
index 0000000..742b73a
--- /dev/null
+++ b/pkcs11/certificate-der-exporter.vala
@@ -0,0 +1,88 @@
+/*
+ * Seahorse
+ *
+ * Copyright (C) 2011 Collabora Ltd.
+ * Copyright (C) 2012 Stefan Walter
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 59 Temple Exporter, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Stef Walter <stefw collabora co uk>
+ */
+
+namespace Seahorse {
+
+public class CertificateDerExporter : GLib.Object, Exporter {
+       private Gcr.Certificate _certificate;
+       private GLib.List<weak GLib.Object> _objects;
+
+       public CertificateDerExporter(Gcr.Certificate certificate)
+       {
+               this._certificate = certificate;
+               this._objects.append(certificate);
+       }
+
+       public string filename {
+               owned get {
+                       string? label = null;
+                       if (this._certificate != null) {
+                               label = this._certificate.label;
+                               if (label == null)
+                                       label = this._certificate.description;
+                       }
+                       if (label == null)
+                               label = _("Certificate");
+
+                       string filename = label + ".crt";
+                       return filename.delimit(BAD_FILENAME_CHARS, '_');
+               }
+       }
+
+       public string content_type {
+               get { return "application/pkix-cert"; }
+       }
+
+       public Gtk.FileFilter file_filter {
+               owned get {
+                       var filter = new Gtk.FileFilter();
+                       filter.set_name(_("Certificates (DER encoded)"));
+                       filter.add_mime_type ("application/pkix-cert");
+                       filter.add_mime_type ("application/x-x509-ca-cert");
+                       filter.add_mime_type ("application/x-x509-user-cert");
+                       filter.add_pattern ("*.cer");
+                       filter.add_pattern ("*.crt");
+                       filter.add_pattern ("*.cert");
+
+                       return filter;
+
+               }
+       }
+
+       public unowned GLib.List<weak GLib.Object> get_objects() {
+               return this._objects;
+       }
+
+       public bool add_object(GLib.Object obj) {
+               return false;
+       }
+
+       public async uchar[] export(GLib.Cancellable? cancellable)
+                       throws GLib.Error {
+               return this._certificate.get_der_data();
+       }
+
+}
+
+}
\ No newline at end of file
diff --git a/pkcs11/pkcs11-module.vala b/pkcs11/pkcs11-module.vala
new file mode 100644
index 0000000..ec3e939
--- /dev/null
+++ b/pkcs11/pkcs11-module.vala
@@ -0,0 +1,29 @@
+/*
+ * Seahorse
+ *
+ * Copyright (C) 2011 Collabora Ltd.
+ * Copyright (C) 2012 Stefan Walter
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 59 Temple Exporter, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Stef Walter <stefw collabora co uk>
+ */
+
+namespace Seahorse {
+
+public const string PKCS11_NAME = "pkcs11";
+
+}
\ No newline at end of file
diff --git a/pkcs11/seahorse-certificate.c b/pkcs11/seahorse-certificate.c
index 5898823..42f775e 100644
--- a/pkcs11/seahorse-certificate.c
+++ b/pkcs11/seahorse-certificate.c
@@ -23,7 +23,6 @@
 #include "config.h"
 
 #include "seahorse-certificate.h"
-#include "seahorse-certificate-der-exporter.h"
 #include "seahorse-pkcs11.h"
 #include "seahorse-pkcs11-deleter.h"
 #include "seahorse-pkcs11-helpers.h"
@@ -354,21 +353,30 @@ static GList *
 seahorse_certificate_create_exporters (SeahorseExportable *exportable,
                                        SeahorseExporterType type)
 {
-       SeahorseExporter *exporter;
+       SeahorseCertificateDerExporter *exporter;
        gboolean can_export = FALSE;
 
        g_object_get (exportable, "exportable", &can_export, NULL);
        if (!can_export)
                return NULL;
 
-       exporter = seahorse_certificate_der_exporter_new (SEAHORSE_CERTIFICATE (exportable));
+       exporter = seahorse_certificate_der_exporter_new (GCR_CERTIFICATE (exportable));
        return g_list_append (NULL, exporter);
 }
 
+static gboolean
+seahorse_certificate_get_exportable (SeahorseExportable *exportable)
+{
+       gboolean can;
+       g_object_get (exportable, "exportable", &can, NULL);
+       return can;
+}
+
 static void
 seahorse_certificate_exportable_iface (SeahorseExportableIface *iface)
 {
        iface->create_exporters = seahorse_certificate_create_exporters;
+       iface->get_exportable = seahorse_certificate_get_exportable;
 }
 
 static SeahorseDeleter *
diff --git a/pkcs11/seahorse-pkcs11-backend.c b/pkcs11/seahorse-pkcs11-backend.c
index 749b58e..ccac03c 100644
--- a/pkcs11/seahorse-pkcs11-backend.c
+++ b/pkcs11/seahorse-pkcs11-backend.c
@@ -21,6 +21,7 @@
 
 #include "config.h"
 
+#include "seahorse-pkcs11.h"
 #include "seahorse-pkcs11-backend.h"
 #include "seahorse-pkcs11-generate.h"
 #include "seahorse-token.h"
@@ -43,6 +44,8 @@ enum {
        PROP_ACTIONS
 };
 
+void  seahorse_pkcs11_backend_initialize (void);
+
 static SeahorsePkcs11Backend *pkcs11_backend = NULL;
 
 struct _SeahorsePkcs11Backend {
diff --git a/pkcs11/seahorse-private-key.c b/pkcs11/seahorse-private-key.c
index 5d63c5d..ff90a6b 100644
--- a/pkcs11/seahorse-private-key.c
+++ b/pkcs11/seahorse-private-key.c
@@ -323,10 +323,19 @@ seahorse_private_key_create_exporters (SeahorseExportable *exportable,
        return NULL;
 }
 
+static gboolean
+seahorse_private_key_get_exportable (SeahorseExportable *exportable)
+{
+       gboolean can;
+       g_object_get (exportable, "exportable", &can, NULL);
+       return can;
+}
+
 static void
 seahorse_private_key_exportable_iface (SeahorseExportableIface *iface)
 {
        iface->create_exporters = seahorse_private_key_create_exporters;
+       iface->get_exportable = seahorse_private_key_get_exportable;
 }
 
 static void
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 7f0d54c..cabf73b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -72,8 +72,8 @@ pgp/seahorse-signer.c
 pgp/seahorse-transfer.c
 pgp/seahorse-unknown.c
 pgp/seahorse-unknown-source.c
+pkcs11/certificate-der-exporter.vala
 pkcs11/seahorse-certificate.c
-pkcs11/seahorse-certificate-der-exporter.c
 pkcs11/seahorse-pkcs11-backend.c
 pkcs11/seahorse-pkcs11-deleter.c
 pkcs11/seahorse-pkcs11-generate.c
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 6d561c7..73df9ba 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -1,2 +1,3 @@
 common/seahorse-exportable.c
+pkcs11/certificate-der-exporter.c
 src/seahorse.desktop.in
diff --git a/ssh/seahorse-ssh-exporter.c b/ssh/seahorse-ssh-exporter.c
index ebab76f..b3d4fa1 100644
--- a/ssh/seahorse-ssh-exporter.c
+++ b/ssh/seahorse-ssh-exporter.c
@@ -68,8 +68,9 @@ G_DEFINE_TYPE_WITH_CODE (SeahorseSshExporter, seahorse_ssh_exporter, G_TYPE_OBJE
 );
 
 static gchar *
-calc_filename (SeahorseSshExporter *self)
+seahorse_ssh_exporter_get_filename (SeahorseExporter *exporter)
 {
+       SeahorseSshExporter *self = SEAHORSE_SSH_EXPORTER (exporter);
        SeahorseSSHKeyData *data;
        const gchar *location = NULL;
        const gchar *basename = NULL;
@@ -105,8 +106,9 @@ calc_filename (SeahorseSshExporter *self)
 }
 
 static const gchar *
-calc_content_type (SeahorseSshExporter *self)
+seahorse_ssh_exporter_get_content_type (SeahorseExporter *exporter)
 {
+       SeahorseSshExporter *self = SEAHORSE_SSH_EXPORTER (exporter);
        if (self->secret)
                return "application/x-pem-key";
        else
@@ -114,8 +116,9 @@ calc_content_type (SeahorseSshExporter *self)
 }
 
 static GtkFileFilter *
-calc_file_filter (SeahorseSshExporter *self)
+seahorse_ssh_exporter_get_file_filter (SeahorseExporter *exporter)
 {
+       SeahorseSshExporter *self = SEAHORSE_SSH_EXPORTER (exporter);
        GtkFileFilter *filter = gtk_file_filter_new ();
 
        if (self->secret) {
@@ -144,16 +147,17 @@ seahorse_ssh_exporter_get_property (GObject *object,
                                       GParamSpec *pspec)
 {
        SeahorseSshExporter *self = SEAHORSE_SSH_EXPORTER (object);
+       SeahorseExporter *exporter = SEAHORSE_EXPORTER (object);
 
        switch (prop_id) {
        case PROP_FILENAME:
-               g_value_take_string (value, calc_filename (self));
+               g_value_take_string (value, seahorse_ssh_exporter_get_filename (exporter));
                break;
        case PROP_CONTENT_TYPE:
-               g_value_set_string (value, calc_content_type (self));
+               g_value_set_string (value, seahorse_ssh_exporter_get_content_type (exporter));
                break;
        case PROP_FILE_FILTER:
-               g_value_take_object (value, calc_file_filter (self));
+               g_value_take_object (value, seahorse_ssh_exporter_get_file_filter (exporter));
                break;
        case PROP_SECRET:
                g_value_set_boolean (value, self->secret);
@@ -175,6 +179,9 @@ seahorse_ssh_exporter_set_property (GObject *object,
        switch (prop_id) {
        case PROP_SECRET:
                self->secret = g_value_get_boolean (value);
+               g_object_notify (G_OBJECT (self), "filename");
+               g_object_notify (G_OBJECT (self), "filter");
+               g_object_notify (G_OBJECT (self), "content-type");
                break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -234,6 +241,7 @@ seahorse_ssh_exporter_add_object (SeahorseExporter *exporter,
                }
                self->key = g_object_ref (key);
                self->objects = g_list_append (self->objects, self->key);
+               g_object_notify (G_OBJECT (self), "filename");
                return TRUE;
        }
 
@@ -302,6 +310,9 @@ seahorse_ssh_exporter_iface_init (SeahorseExporterIface *iface)
        iface->export = seahorse_ssh_exporter_export_async;
        iface->export_finish = seahorse_ssh_exporter_export_finish;
        iface->get_objects = seahorse_ssh_exporter_get_objects;
+       iface->get_filename = seahorse_ssh_exporter_get_filename;
+       iface->get_content_type = seahorse_ssh_exporter_get_content_type;
+       iface->get_file_filter = seahorse_ssh_exporter_get_file_filter;
 }
 
 SeahorseExporter *
diff --git a/ssh/seahorse-ssh-key.c b/ssh/seahorse-ssh-key.c
index f38c576..b1914a4 100644
--- a/ssh/seahorse-ssh-key.c
+++ b/ssh/seahorse-ssh-key.c
@@ -315,10 +315,19 @@ seahorse_ssh_key_create_exporters (SeahorseExportable *exportable,
        return g_list_append (NULL, seahorse_ssh_exporter_new (G_OBJECT (exportable), FALSE));
 }
 
+static gboolean
+seahorse_ssh_key_get_exportable (SeahorseExportable *exportable)
+{
+       gboolean can;
+       g_object_get (exportable, "exportable", &can, NULL);
+       return can;
+}
+
 static void
 seahorse_ssh_key_exportable_iface (SeahorseExportableIface *iface)
 {
        iface->create_exporters = seahorse_ssh_key_create_exporters;
+       iface->get_exportable = seahorse_ssh_key_get_exportable;
 }
 
 static SeahorseDeleter *


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