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

« back to all changes in this revision

Viewing changes to camel/providers/local/camel-local-summary.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:
142
142
                    gint forceindex,
143
143
                    GError **error)
144
144
{
145
 
        d(g_print ("\nlocal_summary_load called \n"));
 
145
        d (g_print ("\nlocal_summary_load called \n"));
146
146
        return camel_folder_summary_load_from_db ((CamelFolderSummary *) cls, error);
147
147
}
148
148
 
154
154
{
155
155
        CamelLocalSummaryClass *class;
156
156
 
157
 
        d(printf("Loading summary ...\n"));
 
157
        d (printf ("Loading summary ...\n"));
158
158
 
159
159
        class = CAMEL_LOCAL_SUMMARY_GET_CLASS (cls);
160
160
 
161
161
        if ((forceindex && class->need_index ())
162
162
            || !class->load (cls, forceindex, error)) {
163
 
                w(g_warning("Could not load summary: flags may be reset"));
 
163
                w (g_warning ("Could not load summary: flags may be reset"));
164
164
                camel_folder_summary_clear ((CamelFolderSummary *) cls, NULL);
165
165
                return FALSE;
166
166
        }
299
299
                }
300
300
                camel_folder_summary_free_array (known_uids);
301
301
 
302
 
                printf("\nMemory used by summary:\n\n");
303
 
                printf("Total of %d messages\n", camel_folder_summary_count(s));
304
 
                printf("Total: %d bytes (ave %f)\n", stats.citotal + stats.mitotal,
305
 
                       (double)(stats.citotal + stats.mitotal) / (double) camel_folder_summary_count (s));
306
 
                printf("Message Info: %d (ave %f)\n", stats.mitotal, (double)stats.mitotal/(double)stats.micount);
307
 
                printf("Content Info; %d (ave %f) count %d\n", stats.citotal, (double)stats.citotal/(double)stats.cicount, stats.cicount);
308
 
                printf("message id's: %d (ave %f) count %d\n", stats.msgid, (double)stats.msgid/(double)stats.msgcount, stats.msgcount);
 
302
                printf ("\nMemory used by summary:\n\n");
 
303
                printf (
 
304
                        "Total of %d messages\n",
 
305
                        camel_folder_summary_count (s));
 
306
                printf (
 
307
                        "Total: %d bytes (ave %f)\n",
 
308
                        stats.citotal + stats.mitotal,
 
309
                        (gdouble) (stats.citotal + stats.mitotal) /
 
310
                        (gdouble) camel_folder_summary_count (s));
 
311
                printf (
 
312
                        "Message Info: %d (ave %f)\n",
 
313
                        stats.mitotal,
 
314
                        (gdouble) stats.mitotal / (gdouble) stats.micount);
 
315
                printf (
 
316
                        "Content Info; %d (ave %f) count %d\n",
 
317
                        stats.citotal,
 
318
                        (gdouble) stats.citotal / (gdouble) stats.cicount,
 
319
                        stats.cicount);
 
320
                printf (
 
321
                        "message id's: %d (ave %f) count %d\n",
 
322
                        stats.msgid,
 
323
                        (gdouble) stats.msgid / (gdouble) stats.msgcount,
 
324
                        stats.msgcount);
309
325
        }
310
326
#endif
311
327
        return ret;
370
386
        if (newfd == -1)
371
387
                return -1;
372
388
 
373
 
        out = fdopen(newfd, "w");
 
389
        out = fdopen (newfd, "w");
374
390
        if (out == NULL) {
375
391
                close (newfd);
376
392
                errno = EINVAL;
378
394
        }
379
395
 
380
396
        while (header) {
381
 
                if (strcmp(header->name, "X-Evolution") != 0
382
 
                    && (status == NULL || strcmp(header->name, "Status") != 0)
383
 
                    && (xstatus == NULL || strcmp(header->name, "X-Status") != 0)) {
384
 
                        len = fprintf(out, "%s:%s\n", header->name, header->value);
 
397
                if (strcmp (header->name, "X-Evolution") != 0
 
398
                    && (status == NULL || strcmp (header->name, "Status") != 0)
 
399
                    && (xstatus == NULL || strcmp (header->name, "X-Status") != 0)) {
 
400
                        len = fprintf (out, "%s:%s\n", header->name, header->value);
385
401
                        if (len == -1) {
386
402
                                fclose (out);
387
403
                                return -1;
392
408
        }
393
409
 
394
410
        if (status) {
395
 
                len = fprintf(out, "Status: %s\n", status);
 
411
                len = fprintf (out, "Status: %s\n", status);
396
412
                if (len == -1) {
397
413
                        fclose (out);
398
414
                        return -1;
401
417
        }
402
418
 
403
419
        if (xstatus) {
404
 
                len = fprintf(out, "X-Status: %s\n", xstatus);
 
420
                len = fprintf (out, "X-Status: %s\n", xstatus);
405
421
                if (len == -1) {
406
422
                        fclose (out);
407
423
                        return -1;
410
426
        }
411
427
 
412
428
        if (xevline) {
413
 
                len = fprintf(out, "X-Evolution: %s\n", xevline);
 
429
                len = fprintf (out, "X-Evolution: %s\n", xevline);
414
430
                if (len == -1) {
415
431
                        fclose (out);
416
432
                        return -1;
418
434
                outlen += len;
419
435
        }
420
436
 
421
 
        len = fprintf(out, "\n");
 
437
        len = fprintf (out, "\n");
422
438
        if (len == -1) {
423
439
                fclose (out);
424
440
                return -1;
481
497
        CamelLocalMessageInfo *mi;
482
498
        gchar *xev;
483
499
 
484
 
        d(printf("Adding message to summary\n"));
 
500
        d (printf ("Adding message to summary\n"));
485
501
 
486
502
        mi = (CamelLocalMessageInfo *) camel_folder_summary_add_from_message ((CamelFolderSummary *) cls, msg);
487
503
        if (mi) {
517
533
 
518
534
                mi->info.flags &= ~(CAMEL_MESSAGE_FOLDER_NOXEV);
519
535
                xev = camel_local_summary_encode_x_evolution (cls, mi);
520
 
                camel_medium_set_header((CamelMedium *)msg, "X-Evolution", xev);
 
536
                camel_medium_set_header ((CamelMedium *) msg, "X-Evolution", xev);
521
537
                g_free (xev);
522
538
                camel_folder_change_info_add_uid (ci, camel_message_info_uid (mi));
523
539
        } else {
524
 
                d(printf("Failed!\n"));
 
540
                d (printf ("Failed!\n"));
525
541
                g_set_error (
526
542
                        error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
527
543
                        _("Unable to add message to summary: unknown reason"));
533
549
local_summary_encode_x_evolution (CamelLocalSummary *cls,
534
550
                                  const CamelLocalMessageInfo *mi)
535
551
{
536
 
        GString *out = g_string_new("");
 
552
        GString *out = g_string_new ("");
537
553
        struct _camel_header_param *params = NULL;
538
554
        CamelFlag *flag = mi->info.user_flags;
539
555
        CamelTag *tag = mi->info.user_tags;
601
617
 
602
618
        /* check for uid/flags */
603
619
        header = camel_header_token_decode (xev);
604
 
        if (header && strlen(header) == strlen("00000000-0000")
605
 
            && sscanf(header, "%08x-%04x", &uid, &flags) == 2) {
 
620
        if (header && strlen (header) == strlen ("00000000-0000")
 
621
            && sscanf (header, "%08x-%04x", &uid, &flags) == 2) {
606
622
                if (mi)
607
 
                        sprintf(uidstr, "%u", uid);
 
623
                        sprintf (uidstr, "%u", uid);
608
624
        } else {
609
625
                g_free (header);
610
626
                return -1;
620
636
                params = camel_header_param_list_decode (header + 1);
621
637
                scan = params;
622
638
                while (scan) {
623
 
                        if (!g_ascii_strcasecmp(scan->name, "flags")) {
624
 
                                gchar **flagv = g_strsplit(scan->value, ",", 1000);
 
639
                        if (!g_ascii_strcasecmp (scan->name, "flags")) {
 
640
                                gchar **flagv = g_strsplit (scan->value, ",", 1000);
625
641
 
626
642
                                for (i = 0; flagv[i]; i++)
627
643
                                        camel_message_info_set_user_flag ((CamelMessageInfo *) mi, flagv[i], TRUE);
628
644
                                g_strfreev (flagv);
629
 
                        } else if (!g_ascii_strcasecmp(scan->name, "tags")) {
630
 
                                gchar **tagv = g_strsplit(scan->value, ",", 10000);
 
645
                        } else if (!g_ascii_strcasecmp (scan->name, "tags")) {
 
646
                                gchar **tagv = g_strsplit (scan->value, ",", 10000);
631
647
                                gchar *val;
632
648
 
633
649
                                for (i = 0; tagv[i]; i++) {
704
720
                const gchar *xev;
705
721
                gint doindex = FALSE;
706
722
 
707
 
                xev = camel_header_raw_find(&h, "X-Evolution", NULL);
 
723
                xev = camel_header_raw_find (&h, "X-Evolution", NULL);
708
724
                if (xev == NULL || camel_local_summary_decode_x_evolution (cls, xev, mi) == -1) {
709
725
                        /* to indicate it has no xev header */
710
726
                        mi->info.flags |= CAMEL_MESSAGE_FOLDER_FLAGGED | CAMEL_MESSAGE_FOLDER_NOXEV;
720
736
                    && (doindex
721
737
                        || cls->index_force
722
738
                        || !camel_index_has_name (cls->index, camel_message_info_uid (mi)))) {
723
 
                        d(printf("Am indexing message %s\n", camel_message_info_uid(mi)));
 
739
                        d (printf ("Am indexing message %s\n", camel_message_info_uid (mi)));
724
740
                        camel_folder_summary_set_index (s, cls->index);
725
741
                } else {
726
 
                        d(printf("Not indexing message %s\n", camel_message_info_uid(mi)));
 
742
                        d (printf ("Not indexing message %s\n", camel_message_info_uid (mi)));
727
743
                        camel_folder_summary_set_index (s, NULL);
728
744
                }
729
745
        }