예제 #1
0
파일: Js2nCtrl.cpp 프로젝트: xgc820313/js2n
void CJs2nCtrl::OnSetClientSite() 
{
	// TODO: Add your specialized code here and/or call the base class
	LPOLECLIENTSITE pClientSite = GetClientSite();

	if (pClientSite != NULL)
	{
		// Obtain URL from container moniker.
		IMoniker*	ppmk;
		LPOLESTR	pszDisplayName;

		if (SUCCEEDED(pClientSite->GetMoniker( OLEGETMONIKER_TEMPFORUSER,
											   OLEWHICHMK_CONTAINER,
											   &ppmk)))
		{
			if (SUCCEEDED(ppmk->GetDisplayName(NULL, NULL, &pszDisplayName)))
			{
				PString strURL( (WORD *)pszDisplayName );
				PString strPluginsPath = FindPluginsPath();
				m_NativeLogic.Init( strURL, strPluginsPath );
				CoTaskMemFree((LPVOID)pszDisplayName);
			}
		}
	}

	COleControl::OnSetClientSite();
}
예제 #2
0
void CMiniMule::_OnBeforeNavigate2(LPDISPATCH pDisp, VARIANT* URL, VARIANT* /*Flags*/, VARIANT* /*TargetFrameName*/, VARIANT* /*PostData*/, VARIANT* /*Headers*/, BOOL* Cancel)
{
    ASSERT( GetCurrentThreadId() == _uMainThreadId );
    CString strURL(V_BSTR(URL));
    TRACE(_T("%hs: %s\n"), __FUNCTION__, strURL);

    // No external links allowed!
    TCHAR szScheme[INTERNET_MAX_SCHEME_LENGTH];
    URL_COMPONENTS Url = {0};
    Url.dwStructSize = sizeof(Url);
    Url.lpszScheme = szScheme;
    Url.dwSchemeLength = ARRSIZE(szScheme);
    if (InternetCrackUrl(strURL, 0, 0, &Url) && Url.dwSchemeLength)
    {
        if (Url.nScheme != INTERNET_SCHEME_UNKNOWN  // <absolute local file path>
                && Url.nScheme != INTERNET_SCHEME_RES	// res://...
                && Url.nScheme != INTERNET_SCHEME_FILE)	// file://...
        {
            *Cancel = TRUE;
            return;
        }
    }

    OnBeforeNavigate(pDisp, strURL);
}
예제 #3
0
HRESULT CCpDialog::WindowOpen(IHTMLElement* pElement, int l, int t, int w, int h, LPCSTR pstrName)
{
	if (!pElement)
		return E_FAIL;

	CComBSTR bstrURL;
	pElement->get_className(&bstrURL);
	CString strURL(bstrURL);
	int iProtocol = strURL.Find(':');
	if (iProtocol < 0 || iProtocol > 5)
	{
		CString strAppRootFolder = GetHomeFolder() + String(GetFolderId());
		strURL = strAppRootFolder + strURL;
	}

	// Get the desired window size and location
	if (l < 0) l = (::GetSystemMetrics(SM_CXSCREEN) - w) / 2;
	if (l < 0) l = 0;
	if (t < 0) t = (::GetSystemMetrics(SM_CYSCREEN) - h) / 2;
	if (t < 0) t = 0;

	RECT Rect = {l, t, l+w, t+h};
	CWorkspaceDialog* pWorkspace = CWorkspaceDialog::CreateModeless(GetDesktopWindow()/*pParent*/, strURL, &Rect, pstrName);
	if (pWorkspace)
		m_WorkspaceArray.Add(pWorkspace);
	
	return S_OK;
}
CString CFileFind::GetFileURL() const
/***********************************/
{
    CString strURL( _T("file://") );
    strURL += GetFilePath();
    return( strURL );
}
예제 #5
0
HRESULT CHtmlCtrl::Navigate(LPCTSTR lpszURL, 
			    DWORD dwFlags /*= 0*/,
			    LPCTSTR lpszTargetFrameName /*= NULL*/,
			    LPCTSTR lpszHeaders /*= NULL*/, 
			    LPVOID lpvPostData /*= NULL*/,
			    DWORD dwPostDataLen /*= 0*/)
{
    CString strURL(lpszURL);
    BSTR bstrURL = strURL.AllocSysString();

    COleSafeArray vPostData;
    if (lpvPostData != NULL)
    {
        if (dwPostDataLen == 0)
            dwPostDataLen = lstrlen((LPCTSTR) lpvPostData);

        vPostData.CreateOneDim(VT_UI1, dwPostDataLen, lpvPostData);
    }

    return m_pBrowser->Navigate(bstrURL,
        COleVariant((long) dwFlags, VT_I4),
        COleVariant(lpszTargetFrameName, VT_BSTR),
        vPostData,
        COleVariant(lpszHeaders, VT_BSTR));
}
예제 #6
0
void CBetaPatchClientDlg::CreateWebControl( LPCTSTR szURL )
{
	// AFX_IDW_PANE_FIRST is a safe but arbitrary ID
#ifdef __LANG_JAP
	//JAPAN 패치 클라이언트 이미지 변경관련 웹 크기 조절.	
	if (!m_wndBrowser.CreateControl(CLSID_WebBrowser, "", WS_VISIBLE | WS_CHILD, CRect(14, 14, 466, 447), 
		this, AFX_IDW_PANE_FIRST))		
#else //__LANG_JAP
#if __CURRENT_LANG == LANG_KOR //공지사항 크기 확장 관련 조정.
	if (!m_wndBrowser.CreateControl(CLSID_WebBrowser, 
			"",	WS_VISIBLE | WS_CHILD, CRect(26, 190, 452, 447), this, AFX_IDW_PANE_FIRST))
#else //LANG_KOR
	if (!m_wndBrowser.CreateControl(CLSID_WebBrowser, 
		                            "",
				                    WS_VISIBLE | WS_CHILD, 
									CRect(26, 263, 452, 447), 
									this, 
									AFX_IDW_PANE_FIRST))
#endif //LANG_KOR
#endif //__LANG_JAP
	{
		return;
	}

	IWebBrowser2* pBrowser;
	LPUNKNOWN lpUnk = m_wndBrowser.GetControlUnknown();
	HRESULT hr = lpUnk->QueryInterface(IID_IWebBrowser2, (void**) &pBrowser);
	if (SUCCEEDED(hr))
	{
		CString strURL( szURL );
		BSTR bstrURL = strURL.AllocSysString();

		COleSafeArray vPostData;
		LPCTSTR lpszTargetFrameName = NULL;
		LPCTSTR lpszHeaders = NULL;

		pBrowser->Navigate(bstrURL,
			COleVariant((long) 0, VT_I4),
			COleVariant(lpszTargetFrameName, VT_BSTR),
			vPostData,
			COleVariant(lpszHeaders, VT_BSTR));
	}
}
예제 #7
0
void CWebCtrl::BeforeNavigate2(LPDISPATCH /*pDispatch*/, VARIANT* pvURL, VARIANT* pvFlags, VARIANT* pvTargetFrameName, VARIANT* pvPostData, VARIANT* pvHeaders, VARIANT_BOOL* pvCancel)
{
	ASSERT(V_VT(pvURL) == VT_BSTR);
	ASSERT(V_VT(pvTargetFrameName) == VT_BSTR);
	ASSERT(pvCancel != NULL);
	*pvCancel = VARIANT_FALSE;

	if ( SysStringLen( V_BSTR(pvTargetFrameName) ) == 0 )
	{
		CString strURL( V_BSTR(pvURL) );

		if ( _tcsncmp( strURL, _T("http"), 4 ) == 0 )
		{
			*pvCancel = VARIANT_TRUE;
			m_tFrame = GetTickCount();
			COleVariant vFrame( _T("_blank"), VT_BSTR );
			m_pBrowser->Navigate2( pvURL, pvFlags, &vFrame, pvPostData, pvHeaders );
		}
	}
}
예제 #8
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();
		}
	}
}
예제 #9
0
HRESULT CMainFrameDropTarget::PasteHTMLDocument(IHTMLDocument2* doc, PASTEURLDATA* /*pPaste*/)
{
    HRESULT hrPasteResult = S_FALSE; // default: nothing was pasted
    int iURLElements = 0;

    // get_links		HREF	all <LINK> and <AREA> elements -> that's *wrong* it also contains all <A> elements!
    // get_anchors		HREF	all <A> elements which have a NAME or ID value!

    //
    // Links
    //
    CComPtr<IHTMLElementCollection> links;
    if (doc->get_links(&links) == S_OK)
    {
        long lLinks;
        if (links->get_length(&lLinks) == S_OK && lLinks > 0)
        {
            iURLElements += lLinks;
            CComVariant vaIndex((long)0);
            CComVariant vaNull((long)0);
            for (long i = 0; i < lLinks; i++)
            {
                vaIndex.lVal = i;
                CComPtr<IDispatch> item;
                if (links->item(vaIndex, vaNull, &item) == S_OK)
                {
                    CComPtr<IHTMLAnchorElement> anchor;
                    if (SUCCEEDED(item->QueryInterface(&anchor)))
                    {
                        CComBSTR bstrHref;
                        if (anchor->get_href(&bstrHref) == S_OK && bstrHref.Length() > 0 && IsUrlSchemeSupportedW(bstrHref))
                        {
                            theApp.emuledlg->ProcessED2KLink(CString(bstrHref));
                            hrPasteResult = S_OK;
                        }
                        anchor.Release(); // conserve memory
                    }
                }
            }
        }
        links.Release(); // conserve memory
    }

    //
    // Text
    //
    // The explicit handling of text is needed, if we're looking at contents which were copied
    // to the clipboard in HTML format -- although it is simple raw text!! This situation applies,
    // if the user opens the "View Partial Source" HTML window for some selected HTML contents,
    // and copies some text (e.g. an URL) to the clipboard. In that case we'll get the raw text
    // as HTML contents!!!
    //
    // PROBLEM: We can *not* always process the HTML elements (anchors, ...) *and* the inner text.
    // The following example (a rather *usual* one) would lead to the adding of the same URL twice
    // because the URL is noted as a HREF *and* as the inner text.
    //
    // <P><A href="http://www.domain.com/image.gif">http://www.domain.com/image.gif</A></P>
    //
    // So, in practice, the examination of the 'innerText' is only done, if there were no other
    // HTML elements in the document.
    //
    if (iURLElements == 0)
    {
        CComPtr<IHTMLElement> el;
        if (doc->get_body(&el) == S_OK)
        {
            CComBSTR bstr;
            if (el->get_innerText(&bstr) == S_OK && bstr.Length() > 0)
            {
                LPCWSTR pwsz = bstr;
                while (*pwsz != L'\0' && iswspace(*pwsz)) // Skip white spaces
                    pwsz++;

                // PROBLEM: The 'innerText' does not contain any HTML tags, but it *MAY* contain
                // HTML comments like "<!--StartFragment-->...<!--EndFragment-->". Those
                // tags have to be explicitly parsed to get the real raw text contents.
                // Those Start- and End-tags are available if the text is copied into the clipboard
                // from a HTML window which was open with "View Partial Source"!
                static const WCHAR _wszStartFrag[] = L"<!--StartFragment-->";
                if (wcsncmp(pwsz, _wszStartFrag, ARRSIZE(_wszStartFrag)-1) == 0)
                {
                    pwsz += ARRSIZE(_wszStartFrag)-1;

                    // If there's a Start-tag, search for an End-tag.
                    static const WCHAR _wszEndFrag[] = L"<!--EndFragment-->";
                    LPWSTR pwszEnd = (LPWSTR)bstr + bstr.Length();
                    pwszEnd -= ARRSIZE(_wszEndFrag)-1;
                    if (pwszEnd >= pwsz)
                    {
                        if (wcsncmp(pwszEnd, _wszEndFrag, ARRSIZE(_wszEndFrag)-1) == 0)
                            *pwszEnd = L'\0'; // Ugly but efficient, terminate the BSTR!
                    }
                }

                // Search all white-space terminated strings and check for a valid URL-scheme
                while (*pwsz != L'\0')
                {
                    while (*pwsz != L'\0' && iswspace(*pwsz)) // Skip white spaces
                        pwsz++;

                    if (IsUrlSchemeSupportedW(pwsz))
                    {
                        LPCWSTR pwszEnd = pwsz;
                        while (*pwszEnd != L'\0' && !iswspace(*pwszEnd)) // Search next white space (end of current string)
                            pwszEnd++;
                        int iLen = pwszEnd - pwsz;
                        if (iLen > 0)
                        {
                            CString strURL(pwsz, iLen);
                            theApp.emuledlg->ProcessED2KLink(strURL);
                            hrPasteResult = S_OK;
                            pwsz += iLen;
                        }
                    }
                    else
                    {
                        while (*pwsz != L'\0' && !iswspace(*pwsz)) // Search next white space (end of current string)
                            pwsz++;
                    }

                    while (*pwsz != L'\0' && iswspace(*pwsz)) // Skip white spaces
                        pwsz++;
                }
            }
        }
    }

    return hrPasteResult;
}
예제 #10
0
// Private methods
//--------------------------------------------------------------------
int ArmoryImporter::readJSONValues(ImportType type, std::string url, wxJSONValue & result) const
{
  wxString apiPage;
  switch(type)
  {
    case CHARACTER:
    {
      /*
				Blizzard's API is mostly RESTful, with data being returned as JSON arrays.
				Full documentation available here: http://blizzard.github.com/api-wow-docs/

				We can now gather all the data with a single request of Host + "/api/wow/character/" + Realm + "/" + CharacterName + "?fields=appearance,items"
				Example: http://us.battle.net/api/wow/character/steamwheedle-cartel/Kjasi?fields=appearance,items

				This will give us all the information we need inside of a JSON array.
				Format as follows:
				{
					"lastModified":1319438058000
					"name":"Kjasi",
					"realm":"Steamwheedle Cartel",
					"class":5,
					"race":1,
					"gender":0,
					"level":83,
					"achievementPoints":4290,
					"thumbnail":"steamwheedle-cartel/193/3589057-avatar.jpg",
					"items":{	This is the Items array. All available item information is listed here.
						"averageItemLevel":298,
						"averageItemLevelEquipped":277,
						"head":{
							"id":50006,
							"name":"Corp'rethar Ceremonial Crown",
							"icon":"inv_helmet_156",
							"quality":4,
							"tooltipParams":{
								"gem0":41376,
								"gem1":40151,
								"enchant":3819,
								"reforge":119
								"transmogItem":63672
							}
						},
						(More slots),
						"ranged":{
							"id":55480,
							"name":"Swamplight Wand of the Invoker",
							"icon":"inv_wand_1h_cataclysm_b_01",
							"quality":2,
							"tooltipParams":{
								"suffix":-39
							}
						}
					},
					"appearance":{
						"faceVariation":11,
						"skinColor":1,
						"hairVariation":11,
						"hairColor":4,
						"featureVariation":1,
						"showHelm":true,
						"showCloak":true
					}
				}

				As you can see, this will give us almost all the data we need to properly rebuild the character.

       */
      wxString strURL(url);

      // Import from http://us.battle.net/wow/en/character/steamwheedle-cartel/Kjasi/simple
      if ((strURL.Find(wxT("simple")) == wxNOT_FOUND) &&
          (strURL.Find(wxT("advanced")) == wxNOT_FOUND))
      {
        // due to Qt plugin, this cause application crash
        // temporary solution : cascade return value to main app to display the pop up (see modelviewer.cpp)
        //wxMessageBox(wxT("Improperly Formatted URL.\nMake sure your link ends in /simple or /advanced."),wxT("Bad Armory Link"));
        LOG_INFO << wxT("Improperly Formatted URL. Lacks /simple and /advanced");
        return 2;
      }
      wxString strDomain = strURL.Mid(7).BeforeFirst('/');
      wxString strPage = strURL.Mid(7).Mid(strDomain.Len());

      wxString Region = strDomain.BeforeFirst('.');

      wxString strp = strPage.BeforeLast('/');	// No simple/advanced
      wxString CharName = strp.AfterLast('/');
      strp = strp.BeforeLast('/');				// Update strp
      wxString Realm = strp.AfterLast('/');

      LOG_INFO << "Loading Battle.Net Armory. Region: " << Region << ", Realm: " << Realm.c_str() << ", Character: " << CharName.c_str();

      apiPage = wxT("https://wowmodelviewer.net/armory.php?region=");
      apiPage << Region << "&realm=" << Realm << "&char=" << CharName;
      break;
    }
    case ITEM:
    {
      // url given is something like http://eu.battle.net/wow/fr/item/104673
      // we need :
      // 1. base battle.net address
      // 2. locale (fr in above example) - Later
      // 3. item number

      // for the sake of simplicity, only handle english name for now

      wxString strURL(url);
      wxString itemNumber = strURL.Mid(7).AfterLast('/');

      LOG_INFO << "Loading Battle.Net Armory. Item: " << itemNumber.c_str();

      apiPage = wxT("https://wowmodelviewer.net/armory.php?item=");
      apiPage << itemNumber;

      break;
    }
  }

  LOG_INFO << "Final API Page: " << apiPage.c_str();

  QNetworkAccessManager networkManager;
  QUrl apiUrl(apiPage.c_str());
  QNetworkRequest request(apiUrl);
  request.setRawHeader("User-Agent", "WoWModelViewer");
  QNetworkReply *reply = networkManager.get(request);

  QEventLoop loop;
  connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
  connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), &loop, SLOT(quit()));
  loop.exec();

  QByteArray bts = reply->readAll();

  LOG_INFO << __FUNCTION__ << bts;

  wxJSONReader reader;
  return reader.Parse(bts.data(),&result);
}