1087
1089
if ( d_func()->msgIdList.isEmpty() ) {
1088
1090
return QByteArray();
1090
const Types::AddrSpec &addr = d_func()->msgIdList.first();
1091
return addr.asString().toLatin1(); // FIXME change parsing to create QByteArrays
1093
if ( d_func()->cachedIdentifier.isEmpty() ) {
1094
const Types::AddrSpec &addr = d_func()->msgIdList.first();
1095
d_func()->cachedIdentifier = addr.asString().toLatin1(); // FIXME change parsing to create QByteArrays
1098
return d_func()->cachedIdentifier;
1094
1101
void SingleIdent::setIdentifier( const QByteArray &id )
1096
1103
Q_D(SingleIdent);
1097
1104
d->msgIdList.clear();
1105
d->cachedIdentifier.clear();
1098
1106
appendIdentifier( id );
1720
1727
QByteArray ContentType::mimeType() const
1722
1729
Q_D(const ContentType);
1724
mt.reserve( d->mimeType.size() + d->mimeSubType.size() + 1 );
1725
mt.append( d->mimeType );
1727
mt.append( d->mimeSubType );
1731
1733
QByteArray ContentType::mediaType() const
1733
return d_func()->mimeType;
1735
Q_D(const ContentType);
1736
const int pos = d->mimeType.indexOf( '/' );
1740
return d->mimeType.left( pos );
1736
1743
QByteArray ContentType::subType() const
1738
return d_func()->mimeSubType;
1745
Q_D(const ContentType);
1746
const int pos = d->mimeType.indexOf( '/' );
1748
return QByteArray();
1750
return d->mimeType.mid( pos + 1);
1741
1753
void ContentType::setMimeType( const QByteArray &mimeType )
1743
1755
Q_D(ContentType);
1744
int pos = mimeType.indexOf( '/' );
1746
d->mimeType = mimeType;
1747
d->mimeSubType.clear();
1749
d->mimeType = mimeType.left( pos );
1750
d->mimeSubType = mimeType.mid( pos + 1 );
1756
d->mimeType = mimeType;
1752
1757
Parametrized::clear();
1754
1759
if ( isMultipart() ) {
1761
1766
bool ContentType::isMediatype( const char *mediatype ) const
1763
return strncasecmp( mediaType().constData(), mediatype, strlen( mediatype ) ) == 0;
1768
Q_D(const ContentType);
1769
const int len = strlen( mediatype );
1770
return strncasecmp( d->mimeType.constData(), mediatype, len ) == 0 && (d->mimeType.at(len) == '/' || d->mimeType.size() == len);
1766
1773
bool ContentType::isSubtype( const char *subtype ) const
1768
return strncasecmp( subType().constData(), subtype, strlen( subtype ) ) == 0;
1775
Q_D(const ContentType);
1776
const int pos = d->mimeType.indexOf( '/' );
1779
const int len = strlen( subtype );
1780
return strncasecmp( d->mimeType.constData() + pos + 1, subtype, len ) == 0 && d->mimeType.size() == pos + len + 1;
1771
1783
bool ContentType::isText() const
1773
return ( strncasecmp( mediaType().constData(), "text", 4 ) == 0
1785
return ( isMediatype( "text" ) || isEmpty() );
1777
1788
bool ContentType::isPlainText() const
1779
return ( strcasecmp( mimeType().constData(), "text/plain" ) == 0
1790
return ( strcasecmp( d_func()->mimeType.constData(), "text/plain" ) == 0 || isEmpty() );
1783
1793
bool ContentType::isHTMLText() const
1785
return strcasecmp( mimeType().constData(), "text/html" ) == 0;
1795
return strcasecmp( d_func()->mimeType.constData(), "text/html" ) == 0;
1788
1798
bool ContentType::isImage() const
1790
return strncasecmp( mediaType().constData(), "image", 5 ) == 0;
1800
return isMediatype( "image" );
1793
1803
bool ContentType::isMultipart() const
1795
return strncasecmp( mediaType().constData(), "multipart", 9 ) == 0;
1805
return isMediatype( "multipart" );
1798
1808
bool ContentType::isPartial() const
1800
return strcasecmp( mimeType().constData(), "message/partial" ) == 0;
1810
return strcasecmp( d_func()->mimeType.constData(), "message/partial" ) == 0;
1803
1813
QByteArray ContentType::charset() const
1901
1911
if ( !parseToken( scursor, send, maybeMimeType, false /* no 8Bit */ ) ) {
1904
d->mimeType = QByteArray( maybeMimeType.first, maybeMimeType.second ).toLower();
1907
1916
eatCFWS( scursor, send, isCRLF );
1918
1927
if ( !parseToken( scursor, send, maybeSubType, false /* no 8bit */ ) ) {
1921
d->mimeSubType = QByteArray( maybeSubType.first, maybeSubType.second ).toLower();
1931
d->mimeType.reserve( maybeMimeType.second + maybeSubType.second + 1 );
1932
d->mimeType = QByteArray( maybeMimeType.first, maybeMimeType.second ).toLower()
1933
+ '/' + QByteArray( maybeSubType.first, maybeSubType.second ).toLower();
1923
1935
// parameter list
1924
1936
eatCFWS( scursor, send, isCRLF );