[gnome-commander] XML config: write connections to XML::xstream



commit 6bdd39f8cb8abd6b340730edc4287861476eb2b7
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Fri Sep 2 20:10:25 2011 +0200

    XML config: write connections to XML::xstream

 src/gnome-cmd-con.cc  |   14 ++++++++++++++
 src/gnome-cmd-con.h   |    2 ++
 src/gnome-cmd-data.cc |   12 ++++++++++++
 3 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/src/gnome-cmd-con.cc b/src/gnome-cmd-con.cc
index d25df4c..d8e737a 100644
--- a/src/gnome-cmd-con.cc
+++ b/src/gnome-cmd-con.cc
@@ -527,3 +527,17 @@ string &__gnome_cmd_con_make_uri (string &s, const gchar *method, gboolean use_a
 
     return s;
 }
+
+
+XML::xstream &operator << (XML::xstream &xml, GnomeCmdCon &con)
+{
+    if (!con.alias || !*con.alias || !con.uri || !*con.uri)
+        return xml;
+
+    xml << XML::tag("Connection");
+
+    xml << XML::attr("name") << XML::escape(con.alias);
+    xml << XML::attr("uri") << XML::escape(con.uri);
+
+    return xml << XML::endtag();
+}
diff --git a/src/gnome-cmd-con.h b/src/gnome-cmd-con.h
index fd96a82..0e5430f 100644
--- a/src/gnome-cmd-con.h
+++ b/src/gnome-cmd-con.h
@@ -104,6 +104,8 @@ struct GnomeCmdCon
     gchar            *open_failed_msg;
 
     GnomeCmdConPrivate *priv;
+
+    friend XML::xstream &operator << (XML::xstream &xml, GnomeCmdCon &con);
 };
 
 struct GnomeCmdConClass
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 76e32a5..73e01f4 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -1672,6 +1672,18 @@ void GnomeCmdData::save()
         xml << search_defaults;
         xml << bookmarks_defaults;
 
+        xml << XML::tag("Connections");
+
+        for (GList *i=gnome_cmd_con_list_get_all_ftp (gnome_cmd_data.priv->con_list); i; i=i->next)
+        {
+            GnomeCmdCon *con = GNOME_CMD_CON (i->data);
+
+            if (con)
+                xml << *con;
+        }
+
+        xml << XML::endtag("Connections");
+
         xml << XML::tag("Bookmarks");
 
         write (xml, gnome_cmd_con_list_get_home (priv->con_list), "Home");



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