aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/subsurfacewebservices.cpp
diff options
context:
space:
mode:
authorGravatar Venkatesh Shukla <venkatesh.shukla.eee11@iitbhu.ac.in>2014-04-11 11:47:35 +0530
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-04-14 09:40:30 -0700
commit3abcde9a2abade0ce576976b6dce869e8aa28601 (patch)
tree883ee747d3fd09c0359976b667ee8da5954b73cd /qt-ui/subsurfacewebservices.cpp
parentad9eb73d73b0200150d34807616ebcc8dd2a4b4f (diff)
downloadsubsurface-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 'qt-ui/subsurfacewebservices.cpp')
-rw-r--r--qt-ui/subsurfacewebservices.cpp39
1 files changed, 37 insertions, 2 deletions
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp
index d6d0debee..1b8eab129 100644
--- a/qt-ui/subsurfacewebservices.cpp
+++ b/qt-ui/subsurfacewebservices.cpp
@@ -312,12 +312,16 @@ void WebServices::resetState()
SubsurfaceWebServices::SubsurfaceWebServices(QWidget *parent, Qt::WindowFlags f) : WebServices(parent, f)
{
QSettings s;
- ui.userID->setText(s.value("subsurface_webservice_uid").toString().toUpper());
+ if (!save_userid_local || !*userid)
+ ui.userID->setText(s.value("subsurface_webservice_uid").toString().toUpper());
+ else
+ ui.userID->setText(userid);
hidePassword();
hideUpload();
ui.progressBar->setFormat("Enter User ID and click Download");
ui.progressBar->setRange(0, 1);
ui.progressBar->setValue(-1);
+ ui.saveUidLocal->setChecked(save_userid_local);
}
void SubsurfaceWebServices::buttonClicked(QAbstractButton *button)
@@ -339,7 +343,20 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton *button)
/* store last entered uid in config */
QSettings s;
- s.setValue("subsurface_webservice_uid", ui.userID->text().toUpper());
+ QString qDialogUid = ui.userID->text().toUpper();
+ bool qSaveUid = ui.saveUidLocal->checkState();
+ set_save_userid_local(qSaveUid);
+ if (qSaveUid) {
+ QString qSettingUid = s.value("subsurface_webservice_uid").toString();
+ QString qFileUid = QString::fromStdString(userid);
+ bool s_eq_d = (qSettingUid == qDialogUid);
+ bool d_eq_f = (qDialogUid == qFileUid);
+ if (!d_eq_f || s_eq_d)
+ s.setValue("subsurface_webservice_uid", qDialogUid);
+ set_userid(qDialogUid.toLocal8Bit().data());
+ } else {
+ s.setValue("subsurface_webservice_uid", qDialogUid);
+ }
s.sync();
hide();
close();
@@ -626,6 +643,7 @@ DivelogsDeWebServices::DivelogsDeWebServices(QWidget *parent, Qt::WindowFlags f)
QSettings s;
ui.userID->setText(s.value("divelogde_user").toString());
ui.password->setText(s.value("divelogde_pass").toString());
+ ui.saveUidLocal->hide();
hideUpload();
}
@@ -883,3 +901,20 @@ void DivelogsDeWebServices::buttonClicked(QAbstractButton *button)
break;
}
}
+
+#define MAX_USERID_SIZE 32
+short save_userid_local = false;
+char *userid = NULL;
+void set_save_userid_local(short value)
+{
+ QSettings s;
+ s.setValue("save_uid_local", value);
+ save_userid_local = value;
+}
+
+void set_userid(char *rUserId)
+{
+ userid = (char *) malloc(MAX_USERID_SIZE);
+ if (userid && rUserId)
+ strcpy(userid, rUserId);
+}