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 f45ad852f918cf4e4cff3b9dccf7d489cb1a42b5..33b8225e75c7cc11a43d46efa1b5c9ec51e33280 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 af8fb7d4e167c4fcb7f1a55eaa487c0d01994254..10c5e0932a32cbac2921ee13d3c8950a7eee2838 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 e70e7328f30cad1da6a342e36c22a5601a2d74ca..f39530aa5e35a9c103ddb210430b76bcd79657d7 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 33be9830c8962d99ca7d25187bcfe8a2f0479558..1c589712b46bac8ac0d5532536d40c4e918db8a0 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.