crypt32: Fixed day/month mismatch in time encoding routines.
[wine] / dlls / shdocvw / factory.c
1 /*
2  * Implementation of class factory for IE Web Browser
3  *
4  * Copyright 2001 John R. Sheets (for CodeWeavers)
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include <string.h>
22 #include "wine/debug.h"
23 #include "shdocvw.h"
24
25 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
26
27 /**********************************************************************
28  * Implement the WebBrowser class factory
29  *
30  * (Based on implementation in ddraw/main.c)
31  */
32
33 typedef struct
34 {
35     /* IUnknown fields */
36     const IClassFactoryVtbl *lpVtbl;
37     HRESULT (*cf)(LPUNKNOWN, REFIID, LPVOID *);
38     LONG ref;
39 } IClassFactoryImpl;
40
41
42 /**********************************************************************
43  * WBCF_QueryInterface (IUnknown)
44  */
45 static HRESULT WINAPI WBCF_QueryInterface(LPCLASSFACTORY iface,
46                                           REFIID riid, LPVOID *ppobj)
47 {
48     TRACE("(%s %p)\n", debugstr_guid(riid), ppobj);
49
50     if (!ppobj)
51         return E_POINTER;
52
53     if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
54         *ppobj = iface;
55         return S_OK;
56     }
57
58     WARN("Not supported interface %s\n", debugstr_guid(riid));
59
60     *ppobj = NULL;
61     return E_NOINTERFACE;
62 }
63
64 /************************************************************************
65  * WBCF_AddRef (IUnknown)
66  */
67 static ULONG WINAPI WBCF_AddRef(LPCLASSFACTORY iface)
68 {
69     SHDOCVW_LockModule();
70
71     return 2; /* non-heap based object */
72 }
73
74 /************************************************************************
75  * WBCF_Release (IUnknown)
76  */
77 static ULONG WINAPI WBCF_Release(LPCLASSFACTORY iface)
78 {
79     SHDOCVW_UnlockModule();
80
81     return 1; /* non-heap based object */
82 }
83
84 /************************************************************************
85  * WBCF_CreateInstance (IClassFactory)
86  */
87 static HRESULT WINAPI WBCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
88                                           REFIID riid, LPVOID *ppobj)
89 {
90     IClassFactoryImpl *This = (IClassFactoryImpl *) iface;
91     return This->cf(pOuter, riid, ppobj);
92 }
93
94 /************************************************************************
95  * WBCF_LockServer (IClassFactory)
96  */
97 static HRESULT WINAPI WBCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
98 {
99     TRACE("(%d)\n", dolock);
100
101     if (dolock)
102         SHDOCVW_LockModule();
103     else
104         SHDOCVW_UnlockModule();
105     
106     return S_OK;
107 }
108
109 static const IClassFactoryVtbl WBCF_Vtbl =
110 {
111     WBCF_QueryInterface,
112     WBCF_AddRef,
113     WBCF_Release,
114     WBCF_CreateInstance,
115     WBCF_LockServer
116 };
117
118 static IClassFactoryImpl SHDOCVW_WBClassFactory = {&WBCF_Vtbl, WebBrowser_Create};
119
120 IClassFactory *get_class_factory(void)
121 {
122     return (IClassFactory*) &SHDOCVW_WBClassFactory;
123 }