void PlayerContainer::copyProperty(const QString& propName, const QVariant& _value, QVariant::Type expType, UpdateType updType) { QVariant value = _value; // we protect our users from bogus values if (value.userType() == qMetaTypeId<QDBusArgument>()) { if (expType == QVariant::Map) { QDBusArgument arg = value.value<QDBusArgument>(); if (arg.currentType() != QDBusArgument::MapType) { kWarning() << m_dbusAddress << "exports" << propName << "with the wrong type; it should be D-Bus type \"a{sv}\""; return; } QVariantMap map; arg >> map; if (propName == QLatin1String("Metadata")) { if (!decodeUri(map, QLatin1String("mpris:artUrl"))) { kWarning() << m_dbusAddress << "has an invalid URL for the mpris:artUrl entry of the \"Metadata\" property"; } if (!decodeUri(map, QLatin1String("xesam:url"))) { kWarning() << m_dbusAddress << "has an invalid URL for the xesam:url entry of the \"Metadata\" property"; } } value = QVariant(map); } }
void Mpris2Player::copyProperty(const QString &name, const QVariant &value, const QVariant::Type &expectedType) { QVariant tmp = value; // We protect our users from bogus values if (tmp.userType() == qMetaTypeId<QDBusArgument>()) { if (expectedType == QVariant::Map) { QDBusArgument arg = tmp.value<QDBusArgument>(); if (arg.currentType() != QDBusArgument::MapType) { qCWarning(MPRIS2_PLAYER) << m_serviceName << "exports" << name << "with the wrong type; it should be D-Bus type \"a{sv}\""; return; } QVariantMap map; arg >> map; if (name == QStringLiteral("Metadata")) { if (!decodeUri(map, QStringLiteral("mpris:artUrl"))) { qCWarning(MPRIS2_PLAYER) << m_serviceName << "has an invalid URL for the mpris:artUrl entry of the \"Metadata\" property"; } if (!decodeUri(map, QStringLiteral("xesam:url"))) { qCWarning(MPRIS2_PLAYER) << m_serviceName << "has an invalid URL for the xesam:url entry of the \"Metadata\" property"; } } tmp = QVariant(map); } }
QMimeData* DeclarativeDragItemWithUrl::mimeData() const { QMimeData* data = new QMimeData; if (!m_url.isEmpty()) { QList<QUrl> urls; urls.append(decodeUri(m_url)); data->setUrls(urls); } return data; }
static errorCode ops_startElement(QName qname, void* app_data) { struct ops_AppData* o_appD = (struct ops_AppData*) app_data; if(o_appD->o_strm->context.currElem.uriId == 4) // URI == http://www.w3.org/2009/exi { o_appD->prevElementUriID = 4; switch(o_appD->o_strm->context.currElem.lnId) { case 33: // strict SET_STRICT(o_appD->parsed_ops->enumOpt); o_appD->prevElementLnID = 33; break; case 31: // schemaId o_appD->prevElementLnID = 31; o_appD->parsed_ops->schemaIDMode = SCHEMA_ID_EMPTY; break; case 7: // compression SET_COMPRESSION(o_appD->parsed_ops->enumOpt); o_appD->prevElementLnID = 7; break; case 14: // fragment SET_FRAGMENT(o_appD->parsed_ops->enumOpt); o_appD->prevElementLnID = 14; break; case 13: // dtd SET_PRESERVED(o_appD->parsed_ops->preserve, PRESERVE_DTD); o_appD->prevElementLnID = 13; break; case 29: // prefixes SET_PRESERVED(o_appD->parsed_ops->preserve, PRESERVE_PREFIXES); o_appD->prevElementLnID = 29; break; case 26: // lexicalValues SET_PRESERVED(o_appD->parsed_ops->preserve, PRESERVE_LEXVALUES); o_appD->prevElementLnID = 26; break; case 5: // comments SET_PRESERVED(o_appD->parsed_ops->preserve, PRESERVE_COMMENTS); o_appD->prevElementLnID = 5; break; case 27: // pis SET_PRESERVED(o_appD->parsed_ops->preserve, PRESERVE_PIS); o_appD->prevElementLnID = 27; break; case 4: // alignment->byte SET_ALIGNMENT(o_appD->parsed_ops->enumOpt, BYTE_ALIGNMENT); o_appD->prevElementLnID = 4; break; case 28: // alignment->pre-compress SET_ALIGNMENT(o_appD->parsed_ops->enumOpt, PRE_COMPRESSION); o_appD->prevElementLnID = 28; break; case 32: // selfContained SET_SELF_CONTAINED(o_appD->parsed_ops->enumOpt); o_appD->prevElementLnID = 32; break; case 8: // datatypeRepresentationMap o_appD->prevElementLnID = 8; break; case 36: // uncommon o_appD->prevElementLnID = 36; #if EXI_PROFILE_DEFAULT { // If the EXI Profile default behaviour is followed, then we expect // SE(*) <p/> indicating default EXI Profile parameters // If this is not the case rise an error // SE(*) has event code 5 in the uncommon grammar unsigned int tmp_bits_val; UnsignedInteger lnLen = 0; errorCode tmp_err_code = UNEXPECTED_ERROR; String lnStr; QNameID qnameId = {URI_MAX, LN_MAX}; // Next event code must be SE(*) TRY(decodeNBitUnsignedInteger(o_appD->o_strm, 3, &tmp_bits_val)); if(tmp_bits_val != 5) { DEBUG_MSG(ERROR, DEBUG_CONTENT_IO, (">EXI Profile default active but <p> element missing\n")); return INVALID_EXIP_CONFIGURATION; } // The <p> element QName must be "http://www.w3.org/2009/exi:p" TRY(decodeUri(o_appD->o_strm, &qnameId.uriId)); TRY(decodeUnsignedInteger(o_appD->o_strm, &lnLen)); if(lnLen == 0) // local-name table hit -> should not be the case to have "p" in the local string table return INVALID_EXIP_CONFIGURATION; TRY(allocateStringMemoryManaged(&(lnStr.str),(Index) (lnLen - 1), &o_appD->o_strm->memList)); TRY(decodeStringOnly(o_appD->o_strm, (Index)lnLen - 1, &lnStr)); // NOTE: the "p" local name is in purpose not added to the // local name table of the http://www.w3.org/2009/exi uri, although it should be. // If there are more strings (24 or more) added there in the future // or the <p> element is encoded more than once - both are highly unlikely, // then there will be a problem with the encoding. if(qnameId.uriId != 4 || !stringEqualToAscii(lnStr, "p")) { DEBUG_MSG(ERROR, DEBUG_CONTENT_IO, (">EXI Profile default active but <p> element missing\n")); return INVALID_EXIP_CONFIGURATION; } // The next event code must be EE -> 0.0 TRY(decodeNBitUnsignedInteger(o_appD->o_strm, 2, &tmp_bits_val)); if(tmp_bits_val != 0) { DEBUG_MSG(ERROR, DEBUG_CONTENT_IO, (">EXI Profile default active but <p> element is not empty\n")); return INVALID_EXIP_CONFIGURATION; } } #endif break; } } else // URI != http://www.w3.org/2009/exi { // The previous element should be either uncommon or datatypeRepresentationMap otherwise it is an error // These are the only places where <any> element is allowed if(o_appD->prevElementUriID != 4 || o_appD->prevElementLnID != 36 || o_appD->prevElementLnID != 8) { DEBUG_MSG(ERROR, DEBUG_CONTENT_IO, (">Wrong namespace in the EXI Options\n")); return EXIP_HANDLER_STOP; } // Handle here the user defined meta-data that follows! http://www.w3.org/TR/2011/REC-exi-20110310/#key-userMetaData } return ERR_OK; }