Module: wine Branch: master Commit: eeb05e6ef98d7bb5cade2eda82640846ebb18c11 URL: http://source.winehq.org/git/wine.git/?a=commit;h=eeb05e6ef98d7bb5cade2eda82...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Mon Nov 25 10:42:31 2013 +0400
qmgr: Implement IBackgroundCopyJob::SetDescription().
---
dlls/qmgr/job.c | 50 ++++++++++++++++++++++++++++++++++++++++++-------- dlls/qmgr/qmgr.h | 1 + 2 files changed, 43 insertions(+), 8 deletions(-)
diff --git a/dlls/qmgr/job.c b/dlls/qmgr/job.c index 4abf220..a395ec6 100644 --- a/dlls/qmgr/job.c +++ b/dlls/qmgr/job.c @@ -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; diff --git a/dlls/qmgr/qmgr.h b/dlls/qmgr/qmgr.h index 215c200..1f64d41 100644 --- a/dlls/qmgr/qmgr.h +++ b/dlls/qmgr/qmgr.h @@ -36,6 +36,7 @@ typedef struct IBackgroundCopyJob2 IBackgroundCopyJob2_iface; LONG ref; LPWSTR displayName; + LPWSTR description; BG_JOB_TYPE type; GUID jobId; struct list files;