本文整理汇总了C++中QStringMap类的典型用法代码示例。如果您正苦于以下问题:C++ QStringMap类的具体用法?C++ QStringMap怎么用?C++ QStringMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QStringMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readSecrets
void NovellVpnSettingWidget::readSecrets()
{
QStringMap secrets = d->setting->vpnSecrets();
kDebug() << "Value of" << NM_NOVELLVPN_KEY_CERT_PWD << secrets.value(QLatin1String(NM_NOVELLVPN_KEY_CERT_PWD));
d->ui.x509CertPass->setText(secrets.value(QLatin1String(NM_NOVELLVPN_KEY_CERT_PWD)));
d->ui.leUserPass->setText(secrets.value(QLatin1String(NM_NOVELLVPN_KEY_USER_PWD)));
d->ui.leGroupPass->setText(secrets.value(QLatin1String(NM_NOVELLVPN_KEY_GRP_PWD)));
}
示例2: GetHeaderValue
QString SSDP::GetHeaderValue( const QStringMap &headers,
const QString &sKey, const QString &sDefault )
{
QStringMap::const_iterator it = headers.find( sKey.toLower() );
if ( it == headers.end())
return( sDefault );
return *it;
}
示例3: setParams
/**
* This controller needs the parameter 'machine' with the name of the machine
*
* \param[in] params The parameter map
*/
void InfoController::setParams(const QStringMap& params)
{
if( !params.contains("machine") || !params.contains("machine"))
{
std::cerr << "InfoController: Required parameter not found" << std::endl;
return;
}
_machine = params["machine"];
_model.setDatabaseFile( params["db"] );
}
示例4: handleOnePasswordType
uint VpncSettingWidget::handleOnePasswordType(const QComboBox * combo, const QString & key, QStringMap & data)
{
uint type = combo->currentIndex();
switch (type) {
case VpncSettingWidgetPrivate::EnumPasswordStorage::AlwaysAsk:
data.insert(key, QString::number(Knm::Setting::NotSaved));
break;
case VpncSettingWidgetPrivate::EnumPasswordStorage::Save:
data.insert(key, QString::number(Knm::Setting::AgentOwned));
break;
case VpncSettingWidgetPrivate::EnumPasswordStorage::NotRequired:
data.insert(key, QString::number(Knm::Setting::NotRequired));
break;
}
return type;
}
示例5: convertToVariant
QVariantMap convertToVariant(const QStringMap &val)
{
QVariantMap ret;
for(const QString &k : val.keys())
{
ret[k] = val[k];
}
return ret;
}
示例6: parseCookie
QStringMap AbstractWebApplication::parseCookie(const Http::Request &request) const
{
// [rfc6265] 4.2.1. Syntax
QStringMap ret;
const QString cookieStr = request.headers.value(QLatin1String("cookie"));
const QVector<QStringRef> cookies = cookieStr.splitRef(';', QString::SkipEmptyParts);
for (const auto &cookie : cookies) {
const int idx = cookie.indexOf('=');
if (idx < 0)
continue;
const QString name = cookie.left(idx).trimmed().toString();
const QString value = Utils::String::unquote(cookie.mid(idx + 1).trimmed())
.toString();
ret.insert(name, value);
}
return ret;
}
示例7: Q_D
void VpncSettingWidget::readSecrets()
{
Q_D(VpncSettingWidget);
QStringMap secrets = d->setting->vpnSecrets();
Knm::Setting::secretsTypes userType;
Knm::Setting::secretsTypes groupType;
userType = (Knm::Setting::secretsTypes)d->setting->data().value(NM_VPNC_KEY_XAUTH_PASSWORD"-flags").toInt();
if (userType & Knm::Setting::AgentOwned || userType & Knm::Setting::None || !userType) {
d->ui.leUserPassword->setText(secrets.value(QLatin1String(NM_VPNC_KEY_XAUTH_PASSWORD)));
}
fillOnePasswordCombo(d->ui.cboUserPassOptions, userType);
groupType = (Knm::Setting::secretsTypes)d->setting->data().value(NM_VPNC_KEY_SECRET"-flags").toInt();
if (groupType & Knm::Setting::AgentOwned || groupType & Knm::Setting::None || !groupType) {
d->ui.leGroupPassword->setText(secrets.value(QLatin1String(NM_VPNC_KEY_SECRET)));
}
fillOnePasswordCombo(d->ui.cboGroupPassOptions, groupType);
}
示例8: SendAction
void MythFEXML::SendAction(HTTPRequest *pRequest)
{
QStringMap* map = &pRequest->m_mapParams;
pRequest->m_eResponseType = ResponseTypeHTML;
QString sText = map->value("action");
uint pcount = map->size();
VERBOSE(VB_UPNP, QString("UPNP Action: %1 (total %2 params)")
.arg(sText).arg(pcount));
if (!IsValidAction(sText))
return;
if (pcount > 1)
{
bool valid = false;
QStringList args;
if (ACTION_SCREENSHOT == sText && 3 == pcount)
{
args << map->value("width");
args << map->value("height");
valid = true;
}
else if (ACTION_HANDLEMEDIA == sText && 2 == pcount)
{
args << map->value("file");
valid = true;
}
if (valid)
{
MythEvent* me = new MythEvent(sText, args);
qApp->postEvent(GetMythMainWindow(), me);
return;
}
VERBOSE(VB_UPNP, QString("Failed to validate extra paramaters - ignoring"));
}
QKeyEvent* ke = new QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier, sText);
qApp->postEvent(GetMythMainWindow(), (QEvent*)ke);
}
示例9:
void NovellVpnSettingWidget::writeX509Auth(QStringMap & data, QStringMap & secretData)
{
data.insert(QLatin1String(NM_NOVELLVPN_KEY_AUTHTYPE), QLatin1String(NM_NOVELLVPN_CONTYPE_X509_STRING));
data.insert(NM_NOVELLVPN_KEY_CERTIFICATE, d->ui.x509Cert->url().path());
secretData.insert(QLatin1String(NM_NOVELLVPN_KEY_CERT_PWD), d->ui.x509CertPass->text());
}
示例10: url
QDomDocument SOAPClient::SendSOAPRequest(const QString &sMethod,
QStringMap &list,
int &nErrCode,
QString &sErrDesc)
{
QUrl url(m_url);
url.setPath(m_sControlPath);
nErrCode = UPnPResult_Success;
sErrDesc = "";
QDomDocument xmlResult;
if (m_sNamespace.isEmpty())
{
nErrCode = UPnPResult_MythTV_NoNamespaceGiven;
sErrDesc = "No namespace given";
return xmlResult;
}
// --------------------------------------------------------------
// Add appropriate headers
// --------------------------------------------------------------
QHash<QByteArray, QByteArray> headers;
headers.insert("Content-Type", "text/xml; charset=\"utf-8\"");
QString soapHeader = QString("\"%1#%2\"").arg(m_sNamespace).arg(sMethod);
headers.insert("SOAPACTION", soapHeader.toUtf8());
headers.insert("User-Agent", "Mozilla/9.876 (X11; U; Linux 2.2.12-20 i686, en) "
"Gecko/25250101 Netscape/5.432b1");
// --------------------------------------------------------------
// Build request payload
// --------------------------------------------------------------
QByteArray aBuffer;
QTextStream os( &aBuffer );
os.setCodec("UTF-8");
os << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
os << "<s:Envelope "
" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\""
" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n";
os << " <s:Body>\r\n";
os << " <u:" << sMethod << " xmlns:u=\"" << m_sNamespace << "\">\r\n";
// --------------------------------------------------------------
// Add parameters from list
// --------------------------------------------------------------
for (QStringMap::iterator it = list.begin(); it != list.end(); ++it)
{
os << " <" << it.key() << ">";
os << HTTPRequest::Encode( *it );
os << "</" << it.key() << ">\r\n";
}
os << " </u:" << sMethod << ">\r\n";
os << " </s:Body>\r\n";
os << "</s:Envelope>\r\n";
os.flush();
// --------------------------------------------------------------
// Perform Request
// --------------------------------------------------------------
LOG(VB_UPNP, LOG_DEBUG,
QString("SOAPClient(%1) sending:\n %2").arg(url.toString()).arg(aBuffer.constData()));
QString sXml;
if (!GetMythDownloadManager()->postAuth(url.toString(), &aBuffer, NULL, NULL, &headers))
{
LOG(VB_GENERAL, LOG_ERR, QString("SOAPClient::SendSOAPRequest: request failed: %1")
.arg(url.toString()));
}
else
sXml = QString(aBuffer);
// --------------------------------------------------------------
// Parse response
// --------------------------------------------------------------
LOG(VB_UPNP, LOG_DEBUG, "SOAPClient response:\n" +
QString("%1\n").arg(sXml));
// TODO handle timeout without response correctly.
list.clear();
QDomDocument doc;
if (!doc.setContent(sXml, true, &sErrDesc, &nErrCode))
{
LOG(VB_UPNP, LOG_ERR,
QString("SendSOAPRequest( %1 ) - Invalid response from %2")
.arg(sMethod).arg(url.toString()) +
QString("%1: %2").arg(nErrCode).arg(sErrDesc));
//.........这里部分代码省略.........
示例11: kDebug
void NovellVpnSettingWidget::writeConfig()
{
kDebug();
d->setting->setServiceType(QLatin1String(NM_DBUS_SERVICE_NOVELLVPN));
QStringMap data;
QStringMap secretData;
// required settings
data.insert(NM_NOVELLVPN_KEY_GATEWAY, d->ui.leGateway->text());
if (d->ui.cmbGwType->currentIndex() == 0) {
data.insert(QLatin1String(NM_NOVELLVPN_KEY_GWTYPE), QLatin1String(NM_NOVELLVPN_GWTYPE_NORTEL_STRING));
if (d->ui.cmbAuthType->currentIndex() == 0) {
data.insert(QLatin1String(NM_NOVELLVPN_KEY_AUTHTYPE), QLatin1String(NM_NOVELLVPN_CONTYPE_GROUPAUTH_STRING));
data.insert(QLatin1String(NM_NOVELLVPN_KEY_USER_NAME), d->ui.leUserName->text());
data.insert(QLatin1String(NM_NOVELLVPN_KEY_GROUP_NAME), d->ui.leGroupName->text());
secretData.insert(QLatin1String(NM_NOVELLVPN_KEY_USER_PWD), d->ui.leUserPass->text());
secretData.insert(QLatin1String(NM_NOVELLVPN_KEY_GRP_PWD), d->ui.leGroupPass->text());
} else {
writeX509Auth(data, secretData);
}
} else {
data.insert(QLatin1String(NM_NOVELLVPN_KEY_GWTYPE), QLatin1String(NM_NOVELLVPN_GWTYPE_STDGW_STRING));
writeX509Auth(data, secretData);
}
// advanced dialog
data.insert(QLatin1String(NM_NOVELLVPN_KEY_DHGROUP),
(d->advUi.rbDh1->isChecked()
? QString::number(DHGROUP_DH1)
: QString::number(DHGROUP_DH2)));
if (d->advUi.rbPfOff->isChecked()) {
data.insert(QLatin1String(NM_NOVELLVPN_KEY_PFSGROUP), QString::number(PFSGROUP_OFF));
} else if (d->advUi.rbPf1->isChecked()) {
data.insert(QLatin1String(NM_NOVELLVPN_KEY_PFSGROUP), QString::number(PFSGROUP_PFS1));
} else {
data.insert(QLatin1String(NM_NOVELLVPN_KEY_PFSGROUP), QString::number(PFSGROUP_PFS2));
}
data.insert(QLatin1String(NM_NOVELLVPN_KEY_NOSPLITTUNNEL), d->advUi.cbDisableSplit->isChecked() ? QLatin1String("yes") : QLatin1String("no"));
d->setting->setData(data);
d->setting->setVpnSecrets(secretData);
}
示例12: GetConnectionInfo
UPnPResultCode MythXMLClient::GetConnectionInfo( const QString &sPin, DatabaseParams *pParams, QString &sMsg )
{
if (pParams == NULL)
return UPnPResult_InvalidArgs;
int nErrCode = 0;
QString sErrDesc;
QStringMap list;
sMsg.clear();
list.insert( "Pin", sPin );
QDomDocument xmlResults = SendSOAPRequest(
"GetConnectionInfo", list, nErrCode, sErrDesc, m_bInQtThread);
// --------------------------------------------------------------
// Is this a valid response?
// --------------------------------------------------------------
QDomNode oNode = xmlResults.namedItem( "GetConnectionInfoResult" );
if (UPnPResult_Success == nErrCode && !oNode.isNull())
{
QDomNode dbNode = oNode.namedItem( "Database" );
pParams->dbHostName = GetNodeValue( dbNode, "Host" , QString());
pParams->dbPort = GetNodeValue( dbNode, "Port" , 0 );
pParams->dbUserName = GetNodeValue( dbNode, "UserName" , QString());
pParams->dbPassword = GetNodeValue( dbNode, "Password" , QString());
pParams->dbName = GetNodeValue( dbNode, "Name" , QString());
pParams->dbType = GetNodeValue( dbNode, "Type" , QString());
QDomNode wolNode = oNode.namedItem( "WOL" );
pParams->wolEnabled = GetNodeValue( wolNode, "Enabled" , false );
pParams->wolReconnect = GetNodeValue( wolNode, "Reconnect", 0 );
pParams->wolRetry = GetNodeValue( wolNode, "Retry" , 0 );
pParams->wolCommand = GetNodeValue( wolNode, "Command" , QString());
return UPnPResult_Success;
}
else
{
sMsg = sErrDesc;
LOG(VB_GENERAL, LOG_ERR,
QString("MythXMLClient::GetConnectionInfo Failed - (%1) %2")
.arg(nErrCode) .arg(sErrDesc));
}
if (( nErrCode == UPnPResult_HumanInterventionRequired ) ||
( nErrCode == UPnPResult_ActionNotAuthorized ) ||
( nErrCode == 501 ))
{
// Service calls no longer return UPnPResult codes,
// convert standard 501 to UPnPResult code for now.
return UPnPResult_ActionNotAuthorized;
}
return UPnPResult_ActionFailed;
}
示例13: Q_D
void OpenconnectSettingWidget::writeConfig()
{
Q_D(OpenconnectSettingWidget);
d->setting->setServiceType(QLatin1String(NM_DBUS_SERVICE_OPENCONNECT));
QStringMap data;
QStringMap secretData;
data.insert(QLatin1String(NM_OPENCONNECT_KEY_GATEWAY), d->ui.leGateway->text().toUtf8());
if (!d->ui.leCaCertificate->url().isEmpty())
data.insert(QLatin1String(NM_OPENCONNECT_KEY_CACERT), d->ui.leCaCertificate->url().path());
if (!d->ui.leProxy->text().isEmpty())
data.insert(QLatin1String(NM_OPENCONNECT_KEY_PROXY), d->ui.leProxy->text().toUtf8());
data.insert(QLatin1String(NM_OPENCONNECT_KEY_CSD_ENABLE), d->ui.chkAllowTrojan->isChecked() ? "yes" : "no");
if (!d->ui.leCsdWrapperScript->url().isEmpty())
data.insert(QLatin1String(NM_OPENCONNECT_KEY_CSD_WRAPPER), d->ui.leCsdWrapperScript->url().path());
if (!d->ui.leUserCert->url().isEmpty())
data.insert(QLatin1String(NM_OPENCONNECT_KEY_USERCERT), d->ui.leUserCert->url().path());
if (!d->ui.leUserPrivateKey->url().isEmpty())
data.insert(QLatin1String(NM_OPENCONNECT_KEY_PRIVKEY), d->ui.leUserPrivateKey->url().path());
data.insert(QLatin1String(NM_OPENCONNECT_KEY_PEM_PASSPHRASE_FSID), d->ui.chkUseFsid->isChecked() ? "yes" : "no");
/* These are different for every login session, and should not be stored */
data.insert(QLatin1String(NM_OPENCONNECT_KEY_COOKIE"-flags"), QString::number(Knm::Setting::NotSaved));
data.insert(QLatin1String(NM_OPENCONNECT_KEY_GWCERT"-flags"), QString::number(Knm::Setting::NotSaved));
data.insert(QLatin1String(NM_OPENCONNECT_KEY_GATEWAY"-flags"), QString::number(Knm::Setting::NotSaved));
d->setting->setData(data);
//VpnSecrets empty so far, they will be acquired by the auth dialog
d->setting->setVpnSecrets(secretData);
}
示例14: GetConnectionInfo
UPnPResultCode MythXMLClient::GetConnectionInfo( const QString &sPin, DatabaseParams *pParams, QString &sMsg )
{
if (pParams == NULL)
return UPnPResult_InvalidArgs;
int nErrCode = 0;
QString sErrDesc;
QStringMap list;
sMsg.clear();
list.insert( "Pin", sPin );
if (SendSOAPRequest( "GetConnectionInfo", list, nErrCode, sErrDesc, m_bInQtThread ))
{
QString sXml = "<Info>" + list[ "Info" ] + "</Info>";
sMsg = sErrDesc;
QDomDocument doc;
if ( !doc.setContent( sXml, false, &sErrDesc, &nErrCode ))
{
sMsg = QObject::tr("Error Requesting Connection Info");
VERBOSE( VB_UPNP, QString( "Error Requesting Connection Info : (%1) - %2" )
.arg( nErrCode )
.arg( sErrDesc ) );
return UPnPResult_ActionFailed;
}
// --------------------------------------------------------------
// Is this a valid response?
// --------------------------------------------------------------
QDomNode infoNode = doc.namedItem( "Info" );
if (!infoNode.isNull())
{
QDomNode dbNode = infoNode.namedItem( "Database" );
pParams->dbHostName = GetNodeValue( dbNode, "Host" , QString( ));
pParams->dbPort = GetNodeValue( dbNode, "Port" , 0 );
pParams->dbUserName = GetNodeValue( dbNode, "UserName" , QString( ));
pParams->dbPassword = GetNodeValue( dbNode, "Password" , QString( ));
pParams->dbName = GetNodeValue( dbNode, "Name" , QString( ));
pParams->dbType = GetNodeValue( dbNode, "Type" , QString( ));
QDomNode wolNode = infoNode.namedItem( "WOL" );
pParams->wolEnabled = GetNodeValue( wolNode, "Enabled" , false );
pParams->wolReconnect = GetNodeValue( wolNode, "Reconnect", 0 );
pParams->wolRetry = GetNodeValue( wolNode, "Retry" , 0 );
pParams->wolCommand = GetNodeValue( wolNode, "Command" , QString( ));
return UPnPResult_Success;
}
else
{
if (sMsg.isEmpty())
sMsg = QObject::tr("Unexpected Response");
VERBOSE( VB_IMPORTANT, QString( "MythXMLClient::GetConnectionInfo Failed : Unexpected Response - %1" )
.arg( sXml ));
}
}
else
{
sMsg = sErrDesc;
if (sMsg.isEmpty())
sMsg = QObject::tr("Access Denied");
VERBOSE( VB_IMPORTANT, QString( "MythXMLClient::GetConnectionInfo Failed - (%1) %2" )
.arg( nErrCode )
.arg( sErrDesc ));
}
if (UPnPResult_HumanInterventionRequired == nErrCode
|| UPnPResult_ActionNotAuthorized == nErrCode)
return (UPnPResultCode)nErrCode;
return UPnPResult_ActionFailed;
}
示例15: url
bool SOAPClient::SendSOAPRequest( const QString &sMethod,
QStringMap &list,
int &nErrCode,
QString &sErrDesc,
bool bInQtThread )
{
QUrl url( m_url );
url.setPath( m_sControlPath );
// --------------------------------------------------------------
// Add appropriate headers
// --------------------------------------------------------------
QHttpRequestHeader header;
header.setValue("CONTENT-TYPE", "text/xml; charset=\"utf-8\"" );
header.setValue("SOAPACTION" , QString( "\"%1#GetConnectionInfo\"" )
.arg( m_sNamespace ));
// --------------------------------------------------------------
// Build request payload
// --------------------------------------------------------------
QByteArray aBuffer;
QTextStream os( &aBuffer );
os << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
os << "<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n";
os << " <s:Body>\r\n";
os << " <u:" << sMethod << " xmlns:u=\"" << m_sNamespace << "\">\r\n";
// --------------------------------------------------------------
// Add parameters from list
// --------------------------------------------------------------
for ( QStringMap::iterator it = list.begin();
it != list.end();
++it )
{
os << " <" << it.key() << ">";
os << HTTPRequest::Encode( *it );
os << "</" << it.key() << ">\r\n";
}
os << " </u:" << sMethod << ">\r\n";
os << " </s:Body>\r\n";
os << "</s:Envelope>\r\n";
os.flush();
// --------------------------------------------------------------
// Perform Request
// --------------------------------------------------------------
QBuffer buff( &aBuffer );
QString sXml = HttpComms::postHttp( url,
&header,
(QIODevice *)&buff,
10000, // ms
3, // retries
0, // redirects
false, // allow gzip
NULL, // login
bInQtThread );
// --------------------------------------------------------------
// Parse response
// --------------------------------------------------------------
list.clear();
QDomDocument doc;
if ( !doc.setContent( sXml, true, &sErrDesc, &nErrCode ))
{
VERBOSE( VB_UPNP, QString( "MythXMLClient::SendSOAPRequest( %1 ) - Invalid response from %2" )
.arg( sMethod )
.arg( url.toString() ));
return false;
}
// --------------------------------------------------------------
// Is this a valid response?
// --------------------------------------------------------------
QString sResponseName = sMethod + "Response";
QDomNodeList oNodeList = doc.elementsByTagNameNS( m_sNamespace, sResponseName );
if (oNodeList.count() > 0)
{
QDomNode oMethod = oNodeList.item(0);
if (!oMethod.isNull())
{
for ( QDomNode oNode = oMethod.firstChild(); !oNode.isNull();
oNode = oNode.nextSibling() )
{
//.........这里部分代码省略.........