check for gnome-keyring.

2005-10-27  Michael Natterer  <mitch@gimp.org>

	* configure.in: check for gnome-keyring.

	* plug-ins/uri/uri-backend.h
	* plug-ins/uri/uri-backend-wget.c
	* plug-ins/uri/uri-backend-gnomevfs.c: added "plugin_name",
	boolean "run" and "run_mode" parameters to uri_backend_init().

	* plug-ins/uri/uri-backend-gnomevfs.c (uri_backend_init):
	initialize the gnome authentication manager only when called
	interactively from "run". Also call gimp_ui_init() when using the
	auth manager, since recent versions seem to require an already
	initialized GTK+. When running noninteractively and gnome-keyring
	is available, implement the needed GnomeVFS authentication
	callbacks ourselves and ask gnome-keyring directly.

	* plug-ins/uri/uri.c: pass the additional parameters to
	uri_backend_init().
This commit is contained in:
Michael Natterer 2005-10-27 17:19:58 +00:00 committed by Michael Natterer
parent bb067d21da
commit 2084dc2cf6
6 changed files with 232 additions and 16 deletions

View File

@ -1,3 +1,23 @@
2005-10-27 Michael Natterer <mitch@gimp.org>
* configure.in: check for gnome-keyring.
* plug-ins/uri/uri-backend.h
* plug-ins/uri/uri-backend-wget.c
* plug-ins/uri/uri-backend-gnomevfs.c: added "plugin_name",
boolean "run" and "run_mode" parameters to uri_backend_init().
* plug-ins/uri/uri-backend-gnomevfs.c (uri_backend_init):
initialize the gnome authentication manager only when called
interactively from "run". Also call gimp_ui_init() when using the
auth manager, since recent versions seem to require an already
initialized GTK+. When running noninteractively and gnome-keyring
is available, implement the needed GnomeVFS authentication
callbacks ourselves and ask gnome-keyring directly.
* plug-ins/uri/uri.c: pass the additional parameters to
uri_backend_init().
2005-10-26 Carol Spears <carol@gimp.org>
* app/actions/image-actions.c: added colors-info-menu and
@ -6,7 +26,7 @@
* menus/image-menu.xml.in: changed Modify placeholder to
colors-modify-menu menuaction and added color-info-menu action to
colors-menu
* plug-ins/common/colortoalpha.c: moved to Colors/Modify in the
registration part.
@ -59,7 +79,7 @@
the new menu.
* app/widgets/gimpbrusheditor.[ch]: use the menu. Added menu_factory
paramater to the contstructor.
parameter to the contstructor.
* app/dialogs/dialogs-constructors.c: changed accordingly.
@ -3703,7 +3723,7 @@
by always asuming that the destination has alpha.
Fixes bug #312392.
(extract_from_region): removed has_alpha paramater. pass
(extract_from_region): removed has_alpha parameter. pass
src->bytes and dest->bytes to above functions.
* app/core/gimpselection.c (gimp_selection_extract): changed

View File

@ -57,6 +57,7 @@ m4_define([pygtk_required_version], [1.99.15])
m4_define([poppler_required_version], [0.3.1])
m4_define([gnome_vfs_required_version], [2.10.0])
m4_define([gnomeui_required_version], [2.10.0])
m4_define([gnome_keyring_required_version], [0.4.5])
m4_define([gnome_print_required_version], [2.10.0])
@ -1219,9 +1220,9 @@ if test "x$have_poppler" = xyes; then
fi
#################################################
# Check for gnome-vfs (and optionally libgnomeui)
#################################################
###################################################################
# Check for gnome-vfs (and optionally libgnomeui and gnome-keyring)
###################################################################
uri_modules="gnome-vfs-2.0 >= gnome_vfs_required_version"
@ -1232,6 +1233,13 @@ else
AC_MSG_WARN([*** URI plug-in will be built without libgnomeui support (libgnomeui-2.0 not found) ***])
fi
if $PKG_CONFIG --atleast-version=gnome_keyring_required_version gnome-keyring-1; then
have_gnome_keyring=yes
uri_modules="$uri_modules gnome-keyring-1"
else
AC_MSG_WARN([*** URI plug-in will be built without gnome-keyring support (gnome-keyring-1 not found) ***])
fi
PKG_CHECK_MODULES(URI, $uri_modules,
have_gnomevfs=yes,
AC_MSG_WARN([*** URI plug-in will be built without gnome-vfs support (gnome-vfs-2.0 not found) ***]))
@ -1242,6 +1250,10 @@ if test "x$have_gnomeui" = xyes; then
AC_DEFINE(HAVE_GNOMEUI, 1, [Define to 1 if libgnomeui is available])
fi
if test "x$have_gnome_keyring" = xyes; then
AC_DEFINE(HAVE_GNOME_KEYRING, 1, [Define to 1 if gnome-keyring is available])
fi
#######################
# Check for gnome-print

View File

@ -23,8 +23,12 @@
#ifdef HAVE_GNOMEUI
#include <libgnomeui/gnome-authentication-manager.h>
#endif
#ifdef HAVE_GNOME_KEYRING
#include <gnome-keyring.h>
#endif
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "libgimp/stdplugins-intl.h"
@ -41,6 +45,21 @@ static gboolean copy_uri (const gchar *src_uri,
const gchar *copied_format_str,
GError **error);
#ifdef HAVE_GNOME_KEYRING
static void vfs_async_fill_authentication_callback (gconstpointer in,
size_t in_size,
gpointer out,
size_t out_size,
gpointer user_data,
GnomeVFSModuleCallbackResponse response,
gpointer response_data);
static void vfs_fill_authentication_callback (gconstpointer in,
size_t in_size,
gpointer out,
size_t out_size,
gpointer user_data);
#endif /* HAVE_GNOME_KEYRING */
/* private variables */
@ -50,7 +69,10 @@ static gchar *supported_protocols = NULL;
/* public functions */
gboolean
uri_backend_init (GError **error)
uri_backend_init (const gchar *plugin_name,
gboolean run,
GimpRunMode run_mode,
GError **error)
{
if (! gnome_vfs_init ())
{
@ -59,8 +81,31 @@ uri_backend_init (GError **error)
}
#ifdef HAVE_GNOMEUI
gnome_authentication_manager_init ();
#endif
if (run)
{
if (run_mode == GIMP_RUN_INTERACTIVE)
{
gimp_ui_init (plugin_name, FALSE);
gnome_authentication_manager_init ();
}
else
{
#ifdef HAVE_GNOME_KEYRING
gnome_vfs_async_module_callback_set_default
(GNOME_VFS_MODULE_CALLBACK_FILL_AUTHENTICATION,
vfs_async_fill_authentication_callback,
GINT_TO_POINTER (0),
NULL);
gnome_vfs_module_callback_set_default
(GNOME_VFS_MODULE_CALLBACK_FILL_AUTHENTICATION,
vfs_fill_authentication_callback,
GINT_TO_POINTER (0),
NULL);
#endif /* HAVE_GNOME_KEYRING */
}
}
#endif /* HAVE_GNOMEUI */
return TRUE;
}
@ -127,6 +172,7 @@ uri_backend_save_image (const gchar *uri,
return success;
}
/* private functions */
static gchar *
@ -313,3 +359,134 @@ copy_uri (const gchar *src_uri,
return TRUE;
}
#ifdef HAVE_GNOME_KEYRING
typedef struct
{
const GnomeVFSModuleCallbackFillAuthenticationIn *in_args;
GnomeVFSModuleCallbackFillAuthenticationOut *out_args;
GnomeVFSModuleCallbackResponse response;
gpointer response_data;
} FillCallbackInfo;
static void
fill_auth_callback (GnomeKeyringResult result,
GList *list,
gpointer data)
{
FillCallbackInfo *info = data;
GnomeKeyringNetworkPasswordData *pwd_data;;
if (result != GNOME_KEYRING_RESULT_OK || list == NULL)
{
info->out_args->valid = FALSE;
}
else
{
/* We use the first result, which is the least specific match */
pwd_data = list->data;
info->out_args->valid = TRUE;
info->out_args->username = g_strdup (pwd_data->user);
info->out_args->domain = g_strdup (pwd_data->domain);
info->out_args->password = g_strdup (pwd_data->password);
}
info->response (info->response_data);
}
static void /* GnomeVFSAsyncModuleCallback */
vfs_async_fill_authentication_callback (gconstpointer in,
size_t in_size,
gpointer out,
size_t out_size,
gpointer user_data,
GnomeVFSModuleCallbackResponse response,
gpointer response_data)
{
GnomeVFSModuleCallbackFillAuthenticationIn *in_real;
GnomeVFSModuleCallbackFillAuthenticationOut *out_real;
gpointer request;
FillCallbackInfo *info;
g_return_if_fail
(sizeof (GnomeVFSModuleCallbackFillAuthenticationIn) == in_size &&
sizeof (GnomeVFSModuleCallbackFillAuthenticationOut) == out_size);
g_return_if_fail (in != NULL);
g_return_if_fail (out != NULL);
in_real = (GnomeVFSModuleCallbackFillAuthenticationIn *)in;
out_real = (GnomeVFSModuleCallbackFillAuthenticationOut *)out;
info = g_new (FillCallbackInfo, 1);
info->in_args = in_real;
info->out_args = out_real;
info->response = response;
info->response_data = response_data;
request = gnome_keyring_find_network_password (in_real->username,
in_real->domain,
in_real->server,
in_real->object,
in_real->protocol,
in_real->authtype,
in_real->port,
fill_auth_callback,
info, g_free);
}
static void /* GnomeVFSModuleCallback */
vfs_fill_authentication_callback (gconstpointer in,
size_t in_size,
gpointer out,
size_t out_size,
gpointer user_data)
{
GnomeVFSModuleCallbackFillAuthenticationIn *in_real;
GnomeVFSModuleCallbackFillAuthenticationOut *out_real;
GnomeKeyringNetworkPasswordData *pwd_data;
GList *list;
GnomeKeyringResult result;
g_return_if_fail
(sizeof (GnomeVFSModuleCallbackFillAuthenticationIn) == in_size &&
sizeof (GnomeVFSModuleCallbackFillAuthenticationOut) == out_size);
g_return_if_fail (in != NULL);
g_return_if_fail (out != NULL);
in_real = (GnomeVFSModuleCallbackFillAuthenticationIn *)in;
out_real = (GnomeVFSModuleCallbackFillAuthenticationOut *)out;
result = gnome_keyring_find_network_password_sync (in_real->username,
in_real->domain,
in_real->server,
in_real->object,
in_real->protocol,
in_real->authtype,
in_real->port,
&list);
if (result != GNOME_KEYRING_RESULT_OK || list == NULL)
{
out_real->valid = FALSE;
}
else
{
/* We use the first result, which is the least specific match */
pwd_data = list->data;
out_real->valid = TRUE;
out_real->username = g_strdup (pwd_data->user);
out_real->domain = g_strdup (pwd_data->domain);
out_real->password = g_strdup (pwd_data->password);
gnome_keyring_network_password_list_free (list);
}
}
#endif /* HAVE_GNOME_KEYRING */

View File

@ -42,7 +42,10 @@
gboolean
uri_backend_init (GError **error)
uri_backend_init (const gchar *plugin_name,
gboolean run,
GimpRunMode run_mode,
GError **error)
{
return TRUE;
}

View File

@ -20,7 +20,10 @@
#define __URI_BACKEND_H__
gboolean uri_backend_init (GError **error);
gboolean uri_backend_init (const gchar *plugin_name,
gboolean run,
GimpRunMode run_mode,
GError **error);
void uri_backend_shutdown (void);
const gchar * uri_backend_get_load_protocols (void);

View File

@ -38,8 +38,9 @@
#include "libgimp/stdplugins-intl.h"
#define LOAD_PROC "file-uri-load"
#define SAVE_PROC "file-uri-save"
#define LOAD_PROC "file-uri-load"
#define SAVE_PROC "file-uri-save"
#define PLUG_IN_BINARY "uri"
static void query (void);
@ -97,7 +98,7 @@ query (void)
GError *error = NULL;
if (! uri_backend_init (&error))
if (! uri_backend_init (PLUG_IN_BINARY, FALSE, 0, &error))
{
g_message (error->message);
g_clear_error (&error);
@ -170,7 +171,7 @@ run (const gchar *name,
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = status;
if (! uri_backend_init (&error))
if (! uri_backend_init (PLUG_IN_BINARY, TRUE, run_mode, &error))
{
g_message (error->message);
g_clear_error (&error);
@ -196,7 +197,7 @@ run (const gchar *name,
status = save_image (param[3].data.d_string,
param[1].data.d_int32,
param[2].data.d_int32,
param[0].data.d_int32);
run_mode);
}
else
{