Properly shut down the WMDM lister
This commit is contained in:
parent
6790b43e62
commit
8c3b16a93d
@ -57,6 +57,7 @@ public:
|
||||
|
||||
public slots:
|
||||
virtual void UpdateDeviceFreeSpace(const QString& id) = 0;
|
||||
virtual void ShutDown() {}
|
||||
|
||||
signals:
|
||||
void DeviceAdded(const QString& id);
|
||||
|
@ -201,7 +201,13 @@ DeviceManager::DeviceManager(BackgroundThread<Database>* database,
|
||||
}
|
||||
|
||||
DeviceManager::~DeviceManager() {
|
||||
qDeleteAll(listers_);
|
||||
foreach (DeviceLister* lister, listers_) {
|
||||
// Let the lister close itself down
|
||||
metaObject()->invokeMethod(lister, "ShutDown", Qt::BlockingQueuedConnection);
|
||||
|
||||
delete lister;
|
||||
}
|
||||
|
||||
backend_->deleteLater();
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,6 @@
|
||||
|
||||
#include <icomponentauthenticate.h>
|
||||
#include <objbase.h>
|
||||
#include <sac_shim.h>
|
||||
#include <mswmdm.h>
|
||||
#include <mswmdm_i.c>
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
@ -54,15 +52,15 @@ void WmdmLister::Init() {
|
||||
return;
|
||||
}
|
||||
|
||||
SacHandle sac = CSecureChannelClient_New();
|
||||
sac_ = CSecureChannelClient_New();
|
||||
if (CSecureChannelClient_SetCertificate(
|
||||
sac, SAC_CERT_V1, abCert, sizeof(abCert), abPVK, sizeof(abPVK))) {
|
||||
sac_, SAC_CERT_V1, abCert, sizeof(abCert), abPVK, sizeof(abPVK))) {
|
||||
qWarning() << "Error setting SAC certificate";
|
||||
return;
|
||||
}
|
||||
|
||||
CSecureChannelClient_SetInterface(sac, auth);
|
||||
if (CSecureChannelClient_Authenticate(sac, SAC_PROTOCOL_V1)) {
|
||||
CSecureChannelClient_SetInterface(sac_, auth);
|
||||
if (CSecureChannelClient_Authenticate(sac_, SAC_PROTOCOL_V1)) {
|
||||
qWarning() << "Error authenticating with SAC";
|
||||
return;
|
||||
}
|
||||
@ -120,6 +118,27 @@ void WmdmLister::Init() {
|
||||
}
|
||||
}
|
||||
|
||||
void WmdmLister::ShutDown() {
|
||||
// Unregister for notifications
|
||||
IConnectionPointContainer* cp_container;
|
||||
device_manager_->QueryInterface(IID_IConnectionPointContainer, (void**)&cp_container);
|
||||
|
||||
IConnectionPoint* cp;
|
||||
cp_container->FindConnectionPoint(IID_IWMDMNotification, &cp);
|
||||
|
||||
cp->Release();
|
||||
cp_container->Release();
|
||||
|
||||
// Release the device manager
|
||||
device_manager_->Release();
|
||||
|
||||
// SAC
|
||||
CSecureChannelClient_Free(sac_);
|
||||
|
||||
// Uninitialise COM
|
||||
CoUninitialize();
|
||||
}
|
||||
|
||||
template <typename F>
|
||||
qint64 GetSpaceValue(F f) {
|
||||
DWORD low, high;
|
||||
|
@ -28,6 +28,7 @@ struct IWMDeviceManager;
|
||||
#include <QPixmap>
|
||||
|
||||
#include <mswmdm.h>
|
||||
#include <sac_shim.h>
|
||||
|
||||
#undef LoadIcon
|
||||
|
||||
@ -60,6 +61,7 @@ public:
|
||||
|
||||
public slots:
|
||||
virtual void UpdateDeviceFreeSpace(const QString& id);
|
||||
virtual void ShutDown();
|
||||
|
||||
private:
|
||||
struct DeviceInfo {
|
||||
@ -89,6 +91,7 @@ private:
|
||||
|
||||
private:
|
||||
IWMDeviceManager* device_manager_;
|
||||
SacHandle sac_;
|
||||
DWORD notification_cookie_;
|
||||
|
||||
QMutex mutex_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user