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