diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2016-01-27 12:27:35 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2016-01-27 12:27:35 +0000 |
commit | c52fc4ca7f0f43f90b93a1dc814ab5310223126a (patch) | |
tree | e7fafba84f697304c4f92746ebef7af65e5b33c9 | |
parent | 1da2c875e9be6506bf9214b4b65c4b7d9d9b2c36 (diff) |
IEView: CallContactService function
git-svn-id: http://svn.miranda-ng.org/main/trunk@16175 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/IEView/src/IEView.cpp | 4 | ||||
-rw-r--r-- | plugins/IEView/src/external_funcs.cpp | 82 | ||||
-rw-r--r-- | plugins/IEView/src/external_funcs.h | 2 |
3 files changed, 64 insertions, 24 deletions
diff --git a/plugins/IEView/src/IEView.cpp b/plugins/IEView/src/IEView.cpp index 82bd22e9b8..87a7350275 100644 --- a/plugins/IEView/src/IEView.cpp +++ b/plugins/IEView/src/IEView.cpp @@ -441,6 +441,8 @@ STDMETHODIMP IEView::GetIDsOfNames(REFIID /*riid*/, LPOLESTR *rgszNames, UINT cN else if (!wcscmp(L"mir_CallService", rgszNames[i]))
rgDispId[i] = DISPID_EXTERNAL_CALLSERVICE;
+ else if (!wcscmp(L"mir_CallContactService", rgszNames[i]))
+ rgDispId[i] = DISPID_EXTERNAL_CALLCONTACTSERVICE;
else
{
@@ -465,6 +467,8 @@ STDMETHODIMP IEView::Invoke(DISPID dispIdMember, {
case DISPID_EXTERNAL_CALLSERVICE:
return External::mir_CallService(pDispParams, pVarResult);
+ case DISPID_EXTERNAL_CALLCONTACTSERVICE:
+ return External::mir_CallContactService(pDispParams, pVarResult);
case DISPID_EXTERNAL_DB_GET:
return External::db_get(pDispParams, pVarResult);
diff --git a/plugins/IEView/src/external_funcs.cpp b/plugins/IEView/src/external_funcs.cpp index 95eac7631b..829ebefe36 100644 --- a/plugins/IEView/src/external_funcs.cpp +++ b/plugins/IEView/src/external_funcs.cpp @@ -1,5 +1,30 @@ #include "stdafx.h"
+template<typename T>
+T Var_To(VARIANTARG &pVar, char strType = 'W')
+{
+ T retVal = NULL;
+ switch (pVar.vt)
+ {
+ case VT_BSTR:
+ if (strType == 'U')
+ retVal = (T)mir_utf8encodeW(pVar.bstrVal);
+ else if (strType == 'A')
+ retVal = (T)mir_u2a(pVar.bstrVal);
+ else
+ retVal = (T)pVar.bstrVal;
+ break;
+ case VT_INT:
+ case VT_I1:
+ case VT_I2:
+ case VT_I4:
+ case VT_I8:
+ retVal = (T)pVar.intVal;
+ break;
+ }
+ return retVal;
+}
+
namespace External
{
HRESULT mir_CallService(DISPPARAMS *pDispParams, VARIANT *pVarResult)
@@ -7,35 +32,45 @@ namespace External if (pDispParams == nullptr || pDispParams->cArgs < 3)
return E_INVALIDARG;
+ wchar_t wType = 'W', lType = 'W';
+ if (pDispParams->cArgs >= 5) lType = pDispParams->rgvarg[4].bstrVal[0];
+ if (pDispParams->cArgs >= 4) wType = pDispParams->rgvarg[3].bstrVal[0];
+
BSTR szName = pDispParams->rgvarg[2].bstrVal;
- WPARAM wParam = 0;
- LPARAM lParam = 0;
+ WPARAM wParam = Var_To<WPARAM>(pDispParams->rgvarg[1], wType);
+ LPARAM lParam = Var_To<LPARAM>(pDispParams->rgvarg[0], lType);
- switch (pDispParams->rgvarg[1].vt)
- {
- case VT_BSTR:
- wParam = (WPARAM)pDispParams->rgvarg[1].bstrVal;
- case VT_INT:
- case VT_I1:
- case VT_I2:
- case VT_I4:
- case VT_I8:
- wParam = (WPARAM)pDispParams->rgvarg[1].intVal;
- }
+ INT_PTR res = CallService(_T2A((TCHAR*)szName), wParam, lParam);
+
+ if (wType == 'A' || wType == 'U') mir_free((void*)wParam);
+ if (lType == 'A' || lType == 'U') mir_free((void*)lParam);
- switch (pDispParams->rgvarg[0].vt)
+ if (pVarResult != nullptr)
{
- case VT_BSTR:
- lParam = (LPARAM)pDispParams->rgvarg[0].bstrVal;
- case VT_INT:
- case VT_I1:
- case VT_I2:
- case VT_I4:
- case VT_I8:
- lParam = (LPARAM)pDispParams->rgvarg[0].intVal;
+ pVarResult->vt = VT_UINT;
+ pVarResult->uintVal = (UINT)res;
}
+ return S_OK;
+ }
- INT_PTR res = CallService(_T2A((TCHAR*)szName), wParam, lParam);
+ HRESULT mir_CallContactService(DISPPARAMS *pDispParams, VARIANT *pVarResult)
+ {
+ if (pDispParams == nullptr || pDispParams->cArgs < 4)
+ return E_INVALIDARG;
+
+ wchar_t wType = 'W', lType = 'W';
+ if (pDispParams->cArgs >= 6) lType = pDispParams->rgvarg[5].bstrVal[0];
+ if (pDispParams->cArgs >= 5) wType = pDispParams->rgvarg[4].bstrVal[0];
+
+ MCONTACT hContact = pDispParams->rgvarg[3].intVal;
+ BSTR szName = pDispParams->rgvarg[2].bstrVal;
+ WPARAM wParam = Var_To<WPARAM>(pDispParams->rgvarg[1], wType);
+ LPARAM lParam = Var_To<LPARAM>(pDispParams->rgvarg[0], lType);
+
+ INT_PTR res = CallContactService(hContact, _T2A((TCHAR*)szName), wParam, lParam);
+
+ if (wType == 'A' || wType == 'U') mir_free((void*)wParam);
+ if (lType == 'A' || lType == 'U') mir_free((void*)lParam);
if (pVarResult != nullptr)
{
@@ -191,5 +226,4 @@ namespace External }
return S_OK;
}
-
}
\ No newline at end of file diff --git a/plugins/IEView/src/external_funcs.h b/plugins/IEView/src/external_funcs.h index ede3ec1333..aa9a6ac306 100644 --- a/plugins/IEView/src/external_funcs.h +++ b/plugins/IEView/src/external_funcs.h @@ -1,6 +1,7 @@ enum EXTERNAL_FUNCTIONS
{
DISPID_EXTERNAL_CALLSERVICE = 600,
+ DISPID_EXTERNAL_CALLCONTACTSERVICE,
DISPID_EXTERNAL_GET_CURRENTCONTACT = 630,
@@ -14,6 +15,7 @@ enum EXTERNAL_FUNCTIONS namespace External
{
HRESULT mir_CallService(DISPPARAMS *pDispParams, VARIANT *pVarResult);
+ HRESULT mir_CallContactService(DISPPARAMS *pDispParams, VARIANT *pVarResult);
HRESULT IEView_GetCurrentContact(IEView *self, DISPPARAMS *pDispParams, VARIANT *pVarResult);
|