48
48
container_add_child (CamelFolderThreadNode *node,
49
49
CamelFolderThreadNode *child)
51
d(printf("\nAdding child %p to parent %p \n", child, node));
51
d (printf ("\nAdding child %p to parent %p \n", child, node));
52
52
child->next = node->child;
53
53
node->child = child;
54
54
child->parent = node;
81
81
/* else remove child from its existing parent, and reparent */
82
82
node = child->parent;
83
83
c = (CamelFolderThreadNode *) &node->child;
84
d(printf("scanning children:\n"));
84
d (printf ("scanning children:\n"));
86
d(printf(" %p\n", c));
86
d (printf (" %p\n", c));
87
87
if (c->next == child) {
88
d(printf("found node %p\n", child));
88
d (printf ("found node %p\n", child));
89
89
c->next = c->next->next;
90
90
child->parent = NULL;
91
91
container_add_child (parent, child);
110
110
prune_empty (thread, &c->child);
112
d(printf("checking message %p %p (%08x%08x)\n", c,
113
c->message, c->message ? c->message->message_id.id.part.hi : 0,
114
c->message ? c->message->message_id.id.part.lo : 0));
113
"checking message %p %p (%08x%08x)\n", c,
115
c->message ? c->message->message_id.id.part.hi : 0,
116
c->message ? c->message->message_id.id.part.lo : 0));
115
117
if (c->message == NULL) {
116
118
if (c->child == NULL) {
117
d(printf("removing empty node\n"));
119
d (printf ("removing empty node\n"));
118
120
lastc->next = c->next;
119
121
m (memset (c, 0xfe, sizeof (*c)));
120
122
camel_memchunk_free (thread->node_chunks, c);
123
125
if (c->parent || c->child->next == NULL) {
124
d(printf("promoting child\n"));
126
d (printf ("promoting child\n"));
125
127
lastc->next = c->next; /* remove us */
126
128
child = c->child;
238
240
CamelFolderThreadNode *c, *clast, *scan, *container;
240
242
/* gather subject lines */
241
d(printf("gathering subject lines\n"));
243
d (printf ("gathering subject lines\n"));
242
244
clast = (CamelFolderThreadNode *) cp;
258
260
clast = (CamelFolderThreadNode *) cp;
259
261
while (clast->next) {
261
d(printf("checking %p %s\n", c, c->root_subject));
263
d (printf ("checking %p %s\n", c, c->root_subject));
262
264
if (c->root_subject
263
265
&& (container = g_hash_table_lookup (subject_table, c->root_subject))
264
266
&& (container != c)) {
265
d(printf(" matching %p %s\n", container, container->root_subject));
267
d (printf (" matching %p %s\n", container, container->root_subject));
266
268
if (c->message == NULL && container->message == NULL) {
267
d(printf("merge containers children\n"));
269
d (printf ("merge containers children\n"));
268
270
/* steal the children from c onto container, and unlink c */
269
271
scan = (CamelFolderThreadNode *) &container->child;
270
272
while (scan->next)
275
277
camel_memchunk_free (thread->node_chunks, c);
277
279
} if (c->message == NULL && container->message != NULL) {
278
d(printf("container is non-empty parent\n"));
280
d (printf ("container is non-empty parent\n"));
279
281
remove_node (cp, container, &clast);
280
282
container_add_child (c, container);
281
283
} else if (c->message != NULL && container->message == NULL) {
282
d(printf("container is empty child\n"));
284
d (printf ("container is empty child\n"));
283
285
clast->next = c->next;
284
286
container_add_child (container, c);
286
288
} else if (c->re && !container->re) {
287
d(printf("container is re\n"));
289
d (printf ("container is re\n"));
288
290
clast->next = c->next;
289
291
container_add_child (container, c);
291
293
} else if (!c->re && container->re) {
292
d(printf("container is not re\n"));
294
d (printf ("container is not re\n"));
293
295
remove_node (cp, container, &clast);
294
296
container_add_child (c, container);
296
d(printf("subjects are common %p and %p\n", c, container));
298
d (printf ("subjects are common %p and %p\n", c, container));
298
300
/* build a phantom node */
299
301
remove_node (cp, container, &clast);
337
339
if (g_hash_table_lookup (info->visited, c)) {
338
printf("WARNING: NODE REVISITED: %p\n", (gpointer) c);
340
printf ("WARNING: NODE REVISITED: %p\n", (gpointer) c);
340
342
g_hash_table_insert (info->visited, c, c);
342
344
if (c->message) {
343
printf("%s %p Subject: %s <%08x%08x>\n", p, (gpointer) c, camel_message_info_subject(c->message),
344
camel_message_info_message_id (c->message)->id.part.hi, camel_message_info_message_id (c->message)->id.part.lo);
346
"%s %p Subject: %s <%08x%08x>\n",
348
camel_message_info_subject (c->message),
349
camel_message_info_message_id (c->message)->id.part.hi,
350
camel_message_info_message_id (c->message)->id.part.lo);
347
printf("%s %p <empty>\n", p, (gpointer) c);
353
printf ("%s %p <empty>\n", p, (gpointer) c);
350
356
count += dump_tree_rec (info, c->child, depth + 1);
468
474
if (c && c->order) {
469
475
/* if duplicate, just make out it is a no-id message, but try and insert it
470
476
* into the right spot in the tree */
471
d(printf("doing: (duplicate message id)\n"));
477
d (printf ("doing: (duplicate message id)\n"));
472
478
c = camel_memchunk_alloc0 (thread->node_chunks);
473
479
g_hash_table_insert (no_id_table, (gpointer) mi, c);
475
d(printf("doing : %08x%08x (%s)\n", mid->id.part.hi, mid->id.part.lo, camel_message_info_subject(mi)));
481
d (printf ("doing : %08x%08x (%s)\n", mid->id.part.hi, mid->id.part.lo, camel_message_info_subject (mi)));
476
482
c = camel_memchunk_alloc0 (thread->node_chunks);
477
483
g_hash_table_insert (id_table, (gpointer) mid, c);
480
d(printf("doing : (no message id)\n"));
486
d (printf ("doing : (no message id)\n"));
481
487
c = camel_memchunk_alloc0 (thread->node_chunks);
482
488
g_hash_table_insert (no_id_table, (gpointer) mi, c);
488
494
if (references) {
491
d(printf("%s (%s) references:\n", G_STRLOC, G_STRFUNC); )
497
d (printf ("%s (%s) references:\n", G_STRLOC, G_STRFUNC); )
492
498
for (j = 0; j < references->size; j++) {
493
499
gboolean found = FALSE;
499
505
c = g_hash_table_lookup (id_table, &references->references[j]);
501
d(printf("%s (%s) not found\n", G_STRLOC, G_STRFUNC));
507
d (printf ("%s (%s) not found\n", G_STRLOC, G_STRFUNC));
502
508
c = camel_memchunk_alloc0 (thread->node_chunks);
503
509
g_hash_table_insert (id_table, (gpointer) &references->references[j], c);
533
539
group_root_set (thread, &head);
536
printf("finished\n");
542
printf ("finished\n");
537
543
i = camel_folder_threaded_messages_dump (head);
538
printf("%d count, %d items in tree\n", summary->len, i);
544
printf ("%d count, %d items in tree\n", summary->len, i);
541
547
sort_thread (&head);
578
584
while (c->next) {
580
586
if (c->message == NULL)
581
g_warning("threading missed removing a pseudo node: %s\n", c->root_subject);
587
g_warning ("threading missed removing a pseudo node: %s\n", c->root_subject);
582
588
if (c->parent != NULL)
583
g_warning("base node has a non-null parent: %s\n", c->root_subject);
589
g_warning ("base node has a non-null parent: %s\n", c->root_subject);
586
592
thread->tree = head;
589
595
gettimeofday (&end, NULL);
590
596
diff = end.tv_sec * 1000 + end.tv_usec / 1000;
591
597
diff -= start.tv_sec * 1000 + start.tv_usec / 1000;
592
printf("Message threading %d messages took %ld.%03ld seconds\n",
593
summary->len, diff / 1000, diff % 1000);
599
"Message threading %d messages took %ld.%03ld seconds\n",
600
summary->len, diff / 1000, diff % 1000);