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