aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-transport.c
diff options
context:
space:
mode:
Diffstat (limited to 'camel/camel-transport.c')
-rw-r--r--camel/camel-transport.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/camel/camel-transport.c b/camel/camel-transport.c
index 5d902ddd33..0338f5dcc0 100644
--- a/camel/camel-transport.c
+++ b/camel/camel-transport.c
@@ -30,10 +30,33 @@
#include "camel-transport.h"
#include "camel-exception.h"
+#include "camel-private.h"
/* Returns the class for a CamelTransport */
#define CT_CLASS(so) CAMEL_TRANSPORT_CLASS (CAMEL_OBJECT_GET_CLASS(so))
+static void
+camel_transport_init (gpointer object, gpointer klass)
+{
+ CamelTransport *xport = object;
+
+ xport->priv = g_malloc0 (sizeof (struct _CamelTransportPrivate));
+#ifdef ENABLE_THREADS
+ xport->priv->send_lock = g_mutex_new ();
+#endif
+}
+
+static void
+camel_transport_finalize (CamelObject *object)
+{
+ CamelTransport *xport = CAMEL_TRANSPORT (object);
+
+#ifdef ENABLE_THREADS
+ g_mutex_free (xport->priv->send_lock);
+#endif
+ g_free (xport->priv);
+}
+
CamelType
camel_transport_get_type (void)
{
@@ -45,8 +68,8 @@ camel_transport_get_type (void)
sizeof (CamelTransportClass),
NULL,
NULL,
- NULL,
- NULL);
+ (CamelObjectInitFunc) camel_transport_init,
+ (CamelObjectFinalizeFunc) camel_transport_finalize);
}
return camel_transport_type;
@@ -84,7 +107,15 @@ gboolean
camel_transport_send (CamelTransport *transport, CamelMedium *message,
CamelException *ex)
{
- return CT_CLASS (transport)->send (transport, message, ex);
+ gboolean sent;
+
+ g_return_val_if_fail (CAMEL_IS_TRANSPORT (transport), FALSE);
+
+ CAMEL_TRANSPORT_LOCK (transport, send_lock);
+ sent = CT_CLASS (transport)->send (transport, message, ex);
+ CAMEL_TRANSPORT_UNLOCK (transport, send_lock);
+
+ return sent;
}
/**
@@ -103,6 +134,14 @@ gboolean
camel_transport_send_to (CamelTransport *transport, CamelMedium *message,
GList *recipients, CamelException *ex)
{
- return CT_CLASS (transport)->send_to (transport, message,
+ gboolean sent;
+
+ g_return_val_if_fail (CAMEL_IS_TRANSPORT (transport), FALSE);
+
+ CAMEL_TRANSPORT_LOCK (transport, send_lock);
+ sent = CT_CLASS (transport)->send_to (transport, message,
recipients, ex);
+ CAMEL_TRANSPORT_UNLOCK (transport, send_lock);
+
+ return sent;
}