diff options
author | Venkatesh Shukla <venkatesh.shukla.eee11@iitbhu.ac.in> | 2014-04-11 11:47:35 +0530 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-04-14 09:40:30 -0700 |
commit | 3abcde9a2abade0ce576976b6dce869e8aa28601 (patch) | |
tree | 883ee747d3fd09c0359976b667ee8da5954b73cd /parse-xml.c | |
parent | ad9eb73d73b0200150d34807616ebcc8dd2a4b4f (diff) | |
download | subsurface-3abcde9a2abade0ce576976b6dce869e8aa28601.tar.gz |
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 <venkatesh.shukla.eee11@iitbhu.ac.in>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r-- | parse-xml.c | 25 |
1 files changed, 25 insertions, 0 deletions
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); |