Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

CtrlWeb.cpp

Go to the documentation of this file.
00001 //
00002 // CtrlWeb.cpp
00003 //
00004 // Copyright (c) Shareaza Development Team, 2002-2005.
00005 // This file is part of SHAREAZA (www.shareaza.com)
00006 //
00007 // Shareaza is free software; you can redistribute it
00008 // and/or modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // Shareaza is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with Shareaza; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 //
00021 
00022 #include "StdAfx.h"
00023 #include "Shareaza.h"
00024 #include "CtrlWeb.h"
00025 
00026 #include "CoolMenu.h"
00027 #include "Skin.h"
00028 
00029 #include <exdispid.h>
00030 
00031 IMPLEMENT_DYNAMIC(CWebCtrl, CWnd)
00032 
00033 BEGIN_INTERFACE_MAP(CWebCtrl::DocSite, COleControlSite)
00034         INTERFACE_PART(CWebCtrl::DocSite, IID_IDocHostUIHandler, DocHostUIHandler)
00035         INTERFACE_PART(CWebCtrl::DocSite, IID_IDocHostShowUI, DocHostShowUI)
00036         INTERFACE_PART(CWebCtrl::DocSite, IID_IServiceProvider, ServiceProvider)
00037         INTERFACE_PART(CWebCtrl::DocSite, IID_IInternetSecurityManager, InternetSecurityManager)
00038 END_INTERFACE_MAP()
00039 
00040 BEGIN_EVENTSINK_MAP(CWebCtrl, CWnd)
00041         ON_EVENT(CWebCtrl, AFX_IDW_PANE_FIRST, DISPID_BEFORENAVIGATE2, BeforeNavigate2, VTS_DISPATCH VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PBOOL)
00042         ON_EVENT(CWebCtrl, AFX_IDW_PANE_FIRST, DISPID_NEWWINDOW2, OnNewWindow2, VTS_PDISPATCH VTS_PBOOL)
00043 END_EVENTSINK_MAP()
00044 
00045 BEGIN_MESSAGE_MAP(CWebCtrl, CWnd)
00046         ON_WM_CREATE()
00047         ON_WM_DESTROY()
00048         ON_WM_SIZE()
00049         ON_WM_PAINT()
00050 END_MESSAGE_MAP()
00051 
00052 
00054 // CWebCtrl construction
00055 
00056 CWebCtrl::CWebCtrl()
00057 {
00058         m_bSandbox      = FALSE;
00059         m_tFrame        = 0;
00060         m_pMenu         = NULL;
00061 }
00062 
00063 CWebCtrl::~CWebCtrl()
00064 {
00065         if ( m_pMenu != NULL )
00066         {
00067                 EnterMenu( NULL );
00068                 delete m_pMenu;
00069         }
00070 }
00071 
00073 // CWebCtrl operations
00074 
00075 BOOL CWebCtrl::Create(DWORD dwStyle, CWnd* pParentWnd, UINT nID)
00076 {
00077         CRect rect( 0, 0, 0, 0 );
00078         return CWnd::Create( NULL, NULL, WS_CHILD|WS_CLIPCHILDREN|dwStyle,
00079                 rect, pParentWnd, nID, NULL );
00080 }
00081 
00082 void CWebCtrl::EnableCoolMenu(BOOL bEnable)
00083 {
00084         if ( m_pMenu != NULL )
00085         {
00086                 if ( bEnable ) return;
00087                 EnterMenu( NULL );
00088                 delete m_pMenu;
00089                 m_pMenu = NULL;
00090         }
00091         else
00092         {
00093                 if ( ! bEnable ) return;
00094                 m_pMenu = new CCoolMenu();
00095                 m_pMenu->SetWatermark( Skin.GetWatermark( _T("CCoolMenu") ) );
00096         }
00097 }
00098 
00099 void CWebCtrl::EnableSandbox(BOOL bSandbox)
00100 {
00101         m_bSandbox = bSandbox;
00102         if ( m_pBrowser ) m_pBrowser->put_Offline( m_bSandbox ? VARIANT_TRUE : VARIANT_FALSE );
00103 }
00104 
00105 void CWebCtrl::SetExternal(IDispatch* pDispatch)
00106 {
00107         m_pExternal = pDispatch;
00108 }
00109 
00110 HRESULT CWebCtrl::Navigate(LPCTSTR lpszURL, DWORD dwFlags, LPCTSTR lpszTargetFrameName, LPCTSTR lpszHeaders, LPVOID lpvPostData, DWORD dwPostDataLen)
00111 {
00112         if ( m_pBrowser == NULL ) return E_UNEXPECTED;
00113 
00114         CString strURL( lpszURL );
00115         CComBSTR bstrURL;
00116         bstrURL.Attach( strURL.AllocSysString() );
00117 
00118         COleSafeArray vPostData;
00119         if ( lpvPostData != NULL )
00120         {
00121                 if ( dwPostDataLen == 0 ) dwPostDataLen = lstrlen( (LPCTSTR)lpvPostData );
00122                 vPostData.CreateOneDim( VT_UI1, dwPostDataLen, lpvPostData );
00123         }
00124 
00125         return m_pBrowser->Navigate( bstrURL, COleVariant( (long) dwFlags, VT_I4 ),
00126         COleVariant( lpszTargetFrameName, VT_BSTR ), vPostData,
00127                 COleVariant( lpszHeaders, VT_BSTR ) );
00128 }
00129 
00131 // CWebCtrl message handlers
00132 
00133 int CWebCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
00134 {
00135         if ( CWnd::OnCreate( lpCreateStruct ) == -1 ) return -1;
00136 
00137         AfxEnableControlContainer();
00138 
00139         CRect rect;
00140         GetClientRect( rect );
00141 
00142         if ( m_wndBrowser.CreateControl( CLSID_WebBrowser, NULL,
00143                  WS_VISIBLE|WS_CHILD, rect, this, AFX_IDW_PANE_FIRST ) )
00144         {
00145                 IUnknown* pUnknown = m_wndBrowser.GetControlUnknown();
00146 
00147                 if ( pUnknown != NULL &&
00148                          SUCCEEDED( pUnknown->QueryInterface( IID_IWebBrowser2, (void**)&m_pBrowser ) ) &&
00149                          m_pBrowser )
00150                 {
00151                         if ( m_bSandbox ) m_pBrowser->put_Offline( VARIANT_TRUE );
00152                 }
00153                 else
00154                 {
00155                         m_pBrowser = NULL;
00156                         m_wndBrowser.DestroyWindow();
00157                 }
00158         }
00159 
00160         return 0;
00161 }
00162 
00163 void CWebCtrl::OnDestroy()
00164 {
00165         EnterMenu( NULL );
00166 
00167         m_pBrowser = NULL;
00168         if ( m_wndBrowser.m_hWnd != NULL ) m_wndBrowser.DestroyWindow();
00169 
00170         CWnd::OnDestroy();
00171 }
00172 
00173 BOOL CWebCtrl::PreTranslateMessage(MSG* pMsg)
00174 {
00175         if ( m_pBrowser )
00176         {
00177                 CComQIPtr<IOleInPlaceActiveObject> pInPlace = m_pBrowser;
00178                 if ( pInPlace )
00179                         return pInPlace->TranslateAccelerator( pMsg ) == S_OK;
00180         }
00181 
00182         return CWnd::PreTranslateMessage( pMsg );
00183 }
00184 
00185 void CWebCtrl::OnSize(UINT nType, int cx, int cy)
00186 {
00187         CWnd::OnSize( nType, cx, cy );
00188 
00189         if ( ::IsWindow( m_wndBrowser.m_hWnd ) )
00190         {
00191                 CRect rect;
00192                 GetClientRect( rect );
00193                 ::AdjustWindowRectEx( rect, ::GetWindowLong( m_wndBrowser, GWL_STYLE ), FALSE, WS_EX_CLIENTEDGE );
00194                 m_wndBrowser.SetWindowPos( NULL, rect.left, rect.top,
00195                         rect.Width(), rect.Height(), SWP_NOACTIVATE|SWP_NOZORDER );
00196         }
00197 }
00198 
00199 void CWebCtrl::OnPaint()
00200 {
00201         CPaintDC dc( this );
00202 
00203         if ( ! ::IsWindow( m_wndBrowser.m_hWnd ) )
00204         {
00205                 CString str = _T("Internet Explorer is required for this feature.");
00206                 CRect rc;
00207                 GetClientRect( &rc );
00208                 dc.FillSolidRect( &rc, GetSysColor( COLOR_WINDOW ) );
00209                 dc.SetTextColor( GetSysColor( COLOR_WINDOWTEXT ) );
00210                 dc.DrawText( str, &rc, DT_CENTER|DT_VCENTER|DT_SINGLELINE );
00211         }
00212 }
00213 
00215 // CWebCtrl cool menu driver
00216 
00217 CWebCtrl* CWebCtrl::m_pThis = NULL;
00218 
00219 void CWebCtrl::EnterMenu(POINT* pPoint)
00220 {
00221         if ( m_pThis != NULL )
00222         {
00223                 SetWindowLong( m_pThis->m_hWndThis, GWL_WNDPROC, (LONG)m_pThis->m_pWndProc );
00224                 m_pThis = NULL;
00225         }
00226 
00227         if ( pPoint == NULL || m_pMenu == NULL ) return;
00228 
00229         CPoint ptScreen( *pPoint );
00230         ptScreen.Offset( 2, 2 );
00231 
00232     CWnd* pChild = this;
00233         for ( ; ; )
00234         {
00235                 CPoint ptClient( ptScreen );
00236                 pChild->ScreenToClient( &ptClient );
00237                 CWnd* pNext = pChild->ChildWindowFromPoint( ptClient, CWP_ALL );
00238                 if ( pNext == NULL || pNext == pChild ) break;
00239                 pChild = pNext;
00240         }
00241 
00242         TCHAR szClass[128];
00243     GetClassName( *pChild, szClass, 128 );
00244         if ( _tcsistr( szClass, _T("Internet Explorer") ) == NULL ) return;
00245 
00246         m_pThis = this;
00247         m_hWndThis = pChild->GetSafeHwnd();
00248         m_pWndProc = (WNDPROC)GetWindowLong( m_hWndThis, GWL_WNDPROC );
00249         SetWindowLong( m_hWndThis, GWL_WNDPROC, (LONG)WebWndProc );
00250 }
00251 
00252 LRESULT PASCAL CWebCtrl::WebWndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
00253 {
00254         WNDPROC pWndProc = m_pThis->m_pWndProc;
00255 
00256         ASSERT( m_pThis->m_hWndThis == hWnd );
00257 
00258     switch ( nMsg )
00259         {
00260         case WM_DESTROY:
00261         case WM_EXITMENULOOP:
00262                 SetWindowLong( hWnd, GWL_WNDPROC, (LONG)pWndProc );
00263                 m_pThis = NULL;
00264                 break;
00265         case WM_INITMENUPOPUP:
00266                 m_pThis->m_pMenu->AddMenu( CMenu::FromHandle( (HMENU)wParam ), TRUE );
00267                 break;
00268         case WM_MEASUREITEM:
00269                 m_pThis->m_pMenu->OnMeasureItem( (LPMEASUREITEMSTRUCT)lParam );
00270                 return 0;
00271         case WM_DRAWITEM:
00272                 m_pThis->m_pMenu->OnDrawItem( (LPDRAWITEMSTRUCT)lParam );
00273                 return 0;
00274         }
00275 
00276         return CallWindowProc( pWndProc, hWnd, nMsg, wParam, lParam );
00277 }
00278 
00280 // CWebCtrl browser event handlers
00281 
00282 void CWebCtrl::BeforeNavigate2(LPDISPATCH pDispatch, VARIANT* pvURL, VARIANT* pvFlags, VARIANT* pvTargetFrameName, VARIANT* pvPostData, VARIANT* pvHeaders, VARIANT_BOOL* pvCancel)
00283 {
00284         ASSERT(V_VT(pvURL) == VT_BSTR);
00285         ASSERT(V_VT(pvTargetFrameName) == VT_BSTR);
00286         ASSERT(pvCancel != NULL);
00287         *pvCancel = VARIANT_FALSE;
00288 
00289         if ( SysStringLen( V_BSTR(pvTargetFrameName) ) == 0 )
00290         {
00291                 CString strURL( V_BSTR(pvURL) );
00292 
00293                 if ( _tcsncmp( strURL, _T("http"), 4 ) == 0 )
00294                 {
00295                         *pvCancel = VARIANT_TRUE;
00296                         m_tFrame = GetTickCount();
00297                         COleVariant vFrame(      _T("_blank"), VT_BSTR );
00298                         m_pBrowser->Navigate2( pvURL, pvFlags, &vFrame, pvPostData, pvHeaders );
00299                 }
00300         }
00301 }
00302 
00303 void CWebCtrl::OnNewWindow2(LPDISPATCH* ppDisp, VARIANT_BOOL* pbCancel)
00304 {
00305         *pbCancel = VARIANT_FALSE;
00306 
00307         if ( m_bSandbox )
00308         {
00309                 if ( GetTickCount() - m_tFrame > 1500 ) *pbCancel = VARIANT_TRUE;
00310         }
00311 }
00312 
00314 // CWebCtrl::DocSite control site implementation
00315 
00316 BOOL CWebCtrl::CreateControlSite(COleControlContainer* pContainer, COleControlSite** ppSite, UINT nID, REFCLSID clsid)
00317 {
00318         ASSERT( ppSite != NULL );
00319         *ppSite = new DocSite( this, pContainer );
00320         return TRUE;
00321 }
00322 
00323 CWebCtrl::DocSite::DocSite(CWebCtrl* pCtrl, COleControlContainer* pContainer) : COleControlSite( pContainer )
00324 {
00325         m_pCtrl = pCtrl;
00326 }
00327 
00329 // CWebCtrl::DocSite IDocHostUIHandler
00330 
00331 IMPLEMENT_UNKNOWN(CWebCtrl::DocSite, DocHostUIHandler);
00332 
00333 STDMETHODIMP CWebCtrl::DocSite::XDocHostUIHandler::GetExternal(LPDISPATCH *lppDispatch)
00334 {
00335         METHOD_PROLOGUE_EX_(CWebCtrl::DocSite, DocHostUIHandler)
00336         CWebCtrl* pCtrl = pThis->GetCtrl();
00337 
00338         *lppDispatch = pCtrl->m_pExternal;
00339         if ( *lppDispatch != NULL ) (*lppDispatch)->AddRef();
00340 
00341         return ( *lppDispatch != NULL ) ? S_OK : S_FALSE;
00342 }
00343 
00344 STDMETHODIMP CWebCtrl::DocSite::XDocHostUIHandler::ShowContextMenu(DWORD dwID, LPPOINT ppt, LPUNKNOWN pcmdtReserved, LPDISPATCH pdispReserved)
00345 {
00346         METHOD_PROLOGUE_EX_(CWebCtrl::DocSite, DocHostUIHandler)
00347         CWebCtrl* pCtrl = pThis->GetCtrl();
00348         WVNCONTEXTMENU pNotify;
00349 
00350         pNotify.hdr.hwndFrom    = pCtrl->GetSafeHwnd();
00351         pNotify.hdr.idFrom              = pCtrl->GetDlgCtrlID();
00352         pNotify.hdr.code                = WVN_CONTEXTMENU;
00353         pNotify.dwMenuID                = dwID;
00354         pNotify.ptMouse                 = *ppt;
00355         pNotify.pCmdTarget              = pcmdtReserved;
00356         pNotify.pContext                = pdispReserved;
00357 
00358         LRESULT lResult = pCtrl->GetOwner()->SendMessage(
00359                 WM_NOTIFY, (WPARAM)pNotify.hdr.idFrom, (LPARAM)&pNotify );
00360 
00361         if ( lResult == 1 ) return S_OK;
00362         pCtrl->EnterMenu( ppt );
00363 
00364         return S_FALSE;
00365 }
00366 
00367 STDMETHODIMP CWebCtrl::DocSite::XDocHostUIHandler::GetHostInfo(DOCHOSTUIINFO *pInfo)
00368 {
00369         METHOD_PROLOGUE_EX_(CWebCtrl::DocSite, DocHostUIHandler)
00370         CWebCtrl* pCtrl = pThis->GetCtrl();
00371         return S_OK;
00372 }
00373 
00374 STDMETHODIMP CWebCtrl::DocSite::XDocHostUIHandler::ShowUI(DWORD dwID, LPOLEINPLACEACTIVEOBJECT pActiveObject, LPOLECOMMANDTARGET pCommandTarget, LPOLEINPLACEFRAME pFrame, LPOLEINPLACEUIWINDOW pDoc)
00375 {
00376         METHOD_PROLOGUE_EX_(CWebCtrl::DocSite, DocHostUIHandler)
00377         CWebCtrl* pCtrl = pThis->GetCtrl();
00378         return S_FALSE;
00379 }
00380 
00381 STDMETHODIMP CWebCtrl::DocSite::XDocHostUIHandler::HideUI()
00382 {
00383         METHOD_PROLOGUE_EX_(CWebCtrl::DocSite, DocHostUIHandler)
00384         CWebCtrl* pCtrl = pThis->GetCtrl();
00385         return S_OK;
00386 }
00387 
00388 STDMETHODIMP CWebCtrl::DocSite::XDocHostUIHandler::UpdateUI(void)
00389 {
00390         METHOD_PROLOGUE_EX_(CWebCtrl::DocSite, DocHostUIHandler)
00391         CWebCtrl* pCtrl = pThis->GetCtrl();
00392         return S_OK;
00393 }
00394 
00395 STDMETHODIMP CWebCtrl::DocSite::XDocHostUIHandler::EnableModeless(BOOL fEnable)
00396 {
00397         METHOD_PROLOGUE_EX_(CWebCtrl::DocSite, DocHostUIHandler)
00398         CWebCtrl* pCtrl = pThis->GetCtrl();
00399         return S_OK;
00400 }
00401 
00402 STDMETHODIMP CWebCtrl::DocSite::XDocHostUIHandler::OnDocWindowActivate(BOOL fActivate)
00403 {
00404         METHOD_PROLOGUE_EX_(CWebCtrl::DocSite, DocHostUIHandler)
00405         CWebCtrl* pCtrl = pThis->GetCtrl();
00406         return S_OK;
00407 }
00408 
00409 STDMETHODIMP CWebCtrl::DocSite::XDocHostUIHandler::OnFrameWindowActivate(BOOL fActivate)
00410 {
00411         METHOD_PROLOGUE_EX_(CWebCtrl::DocSite, DocHostUIHandler)
00412         CWebCtrl* pCtrl = pThis->GetCtrl();
00413         return S_OK;
00414 }
00415 
00416 STDMETHODIMP CWebCtrl::DocSite::XDocHostUIHandler::ResizeBorder(LPCRECT prcBorder, LPOLEINPLACEUIWINDOW pUIWindow, BOOL fFrameWindow)
00417 {
00418         METHOD_PROLOGUE_EX_(CWebCtrl::DocSite, DocHostUIHandler)
00419         CWebCtrl* pCtrl = pThis->GetCtrl();
00420         return S_OK;
00421 }
00422 
00423 STDMETHODIMP CWebCtrl::DocSite::XDocHostUIHandler::TranslateAccelerator(LPMSG lpMsg, const GUID* pguidCmdGroup, DWORD nCmdID)
00424 {
00425         METHOD_PROLOGUE_EX_(CWebCtrl::DocSite, DocHostUIHandler)
00426         CWebCtrl* pCtrl = pThis->GetCtrl();
00427         return S_FALSE;
00428 }
00429 
00430 STDMETHODIMP CWebCtrl::DocSite::XDocHostUIHandler::GetOptionKeyPath(LPOLESTR* pchKey, DWORD dwReserved)
00431 {
00432         METHOD_PROLOGUE_EX_(CWebCtrl::DocSite, DocHostUIHandler)
00433         CWebCtrl* pCtrl = pThis->GetCtrl();
00434         return S_FALSE;
00435 }
00436 
00437 STDMETHODIMP CWebCtrl::DocSite::XDocHostUIHandler::GetDropTarget(LPDROPTARGET pDropTarget, LPDROPTARGET* ppDropTarget)
00438 {
00439         METHOD_PROLOGUE_EX_(CWebCtrl::DocSite, DocHostUIHandler)
00440         CWebCtrl* pCtrl = pThis->GetCtrl();
00441         return S_FALSE;
00442 }
00443 
00444 STDMETHODIMP CWebCtrl::DocSite::XDocHostUIHandler::TranslateUrl(DWORD dwTranslate, OLECHAR* pchURLIn, OLECHAR** ppchURLOut)
00445 {
00446         METHOD_PROLOGUE_EX_(CWebCtrl::DocSite, DocHostUIHandler)
00447         CWebCtrl* pCtrl = pThis->GetCtrl();
00448         return S_FALSE;
00449 }
00450 
00451 STDMETHODIMP CWebCtrl::DocSite::XDocHostUIHandler::FilterDataObject(LPDATAOBJECT pDataObject, LPDATAOBJECT* ppDataObject)
00452 {
00453         METHOD_PROLOGUE_EX_(CWebCtrl::DocSite, DocHostUIHandler)
00454         CWebCtrl* pCtrl = pThis->GetCtrl();
00455         return S_FALSE;
00456 }
00457 
00459 // CWebCtrl::DocSite IDocHostShowUI
00460 
00461 IMPLEMENT_UNKNOWN(CWebCtrl::DocSite, DocHostShowUI);
00462 
00463 STDMETHODIMP CWebCtrl::DocSite::XDocHostShowUI::ShowHelp(HWND hwnd, LPOLESTR pszHelpFile, UINT uCommand, DWORD dwData, POINT ptMouse, IDispatch *pDispatchObjectHit)
00464 {
00465         METHOD_PROLOGUE_EX_(CWebCtrl::DocSite, DocHostShowUI)
00466         CWebCtrl* pCtrl = pThis->GetCtrl();
00467         return S_FALSE;
00468 }
00469 
00470 STDMETHODIMP CWebCtrl::DocSite::XDocHostShowUI::ShowMessage(HWND hwnd, LPOLESTR lpstrText, LPOLESTR lpstrCaption, DWORD dwType, LPOLESTR lpstrHelpFile, DWORD dwHelpContext, LRESULT *plResult)
00471 {
00472         METHOD_PROLOGUE_EX_(CWebCtrl::DocSite, DocHostShowUI)
00473         CWebCtrl* pCtrl = pThis->GetCtrl();
00474         return pCtrl->m_bSandbox ? S_OK : S_FALSE;
00475 }
00476 
00478 // CWebCtrl::DocSite IServiceProvider
00479 
00480 IMPLEMENT_UNKNOWN(CWebCtrl::DocSite, ServiceProvider);
00481 
00482 STDMETHODIMP CWebCtrl::DocSite::XServiceProvider::QueryService(REFGUID guidService, REFIID riid, void **ppv)
00483 {
00484         METHOD_PROLOGUE(CWebCtrl::DocSite, ServiceProvider)
00485         CWebCtrl* pCtrl = pThis->GetCtrl();
00486 
00487         if ( guidService == SID_SInternetSecurityManager && pCtrl->m_bSandbox )
00488         {
00489                 if ( riid == IID_IInternetSecurityManager )
00490                 {
00491                         return pThis->ExternalQueryInterface( &riid, ppv );
00492                 }
00493                 else
00494                 {
00495                         return E_NOINTERFACE;
00496                 }
00497         }
00498         else
00499         {
00500                 // return SVC_E_UNKNOWNSERVICE;
00501                 return E_UNEXPECTED;
00502         }
00503 }
00504 
00506 // CWebCtrl::DocSite IInternetSecurityManager
00507 
00508 IMPLEMENT_UNKNOWN(CWebCtrl::DocSite, InternetSecurityManager);
00509 
00510 STDMETHODIMP CWebCtrl::DocSite::XInternetSecurityManager::GetSecurityId(LPCWSTR pwszUrl, BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
00511 {
00512         return INET_E_DEFAULT_ACTION;
00513 }
00514 
00515 STDMETHODIMP CWebCtrl::DocSite::XInternetSecurityManager::GetSecuritySite(IInternetSecurityMgrSite **ppSite)
00516 {
00517         return INET_E_DEFAULT_ACTION;
00518 }
00519 
00520 STDMETHODIMP CWebCtrl::DocSite::XInternetSecurityManager::GetZoneMappings(DWORD dwZone, IEnumString **ppenumString, DWORD dwFlags)
00521 {
00522         return INET_E_DEFAULT_ACTION;
00523 }
00524 
00525 STDMETHODIMP CWebCtrl::DocSite::XInternetSecurityManager::MapUrlToZone(LPCWSTR pwszUrl, DWORD *pdwZone, DWORD dwFlags)
00526 {
00527         return INET_E_DEFAULT_ACTION;
00528 }
00529 
00530 STDMETHODIMP CWebCtrl::DocSite::XInternetSecurityManager::ProcessUrlAction(LPCWSTR pwszUrl, DWORD dwAction, BYTE *pPolicy, DWORD cbPolicy, BYTE *pContext, DWORD cbContext, DWORD dwFlags, DWORD dwReserved)
00531 {
00532         if ( cbPolicy != 4 ) return INET_E_DEFAULT_ACTION;
00533         PBOOL pBool = (PBOOL)pPolicy;
00534 
00535         if ( wcsncmp( pwszUrl, L"p2p-col://", 10 ) == 0 )
00536         {
00537                 if (    ( dwAction >= URLACTION_ACTIVEX_MIN && dwAction <= URLACTION_ACTIVEX_MAX )
00538                         ||      ( dwAction >= URLACTION_SHELL_MIN && dwAction <= URLACTION_SHELL_MAX )
00539                         ||      ( dwAction >= URLACTION_INFODELIVERY_MIN && dwAction <= URLACTION_INFODELIVERY_MAX )
00540                         ||      ( dwAction >= URLACTION_HTML_MIN && dwAction <= URLACTION_HTML_MAX )
00541                         ||      ( dwAction >= URLACTION_DOWNLOAD_MIN && dwAction <= URLACTION_DOWNLOAD_MAX ) )
00542                 {
00543                         *pBool = URLPOLICY_DISALLOW;
00544                         return S_OK;
00545                 }
00546                 else if ( dwAction >= URLACTION_SCRIPT_MIN && dwAction <= URLACTION_SCRIPT_MAX )
00547                 {
00548                         *pBool = ( dwAction == URLACTION_SCRIPT_RUN ) ? URLPOLICY_ALLOW : URLPOLICY_DISALLOW;
00549                         return S_OK;
00550                 }
00551         }
00552         else
00553         {
00554                 *pBool = URLPOLICY_DISALLOW;
00555                 return S_OK;
00556         }
00557 
00558         return INET_E_DEFAULT_ACTION;
00559 }
00560 
00561 STDMETHODIMP CWebCtrl::DocSite::XInternetSecurityManager::QueryCustomPolicy(LPCWSTR pwszUrl, REFGUID guidKey, BYTE **ppPolicy, DWORD *pcbPolicy, BYTE *pContext, DWORD cbContext, DWORD dwReserved)
00562 {
00563         return INET_E_DEFAULT_ACTION;
00564 }
00565 
00566 STDMETHODIMP CWebCtrl::DocSite::XInternetSecurityManager::SetSecuritySite(IInternetSecurityMgrSite *pSite)
00567 {
00568         return INET_E_DEFAULT_ACTION;
00569 }
00570 
00571 STDMETHODIMP CWebCtrl::DocSite::XInternetSecurityManager::SetZoneMapping(DWORD dwZone, LPCWSTR lpszPattern, DWORD dwFlags)
00572 {
00573         return INET_E_DEFAULT_ACTION;
00574 }

Generated on Thu Dec 15 10:39:38 2005 for Shareaza 2.2.1.0 by  doxygen 1.4.2