~ubuntu-branches/ubuntu/quantal/kdepimlibs/quantal-proposed

« back to all changes in this revision

Viewing changes to kmime/kmime_headers.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-14 14:37:07 UTC
  • mto: This revision was merged to the branch mainline in revision 112.
  • Revision ID: package-import@ubuntu.com-20111214143707-m0qplh3hsd957ukv
Tags: upstream-4.7.90
ImportĀ upstreamĀ versionĀ 4.7.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
206
206
 
207
207
bool Base::is( const char *t ) const
208
208
{
209
 
  return strcasecmp( t, type() ) == 0;
 
209
  return qstricmp( t, type() ) == 0;
210
210
}
211
211
 
212
212
bool Base::isMimeHeader() const
213
213
{
214
 
  return strncasecmp( type(), "Content-", 8 ) == 0;
 
214
  return qstrnicmp( type(), "Content-", 8 ) == 0;
215
215
}
216
216
 
217
217
bool Base::isXHeader() const
218
218
{
219
 
  return strncmp( type(), "X-", 2 ) == 0;
 
219
  return qstrncmp( type(), "X-", 2 ) == 0;
220
220
}
221
221
 
222
222
QByteArray Base::typeIntro() const
983
983
    rv = typeIntro();
984
984
  }
985
985
  foreach ( const Types::AddrSpec &addr, d->msgIdList ) {
986
 
    rv += '<';
987
 
    rv += addr.asString().toLatin1(); // FIXME: change parsing to use QByteArrays
988
 
    rv += "> ";
989
 
  }
990
 
  rv.resize( rv.length() - 1 );
 
986
    if ( !addr.isEmpty() ) {
 
987
      const QString asString = addr.asString();
 
988
      rv += '<';
 
989
      if ( !asString.isEmpty() ) {
 
990
        rv += asString.toLatin1(); // FIXME: change parsing to use QByteArrays
 
991
      }
 
992
      rv += "> ";
 
993
    }
 
994
  }
 
995
  if ( !rv.isEmpty() ) {
 
996
    rv.resize( rv.length() - 1 );
 
997
  }
991
998
  return rv;
992
999
}
993
1000
 
1051
1058
{
1052
1059
  QList<QByteArray> rv;
1053
1060
  foreach ( const Types::AddrSpec &addr, d_func()->msgIdList ) {
1054
 
    rv.append( addr.asString().toLatin1() ); // FIXME change parsing to create QByteArrays
 
1061
    if ( !addr.isEmpty() ) {
 
1062
      const QString asString = addr.asString();
 
1063
      if ( !asString.isEmpty() ) {
 
1064
        rv.append( asString.toLatin1() ); // FIXME: change parsing to use QByteArrays
 
1065
      }
 
1066
    }
1055
1067
  }
1056
1068
  return rv;
1057
1069
}
1092
1104
 
1093
1105
  if ( d_func()->cachedIdentifier.isEmpty() ) {
1094
1106
    const Types::AddrSpec &addr = d_func()->msgIdList.first();
1095
 
    d_func()->cachedIdentifier = addr.asString().toLatin1(); // FIXME change parsing to create QByteArrays
 
1107
    if ( !addr.isEmpty() ) {
 
1108
      const QString asString = addr.asString();
 
1109
      if ( !asString.isEmpty() ) {
 
1110
        d_func()->cachedIdentifier = asString.toLatin1();// FIXME: change parsing to use QByteArrays
 
1111
      }
 
1112
    }
1096
1113
  }
1097
1114
 
1098
1115
  return d_func()->cachedIdentifier;
1767
1784
{
1768
1785
  Q_D(const ContentType);
1769
1786
  const int len = strlen( mediatype );
1770
 
  return strncasecmp( d->mimeType.constData(), mediatype, len ) == 0 && (d->mimeType.at(len) == '/' || d->mimeType.size() == len);
 
1787
  return qstrnicmp( d->mimeType.constData(), mediatype, len ) == 0 && (d->mimeType.at(len) == '/' || d->mimeType.size() == len);
1771
1788
}
1772
1789
 
1773
1790
bool ContentType::isSubtype( const char *subtype ) const
1777
1794
  if ( pos < 0 )
1778
1795
    return false;
1779
1796
  const int len = strlen( subtype );
1780
 
  return strncasecmp( d->mimeType.constData() + pos + 1, subtype, len ) == 0 && d->mimeType.size() == pos + len + 1;
 
1797
  return qstrnicmp( d->mimeType.constData() + pos + 1, subtype, len ) == 0 && d->mimeType.size() == pos + len + 1;
1781
1798
}
1782
1799
 
1783
1800
bool ContentType::isText() const
1787
1804
 
1788
1805
bool ContentType::isPlainText() const
1789
1806
{
1790
 
  return ( strcasecmp( d_func()->mimeType.constData(), "text/plain" ) == 0 || isEmpty() );
 
1807
  return ( qstricmp( d_func()->mimeType.constData(), "text/plain" ) == 0 || isEmpty() );
1791
1808
}
1792
1809
 
1793
1810
bool ContentType::isHTMLText() const
1794
1811
{
1795
 
  return strcasecmp( d_func()->mimeType.constData(), "text/html" ) == 0;
 
1812
  return qstricmp( d_func()->mimeType.constData(), "text/html" ) == 0;
1796
1813
}
1797
1814
 
1798
1815
bool ContentType::isImage() const
1807
1824
 
1808
1825
bool ContentType::isPartial() const
1809
1826
{
1810
 
  return strcasecmp( d_func()->mimeType.constData(), "message/partial" ) == 0;
 
1827
  return qstricmp( d_func()->mimeType.constData(), "message/partial" ) == 0;
1811
1828
}
1812
1829
 
1813
1830
QByteArray ContentType::charset() const
2119
2136
 
2120
2137
  // TODO: error handling in case of an unknown encoding?
2121
2138
  for ( int i = 0; encTable[i].s != 0; ++i ) {
2122
 
    if ( strcasecmp( token().constData(), encTable[i].s ) == 0 ) {
 
2139
    if ( qstricmp( token().constData(), encTable[i].s ) == 0 ) {
2123
2140
      d->cte = ( contentEncoding )encTable[i].e;
2124
2141
      break;
2125
2142
    }