summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/MSN/src/msn_auth.cpp8
-rw-r--r--protocols/MSN/src/msn_ieembed.cpp108
-rw-r--r--protocols/MSN/src/msn_ieembed.h14
3 files changed, 124 insertions, 6 deletions
diff --git a/protocols/MSN/src/msn_auth.cpp b/protocols/MSN/src/msn_auth.cpp
index 0a7cff86bf..e9dde450aa 100644
--- a/protocols/MSN/src/msn_auth.cpp
+++ b/protocols/MSN/src/msn_auth.cpp
@@ -730,6 +730,8 @@ void CMsnProto::SaveAuthTokensDB(void)
}
typedef struct {
+ /* Internal */
+ IEEmbed *pEmbed;
/* Input */
CMsnProto *pProto;
NETLIBHTTPREQUEST *nlhr;
@@ -737,8 +739,6 @@ typedef struct {
/* Output */
char *pszURL;
char *pszCookies;
- /* Internal */
- IEEmbed *pEmbed;
} IEAUTH_PARAM;
LRESULT CALLBACK AuthWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
@@ -755,9 +755,9 @@ LRESULT CALLBACK AuthWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar
case WM_CREATE:
{
IEAUTH_PARAM *pAuth = (IEAUTH_PARAM*)((LPCREATESTRUCT)lParam)->lpCreateParams;
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pAuth);
pAuth->pEmbed = new IEEmbed(hwnd);
WCHAR *pwszCookies = mir_a2u(pAuth->nlhr->headers[1].szValue);
- SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pAuth);
pAuth->pEmbed->addCookie(pwszCookies);
pAuth->pEmbed->navigate(AUTH_URL);
mir_free(pwszCookies);
@@ -966,7 +966,7 @@ int CMsnProto::MSN_AuthOAuth(void)
* window in order to let user login there. May also be used for 2-factor auth */
if (nlhrReply2->resultCode == 200 && nlhrReply2->pData) {
UINT uThreadId;
- IEAUTH_PARAM param = {this, &nlhr, nlhrReply2, NULL, NULL, NULL};
+ IEAUTH_PARAM param = {NULL, this, &nlhr, nlhrReply2, NULL, NULL};
bAskingForAuth = true;
WaitForSingleObject(ForkThreadEx(&CMsnProto::msn_IEAuthThread, &param, &uThreadId), INFINITE);
diff --git a/protocols/MSN/src/msn_ieembed.cpp b/protocols/MSN/src/msn_ieembed.cpp
index ef9ce64285..f231bbafed 100644
--- a/protocols/MSN/src/msn_ieembed.cpp
+++ b/protocols/MSN/src/msn_ieembed.cpp
@@ -114,6 +114,70 @@ void IEEmbedSink::SetSecureLockIcon(long) {}
void IEEmbedSink::FileDownload(VARIANT_BOOL*) {}
+static LRESULT CALLBACK IEEmbedServerWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ IEEmbed **view = (IEEmbed **)GetWindowLongPtr(GetParent(GetParent(GetParent(hwnd))), GWLP_USERDATA);
+ if (view && *view) {
+ switch (message) {
+ /*
+ case WM_KEYUP:
+ if (LOWORD(wParam) == VK_ESCAPE && !(GetKeyState(VK_SHIFT) & 0x8000) && !(GetKeyState(VK_CONTROL) & 0x8000) && !(GetKeyState(VK_MENU) & 0x8000))
+ SendMessage(GetParent(GetParent(GetParent(hwnd))), WM_COMMAND, IDCANCEL, 0);
+ break; */
+
+ case WM_KEYDOWN:
+ (*view)->translateAccelerator(message, wParam, lParam);
+ break;
+
+ /*
+ case WM_SETFOCUS:
+ RECT rcWindow;
+ POINT cursor;
+ GetWindowRect(hwnd, &rcWindow);
+ GetCursorPos(&cursor);
+ if (cursor.y <= rcWindow.bottom && cursor.y >= rcWindow.top && cursor.x <= rcWindow.right && cursor.x >= rcWindow.left)
+ view->mouseActivate();
+
+ if (view->setFocus((HWND)wParam))
+ return TRUE;
+ break;
+ */
+
+ }
+ return CallWindowProc((*view)->getServerWndProc(), hwnd, message, wParam, lParam);
+ }
+ return DefWindowProc(hwnd, message, wParam, lParam);
+}
+
+static LRESULT CALLBACK IEEmbedDocWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ IEEmbed **view = (IEEmbed **)GetWindowLongPtr(GetParent(GetParent(hwnd)), GWLP_USERDATA);
+ if (view && *view) {
+ WNDPROC oldWndProc = (*view)->getDocWndProc();
+ if (message == WM_PARENTNOTIFY && wParam == WM_CREATE) {
+ SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)oldWndProc);
+ (*view)->setServerWndProc((WNDPROC)SetWindowLongPtr((HWND)lParam, GWLP_WNDPROC, (LONG_PTR)IEEmbedServerWindowProcedure));
+ }
+ return CallWindowProc(oldWndProc, hwnd, message, wParam, lParam);
+ }
+ return DefWindowProc(hwnd, message, wParam, lParam);
+}
+
+static LRESULT CALLBACK IEEmbedWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ IEEmbed **view = (IEEmbed **)GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA);
+ if (view && *view) {
+ WNDPROC oldWndProc = (*view)->getMainWndProc();
+ if (message == WM_PARENTNOTIFY && wParam == WM_CREATE) {
+ SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)oldWndProc);
+ (*view)->setDocWndProc((WNDPROC)SetWindowLongPtr((HWND)lParam, GWLP_WNDPROC, (LONG_PTR)IEEmbedDocWindowProcedure));
+ }
+ return CallWindowProc(oldWndProc, hwnd, message, wParam, lParam);
+ }
+ return DefWindowProc(hwnd, message, wParam, lParam);
+}
+
+
IEEmbed::IEEmbed(HWND _parent)
{
MSG msg;
@@ -147,6 +211,8 @@ IEEmbed::IEEmbed(HWND _parent)
MessageBox(NULL, TranslateT("Failed to Advise"), TranslateT("C++ Event Sink"), MB_OK);
}
}
+ setMainWndProc((WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)IEEmbedWindowProcedure));
+ SetFocus(hwnd);
}
pWebBrowser->put_RegisterAsDropTarget(VARIANT_FALSE);
@@ -253,6 +319,36 @@ STDMETHODIMP IEEmbed::OnShowWindow(BOOL) { return E_NOTIMPL; }
STDMETHODIMP IEEmbed::RequestNewObjectLayout(void) { return E_NOTIMPL; }
+void IEEmbed::setMainWndProc(WNDPROC wndProc)
+{
+ mainWndProc = wndProc;
+}
+
+WNDPROC IEEmbed::getMainWndProc()
+{
+ return mainWndProc;
+}
+
+void IEEmbed::setDocWndProc(WNDPROC wndProc)
+{
+ docWndProc = wndProc;
+}
+
+WNDPROC IEEmbed::getDocWndProc()
+{
+ return docWndProc;
+}
+
+void IEEmbed::setServerWndProc(WNDPROC wndProc)
+{
+ serverWndProc = wndProc;
+}
+
+WNDPROC IEEmbed::getServerWndProc()
+{
+ return serverWndProc;
+}
+
void IEEmbed::write(const wchar_t *text)
{
CComPtr<IHTMLDocument2> document = getDocument();
@@ -363,3 +459,15 @@ char *IEEmbed::GetHTMLDoc() {
}
return pszRet;
}
+
+void IEEmbed::translateAccelerator(UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ CComPtr<IOleInPlaceActiveObject> pIOIPAO;
+ if (SUCCEEDED(pWebBrowser.QueryInterface(&pIOIPAO))) {
+ MSG msg;
+ msg.message = uMsg;
+ msg.wParam = wParam;
+ msg.lParam = lParam;
+ pIOIPAO->TranslateAccelerator(&msg);
+ }
+}
diff --git a/protocols/MSN/src/msn_ieembed.h b/protocols/MSN/src/msn_ieembed.h
index 76442b691d..2726fced13 100644
--- a/protocols/MSN/src/msn_ieembed.h
+++ b/protocols/MSN/src/msn_ieembed.h
@@ -77,9 +77,9 @@ public:
STDMETHODIMP_(void)FileDownload(VARIANT_BOOL*);
};
-class IEEmbed :public IDispatch, public IOleClientSite, public IOleInPlaceSite //, public IDocHostUIHandler
+class IEEmbed :public IDispatch, public IOleClientSite, public IOleInPlaceSite
{
-public:
+private:
HWND parent;
HWND hwnd;
int m_cRef;
@@ -88,7 +88,9 @@ public:
CComPtr<IConnectionPoint> m_pConnectionPoint;
CComPtr<IWebBrowser2> pWebBrowser;
IEEmbedSink *sink;
+ WNDPROC mainWndProc, docWndProc, serverWndProc;
+public:
// IUnknown
STDMETHODIMP QueryInterface(REFIID riid, PVOID *ppv);
STDMETHODIMP_(ULONG) AddRef(void);
@@ -128,6 +130,13 @@ public:
IEEmbed(HWND _parent);
virtual ~IEEmbed();
+ void setMainWndProc(WNDPROC);
+ WNDPROC getMainWndProc();
+ void setDocWndProc(WNDPROC);
+ WNDPROC getDocWndProc();
+ void setServerWndProc(WNDPROC);
+ WNDPROC getServerWndProc();
+
void ResizeBrowser();
void navigate(const wchar_t *);
void navigate(char *url);
@@ -136,5 +145,6 @@ public:
void addCookie(const wchar_t *cookieString);
BSTR getCookies();
char* GetHTMLDoc();
+ void translateAccelerator(UINT uMsg, WPARAM wParam, LPARAM lParam);
};
#endif