1 /* Copyright (c) 2006, Nokia Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of the Nokia Corporation nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include <modest-transport-account-decorator.h>
32 #include <modest-tny-account-store.h>
33 #include <modest-tny-account.h>
34 #include <modest-runtime.h>
35 #include <tny-simple-list.h>
36 #include <tny-iterator.h>
37 #include <tny-folder.h>
38 #include <modest-marshal.h>
39 #include <string.h> /* strcmp */
41 /* 'private'/'protected' functions */
42 static void modest_transport_account_decorator_class_init (ModestTransportAccountDecoratorClass *klass);
43 static void modest_transport_account_decorator_finalize (GObject *obj);
44 static void modest_transport_account_decorator_instance_init (GTypeInstance *instance, gpointer g_class);
45 static void modest_transport_account_decorator_send (TnyTransportAccount *self, TnyMsg *msg, GError **err);
49 /* /\* MY_SIGNAL_1, *\/ */
50 /* /\* MY_SIGNAL_2, *\/ */
54 /* typedef struct _ModestTransportAccountDecoratorPrivate ModestTransportAccountDecoratorPrivate; */
55 /* struct _ModestTransportAccountDecoratorPrivate { */
58 /* #define MODEST_TRANSPORT_ACCOUNT_DECORATOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ */
59 /* MODEST_TYPE_TRANSPORT_ACCOUNT_DECORATOR, \ */
60 /* ModestTransportAccountDecoratorPrivate)) */
63 static TnyCamelTransportAccountClass *parent_class = NULL;
65 /* uncomment the following if you have defined any signals */
66 /* static guint signals[LAST_SIGNAL] = {0}; */
69 * this thread actually tries to send all the mails in the outbox and keeps
70 * track of their state.
73 modest_transport_account_decorator_send (TnyTransportAccount *self, TnyMsg *msg, GError **err)
75 TnyTransportAccount *connection_specific_account = NULL;
76 /* ModestTransportAccountDecoratorPrivate *priv = MODEST_TRANSPORT_ACCOUNT_DECORATOR_GET_PRIVATE (self); */
77 ModestTnyAccountStore *store = modest_runtime_get_account_store ();
78 const gchar *account_name;
80 account_name = modest_tny_account_get_parent_modest_account_name_for_server_account (TNY_ACCOUNT (self));
82 connection_specific_account = TNY_TRANSPORT_ACCOUNT
83 (modest_tny_account_store_get_smtp_specific_transport_account_for_open_connection (store, account_name));
86 if (connection_specific_account) {
87 tny_transport_account_send (connection_specific_account, msg, err);
89 TNY_CAMEL_TRANSPORT_ACCOUNT_CLASS(parent_class)->send_func (self, msg, err);
94 modest_transport_account_decorator_class_init (ModestTransportAccountDecoratorClass *klass)
96 GObjectClass *gobject_class;
97 TnyCamelTransportAccountClass *transport_class;
99 gobject_class = (GObjectClass*) klass;
100 transport_class = (TnyCamelTransportAccountClass *) klass;
102 parent_class = g_type_class_peek_parent (klass);
103 gobject_class->finalize = modest_transport_account_decorator_finalize;
105 transport_class->send_func = modest_transport_account_decorator_send;
107 /* g_type_class_add_private (gobject_class, sizeof(ModestTransportAccountDecoratorPrivate)); */
111 modest_transport_account_decorator_instance_init (GTypeInstance *instance, gpointer g_class)
113 /* ModestTransportAccountDecoratorPrivate *priv; */
115 /* priv = MODEST_TRANSPORT_ACCOUNT_DECORATOR_GET_PRIVATE (instance); */
119 modest_transport_account_decorator_finalize (GObject *obj)
121 /* ModestTransportAccountDecoratorPrivate *priv; */
123 /* priv = MODEST_TRANSPORT_ACCOUNT_DECORATOR_GET_PRIVATE (obj); */
125 G_OBJECT_CLASS(parent_class)->finalize (obj);
128 ModestTransportAccountDecorator*
129 modest_transport_account_decorator_new (void)
131 ModestTransportAccountDecorator *self;
132 /* ModestTransportAccountDecoratorPrivate *priv; */
134 self = MODEST_TRANSPORT_ACCOUNT_DECORATOR(g_object_new(MODEST_TYPE_TRANSPORT_ACCOUNT_DECORATOR, NULL));
135 /* priv = MODEST_TRANSPORT_ACCOUNT_DECORATOR_GET_PRIVATE (self); */
141 modest_transport_account_decorator_get_type (void)
143 static GType my_type = 0;
146 static const GTypeInfo my_info = {
147 sizeof(ModestTransportAccountDecoratorClass),
148 NULL, /* base init */
149 NULL, /* base finalize */
150 (GClassInitFunc) modest_transport_account_decorator_class_init,
151 NULL, /* class finalize */
152 NULL, /* class data */
153 sizeof(ModestTransportAccountDecorator),
155 (GInstanceInitFunc) modest_transport_account_decorator_instance_init,
159 my_type = g_type_register_static (TNY_TYPE_CAMEL_TRANSPORT_ACCOUNT,
160 "ModestTransportAccountDecorator",