diff options
Diffstat (limited to 'libemailfunctions')
-rw-r--r-- | libemailfunctions/email.cpp | 156 | ||||
-rw-r--r-- | libemailfunctions/email.h | 58 | ||||
-rw-r--r-- | libemailfunctions/idmapper.cpp | 64 | ||||
-rw-r--r-- | libemailfunctions/idmapper.h | 40 | ||||
-rw-r--r-- | libemailfunctions/networkstatus.cpp | 2 | ||||
-rw-r--r-- | libemailfunctions/networkstatus.h | 4 | ||||
-rw-r--r-- | libemailfunctions/tests/testemail.cpp | 72 | ||||
-rw-r--r-- | libemailfunctions/tests/testidmapper.cpp | 4 |
8 files changed, 200 insertions, 200 deletions
diff --git a/libemailfunctions/email.cpp b/libemailfunctions/email.cpp index ec14800aa..b5148736f 100644 --- a/libemailfunctions/email.cpp +++ b/libemailfunctions/email.cpp @@ -25,10 +25,10 @@ #include <kidna.h> #include <kmime_util.h> -#include <qregexp.h> +#include <tqregexp.h> //----------------------------------------------------------------------------- -QStringList KPIM::splitEmailAddrList(const QString& aStr) +TQStringList KPIM::splitEmailAddrList(const TQString& aStr) { // Features: // - always ignores quoted characters @@ -38,12 +38,12 @@ QStringList KPIM::splitEmailAddrList(const QString& aStr) // - ignores everything (including double quotes and commas) // inside comments - QStringList list; + TQStringList list; if (aStr.isEmpty()) return list; - QString addr; + TQString addr; uint addrstart = 0; int commentlevel = 0; bool insidequote = false; @@ -101,10 +101,10 @@ QStringList KPIM::splitEmailAddrList(const QString& aStr) //----------------------------------------------------------------------------- // Used by KPIM::splitAddress(...) and KPIM::getFirstEmailAddress(...). -KPIM::EmailParseResult splitAddressInternal( const QCString& address, - QCString & displayName, - QCString & addrSpec, - QCString & comment, +KPIM::EmailParseResult splitAddressInternal( const TQCString& address, + TQCString & displayName, + TQCString & addrSpec, + TQCString & comment, bool allowMultipleAddresses ) { // kdDebug() << "KMMessage::splitAddress( " << address << " )" << endl; @@ -116,9 +116,9 @@ KPIM::EmailParseResult splitAddressInternal( const QCString& address, // these strings are later copied to displayName resp. addrSpec resp. comment // we don't operate directly on those variables, since as ByteArray deriverates // they have a miserable performance on operator+ - QString dName; - QString aSpec; - QString cmmt; + TQString dName; + TQString aSpec; + TQString cmmt; if ( address.isEmpty() ) return KPIM::AddressEmpty; @@ -255,10 +255,10 @@ KPIM::EmailParseResult splitAddressInternal( const QCString& address, //----------------------------------------------------------------------------- -KPIM::EmailParseResult KPIM::splitAddress( const QCString& address, - QCString & displayName, - QCString & addrSpec, - QCString & comment ) +KPIM::EmailParseResult KPIM::splitAddress( const TQCString& address, + TQCString & displayName, + TQCString & addrSpec, + TQCString & comment ) { return splitAddressInternal( address, displayName, addrSpec, comment, false /* don't allow multiple addresses */ ); @@ -266,24 +266,24 @@ KPIM::EmailParseResult KPIM::splitAddress( const QCString& address, //----------------------------------------------------------------------------- -KPIM::EmailParseResult KPIM::splitAddress( const QString & address, - QString & displayName, - QString & addrSpec, - QString & comment ) +KPIM::EmailParseResult KPIM::splitAddress( const TQString & address, + TQString & displayName, + TQString & addrSpec, + TQString & comment ) { - QCString d, a, c; + TQCString d, a, c; KPIM::EmailParseResult result = splitAddress( address.utf8(), d, a, c ); if ( result == AddressOk ) { - displayName = QString::fromUtf8( d ); - addrSpec = QString::fromUtf8( a ); - comment = QString::fromUtf8( c ); + displayName = TQString::fromUtf8( d ); + addrSpec = TQString::fromUtf8( a ); + comment = TQString::fromUtf8( c ); } return result; } //----------------------------------------------------------------------------- -KPIM::EmailParseResult KPIM::isValidEmailAddress( const QString& aStr ) +KPIM::EmailParseResult KPIM::isValidEmailAddress( const TQString& aStr ) { // If we are passed an empty string bail right away no need to process further // and waste resources @@ -458,7 +458,7 @@ KPIM::EmailParseResult KPIM::isValidEmailAddress( const QString& aStr ) } //----------------------------------------------------------------------------- -QString KPIM::emailParseResultToString( EmailParseResult errorCode ) +TQString KPIM::emailParseResultToString( EmailParseResult errorCode ) { switch ( errorCode ) { case TooManyAts : @@ -516,7 +516,7 @@ QString KPIM::emailParseResultToString( EmailParseResult errorCode ) } //----------------------------------------------------------------------------- -bool KPIM::isValidSimpleEmailAddress( const QString& aStr ) +bool KPIM::isValidSimpleEmailAddress( const TQString& aStr ) { // If we are passed an empty string bail right away no need to process further // and waste resources @@ -525,8 +525,8 @@ bool KPIM::isValidSimpleEmailAddress( const QString& aStr ) } int atChar = aStr.findRev( '@' ); - QString domainPart = aStr.mid( atChar + 1); - QString localPart = aStr.left( atChar ); + TQString domainPart = aStr.mid( atChar + 1); + TQString localPart = aStr.left( atChar ); bool tooManyAtsFlag = false; bool inQuotedString = false; int atCount = localPart.contains( '@' ); @@ -547,7 +547,7 @@ bool KPIM::isValidSimpleEmailAddress( const QString& aStr ) } } - QString addrRx = "[a-zA-Z]*[~|{}`\\^?=/+*'&%$#!_\\w.-]*[~|{}`\\^?=/+*'&%$#!_a-zA-Z0-9-]@"; + TQString addrRx = "[a-zA-Z]*[~|{}`\\^?=/+*'&%$#!_\\w.-]*[~|{}`\\^?=/+*'&%$#!_a-zA-Z0-9-]@"; if ( localPart[ 0 ] == '\"' || localPart[ localPart.length()-1 ] == '\"' ) { addrRx = "\"[a-zA-Z@]*[\\w.@-]*[a-zA-Z0-9@]\"@"; } @@ -556,26 +556,26 @@ bool KPIM::isValidSimpleEmailAddress( const QString& aStr ) } else { addrRx += "[\\w-]+(\\.[\\w-]+)*"; } - QRegExp rx( addrRx ); + TQRegExp rx( addrRx ); return rx.exactMatch( aStr ) && !tooManyAtsFlag; } //----------------------------------------------------------------------------- -QString KPIM::simpleEmailAddressErrorMsg() +TQString KPIM::simpleEmailAddressErrorMsg() { return i18n("The email address you entered is not valid because it " "does not seem to contain an actual email address, i.e. " "something of the form joe@kde.org."); } //----------------------------------------------------------------------------- -QCString KPIM::getEmailAddress( const QCString & address ) +TQCString KPIM::getEmailAddress( const TQCString & address ) { - QCString dummy1, dummy2, addrSpec; + TQCString dummy1, dummy2, addrSpec; KPIM::EmailParseResult result = splitAddressInternal( address, dummy1, addrSpec, dummy2, false /* don't allow multiple addresses */ ); if ( result != AddressOk ) { - addrSpec = QCString(); + addrSpec = TQCString(); kdDebug() // << k_funcinfo << "\n" << "Input: aStr\nError:" << emailParseResultToString( result ) << endl; @@ -586,21 +586,21 @@ QCString KPIM::getEmailAddress( const QCString & address ) //----------------------------------------------------------------------------- -QString KPIM::getEmailAddress( const QString & address ) +TQString KPIM::getEmailAddress( const TQString & address ) { - return QString::fromUtf8( getEmailAddress( address.utf8() ) ); + return TQString::fromUtf8( getEmailAddress( address.utf8() ) ); } //----------------------------------------------------------------------------- -QCString KPIM::getFirstEmailAddress( const QCString & addresses ) +TQCString KPIM::getFirstEmailAddress( const TQCString & addresses ) { - QCString dummy1, dummy2, addrSpec; + TQCString dummy1, dummy2, addrSpec; KPIM::EmailParseResult result = splitAddressInternal( addresses, dummy1, addrSpec, dummy2, true /* allow multiple addresses */ ); if ( result != AddressOk ) { - addrSpec = QCString(); + addrSpec = TQCString(); kdDebug() // << k_funcinfo << "\n" << "Input: aStr\nError:" << emailParseResultToString( result ) << endl; @@ -611,17 +611,17 @@ QCString KPIM::getFirstEmailAddress( const QCString & addresses ) //----------------------------------------------------------------------------- -QString KPIM::getFirstEmailAddress( const QString & addresses ) +TQString KPIM::getFirstEmailAddress( const TQString & addresses ) { - return QString::fromUtf8( getFirstEmailAddress( addresses.utf8() ) ); + return TQString::fromUtf8( getFirstEmailAddress( addresses.utf8() ) ); } //----------------------------------------------------------------------------- -bool KPIM::getNameAndMail(const QString& aStr, QString& name, QString& mail) +bool KPIM::getNameAndMail(const TQString& aStr, TQString& name, TQString& mail) { - name = QString::null; - mail = QString::null; + name = TQString::null; + mail = TQString::null; const int len=aStr.length(); const char cQuotes = '"'; @@ -629,7 +629,7 @@ bool KPIM::getNameAndMail(const QString& aStr, QString& name, QString& mail) bool bInComment = false; bool bInQuotesOutsideOfEmail = false; int i=0, iAd=0, iMailStart=0, iMailEnd=0; - QChar c; + TQChar c; unsigned int commentstack = 0; // Find the '@' of the email address @@ -791,10 +791,10 @@ bool KPIM::getNameAndMail(const QString& aStr, QString& name, QString& mail) //----------------------------------------------------------------------------- -bool KPIM::compareEmail( const QString& email1, const QString& email2, +bool KPIM::compareEmail( const TQString& email1, const TQString& email2, bool matchName ) { - QString e1Name, e1Email, e2Name, e2Email; + TQString e1Name, e1Email, e2Name, e2Email; getNameAndMail( email1, e1Name, e1Email ); getNameAndMail( email2, e2Name, e2Email ); @@ -805,16 +805,16 @@ bool KPIM::compareEmail( const QString& email1, const QString& email2, //----------------------------------------------------------------------------- -QString KPIM::normalizedAddress( const QString & displayName, - const QString & addrSpec, - const QString & comment ) +TQString KPIM::normalizedAddress( const TQString & displayName, + const TQString & addrSpec, + const TQString & comment ) { if ( displayName.isEmpty() && comment.isEmpty() ) return addrSpec; else if ( comment.isEmpty() ) return quoteNameIfNecessary( displayName ) + " <" + addrSpec + ">"; else if ( displayName.isEmpty() ) { - QString commentStr = comment; + TQString commentStr = comment; return quoteNameIfNecessary( commentStr ) + " <" + addrSpec + ">"; } else @@ -823,28 +823,28 @@ QString KPIM::normalizedAddress( const QString & displayName, //----------------------------------------------------------------------------- -QString KPIM::decodeIDN( const QString & addrSpec ) +TQString KPIM::decodeIDN( const TQString & addrSpec ) { const int atPos = addrSpec.findRev( '@' ); if ( atPos == -1 ) return addrSpec; - QString idn = KIDNA::toUnicode( addrSpec.mid( atPos + 1 ) ); + TQString idn = KIDNA::toUnicode( addrSpec.mid( atPos + 1 ) ); if ( idn.isEmpty() ) - return QString::null; + return TQString::null; return addrSpec.left( atPos + 1 ) + idn; } //----------------------------------------------------------------------------- -QString KPIM::encodeIDN( const QString & addrSpec ) +TQString KPIM::encodeIDN( const TQString & addrSpec ) { const int atPos = addrSpec.findRev( '@' ); if ( atPos == -1 ) return addrSpec; - QString idn = KIDNA::toAscii( addrSpec.mid( atPos + 1 ) ); + TQString idn = KIDNA::toAscii( addrSpec.mid( atPos + 1 ) ); if ( idn.isEmpty() ) return addrSpec; @@ -853,19 +853,19 @@ QString KPIM::encodeIDN( const QString & addrSpec ) //----------------------------------------------------------------------------- -QString KPIM::normalizeAddressesAndDecodeIDNs( const QString & str ) +TQString KPIM::normalizeAddressesAndDecodeIDNs( const TQString & str ) { // kdDebug() << "KPIM::normalizeAddressesAndDecodeIDNs( \"" // << str << "\" )" << endl; if( str.isEmpty() ) return str; - const QStringList addressList = KPIM::splitEmailAddrList( str ); - QStringList normalizedAddressList; + const TQStringList addressList = KPIM::splitEmailAddrList( str ); + TQStringList normalizedAddressList; - QCString displayName, addrSpec, comment; + TQCString displayName, addrSpec, comment; - for( QStringList::ConstIterator it = addressList.begin(); + for( TQStringList::ConstIterator it = addressList.begin(); ( it != addressList.end() ); ++it ) { if( !(*it).isEmpty() ) { @@ -876,9 +876,9 @@ QString KPIM::normalizeAddressesAndDecodeIDNs( const QString & str ) comment = KMime::decodeRFC2047String(comment).utf8(); normalizedAddressList << - normalizedAddress( QString::fromUtf8( displayName ), - decodeIDN( QString::fromUtf8( addrSpec ) ), - QString::fromUtf8( comment ) ); + normalizedAddress( TQString::fromUtf8( displayName ), + decodeIDN( TQString::fromUtf8( addrSpec ) ), + TQString::fromUtf8( comment ) ); } else { kdDebug() << "splitting address failed: " << *it << endl; @@ -894,19 +894,19 @@ QString KPIM::normalizeAddressesAndDecodeIDNs( const QString & str ) } //----------------------------------------------------------------------------- -QString KPIM::normalizeAddressesAndEncodeIDNs( const QString & str ) +TQString KPIM::normalizeAddressesAndEncodeIDNs( const TQString & str ) { //kdDebug() << "KPIM::normalizeAddressesAndEncodeIDNs( \"" // << str << "\" )" << endl; if( str.isEmpty() ) return str; - const QStringList addressList = KPIM::splitEmailAddrList( str ); - QStringList normalizedAddressList; + const TQStringList addressList = KPIM::splitEmailAddrList( str ); + TQStringList normalizedAddressList; - QCString displayName, addrSpec, comment; + TQCString displayName, addrSpec, comment; - for( QStringList::ConstIterator it = addressList.begin(); + for( TQStringList::ConstIterator it = addressList.begin(); ( it != addressList.end() ); ++it ) { if( !(*it).isEmpty() ) { @@ -914,9 +914,9 @@ QString KPIM::normalizeAddressesAndEncodeIDNs( const QString & str ) == AddressOk ) { normalizedAddressList << - normalizedAddress( QString::fromUtf8( displayName ), - encodeIDN( QString::fromUtf8( addrSpec ) ), - QString::fromUtf8( comment ) ); + normalizedAddress( TQString::fromUtf8( displayName ), + encodeIDN( TQString::fromUtf8( addrSpec ) ), + TQString::fromUtf8( comment ) ); } else { kdDebug() << "splitting address failed: " << *it << endl; @@ -935,12 +935,12 @@ QString KPIM::normalizeAddressesAndEncodeIDNs( const QString & str ) //----------------------------------------------------------------------------- // Escapes unescaped doublequotes in str. -static QString escapeQuotes( const QString & str ) +static TQString escapeQuotes( const TQString & str ) { if ( str.isEmpty() ) - return QString(); + return TQString(); - QString escaped; + TQString escaped; // reserve enough memory for the worst case ( """..."" -> \"\"\"...\"\" ) escaped.reserve( 2*str.length() ); unsigned int len = 0; @@ -963,11 +963,11 @@ static QString escapeQuotes( const QString & str ) } //----------------------------------------------------------------------------- -QString KPIM::quoteNameIfNecessary( const QString &str ) +TQString KPIM::quoteNameIfNecessary( const TQString &str ) { - QString quoted = str; + TQString quoted = str; - QRegExp needQuotes( "[^ 0-9A-Za-z\\x0080-\\xFFFF]" ); + TQRegExp needQuotes( "[^ 0-9A-Za-z\\x0080-\\xFFFF]" ); // avoid double quoting if ( ( quoted[0] == '"' ) && ( quoted[quoted.length() - 1] == '"' ) ) { quoted = "\"" + escapeQuotes( quoted.mid( 1, quoted.length() - 2 ) ) + "\""; diff --git a/libemailfunctions/email.h b/libemailfunctions/email.h index 493fa087c..5e5e665b9 100644 --- a/libemailfunctions/email.h +++ b/libemailfunctions/email.h @@ -22,8 +22,8 @@ #ifndef EMAIL_H #define EMAIL_H -#include <qstringlist.h> -#include <qcstring.h> +#include <tqstringlist.h> +#include <tqcstring.h> #include <kdepimmacros.h> @@ -51,7 +51,7 @@ enum EmailParseResult { AddressOk, AddressEmpty, UnexpectedEnd, // Helper functions /** Split a comma separated list of email addresses. */ -KDE_EXPORT QStringList splitEmailAddrList(const QString& aStr); +KDE_EXPORT TQStringList splitEmailAddrList(const TQString& aStr); /** Splits the given address into display name, email address and comment. Returns AddressOk if no error was encountered. Otherwise an appropriate @@ -72,10 +72,10 @@ KDE_EXPORT QStringList splitEmailAddrList(const QString& aStr); @return AddressOk if no error was encountered. Otherwise an appropriate error code is returned. */ -KDE_EXPORT EmailParseResult splitAddress( const QCString & address, - QCString & displayName, - QCString & addrSpec, - QCString & comment ); +KDE_EXPORT EmailParseResult splitAddress( const TQCString & address, + TQCString & displayName, + TQCString & addrSpec, + TQCString & comment ); /** This is an overloaded member function, provided for convenience. It behaves essentially like the above function. @@ -99,10 +99,10 @@ KDE_EXPORT EmailParseResult splitAddress( const QCString & address, @return AddressOk if no error was encountered. Otherwise an appropriate error code is returned. */ -KDE_EXPORT EmailParseResult splitAddress( const QString & address, - QString & displayName, - QString & addrSpec, - QString & comment ); +KDE_EXPORT EmailParseResult splitAddress( const TQString & address, + TQString & displayName, + TQString & addrSpec, + TQString & comment ); /** Validates an email address in the form of "Joe User" <joe@example.org>. Returns AddressOk if no error was encountered. Otherwise an appropriate @@ -113,7 +113,7 @@ KDE_EXPORT EmailParseResult splitAddress( const QString & address, @return AddressOk if no error was encountered. Otherwise an appropriate error code is returned. */ -KDE_EXPORT EmailParseResult isValidEmailAddress( const QString& aStr ); +KDE_EXPORT EmailParseResult isValidEmailAddress( const TQString& aStr ); /** Translate the enum errorcodes from emailParseResult into i18n'd strings that can be used for msg boxes. @@ -122,7 +122,7 @@ KDE_EXPORT EmailParseResult isValidEmailAddress( const QString& aStr ); @return An i18n ready string for use in msgboxes. */ -KDE_EXPORT QString emailParseResultToString( EmailParseResult errorCode ); +KDE_EXPORT TQString emailParseResultToString( EmailParseResult errorCode ); /** Validates an email address in the form of joe@example.org. Returns true if no error was encountered. @@ -134,7 +134,7 @@ KDE_EXPORT QString emailParseResultToString( EmailParseResult errorCode ); example: joe.user@example.org @return true if no error was encountered. */ -KDE_EXPORT bool isValidSimpleEmailAddress( const QString& aStr ); +KDE_EXPORT bool isValidSimpleEmailAddress( const TQString& aStr ); /** Returns a i18n string to be used in msgboxes this allows for error messages to be the same @@ -143,7 +143,7 @@ KDE_EXPORT bool isValidSimpleEmailAddress( const QString& aStr ); @return An i18n ready string for use in msgboxes. */ -KDE_EXPORT QString simpleEmailAddressErrorMsg(); +KDE_EXPORT TQString simpleEmailAddressErrorMsg(); /** Returns the pure email address (addr-spec in RFC2822) of the given address (mailbox in RFC2822). @@ -152,7 +152,7 @@ KDE_EXPORT QString simpleEmailAddressErrorMsg(); @return the addr-spec of @a address, i.e. joe.user@example.org in the example */ -KDE_EXPORT QCString getEmailAddress( const QCString & address ); +KDE_EXPORT TQCString getEmailAddress( const TQCString & address ); /** This is an overloaded member function, provided for convenience. It behaves essentially like the above function. @@ -164,7 +164,7 @@ KDE_EXPORT QCString getEmailAddress( const QCString & address ); @return the addr-spec of @a address, i.e. joe.user@example.org in the example */ -KDE_EXPORT QString getEmailAddress( const QString & address ); +KDE_EXPORT TQString getEmailAddress( const TQString & address ); /** Returns the pure email address (addr-spec in RFC2822) of the first email address of a list of addresses. @@ -173,7 +173,7 @@ KDE_EXPORT QString getEmailAddress( const QString & address ); @return the addr-spec of @a addresses, i.e. joe.user@example.org in the example */ -KDE_EXPORT QCString getFirstEmailAddress( const QCString & addresses ); +KDE_EXPORT TQCString getFirstEmailAddress( const TQCString & addresses ); /** This is an overloaded member function, provided for convenience. It behaves essentially like the above function. @@ -185,7 +185,7 @@ KDE_EXPORT QCString getFirstEmailAddress( const QCString & addresses ); @return the addr-spec of @a addresses, i.e. joe.user@example.org in the example */ -KDE_EXPORT QString getFirstEmailAddress( const QString & addresses ); +KDE_EXPORT TQString getFirstEmailAddress( const TQString & addresses ); /** Return email address and name from string. Examples: * "Stefan Taferner <taferner@example.org>" returns "taferner@example.org" @@ -195,14 +195,14 @@ KDE_EXPORT QString getFirstEmailAddress( const QString & addresses ); * mail are not empty: this does NOT tell you if mail contains a * valid email address or just some rubbish. */ -KDE_EXPORT bool getNameAndMail(const QString& aStr, QString& name, QString& mail); +KDE_EXPORT bool getNameAndMail(const TQString& aStr, TQString& name, TQString& mail); /** * Compare two email addresses. If matchName is false, it just checks * the email address, and returns true if this matches. If matchName * is true, both the name and the email must be the same. */ -KDE_EXPORT bool compareEmail( const QString& email1, const QString& email2, +KDE_EXPORT bool compareEmail( const TQString& email1, const TQString& email2, bool matchName ); /** Returns a normalized address built from the given parts. The normalized @@ -217,16 +217,16 @@ KDE_EXPORT bool compareEmail( const QString& email1, const QString& email2, @param comment a comment @return a normalized address built from the given parts */ -KDE_EXPORT QString normalizedAddress( const QString & displayName, - const QString & addrSpec, - const QString & comment ); +KDE_EXPORT TQString normalizedAddress( const TQString & displayName, + const TQString & addrSpec, + const TQString & comment ); /** Decodes the punycode domain part of the given addr-spec if it's an IDN. @param addrSpec a pure 7-bit email address (addr-spec in RFC2822) @return the email address with Unicode domain */ -KDE_EXPORT QString decodeIDN( const QString & addrSpec ); +KDE_EXPORT TQString decodeIDN( const TQString & addrSpec ); /** Encodes the domain part of the given addr-spec in punycode if it's an IDN. @@ -234,7 +234,7 @@ KDE_EXPORT QString decodeIDN( const QString & addrSpec ); @param addrSpec a pure email address with Unicode domain @return the email address with domain in punycode */ -KDE_EXPORT QString encodeIDN( const QString & addrSpec ); +KDE_EXPORT TQString encodeIDN( const TQString & addrSpec ); /** Normalizes all email addresses in the given list and decodes all IDNs. @@ -242,17 +242,17 @@ KDE_EXPORT QString encodeIDN( const QString & addrSpec ); @return the email addresses in normalized form with Unicode IDNs */ -KDE_EXPORT QString normalizeAddressesAndDecodeIDNs( const QString & addresses ); +KDE_EXPORT TQString normalizeAddressesAndDecodeIDNs( const TQString & addresses ); /** Normalizes all email addresses in the given list and encodes all IDNs in punycode. */ -KDE_EXPORT QString normalizeAddressesAndEncodeIDNs( const QString & str ); +KDE_EXPORT TQString normalizeAddressesAndEncodeIDNs( const TQString & str ); /** Add quote characters around the given string if it contains a * character that makes that necessary, in an email name, such as ",". */ -KDE_EXPORT QString quoteNameIfNecessary( const QString& str ); +KDE_EXPORT TQString quoteNameIfNecessary( const TQString& str ); } // namespace diff --git a/libemailfunctions/idmapper.cpp b/libemailfunctions/idmapper.cpp index a44dc8c83..6250d41c0 100644 --- a/libemailfunctions/idmapper.cpp +++ b/libemailfunctions/idmapper.cpp @@ -25,7 +25,7 @@ #include <kstandarddirs.h> #include <kdebug.h> -#include <qfile.h> +#include <tqfile.h> using namespace KPIM; @@ -33,7 +33,7 @@ IdMapper::IdMapper() { } -IdMapper::IdMapper( const QString &path, const QString &identifier ) +IdMapper::IdMapper( const TQString &path, const TQString &identifier ) : mPath( path ), mIdentifier( identifier ) { } @@ -42,19 +42,19 @@ IdMapper::~IdMapper() { } -void IdMapper::setPath( const QString &path ) +void IdMapper::setPath( const TQString &path ) { mPath = path; } -void IdMapper::setIdentifier( const QString &identifier ) +void IdMapper::setIdentifier( const TQString &identifier ) { mIdentifier = identifier; } -QString IdMapper::filename() +TQString IdMapper::filename() { - QString file = mPath; + TQString file = mPath; if ( !file.endsWith( "/" ) ) file += "/"; file += mIdentifier; @@ -63,7 +63,7 @@ QString IdMapper::filename() bool IdMapper::load() { - QFile file( filename() ); + TQFile file( filename() ); if ( !file.open( IO_ReadOnly ) ) { kdError(5800) << "Can't read uid map file '" << filename() << "'" << endl; return false; @@ -71,11 +71,11 @@ bool IdMapper::load() clear(); - QString line; + TQString line; while ( file.readLine( line, 1024 ) != -1 ) { line.truncate( line.length() - 2 ); // strip newline - QStringList parts = QStringList::split( "\x02\x02", line, true ); + TQStringList parts = TQStringList::split( "\x02\x02", line, true ); mIdMap.insert( parts[ 0 ], parts[ 1 ] ); mFingerprintMap.insert( parts[ 0 ], parts[ 2 ] ); } @@ -87,17 +87,17 @@ bool IdMapper::load() bool IdMapper::save() { - QFile file( filename() ); + TQFile file( filename() ); if ( !file.open( IO_WriteOnly ) ) { kdError(5800) << "Can't write uid map file '" << filename() << "'" << endl; return false; } - QString content; + TQString content; - QMap<QString, QVariant>::Iterator it; + TQMap<TQString, TQVariant>::Iterator it; for ( it = mIdMap.begin(); it != mIdMap.end(); ++it ) { - QString fingerprint( "" ); + TQString fingerprint( "" ); if ( mFingerprintMap.contains( it.key() ) ) fingerprint = mFingerprintMap[ it.key() ]; content += it.key() + "\x02\x02" + it.data().toString() + "\x02\x02" + fingerprint + "\r\n"; @@ -115,14 +115,14 @@ void IdMapper::clear() mFingerprintMap.clear(); } -void IdMapper::setRemoteId( const QString &localId, const QString &remoteId ) +void IdMapper::setRemoteId( const TQString &localId, const TQString &remoteId ) { mIdMap.replace( localId, remoteId ); } -void IdMapper::removeRemoteId( const QString &remoteId ) +void IdMapper::removeRemoteId( const TQString &remoteId ) { - QMap<QString, QVariant>::Iterator it; + TQMap<TQString, TQVariant>::Iterator it; for ( it = mIdMap.begin(); it != mIdMap.end(); ++it ) if ( it.data().toString() == remoteId ) { mIdMap.remove( it ); @@ -131,34 +131,34 @@ void IdMapper::removeRemoteId( const QString &remoteId ) } } -QString IdMapper::remoteId( const QString &localId ) const +TQString IdMapper::remoteId( const TQString &localId ) const { - QMap<QString, QVariant>::ConstIterator it; + TQMap<TQString, TQVariant>::ConstIterator it; it = mIdMap.find( localId ); if ( it != mIdMap.end() ) return it.data().toString(); else - return QString::null; + return TQString::null; } -QString IdMapper::localId( const QString &remoteId ) const +TQString IdMapper::localId( const TQString &remoteId ) const { - QMap<QString, QVariant>::ConstIterator it; + TQMap<TQString, TQVariant>::ConstIterator it; for ( it = mIdMap.begin(); it != mIdMap.end(); ++it ) if ( it.data().toString() == remoteId ) return it.key(); - return QString::null; + return TQString::null; } -QString IdMapper::asString() const +TQString IdMapper::asString() const { - QString content; + TQString content; - QMap<QString, QVariant>::ConstIterator it; + TQMap<TQString, TQVariant>::ConstIterator it; for ( it = mIdMap.begin(); it != mIdMap.end(); ++it ) { - QString fp; + TQString fp; if ( mFingerprintMap.contains( it.key() ) ) fp = mFingerprintMap[ it.key() ]; content += it.key() + "\t" + it.data().toString() + "\t" + fp + "\r\n"; @@ -167,23 +167,23 @@ QString IdMapper::asString() const return content; } -void IdMapper::setFingerprint( const QString &localId, const QString &fingerprint ) +void IdMapper::setFingerprint( const TQString &localId, const TQString &fingerprint ) { mFingerprintMap.insert( localId, fingerprint ); } -const QString& IdMapper::fingerprint( const QString &localId ) const +const TQString& IdMapper::fingerprint( const TQString &localId ) const { if ( mFingerprintMap.contains( localId ) ) return mFingerprintMap[ localId ]; else - return QString::null; + return TQString::null; } -QMap<QString, QString> IdMapper::remoteIdMap() const +TQMap<TQString, TQString> IdMapper::remoteIdMap() const { - QMap<QString, QString> reverseMap; - QMap<QString, QVariant>::ConstIterator it; + TQMap<TQString, TQString> reverseMap; + TQMap<TQString, TQVariant>::ConstIterator it; for ( it = mIdMap.begin(); it != mIdMap.end(); ++it ) { reverseMap.insert( it.data().toString(), it.key() ); } diff --git a/libemailfunctions/idmapper.h b/libemailfunctions/idmapper.h index e09587f4c..999c68ac3 100644 --- a/libemailfunctions/idmapper.h +++ b/libemailfunctions/idmapper.h @@ -22,8 +22,8 @@ #ifndef KPIM_IDMAPPER_H #define KPIM_IDMAPPER_H -#include <qmap.h> -#include <qvariant.h> +#include <tqmap.h> +#include <tqvariant.h> #include <kdepimmacros.h> @@ -52,27 +52,27 @@ class KDE_EXPORT IdMapper The current implementation stores the data at $(KDEHOME)/share/apps/\<path\>/\<identifier\>. */ - IdMapper( const QString &path, const QString &identifier = QString::null ); + IdMapper( const TQString &path, const TQString &identifier = TQString::null ); /** Destructor. */ ~IdMapper(); /** Set id map path. */ - void setPath( const QString &path ); + void setPath( const TQString &path ); /** Return id map path. */ - QString path() const { return mPath; } + TQString path() const { return mPath; } /** Set id map identifier. */ - void setIdentifier( const QString &identifier ); + void setIdentifier( const TQString &identifier ); /** Return id map identifier. */ - QString identifier() const { return mIdentifier; } + TQString identifier() const { return mIdentifier; } /** Loads the map. @@ -92,22 +92,22 @@ class KDE_EXPORT IdMapper /** Stores the remote id for the given local id. */ - void setRemoteId( const QString &localId, const QString &remoteId ); + void setRemoteId( const TQString &localId, const TQString &remoteId ); /** Removes the remote id. */ - void removeRemoteId( const QString &remoteId ); + void removeRemoteId( const TQString &remoteId ); /** Returns the remote id of the given local id. */ - QString remoteId( const QString &localId ) const; + TQString remoteId( const TQString &localId ) const; /** Returns the local id for the given remote id. */ - QString localId( const QString &remoteId ) const; + TQString localId( const TQString &remoteId ) const; /** @@ -116,7 +116,7 @@ class KDE_EXPORT IdMapper * This can be a sequence number of an md5 hash depending on what * the server provides */ - void setFingerprint( const QString &localId, const QString &fingerprint ); + void setFingerprint( const TQString &localId, const TQString &fingerprint ); /** * Returns the fingerprint for the map. @@ -124,7 +124,7 @@ class KDE_EXPORT IdMapper * @todo Figure out if this applies to the last set fingerprint * or if anything else can change it. */ - const QString &fingerprint( const QString &localId ) const; + const TQString &fingerprint( const TQString &localId ) const; /** @@ -132,26 +132,26 @@ class KDE_EXPORT IdMapper * * @todo Document what the map means. */ - QMap<QString, QString> remoteIdMap() const; + TQMap<TQString, TQString> remoteIdMap() const; /** * Returns a string representation of the id pairs, that's usefull * for debugging. */ - QString asString() const; + TQString asString() const; protected: /** * Returns the filename this mapper is (or will be) stored in. */ - QString filename(); + TQString filename(); private: - QMap<QString, QVariant> mIdMap; - QMap<QString, QString> mFingerprintMap; + TQMap<TQString, TQVariant> mIdMap; + TQMap<TQString, TQString> mFingerprintMap; - QString mPath; - QString mIdentifier; + TQString mPath; + TQString mIdentifier; }; } diff --git a/libemailfunctions/networkstatus.cpp b/libemailfunctions/networkstatus.cpp index fae385220..ce6fd2eb5 100644 --- a/libemailfunctions/networkstatus.cpp +++ b/libemailfunctions/networkstatus.cpp @@ -33,7 +33,7 @@ static KStaticDeleter<NetworkStatus> networkStatusDeleter; NetworkStatus *NetworkStatus::mSelf = 0; NetworkStatus::NetworkStatus() - : QObject( 0, "NetworkStatus" ), DCOPObject( "NetworkStatus" ) + : TQObject( 0, "NetworkStatus" ), DCOPObject( "NetworkStatus" ) { KConfigGroup group( KGlobal::config(), "NetworkStatus" ); if ( group.readBoolEntry( "Online", true ) == true ) diff --git a/libemailfunctions/networkstatus.h b/libemailfunctions/networkstatus.h index 6bc3b70a4..42ff0f922 100644 --- a/libemailfunctions/networkstatus.h +++ b/libemailfunctions/networkstatus.h @@ -22,7 +22,7 @@ #ifndef NETWORKSTATUS_H #define NETWORKSTATUS_H -#include <qobject.h> +#include <tqobject.h> #include <dcopobject.h> namespace KPIM { @@ -32,7 +32,7 @@ namespace KPIM { the machine KDE is running on going from "online" mode to offline. What this means is left as an exercise for the reader. */ -class NetworkStatus : public QObject, public DCOPObject +class NetworkStatus : public TQObject, public DCOPObject { Q_OBJECT diff --git a/libemailfunctions/tests/testemail.cpp b/libemailfunctions/tests/testemail.cpp index ce2111db0..30908d83e 100644 --- a/libemailfunctions/tests/testemail.cpp +++ b/libemailfunctions/tests/testemail.cpp @@ -29,7 +29,7 @@ using namespace KPIM; -static bool check(const QString& txt, const QString& a, const QString& b) +static bool check(const TQString& txt, const TQString& a, const TQString& b) { if (a == b) { kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl; @@ -41,7 +41,7 @@ static bool check(const QString& txt, const QString& a, const QString& b) return true; } -static bool check(const QString& txt, const QStringList& a, const QStringList& b) +static bool check(const TQString& txt, const TQStringList& a, const TQStringList& b) { if ( a.join("\n") == b.join("\n") ) { kdDebug() << txt << " : checking list [ " << a.join( ", " ) << " ] against expected value [ " << b.join( ", " ) << " ]... " << "ok" << endl; @@ -53,18 +53,18 @@ static bool check(const QString& txt, const QStringList& a, const QStringList& b return true; } -static bool checkGetNameAndEmail(const QString& input, const QString& expName, const QString& expEmail, bool expRetVal) +static bool checkGetNameAndEmail(const TQString& input, const TQString& expName, const TQString& expEmail, bool expRetVal) { - QString name, email; + TQString name, email; bool retVal = KPIM::getNameAndMail(input, name, email); - check( "getNameAndMail " + input + " retVal", retVal?QString::fromLatin1( "true" ):QString::fromLatin1( "false" ), expRetVal?QString::fromLatin1( "true" ):QString::fromLatin1( "false" ) ); + check( "getNameAndMail " + input + " retVal", retVal?TQString::fromLatin1( "true" ):TQString::fromLatin1( "false" ), expRetVal?TQString::fromLatin1( "true" ):TQString::fromLatin1( "false" ) ); check( "getNameAndMail " + input + " name", name, expName ); check( "getNameAndMail " + input + " email", email, expEmail ); return true; } // convert this to a switch instead but hey, nothing speedy in here is needed but still.. it would be nice -static QString emailTestParseResultToString( EmailParseResult errorCode ) +static TQString emailTestParseResultToString( EmailParseResult errorCode ) { if( errorCode == TooManyAts ) { return "TooManyAts"; @@ -98,7 +98,7 @@ static QString emailTestParseResultToString( EmailParseResult errorCode ) return "unknown error code"; } -static QString simpleEmailTestParseResultToString( bool validEmail ) +static TQString simpleEmailTestParseResultToString( bool validEmail ) { if ( validEmail ) { return "true"; @@ -106,54 +106,54 @@ static QString simpleEmailTestParseResultToString( bool validEmail ) return "false"; } -static bool checkIsValidEmailAddress( const QString& input, const QString& expErrorCode ) +static bool checkIsValidEmailAddress( const TQString& input, const TQString& expErrorCode ) { EmailParseResult errorCode = KPIM::isValidEmailAddress( input ); - QString errorC = emailTestParseResultToString( errorCode ); + TQString errorC = emailTestParseResultToString( errorCode ); check( "isValidEmailAddress " + input + " errorCode ", errorC , expErrorCode ); return true; } -static bool checkIsValidSimpleEmailAddress( const QString& input, const QString& expResult ) +static bool checkIsValidSimpleEmailAddress( const TQString& input, const TQString& expResult ) { bool validEmail = KPIM::isValidSimpleEmailAddress( input ); - QString result = simpleEmailTestParseResultToString( validEmail ); + TQString result = simpleEmailTestParseResultToString( validEmail ); check( "isValidSimpleEmailAddress " + input + " result ", result, expResult ); return true; } -static bool checkGetEmailAddress( const QString& input, const QString& expResult ) +static bool checkGetEmailAddress( const TQString& input, const TQString& expResult ) { - QString emailAddress = KPIM::getEmailAddress( input ); - QString result = emailAddress; + TQString emailAddress = KPIM::getEmailAddress( input ); + TQString result = emailAddress; check( "getEmailAddress " + input + " result ", result, expResult ); return true; } -static bool checkSplitEmailAddrList( const QString& input, const QStringList& expResult ) +static bool checkSplitEmailAddrList( const TQString& input, const TQStringList& expResult ) { - QStringList emailAddresses = KPIM::splitEmailAddrList( input ); + TQStringList emailAddresses = KPIM::splitEmailAddrList( input ); check( "splitEmailAddrList( \"" + input + "\" ) result ", emailAddresses, expResult ); return true; } -static bool checkNormalizeAddressesAndEncodeIDNs( const QString& input, const QString& expResult ) +static bool checkNormalizeAddressesAndEncodeIDNs( const TQString& input, const TQString& expResult ) { - QString result = KPIM::normalizeAddressesAndEncodeIDNs( input ); + TQString result = KPIM::normalizeAddressesAndEncodeIDNs( input ); check( "normalizeAddressesAndEncodeIDNs( \"" + input + "\" ) result ", result, expResult ); return true; } -static bool checkNormalizeAddressesAndDecodeIDNs( const QString& input, const QString& expResult ) +static bool checkNormalizeAddressesAndDecodeIDNs( const TQString& input, const TQString& expResult ) { - QString result = KPIM::normalizeAddressesAndDecodeIDNs( input ); + TQString result = KPIM::normalizeAddressesAndDecodeIDNs( input ); check( "normalizeAddressesAndDecodeIDNs( \"" + input + "\" ) result ", result, expResult ); return true; } -static bool checkQuoteIfNecessary( const QString& input, const QString& expResult ) +static bool checkQuoteIfNecessary( const TQString& input, const TQString& expResult ) { - QString result = quoteNameIfNecessary( input ); + TQString result = quoteNameIfNecessary( input ); check( "quoteNameIfNecessary " + input + " result ", result, expResult ); return true; } @@ -166,10 +166,10 @@ int main(int argc, char *argv[]) KApplication app( false, false ); // Empty input - checkGetNameAndEmail( QString::null, QString::null, QString::null, false ); + checkGetNameAndEmail( TQString::null, TQString::null, TQString::null, false ); // Email only - checkGetNameAndEmail( "faure@kde.org", QString::null, "faure@kde.org", false ); + checkGetNameAndEmail( "faure@kde.org", TQString::null, "faure@kde.org", false ); // Normal case checkGetNameAndEmail( "David Faure <faure@kde.org>", "David Faure", "faure@kde.org", true ); @@ -203,8 +203,8 @@ int main(int argc, char *argv[]) //checkGetNameAndEmail( "\"a@b\" <faure@kde.org>", "a@b", "faure@kde.org", true ); // While typing, when there's no '@' yet - checkGetNameAndEmail( "foo", "foo", QString::null, false ); - checkGetNameAndEmail( "foo <", "foo", QString::null, false ); + checkGetNameAndEmail( "foo", "foo", TQString::null, false ); + checkGetNameAndEmail( "foo <", "foo", TQString::null, false ); checkGetNameAndEmail( "foo <b", "foo", "b", true ); // If multiple emails are there, only return the first one @@ -226,7 +226,7 @@ int main(int argc, char *argv[]) checkIsValidEmailAddress( "mattfruitsalad.org", "TooFewAts" ); // An empty string - checkIsValidEmailAddress( QString::null , "AddressEmpty" ); + checkIsValidEmailAddress( TQString::null , "AddressEmpty" ); // email address starting with a @ checkIsValidEmailAddress( "@mattfruitsalad.org", "MissingLocalPart" ); @@ -385,9 +385,9 @@ int main(int argc, char *argv[]) // checks for "pure" email addresses in the form of xxx@yyy.tld checkIsValidSimpleEmailAddress( "matt@fruitsalad.org", "true" ); - checkIsValidSimpleEmailAddress( QString::fromUtf8("test@täst.invalid"), "true" ); + checkIsValidSimpleEmailAddress( TQString::fromUtf8("test@täst.invalid"), "true" ); // non-ASCII char as first char of IDN - checkIsValidSimpleEmailAddress( QString::fromUtf8("i_want@øl.invalid"), "true" ); + checkIsValidSimpleEmailAddress( TQString::fromUtf8("i_want@øl.invalid"), "true" ); checkIsValidSimpleEmailAddress( "matt@[123.123.123.123]", "true" ); checkIsValidSimpleEmailAddress( "matt@[3.3.3.3]", "true" ); checkIsValidSimpleEmailAddress( "matt@[4.4.4.4]", "true" ); @@ -433,7 +433,7 @@ int main(int argc, char *argv[]) checkIsValidSimpleEmailAddress( "matt@123.123.123.123]", "false" ); checkIsValidSimpleEmailAddress( "\"matt@fruitsalad.org", "false" ); checkIsValidSimpleEmailAddress( "matt\"@fruitsalad.org", "false" ); - checkIsValidSimpleEmailAddress( QString::null, "false" ); + checkIsValidSimpleEmailAddress( TQString::null, "false" ); // and here some insane but still valid cases checkIsValidSimpleEmailAddress( "\"m@tt\"@fruitsalad.org", "true" ); @@ -445,17 +445,17 @@ int main(int argc, char *argv[]) checkGetEmailAddress( "Matt Douhan <matt@fruitsalad.org>", "matt@fruitsalad.org" ); checkGetEmailAddress( "\"Matt Douhan <blah blah>\" <matt@fruitsalad.org>", "matt@fruitsalad.org" ); checkGetEmailAddress( "\"Matt <blah blah>\" <matt@fruitsalad.org>", "matt@fruitsalad.org" ); - checkGetEmailAddress( "Matt Douhan (jongel) <matt@fruitsalad.org", QString() ); + checkGetEmailAddress( "Matt Douhan (jongel) <matt@fruitsalad.org", TQString() ); checkGetEmailAddress( "Matt Douhan (m@tt) <matt@fruitsalad.org>", "matt@fruitsalad.org" ); checkGetEmailAddress( "\"Douhan, Matt\" <matt@fruitsalad.org>", "matt@fruitsalad.org" ); checkGetEmailAddress( "\"Matt Douhan (m@tt)\" <matt@fruitsalad.org>", "matt@fruitsalad.org" ); - checkGetEmailAddress( "\"Matt Douhan\" (matt <matt@fruitsalad.org>", QString() ); + checkGetEmailAddress( "\"Matt Douhan\" (matt <matt@fruitsalad.org>", TQString() ); checkGetEmailAddress( "Matt Douhan <matt@[123.123.123.123]>", "matt@[123.123.123.123]" ); // check the splitEmailAddrList method - checkSplitEmailAddrList( "kloecker@kde.org (Kloecker, Ingo)", QStringList() << "kloecker@kde.org (Kloecker, Ingo)" ); - checkSplitEmailAddrList( "Matt Douhan <matt@fruitsalad.org>, Foo Bar <foo@bar.com>", QStringList() << "Matt Douhan <matt@fruitsalad.org>" << "Foo Bar <foo@bar.com>" ); - checkSplitEmailAddrList( "\"Matt, Douhan\" <matt@fruitsalad.org>, Foo Bar <foo@bar.com>", QStringList() << "\"Matt, Douhan\" <matt@fruitsalad.org>" << "Foo Bar <foo@bar.com>" ); + checkSplitEmailAddrList( "kloecker@kde.org (Kloecker, Ingo)", TQStringList() << "kloecker@kde.org (Kloecker, Ingo)" ); + checkSplitEmailAddrList( "Matt Douhan <matt@fruitsalad.org>, Foo Bar <foo@bar.com>", TQStringList() << "Matt Douhan <matt@fruitsalad.org>" << "Foo Bar <foo@bar.com>" ); + checkSplitEmailAddrList( "\"Matt, Douhan\" <matt@fruitsalad.org>, Foo Bar <foo@bar.com>", TQStringList() << "\"Matt, Douhan\" <matt@fruitsalad.org>" << "Foo Bar <foo@bar.com>" ); // check checkNormalizeAddressesAndEncodeIDNs checkNormalizeAddressesAndEncodeIDNs( "matt@fruitsalad.org", "matt@fruitsalad.org" ); @@ -467,7 +467,7 @@ int main(int argc, char *argv[]) // check checkNormalizeAddressesAndDecodeIDNs checkNormalizeAddressesAndDecodeIDNs( "=?us-ascii?Q?Surname=2C=20Name?= <nobody@example.org>", "\"Surname, Name\" <nobody@example.org>" ); - checkNormalizeAddressesAndDecodeIDNs( "=?iso-8859-1?B?5Hf8b2xmLPZBbmRyZWFz?= <nobody@example.org>", QString::fromUtf8("\"äwüolf,öAndreas\" <nobody@example.org>") ); + checkNormalizeAddressesAndDecodeIDNs( "=?iso-8859-1?B?5Hf8b2xmLPZBbmRyZWFz?= <nobody@example.org>", TQString::fromUtf8("\"äwüolf,öAndreas\" <nobody@example.org>") ); // check the "quote if necessary" method checkQuoteIfNecessary( "Matt Douhan", "Matt Douhan"); diff --git a/libemailfunctions/tests/testidmapper.cpp b/libemailfunctions/tests/testidmapper.cpp index 245895ec9..591ebce03 100644 --- a/libemailfunctions/tests/testidmapper.cpp +++ b/libemailfunctions/tests/testidmapper.cpp @@ -19,13 +19,13 @@ Boston, MA 02110-1301, USA. */ -#include <qapplication.h> +#include <tqapplication.h> #include "idmapper.h" int main( int argc, char **argv ) { - QApplication app( argc, argv ); + TQApplication app( argc, argv ); KPIM::IdMapper mapper( "test.uidmap" ) ; |