Factor out the shared parts of the agent action manager setup.
[kdepim.git] / kalarm / kamail.h
blobc60b82f71ff4a2926a7ccf0ff2bf1259c14c1639
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 #ifdef USE_AKONADI
27 #include <kcalcore/person.h>
28 #else
29 #include <kcal/person.h>
30 #endif
32 #include <QObject>
33 #include <QString>
34 #include <QStringList>
35 #include <QQueue>
36 #ifdef USE_AKONADI
37 #include <QList>
38 #endif
40 class KUrl;
41 class KJob;
42 namespace MailTransport { class MessageQueueJob; }
43 namespace KMime {
44 namespace Types { struct Address; }
45 class Message;
48 using namespace KAlarmCal;
50 class KAMail : public QObject
52 Q_OBJECT
53 public:
54 // Data to store for each mail send job.
55 // Some data is required by KAMail, while other data is used by the caller.
56 struct JobData
58 JobData() {}
59 JobData(KAEvent& e, const KAAlarm& a, bool resched, bool notify)
60 : event(e), alarm(a), reschedule(resched), allowNotify(notify), queued(false) {}
61 KAEvent event;
62 KAAlarm alarm;
63 QString from, bcc, subject;
64 bool reschedule;
65 bool allowNotify;
66 bool queued;
69 static int send(JobData&, QStringList& errmsgs);
70 static int checkAddress(QString& address);
71 static int checkAttachment(QString& attachment, KUrl* = 0);
72 static bool checkAttachment(const KUrl&);
73 #ifdef USE_AKONADI
74 static QString convertAddresses(const QString& addresses, KCalCore::Person::List&);
75 #else
76 static QString convertAddresses(const QString& addresses, QList<KCal::Person>&);
77 #endif
78 static QString convertAttachments(const QString& attachments, QStringList& list);
79 static QString controlCentreAddress();
80 #ifdef KMAIL_SUPPORTED
81 static QString getMailBody(quint32 serialNumber);
82 #endif
83 static QString i18n_NeedFromEmailAddress();
84 static QString i18n_sent_mail();
86 private slots:
87 void slotEmailSent(KJob*);
89 private:
90 KAMail() {}
91 static KAMail* instance();
92 static QString appendBodyAttachments(KMime::Message& message, JobData&);
93 static void notifyQueued(const KAEvent&);
94 enum ErrType { SEND_FAIL, SEND_ERROR };
95 static QStringList errors(const QString& error = QString(), ErrType = SEND_FAIL);
97 static KAMail* mInstance;
98 static QQueue<MailTransport::MessageQueueJob*> mJobs;
99 static QQueue<JobData> mJobData;
102 #endif // KAMAIL_H
104 // vim: et sw=4: