[evolution-data-server] camel_stream_process_connect(): Add GError parameter.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] camel_stream_process_connect(): Add GError parameter.
- Date: Tue, 5 Jul 2011 11:01:34 +0000 (UTC)
commit 064457e38c91ff903d81a60eabf00a151a142142
Author: Matthew Barnes <mbarnes redhat com>
Date: Tue Jul 5 07:00:48 2011 -0400
camel_stream_process_connect(): Add GError parameter.
camel/camel-sasl-ntlm.c | 2 +-
camel/camel-stream-process.c | 24 +++++++++++++++++--
camel/camel-stream-process.h | 3 +-
camel/providers/imap/camel-imap-store.c | 18 +++-----------
camel/providers/imapx/camel-imapx-server.c | 18 +++-----------
.../reference/camel/tmpl/camel-stream-process.sgml | 1 +
6 files changed, 33 insertions(+), 33 deletions(-)
---
diff --git a/camel/camel-sasl-ntlm.c b/camel/camel-sasl-ntlm.c
index e25078a..d03c9d0 100644
--- a/camel/camel-sasl-ntlm.c
+++ b/camel/camel-sasl-ntlm.c
@@ -862,7 +862,7 @@ sasl_ntlm_try_empty_password_sync (CamelSasl *sasl,
NTLM_AUTH_HELPER, url->user);
}
ret = camel_stream_process_connect (
- CAMEL_STREAM_PROCESS (stream), command, NULL);
+ CAMEL_STREAM_PROCESS (stream), command, NULL, error);
g_free (command);
if (ret) {
g_object_unref (stream);
diff --git a/camel/camel-stream-process.c b/camel/camel-stream-process.c
index 8202552..be710a3 100644
--- a/camel/camel-stream-process.c
+++ b/camel/camel-stream-process.c
@@ -39,6 +39,8 @@
#include <sys/types.h>
#include <sys/wait.h>
+#include <glib/gi18n-lib.h>
+
#include "camel-file-utils.h"
#include "camel-stream-process.h"
@@ -226,7 +228,8 @@ do_exec_command (gint fd, const gchar *command, gchar **env)
gint
camel_stream_process_connect (CamelStreamProcess *stream,
const gchar *command,
- const gchar **env)
+ const gchar **env,
+ GError **error)
{
gint sockfds[2];
@@ -237,7 +240,7 @@ camel_stream_process_connect (CamelStreamProcess *stream,
camel_stream_close (CAMEL_STREAM (stream), NULL, NULL);
if (socketpair (AF_UNIX, SOCK_STREAM, 0, sockfds))
- return -1;
+ goto fail;
stream->childpid = fork ();
if (!stream->childpid) {
@@ -246,11 +249,26 @@ camel_stream_process_connect (CamelStreamProcess *stream,
close (sockfds[0]);
close (sockfds[1]);
stream->sockfd = -1;
- return -1;
+ goto fail;
}
close (sockfds[1]);
stream->sockfd = sockfds[0];
return 0;
+
+fail:
+ if (errno == EINTR)
+ g_set_error (
+ error, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ _("Connection cancelled"));
+ else
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ _("Could not connect with command \"%s\": %s"),
+ command, g_strerror (errno));
+
+ return -1;
}
diff --git a/camel/camel-stream-process.h b/camel/camel-stream-process.h
index 047b112..27b41f5 100644
--- a/camel/camel-stream-process.h
+++ b/camel/camel-stream-process.h
@@ -67,7 +67,8 @@ GType camel_stream_process_get_type (void);
CamelStream * camel_stream_process_new (void);
gint camel_stream_process_connect (CamelStreamProcess *stream,
const gchar *command,
- const gchar **env);
+ const gchar **env,
+ GError **error);
G_END_DECLS
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index 45dd797..2b9beef 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -549,29 +549,19 @@ connect_to_server_process (CamelService *service,
cmd_stream = camel_stream_process_new ();
- ret = camel_stream_process_connect (CAMEL_STREAM_PROCESS (cmd_stream),
- full_cmd, (const gchar **) child_env);
+ ret = camel_stream_process_connect (
+ CAMEL_STREAM_PROCESS (cmd_stream),
+ full_cmd, (const gchar **) child_env, error);
while (i)
g_free (child_env[--i]);
if (ret == -1) {
- if (errno == EINTR)
- g_set_error (
- error, G_IO_ERROR,
- G_IO_ERROR_CANCELLED,
- _("Connection cancelled"));
- else
- g_set_error (
- error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Could not connect with command \"%s\": %s"),
- full_cmd, g_strerror (errno));
-
g_object_unref (cmd_stream);
g_free (full_cmd);
return FALSE;
}
+
g_free (full_cmd);
store->ostream = cmd_stream;
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index fbc208b..52270bd 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -2803,29 +2803,19 @@ connect_to_server_process (CamelIMAPXServer *is, const gchar *cmd, GError **erro
cmd_stream = camel_stream_process_new ();
- ret = camel_stream_process_connect (CAMEL_STREAM_PROCESS (cmd_stream),
- full_cmd, (const gchar **) child_env);
+ ret = camel_stream_process_connect (
+ CAMEL_STREAM_PROCESS (cmd_stream),
+ full_cmd, (const gchar **) child_env, error);
while (i)
g_free (child_env[--i]);
if (ret == -1) {
- if (errno == EINTR)
- g_set_error (
- error, G_IO_ERROR,
- G_IO_ERROR_CANCELLED,
- _("Connection cancelled"));
- else
- g_set_error (
- error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Could not connect with command \"%s\": %s"),
- full_cmd, g_strerror (errno));
-
g_object_unref (cmd_stream);
g_free (full_cmd);
return FALSE;
}
+
g_free (full_cmd);
is->stream = (CamelIMAPXStream *) camel_imapx_stream_new (cmd_stream);
diff --git a/docs/reference/camel/tmpl/camel-stream-process.sgml b/docs/reference/camel/tmpl/camel-stream-process.sgml
index bd9d293..f4b987b 100644
--- a/docs/reference/camel/tmpl/camel-stream-process.sgml
+++ b/docs/reference/camel/tmpl/camel-stream-process.sgml
@@ -43,6 +43,7 @@ CamelStreamProcess
@stream:
@command:
@env:
+ error:
@Returns:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]