diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f1180acec..c214fe1c3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -562,6 +562,7 @@ IF(WIN32)
list(APPEND SOURCES devices/wmdmdevice.cpp)
list(APPEND SOURCES devices/wmdmlister.cpp)
list(APPEND SOURCES devices/wmdmloader.cpp)
+ list(APPEND SOURCES devices/wmdmprogress.cpp)
list(APPEND SOURCES devices/wmdmthread.cpp)
list(APPEND HEADERS devices/wmdmdevice.h)
diff --git a/src/devices/wmdmdevice.cpp b/src/devices/wmdmdevice.cpp
index 605c38c6f..7bb21b645 100644
--- a/src/devices/wmdmdevice.cpp
+++ b/src/devices/wmdmdevice.cpp
@@ -18,6 +18,7 @@
#include "wmdmdevice.h"
#include "wmdmlister.h"
#include "wmdmloader.h"
+#include "wmdmprogress.h"
#include "wmdmthread.h"
#include "core/utilities.h"
#include "library/librarybackend.h"
@@ -95,11 +96,13 @@ bool WmdmDevice::CopyToStorage(
storage_->CreateEmptyMetadataObject(&metadata_iface);
song.ToWmdm(metadata_iface);
-
// Convert the filenames to wchars
ScopedWCharArray source_filename(QDir::toNativeSeparators(source));
ScopedWCharArray dest_filename(song.basefilename());
+ // Create the progress object
+ WmdmProgress progress;
+
// Copy the file
IWMDMStorage* new_storage = NULL;
if (storage_control_->Insert3(
@@ -109,7 +112,7 @@ bool WmdmDevice::CopyToStorage(
source_filename,
dest_filename,
NULL, // operation
- NULL, // progress
+ &progress, // progress
metadata_iface,
NULL, // data
&new_storage)) {
@@ -119,6 +122,9 @@ bool WmdmDevice::CopyToStorage(
}
metadata_iface->Release();
+ if (!new_storage)
+ return false;
+
// Get the metadata from the newly copied file
IWMDMStorage3* new_storage3 = NULL;
IWMDMMetaData* new_metadata = NULL;
@@ -129,6 +135,9 @@ bool WmdmDevice::CopyToStorage(
new_storage->Release();
new_storage3->Release();
+ if (!new_metadata)
+ return false;
+
// Add it to our LibraryModel
Song new_song;
new_song.InitFromWmdm(new_metadata);
diff --git a/src/devices/wmdmprogress.cpp b/src/devices/wmdmprogress.cpp
new file mode 100644
index 000000000..e65d47ab6
--- /dev/null
+++ b/src/devices/wmdmprogress.cpp
@@ -0,0 +1,79 @@
+/* This file is part of Clementine.
+
+ Clementine is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Clementine is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Clementine. If not, see .
+*/
+
+#include "wmdmprogress.h"
+
+#include
+
+WmdmProgress::WmdmProgress()
+{
+}
+
+LONG WmdmProgress::QueryInterface(const IID& riid, void** object) {
+ *object = 0;
+
+ if (riid == IID_IUnknown)
+ *object = (IUnknown*) this;
+ else if (riid == IID_IWMDMProgress)
+ *object = (IWMDMProgress*) this;
+ else if (riid == IID_IWMDMProgress2)
+ *object = (IWMDMProgress2*) this;
+ else if (riid == IID_IWMDMProgress3)
+ *object = (IWMDMProgress3*) this;
+ else
+ return E_NOINTERFACE;
+
+ return S_OK;
+}
+
+ULONG WmdmProgress::AddRef() {
+ return 0;
+}
+
+ULONG WmdmProgress::Release() {
+ return 0;
+}
+
+HRESULT WmdmProgress::Begin(DWORD estimated_ticks) {
+ return Begin3(EVENT_WMDM_CONTENT_TRANSFER, estimated_ticks, NULL);
+}
+
+HRESULT WmdmProgress::End() {
+ return End3(EVENT_WMDM_CONTENT_TRANSFER, S_OK, NULL);
+}
+
+HRESULT WmdmProgress::Progress(DWORD transpired_ticks) {
+ return Progress3(EVENT_WMDM_CONTENT_TRANSFER, transpired_ticks, NULL);
+}
+
+HRESULT WmdmProgress::End2(HRESULT completion_code) {
+ return End3(EVENT_WMDM_CONTENT_TRANSFER, completion_code, NULL);
+}
+
+HRESULT WmdmProgress::Begin3(GUID event_id, DWORD estimated_ticks, OPAQUECOMMAND* context) {
+ qDebug() << Q_FUNC_INFO << estimated_ticks;
+ return S_OK;
+}
+
+HRESULT WmdmProgress::End3(GUID event_id, HRESULT completion_code, OPAQUECOMMAND* context) {
+ qDebug() << Q_FUNC_INFO << completion_code;
+ return S_OK;
+}
+
+HRESULT WmdmProgress::Progress3(GUID event_id, DWORD transpired_ticks, OPAQUECOMMAND* context) {
+ qDebug() << Q_FUNC_INFO << transpired_ticks;
+ return S_OK;
+}
diff --git a/src/devices/wmdmprogress.h b/src/devices/wmdmprogress.h
new file mode 100644
index 000000000..b527b3a47
--- /dev/null
+++ b/src/devices/wmdmprogress.h
@@ -0,0 +1,49 @@
+/* This file is part of Clementine.
+
+ Clementine is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Clementine is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Clementine. If not, see .
+*/
+
+#ifndef WMDMPROGRESS_H
+#define WMDMPROGRESS_H
+
+#include
+
+class WmdmProgress : public IWMDMProgress3 {
+public:
+ WmdmProgress();
+
+ // IUnknown
+ // The __stdcall is *really* important
+ virtual LONG __stdcall QueryInterface(const IID& riid, void** object);
+ virtual ULONG __stdcall AddRef();
+ virtual ULONG __stdcall Release();
+
+ // IWMDMProgress
+ virtual HRESULT __stdcall Begin(DWORD estimated_ticks);
+ virtual HRESULT __stdcall End();
+ virtual HRESULT __stdcall Progress(DWORD transpired_ticks);
+
+ // IWMDMProgress2
+ virtual HRESULT __stdcall End2(HRESULT completion_code);
+
+ // IWMDMProgress3
+ virtual HRESULT __stdcall Begin3(GUID event_id, DWORD estimated_ticks,
+ OPAQUECOMMAND* context);
+ virtual HRESULT __stdcall End3(GUID event_id, HRESULT completion_code,
+ OPAQUECOMMAND* context);
+ virtual HRESULT __stdcall Progress3(GUID event_id, DWORD transpired_ticks,
+ OPAQUECOMMAND* context);
+};
+
+#endif // WMDMPROGRESS_H