* modest-tny-send-queue.[ch]:
[modest] / src / modest-tny-send-queue.c
1 /* Copyright (c) 2006, Nokia Corporation
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
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.
16  *
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.
28  */
29
30
31 #include <modest-tny-send-queue.h>
32
33 /* 'private'/'protected' functions */
34 static void modest_tny_send_queue_class_init (ModestTnySendQueueClass *klass);
35 static void modest_tny_send_queue_init       (ModestTnySendQueue *obj);
36 static void modest_tny_send_queue_finalize   (GObject *obj);
37 /* list my signals  */
38 enum {
39         /* MY_SIGNAL_1, */
40         /* MY_SIGNAL_2, */
41         LAST_SIGNAL
42 };
43
44 typedef struct _ModestTnySendQueuePrivate ModestTnySendQueuePrivate;
45 struct _ModestTnySendQueuePrivate {
46         /* my private members go here, eg. */
47         /* gboolean frobnicate_mode; */
48 };
49 #define MODEST_TNY_SEND_QUEUE_GET_PRIVATE(o)      (G_TYPE_INSTANCE_GET_PRIVATE((o), \
50                                                    MODEST_TYPE_TNY_SEND_QUEUE, \
51                                                    ModestTnySendQueuePrivate))
52 /* globals */
53 static TnySendQueueClass *parent_class = NULL;
54
55 /* uncomment the following if you have defined any signals */
56 /* static guint signals[LAST_SIGNAL] = {0}; */
57
58
59 static void
60 modest_tny_send_queue_cancel (TnySendQueue *self, gboolean remove)
61 {
62         MODEST_TNY_SENT_QUEUE_GET_CLASS(self)->cancel_func (self, remove);
63 }
64
65 static void
66 modest_tny_send_queue_add (TnySendQueue *self, TnyMsg *msg)
67 {
68         MODEST_TNY_SENT_QUEUE_GET_CLASS(self)->add_func (self, msg);
69 }
70
71
72 static void
73 modest_tny_send_queue_get_sentbox (TnySendQueue *self)
74 {
75         MODEST_TNY_SENT_QUEUE_GET_CLASS(self)->get_sentbox (self);
76 }
77
78
79 static void
80 modest_tny_send_queue_get_outbox (TnySendQueue *self, TnyMsg *msg)
81 {
82         MODEST_TNY_SENT_QUEUE_GET_CLASS(self)->get_outbox (self);
83 }
84
85
86
87
88 static void
89 modest_tny_send_queue_cancel_default (TnySendQueue *self, gboolean remove)
90 {
91         /* FIXME */
92 }
93
94
95 static void
96 modest_tny_send_queue_add_default (TnySendQueue *self, TnyMsg *msg)
97 {
98         /* FIXME */
99 }
100
101
102 static TnyFolder*
103 modest_tny_send_queue_get_sentbox_default (TnySendQueue *self)
104 {
105         MODEST_TNY_SENT_QUEUE_GET_CLASS(self)->get_sentbox (self);
106 }
107
108
109 static TnyFolder*
110 modest_tny_send_queue_get_outbox_default (TnySendQueue *self, TnyMsg *msg)
111 {
112         MODEST_TNY_SENT_QUEUE_GET_CLASS(self)->get_outbox (self);
113 }
114
115
116
117
118 GType
119 modest_tny_send_queue_get_type (void)
120 {
121         static GType my_type = 0;
122         if (!my_type) {
123                 static const GTypeInfo my_info = {
124                         sizeof(ModestTnySendQueueClass),
125                         NULL,           /* base init */
126                         NULL,           /* base finalize */
127                         (GClassInitFunc) modest_tny_send_queue_class_init,
128                         NULL,           /* class finalize */
129                         NULL,           /* class data */
130                         sizeof(ModestTnySendQueue),
131                         1,              /* n_preallocs */
132                         (GInstanceInitFunc) modest_tny_send_queue_init,
133                         NULL
134                 };
135                 my_type = g_type_register_static (TNY__TYPE__SEND_QUEUE,
136                                                   "ModestTnySendQueue",
137                                                   &my_info, 0);
138         }
139         return my_type;
140 }
141
142
143 static void
144 modest_tny_send_queue_init (gpointer g, gpointer iface_data)
145 {
146         TnySendQueueIface *klass = (TnySendQueueIface*)g;
147         
148         klass->add_func         = modest_tny_send_queue_add;
149         klass->get_outbox_func  = modest_tny_send_queue_get_outbox;
150         klass->get_sentbox_func = modest_tny_send_queue_get_sentbox;
151         klass->cancel_func      = modest_tny_send_queue_cancel;
152 }
153
154
155
156 static void
157 modest_tny_send_queue_class_init (ModestTnySendQueueClass *klass)
158 {
159         GObjectClass *gobject_class;
160
161         gobject_class = (GObjectClass*) klass;
162         
163         parent_class            = g_type_class_peek_parent (klass);
164         gobject_class->finalize = modest_tny_send_queue_finalize;
165
166         klass->add_func         = modest_tny_send_queue_add_default;
167         klass->get_outbox_func  = modest_tny_send_queue_get_outbox_default;
168         klass->get_sentbox_func = modest_tny_send_queue_get_sentbox_default;
169         klass->cancel_func      = modest_tny_send_queue_cancel_default;
170
171         g_type_class_add_private (gobject_class, sizeof(ModestTnySendQueuePrivate));
172 }
173
174 static void
175 modest_tny_send_queue_instance_init (GTypeInstance *instance, gpointer g_class)
176 {
177         TnyCamelSendQueue *self;  
178         TnyCamelSendQueuePriv *priv; 
179
180         self = (TnyCamelSendQueue*)instance;
181         priv = TNY_CAMEL_SEND_QUEUE_GET_PRIVATE (self);
182         
183         priv->sentbox_cache = NULL;
184         priv->outbox_cache = NULL;
185 }
186
187 static void
188 modest_tny_send_queue_finalize (GObject *obj)
189 {
190 /*      free/unref instance resources here */
191         G_OBJECT_CLASS(parent_class)->finalize (obj);
192 }
193
194 ModestTnySendQueue*
195 modest_tny_send_queue_new (void)
196 {
197         return MODEST_TNY_SEND_QUEUE(g_object_new(MODEST_TYPE_TNY_SEND_QUEUE, NULL));
198 }
199