Changeset 3029
- Timestamp:
- 11/28/07 23:37:52
- Files:
-
- devel/pvanhoof/bs/ChangeLog (modified) (1 diff)
- devel/pvanhoof/bs/libtinymail-camel/tny-camel-bs-mime-part.c (modified) (7 diffs)
- devel/pvanhoof/bs/libtinymail-camel/tny-camel-bs-mime-part.h (modified) (1 diff)
- devel/pvanhoof/bs/libtinymail-camel/tny-camel-bs-msg-receive-strategy.c (modified) (1 diff)
- devel/pvanhoof/bs/libtinymail-camel/tny-camel-folder.c (modified) (7 diffs)
- devel/pvanhoof/bs/libtinymail-camel/tny-camel-mime-part.c (modified) (3 diffs)
- devel/pvanhoof/bs/libtinymail-camel/tny-camel-mime-part.h (modified) (1 diff)
- devel/pvanhoof/bs/libtinymail-camel/tny-camel-store-account.c (modified) (1 diff)
- devel/pvanhoof/bs/libtinymail/tny-mime-part.c (modified) (16 diffs)
- devel/pvanhoof/bs/libtinymail/tny-mime-part.h (modified) (2 diffs)
- devel/pvanhoof/bs/libtinymail/tny-shared.h (modified) (1 diff)
- devel/pvanhoof/bs/libtinymailui-gtk/tny-gtk-image-mime-part-view.c (modified) (7 diffs)
- devel/pvanhoof/bs/libtinymailui-gtk/tny-gtk-image-mime-part-view.h (modified) (1 diff)
- devel/pvanhoof/bs/libtinymailui-gtk/tny-gtk-mime-part-save-strategy.c (modified) (10 diffs)
- devel/pvanhoof/bs/libtinymailui-gtk/tny-gtk-mime-part-save-strategy.h (modified) (1 diff)
- devel/pvanhoof/bs/libtinymailui-gtk/tny-gtk-msg-view.c (modified) (4 diffs)
- devel/pvanhoof/bs/libtinymailui-gtk/tny-gtk-msg-view.h (modified) (1 diff)
- devel/pvanhoof/bs/libtinymailui-gtk/tny-gtk-text-mime-part-view.c (modified) (6 diffs)
- devel/pvanhoof/bs/libtinymailui-gtk/tny-gtk-text-mime-part-view.h (modified) (1 diff)
- devel/pvanhoof/bs/libtinymailui-mozembed/tny-moz-embed-html-mime-part-view.c (modified) (6 diffs)
- devel/pvanhoof/bs/libtinymailui-mozembed/tny-moz-embed-html-mime-part-view.h (modified) (1 diff)
- devel/pvanhoof/bs/libtinymailui-mozembed/tny-moz-embed-msg-view.c (modified) (2 diffs)
- devel/pvanhoof/bs/libtinymailui/tny-mime-part-view.c (modified) (2 diffs)
- devel/pvanhoof/bs/tests/c-demo/tny-demoui-summary-view.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
devel/pvanhoof/bs/ChangeLog
r3011 r3029 1 2007-11-28 Philip Van Hoof <pvanhoof@gnome.org> 2 3 * Several fixes. in the bodystructure parsing 4 * Several fixes in the mime part handling 5 * Changed the API of mime part viewers to have a status 6 callback. 7 8 * This was a major API change in libtinymail and libtinymailui 9 1 10 2007-11-27 Philip Van Hoof <pvanhoof@gnome.org> 2 11 devel/pvanhoof/bs/libtinymail-camel/tny-camel-bs-mime-part.c
r3015 r3029 39 39 #include <tny-stream-camel.h> 40 40 #include <tny-camel-stream.h> 41 41 #include <tny-camel-folder.h> 42 42 #include <tny-fs-stream.h> 43 43 44 44 static GObjectClass *parent_class = NULL; 45 46 #include "tny-camel-bs-mime-part-priv.h"47 #include "tny-camel-bs-msg-priv.h"48 #include "tny-camel-bs-msg-header-priv.h"49 45 50 46 … … 60 56 #include "camel/camel-stream-null.h" 61 57 #include "camel/camel-mime-filter-charset.h" 58 #include "camel/camel-folder.h" 59 60 #include "tny-camel-queue-priv.h" 61 #include "tny-camel-folder-priv.h" 62 #include "tny-camel-account-priv.h" 63 #include "tny-camel-store-account-priv.h" 64 #include "tny-camel-bs-mime-part-priv.h" 65 #include "tny-camel-bs-msg-priv.h" 66 #include "tny-camel-bs-msg-header-priv.h" 67 #include "tny-session-camel-priv.h" 68 69 #define TINYMAIL_ENABLE_PRIVATE_API 70 #include "tny-common-priv.h" 71 #undef TINYMAIL_ENABLE_PRIVATE_API 72 73 62 74 63 75 static ssize_t … … 163 175 164 176 static void 177 decode_from_stream_to (TnyMimePart *self, TnyStream *from_stream, TnyStream *stream, gboolean binary, gboolean decode_text) 178 { 179 TnyCamelBsMimePartPriv *priv = TNY_CAMEL_BS_MIME_PART_GET_PRIVATE (self); 180 181 if (decode_text && camel_strcase_equal (priv->bodystructure->content.type, "TEXT")) 182 { 183 gchar *encoding = NULL; 184 gchar *charset = (gchar *) mimeparam_get_value_for (priv->bodystructure->content.params, "CHARSET"); 185 CamelStream *cfrom_stream = tny_stream_camel_new (from_stream); 186 CamelStream *cto_stream = tny_stream_camel_new (stream); 187 188 if (!binary) 189 encoding = priv->bodystructure->encoding; 190 191 if (!charset) 192 charset = "UTF-8"; 193 194 bs_camel_stream_format_text (cfrom_stream, cto_stream, charset, encoding); 195 196 camel_object_unref (cfrom_stream); 197 camel_object_unref (cto_stream); 198 } else { 199 if (binary) 200 tny_stream_write_to_stream (from_stream, stream); 201 else { 202 CamelStream *cfrom_stream = tny_stream_camel_new (from_stream); 203 CamelStream *cto_stream = tny_stream_camel_new (stream); 204 gchar *encoding = priv->bodystructure->encoding; 205 206 decode_to_stream (cfrom_stream, cto_stream, encoding, FALSE); 207 208 camel_object_unref (cfrom_stream); 209 camel_object_unref (cto_stream); 210 } 211 } 212 } 213 214 static void 165 215 fetch_part (TnyMimePart *self, TnyStream *stream, gboolean decode_text) 166 216 { 167 217 TnyCamelBsMimePartPriv *priv = TNY_CAMEL_BS_MIME_PART_GET_PRIVATE (self); 218 GError *err = NULL; 168 219 169 220 if (priv->folder) 170 221 { 171 GError *err = NULL;172 222 gboolean binary = TRUE; 173 223 TnyStream *from_stream; 174 224 175 225 /* binary = !camel_strcase_equal (priv->bodystructure->content.type, "TEXT"); */ 176 177 226 from_stream = tny_camel_bs_msg_receive_strategy_start_receiving_part ( 178 227 priv->strat, priv->folder, TNY_CAMEL_BS_MIME_PART (self), &binary, &err); … … 181 230 g_warning ("Error while fetching part: %s", err->message); 182 231 g_error_free (err); 183 } else { 184 185 186 if (decode_text && camel_strcase_equal (priv->bodystructure->content.type, "TEXT")) 187 { 188 gchar *encoding = NULL; 189 gchar *charset = (gchar *) mimeparam_get_value_for (priv->bodystructure->content.params, "CHARSET"); 190 CamelStream *cfrom_stream = tny_stream_camel_new (from_stream); 191 CamelStream *cto_stream = tny_stream_camel_new (stream); 192 193 if (!binary) 194 encoding = priv->bodystructure->encoding; 195 196 if (!charset) 197 charset = "UTF-8"; 198 199 bs_camel_stream_format_text (cfrom_stream, cto_stream, charset, encoding); 200 201 camel_object_unref (cfrom_stream); 202 camel_object_unref (cto_stream); 203 } else { 204 if (binary) 205 tny_stream_write_to_stream (from_stream, stream); 206 else { 207 CamelStream *cfrom_stream = tny_stream_camel_new (from_stream); 208 CamelStream *cto_stream = tny_stream_camel_new (stream); 209 gchar *encoding = priv->bodystructure->encoding; 210 211 decode_to_stream (cfrom_stream, cto_stream, encoding, FALSE); 212 213 camel_object_unref (cfrom_stream); 214 camel_object_unref (cto_stream); 215 } 216 } 217 } 232 } else 233 decode_from_stream_to (self, from_stream, stream, binary, decode_text); 218 234 219 235 if (from_stream) … … 375 391 } 376 392 393 394 395 typedef struct { 396 TnyCamelQueueable parent; 397 398 GObject *self, *stream; 399 TnyMimePartCallback callback; 400 TnyStatusCallback status_callback; 401 gpointer user_data; 402 GError *err; 403 gboolean binary; 404 TnyStream *from_stream; 405 TnyIdleStopper *stopper; 406 TnySessionCamel *session; 407 } DecodeAsyncInfo; 408 409 410 static void 411 decode_async_destroyer (gpointer user_data) 412 { 413 DecodeAsyncInfo *info = (DecodeAsyncInfo *) user_data; 414 TnyCamelBsMimePartPriv *priv = TNY_CAMEL_BS_MIME_PART_GET_PRIVATE (info->self); 415 TnyCamelFolderPriv *fpriv = TNY_CAMEL_FOLDER_GET_PRIVATE (priv->folder); 416 417 _tny_camel_folder_unreason (fpriv); 418 419 g_object_unref (info->stream); 420 g_object_unref (info->self); 421 if (info->from_stream) 422 g_object_unref (info->from_stream); 423 if (info->err) 424 g_error_free (info->err); 425 426 tny_idle_stopper_destroy (info->stopper); 427 info->stopper = NULL; 428 429 430 return; 431 } 432 433 static gboolean 434 decode_async_callback (gpointer user_data) 435 { 436 DecodeAsyncInfo *info = (DecodeAsyncInfo *) user_data; 437 438 tny_lockable_lock (info->session->priv->ui_lock); 439 440 if (info->from_stream) { 441 decode_from_stream_to (TNY_MIME_PART (info->self), 442 TNY_STREAM (info->from_stream), TNY_STREAM (info->stream), 443 info->binary, TRUE); 444 } 445 446 if (info->callback) { 447 info->callback (TNY_MIME_PART (info->self), TNY_STREAM (info->stream), FALSE, info->err, info->user_data); 448 } 449 450 tny_lockable_unlock (info->session->priv->ui_lock); 451 452 return FALSE; 453 } 454 455 456 457 static void 458 decode_async_cancelled_destroyer (gpointer user_data) 459 { 460 DecodeAsyncInfo *info = (DecodeAsyncInfo *) user_data; 461 TnyCamelBsMimePartPriv *priv = TNY_CAMEL_BS_MIME_PART_GET_PRIVATE (info->self); 462 TnyCamelFolderPriv *fpriv = TNY_CAMEL_FOLDER_GET_PRIVATE (priv->folder); 463 464 _tny_camel_folder_unreason (fpriv); 465 g_object_unref (info->stream); 466 g_object_unref (info->self); 467 if (info->err) 468 g_error_free (info->err); 469 470 tny_idle_stopper_destroy (info->stopper); 471 info->stopper = NULL; 472 473 474 return; 475 } 476 477 478 static gboolean 479 decode_async_cancelled_callback (gpointer user_data) 480 { 481 DecodeAsyncInfo *info = (DecodeAsyncInfo *) user_data; 482 if (info->callback) { 483 tny_lockable_lock (info->session->priv->ui_lock); 484 info->callback (TNY_MIME_PART (info->self), TNY_STREAM (info->stream), TRUE, info->err, info->user_data); 485 tny_lockable_unlock (info->session->priv->ui_lock); 486 } 487 return FALSE; 488 } 489 490 static void 491 decode_async_status (struct _CamelOperation *op, const char *what, int sofar, int oftotal, void *user_data) 492 { 493 DecodeAsyncInfo *oinfo = user_data; 494 TnyProgressInfo *info = NULL; 495 496 info = tny_progress_info_new (G_OBJECT (oinfo->self), oinfo->status_callback, 497 TNY_FOLDER_STATUS, TNY_FOLDER_STATUS_CODE_GET_MSG, what, sofar, 498 oftotal, oinfo->stopper, oinfo->session->priv->ui_lock, oinfo->user_data); 499 500 g_idle_add_full (G_PRIORITY_HIGH, 501 tny_progress_info_idle_func, info, 502 tny_progress_info_destroy); 503 504 return; 505 } 506 507 508 static gpointer 509 decode_async_thread (gpointer user_data) 510 { 511 DecodeAsyncInfo *info = (DecodeAsyncInfo *) user_data; 512 TnyCamelBsMimePartPriv *priv = TNY_CAMEL_BS_MIME_PART_GET_PRIVATE (info->self); 513 TnyCamelFolderPriv *fpriv = TNY_CAMEL_FOLDER_GET_PRIVATE (priv->folder); 514 515 g_static_rec_mutex_lock (fpriv->folder_lock); 516 517 _tny_camel_account_start_camel_operation (TNY_CAMEL_ACCOUNT (fpriv->account), 518 decode_async_status, info, "Getting part"); 519 520 /* binary = !camel_strcase_equal (priv->bodystructure->content.type, "TEXT"); */ 521 info->binary = TRUE; 522 info->from_stream = tny_camel_bs_msg_receive_strategy_start_receiving_part ( 523 priv->strat, priv->folder, TNY_CAMEL_BS_MIME_PART (info->self), 524 &info->binary, &info->err); 525 526 _tny_camel_account_stop_camel_operation (TNY_CAMEL_ACCOUNT (fpriv->account)); 527 528 g_static_rec_mutex_unlock (fpriv->folder_lock); 529 530 return NULL; 531 } 532 533 534 static void 535 tny_camel_bs_mime_part_decode_to_stream_async (TnyMimePart *self, TnyStream *stream, TnyMimePartCallback callback, TnyStatusCallback status_callback, gpointer user_data) 536 { 537 TNY_CAMEL_BS_MIME_PART_GET_CLASS (self)->decode_to_stream_async_func (self, stream, callback, status_callback, user_data); 538 return; 539 } 540 541 542 static void 543 tny_camel_bs_mime_part_decode_to_stream_async_default (TnyMimePart *self, TnyStream *stream, TnyMimePartCallback callback, TnyStatusCallback status_callback, gpointer user_data) 544 { 545 DecodeAsyncInfo *info = g_slice_new0 (DecodeAsyncInfo); 546 TnyCamelBsMimePartPriv *priv = TNY_CAMEL_BS_MIME_PART_GET_PRIVATE (self); 547 TnyCamelFolderPriv *fpriv = TNY_CAMEL_FOLDER_GET_PRIVATE (priv->folder); 548 549 info->err = NULL; 550 info->session = TNY_FOLDER_PRIV_GET_SESSION (fpriv); 551 info->self = g_object_ref (self); 552 info->stream = g_object_ref (stream); 553 info->callback = callback; 554 info->status_callback = status_callback; 555 info->user_data = user_data; 556 info->stopper = tny_idle_stopper_new (); 557 558 _tny_camel_folder_reason (fpriv); 559 560 _tny_camel_queue_launch (TNY_FOLDER_PRIV_GET_QUEUE (fpriv), 561 decode_async_thread, 562 decode_async_callback, 563 decode_async_destroyer, 564 decode_async_cancelled_callback, 565 decode_async_cancelled_destroyer, 566 NULL, 567 info, sizeof (DecodeAsyncInfo), __FUNCTION__); 568 569 return; 570 } 377 571 378 572 … … 753 947 klass->get_header_pairs_func = tny_camel_bs_mime_part_get_header_pairs; 754 948 klass->set_header_pair_func = tny_camel_bs_mime_part_set_header_pair; 949 klass->decode_to_stream_async_func = tny_camel_bs_mime_part_decode_to_stream_async; 755 950 756 951 return; … … 789 984 class->get_header_pairs_func = tny_camel_bs_mime_part_get_header_pairs_default; 790 985 class->set_header_pair_func = tny_camel_bs_mime_part_set_header_pair_default; 986 class->decode_to_stream_async_func = tny_camel_bs_mime_part_decode_to_stream_async_default; 791 987 792 988 object_class->finalize = tny_camel_bs_mime_part_finalize; devel/pvanhoof/bs/libtinymail-camel/tny-camel-bs-mime-part.h
r3011 r3029 71 71 void (*get_header_pairs_func) (TnyMimePart *self, TnyList *list); 72 72 void (*set_header_pair_func) (TnyMimePart *self, const gchar *name, const gchar *value); 73 void (*decode_to_stream_async_func) (TnyMimePart *self, TnyStream *stream, TnyMimePartCallback callback, TnyStatusCallback status_callback, gpointer user_data); 73 74 }; 74 75 devel/pvanhoof/bs/libtinymail-camel/tny-camel-bs-msg-receive-strategy.c
r3013 r3029 89 89 } else { 90 90 int fd = open (filename, 0); 91 retval = tny_fs_stream_new (fd); 91 92 if (fd == -1) { 93 g_set_error (err, TNY_FOLDER_ERROR, 94 TNY_FOLDER_ERROR_GET_MSG, 95 "Can't open %s for reading", filename); 96 retval = NULL; 97 } else 98 retval = tny_fs_stream_new (fd); 92 99 } 93 100 devel/pvanhoof/bs/libtinymail-camel/tny-camel-folder.c
r3007 r3029 907 907 g_error_free (info->err); 908 908 909 tny_idle_stopper_destroy (info->stopper); 910 info->stopper = NULL; 911 909 912 return; 910 913 } … … 1520 1523 if (info->err) 1521 1524 g_error_free (info->err); 1525 1526 tny_idle_stopper_destroy (info->stopper); 1527 info->stopper = NULL; 1522 1528 1523 1529 return; … … 1727 1733 if (info->err) 1728 1734 g_error_free (info->err); 1735 1736 tny_idle_stopper_destroy (info->stopper); 1737 info->stopper = NULL; 1738 1729 1739 return; 1730 1740 } … … 1954 1964 g_object_unref (info->self); 1955 1965 g_object_unref (info->headers); 1966 1956 1967 return; 1957 1968 } … … 2242 2253 if (info->err) 2243 2254 g_error_free (info->err); 2255 2256 tny_idle_stopper_destroy (info->stopper); 2257 info->stopper = NULL; 2244 2258 2245 2259 return; … … 3272 3286 g_object_unref (info->into); 3273 3287 3288 tny_idle_stopper_destroy (info->stopper); 3289 info->stopper = NULL; 3290 3274 3291 return; 3275 3292 } … … 3856 3873 if (info->err) 3857 3874 g_error_free (info->err); 3875 3876 tny_idle_stopper_destroy (info->stopper); 3877 info->stopper = NULL; 3858 3878 3859 3879 return; devel/pvanhoof/bs/libtinymail-camel/tny-camel-mime-part.c
r3028 r3029 196 196 } 197 197 198 typedef struct { 199 GObject *self, *stream; 200 TnyMimePartCallback callback; 201 gpointer user_data; 202 GError *err; 203 } DecodeAsyncInfo; 204 205 206 static void 207 decode_async_destroyer (gpointer user_data) 208 { 209 DecodeAsyncInfo *info = (DecodeAsyncInfo *) user_data; 210 /* thread reference */ 211 g_object_unref (info->self); 212 g_object_unref (info->stream); 213 if (info->err) 214 g_error_free (info->err); 215 g_slice_free (DecodeAsyncInfo, info); 216 return; 217 } 218 219 static gboolean 220 decode_async_callback (gpointer user_data) 221 { 222 DecodeAsyncInfo *info = (DecodeAsyncInfo *) user_data; 223 if (info->callback) { 224 /* TODO: tny_lockable_lock (priv->ui_locker); */ 225 info->callback (TNY_MIME_PART (info->self), TNY_STREAM (info->stream), 226 FALSE, info->err, info->user_data); 227 /* TODO: tny_lockable_unlock (priv->ui_locker); */ 228 } 229 return FALSE; 230 } 231 232 /* This one is just to fulfil the API requirements */ 233 234 static void 235 tny_camel_mime_part_decode_to_stream_async (TnyMimePart *self, TnyStream *stream, TnyMimePartCallback callback, TnyStatusCallback status_callback, gpointer user_data) 236 { 237 TNY_CAMEL_MIME_PART_GET_CLASS (self)->decode_to_stream_async_func (self, stream, callback, status_callback, user_data); 238 return; 239 } 240 241 static void 242 tny_camel_mime_part_decode_to_stream_async_default (TnyMimePart *self, TnyStream *stream, TnyMimePartCallback callback, TnyStatusCallback status_callback, gpointer user_data) 243 { 244 DecodeAsyncInfo *info = g_slice_new0 (DecodeAsyncInfo); 245 246 tny_mime_part_decode_to_stream (self, stream); 247 248 info->self = g_object_ref (self); 249 info->stream = g_object_ref (stream); 250 info->callback = callback; 251 info->user_data = user_data; 252 info->err = NULL; 253 254 g_idle_add_full (G_PRIORITY_HIGH, 255 decode_async_callback, 256 info, decode_async_destroyer); 257 258 return; 259 } 198 260 199 261 … … 1008 1070 klass->get_header_pairs_func = tny_camel_mime_part_get_header_pairs; 1009 1071 klass->set_header_pair_func = tny_camel_mime_part_set_header_pair; 1010 1072 klass->decode_to_stream_async_func = tny_camel_mime_part_decode_to_stream_async; 1011 1073 return; 1012 1074 } … … 1044 1106 class->get_header_pairs_func = tny_camel_mime_part_get_header_pairs_default; 1045 1107 class->set_header_pair_func = tny_camel_mime_part_set_header_pair_default; 1108 class->decode_to_stream_async_func = tny_camel_mime_part_decode_to_stream_async_default; 1046 1109 1047 1110 object_class->finalize = tny_camel_mime_part_finalize; devel/pvanhoof/bs/libtinymail-camel/tny-camel-mime-part.h
r2825 r3029 73 73 void (*get_header_pairs_func) (TnyMimePart *self, TnyList *list); 74 74 void (*set_header_pair_func) (TnyMimePart *self, const gchar *name, const gchar *value); 75 void (*decode_to_stream_async_func) (TnyMimePart *self, TnyStream *stream, TnyMimePartCallback callback, TnyStatusCallback status_callback, gpointer user_data); 76 75 77 }; 76 78 devel/pvanhoof/bs/libtinymail-camel/tny-camel-store-account.c
r2999 r3029 1297 1297 if (info->err) 1298 1298 g_error_free (info->err); 1299 1299 1300 return; 1300 1301 } devel/pvanhoof/bs/libtinymail/tny-mime-part.c
r2825 r3029 38 38 * 39 39 * Set a header pair (name: value) or delete a header (use NULL as value). 40 * 41 * Note that not all TnyMimePart instances are writable. Only when creating 42 * a new message will the instance be guaranteed to be writable. This is a 43 * writing operation. 40 44 * 41 45 * Example: … … 148 152 * Add a mime-part to @self. 149 153 * 154 * Note that not all TnyMimePart instances are writable. Only when creating 155 * a new message will the instance be guaranteed to be writable. This is a 156 * writing operation. 157 * 150 158 * Return value: The id of the added mime-part 151 *152 159 **/ 153 160 gint … … 171 178 * Delete a mime-part from @self 172 179 * 180 * Note that not all TnyMimePart instances are writable. Only when creating 181 * a new message will the instance be guaranteed to be writable. This is a 182 * writing operation. 173 183 **/ 174 184 void … … 236 246 * Set the content location of @self. 237 247 * 248 * Note that not all TnyMimePart instances are writable. Only when creating 249 * a new message will the instance be guaranteed to be writable. This is a 250 * writing operation. 238 251 **/ 239 252 void … … 257 270 * Set the description of @self. 258 271 * 272 * Note that not all TnyMimePart instances are writable. Only when creating 273 * a new message will the instance be guaranteed to be writable. This is a 274 * writing operation. 259 275 **/ 260 276 void … … 278 294 * Set the content id of @self. 279 295 * 296 * Note that not all TnyMimePart instances are writable. Only when creating 297 * a new message will the instance be guaranteed to be writable. This is a 298 * writing operation. 280 299 **/ 281 300 void … … 298 317 * Set the message as purged in cache 299 318 * 319 * This is not a writing operation. Although it might change the content of a 320 * message for a user who's not connected with the server where @self originates 321 * from. 322 * 323 * Using the tny_msg_rewrite_cache API on a message instance will rewrite its 324 * purged mime parts with an empty body (saving storage space). The storage 325 * space is recovered after using tny_msg_rewrite_cache. Only setting a mime 326 * part to purged might not remove it. 327 * 328 * There is no guarantee about what happens with a purged mime part internally 329 * (it might get destroyed or become unuseful more early than the call to 330 * tny_msg_rewrite_cache). 300 331 **/ 301 332 void … … 318 349 * Set the filename of @self. 319 350 * 351 * Note that not all TnyMimePart instances are writable. Only when creating 352 * a new message will the instance be guaranteed to be writable. This is a 353 * writing operation. 320 354 **/ 321 355 void … … 339 373 * Set the content type of @self. Formatted as "type/subtype" 340 374 * 375 * Note that not all TnyMimePart instances are writable. Only when creating 376 * a new message will the instance be guaranteed to be writable. This is a 377 * writing operation. 341 378 **/ 342 379 void … … 362 399 * 363 400 * Return value: the filename of a mime part as a read-only string 364 *365 401 **/ 366 402 const gchar* … … 390 426 * 391 427 * Return value: the content-id of a mime part as a read-only string 392 *393 428 **/ 394 429 const gchar* … … 418 453 * 419 454 * Return value: a #gboolean 420 *421 455 **/ 422 456 gboolean … … 469 503 * 470 504 * Return value: the content-location of a mime part as a read-only string 471 *472 505 **/ 473 506 const gchar* … … 497 530 * Efficiently write the content of @self to a stream. This will not read the 498 531 * data of the part in a memory buffer. In stead it will read the part data while 499 * already writing it to the stream efficiently. 532 * already writing it to the stream efficiently. Although there is no guarantee 533 * about the memory usage either (just that it's the most efficient way). 500 534 * 501 535 * You probably want to utilise the tny_mime_part_decode_to_stream 502 536 * method in stead of this one. This method will not attempt to decode the 503 537 * mime part. Mime parts are usually encoded in E-mails. 538 * 539 * When the mime part was received in BINARY mode from an IMAP server, then this 540 * API has mostly the same effect as the tny_mime_part_decode_to_stream: You 541 * will get a non-encoded version of the data. A small difference will be that 542 * the tny_mime_part_decode_to_stream will decode certain special characters in 543 * TEXT/* mime parts (character set encoding) to UTF-8. 544 * 545 * However. A larger difference happens with binary mime parts that where not 546 * retrieved using BINARY. For those this API will give you the encoded data 547 * as is. This means that you will get a stream spitting out for example BASE64 548 * data. 504 549 * 505 550 * Example: … … 537 582 * Efficiently decode @self to a stream. This will not read the data of the 538 583 * part in a memory buffer. In stead it will read the part data while already 539 * writing it to the stream efficiently. 584 * writing it to the stream efficiently. Although there is no guarantee 585 * about the memory usage either (just that it's the most efficient way). 586 * 587 * You will always get the decoded version of the data of @self. When your part 588 * get received in BINARY from an IMAP server, then nothing will really happen 589 * with your data (it will be streamed to you the way it got received). If we 590 * received using BODY and the data is encoded in a known encoding (BASE65, 591 * QUOTED-PRINTED, UUENCODED), the data will be decoded before delivered. TEXT/* 592 * mime parts will also enjoy character set decoding. 593 * 594 * In short will this API prepare the cookie and deliver it to your stream. It's 595 * most likely the one that you want to use. If you are planning to nevertheless 596 * use the tny_mime_part_write_to_stream API, then please know and understand 597 * what you are doing. 598 * 599 * It's possible that this API receives information from the service. If you 600 * don't want to block on this, use tny_mime_part_decode_to_stream_async. 540 601 * 541 602 * Example: … … 565 626 return; 566 627 } 628 629 /** 630 * tny_mime_part_decode_to_stream_async: 631 * @self: a #TnyMimePart object 632 * @stream: a #TnyMsgStream stream 633 * @callback: a #TnyMimePartCallback callback 634 * @status_callback: a #TnyStatusCallback callback 635 * @user_data: user data for @callback 636 * 637 * This method does the same as tny_mime_part_decode_to_stream. It just does 638 * everything asynchronous and calls you back when finished. 639 */ 640 void 641 tny_mime_part_decode_to_stream_async (TnyMimePart *self, TnyStream *stream, TnyMimePartCallback callback, TnyStatusCallback status_callback, gpointer user_data) 642 { 643 #ifdef DBC /* require */ 644 g_assert (TNY_IS_MIME_PART (self)); 645 g_assert (stream); 646 g_assert (TNY_IS_STREAM (stream)); 647 g_assert (TNY_MIME_PART_GET_IFACE (self)->decode_to_stream_async_func != NULL); 648 #endif 649 650 TNY_MIME_PART_GET_IFACE (self)->decode_to_stream_async_func (self, stream, callback, status_callback, user_data); 651 return; 652 } 653 654 567 655 /** 568 656 * tny_mime_part_construct_from_stream: devel/pvanhoof/bs/libtinymail/tny-mime-part.h
r2825 r3029 68 68 void (*get_header_pairs_func) (TnyMimePart *self, TnyList *list); 69 69 void (*set_header_pair_func) (TnyMimePart *self, const gchar *name, const gchar *value); 70 void (*decode_to_stream_async_func) (TnyMimePart *self, TnyStream *stream, TnyMimePartCallback callback, TnyStatusCallback status_callback, gpointer user_data); 70 71 }; 71 72 … … 95 96 void tny_mime_part_get_header_pairs (TnyMimePart *self, TnyList *list); 96 97 void tny_mime_part_set_header_pair (TnyMimePart *self, const gchar *name, const gchar *value); 98 void tny_mime_part_decode_to_stream_async (TnyMimePart *self, TnyStream *stream, TnyMimePartCallback callback, TnyStatusCallback status_callback, gpointer user_data); 97 99 98 100 G_END_DECLS devel/pvanhoof/bs/libtinymail/tny-shared.h
r2825 r3029 99 99 typedef void (*TnyForgetPassFunc) (TnyAccount *self); 100 100 typedef void (*TnyFolderCallback) (TnyFolder *self, gboolean canceled, GError *err, gpointer user_data); 101 typedef void (*TnyMimePartCallback) (TnyMimePart *self, TnyStream *stream, gboolean canceled, GError *err, gpointer user_data); 101 102 typedef void (*TnyGetHeadersCallback) (TnyFolder *self, gboolean canceled, TnyList *headers, GError *err, gpointer user_data); 102 103 typedef void (*TnyGetMsgCallback) (TnyFolder *folder, gboolean canceled, TnyMsg *msg, GError *err, gpointer user_data); devel/pvanhoof/bs/libtinymailui-gtk/tny-gtk-image-mime-part-view.c
r2975 r3029 51 51 { 52 52 TnyMimePart *part; 53 TnyStatusCallback status_callback; 54 gpointer status_user_data; 53 55 }; 54 56 … … 78 80 79 81 static void 82 on_mime_part_decoded (TnyMimePart *part, TnyStream *dest, gboolean canceled, GError *err, gpointer user_data) 83 { 84 TnyMimePartView *self = (TnyMimePartView *) user_data; 85 GdkPixbuf *pixbuf; 86 tny_stream_reset (dest); 87 pixbuf = tny_gtk_pixbuf_stream_get_pixbuf (TNY_GTK_PIXBUF_STREAM (dest)); 88 gtk_image_set_from_pixbuf (GTK_IMAGE (self), pixbuf); 89 g_object_unref (self); 90 } 91 92 static void 93 on_status (GObject *part, TnyStatus *status, gpointer user_data) 94 { 95 TnyMimePartView *self = (TnyMimePartView *) user_data; 96 TnyGtkImageMimePartViewPriv *priv = TNY_GTK_IMAGE_MIME_PART_VIEW_GET_PRIVATE (self); 97 if (priv->status_callback) 98 priv->status_callback (self, status, priv->status_user_data); 99 return; 100 } 101 102 static void 80 103 tny_gtk_image_mime_part_view_set_part_default (TnyMimePartView *self, TnyMimePart *part) 81 104 { … … 84 107 g_assert (TNY_IS_MIME_PART (part)); 85 108 86 if ( G_LIKELY (priv->part))109 if (priv->part) 87 110 g_object_unref (priv->part); 88 111 89 if (part) 90 { 91 TnyStream *dest; 92 GdkPixbuf *pixbuf; 93 94 dest = tny_gtk_pixbuf_stream_new (tny_mime_part_get_content_type (part)); 95 112 if (part) { 113 TnyStream *dest = tny_gtk_pixbuf_stream_new (tny_mime_part_get_content_type (part)); 96 114 tny_stream_reset (dest); 97 tny_mime_part_decode_to_stream (part, dest); 98 tny_stream_reset (dest); 99 100 pixbuf = tny_gtk_pixbuf_stream_get_pixbuf (TNY_GTK_PIXBUF_STREAM (dest)); 101 gtk_image_set_from_pixbuf (GTK_IMAGE (self), pixbuf); 102 115 tny_mime_part_decode_to_stream_async (part, dest, on_mime_part_decoded, 116 on_status, g_object_ref (self)); 103 117 g_object_unref (dest); 104 105 118 priv->part = g_object_ref (part); 106 119 } … … 124 137 /** 125 138 * tny_gtk_image_mime_part_view_new: 139 * @status_callback: a #TnyStatusCallback for when status information happens 140 * @status_user_data: user data for @status_callback 126 141 * 127 142 * Create a new #TnyMimePartView for Gtk+ … … 130 145 **/ 131 146 TnyMimePartView* 132 tny_gtk_image_mime_part_view_new ( void)147 tny_gtk_image_mime_part_view_new (TnyStatusCallback status_callback, gpointer status_user_data) 133 148 { 134 149 TnyGtkImageMimePartView *self = g_object_new (TNY_TYPE_GTK_IMAGE_MIME_PART_VIEW, NULL); 150 TnyGtkImageMimePartViewPriv *priv = TNY_GTK_IMAGE_MIME_PART_VIEW_GET_PRIVATE (self); 151 152 priv->status_callback = status_callback; 153 priv->status_user_data = status_user_data; 135 154 136 155 return TNY_MIME_PART_VIEW (self); … … 143 162 TnyGtkImageMimePartViewPriv *priv = TNY_GTK_IMAGE_MIME_PART_VIEW_GET_PRIVATE (self); 144 163 164 priv->status_callback = NULL; 165 priv->status_user_data = NULL; 145 166 146 167 return; … … 153 174 TnyGtkImageMimePartViewPriv *priv = TNY_GTK_IMAGE_MIME_PART_VIEW_GET_PRIVATE (self); 154 175 155 if ( G_LIKELY (priv->part))156 g_object_unref ( G_OBJECT (priv->part));176 if (priv->part) 177 g_object_unref (priv->part); 157 178 158 179 (*parent_class->finalize) (object); devel/pvanhoof/bs/libtinymailui-gtk/tny-gtk-image-mime-part-view.h
r2975 r3029 59 59 60 60 GType tny_gtk_image_mime_part_view_get_type (void); 61 TnyMimePartView* tny_gtk_image_mime_part_view_new ( void);61 TnyMimePartView* tny_gtk_image_mime_part_view_new (TnyStatusCallback status_callback, gpointer status_user_data); 62 62 63 63 G_END_DECLS devel/pvanhoof/bs/libtinymailui-gtk/tny-gtk-mime-part-save-strategy.c
r2825 r3029 47 47 static GObjectClass *parent_class = NULL; 48 48 49 typedef struct _TnyGtkMimePartSaveStrategyPriv TnyGtkMimePartSaveStrategyPriv; 50 51 struct _TnyGtkMimePartSaveStrategyPriv 52 { 53 TnyStatusCallback status_callback; 54 gpointer status_user_data; 55 }; 56 49 57 #define TNY_GTK_MIME_PART_SAVE_STRATEGY_GET_PRIVATE(o) \ 50 58 (G_TYPE_INSTANCE_GET_PRIVATE ((o), TNY_TYPE_GTK_MIME_PART_SAVE_STRATEGY, TnyGtkMimePartSaveStrategy
