~ubuntu-branches/ubuntu/hardy/kdepim/hardy-proposed

« back to all changes in this revision

Viewing changes to kmail/popaccount.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Wenning
  • Date: 2008-11-18 13:39:44 UTC
  • mfrom: (82.1.1 hardy-updates)
  • Revision ID: james.westby@ubuntu.com-20081118133944-py2nova33va86lf9
Tags: 4:3.5.10-0ubuntu1~hardy3
* Add kubuntu_17_upstream_r860376.diff which fixed a pointer problem
  in korganizer leading to objects being lost.
* Add kubuntu_18_upstream_r857911.diff to make sure that the inbox
  folder doesn't stay hidden if content is added.
  - See http://bugs.kde.org/show_bug.cgi?id=168544
* Add kubuntu_19_fix_gcal_crash.diff which fixes problems with remote
  resources crashing kontact, most notably when using GCal. (LP: #286905)
* Add kubuntu_20_upstream_r882942.diff which prevents incidence loss
  under certain conditions as the UID map wasn't being reloaded.
* Add kubuntu_21_upstream_r882976.diff to prevent KMail crashing
  due to certain malicious base64-encoded mail parts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
389
389
  idsOfMsgs.clear();
390
390
  mUidForIdMap.clear();
391
391
  idsOfMsgsToDelete.clear();
 
392
  idsOfForcedDeletes.clear();
 
393
 
392
394
  //delete any headers if there are some this have to be done because of check again
393
395
  headersOnServer.clear();
394
396
  headers = false;
735
737
        idsOfMsgsToDelete.remove( it.key().second );
736
738
      }
737
739
    }
 
740
 
 
741
    if ( !idsOfForcedDeletes.isEmpty() ) {
 
742
      idsOfMsgsToDelete += idsOfForcedDeletes;
 
743
      idsOfForcedDeletes.clear();
 
744
    }
 
745
 
738
746
    // If there are messages to delete then delete them
739
747
    if ( !idsOfMsgsToDelete.isEmpty() ) {
740
748
      stage = Dele;
923
931
  QString qdata = data;
924
932
  qdata = qdata.simplifyWhiteSpace(); // Workaround for Maillennium POP3/UNIBOX
925
933
  int spc = qdata.find( ' ' );
926
 
  if (spc > 0) {
927
 
    if (stage == List) {
 
934
  if ( stage == List ) {
 
935
    if ( spc > 0 ) {
928
936
      QString length = qdata.mid(spc+1);
929
937
      if (length.find(' ') != -1) length.truncate(length.find(' '));
930
938
      int len = length.toInt();
933
941
      idsOfMsgs.append( id );
934
942
      mMsgsPendingDownload.insert( id, len );
935
943
    }
936
 
    else { // stage == Uidl
937
 
      const QString id = qdata.left(spc);
938
 
      const QString uid = qdata.mid(spc + 1);
939
 
      int *size = new int; //malloc(size_of(int));
940
 
      *size = mMsgsPendingDownload[id];
941
 
      mSizeOfNextSeenMsgsDict.insert( uid, size );
942
 
      if ( mUidsOfSeenMsgsDict.find( uid ) != 0 ) {
943
 
 
944
 
        if ( mMsgsPendingDownload.contains( id ) ) {
945
 
          mMsgsPendingDownload.remove( id );
946
 
        }
947
 
        else
948
 
          kdDebug(5006) << "PopAccount::slotData synchronization failure." << endl;
949
 
        idsOfMsgsToDelete.append( id );
950
 
        mUidsOfNextSeenMsgsDict.insert( uid, (const int *)1 );
951
 
        if ( mTimeOfSeenMsgsVector.empty() ) {
952
 
          mTimeOfNextSeenMsgsMap.insert( uid, time(0) );
953
 
        }
954
 
        else {
955
 
          // cast the int* with a long to can convert it to a int, BTW
956
 
          // works with g++-4.0 and amd64
957
 
          mTimeOfNextSeenMsgsMap.insert( uid,
958
 
            mTimeOfSeenMsgsVector[(int)( long )mUidsOfSeenMsgsDict[uid] - 1] );
959
 
        }
960
 
      }
961
 
      mUidForIdMap.insert( id, uid );
 
944
    else {
 
945
      stage = Idle;
 
946
      if ( job ) job->kill();
 
947
      job = 0;
 
948
      mSlave = 0;
 
949
      KMessageBox::error( 0, i18n( "Unable to complete LIST operation." ),
 
950
                             i18n( "Invalid Response From Server") );
 
951
      return;
962
952
    }
963
953
  }
964
 
  else {
965
 
    stage = Idle;
966
 
    if (job) job->kill();
967
 
    job = 0;
968
 
    mSlave = 0;
969
 
    KMessageBox::error(0, i18n( "Unable to complete LIST operation." ),
970
 
                          i18n("Invalid Response From Server"));
971
 
    return;
 
954
  else { // stage == Uidl
 
955
    Q_ASSERT ( stage == Uidl);
 
956
 
 
957
    QString id;
 
958
    QString uid;
 
959
 
 
960
    if ( spc <= 0 ) {
 
961
      // an invalid uidl line. we might just need to skip it, but
 
962
      // some servers generate invalid uids with valid ids. in that
 
963
      // case we will just make up a uid - which will cause us to
 
964
      // not cache the document, but we will be able to interoperate
 
965
 
 
966
      int testid = atoi ( qdata.ascii() );
 
967
      if ( testid < 1 ) {
 
968
        // we'll just have to skip this
 
969
        kdDebug(5006) << "PopAccount::slotData skipping UIDL entry due to parse error "
 
970
                      << endl << qdata.ascii() << endl;
 
971
        return;
 
972
      }
 
973
      id.setNum (testid, 10);
 
974
 
 
975
      QString datestring, serialstring;
 
976
 
 
977
      serialstring.setNum ( ++dataCounter, 10 );
 
978
      datestring.setNum ( time(NULL),10 );
 
979
      uid = QString( "uidlgen" ) + datestring + QString( "." ) + serialstring;
 
980
      kdDebug(5006) << "PopAccount::slotData message " << id.ascii()
 
981
                    <<  "%d has bad UIDL, cannot keep a copy on server" << endl;
 
982
      idsOfForcedDeletes.append( id );
 
983
    }
 
984
    else {
 
985
      id = qdata.left( spc );
 
986
      uid = qdata.mid( spc + 1 );
 
987
    }
 
988
 
 
989
    int *size = new int; //malloc(size_of(int));
 
990
    *size = mMsgsPendingDownload[id];
 
991
    mSizeOfNextSeenMsgsDict.insert( uid, size );
 
992
    if ( mUidsOfSeenMsgsDict.find( uid ) != 0 ) {
 
993
      if ( mMsgsPendingDownload.contains( id ) ) {
 
994
        mMsgsPendingDownload.remove( id );
 
995
      }
 
996
      else
 
997
        kdDebug(5006) << "PopAccount::slotData synchronization failure." << endl;
 
998
      idsOfMsgsToDelete.append( id );
 
999
      mUidsOfNextSeenMsgsDict.insert( uid, (const int *)1 );
 
1000
      if ( mTimeOfSeenMsgsVector.empty() ) {
 
1001
        mTimeOfNextSeenMsgsMap.insert( uid, time(0) );
 
1002
      }
 
1003
      else {
 
1004
        // cast the int* with a long to can convert it to a int, BTW
 
1005
        // works with g++-4.0 and amd64
 
1006
        mTimeOfNextSeenMsgsMap.insert( uid, mTimeOfSeenMsgsVector[(int)( long )
 
1007
                                                 mUidsOfSeenMsgsDict[uid] - 1] );
 
1008
      }
 
1009
    }
 
1010
    mUidForIdMap.insert( id, uid );
972
1011
  }
973
1012
}
974
1013
 
975
 
 
976
1014
//-----------------------------------------------------------------------------
977
1015
void PopAccount::slotResult( KIO::Job* )
978
1016
{