Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenenummoniker.c
Go to the documentation of this file.
00001 /* 00002 * IEnumMoniker implementation 00003 * 00004 * Copyright 2003 Robert Shearman 00005 * 00006 * This file contains the (internal) driver registration functions, 00007 * driver enumeration APIs and DirectDraw creation functions. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 * This library is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public 00020 * License along with this library; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00022 */ 00023 00024 #define COBJMACROS 00025 00026 #include "quartz_private.h" 00027 00028 #include "wine/debug.h" 00029 00030 WINE_DEFAULT_DEBUG_CHANNEL(quartz); 00031 00032 typedef struct EnumMonikerImpl 00033 { 00034 const IEnumMonikerVtbl *lpVtbl; 00035 LONG ref; 00036 IMoniker ** ppMoniker; 00037 ULONG nMonikerCount; 00038 ULONG index; 00039 } EnumMonikerImpl; 00040 00041 static const IEnumMonikerVtbl EnumMonikerImpl_Vtbl; 00042 00043 static ULONG WINAPI EnumMonikerImpl_AddRef(LPENUMMONIKER iface); 00044 00045 HRESULT EnumMonikerImpl_Create(IMoniker ** ppMoniker, ULONG nMonikerCount, IEnumMoniker ** ppEnum) 00046 { 00047 /* NOTE: assumes that array of IMonikers has already been AddRef'd 00048 * I.e. this function does not AddRef the array of incoming 00049 * IMonikers */ 00050 EnumMonikerImpl * pemi = CoTaskMemAlloc(sizeof(EnumMonikerImpl)); 00051 00052 TRACE("(%p, %d, %p)\n", ppMoniker, nMonikerCount, ppEnum); 00053 00054 *ppEnum = NULL; 00055 00056 if (!pemi) 00057 return E_OUTOFMEMORY; 00058 00059 pemi->lpVtbl = &EnumMonikerImpl_Vtbl; 00060 pemi->ref = 1; 00061 pemi->ppMoniker = CoTaskMemAlloc(nMonikerCount * sizeof(IMoniker*)); 00062 memcpy(pemi->ppMoniker, ppMoniker, nMonikerCount*sizeof(IMoniker*)); 00063 pemi->nMonikerCount = nMonikerCount; 00064 pemi->index = 0; 00065 00066 *ppEnum = (IEnumMoniker *)pemi; 00067 00068 return S_OK; 00069 } 00070 00071 /********************************************************************** 00072 * IEnumMoniker_QueryInterface (also IUnknown) 00073 */ 00074 static HRESULT WINAPI EnumMonikerImpl_QueryInterface( 00075 LPENUMMONIKER iface, 00076 REFIID riid, 00077 LPVOID *ppvObj) 00078 { 00079 EnumMonikerImpl *This = (EnumMonikerImpl *)iface; 00080 TRACE("\n\tIID:\t%s\n",debugstr_guid(riid)); 00081 00082 if (This == NULL || ppvObj == NULL) return E_POINTER; 00083 00084 if (IsEqualGUID(riid, &IID_IUnknown) || 00085 IsEqualGUID(riid, &IID_IEnumMoniker)) 00086 { 00087 *ppvObj = iface; 00088 EnumMonikerImpl_AddRef(iface); 00089 return S_OK; 00090 } 00091 00092 *ppvObj = NULL; 00093 FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); 00094 return E_NOINTERFACE; 00095 } 00096 00097 /********************************************************************** 00098 * IEnumMoniker_AddRef (also IUnknown) 00099 */ 00100 static ULONG WINAPI EnumMonikerImpl_AddRef(LPENUMMONIKER iface) 00101 { 00102 EnumMonikerImpl *This = (EnumMonikerImpl *)iface; 00103 ULONG ref; 00104 00105 if (This == NULL) return E_POINTER; 00106 00107 ref = InterlockedIncrement(&This->ref); 00108 00109 TRACE("(%p)->() AddRef from %d\n", iface, ref - 1); 00110 00111 return ref; 00112 } 00113 00114 /********************************************************************** 00115 * IEnumMoniker_Release (also IUnknown) 00116 */ 00117 static ULONG WINAPI EnumMonikerImpl_Release(LPENUMMONIKER iface) 00118 { 00119 EnumMonikerImpl *This = (EnumMonikerImpl *)iface; 00120 ULONG ref = InterlockedDecrement(&This->ref); 00121 00122 TRACE("(%p)->() Release from %d\n", iface, ref + 1); 00123 00124 if (!ref) 00125 { 00126 ULONG i; 00127 00128 for (i = 0; i < This->nMonikerCount; i++) 00129 IMoniker_Release(This->ppMoniker[i]); 00130 00131 CoTaskMemFree(This->ppMoniker); 00132 This->ppMoniker = NULL; 00133 CoTaskMemFree(This); 00134 return 0; 00135 } 00136 return ref; 00137 } 00138 00139 static HRESULT WINAPI EnumMonikerImpl_Next(LPENUMMONIKER iface, ULONG celt, IMoniker ** rgelt, ULONG * pceltFetched) 00140 { 00141 ULONG fetched; 00142 EnumMonikerImpl *This = (EnumMonikerImpl *)iface; 00143 00144 TRACE("(%p)->(%d, %p, %p)\n", iface, celt, rgelt, pceltFetched); 00145 00146 for (fetched = 0; (This->index + fetched < This->nMonikerCount) && (fetched < celt); fetched++) 00147 { 00148 rgelt[fetched] = This->ppMoniker[This->index + fetched]; 00149 IMoniker_AddRef(rgelt[fetched]); 00150 } 00151 00152 This->index += fetched; 00153 00154 TRACE("-- fetched %d\n", fetched); 00155 00156 if (pceltFetched) 00157 *pceltFetched = fetched; 00158 00159 if (fetched != celt) 00160 return S_FALSE; 00161 else 00162 return S_OK; 00163 } 00164 00165 static HRESULT WINAPI EnumMonikerImpl_Skip(LPENUMMONIKER iface, ULONG celt) 00166 { 00167 EnumMonikerImpl *This = (EnumMonikerImpl *)iface; 00168 00169 TRACE("(%p)->(%d)\n", iface, celt); 00170 00171 This->index += celt; 00172 00173 return S_OK; 00174 } 00175 00176 static HRESULT WINAPI EnumMonikerImpl_Reset(LPENUMMONIKER iface) 00177 { 00178 EnumMonikerImpl *This = (EnumMonikerImpl *)iface; 00179 00180 TRACE("(%p)->()\n", iface); 00181 00182 This->index = 0; 00183 00184 return S_OK; 00185 } 00186 00187 static HRESULT WINAPI EnumMonikerImpl_Clone(LPENUMMONIKER iface, IEnumMoniker ** ppenum) 00188 { 00189 FIXME("(%p)->(%p): stub\n", iface, ppenum); 00190 00191 return E_NOTIMPL; 00192 } 00193 00194 /********************************************************************** 00195 * IEnumMoniker_Vtbl 00196 */ 00197 static const IEnumMonikerVtbl EnumMonikerImpl_Vtbl = 00198 { 00199 EnumMonikerImpl_QueryInterface, 00200 EnumMonikerImpl_AddRef, 00201 EnumMonikerImpl_Release, 00202 EnumMonikerImpl_Next, 00203 EnumMonikerImpl_Skip, 00204 EnumMonikerImpl_Reset, 00205 EnumMonikerImpl_Clone 00206 }; Generated on Mon May 28 2012 04:21:25 for ReactOS by
1.7.6.1
|