bool nwxFileUtil::ShowFileFolder(const wxString &sFileName) { bool bRtn = true; wxString sURL("file:///"); if(wxDir::Exists(sFileName)) { sURL.Append(sFileName); } else { wxFileName fn(sFileName); bRtn = fn.FileExists() && fn.MakeAbsolute(); if(bRtn) { sURL.Append(fn.GetPath()); } } if(bRtn) { wxBusyCursor x; sURL.Replace(wxS("%"),wxS("%25")); sURL.Replace(wxS(" "),wxS("%20")); sURL.Replace(wxS("+"),wxS("%2b")); bRtn = wxLaunchDefaultBrowser(sURL); } return bRtn; }
void CHttpPoller::GetScript() { std::string sURL(m_url); std::vector<std::string> ExtraHeaders; std::string sResult; std::string auth; if (m_username.length() > 0 || m_password.length() > 0) { if (m_username.length() > 0) { auth += m_username; } auth += ":"; if (m_password.length() > 0) { auth += m_password; } std::string encodedAuth = base64_encode((const unsigned char *)auth.c_str(), auth.length()); ExtraHeaders.push_back("Authorization:Basic " + encodedAuth); } if (!HTTPClient::GET(sURL, ExtraHeaders, sResult)) { std::string err = "Http: Error getting data from url \"" + sURL + "\""; _log.Log(LOG_ERROR, err.c_str()); return; } // Got some data, send them to the lua parsers for processing CLuaHandler luaScript(m_HwdID); luaScript.executeLuaScript(m_script, sResult); }
//---------------------------------------------------------------------------- // STDMETHODIMP CAnchoBackgroundAPI::startBackgroundWindow(BSTR bsPartialURL) { // it's safe to call this method multiple times, anyhow the window // will be created only once if (m_BackgroundWindow) { return S_OK; } CStringW sURL(bsPartialURL); if (!GetURL(sURL)) { return E_FAIL; } // get the main api module and inject it into the background page CComPtr<IMagpieModuleRestricted> mainModule; IF_FAILED_RET(m_Magpie->GetModuleObject((LPOLESTR)s_AnchoMainAPIModuleID, &mainModule)); CComPtr<IDispatch> mainModuleExports; IF_FAILED_RET(mainModule->GetExportsObject(&mainModuleExports)); CComVariant vt; IF_FAILED_RET(mainModuleExports.GetPropertyByName(s_AnchoBackgroundPageAPIName, &vt)); if (vt.vt != VT_DISPATCH) { return E_FAIL; } IF_FAILED_RET(CBackgroundWindow::CreateBackgroundWindow(vt.pdispVal, sURL, &m_BackgroundWindow.p)); return S_OK; }