gnomecard's vcard load/save weirdness




I was tracing address-conduit weirdness and tracked it down to weird
behavior of card_load/card_save code in gnomecard. It seems like it
has "infinite" growth problem. I think it's a bug in
card_load/card_save logic somewhere, but I can't exactly figure out
the best fix, altough I explain it below. Can someone with better
knowledge of the code make any suggestions?

Assuming you do all this in gnome-pim/gnomecard directory:

------cardtest.c-----
#include "card.h"
int main(int argc, char **argv)
{
	FILE *fp;
	GList *cards=NULL;
	if(argc<3){
		printf("Usage: %s file1 file2\n",argv[0]);
		exit(0);
	}
		
	cards=card_load(cards,argv[1]);
	fp = fopen(argv[2],"w");
	if(fp==0) {
		printf("Unable to open file\n");
		exit(1);
	}

	g_list_foreach(cards,(GFunc)card_save,fp);
	fclose(fp);
	g_list_free(cards);   
}

---------test.gcrd-------------
BEGIN:VCARD

FN:test

N:;test

TEL;HOME:(000) 000-0000

END:VCARD


------------------------------
$ gcc -g -o cardtest `gnome-config --cflags gnome gtk` -I..  cardtest.c card.c  my.c `gnome-config --libs gnome gtk gnomeui` -L../libversit/ -lversit

$ ./cardtest test.gcrd test1.gcrd

And the result is:

---------test1.gcrd-----
BEGIN:VCARD

FN:test

N:;test

TEL;HOME;HOME:(000) 000-0000

END:VCARD



-----------------


Notice the 2 "HOME". The next time it will 3, then 4, etc... And while 
the resulting file still loads and works correctly it just keep
growing on and on, which I don't find very nice. And if you think in
terms of address-conduit, this keeps growing with every sync. This
applies to email and address as well. And you can observe similar
behavior with gnomecard itself. 

Basic explanation is that on reading the card, we get a phone entry
with particular type (4=HOME) and also an xtension entry with "HOME"
name. on output the type and xtension result in 2 separate entries,
which on the following reading result in type HOME and *2* xtentsion
entries with "HOME" name, and so on...

Ideas?

-Vadim


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]