Commit e1e8189f authored by Andrew den Exter's avatar Andrew den Exter Committed by Bea Lam

[developermode] Add a developerModeAvailable property. Contributes to JB#39097

This will indicate whether the jolla-developer-mode package is
available from a configured repository.
parent d1932517
......@@ -129,6 +129,7 @@ DeveloperModeSettings::DeveloperModeSettings(QObject *parent)
, m_usbModeDaemon(USB_MODED_SERVICE, USB_MODED_PATH, USB_MODED_INTERFACE,
QDBusConnection::systemBus())
, m_pendingPackageKitCall(nullptr)
, m_packageKitCommand(nullptr)
, m_wlanIpAddress("-")
, m_usbInterface(USB_NETWORK_FALLBACK_INTERFACE)
, m_usbIpAddress(USB_NETWORK_FALLBACK_IP)
......@@ -146,6 +147,11 @@ DeveloperModeSettings::DeveloperModeSettings(QObject *parent)
qWarning() << "Failed to return username using getpwuid()";
}
if (!m_developerModeEnabled) {
m_workerStatus = CheckingStatus;
executePackageKitCommand(&DeveloperModeSettings::resolvePackageId, DEVELOPER_MODE_PACKAGE);
}
refresh();
// TODO: Watch WLAN / USB IP addresses for changes
......@@ -175,6 +181,11 @@ DeveloperModeSettings::username() const
return m_username;
}
bool DeveloperModeSettings::developerModeAvailable() const
{
return m_developerModeEnabled || !m_developerModePackageId.isEmpty();
}
bool
DeveloperModeSettings::developerModeEnabled() const
{
......@@ -219,7 +230,12 @@ DeveloperModeSettings::setDeveloperMode(bool enabled)
m_packageKitCommand = &DeveloperModeSettings::removePackage;
}
executePackageKitCommand(&DeveloperModeSettings::resolvePackageId, DEVELOPER_MODE_PACKAGE);
if (m_developerModePackageId.isEmpty()) {
executePackageKitCommand(&DeveloperModeSettings::resolvePackageId, DEVELOPER_MODE_PACKAGE);
} else {
executePackageKitCommand(m_packageKitCommand, m_developerModePackageId);
m_packageKitCommand = nullptr;
}
emit workerStatusChanged();
emit workerWorkingChanged();
}
......@@ -430,12 +446,18 @@ void DeveloperModeSettings::executePackageKitCommand(
void DeveloperModeSettings::transactionPackage(uint, const QString &packageId)
{
Q_ASSERT(!m_pendingPackageKitCall);
Q_ASSERT(m_packageKitCommand);
m_packageKitTransaction = QDBusObjectPath();
executePackageKitCommand(m_packageKitCommand, packageId);
m_packageKitCommand = nullptr;
if (m_packageKitCommand) {
executePackageKitCommand(m_packageKitCommand, packageId);
m_packageKitCommand = nullptr;
}
m_developerModePackageId = packageId;
if (!m_developerModeEnabled) {
emit developerModeAvailableChanged();
}
}
void DeveloperModeSettings::transactionResolveFinished(uint exit, uint)
......@@ -443,8 +465,9 @@ void DeveloperModeSettings::transactionResolveFinished(uint exit, uint)
if (exit != 1) {
m_packageKitTransaction = QDBusObjectPath();
m_workerStatus = Failure;
m_workerStatus = m_packageKitCommand ? Failure : Idle;
m_workerProgress = PROGRESS_INDETERMINATE;
m_packageKitCommand = nullptr;
emit workerStatusChanged();
emit workerWorkingChanged();
......
......@@ -60,6 +60,10 @@ class SYSTEMSETTINGS_EXPORT DeveloperModeSettings : public QObject
READ username
CONSTANT)
Q_PROPERTY(bool developerModeAvailable
READ developerModeAvailable
NOTIFY developerModeAvailableChanged)
Q_PROPERTY(bool developerModeEnabled
READ developerModeEnabled
NOTIFY developerModeEnabledChanged)
......@@ -96,6 +100,7 @@ public:
QString wlanIpAddress() const;
QString usbIpAddress() const;
QString username() const;
bool developerModeAvailable() const;
bool developerModeEnabled() const;
bool remoteLoginEnabled() const;
bool workerWorking() const;
......@@ -110,6 +115,7 @@ public:
signals:
void wlanIpAddressChanged();
void usbIpAddressChanged();
void developerModeAvailableChanged();
void developerModeEnabledChanged();
void remoteLoginEnabledChanged();
void workerWorkingChanged();
......@@ -138,12 +144,13 @@ private:
QDBusInterface m_usbModeDaemon;
QDBusObjectPath m_packageKitTransaction;
QDBusPendingCallWatcher *m_pendingPackageKitCall;
QDBusPendingCallWatcher *(DeveloperModeSettings::*m_packageKitCommand)(const QString &packageId);
QString m_wlanIpAddress;
QString m_usbInterface;
QString m_usbIpAddress;
QString m_username;
QDBusPendingCallWatcher *(DeveloperModeSettings::*m_packageKitCommand)(const QString &packageId);
QString m_developerModePackageId;
bool m_developerModeEnabled;
bool m_remoteLoginEnabled;
DeveloperModeSettings::Status m_workerStatus;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment