本文整理汇总了C++中NS_ConvertASCIItoUTF16函数的典型用法代码示例。如果您正苦于以下问题:C++ NS_ConvertASCIItoUTF16函数的具体用法?C++ NS_ConvertASCIItoUTF16怎么用?C++ NS_ConvertASCIItoUTF16使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NS_ConvertASCIItoUTF16函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FinishInternal
void
Decoder::Finish()
{
// Implementation-specific finalization
if (!HasError())
FinishInternal();
// If the implementation left us mid-frame, finish that up.
if (mInFrame && !HasDecoderError())
PostFrameStop();
// If PostDecodeDone() has not been called, we need to sent teardown
// notifications.
if (!IsSizeDecode() && !mDecodeDone) {
// Log data errors to the error console
nsCOMPtr<nsIConsoleService> consoleService =
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
nsCOMPtr<nsIScriptError> errorObject =
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
if (consoleService && errorObject && !HasDecoderError()) {
nsAutoString msg(NS_LITERAL_STRING("Image corrupt or truncated: ") +
NS_ConvertASCIItoUTF16(mImage.GetURIString()));
if (NS_SUCCEEDED(errorObject->InitWithWindowID(
msg.get(),
NS_ConvertUTF8toUTF16(mImage.GetURIString()).get(),
nsnull, 0, 0, nsIScriptError::errorFlag,
"Image", mImage.InnerWindowID()
))) {
consoleService->LogMessage(errorObject);
}
}
// If we only have a data error, see if things are worth salvaging
bool salvage = !HasDecoderError() && mImage.GetNumFrames();
// If we're salvaging, say we finished decoding
if (salvage)
mImage.DecodingComplete();
// Fire teardown notifications
if (mObserver) {
mObserver->OnStopContainer(nsnull, &mImage);
mObserver->OnStopDecode(nsnull, salvage ? NS_OK : NS_ERROR_FAILURE, nsnull);
}
}
}
示例2: ArrayLength
void
ErrorReporter::ReportUnexpected(const char *aMessage,
const nsCSSToken &aToken)
{
if (!ShouldReportErrors()) return;
nsAutoString tokenString;
aToken.AppendToString(tokenString);
const PRUnichar *params[1] = { tokenString.get() };
nsAutoString str;
sStringBundle->FormatStringFromName(NS_ConvertASCIItoUTF16(aMessage).get(),
params, ArrayLength(params),
getter_Copies(str));
AddToError(str);
}
示例3: memset
void
MediaEngineWebrtcAudioSource::GetUUID(nsAString& aUUID)
{
char deviceName[KMaxDeviceNameLength];
memset(deviceName, 0, KMaxDeviceNameLength);
char uniqueId[KMaxUniqueIdLength];
memset(uniqueId, 0, KMaxUniqueIdLength);
if(true == mInitDone )
{
mVoEHw->GetRecordingDeviceName(
mCapIndex, deviceName, uniqueId );
aUUID.Assign(NS_ConvertASCIItoUTF16(uniqueId));
}
return;
}
示例4: memset
void
MediaEngineWebRTCVideoSource::GetUUID(nsAString& aUUID)
{
char deviceName[KMaxDeviceNameLength];
memset(deviceName, 0, KMaxDeviceNameLength);
char uniqueId[KMaxUniqueIdLength];
memset(uniqueId, 0, KMaxUniqueIdLength);
if (mInitDone) {
mViECapture->GetCaptureDevice(
mCapIndex, deviceName, KMaxDeviceNameLength, uniqueId, KMaxUniqueIdLength
);
aUUID.Assign(NS_ConvertASCIItoUTF16(uniqueId));
}
}
示例5: NS_NewISupportsArray
/* void openProgressDialog (in nsIDOMWindow parent, in string dialogURL, in nsISupports parameters); */
NS_IMETHODIMP nsPrintProgress::OpenProgressDialog(nsIDOMWindow *parent,
const char *dialogURL,
nsISupports *parameters,
nsIObserver *openDialogObserver,
bool *notifyOnOpen)
{
m_observer = openDialogObserver;
nsresult rv = NS_ERROR_FAILURE;
if (m_dialog)
return NS_ERROR_ALREADY_INITIALIZED;
if (!dialogURL || !*dialogURL)
return NS_ERROR_INVALID_ARG;
if (parent)
{
// Set up window.arguments[0]...
nsCOMPtr<nsISupportsArray> array;
rv = NS_NewISupportsArray(getter_AddRefs(array));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISupportsInterfacePointer> ifptr =
do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
ifptr->SetData(static_cast<nsIPrintProgress*>(this));
ifptr->SetDataIID(&NS_GET_IID(nsIPrintProgress));
array->AppendElement(ifptr);
array->AppendElement(parameters);
// Open the dialog.
nsCOMPtr<nsIDOMWindow> newWindow;
rv = parent->OpenDialog(NS_ConvertASCIItoUTF16(dialogURL),
NS_LITERAL_STRING("_blank"),
NS_LITERAL_STRING("chrome,titlebar,dependent,centerscreen"),
array, getter_AddRefs(newWindow));
if (NS_SUCCEEDED(rv)) {
*notifyOnOpen = true;
}
}
return rv;
}
示例6: parentWindow
NS_IMETHODIMP
nsXPInstallManager::ConfirmInstall(nsIDOMWindow *aParent, const PRUnichar **aPackageList, PRUint32 aCount, PRBool *aRetval)
{
*aRetval = PR_FALSE;
nsCOMPtr<nsIDOMWindowInternal> parentWindow( do_QueryInterface(aParent) );
nsCOMPtr<nsIDialogParamBlock> params;
nsresult rv = LoadParams( aCount, aPackageList, getter_AddRefs(params) );
if ( NS_SUCCEEDED(rv) && parentWindow && params)
{
nsCOMPtr<nsIDOMWindow> newWindow;
nsCOMPtr<nsISupportsInterfacePointer> ifptr =
do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
ifptr->SetData(params);
ifptr->SetDataIID(&NS_GET_IID(nsIDialogParamBlock));
char* confirmDialogURL;
nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
if (!pref)
return rv;
rv = pref->GetCharPref(PREF_XPINSTALL_CONFIRM_DLG, &confirmDialogURL);
NS_ASSERTION(NS_SUCCEEDED(rv), "Can't invoke XPInstall FE without a FE URL! Set xpinstall.dialog.confirm");
if (NS_FAILED(rv))
return rv;
rv = parentWindow->OpenDialog(NS_ConvertASCIItoUTF16(confirmDialogURL),
NS_LITERAL_STRING("_blank"),
NS_LITERAL_STRING("chrome,centerscreen,modal,titlebar"),
ifptr,
getter_AddRefs(newWindow));
if (NS_SUCCEEDED(rv))
{
//Now get which button was pressed from the ParamBlock
PRInt32 buttonPressed = 0;
params->GetInt( 0, &buttonPressed );
*aRetval = buttonPressed ? PR_FALSE : PR_TRUE;
}
}
return rv;
}
示例7: Validate
nsresult Validate()
{
// Verify cert is self-signed
bool selfSigned;
nsresult rv = mCert->GetIsSelfSigned(&selfSigned);
if (NS_FAILED(rv)) {
return rv;
}
if (!selfSigned) {
return NS_ERROR_FAILURE;
}
// Check that subject and issuer match nickname
nsXPIDLString subjectName;
nsXPIDLString issuerName;
mCert->GetSubjectName(subjectName);
mCert->GetIssuerName(issuerName);
if (!subjectName.Equals(issuerName)) {
return NS_ERROR_FAILURE;
}
NS_NAMED_LITERAL_STRING(commonNamePrefix, "CN=");
nsAutoString subjectNameFromNickname(
commonNamePrefix + NS_ConvertASCIItoUTF16(mNickname));
if (!subjectName.Equals(subjectNameFromNickname)) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIX509CertValidity> validity;
mCert->GetValidity(getter_AddRefs(validity));
PRTime notBefore, notAfter;
validity->GetNotBefore(¬Before);
validity->GetNotAfter(¬After);
// Ensure cert will last at least one more day
static const PRTime oneDay = PRTime(PR_USEC_PER_SEC)
* PRTime(60) // sec
* PRTime(60) // min
* PRTime(24); // hours
PRTime now = PR_Now();
if (notBefore > now ||
notAfter < (now - oneDay)) {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
示例8: NS_ENSURE_TRUE
bool
nsXHTMLContentSerializer::AfterElementStart(nsIContent* aContent,
nsIContent* aOriginalElement,
nsAString& aStr)
{
nsIAtom *name = aContent->Tag();
if (aContent->GetNameSpaceID() == kNameSpaceID_XHTML &&
mRewriteEncodingDeclaration &&
name == nsGkAtoms::head) {
// Check if there already are any content-type meta children.
// If there are, they will be modified to use the correct charset.
// If there aren't, we'll insert one here.
bool hasMeta = false;
for (nsIContent* child = aContent->GetFirstChild();
child;
child = child->GetNextSibling()) {
if (child->IsHTML(nsGkAtoms::meta) &&
child->HasAttr(kNameSpaceID_None, nsGkAtoms::content)) {
nsAutoString header;
child->GetAttr(kNameSpaceID_None, nsGkAtoms::httpEquiv, header);
if (header.LowerCaseEqualsLiteral("content-type")) {
hasMeta = true;
break;
}
}
}
if (!hasMeta) {
NS_ENSURE_TRUE(AppendNewLineToString(aStr), false);
if (mDoFormat) {
NS_ENSURE_TRUE(AppendIndentation(aStr), false);
}
NS_ENSURE_TRUE(AppendToString(NS_LITERAL_STRING("<meta http-equiv=\"content-type\""), aStr), false);
NS_ENSURE_TRUE(AppendToString(NS_LITERAL_STRING(" content=\"text/html; charset="), aStr), false);
NS_ENSURE_TRUE(AppendToString(NS_ConvertASCIItoUTF16(mCharset), aStr), false);
if (mIsHTMLSerializer) {
NS_ENSURE_TRUE(AppendToString(NS_LITERAL_STRING("\">"), aStr), false);
} else {
NS_ENSURE_TRUE(AppendToString(NS_LITERAL_STRING("\" />"), aStr), false);
}
}
}
return true;
}
示例9: ReportUnexpectedEOF
// aMessage must take no parameters
void nsCSSScanner::ReportUnexpectedEOF(const char* aLookingFor)
{
ENSURE_STRINGBUNDLE;
nsXPIDLString innerStr;
gStringBundle->GetStringFromName(NS_ConvertASCIItoUTF16(aLookingFor).get(),
getter_Copies(innerStr));
const PRUnichar *params[] = {
innerStr.get()
};
nsXPIDLString str;
gStringBundle->FormatStringFromName(NS_LITERAL_STRING("PEUnexpEOF").get(),
params, NS_ARRAY_LENGTH(params),
getter_Copies(str));
AddToError(str);
}
示例10: strWrapper
NS_IMETHODIMP
nsCategoryObserver::Observe(nsISupports* aSubject, const char* aTopic,
const PRUnichar* aData) {
if (!mListener)
return NS_OK;
if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
mHash.Clear();
mListener->CategoryCleared();
return NS_OK;
}
if (!aData ||
!nsDependentString(aData).Equals(NS_ConvertASCIItoUTF16(mCategory)))
return NS_OK;
nsCAutoString str;
nsCOMPtr<nsISupportsCString> strWrapper(do_QueryInterface(aSubject));
if (strWrapper)
strWrapper->GetData(str);
if (strcmp(aTopic, NS_XPCOM_CATEGORY_ENTRY_ADDED_OBSERVER_ID) == 0) {
nsCOMPtr<nsICategoryManager> catMan =
do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
if (!catMan)
return NS_OK;
nsCString entryValue;
catMan->GetCategoryEntry(mCategory.get(),
str.get(),
getter_Copies(entryValue));
mHash.Put(str, entryValue);
mListener->EntryAdded(entryValue);
} else if (strcmp(aTopic, NS_XPCOM_CATEGORY_ENTRY_REMOVED_OBSERVER_ID) == 0) {
nsCAutoString val;
if (mHash.Get(str, &val)) {
mHash.Remove(str);
mListener->EntryRemoved(val);
}
} else if (strcmp(aTopic, NS_XPCOM_CATEGORY_CLEARED_OBSERVER_ID) == 0) {
mHash.Clear();
mListener->CategoryCleared();
}
return NS_OK;
}
示例11: NS_TIMELINE_START_TIMER
//--------------------------------------------------------------
NS_IMETHODIMP nsCharsetAlias2::GetPreferred(const nsACString& aAlias,
nsACString& oResult)
{
if (aAlias.IsEmpty()) return NS_ERROR_NULL_POINTER;
NS_TIMELINE_START_TIMER("nsCharsetAlias2:GetPreferred");
// Delay loading charsetalias.properties by hardcoding the most
// frequent aliases. Note that it's possible to recur in to this
// function *while loading* charsetalias.properties (see bug 190951),
// so we might have an |mDelegate| already that isn't valid yet, but
// the load is guaranteed to be "UTF-8" so things will be OK.
for (PRUint32 index = 0; index < NS_ARRAY_LENGTH(kAliases); index++) {
if (aAlias.LowerCaseEqualsASCII(kAliases[index][0])) {
oResult.Assign(nsDependentCString(kAliases[index][1],
NS_PTR_TO_UINT32(kAliases[index][2])));
NS_TIMELINE_STOP_TIMER("nsCharsetAlias2:GetPreferred");
return NS_OK;
}
}
oResult.Truncate();
if(!mDelegate) {
//load charsetalias.properties string bundle with all remaining aliases
// we may need to protect the following section with a lock so we won't call the
// 'new nsGREResProperties' from two different threads
mDelegate = new nsGREResProperties( NS_LITERAL_CSTRING("charsetalias.properties") );
NS_ASSERTION(mDelegate, "cannot create nsGREResProperties");
if(nsnull == mDelegate)
return NS_ERROR_OUT_OF_MEMORY;
}
NS_TIMELINE_STOP_TIMER("nsCharsetAlias2:GetPreferred");
NS_TIMELINE_MARK_TIMER("nsCharsetAlias2:GetPreferred");
nsCAutoString key(aAlias);
ToLowerCase(key);
// hack for now, have to fix nsGREResProperties, but we can't until
// string bundles use UTF8 keys
nsAutoString result;
nsresult rv = mDelegate->Get(NS_ConvertASCIItoUTF16(key), result);
LossyAppendUTF16toASCII(result, oResult);
return rv;
}
示例12: NS_ENSURE_ARG_POINTER
nsresult
sbSecurityMixin::DispatchNotificationEvent(const char* aNotificationType,
const Scope* aScope,
bool aHasAccess)
{
// NOTE: This method only /tries/ to dispatch the notification event.
// If there's no notification document then it fails mostly silently.
// This is intentional since there might be cases where this mixin is
// used when no notification document is available.
NS_ENSURE_ARG_POINTER(aNotificationType);
NS_ENSURE_ARG_POINTER(aScope);
// TODO: we need to add the notification type to the event eventually
// get it? event eventually...
LOG(( "sbSecurityMixin::DispatchNotificationEvent(%s)", aNotificationType ));
// see if we've got a document to dispatch events to
if ( mNotificationDocument ) {
LOG(( "sbSecurityMixin::DispatchNotificationEvent - dispatching event" ));
nsCOMPtr<sbIRemotePlayer> remotePlayer;
nsresult rv = mOuter->GetRemotePlayer(getter_AddRefs(remotePlayer));
// objects that do not return a remote player do not want to trigger notifications because
// they are owned by other objects that supercede them in the security hierarchy.
if(NS_SUCCEEDED(rv)) {
return sbRemotePlayer::DispatchSecurityEvent( mNotificationDocument,
remotePlayer,
RAPI_EVENT_CLASS,
RAPI_EVENT_TYPE,
NS_ConvertASCIItoUTF16(aScope->name),
aHasAccess,
PR_TRUE );
}
} else {
LOG(( "sbSecurityMixin::DispatchNotificationEvent - not dispatching event" ));
NS_WARNING( "sbSecurityMixin::DispatchNotificationEvent didn't have a notification document to dispatch to" );
}
return NS_OK;
}
示例13: AppendNewLineToString
void
nsXHTMLContentSerializer::AfterElementStart(nsIContent * aContent,
nsIDOMElement *aOriginalElement,
nsAString& aStr)
{
nsIAtom *name = aContent->Tag();
if (aContent->GetNameSpaceID() == kNameSpaceID_XHTML &&
mRewriteEncodingDeclaration &&
name == nsGkAtoms::head) {
// Check if there already are any content-type meta children.
// If there are, they will be modified to use the correct charset.
// If there aren't, we'll insert one here.
PRBool hasMeta = PR_FALSE;
PRUint32 i, childCount = aContent->GetChildCount();
for (i = 0; i < childCount; ++i) {
nsIContent* child = aContent->GetChildAt(i);
if (child->IsHTML() &&
child->Tag() == nsGkAtoms::meta &&
child->HasAttr(kNameSpaceID_None, nsGkAtoms::content)) {
nsAutoString header;
child->GetAttr(kNameSpaceID_None, nsGkAtoms::httpEquiv, header);
if (header.LowerCaseEqualsLiteral("content-type")) {
hasMeta = PR_TRUE;
break;
}
}
}
if (!hasMeta) {
AppendNewLineToString(aStr);
if (mDoFormat) {
AppendIndentation(aStr);
}
AppendToString(NS_LITERAL_STRING("<meta http-equiv=\"content-type\""),
aStr);
AppendToString(NS_LITERAL_STRING(" content=\"text/html; charset="), aStr);
AppendToString(NS_ConvertASCIItoUTF16(mCharset), aStr);
if (mIsHTMLSerializer)
AppendToString(NS_LITERAL_STRING("\">"), aStr);
else
AppendToString(NS_LITERAL_STRING("\" />"), aStr);
}
}
}
示例14: subImpls
already_AddRefed<Blob>
BlobSet::GetBlobInternal(nsISupports* aParent,
const nsACString& aContentType,
ErrorResult& aRv)
{
nsTArray<RefPtr<BlobImpl>> subImpls(GetBlobImpls());
RefPtr<BlobImpl> blobImpl =
MultipartBlobImpl::Create(Move(subImpls),
NS_ConvertASCIItoUTF16(aContentType),
aRv);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
RefPtr<Blob> blob = Blob::Create(aParent, blobImpl);
return blob.forget();
}
示例15: SetMsgWindow
NS_IMETHODIMP nsMsgProgress::OpenProgressDialog(nsIDOMWindowInternal *parent,
nsIMsgWindow *aMsgWindow,
const char *dialogURL,
PRBool inDisplayModal,
nsISupports *parameters)
{
nsresult rv;
if (aMsgWindow)
{
SetMsgWindow(aMsgWindow);
aMsgWindow->SetStatusFeedback(this);
}
NS_ENSURE_TRUE(!m_dialog, NS_ERROR_ALREADY_INITIALIZED);
NS_ENSURE_ARG_POINTER(dialogURL);
NS_ENSURE_ARG_POINTER(parent);
// Set up window.arguments[0]...
nsCOMPtr<nsISupportsArray> array;
rv = NS_NewISupportsArray(getter_AddRefs(array));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISupportsInterfacePointer> ifptr =
do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
ifptr->SetData(static_cast<nsIMsgProgress*>(this));
ifptr->SetDataIID(&NS_GET_IID(nsIMsgProgress));
array->AppendElement(ifptr);
array->AppendElement(parameters);
// Open the dialog.
nsCOMPtr<nsIDOMWindow> newWindow;
nsString chromeOptions(NS_LITERAL_STRING("chrome,titlebar,dependent"));
if (inDisplayModal)
chromeOptions.AppendLiteral(",modal");
return parent->OpenDialog(NS_ConvertASCIItoUTF16(dialogURL),
NS_LITERAL_STRING("_blank"),
chromeOptions,
array, getter_AddRefs(newWindow));
}