kmail

kmmsginfo.cpp
1 // kmmsginfo.cpp
2 
3 #ifdef HAVE_CONFIG_H
4 #include <config.h>
5 #endif
6 
7 #include "kmmsginfo.h"
8 #include "kmmessage.h"
9 //#include "kmmsgpart.h" // for encode
10 
11 #include <stdlib.h>
12 #include <string.h>
13 #include <stdio.h>
14 #include <assert.h>
15 #include <mimelib/datetime.h>
16 
17 class KMMsgInfo::KMMsgInfoPrivate
18 {
19 public:
20  enum {
21  SUBJECT_SET = 0x01, TOSTRIP_SET = 0x02, REPLYTO_SET = 0x04, MSGID_SET=0x08,
22  DATE_SET = 0x10, OFFSET_SET = 0x20, SIZE_SET = 0x40, SIZESERVER_SET = 0x80,
23  XMARK_SET=0x100, FROMSTRIP_SET=0x200, FILE_SET=0x400, ENCRYPTION_SET=0x800,
24  SIGNATURE_SET=0x1000, MDN_SET=0x2000, REPLYTOAUX_SET = 0x4000,
25  STRIPPEDSUBJECT_SET = 0x8000, UID_SET = 0x10000,
26  TO_SET = 0x20000, FROM_SET = 0x40000,
27 
28  ALL_SET = 0xFFFFFF, NONE_SET = 0x000000
29  };
30  uint modifiers;
31  TQString subject, fromStrip, toStrip, replyToIdMD5, replyToAuxIdMD5,
32  strippedSubjectMD5, msgIdMD5, xmark, file;
33  off_t folderOffset;
34  size_t msgSize, msgSizeServer;
35  time_t date;
36  KMMsgEncryptionState encryptionState;
37  KMMsgSignatureState signatureState;
38  KMMsgMDNSentState mdnSentState;
39  ulong UID;
40  TQString to, from;
41 
42  KMMsgInfoPrivate() : modifiers(NONE_SET) { }
43  KMMsgInfoPrivate& operator=(const KMMsgInfoPrivate& other) {
44  modifiers = NONE_SET;
45  if (other.modifiers & SUBJECT_SET) {
46  modifiers |= SUBJECT_SET;
47  subject = other.subject;
48  }
49  if (other.modifiers & STRIPPEDSUBJECT_SET) {
50  modifiers |= STRIPPEDSUBJECT_SET;
51  strippedSubjectMD5 = other.strippedSubjectMD5;
52  }
53  if (other.modifiers & FROMSTRIP_SET) {
54  modifiers |= FROMSTRIP_SET;
55  fromStrip = other.fromStrip;
56  }
57  if (other.modifiers & FILE_SET) {
58  modifiers |= FILE_SET;
59  file = other.file;
60  }
61  if (other.modifiers & TOSTRIP_SET) {
62  modifiers |= TOSTRIP_SET;
63  toStrip = other.toStrip;
64  }
65  if (other.modifiers & REPLYTO_SET) {
66  modifiers |= REPLYTO_SET;
67  replyToIdMD5 = other.replyToIdMD5;
68  }
69  if (other.modifiers & REPLYTOAUX_SET) {
70  modifiers |= REPLYTOAUX_SET;
71  replyToAuxIdMD5 = other.replyToAuxIdMD5;
72  }
73 
74  if(other.modifiers & MSGID_SET) {
75  modifiers |= MSGID_SET;
76  msgIdMD5 = other.msgIdMD5;
77  }
78  if(other.modifiers & XMARK_SET) {
79  modifiers |= XMARK_SET;
80  xmark = other.xmark;
81  }
82  if(other.modifiers & OFFSET_SET) {
83  modifiers |= OFFSET_SET;
84  folderOffset = other.folderOffset;
85  }
86  if(other.modifiers & SIZE_SET) {
87  modifiers |= SIZE_SET;
88  msgSize = other.msgSize;
89  }
90  if(other.modifiers & DATE_SET) {
91  modifiers |= DATE_SET;
92  date = other.date;
93  }
94  if(other.modifiers & ENCRYPTION_SET) {
95  modifiers |= ENCRYPTION_SET;
96  encryptionState = other.encryptionState;
97  }
98  if(other.modifiers & SIGNATURE_SET) {
99  modifiers |= SIGNATURE_SET;
100  signatureState = other.signatureState;
101  }
102  if(other.modifiers & MDN_SET) {
103  modifiers |= MDN_SET;
104  mdnSentState = other.mdnSentState;
105  }
106  if(other.modifiers & SIZESERVER_SET) {
107  modifiers |= SIZESERVER_SET;
108  msgSizeServer = other.msgSizeServer;
109  }
110  if(other.modifiers & UID_SET) {
111  modifiers |= UID_SET;
112  UID = other.UID;
113  }
114  if (other.modifiers & TO_SET) {
115  modifiers |= TO_SET;
116  to = other.to;
117  }
118  if (other.modifiers & FROM_SET) {
119  modifiers |= FROM_SET;
120  from = other.from;
121  }
122  return *this;
123  }
124 };
125 
126 //-----------------------------------------------------------------------------
127 KMMsgInfo::KMMsgInfo(KMFolder* p, off_t off, short len) :
128  KMMsgBase(p),
129  kd(0)
130 {
131  setIndexOffset(off);
132  setIndexLength(len);
133  setEnableUndo(true);
134 }
135 
136 
137 //-----------------------------------------------------------------------------
138 KMMsgInfo::~KMMsgInfo()
139 {
140  delete kd;
141 }
142 
143 
144 #if 0 // currently unused
145 //-----------------------------------------------------------------------------
146 KMMsgInfo& KMMsgInfo::operator=(const KMMsgInfo& other)
147 {
148  KMMsgBase::assign(&other);
149  if(other.kd) {
150  if(!kd)
151  kd = new KMMsgInfoPrivate;
152  *kd = *other.kd;
153  } else {
154  delete kd;
155  kd = 0;
156  }
157  mStatus = other.status();
158  return *this;
159 }
160 #endif
161 
162 //-----------------------------------------------------------------------------
163 KMMsgInfo& KMMsgInfo::operator=(const KMMessage& msg)
164 {
165  KMMsgBase::assign(&msg.toMsgBase());
166  if(!kd)
167  kd = new KMMsgInfoPrivate;
168  kd->modifiers = KMMsgInfoPrivate::ALL_SET;
169  kd->subject = msg.subject();
170  kd->fromStrip = msg.fromStrip();
171  kd->toStrip = msg.toStrip();
172  kd->replyToIdMD5 = msg.replyToIdMD5();
173  kd->replyToAuxIdMD5 = msg.replyToAuxIdMD5();
174  kd->strippedSubjectMD5 = msg.strippedSubjectMD5();
175  kd->msgIdMD5 = msg.msgIdMD5();
176  kd->xmark = msg.xmark();
177  mStatus = msg.status();
178  kd->folderOffset = msg.folderOffset();
179  kd->msgSize = msg.msgSize();
180  kd->date = msg.date();
181  kd->file = msg.fileName();
182  kd->encryptionState = msg.encryptionState();
183  kd->signatureState = msg.signatureState();
184  kd->mdnSentState = msg.mdnSentState();
185  kd->msgSizeServer = msg.msgSizeServer();
186  kd->UID = msg.UID();
187  kd->to = msg.to();
188  kd->from = msg.from();
189  return *this;
190 }
191 
192 //-----------------------------------------------------------------------------
193 void KMMsgInfo::init(const TQCString& aSubject, const TQCString& aFrom,
194  const TQCString& aTo, time_t aDate,
195  KMMsgStatus aStatus, const TQCString& aXMark,
196  const TQCString& replyToId, const TQCString& replyToAuxId,
197  const TQCString& msgId,
198  KMMsgEncryptionState encryptionState,
199  KMMsgSignatureState signatureState,
200  KMMsgMDNSentState mdnSentState,
201  const TQCString& prefCharset,
202  off_t aFolderOffset, size_t aMsgSize,
203  size_t aMsgSizeServer, ulong aUID)
204 {
205  mIndexOffset = 0;
206  mIndexLength = 0;
207  if(!kd)
208  kd = new KMMsgInfoPrivate;
209  kd->modifiers = KMMsgInfoPrivate::ALL_SET;
210  kd->subject = decodeRFC2047String(aSubject, prefCharset);
211  kd->fromStrip = decodeRFC2047String( KMMessage::stripEmailAddr( aFrom ), prefCharset );
212  kd->toStrip = decodeRFC2047String( KMMessage::stripEmailAddr( aTo ), prefCharset );
213  kd->replyToIdMD5 = base64EncodedMD5( replyToId );
214  kd->replyToAuxIdMD5 = base64EncodedMD5( replyToAuxId );
215  kd->strippedSubjectMD5 = base64EncodedMD5( KMMessage::stripOffPrefixes( kd->subject ), true /*utf8*/ );
216  kd->msgIdMD5 = base64EncodedMD5( msgId );
217  kd->xmark = aXMark;
218  kd->folderOffset = aFolderOffset;
219  mStatus = aStatus;
220  kd->msgSize = aMsgSize;
221  kd->date = aDate;
222  kd->file = "";
223  kd->encryptionState = encryptionState;
224  kd->signatureState = signatureState;
225  kd->mdnSentState = mdnSentState;
226  kd->msgSizeServer = aMsgSizeServer;
227  kd->UID = aUID;
228  kd->to = aTo;
229  kd->from = aFrom;
230  mDirty = false;
231 }
232 
233 void KMMsgInfo::init(const TQCString& aSubject, const TQCString& aFrom,
234  const TQCString& aTo, time_t aDate,
235  KMMsgStatus aStatus, const TQCString& aXMark,
236  const TQCString& replyToId, const TQCString& replyToAuxId,
237  const TQCString& msgId,
238  const TQCString& aFileName,
239  KMMsgEncryptionState encryptionState,
240  KMMsgSignatureState signatureState,
241  KMMsgMDNSentState mdnSentState,
242  const TQCString& prefCharset,
243  size_t aMsgSize,
244  size_t aMsgSizeServer, ulong aUID)
245 {
246  // use the "normal" init for most stuff
247  init( aSubject, aFrom, aTo, aDate, aStatus, aXMark, replyToId, replyToAuxId,
248  msgId, encryptionState, signatureState, mdnSentState, prefCharset,
249  (unsigned long)0, aMsgSize, aMsgSizeServer, aUID );
250  kd->file = aFileName;
251 }
252 
253 
254 //-----------------------------------------------------------------------------
255 TQString KMMsgInfo::subject(void) const
256 {
257  if (kd && kd->modifiers & KMMsgInfoPrivate::SUBJECT_SET)
258  return kd->subject;
259  return getStringPart(MsgSubjectPart);
260 }
261 
262 //-----------------------------------------------------------------------------
263 TQString KMMsgInfo::fromStrip(void) const
264 {
265  if (kd && kd->modifiers & KMMsgInfoPrivate::FROMSTRIP_SET)
266  return kd->fromStrip;
267  return getStringPart(MsgFromStripPart);
268 }
269 
270 //-----------------------------------------------------------------------------
271 TQString KMMsgInfo::from() const
272 {
273  if (kd && kd->modifiers & KMMsgInfoPrivate::FROM_SET)
274  return kd->from;
275  return getStringPart( MsgFromPart );
276 }
277 
278 
279 //-----------------------------------------------------------------------------
280 TQString KMMsgInfo::fileName(void) const
281 {
282  if (kd && kd->modifiers & KMMsgInfoPrivate::FILE_SET)
283  return kd->file;
284  return getStringPart(MsgFilePart);
285 }
286 
287 
288 //-----------------------------------------------------------------------------
289 TQString KMMsgInfo::toStrip(void) const
290 {
291  if (kd && kd->modifiers & KMMsgInfoPrivate::TOSTRIP_SET)
292  return kd->toStrip;
293  return getStringPart(MsgToStripPart);
294 }
295 
296 //-----------------------------------------------------------------------------
297 TQString KMMsgInfo::to() const
298 {
299  if (kd && kd->modifiers & KMMsgInfoPrivate::TO_SET)
300  return kd->to;
301  return getStringPart( MsgToPart );
302 }
303 
304 //-----------------------------------------------------------------------------
305 TQString KMMsgInfo::xmark(void) const
306 {
307  if (kd && kd->modifiers & KMMsgInfoPrivate::XMARK_SET)
308  return kd->xmark;
309  return getStringPart(MsgXMarkPart);
310 }
311 
312 
313 //-----------------------------------------------------------------------------
314 TQString KMMsgInfo::replyToIdMD5(void) const
315 {
316  if (kd && kd->modifiers & KMMsgInfoPrivate::REPLYTO_SET)
317  return kd->replyToIdMD5;
318  return getStringPart(MsgReplyToIdMD5Part);
319 }
320 
321 //-----------------------------------------------------------------------------
322 TQString KMMsgInfo::replyToAuxIdMD5() const
323 {
324  if( kd && kd->modifiers & KMMsgInfoPrivate::REPLYTOAUX_SET )
325  return kd->replyToAuxIdMD5;
326  return getStringPart( MsgReplyToAuxIdMD5Part );
327 }
328 
329 //-----------------------------------------------------------------------------
330 TQString KMMsgInfo::strippedSubjectMD5() const
331 {
332  if( kd && kd->modifiers & KMMsgInfoPrivate::STRIPPEDSUBJECT_SET )
333  return kd->strippedSubjectMD5;
334  return getStringPart( MsgStrippedSubjectMD5Part );
335 }
336 
337 
338 //-----------------------------------------------------------------------------
339 bool KMMsgInfo::subjectIsPrefixed() const
340 {
341  return strippedSubjectMD5() != base64EncodedMD5( subject().stripWhiteSpace(), true /*utf8*/ );
342 }
343 
344 //-----------------------------------------------------------------------------
345 TQString KMMsgInfo::msgIdMD5(void) const
346 {
347  if (kd && kd->modifiers & KMMsgInfoPrivate::MSGID_SET)
348  return kd->msgIdMD5;
349  return getStringPart(MsgIdMD5Part);
350 }
351 
352 
353 //-----------------------------------------------------------------------------
354 void KMMsgInfo::setSubject(const TQString& aSubject)
355 {
356  if(aSubject == subject())
357  return;
358 
359  if (!kd)
360  kd = new KMMsgInfoPrivate;
361  kd->modifiers |= KMMsgInfoPrivate::SUBJECT_SET;
362  kd->subject = aSubject;
363  mDirty = true;
364 }
365 
366 
367 //-----------------------------------------------------------------------------
368 void KMMsgInfo::setXMark(const TQString& aXMark)
369 {
370  if (aXMark == xmark())
371  return;
372 
373  if (!kd)
374  kd = new KMMsgInfoPrivate;
375  kd->modifiers |= KMMsgInfoPrivate::XMARK_SET;
376  kd->xmark = aXMark;
377  mDirty = true;
378 }
379 
380 
381 //-----------------------------------------------------------------------------
382 void KMMsgInfo::setReplyToIdMD5(const TQString& aReplyToIdMD5)
383 {
384  if (aReplyToIdMD5 == replyToIdMD5())
385  return;
386 
387  if (!kd)
388  kd = new KMMsgInfoPrivate;
389  kd->modifiers |= KMMsgInfoPrivate::REPLYTO_SET;
390  kd->replyToIdMD5 = aReplyToIdMD5;
391  mDirty = true;
392 }
393 
394 
395 //-----------------------------------------------------------------------------
396 void KMMsgInfo::setReplyToAuxIdMD5( const TQString& aReplyToAuxIdMD5 )
397 {
398  if( aReplyToAuxIdMD5 == replyToAuxIdMD5() )
399  return;
400 
401  if( !kd )
402  kd = new KMMsgInfoPrivate;
403  kd->modifiers |= KMMsgInfoPrivate::REPLYTOAUX_SET;
404  kd->replyToAuxIdMD5 = aReplyToAuxIdMD5;
405  mDirty = true;
406 }
407 
408 
409 //-----------------------------------------------------------------------------
410 void KMMsgInfo::initStrippedSubjectMD5()
411 {
412  if( kd && kd->modifiers & KMMsgInfoPrivate::STRIPPEDSUBJECT_SET )
413  return;
414  TQString rawSubject = KMMessage::stripOffPrefixes( subject() );
415  TQString subjectMD5 = base64EncodedMD5( rawSubject, true /*utf8*/ );
416  if( !kd )
417  kd = new KMMsgInfoPrivate;
418  kd->modifiers |= KMMsgInfoPrivate::STRIPPEDSUBJECT_SET;
419  kd->strippedSubjectMD5 = subjectMD5;
420  mDirty = true;
421 }
422 
423 
424 //-----------------------------------------------------------------------------
425 void KMMsgInfo::setMsgIdMD5(const TQString& aMsgIdMD5)
426 {
427  if (aMsgIdMD5 == msgIdMD5())
428  return;
429 
430  if (!kd)
431  kd = new KMMsgInfoPrivate;
432  kd->modifiers |= KMMsgInfoPrivate::MSGID_SET;
433  kd->msgIdMD5 = aMsgIdMD5;
434  mDirty = true;
435 }
436 
437 //-----------------------------------------------------------------------------
438 void KMMsgInfo::setEncryptionState( const KMMsgEncryptionState s, int idx )
439 {
440  if (s == encryptionState())
441  return;
442 
443  if (!kd)
444  kd = new KMMsgInfoPrivate;
445  kd->modifiers |= KMMsgInfoPrivate::ENCRYPTION_SET;
446  kd->encryptionState = s;
447  KMMsgBase::setEncryptionState(s, idx); //base does more "stuff"
448  mDirty = true;
449 }
450 
451 //-----------------------------------------------------------------------------
452 void KMMsgInfo::setSignatureState( const KMMsgSignatureState s, int idx )
453 {
454  if (s == signatureState())
455  return;
456 
457  if (!kd)
458  kd = new KMMsgInfoPrivate;
459  kd->modifiers |= KMMsgInfoPrivate::SIGNATURE_SET;
460  kd->signatureState = s;
461  KMMsgBase::setSignatureState(s, idx); //base does more "stuff"
462  mDirty = true;
463 }
464 
465 //-----------------------------------------------------------------------------
466 void KMMsgInfo::setMDNSentState( const KMMsgMDNSentState s, int idx )
467 {
468  if (s == mdnSentState())
469  return;
470 
471  if (!kd)
472  kd = new KMMsgInfoPrivate;
473  kd->modifiers |= KMMsgInfoPrivate::MDN_SET;
474  kd->mdnSentState = s;
475  KMMsgBase::setMDNSentState(s, idx); //base does more "stuff"
476  mDirty = true;
477 }
478 
479 //-----------------------------------------------------------------------------
480 KMMsgStatus KMMsgInfo::status(void) const
481 {
482  if (mStatus == KMMsgStatusUnknown) {
483  KMMsgStatus st = (KMMsgStatus)getLongPart(MsgStatusPart);
484  if (!st) {
485  // We are opening an old index for the first time, get the legacy
486  // status and merge it in.
487  mLegacyStatus = (KMLegacyMsgStatus)getLongPart(MsgLegacyStatusPart);
488  st = KMMsgStatusRead;
489  switch (mLegacyStatus) {
490  case KMLegacyMsgStatusUnknown:
491  st = KMMsgStatusUnknown;
492  break;
493  case KMLegacyMsgStatusNew:
494  st = KMMsgStatusNew;
495  break;
496  case KMLegacyMsgStatusUnread:
497  st = KMMsgStatusUnread;
498  break;
499  case KMLegacyMsgStatusRead:
500  st = KMMsgStatusRead;
501  break;
502  case KMLegacyMsgStatusOld:
503  st = KMMsgStatusOld;
504  break;
505  case KMLegacyMsgStatusDeleted:
506  st |= KMMsgStatusDeleted;
507  break;
508  case KMLegacyMsgStatusReplied:
509  st |= KMMsgStatusReplied;
510  break;
511  case KMLegacyMsgStatusForwarded:
512  st |= KMMsgStatusForwarded;
513  break;
514  case KMLegacyMsgStatusQueued:
515  st |= KMMsgStatusQueued;
516  break;
517  case KMLegacyMsgStatusSent:
518  st |= KMMsgStatusSent;
519  break;
520  case KMLegacyMsgStatusFlag:
521  st |= KMMsgStatusFlag;
522  break;
523  default:
524  break;
525  }
526 
527  }
528  mStatus = st;
529  }
530  return mStatus;
531 }
532 
533 
534 //-----------------------------------------------------------------------------
535 KMMsgEncryptionState KMMsgInfo::encryptionState() const
536 {
537  if (kd && kd->modifiers & KMMsgInfoPrivate::ENCRYPTION_SET)
538  return kd->encryptionState;
539  unsigned long encState = getLongPart(MsgCryptoStatePart) & 0x0000FFFF;
540  return encState ? (KMMsgEncryptionState)encState : KMMsgEncryptionStateUnknown;
541 }
542 
543 
544 KMMsgSignatureState KMMsgInfo::signatureState() const
545 {
546  if (kd && kd->modifiers & KMMsgInfoPrivate::SIGNATURE_SET)
547  return kd->signatureState;
548  unsigned long sigState = getLongPart(MsgCryptoStatePart) >> 16;
549  return sigState ? (KMMsgSignatureState)sigState : KMMsgSignatureStateUnknown;
550 }
551 
552 KMMsgMDNSentState KMMsgInfo::mdnSentState() const {
553  if (kd && kd->modifiers & KMMsgInfoPrivate::MDN_SET)
554  return kd->mdnSentState;
555  unsigned long mdnState = getLongPart(MsgMDNSentPart);
556  return mdnState ? (KMMsgMDNSentState)mdnState : KMMsgMDNStateUnknown;
557 }
558 
559 
560 //-----------------------------------------------------------------------------
561 off_t KMMsgInfo::folderOffset(void) const
562 {
563  if (kd && kd->modifiers & KMMsgInfoPrivate::OFFSET_SET)
564  return kd->folderOffset;
565  return getLongPart(MsgOffsetPart);
566 }
567 
568 //-----------------------------------------------------------------------------
569 size_t KMMsgInfo::msgSize(void) const
570 {
571  if (kd && kd->modifiers & KMMsgInfoPrivate::SIZE_SET)
572  return kd->msgSize;
573  return getLongPart(MsgSizePart);
574 }
575 
576 //-----------------------------------------------------------------------------
577 time_t KMMsgInfo::date(void) const
578 {
579  time_t res;
580  if (kd && kd->modifiers & KMMsgInfoPrivate::DATE_SET)
581  res = kd->date;
582  else
583  res = getLongPart(MsgDatePart);
584  return res;
585 }
586 
587 //-----------------------------------------------------------------------------
588 size_t KMMsgInfo::msgSizeServer(void) const
589 {
590  if (kd && kd->modifiers & KMMsgInfoPrivate::SIZESERVER_SET)
591  return kd->msgSizeServer;
592  return getLongPart(MsgSizeServerPart);
593 }
594 
595 //-----------------------------------------------------------------------------
596 ulong KMMsgInfo::UID(void) const
597 {
598  if (kd && kd->modifiers & KMMsgInfoPrivate::UID_SET)
599  return kd->UID;
600  return getLongPart(MsgUIDPart);
601 }
602 
603 //-----------------------------------------------------------------------------
604 void KMMsgInfo::setMsgSize(size_t sz)
605 {
606  if (sz == msgSize())
607  return;
608 
609  if(!kd)
610  kd = new KMMsgInfoPrivate;
611  kd->modifiers |= KMMsgInfoPrivate::SIZE_SET;
612  kd->msgSize = sz;
613  mDirty = true;
614 }
615 
616 //-----------------------------------------------------------------------------
617 void KMMsgInfo::setMsgSizeServer(size_t sz)
618 {
619  if (sz == msgSizeServer())
620  return;
621 
622  if(!kd)
623  kd = new KMMsgInfoPrivate;
624  kd->modifiers |= KMMsgInfoPrivate::SIZESERVER_SET;
625  kd->msgSizeServer = sz;
626  mDirty = true;
627 }
628 
629 //-----------------------------------------------------------------------------
630 void KMMsgInfo::setUID(ulong uid)
631 {
632  if (uid == UID())
633  return;
634 
635  if(!kd)
636  kd = new KMMsgInfoPrivate;
637  kd->modifiers |= KMMsgInfoPrivate::UID_SET;
638  kd->UID = uid;
639  mDirty = true;
640 }
641 
642 //-----------------------------------------------------------------------------
643 void KMMsgInfo::setFolderOffset(off_t offs)
644 {
645  if (folderOffset() == offs)
646  return;
647 
648  if (!kd)
649  kd = new KMMsgInfoPrivate;
650  kd->modifiers |= KMMsgInfoPrivate::OFFSET_SET;
651  kd->folderOffset = offs;
652  mDirty = true;
653 }
654 
655 //-----------------------------------------------------------------------------
656 void KMMsgInfo::setFileName(const TQString& file)
657 {
658  if (fileName() == file)
659  return;
660 
661  if (!kd)
662  kd = new KMMsgInfoPrivate;
663  kd->modifiers |= KMMsgInfoPrivate::FILE_SET;
664  kd->file = file;
665  mDirty = true;
666 }
667 
668 //-----------------------------------------------------------------------------
669 void KMMsgInfo::setStatus(const KMMsgStatus aStatus, int idx)
670 {
671  if(aStatus == status())
672  return;
673  KMMsgBase::setStatus(aStatus, idx); //base does more "stuff"
674 }
675 
676 //-----------------------------------------------------------------------------
677 void KMMsgInfo::setDate(time_t aUnixTime)
678 {
679  if(aUnixTime == date())
680  return;
681 
682  if(!kd)
683  kd = new KMMsgInfoPrivate;
684  kd->modifiers |= KMMsgInfoPrivate::DATE_SET;
685  kd->date = aUnixTime;
686  mDirty = true;
687 }
688 
689 void KMMsgInfo::setFrom( const TQString &from )
690 {
691  if ( !kd )
692  kd = new KMMsgInfoPrivate;
693  kd->modifiers |= KMMsgInfoPrivate::FROM_SET;
694  kd->from = from;
695  mDirty = true;
696 }
697 
698 void KMMsgInfo::setTo( const TQString &to )
699 {
700  if ( !kd )
701  kd = new KMMsgInfoPrivate;
702  kd->modifiers |= KMMsgInfoPrivate::TO_SET;
703  kd->to = to;
704  mDirty = true;
705 }
706 
707 //--- For compatability with old index files
708 void KMMsgInfo::compat_fromOldIndexString(const TQCString& str, bool toUtf8)
709 {
710  const char *start, *offset;
711 
712  if(!kd)
713  kd = new KMMsgInfoPrivate;
714  kd->modifiers = KMMsgInfoPrivate::ALL_SET;
715  kd->xmark = str.mid(33, 3).stripWhiteSpace();
716  kd->folderOffset = str.mid(2,9).toULong();
717  kd->msgSize = str.mid(12,9).toULong();
718  kd->date = (time_t)str.mid(22,10).toULong();
719  mStatus = (KMMsgStatus)str.at(0);
720  if (toUtf8) {
721  kd->subject = str.mid(37, 100).stripWhiteSpace();
722  kd->fromStrip = str.mid(138, 50).stripWhiteSpace();
723  kd->toStrip = str.mid(189, 50).stripWhiteSpace();
724  } else {
725  start = offset = str.data() + 37;
726  while (*start == ' ' && start - offset < 100) start++;
727  kd->subject = TQString::fromUtf8(str.mid(start - str.data(),
728  100 - (start - offset)), 100 - (start - offset));
729  start = offset = str.data() + 138;
730  while (*start == ' ' && start - offset < 50) start++;
731  kd->fromStrip = TQString::fromUtf8(str.mid(start - str.data(),
732  50 - (start - offset)), 50 - (start - offset));
733  start = offset = str.data() + 189;
734  while (*start == ' ' && start - offset < 50) start++;
735  kd->toStrip = TQString::fromUtf8(str.mid(start - str.data(),
736  50 - (start - offset)), 50 - (start - offset));
737  }
738  kd->replyToIdMD5 = str.mid(240, 22).stripWhiteSpace();
739  kd->msgIdMD5 = str.mid(263, 22).stripWhiteSpace();
740  mDirty = false;
741 }
742 
743 bool KMMsgInfo::dirty(void) const
744 {
745  if( KMMsgBase::dirty() )
746  return true;
747  return kd && kd->modifiers != KMMsgInfoPrivate::NONE_SET;
748 }
Mail folder.
Definition: kmfolder.h:69
This is a Mime Message.
Definition: kmmessage.h:68
size_t msgSizeServer() const
Get/set size on server.
Definition: kmmessage.cpp:2212
TQString from() const
Get or set the 'From' header field.
Definition: kmmessage.cpp:2015
TQString xmark() const
Get or set the 'X-Mark' header field.
Definition: kmmessage.cpp:2064
TQString replyToAuxIdMD5() const
Get the second to last id from the References header field.
Definition: kmmessage.cpp:2146
TQString to() const
Get or set the 'To' header field.
Definition: kmmessage.cpp:1894
TQString subject() const
Get or set the 'Subject' header field.
Definition: kmmessage.cpp:2049
KMMsgEncryptionState encryptionState() const
Encryption status of the message.
Definition: kmmessage.h:844
static TQCString stripEmailAddr(const TQCString &emailAddr)
This function generates a displayable string from a list of email addresses.
Definition: kmmessage.cpp:3483
KMMsgStatus status() const
Status of the message.
Definition: kmmessage.h:830
TQString fileName() const
Get/set filename in mail folder.
Definition: kmmessage.h:802
TQString strippedSubjectMD5() const
Get a hash of the subject with all prefixes such as Re: removed.
Definition: kmmessage.cpp:2159
off_t folderOffset() const
Get/set offset in mail folder.
Definition: kmmessage.h:798
size_t msgSize() const
Get/set size of message in the folder including the whole header in bytes.
Definition: kmmessage.h:812
KMMsgBase & toMsgBase()
Get KMMsgBase for this object.
Definition: kmmessage.h:114
ulong UID() const
Get/set UID.
Definition: kmmessage.cpp:2225
KMMsgSignatureState signatureState() const
Signature status of the message.
Definition: kmmessage.h:847