void WebRTCCall::SetOffer(const std::string& aOffer) { if (mState && mState->mThread.get()) { nsRefPtr<State> pState(mState); nsCOMPtr<RemoteDescriptionEvent> event = new RemoteDescriptionEvent(pState, aOffer, PCOFFER); mState->mThread->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL); } }
NS_IMETHODIMP nsHTMLTextAreaElement::SaveState() { nsresult rv = NS_OK; // Only save if value != defaultValue (bug 62713) nsPresState *state = nsnull; if (mValueChanged) { rv = GetPrimaryPresState(this, &state); if (state) { nsAutoString value; GetValueInternal(value, PR_TRUE); rv = nsLinebreakConverter::ConvertStringLineBreaks( value, nsLinebreakConverter::eLinebreakPlatform, nsLinebreakConverter::eLinebreakContent); NS_ASSERTION(NS_SUCCEEDED(rv), "Converting linebreaks failed!"); nsCOMPtr<nsISupportsString> pState (do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID)); if (!pState) { return NS_ERROR_OUT_OF_MEMORY; } pState->SetData(value); state->SetStateProperty(pState); } } if (mDisabledChanged) { if (!state) { rv = GetPrimaryPresState(this, &state); } if (state) { PRBool disabled; GetDisabled(&disabled); state->SetDisabled(disabled); } } return rv; }
void IosToolHandlerPrivate::processXml() { while (!outputParser.atEnd()) { QXmlStreamReader::TokenType tt = outputParser.readNext(); //qCDebug(toolHandlerLog) << "processXml, tt=" << tt; switch (tt) { case QXmlStreamReader::NoToken: // The reader has not yet read anything. continue; case QXmlStreamReader::Invalid: // An error has occurred, reported in error() and errorString(). break; case QXmlStreamReader::StartDocument: // The reader reports the XML version number in documentVersion(), and the encoding // as specified in the XML document in documentEncoding(). If the document is declared // standalone, isStandaloneDocument() returns true; otherwise it returns false. break; case QXmlStreamReader::EndDocument: // The reader reports the end of the document. // state = XmlEndProcessed; break; case QXmlStreamReader::StartElement: // The reader reports the start of an element with namespaceUri() and name(). Empty // elements are also reported as StartElement, followed directly by EndElement. // The convenience function readElementText() can be called to concatenate all content // until the corresponding EndElement. Attributes are reported in attributes(), // namespace declarations in namespaceDeclarations(). { QStringRef elName = outputParser.name(); if (elName == QLatin1String("msg")) { stack.append(ParserState(ParserState::Msg)); } else if (elName == QLatin1String("exit")) { stack.append(ParserState(ParserState::Exit)); toolExited(outputParser.attributes().value(QLatin1String("code")) .toString().toInt()); } else if (elName == QLatin1String("device_id")) { stack.append(ParserState(ParserState::DeviceId)); } else if (elName == QLatin1String("key")) { stack.append(ParserState(ParserState::Key)); } else if (elName == QLatin1String("value")) { stack.append(ParserState(ParserState::Value)); } else if (elName == QLatin1String("query_result")) { stack.append(ParserState(ParserState::QueryResult)); } else if (elName == QLatin1String("app_output")) { stack.append(ParserState(ParserState::AppOutput)); } else if (elName == QLatin1String("control_char")) { QXmlStreamAttributes attributes = outputParser.attributes(); QChar c[1] = { QChar::fromLatin1(static_cast<char>(attributes.value(QLatin1String("code")).toString().toInt())) }; if (stack.size() > 0 && stack.last().collectChars()) stack.last().chars.append(c[0]); stack.append(ParserState(ParserState::ControlChar)); break; } else if (elName == QLatin1String("item")) { stack.append(ParserState(ParserState::Item)); } else if (elName == QLatin1String("status")) { ParserState pState(ParserState::Status); QXmlStreamAttributes attributes = outputParser.attributes(); pState.progress = attributes.value(QLatin1String("progress")).toString().toInt(); pState.maxProgress = attributes.value(QLatin1String("max_progress")).toString().toInt(); stack.append(pState); } else if (elName == QLatin1String("app_started")) { stack.append(ParserState(ParserState::AppStarted)); QXmlStreamAttributes attributes = outputParser.attributes(); QStringRef statusStr = attributes.value(QLatin1String("status")); Ios::IosToolHandler::OpStatus status = Ios::IosToolHandler::Unknown; if (statusStr.compare(QLatin1String("success"), Qt::CaseInsensitive) == 0) status = Ios::IosToolHandler::Success; else if (statusStr.compare(QLatin1String("failure"), Qt::CaseInsensitive) == 0) status = Ios::IosToolHandler::Failure; didStartApp(bundlePath, deviceId, status); } else if (elName == QLatin1String("app_transfer")) { stack.append(ParserState(ParserState::AppTransfer)); QXmlStreamAttributes attributes = outputParser.attributes(); QStringRef statusStr = attributes.value(QLatin1String("status")); Ios::IosToolHandler::OpStatus status = Ios::IosToolHandler::Unknown; if (statusStr.compare(QLatin1String("success"), Qt::CaseInsensitive) == 0) status = Ios::IosToolHandler::Success; else if (statusStr.compare(QLatin1String("failure"), Qt::CaseInsensitive) == 0) status = Ios::IosToolHandler::Failure; emit didTransferApp(bundlePath, deviceId, status); } else if (elName == QLatin1String("device_info") || elName == QLatin1String("deviceinfo")) { stack.append(ParserState(ParserState::DeviceInfo)); } else if (elName == QLatin1String("inferior_pid")) { stack.append(ParserState(ParserState::InferiorPid)); } else if (elName == QLatin1String("server_ports")) { stack.append(ParserState(ParserState::ServerPorts)); QXmlStreamAttributes attributes = outputParser.attributes(); Utils::Port gdbServerPort( attributes.value(QLatin1String("gdb_server")).toString().toInt()); Utils::Port qmlServerPort( attributes.value(QLatin1String("qml_server")).toString().toInt()); gotServerPorts(bundlePath, deviceId, gdbServerPort, qmlServerPort); } else { qCWarning(toolHandlerLog) << "unexpected element " << elName; } break; } case QXmlStreamReader::EndElement: // The reader reports the end of an element with namespaceUri() and name(). { ParserState p = stack.last(); stack.removeLast(); switch (p.kind) { case ParserState::Msg: errorMsg(p.chars); break; case ParserState::DeviceId: if (deviceId.isEmpty()) deviceId = p.chars; else QTC_CHECK(deviceId.compare(p.chars, Qt::CaseInsensitive) == 0); break; case ParserState::Key: stack.last().key = p.chars; break; case ParserState::Value: stack.last().value = p.chars; break; case ParserState::Status: isTransferringApp(bundlePath, deviceId, p.progress, p.maxProgress, p.chars); break; case ParserState::QueryResult: state = XmlEndProcessed; stop(0); return; case ParserState::AppOutput: appOutput(p.chars); break; case ParserState::ControlChar: break; case ParserState::AppStarted: break; case ParserState::AppTransfer: break; case ParserState::Item: stack.last().info.insert(p.key, p.value); break; case ParserState::DeviceInfo: deviceInfo(deviceId, p.info); break; case ParserState::Exit: break; case ParserState::InferiorPid: gotInferiorPid(bundlePath, deviceId, p.chars.toLongLong()); break; case ParserState::ServerPorts: break; } break; } case QXmlStreamReader::Characters: // The reader reports characters in text(). If the characters are all white-space, // isWhitespace() returns true. If the characters stem from a CDATA section, // isCDATA() returns true. if (stack.isEmpty()) break; if (stack.last().collectChars()) stack.last().chars.append(outputParser.text()); break; case QXmlStreamReader::Comment: // The reader reports a comment in text(). break; case QXmlStreamReader::DTD: // The reader reports a DTD in text(), notation declarations in notationDeclarations(), // and entity declarations in entityDeclarations(). Details of the DTD declaration are // reported in in dtdName(), dtdPublicId(), and dtdSystemId(). break; case QXmlStreamReader::EntityReference: // The reader reports an entity reference that could not be resolved. The name of // the reference is reported in name(), the replacement text in text(). break; case QXmlStreamReader::ProcessingInstruction: break; } } if (outputParser.hasError() && outputParser.error() != QXmlStreamReader::PrematureEndOfDocumentError) { qCWarning(toolHandlerLog) << "error parsing iosTool output:" << outputParser.errorString(); stop(-1); } }