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