When moving messages to a local folder don't try to connect if the
[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 #include <tny-simple-list.h>
33 #include <tny-iterator.h>
34 #include <tny-folder.h>
35 #include <tny-camel-msg.h>
36 #include <tny-folder-change.h>
37 #include <tny-folder-observer.h>
38 #include <modest-tny-account.h>
39 #include <modest-runtime.h>
40 #include <modest-platform.h>
41 #include <widgets/modest-window-mgr.h>
42 #include <modest-marshal.h>
43 #include <string.h> /* strcmp */
44
45 /* 'private'/'protected' functions */
46 static void modest_tny_send_queue_class_init (ModestTnySendQueueClass *klass);
47 static void modest_tny_send_queue_finalize   (GObject *obj);
48 static void modest_tny_send_queue_instance_init (GTypeInstance *instance, gpointer g_class);
49
50 /* Signal handlers */ 
51 static void _on_msg_start_sending (TnySendQueue *self, TnyHeader *header, TnyMsg *msg, int done, int total, gpointer user_data);
52 static void _on_msg_has_been_sent (TnySendQueue *self, TnyHeader *header, TnyMsg *msg, int done, int total, gpointer user_data);
53 static void _on_msg_error_happened (TnySendQueue *self, TnyHeader *header, TnyMsg *msg, GError *err, gpointer user_data);
54
55 static TnyFolder*modest_tny_send_queue_get_outbox (TnySendQueue *self);
56 static TnyFolder*modest_tny_send_queue_get_sentbox (TnySendQueue *self);
57
58 /* list my signals  */
59 enum {
60         STATUS_CHANGED,
61         /* MY_SIGNAL_1, */
62         /* MY_SIGNAL_2, */
63         LAST_SIGNAL
64 };
65
66 typedef struct _SendInfo SendInfo;
67 struct _SendInfo {
68         gchar* msg_id;
69         ModestTnySendQueueStatus status;
70 };
71
72 typedef struct _ModestTnySendQueuePrivate ModestTnySendQueuePrivate;
73 struct _ModestTnySendQueuePrivate {
74         /* Queued infos */
75         GQueue* queue;
76
77         /* The info that is currently being sent */
78         GList* current;
79 };
80
81 #define MODEST_TNY_SEND_QUEUE_GET_PRIVATE(o)      (G_TYPE_INSTANCE_GET_PRIVATE((o), \
82                                                    MODEST_TYPE_TNY_SEND_QUEUE, \
83                                                    ModestTnySendQueuePrivate))
84
85 /* globals */
86 static TnyCamelSendQueueClass *parent_class = NULL;
87
88 /* uncomment the following if you have defined any signals */
89 static guint signals[LAST_SIGNAL] = {0};
90
91 /*
92  * this thread actually tries to send all the mails in the outbox and keeps
93  * track of their state.
94  */
95
96 static int
97 on_modest_tny_send_queue_compare_id(gconstpointer info, gconstpointer msg_id)
98 {
99         g_return_val_if_fail (info && ((SendInfo*)info)->msg_id && msg_id, -1);
100         
101         return strcmp( ((SendInfo*)info)->msg_id, msg_id);
102 }
103
104 static void
105 modest_tny_send_queue_info_free(SendInfo *info)
106 {
107         g_free(info->msg_id);
108         g_slice_free(SendInfo, info);
109 }
110
111 static GList*
112 modest_tny_send_queue_lookup_info (ModestTnySendQueue *self, const gchar *msg_id)
113 {
114         ModestTnySendQueuePrivate *priv;
115         priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self);
116
117         return g_queue_find_custom (priv->queue, msg_id, on_modest_tny_send_queue_compare_id);
118 }
119
120 static void
121 modest_tny_send_queue_cancel (TnySendQueue *self, gboolean remove, GError **err)
122 {
123         ModestTnySendQueuePrivate *priv;
124         SendInfo *info;
125         TnyIterator *iter = NULL;
126         TnyFolder *outbox = NULL;
127         TnyList *headers = tny_simple_list_new ();
128         TnyHeader *header = NULL;
129
130         priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self);
131         if(priv->current != NULL)
132         {
133                 info = priv->current->data;
134                 priv->current = NULL;
135
136                 /* Keep in list until retry, so that we know that this was suspended
137                  * by the user and not by an error. */
138                 info->status = MODEST_TNY_SEND_QUEUE_SUSPENDED;
139
140                 g_signal_emit (self, signals[STATUS_CHANGED], 0, info->msg_id, info->status);
141         }
142
143         /* Set flags to supend sending operaiton (if removed, this is not necessary) */
144         if (!remove) {          
145                 outbox = modest_tny_send_queue_get_outbox (TNY_SEND_QUEUE(self));
146                 tny_folder_get_headers (outbox, headers, TRUE, err);
147                 if (err != NULL) goto frees;
148                 iter = tny_list_create_iterator (headers);
149                 while (!tny_iterator_is_done (iter)) {
150                         header = TNY_HEADER (tny_iterator_get_current (iter));
151                         if (header) {   
152                                 tny_header_unset_flags (header, TNY_HEADER_FLAG_PRIORITY);
153                                 tny_header_set_flags (header, TNY_HEADER_FLAG_SUSPENDED_PRIORITY);
154                                 tny_iterator_next (iter);
155                                 g_object_unref (header);
156                         }
157                 }
158                 
159                 g_queue_foreach (priv->queue, (GFunc)modest_tny_send_queue_info_free, NULL);
160                 g_queue_free (priv->queue);
161                 priv->queue = g_queue_new();
162         }
163                 
164         /* Dont call super class implementaiton, becasue camel removes messages from outbox */
165         TNY_CAMEL_SEND_QUEUE_CLASS(parent_class)->cancel_func (self, remove, err); /* FIXME */
166
167  frees:
168         if (headers != NULL)
169                 g_object_unref (G_OBJECT (headers));
170         if (outbox != NULL) 
171                 g_object_unref (G_OBJECT (outbox));
172         if (iter != NULL) 
173                 g_object_unref (iter);
174 }
175
176 static void
177 _on_added_to_outbox (TnySendQueue *self, gboolean cancelled, TnyMsg *msg, GError *err, gpointer user_data) 
178 {
179         ModestTnySendQueuePrivate *priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE(self);
180         TnyHeader *header = NULL;
181         SendInfo *info = NULL;
182         GList* existing = NULL;
183         const gchar* msg_id = NULL;
184
185         g_return_if_fail (TNY_IS_SEND_QUEUE(self));
186         g_return_if_fail (TNY_IS_CAMEL_MSG(msg));
187
188         header = tny_msg_get_header (msg);
189         msg_id = modest_tny_send_queue_get_msg_id (header);
190 /*      msg_id = tny_header_get_message_id (header); */
191         g_return_if_fail(msg_id != NULL);
192
193         /* Put newly added message in WAITING state */
194         existing = modest_tny_send_queue_lookup_info (MODEST_TNY_SEND_QUEUE(self), msg_id);
195         if(existing != NULL)
196         {
197                 info = existing->data;
198                 info->status = MODEST_TNY_SEND_QUEUE_WAITING;
199         }
200         else
201         {
202                 
203                 info = g_slice_new (SendInfo);
204
205                 info->msg_id = strdup(msg_id);
206                 info->status = MODEST_TNY_SEND_QUEUE_WAITING;
207                 g_queue_push_tail (priv->queue, info);
208         }
209
210         g_signal_emit (self, signals[STATUS_CHANGED], 0, info->msg_id, info->status);
211
212         g_object_unref(G_OBJECT(header));
213 }
214
215 void
216 modest_tny_send_queue_add (ModestTnySendQueue *self, TnyMsg *msg, GError **err)
217 {
218         g_return_if_fail (MODEST_IS_TNY_SEND_QUEUE(self));
219         g_return_if_fail (TNY_IS_CAMEL_MSG(msg));
220
221         tny_camel_send_queue_add_async (TNY_CAMEL_SEND_QUEUE(self), 
222                                   msg, 
223                                   _on_added_to_outbox, 
224                                   NULL, 
225                                   NULL);
226 }
227
228
229 static void
230 _add_message (ModestTnySendQueue *self, TnyHeader *header)
231 {
232         ModestWindowMgr *mgr = NULL;
233         ModestTnySendQueuePrivate *priv;
234         SendInfo *info = NULL;
235         GList* existing = NULL;
236         gchar* msg_uid = NULL;
237         ModestTnySendQueueStatus status = MODEST_TNY_SEND_QUEUE_UNKNONW;
238         gboolean editing = FALSE;
239
240         g_return_if_fail (TNY_IS_SEND_QUEUE(self));
241         g_return_if_fail (TNY_IS_HEADER(header));
242         priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self);
243         
244         /* Check whether the mail is already in the queue */
245         msg_uid = modest_tny_send_queue_get_msg_id (header);
246         status = modest_tny_send_queue_get_msg_status (self, msg_uid);
247         switch (status) {
248         case MODEST_TNY_SEND_QUEUE_UNKNONW:
249         case MODEST_TNY_SEND_QUEUE_SUSPENDED:
250         case MODEST_TNY_SEND_QUEUE_FAILED:
251                 if (status != MODEST_TNY_SEND_QUEUE_SUSPENDED)
252                         tny_header_unset_flags (header, TNY_HEADER_FLAG_PRIORITY);
253                 
254                 /* Check if it already exists on queue */
255                 existing = modest_tny_send_queue_lookup_info (MODEST_TNY_SEND_QUEUE(self), msg_uid);
256                 if(existing != NULL)
257                         break;
258                 
259                 /* Check if its being edited */
260                 mgr = modest_runtime_get_window_mgr ();
261                 editing = modest_window_mgr_find_registered_header (mgr, header, NULL);
262                 if (editing)
263                         break;
264                 
265                 /* Add new meesage info */
266                 info = g_slice_new (SendInfo);
267                 info->msg_id = strdup(msg_uid);
268                 info->status = MODEST_TNY_SEND_QUEUE_WAITING;
269                 g_queue_push_tail (priv->queue, info);
270                 break;
271         default:
272                 break;
273         }
274
275         /* Free */
276         g_free(msg_uid);
277 }
278
279 static TnyFolder*
280 modest_tny_send_queue_get_sentbox (TnySendQueue *self)
281 {
282         TnyFolder *folder;
283         TnyCamelTransportAccount *account;
284
285         g_return_val_if_fail (self, NULL);
286
287         account = tny_camel_send_queue_get_transport_account (TNY_CAMEL_SEND_QUEUE(self));
288         if (!account) {
289                 g_printerr ("modest: no account for send queue\n");
290                 return NULL;
291         }
292         folder  = modest_tny_account_get_special_folder (TNY_ACCOUNT(account),
293                                                          TNY_FOLDER_TYPE_SENT);
294         g_object_unref (G_OBJECT(account));
295
296         return folder;
297 }
298
299
300 static TnyFolder*
301 modest_tny_send_queue_get_outbox (TnySendQueue *self)
302 {
303         TnyFolder *folder;
304         TnyCamelTransportAccount *account;
305
306         g_return_val_if_fail (self, NULL);
307
308         account = tny_camel_send_queue_get_transport_account (TNY_CAMEL_SEND_QUEUE(self));
309         if (!account) {
310                 g_printerr ("modest: no account for send queue\n");
311                 return NULL;
312         }
313         folder  = modest_tny_account_get_special_folder (TNY_ACCOUNT(account),
314                                                          TNY_FOLDER_TYPE_OUTBOX);
315
316         /* This vfunc's tinymail contract does not allow it to return NULL. */
317         if (!folder) {
318                 g_warning("%s: Returning NULL.\n", __FUNCTION__);
319         }
320
321         g_object_unref (G_OBJECT(account));
322
323         return folder;
324 }
325
326 GType
327 modest_tny_send_queue_get_type (void)
328 {
329         static GType my_type = 0;
330
331         if (my_type == 0) {
332                 static const GTypeInfo my_info = {
333                         sizeof(ModestTnySendQueueClass),
334                         NULL,           /* base init */
335                         NULL,           /* base finalize */
336                         (GClassInitFunc) modest_tny_send_queue_class_init,
337                         NULL,           /* class finalize */
338                         NULL,           /* class data */
339                         sizeof(ModestTnySendQueue),
340                         0,              /* n_preallocs */
341                         (GInstanceInitFunc) modest_tny_send_queue_instance_init,
342                         NULL
343                 };
344                 
345                 my_type = g_type_register_static (TNY_TYPE_CAMEL_SEND_QUEUE,
346                                                   "ModestTnySendQueue",
347                                                   &my_info, 0);
348         }
349         return my_type;
350 }
351
352
353 static void
354 modest_tny_send_queue_class_init (ModestTnySendQueueClass *klass)
355 {
356         GObjectClass *gobject_class;
357
358         gobject_class = (GObjectClass*) klass;
359         
360         parent_class            = g_type_class_peek_parent (klass);
361         gobject_class->finalize = modest_tny_send_queue_finalize;
362
363         TNY_CAMEL_SEND_QUEUE_CLASS(klass)->get_outbox_func  = modest_tny_send_queue_get_outbox;
364         TNY_CAMEL_SEND_QUEUE_CLASS(klass)->get_sentbox_func = modest_tny_send_queue_get_sentbox;
365         TNY_CAMEL_SEND_QUEUE_CLASS(klass)->cancel_func      = modest_tny_send_queue_cancel;
366         klass->status_changed   = NULL;
367
368         signals[STATUS_CHANGED] =
369                 g_signal_new ("status_changed",
370                               G_TYPE_FROM_CLASS (gobject_class),
371                               G_SIGNAL_RUN_FIRST,
372                               G_STRUCT_OFFSET (ModestTnySendQueueClass, status_changed),
373                               NULL, NULL,
374                               modest_marshal_VOID__STRING_INT,
375                               G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_INT);
376
377         g_type_class_add_private (gobject_class, sizeof(ModestTnySendQueuePrivate));
378 }
379
380 static void
381 modest_tny_send_queue_instance_init (GTypeInstance *instance, gpointer g_class)
382 {
383         ModestTnySendQueuePrivate *priv;
384
385         priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (instance);
386         priv->queue = g_queue_new();
387         priv->current = NULL;
388 }
389
390 static void
391 modest_tny_send_queue_finalize (GObject *obj)
392 {
393         ModestTnySendQueuePrivate *priv;
394                 
395         priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (obj);
396
397         g_queue_foreach (priv->queue, (GFunc)modest_tny_send_queue_info_free, NULL);
398         g_queue_free (priv->queue);
399
400         G_OBJECT_CLASS(parent_class)->finalize (obj);
401 }
402
403 ModestTnySendQueue*
404 modest_tny_send_queue_new (TnyCamelTransportAccount *account)
405 {
406         ModestTnySendQueue *self;
407         
408         g_return_val_if_fail (TNY_IS_CAMEL_TRANSPORT_ACCOUNT(account), NULL);
409         
410         self = MODEST_TNY_SEND_QUEUE(g_object_new(MODEST_TYPE_TNY_SEND_QUEUE, NULL));
411         
412         tny_camel_send_queue_set_transport_account (TNY_CAMEL_SEND_QUEUE(self),
413                                                     account); 
414
415         /* Connect signals to control when a msg is being or has been sent */
416         g_signal_connect (G_OBJECT(self), "msg-sending",
417                           G_CALLBACK(_on_msg_start_sending),
418                           NULL);                          
419         g_signal_connect (G_OBJECT(self), "msg-sent",
420                           G_CALLBACK(_on_msg_has_been_sent), 
421                           NULL);
422         g_signal_connect (G_OBJECT(self), "error-happened",
423                           G_CALLBACK(_on_msg_error_happened),
424                           NULL);
425         return self;
426 }
427
428
429
430 void
431 modest_tny_send_queue_try_to_send (ModestTnySendQueue* self)
432 {
433         TnyIterator *iter = NULL;
434         TnyFolder *outbox = NULL;
435         TnyList *headers = tny_simple_list_new ();
436         TnyHeader *header = NULL;
437         GError *err = NULL;
438
439         outbox = modest_tny_send_queue_get_outbox (TNY_SEND_QUEUE(self));
440         if (!outbox)
441                 return;
442
443         tny_folder_get_headers (outbox, headers, TRUE, &err);
444         if (err != NULL) 
445                 goto frees;
446
447         iter = tny_list_create_iterator (headers);
448         while (!tny_iterator_is_done (iter)) {
449                 header = TNY_HEADER (tny_iterator_get_current (iter));
450                 if (header) {   
451                         _add_message (self, header); 
452                         g_object_unref (header);
453                 }
454
455                 tny_iterator_next (iter);
456         }
457         
458         /* Flush send queue */
459         tny_camel_send_queue_flush (TNY_CAMEL_SEND_QUEUE(self));
460
461  frees:
462         if (headers != NULL)
463                 g_object_unref (G_OBJECT (headers));
464         if (outbox != NULL) 
465                 g_object_unref (G_OBJECT (outbox));
466         if (iter != NULL) 
467                 g_object_unref (iter);
468 }
469
470 gboolean
471 modest_tny_send_queue_msg_is_being_sent (ModestTnySendQueue* self,
472                                          const gchar *msg_id)
473 {       
474         ModestTnySendQueueStatus status;
475         
476         g_return_val_if_fail (msg_id != NULL, FALSE); 
477         
478         status = modest_tny_send_queue_get_msg_status (self, msg_id);
479         return status == MODEST_TNY_SEND_QUEUE_SENDING;
480 }
481
482 gboolean
483 modest_tny_send_queue_sending_in_progress (ModestTnySendQueue* self)
484 {       
485         ModestTnySendQueuePrivate *priv;
486         priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self);
487         
488         return priv->current != NULL;
489 }
490
491 ModestTnySendQueueStatus
492 modest_tny_send_queue_get_msg_status (ModestTnySendQueue *self, const gchar *msg_id)
493 {
494   GList *item;
495   item = modest_tny_send_queue_lookup_info (self, msg_id);
496   if(item == NULL) return MODEST_TNY_SEND_QUEUE_UNKNONW;
497   return ((SendInfo*)item->data)->status;
498 }
499
500 gchar *
501 modest_tny_send_queue_get_msg_id (TnyHeader *header)
502 {
503         const gchar *uid = NULL;
504         gchar* msg_uid = NULL;
505         gchar **tmp = NULL;
506                 
507         /* Get message uid */
508         uid = tny_header_get_uid (header);
509         if (uid)
510                 tmp = g_strsplit (uid, "__", 2);
511         
512         if (tmp) {
513                 if (tmp[1] != NULL) 
514                         msg_uid = g_strconcat (tmp[0], "_", NULL);
515                 else 
516                         msg_uid = g_strdup(tmp[0]);
517
518                 /* free */
519                 g_strfreev(tmp);
520         }
521
522         return msg_uid;
523 }
524
525
526 static void
527 _on_msg_start_sending (TnySendQueue *self,
528                        TnyHeader *header,
529                        TnyMsg *msg,
530                        int done, 
531                        int total,
532                        gpointer user_data)
533 {
534         ModestTnySendQueuePrivate *priv = NULL;
535         GList *item = NULL;
536         SendInfo *info = NULL;
537         gchar *msg_id = NULL;
538
539         priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self);
540         
541         /* Get message uid */
542         msg_id = modest_tny_send_queue_get_msg_id (header);
543
544         /* Get status info */
545         item = modest_tny_send_queue_lookup_info (MODEST_TNY_SEND_QUEUE (self), msg_id);
546         if (!item) 
547                 g_warning  ("%s: item should not be NULL", __FUNCTION__);
548         else {
549                 info = item->data;
550                 info->status = MODEST_TNY_SEND_QUEUE_SENDING;
551                 
552                 /* Set current status item */
553                 g_signal_emit (self, signals[STATUS_CHANGED], 0, info->msg_id, info->status);
554                 priv->current = item;
555         }
556
557         /* free */
558         g_free (msg_id);
559 }
560
561 static void 
562 _on_msg_has_been_sent (TnySendQueue *self,
563                        TnyHeader *header,
564                        TnyMsg *msg, 
565                        int done, 
566                        int total,
567                        gpointer user_data)
568 {
569         ModestTnySendQueuePrivate *priv;
570         GList *item;
571         gchar *msg_id = NULL;
572
573         priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self);
574
575         /* Get message uid */
576         msg_id = modest_tny_send_queue_get_msg_id (header);
577         
578         /* Get status info */
579         item = modest_tny_send_queue_lookup_info (MODEST_TNY_SEND_QUEUE (self), msg_id);
580         if (!item)
581                 g_warning ("%s: item should not be NULL", __FUNCTION__);
582         else {
583
584                 /* Remove status info */
585                 modest_tny_send_queue_info_free (item->data);
586                 g_queue_delete_link (priv->queue, item);
587                 priv->current = NULL;
588                 
589                 modest_platform_information_banner (NULL, NULL, _("mcen_ib_message_sent"));
590         }
591
592         /* free */
593         g_free(msg_id);
594 }
595
596 static void 
597 _on_msg_error_happened (TnySendQueue *self,
598                         TnyHeader *header,
599                         TnyMsg *msg,
600                         GError *err,
601                         gpointer user_data)
602 {
603         ModestTnySendQueuePrivate *priv = NULL;
604         SendInfo *info = NULL;
605         GList *item = NULL;
606         gchar* msg_uid = NULL;
607         
608         priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self);
609         
610         /* Get sending info (create new if it doesn not exist) */
611         msg_uid = modest_tny_send_queue_get_msg_id (header);
612         item = modest_tny_send_queue_lookup_info (MODEST_TNY_SEND_QUEUE (self), 
613                                                   msg_uid);     
614         if (item == NULL) {
615                 info = g_slice_new (SendInfo);
616                 info->msg_id = strdup(msg_uid);
617                 g_queue_push_tail (priv->queue, info);
618         } else
619                 info = item->data;
620
621         /* Keep in queue so that we remember that the opertion has failed */
622         /* and was not just cancelled */
623         info->status = MODEST_TNY_SEND_QUEUE_FAILED;
624         
625         /* Notify status has changed */
626         g_signal_emit (self, signals[STATUS_CHANGED], 0, info->msg_id, info->status);
627
628         /* free */
629         g_free(msg_uid);
630 }