WIP: enchance device pairing process

- Introduced devicePasswordProtected signal in AppContext to notify when a device is password protected.
- Modified DeviceManagerWidget to handle devicePasswordProtected signal and update pending device state accordingly.
- Enhanced DevicePendingWidget to display appropriate messages based on device lock status.
This commit is contained in:
uncor3
2025-10-01 15:10:40 +00:00
parent 94f85bd8fe
commit 6bbad2a3b6
6 changed files with 47 additions and 12 deletions
+5 -2
View File
@@ -83,8 +83,11 @@ void AppContext::addDevice(QString udid, idevice_connection_type conn_type,
// because it's less likely that it will be an error typeof
// LOCKDOWN_E_PASSWORD_PROTECTED if the device is paired type
if (addType == AddType::Regular) { // TODO:IMPLEMENT
// emit devicePasswordProtected(udid);
};
// FIXME: if a device never gets paired, it will stay in
// this
m_pendingDevices.append(udid);
emit devicePasswordProtected(udid);
}
} else if (initResult.error ==
LOCKDOWN_E_PAIRING_DIALOG_RESPONSE_PENDING) {
m_pendingDevices.append(udid);
+1
View File
@@ -36,6 +36,7 @@ signals:
void deviceAdded(iDescriptorDevice *device);
void deviceRemoved(const std::string &udid);
void devicePaired(iDescriptorDevice *device);
void devicePasswordProtected(const QString &udid);
void recoveryDeviceAdded(RecoveryDeviceInfo *deviceInfo);
void recoveryDeviceRemoved(const QString &udid);
void devicePairPending(const QString &udid);
+23 -4
View File
@@ -1,6 +1,7 @@
#include "devicemanagerwidget.h"
#include "appcontext.h"
#include "devicemenuwidget.h"
#include "devicependingwidget.h"
#include <QDebug>
DeviceManagerWidget::DeviceManagerWidget(QWidget *parent)
@@ -23,7 +24,13 @@ DeviceManagerWidget::DeviceManagerWidget(QWidget *parent)
connect(AppContext::sharedInstance(), &AppContext::devicePairPending, this,
[this](const QString &udid) {
addPendingDevice(udid);
addPendingDevice(udid, false);
emit updateNoDevicesConnected();
});
connect(AppContext::sharedInstance(), &AppContext::devicePasswordProtected,
this, [this](const QString &udid) {
addPendingDevice(udid, true);
emit updateNoDevicesConnected();
});
@@ -99,12 +106,24 @@ void DeviceManagerWidget::addDevice(iDescriptorDevice *device)
// }
}
void DeviceManagerWidget::addPendingDevice(const QString &udid)
void DeviceManagerWidget::addPendingDevice(const QString &udid, bool locked)
{
qDebug() << "Adding pending device:" << udid;
if (m_pendingDeviceWidgets.contains(udid.toStdString()) && !locked) {
qDebug() << "Pending device already exists, moving to next state:"
<< udid;
m_pendingDeviceWidgets[udid.toStdString()].first->next();
return;
} else if (m_pendingDeviceWidgets.contains(udid.toStdString()) && locked) {
// Already exists and still locked, do nothing
qDebug()
<< "Pending device already exists and is locked, doing nothing:"
<< udid;
return;
}
DevicePendingWidget *pendingWidget = new DevicePendingWidget(this);
qDebug() << "Created pending widget for:" << udid << "Locked:" << locked;
DevicePendingWidget *pendingWidget = new DevicePendingWidget(locked, this);
m_stackedWidget->addWidget(pendingWidget);
m_pendingDeviceWidgets[udid.toStdString()] =
std::pair{pendingWidget, m_sidebar->addPendingToSidebar(udid)};
+1 -1
View File
@@ -19,7 +19,7 @@ public:
void addDevice(iDescriptorDevice *device);
// TODO:udid or uuid ?
void addPendingDevice(const QString &udid);
void addPendingDevice(const QString &udid, bool locked);
void addPairedDevice(iDescriptorDevice *device);
void removeDevice(const std::string &uuid);
+11 -3
View File
@@ -2,14 +2,22 @@
#include <QLabel>
#include <QVBoxLayout>
DevicePendingWidget::DevicePendingWidget(QWidget *parent) : QWidget{parent}
DevicePendingWidget::DevicePendingWidget(bool locked, QWidget *parent)
: QWidget{parent}, m_label{nullptr}, m_locked{locked}
{
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(5);
QLabel *label = new QLabel("Please click on trust on the popup", this);
m_label = new QLabel(m_locked ? "Please unlock the screen"
: "Please click on trust on the popup",
this);
layout->addWidget(label);
layout->addWidget(m_label);
setLayout(layout);
}
void DevicePendingWidget::next()
{
m_label->setText("Please click on trust on the popup");
}
+6 -2
View File
@@ -1,15 +1,19 @@
#ifndef DEVICEPENDINGWIDGET_H
#define DEVICEPENDINGWIDGET_H
#include <QLabel>
#include <QWidget>
class DevicePendingWidget : public QWidget
{
Q_OBJECT
public:
explicit DevicePendingWidget(QWidget *parent = nullptr);
explicit DevicePendingWidget(bool locked, QWidget *parent);
void next();
signals:
private:
QLabel *m_label;
bool m_locked;
};
#endif // DEVICEPENDINGWIDGET_H