kalarm

alarmtext.h
00001 /*
00002  *  alarmtext.h  -  text/email alarm text conversion
00003  *  Program:  kalarm
00004  *  Copyright (C) 2004, 2005 by David Jarvie <software@astrojar.org.uk>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #ifndef ALARMTEXT_H
00022 #define ALARMTEXT_H
00023 
00024 #include <tqstring.h>
00025 class TQStringList;
00026 class KAEvent;
00027 
00028 
00029 class AlarmText
00030 {
00031     public:
00032         AlarmText(const TQString& text = TQString())  { setText(text); }
00033         void           setText(const TQString&);
00034         void           setScript(const TQString& text)   { setText(text);  mIsScript = true; }
00035         void           setEmail(const TQString& to, const TQString& from, const TQString& cc, const TQString& time,
00036                                 const TQString& subject, const TQString& body, unsigned long kmailSerialNumber = 0);
00037         TQString        displayText() const;
00038         TQString        calendarText() const;
00039         TQString        to() const                 { return mTo; }
00040         TQString        from() const               { return mFrom; }
00041         TQString        cc() const                 { return mCc; }
00042         TQString        time() const               { return mTime; }
00043         TQString        subject() const            { return mSubject; }
00044         TQString        body() const               { return mIsEmail ? mBody : TQString(); }
00045         bool           isEmpty() const;
00046         bool           isEmail() const            { return mIsEmail; }
00047         bool           isScript() const           { return mIsScript; }
00048         unsigned long  kmailSerialNumber() const  { return mKMailSerialNum; }
00049         static TQString summary(const KAEvent&, int maxLines = 1, bool* truncated = 0);
00050         static bool    checkIfEmail(const TQString&);
00051         static TQString emailHeaders(const TQString&, bool subjectOnly);
00052         static TQString fromCalendarText(const TQString&, bool& email);
00053         static TQString toCalendarText(const TQString&);
00054 
00055     private:
00056         static void    setUpTranslations();
00057         static int     emailHeaderCount(const TQStringList&);
00058 
00059         static TQString mFromPrefix;       // translated header prefixes
00060         static TQString mToPrefix;
00061         static TQString mCcPrefix;
00062         static TQString mDatePrefix;
00063         static TQString mSubjectPrefix;
00064         static TQString mFromPrefixEn;     // untranslated header prefixes
00065         static TQString mToPrefixEn;
00066         static TQString mCcPrefixEn;
00067         static TQString mDatePrefixEn;
00068         static TQString mSubjectPrefixEn;
00069         TQString        mBody, mFrom, mTo, mCc, mTime, mSubject;
00070         unsigned long  mKMailSerialNum;   // if email, message's KMail serial number, else 0
00071         bool           mIsEmail;
00072         bool           mIsScript;
00073 };
00074 
00075 #endif // ALARMTEXT_H