Esempio n. 1
0
QMLManager::QMLManager() : m_locationServiceEnabled(false),
	m_verboseEnabled(false),
	reply(0),
	deletedDive(0),
	deletedTrip(0),
	m_credentialStatus(UNKNOWN),
	m_lastDevicePixelRatio(1.0),
	alreadySaving(false)
{
	m_instance = this;
	connect(qobject_cast<QApplication *>(QApplication::instance()), &QApplication::applicationStateChanged, this, &QMLManager::applicationStateChanged);
	appendTextToLog(getUserAgent());
	appendTextToLog(QStringLiteral("build with Qt Version %1, runtime from Qt Version %2").arg(QT_VERSION_STR).arg(qVersion()));
	qDebug() << "Starting" << getUserAgent();
	qDebug() << QStringLiteral("build with Qt Version %1, runtime from Qt Version %2").arg(QT_VERSION_STR).arg(qVersion());
	setStartPageText(tr("Starting..."));
	setAccessingCloud(-1);
	setSyncToCloud(true);
	// create location manager service
	locationProvider = new GpsLocation(&appendTextToLogStandalone, this);
	set_git_update_cb(&gitProgressCB);

	// make sure we know if the current cloud repo has been successfully synced
	syncLoadFromCloud();
}
Esempio n. 2
0
void QMLManager::finishSetup()
{
	// Initialize cloud credentials.
	setCloudUserName(prefs.cloud_storage_email);
	setCloudPassword(prefs.cloud_storage_password);
	setSyncToCloud(!prefs.git_local_only);
	// if the cloud credentials are valid, we should get the GPS Webservice ID as well
	QString url;
	if (!cloudUserName().isEmpty() &&
	    !cloudPassword().isEmpty() &&
	    getCloudURL(url) == 0) {
		// we know that we are the first ones to access git storage, so we don't need to test,
		// but we need to make sure we stay the only ones accessing git storage
		alreadySaving = true;
		openLocalThenRemote(url);
	} else {
		setCredentialStatus(INCOMPLETE);
		appendTextToLog(QStringLiteral("no cloud credentials"));
		setStartPageText(RED_FONT + tr("Please enter valid cloud credentials.") + END_FONT);
	}
	setDistanceThreshold(prefs.distance_threshold);
	setTimeThreshold(prefs.time_threshold / 60);
}
Esempio n. 3
0
void QMLManager::finishSetup()
{
	// Initialize cloud credentials.
	setCloudUserName(prefs.cloud_storage_email);
	setCloudPassword(prefs.cloud_storage_password);
	setSyncToCloud(!prefs.git_local_only);
	// if the cloud credentials are valid, we should get the GPS Webservice ID as well
	QString url;
	if (!cloudUserName().isEmpty() &&
	    !cloudPassword().isEmpty() &&
	    getCloudURL(url) == 0) {
		// we know that we are the first ones to access git storage, so we don't need to test,
		// but we need to make sure we stay the only ones accessing git storage
		alreadySaving = true;
		openLocalThenRemote(url);
	} else if (!same_string(existing_filename, "")) {
		setCredentialStatus(NOCLOUD);
		appendTextToLog(tr("working in no-cloud mode"));
		int error = parse_file(existing_filename);
		if (error) {
			// we got an error loading the local file
			appendTextToLog(QString("got error %2 when parsing file %1").arg(existing_filename, get_error_string()));
			set_filename(NULL, "");
		} else {
			// successfully opened the local file, now add thigs to the dive list
			consumeFinishedLoad(0);
			setAccessingCloud(-1);
			appendTextToLog(QString("working in no-cloud mode, finished loading %1 dives from %2").arg(dive_table.nr).arg(existing_filename));
		}
	} else {
		setCredentialStatus(INCOMPLETE);
		appendTextToLog(tr("no cloud credentials"));
		setStartPageText(RED_FONT + tr("Please enter valid cloud credentials.") + END_FONT);
	}
	setDistanceThreshold(prefs.distance_threshold);
	setTimeThreshold(prefs.time_threshold / 60);
}