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>
This commit is contained in:
Venkatesh Shukla 2014-04-11 11:47:35 +05:30 committed by Dirk Hohndel
parent ad9eb73d73
commit 3abcde9a2a
10 changed files with 148 additions and 5 deletions

View file

@ -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);