Fix bug #3574: Template addressing
[claws.git] / src / addrharvest.c
blob6d4bf3b6597b9f0714a5594a8de5d9c55cea6e75
1 /*
2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2002-2012 Match Grun and the Claws Mail team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * Functions for an E-Mail address harvester.
24 #include <sys/stat.h>
25 #include <dirent.h>
26 #include <glib.h>
27 #include <string.h>
29 #include "proctypes.h"
30 #include "utils.h"
31 #include "mgutils.h"
32 #include "addrharvest.h"
33 #include "codeconv.h"
34 #include "addritem.h"
35 #ifdef USE_ALT_ADDRBOOK
36 #include "addressbook-dbus.h"
37 #endif
39 /* Mail header names of interest */
40 static gchar *_headerFrom_ = HEADER_FROM;
41 static gchar *_headerReplyTo_ = HEADER_REPLY_TO;
42 static gchar *_headerSender_ = HEADER_SENDER;
43 static gchar *_headerErrorsTo_ = HEADER_ERRORS_TO;
44 static gchar *_headerCC_ = HEADER_CC;
45 static gchar *_headerTo_ = HEADER_TO;
47 #define ADDR_BUFFSIZE 1024
48 #define MSG_BUFFSIZE 2048
49 #define MSGNUM_BUFFSIZE 32
50 #define DFL_FOLDER_SIZE 20
52 /* Noise strings included by some other E-Mail clients */
53 #define REM_NAME_STRING "(Email)"
54 #define REM_NAME_STRING2 "(Email 2)"
56 /* Directories to ignore */
57 #define DIR_IGNORE ".\t..\t.sylpheed_mark\t.sylpheed_claws_cache"
60 * Header entry.
62 struct _HeaderEntry {
63 gchar *header;
64 gboolean selected;
65 ItemFolder *folder;
66 gint count;
69 #ifdef USE_ALT_ADDRBOOK
70 typedef enum {
71 FIRST = 0,
72 LAST,
73 } Namepart;
75 #endif
78 * Build header table entry.
79 * Enter: harvester Harvester object.
80 * name Header name.
82 static void addrharvest_build_entry(
83 AddressHarvester* harvester, gchar *name )
85 HeaderEntry *entry;
87 entry = g_new0( HeaderEntry, 1 );
88 entry->header = name;
89 entry->selected = FALSE;
90 entry->folder = NULL;
91 entry->count = 0;
92 harvester->headerTable = g_list_append( harvester->headerTable, entry );
96 * Free key in table.
98 static gint addrharvest_free_table_vis( gpointer key, gpointer value, gpointer data ) {
99 g_free( key );
100 key = NULL;
101 value = NULL;
102 return TRUE;
106 * Free lookup table.
108 static void addrharvest_free_table( AddressHarvester* harvester ) {
109 GList *node;
110 HeaderEntry *entry;
112 /* Free header list */
113 node = harvester->headerTable;
114 while( node ) {
115 entry = ( HeaderEntry * ) node->data;
116 entry->header = NULL;
117 entry->selected = FALSE;
118 entry->folder = NULL;
119 entry->count = 0;
120 g_free( entry );
121 node = g_list_next( node );
123 g_list_free( harvester->headerTable );
124 harvester->headerTable = NULL;
126 /* Free duplicate table */
127 g_hash_table_foreach_remove( harvester->dupTable, addrharvest_free_table_vis, NULL );
128 g_hash_table_destroy( harvester->dupTable );
129 harvester->dupTable = NULL;
133 * Create new object.
134 * Return: Harvester.
136 AddressHarvester *addrharvest_create( void ) {
137 AddressHarvester *harvester;
139 harvester = g_new0( AddressHarvester, 1 );
140 harvester->path = NULL;
141 harvester->dupTable = g_hash_table_new( g_str_hash, g_str_equal );
142 harvester->folderSize = DFL_FOLDER_SIZE;
143 harvester->retVal = MGU_SUCCESS;
145 /* Build header table */
146 harvester->headerTable = NULL;
147 addrharvest_build_entry( harvester, _headerFrom_ );
148 addrharvest_build_entry( harvester, _headerReplyTo_ );
149 addrharvest_build_entry( harvester, _headerSender_ );
150 addrharvest_build_entry( harvester, _headerErrorsTo_ );
151 addrharvest_build_entry( harvester, _headerCC_ );
152 addrharvest_build_entry( harvester, _headerTo_ );
154 return harvester;
158 * Properties...
161 * Specify path to folder that will be harvested.
162 * Entry: harvester Harvester object.
163 * value Full directory path.
165 void addrharvest_set_path( AddressHarvester* harvester, const gchar *value ) {
166 cm_return_if_fail( harvester != NULL );
167 harvester->path = mgu_replace_string( harvester->path, value );
168 g_strstrip( harvester->path );
172 * Specify maximum folder size.
173 * Entry: harvester Harvester object.
174 * value Folder size.
176 void addrharvest_set_folder_size(
177 AddressHarvester* harvester, const gint value )
179 cm_return_if_fail( harvester != NULL );
180 if( value > 0 ) {
181 harvester->folderSize = value;
186 * Specify folder recursion.
187 * Entry: harvester Harvester object.
188 * value TRUE to process sub-folders, FALSE to process folder only.
190 void addrharvest_set_recurse(
191 AddressHarvester* harvester, const gboolean value )
193 cm_return_if_fail( harvester != NULL );
194 harvester->folderRecurse = value;
198 * Search (case insensitive) for header entry with specified name.
199 * Enter: harvester Harvester.
200 * name Header name.
201 * Return: Header, or NULL if not found.
203 static HeaderEntry *addrharvest_find(
204 AddressHarvester* harvester, const gchar *name ) {
205 HeaderEntry *retVal;
206 GList *node;
208 retVal = NULL;
209 node = harvester->headerTable;
210 while( node ) {
211 HeaderEntry *entry;
213 entry = node->data;
214 if (g_ascii_strncasecmp(entry->header, name,
215 strlen(entry->header)) == 0 ) {
216 retVal = entry;
217 break;
219 node = g_list_next( node );
221 return retVal;
225 * Set selection for specified heaader.
226 * Enter: harvester Harvester.
227 * name Header name.
228 * value Value to set.
230 void addrharvest_set_header(
231 AddressHarvester* harvester, const gchar *name, const gboolean value )
233 HeaderEntry *entry;
235 cm_return_if_fail( harvester != NULL );
236 entry = addrharvest_find( harvester, name );
237 if( entry != NULL ) {
238 entry->selected = value;
243 * Get address count
244 * Enter: harvester Harvester.
245 * name Header name.
246 * Return: Address count, or -1 if header not found.
248 gint addrharvest_get_count( AddressHarvester* harvester, const gchar *name ) {
249 HeaderEntry *entry;
250 gint count;
252 count = -1;
253 cm_return_val_if_fail( harvester != NULL, count );
254 entry = addrharvest_find( harvester, name );
255 if( entry != NULL ) {
256 count = entry->count;
258 return count;
262 * Free up object by releasing internal memory.
263 * Enter: harvester Harvester.
265 void addrharvest_free( AddressHarvester *harvester ) {
266 cm_return_if_fail( harvester != NULL );
268 /* Free internal stuff */
269 addrharvest_free_table( harvester );
270 g_free( harvester->path );
272 /* Clear pointers */
273 harvester->path = NULL;
274 harvester->retVal = MGU_SUCCESS;
275 harvester->headerTable = NULL;
277 harvester->folderSize = 0;
279 /* Now release object */
280 g_free( harvester );
283 #ifdef USE_ALT_ADDRBOOK
284 static gchar* get_namepart(const gchar* name, Namepart namepart) {
285 gchar *pos, *part = NULL;
286 gchar *token = g_strdup(name);
288 pos = g_strrstr(token, " ");
289 if (namepart == FIRST) {
290 if (pos) {
291 *pos = '\0';
292 part = g_strdup(token);
293 *pos = ' ';
296 else {
297 if (! pos)
298 part = g_strdup(token);
299 else {
300 pos +=1;
301 part = g_strdup(pos);
304 g_free(token);
305 return part;
307 #endif
310 * Insert address into cache.
311 * Enter: harvester Harvester object.
312 * entry Header object.
313 * cache Address cache to load.
314 * name Name.
315 * address eMail address.
317 static void addrharvest_insert_cache(
318 AddressHarvester *harvester, HeaderEntry *entry,
319 AddressCache *cache, const gchar *name,
320 const gchar *address )
322 #ifndef USE_ALT_ADDRBOOK
323 ItemPerson *person;
324 ItemFolder *folder;
325 gchar *folderName;
326 gboolean newFolder;
327 gint cnt;
328 gchar *key, *value;
330 newFolder = FALSE;
331 folder = entry->folder;
332 if( folder == NULL ) {
333 newFolder = TRUE; /* No folder yet */
335 if( entry->count % harvester->folderSize == 0 ) {
336 newFolder = TRUE; /* Folder is full */
338 #else
339 ContactEntry* person;
340 gchar* key;
341 #endif
343 /* Insert address */
344 key = g_utf8_strdown( address, -1 );
345 person = g_hash_table_lookup( harvester->dupTable, key );
346 #ifndef USE_ALT_ADDRBOOK
347 if( person ) {
348 /* Update existing person to use longest name */
349 value = ADDRITEM_NAME(person);
350 if( strlen( name ) > strlen( value ) ) {
351 addritem_person_set_common_name( person, name );
353 g_free( key );
355 else {
356 /* Folder if required */
357 if( newFolder ) {
358 cnt = 1 + ( entry->count / harvester->folderSize );
359 folderName =g_strdup_printf( "%s (%d)",
360 entry->header, cnt );
361 folder = addritem_create_item_folder();
362 addritem_folder_set_name( folder, folderName );
363 addritem_folder_set_remarks( folder, "" );
364 addrcache_id_folder( cache, folder );
365 addrcache_add_folder( cache, folder );
366 entry->folder = folder;
367 g_free( folderName );
370 /* Insert entry */
371 person = addrcache_add_contact(
372 cache, folder, name, address, "" );
373 g_hash_table_insert( harvester->dupTable, key, person );
374 entry->count++;
376 addritem_parse_first_last( person );
377 #else
378 if (! person) {
379 person = g_new0(ContactEntry, 1);
380 person->first_name = get_namepart(name, FIRST);
381 person->last_name = get_namepart(name, LAST);
382 person->email = g_strdup(address);
383 g_hash_table_insert(harvester->dupTable, key, person);
384 entry->count++;
386 #endif
390 * Remove specified string from name.
391 * Enter: name Name.
392 * str String to remove.
394 static void addrharvest_del_email( gchar *name, gchar *str ) {
395 gchar *p;
396 gint lenn, lenr;
398 lenr = strlen( str );
399 while((p = strcasestr( name, str )) != NULL) {
400 lenn = strlen( p );
401 memmove( p, p + lenr, lenn );
406 * Find position of at (@) character in buffer.
407 * Enter: buffer Start of buffer.
408 * Return: Position of at character, or NULL if not found.
409 * Note: This function searches for the last occurrence of an 'at' character
410 * prior to a valid delimiter character for the end of address. This enables
411 * an address to be found where it is also used as the name of the
412 * recipient. For example:
413 * "axle.rose@netscape.com" <axle.rose@netscape.com>
414 * The last occurrence of the at character is detected.
416 static gchar *addrharvest_find_at( const gchar *buffer ) {
417 gchar *atCh;
418 gchar *p;
420 atCh = strchr( buffer, '@' );
421 if( atCh ) {
422 /* Search forward for another one */
423 p = atCh + 1;
424 while( *p ) {
425 if( *p == '>' ) {
426 break;
428 if( *p == ',' ) {
429 break;
431 if( *p == '\n' ) {
432 break;
434 if( *p == '@' ) {
435 atCh = p;
436 break;
438 p++;
441 return atCh;
445 * Find start and end of address string.
446 * Enter: buf Start address of buffer to process (not modified).
447 * atp Pointer to email at (@) character.
448 * bp Pointer to start of email address (returned).
449 * ep Pointer to end of email address (returned).
451 static void addrharvest_find_address(
452 const gchar *buf, const gchar *atp, const gchar **bp,
453 const gchar **ep )
455 const gchar *p;
457 /* Find first non-separator char */
458 *bp = NULL;
459 p = buf;
460 while( TRUE ) {
461 if( strchr( ",; \n\r", *p ) == NULL ) break;
462 p++;
464 *bp = p;
466 /* Search forward for end of address */
467 *ep = NULL;
468 p = atp + 1;
469 while( TRUE ) {
470 if( strchr( ",;", *p ) ) break;
471 p++;
473 *ep = p;
477 * Extract E-Mail address from buffer. If found, address is removed from
478 * buffer.
479 * Enter: buffer Address buffer.
480 * Return: E-Mail address, or NULL if none found. Must g_free() when done.
482 static gchar *addrharvest_extract_address( gchar *buffer ) {
483 gchar *addr;
484 gchar *atCh, *p, *bp, *ep;
485 gint len;
487 addr = NULL;
488 atCh = addrharvest_find_at( buffer );
489 if( atCh ) {
490 /* Search back for start of address */
491 bp = NULL;
492 p = atCh;
493 while( p >= buffer ) {
494 bp = p;
495 if( *p == '<' ) {
496 *p = ' ';
497 bp++;
498 break;
500 p--;
503 /* Search fwd for end */
504 ep = NULL;
505 ep = p = atCh;
506 while( *p ) {
507 if( *p == '>' ) {
508 *p = ' ';
509 break;
511 else if( *p == ' ' ) {
512 break;
514 ep = p;
515 p++;
518 /* Extract email */
519 if( bp != NULL ) {
520 len = ( ep - bp );
521 if( len > 0 ) {
522 addr = g_strndup( bp, len + 1 );
523 memmove( bp, ep, len );
524 *bp = ' ';
528 return addr;
532 * Parse address from header buffer creating address in cache.
533 * Enter: harvester Harvester object.
534 * entry Header object.
535 * cache Address cache to load.
536 * hdrBuf Pointer to header buffer.
538 static void addrharvest_parse_address(
539 AddressHarvester *harvester, HeaderEntry *entry,
540 AddressCache *cache, const gchar *hdrBuf )
542 gchar buffer[ ADDR_BUFFSIZE + 2 ];
543 const gchar *bp;
544 const gchar *ep;
545 gchar *atCh, *email, *name;
546 gint bufLen;
548 /* Search for an address */
549 while((atCh = addrharvest_find_at( hdrBuf )) != NULL) {
550 /* Find addres string */
551 addrharvest_find_address( hdrBuf, atCh, &bp, &ep );
553 /* Copy into buffer */
554 bufLen = ( size_t ) ( ep - bp );
555 if( bufLen > ADDR_BUFFSIZE -1 ) {
556 bufLen = ADDR_BUFFSIZE - 1;
558 strncpy( buffer, bp, bufLen );
559 buffer[ bufLen ] = '\0';
560 buffer[ bufLen + 1 ] = '\0';
561 buffer[ bufLen + 2 ] = '\0';
563 /* Extract address from buffer */
564 email = addrharvest_extract_address( buffer );
565 if( email ) {
566 /* Unescape characters */
567 mgu_str_unescape( buffer );
569 /* Remove noise characaters */
570 addrharvest_del_email( buffer, REM_NAME_STRING );
571 addrharvest_del_email( buffer, REM_NAME_STRING2 );
573 /* Remove leading trailing quotes and spaces */
574 mgu_str_ltc2space( buffer, '\"', '\"' );
575 mgu_str_ltc2space( buffer, '\'', '\'' );
576 mgu_str_ltc2space( buffer, '\"', '\"' );
577 mgu_str_ltc2space( buffer, '(', ')' );
578 g_strstrip( buffer );
580 if( g_ascii_strcasecmp( buffer, email ) == 0 )
581 name = g_strdup("");
582 else
583 name = conv_unmime_header(buffer, NULL, TRUE);
585 /* Insert into address book */
586 #ifndef USE_ALT_ADDRBOOK
587 addrharvest_insert_cache(
588 harvester, entry, cache, name, email );
589 #else
590 addrharvest_insert_cache(
591 harvester, entry, NULL, name, email);
592 #endif
593 g_free( email );
594 g_free( name );
596 hdrBuf = ep;
601 * Test whether buffer contains a header that appears in header list.
602 * Enter: listHdr Header list.
603 * buf Header buffer.
604 * Return: TRUE if header in list.
606 static gboolean addrharvest_check_hdr( GList *listHdr, gchar *buf ) {
607 gboolean retVal;
608 GList *node;
609 gchar *p, *hdr, *nhdr;
610 gint len;
612 retVal = FALSE;
613 p = strchr( buf, ':' );
614 if( p ) {
615 len = ( size_t ) ( p - buf );
616 hdr = g_strndup( buf, len );
617 node = listHdr;
618 while( node ) {
619 nhdr = node->data;
620 if (g_ascii_strncasecmp(nhdr, hdr, strlen(nhdr)) == 0 ) {
621 retVal = TRUE;
622 break;
624 node = g_list_next( node );
626 g_free( hdr );
628 return retVal;
632 * Read header into a linked list of lines.
633 * Enter: fp File to read.
634 * listHdr List of header lines of interest.
635 * done End of headers or end of file reached.
636 * Return: Linked list of lines.
638 static GSList *addrharvest_get_header( FILE *fp, GList *listHdr, gboolean *done ) {
639 GSList *list;
640 gchar buf[ MSG_BUFFSIZE + 2 ];
641 gint ch;
642 gboolean foundHdr;
644 list = NULL;
646 /* Read line */
647 if( fgets( buf, MSG_BUFFSIZE, fp ) == NULL ) {
648 *done = TRUE;
649 return list;
652 /* Test for end of headers */
653 if( buf[0] == '\r' || buf[0] == '\n' ) {
654 *done = TRUE;
655 return list;
658 /* Test whether required header */
659 foundHdr = addrharvest_check_hdr( listHdr, buf );
661 /* Read all header lines. Only add reqd ones to list */
662 while( TRUE ) {
663 gchar *p;
665 if( foundHdr ) {
666 p = g_strdup( buf );
667 list = g_slist_append( list, p );
670 /* Read first character */
671 ch = fgetc( fp );
672 if( ch == ' ' || ch == '\t' ) {
673 /* Continuation character - read into buffer */
674 if( fgets( buf, MSG_BUFFSIZE, fp ) == NULL ) {
675 break;
678 else {
679 if( ch == EOF ) {
680 *done = TRUE;
682 else {
683 /* Push back character for next header */
684 ungetc( ch, fp );
686 break;
690 return list;
694 * Read specified file into address book.
695 * Enter: harvester Harvester object.
696 * fileName File to read.
697 * cache Address cache to load.
698 * Return: Status.
700 static gint addrharvest_readfile(
701 AddressHarvester *harvester, const gchar *fileName,
702 AddressCache *cache, GList *listHdr )
704 gint retVal;
705 FILE *msgFile;
706 gchar *buf, *addr, *p;
707 HeaderEntry *entry;
708 GSList *list;
709 gboolean done;
711 msgFile = g_fopen( fileName, "rb" );
712 if( ! msgFile ) {
713 /* Cannot open file */
714 retVal = MGU_OPEN_FILE;
715 return retVal;
718 done = FALSE;
719 while( TRUE ) {
720 list = addrharvest_get_header( msgFile, listHdr, &done );
721 if( done ) break;
723 if( list == NULL ) {
724 continue;
727 buf = mgu_list_coalesce( list );
728 mgu_free_list( list );
730 if(( p = strchr( buf, ':' ) ) != NULL ) {
731 addr = p + 1;
732 *p = '\0';
734 entry = addrharvest_find( harvester, buf );
735 if( entry && entry->selected ) {
736 /* Sanitize control characters */
737 p = addr;
738 while( *p ) {
739 if( *p == '\r' || *p == '\n' || *p == '\t' )
740 *p = ' ';
741 p++;
743 addrharvest_parse_address(
744 harvester, entry, cache, addr );
747 g_free( buf );
750 fclose( msgFile );
751 return MGU_SUCCESS;
755 * Read all files in specified directory into address book. Directories are
756 * traversed recursively if necessary.
757 * Enter: harvester Harvester object.
758 * cache Address cache to load.
759 * msgList List of message numbers, or NULL to process folder.
760 * dir Directory to process.
762 static void addrharvest_harvest_dir(
763 AddressHarvester *harvester, AddressCache *cache, GList *listHdr,
764 gchar *dir )
766 GDir *dp;
767 const gchar *d;
768 gchar *fullname;
769 GError *error = NULL;
770 gint num;
772 debug_print("Harvesting addresses from dir '%s'\n", dir);
774 if( ( dp = g_dir_open( dir, 0, &error ) ) == NULL ) {
775 debug_print("opening '%s' failed: %d (%s)\n", dir,
776 error->code, error->message);
777 g_error_free(error);
778 return;
781 /* Process directory */
782 while( (d = g_dir_read_name( dp )) != NULL ) {
783 fullname = g_strconcat(dir, G_DIR_SEPARATOR_S, d, NULL);
784 if( g_file_test(fullname, G_FILE_TEST_IS_DIR) ) {
785 if( harvester->folderRecurse ) {
786 if( strstr( DIR_IGNORE, d ) != NULL ) {
787 g_free(fullname);
788 continue;
791 addrharvest_harvest_dir(
792 harvester, cache, listHdr, (gchar *)fullname );
795 if( g_file_test(fullname, G_FILE_TEST_IS_REGULAR) ) {
796 if( ( num = to_number( d ) ) >= 0 ) {
797 addrharvest_readfile(
798 harvester, fullname, cache, listHdr );
801 g_free(fullname);
803 g_dir_close( dp );
807 * Read list of files in specified directory into address book.
808 * Enter: harvester Harvester object.
809 * cache Address cache to load.
810 * msgList List of message numbers, or NULL to process folder.
812 static void addrharvest_harvest_list(
813 AddressHarvester *harvester, AddressCache *cache, GList *listHdr,
814 GList *msgList )
816 gint num;
817 GList *node;
818 gchar *fullname;
820 if (!g_file_test(harvester->path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
821 debug_print("'%s' doesn't exist or is not a dir\n", harvester->path);
822 return;
825 /* Process message list */
826 node = msgList;
827 while( node ) {
828 num = GPOINTER_TO_UINT( node->data );
829 fullname = g_strdup_printf("%s%c%d",
830 harvester->path, G_DIR_SEPARATOR, num);
831 addrharvest_readfile( harvester, fullname, cache, listHdr );
832 g_free(fullname);
833 node = g_list_next( node );
838 * ============================================================================
839 * Read all files in specified directory into address book.
840 * Enter: harvester Harvester object.
841 * cache Address cache to load.
842 * msgList List of message numbers, or NULL to process folder.
843 * Return: Status.
844 * ============================================================================
846 gint addrharvest_harvest(
847 AddressHarvester *harvester, AddressCache *cache, GList *msgList )
849 gint retVal;
850 GList *node;
851 GList *listHdr;
853 retVal = MGU_BAD_ARGS;
854 cm_return_val_if_fail( harvester != NULL, retVal );
855 #ifndef USE_ALT_ADDRBOOK
856 cm_return_val_if_fail( cache != NULL, retVal );
857 #endif
858 cm_return_val_if_fail( harvester->path != NULL, retVal );
860 #ifndef USE_ALT_ADDRBOOK
861 /* Clear cache */
862 addrcache_clear( cache );
863 cache->dataRead = FALSE;
864 #endif
865 /* Build list of headers of interest */
866 listHdr = NULL;
867 node = harvester->headerTable;
868 while( node ) {
869 HeaderEntry *entry;
871 entry = node->data;
872 if( entry->selected ) {
873 gchar *p;
875 p = g_utf8_strdown( entry->header, -1 );
876 listHdr = g_list_append( listHdr, p );
878 node = g_list_next( node );
881 /* Process directory/files */
882 if( msgList == NULL ) {
883 addrharvest_harvest_dir( harvester, cache, listHdr, harvester->path );
885 else {
886 addrharvest_harvest_list( harvester, cache, listHdr, msgList );
888 mgu_free_dlist( listHdr );
890 #ifndef USE_ALT_ADDRBOOK
891 /* Mark cache */
892 cache->modified = FALSE;
893 cache->dataRead = TRUE;
894 #endif
895 return retVal;
899 * ============================================================================
900 * Test whether any headers have been selected for processing.
901 * Enter: harvester Harvester object.
902 * Return: TRUE if a header was selected, FALSE if none were selected.
903 * ============================================================================
905 gboolean addrharvest_check_header( AddressHarvester *harvester ) {
906 gboolean retVal;
907 GList *node;
909 retVal = FALSE;
910 cm_return_val_if_fail( harvester != NULL, retVal );
912 node = harvester->headerTable;
913 while( node ) {
914 HeaderEntry *entry;
916 entry = ( HeaderEntry * ) node->data;
917 if( entry->selected ) return TRUE;
918 node = g_list_next( node );
920 return retVal;
924 * ============================================================================
925 * End of Source.
926 * ============================================================================