This is my first patch in Main Subsurface code. I am eager to receive your feedbacks for any kind of improvements.
Changes Made: 1. Choose if User ID is to be saved during import of divelogs from subsurface webservice. Save function must be called once for change to take effect. 2. Dialogbox retains the last set option. Todo: 1. Discard the save option on loading new dive or changing dive. 2. Force save once on clicking accept ? Signed-off-by: Venkatesh Shukla <venkatesh.shukla.ee...@iitbhu.ac.in> --- dive.h | 5 +++++ qt-ui/subsurfacewebservices.cpp | 23 ++++++++++++++++++++++- qt-ui/webservices.ui | 9 ++++++++- save-xml.c | 5 ++++- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/dive.h b/dive.h index f62d83d..3334e5b 100644 --- a/dive.h +++ b/dive.h @@ -899,4 +899,9 @@ extern fraction_t string_to_fraction(const char *str); #include "pref.h" +extern short save_userid_xml; +extern char* userid; +extern void set_save_userid_xml(short value); +extern void set_userid(char* rUserId, int len); + #endif // DIVE_H diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index 7077465..9d29552 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -318,8 +318,10 @@ SubsurfaceWebServices::SubsurfaceWebServices(QWidget *parent, Qt::WindowFlags f) ui.progressBar->setFormat("Enter User ID and click Download"); ui.progressBar->setRange(0, 1); ui.progressBar->setValue(-1); + ui.saveUserIdXml->setChecked(s.value("save_userid_in_xml").toBool()); } +#define MAX_USERID_SIZE 32 void SubsurfaceWebServices::buttonClicked(QAbstractButton *button) { ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); @@ -339,7 +341,12 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton *button) /* store last entered uid in config */ QSettings s; - s.setValue("subsurface_webservice_uid", ui.userID->text().toUpper()); + QString qUserId = ui.userID->text().toUpper(); + bool qSaveUserId = ui.saveUserIdXml->checkState(); + s.setValue("subsurface_webservice_uid", qUserId); + s.setValue("save_userid_in_xml", qSaveUserId); + set_userid(qUserId.toLocal8Bit().data(), MAX_USERID_SIZE); + set_save_userid_xml(qSaveUserId); s.sync(); hide(); close(); @@ -626,6 +633,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.saveUserIdXml->hide(); hideUpload(); } @@ -883,3 +891,16 @@ void DivelogsDeWebServices::buttonClicked(QAbstractButton *button) break; } } + +short save_userid_xml = false; +char *userid = NULL; + +void set_save_userid_xml(short value) { + save_userid_xml = value; +} + +void set_userid(char* rUserId, int len) { + userid = (char*) malloc(len*sizeof(char)); + strcpy(userid, rUserId); +} + diff --git a/qt-ui/webservices.ui b/qt-ui/webservices.ui index 295c252..bf14462 100644 --- a/qt-ui/webservices.ui +++ b/qt-ui/webservices.ui @@ -45,7 +45,7 @@ </property> </widget> </item> - <item row="4" column="0" colspan="3"> + <item row="5" column="0" colspan="3"> <widget class="QDialogButtonBox" name="buttonBox"> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -79,6 +79,13 @@ </property> </widget> </item> + <item row="4" column="0" colspan="4"> + <widget class="QCheckBox" name="saveUserIdXml"> + <property name="text"> + <string>Save User ID in XML?</string> + </property> + </widget> + </item> <item row="1" column="0"> <widget class="QLabel" name="passLabel"> <property name="text"> diff --git a/save-xml.c b/save-xml.c index 61a9300..ac309ba 100644 --- a/save-xml.c +++ b/save-xml.c @@ -11,6 +11,7 @@ #include "device.h" #include "membuffer.h" + /* * We're outputting utf8 in xml. * We need to quote the characters <, >, &. @@ -507,7 +508,9 @@ void save_dives_buffer(struct membuffer *b, const bool select_only) dive_trip_t *trip; put_format(b, "<divelog program='subsurface' version='%d'>\n<settings>\n", VERSION); - + if(save_userid_xml) { + put_format(b, "<userid>%s</userid>\n", userid); + } /* save the dive computer nicknames, if any */ call_for_each_dc(b, save_one_device); if (autogroup) -- 1.9.0 Regards -- *Venkatesh Shukla *
_______________________________________________ subsurface mailing list subsurface@hohndel.org http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface