nsFileChannel::nsFileChannel(nsIURI *uri) { // If we have a link file, we should resolve its target right away. // This is to protect against a same origin attack where the same link file // can point to different resources right after the first resource is loaded. nsCOMPtr<nsIFile> file; nsCOMPtr <nsIURI> targetURI; nsAutoCString fileTarget; nsCOMPtr<nsIFile> resolvedFile; bool symLink; nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(uri); if (fileURL && NS_SUCCEEDED(fileURL->GetFile(getter_AddRefs(file))) && NS_SUCCEEDED(file->IsSymlink(&symLink)) && symLink && NS_SUCCEEDED(file->GetNativeTarget(fileTarget)) && NS_SUCCEEDED(NS_NewNativeLocalFile(fileTarget, PR_TRUE, getter_AddRefs(resolvedFile))) && NS_SUCCEEDED(NS_NewFileURI(getter_AddRefs(targetURI), resolvedFile, nullptr))) { SetURI(targetURI); SetOriginalURI(uri); nsLoadFlags loadFlags = 0; GetLoadFlags(&loadFlags); SetLoadFlags(loadFlags | nsIChannel::LOAD_REPLACE); } else { SetURI(uri); } }
/* * Handler when invite state has changed. */ static void on_call_state (pjsua_call_id call_id, pjsip_event *e) { pjsua_call_info call_info; PJ_UNUSED_ARG (e); pjsua_call_get_info (call_id, &call_info); if (call_info.state == PJSIP_INV_STATE_DISCONNECTED) { g_current_call = PJSUA_INVALID_ID; SetURI (SIP_DST_URI, -1); SetAction (ID_MENU_CALL); //SetCallStatus(call_info.state_text.ptr, call_info.state_text.slen); SetCallStatus (call_info.last_status_text.ptr, call_info.last_status_text.slen); } else { //if (g_current_call == PJSUA_INVALID_ID) // g_current_call = call_id; if (call_info.remote_contact.slen) SetURI (call_info.remote_contact.ptr, call_info.remote_contact.slen, false); else SetURI (call_info.remote_info.ptr, call_info.remote_info.slen, false); if (call_info.state == PJSIP_INV_STATE_CONFIRMED) SetAction (ID_MENU_DISCONNECT); SetCallStatus (call_info.state_text.ptr, call_info.state_text.slen); } }
bool TryConnectionRequest::Create(rude::CGI& cgi) { SetVersion(cgi["version"]); SetDataEngine(cgi["engine"]); SetURI(cgi["uri"]); return true; }
void URLMainThread::SetProtocol(const nsAString& aProtocol, ErrorResult& aRv) { nsAString::const_iterator start, end; aProtocol.BeginReading(start); aProtocol.EndReading(end); nsAString::const_iterator iter(start); FindCharInReadable(':', iter, end); // Changing the protocol of a URL, changes the "nature" of the URI // implementation. In order to do this properly, we have to serialize the // existing URL and reparse it in a new object. nsCOMPtr<nsIURI> clone; nsresult rv = NS_MutateURI(GetURI()) .SetScheme(NS_ConvertUTF16toUTF8(Substring(start, iter))) .Finalize(clone); if (NS_WARN_IF(NS_FAILED(rv))) { return; } nsAutoCString href; rv = clone->GetSpec(href); if (NS_WARN_IF(NS_FAILED(rv))) { return; } nsCOMPtr<nsIURI> uri; rv = NS_NewURI(getter_AddRefs(uri), href); if (NS_WARN_IF(NS_FAILED(rv))) { return; } SetURI(uri.forget()); }
NS_IMETHODIMP nsLocation::SetPort(const nsAString& aPort) { if (!CallerSubsumes()) return NS_ERROR_DOM_SECURITY_ERR; nsCOMPtr<nsIURI> uri; nsresult rv = GetWritableURI(getter_AddRefs(uri)); if (uri) { // perhaps use nsReadingIterators at some point? NS_ConvertUTF16toUTF8 portStr(aPort); const char *buf = portStr.get(); int32_t port = -1; if (buf) { if (*buf == ':') { port = atol(buf+1); } else { port = atol(buf); } } rv = uri->SetPort(port); if (NS_SUCCEEDED(rv)) { SetURI(uri); } } return rv; }
void Location::SetSearch(const nsAString& aSearch, nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) { if (!CallerSubsumes(&aSubjectPrincipal)) { aRv.Throw(NS_ERROR_DOM_SECURITY_ERR); return; } nsCOMPtr<nsIURI> uri; aRv = GetURI(getter_AddRefs(uri)); nsCOMPtr<nsIURL> url(do_QueryInterface(uri)); if (NS_WARN_IF(aRv.Failed()) || !url) { return; } if (nsIDocument* doc = GetEntryDocument()) { aRv = NS_MutateURI(uri) .SetQueryWithEncoding(NS_ConvertUTF16toUTF8(aSearch), doc->GetDocumentCharacterSet()) .Finalize(uri); } else { aRv = NS_MutateURI(uri) .SetQuery(NS_ConvertUTF16toUTF8(aSearch)) .Finalize(uri); } if (NS_WARN_IF(aRv.Failed())) { return; } aRv = SetURI(uri); }
void Location::SetPathname(const nsAString& aPathname, nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) { if (!CallerSubsumes(&aSubjectPrincipal)) { aRv.Throw(NS_ERROR_DOM_SECURITY_ERR); return; } nsCOMPtr<nsIURI> uri; aRv = GetURI(getter_AddRefs(uri)); if (NS_WARN_IF(aRv.Failed()) || !uri) { return; } nsresult rv = NS_MutateURI(uri) .SetFilePath(NS_ConvertUTF16toUTF8(aPathname)) .Finalize(uri); if (NS_FAILED(rv)) { return; } aRv = SetURI(uri); }
void Location::SetHash(const nsAString& aHash, nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) { if (!CallerSubsumes(&aSubjectPrincipal)) { aRv.Throw(NS_ERROR_DOM_SECURITY_ERR); return; } NS_ConvertUTF16toUTF8 hash(aHash); if (hash.IsEmpty() || hash.First() != char16_t('#')) { hash.Insert(char16_t('#'), 0); } nsCOMPtr<nsIURI> uri; aRv = GetURI(getter_AddRefs(uri)); if (NS_WARN_IF(aRv.Failed()) || !uri) { return; } aRv = NS_MutateURI(uri) .SetRef(hash) .Finalize(uri); if (NS_WARN_IF(aRv.Failed()) || !uri) { return; } aRv = SetURI(uri); }
NS_IMETHODIMP Location::SetPort(const nsAString& aPort) { nsCOMPtr<nsIURI> uri; nsresult rv = GetWritableURI(getter_AddRefs(uri)); if (NS_WARN_IF(NS_FAILED(rv) || !uri)) { return rv; } // perhaps use nsReadingIterators at some point? NS_ConvertUTF16toUTF8 portStr(aPort); const char *buf = portStr.get(); int32_t port = -1; if (!portStr.IsEmpty() && buf) { if (*buf == ':') { port = atol(buf+1); } else { port = atol(buf); } } rv = uri->SetPort(port); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } return SetURI(uri); }
NS_IMETHODIMP Location::SetProtocol(const nsAString& aProtocol) { nsCOMPtr<nsIURI> uri; nsresult rv = GetWritableURI(getter_AddRefs(uri)); if (NS_WARN_IF(NS_FAILED(rv) || !uri)) { return rv; } rv = uri->SetScheme(NS_ConvertUTF16toUTF8(aProtocol)); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } nsAutoCString newSpec; rv = uri->GetSpec(newSpec); if (NS_FAILED(rv)) { return rv; } // We may want a new URI class for the new URI, so recreate it: rv = NS_NewURI(getter_AddRefs(uri), newSpec); if (NS_FAILED(rv)) { return rv; } return SetURI(uri); }
bool TorcPlayerInterface::HandleEvent(QEvent *Event) { TorcEvent* torcevent = dynamic_cast<TorcEvent*>(Event); if (!torcevent) return false; QVariantMap data = torcevent->Data(); int event = torcevent->GetEvent(); switch (event) { case Torc::Exit: if (m_standalone) { TorcReferenceCounter::EventLoopEnding(true); QCoreApplication::quit(); } break; case Torc::Suspending: case Torc::Hibernating: { TorcEvent e(Torc::Pause); m_pausedForSuspend = HandlePlayerEvent(&e); if (m_pausedForSuspend) LOG(VB_GENERAL, LOG_INFO, "Playback paused while suspending"); } break; case Torc::WokeUp: if (m_pausedForSuspend) { TorcEvent e(Torc::Unpause); HandlePlayerEvent(&e); LOG(VB_GENERAL, LOG_INFO, "Playback unpaused after suspension"); m_pausedForSuspend = false; } break; case Torc::ShuttingDown: case Torc::Restarting: { TorcEvent e(Torc::Stop); HandlePlayerEvent(&e); } break; case Torc::PlayMedia: if (data.contains("uri")) { bool paused = data.value("paused", false).toBool(); SetURI(data.value("uri").toString()); PlayMedia(paused); } break; case Torc::DisplayDeviceReset: // is this needed anymore? HandlePlayerEvent(Event); break; default: break; } return false; }
bool RegisterDataSourceRequest::Create(rude::CGI& cgi) { SetVersion(cgi["version"]); SetName(cgi["name"]); SetDataEngine(cgi["engine"]); SetURI(cgi["uri"]); return true; }
nsresult nsLocation::SetHrefWithBase(const nsAString& aHref, nsIURI* aBase, PRBool aReplace) { nsresult result; nsCOMPtr<nsIURI> newUri; nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell)); nsCAutoString docCharset; if (NS_SUCCEEDED(GetDocumentCharacterSetForURI(aHref, docCharset))) result = NS_NewURI(getter_AddRefs(newUri), aHref, docCharset.get(), aBase); else result = NS_NewURI(getter_AddRefs(newUri), aHref, nsnull, aBase); if (newUri) { /* Check with the scriptContext if it is currently processing a script tag. * If so, this must be a <script> tag with a location.href in it. * we want to do a replace load, in such a situation. * In other cases, for example if a event handler or a JS timer * had a location.href in it, we want to do a normal load, * so that the new url will be appended to Session History. * This solution is tricky. Hopefully it isn't going to bite * anywhere else. This is part of solution for bug # 39938, 72197 * */ PRBool inScriptTag=PR_FALSE; // Get JSContext from stack. nsCOMPtr<nsIJSContextStack> stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1", &result)); if (stack) { JSContext *cx; result = GetContextFromStack(stack, &cx); if (cx) { nsIScriptContext *scriptContext = nsJSUtils::GetDynamicScriptContext(cx); if (scriptContext) { if (scriptContext->GetProcessingScriptTag()) { // Now check to make sure that the script is running in our window, // since we only want to replace if the location is set by a // <script> tag in the same window. See bug 178729. nsCOMPtr<nsIScriptGlobalObject> ourGlobal(do_GetInterface(docShell)); inScriptTag = (ourGlobal == scriptContext->GetGlobalObject()); } } } //cx } // stack return SetURI(newUri, aReplace || inScriptTag); } return result; }
nsresult Location::SetHrefWithBase(const nsAString& aHref, nsIURI* aBase, bool aReplace) { nsresult result; nsCOMPtr<nsIURI> newUri; nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell)); nsAutoCString docCharset; if (NS_SUCCEEDED(GetDocumentCharacterSetForURI(aHref, docCharset))) result = NS_NewURI(getter_AddRefs(newUri), aHref, docCharset.get(), aBase); else result = NS_NewURI(getter_AddRefs(newUri), aHref, nullptr, aBase); if (newUri) { /* Check with the scriptContext if it is currently processing a script tag. * If so, this must be a <script> tag with a location.href in it. * we want to do a replace load, in such a situation. * In other cases, for example if a event handler or a JS timer * had a location.href in it, we want to do a normal load, * so that the new url will be appended to Session History. * This solution is tricky. Hopefully it isn't going to bite * anywhere else. This is part of solution for bug # 39938, 72197 * */ bool inScriptTag = false; nsIScriptContext* scriptContext = nullptr; nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(GetEntryGlobal()); if (win) { scriptContext = nsGlobalWindow::Cast(win)->GetContextInternal(); } if (scriptContext) { if (scriptContext->GetProcessingScriptTag()) { // Now check to make sure that the script is running in our window, // since we only want to replace if the location is set by a // <script> tag in the same window. See bug 178729. nsCOMPtr<nsIScriptGlobalObject> ourGlobal = docShell ? docShell->GetScriptGlobalObject() : nullptr; inScriptTag = (ourGlobal == scriptContext->GetGlobalObject()); } } return SetURI(newUri, aReplace || inScriptTag); } return result; }
NS_IMETHODIMP Location::SetHash(const nsAString& aHash) { NS_ConvertUTF16toUTF8 hash(aHash); if (hash.IsEmpty() || hash.First() != char16_t('#')) { hash.Insert(char16_t('#'), 0); } nsCOMPtr<nsIURI> uri; nsresult rv = GetWritableURI(getter_AddRefs(uri), &hash); if (NS_FAILED(rv) || !uri) { return rv; } return SetURI(uri); }
NS_IMETHODIMP nsLocation::SetProtocol(const nsAString& aProtocol) { nsCOMPtr<nsIURI> uri; nsresult rv = GetWritableURI(getter_AddRefs(uri)); if (uri) { rv = uri->SetScheme(NS_ConvertUTF16toUTF8(aProtocol)); if (NS_SUCCEEDED(rv)) { SetURI(uri); } } return rv; }
NS_IMETHODIMP Location::SetHostname(const nsAString& aHostname) { nsCOMPtr<nsIURI> uri; nsresult rv = GetWritableURI(getter_AddRefs(uri)); if (NS_WARN_IF(NS_FAILED(rv) || !uri)) { return rv; } rv = uri->SetHost(NS_ConvertUTF16toUTF8(aHostname)); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } return SetURI(uri); }
NS_IMETHODIMP Location::SetPathname(const nsAString& aPathname) { nsCOMPtr<nsIURI> uri; nsresult rv = GetWritableURI(getter_AddRefs(uri)); if (NS_WARN_IF(NS_FAILED(rv) || !uri)) { return rv; } nsCOMPtr<nsIURIWithQuery> url(do_QueryInterface(uri)); if (url && NS_SUCCEEDED(url->SetFilePath(NS_ConvertUTF16toUTF8(aPathname)))) { return SetURI(uri); } return NS_OK; }
NS_IMETHODIMP nsLocation::SetSearch(const nsAString& aSearch) { nsCOMPtr<nsIURI> uri; nsresult rv = GetWritableURI(getter_AddRefs(uri)); nsCOMPtr<nsIURL> url(do_QueryInterface(uri)); if (url) { rv = url->SetQuery(NS_ConvertUTF16toUTF8(aSearch)); if (NS_SUCCEEDED(rv)) { SetURI(uri); } } return rv; }
void* CoAP_RD_Resource::Create() { CoAP_Attr attr; std::string uri("rd"); SetURI(uri); attr.insert(std::make_pair("ct","40")); attr.insert(std::make_pair("rt","\"core.rd\"")); attr.insert(std::make_pair("ins","\"default\"")); SetAttr(attr); rd_resource_ = Create_i(); SetCoAPResource(rd_resource_); return rd_resource_; }
void* CoAPRDLookUpResResource::Create() { CoAP_Attr attr; std::string uri("rd-lookup/res"); SetURI(uri); attr.insert(std::make_pair("ct","40")); attr.insert(std::make_pair("rt","\"core.rd-lookup.res\"")); attr.insert(std::make_pair("ins","\"default\"")); SetAttr(attr); void* rd_resource = Create_i(); SetCoAPResource(rd_resource); return rd_resource; }
nsresult Location::SetSearchInternal(const nsAString& aSearch) { nsCOMPtr<nsIURI> uri; nsresult rv = GetWritableURI(getter_AddRefs(uri)); nsCOMPtr<nsIURL> url(do_QueryInterface(uri)); if (NS_WARN_IF(NS_FAILED(rv) || !url)) { return rv; } rv = url->SetQuery(NS_ConvertUTF16toUTF8(aSearch)); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } return SetURI(uri); }
NS_IMETHODIMP nsLocation::SetPathname(const nsAString& aPathname) { if (!CallerSubsumes()) return NS_ERROR_DOM_SECURITY_ERR; nsCOMPtr<nsIURI> uri; nsresult rv = GetWritableURI(getter_AddRefs(uri)); if (uri) { rv = uri->SetPath(NS_ConvertUTF16toUTF8(aPathname)); if (NS_SUCCEEDED(rv)) { SetURI(uri); } } return rv; }
nsresult nsLocation::SetHrefWithBase(const nsAString& aHref, nsIURI* aBase, bool aReplace) { nsresult result; nsCOMPtr<nsIURI> newUri; nsAutoCString docCharset; if (NS_SUCCEEDED(GetDocumentCharacterSetForURI(aHref, docCharset))) result = NS_NewURI(getter_AddRefs(newUri), aHref, docCharset.get(), aBase); else result = NS_NewURI(getter_AddRefs(newUri), aHref, nullptr, aBase); if (newUri) { return SetURI(newUri, aReplace); } return result; }
void URLMainThread::SetHref(const nsAString& aHref, ErrorResult& aRv) { NS_ConvertUTF16toUTF8 href(aHref); nsresult rv; nsCOMPtr<nsIIOService> ioService(do_GetService(NS_IOSERVICE_CONTRACTID, &rv)); if (NS_FAILED(rv)) { aRv.Throw(rv); return; } nsCOMPtr<nsIURI> uri; rv = ioService->NewURI(href, nullptr, nullptr, getter_AddRefs(uri)); if (NS_FAILED(rv)) { aRv.ThrowTypeError<MSG_INVALID_URL>(aHref); return; } SetURI(uri.forget()); UpdateURLSearchParams(); }
NS_IMETHODIMP nsLocation::SetHash(const nsAString& aHash) { nsCOMPtr<nsIURI> uri; nsresult rv = GetWritableURI(getter_AddRefs(uri)); if (NS_FAILED(rv) || !uri) { return rv; } NS_ConvertUTF16toUTF8 hash(aHash); if (hash.IsEmpty() || hash.First() != PRUnichar('#')) { hash.Insert(PRUnichar('#'), 0); } rv = uri->SetRef(hash); if (NS_SUCCEEDED(rv)) { SetURI(uri); } return rv; }
void Location::SetPort(const nsAString& aPort, nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) { if (!CallerSubsumes(&aSubjectPrincipal)) { aRv.Throw(NS_ERROR_DOM_SECURITY_ERR); return; } nsCOMPtr<nsIURI> uri; aRv = GetURI(getter_AddRefs(uri)); if (NS_WARN_IF(aRv.Failed() || !uri)) { return; } // perhaps use nsReadingIterators at some point? NS_ConvertUTF16toUTF8 portStr(aPort); const char *buf = portStr.get(); int32_t port = -1; if (!portStr.IsEmpty() && buf) { if (*buf == ':') { port = atol(buf+1); } else { port = atol(buf); } } aRv = NS_MutateURI(uri) .SetPort(port) .Finalize(uri); if (NS_WARN_IF(aRv.Failed())) { return; } aRv = SetURI(uri); }
/** * Handler when there is incoming call. */ static void on_incoming_call (pjsua_acc_id acc_id, pjsua_call_id call_id, pjsip_rx_data *rdata) { pjsua_call_info call_info; PJ_UNUSED_ARG (acc_id); PJ_UNUSED_ARG (rdata); if (g_current_call != PJSUA_INVALID_ID) { pj_str_t reason; reason = pj_str ("Another call is in progress"); pjsua_call_answer (call_id, PJSIP_SC_BUSY_HERE, &reason, NULL); return; } g_current_call = call_id; pjsua_call_get_info (call_id, &call_info); SetAction (ID_MENU_ANSWER); SetURI (call_info.remote_info.ptr, call_info.remote_info.slen, false); pjsua_call_answer (call_id, 200, NULL, NULL); }
nsNDNChannel::nsNDNChannel(nsIURI *aURI) { SetURI(aURI); }
static void OnCreate (HWND hWnd) { enum { X = 10, Y = 40, W = 220, H = 30, }; DWORD dwStyle; hMainWnd = hWnd; hwndCB = CommandBar_Create (hInst, hWnd, 1); CommandBar_InsertMenubar (hwndCB, hInst, IDM_MENU, 0); CommandBar_AddAdornments (hwndCB, 0, 0); // Create global status text dwStyle = WS_CHILD | WS_VISIBLE | WS_DISABLED | ES_LEFT; hwndGlobalStatus = CreateWindow ( TEXT ("EDIT"), // Class name NULL, // Window text dwStyle, // Window style X, // x-coordinate of the upper-left corner Y+0, // y-coordinate of the upper-left corner W, // Width of the window for the edit // control H-5, // Height of the window for the edit // control hWnd, // Window handle to the parent window (HMENU) ID_GLOBAL_STATUS, // Control identifier hInst, // Instance handle NULL); // Specify NULL for this parameter when // you create a control SetLocalURI (g_local_uri.ptr, g_local_uri.slen, false); // Create URI edit dwStyle = WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER; hwndURI = CreateWindow ( TEXT ("EDIT"), // Class name NULL, // Window text dwStyle, // Window style X, // x-coordinate of the upper-left corner Y+H, // y-coordinate of the upper-left corner W, // Width of the window for the edit // control H-5, // Height of the window for the edit // control hWnd, // Window handle to the parent window (HMENU) ID_URI, // Control identifier hInst, // Instance handle NULL); // Specify NULL for this parameter when // you create a control // Create action Button hwndActionButton = CreateWindow (L"button", L"Action", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, X, Y+2*H, 60, H-5, hWnd, (HMENU) ID_BTN_ACTION, hInst, NULL); // Create exit button hwndExitButton = CreateWindow (L"button", L"E&xit", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, X+70, Y+2*H, 60, H-5, hWnd, (HMENU) ID_EXIT, hInst, NULL); // Create call status edit dwStyle = WS_CHILD | WS_VISIBLE | WS_DISABLED; hwndCallStatus = CreateWindow ( TEXT ("EDIT"), // Class name NULL, // Window text dwStyle, // Window style X, // x-coordinate of the upper-left corner Y+3*H, // y-coordinate of the upper-left corner W, // Width of the window for the edit // control H-5, // Height of the window for the edit // control hWnd, // Window handle to the parent window (HMENU) ID_CALL_STATUS, // Control identifier hInst, // Instance handle NULL); // Specify NULL for this parameter when // you create a control SetCallStatus ("Ready", 5); SetAction (ID_MENU_CALL); SetURI (SIP_DST_URI, -1); SetFocus (hWnd); }