本文整理汇总了C++中nsAString::Equals方法的典型用法代码示例。如果您正苦于以下问题:C++ nsAString::Equals方法的具体用法?C++ nsAString::Equals怎么用?C++ nsAString::Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsAString
的用法示例。
在下文中一共展示了nsAString::Equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
NS_IMETHODIMP
SpeechRecognition::GetUserMediaErrorCallback::OnError(const nsAString& aError)
{
SpeechRecognitionErrorCode errorCode;
if (aError.Equals(NS_LITERAL_STRING("PERMISSION_DENIED"))) {
errorCode = SpeechRecognitionErrorCode::Not_allowed;
} else {
errorCode = SpeechRecognitionErrorCode::Audio_capture;
}
mRecognition->DispatchError(SpeechRecognition::EVENT_AUDIO_ERROR, errorCode,
aError);
return NS_OK;
}
示例2:
/* void appendFilter (in AString title, in AString filter); */
NS_IMETHODIMP
nsFilePicker::AppendFilter(const nsAString & aTitle, const nsAString & aFilter)
{
if (aFilter.Equals(NS_LITERAL_STRING("..apps"))) {
// No platform specific thing we can do here, really....
return NS_OK;
}
nsCAutoString filter, name;
CopyUTF16toUTF8(aFilter, filter);
CopyUTF16toUTF8(aTitle, name);
mFilters.AppendCString(filter);
mFilterNames.AppendCString(name);
return NS_OK;
}
示例3: DispatchStateChangeEvent
NS_IMETHODIMP
PresentationConnection::NotifyStateChange(const nsAString& aSessionId,
uint16_t aState)
{
if (!aSessionId.Equals(mId)) {
return NS_ERROR_INVALID_ARG;
}
PresentationConnectionState state;
switch (aState) {
case nsIPresentationSessionListener::STATE_CONNECTED:
state = PresentationConnectionState::Connected;
break;
case nsIPresentationSessionListener::STATE_CLOSED:
state = PresentationConnectionState::Closed;
break;
case nsIPresentationSessionListener::STATE_TERMINATED:
state = PresentationConnectionState::Terminated;
break;
default:
NS_WARNING("Unknown presentation session state.");
return NS_ERROR_INVALID_ARG;
}
if (mState == state) {
return NS_OK;
}
mState = state;
// Unregister session listener if the session is no longer connected.
if (mState == PresentationConnectionState::Terminated) {
nsCOMPtr<nsIPresentationService> service =
do_GetService(PRESENTATION_SERVICE_CONTRACTID);
if (NS_WARN_IF(!service)) {
return NS_ERROR_NOT_AVAILABLE;
}
nsresult rv = service->UnregisterSessionListener(mId);
if(NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
}
return DispatchStateChangeEvent();
}
示例4: switch
NS_IMETHODIMP
PresentationConnection::NotifyStateChange(const nsAString& aSessionId,
uint16_t aState,
nsresult aReason)
{
if (!aSessionId.Equals(mId)) {
return NS_ERROR_INVALID_ARG;
}
PresentationConnectionState state;
switch (aState) {
case nsIPresentationSessionListener::STATE_CONNECTING:
state = PresentationConnectionState::Connecting;
break;
case nsIPresentationSessionListener::STATE_CONNECTED:
state = PresentationConnectionState::Connected;
break;
case nsIPresentationSessionListener::STATE_CLOSED:
state = PresentationConnectionState::Closed;
break;
case nsIPresentationSessionListener::STATE_TERMINATED:
state = PresentationConnectionState::Terminated;
break;
default:
NS_WARNING("Unknown presentation session state.");
return NS_ERROR_INVALID_ARG;
}
if (mState == state) {
return NS_OK;
}
mState = state;
nsresult rv = ProcessStateChanged(aReason);
if(NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
if (mOwningConnectionList) {
mOwningConnectionList->NotifyStateChange(aSessionId, this);
}
return NS_OK;
}
示例5: IsContentTypeEqual
static nsresult IsContentTypeEqual(nsAString &aGuid,
sbILibrary* aLibrary,
const nsAString &aContentType,
PRBool* aIsSame)
{
NS_ENSURE_ARG_POINTER(aLibrary);
NS_ENSURE_ARG_POINTER(aIsSame);
nsresult rv;
nsCOMPtr<sbIMediaItem> item;
rv = aLibrary->GetItemByGuid(aGuid, getter_AddRefs(item));
NS_ENSURE_SUCCESS(rv, rv);
nsString contentType;
rv = item->GetProperty(NS_LITERAL_STRING(SB_PROPERTY_CONTENTTYPE),
contentType);
NS_ENSURE_SUCCESS(rv, rv);
*aIsSame = aContentType.Equals(contentType);
return NS_OK;
}
示例6: SetPreference
NS_IMETHODIMP
sbIPDDevice::SetPreference(const nsAString& aPrefName,
nsIVariant* aPrefValue)
{
// Validate arguments.
NS_ENSURE_ARG_POINTER(aPrefValue);
// Function variables.
nsresult rv;
// If a preference needs to be set on the device, enqueue a set preference
// request. The internal, locally stored preference is still set here to
// provide immediate feedback.
if (aPrefName.Equals(SB_SYNC_PARTNER_PREF)) {
rv = ReqPushSetNamedValue(REQUEST_SET_PREF, aPrefName, aPrefValue);
NS_ENSURE_SUCCESS(rv, rv);
}
// Forward call to base class.
return sbBaseDevice::SetPreference(aPrefName, aPrefValue);
}
示例7: GetContextHelper
NS_IMETHODIMP
nsHTMLCanvasElement::MozGetIPCContext(const nsAString& aContextId,
nsISupports **aContext)
{
#ifdef MOZ_IPC
if(!nsContentUtils::IsCallerTrustedForRead()) {
// XXX ERRMSG we need to report an error to developers here! (bug 329026)
return NS_ERROR_DOM_SECURITY_ERR;
}
// We only support 2d shmem contexts for now.
if (!aContextId.Equals(NS_LITERAL_STRING("2d")))
return NS_ERROR_INVALID_ARG;
if (mCurrentContextId.IsEmpty()) {
nsresult rv = GetContextHelper(aContextId, false, getter_AddRefs(mCurrentContext));
NS_ENSURE_SUCCESS(rv, rv);
if (!mCurrentContext) {
return NS_OK;
}
mCurrentContext->SetIsIPC(true);
rv = UpdateContext();
NS_ENSURE_SUCCESS(rv, rv);
mCurrentContextId.Assign(aContextId);
} else if (!mCurrentContextId.Equals(aContextId)) {
//XXX eventually allow for more than one active context on a given canvas
return NS_ERROR_INVALID_ARG;
}
NS_ADDREF (*aContext = mCurrentContext);
return NS_OK;
#else
return NS_ERROR_NOT_IMPLEMENTED;
#endif
}
示例8: contractid
NS_IMETHODIMP
nsDOMScriptObjectFactory::GetScriptRuntime(const nsAString &aLanguageName,
nsIScriptRuntime **aLanguage)
{
// Note that many callers have optimized detection for JS (along with
// supporting various alternate names for JS), so don't call this.
// One exception is for the new "script-type" attribute on a node - and
// there is no need to support backwards compatible names.
// As JS is the default language, this is still rarely called for JS -
// only when a node explicitly sets JS - so that is done last.
nsCAutoString contractid(NS_LITERAL_CSTRING(
"@mozilla.org/script-language;1?script-type="));
// Arbitrarily use utf8 encoding should the name have extended chars
AppendUTF16toUTF8(aLanguageName, contractid);
nsresult rv;
nsCOMPtr<nsIScriptRuntime> lang =
do_GetService(contractid.get(), &rv);
if (NS_FAILED(rv)) {
if (aLanguageName.Equals(NS_LITERAL_STRING("application/javascript")))
return GetScriptRuntimeByID(nsIProgrammingLanguage::JAVASCRIPT, aLanguage);
// Not JS and nothing else we know about.
NS_WARNING("No script language registered for this mime-type");
return NS_ERROR_FACTORY_NOT_REGISTERED;
}
// And stash it away in our array for fast lookup by ID.
PRUint32 lang_ndx = NS_STID_INDEX(lang->GetScriptTypeID());
if (mLanguageArray[lang_ndx] == nsnull) {
mLanguageArray[lang_ndx] = lang;
} else {
// All languages are services - we should have an identical object!
NS_ASSERTION(mLanguageArray[lang_ndx] == lang,
"Got a different language for this ID???");
}
*aLanguage = lang;
NS_IF_ADDREF(*aLanguage);
return NS_OK;
}
示例9: SetRDFString
nsresult nsSceneTracker::SetRDFString (nsIRDFDataSource* aDS,
nsIRDFResource* aSource,
nsIRDFResource* aProp,
const nsAString& aString) {
NS_ENSURE_ARG(aDS);
NS_ENSURE_ARG(aSource);
NS_ENSURE_ARG(aProp);
nsCOMPtr<nsIRDFNode> tmpnode;
nsCOMPtr<nsIRDFService> rdfsvc = do_GetService(
"@mozilla.org/rdf/rdf-service;1");
nsCOMPtr<nsIRDFLiteral> newlit;
rdfsvc->GetLiteral(PromiseFlatString(aString).get(), getter_AddRefs(newlit));
nsresult rv = aDS->GetTarget(aSource, aProp, PR_TRUE,
getter_AddRefs(tmpnode));
if (NS_FAILED(rv))
return rv;
if (tmpnode) {
// Check if no change is needed
nsCOMPtr<nsIRDFLiteral> litval(do_QueryInterface(tmpnode));
if (litval) {
PRUnichar* result;
rv = litval->GetValue(&result);
if (NS_SUCCEEDED(rv)) {
if (aString.Equals(result)) {
PR_Free(result);
return NS_OK;
}
PR_Free(result);
}
}
rv = aDS->Change(aSource, aProp, tmpnode, newlit);
}
else if (! aString.IsEmpty()) {
rv = aDS->Assert(aSource, aProp, newlit, PR_TRUE);
}
return rv;
}
示例10: classStr
// Removes the value aRemoveValue from the string list of white-space separated
// values aValueList
void
ChangeStyleTransaction::RemoveValueFromListOfValues(
nsAString& aValues,
const nsAString& aRemoveValue)
{
nsAutoString classStr(aValues);
nsAutoString outString;
// put an extra null at the end
classStr.Append(kNullCh);
char16_t* start = classStr.BeginWriting();
char16_t* end = start;
while (kNullCh != *start) {
while (kNullCh != *start && nsCRT::IsAsciiSpace(*start)) {
// skip leading space
start++;
}
end = start;
while (kNullCh != *end && !nsCRT::IsAsciiSpace(*end)) {
// look for space or end
end++;
}
// end string here
*end = kNullCh;
if (start < end && !aRemoveValue.Equals(start)) {
outString.Append(start);
outString.Append(char16_t(' '));
}
start = ++end;
}
aValues.Assign(outString);
}
示例11: arena
nsresult
nsKeygenFormProcessor::GetPublicKey(const nsAString& aValue,
const nsAString& aChallenge,
const nsAFlatString& aKeyType,
nsAString& aOutPublicKey,
const nsAString& aKeyParams)
{
nsNSSShutDownPreventionLock locker;
if (isAlreadyShutDown()) {
return NS_ERROR_NOT_AVAILABLE;
}
nsresult rv = NS_ERROR_FAILURE;
char *keystring = nullptr;
char *keyparamsString = nullptr;
uint32_t keyGenMechanism;
PK11SlotInfo *slot = nullptr;
PK11RSAGenParams rsaParams;
SECOidTag algTag;
int keysize = 0;
void *params = nullptr;
SECKEYPrivateKey *privateKey = nullptr;
SECKEYPublicKey *publicKey = nullptr;
CERTSubjectPublicKeyInfo *spkInfo = nullptr;
SECStatus srv = SECFailure;
SECItem spkiItem;
SECItem pkacItem;
SECItem signedItem;
CERTPublicKeyAndChallenge pkac;
pkac.challenge.data = nullptr;
nsIGeneratingKeypairInfoDialogs * dialogs;
nsKeygenThread *KeygenRunnable = 0;
nsCOMPtr<nsIKeygenThread> runnable;
// permanent and sensitive flags for keygen
PK11AttrFlags attrFlags = PK11_ATTR_TOKEN | PK11_ATTR_SENSITIVE | PK11_ATTR_PRIVATE;
UniquePLArenaPool arena(PORT_NewArena(DER_DEFAULT_CHUNKSIZE));
if (!arena) {
goto loser;
}
// Get the key size //
for (size_t i = 0; i < number_of_key_size_choices; ++i) {
if (aValue.Equals(mSECKeySizeChoiceList[i].name)) {
keysize = mSECKeySizeChoiceList[i].size;
break;
}
}
if (!keysize) {
goto loser;
}
// Set the keygen mechanism
if (aKeyType.IsEmpty() || aKeyType.LowerCaseEqualsLiteral("rsa")) {
keyGenMechanism = CKM_RSA_PKCS_KEY_PAIR_GEN;
} else if (aKeyType.LowerCaseEqualsLiteral("ec")) {
keyparamsString = ToNewCString(aKeyParams);
if (!keyparamsString) {
rv = NS_ERROR_OUT_OF_MEMORY;
goto loser;
}
keyGenMechanism = CKM_EC_KEY_PAIR_GEN;
/* ecParams are initialized later */
} else {
goto loser;
}
// Get the slot
rv = GetSlot(keyGenMechanism, &slot);
if (NS_FAILED(rv)) {
goto loser;
}
switch (keyGenMechanism) {
case CKM_RSA_PKCS_KEY_PAIR_GEN:
rsaParams.keySizeInBits = keysize;
rsaParams.pe = DEFAULT_RSA_KEYGEN_PE;
algTag = DEFAULT_RSA_KEYGEN_ALG;
params = &rsaParams;
break;
case CKM_EC_KEY_PAIR_GEN:
/* XXX We ought to rethink how the KEYGEN tag is
* displayed. The pulldown selections presented
* to the user must depend on the keytype.
* The displayed selection could be picked
* from the keyparams attribute (this is currently called
* the pqg attribute).
* For now, we pick ecparams from the keyparams field
* if it specifies a valid supported curve, or else
* we pick one of secp384r1, secp256r1 or secp192r1
* respectively depending on the user's selection
* (High, Medium, Low).
* (RSA uses RSA-2048, RSA-1024 and RSA-512 for historical
* reasons, while ECC choices represent a stronger mapping)
* NOTE: The user's selection
* is silently ignored when a valid curve is presented
* in keyparams.
*/
if ((params = decode_ec_params(keyparamsString)) == nullptr) {
//.........这里部分代码省略.........
示例12: if
bool
nsTemplateCondition::CheckMatchStrings(const nsAString& aLeftString,
const nsAString& aRightString)
{
bool match = false;
if (aRightString.IsEmpty()) {
if ((mRelation == eEquals) && aLeftString.IsEmpty())
match = true;
}
else {
switch (mRelation) {
case eEquals:
if (mIgnoreCase)
match = aLeftString.Equals(aRightString,
nsCaseInsensitiveStringComparator());
else
match = aLeftString.Equals(aRightString);
break;
case eLess:
case eGreater:
{
// non-numbers always compare false
nsresult err;
PRInt32 leftint = PromiseFlatString(aLeftString).ToInteger(&err);
if (NS_SUCCEEDED(err)) {
PRInt32 rightint = PromiseFlatString(aRightString).ToInteger(&err);
if (NS_SUCCEEDED(err)) {
match = (mRelation == eLess) ? (leftint < rightint) :
(leftint > rightint);
}
}
break;
}
case eBefore:
{
nsICollation* collation = nsXULContentUtils::GetCollation();
if (collation) {
PRInt32 sortOrder;
collation->CompareString((mIgnoreCase ?
static_cast<PRInt32>(nsICollation::kCollationCaseInSensitive) :
static_cast<PRInt32>(nsICollation::kCollationCaseSensitive)),
aLeftString,
aRightString,
&sortOrder);
match = (sortOrder < 0);
}
else if (mIgnoreCase) {
match = (Compare(aLeftString, aRightString,
nsCaseInsensitiveStringComparator()) < 0);
}
else {
match = (Compare(aLeftString, aRightString) < 0);
}
break;
}
case eAfter:
{
nsICollation* collation = nsXULContentUtils::GetCollation();
if (collation) {
PRInt32 sortOrder;
collation->CompareString((mIgnoreCase ?
static_cast<PRInt32>(nsICollation::kCollationCaseInSensitive) :
static_cast<PRInt32>(nsICollation::kCollationCaseSensitive)),
aLeftString,
aRightString,
&sortOrder);
match = (sortOrder > 0);
}
else if (mIgnoreCase) {
match = (Compare(aLeftString, aRightString,
nsCaseInsensitiveStringComparator()) > 0);
}
else {
match = (Compare(aLeftString, aRightString) > 0);
}
break;
}
case eStartswith:
if (mIgnoreCase)
match = (StringBeginsWith(aLeftString, aRightString,
nsCaseInsensitiveStringComparator()));
else
match = (StringBeginsWith(aLeftString, aRightString));
break;
case eEndswith:
if (mIgnoreCase)
match = (StringEndsWith(aLeftString, aRightString,
nsCaseInsensitiveStringComparator()));
else
match = (StringEndsWith(aLeftString, aRightString));
break;
case eContains:
//.........这里部分代码省略.........
示例13: prefs
nsresult
nsMsgSearchAdapter::GetSearchCharsets(nsAString &srcCharset, nsAString &dstCharset)
{
nsresult rv;
if (m_defaultCharset.IsEmpty())
{
m_forceAsciiSearch = false; // set the default value in case of error
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIPrefLocalizedString> localizedstr;
rv = prefs->GetComplexValue("mailnews.view_default_charset", NS_GET_IID(nsIPrefLocalizedString),
getter_AddRefs(localizedstr));
if (NS_SUCCEEDED(rv))
localizedstr->GetData(getter_Copies(m_defaultCharset));
prefs->GetBoolPref("mailnews.force_ascii_search", &m_forceAsciiSearch);
}
}
srcCharset = m_defaultCharset.IsEmpty() ?
NS_LITERAL_STRING("ISO-8859-1") : m_defaultCharset;
if (m_scope)
{
// ### DMB is there a way to get the charset for the "window"?
nsCOMPtr<nsIMsgFolder> folder;
rv = m_scope->GetFolder(getter_AddRefs(folder));
// Ask the newsgroup/folder for its csid.
if (NS_SUCCEEDED(rv) && folder)
{
nsCString folderCharset;
folder->GetCharset(folderCharset);
dstCharset.Append(NS_ConvertASCIItoUTF16(folderCharset));
}
}
else
dstCharset.Assign(srcCharset);
// If
// the destination is still CS_DEFAULT, make the destination match
// the source. (CS_DEFAULT is an indication that the charset
// was undefined or unavailable.)
// ### well, it's not really anymore. Is there an equivalent?
if (dstCharset.Equals(m_defaultCharset))
{
dstCharset.Assign(srcCharset);
}
if (m_forceAsciiSearch)
{
// Special cases to use in order to force US-ASCII searching with Latin1
// or MacRoman text. Eurgh. This only has to happen because IMAP
// and Dredd servers currently (4/23/97) only support US-ASCII.
//
// If the dest csid is ISO Latin 1 or MacRoman, attempt to convert the
// source text to US-ASCII. (Not for now.)
// if ((dst_csid == CS_LATIN1) || (dst_csid == CS_MAC_ROMAN))
dstCharset.AssignLiteral("us-ascii");
}
return NS_OK;
}
示例14:
NS_IMETHODIMP
StaticAtom::ScriptableEquals(const nsAString& aString, bool* aResult)
{
*aResult = aString.Equals(nsDependentString(mString, mLength));
return NS_OK;
}
示例15: if
nsresult
nsKeygenFormProcessor::GetPublicKey(nsAString& aValue, nsAString& aChallenge,
nsAFlatString& aKeyType,
nsAString& aOutPublicKey, nsAString& aKeyParams)
{
nsNSSShutDownPreventionLock locker;
nsresult rv = NS_ERROR_FAILURE;
char *keystring = nsnull;
char *keyparamsString = nsnull, *str = nsnull;
KeyType type;
PRUint32 keyGenMechanism;
PRInt32 primeBits;
PK11SlotInfo *slot = nsnull;
PK11RSAGenParams rsaParams;
SECOidTag algTag;
int keysize = 0;
void *params;
SECKEYPrivateKey *privateKey = nsnull;
SECKEYPublicKey *publicKey = nsnull;
CERTSubjectPublicKeyInfo *spkInfo = nsnull;
PRArenaPool *arena = nsnull;
SECStatus sec_rv = SECFailure;
SECItem spkiItem;
SECItem pkacItem;
SECItem signedItem;
CERTPublicKeyAndChallenge pkac;
pkac.challenge.data = nsnull;
nsIGeneratingKeypairInfoDialogs * dialogs;
nsKeygenThread *KeygenRunnable = 0;
nsCOMPtr<nsIKeygenThread> runnable;
// Get the key size //
for (size_t i = 0; i < number_of_key_size_choices; ++i) {
if (aValue.Equals(mSECKeySizeChoiceList[i].name)) {
keysize = mSECKeySizeChoiceList[i].size;
break;
}
}
if (!keysize) {
goto loser;
}
arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
if (!arena) {
goto loser;
}
// Set the keygen mechanism
if (aKeyType.IsEmpty() || aKeyType.LowerCaseEqualsLiteral("rsa")) {
type = rsaKey;
keyGenMechanism = CKM_RSA_PKCS_KEY_PAIR_GEN;
} else if (aKeyType.LowerCaseEqualsLiteral("dsa")) {
char * end;
keyparamsString = ToNewCString(aKeyParams);
if (!keyparamsString) {
rv = NS_ERROR_OUT_OF_MEMORY;
goto loser;
}
type = dsaKey;
keyGenMechanism = CKM_DSA_KEY_PAIR_GEN;
if (strcmp(keyparamsString, "null") == 0)
goto loser;
str = keyparamsString;
PRBool found_match = PR_FALSE;
do {
end = strchr(str, ',');
if (end != nsnull)
*end = '\0';
primeBits = pqg_prime_bits(str);
if (keysize == primeBits) {
found_match = PR_TRUE;
break;
}
str = end + 1;
} while (end != nsnull);
if (!found_match) {
goto loser;
}
} else if (aKeyType.LowerCaseEqualsLiteral("ec")) {
keyparamsString = ToNewCString(aKeyParams);
if (!keyparamsString) {
rv = NS_ERROR_OUT_OF_MEMORY;
goto loser;
}
type = ecKey;
keyGenMechanism = CKM_EC_KEY_PAIR_GEN;
/* ecParams are initialized later */
} else {
goto loser;
}
// Get the slot
rv = GetSlot(keyGenMechanism, &slot);
if (NS_FAILED(rv)) {
goto loser;
}
switch (keyGenMechanism) {
case CKM_RSA_PKCS_KEY_PAIR_GEN:
//.........这里部分代码省略.........