Exemplo n.º 1
0
//OLECMDID_PRINT	= 6,
HRESULT CWtlHtmlView::ExecCommand( OLECMDID nCmdID, OLECMDEXECOPT nCmdExecOpt, VARIANTARG* pvarargIn, VARIANTARG* pvarargOut) 
{
	HRESULT hr=S_OK;
	LPDISPATCH lpDispatch = NULL;
	LPOLECOMMANDTARGET lpOleCommandTarget = NULL;
	try {

		m_spWebBrowser2->get_Document(&lpDispatch);
		if(lpDispatch==NULL)
			throw;
		OLECMDF eQuery ; //      'return value type for QueryStatusWB

		if(FAILED( m_spWebBrowser2->QueryStatusWB(OLECMDID_PRINT, &eQuery))) //  'get print command status
			throw;

		if(!( eQuery & OLECMDF_ENABLED) )
			throw;

		lpDispatch->QueryInterface(IID_IOleCommandTarget, (void**)&lpOleCommandTarget);
		if(lpOleCommandTarget==NULL)
			throw;

		// Print contents of WebBrowser control.
		hr=lpOleCommandTarget->Exec(NULL, nCmdID, nCmdExecOpt, pvarargIn, pvarargOut);
	}
	catch(...)
	{
		hr=E_FAIL;
	}
	if(lpDispatch)
		lpDispatch->Release();
	if(lpOleCommandTarget)
		lpOleCommandTarget->Release();
	return hr;
}
Exemplo n.º 2
0
/* Toggle a button and return the new state.  */
static void
toggle_button (LPDISPATCH button, const char *tag, int instid)
{
  int state;
  char tag2[256];
  char *p;
  LPDISPATCH inspector;
  
  inspector = get_inspector_from_instid (instid);
  if (!inspector)
    {
      log_debug ("%s:%s: inspector not found", SRCNAME, __func__);
      return;
    }

  state = get_oom_int (button, "State");
  log_debug ("%s:%s: button `%s' state is %d", SRCNAME, __func__, tag, state);
  state = (state == msoButtonUp)? msoButtonDown : msoButtonUp;
  put_oom_int (button, "State", state);

  /* Toggle the other button.  */
  mem2str (tag2, tag, sizeof tag2 - 2);
  p = strchr (tag2, '#');
  if (p)
    *p = 0;  /* Strip the instance id suffix.  */
  if (*tag2 && tag2[1] && !strcmp (tag2+strlen(tag2)-2, "@t"))
    tag2[strlen(tag2)-2] = 0; /* Remove the "@t".  */
  else
    strcat (tag2, "@t");      /* Append a "@t".  */
  
  log_debug ("%s:%s: setting `%s' state to %d", SRCNAME, __func__, tag2, state);
  set_one_button (inspector, tag2, state);
  inspector->Release ();
}
Exemplo n.º 3
0
VARIANT CWebDlg::ExecuteScript(CString csCode, CString csLanguage)
{
	COleVariant   varRet;

	IHTMLDocument2* pHTMLDocument2;
	IHTMLWindow2*   pHTMLWindow2;
	LPDISPATCH lpDispatch;
	lpDispatch = m_explore.GetDocument();
   
	BSTR            bstrCode    = _bstr_t((const char *)csCode);
	BSTR            bstrLang    = _bstr_t((const char *)csLanguage);
	HRESULT         hr;
 
	if(lpDispatch)
	{
		hr = lpDispatch->QueryInterface(IID_IHTMLDocument2, (void**)&pHTMLDocument2);
		if(hr == S_OK)
		{
			hr = pHTMLDocument2->get_parentWindow(&pHTMLWindow2);
			if(hr == S_OK)
			{
				pHTMLWindow2->execScript(bstrCode, bstrLang, &varRet);
				pHTMLWindow2->Release();
			}
			pHTMLDocument2->Release();
		}
		lpDispatch->Release();
	}
	return varRet;
}
void CIncrementSystemBFDlg::DocumentCompleteExplorerSelectItem(LPDISPATCH pDisp, VARIANT* URL)
{
	CString url = URL->bstrVal;

	if (url.Find(cUrls.Logon) > 0){
		TRACE("UnLoadhook");
		unloadhook();
		isLogon = true;
	}
	if (isLogon){
		if (url.Find(cUrls.Http1) > 0){
			TRACE("Loadhook");
			loadhook();
			isLogon = false;
		}
	}
    IUnknown*  pUnk;  
    LPDISPATCH lpWBDisp;  
    HRESULT    hr;  
 
    pUnk = m_MyIE.GetControlUnknown();  
    ASSERT(pUnk);  
 
    hr = pUnk->QueryInterface(IID_IDispatch, (void**)&lpWBDisp);  
    ASSERT(SUCCEEDED(hr));  
 
    if (pDisp == lpWBDisp )  
    {
        //TRACE("Web document is finished downloading/n");//这里就是最佳获取时机的判断
    }
    pUnk->Release();
    lpWBDisp->Release();
}
void
addCircleThroughCom()
{
    AutoCAD::IAcadApplication *pAcad;
    AutoCAD::IAcadDocument *pDoc;
    AutoCAD::IAcadModelSpace *pMSpace;

    HRESULT hr = NOERROR;
    LPUNKNOWN pUnk = NULL;
    LPDISPATCH pAcadDisp = acedGetIDispatch(TRUE); 
	if(pAcadDisp==NULL)
		return;
	
	hr = pAcadDisp->QueryInterface(AutoCAD::IID_IAcadApplication,(void**)&pAcad);
	pAcadDisp->Release();
	if (FAILED(hr))
		return;

	hr = pAcad->get_ActiveDocument(&pDoc);
	pAcad->Release();
	if (FAILED(hr))
		return;

	hr = pDoc->get_ModelSpace(&pMSpace);
	pDoc->Release();
	if (FAILED(hr))
		return;


    SAFEARRAYBOUND rgsaBound;
    rgsaBound.lLbound = 0L;
    rgsaBound.cElements = 3;
    long i;
    SAFEARRAY* pStartPoint = NULL;
    pStartPoint = SafeArrayCreate(VT_R8, 1, &rgsaBound);

    i = 0;
    double value = 4.0;
    SafeArrayPutElement(pStartPoint, &i, &value);
    
    i = 1;
    value = 2.0;
    SafeArrayPutElement(pStartPoint, &i, &value);
    
    i = 2;
    value = 0.0;
    SafeArrayPutElement(pStartPoint, &i, &value);
    
    VARIANT pt1;
    pt1.vt = VT_ARRAY | VT_R8;
    pt1.parray = pStartPoint;

    AutoCAD::IAcadCircle *pCircle;
    pMSpace->AddCircle(pt1, 2.0, &pCircle);
	VariantClear(&pt1);
    pMSpace->Release();
}
Exemplo n.º 6
0
void CNetscapeCntrItem::OnActivate()
{
	char * pSource = NULL;
	const char* ptr;
	LPDISPATCH pdisp;
	HRESULT hr;
	int _convert;
	if (m_lpObject->QueryInterface(IID_IDispatch, (void**)&pdisp) == S_OK){
#ifdef XP_WIN32
		LPCOLESTR lpOleStr = T2COLE("SaveAs");
		hr = pdisp->GetIDsOfNames(IID_NULL, (unsigned short **)&lpOleStr, 1, LOCALE_USER_DEFAULT, &m_idSavedAs);
		pdisp->Release();
		if (hr == S_OK)	
			m_bCanSavedByOLE = TRUE;
		else
			m_idSavedAs = DISPID_UNKNOWN;
#else
			m_idSavedAs = DISPID_UNKNOWN;
#endif
	}

	const char* ptr1 = m_csAddress; 
	if (NET_IsLocalFileURL((char*)ptr1)) {
		XP_ConvertUrlToLocalFile(m_csAddress, &pSource);
		m_csDosName = *pSource;  // pick up the drive name.
		m_csDosName += ":";
		m_csDosName += strchr(pSource, '\\');  // pick up the real file name.
		ptr = m_csDosName;	 
		FE_ConvertSpace((char*)ptr);
		XP_FREE(pSource);
	}

	// the object does not support ole automation, try to find out if this is a storagefile, so
	// we can use OLESave().
	if (!m_bCanSavedByOLE) {
#ifdef XP_WIN32		// we will only want to handle saving when the object had storage file.
		int _convert;
		LPCOLESTR lpsz = A2CW(m_csDosName);
		if (StgIsStorageFile(lpsz) == S_OK) 
			m_bCanSavedByOLE = TRUE;
#else                       
		HRESULT sc1 = StgIsStorageFile(m_csDosName);
		if (GetScode(sc1) == S_OK) 
			m_bCanSavedByOLE = TRUE;
#endif
		}

	CGenericView* pView = GetActiveView();
	CFrameGlue *pFrameGlue = pView->GetFrame();
	if(pFrameGlue != NULL)	{
		m_bLocationBarShowing = pFrameGlue->GetChrome()->GetToolbarVisible(ID_LOCATION_TOOLBAR);
	}

	COleClientItem::OnActivate();
}
// MyTimerProc is a callback function passed to SetTimer()
VOID CALLBACK MyTimerProc(HWND /*hwnd*/, UINT /*uMsg*/, UINT /*idEvent*/, 
   DWORD /*dwTime*/)
{
   LPDISPATCH pDisp = NULL;
   // gpMyCtrl is a global variable of type CMyCtrl*
   // _GetEntries() is a static function you get with BEGIN_COM_MAP()
   AtlInternalQueryInterface (gpMyCtrl, CMyCtrl::_GetEntries(), IID_IDispatch, 
      (LPVOID*)&pDisp);
   //...
   pDisp->Release ();
}
Exemplo n.º 8
0
// The open document event handle is the place where the real interface work
// is done.
// Vim gets called from here.
//
HRESULT CCommands::XApplicationEvents::DocumentOpen (IDispatch * theDocument)
{
	AFX_MANAGE_STATE (AfxGetStaticModuleState ());

	if (! g_bEnableVim)
		// Vim not enabled or empty command line entered
		return S_OK;

	// First get the current file name and line number

	// Get the document object
	CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc (theDocument);
	if (! pDoc)
		return S_OK;

	BSTR FileName;
	long LineNr = -1;

	// Get the document name
	if (FAILED (pDoc->get_FullName (&FileName)))
		return S_OK;

	LPDISPATCH pDispSel;

	// Get a selection object dispatch pointer
	if (SUCCEEDED (pDoc->get_Selection (&pDispSel)))
	{
		// Get the selection object
		CComQIPtr < ITextSelection, &IID_ITextSelection > pSel (pDispSel);

		if (pSel)
			// Get the selection line number
			pSel->get_CurrentLine (&LineNr);

		pDispSel->Release ();
	}

	// Open the file in Vim and position to the current line
	if (VimOpenFile (FileName, LineNr))
	{
		if (! g_bDevStudioEditor)
		{
			// Close the document in developer studio
			CComVariant vSaveChanges = dsSaveChangesPrompt;
			DsSaveStatus Saved;

			pDoc->Close (vSaveChanges, &Saved);
		}
	}

	// We're done here
	SysFreeString (FileName);
	return S_OK;
}
Exemplo n.º 9
0
IHTMLDocument2Ptr CH_HBarWnd::GetHtmlDocument(){
  LPDISPATCH pDispatch = 0;
  if(pwb_){
    if (FAILED(pwb_->get_Document(&pDispatch))){
      return NULL;
    }
  }
  IHTMLDocument2Ptr pHtmlDoc2 = pDispatch;
  if(pDispatch)
    pDispatch->Release();
  return pHtmlDoc2;
}
Exemplo n.º 10
0
/* Get the flags from the inspector; i.e. whether to sign or encrypt a
   message.  Returns 0 on success.  */
int
get_inspector_composer_flags (LPDISPATCH inspector,
                              bool *r_sign, bool *r_encrypt)
{
  LPDISPATCH button;
  int rc = 0;

  button = get_button (inspector, "GpgOL_Inspector_Sign");
  if (!button)
    {
      log_error ("%s:%s: Sign button not found", SRCNAME, __func__);
      rc = -1;
    }
  else
    {
      *r_sign = get_oom_int (button, "State") == msoButtonDown;
      button->Release ();
    }

  button = get_button (inspector, "GpgOL_Inspector_Encrypt");
  if (!button)
    {
      log_error ("%s:%s: Encrypt button not found", SRCNAME, __func__);
      rc = -1;
    }
  else
    {
      *r_encrypt = get_oom_int (button, "State") == msoButtonDown;
      button->Release ();
    }
  
  if (!rc)
    log_debug ("%s:%s: sign=%d encrypt=%d",
               SRCNAME, __func__, *r_sign, *r_encrypt);
  return rc;
}
Exemplo n.º 11
0
const COleDispatchDriver&
COleDispatchDriver::operator=(const COleDispatchDriver& dispatchSrc)
{
	if (this != &dispatchSrc)
	{
		LPDISPATCH lpTemp = m_lpDispatch;
		m_lpDispatch = dispatchSrc.m_lpDispatch;
		if (m_lpDispatch != NULL)
			m_lpDispatch->AddRef();
		if (lpTemp != NULL && m_bAutoRelease)
			lpTemp->Release();
		m_bAutoRelease = TRUE;
	}
	return *this;
}
Exemplo n.º 12
0
void CEx24dView::OnDlloleLoad() 
{
   if(!m_auto.CreateDispatch("Ex24b.Auto")) {
		AfxMessageBox("Ex24b.Auto component not found");
		return;
   }
   m_auto.SetTextData(COleVariant("test"));  // testing
   m_auto.SetLongData(79);  // testing
	// verify dispatch interface
    // {A9515AD7-5B85-11D0-848F-00400526305B}
	static const IID IID_IEx24bAuto =
	{ 0xa9515ad7, 0x5b85, 0x11d0, { 0x84, 0x8f, 0x0, 0x40, 0x5, 0x26, 0x30, 0x5b } };
	LPDISPATCH p;
	HRESULT hr = m_auto.m_lpDispatch->QueryInterface(IID_IEx24bAuto, 
		(void**) &p);
	TRACE("OnDlloleLoad -- QueryInterface result = %x\n", hr);
	p->Release();
}
Exemplo n.º 13
0
/*  CreateUser()   - Function for creating a basic User
    
    Parameters

        IDirectoryObject *pDirObject    -   Parent Directory Object for the new User
        LPWSTR pwCommonName             -   Common Name for the new User
        IDirectoryObject ** ppDirObjRet -   Pointer to the Pointer which will receive the new User
        int iUserType                  -   Bitflags for new User:
                                                                    ADS_User_TYPE_GLOBAL_User, 
                                                                    ADS_User_TYPE_DOMAIN_LOCAL_User, 
                                                                    ADS_User_TYPE_UNIVERSAL_User, 
                                                                    ADS_User_TYPE_SECURITY_ENABLED 
*/
HRESULT CreateUser(IDirectoryObject *pDirObject, LPWSTR pwCommonName,LPWSTR pwSamAcctName,IDirectoryObject ** ppDirObjRet)
{
    assert(pDirObject);
    if (wcslen(pwSamAcctName) >20)
    {
        MessageBox(NULL,L"SamAccountName CANNOT be bigger than 20 characters",L"Error: CreateSimpleUser()",MB_ICONSTOP);
        assert(0);
        return E_FAIL;
    }

	HRESULT    hr;
    ADSVALUE   sAMValue;
    ADSVALUE   classValue;
    LPDISPATCH pDisp;
    WCHAR       pwCommonNameFull[1024];
    
    ADS_ATTR_INFO  attrInfo[] = 
    {  
       { L"objectClass", ADS_ATTR_UPDATE, 
                           ADSTYPE_CASE_IGNORE_STRING, &classValue, 1 },
       {L"sAMAccountName", ADS_ATTR_UPDATE, 
                           ADSTYPE_CASE_IGNORE_STRING, &sAMValue, 1},
    };

    DWORD dwAttrs = sizeof(attrInfo)/sizeof(ADS_ATTR_INFO); 
    classValue.dwType = ADSTYPE_CASE_IGNORE_STRING;
    classValue.CaseIgnoreString = L"User";
   
    sAMValue.dwType=ADSTYPE_CASE_IGNORE_STRING;
    sAMValue.CaseIgnoreString = pwSamAcctName;
 
    wsprintfW(pwCommonNameFull,L"CN=%s",pwCommonName);
     
    hr = pDirObject->CreateDSObject( pwCommonNameFull,  attrInfo, 
                                dwAttrs, &pDisp );
    if (SUCCEEDED(hr))
    {
        hr = pDisp->QueryInterface(IID_IDirectoryObject,(void**) ppDirObjRet);

        pDisp->Release();
        pDisp = NULL;
    }
    return hr;
}
Exemplo n.º 14
0
/* Check whether we are in composer or read mode.  */
static bool
is_inspector_in_composer_mode (LPDISPATCH inspector)
{
  LPDISPATCH obj;
  bool in_composer;
  
  obj = get_oom_object (inspector, "get_CurrentItem");
  if (obj)
    {
      /* We are in composer mode if the "Sent" property is false and
         the class is 43.  */
      in_composer = (!get_oom_bool (obj, "Sent") 
                     && get_oom_int (obj, "Class") == 43);
      obj->Release ();
    }
  else
    in_composer = false;
  return in_composer;
}
Exemplo n.º 15
0
void
run_explorer_revert_folder (LPDISPATCH button)
{
  LPDISPATCH obj;

  log_debug ("%s:%s: Enter", SRCNAME, __func__);

  /* Notify the user that the general GpgOl function will be disabled
     when calling this function.  */
  if ( opt.disable_gpgol
       || (MessageBox 
           (NULL/* FIXME: need the hwnd */,
            _("You are about to start the process of reversing messages "
              "created by GpgOL to prepare deinstalling of GpgOL. "
              "Running this command will put GpgOL into a disabled state "
              "so that messages are not anymore processed by GpgOL.\n"
              "\n"
              "You should convert all folders one after the other with "
              "this command, close Outlook and then deinstall GpgOL.\n"
              "\n"
              "Note that if you start Outlook again with GpgOL still "
              "being installed, GpgOL will again process messages."),
            _("GpgOL"), MB_ICONWARNING|MB_OKCANCEL) == IDOK))
    {
      if ( MessageBox 
           (NULL /* Fixme: need hwnd */,
            _("Do you want to revert this folder?"),
            _("GpgOL"), MB_ICONQUESTION|MB_YESNO) == IDYES )
        {
          if (!opt.disable_gpgol)
            opt.disable_gpgol = 1;

          obj = get_oom_object (button, 
                                "get_Parent.get_Parent.get_Parent.get_Parent"
                                ".get_CurrentFolder");
          if (obj)
            {
              gpgol_folder_revert (obj);
              obj->Release ();
            }
        }
    }
}
Exemplo n.º 16
0
//
// Function: LoadWebOCFromStream
//
// Description: Takes an IWebBrowser pointer and causes the stream to 
// be loaded into the contained HTML Document Object.
//
HRESULT LoadWebOCFromStream(IWebBrowser *pWebBrowser, IStream *pStream)
{
    HRESULT             hr;
    LPDISPATCH          pHtmlDoc = NULL;
    IPersistStreamInit *pPersistStreamInit = NULL;

    // Test for valid pointers.
    //
    if (!pWebBrowser || !pStream)
        return E_POINTER;

    // Get to the document object's IDispatch pointer.
    //
    hr = pWebBrowser->get_Document(&pHtmlDoc);
    if (hr)
        goto CleanUp;

    // Query for IPersistStreamInit
    //
    hr = pHtmlDoc->QueryInterface(IID_IPersistStreamInit, 
            (void**)&pPersistStreamInit);
    if (hr)
        goto CleanUp;

    // Tell the document we'll be reinitializing it.
    //
    hr = pPersistStreamInit->InitNew();
    if (hr)
        goto CleanUp;

    // Load the contents of the stream.
    //
    hr = pPersistStreamInit->Load(pStream);

CleanUp:
    if (pHtmlDoc)
        pHtmlDoc->Release();
    if (pPersistStreamInit)
        pPersistStreamInit->Release();
    return hr;

}
Exemplo n.º 17
0
static int
set_one_button (LPDISPATCH inspector, const char *tag, bool down)
{
  LPDISPATCH button;
  int rc = 0;

  button = get_button (inspector, tag);
  if (!button)
    {
      log_error ("%s:%s: `%s' not found", SRCNAME, __func__, tag);
      rc = -1;
    }
  else
    {
      if (put_oom_int (button, "State", down? msoButtonDown : msoButtonUp))
        rc = -1;
      button->Release ();
    }
  return rc;
}
Exemplo n.º 18
0
GpgolInspectorEvents::Activate (void)
{
  LPOOMINSPECTOR inspector;
  LPDISPATCH obj;

  log_debug ("%s:%s: Called (this=%p, inspector=%p)", 
             SRCNAME, __func__, this, m_object);
  
  /* Note: It is easier to use the registered inspector object than to
     find the inspector object in the ALL_INSPECTORS list.  The
     ALL_INSPECTORS list primarly useful to keep track of additional
     information, not directly related to the event sink. */
  if (!m_object)
    {
      log_error ("%s:%s: Object not set", SRCNAME, __func__);
      return;
    }
  inspector = (LPOOMINSPECTOR)m_object;
  inspector->AddRef ();

  /* If this is the first activate for the inspector, we add the
     controls.  We do it only now to be sure that everything has been
     initialized.  Doing that in GpgolInspectorsEvents::NewInspector
     is not suggested due to claims from some mailing lists.  */ 
  if (!m_first_activate_seen)
    {
      m_first_activate_seen = true;
      add_inspector_controls (inspector);
      obj = get_oom_object (inspector, "get_CurrentItem");
      if (obj)
        {
          // LPDISPATCH obj2 = install_GpgolItemEvents_sink (obj);
          // if (obj2)
          //   obj2->Release ();
          obj->Release ();
        }
    }
  
  update_crypto_info (inspector);
  inspector->Release ();
}
void CGraphConstructionForm::Reload(GraphStudio::RenderParameters *params)
{
	CString		text;
	GenerateHTML(text, params);

	LPDISPATCH		doc = browser_window.get_Document();
	if (doc) {
		CComPtr<IHTMLDocument2>	html;
		doc->QueryInterface(IID_IHTMLDocument2, (void**)&html);
		if (html) {

			CComBSTR    bstrURL;
			CComVariant varDummy;

			html->open(bstrURL, CComVariant("_self"), varDummy, varDummy, NULL);

			// Create a safearray to store the HTML text
			SAFEARRAY      *pSA = NULL;
			SAFEARRAYBOUND  saBound = {1, 0};
			pSA = SafeArrayCreate(VT_VARIANT, 1, &saBound);
			if (pSA) {

				// Copy the HTML into the one and only element
				VARIANT   *pVar;	
				SafeArrayAccessData(pSA, (void**)&pVar);    // Access safearray data

				V_BSTR(pVar)	= SysAllocString(text);
				V_VT(pVar)		= VT_BSTR;

				SafeArrayUnaccessData(pSA);                 // Release access
				// Write the HTML as the document's new text
				html->write(pSA);                           // Overwrite HTML
				SafeArrayDestroy(pSA);                      // Finished with the safearray
			}

			html->close();  
		}
		doc->Release();
	}	
}
Exemplo n.º 20
0
/* The method called by outlook for each new inspector.  Note that
   Outlook sometimes reuses Inspectro objects thus this event is not
   an indication for a newly opened Inspector.  */
STDMETHODIMP
GpgolInspectorsEvents::NewInspector (LPOOMINSPECTOR inspector)
{
  LPDISPATCH obj;

  log_debug ("%s:%s: Called (this=%p, inspector=%p)",
             SRCNAME, __func__, this, inspector);

  /* It has been said that INSPECTOR here a "weak" reference. This may
     mean that the object has not been fully initialized.  So better
     take some care here and also take an additional reference.  */

  inspector->AddRef ();
  obj = install_GpgolInspectorEvents_sink ((LPDISPATCH)inspector);
  if (obj)
    {
      register_inspector ((LPGPGOLINSPECTOREVENTS)obj, inspector);
      obj->Release ();
    }
  inspector->Release ();
  return S_OK;
}
Exemplo n.º 21
0
HRESULT CMyAddin::GetOutlookApp(IExchExtCallback 		*pmecb,
			     Outlook::_ApplicationPtr 	&rOLAppPtr)
{
   AFX_MANAGE_STATE(AfxGetStaticModuleState());
   try
   {
	  IOutlookExtCallback *pOutlook = NULL;
      HRESULT hRes = pmecb->QueryInterface(IID_IOutlookExtCallback,(void **) &pOutlook);
      if (pOutlook)
      {
         IUnknown *pUnk = NULL;
         pOutlook->GetObject(&pUnk);
         LPDISPATCH lpMyDispatch;
         if (pUnk != NULL)
         {
            hRes = pUnk->QueryInterface(IID_IDispatch, (void **) &lpMyDispatch);
			pUnk->Release();
         }
         if (lpMyDispatch)
         {
            OLECHAR * szApplication = L"Application";
			DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
			DISPID dspid;
			VARIANT vtResult;
			lpMyDispatch->GetIDsOfNames(IID_NULL, &szApplication, 1, LOCALE_SYSTEM_DEFAULT, &dspid);
			lpMyDispatch->Invoke(dspid, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &dispparamsNoArgs, &vtResult, NULL, NULL);
			lpMyDispatch->Release();

			rOLAppPtr= vtResult.pdispVal;
            return S_OK;
         }
      }
   }
   catch(...)
   {
   }
   return S_FALSE;
}
/**
* Event: OnBeforeNavigate2
*/
void __stdcall CBrowserHelperObject::OnBeforeNavigate2(IDispatch *idispatch, VARIANT *url, VARIANT *Flags, VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers, VARIANT_BOOL* Cancel)
{
  // add page counter so we can compare in DownloadBegin function
  ++m_nPageCounter;

  LPDISPATCH lpWBDisp = nullptr;
  HRESULT hr = S_OK;
  for (;;) {
    BreakOnNull(url, hr);
    // capture relevant information on the URL etc we are about to load.
    BSTR strUrl = (BSTR)url->bstrVal;
    BreakOnNull(m_webBrowser2, hr);
    // get web browser Dispatch to see if this is the top level URL call
    m_webBrowser2->QueryInterface(IID_IDispatch, (void**)&lpWBDisp);
    BreakOnNull(lpWBDisp, hr);
    if (idispatch == lpWBDisp && !m_bIsRefresh) {
      // Top-level Window object, so store URL for a refresh request
      m_strUrl = strUrl;
    }
    lpWBDisp->Release();
    break;
  }
}
Exemplo n.º 23
0
void CHtmlView::OnFilePrint()
{
	// get the HTMLDocument

	if (m_pBrowserApp != NULL)
	{
		LPOLECOMMANDTARGET lpTarget = NULL;
		LPDISPATCH lpDisp = GetHtmlDocument();

		if (lpDisp != NULL)
		{
			// the control will handle all printing UI

			if (SUCCEEDED(lpDisp->QueryInterface(IID_IOleCommandTarget,
					(LPVOID*) &lpTarget)))
			{
				lpTarget->Exec(NULL, OLECMDID_PRINT, 0, NULL, NULL);
				lpTarget->Release();
			}
			lpDisp->Release();
		}
	}
}
Exemplo n.º 24
0
void CMFCApplication2View::OnDocumentComplete(LPCTSTR lpszURL)
{
	CHtmlView::OnDocumentComplete(lpszURL);
	if (lpszURL != nullptr) {
		CString strURL(lpszURL);
		static int i = 0;
		if (strURL.Find(_T("127.0.0.1.com/?code=")) > 0 && i == 0)
		{
			CString strCode = strURL.Mid(strURL.Find(_T("127.0.0.1.com/?code="))+20);
			CString strNewURL(_T("https://api.ciscospark.com/v1/access_token"));
			CString strPostData(_T("grant_type=authorization_code&client_id=Ce07a320a3e5fd132ac55854ef107e48988fb573b0478c4126df9f01d941a3ec3&client_secret=ec699f8e1f970a7b4e76b06ca226e1d5e3a5c40ee509cacbda2f6d1da7662b67&redirect_uri=http%3A%2F%2F127.0.0.1.com&code="));
			strPostData.Append(strCode);
			Navigate2(strNewURL, NULL, NULL, NULL, (LPVOID)(LPCTSTR)strPostData, (DWORD)strPostData.GetLength());
			i++;
		}

		
		if (i == 1) {
			LPDISPATCH   lpDispatch;
			lpDispatch = GetHtmlDocument();
			ASSERT(lpDispatch);
			CComQIPtr <IHTMLDocument2, &IID_IHTMLDocument2>   pDoc2;
			HRESULT   hr;
			hr = lpDispatch->QueryInterface(IID_IHTMLDocument2, (void**)&pDoc2);
			if (SUCCEEDED(hr))
			{
				IHTMLElement   *pBodyElement;
				pDoc2->get_body(&pBodyElement);
				BSTR   body;
				pBodyElement->get_innerHTML(&body);
				char * strBody = ::_com_util::ConvertBSTRToString(body);
				pDoc2.Release();
			}
			lpDispatch->Release();
		}
	}
}
Exemplo n.º 25
0
void CWebDlg::OnBeforeNavigate2(LPDISPATCH pDisp, VARIANT FAR* URL, VARIANT FAR* Flags, VARIANT FAR* TargetFrameName, VARIANT FAR* PostData, VARIANT FAR* Headers, BOOL FAR* Cancel) 
{
/*	CRect	r;

	GetClientRect(&r);
	ClientToScreen(&r);
	m_dlgLoading.MoveWindow(r.left+BROWSER_X, r.top+BROWSER_Y, BROWSER_W, BROWSER_H);
	m_dlgLoading.ShowWindow(SW_SHOW);*/

	// set the user agent to nel_launcher changing the header
    CString csHeader(Headers->bstrVal);

    if(csHeader.IsEmpty())
	{
		IWebBrowser2 *pBrowser;
		LPDISPATCH pWebDisp;

		pDisp->QueryInterface(IID_IWebBrowser2, (void**) &pBrowser);
		pBrowser->get_Container(&pWebDisp);

		BSTR bstr = SysAllocString(L"User-Agent: nel_launcher\r\n");
		Headers->bstrVal =  bstr;

		pBrowser->Navigate2(URL, Flags, TargetFrameName, PostData, Headers);

		if (!pWebDisp)
			(*Cancel) = true;

		if (pWebDisp)
			pWebDisp->Release();
		if (pBrowser)
			pBrowser->Release();

		SysFreeString(bstr);
		return;
    }	
}
Exemplo n.º 26
0
/* Called for a click on an inspector button.  BUTTON is the button
   object and TAG is the tag value (which is guaranteed not to be
   NULL).  INSTID is the instance ID of the button. */
void
proc_inspector_button_click (LPDISPATCH button, const char *tag, int instid)
{
  LPMESSAGE message;
  HWND hwnd = NULL; /* Fixme  */

  if (!tagcmp (tag, "GpgOL_Inspector_Encrypt"))
    {  
      toggle_button (button, tag, instid);
    }
  else if (!tagcmp (tag, "GpgOL_Inspector_Sign"))
    {  
      toggle_button (button, tag, instid);
    }
  else if (!tagcmp (tag, "GpgOL_Inspector_Verify")
           || !tagcmp (tag, "GpgOL_Inspector_Crypto_Info"))
    {
      LPDISPATCH inspector;

      message = get_message_from_button (instid, &inspector);
      if (message)
        {
          if (message_incoming_handler (message, hwnd, true))
            message_display_handler (message, inspector, hwnd);
          message->Release ();
        }
      if (inspector)
        {
          update_crypto_info (inspector);
          inspector->Release ();
        }
    }
  else if (!tagcmp (tag, "GpgOL_Inspector_Debug-0"))
    {
      log_debug ("%s:%s: command Debug0 (showInfo) called\n",
                 SRCNAME, __func__);
      message = get_message_from_button (instid, NULL);
      if (message)
        {
          message_show_info (message, hwnd);
          message->Release ();
        }
    }
  else if (!tagcmp (tag, "GpgOL_Inspector_Debug-1"))
    {
      log_debug ("%s:%s: command Debug1 (not used) called\n",
                 SRCNAME, __func__);
    }
  else if (!tagcmp (tag, "GpgOL_Inspector_Debug-2"))
    {
      log_debug ("%s:%s: command Debug2 (change message class) called", 
                 SRCNAME, __func__);
      message = get_message_from_button (instid, NULL);
      if (message)
        {
          /* We sync here. */
          mapi_change_message_class (message, 1);
          message->Release ();
        }
    }
  else if (!tagcmp (tag, "GpgOL_Inspector_Debug-3"))
    {
      log_debug ("%s:%s: command Debug3 (revert_message_class) called", 
                 SRCNAME, __func__);
      message = get_message_from_button (instid, NULL);
      if (message)
        {
          int rc = gpgol_message_revert (message, 1, 
                                         KEEP_OPEN_READWRITE|FORCE_SAVE);
          log_debug ("%s:%s: gpgol_message_revert returns %d\n", 
                     SRCNAME, __func__, rc);
          message->Release ();
        }
    }

}
Exemplo n.º 27
0
void CEx24dView::OnExceloleExecute() 
{
   LPDISPATCH pRange, pWorkbooks;
    
   CWnd* pWnd = CWnd::FindWindow("XLMAIN", NULL);
   if (pWnd != NULL) {
     TRACE("Excel window found\n");
     pWnd->ShowWindow(SW_SHOWNORMAL);
     pWnd->UpdateWindow();
     pWnd->BringWindowToTop();
   }

   m_app.SetSheetsInNewWorkbook(1);
   
   VERIFY(pWorkbooks = m_app.GetWorkbooks());
   m_workbooks.AttachDispatch(pWorkbooks);

   LPDISPATCH pWorkbook = NULL;
   if (m_workbooks.GetCount() == 0) {
      // Add returns a Workbook pointer, but we
      //  don't have a Workbook class
      pWorkbook = m_workbooks.Add(); // Save the pointer for
                                     //  later release
   }
   LPDISPATCH pWorksheets = m_app.GetWorksheets();
   ASSERT(pWorksheets != NULL);
   m_worksheets.AttachDispatch(pWorksheets);
   LPDISPATCH pWorksheet = m_worksheets.GetItem(COleVariant((short) 1));

   m_worksheet.AttachDispatch(pWorksheet);
   m_worksheet.Select();

   VERIFY(pRange = m_worksheet.GetRange(COleVariant("A1")));
   m_range[0].AttachDispatch(pRange);

   VERIFY(pRange = m_worksheet.GetRange(COleVariant("A2")));
   m_range[1].AttachDispatch(pRange);
   
   VERIFY(pRange = m_worksheet.GetRange(COleVariant("A3")));
   m_range[2].AttachDispatch(pRange);

   VERIFY(pRange = m_worksheet.GetRange(COleVariant("A3"), 
	   COleVariant("C5")));
   m_range[3].AttachDispatch(pRange);

   VERIFY(pRange = m_worksheet.GetRange(COleVariant("A6")));
   m_range[4].AttachDispatch(pRange);
   
   m_range[4].SetValue(COleVariant(COleDateTime(1994, 4, 24, 15, 47, 8)));
   // retrieve the stored date and print it as a string
   COleVariant vaTimeDate = m_range[4].GetValue();
   TRACE("returned date type = %d\n", vaTimeDate.vt);
   COleVariant vaTemp;
   vaTemp.ChangeType(VT_BSTR, &vaTimeDate);
   CString str = vaTemp.bstrVal;
   TRACE("date = %s\n", (const char*) str);

   m_range[0].SetValue(COleVariant("test string"));
   
   COleVariant vaResult0 = m_range[0].GetValue();
   if (vaResult0.vt == VT_BSTR) {
     CString str = vaResult0.bstrVal;
     TRACE("vaResult0 = %s\n", (const char*) str);
   }

   m_range[1].SetValue(COleVariant(3.14159));
   
   COleVariant vaResult1 = m_range[1].GetValue();
   if (vaResult1.vt == VT_R8) {
     TRACE("vaResult1 = %f\n", vaResult1.dblVal);
   }
   
   m_range[2].SetFormula(COleVariant("=$A2*2.0"));
   
   COleVariant vaResult2 = m_range[2].GetValue();
   if (vaResult2.vt == VT_R8) {
     TRACE("vaResult2 = %f\n", vaResult2.dblVal);
   }

   COleVariant vaResult2a = m_range[2].GetFormula();
   if (vaResult2a.vt == VT_BSTR) {
     CString str = vaResult2a.bstrVal;
     TRACE("vaResult2a = %s\n", (const char*) str);
   }
   
   m_range[3].FillRight();
   m_range[3].FillDown();
   
// cleanup  
    if (pWorkbook != NULL) {
	    pWorkbook->Release();
   }
}
Exemplo n.º 28
0
/*
  This method displays the HTML that is passed as a string.
*/
long mHpWebClient::HTML(std::string const& html_txt) {
  IWebBrowser2    *webBrowser2;
  LPDISPATCH       lpDispatch;
  IHTMLDocument2  *htmlDoc2;
  SAFEARRAY       *sfArray;
  VARIANT         *pVar;

  BSTR             bstr_html_txt;

  // bstr_html_txt <> 0 indicates no error.
  //   Here, an error is assumed; but it is also hoped that 
  //   it is actually none
  bstr_html_txt = 0;

  TraceFunc("mHpWebClient::HTML");

  static bool TODO_about_blank_written_once = false;
  if (!TODO_about_blank_written_once) {
    Trace("going to DisplayHTMLPage with about:blank (calling URL)");
    URL("about:blank");
    TODO_about_blank_written_once = true;
  }

  if (!browserObject_->QueryInterface(IID_IWebBrowser2, (void**)&webBrowser2)) {
    if (!webBrowser2->get_Document(&lpDispatch)) {
      if (!lpDispatch->QueryInterface(IID_IHTMLDocument2, (void**)&htmlDoc2)) {
        
        // A SAFEARRAY is a multi dimensional multi type array. 
        // TODO raus mit dem
        SAFEARRAYBOUND ArrayBound = {1, 0};

        /* The HTML passed to IHTMLDocument2::write must be a 
        BSTR within an array of VARIANTs....  */
        if ((sfArray = SafeArrayCreate(VT_VARIANT, 1, &ArrayBound))) {
          if (!SafeArrayAccessData(sfArray, (void**)&pVar)) {
            pVar->vt = VT_BSTR;
#ifndef UNICODE
            std::wstring ws_html_txt = s2ws(html_txt);
            bstr_html_txt = ::SysAllocString(ws_html_txt.c_str());
#else
            bstr_html_txt = ::SysAllocString(html_txt);
#endif
            if ((pVar->bstrVal = bstr_html_txt)) {
              Trace("Going to actually write sfArray into html document");
              if (htmlDoc2->write(sfArray) != S_OK) {
                throw ("Could not write sfArray");
              }

              /* 
                 If the document were not closed, subsequent calls to 
                 DisplayHTMLStr would append to the contents of the page.  */
              htmlDoc2->close();
              Trace("Closing document");
            }
          }

          /*
            Freeing the array along with the VARIANT that SafeArrayAccessData 
            created and the BSTR that was allocated with SysAllocString */
          SafeArrayDestroy(sfArray);
        }

        htmlDoc2->Release();
      }

      lpDispatch->Release();
    }

    webBrowser2->Release();
  }

  // bstr_html_txt <> 0 indicates no error
  if (bstr_html_txt) return 0;

  return(-1);
}
Exemplo n.º 29
0
/* Add all the controls.  */
static void
add_inspector_controls (LPOOMINSPECTOR inspector)
{
  static
  LPDISPATCH obj, controls, button;
  inspector_info_t inspinfo;
  button_list_t buttonlist = NULL;
  const char *tag;
  int in_composer;

  log_debug ("%s:%s: Enter", SRCNAME, __func__);

  /* Check whether we are in composer or read mode.  */
  in_composer = is_inspector_in_composer_mode (inspector);

  /* Add buttons to the Format menu but only in composer mode.  */
  if (in_composer)
    {
      controls = get_oom_object 
        (inspector, "CommandBars.FindControl(,30006).get_Controls");
      if (!controls)
        log_debug ("%s:%s: Menu Popup Format not found\n", SRCNAME, __func__);
      else
        {
          button = opt.disable_gpgol? NULL : add_oom_button (controls);
          if (button)
            {
              tag = add_tag (button, "GpgOL_Inspector_Encrypt");
              put_oom_bool (button, "BeginGroup", true);
              put_oom_int (button, "Style", msoButtonIconAndCaption );
              put_oom_string (button, "Caption",
                              _("&encrypt message with GnuPG"));
              put_oom_icon (button, IDB_ENCRYPT_16, 16);
              put_oom_int (button, "State",
                           opt.encrypt_default? msoButtonDown: msoButtonUp);
              
              obj = install_GpgolCommandBarButtonEvents_sink (button);
              move_to_button_list (&buttonlist, obj, button, tag);
            }
          
          button = opt.disable_gpgol? NULL : add_oom_button (controls);
          if (button)
            {
              tag = add_tag (button, "GpgOL_Inspector_Sign");
              put_oom_int (button, "Style", msoButtonIconAndCaption );
              put_oom_string (button, "Caption", _("&sign message with GnuPG"));
              put_oom_icon (button, IDB_SIGN_16, 16);
              put_oom_int (button, "State",
                           opt.sign_default? msoButtonDown: msoButtonUp);
              
              obj = install_GpgolCommandBarButtonEvents_sink (button);
              move_to_button_list (&buttonlist, obj, button, tag);
            }
          
          controls->Release ();
        }
    }
  

  /* Add buttons to the Extra menu.  */
  controls = get_oom_object (inspector,
                             "CommandBars.FindControl(,30007).get_Controls");
  if (!controls)
    log_debug ("%s:%s: Menu Popup Extras not found\n", SRCNAME, __func__);
  else
    {
      button = in_composer? NULL : add_oom_button (controls);
      if (button)
        {
          tag = add_tag (button, "GpgOL_Inspector_Verify");
          put_oom_int (button, "Style", msoButtonIconAndCaption );
          put_oom_string (button, "Caption", _("GpgOL Decrypt/Verify"));
          put_oom_icon (button, IDB_DECRYPT_VERIFY_16, 16);
          
          obj = install_GpgolCommandBarButtonEvents_sink (button);
          move_to_button_list (&buttonlist, obj, button, tag);
        }

      button = opt.enable_debug? add_oom_button (controls) : NULL;
      if (button)
        {
          tag = add_tag (button, "GpgOL_Inspector_Debug-0");
          put_oom_int (button, "Style", msoButtonCaption );
          put_oom_string (button, "Caption",
                          "GpgOL Debug-0 (display crypto info)");
          
          obj = install_GpgolCommandBarButtonEvents_sink (button);
          move_to_button_list (&buttonlist, obj, button, tag);
        }

      button = opt.enable_debug? add_oom_button (controls) : NULL;
      if (button)
        {
          tag = add_tag (button, "GpgOL_Inspector_Debug-1");
          put_oom_int (button, "Style", msoButtonCaption );
          put_oom_string (button, "Caption",
                          "GpgOL Debug-1 (not used)");
          
          obj = install_GpgolCommandBarButtonEvents_sink (button);
          move_to_button_list (&buttonlist, obj, button, tag);
        }

      button = opt.enable_debug? add_oom_button (controls) : NULL;
      if (button)
        {
          tag = add_tag (button, "GpgOL_Inspector_Debug-2");
          put_oom_int (button, "Style", msoButtonCaption );
          put_oom_string (button, "Caption",
                          "GpgOL Debug-2 (change message class)");
          
          obj = install_GpgolCommandBarButtonEvents_sink (button);
          move_to_button_list (&buttonlist, obj, button, tag);
        }

      controls->Release ();
    }


  /* Create the toolbar buttons.  */
  controls = get_oom_object (inspector,
                             "CommandBars.Item(Standard).get_Controls");
  if (!controls)
    log_error ("%s:%s: CommandBar \"Standard\" not found\n",
               SRCNAME, __func__);
  else
    {
      button = (opt.disable_gpgol || !in_composer
                ? NULL : add_oom_button (controls));
      if (button)
        {
          tag = add_tag (button, "GpgOL_Inspector_Encrypt@t");
          put_oom_int (button, "Style", msoButtonIcon );
          put_oom_string (button, "Caption", _("Encrypt message with GnuPG"));
          put_oom_icon (button, IDB_ENCRYPT_16, 16);
          put_oom_int (button, "State", msoButtonMixed );
          put_oom_int (button, "State",
                       opt.encrypt_default? msoButtonDown: msoButtonUp);
          
          obj = install_GpgolCommandBarButtonEvents_sink (button);
          move_to_button_list (&buttonlist, obj, button, tag);
        }

      button = (opt.disable_gpgol || !in_composer
                ? NULL : add_oom_button (controls));
      if (button)
        {
          tag = add_tag (button, "GpgOL_Inspector_Sign@t");
          put_oom_int (button, "Style", msoButtonIcon);
          put_oom_string (button, "Caption", _("Sign message with GnuPG"));
          put_oom_icon (button, IDB_SIGN_16, 16);
          put_oom_int (button, "State", msoButtonDown);
          put_oom_int (button, "State",
                       opt.sign_default? msoButtonDown: msoButtonUp);
          
          obj = install_GpgolCommandBarButtonEvents_sink (button);
          move_to_button_list (&buttonlist, obj, button, tag);
        }

      button = in_composer? NULL : add_oom_button (controls);
      if (button)
        {
          tag = add_tag (button, "GpgOL_Inspector_Crypto_Info");
          put_oom_int (button, "Style", msoButtonIcon);
          
          obj = install_GpgolCommandBarButtonEvents_sink (button);
          move_to_button_list (&buttonlist, obj, button, tag);
        }

      controls->Release ();
    }


  /* Save the buttonlist.  */
  inspinfo = get_inspector_info (inspector);
  if (inspinfo)
    {
      inspinfo->buttons = buttonlist;
      unlock_all_inspectors ();
    }
  else
    {
      button_list_t ol, ol2;

      log_error ("%s:%s: inspector not registered", SRCNAME, __func__);
      for (ol = buttonlist; ol; ol = ol2)
        {
          ol2 = ol->next;
          if (ol->sink)
            ol->sink->Release ();
          if (ol->button)
            ol->button->Release ();
          xfree (ol);
        }
    }
    
  log_debug ("%s:%s: Leave", SRCNAME, __func__);
}
Exemplo n.º 30
0
/* Update the crypto info icon.  */
static void
update_crypto_info (LPDISPATCH inspector)
{
  HRESULT hr;
  LPDISPATCH button;
  const char *tooltip = "";
  int iconrc = -1;

  button = get_button (inspector, "GpgOL_Inspector_Crypto_Info");
  if (!button)
    {
      log_error ("%s:%s: Crypto Info button not found", SRCNAME, __func__);
      return;
    }

  if (!is_inspector_in_composer_mode (inspector))
    {
      LPDISPATCH obj;
      LPUNKNOWN unknown;
      LPMESSAGE message = NULL;

      obj = get_oom_object (inspector, "get_CurrentItem");
      if (obj)
        {
          unknown = get_oom_iunknown (obj, "MAPIOBJECT");
          if (!unknown)
            log_error ("%s:%s: error getting MAPI object", SRCNAME, __func__);
          else
            {
              hr = unknown->QueryInterface (IID_IMessage, (void**)&message);
              if (hr != S_OK || !message)
                {
                  message = NULL;
                  log_error ("%s:%s: error getting IMESSAGE: hr=%#lx",
                             SRCNAME, __func__, hr);
                }
              unknown->Release ();
            }
          obj->Release ();
        }
      if (message)
        {
          int is_encrypted = 0;
          int is_signed = 0;
          
          switch (mapi_get_message_type (message))
            {
            case MSGTYPE_GPGOL_MULTIPART_ENCRYPTED:
            case MSGTYPE_GPGOL_OPAQUE_ENCRYPTED:
            case MSGTYPE_GPGOL_PGP_MESSAGE:
              is_encrypted = 1;
              if ( mapi_test_sig_status (message) )
                is_signed = 1;
              break;
            case MSGTYPE_GPGOL:
            case MSGTYPE_SMIME:
            case MSGTYPE_UNKNOWN:
              break;
            default:
              is_signed = 1;
              break;
            }
          
          if (is_signed && is_encrypted)
            {
              tooltip =  _("This is a signed and encrypted message.\n"
                           "Click for more information. ");
              iconrc = IDB_DECRYPT_VERIFY_16;
            }
          else if (is_signed)
            {
              tooltip =  _("This is a signed message.\n"
                           "Click for more information. ");
              iconrc = IDB_VERIFY_16;
            }
          else if (is_encrypted)
            {
              tooltip =  _("This is an encrypted message.\n"
                           "Click for more information. ");
              iconrc = IDB_DECRYPT_16;
            }
          
          message->Release ();
        }
    }

  put_oom_string (button, "TooltipText", tooltip);
  if (iconrc != -1)
    put_oom_icon (button, iconrc, 16);
  put_oom_bool (button, "Visible", (iconrc != -1));
  button->Release ();
}