Changeset 552
- Timestamp:
- 07/04/06 15:08:36
- Files:
-
- trunk/libtinymail-camel/tny-msg-priv.h (modified) (1 diff)
- trunk/libtinymail-camel/tny-msg.c (modified) (9 diffs)
- trunk/libtinymail-camel/tny-msg.h (modified) (1 diff)
- trunk/libtinymail/tny-list-iterator.c (modified) (1 diff)
- trunk/libtinymail/tny-msg-iface.c (modified) (1 diff)
- trunk/libtinymail/tny-msg-iface.h (modified) (2 diffs)
- trunk/libtinymailui-gtk/tny-msg-view.c (modified) (5 diffs)
- trunk/libtinymailui-mozembed/tny-moz-embed-msg-view.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libtinymail-camel/tny-msg-priv.h
r521 r552 32 32 TnyMsgHeaderIface *header; 33 33 GMutex *parts_lock; 34 GList*parts;34 TnyListIface *parts; 35 35 GMutex *folder_lock; 36 36 TnyMsgFolderIface *folder; trunk/libtinymail-camel/tny-msg.c
r536 r552 24 24 #include <time.h> 25 25 26 #include <tny-list.h> 27 #include <tny-list-iface.h> 28 #include <tny-iterator-iface.h> 29 26 30 #include <tny-msg.h> 27 31 #include <tny-msg-mime-part-iface.h> … … 104 108 105 109 g_mutex_lock (priv->parts_lock); 106 priv->parts = g_list_prepend (priv->parts, tpart); 110 111 if (!priv->parts) 112 priv->parts = tny_list_new (); 113 114 tny_list_iface_prepend (priv->parts, tpart); 107 115 g_mutex_unlock (priv->parts_lock); 108 116 … … 124 132 125 133 if (G_LIKELY (priv->parts)) 126 { 127 g_list_foreach (priv->parts, 128 destroy_part, NULL); 129 130 g_list_free (priv->parts); 131 } 132 134 g_object_unref (G_OBJECT (priv->parts)); 133 135 priv->parts = NULL; 134 136 … … 199 201 } 200 202 201 static const GList*203 static const TnyListIface* 202 204 tny_msg_get_parts (TnyMsgIface *self) 203 205 { 204 206 TnyMsgPriv *priv = TNY_MSG_GET_PRIVATE (TNY_MSG (self)); 205 const GList*retval;207 const TnyListIface *retval; 206 208 207 209 g_mutex_lock (priv->parts_lock); … … 256 258 camel_medium_set_content_object (medium, containee); 257 259 } else { 258 curl = g_list_length (priv->parts); curl++;260 curl = priv->parts ? tny_list_iface_length (priv->parts) : 0; curl++; 259 261 } 260 262 … … 266 268 camel_multipart_add_part_at ((CamelMultipart*)containee, 267 269 tny_msg_mime_part_get_part (TNY_MSG_MIME_PART (part)), curl); 268 269 priv->parts = g_list_prepend (priv->parts, part); curl++; 270 271 if (!priv->parts) 272 priv->parts = tny_list_new (); 273 274 tny_list_iface_prepend (priv->parts, part); curl++; 270 275 271 276 g_mutex_unlock (priv->parts_lock); … … 285 290 TnyMsgPriv *priv = TNY_MSG_GET_PRIVATE (TNY_MSG (self)); 286 291 TnyMsgMimePartPriv *ppriv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 287 GList *remove; 292 gpointer remove; 293 TnyIteratorIface *iterator; 288 294 CamelDataWrapper *containee; 289 295 … … 291 297 292 298 containee = camel_medium_get_content_object (CAMEL_MEDIUM (ppriv->part)); 293 remove = g_list_nth (priv->parts, id); 294 priv->parts = g_list_remove_link (priv->parts, remove); 299 if (priv->parts) 300 { 301 iterator = tny_list_iface_create_iterator (priv->parts); 302 remove = tny_iterator_iface_nth (iterator, id); 303 g_object_unref (G_OBJECT (iterator)); 304 tny_list_iface_remove (priv->parts, remove); 305 } 295 306 camel_multipart_remove_part_at (CAMEL_MULTIPART (containee), id); 296 307 297 308 if (G_LIKELY (remove)) 298 { 299 if (G_LIKELY (remove->data)) 300 camel_object_unref (CAMEL_OBJECT (remove->data)); 301 302 g_list_free (remove); 303 } 309 camel_object_unref (CAMEL_OBJECT (remove)); 304 310 305 311 /* Warning: large lock that locks code, not data */ … … 406 412 407 413 tny_msg_set_header (TNY_MSG_IFACE (self), header); 408 409 return self;410 }411 412 static void413 tny_msg_set_parts (TnyMsg *self, const GList *parts)414 {415 TnyMsgPriv *priv = TNY_MSG_GET_PRIVATE (TNY_MSG (self));416 GList *list = (GList*)parts;417 gint nth=0;418 419 while (G_LIKELY (list))420 {421 if (TNY_IS_MSG_MIME_PART_IFACE (list->data))422 tny_msg_add_part (TNY_MSG_IFACE (self), list->data);423 else424 g_warning (_("Item number %d isn't a TnyMsgMimePartIface\n"), nth);425 426 list = g_list_next (list); nth++;427 }428 429 return;430 }431 432 /**433 * tny_msg_new_with_header_and_parts:434 * @header: a #TnyMsgHeaderIface object435 * @parts: A double linked list with #TnyMsgMimePartIface objects436 *437 * The #TnyMsg implementation is actually a proxy for #CamelMimeMessage (and438 * a few other Camel types)439 *440 * Return value: A new #TnyMsgIface instance implemented for Camel441 **/442 TnyMsg*443 tny_msg_new_with_header_and_parts (TnyMsgHeaderIface *header, const GList *parts)444 {445 TnyMsg *self = g_object_new (TNY_TYPE_MSG, NULL);446 447 tny_msg_set_header (TNY_MSG_IFACE (self), header);448 tny_msg_set_parts (self, parts);449 414 450 415 return self; trunk/libtinymail-camel/tny-msg.h
r187 r552 56 56 TnyMsg* tny_msg_new (void); 57 57 TnyMsg* tny_msg_new_with_header (TnyMsgHeaderIface *header); 58 TnyMsg* tny_msg_new_with_header_and_parts (TnyMsgHeaderIface *header, const GList *parts);59 58 60 59 G_END_DECLS trunk/libtinymail/tny-list-iterator.c
r550 r552 238 238 klass->nth_func = tny_list_iterator_nth; 239 239 klass->current_func = tny_list_iterator_current; 240 klass->has_first_func = tny_list_iterator_has_ next;240 klass->has_first_func = tny_list_iterator_has_first; 241 241 klass->has_next_func = tny_list_iterator_has_next; 242 242 klass->get_list_func = tny_list_iterator_get_list; trunk/libtinymail/tny-msg-iface.c
r521 r552 49 49 * Get a read-only list of mime-parts of this message 50 50 * 51 * Return value: A read-only GListwith #TnyMsgMimePartIface instances51 * Return value: A read-only #TnyListIface with #TnyMsgMimePartIface instances 52 52 **/ 53 const GList*53 const TnyListIface* 54 54 tny_msg_iface_get_parts (TnyMsgIface *self) 55 55 { trunk/libtinymail/tny-msg-iface.h
r546 r552 42 42 GTypeInterface parent; 43 43 44 const GList*(*get_parts_func) (TnyMsgIface *self);44 const TnyListIface* (*get_parts_func) (TnyMsgIface *self); 45 45 const TnyMsgHeaderIface* (*get_header_func) (TnyMsgIface *self); 46 46 … … 56 56 GType tny_msg_iface_get_type (void); 57 57 58 const GList*tny_msg_iface_get_parts (TnyMsgIface *self);58 const TnyListIface* tny_msg_iface_get_parts (TnyMsgIface *self); 59 59 const TnyMsgHeaderIface* tny_msg_iface_get_header (TnyMsgIface *self); 60 60 trunk/libtinymailui-gtk/tny-msg-view.c
r497 r552 31 31 #include <string.h> 32 32 #include <gtk/gtk.h> 33 34 #include <tny-list-iface.h> 35 #include <tny-iterator-iface.h> 36 33 37 #include <tny-msg-view.h> 34 38 #include <tny-text-buffer-stream.h> … … 72 76 TnyStreamIface *dest; 73 77 TnyMsgHeaderIface *header; 74 GList *parts; 78 TnyListIface *parts; 79 TnyIteratorIface *iterator; 75 80 const gchar *str = NULL; 76 gboolean first_attach = TRUE ;81 gboolean first_attach = TRUE, next = FALSE; 77 82 TnyAttachListModel *model; 78 83 … … 85 90 g_return_if_fail (header); 86 91 87 parts = (GList*)tny_msg_iface_get_parts (priv->msg); 92 parts = (TnyListIface*)tny_msg_iface_get_parts (priv->msg); 93 iterator = tny_list_iface_create_iterator (parts); 94 next = tny_iterator_iface_has_first (iterator); 88 95 89 96 gtk_widget_hide (priv->attachview_sw); … … 94 101 gtk_widget_show (GTK_WIDGET (priv->headerview)); 95 102 96 while ( G_LIKELY (parts))97 { 98 TnyMsgMimePartIface *part = parts->data;103 while (next) 104 { 105 TnyMsgMimePartIface *part = tny_iterator_iface_current (iterator); 99 106 100 107 if (G_LIKELY (tny_msg_mime_part_iface_content_type_is (part, "text/*"))) … … 113 120 } 114 121 115 parts = g_list_next (parts); 116 } 122 next = tny_iterator_iface_has_next (iterator); 123 124 if (next) 125 tny_iterator_iface_next (iterator); 126 127 } 128 129 g_object_unref (G_OBJECT (iterator)); 130 117 131 118 132 if (G_LIKELY (!first_attach)) trunk/libtinymailui-mozembed/tny-moz-embed-msg-view.c
r497 r552 30 30 #include <string.h> 31 31 #include <gtk/gtk.h> 32 #include <tny-list-iface.h> 33 #include <tny-iterator-iface.h> 34 32 35 #include <tny-moz-embed-msg-view.h> 33 36 #include <tny-moz-embed-stream.h> … … 86 89 GtkTextIter hiter; 87 90 TnyMsgHeaderIface *header; 88 GList *parts; 91 TnyListIface *parts; 92 TnyIteratorIface *iterator; 89 93 const gchar *str = NULL; 90 94 gboolean first_attach = TRUE; 91 95 TnyAttachListModel *model; 92 gboolean have_html = FALSE ;96 gboolean have_html = FALSE, next = FALSE; 93 97 GtkTextBuffer *buffer; 94 98 … … 99 103 g_return_if_fail (header); 100 104 101 parts = (GList*)tny_msg_iface_get_parts (priv->msg); 105 parts = (TnyListIface*)tny_msg_iface_get_parts (priv->msg); 106 iterator = tny_list_iface_create_iterator (parts); 107 next = tny_iterator_iface_has_first (iterator); 108 102 109 buffer = gtk_text_view_get_buffer (priv->textview); 103 110 … … 109 116 gtk_text_buffer_set_text (buffer, "", 0); 110 117 111 while (G_LIKELY (parts)) 112 { 113 TnyMsgMimePartIface *part = parts->data; 114 115 if (!part) 116 { 117 /* This shouldn't happen! ;-) */ 118 g_warning (_("Mimepart problem\n")); 119 parts = g_list_next (parts); 120 continue; 121 } 118 while (next) 119 { 120 TnyMsgMimePartIface *part = tny_iterator_iface_current (iterator); 122 121 123 122 if (!have_html && G_LIKELY (tny_msg_mime_part_iface_content_type_is (part, "text/plain"))) … … 164 163 } 165 164 166 parts = g_list_next (parts); 167 } 165 166 next = tny_iterator_iface_has_next (iterator); 167 168 if (next) 169 tny_iterator_iface_next (iterator); 170 } 171 172 g_object_unref (G_OBJECT (iterator)); 168 173 169 174 if (G_LIKELY (!first_attach))
