summaryrefslogtreecommitdiff
authortille <tille>2002-06-19 13:06:57 (UTC)
committer tille <tille>2002-06-19 13:06:57 (UTC)
commit8d6e1b42d3b5b8dc376f0979d9f4363d9a6c6970 (patch) (unidiff)
tree35b6166a07f887b262b784947caec9a0c2e4dabe
parent2bcd7302e4e156ad5f389b23c01a690917abee01 (diff)
downloadopie-8d6e1b42d3b5b8dc376f0979d9f4363d9a6c6970.zip
opie-8d6e1b42d3b5b8dc376f0979d9f4363d9a6c6970.tar.gz
opie-8d6e1b42d3b5b8dc376f0979d9f4363d9a6c6970.tar.bz2
fixed error while sending queue
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/mail2/composer.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/noncore/unsupported/mail2/composer.cpp b/noncore/unsupported/mail2/composer.cpp
index 03dacae..52ebbdd 100644
--- a/noncore/unsupported/mail2/composer.cpp
+++ b/noncore/unsupported/mail2/composer.cpp
@@ -1,415 +1,420 @@
1#include <qmultilineedit.h> 1#include <qmultilineedit.h>
2#include <qmessagebox.h> 2#include <qmessagebox.h>
3#include <qpopupmenu.h> 3#include <qpopupmenu.h>
4#include <qcombobox.h> 4#include <qcombobox.h>
5#include <qlineedit.h> 5#include <qlineedit.h>
6#include <qaction.h> 6#include <qaction.h>
7#include <qtimer.h> 7#include <qtimer.h>
8#include <qlabel.h> 8#include <qlabel.h>
9#include <qapplication.h> 9#include <qapplication.h>
10 10
11#include <qpe/resource.h> 11#include <qpe/resource.h>
12#include <qpe/config.h> 12#include <qpe/config.h>
13 13
14#include <opie/ofiledialog.h> 14#include <opie/ofiledialog.h>
15//#include "attachdiag.h" 15//#include "attachdiag.h"
16 16
17#include "addresspicker.h" 17#include "addresspicker.h"
18#include "listviewplus.h" 18#include "listviewplus.h"
19#include "smtphandler.h" 19#include "smtphandler.h"
20#include "composer.h" 20#include "composer.h"
21#include "rename.h" 21#include "rename.h"
22 22
23AttachViewItem::AttachViewItem(QListView *parent, Attachment &attachment) 23AttachViewItem::AttachViewItem(QListView *parent, Attachment &attachment)
24 : QListViewItem(parent), _attachment(attachment) 24 : QListViewItem(parent), _attachment(attachment)
25{ 25{
26 setPixmap(0, _attachment.docLnk().pixmap().isNull() ? Resource::loadPixmap("UnknownDocument-14") : _attachment.docLnk().pixmap()); 26 setPixmap(0, _attachment.docLnk().pixmap().isNull() ? Resource::loadPixmap("UnknownDocument-14") : _attachment.docLnk().pixmap());
27 setText(0, _attachment.newName().isEmpty() ? _attachment.fileName() : _attachment.newName()); 27 setText(0, _attachment.newName().isEmpty() ? _attachment.fileName() : _attachment.newName());
28 setText(1, _attachment.description()); 28 setText(1, _attachment.description());
29} 29}
30 30
31Composer::Composer(QWidget *parent, const char *name, WFlags fl, bool sendQueue) 31Composer::Composer(QWidget *parent, const char *name, WFlags fl, bool sendQueue)
32 : ComposerBase(parent, name, fl), _inLoop(false) 32 : ComposerBase(parent, name, fl), _inLoop(false)
33{ 33{
34 _sendQueued = sendQueue; 34 _sendQueued = sendQueue;
35 abort->setEnabled(false); 35 abort->setEnabled(false);
36 to->setFocus(); 36 to->setFocus();
37 37
38 connect(sendmail, SIGNAL(activated()), SLOT(slotSendMail())); 38 connect(sendmail, SIGNAL(activated()), SLOT(slotSendMail()));
39 connect(queuemail, SIGNAL(activated()), SLOT(slotQueueMail())); 39 connect(queuemail, SIGNAL(activated()), SLOT(slotQueueMail()));
40 connect(addressbook, SIGNAL(activated()), SLOT(slotOpenAddressPicker())); 40 connect(addressbook, SIGNAL(activated()), SLOT(slotOpenAddressPicker()));
41 connect(addattach, SIGNAL(activated()), SLOT(slotAddAttach())); 41 connect(addattach, SIGNAL(activated()), SLOT(slotAddAttach()));
42 connect(delattach, SIGNAL(activated()), SLOT(slotDelAttach())); 42 connect(delattach, SIGNAL(activated()), SLOT(slotDelAttach()));
43 43
44 connect(from, SIGNAL(activated(int)), SLOT(slotFromChanged(int))); 44 connect(from, SIGNAL(activated(int)), SLOT(slotFromChanged(int)));
45 45
46 connect(attachPopup, SIGNAL(activated(int)), SLOT(slotPopupHandler(int))); 46 connect(attachPopup, SIGNAL(activated(int)), SLOT(slotPopupHandler(int)));
47 47
48 QTimer::singleShot(0, this, SLOT(slotFillStuff())); 48 QTimer::singleShot(0, this, SLOT(slotFillStuff()));
49 QTimer::singleShot(0, this, SLOT(slotResizing())); 49 QTimer::singleShot(0, this, SLOT(slotResizing()));
50 50
51} 51}
52 52
53Composer::~Composer() 53Composer::~Composer()
54{ 54{
55 hide(); 55 hide();
56} 56}
57 57
58void Composer::hide() 58void Composer::hide()
59{ 59{
60 QWidget::hide(); 60 QWidget::hide();
61 61
62 if (_inLoop) { 62 if (_inLoop) {
63 _inLoop = false; 63 _inLoop = false;
64 qApp->exit_loop(); 64 qApp->exit_loop();
65 } 65 }
66} 66}
67 67
68void Composer::exec() 68void Composer::exec()
69{ 69{
70 show(); 70 show();
71 if (!_inLoop) { 71 if (!_inLoop) {
72 _inLoop = true; 72 _inLoop = true;
73 qApp->enter_loop(); 73 qApp->enter_loop();
74 } 74 }
75} 75}
76 76
77void Composer::setSendMail(SendMail &sendMail) 77void Composer::setSendMail(SendMail &sendMail)
78{ 78{
79 to->setText(sendMail.to()); 79 to->setText(sendMail.to());
80 cc->setText(sendMail.cc()); 80 cc->setText(sendMail.cc());
81 bcc->setText(sendMail.bcc()); 81 bcc->setText(sendMail.bcc());
82 subject->setText(sendMail.subject()); 82 subject->setText(sendMail.subject());
83 message->setText(sendMail.message()); 83 message->setText(sendMail.message());
84 _inReplyTo = sendMail.inReplyTo(); 84 _inReplyTo = sendMail.inReplyTo();
85 85
86 QValueList<Attachment> attachments = sendMail.attachments(); 86 QValueList<Attachment> attachments = sendMail.attachments();
87 QValueList<Attachment>::Iterator it; 87 QValueList<Attachment>::Iterator it;
88 for (it = attachments.begin(); it != attachments.end(); it++) { 88 for (it = attachments.begin(); it != attachments.end(); it++) {
89 (void) new AttachViewItem(attachView, *it); 89 (void) new AttachViewItem(attachView, *it);
90 if (attachView->isHidden()) attachView->show(); 90 if (attachView->isHidden()) attachView->show();
91 } 91 }
92} 92}
93 93
94void Composer::slotResizing() 94void Composer::slotResizing()
95{ 95{
96 from->setMaximumWidth(width() - fromBox->width()); 96 from->setMaximumWidth(width() - fromBox->width());
97 from->resize(width() - fromBox->width(), y()); 97 from->resize(width() - fromBox->width(), y());
98 if (_sendQueued) slotSendQueued(); 98 if (_sendQueued) slotSendQueued();
99} 99}
100 100
101void Composer::slotPopupHandler(int itemid) 101void Composer::slotPopupHandler(int itemid)
102{ 102{
103 if (attachView->currentItem() == NULL) { 103 if (attachView->currentItem() == NULL) {
104 QMessageBox::information(this, tr("Error"), tr("Please select an entry first."), tr("Ok")); 104 QMessageBox::information(this, tr("Error"), tr("Please select an entry first."), tr("Ok"));
105 return; 105 return;
106 } 106 }
107 107
108 if (itemid == POPUP_ATTACH_RENAME) { 108 if (itemid == POPUP_ATTACH_RENAME) {
109 QString tmp = Rename::rename(attachView->currentItem()->text(0), this); 109 QString tmp = Rename::rename(attachView->currentItem()->text(0), this);
110 if (tmp != QString(0)) attachView->currentItem()->setText(0, tmp); 110 if (tmp != QString(0)) attachView->currentItem()->setText(0, tmp);
111 } else if (itemid == POPUP_ATTACH_DESC) { 111 } else if (itemid == POPUP_ATTACH_DESC) {
112 QString tmp = Rename::getText(tr("Set Description"), tr("<div align=center>Description"), this); 112 QString tmp = Rename::getText(tr("Set Description"), tr("<div align=center>Description"), this);
113 if (tmp != QString(0)) attachView->currentItem()->setText(1, tmp); 113 if (tmp != QString(0)) attachView->currentItem()->setText(1, tmp);
114 } else if (itemid == POPUP_ATTACH_REMOVE) { 114 } else if (itemid == POPUP_ATTACH_REMOVE) {
115 attachView->takeItem(attachView->currentItem()); 115 attachView->takeItem(attachView->currentItem());
116 } 116 }
117} 117}
118 118
119void Composer::slotSendMail() 119void Composer::slotSendMail()
120{ 120{
121 if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) { 121 if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) {
122 QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok")); 122 QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok"));
123 return; 123 return;
124 } 124 }
125 125
126 SendMail smail; 126 SendMail smail;
127 smail.setFrom(from->currentText()); 127 smail.setFrom(from->currentText());
128 smail.setReplyTo(replyto->text()); 128 smail.setReplyTo(replyto->text());
129 smail.setTo(to->text()); 129 smail.setTo(to->text());
130 smail.setCc(cc->text()); 130 smail.setCc(cc->text());
131 smail.setBcc(bcc->text()); 131 smail.setBcc(bcc->text());
132 smail.setSubject(subject->text()); 132 smail.setSubject(subject->text());
133 smail.setMessage(message->text()); 133 smail.setMessage(message->text());
134 smail.setNeedsMime(attachView->childCount() == 0 ? false : true); 134 smail.setNeedsMime(attachView->childCount() == 0 ? false : true);
135 smail.setAccount(accountsLoaded[from->currentItem()]); 135 smail.setAccount(accountsLoaded[from->currentItem()]);
136 136
137 if (priority->currentItem() == POPUP_PRIO_LOW) { 137 if (priority->currentItem() == POPUP_PRIO_LOW) {
138 smail.setPriority("Low");// No i18n on purpose 138 smail.setPriority("Low");// No i18n on purpose
139 } else if (priority->currentItem() == POPUP_PRIO_NORMAL) { 139 } else if (priority->currentItem() == POPUP_PRIO_NORMAL) {
140 smail.setPriority("Normal");// No i18n on purpose 140 smail.setPriority("Normal");// No i18n on purpose
141 } else if (priority->currentItem() == POPUP_PRIO_HIGH) { 141 } else if (priority->currentItem() == POPUP_PRIO_HIGH) {
142 smail.setPriority("High");// No i18n on purpose 142 smail.setPriority("High");// No i18n on purpose
143 } 143 }
144 144
145 QValueList<Attachment> attachments; 145 QValueList<Attachment> attachments;
146 QListViewItem *item; 146 QListViewItem *item;
147 for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) { 147 for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) {
148 attachments.append(((AttachViewItem *)item)->attachment()); 148 attachments.append(((AttachViewItem *)item)->attachment());
149 } 149 }
150 150
151 smail.setAttachments(attachments); 151 smail.setAttachments(attachments);
152 152
153 QString header, message; 153 QString header, message;
154 MailFactory::genMail(header, message, smail, this); 154 MailFactory::genMail(header, message, smail, this);
155 if (header.isNull() || message.isNull()) return;// Aborted. 155 if (header.isNull() || message.isNull()) return;// Aborted.
156 156
157 abort->setEnabled(true); 157 abort->setEnabled(true);
158 158
159 SmtpHandler *handler = new SmtpHandler(header, message, accountsLoaded[from->currentItem()], to->text()); 159 SmtpHandler *handler = new SmtpHandler(header, message, accountsLoaded[from->currentItem()], to->text());
160 connect(handler, SIGNAL(finished()), SLOT(slotSendFinished())); 160 connect(handler, SIGNAL(finished()), SLOT(slotSendFinished()));
161 connect(handler, SIGNAL(error(const QString &)), SLOT(slotSendError(const QString &))); 161 connect(handler, SIGNAL(error(const QString &)), SLOT(slotSendError(const QString &)));
162 connect(handler, SIGNAL(status(const QString &)), status, SLOT(setText(const QString &))); 162 connect(handler, SIGNAL(status(const QString &)), status, SLOT(setText(const QString &)));
163} 163}
164 164
165void Composer::slotSendQueued() 165void Composer::slotSendQueued()
166{ 166{
167 167 int effSendCount = 0;
168 qDebug("Sending queued messages"); 168 qDebug("Sending queued messages");
169 Config cfg( "mailqueue", Config::User ); 169 Config cfg( "mailqueue", Config::User );
170 cfg.setGroup( "Settings" ); 170 cfg.setGroup( "Settings" );
171 _sendCount = 0; 171 _sendCount = 0;
172 _sendError = 0; 172 _sendError = 0;
173 _toSend = cfg.readNumEntry( "count", 0 ); 173 _toSend = cfg.readNumEntry( "count", 0 );
174 174
175 if (_toSend == 0) close(); 175 if (_toSend == 0) close();
176 176
177 qDebug("%i messages to send", _toSend); 177 qDebug("%i messages to send", _toSend);
178 QString str; 178 QString str;
179 for (int i=1;i<=_toSend;i++) 179 for (int i=1;i<=_toSend;i++)
180 { 180 {
181 qDebug("sending message %i",i); 181 qDebug("sending message %i",i);
182 cfg.setGroup( "Mail_" + QString::number(i) ); 182 cfg.setGroup( "Mail_" + QString::number(i) );
183 SendMail smail; 183 SendMail smail;
184 str = cfg.readEntry("from"); 184 str = cfg.readEntry("from");
185 qDebug("setFrom %s",str.latin1()); 185 qDebug("setFrom %s",str.latin1());
186 smail.setFrom( str ); 186 smail.setFrom( str );
187 str = cfg.readEntry("reply"); 187 str = cfg.readEntry("reply");
188 qDebug("setReplyTo %s",str.latin1()); 188 qDebug("setReplyTo %s",str.latin1());
189 smail.setReplyTo( str ); 189 smail.setReplyTo( str );
190 QString toAdr = cfg.readEntry("to"); 190 QString toAdr = cfg.readEntry("to");
191 qDebug("to %s",toAdr.latin1()); 191 qDebug("to %s",toAdr.latin1());
192 smail.setTo( toAdr ); //to->text()); 192 smail.setTo( toAdr ); //to->text());
193 str = cfg.readEntry("cc"); 193 str = cfg.readEntry("cc");
194 qDebug("setCc %s",str.latin1()); 194 qDebug("setCc %s",str.latin1());
195 smail.setCc( str ); //cc->text()); 195 smail.setCc( str ); //cc->text());
196 smail.setBcc( cfg.readEntry("bcc") ); //bcc->text()); 196 smail.setBcc( cfg.readEntry("bcc") ); //bcc->text());
197 str = cfg.readEntry("subject"); 197 str = cfg.readEntry("subject");
198 qDebug("setSubject %s",str.latin1()); 198 qDebug("setSubject %s",str.latin1());
199 smail.setSubject( str ); //subject->text()); 199 smail.setSubject( str ); //subject->text());
200 str = cfg.readEntryCrypt("message"); 200 str = cfg.readEntryCrypt("message");
201 qDebug("setMessage %s",str.latin1()); 201 qDebug("setMessage %s",str.latin1());
202 smail.setMessage( str ); //message->text()); 202 smail.setMessage( str ); //message->text());
203 smail.setNeedsMime( cfg.readBoolEntry("mime") ); //attachView->childCount() == 0 ? false : true); 203 smail.setNeedsMime( cfg.readBoolEntry("mime") ); //attachView->childCount() == 0 ? false : true);
204 204
205 qDebug("setting account [%i]",cfg.readNumEntry("account")); 205 qDebug("setting account [%i]",cfg.readNumEntry("account"));
206 Account accnt = accountsLoaded[ cfg.readNumEntry("account") ]; 206 Account accnt = accountsLoaded[ cfg.readNumEntry("account") ];
207 smail.setAccount( accnt ); //accountsLoaded[from->currentItem()]); 207 smail.setAccount( accnt ); //accountsLoaded[from->currentItem()]);
208 208
209 209
210 int prio = cfg.readNumEntry( "priority" ); 210 int prio = cfg.readNumEntry( "priority" );
211 qDebug("setting priority %i",prio); 211 qDebug("setting priority %i",prio);
212 if (prio == POPUP_PRIO_LOW) { 212 if (prio == POPUP_PRIO_LOW) {
213 smail.setPriority("Low");// No i18n on purpose 213 smail.setPriority("Low");// No i18n on purpose
214 } else if (prio == POPUP_PRIO_NORMAL) { 214 } else if (prio == POPUP_PRIO_NORMAL) {
215 smail.setPriority("Normal");// No i18n on purpose 215 smail.setPriority("Normal");// No i18n on purpose
216 } else if (prio == POPUP_PRIO_HIGH) { 216 } else if (prio == POPUP_PRIO_HIGH) {
217 smail.setPriority("High");// No i18n on purpose 217 smail.setPriority("High");// No i18n on purpose
218 } 218 }
219 219
220 QValueList<Attachment> attachments; 220 QValueList<Attachment> attachments;
221 Attachment a; 221 Attachment a;
222 QString an; 222 QString an;
223 223
224 int ac = cfg.readNumEntry( "attachments", 0 ); 224 int ac = cfg.readNumEntry( "attachments", 0 );
225 qDebug("%i Attachments",ac); 225 qDebug("%i Attachments",ac);
226 for (int j = 0; i < ac; ac++) { 226 for (int j = 0; i < ac; ac++) {
227 an = "Attachment_" + QString::number( j ); 227 an = "Attachment_" + QString::number( j );
228 qDebug(an.latin1()); 228 qDebug(an.latin1());
229 a.setFileName(cfg.readEntry( an + "fileName" )); 229 a.setFileName(cfg.readEntry( an + "fileName" ));
230 a.setNewName(cfg.readEntry( an + "newName" )); 230 a.setNewName(cfg.readEntry( an + "newName" ));
231 a.setDescription(cfg.readEntry( an + "description" )); 231 a.setDescription(cfg.readEntry( an + "description" ));
232 a.setDocLnk( DocLnk( cfg.readEntry( an + "docLnk" )) ); 232 a.setDocLnk( DocLnk( cfg.readEntry( an + "docLnk" )) );
233 attachments.append( a ); 233 attachments.append( a );
234 } 234 }
235 235
236 smail.setAttachments(attachments); 236 smail.setAttachments(attachments);
237 237
238 qDebug("putting mail together"); 238 qDebug("putting mail together");
239 239
240 QString header, message; 240 QString header, message;
241 MailFactory::genMail(header, message, smail, this); 241 MailFactory::genMail(header, message, smail, this);
242 if (header.isNull() || message.isNull()) continue;//return;// Aborted. 242 if (header.isNull() || message.isNull()) continue;//return;// Aborted.
243 243
244 // abort->setEnabled(true); 244 // abort->setEnabled(true);
245 245
246 qDebug("Sending to %s",toAdr.latin1()); 246 qDebug("Sending to %s",toAdr.latin1());
247 SmtpHandler *handler = new SmtpHandler(header, message, accnt ,toAdr); 247 SmtpHandler *handler = new SmtpHandler(header, message, accnt ,toAdr);
248 248 effSendCount++;
249 connect(handler, SIGNAL(finished()), SLOT(slotSendQueuedFinished())); 249 connect(handler, SIGNAL(finished()), SLOT(slotSendQueuedFinished()));
250 connect(handler, SIGNAL(error(const QString &)), SLOT(slotSendQueuedError(const QString &))); 250 connect(handler, SIGNAL(error(const QString &)), SLOT(slotSendQueuedError(const QString &)));
251 connect(handler, SIGNAL(status(const QString &)), status, SLOT(setText(const QString &))); 251 connect(handler, SIGNAL(status(const QString &)), status, SLOT(setText(const QString &)));
252 252
253 } 253 }
254 if (effSendCount < _toSend)
255 {
256 _toSend = effSendCount;
257 QMessageBox::information(this, tr("Error"), tr("<p>There was a problem sending some of the queued mails.</p>"), tr("Ok"));
258 }
254} 259}
255 260
256void Composer::slotQueueMail() 261void Composer::slotQueueMail()
257{ 262{
258 if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) { 263 if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) {
259 QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok")); 264 QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok"));
260 return; 265 return;
261 } 266 }
262 267
263 Config cfg( "mailqueue", Config::User ); 268 Config cfg( "mailqueue", Config::User );
264 269
265 cfg.setGroup( "Settings" ); 270 cfg.setGroup( "Settings" );
266 int count = cfg.readNumEntry( "count", 0 ); 271 int count = cfg.readNumEntry( "count", 0 );
267 count++; 272 count++;
268 cfg.writeEntry( "count", count ); 273 cfg.writeEntry( "count", count );
269 qDebug("queueing mail %i",count); 274 qDebug("queueing mail %i",count);
270 275
271 cfg.setGroup( "Mail_" + QString::number( count )); 276 cfg.setGroup( "Mail_" + QString::number( count ));
272 cfg.writeEntry( "from", from->currentText() ); 277 cfg.writeEntry( "from", from->currentText() );
273 cfg.writeEntry( "reply", replyto->text()); 278 cfg.writeEntry( "reply", replyto->text());
274 cfg.writeEntry( "to", to->text()); 279 cfg.writeEntry( "to", to->text());
275 cfg.writeEntry( "cc", cc->text()); 280 cfg.writeEntry( "cc", cc->text());
276 cfg.writeEntry( "bcc", bcc->text()); 281 cfg.writeEntry( "bcc", bcc->text());
277 cfg.writeEntry( "subject", subject->text()); 282 cfg.writeEntry( "subject", subject->text());
278 cfg.writeEntryCrypt( "message", message->text()); 283 cfg.writeEntryCrypt( "message", message->text());
279 cfg.writeEntry( "mime", attachView->childCount() == 0 ); 284 cfg.writeEntry( "mime", attachView->childCount() == 0 );
280 cfg.writeEntry( "account", from->currentItem()); 285 cfg.writeEntry( "account", from->currentItem());
281 cfg.writeEntry( "priority", priority->currentItem() ); 286 cfg.writeEntry( "priority", priority->currentItem() );
282 cfg.writeEntry( "attachments", attachView->childCount() ); 287 cfg.writeEntry( "attachments", attachView->childCount() );
283 288
284 Attachment a; 289 Attachment a;
285 QListViewItem *item; 290 QListViewItem *item;
286 QString an; 291 QString an;
287 int i = 0; 292 int i = 0;
288 for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) { 293 for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) {
289 a = ((AttachViewItem *)item)->attachment(); 294 a = ((AttachViewItem *)item)->attachment();
290 an = "Attachment_" + QString::number( i++ ); 295 an = "Attachment_" + QString::number( i++ );
291 cfg.writeEntry( an + "fileName", a.fileName() ); 296 cfg.writeEntry( an + "fileName", a.fileName() );
292 cfg.writeEntry( an + "newName", a.newName() ); 297 cfg.writeEntry( an + "newName", a.newName() );
293 cfg.writeEntry( an + "description", a.description() ); 298 cfg.writeEntry( an + "description", a.description() );
294 cfg.writeEntry( an + "docLnk", a.docLnk().file() ); 299 cfg.writeEntry( an + "docLnk", a.docLnk().file() );
295 } 300 }
296 301
297 QMessageBox::information(this, tr("Success"), tr("<p>The mail was queued successfully.</p><p>The queue contains ")+QString::number(count)+tr(" mails.</p>"), tr("Ok")); 302 QMessageBox::information(this, tr("Success"), tr("<p>The mail was queued successfully.</p><p>The queue contains ")+QString::number(count)+tr(" mails.</p>"), tr("Ok"));
298 303
299} 304}
300 305
301void Composer::slotSendError(const QString &error) 306void Composer::slotSendError(const QString &error)
302{ 307{
303 status->setText(tr("<font color=#ff0000>Error occoured during sending.</font>")); 308 status->setText(tr("<font color=#ff0000>Error occoured during sending.</font>"));
304 QMessageBox::warning(this, tr("Error"), tr("<p>%1</p").arg(error), tr("Ok")); 309 QMessageBox::warning(this, tr("Error"), tr("<p>%1</p").arg(error), tr("Ok"));
305} 310}
306 311
307void Composer::slotSendQueuedError(const QString &error) 312void Composer::slotSendQueuedError(const QString &error)
308{ 313{
309 _sendError++; 314 _sendError++;
310 qDebug("error send mail %i",_sendCount); 315 qDebug("error send mail %i",_sendCount);
311 status->setText(tr("<font color=#ff0000>Error occoured during sending.</font>")); 316 status->setText(tr("<font color=#ff0000>Error occoured during sending.</font>"));
312 QMessageBox::warning(this, tr("Error"), tr("<p>%1</p").arg(error), tr("Ok")); 317 QMessageBox::warning(this, tr("Error"), tr("<p>%1</p").arg(error), tr("Ok"));
313} 318}
314 319
315void Composer::slotSendFinished() 320void Composer::slotSendFinished()
316{ 321{
317 QMessageBox::information(this, tr("Success"), tr("<p>The mail was sent successfully.</p>"), tr("Ok")); 322 QMessageBox::information(this, tr("Success"), tr("<p>The mail was sent successfully.</p>"), tr("Ok"));
318 323
319 status->setText(QString(0)); 324 status->setText(QString(0));
320 abort->setEnabled(false); 325 abort->setEnabled(false);
321} 326}
322 327
323void Composer::slotSendQueuedFinished() 328void Composer::slotSendQueuedFinished()
324{ 329{
325 330
326 _sendCount++; 331 _sendCount++;
327 qDebug("finished send mail %i of %i (error %i)",_sendCount,_toSend,_sendError); 332 qDebug("finished send mail %i of %i (error %i)",_sendCount,_toSend,_sendError);
328 if (_sendCount < _toSend) return; 333 if (_sendCount < _toSend) return;
329 if (_sendError == _toSend) close(); 334 if (_sendError == _toSend) close();
330 QMessageBox::information(this, tr("Success"), tr("<p>The queued mails ")+QString::number(_toSend-_sendError)+tr(" of ")+QString::number(_toSend)+(" were sent successfully.</p>"), tr("Ok")); 335 QMessageBox::information(this, tr("Success"), tr("<p>The queued mails ")+QString::number(_toSend-_sendError)+tr(" of ")+QString::number(_toSend)+(" were sent successfully.</p>"), tr("Ok"));
331 Config cfg( "mailqueue", Config::User ); 336 Config cfg( "mailqueue", Config::User );
332 cfg.setGroup( "Settings" ); 337 cfg.setGroup( "Settings" );
333 cfg.writeEntry( "count", 0 ); 338 cfg.writeEntry( "count", 0 );
334 for (int i=1;i<=_sendCount;i++) 339 for (int i=1;i<=_sendCount;i++)
335 { 340 {
336 cfg.setGroup( "Mail_" + QString::number(i) ); 341 cfg.setGroup( "Mail_" + QString::number(i) );
337 qDebug("remove mail %i", i); 342 qDebug("remove mail %i", i);
338 cfg.clearGroup(); 343 cfg.clearGroup();
339 cfg.removeEntry( "Mail_" + QString::number(i) ); 344 cfg.removeEntry( "Mail_" + QString::number(i) );
340 } 345 }
341 close(); 346 close();
342} 347}
343 348
344void Composer::slotFillStuff() 349void Composer::slotFillStuff()
345{ 350{
346 QValueList<Account> accounts = ConfigFile::getAccounts(); 351 QValueList<Account> accounts = ConfigFile::getAccounts();
347 int i = 0; 352 int i = 0;
348 353
349 QValueList<Account>::Iterator it; 354 QValueList<Account>::Iterator it;
350 for (it = accounts.begin(); it != accounts.end(); it++) { 355 for (it = accounts.begin(); it != accounts.end(); it++) {
351 if (!(*it).email().isEmpty() && !(*it).smtpServer().isEmpty() && !(*it).smtpPort().isEmpty()) { 356 if (!(*it).email().isEmpty() && !(*it).smtpServer().isEmpty() && !(*it).smtpPort().isEmpty()) {
352 if (!(*it).realName().isEmpty()) 357 if (!(*it).realName().isEmpty())
353 from->insertItem((*it).realName() + " <" + (*it).email() + ">", i); 358 from->insertItem((*it).realName() + " <" + (*it).email() + ">", i);
354 else 359 else
355 from->insertItem((*it).email()); 360 from->insertItem((*it).email());
356 361
357 accountsLoaded.append(*it); 362 accountsLoaded.append(*it);
358 i++; 363 i++;
359 } 364 }
360 } 365 }
361} 366}
362 367
363void Composer::slotFromChanged(int id) 368void Composer::slotFromChanged(int id)
364{ 369{
365 Account account = accountsLoaded[id]; 370 Account account = accountsLoaded[id];
366 371
367 if (account.defaultCc()) cc->setText(account.cc()); 372 if (account.defaultCc()) cc->setText(account.cc());
368 if (account.defaultBcc()) bcc->setText(account.bcc()); 373 if (account.defaultBcc()) bcc->setText(account.bcc());
369 if (account.defaultReplyTo()) replyto->setText(account.replyTo()); 374 if (account.defaultReplyTo()) replyto->setText(account.replyTo());
370 if (!account.signature().isEmpty()) 375 if (!account.signature().isEmpty())
371 message->setText(message->text() + "\n\n-- \n" + account.signature()); 376 message->setText(message->text() + "\n\n-- \n" + account.signature());
372} 377}
373 378
374void Composer::slotOpenAddressPicker() 379void Composer::slotOpenAddressPicker()
375{ 380{
376 if (!to->isHidden() && cc->isHidden() && bcc->isHidden()) { 381 if (!to->isHidden() && cc->isHidden() && bcc->isHidden()) {
377 if (to->text().isEmpty()) { 382 if (to->text().isEmpty()) {
378 to->setText(AddressPicker::getNames()); 383 to->setText(AddressPicker::getNames());
379 } else { 384 } else {
380 to->setText(to->text() + ", " + AddressPicker::getNames()); 385 to->setText(to->text() + ", " + AddressPicker::getNames());
381 } 386 }
382 } else if (to->isHidden() && !cc->isHidden() && bcc->isHidden()) { 387 } else if (to->isHidden() && !cc->isHidden() && bcc->isHidden()) {
383 if (cc->text().isEmpty()) { 388 if (cc->text().isEmpty()) {
384 cc->setText(AddressPicker::getNames()); 389 cc->setText(AddressPicker::getNames());
385 } else { 390 } else {
386 cc->setText(cc->text() + ", " + AddressPicker::getNames()); 391 cc->setText(cc->text() + ", " + AddressPicker::getNames());
387 } 392 }
388 } else if (to->isHidden() && cc->isHidden() && !bcc->isHidden()) { 393 } else if (to->isHidden() && cc->isHidden() && !bcc->isHidden()) {
389 if (bcc->text().isEmpty()) { 394 if (bcc->text().isEmpty()) {
390 bcc->setText(AddressPicker::getNames()); 395 bcc->setText(AddressPicker::getNames());
391 } else { 396 } else {
392 bcc->setText(bcc->text() + ", " + AddressPicker::getNames()); 397 bcc->setText(bcc->text() + ", " + AddressPicker::getNames());
393 } 398 }
394 } 399 }
395} 400}
396 401
397void Composer::slotAddAttach() 402void Composer::slotAddAttach()
398{ 403{
399 DocLnk lnk = OFileDialog::getOpenFileName( 1,"/"); 404 DocLnk lnk = OFileDialog::getOpenFileName( 1,"/");
400 //DocLnk lnk = AttachDiag::getFile(this); 405 //DocLnk lnk = AttachDiag::getFile(this);
401 if (lnk.name().isEmpty()) return; 406 if (lnk.name().isEmpty()) return;
402 407
403 Attachment attachment; 408 Attachment attachment;
404 attachment.setFileName(lnk.file()); 409 attachment.setFileName(lnk.file());
405 attachment.setNewName(lnk.name()); 410 attachment.setNewName(lnk.name());
406 attachment.setDocLnk(lnk); 411 attachment.setDocLnk(lnk);
407 412
408 (void) new AttachViewItem(attachView, attachment); 413 (void) new AttachViewItem(attachView, attachment);
409} 414}
410 415
411void Composer::slotDelAttach() 416void Composer::slotDelAttach()
412{ 417{
413 if (attachView->currentItem() == NULL) return; 418 if (attachView->currentItem() == NULL) return;
414 attachView->takeItem(attachView->currentItem()); 419 attachView->takeItem(attachView->currentItem());
415} 420}