本文整理汇总了C++中nsCString::IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCString::IsEmpty方法的具体用法?C++ nsCString::IsEmpty怎么用?C++ nsCString::IsEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCString
的用法示例。
在下文中一共展示了nsCString::IsEmpty方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static inline bool
IsEndOfHeaders(const nsCString &aLine)
{
return aLine.IsEmpty();
}
示例2: strchr
// Finds the base domain for a host, with requested number of additional parts.
// This will fail, generating an error, if the host is an IPv4/IPv6 address,
// if more subdomain parts are requested than are available, or if the hostname
// includes characters that are not valid in a URL. Normalization is performed
// on the host string and the result will be in UTF8.
nsresult
nsEffectiveTLDService::GetBaseDomainInternal(nsCString &aHostname,
int32_t aAdditionalParts,
nsACString &aBaseDomain)
{
if (aHostname.IsEmpty())
return NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS;
// chomp any trailing dot, and keep track of it for later
bool trailingDot = aHostname.Last() == '.';
if (trailingDot)
aHostname.Truncate(aHostname.Length() - 1);
// check the edge cases of the host being '.' or having a second trailing '.',
// since subsequent checks won't catch it.
if (aHostname.IsEmpty() || aHostname.Last() == '.')
return NS_ERROR_INVALID_ARG;
// Check if we're dealing with an IPv4/IPv6 hostname, and return
PRNetAddr addr;
PRStatus result = PR_StringToNetAddr(aHostname.get(), &addr);
if (result == PR_SUCCESS)
return NS_ERROR_HOST_IS_IP_ADDRESS;
// Walk up the domain tree, most specific to least specific,
// looking for matches at each level. Note that a given level may
// have multiple attributes (e.g. IsWild() and IsNormal()).
const char *prevDomain = nullptr;
const char *currDomain = aHostname.get();
const char *nextDot = strchr(currDomain, '.');
const char *end = currDomain + aHostname.Length();
const char *eTLD = currDomain;
while (1) {
// sanity check the string we're about to look up: it should not begin with
// a '.'; this would mean the hostname began with a '.' or had an
// embedded '..' sequence.
if (*currDomain == '.')
return NS_ERROR_INVALID_ARG;
// perform the hash lookup.
nsDomainEntry *entry = mHash.GetEntry(currDomain);
if (entry) {
if (entry->IsWild() && prevDomain) {
// wildcard rules imply an eTLD one level inferior to the match.
eTLD = prevDomain;
break;
} else if (entry->IsNormal() || !nextDot) {
// specific match, or we've hit the top domain level
eTLD = currDomain;
break;
} else if (entry->IsException()) {
// exception rules imply an eTLD one level superior to the match.
eTLD = nextDot + 1;
break;
}
}
if (!nextDot) {
// we've hit the top domain level; use it by default.
eTLD = currDomain;
break;
}
prevDomain = currDomain;
currDomain = nextDot + 1;
nextDot = strchr(currDomain, '.');
}
const char *begin, *iter;
if (aAdditionalParts < 0) {
NS_ASSERTION(aAdditionalParts == -1,
"aAdditionalParts can't be negative and different from -1");
for (iter = aHostname.get(); iter != eTLD && *iter != '.'; iter++);
if (iter != eTLD) {
iter++;
}
if (iter != eTLD) {
aAdditionalParts = 0;
}
} else {
// count off the number of requested domains.
begin = aHostname.get();
iter = eTLD;
while (1) {
if (iter == begin)
break;
if (*(--iter) == '.' && aAdditionalParts-- == 0) {
++iter;
++aAdditionalParts;
//.........这里部分代码省略.........
示例3: ConvertString
bool ImportTranslate::ConvertString( const nsCString& inStr, nsCString& outStr, bool mimeHeader)
{
if (inStr.IsEmpty()) {
outStr = inStr;
return( PR_TRUE);
}
nsImportTranslator *pTrans = GetTranslator();
// int maxLen = (int) pTrans->GetMaxBufferSize( inStr.Length());
// int hLen = 0;
nsCString set;
nsCString lang;
if (mimeHeader) {
// add the charset and language
pTrans->GetCharset( set);
pTrans->GetLanguage( lang);
}
// Unfortunatly, we didn't implement ConvertBuffer for all translators,
// just ConvertToFile. This means that this data will not always
// be converted to the charset of pTrans. In that case...
// We don't always have the data in the same charset as the current
// translator...
// It is safer to leave the charset and language field blank
set.Truncate();
lang.Truncate();
PRUint8 * pBuf;
/*
pBuf = (P_U8) outStr.GetBuffer( maxLen);
if (!pBuf) {
delete pTrans;
return( FALSE);
}
pTrans->ConvertBuffer( (PC_U8)(PC_S8)inStr, inStr.GetLength(), pBuf);
outStr.ReleaseBuffer();
*/
outStr = inStr;
delete pTrans;
// Now I need to run the string through the mime-header special char
// encoder.
pTrans = new CMHTranslator;
pBuf = new PRUint8[pTrans->GetMaxBufferSize( outStr.Length())];
pTrans->ConvertBuffer( (const PRUint8 *)(outStr.get()), outStr.Length(), pBuf);
delete pTrans;
outStr.Truncate();
if (mimeHeader) {
outStr = set;
outStr += "'";
outStr += lang;
outStr += "'";
}
outStr += (const char *)pBuf;
delete [] pBuf;
return( PR_TRUE);
}
示例4: SendFailedAsyncOpen
//.........这里部分代码省略.........
if (originalUri)
mChannel->SetOriginalURI(originalUri);
if (docUri)
mChannel->SetDocumentURI(docUri);
if (referrerUri)
mChannel->SetReferrerWithPolicyInternal(referrerUri, aReferrerPolicy);
if (apiRedirectToUri)
mChannel->RedirectTo(apiRedirectToUri);
if (topWindowUri)
mChannel->SetTopWindowURI(topWindowUri);
if (loadFlags != nsIRequest::LOAD_NORMAL)
mChannel->SetLoadFlags(loadFlags);
for (uint32_t i = 0; i < requestHeaders.Length(); i++) {
mChannel->SetRequestHeader(requestHeaders[i].mHeader,
requestHeaders[i].mValue,
requestHeaders[i].mMerge);
}
mParentListener = new HttpChannelParentListener(this);
mChannel->SetNotificationCallbacks(mParentListener);
mChannel->SetRequestMethod(nsDependentCString(requestMethod.get()));
nsTArray<mozilla::ipc::FileDescriptor> fds;
if (aFds.type() == OptionalFileDescriptorSet::TPFileDescriptorSetParent) {
FileDescriptorSetParent* fdSetActor =
static_cast<FileDescriptorSetParent*>(aFds.get_PFileDescriptorSetParent());
MOZ_ASSERT(fdSetActor);
fdSetActor->ForgetFileDescriptors(fds);
MOZ_ASSERT(!fds.IsEmpty());
unused << fdSetActor->Send__delete__(fdSetActor);
} else if (aFds.type() == OptionalFileDescriptorSet::TArrayOfFileDescriptor) {
const_cast<OptionalFileDescriptorSet&>(aFds).
get_ArrayOfFileDescriptor().SwapElements(fds);
}
nsCOMPtr<nsIInputStream> stream = DeserializeInputStream(uploadStream, fds);
if (stream) {
mChannel->InternalSetUploadStream(stream);
mChannel->SetUploadStreamHasHeaders(uploadStreamHasHeaders);
}
if (aSynthesizedResponseHead.type() == OptionalHttpResponseHead::TnsHttpResponseHead) {
mSynthesizedResponseHead = new nsHttpResponseHead(aSynthesizedResponseHead.get_nsHttpResponseHead());
mShouldIntercept = true;
} else {
mChannel->ForceNoIntercept();
}
nsCOMPtr<nsISupportsPRUint32> cacheKey =
do_CreateInstance(NS_SUPPORTS_PRUINT32_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
return SendFailedAsyncOpen(rv);
}
rv = cacheKey->SetData(aCacheKey);
if (NS_FAILED(rv)) {
return SendFailedAsyncOpen(rv);
}
mChannel->SetCacheKey(cacheKey);
示例5: StartTimer
//.........这里部分代码省略.........
if (*s && endptr && (endptr != s) &&
(mCurrentSize == startByte)) {
// ok the starting point is confirmed. We still need to check the
// total size of the range for consistency if this isn't
// the first chunk
if (mTotalSize == int64_t(-1)) {
// first chunk
confirmedOK = true;
} else {
int32_t slash = buf.FindChar('/');
int64_t rangeSize = 0;
if (slash != kNotFound &&
(PR_sscanf(buf.get() + slash + 1, "%lld", (int64_t *) &rangeSize) == 1) &&
rangeSize == mTotalSize) {
confirmedOK = true;
}
}
}
}
if (!confirmedOK) {
NS_WARNING("unexpected content-range");
mCacheBust = true;
mChannel = nullptr;
if (++mNonPartialCount > MAX_RETRY_COUNT) {
NS_WARNING("unable to fetch a byte range; giving up");
return NS_ERROR_FAILURE;
}
// Increase delay with each failure.
StartTimer(mInterval * mNonPartialCount);
return NS_ERROR_DOWNLOAD_NOT_PARTIAL;
}
}
}
// Do special processing after the first response.
if (mTotalSize == int64_t(-1)) {
// Update knowledge of mFinalURI
rv = http->GetURI(getter_AddRefs(mFinalURI));
if (NS_FAILED(rv))
return rv;
http->GetResponseHeader(NS_LITERAL_CSTRING("Etag"), mPartialValidator);
if (StringBeginsWith(mPartialValidator, NS_LITERAL_CSTRING("W/")))
mPartialValidator.Truncate(); // don't use weak validators
if (mPartialValidator.IsEmpty())
http->GetResponseHeader(NS_LITERAL_CSTRING("Last-Modified"), mPartialValidator);
if (code == 206) {
// OK, read the Content-Range header to determine the total size of this
// download file.
nsAutoCString buf;
rv = http->GetResponseHeader(NS_LITERAL_CSTRING("Content-Range"), buf);
if (NS_FAILED(rv))
return rv;
int32_t slash = buf.FindChar('/');
if (slash == kNotFound) {
NS_WARNING("server returned invalid Content-Range header!");
return NS_ERROR_UNEXPECTED;
}
if (PR_sscanf(buf.get() + slash + 1, "%lld", (int64_t *) &mTotalSize) != 1)
return NS_ERROR_UNEXPECTED;
} else {
rv = http->GetContentLength(&mTotalSize);
if (NS_FAILED(rv))
return rv;
// We need to know the total size of the thing we're trying to download.
if (mTotalSize == int64_t(-1)) {
NS_WARNING("server returned no content-length header!");
return NS_ERROR_UNEXPECTED;
}
// Need to truncate (or create, if it doesn't exist) the file since we
// are downloading the whole thing.
WriteToFile(mDest, nullptr, 0, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE);
mCurrentSize = 0;
}
// Notify observer that we are starting...
rv = CallOnStartRequest();
if (NS_FAILED(rv))
return rv;
}
// Adjust mChunkSize accordingly if mCurrentSize is close to mTotalSize.
int64_t diff = mTotalSize - mCurrentSize;
if (diff <= int64_t(0)) {
NS_WARNING("about to set a bogus chunk size; giving up");
return NS_ERROR_UNEXPECTED;
}
if (diff < int64_t(mChunkSize))
mChunkSize = uint32_t(diff);
mChunk = new char[mChunkSize];
if (!mChunk)
rv = NS_ERROR_OUT_OF_MEMORY;
return rv;
}
示例6: nsCString
nsresult
UDPSocketParent::BindInternal(const nsCString& aHost, const uint16_t& aPort,
const bool& aAddressReuse, const bool& aLoopback,
const uint32_t& recvBufferSize,
const uint32_t& sendBufferSize)
{
nsresult rv;
UDPSOCKET_LOG(("%s: [this=%p] %s:%u addressReuse: %d loopback: %d recvBufferSize: %lu, sendBufferSize: %lu",
__FUNCTION__, this, nsCString(aHost).get(), aPort,
aAddressReuse, aLoopback, recvBufferSize, sendBufferSize));
nsCOMPtr<nsIUDPSocket> sock =
do_CreateInstance("@mozilla.org/network/udp-socket;1", &rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
if (aHost.IsEmpty()) {
rv = sock->Init(aPort, false, mPrincipal, aAddressReuse,
/* optional_argc = */ 1);
} else {
PRNetAddr prAddr;
PR_InitializeNetAddr(PR_IpAddrAny, aPort, &prAddr);
PRStatus status = PR_StringToNetAddr(aHost.BeginReading(), &prAddr);
if (status != PR_SUCCESS) {
return NS_ERROR_FAILURE;
}
mozilla::net::NetAddr addr;
PRNetAddrToNetAddr(&prAddr, &addr);
rv = sock->InitWithAddress(&addr, mPrincipal, aAddressReuse,
/* optional_argc = */ 1);
}
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
nsCOMPtr<nsINetAddr> laddr;
rv = sock->GetLocalAddr(getter_AddRefs(laddr));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
uint16_t family;
rv = laddr->GetFamily(&family);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
if (family == nsINetAddr::FAMILY_INET) {
rv = sock->SetMulticastLoopback(aLoopback);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
}
// TODO: once bug 1252759 is fixed query buffer first and only increase
if (recvBufferSize != 0) {
rv = sock->SetRecvBufferSize(recvBufferSize);
if (NS_WARN_IF(NS_FAILED(rv))) {
UDPSOCKET_LOG(("%s: [this=%p] %s:%u failed to set recv buffer size to: %lu", __FUNCTION__, this, nsCString(aHost).get(), aPort, recvBufferSize));
}
}
if (sendBufferSize != 0) {
rv = sock->SetSendBufferSize(sendBufferSize);
if (NS_WARN_IF(NS_FAILED(rv))) {
UDPSOCKET_LOG(("%s: [this=%p] %s:%u failed to set send buffer size to: %lu", __FUNCTION__, this, nsCString(aHost).get(), aPort, sendBufferSize));
}
}
// register listener
rv = sock->AsyncListen(this);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
mSocket = sock;
return NS_OK;
}
示例7: CallOnStopRequest
nsresult
nsIncrementalDownload::ProcessTimeout()
{
NS_ASSERTION(!mChannel, "how can we have a channel?");
// Handle existing error conditions
if (NS_FAILED(mStatus)) {
CallOnStopRequest();
return NS_OK;
}
// Fetch next chunk
nsCOMPtr<nsIChannel> channel;
nsresult rv = NS_NewChannel(getter_AddRefs(channel),
mFinalURI,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER,
nullptr, // loadGroup
this, // aCallbacks
mLoadFlags);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIHttpChannel> http = do_QueryInterface(channel, &rv);
if (NS_FAILED(rv))
return rv;
NS_ASSERTION(mCurrentSize != int64_t(-1),
"we should know the current file size by now");
rv = ClearRequestHeader(http);
if (NS_FAILED(rv))
return rv;
// Don't bother making a range request if we are just going to fetch the
// entire document.
if (mInterval || mCurrentSize != int64_t(0)) {
nsAutoCString range;
MakeRangeSpec(mCurrentSize, mTotalSize, mChunkSize, mInterval == 0, range);
rv = http->SetRequestHeader(NS_LITERAL_CSTRING("Range"), range, false);
if (NS_FAILED(rv))
return rv;
if (!mPartialValidator.IsEmpty())
http->SetRequestHeader(NS_LITERAL_CSTRING("If-Range"),
mPartialValidator, false);
if (mCacheBust) {
http->SetRequestHeader(NS_LITERAL_CSTRING("Cache-Control"),
NS_LITERAL_CSTRING("no-cache"), false);
http->SetRequestHeader(NS_LITERAL_CSTRING("Pragma"),
NS_LITERAL_CSTRING("no-cache"), false);
}
}
rv = channel->AsyncOpen(this, nullptr);
if (NS_FAILED(rv))
return rv;
// Wait to assign mChannel when we know we are going to succeed. This is
// important because we don't want to introduce a reference cycle between
// mChannel and this until we know for a fact that AsyncOpen has succeeded,
// thus ensuring that our stream listener methods will be invoked.
mChannel = channel;
return NS_OK;
}
示例8: nsMsgI18NConvertToUnicode
nsresult nsMsgI18NConvertToUnicode(const char* aCharset,
const nsCString& inString,
nsAString& outString,
bool aIsCharsetCanonical)
{
if (inString.IsEmpty()) {
outString.Truncate();
return NS_OK;
}
else if (!*aCharset || !PL_strcasecmp(aCharset, "us-ascii") ||
!PL_strcasecmp(aCharset, "ISO-8859-1")) {
// Despite its name, it also works for Latin-1.
CopyASCIItoUTF16(inString, outString);
return NS_OK;
}
else if (!PL_strcasecmp(aCharset, "UTF-8")) {
if (MsgIsUTF8(inString)) {
nsAutoString tmp;
CopyUTF8toUTF16(inString, tmp);
if (!tmp.IsEmpty() && tmp.get()[0] == char16_t(0xFEFF))
tmp.Cut(0, 1);
outString.Assign(tmp);
return NS_OK;
}
NS_WARNING("Invalid UTF-8 string");
return NS_ERROR_UNEXPECTED;
}
nsresult rv;
nsCOMPtr <nsICharsetConverterManager> ccm = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr <nsIUnicodeDecoder> decoder;
// get an unicode converter
if (aIsCharsetCanonical) // optimize for modified UTF-7 used by IMAP
rv = ccm->GetUnicodeDecoderRaw(aCharset, getter_AddRefs(decoder));
else
rv = ccm->GetUnicodeDecoderInternal(aCharset, getter_AddRefs(decoder));
NS_ENSURE_SUCCESS(rv, rv);
const char *originalSrcPtr = inString.get();
const char *currentSrcPtr = originalSrcPtr;
int32_t originalLength = inString.Length();
int32_t srcLength;
int32_t dstLength;
char16_t localbuf[512];
int32_t consumedLen = 0;
outString.Truncate();
// convert
while (consumedLen < originalLength) {
srcLength = originalLength - consumedLen;
dstLength = 512;
rv = decoder->Convert(currentSrcPtr, &srcLength, localbuf, &dstLength);
if (NS_FAILED(rv) || dstLength == 0)
break;
outString.Append(localbuf, dstLength);
currentSrcPtr += srcLength;
consumedLen = currentSrcPtr - originalSrcPtr; // src length used so far
}
return rv;
}
示例9: ApplyTransformations
/**
* This method applies a sequence of transformations to the line.
*
* It applies the following sequences in order
* * Removes headers if the searcher doesn't want them
* (sets m_pastHeaders)
* * Determines the current MIME type.
* (via SniffPossibleMIMEHeader)
* * Strips any HTML if the searcher doesn't want it
* * Strips non-text parts
* * Decodes any base64 part
* (resetting part variables: m_base64part, m_pastHeaders, m_partIsHtml,
* m_partIsText)
*
* @param line (in) the current line
* @param length (in) the length of said line
* @param eatThisLine (out) whether or not to ignore this line
* @param buf (inout) if m_base64part, the current part as needed for
* decoding; else, it is treated as an out param (a
* redundant version of line).
* @return the length of the line after applying transformations
*/
PRInt32 nsMsgBodyHandler::ApplyTransformations (const nsCString &line, PRInt32 length,
bool &eatThisLine, nsCString &buf)
{
PRInt32 newLength = length;
eatThisLine = PR_FALSE;
if (!m_pastHeaders) // line is a line from the message headers
{
if (m_stripHeaders)
eatThisLine = PR_TRUE;
// We have already grabbed all worthwhile information from the headers,
// so there is no need to keep track of the current lines
buf.Assign(line);
SniffPossibleMIMEHeader(buf);
m_pastHeaders = buf.IsEmpty() || buf.First() == '\r' ||
buf.First() == '\n';
return length;
}
// Check to see if this is the boundary string
if (m_isMultipart && StringBeginsWith(line, boundary))
{
if (m_base64part && m_partIsText)
{
Base64Decode(buf);
// Work on the parsed string
if (!buf.Length())
{
NS_WARNING("Trying to transform an empty buffer");
eatThisLine = PR_TRUE;
}
else
{
ApplyTransformations(buf, buf.Length(), eatThisLine, buf);
// Avoid spurious failures
eatThisLine = PR_FALSE;
}
}
else
{
buf.Truncate();
eatThisLine = PR_TRUE; // We have no content...
}
// Reset all assumed headers
m_base64part = PR_FALSE;
m_pastHeaders = PR_FALSE;
m_partIsHtml = PR_FALSE;
m_partIsText = PR_TRUE;
return buf.Length();
}
if (!m_partIsText)
{
// Ignore non-text parts
buf.Truncate();
eatThisLine = PR_TRUE;
return 0;
}
if (m_base64part)
{
// We need to keep track of all lines to parse base64encoded...
buf.Append(line.get());
eatThisLine = PR_TRUE;
return buf.Length();
}
// ... but there's no point if we're not parsing base64.
buf.Assign(line);
if (m_stripHtml && m_partIsHtml)
{
StripHtml (buf);
//.........这里部分代码省略.........
示例10: ConfigWebRtcLog
void ConfigWebRtcLog(mozilla::LogLevel level, uint32_t trace_mask,
nsCString &aLogFile, bool multi_log)
{
if (gWebRtcTraceLoggingOn) {
return;
}
#if defined(ANDROID)
// Special case: use callback to pipe to NSPR logging.
aLogFile.Assign(default_log_name);
#else
rtc::LoggingSeverity log_level;
switch (level) {
case mozilla::LogLevel::Verbose:
log_level = rtc::LoggingSeverity::LS_VERBOSE;
break;
case mozilla::LogLevel::Debug:
case mozilla::LogLevel::Info:
log_level = rtc::LoggingSeverity::LS_INFO;
break;
case mozilla::LogLevel::Warning:
log_level = rtc::LoggingSeverity::LS_WARNING;
break;
case mozilla::LogLevel::Error:
log_level = rtc::LoggingSeverity::LS_ERROR;
break;
case mozilla::LogLevel::Disabled:
log_level = rtc::LoggingSeverity::LS_NONE;
break;
default:
MOZ_ASSERT(false);
break;
}
rtc::LogMessage::LogToDebug(log_level);
if (level != mozilla::LogLevel::Disabled) {
// always capture LOG(...) << ... logging in webrtc.org code to nspr logs
if (!sSink) {
sSink = new LogSinkImpl();
rtc::LogMessage::AddLogToStream(sSink, log_level);
// it's ok if this leaks to program end
}
} else if (sSink) {
rtc::LogMessage::RemoveLogToStream(sSink);
sSink = nullptr;
}
webrtc::Trace::set_level_filter(trace_mask);
if (trace_mask != 0) {
// default WEBRTC_TRACE logs to a rotating file, but allow redirecting to nspr
// XXX always redirect in e10s if the sandbox blocks file access, or somehow proxy
if (aLogFile.EqualsLiteral("nspr") || aLogFile.EqualsLiteral("moz_log")) {
rtc::LogMessage::SetLogToStderr(false);
webrtc::Trace::SetTraceCallback(&gWebRtcCallback);
} else {
rtc::LogMessage::SetLogToStderr(true);
webrtc::Trace::SetTraceFile(aLogFile.get(), multi_log);
}
} else {
rtc::LogMessage::SetLogToStderr(false);
}
if (aLogFile.IsEmpty()) {
nsCOMPtr<nsIFile> tempDir;
nsresult rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tempDir));
if (NS_SUCCEEDED(rv)) {
tempDir->AppendNative(default_log_name);
#ifdef XP_WIN
// WebRTC wants a path encoded in the native charset, not UTF-8.
nsAutoString logFile;
tempDir->GetPath(logFile);
NS_CopyUnicodeToNative(logFile, aLogFile);
#else
tempDir->GetNativePath(aLogFile);
#endif
}
}
#endif
if (XRE_IsParentProcess()) {
// Capture the final choice for the trace setting.
mozilla::Preferences::SetCString("media.webrtc.debug.log_file", aLogFile);
}
}
示例11: 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;
}