25 #include <sys/types.h>
43 KMMsgStatusUnknown = 0x00000000,
44 KMMsgStatusNew = 0x00000001,
45 KMMsgStatusUnread = 0x00000002,
46 KMMsgStatusRead = 0x00000004,
47 KMMsgStatusOld = 0x00000008,
48 KMMsgStatusDeleted = 0x00000010,
49 KMMsgStatusReplied = 0x00000020,
50 KMMsgStatusForwarded = 0x00000040,
51 KMMsgStatusQueued = 0x00000080,
52 KMMsgStatusSent = 0x00000100,
53 KMMsgStatusFlag = 0x00000200,
54 KMMsgStatusWatched = 0x00000400,
55 KMMsgStatusIgnored = 0x00000800,
56 KMMsgStatusTodo = 0x00001000,
57 KMMsgStatusSpam = 0x00002000,
58 KMMsgStatusHam = 0x00004000,
59 KMMsgStatusHasAttach = 0x00008000,
60 KMMsgStatusHasNoAttach = 0x00010000,
61 KMMsgStatusHasInvitation = 0x00020000,
62 KMMsgStatusHasNoInvitation = 0x00040000
65 typedef uint KMMsgStatus;
72 KMLegacyMsgStatusUnknown=
' ',
73 KMLegacyMsgStatusNew=
'N',
74 KMLegacyMsgStatusUnread=
'U',
75 KMLegacyMsgStatusRead=
'R',
76 KMLegacyMsgStatusOld=
'O',
77 KMLegacyMsgStatusDeleted=
'D',
78 KMLegacyMsgStatusReplied=
'A',
79 KMLegacyMsgStatusForwarded=
'F',
80 KMLegacyMsgStatusQueued=
'Q',
81 KMLegacyMsgStatusSent=
'S',
82 KMLegacyMsgStatusFlag=
'G'
90 KMMsgEncryptionStateUnknown=
' ',
91 KMMsgNotEncrypted=
'N',
92 KMMsgPartiallyEncrypted=
'P',
93 KMMsgFullyEncrypted=
'F',
94 KMMsgEncryptionProblematic=
'X'
95 } KMMsgEncryptionState;
100 KMMsgSignatureStateUnknown=
' ',
102 KMMsgPartiallySigned=
'P',
103 KMMsgFullySigned=
'F',
104 KMMsgSignatureProblematic=
'X'
105 } KMMsgSignatureState;
110 KMMsgMDNStateUnknown =
' ',
112 KMMsgMDNIgnore =
'I',
113 KMMsgMDNDisplayed =
'R',
114 KMMsgMDNDeleted =
'D',
115 KMMsgMDNDispatched =
'F',
116 KMMsgMDNProcessed =
'P',
117 KMMsgMDNDenied =
'X',
124 KMMsgDnDActionMOVE=0,
125 KMMsgDnDActionCOPY=1,
133 KMMsgHasNoAttachment,
134 KMMsgAttachmentUnknown
135 } KMMsgAttachmentState;
141 KMMsgHasNoInvitation,
142 KMMsgInvitationUnknown
143 } KMMsgInvitationState;
149 virtual ~KMMsgBase();
155 KMFolder* parent()
const {
return mParent; }
158 void setParent(
KMFolder* p) { mParent = p; }
161 static TQCString statusToStr(
const KMMsgStatus status);
164 TQString statusToSortRank();
167 virtual bool isMessage(
void)
const;
170 virtual bool isUnread(
void)
const;
173 virtual bool isNew(
void)
const;
176 virtual bool isOfUnknownStatus(
void)
const;
179 virtual bool isOld(
void)
const;
182 virtual bool isRead(
void)
const;
185 virtual bool isDeleted(
void)
const;
188 virtual bool isReplied(
void)
const;
191 virtual bool isForwarded(
void)
const;
194 virtual bool isQueued(
void)
const;
197 virtual bool isTodo(
void)
const;
200 virtual bool isSent(
void)
const;
203 virtual bool isImportant(
void)
const;
206 virtual bool isWatched(
void)
const;
209 virtual bool isIgnored(
void)
const;
212 virtual bool isSpam(
void)
const;
215 virtual bool isHam(
void)
const;
219 virtual KMMsgStatus status(
void)
const = 0;
223 virtual void setStatus(
const KMMsgStatus status,
int idx = -1);
224 virtual void toggleStatus(
const KMMsgStatus status,
int idx = -1);
225 virtual void setStatus(
const char* statusField,
const char* xstatusField=0);
228 virtual KMMsgEncryptionState encryptionState()
const = 0;
231 virtual KMMsgSignatureState signatureState()
const = 0;
234 virtual KMMsgMDNSentState mdnSentState()
const = 0;
237 virtual void setMDNSentState( KMMsgMDNSentState status,
int idx=-1 );
242 virtual void setEncryptionState(
const KMMsgEncryptionState,
int idx = -1);
247 virtual void setSignatureState(
const KMMsgSignatureState,
int idx = -1);
252 virtual void setEncryptionStateChar( TQChar status,
int idx = -1 );
257 virtual void setSignatureStateChar( TQChar status,
int idx = -1 );
260 virtual TQString subject(
void)
const = 0;
261 virtual TQString fromStrip(
void)
const = 0;
262 virtual TQString from()
const = 0;
263 virtual TQString toStrip(
void)
const = 0;
264 virtual TQString to()
const = 0;
265 virtual TQString replyToIdMD5(
void)
const = 0;
266 virtual TQString msgIdMD5(
void)
const = 0;
267 virtual TQString replyToAuxIdMD5()
const = 0;
268 virtual TQString strippedSubjectMD5()
const = 0;
269 virtual bool subjectIsPrefixed()
const = 0;
270 virtual time_t date(
void)
const = 0;
271 virtual TQString dateStr(
void)
const;
272 virtual TQString xmark(
void)
const = 0;
275 virtual void setDate(
const TQCString &aStrDate);
276 virtual void setDate(time_t aUnixTime) = 0;
279 virtual bool dirty(
void)
const {
return mDirty; }
282 void setDirty(
bool b) { mDirty = b; }
285 virtual void setSubject(
const TQString&) = 0;
286 virtual void setXMark(
const TQString&) = 0;
289 virtual void initStrippedSubjectMD5() = 0;
292 const uchar *asIndexString(
int &len)
const;
295 virtual off_t folderOffset(
void)
const = 0;
296 virtual void setFolderOffset(off_t offs) = 0;
299 virtual TQString fileName(
void)
const = 0;
300 virtual void setFileName(
const TQString& filename) = 0;
303 virtual size_t msgSize(
void)
const = 0;
304 virtual void setMsgSize(
size_t sz) = 0;
307 virtual size_t msgSizeServer(
void)
const = 0;
308 virtual void setMsgSizeServer(
size_t sz) = 0;
311 virtual ulong UID(
void)
const = 0;
312 virtual void setUID(ulong uid) = 0;
315 virtual void setIndexOffset(off_t off) { mIndexOffset = off; }
316 virtual off_t indexOffset()
const {
return mIndexOffset; }
319 virtual void setIndexLength(
short len) { mIndexLength = len; }
320 virtual short indexLength()
const {
return mIndexLength; }
326 static TQString skipKeyword(
const TQString& str, TQChar sepChar=
':',
327 bool* keywordFound=0);
331 static const TQTextCodec* codecForName(
const TQCString& _str);
336 static TQCString toUsAscii(
const TQString& _str,
bool *ok=0);
339 static TQStringList supportedEncodings(
bool usAscii);
342 void assign(
const KMMsgBase* other);
345 KMMsgBase& operator=(
const KMMsgBase& other);
348 KMMsgBase(
const KMMsgBase& other );
351 static TQCString encodeRFC2047Quoted(
const TQCString& aStr,
bool base64);
355 static TQString decodeRFC2047String(
const TQCString& aStr,
const TQCString prefCharset =
"");
359 static TQCString encodeRFC2047String(
const TQString& aStr,
360 const TQCString& charset);
364 static TQCString encodeRFC2231String(
const TQString& aStr,
365 const TQCString& charset);
371 static TQCString encodeRFC2231StringAutoDetectCharset(
const TQString &str,
372 const TQCString &defaultCharset =
"" );
375 static TQString decodeRFC2231String(
const TQCString& aStr);
380 static TQCString extractRFC2231HeaderField(
const TQCString &aStr,
const TQCString &field );
385 static TQString base64EncodedMD5(
const TQString & aStr,
bool utf8=
false );
386 static TQString base64EncodedMD5(
const TQCString & aStr );
387 static TQString base64EncodedMD5(
const char * aStr,
int len=-1 );
394 static TQCString autoDetectCharset(
const TQCString &encoding,
const TQStringList &encodingList,
const TQString &text);
397 virtual unsigned long getMsgSerNum()
const;
400 virtual bool enableUndo() {
return mEnableUndo; }
401 virtual void setEnableUndo(
bool enable ) { mEnableUndo = enable; }
404 virtual KMMsgAttachmentState attachmentState()
const;
407 virtual KMMsgInvitationState invitationState()
const;
415 static TQString replacePrefixes(
const TQString& str,
416 const TQStringList& prefixRegExps,
418 const TQString& newPrefix );
422 static TQString stripOffPrefixes(
const TQString& str );
430 TQString cleanSubject(
const TQStringList& prefixRegExps,
bool replace,
431 const TQString& newPrefix)
const;
435 TQString cleanSubject()
const;
438 TQString forwardSubject()
const;
441 TQString replySubject()
const;
445 static void readConfig();
453 mutable KMMsgStatus mStatus;
456 mutable KMLegacyMsgStatus mLegacyStatus;
463 MsgFromStripPart = 1,
466 MsgReplyToIdMD5Part = 4,
471 MsgLegacyStatusPart = 8,
475 MsgCryptoStatePart = 12,
478 MsgReplyToAuxIdMD5Part = 14,
479 MsgStrippedSubjectMD5Part = 15,
482 MsgSizeServerPart = 17,
488 off_t getLongPart(MsgPartType)
const;
490 TQString getStringPart(MsgPartType)
const;
492 bool syncIndexString()
const;
A FolderStorage with an index for faster access to often used message properties.