author | zautrix <zautrix> | 2005-02-03 10:48:05 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-03 10:48:05 (UTC) |
commit | fb6753570dc90e936b4e89092554ab012e946a56 (patch) (unidiff) | |
tree | 6d3ae5c866f0bbb99f0b6bc8194d04d2c7681ff9 /kmicromail/composemail.cpp | |
parent | e0fce8c0f108e054cb6e4e4767affd04b398da45 (diff) | |
download | kdepimpi-fb6753570dc90e936b4e89092554ab012e946a56.zip kdepimpi-fb6753570dc90e936b4e89092554ab012e946a56.tar.gz kdepimpi-fb6753570dc90e936b4e89092554ab012e946a56.tar.bz2 |
mail fixes
-rw-r--r-- | kmicromail/composemail.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp index 976e309..ed8a2ee 100644 --- a/kmicromail/composemail.cpp +++ b/kmicromail/composemail.cpp | |||
@@ -56,399 +56,410 @@ ComposeMail::ComposeMail( Settings *sett, QWidget *parent, const char *name, boo | |||
56 | mPickLineEdit = 0; | 56 | mPickLineEdit = 0; |
57 | mEncoding = KOPrefs::instance()->mCurrentCodeName; | 57 | mEncoding = KOPrefs::instance()->mCurrentCodeName; |
58 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), | 58 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), |
59 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 59 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
60 | settings = sett; | 60 | settings = sett; |
61 | m_replyid = ""; | 61 | m_replyid = ""; |
62 | if ( KOPrefs::instance()->mUseKapi) { | 62 | if ( KOPrefs::instance()->mUseKapi) { |
63 | KConfig config( locateLocal("config", "kabcrc") ); | 63 | KConfig config( locateLocal("config", "kabcrc") ); |
64 | config.setGroup( "General" ); | 64 | config.setGroup( "General" ); |
65 | QString whoami_uid = config.readEntry( "WhoAmI" ); | 65 | QString whoami_uid = config.readEntry( "WhoAmI" ); |
66 | 66 | ||
67 | if ( whoami_uid.isEmpty() ) { | 67 | if ( whoami_uid.isEmpty() ) { |
68 | QMessageBox::information( 0, i18n( "Hint" ), | 68 | QMessageBox::information( 0, i18n( "Hint" ), |
69 | i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 69 | i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
70 | i18n( "Ok" ) ); | 70 | i18n( "Ok" ) ); |
71 | 71 | ||
72 | 72 | ||
73 | fillSettings(); | 73 | fillSettings(); |
74 | } else | 74 | } else |
75 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); | 75 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); |
76 | 76 | ||
77 | 77 | ||
78 | #ifdef DESKTOP_VERSION | 78 | #ifdef DESKTOP_VERSION |
79 | KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); | 79 | KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); |
80 | QStringList mails = con.emails(); | 80 | QStringList mails = con.emails(); |
81 | QString defmail = con.preferredEmail(); | 81 | QString defmail = con.preferredEmail(); |
82 | if ( mails.count() == 0) | 82 | if ( mails.count() == 0) |
83 | QMessageBox::information( 0, i18n( "Hint" ), | 83 | QMessageBox::information( 0, i18n( "Hint" ), |
84 | i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 84 | i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
85 | i18n( "Ok" ) ); | 85 | i18n( "Ok" ) ); |
86 | if (defmail.length()!=0) { | 86 | if (defmail.length()!=0) { |
87 | fromBox->insertItem(defmail); | 87 | fromBox->insertItem(defmail); |
88 | } | 88 | } |
89 | QStringList::ConstIterator sit = mails.begin(); | 89 | QStringList::ConstIterator sit = mails.begin(); |
90 | for (;sit!=mails.end();++sit) { | 90 | for (;sit!=mails.end();++sit) { |
91 | if ( (*sit)==defmail) | 91 | if ( (*sit)==defmail) |
92 | continue; | 92 | continue; |
93 | fromBox->insertItem((*sit)); | 93 | fromBox->insertItem((*sit)); |
94 | } | 94 | } |
95 | senderNameEdit->setText(con.formattedName()); | 95 | senderNameEdit->setText(con.formattedName()); |
96 | #endif | 96 | #endif |
97 | 97 | ||
98 | } else { | 98 | } else { |
99 | fillSettings(); | 99 | fillSettings(); |
100 | } | 100 | } |
101 | checkBoxLater->setChecked( KOPrefs::instance()->mSendLater ); | 101 | checkBoxLater->setChecked( KOPrefs::instance()->mSendLater ); |
102 | 102 | ||
103 | attList->addColumn( i18n( "Name" ) ); | 103 | attList->addColumn( i18n( "Name" ) ); |
104 | attList->addColumn( i18n( "Size" ) ); | 104 | attList->addColumn( i18n( "Size" ) ); |
105 | QList<Account> accounts = settings->getAccounts(); | 105 | QList<Account> accounts = settings->getAccounts(); |
106 | 106 | ||
107 | if ( QApplication::desktop()->width() < 320 ) | 107 | if ( QApplication::desktop()->width() < 320 ) |
108 | smtpAccountBox->setMaximumWidth( 80 ); | 108 | smtpAccountBox->setMaximumWidth( 80 ); |
109 | Account *it; | 109 | Account *it; |
110 | for ( it = accounts.first(); it; it = accounts.next() ) { | 110 | for ( it = accounts.first(); it; it = accounts.next() ) { |
111 | if ( it->getType()==MAILLIB::A_SMTP ) { | 111 | if ( it->getType()==MAILLIB::A_SMTP ) { |
112 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); | 112 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); |
113 | smtpAccountBox->insertItem( smtp->getAccountName() ); | 113 | smtpAccountBox->insertItem( smtp->getAccountName() ); |
114 | smtpAccounts.append( smtp ); | 114 | smtpAccounts.append( smtp ); |
115 | } | 115 | } |
116 | } | 116 | } |
117 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); | 117 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); |
118 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); | 118 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); |
119 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); | 119 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); |
120 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); | 120 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); |
121 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); | 121 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); |
122 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); | 122 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); |
123 | connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); | 123 | connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); |
124 | mMail = 0; | 124 | mMail = 0; |
125 | warnAttach = true; | 125 | warnAttach = true; |
126 | QIconSet icon; | 126 | QIconSet icon; |
127 | //icon = SmallIcon("fileexport"); | 127 | //icon = SmallIcon("fileexport"); |
128 | icon = SmallIcon("filesave"); | 128 | icon = SmallIcon("filesave"); |
129 | SaveButton->setIconSet (icon ) ; | 129 | SaveButton->setIconSet (icon ) ; |
130 | if ( QApplication::desktop()->width() < 320 ) { | 130 | if ( QApplication::desktop()->width() < 320 ) { |
131 | SaveButton->setText ("") ; | 131 | SaveButton->setText ("") ; |
132 | SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ; | 132 | SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ; |
133 | } | 133 | } |
134 | else | 134 | else |
135 | SaveButton->setText (i18n("Save")); | 135 | SaveButton->setText (i18n("Save")); |
136 | #ifndef DESKTOP_VERSION | 136 | #ifndef DESKTOP_VERSION |
137 | QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold ); | 137 | QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold ); |
138 | QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold ); | 138 | QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold ); |
139 | QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold ); | 139 | QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold ); |
140 | #endif | 140 | #endif |
141 | message->setFont ( KOPrefs::instance()->mComposeFont ); | 141 | message->setFont ( KOPrefs::instance()->mComposeFont ); |
142 | message->setWordWrap (QMultiLineEdit::WidgetWidth); | 142 | message->setWordWrap (QMultiLineEdit::WidgetWidth); |
143 | if ( smtpAccounts.count() > 0 ) { | 143 | if ( smtpAccounts.count() > 0 ) { |
144 | fillValues( smtpAccountBox->currentItem() ); | 144 | fillValues( smtpAccountBox->currentItem() ); |
145 | } else { | 145 | } else { |
146 | QMessageBox::information( 0, i18n( "Problem" ), | 146 | QMessageBox::information( 0, i18n( "Problem" ), |
147 | i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ), | 147 | i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ), |
148 | i18n( "Ok" ) ); | 148 | i18n( "Ok" ) ); |
149 | return; | 149 | return; |
150 | } | 150 | } |
151 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); | 151 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); |
152 | 152 | connect( SaveSigButton, SIGNAL( clicked() ), SLOT( saveSig()) ); | |
153 | if ( smtpAccountBox->count()) | ||
154 | fillValues(0); | ||
153 | 155 | ||
154 | } | 156 | } |
155 | 157 | ||
156 | void ComposeMail::fillSettings() | 158 | void ComposeMail::fillSettings() |
157 | { | 159 | { |
158 | if ( QApplication::desktop()->width() < 320 ) | 160 | if ( QApplication::desktop()->width() < 320 ) |
159 | fromBox->setMaximumWidth( 100 ); | 161 | fromBox->setMaximumWidth( 100 ); |
160 | QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); | 162 | QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); |
161 | QStringList::ConstIterator sit = mailList.begin(); | 163 | QStringList::ConstIterator sit = mailList.begin(); |
162 | int pref = 0; | 164 | int pref = 0; |
163 | for (;sit!=mailList.end();++sit) { | 165 | for (;sit!=mailList.end();++sit) { |
164 | fromBox->insertItem((*sit)); | 166 | fromBox->insertItem((*sit)); |
165 | } | 167 | } |
166 | senderNameEdit->setText(KOPrefs::instance()->mName); | 168 | senderNameEdit->setText(KOPrefs::instance()->mName); |
167 | } | 169 | } |
168 | 170 | void ComposeMail::saveSig() | |
169 | 171 | { | |
172 | if ( smtpAccountBox->count()) { | ||
173 | int cur = smtpAccountBox->currentItem (); | ||
174 | SMTPaccount *smtp = smtpAccounts.at( cur ); | ||
175 | if ( smtp ) | ||
176 | smtp->setSignature( sigMultiLine->text()); | ||
177 | } | ||
178 | } | ||
170 | void ComposeMail::saveAsDraft() | 179 | void ComposeMail::saveAsDraft() |
171 | { | 180 | { |
172 | 181 | ||
173 | Opie::Core::OSmartPointer<Mail> mail= new Mail(); | 182 | Opie::Core::OSmartPointer<Mail> mail= new Mail(); |
174 | mail->setMail(fromBox->currentText()); | 183 | mail->setMail(fromBox->currentText()); |
175 | mail->setTo( toLine->text() ); | 184 | mail->setTo( toLine->text() ); |
176 | mail->setName(senderNameEdit->text()); | 185 | mail->setName(senderNameEdit->text()); |
177 | mail->setCC( ccLine->text() ); | 186 | mail->setCC( ccLine->text() ); |
178 | mail->setBCC( bccLine->text() ); | 187 | mail->setBCC( bccLine->text() ); |
179 | mail->setReply( replyLine->text() ); | 188 | mail->setReply( replyLine->text() ); |
180 | mail->setSubject( subjectLine->text() ); | 189 | mail->setSubject( subjectLine->text() ); |
181 | if (!m_replyid.isEmpty()) { | 190 | if (!m_replyid.isEmpty()) { |
182 | QStringList ids; | 191 | QStringList ids; |
183 | ids.append(m_replyid); | 192 | ids.append(m_replyid); |
184 | mail->setInreply(ids); | 193 | mail->setInreply(ids); |
185 | } | 194 | } |
186 | QString txt = message->text(); | 195 | QString txt = message->text(); |
187 | if ( !sigMultiLine->text().isEmpty() ) { | 196 | if ( !sigMultiLine->text().isEmpty() ) { |
188 | txt.append( "\n--\n" ); | 197 | txt.append( "\n--\n" ); |
189 | txt.append( sigMultiLine->text() ); | 198 | txt.append( sigMultiLine->text() ); |
190 | } | 199 | } |
191 | mail->setMessage( txt ); | 200 | mail->setMessage( txt ); |
192 | mail->setCharset (mEncoding); | 201 | mail->setCharset (mEncoding); |
193 | /* only use the default drafts folder name! */ | 202 | /* only use the default drafts folder name! */ |
194 | Storemail wrapper(AbstractMail::draftFolder()); | 203 | Storemail wrapper(AbstractMail::draftFolder()); |
195 | wrapper.storeMail(mail); | 204 | wrapper.storeMail(mail); |
196 | 205 | ||
197 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 206 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
198 | /* attachments we will ignore! */ | 207 | /* attachments we will ignore! */ |
199 | if ( it != 0 ) { | 208 | if ( it != 0 ) { |
200 | if ( warnAttach ) | 209 | if ( warnAttach ) |
201 | QMessageBox::warning(0,i18n("Store message"), | 210 | QMessageBox::warning(0,i18n("Store message"), |
202 | i18n("<center>Attachments will not be stored in \"Draft\" folder</center>")); | 211 | i18n("<center>Attachments will not be stored in \"Draft\" folder</center>")); |
203 | warnAttach = false; | 212 | warnAttach = false; |
204 | } | 213 | } |
205 | setStatus( i18n("Mail saved as draft!") ); | 214 | setStatus( i18n("Mail saved as draft!") ); |
206 | } | 215 | } |
207 | void ComposeMail::clearStatus() | 216 | void ComposeMail::clearStatus() |
208 | { | 217 | { |
209 | topLevelWidget()->setCaption( i18n("Compose mail") ); | 218 | topLevelWidget()->setCaption( i18n("Compose mail") ); |
210 | } | 219 | } |
211 | void ComposeMail::setStatus( QString status ) | 220 | void ComposeMail::setStatus( QString status ) |
212 | { | 221 | { |
213 | topLevelWidget()->setCaption( status ); | 222 | topLevelWidget()->setCaption( status ); |
214 | QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; | 223 | QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; |
215 | } | 224 | } |
216 | void ComposeMail::pickAddress( ) | 225 | void ComposeMail::pickAddress( ) |
217 | { | 226 | { |
218 | 227 | ||
219 | QLineEdit *line = mPickLineEdit; | 228 | QLineEdit *line = mPickLineEdit; |
220 | if ( line == 0 ) | 229 | if ( line == 0 ) |
221 | return; | 230 | return; |
222 | #ifdef DESKTOP_VERSION | 231 | #ifdef DESKTOP_VERSION |
223 | //qDebug(" ComposeMail::pickAddress "); | 232 | //qDebug(" ComposeMail::pickAddress "); |
224 | QString names ;//= AddressPicker::getNames(); | 233 | QString names ;//= AddressPicker::getNames(); |
225 | 234 | ||
226 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 235 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
227 | uint i=0; | 236 | uint i=0; |
228 | for (i=0; i < list.count(); i++) { | 237 | for (i=0; i < list.count(); i++) { |
229 | if ( !list[i].preferredEmail().isEmpty()) { | 238 | if ( !list[i].preferredEmail().isEmpty()) { |
230 | if ( ! names.isEmpty() ) | 239 | if ( ! names.isEmpty() ) |
231 | names+= ","; | 240 | names+= ","; |
232 | names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; | 241 | names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; |
233 | 242 | ||
234 | } | 243 | } |
235 | } | 244 | } |
236 | 245 | ||
237 | 246 | ||
238 | if ( line->text().isEmpty() ) { | 247 | if ( line->text().isEmpty() ) { |
239 | line->setText( names ); | 248 | line->setText( names ); |
240 | } else if ( !names.isEmpty() ) { | 249 | } else if ( !names.isEmpty() ) { |
241 | line->setText( line->text() + ", " + names ); | 250 | line->setText( line->text() + ", " + names ); |
242 | } | 251 | } |
243 | #else | 252 | #else |
244 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); | 253 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); |
245 | // the result should now arrive through method insertAttendees | 254 | // the result should now arrive through method insertAttendees |
246 | #endif | 255 | #endif |
247 | } | 256 | } |
248 | //the map includes name/email pairs, that comes from Ka/Pi | 257 | //the map includes name/email pairs, that comes from Ka/Pi |
249 | void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) | 258 | void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) |
250 | { | 259 | { |
251 | //qDebug("ComposeMail::insertAttendees "); | 260 | //qDebug("ComposeMail::insertAttendees "); |
252 | raise(); | 261 | raise(); |
253 | 262 | ||
254 | if ( mPickLineEdit == 0 ) { //whoami received | 263 | if ( mPickLineEdit == 0 ) { //whoami received |
255 | QString defmail = uidList[0]; | 264 | QString defmail = uidList[0]; |
256 | if ( emailList.count() == 0 ) | 265 | if ( emailList.count() == 0 ) |
257 | QMessageBox::information( 0, i18n( "Hint" ), | 266 | QMessageBox::information( 0, i18n( "Hint" ), |
258 | i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 267 | i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
259 | i18n( "Ok" ) ); | 268 | i18n( "Ok" ) ); |
260 | if (defmail.length()!=0) { | 269 | if (defmail.length()!=0) { |
261 | fromBox->insertItem(defmail); | 270 | fromBox->insertItem(defmail); |
262 | } | 271 | } |
263 | QStringList::ConstIterator sit = emailList.begin(); | 272 | QStringList::ConstIterator sit = emailList.begin(); |
264 | int pref = 0; | 273 | int pref = 0; |
265 | for (;sit!=emailList.end();++sit) { | 274 | for (;sit!=emailList.end();++sit) { |
266 | if ( (*sit)==defmail) | 275 | if ( (*sit)==defmail) |
267 | continue; | 276 | continue; |
268 | fromBox->insertItem((*sit)); | 277 | fromBox->insertItem((*sit)); |
269 | } | 278 | } |
270 | senderNameEdit->setText(nameList[0]); | 279 | senderNameEdit->setText(nameList[0]); |
271 | return; | 280 | return; |
272 | } | 281 | } |
273 | QString names ; | 282 | QString names ; |
274 | QLineEdit *line = mPickLineEdit; | 283 | QLineEdit *line = mPickLineEdit; |
275 | if (uid == this->name()) | 284 | if (uid == this->name()) |
276 | { | 285 | { |
277 | for ( int i = 0; i < nameList.count(); i++) | 286 | for ( int i = 0; i < nameList.count(); i++) |
278 | { | 287 | { |
279 | QString _name = nameList[i]; | 288 | QString _name = nameList[i]; |
280 | QString _email = emailList[i]; | 289 | QString _email = emailList[i]; |
281 | QString _uid = uidList[i]; | 290 | QString _uid = uidList[i]; |
282 | if ( ! _email.isEmpty() ) { | 291 | if ( ! _email.isEmpty() ) { |
283 | if ( ! names.isEmpty() ) | 292 | if ( ! names.isEmpty() ) |
284 | names+= ","; | 293 | names+= ","; |
285 | names+= "\""+_name +"\"<" +_email +">"; | 294 | names+= "\""+_name +"\"<" +_email +">"; |
286 | } | 295 | } |
287 | } | 296 | } |
288 | } | 297 | } |
289 | if ( line->text().isEmpty() ) { | 298 | if ( line->text().isEmpty() ) { |
290 | line->setText( names ); | 299 | line->setText( names ); |
291 | } else if ( !names.isEmpty() ) { | 300 | } else if ( !names.isEmpty() ) { |
292 | line->setText( line->text() + ", " + names ); | 301 | line->setText( line->text() + ", " + names ); |
293 | } | 302 | } |
294 | } | 303 | } |
295 | 304 | ||
296 | void ComposeMail::setTo( const QString & to ) | 305 | void ComposeMail::setTo( const QString & to ) |
297 | { | 306 | { |
298 | toLine->setText( to ); | 307 | toLine->setText( to ); |
299 | } | 308 | } |
300 | 309 | ||
301 | void ComposeMail::setSubject( const QString & subject ) | 310 | void ComposeMail::setSubject( const QString & subject ) |
302 | { | 311 | { |
303 | subjectLine->setText( subject ); | 312 | subjectLine->setText( subject ); |
304 | } | 313 | } |
305 | 314 | ||
306 | void ComposeMail::setInReplyTo( const QString & messageId ) | 315 | void ComposeMail::setInReplyTo( const QString & messageId ) |
307 | { | 316 | { |
308 | m_replyid = messageId; | 317 | m_replyid = messageId; |
309 | } | 318 | } |
310 | 319 | ||
311 | void ComposeMail::setMessage( const QString & text ) | 320 | void ComposeMail::setMessage( const QString & text ) |
312 | { | 321 | { |
313 | message->setText( text ); | 322 | message->setText( text ); |
314 | } | 323 | } |
315 | 324 | ||
316 | 325 | ||
317 | void ComposeMail::pickAddressTo() | 326 | void ComposeMail::pickAddressTo() |
318 | { | 327 | { |
319 | mPickLineEdit = toLine; | 328 | mPickLineEdit = toLine; |
320 | pickAddress( ); | 329 | pickAddress( ); |
321 | } | 330 | } |
322 | 331 | ||
323 | void ComposeMail::pickAddressCC() | 332 | void ComposeMail::pickAddressCC() |
324 | { | 333 | { |
325 | mPickLineEdit = ccLine; | 334 | mPickLineEdit = ccLine; |
326 | pickAddress( ); | 335 | pickAddress( ); |
327 | } | 336 | } |
328 | 337 | ||
329 | void ComposeMail::pickAddressBCC() | 338 | void ComposeMail::pickAddressBCC() |
330 | { | 339 | { |
331 | mPickLineEdit = bccLine; | 340 | mPickLineEdit = bccLine; |
332 | pickAddress( ); | 341 | pickAddress( ); |
333 | } | 342 | } |
334 | 343 | ||
335 | void ComposeMail::pickAddressReply() | 344 | void ComposeMail::pickAddressReply() |
336 | { | 345 | { |
337 | mPickLineEdit = replyLine; | 346 | mPickLineEdit = replyLine; |
338 | pickAddress( ); | 347 | pickAddress( ); |
339 | } | 348 | } |
340 | 349 | ||
341 | void ComposeMail::fillValues( int ) | 350 | void ComposeMail::fillValues( int current ) |
342 | { | 351 | { |
343 | #if 0 | 352 | #if 0 |
344 | SMTPaccount *smtp = smtpAccounts.at( current ); | 353 | SMTPaccount *smtp = smtpAccounts.at( current ); |
345 | ccLine->clear(); | 354 | ccLine->clear(); |
346 | if ( smtp->getUseCC() ) { | 355 | if ( smtp->getUseCC() ) { |
347 | ccLine->setText( smtp->getCC() ); | 356 | ccLine->setText( smtp->getCC() ); |
348 | } | 357 | } |
349 | bccLine->clear(); | 358 | bccLine->clear(); |
350 | if ( smtp->getUseBCC() ) { | 359 | if ( smtp->getUseBCC() ) { |
351 | bccLine->setText( smtp->getBCC() ); | 360 | bccLine->setText( smtp->getBCC() ); |
352 | } | 361 | } |
353 | replyLine->clear(); | 362 | replyLine->clear(); |
354 | if ( smtp->getUseReply() ) { | 363 | if ( smtp->getUseReply() ) { |
355 | replyLine->setText( smtp->getReply() ); | 364 | replyLine->setText( smtp->getReply() ); |
356 | } | 365 | } |
357 | sigMultiLine->setText( smtp->getSignature() ); | ||
358 | #endif | 366 | #endif |
367 | SMTPaccount *smtp = smtpAccounts.at( current ); | ||
368 | if ( smtp ) | ||
369 | sigMultiLine->setText( smtp->getSignature() ); | ||
359 | } | 370 | } |
360 | 371 | ||
361 | void ComposeMail::slotAdjustColumns() | 372 | void ComposeMail::slotAdjustColumns() |
362 | { | 373 | { |
363 | int currPage = tabWidget->currentPageIndex(); | 374 | int currPage = tabWidget->currentPageIndex(); |
364 | 375 | ||
365 | tabWidget->showPage( attachTab ); | 376 | tabWidget->showPage( attachTab ); |
366 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); | 377 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); |
367 | attList->setColumnWidth( 1, 80 ); | 378 | attList->setColumnWidth( 1, 80 ); |
368 | 379 | ||
369 | tabWidget->setCurrentPage( currPage ); | 380 | tabWidget->setCurrentPage( currPage ); |
370 | } | 381 | } |
371 | 382 | ||
372 | void ComposeMail::addAttachment() | 383 | void ComposeMail::addAttachment() |
373 | { | 384 | { |
374 | QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); | 385 | QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); |
375 | if ( !lnk.isEmpty() ) { | 386 | if ( !lnk.isEmpty() ) { |
376 | Attachment *att = new Attachment( lnk ); | 387 | Attachment *att = new Attachment( lnk ); |
377 | (void) new AttachViewItem( attList, att ); | 388 | (void) new AttachViewItem( attList, att ); |
378 | } | 389 | } |
379 | } | 390 | } |
380 | 391 | ||
381 | void ComposeMail::removeAttachment() | 392 | void ComposeMail::removeAttachment() |
382 | { | 393 | { |
383 | if ( !attList->currentItem() ) { | 394 | if ( !attList->currentItem() ) { |
384 | QMessageBox::information( this, i18n( "Error" ), | 395 | QMessageBox::information( this, i18n( "Error" ), |
385 | i18n( "<p>Please select a File.</p>" ), | 396 | i18n( "<p>Please select a File.</p>" ), |
386 | i18n( "Ok" ) ); | 397 | i18n( "Ok" ) ); |
387 | } else { | 398 | } else { |
388 | attList->takeItem( attList->currentItem() ); | 399 | attList->takeItem( attList->currentItem() ); |
389 | } | 400 | } |
390 | } | 401 | } |
391 | 402 | ||
392 | void ComposeMail::accept() | 403 | void ComposeMail::accept() |
393 | { | 404 | { |
394 | if ( smtpAccountBox->count() == 0 ) { | 405 | if ( smtpAccountBox->count() == 0 ) { |
395 | 406 | ||
396 | reject(); | 407 | reject(); |
397 | return; | 408 | return; |
398 | } | 409 | } |
399 | 410 | ||
400 | if (! checkBoxLater->isChecked() ) { | 411 | if (! checkBoxLater->isChecked() ) { |
401 | int yesno = QMessageBox::warning(0,i18n("Stop editing message"), | 412 | int yesno = QMessageBox::warning(0,i18n("Stop editing message"), |
402 | i18n("Send this message?"), | 413 | i18n("Send this message?"), |
403 | i18n("Yes"), | 414 | i18n("Yes"), |
404 | i18n("Cancel")); | 415 | i18n("Cancel")); |
405 | 416 | ||
406 | if (yesno == 1) { | 417 | if (yesno == 1) { |
407 | return; | 418 | return; |
408 | } | 419 | } |
409 | } | 420 | } |
410 | #if 0 | 421 | #if 0 |
411 | odebug << "Sending Mail with " | 422 | odebug << "Sending Mail with " |
412 | << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; | 423 | << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; |
413 | #endif | 424 | #endif |
414 | Opie::Core::OSmartPointer<Mail> mail=new Mail; | 425 | Opie::Core::OSmartPointer<Mail> mail=new Mail; |
415 | 426 | ||
416 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); | 427 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); |
417 | mail->setMail(fromBox->currentText()); | 428 | mail->setMail(fromBox->currentText()); |
418 | 429 | ||
419 | if ( !toLine->text().isEmpty() ) { | 430 | if ( !toLine->text().isEmpty() ) { |
420 | mail->setTo( toLine->text() ); | 431 | mail->setTo( toLine->text() ); |
421 | } else { | 432 | } else { |
422 | QMessageBox::warning(0,i18n("Sending mail"), | 433 | QMessageBox::warning(0,i18n("Sending mail"), |
423 | i18n("No Receiver spezified" ) ); | 434 | i18n("No Receiver spezified" ) ); |
424 | return; | 435 | return; |
425 | } | 436 | } |
426 | 437 | ||
427 | mail->setName(senderNameEdit->text()); | 438 | mail->setName(senderNameEdit->text()); |
428 | mail->setCC( ccLine->text() ); | 439 | mail->setCC( ccLine->text() ); |
429 | mail->setBCC( bccLine->text() ); | 440 | mail->setBCC( bccLine->text() ); |
430 | mail->setReply( replyLine->text() ); | 441 | mail->setReply( replyLine->text() ); |
431 | mail->setSubject( subjectLine->text() ); | 442 | mail->setSubject( subjectLine->text() ); |
432 | if (!m_replyid.isEmpty()) { | 443 | if (!m_replyid.isEmpty()) { |
433 | QStringList ids; | 444 | QStringList ids; |
434 | ids.append(m_replyid); | 445 | ids.append(m_replyid); |
435 | mail->setInreply(ids); | 446 | mail->setInreply(ids); |
436 | } | 447 | } |
437 | QString txt = message->text(); | 448 | QString txt = message->text(); |
438 | if ( !sigMultiLine->text().isEmpty() ) { | 449 | if ( !sigMultiLine->text().isEmpty() ) { |
439 | txt.append( "\n--\n" ); | 450 | txt.append( "\n--\n" ); |
440 | txt.append( sigMultiLine->text() ); | 451 | txt.append( sigMultiLine->text() ); |
441 | } | 452 | } |
442 | mail->setMessage( txt ); | 453 | mail->setMessage( txt ); |
443 | mail->setCharset (mEncoding); | 454 | mail->setCharset (mEncoding); |
444 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 455 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
445 | while ( it != 0 ) { | 456 | while ( it != 0 ) { |
446 | mail->addAttachment( it->getAttachment() ); | 457 | mail->addAttachment( it->getAttachment() ); |
447 | it = (AttachViewItem *) it->nextSibling(); | 458 | it = (AttachViewItem *) it->nextSibling(); |
448 | } | 459 | } |
449 | 460 | ||
450 | SMTPwrapper wrapper( smtp ); | 461 | SMTPwrapper wrapper( smtp ); |
451 | if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) | 462 | if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) |
452 | setStatus( tr ("Mail sent")); | 463 | setStatus( tr ("Mail sent")); |
453 | else { | 464 | else { |
454 | setStatus( tr ("Error: Something went wrong. Nothing sent")); | 465 | setStatus( tr ("Error: Something went wrong. Nothing sent")); |