-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMSEnumerator.cpp
More file actions
73 lines (63 loc) · 2.12 KB
/
Copy pathMSEnumerator.cpp
File metadata and controls
73 lines (63 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "StdAfx.h"
#include "MSEnumerator.h"
#include "AutoCriticalSection.h"
#include "EnumDisks.h"
using namespace DeviceDetectLibrary;
using namespace DeviceDetectLibrary::Connection;
CMSEnumerator::CMSEnumerator(ICollector& collector)
: collector_(collector)
{
}
CMSEnumerator::~CMSEnumerator(void)
{
}
void CMSEnumerator::TryThis(const std::wstring& devicePath)
{
CAutoCriticalSection lock(sec_);
if(checkers_.count(devicePath) == 0)
{
CMSChecker::Pointer pMSChecker = CMSChecker::Create(collector_, devicePath);
checkers_.insert(std::make_pair(devicePath, pMSChecker));
//checkers_[devicePath] = pMSChecker;
}
// Cancel previous process
checkers_[devicePath]->Stop();
// Begin new process
checkers_[devicePath]->Start();
}
void CMSEnumerator::RemoveThis(const std::wstring& devicePath)
{
CAutoCriticalSection lock(sec_);
if(checkers_.count(devicePath) != 0)
{
checkers_.erase(devicePath);
}
}
void CMSEnumerator::Collect(const CDeviceInfo::Pointer& pDeviceInfo)
{
try
{
Disk::Types::RemovableDeviceInfo_vt vctDisks;
Disk::Functions::SearchRemovalDisks(vctDisks);
for(Disk::Types::RemovableDeviceInfo_vt_cit iter = vctDisks.begin(); iter != vctDisks.end(); ++iter)
{
CConnectionInfo::Pointer pConnectionInfo = CConnectionInfo::Create();
pConnectionInfo->Type = TypeUnknown;
pConnectionInfo->FriendlyName = iter->wsFriendlyName;
pConnectionInfo->DevicePath = iter->wsDevInterfaceVolume;
pConnectionInfo->HardwareID = iter->wsHardwareID;
pConnectionInfo->PhysicalDeviceName = iter->wsEnumeratorName;
pConnectionInfo->DeviceDescription = iter->wsDeviceDesc;
pConnectionInfo->ServiceName = iter->wsCompatibleIDs;
//ConnectionInfo info = {TypeUnknown, iter->wsFriendlyName, iter->wsDevInterfaceVolume,
// iter->wsHardwareID, iter->wsEnumeratorName, iter->wsDeviceDesc, iter->wsCompatibleIDs};
CDeviceInfo::Pointer pDevice = CDeviceInfo::Create(iter->wsHardwareID, iter->wsFriendlyName, L"Mass Storage device", pConnectionInfo);
collector_.Found(pDevice);
}
}
catch(const std::exception& ex)
{
ex.what();
// EXCEPTION: Cannot do SearchRemovalDisks(). Error = %s", ex.what());
}
}