2 * Copyright (C) 2008 Google (Roy Shea)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include "mstask_private.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(mstask
);
35 ITaskTrigger ITaskTrigger_iface
;
41 static inline TaskTriggerImpl
*impl_from_ITaskTrigger(ITaskTrigger
*iface
)
43 return CONTAINING_RECORD(iface
, TaskTriggerImpl
, ITaskTrigger_iface
);
46 static HRESULT WINAPI
MSTASK_ITaskTrigger_QueryInterface(
51 TaskTriggerImpl
*This
= impl_from_ITaskTrigger(iface
);
53 TRACE("IID: %s\n", debugstr_guid(riid
));
54 if (ppvObject
== NULL
)
57 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
58 IsEqualGUID(riid
, &IID_ITaskTrigger
))
60 *ppvObject
= &This
->ITaskTrigger_iface
;
61 ITaskTrigger_AddRef(iface
);
65 WARN("Unknown interface: %s\n", debugstr_guid(riid
));
70 static ULONG WINAPI
MSTASK_ITaskTrigger_AddRef(
73 TaskTriggerImpl
*This
= impl_from_ITaskTrigger(iface
);
76 ref
= InterlockedIncrement(&This
->ref
);
80 static ULONG WINAPI
MSTASK_ITaskTrigger_Release(
83 TaskTriggerImpl
*This
= impl_from_ITaskTrigger(iface
);
86 ref
= InterlockedDecrement(&This
->ref
);
89 ITask_Release(This
->parent_task
);
91 InterlockedDecrement(&dll_ref
);
96 static HRESULT WINAPI
MSTASK_ITaskTrigger_SetTrigger(ITaskTrigger
*iface
, const PTASK_TRIGGER trigger
)
98 TaskTriggerImpl
*This
= impl_from_ITaskTrigger(iface
);
100 TRACE("(%p, %p)\n", iface
, trigger
);
102 if (!trigger
) return E_INVALIDARG
;
104 return task_set_trigger(This
->parent_task
, This
->trigger_index
, trigger
);
107 static HRESULT WINAPI
MSTASK_ITaskTrigger_GetTrigger(ITaskTrigger
*iface
, TASK_TRIGGER
*trigger
)
109 TaskTriggerImpl
*This
= impl_from_ITaskTrigger(iface
);
111 TRACE("(%p, %p)\n", iface
, trigger
);
113 if (!trigger
) return E_INVALIDARG
;
115 return task_get_trigger(This
->parent_task
, This
->trigger_index
, trigger
);
118 static HRESULT WINAPI
MSTASK_ITaskTrigger_GetTriggerString(
120 LPWSTR
*ppwszTrigger
)
122 FIXME("Not implemented\n");
126 static const ITaskTriggerVtbl MSTASK_ITaskTriggerVtbl
=
128 MSTASK_ITaskTrigger_QueryInterface
,
129 MSTASK_ITaskTrigger_AddRef
,
130 MSTASK_ITaskTrigger_Release
,
131 MSTASK_ITaskTrigger_SetTrigger
,
132 MSTASK_ITaskTrigger_GetTrigger
,
133 MSTASK_ITaskTrigger_GetTriggerString
136 HRESULT
TaskTriggerConstructor(ITask
*task
, WORD idx
, ITaskTrigger
**trigger
)
138 TaskTriggerImpl
*This
;
140 TRACE("(%p, %u, %p)\n", task
, idx
, trigger
);
142 This
= heap_alloc(sizeof(*This
));
144 return E_OUTOFMEMORY
;
146 This
->ITaskTrigger_iface
.lpVtbl
= &MSTASK_ITaskTriggerVtbl
;
150 This
->parent_task
= task
;
151 This
->trigger_index
= idx
;
153 *trigger
= &This
->ITaskTrigger_iface
;
154 InterlockedIncrement(&dll_ref
);