[PATCH 2/2] Store/Retrieve last entered webservice UID to/from config.

Lubomir I. Ivanov neolit123 at gmail.com
Wed Jan 23 07:49:00 PST 2013


From: "Lubomir I. Ivanov" <neolit123 at gmail.com>

This patch also includes Dirk's patch that calls parse_xml_buffer(),
so that the download is merged with the dives in the current dive list.

Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
 webservice.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/webservice.c b/webservice.c
index 5acfb2d..88aea27 100644
--- a/webservice.c
+++ b/webservice.c
@@ -32,6 +32,7 @@ struct download_dialog_state {
 	GtkWidget *status;
 	GtkWidget *apply;
 	gchar *xmldata;
+	guint xmldata_len;
 };
 
 /* this method uses libsoup as a backend. if there are some portability,
@@ -125,6 +126,7 @@ static void download_dialog_connect_cb(GtkWidget *w, gpointer data)
 		gtk_label_set_text(GTK_LABEL(state->status), err);
 	}
 	state->xmldata = xmldata;
+	state->xmldata_len = len;
 	gtk_widget_set_sensitive(state->apply, ret);
 }
 
@@ -144,12 +146,15 @@ void webservice_download_dialog(void)
 {
 	const guint pad = 6;
 	/* user entered value should be stored in the config */
-	const gchar *current_uid = "41TFEC8ZMVD5DBE0JPBBU5JDDA2Y6T";
+	const gchar *current_uid = subsurface_get_conf("webservice_uid");
 	GtkWidget *dialog, *vbox, *status, *info, *uid;
 	GtkWidget *frame_uid, *frame_status, *download, *image, *apply;
 	struct download_dialog_state state = {NULL};
 	int result;
 
+	if (!current_uid)
+		current_uid = "";
+
 	dialog = gtk_dialog_new_with_buttons(_("Download From Web Service"),
 		GTK_WINDOW(main_window),
 		GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -198,7 +203,10 @@ void webservice_download_dialog(void)
 	result = gtk_dialog_run(GTK_DIALOG(dialog));
 	if (result == GTK_RESPONSE_ACCEPT) {
 		/* apply download */
-		g_message("\napply download should happen here: \n\n %s", state.xmldata);
+		parse_xml_buffer(_("Webservice"), state.xmldata, state.xmldata_len, NULL);
+		report_dives(TRUE, FALSE);
+		/* store last entered uid in config */
+		subsurface_set_conf("webservice_uid", gtk_entry_get_text(GTK_ENTRY(uid)));
 	}
 	download_dialog_release_xml(&state);
 	gtk_widget_destroy(dialog);
-- 
1.7.11.msysgit.0



More information about the subsurface mailing list