2 * kamail.h - email functions
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.
24 #include <kalarmcal/kaevent.h>
26 #include <KCalCore/Person>
30 #include <QStringList>
35 namespace MailTransport
{ class MessageQueueJob
; }
37 namespace Types
{ struct Address
; }
41 using namespace KAlarmCal
;
43 class KAMail
: public QObject
47 // Data to store for each mail send job.
48 // Some data is required by KAMail, while other data is used by the caller.
52 JobData(KAEvent
& e
, const KAAlarm
& a
, bool resched
, bool notify
)
53 : event(e
), alarm(a
), reschedule(resched
), allowNotify(notify
), queued(false) {}
56 QString from
, bcc
, subject
;
62 static int send(JobData
&, QStringList
& errmsgs
);
63 static int checkAddress(QString
& address
);
64 static int checkAttachment(QString
& attachment
, QUrl
* = Q_NULLPTR
);
65 static bool checkAttachment(const QUrl
&);
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();
74 void slotEmailSent(KJob
*);
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
;