~ubuntu-branches/ubuntu/saucy/evolution-data-server/saucy

« back to all changes in this revision

Viewing changes to camel/camel-folder-thread.c

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2012-10-08 12:58:16 UTC
  • mfrom: (181.1.7 quantal)
  • Revision ID: package-import@ubuntu.com-20121008125816-i3n76e8c0m64e7xp
Tags: 3.6.0-0ubuntu2
* Fix LP: #1038047 part 1 - Don't abort in e_source_registry_new* when a
  problem occurs connecting to the Dbus service
  - add debian/patches/dont-abort-in-e_source_registry_new.patch
  - update debian/patches/series
* Fix LP: #1038047 part 2 - libedataserver depends on
  evolution-data-server-common to ensure that the GSettings schemas are
  present
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
container_add_child (CamelFolderThreadNode *node,
49
49
                     CamelFolderThreadNode *child)
50
50
{
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"));
85
85
        while (c->next) {
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);
94
94
                c = c->next;
95
95
        }
96
96
 
97
 
        printf("DAMN, we shouldn't  be here!\n");
 
97
        printf ("DAMN, we shouldn't  be here!\n");
98
98
}
99
99
 
100
100
static void
109
109
                c = lastc->next;
110
110
                prune_empty (thread, &c->child);
111
111
 
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));
 
112
                d (printf (
 
113
                        "checking message %p %p (%08x%08x)\n", c,
 
114
                        c->message,
 
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);
121
123
                                continue;
122
124
                        }
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;
127
129
                                while (child) {
227
229
                c = c->next;
228
230
        }
229
231
 
230
 
        printf("ERROR: removing node %p failed\n", (gpointer) node);
 
232
        printf ("ERROR: removing node %p failed\n", (gpointer) node);
231
233
}
232
234
 
233
235
static void
238
240
        CamelFolderThreadNode *c, *clast, *scan, *container;
239
241
 
240
242
        /* gather subject lines */
241
 
        d(printf("gathering subject lines\n"));
 
243
        d (printf ("gathering subject lines\n"));
242
244
        clast = (CamelFolderThreadNode *) cp;
243
245
        c = clast->next;
244
246
        while (c) {
258
260
        clast = (CamelFolderThreadNode *) cp;
259
261
        while (clast->next) {
260
262
                c = 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);
276
278
                                continue;
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);
285
287
                                continue;
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);
290
292
                                continue;
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);
295
297
                        } else {
296
 
                                d(printf("subjects are common %p and %p\n", c, container));
 
298
                                d (printf ("subjects are common %p and %p\n", c, container));
297
299
 
298
300
                                /* build a phantom node */
299
301
                                remove_node (cp, container, &clast);
335
337
 
336
338
        while (c) {
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);
339
341
                } else {
340
342
                        g_hash_table_insert (info->visited, c, c);
341
343
                }
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);
 
345
                        printf (
 
346
                                "%s %p Subject: %s <%08x%08x>\n",
 
347
                                p, (gpointer) c,
 
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);
345
351
                        count += 1;
346
352
                } else {
347
 
                        printf("%s %p <empty>\n", p, (gpointer) c);
 
353
                        printf ("%s %p <empty>\n", p, (gpointer) c);
348
354
                }
349
355
                if (c->child)
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);
474
480
                        } else if (!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);
478
484
                        }
479
485
                } else {
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);
483
489
                }
488
494
                if (references) {
489
495
                        gint j;
490
496
 
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;
494
500
 
498
504
 
499
505
                                c = g_hash_table_lookup (id_table, &references->references[j]);
500
506
                                if (c == NULL) {
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);
504
510
                                } else
516
522
                }
517
523
        }
518
524
 
519
 
        d(printf("\n\n"));
 
525
        d (printf ("\n\n"));
520
526
        /* build a list of root messages (no parent) */
521
527
        head = NULL;
522
528
        g_hash_table_foreach (id_table, hashloop, &head);
533
539
                group_root_set (thread, &head);
534
540
 
535
541
#if 0
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);
539
545
#endif
540
546
 
541
547
        sort_thread (&head);
578
584
        while (c->next) {
579
585
                c = 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);
584
590
        }
585
591
 
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);
 
598
        printf (
 
599
                "Message threading %d messages took %ld.%03ld seconds\n",
 
600
                summary->len, diff / 1000, diff % 1000);
594
601
#endif
595
602
}
596
603