author | groucho <groucho> | 2003-04-20 07:59:48 (UTC) |
---|---|---|
committer | groucho <groucho> | 2003-04-20 07:59:48 (UTC) |
commit | 8b85cba50912127ff6a2d048021baf68306481c6 (patch) (unidiff) | |
tree | bfd1b377911d05db8e1c816f72fe070d5a5b2ff3 /noncore/unsupported/mailit/writemail.cpp | |
parent | 6b381e438fdeb1757b3278c683349dee9c4ab230 (diff) | |
download | opie-8b85cba50912127ff6a2d048021baf68306481c6.zip opie-8b85cba50912127ff6a2d048021baf68306481c6.tar.gz opie-8b85cba50912127ff6a2d048021baf68306481c6.tar.bz2 |
- Added CC: support
- Added mail forwarding
- Added icon for selective mail download
- Removing mails from mail list via icon
- Temporarily disabled mail header download queue
Diffstat (limited to 'noncore/unsupported/mailit/writemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/mailit/writemail.cpp | 103 |
1 files changed, 89 insertions, 14 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 | |||
@@ -74,43 +74,50 @@ void WriteMail::init() | |||
74 | confirmButton->addTo(mailMenu); | 74 | confirmButton->addTo(mailMenu); |
75 | connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); | 75 | connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); |
76 | 76 | ||
77 | newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); | 77 | newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); |
78 | newButton->addTo(mailMenu); | 78 | newButton->addTo(mailMenu); |
79 | connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); | 79 | connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); |
80 | 80 | ||
81 | widget = new QWidget(this, "widget"); | 81 | widget = new QWidget(this, "widget"); |
82 | grid = new QGridLayout( widget ); | 82 | grid = new QGridLayout( widget ); |
83 | 83 | ||
84 | recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); | 84 | recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); |
85 | recipientsBox->insertItem( tr( "To:" ) ); | 85 | recipientsBox->insertItem( tr( "To:" ) ); |
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:" ) ); |
92 | 94 | ||
93 | grid->addWidget( subjetLabel, 1, 0 ); | 95 | grid->addWidget( subjetLabel, 1, 0 ); |
94 | 96 | ||
95 | ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); | 97 | ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); |
96 | ToolButton13_2->setText( tr( "..." ) ); | 98 | ToolButton13_2->setText( tr( "..." ) ); |
97 | grid->addWidget( ToolButton13_2, 1, 2 ); | 99 | grid->addWidget( ToolButton13_2, 1, 2 ); |
98 | 100 | ||
99 | subjectInput = new QLineEdit( widget, "subjectInput" ); | 101 | subjectInput = new QLineEdit( widget, "subjectInput" ); |
100 | grid->addWidget( subjectInput, 1, 1 ); | 102 | grid->addWidget( subjectInput, 1, 1 ); |
101 | 103 | ||
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); |
108 | grid->addWidget( addressButton, 0, 2 ); | 115 | grid->addWidget( addressButton, 0, 2 ); |
109 | connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); | 116 | connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); |
110 | 117 | ||
111 | emailInput = new QMultiLineEdit( widget, "emailInput" ); | 118 | emailInput = new QMultiLineEdit( widget, "emailInput" ); |
112 | grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); | 119 | grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); |
113 | 120 | ||
114 | 121 | ||
115 | addressView = new QListView( widget, "addressView"); | 122 | addressView = new QListView( widget, "addressView"); |
116 | addressView->addColumn("Name"); | 123 | addressView->addColumn("Name"); |
@@ -130,46 +137,69 @@ void WriteMail::init() | |||
130 | 137 | ||
131 | void WriteMail::reject() | 138 | void WriteMail::reject() |
132 | { | 139 | { |
133 | emit cancelMail(); | 140 | emit cancelMail(); |
134 | } | 141 | } |
135 | 142 | ||
136 | // need to insert date | 143 | // need to insert date |
137 | void WriteMail::accept() | 144 | void WriteMail::accept() |
138 | { | 145 | { |
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(); |
158 | it != mail.recipients.end(); ++it) { | 177 | it != mail.recipients.end(); ++it) { |
159 | 178 | ||
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; |
167 | mail.rawMail += "\n\n"; | 197 | mail.rawMail += "\n\n"; |
168 | 198 | ||
169 | attatchedFiles = addAtt->returnAttatchedFiles(); | 199 | attatchedFiles = addAtt->returnAttatchedFiles(); |
170 | attatchmentsType = addAtt->returnFileTypes(); | 200 | attatchmentsType = addAtt->returnFileTypes(); |
171 | 201 | ||
172 | QStringList::Iterator itType = attatchmentsType.begin(); | 202 | QStringList::Iterator itType = attatchmentsType.begin(); |
173 | 203 | ||
174 | Enclosure e; | 204 | Enclosure e; |
175 | for ( QStringList::Iterator it = attatchedFiles.begin(); it != attatchedFiles.end(); ++it ) { | 205 | for ( QStringList::Iterator it = attatchedFiles.begin(); it != attatchedFiles.end(); ++it ) { |
@@ -202,96 +232,141 @@ void WriteMail::getAddress() | |||
202 | } else { | 232 | } else { |
203 | addressView->hide(); | 233 | addressView->hide(); |
204 | okButton->hide(); | 234 | okButton->hide(); |
205 | emailInput->show(); | 235 | emailInput->show(); |
206 | } | 236 | } |
207 | } | 237 | } |
208 | 238 | ||
209 | void WriteMail::attatchFile() | 239 | void WriteMail::attatchFile() |
210 | { | 240 | { |
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 | ||
218 | mail = replyMail; | 248 | mail = 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, ">>"); |
226 | while (pos != -1) { | 260 | while (pos != -1) { |
227 | pos = mail.body.find('\n', pos); | 261 | pos = mail.body.find('\n', pos); |
228 | if (pos != -1) | 262 | if (pos != -1) |
229 | mail.body.insert(++pos, ">>"); | 263 | mail.body.insert(++pos, ">>"); |
230 | } | 264 | } |
231 | 265 | ||
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 | |||
260 | 313 | ||
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() ) { |
269 | if (recipients == "") { | 329 | if (recipients == "") { |
270 | recipients = item->text(0); | 330 | recipients = item->text(0); |
271 | } else { | 331 | } else { |
272 | recipients += "; " + item->text(0); | 332 | recipients += "; " + item->text(0); |
273 | } | 333 | } |
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(); |
281 | emailInput->show(); | 342 | emailInput->show(); |
282 | addressButton->setOn(FALSE); | 343 | addressButton->setOn(FALSE); |
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); |
289 | } | 364 | } |
290 | 365 | ||
291 | void WriteMail::newMail() | 366 | void WriteMail::newMail() |
292 | { | 367 | { |
293 | toInput->clear(); | 368 | toInput->clear(); |
294 | subjectInput->clear(); | 369 | subjectInput->clear(); |
295 | emailInput->clear(); | 370 | emailInput->clear(); |
296 | //to clear selected | 371 | //to clear selected |
297 | setAddressList(addressList); | 372 | setAddressList(addressList); |