本文整理汇总了C++中KUrl::setHost方法的典型用法代码示例。如果您正苦于以下问题:C++ KUrl::setHost方法的具体用法?C++ KUrl::setHost怎么用?C++ KUrl::setHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KUrl
的用法示例。
在下文中一共展示了KUrl::setHost方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void
CoverFetchSearchPayload::prepareUrls()
{
KUrl url;
url.setScheme( "http" );
CoverFetch::Metadata metadata;
switch( m_src )
{
default:
case CoverFetch::LastFm:
url.setHost( "ws.audioscrobbler.com" );
url.setPath( "/2.0/" );
url.addQueryItem( "api_key", Amarok::lastfmApiKey() );
url.addQueryItem( "limit", QString::number( 20 ) );
url.addQueryItem( "page", QString::number( m_page ) );
url.addQueryItem( "album", sanitizeQuery( m_query ) );
url.addQueryItem( "method", method() );
metadata[ "source" ] = "Last.fm";
metadata[ "method" ] = method();
break;
case CoverFetch::Discogs:
url.setHost( "www.discogs.com" );
url.setPath( "/search" );
url.addQueryItem( "api_key", Amarok::discogsApiKey() );
url.addQueryItem( "page", QString::number( m_page + 1 ) );
url.addQueryItem( "type", "all" );
url.addQueryItem( "q", sanitizeQuery( m_query ) );
url.addQueryItem( "f", "xml" );
metadata[ "source" ] = "Discogs";
break;
case CoverFetch::Yahoo:
url.setHost( "boss.yahooapis.com" );
url.setPath( "/ysearch/images/v1/" + sanitizeQuery( m_query ) );
url.addQueryItem( "appid", Amarok::yahooBossApiKey() );
url.addQueryItem( "count", QString::number( 20 ) );
url.addQueryItem( "start", QString::number( 20 * m_page ) );
url.addQueryItem( "format", "xml" );
metadata[ "source" ] = "Yahoo!";
break;
case CoverFetch::Google:
url.setHost( "images.google.com" );
url.setPath( "/images" );
url.addQueryItem( "q", sanitizeQuery( m_query ) );
url.addQueryItem( "gbv", QChar( '1' ) );
url.addQueryItem( "filter", QChar( '1' ) );
url.addQueryItem( "start", QString::number( 20 * m_page ) );
metadata[ "source" ] = "Google";
break;
}
if( url.isValid() )
m_urls.insert( url, metadata );
}
示例2: findUrlForAccount
static KUrl findUrlForAccount( const KMail::ImapAccountBase * a ) {
assert( a );
const SieveConfig sieve = a->sieveConfig();
if ( !sieve.managesieveSupported() )
return KUrl();
if ( sieve.reuseConfig() ) {
// assemble Sieve url from the settings of the account:
KUrl u;
u.setProtocol( "sieve" );
u.setHost( a->host() );
u.setUser( a->login() );
u.setPass( a->passwd() );
u.setPort( sieve.port() );
u.addQueryItem( "x-mech", a->auth() == "*" ? "PLAIN" : a->auth() ); //translate IMAP LOGIN to PLAIN
if ( !a->useSSL() && !a->useTLS() )
u.addQueryItem( "x-allow-unencrypted", "true" );
u.setFileName( sieve.vacationFileName() );
return u;
} else {
KUrl u = sieve.alternateURL();
if ( u.protocol().toLower() == "sieve" && !a->useSSL() && !a->useTLS() && u.queryItem("x-allow-unencrypted").isEmpty() )
u.addQueryItem( "x-allow-unencrypted", "true" );
u.setFileName( sieve.vacationFileName() );
return u;
}
}
示例3: parseURL
static KUrl parseURL( int mRealArgType, const QString& str )
{
if ( mRealArgType == 33 ) { // LDAP server
// The format is HOSTNAME:PORT:USERNAME:PASSWORD:BASE_DN
QStringList items = str.split( ':' );
if ( items.count() == 5 ) {
QStringList::const_iterator it = items.constBegin();
KUrl url;
url.setProtocol( "ldap" );
url.setHost( urlpart_decode( *it++ ) );
bool ok;
const int port = (*it++).toInt( &ok );
if ( ok )
url.setPort( port );
else if ( !it->isEmpty() )
kWarning(5150) <<"parseURL: malformed LDAP server port, ignoring: \"" << *it << "\"";
url.setPath( "/" ); // workaround KUrl parsing bug
url.setUser( urlpart_decode( *it++ ) );
url.setPass( urlpart_decode( *it++ ) );
url.setQuery( urlpart_decode( *it ) );
return url;
} else
kWarning(5150) <<"parseURL: malformed LDAP server:" << str;
}
// other URLs : assume wellformed URL syntax.
return KUrl( str );
}
示例4: xml
void
CoverFetchInfoPayload::prepareDiscogsUrls( const QByteArray &data )
{
QXmlStreamReader xml( QString::fromUtf8(data) );
while( !xml.atEnd() && !xml.hasError() )
{
xml.readNext();
if( xml.isStartElement() && xml.name() == "searchresults" )
{
while( !xml.atEnd() && !xml.hasError() )
{
xml.readNext();
const QStringRef &n = xml.name();
if( xml.isEndElement() && n == "searchresults" )
break;
if( !xml.isStartElement() )
continue;
if( n == "result" )
{
while( !xml.atEnd() && !xml.hasError() )
{
xml.readNext();
if( xml.isEndElement() && n == "result" )
break;
if( !xml.isStartElement() )
continue;
if( xml.name() == "uri" )
{
KUrl releaseUrl( xml.readElementText() );
QString releaseStr = releaseUrl.url( KUrl::RemoveTrailingSlash );
QString releaseId = releaseStr.split( '/' ).last();
KUrl url;
url.setScheme( "http" );
url.setHost( "www.discogs.com" );
url.setPath( "/release/" + releaseId );
url.addQueryItem( "api_key", Amarok::discogsApiKey() );
url.addQueryItem( "f", "xml" );
CoverFetch::Metadata metadata;
metadata[ "source" ] = "Discogs";
if( url.isValid() )
m_urls.insert( url, metadata );
}
else
xml.skipCurrentElement();
}
}
else
xml.skipCurrentElement();
}
}
}
}
示例5: info
PhotosInfo::List
PhotosEngine::photosListFromXml( QXmlStreamReader &xml )
{
PhotosInfo::List photoList;
xml.readNextStartElement(); // rsp
if( xml.attributes().value(QLatin1String("stat")) != QLatin1String("ok") )
return photoList;
xml.readNextStartElement(); // photos
while( xml.readNextStartElement() )
{
if( xml.name() == QLatin1String("photo") )
{
const QXmlStreamAttributes &attr = xml.attributes();
QStringRef id = attr.value( QLatin1String("id") );
QStringRef farm = attr.value( QLatin1String("farm") );
QStringRef owner = attr.value( QLatin1String("owner") );
QStringRef secret = attr.value( QLatin1String("secret") );
QStringRef server = attr.value( QLatin1String("server") );
QStringRef title = attr.value( QLatin1String("title") );
KUrl photoUrl;
photoUrl.setScheme( "http" );
photoUrl.setHost( QString("farm%1.static.flickr.com").arg( farm.toString() ) );
photoUrl.setPath( QString("/%1/%2_%3.jpg").arg( server.toString(), id.toString(), secret.toString() ) );
KUrl pageUrl;
pageUrl.setScheme( "http" );
pageUrl.setHost( QLatin1String("www.flickr.com") );
pageUrl.setPath( QString("/photos/%1/%2").arg( owner.toString(), id.toString() ) );
PhotosInfoPtr info( new PhotosInfo );
info->title = title.toString();
info->urlpage = pageUrl;
info->urlphoto = photoUrl;
photoList.append( info );
}
xml.skipCurrentElement();
}
return photoList;
}
示例6: SLOT
void
ArtistWidget::fetchTopTrack()
{
// we genere the url for the demand on the lastFM Api
KUrl url;
url.setScheme( "http" );
url.setHost( "ws.audioscrobbler.com" );
url.setPath( "/2.0/" );
url.addQueryItem( "method", "artist.getTopTracks" );
url.addQueryItem( "api_key", Amarok::lastfmApiKey() );
url.addQueryItem( "artist", m_artist->name() );
The::networkAccessManager()->getData( url, this,
SLOT(parseTopTrack(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) );
}
示例7: SLOT
void
SimilarArtistsEngine::similarArtistsRequest( const QString &artistName )
{
// we generate the url for the demand on the lastFM Api
KUrl url;
url.setScheme( "http" );
url.setHost( "ws.audioscrobbler.com" );
url.setPath( "/2.0/" );
url.addQueryItem( "method", "artist.getSimilar" );
url.addQueryItem( "api_key", Amarok::lastfmApiKey() );
url.addQueryItem( "artist", artistName );
url.addQueryItem( "limit", QString::number( m_maxArtists ) );
The::networkAccessManager()->getData( url, this,
SLOT(parseSimilarArtists(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) );
}
示例8: getUrl
KUrl Site::getUrl()
{
KUrl url;
// Properly translate the protocol value
switch (protocol()) {
case ProtoFtp: url.setProtocol("ftp"); break;
case ProtoSftp: url.setProtocol("sftp"); break;
}
url.setHost(getProperty("host"));
url.setPort(getIntProperty("port"));
url.setUser(getProperty("username"));
url.setPass(getProperty("password"));
return url;
}
示例9: if
KUrl Kopete::Transfer::displayURL( const Kopete::Contact *contact, const QString &file )
{
KUrl url;
url.setProtocol( QString::fromLatin1("kopete") );
QString host;
if( !contact )
host = QString::fromLatin1("unknown origin");
else if( contact->metaContact() )
host = contact->metaContact()->displayName();
else
host = contact->contactId();
url.setHost(host);
// url.setPath( contact->protocol()->displayName() );
url.setFileName( file );
return url;
}
示例10: validateCurrentPage
bool KNetAttach::validateCurrentPage()
{
if (currentPage() == _folderType){
_host->setFocus();
_connectionName->setFocus();
if (_webfolder->isChecked()) {
setInformationText("WebFolder");
updateForProtocol("WebFolder");
_port->setValue(80);
} else if (_fish->isChecked()) {
setInformationText("Fish");
updateForProtocol("Fish");
_port->setValue(22);
} else if (_ftp->isChecked()) {
setInformationText("FTP");
updateForProtocol("FTP");
_port->setValue(21);
if (_path->text().isEmpty()) {
_path->setText("/");
}
} else if (_smb->isChecked()) {
setInformationText("SMB");
updateForProtocol("SMB");
} else { //if (_recent->isChecked()) {
KConfig recent( "krecentconnections", KConfig::NoGlobals );
if (!recent.hasGroup(_recentConnectionName->currentText())) {
KConfigGroup group = recent.group("General");
QStringList idx = group.readEntry("Index",QStringList());
if (idx.isEmpty()) {
_recent->setEnabled(false);
if (_recent->isChecked()) {
_webfolder->setChecked(true);
}
} else {
_recent->setEnabled(true);
_recentConnectionName->addItems(idx);
}
return false;
}
KConfigGroup group = recent.group(_recentConnectionName->currentText());
_type = group.readEntry("Type");
setInformationText(_type);
if (!updateForProtocol(_type)) {
// FIXME: handle error
}
KUrl u(group.readEntry("URL"));
_host->setText(u.host());
_user->setText(u.user());
_path->setText(u.path());
if (group.hasKey("Port")) {
_port->setValue(group.readEntry("Port",0));
} else {
_port->setValue(u.port());
}
_connectionName->setText(_recentConnectionName->currentText());
_createIcon->setChecked(false);
}
updateParametersPageStatus();
}else{
button(BackButton)->setEnabled(false);
button(FinishButton)->setEnabled(false);
KUrl url;
if (_type == "WebFolder") {
if (_useEncryption->isChecked()) {
url.setProtocol("webdavs");
} else {
url.setProtocol("webdav");
}
url.setPort(_port->value());
} else if (_type == "Fish") {
KConfig config("kio_fishrc");
KConfigGroup cg(&config, _host->text().trimmed());
cg.writeEntry("Charset", KCharsets::charsets()->encodingForName(_encoding->currentText()));
url.setProtocol(_protocolText->currentText());
url.setPort(_port->value());
} else if (_type == "FTP") {
url.setProtocol("ftp");
url.setPort(_port->value());
KConfig config("kio_ftprc");
KConfigGroup cg(&config, _host->text().trimmed());
cg.writeEntry("Charset", KCharsets::charsets()->encodingForName(_encoding->currentText()));
config.sync();
} else if (_type == "SMB") {
url.setProtocol("smb");
} else { // recent
}
url.setHost(_host->text().trimmed());
url.setUser(_user->text().trimmed());
QString path = _path->text().trimmed();
#ifndef Q_WS_WIN
// could a relative path really be made absolute by simply prepending a '/' ?
if (!path.startsWith('/')) {
path = QString("/") + path;
}
#endif
url.setPath(path);
_folderParameters->setEnabled(false);
//.........这里部分代码省略.........
示例11: if
void
PhotosEngine::update( bool force )
{
QString tmpYoutStr;
// prevent
Meta::TrackPtr currentTrack = The::engineController()->currentTrack();
if( !currentTrack || !currentTrack->artist() )
{
debug() << "invalid current track";
setData( "photos", Plasma::DataEngine::Data() );
return;
}
else if( !force && currentTrack->artist()->name() == m_artist )
{
debug() << "artist name unchanged";
setData( "photos", Plasma::DataEngine::Data() );
return;
}
else
{
unsubscribeFrom( m_currentTrack );
m_currentTrack = currentTrack;
subscribeTo( currentTrack );
if ( !currentTrack )
return;
// Save artist
m_artist = currentTrack->artist()->name();
removeAllData( "photos" );
// Show the information
if( !m_artist.isEmpty() )
{
setData( "photos", "message", "Fetching");
setData( "photos", "artist", m_artist );
}
else
{
removeAllData( "photos" );
return;
}
QStringList tags = m_keywords;
tags << m_artist;
tags.removeDuplicates();
// Query flickr, order by relevance, 10 max
// Flickr :http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=9c5a288116c34c17ecee37877397fe31&text=ARTIST&per_page=20
KUrl flickrUrl;
flickrUrl.setScheme( "http" );
flickrUrl.setHost( "api.flickr.com" );
flickrUrl.setPath( "/services/rest/" );
flickrUrl.addQueryItem( "method", "flickr.photos.search" );
flickrUrl.addQueryItem( "api_key", Amarok::flickrApiKey() );
flickrUrl.addQueryItem( "per_page", QString::number( m_nbPhotos ) );
flickrUrl.addQueryItem( "sort", "date-posted-desc" );
flickrUrl.addQueryItem( "media", "photos" );
flickrUrl.addQueryItem( "content_type", QString::number(1) );
flickrUrl.addQueryItem( "text", tags.join(" ") );
debug() << "Flickr url:" << flickrUrl;
m_flickrUrls << flickrUrl;
The::networkAccessManager()->getData( flickrUrl, this,
SLOT(resultFlickr(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) );
}
}