1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* camel-transport.c : Abstract class for an email transport */
7 * Dan Winship <danw@ximian.com>
9 * Copyright 2000 Ximian, Inc. (www.ximian.com)
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of version 2 of the GNU Lesser General Public
13 * License as published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
30 #include "camel-address.h"
31 #include "camel-mime-message.h"
32 #include "camel-private.h"
33 #include "camel-transport.h"
35 static CamelServiceClass *parent_class = NULL;
37 /* Returns the class for a CamelTransport */
38 #define CT_CLASS(so) CAMEL_TRANSPORT_CLASS (CAMEL_OBJECT_GET_CLASS(so))
40 static int transport_setv (CamelObject *object, CamelException *ex, CamelArgV *args);
41 static int transport_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args);
45 camel_transport_class_init (CamelTransportClass *camel_transport_class)
47 CamelObjectClass *camel_object_class = CAMEL_OBJECT_CLASS (camel_transport_class);
49 parent_class = CAMEL_SERVICE_CLASS (camel_type_get_global_classfuncs (camel_service_get_type ()));
51 /* virtual method overload */
52 camel_object_class->setv = transport_setv;
53 camel_object_class->getv = transport_getv;
57 camel_transport_init (gpointer object, gpointer klass)
59 CamelTransport *xport = object;
61 xport->priv = g_malloc0 (sizeof (struct _CamelTransportPrivate));
62 xport->priv->send_lock = g_mutex_new ();
66 camel_transport_finalize (CamelObject *object)
68 CamelTransport *xport = CAMEL_TRANSPORT (object);
70 g_mutex_free (xport->priv->send_lock);
75 camel_transport_get_type (void)
77 static CamelType type = CAMEL_INVALID_TYPE;
79 if (type == CAMEL_INVALID_TYPE) {
80 type = camel_type_register (CAMEL_SERVICE_TYPE,
82 sizeof (CamelTransport),
83 sizeof (CamelTransportClass),
84 (CamelObjectClassInitFunc) camel_transport_class_init,
86 (CamelObjectInitFunc) camel_transport_init,
87 (CamelObjectFinalizeFunc) camel_transport_finalize);
95 transport_setv (CamelObject *object, CamelException *ex, CamelArgV *args)
97 /* CamelTransport doesn't currently have anything to set */
98 return CAMEL_OBJECT_CLASS (parent_class)->setv (object, ex, args);
102 transport_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args)
104 /* CamelTransport doesn't currently have anything to get */
105 return CAMEL_OBJECT_CLASS (parent_class)->getv (object, ex, args);
110 * camel_transport_send_to:
111 * @transport: a #CamelTransport object
112 * @message: a #CamelMimeMessage to send
113 * @from: a #CamelAddress to send from
114 * @recipients: a #CamelAddress containing all recipients
115 * @ex: a #CamelException
117 * Sends the message to the given recipients, regardless of the contents
118 * of @message. If the message contains a "Bcc" header, the transport
119 * is responsible for stripping it.
121 * Return %TRUE on success or %FALSE on fail
124 camel_transport_send_to (CamelTransport *transport, CamelMimeMessage *message,
125 CamelAddress *from, CamelAddress *recipients,
130 g_return_val_if_fail (CAMEL_IS_TRANSPORT (transport), FALSE);
131 g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), FALSE);
132 g_return_val_if_fail (CAMEL_IS_ADDRESS (from), FALSE);
133 g_return_val_if_fail (CAMEL_IS_ADDRESS (recipients), FALSE);
135 CAMEL_TRANSPORT_LOCK (transport, send_lock);
136 sent = CT_CLASS (transport)->send_to (transport, message,
137 from, recipients, ex);
138 CAMEL_TRANSPORT_UNLOCK (transport, send_lock);