2006-12-09 11:50:08 +00:00
|
|
|
/*
|
2006-12-11 14:58:25 +00:00
|
|
|
* $Id: awk_cp.h,v 1.5 2006-12-11 14:58:25 bacon Exp $
|
2006-12-09 11:50:08 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _AWK_CP_H_
|
|
|
|
#define _AWK_CP_H_
|
|
|
|
|
|
|
|
template <class T>
|
2006-12-11 08:44:52 +00:00
|
|
|
class CProxyIAwkEvents:
|
|
|
|
public IConnectionPointImpl<T, &DIID_IAwkEvents, CComDynamicUnkArray>
|
2006-12-09 11:50:08 +00:00
|
|
|
{
|
|
|
|
public:
|
2006-12-09 17:36:27 +00:00
|
|
|
INT Fire_OpenSource(INT mode)
|
2006-12-09 11:50:08 +00:00
|
|
|
{
|
|
|
|
T* pT = static_cast<T*>(this);
|
2006-12-09 12:09:42 +00:00
|
|
|
int i, nconns = m_vec.GetSize();
|
|
|
|
CComVariant args[1], ret;
|
2006-12-09 11:50:08 +00:00
|
|
|
|
2006-12-09 12:09:42 +00:00
|
|
|
for (i = 0; i < nconns; i++)
|
2006-12-09 11:50:08 +00:00
|
|
|
{
|
|
|
|
pT->Lock();
|
2006-12-09 12:09:42 +00:00
|
|
|
CComPtr<IUnknown> sp = m_vec.GetAt(i);
|
2006-12-09 11:50:08 +00:00
|
|
|
pT->Unlock();
|
2006-12-09 12:09:42 +00:00
|
|
|
|
|
|
|
IDispatch* pDispatch =
|
|
|
|
reinterpret_cast<IDispatch*>(sp.p);
|
|
|
|
if (pDispatch == NULL) continue;
|
|
|
|
|
|
|
|
VariantClear (&ret);
|
|
|
|
VariantClear (&args[0]);
|
|
|
|
|
|
|
|
args[0] = mode;
|
|
|
|
|
|
|
|
DISPPARAMS disp = { args, NULL, 1, 0 };
|
|
|
|
HRESULT hr = pDispatch->Invoke (
|
|
|
|
0x1, IID_NULL, LOCALE_USER_DEFAULT,
|
|
|
|
DISPATCH_METHOD, &disp, &ret, NULL, NULL);
|
|
|
|
if (FAILED(hr)) continue;
|
|
|
|
|
|
|
|
if (ret.vt == VT_EMPTY)
|
2006-12-09 11:50:08 +00:00
|
|
|
{
|
2006-12-09 12:09:42 +00:00
|
|
|
/* probably, the handler has not been implemeted*/
|
|
|
|
continue;
|
2006-12-09 11:50:08 +00:00
|
|
|
}
|
2006-12-09 12:09:42 +00:00
|
|
|
|
|
|
|
hr = ret.ChangeType (VT_I4);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
/* TODO: set the error code properly... */
|
|
|
|
/* invalid value returned... */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret.lVal;
|
2006-12-09 11:50:08 +00:00
|
|
|
}
|
2006-12-09 12:09:42 +00:00
|
|
|
|
|
|
|
return -1;
|
2006-12-09 11:50:08 +00:00
|
|
|
}
|
2006-12-09 12:09:42 +00:00
|
|
|
|
2006-12-09 17:36:27 +00:00
|
|
|
INT Fire_CloseSource(INT mode)
|
2006-12-09 11:50:08 +00:00
|
|
|
{
|
|
|
|
T* pT = static_cast<T*>(this);
|
2006-12-09 12:09:42 +00:00
|
|
|
int i, nconns = m_vec.GetSize();
|
|
|
|
CComVariant args[1], ret;
|
2006-12-09 11:50:08 +00:00
|
|
|
|
2006-12-09 12:09:42 +00:00
|
|
|
for (i = 0; i < nconns; i++)
|
2006-12-09 11:50:08 +00:00
|
|
|
{
|
|
|
|
pT->Lock();
|
2006-12-09 12:09:42 +00:00
|
|
|
CComPtr<IUnknown> sp = m_vec.GetAt(i);
|
2006-12-09 11:50:08 +00:00
|
|
|
pT->Unlock();
|
2006-12-09 12:09:42 +00:00
|
|
|
|
|
|
|
IDispatch* pDispatch =
|
|
|
|
reinterpret_cast<IDispatch*>(sp.p);
|
|
|
|
if (pDispatch == NULL) continue;
|
|
|
|
|
|
|
|
VariantClear (&ret);
|
|
|
|
VariantClear (&args[0]);
|
|
|
|
|
|
|
|
args[0] = mode;
|
|
|
|
|
|
|
|
DISPPARAMS disp = { args, NULL, 1, 0 };
|
|
|
|
HRESULT hr = pDispatch->Invoke (
|
|
|
|
0x2, IID_NULL, LOCALE_USER_DEFAULT,
|
|
|
|
DISPATCH_METHOD, &disp, &ret, NULL, NULL);
|
|
|
|
if (FAILED(hr)) continue;
|
|
|
|
|
|
|
|
if (ret.vt == VT_EMPTY)
|
2006-12-09 11:50:08 +00:00
|
|
|
{
|
2006-12-09 12:09:42 +00:00
|
|
|
/* probably, the handler has not been implemeted*/
|
|
|
|
continue;
|
2006-12-09 11:50:08 +00:00
|
|
|
}
|
2006-12-09 12:09:42 +00:00
|
|
|
|
|
|
|
hr = ret.ChangeType (VT_I4);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
/* TODO: set the error code properly... */
|
|
|
|
/* invalid value returned... */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret.lVal;
|
2006-12-09 11:50:08 +00:00
|
|
|
}
|
2006-12-09 12:09:42 +00:00
|
|
|
|
|
|
|
return -1;
|
2006-12-09 11:50:08 +00:00
|
|
|
}
|
2006-12-09 12:09:42 +00:00
|
|
|
|
2006-12-09 17:36:27 +00:00
|
|
|
INT Fire_ReadSource (IBuffer* buf)
|
2006-12-09 11:50:08 +00:00
|
|
|
{
|
|
|
|
T* pT = static_cast<T*>(this);
|
|
|
|
int i, nconns = m_vec.GetSize();
|
|
|
|
CComVariant args[1], ret;
|
|
|
|
|
|
|
|
for (i = 0; i < nconns; i++)
|
|
|
|
{
|
|
|
|
pT->Lock();
|
|
|
|
CComPtr<IUnknown> sp = m_vec.GetAt(i);
|
|
|
|
pT->Unlock();
|
|
|
|
|
|
|
|
IDispatch* pDispatch =
|
|
|
|
reinterpret_cast<IDispatch*>(sp.p);
|
|
|
|
if (pDispatch == NULL) continue;
|
|
|
|
|
|
|
|
VariantClear (&ret);
|
|
|
|
VariantClear (&args[0]);
|
|
|
|
|
|
|
|
args[0] = (IUnknown*)buf;
|
|
|
|
|
|
|
|
DISPPARAMS disp = { args, NULL, 1, 0 };
|
|
|
|
HRESULT hr = pDispatch->Invoke (
|
|
|
|
0x3, IID_NULL, LOCALE_USER_DEFAULT,
|
|
|
|
DISPATCH_METHOD, &disp, &ret, NULL, NULL);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret.vt == VT_EMPTY)
|
|
|
|
{
|
|
|
|
/* probably, the handler has not been implemeted*/
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = ret.ChangeType (VT_I4);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
/* TODO: set the error code properly... */
|
|
|
|
/* invalid value returned... */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret.lVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no event handler attached for the source code read. */
|
|
|
|
/* TODO: set error code ... */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-12-09 17:36:27 +00:00
|
|
|
INT Fire_WriteSource (IBuffer* buf)
|
2006-12-09 11:50:08 +00:00
|
|
|
{
|
|
|
|
T* pT = static_cast<T*>(this);
|
|
|
|
int i, nconns = m_vec.GetSize();
|
|
|
|
CComVariant args[1], ret;
|
|
|
|
|
|
|
|
for (i = 0; i < nconns; i++)
|
|
|
|
{
|
|
|
|
pT->Lock();
|
|
|
|
CComPtr<IUnknown> sp = m_vec.GetAt(i);
|
|
|
|
pT->Unlock();
|
|
|
|
|
|
|
|
IDispatch* pDispatch =
|
|
|
|
reinterpret_cast<IDispatch*>(sp.p);
|
|
|
|
if (pDispatch == NULL) continue;
|
|
|
|
|
|
|
|
VariantClear (&ret);
|
|
|
|
VariantClear (&args[0]);
|
|
|
|
|
|
|
|
args[0] = (IUnknown*)buf;
|
|
|
|
|
|
|
|
DISPPARAMS disp = { args, NULL, 1, 0 };
|
|
|
|
HRESULT hr = pDispatch->Invoke (
|
|
|
|
0x4, IID_NULL, LOCALE_USER_DEFAULT,
|
|
|
|
DISPATCH_METHOD, &disp, &ret, NULL, NULL);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret.vt == VT_EMPTY)
|
|
|
|
{
|
|
|
|
/* probably, the handler has not been implemeted*/
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = ret.ChangeType (VT_I4);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
/* TODO: set the error code properly... */
|
|
|
|
/* invalid value returned... */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret.lVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no event handler attached for the source code write.
|
|
|
|
* make the operation succeed by returning the reqested
|
|
|
|
* data length. */
|
|
|
|
CComBSTR bstr;
|
|
|
|
buf->get_Value (&bstr);
|
|
|
|
return bstr.Length();
|
|
|
|
}
|
2006-12-09 17:36:27 +00:00
|
|
|
|
|
|
|
INT Fire_OpenExtio (IAwkExtio* extio)
|
|
|
|
{
|
|
|
|
T* pT = static_cast<T*>(this);
|
|
|
|
int i, nconns = m_vec.GetSize();
|
|
|
|
CComVariant args[1], ret;
|
|
|
|
|
|
|
|
for (i = 0; i < nconns; i++)
|
|
|
|
{
|
|
|
|
pT->Lock();
|
|
|
|
CComPtr<IUnknown> sp = m_vec.GetAt(i);
|
|
|
|
pT->Unlock();
|
|
|
|
|
|
|
|
IDispatch* pDispatch =
|
|
|
|
reinterpret_cast<IDispatch*>(sp.p);
|
|
|
|
if (pDispatch == NULL) continue;
|
|
|
|
|
|
|
|
VariantClear (&ret);
|
|
|
|
VariantClear (&args[0]);
|
|
|
|
|
|
|
|
args[0] = (IUnknown*)extio;
|
|
|
|
|
|
|
|
DISPPARAMS disp = { args, NULL, 1, 0 };
|
|
|
|
HRESULT hr = pDispatch->Invoke (
|
|
|
|
0x5, IID_NULL, LOCALE_USER_DEFAULT,
|
|
|
|
DISPATCH_METHOD, &disp, &ret, NULL, NULL);
|
|
|
|
if (FAILED(hr)) continue;
|
|
|
|
|
|
|
|
if (ret.vt == VT_EMPTY)
|
|
|
|
{
|
|
|
|
/* probably, the handler has not been implemeted*/
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = ret.ChangeType (VT_I4);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
/* TODO: set the error code properly... */
|
|
|
|
/* invalid value returned... */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret.lVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
INT Fire_CloseExtio (IAwkExtio* extio)
|
|
|
|
{
|
|
|
|
T* pT = static_cast<T*>(this);
|
|
|
|
int i, nconns = m_vec.GetSize();
|
|
|
|
CComVariant args[1], ret;
|
|
|
|
|
|
|
|
for (i = 0; i < nconns; i++)
|
|
|
|
{
|
|
|
|
pT->Lock();
|
|
|
|
CComPtr<IUnknown> sp = m_vec.GetAt(i);
|
|
|
|
pT->Unlock();
|
|
|
|
|
|
|
|
IDispatch* pDispatch =
|
|
|
|
reinterpret_cast<IDispatch*>(sp.p);
|
|
|
|
if (pDispatch == NULL) continue;
|
|
|
|
|
|
|
|
VariantClear (&ret);
|
|
|
|
VariantClear (&args[0]);
|
|
|
|
|
|
|
|
args[0] = (IUnknown*)extio;
|
|
|
|
|
|
|
|
DISPPARAMS disp = { args, NULL, 1, 0 };
|
|
|
|
HRESULT hr = pDispatch->Invoke (
|
|
|
|
0x6, IID_NULL, LOCALE_USER_DEFAULT,
|
|
|
|
DISPATCH_METHOD, &disp, &ret, NULL, NULL);
|
|
|
|
if (FAILED(hr)) continue;
|
|
|
|
|
|
|
|
if (ret.vt == VT_EMPTY)
|
|
|
|
{
|
|
|
|
/* probably, the handler has not been implemeted*/
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = ret.ChangeType (VT_I4);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
/* TODO: set the error code properly... */
|
|
|
|
/* invalid value returned... */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret.lVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-12-11 08:44:52 +00:00
|
|
|
INT Fire_ReadExtio (IAwkExtio* extio, IBuffer* buf)
|
|
|
|
{
|
|
|
|
T* pT = static_cast<T*>(this);
|
|
|
|
int i, nconns = m_vec.GetSize();
|
|
|
|
CComVariant args[2], ret;
|
|
|
|
|
|
|
|
for (i = 0; i < nconns; i++)
|
|
|
|
{
|
|
|
|
pT->Lock();
|
|
|
|
CComPtr<IUnknown> sp = m_vec.GetAt(i);
|
|
|
|
pT->Unlock();
|
|
|
|
|
|
|
|
IDispatch* pDispatch =
|
|
|
|
reinterpret_cast<IDispatch*>(sp.p);
|
|
|
|
if (pDispatch == NULL) continue;
|
|
|
|
|
|
|
|
VariantClear (&ret);
|
|
|
|
VariantClear (&args[0]);
|
|
|
|
VariantClear (&args[1]);
|
|
|
|
|
|
|
|
args[1] = (IUnknown*)extio;
|
|
|
|
args[0] = (IUnknown*)buf;
|
|
|
|
|
|
|
|
DISPPARAMS disp = { args, NULL, 2, 0 };
|
|
|
|
HRESULT hr = pDispatch->Invoke (
|
|
|
|
0x7, IID_NULL, LOCALE_USER_DEFAULT,
|
|
|
|
DISPATCH_METHOD, &disp, &ret, NULL, NULL);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret.vt == VT_EMPTY)
|
|
|
|
{
|
|
|
|
/* probably, the handler has not been implemeted*/
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = ret.ChangeType (VT_I4);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
/* TODO: set the error code properly... */
|
|
|
|
/* invalid value returned... */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret.lVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-12-09 17:36:27 +00:00
|
|
|
INT Fire_WriteExtio (IAwkExtio* extio, IBuffer* buf)
|
|
|
|
{
|
|
|
|
T* pT = static_cast<T*>(this);
|
|
|
|
int i, nconns = m_vec.GetSize();
|
|
|
|
CComVariant args[2], ret;
|
|
|
|
|
|
|
|
for (i = 0; i < nconns; i++)
|
|
|
|
{
|
|
|
|
pT->Lock();
|
|
|
|
CComPtr<IUnknown> sp = m_vec.GetAt(i);
|
|
|
|
pT->Unlock();
|
|
|
|
|
|
|
|
IDispatch* pDispatch =
|
|
|
|
reinterpret_cast<IDispatch*>(sp.p);
|
|
|
|
if (pDispatch == NULL) continue;
|
|
|
|
|
|
|
|
VariantClear (&ret);
|
|
|
|
VariantClear (&args[0]);
|
|
|
|
VariantClear (&args[1]);
|
|
|
|
|
|
|
|
args[1] = (IUnknown*)extio;
|
|
|
|
args[0] = (IUnknown*)buf;
|
|
|
|
|
|
|
|
DISPPARAMS disp = { args, NULL, 2, 0 };
|
|
|
|
HRESULT hr = pDispatch->Invoke (
|
|
|
|
0x8, IID_NULL, LOCALE_USER_DEFAULT,
|
|
|
|
DISPATCH_METHOD, &disp, &ret, NULL, NULL);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret.vt == VT_EMPTY)
|
|
|
|
{
|
|
|
|
/* probably, the handler has not been implemeted*/
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = ret.ChangeType (VT_I4);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
/* TODO: set the error code properly... */
|
|
|
|
/* invalid value returned... */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret.lVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2006-12-11 14:58:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
INT Fire_FlushExtio (IAwkExtio* extio)
|
|
|
|
{
|
|
|
|
T* pT = static_cast<T*>(this);
|
|
|
|
int i, nconns = m_vec.GetSize();
|
|
|
|
CComVariant args[1], ret;
|
|
|
|
|
|
|
|
for (i = 0; i < nconns; i++)
|
|
|
|
{
|
|
|
|
pT->Lock();
|
|
|
|
CComPtr<IUnknown> sp = m_vec.GetAt(i);
|
|
|
|
pT->Unlock();
|
|
|
|
|
|
|
|
IDispatch* pDispatch =
|
|
|
|
reinterpret_cast<IDispatch*>(sp.p);
|
|
|
|
if (pDispatch == NULL) continue;
|
|
|
|
|
|
|
|
VariantClear (&ret);
|
|
|
|
VariantClear (&args[0]);
|
|
|
|
|
|
|
|
args[0] = (IUnknown*)extio;
|
|
|
|
|
|
|
|
DISPPARAMS disp = { args, NULL, 1, 0 };
|
|
|
|
HRESULT hr = pDispatch->Invoke (
|
|
|
|
0x9, IID_NULL, LOCALE_USER_DEFAULT,
|
|
|
|
DISPATCH_METHOD, &disp, &ret, NULL, NULL);
|
|
|
|
if (FAILED(hr)) continue;
|
|
|
|
|
|
|
|
if (ret.vt == VT_EMPTY)
|
|
|
|
{
|
|
|
|
/* probably, the handler has not been implemeted*/
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = ret.ChangeType (VT_I4);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
/* TODO: set the error code properly... */
|
|
|
|
/* invalid value returned... */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret.lVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
INT Fire_NextExtio (IAwkExtio* extio)
|
|
|
|
{
|
|
|
|
T* pT = static_cast<T*>(this);
|
|
|
|
int i, nconns = m_vec.GetSize();
|
|
|
|
CComVariant args[1], ret;
|
|
|
|
|
|
|
|
for (i = 0; i < nconns; i++)
|
|
|
|
{
|
|
|
|
pT->Lock();
|
|
|
|
CComPtr<IUnknown> sp = m_vec.GetAt(i);
|
|
|
|
pT->Unlock();
|
|
|
|
|
|
|
|
IDispatch* pDispatch =
|
|
|
|
reinterpret_cast<IDispatch*>(sp.p);
|
|
|
|
if (pDispatch == NULL) continue;
|
|
|
|
|
|
|
|
VariantClear (&ret);
|
|
|
|
VariantClear (&args[0]);
|
|
|
|
|
|
|
|
args[0] = (IUnknown*)extio;
|
|
|
|
|
|
|
|
DISPPARAMS disp = { args, NULL, 1, 0 };
|
|
|
|
HRESULT hr = pDispatch->Invoke (
|
|
|
|
0xA, IID_NULL, LOCALE_USER_DEFAULT,
|
|
|
|
DISPATCH_METHOD, &disp, &ret, NULL, NULL);
|
|
|
|
if (FAILED(hr)) continue;
|
|
|
|
|
|
|
|
if (ret.vt == VT_EMPTY)
|
|
|
|
{
|
|
|
|
/* probably, the handler has not been implemeted*/
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = ret.ChangeType (VT_I4);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
/* TODO: set the error code properly... */
|
|
|
|
/* invalid value returned... */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret.lVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-12-09 11:50:08 +00:00
|
|
|
};
|
2006-12-09 12:09:42 +00:00
|
|
|
|
2006-12-09 11:50:08 +00:00
|
|
|
#endif
|