void WmdmLister::WMDMDeviceAdded(const QString& canonical_name) { ScopedWCharArray name(canonical_name); IWMDMDevice* device = NULL; if (thread_->manager()->GetDeviceFromCanonicalName(name, &device)) { qLog(Warning) << "Error in GetDeviceFromCanonicalName for" << canonical_name; return; } IWMDMDevice2* device2 = NULL; if (device->QueryInterface(IID_IWMDMDevice2, (void**) &device2)) { qLog(Warning) << "Error getting IWMDMDevice2 from device"; device->Release(); return; } device->Release(); DeviceInfo info = ReadDeviceInfo(device2); if (info.is_suitable_) { QString id = info.unique_id(); { QMutexLocker l(&mutex_); devices_[id] = info; } emit DeviceAdded(id); } else { device2->Release(); } }
int GainDRMInformation(char *MapPath, char *DRMRequestBuffer) { DRM_DATA_T *DRMData; int DRMDataCount = 0; DRM_FOLDER_T *DRMFolder; int DRMFolderCount = 0; char DeviceInfoType = DEVICE_INFO_TYPE_DEVINFO_BIN; char DeviceString[NORMAL_BUFF_SIZE]; char DevInfoPath[MIN_BUFF_SIZE]; char MapVersion[MAPVER_LEN+1]; memset(DeviceString, 0, NORMAL_BUFF_SIZE); memset(MapVersion, 0, MAPVER_LEN+1); sprintf(DevInfoPath, "%s/../devinfo.bin", MapPath); GetMapVersion(MapPath, MapVersion); if((DRMData = InitDRMData(MapPath, &DRMDataCount, MapVersion)) == NULL) { return DRM_ERR_DECODE; } if((DRMFolder = InitDRMFolder(MapPath, &DRMFolderCount)) == NULL) { return DRM_ERR_DECODE; } if(ReadDeviceInfo(DevInfoPath, DeviceString) != DRM_ERR_NONE) { if(MapVersion[DEVICE_CHECK_POSITION] == MAP_DEVICE_TW_PND || MapVersion[DEVICE_CHECK_POSITION] == MAP_DEVICE_TW_PND2) { sprintf(DevInfoPath, "%s/../../device.uid", MapPath); if(ReadDeviceInfo(DevInfoPath, DeviceString) != DRM_ERR_NONE) { free(DRMData); return DRM_ERR_NOFILE; } else { DeviceInfoType = DEVICE_INFO_TYPE_DEVICE_UID; } } else { free(DRMData); return DRM_ERR_NOFILE; } } MakeDRMRequestString(DeviceString, MapVersion, DRMData, DRMFolder, DRMDataCount, DRMFolderCount, DRMRequestBuffer, DeviceInfoType); free(DRMData); free(DRMFolder); D("Request String :: (%s)\n", DRMRequestBuffer); return DRM_ERR_NONE; }
void iLister::DeviceAddedCallback(const char* uuid) { DeviceInfo info = ReadDeviceInfo(uuid); QString id = UniqueId(uuid); QString name = MakeFriendlyName(id); if (info.product_type == "iPhone 3,1" || info.product_type.startsWith("iPad")) { // iPhone 4 and iPad unsupported by libgpod as of 0.7.94. return; } { QMutexLocker l(&mutex_); devices_[id] = info; } emit DeviceAdded(id); }
void WmdmLister::Init() { qLog(Debug) << "Starting"; thread_.reset(new WmdmThread); if (!thread_->manager()) return; // Register for notifications qLog(Debug) << "Obtaining CP container"; IConnectionPointContainer* cp_container = NULL; thread_->manager()->QueryInterface(IID_IConnectionPointContainer, (void**)&cp_container); qLog(Debug) << "Obtaining CP"; IConnectionPoint* cp = NULL; cp_container->FindConnectionPoint(IID_IWMDMNotification, &cp); qLog(Debug) << "Registering for notifications"; cp->Advise(this, ¬ification_cookie_); cp->Release(); cp_container->Release(); // Fetch the initial list of devices qLog(Debug) << "Fetching device list"; IWMDMEnumDevice* device_it = NULL; if (thread_->manager()->EnumDevices2(&device_it)) { qLog(Warning) << "Error querying WMDM devices"; return; } // Iterate through the devices QMap<QString, DeviceInfo> devices; forever { IWMDMDevice* device = NULL; IWMDMDevice2* device2 = NULL; ULONG fetched = 0; if (device_it->Next(1, &device, &fetched) || fetched != 1) break; qLog(Debug) << "Querying device"; if (device->QueryInterface(IID_IWMDMDevice2, (void**)&device2)) { qLog(Warning) << "Error getting IWMDMDevice2 from device"; device->Release(); continue; } device->Release(); DeviceInfo info = ReadDeviceInfo(device2); if (info.is_suitable_) devices[info.unique_id()] = info; else device2->Release(); } device_it->Release(); // Update the internal cache qLog(Debug) << "Updating device cache"; { QMutexLocker l(&mutex_); devices_ = devices; } // Notify about the changes foreach (const QString& id, devices.keys()) { emit DeviceAdded(id); } qLog(Debug) << "Startup complete"; }