-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 | |||
@@ -1,519 +1,530 @@ | |||
1 | // CHANGED 2004-08-06 Lutz Rogowski | 1 | // CHANGED 2004-08-06 Lutz Rogowski |
2 | 2 | ||
3 | 3 | ||
4 | #ifdef DESKTOP_VERSION | 4 | #ifdef DESKTOP_VERSION |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #include <kabc/addresseedialog.h> | 6 | #include <kabc/addresseedialog.h> |
7 | #include <kabc/stdaddressbook.h> | 7 | #include <kabc/stdaddressbook.h> |
8 | #include <kabc/addressee.h> | 8 | #include <kabc/addressee.h> |
9 | #else | 9 | #else |
10 | #include <qpe/qpeapplication.h> | 10 | #include <qpe/qpeapplication.h> |
11 | #endif //DESKTOP_VERSION | 11 | #endif //DESKTOP_VERSION |
12 | #include <libkdepim/externalapphandler.h> | 12 | #include <libkdepim/externalapphandler.h> |
13 | 13 | ||
14 | #include "koprefs.h" | 14 | #include "koprefs.h" |
15 | #include <klocale.h> | 15 | #include <klocale.h> |
16 | #include <kglobal.h> | 16 | #include <kglobal.h> |
17 | 17 | ||
18 | #ifdef MINIKDE_KDIALOG_H | 18 | #ifdef MINIKDE_KDIALOG_H |
19 | #undef MINIKDE_KDIALOG_H | 19 | #undef MINIKDE_KDIALOG_H |
20 | #endif | 20 | #endif |
21 | 21 | ||
22 | 22 | ||
23 | #include "composemail.h" | 23 | #include "composemail.h" |
24 | 24 | ||
25 | #include <libmailwrapper/smtpwrapper.h> | 25 | #include <libmailwrapper/smtpwrapper.h> |
26 | #include <libmailwrapper/storemail.h> | 26 | #include <libmailwrapper/storemail.h> |
27 | #include <libmailwrapper/abstractmail.h> | 27 | #include <libmailwrapper/abstractmail.h> |
28 | #include <libmailwrapper/mailtypes.h> | 28 | #include <libmailwrapper/mailtypes.h> |
29 | 29 | ||
30 | /* OPIE */ | 30 | /* OPIE */ |
31 | //#include <opie2/ofiledialog.h> | 31 | //#include <opie2/ofiledialog.h> |
32 | //#include <opie2/odebug.h> | 32 | //#include <opie2/odebug.h> |
33 | #include <kfiledialog.h> | 33 | #include <kfiledialog.h> |
34 | //#include <qpe/resource.h> | 34 | //#include <qpe/resource.h> |
35 | #include <qpe/global.h> | 35 | #include <qpe/global.h> |
36 | //#include <qpe/contact.h> | 36 | //#include <qpe/contact.h> |
37 | 37 | ||
38 | 38 | ||
39 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
40 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
41 | #include <qiconset.h> | 41 | #include <qiconset.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qmessagebox.h> | 43 | #include <qmessagebox.h> |
44 | #include <qpushbutton.h> | 44 | #include <qpushbutton.h> |
45 | #include <qmultilineedit.h> | 45 | #include <qmultilineedit.h> |
46 | #include <qlabel.h> | 46 | #include <qlabel.h> |
47 | #include <qtabwidget.h> | 47 | #include <qtabwidget.h> |
48 | #include <qlistview.h> | 48 | #include <qlistview.h> |
49 | 49 | ||
50 | //using namespace Opie::Core; | 50 | //using namespace Opie::Core; |
51 | //using namespace Opie::Ui; | 51 | //using namespace Opie::Ui; |
52 | ComposeMail::ComposeMail( Settings *sett, QWidget *parent, const char *name, bool modal ) | 52 | ComposeMail::ComposeMail( Settings *sett, QWidget *parent, const char *name, bool modal ) |
53 | : ComposeMailUI( parent, name, modal ) | 53 | : ComposeMailUI( parent, name, modal ) |
54 | { | 54 | { |
55 | 55 | ||
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")); |
455 | return; | 466 | return; |
456 | } | 467 | } |
457 | 468 | ||
458 | 469 | ||
459 | QDialog::accept(); | 470 | QDialog::accept(); |
460 | } | 471 | } |
461 | 472 | ||
462 | void ComposeMail::reject() | 473 | void ComposeMail::reject() |
463 | { | 474 | { |
464 | //qDebug("ComposeMail::reject() "); | 475 | //qDebug("ComposeMail::reject() "); |
465 | int yesno = QMessageBox::warning(0,i18n("Store message?"), | 476 | int yesno = QMessageBox::warning(0,i18n("Store message?"), |
466 | i18n("Store message into drafts?\n"), | 477 | i18n("Store message into drafts?\n"), |
467 | i18n("Yes"), | 478 | i18n("Yes"), |
468 | i18n("No")); | 479 | i18n("No")); |
469 | 480 | ||
470 | //qDebug("button %d ", yesno); | 481 | //qDebug("button %d ", yesno); |
471 | if (yesno == 0) { | 482 | if (yesno == 0) { |
472 | if ( toLine->text().isEmpty() ) { | 483 | if ( toLine->text().isEmpty() ) { |
473 | QMessageBox::warning(0,i18n("Sending mail"), | 484 | QMessageBox::warning(0,i18n("Sending mail"), |
474 | i18n("No Receiver spezified" ) ); | 485 | i18n("No Receiver spezified" ) ); |
475 | return; | 486 | return; |
476 | } | 487 | } |
477 | saveAsDraft(); | 488 | saveAsDraft(); |
478 | } | 489 | } |
479 | if (yesno == 2) { | 490 | if (yesno == 2) { |
480 | qDebug("return "); | 491 | qDebug("return "); |
481 | return; | 492 | return; |
482 | } | 493 | } |
483 | QDialog::reject(); | 494 | QDialog::reject(); |
484 | } | 495 | } |
485 | 496 | ||
486 | void ComposeMail::setCharset(const QString& charset) | 497 | void ComposeMail::setCharset(const QString& charset) |
487 | { | 498 | { |
488 | if ( !charset.isEmpty() ) | 499 | if ( !charset.isEmpty() ) |
489 | mEncoding = charset; | 500 | mEncoding = charset; |
490 | qDebug("ComposeMail::setCharset %s ", mEncoding.latin1()); | 501 | qDebug("ComposeMail::setCharset %s ", mEncoding.latin1()); |
491 | } | 502 | } |
492 | ComposeMail::~ComposeMail() | 503 | ComposeMail::~ComposeMail() |
493 | { | 504 | { |
494 | } | 505 | } |
495 | 506 | ||
496 | void ComposeMail::reEditMail(const RecMailP¤t) | 507 | void ComposeMail::reEditMail(const RecMailP¤t) |
497 | { | 508 | { |
498 | RecMailP data = current; | 509 | RecMailP data = current; |
499 | RecBodyP body = data->Wrapper()->fetchBody(current); | 510 | RecBodyP body = data->Wrapper()->fetchBody(current); |
500 | 511 | ||
501 | message->setText(body->Bodytext()); | 512 | message->setText(body->Bodytext()); |
502 | subjectLine->setText( data->getSubject()); | 513 | subjectLine->setText( data->getSubject()); |
503 | toLine->setText(data->To().join(",")); | 514 | toLine->setText(data->To().join(",")); |
504 | ccLine->setText(data->CC().join(",")); | 515 | ccLine->setText(data->CC().join(",")); |
505 | bccLine->setText(data->Bcc().join(",")); | 516 | bccLine->setText(data->Bcc().join(",")); |
506 | replyLine->setText(data->Replyto()); | 517 | replyLine->setText(data->Replyto()); |
507 | setCharset(body->getCharset()); | 518 | setCharset(body->getCharset()); |
508 | } | 519 | } |
509 | 520 | ||
510 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) | 521 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) |
511 | : QListViewItem( parent ) | 522 | : QListViewItem( parent ) |
512 | { | 523 | { |
513 | attachment = att; | 524 | attachment = att; |
514 | if ( !attachment->getPixmap().isNull() ) | 525 | if ( !attachment->getPixmap().isNull() ) |
515 | setPixmap( 0,attachment->getPixmap() ); | 526 | setPixmap( 0,attachment->getPixmap() ); |
516 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); | 527 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); |
517 | setText( 1, QString::number( att->getSize() ) ); | 528 | setText( 1, QString::number( att->getSize() ) ); |
518 | } | 529 | } |
519 | 530 | ||