Changeset 2215
- Timestamp:
- 06/19/07 10:31:36
- Files:
-
- trunk/ChangeLog (modified) (1 diff)
- trunk/libtinymail-camel/camel-lite/camel/camel-file-utils.c (modified) (1 diff)
- trunk/libtinymail-camel/camel-lite/camel/camel-file-utils.h (modified) (2 diffs)
- trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c (modified) (1 diff)
- trunk/libtinymail-camel/camel-lite/camel/providers/local/camel-maildir-store.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r2214 r2215 1 2007-06-19 Philip Van Hoof <pvanhoof@gnome.org> 2 3 * Fixed reading the unread and total counts from Maildir folders 4 1 5 2007-06-19 Dirk-Jan C. Binnema <dirk-jan.binnema@nokia.com> 2 6 trunk/libtinymail-camel/camel-lite/camel/camel-file-utils.c
r2191 r2215 71 71 } 72 72 73 void 74 camel_file_util_read_counts (const gchar *spath, CamelFolderInfo *fi) 75 { 76 /* This code reads the beginning of the summary.mmap file for 77 * the length and unread-count of the folder. It makes it 78 * possible to read the total and unread values of the 79 * CamelFolderInfo structure without having to read the entire 80 * folder in (mmap it) 81 * It's called by get_folder_info_offline and therefore also by 82 * get_folder_info_online for each node in the tree. */ 83 84 FILE *f = fopen (spath, "r"); 85 if (f) { 86 87 gint tsize = ((sizeof (guint32) * 5) + sizeof (time_t)); 88 char *buffer = malloc (tsize), *ptr; 89 guint32 version, a; 90 a = fread (buffer, 1, tsize, f); 91 if (a == tsize) 92 { 93 ptr = buffer; 94 version = g_ntohl(get_unaligned_u32(ptr)); 95 ptr += 16; 96 if (fi->total == -1) 97 fi->total = g_ntohl(get_unaligned_u32(ptr)); 98 ptr += 4; 99 if (fi->unread == -1 && (version < 0x100 && version >= 13)) 100 fi->unread = g_ntohl(get_unaligned_u32(ptr)); 101 } 102 g_free (buffer); 103 fclose (f); 104 } 105 } 73 106 74 107 /** trunk/libtinymail-camel/camel-lite/camel/camel-file-utils.h
r2191 r2215 33 33 #include <time.h> 34 34 #include <fcntl.h> 35 36 #include <camel/camel-store.h> 35 37 36 38 #ifndef O_BINARY … … 94 96 95 97 char *camel_file_util_savename(const char *filename); 98 void camel_file_util_read_counts (const gchar *spath, CamelFolderInfo *fi); 96 99 97 100 #define get_unaligned_u32(p) ((((unsigned char*)(p))[0]) | \ trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c
r2195 r2215 3294 3294 3295 3295 } else if ((fi->unread == -1) || (fi->total == -1)) { 3296 3297 3298 /* This code reads the beginning of the summary.mmap file for3299 * the length and unread-count of the folder. It makes it3300 * possible to read the total and unread values of the3301 * CamelFolderInfo structure without having to read the entire3302 * folder in (mmap it)3303 * It's called by get_folder_info_offline and therefore also by3304 * get_folder_info_online for each node in the tree. */3305 3306 3296 gchar *spath = g_strdup_printf ("%s/summary.mmap", folder_dir); 3307 FILE *f = fopen (spath, "r");3297 camel_file_util_read_counts (spath, fi); 3308 3298 g_free (spath); 3309 3310 if (f) {3311 3312 gint tsize = ((sizeof (guint32) * 5) + sizeof (time_t));3313 char *buffer = malloc (tsize), *ptr;3314 guint32 version, a;3315 a = fread (buffer, 1, tsize, f);3316 if (a == tsize)3317 {3318 ptr = buffer;3319 version = g_ntohl(get_unaligned_u32(ptr));3320 ptr += 16;3321 if (fi->total == -1)3322 fi->total = g_ntohl(get_unaligned_u32(ptr));3323 ptr += 4;3324 if (fi->unread == -1 && (version < 0x100 && version >= 13))3325 fi->unread = g_ntohl(get_unaligned_u32(ptr));3326 }3327 g_free (buffer);3328 fclose (f);3329 }3330 3299 } 3331 3300 trunk/libtinymail-camel/camel-lite/camel/providers/local/camel-maildir-store.c
r2180 r2215 41 41 #include "camel-maildir-summary.h" 42 42 #include "camel-string-utils.h" 43 #include "camel-file-utils.h" 43 44 44 45 #define d(x) … … 320 321 camel_object_unref(folder); 321 322 } else { 322 CamelFolderSummary *s; 323 /* This should be fast enough not to have to test for INFO_FAST */ 324 s = (CamelFolderSummary *)camel_maildir_summary_new(NULL, path, folderpath, NULL); 325 if (camel_folder_summary_header_load(s) != -1) { 326 fi->unread = s->unread_count; 327 fi->total = s->saved_count; 328 } else { 329 printf ("summary header\n"); 330 } 331 camel_object_unref(s); 332 323 camel_file_util_read_counts (path, fi); 333 324 } 334 325
