ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

aclmulti.cpp
Go to the documentation of this file.
00001 /*
00002  *  Multisource AutoComplete list
00003  *
00004  *  Copyright 2007  Mikolaj Zalewski
00005  *  Copyright 2009  Andrew Hill
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00020  */
00021 
00022 #include "precomp.h"
00023 
00024 WINE_DEFAULT_DEBUG_CHANNEL(browseui);
00025 
00026 void CACLMulti::release_obj(struct ACLMultiSublist *obj)
00027 {
00028     obj->punk->Release();
00029     if (obj->pEnum)
00030         obj->pEnum->Release();
00031     if (obj->pACL)
00032         obj->pACL->Release();
00033 }
00034 
00035 CACLMulti::CACLMulti()
00036 {
00037     fObjectCount = 0;
00038     fCurrentObject = 0;
00039     fObjects = NULL;
00040 }
00041 
00042 CACLMulti::~CACLMulti()
00043 {
00044     int                                     i;
00045 
00046     TRACE("destroying %p\n", this);
00047     for (i = 0; i < fObjectCount; i++)
00048         release_obj(&fObjects[i]);
00049     CoTaskMemFree(fObjects);
00050 }
00051 
00052 HRESULT STDMETHODCALLTYPE CACLMulti::Append(IUnknown *punk)
00053 {
00054     TRACE("(%p, %p)\n", this, punk);
00055     if (punk == NULL)
00056         return E_FAIL;
00057 
00058     fObjects = reinterpret_cast<struct ACLMultiSublist *>(CoTaskMemRealloc(fObjects, sizeof(fObjects[0]) * (fObjectCount + 1)));
00059     fObjects[fObjectCount].punk = punk;
00060     punk->AddRef();
00061     if (FAILED(punk->QueryInterface(IID_IEnumString, (void **)&fObjects[fObjectCount].pEnum)))
00062         fObjects[fObjectCount].pEnum = NULL;
00063     if (FAILED(punk->QueryInterface(IID_IACList, (void **)&fObjects[fObjectCount].pACL)))
00064         fObjects[fObjectCount].pACL = NULL;
00065     fObjectCount++;
00066     return S_OK;
00067 }
00068 
00069 HRESULT STDMETHODCALLTYPE CACLMulti::Remove(IUnknown *punk)
00070 {
00071     int                                     i;
00072 
00073     TRACE("(%p, %p)\n", this, punk);
00074     for (i = 0; i < fObjectCount; i++)
00075         if (fObjects[i].punk == punk)
00076         {
00077             release_obj(&fObjects[i]);
00078             memmove(&fObjects[i], &fObjects[i + 1], (fObjectCount - i - 1) * sizeof(struct ACLMultiSublist));
00079             fObjectCount--;
00080             fObjects = reinterpret_cast<struct ACLMultiSublist *>(CoTaskMemRealloc(fObjects, sizeof(fObjects[0]) * fObjectCount));
00081             return S_OK;
00082         }
00083 
00084     return E_FAIL;
00085 }
00086 
00087 HRESULT STDMETHODCALLTYPE CACLMulti::Next(ULONG celt, LPOLESTR *rgelt, ULONG *pceltFetched)
00088 {
00089     TRACE("(%p, %d, %p, %p)\n", this, celt, rgelt, pceltFetched);
00090     while (fCurrentObject < fObjectCount)
00091     {
00092         if (fObjects[fCurrentObject].pEnum)
00093         {
00094             /* native browseui 6.0 also returns only one element */
00095             HRESULT ret = fObjects[fCurrentObject].pEnum->Next(1, rgelt, pceltFetched);
00096             if (ret != S_FALSE)
00097                 return ret;
00098         }
00099         fCurrentObject++;
00100     }
00101 
00102     if (pceltFetched)
00103         *pceltFetched = 0;
00104     *rgelt = NULL;
00105     return S_FALSE;
00106 }
00107 
00108 HRESULT STDMETHODCALLTYPE CACLMulti::Reset()
00109 {
00110     int                                     i;
00111 
00112     fCurrentObject = 0;
00113     for (i = 0; i < fObjectCount; i++)
00114     {
00115         if (fObjects[i].pEnum)
00116             fObjects[i].pEnum->Reset();
00117     }
00118     return S_OK;
00119 }
00120 
00121 HRESULT STDMETHODCALLTYPE CACLMulti::Skip(ULONG celt)
00122 {
00123     /* native browseui 6.0 returns this: */
00124     return E_NOTIMPL;
00125 }
00126 
00127 HRESULT STDMETHODCALLTYPE CACLMulti::Clone(IEnumString **ppOut)
00128 {
00129     *ppOut = NULL;
00130     /* native browseui 6.0 returns this: */
00131     return E_OUTOFMEMORY;
00132 }
00133 
00134 HRESULT STDMETHODCALLTYPE CACLMulti::Expand(LPCWSTR wstr)
00135 {
00136     HRESULT                                 res = S_OK;
00137     int                                     i;
00138 
00139     for (i = 0; i < fObjectCount; i++)
00140     {
00141         if (!fObjects[i].pACL)
00142             continue;
00143         res = fObjects[i].pACL->Expand(wstr);
00144         if (res == S_OK)
00145             break;
00146     }
00147     return res;
00148 }

Generated on Mon May 28 2012 04:22:29 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.