Changeset View
Changeset View
Standalone View
Standalone View
korgac/mailclient.cpp
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | |||||
56 | } | 56 | } | ||
57 | 57 | | |||
58 | MailClient::~MailClient() | 58 | MailClient::~MailClient() | ||
59 | { | 59 | { | ||
60 | } | 60 | } | ||
61 | 61 | | |||
62 | bool MailClient::mailAttendees(const KCalCore::IncidenceBase::Ptr &incidence, const KIdentityManagement::Identity &identity, bool bccMe, const QString &attachment, const QString &mailTransport) | 62 | bool MailClient::mailAttendees(const KCalCore::IncidenceBase::Ptr &incidence, const KIdentityManagement::Identity &identity, bool bccMe, const QString &attachment, const QString &mailTransport) | ||
63 | { | 63 | { | ||
64 | KCalCore::Attendee::List attendees = incidence->attendees(); | 64 | const KCalCore::Attendee::List attendees = incidence->attendees(); | ||
65 | if (attendees.isEmpty()) { | 65 | if (attendees.isEmpty()) { | ||
66 | qCWarning(KOALARMCLIENT_LOG) << "There are no attendees to e-mail"; | 66 | qCWarning(KOALARMCLIENT_LOG) << "There are no attendees to e-mail"; | ||
67 | return false; | 67 | return false; | ||
68 | } | 68 | } | ||
69 | 69 | | |||
70 | const QString from = incidence->organizer().fullName(); | 70 | const QString from = incidence->organizer().fullName(); | ||
71 | const QString organizerEmail = incidence->organizer().email(); | 71 | const QString organizerEmail = incidence->organizer().email(); | ||
72 | 72 | | |||
73 | QStringList toList; | 73 | QStringList toList; | ||
74 | QStringList ccList; | 74 | QStringList ccList; | ||
75 | const int numberOfAttendees(attendees.count()); | 75 | for (const auto &a : attendees) { | ||
76 | for (int i = 0; i < numberOfAttendees; ++i) { | 76 | const QString email = a.email(); | ||
77 | KCalCore::Attendee::Ptr a = attendees.at(i); | | |||
78 | | ||||
79 | const QString email = a->email(); | | |||
80 | if (email.isEmpty()) { | 77 | if (email.isEmpty()) { | ||
81 | continue; | 78 | continue; | ||
82 | } | 79 | } | ||
83 | 80 | | |||
84 | // In case we (as one of our identities) are the organizer we are sending | 81 | // In case we (as one of our identities) are the organizer we are sending | ||
85 | // this mail. We could also have added ourselves as an attendee, in which | 82 | // this mail. We could also have added ourselves as an attendee, in which | ||
86 | // case we don't want to send ourselves a notification mail. | 83 | // case we don't want to send ourselves a notification mail. | ||
87 | if (organizerEmail == email) { | 84 | if (organizerEmail == email) { | ||
88 | continue; | 85 | continue; | ||
89 | } | 86 | } | ||
90 | 87 | | |||
91 | // Build a nice address for this attendee including the CN. | 88 | // Build a nice address for this attendee including the CN. | ||
92 | QString tname, temail; | 89 | QString tname, temail; | ||
93 | const QString username = KEmailAddress::quoteNameIfNecessary(a->name()); | 90 | const QString username = KEmailAddress::quoteNameIfNecessary(a.name()); | ||
94 | // ignore the return value from extractEmailAddressAndName() because | 91 | // ignore the return value from extractEmailAddressAndName() because | ||
95 | // it will always be false since tusername does not contain "@domain". | 92 | // it will always be false since tusername does not contain "@domain". | ||
96 | KEmailAddress::extractEmailAddressAndName(username, temail /*byref*/, tname /*byref*/); | 93 | KEmailAddress::extractEmailAddressAndName(username, temail /*byref*/, tname /*byref*/); | ||
97 | tname += QStringLiteral(" <") + email + QLatin1Char('>'); | 94 | tname += QStringLiteral(" <") + email + QLatin1Char('>'); | ||
98 | 95 | | |||
99 | // Optional Participants and Non-Participants are copied on the email | 96 | // Optional Participants and Non-Participants are copied on the email | ||
100 | if (a->role() == KCalCore::Attendee::OptParticipant | 97 | if (a.role() == KCalCore::Attendee::OptParticipant | ||
101 | || a->role() == KCalCore::Attendee::NonParticipant) { | 98 | || a.role() == KCalCore::Attendee::NonParticipant) { | ||
102 | ccList << tname; | 99 | ccList << tname; | ||
103 | } else { | 100 | } else { | ||
104 | toList << tname; | 101 | toList << tname; | ||
105 | } | 102 | } | ||
106 | } | 103 | } | ||
107 | if (toList.isEmpty() && ccList.isEmpty()) { | 104 | if (toList.isEmpty() && ccList.isEmpty()) { | ||
108 | // Not really to be called a groupware meeting, eh | 105 | // Not really to be called a groupware meeting, eh | ||
109 | qCDebug(KOALARMCLIENT_LOG) << "There are really no attendees to e-mail"; | 106 | qCDebug(KOALARMCLIENT_LOG) << "There are really no attendees to e-mail"; | ||
▲ Show 20 Lines • Show All 261 Lines • Show Last 20 Lines |