2009-01-11 [colin] 3.7.0cvs31
authorColin Leroy <colin@colino.net>
Sun, 11 Jan 2009 12:41:22 +0000 (12:41 +0000)
committerColin Leroy <colin@colino.net>
Sun, 11 Jan 2009 12:41:22 +0000 (12:41 +0000)
* src/addrindex.c
Revert part of patch 3.7.0cvs29
This function is used when jpilot
support is disabled

ChangeLog
PATCHSETS
configure.ac
src/addrindex.c

index f45ad85..33b8225 100644 (file)
--- 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
index af8fb7d..10c5e09 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( 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
index e70e732..f39530a 100644 (file)
@@ -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=
 
index 33be983..1c58971 100644 (file)
@@ -979,6 +979,115 @@ static int addrindex_write_attr( FILE *fp, const gchar *name, const gchar *value
        return 0;
 }
 
+/**
+ * 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.