本文整理汇总了C++中nsCString::AssignLiteral方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCString::AssignLiteral方法的具体用法?C++ nsCString::AssignLiteral怎么用?C++ nsCString::AssignLiteral使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCString
的用法示例。
在下文中一共展示了nsCString::AssignLiteral方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getNumberOfCameras
nsresult
ICameraControl::GetCameraName(uint32_t aDeviceNum, nsCString& aDeviceName)
{
int32_t count = android::Camera::getNumberOfCameras();
int32_t deviceNum = static_cast<int32_t>(aDeviceNum);
DOM_CAMERA_LOGI("GetCameraName : getNumberOfCameras() returned %d\n", count);
if (deviceNum < 0 || deviceNum > count) {
DOM_CAMERA_LOGE("GetCameraName : invalid device number (%u)\n", aDeviceNum);
return NS_ERROR_INVALID_ARG;
}
android::CameraInfo info;
int rv = android::Camera::getCameraInfo(deviceNum, &info);
if (rv != 0) {
DOM_CAMERA_LOGE("GetCameraName : get_camera_info(%d) failed: %d\n", deviceNum, rv);
return NS_ERROR_NOT_AVAILABLE;
}
switch (info.facing) {
case CAMERA_FACING_BACK:
aDeviceName.AssignLiteral("back");
break;
case CAMERA_FACING_FRONT:
aDeviceName.AssignLiteral("front");
break;
default:
aDeviceName.AssignLiteral("extra-camera-");
aDeviceName.AppendInt(deviceNum);
break;
}
return NS_OK;
}
示例2:
void
CreateFileTask::GetPermissionAccessType(nsCString& aAccess) const
{
if (mReplace) {
aAccess.AssignLiteral("write");
return;
}
aAccess.AssignLiteral("create");
}
示例3:
nsresult
nsFileChannel::MakeFileInputStream(nsIFile *file,
nsCOMPtr<nsIInputStream> &stream,
nsCString &contentType)
{
// we accept that this might result in a disk hit to stat the file
bool isDir;
nsresult rv = file->IsDirectory(&isDir);
if (NS_FAILED(rv)) {
// canonicalize error message
if (rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)
rv = NS_ERROR_FILE_NOT_FOUND;
return rv;
}
if (isDir) {
rv = nsDirectoryIndexStream::Create(file, getter_AddRefs(stream));
if (NS_SUCCEEDED(rv) && !HasContentTypeHint())
contentType.AssignLiteral(APPLICATION_HTTP_INDEX_FORMAT);
} else {
rv = NS_NewLocalFileInputStream(getter_AddRefs(stream), file);
if (NS_SUCCEEDED(rv) && !HasContentTypeHint()) {
// Use file extension to infer content type
nsCOMPtr<nsIMIMEService> mime = do_GetService("@mozilla.org/mime;1", &rv);
if (NS_SUCCEEDED(rv)) {
mime->GetTypeFromFile(file, contentType);
}
}
}
return rv;
}
示例4: PgpMimeGetNeedsAddonString
static void PgpMimeGetNeedsAddonString(nsCString &aResult)
{
aResult.AssignLiteral("???");
nsCOMPtr<nsIStringBundleService> stringBundleService =
mozilla::services::GetStringBundleService();
nsCOMPtr<nsIStringBundle> stringBundle;
nsresult rv = stringBundleService->CreateBundle(PGPMIME_PROPERTIES_URL,
getter_AddRefs(stringBundle));
if (NS_FAILED(rv))
return;
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
if (NS_FAILED(rv))
return;
nsCString url;
if (NS_FAILED(prefs->GetCharPref("mail.pgpmime.addon_url",
getter_Copies(url))))
return;
NS_ConvertUTF8toUTF16 url16(url);
const char16_t *formatStrings[] = { url16.get() };
nsString result;
rv = stringBundle->FormatStringFromName(MOZ_UTF16(PGPMIME_STR_NOT_SUPPORTED_ID),
formatStrings, 1, getter_Copies(result));
if (NS_FAILED(rv))
return;
aResult = NS_ConvertUTF16toUTF8(result);
}
示例5: ewsServer
int
msg_server_send_mail(nsIMsgIncomingServer * pIncomingServer,
const nsCString & mimeContent,
nsCString & err_msg) {
nsresult rv = NS_OK;
ews_session * session = NULL;
nsCOMPtr<IMailEwsMsgIncomingServer> ewsServer(do_QueryInterface(pIncomingServer, &rv));
NS_ENSURE_SUCCESS(rv, EWS_FAIL);
nsCOMPtr<IMailEwsService> ewsService;
rv = ewsServer->GetService(getter_AddRefs(ewsService));
NS_ENSURE_SUCCESS(rv, EWS_FAIL);
nsresult rv1 = ewsService->GetNewSession(&session);
int ret = EWS_FAIL;
if (NS_SUCCEEDED(rv)
&& NS_SUCCEEDED(rv1)
&& session) {
ret = do_send_mail(session,
mimeContent.get(),
mimeContent.Length(),
getter_Copies(err_msg));
} else {
err_msg.AssignLiteral("");
ret = (session ? EWS_FAIL : 401);
}
if (session)
ewsService->ReleaseSession(session);
return ret;
}
示例6: Init
NS_IMETHODIMP GnomeKeyring::Init()
#endif
{
nsresult ret;
nsCOMPtr<nsIServiceManager> servMan;
nsCOMPtr<nsIPrefService> prefService;
nsCOMPtr<nsIPrefBranch> pref;
#ifdef PR_LOGGING
gGnomeKeyringLog = PR_NewLogModule("GnomeKeyringLog");
#endif
keyringName.AssignLiteral(kDefaultKeyring);
ret = NS_GetServiceManager(getter_AddRefs(servMan));
if (ret != NS_OK) { return ret; }
ret = servMan->GetServiceByContractID("@mozilla.org/preferences-service;1",
NS_GET_IID(nsIPrefService),
getter_AddRefs(prefService));
if (ret != NS_OK) { return ret; }
ret = prefService->ReadUserPrefs(nullptr);
if (ret != NS_OK) { return ret; }
ret = prefService->GetBranch(kPrefsBranch, getter_AddRefs(pref));
if (ret != NS_OK) { return ret; }
PRInt32 prefType;
ret = pref->GetPrefType(kPrefsKeyring, &prefType);
if (ret != NS_OK) { return ret; }
if (prefType == 32) {
char* tempKeyringName;
pref->GetCharPref(kPrefsKeyring, &tempKeyringName);
keyringName = tempKeyringName;
if ( keyringName.IsVoid() || keyringName.IsEmpty() ) keyringName.AssignLiteral(kDefaultKeyring);
}
/* Create the password keyring, it doesn't hurt if it already exists */
GnomeKeyringResult result = gnome_keyring_create_sync(keyringName.get(), NULL);
if ((result != GNOME_KEYRING_RESULT_OK) &&
(result != GNOME_KEYRING_RESULT_KEYRING_ALREADY_EXISTS)) {
NS_ERROR("Can't open or create password keyring!");
return NS_ERROR_FAILURE;
}
return ret;
}
示例7: GetHTMLCharset
/*
* get "charset" information from clipboard data
* return value can be:
* 1. "UTF-16": mozilla or "text/html" with "charset=utf-16"
* 2. "UNKNOWN": mozilla can't detect what encode it use
* 3. other: "text/html" with other charset than utf-16
*/
void GetHTMLCharset(guchar * data, int32_t dataLength, nsCString& str)
{
// if detect "FFFE" or "FEFF", assume UTF-16
PRUnichar* beginChar = (PRUnichar*)data;
if ((beginChar[0] == 0xFFFE) || (beginChar[0] == 0xFEFF)) {
str.AssignLiteral("UTF-16");
return;
}
// no "FFFE" and "FEFF", assume ASCII first to find "charset" info
const nsDependentCString htmlStr((const char *)data, dataLength);
nsACString::const_iterator start, end;
htmlStr.BeginReading(start);
htmlStr.EndReading(end);
nsACString::const_iterator valueStart(start), valueEnd(start);
if (CaseInsensitiveFindInReadable(
NS_LITERAL_CSTRING("CONTENT=\"text/html;"),
start, end)) {
start = end;
htmlStr.EndReading(end);
if (CaseInsensitiveFindInReadable(
NS_LITERAL_CSTRING("charset="),
start, end)) {
valueStart = end;
start = end;
htmlStr.EndReading(end);
if (FindCharInReadable('"', start, end))
valueEnd = start;
}
}
// find "charset" in HTML
if (valueStart != valueEnd) {
str = Substring(valueStart, valueEnd);
ToUpperCase(str);
#ifdef DEBUG_CLIPBOARD
printf("Charset of HTML = %s\n", charsetUpperStr.get());
#endif
return;
}
str.AssignLiteral("UNKNOWN");
}
示例8: tzService
nsresult
GetExchangeTZId(calITimezone * tz,
nsCString & tzId) {
nsCOMPtr<calITimezoneService> tzService(do_GetService(CAL_TIMEZONESERVICE_CONTRACTID));
tzId.AssignLiteral("");
for (size_t i = 0; i < TIMEZONES_COUNT; i+=2) {
nsCOMPtr<calITimezone> timezone;
nsCString exId;
exId.AssignLiteral(TIMEZONES[i + 1]);
tzService->GetTimezone(exId,
getter_AddRefs(timezone));
if (tz == timezone) {
tzId.AssignLiteral(TIMEZONES[i + 1]);
break;
}
}
return NS_OK;
}
示例9: InitStreams
// set up the internal streams
void nsMIMEInputStream::InitStreams()
{
NS_ASSERTION(!mStartedReading,
"Don't call initStreams twice without rewinding");
mStartedReading = true;
// We'll use the content-length stream to add the final \r\n
if (mAddContentLength) {
uint64_t cl = 0;
if (mData) {
mData->Available(&cl);
}
mContentLength.AssignLiteral("Content-Length: ");
mContentLength.AppendInt(cl);
mContentLength.AppendLiteral("\r\n\r\n");
}
else {
mContentLength.AssignLiteral("\r\n");
}
mCLStream->ShareData(mContentLength.get(), -1);
mHeaderStream->ShareData(mHeaders.get(), -1);
}
示例10:
// maxSize may be -1 if unknown
static void
MakeRangeSpec(PRInt64 size, PRInt64 maxSize, PRInt32 chunkSize,
PRBool fetchRemaining, nsCString &rangeSpec)
{
rangeSpec.AssignLiteral("bytes=");
rangeSpec.AppendInt(size);
rangeSpec.Append('-');
if (fetchRemaining)
return;
PRInt64 end = size + chunkSize;
if (maxSize != -1 && end > maxSize)
end = maxSize;
end -= 1;
rangeSpec.AppendInt(end);
}
示例11:
// maxSize may be -1 if unknown
static void
MakeRangeSpec(const PRInt64 &size, const PRInt64 &maxSize, PRInt32 chunkSize,
PRBool fetchRemaining, nsCString &rangeSpec)
{
rangeSpec.AssignLiteral("bytes=");
rangeSpec.AppendInt(PRInt64(size));
rangeSpec.Append('-');
if (fetchRemaining)
return;
PRInt64 end = size + PRInt64(chunkSize);
if (maxSize != PRInt64(-1) && end > maxSize)
end = maxSize;
end -= 1;
rangeSpec.AppendInt(PRInt64(end));
}
示例12:
// maxSize may be -1 if unknown
static void
MakeRangeSpec(const int64_t &size, const int64_t &maxSize, int32_t chunkSize,
bool fetchRemaining, nsCString &rangeSpec)
{
rangeSpec.AssignLiteral("bytes=");
rangeSpec.AppendInt(int64_t(size));
rangeSpec.Append('-');
if (fetchRemaining)
return;
int64_t end = size + int64_t(chunkSize);
if (maxSize != int64_t(-1) && end > maxSize)
end = maxSize;
end -= 1;
rangeSpec.AppendInt(int64_t(end));
}
示例13: ToLowerCase
void
nsGIOProtocolHandler::InitSupportedProtocolsPref(nsIPrefBranch *prefs)
{
// Get user preferences to determine which protocol is supported.
// Gvfs/GIO has a set of supported protocols like obex, network, archive,
// computer, dav, cdda, gphoto2, trash, etc. Some of these seems to be
// irrelevant to process by browser. By default accept only smb and sftp
// protocols so far.
nsresult rv = prefs->GetCharPref(MOZ_GIO_SUPPORTED_PROTOCOLS,
getter_Copies(mSupportedProtocols));
if (NS_SUCCEEDED(rv)) {
mSupportedProtocols.StripWhitespace();
ToLowerCase(mSupportedProtocols);
}
else
mSupportedProtocols.AssignLiteral("smb:,sftp:"); // use defaults
LOG(("gio: supported protocols \"%s\"\n", mSupportedProtocols.get()));
}
示例14:
nsresult
nsFileChannel::MakeFileInputStream(nsIFile *file,
nsCOMPtr<nsIInputStream> &stream,
nsCString &contentType,
bool async)
{
// we accept that this might result in a disk hit to stat the file
bool isDir;
nsresult rv = file->IsDirectory(&isDir);
if (NS_FAILED(rv)) {
// canonicalize error message
if (rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)
rv = NS_ERROR_FILE_NOT_FOUND;
if (async && (NS_ERROR_FILE_NOT_FOUND == rv)) {
// We don't return "Not Found" errors here. Since we could not find
// the file, it's not a directory anyway.
isDir = false;
} else {
return rv;
}
}
if (isDir) {
rv = nsDirectoryIndexStream::Create(file, getter_AddRefs(stream));
if (NS_SUCCEEDED(rv) && !HasContentTypeHint())
contentType.AssignLiteral(APPLICATION_HTTP_INDEX_FORMAT);
} else {
rv = NS_NewLocalFileInputStream(getter_AddRefs(stream), file, -1, -1,
async? nsIFileInputStream::DEFER_OPEN : 0);
if (NS_SUCCEEDED(rv) && !HasContentTypeHint()) {
// Use file extension to infer content type
nsCOMPtr<nsIMIMEService> mime = do_GetService("@mozilla.org/mime;1", &rv);
if (NS_SUCCEEDED(rv)) {
mime->GetTypeFromFile(file, contentType);
}
}
}
return rv;
}
示例15: UpdateMimeContentToEwsFormat
static
void UpdateMimeContentToEwsFormat(nsCString & mimeContent,
bool & has_uid,
nsCString & uid) {
nsresult rv = NS_OK;
nsCOMPtr<calIICSService> icsService =
do_GetService(CAL_ICSSERVICE_CONTRACTID, &rv);
NS_FAILED_WARN(rv);
if (!icsService)
return;
nsCOMPtr<calIIcalComponent> component;
rv = icsService->ParseICS(mimeContent,
nullptr,
getter_AddRefs(component));
NS_FAILED_WARN(rv);
if (!component)
return;
//check METHOD
nsCString method;
rv = component->GetMethod(method);
NS_FAILED_WARN(rv);
if (NS_FAILED(rv) || method.IsEmpty()) {
component->SetMethod(NS_LITERAL_CSTRING("PUBLISH"));
}
//Check UID
nsCOMPtr<calIIcalComponent> todo;
rv = component->GetFirstSubcomponent(NS_LITERAL_CSTRING("VTODO"),
getter_AddRefs(todo));
NS_FAILED_WARN(rv);
if (todo) {
rv = todo->GetUid(uid);
NS_FAILED_WARN(rv);
if (NS_FAILED(rv) || uid.IsEmpty()) {
has_uid = false;
rv = GenerateUid(uid);
NS_FAILED_WARN(rv);
if (NS_SUCCEEDED(rv) && !uid.IsEmpty()) {
todo->SetUid(uid);
}
} else {
has_uid = true;
}
} else {
has_uid = false;
uid.AssignLiteral("");
}
mailews_logger << "origianl ics:"
<< mimeContent.get()
<< std::endl;
component->SerializeToICS(mimeContent);
mailews_logger << "updated ics:"
<< mimeContent.get()
<< std::endl;
}