Update free space on WMDM devices
This commit is contained in:
parent
572a4730cb
commit
e779190b2f
|
@ -171,14 +171,7 @@ WmdmLister::DeviceInfo WmdmLister::ReadDeviceInfo(IWMDMDevice2* device) {
|
||||||
qWarning() << "Error getting IWMDMStorage2 from storage";
|
qWarning() << "Error getting IWMDMStorage2 from storage";
|
||||||
} else {
|
} else {
|
||||||
// Get free space information
|
// Get free space information
|
||||||
IWMDMStorageGlobals* globals;
|
UpdateFreeSpace(&ret);
|
||||||
ret.storage_->GetStorageGlobals(&globals);
|
|
||||||
|
|
||||||
ret.total_bytes_ = GetSpaceValue(boost::bind(&IWMDMStorageGlobals::GetTotalSize, globals, _1, _2));
|
|
||||||
ret.free_bytes_ = GetSpaceValue(boost::bind(&IWMDMStorageGlobals::GetTotalFree, globals, _1, _2));
|
|
||||||
ret.free_bytes_ -= GetSpaceValue(boost::bind(&IWMDMStorageGlobals::GetTotalBad, globals, _1, _2));
|
|
||||||
|
|
||||||
globals->Release();
|
|
||||||
}
|
}
|
||||||
storage->Release();
|
storage->Release();
|
||||||
}
|
}
|
||||||
|
@ -280,6 +273,33 @@ void WmdmLister::UnmountDevice(const QString& id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WmdmLister::UpdateDeviceFreeSpace(const QString& id) {
|
void WmdmLister::UpdateDeviceFreeSpace(const QString& id) {
|
||||||
|
// This needs to be done in the lister's thread where we already have COM
|
||||||
|
// initialised
|
||||||
|
metaObject()->invokeMethod(this, "DoUpdateDriveFreeSpace",
|
||||||
|
Qt::BlockingQueuedConnection, Q_ARG(QString, id));
|
||||||
|
}
|
||||||
|
|
||||||
|
void WmdmLister::DoUpdateDriveFreeSpace(const QString& id) {
|
||||||
|
{
|
||||||
|
QMutexLocker l(&mutex_);
|
||||||
|
if (!devices_.contains(id))
|
||||||
|
return;
|
||||||
|
|
||||||
|
UpdateFreeSpace(&devices_[id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
emit DeviceChanged(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WmdmLister::UpdateFreeSpace(DeviceInfo* info) {
|
||||||
|
IWMDMStorageGlobals* globals;
|
||||||
|
info->storage_->GetStorageGlobals(&globals);
|
||||||
|
|
||||||
|
info->total_bytes_ = GetSpaceValue(boost::bind(&IWMDMStorageGlobals::GetTotalSize, globals, _1, _2));
|
||||||
|
info->free_bytes_ = GetSpaceValue(boost::bind(&IWMDMStorageGlobals::GetTotalFree, globals, _1, _2));
|
||||||
|
info->free_bytes_ -= GetSpaceValue(boost::bind(&IWMDMStorageGlobals::GetTotalBad, globals, _1, _2));
|
||||||
|
|
||||||
|
globals->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT WmdmLister::WMDMMessage(DWORD message_type, LPCWSTR name) {
|
HRESULT WmdmLister::WMDMMessage(DWORD message_type, LPCWSTR name) {
|
||||||
|
|
|
@ -67,6 +67,7 @@ public slots:
|
||||||
virtual void ShutDown();
|
virtual void ShutDown();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
virtual void DoUpdateDriveFreeSpace(const QString& id);
|
||||||
virtual void ReallyShutdown();
|
virtual void ReallyShutdown();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -102,6 +103,8 @@ private:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T LockAndGetDeviceInfo(const QString& id, T DeviceInfo::*field);
|
T LockAndGetDeviceInfo(const QString& id, T DeviceInfo::*field);
|
||||||
|
|
||||||
|
void UpdateFreeSpace(DeviceInfo* info);
|
||||||
|
|
||||||
static QString CanonicalNameToId(const QString& canonical_name);
|
static QString CanonicalNameToId(const QString& canonical_name);
|
||||||
void WMDMDeviceAdded(const QString& canonical_name);
|
void WMDMDeviceAdded(const QString& canonical_name);
|
||||||
void WMDMDeviceRemoved(const QString& canonical_name);
|
void WMDMDeviceRemoved(const QString& canonical_name);
|
||||||
|
|
Loading…
Reference in New Issue