aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-03-22 05:45:26 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-03-22 05:45:26 +0800
commit0ec6ccc4dfc136dd7347e49e4dc2b309126706a9 (patch)
tree9ecc7f6b9100cd891fe375f3ac0b5085b7842475 /camel
parentb83cafb408e84cb77ed7f2126bb542a0b1ba0240 (diff)
downloadgsoc2013-evolution-0ec6ccc4dfc136dd7347e49e4dc2b309126706a9.tar
gsoc2013-evolution-0ec6ccc4dfc136dd7347e49e4dc2b309126706a9.tar.gz
gsoc2013-evolution-0ec6ccc4dfc136dd7347e49e4dc2b309126706a9.tar.bz2
gsoc2013-evolution-0ec6ccc4dfc136dd7347e49e4dc2b309126706a9.tar.lz
gsoc2013-evolution-0ec6ccc4dfc136dd7347e49e4dc2b309126706a9.tar.xz
gsoc2013-evolution-0ec6ccc4dfc136dd7347e49e4dc2b309126706a9.tar.zst
gsoc2013-evolution-0ec6ccc4dfc136dd7347e49e4dc2b309126706a9.zip
Return -1 on fail. (camel_filter_driver_filter_folder): Same.
2001-03-21 Jeffrey Stedfast <fejj@ximian.com> * camel-filter-driver.c (camel_filter_driver_filter_message): Return -1 on fail. (camel_filter_driver_filter_folder): Same. (camel_filter_driver_filter_mbox): Same. (camel_filter_driver_filter_folder): Return -1 if an exception was set as well. 2001-03-19 Jeffrey Stedfast <fejj@ximian.com> * camel-tcp-stream-openssl.c (camel_tcp_stream_openssl_finalize): Free the expected host. (camel_tcp_stream_openssl_new): Now takes a Service and an expected_host. Set them. svn path=/trunk/; revision=8871
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog16
-rw-r--r--camel/camel-filter-driver.c40
-rw-r--r--camel/camel-filter-driver.h6
-rw-r--r--camel/camel-tcp-stream-openssl.c27
-rw-r--r--camel/camel-tcp-stream-ssl.c2
-rw-r--r--camel/camel-vee-folder.c2
6 files changed, 63 insertions, 30 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index d41026b50e..e55967a224 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,19 @@
+2001-03-21 Jeffrey Stedfast <fejj@ximian.com>
+
+ * camel-filter-driver.c (camel_filter_driver_filter_message):
+ Return -1 on fail.
+ (camel_filter_driver_filter_folder): Same.
+ (camel_filter_driver_filter_mbox): Same.
+ (camel_filter_driver_filter_folder): Return -1 if an exception was
+ set as well.
+
+2001-03-19 Jeffrey Stedfast <fejj@ximian.com>
+
+ * camel-tcp-stream-openssl.c (camel_tcp_stream_openssl_finalize):
+ Free the expected host.
+ (camel_tcp_stream_openssl_new): Now takes a Service and an
+ expected_host. Set them.
+
2001-03-20 Dan Winship <danw@ximian.com>
* providers/imap/camel-imap-store.c
diff --git a/camel/camel-filter-driver.c b/camel/camel-filter-driver.c
index 3bee7c648a..794b105efa 100644
--- a/camel/camel-filter-driver.c
+++ b/camel/camel-filter-driver.c
@@ -608,11 +608,11 @@ camel_filter_driver_log (CamelFilterDriver *driver, enum filter_log_t status, co
* object. Is more efficient as it doesn't need to open the folder
* through Camel directly.
*
- * Returns FALSE if errors were encountered during filtering,
- * otherwise returns TRUE.
+ * Returns -1 if errors were encountered during filtering,
+ * otherwise returns 0.
*
**/
-gboolean
+int
camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const char *mbox, CamelException *ex)
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
@@ -621,7 +621,7 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const char *mbox, Ca
int fd = -1;
int i = 0;
struct stat st;
- gboolean status;
+ int status;
fd = open (mbox, O_RDONLY);
if (fd == -1) {
@@ -660,7 +660,7 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const char *mbox, Ca
status = camel_filter_driver_filter_message (driver, msg, NULL, NULL, NULL, source_url, ex);
camel_object_unref (CAMEL_OBJECT (msg));
- if (camel_exception_is_set (ex) || !status) {
+ if (camel_exception_is_set (ex) || status == -1) {
report_status (driver, CAMEL_FILTER_STATUS_END, 100, "Failed message %d", i);
goto fail;
}
@@ -678,7 +678,7 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const char *mbox, Ca
report_status (driver, CAMEL_FILTER_STATUS_END, 100, "Complete");
- return TRUE;
+ return 0;
fail:
g_free (source_url);
@@ -687,7 +687,7 @@ fail:
if (mp)
camel_object_unref (CAMEL_OBJECT (mp));
- return FALSE;
+ return -1;
}
@@ -702,11 +702,11 @@ fail:
* Filters a folder based on rules defined in the FilterDriver
* object.
*
- * Returns FALSE if errors were encountered during filtering,
- * otherwise returns TRUE.
+ * Returns -1 if errors were encountered during filtering,
+ * otherwise returns 0.
*
**/
-gboolean
+int
camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folder,
GPtrArray *uids, gboolean remove, CamelException *ex)
{
@@ -716,7 +716,7 @@ camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folde
CamelMimeMessage *message;
CamelMessageInfo *info;
char *source_url, *service_url;
- gboolean status = TRUE;
+ int status = 0;
service_url = camel_service_get_url (CAMEL_SERVICE (camel_folder_get_parent_store (folder)));
source_url = g_strdup_printf ("%s%s", service_url, camel_folder_get_full_name (folder));
@@ -737,6 +737,7 @@ camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folde
if (!message || camel_exception_is_set (ex)) {
report_status (driver, CAMEL_FILTER_STATUS_END, 100, "Failed at message %d of %d",
i+1, uids->len);
+ status = -1;
break;
}
@@ -751,9 +752,10 @@ camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folde
if (camel_folder_has_summary_capability (folder))
camel_folder_free_message_info (folder, info);
- if (camel_exception_is_set (ex) || !status) {
+ if (camel_exception_is_set (ex) || status == -1) {
report_status (driver, CAMEL_FILTER_STATUS_END, 100, "Failed at message %d of %d",
i+1, uids->len);
+ status = -1;
break;
}
@@ -797,11 +799,11 @@ camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folde
* certain cases is more efficient than using the default
* camel_folder_append_message() function).
*
- * Returns FALSE if errors were encountered during filtering,
- * otherwise returns TRUE.
+ * Returns -1 if errors were encountered during filtering,
+ * otherwise returns 0.
*
**/
-gboolean
+int
camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage *message,
CamelMessageInfo *info, const char *uid,
CamelFolder *source, const char *source_url,
@@ -820,7 +822,7 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
freeinfo = TRUE;
} else {
if (info->flags & CAMEL_MESSAGE_DELETED)
- return TRUE;
+ return 0;
}
p->ex = ex;
@@ -839,7 +841,7 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
if (camel_filter_search_match(p->message, p->info, source_url, node->match, p->ex)) {
filtered = TRUE;
camel_filter_driver_log (driver, FILTER_LOG_START, node->name);
-
+
/* perform necessary filtering actions */
e_sexp_input_text (p->eval, node->action, strlen (node->action));
if (e_sexp_parse (p->eval) == -1) {
@@ -873,7 +875,7 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
camel_folder_append_message (p->defaultfolder, p->message, p->info, p->ex);
}
- return TRUE;
+ return 0;
error:
if (filtered)
@@ -882,5 +884,5 @@ error:
if (freeinfo)
camel_message_info_free (info);
- return FALSE;
+ return -1;
}
diff --git a/camel/camel-filter-driver.h b/camel/camel-filter-driver.h
index 72737d31de..fdebb4228e 100644
--- a/camel/camel-filter-driver.h
+++ b/camel/camel-filter-driver.h
@@ -72,13 +72,13 @@ void camel_filter_driver_add_rule (CamelFilterDriver *d, const char *name, con
/*void camel_filter_driver_set_global(CamelFilterDriver *, const char *name, const char *value);*/
-gboolean camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage *message,
+int camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage *message,
CamelMessageInfo *info, const char *uri,
CamelFolder *source, const char *source_url,
CamelException *ex);
-gboolean camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const char *mbox,
+int camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const char *mbox,
CamelException *ex);
-gboolean camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folder,
+int camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folder,
GPtrArray *uids, gboolean remove, CamelException *ex);
#if 0
diff --git a/camel/camel-tcp-stream-openssl.c b/camel/camel-tcp-stream-openssl.c
index 1830c8dab6..39a42d615b 100644
--- a/camel/camel-tcp-stream-openssl.c
+++ b/camel/camel-tcp-stream-openssl.c
@@ -53,6 +53,9 @@ static gpointer stream_get_socket (CamelTcpStream *stream);
struct _CamelTcpStreamOpenSSLPrivate {
int sockfd;
SSL *ssl;
+
+ CamelService *service;
+ char *expected_host;
};
static void
@@ -82,9 +85,8 @@ camel_tcp_stream_openssl_init (gpointer object, gpointer klass)
{
CamelTcpStreamOpenSSL *stream = CAMEL_TCP_STREAM_OPENSSL (object);
- stream->priv = g_new (struct _CamelTcpStreamOpenSSLPrivate, 1);
+ stream->priv = g_new0 (struct _CamelTcpStreamOpenSSLPrivate, 1);
stream->priv->sockfd = -1;
- stream->priv->ssl = NULL;
}
static void
@@ -104,6 +106,8 @@ camel_tcp_stream_openssl_finalize (CamelObject *object)
if (stream->priv->sockfd != -1)
close (stream->priv->sockfd);
+ g_free (stream->priv->expected_host);
+
g_free (stream->priv);
}
@@ -130,16 +134,25 @@ camel_tcp_stream_openssl_get_type (void)
/**
* camel_tcp_stream_openssl_new:
+ * @service: camel service
+ * @expected_host: host that the stream is expecting to connect with.
+ *
+ * Since the SSL certificate authenticator may need to prompt the
+ * user, a CamelService is needed. @expected_host is needed as a
+ * protection against an MITM attack.
*
* Return value: a tcp stream
**/
CamelStream *
-camel_tcp_stream_openssl_new ()
+camel_tcp_stream_openssl_new (CamelService *service, const char *expected_host)
{
CamelTcpStreamOpenSSL *stream;
stream = CAMEL_TCP_STREAM_OPENSSL (camel_object_new (camel_tcp_stream_openssl_get_type ()));
+ stream->priv->service = service;
+ stream->priv->expected_host = g_strdup (expected_host);
+
return CAMEL_STREAM (stream);
}
@@ -360,7 +373,7 @@ socket_connect (struct hostent *h, int port)
}
static int
-verify_callback (int ok, X509_STORE_CTX *ctx)
+ssl_verify (int ok, X509_STORE_CTX *ctx)
{
char *str, buf[256];
X509 *cert;
@@ -392,7 +405,7 @@ verify_callback (int ok, X509_STORE_CTX *ctx)
}
static SSL *
-open_ssl_connection (int sockfd)
+open_ssl_connection (CamelService *service, int sockfd)
{
SSL_CTX *ssl_ctx = NULL;
SSL *ssl = NULL;
@@ -400,7 +413,7 @@ open_ssl_connection (int sockfd)
/* SSLv23_client_method will negotiate with SSL v2, v3, or TLS v1 */
ssl_ctx = SSL_CTX_new (SSLv23_client_method ());
- SSL_CTX_set_verify (ssl_ctx, SSL_VERIFY_PEER, &verify_cb);
+ SSL_CTX_set_verify (ssl_ctx, SSL_VERIFY_PEER, &ssl_verify);
ssl = SSL_new (ssl_ctx);
SSL_set_fd (ssl, sockfd);
@@ -431,7 +444,7 @@ stream_connect (CamelTcpStream *stream, struct hostent *host, int port)
if (fd == -1)
return -1;
- ssl = open_ssl_connection (sockfd);
+ ssl = open_ssl_connection (stream->priv->service, sockfd);
if (!ssl)
return -1;
diff --git a/camel/camel-tcp-stream-ssl.c b/camel/camel-tcp-stream-ssl.c
index 708c58e364..e108dc5507 100644
--- a/camel/camel-tcp-stream-ssl.c
+++ b/camel/camel-tcp-stream-ssl.c
@@ -131,7 +131,7 @@ camel_tcp_stream_ssl_get_type (void)
* @expected_host: host that the stream is expected to connect with.
*
* Since the SSL certificate authenticator may need to prompt the
- * user, a CamelService is needed. #expected_host is needed as a
+ * user, a CamelService is needed. @expected_host is needed as a
* protection against an MITM attack.
*
* Return value: a tcp stream
diff --git a/camel/camel-vee-folder.c b/camel/camel-vee-folder.c
index cb6ef4bf91..55a355ae2f 100644
--- a/camel/camel-vee-folder.c
+++ b/camel/camel-vee-folder.c
@@ -20,6 +20,8 @@
* USA
*/
+#include <config.h>
+
#include "camel-exception.h"
#include "camel-vee-folder.h"
#include "camel-store.h"