summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/mail2/composer.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/unsupported/mail2/composer.cpp b/noncore/unsupported/mail2/composer.cpp
index 03d50b6..57f0779 100644
--- a/noncore/unsupported/mail2/composer.cpp
+++ b/noncore/unsupported/mail2/composer.cpp
@@ -27,191 +27,192 @@ AttachViewItem::AttachViewItem(QListView *parent, Attachment &attachment)
27Composer::Composer(QWidget *parent, const char *name, WFlags fl) 27Composer::Composer(QWidget *parent, const char *name, WFlags fl)
28 : ComposerBase(parent, name, fl) 28 : ComposerBase(parent, name, fl)
29{ 29{
30 abort->setEnabled(false); 30 abort->setEnabled(false);
31 to->setFocus(); 31 to->setFocus();
32 32
33 connect(sendmail, SIGNAL(activated()), SLOT(slotSendMail())); 33 connect(sendmail, SIGNAL(activated()), SLOT(slotSendMail()));
34 connect(addressbook, SIGNAL(activated()), SLOT(slotOpenAddressPicker())); 34 connect(addressbook, SIGNAL(activated()), SLOT(slotOpenAddressPicker()));
35 connect(addattach, SIGNAL(activated()), SLOT(slotAddAttach())); 35 connect(addattach, SIGNAL(activated()), SLOT(slotAddAttach()));
36 connect(delattach, SIGNAL(activated()), SLOT(slotDelAttach())); 36 connect(delattach, SIGNAL(activated()), SLOT(slotDelAttach()));
37 37
38 connect(from, SIGNAL(activated(int)), SLOT(slotFromChanged(int))); 38 connect(from, SIGNAL(activated(int)), SLOT(slotFromChanged(int)));
39 39
40 connect(attachPopup, SIGNAL(activated(int)), SLOT(slotPopupHandler(int))); 40 connect(attachPopup, SIGNAL(activated(int)), SLOT(slotPopupHandler(int)));
41 41
42 QTimer::singleShot(0, this, SLOT(slotFillStuff())); 42 QTimer::singleShot(0, this, SLOT(slotFillStuff()));
43 QTimer::singleShot(0, this, SLOT(slotResizing())); 43 QTimer::singleShot(0, this, SLOT(slotResizing()));
44} 44}
45 45
46void Composer::setSendMail(SendMail &sendMail) 46void Composer::setSendMail(SendMail &sendMail)
47{ 47{
48 to->setText(sendMail.to()); 48 to->setText(sendMail.to());
49 cc->setText(sendMail.cc()); 49 cc->setText(sendMail.cc());
50 bcc->setText(sendMail.bcc()); 50 bcc->setText(sendMail.bcc());
51 subject->setText(sendMail.subject()); 51 subject->setText(sendMail.subject());
52 message->setText(sendMail.message()); 52 message->setText(sendMail.message());
53 _inReplyTo = sendMail.inReplyTo(); 53 _inReplyTo = sendMail.inReplyTo();
54 54
55 QValueList<Attachment> attachments = sendMail.attachments(); 55 QValueList<Attachment> attachments = sendMail.attachments();
56 QValueList<Attachment>::Iterator it; 56 QValueList<Attachment>::Iterator it;
57 for (it = attachments.begin(); it != attachments.end(); it++) { 57 for (it = attachments.begin(); it != attachments.end(); it++) {
58 (void) new AttachViewItem(attachView, *it); 58 (void) new AttachViewItem(attachView, *it);
59 if (attachView->isHidden()) attachView->show(); 59 if (attachView->isHidden()) attachView->show();
60 } 60 }
61} 61}
62 62
63void Composer::slotResizing() 63void Composer::slotResizing()
64{ 64{
65 from->setMaximumWidth(width() - fromBox->width()); 65 from->setMaximumWidth(width() - fromBox->width());
66 from->resize(width() - fromBox->width(), y()); 66 from->resize(width() - fromBox->width(), y());
67} 67}
68 68
69void Composer::slotPopupHandler(int itemid) 69void Composer::slotPopupHandler(int itemid)
70{ 70{
71 if (attachView->currentItem() == NULL) { 71 if (attachView->currentItem() == NULL) {
72 QMessageBox::information(this, tr("Error"), tr("Please select an entry first."), tr("Ok")); 72 QMessageBox::information(this, tr("Error"), tr("Please select an entry first."), tr("Ok"));
73 return; 73 return;
74 } 74 }
75 75
76 if (itemid == POPUP_ATTACH_RENAME) { 76 if (itemid == POPUP_ATTACH_RENAME) {
77 QString tmp = Rename::rename(attachView->currentItem()->text(0), this); 77 QString tmp = Rename::rename(attachView->currentItem()->text(0), this);
78 if (tmp != QString(0)) attachView->currentItem()->setText(0, tmp); 78 if (tmp != QString(0)) attachView->currentItem()->setText(0, tmp);
79 } else if (itemid == POPUP_ATTACH_DESC) { 79 } else if (itemid == POPUP_ATTACH_DESC) {
80 QString tmp = Rename::getText(tr("Set Description"), tr("<div align=center>Description"), this); 80 QString tmp = Rename::getText(tr("Set Description"), tr("<div align=center>Description"), this);
81 if (tmp != QString(0)) attachView->currentItem()->setText(1, tmp); 81 if (tmp != QString(0)) attachView->currentItem()->setText(1, tmp);
82 } else if (itemid == POPUP_ATTACH_REMOVE) { 82 } else if (itemid == POPUP_ATTACH_REMOVE) {
83 attachView->takeItem(attachView->currentItem()); 83 attachView->takeItem(attachView->currentItem());
84 } 84 }
85} 85}
86 86
87void Composer::slotSendMail() 87void Composer::slotSendMail()
88{ 88{
89 if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) { 89 if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) {
90 QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok")); 90 QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok"));
91 return; 91 return;
92 } 92 }
93 93
94 SendMail smail; 94 SendMail smail;
95 smail.setFrom(from->currentText()); 95 smail.setFrom(from->currentText());
96 smail.setReplyTo(replyto->text()); 96 smail.setReplyTo(replyto->text());
97 smail.setTo(to->text()); 97 smail.setTo(to->text());
98 smail.setCc(cc->text()); 98 smail.setCc(cc->text());
99 smail.setBcc(bcc->text()); 99 smail.setBcc(bcc->text());
100 smail.setSubject(subject->text()); 100 smail.setSubject(subject->text());
101 smail.setMessage(message->text()); 101 smail.setMessage(message->text());
102 smail.setNeedsMime(attachView->childCount() == 0 ? false : true); 102 smail.setNeedsMime(attachView->childCount() == 0 ? false : true);
103 smail.setAccount(accountsLoaded[from->currentItem()]); 103 smail.setAccount(accountsLoaded[from->currentItem()]);
104 104
105 if (priority->currentItem() == POPUP_PRIO_LOW) { 105 if (priority->currentItem() == POPUP_PRIO_LOW) {
106 smail.setPriority("Low");// No i18n on purpose 106 smail.setPriority("Low");// No i18n on purpose
107 } else if (priority->currentItem() == POPUP_PRIO_NORMAL) { 107 } else if (priority->currentItem() == POPUP_PRIO_NORMAL) {
108 smail.setPriority("Normal");// No i18n on purpose 108 smail.setPriority("Normal");// No i18n on purpose
109 } else if (priority->currentItem() == POPUP_PRIO_HIGH) { 109 } else if (priority->currentItem() == POPUP_PRIO_HIGH) {
110 smail.setPriority("High");// No i18n on purpose 110 smail.setPriority("High");// No i18n on purpose
111 } 111 }
112 112
113 QValueList<Attachment> attachments; 113 QValueList<Attachment> attachments;
114 QListViewItem *item; 114 QListViewItem *item;
115 for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) { 115 for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) {
116 attachments.append(((AttachViewItem *)item)->attachment()); 116 attachments.append(((AttachViewItem *)item)->attachment());
117 } 117 }
118 118
119 smail.setAttachments(attachments); 119 smail.setAttachments(attachments);
120 120
121 QString header, message; 121 QString header, message;
122 MailFactory::genMail(header, message, smail, this); 122 MailFactory::genMail(header, message, smail, this);
123 if (header.isNull() || message.isNull()) return;// Aborted.
123 124
124 abort->setEnabled(true); 125 abort->setEnabled(true);
125 126
126 SmtpHandler *handler = new SmtpHandler(header, message, accountsLoaded[from->currentItem()], to->text()); 127 SmtpHandler *handler = new SmtpHandler(header, message, accountsLoaded[from->currentItem()], to->text());
127 connect(handler, SIGNAL(finished()), SLOT(slotSendFinished())); 128 connect(handler, SIGNAL(finished()), SLOT(slotSendFinished()));
128 connect(handler, SIGNAL(error(const QString &)), SLOT(slotSendError(const QString &))); 129 connect(handler, SIGNAL(error(const QString &)), SLOT(slotSendError(const QString &)));
129 connect(handler, SIGNAL(status(const QString &)), status, SLOT(setText(const QString &))); 130 connect(handler, SIGNAL(status(const QString &)), status, SLOT(setText(const QString &)));
130} 131}
131 132
132void Composer::slotSendError(const QString &error) 133void Composer::slotSendError(const QString &error)
133{ 134{
134 status->setText(tr("<font color=#ff0000>Error occoured during sending.</font>")); 135 status->setText(tr("<font color=#ff0000>Error occoured during sending.</font>"));
135 QMessageBox::warning(this, tr("Error"), tr("<p>%1</p").arg(error), tr("Ok")); 136 QMessageBox::warning(this, tr("Error"), tr("<p>%1</p").arg(error), tr("Ok"));
136} 137}
137 138
138void Composer::slotSendFinished() 139void Composer::slotSendFinished()
139{ 140{
140 QMessageBox::information(this, tr("Success"), tr("<p>The mail was sent successfully.</p>"), tr("Ok")); 141 QMessageBox::information(this, tr("Success"), tr("<p>The mail was sent successfully.</p>"), tr("Ok"));
141 142
142 status->setText(QString(0)); 143 status->setText(QString(0));
143 abort->setEnabled(false); 144 abort->setEnabled(false);
144} 145}
145 146
146void Composer::slotFillStuff() 147void Composer::slotFillStuff()
147{ 148{
148 QValueList<Account> accounts = ConfigFile::getAccounts(); 149 QValueList<Account> accounts = ConfigFile::getAccounts();
149 int i = 0; 150 int i = 0;
150 151
151 QValueList<Account>::Iterator it; 152 QValueList<Account>::Iterator it;
152 for (it = accounts.begin(); it != accounts.end(); it++) { 153 for (it = accounts.begin(); it != accounts.end(); it++) {
153 if (!(*it).email().isEmpty() && !(*it).smtpServer().isEmpty() && !(*it).smtpPort().isEmpty()) { 154 if (!(*it).email().isEmpty() && !(*it).smtpServer().isEmpty() && !(*it).smtpPort().isEmpty()) {
154 if (!(*it).realName().isEmpty()) 155 if (!(*it).realName().isEmpty())
155 from->insertItem((*it).realName() + " <" + (*it).email() + ">", i); 156 from->insertItem((*it).realName() + " <" + (*it).email() + ">", i);
156 else 157 else
157 from->insertItem((*it).email()); 158 from->insertItem((*it).email());
158 159
159 accountsLoaded.append(*it); 160 accountsLoaded.append(*it);
160 i++; 161 i++;
161 } 162 }
162 } 163 }
163} 164}
164 165
165void Composer::slotFromChanged(int id) 166void Composer::slotFromChanged(int id)
166{ 167{
167 Account account = accountsLoaded[id]; 168 Account account = accountsLoaded[id];
168 169
169 if (account.defaultCc()) cc->setText(account.cc()); 170 if (account.defaultCc()) cc->setText(account.cc());
170 if (account.defaultBcc()) bcc->setText(account.bcc()); 171 if (account.defaultBcc()) bcc->setText(account.bcc());
171 if (account.defaultReplyTo()) replyto->setText(account.replyTo()); 172 if (account.defaultReplyTo()) replyto->setText(account.replyTo());
172 if (!account.signature().isEmpty()) 173 if (!account.signature().isEmpty())
173 message->setText(message->text() + "\n\n-- \n" + account.signature()); 174 message->setText(message->text() + "\n\n-- \n" + account.signature());
174} 175}
175 176
176void Composer::slotOpenAddressPicker() 177void Composer::slotOpenAddressPicker()
177{ 178{
178 if (!to->isHidden() && cc->isHidden() && bcc->isHidden()) { 179 if (!to->isHidden() && cc->isHidden() && bcc->isHidden()) {
179 if (to->text().isEmpty()) { 180 if (to->text().isEmpty()) {
180 to->setText(AddressPicker::getNames()); 181 to->setText(AddressPicker::getNames());
181 } else { 182 } else {
182 to->setText(to->text() + ", " + AddressPicker::getNames()); 183 to->setText(to->text() + ", " + AddressPicker::getNames());
183 } 184 }
184 } else if (to->isHidden() && !cc->isHidden() && bcc->isHidden()) { 185 } else if (to->isHidden() && !cc->isHidden() && bcc->isHidden()) {
185 if (cc->text().isEmpty()) { 186 if (cc->text().isEmpty()) {
186 cc->setText(AddressPicker::getNames()); 187 cc->setText(AddressPicker::getNames());
187 } else { 188 } else {
188 cc->setText(cc->text() + ", " + AddressPicker::getNames()); 189 cc->setText(cc->text() + ", " + AddressPicker::getNames());
189 } 190 }
190 } else if (to->isHidden() && cc->isHidden() && !bcc->isHidden()) { 191 } else if (to->isHidden() && cc->isHidden() && !bcc->isHidden()) {
191 if (bcc->text().isEmpty()) { 192 if (bcc->text().isEmpty()) {
192 bcc->setText(AddressPicker::getNames()); 193 bcc->setText(AddressPicker::getNames());
193 } else { 194 } else {
194 bcc->setText(bcc->text() + ", " + AddressPicker::getNames()); 195 bcc->setText(bcc->text() + ", " + AddressPicker::getNames());
195 } 196 }
196 } 197 }
197} 198}
198 199
199void Composer::slotAddAttach() 200void Composer::slotAddAttach()
200{ 201{
201 DocLnk lnk = AttachDiag::getFile(); 202 DocLnk lnk = AttachDiag::getFile();
202 if (lnk.name().isEmpty()) return; 203 if (lnk.name().isEmpty()) return;
203 204
204 Attachment attachment; 205 Attachment attachment;
205 attachment.setFileName(lnk.file()); 206 attachment.setFileName(lnk.file());
206 attachment.setNewName(lnk.name()); 207 attachment.setNewName(lnk.name());
207 attachment.setDocLnk(&lnk); 208 attachment.setDocLnk(&lnk);
208 209
209 (void) new AttachViewItem(attachView, attachment); 210 (void) new AttachViewItem(attachView, attachment);
210} 211}
211 212
212void Composer::slotDelAttach() 213void Composer::slotDelAttach()
213{ 214{
214 if (attachView->currentItem() == NULL) return; 215 if (attachView->currentItem() == NULL) return;
215 attachView->takeItem(attachView->currentItem()); 216 attachView->takeItem(attachView->currentItem());
216} 217}
217 218