MSHTML: Add basic support for ITimer interface [2/2]

Matthew Kehrer kehrermatt at gmail.com
Sun Nov 19 16:59:55 CST 2006


MSHTML: Add basic support for ITimer interface [2/2]

This Patch implements ITimer with stubs. Only ITimer is implemented
because MSDN states that ITimerService and ITimerSink have no stock
implementation.

This part of the patchset contains the source code itself.


 dlls/mshtml/Makefile.in |    1
 dlls/mshtml/timer.c     |  137 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 138 insertions(+), 0 deletions(-)

diff --git a/dlls/mshtml/Makefile.in b/dlls/mshtml/Makefile.in
index d4a0803..cbdf6a0 100644
--- a/dlls/mshtml/Makefile.in
+++ b/dlls/mshtml/Makefile.in
@@ -38,6 +38,7 @@ C_SRCS = \
 	selection.c \
 	service.c \
 	task.c \
+	timer.c \
 	txtrange.c \
 	view.c

diff --git a/dlls/mshtml/timer.c b/dlls/mshtml/timer.c
new file mode 100755
index 0000000..3eab598
--- /dev/null
+++ b/dlls/mshtml/timer.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2006 Matthew Kehrer
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+/*!! Only ITimer is implemented here as ITimerService & ITimerSink
have no stock implementation !!*/
+
+#include "config.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#define COBJMACROS
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "ole2.h"
+
+#include "wine/debug.h"
+#include "wine/unicode.h"
+
+#include "mshtml_private.h"
+
+#include "ocmm.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
+
+typedef struct
+{
+    const ITimerVtbl* lpTimerVtbl;
+    LONG ref;
+
+    /* Fields */
+    VARIANT *time;
+    BOOL *freeze;
+} Timer;
+
+#define TIMER(x)    ((ITimer*) &(x)->lpTimerVtbl);
+
+#define TIMER_THIS(iface) DEFINE_THIS(Timer, Timer, iface)
+
+static HRESULT WINAPI Timer_QueryInterface(ITimer* iface, REFIID
riid, LPVOID* ppobj)
+{
+    Timer* This = TIMER_THIS(iface);
+
+    if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ITimer))
+    {
+        IUnknown_AddRef(iface);
+        *ppobj = This;
+        return S_OK;
+    }
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI Timer_AddRef(ITimer* iface)
+{
+    Timer* This = TIMER_THIS(iface);
+    ULONG ref = InterlockedIncrement(&This->ref);
+
+    return ref;
+}
+
+static ULONG WINAPI Timer_Release(ITimer* iface)
+{
+    Timer* This = TIMER_THIS(iface);
+    ULONG ref = InterlockedDecrement(&This->ref);
+
+    if(ref == 0)
+    {
+        HeapFree(GetProcessHeap(), 0, This->time);
+        HeapFree(GetProcessHeap(), 0, This->freeze);
+        HeapFree(GetProcessHeap(), 0, This);
+    }
+
+    return ref;
+}
+
+static HRESULT WINAPI Timer_Advise(ITimer* iface, VARIANT vtimeMin,
VARIANT vtimeMax,
+                                   VARIANT vtimeInterval, DWORD
dwFlags, ITimerSink *pTimerSink,
+                                   DWORD *pdwCookie)
+{
+    Timer* This = TIMER_THIS(iface);
+    FIXME("(%p): Stub!\n",This); /* I get a too many arguments when
try to put VARIANTS in */
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI Timer_Unadvise(ITimer* iface, DWORD dwCookie)
+{
+    Timer* This = TIMER_THIS(iface);
+    FIXME("(%p->%x): Stub!\n",This,dwCookie);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI Timer_Freeze(ITimer* iface, BOOL fFreeze)
+{
+    Timer* This = TIMER_THIS(iface);
+
+    TRACE("(%p->%d)\n",This,fFreeze);
+
+    This->freeze = &fFreeze;
+
+    return S_OK;
+}
+
+static HRESULT WINAPI Timer_GetTime(ITimer* iface, VARIANT *pvtime)
+{
+    Timer* This = TIMER_THIS(iface);
+
+    TRACE("(%p->%p)\n",This,pvtime);
+
+    pvtime = This->time;
+
+    return S_OK;
+}
+
+static const ITimerVtbl TimerVtbl = {
+    Timer_QueryInterface,
+    Timer_AddRef,
+    Timer_Release,
+    Timer_Advise,
+    Timer_Unadvise,
+    Timer_Freeze,
+    Timer_GetTime
+};
-- 
1.4.2



More information about the wine-patches mailing list