summaryrefslogtreecommitdiffstats
path: root/src/qt3support/network
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-05-28 08:27:50 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-05-28 08:31:07 (GMT)
commitf390f9b51cf8686e9ed44f13a33c7349b9e96a09 (patch)
tree162c768769713a7215bca64daf8f2bdc75c9fbee /src/qt3support/network
parent0bb0699d403b7541472a72a4057ecf0ca366a7cd (diff)
downloadQt-f390f9b51cf8686e9ed44f13a33c7349b9e96a09.zip
Qt-f390f9b51cf8686e9ed44f13a33c7349b9e96a09.tar.gz
Qt-f390f9b51cf8686e9ed44f13a33c7349b9e96a09.tar.bz2
improved string operations all over the place
used character operations whenever possible better usage of QLatin1String
Diffstat (limited to 'src/qt3support/network')
-rw-r--r--src/qt3support/network/q3dns.cpp16
-rw-r--r--src/qt3support/network/q3ftp.cpp22
-rw-r--r--src/qt3support/network/q3http.cpp8
-rw-r--r--src/qt3support/network/q3url.cpp61
-rw-r--r--src/qt3support/network/q3urloperator.cpp2
5 files changed, 54 insertions, 55 deletions
diff --git a/src/qt3support/network/q3dns.cpp b/src/qt3support/network/q3dns.cpp
index c53f2ff..3ca3977 100644
--- a/src/qt3support/network/q3dns.cpp
+++ b/src/qt3support/network/q3dns.cpp
@@ -1738,7 +1738,7 @@ void Q3Dns::setLabel( const QString & label )
const char * dom;
while( (dom=it.current()) != 0 ) {
++it;
- n.append( l.lower() + QLatin1String(".") + QLatin1String(dom) );
+ n.append( l.lower() + QLatin1Char('.') + QLatin1String(dom) );
}
}
n.append( l.lower() );
@@ -1902,8 +1902,8 @@ QString Q3Dns::toInAddrArpaDomain( const QHostAddress &address )
s = QLatin1String("ip6.arpa");
uint b = 0;
while( b < 16 ) {
- s = QString::number( i.c[b]%16, 16 ) + QLatin1String(".") +
- QString::number( i.c[b]/16, 16 ) + QLatin1String(".") + s;
+ s = QString::number( i.c[b]%16, 16 ) + QLatin1Char('.') +
+ QString::number( i.c[b]/16, 16 ) + QLatin1Char('.') + s;
b++;
}
}
@@ -2347,7 +2347,7 @@ void Q3Dns::doResInit()
nameServer += QLatin1String(dnsServer->IpAddress.String);
dnsServer = dnsServer->Next;
if ( dnsServer != 0 )
- nameServer += QLatin1String(" ");
+ nameServer += QLatin1Char(' ');
}
searchList = QLatin1String("");
separator = ' ';
@@ -2360,12 +2360,12 @@ void Q3Dns::doResInit()
}
if ( !gotNetworkParams ) {
if ( getDnsParamsFromRegistry(
- QString( QLatin1String("System\\CurrentControlSet\\Services\\Tcpip\\Parameters") ),
+ QLatin1String("System\\CurrentControlSet\\Services\\Tcpip\\Parameters"),
&domainName, &nameServer, &searchList )) {
// for NT
separator = ' ';
} else if ( getDnsParamsFromRegistry(
- QString( QLatin1String("System\\CurrentControlSet\\Services\\VxD\\MSTCP") ),
+ QLatin1String("System\\CurrentControlSet\\Services\\VxD\\MSTCP"),
&domainName, &nameServer, &searchList )) {
// for Windows 98
separator = ',';
@@ -2395,7 +2395,7 @@ void Q3Dns::doResInit()
} while( first < (int)nameServer.length() );
}
- searchList = searchList + QLatin1String(" ") + domainName;
+ searchList += QLatin1Char(' ') + domainName;
searchList = searchList.simplifyWhiteSpace().lower();
first = 0;
do {
@@ -2488,7 +2488,7 @@ void Q3Dns::doResInit()
while ( !stream.atEnd() ) {
line = stream.readLine();
QStringList list = QStringList::split( QLatin1String(" "), line );
- if( line.startsWith( QLatin1String("#") ) || list.size() < 2 )
+ if( line.startsWith( QLatin1Char('#') ) || list.size() < 2 )
continue;
const QString type = list[0].lower();
diff --git a/src/qt3support/network/q3ftp.cpp b/src/qt3support/network/q3ftp.cpp
index 5ab84cc..44c1f5c 100644
--- a/src/qt3support/network/q3ftp.cpp
+++ b/src/qt3support/network/q3ftp.cpp
@@ -485,7 +485,7 @@ bool Q3FtpDTP::parseDir( const QString &buffer, const QString &userName, QUrlInf
dateStr += lst[ 6 ];
dateStr += QLatin1Char(' ');
- if ( lst[ 7 ].contains( QLatin1String(":") ) ) {
+ if ( lst[ 7 ].contains( QLatin1Char(':') ) ) {
time = QTime( lst[ 7 ].left( 2 ).toInt(), lst[ 7 ].right( 2 ).toInt() );
dateStr += QString::number( QDate::currentDate().year() );
} else {
@@ -495,7 +495,7 @@ bool Q3FtpDTP::parseDir( const QString &buffer, const QString &userName, QUrlInf
QDate date = QDate::fromString( dateStr );
info->setLastModified( QDateTime( date, time ) );
- if ( lst[ 7 ].contains( QLatin1String(":") ) ) {
+ if ( lst[ 7 ].contains( QLatin1Char(':') ) ) {
const int futureTolerance = 600;
if( info->lastModified().secsTo( QDateTime::currentDateTime() ) < -futureTolerance ) {
QDateTime dt = info->lastModified();
@@ -512,7 +512,7 @@ bool Q3FtpDTP::parseDir( const QString &buffer, const QString &userName, QUrlInf
else {
QString n;
for ( uint i = 8; i < (uint) lst.count(); ++i )
- n += lst[ i ] + QLatin1String(" ");
+ n += lst[ i ] + QLatin1Char(' ');
n = n.stripWhiteSpace();
info->setName( n );
}
@@ -897,7 +897,7 @@ bool Q3FtpPI::processReply()
// ### error handling
} else {
QStringList lst = addrPortPattern.capturedTexts();
- QString host = lst[1] + QLatin1String(".") + lst[2] + QLatin1String(".") + lst[3] + QLatin1String(".") + lst[4];
+ QString host = lst[1] + QLatin1Char('.') + lst[2] + QLatin1Char('.') + lst[3] + QLatin1Char('.') + lst[4];
Q_UINT16 port = ( lst[5].toUInt() << 8 ) + lst[6].toUInt();
waitForDtpToConnect = true;
dtp.connectToHost( host, port );
@@ -1435,8 +1435,8 @@ int Q3Ftp::connectToHost( const QString &host, Q_UINT16 port )
int Q3Ftp::login( const QString &user, const QString &password )
{
QStringList cmds;
- cmds << ( QString(QLatin1String("USER ")) + ( user.isNull() ? QString(QLatin1String("anonymous")) : user ) + QLatin1String("\r\n") );
- cmds << ( QString(QLatin1String("PASS ")) + ( password.isNull() ? QString(QLatin1String("anonymous@")) : password ) + QLatin1String("\r\n") );
+ cmds << ( QString::fromLatin1("USER ") + ( user.isNull() ? QString::fromLatin1("anonymous") : user ) + QLatin1String("\r\n") );
+ cmds << ( QString::fromLatin1("PASS ") + ( password.isNull() ? QString::fromLatin1("anonymous@") : password ) + QLatin1String("\r\n") );
return addCommand( new Q3FtpCommand( Login, cmds ) );
}
@@ -2095,7 +2095,7 @@ void Q3Ftp::operationListChildren( Q3NetworkOperation *op )
{
op->setState( StInProgress );
- cd( ( url()->path().isEmpty() ? QString( QLatin1String("/") ) : url()->path() ) );
+ cd( ( url()->path().isEmpty() ? QString::fromLatin1("/") : url()->path() ) );
list();
emit start( op );
}
@@ -2115,7 +2115,7 @@ void Q3Ftp::operationRemove( Q3NetworkOperation *op )
{
op->setState( StInProgress );
- cd( ( url()->path().isEmpty() ? QString( QLatin1String("/") ) : url()->path() ) );
+ cd( ( url()->path().isEmpty() ? QString::fromLatin1("/") : url()->path() ) );
remove( Q3Url( op->arg( 0 ) ).path() );
}
@@ -2125,7 +2125,7 @@ void Q3Ftp::operationRename( Q3NetworkOperation *op )
{
op->setState( StInProgress );
- cd( ( url()->path().isEmpty() ? QString( QLatin1String("/") ) : url()->path() ) );
+ cd( ( url()->path().isEmpty() ? QString::fromLatin1("/") : url()->path() ) );
rename( op->arg( 0 ), op->arg( 1 ));
}
@@ -2179,8 +2179,8 @@ bool Q3Ftp::checkConnection( Q3NetworkOperation *op )
connectToHost( url()->host(), url()->port() != -1 ? url()->port() : 21 );
break;
}
- QString user = url()->user().isEmpty() ? QString( QLatin1String("anonymous") ) : url()->user();
- QString pass = url()->password().isEmpty() ? QString( QLatin1String("anonymous@") ) : url()->password();
+ QString user = url()->user().isEmpty() ? QString::fromLatin1("anonymous") : url()->user();
+ QString pass = url()->password().isEmpty() ? QString::fromLatin1("anonymous@") : url()->password();
login( user, pass );
}
diff --git a/src/qt3support/network/q3http.cpp b/src/qt3support/network/q3http.cpp
index 591b381..aabf4a3 100644
--- a/src/qt3support/network/q3http.cpp
+++ b/src/qt3support/network/q3http.cpp
@@ -468,7 +468,7 @@ bool Q3HttpHeader::parse( const QString& str )
if ( !(*it).isEmpty() ) {
if ( (*it)[0].isSpace() ) {
if ( !lines.isEmpty() ) {
- lines.last() += QLatin1String(" ");
+ lines.last() += QLatin1Char(' ');
lines.last() += (*it).stripWhiteSpace();
}
} else {
@@ -562,7 +562,7 @@ void Q3HttpHeader::removeValue( const QString& key )
*/
bool Q3HttpHeader::parseLine( const QString& line, int )
{
- int i = line.find( QLatin1String(":") );
+ int i = line.find( QLatin1Char(':') );
if ( i == -1 )
return false;
@@ -647,7 +647,7 @@ QString Q3HttpHeader::contentType() const
if ( type.isEmpty() )
return QString();
- int pos = type.find( QLatin1String(";") );
+ int pos = type.find( QLatin1Char(';') );
if ( pos == -1 )
return type;
@@ -2210,7 +2210,7 @@ void Q3Http::clientReply( const Q3HttpResponseHeader &rep )
if ( rep.statusCode() >= 400 && rep.statusCode() < 600 ) {
op->setState( StFailed );
op->setProtocolDetail(
- QString(QLatin1String("%1 %2")).arg(rep.statusCode()).arg(rep.reasonPhrase())
+ QString::fromLatin1("%1 %2").arg(rep.statusCode()).arg(rep.reasonPhrase())
);
switch ( rep.statusCode() ) {
case 401:
diff --git a/src/qt3support/network/q3url.cpp b/src/qt3support/network/q3url.cpp
index fc2fdb2..68753b6 100644
--- a/src/qt3support/network/q3url.cpp
+++ b/src/qt3support/network/q3url.cpp
@@ -211,8 +211,8 @@ Q3Url::Q3Url( const Q3Url& url )
bool Q3Url::isRelativeUrl( const QString &url )
{
- int colon = url.find( QLatin1String(":") );
- int slash = url.find( QLatin1String("/") );
+ int colon = url.find( QLatin1Char(':') );
+ int slash = url.find( QLatin1Char('/') );
return ( slash != 0 && ( colon == -1 || ( slash != -1 && colon > slash ) ) );
}
@@ -280,8 +280,8 @@ Q3Url::Q3Url( const Q3Url& url, const QString& relUrl, bool checkSlash )
if ( !d->host.isEmpty() && !d->user.isEmpty() && !d->pass.isEmpty() )
p = QLatin1String("/");
}
- if ( !p.isEmpty() && p.right(1)!=QLatin1String("/") )
- p += QLatin1String("/");
+ if ( !p.isEmpty() && !p.endsWith(QLatin1Char('/')) )
+ p += QLatin1Char('/');
p += rel;
d->path = p;
d->cleanPathDirty = true;
@@ -678,7 +678,7 @@ bool Q3Url::parse( const QString& url )
++cs;
while ( url_[ cs ] == QLatin1Char('/') )
++cs;
- int slash = url_.find( QLatin1String("/"), cs );
+ int slash = url_.find( QLatin1Char('/'), cs );
if ( slash == -1 )
slash = url_.length() - 1;
QString tmp = url_.mid( cs, slash - cs + 1 );
@@ -686,7 +686,7 @@ bool Q3Url::parse( const QString& url )
if ( !tmp.isEmpty() ) { // if this part exists
// look for the @ in this part
- int at = tmp.find( QLatin1String("@") );
+ int at = tmp.find( QLatin1Char('@') );
if ( at != -1 )
at += cs;
// we have no @, which means host[:port], so directly
@@ -793,7 +793,7 @@ bool Q3Url::parse( const QString& url )
// hack for windows
if ( d->path.length() == 2 && d->path[ 1 ] == QLatin1Char(':') )
- d->path += QLatin1String("/");
+ d->path += QLatin1Char('/');
// #### do some corrections, should be done nicer too
if ( !d->pass.isEmpty() ) {
@@ -808,7 +808,7 @@ bool Q3Url::parse( const QString& url )
if ( d->path[ 0 ] == QLatin1Char('@') || d->path[ 0 ] == QLatin1Char(':') )
d->path.remove( (uint)0, 1 );
if ( d->path[ 0 ] != QLatin1Char('/') && !relPath && d->path[ 1 ] != QLatin1Char(':') )
- d->path.prepend( QLatin1String("/") );
+ d->path.prepend( QLatin1Char('/') );
}
if ( !d->refEncoded.isEmpty() && d->refEncoded[ 0 ] == QLatin1Char('#') )
d->refEncoded.remove( (uint)0, 1 );
@@ -820,9 +820,9 @@ bool Q3Url::parse( const QString& url )
#if defined(Q_OS_WIN32)
// hack for windows file://machine/path syntax
if ( d->protocol == QLatin1String("file") ) {
- if ( url.left( 7 ) == QLatin1String("file://") &&
+ if ( url.startsWith(QLatin1String("file://")) &&
d->path.length() > 1 && d->path[ 1 ] != QLatin1Char(':') )
- d->path.prepend( QLatin1String("/") );
+ d->path.prepend( QLatin1Char('/') );
}
#endif
@@ -942,7 +942,7 @@ void Q3Url::setFileName( const QString& name )
p += fn;
if ( !d->queryEncoded.isEmpty() )
- p += QLatin1String("?") + d->queryEncoded;
+ p += QLatin1Char('?') + d->queryEncoded;
setEncodedPathAndQuery( p );
}
@@ -961,7 +961,7 @@ QString Q3Url::encodedPathAndQuery()
encode( p );
if ( !d->queryEncoded.isEmpty() ) {
- p += QLatin1String("?");
+ p += QLatin1Char('?');
p += d->queryEncoded;
}
@@ -1011,7 +1011,7 @@ QString Q3Url::path( bool correct ) const
} else if ( isLocalFile() ) {
#if defined(Q_OS_WIN32)
// hack for stuff like \\machine\path and //machine/path on windows
- if ( ( d->path.left( 1 ) == QLatin1String("/") || d->path.left( 1 ) == QLatin1String("\\") ) &&
+ if ( ( d->path.startsWith(QLatin1Char('/')) || d->path.startsWith(QLatin1Char('\\')) ) &&
d->path.length() > 1 ) {
d->cleanPath = d->path;
bool share = (d->cleanPath[0] == QLatin1Char('\\') && d->cleanPath[1] == QLatin1Char('\\')) ||
@@ -1021,7 +1021,7 @@ QString Q3Url::path( bool correct ) const
if ( share ) {
check = false;
while (d->cleanPath.at(0) != QLatin1Char('/') || d->cleanPath.at(1) != QLatin1Char('/'))
- d->cleanPath.prepend(QLatin1String("/"));
+ d->cleanPath.prepend(QLatin1Char('/'));
}
}
#endif
@@ -1036,7 +1036,7 @@ QString Q3Url::path( bool correct ) const
dir = QDir::cleanDirPath( canPath );
else
dir = QDir::cleanDirPath( QDir( d->path ).absPath() );
- dir += QLatin1String("/");
+ dir += QLatin1Char('/');
if ( dir == QLatin1String("//") )
d->cleanPath = QLatin1String("/");
else
@@ -1046,14 +1046,13 @@ QString Q3Url::path( bool correct ) const
QDir::cleanDirPath( (qt_resolve_symlinks ?
fi.dir().canonicalPath() :
fi.dir().absPath()) );
- d->cleanPath = p + QLatin1String("/") + fi.fileName();
+ d->cleanPath = p + QLatin1Char('/') + fi.fileName();
}
}
} else {
- if ( d->path != QLatin1String("/") && d->path[ (int)d->path.length() - 1 ] == QLatin1Char('/') )
- d->cleanPath = QDir::cleanDirPath( d->path ) + QLatin1String("/");
- else
d->cleanPath = QDir::cleanDirPath( d->path );
+ if ( d->path.length() > 1 && d->path.endsWith(QLatin1Char('/')) )
+ d->cleanPath += QLatin1Char('/');
}
if ( check )
@@ -1084,9 +1083,9 @@ bool Q3Url::isLocalFile() const
QString Q3Url::fileName() const
{
- if ( d->path.isEmpty() || d->path.endsWith( QLatin1String("/") )
+ if ( d->path.isEmpty() || d->path.endsWith( QLatin1Char('/') )
#ifdef Q_WS_WIN
- || d->path.endsWith( QLatin1String("\\") )
+ || d->path.endsWith( QLatin1Char('\\') )
#endif
)
return QString();
@@ -1110,12 +1109,12 @@ void Q3Url::addPath( const QString& pa )
if ( path().isEmpty() ) {
if ( p[ 0 ] != QLatin1Char( '/' ) )
- d->path = QLatin1String("/") + p;
+ d->path = QLatin1Char('/') + p;
else
d->path = p;
} else {
if ( p[ 0 ] != QLatin1Char( '/' ) && d->path[ (int)d->path.length() - 1 ] != QLatin1Char('/') )
- d->path += QLatin1String("/") + p;
+ d->path += QLatin1Char('/') + p;
else
d->path += p;
}
@@ -1250,11 +1249,11 @@ QString Q3Url::toString( bool encodedPath, bool forcePrependProtocol ) const
if ( isLocalFile() ) {
if ( forcePrependProtocol )
- res = d->protocol + QLatin1String(":") + p;
+ res = d->protocol + QLatin1Char(':') + p;
else
res = p;
} else if ( d->protocol == QLatin1String("mailto") ) {
- res = d->protocol + QLatin1String(":") + p;
+ res = d->protocol + QLatin1Char(':') + p;
} else {
res = d->protocol + QLatin1String("://");
if ( !d->user.isEmpty() || !d->pass.isEmpty() ) {
@@ -1267,24 +1266,24 @@ QString Q3Url::toString( bool encodedPath, bool forcePrependProtocol ) const
if ( !d->pass.isEmpty() ) {
tmp = d->pass;
encode( tmp );
- res += QLatin1String(":") + tmp;
+ res += QLatin1Char(':') + tmp;
}
- res += QLatin1String("@");
+ res += QLatin1Char('@');
}
res += d->host;
if ( d->port != -1 )
- res += QLatin1String(":") + QString( QLatin1String("%1") ).arg( d->port );
+ res += QLatin1Char(':') + QString::number( d->port );
if ( !p.isEmpty() ) {
if ( !d->host.isEmpty() && p[0]!= QLatin1Char( '/' ) )
- res += QLatin1String("/");
+ res += QLatin1Char('/');
res += p;
}
}
if ( !d->refEncoded.isEmpty() )
- res += QLatin1String("#") + d->refEncoded;
+ res += QLatin1Char('#') + d->refEncoded;
if ( !d->queryEncoded.isEmpty() )
- res += QLatin1String("?") + d->queryEncoded;
+ res += QLatin1Char('?') + d->queryEncoded;
return res;
}
diff --git a/src/qt3support/network/q3urloperator.cpp b/src/qt3support/network/q3urloperator.cpp
index b415e12..6afd8ab 100644
--- a/src/qt3support/network/q3urloperator.cpp
+++ b/src/qt3support/network/q3urloperator.cpp
@@ -579,7 +579,7 @@ Q3PtrList<Q3NetworkOperation> Q3UrlOperator::copy( const QString &from, const QS
if (frm == to + file)
return ops;
- file.prepend( QLatin1String("/") );
+ file.prepend( QLatin1Char('/') );
// uFrom and uTo are deleted when the Q3NetworkProtocol deletes itself via
// autodelete