qmgr: Implement IBackgroundCopyJob::SetDescription().

This commit is contained in:
Nikolay Sivov 2013-11-25 10:42:31 +04:00 committed by Alexandre Julliard
parent d5b0232b04
commit eeb05e6ef9
2 changed files with 43 additions and 8 deletions

View File

@ -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;

View File

@ -36,6 +36,7 @@ typedef struct
IBackgroundCopyJob2 IBackgroundCopyJob2_iface;
LONG ref;
LPWSTR displayName;
LPWSTR description;
BG_JOB_TYPE type;
GUID jobId;
struct list files;