diff options
| author | Dave Wilson <[email protected]> | 2015-03-17 19:50:07 -0700 |
|---|---|---|
| committer | Dave Wilson <[email protected]> | 2015-03-17 19:50:07 -0700 |
| commit | 97cf5197cf5b882b2c689d8dc2b555f2edf8f418 (patch) | |
| tree | 46f3701832d70b420eb0fc0eb93261f9da45db3f /wpd/WpdWudfSampleDriver/WpdStorage.cpp | |
| parent | ef1905bf1e8825bb31120dfb27e0daf3154d859a (diff) | |
Initial publish
Diffstat (limited to 'wpd/WpdWudfSampleDriver/WpdStorage.cpp')
| -rw-r--r-- | wpd/WpdWudfSampleDriver/WpdStorage.cpp | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/wpd/WpdWudfSampleDriver/WpdStorage.cpp b/wpd/WpdWudfSampleDriver/WpdStorage.cpp new file mode 100644 index 00000000..cb4e85c3 --- /dev/null +++ b/wpd/WpdWudfSampleDriver/WpdStorage.cpp @@ -0,0 +1,102 @@ +#include "stdafx.h" +#include "WpdStorage.tmh" + +WpdStorage::WpdStorage() +{ + +} + +WpdStorage::~WpdStorage() +{ + +} + +HRESULT WpdStorage::Initialize(_In_ FakeDevice *pFakeDevice) +{ + + HRESULT hr = S_OK; + + if(pFakeDevice == NULL) + { + hr = E_POINTER; + CHECK_HR(hr, "Cannot have NULL parameter"); + return hr; + } + m_pFakeDevice = pFakeDevice; + return hr; +} + + +HRESULT WpdStorage::DispatchWpdMessage(_In_ REFPROPERTYKEY Command, + _In_ IPortableDeviceValues* pParams, + _In_ IPortableDeviceValues* pResults) +{ + + HRESULT hr = S_OK; + + if (hr == S_OK) + { + if (Command.fmtid != WPD_CATEGORY_STORAGE) + { + hr = E_INVALIDARG; + CHECK_HR(hr, "This object does not support this command category %ws",CComBSTR(Command.fmtid)); + } + } + + if (hr == S_OK) + { + if (IsEqualPropertyKey(Command, WPD_COMMAND_STORAGE_FORMAT)) + { + hr = OnFormat(pParams, pResults); + CHECK_HR(hr, "Failed to format storage"); + } + else + { + hr = E_NOTIMPL; + CHECK_HR(hr, "This object does not support this command id %d", Command.pid); + } + } + return hr; +} + +/** + * This method is called when we receive a WPD_COMMAND_STORAGE_FORMAT + * command. + * + * The parameters sent to us are: + * - WPD_PROPERTY_STORAGE_OBJECT_ID: identifies the storage object to format. + * + * The driver should: + * - Format the storage identified by WPD_PROPERTY_STORAGE_OBJECT_ID. + */ +HRESULT WpdStorage::OnFormat( + _In_ IPortableDeviceValues* pParams, + _In_ IPortableDeviceValues* pResults) +{ + HRESULT hr = S_OK; + LPWSTR pszObjectID = NULL; + + UNREFERENCED_PARAMETER(pResults); + + // Get the Object ID + hr = pParams->GetStringValue(WPD_PROPERTY_STORAGE_OBJECT_ID, &pszObjectID); + if (hr != S_OK) + { + hr = E_INVALIDARG; + CHECK_HR(hr, "Missing string value for WPD_PROPERTY_STORAGE_OBJECT_ID"); + } + + // Format this storage + if (hr == S_OK) + { + hr = m_pFakeDevice->FormatStorage(pszObjectID, pParams); + CHECK_HR(hr, "Failed to process format command on [%ws]", pszObjectID); + } + + // Free the memory. CoTaskMemFree ignores NULLs so no need to check. + CoTaskMemFree(pszObjectID); + + return hr; +} + + |
