[Gpa-commits] r786 - trunk/src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Oct 4 10:46:44 CEST 2007
Author: werner
Date: 2007-10-04 10:46:43 +0200 (Thu, 04 Oct 2007)
New Revision: 786
Modified:
trunk/src/gpastreamop.c
trunk/src/server.c
Log:
cmd "encrypt" does now work on Unix and W32.
Modified: trunk/src/gpastreamop.c
===================================================================
--- trunk/src/gpastreamop.c 2007-10-02 18:18:01 UTC (rev 785)
+++ trunk/src/gpastreamop.c 2007-10-04 08:46:43 UTC (rev 786)
@@ -69,10 +69,10 @@
static void
-gpa_stream_operation_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gpa_stream_operation_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
GpaStreamOperation *op = GPA_STREAM_OPERATION (object);
@@ -101,7 +101,7 @@
gpgme_data_release (op->input_stream);
gpgme_data_release (op->output_stream);
- gpgme_data_release (op->output_stream);
+ gpgme_data_release (op->message_stream);
gtk_widget_destroy (op->progress_dialog);
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -166,7 +166,7 @@
"Data written by gpg/gpgsm",
G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
- PROP_INPUT_STREAM,
+ PROP_MESSAGE_STREAM,
g_param_spec_pointer
("message_stream", "Message Stream",
"Message data read by gpg/gpgsm",
Modified: trunk/src/server.c
===================================================================
--- trunk/src/server.c 2007-10-02 18:18:01 UTC (rev 785)
+++ trunk/src/server.c 2007-10-04 08:46:43 UTC (rev 786)
@@ -24,7 +24,10 @@
#include <assert.h>
#include <string.h>
#include <errno.h>
-
+#ifndef HAVE_W32_SYSTEM
+# include <sys/socket.h>
+# include <sys/un.h>
+#endif /*HAVE_W32_SYSTEM*/
#include <gpgme.h>
#include <glib.h>
#include <assuan.h>
@@ -57,10 +60,6 @@
GIOChannel *input_channel;
GIOChannel *output_channel;
- /* Gpgme Data objects. */
- gpgme_data_t input_data;
- gpgme_data_t output_data;
-
};
@@ -125,6 +124,7 @@
size_t nread;
int retval;
+ g_debug ("my_gpgme_read_cb: requesting %d bytes\n", (int)size);
status = g_io_channel_read_chars (ctrl->input_channel, buffer, size,
&nread, NULL);
if (status == G_IO_STATUS_AGAIN
@@ -140,8 +140,10 @@
else
{
errno = EIO;
- retval = 1;
+ retval = -1;
}
+ g_debug ("my_gpgme_read_cb: got status=%x, %d bytes, retval=%d\n",
+ status, (int)size, retval);
return retval;
}
@@ -196,8 +198,6 @@
g_debug ("cont_encrypt called with with ERR=%s <%s>",
gpg_strerror (err), gpg_strsource (err));
- gpgme_data_release (ctrl->input_data); ctrl->input_data = NULL;
- gpgme_data_release (ctrl->output_data); ctrl->output_data = NULL;
if (ctrl->input_channel)
{
g_io_channel_shutdown (ctrl->input_channel, 0, NULL);
@@ -223,6 +223,8 @@
gpg_error_t err;
gpgme_protocol_t protocol = GPGME_PROTOCOL_OpenPGP;
GpaStreamEncryptOperation *op;
+ gpgme_data_t input_data = NULL;
+ gpgme_data_t output_data = NULL;
if (has_option (line, "--protocol=OpenPGP"))
@@ -256,7 +258,7 @@
}
#ifdef HAVE_W32_SYSTEM
- ctrl->input_channel = g_io_channel_win32_new_socket (ctrl->input_fd);
+ ctrl->input_channel = g_io_channel_win32_new_fd (ctrl->input_fd);
#else
ctrl->input_channel = g_io_channel_unix_new (ctrl->input_fd);
#endif
@@ -270,7 +272,7 @@
g_io_channel_set_buffered (ctrl->input_channel, FALSE);
#ifdef HAVE_W32_SYSTEM
- ctrl->output_channel = g_io_channel_win32_new_socket (ctrl->output_fd);
+ ctrl->output_channel = g_io_channel_win32_new_fd (ctrl->output_fd);
#else
ctrl->output_channel = g_io_channel_unix_new (ctrl->output_fd);
#endif
@@ -284,23 +286,23 @@
g_io_channel_set_buffered (ctrl->output_channel, FALSE);
- err = gpgme_data_new_from_cbs (&ctrl->input_data, &my_gpgme_data_cbs, ctrl);
+ err = gpgme_data_new_from_cbs (&input_data, &my_gpgme_data_cbs, ctrl);
if (err)
goto leave;
- err = gpgme_data_new_from_cbs (&ctrl->output_data, &my_gpgme_data_cbs, ctrl);
+ err = gpgme_data_new_from_cbs (&output_data, &my_gpgme_data_cbs, ctrl);
if (err)
goto leave;
ctrl->cont_cmd = cont_encrypt;
- op = gpa_stream_encrypt_operation_new (NULL, ctrl->input_data,
- ctrl->output_data, ctx);
+ op = gpa_stream_encrypt_operation_new (NULL, input_data, output_data, ctx);
+ input_data = output_data = NULL;
g_signal_connect (G_OBJECT (op), "completed",
G_CALLBACK (g_object_unref), NULL);
return gpg_error (GPG_ERR_UNFINISHED);
leave:
- gpgme_data_release (ctrl->input_data); ctrl->input_data = NULL;
- gpgme_data_release (ctrl->output_data); ctrl->output_data = NULL;
+ gpgme_data_release (input_data);
+ gpgme_data_release (output_data);
if (ctrl->input_channel)
{
g_io_channel_shutdown (ctrl->input_channel, 0, NULL);
@@ -388,9 +390,9 @@
assuan_context_t ctx;
conn_ctrl_t ctrl;
- /* Get an assuan context for the already accepted file descriptor
- FD. */
- err = assuan_init_socket_server_ext (&ctx, ASSUAN_INT2FD(fd), 2);
+ /* Get an Assuan context for the already accepted file descriptor
+ FD. Allow descriptor passing. */
+ err = assuan_init_socket_server_ext (&ctx, ASSUAN_INT2FD(fd), 1|2);
if (err)
{
g_debug ("failed to initialize the new connection: %s",
@@ -423,8 +425,6 @@
{
conn_ctrl_t ctrl = assuan_get_pointer (ctx);
- gpgme_data_release (ctrl->input_data);
- gpgme_data_release (ctrl->output_data);
if (ctrl->input_channel)
{
g_io_channel_shutdown (ctrl->input_channel, 0, NULL);
More information about the Gpa-commits
mailing list