mstask: Implement (Set|Get)Parameters.
This commit is contained in:
parent
aec0eb87de
commit
2f95e5123b
|
@ -59,6 +59,7 @@ typedef struct
|
|||
LONG ref;
|
||||
LPWSTR taskName;
|
||||
LPWSTR applicationName;
|
||||
LPWSTR parameters;
|
||||
} TaskImpl;
|
||||
extern HRESULT TaskConstructor(LPCWSTR pwszTaskName, LPVOID *ppObj);
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ static inline TaskImpl *impl_from_IPersistFile( IPersistFile *iface )
|
|||
static void TaskDestructor(TaskImpl *This)
|
||||
{
|
||||
TRACE("%p\n", This);
|
||||
HeapFree(GetProcessHeap(), 0, This->parameters);
|
||||
HeapFree(GetProcessHeap(), 0, This->taskName);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
InterlockedDecrement(&dll_ref);
|
||||
|
@ -403,16 +404,51 @@ static HRESULT WINAPI MSTASK_ITask_SetParameters(
|
|||
ITask* iface,
|
||||
LPCWSTR pwszParameters)
|
||||
{
|
||||
FIXME("(%p, %s): stub\n", iface, debugstr_w(pwszParameters));
|
||||
return E_NOTIMPL;
|
||||
DWORD n;
|
||||
TaskImpl *This = (TaskImpl *)iface;
|
||||
LPWSTR tmp_parameters;
|
||||
|
||||
TRACE("(%p, %s)\n", iface, debugstr_w(pwszParameters));
|
||||
|
||||
/* Empty parameter list */
|
||||
if (pwszParameters[0] == 0)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, This->parameters);
|
||||
This->parameters = NULL;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/* Set to pwszParameters */
|
||||
n = (lstrlenW(pwszParameters) + 1);
|
||||
tmp_parameters = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR));
|
||||
if (!tmp_parameters)
|
||||
return E_OUTOFMEMORY;
|
||||
lstrcpyW(tmp_parameters, pwszParameters);
|
||||
HeapFree(GetProcessHeap(), 0, This->parameters);
|
||||
This->parameters = tmp_parameters;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI MSTASK_ITask_GetParameters(
|
||||
ITask* iface,
|
||||
LPWSTR *ppwszParameters)
|
||||
{
|
||||
FIXME("(%p, %p): stub\n", iface, ppwszParameters);
|
||||
return E_NOTIMPL;
|
||||
DWORD n;
|
||||
TaskImpl *This = (TaskImpl *)iface;
|
||||
|
||||
TRACE("(%p, %p)\n", iface, ppwszParameters);
|
||||
|
||||
n = This->parameters ? lstrlenW(This->parameters) + 1 : 1;
|
||||
*ppwszParameters = CoTaskMemAlloc(n * sizeof(WCHAR));
|
||||
if (!*ppwszParameters)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
if (!This->parameters)
|
||||
*ppwszParameters[0] = 0;
|
||||
else
|
||||
lstrcpyW(*ppwszParameters, This->parameters);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI MSTASK_ITask_SetWorkingDirectory(
|
||||
|
@ -645,6 +681,7 @@ HRESULT TaskConstructor(LPCWSTR pwszTaskName, LPVOID *ppObj)
|
|||
}
|
||||
lstrcpyW(This->taskName, pwszTaskName);
|
||||
This->applicationName = NULL;
|
||||
This->parameters = NULL;
|
||||
|
||||
*ppObj = &This->lpVtbl;
|
||||
InterlockedIncrement(&dll_ref);
|
||||
|
|
|
@ -249,49 +249,49 @@ static void test_SetParameters_GetParameters(void)
|
|||
|
||||
/* Get parameters before setting them */
|
||||
hres = ITask_GetParameters(test_task, ¶meters);
|
||||
todo_wine ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
|
||||
ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
todo_wine ok(!lstrcmpW(parameters, empty),
|
||||
ok(!lstrcmpW(parameters, empty),
|
||||
"Got %s, expected empty string\n", dbgstr_w(parameters));
|
||||
CoTaskMemFree(parameters);
|
||||
}
|
||||
|
||||
/* Set parameters to a simple string */
|
||||
hres = ITask_SetParameters(test_task, parameters_a);
|
||||
todo_wine ok(hres == S_OK, "Failed setting parameters %s: %08x\n",
|
||||
ok(hres == S_OK, "Failed setting parameters %s: %08x\n",
|
||||
dbgstr_w(parameters_a), hres);
|
||||
hres = ITask_GetParameters(test_task, ¶meters);
|
||||
todo_wine ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
|
||||
ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
todo_wine ok(!lstrcmpW(parameters, parameters_a), "Got %s, expected %s\n",
|
||||
ok(!lstrcmpW(parameters, parameters_a), "Got %s, expected %s\n",
|
||||
dbgstr_w(parameters), dbgstr_w(parameters_a));
|
||||
CoTaskMemFree(parameters);
|
||||
}
|
||||
|
||||
/* Update parameters to a different simple string */
|
||||
hres = ITask_SetParameters(test_task, parameters_b);
|
||||
todo_wine ok(hres == S_OK, "Failed setting parameters %s: %08x\n",
|
||||
ok(hres == S_OK, "Failed setting parameters %s: %08x\n",
|
||||
dbgstr_w(parameters_b), hres);
|
||||
hres = ITask_GetParameters(test_task, ¶meters);
|
||||
todo_wine ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
|
||||
ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
todo_wine ok(!lstrcmpW(parameters, parameters_b), "Got %s, expected %s\n",
|
||||
ok(!lstrcmpW(parameters, parameters_b), "Got %s, expected %s\n",
|
||||
dbgstr_w(parameters), dbgstr_w(parameters_b));
|
||||
CoTaskMemFree(parameters);
|
||||
}
|
||||
|
||||
/* Clear parameters */
|
||||
hres = ITask_SetParameters(test_task, empty);
|
||||
todo_wine ok(hres == S_OK, "Failed setting parameters %s: %08x\n",
|
||||
ok(hres == S_OK, "Failed setting parameters %s: %08x\n",
|
||||
dbgstr_w(empty), hres);
|
||||
hres = ITask_GetParameters(test_task, ¶meters);
|
||||
todo_wine ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
|
||||
ok(hres == S_OK, "GetParameters failed: %08x\n", hres);
|
||||
if (hres == S_OK)
|
||||
{
|
||||
todo_wine ok(!lstrcmpW(parameters, empty),
|
||||
ok(!lstrcmpW(parameters, empty),
|
||||
"Got %s, expected empty string\n", dbgstr_w(parameters));
|
||||
CoTaskMemFree(parameters);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue