diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2016-01-20 19:04:33 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2016-01-20 19:04:33 +0000 |
commit | 57b80b65d310667d22faa05906eaf4458f977483 (patch) | |
tree | 92d4848e1f9d6fb510b40b968c4b715a08f2053c /plugins/IEView/src/IEView.cpp | |
parent | 844708bdfa6686a644b65f26b8b9e5269a3fd479 (diff) |
IEView: support getting db settings via javascript (via external.db_get)
git-svn-id: http://svn.miranda-ng.org/main/trunk@16128 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/IEView/src/IEView.cpp')
-rw-r--r-- | plugins/IEView/src/IEView.cpp | 99 |
1 files changed, 90 insertions, 9 deletions
diff --git a/plugins/IEView/src/IEView.cpp b/plugins/IEView/src/IEView.cpp index 09c7afd088..4caa80c9f4 100644 --- a/plugins/IEView/src/IEView.cpp +++ b/plugins/IEView/src/IEView.cpp @@ -388,6 +388,8 @@ STDMETHODIMP IEView::QueryInterface(REFIID riid, PVOID *ppv) *ppv = (IInternetSecurityManager*)this;
if (IID_IServiceProvider == riid)
*ppv = (IServiceProvider*)this;
+ if (IID_IDispatch == riid)
+ *ppv = (IDispatch*)this;
if (NULL != *ppv) {
((LPUNKNOWN)*ppv)->AddRef();
@@ -409,16 +411,89 @@ STDMETHODIMP_(ULONG) IEView::Release(void) }
// IDispatch
-STDMETHODIMP IEView::GetTypeInfoCount(UINT *) { return E_NOTIMPL; }
-STDMETHODIMP IEView::GetTypeInfo(UINT, LCID, LPTYPEINFO*) { return S_OK; }
-STDMETHODIMP IEView::GetIDsOfNames(REFIID, LPOLESTR*, UINT, LCID, DISPID*) { return S_OK; }
+STDMETHODIMP IEView::GetTypeInfoCount(UINT *pctinfo)
+{
+ if (pctinfo == NULL) return E_INVALIDARG;
+ *pctinfo = 1;
+ return S_OK;
+}
+STDMETHODIMP IEView::GetTypeInfo(UINT, LCID, LPTYPEINFO*)
+{
+ return S_OK;
+}
+STDMETHODIMP IEView::GetIDsOfNames(REFIID riid, OLECHAR **rgszNames, size_t cNames, LCID lcid, DISPID *rgDispId)
+{
+ HRESULT retval = S_OK;
+ for (size_t i = 0; i < cNames; i++)
+ {
+ if (!wcscmp(L"db_get", rgszNames[i]))
+ rgDispId[i] = DISPID_JS_DB_GET;
+ else
+ {
+ rgDispId[i] = NULL;
+ retval = DISP_E_UNKNOWNNAME;
+ }
+ }
+ return S_OK;
+}
-STDMETHODIMP IEView::Invoke(DISPID dispIdMember, REFIID, LCID, WORD, DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*)
+HRESULT IE_db_get(DISPPARAMS *pDispParams, VARIANT *pVarResult)
{
- switch (dispIdMember) {
- case DISPID_AMBIENT_DLCONTROL:
- break;
+ if (pDispParams->cArgs == 3 && pDispParams && pVarResult)
+ {
+ MCONTACT hContact = pDispParams->rgvarg[2].vt == VT_INT ? pDispParams->rgvarg[2].intVal : NULL;
+ BSTR szModule = pDispParams->rgvarg[1].vt == VT_BSTR ? pDispParams->rgvarg[1].bstrVal : NULL;
+ BSTR szSetting = pDispParams->rgvarg[0].vt == VT_BSTR ? pDispParams->rgvarg[0].bstrVal : NULL;
+
+ DBVARIANT dbv = { 0 };
+
+ db_get(hContact, _T2A((TCHAR*)szModule), _T2A((TCHAR*)szSetting), &dbv);
+
+ switch (dbv.type)
+ {
+ case DBVT_BYTE:
+ pVarResult->bVal = dbv.bVal;
+ pVarResult->vt = VT_BOOL;
+ break;
+ case DBVT_WCHAR:
+ pVarResult->vt = VT_BSTR;
+ pVarResult->bstrVal = ::SysAllocString(dbv.pwszVal);
+ break;
+ case DBVT_UTF8:
+ pVarResult->vt = VT_BSTR;
+ pVarResult->bstrVal = ::SysAllocString(ptrW(mir_utf8decodeW(dbv.pszVal)));
+ break;
+ case DBVT_ASCIIZ:
+ pVarResult->vt = VT_BSTR;
+ pVarResult->bstrVal = ::SysAllocString(_A2T(dbv.pszVal));
+ break;
+ case DBVT_DWORD:
+ pVarResult->vt = VT_INT;
+ pVarResult->intVal = dbv.dVal;
+ }
+
+
+ return S_OK;
}
+ return E_INVALIDARG;
+}
+
+STDMETHODIMP IEView::Invoke(DISPID dispIdMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ DISPPARAMS *pDispParams,
+ VARIANT *pVarResult,
+ EXCEPINFO *pExcepInfo,
+ UINT *puArgErr)
+{
+
+ switch (dispIdMember)
+ {
+ case DISPID_JS_DB_GET:
+ return IE_db_get(pDispParams, pVarResult);
+ }
+
return DISP_E_MEMBERNOTFOUND;
}
@@ -619,8 +694,8 @@ STDMETHODIMP IEView::GetDropTarget(IDropTarget *, IDropTarget **ppDropTarget) STDMETHODIMP IEView::GetExternal(IDispatch **ppDispatch)
{
- *ppDispatch = NULL;
- return S_FALSE;
+ *ppDispatch = this;
+ return S_OK;
}
STDMETHODIMP IEView::TranslateUrl(DWORD, OLECHAR *, OLECHAR **) { return E_NOTIMPL; }
STDMETHODIMP IEView::FilterDataObject(IDataObject *, IDataObject **) { return E_NOTIMPL; }
@@ -711,6 +786,12 @@ STDMETHODIMP IEView::GetZoneMappings(DWORD, IEnumString **, DWORD) return INET_E_DEFAULT_ACTION;
}
+STDMETHODIMP IEView::SayHello()
+{
+ MessageBox(NULL, L"Hello", L"Hello", MB_YESNO);
+ return S_OK;
+}
+
IHTMLDocument2* IEView::getDocument()
{
CComPtr<IDispatch> dispatch;
|