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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2005-10-10 11:30:56 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20051010113056-rb4vj4kbs8yxft85
Tags: 1.4.1-0ubuntu3
* debian/patches/camel-imap-store.c.patch:
  - Ubuntu 17465: apply patch from
  http://bugzilla.gnome.org/attachment.cgi?id=53234&action=view
  (additional NULL pointer check)

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *  Authors: Michael Zucchi <notzed@ximian.com>
6
6
 *
7
7
 * This program is free software; you can redistribute it and/or
8
 
 * modify it under the terms of version 2 of the GNU General Public
 
8
 * modify it under the terms of version 2 of the GNU Lesser General Public
9
9
 * License as published by the Free Software Foundation.
10
10
 *
11
11
 * This program is distributed in the hope that it will be useful,
13
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
14
 * General Public License for more details.
15
15
 *
16
 
 * You should have received a copy of the GNU General Public
 
16
 * You should have received a copy of the GNU Lesser General Public
17
17
 * License along with this program; if not, write to the
18
18
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
19
 * Boston, MA 02111-1307, USA.
73
73
 
74
74
#define d(x)
75
75
#define io(x)                   /* io debug */
 
76
#define w(x)
76
77
 
77
78
#if 0
78
79
extern int strdup_count, malloc_count, free_count;
225
226
        return type;
226
227
}
227
228
 
 
229
 
228
230
/**
229
231
 * camel_folder_summary_new:
230
 
 * @folder: Parent folder.  It will hold a ref to us, not the other way around.
 
232
 * @folder: parent #CamelFolder object
231
233
 *
232
 
 * Create a new CamelFolderSummary object.
 
234
 * Create a new #CamelFolderSummary object.
233
235
 * 
234
 
 * Return value: A new CamelFolderSummary widget.
 
236
 * Returns a new #CamelFolderSummary object
235
237
 **/
236
238
CamelFolderSummary *
237
239
camel_folder_summary_new (struct _CamelFolder *folder)
243
245
        return new;
244
246
}
245
247
 
 
248
 
246
249
/**
247
250
 * camel_folder_summary_set_filename:
248
 
 * @s: 
249
 
 * @name: 
 
251
 * @summary: a #CamelFolderSummary object
 
252
 * @filename: a filename
250
253
 * 
251
254
 * Set the filename where the summary will be loaded to/saved from.
252
255
 **/
253
 
void camel_folder_summary_set_filename(CamelFolderSummary *s, const char *name)
 
256
void
 
257
camel_folder_summary_set_filename(CamelFolderSummary *s, const char *name)
254
258
{
255
259
        CAMEL_SUMMARY_LOCK(s, summary_lock);
256
260
 
260
264
        CAMEL_SUMMARY_UNLOCK(s, summary_lock);
261
265
}
262
266
 
 
267
 
263
268
/**
264
269
 * camel_folder_summary_set_index:
265
 
 * @s: 
266
 
 * @index: 
 
270
 * @summary: a #CamelFolderSummary object
 
271
 * @index: a #CamelIndex
267
272
 * 
268
 
 * Set the index used to index body content.  If the index is NULL, or
 
273
 * Set the index used to index body content.  If the index is %NULL, or
269
274
 * not set (the default), no indexing of body content will take place.
270
275
 *
271
276
 * Unlike earlier behaviour, build_content need not be set to perform indexing.
272
277
 **/
273
 
void camel_folder_summary_set_index(CamelFolderSummary *s, CamelIndex *index)
 
278
void
 
279
camel_folder_summary_set_index(CamelFolderSummary *s, CamelIndex *index)
274
280
{
275
281
        struct _CamelFolderSummaryPrivate *p = _PRIVATE(s);
276
282
 
282
288
                camel_object_ref((CamelObject *)index);
283
289
}
284
290
 
 
291
 
285
292
/**
286
293
 * camel_folder_summary_set_build_content:
287
 
 * @s: 
288
 
 * @state: 
 
294
 * @summary: a #CamelFolderSummary object
 
295
 * @state: to build or not to build the content
289
296
 * 
290
297
 * Set a flag to tell the summary to build the content info summary
291
 
 * (CamelMessageInfo.content).  The default is not to build content info
292
 
 * summaries.
 
298
 * (#CamelMessageInfo.content).  The default is not to build content
 
299
 * info summaries.
293
300
 **/
294
 
void camel_folder_summary_set_build_content(CamelFolderSummary *s, gboolean state)
 
301
void
 
302
camel_folder_summary_set_build_content(CamelFolderSummary *s, gboolean state)
295
303
{
296
304
        s->build_content = state;
297
305
}
298
306
 
 
307
 
299
308
/**
300
309
 * camel_folder_summary_count:
301
 
 * @s: 
 
310
 * @summary: a #CamelFolderSummary object
302
311
 * 
303
312
 * Get the number of summary items stored in this summary.
304
313
 * 
305
 
 * Return value: The number of items int he summary.
 
314
 * Returns the number of items in the summary
306
315
 **/
307
316
int
308
317
camel_folder_summary_count(CamelFolderSummary *s)
310
319
        return s->messages->len;
311
320
}
312
321
 
 
322
 
313
323
/**
314
324
 * camel_folder_summary_index:
315
 
 * @s: 
316
 
 * @i: 
 
325
 * @summary: a #CamelFolderSummary object
 
326
 * @index: item index
317
327
 * 
318
328
 * Retrieve a summary item by index number.
319
329
 *
320
330
 * A referenced to the summary item is returned, which may be
321
331
 * ref'd or free'd as appropriate.
322
332
 * 
323
 
 * Return value: The summary item, or NULL if the index @i is out
324
 
 * of range.
 
333
 * Returns the summary item, or %NULL if @index is out of range
325
334
 **/
326
335
CamelMessageInfo *
327
336
camel_folder_summary_index(CamelFolderSummary *s, int i)
343
352
        return info;
344
353
}
345
354
 
 
355
 
346
356
/**
347
 
 * camel_folder_summary_index:
348
 
 * @s: 
349
 
 * @i: 
 
357
 * camel_folder_summary_array:
 
358
 * @summary: a #CamelFolderSummary object
350
359
 * 
351
360
 * Obtain a copy of the summary array.  This is done atomically,
352
361
 * so cannot contain empty entries.
353
362
 *
354
 
 * It must be freed using camel_folder_summary_array_free().
 
363
 * It must be freed using #camel_folder_summary_array_free.
 
364
 *
 
365
 * Returns a #GPtrArray of #CamelMessageInfo items
355
366
 **/
356
367
GPtrArray *
357
368
camel_folder_summary_array(CamelFolderSummary *s)
375
386
        return res;
376
387
}
377
388
 
 
389
 
378
390
/**
379
391
 * camel_folder_summary_array_free:
380
 
 * @s: 
381
 
 * @array: 
 
392
 * @summary: a #CamelFolderSummary object
 
393
 * @array: array of #CamelMessageInfo items as returned from #camel_folder_summary_array
382
394
 * 
383
395
 * Free the folder summary array.
384
396
 **/
394
406
        g_ptr_array_free(array, TRUE);
395
407
}
396
408
 
 
409
 
397
410
/**
398
411
 * camel_folder_summary_uid:
399
 
 * @s: 
400
 
 * @uid: 
 
412
 * @summary: a #CamelFolderSummary object
 
413
 * @uid: a uid
401
414
 * 
402
415
 * Retrieve a summary item by uid.
403
416
 *
404
417
 * A referenced to the summary item is returned, which may be
405
418
 * ref'd or free'd as appropriate.
406
419
 * 
407
 
 * Return value: The summary item, or NULL if the uid @uid
408
 
 * is not available.
 
420
 * Returns the summary item, or %NULL if the uid @uid is not available
409
421
 **/
410
422
CamelMessageInfo *
411
423
camel_folder_summary_uid(CamelFolderSummary *s, const char *uid)
426
438
        return info;
427
439
}
428
440
 
 
441
 
429
442
/**
430
443
 * camel_folder_summary_next_uid:
431
 
 * @s: 
 
444
 * @summary: a #CamelFolderSummary object
432
445
 * 
433
446
 * Generate a new unique uid value as an integer.  This
434
447
 * may be used to create a unique sequence of numbers.
435
448
 * 
436
 
 * Return value: The next unique uid value.
 
449
 * Returns the next unique uid value
437
450
 **/
438
 
guint32 camel_folder_summary_next_uid(CamelFolderSummary *s)
 
451
guint32
 
452
camel_folder_summary_next_uid(CamelFolderSummary *s)
439
453
{
440
454
        guint32 uid;
441
455
 
451
465
        return uid;
452
466
}
453
467
 
 
468
 
454
469
/**
455
470
 * camel_folder_summary_set_uid:
456
 
 * @s: 
 
471
 * @summary: a #CamelFolderSummary object
457
472
 * @uid: The next minimum uid to assign.  To avoid clashing
458
473
 * uid's, set this to the uid of a given messages + 1.
459
474
 * 
460
475
 * Set the next minimum uid available.  This can be used to
461
476
 * ensure new uid's do not clash with existing uid's.
462
477
 **/
463
 
void camel_folder_summary_set_uid(CamelFolderSummary *s, guint32 uid)
 
478
void
 
479
camel_folder_summary_set_uid(CamelFolderSummary *s, guint32 uid)
464
480
{
465
481
        /* TODO: sync to disk? */
466
482
        CAMEL_SUMMARY_LOCK(s, summary_lock);
470
486
        CAMEL_SUMMARY_UNLOCK(s, summary_lock);
471
487
}
472
488
 
 
489
 
473
490
/**
474
491
 * camel_folder_summary_next_uid_string:
475
 
 * @s: 
476
 
 * 
 
492
 * @summary: a #CamelFolderSummary object
 
493
 *
477
494
 * Retrieve the next uid, but as a formatted string.
478
 
 * 
479
 
 * Return value: The next uid as an unsigned integer string.
 
495
 *
 
496
 * Returns the next uid as an unsigned integer string.
480
497
 * This string must be freed by the caller.
481
498
 **/
482
499
char *
516
533
        return ci;
517
534
}
518
535
 
 
536
 
 
537
/**
 
538
 * camel_folder_summary_load:
 
539
 * @summary: a #CamelFolderSummary object
 
540
 *
 
541
 * Load the summary from disk.
 
542
 *
 
543
 * Returns %0 on success or %-1 on fail
 
544
 **/
519
545
int
520
546
camel_folder_summary_load(CamelFolderSummary *s)
521
547
{
595
621
        return 0;
596
622
}
597
623
 
 
624
 
598
625
/**
599
626
 * camel_folder_summary_save:
600
 
 * @s: 
 
627
 * @summary: a #CamelFolderSummary object
601
628
 * 
602
629
 * Writes the summary to disk.  The summary is only written if changes
603
630
 * have occured.
604
631
 * 
605
 
 * Return value: Returns -1 on error.
 
632
 * Returns %0 on success or %-1 on fail
606
633
 **/
607
634
int
608
635
camel_folder_summary_save(CamelFolderSummary *s)
685
712
        return -1;
686
713
}
687
714
 
 
715
 
688
716
/**
689
717
 * camel_folder_summary_header_load:
690
 
 * @s: Summary object.
 
718
 * @summary: a #CamelFolderSummary object
691
719
 * 
692
720
 * Only load the header information from the summary,
693
721
 * keep the rest on disk.  This should only be done on
694
722
 * a fresh summary object.
695
723
 * 
696
 
 * Return value: -1 on error.
 
724
 * Returns %0 on success or %-1 on fail
697
725
 **/
698
 
int camel_folder_summary_header_load(CamelFolderSummary *s)
 
726
int
 
727
camel_folder_summary_header_load(CamelFolderSummary *s)
699
728
{
700
729
        FILE *in;
701
730
        int ret;
746
775
        return 1;
747
776
}
748
777
 
 
778
 
749
779
/**
750
780
 * camel_folder_summary_add:
751
 
 * @s: 
752
 
 * @info: 
 
781
 * @summary: a #CamelFolderSummary object
 
782
 * @info: a #CamelMessageInfo
753
783
 * 
754
 
 * Adds a new @info record to the summary.  If @info->uid is NULL, then a new
755
 
 * uid is automatically re-assigned by calling :next_uid_string().
 
784
 * Adds a new @info record to the summary.  If @info->uid is %NULL,
 
785
 * then a new uid is automatically re-assigned by calling
 
786
 * #camel_folder_summary_next_uid_string.
756
787
 *
757
788
 * The @info record should have been generated by calling one of the
758
789
 * info_new_*() functions, as it will be free'd based on the summary
759
790
 * class.  And MUST NOT be allocated directly using malloc.
760
791
 **/
761
 
void camel_folder_summary_add(CamelFolderSummary *s, CamelMessageInfo *info)
 
792
void
 
793
camel_folder_summary_add(CamelFolderSummary *s, CamelMessageInfo *info)
762
794
{
763
795
        if (info == NULL)
764
796
                return;
782
814
        CAMEL_SUMMARY_UNLOCK(s, summary_lock);
783
815
}
784
816
 
 
817
 
785
818
/**
786
819
 * camel_folder_summary_add_from_header:
787
 
 * @s: 
788
 
 * @h: 
 
820
 * @summary: a #CamelFolderSummary object
 
821
 * @headers: rfc822 headers
789
822
 * 
790
 
 * Build a new info record based on a set of headers, and add it to the
791
 
 * summary.
 
823
 * Build a new info record based on a set of headers, and add it to
 
824
 * the summary.
792
825
 *
793
 
 * Note that this function should not be used if build_content_info has
794
 
 * been specified for this summary.
 
826
 * Note that this function should not be used if build_content_info
 
827
 * has been specified for this summary.
795
828
 * 
796
 
 * Return value: The newly added record.
 
829
 * Returns the newly added record
797
830
 **/
798
 
CamelMessageInfo *camel_folder_summary_add_from_header(CamelFolderSummary *s, struct _camel_header_raw *h)
 
831
CamelMessageInfo *
 
832
camel_folder_summary_add_from_header(CamelFolderSummary *s, struct _camel_header_raw *h)
799
833
{
800
834
        CamelMessageInfo *info = camel_folder_summary_info_new_from_header(s, h);
801
835
 
804
838
        return info;
805
839
}
806
840
 
 
841
 
807
842
/**
808
843
 * camel_folder_summary_add_from_parser:
809
 
 * @s: 
810
 
 * @mp: 
 
844
 * @summary: a #CamelFolderSummary object
 
845
 * @parser: a #CamelMimeParser object
811
846
 * 
812
 
 * Build a new info record based on the current position of a CamelMimeParser.
 
847
 * Build a new info record based on the current position of a #CamelMimeParser.
813
848
 *
814
849
 * The parser should be positioned before the start of the message to summarise.
815
850
 * This function may be used if build_contnet_info or an index has been
816
851
 * specified for the summary.
817
852
 * 
818
 
 * Return value: The newly added record.
 
853
 * Returns the newly added record
819
854
 **/
820
 
CamelMessageInfo *camel_folder_summary_add_from_parser(CamelFolderSummary *s, CamelMimeParser *mp)
 
855
CamelMessageInfo *
 
856
camel_folder_summary_add_from_parser(CamelFolderSummary *s, CamelMimeParser *mp)
821
857
{
822
858
        CamelMessageInfo *info = camel_folder_summary_info_new_from_parser(s, mp);
823
859
 
826
862
        return info;
827
863
}
828
864
 
 
865
 
829
866
/**
830
867
 * camel_folder_summary_add_from_message:
831
 
 * @s: 
832
 
 * @msg: 
 
868
 * @summary: a #CamelFolderSummary object
 
869
 * @message: a #CamelMimeMessage object
833
870
 * 
834
871
 * Add a summary item from an existing message.
835
872
 * 
836
 
 * Return value: 
 
873
 * Returns the newly added record
837
874
 **/
838
 
CamelMessageInfo *camel_folder_summary_add_from_message(CamelFolderSummary *s, CamelMimeMessage *msg)
 
875
CamelMessageInfo *
 
876
camel_folder_summary_add_from_message(CamelFolderSummary *s, CamelMimeMessage *msg)
839
877
{
840
878
        CamelMessageInfo *info = camel_folder_summary_info_new_from_message(s, msg);
841
879
 
844
882
        return info;
845
883
}
846
884
 
 
885
 
847
886
/**
848
887
 * camel_folder_summary_info_new_from_header:
849
 
 * @s: 
850
 
 * @h: 
 
888
 * @summary: a #CamelFolderSummary object
 
889
 * @headers: rfc822 headers
851
890
 * 
852
891
 * Create a new info record from a header.
853
 
 * 
854
 
 * Return value: Guess?  Free using camel_message_info_free().
 
892
 *
 
893
 * Returns the newly allocated record which must be freed with
 
894
 * #camel_message_info_free
855
895
 **/
856
 
CamelMessageInfo *camel_folder_summary_info_new_from_header(CamelFolderSummary *s, struct _camel_header_raw *h)
 
896
CamelMessageInfo *
 
897
camel_folder_summary_info_new_from_header(CamelFolderSummary *s, struct _camel_header_raw *h)
857
898
{
858
 
        return ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s))) -> message_info_new_from_header(s, h);
 
899
        return ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->message_info_new_from_header(s, h);
859
900
}
860
901
 
 
902
 
861
903
/**
862
904
 * camel_folder_summary_info_new_from_parser:
863
 
 * @s: 
864
 
 * @mp: 
 
905
 * @summary: a #CamelFolderSummary object
 
906
 * @parser: a #CamelMimeParser object
865
907
 * 
866
908
 * Create a new info record from a parser.  If the parser cannot
867
909
 * determine a uid, then none will be assigned.
868
 
 
 
910
 *
869
911
 * If indexing is enabled, and the parser cannot determine a new uid, then
870
912
 * one is automatically assigned.
871
913
 *
876
918
 * Once complete, the parser will be positioned at the end of
877
919
 * the message.
878
920
 *
879
 
 * Return value: Guess?
 
921
 * Returns the newly allocated record which must be freed with
 
922
 * #camel_message_info_free
880
923
 **/
881
 
CamelMessageInfo *camel_folder_summary_info_new_from_parser(CamelFolderSummary *s, CamelMimeParser *mp)
 
924
CamelMessageInfo *
 
925
camel_folder_summary_info_new_from_parser(CamelFolderSummary *s, CamelMimeParser *mp)
882
926
{
883
927
        CamelMessageInfo *info = NULL;
884
928
        char *buffer;
926
970
        return info;
927
971
}
928
972
 
 
973
 
929
974
/**
930
975
 * camel_folder_summary_info_new_from_message:
931
 
 * @: 
932
 
 * @: 
 
976
 * @summary: a #CamelFodlerSummary object
 
977
 * @message: a #CamelMimeMessage object
933
978
 * 
934
979
 * Create a summary item from a message.
935
980
 * 
936
 
 * Return value: 
 
981
 * Returns the newly allocated record which must be freed using
 
982
 * #camel_message_info_free
937
983
 **/
938
 
CamelMessageInfo *camel_folder_summary_info_new_from_message(CamelFolderSummary *s, CamelMimeMessage *msg)
 
984
CamelMessageInfo *
 
985
camel_folder_summary_info_new_from_message(CamelFolderSummary *s, CamelMimeMessage *msg)
939
986
{
940
987
        CamelMessageInfo *info;
941
988
        struct _CamelFolderSummaryPrivate *p = _PRIVATE(s);
978
1025
        return info;
979
1026
}
980
1027
 
 
1028
 
981
1029
/**
982
1030
 * camel_folder_summary_content_info_free:
983
 
 * @s: 
984
 
 * @ci: 
 
1031
 * @summary: a #CamelFolderSummary object
 
1032
 * @ci: a #CamelMessageContentInfo
985
1033
 * 
986
1034
 * Free the content info @ci, and all associated memory.
987
1035
 **/
999
1047
        }
1000
1048
}
1001
1049
 
 
1050
 
1002
1051
/**
1003
1052
 * camel_folder_summary_touch:
1004
 
 * @s: 
 
1053
 * @summary: a #CamelFolderSummary object
1005
1054
 * 
1006
 
 * Mark the summary as changed, so that a save will save it.
 
1055
 * Mark the summary as changed, so that a save will force it to be
 
1056
 * written back to disk.
1007
1057
 **/
1008
1058
void
1009
1059
camel_folder_summary_touch(CamelFolderSummary *s)
1013
1063
        CAMEL_SUMMARY_UNLOCK(s, summary_lock);
1014
1064
}
1015
1065
 
 
1066
 
1016
1067
/**
1017
1068
 * camel_folder_summary_clear:
1018
 
 * @s: 
 
1069
 * @summary: a #CamelFolderSummary object
1019
1070
 * 
1020
1071
 * Empty the summary contents.
1021
1072
 **/
1040
1091
        CAMEL_SUMMARY_UNLOCK(s, summary_lock);
1041
1092
}
1042
1093
 
 
1094
 
1043
1095
/**
1044
1096
 * camel_folder_summary_remove:
1045
 
 * @s: 
1046
 
 * @info: 
 
1097
 * @summary: a #CamelFolderSummary object
 
1098
 * @info: a #CamelMessageInfo
1047
1099
 * 
1048
1100
 * Remove a specific @info record from the summary.
1049
1101
 **/
1050
 
void camel_folder_summary_remove(CamelFolderSummary *s, CamelMessageInfo *info)
 
1102
void
 
1103
camel_folder_summary_remove(CamelFolderSummary *s, CamelMessageInfo *info)
1051
1104
{
1052
1105
        CAMEL_SUMMARY_LOCK(s, summary_lock);
1053
1106
        g_hash_table_remove(s->messages_uid, camel_message_info_uid(info));
1058
1111
        camel_message_info_free(info);
1059
1112
}
1060
1113
 
 
1114
 
1061
1115
/**
1062
1116
 * camel_folder_summary_remove_uid:
1063
 
 * @s: 
1064
 
 * @uid: 
 
1117
 * @summary: a #CamelFolderSummary object
 
1118
 * @uid: a uid
1065
1119
 * 
1066
1120
 * Remove a specific info record from the summary, by @uid.
1067
1121
 **/
1068
 
void camel_folder_summary_remove_uid(CamelFolderSummary *s, const char *uid)
 
1122
void
 
1123
camel_folder_summary_remove_uid(CamelFolderSummary *s, const char *uid)
1069
1124
{
1070
1125
        CamelMessageInfo *oldinfo;
1071
1126
        char *olduid;
1085
1140
        }
1086
1141
}
1087
1142
 
 
1143
 
1088
1144
/**
1089
1145
 * camel_folder_summary_remove_index:
1090
 
 * @s: 
1091
 
 * @index: 
 
1146
 * @summary: a #CamelFolderSummary object
 
1147
 * @index: record index
1092
1148
 * 
1093
1149
 * Remove a specific info record from the summary, by index.
1094
1150
 **/
1095
 
void camel_folder_summary_remove_index(CamelFolderSummary *s, int index)
 
1151
void
 
1152
camel_folder_summary_remove_index(CamelFolderSummary *s, int index)
1096
1153
{
1097
1154
        CAMEL_SUMMARY_LOCK(s, summary_lock);
1098
1155
        if (index < s->messages->len) {
1109
1166
        }
1110
1167
}
1111
1168
 
 
1169
 
1112
1170
/**
1113
1171
 * camel_folder_summary_remove_range:
1114
 
 * @s: 
 
1172
 * @summary: a #CamelFolderSummary object
1115
1173
 * @start: initial index
1116
1174
 * @end: last index to remove
1117
1175
 * 
1118
1176
 * Removes an indexed range of info records.
1119
1177
 **/
1120
 
void camel_folder_summary_remove_range(CamelFolderSummary *s, int start, int end)
 
1178
void
 
1179
camel_folder_summary_remove_range(CamelFolderSummary *s, int start, int end)
1121
1180
{
1122
1181
        if (end < start)
1123
1182
                return;
1202
1261
 
1203
1262
/**
1204
1263
 * camel_folder_summary_encode_token:
1205
 
 * @out: 
1206
 
 * @str: 
 
1264
 * @out: output FILE pointer
 
1265
 * @str: string token to encode
1207
1266
 * 
1208
1267
 * Encode a string value, but use tokenisation and compression
1209
1268
 * to reduce the size taken for common mailer words.  This
1210
1269
 * can still be used to encode normal strings as well.
1211
1270
 * 
1212
 
 * Return value: -1 on error.
 
1271
 * Returns %0 on success or %-1 on fail
1213
1272
 **/
1214
1273
int
1215
1274
camel_folder_summary_encode_token(FILE *out, const char *str)
1254
1313
        return 0;
1255
1314
}
1256
1315
 
 
1316
 
1257
1317
/**
1258
1318
 * camel_folder_summary_decode_token:
1259
 
 * @in: 
1260
 
 * @str: 
 
1319
 * @in: input FILE pointer
 
1320
 * @str: string pointer to hold the decoded result
1261
1321
 * 
1262
1322
 * Decode a token value.
1263
1323
 * 
1264
 
 * Return value: -1 on error.
 
1324
 * Returns %0 on success or %-1 on fail
1265
1325
 **/
1266
1326
int
1267
1327
camel_folder_summary_decode_token(FILE *in, char **str)
1414
1474
}
1415
1475
 
1416
1476
/* are these even useful for anything??? */
1417
 
static CamelMessageInfo * message_info_new_from_parser(CamelFolderSummary *s, CamelMimeParser *mp)
 
1477
static CamelMessageInfo *
 
1478
message_info_new_from_parser(CamelFolderSummary *s, CamelMimeParser *mp)
1418
1479
{
1419
1480
        CamelMessageInfo *mi = NULL;
1420
1481
        int state;
1433
1494
        return mi;
1434
1495
}
1435
1496
 
1436
 
static CamelMessageContentInfo * content_info_new_from_parser(CamelFolderSummary *s, CamelMimeParser *mp)
 
1497
static CamelMessageContentInfo *
 
1498
content_info_new_from_parser(CamelFolderSummary *s, CamelMimeParser *mp)
1437
1499
{
1438
1500
        CamelMessageContentInfo *ci = NULL;
1439
1501
 
1454
1516
        return ci;
1455
1517
}
1456
1518
 
1457
 
static CamelMessageInfo * message_info_new_from_message(CamelFolderSummary *s, CamelMimeMessage *msg)
 
1519
static CamelMessageInfo *
 
1520
message_info_new_from_message(CamelFolderSummary *s, CamelMimeMessage *msg)
1458
1521
{
1459
1522
        CamelMessageInfo *mi;
1460
1523
 
1463
1526
        return mi;
1464
1527
}
1465
1528
 
1466
 
static CamelMessageContentInfo * content_info_new_from_message(CamelFolderSummary *s, CamelMimePart *mp)
 
1529
static CamelMessageContentInfo *
 
1530
content_info_new_from_message(CamelFolderSummary *s, CamelMimePart *mp)
1467
1531
{
1468
1532
        CamelMessageContentInfo *ci;
1469
1533
 
1506
1570
        }
1507
1571
}
1508
1572
 
 
1573
 
1509
1574
/**
1510
1575
 * camel_folder_summary_content_info_new:
1511
 
 * @s: 
 
1576
 * @summary: a #CamelFolderSummary object
1512
1577
 * 
1513
 
 * Allocate a new camel message content info, suitable for adding
 
1578
 * Allocate a new #CamelMessageContentInfo, suitable for adding
1514
1579
 * to this summary.
1515
1580
 * 
1516
 
 * Return value: 
 
1581
 * Returns a newly allocated #CamelMessageContentInfo
1517
1582
 **/
1518
1583
CamelMessageContentInfo *
1519
1584
camel_folder_summary_content_info_new(CamelFolderSummary *s)
1630
1695
        CamelMessageInfoBase *mi;
1631
1696
        guint count;
1632
1697
        int i;
1633
 
        char *subject, *from, *to, *cc, *mlist, *uid;;
 
1698
        char *subject, *from, *to, *cc, *mlist, *uid;
1634
1699
 
1635
1700
        mi = (CamelMessageInfoBase *)camel_message_info_new(s);
1636
1701
 
1992
2057
                                if (mfc) {
1993
2058
                                        chr_id = camel_mime_parser_filter_add(mp, (CamelMimeFilter *)mfc);
1994
2059
                                } else {
1995
 
                                        g_warning("Cannot convert '%s' to 'UTF-8', message index may be corrupt", charset);
 
2060
                                        w(g_warning("Cannot convert '%s' to 'UTF-8', message index may be corrupt", charset));
1996
2061
                                }
1997
2062
                        }
1998
2063
 
2144
2209
 
2145
2210
/**
2146
2211
 * camel_flag_get:
2147
 
 * @list: 
2148
 
 * @name: 
 
2212
 * @list: the address of a #CamelFlag list
 
2213
 * @name: name of the flag to get
2149
2214
 * 
2150
2215
 * Find the state of the flag @name in @list.
2151
2216
 * 
2152
 
 * Return value: The state of the flag (TRUE or FALSE).
 
2217
 * Returns the state of the flag (%TRUE or %FALSE)
2153
2218
 **/
2154
2219
gboolean
2155
2220
camel_flag_get(CamelFlag **list, const char *name)
2164
2229
        return FALSE;
2165
2230
}
2166
2231
 
 
2232
 
2167
2233
/**
2168
2234
 * camel_flag_set:
2169
 
 * @list: 
2170
 
 * @name: 
2171
 
 * @value: 
 
2235
 * @list: the address of a #CamelFlag list
 
2236
 * @name: name of the flag to set or change
 
2237
 * @value: the value to set on the flag
2172
2238
 * 
2173
2239
 * Set the state of a flag @name in the list @list to @value.
2174
2240
 *
2175
 
 * Return value: Whether or not it changed.
 
2241
 * Returns %TRUE if the value of the flag has been changed or %FALSE
 
2242
 * otherwise
2176
2243
 **/
2177
2244
gboolean
2178
2245
camel_flag_set(CamelFlag **list, const char *name, gboolean value)
2202
2269
        return value;
2203
2270
}
2204
2271
 
 
2272
 
2205
2273
/**
2206
2274
 * camel_flag_list_size:
2207
 
 * @list: 
 
2275
 * @list: the address of a #CamelFlag list
2208
2276
 * 
2209
2277
 * Get the length of the flag list.
2210
2278
 * 
2211
 
 * Return value: The number of TRUE flags in the list.
 
2279
 * Returns the number of flags in the list
2212
2280
 **/
2213
2281
int
2214
2282
camel_flag_list_size(CamelFlag **list)
2224
2292
        return count;
2225
2293
}
2226
2294
 
 
2295
 
2227
2296
/**
2228
2297
 * camel_flag_list_free:
2229
 
 * @list: 
 
2298
 * @list: the address of a #CamelFlag list
2230
2299
 * 
2231
2300
 * Free the memory associated with the flag list @list.
2232
2301
 **/
2243
2312
        *list = NULL;
2244
2313
}
2245
2314
 
 
2315
 
2246
2316
/**
2247
2317
 * camel_flag_list_copy:
2248
 
 * @to: 
2249
 
 * @from: 
2250
 
 * 
2251
 
 * Copy a flag list, return true if the destination list @to changed.
2252
 
 * 
2253
 
 * Return value: 
 
2318
 * @to: the address of the #CamelFlag list to copy to
 
2319
 * @from: the address of the #CamelFlag list to copy from
 
2320
 * 
 
2321
 * Copy a flag list.
 
2322
 * 
 
2323
 * Returns %TRUE if @to is changed or %FALSE otherwise
2254
2324
 **/
2255
2325
gboolean
2256
2326
camel_flag_list_copy(CamelFlag **to, CamelFlag **from)
2284
2354
        return changed;
2285
2355
}
2286
2356
 
 
2357
 
 
2358
/**
 
2359
 * camel_tag_get:
 
2360
 * @list: the address of a #CamelTag list
 
2361
 * @name: name of the tag to get
 
2362
 *
 
2363
 * Find the flag @name in @list and get the value.
 
2364
 * 
 
2365
 * Returns the value of the flag  or %NULL if unset
 
2366
 **/
2287
2367
const char *
2288
2368
camel_tag_get(CamelTag **list, const char *name)
2289
2369
{
2298
2378
        return NULL;
2299
2379
}
2300
2380
 
 
2381
 
2301
2382
/**
2302
2383
 * camel_tag_set:
2303
 
 * @list: 
2304
 
 * @name: 
2305
 
 * @value: 
 
2384
 * @list: the address of a #CamelTag list
 
2385
 * @name: name of the tag to set
 
2386
 * @value: value to set on the tag
2306
2387
 * 
2307
2388
 * Set the tag @name in the tag list @list to @value.
2308
2389
 *
2309
 
 * Return value: whether or not it changed
 
2390
 * Returns %TRUE if the value on the tag changed or %FALSE otherwise
2310
2391
 **/
2311
2392
gboolean
2312
2393
camel_tag_set(CamelTag **list, const char *name, const char *value)
2344
2425
        return FALSE;
2345
2426
}
2346
2427
 
 
2428
 
2347
2429
/**
2348
2430
 * camel_tag_list_size:
2349
 
 * @list: 
 
2431
 * @list: the address of a #CamelTag list
2350
2432
 * 
2351
2433
 * Get the number of tags present in the tag list @list.
2352
2434
 * 
2353
 
 * Return value: The number of tags.
 
2435
 * Returns the number of tags
2354
2436
 **/
2355
 
int             camel_tag_list_size(CamelTag **list)
 
2437
int
 
2438
camel_tag_list_size(CamelTag **list)
2356
2439
{
2357
2440
        int count=0;
2358
2441
        CamelTag *tag;
2371
2454
        camel_tag_set(to, key, NULL);
2372
2455
}
2373
2456
 
 
2457
 
2374
2458
/**
2375
2459
 * camel_tag_list_copy:
2376
 
 * @to: 
2377
 
 * @from: 
2378
 
 * 
2379
 
 * Copy a list of tags.
2380
 
 * 
2381
 
 * Return value: 
 
2460
 * @to: the address of the #CamelTag list to copy to
 
2461
 * @from: the address of the #CamelTag list to copy from
 
2462
 * 
 
2463
 * Copy a tag list.
 
2464
 * 
 
2465
 * Returns %TRUE if @to is changed or %FALSE otherwise
2382
2466
 **/
2383
2467
gboolean
2384
2468
camel_tag_list_copy(CamelTag **to, CamelTag **from)
2413
2497
        return changed;
2414
2498
}
2415
2499
 
 
2500
 
2416
2501
/**
2417
2502
 * camel_tag_list_free:
2418
 
 * @list: 
 
2503
 * @list: the address of a #CamelTag list
2419
2504
 * 
2420
2505
 * Free the tag list @list.
2421
2506
 **/
2422
 
void            camel_tag_list_free(CamelTag **list)
 
2507
void
 
2508
camel_tag_list_free(CamelTag **list)
2423
2509
{
2424
2510
        CamelTag *tag, *tmp;
2425
2511
        tag = *list;
2447
2533
        { NULL, 0 }
2448
2534
};
2449
2535
 
 
2536
 
2450
2537
/**
2451
2538
 * camel_system_flag:
2452
 
 * @name: 
 
2539
 * @name: name of a system flag
2453
2540
 * 
2454
 
 * Returns the integer value of the flag string.
 
2541
 * Returns the integer value of the system flag string
2455
2542
 **/
2456
2543
guint32
2457
2544
camel_system_flag (const char *name)
2467
2554
        return 0;
2468
2555
}
2469
2556
 
 
2557
 
2470
2558
/**
2471
2559
 * camel_system_flag_get:
2472
 
 * @flags: 
2473
 
 * @name: 
 
2560
 * @flags: bitwise system flags
 
2561
 * @name: name of the flag to check for
2474
2562
 * 
2475
2563
 * Find the state of the flag @name in @flags.
2476
2564
 * 
2477
 
 * Return value: The state of the flag (TRUE or FALSE).
 
2565
 * Returns %TRUE if the named flag is set or %FALSE otherwise
2478
2566
 **/
2479
2567
gboolean
2480
2568
camel_system_flag_get (guint32 flags, const char *name)
2487
2575
 
2488
2576
/**
2489
2577
 * camel_message_info_new:
2490
 
 *
2491
 
 * Returns a new CamelMessageInfo structure.
 
2578
 * @summary: a #CamelFolderSummary object or %NULL
 
2579
 *
 
2580
 * Create a new #CamelMessageInfo.
 
2581
 *
 
2582
 * Returns a new #CamelMessageInfo
2492
2583
 **/
2493
2584
void *
2494
2585
camel_message_info_new (CamelFolderSummary *s)
2511
2602
        return info;
2512
2603
}
2513
2604
 
 
2605
 
2514
2606
/**
2515
2607
 * camel_message_info_ref:
2516
 
 * @info: 
 
2608
 * @info: a #CamelMessageInfo
2517
2609
 * 
2518
2610
 * Reference an info.
2519
2611
 **/
2520
 
void camel_message_info_ref(void *o)
 
2612
void
 
2613
camel_message_info_ref(void *o)
2521
2614
{
2522
2615
        CamelMessageInfo *mi = o;
2523
2616
 
2534
2627
        }
2535
2628
}
2536
2629
 
 
2630
 
2537
2631
/**
2538
2632
 * camel_message_info_new_from_header:
 
2633
 * @summary: a #CamelFolderSummary object or %NULL
2539
2634
 * @header: raw header
2540
2635
 *
2541
 
 * Returns a new CamelMessageInfo structure populated by the header.
 
2636
 * Create a new #CamelMessageInfo pre-populated with info from
 
2637
 * @header.
 
2638
 *
 
2639
 * Returns a new #CamelMessageInfo
2542
2640
 **/
2543
2641
CamelMessageInfo *
2544
2642
camel_message_info_new_from_header(CamelFolderSummary *s, struct _camel_header_raw *header)
2549
2647
                return message_info_new_from_header(NULL, header);
2550
2648
}
2551
2649
 
 
2650
 
2552
2651
/**
2553
2652
 * camel_message_info_free:
2554
 
 * @mi: the message info
2555
 
 *
2556
 
 * Unref's and potentially frees a CamelMessageInfo and its contents.
2557
 
 *
 
2653
 * @info: a #CamelMessageInfo
 
2654
 *
 
2655
 * Unref's and potentially frees a #CamelMessageInfo and its contents.
2558
2656
 **/
2559
2657
void
2560
2658
camel_message_info_free(void *o)
2645
2743
        return (CamelMessageInfo *)to;
2646
2744
}
2647
2745
 
 
2746
 
 
2747
/**
 
2748
 * camel_message_info_clone:
 
2749
 * @info: a #CamelMessageInfo
 
2750
 *
 
2751
 * Duplicate a #CamelMessageInfo.
 
2752
 *
 
2753
 * Returns the duplicated #CamelMessageInfo
 
2754
 **/
2648
2755
void *
2649
2756
camel_message_info_clone(const void *o)
2650
2757
{
2721
2828
        return camel_tag_get(&((CamelMessageInfoBase *)mi)->user_tags, id);
2722
2829
}
2723
2830
 
 
2831
 
 
2832
/**
 
2833
 * camel_message_info_ptr:
 
2834
 * @mi: a #CamelMessageInfo
 
2835
 * @id: info to get
 
2836
 *
 
2837
 * Generic accessor method for getting pointer data.
 
2838
 *
 
2839
 * Returns the pointer data
 
2840
 **/
2724
2841
const void *
2725
2842
camel_message_info_ptr(const CamelMessageInfo *mi, int id)
2726
2843
{
2730
2847
                return info_ptr(mi, id);
2731
2848
}
2732
2849
 
2733
 
guint32 camel_message_info_uint32(const CamelMessageInfo *mi, int id)
 
2850
 
 
2851
/**
 
2852
 * camel_message_info_uint32:
 
2853
 * @mi: a #CamelMessageInfo
 
2854
 * @id: info to get
 
2855
 *
 
2856
 * Generic accessor method for getting 32bit int data.
 
2857
 *
 
2858
 * Returns the int data
 
2859
 **/
 
2860
guint32
 
2861
camel_message_info_uint32(const CamelMessageInfo *mi, int id)
2734
2862
{
2735
2863
        if (mi->summary)
2736
2864
                return ((CamelFolderSummaryClass *)((CamelObject *)mi->summary)->klass)->info_uint32(mi, id);
2738
2866
                return info_uint32(mi, id);
2739
2867
}
2740
2868
 
2741
 
time_t camel_message_info_time(const CamelMessageInfo *mi, int id)
 
2869
 
 
2870
/**
 
2871
 * camel_message_info_time:
 
2872
 * @mi: a #CamelMessageInfo
 
2873
 * @id: info to get
 
2874
 *
 
2875
 * Generic accessor method for getting time_t data.
 
2876
 *
 
2877
 * Returns the time_t data
 
2878
 **/
 
2879
time_t
 
2880
camel_message_info_time(const CamelMessageInfo *mi, int id)
2742
2881
{
2743
2882
        if (mi->summary)
2744
2883
                return ((CamelFolderSummaryClass *)((CamelObject *)mi->summary)->klass)->info_time(mi, id);
2746
2885
                return info_time(mi, id);
2747
2886
}
2748
2887
 
2749
 
gboolean camel_message_info_user_flag(const CamelMessageInfo *mi, const char *id)
 
2888
 
 
2889
/**
 
2890
 * camel_message_info_user_flag:
 
2891
 * @mi: a #CamelMessageInfo
 
2892
 * @id: user flag to get
 
2893
 *
 
2894
 * Get the state of a user flag named @id.
 
2895
 *
 
2896
 * Returns the state of the user flag
 
2897
 **/
 
2898
gboolean
 
2899
camel_message_info_user_flag(const CamelMessageInfo *mi, const char *id)
2750
2900
{
2751
2901
        if (mi->summary)
2752
2902
                return ((CamelFolderSummaryClass *)((CamelObject *)mi->summary)->klass)->info_user_flag(mi, id);
2754
2904
                return info_user_flag(mi, id);
2755
2905
}
2756
2906
 
2757
 
const char *camel_message_info_user_tag(const CamelMessageInfo *mi, const char *id)
 
2907
 
 
2908
/**
 
2909
 * camel_message_info_user_tag:
 
2910
 * @mi: a #CamelMessageInfo
 
2911
 * @id: user tag to get
 
2912
 *
 
2913
 * Get the value of a user tag named @id.
 
2914
 *
 
2915
 * Returns the value of the user tag
 
2916
 **/
 
2917
const char *
 
2918
camel_message_info_user_tag(const CamelMessageInfo *mi, const char *id)
2758
2919
{
2759
2920
        if (mi->summary)
2760
2921
                return ((CamelFolderSummaryClass *)((CamelObject *)mi->summary)->klass)->info_user_tag(mi, id);
2792
2953
        return TRUE;
2793
2954
}
2794
2955
 
2795
 
gboolean camel_message_info_set_flags(CamelMessageInfo *mi, guint32 flags, guint32 set)
 
2956
 
 
2957
/**
 
2958
 * camel_message_info_set_flags:
 
2959
 * @mi: a #CamelMessageInfo
 
2960
 * @flags: mask of flags to change
 
2961
 * @set: state the flags should be changed to
 
2962
 *
 
2963
 * Change the state of the system flags on the #CamelMessageInfo
 
2964
 *
 
2965
 * Returns %TRUE if any of the flags changed or %FALSE otherwise
 
2966
 **/
 
2967
gboolean
 
2968
camel_message_info_set_flags(CamelMessageInfo *mi, guint32 flags, guint32 set)
2796
2969
{
2797
2970
        if (mi->summary)
2798
2971
                return ((CamelFolderSummaryClass *)((CamelObject *)mi->summary)->klass)->info_set_flags(mi, flags, set);
2822
2995
        return res;
2823
2996
}
2824
2997
 
2825
 
gboolean camel_message_info_set_user_flag(CamelMessageInfo *mi, const char *id, gboolean state)
 
2998
 
 
2999
/**
 
3000
 * camel_message_info_set_user_flag:
 
3001
 * @mi: a #CamelMessageInfo
 
3002
 * @id: name of the user flag to set
 
3003
 * @state: state to set the flag to
 
3004
 *
 
3005
 * Set the state of a user flag on a #CamelMessageInfo.
 
3006
 *
 
3007
 * Returns %TRUE if the state changed or %FALSE otherwise
 
3008
 **/
 
3009
gboolean
 
3010
camel_message_info_set_user_flag(CamelMessageInfo *mi, const char *id, gboolean state)
2826
3011
{
2827
3012
        if (mi->summary)
2828
3013
                return ((CamelFolderSummaryClass *)((CamelObject *)mi->summary)->klass)->info_set_user_flag(mi, id, state);
2851
3036
        return res;
2852
3037
}
2853
3038
 
2854
 
gboolean camel_message_info_set_user_tag(CamelMessageInfo *mi, const char *id, const char *val)
 
3039
 
 
3040
/**
 
3041
 * camel_message_info_set_user_tag:
 
3042
 * @mi: a #CamelMessageInfo
 
3043
 * @id: name of the user tag to set
 
3044
 * @val: value to set
 
3045
 *
 
3046
 * Set the value of a user tag on a #CamelMessageInfo.
 
3047
 *
 
3048
 * Returns %TRUE if the value changed or %FALSE otherwise
 
3049
 **/
 
3050
gboolean
 
3051
camel_message_info_set_user_tag(CamelMessageInfo *mi, const char *id, const char *val)
2855
3052
{
2856
3053
        if (mi->summary)
2857
3054
                return ((CamelFolderSummaryClass *)((CamelObject *)mi->summary)->klass)->info_set_user_tag(mi, id, val);