SVN_SILENT made messages (.desktop file)
[kdepim.git] / kalarm / kamail.h
blob42c485421aa8c1eb13ba42566fcafc4a8fca5cc3
1 /*
2 * kamail.h - email functions
3 * Program: kalarm
4 * Copyright © 2002-2011 by David Jarvie <djarvie@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef KAMAIL_H
22 #define KAMAIL_H
24 #include <kalarmcal/kaevent.h>
26 #include <KCalCore/Person>
28 #include <QObject>
29 #include <QString>
30 #include <QStringList>
31 #include <QQueue>
33 class KUrl;
34 class KJob;
35 namespace MailTransport { class MessageQueueJob; }
36 namespace KMime {
37 namespace Types { struct Address; }
38 class Message;
41 using namespace KAlarmCal;
43 class KAMail : public QObject
45 Q_OBJECT
46 public:
47 // Data to store for each mail send job.
48 // Some data is required by KAMail, while other data is used by the caller.
49 struct JobData
51 JobData() {}
52 JobData(KAEvent& e, const KAAlarm& a, bool resched, bool notify)
53 : event(e), alarm(a), reschedule(resched), allowNotify(notify), queued(false) {}
54 KAEvent event;
55 KAAlarm alarm;
56 QString from, bcc, subject;
57 bool reschedule;
58 bool allowNotify;
59 bool queued;
62 static int send(JobData&, QStringList& errmsgs);
63 static int checkAddress(QString& address);
64 static int checkAttachment(QString& attachment, KUrl* = 0);
65 static bool checkAttachment(const KUrl&);
66 static QString convertAddresses(const QString& addresses, KCalCore::Person::List&);
67 static QString convertAttachments(const QString& attachments, QStringList& list);
68 static QString controlCentreAddress();
69 static QString getMailBody(quint32 serialNumber);
70 static QString i18n_NeedFromEmailAddress();
71 static QString i18n_sent_mail();
73 private Q_SLOTS:
74 void slotEmailSent(KJob*);
76 private:
77 KAMail() {}
78 static KAMail* instance();
79 static QString appendBodyAttachments(KMime::Message& message, JobData&);
80 static void notifyQueued(const KAEvent&);
81 enum ErrType { SEND_FAIL, SEND_ERROR };
82 static QStringList errors(const QString& error = QString(), ErrType = SEND_FAIL);
84 static KAMail* mInstance;
85 static QQueue<MailTransport::MessageQueueJob*> mJobs;
86 static QQueue<JobData> mJobData;
89 #endif // KAMAIL_H
91 // vim: et sw=4: