-rw-r--r-- | kmicromail/composemail.cpp | 58 | ||||
-rw-r--r-- | kmicromail/composemail.h | 2 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.cpp | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 11 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mailtypes.cpp | 11 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mailtypes.h | 3 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mailwrapper.h | 5 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/storemail.cpp | 12 | ||||
-rw-r--r-- | kmicromail/opiemail.cpp | 2 | ||||
-rw-r--r-- | kmicromail/viewmail.cpp | 1 |
10 files changed, 74 insertions, 32 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 | ||
diff --git a/kmicromail/composemail.h b/kmicromail/composemail.h index 0fc41fb..a7fa41c 100644 --- a/kmicromail/composemail.h +++ b/kmicromail/composemail.h | |||
@@ -1,91 +1,93 @@ | |||
1 | #ifndef COMPOSEMAIL_H | 1 | #ifndef COMPOSEMAIL_H |
2 | #define COMPOSEMAIL_H | 2 | #define COMPOSEMAIL_H |
3 | 3 | ||
4 | #include <qlineedit.h> | 4 | #include <qlineedit.h> |
5 | #include <qlistview.h> | 5 | #include <qlistview.h> |
6 | 6 | ||
7 | #include "composemailui.h" | 7 | #include "composemailui.h" |
8 | //#include "addresspickerui.h" | 8 | //#include "addresspickerui.h" |
9 | #include <libmailwrapper/settings.h> | 9 | #include <libmailwrapper/settings.h> |
10 | #include <libmailwrapper/mailwrapper.h> | 10 | #include <libmailwrapper/mailwrapper.h> |
11 | 11 | ||
12 | class RecMail; | 12 | class RecMail; |
13 | 13 | ||
14 | #include <opie2/osmartpointer.h> | 14 | #include <opie2/osmartpointer.h> |
15 | #if 0 | 15 | #if 0 |
16 | class AddressPicker : public AddressPickerUI | 16 | class AddressPicker : public AddressPickerUI |
17 | { | 17 | { |
18 | //Q_OBJECT | 18 | //Q_OBJECT |
19 | 19 | ||
20 | public: | 20 | public: |
21 | AddressPicker( QWidget *parent = 0, const char *name = 0, bool modal = false ); | 21 | AddressPicker( QWidget *parent = 0, const char *name = 0, bool modal = false ); |
22 | static QString getNames(); | 22 | static QString getNames(); |
23 | 23 | ||
24 | protected: | 24 | protected: |
25 | QString selectedNames; | 25 | QString selectedNames; |
26 | void accept(); | 26 | void accept(); |
27 | 27 | ||
28 | }; | 28 | }; |
29 | #endif | 29 | #endif |
30 | class RecMail; | 30 | class RecMail; |
31 | 31 | ||
32 | class ComposeMail : public ComposeMailUI | 32 | class ComposeMail : public ComposeMailUI |
33 | { | 33 | { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | 35 | ||
36 | public: | 36 | public: |
37 | 37 | ||
38 | ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false ); | 38 | ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false ); |
39 | virtual ~ComposeMail(); | 39 | virtual ~ComposeMail(); |
40 | 40 | ||
41 | void reEditMail(const Opie::Core::OSmartPointer<RecMail>¤t); | 41 | void reEditMail(const Opie::Core::OSmartPointer<RecMail>¤t); |
42 | 42 | ||
43 | public slots: | 43 | public slots: |
44 | void slotAdjustColumns(); | 44 | void slotAdjustColumns(); |
45 | 45 | ||
46 | void setTo( const QString & to ); | 46 | void setTo( const QString & to ); |
47 | void setSubject( const QString & subject ); | 47 | void setSubject( const QString & subject ); |
48 | void setInReplyTo( const QString & messageId ); | 48 | void setInReplyTo( const QString & messageId ); |
49 | void setMessage( const QString & text ); | 49 | void setMessage( const QString & text ); |
50 | void insertAttendees(const QString&, const QStringList& namelist, const QStringList& emaillist, const QStringList& uidlist); | 50 | void insertAttendees(const QString&, const QStringList& namelist, const QStringList& emaillist, const QStringList& uidlist); |
51 | void setCharset(const QString&); | ||
51 | 52 | ||
52 | 53 | ||
53 | protected slots: | 54 | protected slots: |
54 | void accept(); | 55 | void accept(); |
55 | void reject(); | 56 | void reject(); |
56 | 57 | ||
57 | private slots: | 58 | private slots: |
58 | void fillValues( int current ); | 59 | void fillValues( int current ); |
59 | void fillSettings(); | 60 | void fillSettings(); |
60 | void pickAddress(); | 61 | void pickAddress(); |
61 | void pickAddressTo(); | 62 | void pickAddressTo(); |
62 | void pickAddressCC(); | 63 | void pickAddressCC(); |
63 | void pickAddressBCC(); | 64 | void pickAddressBCC(); |
64 | void pickAddressReply(); | 65 | void pickAddressReply(); |
65 | void saveAsDraft(); | 66 | void saveAsDraft(); |
66 | void addAttachment(); | 67 | void addAttachment(); |
67 | void removeAttachment(); | 68 | void removeAttachment(); |
68 | void clearStatus(); | 69 | void clearStatus(); |
69 | void setStatus( QString ); | 70 | void setStatus( QString ); |
70 | 71 | ||
71 | protected: | 72 | protected: |
72 | QLineEdit* mPickLineEdit; | 73 | QLineEdit* mPickLineEdit; |
73 | Opie::Core::OSmartPointer<Mail> mMail; | 74 | Opie::Core::OSmartPointer<Mail> mMail; |
74 | Settings *settings; | 75 | Settings *settings; |
75 | QList<SMTPaccount> smtpAccounts; | 76 | QList<SMTPaccount> smtpAccounts; |
76 | QString m_replyid; | 77 | QString m_replyid; |
78 | QString mEncoding; | ||
77 | bool warnAttach; | 79 | bool warnAttach; |
78 | }; | 80 | }; |
79 | 81 | ||
80 | class AttachViewItem : public QListViewItem | 82 | class AttachViewItem : public QListViewItem |
81 | { | 83 | { |
82 | public: | 84 | public: |
83 | AttachViewItem( QListView *parent, Attachment *att ); | 85 | AttachViewItem( QListView *parent, Attachment *att ); |
84 | Attachment *getAttachment() { return attachment; } | 86 | Attachment *getAttachment() { return attachment; } |
85 | 87 | ||
86 | private: | 88 | private: |
87 | Attachment *attachment; | 89 | Attachment *attachment; |
88 | 90 | ||
89 | }; | 91 | }; |
90 | 92 | ||
91 | #endif | 93 | #endif |
diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp index 49227dd..28d45ce 100644 --- a/kmicromail/libmailwrapper/genericwrapper.cpp +++ b/kmicromail/libmailwrapper/genericwrapper.cpp | |||
@@ -37,384 +37,385 @@ const QDateTime Genericwrapper::parseDateTime( mailimf_date_time *date ) | |||
37 | //qDebug("adsec1 %d ",addsec ); | 37 | //qDebug("adsec1 %d ",addsec ); |
38 | dt = dt.addSecs( addsec ); | 38 | dt = dt.addSecs( addsec ); |
39 | int off = KGlobal::locale()->localTimeOffset( dt ); | 39 | int off = KGlobal::locale()->localTimeOffset( dt ); |
40 | //qDebug("adsec2 %d ",off*60 ); | 40 | //qDebug("adsec2 %d ",off*60 ); |
41 | 41 | ||
42 | dt = dt.addSecs( off*60 ); | 42 | dt = dt.addSecs( off*60 ); |
43 | return dt; | 43 | return dt; |
44 | #if 0 | 44 | #if 0 |
45 | QString ret; | 45 | QString ret; |
46 | if ( dt.date() == QDate::currentDate () ) | 46 | if ( dt.date() == QDate::currentDate () ) |
47 | ret = KGlobal::locale()->formatTime( dt.time(),true); | 47 | ret = KGlobal::locale()->formatTime( dt.time(),true); |
48 | 48 | ||
49 | else { | 49 | else { |
50 | ret = KGlobal::locale()->formatDateTime( dt,true,true); | 50 | ret = KGlobal::locale()->formatDateTime( dt,true,true); |
51 | } | 51 | } |
52 | #endif | 52 | #endif |
53 | #if 0 | 53 | #if 0 |
54 | if ( off < 0 ) | 54 | if ( off < 0 ) |
55 | ret += " -"; | 55 | ret += " -"; |
56 | else | 56 | else |
57 | ret += " +"; | 57 | ret += " +"; |
58 | ret += QString::number( off / 60 ); | 58 | ret += QString::number( off / 60 ); |
59 | ret += "h"; | 59 | ret += "h"; |
60 | #endif | 60 | #endif |
61 | #if 0 | 61 | #if 0 |
62 | char tmp[23]; | 62 | char tmp[23]; |
63 | 63 | ||
64 | // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | 64 | // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", |
65 | // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 65 | // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
66 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", | 66 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", |
67 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 67 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
68 | 68 | ||
69 | 69 | ||
70 | return QString( tmp ); | 70 | return QString( tmp ); |
71 | #endif | 71 | #endif |
72 | //return ret; | 72 | //return ret; |
73 | } | 73 | } |
74 | 74 | ||
75 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) | 75 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) |
76 | { | 76 | { |
77 | if (!mime) { | 77 | if (!mime) { |
78 | return; | 78 | return; |
79 | } | 79 | } |
80 | mailmime_field*field = 0; | 80 | mailmime_field*field = 0; |
81 | mailmime_single_fields fields; | 81 | mailmime_single_fields fields; |
82 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 82 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
83 | if (mime->mm_mime_fields != NULL) { | 83 | if (mime->mm_mime_fields != NULL) { |
84 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, | 84 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, |
85 | mime->mm_content_type); | 85 | mime->mm_content_type); |
86 | } | 86 | } |
87 | 87 | ||
88 | mailmime_content*type = fields.fld_content; | 88 | mailmime_content*type = fields.fld_content; |
89 | clistcell*current; | 89 | clistcell*current; |
90 | if (!type) { | 90 | if (!type) { |
91 | target->setType("text"); | 91 | target->setType("text"); |
92 | target->setSubtype("plain"); | 92 | target->setSubtype("plain"); |
93 | } else { | 93 | } else { |
94 | target->setSubtype(type->ct_subtype); | 94 | target->setSubtype(type->ct_subtype); |
95 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { | 95 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { |
96 | case MAILMIME_DISCRETE_TYPE_TEXT: | 96 | case MAILMIME_DISCRETE_TYPE_TEXT: |
97 | target->setType("text"); | 97 | target->setType("text"); |
98 | break; | 98 | break; |
99 | case MAILMIME_DISCRETE_TYPE_IMAGE: | 99 | case MAILMIME_DISCRETE_TYPE_IMAGE: |
100 | target->setType("image"); | 100 | target->setType("image"); |
101 | break; | 101 | break; |
102 | case MAILMIME_DISCRETE_TYPE_AUDIO: | 102 | case MAILMIME_DISCRETE_TYPE_AUDIO: |
103 | target->setType("audio"); | 103 | target->setType("audio"); |
104 | break; | 104 | break; |
105 | case MAILMIME_DISCRETE_TYPE_VIDEO: | 105 | case MAILMIME_DISCRETE_TYPE_VIDEO: |
106 | target->setType("video"); | 106 | target->setType("video"); |
107 | break; | 107 | break; |
108 | case MAILMIME_DISCRETE_TYPE_APPLICATION: | 108 | case MAILMIME_DISCRETE_TYPE_APPLICATION: |
109 | target->setType("application"); | 109 | target->setType("application"); |
110 | break; | 110 | break; |
111 | case MAILMIME_DISCRETE_TYPE_EXTENSION: | 111 | case MAILMIME_DISCRETE_TYPE_EXTENSION: |
112 | default: | 112 | default: |
113 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { | 113 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { |
114 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); | 114 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); |
115 | } | 115 | } |
116 | break; | 116 | break; |
117 | } | 117 | } |
118 | if (type->ct_parameters) { | 118 | if (type->ct_parameters) { |
119 | fillParameters(target,type->ct_parameters); | 119 | fillParameters(target,type->ct_parameters); |
120 | } | 120 | } |
121 | } | 121 | } |
122 | if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { | 122 | if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { |
123 | for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { | 123 | for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { |
124 | field = (mailmime_field*)current->data; | 124 | field = (mailmime_field*)current->data; |
125 | switch(field->fld_type) { | 125 | switch(field->fld_type) { |
126 | case MAILMIME_FIELD_TRANSFER_ENCODING: | 126 | case MAILMIME_FIELD_TRANSFER_ENCODING: |
127 | target->setEncoding(getencoding(field->fld_data.fld_encoding)); | 127 | target->setEncoding(getencoding(field->fld_data.fld_encoding)); |
128 | break; | 128 | break; |
129 | case MAILMIME_FIELD_ID: | 129 | case MAILMIME_FIELD_ID: |
130 | target->setIdentifier(field->fld_data.fld_id); | 130 | target->setIdentifier(field->fld_data.fld_id); |
131 | break; | 131 | break; |
132 | case MAILMIME_FIELD_DESCRIPTION: | 132 | case MAILMIME_FIELD_DESCRIPTION: |
133 | target->setDescription(field->fld_data.fld_description); | 133 | target->setDescription(field->fld_data.fld_description); |
134 | break; | 134 | break; |
135 | default: | 135 | default: |
136 | break; | 136 | break; |
137 | } | 137 | } |
138 | } | 138 | } |
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
142 | void Genericwrapper::fillParameters(RecPartP&target,clist*parameters) | 142 | void Genericwrapper::fillParameters(RecPartP&target,clist*parameters) |
143 | { | 143 | { |
144 | if (!parameters) {return;} | 144 | if (!parameters) {return;} |
145 | clistcell*current=0; | 145 | clistcell*current=0; |
146 | mailmime_parameter*param; | 146 | mailmime_parameter*param; |
147 | for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { | 147 | for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { |
148 | param = (mailmime_parameter*)current->data; | 148 | param = (mailmime_parameter*)current->data; |
149 | if (param) { | 149 | if (param) { |
150 | target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 150 | target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
151 | } | 151 | } |
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) | 155 | QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) |
156 | { | 156 | { |
157 | QString enc="7bit"; | 157 | QString enc="7bit"; |
158 | if (!aEnc) return enc; | 158 | if (!aEnc) return enc; |
159 | switch(aEnc->enc_type) { | 159 | switch(aEnc->enc_type) { |
160 | case MAILMIME_MECHANISM_7BIT: | 160 | case MAILMIME_MECHANISM_7BIT: |
161 | enc = "7bit"; | 161 | enc = "7bit"; |
162 | break; | 162 | break; |
163 | case MAILMIME_MECHANISM_8BIT: | 163 | case MAILMIME_MECHANISM_8BIT: |
164 | enc = "8bit"; | 164 | enc = "8bit"; |
165 | break; | 165 | break; |
166 | case MAILMIME_MECHANISM_BINARY: | 166 | case MAILMIME_MECHANISM_BINARY: |
167 | enc = "binary"; | 167 | enc = "binary"; |
168 | break; | 168 | break; |
169 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: | 169 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: |
170 | enc = "quoted-printable"; | 170 | enc = "quoted-printable"; |
171 | break; | 171 | break; |
172 | case MAILMIME_MECHANISM_BASE64: | 172 | case MAILMIME_MECHANISM_BASE64: |
173 | enc = "base64"; | 173 | enc = "base64"; |
174 | break; | 174 | break; |
175 | case MAILMIME_MECHANISM_TOKEN: | 175 | case MAILMIME_MECHANISM_TOKEN: |
176 | default: | 176 | default: |
177 | if (aEnc->enc_token) { | 177 | if (aEnc->enc_token) { |
178 | enc = QString(aEnc->enc_token); | 178 | enc = QString(aEnc->enc_token); |
179 | } | 179 | } |
180 | break; | 180 | break; |
181 | } | 181 | } |
182 | return enc; | 182 | return enc; |
183 | } | 183 | } |
184 | 184 | ||
185 | void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) | 185 | void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) |
186 | { | 186 | { |
187 | if (current_rec >= 10) { | 187 | if (current_rec >= 10) { |
188 | ; // odebug << "too deep recursion!" << oendl; | 188 | ; // odebug << "too deep recursion!" << oendl; |
189 | } | 189 | } |
190 | if (!message || !mime) { | 190 | if (!message || !mime) { |
191 | return; | 191 | return; |
192 | } | 192 | } |
193 | int r; | 193 | int r; |
194 | char*data = 0; | 194 | char*data = 0; |
195 | size_t len; | 195 | size_t len; |
196 | clistiter * cur = 0; | 196 | clistiter * cur = 0; |
197 | QString b; | 197 | QString b; |
198 | RecPartP part = new RecPart(); | 198 | RecPartP part = new RecPart(); |
199 | 199 | ||
200 | switch (mime->mm_type) { | 200 | switch (mime->mm_type) { |
201 | case MAILMIME_SINGLE: | 201 | case MAILMIME_SINGLE: |
202 | { | 202 | { |
203 | QValueList<int>countlist = recList; | 203 | QValueList<int>countlist = recList; |
204 | countlist.append(current_count); | 204 | countlist.append(current_count); |
205 | r = mailmessage_fetch_section(message,mime,&data,&len); | 205 | r = mailmessage_fetch_section(message,mime,&data,&len); |
206 | part->setSize(len); | 206 | part->setSize(len); |
207 | part->setPositionlist(countlist); | 207 | part->setPositionlist(countlist); |
208 | b = gen_attachment_id(); | 208 | b = gen_attachment_id(); |
209 | part->setIdentifier(b); | 209 | part->setIdentifier(b); |
210 | fillSingleBody(part,message,mime); | 210 | fillSingleBody(part,message,mime); |
211 | if (part->Type()=="text" && target->Bodytext().isNull()) { | 211 | if (part->Type()=="text" && target->Bodytext().isNull()) { |
212 | encodedString*rs = new encodedString(); | 212 | encodedString*rs = new encodedString(); |
213 | rs->setContent(data,len); | 213 | rs->setContent(data,len); |
214 | encodedString*res = decode_String(rs,part->Encoding()); | 214 | encodedString*res = decode_String(rs,part->Encoding()); |
215 | if (countlist.count()>2) { | 215 | if (countlist.count()>2) { |
216 | bodyCache[b]=rs; | 216 | bodyCache[b]=rs; |
217 | target->addPart(part); | 217 | target->addPart(part); |
218 | } else { | 218 | } else { |
219 | delete rs; | 219 | delete rs; |
220 | } | 220 | } |
221 | b = QString(res->Content()); | 221 | b = QString(res->Content()); |
222 | delete res; | 222 | delete res; |
223 | size_t index = 0; | 223 | size_t index = 0; |
224 | char*resu = 0; | 224 | char*resu = 0; |
225 | int err = MAILIMF_NO_ERROR; | 225 | int err = MAILIMF_NO_ERROR; |
226 | QString charset = part->searchParamter( "charset"); | 226 | QString charset = part->searchParamter( "charset"); |
227 | qDebug("CHARSET %s ",charset.latin1() ); | 227 | qDebug("CHARSET %s ",charset.latin1() ); |
228 | if ( !charset.isEmpty() ) { | 228 | if ( !charset.isEmpty() ) { |
229 | target->setCharset( charset ); | ||
229 | err = mailmime_encoded_phrase_parse(charset.latin1(), | 230 | err = mailmime_encoded_phrase_parse(charset.latin1(), |
230 | b.latin1(), b.length(),&index, "utf-8",&resu); | 231 | b.latin1(), b.length(),&index, "utf-8",&resu); |
231 | if (err == MAILIMF_NO_ERROR && resu && strlen(resu)) { | 232 | if (err == MAILIMF_NO_ERROR && resu && strlen(resu)) { |
232 | //qDebug("res %d %s ", index, resu); | 233 | //qDebug("res %d %s ", index, resu); |
233 | b = QString::fromUtf8(resu); | 234 | b = QString::fromUtf8(resu); |
234 | } | 235 | } |
235 | if (resu) free(resu); | 236 | if (resu) free(resu); |
236 | } | 237 | } |
237 | target->setBodytext(b); | 238 | target->setBodytext(b); |
238 | target->setDescription(part); | 239 | target->setDescription(part); |
239 | } else { | 240 | } else { |
240 | bodyCache[b]=new encodedString(data,len); | 241 | bodyCache[b]=new encodedString(data,len); |
241 | target->addPart(part); | 242 | target->addPart(part); |
242 | } | 243 | } |
243 | } | 244 | } |
244 | break; | 245 | break; |
245 | case MAILMIME_MULTIPLE: | 246 | case MAILMIME_MULTIPLE: |
246 | { | 247 | { |
247 | unsigned int ccount = 1; | 248 | unsigned int ccount = 1; |
248 | mailmime*cbody=0; | 249 | mailmime*cbody=0; |
249 | QValueList<int>countlist = recList; | 250 | QValueList<int>countlist = recList; |
250 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { | 251 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { |
251 | cbody = (mailmime*)clist_content(cur); | 252 | cbody = (mailmime*)clist_content(cur); |
252 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 253 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
253 | RecPartP targetPart = new RecPart(); | 254 | RecPartP targetPart = new RecPart(); |
254 | targetPart->setType("multipart"); | 255 | targetPart->setType("multipart"); |
255 | countlist.append(current_count); | 256 | countlist.append(current_count); |
256 | targetPart->setPositionlist(countlist); | 257 | targetPart->setPositionlist(countlist); |
257 | target->addPart(targetPart); | 258 | target->addPart(targetPart); |
258 | } | 259 | } |
259 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); | 260 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); |
260 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 261 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
261 | countlist = recList; | 262 | countlist = recList; |
262 | } | 263 | } |
263 | ++ccount; | 264 | ++ccount; |
264 | } | 265 | } |
265 | } | 266 | } |
266 | break; | 267 | break; |
267 | case MAILMIME_MESSAGE: | 268 | case MAILMIME_MESSAGE: |
268 | { | 269 | { |
269 | QValueList<int>countlist = recList; | 270 | QValueList<int>countlist = recList; |
270 | countlist.append(current_count); | 271 | countlist.append(current_count); |
271 | /* the own header is always at recursion 0 - we don't need that */ | 272 | /* the own header is always at recursion 0 - we don't need that */ |
272 | if (current_rec > 0) { | 273 | if (current_rec > 0) { |
273 | part->setPositionlist(countlist); | 274 | part->setPositionlist(countlist); |
274 | r = mailmessage_fetch_section(message,mime,&data,&len); | 275 | r = mailmessage_fetch_section(message,mime,&data,&len); |
275 | part->setSize(len); | 276 | part->setSize(len); |
276 | part->setPositionlist(countlist); | 277 | part->setPositionlist(countlist); |
277 | b = gen_attachment_id(); | 278 | b = gen_attachment_id(); |
278 | part->setIdentifier(b); | 279 | part->setIdentifier(b); |
279 | part->setType("message"); | 280 | part->setType("message"); |
280 | part->setSubtype("rfc822"); | 281 | part->setSubtype("rfc822"); |
281 | bodyCache[b]=new encodedString(data,len); | 282 | bodyCache[b]=new encodedString(data,len); |
282 | target->addPart(part); | 283 | target->addPart(part); |
283 | } | 284 | } |
284 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { | 285 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { |
285 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); | 286 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); |
286 | } | 287 | } |
287 | } | 288 | } |
288 | break; | 289 | break; |
289 | } | 290 | } |
290 | } | 291 | } |
291 | 292 | ||
292 | RecBodyP Genericwrapper::parseMail( mailmessage * msg ) | 293 | RecBodyP Genericwrapper::parseMail( mailmessage * msg ) |
293 | { | 294 | { |
294 | int err = MAILIMF_NO_ERROR; | 295 | int err = MAILIMF_NO_ERROR; |
295 | //mailmime_single_fields fields; | 296 | //mailmime_single_fields fields; |
296 | /* is bound to msg and will be freed there */ | 297 | /* is bound to msg and will be freed there */ |
297 | mailmime * mime=0; | 298 | mailmime * mime=0; |
298 | RecBodyP body = new RecBody(); | 299 | RecBodyP body = new RecBody(); |
299 | //memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 300 | //memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
300 | err = mailmessage_get_bodystructure(msg,&mime); | 301 | err = mailmessage_get_bodystructure(msg,&mime); |
301 | QValueList<int>recList; | 302 | QValueList<int>recList; |
302 | traverseBody(body,msg,mime,recList); | 303 | traverseBody(body,msg,mime,recList); |
303 | return body; | 304 | return body; |
304 | } | 305 | } |
305 | 306 | ||
306 | 307 | ||
307 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) | 308 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) |
308 | { | 309 | { |
309 | QString result( "" ); | 310 | QString result( "" ); |
310 | 311 | ||
311 | bool first = true; | 312 | bool first = true; |
312 | if (list == 0) return result; | 313 | if (list == 0) return result; |
313 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { | 314 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { |
314 | mailimf_address *addr = (mailimf_address *) current->data; | 315 | mailimf_address *addr = (mailimf_address *) current->data; |
315 | 316 | ||
316 | if ( !first ) { | 317 | if ( !first ) { |
317 | result.append( "," ); | 318 | result.append( "," ); |
318 | } else { | 319 | } else { |
319 | first = false; | 320 | first = false; |
320 | } | 321 | } |
321 | 322 | ||
322 | switch ( addr->ad_type ) { | 323 | switch ( addr->ad_type ) { |
323 | case MAILIMF_ADDRESS_MAILBOX: | 324 | case MAILIMF_ADDRESS_MAILBOX: |
324 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); | 325 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); |
325 | break; | 326 | break; |
326 | case MAILIMF_ADDRESS_GROUP: | 327 | case MAILIMF_ADDRESS_GROUP: |
327 | result.append( parseGroup( addr->ad_data.ad_group ) ); | 328 | result.append( parseGroup( addr->ad_data.ad_group ) ); |
328 | break; | 329 | break; |
329 | default: | 330 | default: |
330 | ; // odebug << "Generic: unkown mailimf address type" << oendl; | 331 | ; // odebug << "Generic: unkown mailimf address type" << oendl; |
331 | break; | 332 | break; |
332 | } | 333 | } |
333 | } | 334 | } |
334 | 335 | ||
335 | return result; | 336 | return result; |
336 | } | 337 | } |
337 | 338 | ||
338 | QString Genericwrapper::parseGroup( mailimf_group *group ) | 339 | QString Genericwrapper::parseGroup( mailimf_group *group ) |
339 | { | 340 | { |
340 | QString result( "" ); | 341 | QString result( "" ); |
341 | 342 | ||
342 | result.append( group->grp_display_name ); | 343 | result.append( group->grp_display_name ); |
343 | result.append( ": " ); | 344 | result.append( ": " ); |
344 | 345 | ||
345 | if ( group->grp_mb_list != NULL ) { | 346 | if ( group->grp_mb_list != NULL ) { |
346 | result.append( parseMailboxList( group->grp_mb_list ) ); | 347 | result.append( parseMailboxList( group->grp_mb_list ) ); |
347 | } | 348 | } |
348 | 349 | ||
349 | result.append( ";" ); | 350 | result.append( ";" ); |
350 | 351 | ||
351 | return result; | 352 | return result; |
352 | } | 353 | } |
353 | 354 | ||
354 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) | 355 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) |
355 | { | 356 | { |
356 | QString result( "" ); | 357 | QString result( "" ); |
357 | 358 | ||
358 | if ( box->mb_display_name == NULL ) { | 359 | if ( box->mb_display_name == NULL ) { |
359 | result.append( box->mb_addr_spec ); | 360 | result.append( box->mb_addr_spec ); |
360 | } else { | 361 | } else { |
361 | result.append( convert_String(box->mb_display_name) ); | 362 | result.append( convert_String(box->mb_display_name) ); |
362 | result.append( " <" ); | 363 | result.append( " <" ); |
363 | result.append( box->mb_addr_spec ); | 364 | result.append( box->mb_addr_spec ); |
364 | result.append( ">" ); | 365 | result.append( ">" ); |
365 | } | 366 | } |
366 | 367 | ||
367 | return result; | 368 | return result; |
368 | } | 369 | } |
369 | 370 | ||
370 | QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) | 371 | QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) |
371 | { | 372 | { |
372 | QString result( "" ); | 373 | QString result( "" ); |
373 | 374 | ||
374 | bool first = true; | 375 | bool first = true; |
375 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { | 376 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { |
376 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; | 377 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; |
377 | 378 | ||
378 | if ( !first ) { | 379 | if ( !first ) { |
379 | result.append( "," ); | 380 | result.append( "," ); |
380 | } else { | 381 | } else { |
381 | first = false; | 382 | first = false; |
382 | } | 383 | } |
383 | 384 | ||
384 | result.append( parseMailbox( box ) ); | 385 | result.append( parseMailbox( box ) ); |
385 | } | 386 | } |
386 | 387 | ||
387 | return result; | 388 | return result; |
388 | } | 389 | } |
389 | 390 | ||
390 | encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPartP&part) | 391 | encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPartP&part) |
391 | { | 392 | { |
392 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); | 393 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); |
393 | if (it==bodyCache.end()) return new encodedString(); | 394 | if (it==bodyCache.end()) return new encodedString(); |
394 | encodedString*t = decode_String(it.data(),part->Encoding()); | 395 | encodedString*t = decode_String(it.data(),part->Encoding()); |
395 | return t; | 396 | return t; |
396 | } | 397 | } |
397 | 398 | ||
398 | encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part) | 399 | encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part) |
399 | { | 400 | { |
400 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); | 401 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); |
401 | if (it==bodyCache.end()) return new encodedString(); | 402 | if (it==bodyCache.end()) return new encodedString(); |
402 | encodedString*t = it.data(); | 403 | encodedString*t = it.data(); |
403 | return t; | 404 | return t; |
404 | } | 405 | } |
405 | 406 | ||
406 | QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) | 407 | QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) |
407 | { | 408 | { |
408 | encodedString*t = fetchDecodedPart(mail,part); | 409 | encodedString*t = fetchDecodedPart(mail,part); |
409 | QString text=t->Content(); | 410 | QString text=t->Content(); |
410 | delete t; | 411 | delete t; |
411 | return text; | 412 | return text; |
412 | } | 413 | } |
413 | 414 | ||
414 | void Genericwrapper::cleanMimeCache() | 415 | void Genericwrapper::cleanMimeCache() |
415 | { | 416 | { |
416 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); | 417 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); |
417 | for (;it!=bodyCache.end();++it) { | 418 | for (;it!=bodyCache.end();++it) { |
418 | encodedString*t = it.data(); | 419 | encodedString*t = it.data(); |
419 | //it.setValue(0); | 420 | //it.setValue(0); |
420 | if (t) delete t; | 421 | if (t) delete t; |
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index eb2b47d..2a54381 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,955 +1,956 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include <qpe/global.h> | 4 | #include <qpe/global.h> |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #include "imapwrapper.h" | 6 | #include "imapwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include "logindialog.h" | 8 | #include "logindialog.h" |
9 | #include <qprogressbar.h> | 9 | #include <qprogressbar.h> |
10 | #include "genericwrapper.h" | 10 | #include "genericwrapper.h" |
11 | #include <kglobal.h> | 11 | #include <kglobal.h> |
12 | 12 | ||
13 | using namespace Opie::Core; | 13 | using namespace Opie::Core; |
14 | int IMAPwrapper::mMax = 0; | 14 | int IMAPwrapper::mMax = 0; |
15 | int IMAPwrapper::mCurrent = 0; | 15 | int IMAPwrapper::mCurrent = 0; |
16 | 16 | ||
17 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 17 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
18 | : AbstractMail() | 18 | : AbstractMail() |
19 | { | 19 | { |
20 | account = a; | 20 | account = a; |
21 | m_imap = 0; | 21 | m_imap = 0; |
22 | m_Lastmbox = ""; | 22 | m_Lastmbox = ""; |
23 | mCurrent = 0; | 23 | mCurrent = 0; |
24 | mMax = 0; | 24 | mMax = 0; |
25 | } | 25 | } |
26 | 26 | ||
27 | IMAPwrapper::~IMAPwrapper() | 27 | IMAPwrapper::~IMAPwrapper() |
28 | { | 28 | { |
29 | logout(); | 29 | logout(); |
30 | } | 30 | } |
31 | 31 | ||
32 | /* to avoid to often select statements in loops etc. | 32 | /* to avoid to often select statements in loops etc. |
33 | we trust that we are logged in and connection is established!*/ | 33 | we trust that we are logged in and connection is established!*/ |
34 | int IMAPwrapper::selectMbox(const QString&mbox) | 34 | int IMAPwrapper::selectMbox(const QString&mbox) |
35 | { | 35 | { |
36 | if (mbox == m_Lastmbox) { | 36 | if (mbox == m_Lastmbox) { |
37 | return MAILIMAP_NO_ERROR; | 37 | return MAILIMAP_NO_ERROR; |
38 | } | 38 | } |
39 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | 39 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); |
40 | if ( err != MAILIMAP_NO_ERROR ) { | 40 | if ( err != MAILIMAP_NO_ERROR ) { |
41 | m_Lastmbox = ""; | 41 | m_Lastmbox = ""; |
42 | return err; | 42 | return err; |
43 | } | 43 | } |
44 | m_Lastmbox = mbox; | 44 | m_Lastmbox = mbox; |
45 | return err; | 45 | return err; |
46 | } | 46 | } |
47 | 47 | ||
48 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 48 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
49 | { | 49 | { |
50 | //qDebug("imap progress %d of %d ",current,maximum ); | 50 | //qDebug("imap progress %d of %d ",current,maximum ); |
51 | //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum)); | 51 | //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum)); |
52 | //qApp->processEvents() | 52 | //qApp->processEvents() |
53 | static int last = 0; | 53 | static unsigned int last = 0; |
54 | if ( last != current ) | 54 | if ( last != current ) |
55 | IMAPwrapper::progress(); | 55 | IMAPwrapper::progress(); |
56 | last = current; | 56 | last = current; |
57 | } | 57 | } |
58 | void IMAPwrapper::progress( QString m ) | 58 | void IMAPwrapper::progress( QString m ) |
59 | { | 59 | { |
60 | 60 | ||
61 | static QString mProgrMess; | 61 | static QString mProgrMess; |
62 | if ( m != QString::null ) { | 62 | if ( m != QString::null ) { |
63 | mProgrMess = m; | 63 | mProgrMess = m; |
64 | mCurrent = 1; | 64 | mCurrent = 1; |
65 | return; | 65 | return; |
66 | } | 66 | } |
67 | QString mess; | 67 | QString mess; |
68 | //qDebug("progress "); | 68 | //qDebug("progress "); |
69 | if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax); | 69 | if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax); |
70 | else mess = mProgrMess +i18n(" message %1").arg( mCurrent++); | 70 | else mess = mProgrMess +i18n(" message %1").arg( mCurrent++); |
71 | Global::statusMessage(mess); | 71 | Global::statusMessage(mess); |
72 | //qDebug("Progress %s %s", mess.latin1(), m.latin1()); | 72 | //qDebug("Progress %s %s", mess.latin1(), m.latin1()); |
73 | qApp->processEvents(); | 73 | qApp->processEvents(); |
74 | } | 74 | } |
75 | bool IMAPwrapper::start_tls(bool force_tls) | 75 | bool IMAPwrapper::start_tls(bool force_tls) |
76 | { | 76 | { |
77 | int err; | 77 | int err; |
78 | bool try_tls = force_tls; | 78 | bool try_tls = force_tls; |
79 | mailimap_capability_data * cap_data = 0; | 79 | mailimap_capability_data * cap_data = 0; |
80 | 80 | ||
81 | err = mailimap_capability(m_imap,&cap_data); | 81 | err = mailimap_capability(m_imap,&cap_data); |
82 | if (err != MAILIMAP_NO_ERROR) { | 82 | if (err != MAILIMAP_NO_ERROR) { |
83 | Global::statusMessage("error getting capabilities!"); | 83 | Global::statusMessage("error getting capabilities!"); |
84 | return false; | 84 | return false; |
85 | } | 85 | } |
86 | clistiter * cur; | 86 | clistiter * cur; |
87 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { | 87 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { |
88 | struct mailimap_capability * cap; | 88 | struct mailimap_capability * cap; |
89 | cap = (struct mailimap_capability *)clist_content(cur); | 89 | cap = (struct mailimap_capability *)clist_content(cur); |
90 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { | 90 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { |
91 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { | 91 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { |
92 | try_tls = true; | 92 | try_tls = true; |
93 | break; | 93 | break; |
94 | } | 94 | } |
95 | } | 95 | } |
96 | } | 96 | } |
97 | if (cap_data) { | 97 | if (cap_data) { |
98 | mailimap_capability_data_free(cap_data); | 98 | mailimap_capability_data_free(cap_data); |
99 | } | 99 | } |
100 | if (try_tls) { | 100 | if (try_tls) { |
101 | err = mailimap_starttls(m_imap); | 101 | err = mailimap_starttls(m_imap); |
102 | if (err != MAILIMAP_NO_ERROR && force_tls) { | 102 | if (err != MAILIMAP_NO_ERROR && force_tls) { |
103 | Global::statusMessage(i18n("Server has no TLS support!")); | 103 | Global::statusMessage(i18n("Server has no TLS support!")); |
104 | try_tls = false; | 104 | try_tls = false; |
105 | } else { | 105 | } else { |
106 | mailstream_low * low; | 106 | mailstream_low * low; |
107 | mailstream_low * new_low; | 107 | mailstream_low * new_low; |
108 | low = mailstream_get_low(m_imap->imap_stream); | 108 | low = mailstream_get_low(m_imap->imap_stream); |
109 | if (!low) { | 109 | if (!low) { |
110 | try_tls = false; | 110 | try_tls = false; |
111 | } else { | 111 | } else { |
112 | int fd = mailstream_low_get_fd(low); | 112 | int fd = mailstream_low_get_fd(low); |
113 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { | 113 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { |
114 | mailstream_low_free(low); | 114 | mailstream_low_free(low); |
115 | mailstream_set_low(m_imap->imap_stream, new_low); | 115 | mailstream_set_low(m_imap->imap_stream, new_low); |
116 | } else { | 116 | } else { |
117 | try_tls = false; | 117 | try_tls = false; |
118 | } | 118 | } |
119 | } | 119 | } |
120 | } | 120 | } |
121 | } | 121 | } |
122 | return try_tls; | 122 | return try_tls; |
123 | } | 123 | } |
124 | 124 | ||
125 | void IMAPwrapper::login() | 125 | void IMAPwrapper::login() |
126 | { | 126 | { |
127 | QString server, user, pass; | 127 | QString server, user, pass; |
128 | uint16_t port; | 128 | uint16_t port; |
129 | int err = MAILIMAP_NO_ERROR; | 129 | int err = MAILIMAP_NO_ERROR; |
130 | 130 | ||
131 | if (account->getOffline()) return; | 131 | if (account->getOffline()) return; |
132 | /* we are connected this moment */ | 132 | /* we are connected this moment */ |
133 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 133 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
134 | if (m_imap) { | 134 | if (m_imap) { |
135 | err = mailimap_noop(m_imap); | 135 | err = mailimap_noop(m_imap); |
136 | if (err!=MAILIMAP_NO_ERROR) { | 136 | if (err!=MAILIMAP_NO_ERROR) { |
137 | logout(); | 137 | logout(); |
138 | } else { | 138 | } else { |
139 | mailstream_flush(m_imap->imap_stream); | 139 | mailstream_flush(m_imap->imap_stream); |
140 | return; | 140 | return; |
141 | } | 141 | } |
142 | } | 142 | } |
143 | server = account->getServer(); | 143 | server = account->getServer(); |
144 | port = account->getPort().toUInt(); | 144 | port = account->getPort().toUInt(); |
145 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 145 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
146 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 146 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
147 | login.show(); | 147 | login.show(); |
148 | if ( QDialog::Accepted == login.exec() ) { | 148 | if ( QDialog::Accepted == login.exec() ) { |
149 | // ok | 149 | // ok |
150 | user = login.getUser(); | 150 | user = login.getUser(); |
151 | pass = login.getPassword(); | 151 | pass = login.getPassword(); |
152 | } else { | 152 | } else { |
153 | // cancel | 153 | // cancel |
154 | return; | 154 | return; |
155 | } | 155 | } |
156 | } else { | 156 | } else { |
157 | user = account->getUser(); | 157 | user = account->getUser(); |
158 | pass = account->getPassword(); | 158 | pass = account->getPassword(); |
159 | } | 159 | } |
160 | 160 | ||
161 | m_imap = mailimap_new( 20, &imap_progress ); | 161 | m_imap = mailimap_new( 20, &imap_progress ); |
162 | 162 | ||
163 | /* connect */ | 163 | /* connect */ |
164 | bool ssl = false; | 164 | bool ssl = false; |
165 | bool try_tls = false; | 165 | bool try_tls = false; |
166 | bool force_tls = false; | 166 | bool force_tls = false; |
167 | 167 | ||
168 | if ( account->ConnectionType() == 2 ) { | 168 | if ( account->ConnectionType() == 2 ) { |
169 | ssl = true; | 169 | ssl = true; |
170 | } | 170 | } |
171 | if (account->ConnectionType()==1) { | 171 | if (account->ConnectionType()==1) { |
172 | force_tls = true; | 172 | force_tls = true; |
173 | } | 173 | } |
174 | 174 | ||
175 | if ( ssl ) { | 175 | if ( ssl ) { |
176 | qDebug("using ssl "); | 176 | qDebug("using ssl "); |
177 | err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); | 177 | err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); |
178 | qDebug("back "); | 178 | qDebug("back "); |
179 | } else { | 179 | } else { |
180 | err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); | 180 | err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); |
181 | } | 181 | } |
182 | 182 | ||
183 | if ( err != MAILIMAP_NO_ERROR && | 183 | if ( err != MAILIMAP_NO_ERROR && |
184 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 184 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
185 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 185 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
186 | QString failure = ""; | 186 | QString failure = ""; |
187 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { | 187 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { |
188 | failure="Connection refused"; | 188 | failure="Connection refused"; |
189 | } else { | 189 | } else { |
190 | failure="Unknown failure"; | 190 | failure="Unknown failure"; |
191 | } | 191 | } |
192 | Global::statusMessage(i18n("error connecting imap server: %1").arg(failure)); | 192 | Global::statusMessage(i18n("error connecting imap server: %1").arg(failure)); |
193 | mailimap_free( m_imap ); | 193 | mailimap_free( m_imap ); |
194 | m_imap = 0; | 194 | m_imap = 0; |
195 | return; | 195 | return; |
196 | } | 196 | } |
197 | 197 | ||
198 | if (!ssl) { | 198 | if (!ssl) { |
199 | try_tls = start_tls(force_tls); | 199 | try_tls = start_tls(force_tls); |
200 | } | 200 | } |
201 | 201 | ||
202 | bool ok = true; | 202 | bool ok = true; |
203 | if (force_tls && !try_tls) { | 203 | if (force_tls && !try_tls) { |
204 | Global::statusMessage(i18n("Server has no TLS support!")); | 204 | Global::statusMessage(i18n("Server has no TLS support!")); |
205 | ok = false; | 205 | ok = false; |
206 | } | 206 | } |
207 | 207 | ||
208 | 208 | ||
209 | /* login */ | 209 | /* login */ |
210 | 210 | ||
211 | if (ok) { | 211 | if (ok) { |
212 | err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); | 212 | err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); |
213 | if ( err != MAILIMAP_NO_ERROR ) { | 213 | if ( err != MAILIMAP_NO_ERROR ) { |
214 | Global::statusMessage(i18n("error logging in imap server: %1").arg(m_imap->imap_response)); | 214 | Global::statusMessage(i18n("error logging in imap server: %1").arg(m_imap->imap_response)); |
215 | ok = false; | 215 | ok = false; |
216 | } | 216 | } |
217 | } | 217 | } |
218 | if (!ok) { | 218 | if (!ok) { |
219 | err = mailimap_close( m_imap ); | 219 | err = mailimap_close( m_imap ); |
220 | mailimap_free( m_imap ); | 220 | mailimap_free( m_imap ); |
221 | m_imap = 0; | 221 | m_imap = 0; |
222 | } | 222 | } |
223 | } | 223 | } |
224 | 224 | ||
225 | void IMAPwrapper::logout() | 225 | void IMAPwrapper::logout() |
226 | { | 226 | { |
227 | int err = MAILIMAP_NO_ERROR; | 227 | int err = MAILIMAP_NO_ERROR; |
228 | if (!m_imap) return; | 228 | if (!m_imap) return; |
229 | err = mailimap_logout( m_imap ); | 229 | err = mailimap_logout( m_imap ); |
230 | err = mailimap_close( m_imap ); | 230 | err = mailimap_close( m_imap ); |
231 | mailimap_free( m_imap ); | 231 | mailimap_free( m_imap ); |
232 | m_imap = 0; | 232 | m_imap = 0; |
233 | m_Lastmbox = ""; | 233 | m_Lastmbox = ""; |
234 | } | 234 | } |
235 | 235 | ||
236 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) | 236 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) |
237 | { | 237 | { |
238 | 238 | ||
239 | int tryAgain = 1; | 239 | int tryAgain = 1; |
240 | while ( tryAgain >= 0 ) { | 240 | while ( tryAgain >= 0 ) { |
241 | int err = MAILIMAP_NO_ERROR; | 241 | int err = MAILIMAP_NO_ERROR; |
242 | clist *result = 0; | 242 | clist *result = 0; |
243 | clistcell *current; | 243 | clistcell *current; |
244 | mailimap_fetch_type *fetchType = 0; | 244 | mailimap_fetch_type *fetchType = 0; |
245 | mailimap_set *set = 0; | 245 | mailimap_set *set = 0; |
246 | 246 | ||
247 | login(); | 247 | login(); |
248 | if (!m_imap) { | 248 | if (!m_imap) { |
249 | return; | 249 | return; |
250 | } | 250 | } |
251 | /* select mailbox READONLY for operations */ | 251 | /* select mailbox READONLY for operations */ |
252 | err = selectMbox(mailbox); | 252 | err = selectMbox(mailbox); |
253 | if ( err != MAILIMAP_NO_ERROR ) { | 253 | if ( err != MAILIMAP_NO_ERROR ) { |
254 | return; | 254 | return; |
255 | } | 255 | } |
256 | 256 | ||
257 | int last = m_imap->imap_selection_info->sel_exists; | 257 | int last = m_imap->imap_selection_info->sel_exists; |
258 | 258 | ||
259 | if (last == 0) { | 259 | if (last == 0) { |
260 | Global::statusMessage(i18n("Mailbox has no mails")); | 260 | Global::statusMessage(i18n("Mailbox has no mails")); |
261 | return; | 261 | return; |
262 | } else { | 262 | } else { |
263 | } | 263 | } |
264 | progress( i18n("Fetch ")); | 264 | progress( i18n("Fetch ")); |
265 | mMax = last; | 265 | mMax = last; |
266 | //qDebug("last %d ", last); | 266 | //qDebug("last %d ", last); |
267 | Global::statusMessage(i18n("Fetching header list")); | 267 | Global::statusMessage(i18n("Fetching header list")); |
268 | qApp->processEvents(); | 268 | qApp->processEvents(); |
269 | /* the range has to start at 1!!! not with 0!!!! */ | 269 | /* the range has to start at 1!!! not with 0!!!! */ |
270 | //LR the access to web.de imap server is no working with value 1 | 270 | //LR the access to web.de imap server is no working with value 1 |
271 | //qDebug("interval %d - %d ", tryAgain, last-1+tryAgain ); | 271 | //qDebug("interval %d - %d ", tryAgain, last-1+tryAgain ); |
272 | set = mailimap_set_new_interval( tryAgain, last ); | 272 | set = mailimap_set_new_interval( tryAgain, last ); |
273 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); | 273 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); |
274 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); | 274 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); |
275 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); | 275 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); |
276 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); | 276 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); |
277 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); | 277 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); |
278 | 278 | ||
279 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 279 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
280 | mailimap_set_free( set ); | 280 | mailimap_set_free( set ); |
281 | mailimap_fetch_type_free( fetchType ); | 281 | mailimap_fetch_type_free( fetchType ); |
282 | 282 | ||
283 | QString date,subject,from; | 283 | QString date,subject,from; |
284 | 284 | ||
285 | if ( err == MAILIMAP_NO_ERROR ) { | 285 | if ( err == MAILIMAP_NO_ERROR ) { |
286 | tryAgain = -1; | 286 | tryAgain = -1; |
287 | mailimap_msg_att * msg_att; | 287 | mailimap_msg_att * msg_att; |
288 | int i = 0; | 288 | int i = 0; |
289 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | 289 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { |
290 | ++i; | 290 | ++i; |
291 | //qDebug("iii %d ",i); | 291 | //qDebug("iii %d ",i); |
292 | msg_att = (mailimap_msg_att*)current->data; | 292 | msg_att = (mailimap_msg_att*)current->data; |
293 | RecMail*m = parse_list_result(msg_att); | 293 | RecMail*m = parse_list_result(msg_att); |
294 | if (m) { | 294 | if (m) { |
295 | if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) { | 295 | if ( maxSizeInKb == 0 || m->Msgsize()<=(unsigned int ) maxSizeInKb*1024 ) { |
296 | m->setNumber(i); | 296 | m->setNumber(i); |
297 | m->setMbox(mailbox); | 297 | m->setMbox(mailbox); |
298 | m->setWrapper(this); | 298 | m->setWrapper(this); |
299 | target.append(m); | 299 | target.append(m); |
300 | } | 300 | } |
301 | } | 301 | } |
302 | } | 302 | } |
303 | Global::statusMessage(i18n("Mailbox has %1 mails").arg(target.count())); | 303 | Global::statusMessage(i18n("Mailbox has %1 mails").arg(target.count())); |
304 | } else { | 304 | } else { |
305 | --tryAgain; | 305 | --tryAgain; |
306 | --tryAgain;//disabled tryagain by adding this line | 306 | --tryAgain;//disabled tryagain by adding this line |
307 | if ( tryAgain < 0 ) | 307 | if ( tryAgain < 0 ) |
308 | Global::statusMessage(i18n("Error fetching headers: %1").arg(m_imap->imap_response)); | 308 | Global::statusMessage(i18n("Error fetching headers: %1").arg(m_imap->imap_response)); |
309 | else | 309 | else |
310 | qDebug("try again... "); | 310 | qDebug("try again... "); |
311 | } | 311 | } |
312 | 312 | ||
313 | if (result) mailimap_fetch_list_free(result); | 313 | if (result) mailimap_fetch_list_free(result); |
314 | } | 314 | } |
315 | } | 315 | } |
316 | 316 | ||
317 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | 317 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() |
318 | { | 318 | { |
319 | const char *path, *mask; | 319 | const char *path, *mask; |
320 | int err = MAILIMAP_NO_ERROR; | 320 | int err = MAILIMAP_NO_ERROR; |
321 | clist *result = 0; | 321 | clist *result = 0; |
322 | clistcell *current = 0; | 322 | clistcell *current = 0; |
323 | clistcell*cur_flag = 0; | 323 | clistcell*cur_flag = 0; |
324 | mailimap_mbx_list_flags*bflags = 0; | 324 | mailimap_mbx_list_flags*bflags = 0; |
325 | 325 | ||
326 | QValueList<FolderP>* folders = new QValueList<FolderP>(); | 326 | QValueList<FolderP>* folders = new QValueList<FolderP>(); |
327 | login(); | 327 | login(); |
328 | if (!m_imap) { | 328 | if (!m_imap) { |
329 | return folders; | 329 | return folders; |
330 | } | 330 | } |
331 | 331 | ||
332 | /* | 332 | /* |
333 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 333 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
334 | * We must not forget to filter them out in next loop! | 334 | * We must not forget to filter them out in next loop! |
335 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 335 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
336 | */ | 336 | */ |
337 | Global::statusMessage(i18n("Fetching folder list")); | 337 | Global::statusMessage(i18n("Fetching folder list")); |
338 | qApp->processEvents(); | 338 | qApp->processEvents(); |
339 | QString temp; | 339 | QString temp; |
340 | mask = "INBOX" ; | 340 | mask = "INBOX" ; |
341 | mailimap_mailbox_list *list; | 341 | mailimap_mailbox_list *list; |
342 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 342 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
343 | QString del; | 343 | QString del; |
344 | bool selectable = true; | 344 | bool selectable = true; |
345 | bool no_inferiors = false; | 345 | bool no_inferiors = false; |
346 | if ( err == MAILIMAP_NO_ERROR ) { | 346 | if ( err == MAILIMAP_NO_ERROR ) { |
347 | current = result->first; | 347 | current = result->first; |
348 | for ( int i = result->count; i > 0; i-- ) { | 348 | for ( int i = result->count; i > 0; i-- ) { |
349 | list = (mailimap_mailbox_list *) current->data; | 349 | list = (mailimap_mailbox_list *) current->data; |
350 | // it is better use the deep copy mechanism of qt itself | 350 | // it is better use the deep copy mechanism of qt itself |
351 | // instead of using strdup! | 351 | // instead of using strdup! |
352 | temp = list->mb_name; | 352 | temp = list->mb_name; |
353 | del = list->mb_delimiter; | 353 | del = list->mb_delimiter; |
354 | current = current->next; | 354 | current = current->next; |
355 | if ( (bflags = list->mb_flag) ) { | 355 | if ( (bflags = list->mb_flag) ) { |
356 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 356 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
357 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 357 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
358 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 358 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
359 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 359 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
360 | no_inferiors = true; | 360 | no_inferiors = true; |
361 | } | 361 | } |
362 | } | 362 | } |
363 | } | 363 | } |
364 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 364 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
365 | } | 365 | } |
366 | } else { | 366 | } else { |
367 | qDebug("error fetching folders: "); | 367 | qDebug("error fetching folders: "); |
368 | 368 | ||
369 | } | 369 | } |
370 | mailimap_list_result_free( result ); | 370 | mailimap_list_result_free( result ); |
371 | 371 | ||
372 | /* | 372 | /* |
373 | * second stage - get the other then inbox folders | 373 | * second stage - get the other then inbox folders |
374 | */ | 374 | */ |
375 | mask = "*" ; | 375 | mask = "*" ; |
376 | path = account->getPrefix().latin1(); | 376 | path = account->getPrefix().latin1(); |
377 | if (!path) path = ""; | 377 | if (!path) path = ""; |
378 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 378 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
379 | if ( err == MAILIMAP_NO_ERROR ) { | 379 | if ( err == MAILIMAP_NO_ERROR ) { |
380 | current = result->first; | 380 | current = result->first; |
381 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { | 381 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { |
382 | no_inferiors = false; | 382 | no_inferiors = false; |
383 | list = (mailimap_mailbox_list *) current->data; | 383 | list = (mailimap_mailbox_list *) current->data; |
384 | // it is better use the deep copy mechanism of qt itself | 384 | // it is better use the deep copy mechanism of qt itself |
385 | // instead of using strdup! | 385 | // instead of using strdup! |
386 | temp = list->mb_name; | 386 | temp = list->mb_name; |
387 | if (temp.lower()=="inbox") | 387 | if (temp.lower()=="inbox") |
388 | continue; | 388 | continue; |
389 | if (temp.lower()==account->getPrefix().lower()) | 389 | if (temp.lower()==account->getPrefix().lower()) |
390 | continue; | 390 | continue; |
391 | if ( (bflags = list->mb_flag) ) { | 391 | if ( (bflags = list->mb_flag) ) { |
392 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 392 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
393 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 393 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
394 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 394 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
395 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 395 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
396 | no_inferiors = true; | 396 | no_inferiors = true; |
397 | } | 397 | } |
398 | } | 398 | } |
399 | } | 399 | } |
400 | del = list->mb_delimiter; | 400 | del = list->mb_delimiter; |
401 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 401 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
402 | } | 402 | } |
403 | } else { | 403 | } else { |
404 | qDebug("error fetching folders "); | 404 | qDebug("error fetching folders "); |
405 | 405 | ||
406 | } | 406 | } |
407 | if (result) mailimap_list_result_free( result ); | 407 | if (result) mailimap_list_result_free( result ); |
408 | return folders; | 408 | return folders; |
409 | } | 409 | } |
410 | 410 | ||
411 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 411 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
412 | { | 412 | { |
413 | RecMail * m = 0; | 413 | RecMail * m = 0; |
414 | mailimap_msg_att_item *item=0; | 414 | mailimap_msg_att_item *item=0; |
415 | clistcell *current,*c,*cf; | 415 | clistcell *current,*c,*cf; |
416 | mailimap_msg_att_dynamic*flist; | 416 | mailimap_msg_att_dynamic*flist; |
417 | mailimap_flag_fetch*cflag; | 417 | mailimap_flag_fetch*cflag; |
418 | int size; | 418 | int size = 0; |
419 | QBitArray mFlags(7); | 419 | QBitArray mFlags(7); |
420 | QStringList addresslist; | 420 | QStringList addresslist; |
421 | 421 | ||
422 | if (!m_att) { | 422 | if (!m_att) { |
423 | return m; | 423 | return m; |
424 | } | 424 | } |
425 | m = new RecMail(); | 425 | m = new RecMail(); |
426 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 426 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
427 | current = c; | 427 | current = c; |
428 | size = 0; | 428 | size = 0; |
429 | item = (mailimap_msg_att_item*)current->data; | 429 | item = (mailimap_msg_att_item*)current->data; |
430 | if ( !item ) | 430 | if ( !item ) |
431 | continue; | 431 | continue; |
432 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 432 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
433 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 433 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
434 | if (!flist || !flist->att_list) { | 434 | if (!flist || !flist->att_list) { |
435 | continue; | 435 | continue; |
436 | } | 436 | } |
437 | cf = flist->att_list->first; | 437 | cf = flist->att_list->first; |
438 | if( ! cf ) | 438 | if( ! cf ) |
439 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 439 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
440 | cflag = (mailimap_flag_fetch*)cf->data; | 440 | cflag = (mailimap_flag_fetch*)cf->data; |
441 | if( ! cflag ) | 441 | if( ! cflag ) |
442 | qDebug("imap:not cflag "); | 442 | qDebug("imap:not cflag "); |
443 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 443 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
444 | switch (cflag->fl_flag->fl_type) { | 444 | switch (cflag->fl_flag->fl_type) { |
445 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 445 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
446 | mFlags.setBit(FLAG_ANSWERED); | 446 | mFlags.setBit(FLAG_ANSWERED); |
447 | break; | 447 | break; |
448 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 448 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
449 | mFlags.setBit(FLAG_FLAGGED); | 449 | mFlags.setBit(FLAG_FLAGGED); |
450 | break; | 450 | break; |
451 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 451 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
452 | mFlags.setBit(FLAG_DELETED); | 452 | mFlags.setBit(FLAG_DELETED); |
453 | break; | 453 | break; |
454 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 454 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
455 | mFlags.setBit(FLAG_SEEN); | 455 | mFlags.setBit(FLAG_SEEN); |
456 | break; | 456 | break; |
457 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 457 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
458 | mFlags.setBit(FLAG_DRAFT); | 458 | mFlags.setBit(FLAG_DRAFT); |
459 | break; | 459 | break; |
460 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 460 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
461 | break; | 461 | break; |
462 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 462 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
463 | break; | 463 | break; |
464 | default: | 464 | default: |
465 | break; | 465 | break; |
466 | } | 466 | } |
467 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 467 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
468 | mFlags.setBit(FLAG_RECENT); | 468 | mFlags.setBit(FLAG_RECENT); |
469 | } | 469 | } |
470 | } | 470 | } |
471 | continue; | 471 | continue; |
472 | } | 472 | } |
473 | if ( item->att_data.att_static == NULL ) | 473 | if ( item->att_data.att_static == NULL ) |
474 | continue; | 474 | continue; |
475 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 475 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
476 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 476 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
477 | if ( head == NULL ) | 477 | if ( head == NULL ) |
478 | continue; | 478 | continue; |
479 | if ( head->env_date != NULL ) { | 479 | if ( head->env_date != NULL ) { |
480 | m->setDate(head->env_date); | 480 | m->setDate(head->env_date); |
481 | //struct mailimf_date_time result; | 481 | //struct mailimf_date_time result; |
482 | struct mailimf_date_time* date;// = &result; | 482 | struct mailimf_date_time* date;// = &result; |
483 | struct mailimf_date_time **re = &date; | 483 | struct mailimf_date_time **re = &date; |
484 | size_t length = m->getDate().length(); | 484 | size_t length = m->getDate().length(); |
485 | size_t index = 0; | 485 | size_t index = 0; |
486 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { | 486 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { |
487 | QDateTime dt = Genericwrapper::parseDateTime( date ); | 487 | QDateTime dt = Genericwrapper::parseDateTime( date ); |
488 | QString ret; | 488 | QString ret; |
489 | if ( dt.date() == QDate::currentDate () ) | 489 | if ( dt.date() == QDate::currentDate () ) |
490 | ret = KGlobal::locale()->formatTime( dt.time(),true); | 490 | ret = KGlobal::locale()->formatTime( dt.time(),true); |
491 | else { | 491 | else { |
492 | ret = KGlobal::locale()->formatDateTime( dt,true,true); | 492 | ret = KGlobal::locale()->formatDateTime( dt,true,true); |
493 | } | 493 | } |
494 | m->setDate( ret ); | 494 | m->setDate( ret ); |
495 | char tmp[20]; | 495 | char tmp[20]; |
496 | snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", | 496 | snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", |
497 | dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); | 497 | dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); |
498 | //qDebug("%d iso %s %s ", date->dt_zone, tmp, head->env_date); | 498 | //qDebug("%d iso %s %s ", date->dt_zone, tmp, head->env_date); |
499 | m->setIsoDate( QString( tmp ) ); | 499 | m->setIsoDate( QString( tmp ) ); |
500 | mailimf_date_time_free ( date ); | 500 | mailimf_date_time_free ( date ); |
501 | } else { | 501 | } else { |
502 | m->setIsoDate(head->env_date); | 502 | m->setIsoDate(head->env_date); |
503 | } | 503 | } |
504 | } | 504 | } |
505 | if ( head->env_subject != NULL ) | 505 | if ( head->env_subject != NULL ) |
506 | m->setSubject(convert_String((const char*)head->env_subject)); | 506 | m->setSubject(convert_String((const char*)head->env_subject)); |
507 | //m->setSubject(head->env_subject); | 507 | //m->setSubject(head->env_subject); |
508 | if (head->env_from!=NULL) { | 508 | if (head->env_from!=NULL) { |
509 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 509 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
510 | if (addresslist.count()) { | 510 | if (addresslist.count()) { |
511 | m->setFrom(addresslist.first()); | 511 | m->setFrom(addresslist.first()); |
512 | } | 512 | } |
513 | } | 513 | } |
514 | if (head->env_to!=NULL) { | 514 | if (head->env_to!=NULL) { |
515 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 515 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
516 | m->setTo(addresslist); | 516 | m->setTo(addresslist); |
517 | } | 517 | } |
518 | if (head->env_cc!=NULL) { | 518 | if (head->env_cc!=NULL) { |
519 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 519 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
520 | m->setCC(addresslist); | 520 | m->setCC(addresslist); |
521 | } | 521 | } |
522 | if (head->env_bcc!=NULL) { | 522 | if (head->env_bcc!=NULL) { |
523 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 523 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
524 | m->setBcc(addresslist); | 524 | m->setBcc(addresslist); |
525 | } | 525 | } |
526 | /* reply to address, eg. email. */ | 526 | /* reply to address, eg. email. */ |
527 | if (head->env_reply_to!=NULL) { | 527 | if (head->env_reply_to!=NULL) { |
528 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 528 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
529 | if (addresslist.count()) { | 529 | if (addresslist.count()) { |
530 | m->setReplyto(addresslist.first()); | 530 | m->setReplyto(addresslist.first()); |
531 | } | 531 | } |
532 | } | 532 | } |
533 | if (head->env_in_reply_to!=NULL) { | 533 | if (head->env_in_reply_to!=NULL) { |
534 | QString h(head->env_in_reply_to); | 534 | QString h(head->env_in_reply_to); |
535 | while (h.length()>0 && h[0]=='<') { | 535 | while (h.length()>0 && h[0]=='<') { |
536 | h.remove(0,1); | 536 | h.remove(0,1); |
537 | } | 537 | } |
538 | while (h.length()>0 && h[h.length()-1]=='>') { | 538 | while (h.length()>0 && h[h.length()-1]=='>') { |
539 | h.remove(h.length()-1,1); | 539 | h.remove(h.length()-1,1); |
540 | } | 540 | } |
541 | if (h.length()>0) { | 541 | if (h.length()>0) { |
542 | m->setInreply(QStringList(h)); | 542 | m->setInreply(QStringList(h)); |
543 | } | 543 | } |
544 | } | 544 | } |
545 | if (head->env_message_id != NULL) { | 545 | if (head->env_message_id != NULL) { |
546 | m->setMsgid(QString(head->env_message_id)); | 546 | m->setMsgid(QString(head->env_message_id)); |
547 | } | 547 | } |
548 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 548 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
549 | #if 0 | 549 | #if 0 |
550 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 550 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
551 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 551 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
552 | qDebug("time %s ",da.toString().latin1() ); | 552 | qDebug("time %s ",da.toString().latin1() ); |
553 | #endif | 553 | #endif |
554 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 554 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
555 | size = item->att_data.att_static->att_data.att_rfc822_size; | 555 | size = item->att_data.att_static->att_data.att_rfc822_size; |
556 | } | 556 | } |
557 | } | 557 | } |
558 | /* msg is already deleted */ | 558 | /* msg is already deleted */ |
559 | if (mFlags.testBit(FLAG_DELETED) && m) { | 559 | if (mFlags.testBit(FLAG_DELETED) && m) { |
560 | delete m; | 560 | delete m; |
561 | m = 0; | 561 | m = 0; |
562 | } | 562 | } |
563 | if (m) { | 563 | if (m) { |
564 | m->setFlags(mFlags); | 564 | m->setFlags(mFlags); |
565 | m->setMsgsize(size); | 565 | m->setMsgsize(size); |
566 | } | 566 | } |
567 | return m; | 567 | return m; |
568 | } | 568 | } |
569 | 569 | ||
570 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) | 570 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) |
571 | { | 571 | { |
572 | RecBodyP body = new RecBody(); | 572 | RecBodyP body = new RecBody(); |
573 | const char *mb; | 573 | const char *mb; |
574 | int err = MAILIMAP_NO_ERROR; | 574 | int err = MAILIMAP_NO_ERROR; |
575 | clist *result = 0; | 575 | clist *result = 0; |
576 | clistcell *current; | 576 | clistcell *current; |
577 | mailimap_fetch_att *fetchAtt = 0; | 577 | mailimap_fetch_att *fetchAtt = 0; |
578 | mailimap_fetch_type *fetchType = 0; | 578 | mailimap_fetch_type *fetchType = 0; |
579 | mailimap_set *set = 0; | 579 | mailimap_set *set = 0; |
580 | mailimap_body*body_desc = 0; | 580 | mailimap_body*body_desc = 0; |
581 | 581 | ||
582 | mb = mail->getMbox().latin1(); | 582 | mb = mail->getMbox().latin1(); |
583 | 583 | ||
584 | login(); | 584 | login(); |
585 | if (!m_imap) { | 585 | if (!m_imap) { |
586 | return body; | 586 | return body; |
587 | } | 587 | } |
588 | err = selectMbox(mail->getMbox()); | 588 | err = selectMbox(mail->getMbox()); |
589 | if ( err != MAILIMAP_NO_ERROR ) { | 589 | if ( err != MAILIMAP_NO_ERROR ) { |
590 | return body; | 590 | return body; |
591 | } | 591 | } |
592 | 592 | ||
593 | /* the range has to start at 1!!! not with 0!!!! */ | 593 | /* the range has to start at 1!!! not with 0!!!! */ |
594 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); | 594 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); |
595 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 595 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
596 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 596 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
597 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 597 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
598 | mailimap_set_free( set ); | 598 | mailimap_set_free( set ); |
599 | mailimap_fetch_type_free( fetchType ); | 599 | mailimap_fetch_type_free( fetchType ); |
600 | 600 | ||
601 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 601 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
602 | mailimap_msg_att * msg_att; | 602 | mailimap_msg_att * msg_att; |
603 | msg_att = (mailimap_msg_att*)current->data; | 603 | msg_att = (mailimap_msg_att*)current->data; |
604 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 604 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
605 | QValueList<int> path; | 605 | QValueList<int> path; |
606 | body_desc = item->att_data.att_static->att_data.att_body; | 606 | body_desc = item->att_data.att_static->att_data.att_body; |
607 | traverseBody(mail,body_desc,body,0,path); | 607 | traverseBody(mail,body_desc,body,0,path); |
608 | } else { | 608 | } else { |
609 | //odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; | 609 | //odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; |
610 | } | 610 | } |
611 | if (result) mailimap_fetch_list_free(result); | 611 | if (result) mailimap_fetch_list_free(result); |
612 | return body; | 612 | return body; |
613 | } | 613 | } |
614 | 614 | ||
615 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 615 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
616 | { | 616 | { |
617 | QStringList l; | 617 | QStringList l; |
618 | QString from; | 618 | QString from; |
619 | bool named_from; | 619 | bool named_from; |
620 | clistcell *current = NULL; | 620 | clistcell *current = NULL; |
621 | mailimap_address * current_address=NULL; | 621 | mailimap_address * current_address=NULL; |
622 | if (!list) { | 622 | if (!list) { |
623 | return l; | 623 | return l; |
624 | } | 624 | } |
625 | unsigned int count = 0; | 625 | unsigned int count = 0; |
626 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { | 626 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { |
627 | from = ""; | 627 | from = ""; |
628 | named_from = false; | 628 | named_from = false; |
629 | current_address=(mailimap_address*)current->data; | 629 | current_address=(mailimap_address*)current->data; |
630 | if (current_address->ad_personal_name){ | 630 | if (current_address->ad_personal_name){ |
631 | from+=convert_String((const char*)current_address->ad_personal_name); | 631 | from+=convert_String((const char*)current_address->ad_personal_name); |
632 | from+=" "; | 632 | from+=" "; |
633 | named_from = true; | 633 | named_from = true; |
634 | } | 634 | } |
635 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 635 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
636 | from+="<"; | 636 | from+="<"; |
637 | } | 637 | } |
638 | if (current_address->ad_mailbox_name) { | 638 | if (current_address->ad_mailbox_name) { |
639 | from+=QString(current_address->ad_mailbox_name); | 639 | from+=QString(current_address->ad_mailbox_name); |
640 | from+="@"; | 640 | from+="@"; |
641 | } | 641 | } |
642 | if (current_address->ad_host_name) { | 642 | if (current_address->ad_host_name) { |
643 | from+=QString(current_address->ad_host_name); | 643 | from+=QString(current_address->ad_host_name); |
644 | } | 644 | } |
645 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 645 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
646 | from+=">"; | 646 | from+=">"; |
647 | } | 647 | } |
648 | l.append(QString(from)); | 648 | l.append(QString(from)); |
649 | if (++count > 99) { | 649 | if (++count > 99) { |
650 | break; | 650 | break; |
651 | } | 651 | } |
652 | } | 652 | } |
653 | return l; | 653 | return l; |
654 | } | 654 | } |
655 | 655 | ||
656 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) | 656 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) |
657 | { | 657 | { |
658 | encodedString*res=new encodedString; | 658 | encodedString*res=new encodedString; |
659 | int err; | 659 | int err; |
660 | mailimap_fetch_type *fetchType; | 660 | mailimap_fetch_type *fetchType; |
661 | mailimap_set *set; | 661 | mailimap_set *set; |
662 | clistcell*current,*cur; | 662 | clistcell*current,*cur; |
663 | mailimap_section_part * section_part = 0; | 663 | mailimap_section_part * section_part = 0; |
664 | mailimap_section_spec * section_spec = 0; | 664 | mailimap_section_spec * section_spec = 0; |
665 | mailimap_section * section = 0; | 665 | mailimap_section * section = 0; |
666 | mailimap_fetch_att * fetch_att = 0; | 666 | mailimap_fetch_att * fetch_att = 0; |
667 | 667 | ||
668 | login(); | 668 | login(); |
669 | if (!m_imap) { | 669 | if (!m_imap) { |
670 | return res; | 670 | return res; |
671 | } | 671 | } |
672 | if (!internal_call) { | 672 | if (!internal_call) { |
673 | err = selectMbox(mail->getMbox()); | 673 | err = selectMbox(mail->getMbox()); |
674 | if ( err != MAILIMAP_NO_ERROR ) { | 674 | if ( err != MAILIMAP_NO_ERROR ) { |
675 | return res; | 675 | return res; |
676 | } | 676 | } |
677 | } | 677 | } |
678 | set = mailimap_set_new_single(mail->getNumber()); | 678 | set = mailimap_set_new_single(mail->getNumber()); |
679 | 679 | ||
680 | clist*id_list = 0; | 680 | clist*id_list = 0; |
681 | 681 | ||
682 | /* if path == empty then its a request for the whole rfc822 mail and generates | 682 | /* if path == empty then its a request for the whole rfc822 mail and generates |
683 | a "fetch <id> (body[])" statement on imap server */ | 683 | a "fetch <id> (body[])" statement on imap server */ |
684 | if (path.count()>0 ) { | 684 | if (path.count()>0 ) { |
685 | id_list = clist_new(); | 685 | id_list = clist_new(); |
686 | for (unsigned j=0; j < path.count();++j) { | 686 | for (unsigned j=0; j < path.count();++j) { |
687 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); | 687 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); |
688 | *p_id = path[j]; | 688 | *p_id = path[j]; |
689 | clist_append(id_list,p_id); | 689 | clist_append(id_list,p_id); |
690 | } | 690 | } |
691 | section_part = mailimap_section_part_new(id_list); | 691 | section_part = mailimap_section_part_new(id_list); |
692 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); | 692 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); |
693 | } | 693 | } |
694 | 694 | ||
695 | section = mailimap_section_new(section_spec); | 695 | section = mailimap_section_new(section_spec); |
696 | fetch_att = mailimap_fetch_att_new_body_section(section); | 696 | fetch_att = mailimap_fetch_att_new_body_section(section); |
697 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); | 697 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); |
698 | 698 | ||
699 | clist*result = 0; | 699 | clist*result = 0; |
700 | 700 | ||
701 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 701 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
702 | mailimap_set_free( set ); | 702 | mailimap_set_free( set ); |
703 | mailimap_fetch_type_free( fetchType ); | 703 | mailimap_fetch_type_free( fetchType ); |
704 | 704 | ||
705 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 705 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
706 | mailimap_msg_att * msg_att; | 706 | mailimap_msg_att * msg_att; |
707 | msg_att = (mailimap_msg_att*)current->data; | 707 | msg_att = (mailimap_msg_att*)current->data; |
708 | mailimap_msg_att_item*msg_att_item; | 708 | mailimap_msg_att_item*msg_att_item; |
709 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | 709 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { |
710 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | 710 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); |
711 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | 711 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { |
712 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 712 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
713 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 713 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
714 | /* detach - we take over the content */ | 714 | /* detach - we take over the content */ |
715 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 715 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
716 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); | 716 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); |
717 | } | 717 | } |
718 | } | 718 | } |
719 | } | 719 | } |
720 | } else { | 720 | } else { |
721 | ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; | 721 | ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; |
722 | } | 722 | } |
723 | if (result) mailimap_fetch_list_free(result); | 723 | if (result) mailimap_fetch_list_free(result); |
724 | return res; | 724 | return res; |
725 | } | 725 | } |
726 | 726 | ||
727 | /* current_recursion is for recursive calls. | 727 | /* current_recursion is for recursive calls. |
728 | current_count means the position inside the internal loop! */ | 728 | current_count means the position inside the internal loop! */ |
729 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, | 729 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, |
730 | int current_recursion,QValueList<int>recList,int current_count) | 730 | int current_recursion,QValueList<int>recList,int current_count) |
731 | { | 731 | { |
732 | if (!body || current_recursion>=10) { | 732 | if (!body || current_recursion>=10) { |
733 | return; | 733 | return; |
734 | } | 734 | } |
735 | switch (body->bd_type) { | 735 | switch (body->bd_type) { |
736 | case MAILIMAP_BODY_1PART: | 736 | case MAILIMAP_BODY_1PART: |
737 | { | 737 | { |
738 | QValueList<int>countlist = recList; | 738 | QValueList<int>countlist = recList; |
739 | countlist.append(current_count); | 739 | countlist.append(current_count); |
740 | RecPartP currentPart = new RecPart(); | 740 | RecPartP currentPart = new RecPart(); |
741 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; | 741 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; |
742 | QString id(""); | 742 | QString id(""); |
743 | currentPart->setPositionlist(countlist); | 743 | currentPart->setPositionlist(countlist); |
744 | for (unsigned int j = 0; j < countlist.count();++j) { | 744 | for (unsigned int j = 0; j < countlist.count();++j) { |
745 | id+=(j>0?" ":""); | 745 | id+=(j>0?" ":""); |
746 | id+=QString("%1").arg(countlist[j]); | 746 | id+=QString("%1").arg(countlist[j]); |
747 | } | 747 | } |
748 | //odebug << "ID = " << id.latin1() << "" << oendl; | 748 | //odebug << "ID = " << id.latin1() << "" << oendl; |
749 | currentPart->setIdentifier(id); | 749 | currentPart->setIdentifier(id); |
750 | fillSinglePart(currentPart,part1); | 750 | fillSinglePart(currentPart,part1); |
751 | /* important: Check for is NULL 'cause a body can be empty! | 751 | /* important: Check for is NULL 'cause a body can be empty! |
752 | And we put it only into the mail if it is the FIRST part */ | 752 | And we put it only into the mail if it is the FIRST part */ |
753 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { | 753 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { |
754 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); | 754 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); |
755 | 755 | ||
756 | size_t index = 0; | 756 | size_t index = 0; |
757 | char*res = 0; | 757 | char*res = 0; |
758 | int err = MAILIMF_NO_ERROR; | 758 | int err = MAILIMF_NO_ERROR; |
759 | 759 | ||
760 | QString charset = currentPart->searchParamter( "charset"); | 760 | QString charset = currentPart->searchParamter( "charset"); |
761 | qDebug("CHARSET %s ",charset.latin1() ); | 761 | qDebug("CHARSET %s ",charset.latin1() ); |
762 | //if ( false ) { | 762 | //if ( false ) { |
763 | if ( !charset.isEmpty() ) { | 763 | if ( !charset.isEmpty() ) { |
764 | target_body->setCharset( charset ); | ||
764 | //err = mailmime_encoded_phrase_parse("iso-8859-1", | 765 | //err = mailmime_encoded_phrase_parse("iso-8859-1", |
765 | // text, strlen(text),&index, "iso-8859-1",&res); | 766 | // text, strlen(text),&index, "iso-8859-1",&res); |
766 | err = mailmime_encoded_phrase_parse(charset.latin1(), | 767 | err = mailmime_encoded_phrase_parse(charset.latin1(), |
767 | body_text.latin1(), body_text.length(),&index, "utf-8",&res); | 768 | body_text.latin1(), body_text.length(),&index, "utf-8",&res); |
768 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { | 769 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { |
769 | //qDebug("res %d %s ", index, res); | 770 | //qDebug("res %d %s ", index, res); |
770 | body_text = QString::fromUtf8(res); | 771 | body_text = QString::fromUtf8(res); |
771 | } | 772 | } |
772 | if (res) free(res); | 773 | if (res) free(res); |
773 | } | 774 | } |
774 | //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() ); | 775 | //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() ); |
775 | target_body->setDescription(currentPart); | 776 | target_body->setDescription(currentPart); |
776 | target_body->setBodytext(body_text); | 777 | target_body->setBodytext(body_text); |
777 | if (countlist.count()>1) { | 778 | if (countlist.count()>1) { |
778 | target_body->addPart(currentPart); | 779 | target_body->addPart(currentPart); |
779 | } | 780 | } |
780 | } else { | 781 | } else { |
781 | target_body->addPart(currentPart); | 782 | target_body->addPart(currentPart); |
782 | } | 783 | } |
783 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { | 784 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { |
784 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); | 785 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); |
785 | } | 786 | } |
786 | } | 787 | } |
787 | break; | 788 | break; |
788 | case MAILIMAP_BODY_MPART: | 789 | case MAILIMAP_BODY_MPART: |
789 | { | 790 | { |
790 | QValueList<int>countlist = recList; | 791 | QValueList<int>countlist = recList; |
791 | clistcell*current=0; | 792 | clistcell*current=0; |
792 | mailimap_body*current_body=0; | 793 | mailimap_body*current_body=0; |
793 | unsigned int ccount = 1; | 794 | unsigned int ccount = 1; |
794 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; | 795 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; |
795 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { | 796 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { |
796 | current_body = (mailimap_body*)current->data; | 797 | current_body = (mailimap_body*)current->data; |
797 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 798 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
798 | RecPartP targetPart = new RecPart(); | 799 | RecPartP targetPart = new RecPart(); |
799 | targetPart->setType("multipart"); | 800 | targetPart->setType("multipart"); |
800 | fillMultiPart(targetPart,mailDescription); | 801 | fillMultiPart(targetPart,mailDescription); |
801 | countlist.append(current_count); | 802 | countlist.append(current_count); |
802 | targetPart->setPositionlist(countlist); | 803 | targetPart->setPositionlist(countlist); |
803 | target_body->addPart(targetPart); | 804 | target_body->addPart(targetPart); |
804 | QString id(""); | 805 | QString id(""); |
805 | for (unsigned int j = 0; j < countlist.count();++j) { | 806 | for (unsigned int j = 0; j < countlist.count();++j) { |
806 | id+=(j>0?" ":""); | 807 | id+=(j>0?" ":""); |
807 | id+=QString("%1").arg(countlist[j]); | 808 | id+=QString("%1").arg(countlist[j]); |
808 | } | 809 | } |
809 | // odebug << "ID(mpart) = " << id.latin1() << "" << oendl; | 810 | // odebug << "ID(mpart) = " << id.latin1() << "" << oendl; |
810 | } | 811 | } |
811 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); | 812 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); |
812 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 813 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
813 | countlist = recList; | 814 | countlist = recList; |
814 | } | 815 | } |
815 | ++ccount; | 816 | ++ccount; |
816 | } | 817 | } |
817 | } | 818 | } |
818 | break; | 819 | break; |
819 | default: | 820 | default: |
820 | break; | 821 | break; |
821 | } | 822 | } |
822 | } | 823 | } |
823 | 824 | ||
824 | void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) | 825 | void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) |
825 | { | 826 | { |
826 | if (!Description) { | 827 | if (!Description) { |
827 | return; | 828 | return; |
828 | } | 829 | } |
829 | switch (Description->bd_type) { | 830 | switch (Description->bd_type) { |
830 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 831 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
831 | target_part->setType("text"); | 832 | target_part->setType("text"); |
832 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); | 833 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); |
833 | break; | 834 | break; |
834 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | 835 | case MAILIMAP_BODY_TYPE_1PART_BASIC: |
835 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); | 836 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); |
836 | break; | 837 | break; |
837 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 838 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
838 | target_part->setType("message"); | 839 | target_part->setType("message"); |
839 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); | 840 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); |
840 | break; | 841 | break; |
841 | default: | 842 | default: |
842 | break; | 843 | break; |
843 | } | 844 | } |
844 | } | 845 | } |
845 | 846 | ||
846 | void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) | 847 | void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) |
847 | { | 848 | { |
848 | if (!which) { | 849 | if (!which) { |
849 | return; | 850 | return; |
850 | } | 851 | } |
851 | QString sub; | 852 | QString sub; |
852 | sub = which->bd_media_text; | 853 | sub = which->bd_media_text; |
853 | //odebug << "Type= text/" << which->bd_media_text << "" << oendl; | 854 | //odebug << "Type= text/" << which->bd_media_text << "" << oendl; |
854 | target_part->setSubtype(sub.lower()); | 855 | target_part->setSubtype(sub.lower()); |
855 | target_part->setLines(which->bd_lines); | 856 | target_part->setLines(which->bd_lines); |
856 | fillBodyFields(target_part,which->bd_fields); | 857 | fillBodyFields(target_part,which->bd_fields); |
857 | } | 858 | } |
858 | 859 | ||
859 | void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) | 860 | void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) |
860 | { | 861 | { |
861 | if (!which) { | 862 | if (!which) { |
862 | return; | 863 | return; |
863 | } | 864 | } |
864 | target_part->setSubtype("rfc822"); | 865 | target_part->setSubtype("rfc822"); |
865 | //odebug << "Message part" << oendl; | 866 | //odebug << "Message part" << oendl; |
866 | /* we set this type to text/plain */ | 867 | /* we set this type to text/plain */ |
867 | target_part->setLines(which->bd_lines); | 868 | target_part->setLines(which->bd_lines); |
868 | fillBodyFields(target_part,which->bd_fields); | 869 | fillBodyFields(target_part,which->bd_fields); |
869 | } | 870 | } |
870 | 871 | ||
871 | void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) | 872 | void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) |
872 | { | 873 | { |
873 | if (!which) return; | 874 | if (!which) return; |
874 | QString sub = which->bd_media_subtype; | 875 | QString sub = which->bd_media_subtype; |
875 | target_part->setSubtype(sub.lower()); | 876 | target_part->setSubtype(sub.lower()); |
876 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { | 877 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { |
877 | clistcell*cur = 0; | 878 | clistcell*cur = 0; |
878 | mailimap_single_body_fld_param*param=0; | 879 | mailimap_single_body_fld_param*param=0; |
879 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 880 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
880 | param = (mailimap_single_body_fld_param*)cur->data; | 881 | param = (mailimap_single_body_fld_param*)cur->data; |
881 | if (param) { | 882 | if (param) { |
882 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 883 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
883 | } | 884 | } |
884 | } | 885 | } |
885 | } | 886 | } |
886 | } | 887 | } |
887 | 888 | ||
888 | void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) | 889 | void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) |
889 | { | 890 | { |
890 | if (!which) { | 891 | if (!which) { |
891 | return; | 892 | return; |
892 | } | 893 | } |
893 | QString type,sub; | 894 | QString type,sub; |
894 | switch (which->bd_media_basic->med_type) { | 895 | switch (which->bd_media_basic->med_type) { |
895 | case MAILIMAP_MEDIA_BASIC_APPLICATION: | 896 | case MAILIMAP_MEDIA_BASIC_APPLICATION: |
896 | type = "application"; | 897 | type = "application"; |
897 | break; | 898 | break; |
898 | case MAILIMAP_MEDIA_BASIC_AUDIO: | 899 | case MAILIMAP_MEDIA_BASIC_AUDIO: |
899 | type = "audio"; | 900 | type = "audio"; |
900 | break; | 901 | break; |
901 | case MAILIMAP_MEDIA_BASIC_IMAGE: | 902 | case MAILIMAP_MEDIA_BASIC_IMAGE: |
902 | type = "image"; | 903 | type = "image"; |
903 | break; | 904 | break; |
904 | case MAILIMAP_MEDIA_BASIC_MESSAGE: | 905 | case MAILIMAP_MEDIA_BASIC_MESSAGE: |
905 | type = "message"; | 906 | type = "message"; |
906 | break; | 907 | break; |
907 | case MAILIMAP_MEDIA_BASIC_VIDEO: | 908 | case MAILIMAP_MEDIA_BASIC_VIDEO: |
908 | type = "video"; | 909 | type = "video"; |
909 | break; | 910 | break; |
910 | case MAILIMAP_MEDIA_BASIC_OTHER: | 911 | case MAILIMAP_MEDIA_BASIC_OTHER: |
911 | default: | 912 | default: |
912 | if (which->bd_media_basic->med_basic_type) { | 913 | if (which->bd_media_basic->med_basic_type) { |
913 | type = which->bd_media_basic->med_basic_type; | 914 | type = which->bd_media_basic->med_basic_type; |
914 | } else { | 915 | } else { |
915 | type = ""; | 916 | type = ""; |
916 | } | 917 | } |
917 | break; | 918 | break; |
918 | } | 919 | } |
919 | if (which->bd_media_basic->med_subtype) { | 920 | if (which->bd_media_basic->med_subtype) { |
920 | sub = which->bd_media_basic->med_subtype; | 921 | sub = which->bd_media_basic->med_subtype; |
921 | } else { | 922 | } else { |
922 | sub = ""; | 923 | sub = ""; |
923 | } | 924 | } |
924 | // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; | 925 | // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; |
925 | target_part->setType(type.lower()); | 926 | target_part->setType(type.lower()); |
926 | target_part->setSubtype(sub.lower()); | 927 | target_part->setSubtype(sub.lower()); |
927 | fillBodyFields(target_part,which->bd_fields); | 928 | fillBodyFields(target_part,which->bd_fields); |
928 | } | 929 | } |
929 | 930 | ||
930 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) | 931 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) |
931 | { | 932 | { |
932 | if (!which) return; | 933 | if (!which) return; |
933 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { | 934 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { |
934 | clistcell*cur; | 935 | clistcell*cur; |
935 | mailimap_single_body_fld_param*param=0; | 936 | mailimap_single_body_fld_param*param=0; |
936 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 937 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
937 | param = (mailimap_single_body_fld_param*)cur->data; | 938 | param = (mailimap_single_body_fld_param*)cur->data; |
938 | if (param) { | 939 | if (param) { |
939 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 940 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
940 | } | 941 | } |
941 | } | 942 | } |
942 | } | 943 | } |
943 | mailimap_body_fld_enc*enc = which->bd_encoding; | 944 | mailimap_body_fld_enc*enc = which->bd_encoding; |
944 | QString encoding(""); | 945 | QString encoding(""); |
945 | switch (enc->enc_type) { | 946 | switch (enc->enc_type) { |
946 | case MAILIMAP_BODY_FLD_ENC_7BIT: | 947 | case MAILIMAP_BODY_FLD_ENC_7BIT: |
947 | encoding = "7bit"; | 948 | encoding = "7bit"; |
948 | break; | 949 | break; |
949 | case MAILIMAP_BODY_FLD_ENC_8BIT: | 950 | case MAILIMAP_BODY_FLD_ENC_8BIT: |
950 | encoding = "8bit"; | 951 | encoding = "8bit"; |
951 | break; | 952 | break; |
952 | case MAILIMAP_BODY_FLD_ENC_BINARY: | 953 | case MAILIMAP_BODY_FLD_ENC_BINARY: |
953 | encoding="binary"; | 954 | encoding="binary"; |
954 | break; | 955 | break; |
955 | case MAILIMAP_BODY_FLD_ENC_BASE64: | 956 | case MAILIMAP_BODY_FLD_ENC_BASE64: |
@@ -993,366 +994,366 @@ void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) | |||
993 | mMax = count; | 994 | mMax = count; |
994 | progress( i18n("Delete")); | 995 | progress( i18n("Delete")); |
995 | 996 | ||
996 | QProgressBar wid ( count ); | 997 | QProgressBar wid ( count ); |
997 | wid.setCaption( i18n("Deleting ...")); | 998 | wid.setCaption( i18n("Deleting ...")); |
998 | wid.show(); | 999 | wid.show(); |
999 | while (iii < count ) { | 1000 | while (iii < count ) { |
1000 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); | 1001 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); |
1001 | wid.setProgress( iii ); | 1002 | wid.setProgress( iii ); |
1002 | wid.raise(); | 1003 | wid.raise(); |
1003 | qApp->processEvents(); | 1004 | qApp->processEvents(); |
1004 | RecMailP mail = (*target.at( iii )); | 1005 | RecMailP mail = (*target.at( iii )); |
1005 | //#if 0 | 1006 | //#if 0 |
1006 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); | 1007 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); |
1007 | err = selectMbox(mail->getMbox()); | 1008 | err = selectMbox(mail->getMbox()); |
1008 | if ( err != MAILIMAP_NO_ERROR ) { | 1009 | if ( err != MAILIMAP_NO_ERROR ) { |
1009 | return; | 1010 | return; |
1010 | } | 1011 | } |
1011 | flist = mailimap_flag_list_new_empty(); | 1012 | flist = mailimap_flag_list_new_empty(); |
1012 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 1013 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
1013 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 1014 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
1014 | set = mailimap_set_new_single(mail->getNumber()); | 1015 | set = mailimap_set_new_single(mail->getNumber()); |
1015 | err = mailimap_store(m_imap,set,store_flags); | 1016 | err = mailimap_store(m_imap,set,store_flags); |
1016 | mailimap_set_free( set ); | 1017 | mailimap_set_free( set ); |
1017 | mailimap_store_att_flags_free(store_flags); | 1018 | mailimap_store_att_flags_free(store_flags); |
1018 | 1019 | ||
1019 | if (err != MAILIMAP_NO_ERROR) { | 1020 | if (err != MAILIMAP_NO_ERROR) { |
1020 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 1021 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
1021 | return; | 1022 | return; |
1022 | } | 1023 | } |
1023 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1024 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1024 | /* should we realy do that at this moment? */ | 1025 | /* should we realy do that at this moment? */ |
1025 | 1026 | ||
1026 | // err = mailimap_expunge(m_imap); | 1027 | // err = mailimap_expunge(m_imap); |
1027 | //if (err != MAILIMAP_NO_ERROR) { | 1028 | //if (err != MAILIMAP_NO_ERROR) { |
1028 | // Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); | 1029 | // Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); |
1029 | // } | 1030 | // } |
1030 | //#endif | 1031 | //#endif |
1031 | //deleteMail( mail); | 1032 | //deleteMail( mail); |
1032 | ++iii; | 1033 | ++iii; |
1033 | } | 1034 | } |
1034 | //qDebug("Deleting imap mails... "); | 1035 | //qDebug("Deleting imap mails... "); |
1035 | err = mailimap_expunge(m_imap); | 1036 | err = mailimap_expunge(m_imap); |
1036 | if (err != MAILIMAP_NO_ERROR) { | 1037 | if (err != MAILIMAP_NO_ERROR) { |
1037 | Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); | 1038 | Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); |
1038 | } | 1039 | } |
1039 | } | 1040 | } |
1040 | void IMAPwrapper::deleteMail(const RecMailP&mail) | 1041 | void IMAPwrapper::deleteMail(const RecMailP&mail) |
1041 | { | 1042 | { |
1042 | mailimap_flag_list*flist; | 1043 | mailimap_flag_list*flist; |
1043 | mailimap_set *set; | 1044 | mailimap_set *set; |
1044 | mailimap_store_att_flags * store_flags; | 1045 | mailimap_store_att_flags * store_flags; |
1045 | int err; | 1046 | int err; |
1046 | login(); | 1047 | login(); |
1047 | if (!m_imap) { | 1048 | if (!m_imap) { |
1048 | return; | 1049 | return; |
1049 | } | 1050 | } |
1050 | err = selectMbox(mail->getMbox()); | 1051 | err = selectMbox(mail->getMbox()); |
1051 | if ( err != MAILIMAP_NO_ERROR ) { | 1052 | if ( err != MAILIMAP_NO_ERROR ) { |
1052 | return; | 1053 | return; |
1053 | } | 1054 | } |
1054 | flist = mailimap_flag_list_new_empty(); | 1055 | flist = mailimap_flag_list_new_empty(); |
1055 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 1056 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
1056 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 1057 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
1057 | set = mailimap_set_new_single(mail->getNumber()); | 1058 | set = mailimap_set_new_single(mail->getNumber()); |
1058 | err = mailimap_store(m_imap,set,store_flags); | 1059 | err = mailimap_store(m_imap,set,store_flags); |
1059 | mailimap_set_free( set ); | 1060 | mailimap_set_free( set ); |
1060 | mailimap_store_att_flags_free(store_flags); | 1061 | mailimap_store_att_flags_free(store_flags); |
1061 | 1062 | ||
1062 | if (err != MAILIMAP_NO_ERROR) { | 1063 | if (err != MAILIMAP_NO_ERROR) { |
1063 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 1064 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
1064 | return; | 1065 | return; |
1065 | } | 1066 | } |
1066 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1067 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1067 | /* should we realy do that at this moment? */ | 1068 | /* should we realy do that at this moment? */ |
1068 | 1069 | ||
1069 | err = mailimap_expunge(m_imap); | 1070 | err = mailimap_expunge(m_imap); |
1070 | if (err != MAILIMAP_NO_ERROR) { | 1071 | if (err != MAILIMAP_NO_ERROR) { |
1071 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); | 1072 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); |
1072 | } | 1073 | } |
1073 | //qDebug("IMAPwrapper::deleteMail 2"); | 1074 | //qDebug("IMAPwrapper::deleteMail 2"); |
1074 | 1075 | ||
1075 | } | 1076 | } |
1076 | 1077 | ||
1077 | void IMAPwrapper::answeredMail(const RecMailP&mail) | 1078 | void IMAPwrapper::answeredMail(const RecMailP&mail) |
1078 | { | 1079 | { |
1079 | mailimap_flag_list*flist; | 1080 | mailimap_flag_list*flist; |
1080 | mailimap_set *set; | 1081 | mailimap_set *set; |
1081 | mailimap_store_att_flags * store_flags; | 1082 | mailimap_store_att_flags * store_flags; |
1082 | int err; | 1083 | int err; |
1083 | login(); | 1084 | login(); |
1084 | if (!m_imap) { | 1085 | if (!m_imap) { |
1085 | return; | 1086 | return; |
1086 | } | 1087 | } |
1087 | err = selectMbox(mail->getMbox()); | 1088 | err = selectMbox(mail->getMbox()); |
1088 | if ( err != MAILIMAP_NO_ERROR ) { | 1089 | if ( err != MAILIMAP_NO_ERROR ) { |
1089 | return; | 1090 | return; |
1090 | } | 1091 | } |
1091 | flist = mailimap_flag_list_new_empty(); | 1092 | flist = mailimap_flag_list_new_empty(); |
1092 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); | 1093 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); |
1093 | store_flags = mailimap_store_att_flags_new_add_flags(flist); | 1094 | store_flags = mailimap_store_att_flags_new_add_flags(flist); |
1094 | set = mailimap_set_new_single(mail->getNumber()); | 1095 | set = mailimap_set_new_single(mail->getNumber()); |
1095 | err = mailimap_store(m_imap,set,store_flags); | 1096 | err = mailimap_store(m_imap,set,store_flags); |
1096 | mailimap_set_free( set ); | 1097 | mailimap_set_free( set ); |
1097 | mailimap_store_att_flags_free(store_flags); | 1098 | mailimap_store_att_flags_free(store_flags); |
1098 | 1099 | ||
1099 | if (err != MAILIMAP_NO_ERROR) { | 1100 | if (err != MAILIMAP_NO_ERROR) { |
1100 | // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; | 1101 | // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; |
1101 | return; | 1102 | return; |
1102 | } | 1103 | } |
1103 | } | 1104 | } |
1104 | 1105 | ||
1105 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | 1106 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) |
1106 | { | 1107 | { |
1107 | QString body(""); | 1108 | QString body(""); |
1108 | encodedString*res = fetchRawPart(mail,path,internal_call); | 1109 | encodedString*res = fetchRawPart(mail,path,internal_call); |
1109 | encodedString*r = decode_String(res,enc); | 1110 | encodedString*r = decode_String(res,enc); |
1110 | delete res; | 1111 | delete res; |
1111 | if (r) { | 1112 | if (r) { |
1112 | if (r->Length()>0) { | 1113 | if (r->Length()>0) { |
1113 | body = r->Content(); | 1114 | body = r->Content(); |
1114 | } | 1115 | } |
1115 | delete r; | 1116 | delete r; |
1116 | } | 1117 | } |
1117 | return body; | 1118 | return body; |
1118 | } | 1119 | } |
1119 | 1120 | ||
1120 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) | 1121 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) |
1121 | { | 1122 | { |
1122 | return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); | 1123 | return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); |
1123 | } | 1124 | } |
1124 | 1125 | ||
1125 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) | 1126 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) |
1126 | { | 1127 | { |
1127 | encodedString*res = fetchRawPart(mail,part->Positionlist(),false); | 1128 | encodedString*res = fetchRawPart(mail,part->Positionlist(),false); |
1128 | encodedString*r = decode_String(res,part->Encoding()); | 1129 | encodedString*r = decode_String(res,part->Encoding()); |
1129 | delete res; | 1130 | delete res; |
1130 | return r; | 1131 | return r; |
1131 | } | 1132 | } |
1132 | 1133 | ||
1133 | encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part) | 1134 | encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part) |
1134 | { | 1135 | { |
1135 | return fetchRawPart(mail,part->Positionlist(),false); | 1136 | return fetchRawPart(mail,part->Positionlist(),false); |
1136 | } | 1137 | } |
1137 | 1138 | ||
1138 | int IMAPwrapper::deleteAllMail(const FolderP&folder) | 1139 | int IMAPwrapper::deleteAllMail(const FolderP&folder) |
1139 | { | 1140 | { |
1140 | login(); | 1141 | login(); |
1141 | if (!m_imap) { | 1142 | if (!m_imap) { |
1142 | return 0; | 1143 | return 0; |
1143 | } | 1144 | } |
1144 | mailimap_flag_list*flist; | 1145 | mailimap_flag_list*flist; |
1145 | mailimap_set *set; | 1146 | mailimap_set *set; |
1146 | mailimap_store_att_flags * store_flags; | 1147 | mailimap_store_att_flags * store_flags; |
1147 | int err = selectMbox(folder->getName()); | 1148 | int err = selectMbox(folder->getName()); |
1148 | if ( err != MAILIMAP_NO_ERROR ) { | 1149 | if ( err != MAILIMAP_NO_ERROR ) { |
1149 | return 0; | 1150 | return 0; |
1150 | } | 1151 | } |
1151 | 1152 | ||
1152 | int last = m_imap->imap_selection_info->sel_exists; | 1153 | int last = m_imap->imap_selection_info->sel_exists; |
1153 | if (last == 0) { | 1154 | if (last == 0) { |
1154 | Global::statusMessage(i18n("Mailbox has no mails!")); | 1155 | Global::statusMessage(i18n("Mailbox has no mails!")); |
1155 | return 0; | 1156 | return 0; |
1156 | } | 1157 | } |
1157 | flist = mailimap_flag_list_new_empty(); | 1158 | flist = mailimap_flag_list_new_empty(); |
1158 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 1159 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
1159 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 1160 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
1160 | set = mailimap_set_new_interval( 1, last ); | 1161 | set = mailimap_set_new_interval( 1, last ); |
1161 | err = mailimap_store(m_imap,set,store_flags); | 1162 | err = mailimap_store(m_imap,set,store_flags); |
1162 | mailimap_set_free( set ); | 1163 | mailimap_set_free( set ); |
1163 | mailimap_store_att_flags_free(store_flags); | 1164 | mailimap_store_att_flags_free(store_flags); |
1164 | if (err != MAILIMAP_NO_ERROR) { | 1165 | if (err != MAILIMAP_NO_ERROR) { |
1165 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); | 1166 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); |
1166 | return 0; | 1167 | return 0; |
1167 | } | 1168 | } |
1168 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1169 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1169 | /* should we realy do that at this moment? */ | 1170 | /* should we realy do that at this moment? */ |
1170 | err = mailimap_expunge(m_imap); | 1171 | err = mailimap_expunge(m_imap); |
1171 | if (err != MAILIMAP_NO_ERROR) { | 1172 | if (err != MAILIMAP_NO_ERROR) { |
1172 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); | 1173 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); |
1173 | return 0; | 1174 | return 0; |
1174 | } | 1175 | } |
1175 | // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; | 1176 | // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; |
1176 | return 1; | 1177 | return 1; |
1177 | } | 1178 | } |
1178 | 1179 | ||
1179 | int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) | 1180 | int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) |
1180 | { | 1181 | { |
1181 | if (folder.length()==0) return 0; | 1182 | if (folder.length()==0) return 0; |
1182 | login(); | 1183 | login(); |
1183 | if (!m_imap) {return 0;} | 1184 | if (!m_imap) {return 0;} |
1184 | QString pre = account->getPrefix(); | 1185 | QString pre = account->getPrefix(); |
1185 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { | 1186 | if (delemiter.length()>0 && pre.findRev(delemiter)!=((int)pre.length())-1) { |
1186 | pre+=delemiter; | 1187 | pre+=delemiter; |
1187 | } | 1188 | } |
1188 | if (parentfolder) { | 1189 | if (parentfolder) { |
1189 | pre += parentfolder->getDisplayName()+delemiter; | 1190 | pre += parentfolder->getDisplayName()+delemiter; |
1190 | } | 1191 | } |
1191 | pre+=folder; | 1192 | pre+=folder; |
1192 | if (getsubfolder) { | 1193 | if (getsubfolder) { |
1193 | if (delemiter.length()>0) { | 1194 | if (delemiter.length()>0) { |
1194 | pre+=delemiter; | 1195 | pre+=delemiter; |
1195 | } else { | 1196 | } else { |
1196 | Global::statusMessage(i18n("Cannot create folder %1 for holding subfolders").arg(pre)); | 1197 | Global::statusMessage(i18n("Cannot create folder %1 for holding subfolders").arg(pre)); |
1197 | return 0; | 1198 | return 0; |
1198 | } | 1199 | } |
1199 | } | 1200 | } |
1200 | // odebug << "Creating " << pre.latin1() << "" << oendl; | 1201 | // odebug << "Creating " << pre.latin1() << "" << oendl; |
1201 | int res = mailimap_create(m_imap,pre.latin1()); | 1202 | int res = mailimap_create(m_imap,pre.latin1()); |
1202 | if (res != MAILIMAP_NO_ERROR) { | 1203 | if (res != MAILIMAP_NO_ERROR) { |
1203 | Global::statusMessage(i18n("%1").arg(m_imap->imap_response)); | 1204 | Global::statusMessage(i18n("%1").arg(m_imap->imap_response)); |
1204 | return 0; | 1205 | return 0; |
1205 | } | 1206 | } |
1206 | return 1; | 1207 | return 1; |
1207 | } | 1208 | } |
1208 | 1209 | ||
1209 | int IMAPwrapper::deleteMbox(const FolderP&folder) | 1210 | int IMAPwrapper::deleteMbox(const FolderP&folder) |
1210 | { | 1211 | { |
1211 | if (!folder) return 0; | 1212 | if (!folder) return 0; |
1212 | login(); | 1213 | login(); |
1213 | if (!m_imap) {return 0;} | 1214 | if (!m_imap) {return 0;} |
1214 | int res = mailimap_delete(m_imap,folder->getName()); | 1215 | int res = mailimap_delete(m_imap,folder->getName()); |
1215 | if (res != MAILIMAP_NO_ERROR) { | 1216 | if (res != MAILIMAP_NO_ERROR) { |
1216 | Global::statusMessage(i18n("%1").arg(m_imap->imap_response)); | 1217 | Global::statusMessage(i18n("%1").arg(m_imap->imap_response)); |
1217 | return 0; | 1218 | return 0; |
1218 | } | 1219 | } |
1219 | return 1; | 1220 | return 1; |
1220 | } | 1221 | } |
1221 | 1222 | ||
1222 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 1223 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
1223 | { | 1224 | { |
1224 | mailimap_status_att_list * att_list =0; | 1225 | mailimap_status_att_list * att_list =0; |
1225 | mailimap_mailbox_data_status * status=0; | 1226 | mailimap_mailbox_data_status * status=0; |
1226 | clistiter * cur = 0; | 1227 | clistiter * cur = 0; |
1227 | int r = 0; | 1228 | int r = 0; |
1228 | target_stat.message_count = 0; | 1229 | target_stat.message_count = 0; |
1229 | target_stat.message_unseen = 0; | 1230 | target_stat.message_unseen = 0; |
1230 | target_stat.message_recent = 0; | 1231 | target_stat.message_recent = 0; |
1231 | login(); | 1232 | login(); |
1232 | if (!m_imap) { | 1233 | if (!m_imap) { |
1233 | return; | 1234 | return; |
1234 | } | 1235 | } |
1235 | att_list = mailimap_status_att_list_new_empty(); | 1236 | att_list = mailimap_status_att_list_new_empty(); |
1236 | if (!att_list) return; | 1237 | if (!att_list) return; |
1237 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); | 1238 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); |
1238 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); | 1239 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); |
1239 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); | 1240 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); |
1240 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); | 1241 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); |
1241 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { | 1242 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { |
1242 | for (cur = clist_begin(status->st_info_list); | 1243 | for (cur = clist_begin(status->st_info_list); |
1243 | cur != NULL ; cur = clist_next(cur)) { | 1244 | cur != NULL ; cur = clist_next(cur)) { |
1244 | mailimap_status_info * status_info; | 1245 | mailimap_status_info * status_info; |
1245 | status_info = (mailimap_status_info *)clist_content(cur); | 1246 | status_info = (mailimap_status_info *)clist_content(cur); |
1246 | switch (status_info->st_att) { | 1247 | switch (status_info->st_att) { |
1247 | case MAILIMAP_STATUS_ATT_MESSAGES: | 1248 | case MAILIMAP_STATUS_ATT_MESSAGES: |
1248 | target_stat.message_count = status_info->st_value; | 1249 | target_stat.message_count = status_info->st_value; |
1249 | break; | 1250 | break; |
1250 | case MAILIMAP_STATUS_ATT_RECENT: | 1251 | case MAILIMAP_STATUS_ATT_RECENT: |
1251 | target_stat.message_recent = status_info->st_value; | 1252 | target_stat.message_recent = status_info->st_value; |
1252 | break; | 1253 | break; |
1253 | case MAILIMAP_STATUS_ATT_UNSEEN: | 1254 | case MAILIMAP_STATUS_ATT_UNSEEN: |
1254 | target_stat.message_unseen = status_info->st_value; | 1255 | target_stat.message_unseen = status_info->st_value; |
1255 | break; | 1256 | break; |
1256 | } | 1257 | } |
1257 | } | 1258 | } |
1258 | } else { | 1259 | } else { |
1259 | // odebug << "Error retrieving status" << oendl; | 1260 | // odebug << "Error retrieving status" << oendl; |
1260 | } | 1261 | } |
1261 | if (status) mailimap_mailbox_data_status_free(status); | 1262 | if (status) mailimap_mailbox_data_status_free(status); |
1262 | if (att_list) mailimap_status_att_list_free(att_list); | 1263 | if (att_list) mailimap_status_att_list_free(att_list); |
1263 | } | 1264 | } |
1264 | 1265 | ||
1265 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 1266 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
1266 | { | 1267 | { |
1267 | login(); | 1268 | login(); |
1268 | if (!m_imap) return; | 1269 | if (!m_imap) return; |
1269 | if (!msg) return; | 1270 | if (!msg) return; |
1270 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); | 1271 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); |
1271 | if (r != MAILIMAP_NO_ERROR) { | 1272 | if (r != MAILIMAP_NO_ERROR) { |
1272 | Global::statusMessage("Error storing mail!"); | 1273 | Global::statusMessage("Error storing mail!"); |
1273 | } | 1274 | } |
1274 | } | 1275 | } |
1275 | 1276 | ||
1276 | MAILLIB::ATYPE IMAPwrapper::getType()const | 1277 | MAILLIB::ATYPE IMAPwrapper::getType()const |
1277 | { | 1278 | { |
1278 | return account->getType(); | 1279 | return account->getType(); |
1279 | } | 1280 | } |
1280 | 1281 | ||
1281 | const QString&IMAPwrapper::getName()const | 1282 | const QString&IMAPwrapper::getName()const |
1282 | { | 1283 | { |
1283 | // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; | 1284 | // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; |
1284 | return account->getAccountName(); | 1285 | return account->getAccountName(); |
1285 | } | 1286 | } |
1286 | 1287 | ||
1287 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) | 1288 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) |
1288 | { | 1289 | { |
1289 | // dummy | 1290 | // dummy |
1290 | QValueList<int> path; | 1291 | QValueList<int> path; |
1291 | return fetchRawPart(mail,path,false); | 1292 | return fetchRawPart(mail,path,false); |
1292 | } | 1293 | } |
1293 | 1294 | ||
1294 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, | 1295 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, |
1295 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) | 1296 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) |
1296 | { | 1297 | { |
1297 | if (targetWrapper != this || maxSizeInKb > 0 ) { | 1298 | if (targetWrapper != this || maxSizeInKb > 0 ) { |
1298 | mMax = 0; | 1299 | mMax = 0; |
1299 | progress( i18n("Copy")); | 1300 | progress( i18n("Copy")); |
1300 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); | 1301 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); |
1301 | //qDebug("IMAPwrapper::mvcpAllMails::Using generic"); | 1302 | //qDebug("IMAPwrapper::mvcpAllMails::Using generic"); |
1302 | // odebug << "Using generic" << oendl; | 1303 | // odebug << "Using generic" << oendl; |
1303 | return; | 1304 | return; |
1304 | } | 1305 | } |
1305 | mailimap_set *set = 0; | 1306 | mailimap_set *set = 0; |
1306 | login(); | 1307 | login(); |
1307 | if (!m_imap) { | 1308 | if (!m_imap) { |
1308 | return; | 1309 | return; |
1309 | } | 1310 | } |
1310 | int err = selectMbox(fromFolder->getName()); | 1311 | int err = selectMbox(fromFolder->getName()); |
1311 | if ( err != MAILIMAP_NO_ERROR ) { | 1312 | if ( err != MAILIMAP_NO_ERROR ) { |
1312 | return; | 1313 | return; |
1313 | } | 1314 | } |
1314 | Global::statusMessage( i18n("Copying mails on server...") ); | 1315 | Global::statusMessage( i18n("Copying mails on server...") ); |
1315 | int last = m_imap->imap_selection_info->sel_exists; | 1316 | int last = m_imap->imap_selection_info->sel_exists; |
1316 | set = mailimap_set_new_interval( 1, last ); | 1317 | set = mailimap_set_new_interval( 1, last ); |
1317 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1318 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1318 | mailimap_set_free( set ); | 1319 | mailimap_set_free( set ); |
1319 | if ( err != MAILIMAP_NO_ERROR ) { | 1320 | if ( err != MAILIMAP_NO_ERROR ) { |
1320 | QString error_msg = i18n("Error copy mails: %1").arg(m_imap->imap_response); | 1321 | QString error_msg = i18n("Error copy mails: %1").arg(m_imap->imap_response); |
1321 | Global::statusMessage(error_msg); | 1322 | Global::statusMessage(error_msg); |
1322 | // odebug << error_msg << oendl; | 1323 | // odebug << error_msg << oendl; |
1323 | return; | 1324 | return; |
1324 | } | 1325 | } |
1325 | if (moveit) { | 1326 | if (moveit) { |
1326 | deleteAllMail(fromFolder); | 1327 | deleteAllMail(fromFolder); |
1327 | } | 1328 | } |
1328 | } | 1329 | } |
1329 | 1330 | ||
1330 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1331 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1331 | { | 1332 | { |
1332 | if (targetWrapper != this) { | 1333 | if (targetWrapper != this) { |
1333 | // odebug << "Using generic" << oendl; | 1334 | // odebug << "Using generic" << oendl; |
1334 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 1335 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
1335 | return; | 1336 | return; |
1336 | } | 1337 | } |
1337 | mailimap_set *set = 0; | 1338 | mailimap_set *set = 0; |
1338 | login(); | 1339 | login(); |
1339 | if (!m_imap) { | 1340 | if (!m_imap) { |
1340 | return; | 1341 | return; |
1341 | } | 1342 | } |
1342 | int err = selectMbox(mail->getMbox()); | 1343 | int err = selectMbox(mail->getMbox()); |
1343 | if ( err != MAILIMAP_NO_ERROR ) { | 1344 | if ( err != MAILIMAP_NO_ERROR ) { |
1344 | return; | 1345 | return; |
1345 | } | 1346 | } |
1346 | set = mailimap_set_new_single(mail->getNumber()); | 1347 | set = mailimap_set_new_single(mail->getNumber()); |
1347 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1348 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1348 | mailimap_set_free( set ); | 1349 | mailimap_set_free( set ); |
1349 | if ( err != MAILIMAP_NO_ERROR ) { | 1350 | if ( err != MAILIMAP_NO_ERROR ) { |
1350 | QString error_msg = i18n("error copy mail: %1").arg(m_imap->imap_response); | 1351 | QString error_msg = i18n("error copy mail: %1").arg(m_imap->imap_response); |
1351 | Global::statusMessage(error_msg); | 1352 | Global::statusMessage(error_msg); |
1352 | // odebug << error_msg << oendl; | 1353 | // odebug << error_msg << oendl; |
1353 | return; | 1354 | return; |
1354 | } | 1355 | } |
1355 | if (moveit) { | 1356 | if (moveit) { |
1356 | deleteMail(mail); | 1357 | deleteMail(mail); |
1357 | } | 1358 | } |
1358 | } | 1359 | } |
diff --git a/kmicromail/libmailwrapper/mailtypes.cpp b/kmicromail/libmailwrapper/mailtypes.cpp index af3b9d0..89150ad 100644 --- a/kmicromail/libmailwrapper/mailtypes.cpp +++ b/kmicromail/libmailwrapper/mailtypes.cpp | |||
@@ -98,331 +98,342 @@ void RecMail::setTo(const QStringList&list) | |||
98 | } | 98 | } |
99 | 99 | ||
100 | const QStringList&RecMail::To()const | 100 | const QStringList&RecMail::To()const |
101 | { | 101 | { |
102 | return to; | 102 | return to; |
103 | } | 103 | } |
104 | 104 | ||
105 | void RecMail::setCC(const QStringList&list) | 105 | void RecMail::setCC(const QStringList&list) |
106 | { | 106 | { |
107 | cc = list; | 107 | cc = list; |
108 | } | 108 | } |
109 | 109 | ||
110 | const QStringList&RecMail::CC()const | 110 | const QStringList&RecMail::CC()const |
111 | { | 111 | { |
112 | return cc; | 112 | return cc; |
113 | } | 113 | } |
114 | 114 | ||
115 | void RecMail::setBcc(const QStringList&list) | 115 | void RecMail::setBcc(const QStringList&list) |
116 | { | 116 | { |
117 | bcc = list; | 117 | bcc = list; |
118 | } | 118 | } |
119 | 119 | ||
120 | const QStringList& RecMail::Bcc()const | 120 | const QStringList& RecMail::Bcc()const |
121 | { | 121 | { |
122 | return bcc; | 122 | return bcc; |
123 | } | 123 | } |
124 | 124 | ||
125 | void RecMail::setInreply(const QStringList&list) | 125 | void RecMail::setInreply(const QStringList&list) |
126 | { | 126 | { |
127 | in_reply_to = list; | 127 | in_reply_to = list; |
128 | } | 128 | } |
129 | 129 | ||
130 | const QStringList& RecMail::Inreply()const | 130 | const QStringList& RecMail::Inreply()const |
131 | { | 131 | { |
132 | return in_reply_to; | 132 | return in_reply_to; |
133 | } | 133 | } |
134 | 134 | ||
135 | void RecMail::setReferences(const QStringList&list) | 135 | void RecMail::setReferences(const QStringList&list) |
136 | { | 136 | { |
137 | references = list; | 137 | references = list; |
138 | } | 138 | } |
139 | 139 | ||
140 | const QStringList& RecMail::References()const | 140 | const QStringList& RecMail::References()const |
141 | { | 141 | { |
142 | return references; | 142 | return references; |
143 | } | 143 | } |
144 | 144 | ||
145 | RecPart::RecPart() | 145 | RecPart::RecPart() |
146 | : Opie::Core::ORefCount(), | 146 | : Opie::Core::ORefCount(), |
147 | m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) | 147 | m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) |
148 | { | 148 | { |
149 | m_Parameters.clear(); | 149 | m_Parameters.clear(); |
150 | m_poslist.clear(); | 150 | m_poslist.clear(); |
151 | } | 151 | } |
152 | 152 | ||
153 | RecPart::RecPart(const RecPart&old) | 153 | RecPart::RecPart(const RecPart&old) |
154 | : Opie::Core::ORefCount(), | 154 | : Opie::Core::ORefCount(), |
155 | m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) | 155 | m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) |
156 | { | 156 | { |
157 | m_type = old.m_type; | 157 | m_type = old.m_type; |
158 | m_subtype = old.m_subtype; | 158 | m_subtype = old.m_subtype; |
159 | m_identifier = old.m_identifier; | 159 | m_identifier = old.m_identifier; |
160 | m_encoding = old.m_encoding; | 160 | m_encoding = old.m_encoding; |
161 | m_description = old.m_description; | 161 | m_description = old.m_description; |
162 | m_lines = old.m_lines; | 162 | m_lines = old.m_lines; |
163 | m_size = old.m_size; | 163 | m_size = old.m_size; |
164 | m_Parameters = old.m_Parameters; | 164 | m_Parameters = old.m_Parameters; |
165 | m_poslist = old.m_poslist; | 165 | m_poslist = old.m_poslist; |
166 | // odebug << "RecPart copy constructor" << oendl; | 166 | // odebug << "RecPart copy constructor" << oendl; |
167 | } | 167 | } |
168 | 168 | ||
169 | RecPart::~RecPart() | 169 | RecPart::~RecPart() |
170 | { | 170 | { |
171 | } | 171 | } |
172 | 172 | ||
173 | void RecPart::setSize(unsigned int size) | 173 | void RecPart::setSize(unsigned int size) |
174 | { | 174 | { |
175 | m_size = size; | 175 | m_size = size; |
176 | } | 176 | } |
177 | 177 | ||
178 | const unsigned int RecPart::Size()const | 178 | const unsigned int RecPart::Size()const |
179 | { | 179 | { |
180 | return m_size; | 180 | return m_size; |
181 | } | 181 | } |
182 | 182 | ||
183 | void RecPart::setLines(unsigned int lines) | 183 | void RecPart::setLines(unsigned int lines) |
184 | { | 184 | { |
185 | m_lines = lines; | 185 | m_lines = lines; |
186 | } | 186 | } |
187 | 187 | ||
188 | const unsigned int RecPart::Lines()const | 188 | const unsigned int RecPart::Lines()const |
189 | { | 189 | { |
190 | return m_lines; | 190 | return m_lines; |
191 | } | 191 | } |
192 | 192 | ||
193 | const QString& RecPart::Type()const | 193 | const QString& RecPart::Type()const |
194 | { | 194 | { |
195 | return m_type; | 195 | return m_type; |
196 | } | 196 | } |
197 | 197 | ||
198 | void RecPart::setType(const QString&type) | 198 | void RecPart::setType(const QString&type) |
199 | { | 199 | { |
200 | m_type = type; | 200 | m_type = type; |
201 | } | 201 | } |
202 | 202 | ||
203 | const QString& RecPart::Subtype()const | 203 | const QString& RecPart::Subtype()const |
204 | { | 204 | { |
205 | return m_subtype; | 205 | return m_subtype; |
206 | } | 206 | } |
207 | 207 | ||
208 | void RecPart::setSubtype(const QString&subtype) | 208 | void RecPart::setSubtype(const QString&subtype) |
209 | { | 209 | { |
210 | m_subtype = subtype; | 210 | m_subtype = subtype; |
211 | } | 211 | } |
212 | 212 | ||
213 | const QString& RecPart::Identifier()const | 213 | const QString& RecPart::Identifier()const |
214 | { | 214 | { |
215 | return m_identifier; | 215 | return m_identifier; |
216 | } | 216 | } |
217 | 217 | ||
218 | void RecPart::setIdentifier(const QString&identifier) | 218 | void RecPart::setIdentifier(const QString&identifier) |
219 | { | 219 | { |
220 | m_identifier = identifier; | 220 | m_identifier = identifier; |
221 | } | 221 | } |
222 | 222 | ||
223 | const QString& RecPart::Encoding()const | 223 | const QString& RecPart::Encoding()const |
224 | { | 224 | { |
225 | return m_encoding; | 225 | return m_encoding; |
226 | } | 226 | } |
227 | 227 | ||
228 | void RecPart::setEncoding(const QString&encoding) | 228 | void RecPart::setEncoding(const QString&encoding) |
229 | { | 229 | { |
230 | m_encoding = encoding; | 230 | m_encoding = encoding; |
231 | } | 231 | } |
232 | 232 | ||
233 | const QString& RecPart::Description()const | 233 | const QString& RecPart::Description()const |
234 | { | 234 | { |
235 | return m_description; | 235 | return m_description; |
236 | } | 236 | } |
237 | 237 | ||
238 | void RecPart::setDescription(const QString&desc) | 238 | void RecPart::setDescription(const QString&desc) |
239 | { | 239 | { |
240 | m_description = desc; | 240 | m_description = desc; |
241 | } | 241 | } |
242 | 242 | ||
243 | void RecPart::setParameters(const part_plist_t&list) | 243 | void RecPart::setParameters(const part_plist_t&list) |
244 | { | 244 | { |
245 | m_Parameters = list; | 245 | m_Parameters = list; |
246 | } | 246 | } |
247 | 247 | ||
248 | const part_plist_t& RecPart::Parameters()const | 248 | const part_plist_t& RecPart::Parameters()const |
249 | { | 249 | { |
250 | return m_Parameters; | 250 | return m_Parameters; |
251 | } | 251 | } |
252 | 252 | ||
253 | void RecPart::addParameter(const QString&key,const QString&value) | 253 | void RecPart::addParameter(const QString&key,const QString&value) |
254 | { | 254 | { |
255 | m_Parameters[key]=value; | 255 | m_Parameters[key]=value; |
256 | } | 256 | } |
257 | 257 | ||
258 | const QString RecPart::searchParamter(const QString&key)const | 258 | const QString RecPart::searchParamter(const QString&key)const |
259 | { | 259 | { |
260 | QString value(""); | 260 | QString value(""); |
261 | part_plist_t::ConstIterator it = m_Parameters.find(key); | 261 | part_plist_t::ConstIterator it = m_Parameters.find(key); |
262 | if (it != m_Parameters.end()) { | 262 | if (it != m_Parameters.end()) { |
263 | value = it.data(); | 263 | value = it.data(); |
264 | } | 264 | } |
265 | return value; | 265 | return value; |
266 | } | 266 | } |
267 | 267 | ||
268 | void RecPart::setPositionlist(const QValueList<int>&poslist) | 268 | void RecPart::setPositionlist(const QValueList<int>&poslist) |
269 | { | 269 | { |
270 | m_poslist = poslist; | 270 | m_poslist = poslist; |
271 | } | 271 | } |
272 | 272 | ||
273 | const QValueList<int>& RecPart::Positionlist()const | 273 | const QValueList<int>& RecPart::Positionlist()const |
274 | { | 274 | { |
275 | return m_poslist; | 275 | return m_poslist; |
276 | } | 276 | } |
277 | 277 | ||
278 | RecBody::RecBody() | 278 | RecBody::RecBody() |
279 | : Opie::Core::ORefCount(),m_BodyText(),m_description(new RecPart()) | 279 | : Opie::Core::ORefCount(),m_BodyText(),m_description(new RecPart()) |
280 | { | 280 | { |
281 | m_PartsList.clear(); | 281 | m_PartsList.clear(); |
282 | } | 282 | } |
283 | 283 | ||
284 | RecBody::RecBody(const RecBody&old) | 284 | RecBody::RecBody(const RecBody&old) |
285 | :Opie::Core::ORefCount(),m_BodyText(),m_PartsList(),m_description(new RecPart()) | 285 | :Opie::Core::ORefCount(),m_BodyText(),m_PartsList(),m_description(new RecPart()) |
286 | { | 286 | { |
287 | m_BodyText = old.m_BodyText; | 287 | m_BodyText = old.m_BodyText; |
288 | m_PartsList = old.m_PartsList; | 288 | m_PartsList = old.m_PartsList; |
289 | m_description = old.m_description; | 289 | m_description = old.m_description; |
290 | mCharset = old.mCharset; | ||
290 | // odebug << "Recbody copy constructor" << oendl; | 291 | // odebug << "Recbody copy constructor" << oendl; |
291 | } | 292 | } |
292 | 293 | ||
293 | RecBody::~RecBody() | 294 | RecBody::~RecBody() |
294 | { | 295 | { |
295 | } | 296 | } |
296 | 297 | ||
297 | void RecBody::setBodytext(const QString&bodyText) | 298 | void RecBody::setBodytext(const QString&bodyText) |
298 | { | 299 | { |
299 | m_BodyText = bodyText; | 300 | m_BodyText = bodyText; |
300 | } | 301 | } |
301 | 302 | ||
302 | const QString& RecBody::Bodytext()const | 303 | const QString& RecBody::Bodytext()const |
303 | { | 304 | { |
304 | return m_BodyText; | 305 | return m_BodyText; |
305 | } | 306 | } |
306 | 307 | ||
307 | void RecBody::setParts(const QValueList<RecPartP>&parts) | 308 | void RecBody::setParts(const QValueList<RecPartP>&parts) |
308 | { | 309 | { |
309 | m_PartsList.clear(); | 310 | m_PartsList.clear(); |
310 | m_PartsList = parts; | 311 | m_PartsList = parts; |
311 | } | 312 | } |
312 | 313 | ||
313 | const QValueList<RecPartP>& RecBody::Parts()const | 314 | const QValueList<RecPartP>& RecBody::Parts()const |
314 | { | 315 | { |
315 | return m_PartsList; | 316 | return m_PartsList; |
316 | } | 317 | } |
317 | 318 | ||
318 | void RecBody::addPart(const RecPartP& part) | 319 | void RecBody::addPart(const RecPartP& part) |
319 | { | 320 | { |
320 | m_PartsList.append(part); | 321 | m_PartsList.append(part); |
321 | } | 322 | } |
322 | 323 | ||
323 | void RecBody::setDescription(const RecPartP&des) | 324 | void RecBody::setDescription(const RecPartP&des) |
324 | { | 325 | { |
325 | m_description = des; | 326 | m_description = des; |
326 | } | 327 | } |
327 | 328 | ||
328 | const RecPartP& RecBody::Description()const | 329 | const RecPartP& RecBody::Description()const |
329 | { | 330 | { |
330 | return m_description; | 331 | return m_description; |
331 | } | 332 | } |
332 | 333 | ||
334 | void RecBody::setCharset(const QString& str) | ||
335 | { | ||
336 | mCharset = str; | ||
337 | } | ||
338 | |||
339 | QString RecBody::getCharset()const | ||
340 | { | ||
341 | return mCharset; | ||
342 | } | ||
343 | |||
333 | /* handling encoded content */ | 344 | /* handling encoded content */ |
334 | encodedString::encodedString() | 345 | encodedString::encodedString() |
335 | { | 346 | { |
336 | init(); | 347 | init(); |
337 | } | 348 | } |
338 | 349 | ||
339 | encodedString::encodedString(const char*nContent,unsigned int nSize) | 350 | encodedString::encodedString(const char*nContent,unsigned int nSize) |
340 | { | 351 | { |
341 | init(); | 352 | init(); |
342 | setContent(nContent,nSize); | 353 | setContent(nContent,nSize); |
343 | } | 354 | } |
344 | 355 | ||
345 | encodedString::encodedString(char*nContent,unsigned int nSize) | 356 | encodedString::encodedString(char*nContent,unsigned int nSize) |
346 | { | 357 | { |
347 | init(); | 358 | init(); |
348 | setContent(nContent,nSize); | 359 | setContent(nContent,nSize); |
349 | } | 360 | } |
350 | 361 | ||
351 | encodedString::encodedString(const encodedString&old) | 362 | encodedString::encodedString(const encodedString&old) |
352 | { | 363 | { |
353 | init(); | 364 | init(); |
354 | copy_old(old); | 365 | copy_old(old); |
355 | // odebug << "encodedeString: copy constructor!" << oendl; | 366 | // odebug << "encodedeString: copy constructor!" << oendl; |
356 | } | 367 | } |
357 | 368 | ||
358 | encodedString& encodedString::operator=(const encodedString&old) | 369 | encodedString& encodedString::operator=(const encodedString&old) |
359 | { | 370 | { |
360 | init(); | 371 | init(); |
361 | copy_old(old); | 372 | copy_old(old); |
362 | // odebug << "encodedString: assign operator!" << oendl; | 373 | // odebug << "encodedString: assign operator!" << oendl; |
363 | return *this; | 374 | return *this; |
364 | } | 375 | } |
365 | 376 | ||
366 | encodedString::~encodedString() | 377 | encodedString::~encodedString() |
367 | { | 378 | { |
368 | clean(); | 379 | clean(); |
369 | } | 380 | } |
370 | 381 | ||
371 | void encodedString::init() | 382 | void encodedString::init() |
372 | { | 383 | { |
373 | content = 0; | 384 | content = 0; |
374 | size = 0; | 385 | size = 0; |
375 | } | 386 | } |
376 | 387 | ||
377 | void encodedString::clean() | 388 | void encodedString::clean() |
378 | { | 389 | { |
379 | if (content) { | 390 | if (content) { |
380 | free(content); | 391 | free(content); |
381 | } | 392 | } |
382 | content = 0; | 393 | content = 0; |
383 | size = 0; | 394 | size = 0; |
384 | } | 395 | } |
385 | 396 | ||
386 | void encodedString::copy_old(const encodedString&old) | 397 | void encodedString::copy_old(const encodedString&old) |
387 | { | 398 | { |
388 | clean(); | 399 | clean(); |
389 | if (old.size>0 && old.content) { | 400 | if (old.size>0 && old.content) { |
390 | content = (char*)malloc(old.size*sizeof(char)); | 401 | content = (char*)malloc(old.size*sizeof(char)); |
391 | memcpy(content,old.content,size); | 402 | memcpy(content,old.content,size); |
392 | size = old.size; | 403 | size = old.size; |
393 | } | 404 | } |
394 | } | 405 | } |
395 | 406 | ||
396 | const char*encodedString::Content()const | 407 | const char*encodedString::Content()const |
397 | { | 408 | { |
398 | return content; | 409 | return content; |
399 | } | 410 | } |
400 | 411 | ||
401 | const int encodedString::Length()const | 412 | const int encodedString::Length()const |
402 | { | 413 | { |
403 | return size; | 414 | return size; |
404 | } | 415 | } |
405 | 416 | ||
406 | void encodedString::setContent(const char*nContent,int nSize) | 417 | void encodedString::setContent(const char*nContent,int nSize) |
407 | { | 418 | { |
408 | if (nSize>0 && nContent) { | 419 | if (nSize>0 && nContent) { |
409 | content = (char*)malloc(nSize*sizeof(char)); | 420 | content = (char*)malloc(nSize*sizeof(char)); |
410 | memcpy(content,nContent,nSize); | 421 | memcpy(content,nContent,nSize); |
411 | size = nSize; | 422 | size = nSize; |
412 | } | 423 | } |
413 | } | 424 | } |
414 | 425 | ||
415 | void encodedString::setContent(char*nContent,int nSize) | 426 | void encodedString::setContent(char*nContent,int nSize) |
416 | { | 427 | { |
417 | content = nContent; | 428 | content = nContent; |
418 | size = nSize; | 429 | size = nSize; |
419 | } | 430 | } |
420 | 431 | ||
421 | folderStat&folderStat::operator=(const folderStat&old) | 432 | folderStat&folderStat::operator=(const folderStat&old) |
422 | { | 433 | { |
423 | message_count = old.message_count; | 434 | message_count = old.message_count; |
424 | message_unseen = old.message_unseen; | 435 | message_unseen = old.message_unseen; |
425 | message_recent = old.message_recent; | 436 | message_recent = old.message_recent; |
426 | return *this; | 437 | return *this; |
427 | } | 438 | } |
428 | 439 | ||
diff --git a/kmicromail/libmailwrapper/mailtypes.h b/kmicromail/libmailwrapper/mailtypes.h index c1c1a74..32d92c0 100644 --- a/kmicromail/libmailwrapper/mailtypes.h +++ b/kmicromail/libmailwrapper/mailtypes.h | |||
@@ -1,211 +1,214 @@ | |||
1 | #ifndef __MAIL_TYPES_H | 1 | #ifndef __MAIL_TYPES_H |
2 | #define __MAIL_TYPES_H | 2 | #define __MAIL_TYPES_H |
3 | 3 | ||
4 | #define FLAG_ANSWERED 0 | 4 | #define FLAG_ANSWERED 0 |
5 | #define FLAG_FLAGGED 1 | 5 | #define FLAG_FLAGGED 1 |
6 | #define FLAG_DELETED 2 | 6 | #define FLAG_DELETED 2 |
7 | #define FLAG_SEEN 3 | 7 | #define FLAG_SEEN 3 |
8 | #define FLAG_DRAFT 4 | 8 | #define FLAG_DRAFT 4 |
9 | #define FLAG_RECENT 5 | 9 | #define FLAG_RECENT 5 |
10 | 10 | ||
11 | #include <opie2/osmartpointer.h> | 11 | #include <opie2/osmartpointer.h> |
12 | 12 | ||
13 | #include <qbitarray.h> | 13 | #include <qbitarray.h> |
14 | #include <qstring.h> | 14 | #include <qstring.h> |
15 | #include <qstringlist.h> | 15 | #include <qstringlist.h> |
16 | #include <qmap.h> | 16 | #include <qmap.h> |
17 | #include <qvaluelist.h> | 17 | #include <qvaluelist.h> |
18 | 18 | ||
19 | class AbstractMail; | 19 | class AbstractMail; |
20 | /* a class to describe mails in a mailbox */ | 20 | /* a class to describe mails in a mailbox */ |
21 | /* Attention! | 21 | /* Attention! |
22 | From programmers point of view it would make sense to | 22 | From programmers point of view it would make sense to |
23 | store the mail body into this class, too. | 23 | store the mail body into this class, too. |
24 | But: not from the point of view of the device. | 24 | But: not from the point of view of the device. |
25 | Mailbodies can be real large. So we request them when | 25 | Mailbodies can be real large. So we request them when |
26 | needed from the mail-wrapper class direct from the server itself | 26 | needed from the mail-wrapper class direct from the server itself |
27 | (imap) or from a file-based cache (pop3?) | 27 | (imap) or from a file-based cache (pop3?) |
28 | So there is no interface "const QString&body()" but you should | 28 | So there is no interface "const QString&body()" but you should |
29 | make a request to the mailwrapper with this class as parameter to | 29 | make a request to the mailwrapper with this class as parameter to |
30 | get the body. Same words for the attachments. | 30 | get the body. Same words for the attachments. |
31 | */ | 31 | */ |
32 | class RecMail:public Opie::Core::ORefCount | 32 | class RecMail:public Opie::Core::ORefCount |
33 | { | 33 | { |
34 | public: | 34 | public: |
35 | RecMail(); | 35 | RecMail(); |
36 | RecMail(const RecMail&old); | 36 | RecMail(const RecMail&old); |
37 | virtual ~RecMail(); | 37 | virtual ~RecMail(); |
38 | bool isEqual( RecMail* r1 ); | 38 | bool isEqual( RecMail* r1 ); |
39 | 39 | ||
40 | const unsigned int getNumber()const{return msg_number;} | 40 | const unsigned int getNumber()const{return msg_number;} |
41 | void setNumber(unsigned int number){msg_number=number;} | 41 | void setNumber(unsigned int number){msg_number=number;} |
42 | const QString&getDate()const{ return date; } | 42 | const QString&getDate()const{ return date; } |
43 | void setDate( const QString&a ) { date = a; } | 43 | void setDate( const QString&a ) { date = a; } |
44 | const QString&getIsoDate()const{ return isodate; } | 44 | const QString&getIsoDate()const{ return isodate; } |
45 | void setIsoDate( const QString&a ) { isodate = a; } | 45 | void setIsoDate( const QString&a ) { isodate = a; } |
46 | const QString&getFrom()const{ return from; } | 46 | const QString&getFrom()const{ return from; } |
47 | void setFrom( const QString&a ) { from = a; } | 47 | void setFrom( const QString&a ) { from = a; } |
48 | const QString&getSubject()const { return subject; } | 48 | const QString&getSubject()const { return subject; } |
49 | void setSubject( const QString&s ) { subject = s; } | 49 | void setSubject( const QString&s ) { subject = s; } |
50 | const QString&getMbox()const{return mbox;} | 50 | const QString&getMbox()const{return mbox;} |
51 | void setMbox(const QString&box){mbox = box;} | 51 | void setMbox(const QString&box){mbox = box;} |
52 | void setMsgid(const QString&id){msg_id=id;} | 52 | void setMsgid(const QString&id){msg_id=id;} |
53 | const QString&Msgid()const{return msg_id;} | 53 | const QString&Msgid()const{return msg_id;} |
54 | void setReplyto(const QString&reply){replyto=reply;} | 54 | void setReplyto(const QString&reply){replyto=reply;} |
55 | const QString&Replyto()const{return replyto;} | 55 | const QString&Replyto()const{return replyto;} |
56 | void setMsgsize(unsigned int size){msg_size = size;} | 56 | void setMsgsize(unsigned int size){msg_size = size;} |
57 | const unsigned int Msgsize()const{return msg_size;} | 57 | const unsigned int Msgsize()const{return msg_size;} |
58 | 58 | ||
59 | 59 | ||
60 | void setTo(const QStringList&list); | 60 | void setTo(const QStringList&list); |
61 | const QStringList&To()const; | 61 | const QStringList&To()const; |
62 | void setCC(const QStringList&list); | 62 | void setCC(const QStringList&list); |
63 | const QStringList&CC()const; | 63 | const QStringList&CC()const; |
64 | void setBcc(const QStringList&list); | 64 | void setBcc(const QStringList&list); |
65 | const QStringList&Bcc()const; | 65 | const QStringList&Bcc()const; |
66 | void setInreply(const QStringList&list); | 66 | void setInreply(const QStringList&list); |
67 | const QStringList&Inreply()const; | 67 | const QStringList&Inreply()const; |
68 | void setReferences(const QStringList&list); | 68 | void setReferences(const QStringList&list); |
69 | const QStringList&References()const; | 69 | const QStringList&References()const; |
70 | 70 | ||
71 | const QBitArray&getFlags()const{return msg_flags;} | 71 | const QBitArray&getFlags()const{return msg_flags;} |
72 | void setFlags(const QBitArray&flags){msg_flags = flags;} | 72 | void setFlags(const QBitArray&flags){msg_flags = flags;} |
73 | 73 | ||
74 | void setWrapper(AbstractMail*wrapper); | 74 | void setWrapper(AbstractMail*wrapper); |
75 | AbstractMail* Wrapper(); | 75 | AbstractMail* Wrapper(); |
76 | // public for debugging | 76 | // public for debugging |
77 | QString subject,date,isodate,from,mbox,msg_id,replyto; | 77 | QString subject,date,isodate,from,mbox,msg_id,replyto; |
78 | 78 | ||
79 | protected: | 79 | protected: |
80 | //QString subject,date,isodate,from,mbox,msg_id,replyto; | 80 | //QString subject,date,isodate,from,mbox,msg_id,replyto; |
81 | unsigned int msg_number,msg_size; | 81 | unsigned int msg_number,msg_size; |
82 | QBitArray msg_flags; | 82 | QBitArray msg_flags; |
83 | QStringList to,cc,bcc,in_reply_to,references; | 83 | QStringList to,cc,bcc,in_reply_to,references; |
84 | AbstractMail*wrapper; | 84 | AbstractMail*wrapper; |
85 | void init(); | 85 | void init(); |
86 | void copy_old(const RecMail&old); | 86 | void copy_old(const RecMail&old); |
87 | }; | 87 | }; |
88 | 88 | ||
89 | typedef Opie::Core::OSmartPointer<RecMail> RecMailP; | 89 | typedef Opie::Core::OSmartPointer<RecMail> RecMailP; |
90 | typedef QMap<QString,QString> part_plist_t; | 90 | typedef QMap<QString,QString> part_plist_t; |
91 | 91 | ||
92 | class RecPart:public Opie::Core::ORefCount | 92 | class RecPart:public Opie::Core::ORefCount |
93 | { | 93 | { |
94 | protected: | 94 | protected: |
95 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; | 95 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; |
96 | unsigned int m_lines,m_size; | 96 | unsigned int m_lines,m_size; |
97 | part_plist_t m_Parameters; | 97 | part_plist_t m_Parameters; |
98 | /* describes the position in the mail */ | 98 | /* describes the position in the mail */ |
99 | QValueList<int> m_poslist; | 99 | QValueList<int> m_poslist; |
100 | 100 | ||
101 | public: | 101 | public: |
102 | RecPart(); | 102 | RecPart(); |
103 | RecPart(const RecPart&); | 103 | RecPart(const RecPart&); |
104 | virtual ~RecPart(); | 104 | virtual ~RecPart(); |
105 | 105 | ||
106 | const QString&Type()const; | 106 | const QString&Type()const; |
107 | void setType(const QString&type); | 107 | void setType(const QString&type); |
108 | const QString&Subtype()const; | 108 | const QString&Subtype()const; |
109 | void setSubtype(const QString&subtype); | 109 | void setSubtype(const QString&subtype); |
110 | const QString&Identifier()const; | 110 | const QString&Identifier()const; |
111 | void setIdentifier(const QString&identifier); | 111 | void setIdentifier(const QString&identifier); |
112 | const QString&Encoding()const; | 112 | const QString&Encoding()const; |
113 | void setEncoding(const QString&encoding); | 113 | void setEncoding(const QString&encoding); |
114 | const QString&Description()const; | 114 | const QString&Description()const; |
115 | void setDescription(const QString&desc); | 115 | void setDescription(const QString&desc); |
116 | void setLines(unsigned int lines); | 116 | void setLines(unsigned int lines); |
117 | const unsigned int Lines()const; | 117 | const unsigned int Lines()const; |
118 | void setSize(unsigned int size); | 118 | void setSize(unsigned int size); |
119 | const unsigned int Size()const; | 119 | const unsigned int Size()const; |
120 | 120 | ||
121 | 121 | ||
122 | void setParameters(const part_plist_t&list); | 122 | void setParameters(const part_plist_t&list); |
123 | const part_plist_t&Parameters()const; | 123 | const part_plist_t&Parameters()const; |
124 | void addParameter(const QString&key,const QString&value); | 124 | void addParameter(const QString&key,const QString&value); |
125 | const QString searchParamter(const QString&key)const; | 125 | const QString searchParamter(const QString&key)const; |
126 | void setPositionlist(const QValueList<int>&poslist); | 126 | void setPositionlist(const QValueList<int>&poslist); |
127 | const QValueList<int>& Positionlist()const; | 127 | const QValueList<int>& Positionlist()const; |
128 | }; | 128 | }; |
129 | 129 | ||
130 | typedef Opie::Core::OSmartPointer<RecPart> RecPartP; | 130 | typedef Opie::Core::OSmartPointer<RecPart> RecPartP; |
131 | 131 | ||
132 | class RecBody:public Opie::Core::ORefCount | 132 | class RecBody:public Opie::Core::ORefCount |
133 | { | 133 | { |
134 | protected: | 134 | protected: |
135 | QString m_BodyText; | 135 | QString m_BodyText; |
136 | QString mCharset; | ||
136 | QValueList<RecPartP> m_PartsList; | 137 | QValueList<RecPartP> m_PartsList; |
137 | RecPartP m_description; | 138 | RecPartP m_description; |
138 | 139 | ||
139 | public: | 140 | public: |
140 | RecBody(); | 141 | RecBody(); |
141 | RecBody(const RecBody&old); | 142 | RecBody(const RecBody&old); |
142 | virtual ~RecBody(); | 143 | virtual ~RecBody(); |
143 | void setBodytext(const QString&); | 144 | void setBodytext(const QString&); |
144 | const QString& Bodytext()const; | 145 | const QString& Bodytext()const; |
146 | void setCharset(const QString&); | ||
147 | QString getCharset()const; | ||
145 | 148 | ||
146 | void setDescription(const RecPartP&des); | 149 | void setDescription(const RecPartP&des); |
147 | const RecPartP& Description()const; | 150 | const RecPartP& Description()const; |
148 | 151 | ||
149 | void setParts(const QValueList<RecPartP>&parts); | 152 | void setParts(const QValueList<RecPartP>&parts); |
150 | const QValueList<RecPartP>& Parts()const; | 153 | const QValueList<RecPartP>& Parts()const; |
151 | void addPart(const RecPartP&part); | 154 | void addPart(const RecPartP&part); |
152 | }; | 155 | }; |
153 | 156 | ||
154 | typedef Opie::Core::OSmartPointer<RecBody> RecBodyP; | 157 | typedef Opie::Core::OSmartPointer<RecBody> RecBodyP; |
155 | 158 | ||
156 | class encodedString | 159 | class encodedString |
157 | { | 160 | { |
158 | public: | 161 | public: |
159 | encodedString(); | 162 | encodedString(); |
160 | /* | 163 | /* |
161 | creates an new content string. | 164 | creates an new content string. |
162 | it makes a deep copy of it! | 165 | it makes a deep copy of it! |
163 | */ | 166 | */ |
164 | encodedString(const char*nContent,unsigned int length); | 167 | encodedString(const char*nContent,unsigned int length); |
165 | /* | 168 | /* |
166 | Take over the nContent. Means: it will just copy the pointer, not the content. | 169 | Take over the nContent. Means: it will just copy the pointer, not the content. |
167 | so make sure: No one else frees the string, the string has allocated with | 170 | so make sure: No one else frees the string, the string has allocated with |
168 | malloc for compatibility with c-based libs | 171 | malloc for compatibility with c-based libs |
169 | */ | 172 | */ |
170 | encodedString(char*nContent,unsigned int nSize); | 173 | encodedString(char*nContent,unsigned int nSize); |
171 | /* copy construkor - makes ALWAYS a deep copy!!!! */ | 174 | /* copy construkor - makes ALWAYS a deep copy!!!! */ |
172 | encodedString(const encodedString&old); | 175 | encodedString(const encodedString&old); |
173 | /* assign operator - makes ALWAYS a deep copy!!!! */ | 176 | /* assign operator - makes ALWAYS a deep copy!!!! */ |
174 | encodedString& operator=(const encodedString&old); | 177 | encodedString& operator=(const encodedString&old); |
175 | /* destructor - cleans the content */ | 178 | /* destructor - cleans the content */ |
176 | virtual ~encodedString(); | 179 | virtual ~encodedString(); |
177 | 180 | ||
178 | /* returns a pointer to the content - do not delete yoursel! */ | 181 | /* returns a pointer to the content - do not delete yoursel! */ |
179 | const char*Content()const; | 182 | const char*Content()const; |
180 | /* returns the lengths of the content 'cause it must not be a null-terminated string! */ | 183 | /* returns the lengths of the content 'cause it must not be a null-terminated string! */ |
181 | const int Length()const; | 184 | const int Length()const; |
182 | 185 | ||
183 | /* | 186 | /* |
184 | makes a deep copy of nContent! | 187 | makes a deep copy of nContent! |
185 | */ | 188 | */ |
186 | void setContent(const char*nContent,int nSize); | 189 | void setContent(const char*nContent,int nSize); |
187 | /* | 190 | /* |
188 | Take over the nContent. Means: it will just copy the pointer, not the content. | 191 | Take over the nContent. Means: it will just copy the pointer, not the content. |
189 | so make sure: No one else frees the string, the string has allocated with | 192 | so make sure: No one else frees the string, the string has allocated with |
190 | malloc for compatibility with c-based libs | 193 | malloc for compatibility with c-based libs |
191 | */ | 194 | */ |
192 | void setContent(char*nContent,int nSize); | 195 | void setContent(char*nContent,int nSize); |
193 | 196 | ||
194 | protected: | 197 | protected: |
195 | char * content; | 198 | char * content; |
196 | unsigned int size; | 199 | unsigned int size; |
197 | 200 | ||
198 | void init(); | 201 | void init(); |
199 | void copy_old(const encodedString&old); | 202 | void copy_old(const encodedString&old); |
200 | void clean(); | 203 | void clean(); |
201 | }; | 204 | }; |
202 | 205 | ||
203 | struct folderStat | 206 | struct folderStat |
204 | { | 207 | { |
205 | unsigned int message_count; | 208 | unsigned int message_count; |
206 | unsigned int message_unseen; | 209 | unsigned int message_unseen; |
207 | unsigned int message_recent; | 210 | unsigned int message_recent; |
208 | folderStat&operator=(const folderStat&old); | 211 | folderStat&operator=(const folderStat&old); |
209 | }; | 212 | }; |
210 | 213 | ||
211 | #endif | 214 | #endif |
diff --git a/kmicromail/libmailwrapper/mailwrapper.h b/kmicromail/libmailwrapper/mailwrapper.h index 88f10da..ea6bf36 100644 --- a/kmicromail/libmailwrapper/mailwrapper.h +++ b/kmicromail/libmailwrapper/mailwrapper.h | |||
@@ -1,128 +1,131 @@ | |||
1 | #ifndef MAILWRAPPER_H | 1 | #ifndef MAILWRAPPER_H |
2 | #define MAILWRAPPER_H | 2 | #define MAILWRAPPER_H |
3 | 3 | ||
4 | //#include <qpe/applnk.h> | 4 | //#include <qpe/applnk.h> |
5 | 5 | ||
6 | #include <qbitarray.h> | 6 | #include <qbitarray.h> |
7 | #include <qdatetime.h> | 7 | #include <qdatetime.h> |
8 | #include <qfileinfo.h> | 8 | #include <qfileinfo.h> |
9 | #include <kiconloader.h> | 9 | #include <kiconloader.h> |
10 | 10 | ||
11 | #include "settings.h" | 11 | #include "settings.h" |
12 | 12 | ||
13 | #include <opie2/osmartpointer.h> | 13 | #include <opie2/osmartpointer.h> |
14 | /* | 14 | /* |
15 | class Attachment | 15 | class Attachment |
16 | { | 16 | { |
17 | public: | 17 | public: |
18 | Attachment( DocLnk lnk ); | 18 | Attachment( DocLnk lnk ); |
19 | virtual ~Attachment(){} | 19 | virtual ~Attachment(){} |
20 | const QString getFileName()const{ return doc.file(); } | 20 | const QString getFileName()const{ return doc.file(); } |
21 | const QString getName()const{ return doc.name(); } | 21 | const QString getName()const{ return doc.name(); } |
22 | const QString getMimeType()const{ return doc.type(); } | 22 | const QString getMimeType()const{ return doc.type(); } |
23 | const QPixmap getPixmap()const{ return doc.pixmap(); } | 23 | const QPixmap getPixmap()const{ return doc.pixmap(); } |
24 | const int getSize()const { return size; } | 24 | const int getSize()const { return size; } |
25 | DocLnk getDocLnk() { return doc; } | 25 | DocLnk getDocLnk() { return doc; } |
26 | 26 | ||
27 | protected: | 27 | protected: |
28 | DocLnk doc; | 28 | DocLnk doc; |
29 | int size; | 29 | int size; |
30 | 30 | ||
31 | }; | 31 | }; |
32 | */ | 32 | */ |
33 | 33 | ||
34 | class Attachment | 34 | class Attachment |
35 | { | 35 | { |
36 | public: | 36 | public: |
37 | Attachment( QString lnk ); | 37 | Attachment( QString lnk ); |
38 | virtual ~Attachment(){} | 38 | virtual ~Attachment(){} |
39 | const QString getFileName()const{ return doc; } | 39 | const QString getFileName()const{ return doc; } |
40 | const QString getName()const{ return QFileInfo( doc ).baseName (); } | 40 | const QString getName()const{ return QFileInfo( doc ).baseName (); } |
41 | const QString getMimeType()const{ return QFileInfo( doc ).extension(false); } | 41 | const QString getMimeType()const{ return QFileInfo( doc ).extension(false); } |
42 | const QPixmap getPixmap()const{ return mPix; } | 42 | const QPixmap getPixmap()const{ return mPix; } |
43 | const int getSize()const { return size; } | 43 | const int getSize()const { return size; } |
44 | QString getDocLnk() { return doc; } | 44 | QString getDocLnk() { return doc; } |
45 | 45 | ||
46 | protected: | 46 | protected: |
47 | QPixmap mPix; | 47 | QPixmap mPix; |
48 | QString doc; | 48 | QString doc; |
49 | int size; | 49 | int size; |
50 | 50 | ||
51 | }; | 51 | }; |
52 | 52 | ||
53 | class Mail:public Opie::Core::ORefCount | 53 | class Mail:public Opie::Core::ORefCount |
54 | { | 54 | { |
55 | public: | 55 | public: |
56 | Mail(); | 56 | Mail(); |
57 | /* Possible that this destructor must not be declared virtual | 57 | /* Possible that this destructor must not be declared virtual |
58 | * 'cause it seems that it will never have some child classes. | 58 | * 'cause it seems that it will never have some child classes. |
59 | * in this case this object will not get a virtual table -> memory and | 59 | * in this case this object will not get a virtual table -> memory and |
60 | * speed will be a little bit better? | 60 | * speed will be a little bit better? |
61 | */ | 61 | */ |
62 | virtual ~Mail(){} | 62 | virtual ~Mail(){} |
63 | void addAttachment( Attachment *att ) { attList.append( att ); } | 63 | void addAttachment( Attachment *att ) { attList.append( att ); } |
64 | const QList<Attachment>& getAttachments()const { return attList; } | 64 | const QList<Attachment>& getAttachments()const { return attList; } |
65 | void removeAttachment( Attachment *att ) { attList.remove( att ); } | 65 | void removeAttachment( Attachment *att ) { attList.remove( att ); } |
66 | const QString&getName()const { return name; } | 66 | const QString&getName()const { return name; } |
67 | void setName( QString s ) { name = s; } | 67 | void setName( QString s ) { name = s; } |
68 | const QString&getMail()const{ return mail; } | 68 | const QString&getMail()const{ return mail; } |
69 | void setMail( const QString&s ) { mail = s; } | 69 | void setMail( const QString&s ) { mail = s; } |
70 | const QString&getTo()const{ return to; } | 70 | const QString&getTo()const{ return to; } |
71 | void setTo( const QString&s ) { to = s; } | 71 | void setTo( const QString&s ) { to = s; } |
72 | const QString&getCC()const{ return cc; } | 72 | const QString&getCC()const{ return cc; } |
73 | void setCC( const QString&s ) { cc = s; } | 73 | void setCC( const QString&s ) { cc = s; } |
74 | const QString&getBCC()const { return bcc; } | 74 | const QString&getBCC()const { return bcc; } |
75 | void setBCC( const QString&s ) { bcc = s; } | 75 | void setBCC( const QString&s ) { bcc = s; } |
76 | const QString&getMessage()const { return message; } | 76 | const QString&getMessage()const { return message; } |
77 | void setMessage( const QString&s ) { message = s; } | 77 | void setMessage( const QString&s ) { message = s; } |
78 | const QString&getSubject()const { return subject; } | 78 | const QString&getSubject()const { return subject; } |
79 | void setSubject( const QString&s ) { subject = s; } | 79 | void setSubject( const QString&s ) { subject = s; } |
80 | const QString&getReply()const{ return reply; } | 80 | const QString&getReply()const{ return reply; } |
81 | void setReply( const QString&a ) { reply = a; } | 81 | void setReply( const QString&a ) { reply = a; } |
82 | void setInreply(const QStringList&list){m_in_reply_to = list;} | 82 | void setInreply(const QStringList&list){m_in_reply_to = list;} |
83 | const QStringList&Inreply()const{return m_in_reply_to;} | 83 | const QStringList&Inreply()const{return m_in_reply_to;} |
84 | 84 | ||
85 | void setCharset( const QString&a ) { charset= a; } | ||
86 | const QString& getCharset() { return charset; } | ||
87 | |||
85 | private: | 88 | private: |
86 | QList<Attachment> attList; | 89 | QList<Attachment> attList; |
87 | QString name, mail, to, cc, bcc, reply, subject, message; | 90 | QString name, mail, to, cc, bcc, reply, subject, message, charset; |
88 | QStringList m_in_reply_to; | 91 | QStringList m_in_reply_to; |
89 | }; | 92 | }; |
90 | 93 | ||
91 | class Folder:public Opie::Core::ORefCount | 94 | class Folder:public Opie::Core::ORefCount |
92 | { | 95 | { |
93 | public: | 96 | public: |
94 | Folder( const QString&init_name,const QString&sep ); | 97 | Folder( const QString&init_name,const QString&sep ); |
95 | virtual ~Folder(); | 98 | virtual ~Folder(); |
96 | const QString&getDisplayName()const { return nameDisplay; } | 99 | const QString&getDisplayName()const { return nameDisplay; } |
97 | const QString&getName()const { return name; } | 100 | const QString&getName()const { return name; } |
98 | const QString&getPrefix()const{return prefix; } | 101 | const QString&getPrefix()const{return prefix; } |
99 | virtual bool may_select()const{return true;} | 102 | virtual bool may_select()const{return true;} |
100 | virtual bool no_inferior()const{return true;} | 103 | virtual bool no_inferior()const{return true;} |
101 | const QString&Separator()const; | 104 | const QString&Separator()const; |
102 | 105 | ||
103 | protected: | 106 | protected: |
104 | QString nameDisplay, name, separator,prefix; | 107 | QString nameDisplay, name, separator,prefix; |
105 | }; | 108 | }; |
106 | 109 | ||
107 | typedef Opie::Core::OSmartPointer<Folder> FolderP; | 110 | typedef Opie::Core::OSmartPointer<Folder> FolderP; |
108 | 111 | ||
109 | class MHFolder : public Folder | 112 | class MHFolder : public Folder |
110 | { | 113 | { |
111 | public: | 114 | public: |
112 | MHFolder(const QString&disp_name,const QString&mbox); | 115 | MHFolder(const QString&disp_name,const QString&mbox); |
113 | virtual ~MHFolder(); | 116 | virtual ~MHFolder(); |
114 | }; | 117 | }; |
115 | 118 | ||
116 | class IMAPFolder : public Folder | 119 | class IMAPFolder : public Folder |
117 | { | 120 | { |
118 | public: | 121 | public: |
119 | IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" ); | 122 | IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" ); |
120 | virtual ~IMAPFolder(); | 123 | virtual ~IMAPFolder(); |
121 | virtual bool may_select()const{return m_MaySelect;} | 124 | virtual bool may_select()const{return m_MaySelect;} |
122 | virtual bool no_inferior()const{return m_NoInferior;} | 125 | virtual bool no_inferior()const{return m_NoInferior;} |
123 | static QString decodeFolderName( const QString &name ); | 126 | static QString decodeFolderName( const QString &name ); |
124 | private: | 127 | private: |
125 | bool m_MaySelect,m_NoInferior; | 128 | bool m_MaySelect,m_NoInferior; |
126 | }; | 129 | }; |
127 | 130 | ||
128 | #endif | 131 | #endif |
diff --git a/kmicromail/libmailwrapper/storemail.cpp b/kmicromail/libmailwrapper/storemail.cpp index ed1d44a..9d1735f 100644 --- a/kmicromail/libmailwrapper/storemail.cpp +++ b/kmicromail/libmailwrapper/storemail.cpp | |||
@@ -1,90 +1,98 @@ | |||
1 | #include "storemail.h" | 1 | #include "storemail.h" |
2 | #include "mailwrapper.h" | 2 | #include "mailwrapper.h" |
3 | #include "settings.h" | 3 | #include "settings.h" |
4 | #include "abstractmail.h" | 4 | #include "abstractmail.h" |
5 | 5 | ||
6 | #include <libetpan/libetpan.h> | 6 | #include <libetpan/libetpan.h> |
7 | #include <qstring.h> | 7 | #include <qstring.h> |
8 | 8 | ||
9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
10 | #include <kglobal.h> | ||
10 | 11 | ||
11 | using namespace Opie::Core; | 12 | using namespace Opie::Core; |
12 | Storemail::Storemail(Account*aAccount,const QString&aFolder) | 13 | Storemail::Storemail(Account*aAccount,const QString&aFolder) |
13 | : Generatemail() | 14 | : Generatemail() |
14 | { | 15 | { |
15 | wrapper = 0; | 16 | wrapper = 0; |
16 | m_Account = aAccount; | 17 | m_Account = aAccount; |
17 | m_tfolder = aFolder; | 18 | m_tfolder = aFolder; |
18 | wrapper = AbstractMail::getWrapper(m_Account); | 19 | wrapper = AbstractMail::getWrapper(m_Account); |
19 | if (wrapper) { | 20 | if (wrapper) { |
20 | wrapper->createMbox(m_tfolder); | 21 | wrapper->createMbox(m_tfolder); |
21 | } | 22 | } |
22 | } | 23 | } |
23 | 24 | ||
24 | Storemail::Storemail(const QString&dir,const QString&aFolder) | 25 | Storemail::Storemail(const QString&dir,const QString&aFolder) |
25 | : Generatemail() | 26 | : Generatemail() |
26 | { | 27 | { |
27 | wrapper = 0; | 28 | wrapper = 0; |
28 | m_Account = 0; | 29 | m_Account = 0; |
29 | m_tfolder = aFolder; | 30 | m_tfolder = aFolder; |
30 | wrapper = AbstractMail::getWrapper(dir); | 31 | wrapper = AbstractMail::getWrapper(dir); |
31 | if (wrapper) { | 32 | if (wrapper) { |
32 | wrapper->createMbox(m_tfolder); | 33 | wrapper->createMbox(m_tfolder); |
33 | } | 34 | } |
34 | } | 35 | } |
35 | 36 | ||
36 | Storemail::Storemail(const QString&aFolder) | 37 | Storemail::Storemail(const QString&aFolder) |
37 | : Generatemail() | 38 | : Generatemail() |
38 | { | 39 | { |
39 | wrapper = 0; | 40 | wrapper = 0; |
40 | m_Account = 0; | 41 | m_Account = 0; |
41 | m_tfolder = aFolder; | 42 | m_tfolder = aFolder; |
42 | wrapper = AbstractMail::getWrapper(AbstractMail::defaultLocalfolder()); | 43 | wrapper = AbstractMail::getWrapper(AbstractMail::defaultLocalfolder()); |
43 | if (wrapper) { | 44 | if (wrapper) { |
44 | wrapper->createMbox(m_tfolder); | 45 | wrapper->createMbox(m_tfolder); |
45 | } | 46 | } |
46 | } | 47 | } |
47 | 48 | ||
48 | Storemail::~Storemail() | 49 | Storemail::~Storemail() |
49 | { | 50 | { |
50 | } | 51 | } |
51 | 52 | ||
52 | int Storemail::storeMail(const Opie::Core::OSmartPointer<Mail>&mail) | 53 | int Storemail::storeMail(const Opie::Core::OSmartPointer<Mail>&mail) |
53 | { | 54 | { |
54 | if (!wrapper) return 0; | 55 | if (!wrapper) return 0; |
55 | int ret = 1; | 56 | int ret = 1; |
56 | 57 | ||
57 | mailmime * mimeMail = 0; | 58 | mailmime * mimeMail = 0; |
58 | mimeMail = createMimeMail(mail ); | 59 | mimeMail = createMimeMail(mail ); |
59 | if ( mimeMail == NULL ) { | 60 | if ( mimeMail == NULL ) { |
60 | qDebug("storeMail: error creating mime mail "); | 61 | qDebug("storeMail: error creating mime mail "); |
61 | return 0; | 62 | return 0; |
62 | } | 63 | } |
63 | char *data; | 64 | char *data; |
64 | size_t size; | 65 | size_t size; |
65 | data = 0; | 66 | data = 0; |
66 | 67 | ||
67 | mailmessage * msg = 0; | 68 | mailmessage * msg = 0; |
68 | msg = mime_message_init(mimeMail); | 69 | msg = mime_message_init(mimeMail); |
69 | mime_message_set_tmpdir(msg,getenv( "HOME" )); | 70 | QString fileName; |
71 | #ifdef DESKTOP_VERSION | ||
72 | fileName = locateLocal("tmp", ""); | ||
73 | #else | ||
74 | fileName = "/tmp/"; | ||
75 | #endif | ||
76 | //mime_message_set_tmpdir(msg,getenv( "HOME" )); | ||
77 | mime_message_set_tmpdir(msg,(char*)fileName.latin1()); | ||
70 | int r = mailmessage_fetch(msg,&data,&size); | 78 | int r = mailmessage_fetch(msg,&data,&size); |
71 | mime_message_detach_mime(msg); | 79 | mime_message_detach_mime(msg); |
72 | mailmessage_free(msg); | 80 | mailmessage_free(msg); |
73 | msg = 0; | 81 | msg = 0; |
74 | if (r != MAIL_NO_ERROR || !data) { | 82 | if (r != MAIL_NO_ERROR || !data) { |
75 | qDebug("Error fetching mime... "); | 83 | qDebug("Error fetching mime... "); |
76 | ret = 0; | 84 | ret = 0; |
77 | } | 85 | } |
78 | 86 | ||
79 | if (ret) { | 87 | if (ret) { |
80 | wrapper->storeMessage(data,size,m_tfolder); | 88 | wrapper->storeMessage(data,size,m_tfolder); |
81 | } | 89 | } |
82 | 90 | ||
83 | if (data) { | 91 | if (data) { |
84 | free(data); | 92 | free(data); |
85 | } | 93 | } |
86 | if (mimeMail) { | 94 | if (mimeMail) { |
87 | mailmime_free( mimeMail ); | 95 | mailmime_free( mimeMail ); |
88 | } | 96 | } |
89 | return ret; | 97 | return ret; |
90 | } | 98 | } |
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index 18a5600..c20c7ce 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -102,385 +102,385 @@ void OpieMail::message(const QCString &msg, const QByteArray &data) | |||
102 | 102 | ||
103 | //qDebug("END OpieMail::message "); | 103 | //qDebug("END OpieMail::message "); |
104 | } | 104 | } |
105 | void OpieMail::slotExtAppHandler() | 105 | void OpieMail::slotExtAppHandler() |
106 | { | 106 | { |
107 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); | 107 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); |
108 | } | 108 | } |
109 | void OpieMail::slotwriteMail2(const QString& namemail ) | 109 | void OpieMail::slotwriteMail2(const QString& namemail ) |
110 | { | 110 | { |
111 | //qDebug("OpieMail::slotwriteMail2 "); | 111 | //qDebug("OpieMail::slotwriteMail2 "); |
112 | //qApp->processEvents(); | 112 | //qApp->processEvents(); |
113 | ComposeMail compose( settings, this, 0, true ); | 113 | ComposeMail compose( settings, this, 0, true ); |
114 | if ( !namemail.isEmpty() ) { | 114 | if ( !namemail.isEmpty() ) { |
115 | QString to = namemail; | 115 | QString to = namemail; |
116 | if ( namemail.find( " <") > 1 ) { | 116 | if ( namemail.find( " <") > 1 ) { |
117 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; | 117 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; |
118 | } else | 118 | } else |
119 | if ( namemail.find( "<") > 1 ) { | 119 | if ( namemail.find( "<") > 1 ) { |
120 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; | 120 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; |
121 | } | 121 | } |
122 | int sub = to.find( ">:"); | 122 | int sub = to.find( ">:"); |
123 | if ( sub > 0 ) { | 123 | if ( sub > 0 ) { |
124 | compose.setTo( to.left(sub+1) ); | 124 | compose.setTo( to.left(sub+1) ); |
125 | compose.setSubject( to.mid(sub+2) ); | 125 | compose.setSubject( to.mid(sub+2) ); |
126 | } else | 126 | } else |
127 | compose.setTo( to ); | 127 | compose.setTo( to ); |
128 | } | 128 | } |
129 | compose.slotAdjustColumns(); | 129 | compose.slotAdjustColumns(); |
130 | #ifndef DESKTOP_VERSION | 130 | #ifndef DESKTOP_VERSION |
131 | compose.showMaximized(); | 131 | compose.showMaximized(); |
132 | #endif | 132 | #endif |
133 | compose.exec(); | 133 | compose.exec(); |
134 | raise(); | 134 | raise(); |
135 | //qDebug("retttich "); | 135 | //qDebug("retttich "); |
136 | } | 136 | } |
137 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 137 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
138 | { | 138 | { |
139 | // qDebug("OpieMail::slotwriteMail "); | 139 | // qDebug("OpieMail::slotwriteMail "); |
140 | ComposeMail compose( settings, this, 0, true ); | 140 | ComposeMail compose( settings, this, 0, true ); |
141 | if (!email.isEmpty()) | 141 | if (!email.isEmpty()) |
142 | { | 142 | { |
143 | if (!name.isEmpty()) | 143 | if (!name.isEmpty()) |
144 | { | 144 | { |
145 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 145 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
146 | } | 146 | } |
147 | else | 147 | else |
148 | { | 148 | { |
149 | compose.setTo(email); | 149 | compose.setTo(email); |
150 | } | 150 | } |
151 | } | 151 | } |
152 | compose.slotAdjustColumns(); | 152 | compose.slotAdjustColumns(); |
153 | #ifndef DESKTOP_VERSION | 153 | #ifndef DESKTOP_VERSION |
154 | compose.showMaximized(); | 154 | compose.showMaximized(); |
155 | #endif | 155 | #endif |
156 | compose.exec(); | 156 | compose.exec(); |
157 | raise(); | 157 | raise(); |
158 | } | 158 | } |
159 | 159 | ||
160 | void OpieMail::slotComposeMail() | 160 | void OpieMail::slotComposeMail() |
161 | { | 161 | { |
162 | if ( mPendingEmail == QString::null && mPendingName == QString::null) | 162 | if ( mPendingEmail == QString::null && mPendingName == QString::null) |
163 | slotwriteMail2( QString () ); | 163 | slotwriteMail2( QString () ); |
164 | else { | 164 | else { |
165 | if ( mPendingEmail == QString::null ) | 165 | if ( mPendingEmail == QString::null ) |
166 | slotwriteMail2( mPendingName ); | 166 | slotwriteMail2( mPendingName ); |
167 | else | 167 | else |
168 | slotwriteMail( mPendingName, mPendingEmail ); | 168 | slotwriteMail( mPendingName, mPendingEmail ); |
169 | } | 169 | } |
170 | //slotwriteMail(0l,0l); | 170 | //slotwriteMail(0l,0l); |
171 | } | 171 | } |
172 | 172 | ||
173 | void OpieMail::slotSendQueued() | 173 | void OpieMail::slotSendQueued() |
174 | { | 174 | { |
175 | SMTPaccount *smtp = 0; | 175 | SMTPaccount *smtp = 0; |
176 | 176 | ||
177 | QList<Account> list = settings->getAccounts(); | 177 | QList<Account> list = settings->getAccounts(); |
178 | QList<SMTPaccount> smtpList; | 178 | QList<SMTPaccount> smtpList; |
179 | smtpList.setAutoDelete(false); | 179 | smtpList.setAutoDelete(false); |
180 | Account *it; | 180 | Account *it; |
181 | for ( it = list.first(); it; it = list.next() ) | 181 | for ( it = list.first(); it; it = list.next() ) |
182 | { | 182 | { |
183 | if ( it->getType() == MAILLIB::A_SMTP ) | 183 | if ( it->getType() == MAILLIB::A_SMTP ) |
184 | { | 184 | { |
185 | smtp = static_cast<SMTPaccount *>(it); | 185 | smtp = static_cast<SMTPaccount *>(it); |
186 | smtpList.append(smtp); | 186 | smtpList.append(smtp); |
187 | } | 187 | } |
188 | } | 188 | } |
189 | if (smtpList.count()==0) | 189 | if (smtpList.count()==0) |
190 | { | 190 | { |
191 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); | 191 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); |
192 | return; | 192 | return; |
193 | } | 193 | } |
194 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) | 194 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) |
195 | return; | 195 | return; |
196 | if (smtpList.count()==1) | 196 | if (smtpList.count()==1) |
197 | { | 197 | { |
198 | smtp = smtpList.at(0); | 198 | smtp = smtpList.at(0); |
199 | } | 199 | } |
200 | else | 200 | else |
201 | { | 201 | { |
202 | smtp = 0; | 202 | smtp = 0; |
203 | selectsmtp selsmtp; | 203 | selectsmtp selsmtp; |
204 | selsmtp.setSelectionlist(&smtpList); | 204 | selsmtp.setSelectionlist(&smtpList); |
205 | #ifndef DESKTOP_VERSION | 205 | #ifndef DESKTOP_VERSION |
206 | selsmtp.showMaximized(); | 206 | selsmtp.showMaximized(); |
207 | #endif | 207 | #endif |
208 | if ( selsmtp.exec() == QDialog::Accepted ) | 208 | if ( selsmtp.exec() == QDialog::Accepted ) |
209 | { | 209 | { |
210 | smtp = selsmtp.selected_smtp(); | 210 | smtp = selsmtp.selected_smtp(); |
211 | } | 211 | } |
212 | } | 212 | } |
213 | if (smtp) | 213 | if (smtp) |
214 | { | 214 | { |
215 | 215 | ||
216 | Global::statusMessage("Sending mails...!"); | 216 | Global::statusMessage("Sending mails...!"); |
217 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 217 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
218 | if ( wrap->flushOutbox() ) | 218 | if ( wrap->flushOutbox() ) |
219 | { | 219 | { |
220 | Global::statusMessage("Mails sent!"); | 220 | Global::statusMessage("Mails sent!"); |
221 | } | 221 | } |
222 | delete wrap; | 222 | delete wrap; |
223 | } | 223 | } |
224 | // pending refresh list view, if outgoing is displayed | 224 | // pending refresh list view, if outgoing is displayed |
225 | } | 225 | } |
226 | 226 | ||
227 | void OpieMail::slotSearchMails() | 227 | void OpieMail::slotSearchMails() |
228 | { | 228 | { |
229 | qDebug("OpieMail::slotSearchMails():not implemented "); | 229 | qDebug("OpieMail::slotSearchMails():not implemented "); |
230 | } | 230 | } |
231 | 231 | ||
232 | void OpieMail::slotEditSettings() | 232 | void OpieMail::slotEditSettings() |
233 | { | 233 | { |
234 | 234 | ||
235 | KOPrefsDialog settingsDialog( this, "koprefs", true ); | 235 | KOPrefsDialog settingsDialog( this, "koprefs", true ); |
236 | #ifndef DESKTOP_VERSION | 236 | #ifndef DESKTOP_VERSION |
237 | settingsDialog.showMaximized(); | 237 | settingsDialog.showMaximized(); |
238 | #endif | 238 | #endif |
239 | settingsDialog.exec(); | 239 | settingsDialog.exec(); |
240 | 240 | ||
241 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); | 241 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); |
242 | // KApplication::execDialog(settingsDialog); | 242 | // KApplication::execDialog(settingsDialog); |
243 | } | 243 | } |
244 | 244 | ||
245 | void OpieMail::slotEditAccounts() | 245 | void OpieMail::slotEditAccounts() |
246 | { | 246 | { |
247 | EditAccounts eaDialog( settings, this, 0, true ); | 247 | EditAccounts eaDialog( settings, this, 0, true ); |
248 | eaDialog.slotAdjustColumns(); | 248 | eaDialog.slotAdjustColumns(); |
249 | #ifndef DESKTOP_VERSION | 249 | #ifndef DESKTOP_VERSION |
250 | eaDialog.showMaximized(); | 250 | eaDialog.showMaximized(); |
251 | #endif | 251 | #endif |
252 | eaDialog.exec(); | 252 | eaDialog.exec(); |
253 | if ( settings ) delete settings; | 253 | if ( settings ) delete settings; |
254 | settings = new Settings(); | 254 | settings = new Settings(); |
255 | 255 | ||
256 | folderView->populate( settings->getAccounts() ); | 256 | folderView->populate( settings->getAccounts() ); |
257 | } | 257 | } |
258 | void OpieMail::replyMail() | 258 | void OpieMail::replyMail() |
259 | { | 259 | { |
260 | 260 | ||
261 | QListViewItem*item = mailView->currentItem(); | 261 | QListViewItem*item = mailView->currentItem(); |
262 | if (!item) return; | 262 | if (!item) return; |
263 | RecMailP mail = ((MailListViewItem*)item)->data(); | 263 | RecMailP mail = ((MailListViewItem*)item)->data(); |
264 | RecBodyP body = folderView->fetchBody(mail); | 264 | RecBodyP body = folderView->fetchBody(mail); |
265 | 265 | ||
266 | QString rtext; | 266 | QString rtext; |
267 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 267 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
268 | .arg( mail->getFrom()) | 268 | .arg( mail->getFrom()) |
269 | .arg( mail->getDate()); | 269 | .arg( mail->getDate()); |
270 | 270 | ||
271 | QString text = body->Bodytext(); | 271 | QString text = body->Bodytext(); |
272 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 272 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
273 | QStringList::Iterator it; | 273 | QStringList::Iterator it; |
274 | for (it = lines.begin(); it != lines.end(); it++) | 274 | for (it = lines.begin(); it != lines.end(); it++) |
275 | { | 275 | { |
276 | rtext += "> " + *it + "\n"; | 276 | rtext += "> " + *it + "\n"; |
277 | } | 277 | } |
278 | rtext += "\n"; | 278 | rtext += "\n"; |
279 | 279 | ||
280 | QString prefix; | 280 | QString prefix; |
281 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 281 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
282 | else prefix = "Re: "; // no i18n on purpose | 282 | else prefix = "Re: "; // no i18n on purpose |
283 | 283 | ||
284 | Settings *settings = new Settings(); | 284 | Settings *settings = new Settings(); |
285 | ComposeMail composer( settings ,this, 0, true); | 285 | ComposeMail composer( settings ,this, 0, true); |
286 | if (mail->Replyto().isEmpty()) { | 286 | if (mail->Replyto().isEmpty()) { |
287 | composer.setTo( mail->getFrom()); | 287 | composer.setTo( mail->getFrom()); |
288 | } else { | 288 | } else { |
289 | composer.setTo( mail->Replyto()); | 289 | composer.setTo( mail->Replyto()); |
290 | } | 290 | } |
291 | composer.setSubject( prefix + mail->getSubject()); | 291 | composer.setSubject( prefix + mail->getSubject()); |
292 | composer.setMessage( rtext ); | 292 | composer.setMessage( rtext ); |
293 | composer.setInReplyTo( mail->Msgid()); | 293 | composer.setInReplyTo( mail->Msgid()); |
294 | 294 | composer.setCharset( body->getCharset() ); | |
295 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 295 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
296 | { | 296 | { |
297 | mail->Wrapper()->answeredMail(mail); | 297 | mail->Wrapper()->answeredMail(mail); |
298 | } | 298 | } |
299 | delete settings; | 299 | delete settings; |
300 | 300 | ||
301 | } | 301 | } |
302 | void OpieMail::displayMail() | 302 | void OpieMail::displayMail() |
303 | { | 303 | { |
304 | QListViewItem*item = mailView->currentItem(); | 304 | QListViewItem*item = mailView->currentItem(); |
305 | if (!item) return; | 305 | if (!item) return; |
306 | RecMailP mail = ((MailListViewItem*)item)->data(); | 306 | RecMailP mail = ((MailListViewItem*)item)->data(); |
307 | RecBodyP body = folderView->fetchBody(mail); | 307 | RecBodyP body = folderView->fetchBody(mail); |
308 | ViewMail readMail( this,"", Qt::WType_Modal ); | 308 | ViewMail readMail( this,"", Qt::WType_Modal ); |
309 | readMail.setBody( body ); | 309 | readMail.setBody( body ); |
310 | readMail.setMail( mail ); | 310 | readMail.setMail( mail ); |
311 | #ifndef DESKTOP_VERSION | 311 | #ifndef DESKTOP_VERSION |
312 | readMail.showMaximized(); | 312 | readMail.showMaximized(); |
313 | #else | 313 | #else |
314 | readMail.resize( 640, 480); | 314 | readMail.resize( 640, 480); |
315 | #endif | 315 | #endif |
316 | readMail.exec(); | 316 | readMail.exec(); |
317 | 317 | ||
318 | if ( readMail.deleted ) | 318 | if ( readMail.deleted ) |
319 | { | 319 | { |
320 | folderView->refreshCurrent(); | 320 | folderView->refreshCurrent(); |
321 | } | 321 | } |
322 | else | 322 | else |
323 | { | 323 | { |
324 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 324 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
325 | } | 325 | } |
326 | } | 326 | } |
327 | void OpieMail::slotGetAllMail() | 327 | void OpieMail::slotGetAllMail() |
328 | { | 328 | { |
329 | QListViewItem * item = folderView->firstChild(); | 329 | QListViewItem * item = folderView->firstChild(); |
330 | while ( item ){ | 330 | while ( item ){ |
331 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 331 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
332 | item = item->nextSibling (); | 332 | item = item->nextSibling (); |
333 | } | 333 | } |
334 | } | 334 | } |
335 | void OpieMail::slotGetMail() | 335 | void OpieMail::slotGetMail() |
336 | { | 336 | { |
337 | QListViewItem * item = folderView->currentItem(); | 337 | QListViewItem * item = folderView->currentItem(); |
338 | if ( ! item ) return; | 338 | if ( ! item ) return; |
339 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 339 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
340 | } | 340 | } |
341 | void OpieMail::slotDeleteMail() | 341 | void OpieMail::slotDeleteMail() |
342 | { | 342 | { |
343 | if (!mailView->currentItem()) return; | 343 | if (!mailView->currentItem()) return; |
344 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 344 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
345 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 345 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
346 | { | 346 | { |
347 | mail->Wrapper()->deleteMail( mail ); | 347 | mail->Wrapper()->deleteMail( mail ); |
348 | folderView->refreshCurrent(); | 348 | folderView->refreshCurrent(); |
349 | } | 349 | } |
350 | } | 350 | } |
351 | void OpieMail::slotDeleteAllMail() | 351 | void OpieMail::slotDeleteAllMail() |
352 | { | 352 | { |
353 | 353 | ||
354 | QValueList<RecMailP> t; | 354 | QValueList<RecMailP> t; |
355 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 355 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
356 | { | 356 | { |
357 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 357 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
358 | while ( item ) { | 358 | while ( item ) { |
359 | if ( item->isSelected() ) { | 359 | if ( item->isSelected() ) { |
360 | t.append( item->data() ); | 360 | t.append( item->data() ); |
361 | } | 361 | } |
362 | item = (MailListViewItem*)item->nextSibling(); | 362 | item = (MailListViewItem*)item->nextSibling(); |
363 | } | 363 | } |
364 | } | 364 | } |
365 | else | 365 | else |
366 | return; | 366 | return; |
367 | if ( t.count() == 0 ) | 367 | if ( t.count() == 0 ) |
368 | return; | 368 | return; |
369 | RecMailP mail = t.first(); | 369 | RecMailP mail = t.first(); |
370 | mail->Wrapper()->deleteMailList(t); | 370 | mail->Wrapper()->deleteMailList(t); |
371 | folderView->refreshCurrent(); | 371 | folderView->refreshCurrent(); |
372 | 372 | ||
373 | 373 | ||
374 | } | 374 | } |
375 | void OpieMail::clearSelection() | 375 | void OpieMail::clearSelection() |
376 | { | 376 | { |
377 | mailView->clearSelection(); | 377 | mailView->clearSelection(); |
378 | 378 | ||
379 | } | 379 | } |
380 | 380 | ||
381 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | 381 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) |
382 | { | 382 | { |
383 | if (!mailView->currentItem()) return; | 383 | if (!mailView->currentItem()) return; |
384 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); | 384 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); |
385 | /* just the RIGHT button - or hold on pda */ | 385 | /* just the RIGHT button - or hold on pda */ |
386 | if (button!=2) {return;} | 386 | if (button!=2) {return;} |
387 | if (!item) return; | 387 | if (!item) return; |
388 | QPopupMenu *m = new QPopupMenu(0); | 388 | QPopupMenu *m = new QPopupMenu(0); |
389 | if (m) | 389 | if (m) |
390 | { | 390 | { |
391 | if (mailtype==MAILLIB::A_NNTP) { | 391 | if (mailtype==MAILLIB::A_NNTP) { |
392 | m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); | 392 | m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); |
393 | m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); | 393 | m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); |
394 | m->insertSeparator(); | 394 | m->insertSeparator(); |
395 | m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); | 395 | m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); |
396 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); | 396 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); |
397 | } else { | 397 | } else { |
398 | if (folderView->currentisDraft()) { | 398 | if (folderView->currentisDraft()) { |
399 | m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); | 399 | m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); |
400 | } | 400 | } |
401 | m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); | 401 | m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); |
402 | m->insertSeparator(); | 402 | m->insertSeparator(); |
403 | m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); | 403 | m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); |
404 | m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); | 404 | m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); |
405 | m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); | 405 | m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); |
406 | m->insertSeparator(); | 406 | m->insertSeparator(); |
407 | m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); | 407 | m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); |
408 | m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); | 408 | m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); |
409 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); | 409 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); |
410 | } | 410 | } |
411 | m->setFocus(); | 411 | m->setFocus(); |
412 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 412 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
413 | delete m; | 413 | delete m; |
414 | } | 414 | } |
415 | } | 415 | } |
416 | 416 | ||
417 | void OpieMail::slotShowFolders( bool show ) | 417 | void OpieMail::slotShowFolders( bool show ) |
418 | { | 418 | { |
419 | if ( show && folderView->isHidden() ) | 419 | if ( show && folderView->isHidden() ) |
420 | { | 420 | { |
421 | folderView->show(); | 421 | folderView->show(); |
422 | } | 422 | } |
423 | else if ( !show && !folderView->isHidden() ) | 423 | else if ( !show && !folderView->isHidden() ) |
424 | { | 424 | { |
425 | folderView->hide(); | 425 | folderView->hide(); |
426 | } | 426 | } |
427 | } | 427 | } |
428 | 428 | ||
429 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) | 429 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) |
430 | { | 430 | { |
431 | MailListViewItem*item = 0; | 431 | MailListViewItem*item = 0; |
432 | mailView->clear(); | 432 | mailView->clear(); |
433 | 433 | ||
434 | QValueList<RecMailP>::ConstIterator it; | 434 | QValueList<RecMailP>::ConstIterator it; |
435 | for (it = list.begin(); it != list.end();++it) | 435 | for (it = list.begin(); it != list.end();++it) |
436 | { | 436 | { |
437 | item = new MailListViewItem(mailView,item); | 437 | item = new MailListViewItem(mailView,item); |
438 | item->storeData((*it)); | 438 | item->storeData((*it)); |
439 | item->showEntry(); | 439 | item->showEntry(); |
440 | } | 440 | } |
441 | mailView->setSorting ( 4, false ); | 441 | mailView->setSorting ( 4, false ); |
442 | } | 442 | } |
443 | 443 | ||
444 | void OpieMail::mailLeftClicked( QListViewItem *item ) | 444 | void OpieMail::mailLeftClicked( QListViewItem *item ) |
445 | { | 445 | { |
446 | mailView->clearSelection(); | 446 | mailView->clearSelection(); |
447 | /* just LEFT button - or tap with stylus on pda */ | 447 | /* just LEFT button - or tap with stylus on pda */ |
448 | //if (button!=1) return; | 448 | //if (button!=1) return; |
449 | if (!item) return; | 449 | if (!item) return; |
450 | if (folderView->currentisDraft()) { | 450 | if (folderView->currentisDraft()) { |
451 | reEditMail(); | 451 | reEditMail(); |
452 | } else { | 452 | } else { |
453 | displayMail(); | 453 | displayMail(); |
454 | } | 454 | } |
455 | } | 455 | } |
456 | 456 | ||
457 | void OpieMail::slotMoveCopyMail() | 457 | void OpieMail::slotMoveCopyMail() |
458 | { | 458 | { |
459 | if (!mailView->currentItem()) return; | 459 | if (!mailView->currentItem()) return; |
460 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 460 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
461 | AbstractMail*targetMail = 0; | 461 | AbstractMail*targetMail = 0; |
462 | QString targetFolder = ""; | 462 | QString targetFolder = ""; |
463 | Selectstore sels; | 463 | Selectstore sels; |
464 | folderView->setupFolderselect(&sels); | 464 | folderView->setupFolderselect(&sels); |
465 | if (!sels.exec()) return; | 465 | if (!sels.exec()) return; |
466 | targetMail = sels.currentMail(); | 466 | targetMail = sels.currentMail(); |
467 | targetFolder = sels.currentFolder(); | 467 | targetFolder = sels.currentFolder(); |
468 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || | 468 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || |
469 | targetFolder.isEmpty()) | 469 | targetFolder.isEmpty()) |
470 | { | 470 | { |
471 | return; | 471 | return; |
472 | } | 472 | } |
473 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 473 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
474 | { | 474 | { |
475 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 475 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
476 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); | 476 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); |
477 | return; | 477 | return; |
478 | } | 478 | } |
479 | sels.hide(); | 479 | sels.hide(); |
480 | qApp->processEvents(); | 480 | qApp->processEvents(); |
481 | // qDebug("hiding sels "); | 481 | // qDebug("hiding sels "); |
482 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); | 482 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); |
483 | folderView->refreshCurrent(); | 483 | folderView->refreshCurrent(); |
484 | } | 484 | } |
485 | 485 | ||
486 | void OpieMail::slotMoveCopyAllMail() | 486 | void OpieMail::slotMoveCopyAllMail() |
diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp index 4883231..3bd6f41 100644 --- a/kmicromail/viewmail.cpp +++ b/kmicromail/viewmail.cpp | |||
@@ -268,264 +268,265 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int | |||
268 | if (content) { | 268 | if (content) { |
269 | QFile output(tmpfile); | 269 | QFile output(tmpfile); |
270 | output.open(IO_WriteOnly); | 270 | output.open(IO_WriteOnly); |
271 | output.writeBlock(content->Content(),content->Length()); | 271 | output.writeBlock(content->Content(),content->Length()); |
272 | output.close(); | 272 | output.close(); |
273 | delete content; | 273 | delete content; |
274 | MailImageDlg iview(""); | 274 | MailImageDlg iview(""); |
275 | iview.setName(tmpfile); | 275 | iview.setName(tmpfile); |
276 | KApplication::execDialog(&iview); | 276 | KApplication::execDialog(&iview); |
277 | output.remove(); | 277 | output.remove(); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | break; | 280 | break; |
281 | case 1: | 281 | case 1: |
282 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 282 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
283 | { | 283 | { |
284 | setText(); | 284 | setText(); |
285 | } | 285 | } |
286 | else | 286 | else |
287 | { | 287 | { |
288 | if ( m_recMail->Wrapper() != 0l ) | 288 | if ( m_recMail->Wrapper() != 0l ) |
289 | { // make sure that there is a wrapper , even after delete or simular actions | 289 | { // make sure that there is a wrapper , even after delete or simular actions |
290 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 290 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
291 | } | 291 | } |
292 | } | 292 | } |
293 | break; | 293 | break; |
294 | } | 294 | } |
295 | delete menu; | 295 | delete menu; |
296 | } | 296 | } |
297 | 297 | ||
298 | 298 | ||
299 | void ViewMail::setMail(const RecMailP&mail ) | 299 | void ViewMail::setMail(const RecMailP&mail ) |
300 | { | 300 | { |
301 | 301 | ||
302 | m_recMail = mail; | 302 | m_recMail = mail; |
303 | 303 | ||
304 | m_mail[0] = mail->getFrom(); | 304 | m_mail[0] = mail->getFrom(); |
305 | m_mail[1] = mail->getSubject(); | 305 | m_mail[1] = mail->getSubject(); |
306 | m_mail[3] = mail->getDate(); | 306 | m_mail[3] = mail->getDate(); |
307 | m_mail[4] = mail->Msgid(); | 307 | m_mail[4] = mail->Msgid(); |
308 | 308 | ||
309 | m_mail2[0] = mail->To(); | 309 | m_mail2[0] = mail->To(); |
310 | m_mail2[1] = mail->CC(); | 310 | m_mail2[1] = mail->CC(); |
311 | m_mail2[2] = mail->Bcc(); | 311 | m_mail2[2] = mail->Bcc(); |
312 | 312 | ||
313 | setText(); | 313 | setText(); |
314 | } | 314 | } |
315 | 315 | ||
316 | 316 | ||
317 | 317 | ||
318 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 318 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
319 | : ViewMailBase(parent, name, fl), _inLoop(false) | 319 | : ViewMailBase(parent, name, fl), _inLoop(false) |
320 | { | 320 | { |
321 | m_gotBody = false; | 321 | m_gotBody = false; |
322 | deleted = false; | 322 | deleted = false; |
323 | 323 | ||
324 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); | 324 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); |
325 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); | 325 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); |
326 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); | 326 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); |
327 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); | 327 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); |
328 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); | 328 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); |
329 | 329 | ||
330 | attachments->setEnabled(m_gotBody); | 330 | attachments->setEnabled(m_gotBody); |
331 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); | 331 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); |
332 | 332 | ||
333 | readConfig(); | 333 | readConfig(); |
334 | attachments->setSorting(-1); | 334 | attachments->setSorting(-1); |
335 | } | 335 | } |
336 | 336 | ||
337 | void ViewMail::readConfig() | 337 | void ViewMail::readConfig() |
338 | { | 338 | { |
339 | 339 | ||
340 | setFont ( KOPrefs::instance()->mReadFont ); | 340 | setFont ( KOPrefs::instance()->mReadFont ); |
341 | m_showHtml = KOPrefs::instance()->mViewAsHtml; | 341 | m_showHtml = KOPrefs::instance()->mViewAsHtml; |
342 | showHtml->setOn( m_showHtml ); | 342 | showHtml->setOn( m_showHtml ); |
343 | } | 343 | } |
344 | 344 | ||
345 | void ViewMail::setText() | 345 | void ViewMail::setText() |
346 | { | 346 | { |
347 | 347 | ||
348 | QString toString; | 348 | QString toString; |
349 | QString ccString; | 349 | QString ccString; |
350 | QString bccString; | 350 | QString bccString; |
351 | 351 | ||
352 | 352 | ||
353 | toString = m_mail2[0].join(","); | 353 | toString = m_mail2[0].join(","); |
354 | ccString = m_mail2[1].join(","); | 354 | ccString = m_mail2[1].join(","); |
355 | bccString = m_mail2[2].join(","); | 355 | bccString = m_mail2[2].join(","); |
356 | 356 | ||
357 | 357 | ||
358 | setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) ); | 358 | setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) ); |
359 | 359 | ||
360 | m_mailHtml = "<html><body>" | 360 | m_mailHtml = "<html><body>" |
361 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" | 361 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
362 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" | 362 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" |
363 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" | 363 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
364 | "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 364 | "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
365 | "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 365 | "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
366 | i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 366 | i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
367 | "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] + | 367 | "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] + |
368 | "</td></tr></table><font>"; | 368 | "</td></tr></table><font>"; |
369 | 369 | ||
370 | if ( !m_showHtml ) | 370 | if ( !m_showHtml ) |
371 | { | 371 | { |
372 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); | 372 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); |
373 | } | 373 | } |
374 | else | 374 | else |
375 | { | 375 | { |
376 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); | 376 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); |
377 | } | 377 | } |
378 | // remove later in favor of a real handling | 378 | // remove later in favor of a real handling |
379 | m_gotBody = true; | 379 | m_gotBody = true; |
380 | } | 380 | } |
381 | 381 | ||
382 | 382 | ||
383 | ViewMail::~ViewMail() | 383 | ViewMail::~ViewMail() |
384 | { | 384 | { |
385 | m_recMail->Wrapper()->cleanMimeCache(); | 385 | m_recMail->Wrapper()->cleanMimeCache(); |
386 | hide(); | 386 | hide(); |
387 | } | 387 | } |
388 | 388 | ||
389 | void ViewMail::hide() | 389 | void ViewMail::hide() |
390 | { | 390 | { |
391 | QWidget::hide(); | 391 | QWidget::hide(); |
392 | 392 | ||
393 | if (_inLoop) | 393 | if (_inLoop) |
394 | { | 394 | { |
395 | _inLoop = false; | 395 | _inLoop = false; |
396 | qApp->exit_loop(); | 396 | qApp->exit_loop(); |
397 | 397 | ||
398 | } | 398 | } |
399 | 399 | ||
400 | } | 400 | } |
401 | 401 | ||
402 | void ViewMail::exec() | 402 | void ViewMail::exec() |
403 | { | 403 | { |
404 | show(); | 404 | show(); |
405 | 405 | ||
406 | if (!_inLoop) | 406 | if (!_inLoop) |
407 | { | 407 | { |
408 | _inLoop = true; | 408 | _inLoop = true; |
409 | qApp->enter_loop(); | 409 | qApp->enter_loop(); |
410 | } | 410 | } |
411 | 411 | ||
412 | } | 412 | } |
413 | 413 | ||
414 | QString ViewMail::deHtml(const QString &string) | 414 | QString ViewMail::deHtml(const QString &string) |
415 | { | 415 | { |
416 | QString string_ = string; | 416 | QString string_ = string; |
417 | string_.replace(QRegExp("&"), "&"); | 417 | string_.replace(QRegExp("&"), "&"); |
418 | string_.replace(QRegExp("<"), "<"); | 418 | string_.replace(QRegExp("<"), "<"); |
419 | string_.replace(QRegExp(">"), ">"); | 419 | string_.replace(QRegExp(">"), ">"); |
420 | string_.replace(QRegExp("\\n"), "<br>"); | 420 | string_.replace(QRegExp("\\n"), "<br>"); |
421 | return string_; | 421 | return string_; |
422 | } | 422 | } |
423 | 423 | ||
424 | void ViewMail::slotReply() | 424 | void ViewMail::slotReply() |
425 | { | 425 | { |
426 | if (!m_gotBody) | 426 | if (!m_gotBody) |
427 | { | 427 | { |
428 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot reply yet."), i18n("Ok")); | 428 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot reply yet."), i18n("Ok")); |
429 | return; | 429 | return; |
430 | } | 430 | } |
431 | 431 | ||
432 | QString rtext; | 432 | QString rtext; |
433 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 433 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
434 | .arg( m_mail[0] ) | 434 | .arg( m_mail[0] ) |
435 | .arg( m_mail[3] ); | 435 | .arg( m_mail[3] ); |
436 | 436 | ||
437 | QString text = m_mail[2]; | 437 | QString text = m_mail[2]; |
438 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 438 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
439 | QStringList::Iterator it; | 439 | QStringList::Iterator it; |
440 | for (it = lines.begin(); it != lines.end(); it++) | 440 | for (it = lines.begin(); it != lines.end(); it++) |
441 | { | 441 | { |
442 | rtext += "> " + *it + "\n"; | 442 | rtext += "> " + *it + "\n"; |
443 | } | 443 | } |
444 | rtext += "\n"; | 444 | rtext += "\n"; |
445 | 445 | ||
446 | QString prefix; | 446 | QString prefix; |
447 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 447 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
448 | else prefix = "Re: "; // no i18n on purpose | 448 | else prefix = "Re: "; // no i18n on purpose |
449 | 449 | ||
450 | Settings *settings = new Settings(); | 450 | Settings *settings = new Settings(); |
451 | ComposeMail composer( settings ,this, 0, true); | 451 | ComposeMail composer( settings ,this, 0, true); |
452 | if (m_recMail->Replyto().isEmpty()) { | 452 | if (m_recMail->Replyto().isEmpty()) { |
453 | composer.setTo(m_recMail->getFrom()); | 453 | composer.setTo(m_recMail->getFrom()); |
454 | } else { | 454 | } else { |
455 | composer.setTo(m_recMail->Replyto()); | 455 | composer.setTo(m_recMail->Replyto()); |
456 | } | 456 | } |
457 | composer.setSubject( prefix + m_mail[1] ); | 457 | composer.setSubject( prefix + m_mail[1] ); |
458 | composer.setMessage( rtext ); | 458 | composer.setMessage( rtext ); |
459 | composer.setInReplyTo(m_recMail->Msgid()); | 459 | composer.setInReplyTo(m_recMail->Msgid()); |
460 | composer.setCharset( m_body->getCharset() ); | ||
460 | 461 | ||
461 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 462 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
462 | { | 463 | { |
463 | m_recMail->Wrapper()->answeredMail(m_recMail); | 464 | m_recMail->Wrapper()->answeredMail(m_recMail); |
464 | } | 465 | } |
465 | delete settings; | 466 | delete settings; |
466 | } | 467 | } |
467 | 468 | ||
468 | void ViewMail::slotForward() | 469 | void ViewMail::slotForward() |
469 | { | 470 | { |
470 | if (!m_gotBody) | 471 | if (!m_gotBody) |
471 | { | 472 | { |
472 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot forward yet."), i18n("Ok")); | 473 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot forward yet."), i18n("Ok")); |
473 | return; | 474 | return; |
474 | } | 475 | } |
475 | 476 | ||
476 | QString ftext; | 477 | QString ftext; |
477 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 478 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
478 | .arg( m_mail[0] ); | 479 | .arg( m_mail[0] ); |
479 | if (!m_mail[3].isNull()) | 480 | if (!m_mail[3].isNull()) |
480 | ftext += QString("Date: %1\n") | 481 | ftext += QString("Date: %1\n") |
481 | .arg( m_mail[3] ); | 482 | .arg( m_mail[3] ); |
482 | if (!m_mail[0].isNull()) | 483 | if (!m_mail[0].isNull()) |
483 | ftext += QString("From: %1\n") | 484 | ftext += QString("From: %1\n") |
484 | .arg( m_mail[0] ); | 485 | .arg( m_mail[0] ); |
485 | if (!m_mail[1].isNull()) | 486 | if (!m_mail[1].isNull()) |
486 | ftext += QString("Subject: %1\n") | 487 | ftext += QString("Subject: %1\n") |
487 | .arg( m_mail[1] ); | 488 | .arg( m_mail[1] ); |
488 | 489 | ||
489 | ftext += QString("\n%1\n") | 490 | ftext += QString("\n%1\n") |
490 | .arg( m_mail[2]); | 491 | .arg( m_mail[2]); |
491 | 492 | ||
492 | ftext += QString("----- End forwarded message -----\n"); | 493 | ftext += QString("----- End forwarded message -----\n"); |
493 | 494 | ||
494 | Settings *settings = new Settings(); | 495 | Settings *settings = new Settings(); |
495 | ComposeMail composer( settings ,this, 0, true); | 496 | ComposeMail composer( settings ,this, 0, true); |
496 | composer.setSubject( "Fwd: " + m_mail[1] ); | 497 | composer.setSubject( "Fwd: " + m_mail[1] ); |
497 | composer.setMessage( ftext ); | 498 | composer.setMessage( ftext ); |
498 | if ( QDialog::Accepted == KApplication::execDialog( &composer )) | 499 | if ( QDialog::Accepted == KApplication::execDialog( &composer )) |
499 | { | 500 | { |
500 | } | 501 | } |
501 | } | 502 | } |
502 | 503 | ||
503 | void ViewMail::slotDeleteMail( ) | 504 | void ViewMail::slotDeleteMail( ) |
504 | { | 505 | { |
505 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 506 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
506 | { | 507 | { |
507 | m_recMail->Wrapper()->deleteMail( m_recMail ); | 508 | m_recMail->Wrapper()->deleteMail( m_recMail ); |
508 | hide(); | 509 | hide(); |
509 | deleted = true; | 510 | deleted = true; |
510 | } | 511 | } |
511 | } | 512 | } |
512 | 513 | ||
513 | MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) | 514 | MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) |
514 | : QDialog(parent,name,modal) | 515 | : QDialog(parent,name,modal) |
515 | { | 516 | { |
516 | QVBoxLayout*dlglayout = new QVBoxLayout(this); | 517 | QVBoxLayout*dlglayout = new QVBoxLayout(this); |
517 | dlglayout->setSpacing(2); | 518 | dlglayout->setSpacing(2); |
518 | dlglayout->setMargin(1); | 519 | dlglayout->setMargin(1); |
519 | //m_imageview = new Opie::MM::OImageScrollView(this); | 520 | //m_imageview = new Opie::MM::OImageScrollView(this); |
520 | //dlglayout->addWidget(m_imageview); | 521 | //dlglayout->addWidget(m_imageview); |
521 | } | 522 | } |
522 | 523 | ||
523 | MailImageDlg::~MailImageDlg() | 524 | MailImageDlg::~MailImageDlg() |
524 | { | 525 | { |
525 | } | 526 | } |
526 | 527 | ||
527 | void MailImageDlg::setName(const QString&fname) | 528 | void MailImageDlg::setName(const QString&fname) |
528 | { | 529 | { |
529 | qDebug("viewmail.cpp: MailImageDlg::setName Pending"); | 530 | qDebug("viewmail.cpp: MailImageDlg::setName Pending"); |
530 | // m_imageview->setImage(fname); | 531 | // m_imageview->setImage(fname); |
531 | } | 532 | } |