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