From 3abcde9a2abade0ce576976b6dce869e8aa28601 Mon Sep 17 00:00:00 2001 From: Venkatesh Shukla Date: Fri, 11 Apr 2014 11:47:35 +0530 Subject: Add option to save userid in data files The userid of Subsurface Webservice can be included in locally saved xml files and git repository. For xml files, it is stored in userid tag. For git repo, it is stored in 00-Subsurface file present in the repo. Preference dialog and webservice dialog modified to include option for saving userid locally. In case of difference in default userid and userid in local file, some semantics are followed. These can be referred to here: http://lists.hohndel.org/pipermail/subsurface/2014-April/011422.html Fixes #473 Signed-off-by: Venkatesh Shukla Signed-off-by: Dirk Hohndel --- parse-xml.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'parse-xml.c') diff --git a/parse-xml.c b/parse-xml.c index 483187a51..966e56726 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -112,6 +112,7 @@ static struct { } dc; } cur_settings; static bool in_settings = false; +static bool in_userid = false; static struct tm cur_tm; static int cur_cylinder_index, cur_ws_index; static int lastndl, laststoptime, laststopdepth, lastcns, lastpo2, lastindeco; @@ -858,6 +859,12 @@ static void try_to_fill_sample(struct sample *sample, const char *name, char *bu nonmatch("sample", name, buf); } +void try_to_fill_userid(const char *name, char *buf) +{ + if (save_userid_local) + set_userid(buf); +} + static const char *country, *city; static void divinglog_place(char *place, void *_location) @@ -1367,8 +1374,23 @@ static void divecomputer_end(void) cur_dc = NULL; } +static void userid_start(void) +{ + in_userid = true; + set_save_userid_local(true); //if the xml contains userid, keep saving it. +} + +static void userid_stop(void) +{ + in_userid = false; +} + static void entry(const char *name, char *buf) { + if (in_userid) { + try_to_fill_userid(name, buf); + return; + } if (in_settings) { try_to_fill_dc_settings(name, buf); try_to_match_autogroup(name, buf); @@ -1515,6 +1537,7 @@ static struct nesting { { "weightsystem", ws_start, ws_end }, { "divecomputer", divecomputer_start, divecomputer_end }, { "P", sample_start, sample_end }, + { "userid", userid_start, userid_stop}, /* Import type recognition */ { "Divinglog", DivingLog_importer }, @@ -1602,6 +1625,8 @@ void parse_xml_buffer(const char *url, const char *buffer, int size, report_error(translate("gettextFromC", "Failed to parse '%s'"), url); return; } + set_save_userid_local(false); + set_userid(""); reset_all(); dive_start(); doc = test_xslt_transforms(doc, params); -- cgit v1.2.3-70-g09d2