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