Signed-off-by: Hans Leidekker hans@codeweavers.com --- dlls/taskschd/task.c | 15 ++++++++++++++- dlls/taskschd/tests/scheduler.c | 11 +++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/dlls/taskschd/task.c b/dlls/taskschd/task.c index 9959f042a2..a469e12347 100644 --- a/dlls/taskschd/task.c +++ b/dlls/taskschd/task.c @@ -39,6 +39,7 @@ typedef struct { IDailyTrigger IDailyTrigger_iface; LONG ref; short interval; + WCHAR *start_boundary; } DailyTrigger;
static inline DailyTrigger *impl_from_IDailyTrigger(IDailyTrigger *iface) @@ -88,7 +89,11 @@ static ULONG WINAPI DailyTrigger_Release(IDailyTrigger *iface) TRACE("(%p) ref=%d\n", This, ref);
if(!ref) + { + TRACE("destroying %p\n", iface); + heap_free(This->start_boundary); heap_free(This); + }
return ref; } @@ -183,7 +188,14 @@ static HRESULT WINAPI DailyTrigger_get_StartBoundary(IDailyTrigger *iface, BSTR static HRESULT WINAPI DailyTrigger_put_StartBoundary(IDailyTrigger *iface, BSTR start) { DailyTrigger *This = impl_from_IDailyTrigger(iface); - FIXME("(%p)->(%s)\n", This, debugstr_w(start)); + WCHAR *str = NULL; + + TRACE("(%p)->(%s)\n", This, debugstr_w(start)); + + if (start && !(This->start_boundary = heap_strdupW(start))) return E_OUTOFMEMORY; + heap_free(This->start_boundary); + This->start_boundary = str; + return S_OK; }
@@ -290,6 +302,7 @@ static HRESULT DailyTrigger_create(ITrigger **trigger) daily_trigger->IDailyTrigger_iface.lpVtbl = &DailyTrigger_vtbl; daily_trigger->ref = 1; daily_trigger->interval = 1; + daily_trigger->start_boundary = NULL;
*trigger = (ITrigger*)&daily_trigger->IDailyTrigger_iface; return S_OK; diff --git a/dlls/taskschd/tests/scheduler.c b/dlls/taskschd/tests/scheduler.c index c7de7c7041..0f3010e30f 100644 --- a/dlls/taskschd/tests/scheduler.c +++ b/dlls/taskschd/tests/scheduler.c @@ -1195,7 +1195,10 @@ static void change_settings(ITaskDefinition *taskdef, struct settings *test)
static void test_daily_trigger(ITrigger *trigger) { + static const WCHAR startW[] = + {'2','0','0','4','-','0','1','-','0','1','T','0','0',':','0','0',':','0','0',0}; IDailyTrigger *daily_trigger; + BSTR start_boundary; short interval; HRESULT hr;
@@ -1225,6 +1228,14 @@ static void test_daily_trigger(ITrigger *trigger) ok(hr == S_OK, "get_DaysInterval failed: %08x\n", hr); ok(interval == 2, "interval = %d\n", interval);
+ start_boundary = SysAllocString(startW); + hr = IDailyTrigger_put_StartBoundary(daily_trigger, start_boundary); + ok(hr == S_OK, "put_StartBoundary failed: %08x\n", hr); + SysFreeString(start_boundary); + + hr = IDailyTrigger_put_StartBoundary(daily_trigger, NULL); + ok(hr == S_OK, "put_StartBoundary failed: %08x\n", hr); + IDailyTrigger_Release(daily_trigger); }
Hans Leidekker hans@codeweavers.com wrote:
static HRESULT WINAPI DailyTrigger_put_StartBoundary(IDailyTrigger *iface, BSTR start) { DailyTrigger *This = impl_from_IDailyTrigger(iface);
- FIXME("(%p)->(%s)\n", This, debugstr_w(start));
- WCHAR *str = NULL;
- TRACE("(%p)->(%s)\n", This, debugstr_w(start));
- if (start && !(This->start_boundary = heap_strdupW(start))) return E_OUTOFMEMORY;
- heap_free(This->start_boundary);
- This->start_boundary = str;
- return S_OK;
}
Probably trigger time related data should be stored as a parsed system time instead of a string since all the further checks and calculations would need to be done with absolute time anyway. And the reverse conversion should be performed in get_StartBoundary().
On Fri, 2017-12-01 at 18:02 +0800, Dmitry Timoshkov wrote:
Hans Leidekker hans@codeweavers.com wrote:
static HRESULT WINAPI DailyTrigger_put_StartBoundary(IDailyTrigger *iface, BSTR start) { DailyTrigger *This = impl_from_IDailyTrigger(iface);
- FIXME("(%p)->(%s)\n", This, debugstr_w(start));
- WCHAR *str = NULL;
- TRACE("(%p)->(%s)\n", This, debugstr_w(start));
- if (start && !(This->start_boundary = heap_strdupW(start))) return E_OUTOFMEMORY;
- heap_free(This->start_boundary);
- This->start_boundary = str;
- return S_OK;
}
Probably trigger time related data should be stored as a parsed system time instead of a string since all the further checks and calculations would need to be done with absolute time anyway. And the reverse conversion should be performed in get_StartBoundary().
No, it's stored as-is. I've added some tests to show that.
Hans Leidekker hans@codeweavers.com wrote:
Probably trigger time related data should be stored as a parsed system time instead of a string since all the further checks and calculations would need to be done with absolute time anyway. And the reverse conversion should be performed in get_StartBoundary().
No, it's stored as-is. I've added some tests to show that.
I see, thanks.