Fetch the Subsurface webservice userid if cloud credentials were given

This allows users to not have to worry about this userid anymore. Both the
mobile app and the desktop app can now derive the userid from the cloud
storage credentials.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-12-02 14:32:03 -08:00
parent 962341ae9f
commit 8f33403e4f
2 changed files with 13 additions and 4 deletions

View file

@ -209,6 +209,7 @@ MainWindow::MainWindow() : QMainWindow(),
if (!locationProvider->hasLocationsSource()) {
ui.menuFile->removeAction(ui.add_GPS_location_here);
}
ui.mainErrorMessage->hide();
graphics()->setEmptyState();
initialUiSetup();

View file

@ -385,10 +385,18 @@ void WebServices::resetState()
SubsurfaceWebServices::SubsurfaceWebServices(QWidget *parent, Qt::WindowFlags f) : WebServices(parent, f)
{
QSettings s;
if (!prefs.save_userid_local || !*prefs.userid)
ui.userID->setText(s.value("subsurface_webservice_uid").toString().toUpper());
else
ui.userID->setText(prefs.userid);
// figure out if we know (or can determine) the user's web service userid
QString userid(prefs.userid);
if (userid.isEmpty())
userid = s.value("subsurface_webservice_uid").toString().toUpper();
if (userid.isEmpty() &&
!same_string(prefs.cloud_storage_email, "") &&
!same_string(prefs.cloud_storage_password, ""))
userid = GpsLocation::instance()->getUserid(prefs.cloud_storage_email, prefs.cloud_storage_password);
ui.userID->setText(userid);
hidePassword();
hideUpload();
ui.progressBar->setFormat(tr("Enter User ID and click Download"));