diff options
Diffstat (limited to 'plugins/IEView/src/external_funcs.cpp')
-rw-r--r-- | plugins/IEView/src/external_funcs.cpp | 119 |
1 files changed, 58 insertions, 61 deletions
diff --git a/plugins/IEView/src/external_funcs.cpp b/plugins/IEView/src/external_funcs.cpp index a690d9f0c8..57e4c8f5cf 100644 --- a/plugins/IEView/src/external_funcs.cpp +++ b/plugins/IEView/src/external_funcs.cpp @@ -4,8 +4,7 @@ template<typename T> T Var_To(VARIANTARG &pVar, char strType = 'W')
{
T retVal = NULL;
- switch (pVar.vt)
- {
+ switch (pVar.vt) {
case VT_BSTR:
if (strType == 'U')
retVal = (T)mir_utf8encodeW(pVar.bstrVal);
@@ -14,6 +13,7 @@ T Var_To(VARIANTARG &pVar, char strType = 'W') else
retVal = (T)pVar.bstrVal;
break;
+
case VT_INT:
case VT_I1:
case VT_I2:
@@ -25,89 +25,89 @@ T Var_To(VARIANTARG &pVar, char strType = 'W') return retVal;
}
+static const wchar_t* STR(const VARIANTARG &pVar)
+{
+ return (pVar.vt == VT_BSTR) ? pVar.bstrVal : L"";
+}
+
namespace External
{
- HRESULT mir_CallService(DISPPARAMS *pDispParams, VARIANT *pVarResult)
+ HRESULT mir_CallService(DISPPARAMS *p, VARIANT *pVarResult)
{
- if (pDispParams == nullptr || pDispParams->cArgs < 3)
+ if (p == nullptr || p->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];
+ if (p->cArgs >= 5) lType = p->rgvarg[4].bstrVal[0];
+ if (p->cArgs >= 4) wType = p->rgvarg[3].bstrVal[0];
- BSTR szName = pDispParams->rgvarg[2].bstrVal;
- WPARAM wParam = Var_To<WPARAM>(pDispParams->rgvarg[1], wType);
- LPARAM lParam = Var_To<LPARAM>(pDispParams->rgvarg[0], lType);
+ BSTR szName = p->rgvarg[2].bstrVal;
+ WPARAM wParam = Var_To<WPARAM>(p->rgvarg[1], wType);
+ LPARAM lParam = Var_To<LPARAM>(p->rgvarg[0], lType);
- INT_PTR res = CallService(_T2A((wchar_t*)szName), wParam, lParam);
+ INT_PTR res = CallService(_T2A((wchar_t *)szName), wParam, lParam);
- if (wType == 'A' || wType == 'U') mir_free((void*)wParam);
- if (lType == 'A' || lType == 'U') mir_free((void*)lParam);
+ if (wType == 'A' || wType == 'U') mir_free((void *)wParam);
+ if (lType == 'A' || lType == 'U') mir_free((void *)lParam);
- if (pVarResult != nullptr)
- {
+ if (pVarResult != nullptr) {
pVarResult->vt = VT_UINT;
pVarResult->uintVal = (UINT)res;
}
return S_OK;
}
- HRESULT mir_CallContactService(DISPPARAMS *pDispParams, VARIANT *pVarResult)
+ HRESULT mir_CallContactService(DISPPARAMS *p, VARIANT *pVarResult)
{
- if (pDispParams == nullptr || pDispParams->cArgs < 4)
+ if (p == nullptr || p->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];
+ if (p->cArgs >= 6) lType = p->rgvarg[5].bstrVal[0];
+ if (p->cArgs >= 5) wType = p->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);
+ MCONTACT hContact = p->rgvarg[3].intVal;
+ BSTR szName = p->rgvarg[2].bstrVal;
+ WPARAM wParam = Var_To<WPARAM>(p->rgvarg[1], wType);
+ LPARAM lParam = Var_To<LPARAM>(p->rgvarg[0], lType);
- INT_PTR res = ProtoChainSend(hContact, _T2A((wchar_t*)szName), wParam, lParam);
+ INT_PTR res = ProtoChainSend(hContact, _T2A((wchar_t *)szName), wParam, lParam);
- if (wType == 'A' || wType == 'U') mir_free((void*)wParam);
- if (lType == 'A' || lType == 'U') mir_free((void*)lParam);
+ if (wType == 'A' || wType == 'U') mir_free((void *)wParam);
+ if (lType == 'A' || lType == 'U') mir_free((void *)lParam);
- if (pVarResult != nullptr)
- {
+ if (pVarResult != nullptr) {
pVarResult->vt = VT_UINT;
pVarResult->uintVal = (UINT)res;
}
return S_OK;
}
- HRESULT IEView_GetCurrentContact(IEView *self, DISPPARAMS*, VARIANT *pVarResult)
+ HRESULT IEView_GetCurrentContact(IEView *self, DISPPARAMS *, VARIANT *pVarResult)
{
- if (pVarResult != nullptr)
- {
+ if (pVarResult != nullptr) {
pVarResult->vt = VT_UINT;
pVarResult->uintVal = self->Get_CurrentContact();
}
return S_OK;
}
- HRESULT db_get(DISPPARAMS *pDispParams, VARIANT *pVarResult)
+ HRESULT db_get(DISPPARAMS *p, VARIANT *pVarResult)
{
- if (pDispParams->cArgs < 3)
+ if (p->cArgs < 3)
return E_INVALIDARG;
- MCONTACT hContact = pDispParams->rgvarg[2].intVal;
- BSTR szModule = pDispParams->rgvarg[1].bstrVal;
- BSTR szSetting = pDispParams->rgvarg[0].bstrVal;
+ MCONTACT hContact = p->rgvarg[2].intVal;
+ BSTR szModule = p->rgvarg[1].bstrVal;
+ BSTR szSetting = p->rgvarg[0].bstrVal;
DBVARIANT dbv = { 0 };
- if (db_get(hContact, _T2A((wchar_t*)szModule), _T2A((wchar_t*)szSetting), &dbv))
+ if (db_get(hContact, _T2A((wchar_t *)szModule), _T2A((wchar_t *)szSetting), &dbv))
return S_OK;
- if (pVarResult != nullptr)
- {
- switch (dbv.type)
- {
+ if (pVarResult != nullptr) {
+ switch (dbv.type) {
case DBVT_BYTE:
//pVarResult->bVal = dbv.bVal != 0;
//pVarResult->vt = VT_BOOL;
@@ -140,21 +140,20 @@ namespace External return S_OK;
}
- HRESULT db_set(DISPPARAMS *pDispParams, VARIANT *pVarResult)
+ HRESULT db_set(DISPPARAMS *p, VARIANT *pVarResult)
{
- if (pDispParams == nullptr || pDispParams->cArgs < 4)
+ if (p == nullptr || p->cArgs < 4)
return E_INVALIDARG;
- MCONTACT hContact = pDispParams->rgvarg[3].intVal;
- BSTR szModule = pDispParams->rgvarg[2].bstrVal;
- BSTR szSetting = pDispParams->rgvarg[1].bstrVal;
+ MCONTACT hContact = p->rgvarg[3].intVal;
+ BSTR szModule = p->rgvarg[2].bstrVal;
+ BSTR szSetting = p->rgvarg[1].bstrVal;
DBVARIANT dbv = { 0 };
- VARIANT& pVal = pDispParams->rgvarg[0];
+ VARIANT &pVal = p->rgvarg[0];
- switch (pVal.vt)
- {
+ switch (pVal.vt) {
case VT_BSTR:
dbv.type = DBVT_WCHAR;
dbv.pwszVal = mir_wstrdup(pVal.bstrVal);
@@ -171,29 +170,27 @@ namespace External dbv.type = DBVT_BYTE;
dbv.bVal = pVal.boolVal;
break;
- default:
+ default:
return E_INVALIDARG;
}
- INT_PTR res = ::db_set(hContact, _T2A((wchar_t*)szModule), _T2A((wchar_t*)szSetting), &dbv);
+ INT_PTR res = ::db_set(hContact, _T2A((wchar_t *)szModule), _T2A((wchar_t *)szSetting), &dbv);
- if (pVarResult != nullptr)
- {
+ if (pVarResult != nullptr) {
pVarResult->vt = VT_INT;
pVarResult->intVal = (int)res;
}
return S_OK;
}
- HRESULT win32_ShellExecute(DISPPARAMS *pDispParams, VARIANT *pVarResult)
+ HRESULT win32_ShellExecute(DISPPARAMS *p, VARIANT *pVarResult)
{
- if (pDispParams == nullptr || pDispParams->cArgs < 5)
+ if (p == nullptr || p->cArgs < 5)
return E_INVALIDARG;
- HINSTANCE res = ShellExecuteW(nullptr, pDispParams->rgvarg[4].bstrVal, pDispParams->rgvarg[3].bstrVal, pDispParams->rgvarg[2].bstrVal, pDispParams->rgvarg[1].bstrVal, pDispParams->rgvarg[0].intVal);
+ HINSTANCE res = ShellExecuteW(nullptr, STR(p->rgvarg[4]), STR(p->rgvarg[3]), STR(p->rgvarg[2]), STR(p->rgvarg[1]), p->rgvarg[0].intVal);
- if (pVarResult != nullptr)
- {
+ if (pVarResult != nullptr) {
pVarResult->vt = VT_HANDLE;
pVarResult->ullVal = (ULONGLONG)res;
}
@@ -201,12 +198,12 @@ namespace External return S_OK;
}
- HRESULT win32_CopyToClipboard(DISPPARAMS *pDispParams, VARIANT*)
+ HRESULT win32_CopyToClipboard(DISPPARAMS *p, VARIANT *)
{
- if (pDispParams == nullptr || pDispParams->cArgs < 1)
+ if (p == nullptr || p->cArgs < 1)
return E_INVALIDARG;
- Utils_ClipboardCopy(pDispParams->rgvarg[0].bstrVal);
+ Utils_ClipboardCopy(p->rgvarg[0].bstrVal);
return S_OK;
}
-}
\ No newline at end of file +}
|