46 QList<NmAddress> &recipients, |
46 QList<NmAddress> &recipients, |
47 NmAddressValidationType type ) |
47 NmAddressValidationType type ) |
48 { |
48 { |
49 NM_FUNCTION; |
49 NM_FUNCTION; |
50 |
50 |
|
51 // Get envelope from message |
|
52 const NmMessageEnvelope &env = message.envelope(); |
|
53 |
51 // validate TO addresses |
54 // validate TO addresses |
52 QList<NmAddress> toRecipients = message.envelope().toRecipients(); |
55 QList<NmAddress> toRecipients = env.toRecipients(); |
53 int recipientCount = toRecipients.count(); |
56 int recipientCount = toRecipients.count(); |
54 |
57 |
55 for (int i = 0; i < recipientCount; ++i) { |
58 for (int i = 0; i < recipientCount; ++i) { |
56 bool validAddress = isValidEmailAddress(toRecipients.at(i).address()); |
59 bool validAddress = isValidEmailAddress(toRecipients.at(i).address()); |
57 |
60 |
58 if (type == Default || |
61 if (type == NmDefault || |
59 type == ValidAddress && validAddress || |
62 type == NmValidAddress && validAddress || |
60 type == InvalidAddress && !validAddress) { |
63 type == NmInvalidAddress && !validAddress) { |
61 recipients.append(toRecipients.at(i)); |
64 recipients.append(toRecipients.at(i)); |
62 } |
65 } |
63 } |
66 } |
64 |
67 |
65 // validate CC addresses |
68 // validate CC addresses |
66 QList<NmAddress> ccRecipients = message.envelope().ccRecipients(); |
69 QList<NmAddress> ccRecipients = env.ccRecipients(); |
67 recipientCount = ccRecipients.count(); |
70 recipientCount = ccRecipients.count(); |
68 |
71 |
69 for (int i = 0; i < recipientCount; ++i) { |
72 for (int i = 0; i < recipientCount; ++i) { |
70 bool validAddress = isValidEmailAddress(ccRecipients.at(i).address()); |
73 bool validAddress = isValidEmailAddress(ccRecipients.at(i).address()); |
71 |
74 |
72 if (type == Default || |
75 if (type == NmDefault || |
73 type == ValidAddress && validAddress || |
76 type == NmValidAddress && validAddress || |
74 type == InvalidAddress && !validAddress) { |
77 type == NmInvalidAddress && !validAddress) { |
75 recipients.append(ccRecipients.at(i)); |
78 recipients.append(ccRecipients.at(i)); |
76 } |
79 } |
77 } |
80 } |
78 |
81 |
79 // validate BCC addresses |
82 // validate BCC addresses |
80 QList<NmAddress> bccRecipients = message.envelope().bccRecipients(); |
83 QList<NmAddress> bccRecipients = env.bccRecipients(); |
81 recipientCount = bccRecipients.count(); |
84 recipientCount = bccRecipients.count(); |
82 |
85 |
83 for (int i = 0; i < recipientCount; ++i) { |
86 for (int i = 0; i < recipientCount; ++i) { |
84 bool validAddress = isValidEmailAddress(bccRecipients.at(i).address()); |
87 bool validAddress = isValidEmailAddress(bccRecipients.at(i).address()); |
85 |
88 |
86 if (type == Default || |
89 if (type == NmDefault || |
87 type == ValidAddress && validAddress || |
90 type == NmValidAddress && validAddress || |
88 type == InvalidAddress && !validAddress) { |
91 type == NmInvalidAddress && !validAddress) { |
89 recipients.append(bccRecipients.at(i)); |
92 recipients.append(bccRecipients.at(i)); |
90 } |
93 } |
91 } |
94 } |
92 } |
95 } |
93 |
96 |
126 */ |
129 */ |
127 bool NmUtilities::parseEmailAddress( const QString &emailAddress, NmAddress &address ) |
130 bool NmUtilities::parseEmailAddress( const QString &emailAddress, NmAddress &address ) |
128 { |
131 { |
129 NM_FUNCTION; |
132 NM_FUNCTION; |
130 |
133 |
131 bool foundAddress = false; |
134 bool foundAddress(false); |
132 |
135 |
133 QRegExp rx(EmailAddressPattern); |
136 QRegExp rx(NmEmailAddressPattern); |
134 // locate the email address in the string |
137 // locate the email address in the string |
135 int pos = rx.indexIn(emailAddress); |
138 int pos = rx.indexIn(emailAddress); |
136 if (pos != -1) { |
139 if (pos != -1) { |
137 // extract the email address... |
140 // extract the email address... |
138 int matchedLen = rx.matchedLength(); |
141 int matchedLen = rx.matchedLength(); |
241 QString NmUtilities::attachmentSizeString(const int sizeInBytes) |
244 QString NmUtilities::attachmentSizeString(const int sizeInBytes) |
242 { |
245 { |
243 NM_FUNCTION; |
246 NM_FUNCTION; |
244 |
247 |
245 qreal sizeMb = (qreal)sizeInBytes / (qreal)NmMegabyte; |
248 qreal sizeMb = (qreal)sizeInBytes / (qreal)NmMegabyte; |
246 if (sizeMb < 0.1) { |
249 if (sizeMb < NmMinAttachmentSize) { |
247 // 0.1 Mb is the minimum size shown for attachment |
250 // NmMinAttachmentSize (0.1Mb) is the minimum size shown for attachment |
248 sizeMb = 0.1; |
251 sizeMb = NmMinAttachmentSize; |
249 } |
252 } |
250 return QString().sprintf("(%.1f Mb)", sizeMb); // Use loc string when available |
253 return QString().sprintf("(%.1f Mb)", sizeMb); // Use loc string when available |
251 } |
254 } |
252 |
255 |
253 /*! |
256 /*! |
254 Displays a note with Yes/No buttons. Note has no timeout, i.e. it has to be dismissed manually. |
257 Displays a note with Yes/No buttons. Note has no timeout, i.e. it has to be dismissed manually. |