Make sure device is valid before adding it
This commit is contained in:
@@ -65,6 +65,8 @@ void iLister::EventCallback(const idevice_event_t *event, void *context) {
|
|||||||
void iLister::DeviceAddedCallback(const char *uuid) {
|
void iLister::DeviceAddedCallback(const char *uuid) {
|
||||||
|
|
||||||
DeviceInfo info = ReadDeviceInfo(uuid);
|
DeviceInfo info = ReadDeviceInfo(uuid);
|
||||||
|
if (!info.valid) return;
|
||||||
|
|
||||||
QString id = UniqueId(uuid);
|
QString id = UniqueId(uuid);
|
||||||
|
|
||||||
QString name = MakeFriendlyName(id);
|
QString name = MakeFriendlyName(id);
|
||||||
@@ -196,6 +198,8 @@ iLister::DeviceInfo iLister::ReadDeviceInfo(const char *uuid) {
|
|||||||
DeviceInfo ret;
|
DeviceInfo ret;
|
||||||
|
|
||||||
iMobileDeviceConnection conn(uuid);
|
iMobileDeviceConnection conn(uuid);
|
||||||
|
if (!conn.is_valid()) return ret;
|
||||||
|
ret.valid = conn.is_valid();
|
||||||
ret.uuid = uuid;
|
ret.uuid = uuid;
|
||||||
ret.product_type = conn.GetProperty("ProductType").toString();
|
ret.product_type = conn.GetProperty("ProductType").toString();
|
||||||
ret.free_bytes = conn.GetProperty("AmountDataAvailable", "com.apple.disk_usage").toULongLong();
|
ret.free_bytes = conn.GetProperty("AmountDataAvailable", "com.apple.disk_usage").toULongLong();
|
||||||
|
|||||||
@@ -59,7 +59,9 @@ class iLister : public DeviceLister {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
struct DeviceInfo {
|
struct DeviceInfo {
|
||||||
DeviceInfo() : free_bytes(0), total_bytes(0) {}
|
DeviceInfo() : valid(false), free_bytes(0), total_bytes(0) {}
|
||||||
|
|
||||||
|
bool valid;
|
||||||
|
|
||||||
QString uuid;
|
QString uuid;
|
||||||
QString product_type;
|
QString product_type;
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ public:
|
|||||||
|
|
||||||
QString GetUnusedFilename(Itdb_iTunesDB *itdb, const Song &metadata);
|
QString GetUnusedFilename(Itdb_iTunesDB *itdb, const Song &metadata);
|
||||||
|
|
||||||
|
bool is_valid() { return device_ && afc_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(iMobileDeviceConnection);
|
Q_DISABLE_COPY(iMobileDeviceConnection);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user