Changeset 1092
- Timestamp:
- 11/06/06 15:19:14
- Files:
-
- trunk (modified) (1 prop)
- trunk/.svnignore (modified) (1 diff)
- trunk/ChangeLog (modified) (1 diff)
- trunk/bindings/python/Makefile.am (modified) (1 diff)
- trunk/libtinymail-camel/Makefile.am (modified) (2 diffs)
- trunk/libtinymail-camel/tny-camel-folder-priv.h (modified) (1 diff)
- trunk/libtinymail-camel/tny-camel-folder.c (modified) (59 diffs)
- trunk/libtinymail-camel/tny-camel-folder.h (modified) (1 diff)
- trunk/libtinymail-camel/tny-camel-msg-remove-strategy.c (added)
- trunk/libtinymail-camel/tny-camel-msg-remove-strategy.h (added)
- trunk/libtinymail-test/tny-folder-test.c (modified) (1 diff)
- trunk/libtinymail/Makefile.am (modified) (2 diffs)
- trunk/libtinymail/tny-folder.c (modified) (8 diffs)
- trunk/libtinymail/tny-folder.h (modified) (4 diffs)
- trunk/libtinymail/tny-msg-remove-strategy.c (added)
- trunk/libtinymail/tny-msg-remove-strategy.h (added)
- trunk/libtinymail/tny-shared.h (modified) (1 diff)
- trunk/tinymail/tny-demoui-summary-view.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk
- Property svn:ignore changed from compile tags py* anjuta.anjuta config.h stamp-h1 libtinymail-*.tar.gz libtinymail.spec .anjuta .svnignore .tm_project2.cache configure config.log depcomp TODO.tasks config.guess ltmain.sh config.sub anjuta gtk-doc.make tinymail.anjuta Makefile Makefile.in mkinstalldirs config.status autom4te.cache libtool tm_project2.cache missing aclocal.m4 install-sh to compile tags py* *.anjuta config.h stamp-h1 libtinymail-*.tar.gz libtinymail.spec .anjuta .svnignore .tm_project2.cache configure config.log depcomp TODO.tasks config.guess ltmain.sh config.sub anjuta gtk-doc.make tinymail.anjuta Makefile Makefile.in mkinstalldirs config.status autom4te.cache libtool tm_project2.cache missing aclocal.m4 install-sh
trunk/.svnignore
r802 r1092 2 2 tags 3 3 py* 4 anjuta.anjuta4 *.anjuta 5 5 config.h 6 6 stamp-h1 trunk/ChangeLog
r1091 r1092 1 2006-11-06 Philip van Hoof <pvanhoof@gnome.org> 2 3 * Introduction of the TnyMsgRemoveStrategy, which makes it more 4 flexible to define how tinymail should remove messages (as this might 5 be specific per device). Although this means a major API change, not a 6 lot external API has changed. A default remove strategy is used for 7 each folder and is implemented as TnyCamelMsgRemoveStrategy. This 8 is an overwritable property. 9 10 * This was a major API change 11 1 12 2006-11-06 Sergio Villar Senin <svillar@igalia.com> 2 13 trunk/bindings/python/Makefile.am
r1090 r1092 88 88 $(top_srcdir)/libtinymail/tny-store-account.h \ 89 89 $(top_srcdir)/libtinymail/tny-stream.h \ 90 $(top_srcdir)/libtinymail/tny-transport-account.h 90 $(top_srcdir)/libtinymail/tny-transport-account.h \ 91 $(top_srcdir)/libtinymail/tny-msg-remove-strategy.h 91 92 92 93 tinymail.defs: $(tinymail_h_files) tinymail.defs.extra $(top_srcdir)/bindings/python/filter.py trunk/libtinymail-camel/Makefile.am
r1014 r1092 10 10 libtinymail_camel_1_0_headers = \ 11 11 tny-camel-mime-part.h \ 12 tny-camel-msg-remove-strategy.h \ 12 13 tny-camel-header.h \ 13 14 tny-camel-msg.h \ … … 29 30 libtinymail_camel_1_0_la_SOURCES = \ 30 31 tny-session-camel-priv.h \ 32 tny-camel-msg-remove-strategy.c \ 31 33 tny-camel-common.c \ 32 34 tny-camel-common-priv.h \ trunk/libtinymail-camel/tny-camel-folder-priv.h
r976 r1092 46 46 TnyFolderType cached_folder_type; 47 47 GList *possible_headers; 48 GMutex *poshdr_lock; 48 GMutex *poshdr_lock; 49 TnyMsgRemoveStrategy *remove_strat; 49 50 }; 50 51 trunk/libtinymail-camel/tny-camel-folder.c
r1087 r1092 44 44 #include <errno.h> 45 45 46 #include <tny-camel-msg-remove-strategy.h> 46 47 #include <tny-session-camel.h> 47 48 #include "tny-camel-account-priv.h" … … 64 65 65 66 When we know a new message got added to this folder 66 67 info->uid_added68 info->uid_removed69 info->uid_changed70 info->uid_recent67 68 info->uid_added 69 info->uid_removed 70 info->uid_changed 71 info->uid_recent 71 72 } 72 73 */ … … 75 76 pos_header_check (gpointer data, gpointer udata) 76 77 { 77 /* this is a very ugly check .. let's hope that we can remove this soon */ 78 79 /* Note: TNY_IS_CAMEL_HEADER crashes if there's a message referenced ( 78 /* this is a very ugly check .. let's hope that we can remove this soon */ 79 /* Note: TNY_IS_CAMEL_HEADER crashes if there's a message referenced ( 80 80 this might imply that a header is still referenced and therefore not 81 81 destroyed) .. I don't know, it's definitely a bug. Also check #1 on 82 82 the trac's tickets. */ 83 83 84 84 if (data) 85 85 { … … 93 93 { 94 94 95 if (priv->folder && !CAMEL_IS_FOLDER (priv->folder))95 if (priv->folder && !CAMEL_IS_FOLDER (priv->folder)) 96 96 { 97 97 g_mutex_lock (priv->poshdr_lock); … … 103 103 priv->possible_headers = NULL; 104 104 g_mutex_unlock (priv->poshdr_lock); 105 105 106 106 if (CAMEL_IS_OBJECT (priv->folder)) 107 107 { 108 108 g_critical ("Killing invalid CamelObject (should be a Camelfolder) at 0x%x\n", priv->folder); 109 110 109 while (((CamelObject*)priv->folder)->ref_count >= 1) 111 110 camel_object_unref (CAMEL_OBJECT (priv->folder)); 112 111 } else 113 g_critical ("Corrupted CamelFolder instance at 0x%x (I can't recover from this state, therefore I will leak)\n", priv->folder);114 } 115 112 g_critical ("Corrupted CamelFolder instance at 0x%x (I can't recover from this state, therefore I will leak)\n", priv->folder); 113 } 114 116 115 if (G_LIKELY (priv->folder) && CAMEL_IS_FOLDER (priv->folder)) 117 116 { 118 /*117 /* 119 118 if (((CamelObject*)priv->folder)->ref_count) 120 119 if (priv->folder_changed_id != 0) 121 120 camel_object_remove_event (priv->folder, priv->folder_changed_id); 122 121 */ 123 122 124 123 g_mutex_lock (priv->poshdr_lock); 125 124 if (priv->possible_headers) … … 130 129 priv->possible_headers = NULL; 131 130 g_mutex_unlock (priv->poshdr_lock); 132 131 133 132 while (((CamelObject*)priv->folder)->ref_count >= 1) 134 133 camel_object_unref (CAMEL_OBJECT (priv->folder)); … … 136 135 } 137 136 138 priv->folder = NULL;137 priv->folder = NULL; 139 138 priv->cached_length = 0; 140 139 priv->cached_folder_type = TNY_FOLDER_TYPE_UNKNOWN; … … 158 157 if (priv->folder && !CAMEL_IS_FOLDER (priv->folder)) 159 158 unload_folder_no_lock (priv, FALSE); 160 159 161 160 if (!priv->folder && !priv->loaded && priv->folder_name) 162 161 { … … 164 163 CamelStore *store = (CamelStore*) _tny_camel_account_get_service 165 164 (TNY_CAMEL_ACCOUNT (priv->account)); 166 165 167 166 g_mutex_lock (priv->poshdr_lock); 168 167 if (priv->possible_headers) … … 173 172 priv->possible_headers = NULL; 174 173 g_mutex_unlock (priv->poshdr_lock); 175 174 176 175 priv->folder = camel_store_get_folder 177 176 (store, priv->folder_name, 0, &ex); … … 182 181 while (((CamelObject*)priv->folder)->ref_count >= 1) 183 182 camel_object_unref (CAMEL_OBJECT (priv->folder)); 184 183 185 184 priv->folder = NULL; 186 185 priv->loaded = FALSE; 187 186 return FALSE; 188 187 } 189 190 priv->cached_length = camel_folder_get_message_count (priv->folder);188 189 priv->cached_length = camel_folder_get_message_count (priv->folder); 191 190 192 191 /* priv->folder_changed_id = camel_object_hook_event (priv->folder, … … 211 210 { 212 211 gboolean retval; 213 212 214 213 g_mutex_lock (priv->folder_lock); 215 214 retval = load_folder_no_lock (priv); … … 221 220 222 221 static void 223 tny_camel_folder_remove_message (TnyFolder *self, TnyHeader *header) 224 { 225 TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 226 const gchar *id; 222 tny_camel_folder_remove_msg (TnyFolder *self, TnyHeader *header) 223 { 224 TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 225 226 if (!priv->remove_strat) 227 return; 227 228 228 229 g_mutex_lock (priv->folder_lock); … … 234 235 return; 235 236 } 236 237 id = tny_header_get_uid (TNY_HEADER (header)); 238 camel_folder_delete_message (priv->folder, id); 237 238 tny_msg_remove_strategy_remove (priv->remove_strat, self, header); 239 239 240 240 g_mutex_unlock (priv->folder_lock); … … 257 257 return; 258 258 } 259 259 260 260 camel_folder_sync (priv->folder, TRUE, &ex); 261 261 … … 275 275 if (!load_folder_no_lock (priv)) 276 276 return NULL; 277 277 278 278 retval = priv->folder; 279 279 … … 420 420 gpointer user_data; 421 421 gboolean cancelled; 422 guint depth;422 guint depth; 423 423 } RefreshFolderInfo; 424 424 … … 519 519 destroy_progress_idle (info); 520 520 } 521 521 522 522 return; 523 523 } … … 537 537 538 538 g_mutex_lock (priv->folder_lock); 539 539 540 540 if (!load_folder_no_lock (priv)) 541 541 { … … 546 546 return NULL; 547 547 } 548 548 549 549 info->cancelled = FALSE; 550 550 str = g_strdup_printf (_("Reading folder `%s'"), priv->folder->full_name); … … 553 553 g_free (str); 554 554 camel_folder_refresh_info (priv->folder, ex); 555 priv->cached_length = camel_folder_get_message_count (priv->folder);555 priv->cached_length = camel_folder_get_message_count (priv->folder); 556 556 557 557 if (G_LIKELY (priv->folder) && CAMEL_IS_FOLDER (priv->folder) && G_LIKELY (priv->has_summary_cap)) … … 563 563 g_mutex_unlock (priv->folder_lock); 564 564 565 /* thread reference */565 /* thread reference */ 566 566 g_object_unref (G_OBJECT (self)); 567 567 … … 581 581 } 582 582 } 583 583 584 584 g_thread_exit (NULL); 585 585 … … 592 592 RefreshFolderInfo *info = g_new0 (RefreshFolderInfo, 1); 593 593 GThread *thread; 594 594 595 595 info->self = self; 596 596 info->callback = callback; … … 598 598 info->user_data = user_data; 599 599 info->depth = g_main_depth (); 600 600 601 601 /* thread reference */ 602 602 g_object_ref (G_OBJECT (self)); … … 624 624 return; 625 625 } 626 626 627 627 _tny_camel_account_start_camel_operation (TNY_CAMEL_ACCOUNT (priv->account), 628 628 NULL, NULL, NULL); … … 630 630 _tny_camel_account_stop_camel_operation (TNY_CAMEL_ACCOUNT (priv->account)); 631 631 632 priv->cached_length = camel_folder_get_message_count (priv->folder);632 priv->cached_length = camel_folder_get_message_count (priv->folder); 633 633 if (G_LIKELY (priv->folder) && CAMEL_IS_FOLDER (priv->folder) && G_LIKELY (priv->has_summary_cap)) 634 634 priv->unread_length = (guint)camel_folder_get_unread_message_count (priv->folder); … … 656 656 } 657 657 658 g_object_ref (G_OBJECT (headers));658 g_object_ref (G_OBJECT (headers)); 659 659 660 660 ptr = g_new (FldAndPriv, 1); … … 666 666 { 667 667 camel_folder_refresh_info (priv->folder, &ex); 668 priv->cached_length = camel_folder_get_message_count (priv->folder);668 priv->cached_length = camel_folder_get_message_count (priv->folder); 669 669 if (G_LIKELY (priv->folder) && CAMEL_IS_FOLDER (priv->folder) && G_LIKELY (priv->has_summary_cap)) 670 670 priv->unread_length = (guint)camel_folder_get_unread_message_count (priv->folder); 671 671 } 672 673 672 priv->cached_length = 0; 674 673 675 if (priv->folder && CAMEL_IS_FOLDER (priv->folder))674 if (priv->folder && CAMEL_IS_FOLDER (priv->folder)) 676 675 uids = camel_folder_get_uids (priv->folder); 677 676 678 677 /* TODO: remove this warning, as it's not really strange. But needed for debugging aid 679 678 for ticket #1 on the trac. So if we fix this bug, remove this. */ 680 681 if (uids)679 680 if (uids) 682 681 g_ptr_array_foreach (uids, add_message_with_uid, ptr); 683 684 682 g_free (ptr); 685 683 686 684 if (uids) 687 685 camel_folder_free_uids (priv->folder, uids); 688 686 689 687 g_object_unref (G_OBJECT (headers)); 690 688 g_mutex_unlock (priv->folder_lock); … … 695 693 696 694 static TnyMsg* 697 tny_camel_folder_get_m essage(TnyFolder *self, TnyHeader *header)695 tny_camel_folder_get_msg (TnyFolder *self, TnyHeader *header) 698 696 { 699 697 TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 700 698 TnyMsg *message = NULL; 701 CamelMimeMessage *camel_message = NULL;699 CamelMimeMessage *camel_message = NULL; 702 700 const gchar *id; 703 701 CamelException *ex = camel_exception_new (); 704 702 705 703 g_mutex_lock (priv->folder_lock); 706 704 707 705 id = tny_header_get_uid (TNY_HEADER (header)); 708 706 709 707 if (!load_folder_no_lock (priv)) 710 708 { … … 720 718 if (camel_exception_get_id (ex) == CAMEL_EXCEPTION_NONE) 721 719 { 722 TnyCamelHeader *nheader = tny_camel_header_new ();720 TnyCamelHeader *nheader = TNY_CAMEL_HEADER (tny_camel_header_new ()); 723 721 724 722 /* I don't reuse the header because that would keep a reference … … 761 759 if (!load_folder (priv)) 762 760 return NULL; 763 764 761 name = camel_folder_get_name (priv->folder); 765 762 } else … … 883 880 { 884 881 TnyCamelFolder *self = g_object_new (TNY_TYPE_CAMEL_FOLDER, NULL); 885 882 886 883 tny_camel_folder_set_folder (self, camel_folder); 887 884 … … 916 913 g_mutex_lock (priv->folder_lock); 917 914 918 if (priv->account)915 if (priv->account) 919 916 { 920 917 TnyCamelStoreAccountPriv *apriv = TNY_CAMEL_STORE_ACCOUNT_GET_PRIVATE (priv->account); 921 918 apriv->managed_folders = g_list_remove (apriv->managed_folders, self); 922 919 } 923 920 924 921 if (!priv->iter_parented && priv->iter) 925 922 { 926 CamelStore *store = (CamelStore*) _tny_camel_account_get_service (TNY_CAMEL_ACCOUNT (priv->account));923 CamelStore *store = (CamelStore*) _tny_camel_account_get_service (TNY_CAMEL_ACCOUNT (priv->account)); 927 924 camel_store_free_folder_info (store, priv->iter); 928 925 } 929 926 930 927 unload_folder_no_lock (priv, TRUE); 931 928 … … 940 937 priv->cached_name = NULL; 941 938 939 if (G_LIKELY (priv->remove_strat)) 940 g_object_unref (G_OBJECT (priv->remove_strat)); 941 priv->remove_strat = NULL; 942 942 943 943 g_mutex_unlock (priv->folder_lock); … … 948 948 g_mutex_free (priv->poshdr_lock); 949 949 priv->poshdr_lock = NULL; 950 950 951 951 if (priv->folder_name) 952 952 g_free (priv->folder_name); 953 953 954 954 (*parent_class->finalize) (object); 955 955 … … 971 971 void 972 972 _tny_camel_folder_check_uncache (TnyCamelFolder *self, TnyCamelFolderPriv *priv) 973 { 973 { 974 974 if (priv->headers_managed == 0) 975 975 tny_camel_folder_uncache (self); … … 977 977 978 978 979 static TnyMsgRemoveStrategy* 980 tny_camel_folder_get_msg_remove_strategy (TnyFolder *self) 981 { 982 TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 983 984 return TNY_MSG_REMOVE_STRATEGY (g_object_ref (G_OBJECT (priv->remove_strat))); 985 } 986 987 static void 988 tny_camel_folder_set_msg_remove_strategy (TnyFolder *self, TnyMsgRemoveStrategy *st) 989 { 990 TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 991 992 if (priv->remove_strat) 993 g_object_unref (G_OBJECT (priv->remove_strat)); 994 995 priv->remove_strat = TNY_MSG_REMOVE_STRATEGY (g_object_ref (G_OBJECT (st))); 996 997 return; 998 } 999 1000 979 1001 static void 980 1002 tny_folder_init (gpointer g, gpointer iface_data) … … 982 1004 TnyFolderIface *klass = (TnyFolderIface *)g; 983 1005 1006 klass->get_msg_remove_strategy_func = tny_camel_folder_get_msg_remove_strategy; 1007 klass->set_msg_remove_strategy_func = tny_camel_folder_set_msg_remove_strategy; 984 1008 klass->get_headers_func = tny_camel_folder_get_headers; 985 klass->get_m essage_func = tny_camel_folder_get_message;1009 klass->get_msg_func = tny_camel_folder_get_msg; 986 1010 klass->get_id_func = tny_camel_folder_get_id; 987 1011 klass->set_name_func = tny_camel_folder_set_name; … … 994 1018 klass->refresh_async_func = tny_camel_folder_refresh_async; 995 1019 klass->refresh_func = tny_camel_folder_refresh; 996 klass->remove_m essage_func = tny_camel_folder_remove_message;1020 klass->remove_msg_func = tny_camel_folder_remove_msg; 997 1021 klass->expunge_func = tny_camel_folder_expunge; 998 1022 … … 1015 1039 TnyCamelFolder *cfol = TNY_CAMEL_FOLDER (folder); 1016 1040 TnyCamelFolderPriv *cpriv = TNY_CAMEL_FOLDER_GET_PRIVATE (cfol); 1017 gchar *cfolname; gchar *folname; gint parlen;1041 gchar *cfolname; gchar *folname; gint parlen; 1018 1042 CamelException ex = CAMEL_EXCEPTION_INITIALISER; 1019 1043 1020 if (!cpriv->folder_name || !priv->folder_name)1044 if (!cpriv->folder_name || !priv->folder_name) 1021 1045 return; 1022 1046 … … 1025 1049 parlen = strlen (folname); 1026 1050 1027 /* /INBOX/test 1051 /* /INBOX/test 1028 1052 /INBOX/test/test */ 1029 1030 if (!strncmp (folname, cfolname, parlen))1053 1054 if (!strncmp (folname, cfolname, parlen)) 1031 1055 { 1032 1056 gchar *ccfoln = cfolname + parlen; … … 1065 1089 1066 1090 folname = priv->folder_name; 1067 folder = tny_camel_folder_new ();1091 folder = tny_camel_folder_new (); 1068 1092 info = camel_store_create_folder (store, priv->folder_name, name, &ex); 1069 1093 1070 1094 _tny_camel_folder_set_id (TNY_CAMEL_FOLDER (folder), info->full_name); 1071 camel_store_free_folder_info (store, info);1095 camel_store_free_folder_info (store, info); 1072 1096 1073 1097 /* TODO: Error handling using 'ex' */ 1074 1098 1075 return folder;1099 return folder; 1076 1100 } 1077 1101 … … 1080 1104 _tny_camel_folder_set_folder_type (TnyCamelFolder *folder, CamelFolderInfo *folder_info) 1081 1105 { 1082 TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (folder);1106 TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (folder); 1083 1107 1084 1108 if (!folder_info) … … 1113 1137 { 1114 1138 TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (folder); 1115 1139 1116 1140 priv->iter = iter; 1117 priv->iter_parented = TRUE;1118 1141 priv->iter_parented = TRUE; 1142 1119 1143 return; 1120 1144 } … … 1132 1156 TnyCamelStoreAccountPriv *apriv = TNY_CAMEL_STORE_ACCOUNT_GET_PRIVATE (priv->account); 1133 1157 CamelFolderInfo *iter; 1134 1135 1158 1136 1159 if (!priv->folder_name) … … 1144 1167 priv->iter_parented = FALSE; 1145 1168 } 1146 1169 1147 1170 iter = priv->iter; 1148 1149 if (iter)1150 { 1171 1172 if (iter) 1173 { 1151 1174 iter = iter->child; 1152 1153 1175 while (iter) 1154 {1176 { 1155 1177 if (_tny_folder_store_query_passes (query, iter)) 1156 1178 { … … 1170 1192 1171 1193 tny_list_prepend (list, G_OBJECT (folder)); 1172 } 1194 } 1173 1195 iter = iter->next; 1174 1196 } 1175 1197 } 1176 1177 return; 1178 } 1179 1180 1181 typedef struct { 1182 TnyFolderStore *self; 1183 TnyList *list; 1184 TnyGetFoldersCallback callback; 1185 TnyFolderStoreQuery *query; 1186 gpointer user_data; 1187 guint depth; 1198 1199 return; 1200 } 1201 1202 1203 typedef struct 1204 { 1205 TnyFolderStore *self; 1206 TnyList *list; 1207 TnyGetFoldersCallback callback; 1208 TnyFolderStoreQuery *query; 1209 gpointer user_data; 1210 guint depth; 1188 1211 } GetFoldersInfo; 1189 1212 … … 1193 1216 { 1194 1217 GetFoldersInfo *info = thr_user_data; 1195 1218 1196 1219 /* gidle reference */ 1197 1220 g_object_unref (G_OBJECT (info->self)); … … 1218 1241 { 1219 1242 GetFoldersInfo *info = (GetFoldersInfo*) thr_user_data; 1220 1243 1221 1244 tny_folder_store_get_folders (TNY_FOLDER_STORE (info->self), 1222 1245 info->list, info->query); 1223 1246 1224 1247 if (info->query) 1225 1248 g_object_unref (G_OBJECT (info->query)); 1226 1249 1227 /* thread reference */1250 /* thread reference */ 1228 1251 g_object_unref (G_OBJECT (info->self)); 1229 1252 g_object_unref (G_OBJECT (info->list)); 1230 1253 1231 1254 if (info->callback) 1232 1255 { … … 1235 1258 g_object_ref (G_OBJECT (info->list)); 1236 1259 1237 if (info->depth > 0)1260 if (info->depth > 0) 1238 1261 { 1239 1262 g_idle_add_full (G_PRIORITY_HIGH, … … 1246 1269 } 1247 1270 1248 1249 1271 g_thread_exit (NULL); 1250 1272 1251 1273 return NULL; 1252 1274 } … … 1255 1277 tny_camel_folder_get_folders_async (TnyFolderStore *self, TnyList *list, TnyGetFoldersCallback callback, TnyFolderStoreQuery *query, gpointer user_data) 1256 1278 { 1257 TNY_CAMEL_FOLDER_GET_CLASS (self)->get_folders_async_func (self, list, callback, query, user_data);1279 TNY_CAMEL_FOLDER_GET_CLASS (self)->get_folders_async_func (self, list, callback, query, user_data); 1258 1280 } 1259 1281 … … 1265 1287 1266 1288 info->self = self; 1267 info->list = list;1289 info->list = list; 1268 1290 info->callback = callback; 1269 1291 info->user_data = user_data; 1270 1292 info->query = query; 1271 info->depth = g_main_depth ();1272 1293 info->depth = g_main_depth (); 1294 1273 1295 /* thread reference */ 1274 1296 g_object_ref (G_OBJECT (info->self)); … … 1276 1298 if (info->query) 1277 1299 g_object_ref (G_OBJECT (info->query)); 1278 1300 1279 1301 thread = g_thread_create (tny_camel_folder_get_folders_async_thread, 1280 1302 info, FALSE, NULL); … … 1293 1315 klass->get_folders_func = tny_camel_folder_get_folders; 1294 1316 klass->get_folders_async_func = tny_camel_folder_get_folders_async; 1295 1296 return;1317 1318 return; 1297 1319 } 1298 1320 … … 1306 1328 object_class->finalize = tny_camel_folder_finalize; 1307 1329 1308 class->get_folders_async_func = tny_camel_folder_get_folders_async_default;1330 class->get_folders_async_func = tny_camel_folder_get_folders_async_default; 1309 1331 class->get_folders_func = tny_camel_folder_get_folders_default; 1310 1332 class->create_folder_func = tny_camel_folder_create_folder_default; 1311 1333 class->remove_folder_func = tny_camel_folder_remove_folder_default; 1312 1334 1313 1335 g_type_class_add_private (object_class, sizeof (TnyCamelFolderPriv)); 1314 1336 … … 1324 1346 TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 1325 1347 1326 priv->iter = NULL;1348 priv->iter = NULL; 1327 1349 priv->iter_parented = FALSE; 1328 1350 priv->headers_managed = 0; … … 1334 1356 priv->cached_name = NULL; 1335 1357 priv->cached_folder_type = TNY_FOLDER_TYPE_UNKNOWN; 1336 1358 1359 priv->remove_strat = tny_camel_msg_remove_strategy_new (); 1360 1337 1361 return; 1338 1362 } trunk/libtinymail-camel/tny-camel-folder.h
r900 r1092 49 49 { 50 50 GObjectClass parent; 51 52 /* virtual methods (they have a default implementation in TnyCamelFolder */51 52 /* virtual methods (they have a default implementation in TnyCamelFolder */ 53 53 void (*get_folders_async_func) (TnyFolderStore *self, TnyList *list, TnyGetFoldersCallback callback, TnyFolderStoreQuery *query, gpointer user_data); 54 54 void (*get_folders_func) (TnyFolderStore *self, TnyList *list, TnyFolderStoreQuery *query); trunk/libtinymail-test/tny-folder-test.c
r965 r1092 148 148 tny_folder_test_remove_message (void) 149 149 { 150 TnyList *headers;150 TnyList *headers; 151 151 gint orig_length = 0, test_len = 0, new_len = 0, headers_len = 0; 152 152 TnyIterator *iter; 153 TnyHeader *header;154 155 if (iface == NULL)153 TnyHeader *header; 154 155 if (iface == NULL) 156 156 { 157 157 GUNIT_WARNING ("Test cannot continue (are you online?)"); 158 return;158 return; 159 159 } 160 161 headers = tny_simple_list_new ();160 161 headers = tny_simple_list_new (); 162 162 tny_folder_refresh (iface); 163 163 164 164 tny_folder_get_headers (iface, headers, FALSE); 165 165 orig_length = tny_list_get_length (headers); 166 test_len = tny_folder_get_all_count (iface);167 166 test_len = tny_folder_get_all_count (iface); 167 168 168 str = g_strdup_printf ("I received %d headers, the folder tells me it has %d messages\n", orig_length, test_len); 169 169 gunit_fail_unless (orig_length == test_len, str); 170 170 g_free (str); 171 172 iter = tny_list_create_iterator (headers);173 tny_iterator_first (iter);174 header = (TnyHeader*)tny_iterator_get_current (iter);175 176 /* Flag as removed */177 tny_folder_remove_message(iface, header);178 tny_folder_refresh (iface);179 180 g_object_unref (G_OBJECT (headers));181 182 183 new_len = tny_folder_get_all_count (iface);184 str = g_strdup_printf ("After removal but not yet expunge, the new length is %d, whereas it should be %d\n", new_len, orig_length);171 172 iter = tny_list_create_iterator (headers); 173 tny_iterator_first (iter); 174 header = (TnyHeader*)tny_iterator_get_current (iter); 175 176 /* Flag as removed */ 177 tny_folder_remove_msg (iface, header); 178 tny_folder_refresh (iface); 179 180 g_object_unref (G_OBJECT (headers)); 181 182 183 new_len = tny_folder_get_all_count (iface); 184 str = g_strdup_printf ("After removal but not yet expunge, the new length is %d, whereas it should be %d\n", new_len, orig_length); 185 185 gunit_fail_unless (new_len == orig_length, str); 186 186 g_free (str); 187 188 headers = tny_simple_list_new ();189 tny_folder_get_headers (iface, headers, FALSE);187 188 headers = tny_simple_list_new (); 189 tny_folder_get_headers (iface, headers, FALSE); 190 190 headers_len = tny_list_get_length (headers); 191 191 g_object_unref (G_OBJECT (headers)); 192 193 str = g_strdup_printf ("After removal but not yet expunge, the header count is %d, whereas it should be %d\n", headers_len, orig_length);192 193 str = g_strdup_printf ("After removal but not yet expunge, the header count is %d, whereas it should be %d\n", headers_len, orig_length); 194 194 gunit_fail_unless (new_len == orig_length, str); 195 195 g_free (str); 196 197 /* Expunge ...*/198 tny_folder_expunge (iface);199 tny_folder_refresh (iface); 200 201 new_len = tny_folder_get_all_count (iface);202 str = g_strdup_printf ("After removal, the new length is %d, whereas it should be %d\n", new_len, orig_length-1);196 197 /* Expunge ...*/ 198 tny_folder_expunge (iface); 199 tny_folder_refresh (iface); 200 201 new_len = tny_folder_get_all_count (iface); 202 str = g_strdup_printf ("After removal, the new length is %d, whereas it should be %d\n", new_len, orig_length-1); 203 203 gunit_fail_unless (new_len == orig_length-1, str); 204 204 g_free (str); 205 206 headers = tny_simple_list_new ();207 tny_folder_get_headers (iface, headers, FALSE);205 206 headers = tny_simple_list_new (); 207 tny_folder_get_headers (iface, headers, FALSE); 208 208 headers_len = tny_list_get_length (headers); 209 209 g_object_unref (G_OBJECT (headers)); 210 211 str = g_strdup_printf ("After removal, the header count is %d, whereas it should be %d\n", headers_len, orig_length-1);210 211 str = g_strdup_printf ("After removal, the header count is %d, whereas it should be %d\n", headers_len, orig_length-1); 212 212 gunit_fail_unless (new_len == orig_length-1, str); 213 213 g_free (str); 214 214 215 215 } 216 216 trunk/libtinymail/Makefile.am
r994 r1092 20 20 tny-simple-list.h \ 21 21 tny-folder-store.h \ 22 tny-folder-store-query.h 22 tny-folder-store-query.h \ 23 tny-msg-remove-strategy.h 23 24 24 25 libtinymail_1_0_la_SOURCES = \ … … 42 43 tny-simple-list-iterator.c \ 43 44 tny-folder-store.c \ 44 tny-folder-store-query.c 45 tny-folder-store-query.c \ 46 tny-msg-remove-strategy.c 45 47 46 48 libtinymail_1_0_la_LIBADD = $(LIBTINYMAIL_LIBS) trunk/libtinymail/tny-folder.c
r1012 r1092 26 26 guint tny_folder_signals [TNY_FOLDER_LAST_SIGNAL]; 27 27 28 29 /** 30 * tny_folder_get_msg_remove_strategy: 31 * @self: a TnyFolder object 32 * 33 * Get the strategy for removing a message. The return value of this method 34 * must be unreferenced after use. 35 * 36 * Return value: the strategy for removing a message 37 **/ 38 TnyMsgRemoveStrategy* 39 tny_folder_get_msg_remove_strategy (TnyFolder *self) 40 { 41 #ifdef DEBUG 42 if (!TNY_FOLDER_GET_IFACE (self)->get_msg_remove_strategy_func) 43 g_critical ("You must implement tny_folder_get_msg_remove_strategy\n"); 44 #endif 45 return TNY_FOLDER_GET_IFACE (self)->get_msg_remove_strategy_func (self); 46 } 47 48 /** 49 * tny_folder_set_msg_remove_strategy: 50 * @self: a TnyFolder object 51 * @st: a #TnyMsgRemoveStrategy object 52 * 53 * Set the strategy for removing a message 54 * 55 **/ 56 void 57 tny_folder_set_msg_remove_strategy (TnyFolder *self, TnyMsgRemoveStrategy *st) 58 { 59 #ifdef DEBUG 60 if (!TNY_FOLDER_GET_IFACE (self)->set_msg_remove_strategy_func) 61 g_critical ("You must implement tny_folder_set_msg_remove_strategy\n"); 62 #endif 63 TNY_FOLDER_GET_IFACE (self)->set_msg_remove_strategy_func (self, st); 64 return; 65 } 66 28 67 /** 29 68 * tny_folder_expunge: … … 37 76 * TnyHeader *header = ... 38 77 * TnyFolder *folder = tny_header_ge
