Changeset 1817
- Timestamp:
- 04/22/07 13:46:08
- Files:
-
- trunk/ChangeLog (modified) (1 diff)
- trunk/libtinymail-camel/tny-camel-send-queue.c (modified) (2 diffs)
- trunk/libtinymail-queues/tny-generic-send-queue-priv.h (modified) (1 diff)
- trunk/libtinymail-queues/tny-generic-send-queue.c (modified) (8 diffs)
- trunk/po/Makefile.in.in (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r1815 r1817 3 3 * Created a TnyGenericSendQueue which implements TnySendQueue in a 4 4 generic way (doesn't strictly depend on the libtinymail-camel impl 5 libraries ) * unfinished implementation *5 libraries like the TnyCamelSendQueue type) 6 6 7 7 * This was a minor API change (new type added) trunk/libtinymail-camel/tny-camel-send-queue.c
r1781 r1817 40 40 (G_TYPE_INSTANCE_GET_PRIVATE ((o), TNY_TYPE_CAMEL_SEND_QUEUE, TnyCamelSendQueuePriv)) 41 41 42 typedef struct 43 { 42 typedef struct { 44 43 TnySendQueue *self; 45 44 TnyMsg *msg; 46 45 GError *error; 47 46 gint i, total; 48 49 47 } ErrorInfo; 50 48 … … 53 51 { 54 52 ErrorInfo *info = data; 55 56 53 g_signal_emit (info->self, tny_send_queue_signals [TNY_SEND_QUEUE_ERROR_HAPPENED], 57 54 0, info->msg, info->error, info->i, info->total); 58 59 55 return FALSE; 60 56 } trunk/libtinymail-queues/tny-generic-send-queue-priv.h
r1816 r1817 29 29 TnyFolder *outbox, *sentbox; 30 30 TnyTransportAccount *account; 31 gboolean cancelled; 31 32 }; 32 33 trunk/libtinymail-queues/tny-generic-send-queue.c
r1816 r1817 31 31 #include "tny-generic-send-queue-priv.h" 32 32 33 34 typedef struct { 35 TnySendQueue *self; 36 TnyMsg *msg; 37 GError *error; 38 gint i, total; 39 } ErrorInfo; 40 41 static gboolean 42 emit_error_on_mainloop (gpointer data) 43 { 44 ErrorInfo *info = data; 45 g_signal_emit (info->self, tny_send_queue_signals [TNY_SEND_QUEUE_ERROR_HAPPENED], 46 0, info->msg, info->error, info->i, info->total); 47 return FALSE; 48 } 49 50 51 static void 52 destroy_error_info (gpointer data) 53 { 54 ErrorInfo *info = data; 55 if (info->msg) 56 g_object_unref (G_OBJECT (info->msg)); 57 if (info->self) 58 g_object_unref (G_OBJECT (info->self)); 59 if (info->error) 60 g_error_free (info->error); 61 g_slice_free (ErrorInfo, info); 62 } 63 64 static void 65 emit_error (TnySendQueue *self, TnyMsg *msg, GError *error, int i, int total) 66 { 67 ErrorInfo *info = g_slice_new0 (ErrorInfo); 68 if (error != NULL) 69 info->error = g_error_copy ((const GError *) error); 70 if (self) 71 info->self = TNY_SEND_QUEUE (g_object_ref (G_OBJECT (self))); 72 if (msg) 73 info->msg = TNY_MSG (g_object_ref (G_OBJECT (msg))); 74 info->i = i; 75 info->total = total; 76 g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, 77 emit_error_on_mainloop, info, destroy_error_info); 78 return; 79 } 80 33 81 typedef struct { 34 82 TnyGenericSendQueue *self; 35 83 TnyMsg *msg; 36 GError **err;84 gint i, total; 37 85 } GenericSendInfo; 38 86 … … 42 90 { 43 91 GenericSendInfo *info = (GenericSendInfo *) arguments; 92 TnySendQueue *self = (TnySendQueue *) info->self; 44 93 TnyGenericSendQueuePriv *priv = TNY_GENERIC_SEND_QUEUE_GET_PRIVATE (info->self); 45 TnyList *list = tny_simple_list_new (); 94 TnyList *list; 95 GError *err = NULL; 46 96 47 97 g_mutex_lock (priv->lock); 48 98 49 tny_transport_account_send (priv->account, info->msg, info->err); 50 /* TODO handle err */ 51 52 if (info->err == NULL) 99 if (priv->cancelled) 53 100 { 101 g_mutex_unlock (priv->lock); 102 return; 103 } 104 105 list = tny_simple_list_new (); 106 tny_transport_account_send (priv->account, info->msg, &err); 107 if (err != NULL) { 108 emit_error (self, info->msg, err, info->i, info->total); 109 g_error_free (err); 110 } else { 111 TnyFolder *outbox, *sentbox; 112 113 outbox = tny_send_queue_get_outbox (TNY_SEND_QUEUE (info->self)); 114 sentbox = tny_send_queue_get_sentbox (TNY_SEND_QUEUE (info->self)); 115 54 116 tny_list_prepend (list, G_OBJECT (info->msg)); 55 tny_folder_transfer_msgs ( priv->outbox, list, priv->sentbox, TRUE, info->err);117 tny_folder_transfer_msgs (outbox, list, sentbox, TRUE, &err); 56 118 g_object_unref (list); 57 /* TODO handle err */ 58 } 59 119 if (err != NULL) { 120 emit_error (self, info->msg, err, info->i, info->total); 121 g_error_free (err); 122 } 123 124 g_object_unref (outbox); 125 g_object_unref (sentbox); 126 } 60 127 g_object_unref (info->msg); 61 128 … … 69 136 { 70 137 GenericSendInfo *info = o_async_worker_task_get_arguments (task); 138 TnyGenericSendQueuePriv *priv = TNY_GENERIC_SEND_QUEUE_GET_PRIVATE (info->self); 71 139 72 140 g_object_unref (info->self); … … 79 147 TnyGenericSendQueuePriv *priv = TNY_GENERIC_SEND_QUEUE_GET_PRIVATE (self); 80 148 TnyIterator *iter; 81 TnyList *list = tny_simple_list_new (); 149 TnyList *list; 150 gint i=1, total; 151 152 TnyFolder *outbox; 82 153 83 154 g_mutex_lock (priv->lock); 84 155 85 tny_folder_add_msg (priv->outbox, msg, err); 86 /* TODO: handle err */ 87 88 tny_folder_get_headers (priv->outbox, list, FALSE, err); 89 /* TODO: handle err */ 90 156 outbox = tny_send_queue_get_outbox (self); 157 158 tny_folder_add_msg (outbox, msg, err); 159 160 if (err!= NULL && *err != NULL) { 161 g_object_unref (G_OBJECT (outbox)); 162 g_mutex_unlock (priv->lock); 163 return; 164 } 165 166 list = tny_simple_list_new (); 167 tny_folder_get_headers (outbox, list, FALSE, err); 168 169 if (err != NULL && *err != NULL) 170 { 171 g_object_unref (G_OBJECT (outbox)); 172 g_object_unref (G_OBJECT (list)); 173 g_mutex_unlock (priv->lock); 174 return; 175 } 176 177 total = tny_list_get_length (list); 91 178 iter = tny_list_create_iterator (list); 92 179 … … 96 183 GenericSendInfo *info = g_slice_new (GenericSendInfo); 97 184 TnyHeader *header = TNY_HEADER (tny_iterator_get_current (iter)); 98 185 guint item = 0; 186 187 info->msg = NULL; 188 info->i = i; 189 info->total = total; 99 190 info->self = TNY_GENERIC_SEND_QUEUE (g_object_ref (self)); 100 191 info->msg = tny_folder_get_msg (priv->outbox, header, err); 101 192 102 /* TODO: Handle err */ 103 104 info->err = err; 193 if (err != NULL && *err != NULL) 194 { 195 g_object_unref (G_OBJECT (task)); 196 g_object_unref (G_OBJECT (info->self)); 197 if (info->msg) 198 g_object_unref (G_OBJECT (info->msg)); 199 g_object_unref (G_OBJECT (header)); 200 g_object_unref (G_OBJECT (iter)); 201 g_object_unref (G_OBJECT (list)); 202 g_slice_free (GenericSendInfo, info); 203 g_object_unref (G_OBJECT (outbox)); 204 g_mutex_unlock (priv->lock); 205 return; 206 } 207 105 208 o_async_worker_task_set_arguments (task, info); 106 209 o_async_worker_task_set_func (task, generic_send_task); 107 210 o_async_worker_task_set_callback (task, generic_send_callback); 108 211 109 o_async_worker_add (priv->queue, task);212 item = o_async_worker_add (priv->queue, task); 110 213 111 214 g_object_unref (header); 112 tny_iterator_next (iter); 215 tny_iterator_next (iter); 216 i++; 113 217 } 114 218 115 219 g_object_unref (iter); 116 220 g_object_unref (list); 221 g_object_unref (G_OBJECT (outbox)); 117 222 118 223 g_mutex_unlock (priv->lock); … … 124 229 tny_generic_send_queue_cancel (TnySendQueue *self, gboolean remove, GError **err) 125 230 { 126 /* TODO */ 231 TnyGenericSendQueuePriv *priv = TNY_GENERIC_SEND_QUEUE_GET_PRIVATE (self); 232 233 priv->cancelled = TRUE; 234 o_async_worker_join (priv->queue); 235 236 g_mutex_lock (priv->lock); 237 if (remove) 238 { 239 TnyFolder *outbox; 240 TnyList *headers = tny_simple_list_new (); 241 TnyIterator *iter; 242 243 outbox = tny_send_queue_get_outbox (self); 244 245 tny_folder_get_headers (outbox, headers, TRUE, err); 246 247 if (err != NULL && *err != NULL) 248 { 249 g_object_unref (G_OBJECT (headers)); 250 g_object_unref (G_OBJECT (outbox)); 251 priv->cancelled = FALSE; 252 g_mutex_unlock (priv->lock); 253 return; 254 } 255 256 iter = tny_list_create_iterator (headers); 257 258 while (!tny_iterator_is_done (iter)) 259 { 260 TnyHeader *header = TNY_HEADER (tny_iterator_get_current (iter)); 261 tny_folder_remove_msg (outbox, header, err); 262 263 if (err != NULL && *err != NULL) 264 { 265 g_object_unref (G_OBJECT (header)); 266 g_object_unref (G_OBJECT (iter)); 267 g_object_unref (G_OBJECT (headers)); 268 g_object_unref (G_OBJECT (outbox)); 269 priv->cancelled = FALSE; 270 g_mutex_unlock (priv->lock); 271 return; 272 } 273 274 g_object_unref (G_OBJECT (header)); 275 tny_iterator_next (iter); 276 } 277 g_object_unref (G_OBJECT (iter)); 278 g_object_unref (G_OBJECT (headers)); 279 280 tny_folder_sync (outbox, TRUE, err); 281 282 g_object_unref (G_OBJECT (outbox)); 283 } 284 285 priv->cancelled = FALSE; 286 g_mutex_unlock (priv->lock); 287 288 return; 127 289 } 128 290 … … 173 335 TnyGenericSendQueuePriv *priv = TNY_GENERIC_SEND_QUEUE_GET_PRIVATE (object); 174 336 337 priv->cancelled = TRUE; 338 o_async_worker_join (priv->queue); 339 175 340 g_mutex_lock (priv->lock); 176 o_async_worker_join (priv->queue);177 341 g_object_unref (G_OBJECT (priv->queue)); 178 342 g_object_unref (G_OBJECT (priv->sentbox)); … … 198 362 priv->sentbox = NULL; 199 363 priv->outbox = NULL; 364 priv->cancelled = FALSE; 200 365 g_mutex_unlock (priv->lock); 201 366 trunk/po/Makefile.in.in
r504 r1817 26 26 prefix = @prefix@ 27 27 exec_prefix = @exec_prefix@ 28 datarootdir = @datarootdir@ 28 29 datadir = @datadir@ 29 30 libdir = @libdir@ … … 41 42 GMSGFMT = @GMSGFMT@ 42 43 MSGFMT = @MSGFMT@ 44 MSGFMT_OPTS = @MSGFMT_OPTS@ 43 45 XGETTEXT = @XGETTEXT@ 44 46 MSGMERGE = msgmerge … … 79 81 .po.gmo: 80 82 file=$(srcdir)/`echo $* | sed 's,.*/,,'`.gmo \ 81 && rm -f $$file && $(GMSGFMT) -c-o $$file $<83 && rm -f $$file && $(GMSGFMT) $(MSGFMT_OPTS) -o $$file $< 82 84 83 85 .po.cat:
