1 /* 2 * Object Picker Dialog 3 * 4 * Copyright 2005 Thomas Weidenmueller <w3seek@reactos.com> 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 */ 20 21 #include "objsel_private.h" 22 23 #include <rpcproxy.h> 24 25 LONG dll_refs = 0; 26 static HINSTANCE hInstance; 27 28 /*********************************************************************** 29 * DllEntryPoint 30 */ 31 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) 32 { 33 switch(fdwReason) 34 { 35 case DLL_PROCESS_ATTACH: 36 hInstance = hinstDLL; 37 DisableThreadLibraryCalls(hInstance); 38 break; 39 } 40 return TRUE; 41 } 42 43 44 /*********************************************************************** 45 * DllGetClassObject (OBJSEL.@) 46 */ 47 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv) 48 { 49 TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv); 50 51 *ppv = NULL; 52 53 if (IsEqualGUID(rclsid, &CLSID_DsObjectPicker)) 54 return IClassFactory_QueryInterface(&OBJSEL_ClassFactory.IClassFactory_iface, iid, ppv); 55 56 FIXME("CLSID: %s, IID: %s\n", debugstr_guid(rclsid), debugstr_guid(iid)); 57 return CLASS_E_CLASSNOTAVAILABLE; 58 } 59 60 61 /*********************************************************************** 62 * DllCanUnloadNow (OBJSEL.@) 63 */ 64 HRESULT WINAPI DllCanUnloadNow(void) 65 { 66 return dll_refs != 0 ? S_FALSE : S_OK; 67 } 68 69 70 /*********************************************************************** 71 * DllRegisterServer (OBJSEL.@) 72 */ 73 HRESULT WINAPI DllRegisterServer(void) 74 { 75 return __wine_register_resources( hInstance ); 76 } 77 78 79 /*********************************************************************** 80 * DllUnregisterServer (OBJSEL.@) 81 */ 82 HRESULT WINAPI DllUnregisterServer(void) 83 { 84 return __wine_unregister_resources( hInstance ); 85 } 86 87 88 /********************************************************************** 89 * OBJSEL_IDsObjectPicker_Destroy (also IUnknown) 90 */ 91 static VOID OBJSEL_IDsObjectPicker_Destroy(IDsObjectPickerImpl *This) 92 { 93 HeapFree(GetProcessHeap(), 94 0, 95 This); 96 } 97 98 99 static inline IDsObjectPickerImpl *impl_from_IDsObjectPicker(IDsObjectPicker *iface) 100 { 101 return CONTAINING_RECORD(iface, IDsObjectPickerImpl, IDsObjectPicker_iface); 102 } 103 104 /********************************************************************** 105 * OBJSEL_IDsObjectPicker_AddRef (also IUnknown) 106 */ 107 static ULONG WINAPI OBJSEL_IDsObjectPicker_AddRef(IDsObjectPicker * iface) 108 { 109 IDsObjectPickerImpl *This = impl_from_IDsObjectPicker(iface); 110 ULONG ref; 111 112 TRACE("\n"); 113 114 if (This == NULL) return E_POINTER; 115 116 ref = InterlockedIncrement(&This->ref); 117 118 if (ref == 1) 119 { 120 InterlockedIncrement(&dll_refs); 121 } 122 123 return ref; 124 } 125 126 127 /********************************************************************** 128 * OBJSEL_IDsObjectPicker_Release (also IUnknown) 129 */ 130 static ULONG WINAPI OBJSEL_IDsObjectPicker_Release(IDsObjectPicker * iface) 131 { 132 IDsObjectPickerImpl *This = impl_from_IDsObjectPicker(iface); 133 ULONG ref; 134 135 TRACE("\n"); 136 137 if (This == NULL) return E_POINTER; 138 139 ref = InterlockedDecrement(&This->ref); 140 141 if (ref == 0) 142 { 143 InterlockedDecrement(&dll_refs); 144 OBJSEL_IDsObjectPicker_Destroy(This); 145 } 146 147 return ref; 148 } 149 150 151 /********************************************************************** 152 * OBJSEL_IDsObjectPicker_QueryInterface (also IUnknown) 153 */ 154 static HRESULT WINAPI OBJSEL_IDsObjectPicker_QueryInterface( 155 IDsObjectPicker * iface, 156 REFIID riid, 157 LPVOID *ppvObj) 158 { 159 TRACE("\n\tIID:\t%s\n",debugstr_guid(riid)); 160 161 if (ppvObj == NULL) return E_POINTER; 162 163 if (IsEqualGUID(riid, &IID_IUnknown) || 164 IsEqualGUID(riid, &IID_IDsObjectPicker)) 165 { 166 *ppvObj = iface; 167 OBJSEL_IDsObjectPicker_AddRef(iface); 168 return S_OK; 169 } 170 171 FIXME("- no interface IID: %s\n", debugstr_guid(riid)); 172 return E_NOINTERFACE; 173 } 174 175 176 /********************************************************************** 177 * OBJSEL_IDsObjectPicker_Initialize 178 */ 179 static HRESULT WINAPI OBJSEL_IDsObjectPicker_Initialize( 180 IDsObjectPicker * iface, 181 PDSOP_INIT_INFO pInitInfo) 182 { 183 FIXME("stub!\n"); 184 return S_OK; 185 } 186 187 188 /********************************************************************** 189 * OBJSEL_IDsObjectPicker_InvokeDialog 190 */ 191 static HRESULT WINAPI OBJSEL_IDsObjectPicker_InvokeDialog( 192 IDsObjectPicker * iface, 193 HWND hwndParent, 194 IDataObject** ppdoSelections) 195 { 196 FIXME("stub!\n"); 197 return S_FALSE; 198 } 199 200 201 /********************************************************************** 202 * IDsObjectPicker_Vtbl 203 */ 204 static IDsObjectPickerVtbl IDsObjectPicker_Vtbl = 205 { 206 OBJSEL_IDsObjectPicker_QueryInterface, 207 OBJSEL_IDsObjectPicker_AddRef, 208 OBJSEL_IDsObjectPicker_Release, 209 OBJSEL_IDsObjectPicker_Initialize, 210 OBJSEL_IDsObjectPicker_InvokeDialog 211 }; 212 213 214 /********************************************************************** 215 * OBJSEL_IDsObjectPicker_Create 216 */ 217 HRESULT WINAPI OBJSEL_IDsObjectPicker_Create(LPVOID *ppvObj) 218 { 219 IDsObjectPickerImpl *Instance = HeapAlloc(GetProcessHeap(), 220 HEAP_ZERO_MEMORY, 221 sizeof(IDsObjectPickerImpl)); 222 if (Instance != NULL) 223 { 224 Instance->IDsObjectPicker_iface.lpVtbl = &IDsObjectPicker_Vtbl; 225 OBJSEL_IDsObjectPicker_AddRef(&Instance->IDsObjectPicker_iface); 226 227 *ppvObj = Instance; 228 return S_OK; 229 } 230 else 231 return E_OUTOFMEMORY; 232 } 233