本文整理汇总了C++中SetURI函数的典型用法代码示例。如果您正苦于以下问题:C++ SetURI函数的具体用法?C++ SetURI怎么用?C++ SetURI使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetURI函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_QueryInterface
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);
}
}
示例2: on_call_state
/*
* 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);
}
}
示例3: SetVersion
bool TryConnectionRequest::Create(rude::CGI& cgi)
{
SetVersion(cgi["version"]);
SetDataEngine(cgi["engine"]);
SetURI(cgi["uri"]);
return true;
}
示例4: iter
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());
}
示例5: GetWritableURI
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;
}
示例6: GetURI
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);
}
示例7: hash
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);
}
示例8: GetWritableURI
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);
}
示例9: SetVersion
bool RegisterDataSourceRequest::Create(rude::CGI& cgi)
{
SetVersion(cgi["version"]);
SetName(cgi["name"]);
SetDataEngine(cgi["engine"]);
SetURI(cgi["uri"]);
return true;
}
示例10: docShell
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;
}
示例11: docShell
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;
}
示例12: hash
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);
}
示例13: GetWritableURI
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;
}
示例14: uri
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_;
}
示例15: uri
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;
}