fixes bug 234916 "Remove global/static NS_NAMED_LITERAL_C?STRING usage [was: Firefox crashes on startup on Mac OS X]" r=jst sr=dbaron

This commit is contained in:
darin%meer.net 2004-02-25 02:08:34 +00:00
Родитель b8dd9a5164
Коммит 0616fb43c2
26 изменённых файлов: 584 добавлений и 630 удалений

Просмотреть файл

@ -2574,7 +2574,7 @@ nsScriptSecurityManager::CheckXPCPermissions(nsISupports* aObj,
// Method implementing nsIObserver //
/////////////////////////////////////
static const char sPrincipalPrefix[] = "capability.principal";
static NS_NAMED_LITERAL_CSTRING(sPolicyPrefix, "capability.policy.");
static const char sPolicyPrefix[] = "capability.policy.";
NS_IMETHODIMP
nsScriptSecurityManager::Observe(nsISupports* aObject, const char* aTopic,
@ -2591,7 +2591,7 @@ nsScriptSecurityManager::Observe(nsISupports* aObject, const char* aTopic,
#endif
)
JSEnabledPrefChanged(mSecurityPref);
if(PL_strncmp(message, sPolicyPrefix.get(), sPolicyPrefix.Length()) == 0)
if(PL_strncmp(message, sPolicyPrefix, sizeof(sPolicyPrefix)-1) == 0)
mPolicyPrefsChanged = PR_TRUE; // This will force re-initialization of the pref table
else if((PL_strncmp(message, sPrincipalPrefix, sizeof(sPrincipalPrefix)-1) == 0) &&
!mIsWritingPrefs)
@ -2811,7 +2811,8 @@ nsScriptSecurityManager::InitPolicies()
*policyCurrent = '\0';
policyCurrent++;
nsCAutoString sitesPrefName(sPolicyPrefix +
nsCAutoString sitesPrefName(
NS_LITERAL_CSTRING(sPolicyPrefix) +
nsDependentCString(nameBegin) +
NS_LITERAL_CSTRING(".sites"));
nsXPIDLCString domainList;
@ -2908,7 +2909,7 @@ nsScriptSecurityManager::InitDomainPolicy(JSContext* cx,
DomainPolicy* aDomainPolicy)
{
nsresult rv;
nsCAutoString policyPrefix(sPolicyPrefix +
nsCAutoString policyPrefix(NS_LITERAL_CSTRING(sPolicyPrefix) +
nsDependentCString(aPolicyName) +
NS_LITERAL_CSTRING("."));
PRUint32 prefixLength = policyPrefix.Length() - 1; // subtract the '.'
@ -3196,7 +3197,7 @@ nsScriptSecurityManager::InitPrefs()
char** prefNames;
// Set a callback for policy pref changes
prefBranchInternal->AddObserver(sPolicyPrefix.get(), this, PR_FALSE);
prefBranchInternal->AddObserver(sPolicyPrefix, this, PR_FALSE);
//-- Initialize the principals database from prefs
rv = mPrefBranch->GetChildList(sPrincipalPrefix, &prefCount, &prefNames);

Просмотреть файл

@ -51,8 +51,8 @@
} \
PR_END_MACRO
static NS_NAMED_LITERAL_CSTRING(kWellKnownLocation, "/w3c/p3p.xml");
static NS_NAMED_LITERAL_CSTRING(kW3C, "/w3c/");
static const char kWellKnownLocation[] = "/w3c/p3p.xml";
static const char kW3C[] = "/w3c/";
static nsresult
RequestSucceeded(nsIXMLHttpRequest* aRequest, PRBool* aReturn)
@ -186,7 +186,7 @@ nsPolicyReference::LoadPolicyReferenceFileFor(nsIURI* aURI,
if (!mDocument) {
nsXPIDLCString value;
mMainURI->GetPrePath(value);
value += kWellKnownLocation;
value += NS_LITERAL_CSTRING(kWellKnownLocation);
result = Load(value);
}
else {
@ -200,7 +200,7 @@ nsPolicyReference::LoadPolicyReferenceFileFor(nsIURI* aURI,
// well known location
nsXPIDLCString value;
mCurrentURI->GetPrePath(value);
value += kWellKnownLocation;
value += NS_LITERAL_CSTRING(kWellKnownLocation);
result = Load(value);
}
else if (mFlags & IS_LINKED_URI) {
@ -322,13 +322,13 @@ nsPolicyReference::ProcessPolicyReferenceFile(nsIDOMDocument* aDocument,
}
if (mFlags & IS_MAIN_URI) {
nsCOMPtr<nsIURI> tmpURI= mMainURI;
tmpURI->SetPath(kW3C);
tmpURI->SetPath(NS_LITERAL_CSTRING(kW3C));
result = NS_MakeAbsoluteURI(absURI, policyLocation, tmpURI);
NS_ENSURE_SUCCESS(result, result);
}
else {
// it is ok to do this because we won't be needing current uri beyond this.
mCurrentURI->SetPath(kW3C);
mCurrentURI->SetPath(NS_LITERAL_CSTRING(kW3C));
result = NS_MakeAbsoluteURI(absURI, policyLocation, mCurrentURI);
NS_ENSURE_SUCCESS(result, result);
}

Просмотреть файл

@ -505,13 +505,29 @@ static const nsModuleComponentInfo gComponents[] = {
}
};
void PR_CALLBACK
nsSOAPStrings *gSOAPStrings;
PR_STATIC_CALLBACK(nsresult)
nsWebServicesModuleConstructor(nsIModule* self)
{
NS_ASSERTION(gSOAPStrings == nsnull, "already initialized");
gSOAPStrings = new nsSOAPStrings();
if (!gSOAPStrings)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
PR_STATIC_CALLBACK(void)
nsWebServicesModuleDestructor(nsIModule* self)
{
nsSchemaAtoms::DestroySchemaAtoms();
nsWSDLAtoms::DestroyWSDLAtoms();
delete gSOAPStrings;
gSOAPStrings = nsnull;
}
NS_IMPL_NSGETMODULE_WITH_DTOR(nsWebServicesModule, gComponents,
nsWebServicesModuleDestructor)
NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(nsWebServicesModule, gComponents,
nsWebServicesModuleConstructor,
nsWebServicesModuleDestructor)

Просмотреть файл

@ -68,23 +68,6 @@
#define SERVICE_LISTED_PUBLIC (1 << 3)
#define HAS_MASTER_SERVICE_DECISION (1 << 4)
NS_NAMED_LITERAL_STRING(kNamespace2002, "http://www.mozilla.org/2002/soap/security");
// Element set
NS_NAMED_LITERAL_STRING(kWebScriptAccessTag, "webScriptAccess");
NS_NAMED_LITERAL_STRING(kDelegateTag, "delegate");
NS_NAMED_LITERAL_STRING(kAllowTag, "allow");
// Attribute set
NS_NAMED_LITERAL_STRING(kTypeAttr, "type");
NS_NAMED_LITERAL_STRING(kFromAttr, "from");
// Default attribute value
NS_NAMED_LITERAL_STRING(kAny, "any");
// Method name. Note: This method should be implemented by master services.
NS_NAMED_LITERAL_STRING(kIsServicePublic, "isServicePublic");
static PRBool PR_CALLBACK
FreeEntries(nsHashKey *aKey, void *aData, void* aClosure)
{
@ -95,9 +78,16 @@ FreeEntries(nsHashKey *aKey, void *aData, void* aClosure)
NS_IMPL_ISUPPORTS1(nsWebScriptsAccess,
nsIWebScriptsAccessService)
nsWebScriptsAccess::nsWebScriptsAccess()
: NS_LITERAL_STRING_INIT(kNamespace2002, "http://www.mozilla.org/2002/soap/security")
, NS_LITERAL_STRING_INIT(kWebScriptAccessTag, "webScriptAccess")
, NS_LITERAL_STRING_INIT(kDelegateTag, "delegate")
, NS_LITERAL_STRING_INIT(kAllowTag, "allow")
, NS_LITERAL_STRING_INIT(kTypeAttr, "type")
, NS_LITERAL_STRING_INIT(kFromAttr, "from")
, NS_LITERAL_STRING_INIT(kAny, "any")
, NS_LITERAL_STRING_INIT(kIsServicePublic, "isServicePublic")
{
}

Просмотреть файл

@ -114,6 +114,19 @@ protected:
nsCOMPtr<nsIScriptSecurityManager> mSecurityManager;
nsStringArray mMasterServices;
nsHashtable mAccessInfoTable;
const nsLiteralString kNamespace2002;
// Element set
const nsLiteralString kWebScriptAccessTag;
const nsLiteralString kDelegateTag;
const nsLiteralString kAllowTag;
// Attribute set
const nsLiteralString kTypeAttr;
const nsLiteralString kFromAttr;
// Default attribute value
const nsLiteralString kAny;
// Method name. Note: This method should be implemented by master services.
const nsLiteralString kIsServicePublic;
};
#endif

Просмотреть файл

@ -66,67 +66,6 @@
#include "nsIPropertyBag.h"
#include "nsSupportsArray.h"
static NS_NAMED_LITERAL_STRING(kEmpty, "");
static NS_NAMED_LITERAL_STRING(kNull, "null");
static NS_NAMED_LITERAL_STRING(kNil, "nil");
static NS_NAMED_LITERAL_STRING(kSOAPArrayTypeAttribute, "arrayType");
static NS_NAMED_LITERAL_STRING(kSOAPArrayOffsetAttribute, "offset");
static NS_NAMED_LITERAL_STRING(kSOAPArrayPositionAttribute, "position");
static NS_NAMED_LITERAL_STRING(kAnyTypeSchemaType, "anyType");
static NS_NAMED_LITERAL_STRING(kAnySimpleTypeSchemaType, "anySimpleType");
static NS_NAMED_LITERAL_STRING(kArraySOAPType, "Array");
static NS_NAMED_LITERAL_STRING(kStructSOAPType, "Struct");
static NS_NAMED_LITERAL_STRING(kStringSchemaType, "string");
static NS_NAMED_LITERAL_STRING(kBooleanSchemaType, "boolean");
static NS_NAMED_LITERAL_STRING(kFloatSchemaType, "float");
static NS_NAMED_LITERAL_STRING(kDoubleSchemaType, "double");
static NS_NAMED_LITERAL_STRING(kLongSchemaType, "long");
static NS_NAMED_LITERAL_STRING(kIntSchemaType, "int");
static NS_NAMED_LITERAL_STRING(kShortSchemaType, "short");
static NS_NAMED_LITERAL_STRING(kByteSchemaType, "byte");
static NS_NAMED_LITERAL_STRING(kUnsignedLongSchemaType, "unsignedLong");
static NS_NAMED_LITERAL_STRING(kUnsignedIntSchemaType, "unsignedInt");
static NS_NAMED_LITERAL_STRING(kUnsignedShortSchemaType, "unsignedShort");
static NS_NAMED_LITERAL_STRING(kUnsignedByteSchemaType, "unsignedByte");
static NS_NAMED_LITERAL_STRING(kDurationSchemaType, "duration");
static NS_NAMED_LITERAL_STRING(kDateTimeSchemaType, "dateTime");
static NS_NAMED_LITERAL_STRING(kTimeSchemaType, "time");
static NS_NAMED_LITERAL_STRING(kDateSchemaType, "date");
static NS_NAMED_LITERAL_STRING(kGYearMonthSchemaType, "gYearMonth");
static NS_NAMED_LITERAL_STRING(kGYearSchemaType, "gYear");
static NS_NAMED_LITERAL_STRING(kGMonthDaySchemaType, "gMonthDay");
static NS_NAMED_LITERAL_STRING(kGDaySchemaType, "gDay");
static NS_NAMED_LITERAL_STRING(kGMonthSchemaType, "gMonth");
static NS_NAMED_LITERAL_STRING(kHexBinarySchemaType, "hexBinary");
static NS_NAMED_LITERAL_STRING(kBase64BinarySchemaType, "base64Binary");
static NS_NAMED_LITERAL_STRING(kAnyURISchemaType, "anyURI");
static NS_NAMED_LITERAL_STRING(kQNameSchemaType, "QName");
static NS_NAMED_LITERAL_STRING(kNOTATIONSchemaType, "NOTATION");
static NS_NAMED_LITERAL_STRING(kNormalizedStringSchemaType, "normalizedString");
static NS_NAMED_LITERAL_STRING(kTokenSchemaType, "token");
static NS_NAMED_LITERAL_STRING(kLanguageSchemaType, "language");
static NS_NAMED_LITERAL_STRING(kNMTOKENSchemaType, "NMTOKEN");
static NS_NAMED_LITERAL_STRING(kNMTOKENSSchemaType, "NMTOKENS");
static NS_NAMED_LITERAL_STRING(kNameSchemaType, "Name");
static NS_NAMED_LITERAL_STRING(kNCNameSchemaType, "NCName");
static NS_NAMED_LITERAL_STRING(kIDSchemaType, "ID");
static NS_NAMED_LITERAL_STRING(kIDREFSchemaType, "IDREF");
static NS_NAMED_LITERAL_STRING(kIDREFSSchemaType, "IDREFS");
static NS_NAMED_LITERAL_STRING(kENTITYSchemaType, "ENTITY");
static NS_NAMED_LITERAL_STRING(kENTITIESSchemaType, "ENTITIES");
static NS_NAMED_LITERAL_STRING(kDecimalSchemaType, "decimal");
static NS_NAMED_LITERAL_STRING(kIntegerSchemaType, "integer");
static NS_NAMED_LITERAL_STRING(kNonPositiveIntegerSchemaType,
"nonPositiveInteger");
static NS_NAMED_LITERAL_STRING(kNegativeIntegerSchemaType, "negativeInteger");
static NS_NAMED_LITERAL_STRING(kNonNegativeIntegerSchemaType,
"nonNegativeInteger");
static NS_NAMED_LITERAL_STRING(kPositiveIntegerSchemaType, "positiveInteger");
#define MAX_ARRAY_DIMENSIONS 100
@ -180,13 +119,13 @@ ns##name##Encoder::~ns##name##Encoder() {}
{\
ns##name##Encoder *handler = new ns##name##Encoder(version);\
nsAutoString encodingKey;\
SOAPEncodingKey(uri, k##name##type##Type, encodingKey);\
SOAPEncodingKey(uri, gSOAPStrings->k##name##type##Type, encodingKey);\
SetEncoder(encodingKey, handler); \
SetDecoder(encodingKey, handler); \
}
#define REGISTER_SCHEMA_ENCODER(name) REGISTER_ENCODER(name,Schema,nsSOAPUtils::kXSURI)
#define REGISTER_SOAP_ENCODER(name) REGISTER_ENCODER(name,SOAP,nsSOAPUtils::kSOAPEncURI)
#define REGISTER_SCHEMA_ENCODER(name) REGISTER_ENCODER(name,Schema,gSOAPStrings->kXSURI)
#define REGISTER_SOAP_ENCODER(name) REGISTER_ENCODER(name,SOAP,gSOAPStrings->kSOAPEncURI)
#define REGISTER_ENCODERS \
{\
@ -219,13 +158,13 @@ NS_IMPL_ADDREF(nsDefaultSOAPEncoding_1_1)
NS_IMPL_RELEASE(nsDefaultSOAPEncoding_1_1)
nsDefaultSOAPEncoding_1_1::nsDefaultSOAPEncoding_1_1()
: nsSOAPEncoding(nsSOAPUtils::kSOAPEncURI11, nsnull, nsnull)
: nsSOAPEncoding(gSOAPStrings->kSOAPEncURI11, nsnull, nsnull)
{
PRUint16 version = nsISOAPMessage::VERSION_1_1;
PRBool result;
MapSchemaURI(nsSOAPUtils::kXSURI1999,nsSOAPUtils::kXSURI,PR_TRUE,&result);
MapSchemaURI(nsSOAPUtils::kXSIURI1999,nsSOAPUtils::kXSIURI,PR_TRUE,&result);
MapSchemaURI(nsSOAPUtils::kSOAPEncURI11,nsSOAPUtils::kSOAPEncURI,PR_TRUE,&result);
MapSchemaURI(gSOAPStrings->kXSURI1999,gSOAPStrings->kXSURI,PR_TRUE,&result);
MapSchemaURI(gSOAPStrings->kXSIURI1999,gSOAPStrings->kXSIURI,PR_TRUE,&result);
MapSchemaURI(gSOAPStrings->kSOAPEncURI11,gSOAPStrings->kSOAPEncURI,PR_TRUE,&result);
REGISTER_ENCODERS
}
@ -233,13 +172,13 @@ NS_IMPL_ADDREF(nsDefaultSOAPEncoding_1_2)
NS_IMPL_RELEASE(nsDefaultSOAPEncoding_1_2)
nsDefaultSOAPEncoding_1_2::nsDefaultSOAPEncoding_1_2()
: nsSOAPEncoding(nsSOAPUtils::kSOAPEncURI, nsnull, nsnull)
: nsSOAPEncoding(gSOAPStrings->kSOAPEncURI, nsnull, nsnull)
{
PRUint16 version = nsISOAPMessage::VERSION_1_2;
PRBool result;
MapSchemaURI(nsSOAPUtils::kXSURI1999,nsSOAPUtils::kXSURI,PR_FALSE,&result);
MapSchemaURI(nsSOAPUtils::kXSIURI1999,nsSOAPUtils::kXSIURI,PR_FALSE,&result);
MapSchemaURI(nsSOAPUtils::kSOAPEncURI11,nsSOAPUtils::kSOAPEncURI,PR_FALSE,&result);
MapSchemaURI(gSOAPStrings->kXSURI1999,gSOAPStrings->kXSURI,PR_FALSE,&result);
MapSchemaURI(gSOAPStrings->kXSIURI1999,gSOAPStrings->kXSIURI,PR_FALSE,&result);
MapSchemaURI(gSOAPStrings->kSOAPEncURI11,gSOAPStrings->kSOAPEncURI,PR_FALSE,&result);
REGISTER_ENCODERS
}
@ -309,155 +248,155 @@ static nsresult GetSupertype(nsISOAPEncoding * aEncoding, nsISchemaType* aType,
return NS_OK;
case nsISchemaBuiltinType::BUILTIN_TYPE_STRING:
// name = kAnySimpleTypeSchemaType;
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_NORMALIZED_STRING:
name = kStringSchemaType;
name = gSOAPStrings->kStringSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_TOKEN:
name = kNormalizedStringSchemaType;
name = gSOAPStrings->kNormalizedStringSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_BYTE:
name = kShortSchemaType;
name = gSOAPStrings->kShortSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_UNSIGNEDBYTE:
name = kUnsignedShortSchemaType;
name = gSOAPStrings->kUnsignedShortSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_BASE64BINARY:
// name = kAnySimpleTypeSchemaType;
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_HEXBINARY:
// name = kAnySimpleTypeSchemaType;
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_INTEGER:
name = kDecimalSchemaType;
name = gSOAPStrings->kDecimalSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_POSITIVEINTEGER:
name = kNonNegativeIntegerSchemaType;
name = gSOAPStrings->kNonNegativeIntegerSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_NEGATIVEINTEGER:
name = kNonPositiveIntegerSchemaType;
name = gSOAPStrings->kNonPositiveIntegerSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_NONNEGATIVEINTEGER:
name = kIntegerSchemaType;
name = gSOAPStrings->kIntegerSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_NONPOSITIVEINTEGER:
name = kIntegerSchemaType;
name = gSOAPStrings->kIntegerSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_INT:
name = kLongSchemaType;
name = gSOAPStrings->kLongSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_UNSIGNEDINT:
name = kUnsignedLongSchemaType;
name = gSOAPStrings->kUnsignedLongSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_LONG:
name = kIntegerSchemaType;
name = gSOAPStrings->kIntegerSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_UNSIGNEDLONG:
name = kNonNegativeIntegerSchemaType;
name = gSOAPStrings->kNonNegativeIntegerSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_SHORT:
name = kIntSchemaType;
name = gSOAPStrings->kIntSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_UNSIGNEDSHORT:
name = kUnsignedIntSchemaType;
name = gSOAPStrings->kUnsignedIntSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_DECIMAL:
// name = kAnySimpleTypeSchemaType;
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_FLOAT:
// name = kAnySimpleTypeSchemaType;
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_DOUBLE:
// name = kAnySimpleTypeSchemaType;
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_BOOLEAN:
// name = kAnySimpleTypeSchemaType;
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_TIME:
// name = kAnySimpleTypeSchemaType;
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_DATETIME:
// name = kAnySimpleTypeSchemaType;
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_DURATION:
// name = kAnySimpleTypeSchemaType;
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_DATE:
// name = kAnySimpleTypeSchemaType;
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_GMONTH:
// name = kAnySimpleTypeSchemaType;
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_GYEAR:
// name = kAnySimpleTypeSchemaType;
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_GYEARMONTH:
// name = kAnySimpleTypeSchemaType;
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_GDAY:
// name = kAnySimpleTypeSchemaType;
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_GMONTHDAY:
// name = kAnySimpleTypeSchemaType;
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_NAME:
// name = kAnySimpleTypeSchemaType;
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_QNAME:
// name = kAnySimpleTypeSchemaType;
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_NCNAME:
name = kNameSchemaType;
name = gSOAPStrings->kNameSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_ANYURI:
// name = kAnySimpleTypeSchemaType;
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_LANGUAGE:
name = kTokenSchemaType;
name = gSOAPStrings->kTokenSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_ID:
name = kNCNameSchemaType;
name = gSOAPStrings->kNCNameSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_IDREF:
name = kNCNameSchemaType;
name = gSOAPStrings->kNCNameSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_IDREFS:
name = kNormalizedStringSchemaType; // Really a list...
name = gSOAPStrings->kNormalizedStringSchemaType; // Really a list...
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_ENTITY:
name = kNCNameSchemaType;
name = gSOAPStrings->kNCNameSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_ENTITIES:
name = kNormalizedStringSchemaType; // Really a list...
name = gSOAPStrings->kNormalizedStringSchemaType; // Really a list...
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_NOTATION:
// name = kAnySimpleTypeSchemaType;
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_NMTOKEN:
name = kTokenSchemaType;
name = gSOAPStrings->kTokenSchemaType;
break;
case nsISchemaBuiltinType::BUILTIN_TYPE_NMTOKENS:
name = kNormalizedStringSchemaType; // Really a list...
name = gSOAPStrings->kNormalizedStringSchemaType; // Really a list...
break;
}
}
@ -469,11 +408,11 @@ static nsresult GetSupertype(nsISOAPEncoding * aEncoding, nsISchemaType* aType,
if (name.IsEmpty()) {
switch (typevalue) {
case nsISchemaType::SCHEMA_TYPE_COMPLEX:
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
break;
default:
// name = kAnySimpleTypeSchemaType;
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
}
}
nsCOMPtr<nsISchemaCollection> collection;
@ -481,7 +420,7 @@ static nsresult GetSupertype(nsISOAPEncoding * aEncoding, nsISchemaType* aType,
if (NS_FAILED(rc))
return rc;
rc = collection->GetType(name,
nsSOAPUtils::kXSURI,
gSOAPStrings->kXSURI,
getter_AddRefs(base));
// if (NS_FAILED(rc)) return rc;
}
@ -510,24 +449,24 @@ EncodeSimpleValue(nsISOAPEncoding * aEncoding,
if (NS_FAILED(rc))
return rc;
needType = (!typeName.IsEmpty() &&
!(typeName.Equals(kAnyTypeSchemaType) &&
typeNS.Equals(nsSOAPUtils::kXSURI)));
!(typeName.Equals(gSOAPStrings->kAnyTypeSchemaType) &&
typeNS.Equals(gSOAPStrings->kXSURI)));
}
nsAutoString name; // First choose the appropriate name and namespace for the element.
nsAutoString ns;
if (aName.IsEmpty()) { // We automatically choose appropriate element names where none exist.
ns = nsSOAPUtils::kSOAPEncURI;
ns = gSOAPStrings->kSOAPEncURI;
nsAutoString currentURI = ns;
nsCOMPtr<nsISchemaType>currentType = aSchemaType;
while (currentType
&& !(typeNS.Equals(nsSOAPUtils::kXSURI)
|| typeNS.Equals(nsSOAPUtils::kSOAPEncURI))) {
&& !(typeNS.Equals(gSOAPStrings->kXSURI)
|| typeNS.Equals(gSOAPStrings->kSOAPEncURI))) {
nsCOMPtr<nsISchemaType> supertype;
rc = GetSupertype(aEncoding, currentType, getter_AddRefs(supertype));
if (NS_FAILED(rc))
return rc;
if (!currentType) {
currentURI = nsSOAPUtils::kXSURI;
currentURI = gSOAPStrings->kXSURI;
break;
}
currentType = supertype;
@ -542,10 +481,10 @@ EncodeSimpleValue(nsISOAPEncoding * aEncoding,
needType = needType && (currentType != aSchemaType); // We may not need type
}
else {
name = kAnyTypeSchemaType;
name = gSOAPStrings->kAnyTypeSchemaType;
needType = PR_FALSE;
}
rc = aEncoding->GetExternalSchemaURI(nsSOAPUtils::kSOAPEncURI, ns);
rc = aEncoding->GetExternalSchemaURI(gSOAPStrings->kSOAPEncURI, ns);
}
else {
name = aName;
@ -571,13 +510,13 @@ EncodeSimpleValue(nsISOAPEncoding * aEncoding,
typeNS, type);
if (NS_FAILED(rc))
return rc;
type.Append(nsSOAPUtils::kQualifiedSeparator);
type.Append(gSOAPStrings->kQualifiedSeparator);
type.Append(typeName);
rc = aEncoding->GetExternalSchemaURI(nsSOAPUtils::kXSIURI, ns);
rc = aEncoding->GetExternalSchemaURI(gSOAPStrings->kXSIURI, ns);
if (NS_FAILED(rc))
return rc;
rc = (element)->
SetAttributeNS(ns, nsSOAPUtils::kXSITypeAttribute, type);
SetAttributeNS(ns, gSOAPStrings->kXSITypeAttribute, type);
if (NS_FAILED(rc))
return rc;
}
@ -634,17 +573,17 @@ NS_IMETHODIMP
if (aSource == nsnull) {
nsAutoString ns;
nsCOMPtr<nsIDOMElement> cloneable;
nsresult rc = aEncoding->GetExternalSchemaURI(nsSOAPUtils::kXSIURI, ns);
nsresult rc = aEncoding->GetExternalSchemaURI(gSOAPStrings->kXSIURI, ns);
if (NS_FAILED(rc))
return rc;
nsAutoString name;
if (!aName.IsEmpty())
name.Assign(kNull);
rc = EncodeSimpleValue(aEncoding, kEmpty, kEmpty,
name.Assign(gSOAPStrings->kNull);
rc = EncodeSimpleValue(aEncoding, gSOAPStrings->kEmpty, gSOAPStrings->kEmpty,
name, nsnull, aDestination, aReturnValue);
if (NS_FAILED(rc))
return rc;
rc = (*aReturnValue)->SetAttributeNS(ns, kNull, nsSOAPUtils::kTrueA);
rc = (*aReturnValue)->SetAttributeNS(ns, gSOAPStrings->kNull, gSOAPStrings->kTrueA);
if (NS_FAILED(rc))
return rc;
}
@ -677,8 +616,8 @@ NS_IMETHODIMP
}
if (!encoder) {
nsAutoString encodingKey;
SOAPEncodingKey(nsSOAPUtils::kXSURI,
kAnyTypeSchemaType, encodingKey);
SOAPEncodingKey(gSOAPStrings->kXSURI,
gSOAPStrings->kAnyTypeSchemaType, encodingKey);
nsresult rc =
aEncoding->GetEncoder(encodingKey, getter_AddRefs(encoder));
if (NS_FAILED(rc))
@ -694,7 +633,7 @@ NS_IMETHODIMP
static nsresult GetNativeType(PRUint16 aType, nsAString & aSchemaNamespaceURI, nsAString & aSchemaType)
{
aSchemaNamespaceURI.Assign(nsSOAPUtils::kXSURI);
aSchemaNamespaceURI.Assign(gSOAPStrings->kXSURI);
switch (aType) {
case nsIDataType::VTYPE_CHAR_STR:
case nsIDataType::VTYPE_WCHAR_STR:
@ -706,45 +645,45 @@ static nsresult GetNativeType(PRUint16 aType, nsAString & aSchemaNamespaceURI, n
case nsIDataType::VTYPE_DOMSTRING:
case nsIDataType::VTYPE_CSTRING:
case nsIDataType::VTYPE_UTF8STRING:
aSchemaType.Assign(kStringSchemaType);
aSchemaType.Assign(gSOAPStrings->kStringSchemaType);
break;
case nsIDataType::VTYPE_INT8:
aSchemaType.Assign(kByteSchemaType);
aSchemaType.Assign(gSOAPStrings->kByteSchemaType);
break;
case nsIDataType::VTYPE_INT16:
aSchemaType.Assign(kShortSchemaType);
aSchemaType.Assign(gSOAPStrings->kShortSchemaType);
break;
case nsIDataType::VTYPE_INT32:
aSchemaType.Assign(kIntSchemaType);
aSchemaType.Assign(gSOAPStrings->kIntSchemaType);
break;
case nsIDataType::VTYPE_INT64:
aSchemaType.Assign(kLongSchemaType);
aSchemaType.Assign(gSOAPStrings->kLongSchemaType);
break;
case nsIDataType::VTYPE_UINT8:
aSchemaType.Assign(kUnsignedByteSchemaType);
aSchemaType.Assign(gSOAPStrings->kUnsignedByteSchemaType);
break;
case nsIDataType::VTYPE_UINT16:
aSchemaType.Assign(kUnsignedShortSchemaType);
aSchemaType.Assign(gSOAPStrings->kUnsignedShortSchemaType);
break;
case nsIDataType::VTYPE_UINT32:
aSchemaType.Assign(kUnsignedIntSchemaType);
aSchemaType.Assign(gSOAPStrings->kUnsignedIntSchemaType);
break;
case nsIDataType::VTYPE_UINT64:
aSchemaType.Assign(kUnsignedLongSchemaType);
aSchemaType.Assign(gSOAPStrings->kUnsignedLongSchemaType);
break;
case nsIDataType::VTYPE_FLOAT:
aSchemaType.Assign(kFloatSchemaType);
aSchemaType.Assign(gSOAPStrings->kFloatSchemaType);
break;
case nsIDataType::VTYPE_DOUBLE:
aSchemaType.Assign(kDoubleSchemaType);
aSchemaType.Assign(gSOAPStrings->kDoubleSchemaType);
break;
case nsIDataType::VTYPE_BOOL:
aSchemaType.Assign(kBooleanSchemaType);
aSchemaType.Assign(gSOAPStrings->kBooleanSchemaType);
break;
case nsIDataType::VTYPE_ARRAY:
case nsIDataType::VTYPE_EMPTY_ARRAY:
aSchemaType.Assign(kArraySOAPType);
aSchemaNamespaceURI.Assign(nsSOAPUtils::kSOAPEncURI);
aSchemaType.Assign(gSOAPStrings->kArraySOAPType);
aSchemaNamespaceURI.Assign(gSOAPStrings->kSOAPEncURI);
break;
// case nsIDataType::VTYPE_VOID:
// case nsIDataType::VTYPE_EMPTY:
@ -752,11 +691,11 @@ static nsresult GetNativeType(PRUint16 aType, nsAString & aSchemaNamespaceURI, n
break;
case nsIDataType::VTYPE_INTERFACE_IS:
case nsIDataType::VTYPE_INTERFACE:
aSchemaType.Assign(kStructSOAPType);
aSchemaNamespaceURI.Assign(nsSOAPUtils::kSOAPEncURI);
aSchemaType.Assign(gSOAPStrings->kStructSOAPType);
aSchemaNamespaceURI.Assign(gSOAPStrings->kSOAPEncURI);
break;
default:
aSchemaType.Assign(kAnySimpleTypeSchemaType);
aSchemaType.Assign(gSOAPStrings->kAnySimpleTypeSchemaType);
}
return NS_OK;
}
@ -800,12 +739,12 @@ NS_IMETHODIMP
}
}
if (simple) {
nativeSchemaType.Assign(kAnySimpleTypeSchemaType);
nativeSchemaURI.Assign(nsSOAPUtils::kXSURI);
nativeSchemaType.Assign(gSOAPStrings->kAnySimpleTypeSchemaType);
nativeSchemaURI.Assign(gSOAPStrings->kXSURI);
}
else {
nativeSchemaType.Assign(kStructSOAPType);
nativeSchemaURI.Assign(nsSOAPUtils::kSOAPEncURI);
nativeSchemaType.Assign(gSOAPStrings->kStructSOAPType);
nativeSchemaURI.Assign(gSOAPStrings->kSOAPEncURI);
}
}
else {
@ -890,7 +829,7 @@ static nsresult EncodeStructParticle(nsISOAPEncoding* aEncoding, nsIPropertyBag*
rc = aPropertyBag->GetProperty(name, getter_AddRefs(value));
if (!NS_FAILED(rc)) {
nsCOMPtr<nsIDOMElement> dummy;
rc = aEncoding->Encode(value, kEmpty, name, type, aAttachments, aDestination, getter_AddRefs(dummy));
rc = aEncoding->Encode(value, gSOAPStrings->kEmpty, name, type, aAttachments, aDestination, getter_AddRefs(dummy));
if (NS_FAILED(rc))
return rc;
}
@ -967,7 +906,7 @@ static nsresult EncodeStructParticle(nsISOAPEncoding* aEncoding, nsIPropertyBag*
if (NS_FAILED(rc))
return rc;
nsCOMPtr<nsIDOMElement>result;
rc = aEncoding->Encode(value,kEmpty,name,nsnull,aAttachments,aDestination,getter_AddRefs(result));
rc = aEncoding->Encode(value,gSOAPStrings->kEmpty,name,nsnull,aAttachments,aDestination,getter_AddRefs(result));
if (NS_FAILED(rc))
return rc;
rc = e->HasMoreElements(&more);
@ -1011,13 +950,14 @@ NS_IMETHODIMP
}
// We still have to fake this one, because there is no struct type in schema.
if (aName.IsEmpty() && !aSchemaType) {
rc = EncodeSimpleValue(aEncoding, kEmpty,
nsSOAPUtils::kSOAPEncURI, kStructSOAPType,
rc = EncodeSimpleValue(aEncoding, gSOAPStrings->kEmpty,
gSOAPStrings->kSOAPEncURI,
gSOAPStrings->kStructSOAPType,
aSchemaType, aDestination,
aReturnValue);
}
else {
rc = EncodeSimpleValue(aEncoding, kEmpty,
rc = EncodeSimpleValue(aEncoding, gSOAPStrings->kEmpty,
aNamespaceURI, aName, aSchemaType, aDestination,
aReturnValue);
}
@ -1055,8 +995,8 @@ NS_IMETHODIMP
if (aName.IsEmpty() && !aSchemaType) {
return EncodeSimpleValue(aEncoding,
value,
nsSOAPUtils::kSOAPEncURI,
kAnySimpleTypeSchemaType,
gSOAPStrings->kSOAPEncURI,
gSOAPStrings->kAnySimpleTypeSchemaType,
aSchemaType,
aDestination,
aReturnValue);
@ -1201,14 +1141,14 @@ static nsresult EncodeArray(nsISOAPEncoding* aEncoding, nsIVariant* aSource, nsI
if (count) {
nsAutoString ns;
nsCOMPtr<nsIDOMElement> cloneable;
rc = aEncoding->GetExternalSchemaURI(nsSOAPUtils::kXSIURI, ns);
rc = aEncoding->GetExternalSchemaURI(gSOAPStrings->kXSIURI, ns);
if (NS_FAILED(rc))
return rc;
rc = EncodeSimpleValue(aEncoding, kEmpty, kEmpty,
kNull, nsnull, aArray, getter_AddRefs(cloneable));
rc = EncodeSimpleValue(aEncoding, gSOAPStrings->kEmpty, gSOAPStrings->kEmpty,
gSOAPStrings->kNull, nsnull, aArray, getter_AddRefs(cloneable));
if (NS_FAILED(rc))
return rc;
rc = cloneable->SetAttributeNS(ns, kNull, nsSOAPUtils::kTrueA);
rc = cloneable->SetAttributeNS(ns, gSOAPStrings->kNull, gSOAPStrings->kTrueA);
if (NS_FAILED(rc))
return rc;
nsCOMPtr<nsIDOMNode> clone;
@ -1243,8 +1183,8 @@ static nsresult EncodeArray(nsISOAPEncoding* aEncoding, nsIVariant* aSource, nsI
if (NS_FAILED(rc))\
break;\
rc = aEncoding->Encode(p,\
kEmpty,\
kEmpty,\
gSOAPStrings->kEmpty,\
gSOAPStrings->kEmpty,\
aSchemaType,\
aAttachments,\
aArray,\
@ -1321,8 +1261,8 @@ static nsresult EncodeArray(nsISOAPEncoding* aEncoding, nsIVariant* aSource, nsI
if (iid.Equals(NS_GET_IID(nsIVariant))) { // Only do variants for now.
for (i = 0; i < count; i++) {
rc = aEncoding->Encode(values[i],
kEmpty,
kEmpty,
gSOAPStrings->kEmpty,
gSOAPStrings->kEmpty,
aSchemaType,
aAttachments,
aArray,
@ -1341,8 +1281,8 @@ static nsresult EncodeArray(nsISOAPEncoding* aEncoding, nsIVariant* aSource, nsI
if (NS_FAILED(rc))
break;
rc = aEncoding->Encode(p,
kEmpty,
kEmpty,
gSOAPStrings->kEmpty,
gSOAPStrings->kEmpty,
aSchemaType,
aAttachments,
aArray,
@ -1430,8 +1370,8 @@ NS_IMETHODIMP
switch (arrayNativeType) {
case nsIDataType::VTYPE_INTERFACE: // In a variant, an interface is a struct, but here it is any
case nsIDataType::VTYPE_INTERFACE_IS:
arrayTypeSchemaName = kAnyTypeSchemaType;
arrayTypeSchemaURI = nsSOAPUtils::kXSURI;
arrayTypeSchemaName = gSOAPStrings->kAnyTypeSchemaType;
arrayTypeSchemaURI = gSOAPStrings->kXSURI;
break;
default: // Everything else can be interpreted correctly
rc = GetNativeType(arrayNativeType, arrayTypeSchemaURI, arrayTypeSchemaName);
@ -1456,7 +1396,7 @@ NS_IMETHODIMP
if (NS_FAILED(rc))
return rc;
}
rc = EncodeSimpleValue(aEncoding, kEmpty,
rc = EncodeSimpleValue(aEncoding, gSOAPStrings->kEmpty,
aNamespaceURI,
aName, aSchemaType, aDestination, aReturnValue);
if (NS_FAILED(rc))
@ -1467,7 +1407,7 @@ NS_IMETHODIMP
{
nsAutoString value;
nsSOAPUtils::MakeNamespacePrefix(aEncoding,*aReturnValue,arrayTypeSchemaURI,value);
value.Append(nsSOAPUtils::kQualifiedSeparator);
value.Append(gSOAPStrings->kQualifiedSeparator);
value.Append(arrayTypeSchemaName);
value.Append(NS_LITERAL_STRING("["));
for (i = 0; i < dimensionCount; i++) {
@ -1479,11 +1419,11 @@ NS_IMETHODIMP
}
value.Append(NS_LITERAL_STRING("]"));
nsAutoString encURI;
rc = aEncoding->GetExternalSchemaURI(nsSOAPUtils::kSOAPEncURI,encURI);
rc = aEncoding->GetExternalSchemaURI(gSOAPStrings->kSOAPEncURI,encURI);
if (NS_FAILED(rc))
return rc;
rc = (*aReturnValue)->SetAttributeNS(encURI, kSOAPArrayTypeAttribute, value);
rc = (*aReturnValue)->SetAttributeNS(encURI, gSOAPStrings->kSOAPArrayTypeAttribute, value);
if (NS_FAILED(rc))
return rc;
}
@ -1544,7 +1484,7 @@ NS_IMETHODIMP
rc = aSource->GetAsBool(&b);
if (NS_FAILED(rc))
return rc;
return EncodeSimpleValue(aEncoding, b ? nsSOAPUtils::kTrueA : nsSOAPUtils::kFalseA,
return EncodeSimpleValue(aEncoding, b ? gSOAPStrings->kTrueA : gSOAPStrings->kFalseA,
aNamespaceURI, aName, aSchemaType, aDestination,
aReturnValue);
}
@ -1906,8 +1846,8 @@ NS_IMETHODIMP
nsCOMPtr < nsIDOMAttr > enc;
nsresult rv =
aSource->
GetAttributeNodeNS(*nsSOAPUtils::kSOAPEnvURI[mSOAPVersion],
nsSOAPUtils::kEncodingStyleAttribute,
GetAttributeNodeNS(*gSOAPStrings->kSOAPEnvURI[mSOAPVersion],
gSOAPStrings->kEncodingStyleAttribute,
getter_AddRefs(enc));
if (NS_FAILED(rv))
return rv;
@ -1936,14 +1876,14 @@ NS_IMETHODIMP
// Handle xsi:null="true"
nsAutoString nullstr;
if (nsSOAPUtils::GetAttribute(aEncoding, aSource, nsSOAPUtils::kXSIURI, kNull, nullstr)) {
if (nullstr.Equals(nsSOAPUtils::kTrue)
|| nullstr.Equals(nsSOAPUtils::kTrueA)) {
if (nsSOAPUtils::GetAttribute(aEncoding, aSource, gSOAPStrings->kXSIURI, gSOAPStrings->kNull, nullstr)) {
if (nullstr.Equals(gSOAPStrings->kTrue)
|| nullstr.Equals(gSOAPStrings->kTrueA)) {
*_retval = nsnull;
return NS_OK;
}
else if (!(nullstr.Equals(nsSOAPUtils::kFalse)
|| nullstr.Equals(nsSOAPUtils::kFalseA)))
else if (!(nullstr.Equals(gSOAPStrings->kFalse)
|| nullstr.Equals(gSOAPStrings->kFalseA)))
return SOAP_EXCEPTION(NS_ERROR_ILLEGAL_VALUE,"SOAP_NILL_VALUE","The value of the nill attribute must be true or false.");
}
@ -1980,13 +1920,13 @@ NS_IMETHODIMP
rc = aEncoding->GetInternalSchemaURI(ns, internal);
if (NS_FAILED(rc))
return rc;
if (internal.Equals(nsSOAPUtils::kSOAPEncURI)) { // Last-ditch hack to get undeclared types from SOAP namespace
if (name.Equals(kArraySOAPType)
|| name.Equals(kStructSOAPType)) { // This should not be needed if schema has these declarations
if (internal.Equals(gSOAPStrings->kSOAPEncURI)) { // Last-ditch hack to get undeclared types from SOAP namespace
if (name.Equals(gSOAPStrings->kArraySOAPType)
|| name.Equals(gSOAPStrings->kStructSOAPType)) { // This should not be needed if schema has these declarations
rc = collection->GetType(name, internal, getter_AddRefs(subType));
} else {
rc = collection->GetType(name,
nsSOAPUtils::kXSURI,
gSOAPStrings->kXSURI,
getter_AddRefs(subType));
}
}
@ -1997,8 +1937,8 @@ NS_IMETHODIMP
nsCOMPtr < nsISchemaType > subsubType;
nsAutoString explicitType;
if (nsSOAPUtils::GetAttribute(aEncoding, aSource, nsSOAPUtils::kXSIURI,
nsSOAPUtils::kXSITypeAttribute,
if (nsSOAPUtils::GetAttribute(aEncoding, aSource, gSOAPStrings->kXSIURI,
gSOAPStrings->kXSITypeAttribute,
explicitType)) {
rc = nsSOAPUtils::GetNamespaceURI(aEncoding, aSource, explicitType, ns);
if (NS_FAILED(rc))
@ -2069,11 +2009,11 @@ NS_IMETHODIMP
}
nsAutoString decodingKey;
if (!simple) {
SOAPEncodingKey(nsSOAPUtils::kSOAPEncURI,
kStructSOAPType, decodingKey);
SOAPEncodingKey(gSOAPStrings->kSOAPEncURI,
gSOAPStrings->kStructSOAPType, decodingKey);
} else {
SOAPEncodingKey(nsSOAPUtils::kXSURI,
kAnySimpleTypeSchemaType, decodingKey);
SOAPEncodingKey(gSOAPStrings->kXSURI,
gSOAPStrings->kAnySimpleTypeSchemaType, decodingKey);
}
nsresult rc =
aEncoding->GetDecoder(decodingKey, getter_AddRefs(decoder));
@ -2111,11 +2051,11 @@ NS_IMETHODIMP
}
nsAutoString decodingKey;
if (!simple) {
SOAPEncodingKey(nsSOAPUtils::kSOAPEncURI,
kStructSOAPType, decodingKey);
SOAPEncodingKey(gSOAPStrings->kSOAPEncURI,
gSOAPStrings->kStructSOAPType, decodingKey);
} else {
SOAPEncodingKey(nsSOAPUtils::kXSURI,
kAnySimpleTypeSchemaType, decodingKey);
SOAPEncodingKey(gSOAPStrings->kXSURI,
gSOAPStrings->kAnySimpleTypeSchemaType, decodingKey);
}
nsCOMPtr < nsISOAPDecoder > decoder;
nsresult rc =
@ -2653,8 +2593,8 @@ NS_IMETHODIMP
return rc;
}
}
if (nsSOAPUtils::GetAttribute(aEncoding, aSource, nsSOAPUtils::kSOAPEncURI,
kSOAPArrayTypeAttribute, value)) {
if (nsSOAPUtils::GetAttribute(aEncoding, aSource, gSOAPStrings->kSOAPEncURI,
gSOAPStrings->kSOAPArrayTypeAttribute, value)) {
nsAutoString dst;
PRUint32 n = DecodeArrayDimensions(value, dimensionSizes, dst);
if (n > 0) {
@ -2695,8 +2635,8 @@ NS_IMETHODIMP
if (NS_FAILED(rc))
return rc;
if (value.Last() ==']') {
ns.Assign(nsSOAPUtils::kSOAPEncURI);
name.Assign(kArraySOAPType);
ns.Assign(gSOAPStrings->kSOAPEncURI);
name.Assign(gSOAPStrings->kArraySOAPType);
}
else {
rc = nsSOAPUtils::GetNamespaceURI(aEncoding, aSource, value, ns);
@ -2733,8 +2673,8 @@ NS_IMETHODIMP
}
}
PRUint32 offset; // Computing offset trickier, because size may be unspecified.
if (nsSOAPUtils::GetAttribute(aEncoding, aSource, nsSOAPUtils::kSOAPEncURI,
kSOAPArrayOffsetAttribute, value)) {
if (nsSOAPUtils::GetAttribute(aEncoding, aSource, gSOAPStrings->kSOAPEncURI,
gSOAPStrings->kSOAPArrayOffsetAttribute, value)) {
PRInt32 pos[MAX_ARRAY_DIMENSIONS];
nsAutoString leftover;
offset = DecodeArrayDimensions(value, pos, leftover);
@ -2795,8 +2735,8 @@ NS_IMETHODIMP
PRInt32 next = offset;
while (child) {
nsAutoString pos;
if (nsSOAPUtils::GetAttribute(aEncoding, aSource, nsSOAPUtils::kSOAPEncURI,
kSOAPArrayPositionAttribute, pos)) {
if (nsSOAPUtils::GetAttribute(aEncoding, aSource, gSOAPStrings->kSOAPEncURI,
gSOAPStrings->kSOAPArrayPositionAttribute, pos)) {
nsAutoString leftover;
PRInt32 inc[MAX_ARRAY_DIMENSIONS];
i = DecodeArrayDimensions(pos, inc, leftover);
@ -2864,8 +2804,8 @@ NS_IMETHODIMP
while (child) {\
nsAutoString pos;\
PRInt32 p;\
if (nsSOAPUtils::GetAttribute(aEncoding, aSource, nsSOAPUtils::kSOAPEncURI,\
kSOAPArrayPositionAttribute, pos)) {\
if (nsSOAPUtils::GetAttribute(aEncoding, aSource, gSOAPStrings->kSOAPEncURI,\
gSOAPStrings->kSOAPArrayPositionAttribute, pos)) {\
p = DecodeArrayPosition(pos, dimensionCount, dimensionSizes);\
if (p == -1) {\
rc = NS_ERROR_ILLEGAL_VALUE;\
@ -2905,31 +2845,31 @@ NS_IMETHODIMP
if (NS_FAILED(rc))
return rc;
PRBool unhandled = PR_FALSE;
if (ns.Equals(nsSOAPUtils::kXSURI)) {
if (name.Equals(kStringSchemaType)) {
if (ns.Equals(gSOAPStrings->kXSURI)) {
if (name.Equals(gSOAPStrings->kStringSchemaType)) {
DECODE_ARRAY(PRUnichar*,WCHAR_STR,nsnull,rc = v->GetAsWString(a + p);if(NS_FAILED(rc))break;,
for (si = 0; si < size; si++) nsMemory::Free(a[si]););
} else if (name.Equals(kBooleanSchemaType)) {
} else if (name.Equals(gSOAPStrings->kBooleanSchemaType)) {
DECODE_SIMPLE_ARRAY(PRBool,Bool,BOOL);
} else if (name.Equals(kFloatSchemaType)) {
} else if (name.Equals(gSOAPStrings->kFloatSchemaType)) {
DECODE_SIMPLE_ARRAY(float,Float,FLOAT);
} else if (name.Equals(kDoubleSchemaType)) {
} else if (name.Equals(gSOAPStrings->kDoubleSchemaType)) {
DECODE_SIMPLE_ARRAY(double,Double,DOUBLE);
} else if (name.Equals(kLongSchemaType)) {
} else if (name.Equals(gSOAPStrings->kLongSchemaType)) {
DECODE_SIMPLE_ARRAY(PRInt64,Int64,INT64);
} else if (name.Equals(kIntSchemaType)) {
} else if (name.Equals(gSOAPStrings->kIntSchemaType)) {
DECODE_SIMPLE_ARRAY(PRInt32,Int32,INT32);
} else if (name.Equals(kShortSchemaType)) {
} else if (name.Equals(gSOAPStrings->kShortSchemaType)) {
DECODE_SIMPLE_ARRAY(PRInt16,Int16,INT16);
} else if (name.Equals(kByteSchemaType)) {
} else if (name.Equals(gSOAPStrings->kByteSchemaType)) {
DECODE_SIMPLE_ARRAY(PRUint8,Int8,INT8);
} else if (name.Equals(kUnsignedLongSchemaType)) {
} else if (name.Equals(gSOAPStrings->kUnsignedLongSchemaType)) {
DECODE_SIMPLE_ARRAY(PRUint64,Uint64,UINT64);
} else if (name.Equals(kUnsignedIntSchemaType)) {
} else if (name.Equals(gSOAPStrings->kUnsignedIntSchemaType)) {
DECODE_SIMPLE_ARRAY(PRUint32,Uint32,UINT32);
} else if (name.Equals(kUnsignedShortSchemaType)) {
} else if (name.Equals(gSOAPStrings->kUnsignedShortSchemaType)) {
DECODE_SIMPLE_ARRAY(PRUint16,Uint16,UINT16);
} else if (name.Equals(kUnsignedByteSchemaType)) {
} else if (name.Equals(gSOAPStrings->kUnsignedByteSchemaType)) {
DECODE_SIMPLE_ARRAY(PRUint8,Uint8,UINT8);
} else {
unhandled = PR_TRUE;
@ -2992,11 +2932,11 @@ NS_IMETHODIMP
if (NS_FAILED(rc))
return rc;
PRBool b;
if (value.Equals(nsSOAPUtils::kTrue)
|| value.Equals(nsSOAPUtils::kTrueA)) {
if (value.Equals(gSOAPStrings->kTrue)
|| value.Equals(gSOAPStrings->kTrueA)) {
b = PR_TRUE;
} else if (value.Equals(nsSOAPUtils::kFalse)
|| value.Equals(nsSOAPUtils::kFalseA)) {
} else if (value.Equals(gSOAPStrings->kFalse)
|| value.Equals(gSOAPStrings->kFalseA)) {
b = PR_FALSE;
} else
return SOAP_EXCEPTION(NS_ERROR_ILLEGAL_VALUE,"SOAP_ILLEGAL_BOOLEAN","Illegal value discovered for boolean");

Просмотреть файл

@ -88,8 +88,6 @@ nsresult DebugPrintDOM(nsIDOMNode * node)
#define DEBUG_DUMP_DOCUMENT(message,doc)
#endif
static NS_NAMED_LITERAL_STRING(kAnyURISchemaType, "anyURI");
/**
* This method will replace the target document's
* codebase principal with the subject codebase to
@ -225,8 +223,8 @@ static nsresult GetTransportURI(nsISOAPCall * aCall, nsAString & aURI)
// Remove any existing elements that may conflict with this verifySource identification
nsCOMPtr<nsIDOMElement> verifySource;
for (;;) {
nsSOAPUtils::GetSpecificChildElement(nsnull, element, nsSOAPUtils::kVerifySourceNamespaceURI,
nsSOAPUtils::kVerifySourceHeader, getter_AddRefs(verifySource));
nsSOAPUtils::GetSpecificChildElement(nsnull, element, gSOAPStrings->kVerifySourceNamespaceURI,
gSOAPStrings->kVerifySourceHeader, getter_AddRefs(verifySource));
if (verifySource) {
element->RemoveChild(verifySource, getter_AddRefs(ignore));
if (NS_FAILED(rc))
@ -250,30 +248,30 @@ static nsresult GetTransportURI(nsISOAPCall * aCall, nsAString & aURI)
nsAutoString XSIURI;
nsAutoString SOAPEncURI;
if (version == nsISOAPMessage::VERSION_1_1) {
XSURI.Assign(nsSOAPUtils::kXSURI1999);
XSIURI.Assign(nsSOAPUtils::kXSIURI1999);
SOAPEncURI.Assign(nsSOAPUtils::kSOAPEncURI11);
XSURI.Assign(gSOAPStrings->kXSURI1999);
XSIURI.Assign(gSOAPStrings->kXSIURI1999);
SOAPEncURI.Assign(gSOAPStrings->kSOAPEncURI11);
}
else {
XSURI.Assign(nsSOAPUtils::kXSURI);
XSIURI.Assign(nsSOAPUtils::kXSIURI);
SOAPEncURI.Assign(nsSOAPUtils::kSOAPEncURI);
XSURI.Assign(gSOAPStrings->kXSURI);
XSIURI.Assign(gSOAPStrings->kXSIURI);
SOAPEncURI.Assign(gSOAPStrings->kSOAPEncURI);
}
// Create the header and append it with mustUnderstand and normal encoding.
rc = document->CreateElementNS(nsSOAPUtils::kVerifySourceNamespaceURI,
nsSOAPUtils::kVerifySourceHeader,
rc = document->CreateElementNS(gSOAPStrings->kVerifySourceNamespaceURI,
gSOAPStrings->kVerifySourceHeader,
getter_AddRefs(verifySource));
if (NS_FAILED(rc))
return rc;
rc = element->AppendChild(verifySource, getter_AddRefs(ignore));
if (NS_FAILED(rc))
return rc;
rc = verifySource->SetAttributeNS(*nsSOAPUtils::kSOAPEnvURI[version],
nsSOAPUtils::kMustUnderstandAttribute,nsSOAPUtils::kTrueA);// mustUnderstand
rc = verifySource->SetAttributeNS(*gSOAPStrings->kSOAPEnvURI[version],
gSOAPStrings->kMustUnderstandAttribute,gSOAPStrings->kTrueA);// mustUnderstand
if (NS_FAILED(rc))
return rc;
rc = verifySource->SetAttributeNS(*nsSOAPUtils::kSOAPEnvURI[version],
nsSOAPUtils::kEncodingStyleAttribute, SOAPEncURI);// 1.2 encoding
rc = verifySource->SetAttributeNS(*gSOAPStrings->kSOAPEnvURI[version],
gSOAPStrings->kEncodingStyleAttribute, SOAPEncURI);// 1.2 encoding
if (NS_FAILED(rc))
return rc;
@ -284,21 +282,21 @@ static nsresult GetTransportURI(nsISOAPCall * aCall, nsAString & aURI)
rc = nsSOAPUtils::MakeNamespacePrefix(nsnull, verifySource, XSURI, stringType);
if (NS_FAILED(rc))
return rc;
stringType.Append(nsSOAPUtils::kQualifiedSeparator);
stringType.Append(kAnyURISchemaType);
stringType.Append(gSOAPStrings->kQualifiedSeparator);
stringType.Append(NS_LITERAL_STRING("anyURI"));
}
// If it is available, add the sourceURI
if (!sourceURI.IsEmpty()) {
rc = document->CreateElementNS(nsSOAPUtils::kVerifySourceNamespaceURI,
nsSOAPUtils::kVerifySourceURI,getter_AddRefs(element));
rc = document->CreateElementNS(gSOAPStrings->kVerifySourceNamespaceURI,
gSOAPStrings->kVerifySourceURI,getter_AddRefs(element));
if (NS_FAILED(rc))
return rc;
rc = verifySource->AppendChild(element, getter_AddRefs(ignore));
if (NS_FAILED(rc))
return rc;
rc = element->SetAttributeNS(XSIURI,
nsSOAPUtils::kXSITypeAttribute,stringType);
gSOAPStrings->kXSITypeAttribute,stringType);
if (NS_FAILED(rc))
return rc;
nsCOMPtr<nsIDOMText> text;

Просмотреть файл

@ -174,7 +174,7 @@ nsSOAPEncoding::nsSOAPEncoding() : mEncoders(),
mMappedInternal(),
mMappedExternal()
{
mStyleURI.Assign(nsSOAPUtils::kSOAPEncURI11);
mStyleURI.Assign(gSOAPStrings->kSOAPEncURI11);
mRegistry = new nsSOAPEncodingRegistry(this);
mDefaultEncoding = do_GetService(NS_DEFAULTSOAPENCODING_1_1_CONTRACTID);
}

Просмотреть файл

@ -159,10 +159,6 @@ nsSOAPException::GetData(nsISupports * *aData)
return NS_OK;
}
static NS_NAMED_LITERAL_STRING(kErrorSeparator1, ": ");
static NS_NAMED_LITERAL_STRING(kErrorSeparator2, ", called by ");
static NS_NAMED_LITERAL_STRING(kErrorSeparator3, ", caused by ");
/* string toString (); */
NS_IMETHODIMP
nsSOAPException::ToString(char **_retval)
@ -170,13 +166,13 @@ nsSOAPException::ToString(char **_retval)
NS_ENSURE_ARG_POINTER(_retval);
nsAutoString s;
s.Append(mName);
s.Append(kErrorSeparator1);
s.Append(NS_LITERAL_STRING(": "));
s.Append(mMessage);
if (mFrame) {
char* str = nsnull;
mFrame->ToString(&str);
if (str) {
s.Append(kErrorSeparator2);
s.Append(NS_LITERAL_STRING(", called by "));
nsAutoString i;
CopyASCIItoUCS2(nsDependentCString(str),i);
nsMemory::Free(str);
@ -190,7 +186,7 @@ nsSOAPException::ToString(char **_retval)
nsAutoString i;
CopyASCIItoUCS2(nsDependentCString(str),i);
nsMemory::Free(str);
s.Append(kErrorSeparator3);
s.Append(NS_LITERAL_STRING(", caused by "));
s.Append(i);
}
}
@ -199,12 +195,6 @@ nsSOAPException::ToString(char **_retval)
return NS_OK;
}
NS_NAMED_LITERAL_STRING(realSOAPExceptionEmpty, "");
const nsAString & nsSOAPException::kEmpty = realSOAPExceptionEmpty;
static NS_NAMED_LITERAL_STRING(kFailure, "SOAP_FAILURE");
static NS_NAMED_LITERAL_STRING(kNoDescription, "No description");
nsresult nsSOAPException::AddException(nsresult aStatus, const nsAString & aName,
const nsAString & aMessage,PRBool aClear)
{
@ -217,11 +207,6 @@ nsresult nsSOAPException::AddException(nsresult aStatus, const nsAString & aName
nsCOMPtr<nsIException> old;
if (!aClear)
xs->GetCurrentException(getter_AddRefs(old));
// Need to cast the NS_LITERAL_STRING to const nsAString& to make
// it compile on CW on Mac.
// The evil ? operator caused bustage. This time, eliminate that.
// const nsAString& name = aName.IsEmpty() ? kFailure : aName;
// const nsAString& message = aMessage.IsEmpty() ? kNoDescription : aMessage;
nsCOMPtr<nsIException> exception = new nsSOAPException(aStatus, aName,
aMessage, old);
if (exception) {

Просмотреть файл

@ -55,7 +55,6 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSIEXCEPTION
static const nsAString & kEmpty;
static nsresult AddException(nsresult aStatus, const nsAString & aName, const nsAString & aMessage,PRBool aClear = PR_FALSE);
protected:

Просмотреть файл

@ -42,8 +42,6 @@
#include "nsISOAPMessage.h"
#include "nsSOAPException.h"
static NS_NAMED_LITERAL_STRING(kEmpty, "");
nsSOAPFault::nsSOAPFault()
{
}
@ -65,13 +63,12 @@ NS_IMETHODIMP nsSOAPFault::SetElement(nsIDOMElement * aElement)
rc = aElement->GetLocalName(name);
if (NS_FAILED(rc))
return rc;
if (name.Equals(nsSOAPUtils::kFaultTagName)) {
if (name.Equals(gSOAPStrings->kFaultTagName)) {
if (namespaceURI.
Equals(*nsSOAPUtils::kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])) {
Equals(*gSOAPStrings->kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])) {
mVersion = nsISOAPMessage::VERSION_1_2;
} else if (namespaceURI.
Equals(*nsSOAPUtils::
kSOAPEnvURI[nsISOAPMessage::VERSION_1_1])) {
Equals(*gSOAPStrings->kSOAPEnvURI[nsISOAPMessage::VERSION_1_1])) {
mVersion = nsISOAPMessage::VERSION_1_1;
} else {
return SOAP_EXCEPTION(NS_ERROR_ILLEGAL_VALUE,"SOAP_BADFAULT", "Cannot recognize SOAP version from namespace URI of fault");
@ -101,8 +98,8 @@ NS_IMETHODIMP nsSOAPFault::GetFaultCode(nsAString & aFaultCode)
aFaultCode.Truncate();
nsCOMPtr < nsIDOMElement > faultcode;
nsSOAPUtils::GetSpecificChildElement(nsnull, mFaultElement,
kEmpty,
nsSOAPUtils::kFaultCodeTagName,
gSOAPStrings->kEmpty,
gSOAPStrings->kFaultCodeTagName,
getter_AddRefs(faultcode));
if (faultcode) {
nsAutoString combined;
@ -123,8 +120,8 @@ NS_IMETHODIMP nsSOAPFault::GetFaultNamespaceURI(nsAString & aNamespaceURI)
aNamespaceURI.Truncate();
nsCOMPtr < nsIDOMElement > faultcode;
nsSOAPUtils::GetSpecificChildElement(nsnull, mFaultElement,
kEmpty,
nsSOAPUtils::kFaultCodeTagName,
gSOAPStrings->kEmpty,
gSOAPStrings->kFaultCodeTagName,
getter_AddRefs(faultcode));
if (faultcode) {
nsAutoString combined;
@ -146,8 +143,8 @@ NS_IMETHODIMP nsSOAPFault::GetFaultString(nsAString & aFaultString)
aFaultString.Truncate();
nsCOMPtr < nsIDOMElement > element;
nsSOAPUtils::GetSpecificChildElement(nsnull, mFaultElement,
kEmpty,
nsSOAPUtils::kFaultStringTagName,
gSOAPStrings->kEmpty,
gSOAPStrings->kFaultStringTagName,
getter_AddRefs(element));
if (element) {
nsresult rc = nsSOAPUtils::GetElementTextContent(element, aFaultString);
@ -167,8 +164,8 @@ NS_IMETHODIMP nsSOAPFault::GetFaultActor(nsAString & aFaultActor)
aFaultActor.Truncate();
nsCOMPtr < nsIDOMElement > element;
nsSOAPUtils::GetSpecificChildElement(nsnull, mFaultElement,
kEmpty,
nsSOAPUtils::kFaultActorTagName,
gSOAPStrings->kEmpty,
gSOAPStrings->kFaultActorTagName,
getter_AddRefs(element));
if (element) {
nsresult rc = nsSOAPUtils::GetElementTextContent(element, aFaultActor);
@ -186,8 +183,8 @@ NS_IMETHODIMP nsSOAPFault::GetDetail(nsIDOMElement * *aDetail)
return NS_ERROR_ILLEGAL_VALUE;
nsSOAPUtils::GetSpecificChildElement(nsnull, mFaultElement,
kEmpty,
nsSOAPUtils::kFaultDetailTagName,
gSOAPStrings->kEmpty,
gSOAPStrings->kFaultDetailTagName,
aDetail);
return NS_OK;
}

Просмотреть файл

@ -68,8 +68,8 @@ NS_IMETHODIMP nsSOAPHeaderBlock::GetActorURI(nsAString & aActorURI)
if (mElement) {
if (mVersion == nsISOAPMessage::VERSION_UNKNOWN)
return SOAP_EXCEPTION(NS_ERROR_NOT_AVAILABLE,"SOAP_HEADER_INIT", "Header has not been properly initialized.");
return mElement->GetAttributeNS(*nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kActorAttribute,
return mElement->GetAttributeNS(*gSOAPStrings->kSOAPEnvURI[mVersion],
gSOAPStrings->kActorAttribute,
aActorURI);
} else {
aActorURI.Assign(mActorURI);
@ -98,17 +98,17 @@ NS_IMETHODIMP nsSOAPHeaderBlock::GetMustUnderstand(PRBool *
nsresult
rc =
mElement->
GetAttributeNS(*nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kMustUnderstandAttribute, m);
GetAttributeNS(*gSOAPStrings->kSOAPEnvURI[mVersion],
gSOAPStrings->kMustUnderstandAttribute, m);
if (NS_FAILED(rc))
return rc;
if (m.IsEmpty())
*aMustUnderstand = PR_FALSE;
else if (m.Equals(nsSOAPUtils::kTrue)
|| m.Equals(nsSOAPUtils::kTrueA))
else if (m.Equals(gSOAPStrings->kTrue)
|| m.Equals(gSOAPStrings->kTrueA))
*aMustUnderstand = PR_TRUE;
else if (m.Equals(nsSOAPUtils::kFalse)
|| m.Equals(nsSOAPUtils::kFalseA))
else if (m.Equals(gSOAPStrings->kFalse)
|| m.Equals(gSOAPStrings->kFalseA))
*aMustUnderstand = PR_FALSE;
else
return SOAP_EXCEPTION(NS_ERROR_ILLEGAL_VALUE,"SOAP_HEADER_MUSTUNDERSTAND", "Must understand value in header has an illegal value.");

Просмотреть файл

@ -97,13 +97,11 @@ NS_IMETHODIMP nsSOAPMessage::GetEnvelope(nsIDOMElement * *aEnvelope)
rc = root->GetLocalName(name);
if (NS_FAILED(rc))
return rc;
if (name.Equals(nsSOAPUtils::kEnvelopeTagName)
if (name.Equals(gSOAPStrings->kEnvelopeTagName)
&& (namespaceURI.
Equals(*nsSOAPUtils::
kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])
Equals(*gSOAPStrings->kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])
|| namespaceURI.
Equals(*nsSOAPUtils::
kSOAPEnvURI[nsISOAPMessage::VERSION_1_1]))) {
Equals(*gSOAPStrings->kSOAPEnvURI[nsISOAPMessage::VERSION_1_1]))) {
*aEnvelope = root;
NS_ADDREF(*aEnvelope);
return NS_OK;
@ -130,15 +128,13 @@ NS_IMETHODIMP nsSOAPMessage::GetVersion(PRUint16 * aVersion)
rc = root->GetLocalName(name);
if (NS_FAILED(rc))
return rc;
if (name.Equals(nsSOAPUtils::kEnvelopeTagName)) {
if (name.Equals(gSOAPStrings->kEnvelopeTagName)) {
if (namespaceURI.
Equals(*nsSOAPUtils::
kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])) {
Equals(*gSOAPStrings->kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])) {
*aVersion = nsISOAPMessage::VERSION_1_2;
return NS_OK;
} else if (namespaceURI.
Equals(*nsSOAPUtils::
kSOAPEnvURI[nsISOAPMessage::VERSION_1_1])) {
Equals(*gSOAPStrings->kSOAPEnvURI[nsISOAPMessage::VERSION_1_1])) {
*aVersion = nsISOAPMessage::VERSION_1_1;
return NS_OK;
}
@ -160,16 +156,14 @@ PRUint16 nsSOAPMessage::GetEnvelopeWithVersion(nsIDOMElement * *aEnvelope)
nsAutoString name;
root->GetNamespaceURI(namespaceURI);
root->GetLocalName(name);
if (name.Equals(nsSOAPUtils::kEnvelopeTagName)) {
if (name.Equals(gSOAPStrings->kEnvelopeTagName)) {
if (namespaceURI.
Equals(*nsSOAPUtils::
kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])) {
Equals(*gSOAPStrings->kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])) {
*aEnvelope = root;
NS_ADDREF(*aEnvelope);
return nsISOAPMessage::VERSION_1_2;
} else if (namespaceURI.
Equals(*nsSOAPUtils::
kSOAPEnvURI[nsISOAPMessage::VERSION_1_1])) {
Equals(*gSOAPStrings->kSOAPEnvURI[nsISOAPMessage::VERSION_1_1])) {
*aEnvelope = root;
NS_ADDREF(*aEnvelope);
return nsISOAPMessage::VERSION_1_1;
@ -189,9 +183,8 @@ NS_IMETHODIMP nsSOAPMessage::GetHeader(nsIDOMElement * *aHeader)
PRUint16 version = GetEnvelopeWithVersion(getter_AddRefs(env));
if (env) {
nsSOAPUtils::GetSpecificChildElement(nsnull, env,
*nsSOAPUtils::
kSOAPEnvURI[version],
nsSOAPUtils::kHeaderTagName,
*gSOAPStrings->kSOAPEnvURI[version],
gSOAPStrings->kHeaderTagName,
aHeader);
} else {
*aHeader = nsnull;
@ -207,9 +200,8 @@ NS_IMETHODIMP nsSOAPMessage::GetBody(nsIDOMElement * *aBody)
PRUint16 version = GetEnvelopeWithVersion(getter_AddRefs(env));
if (env) {
nsSOAPUtils::GetSpecificChildElement(nsnull, env,
*nsSOAPUtils::
kSOAPEnvURI[version],
nsSOAPUtils::kBodyTagName, aBody);
*gSOAPStrings->kSOAPEnvURI[version],
gSOAPStrings->kBodyTagName, aBody);
} else {
*aBody = nsnull;
}
@ -276,15 +268,6 @@ GetTargetObjectURI(nsAString & aTargetObjectURI)
return NS_OK;
}
NS_NAMED_LITERAL_STRING(realEmptySOAPDocStr1,
"<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:enc=\"http://schemas.xmlsoap.org/soap/encoding/\"><env:Header/><env:Body/></env:Envelope>");
NS_NAMED_LITERAL_STRING(realEmptySOAPDocStr2,
"<env:Envelope xmlns:env=\"http://www.w3.org/2001/09/soap-envelope\" xmlns:enc=\"http://www.w3.org/2001/09/soap-encoding\"><env:Header/><env:Body/></env:Envelope>");
const nsAString *kEmptySOAPDocStr[] =
{ &realEmptySOAPDocStr1, &realEmptySOAPDocStr2
};
NS_IMETHODIMP
nsSOAPMessage::Encode(PRUint16 aVersion, const nsAString & aMethodName,
const nsAString & aTargetObjectURI,
@ -293,6 +276,14 @@ NS_IMETHODIMP
PRUint32 aParameterCount,
nsISOAPParameter ** aParameters)
{
static const NS_NAMED_LITERAL_STRING(realEmptySOAPDocStr1,
"<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:enc=\"http://schemas.xmlsoap.org/soap/encoding/\"><env:Header/><env:Body/></env:Envelope>");
static const NS_NAMED_LITERAL_STRING(realEmptySOAPDocStr2,
"<env:Envelope xmlns:env=\"http://www.w3.org/2001/09/soap-envelope\" xmlns:enc=\"http://www.w3.org/2001/09/soap-encoding\"><env:Header/><env:Body/></env:Envelope>");
static const nsAString *kEmptySOAPDocStr[] = {
&realEmptySOAPDocStr1, &realEmptySOAPDocStr2
};
NS_ENSURE_ARG_POINTER(&aMethodName);
NS_ENSURE_ARG_POINTER(&aTargetObjectURI);
if (aVersion != nsISOAPMessage::VERSION_1_1
@ -328,9 +319,8 @@ NS_IMETHODIMP
if (NS_FAILED(rv))
return rv;
if (!enc.IsEmpty()) {
rv = envelope->SetAttributeNS(*nsSOAPUtils::kSOAPEnvURI[aVersion],
nsSOAPUtils::
kEncodingStyleAttribute, enc);
rv = envelope->SetAttributeNS(*gSOAPStrings->kSOAPEnvURI[aVersion],
gSOAPStrings->kEncodingStyleAttribute, enc);
if (NS_FAILED(rv))
return rv;
}
@ -339,20 +329,20 @@ NS_IMETHODIMP
nsAutoString temp;
nsAutoString temp2;
temp.Assign(nsSOAPUtils::kXMLNamespacePrefix);
temp.Append(nsSOAPUtils::kXSPrefix);
rv = encoding->GetExternalSchemaURI(nsSOAPUtils::kXSURI, temp2);
temp.Assign(gSOAPStrings->kXMLNamespacePrefix);
temp.Append(gSOAPStrings->kXSPrefix);
rv = encoding->GetExternalSchemaURI(gSOAPStrings->kXSURI, temp2);
if (NS_FAILED(rv))
return rv;
rv = envelope->SetAttributeNS(nsSOAPUtils::kXMLNamespaceNamespaceURI, temp, temp2);
rv = envelope->SetAttributeNS(gSOAPStrings->kXMLNamespaceNamespaceURI, temp, temp2);
if (NS_FAILED(rv))
return rv;
temp.Assign(nsSOAPUtils::kXMLNamespacePrefix);
temp.Append(nsSOAPUtils::kXSIPrefix);
rv = encoding->GetExternalSchemaURI(nsSOAPUtils::kXSIURI, temp2);
temp.Assign(gSOAPStrings->kXMLNamespacePrefix);
temp.Append(gSOAPStrings->kXSIPrefix);
rv = encoding->GetExternalSchemaURI(gSOAPStrings->kXSIURI, temp2);
if (NS_FAILED(rv))
return rv;
rv = envelope->SetAttributeNS(nsSOAPUtils::kXMLNamespaceNamespaceURI, temp, temp2);
rv = envelope->SetAttributeNS(gSOAPStrings->kXMLNamespaceNamespaceURI, temp, temp2);
if (NS_FAILED(rv))
return rv;
@ -421,16 +411,15 @@ NS_IMETHODIMP
if (NS_FAILED(rv))
return rv;
if (!actorURI.IsEmpty()) {
element->SetAttributeNS(nsSOAPUtils::kSOAPEnvPrefix,
nsSOAPUtils::kActorAttribute, actorURI);
element->SetAttributeNS(gSOAPStrings->kSOAPEnvPrefix,
gSOAPStrings->kActorAttribute, actorURI);
if (NS_FAILED(rv))
return rv;
}
if (mustUnderstand) {
element->SetAttributeNS(nsSOAPUtils::kSOAPEnvPrefix,
nsSOAPUtils::
kMustUnderstandAttribute,
nsSOAPUtils::kTrueA);
element->SetAttributeNS(gSOAPStrings->kSOAPEnvPrefix,
gSOAPStrings->kMustUnderstandAttribute,
gSOAPStrings->kTrueA);
if (NS_FAILED(rv))
return rv;
}
@ -438,8 +427,8 @@ NS_IMETHODIMP
nsAutoString enc;
encoding->GetStyleURI(enc);
element->
SetAttributeNS(*nsSOAPUtils::kSOAPEnvURI[aVersion],
nsSOAPUtils::kEncodingStyleAttribute, enc);
SetAttributeNS(*gSOAPStrings->kSOAPEnvURI[aVersion],
gSOAPStrings->kEncodingStyleAttribute, enc);
}
}
}
@ -518,8 +507,8 @@ NS_IMETHODIMP
if (encoding != newencoding) {
nsAutoString enc;
newencoding->GetStyleURI(enc);
element->SetAttributeNS(*nsSOAPUtils::kSOAPEnvURI[aVersion],
nsSOAPUtils::kEncodingStyleAttribute, enc);
element->SetAttributeNS(*gSOAPStrings->kSOAPEnvURI[aVersion],
gSOAPStrings->kEncodingStyleAttribute, enc);
}
}
}
@ -551,8 +540,8 @@ nsresult
nsAutoString style;
for (;;) {
nsCOMPtr < nsIDOMAttr > enc;
rv = element->GetAttributeNodeNS(*nsSOAPUtils::kSOAPEnvURI[*aVersion],
nsSOAPUtils::kEncodingStyleAttribute,
rv = element->GetAttributeNodeNS(*gSOAPStrings->kSOAPEnvURI[*aVersion],
gSOAPStrings->kEncodingStyleAttribute,
getter_AddRefs(enc));
if (NS_FAILED(rv))
return rv;
@ -751,12 +740,12 @@ NS_IMETHODIMP nsSOAPMessage::GetEncoding(nsISOAPEncoding * *aEncoding)
return NS_ERROR_OUT_OF_MEMORY;
if (version == nsISOAPMessage::VERSION_1_1) {
rc = encoding->
GetAssociatedEncoding(nsSOAPUtils::kSOAPEncURI11,
GetAssociatedEncoding(gSOAPStrings->kSOAPEncURI11,
PR_FALSE, getter_AddRefs(mEncoding));
}
else {
rc = encoding->
GetAssociatedEncoding(nsSOAPUtils::kSOAPEncURI,
GetAssociatedEncoding(gSOAPStrings->kSOAPEncURI,
PR_FALSE, getter_AddRefs(mEncoding));
}
if (NS_FAILED(rc))

Просмотреть файл

@ -80,9 +80,8 @@ NS_IMETHODIMP nsSOAPResponse::GetFault(nsISOAPFault * *aFault)
if (rc != nsSOAPMessage::VERSION_UNKNOWN) {
nsCOMPtr < nsIDOMElement > fault;
nsSOAPUtils::GetSpecificChildElement(nsnull, body,
*nsSOAPUtils::
kSOAPEnvURI[version],
nsSOAPUtils::kFaultTagName,
*gSOAPStrings->kSOAPEnvURI[version],
gSOAPStrings->kFaultTagName,
getter_AddRefs(fault));
if (fault) {
nsCOMPtr < nsISOAPFault > f =

Просмотреть файл

@ -44,127 +44,78 @@
#include "nsCOMPtr.h"
#include "nsSOAPException.h"
NS_NAMED_LITERAL_STRING(realSOAPEnvURI1,
"http://schemas.xmlsoap.org/soap/envelope/");
NS_NAMED_LITERAL_STRING(realSOAPEnvURI2,
"http://www.w3.org/2001/09/soap-envelope");
const nsAString *nsSOAPUtils::kSOAPEnvURI[] =
{ &realSOAPEnvURI1, &realSOAPEnvURI2
};
nsSOAPStrings::nsSOAPStrings()
: NS_LITERAL_STRING_INIT(kSOAPEnvURI1, "http://schemas.xmlsoap.org/soap/envelope/")
, NS_LITERAL_STRING_INIT(kSOAPEnvURI2, "http://www.w3.org/2001/09/soap-envelope")
, NS_LITERAL_STRING_INIT(kSOAPEncURI, "http://www.w3.org/2001/09/soap-encoding")
, NS_LITERAL_STRING_INIT(kSOAPEncURI11, "http://schemas.xmlsoap.org/soap/encoding/")
, NS_LITERAL_STRING_INIT(kXSIURI, "http://www.w3.org/2001/XMLSchema-instance")
, NS_LITERAL_STRING_INIT(kXSURI, "http://www.w3.org/2001/XMLSchema")
, NS_LITERAL_STRING_INIT(kXSIURI1999, "http://www.w3.org/1999/XMLSchema-instance")
, NS_LITERAL_STRING_INIT(kXSURI1999, "http://www.w3.org/1999/XMLSchema")
, NS_LITERAL_STRING_INIT(kSOAPEnvPrefix, "env")
, NS_LITERAL_STRING_INIT(kSOAPEncPrefix, "enc")
, NS_LITERAL_STRING_INIT(kXSIPrefix, "xsi")
, NS_LITERAL_STRING_INIT(kXSITypeAttribute, "type")
, NS_LITERAL_STRING_INIT(kXSPrefix, "xs")
, NS_LITERAL_STRING_INIT(kEncodingStyleAttribute, "encodingStyle")
, NS_LITERAL_STRING_INIT(kActorAttribute, "actor")
, NS_LITERAL_STRING_INIT(kMustUnderstandAttribute, "mustUnderstand")
, NS_LITERAL_STRING_INIT(kEnvelopeTagName, "Envelope")
, NS_LITERAL_STRING_INIT(kHeaderTagName, "Header")
, NS_LITERAL_STRING_INIT(kBodyTagName, "Body")
, NS_LITERAL_STRING_INIT(kFaultTagName, "Fault")
, NS_LITERAL_STRING_INIT(kFaultCodeTagName, "faultcode")
, NS_LITERAL_STRING_INIT(kFaultStringTagName, "faultstring")
, NS_LITERAL_STRING_INIT(kFaultActorTagName, "faultactor")
, NS_LITERAL_STRING_INIT(kFaultDetailTagName, "detail")
, NS_LITERAL_STRING_INIT(kEncodingSeparator, "#")
, NS_LITERAL_STRING_INIT(kQualifiedSeparator, ":")
, NS_LITERAL_STRING_INIT(kXMLNamespaceNamespaceURI, "http://www.w3.org/2000/xmlns/")
, NS_LITERAL_STRING_INIT(kXMLNamespaceURI, "http://www.w3.org/XML/1998/namespace")
, NS_LITERAL_STRING_INIT(kXMLNamespacePrefix, "xmlns:")
, NS_LITERAL_STRING_INIT(kXMLPrefix, "xml:")
, NS_LITERAL_STRING_INIT(kTrue, "true")
, NS_LITERAL_STRING_INIT(kTrueA, "1")
, NS_LITERAL_STRING_INIT(kFalse, "false")
, NS_LITERAL_STRING_INIT(kFalseA, "0")
, NS_LITERAL_STRING_INIT(kVerifySourceHeader, "verifySource")
, NS_LITERAL_STRING_INIT(kVerifySourceURI, "uri")
, NS_LITERAL_STRING_INIT(kVerifySourceNamespaceURI, "urn:inet:www.mozilla.org:user-agent")
NS_NAMED_LITERAL_STRING(realSOAPEncURI,
"http://www.w3.org/2001/09/soap-encoding");
const nsAString & nsSOAPUtils::kSOAPEncURI = realSOAPEncURI;
NS_NAMED_LITERAL_STRING(realSOAPEncURI11,
"http://schemas.xmlsoap.org/soap/encoding/");
const nsAString & nsSOAPUtils::kSOAPEncURI11 = realSOAPEncURI11;
NS_NAMED_LITERAL_STRING(realXSIURI, "http://www.w3.org/2001/XMLSchema-instance");
const nsAString & nsSOAPUtils::kXSIURI = realXSIURI;
NS_NAMED_LITERAL_STRING(realXSURI, "http://www.w3.org/2001/XMLSchema");
const nsAString & nsSOAPUtils::kXSURI = realXSURI;
NS_NAMED_LITERAL_STRING(realXSIURI1999, "http://www.w3.org/1999/XMLSchema-instance");
const nsAString & nsSOAPUtils::kXSIURI1999 = realXSIURI1999;
NS_NAMED_LITERAL_STRING(realXSURI1999, "http://www.w3.org/1999/XMLSchema");
const nsAString & nsSOAPUtils::kXSURI1999 = realXSURI1999;
NS_NAMED_LITERAL_STRING(realSOAPEnvPrefix, "env");
const nsAString & nsSOAPUtils::kSOAPEnvPrefix = realSOAPEnvPrefix;
NS_NAMED_LITERAL_STRING(realSOAPEncPrefix, "enc");
const nsAString & nsSOAPUtils::kSOAPEncPrefix = realSOAPEncPrefix;
NS_NAMED_LITERAL_STRING(realXSIPrefix, "xsi");
const nsAString & nsSOAPUtils::kXSIPrefix = realXSIPrefix;
NS_NAMED_LITERAL_STRING(realXSITypeAttribute, "type");
const nsAString & nsSOAPUtils::kXSITypeAttribute = realXSITypeAttribute;
NS_NAMED_LITERAL_STRING(realXSPrefix, "xs");
const nsAString & nsSOAPUtils::kXSPrefix = realXSPrefix;
NS_NAMED_LITERAL_STRING(realEncodingStyleAttribute, "encodingStyle");
const
nsAString &
nsSOAPUtils::kEncodingStyleAttribute = realEncodingStyleAttribute;
NS_NAMED_LITERAL_STRING(realActorAttribute, "actor");
const nsAString & nsSOAPUtils::kActorAttribute = realActorAttribute;
NS_NAMED_LITERAL_STRING(realMustUnderstandAttribute, "mustUnderstand");
const
nsAString &
nsSOAPUtils::kMustUnderstandAttribute = realMustUnderstandAttribute;
NS_NAMED_LITERAL_STRING(realEnvelopeTagName, "Envelope");
const nsAString & nsSOAPUtils::kEnvelopeTagName = realEnvelopeTagName;
NS_NAMED_LITERAL_STRING(realHeaderTagName, "Header");
const nsAString & nsSOAPUtils::kHeaderTagName = realHeaderTagName;
NS_NAMED_LITERAL_STRING(realBodyTagName, "Body");
const nsAString & nsSOAPUtils::kBodyTagName = realBodyTagName;
NS_NAMED_LITERAL_STRING(realFaultTagName, "Fault");
const nsAString & nsSOAPUtils::kFaultTagName = realFaultTagName;
NS_NAMED_LITERAL_STRING(realFaultCodeTagName, "faultcode");
const nsAString & nsSOAPUtils::kFaultCodeTagName = realFaultCodeTagName;
NS_NAMED_LITERAL_STRING(realFaultStringTagName, "faultstring");
const
nsAString & nsSOAPUtils::kFaultStringTagName = realFaultStringTagName;
NS_NAMED_LITERAL_STRING(realFaultActorTagName, "faultactor");
const nsAString & nsSOAPUtils::kFaultActorTagName = realFaultActorTagName;
NS_NAMED_LITERAL_STRING(realFaultDetailTagName, "detail");
const
nsAString & nsSOAPUtils::kFaultDetailTagName = realFaultDetailTagName;
NS_NAMED_LITERAL_STRING(realEncodingSeparator, "#");
const nsAString & nsSOAPUtils::kEncodingSeparator = realEncodingSeparator;
NS_NAMED_LITERAL_STRING(realQualifiedSeparator, ":");
const
nsAString & nsSOAPUtils::kQualifiedSeparator = realQualifiedSeparator;
NS_NAMED_LITERAL_STRING(realXMLNamespaceNamespaceURI,
"http://www.w3.org/2000/xmlns/");
const nsAString &
nsSOAPUtils::kXMLNamespaceNamespaceURI = realXMLNamespaceNamespaceURI;
NS_NAMED_LITERAL_STRING(realXMLNamespaceURI,
"http://www.w3.org/XML/1998/namespace");
const
nsAString & nsSOAPUtils::kXMLNamespaceURI = realXMLNamespaceURI;
NS_NAMED_LITERAL_STRING(realXMLPrefix, "xml:");
const nsAString & nsSOAPUtils::kXMLPrefix = realXMLPrefix;
NS_NAMED_LITERAL_STRING(realXMLNamespacePrefix, "xmlns:");
const
nsAString & nsSOAPUtils::kXMLNamespacePrefix = realXMLNamespacePrefix;
NS_NAMED_LITERAL_STRING(realTrue, "true");
const nsAString & nsSOAPUtils::kTrue = realTrue;
NS_NAMED_LITERAL_STRING(realFalse, "false");
const nsAString & nsSOAPUtils::kFalse = realFalse;
NS_NAMED_LITERAL_STRING(realTrueA, "1");
const nsAString & nsSOAPUtils::kTrueA = realTrueA;
NS_NAMED_LITERAL_STRING(realFalseA, "0");
const nsAString & nsSOAPUtils::kFalseA = realFalseA;
NS_NAMED_LITERAL_STRING(realVerifySourceHeader, "verifySource");
const nsAString & nsSOAPUtils::kVerifySourceHeader = realVerifySourceHeader;
NS_NAMED_LITERAL_STRING(realVerifySourceURI, "uri");
const nsAString & nsSOAPUtils::kVerifySourceURI = realVerifySourceURI;
NS_NAMED_LITERAL_STRING(realVerifySourceNamespaceURI, "urn:inet:www.mozilla.org:user-agent");
const nsAString & nsSOAPUtils::kVerifySourceNamespaceURI = realVerifySourceNamespaceURI;
, NS_LITERAL_STRING_INIT(kEmpty, "")
, NS_LITERAL_STRING_INIT(kNull, "null")
, NS_LITERAL_STRING_INIT(kSOAPArrayTypeAttribute, "arrayType")
, NS_LITERAL_STRING_INIT(kSOAPArrayOffsetAttribute, "offset")
, NS_LITERAL_STRING_INIT(kSOAPArrayPositionAttribute, "position")
, NS_LITERAL_STRING_INIT(kAnyTypeSchemaType, "anyType")
, NS_LITERAL_STRING_INIT(kAnySimpleTypeSchemaType, "anySimpleType")
, NS_LITERAL_STRING_INIT(kArraySOAPType, "Array")
, NS_LITERAL_STRING_INIT(kStructSOAPType, "Struct")
, NS_LITERAL_STRING_INIT(kStringSchemaType, "string")
, NS_LITERAL_STRING_INIT(kBooleanSchemaType, "boolean")
, NS_LITERAL_STRING_INIT(kFloatSchemaType, "float")
, NS_LITERAL_STRING_INIT(kDoubleSchemaType, "double")
, NS_LITERAL_STRING_INIT(kLongSchemaType, "long")
, NS_LITERAL_STRING_INIT(kIntSchemaType, "int")
, NS_LITERAL_STRING_INIT(kShortSchemaType, "short")
, NS_LITERAL_STRING_INIT(kByteSchemaType, "byte")
, NS_LITERAL_STRING_INIT(kUnsignedLongSchemaType, "unsignedLong")
, NS_LITERAL_STRING_INIT(kUnsignedIntSchemaType, "unsignedInt")
, NS_LITERAL_STRING_INIT(kUnsignedShortSchemaType, "unsignedShort")
, NS_LITERAL_STRING_INIT(kUnsignedByteSchemaType, "unsignedByte")
, NS_LITERAL_STRING_INIT(kNormalizedStringSchemaType, "normalizedString")
, NS_LITERAL_STRING_INIT(kTokenSchemaType, "token")
, NS_LITERAL_STRING_INIT(kNameSchemaType, "Name")
, NS_LITERAL_STRING_INIT(kNCNameSchemaType, "NCName")
, NS_LITERAL_STRING_INIT(kDecimalSchemaType, "decimal")
, NS_LITERAL_STRING_INIT(kIntegerSchemaType, "integer")
, NS_LITERAL_STRING_INIT(kNonPositiveIntegerSchemaType, "nonPositiveInteger")
, NS_LITERAL_STRING_INIT(kNonNegativeIntegerSchemaType, "nonNegativeInteger")
{
kSOAPEnvURI[0] = &kSOAPEnvURI1;
kSOAPEnvURI[1] = &kSOAPEnvURI2;
}
void nsSOAPUtils::GetSpecificChildElement(nsISOAPEncoding * aEncoding,
nsIDOMElement * aParent,
@ -347,8 +298,8 @@ nsresult
prefix = Substring(aQName, 0, i);
nsAutoString result;
if (prefix.Equals(kXMLPrefix)) {
result.Assign(kXMLNamespaceURI);
if (prefix.Equals(gSOAPStrings->kXMLPrefix)) {
result.Assign(gSOAPStrings->kXMLNamespaceURI);
}
else {
@ -362,7 +313,7 @@ nsresult
if (NS_FAILED(rc))
return rc;
if (attrs) {
rc = attrs->GetNamedItemNS(kXMLNamespaceNamespaceURI, prefix,
rc = attrs->GetNamedItemNS(gSOAPStrings->kXMLNamespaceNamespaceURI, prefix,
getter_AddRefs(temp));
if (NS_FAILED(rc))
return rc;
@ -420,8 +371,8 @@ nsresult
aPrefix.Truncate();
if (externalURI.IsEmpty())
return NS_OK;
if (externalURI.Equals(nsSOAPUtils::kXMLNamespaceURI)) {
aPrefix.Assign(nsSOAPUtils::kXMLPrefix);
if (externalURI.Equals(gSOAPStrings->kXMLNamespaceURI)) {
aPrefix.Assign(gSOAPStrings->kXMLPrefix);
return NS_OK;
}
nsCOMPtr < nsIDOMNode > current = aScope;
@ -445,7 +396,7 @@ nsresult
if (!temp)
break;
temp->GetNamespaceURI(tstr);
if (!tstr.Equals(nsSOAPUtils::kXMLNamespaceNamespaceURI))
if (!tstr.Equals(gSOAPStrings->kXMLNamespaceNamespaceURI))
continue;
temp->GetNodeValue(tstr);
if (tstr.Equals(externalURI)) {
@ -460,8 +411,7 @@ nsresult
echeck = do_QueryInterface(check);
if (echeck) {
rc = echeck->
HasAttributeNS(nsSOAPUtils::
kXMLNamespaceNamespaceURI, prefix,
HasAttributeNS(gSOAPStrings->kXMLNamespaceNamespaceURI, prefix,
&hasDecl);
if (NS_FAILED(rc))
return rc;
@ -535,9 +485,9 @@ nsresult
// Declare the fabricated prefix
if (aScope) {
tstr.Assign(nsSOAPUtils::kXMLNamespacePrefix);
tstr.Assign(gSOAPStrings->kXMLNamespacePrefix);
tstr.Append(aPrefix);
rc = aScope->SetAttributeNS(nsSOAPUtils::kXMLNamespaceNamespaceURI,
rc = aScope->SetAttributeNS(gSOAPStrings->kXMLNamespaceNamespaceURI,
tstr, externalURI);
}
return NS_OK;
@ -609,25 +559,3 @@ PRBool nsSOAPUtils::GetAttribute(nsISOAPEncoding *aEncoding,
SetAStringToNull(aValue);
return PR_FALSE;
}
PRBool nsSOAPUtils::StartsWith(nsAString & aSuper, nsAString & aSub)
{
PRUint32 c1 = aSuper.Length();
PRUint32 c2 = aSub.Length();
if (c1 < c2)
return PR_FALSE;
if (c1 == c2)
return aSuper.Equals(aSub);
nsReadingIterator < PRUnichar > i1;
nsReadingIterator < PRUnichar > i2;
aSuper.BeginReading(i1);
aSub.BeginReading(i2);
while (c2--) {
if (*i1 != *i2)
return PR_FALSE;
i1++;
i2++;
}
return PR_TRUE;
}

Просмотреть файл

@ -83,50 +83,86 @@ public:
const nsAString & aNamespaceURI,
const nsAString & aLocalName,
nsAString & aValue);
// All those missing string functions have to come from somewhere...
static PRBool StartsWith(nsAString & aSuper, nsAString & aSub);
static const nsAString *kSOAPEnvURI[];
static const nsAString & kSOAPEncURI;
static const nsAString & kSOAPEncURI11;
static const nsAString & kXSIURI;
static const nsAString & kXSURI;
static const nsAString & kXSIURI1999;
static const nsAString & kXSURI1999;
static const nsAString & kSOAPEnvPrefix;
static const nsAString & kSOAPEncPrefix;
static const nsAString & kXSIPrefix;
static const nsAString & kXSITypeAttribute;
static const nsAString & kXSPrefix;
static const nsAString & kEncodingStyleAttribute;
static const nsAString & kActorAttribute;
static const nsAString & kMustUnderstandAttribute;
static const nsAString & kEnvelopeTagName;
static const nsAString & kHeaderTagName;
static const nsAString & kBodyTagName;
static const nsAString & kFaultTagName;
static const nsAString & kFaultCodeTagName;
static const nsAString & kFaultStringTagName;
static const nsAString & kFaultActorTagName;
static const nsAString & kFaultDetailTagName;
static const nsAString & kEncodingSeparator;
static const nsAString & kQualifiedSeparator;
static const nsAString & kXMLNamespaceNamespaceURI;
static const nsAString & kXMLNamespaceURI;
static const nsAString & kXMLNamespacePrefix;
static const nsAString & kXMLPrefix;
static const nsAString & kTrue;
static const nsAString & kTrueA;
static const nsAString & kFalse;
static const nsAString & kFalseA;
static const nsAString & kVerifySourceHeader;
static const nsAString & kVerifySourceURI;
static const nsAString & kVerifySourceNamespaceURI;
};
struct nsSOAPStrings
{
const nsLiteralString kSOAPEnvURI1;
const nsLiteralString kSOAPEnvURI2;
const nsLiteralString *kSOAPEnvURI[2];
const nsLiteralString kSOAPEncURI;
const nsLiteralString kSOAPEncURI11;
const nsLiteralString kXSIURI;
const nsLiteralString kXSURI;
const nsLiteralString kXSIURI1999;
const nsLiteralString kXSURI1999;
const nsLiteralString kSOAPEnvPrefix;
const nsLiteralString kSOAPEncPrefix;
const nsLiteralString kXSIPrefix;
const nsLiteralString kXSITypeAttribute;
const nsLiteralString kXSPrefix;
const nsLiteralString kEncodingStyleAttribute;
const nsLiteralString kActorAttribute;
const nsLiteralString kMustUnderstandAttribute;
const nsLiteralString kEnvelopeTagName;
const nsLiteralString kHeaderTagName;
const nsLiteralString kBodyTagName;
const nsLiteralString kFaultTagName;
const nsLiteralString kFaultCodeTagName;
const nsLiteralString kFaultStringTagName;
const nsLiteralString kFaultActorTagName;
const nsLiteralString kFaultDetailTagName;
const nsLiteralString kEncodingSeparator;
const nsLiteralString kQualifiedSeparator;
const nsLiteralString kXMLNamespaceNamespaceURI;
const nsLiteralString kXMLNamespaceURI;
const nsLiteralString kXMLNamespacePrefix;
const nsLiteralString kXMLPrefix;
const nsLiteralString kTrue;
const nsLiteralString kTrueA;
const nsLiteralString kFalse;
const nsLiteralString kFalseA;
const nsLiteralString kVerifySourceHeader;
const nsLiteralString kVerifySourceURI;
const nsLiteralString kVerifySourceNamespaceURI;
// used by nsDefaultSOAPEncoder.cpp
const nsLiteralString kEmpty;
const nsLiteralString kNull;
const nsLiteralString kSOAPArrayTypeAttribute;
const nsLiteralString kSOAPArrayOffsetAttribute;
const nsLiteralString kSOAPArrayPositionAttribute;
const nsLiteralString kAnyTypeSchemaType;
const nsLiteralString kAnySimpleTypeSchemaType;
const nsLiteralString kArraySOAPType;
const nsLiteralString kStructSOAPType;
const nsLiteralString kStringSchemaType;
const nsLiteralString kBooleanSchemaType;
const nsLiteralString kFloatSchemaType;
const nsLiteralString kDoubleSchemaType;
const nsLiteralString kLongSchemaType;
const nsLiteralString kIntSchemaType;
const nsLiteralString kShortSchemaType;
const nsLiteralString kByteSchemaType;
const nsLiteralString kUnsignedLongSchemaType;
const nsLiteralString kUnsignedIntSchemaType;
const nsLiteralString kUnsignedShortSchemaType;
const nsLiteralString kUnsignedByteSchemaType;
const nsLiteralString kNormalizedStringSchemaType;
const nsLiteralString kTokenSchemaType;
const nsLiteralString kNameSchemaType;
const nsLiteralString kNCNameSchemaType;
const nsLiteralString kDecimalSchemaType;
const nsLiteralString kIntegerSchemaType;
const nsLiteralString kNonPositiveIntegerSchemaType;
const nsLiteralString kNonNegativeIntegerSchemaType;
nsSOAPStrings();
};
extern nsSOAPStrings *gSOAPStrings;
// Used to support null strings.
inline PRBool AStringIsNull(const nsAString & aString)
@ -136,7 +172,6 @@ inline PRBool AStringIsNull(const nsAString & aString)
inline void SetAStringToNull(nsAString & aString)
{
aString.Truncate();
aString.SetIsVoid(PR_TRUE);
}
@ -147,9 +182,7 @@ inline void
SOAPEncodingKey(const nsAString & aURI, const nsAString & aType,
nsAString & result)
{
result.Assign(aURI);
result.Append(nsSOAPUtils::kEncodingSeparator);
result.Append(aType);
result = aURI + gSOAPStrings->kEncodingSeparator + aType;
}
#endif

Просмотреть файл

@ -62,7 +62,7 @@
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_NAMED_LITERAL_CSTRING(REL_FILE_PREF_SUFFIX, "-rel");
#define REL_FILE_PREF_SUFFIX NS_LITERAL_CSTRING("-rel")
NS_IMPL_THREADSAFE_ISUPPORTS1(nsMsgIdentity,
nsIMsgIdentity)

Просмотреть файл

@ -82,7 +82,7 @@
#define PORT_NOT_SET -1
NS_NAMED_LITERAL_CSTRING(REL_FILE_PREF_SUFFIX, "-rel");
#define REL_FILE_PREF_SUFFIX NS_LITERAL_CSTRING("-rel")
MOZ_DECL_CTOR_COUNTER(nsMsgIncomingServer)

Просмотреть файл

@ -129,8 +129,6 @@ nsIndexedToHTML::AsyncConvertData(const PRUnichar *aFromType,
return Init(aListener);
}
static NS_NAMED_LITERAL_STRING(tableHeading,"<table>\n");
NS_IMETHODIMP
nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) {
nsresult rv;
@ -322,7 +320,7 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) {
ConvertNonAsciiToNCR(title, strNCR);
buffer.Append(strNCR);
buffer.Append(NS_LITERAL_STRING("</h1>\n<hr/>") + tableHeading);
buffer.Append(NS_LITERAL_STRING("</h1>\n<hr/><table>\n"));
//buffer.Append(NS_LITERAL_STRING("<tr><th>Name</th><th>Size</th><th>Last modified</th></tr>\n"));
@ -575,7 +573,7 @@ nsIndexedToHTML::OnIndexAvailable(nsIRequest *aRequest,
// Split this up to avoid slow layout performance with large tables
// - bug 85381
if (++mRowCount > ROWS_PER_TABLE) {
pushBuffer.Append(NS_LITERAL_STRING("</table>\n") + tableHeading);
pushBuffer.Append(NS_LITERAL_STRING("</table>\n<table>\n"));
mRowCount = 0;
}

Просмотреть файл

@ -1377,9 +1377,10 @@ NS_IMETHODIMP nsProfile::ShutDownCurrentProfile(PRUint32 shutDownType)
#define SALT_SIZE 8
#define TABLE_SIZE 36
NS_NAMED_LITERAL_CSTRING(kSaltExtensionCString, ".slt");
static const char kSaltExtensionCString[] = ".slt";
#define kSaltExtensionCString_Len PRUint32(sizeof(kSaltExtensionCString)-1)
const char table[] =
static const char table[] =
{ 'a','b','c','d','e','f','g','h','i','j',
'k','l','m','n','o','p','q','r','s','t',
'u','v','w','x','y','z','0','1','2','3',
@ -1435,9 +1436,11 @@ nsProfile::AddLevelOfIndirection(nsIFile *aDir)
if (NS_SUCCEEDED(rv) && !leafName.IsEmpty()) {
PRUint32 length = leafName.Length();
// check if the filename is the right length, len("xxxxxxxx.slt")
if (length == (SALT_SIZE + kSaltExtensionCString.Length())) {
if (length == (SALT_SIZE + kSaltExtensionCString_Len)) {
// check that the filename ends with ".slt"
if (nsCRT::strncmp(leafName.get() + SALT_SIZE, kSaltExtensionCString.get(), kSaltExtensionCString.Length()) == 0) {
if (nsCRT::strncmp(leafName.get() + SALT_SIZE,
kSaltExtensionCString,
kSaltExtensionCString_Len) == 0) {
// found a salt directory, use it
rv = aDir->AppendNative(leafName);
return rv;
@ -1463,7 +1466,7 @@ nsProfile::AddLevelOfIndirection(nsIFile *aDir)
for (i=0;i<SALT_SIZE;i++) {
saltStr.Append(table[rand()%TABLE_SIZE]);
}
saltStr.Append(kSaltExtensionCString);
saltStr.Append(kSaltExtensionCString, kSaltExtensionCString_Len);
#ifdef DEBUG_profile_verbose
printf("directory name: %s\n",saltStr.get());
#endif
@ -1494,15 +1497,16 @@ nsresult nsProfile::IsProfileDirSalted(nsIFile *profileDir, PRBool *isSalted)
if (NS_FAILED(rv)) return rv;
PRBool endsWithSalt = PR_FALSE;
if (leafName.Length() >= kSaltExtensionCString.Length())
if (leafName.Length() >= kSaltExtensionCString_Len)
{
nsReadingIterator<char> stringEnd;
leafName.EndReading(stringEnd);
nsReadingIterator<char> stringStart = stringEnd;
stringStart.advance( -(NS_STATIC_CAST(PRInt32, kSaltExtensionCString.Length())) );
stringStart.advance( -(NS_STATIC_CAST(PRInt32, kSaltExtensionCString_Len)) );
endsWithSalt = kSaltExtensionCString.Equals(Substring(stringStart, stringEnd));
endsWithSalt =
Substring(stringStart, stringEnd).Equals(kSaltExtensionCString);
}
if (!endsWithSalt)
return NS_OK;

Просмотреть файл

@ -66,11 +66,15 @@ literal_string( const nsACString::char_type* aPtr, PRUint32 aLength )
#ifdef HAVE_CPP_2BYTE_WCHAR_T
#define NS_LL(s) L##s
#define NS_MULTILINE_LITERAL_STRING(s) nsDependentString(NS_REINTERPRET_CAST(const nsAString::char_type*, s), PRUint32((sizeof(s)/sizeof(wchar_t))-1))
#define NS_MULTILINE_LITERAL_STRING_INIT(n,s) n(NS_REINTERPRET_CAST(const nsAString::char_type*, s), PRUint32((sizeof(s)/sizeof(wchar_t))-1))
#define NS_NAMED_MULTILINE_LITERAL_STRING(n,s) nsDependentString n(NS_REINTERPRET_CAST(const nsAString::char_type*, s), PRUint32((sizeof(s)/sizeof(wchar_t))-1))
typedef nsDependentString nsLiteralString;
#else
#define NS_LL(s) s
#define NS_MULTILINE_LITERAL_STRING(s) NS_ConvertASCIItoUTF16(s, PRUint32(sizeof(s)-1))
#define NS_MULTILINE_LITERAL_STRING_INIT(n,s) n(s, PRUint32(sizeof(s)-1))
#define NS_NAMED_MULTILINE_LITERAL_STRING(n,s) NS_ConvertASCIItoUTF16 n(s, PRUint32(sizeof(s)-1))
typedef NS_ConvertASCIItoUTF16 nsLiteralString;
#endif
/*
@ -85,9 +89,13 @@ literal_string( const nsACString::char_type* aPtr, PRUint32 aLength )
#define NS_L(s) NS_LL(s)
#define NS_LITERAL_STRING(s) NS_STATIC_CAST(const nsAFlatString&, NS_MULTILINE_LITERAL_STRING(NS_LL(s)))
#define NS_LITERAL_STRING_INIT(n,s) NS_MULTILINE_LITERAL_STRING_INIT(n, NS_LL(s))
#define NS_NAMED_LITERAL_STRING(n,s) NS_NAMED_MULTILINE_LITERAL_STRING(n, NS_LL(s))
#define NS_LITERAL_CSTRING(s) nsDependentCString(s, PRUint32(sizeof(s)-1))
#define NS_LITERAL_CSTRING_INIT(n,s) n(s, PRUint32(sizeof(s)-1))
#define NS_NAMED_LITERAL_CSTRING(n,s) nsDependentCString n(s, PRUint32(sizeof(s)-1))
typedef nsDependentCString nsLiteralCString;
#endif /* !defined(nsLiteralString_h___) */

Просмотреть файл

@ -528,13 +528,17 @@ nsTSubstring_CharT::Equals( const abstract_string_type& readable, const comparat
PRBool
nsTSubstring_CharT::Equals( const char_type* data ) const
{
return Equals(nsTDependentString_CharT(data));
// XXX avoid length calculation?
size_type length = char_traits::length(data);
return mLength == length && char_traits::compare(mData, data, mLength) == 0;
}
PRBool
nsTSubstring_CharT::Equals( const char_type* data, const comparator_type& comp ) const
{
return Equals(nsTDependentString_CharT(data), comp);
// XXX avoid length calculation?
size_type length = char_traits::length(data);
return mLength == length && comp(mData, data, mLength) == 0;
}
nsTSubstring_CharT::size_type

Просмотреть файл

@ -49,6 +49,7 @@
#include "nsCommandLineService.h"
#include "nsAppShellService.h"
#include "nsWindowMediator.h"
#include "nsChromeTreeOwner.h"
#include "nsUserInfo.h"
@ -89,5 +90,18 @@ static const nsModuleComponentInfo gAppShellModuleInfo[] =
},
};
NS_IMPL_NSGETMODULE(appshell, gAppShellModuleInfo)
PR_STATIC_CALLBACK(nsresult)
nsAppShellModuleConstructor(nsIModule *aModule)
{
return nsChromeTreeOwner::InitGlobals();
}
PR_STATIC_CALLBACK(void)
nsAppShellModuleDestructor(nsIModule *aModule)
{
nsChromeTreeOwner::FreeGlobals();
}
NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(appshell, gAppShellModuleInfo,
nsAppShellModuleConstructor,
nsAppShellModuleDestructor)

Просмотреть файл

@ -48,6 +48,50 @@
// CIDs
static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
//*****************************************************************************
// nsChromeTreeOwner string literals
//*****************************************************************************
struct nsChromeTreeOwnerLiterals
{
const nsLiteralString kPersist;
const nsLiteralString kScreenX;
const nsLiteralString kScreenY;
const nsLiteralString kWidth;
const nsLiteralString kHeight;
const nsLiteralString kSizemode;
const nsLiteralString kSpace;
nsChromeTreeOwnerLiterals()
: NS_LITERAL_STRING_INIT(kPersist,"persist")
, NS_LITERAL_STRING_INIT(kScreenX,"screenX")
, NS_LITERAL_STRING_INIT(kScreenY,"screenY")
, NS_LITERAL_STRING_INIT(kWidth,"width")
, NS_LITERAL_STRING_INIT(kHeight,"height")
, NS_LITERAL_STRING_INIT(kSizemode,"sizemode")
, NS_LITERAL_STRING_INIT(kSpace," ")
{}
};
static nsChromeTreeOwnerLiterals *gLiterals;
nsresult
nsChromeTreeOwner::InitGlobals()
{
NS_ASSERTION(gLiterals == nsnull, "already initialized");
gLiterals = new nsChromeTreeOwnerLiterals();
if (!gLiterals)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
void
nsChromeTreeOwner::FreeGlobals()
{
delete gLiterals;
gLiterals = nsnull;
}
//*****************************************************************************
//*** nsChromeTreeOwner: Object Management
//*****************************************************************************
@ -197,14 +241,6 @@ NS_IMETHODIMP nsChromeTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem,
return mXULWindow->SizeShellTo(aShellItem, aCX, aCY);
}
NS_NAMED_LITERAL_STRING(gLiteralPersist,"persist");
NS_NAMED_LITERAL_STRING(gLiteralScreenX,"screenX");
NS_NAMED_LITERAL_STRING(gLiteralScreenY,"screenY");
NS_NAMED_LITERAL_STRING(gLiteralWidth,"width");
NS_NAMED_LITERAL_STRING(gLiteralHeight,"height");
NS_NAMED_LITERAL_STRING(gLiteralSizemode,"sizemode");
NS_NAMED_LITERAL_STRING(gLiteralSpace," ");
NS_IMETHODIMP
nsChromeTreeOwner::SetPersistence(PRBool aPersistPosition,
PRBool aPersistSize,
@ -216,28 +252,28 @@ nsChromeTreeOwner::SetPersistence(PRBool aPersistPosition,
return NS_ERROR_FAILURE;
nsAutoString persistString;
docShellElement->GetAttribute(gLiteralPersist, persistString);
docShellElement->GetAttribute(gLiterals->kPersist, persistString);
PRBool saveString = PR_FALSE;
PRInt32 index;
#define FIND_PERSIST_STRING(aString, aCond) \
index = persistString.Find(aString); \
if (!aCond && index > kNotFound) { \
persistString.Cut(index, aString.Length()); \
saveString = PR_TRUE; \
} else if (aCond && index == kNotFound) { \
persistString.Append(gLiteralSpace+aString); \
saveString = PR_TRUE; \
#define FIND_PERSIST_STRING(aString, aCond) \
index = persistString.Find(aString); \
if (!aCond && index > kNotFound) { \
persistString.Cut(index, aString.Length()); \
saveString = PR_TRUE; \
} else if (aCond && index == kNotFound) { \
persistString.Append(gLiterals->kSpace + aString); \
saveString = PR_TRUE; \
}
FIND_PERSIST_STRING(gLiteralScreenX, aPersistPosition);
FIND_PERSIST_STRING(gLiteralScreenY, aPersistPosition);
FIND_PERSIST_STRING(gLiteralWidth, aPersistSize);
FIND_PERSIST_STRING(gLiteralHeight, aPersistSize);
FIND_PERSIST_STRING(gLiteralSizemode, aPersistSizeMode);
FIND_PERSIST_STRING(gLiterals->kScreenX, aPersistPosition);
FIND_PERSIST_STRING(gLiterals->kScreenY, aPersistPosition);
FIND_PERSIST_STRING(gLiterals->kWidth, aPersistSize);
FIND_PERSIST_STRING(gLiterals->kHeight, aPersistSize);
FIND_PERSIST_STRING(gLiterals->kSizemode, aPersistSizeMode);
if (saveString)
docShellElement->SetAttribute(gLiteralPersist, persistString);
docShellElement->SetAttribute(gLiterals->kPersist, persistString);
return NS_OK;
}
@ -253,18 +289,18 @@ nsChromeTreeOwner::GetPersistence(PRBool* aPersistPosition,
return NS_ERROR_FAILURE;
nsAutoString persistString;
docShellElement->GetAttribute(gLiteralPersist, persistString);
docShellElement->GetAttribute(gLiterals->kPersist, persistString);
// data structure doesn't quite match the question, but it's close enough
// for what we want (since this method is never actually called...)
if (aPersistPosition)
*aPersistPosition = persistString.Find(gLiteralScreenX) > kNotFound ||
persistString.Find(gLiteralScreenY) > kNotFound;
*aPersistPosition = persistString.Find(gLiterals->kScreenX) > kNotFound ||
persistString.Find(gLiterals->kScreenY) > kNotFound;
if (aPersistSize)
*aPersistSize = persistString.Find(gLiteralWidth) > kNotFound ||
persistString.Find(gLiteralHeight) > kNotFound;
*aPersistSize = persistString.Find(gLiterals->kWidth) > kNotFound ||
persistString.Find(gLiterals->kHeight) > kNotFound;
if (aPersistSizeMode)
*aPersistSizeMode = persistString.Find(gLiteralSizemode) > kNotFound;
*aPersistSizeMode = persistString.Find(gLiterals->kSizemode) > kNotFound;
return NS_OK;
}

Просмотреть файл

@ -52,6 +52,9 @@ public:
NS_DECL_NSIDOCSHELLTREEOWNER
NS_DECL_NSIWEBPROGRESSLISTENER
static nsresult InitGlobals();
static void FreeGlobals();
protected:
nsChromeTreeOwner();
virtual ~nsChromeTreeOwner();

Просмотреть файл

@ -122,7 +122,6 @@ static void CloneCStringArray(const nsCStringArray& src, nsCStringArray& dest)
}
}
NS_NAMED_LITERAL_STRING(gCharsetMenuSelectedTopic, "charsetmenu-selected");
//----------------------------------------------------------------------------
// Class nsMenuEntry [declaration]