Changeset 1845
- Timestamp:
- 04/27/07 13:44:14
- Files:
-
- trunk/libtinymail-camel/camel-lite/camel/camel-folder.c (modified) (4 diffs)
- trunk/libtinymail-camel/tny-camel-folder.c (modified) (12 diffs)
- trunk/libtinymailui-gtk/tny-gtk-folder-store-tree-model.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libtinymail-camel/camel-lite/camel/camel-folder.c
r1706 r1845 320 320 int unread = -1, deleted = 0, junked = 0, visible = 0, count = -1; 321 321 322 for (i=0;i<args->argc;i++) { 323 CamelArgGet *arg = &args->argv[i]; 324 325 tag = arg->tag; 326 327 switch (tag & CAMEL_ARG_TAG) { 328 /* CamelObject args */ 322 for (i=0; i < args->argc; i++) 323 { 324 CamelArgGet *arg = &args->argv[i]; 325 326 tag = arg->tag; 327 328 switch (tag & CAMEL_ARG_TAG) 329 { 330 /* CamelObject args */ 329 331 case CAMEL_OBJECT_ARG_DESCRIPTION: 330 332 if (folder->description == NULL) … … 351 353 case CAMEL_FOLDER_ARG_UNREAD: 352 354 case CAMEL_FOLDER_ARG_DELETED: 353 /* This is so we can get the values atomically, and also so we can calculate them only once */ 355 356 /* This is so we can get the values atomically, and also 357 * so we can calculate them only once */ 358 354 359 if (unread == -1) { 355 360 int j; … … 358 363 /* TODO: Locking? */ 359 364 unread = 0; 360 count = camel_folder_summary_count (folder->summary);361 for (j=0; j <count; j++)365 count = camel_folder_summary_count (folder->summary); 366 for (j=0; j < count; j++) 362 367 { 363 info = camel_folder_summary_index (folder->summary, j);368 info = camel_folder_summary_index (folder->summary, j); 364 369 if (info) 365 370 { 366 guint32 flags = camel_message_info_flags(info); 367 368 if ((flags & CAMEL_MESSAGE_SEEN) == 0) 369 unread++; 371 guint32 flags = camel_message_info_flags (info); 372 370 373 if (flags & CAMEL_MESSAGE_DELETED) 371 374 deleted++; 375 else 376 if ((flags & CAMEL_MESSAGE_SEEN) == 0) 377 unread++; 378 372 379 camel_message_info_free(info); 373 380 } … … 410 417 default: 411 418 continue; 412 }413 414 arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE;419 } 420 421 arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE; 415 422 } 416 423 trunk/libtinymail-camel/tny-camel-folder.c
r1836 r1845 173 173 { 174 174 guint32 flags = camel_message_info_flags(info); 175 if ((flags & CAMEL_MESSAGE_ SEEN) == 0)175 if ((flags & CAMEL_MESSAGE_DELETED) && (flags & CAMEL_MESSAGE_SEEN)) 176 176 priv->unread_length++; 177 177 priv->cached_length++; … … 213 213 unread messages (yes I know it sucks, but get_unread_msg_cnt 214 214 walks the entire summary to count the unread ones). 215 216 215 TNY TODO: a better solution for this */ 217 218 216 priv->unread_length = camel_folder_get_unread_message_count (priv->folder); 219 217 priv->unread_sync = 0; … … 711 709 GError *err; 712 710 TnySessionCamel *session; 713 guint oldlen, oldurlen;714 711 } RefreshFolderInfo; 715 712 … … 740 737 TnyFolder *self = info->self; 741 738 TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 739 TnyFolderChange *change = tny_folder_change_new (self); 742 740 743 741 if (info->callback) 744 742 info->callback (info->self, info->cancelled, &info->err, info->user_data); 745 743 746 if (info->oldlen != priv->cached_length || info->oldurlen != priv->unread_length) 747 { 748 TnyFolderChange *change = tny_folder_change_new (self); 749 if (info->oldlen != priv->cached_length) 750 tny_folder_change_set_new_all_count (change, priv->cached_length); 751 if (info->oldurlen != priv->unread_length) 752 tny_folder_change_set_new_unread_count (change, priv->unread_length); 753 notify_folder_observers_about (self, change); 754 g_object_unref (change); 755 } 744 tny_folder_change_set_new_all_count (change, priv->cached_length); 745 tny_folder_change_set_new_unread_count (change, priv->unread_length); 746 notify_folder_observers_about (self, change); 747 g_object_unref (change); 756 748 757 749 return FALSE; … … 970 962 971 963 info = g_slice_new (RefreshFolderInfo); 972 info->oldlen = priv->cached_length;973 info->oldurlen = priv->unread_length;974 964 info->session = TNY_FOLDER_PRIV_GET_SESSION (priv); 975 965 info->err = NULL; … … 1031 1021 priv->cached_length = camel_folder_get_message_count (priv->folder); 1032 1022 if (G_LIKELY (priv->folder) && CAMEL_IS_FOLDER (priv->folder) && G_LIKELY (priv->has_summary_cap)) 1033 priv->unread_length = (guint) camel_folder_get_unread_message_count (priv->folder);1023 priv->unread_length = (guint) camel_folder_get_unread_message_count (priv->folder); 1034 1024 1035 1025 if (camel_exception_is_set (&ex)) … … 1090 1080 tny_list_prepend (headers, (GObject*)header); 1091 1081 1092 if ((flags & CAMEL_MESSAGE_SEEN) == 0)1093 priv->unread_length++;1094 1095 1082 g_object_unref (G_OBJECT (header)); 1096 1097 priv->cached_length++;1098 1083 1099 1084 return; … … 1113 1098 CamelException ex = CAMEL_EXCEPTION_INITIALISER; 1114 1099 FldAndPriv *ptr = NULL; 1115 guint oldlen = priv->cached_length;1116 guint oldurlen = priv->unread_length;1117 1100 1118 1101 g_assert (TNY_IS_LIST (headers)); … … 1153 1136 1154 1137 if (priv->folder && CAMEL_IS_FOLDER (priv->folder)) 1155 { 1156 priv->cached_length = 0; 1157 priv->unread_length = 0; 1158 g_ptr_array_foreach (priv->folder->summary->messages, add_message_with_uid, ptr); 1159 } 1138 g_ptr_array_foreach (priv->folder->summary->messages, 1139 add_message_with_uid, ptr); 1160 1140 1161 1141 g_slice_free (FldAndPriv, ptr); … … 1163 1143 g_object_unref (G_OBJECT (headers)); 1164 1144 g_static_rec_mutex_unlock (priv->folder_lock); 1165 1166 if (oldlen != priv->cached_length || oldurlen != priv->unread_length)1167 {1168 TnyFolderChange *change = tny_folder_change_new (self);1169 if (oldlen != priv->cached_length)1170 tny_folder_change_set_new_all_count (change, priv->cached_length);1171 if (oldurlen != priv->unread_length)1172 tny_folder_change_set_new_unread_count (change, priv->unread_length);1173 notify_folder_observers_about (self, change);1174 g_object_unref (change);1175 }1176 1145 1177 1146 _tny_session_stop_operation (TNY_FOLDER_PRIV_GET_SESSION (priv)); … … 2843 2812 TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 2844 2813 guint newlen, newurlen; 2814 TnyFolderChange *change; 2815 2816 2817 /* TODO: This causes a memory peak at the application's startup. 2818 * We can improve this by only reading the unread and read counts 2819 * from the summary.mmap file (in camel-lite). */ 2845 2820 2846 2821 g_static_rec_mutex_lock (priv->folder_lock); 2847 2848 2822 if (!priv->folder || !priv->loaded || !CAMEL_IS_FOLDER (priv->folder)) 2849 2823 if (!load_folder_no_lock (priv)) … … 2852 2826 return; 2853 2827 } 2854 2855 2828 newurlen = camel_folder_get_unread_message_count (priv->folder); 2856 2829 newlen = camel_folder_get_message_count (priv->folder); 2857 2858 2830 g_static_rec_mutex_unlock (priv->folder_lock); 2859 2831 2860 2861 if (newlen != priv->cached_length || newurlen != priv->unread_length) 2862 { 2863 TnyFolderChange *change = tny_folder_change_new (self); 2864 2865 if (newlen != priv->cached_length) 2866 { 2867 priv->cached_length = newlen; 2868 tny_folder_change_set_new_all_count (change, priv->cached_length); 2869 } 2870 2871 2872 if (newurlen != priv->unread_length) 2873 { 2874 priv->unread_length = newurlen; 2875 tny_folder_change_set_new_unread_count (change, priv->unread_length); 2876 } 2877 2878 notify_folder_observers_about (self, change); 2879 g_object_unref (change); 2880 } 2881 2832 change = tny_folder_change_new (self); 2833 priv->cached_length = newlen; 2834 tny_folder_change_set_new_all_count (change, priv->cached_length); 2835 priv->unread_length = newurlen; 2836 tny_folder_change_set_new_unread_count (change, priv->unread_length); 2837 notify_folder_observers_about (self, change); 2838 g_object_unref (change); 2839 2840 _tny_camel_folder_check_uncache ((TnyCamelFolder*)self, priv); 2882 2841 2883 2842 return FALSE; trunk/libtinymailui-gtk/tny-gtk-folder-store-tree-model.c
r1788 r1845 86 86 folder, -1); 87 87 88 /* TODO: This causes a memory peak at the application's startup. 89 *Also look at tny-camel-folder:c:2818... for more information */ 90 91 tny_folder_poke_status (TNY_FOLDER (folder)); 92 88 93 recurse_folders_async (hlrp->self, folder, tree_iter); 89 94 … … 163 168 164 169 recurse_folders_sync (self, folder, &tree_iter); 170 171 172 /* TODO: This causes a memory peak at the application's startup. 173 *Also look at tny-camel-folder:c:2818... for more information */ 174 175 tny_folder_poke_status (TNY_FOLDER (folder)); 165 176 166 177 g_object_unref (G_OBJECT (folder));
