talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 68bcb4368e9451006f7c0868b01d52acad9e416b
parent 07eb5a0d11a9a42516c9dba35970bd72b47344ff
Author: Colin Leroy <colin@colino.net>
Date:   Sun, 11 Jan 2009 12:41:22 +0000

2009-01-11 [colin]	3.7.0cvs31

	* src/addrindex.c
		Revert part of patch 3.7.0cvs29
		This function is used when jpilot
		support is disabled

Diffstat:
MChangeLog | 7+++++++
MPATCHSETS | 1+
Mconfigure.ac | 2+-
Msrc/addrindex.c | 109+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 118 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,10 @@ +2009-01-11 [colin] 3.7.0cvs31 + + * src/addrindex.c + Revert part of patch 3.7.0cvs29 + This function is used when jpilot + support is disabled + 2009-01-11 [colin] 3.7.0cvs30 * src/folder.c diff --git a/PATCHSETS b/PATCHSETS @@ -3692,3 +3692,4 @@ ( cvs diff -u -r 1.4.2.73 -r 1.4.2.74 src/gtk/about.c; ) > 3.7.0cvs28.patchset ( cvs diff -u -r 1.5.2.8 -r 1.5.2.9 src/addrclip.c; cvs diff -u -r 1.28.2.38 -r 1.28.2.39 src/addrindex.c; cvs diff -u -r 1.13.2.18 -r 1.13.2.19 src/addritem.c; cvs diff -u -r 1.4.12.8 -r 1.4.12.9 src/foldersel.h; cvs diff -u -r 1.207.2.210 -r 1.207.2.211 src/folderview.c; cvs diff -u -r 1.52.2.71 -r 1.52.2.72 src/prefs_folder_item.c; ) > 3.7.0cvs29.patchset ( cvs diff -u -r 1.213.2.186 -r 1.213.2.187 src/folder.c; ) > 3.7.0cvs30.patchset +( cvs diff -u -r 1.28.2.39 -r 1.28.2.40 src/addrindex.c; ) > 3.7.0cvs31.patchset diff --git a/configure.ac b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=7 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=30 +EXTRA_VERSION=31 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/addrindex.c b/src/addrindex.c @@ -980,6 +980,115 @@ static int addrindex_write_attr( FILE *fp, const gchar *name, const gchar *value } /** + * Return DOM fragment for current XML tag from file. + * \param file XML file being processed. + * \return Fragment representing DOM fragment for configuration element. + */ +static AddressIfFragment *addrindex_read_fragment( XMLFile *file ) { + AddressIfFragment *fragment; + AddressIfFragment *child; + AddressIfAttrib *nv; + XMLTag *xtag; + GList *list; + GList *attr; + gchar *name; + gchar *value; + guint prevLevel; + gint rc; + + /* g_print( "addrindex_read_fragment\n" ); */ + + prevLevel = file->level; + + /* Get current tag name */ + xtag = xml_get_current_tag( file ); + + /* Create new fragment */ + fragment = g_new0( AddressIfFragment, 1 ); + fragment->name = g_strdup( xtag->tag ); + fragment->children = NULL; + fragment->attributes = NULL; + + /* Read attributes */ + list = NULL; + attr = xml_get_current_tag_attr( file ); + while( attr ) { + name = ((XMLAttr *)attr->data)->name; + value = ((XMLAttr *)attr->data)->value; + nv = g_new0( AddressIfAttrib, 1 ); + nv->name = g_strdup( name ); + nv->value = g_strdup( value ); + list = g_list_append( list, nv ); + attr = g_list_next( attr ); + } + fragment->attributes = list; + + /* Now read the children */ + while( TRUE ) { + rc = xml_parse_next_tag( file ); + if( rc != 0 ) { + /* End of file? */ + break; + } + if( file->level < prevLevel ) { + /* We must be above level we start at */ + break; + } + child = addrindex_read_fragment( file ); + fragment->children = g_list_append( fragment->children, child ); + } + + return fragment; +} + +/** + * Write DOM fragment to file. + * \param fp File to write. + * \param fragment DOM fragment for configuration element. + * \param lvl Indent level. + */ +static int addrindex_write_fragment( + FILE *fp, const AddressIfFragment *fragment, const gint lvl ) +{ + GList *node; + + if( fragment ) { + if (addrindex_write_elem_s( fp, lvl, fragment->name ) < 0) + return -1; + node = fragment->attributes; + while( node ) { + AddressIfAttrib *nv = node->data; + if (addrindex_write_attr( fp, nv->name, nv->value ) < 0) + return -1; + node = g_list_next( node ); + } + if( fragment->children ) { + if (fputs(" >\n", fp) == EOF) + return -1; + + /* Output children */ + node = fragment->children; + while( node ) { + AddressIfFragment *child = node->data; + if (addrindex_write_fragment( fp, child, 1+lvl ) < 0) + return -1; + node = g_list_next( node ); + } + + /* Output closing tag */ + if (addrindex_write_elem_e( fp, lvl, fragment->name ) < 0) + return -1; + } + else { + if (fputs(" />\n", fp) == EOF) + return -1; + } + } + + return 0; +} + +/** * Read/parse address index file, creating a data source for a regular * intrinsic XML addressbook. * \param file Address index file.