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