seahorse r2270 - in trunk: . daemon gkr libseahorse pgp src ssh
- From: nnielsen svn gnome org
- To: svn-commits-list gnome org
- Subject: seahorse r2270 - in trunk: . daemon gkr libseahorse pgp src ssh
- Date: Tue, 15 Jul 2008 22:44:48 +0000 (UTC)
Author: nnielsen
Date: Tue Jul 15 22:44:47 2008
New Revision: 2270
URL: http://svn.gnome.org/viewvc/seahorse?rev=2270&view=rev
Log:
* daemon/Makefile.am:
* daemon/seahorse-daemon.c:
* daemon/seahorse-service.c:
* gkr/seahorse-gkeyring-item.c:
* gkr/seahorse-gkeyring-operation.h:
* libseahorse/libseahorse-c.vapi:
* libseahorse/Makefile.am:
* libseahorse/seahorse-context.c:
* libseahorse/seahorse-keyserver-control.c:
* libseahorse/seahorse-prefs.c:
* libseahorse/seahorse-servers.vala: (added)
* pgp/seahorse-hkp-source.c:
* pgp/seahorse-ldap-source.c:
* pgp/seahorse-server-source.c:
* pgp/seahorse-server-source.h:
* src/main.c:
* src/seahorse-key-manager-store.c:
* src/seahorse-keyserver-search.c:
* src/seahorse-keyserver-sync.c:
* configure.in:
* Makefile.am: Further decouple seahorse from PGP. Implement a place
where modules can register server uri validation functions.
* libseahorse/seahorse-dns-sd.c:
* libseahorse/seahorse-util.c:
* pgp/seahorse-pgp-key-properties.c:
* pgp/seahorse-pgp-photos.c:
* ssh/seahorse-ssh-key-properties.c: Fix compile warnings
Added:
trunk/libseahorse/seahorse-servers.c
- copied, changed from r2249, /trunk/pgp/seahorse-server-source.c
trunk/libseahorse/seahorse-servers.h
- copied, changed from r2249, /trunk/pgp/seahorse-server-source.h
trunk/libseahorse/seahorse-servers.vala
Modified:
trunk/ChangeLog
trunk/Makefile.am
trunk/configure.in
trunk/daemon/Makefile.am
trunk/daemon/seahorse-daemon.c
trunk/daemon/seahorse-service.c
trunk/gkr/seahorse-gkeyring-item.c
trunk/gkr/seahorse-gkeyring-operation.h
trunk/gkr/vala-build.stamp
trunk/libseahorse/Makefile.am
trunk/libseahorse/libseahorse-c.vapi
trunk/libseahorse/libseahorse.gidl
trunk/libseahorse/libseahorse.vapi
trunk/libseahorse/seahorse-context.c
trunk/libseahorse/seahorse-dns-sd.c
trunk/libseahorse/seahorse-keyserver-control.c
trunk/libseahorse/seahorse-prefs.c
trunk/libseahorse/seahorse-util.c
trunk/libseahorse/vala-build.stamp
trunk/pgp/seahorse-hkp-source.c
trunk/pgp/seahorse-ldap-source.c
trunk/pgp/seahorse-pgp-key-properties.c
trunk/pgp/seahorse-pgp-photos.c
trunk/pgp/seahorse-server-source.c
trunk/pgp/seahorse-server-source.h
trunk/pgp/vala-build.stamp
trunk/src/Makefile.am
trunk/src/main.c
trunk/src/seahorse-key-manager-store.c
trunk/src/seahorse-keyserver-search.c
trunk/src/seahorse-keyserver-sync.c
trunk/src/vala-build.stamp
trunk/ssh/seahorse-ssh-key-properties.c
trunk/ssh/vala-build.stamp
Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am (original)
+++ trunk/Makefile.am Tue Jul 15 22:44:47 2008
@@ -8,12 +8,18 @@
SSH_DIR =
endif
+if WITH_PGP
+PGP_DIR = pgp
+else
+PGP_DIR =
+endif
+
SUBDIRS = libegg \
libcryptui \
common \
libseahorse \
gkr \
- pgp \
+ $(PGP_DIR) \
$(SSH_DIR) \
src \
po \
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Tue Jul 15 22:44:47 2008
@@ -83,94 +83,117 @@
fi
AC_SUBST(PLUGIN_LIBTOOL_FLAGS)
-dnl *********************
-dnl Accepted GPG versions
-dnl *********************
-AC_ARG_ENABLE(gpg-check,
- AC_HELP_STRING([--disable-gpg-check], [check GPG version (default is yes)]),
- DO_CHECK=$enableval, DO_CHECK=yes)
+dnl **************************************************************
+dnl GPG / GPGME CHECKS
+dnl **************************************************************
+
+AC_ARG_ENABLE(pgp,
+ AC_HELP_STRING([--enable-pgp], [enable PGP support (default is auto)]))
-if test "$DO_CHECK" = "yes"; then
- accepted_versions="1.2 1.4 2.0"
- AC_PATH_PROG(GNUPG, gpg, no)
- ok="no"
- if test "$GNUPG" != "no"; then
- AC_MSG_CHECKING(for appropriate GnuPG version)
- gnupg_version=`$GNUPG --version | grep gpg`
- major=`echo $gnupg_version | \
- sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
- minor=`echo $gnupg_version | \
- sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
- micro=`echo $gnupg_version | \
- sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
-
- for ver in $accepted_versions; do
- if test "$ver" = "$major.$minor"; then
- AC_DEFINE_UNQUOTED(GPG_MAJOR, [$major], [GPG Major Version])
- AC_DEFINE_UNQUOTED(GPG_MINOR, [$minor], [GPG Minor Version])
- ok="yes"
- break
- fi
- done
+have_gpg=""
+have_gpgme=""
+
+if test "$enable_pgp" = "no"; then
+ echo "disabling PGP support"
+else
+ AC_ARG_ENABLE(gpg-check,
+ AC_HELP_STRING([--disable-gpg-check], [check GPG version (default is yes)]),
+ DO_CHECK=$enableval, DO_CHECK=yes)
+
+ if test "$DO_CHECK" = "yes"; then
+ accepted_versions="1.2 1.4 2.0"
+ AC_PATH_PROG(GNUPG, gpg, no)
+ ok="no"
+ if test "$GNUPG" != "no"; then
+ AC_MSG_CHECKING(for appropriate GnuPG version)
+ gnupg_version=`$GNUPG --version | grep gpg`
+ major=`echo $gnupg_version | \
+ sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
+ minor=`echo $gnupg_version | \
+ sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
+ micro=`echo $gnupg_version | \
+ sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
- fi
+ for ver in $accepted_versions; do
+ if test "$ver" = "$major.$minor"; then
+ AC_DEFINE_UNQUOTED(GPG_MAJOR, [$major], [GPG Major Version])
+ AC_DEFINE_UNQUOTED(GPG_MINOR, [$minor], [GPG Minor Version])
+ ok="yes"
+ break
+ fi
+ done
+ fi
- if test "$ok" = "yes"; then
- AC_MSG_RESULT([yes])
- else
- AC_MSG_ERROR([Appropriate version of GnuPG not found. Please install one of versions: $accepted_versions])
- fi
+ if test "$ok" = "yes"; then
+ AC_MSG_RESULT([yes])
+ have_gpg="$gnupg_version"
+ else
+ AC_MSG_RESULT([no])
+ fi
+ fi
-fi
+ ok="no"
+ min_gpgme_version=1.0.0
+ AC_PATH_PROG(GPGME_CONFIG, gpgme-config, "failed")
+ if test $GPGME_CONFIG != "failed" ; then
+ AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version)
+ req_major=`echo $min_gpgme_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
+ req_minor=`echo $min_gpgme_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
+ req_micro=`echo $min_gpgme_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
+ gpgme_config_version=`$GPGME_CONFIG --version`
+ major=`echo $gpgme_config_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
+ minor=`echo $gpgme_config_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
+ micro=`echo $gpgme_config_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
+
+ if test "$major" -eq "$req_major"; then
+ if test "$minor" -ge "$req_minor"; then
+ if test "$micro" -ge "$req_micro"; then
+ ok="yes"
+ fi
+ fi
+ fi
+ fi
-dnl **********
-dnl GPGME
-dnl **********
-
-ok="no"
-min_gpgme_version=1.0.0
-AC_PATH_PROG(GPGME_CONFIG, gpgme-config, "failed")
-if test $GPGME_CONFIG != "failed" ; then
- AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version)
- req_major=`echo $min_gpgme_version | \
- sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
- req_minor=`echo $min_gpgme_version | \
- sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
- req_micro=`echo $min_gpgme_version | \
- sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
- gpgme_config_version=`$GPGME_CONFIG --version`
- major=`echo $gpgme_config_version | \
- sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
- minor=`echo $gpgme_config_version | \
- sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
- micro=`echo $gpgme_config_version | \
- sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
-
- if test "$major" -eq "$req_major"; then
- if test "$minor" -ge "$req_minor"; then
- if test "$micro" -ge "$req_micro"; then
- ok="yes"
- fi
- fi
+ if test $ok = "yes"; then
+ GPGME_CFLAGS=`$GPGME_CONFIG --cflags`
+ GPGME_LIBS=`$GPGME_CONFIG --libs`
+ AC_MSG_RESULT(yes)
+ have_gpgme="$gpgme_config_version"
+ else
+ AC_MSG_RESULT(no)
fi
fi
-if test $ok = "yes"; then
- GPGME_CFLAGS=`$GPGME_CONFIG --cflags`
- GPGME_LIBS=`$GPGME_CONFIG --libs`
- AC_MSG_RESULT(yes)
-else
- AC_MSG_ERROR(GPGME $min_gpgme_version or later needed)
+if test "$enable_pgp" != "no" -a -n "$have_gpg" -a -n "$have_gpgme"; then
+ enable_pgp="yes"
fi
-SEAHORSE_CFLAGS="$SEAHORSE_CFLAGS $GPGME_CFLAGS -O0"
-SEAHORSE_LIBS="$SEAHORSE_LIBS $GPGME_LIBS"
+if test "$enable_pgp" = "yes"; then
+ if test -z "$have_gpg"; then
+ AC_MSG_ERROR([Appropriate version of GnuPG not found. Please install one of versions: $accepted_versions])
+ fi
+
+ if test -z "$have_gpgme"; then
+ AC_MSG_ERROR(GPGME $min_gpgme_version or later needed)
+ fi
+ SEAHORSE_CFLAGS="$SEAHORSE_CFLAGS $GPGME_CFLAGS -O0"
+ SEAHORSE_LIBS="$SEAHORSE_LIBS $GPGME_LIBS"
+ AC_DEFINE(WITH_PGP, 1, [With PGP Support])
+fi
-dnl ***************
+AM_CONDITIONAL(WITH_PGP, test "$enable_pgp" == "yes")
+
+dnl ******************************************************************************
dnl LDAP [from gpg]
-dnl ***************
+dnl ******************************************************************************
AC_MSG_CHECKING([LDAP keyserver support])
AC_ARG_ENABLE(ldap,
@@ -313,9 +336,14 @@
AC_HELP_STRING([--disable-sharing],
[Don't compile in DNS-SD key sharing]))
-if test "$enable_hkp" != "yes"; then
- echo "DNS-SD key sharing requires HKP support"
- enable_sharing=no
+if test "$enable_pgp" != "no"; then
+ echo "DNS-SD key sharing requires PGP support"
+ enable_sharing=no
+fi
+
+if test "$enable_hkp" = "no"; then
+ echo "DNS-SD key sharing requires HKP support"
+ enable_sharing=no
fi
if test "$enable_sharing" = "no"; then
@@ -531,8 +559,9 @@
dnl ****************************************************************************
echo "
-GnuPG Version: $gnupg_version
-GPGME Version: $gpgme_config_version
+PGP Support: $enable_pgp
+ GnuPG Version: $have_gpg
+ GPGME Version: $have_gpgme
SSH Support: $enable_ssh
Keyserver Support: $with_keyserver
LDAP: $with_ldap
Modified: trunk/daemon/Makefile.am
==============================================================================
--- trunk/daemon/Makefile.am (original)
+++ trunk/daemon/Makefile.am Tue Jul 15 22:44:47 2008
@@ -27,16 +27,32 @@
SHARING_SRCS =
endif
+if WITH_PGP
+PGP_LDADD = $(top_builddir)/pgp/libseahorse-pgp.la
+PGP_SRCS = seahorse-service-crypto.c
+else
+PGP_LDADD =
+PGP_SRCS =
+endif
+
+if WITH_SSH
+SSH_LDADD = $(top_builddir)/ssh/libseahorse-ssh.la
+else
+SSH_LDADD =
+endif
+
seahorse_daemon_SOURCES = \
seahorse-daemon.c seahorse-daemon.h \
seahorse-dbus-server.c seahorse-service.c seahorse-service.h \
- seahorse-service-keyset.c seahorse-service-crypto.c \
+ seahorse-service-keyset.c \
+ $(PGP_SRCS) \
$(SHARING_SRCS)
+
seahorse_daemon_LDADD = \
$(top_builddir)/libseahorse/libseahorse.la \
- $(top_builddir)/pgp/libseahorse-pgp.la \
- $(top_builddir)/ssh/libseahorse-ssh.la \
+ $(PGP_LDADD) \
+ $(SSH_LDADD) \
$(top_builddir)/common/libseahorse-common.la \
$(top_builddir)/libcryptui/libcryptui.la \
$(top_builddir)/libegg/libeggdatetime.la \
Modified: trunk/daemon/seahorse-daemon.c
==============================================================================
--- trunk/daemon/seahorse-daemon.c (original)
+++ trunk/daemon/seahorse-daemon.c Tue Jul 15 22:44:47 2008
@@ -31,7 +31,9 @@
#include "common/seahorse-cleanup.h"
#include "common/seahorse-registry.h"
+#ifdef WITH_PGP
#include "pgp/seahorse-pgp-module.h"
+#endif
#ifdef WITH_SSH
#include "ssh/seahorse-ssh-module.h"
@@ -210,8 +212,12 @@
seahorse_gtkstock_add_icons (daemon_icons);
/* Load the various components */
+#ifdef WITH_PGP
seahorse_registry_load_types (NULL, SEAHORSE_PGP_REGISTRY);
+#endif
+#ifdef WITH_SSH
seahorse_registry_load_types (NULL, SEAHORSE_SSH_REGISTRY);
+#endif
/* Make the default SeahorseContext */
seahorse_context_new (SEAHORSE_CONTEXT_APP | SEAHORSE_CONTEXT_DAEMON, 0);
Modified: trunk/daemon/seahorse-service.c
==============================================================================
--- trunk/daemon/seahorse-service.c (original)
+++ trunk/daemon/seahorse-service.c Tue Jul 15 22:44:47 2008
@@ -35,8 +35,6 @@
#include "seahorse-util.h"
#include "seahorse-libdialogs.h"
-#include "pgp/seahorse-gpgmex.h"
-
#include <gio/gio.h>
#define KEYSET_PATH "/org/gnome/seahorse/keys/%s"
Modified: trunk/gkr/seahorse-gkeyring-item.c
==============================================================================
--- trunk/gkr/seahorse-gkeyring-item.c (original)
+++ trunk/gkr/seahorse-gkeyring-item.c Tue Jul 15 22:44:47 2008
@@ -33,7 +33,9 @@
#include "seahorse-secure-memory.h"
/* For gnome-keyring secret type ids */
+#ifdef WITH_PGP
#include "pgp/seahorse-pgp-key.h"
+#endif
#ifdef WITH_SSH
#include "ssh/seahorse-ssh-key.h"
#endif
@@ -581,11 +583,13 @@
if (git->attributes) {
val = seahorse_gkeyring_item_get_attribute (git, "seahorse-key-type");
if (val) {
- if (strcmp (val, SEAHORSE_PGP_STR) == 0)
- return SEAHORSE_GKEYRING_USE_PGP;
+#ifdef WITH_PGP
+ if (strcmp (val, SEAHORSE_PGP_STR) == 0)
+ return SEAHORSE_GKEYRING_USE_PGP;
+#endif
#ifdef WITH_SSH
- if (strcmp (val, SEAHORSE_SSH_STR) == 0)
- return SEAHORSE_GKEYRING_USE_SSH;
+ if (strcmp (val, SEAHORSE_SSH_STR) == 0)
+ return SEAHORSE_GKEYRING_USE_SSH;
#endif
}
}
Modified: trunk/gkr/seahorse-gkeyring-operation.h
==============================================================================
--- trunk/gkr/seahorse-gkeyring-operation.h (original)
+++ trunk/gkr/seahorse-gkeyring-operation.h Tue Jul 15 22:44:47 2008
@@ -20,7 +20,7 @@
*/
/**
- * SeahorsePGPOperation: Operations to be done on gnome-keyring items
+ * SeahorseGKeyringOperation: Operations to be done on gnome-keyring items
*
* - Derived from SeahorseOperation
*
Modified: trunk/gkr/vala-build.stamp
==============================================================================
--- trunk/gkr/vala-build.stamp (original)
+++ trunk/gkr/vala-build.stamp Tue Jul 15 22:44:47 2008
@@ -1 +1 @@
-1214713742
+1216160617
Modified: trunk/libseahorse/Makefile.am
==============================================================================
--- trunk/libseahorse/Makefile.am (original)
+++ trunk/libseahorse/Makefile.am Tue Jul 15 22:44:47 2008
@@ -16,9 +16,10 @@
-DLIBCRYPTUI_API_SUBJECT_TO_CHANGE
VALA_SRCS = \
- seahorse-view.vala \
seahorse-commands.vala \
- seahorse-generator.vala
+ seahorse-generator.vala \
+ seahorse-servers.vala \
+ seahorse-view.vala
VALA_PKGS = \
--vapidir . \
@@ -75,6 +76,7 @@
seahorse-notification.c \
seahorse-secure-memory.c seahorse-secure-memory.h \
seahorse-secure-entry.c seahorse-secure-entry.h \
+ seahorse-servers.c seahorse-servers.h \
seahorse-unix-signal.c seahorse-unix-signal.h \
$(MARSHAL_SRCS) \
$(VALA_CFILES) $(VALA_HFILES) \
Modified: trunk/libseahorse/libseahorse-c.vapi
==============================================================================
--- trunk/libseahorse/libseahorse-c.vapi (original)
+++ trunk/libseahorse/libseahorse-c.vapi Tue Jul 15 22:44:47 2008
@@ -184,8 +184,12 @@
[CCode (cname = "LISTING_SCHEMAS", cheader_filename = "seahorse-preferences.h")]
public const string LISTING_SCHEMAS;
+ [CCode (cname = "KEYSERVER_KEY", cheader_filename = "seahorse-gconf.h")]
+ public const string KEYSERVER_KEY;
+
public bool get_boolean (string key);
public void set_boolean (string key, bool value);
+ public GLib.SList<string> get_string_list (string key);
public void notify_lazy (string key, GConf.ClientNotifyFunc func, Gtk.Object lifetime);
}
Modified: trunk/libseahorse/libseahorse.gidl
==============================================================================
--- trunk/libseahorse/libseahorse.gidl (original)
+++ trunk/libseahorse/libseahorse.gidl Tue Jul 15 22:44:47 2008
@@ -24,6 +24,48 @@
<object name="Generator" parent="GLib.Object" type-name="SeahorseGenerator" get-type="seahorse_generator_get_type">
<property name="actions" type="Gtk.ActionGroup*" readable="1"/>
</object>
+ <object name="Servers" parent="GLib.Object" type-name="SeahorseServers" get-type="seahorse_servers_get_type">
+ <method name="get_types" symbol="seahorse_servers_get_types">
+ <parameters>
+ </parameters>
+ <return-type type="GLib.SList*" transfer="full"/>
+ </method>
+ <method name="get_description" symbol="seahorse_servers_get_description">
+ <parameters>
+ <parameter name="type" type="const char*"/>
+ </parameters>
+ <return-type type="string*" transfer="full"/>
+ </method>
+ <method name="register_type" symbol="seahorse_servers_register_type">
+ <parameters>
+ <parameter name="type" type="const char*"/>
+ <parameter name="description" type="const char*"/>
+ <parameter name="validate" type="Seahorse.ValidUriFunc"/>
+ </parameters>
+ <return-type type="void"/>
+ </method>
+ <method name="get_uris" symbol="seahorse_servers_get_uris">
+ <parameters>
+ </parameters>
+ <return-type type="GLib.SList*" transfer="full"/>
+ </method>
+ <method name="get_names" symbol="seahorse_servers_get_names">
+ <parameters>
+ </parameters>
+ <return-type type="GLib.SList*" transfer="full"/>
+ </method>
+ <method name="is_valid_uri" symbol="seahorse_servers_is_valid_uri">
+ <parameters>
+ <parameter name="uri" type="const char*"/>
+ </parameters>
+ <return-type type="bool" transfer="full"/>
+ </method>
+ <constructor name="new" symbol="seahorse_servers_new">
+ <parameters>
+ </parameters>
+ <return-type type="Seahorse.Servers*"/>
+ </constructor>
+ </object>
<interface name="SeahorseView" get-type="seahorse_view_get_type">
<requires>
<object name="GLib.Object"/>
@@ -57,5 +99,11 @@
<return-type type="void"/>
</signal>
</interface>
+ <callback name="SeahorseValidUriFunc">
+ <parameters>
+ <parameter name="uri" type="const char*"/>
+ </parameters>
+ <return-type type="bool" transfer="full"/>
+ </callback>
</namespace>
</api>
Modified: trunk/libseahorse/libseahorse.vapi
==============================================================================
--- trunk/libseahorse/libseahorse.vapi (original)
+++ trunk/libseahorse/libseahorse.vapi Tue Jul 15 22:44:47 2008
@@ -15,6 +15,16 @@
public abstract class Generator : GLib.Object {
public abstract Gtk.ActionGroup actions { get; }
}
+ [CCode (cheader_filename = "seahorse-servers.h")]
+ public class Servers : GLib.Object {
+ public static GLib.SList<string> get_types ();
+ public static string? get_description (string type);
+ public static void register_type (string type, string description, Seahorse.ValidUriFunc validate);
+ public static GLib.SList<string> get_uris ();
+ public static GLib.SList<string> get_names ();
+ public static bool is_valid_uri (string uri);
+ public Servers ();
+ }
[CCode (cheader_filename = "seahorse-view.h")]
public interface View : GLib.Object {
public abstract GLib.List<weak Seahorse.Key> get_selected_keys ();
@@ -25,4 +35,6 @@
public abstract Gtk.Window window { get; }
public signal void selection_changed ();
}
+ [CCode (cheader_filename = "seahorse-servers.h")]
+ public static delegate bool ValidUriFunc (string uri);
}
Modified: trunk/libseahorse/seahorse-context.c
==============================================================================
--- trunk/libseahorse/seahorse-context.c (original)
+++ trunk/libseahorse/seahorse-context.c Tue Jul 15 22:44:47 2008
@@ -27,18 +27,21 @@
#include <libintl.h>
#include "seahorse-context.h"
-#include "seahorse-marshal.h"
-#include "seahorse-libdialogs.h"
-#include "seahorse-gconf.h"
-#include "seahorse-util.h"
#include "seahorse-dns-sd.h"
+#include "seahorse-gconf.h"
+#include "seahorse-libdialogs.h"
+#include "seahorse-marshal.h"
+#include "seahorse-servers.h"
#include "seahorse-transfer-operation.h"
#include "seahorse-unknown-source.h"
#include "seahorse-unknown-key.h"
+#include "seahorse-util.h"
#include "common/seahorse-registry.h"
+#ifdef WITH_PGP
#include "pgp/seahorse-server-source.h"
+#endif
/* The application main context */
SeahorseContext* app_context = NULL;
@@ -821,6 +824,7 @@
SeahorseContext *sctx)
{
#ifdef WITH_KEYSERVER
+#ifdef WITH_PGP
SeahorseServerSource *ssrc;
GSList *keyservers, *l;
GHashTable *check;
@@ -838,8 +842,7 @@
/* Load and strip names from keyserver list */
- keyservers = seahorse_gconf_get_string_list (KEYSERVER_KEY);
- seahorse_server_source_purge_keyservers (keyservers);
+ keyservers = seahorse_servers_get_uris ();
for (l = keyservers; l; l = g_slist_next (l)) {
uri = (const gchar*)(l->data);
@@ -861,7 +864,8 @@
g_hash_table_foreach (check, (GHFunc)auto_source_remove, sctx);
g_hash_table_destroy (check);
- seahorse_util_string_slist_free (keyservers);
+ seahorse_util_string_slist_free (keyservers);
+#endif /* WITH_PGP */
#endif /* WITH_KEYSERVER */
}
Modified: trunk/libseahorse/seahorse-dns-sd.c
==============================================================================
--- trunk/libseahorse/seahorse-dns-sd.c (original)
+++ trunk/libseahorse/seahorse-dns-sd.c Tue Jul 15 22:44:47 2008
@@ -31,7 +31,9 @@
#include "seahorse-dns-sd.h"
#include "seahorse-context.h"
+#ifdef WITH_PGP
#include "pgp/seahorse-server-source.h"
+#endif
/* Override the DEBUG_DNSSD_ENABLE switch here */
/* #define DEBUG_DNSSD_ENABLE 1 */
@@ -80,6 +82,7 @@
*/
#ifdef WITH_SHARING
+#ifdef WITH_PGP
static void
disconnect (SeahorseServiceDiscovery *ssd)
@@ -221,6 +224,7 @@
}
}
+#endif /* WITH_PGP */
#endif /* WITH_SHARING */
static void
@@ -238,7 +242,9 @@
static void
seahorse_service_discovery_init (SeahorseServiceDiscovery *ssd)
{
+#ifdef WITH_SHARING
int aerr;
+#endif
ssd->priv = g_new0 (SeahorseServiceDiscoveryPriv, 1);
ssd->services = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
Modified: trunk/libseahorse/seahorse-keyserver-control.c
==============================================================================
--- trunk/libseahorse/seahorse-keyserver-control.c (original)
+++ trunk/libseahorse/seahorse-keyserver-control.c Tue Jul 15 22:44:47 2008
@@ -19,13 +19,12 @@
* Boston, MA 02111-1307, USA.
*/
-#include "seahorse-util.h"
#include "seahorse-context.h"
+#include "seahorse-gconf.h"
#include "seahorse-keyserver-control.h"
#include "seahorse-key.h"
-#include "seahorse-gconf.h"
-
-#include "pgp/seahorse-server-source.h"
+#include "seahorse-servers.h"
+#include "seahorse-util.h"
#define UPDATING "updating"
@@ -281,8 +280,7 @@
-1);
}
- ks = seahorse_gconf_get_string_list (KEYSERVER_KEY);
- ks = seahorse_server_source_purge_keyservers (ks);
+ ks = seahorse_servers_get_uris ();
for (l = ks; l != NULL; l = g_slist_next (l)) {
const gchar *keyserver = (const gchar *) l->data;
Modified: trunk/libseahorse/seahorse-prefs.c
==============================================================================
--- trunk/libseahorse/seahorse-prefs.c (original)
+++ trunk/libseahorse/seahorse-prefs.c Tue Jul 15 22:44:47 2008
@@ -22,20 +22,18 @@
#include <glib/gi18n.h>
-#include "seahorse-prefs.h"
-#include "seahorse-util.h"
#include "seahorse-check-button-control.h"
#include "seahorse-combo-keys.h"
-#include "seahorse-keyserver-control.h"
#include "seahorse-gconf.h"
#include "seahorse-gtkstock.h"
+#include "seahorse-keyserver-control.h"
+#include "seahorse-prefs.h"
#include "seahorse-secure-entry.h"
+#include "seahorse-servers.h"
+#include "seahorse-util.h"
#include "common/seahorse-registry.h"
-#include "pgp/seahorse-pgp-module.h"
-#include "pgp/seahorse-server-source.h"
-
/* From seahorse-prefs-cache.c */
void seahorse_prefs_cache (SeahorseWidget *widget);
@@ -63,7 +61,7 @@
GtkTreeIter iter;
gboolean ret;
- if (!seahorse_server_source_valid_uri (text)) {
+ if (!seahorse_servers_is_valid_uri (text)) {
seahorse_util_show_error (NULL, _("Not a valid Key Server address."),
_("For help contact your system adminstrator or the administrator of the key server." ));
return;
@@ -227,8 +225,6 @@
/* Change list of GConfValue to list of strings */
for (ks = NULL, l = gconf_value_get_list (value); l; l = l->next)
ks = g_slist_append (ks, (gchar*)gconf_value_get_string (l->data));
-
- ks = seahorse_server_source_purge_keyservers (ks);
populate_keyservers (swidget, ks);
g_slist_free (l); /* We don't own string values */
}
@@ -275,7 +271,7 @@
/* Custom URI? */
if (scheme == NULL) {
- if (seahorse_server_source_valid_uri (host))
+ if (seahorse_servers_is_valid_uri (host))
return g_strdup (host);
return NULL;
}
@@ -289,7 +285,7 @@
port = NULL;
uri = g_strdup_printf("%s://%s%s%s", scheme, host, port ? ":" : "", port ? port : "");
- if (!seahorse_server_source_valid_uri (uri)) {
+ if (!seahorse_servers_is_valid_uri (uri)) {
g_free (uri);
uri = NULL;
}
@@ -353,22 +349,26 @@
widget = glade_xml_get_widget (swidget->xml, "keyserver-type");
g_return_if_fail (widget != NULL);
- /* The list of types, plus the null 'custom' type */
- types = seahorse_server_source_get_types ();
- types = g_slist_append (types, g_strdup (""));
- g_object_set_data_full (G_OBJECT (swidget), "keyserver-types", types,
- (GDestroyNotify)seahorse_util_string_slist_free);
+ /* The list of types */
+ types = seahorse_servers_get_types ();
/* The description for the key server types, plus custom */
- descriptions = seahorse_server_source_get_descriptions ();
+ descriptions = NULL;
+ for (l = types; l; l = g_slist_next (l))
+ descriptions = g_slist_append (descriptions, seahorse_servers_get_description (l->data));
descriptions = g_slist_append (descriptions, g_strdup (_("Custom")));
gtk_combo_box_remove_text (GTK_COMBO_BOX (widget), 0);
for (l = descriptions; l; l = g_slist_next (l))
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), l->data);
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), l->data ? l->data : "");
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
seahorse_util_string_slist_free (descriptions);
+ /* Save these away for later */
+ types = g_slist_append (types, g_strdup (""));
+ g_object_set_data_full (G_OBJECT (swidget), "keyserver-types", types,
+ (GDestroyNotify)seahorse_util_string_slist_free);
+
glade_xml_signal_connect_data (swidget->xml, "on_uri_changed",
G_CALLBACK (uri_changed), swidget);
@@ -404,8 +404,7 @@
GSList *ks;
guint notify_id;
- ks = seahorse_gconf_get_string_list (KEYSERVER_KEY);
- ks = seahorse_server_source_purge_keyservers (ks);
+ ks = seahorse_servers_get_uris ();
populate_keyservers (swidget, ks);
seahorse_util_string_slist_free (ks);
@@ -482,6 +481,7 @@
seahorse_prefs_new (GtkWindow *parent)
{
SeahorseWidget *swidget;
+ GtkWidget *widget = NULL;
swidget = seahorse_widget_new ("prefs", parent);
Copied: trunk/libseahorse/seahorse-servers.c (from r2249, /trunk/pgp/seahorse-server-source.c)
==============================================================================
--- /trunk/pgp/seahorse-server-source.c (original)
+++ trunk/libseahorse/seahorse-servers.c Tue Jul 15 22:44:47 2008
@@ -1,530 +1,332 @@
-/*
- * Seahorse
- *
- * Copyright (C) 2004 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 Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <glib/gi18n.h>
-
-#include "seahorse-gpgmex.h"
-#include "seahorse-operation.h"
-#include "seahorse-ldap-source.h"
-#include "seahorse-hkp-source.h"
-#include "seahorse-server-source.h"
-#include "seahorse-util.h"
-#include "seahorse-pgp-key.h"
-
-enum {
- PROP_0,
- PROP_KEY_TYPE,
- PROP_KEY_DESC,
- PROP_LOCATION,
- PROP_KEY_SERVER,
- PROP_URI
+
+#include <seahorse-servers.h>
+#include <seahorse-gconf.h>
+
+
+#define SEAHORSE_SERVERS_TYPE_SERVER_INFO (seahorse_servers_server_info_get_type ())
+#define SEAHORSE_SERVERS_SERVER_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_SERVERS_TYPE_SERVER_INFO, SeahorseServersServerInfo))
+#define SEAHORSE_SERVERS_SERVER_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAHORSE_SERVERS_TYPE_SERVER_INFO, SeahorseServersServerInfoClass))
+#define SEAHORSE_SERVERS_IS_SERVER_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAHORSE_SERVERS_TYPE_SERVER_INFO))
+#define SEAHORSE_SERVERS_IS_SERVER_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAHORSE_SERVERS_TYPE_SERVER_INFO))
+#define SEAHORSE_SERVERS_SERVER_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAHORSE_SERVERS_TYPE_SERVER_INFO, SeahorseServersServerInfoClass))
+
+typedef struct _SeahorseServersServerInfo SeahorseServersServerInfo;
+typedef struct _SeahorseServersServerInfoClass SeahorseServersServerInfoClass;
+typedef struct _SeahorseServersServerInfoPrivate SeahorseServersServerInfoPrivate;
+
+struct _SeahorseServersServerInfo {
+ GTypeInstance parent_instance;
+ volatile int ref_count;
+ SeahorseServersServerInfoPrivate * priv;
+ char* type;
+ char* description;
+ SeahorseValidUriFunc validator;
};
-/* -----------------------------------------------------------------------------
- * SERVER SOURCE
- */
-
-struct _SeahorseServerSourcePrivate {
- SeahorseMultiOperation *mop;
- gchar *server;
- gchar *uri;
+struct _SeahorseServersServerInfoClass {
+ GTypeClass parent_class;
+ void (*finalize) (SeahorseServersServerInfo *self);
};
-G_DEFINE_TYPE (SeahorseServerSource, seahorse_server_source, SEAHORSE_TYPE_KEY_SOURCE);
-/* GObject handlers */
-static void seahorse_server_source_dispose (GObject *gobject);
-static void seahorse_server_source_finalize (GObject *gobject);
-static void seahorse_server_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
-static void seahorse_server_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-
-/* SeahorseKeySource methods */
-static void seahorse_server_source_stop (SeahorseKeySource *src);
-static guint seahorse_server_source_get_state (SeahorseKeySource *src);
-static SeahorseOperation* seahorse_server_source_load (SeahorseKeySource *src, GQuark keyid);
-
-static GObjectClass *parent_class = NULL;
-
-/* Initialize the basic class stuff */
-static void
-seahorse_server_source_class_init (SeahorseServerSourceClass *klass)
-{
- GObjectClass *gobject_class;
- SeahorseKeySourceClass *key_class;
-
- parent_class = g_type_class_peek_parent (klass);
- gobject_class = G_OBJECT_CLASS (klass);
-
- key_class = SEAHORSE_KEY_SOURCE_CLASS (klass);
-
- key_class->canonize_keyid = seahorse_pgp_key_get_cannonical_id;
- key_class->load = seahorse_server_source_load;
- key_class->stop = seahorse_server_source_stop;
- key_class->get_state = seahorse_server_source_get_state;
-
- gobject_class->dispose = seahorse_server_source_dispose;
- gobject_class->finalize = seahorse_server_source_finalize;
- gobject_class->set_property = seahorse_server_set_property;
- gobject_class->get_property = seahorse_server_get_property;
-
- g_object_class_install_property (gobject_class, PROP_KEY_TYPE,
- g_param_spec_uint ("key-type", "Key Type", "Key type that originates from this key source.",
- 0, G_MAXUINT, SKEY_UNKNOWN, G_PARAM_READABLE));
-
- g_object_class_install_property (gobject_class, PROP_KEY_DESC,
- g_param_spec_string ("key-desc", "Key Desc", "Description for keys that originate here.",
- NULL, G_PARAM_READABLE));
-
- g_object_class_install_property (gobject_class, PROP_LOCATION,
- g_param_spec_uint ("location", "Key Location", "Where the key is stored. See SeahorseKeyLoc",
- 0, G_MAXUINT, SKEY_LOC_INVALID, G_PARAM_READABLE));
-
- g_object_class_install_property (gobject_class, PROP_KEY_SERVER,
- g_param_spec_string ("key-server", "Key Server",
- "Key Server to search on", "",
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_URI,
- g_param_spec_string ("uri", "Key Server URI",
- "Key Server full URI", "",
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
-}
-
-/* init context, private vars, set prefs, connect signals */
-static void
-seahorse_server_source_init (SeahorseServerSource *ssrc)
-{
- /* init private vars */
- ssrc->priv = g_new0 (SeahorseServerSourcePrivate, 1);
- ssrc->priv->mop = seahorse_multi_operation_new ();
-}
-
-/* dispose of all our internal references */
-static void
-seahorse_server_source_dispose (GObject *gobject)
-{
- SeahorseServerSource *ssrc;
- SeahorseKeySource *sksrc;
-
- /*
- * Note that after this executes the rest of the object should
- * still work without a segfault. This basically nullifies the
- * object, but doesn't free it.
- *
- * This function should also be able to run multiple times.
- */
-
- ssrc = SEAHORSE_SERVER_SOURCE (gobject);
- sksrc = SEAHORSE_KEY_SOURCE (gobject);
- g_assert (ssrc->priv);
-
- /* Clear out all the operations */
- if (ssrc->priv->mop) {
- if(seahorse_operation_is_running (SEAHORSE_OPERATION (ssrc->priv->mop)))
- seahorse_operation_cancel (SEAHORSE_OPERATION (ssrc->priv->mop));
- g_object_unref (ssrc->priv->mop);
- ssrc->priv->mop = NULL;
- }
-
- G_OBJECT_CLASS (parent_class)->dispose (gobject);
-}
-
-/* free private vars */
-static void
-seahorse_server_source_finalize (GObject *gobject)
-{
- SeahorseServerSource *ssrc;
-
- ssrc = SEAHORSE_SERVER_SOURCE (gobject);
- g_assert (ssrc->priv);
-
- g_free (ssrc->priv->server);
- g_free (ssrc->priv->uri);
- g_assert (ssrc->priv->mop == NULL);
- g_free (ssrc->priv);
-
- G_OBJECT_CLASS (parent_class)->finalize (gobject);
-}
-
-static void
-seahorse_server_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- SeahorseServerSource *ssrc = SEAHORSE_SERVER_SOURCE (object);
-
- switch (prop_id) {
- case PROP_KEY_SERVER:
- g_assert (ssrc->priv->server == NULL);
- ssrc->priv->server = g_strdup (g_value_get_string (value));
- g_return_if_fail (ssrc->priv->server && ssrc->priv->server[0]);
- break;
- case PROP_URI:
- g_assert (ssrc->priv->uri == NULL);
- ssrc->priv->uri = g_strdup (g_value_get_string (value));
- g_return_if_fail (ssrc->priv->uri && ssrc->priv->uri[0]);
- break;
- default:
- break;
- }
-}
-
-static void
-seahorse_server_get_property (GObject *object, guint prop_id, GValue *value,
- GParamSpec *pspec)
-{
- SeahorseServerSource *ssrc = SEAHORSE_SERVER_SOURCE (object);
-
- switch (prop_id) {
- case PROP_KEY_SERVER:
- g_value_set_string (value, ssrc->priv->server);
- break;
- case PROP_URI:
- g_value_set_string (value, ssrc->priv->uri);
- break;
- case PROP_KEY_TYPE:
- g_value_set_uint (value, SEAHORSE_PGP);
- break;
- case PROP_KEY_DESC:
- g_value_set_string (value, _("PGP Key"));
- break;
- case PROP_LOCATION:
- g_value_set_uint (value, SKEY_LOC_REMOTE);
- break;
- }
-}
-
-
-/* --------------------------------------------------------------------------
- * HELPERS
- */
-
-/* Combine information from one key and tack onto others */
-static void
-combine_keys (SeahorseServerSource *ssrc, gpgme_key_t k, gpgme_key_t key)
-{
- gpgme_user_id_t uid;
- gpgme_user_id_t u;
- gpgme_subkey_t subkey;
- gpgme_subkey_t s;
- gboolean found;
-
- g_assert (k != NULL);
- g_assert (key != NULL);
-
- /* Go through user ids */
- for (uid = key->uids; uid != NULL; uid = uid->next) {
- g_assert (uid->uid);
- found = FALSE;
-
- for (u = k->uids; u != NULL; u = u->next) {
- g_assert (u->uid);
-
- if (strcmp (u->uid, uid->uid) == 0) {
- found = TRUE;
- break;
- }
- }
-
- if (!found)
- gpgmex_key_copy_uid (k, uid);
- }
-
- /* Go through subkeys */
- for (subkey = key->subkeys; subkey != NULL; subkey = subkey->next) {
- g_assert (subkey->fpr);
- found = FALSE;
-
- for (s = k->subkeys; s != NULL; s = s->next) {
- g_assert (s->fpr);
-
- if (strcmp (s->fpr, subkey->fpr) == 0) {
- found = TRUE;
- break;
- }
- }
-
- if (!found)
- gpgmex_key_copy_subkey (k, subkey);
- }
-}
-
-void
-seahorse_server_source_add_key (SeahorseServerSource *ssrc, gpgme_key_t key)
-{
- SeahorseKey *prev;
- SeahorsePGPKey *pkey;
- GQuark keyid;
-
- g_return_if_fail (SEAHORSE_IS_SERVER_SOURCE (ssrc));
-
- keyid = seahorse_pgp_key_get_cannonical_id (seahorse_pgp_key_get_id (key, 0));
- prev = seahorse_context_get_key (SCTX_APP (), SEAHORSE_KEY_SOURCE (ssrc), keyid);
-
- /* TODO: This function needs reworking after we get more key types */
- if (prev != NULL) {
- g_return_if_fail (SEAHORSE_IS_PGP_KEY (prev));
- combine_keys (ssrc, SEAHORSE_PGP_KEY (prev)->pubkey, key);
- seahorse_key_changed (prev, SKEY_CHANGE_UIDS);
- return;
- }
-
- /* A public key */
- pkey = seahorse_pgp_key_new (SEAHORSE_KEY_SOURCE (ssrc), key, NULL);
-
- /* Add to context */
- seahorse_context_add_key (SCTX_APP (), SEAHORSE_KEY (pkey));
-}
-
-void
-seahorse_server_source_take_operation (SeahorseServerSource *ssrc, SeahorseOperation *op)
-{
- g_return_if_fail (SEAHORSE_IS_SERVER_SOURCE (ssrc));
- g_return_if_fail (SEAHORSE_IS_OPERATION (op));
-
- seahorse_multi_operation_take (ssrc->priv->mop, op);
-}
-
-/* --------------------------------------------------------------------------
- * METHODS
- */
-
-static SeahorseOperation*
-seahorse_server_source_load (SeahorseKeySource *src, GQuark keyid)
-{
- SeahorseServerSource *ssrc;
-
- g_assert (SEAHORSE_IS_KEY_SOURCE (src));
- ssrc = SEAHORSE_SERVER_SOURCE (src);
-
- /* We should never be called directly */
- return NULL;
-}
-
-static void
-seahorse_server_source_stop (SeahorseKeySource *src)
-{
- SeahorseServerSource *ssrc;
-
- g_assert (SEAHORSE_IS_KEY_SOURCE (src));
- ssrc = SEAHORSE_SERVER_SOURCE (src);
-
- if(seahorse_operation_is_running (SEAHORSE_OPERATION (ssrc->priv->mop)))
- seahorse_operation_cancel (SEAHORSE_OPERATION (ssrc->priv->mop));
-}
-
-static guint
-seahorse_server_source_get_state (SeahorseKeySource *src)
-{
- SeahorseServerSource *ssrc;
-
- g_assert (SEAHORSE_IS_SERVER_SOURCE (src));
- ssrc = SEAHORSE_SERVER_SOURCE (src);
-
- guint state = SKSRC_REMOTE;
- if (seahorse_operation_is_running (SEAHORSE_OPERATION (ssrc->priv->mop)))
- state |= SKSRC_LOADING;
- return state;
-}
-
-/* Code adapted from GnuPG (file g10/keyserver.c) */
-static gboolean
-parse_keyserver_uri (char *uri, const char **scheme, const char **host)
-{
- int assume_ldap = 0;
-
- g_assert (uri != NULL);
- g_assert (scheme != NULL && host != NULL);
-
- *scheme = NULL;
- *host = NULL;
-
- /* Get the scheme */
-
- *scheme = strsep(&uri, ":");
- if (uri == NULL) {
- /* Assume LDAP if there is no scheme */
- assume_ldap = 1;
- uri = (char*)*scheme;
- *scheme = "ldap";
- }
-
- if (assume_ldap || (uri[0] == '/' && uri[1] == '/')) {
- /* Two slashes means network path. */
-
- /* Skip over the "//", if any */
- if (!assume_ldap)
- uri += 2;
-
- /* Get the host */
- *host = strsep (&uri, "/");
- if (*host[0] == '\0')
- return FALSE;
- }
-
- if (*scheme[0] == '\0')
- return FALSE;
-
- return TRUE;
-}
-
-SeahorseServerSource*
-seahorse_server_source_new (const gchar *server)
-{
- SeahorseServerSource *ssrc = NULL;
- const gchar *scheme;
- const gchar *host;
- gchar *uri, *t;
-
- g_return_val_if_fail (server && server[0], NULL);
-
- uri = g_strdup (server);
-
- if (!parse_keyserver_uri (uri, &scheme, &host)) {
- g_warning ("invalid uri passed: %s", server);
-
-
- } else {
-
-#ifdef WITH_LDAP
- /* LDAP Uris */
- if (g_ascii_strcasecmp (scheme, "ldap") == 0)
- ssrc = SEAHORSE_SERVER_SOURCE (seahorse_ldap_source_new (server, host));
- else
-#endif /* WITH_LDAP */
-
-#ifdef WITH_HKP
- /* HKP Uris */
- if (g_ascii_strcasecmp (scheme, "hkp") == 0) {
-
- ssrc = SEAHORSE_SERVER_SOURCE (seahorse_hkp_source_new (server, host));
-
- /* HTTP Uris */
- } else if (g_ascii_strcasecmp (scheme, "http") == 0 ||
- g_ascii_strcasecmp (scheme, "https") == 0) {
-
- /* If already have a port */
- if (strchr (host, ':'))
- ssrc = SEAHORSE_SERVER_SOURCE (seahorse_hkp_source_new (server, host));
-
- /* No port make sure to use defaults */
- else {
- t = g_strdup_printf ("%s:%d", host,
- (g_ascii_strcasecmp (scheme, "http") == 0) ? 80 : 443);
- ssrc = SEAHORSE_SERVER_SOURCE (seahorse_hkp_source_new (server, t));
- g_free (t);
- }
-
- } else
-#endif /* WITH_HKP */
-
- g_warning ("unsupported key server uri scheme: %s", scheme);
- }
-
- g_free (uri);
- return ssrc;
-}
-
-GSList*
-seahorse_server_source_get_types()
-{
- GSList *types = NULL;
-#ifdef WITH_LDAP
- types = g_slist_prepend(types, g_strdup("ldap"));
-#endif
-#ifdef WITH_HKP
- types = g_slist_prepend(types, g_strdup("hkp"));
-#endif
- return types;
-}
-
-GSList*
-seahorse_server_source_get_descriptions()
-{
- GSList *descriptions = NULL;
-#ifdef WITH_LDAP
- descriptions = g_slist_prepend(descriptions, g_strdup(_("LDAP Key Server")));
-#endif
-#ifdef WITH_HKP
- descriptions = g_slist_prepend(descriptions, g_strdup(_("HTTP Key Server")));
-#endif
- return descriptions;
-}
-
-gboolean
-seahorse_server_source_valid_uri (const gchar *uri)
-{
- if (!uri || !*uri)
- return FALSE;
-
-#ifdef WITH_LDAP
- if (seahorse_ldap_is_valid_uri (uri))
- return TRUE;
-#endif
-#ifdef WITH_HKP
- if (seahorse_hkp_is_valid_uri (uri))
- return TRUE;
-#endif
- return FALSE;
-}
-
-GSList*
-seahorse_server_source_parse_keyservers (GSList *keyservers)
-{
- GSList *names = NULL;
- gchar *t;
-
- while (keyservers) {
- t = strchr ((gchar*)keyservers->data, ' ');
- if (t != NULL) {
- *(t++) = 0;
- g_strstrip (t);
- } else {
- t = (gchar*)keyservers->data;
- }
-
- names = g_slist_append (names, g_strdup (t));
- keyservers = g_slist_next (keyservers);
- }
-
- return names;
-}
-
-GSList*
-seahorse_server_source_purge_keyservers (GSList *keyservers)
-{
- GSList *l;
- gchar *t;
-
- for (l = keyservers; l; l = g_slist_next (l)) {
- t = strchr ((gchar*)l->data, ' ');
- if (t != NULL)
- *t = 0;
+
+enum {
+ SEAHORSE_SERVERS_DUMMY_PROPERTY
+};
+static GHashTable* seahorse_servers_types;
+static void _g_slist_free_g_free (GSList* self);
+enum {
+ SEAHORSE_SERVERS_SERVER_INFO_DUMMY_PROPERTY
+};
+static SeahorseServersServerInfo* seahorse_servers_server_info_new (void);
+static gpointer seahorse_servers_server_info_parent_class = NULL;
+static GType seahorse_servers_server_info_get_type (void);
+static gpointer seahorse_servers_server_info_ref (gpointer instance);
+static void seahorse_servers_server_info_unref (gpointer instance);
+static gpointer seahorse_servers_parent_class = NULL;
+static void seahorse_servers_dispose (GObject * obj);
+static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
+
+
+
+static void _g_slist_free_g_free (GSList* self) {
+ g_slist_foreach (self, ((GFunc) (g_free)), NULL);
+ g_slist_free (self);
+}
+
+
+GSList* seahorse_servers_get_types (void) {
+ GSList* results;
+ results = NULL;
+ {
+ GList* type_collection;
+ GList* type_it;
+ type_collection = g_hash_table_get_keys (seahorse_servers_types);
+ for (type_it = type_collection; type_it != NULL; type_it = type_it->next) {
+ const char* type;
+ type = ((const char*) (type_it->data));
+ {
+ const char* _tmp0;
+ _tmp0 = NULL;
+ results = g_slist_append (results, (_tmp0 = type, (_tmp0 == NULL ? NULL : g_strdup (_tmp0))));
+ }
+ }
+ (type_collection == NULL ? NULL : (type_collection = (g_list_free (type_collection), NULL)));
+ }
+ return results;
+}
+
+
+char* seahorse_servers_get_description (const char* type) {
+ SeahorseServersServerInfo* _tmp0;
+ SeahorseServersServerInfo* server;
+ const char* _tmp2;
+ char* _tmp3;
+ g_return_val_if_fail (type != NULL, NULL);
+ _tmp0 = NULL;
+ server = (_tmp0 = ((SeahorseServersServerInfo*) (g_hash_table_lookup (seahorse_servers_types, type))), (_tmp0 == NULL ? NULL : seahorse_servers_server_info_ref (_tmp0)));
+ if (server == NULL) {
+ char* _tmp1;
+ _tmp1 = NULL;
+ return (_tmp1 = NULL, (server == NULL ? NULL : (server = (seahorse_servers_server_info_unref (server), NULL))), _tmp1);
+ }
+ _tmp2 = NULL;
+ _tmp3 = NULL;
+ return (_tmp3 = (_tmp2 = server->description, (_tmp2 == NULL ? NULL : g_strdup (_tmp2))), (server == NULL ? NULL : (server = (seahorse_servers_server_info_unref (server), NULL))), _tmp3);
+}
+
+
+void seahorse_servers_register_type (const char* type, const char* description, SeahorseValidUriFunc validate) {
+ SeahorseServers* dummy;
+ SeahorseServersServerInfo* info;
+ char* _tmp1;
+ const char* _tmp0;
+ char* _tmp3;
+ const char* _tmp2;
+ SeahorseServersServerInfo* _tmp5;
+ const char* _tmp4;
+ g_return_if_fail (type != NULL);
+ g_return_if_fail (description != NULL);
+ /* Work around for: http://bugzilla.gnome.org/show_bug.cgi?id=543190 */
+ dummy = seahorse_servers_new ();
+ info = seahorse_servers_server_info_new ();
+ _tmp1 = NULL;
+ _tmp0 = NULL;
+ info->type = (_tmp1 = (_tmp0 = type, (_tmp0 == NULL ? NULL : g_strdup (_tmp0))), (info->type = (g_free (info->type), NULL)), _tmp1);
+ _tmp3 = NULL;
+ _tmp2 = NULL;
+ info->description = (_tmp3 = (_tmp2 = description, (_tmp2 == NULL ? NULL : g_strdup (_tmp2))), (info->description = (g_free (info->description), NULL)), _tmp3);
+ info->validator = validate;
+ _tmp5 = NULL;
+ _tmp4 = NULL;
+ g_hash_table_replace (seahorse_servers_types, (_tmp4 = type, (_tmp4 == NULL ? NULL : g_strdup (_tmp4))), (_tmp5 = info, (_tmp5 == NULL ? NULL : seahorse_servers_server_info_ref (_tmp5))));
+ (dummy == NULL ? NULL : (dummy = (g_object_unref (dummy), NULL)));
+ (info == NULL ? NULL : (info = (seahorse_servers_server_info_unref (info), NULL)));
+}
+
+
+GSList* seahorse_servers_get_uris (void) {
+ GSList* servers;
+ GSList* results;
+ GSList* _tmp3;
+ servers = seahorse_gconf_get_string_list (KEYSERVER_KEY);
+ results = NULL;
+ /* The values are 'uri name', remove the name part */
+ {
+ GSList* value_collection;
+ GSList* value_it;
+ value_collection = servers;
+ for (value_it = value_collection; value_it != NULL; value_it = value_it->next) {
+ const char* _tmp2;
+ char* value;
+ _tmp2 = NULL;
+ value = (_tmp2 = ((char*) (value_it->data)), (_tmp2 == NULL ? NULL : g_strdup (_tmp2)));
+ {
+ char** _tmp0;
+ gint parts_length1;
+ char** parts;
+ const char* _tmp1;
+ _tmp0 = NULL;
+ parts = (_tmp0 = g_strsplit (value, " ", 2), parts_length1 = -1, _tmp0);
+ _tmp1 = NULL;
+ results = g_slist_append (results, (_tmp1 = parts[0], (_tmp1 == NULL ? NULL : g_strdup (_tmp1))));
+ value = (g_free (value), NULL);
+ parts = (_vala_array_free (parts, parts_length1, ((GDestroyNotify) (g_free))), NULL);
+ }
+ }
+ }
+ _tmp3 = NULL;
+ return (_tmp3 = results, (servers == NULL ? NULL : (servers = (_g_slist_free_g_free (servers), NULL))), _tmp3);
+}
+
+
+GSList* seahorse_servers_get_names (void) {
+ GSList* servers;
+ GSList* results;
+ GSList* _tmp4;
+ servers = seahorse_gconf_get_string_list (KEYSERVER_KEY);
+ results = NULL;
+ /* The values are 'uri name', remove the uri part */
+ {
+ GSList* value_collection;
+ GSList* value_it;
+ value_collection = servers;
+ for (value_it = value_collection; value_it != NULL; value_it = value_it->next) {
+ const char* _tmp3;
+ char* value;
+ _tmp3 = NULL;
+ value = (_tmp3 = ((char*) (value_it->data)), (_tmp3 == NULL ? NULL : g_strdup (_tmp3)));
+ {
+ char** _tmp0;
+ gint parts_length1;
+ char** parts;
+ _tmp0 = NULL;
+ parts = (_tmp0 = g_strsplit (value, " ", 2), parts_length1 = -1, _tmp0);
+ if (parts_length1 == 2 && g_utf8_strlen (parts[1], -1) > 0) {
+ const char* _tmp1;
+ _tmp1 = NULL;
+ results = g_slist_append (results, (_tmp1 = parts[1], (_tmp1 == NULL ? NULL : g_strdup (_tmp1))));
+ } else {
+ const char* _tmp2;
+ _tmp2 = NULL;
+ results = g_slist_append (results, (_tmp2 = parts[0], (_tmp2 == NULL ? NULL : g_strdup (_tmp2))));
+ }
+ value = (g_free (value), NULL);
+ parts = (_vala_array_free (parts, parts_length1, ((GDestroyNotify) (g_free))), NULL);
+ }
+ }
}
-
- return keyservers;
+ _tmp4 = NULL;
+ return (_tmp4 = results, (servers == NULL ? NULL : (servers = (_g_slist_free_g_free (servers), NULL))), _tmp4);
+}
+
+
+/* Check to see if the passed uri is valid against registered validators */
+gboolean seahorse_servers_is_valid_uri (const char* uri) {
+ char** _tmp0;
+ gint parts_length1;
+ char** parts;
+ SeahorseServersServerInfo* _tmp2;
+ SeahorseServersServerInfo* info;
+ gboolean _tmp4;
+ g_return_val_if_fail (uri != NULL, FALSE);
+ _tmp0 = NULL;
+ parts = (_tmp0 = g_strsplit (uri, ":", 2), parts_length1 = -1, _tmp0);
+ if (parts_length1 == 0) {
+ gboolean _tmp1;
+ return (_tmp1 = FALSE, (parts = (_vala_array_free (parts, parts_length1, ((GDestroyNotify) (g_free))), NULL)), _tmp1);
+ }
+ _tmp2 = NULL;
+ info = (_tmp2 = ((SeahorseServersServerInfo*) (g_hash_table_lookup (seahorse_servers_types, parts[0]))), (_tmp2 == NULL ? NULL : seahorse_servers_server_info_ref (_tmp2)));
+ if (info == NULL) {
+ gboolean _tmp3;
+ return (_tmp3 = FALSE, (parts = (_vala_array_free (parts, parts_length1, ((GDestroyNotify) (g_free))), NULL)), (info == NULL ? NULL : (info = (seahorse_servers_server_info_unref (info), NULL))), _tmp3);
+ }
+ return (_tmp4 = info->validator (uri), (parts = (_vala_array_free (parts, parts_length1, ((GDestroyNotify) (g_free))), NULL)), (info == NULL ? NULL : (info = (seahorse_servers_server_info_unref (info), NULL))), _tmp4);
+}
+
+
+SeahorseServers* seahorse_servers_new (void) {
+ SeahorseServers * self;
+ self = g_object_newv (SEAHORSE_TYPE_SERVERS, 0, NULL);
+ return self;
+}
+
+
+static SeahorseServersServerInfo* seahorse_servers_server_info_new (void) {
+ SeahorseServersServerInfo* self;
+ self = ((SeahorseServersServerInfo*) (g_type_create_instance (SEAHORSE_SERVERS_TYPE_SERVER_INFO)));
+ return self;
}
+
+
+static void seahorse_servers_server_info_class_init (SeahorseServersServerInfoClass * klass) {
+ seahorse_servers_server_info_parent_class = g_type_class_peek_parent (klass);
+}
+
+
+static void seahorse_servers_server_info_instance_init (SeahorseServersServerInfo * self) {
+ self->ref_count = 1;
+}
+
+
+static GType seahorse_servers_server_info_get_type (void) {
+ static GType seahorse_servers_server_info_type_id = 0;
+ if (G_UNLIKELY (seahorse_servers_server_info_type_id == 0)) {
+ static const GTypeInfo g_define_type_info = { sizeof (SeahorseServersServerInfoClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) seahorse_servers_server_info_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SeahorseServersServerInfo), 0, (GInstanceInitFunc) seahorse_servers_server_info_instance_init };
+ static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
+ seahorse_servers_server_info_type_id = g_type_register_fundamental (g_type_fundamental_next (), "SeahorseServersServerInfo", &g_define_type_info, &g_define_type_fundamental_info, 0);
+ }
+ return seahorse_servers_server_info_type_id;
+}
+
+
+static gpointer seahorse_servers_server_info_ref (gpointer instance) {
+ SeahorseServersServerInfo* self;
+ self = instance;
+ g_atomic_int_inc (&self->ref_count);
+ return instance;
+}
+
+
+static void seahorse_servers_server_info_unref (gpointer instance) {
+ SeahorseServersServerInfo* self;
+ self = instance;
+ if (g_atomic_int_dec_and_test (&self->ref_count)) {
+ g_type_free_instance (((GTypeInstance *) (self)));
+ }
+}
+
+
+static void seahorse_servers_class_init (SeahorseServersClass * klass) {
+ seahorse_servers_parent_class = g_type_class_peek_parent (klass);
+ G_OBJECT_CLASS (klass)->dispose = seahorse_servers_dispose;
+ {
+ GHashTable* _tmp0;
+ /* TODO: What do we specify to free ServerInfo? */
+ _tmp0 = NULL;
+ seahorse_servers_types = (_tmp0 = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL), (seahorse_servers_types == NULL ? NULL : (seahorse_servers_types = (g_hash_table_unref (seahorse_servers_types), NULL))), _tmp0);
+ }
+}
+
+
+static void seahorse_servers_instance_init (SeahorseServers * self) {
+}
+
+
+static void seahorse_servers_dispose (GObject * obj) {
+ SeahorseServers * self;
+ self = SEAHORSE_SERVERS (obj);
+ G_OBJECT_CLASS (seahorse_servers_parent_class)->dispose (obj);
+}
+
+
+GType seahorse_servers_get_type (void) {
+ static GType seahorse_servers_type_id = 0;
+ if (G_UNLIKELY (seahorse_servers_type_id == 0)) {
+ static const GTypeInfo g_define_type_info = { sizeof (SeahorseServersClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) seahorse_servers_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SeahorseServers), 0, (GInstanceInitFunc) seahorse_servers_instance_init };
+ seahorse_servers_type_id = g_type_register_static (G_TYPE_OBJECT, "SeahorseServers", &g_define_type_info, 0);
+ }
+ return seahorse_servers_type_id;
+}
+
+
+static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
+ if (array != NULL && destroy_func != NULL) {
+ int i;
+ if (array_length >= 0)
+ for (i = 0; i < array_length; i = i + 1) {
+ if (((gpointer*) (array))[i] != NULL)
+ destroy_func (((gpointer*) (array))[i]);
+ }
+ else
+ for (i = 0; ((gpointer*) (array))[i] != NULL; i = i + 1) {
+ destroy_func (((gpointer*) (array))[i]);
+ }
+ }
+ g_free (array);
+}
+
+
+
+
Copied: trunk/libseahorse/seahorse-servers.h (from r2249, /trunk/pgp/seahorse-server-source.h)
==============================================================================
--- /trunk/pgp/seahorse-server-source.h (original)
+++ trunk/libseahorse/seahorse-servers.h Tue Jul 15 22:44:47 2008
@@ -1,85 +1,47 @@
-/*
- * Seahorse
- *
- * Copyright (C) 2004 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 Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/**
- * SeahorseServerSoruce: A base class for key sources that retrieve keys
- * from remote key servers.
- *
- * - Derived from SeahorseKeySource.
- * - Also includes functions for parsing keyserver URIs and mapping them
- * to the appropriate key sources (such as SeahorseHKPSource)
- * - There's some GPGME specific stuff in here that may eventually need to be
- * moved elsewhere.
- *
- * Properties:
- * key-type: (GQuark) The type of keys generated (ie: SKEY_PGP)
- * location: (gchar*) The location of keys from this key source (ie: SKEY_LOC_REMOTE)
- * key-server: (gchar*) The host:port of the keyserver to search.
- * uri: (gchar*) Only for remote key sources. The full URI of the keyserver
- * being used.
- */
-
-#ifndef __SEAHORSE_SERVER_SOURCE_H__
-#define __SEAHORSE_SERVER_SOURCE_H__
-
-#include "seahorse-key-source.h"
-#include "seahorse-operation.h"
-
-#define SEAHORSE_TYPE_SERVER_SOURCE (seahorse_server_source_get_type ())
-#define SEAHORSE_SERVER_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_SERVER_SOURCE, SeahorseServerSource))
-#define SEAHORSE_SERVER_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAHORSE_TYPE_SERVER_SOURCE, SeahorseServerSourceClass))
-#define SEAHORSE_IS_SERVER_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAHORSE_TYPE_SERVER_SOURCE))
-#define SEAHORSE_IS_SERVER_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAHORSE_TYPE_SERVER_SOURCE))
-#define SEAHORSE_SERVER_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAHORSE_TYPE_SERVER_SOURCE, SeahorseServerSourceClass))
-
-typedef struct _SeahorseServerSource SeahorseServerSource;
-typedef struct _SeahorseServerSourceClass SeahorseServerSourceClass;
-typedef struct _SeahorseServerSourcePrivate SeahorseServerSourcePrivate;
-
-struct _SeahorseServerSource {
- SeahorseKeySource parent;
-
- /*< private >*/
- SeahorseServerSourcePrivate *priv;
-};
-
-struct _SeahorseServerSourceClass {
- SeahorseKeySourceClass parent_class;
-};
-GType seahorse_server_source_get_type (void);
+#ifndef __SEAHORSE_SERVERS_H__
+#define __SEAHORSE_SERVERS_H__
-void seahorse_server_source_take_operation (SeahorseServerSource *ssrc,
- SeahorseOperation *operation);
-
-SeahorseServerSource* seahorse_server_source_new (const gchar *uri);
+#include <glib.h>
+#include <glib-object.h>
+#include <stdlib.h>
+#include <string.h>
+
+G_BEGIN_DECLS
+
+typedef gboolean (*SeahorseValidUriFunc) (const char* uri);
+
+#define SEAHORSE_TYPE_SERVERS (seahorse_servers_get_type ())
+#define SEAHORSE_SERVERS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_SERVERS, SeahorseServers))
+#define SEAHORSE_SERVERS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAHORSE_TYPE_SERVERS, SeahorseServersClass))
+#define SEAHORSE_IS_SERVERS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAHORSE_TYPE_SERVERS))
+#define SEAHORSE_IS_SERVERS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAHORSE_TYPE_SERVERS))
+#define SEAHORSE_SERVERS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAHORSE_TYPE_SERVERS, SeahorseServersClass))
+
+typedef struct _SeahorseServers SeahorseServers;
+typedef struct _SeahorseServersClass SeahorseServersClass;
+typedef struct _SeahorseServersPrivate SeahorseServersPrivate;
+
+struct _SeahorseServers {
+ GObject parent_instance;
+ SeahorseServersPrivate * priv;
+};
-GSList* seahorse_server_source_get_types ();
+struct _SeahorseServersClass {
+ GObjectClass parent_class;
+};
-GSList* seahorse_server_source_get_descriptions ();
-gboolean seahorse_server_source_valid_uri (const gchar *uri);
+GSList* seahorse_servers_get_types (void);
+char* seahorse_servers_get_description (const char* type);
+void seahorse_servers_register_type (const char* type, const char* description, SeahorseValidUriFunc validate);
+GSList* seahorse_servers_get_uris (void);
+GSList* seahorse_servers_get_names (void);
+gboolean seahorse_servers_is_valid_uri (const char* uri);
+SeahorseServers* seahorse_servers_new (void);
+GType seahorse_servers_get_type (void);
-GSList* seahorse_server_source_parse_keyservers (GSList *keyservers);
-GSList* seahorse_server_source_purge_keyservers (GSList *keyservers);
+G_END_DECLS
-#endif /* __SEAHORSE_SERVER_SOURCE_H__ */
+#endif
Added: trunk/libseahorse/seahorse-servers.vala
==============================================================================
--- (empty file)
+++ trunk/libseahorse/seahorse-servers.vala Tue Jul 15 22:44:47 2008
@@ -0,0 +1,85 @@
+
+namespace Seahorse {
+
+ public static delegate bool ValidUriFunc (string uri);
+
+ public class Servers : GLib.Object {
+ private class ServerInfo {
+ public string type;
+ public string description;
+ public ValidUriFunc validator;
+ }
+
+ private static HashTable<string, ServerInfo> types;
+
+ static construct {
+ /* TODO: What do we specify to free ServerInfo? */
+ types = new HashTable<string, ServerInfo>.full(str_hash, str_equal, g_free, null);
+ }
+
+ public static SList<string> get_types() {
+ SList<string> results;
+ foreach (var type in types.get_keys())
+ results.append(type);
+ return results;
+ }
+
+ public static string? get_description(string type) {
+ var server = types.lookup(type);
+ if (server == null)
+ return null;
+ return server.description;
+ }
+
+ public static void register_type(string type, string description, ValidUriFunc validate) {
+ /* Work around for: http://bugzilla.gnome.org/show_bug.cgi?id=543190 */
+ Servers dummy = new Servers();
+
+ ServerInfo info = new ServerInfo();
+ info.type = type;
+ info.description = description;
+ info.validator = validate;
+ types.replace(type, info);
+ }
+
+ public static GLib.SList<string> get_uris() {
+ var servers = Conf.get_string_list (Conf.KEYSERVER_KEY);
+ GLib.SList<string> results;
+
+ /* The values are 'uri name', remove the name part */
+ foreach (string value in servers) {
+ string[] parts = value.split(" ", 2);
+ results.append(parts[0]);
+ }
+
+ return results;
+ }
+
+ public static GLib.SList<string> get_names() {
+ var servers = Conf.get_string_list (Conf.KEYSERVER_KEY);
+ GLib.SList<string> results;
+
+ /* The values are 'uri name', remove the uri part */
+ foreach (string value in servers) {
+ string[] parts = value.split(" ", 2);
+ if (parts.length == 2 && parts[1].len() > 0)
+ results.append(parts[1]);
+ else
+ results.append(parts[0]);
+ }
+
+ return results;
+ }
+
+ /* Check to see if the passed uri is valid against registered validators */
+ public static bool is_valid_uri(string uri) {
+ string[] parts = uri.split(":", 2);
+ if(parts.length == 0)
+ return false;
+ ServerInfo? info = types.lookup(parts[0]);
+ if(info == null)
+ return false;
+ return info.validator (uri);
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/libseahorse/seahorse-util.c
==============================================================================
--- trunk/libseahorse/seahorse-util.c (original)
+++ trunk/libseahorse/seahorse-util.c Tue Jul 15 22:44:47 2008
@@ -892,7 +892,7 @@
break;
}
- gtk_widget_destroy (dialog);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
return uri;
}
@@ -904,7 +904,7 @@
if(gtk_dialog_run (dialog) == GTK_RESPONSE_ACCEPT)
uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
- gtk_widget_destroy (dialog);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
return uri;
}
@@ -971,7 +971,7 @@
uri = NULL;
uri = seahorse_util_chooser_save_prompt (dialog);
- gtk_widget_destroy (dialog);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
return uri;
@@ -1009,7 +1009,7 @@
uri = NULL;
uri = seahorse_util_chooser_save_prompt (dialog);
- gtk_widget_destroy (dialog);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
return uri;
Modified: trunk/libseahorse/vala-build.stamp
==============================================================================
--- trunk/libseahorse/vala-build.stamp (original)
+++ trunk/libseahorse/vala-build.stamp Tue Jul 15 22:44:47 2008
@@ -1 +1 @@
-1214704934
+1216160611
Modified: trunk/pgp/seahorse-hkp-source.c
==============================================================================
--- trunk/pgp/seahorse-hkp-source.c (original)
+++ trunk/pgp/seahorse-hkp-source.c Tue Jul 15 22:44:47 2008
@@ -33,6 +33,7 @@
#include "seahorse-gconf.h"
#include "seahorse-operation.h"
+#include "seahorse-servers.h"
#include "seahorse-util.h"
#include <libsoup/soup.h>
@@ -969,6 +970,7 @@
NULL, G_PARAM_READABLE));
seahorse_registry_register_type (NULL, SEAHORSE_TYPE_HKP_SOURCE, "key-source", "remote", SEAHORSE_PGP_STR, NULL);
+ seahorse_servers_register_type ("hkp", _("HTTP Key Server"), seahorse_hkp_is_valid_uri);
}
Modified: trunk/pgp/seahorse-ldap-source.c
==============================================================================
--- trunk/pgp/seahorse-ldap-source.c (original)
+++ trunk/pgp/seahorse-ldap-source.c Tue Jul 15 22:44:47 2008
@@ -33,6 +33,7 @@
#include "seahorse-pgp-key.h"
#include "seahorse-operation.h"
+#include "seahorse-servers.h"
#include "seahorse-util.h"
#include <ldap.h>
@@ -1406,6 +1407,7 @@
NULL, G_PARAM_READABLE));
seahorse_registry_register_type (NULL, SEAHORSE_TYPE_LDAP_SOURCE, "key-source", "remote", SEAHORSE_PGP_STR, NULL);
+ seahorse_servers_register_type ("ldap", _("LDAP Key Server"), seahorse_ldap_is_valid_uri);
}
Modified: trunk/pgp/seahorse-pgp-key-properties.c
==============================================================================
--- trunk/pgp/seahorse-pgp-key-properties.c (original)
+++ trunk/pgp/seahorse-pgp-key-properties.c Tue Jul 15 22:44:47 2008
@@ -1027,7 +1027,7 @@
seahorse_util_chooser_set_filename (dialog, keys);
uri = seahorse_util_chooser_save_prompt (dialog);
- gtk_widget_destroy (dialog);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
if(!uri)
return;
Modified: trunk/pgp/seahorse-pgp-photos.c
==============================================================================
--- trunk/pgp/seahorse-pgp-photos.c (original)
+++ trunk/pgp/seahorse-pgp-photos.c Tue Jul 15 22:44:47 2008
@@ -260,12 +260,12 @@
if (NULL == path) {
chooser = seahorse_util_chooser_open_new (_("Choose Photo to Add to Key"), parent);
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (chooser), TRUE);
- add_image_files (chooser);
+ add_image_files (GTK_WIDGET (chooser));
if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_ACCEPT)
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
- gtk_widget_destroy (chooser);
+ gtk_widget_destroy (GTK_WIDGET (chooser));
if (!filename)
return FALSE;
Modified: trunk/pgp/seahorse-server-source.c
==============================================================================
--- trunk/pgp/seahorse-server-source.c (original)
+++ trunk/pgp/seahorse-server-source.c Tue Jul 15 22:44:47 2008
@@ -448,83 +448,3 @@
g_free (uri);
return ssrc;
}
-
-GSList*
-seahorse_server_source_get_types()
-{
- GSList *types = NULL;
-#ifdef WITH_LDAP
- types = g_slist_prepend(types, g_strdup("ldap"));
-#endif
-#ifdef WITH_HKP
- types = g_slist_prepend(types, g_strdup("hkp"));
-#endif
- return types;
-}
-
-GSList*
-seahorse_server_source_get_descriptions()
-{
- GSList *descriptions = NULL;
-#ifdef WITH_LDAP
- descriptions = g_slist_prepend(descriptions, g_strdup(_("LDAP Key Server")));
-#endif
-#ifdef WITH_HKP
- descriptions = g_slist_prepend(descriptions, g_strdup(_("HTTP Key Server")));
-#endif
- return descriptions;
-}
-
-gboolean
-seahorse_server_source_valid_uri (const gchar *uri)
-{
- if (!uri || !*uri)
- return FALSE;
-
-#ifdef WITH_LDAP
- if (seahorse_ldap_is_valid_uri (uri))
- return TRUE;
-#endif
-#ifdef WITH_HKP
- if (seahorse_hkp_is_valid_uri (uri))
- return TRUE;
-#endif
- return FALSE;
-}
-
-GSList*
-seahorse_server_source_parse_keyservers (GSList *keyservers)
-{
- GSList *names = NULL;
- gchar *t;
-
- while (keyservers) {
- t = strchr ((gchar*)keyservers->data, ' ');
- if (t != NULL) {
- *(t++) = 0;
- g_strstrip (t);
- } else {
- t = (gchar*)keyservers->data;
- }
-
- names = g_slist_append (names, g_strdup (t));
- keyservers = g_slist_next (keyservers);
- }
-
- return names;
-}
-
-GSList*
-seahorse_server_source_purge_keyservers (GSList *keyservers)
-{
- GSList *l;
- gchar *t;
-
- for (l = keyservers; l; l = g_slist_next (l)) {
- t = strchr ((gchar*)l->data, ' ');
- if (t != NULL)
- *t = 0;
- }
-
- return keyservers;
-}
Modified: trunk/pgp/seahorse-server-source.h
==============================================================================
--- trunk/pgp/seahorse-server-source.h (original)
+++ trunk/pgp/seahorse-server-source.h Tue Jul 15 22:44:47 2008
@@ -72,14 +72,4 @@
SeahorseServerSource* seahorse_server_source_new (const gchar *uri);
-GSList* seahorse_server_source_get_types ();
-
-GSList* seahorse_server_source_get_descriptions ();
-
-gboolean seahorse_server_source_valid_uri (const gchar *uri);
-
-GSList* seahorse_server_source_parse_keyservers (GSList *keyservers);
-
-GSList* seahorse_server_source_purge_keyservers (GSList *keyservers);
-
#endif /* __SEAHORSE_SERVER_SOURCE_H__ */
Modified: trunk/pgp/vala-build.stamp
==============================================================================
--- trunk/pgp/vala-build.stamp (original)
+++ trunk/pgp/vala-build.stamp Tue Jul 15 22:44:47 2008
@@ -1 +1 @@
-1214713745
+1216160621
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Tue Jul 15 22:44:47 2008
@@ -46,6 +46,18 @@
KEYSERVER_SRCS =
endif
+if WITH_PGP
+PGP_LDADD = $(top_builddir)/pgp/libseahorse-pgp.la
+else
+PGP_LDADD =
+endif
+
+if WITH_SSH
+SSH_LDADD = $(top_builddir)/ssh/libseahorse-ssh.la
+else
+SSH_LDADD =
+endif
+
bin_PROGRAMS = seahorse
seahorse_SOURCES = main.c \
@@ -58,8 +70,8 @@
seahorse_LDADD = \
$(top_builddir)/libseahorse/libseahorse.la \
- $(top_builddir)/pgp/libseahorse-pgp.la \
- $(top_builddir)/ssh/libseahorse-ssh.la \
+ $(PGP_LDADD) \
+ $(SSH_LDADD) \
$(top_builddir)/gkr/libseahorse-gkr.la \
$(top_builddir)/common/libseahorse-common.la \
$(top_builddir)/libcryptui/libcryptui.la \
Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c (original)
+++ trunk/src/main.c Tue Jul 15 22:44:47 2008
@@ -33,9 +33,11 @@
#include "common/seahorse-cleanup.h"
#include "common/seahorse-registry.h"
+#ifdef WITH_PGP
#include "pgp/seahorse-pgp-module.h"
#include "pgp/seahorse-pgp-key.h"
#include "pgp/seahorse-pgp-source.h"
+#endif
#ifdef WITH_SSH
#include "ssh/seahorse-ssh-module.h"
@@ -76,8 +78,12 @@
seahorse_gtkstock_init ();
/* Initialize the various components */
+#ifdef WITH_PGP
seahorse_registry_load_types (NULL, SEAHORSE_PGP_REGISTRY);
+#endif
+#ifdef WITH_SSH
seahorse_registry_load_types (NULL, SEAHORSE_SSH_REGISTRY);
+#endif
/* Make the default SeahorseContext */
seahorse_context_new (SEAHORSE_CONTEXT_APP, 0);
Modified: trunk/src/seahorse-key-manager-store.c
==============================================================================
--- trunk/src/seahorse-key-manager-store.c (original)
+++ trunk/src/seahorse-key-manager-store.c Tue Jul 15 22:44:47 2008
@@ -34,12 +34,6 @@
#include "seahorse-gconf.h"
#include "eggtreemultidnd.h"
-#include "pgp/seahorse-pgp-key.h"
-
-#ifdef WITH_SSH
-#include "ssh/seahorse-ssh-key.h"
-#endif
-
#define KEY_MANAGER_SORT_KEY "/apps/seahorse/listing/sort_by"
enum {
Modified: trunk/src/seahorse-keyserver-search.c
==============================================================================
--- trunk/src/seahorse-keyserver-search.c (original)
+++ trunk/src/seahorse-keyserver-search.c Tue Jul 15 22:44:47 2008
@@ -20,16 +20,14 @@
*/
-#include "seahorse-widget.h"
-#include "seahorse-util.h"
#include "seahorse-context.h"
+#include "seahorse-dns-sd.h"
+#include "seahorse-gconf.h"
#include "seahorse-keyserver-results.h"
#include "seahorse-preferences.h"
-#include "seahorse-gconf.h"
-#include "seahorse-context.h"
-#include "seahorse-dns-sd.h"
-
-#include "pgp/seahorse-server-source.h"
+#include "seahorse-servers.h"
+#include "seahorse-util.h"
+#include "seahorse-widget.h"
typedef struct _KeyserverSelection {
GSList *names;
@@ -265,8 +263,8 @@
w = glade_xml_get_widget (swidget->xml, "key-server-list");
g_return_if_fail (w != NULL);
- keyservers = seahorse_gconf_get_string_list (KEYSERVER_KEY);
- names = seahorse_server_source_parse_keyservers (keyservers);
+ keyservers = seahorse_servers_get_uris ();
+ names = seahorse_servers_get_names ();
populate_keyserver_list (swidget, w, keyservers, names);
seahorse_util_string_slist_free (keyservers);
Modified: trunk/src/seahorse-keyserver-sync.c
==============================================================================
--- trunk/src/seahorse-keyserver-sync.c (original)
+++ trunk/src/seahorse-keyserver-sync.c Tue Jul 15 22:44:47 2008
@@ -23,17 +23,16 @@
#include <glib/gi18n.h>
-#include "seahorse-widget.h"
-#include "seahorse-util.h"
#include "seahorse-context.h"
-#include "seahorse-windows.h"
+#include "seahorse-gconf.h"
+#include "seahorse-keyserver-sync.h"
#include "seahorse-progress.h"
#include "seahorse-preferences.h"
-#include "seahorse-gconf.h"
+#include "seahorse-servers.h"
#include "seahorse-transfer-operation.h"
-#include "seahorse-keyserver-sync.h"
-
-#include "pgp/seahorse-server-source.h"
+#include "seahorse-util.h"
+#include "seahorse-widget.h"
+#include "seahorse-windows.h"
static void
sync_import_complete (SeahorseOperation *op, SeahorseKeySource *sksrc)
@@ -204,8 +203,7 @@
mop = seahorse_multi_operation_new ();
/* And now synchronizing keys from the servers */
- ks = seahorse_gconf_get_string_list (KEYSERVER_KEY);
- ks = seahorse_server_source_purge_keyservers (ks);
+ ks = seahorse_servers_get_uris ();
for (l = ks; l; l = g_slist_next (l)) {
Modified: trunk/src/vala-build.stamp
==============================================================================
--- trunk/src/vala-build.stamp (original)
+++ trunk/src/vala-build.stamp Tue Jul 15 22:44:47 2008
@@ -1 +1 @@
-1214715218
+1216160634
Modified: trunk/ssh/seahorse-ssh-key-properties.c
==============================================================================
--- trunk/ssh/seahorse-ssh-key-properties.c (original)
+++ trunk/ssh/seahorse-ssh-key-properties.c Tue Jul 15 22:44:47 2008
@@ -223,7 +223,7 @@
seahorse_util_chooser_set_filename (dialog, keys);
uri = seahorse_util_chooser_save_prompt (dialog);
- gtk_widget_destroy (dialog);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
if(!uri)
return;
Modified: trunk/ssh/vala-build.stamp
==============================================================================
--- trunk/ssh/vala-build.stamp (original)
+++ trunk/ssh/vala-build.stamp Tue Jul 15 22:44:47 2008
@@ -1 +1 @@
-1214713748
+1216160626
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]