mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
wfreerdp: consolidate cliprdr code
This commit is contained in:
@@ -19,12 +19,6 @@ set(MODULE_NAME "wfreerdp-client")
|
||||
set(MODULE_PREFIX "FREERDP_CLIENT_WINDOWS_CONTROL")
|
||||
|
||||
set(${MODULE_PREFIX}_SRCS
|
||||
wf_cliprdr_DataObject.c
|
||||
wf_cliprdr_DataObject.h
|
||||
wf_cliprdr_EnumFORMATETC.c
|
||||
wf_cliprdr_EnumFORMATETC.h
|
||||
wf_cliprdr_Stream.c
|
||||
wf_cliprdr_Stream.h
|
||||
wf_gdi.c
|
||||
wf_gdi.h
|
||||
wf_event.c
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -28,18 +28,63 @@
|
||||
#include "wf_client.h"
|
||||
#include <freerdp/log.h>
|
||||
|
||||
#define TAG CLIENT_TAG(WIN_CLIPRDR_TAG)
|
||||
#ifdef WITH_DEBUG_CLIPRDR
|
||||
#define DEBUG_CLIPRDR(fmt, ...) WLog_DBG(WIN_CLIPRDR_TAG, fmt, ## __VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_CLIPRDR(fmt, ...) do { } while (0)
|
||||
#endif
|
||||
|
||||
struct _CliprdrStream
|
||||
{
|
||||
IStream iStream;
|
||||
|
||||
LONG m_lRefCount;
|
||||
LONG m_lIndex;
|
||||
ULARGE_INTEGER m_lSize;
|
||||
ULARGE_INTEGER m_lOffset;
|
||||
void* m_pData;
|
||||
};
|
||||
typedef struct _CliprdrStream CliprdrStream;
|
||||
|
||||
CliprdrStream* CliprdrStream_New(LONG index, void* pData);
|
||||
void CliprdrStream_Delete(CliprdrStream* instance);
|
||||
|
||||
struct _CliprdrDataObject
|
||||
{
|
||||
IDataObject iDataObject;
|
||||
|
||||
LONG m_lRefCount;
|
||||
FORMATETC* m_pFormatEtc;
|
||||
STGMEDIUM* m_pStgMedium;
|
||||
LONG m_nNumFormats;
|
||||
LONG m_nStreams;
|
||||
IStream** m_pStream;
|
||||
void* m_pData;
|
||||
};
|
||||
typedef struct _CliprdrDataObject CliprdrDataObject;
|
||||
|
||||
CliprdrDataObject* CliprdrDataObject_New(FORMATETC* fmtetc, STGMEDIUM* stgmed, int count, void* data);
|
||||
void CliprdrDataObject_Delete(CliprdrDataObject* instance);
|
||||
|
||||
struct _CliprdrEnumFORMATETC
|
||||
{
|
||||
IEnumFORMATETC iEnumFORMATETC;
|
||||
|
||||
LONG m_lRefCount;
|
||||
LONG m_nIndex;
|
||||
LONG m_nNumFormats;
|
||||
FORMATETC* m_pFormatEtc;
|
||||
};
|
||||
typedef struct _CliprdrEnumFORMATETC CliprdrEnumFORMATETC;
|
||||
|
||||
CliprdrEnumFORMATETC* CliprdrEnumFORMATETC_New(int nFormats, FORMATETC* pFormatEtc);
|
||||
void CliprdrEnumFORMATETC_Delete(CliprdrEnumFORMATETC* This);
|
||||
|
||||
struct format_mapping
|
||||
{
|
||||
UINT32 remote_format_id;
|
||||
UINT32 local_format_id;
|
||||
void *name; /* Unicode or ASCII characters with NULL terminator */
|
||||
void* name; /* Unicode or ASCII characters with NULL terminator */
|
||||
};
|
||||
typedef struct format_mapping formatMapping;
|
||||
|
||||
|
||||
@@ -1,372 +0,0 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Implementation of the IDataObject COM interface
|
||||
*
|
||||
* Copyright 2014 Zhang Zhaolong <zhangzl2013@126.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "wf_cliprdr.h"
|
||||
#include "wf_cliprdr_Stream.h"
|
||||
#include "wf_cliprdr_DataObject.h"
|
||||
#include "wf_cliprdr_EnumFORMATETC.h"
|
||||
|
||||
static int cliprdr_lookup_format(CliprdrDataObject* instance, FORMATETC* pFormatEtc)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < instance->m_nNumFormats; i++)
|
||||
{
|
||||
if ((pFormatEtc->tymed & instance->m_pFormatEtc[i].tymed) &&
|
||||
pFormatEtc->cfFormat == instance->m_pFormatEtc[i].cfFormat &&
|
||||
pFormatEtc->dwAspect == instance->m_pFormatEtc[i].dwAspect)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrDataObject_QueryInterface(IDataObject* This, REFIID riid, void** ppvObject)
|
||||
{
|
||||
CliprdrDataObject* instance = (CliprdrDataObject*) This;
|
||||
|
||||
if (IsEqualIID(riid, &IID_IDataObject) || IsEqualIID(riid, &IID_IUnknown))
|
||||
{
|
||||
IDataObject_AddRef(This);
|
||||
*ppvObject = This;
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ppvObject = 0;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE CliprdrDataObject_AddRef(IDataObject* This)
|
||||
{
|
||||
CliprdrDataObject* instance = (CliprdrDataObject*) This;
|
||||
|
||||
return InterlockedIncrement(&instance->m_lRefCount);
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE CliprdrDataObject_Release(IDataObject* This)
|
||||
{
|
||||
LONG count;
|
||||
CliprdrDataObject* instance = (CliprdrDataObject*) This;
|
||||
|
||||
count = InterlockedDecrement(&instance->m_lRefCount);
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
CliprdrDataObject_Delete(instance);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetData(IDataObject* This, FORMATETC* pFormatEtc, STGMEDIUM* pMedium)
|
||||
{
|
||||
int i, idx;
|
||||
CliprdrDataObject* instance = (CliprdrDataObject*) This;
|
||||
cliprdrContext* cliprdr = (cliprdrContext*) instance->m_pData;
|
||||
|
||||
if (pFormatEtc == NULL || pMedium == NULL)
|
||||
{
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if ((idx = cliprdr_lookup_format(instance, pFormatEtc)) == -1)
|
||||
{
|
||||
return DV_E_FORMATETC;
|
||||
}
|
||||
|
||||
pMedium->tymed = instance->m_pFormatEtc[idx].tymed;
|
||||
pMedium->pUnkForRelease = 0;
|
||||
|
||||
if (instance->m_pFormatEtc[idx].cfFormat == cliprdr->ID_FILEDESCRIPTORW)
|
||||
{
|
||||
if (cliprdr_send_data_request(cliprdr, instance->m_pFormatEtc[idx].cfFormat) != 0)
|
||||
return E_UNEXPECTED;
|
||||
|
||||
pMedium->hGlobal = cliprdr->hmem; /* points to a FILEGROUPDESCRIPTOR structure */
|
||||
|
||||
/* GlobalLock returns a pointer to the first byte of the memory block,
|
||||
* in which is a FILEGROUPDESCRIPTOR structure, whose first UINT member
|
||||
* is the number of FILEDESCRIPTOR's */
|
||||
instance->m_nStreams = *(PUINT)GlobalLock(cliprdr->hmem);
|
||||
GlobalUnlock(cliprdr->hmem);
|
||||
|
||||
if (instance->m_nStreams > 0)
|
||||
{
|
||||
if (!instance->m_pStream)
|
||||
{
|
||||
instance->m_pStream = (LPSTREAM*) calloc(instance->m_nStreams, sizeof(LPSTREAM));
|
||||
|
||||
if (instance->m_pStream)
|
||||
{
|
||||
for (i = 0; i < instance->m_nStreams; i++)
|
||||
{
|
||||
instance->m_pStream[i] = (IStream*) CliprdrStream_New(i, cliprdr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!instance->m_pStream)
|
||||
{
|
||||
cliprdr->hmem = GlobalFree(cliprdr->hmem);
|
||||
pMedium->hGlobal = cliprdr->hmem;
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
}
|
||||
else if (instance->m_pFormatEtc[idx].cfFormat == cliprdr->ID_FILECONTENTS)
|
||||
{
|
||||
if (pFormatEtc->lindex < instance->m_nStreams)
|
||||
{
|
||||
pMedium->pstm = instance->m_pStream[pFormatEtc->lindex];
|
||||
IDataObject_AddRef(instance->m_pStream[pFormatEtc->lindex]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
}
|
||||
else if (instance->m_pFormatEtc[idx].cfFormat == cliprdr->ID_PREFERREDDROPEFFECT)
|
||||
{
|
||||
if (cliprdr_send_data_request(cliprdr, instance->m_pFormatEtc[idx].cfFormat) != 0)
|
||||
return E_UNEXPECTED;
|
||||
|
||||
pMedium->hGlobal = cliprdr->hmem;
|
||||
}
|
||||
else
|
||||
{
|
||||
return E_UNEXPECTED;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetDataHere(IDataObject* This, FORMATETC *pformatetc, STGMEDIUM *pmedium)
|
||||
{
|
||||
CliprdrDataObject* instance = (CliprdrDataObject*) This;
|
||||
|
||||
return DATA_E_FORMATETC;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrDataObject_QueryGetData(IDataObject* This, FORMATETC *pformatetc)
|
||||
{
|
||||
CliprdrDataObject* instance = (CliprdrDataObject*) This;
|
||||
|
||||
if (!pformatetc)
|
||||
return E_INVALIDARG;
|
||||
|
||||
return (cliprdr_lookup_format(instance, pformatetc) == -1) ? DV_E_FORMATETC : S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetCanonicalFormatEtc(IDataObject* This, FORMATETC *pformatectIn, FORMATETC *pformatetcOut)
|
||||
{
|
||||
CliprdrDataObject* instance = (CliprdrDataObject*) This;
|
||||
|
||||
if (!pformatetcOut)
|
||||
return E_INVALIDARG;
|
||||
|
||||
pformatetcOut->ptd = NULL;
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrDataObject_SetData(IDataObject* This, FORMATETC *pformatetc, STGMEDIUM *pmedium, BOOL fRelease)
|
||||
{
|
||||
CliprdrDataObject* instance = (CliprdrDataObject*) This;
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrDataObject_EnumFormatEtc(IDataObject* This, DWORD dwDirection, IEnumFORMATETC **ppenumFormatEtc)
|
||||
{
|
||||
CliprdrDataObject* instance = (CliprdrDataObject*) This;
|
||||
|
||||
if (!ppenumFormatEtc)
|
||||
return E_INVALIDARG;
|
||||
|
||||
if(dwDirection == DATADIR_GET)
|
||||
{
|
||||
*ppenumFormatEtc = (IEnumFORMATETC*) CliprdrEnumFORMATETC_New(instance->m_nNumFormats, instance->m_pFormatEtc);
|
||||
return (*ppenumFormatEtc) ? S_OK : E_OUTOFMEMORY;
|
||||
}
|
||||
else
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrDataObject_DAdvise(IDataObject* This, FORMATETC *pformatetc, DWORD advf, IAdviseSink* pAdvSink, DWORD *pdwConnection)
|
||||
{
|
||||
CliprdrDataObject* instance = (CliprdrDataObject*) This;
|
||||
|
||||
return OLE_E_ADVISENOTSUPPORTED;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrDataObject_DUnadvise(IDataObject* This, DWORD dwConnection)
|
||||
{
|
||||
CliprdrDataObject* instance = (CliprdrDataObject*) This;
|
||||
|
||||
return OLE_E_ADVISENOTSUPPORTED;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrDataObject_EnumDAdvise(IDataObject* This, IEnumSTATDATA** ppenumAdvise)
|
||||
{
|
||||
CliprdrDataObject* instance = (CliprdrDataObject*) This;
|
||||
|
||||
return OLE_E_ADVISENOTSUPPORTED;
|
||||
}
|
||||
|
||||
CliprdrDataObject* CliprdrDataObject_New(FORMATETC* fmtetc, STGMEDIUM* stgmed, int count, void* data)
|
||||
{
|
||||
int i;
|
||||
CliprdrDataObject* instance;
|
||||
IDataObject* iDataObject;
|
||||
|
||||
instance = (CliprdrDataObject*) calloc(1, sizeof(CliprdrDataObject));
|
||||
|
||||
if (instance)
|
||||
{
|
||||
iDataObject = &instance->iDataObject;
|
||||
|
||||
iDataObject->lpVtbl = (IDataObjectVtbl*) calloc(1, sizeof(IDataObjectVtbl));
|
||||
|
||||
if (iDataObject->lpVtbl)
|
||||
{
|
||||
iDataObject->lpVtbl->QueryInterface = CliprdrDataObject_QueryInterface;
|
||||
iDataObject->lpVtbl->AddRef = CliprdrDataObject_AddRef;
|
||||
iDataObject->lpVtbl->Release = CliprdrDataObject_Release;
|
||||
iDataObject->lpVtbl->GetData = CliprdrDataObject_GetData;
|
||||
iDataObject->lpVtbl->GetDataHere = CliprdrDataObject_GetDataHere;
|
||||
iDataObject->lpVtbl->QueryGetData = CliprdrDataObject_QueryGetData;
|
||||
iDataObject->lpVtbl->GetCanonicalFormatEtc = CliprdrDataObject_GetCanonicalFormatEtc;
|
||||
iDataObject->lpVtbl->SetData = CliprdrDataObject_SetData;
|
||||
iDataObject->lpVtbl->EnumFormatEtc = CliprdrDataObject_EnumFormatEtc;
|
||||
iDataObject->lpVtbl->DAdvise = CliprdrDataObject_DAdvise;
|
||||
iDataObject->lpVtbl->DUnadvise = CliprdrDataObject_DUnadvise;
|
||||
iDataObject->lpVtbl->EnumDAdvise = CliprdrDataObject_EnumDAdvise;
|
||||
|
||||
instance->m_lRefCount = 1;
|
||||
instance->m_nNumFormats = count;
|
||||
instance->m_pData = data;
|
||||
instance->m_nStreams = 0;
|
||||
instance->m_pStream = NULL;
|
||||
|
||||
instance->m_pFormatEtc = (FORMATETC*) calloc(count, sizeof(FORMATETC));
|
||||
instance->m_pStgMedium = (STGMEDIUM*) calloc(count, sizeof(STGMEDIUM));
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
instance->m_pFormatEtc[i] = fmtetc[i];
|
||||
instance->m_pStgMedium[i] = stgmed[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
free(instance);
|
||||
instance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void CliprdrDataObject_Delete(CliprdrDataObject* instance)
|
||||
{
|
||||
if (instance)
|
||||
{
|
||||
if (instance->iDataObject.lpVtbl)
|
||||
free(instance->iDataObject.lpVtbl);
|
||||
|
||||
if (instance->m_pFormatEtc)
|
||||
free(instance->m_pFormatEtc);
|
||||
|
||||
if (instance->m_pStgMedium)
|
||||
free(instance->m_pStgMedium);
|
||||
|
||||
if(instance->m_pStream)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < instance->m_nStreams; i++)
|
||||
{
|
||||
CliprdrStream_Release(instance->m_pStream[i]);
|
||||
}
|
||||
|
||||
free(instance->m_pStream);
|
||||
}
|
||||
|
||||
free(instance);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOL wf_create_file_obj(cliprdrContext* cliprdr, IDataObject** ppDataObject)
|
||||
{
|
||||
FORMATETC fmtetc[3];
|
||||
STGMEDIUM stgmeds[3];
|
||||
|
||||
if (!ppDataObject)
|
||||
return FALSE;
|
||||
|
||||
fmtetc[0].cfFormat = RegisterClipboardFormatW(CFSTR_FILEDESCRIPTORW);
|
||||
fmtetc[0].dwAspect = DVASPECT_CONTENT;
|
||||
fmtetc[0].lindex = 0;
|
||||
fmtetc[0].ptd = NULL;
|
||||
fmtetc[0].tymed = TYMED_HGLOBAL;
|
||||
|
||||
stgmeds[0].tymed = TYMED_HGLOBAL;
|
||||
stgmeds[0].hGlobal = NULL;
|
||||
stgmeds[0].pUnkForRelease = NULL;
|
||||
|
||||
fmtetc[1].cfFormat = RegisterClipboardFormatW(CFSTR_FILECONTENTS);
|
||||
fmtetc[1].dwAspect = DVASPECT_CONTENT;
|
||||
fmtetc[1].lindex = 0;
|
||||
fmtetc[1].ptd = NULL;
|
||||
fmtetc[1].tymed = TYMED_ISTREAM;
|
||||
|
||||
stgmeds[1].tymed = TYMED_ISTREAM;
|
||||
stgmeds[1].pstm = NULL;
|
||||
stgmeds[1].pUnkForRelease = NULL;
|
||||
|
||||
fmtetc[2].cfFormat = RegisterClipboardFormatW(CFSTR_PREFERREDDROPEFFECT);
|
||||
fmtetc[2].dwAspect = DVASPECT_CONTENT;
|
||||
fmtetc[2].lindex = 0;
|
||||
fmtetc[2].ptd = NULL;
|
||||
fmtetc[2].tymed = TYMED_HGLOBAL;
|
||||
|
||||
stgmeds[2].tymed = TYMED_HGLOBAL;
|
||||
stgmeds[2].hGlobal = NULL;
|
||||
stgmeds[2].pUnkForRelease = NULL;
|
||||
|
||||
*ppDataObject = (IDataObject*) CliprdrDataObject_New(fmtetc, stgmeds, 3, cliprdr);
|
||||
|
||||
return (*ppDataObject) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
void wf_destroy_file_obj(IDataObject* instance)
|
||||
{
|
||||
if (instance)
|
||||
IDataObject_Release(instance);
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Implementation of the IDataObject COM interface
|
||||
*
|
||||
* Copyright 2014 Zhang Zhaolong <zhangzl2013@126.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __WF_CLIPRDR_DATAOBJECT_H__
|
||||
#define __WF_CLIPRDR_DATAOBJECT_H__
|
||||
|
||||
#define CINTERFACE
|
||||
#define COBJMACROS
|
||||
|
||||
#include <windows.h>
|
||||
#include <Ole2.h>
|
||||
#include <ShlObj.h>
|
||||
|
||||
typedef struct _CliprdrDataObject {
|
||||
IDataObject iDataObject;
|
||||
|
||||
// private
|
||||
LONG m_lRefCount;
|
||||
FORMATETC *m_pFormatEtc;
|
||||
STGMEDIUM *m_pStgMedium;
|
||||
LONG m_nNumFormats;
|
||||
LONG m_nStreams;
|
||||
IStream **m_pStream;
|
||||
void *m_pData;
|
||||
}CliprdrDataObject;
|
||||
|
||||
CliprdrDataObject *CliprdrDataObject_New(FORMATETC *fmtetc, STGMEDIUM *stgmed, int count, void *data);
|
||||
void CliprdrDataObject_Delete(CliprdrDataObject *instance);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrDataObject_QueryInterface(IDataObject *This, REFIID riid, void **ppvObject);
|
||||
ULONG STDMETHODCALLTYPE CliprdrDataObject_AddRef(IDataObject *This);
|
||||
ULONG STDMETHODCALLTYPE CliprdrDataObject_Release(IDataObject *This);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetData(IDataObject *This, FORMATETC *pformatetcIn, STGMEDIUM *pmedium);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetDataHere(IDataObject *This, FORMATETC *pformatetc, STGMEDIUM *pmedium);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrDataObject_QueryGetData(IDataObject *This, FORMATETC *pformatetc);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetCanonicalFormatEtc(IDataObject *This, FORMATETC *pformatectIn, FORMATETC *pformatetcOut);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrDataObject_SetData(IDataObject *This, FORMATETC *pformatetc, STGMEDIUM *pmedium, BOOL fRelease);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrDataObject_EnumFormatEtc(IDataObject *This, DWORD dwDirection, IEnumFORMATETC **ppenumFormatEtc);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrDataObject_DAdvise(IDataObject *This, FORMATETC *pformatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrDataObject_DUnadvise(IDataObject *This, DWORD dwConnection);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrDataObject_EnumDAdvise(IDataObject *This, IEnumSTATDATA **ppenumAdvise);
|
||||
|
||||
#endif // __WF_CLIPRDR_DATAOBJECT_H__
|
||||
@@ -1,202 +0,0 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Implementation of the IEnumFORMATETC COM interface
|
||||
*
|
||||
* Copyright 2014 Zhang Zhaolong <zhangzl2013@126.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "wf_cliprdr_EnumFORMATETC.h"
|
||||
|
||||
static void cliprdr_format_deep_copy(FORMATETC* dest, FORMATETC* source)
|
||||
{
|
||||
*dest = *source;
|
||||
|
||||
if (source->ptd)
|
||||
{
|
||||
dest->ptd = (DVTARGETDEVICE*) CoTaskMemAlloc(sizeof(DVTARGETDEVICE));
|
||||
*(dest->ptd) = *(source->ptd);
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_QueryInterface(IEnumFORMATETC* This, REFIID riid, void** ppvObject)
|
||||
{
|
||||
CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*) This;
|
||||
|
||||
if (IsEqualIID(riid, &IID_IEnumFORMATETC) || IsEqualIID(riid, &IID_IUnknown))
|
||||
{
|
||||
IEnumFORMATETC_AddRef(This);
|
||||
*ppvObject = This;
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ppvObject = 0;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE CliprdrEnumFORMATETC_AddRef(IEnumFORMATETC* This)
|
||||
{
|
||||
CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*) This;
|
||||
|
||||
return InterlockedIncrement(&instance->m_lRefCount);
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE CliprdrEnumFORMATETC_Release(IEnumFORMATETC* This)
|
||||
{
|
||||
LONG count;
|
||||
CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*) This;
|
||||
|
||||
count = InterlockedDecrement(&instance->m_lRefCount);
|
||||
|
||||
if(count == 0)
|
||||
{
|
||||
CliprdrEnumFORMATETC_Delete(instance);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Next(IEnumFORMATETC* This, ULONG celt, FORMATETC *rgelt, ULONG *pceltFetched)
|
||||
{
|
||||
ULONG copied = 0;
|
||||
CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*) This;
|
||||
|
||||
if (celt == 0 || !rgelt)
|
||||
return E_INVALIDARG;
|
||||
|
||||
while (instance->m_nIndex < instance->m_nNumFormats && copied < celt)
|
||||
{
|
||||
cliprdr_format_deep_copy(&rgelt[copied++], &instance->m_pFormatEtc[instance->m_nIndex++]);
|
||||
}
|
||||
|
||||
if (pceltFetched != 0)
|
||||
*pceltFetched = copied;
|
||||
|
||||
return (copied == celt) ? S_OK : S_FALSE;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Skip(IEnumFORMATETC* This, ULONG celt)
|
||||
{
|
||||
CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*) This;
|
||||
|
||||
if (instance->m_nIndex + (LONG) celt > instance->m_nNumFormats)
|
||||
return S_FALSE;
|
||||
|
||||
instance->m_nIndex += celt;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Reset(IEnumFORMATETC* This)
|
||||
{
|
||||
CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*) This;
|
||||
|
||||
instance->m_nIndex = 0;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Clone(IEnumFORMATETC* This, IEnumFORMATETC **ppEnum)
|
||||
{
|
||||
CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*) This;
|
||||
|
||||
if (!ppEnum)
|
||||
return E_INVALIDARG;
|
||||
|
||||
*ppEnum = (IEnumFORMATETC *)CliprdrEnumFORMATETC_New(instance->m_nNumFormats, instance->m_pFormatEtc);
|
||||
|
||||
if (!*ppEnum)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
((CliprdrEnumFORMATETC *) *ppEnum)->m_nIndex = instance->m_nIndex;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CliprdrEnumFORMATETC *CliprdrEnumFORMATETC_New(int nFormats, FORMATETC *pFormatEtc)
|
||||
{
|
||||
CliprdrEnumFORMATETC *instance;
|
||||
IEnumFORMATETC *iEnumFORMATETC;
|
||||
int i;
|
||||
|
||||
if (!pFormatEtc)
|
||||
return NULL;
|
||||
|
||||
instance = (CliprdrEnumFORMATETC *)calloc(1, sizeof(CliprdrEnumFORMATETC));
|
||||
|
||||
if (instance)
|
||||
{
|
||||
iEnumFORMATETC = &instance->iEnumFORMATETC;
|
||||
|
||||
iEnumFORMATETC->lpVtbl = (IEnumFORMATETCVtbl *)calloc(1, sizeof(IEnumFORMATETCVtbl));
|
||||
if (iEnumFORMATETC->lpVtbl)
|
||||
{
|
||||
iEnumFORMATETC->lpVtbl->QueryInterface = CliprdrEnumFORMATETC_QueryInterface;
|
||||
iEnumFORMATETC->lpVtbl->AddRef = CliprdrEnumFORMATETC_AddRef;
|
||||
iEnumFORMATETC->lpVtbl->Release = CliprdrEnumFORMATETC_Release;
|
||||
iEnumFORMATETC->lpVtbl->Next = CliprdrEnumFORMATETC_Next;
|
||||
iEnumFORMATETC->lpVtbl->Skip = CliprdrEnumFORMATETC_Skip;
|
||||
iEnumFORMATETC->lpVtbl->Reset = CliprdrEnumFORMATETC_Reset;
|
||||
iEnumFORMATETC->lpVtbl->Clone = CliprdrEnumFORMATETC_Clone;
|
||||
|
||||
instance->m_lRefCount = 0;
|
||||
instance->m_nIndex = 0;
|
||||
instance->m_nNumFormats = nFormats;
|
||||
instance->m_pFormatEtc = (FORMATETC *)calloc(nFormats, sizeof(FORMATETC));
|
||||
|
||||
for (i = 0; i < nFormats; i++)
|
||||
{
|
||||
cliprdr_format_deep_copy(&instance->m_pFormatEtc[i], &pFormatEtc[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
free(instance);
|
||||
instance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void CliprdrEnumFORMATETC_Delete(CliprdrEnumFORMATETC *instance)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (instance)
|
||||
{
|
||||
if (instance->iEnumFORMATETC.lpVtbl)
|
||||
free(instance->iEnumFORMATETC.lpVtbl);
|
||||
|
||||
if (instance->m_pFormatEtc)
|
||||
{
|
||||
for (i = 0; i < instance->m_nNumFormats; i++)
|
||||
{
|
||||
if (instance->m_pFormatEtc[i].ptd)
|
||||
CoTaskMemFree(instance->m_pFormatEtc[i].ptd);
|
||||
}
|
||||
|
||||
free(instance->m_pFormatEtc);
|
||||
}
|
||||
|
||||
free(instance);
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Implementation of the IEnumFORMATETC COM interface
|
||||
*
|
||||
* Copyright 2014 Zhang Zhaolong <zhangzl2013@126.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __WF_CLIPRDR_ENUMFORMATETC_H__
|
||||
#define __WF_CLIPRDR_ENUMFORMATETC_H__
|
||||
|
||||
#define CINTERFACE
|
||||
#define COBJMACROS
|
||||
|
||||
#include <windows.h>
|
||||
#include <Ole2.h>
|
||||
|
||||
typedef struct _CliprdrEnumFORMATETC {
|
||||
IEnumFORMATETC iEnumFORMATETC;
|
||||
|
||||
// private
|
||||
LONG m_lRefCount;
|
||||
LONG m_nIndex;
|
||||
LONG m_nNumFormats;
|
||||
FORMATETC *m_pFormatEtc;
|
||||
} CliprdrEnumFORMATETC;
|
||||
|
||||
CliprdrEnumFORMATETC *CliprdrEnumFORMATETC_New(int nFormats, FORMATETC *pFormatEtc);
|
||||
void CliprdrEnumFORMATETC_Delete(CliprdrEnumFORMATETC *This);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_QueryInterface(IEnumFORMATETC *This, REFIID riid, void **ppvObject);
|
||||
ULONG STDMETHODCALLTYPE CliprdrEnumFORMATETC_AddRef(IEnumFORMATETC *This);
|
||||
ULONG STDMETHODCALLTYPE CliprdrEnumFORMATETC_Release(IEnumFORMATETC *This);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Next(IEnumFORMATETC *This, ULONG celt, FORMATETC *rgelt, ULONG *pceltFetched);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Skip(IEnumFORMATETC *This, ULONG celt);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Reset(IEnumFORMATETC *This);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Clone(IEnumFORMATETC *This, IEnumFORMATETC **ppenum);
|
||||
|
||||
#endif // __WF_CLIPRDR_ENUMFORMATETC_H__
|
||||
@@ -1,283 +0,0 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Implementation of the IStream COM interface
|
||||
*
|
||||
* Copyright 2014 Zhang Zhaolong <zhangzl2013@126.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "wf_cliprdr.h"
|
||||
#include "wf_cliprdr_Stream.h"
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_QueryInterface(IStream* This, REFIID riid, void** ppvObject)
|
||||
{
|
||||
CliprdrStream* instance = (CliprdrStream*) This;
|
||||
|
||||
if (IsEqualIID(riid, &IID_IStream) || IsEqualIID(riid, &IID_IUnknown))
|
||||
{
|
||||
IStream_AddRef(This);
|
||||
*ppvObject = This;
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ppvObject = 0;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE CliprdrStream_AddRef(IStream* This)
|
||||
{
|
||||
CliprdrStream* instance = (CliprdrStream*) This;
|
||||
|
||||
return InterlockedIncrement(&instance->m_lRefCount);
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE CliprdrStream_Release(IStream* This)
|
||||
{
|
||||
LONG count;
|
||||
CliprdrStream* instance = (CliprdrStream*) This;
|
||||
|
||||
count = InterlockedDecrement(&instance->m_lRefCount);
|
||||
|
||||
if(count == 0)
|
||||
{
|
||||
CliprdrStream_Delete(instance);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
#define FILECONTENTS_SIZE 0x00000001
|
||||
#define FILECONTENTS_RANGE 0x00000002
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_Read(IStream* This, void *pv, ULONG cb, ULONG *pcbRead)
|
||||
{
|
||||
CliprdrStream* instance = (CliprdrStream*) This;
|
||||
cliprdrContext *cliprdr = (cliprdrContext *)instance->m_pData;
|
||||
int ret;
|
||||
|
||||
if (pv == NULL || pcbRead == NULL)
|
||||
return E_INVALIDARG;
|
||||
|
||||
*pcbRead = 0;
|
||||
if (instance->m_lOffset.QuadPart >= instance->m_lSize.QuadPart)
|
||||
return S_FALSE;
|
||||
|
||||
ret = cliprdr_send_request_filecontents(cliprdr, (void *)This,
|
||||
instance->m_lIndex, FILECONTENTS_RANGE,
|
||||
instance->m_lOffset.HighPart, instance->m_lOffset.LowPart,
|
||||
cb);
|
||||
if (ret < 0)
|
||||
return S_FALSE;
|
||||
|
||||
if (cliprdr->req_fdata)
|
||||
{
|
||||
memcpy(pv, cliprdr->req_fdata, cliprdr->req_fsize);
|
||||
free(cliprdr->req_fdata);
|
||||
}
|
||||
|
||||
*pcbRead = cliprdr->req_fsize;
|
||||
instance->m_lOffset.QuadPart += cliprdr->req_fsize;
|
||||
|
||||
if (cliprdr->req_fsize < cb)
|
||||
return S_FALSE;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_Write(IStream* This, const void *pv, ULONG cb, ULONG *pcbWritten)
|
||||
{
|
||||
CliprdrStream* instance = (CliprdrStream*) This;
|
||||
|
||||
return STG_E_ACCESSDENIED;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_Seek(IStream* This, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
|
||||
{
|
||||
CliprdrStream* instance = (CliprdrStream*) This;
|
||||
ULONGLONG newoffset;
|
||||
|
||||
newoffset = instance->m_lOffset.QuadPart;
|
||||
|
||||
switch (dwOrigin)
|
||||
{
|
||||
case STREAM_SEEK_SET:
|
||||
newoffset = dlibMove.QuadPart;
|
||||
break;
|
||||
case STREAM_SEEK_CUR:
|
||||
newoffset += dlibMove.QuadPart;
|
||||
break;
|
||||
case STREAM_SEEK_END:
|
||||
newoffset = instance->m_lSize.QuadPart + dlibMove.QuadPart;
|
||||
break;
|
||||
default:
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
if (newoffset < 0 || newoffset >= instance->m_lSize.QuadPart)
|
||||
return FALSE;
|
||||
|
||||
instance->m_lOffset.QuadPart = newoffset;
|
||||
if (plibNewPosition)
|
||||
plibNewPosition->QuadPart = instance->m_lOffset.QuadPart;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_SetSize(IStream* This, ULARGE_INTEGER libNewSize)
|
||||
{
|
||||
CliprdrStream* instance = (CliprdrStream*) This;
|
||||
|
||||
return STG_E_INSUFFICIENTMEMORY;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_CopyTo(IStream* This, IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER *pcbWritten)
|
||||
{
|
||||
CliprdrStream* instance = (CliprdrStream*) This;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_Commit(IStream* This, DWORD grfCommitFlags)
|
||||
{
|
||||
CliprdrStream* instance = (CliprdrStream*) This;
|
||||
|
||||
return STG_E_MEDIUMFULL;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_Revert(IStream* This)
|
||||
{
|
||||
CliprdrStream* instance = (CliprdrStream*) This;
|
||||
|
||||
return STG_E_INSUFFICIENTMEMORY;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_LockRegion(IStream* This, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
|
||||
{
|
||||
CliprdrStream* instance = (CliprdrStream*) This;
|
||||
|
||||
return STG_E_INSUFFICIENTMEMORY;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_UnlockRegion(IStream* This, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
|
||||
{
|
||||
CliprdrStream* instance = (CliprdrStream*) This;
|
||||
|
||||
return STG_E_INSUFFICIENTMEMORY;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_Stat(IStream* This, STATSTG* pstatstg, DWORD grfStatFlag)
|
||||
{
|
||||
CliprdrStream* instance = (CliprdrStream*) This;
|
||||
|
||||
if (pstatstg == NULL)
|
||||
return STG_E_INVALIDPOINTER;
|
||||
|
||||
ZeroMemory(pstatstg, sizeof(STATSTG));
|
||||
|
||||
switch (grfStatFlag)
|
||||
{
|
||||
case STATFLAG_DEFAULT:
|
||||
return STG_E_INSUFFICIENTMEMORY;
|
||||
|
||||
case STATFLAG_NONAME:
|
||||
pstatstg->cbSize.QuadPart = instance->m_lSize.QuadPart;
|
||||
pstatstg->grfLocksSupported = LOCK_EXCLUSIVE;
|
||||
pstatstg->grfMode = GENERIC_READ;
|
||||
pstatstg->grfStateBits = 0;
|
||||
pstatstg->type = STGTY_STREAM;
|
||||
break;
|
||||
|
||||
case STATFLAG_NOOPEN:
|
||||
return STG_E_INVALIDFLAG;
|
||||
|
||||
default:
|
||||
return STG_E_INVALIDFLAG;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_Clone(IStream* This, IStream** ppstm)
|
||||
{
|
||||
CliprdrStream* instance = (CliprdrStream*) This;
|
||||
|
||||
return STG_E_INSUFFICIENTMEMORY;
|
||||
}
|
||||
|
||||
CliprdrStream *CliprdrStream_New(LONG index, void* pData)
|
||||
{
|
||||
cliprdrContext* cliprdr = (cliprdrContext*) pData;
|
||||
CliprdrStream* instance;
|
||||
IStream* iStream;
|
||||
|
||||
instance = (CliprdrStream*) calloc(1, sizeof(CliprdrStream));
|
||||
|
||||
if (instance)
|
||||
{
|
||||
iStream = &instance->iStream;
|
||||
|
||||
iStream->lpVtbl = (IStreamVtbl*) calloc(1, sizeof(IStreamVtbl));
|
||||
|
||||
if (iStream->lpVtbl)
|
||||
{
|
||||
iStream->lpVtbl->QueryInterface = CliprdrStream_QueryInterface;
|
||||
iStream->lpVtbl->AddRef = CliprdrStream_AddRef;
|
||||
iStream->lpVtbl->Release = CliprdrStream_Release;
|
||||
iStream->lpVtbl->Read = CliprdrStream_Read;
|
||||
iStream->lpVtbl->Write = CliprdrStream_Write;
|
||||
iStream->lpVtbl->Seek = CliprdrStream_Seek;
|
||||
iStream->lpVtbl->SetSize = CliprdrStream_SetSize;
|
||||
iStream->lpVtbl->CopyTo = CliprdrStream_CopyTo;
|
||||
iStream->lpVtbl->Commit = CliprdrStream_Commit;
|
||||
iStream->lpVtbl->Revert = CliprdrStream_Revert;
|
||||
iStream->lpVtbl->LockRegion = CliprdrStream_LockRegion;
|
||||
iStream->lpVtbl->UnlockRegion = CliprdrStream_UnlockRegion;
|
||||
iStream->lpVtbl->Stat = CliprdrStream_Stat;
|
||||
iStream->lpVtbl->Clone = CliprdrStream_Clone;
|
||||
|
||||
instance->m_lRefCount = 1;
|
||||
instance->m_lIndex = index;
|
||||
instance->m_pData = pData;
|
||||
instance->m_lOffset.QuadPart = 0;
|
||||
|
||||
/* get content size of this stream */
|
||||
cliprdr_send_request_filecontents(cliprdr, (void*) instance, instance->m_lIndex, FILECONTENTS_SIZE, 0, 0, 8);
|
||||
instance->m_lSize.QuadPart = *(LONGLONG*)cliprdr->req_fdata;
|
||||
free(cliprdr->req_fdata);
|
||||
}
|
||||
else
|
||||
{
|
||||
free(instance);
|
||||
instance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void CliprdrStream_Delete(CliprdrStream* instance)
|
||||
{
|
||||
if (instance)
|
||||
{
|
||||
if (instance->iStream.lpVtbl)
|
||||
free(instance->iStream.lpVtbl);
|
||||
|
||||
free(instance);
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Implementation of the IStream COM interface
|
||||
*
|
||||
* Copyright 2014 Zhang Zhaolong <zhangzl2013@126.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __WF_CLIPRDR_STREAM_H__
|
||||
#define __WF_CLIPRDR_STREAM_H__
|
||||
|
||||
#define CINTERFACE
|
||||
#define COBJMACROS
|
||||
|
||||
#include <windows.h>
|
||||
#include <Ole2.h>
|
||||
|
||||
typedef struct _CliprdrStream {
|
||||
IStream iStream;
|
||||
|
||||
// private
|
||||
LONG m_lRefCount;
|
||||
LONG m_lIndex;
|
||||
ULARGE_INTEGER m_lSize;
|
||||
ULARGE_INTEGER m_lOffset;
|
||||
void *m_pData;
|
||||
} CliprdrStream;
|
||||
|
||||
CliprdrStream *CliprdrStream_New(LONG index, void *pData);
|
||||
void CliprdrStream_Delete(CliprdrStream *instance);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_QueryInterface(IStream *This, REFIID riid, void **ppvObject);
|
||||
ULONG STDMETHODCALLTYPE CliprdrStream_AddRef(IStream *This);
|
||||
ULONG STDMETHODCALLTYPE CliprdrStream_Release(IStream * This);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_Read(IStream *This, void *pv, ULONG cb, ULONG *pcbRead);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_Write(IStream *This, const void *pv, ULONG cb, ULONG *pcbWritten);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_Seek(IStream *This, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_SetSize(IStream *This, ULARGE_INTEGER libNewSize);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_CopyTo(IStream *This, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_Commit(IStream *This, DWORD grfCommitFlags);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_Revert(IStream *This);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_LockRegion(IStream *This, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_UnlockRegion(IStream *This, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_Stat(IStream *This, STATSTG *pstatstg, DWORD grfStatFlag);
|
||||
HRESULT STDMETHODCALLTYPE CliprdrStream_Clone(IStream *This, IStream **ppstm);
|
||||
|
||||
#endif // __WF_CLIPRDR_STREAM_H__
|
||||
@@ -28,6 +28,8 @@
|
||||
LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||
LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
void wf_event_focus_in(wfContext* wfc);
|
||||
|
||||
#define KBD_TAG CLIENT_TAG("windows")
|
||||
#ifdef WITH_DEBUG_KBD
|
||||
#define DEBUG_KBD(fmt, ...) WLog_DBG(KBD_TAG, fmt, ## __VA_ARGS__)
|
||||
|
||||
Reference in New Issue
Block a user