mirror of
https://github.com/iDescriptor/iDescriptor.git
synced 2026-06-22 03:45:51 +08:00
WIP: implement instanceRemoveDevice
This commit is contained in:
+29
-1
@@ -118,6 +118,33 @@ void AppContext::addDevice(QString udid, idevice_connection_type conn_type,
|
||||
// processing device information");
|
||||
}
|
||||
}
|
||||
// TODO:WIP
|
||||
void AppContext::instanceRemoveDevice(QString _udid)
|
||||
{
|
||||
const std::string uuid = _udid.toStdString();
|
||||
if (!m_devices.contains(uuid)) {
|
||||
qDebug() << "Device with UUID " + _udid +
|
||||
" not found. Please report this issue.",
|
||||
"Error";
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "Removing device with UUID:" << QString::fromStdString(uuid);
|
||||
|
||||
// cleanDevice(device);
|
||||
iDescriptorDevice *device = m_devices[uuid];
|
||||
m_devices.remove(uuid);
|
||||
|
||||
emit deviceRemoved(uuid);
|
||||
// TODO: Cleanup now should be done wherever there are initialized
|
||||
// lockdownd_client_free(device->lockdownClient);
|
||||
if (device->afcClient)
|
||||
afc_client_free(device->afcClient);
|
||||
idevice_free(device->device);
|
||||
// lockdownd_service_descriptor_free(device->lockdownService);
|
||||
delete device;
|
||||
// return true;
|
||||
}
|
||||
|
||||
void AppContext::removeDevice(QString _udid)
|
||||
|
||||
@@ -139,7 +166,8 @@ void AppContext::removeDevice(QString _udid)
|
||||
emit deviceRemoved(uuid);
|
||||
// TODO: Cleanup now should be done wherever there are initialized
|
||||
// lockdownd_client_free(device->lockdownClient);
|
||||
// afc_client_free(device->afcClient);
|
||||
if (device->afcClient)
|
||||
afc_client_free(device->afcClient);
|
||||
idevice_free(device->device);
|
||||
// lockdownd_service_descriptor_free(device->lockdownService);
|
||||
delete device;
|
||||
|
||||
@@ -26,6 +26,7 @@ public:
|
||||
bool noDevicesConnected();
|
||||
QList<RecoveryDeviceInfo *> getAllRecoveryDevices();
|
||||
~AppContext();
|
||||
void instanceRemoveDevice(QString _udid);
|
||||
|
||||
private:
|
||||
QMap<std::string, iDescriptorDevice *> m_devices;
|
||||
|
||||
@@ -27,15 +27,22 @@
|
||||
// TODO:break all the client because device wont restart if any client is still
|
||||
// connected we need to change the main device init function to not connect to
|
||||
// any client
|
||||
bool restart(idevice_t device)
|
||||
bool restart(std::string _udid)
|
||||
{
|
||||
idevice_t device = NULL;
|
||||
lockdownd_client_t lockdown_client = NULL;
|
||||
diagnostics_relay_client_t diagnostics_client = NULL;
|
||||
lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR;
|
||||
lockdownd_service_descriptor_t service = NULL;
|
||||
const char *udid = NULL;
|
||||
const char *udid = _udid.c_str();
|
||||
int use_network = 0;
|
||||
|
||||
if (idevice_new_with_options(&device, udid, IDEVICE_LOOKUP_USBMUX) !=
|
||||
IDEVICE_E_SUCCESS) {
|
||||
printf("ERROR: No device found, is it plugged in?\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (LOCKDOWN_E_SUCCESS != (ret = lockdownd_client_new_with_handshake(
|
||||
device, &lockdown_client, TOOL_NAME))) {
|
||||
idevice_free(device);
|
||||
@@ -82,10 +89,5 @@ bool restart(idevice_t device)
|
||||
diagnostics_relay_client_free(diagnostics_client);
|
||||
}
|
||||
|
||||
if (service) {
|
||||
lockdownd_service_descriptor_free(service);
|
||||
service = NULL;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
+14
-3
@@ -346,9 +346,20 @@ void ToolboxWidget::onToolboxClicked(const QString &toolName)
|
||||
virtualLocation->resize(800, 600); // Optional: default size
|
||||
virtualLocation->show();
|
||||
} else if (toolName == "Restart") {
|
||||
if (!(restart(m_currentDevice->device)))
|
||||
// TODO:WIP
|
||||
std::string udid = m_currentDevice->udid;
|
||||
AppContext::sharedInstance()->instanceRemoveDevice(
|
||||
QString::fromStdString(udid));
|
||||
// QMetaObject::invokeMethod(AppContext::sharedInstance(),
|
||||
// "removeDevice",
|
||||
// Qt::QueuedConnection,
|
||||
// Q_ARG(QString, QString(udid.c_str())));
|
||||
if (!(restart(udid)))
|
||||
warn("Failed to restart device");
|
||||
qDebug() << "Restarting device services...";
|
||||
else {
|
||||
warn("Device services restarted successfully", "Success");
|
||||
qDebug() << "Restarting device";
|
||||
}
|
||||
} else if (toolName == "Shutdown") {
|
||||
// TODO
|
||||
// if (!(shutdown(m_currentDevice->device)))
|
||||
@@ -371,7 +382,7 @@ void ToolboxWidget::onToolboxClicked(const QString &toolName)
|
||||
} else if (toolName == "Query MobileGestalt") {
|
||||
// Handle querying MobileGestalt
|
||||
QueryMobileGestaltWidget *queryMobileGestaltWidget =
|
||||
new QueryMobileGestaltWidget();
|
||||
new QueryMobileGestaltWidget(m_currentDevice);
|
||||
queryMobileGestaltWidget->show();
|
||||
} else if (toolName == "Developer Disk Images") {
|
||||
// Handle developer disk images
|
||||
|
||||
Reference in New Issue
Block a user