Commit 4232d31c authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

ole32: Implement Cache and Uncache for the data cache.

parent 07e3d538
...@@ -98,6 +98,8 @@ typedef struct DataCacheEntry ...@@ -98,6 +98,8 @@ typedef struct DataCacheEntry
* representation of the object is stored. * representation of the object is stored.
*/ */
IStorage *storage; IStorage *storage;
DWORD id;
} DataCacheEntry; } DataCacheEntry;
/**************************************************************************** /****************************************************************************
...@@ -136,6 +138,9 @@ struct DataCache ...@@ -136,6 +138,9 @@ struct DataCache
IStorage *presentationStorage; IStorage *presentationStorage;
struct list cache_list; struct list cache_list;
/* last id assigned to an object */
DWORD last_cache_id;
}; };
typedef struct DataCache DataCache; typedef struct DataCache DataCache;
...@@ -186,6 +191,15 @@ static DataCache* DataCache_Construct(REFCLSID clsid, ...@@ -186,6 +191,15 @@ static DataCache* DataCache_Construct(REFCLSID clsid,
static HRESULT DataCacheEntry_OpenPresStream(DataCacheEntry *This, static HRESULT DataCacheEntry_OpenPresStream(DataCacheEntry *This,
IStream **pStm); IStream **pStm);
static void DataCacheEntry_Destroy(DataCacheEntry *This)
{
list_remove(&This->entry);
if (This->storage)
IStorage_Release(This->storage);
HeapFree(GetProcessHeap(), 0, This->fmtetc.ptd);
HeapFree(GetProcessHeap(), 0, This);
}
static void DataCache_Destroy( static void DataCache_Destroy(
DataCache* ptrToDestroy) DataCache* ptrToDestroy)
{ {
...@@ -200,11 +214,7 @@ static void DataCache_Destroy( ...@@ -200,11 +214,7 @@ static void DataCache_Destroy(
} }
LIST_FOR_EACH_ENTRY_SAFE(cache_entry, next_cache_entry, &ptrToDestroy->cache_list, DataCacheEntry, entry) LIST_FOR_EACH_ENTRY_SAFE(cache_entry, next_cache_entry, &ptrToDestroy->cache_list, DataCacheEntry, entry)
{ DataCacheEntry_Destroy(cache_entry);
IStorage_Release(cache_entry->storage);
HeapFree(GetProcessHeap(), 0, cache_entry->fmtetc.ptd);
HeapFree(GetProcessHeap(), 0, cache_entry);
}
/* /*
* Free the datacache pointer. * Free the datacache pointer.
...@@ -237,6 +247,7 @@ static HRESULT DataCache_CreateEntry(DataCache *This, const FORMATETC *formatetc ...@@ -237,6 +247,7 @@ static HRESULT DataCache_CreateEntry(DataCache *This, const FORMATETC *formatetc
memcpy((*cache_entry)->fmtetc.ptd, formatetc->ptd, formatetc->ptd->tdSize); memcpy((*cache_entry)->fmtetc.ptd, formatetc->ptd, formatetc->ptd->tdSize);
} }
(*cache_entry)->storage = NULL; (*cache_entry)->storage = NULL;
(*cache_entry)->id = This->last_cache_id++;
list_add_tail(&This->cache_list, &(*cache_entry)->entry); list_add_tail(&This->cache_list, &(*cache_entry)->entry);
return S_OK; return S_OK;
} }
...@@ -1646,16 +1657,46 @@ static HRESULT WINAPI DataCache_Cache( ...@@ -1646,16 +1657,46 @@ static HRESULT WINAPI DataCache_Cache(
DWORD advf, DWORD advf,
DWORD* pdwConnection) DWORD* pdwConnection)
{ {
FIXME("stub\n"); DataCache *This = impl_from_IOleCache2(iface);
return E_NOTIMPL; DataCacheEntry *cache_entry;
HRESULT hr;
TRACE("(%p, 0x%x, %p)\n", pformatetc, advf, pdwConnection);
*pdwConnection = 0;
cache_entry = DataCache_GetEntryForFormatEtc(This, pformatetc);
if (cache_entry)
{
*pdwConnection = cache_entry->id;
return CACHE_S_SAMECACHE;
}
hr = DataCache_CreateEntry(This, pformatetc, &cache_entry);
if (SUCCEEDED(hr))
*pdwConnection = cache_entry->id;
return hr;
} }
static HRESULT WINAPI DataCache_Uncache( static HRESULT WINAPI DataCache_Uncache(
IOleCache2* iface, IOleCache2* iface,
DWORD dwConnection) DWORD dwConnection)
{ {
FIXME("stub\n"); DataCache *This = impl_from_IOleCache2(iface);
return E_NOTIMPL; DataCacheEntry *cache_entry;
TRACE("(%d)\n", dwConnection);
LIST_FOR_EACH_ENTRY(cache_entry, &This->cache_list, DataCacheEntry, entry)
if (cache_entry->id == dwConnection)
{
DataCacheEntry_Destroy(cache_entry);
return S_OK;
}
return OLE_E_NOCONNECTION;
} }
static HRESULT WINAPI DataCache_EnumCache( static HRESULT WINAPI DataCache_EnumCache(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment