Commit eeb05e6e authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

qmgr: Implement IBackgroundCopyJob::SetDescription().

parent d5b0232b
......@@ -25,9 +25,15 @@
#include "qmgr.h"
#include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
static inline BOOL is_job_done(const BackgroundCopyJobImpl *job)
{
return job->state == BG_JOB_STATE_CANCELLED || job->state == BG_JOB_STATE_ACKNOWLEDGED;
}
static inline BackgroundCopyJobImpl *impl_from_IBackgroundCopyJob2(IBackgroundCopyJob2 *iface)
{
return CONTAINING_RECORD(iface, BackgroundCopyJobImpl, IBackgroundCopyJob2_iface);
......@@ -73,6 +79,7 @@ static ULONG WINAPI BITS_IBackgroundCopyJob_Release(IBackgroundCopyJob2 *iface)
This->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&This->cs);
HeapFree(GetProcessHeap(), 0, This->displayName);
HeapFree(GetProcessHeap(), 0, This->description);
HeapFree(GetProcessHeap(), 0, This);
}
......@@ -147,8 +154,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_Resume(
HRESULT rv = S_OK;
EnterCriticalSection(&globalMgr.cs);
if (This->state == BG_JOB_STATE_CANCELLED
|| This->state == BG_JOB_STATE_ACKNOWLEDGED)
if (is_job_done(This))
{
rv = BG_E_INVALID_STATE;
}
......@@ -182,8 +188,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_Complete(
EnterCriticalSection(&This->cs);
if (This->state == BG_JOB_STATE_CANCELLED
|| This->state == BG_JOB_STATE_ACKNOWLEDGED)
if (is_job_done(This))
{
rv = BG_E_INVALID_STATE;
}
......@@ -313,7 +318,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_GetDisplayName(
if (!pVal)
return E_INVALIDARG;
n = (lstrlenW(This->displayName) + 1) * sizeof **pVal;
n = (strlenW(This->displayName) + 1) * sizeof **pVal;
*pVal = CoTaskMemAlloc(n);
if (*pVal == NULL)
return E_OUTOFMEMORY;
......@@ -325,8 +330,36 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_SetDescription(
IBackgroundCopyJob2 *iface,
LPCWSTR Val)
{
FIXME("Not implemented\n");
return E_NOTIMPL;
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
static const int max_description_len = 1024;
HRESULT hr = S_OK;
int len;
TRACE("(%p)->(%s)\n", This, debugstr_w(Val));
if (!Val) return E_INVALIDARG;
len = strlenW(Val);
if (len > max_description_len) return BG_E_STRING_TOO_LONG;
EnterCriticalSection(&This->cs);
if (is_job_done(This))
{
hr = BG_E_INVALID_STATE;
}
else
{
HeapFree(GetProcessHeap(), 0, This->description);
if ((This->description = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR))))
strcpyW(This->description, Val);
else
hr = E_OUTOFMEMORY;
}
LeaveCriticalSection(&This->cs);
return hr;
}
static HRESULT WINAPI BITS_IBackgroundCopyJob_GetDescription(
......@@ -588,7 +621,7 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID
This->ref = 1;
This->type = type;
n = (lstrlenW(displayName) + 1) * sizeof *displayName;
n = (strlenW(displayName) + 1) * sizeof *displayName;
This->displayName = HeapAlloc(GetProcessHeap(), 0, n);
if (!This->displayName)
{
......@@ -617,6 +650,7 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID
This->jobProgress.FilesTransferred = 0;
This->state = BG_JOB_STATE_SUSPENDED;
This->description = NULL;
*job = This;
return S_OK;
......
......@@ -36,6 +36,7 @@ typedef struct
IBackgroundCopyJob2 IBackgroundCopyJob2_iface;
LONG ref;
LPWSTR displayName;
LPWSTR description;
BG_JOB_TYPE type;
GUID jobId;
struct list files;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment