comdlg32: Pass full colorref to RGB -> HSL conversion function.
[wine.git] / dlls / xolehlp / xolehlp.c
blob2d686cc772d17986229f338782ecd746b421f76a
1 /*
2 * Copyright 2011 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
20 #define COBJMACROS
21 #include "windef.h"
22 #include "winbase.h"
23 #include "transact.h"
24 #include "wine/unicode.h"
25 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(xolehlp);
29 typedef struct {
30 ITransactionDispenser ITransactionDispenser_iface;
31 LONG ref;
32 } TransactionManager;
34 static inline TransactionManager *impl_from_ITransactionDispenser(ITransactionDispenser *iface)
36 return CONTAINING_RECORD(iface, TransactionManager, ITransactionDispenser_iface);
39 static HRESULT WINAPI TransactionDispenser_QueryInterface(ITransactionDispenser *iface, REFIID iid,
40 void **ppv)
42 TransactionManager *This = impl_from_ITransactionDispenser(iface);
43 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
45 if (!ppv) return E_INVALIDARG;
47 if (IsEqualIID(&IID_IUnknown, iid) ||
48 IsEqualIID(&IID_ITransactionDispenser, iid))
50 *ppv = &This->ITransactionDispenser_iface;
52 else
54 FIXME("(%s): not implemented\n", debugstr_guid(iid));
55 *ppv = NULL;
56 return E_NOINTERFACE;
59 IUnknown_AddRef((IUnknown*)*ppv);
60 return S_OK;
63 static ULONG WINAPI TransactionDispenser_AddRef(ITransactionDispenser *iface)
65 TransactionManager *This = impl_from_ITransactionDispenser(iface);
66 ULONG ref = InterlockedIncrement(&This->ref);
68 TRACE("(%p) refcount=%u\n", iface, ref);
70 return ref;
73 static ULONG WINAPI TransactionDispenser_Release(ITransactionDispenser *iface)
75 TransactionManager *This = impl_from_ITransactionDispenser(iface);
76 ULONG ref = InterlockedDecrement(&This->ref);
78 TRACE("(%p) refcount=%u\n", iface, ref);
80 if (ref == 0)
82 HeapFree(GetProcessHeap(), 0, This);
85 return ref;
88 static HRESULT WINAPI TransactionDispenser_GetOptionsObject(ITransactionDispenser *iface,
89 ITransactionOptions **ppOptions)
91 FIXME("(%p, %p): stub\n", iface, ppOptions);
92 if (!ppOptions) return E_INVALIDARG;
93 *ppOptions = NULL;
94 return E_NOTIMPL;
96 static HRESULT WINAPI TransactionDispenser_BeginTransaction(ITransactionDispenser *iface,
97 IUnknown *punkOuter,
98 ISOLEVEL isoLevel,
99 ULONG isoFlags,
100 ITransactionOptions *pOptions,
101 ITransaction **ppTransaction)
103 FIXME("(%p, %p, %08x, %08x, %p, %p): stub\n", iface, punkOuter,
104 isoLevel, isoFlags, pOptions, ppTransaction);
106 if (!ppTransaction) return E_INVALIDARG;
107 *ppTransaction = NULL;
108 if (punkOuter) return CLASS_E_NOAGGREGATION;
109 return E_NOTIMPL;
111 static const ITransactionDispenserVtbl TransactionDispenser_Vtbl = {
112 TransactionDispenser_QueryInterface,
113 TransactionDispenser_AddRef,
114 TransactionDispenser_Release,
115 TransactionDispenser_GetOptionsObject,
116 TransactionDispenser_BeginTransaction
119 static HRESULT TransactionManager_Create(REFIID riid, void **ppv)
121 TransactionManager *This;
122 HRESULT ret;
124 This = HeapAlloc(GetProcessHeap(), 0, sizeof(TransactionManager));
125 if (!This) return E_OUTOFMEMORY;
127 This->ITransactionDispenser_iface.lpVtbl = &TransactionDispenser_Vtbl;
128 This->ref = 1;
130 ret = ITransactionDispenser_QueryInterface(&This->ITransactionDispenser_iface, riid, ppv);
131 ITransactionDispenser_Release(&This->ITransactionDispenser_iface);
133 return ret;
136 BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
138 TRACE("%p, %u, %p\n", hinst, reason, reserved);
140 switch (reason)
142 case DLL_WINE_PREATTACH:
143 return FALSE; /* prefer native version */
144 case DLL_PROCESS_ATTACH:
145 DisableThreadLibraryCalls( hinst );
146 break;
148 return TRUE;
151 static BOOL is_local_machineA( const CHAR *server )
153 static const CHAR dot[] = ".";
154 CHAR buffer[MAX_COMPUTERNAME_LENGTH + 1];
155 DWORD len = sizeof(buffer) / sizeof(buffer[0]);
157 if (!server || !strcmp( server, dot )) return TRUE;
158 if (GetComputerNameA( buffer, &len ) && !lstrcmpiA( server, buffer )) return TRUE;
159 return FALSE;
161 static BOOL is_local_machineW( const WCHAR *server )
163 static const WCHAR dotW[] = {'.',0};
164 WCHAR buffer[MAX_COMPUTERNAME_LENGTH + 1];
165 DWORD len = sizeof(buffer) / sizeof(buffer[0]);
167 if (!server || !strcmpW( server, dotW )) return TRUE;
168 if (GetComputerNameW( buffer, &len ) && !strcmpiW( server, buffer )) return TRUE;
169 return FALSE;
172 HRESULT CDECL DtcGetTransactionManager(char *host, char *tm_name, REFIID riid,
173 DWORD dwReserved1, WORD wcbReserved2, void *pvReserved2, void **ppv)
175 TRACE("(%s, %s, %s, %d, %d, %p, %p)\n", debugstr_a(host), debugstr_a(tm_name),
176 debugstr_guid(riid), dwReserved1, wcbReserved2, pvReserved2, ppv);
178 if (!is_local_machineA(host))
180 FIXME("remote computer not supported\n");
181 return E_NOTIMPL;
183 return TransactionManager_Create(riid, ppv);
186 HRESULT CDECL DtcGetTransactionManagerExA(CHAR *host, CHAR *tm_name, REFIID riid,
187 DWORD options, void *config, void **ppv)
189 TRACE("(%s, %s, %s, %d, %p, %p)\n", debugstr_a(host), debugstr_a(tm_name),
190 debugstr_guid(riid), options, config, ppv);
192 if (!is_local_machineA(host))
194 FIXME("remote computer not supported\n");
195 return E_NOTIMPL;
197 return TransactionManager_Create(riid, ppv);
200 HRESULT CDECL DtcGetTransactionManagerExW(WCHAR *host, WCHAR *tm_name, REFIID riid,
201 DWORD options, void *config, void **ppv)
203 TRACE("(%s, %s, %s, %d, %p, %p)\n", debugstr_w(host), debugstr_w(tm_name),
204 debugstr_guid(riid), options, config, ppv);
206 if (!is_local_machineW(host))
208 FIXME("remote computer not supported\n");
209 return E_NOTIMPL;
211 return TransactionManager_Create(riid, ppv);