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
24 #include "wine/unicode.h"
25 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(xolehlp
);
30 ITransactionDispenser ITransactionDispenser_iface
;
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
,
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
;
54 FIXME("(%s): not implemented\n", debugstr_guid(iid
));
59 IUnknown_AddRef((IUnknown
*)*ppv
);
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
);
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
);
82 HeapFree(GetProcessHeap(), 0, This
);
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
;
96 static HRESULT WINAPI
TransactionDispenser_BeginTransaction(ITransactionDispenser
*iface
,
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
;
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
;
124 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(TransactionManager
));
125 if (!This
) return E_OUTOFMEMORY
;
127 This
->ITransactionDispenser_iface
.lpVtbl
= &TransactionDispenser_Vtbl
;
130 ret
= ITransactionDispenser_QueryInterface(&This
->ITransactionDispenser_iface
, riid
, ppv
);
131 ITransactionDispenser_Release(&This
->ITransactionDispenser_iface
);
136 BOOL WINAPI
DllMain( HINSTANCE hinst
, DWORD reason
, LPVOID reserved
)
138 TRACE("%p, %u, %p\n", hinst
, reason
, reserved
);
142 case DLL_WINE_PREATTACH
:
143 return FALSE
; /* prefer native version */
144 case DLL_PROCESS_ATTACH
:
145 DisableThreadLibraryCalls( hinst
);
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
;
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
;
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");
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");
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");
211 return TransactionManager_Create(riid
, ppv
);