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/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(activeds
);
36 DEFINE_GUID(CLSID_Pathname
,0x080d0d78,0xf421,0x11d0,0xa3,0x6e,0x00,0xc0,0x4f,0xb9,0x50,0xdc);
40 IADsPathname IADsPathname_iface
;
42 BSTR provider
, server
, dn
;
45 static inline Pathname
*impl_from_IADsPathname(IADsPathname
*iface
)
47 return CONTAINING_RECORD(iface
, Pathname
, IADsPathname_iface
);
50 static HRESULT WINAPI
path_QueryInterface(IADsPathname
*iface
, REFIID riid
, void **obj
)
52 TRACE("%p,%s,%p\n", iface
, debugstr_guid(riid
), obj
);
54 if (!riid
|| !obj
) return E_INVALIDARG
;
56 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
57 IsEqualGUID(riid
, &IID_IDispatch
) ||
58 IsEqualGUID(riid
, &IID_IADsPathname
))
60 IADsPathname_AddRef(iface
);
65 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
69 static ULONG WINAPI
path_AddRef(IADsPathname
*iface
)
71 Pathname
*path
= impl_from_IADsPathname(iface
);
72 return InterlockedIncrement(&path
->ref
);
75 static ULONG WINAPI
path_Release(IADsPathname
*iface
)
77 Pathname
*path
= impl_from_IADsPathname(iface
);
78 LONG ref
= InterlockedDecrement(&path
->ref
);
82 TRACE("destroying %p\n", iface
);
83 SysFreeString(path
->provider
);
84 SysFreeString(path
->server
);
85 SysFreeString(path
->dn
);
92 static HRESULT WINAPI
path_GetTypeInfoCount(IADsPathname
*iface
, UINT
*count
)
94 FIXME("%p,%p: stub\n", iface
, count
);
98 static HRESULT WINAPI
path_GetTypeInfo(IADsPathname
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
100 FIXME("%p,%u,%#lx,%p: stub\n", iface
, index
, lcid
, info
);
104 static HRESULT WINAPI
path_GetIDsOfNames(IADsPathname
*iface
, REFIID riid
, LPOLESTR
*names
,
105 UINT count
, LCID lcid
, DISPID
*dispid
)
107 FIXME("%p,%s,%p,%u,%lu,%p: stub\n", iface
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
111 static HRESULT WINAPI
path_Invoke(IADsPathname
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
, WORD flags
,
112 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excepinfo
, UINT
*argerr
)
114 FIXME("%p,%ld,%s,%04lx,%04x,%p,%p,%p,%p: stub\n", iface
, dispid
, debugstr_guid(riid
), lcid
, flags
,
115 params
, result
, excepinfo
, argerr
);
119 static HRESULT
parse_path(BSTR path
, BSTR
*provider
, BSTR
*server
, BSTR
*dn
)
128 if (wcsnicmp(path
, L
"LDAP:", 5) != 0)
129 return E_ADS_BAD_PATHNAME
;
131 *provider
= SysAllocStringLen(path
, 4);
132 if (!*provider
) return E_OUTOFMEMORY
;
135 if (!*p
) return S_OK
;
137 if (*p
++ != '/' || *p
++ != '/' || !*p
)
139 SysFreeString(*provider
);
140 return E_ADS_BAD_PATHNAME
;
145 while (*p
&& *p
!= '/')
152 SysFreeString(*provider
);
153 return E_ADS_BAD_PATHNAME
;
156 *server
= SysAllocStringLen(p_server
, server_len
);
159 SysFreeString(*provider
);
160 return E_OUTOFMEMORY
;
163 if (!*p
) return S_OK
;
165 if (*p
++ != '/' || !*p
)
167 SysFreeString(*provider
);
168 SysFreeString(*server
);
169 return E_ADS_BAD_PATHNAME
;
172 *dn
= SysAllocString(p
);
175 SysFreeString(*provider
);
176 SysFreeString(*server
);
177 return E_OUTOFMEMORY
;
183 static HRESULT WINAPI
path_Set(IADsPathname
*iface
, BSTR adspath
, LONG type
)
185 Pathname
*path
= impl_from_IADsPathname(iface
);
187 BSTR provider
, server
, dn
;
189 TRACE("%p,%s,%ld\n", iface
, debugstr_w(adspath
), type
);
191 if (!adspath
) return E_INVALIDARG
;
193 if (type
== ADS_SETTYPE_PROVIDER
)
195 SysFreeString(path
->provider
);
196 path
->provider
= SysAllocString(adspath
);
197 return path
->provider
? S_OK
: E_OUTOFMEMORY
;
200 if (type
== ADS_SETTYPE_SERVER
)
202 SysFreeString(path
->server
);
203 path
->server
= SysAllocString(adspath
);
204 return path
->server
? S_OK
: E_OUTOFMEMORY
;
207 if (type
== ADS_SETTYPE_DN
)
209 SysFreeString(path
->dn
);
210 path
->dn
= SysAllocString(adspath
);
211 return path
->dn
? S_OK
: E_OUTOFMEMORY
;
214 if (type
!= ADS_SETTYPE_FULL
)
216 FIXME("type %ld not implemented\n", type
);
220 hr
= parse_path(adspath
, &provider
, &server
, &dn
);
223 SysFreeString(path
->provider
);
224 SysFreeString(path
->server
);
225 SysFreeString(path
->dn
);
227 path
->provider
= provider
;
228 path
->server
= server
;
234 static HRESULT WINAPI
path_SetDisplayType(IADsPathname
*iface
, LONG type
)
236 FIXME("%p,%ld: stub\n", iface
, type
);
240 static HRESULT WINAPI
path_Retrieve(IADsPathname
*iface
, LONG type
, BSTR
*adspath
)
242 Pathname
*path
= impl_from_IADsPathname(iface
);
245 TRACE("%p,%ld,%p\n", iface
, type
, adspath
);
247 if (!adspath
) return E_INVALIDARG
;
252 FIXME("type %ld not implemented\n", type
);
255 case ADS_FORMAT_X500
:
256 len
= wcslen(path
->provider
) + 3;
257 if (path
->server
) len
+= wcslen(path
->server
) + 1;
258 if (path
->dn
) len
+= wcslen(path
->dn
);
260 *adspath
= SysAllocStringLen(NULL
, len
);
261 if (!*adspath
) break;
263 wcscpy(*adspath
, path
->provider
);
264 wcscat(*adspath
, L
"://");
267 wcscat(*adspath
, path
->server
);
268 wcscat(*adspath
, L
"/");
270 if (path
->dn
) wcscat(*adspath
, path
->dn
);
273 case ADS_FORMAT_PROVIDER
:
274 *adspath
= SysAllocString(path
->provider
);
277 case ADS_FORMAT_SERVER
:
278 *adspath
= path
->provider
? SysAllocString(path
->server
) : SysAllocStringLen(NULL
, 0);
281 case ADS_FORMAT_X500_DN
:
282 *adspath
= path
->dn
? SysAllocString(path
->dn
) : SysAllocStringLen(NULL
, 0);
285 case ADS_FORMAT_LEAF
:
287 *adspath
= SysAllocStringLen(NULL
, 0);
290 WCHAR
*p
= wcschr(path
->dn
, ',');
291 *adspath
= p
? SysAllocStringLen(path
->dn
, p
- path
->dn
) : SysAllocString(path
->dn
);
296 TRACE("=> %s\n", debugstr_w(*adspath
));
297 return *adspath
? S_OK
: E_OUTOFMEMORY
;
300 static HRESULT WINAPI
path_GetNumElements(IADsPathname
*iface
, LONG
*count
)
302 Pathname
*path
= impl_from_IADsPathname(iface
);
305 TRACE("%p,%p\n", iface
, count
);
307 if (!count
) return E_INVALIDARG
;
322 static HRESULT WINAPI
path_GetElement(IADsPathname
*iface
, LONG index
, BSTR
*element
)
324 Pathname
*path
= impl_from_IADsPathname(iface
);
329 TRACE("%p,%ld,%p\n", iface
, index
, element
);
331 if (!element
) return E_INVALIDARG
;
334 hr
= HRESULT_FROM_WIN32(ERROR_INVALID_INDEX
);
339 end
= wcschr(p
, ',');
343 *element
= end
? SysAllocStringLen(p
, end
- p
) : SysAllocString(p
);
344 hr
= *element
? S_OK
: E_OUTOFMEMORY
;
348 p
= end
? end
+ 1 : NULL
;
355 static HRESULT WINAPI
path_AddLeafElement(IADsPathname
*iface
, BSTR element
)
357 FIXME("%p,%s: stub\n", iface
, debugstr_w(element
));
361 static HRESULT WINAPI
path_RemoveLeafElement(IADsPathname
*iface
)
363 FIXME("%p: stub\n", iface
);
367 static HRESULT WINAPI
path_CopyPath(IADsPathname
*iface
, IDispatch
**path
)
369 FIXME("%p,%p: stub\n", iface
, path
);
373 static HRESULT WINAPI
path_GetEscapedElement(IADsPathname
*iface
, LONG reserved
, BSTR element
, BSTR
*str
)
375 FIXME("%p,%ld,%s,%p: stub\n", iface
, reserved
, debugstr_w(element
), str
);
379 static HRESULT WINAPI
path_get_EscapedMode(IADsPathname
*iface
, LONG
*mode
)
381 FIXME("%p,%p: stub\n", iface
, mode
);
385 static HRESULT WINAPI
path_put_EscapedMode(IADsPathname
*iface
, LONG mode
)
387 FIXME("%p,%ld: stub\n", iface
, mode
);
391 static const IADsPathnameVtbl IADsPathname_vtbl
=
396 path_GetTypeInfoCount
,
406 path_RemoveLeafElement
,
408 path_GetEscapedElement
,
409 path_get_EscapedMode
,
413 static HRESULT
Pathname_create(REFIID riid
, void **obj
)
418 path
= malloc(sizeof(*path
));
419 if (!path
) return E_OUTOFMEMORY
;
421 path
->IADsPathname_iface
.lpVtbl
= &IADsPathname_vtbl
;
423 path
->provider
= SysAllocString(L
"LDAP");
427 hr
= IADsPathname_QueryInterface(&path
->IADsPathname_iface
, riid
, obj
);
428 IADsPathname_Release(&path
->IADsPathname_iface
);
433 static const struct class_info
436 HRESULT (*constructor
)(REFIID
, void **);
439 { &CLSID_Pathname
, Pathname_create
}
444 IClassFactory IClassFactory_iface
;
446 const struct class_info
*info
;
449 static inline class_factory
*impl_from_IClassFactory(IClassFactory
*iface
)
451 return CONTAINING_RECORD(iface
, class_factory
, IClassFactory_iface
);
454 static HRESULT WINAPI
factory_QueryInterface(IClassFactory
*iface
, REFIID riid
, LPVOID
*obj
)
456 TRACE("%p,%s,%p\n", iface
, debugstr_guid(riid
), obj
);
458 if (!riid
|| !obj
) return E_INVALIDARG
;
460 if (IsEqualIID(riid
, &IID_IUnknown
) ||
461 IsEqualIID(riid
, &IID_IClassFactory
))
463 IClassFactory_AddRef(iface
);
469 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
470 return E_NOINTERFACE
;
473 static ULONG WINAPI
factory_AddRef(IClassFactory
*iface
)
475 class_factory
*factory
= impl_from_IClassFactory(iface
);
476 ULONG ref
= InterlockedIncrement(&factory
->ref
);
478 TRACE("(%p) ref %lu\n", iface
, ref
);
483 static ULONG WINAPI
factory_Release(IClassFactory
*iface
)
485 class_factory
*factory
= impl_from_IClassFactory(iface
);
486 ULONG ref
= InterlockedDecrement(&factory
->ref
);
488 TRACE("(%p) ref %lu\n", iface
, ref
);
496 static HRESULT WINAPI
factory_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID riid
, void **obj
)
498 class_factory
*factory
= impl_from_IClassFactory(iface
);
500 TRACE("%p,%s,%p\n", outer
, debugstr_guid(riid
), obj
);
502 if (!riid
|| !obj
) return E_INVALIDARG
;
505 if (outer
) return CLASS_E_NOAGGREGATION
;
507 return factory
->info
->constructor(riid
, obj
);
510 static HRESULT WINAPI
factory_LockServer(IClassFactory
*iface
, BOOL lock
)
512 FIXME("%p,%d: stub\n", iface
, lock
);
516 static const struct IClassFactoryVtbl factory_vtbl
=
518 factory_QueryInterface
,
521 factory_CreateInstance
,
525 static HRESULT
factory_constructor(const struct class_info
*info
, REFIID riid
, void **obj
)
527 class_factory
*factory
;
530 factory
= malloc(sizeof(*factory
));
531 if (!factory
) return E_OUTOFMEMORY
;
533 factory
->IClassFactory_iface
.lpVtbl
= &factory_vtbl
;
535 factory
->info
= info
;
537 hr
= IClassFactory_QueryInterface(&factory
->IClassFactory_iface
, riid
, obj
);
538 IClassFactory_Release(&factory
->IClassFactory_iface
);
543 HRESULT WINAPI
DllGetClassObject(REFCLSID clsid
, REFIID iid
, LPVOID
*obj
)
547 TRACE("%s,%s,%p\n", debugstr_guid(clsid
), debugstr_guid(iid
), obj
);
549 if (!clsid
|| !iid
|| !obj
) return E_INVALIDARG
;
553 for (i
= 0; i
< ARRAY_SIZE(class_info
); i
++)
555 if (IsEqualCLSID(class_info
[i
].clsid
, clsid
))
556 return factory_constructor(&class_info
[i
], iid
, obj
);
559 FIXME("class %s/%s is not implemented\n", debugstr_guid(clsid
), debugstr_guid(iid
));
560 return CLASS_E_CLASSNOTAVAILABLE
;