Diffstat (limited to 'noncore/net/mailit/writemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mailit/writemail.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/noncore/net/mailit/writemail.cpp b/noncore/net/mailit/writemail.cpp index 0336c83..dcf0c6e 100644 --- a/noncore/net/mailit/writemail.cpp +++ b/noncore/net/mailit/writemail.cpp | |||
@@ -78,122 +78,121 @@ void WriteMail::init() | |||
78 | confirmButton->setWhatsThis(tr("This button puts your mail in the send queue")); | 78 | confirmButton->setWhatsThis(tr("This button puts your mail in the send queue")); |
79 | 79 | ||
80 | newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); | 80 | newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); |
81 | newButton->addTo(mailMenu); | 81 | newButton->addTo(mailMenu); |
82 | connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); | 82 | connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); |
83 | newButton->setWhatsThis(tr("Click here to create a new mail")); | 83 | newButton->setWhatsThis(tr("Click here to create a new mail")); |
84 | 84 | ||
85 | widget = new QWidget(this, "widget"); | 85 | widget = new QWidget(this, "widget"); |
86 | grid = new QGridLayout( widget ); | 86 | grid = new QGridLayout( widget ); |
87 | 87 | ||
88 | recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); | 88 | recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); |
89 | recipientsBox->insertItem( tr( "To:" ) ); | 89 | recipientsBox->insertItem( tr( "To:" ) ); |
90 | recipientsBox->insertItem( tr( "CC:" ) ); | 90 | recipientsBox->insertItem( tr( "CC:" ) ); |
91 | recipientsBox->setCurrentItem(0); | 91 | recipientsBox->setCurrentItem(0); |
92 | grid->addWidget( recipientsBox, 0, 0 ); | 92 | grid->addWidget( recipientsBox, 0, 0 ); |
93 | connect(recipientsBox,SIGNAL(activated(int)),this, SLOT(changeRecipients(int))); | 93 | connect(recipientsBox,SIGNAL(activated(int)),this, SLOT(changeRecipients(int))); |
94 | 94 | ||
95 | subjetLabel = new QLabel( widget, "subjetLabel" ); | 95 | subjetLabel = new QLabel( widget, "subjetLabel" ); |
96 | subjetLabel->setText( tr( "Subject:" ) ); | 96 | subjetLabel->setText( tr( "Subject:" ) ); |
97 | 97 | ||
98 | grid->addWidget( subjetLabel, 1, 0 ); | 98 | grid->addWidget( subjetLabel, 1, 0 ); |
99 | 99 | ||
100 | ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); | 100 | ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); |
101 | ToolButton13_2->setText( tr( "..." ) ); | 101 | ToolButton13_2->setText( tr( "..." ) ); |
102 | grid->addWidget( ToolButton13_2, 1, 2 ); | 102 | grid->addWidget( ToolButton13_2, 1, 2 ); |
103 | 103 | ||
104 | subjectInput = new QLineEdit( widget, "subjectInput" ); | 104 | subjectInput = new QLineEdit( widget, "subjectInput" ); |
105 | grid->addWidget( subjectInput, 1, 1 ); | 105 | grid->addWidget( subjectInput, 1, 1 ); |
106 | QWhatsThis::add(subjectInput,QWidget::tr("The mail subject should be entered here")); | 106 | QWhatsThis::add(subjectInput,QWidget::tr("The mail subject should be entered here")); |
107 | 107 | ||
108 | toInput = new QLineEdit( widget, "toInput" ); | 108 | toInput = new QLineEdit( widget, "toInput" ); |
109 | grid->addWidget( toInput, 0, 1 ); | 109 | grid->addWidget( toInput, 0, 1 ); |
110 | QWhatsThis::add(recipientsBox,QWidget::tr("Recipients can be entered here")); | 110 | QWhatsThis::add(recipientsBox,QWidget::tr("Recipients can be entered here")); |
111 | 111 | ||
112 | ccInput = new QLineEdit( widget, "ccInput" ); | 112 | ccInput = new QLineEdit( widget, "ccInput" ); |
113 | ccInput->hide(); | 113 | ccInput->hide(); |
114 | grid->addWidget( ccInput, 0, 1 ); | 114 | grid->addWidget( ccInput, 0, 1 ); |
115 | QWhatsThis::add(ccInput,QWidget::tr("If you would like to send copies of your mail they can be entered here")); | 115 | QWhatsThis::add(ccInput,QWidget::tr("If you would like to send copies of your mail they can be entered here")); |
116 | 116 | ||
117 | addressButton = new QToolButton( widget, "addressButton" ); | 117 | addressButton = new QToolButton( widget, "addressButton" ); |
118 | addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); | 118 | addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); |
119 | addressButton->setToggleButton(TRUE); | 119 | addressButton->setToggleButton(TRUE); |
120 | grid->addWidget( addressButton, 0, 2 ); | 120 | grid->addWidget( addressButton, 0, 2 ); |
121 | connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); | 121 | connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); |
122 | QWhatsThis::add(addressButton,QWidget::tr("This button opens the address selector with all mail adresses from your OPIE addressbook")); | 122 | QWhatsThis::add(addressButton,QWidget::tr("This button opens the address selector with all mail adresses from your OPIE addressbook")); |
123 | 123 | ||
124 | emailInput = new QMultiLineEdit( widget, "emailInput" ); | 124 | emailInput = new QMultiLineEdit( widget, "emailInput" ); |
125 | grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); | 125 | grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); |
126 | QWhatsThis::add(recipientsBox,QWidget::tr("Enter your mail text here")); | 126 | QWhatsThis::add(emailInput,QWidget::tr("Enter your mail text here")); |
127 | 127 | ||
128 | addressView = new QListView( widget, "addressView"); | 128 | addressView = new QListView( widget, "addressView"); |
129 | addressView->addColumn("Name"); | 129 | addressView->addColumn("Name"); |
130 | addressView->addColumn("EMail"); | 130 | addressView->addColumn("EMail"); |
131 | addressView->setAllColumnsShowFocus(TRUE); | 131 | addressView->setAllColumnsShowFocus(TRUE); |
132 | addressView->setMultiSelection(TRUE); | 132 | addressView->setMultiSelection(TRUE); |
133 | addressView->hide(); | 133 | addressView->hide(); |
134 | grid->addMultiCellWidget( addressView, 3, 3, 0, 2); | 134 | grid->addMultiCellWidget( addressView, 3, 3, 0, 2); |
135 | QWhatsThis::add(recipientsBox,QWidget::tr("Chose the recipients from this list")); | 135 | QWhatsThis::add(recipientsBox,QWidget::tr("Choose the recipients from this list")); |
136 | 136 | ||
137 | okButton = new QToolButton(bar, "ok"); | 137 | okButton = new QToolButton(bar, "ok"); |
138 | okButton->setPixmap( Resource::loadPixmap("enter") ); | 138 | okButton->setPixmap( Resource::loadPixmap("enter") ); |
139 | okButton->hide(); | 139 | okButton->hide(); |
140 | connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); | 140 | connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); |
141 | QWhatsThis::add(okButton,QWidget::tr("Queue your mail by clicking here")); | 141 | QWhatsThis::add(okButton,QWidget::tr("Queue your mail by clicking here")); |
142 | 142 | ||
143 | setCentralWidget(widget); | 143 | setCentralWidget(widget); |
144 | } | 144 | } |
145 | 145 | ||
146 | void WriteMail::reject() | 146 | void WriteMail::reject() |
147 | { | 147 | { |
148 | emit cancelMail(); | 148 | emit cancelMail(); |
149 | } | 149 | } |
150 | 150 | ||
151 | // need to insert date | ||
152 | void WriteMail::accept() | 151 | void WriteMail::accept() |
153 | { | 152 | { |
154 | QStringList attachedFiles, attachmentsType; | 153 | QStringList attachedFiles, attachmentsType; |
155 | int idCount = 0; | 154 | int idCount = 0; |
156 | 155 | ||
157 | if (toInput->text() == "") | 156 | if (toInput->text() == "") |
158 | { | 157 | { |
159 | QMessageBox::warning(this,tr("No recipient"), tr("Send mail to whom?"), tr("OK\n")); | 158 | QMessageBox::warning(this,tr("No recipient"), tr("Send mail to whom?"), tr("OK\n")); |
160 | return; | 159 | return; |
161 | } | 160 | } |
162 | 161 | ||
163 | if (! getRecipients(false) ) | 162 | if (! getRecipients(false) ) |
164 | { | 163 | { |
165 | QMessageBox::warning(this,tr("Incorrect recipient separator"), | 164 | QMessageBox::warning(this,tr("Incorrect recipient separator"), |
166 | tr("Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); | 165 | tr("Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); |
167 | return; | 166 | return; |
168 | } | 167 | } |
169 | 168 | ||
170 | if ((ccInput->text()!="") && (! getRecipients(true) )) | 169 | if ((ccInput->text()!="") && (! getRecipients(true) )) |
171 | { | 170 | { |
172 | QMessageBox::warning(this,tr("Incorrect carbon copy separator"), | 171 | QMessageBox::warning(this,tr("Incorrect carbon copy separator"), |
173 | tr("CC Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); | 172 | tr("CC Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); |
174 | return; | 173 | return; |
175 | } | 174 | } |
176 | 175 | ||
177 | mail.subject = subjectInput->text(); | 176 | mail.subject = subjectInput->text(); |
178 | mail.body = emailInput->text(); | 177 | mail.body = emailInput->text(); |
179 | mail.sent = false; | 178 | mail.sent = false; |
180 | mail.received = false; | 179 | mail.received = false; |
181 | 180 | ||
182 | mail.rawMail = "To: "; | 181 | mail.rawMail = "To: "; |
183 | 182 | ||
184 | for (QStringList::Iterator it = mail.recipients.begin(); | 183 | for (QStringList::Iterator it = mail.recipients.begin(); |
185 | it != mail.recipients.end(); ++it) { | 184 | it != mail.recipients.end(); ++it) { |
186 | 185 | ||
187 | mail.rawMail += (*it); | 186 | mail.rawMail += (*it); |
188 | mail.rawMail += ",\n"; | 187 | mail.rawMail += ",\n"; |
189 | } | 188 | } |
190 | 189 | ||
191 | mail.rawMail.truncate(mail.rawMail.length()-2); | 190 | mail.rawMail.truncate(mail.rawMail.length()-2); |
192 | 191 | ||
193 | mail.rawMail += "\nCC: "; | 192 | mail.rawMail += "\nCC: "; |
194 | 193 | ||
195 | for (QStringList::Iterator it = mail.carbonCopies.begin(); | 194 | for (QStringList::Iterator it = mail.carbonCopies.begin(); |
196 | it != mail.carbonCopies.end(); ++it) { | 195 | it != mail.carbonCopies.end(); ++it) { |
197 | 196 | ||
198 | mail.rawMail += (*it); | 197 | mail.rawMail += (*it); |
199 | mail.rawMail += ",\n"; | 198 | mail.rawMail += ",\n"; |
@@ -207,175 +206,184 @@ void WriteMail::accept() | |||
207 | attachedFiles = addAtt->returnattachedFiles(); | 206 | attachedFiles = addAtt->returnattachedFiles(); |
208 | attachmentsType = addAtt->returnFileTypes(); | 207 | attachmentsType = addAtt->returnFileTypes(); |
209 | 208 | ||
210 | QStringList::Iterator itType = attachmentsType.begin(); | 209 | QStringList::Iterator itType = attachmentsType.begin(); |
211 | 210 | ||
212 | Enclosure e; | 211 | Enclosure e; |
213 | for ( QStringList::Iterator it = attachedFiles.begin(); it != attachedFiles.end(); ++it ) { | 212 | for ( QStringList::Iterator it = attachedFiles.begin(); it != attachedFiles.end(); ++it ) { |
214 | e.id = idCount; | 213 | e.id = idCount; |
215 | e.originalName = (*it).latin1(); | 214 | e.originalName = (*it).latin1(); |
216 | e.contentType = (*itType).latin1(); | 215 | e.contentType = (*itType).latin1(); |
217 | e.contentAttribute = (*itType).latin1(); | 216 | e.contentAttribute = (*itType).latin1(); |
218 | e.saved = TRUE; | 217 | e.saved = TRUE; |
219 | mail.addEnclosure(&e); | 218 | mail.addEnclosure(&e); |
220 | 219 | ||
221 | itType++; | 220 | itType++; |
222 | idCount++; | 221 | idCount++; |
223 | } | 222 | } |
224 | mail.rawMail += mail.body; | 223 | mail.rawMail += mail.body; |
225 | mail.rawMail += "\n"; | 224 | mail.rawMail += "\n"; |
226 | mail.rawMail += ".\n"; | 225 | mail.rawMail += ".\n"; |
227 | emit sendMailRequested(mail); | 226 | emit sendMailRequested(mail); |
228 | addAtt->clear(); | 227 | addAtt->clear(); |
229 | } | 228 | } |
230 | 229 | ||
231 | void WriteMail::getAddress() | 230 | void WriteMail::getAddress() |
232 | { | 231 | { |
233 | showingAddressList = !showingAddressList; | 232 | showingAddressList = !showingAddressList; |
234 | 233 | ||
235 | if (showingAddressList) { | 234 | if (showingAddressList) { |
236 | emailInput->hide(); | 235 | emailInput->hide(); |
237 | addressView->show(); | 236 | addressView->show(); |
238 | okButton->show(); | 237 | okButton->show(); |
239 | 238 | ||
240 | } else { | 239 | } else { |
241 | addressView->hide(); | 240 | addressView->hide(); |
242 | okButton->hide(); | 241 | okButton->hide(); |
243 | emailInput->show(); | 242 | emailInput->show(); |
244 | } | 243 | } |
245 | } | 244 | } |
246 | 245 | ||
247 | void WriteMail::attachFile() | 246 | void WriteMail::attachFile() |
248 | { | 247 | { |
249 | addAtt->showMaximized(); | 248 | addAtt->showMaximized(); |
250 | } | 249 | } |
251 | 250 | ||
252 | void WriteMail::reply(Email replyMail, bool replyAll) | 251 | void WriteMail::reply(Email replyMail, bool replyAll) |
253 | { | 252 | { |
254 | int pos; | 253 | int pos; |
254 | QString ccRecipients; | ||
255 | 255 | ||
256 | mail = replyMail; | 256 | mail = replyMail; |
257 | mail.files.clear(); | 257 | mail.files.clear(); |
258 | 258 | ||
259 | toInput->setText(mail.fromMail); | 259 | toInput->setText(mail.fromMail); |
260 | //replyAll ? ccInput->setText(mail.c) | ||
261 | 260 | ||
261 | if (replyAll) | ||
262 | { | ||
263 | for (QStringList::Iterator it = mail.carbonCopies.begin();it != mail.carbonCopies.end(); ++it) | ||
264 | { | ||
265 | ccRecipients.append(*it); | ||
266 | ccRecipients.append(";"); | ||
267 | } | ||
268 | ccRecipients.truncate(ccRecipients.length()-1); //no ; at the end | ||
269 | ccInput->setText(ccRecipients); | ||
270 | } | ||
271 | |||
262 | addRecipients(replyAll); | 272 | addRecipients(replyAll); |
263 | 273 | ||
264 | subjectInput->setText(tr("Re: ") + mail.subject); | 274 | subjectInput->setText(tr("Re: ") + mail.subject); |
265 | 275 | ||
266 | pos = 0; | 276 | pos = 0; |
267 | mail.body.insert(pos, ">"); | 277 | mail.body.insert(pos, ">"); |
268 | while (pos != -1) { | 278 | while (pos != -1) { |
269 | pos = mail.body.find('\n', pos); | 279 | pos = mail.body.find('\n', pos); |
270 | if (pos != -1) | 280 | if (pos != -1) |
271 | mail.body.insert(++pos, ">>"); | 281 | mail.body.insert(++pos, ">>"); |
272 | } | 282 | } |
273 | 283 | ||
274 | emailInput->setText(mail.body); | 284 | emailInput->setText(mail.body); |
275 | } | 285 | } |
276 | 286 | ||
277 | void WriteMail::forward(Email forwMail) | 287 | void WriteMail::forward(Email forwMail) |
278 | { | 288 | { |
279 | int pos=0; | 289 | int pos=0; |
280 | 290 | ||
281 | QString fwdBody=tr("======forwarded message from "); | 291 | QString fwdBody=tr("======forwarded message from "); |
282 | fwdBody.append(forwMail.fromMail); | 292 | fwdBody.append(forwMail.fromMail); |
283 | fwdBody.append(tr(" starts======\n\n")); | 293 | fwdBody.append(tr(" starts======\n\n")); |
284 | 294 | ||
285 | mail=forwMail; | 295 | mail=forwMail; |
286 | toInput->setText(""); | 296 | toInput->setText(""); |
287 | ccInput->setText(""); | 297 | ccInput->setText(""); |
288 | subjectInput->setText(tr("FWD: ") + mail.subject); | 298 | subjectInput->setText(tr("FWD: ") + mail.subject); |
289 | 299 | ||
290 | fwdBody+=mail.body; | 300 | fwdBody+=mail.body; |
291 | fwdBody+=QString(tr("======end of forwarded message======\n\n")); | 301 | fwdBody+=QString(tr("======end of forwarded message======\n\n")); |
292 | 302 | ||
293 | emailInput->setText(fwdBody); | 303 | emailInput->setText(fwdBody); |
294 | } | 304 | } |
295 | 305 | ||
296 | bool WriteMail::getRecipients(bool ccField) | 306 | bool WriteMail::getRecipients(bool ccField) |
297 | { | 307 | { |
298 | QString str, temp; | 308 | QString str, temp; |
299 | int pos = 0; | 309 | int pos = 0; |
300 | 310 | ||
301 | mail.recipients.clear(); | 311 | mail.recipients.clear(); |
302 | 312 | ||
303 | ccField ? temp = ccInput->text() : temp=toInput->text() ; | 313 | ccField ? temp = ccInput->text() : temp=toInput->text() ; |
304 | 314 | ||
305 | while ( (pos = temp.find(';')) != -1) { | 315 | while ( (pos = temp.find(';')) != -1) { |
306 | str = temp.left(pos).stripWhiteSpace(); | 316 | str = temp.left(pos).stripWhiteSpace(); |
307 | temp = temp.right(temp.length() - (pos + 1)); | 317 | temp = temp.right(temp.length() - (pos + 1)); |
308 | if ( str.find('@') == -1) | 318 | if ( str.find('@') == -1) |
309 | return false; | 319 | return false; |
310 | ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str); | 320 | ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str); |
311 | addressList->addContact(str, ""); | 321 | addressList->addContact(str, ""); |
312 | } | 322 | } |
313 | temp = temp.stripWhiteSpace(); | 323 | temp = temp.stripWhiteSpace(); |
314 | if ( temp.find('@') == -1) | 324 | if ( temp.find('@') == -1) |
315 | return false; | 325 | return false; |
316 | ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp); | 326 | ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp); |
317 | addressList->addContact(temp, ""); | 327 | addressList->addContact(temp, ""); |
318 | 328 | ||
319 | return TRUE; | 329 | return TRUE; |
320 | } | 330 | } |
321 | 331 | ||
322 | void WriteMail::addRecipients() | 332 | void WriteMail::addRecipients() |
323 | { | 333 | { |
324 | 334 | toInput->isVisible() ? addRecipients(false) : addRecipients(true); | |
325 | addRecipients(false); | ||
326 | } | 335 | } |
327 | 336 | ||
328 | void WriteMail::addRecipients(bool ccField) | 337 | void WriteMail::addRecipients(bool ccField) |
329 | { | 338 | { |
330 | QString recipients = ""; | 339 | QString recipients = ""; |
331 | 340 | ||
332 | mail.recipients.clear(); | 341 | mail.recipients.clear(); |
333 | 342 | ||
334 | QListViewItem *item = addressView->firstChild(); | 343 | QListViewItem *item = addressView->firstChild(); |
335 | while (item != NULL) { | 344 | while (item != NULL) { |
336 | if ( item->isSelected() ) { | 345 | if ( item->isSelected() ) { |
337 | if (recipients == "") { | 346 | if (recipients == "") { |
338 | recipients = item->text(0); | 347 | recipients = item->text(1); |
339 | } else { | 348 | } else { |
340 | recipients += "; " + item->text(0); | 349 | recipients += "; " + item->text(1); |
341 | } | 350 | } |
342 | } | 351 | } |
343 | item = item->nextSibling(); | 352 | item = item->nextSibling(); |
344 | } | 353 | } |
345 | 354 | ||
346 | ccField ? ccInput->setText(recipients):toInput->setText(recipients); | 355 | ccField ? ccInput->setText(recipients):toInput->setText(recipients); |
347 | 356 | ||
348 | addressView->hide(); | 357 | addressView->hide(); |
349 | okButton->hide(); | 358 | okButton->hide(); |
350 | emailInput->show(); | 359 | emailInput->show(); |
351 | addressButton->setOn(FALSE); | 360 | addressButton->setOn(FALSE); |
352 | showingAddressList = !showingAddressList; | 361 | showingAddressList = !showingAddressList; |
353 | } | 362 | } |
354 | 363 | ||
355 | void WriteMail::changeRecipients(int selection) | 364 | void WriteMail::changeRecipients(int selection) |
356 | { | 365 | { |
357 | if (selection==0) | 366 | if (selection==0) |
358 | { | 367 | { |
359 | toInput->show(); | 368 | toInput->show(); |
360 | ccInput->hide(); | 369 | ccInput->hide(); |
361 | } | 370 | } |
362 | else if (selection==1) | 371 | else if (selection==1) |
363 | { | 372 | { |
364 | toInput->hide(); | 373 | toInput->hide(); |
365 | ccInput->show(); | 374 | ccInput->show(); |
366 | } | 375 | } |
367 | } | 376 | } |
368 | 377 | ||
369 | void WriteMail::setRecipient(const QString &recipient) | 378 | void WriteMail::setRecipient(const QString &recipient) |
370 | { | 379 | { |
371 | toInput->setText(recipient); | 380 | toInput->setText(recipient); |
372 | } | 381 | } |
373 | 382 | ||
374 | void WriteMail::newMail() | 383 | void WriteMail::newMail() |
375 | { | 384 | { |
376 | toInput->clear(); | 385 | toInput->clear(); |
377 | subjectInput->clear(); | 386 | subjectInput->clear(); |
378 | emailInput->clear(); | 387 | emailInput->clear(); |
379 | //to clear selected | ||
380 | setAddressList(addressList); | 388 | setAddressList(addressList); |
381 | } | 389 | } |