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>
27 #include <kcalcore/person.h>
29 #include <kcal/person.h>
34 #include <QStringList>
42 namespace MailTransport
{ class MessageQueueJob
; }
44 namespace Types
{ struct Address
; }
48 using namespace KAlarmCal
;
50 class KAMail
: public QObject
54 // Data to store for each mail send job.
55 // Some data is required by KAMail, while other data is used by the caller.
59 JobData(KAEvent
& e
, const KAAlarm
& a
, bool resched
, bool notify
)
60 : event(e
), alarm(a
), reschedule(resched
), allowNotify(notify
), queued(false) {}
63 QString from
, bcc
, subject
;
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
&);
74 static QString
convertAddresses(const QString
& addresses
, KCalCore::Person::List
&);
76 static QString
convertAddresses(const QString
& addresses
, QList
<KCal::Person
>&);
78 static QString
convertAttachments(const QString
& attachments
, QStringList
& list
);
79 static QString
controlCentreAddress();
80 #ifdef KMAIL_SUPPORTED
81 static QString
getMailBody(quint32 serialNumber
);
83 static QString
i18n_NeedFromEmailAddress();
84 static QString
i18n_sent_mail();
87 void slotEmailSent(KJob
*);
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
;