msxml3: Properly handle qualified names in getAttributeNode().
[wine] / dlls / dpnet / dpnet_main.c
1 /* 
2  * DirectPlay
3  * 
4  * Copyright 2004 Raphael Junqueira
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  *
20  */
21
22 #include "config.h"
23
24 #include <stdarg.h>
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29 #include "winuser.h"
30 #include "objbase.h"
31 #include "oleauto.h"
32 #include "oleidl.h"
33 #include "rpcproxy.h"
34 #include "wine/debug.h"
35
36 #include "initguid.h"
37 #include "dpnet_private.h"
38
39 WINE_DEFAULT_DEBUG_CHANNEL(dpnet);
40
41 static HINSTANCE instance;
42
43 /* At process attach */
44 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
45 {
46   TRACE("%p,%x,%p\n", hInstDLL, fdwReason, lpvReserved);
47   if (fdwReason == DLL_PROCESS_ATTACH) {
48       instance = hInstDLL;
49       DisableThreadLibraryCalls(hInstDLL);
50   }
51   return TRUE;
52 }
53
54 /***********************************************************************
55  *             DirectPlay8Create (DPNET.@)
56  */
57 HRESULT WINAPI DirectPlay8Create(REFGUID lpGUID, LPVOID *ppvInt, LPUNKNOWN punkOuter)
58 {
59     TRACE("(%s, %p, %p): stub\n", debugstr_guid(lpGUID), ppvInt, punkOuter);
60     return S_OK;
61 }
62
63 /*******************************************************************************
64  * DirectPlay ClassFactory
65  */
66 typedef struct
67 {
68   /* IUnknown fields */
69   IClassFactory IClassFactory_iface;
70   LONG          ref;
71   REFCLSID      rclsid;
72   HRESULT       (*pfnCreateInstanceFactory)(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj);
73 } IClassFactoryImpl;
74
75 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
76 {
77   return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
78 }
79
80 static HRESULT WINAPI DICF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
81   IClassFactoryImpl *This = impl_from_IClassFactory(iface);
82
83   FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
84   return E_NOINTERFACE;
85 }
86
87 static ULONG WINAPI DICF_AddRef(LPCLASSFACTORY iface) {
88   IClassFactoryImpl *This = impl_from_IClassFactory(iface);
89   return InterlockedIncrement(&This->ref);
90 }
91
92 static ULONG WINAPI DICF_Release(LPCLASSFACTORY iface) {
93   IClassFactoryImpl *This = impl_from_IClassFactory(iface);
94   /* static class, won't be  freed */
95   return InterlockedDecrement(&This->ref);
96 }
97
98 static HRESULT WINAPI DICF_CreateInstance(LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj) {
99   IClassFactoryImpl *This = impl_from_IClassFactory(iface);
100
101   TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
102   return This->pfnCreateInstanceFactory(iface, pOuter, riid, ppobj);
103 }
104
105 static HRESULT WINAPI DICF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
106   IClassFactoryImpl *This = impl_from_IClassFactory(iface);
107   FIXME("(%p)->(%d),stub!\n",This,dolock);
108   return S_OK;
109 }
110
111 static const IClassFactoryVtbl DICF_Vtbl = {
112   DICF_QueryInterface,
113   DICF_AddRef,
114   DICF_Release,
115   DICF_CreateInstance,
116   DICF_LockServer
117 };
118
119 static IClassFactoryImpl DPNET_CFS[] = {
120   { { &DICF_Vtbl }, 1, &CLSID_DirectPlay8Client,  DPNET_CreateDirectPlay8Client },
121   { { &DICF_Vtbl }, 1, &CLSID_DirectPlay8Server,  DPNET_CreateDirectPlay8Server },
122   { { &DICF_Vtbl }, 1, &CLSID_DirectPlay8Peer,    DPNET_CreateDirectPlay8Peer },
123   { { &DICF_Vtbl }, 1, &CLSID_DirectPlay8Address, DPNET_CreateDirectPlay8Address },
124   { { &DICF_Vtbl }, 1, &CLSID_DirectPlay8LobbiedApplication, DPNET_CreateDirectPlay8LobbiedApp },
125   { { &DICF_Vtbl }, 1, &CLSID_DirectPlay8ThreadPool, DPNET_CreateDirectPlay8ThreadPool},
126   { { NULL }, 0, NULL, NULL }
127 };
128
129 /***********************************************************************
130  *             DllCanUnloadNow (DPNET.@)
131  */
132 HRESULT WINAPI DllCanUnloadNow(void)
133 {
134     return S_FALSE;
135 }
136
137 /***********************************************************************
138  *              DllGetClassObject (DPNET.@)
139  */
140 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
141 {
142     int i = 0;
143
144     TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
145     /*
146     if ( IsEqualCLSID( &IID_IClassFactory, riid ) ) {
147         *ppv = (LPVOID)&DPNET_CF;
148         IClassFactory_AddRef((IClassFactory*)*ppv);
149         return S_OK;
150     }
151     */
152     while (NULL != DPNET_CFS[i].rclsid) {
153       if (IsEqualGUID(rclsid, DPNET_CFS[i].rclsid)) {
154         DICF_AddRef(&DPNET_CFS[i].IClassFactory_iface);
155         *ppv = &DPNET_CFS[i];
156         return S_OK;
157       }
158       ++i;
159     }
160
161     FIXME("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
162     return CLASS_E_CLASSNOTAVAILABLE;
163 }
164
165 /***********************************************************************
166  *              DllRegisterServer (DPNET.@)
167  */
168 HRESULT WINAPI DllRegisterServer(void)
169 {
170     return __wine_register_resources( instance );
171 }
172
173 /***********************************************************************
174  *              DllUnregisterServer (DPNET.@)
175  */
176 HRESULT WINAPI DllUnregisterServer(void)
177 {
178     return __wine_unregister_resources( instance );
179 }