Backport r950340 | aacid | 2009-04-06 23:21:18 +0200 (Mon, 06 Apr 2009) | 4 lines
[kdepim.git] / kmail / kmmsginfo.cpp
bloba2481e76a4dbc4575bae317ff91b51de179e80d0
1 // kmmsginfo.cpp
4 #include "kmmsginfo.h"
5 #include "kmmessage.h"
6 #include "kmmessagetag.h"
7 //#include "kmmsgpart.h" // for encode
9 #include <stdlib.h>
10 #include <string.h>
11 #include <stdio.h>
12 #include <assert.h>
13 #include <mimelib/datetime.h>
14 #include <QByteArray>
16 /** The old status format, only one at a time possible. Needed
17 for upgrade path purposes. */
18 typedef enum
20 KMLegacyMsgStatusUnknown=' ',
21 KMLegacyMsgStatusNew='N',
22 KMLegacyMsgStatusUnread='U',
23 KMLegacyMsgStatusRead='R',
24 KMLegacyMsgStatusOld='O',
25 KMLegacyMsgStatusDeleted='D',
26 KMLegacyMsgStatusReplied='A',
27 KMLegacyMsgStatusForwarded='F',
28 KMLegacyMsgStatusQueued='Q',
29 KMLegacyMsgStatusSent='S',
30 KMLegacyMsgStatusFlag='G'
31 } KMLegacyMsgStatus;
34 class KMMsgInfo::KMMsgInfoPrivate
36 public:
37 enum {
38 SUBJECT_SET = 0x01, TO_SET = 0x02, REPLYTO_SET = 0x04, MSGID_SET=0x08,
39 DATE_SET = 0x10, OFFSET_SET = 0x20, SIZE_SET = 0x40, SIZESERVER_SET = 0x80,
40 XMARK_SET=0x100, FROM_SET=0x200, FILE_SET=0x400, ENCRYPTION_SET=0x800,
41 SIGNATURE_SET=0x1000, MDN_SET=0x2000, REPLYTOAUX_SET = 0x4000,
42 STRIPPEDSUBJECT_SET = 0x8000, UID_SET = 0x10000,
44 ALL_SET = 0xFFFFFF, NONE_SET = 0x000000
46 uint modifiers;
47 QString subject, from, to, replyToIdMD5, replyToAuxIdMD5,
48 strippedSubjectMD5, msgIdMD5, xmark, file;
49 off_t folderOffset;
50 size_t msgSize, msgSizeServer;
51 time_t date;
52 KMMsgEncryptionState encryptionState;
53 KMMsgSignatureState signatureState;
54 KMMsgMDNSentState mdnSentState;
55 ulong UID;
57 KMMsgInfoPrivate() : modifiers(NONE_SET) { }
58 KMMsgInfoPrivate& operator=(const KMMsgInfoPrivate& other) {
59 modifiers = NONE_SET;
60 if (other.modifiers & SUBJECT_SET) {
61 modifiers |= SUBJECT_SET;
62 subject = other.subject;
64 if (other.modifiers & STRIPPEDSUBJECT_SET) {
65 modifiers |= STRIPPEDSUBJECT_SET;
66 strippedSubjectMD5 = other.strippedSubjectMD5;
68 if (other.modifiers & FROM_SET) {
69 modifiers |= FROM_SET;
70 from = other.from;
72 if (other.modifiers & FILE_SET) {
73 modifiers |= FILE_SET;
74 file = other.from;
76 if (other.modifiers & TO_SET) {
77 modifiers |= TO_SET;
78 to = other.to;
80 if (other.modifiers & REPLYTO_SET) {
81 modifiers |= REPLYTO_SET;
82 replyToIdMD5 = other.replyToIdMD5;
84 if (other.modifiers & REPLYTOAUX_SET) {
85 modifiers |= REPLYTOAUX_SET;
86 replyToAuxIdMD5 = other.replyToAuxIdMD5;
89 if(other.modifiers & MSGID_SET) {
90 modifiers |= MSGID_SET;
91 msgIdMD5 = other.msgIdMD5;
93 if(other.modifiers & XMARK_SET) {
94 modifiers |= XMARK_SET;
95 xmark = other.xmark;
97 if(other.modifiers & OFFSET_SET) {
98 modifiers |= OFFSET_SET;
99 folderOffset = other.folderOffset;
101 if(other.modifiers & SIZE_SET) {
102 modifiers |= SIZE_SET;
103 msgSize = other.msgSize;
105 if(other.modifiers & DATE_SET) {
106 modifiers |= DATE_SET;
107 date = other.date;
109 if(other.modifiers & ENCRYPTION_SET) {
110 modifiers |= ENCRYPTION_SET;
111 encryptionState = other.encryptionState;
113 if(other.modifiers & SIGNATURE_SET) {
114 modifiers |= SIGNATURE_SET;
115 signatureState = other.signatureState;
117 if(other.modifiers & MDN_SET) {
118 modifiers |= MDN_SET;
119 mdnSentState = other.mdnSentState;
121 if(other.modifiers & SIZESERVER_SET) {
122 modifiers |= SIZESERVER_SET;
123 msgSizeServer = other.msgSizeServer;
125 if(other.modifiers & UID_SET) {
126 modifiers |= UID_SET;
127 UID = other.UID;
129 return *this;
133 //-----------------------------------------------------------------------------
134 #ifdef KMAIL_SQLITE_INDEX
135 KMMsgInfo::KMMsgInfo(KMFolder* p, char* data, short len, sqlite_int64 dbId) :
136 KMMsgBase(p, data, len, dbId),
137 #else
138 KMMsgInfo::KMMsgInfo(KMFolder* p, off_t off, short len) :
139 KMMsgBase(p, off, len),
140 #endif
141 kd(0)
143 setEnableUndo(true);
147 //-----------------------------------------------------------------------------
148 KMMsgInfo::~KMMsgInfo()
150 delete kd;
154 #if 0 // currently unused
155 //-----------------------------------------------------------------------------
156 KMMsgInfo& KMMsgInfo::operator=(const KMMsgInfo& other)
158 KMMsgBase::assign(&other);
159 if(other.kd) {
160 if(!kd)
161 kd = new KMMsgInfoPrivate;
162 *kd = *other.kd;
163 } else {
164 delete kd;
165 kd = 0;
167 mStatus = other.status();
168 return *this;
170 #endif
172 //-----------------------------------------------------------------------------
173 KMMsgInfo& KMMsgInfo::operator=(const KMMessage& msg)
175 KMMsgBase::assign(&msg.toMsgBase());
176 if(!kd)
177 kd = new KMMsgInfoPrivate;
178 kd->modifiers = KMMsgInfoPrivate::ALL_SET;
179 kd->subject = msg.subject();
180 kd->from = msg.fromStrip();
181 kd->to = msg.toStrip();
182 kd->replyToIdMD5 = msg.replyToIdMD5();
183 kd->replyToAuxIdMD5 = msg.replyToAuxIdMD5();
184 kd->strippedSubjectMD5 = msg.strippedSubjectMD5();
185 kd->msgIdMD5 = msg.msgIdMD5();
186 kd->xmark = msg.xmark();
187 mStatus = msg.messageStatus();
188 kd->folderOffset = msg.folderOffset();
189 kd->msgSize = msg.msgSize();
190 kd->date = msg.date();
191 kd->file = msg.fileName();
192 kd->encryptionState = msg.encryptionState();
193 kd->signatureState = msg.signatureState();
194 kd->mdnSentState = msg.mdnSentState();
195 kd->msgSizeServer = msg.msgSizeServer();
196 kd->UID = msg.UID();
197 if ( msg.tagList() ) {
198 if ( !mTagList )
199 mTagList = new KMMessageTagList();
200 *mTagList = *msg.tagList();
201 } else {
202 delete mTagList;
203 mTagList = 0;
205 return *this;
208 //-----------------------------------------------------------------------------
209 void KMMsgInfo::init(const QByteArray& aSubject, const QByteArray& aFrom,
210 const QByteArray& aTo, time_t aDate,
211 const MessageStatus& aStatus, const QByteArray& aXMark,
212 const QByteArray& replyToId, const QByteArray& replyToAuxId,
213 const QByteArray& msgId,
214 KMMsgEncryptionState encryptionState,
215 KMMsgSignatureState signatureState,
216 KMMsgMDNSentState mdnSentState,
217 const QByteArray& prefCharset,
218 off_t aFolderOffset, size_t aMsgSize,
219 size_t aMsgSizeServer, ulong aUID)
221 #ifdef KMAIL_SQLITE_INDEX
222 mData = 0;
223 #else
224 mIndexOffset = 0;
225 #endif
226 mIndexLength = 0;
227 if(!kd)
228 kd = new KMMsgInfoPrivate;
229 kd->modifiers = KMMsgInfoPrivate::ALL_SET;
230 kd->subject = decodeRFC2047String( aSubject, prefCharset );
231 kd->from = decodeRFC2047String( KMMessage::stripEmailAddr( aFrom ),
232 prefCharset );
233 kd->to = decodeRFC2047String( KMMessage::stripEmailAddr( aTo ),
234 prefCharset );
235 kd->replyToIdMD5 = base64EncodedMD5( replyToId );
236 kd->replyToAuxIdMD5 = base64EncodedMD5( replyToAuxId );
237 kd->strippedSubjectMD5 = base64EncodedMD5( KMMessage::stripOffPrefixes( kd->subject ), true /*utf8*/ );
238 kd->msgIdMD5 = base64EncodedMD5( msgId );
239 kd->xmark = aXMark;
240 kd->folderOffset = aFolderOffset;
241 mStatus = aStatus;
242 kd->msgSize = aMsgSize;
243 kd->date = aDate;
244 kd->file = "";
245 kd->encryptionState = encryptionState;
246 kd->signatureState = signatureState;
247 kd->mdnSentState = mdnSentState;
248 kd->msgSizeServer = aMsgSizeServer;
249 kd->UID = aUID;
250 mDirty = false;
253 void KMMsgInfo::init(const QByteArray& aSubject, const QByteArray& aFrom,
254 const QByteArray& aTo, time_t aDate,
255 const MessageStatus& aStatus, const QByteArray& aXMark,
256 const QByteArray& replyToId, const QByteArray& replyToAuxId,
257 const QByteArray& msgId,
258 const QByteArray& aFileName,
259 KMMsgEncryptionState encryptionState,
260 KMMsgSignatureState signatureState,
261 KMMsgMDNSentState mdnSentState,
262 const QByteArray &prefCharset,
263 size_t aMsgSize,
264 size_t aMsgSizeServer, ulong aUID)
266 // use the "normal" init for most stuff
267 init( aSubject, aFrom, aTo, aDate, aStatus, aXMark, replyToId, replyToAuxId,
268 msgId, encryptionState, signatureState, mdnSentState, prefCharset,
269 (unsigned long)0, aMsgSize, aMsgSizeServer, aUID );
270 kd->file = aFileName;
274 //-----------------------------------------------------------------------------
275 QString KMMsgInfo::subject(void) const
277 if (kd && kd->modifiers & KMMsgInfoPrivate::SUBJECT_SET)
278 return kd->subject;
279 return getStringPart(MsgSubjectPart);
283 //-----------------------------------------------------------------------------
284 QString KMMsgInfo::fromStrip(void) const
286 if (kd && kd->modifiers & KMMsgInfoPrivate::FROM_SET)
287 return kd->from;
288 return getStringPart(MsgFromPart);
291 //-----------------------------------------------------------------------------
292 QString KMMsgInfo::fileName(void) const
294 if (kd && kd->modifiers & KMMsgInfoPrivate::FILE_SET)
295 return kd->file;
296 return getStringPart(MsgFilePart);
299 //-----------------------------------------------------------------------------
300 QString KMMsgInfo::tagString( void ) const
302 return tagList()->join( "," );
304 KMMessageTagList* KMMsgInfo::tagList( void ) const
306 if (mTagList)
307 return mTagList;
308 mTagList = new KMMessageTagList( KMMessageTagList::split( ",",
309 getStringPart( MsgTagPart ) ) );
310 mTagList->prioritySort();
311 return mTagList;
314 //-----------------------------------------------------------------------------
315 QString KMMsgInfo::toStrip(void) const
317 if (kd && kd->modifiers & KMMsgInfoPrivate::TO_SET)
318 return kd->to;
319 return getStringPart(MsgToPart);
322 //-----------------------------------------------------------------------------
323 QString KMMsgInfo::xmark(void) const
325 if (kd && kd->modifiers & KMMsgInfoPrivate::XMARK_SET)
326 return kd->xmark;
327 return getStringPart(MsgXMarkPart);
331 //-----------------------------------------------------------------------------
332 QString KMMsgInfo::replyToIdMD5(void) const
334 if (kd && kd->modifiers & KMMsgInfoPrivate::REPLYTO_SET)
335 return kd->replyToIdMD5;
336 return getStringPart(MsgReplyToIdMD5Part);
339 //-----------------------------------------------------------------------------
340 QString KMMsgInfo::replyToAuxIdMD5() const
342 if( kd && kd->modifiers & KMMsgInfoPrivate::REPLYTOAUX_SET )
343 return kd->replyToAuxIdMD5;
344 return getStringPart( MsgReplyToAuxIdMD5Part );
347 //-----------------------------------------------------------------------------
348 QString KMMsgInfo::strippedSubjectMD5() const
350 if( kd && kd->modifiers & KMMsgInfoPrivate::STRIPPEDSUBJECT_SET )
351 return kd->strippedSubjectMD5;
352 return getStringPart( MsgStrippedSubjectMD5Part );
356 //-----------------------------------------------------------------------------
357 bool KMMsgInfo::subjectIsPrefixed() const
359 return strippedSubjectMD5() != base64EncodedMD5( subject().trimmed(), true /*utf8*/ );
362 //-----------------------------------------------------------------------------
363 QString KMMsgInfo::msgIdMD5(void) const
365 if (kd && kd->modifiers & KMMsgInfoPrivate::MSGID_SET)
366 return kd->msgIdMD5;
367 return getStringPart(MsgIdMD5Part);
371 //-----------------------------------------------------------------------------
372 void KMMsgInfo::setSubject(const QString& aSubject)
374 if(aSubject == subject())
375 return;
377 if (!kd)
378 kd = new KMMsgInfoPrivate;
379 kd->modifiers |= KMMsgInfoPrivate::SUBJECT_SET;
380 kd->subject = aSubject;
381 mDirty = true;
385 //-----------------------------------------------------------------------------
386 void KMMsgInfo::setXMark(const QString& aXMark)
388 if (aXMark == xmark())
389 return;
391 if (!kd)
392 kd = new KMMsgInfoPrivate;
393 kd->modifiers |= KMMsgInfoPrivate::XMARK_SET;
394 kd->xmark = aXMark;
395 mDirty = true;
399 //-----------------------------------------------------------------------------
400 void KMMsgInfo::setReplyToIdMD5(const QString& aReplyToIdMD5)
402 if (aReplyToIdMD5 == replyToIdMD5())
403 return;
405 if (!kd)
406 kd = new KMMsgInfoPrivate;
407 kd->modifiers |= KMMsgInfoPrivate::REPLYTO_SET;
408 kd->replyToIdMD5 = aReplyToIdMD5;
409 mDirty = true;
413 //-----------------------------------------------------------------------------
414 void KMMsgInfo::setReplyToAuxIdMD5( const QString& aReplyToAuxIdMD5 )
416 if( aReplyToAuxIdMD5 == replyToAuxIdMD5() )
417 return;
419 if( !kd )
420 kd = new KMMsgInfoPrivate;
421 kd->modifiers |= KMMsgInfoPrivate::REPLYTOAUX_SET;
422 kd->replyToAuxIdMD5 = aReplyToAuxIdMD5;
423 mDirty = true;
427 //-----------------------------------------------------------------------------
428 void KMMsgInfo::initStrippedSubjectMD5()
430 if( kd && kd->modifiers & KMMsgInfoPrivate::STRIPPEDSUBJECT_SET )
431 return;
432 QString rawSubject = KMMessage::stripOffPrefixes( subject() );
433 QString subjectMD5 = base64EncodedMD5( rawSubject, true /*utf8*/ );
434 if( !kd )
435 kd = new KMMsgInfoPrivate;
436 kd->modifiers |= KMMsgInfoPrivate::STRIPPEDSUBJECT_SET;
437 kd->strippedSubjectMD5 = subjectMD5;
438 mDirty = true;
442 //-----------------------------------------------------------------------------
443 void KMMsgInfo::setMsgIdMD5(const QString& aMsgIdMD5)
445 if (aMsgIdMD5 == msgIdMD5())
446 return;
448 if (!kd)
449 kd = new KMMsgInfoPrivate;
450 kd->modifiers |= KMMsgInfoPrivate::MSGID_SET;
451 kd->msgIdMD5 = aMsgIdMD5;
452 mDirty = true;
455 //-----------------------------------------------------------------------------
456 void KMMsgInfo::setEncryptionState( const KMMsgEncryptionState s, int idx )
458 if (s == encryptionState())
459 return;
461 if (!kd)
462 kd = new KMMsgInfoPrivate;
463 kd->modifiers |= KMMsgInfoPrivate::ENCRYPTION_SET;
464 kd->encryptionState = s;
465 KMMsgBase::setEncryptionState(s, idx); //base does more "stuff"
466 mDirty = true;
469 //-----------------------------------------------------------------------------
470 void KMMsgInfo::setSignatureState( const KMMsgSignatureState s, int idx )
472 if (s == signatureState())
473 return;
475 if (!kd)
476 kd = new KMMsgInfoPrivate;
477 kd->modifiers |= KMMsgInfoPrivate::SIGNATURE_SET;
478 kd->signatureState = s;
479 KMMsgBase::setSignatureState(s, idx); //base does more "stuff"
480 mDirty = true;
483 //-----------------------------------------------------------------------------
484 void KMMsgInfo::setMDNSentState( const KMMsgMDNSentState s, int idx )
486 if (s == mdnSentState())
487 return;
489 if (!kd)
490 kd = new KMMsgInfoPrivate;
491 kd->modifiers |= KMMsgInfoPrivate::MDN_SET;
492 kd->mdnSentState = s;
493 KMMsgBase::setMDNSentState(s, idx); //base does more "stuff"
494 mDirty = true;
497 //-----------------------------------------------------------------------------
498 MessageStatus& KMMsgInfo::status() const
500 if ( mStatus.isOfUnknownStatus() ) {
501 mStatus.fromQInt32( getLongPart( MsgStatusPart ) );
502 if ( mStatus.isOfUnknownStatus() ) {
503 // We are opening an old index for the first time, get the legacy
504 // status and merge it in.
505 // This is kept to provide an upgrade path from the old single
506 // status to the new multiple status scheme.
507 KMLegacyMsgStatus legacyMsgStatus = (KMLegacyMsgStatus)getLongPart(MsgLegacyStatusPart);
508 mStatus.setRead();
509 switch (legacyMsgStatus) {
510 case KMLegacyMsgStatusUnknown:
511 mStatus.clear();
512 break;
513 case KMLegacyMsgStatusNew:
514 mStatus.setNew();
515 break;
516 case KMLegacyMsgStatusUnread:
517 mStatus.setUnread();
518 break;
519 case KMLegacyMsgStatusRead:
520 mStatus.setRead();
521 break;
522 case KMLegacyMsgStatusOld:
523 mStatus.setOld();
524 break;
525 case KMLegacyMsgStatusDeleted:
526 mStatus.setDeleted();
527 break;
528 case KMLegacyMsgStatusReplied:
529 mStatus.setReplied();
530 break;
531 case KMLegacyMsgStatusForwarded:
532 mStatus.setForwarded();
533 break;
534 case KMLegacyMsgStatusQueued:
535 mStatus.setQueued();
536 break;
537 case KMLegacyMsgStatusSent:
538 mStatus.setSent();
539 break;
540 case KMLegacyMsgStatusFlag:
541 mStatus.setImportant();
542 break;
543 default:
544 break;
549 return mStatus;
553 //-----------------------------------------------------------------------------
554 KMMsgEncryptionState KMMsgInfo::encryptionState() const
556 if (kd && kd->modifiers & KMMsgInfoPrivate::ENCRYPTION_SET)
557 return kd->encryptionState;
558 unsigned long encState = getLongPart(MsgCryptoStatePart) & 0x0000FFFF;
559 return encState ? (KMMsgEncryptionState)encState : KMMsgEncryptionStateUnknown;
563 KMMsgSignatureState KMMsgInfo::signatureState() const
565 if (kd && kd->modifiers & KMMsgInfoPrivate::SIGNATURE_SET)
566 return kd->signatureState;
567 unsigned long sigState = getLongPart(MsgCryptoStatePart) >> 16;
568 return sigState ? (KMMsgSignatureState)sigState : KMMsgSignatureStateUnknown;
571 KMMsgMDNSentState KMMsgInfo::mdnSentState() const {
572 if (kd && kd->modifiers & KMMsgInfoPrivate::MDN_SET)
573 return kd->mdnSentState;
574 unsigned long mdnState = getLongPart(MsgMDNSentPart);
575 return mdnState ? (KMMsgMDNSentState)mdnState : KMMsgMDNStateUnknown;
579 //-----------------------------------------------------------------------------
580 off_t KMMsgInfo::folderOffset(void) const
582 if (kd && kd->modifiers & KMMsgInfoPrivate::OFFSET_SET)
583 return kd->folderOffset;
584 return getLongPart(MsgOffsetPart);
587 //-----------------------------------------------------------------------------
588 size_t KMMsgInfo::msgSize(void) const
590 if (kd && kd->modifiers & KMMsgInfoPrivate::SIZE_SET)
591 return kd->msgSize;
592 return getLongPart(MsgSizePart);
595 //-----------------------------------------------------------------------------
596 time_t KMMsgInfo::date(void) const
598 time_t res;
599 if (kd && kd->modifiers & KMMsgInfoPrivate::DATE_SET)
600 res = kd->date;
601 else
602 res = getLongPart(MsgDatePart);
603 return res;
606 //-----------------------------------------------------------------------------
607 size_t KMMsgInfo::msgSizeServer(void) const
609 if (kd && kd->modifiers & KMMsgInfoPrivate::SIZESERVER_SET)
610 return kd->msgSizeServer;
611 return getLongPart(MsgSizeServerPart);
614 //-----------------------------------------------------------------------------
615 ulong KMMsgInfo::UID(void) const
617 if (kd && kd->modifiers & KMMsgInfoPrivate::UID_SET)
618 return kd->UID;
619 return getLongPart(MsgUIDPart);
622 //-----------------------------------------------------------------------------
623 void KMMsgInfo::setMsgSize(size_t sz)
625 if (sz == msgSize())
626 return;
628 if(!kd)
629 kd = new KMMsgInfoPrivate;
630 kd->modifiers |= KMMsgInfoPrivate::SIZE_SET;
631 kd->msgSize = sz;
632 mDirty = true;
635 //-----------------------------------------------------------------------------
636 void KMMsgInfo::setMsgSizeServer(size_t sz)
638 if (sz == msgSizeServer())
639 return;
641 if(!kd)
642 kd = new KMMsgInfoPrivate;
643 kd->modifiers |= KMMsgInfoPrivate::SIZESERVER_SET;
644 kd->msgSizeServer = sz;
645 mDirty = true;
648 //-----------------------------------------------------------------------------
649 void KMMsgInfo::setUID(ulong uid)
651 if (uid == UID())
652 return;
654 if(!kd)
655 kd = new KMMsgInfoPrivate;
656 kd->modifiers |= KMMsgInfoPrivate::UID_SET;
657 kd->UID = uid;
658 mDirty = true;
661 //-----------------------------------------------------------------------------
662 void KMMsgInfo::setFolderOffset(off_t offs)
664 if (folderOffset() == offs)
665 return;
667 if (!kd)
668 kd = new KMMsgInfoPrivate;
669 kd->modifiers |= KMMsgInfoPrivate::OFFSET_SET;
670 kd->folderOffset = offs;
671 mDirty = true;
674 //-----------------------------------------------------------------------------
675 void KMMsgInfo::setFileName(const QString& file)
677 if (fileName() == file)
678 return;
680 if (!kd)
681 kd = new KMMsgInfoPrivate;
682 kd->modifiers |= KMMsgInfoPrivate::FILE_SET;
683 kd->file = file;
684 mDirty = true;
687 //-----------------------------------------------------------------------------
688 void KMMsgInfo::setStatus(const MessageStatus& aStatus, int idx)
690 if( aStatus == mStatus )
691 return;
692 KMMsgBase::setStatus( aStatus, idx ); //base does more "stuff"
695 //-----------------------------------------------------------------------------
696 void KMMsgInfo::setDate(time_t aUnixTime)
698 if(aUnixTime == date())
699 return;
701 if(!kd)
702 kd = new KMMsgInfoPrivate;
703 kd->modifiers |= KMMsgInfoPrivate::DATE_SET;
704 kd->date = aUnixTime;
705 mDirty = true;
708 //--- For compatibility with old index files
709 void KMMsgInfo::compat_fromOldIndexString(const QByteArray& str, bool toUtf8)
711 const char *start, *offset;
713 if(!kd)
714 kd = new KMMsgInfoPrivate;
715 kd->modifiers = KMMsgInfoPrivate::ALL_SET;
716 kd->xmark = str.mid(33, 3).trimmed();
717 kd->folderOffset = str.mid(2,9).toULong();
718 kd->msgSize = str.mid(12,9).toULong();
719 kd->date = (time_t)str.mid(22,10).toULong();
720 mStatus.setStatusFromStr( str );
721 if (toUtf8) {
722 kd->subject = str.mid(37, 100).trimmed();
723 kd->from = str.mid(138, 50).trimmed();
724 kd->to = str.mid(189, 50).trimmed();
725 } else {
726 start = offset = str.data() + 37;
727 while (*start == ' ' && start - offset < 100) start++;
728 kd->subject = QString::fromUtf8(str.mid(start - str.data(),
729 100 - (start - offset)), 100 - (start - offset));
730 start = offset = str.data() + 138;
731 while (*start == ' ' && start - offset < 50) start++;
732 kd->from = QString::fromUtf8(str.mid(start - str.data(),
733 50 - (start - offset)), 50 - (start - offset));
734 start = offset = str.data() + 189;
735 while (*start == ' ' && start - offset < 50) start++;
736 kd->to = QString::fromUtf8(str.mid(start - str.data(),
737 50 - (start - offset)), 50 - (start - offset));
739 kd->replyToIdMD5 = str.mid(240, 22).trimmed();
740 kd->msgIdMD5 = str.mid(263, 22).trimmed();
741 mDirty = false;
744 bool KMMsgInfo::dirty(void) const
746 if( KMMsgBase::dirty() )
747 return true;
748 return kd && kd->modifiers != KMMsgInfoPrivate::NONE_SET;