mstask: Implement setting and getting a task comment using IExecAction.
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
04e240b3a7
commit
52df130d29
|
@ -39,7 +39,6 @@ typedef struct
|
||||||
ITaskDefinition *task;
|
ITaskDefinition *task;
|
||||||
IExecAction *action;
|
IExecAction *action;
|
||||||
LPWSTR task_name;
|
LPWSTR task_name;
|
||||||
LPWSTR comment;
|
|
||||||
DWORD maxRunTime;
|
DWORD maxRunTime;
|
||||||
LPWSTR accountName;
|
LPWSTR accountName;
|
||||||
} TaskImpl;
|
} TaskImpl;
|
||||||
|
@ -62,7 +61,6 @@ static void TaskDestructor(TaskImpl *This)
|
||||||
ITaskDefinition_Release(This->task);
|
ITaskDefinition_Release(This->task);
|
||||||
HeapFree(GetProcessHeap(), 0, This->task_name);
|
HeapFree(GetProcessHeap(), 0, This->task_name);
|
||||||
HeapFree(GetProcessHeap(), 0, This->accountName);
|
HeapFree(GetProcessHeap(), 0, This->accountName);
|
||||||
HeapFree(GetProcessHeap(), 0, This->comment);
|
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
InterlockedDecrement(&dll_ref);
|
InterlockedDecrement(&dll_ref);
|
||||||
}
|
}
|
||||||
|
@ -247,56 +245,45 @@ static HRESULT WINAPI MSTASK_ITask_GetExitCode(
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI MSTASK_ITask_SetComment(
|
static HRESULT WINAPI MSTASK_ITask_SetComment(ITask *iface, LPCWSTR comment)
|
||||||
ITask* iface,
|
|
||||||
LPCWSTR pwszComment)
|
|
||||||
{
|
{
|
||||||
DWORD n;
|
|
||||||
TaskImpl *This = impl_from_ITask(iface);
|
TaskImpl *This = impl_from_ITask(iface);
|
||||||
LPWSTR tmp_comment;
|
|
||||||
|
|
||||||
TRACE("(%p, %s)\n", iface, debugstr_w(pwszComment));
|
TRACE("(%p, %s)\n", iface, debugstr_w(comment));
|
||||||
|
|
||||||
/* Empty comment */
|
if (!comment || !comment[0])
|
||||||
if (pwszComment[0] == 0)
|
comment = NULL;
|
||||||
{
|
|
||||||
HeapFree(GetProcessHeap(), 0, This->comment);
|
|
||||||
This->comment = NULL;
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set to pwszComment */
|
return IExecAction_put_Id(This->action, (BSTR)comment);
|
||||||
n = (lstrlenW(pwszComment) + 1);
|
|
||||||
tmp_comment = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR));
|
|
||||||
if (!tmp_comment)
|
|
||||||
return E_OUTOFMEMORY;
|
|
||||||
lstrcpyW(tmp_comment, pwszComment);
|
|
||||||
HeapFree(GetProcessHeap(), 0, This->comment);
|
|
||||||
This->comment = tmp_comment;
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI MSTASK_ITask_GetComment(
|
static HRESULT WINAPI MSTASK_ITask_GetComment(ITask *iface, LPWSTR *comment)
|
||||||
ITask* iface,
|
|
||||||
LPWSTR *ppwszComment)
|
|
||||||
{
|
{
|
||||||
DWORD n;
|
|
||||||
TaskImpl *This = impl_from_ITask(iface);
|
TaskImpl *This = impl_from_ITask(iface);
|
||||||
|
HRESULT hr;
|
||||||
|
BSTR id;
|
||||||
|
DWORD len;
|
||||||
|
|
||||||
TRACE("(%p, %p)\n", iface, ppwszComment);
|
TRACE("(%p, %p)\n", iface, comment);
|
||||||
|
|
||||||
n = This->comment ? lstrlenW(This->comment) + 1 : 1;
|
hr = IExecAction_get_Id(This->action, &id);
|
||||||
*ppwszComment = CoTaskMemAlloc(n * sizeof(WCHAR));
|
if (hr != S_OK) return hr;
|
||||||
if (!*ppwszComment)
|
|
||||||
return E_OUTOFMEMORY;
|
|
||||||
|
|
||||||
if (!This->comment)
|
len = id ? lstrlenW(id) + 1 : 1;
|
||||||
*ppwszComment[0] = 0;
|
*comment = CoTaskMemAlloc(len * sizeof(WCHAR));
|
||||||
|
if (*comment)
|
||||||
|
{
|
||||||
|
if (!id)
|
||||||
|
*comment[0] = 0;
|
||||||
|
else
|
||||||
|
lstrcpyW(*comment, id);
|
||||||
|
hr = S_OK;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
lstrcpyW(*ppwszComment, This->comment);
|
hr = E_OUTOFMEMORY;
|
||||||
|
|
||||||
return S_OK;
|
SysFreeString(id);
|
||||||
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI MSTASK_ITask_SetCreator(
|
static HRESULT WINAPI MSTASK_ITask_SetCreator(
|
||||||
|
@ -798,7 +785,6 @@ HRESULT TaskConstructor(ITaskService *service, const WCHAR *task_name, ITask **t
|
||||||
This->ref = 1;
|
This->ref = 1;
|
||||||
This->task = taskdef;
|
This->task = taskdef;
|
||||||
This->task_name = heap_strdupW(task_name);
|
This->task_name = heap_strdupW(task_name);
|
||||||
This->comment = NULL;
|
|
||||||
This->accountName = NULL;
|
This->accountName = NULL;
|
||||||
|
|
||||||
/* Default time is 3 days = 259200000 ms */
|
/* Default time is 3 days = 259200000 ms */
|
||||||
|
|
Loading…
Reference in New Issue