STDMETHODIMP IECrossfireBHO::SetSite(IUnknown* pUnkSite) {
	HRESULT hr = S_OK;
	if (pUnkSite) {
		if (m_webBrowser) {
			m_webBrowser->Release();
			m_webBrowser = NULL;
		}
		hr = pUnkSite->QueryInterface(IID_IWebBrowser2, (void**)&m_webBrowser);
		if (FAILED(hr)) {
			Logger::error("IECrossfireBHO.SetSite(): QI(IWebBrowser2) failed", hr);
		} else {
			hr = DispEventAdvise(m_webBrowser);
			if (FAILED(hr)) {
				Logger::error("IECrossfireBHO.SetSite(): DispEventAdvise() failed", hr);
			}
		}
		initServer(false);
	} else {
		if (m_eventsHooked) {
			HRESULT hr = DispEventUnadvise(m_webBrowser);
			if (SUCCEEDED(hr)) {
				m_eventsHooked = false;
			} else {
				Logger::error("IECrossfireBHO.SetSite(): DispEventUnadvise() failed", hr);
			}
		}
		m_webBrowser->Release();
		m_webBrowser = NULL;
	}

	//return IObjectWithSiteImpl<IECrossfireBHO>::SetSite(pUnkSite);
	return hr;
}
STDMETHODIMP CVolatilityManagement::UnregisterPublisher()
{
	try
	{
		ObjectLock lock(this);

		ATLASSERT( m_spSymbolObject != NULL );
		if( m_spPubManager != NULL )
			__CHECK_HRESULT( m_spPubManager->UnregPublisher( enMtVola, m_spSymbolObject ), _T("Error unregistering publisher.") );
		m_spPubManager = NULL;

		if( m_spSubManager != NULL )
		{
			__CHECK_HRESULT( DispEventUnadvise( m_spSubManager ), _T("Error unadvising messaging source interface") );
			__CHECK_HRESULT( m_spSubManager->UnsubVola( m_spSymbolObject ), _T("Error unsubscribing from volatility messages.") );
		}
		m_spSubManager = NULL;
	}
	catch( const _com_error& e )
	{
		REPORT_ERR_TO_MAIL (e)
		//return Error( (PTCHAR)CComErrorWrapper::ErrorDescription( e ), IID_IVSSymbolVolatility, e.Error() );
		return CComErrorWrapper::SetError(e, L"VolaControl", L"", __FILE__,__FUNCDNAME__,__LINE__);;
	}

	return S_OK;
}
STDMETHODIMP CMSDNForumHelper::SetSite(IUnknown* pUnkSite)
{
    if (pUnkSite != NULL)
    {
		// Cache the pointer to IWebBrowser2.
        HRESULT hr = pUnkSite->QueryInterface(IID_IWebBrowser2, (void **)&m_spWebBrowser);
        if (SUCCEEDED(hr))
        {
            // Register to sink events from DWebBrowserEvents2.
            hr = DispEventAdvise(m_spWebBrowser);
            if (SUCCEEDED(hr))
            {
                m_fAdvised = TRUE;
            }
        }

    }
    else
    {
        // Unregister event sink.
        if (m_fAdvised)
        {
            DispEventUnadvise(m_spWebBrowser);
            m_fAdvised = FALSE;
        }

        // Release cached pointers and other resources here.
        m_spWebBrowser.Release();

    }

    // Return the base class implementation
    return IObjectWithSiteImpl<CMSDNForumHelper>::SetSite(pUnkSite);
}
예제 #4
0
CSoftwareProxy::~CSoftwareProxy()
{
	if (m_spSoftwareEx && m_bUnadvise)
	{
		DispEventUnadvise(m_spSoftwareEx);
	}
}
CWtlHtmlView::~CWtlHtmlView()
{
	if(m_spWebBrowser2!=NULL)
	{
		DispEventUnadvise ( m_spWebBrowser2 );
	}
}
예제 #6
0
// CXRefreshBHO
STDMETHODIMP 
CXRefreshBHO::SetSite(IUnknown* pUnkSite)
{
	WATCH_EXITS;
	DTI(TRACE_I(FS(_T("BHO[%08X]: SetSite(%08X)"), this, pUnkSite)));
	if (pUnkSite != NULL)
	{
		// cache the pointer to IWebBrowser2
		pUnkSite->QueryInterface(IID_IWebBrowser2, (void **)&m_Browser);
		// register to sink events from DWebBrowserEvents2
		DispEventAdvise(m_Browser);
		m_IsAdvised = true;

		// allocate browser id
		BrowserManagerLock browserManager;
		m_BrowserId = browserManager->AllocBrowserId(m_Browser, this);
		m_Logger.m_BrowserId = m_BrowserId;
		ATLASSERT(m_BrowserId!=NULL_BROWSER);

		HWND hwnd;
		HRESULT hr = m_Browser->get_HWND((LONG_PTR*)&hwnd);
		if (SUCCEEDED(hr))
		{
			m_IE7ToolWindow.TryToIntegrate(hwnd);
		}

		m_ConnectionManager.Connect();
	}
	else
	{
		m_ConnectionManager.StopReconnectListener();
		m_ConnectionManager.Disconnect();

		m_IE7ToolWindow.DetachFromIE();

		// unregister event sink.
		if (m_IsAdvised)
		{
			DispEventUnadvise(m_Browser);
			m_IsAdvised = false;
		}

		BrowserManagerLock browserManager;
		CBrowserMessageWindow* bw = browserManager->FindBrowserMessageWindow(m_BrowserId);
		ATLASSERT(bw);
		bw->SetBHO(NULL);
		browserManager->ReleaseBrowserId(m_BrowserId);
		m_BrowserId = NULL_BROWSER;
		m_Logger.m_BrowserId = NULL_BROWSER;

		// release cached pointers and other resources here.
		m_Browser = NULL;
	}

	SendInfoAboutPage();

	// Call base class implementation.
	return IObjectWithSiteImpl<CXRefreshBHO>::SetSite(pUnkSite);
}
예제 #7
0
SkypeThread::~SkypeThread()
{
    if (m_bEventsConnected) {
        if (SUCCEEDED(DispEventUnadvise(m_spSkype)))
            m_bEventsConnected = FALSE;
    }
    m_spSkype = NULL;
}
CDropHandlerSink::~CDropHandlerSink()
{
	if (m_pDropHandlerObj)
	{
		// remove our connection point
		DispEventUnadvise(m_pDropHandlerObj);
	}

	// de-ref the SRC
	m_pDropHandlerObj=NULL;
}
COrderSetNotifySink::~COrderSetNotifySink()
{
	if (m_pOrderSetObj)
	{
		// remove our connection point
		DispEventUnadvise(m_pOrderSetObj);
	}

	// de-ref the SRC
	m_pOrderSetObj=NULL;
}
bool CEventHandler::UnhookEvent(IUnknown* pSource)
{
#if defined(__USE_ADDBACK_DUAL)
    AtlUnadvise(pSource, __uuidof(IAddBackEvents), cookie_);
#elif defined(__USE_ADDBACK_DISPATCH)
    DispEventUnadvise(pSource, &__uuidof(_IAddBackEvents));
#elif defined(__USE_ADDBACK_BYATTRIB_DISPATCH)
    __unhook(&_IAddBackEvents::ChangedAddEnd, pSource, &CEventHandler::onChangedAddEnd);
    __unhook(&_IAddBackEvents::ChangedSum, pSource, &CEventHandler::onChangedSum);
#endif

    return true;
}
예제 #11
0
STDMETHODIMP CDispCtl::Disconnect()
{
	if(m_bConnected){
		HRESULT hr = DispEventUnadvise(m_pIServ); 
		((IUnknown*)m_pIServ)->Release();
		if(hr == S_OK)
		{
			m_bConnected = FALSE;
			SysFreeString(m_OutText.bstrVal);
			m_OutText.bstrVal = SysAllocString(L"Disconnected");
			FireViewChange();
		}
		return hr;
	}
	return S_OK;
}
예제 #12
0
//================================================
// OnAutoUpdateComplete
//================================================
void STDMETHODCALLTYPE CJMBrkr::OnAutoUpdateComplete(DWORD dwResult)
{
	if (dwResult & UPDATE_RESOURCES)
		BroadcastMessage(UWM_UPDATERESOURCE, 0, 0);

	if (m_spUpdateObj)
	{
		HRESULT hr = DispEventUnadvise(m_spUpdateObj);
		m_spUpdateObj.Release();
		m_spUpdateObj = NULL;
	}

	if (dwResult && ::IsWindow(m_OptPropsheet.m_hWnd))
		m_OptPropsheet.ShowWindow(SW_MINIMIZE);

	return;
}
/**
 * Event: OnDisconnect
 */
HRESULT CBrowserHelperObject::OnDisconnect(IUnknown *unknown) 
{
  logger->debug(L"BrowserHelperObject::OnDisconnect() -> " + boost::lexical_cast<wstring>(m_instanceId)+L" -> " + _AtlModule.moduleManifest->uuid);

  HRESULT hr = S_OK;

  // NativeMessaging
  logger->debug(L"BrowserHelperObject::OnDisconnect() release NativeMessaging");
  if (m_nativeMessaging)
    m_nativeMessaging->unload(CComBSTR(_AtlModule.moduleManifest->uuid.c_str()), m_instanceId);

  // NativeAccessible
  logger->debug(L"BrowserHelperObject::OnDisconnect() release NativeAccessible");
  if (m_nativeAccessible)
    m_nativeAccessible.reset();

  // NativeBackground
  logger->debug(L"BrowserHelperObject::OnDisconnect() release NativeBackground");
  if (m_nativeBackground) {
    hr = m_nativeBackground->unload(CComBSTR(_AtlModule.moduleManifest->uuid.c_str()), m_instanceId);
    if (FAILED(hr))
      logger->warn(L"BrowserHelperObject::OnDisconnect failed to unload NativeBackground -> " + boost::lexical_cast<wstring>(m_instanceId) + L" -> " + logger->parse(hr));
  }

  // BrowserHelperObject    
  logger->debug(L"BrowserHelperObject::OnDisconnect() release BHO");
  if (m_webBrowser2 && m_isConnected) {
    hr = DispEventUnadvise(m_webBrowser2);
    if (hr == CONNECT_E_NOCONNECTION) {
      // IE7 disconnects our connection points _before_ calling us with SetSite(NULL)
      logger->warn(L"BrowserHelperObject::OnDisconnect DispEventUnadvise bug");
      hr = S_OK;
    }
    else if (FAILED(hr)) {
      logger->error(L"BrowserHelperObject::OnDisconnect failed to unsink events -> " + logger->parse(hr));
    }
    else {
      logger->debug(L"BrowserHelperObject::OnDisconnect unsunk events");
    }
    m_isConnected = false;
  }

  logger->debug(L"BrowserHelperObject::OnDisconnect() done");
  return hr;
}
예제 #14
0
파일: Plugin.cpp 프로젝트: alezhu/C-YaTabs
void STDMETHODCALLTYPE CPlugin::OnDocumentComplete(IDispatch *pDisp, VARIANT *pvarURL)
{
	// Retrieve the top-level window from the site.
	//HWND hwnd;
	//HRESULT hr = m_spWebBrowser->get_HWND((LONG_PTR*)&hwnd);
	//if (SUCCEEDED(hr))
	//{
	// Output a message box when page is loaded.
	//MessageBox(hwnd, L"OnDocComplete", L"YaTabs", MB_OK);
	//}
	if (m_iCount++ != 0 ) return;
	CComBSTR url = pvarURL->bstrVal;
	if(url == _T("about:blank")) {
		CComBSTR url = _T("bar:Tabs");
		m_spWebBrowser->Navigate(url,NULL,NULL,NULL,NULL);
		DispEventUnadvise(m_spWebBrowser);
		m_fAdvised = FALSE;
	}
}
예제 #15
0
STDMETHODIMP CFlashProtectorBHO::SetSite(IUnknown* pUnkSite)
{
	if (pUnkSite != NULL)
	{
		// Cache the pointer to IWebBrowser2.
		HRESULT hr = pUnkSite->QueryInterface(IID_IWebBrowser2, (void **)&m_spWebBrowser);
		if (SUCCEEDED(hr))
		{
			// Register to sink events from DWebBrowserEvents2.
			hr = DispEventAdvise(m_spWebBrowser);
			if (SUCCEEDED(hr))
			{
				m_fAdvised = TRUE;
			}
		}
		//
		BOOL is_ie_protect_mode = FALSE;
		hr = IEIsProtectedModeProcess(&is_ie_protect_mode);
		long hook_result = 0;
		if(SUCCEEDED(hr) && is_ie_protect_mode) {
			hook_result = IEHooker::GetIEHooker()->Hook(true);
		} else {
			hook_result = IEHooker::GetIEHooker()->Hook(false);
		}

	}
	else
	{
		// Unregister event sink.
		if (m_fAdvised)
		{
			DispEventUnadvise(m_spWebBrowser);
			m_fAdvised = FALSE;
		}

		// Release cached pointers and other resources here.
		m_spWebBrowser.Release();
	}

	// Call base class implementation.
	return IObjectWithSiteImpl<CFlashProtectorBHO>::SetSite(pUnkSite);
}
예제 #16
0
    virtual ~CJabberEvents ()
    {
        DispEventUnadvise ( (IUnknown*)m_pJ->m_Jabb);
//        m_pJ->m_Jabb.Release();
    }
예제 #17
0
STDMETHODIMP CConsoleObject::SetSite(IUnknown* site)
{
	Log(LOG_FUNC, _T("CConsoleObject::SetSite(0x%08p)\n"), site);

	HRESULT hr = S_OK;
	if (site) {
		AddRef();

		hr = IObjectWithSiteImpl<CConsoleObject>::SetSite(site);
		if (FAILED(hr)) return hr;

		CComQIPtr<IWebBrowser2> webBrowser2 = m_spUnkSite;
		if (!webBrowser2) {
			Log(LOG_ERROR, _T("QI IWebBrowser2 failed\n"));
			return E_NOINTERFACE;
		}

		hr = DispEventAdvise(webBrowser2, &DIID_DWebBrowserEvents2);
		if (FAILED(hr)) return hr;

		CComPtr<IRunningObjectTable> rot;
		hr = ::GetRunningObjectTable(0, &rot);
		if (FAILED(hr)) {
			Log(LOG_ERROR, _T("GetRunningObjectTable() failed\n"));
			return hr;
		}

		TCHAR name[64];
		_stprintf(name, _T("comie67:%u"), GetCurrentProcessId());

		CComPtr<IMoniker> moniker;
		hr = ::CreateItemMoniker(OLESTR("!"), name, &moniker);
		if (FAILED(hr)) {
			Log(LOG_ERROR, _T("CreateItemMoniker() failed\n"));
			return hr;
		}

		CComQIPtr<IConsoleObject> obj = this;
		hr = rot->Register(ROTFLAGS_REGISTRATIONKEEPSALIVE, obj, moniker, &mRotCookie);
		if (FAILED(hr)) {
			Log(LOG_ERROR, _T("rot->Register() failed: 0x%x\n"), hr);
			return hr;
		}
	} else {
		CComQIPtr<IWebBrowser2> webBrowser2 = m_spUnkSite;
		if (webBrowser2) {
			DispEventUnadvise(webBrowser2, &DIID_DWebBrowserEvents2);
		}

		CComPtr<IRunningObjectTable> rot;
		hr = GetRunningObjectTable(0, &rot);
		if (FAILED(hr)) return hr;

		hr = rot->Revoke(mRotCookie);
		if (FAILED(hr)) return hr;

		IObjectWithSiteImpl<CConsoleObject>::SetSite(site);
		Release();
	}

	return hr;
}
예제 #18
0
ClickEventRedirector::~ClickEventRedirector()
{
	DispEventUnadvise(m_punk);
}