explorerframe: Avoid signed-unsigned integer comparisons.
[wine] / dlls / mmcndmgr / mmcndmgr.c
1 /*
2  *
3  * Copyright 2011 Alistair Leslie-Hughes
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  */
19
20 #include <stdarg.h>
21
22 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
27 #include "rpcproxy.h"
28
29 #include "wine/unicode.h"
30 #include "wine/debug.h"
31 #include "wine/library.h"
32
33 #include "initguid.h"
34 #include "mmc.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(mmc);
37
38 static HINSTANCE MMC_hInstance;
39
40 static HRESULT WINAPI mmcversion_QueryInterface(IMMCVersionInfo *iface, REFIID riid, void **ppv)
41 {
42     TRACE("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
43
44     if ( IsEqualGUID( riid, &IID_IMMCVersionInfo ) ||
45          IsEqualGUID( riid, &IID_IUnknown ) )
46     {
47         *ppv = iface;
48     }
49     else
50     {
51         TRACE("Unsupported interface %s\n", debugstr_guid(riid));
52         *ppv = NULL;
53         return E_NOINTERFACE;
54     }
55
56     IMMCVersionInfo_AddRef(iface);
57     return S_OK;
58 }
59
60 static ULONG WINAPI mmcversion_AddRef(IMMCVersionInfo *iface)
61 {
62     return 2;
63 }
64
65 static ULONG WINAPI mmcversion_Release(IMMCVersionInfo *iface)
66 {
67    return 1;
68 }
69
70 static HRESULT WINAPI mmcversion_GetMMCVersion(IMMCVersionInfo *iface, LONG *pVersionMajor, LONG *pVersionMinor)
71 {
72     TRACE("(%p, %p, %p): stub\n", iface, pVersionMajor, pVersionMinor);
73
74     if(pVersionMajor)
75         *pVersionMajor = 3;
76
77     if(pVersionMinor)
78         *pVersionMinor = 0;
79
80     return S_OK;
81 }
82
83 static const struct IMMCVersionInfoVtbl mmcversionVtbl =
84 {
85     mmcversion_QueryInterface,
86     mmcversion_AddRef,
87     mmcversion_Release,
88     mmcversion_GetMMCVersion
89 };
90
91 static IMMCVersionInfo mmcVersionInfo = { &mmcversionVtbl };
92
93 /***********************************************************
94  *    ClassFactory implementation
95  */
96 typedef HRESULT (*CreateInstanceFunc)(IUnknown*,REFIID,void**);
97
98 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFGUID riid, void **ppvObject)
99 {
100     if(IsEqualGUID(&IID_IClassFactory, riid) || IsEqualGUID(&IID_IUnknown, riid)) {
101         IClassFactory_AddRef(iface);
102         *ppvObject = iface;
103         return S_OK;
104     }
105
106     WARN("not supported iid %s\n", debugstr_guid(riid));
107     *ppvObject = NULL;
108     return E_NOINTERFACE;
109 }
110
111 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
112 {
113     TRACE("(%p)\n", iface);
114     return 2;
115 }
116
117 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
118 {
119     TRACE("(%p)\n", iface);
120
121     return 1;
122 }
123
124 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *outer,
125         REFIID riid, void **ppv)
126 {
127     TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
128     return IMMCVersionInfo_QueryInterface(&mmcVersionInfo, riid, ppv);
129 }
130
131 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
132 {
133     TRACE("(%p)->(%x)\n", iface, fLock);
134     return S_OK;
135 }
136
137 static const IClassFactoryVtbl MMCClassFactoryVtbl = {
138     ClassFactory_QueryInterface,
139     ClassFactory_AddRef,
140     ClassFactory_Release,
141     ClassFactory_CreateInstance,
142     ClassFactory_LockServer
143 };
144
145 static IClassFactory MMCVersionInfoFactory = { &MMCClassFactoryVtbl };
146
147 HRESULT WINAPI DllGetClassObject( REFCLSID riid, REFIID iid, LPVOID *ppv )
148 {
149     TRACE("%s %s %p\n", debugstr_guid(riid), debugstr_guid(iid), ppv );
150
151     if( IsEqualCLSID( riid, &CLSID_MMCVersionInfo ))
152     {
153         TRACE("(CLSID_MMCVersionInfo %s %p)\n", debugstr_guid(riid), ppv);
154         return IClassFactory_QueryInterface(&MMCVersionInfoFactory, iid, ppv);
155     }
156
157     FIXME("Unsupported interface %s\n", debugstr_guid(riid));
158     return CLASS_E_CLASSNOTAVAILABLE;
159  }
160
161 HRESULT WINAPI DllRegisterServer(void)
162 {
163     return __wine_register_resources( MMC_hInstance );
164 }
165
166 HRESULT WINAPI DllUnregisterServer(void)
167 {
168     return __wine_unregister_resources( MMC_hInstance );
169 }
170
171 HRESULT WINAPI DllCanUnloadNow(void)
172 {
173     return S_FALSE;
174 }
175
176 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
177 {
178     TRACE("(%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
179
180     switch (fdwReason)
181     {
182     case DLL_WINE_PREATTACH:
183         return FALSE;  /* prefer native version */
184     case DLL_PROCESS_ATTACH:
185         MMC_hInstance = hinstDLL;
186         break;
187     case DLL_PROCESS_DETACH:
188         break;
189     }
190     return TRUE;
191 }