mstask: Use ifaces instead of vtbl pointers in TaskImpl.
This commit is contained in:
parent
052de3f9a8
commit
591b59420d
|
@ -36,19 +36,6 @@ extern ClassFactoryImpl MSTASK_ClassFactory;
|
||||||
|
|
||||||
extern HRESULT TaskTriggerConstructor(LPVOID *ppObj);
|
extern HRESULT TaskTriggerConstructor(LPVOID *ppObj);
|
||||||
extern HRESULT TaskSchedulerConstructor(LPVOID *ppObj);
|
extern HRESULT TaskSchedulerConstructor(LPVOID *ppObj);
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
const ITaskVtbl *lpVtbl;
|
|
||||||
const IPersistFileVtbl *persistVtbl;
|
|
||||||
LONG ref;
|
|
||||||
LPWSTR taskName;
|
|
||||||
LPWSTR applicationName;
|
|
||||||
LPWSTR parameters;
|
|
||||||
LPWSTR comment;
|
|
||||||
DWORD maxRunTime;
|
|
||||||
LPWSTR accountName;
|
|
||||||
} TaskImpl;
|
|
||||||
extern HRESULT TaskConstructor(LPCWSTR pwszTaskName, LPVOID *ppObj);
|
extern HRESULT TaskConstructor(LPCWSTR pwszTaskName, LPVOID *ppObj);
|
||||||
|
|
||||||
#endif /* __MSTASK_PRIVATE_H__ */
|
#endif /* __MSTASK_PRIVATE_H__ */
|
||||||
|
|
|
@ -21,9 +21,27 @@
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(mstask);
|
WINE_DEFAULT_DEBUG_CHANNEL(mstask);
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ITask ITask_iface;
|
||||||
|
IPersistFile IPersistFile_iface;
|
||||||
|
LONG ref;
|
||||||
|
LPWSTR taskName;
|
||||||
|
LPWSTR applicationName;
|
||||||
|
LPWSTR parameters;
|
||||||
|
LPWSTR comment;
|
||||||
|
DWORD maxRunTime;
|
||||||
|
LPWSTR accountName;
|
||||||
|
} TaskImpl;
|
||||||
|
|
||||||
|
static inline TaskImpl *impl_from_ITask(ITask *iface)
|
||||||
|
{
|
||||||
|
return CONTAINING_RECORD(iface, TaskImpl, ITask_iface);
|
||||||
|
}
|
||||||
|
|
||||||
static inline TaskImpl *impl_from_IPersistFile( IPersistFile *iface )
|
static inline TaskImpl *impl_from_IPersistFile( IPersistFile *iface )
|
||||||
{
|
{
|
||||||
return (TaskImpl*) ((char*)(iface) - FIELD_OFFSET(TaskImpl, persistVtbl));
|
return CONTAINING_RECORD(iface, TaskImpl, IPersistFile_iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TaskDestructor(TaskImpl *This)
|
static void TaskDestructor(TaskImpl *This)
|
||||||
|
@ -42,7 +60,7 @@ static HRESULT WINAPI MSTASK_ITask_QueryInterface(
|
||||||
REFIID riid,
|
REFIID riid,
|
||||||
void **ppvObject)
|
void **ppvObject)
|
||||||
{
|
{
|
||||||
TaskImpl * This = (TaskImpl *)iface;
|
TaskImpl * This = impl_from_ITask(iface);
|
||||||
|
|
||||||
TRACE("IID: %s\n", debugstr_guid(riid));
|
TRACE("IID: %s\n", debugstr_guid(riid));
|
||||||
if (ppvObject == NULL)
|
if (ppvObject == NULL)
|
||||||
|
@ -51,13 +69,13 @@ static HRESULT WINAPI MSTASK_ITask_QueryInterface(
|
||||||
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
||||||
IsEqualGUID(riid, &IID_ITask))
|
IsEqualGUID(riid, &IID_ITask))
|
||||||
{
|
{
|
||||||
*ppvObject = &This->lpVtbl;
|
*ppvObject = &This->ITask_iface;
|
||||||
ITask_AddRef(iface);
|
ITask_AddRef(iface);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
else if (IsEqualGUID(riid, &IID_IPersistFile))
|
else if (IsEqualGUID(riid, &IID_IPersistFile))
|
||||||
{
|
{
|
||||||
*ppvObject = &This->persistVtbl;
|
*ppvObject = &This->IPersistFile_iface;
|
||||||
ITask_AddRef(iface);
|
ITask_AddRef(iface);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +88,7 @@ static HRESULT WINAPI MSTASK_ITask_QueryInterface(
|
||||||
static ULONG WINAPI MSTASK_ITask_AddRef(
|
static ULONG WINAPI MSTASK_ITask_AddRef(
|
||||||
ITask* iface)
|
ITask* iface)
|
||||||
{
|
{
|
||||||
TaskImpl *This = (TaskImpl *)iface;
|
TaskImpl *This = impl_from_ITask(iface);
|
||||||
ULONG ref;
|
ULONG ref;
|
||||||
TRACE("\n");
|
TRACE("\n");
|
||||||
ref = InterlockedIncrement(&This->ref);
|
ref = InterlockedIncrement(&This->ref);
|
||||||
|
@ -80,7 +98,7 @@ static ULONG WINAPI MSTASK_ITask_AddRef(
|
||||||
static ULONG WINAPI MSTASK_ITask_Release(
|
static ULONG WINAPI MSTASK_ITask_Release(
|
||||||
ITask* iface)
|
ITask* iface)
|
||||||
{
|
{
|
||||||
TaskImpl * This = (TaskImpl *)iface;
|
TaskImpl * This = impl_from_ITask(iface);
|
||||||
ULONG ref;
|
ULONG ref;
|
||||||
TRACE("\n");
|
TRACE("\n");
|
||||||
ref = InterlockedDecrement(&This->ref);
|
ref = InterlockedDecrement(&This->ref);
|
||||||
|
@ -222,7 +240,7 @@ static HRESULT WINAPI MSTASK_ITask_SetComment(
|
||||||
LPCWSTR pwszComment)
|
LPCWSTR pwszComment)
|
||||||
{
|
{
|
||||||
DWORD n;
|
DWORD n;
|
||||||
TaskImpl *This = (TaskImpl *)iface;
|
TaskImpl *This = impl_from_ITask(iface);
|
||||||
LPWSTR tmp_comment;
|
LPWSTR tmp_comment;
|
||||||
|
|
||||||
TRACE("(%p, %s)\n", iface, debugstr_w(pwszComment));
|
TRACE("(%p, %s)\n", iface, debugstr_w(pwszComment));
|
||||||
|
@ -252,7 +270,7 @@ static HRESULT WINAPI MSTASK_ITask_GetComment(
|
||||||
LPWSTR *ppwszComment)
|
LPWSTR *ppwszComment)
|
||||||
{
|
{
|
||||||
DWORD n;
|
DWORD n;
|
||||||
TaskImpl *This = (TaskImpl *)iface;
|
TaskImpl *This = impl_from_ITask(iface);
|
||||||
|
|
||||||
TRACE("(%p, %p)\n", iface, ppwszComment);
|
TRACE("(%p, %p)\n", iface, ppwszComment);
|
||||||
|
|
||||||
|
@ -357,7 +375,7 @@ static HRESULT WINAPI MSTASK_ITask_SetAccountInformation(
|
||||||
LPCWSTR pwszPassword)
|
LPCWSTR pwszPassword)
|
||||||
{
|
{
|
||||||
DWORD n;
|
DWORD n;
|
||||||
TaskImpl *This = (TaskImpl *)iface;
|
TaskImpl *This = impl_from_ITask(iface);
|
||||||
LPWSTR tmp_account_name;
|
LPWSTR tmp_account_name;
|
||||||
|
|
||||||
TRACE("(%p, %s, %s): partial stub\n", iface, debugstr_w(pwszAccountName),
|
TRACE("(%p, %s, %s): partial stub\n", iface, debugstr_w(pwszAccountName),
|
||||||
|
@ -381,7 +399,7 @@ static HRESULT WINAPI MSTASK_ITask_GetAccountInformation(
|
||||||
LPWSTR *ppwszAccountName)
|
LPWSTR *ppwszAccountName)
|
||||||
{
|
{
|
||||||
DWORD n;
|
DWORD n;
|
||||||
TaskImpl *This = (TaskImpl *)iface;
|
TaskImpl *This = impl_from_ITask(iface);
|
||||||
|
|
||||||
TRACE("(%p, %p): partial stub\n", iface, ppwszAccountName);
|
TRACE("(%p, %p): partial stub\n", iface, ppwszAccountName);
|
||||||
|
|
||||||
|
@ -403,7 +421,7 @@ static HRESULT WINAPI MSTASK_ITask_SetApplicationName(
|
||||||
LPCWSTR pwszApplicationName)
|
LPCWSTR pwszApplicationName)
|
||||||
{
|
{
|
||||||
DWORD n;
|
DWORD n;
|
||||||
TaskImpl *This = (TaskImpl *)iface;
|
TaskImpl *This = impl_from_ITask(iface);
|
||||||
LPWSTR tmp_name;
|
LPWSTR tmp_name;
|
||||||
|
|
||||||
TRACE("(%p, %s)\n", iface, debugstr_w(pwszApplicationName));
|
TRACE("(%p, %s)\n", iface, debugstr_w(pwszApplicationName));
|
||||||
|
@ -450,7 +468,7 @@ static HRESULT WINAPI MSTASK_ITask_GetApplicationName(
|
||||||
LPWSTR *ppwszApplicationName)
|
LPWSTR *ppwszApplicationName)
|
||||||
{
|
{
|
||||||
DWORD n;
|
DWORD n;
|
||||||
TaskImpl *This = (TaskImpl *)iface;
|
TaskImpl *This = impl_from_ITask(iface);
|
||||||
|
|
||||||
TRACE("(%p, %p)\n", iface, ppwszApplicationName);
|
TRACE("(%p, %p)\n", iface, ppwszApplicationName);
|
||||||
|
|
||||||
|
@ -472,7 +490,7 @@ static HRESULT WINAPI MSTASK_ITask_SetParameters(
|
||||||
LPCWSTR pwszParameters)
|
LPCWSTR pwszParameters)
|
||||||
{
|
{
|
||||||
DWORD n;
|
DWORD n;
|
||||||
TaskImpl *This = (TaskImpl *)iface;
|
TaskImpl *This = impl_from_ITask(iface);
|
||||||
LPWSTR tmp_parameters;
|
LPWSTR tmp_parameters;
|
||||||
|
|
||||||
TRACE("(%p, %s)\n", iface, debugstr_w(pwszParameters));
|
TRACE("(%p, %s)\n", iface, debugstr_w(pwszParameters));
|
||||||
|
@ -501,7 +519,7 @@ static HRESULT WINAPI MSTASK_ITask_GetParameters(
|
||||||
LPWSTR *ppwszParameters)
|
LPWSTR *ppwszParameters)
|
||||||
{
|
{
|
||||||
DWORD n;
|
DWORD n;
|
||||||
TaskImpl *This = (TaskImpl *)iface;
|
TaskImpl *This = impl_from_ITask(iface);
|
||||||
|
|
||||||
TRACE("(%p, %p)\n", iface, ppwszParameters);
|
TRACE("(%p, %p)\n", iface, ppwszParameters);
|
||||||
|
|
||||||
|
@ -570,7 +588,7 @@ static HRESULT WINAPI MSTASK_ITask_SetMaxRunTime(
|
||||||
ITask* iface,
|
ITask* iface,
|
||||||
DWORD dwMaxRunTime)
|
DWORD dwMaxRunTime)
|
||||||
{
|
{
|
||||||
TaskImpl *This = (TaskImpl *)iface;
|
TaskImpl *This = impl_from_ITask(iface);
|
||||||
|
|
||||||
TRACE("(%p, %d)\n", iface, dwMaxRunTime);
|
TRACE("(%p, %d)\n", iface, dwMaxRunTime);
|
||||||
|
|
||||||
|
@ -582,7 +600,7 @@ static HRESULT WINAPI MSTASK_ITask_GetMaxRunTime(
|
||||||
ITask* iface,
|
ITask* iface,
|
||||||
DWORD *pdwMaxRunTime)
|
DWORD *pdwMaxRunTime)
|
||||||
{
|
{
|
||||||
TaskImpl *This = (TaskImpl *)iface;
|
TaskImpl *This = impl_from_ITask(iface);
|
||||||
|
|
||||||
TRACE("(%p, %p)\n", iface, pdwMaxRunTime);
|
TRACE("(%p, %p)\n", iface, pdwMaxRunTime);
|
||||||
|
|
||||||
|
@ -597,7 +615,7 @@ static HRESULT WINAPI MSTASK_IPersistFile_QueryInterface(
|
||||||
{
|
{
|
||||||
TaskImpl *This = impl_from_IPersistFile(iface);
|
TaskImpl *This = impl_from_IPersistFile(iface);
|
||||||
TRACE("(%p, %s, %p)\n", iface, debugstr_guid(riid), ppvObject);
|
TRACE("(%p, %s, %p)\n", iface, debugstr_guid(riid), ppvObject);
|
||||||
return ITask_QueryInterface((ITask *) This, riid, ppvObject);
|
return ITask_QueryInterface(&This->ITask_iface, riid, ppvObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI MSTASK_IPersistFile_AddRef(
|
static ULONG WINAPI MSTASK_IPersistFile_AddRef(
|
||||||
|
@ -746,8 +764,8 @@ HRESULT TaskConstructor(LPCWSTR pwszTaskName, LPVOID *ppObj)
|
||||||
if (!This)
|
if (!This)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
This->lpVtbl = &MSTASK_ITaskVtbl;
|
This->ITask_iface.lpVtbl = &MSTASK_ITaskVtbl;
|
||||||
This->persistVtbl = &MSTASK_IPersistFileVtbl;
|
This->IPersistFile_iface.lpVtbl = &MSTASK_IPersistFileVtbl;
|
||||||
This->ref = 1;
|
This->ref = 1;
|
||||||
n = (lstrlenW(pwszTaskName) + 1) * sizeof(WCHAR);
|
n = (lstrlenW(pwszTaskName) + 1) * sizeof(WCHAR);
|
||||||
This->taskName = HeapAlloc(GetProcessHeap(), 0, n);
|
This->taskName = HeapAlloc(GetProcessHeap(), 0, n);
|
||||||
|
@ -765,7 +783,7 @@ HRESULT TaskConstructor(LPCWSTR pwszTaskName, LPVOID *ppObj)
|
||||||
/* Default time is 3 days = 259200000 ms */
|
/* Default time is 3 days = 259200000 ms */
|
||||||
This->maxRunTime = 259200000;
|
This->maxRunTime = 259200000;
|
||||||
|
|
||||||
*ppObj = &This->lpVtbl;
|
*ppObj = &This->ITask_iface;
|
||||||
InterlockedIncrement(&dll_ref);
|
InterlockedIncrement(&dll_ref);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue