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