Diffstat (limited to 'noncore/unsupported/mailit/writemail.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/unsupported/mailit/writemail.cpp | 101 |
1 files changed, 88 insertions, 13 deletions
diff --git a/noncore/unsupported/mailit/writemail.cpp b/noncore/unsupported/mailit/writemail.cpp index 38a2596..a9dcb02 100644 --- a/noncore/unsupported/mailit/writemail.cpp +++ b/noncore/unsupported/mailit/writemail.cpp | |||
@@ -86,6 +86,8 @@ void WriteMail::init() | |||
86 | recipientsBox->insertItem( tr( "CC:" ) ); | 86 | recipientsBox->insertItem( tr( "CC:" ) ); |
87 | recipientsBox->setCurrentItem(0); | 87 | recipientsBox->setCurrentItem(0); |
88 | grid->addWidget( recipientsBox, 0, 0 ); | 88 | grid->addWidget( recipientsBox, 0, 0 ); |
89 | connect(recipientsBox,SIGNAL(activated(int)),this, SLOT(changeRecipients(int))); | ||
90 | |||
89 | 91 | ||
90 | subjetLabel = new QLabel( widget, "subjetLabel" ); | 92 | subjetLabel = new QLabel( widget, "subjetLabel" ); |
91 | subjetLabel->setText( tr( "Subject:" ) ); | 93 | subjetLabel->setText( tr( "Subject:" ) ); |
@@ -102,6 +104,11 @@ void WriteMail::init() | |||
102 | toInput = new QLineEdit( widget, "toInput" ); | 104 | toInput = new QLineEdit( widget, "toInput" ); |
103 | grid->addWidget( toInput, 0, 1 ); | 105 | grid->addWidget( toInput, 0, 1 ); |
104 | 106 | ||
107 | ccInput = new QLineEdit( widget, "ccInput" ); | ||
108 | ccInput->hide(); | ||
109 | grid->addWidget( ccInput, 0, 1 ); | ||
110 | |||
111 | |||
105 | addressButton = new QToolButton( widget, "addressButton" ); | 112 | addressButton = new QToolButton( widget, "addressButton" ); |
106 | addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); | 113 | addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); |
107 | addressButton->setToggleButton(TRUE); | 114 | addressButton->setToggleButton(TRUE); |
@@ -139,19 +146,31 @@ void WriteMail::accept() | |||
139 | QStringList attatchedFiles, attatchmentsType; | 146 | QStringList attatchedFiles, attatchmentsType; |
140 | int idCount = 0; | 147 | int idCount = 0; |
141 | 148 | ||
142 | if (toInput->text() == "") { | 149 | if (toInput->text() == "") |
143 | QMessageBox::warning(this,"No recipient", "Send mail to whom?", "OK\n"); | 150 | { |
151 | QMessageBox::warning(this,tr("No recipient"), tr("Send mail to whom?"), tr("OK\n")); | ||
152 | return; | ||
153 | } | ||
154 | |||
155 | if (! getRecipients(false) ) | ||
156 | { | ||
157 | QMessageBox::warning(this,tr("Incorrect recipient separator"), | ||
158 | tr("Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); | ||
144 | return; | 159 | return; |
145 | } | 160 | } |
146 | if (! getRecipients() ) { | 161 | |
147 | QMessageBox::warning(this,"Incorrect recipient separator", | 162 | if ((ccInput->text()!="") && (! getRecipients(true) )) |
148 | "Recipients must be separated by ;\nand be valid emailaddresses", "OK\n"); | 163 | { |
164 | QMessageBox::warning(this,tr("Incorrect carbon copy separator"), | ||
165 | tr("CC Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); | ||
149 | return; | 166 | return; |
150 | } | 167 | } |
168 | |||
151 | mail.subject = subjectInput->text(); | 169 | mail.subject = subjectInput->text(); |
152 | mail.body = emailInput->text(); | 170 | mail.body = emailInput->text(); |
153 | mail.sent = false; | 171 | mail.sent = false; |
154 | mail.received = false; | 172 | mail.received = false; |
173 | |||
155 | mail.rawMail = "To: "; | 174 | mail.rawMail = "To: "; |
156 | 175 | ||
157 | for (QStringList::Iterator it = mail.recipients.begin(); | 176 | for (QStringList::Iterator it = mail.recipients.begin(); |
@@ -160,7 +179,18 @@ void WriteMail::accept() | |||
160 | mail.rawMail += (*it); | 179 | mail.rawMail += (*it); |
161 | mail.rawMail += ",\n"; | 180 | mail.rawMail += ",\n"; |
162 | } | 181 | } |
182 | |||
163 | mail.rawMail.truncate(mail.rawMail.length()-2); | 183 | mail.rawMail.truncate(mail.rawMail.length()-2); |
184 | |||
185 | mail.rawMail += "\nCC: "; | ||
186 | |||
187 | for (QStringList::Iterator it = mail.carbonCopies.begin(); | ||
188 | it != mail.carbonCopies.end(); ++it) { | ||
189 | |||
190 | mail.rawMail += (*it); | ||
191 | mail.rawMail += ",\n"; | ||
192 | } | ||
193 | |||
164 | mail.rawMail += mail.from; | 194 | mail.rawMail += mail.from; |
165 | mail.rawMail += "\nSubject: "; | 195 | mail.rawMail += "\nSubject: "; |
166 | mail.rawMail += mail.subject; | 196 | mail.rawMail += mail.subject; |
@@ -211,7 +241,7 @@ void WriteMail::attatchFile() | |||
211 | addAtt->showMaximized(); | 241 | addAtt->showMaximized(); |
212 | } | 242 | } |
213 | 243 | ||
214 | void WriteMail::reply(Email replyMail) | 244 | void WriteMail::reply(Email replyMail, bool replyAll) |
215 | { | 245 | { |
216 | int pos; | 246 | int pos; |
217 | 247 | ||
@@ -219,7 +249,11 @@ void WriteMail::reply(Email replyMail) | |||
219 | mail.files.clear(); | 249 | mail.files.clear(); |
220 | 250 | ||
221 | toInput->setText(mail.fromMail); | 251 | toInput->setText(mail.fromMail); |
222 | subjectInput->setText("Re: " + mail.subject); | 252 | //replyAll ? ccInput->setText(mail.c) |
253 | |||
254 | addRecipients(replyAll); | ||
255 | |||
256 | subjectInput->setText(tr("Re: ") + mail.subject); | ||
223 | 257 | ||
224 | pos = 0; | 258 | pos = 0; |
225 | mail.body.insert(pos, ">>"); | 259 | mail.body.insert(pos, ">>"); |
@@ -232,37 +266,63 @@ void WriteMail::reply(Email replyMail) | |||
232 | emailInput->setText(mail.body); | 266 | emailInput->setText(mail.body); |
233 | } | 267 | } |
234 | 268 | ||
235 | bool WriteMail::getRecipients() | 269 | void WriteMail::forward(Email forwMail) |
270 | { | ||
271 | int pos=0; | ||
272 | |||
273 | QString fwdBody=tr("======forwarded message from "); | ||
274 | fwdBody.append(forwMail.fromMail); | ||
275 | fwdBody.append(tr(" starts======\n\n")); | ||
276 | |||
277 | mail=forwMail; | ||
278 | toInput->setText(""); | ||
279 | ccInput->setText(""); | ||
280 | subjectInput->setText(tr("FWD: ") + mail.subject); | ||
281 | |||
282 | fwdBody+=mail.body; | ||
283 | fwdBody+=QString(tr("======end of forwarded message======\n\n")); | ||
284 | |||
285 | emailInput->setText(fwdBody); | ||
286 | } | ||
287 | |||
288 | bool WriteMail::getRecipients(bool ccField) | ||
236 | { | 289 | { |
237 | QString str, temp; | 290 | QString str, temp; |
238 | int pos = 0; | 291 | int pos = 0; |
239 | 292 | ||
240 | mail.recipients.clear(); | 293 | mail.recipients.clear(); |
241 | 294 | ||
242 | temp = toInput->text(); | 295 | ccField ? temp = ccInput->text() : temp=toInput->text() ; |
296 | |||
243 | while ( (pos = temp.find(';')) != -1) { | 297 | while ( (pos = temp.find(';')) != -1) { |
244 | str = temp.left(pos).stripWhiteSpace(); | 298 | str = temp.left(pos).stripWhiteSpace(); |
245 | temp = temp.right(temp.length() - (pos + 1)); | 299 | temp = temp.right(temp.length() - (pos + 1)); |
246 | if ( str.find('@') == -1) | 300 | if ( str.find('@') == -1) |
247 | return false; | 301 | return false; |
248 | mail.recipients.append(str); | 302 | ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str); |
249 | addressList->addContact(str, ""); | 303 | addressList->addContact(str, ""); |
250 | } | 304 | } |
251 | temp = temp.stripWhiteSpace(); | 305 | temp = temp.stripWhiteSpace(); |
252 | if ( temp.find('@') == -1) | 306 | if ( temp.find('@') == -1) |
253 | return false; | 307 | return false; |
254 | mail.recipients.append(temp); | 308 | ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp); |
255 | addressList->addContact(temp, ""); | 309 | addressList->addContact(temp, ""); |
256 | 310 | ||
257 | return TRUE; | 311 | return TRUE; |
258 | } | 312 | } |
259 | 313 | ||
260 | |||
261 | void WriteMail::addRecipients() | 314 | void WriteMail::addRecipients() |
262 | { | 315 | { |
316 | |||
317 | addRecipients(false); | ||
318 | } | ||
319 | |||
320 | void WriteMail::addRecipients(bool ccField) | ||
321 | { | ||
263 | QString recipients = ""; | 322 | QString recipients = ""; |
264 | 323 | ||
265 | mail.recipients.clear(); | 324 | mail.recipients.clear(); |
325 | |||
266 | QListViewItem *item = addressView->firstChild(); | 326 | QListViewItem *item = addressView->firstChild(); |
267 | while (item != NULL) { | 327 | while (item != NULL) { |
268 | if ( item->isSelected() ) { | 328 | if ( item->isSelected() ) { |
@@ -274,7 +334,8 @@ void WriteMail::addRecipients() | |||
274 | } | 334 | } |
275 | item = item->nextSibling(); | 335 | item = item->nextSibling(); |
276 | } | 336 | } |
277 | toInput->setText(recipients); | 337 | |
338 | ccField ? ccInput->setText(recipients):toInput->setText(recipients); | ||
278 | 339 | ||
279 | addressView->hide(); | 340 | addressView->hide(); |
280 | okButton->hide(); | 341 | okButton->hide(); |
@@ -283,6 +344,20 @@ void WriteMail::addRecipients() | |||
283 | showingAddressList = !showingAddressList; | 344 | showingAddressList = !showingAddressList; |
284 | } | 345 | } |
285 | 346 | ||
347 | void WriteMail::changeRecipients(int selection) | ||
348 | { | ||
349 | if (selection==0) | ||
350 | { | ||
351 | toInput->show(); | ||
352 | ccInput->hide(); | ||
353 | } | ||
354 | else if (selection==1) | ||
355 | { | ||
356 | toInput->hide(); | ||
357 | ccInput->show(); | ||
358 | } | ||
359 | } | ||
360 | |||
286 | void WriteMail::setRecipient(const QString &recipient) | 361 | void WriteMail::setRecipient(const QString &recipient) |
287 | { | 362 | { |
288 | toInput->setText(recipient); | 363 | toInput->setText(recipient); |