mountmgr: Store the device name in the mount point structure.
[wine] / dlls / msxml3 / factory.c
1 /*
2  *    MSXML Class Factory
3  *
4  * Copyright 2002 Lionel Ulmer
5  * Copyright 2005 Mike McCormack
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #define COBJMACROS
23
24 #include "config.h"
25
26 #include <stdarg.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winuser.h"
30 #include "ole2.h"
31 #include "msxml.h"
32 #include "xmldom.h"
33 #include "msxml2.h"
34
35 /* undef the #define in msxml2 so that we can access the v.2 version
36    independent CLSID as well as the v.3 one. */
37 #undef CLSID_DOMDocument
38
39 #include "wine/debug.h"
40
41 #include "msxml_private.h"
42
43 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
44
45 typedef HRESULT (*fnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
46
47 /******************************************************************************
48  * MSXML ClassFactory
49  */
50 typedef struct _xmlcf
51 {
52     const struct IClassFactoryVtbl *lpVtbl;
53     fnCreateInstance pfnCreateInstance;
54 } xmlcf;
55
56 static inline xmlcf *impl_from_IClassFactory( IClassFactory *iface )
57 {
58     return (xmlcf *)((char*)iface - FIELD_OFFSET(xmlcf, lpVtbl));
59 }
60
61 static HRESULT WINAPI xmlcf_QueryInterface(
62     IClassFactory *iface,
63     REFIID riid,
64     LPVOID *ppobj )
65 {
66     if (IsEqualGUID(riid, &IID_IUnknown) ||
67         IsEqualGUID(riid, &IID_IClassFactory))
68     {
69         IClassFactory_AddRef( iface );
70         *ppobj = iface;
71         return S_OK;
72     }
73
74     FIXME("interface %s not implemented\n", debugstr_guid(riid));
75     return E_NOINTERFACE;
76 }
77
78 static ULONG WINAPI xmlcf_AddRef(
79     IClassFactory *iface )
80 {
81     return 2;
82 }
83
84 static ULONG WINAPI xmlcf_Release(
85     IClassFactory *iface )
86 {
87     return 1;
88 }
89
90 static HRESULT WINAPI xmlcf_CreateInstance(
91     IClassFactory *iface,
92     LPUNKNOWN pOuter,
93     REFIID riid,
94     LPVOID *ppobj )
95 {
96     xmlcf *This = impl_from_IClassFactory( iface );
97     HRESULT r;
98     IUnknown *punk;
99     
100     TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj );
101
102     *ppobj = NULL;
103
104     if (pOuter)
105         return CLASS_E_NOAGGREGATION;
106
107     r = This->pfnCreateInstance( pOuter, (LPVOID*) &punk );
108     if (FAILED(r))
109         return r;
110
111     r = IUnknown_QueryInterface( punk, riid, ppobj );
112     IUnknown_Release( punk );
113     return r;
114 }
115
116 static HRESULT WINAPI xmlcf_LockServer(
117     IClassFactory *iface,
118     BOOL dolock)
119 {
120     FIXME("(%p)->(%d),stub!\n",iface,dolock);
121     return S_OK;
122 }
123
124 static const struct IClassFactoryVtbl xmlcf_vtbl =
125 {
126     xmlcf_QueryInterface,
127     xmlcf_AddRef,
128     xmlcf_Release,
129     xmlcf_CreateInstance,
130     xmlcf_LockServer
131 };
132
133 static xmlcf domdoccf = { &xmlcf_vtbl, DOMDocument_create };
134 static xmlcf schemacf = { &xmlcf_vtbl, SchemaCache_create };
135 static xmlcf xmldoccf = { &xmlcf_vtbl, XMLDocument_create };
136 static xmlcf saxreadcf = { &xmlcf_vtbl, SAXXMLReader_create };
137 static xmlcf httpreqcf = { &xmlcf_vtbl, XMLHTTPRequest_create };
138
139 /******************************************************************
140  *              DllGetClassObject (MSXML3.@)
141  */
142 HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID iid, LPVOID *ppv )
143 {
144     IClassFactory *cf = NULL;
145
146     TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv );
147
148     if( IsEqualCLSID( rclsid, &CLSID_DOMDocument ) ||   /* Version indep. v 2.x */
149         IsEqualCLSID( rclsid, &CLSID_DOMDocument2 ) ||  /* Version indep. v 3.0 */
150         IsEqualCLSID( rclsid, &CLSID_DOMDocument30 ) )  /* Version dep.   v 3.0 */
151     {
152         cf = (IClassFactory*) &domdoccf.lpVtbl;
153     }
154     else if( IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache ) ||
155              IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache30 ) )
156     {
157         cf = (IClassFactory*) &schemacf.lpVtbl;
158     }
159     else if( IsEqualCLSID( rclsid, &CLSID_XMLDocument ) )
160     {
161         cf = (IClassFactory*) &xmldoccf.lpVtbl;
162     }
163     else if( IsEqualCLSID( rclsid, &CLSID_DOMFreeThreadedDocument ) ||   /* Version indep. v 2.x */
164              IsEqualCLSID( rclsid, &CLSID_FreeThreadedDOMDocument ) )
165     {
166         cf = (IClassFactory*) &domdoccf.lpVtbl;
167     }
168     else if( IsEqualCLSID( rclsid, &CLSID_SAXXMLReader) ||
169              IsEqualCLSID( rclsid, &CLSID_SAXXMLReader30 ))
170     {
171         cf = (IClassFactory*) &saxreadcf.lpVtbl;
172     }
173     else if( IsEqualCLSID( rclsid, &CLSID_XMLHTTPRequest))
174     {
175         cf = (IClassFactory*) &httpreqcf.lpVtbl;
176     }
177
178     if ( !cf )
179         return CLASS_E_CLASSNOTAVAILABLE;
180
181     return IClassFactory_QueryInterface( cf, iid, ppv );
182 }