kmail Library API Documentation

kmmsginfo.cpp

00001 // kmmsginfo.cpp
00002 
00003 #ifdef HAVE_CONFIG_H
00004 #include <config.h>
00005 #endif
00006 
00007 #include "kmmsginfo.h"
00008 #include "kmmessage.h"
00009 //#include "kmmsgpart.h" // for encode
00010 
00011 #include <stdlib.h>
00012 #include <string.h>
00013 #include <stdio.h>
00014 #include <assert.h>
00015 #include <mimelib/datetime.h>
00016 
00017 class KMMsgInfo::KMMsgInfoPrivate
00018 {
00019 public:
00020     enum {
00021     SUBJECT_SET = 0x01, TO_SET = 0x02, REPLYTO_SET = 0x04, MSGID_SET=0x08,
00022     DATE_SET = 0x10, OFFSET_SET = 0x20, SIZE_SET = 0x40, SIZESERVER_SET = 0x80,
00023     XMARK_SET=0x100, FROM_SET=0x200, FILE_SET=0x400, ENCRYPTION_SET=0x800,
00024     SIGNATURE_SET=0x1000, MDN_SET=0x2000, REPLYTOAUX_SET = 0x4000,
00025     STRIPPEDSUBJECT_SET = 0x8000,  UID_SET = 0x10000,
00026 
00027     ALL_SET = 0xFFFFFF, NONE_SET = 0x000000
00028     };
00029     uint modifiers;
00030     QString subject, from, to, replyToIdMD5, replyToAuxIdMD5,
00031             strippedSubjectMD5, msgIdMD5, xmark, file;
00032     off_t folderOffset;
00033     size_t msgSize, msgSizeServer;
00034     time_t date;
00035     KMMsgEncryptionState encryptionState;
00036     KMMsgSignatureState signatureState;
00037     KMMsgMDNSentState mdnSentState;
00038     ulong UID;
00039 
00040     KMMsgInfoPrivate() : modifiers(NONE_SET) { }
00041     KMMsgInfoPrivate& operator=(const KMMsgInfoPrivate& other) {
00042     modifiers = NONE_SET;
00043     if (other.modifiers & SUBJECT_SET) {
00044         modifiers |= SUBJECT_SET;
00045         subject = other.subject;
00046     }
00047     if (other.modifiers & STRIPPEDSUBJECT_SET) {
00048         modifiers |= STRIPPEDSUBJECT_SET;
00049         strippedSubjectMD5 = other.strippedSubjectMD5;
00050     }
00051     if (other.modifiers & FROM_SET) {
00052         modifiers |= FROM_SET;
00053         from = other.from;
00054     }
00055     if (other.modifiers & FILE_SET) {
00056         modifiers |= FILE_SET;
00057         file = other.from;
00058     }
00059     if (other.modifiers & TO_SET) {
00060         modifiers |= TO_SET;
00061         to = other.to;
00062     }
00063     if (other.modifiers & REPLYTO_SET) {
00064         modifiers |= REPLYTO_SET;
00065         replyToIdMD5 = other.replyToIdMD5;
00066     }
00067     if (other.modifiers & REPLYTOAUX_SET) {
00068         modifiers |= REPLYTOAUX_SET;
00069         replyToAuxIdMD5 = other.replyToAuxIdMD5;
00070     }
00071 
00072     if(other.modifiers & MSGID_SET) {
00073         modifiers |= MSGID_SET;
00074         msgIdMD5 = other.msgIdMD5;
00075     }
00076     if(other.modifiers & XMARK_SET) {
00077         modifiers |= XMARK_SET;
00078         xmark = other.xmark;
00079     }
00080     if(other.modifiers & OFFSET_SET) {
00081         modifiers |= OFFSET_SET;
00082         folderOffset = other.folderOffset;
00083     }
00084     if(other.modifiers & SIZE_SET) {
00085         modifiers |= SIZE_SET;
00086         msgSize = other.msgSize;
00087     }
00088     if(other.modifiers & DATE_SET) {
00089         modifiers |= DATE_SET;
00090         date = other.date;
00091     }
00092     if(other.modifiers & ENCRYPTION_SET) {
00093         modifiers |= ENCRYPTION_SET;
00094         encryptionState = other.encryptionState;
00095     }
00096     if(other.modifiers & SIGNATURE_SET) {
00097         modifiers |= SIGNATURE_SET;
00098         signatureState = other.signatureState;
00099     }
00100     if(other.modifiers & MDN_SET) {
00101         modifiers |= MDN_SET;
00102         mdnSentState = other.mdnSentState;
00103     }
00104     if(other.modifiers & SIZESERVER_SET) {
00105         modifiers |= SIZESERVER_SET;
00106         msgSizeServer = other.msgSizeServer;
00107     }
00108     if(other.modifiers & UID_SET) {
00109         modifiers |= UID_SET;
00110         UID = other.UID;
00111     }
00112     return *this;
00113     }
00114 };
00115 
00116 //-----------------------------------------------------------------------------
00117 KMMsgInfo::KMMsgInfo(KMFolder* p, off_t off, short len) :
00118     KMMsgBase(p),
00119     kd(0)
00120 {
00121     setIndexOffset(off);
00122     setIndexLength(len);
00123     setEnableUndo(true);
00124 }
00125 
00126 
00127 //-----------------------------------------------------------------------------
00128 KMMsgInfo::~KMMsgInfo()
00129 {
00130     delete kd;
00131 }
00132 
00133 
00134 //-----------------------------------------------------------------------------
00135 KMMsgInfo& KMMsgInfo::operator=(const KMMsgInfo& other)
00136 {
00137     KMMsgBase::assign(&other);
00138     if(other.kd) {
00139         if(!kd)
00140         kd = new KMMsgInfoPrivate;
00141     *kd = *other.kd;
00142     } else {
00143     delete kd;
00144     kd = 0;
00145     }
00146     mStatus = other.status();
00147     return *this;
00148 }
00149 
00150 
00151 //-----------------------------------------------------------------------------
00152 KMMsgInfo& KMMsgInfo::operator=(const KMMessage& msg)
00153 {
00154     KMMsgBase::assign(&msg.toMsgBase());
00155     if(!kd)
00156     kd = new KMMsgInfoPrivate;
00157     kd->modifiers = KMMsgInfoPrivate::ALL_SET;
00158     kd->subject = msg.subject();
00159     kd->from = msg.fromStrip();
00160     kd->to = msg.toStrip();
00161     kd->replyToIdMD5 = msg.replyToIdMD5();
00162     kd->replyToAuxIdMD5 = msg.replyToAuxIdMD5();
00163     kd->strippedSubjectMD5 = msg.strippedSubjectMD5();
00164     kd->msgIdMD5 = msg.msgIdMD5();
00165     kd->xmark = msg.xmark();
00166     mStatus = msg.status();
00167     kd->folderOffset = msg.folderOffset();
00168     kd->msgSize = msg.msgSize();
00169     kd->date = msg.date();
00170     kd->file = msg.fileName();
00171     kd->encryptionState = msg.encryptionState();
00172     kd->signatureState = msg.signatureState();
00173     kd->mdnSentState = msg.mdnSentState();
00174     kd->msgSizeServer = msg.msgSizeServer();
00175     kd->UID = msg.UID();
00176     return *this;
00177 }
00178 
00179 //-----------------------------------------------------------------------------
00180 void KMMsgInfo::init(const QCString& aSubject, const QCString& aFrom,
00181                      const QCString& aTo, time_t aDate,
00182              KMMsgStatus aStatus, const QCString& aXMark,
00183              const QCString& replyToId, const QCString& replyToAuxId,
00184              const QCString& msgId,
00185              KMMsgEncryptionState encryptionState,
00186              KMMsgSignatureState signatureState,
00187              KMMsgMDNSentState mdnSentState,
00188              off_t aFolderOffset, size_t aMsgSize,
00189              size_t aMsgSizeServer, ulong aUID)
00190 {
00191     mIndexOffset = 0;
00192     mIndexLength = 0;
00193     if(!kd)
00194     kd = new KMMsgInfoPrivate;
00195     kd->modifiers = KMMsgInfoPrivate::ALL_SET;
00196     kd->subject = decodeRFC2047String(aSubject);
00197     kd->from = decodeRFC2047String( KMMessage::stripEmailAddr( aFrom ) );
00198     kd->to = decodeRFC2047String( KMMessage::stripEmailAddr( aTo ) );
00199     kd->replyToIdMD5 = base64EncodedMD5( replyToId );
00200     kd->replyToAuxIdMD5 = base64EncodedMD5( replyToAuxId );
00201     kd->strippedSubjectMD5 = base64EncodedMD5( KMMessage::stripOffPrefixes( kd->subject ), true /*utf8*/ );
00202     kd->msgIdMD5 = base64EncodedMD5( msgId );
00203     kd->xmark = aXMark;
00204     kd->folderOffset = aFolderOffset;
00205     mStatus    = aStatus;
00206     kd->msgSize = aMsgSize;
00207     kd->date = aDate;
00208     kd->file = "";
00209     kd->encryptionState = encryptionState;
00210     kd->signatureState = signatureState;
00211     kd->mdnSentState = mdnSentState;
00212     kd->msgSizeServer = aMsgSizeServer;
00213     kd->UID = aUID;
00214     mDirty     = FALSE;
00215 }
00216 
00217 void KMMsgInfo::init(const QCString& aSubject, const QCString& aFrom,
00218                      const QCString& aTo, time_t aDate,
00219              KMMsgStatus aStatus, const QCString& aXMark,
00220              const QCString& replyToId, const QCString& replyToAuxId,
00221              const QCString& msgId,
00222              const QCString& aFileName,
00223              KMMsgEncryptionState encryptionState,
00224              KMMsgSignatureState signatureState,
00225              KMMsgMDNSentState mdnSentState,
00226              size_t aMsgSize,
00227              size_t aMsgSizeServer, ulong aUID)
00228 {
00229   // use the "normal" init for most stuff
00230   init( aSubject, aFrom, aTo, aDate, aStatus, aXMark, replyToId, replyToAuxId,
00231         msgId, encryptionState, signatureState, mdnSentState,
00232         (unsigned long)0, aMsgSize, aMsgSizeServer, aUID );
00233   kd->file = aFileName;
00234 }
00235 
00236 
00237 //-----------------------------------------------------------------------------
00238 QString KMMsgInfo::subject(void) const
00239 {
00240     if (kd && kd->modifiers & KMMsgInfoPrivate::SUBJECT_SET)
00241     return kd->subject;
00242     return getStringPart(MsgSubjectPart);
00243 }
00244 
00245 
00246 //-----------------------------------------------------------------------------
00247 QString KMMsgInfo::fromStrip(void) const
00248 {
00249     if (kd && kd->modifiers & KMMsgInfoPrivate::FROM_SET)
00250     return kd->from;
00251     return getStringPart(MsgFromPart);
00252 }
00253 
00254 //-----------------------------------------------------------------------------
00255 QString KMMsgInfo::fileName(void) const
00256 {
00257     if (kd && kd->modifiers & KMMsgInfoPrivate::FILE_SET)
00258         return kd->file;
00259     return getStringPart(MsgFilePart);
00260 }
00261 
00262 
00263 //-----------------------------------------------------------------------------
00264 QString KMMsgInfo::toStrip(void) const
00265 {
00266     if (kd && kd->modifiers & KMMsgInfoPrivate::TO_SET)
00267     return kd->to;
00268     return getStringPart(MsgToPart);
00269 }
00270 
00271 //-----------------------------------------------------------------------------
00272 QString KMMsgInfo::xmark(void) const
00273 {
00274     if (kd && kd->modifiers & KMMsgInfoPrivate::XMARK_SET)
00275     return kd->xmark;
00276     return getStringPart(MsgXMarkPart);
00277 }
00278 
00279 
00280 //-----------------------------------------------------------------------------
00281 QString KMMsgInfo::replyToIdMD5(void) const
00282 {
00283     if (kd && kd->modifiers & KMMsgInfoPrivate::REPLYTO_SET)
00284     return kd->replyToIdMD5;
00285     return getStringPart(MsgReplyToIdMD5Part);
00286 }
00287 
00288 //-----------------------------------------------------------------------------
00289 QString KMMsgInfo::replyToAuxIdMD5() const
00290 {
00291     if( kd && kd->modifiers & KMMsgInfoPrivate::REPLYTOAUX_SET )
00292     return kd->replyToAuxIdMD5;
00293     return getStringPart( MsgReplyToAuxIdMD5Part );
00294 }
00295 
00296 //-----------------------------------------------------------------------------
00297 QString KMMsgInfo::strippedSubjectMD5() const
00298 {
00299     if( kd && kd->modifiers & KMMsgInfoPrivate::STRIPPEDSUBJECT_SET )
00300     return kd->strippedSubjectMD5;
00301     return getStringPart( MsgStrippedSubjectMD5Part );
00302 }
00303 
00304 
00305 //-----------------------------------------------------------------------------
00306 bool KMMsgInfo::subjectIsPrefixed() const
00307 {
00308     return strippedSubjectMD5() != base64EncodedMD5( subject().stripWhiteSpace(), true /*utf8*/ );
00309 }
00310 
00311 //-----------------------------------------------------------------------------
00312 QString KMMsgInfo::msgIdMD5(void) const
00313 {
00314     if (kd && kd->modifiers & KMMsgInfoPrivate::MSGID_SET)
00315     return kd->msgIdMD5;
00316     return getStringPart(MsgIdMD5Part);
00317 }
00318 
00319 
00320 //-----------------------------------------------------------------------------
00321 void KMMsgInfo::setSubject(const QString& aSubject)
00322 {
00323     if(aSubject == subject())
00324     return;
00325 
00326     if (!kd)
00327     kd = new KMMsgInfoPrivate;
00328     kd->modifiers |= KMMsgInfoPrivate::SUBJECT_SET;
00329     kd->subject = aSubject;
00330     mDirty = TRUE;
00331 }
00332 
00333 
00334 //-----------------------------------------------------------------------------
00335 void KMMsgInfo::setXMark(const QString& aXMark)
00336 {
00337     if (aXMark == xmark())
00338     return;
00339 
00340     if (!kd)
00341     kd = new KMMsgInfoPrivate;
00342     kd->modifiers |= KMMsgInfoPrivate::XMARK_SET;
00343     kd->xmark = aXMark;
00344     mDirty = TRUE;
00345 }
00346 
00347 
00348 //-----------------------------------------------------------------------------
00349 void KMMsgInfo::setReplyToIdMD5(const QString& aReplyToIdMD5)
00350 {
00351     if (aReplyToIdMD5 == replyToIdMD5())
00352     return;
00353 
00354     if (!kd)
00355     kd = new KMMsgInfoPrivate;
00356     kd->modifiers |= KMMsgInfoPrivate::REPLYTO_SET;
00357     kd->replyToIdMD5 = aReplyToIdMD5;
00358     mDirty = TRUE;
00359 }
00360 
00361 
00362 //-----------------------------------------------------------------------------
00363 void KMMsgInfo::setReplyToAuxIdMD5( const QString& aReplyToAuxIdMD5 )
00364 {
00365     if( aReplyToAuxIdMD5 == replyToAuxIdMD5() )
00366     return;
00367 
00368     if( !kd )
00369     kd = new KMMsgInfoPrivate;
00370     kd->modifiers |= KMMsgInfoPrivate::REPLYTOAUX_SET;
00371     kd->replyToAuxIdMD5 = aReplyToAuxIdMD5;
00372     mDirty = TRUE;
00373 }
00374 
00375 
00376 //-----------------------------------------------------------------------------
00377 void KMMsgInfo::initStrippedSubjectMD5()
00378 {
00379     if( kd && kd->modifiers & KMMsgInfoPrivate::STRIPPEDSUBJECT_SET )
00380     return;
00381     QString rawSubject = KMMessage::stripOffPrefixes( subject() );
00382     QString subjectMD5 = base64EncodedMD5( rawSubject, true /*utf8*/ );
00383     if( !kd )
00384     kd = new KMMsgInfoPrivate;
00385     kd->modifiers |= KMMsgInfoPrivate::STRIPPEDSUBJECT_SET;
00386     kd->strippedSubjectMD5 = subjectMD5;
00387     mDirty = TRUE;
00388 }
00389 
00390 
00391 //-----------------------------------------------------------------------------
00392 void KMMsgInfo::setMsgIdMD5(const QString& aMsgIdMD5)
00393 {
00394     if (aMsgIdMD5 == msgIdMD5())
00395     return;
00396 
00397     if (!kd)
00398     kd = new KMMsgInfoPrivate;
00399     kd->modifiers |= KMMsgInfoPrivate::MSGID_SET;
00400     kd->msgIdMD5 = aMsgIdMD5;
00401     mDirty = TRUE;
00402 }
00403 
00404 //-----------------------------------------------------------------------------
00405 void KMMsgInfo::setEncryptionState( const KMMsgEncryptionState s, int idx )
00406 {
00407     if (s == encryptionState())
00408     return;
00409 
00410     if (!kd)
00411     kd = new KMMsgInfoPrivate;
00412     kd->modifiers |= KMMsgInfoPrivate::ENCRYPTION_SET;
00413     kd->encryptionState = s;
00414     KMMsgBase::setEncryptionState(s, idx); //base does more "stuff"
00415     mDirty = TRUE;
00416 }
00417 
00418 //-----------------------------------------------------------------------------
00419 void KMMsgInfo::setSignatureState( const KMMsgSignatureState s, int idx )
00420 {
00421     if (s == signatureState())
00422     return;
00423 
00424     if (!kd)
00425     kd = new KMMsgInfoPrivate;
00426     kd->modifiers |= KMMsgInfoPrivate::SIGNATURE_SET;
00427     kd->signatureState = s;
00428     KMMsgBase::setSignatureState(s, idx); //base does more "stuff"
00429     mDirty = TRUE;
00430 }
00431 
00432 //-----------------------------------------------------------------------------
00433 void KMMsgInfo::setMDNSentState( const KMMsgMDNSentState s, int idx )
00434 {
00435     if (s == mdnSentState())
00436     return;
00437 
00438     if (!kd)
00439     kd = new KMMsgInfoPrivate;
00440     kd->modifiers |= KMMsgInfoPrivate::MDN_SET;
00441     kd->mdnSentState = s;
00442     KMMsgBase::setMDNSentState(s, idx); //base does more "stuff"
00443     mDirty = TRUE;
00444 }
00445 
00446 //-----------------------------------------------------------------------------
00447 KMMsgStatus KMMsgInfo::status(void) const
00448 {
00449     if (mStatus == KMMsgStatusUnknown) {
00450         KMMsgStatus st = (KMMsgStatus)getLongPart(MsgStatusPart);
00451         if (!st) {
00452             // We are opening an old index for the first time, get the legacy
00453             // status and merge it in.
00454             mLegacyStatus = (KMLegacyMsgStatus)getLongPart(MsgLegacyStatusPart);
00455             st = KMMsgStatusRead;
00456             switch (mLegacyStatus) {
00457                 case KMLegacyMsgStatusUnknown:
00458                     st = KMMsgStatusUnknown;
00459                     break;
00460                 case KMLegacyMsgStatusNew:
00461                     st = KMMsgStatusNew;
00462                     break;
00463                 case KMLegacyMsgStatusUnread:
00464                     st = KMMsgStatusUnread;
00465                     break;
00466                 case KMLegacyMsgStatusRead:
00467                     st = KMMsgStatusRead;
00468                     break;
00469                 case KMLegacyMsgStatusOld:
00470                     st = KMMsgStatusOld;
00471                     break;
00472                 case KMLegacyMsgStatusDeleted:
00473                     st |= KMMsgStatusDeleted;
00474                     break;
00475                 case KMLegacyMsgStatusReplied:
00476                     st |= KMMsgStatusReplied;
00477                     break;
00478                 case KMLegacyMsgStatusForwarded:
00479                     st |= KMMsgStatusForwarded;
00480                     break;
00481                 case KMLegacyMsgStatusQueued:
00482                     st |= KMMsgStatusQueued;
00483                     break;
00484                 case KMLegacyMsgStatusSent:
00485                     st |= KMMsgStatusSent;
00486                     break;
00487                 case KMLegacyMsgStatusFlag:
00488                     st |= KMMsgStatusFlag;
00489                     break;
00490                 default:
00491                     break;
00492             }
00493 
00494         }
00495         mStatus = st;
00496     }
00497     return mStatus;
00498 }
00499 
00500 
00501 //-----------------------------------------------------------------------------
00502 KMMsgEncryptionState KMMsgInfo::encryptionState() const
00503 {
00504     if (kd && kd->modifiers & KMMsgInfoPrivate::ENCRYPTION_SET)
00505       return kd->encryptionState;
00506     unsigned long encState = getLongPart(MsgCryptoStatePart) & 0x0000FFFF;
00507     return encState ? (KMMsgEncryptionState)encState : KMMsgEncryptionStateUnknown;
00508 }
00509 
00510 
00511 KMMsgSignatureState KMMsgInfo::signatureState() const
00512 {
00513     if (kd && kd->modifiers & KMMsgInfoPrivate::SIGNATURE_SET)
00514       return kd->signatureState;
00515     unsigned long sigState = getLongPart(MsgCryptoStatePart) >> 16;
00516     return sigState ? (KMMsgSignatureState)sigState : KMMsgSignatureStateUnknown;
00517 }
00518 
00519 KMMsgMDNSentState KMMsgInfo::mdnSentState() const {
00520     if (kd && kd->modifiers & KMMsgInfoPrivate::MDN_SET)
00521       return kd->mdnSentState;
00522     unsigned long mdnState = getLongPart(MsgMDNSentPart);
00523     return mdnState ? (KMMsgMDNSentState)mdnState : KMMsgMDNStateUnknown;
00524 }
00525 
00526 
00527 //-----------------------------------------------------------------------------
00528 off_t KMMsgInfo::folderOffset(void) const
00529 {
00530     if (kd && kd->modifiers & KMMsgInfoPrivate::OFFSET_SET)
00531     return kd->folderOffset;
00532     return getLongPart(MsgOffsetPart);
00533 }
00534 
00535 //-----------------------------------------------------------------------------
00536 size_t KMMsgInfo::msgSize(void) const
00537 {
00538     if (kd && kd->modifiers & KMMsgInfoPrivate::SIZE_SET)
00539     return kd->msgSize;
00540     return getLongPart(MsgSizePart);
00541 }
00542 
00543 //-----------------------------------------------------------------------------
00544 time_t KMMsgInfo::date(void) const
00545 {
00546     time_t res;
00547     if (kd && kd->modifiers & KMMsgInfoPrivate::DATE_SET)
00548       res = kd->date;
00549     else
00550       res = getLongPart(MsgDatePart);
00551     return res;
00552 }
00553 
00554 //-----------------------------------------------------------------------------
00555 size_t KMMsgInfo::msgSizeServer(void) const
00556 {
00557     if (kd && kd->modifiers & KMMsgInfoPrivate::SIZESERVER_SET)
00558       return kd->msgSizeServer;
00559     return getLongPart(MsgSizeServerPart);
00560 }
00561 
00562 //-----------------------------------------------------------------------------
00563 ulong KMMsgInfo::UID(void) const
00564 {
00565     if (kd && kd->modifiers & KMMsgInfoPrivate::UID_SET)
00566       return kd->UID;
00567     return getLongPart(MsgUIDPart);
00568 }
00569 
00570 //-----------------------------------------------------------------------------
00571 void KMMsgInfo::setMsgSize(size_t sz)
00572 {
00573     if (sz == msgSize())
00574     return;
00575 
00576     if(!kd)
00577     kd = new KMMsgInfoPrivate;
00578     kd->modifiers |= KMMsgInfoPrivate::SIZE_SET;
00579     kd->msgSize = sz;
00580     mDirty = TRUE;
00581 }
00582 
00583 //-----------------------------------------------------------------------------
00584 void KMMsgInfo::setMsgSizeServer(size_t sz)
00585 {
00586     if (sz == msgSizeServer())
00587       return;
00588 
00589     if(!kd)
00590       kd = new KMMsgInfoPrivate;
00591     kd->modifiers |= KMMsgInfoPrivate::SIZESERVER_SET;
00592     kd->msgSizeServer = sz;
00593     mDirty = TRUE;
00594 }
00595 
00596 //-----------------------------------------------------------------------------
00597 void KMMsgInfo::setUID(ulong uid)
00598 {
00599     if (uid == UID())
00600       return;
00601 
00602     if(!kd)
00603       kd = new KMMsgInfoPrivate;
00604     kd->modifiers |= KMMsgInfoPrivate::UID_SET;
00605     kd->UID = uid;
00606     mDirty = TRUE;
00607 }
00608 
00609 //-----------------------------------------------------------------------------
00610 void KMMsgInfo::setFolderOffset(off_t offs)
00611 {
00612     if (folderOffset() == offs)
00613     return;
00614 
00615     if (!kd)
00616     kd = new KMMsgInfoPrivate;
00617     kd->modifiers |= KMMsgInfoPrivate::OFFSET_SET;
00618     kd->folderOffset = offs;
00619     mDirty = TRUE;
00620 }
00621 
00622 //-----------------------------------------------------------------------------
00623 void KMMsgInfo::setFileName(const QString& file)
00624 {
00625     if (fileName() == file)
00626     return;
00627 
00628     if (!kd)
00629     kd = new KMMsgInfoPrivate;
00630     kd->modifiers |= KMMsgInfoPrivate::FILE_SET;
00631     kd->file = file;
00632     mDirty = TRUE;
00633 }
00634 
00635 //-----------------------------------------------------------------------------
00636 void KMMsgInfo::setStatus(const KMMsgStatus aStatus, int idx)
00637 {
00638     // ## this test is wrong since setStatus is also used to set one more bit, not just to set a complete status
00639     if(aStatus == status())
00640     return;
00641     KMMsgBase::setStatus(aStatus, idx); //base does more "stuff"
00642 }
00643 
00644 //-----------------------------------------------------------------------------
00645 void KMMsgInfo::setDate(time_t aUnixTime)
00646 {
00647     if(aUnixTime == date())
00648     return;
00649 
00650     if(!kd)
00651     kd = new KMMsgInfoPrivate;
00652     kd->modifiers |= KMMsgInfoPrivate::DATE_SET;
00653     kd->date = aUnixTime;
00654     mDirty = TRUE;
00655 }
00656 
00657 //--- For compatability with old index files
00658 void KMMsgInfo::compat_fromOldIndexString(const QCString& str, bool toUtf8)
00659 {
00660     char *start, *offset;
00661 
00662     if(!kd)
00663     kd = new KMMsgInfoPrivate;
00664     kd->modifiers = KMMsgInfoPrivate::ALL_SET;
00665     kd->xmark   = str.mid(33, 3).stripWhiteSpace();
00666     kd->folderOffset = str.mid(2,9).toULong();
00667     kd->msgSize = str.mid(12,9).toULong();
00668     kd->date = (time_t)str.mid(22,10).toULong();
00669     mStatus = (KMMsgStatus)str.at(0);
00670     if (toUtf8) {
00671     kd->subject = str.mid(37, 100).stripWhiteSpace();
00672     kd->from = str.mid(138, 50).stripWhiteSpace();
00673     kd->to = str.mid(189, 50).stripWhiteSpace();
00674     } else {
00675     start = offset = str.data() + 37;
00676     while (*start == ' ' && start - offset < 100) start++;
00677     kd->subject = QString::fromUtf8(str.mid(start - str.data(),
00678             100 - (start - offset)), 100 - (start - offset));
00679     start = offset = str.data() + 138;
00680     while (*start == ' ' && start - offset < 50) start++;
00681     kd->from = QString::fromUtf8(str.mid(start - str.data(),
00682             50 - (start - offset)), 50 - (start - offset));
00683     start = offset = str.data() + 189;
00684     while (*start == ' ' && start - offset < 50) start++;
00685     kd->to = QString::fromUtf8(str.mid(start - str.data(),
00686             50 - (start - offset)), 50 - (start - offset));
00687     }
00688     kd->replyToIdMD5 = str.mid(240, 22).stripWhiteSpace();
00689     kd->msgIdMD5 = str.mid(263, 22).stripWhiteSpace();
00690     mDirty = FALSE;
00691 }
00692 
00693 bool KMMsgInfo::dirty(void) const
00694 {
00695     if(KMMsgBase::dirty())
00696     return TRUE;
00697     return kd && kd->modifiers != KMMsgInfoPrivate::NONE_SET;
00698 }
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jan 31 15:55:05 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003