2 * Copyright 2020 Dmitry Timoshkov
4 * This file contains only stubs to get the printui.dll up and running
5 * activeds.dll is much much more than this
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.
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.
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
31 #include "wine/heap.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(activeds
);
37 DEFINE_GUID(CLSID_Pathname
,0x080d0d78,0xf421,0x11d0,0xa3,0x6e,0x00,0xc0,0x4f,0xb9,0x50,0xdc);
41 IADsPathname IADsPathname_iface
;
43 BSTR provider
, server
, dn
;
46 static inline Pathname
*impl_from_IADsPathname(IADsPathname
*iface
)
48 return CONTAINING_RECORD(iface
, Pathname
, IADsPathname_iface
);
51 static HRESULT WINAPI
path_QueryInterface(IADsPathname
*iface
, REFIID riid
, void **obj
)
53 TRACE("%p,%s,%p\n", iface
, debugstr_guid(riid
), obj
);
55 if (!riid
|| !obj
) return E_INVALIDARG
;
57 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
58 IsEqualGUID(riid
, &IID_IDispatch
) ||
59 IsEqualGUID(riid
, &IID_IADsPathname
))
61 IADsPathname_AddRef(iface
);
66 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
70 static ULONG WINAPI
path_AddRef(IADsPathname
*iface
)
72 Pathname
*path
= impl_from_IADsPathname(iface
);
73 return InterlockedIncrement(&path
->ref
);
76 static ULONG WINAPI
path_Release(IADsPathname
*iface
)
78 Pathname
*path
= impl_from_IADsPathname(iface
);
79 LONG ref
= InterlockedDecrement(&path
->ref
);
83 TRACE("destroying %p\n", iface
);
84 SysFreeString(path
->provider
);
85 SysFreeString(path
->server
);
86 SysFreeString(path
->dn
);
93 static HRESULT WINAPI
path_GetTypeInfoCount(IADsPathname
*iface
, UINT
*count
)
95 FIXME("%p,%p: stub\n", iface
, count
);
99 static HRESULT WINAPI
path_GetTypeInfo(IADsPathname
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
101 FIXME("%p,%u,%#x,%p: stub\n", iface
, index
, lcid
, info
);
105 static HRESULT WINAPI
path_GetIDsOfNames(IADsPathname
*iface
, REFIID riid
, LPOLESTR
*names
,
106 UINT count
, LCID lcid
, DISPID
*dispid
)
108 FIXME("%p,%s,%p,%u,%u,%p: stub\n", iface
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
112 static HRESULT WINAPI
path_Invoke(IADsPathname
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
, WORD flags
,
113 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excepinfo
, UINT
*argerr
)
115 FIXME("%p,%d,%s,%04x,%04x,%p,%p,%p,%p: stub\n", iface
, dispid
, debugstr_guid(riid
), lcid
, flags
,
116 params
, result
, excepinfo
, argerr
);
120 static HRESULT
parse_path(BSTR path
, BSTR
*provider
, BSTR
*server
, BSTR
*dn
)
129 if (wcsnicmp(path
, L
"LDAP:", 5) != 0)
130 return E_ADS_BAD_PATHNAME
;
132 *provider
= SysAllocStringLen(path
, 4);
133 if (!*provider
) return E_OUTOFMEMORY
;
136 if (!*p
) return S_OK
;
138 if (*p
++ != '/' || *p
++ != '/' || !*p
)
139 return E_ADS_BAD_PATHNAME
;
143 while (*p
&& *p
!= '/')
148 if (server_len
== 0) return E_ADS_BAD_PATHNAME
;
150 *server
= SysAllocStringLen(p_server
, server_len
);
153 SysFreeString(*provider
);
154 return E_OUTOFMEMORY
;
157 if (!*p
) return S_OK
;
159 if (*p
++ != '/' || !*p
)
161 SysFreeString(*provider
);
162 SysFreeString(*server
);
163 return E_ADS_BAD_PATHNAME
;
166 *dn
= SysAllocString(p
);
169 SysFreeString(*provider
);
170 SysFreeString(*server
);
171 return E_OUTOFMEMORY
;
177 static HRESULT WINAPI
path_Set(IADsPathname
*iface
, BSTR adspath
, LONG type
)
179 Pathname
*path
= impl_from_IADsPathname(iface
);
181 BSTR provider
, server
, dn
;
183 TRACE("%p,%s,%d\n", iface
, debugstr_w(adspath
), type
);
185 if (!adspath
) return E_INVALIDARG
;
187 if (type
== ADS_SETTYPE_PROVIDER
)
189 SysFreeString(path
->provider
);
190 path
->provider
= SysAllocString(adspath
);
191 return path
->provider
? S_OK
: E_OUTOFMEMORY
;
194 if (type
== ADS_SETTYPE_SERVER
)
196 SysFreeString(path
->server
);
197 path
->server
= SysAllocString(adspath
);
198 return path
->server
? S_OK
: E_OUTOFMEMORY
;
201 if (type
== ADS_SETTYPE_DN
)
203 SysFreeString(path
->dn
);
204 path
->dn
= SysAllocString(adspath
);
205 return path
->dn
? S_OK
: E_OUTOFMEMORY
;
208 if (type
!= ADS_SETTYPE_FULL
)
210 FIXME("type %d not implemented\n", type
);
214 hr
= parse_path(adspath
, &provider
, &server
, &dn
);
217 SysFreeString(path
->provider
);
218 SysFreeString(path
->server
);
219 SysFreeString(path
->dn
);
221 path
->provider
= provider
;
222 path
->server
= server
;
228 static HRESULT WINAPI
path_SetDisplayType(IADsPathname
*iface
, LONG type
)
230 FIXME("%p,%d: stub\n", iface
, type
);
234 static HRESULT WINAPI
path_Retrieve(IADsPathname
*iface
, LONG type
, BSTR
*adspath
)
236 Pathname
*path
= impl_from_IADsPathname(iface
);
239 TRACE("%p,%d,%p\n", iface
, type
, adspath
);
241 if (!adspath
) return E_INVALIDARG
;
246 FIXME("type %d not implemented\n", type
);
249 case ADS_FORMAT_X500
:
250 len
= wcslen(path
->provider
) + 3;
251 if (path
->server
) len
+= wcslen(path
->server
) + 1;
252 if (path
->dn
) len
+= wcslen(path
->dn
);
254 *adspath
= SysAllocStringLen(NULL
, len
);
255 if (!*adspath
) break;
257 wcscpy(*adspath
, path
->provider
);
258 wcscat(*adspath
, L
"://");
261 wcscat(*adspath
, path
->server
);
262 wcscat(*adspath
, L
"/");
264 if (path
->dn
) wcscat(*adspath
, path
->dn
);
267 case ADS_FORMAT_PROVIDER
:
268 *adspath
= SysAllocString(path
->provider
);
271 case ADS_FORMAT_SERVER
:
272 *adspath
= path
->provider
? SysAllocString(path
->server
) : SysAllocStringLen(NULL
, 0);
275 case ADS_FORMAT_X500_DN
:
276 *adspath
= path
->dn
? SysAllocString(path
->dn
) : SysAllocStringLen(NULL
, 0);
279 case ADS_FORMAT_LEAF
:
281 *adspath
= SysAllocStringLen(NULL
, 0);
284 WCHAR
*p
= wcschr(path
->dn
, ',');
285 *adspath
= p
? SysAllocStringLen(path
->dn
, p
- path
->dn
) : SysAllocString(path
->dn
);
290 TRACE("=> %s\n", debugstr_w(*adspath
));
291 return *adspath
? S_OK
: E_OUTOFMEMORY
;
294 static HRESULT WINAPI
path_GetNumElements(IADsPathname
*iface
, LONG
*count
)
296 Pathname
*path
= impl_from_IADsPathname(iface
);
299 TRACE("%p,%p\n", iface
, count
);
301 if (!count
) return E_INVALIDARG
;
316 static HRESULT WINAPI
path_GetElement(IADsPathname
*iface
, LONG index
, BSTR
*element
)
318 Pathname
*path
= impl_from_IADsPathname(iface
);
323 TRACE("%p,%d,%p\n", iface
, index
, element
);
325 if (!element
) return E_INVALIDARG
;
328 hr
= HRESULT_FROM_WIN32(ERROR_INVALID_INDEX
);
333 end
= wcschr(p
, ',');
337 *element
= end
? SysAllocStringLen(p
, end
- p
) : SysAllocString(p
);
338 hr
= *element
? S_OK
: E_OUTOFMEMORY
;
342 p
= end
? end
+ 1 : NULL
;
349 static HRESULT WINAPI
path_AddLeafElement(IADsPathname
*iface
, BSTR element
)
351 FIXME("%p,%s: stub\n", iface
, debugstr_w(element
));
355 static HRESULT WINAPI
path_RemoveLeafElement(IADsPathname
*iface
)
357 FIXME("%p: stub\n", iface
);
361 static HRESULT WINAPI
path_CopyPath(IADsPathname
*iface
, IDispatch
**path
)
363 FIXME("%p,%p: stub\n", iface
, path
);
367 static HRESULT WINAPI
path_GetEscapedElement(IADsPathname
*iface
, LONG reserved
, BSTR element
, BSTR
*str
)
369 FIXME("%p,%d,%s,%p: stub\n", iface
, reserved
, debugstr_w(element
), str
);
373 static HRESULT WINAPI
path_get_EscapedMode(IADsPathname
*iface
, LONG
*mode
)
375 FIXME("%p,%p: stub\n", iface
, mode
);
379 static HRESULT WINAPI
path_put_EscapedMode(IADsPathname
*iface
, LONG mode
)
381 FIXME("%p,%d: stub\n", iface
, mode
);
385 static const IADsPathnameVtbl IADsPathname_vtbl
=
390 path_GetTypeInfoCount
,
400 path_RemoveLeafElement
,
402 path_GetEscapedElement
,
403 path_get_EscapedMode
,
407 static HRESULT
Pathname_create(REFIID riid
, void **obj
)
412 path
= heap_alloc(sizeof(*path
));
413 if (!path
) return E_OUTOFMEMORY
;
415 path
->IADsPathname_iface
.lpVtbl
= &IADsPathname_vtbl
;
417 path
->provider
= SysAllocString(L
"LDAP");
421 hr
= IADsPathname_QueryInterface(&path
->IADsPathname_iface
, riid
, obj
);
422 IADsPathname_Release(&path
->IADsPathname_iface
);
427 static const struct class_info
430 HRESULT (*constructor
)(REFIID
, void **);
433 { &CLSID_Pathname
, Pathname_create
}
438 IClassFactory IClassFactory_iface
;
440 const struct class_info
*info
;
443 static inline class_factory
*impl_from_IClassFactory(IClassFactory
*iface
)
445 return CONTAINING_RECORD(iface
, class_factory
, IClassFactory_iface
);
448 static HRESULT WINAPI
factory_QueryInterface(IClassFactory
*iface
, REFIID riid
, LPVOID
*obj
)
450 TRACE("%p,%s,%p\n", iface
, debugstr_guid(riid
), obj
);
452 if (!riid
|| !obj
) return E_INVALIDARG
;
454 if (IsEqualIID(riid
, &IID_IUnknown
) ||
455 IsEqualIID(riid
, &IID_IClassFactory
))
457 IClassFactory_AddRef(iface
);
463 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
464 return E_NOINTERFACE
;
467 static ULONG WINAPI
factory_AddRef(IClassFactory
*iface
)
469 class_factory
*factory
= impl_from_IClassFactory(iface
);
470 ULONG ref
= InterlockedIncrement(&factory
->ref
);
472 TRACE("(%p) ref %u\n", iface
, ref
);
477 static ULONG WINAPI
factory_Release(IClassFactory
*iface
)
479 class_factory
*factory
= impl_from_IClassFactory(iface
);
480 ULONG ref
= InterlockedDecrement(&factory
->ref
);
482 TRACE("(%p) ref %u\n", iface
, ref
);
490 static HRESULT WINAPI
factory_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID riid
, void **obj
)
492 class_factory
*factory
= impl_from_IClassFactory(iface
);
494 TRACE("%p,%s,%p\n", outer
, debugstr_guid(riid
), obj
);
496 if (!riid
|| !obj
) return E_INVALIDARG
;
499 if (outer
) return CLASS_E_NOAGGREGATION
;
501 return factory
->info
->constructor(riid
, obj
);
504 static HRESULT WINAPI
factory_LockServer(IClassFactory
*iface
, BOOL lock
)
506 FIXME("%p,%d: stub\n", iface
, lock
);
510 static const struct IClassFactoryVtbl factory_vtbl
=
512 factory_QueryInterface
,
515 factory_CreateInstance
,
519 static HRESULT
factory_constructor(const struct class_info
*info
, REFIID riid
, void **obj
)
521 class_factory
*factory
;
524 factory
= heap_alloc(sizeof(*factory
));
525 if (!factory
) return E_OUTOFMEMORY
;
527 factory
->IClassFactory_iface
.lpVtbl
= &factory_vtbl
;
529 factory
->info
= info
;
531 hr
= IClassFactory_QueryInterface(&factory
->IClassFactory_iface
, riid
, obj
);
532 IClassFactory_Release(&factory
->IClassFactory_iface
);
537 HRESULT WINAPI
DllGetClassObject(REFCLSID clsid
, REFIID iid
, LPVOID
*obj
)
541 TRACE("%s,%s,%p\n", debugstr_guid(clsid
), debugstr_guid(iid
), obj
);
543 if (!clsid
|| !iid
|| !obj
) return E_INVALIDARG
;
547 for (i
= 0; i
< ARRAY_SIZE(class_info
); i
++)
549 if (IsEqualCLSID(class_info
[i
].clsid
, clsid
))
550 return factory_constructor(&class_info
[i
], iid
, obj
);
553 FIXME("class %s/%s is not implemented\n", debugstr_guid(clsid
), debugstr_guid(iid
));
554 return CLASS_E_CLASSNOTAVAILABLE
;