author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kmicromail/libmailwrapper | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-p1.zip kdepimpi-p1.tar.gz kdepimpi-p1.tar.bz2 |
initial public commit of qt4 portp1
25 files changed, 159 insertions, 115 deletions
diff --git a/kmicromail/libmailwrapper/abstractmail.cpp b/kmicromail/libmailwrapper/abstractmail.cpp index 870985e..746d2ae 100644 --- a/kmicromail/libmailwrapper/abstractmail.cpp +++ b/kmicromail/libmailwrapper/abstractmail.cpp | |||
@@ -1,41 +1,43 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "abstractmail.h" | 2 | #include "abstractmail.h" |
3 | #include "imapwrapper.h" | 3 | #include "imapwrapper.h" |
4 | #include "pop3wrapper.h" | 4 | #include "pop3wrapper.h" |
5 | #include "nntpwrapper.h" | 5 | #include "nntpwrapper.h" |
6 | #include "mhwrapper.h" | 6 | #include "mhwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include <qpe/global.h> | 8 | #include <qpe/global.h> |
9 | 9 | ||
10 | 10 | ||
11 | #include <qprogressbar.h> | 11 | #include <q3progressbar.h> |
12 | #include <qapplication.h> | 12 | #include <qapplication.h> |
13 | #include <qmessagebox.h> | 13 | #include <qmessagebox.h> |
14 | //Added by qt3to4: | ||
15 | #include <Q3ValueList> | ||
14 | #include <klocale.h> | 16 | #include <klocale.h> |
15 | #include <kdecore/kstandarddirs.h> | 17 | #include <kdecore/kstandarddirs.h> |
16 | #include <qfile.h> | 18 | #include <qfile.h> |
17 | #include <qtextstream.h> | 19 | #include <q3textstream.h> |
18 | #include <stdlib.h> | 20 | #include <stdlib.h> |
19 | #include <libetpan/mailmime_content.h> | 21 | #include <libetpan/mailmime_content.h> |
20 | #include <libetpan/mailmime.h> | 22 | #include <libetpan/mailmime.h> |
21 | 23 | ||
22 | using namespace Opie::Core; | 24 | using namespace Opie::Core; |
23 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) | 25 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) |
24 | { | 26 | { |
25 | return new IMAPwrapper(a); | 27 | return new IMAPwrapper(a); |
26 | } | 28 | } |
27 | 29 | ||
28 | AbstractMail* AbstractMail::getWrapper(POP3account *a) | 30 | AbstractMail* AbstractMail::getWrapper(POP3account *a) |
29 | { | 31 | { |
30 | return new POP3wrapper(a); | 32 | return new POP3wrapper(a); |
31 | } | 33 | } |
32 | 34 | ||
33 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) | 35 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) |
34 | { | 36 | { |
35 | return new NNTPwrapper(a); | 37 | return new NNTPwrapper(a); |
36 | } | 38 | } |
37 | 39 | ||
38 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) | 40 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) |
39 | { | 41 | { |
40 | return new MHwrapper(a,name); | 42 | return new MHwrapper(a,name); |
41 | } | 43 | } |
@@ -90,184 +92,184 @@ encodedString* AbstractMail::decode_String(const encodedString*text,const QStrin | |||
90 | QString AbstractMail::convert_String(const char*text) | 92 | QString AbstractMail::convert_String(const char*text) |
91 | { | 93 | { |
92 | size_t index = 0; | 94 | size_t index = 0; |
93 | char*res = 0; | 95 | char*res = 0; |
94 | int err = MAILIMF_NO_ERROR; | 96 | int err = MAILIMF_NO_ERROR; |
95 | 97 | ||
96 | QString result(text); | 98 | QString result(text); |
97 | //qDebug("convert_String %s ", text); | 99 | //qDebug("convert_String %s ", text); |
98 | //err = mailmime_encoded_phrase_parse("iso-8859-1", | 100 | //err = mailmime_encoded_phrase_parse("iso-8859-1", |
99 | // text, strlen(text),&index, "iso-8859-1",&res); | 101 | // text, strlen(text),&index, "iso-8859-1",&res); |
100 | err = mailmime_encoded_phrase_parse("iso-8859-1", | 102 | err = mailmime_encoded_phrase_parse("iso-8859-1", |
101 | text, strlen(text),&index, "utf-8",&res); | 103 | text, strlen(text),&index, "utf-8",&res); |
102 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { | 104 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { |
103 | result = QString::fromUtf8(res); | 105 | result = QString::fromUtf8(res); |
104 | } | 106 | } |
105 | //qDebug("convert_String:%s ",result.latin1() ); | 107 | //qDebug("convert_String:%s ",result.latin1() ); |
106 | if (res) free(res); | 108 | if (res) free(res); |
107 | return result; | 109 | return result; |
108 | } | 110 | } |
109 | 111 | ||
110 | /* cp & paste from launcher */ | 112 | /* cp & paste from launcher */ |
111 | QString AbstractMail::gen_attachment_id() | 113 | QString AbstractMail::gen_attachment_id() |
112 | { | 114 | { |
113 | QFile file( "/proc/sys/kernel/random/uuid" ); | 115 | QFile file( "/proc/sys/kernel/random/uuid" ); |
114 | if (!file.open(IO_ReadOnly ) ) | 116 | if (!file.open(QIODevice::ReadOnly ) ) |
115 | return QString::null; | 117 | return QString::null; |
116 | 118 | ||
117 | QTextStream stream(&file); | 119 | Q3TextStream stream(&file); |
118 | 120 | ||
119 | return "{" + stream.read().stripWhiteSpace() + "}"; | 121 | return "{" + stream.read().stripWhiteSpace() + "}"; |
120 | } | 122 | } |
121 | 123 | ||
122 | int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) | 124 | int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) |
123 | { | 125 | { |
124 | return 0; | 126 | return 0; |
125 | } | 127 | } |
126 | 128 | ||
127 | QString AbstractMail::defaultLocalfolder() | 129 | QString AbstractMail::defaultLocalfolder() |
128 | { | 130 | { |
129 | // QString f = getenv( "HOME" ); | 131 | // QString f = getenv( "HOME" ); |
130 | QString f = locateLocal( "data", "kopiemail/localmail"); | 132 | QString f = locateLocal( "data", "kopiemail/localmail"); |
131 | // f += "/Applications/opiemail/localmail"; | 133 | // f += "/Applications/opiemail/localmail"; |
132 | return f; | 134 | return f; |
133 | } | 135 | } |
134 | 136 | ||
135 | QString AbstractMail::draftFolder() | 137 | QString AbstractMail::draftFolder() |
136 | { | 138 | { |
137 | return QString("Drafts"); | 139 | return QString("Drafts"); |
138 | } | 140 | } |
139 | 141 | ||
140 | /* temporary - will be removed when implemented in all classes */ | 142 | /* temporary - will be removed when implemented in all classes */ |
141 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) | 143 | void AbstractMail::deleteMails(const QString &,const Q3ValueList<Opie::Core::OSmartPointer<RecMail> > &) |
142 | { | 144 | { |
143 | } | 145 | } |
144 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) | 146 | void AbstractMail::deleteMailList(const Q3ValueList<RecMailP>&target) |
145 | { | 147 | { |
146 | //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); | 148 | //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); |
147 | // this is currently re-implemented in pop3wrapper and imapwrapper | 149 | // this is currently re-implemented in pop3wrapper and imapwrapper |
148 | int iii = 0; | 150 | int iii = 0; |
149 | int count = target.count(); | 151 | int count = target.count(); |
150 | QProgressBar wid ( count ); | 152 | Q3ProgressBar wid ( count ); |
151 | wid.setCaption( i18n("Deleting ...")); | 153 | wid.setCaption( i18n("Deleting ...")); |
152 | wid.show(); | 154 | wid.show(); |
153 | while (iii < count ) { | 155 | while (iii < count ) { |
154 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); | 156 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); |
155 | wid.setProgress( iii ); | 157 | wid.setProgress( iii ); |
156 | wid.raise(); | 158 | wid.raise(); |
157 | qApp->processEvents(); | 159 | qApp->processEvents(); |
158 | RecMailP mail = (*target.at( iii )); | 160 | RecMailP mail = (*target.at( iii )); |
159 | deleteMail(mail); | 161 | deleteMail(mail); |
160 | ++iii; | 162 | ++iii; |
161 | } | 163 | } |
162 | } | 164 | } |
163 | 165 | ||
164 | void AbstractMail::downloadNewMails(const FolderP&fromFolder, AbstractMail*targetMail ) | 166 | void AbstractMail::downloadNewMails(const FolderP&fromFolder, AbstractMail*targetMail ) |
165 | { | 167 | { |
166 | //qDebug("AbstractMail::downloadNewMails %s ", fromFolder->getName().latin1()); | 168 | //qDebug("AbstractMail::downloadNewMails %s ", fromFolder->getName().latin1()); |
167 | // get local folder | 169 | // get local folder |
168 | Account * acc = getAccount(); | 170 | Account * acc = getAccount(); |
169 | if ( !acc ) return; | 171 | if ( !acc ) return; |
170 | QString lfName = acc->getLocalFolder(); | 172 | QString lfName = acc->getLocalFolder(); |
171 | if ( lfName.isEmpty() ) | 173 | if ( lfName.isEmpty() ) |
172 | lfName = acc->getAccountName(); | 174 | lfName = acc->getAccountName(); |
173 | // create local folder | 175 | // create local folder |
174 | if ( !targetMail->createMbox(lfName)) | 176 | if ( !targetMail->createMbox(lfName)) |
175 | { | 177 | { |
176 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 178 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
177 | i18n("Error while creating new folder\n%1\n\nCancelling action.").arg(lfName)); | 179 | i18n("Error while creating new folder\n%1\n\nCancelling action.").arg(lfName)); |
178 | return; | 180 | return; |
179 | } | 181 | } |
180 | QValueList<RecMailP> t; | 182 | Q3ValueList<RecMailP> t; |
181 | listMessages(fromFolder->getName(),t,acc->getMaxMailSize() ); | 183 | listMessages(fromFolder->getName(),t,acc->getMaxMailSize() ); |
182 | if ( t.count() == 0 ) { | 184 | if ( t.count() == 0 ) { |
183 | qDebug("There are no new messages %s", fromFolder->getName().latin1()); | 185 | qDebug("There are no new messages %s", fromFolder->getName().latin1()); |
184 | Global::statusMessage(i18n("There are no new messages")); | 186 | Global::statusMessage(i18n("There are no new messages")); |
185 | return; | 187 | return; |
186 | } | 188 | } |
187 | Global::statusMessage(i18n("%1 :Downloading mails..."). arg(acc->getAccountName())); | 189 | Global::statusMessage(i18n("%1 :Downloading mails..."). arg(acc->getAccountName())); |
188 | qDebug(i18n("%1 :Downloading mails..."). arg(acc->getAccountName())); | 190 | qDebug(i18n("%1 :Downloading mails..."). arg(acc->getAccountName())); |
189 | qApp->processEvents(); | 191 | qApp->processEvents(); |
190 | QValueList<RecMailP> e; | 192 | Q3ValueList<RecMailP> e; |
191 | targetMail->listMessages(lfName,e,acc->getMaxMailSize() ); | 193 | targetMail->listMessages(lfName,e,acc->getMaxMailSize() ); |
192 | //qDebug("target has mails %d ", e.count()); | 194 | //qDebug("target has mails %d ", e.count()); |
193 | QValueList<RecMailP> n; | 195 | Q3ValueList<RecMailP> n; |
194 | int iii = 0; | 196 | int iii = 0; |
195 | int count = t.count(); | 197 | int count = t.count(); |
196 | while (iii < count ) { | 198 | while (iii < count ) { |
197 | RecMailP r = (*t.at( iii )); | 199 | RecMailP r = (*t.at( iii )); |
198 | bool found = false; | 200 | bool found = false; |
199 | int jjj = 0; | 201 | int jjj = 0; |
200 | int countE = e.count(); | 202 | int countE = e.count(); |
201 | while (jjj < countE ) { | 203 | while (jjj < countE ) { |
202 | RecMailP re = (*e.at( jjj )); | 204 | RecMailP re = (*e.at( jjj )); |
203 | if ( re->isEqual(r) ) { | 205 | if ( re->isEqual(r) ) { |
204 | found = true; | 206 | found = true; |
205 | break; | 207 | break; |
206 | } | 208 | } |
207 | ++jjj; | 209 | ++jjj; |
208 | } | 210 | } |
209 | if ( !found ) { | 211 | if ( !found ) { |
210 | //qDebug("AAAdate *%s* ", r->isodate.latin1() ); | 212 | //qDebug("AAAdate *%s* ", r->isodate.latin1() ); |
211 | n.append( r ); | 213 | n.append( r ); |
212 | } | 214 | } |
213 | ++iii; | 215 | ++iii; |
214 | } | 216 | } |
215 | qDebug("Downloaded %d messages ",n.count() ); | 217 | qDebug("Downloaded %d messages ",n.count() ); |
216 | if ( n.count() == 0 ) { | 218 | if ( n.count() == 0 ) { |
217 | Global::statusMessage(i18n("There are no new messages")); | 219 | Global::statusMessage(i18n("There are no new messages")); |
218 | return; | 220 | return; |
219 | } | 221 | } |
220 | mvcpMailList( n,lfName,targetMail,!acc->getLeaveOnServer()); | 222 | mvcpMailList( n,lfName,targetMail,!acc->getLeaveOnServer()); |
221 | Global::statusMessage(i18n("Downloaded %1 messages").arg(n.count())); | 223 | Global::statusMessage(i18n("Downloaded %1 messages").arg(n.count())); |
222 | 224 | ||
223 | #if 0 | 225 | #if 0 |
224 | QValueList<RecMailP> t; | 226 | Q3ValueList<RecMailP> t; |
225 | listMessages(fromFolder->getName(),t, maxSizeInKb); | 227 | listMessages(fromFolder->getName(),t, maxSizeInKb); |
226 | mvcpMailList( t,targetFolder,targetWrapper,moveit); | 228 | mvcpMailList( t,targetFolder,targetWrapper,moveit); |
227 | #endif | 229 | #endif |
228 | 230 | ||
229 | } | 231 | } |
230 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, | 232 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, |
231 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) | 233 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) |
232 | { | 234 | { |
233 | QValueList<RecMailP> t; | 235 | Q3ValueList<RecMailP> t; |
234 | listMessages(fromFolder->getName(),t, maxSizeInKb); | 236 | listMessages(fromFolder->getName(),t, maxSizeInKb); |
235 | mvcpMailList( t,targetFolder,targetWrapper,moveit); | 237 | mvcpMailList( t,targetFolder,targetWrapper,moveit); |
236 | 238 | ||
237 | } | 239 | } |
238 | void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, | 240 | void AbstractMail::mvcpMailList(const Q3ValueList<RecMailP>& t, |
239 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 241 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
240 | { | 242 | { |
241 | encodedString*st = 0; | 243 | encodedString*st = 0; |
242 | int iii = 0; | 244 | int iii = 0; |
243 | int count = t.count(); | 245 | int count = t.count(); |
244 | if ( count == 0 ) | 246 | if ( count == 0 ) |
245 | return; | 247 | return; |
246 | // wel, processevents is qite strange, we need a widget for getting | 248 | // wel, processevents is qite strange, we need a widget for getting |
247 | // Global::statusMessage(i18n("Copy2 message %1").arg(iii)); displaye | 249 | // Global::statusMessage(i18n("Copy2 message %1").arg(iii)); displaye |
248 | 250 | ||
249 | QProgressBar wid ( count ); | 251 | Q3ProgressBar wid ( count ); |
250 | wid.setCaption( i18n("Copying...")); | 252 | wid.setCaption( i18n("Copying...")); |
251 | wid.show(); | 253 | wid.show(); |
252 | while (iii < count ) { | 254 | while (iii < count ) { |
253 | Global::statusMessage(i18n("Copy message %1 of %2").arg(iii).arg(count)); | 255 | Global::statusMessage(i18n("Copy message %1 of %2").arg(iii).arg(count)); |
254 | wid.setProgress( iii ); | 256 | wid.setProgress( iii ); |
255 | wid.raise(); | 257 | wid.raise(); |
256 | qApp->processEvents(); | 258 | qApp->processEvents(); |
257 | RecMailP r = (*t.at( iii )); | 259 | RecMailP r = (*t.at( iii )); |
258 | st = fetchRawBody(r); | 260 | st = fetchRawBody(r); |
259 | if (st) { | 261 | if (st) { |
260 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 262 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
261 | delete st; | 263 | delete st; |
262 | } | 264 | } |
263 | ++iii; | 265 | ++iii; |
264 | } | 266 | } |
265 | if (moveit) { | 267 | if (moveit) { |
266 | deleteMailList( t ); | 268 | deleteMailList( t ); |
267 | //deleteAllMail(fromFolder); | 269 | //deleteAllMail(fromFolder); |
268 | } | 270 | } |
269 | } | 271 | } |
270 | 272 | ||
271 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 273 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
272 | { | 274 | { |
273 | encodedString*st = 0; | 275 | encodedString*st = 0; |
diff --git a/kmicromail/libmailwrapper/abstractmail.h b/kmicromail/libmailwrapper/abstractmail.h index 2069ca1..f606b1f 100644 --- a/kmicromail/libmailwrapper/abstractmail.h +++ b/kmicromail/libmailwrapper/abstractmail.h | |||
@@ -1,71 +1,73 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef __abstract_mail_ | 2 | #ifndef __abstract_mail_ |
3 | #define __abstract_mail_ | 3 | #define __abstract_mail_ |
4 | 4 | ||
5 | #include "maildefines.h" | 5 | #include "maildefines.h" |
6 | 6 | ||
7 | #include "settings.h" | 7 | #include "settings.h" |
8 | 8 | ||
9 | #include <qobject.h> | 9 | #include <qobject.h> |
10 | //Added by qt3to4: | ||
11 | #include <Q3ValueList> | ||
10 | #include <opie2/osmartpointer.h> | 12 | #include <opie2/osmartpointer.h> |
11 | #include "mailtypes.h" | 13 | #include "mailtypes.h" |
12 | 14 | ||
13 | 15 | ||
14 | #include "mailwrapper.h" | 16 | #include "mailwrapper.h" |
15 | 17 | ||
16 | class IMAPwrapper; | 18 | class IMAPwrapper; |
17 | class POP3wrapper; | 19 | class POP3wrapper; |
18 | class Folder; | 20 | class Folder; |
19 | class encodedString; | 21 | class encodedString; |
20 | struct folderStat; | 22 | struct folderStat; |
21 | 23 | ||
22 | class AbstractMail:public QObject | 24 | class AbstractMail:public QObject |
23 | { | 25 | { |
24 | Q_OBJECT | 26 | Q_OBJECT |
25 | public: | 27 | public: |
26 | AbstractMail(){}; | 28 | AbstractMail(){}; |
27 | virtual ~AbstractMail(){} | 29 | virtual ~AbstractMail(){} |
28 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders()=0; | 30 | virtual Q3ValueList<Opie::Core::OSmartPointer<Folder> >* listFolders()=0; |
29 | virtual void listMessages(const QString & mailbox,QValueList<RecMailP>&target, int sizeInKb = 0 )=0; | 31 | virtual void listMessages(const QString & mailbox,Q3ValueList<RecMailP>&target, int sizeInKb = 0 )=0; |
30 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; | 32 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; |
31 | virtual RecBodyP fetchBody(const RecMailP&mail)=0; | 33 | virtual RecBodyP fetchBody(const RecMailP&mail)=0; |
32 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part)=0; | 34 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part)=0; |
33 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part)=0; | 35 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part)=0; |
34 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part)=0; | 36 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part)=0; |
35 | virtual encodedString* fetchRawBody(const RecMailP&mail)=0; | 37 | virtual encodedString* fetchRawBody(const RecMailP&mail)=0; |
36 | 38 | ||
37 | virtual void deleteMail(const RecMailP&mail)=0; | 39 | virtual void deleteMail(const RecMailP&mail)=0; |
38 | virtual void deleteMailList(const QValueList<RecMailP>&target); | 40 | virtual void deleteMailList(const Q3ValueList<RecMailP>&target); |
39 | virtual void answeredMail(const RecMailP&mail)=0; | 41 | virtual void answeredMail(const RecMailP&mail)=0; |
40 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&)=0; | 42 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&)=0; |
41 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> >&target); | 43 | virtual void deleteMails(const QString & FolderName,const Q3ValueList<Opie::Core::OSmartPointer<RecMail> >&target); |
42 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&)=0; | 44 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&)=0; |
43 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; | 45 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; |
44 | void downloadNewMails(const FolderP&fromFolder,AbstractMail*targetWrapper ); | 46 | void downloadNewMails(const FolderP&fromFolder,AbstractMail*targetWrapper ); |
45 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, | 47 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, |
46 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int sizeInKb = 0); | 48 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int sizeInKb = 0); |
47 | virtual void mvcpMailList(const QValueList<RecMailP>& t, | 49 | virtual void mvcpMailList(const Q3ValueList<RecMailP>& t, |
48 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 50 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
49 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 51 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
50 | 52 | ||
51 | virtual void cleanMimeCache(){}; | 53 | virtual void cleanMimeCache(){}; |
52 | /* mail box methods */ | 54 | /* mail box methods */ |
53 | /* parameter is the box to create. | 55 | /* parameter is the box to create. |
54 | * if the implementing subclass has prefixes, | 56 | * if the implementing subclass has prefixes, |
55 | * them has to be appended automatic. | 57 | * them has to be appended automatic. |
56 | */ | 58 | */ |
57 | virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, | 59 | virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, |
58 | const QString& delemiter="/",bool getsubfolder=false); | 60 | const QString& delemiter="/",bool getsubfolder=false); |
59 | virtual void logout()=0; | 61 | virtual void logout()=0; |
60 | 62 | ||
61 | virtual Account* getAccount() = 0; | 63 | virtual Account* getAccount() = 0; |
62 | 64 | ||
63 | static AbstractMail* getWrapper(IMAPaccount *a); | 65 | static AbstractMail* getWrapper(IMAPaccount *a); |
64 | static AbstractMail* getWrapper(POP3account *a); | 66 | static AbstractMail* getWrapper(POP3account *a); |
65 | static AbstractMail* getWrapper(NNTPaccount *a); | 67 | static AbstractMail* getWrapper(NNTPaccount *a); |
66 | /* mbox only! */ | 68 | /* mbox only! */ |
67 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); | 69 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); |
68 | static AbstractMail* getWrapper(Account*a); | 70 | static AbstractMail* getWrapper(Account*a); |
69 | 71 | ||
70 | static QString defaultLocalfolder(); | 72 | static QString defaultLocalfolder(); |
71 | static QString draftFolder(); | 73 | static QString draftFolder(); |
diff --git a/kmicromail/libmailwrapper/generatemail.cpp b/kmicromail/libmailwrapper/generatemail.cpp index 2d213fe..ddad21b 100644 --- a/kmicromail/libmailwrapper/generatemail.cpp +++ b/kmicromail/libmailwrapper/generatemail.cpp | |||
@@ -1,33 +1,35 @@ | |||
1 | #include "generatemail.h" | 1 | #include "generatemail.h" |
2 | #include "mailwrapper.h" | 2 | #include "mailwrapper.h" |
3 | 3 | ||
4 | #include <libetpan/libetpan.h> | 4 | #include <libetpan/libetpan.h> |
5 | 5 | ||
6 | //#include <qt.h> | 6 | //#include <qt.h> |
7 | 7 | ||
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | #include <qfileinfo.h> | 9 | #include <qfileinfo.h> |
10 | //Added by qt3to4: | ||
11 | #include <Q3CString> | ||
10 | 12 | ||
11 | using namespace Opie::Core; | 13 | using namespace Opie::Core; |
12 | const char* Generatemail::USER_AGENT="KOpieMail 33 1/3"; | 14 | const char* Generatemail::USER_AGENT="KOpieMail 33 1/3"; |
13 | 15 | ||
14 | Generatemail::Generatemail() | 16 | Generatemail::Generatemail() |
15 | { | 17 | { |
16 | mCharset = "iso-8859-1"; | 18 | mCharset = "iso-8859-1"; |
17 | } | 19 | } |
18 | 20 | ||
19 | Generatemail::~Generatemail() | 21 | Generatemail::~Generatemail() |
20 | { | 22 | { |
21 | } | 23 | } |
22 | 24 | ||
23 | void Generatemail::addRcpts( clist *list, mailimf_address_list *addr_list ) { | 25 | void Generatemail::addRcpts( clist *list, mailimf_address_list *addr_list ) { |
24 | clistiter *it, *it2; | 26 | clistiter *it, *it2; |
25 | 27 | ||
26 | for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { | 28 | for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { |
27 | mailimf_address *addr; | 29 | mailimf_address *addr; |
28 | addr = (mailimf_address *) it->data; | 30 | addr = (mailimf_address *) it->data; |
29 | 31 | ||
30 | if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { | 32 | if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { |
31 | esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); | 33 | esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); |
32 | } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { | 34 | } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { |
33 | clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; | 35 | clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; |
@@ -207,73 +209,73 @@ void Generatemail::addFileParts( mailmime *message,const QList<Attachment>&files | |||
207 | const Attachment *it; | 209 | const Attachment *it; |
208 | unsigned int count = files.count(); | 210 | unsigned int count = files.count(); |
209 | for ( unsigned int i = 0; i < count; ++i ) { | 211 | for ( unsigned int i = 0; i < count; ++i ) { |
210 | mailmime *filePart; | 212 | mailmime *filePart; |
211 | int err; | 213 | int err; |
212 | it = ((QList<Attachment>)files).at(i); | 214 | it = ((QList<Attachment>)files).at(i); |
213 | 215 | ||
214 | filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" ); | 216 | filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" ); |
215 | if ( filePart == NULL ) { | 217 | if ( filePart == NULL ) { |
216 | continue; | 218 | continue; |
217 | } | 219 | } |
218 | err = mailmime_smart_add_part( message, filePart ); | 220 | err = mailmime_smart_add_part( message, filePart ); |
219 | if ( err != MAILIMF_NO_ERROR ) { | 221 | if ( err != MAILIMF_NO_ERROR ) { |
220 | mailmime_free( filePart ); | 222 | mailmime_free( filePart ); |
221 | } | 223 | } |
222 | } | 224 | } |
223 | } | 225 | } |
224 | 226 | ||
225 | mailmime *Generatemail::buildTxtPart(const QString&str ) { | 227 | mailmime *Generatemail::buildTxtPart(const QString&str ) { |
226 | mailmime *txtPart; | 228 | mailmime *txtPart; |
227 | mailmime_fields *fields; | 229 | mailmime_fields *fields; |
228 | mailmime_content *content; | 230 | mailmime_content *content; |
229 | mailmime_parameter *param; | 231 | mailmime_parameter *param; |
230 | int err; | 232 | int err; |
231 | QCString __str; | 233 | Q3CString __str; |
232 | //qDebug(" Generatemail::buildTxtPart %s", str.latin1()); | 234 | //qDebug(" Generatemail::buildTxtPart %s", str.latin1()); |
233 | param = mailmime_parameter_new( strdup( "charset" ), | 235 | param = mailmime_parameter_new( strdup( "charset" ), |
234 | strdup( mCharset.latin1() ) ); | 236 | strdup( mCharset.latin1() ) ); |
235 | if ( param == NULL ) | 237 | if ( param == NULL ) |
236 | goto err_free; | 238 | goto err_free; |
237 | 239 | ||
238 | content = mailmime_content_new_with_str( "text/plain" ); | 240 | content = mailmime_content_new_with_str( "text/plain" ); |
239 | if ( content == NULL ) | 241 | if ( content == NULL ) |
240 | goto err_free_param; | 242 | goto err_free_param; |
241 | 243 | ||
242 | err = clist_append( content->ct_parameters, param ); | 244 | err = clist_append( content->ct_parameters, param ); |
243 | if ( err != MAILIMF_NO_ERROR ) | 245 | if ( err != MAILIMF_NO_ERROR ) |
244 | goto err_free_content; | 246 | goto err_free_content; |
245 | 247 | ||
246 | fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); | 248 | fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); |
247 | if ( fields == NULL ) | 249 | if ( fields == NULL ) |
248 | goto err_free_content; | 250 | goto err_free_content; |
249 | 251 | ||
250 | txtPart = mailmime_new_empty( content, fields ); | 252 | txtPart = mailmime_new_empty( content, fields ); |
251 | if ( txtPart == NULL ) | 253 | if ( txtPart == NULL ) |
252 | goto err_free_fields; | 254 | goto err_free_fields; |
253 | { | 255 | { |
254 | //__str = str.utf8(); | 256 | //__str = str.utf8(); |
255 | __str = QCString (str.latin1()); | 257 | __str = Q3CString (str.latin1()); |
256 | err = mailmime_set_body_text( txtPart, strdup(__str.data()), __str.length() ); | 258 | err = mailmime_set_body_text( txtPart, strdup(__str.data()), __str.length() ); |
257 | } | 259 | } |
258 | if ( err != MAILIMF_NO_ERROR ) | 260 | if ( err != MAILIMF_NO_ERROR ) |
259 | goto err_free_txtPart; | 261 | goto err_free_txtPart; |
260 | 262 | ||
261 | return txtPart; // Success :) | 263 | return txtPart; // Success :) |
262 | 264 | ||
263 | err_free_txtPart: | 265 | err_free_txtPart: |
264 | mailmime_free( txtPart ); | 266 | mailmime_free( txtPart ); |
265 | err_free_fields: | 267 | err_free_fields: |
266 | mailmime_fields_free( fields ); | 268 | mailmime_fields_free( fields ); |
267 | err_free_content: | 269 | err_free_content: |
268 | mailmime_content_free( content ); | 270 | mailmime_content_free( content ); |
269 | err_free_param: | 271 | err_free_param: |
270 | mailmime_parameter_free( param ); | 272 | mailmime_parameter_free( param ); |
271 | err_free: | 273 | err_free: |
272 | ; | 274 | ; |
273 | 275 | ||
274 | return NULL; // Error :( | 276 | return NULL; // Error :( |
275 | } | 277 | } |
276 | 278 | ||
277 | mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { | 279 | mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { |
278 | return mailimf_mailbox_new( strdup( name.latin1() ), | 280 | return mailimf_mailbox_new( strdup( name.latin1() ), |
279 | strdup( mail.latin1() ) ); | 281 | strdup( mail.latin1() ) ); |
diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp index 0b6adf7..633ab42 100644 --- a/kmicromail/libmailwrapper/genericwrapper.cpp +++ b/kmicromail/libmailwrapper/genericwrapper.cpp | |||
@@ -1,32 +1,34 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "genericwrapper.h" | 2 | #include "genericwrapper.h" |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include "mailtypes.h" | 4 | #include "mailtypes.h" |
5 | 5 | ||
6 | #include <kconfig.h> | 6 | #include <kconfig.h> |
7 | #include <kglobal.h> | 7 | #include <kglobal.h> |
8 | #include <kstandarddirs.h> | 8 | #include <kstandarddirs.h> |
9 | //Added by qt3to4: | ||
10 | #include <Q3ValueList> | ||
9 | 11 | ||
10 | 12 | ||
11 | using namespace Opie::Core; | 13 | using namespace Opie::Core; |
12 | Genericwrapper::Genericwrapper() | 14 | Genericwrapper::Genericwrapper() |
13 | : AbstractMail() | 15 | : AbstractMail() |
14 | { | 16 | { |
15 | bodyCache.clear(); | 17 | bodyCache.clear(); |
16 | m_storage = 0; | 18 | m_storage = 0; |
17 | m_folder = 0; | 19 | m_folder = 0; |
18 | } | 20 | } |
19 | 21 | ||
20 | Genericwrapper::~Genericwrapper() | 22 | Genericwrapper::~Genericwrapper() |
21 | { | 23 | { |
22 | if (m_folder) { | 24 | if (m_folder) { |
23 | mailfolder_free(m_folder); | 25 | mailfolder_free(m_folder); |
24 | } | 26 | } |
25 | if (m_storage) { | 27 | if (m_storage) { |
26 | mailstorage_free(m_storage); | 28 | mailstorage_free(m_storage); |
27 | } | 29 | } |
28 | cleanMimeCache(); | 30 | cleanMimeCache(); |
29 | } | 31 | } |
30 | const QDateTime Genericwrapper::parseDateTime( mailimf_date_time *date ) | 32 | const QDateTime Genericwrapper::parseDateTime( mailimf_date_time *date ) |
31 | { | 33 | { |
32 | 34 | ||
@@ -161,67 +163,67 @@ QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) | |||
161 | enc = "7bit"; | 163 | enc = "7bit"; |
162 | break; | 164 | break; |
163 | case MAILMIME_MECHANISM_8BIT: | 165 | case MAILMIME_MECHANISM_8BIT: |
164 | enc = "8bit"; | 166 | enc = "8bit"; |
165 | break; | 167 | break; |
166 | case MAILMIME_MECHANISM_BINARY: | 168 | case MAILMIME_MECHANISM_BINARY: |
167 | enc = "binary"; | 169 | enc = "binary"; |
168 | break; | 170 | break; |
169 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: | 171 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: |
170 | enc = "quoted-printable"; | 172 | enc = "quoted-printable"; |
171 | break; | 173 | break; |
172 | case MAILMIME_MECHANISM_BASE64: | 174 | case MAILMIME_MECHANISM_BASE64: |
173 | enc = "base64"; | 175 | enc = "base64"; |
174 | break; | 176 | break; |
175 | case MAILMIME_MECHANISM_TOKEN: | 177 | case MAILMIME_MECHANISM_TOKEN: |
176 | default: | 178 | default: |
177 | if (aEnc->enc_token) { | 179 | if (aEnc->enc_token) { |
178 | enc = QString(aEnc->enc_token); | 180 | enc = QString(aEnc->enc_token); |
179 | } | 181 | } |
180 | break; | 182 | break; |
181 | } | 183 | } |
182 | return enc; | 184 | return enc; |
183 | } | 185 | } |
184 | 186 | ||
185 | void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) | 187 | void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,Q3ValueList<int>recList,unsigned int current_rec,int current_count) |
186 | { | 188 | { |
187 | if (current_rec >= 10) { | 189 | if (current_rec >= 10) { |
188 | ; // odebug << "too deep recursion!" << oendl; | 190 | ; // odebug << "too deep recursion!" << oendl; |
189 | } | 191 | } |
190 | if (!message || !mime) { | 192 | if (!message || !mime) { |
191 | return; | 193 | return; |
192 | } | 194 | } |
193 | int r; | 195 | int r; |
194 | char*data = 0; | 196 | char*data = 0; |
195 | size_t len; | 197 | size_t len; |
196 | clistiter * cur = 0; | 198 | clistiter * cur = 0; |
197 | QString b; | 199 | QString b; |
198 | RecPartP part = new RecPart(); | 200 | RecPartP part = new RecPart(); |
199 | 201 | ||
200 | switch (mime->mm_type) { | 202 | switch (mime->mm_type) { |
201 | case MAILMIME_SINGLE: | 203 | case MAILMIME_SINGLE: |
202 | { | 204 | { |
203 | QValueList<int>countlist = recList; | 205 | Q3ValueList<int>countlist = recList; |
204 | countlist.append(current_count); | 206 | countlist.append(current_count); |
205 | r = mailmessage_fetch_section(message,mime,&data,&len); | 207 | r = mailmessage_fetch_section(message,mime,&data,&len); |
206 | part->setSize(len); | 208 | part->setSize(len); |
207 | part->setPositionlist(countlist); | 209 | part->setPositionlist(countlist); |
208 | b = gen_attachment_id(); | 210 | b = gen_attachment_id(); |
209 | part->setIdentifier(b); | 211 | part->setIdentifier(b); |
210 | fillSingleBody(part,message,mime); | 212 | fillSingleBody(part,message,mime); |
211 | if (part->Type()=="text" && target->Bodytext().isNull()) { | 213 | if (part->Type()=="text" && target->Bodytext().isNull()) { |
212 | encodedString*rs = new encodedString(); | 214 | encodedString*rs = new encodedString(); |
213 | rs->setContent(data,len); | 215 | rs->setContent(data,len); |
214 | encodedString*res = decode_String(rs,part->Encoding()); | 216 | encodedString*res = decode_String(rs,part->Encoding()); |
215 | if (countlist.count()>2) { | 217 | if (countlist.count()>2) { |
216 | bodyCache[b]=rs; | 218 | bodyCache[b]=rs; |
217 | target->addPart(part); | 219 | target->addPart(part); |
218 | } else { | 220 | } else { |
219 | delete rs; | 221 | delete rs; |
220 | } | 222 | } |
221 | b = QString(res->Content()); | 223 | b = QString(res->Content()); |
222 | delete res; | 224 | delete res; |
223 | size_t index = 0; | 225 | size_t index = 0; |
224 | char*resu = 0; | 226 | char*resu = 0; |
225 | int err = MAILIMF_NO_ERROR; | 227 | int err = MAILIMF_NO_ERROR; |
226 | QString charset = part->searchParamter( "charset"); | 228 | QString charset = part->searchParamter( "charset"); |
227 | qDebug("CHARSET %s ",charset.latin1() ); | 229 | qDebug("CHARSET %s ",charset.latin1() ); |
@@ -229,101 +231,101 @@ void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*m | |||
229 | if (false ) { | 231 | if (false ) { |
230 | //if ( !charset.isEmpty() ) { | 232 | //if ( !charset.isEmpty() ) { |
231 | target->setCharset( charset ); | 233 | target->setCharset( charset ); |
232 | err = mailmime_encoded_phrase_parse(charset.latin1(), | 234 | err = mailmime_encoded_phrase_parse(charset.latin1(), |
233 | b.latin1(), b.length(),&index, "utf-8",&resu); | 235 | b.latin1(), b.length(),&index, "utf-8",&resu); |
234 | if (err == MAILIMF_NO_ERROR && resu && strlen(resu)) { | 236 | if (err == MAILIMF_NO_ERROR && resu && strlen(resu)) { |
235 | //qDebug("res %d %s ", index, resu); | 237 | //qDebug("res %d %s ", index, resu); |
236 | b = QString::fromUtf8(resu); | 238 | b = QString::fromUtf8(resu); |
237 | } | 239 | } |
238 | if (resu) free(resu); | 240 | if (resu) free(resu); |
239 | } | 241 | } |
240 | #endif | 242 | #endif |
241 | target->setBodytext(b); | 243 | target->setBodytext(b); |
242 | target->setDescription(part); | 244 | target->setDescription(part); |
243 | } else { | 245 | } else { |
244 | bodyCache[b]=new encodedString(data,len); | 246 | bodyCache[b]=new encodedString(data,len); |
245 | target->addPart(part); | 247 | target->addPart(part); |
246 | } | 248 | } |
247 | } | 249 | } |
248 | break; | 250 | break; |
249 | case MAILMIME_MULTIPLE: | 251 | case MAILMIME_MULTIPLE: |
250 | { | 252 | { |
251 | unsigned int ccount = 1; | 253 | unsigned int ccount = 1; |
252 | mailmime*cbody=0; | 254 | mailmime*cbody=0; |
253 | QValueList<int>countlist = recList; | 255 | Q3ValueList<int>countlist = recList; |
254 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { | 256 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { |
255 | cbody = (mailmime*)clist_content(cur); | 257 | cbody = (mailmime*)clist_content(cur); |
256 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 258 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
257 | RecPartP targetPart = new RecPart(); | 259 | RecPartP targetPart = new RecPart(); |
258 | targetPart->setType("multipart"); | 260 | targetPart->setType("multipart"); |
259 | countlist.append(current_count); | 261 | countlist.append(current_count); |
260 | targetPart->setPositionlist(countlist); | 262 | targetPart->setPositionlist(countlist); |
261 | target->addPart(targetPart); | 263 | target->addPart(targetPart); |
262 | } | 264 | } |
263 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); | 265 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); |
264 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 266 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
265 | countlist = recList; | 267 | countlist = recList; |
266 | } | 268 | } |
267 | ++ccount; | 269 | ++ccount; |
268 | } | 270 | } |
269 | } | 271 | } |
270 | break; | 272 | break; |
271 | case MAILMIME_MESSAGE: | 273 | case MAILMIME_MESSAGE: |
272 | { | 274 | { |
273 | QValueList<int>countlist = recList; | 275 | Q3ValueList<int>countlist = recList; |
274 | countlist.append(current_count); | 276 | countlist.append(current_count); |
275 | /* the own header is always at recursion 0 - we don't need that */ | 277 | /* the own header is always at recursion 0 - we don't need that */ |
276 | if (current_rec > 0) { | 278 | if (current_rec > 0) { |
277 | part->setPositionlist(countlist); | 279 | part->setPositionlist(countlist); |
278 | r = mailmessage_fetch_section(message,mime,&data,&len); | 280 | r = mailmessage_fetch_section(message,mime,&data,&len); |
279 | part->setSize(len); | 281 | part->setSize(len); |
280 | part->setPositionlist(countlist); | 282 | part->setPositionlist(countlist); |
281 | b = gen_attachment_id(); | 283 | b = gen_attachment_id(); |
282 | part->setIdentifier(b); | 284 | part->setIdentifier(b); |
283 | part->setType("message"); | 285 | part->setType("message"); |
284 | part->setSubtype("rfc822"); | 286 | part->setSubtype("rfc822"); |
285 | bodyCache[b]=new encodedString(data,len); | 287 | bodyCache[b]=new encodedString(data,len); |
286 | target->addPart(part); | 288 | target->addPart(part); |
287 | } | 289 | } |
288 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { | 290 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { |
289 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); | 291 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); |
290 | } | 292 | } |
291 | } | 293 | } |
292 | break; | 294 | break; |
293 | } | 295 | } |
294 | } | 296 | } |
295 | 297 | ||
296 | RecBodyP Genericwrapper::parseMail( mailmessage * msg ) | 298 | RecBodyP Genericwrapper::parseMail( mailmessage * msg ) |
297 | { | 299 | { |
298 | int err = MAILIMF_NO_ERROR; | 300 | int err = MAILIMF_NO_ERROR; |
299 | //mailmime_single_fields fields; | 301 | //mailmime_single_fields fields; |
300 | /* is bound to msg and will be freed there */ | 302 | /* is bound to msg and will be freed there */ |
301 | mailmime * mime=0; | 303 | mailmime * mime=0; |
302 | RecBodyP body = new RecBody(); | 304 | RecBodyP body = new RecBody(); |
303 | //memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 305 | //memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
304 | err = mailmessage_get_bodystructure(msg,&mime); | 306 | err = mailmessage_get_bodystructure(msg,&mime); |
305 | QValueList<int>recList; | 307 | Q3ValueList<int>recList; |
306 | traverseBody(body,msg,mime,recList); | 308 | traverseBody(body,msg,mime,recList); |
307 | return body; | 309 | return body; |
308 | } | 310 | } |
309 | 311 | ||
310 | 312 | ||
311 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) | 313 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) |
312 | { | 314 | { |
313 | QString result( "" ); | 315 | QString result( "" ); |
314 | 316 | ||
315 | bool first = true; | 317 | bool first = true; |
316 | if (list == 0) return result; | 318 | if (list == 0) return result; |
317 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { | 319 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { |
318 | mailimf_address *addr = (mailimf_address *) current->data; | 320 | mailimf_address *addr = (mailimf_address *) current->data; |
319 | 321 | ||
320 | if ( !first ) { | 322 | if ( !first ) { |
321 | result.append( "," ); | 323 | result.append( "," ); |
322 | } else { | 324 | } else { |
323 | first = false; | 325 | first = false; |
324 | } | 326 | } |
325 | 327 | ||
326 | switch ( addr->ad_type ) { | 328 | switch ( addr->ad_type ) { |
327 | case MAILIMF_ADDRESS_MAILBOX: | 329 | case MAILIMF_ADDRESS_MAILBOX: |
328 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); | 330 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); |
329 | break; | 331 | break; |
@@ -426,49 +428,49 @@ void Genericwrapper::cleanMimeCache() | |||
426 | bodyCache.clear(); | 428 | bodyCache.clear(); |
427 | ; // odebug << "Genericwrapper: cache cleaned" << oendl; | 429 | ; // odebug << "Genericwrapper: cache cleaned" << oendl; |
428 | } | 430 | } |
429 | 431 | ||
430 | QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) | 432 | QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) |
431 | { | 433 | { |
432 | QStringList res; | 434 | QStringList res; |
433 | if (!in_replies || !in_replies->mid_list) return res; | 435 | if (!in_replies || !in_replies->mid_list) return res; |
434 | clistiter * current = 0; | 436 | clistiter * current = 0; |
435 | for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { | 437 | for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { |
436 | QString h((char*)current->data); | 438 | QString h((char*)current->data); |
437 | while (h.length()>0 && h[0]=='<') { | 439 | while (h.length()>0 && h[0]=='<') { |
438 | h.remove(0,1); | 440 | h.remove(0,1); |
439 | } | 441 | } |
440 | while (h.length()>0 && h[h.length()-1]=='>') { | 442 | while (h.length()>0 && h[h.length()-1]=='>') { |
441 | h.remove(h.length()-1,1); | 443 | h.remove(h.length()-1,1); |
442 | } | 444 | } |
443 | if (h.length()>0) { | 445 | if (h.length()>0) { |
444 | res.append(h); | 446 | res.append(h); |
445 | } | 447 | } |
446 | } | 448 | } |
447 | return res; | 449 | return res; |
448 | } | 450 | } |
449 | 451 | ||
450 | void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to, int maxSizeInKb) | 452 | void Genericwrapper::parseList(Q3ValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to, int maxSizeInKb) |
451 | { | 453 | { |
452 | int r; | 454 | int r; |
453 | mailmessage_list * env_list = 0; | 455 | mailmessage_list * env_list = 0; |
454 | r = mailsession_get_messages_list(session,&env_list); | 456 | r = mailsession_get_messages_list(session,&env_list); |
455 | if (r != MAIL_NO_ERROR) { | 457 | if (r != MAIL_NO_ERROR) { |
456 | ; // odebug << "Error message list" << oendl; | 458 | ; // odebug << "Error message list" << oendl; |
457 | return; | 459 | return; |
458 | } | 460 | } |
459 | r = mailsession_get_envelopes_list(session, env_list); | 461 | r = mailsession_get_envelopes_list(session, env_list); |
460 | if (r != MAIL_NO_ERROR) { | 462 | if (r != MAIL_NO_ERROR) { |
461 | ; // odebug << "Error filling message list" << oendl; | 463 | ; // odebug << "Error filling message list" << oendl; |
462 | if (env_list) { | 464 | if (env_list) { |
463 | mailmessage_list_free(env_list); | 465 | mailmessage_list_free(env_list); |
464 | } | 466 | } |
465 | return; | 467 | return; |
466 | } | 468 | } |
467 | mailimf_references * refs = 0; | 469 | mailimf_references * refs = 0; |
468 | mailimf_in_reply_to * in_replies = 0; | 470 | mailimf_in_reply_to * in_replies = 0; |
469 | uint32_t i = 0; | 471 | uint32_t i = 0; |
470 | for(; i < carray_count(env_list->msg_tab) ; ++i) { | 472 | for(; i < carray_count(env_list->msg_tab) ; ++i) { |
471 | mailmessage * msg; | 473 | mailmessage * msg; |
472 | QBitArray mFlags(7); | 474 | QBitArray mFlags(7); |
473 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); | 475 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); |
474 | if (msg->msg_fields == NULL) { | 476 | if (msg->msg_fields == NULL) { |
diff --git a/kmicromail/libmailwrapper/genericwrapper.h b/kmicromail/libmailwrapper/genericwrapper.h index c35a6da..a50161d 100644 --- a/kmicromail/libmailwrapper/genericwrapper.h +++ b/kmicromail/libmailwrapper/genericwrapper.h | |||
@@ -1,68 +1,70 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef __GENERIC_WRAPPER_H | 2 | #ifndef __GENERIC_WRAPPER_H |
3 | #define __GENERIC_WRAPPER_H | 3 | #define __GENERIC_WRAPPER_H |
4 | 4 | ||
5 | #include "abstractmail.h" | 5 | #include "abstractmail.h" |
6 | #include <qmap.h> | 6 | #include <qmap.h> |
7 | #include <qstring.h> | 7 | #include <qstring.h> |
8 | //Added by qt3to4: | ||
9 | #include <Q3ValueList> | ||
8 | #include <libetpan/clist.h> | 10 | #include <libetpan/clist.h> |
9 | 11 | ||
10 | class RecMail; | 12 | class RecMail; |
11 | class RecBody; | 13 | class RecBody; |
12 | class encodedString; | 14 | class encodedString; |
13 | struct mailpop3; | 15 | struct mailpop3; |
14 | struct mailmessage; | 16 | struct mailmessage; |
15 | struct mailmime; | 17 | struct mailmime; |
16 | struct mailmime_mechanism; | 18 | struct mailmime_mechanism; |
17 | struct mailimf_mailbox_list; | 19 | struct mailimf_mailbox_list; |
18 | struct mailimf_mailbox; | 20 | struct mailimf_mailbox; |
19 | struct mailimf_date_time; | 21 | struct mailimf_date_time; |
20 | struct mailimf_group; | 22 | struct mailimf_group; |
21 | struct mailimf_address_list; | 23 | struct mailimf_address_list; |
22 | struct mailsession; | 24 | struct mailsession; |
23 | struct mailstorage; | 25 | struct mailstorage; |
24 | struct mailfolder; | 26 | struct mailfolder; |
25 | struct mailimf_in_reply_to; | 27 | struct mailimf_in_reply_to; |
26 | 28 | ||
27 | /* this class hold just the funs shared between | 29 | /* this class hold just the funs shared between |
28 | * mbox and pop3 (later mh, too) mail access. | 30 | * mbox and pop3 (later mh, too) mail access. |
29 | * it is not desigend to make a instance of it! | 31 | * it is not desigend to make a instance of it! |
30 | */ | 32 | */ |
31 | class Genericwrapper : public AbstractMail | 33 | class Genericwrapper : public AbstractMail |
32 | { | 34 | { |
33 | Q_OBJECT | 35 | Q_OBJECT |
34 | public: | 36 | public: |
35 | Genericwrapper(); | 37 | Genericwrapper(); |
36 | virtual ~Genericwrapper(); | 38 | virtual ~Genericwrapper(); |
37 | 39 | ||
38 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); | 40 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); |
39 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); | 41 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); |
40 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); | 42 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); |
41 | virtual void cleanMimeCache(); | 43 | virtual void cleanMimeCache(); |
42 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&){return 1;} | 44 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&){return 1;} |
43 | virtual void logout(){}; | 45 | virtual void logout(){}; |
44 | virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; | 46 | virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; |
45 | static const QDateTime parseDateTime( mailimf_date_time *date ); | 47 | static const QDateTime parseDateTime( mailimf_date_time *date ); |
46 | 48 | ||
47 | protected: | 49 | protected: |
48 | RecBodyP parseMail( mailmessage * msg ); | 50 | RecBodyP parseMail( mailmessage * msg ); |
49 | QString parseMailboxList( mailimf_mailbox_list *list ); | 51 | QString parseMailboxList( mailimf_mailbox_list *list ); |
50 | QString parseMailbox( mailimf_mailbox *box ); | 52 | QString parseMailbox( mailimf_mailbox *box ); |
51 | QString parseGroup( mailimf_group *group ); | 53 | QString parseGroup( mailimf_group *group ); |
52 | QString parseAddressList( mailimf_address_list *list ); | 54 | QString parseAddressList( mailimf_address_list *list ); |
53 | 55 | ||
54 | void traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1); | 56 | void traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,Q3ValueList<int>recList,unsigned int current_rek=0,int current_count=1); |
55 | static void fillSingleBody(RecPartP&target,mailmessage*message,mailmime*mime); | 57 | static void fillSingleBody(RecPartP&target,mailmessage*message,mailmime*mime); |
56 | static void fillParameters(RecPartP&target,clist*parameters); | 58 | static void fillParameters(RecPartP&target,clist*parameters); |
57 | static QString getencoding(mailmime_mechanism*aEnc); | 59 | static QString getencoding(mailmime_mechanism*aEnc); |
58 | virtual void parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false, int maxSizeInKb = 0); | 60 | virtual void parseList(Q3ValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false, int maxSizeInKb = 0); |
59 | QStringList parseInreplies(mailimf_in_reply_to * in_replies); | 61 | QStringList parseInreplies(mailimf_in_reply_to * in_replies); |
60 | 62 | ||
61 | QString msgTempName; | 63 | QString msgTempName; |
62 | unsigned int last_msg_id; | 64 | unsigned int last_msg_id; |
63 | QMap<QString,encodedString*> bodyCache; | 65 | QMap<QString,encodedString*> bodyCache; |
64 | mailstorage * m_storage; | 66 | mailstorage * m_storage; |
65 | mailfolder*m_folder; | 67 | mailfolder*m_folder; |
66 | }; | 68 | }; |
67 | 69 | ||
68 | #endif | 70 | #endif |
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index 4f0c849..f73f4cc 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,33 +1,35 @@ | |||
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 | //Added by qt3to4: | ||
7 | #include <Q3ValueList> | ||
6 | #include "imapwrapper.h" | 8 | #include "imapwrapper.h" |
7 | #include "mailtypes.h" | 9 | #include "mailtypes.h" |
8 | #include "logindialog.h" | 10 | #include "logindialog.h" |
9 | #include <qprogressbar.h> | 11 | #include <q3progressbar.h> |
10 | #include "genericwrapper.h" | 12 | #include "genericwrapper.h" |
11 | #include <kglobal.h> | 13 | #include <kglobal.h> |
12 | 14 | ||
13 | using namespace Opie::Core; | 15 | using namespace Opie::Core; |
14 | int IMAPwrapper::mMax = 0; | 16 | int IMAPwrapper::mMax = 0; |
15 | int IMAPwrapper::mCurrent = 0; | 17 | int IMAPwrapper::mCurrent = 0; |
16 | 18 | ||
17 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 19 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
18 | : AbstractMail() | 20 | : AbstractMail() |
19 | { | 21 | { |
20 | account = a; | 22 | account = a; |
21 | m_imap = 0; | 23 | m_imap = 0; |
22 | m_Lastmbox = ""; | 24 | m_Lastmbox = ""; |
23 | mCurrent = 0; | 25 | mCurrent = 0; |
24 | mMax = 0; | 26 | mMax = 0; |
25 | } | 27 | } |
26 | 28 | ||
27 | IMAPwrapper::~IMAPwrapper() | 29 | IMAPwrapper::~IMAPwrapper() |
28 | { | 30 | { |
29 | logout(); | 31 | logout(); |
30 | } | 32 | } |
31 | 33 | ||
32 | /* to avoid to often select statements in loops etc. | 34 | /* to avoid to often select statements in loops etc. |
33 | we trust that we are logged in and connection is established!*/ | 35 | we trust that we are logged in and connection is established!*/ |
@@ -218,49 +220,49 @@ void IMAPwrapper::login(bool tryTLS) // = true) | |||
218 | return; | 220 | return; |
219 | } | 221 | } |
220 | Global::statusMessage(i18n("error logging in imap server: %1").arg(m_imap->imap_response)); | 222 | Global::statusMessage(i18n("error logging in imap server: %1").arg(m_imap->imap_response)); |
221 | ok = false; | 223 | ok = false; |
222 | } | 224 | } |
223 | } | 225 | } |
224 | if (!ok) { | 226 | if (!ok) { |
225 | err = mailimap_close( m_imap ); | 227 | err = mailimap_close( m_imap ); |
226 | mailimap_free( m_imap ); | 228 | mailimap_free( m_imap ); |
227 | m_imap = 0; | 229 | m_imap = 0; |
228 | } | 230 | } |
229 | } | 231 | } |
230 | 232 | ||
231 | void IMAPwrapper::logout() | 233 | void IMAPwrapper::logout() |
232 | { | 234 | { |
233 | int err = MAILIMAP_NO_ERROR; | 235 | int err = MAILIMAP_NO_ERROR; |
234 | if (!m_imap) return; | 236 | if (!m_imap) return; |
235 | err = mailimap_logout( m_imap ); | 237 | err = mailimap_logout( m_imap ); |
236 | err = mailimap_close( m_imap ); | 238 | err = mailimap_close( m_imap ); |
237 | mailimap_free( m_imap ); | 239 | mailimap_free( m_imap ); |
238 | m_imap = 0; | 240 | m_imap = 0; |
239 | m_Lastmbox = ""; | 241 | m_Lastmbox = ""; |
240 | } | 242 | } |
241 | 243 | ||
242 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) | 244 | void IMAPwrapper::listMessages(const QString&mailbox,Q3ValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) |
243 | { | 245 | { |
244 | 246 | ||
245 | int tryAgain = 1; | 247 | int tryAgain = 1; |
246 | while ( tryAgain >= 0 ) { | 248 | while ( tryAgain >= 0 ) { |
247 | int err = MAILIMAP_NO_ERROR; | 249 | int err = MAILIMAP_NO_ERROR; |
248 | clist *result = 0; | 250 | clist *result = 0; |
249 | clistcell *current; | 251 | clistcell *current; |
250 | mailimap_fetch_type *fetchType = 0; | 252 | mailimap_fetch_type *fetchType = 0; |
251 | mailimap_set *set = 0; | 253 | mailimap_set *set = 0; |
252 | 254 | ||
253 | login(); | 255 | login(); |
254 | if (!m_imap) { | 256 | if (!m_imap) { |
255 | return; | 257 | return; |
256 | } | 258 | } |
257 | /* select mailbox READONLY for operations */ | 259 | /* select mailbox READONLY for operations */ |
258 | err = selectMbox(mailbox); | 260 | err = selectMbox(mailbox); |
259 | if ( err != MAILIMAP_NO_ERROR ) { | 261 | if ( err != MAILIMAP_NO_ERROR ) { |
260 | return; | 262 | return; |
261 | } | 263 | } |
262 | 264 | ||
263 | int last = m_imap->imap_selection_info->sel_exists; | 265 | int last = m_imap->imap_selection_info->sel_exists; |
264 | 266 | ||
265 | if (last == 0) { | 267 | if (last == 0) { |
266 | Global::statusMessage(i18n("Mailbox has no mails")); | 268 | Global::statusMessage(i18n("Mailbox has no mails")); |
@@ -299,58 +301,58 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma | |||
299 | RecMail*m = parse_list_result(msg_att); | 301 | RecMail*m = parse_list_result(msg_att); |
300 | if (m) { | 302 | if (m) { |
301 | if ( maxSizeInKb == 0 || m->Msgsize()<=(unsigned int ) maxSizeInKb*1024 ) { | 303 | if ( maxSizeInKb == 0 || m->Msgsize()<=(unsigned int ) maxSizeInKb*1024 ) { |
302 | m->setNumber(i); | 304 | m->setNumber(i); |
303 | m->setMbox(mailbox); | 305 | m->setMbox(mailbox); |
304 | m->setWrapper(this); | 306 | m->setWrapper(this); |
305 | target.append(m); | 307 | target.append(m); |
306 | } | 308 | } |
307 | } | 309 | } |
308 | } | 310 | } |
309 | Global::statusMessage(i18n("Mailbox has %1 mails").arg(target.count())); | 311 | Global::statusMessage(i18n("Mailbox has %1 mails").arg(target.count())); |
310 | } else { | 312 | } else { |
311 | --tryAgain; | 313 | --tryAgain; |
312 | --tryAgain;//disabled tryagain by adding this line | 314 | --tryAgain;//disabled tryagain by adding this line |
313 | if ( tryAgain < 0 ) | 315 | if ( tryAgain < 0 ) |
314 | Global::statusMessage(i18n("Error fetching headers: %1").arg(m_imap->imap_response)); | 316 | Global::statusMessage(i18n("Error fetching headers: %1").arg(m_imap->imap_response)); |
315 | else | 317 | else |
316 | qDebug("try again... "); | 318 | qDebug("try again... "); |
317 | } | 319 | } |
318 | 320 | ||
319 | if (result) mailimap_fetch_list_free(result); | 321 | if (result) mailimap_fetch_list_free(result); |
320 | } | 322 | } |
321 | } | 323 | } |
322 | 324 | ||
323 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | 325 | Q3ValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() |
324 | { | 326 | { |
325 | const char *path, *mask; | 327 | const char *path, *mask; |
326 | int err = MAILIMAP_NO_ERROR; | 328 | int err = MAILIMAP_NO_ERROR; |
327 | clist *result = 0; | 329 | clist *result = 0; |
328 | clistcell *current = 0; | 330 | clistcell *current = 0; |
329 | clistcell*cur_flag = 0; | 331 | clistcell*cur_flag = 0; |
330 | mailimap_mbx_list_flags*bflags = 0; | 332 | mailimap_mbx_list_flags*bflags = 0; |
331 | 333 | ||
332 | QValueList<FolderP>* folders = new QValueList<FolderP>(); | 334 | Q3ValueList<FolderP>* folders = new Q3ValueList<FolderP>(); |
333 | login(); | 335 | login(); |
334 | if (!m_imap) { | 336 | if (!m_imap) { |
335 | return folders; | 337 | return folders; |
336 | } | 338 | } |
337 | 339 | ||
338 | /* | 340 | /* |
339 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 341 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
340 | * We must not forget to filter them out in next loop! | 342 | * We must not forget to filter them out in next loop! |
341 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 343 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
342 | */ | 344 | */ |
343 | Global::statusMessage(i18n("Fetching folder list")); | 345 | Global::statusMessage(i18n("Fetching folder list")); |
344 | qApp->processEvents(); | 346 | qApp->processEvents(); |
345 | QString temp; | 347 | QString temp; |
346 | mask = "INBOX" ; | 348 | mask = "INBOX" ; |
347 | mailimap_mailbox_list *list; | 349 | mailimap_mailbox_list *list; |
348 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 350 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
349 | QString del; | 351 | QString del; |
350 | bool selectable = true; | 352 | bool selectable = true; |
351 | bool no_inferiors = false; | 353 | bool no_inferiors = false; |
352 | if ( err == MAILIMAP_NO_ERROR ) { | 354 | if ( err == MAILIMAP_NO_ERROR ) { |
353 | current = result->first; | 355 | current = result->first; |
354 | for ( int i = result->count; i > 0; i-- ) { | 356 | for ( int i = result->count; i > 0; i-- ) { |
355 | list = (mailimap_mailbox_list *) current->data; | 357 | list = (mailimap_mailbox_list *) current->data; |
356 | // it is better use the deep copy mechanism of qt itself | 358 | // it is better use the deep copy mechanism of qt itself |
@@ -592,49 +594,49 @@ RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) | |||
592 | 594 | ||
593 | mb = mail->getMbox().latin1(); | 595 | mb = mail->getMbox().latin1(); |
594 | 596 | ||
595 | login(); | 597 | login(); |
596 | if (!m_imap) { | 598 | if (!m_imap) { |
597 | return body; | 599 | return body; |
598 | } | 600 | } |
599 | err = selectMbox(mail->getMbox()); | 601 | err = selectMbox(mail->getMbox()); |
600 | if ( err != MAILIMAP_NO_ERROR ) { | 602 | if ( err != MAILIMAP_NO_ERROR ) { |
601 | return body; | 603 | return body; |
602 | } | 604 | } |
603 | 605 | ||
604 | /* the range has to start at 1!!! not with 0!!!! */ | 606 | /* the range has to start at 1!!! not with 0!!!! */ |
605 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); | 607 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); |
606 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 608 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
607 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 609 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
608 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 610 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
609 | mailimap_set_free( set ); | 611 | mailimap_set_free( set ); |
610 | mailimap_fetch_type_free( fetchType ); | 612 | mailimap_fetch_type_free( fetchType ); |
611 | 613 | ||
612 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 614 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
613 | mailimap_msg_att * msg_att; | 615 | mailimap_msg_att * msg_att; |
614 | msg_att = (mailimap_msg_att*)current->data; | 616 | msg_att = (mailimap_msg_att*)current->data; |
615 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 617 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
616 | QValueList<int> path; | 618 | Q3ValueList<int> path; |
617 | body_desc = item->att_data.att_static->att_data.att_body; | 619 | body_desc = item->att_data.att_static->att_data.att_body; |
618 | traverseBody(mail,body_desc,body,0,path); | 620 | traverseBody(mail,body_desc,body,0,path); |
619 | } else { | 621 | } else { |
620 | qDebug("error fetching body %d (%d): %s", err, MAILIMAP_NO_ERROR, m_imap->imap_response ); | 622 | qDebug("error fetching body %d (%d): %s", err, MAILIMAP_NO_ERROR, m_imap->imap_response ); |
621 | } | 623 | } |
622 | if (result) mailimap_fetch_list_free(result); | 624 | if (result) mailimap_fetch_list_free(result); |
623 | return body; | 625 | return body; |
624 | } | 626 | } |
625 | 627 | ||
626 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 628 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
627 | { | 629 | { |
628 | QStringList l; | 630 | QStringList l; |
629 | QString from; | 631 | QString from; |
630 | bool named_from; | 632 | bool named_from; |
631 | clistcell *current = NULL; | 633 | clistcell *current = NULL; |
632 | mailimap_address * current_address=NULL; | 634 | mailimap_address * current_address=NULL; |
633 | if (!list) { | 635 | if (!list) { |
634 | return l; | 636 | return l; |
635 | } | 637 | } |
636 | unsigned int count = 0; | 638 | unsigned int count = 0; |
637 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { | 639 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { |
638 | from = ""; | 640 | from = ""; |
639 | named_from = false; | 641 | named_from = false; |
640 | current_address=(mailimap_address*)current->data; | 642 | current_address=(mailimap_address*)current->data; |
@@ -643,49 +645,49 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | |||
643 | from+=" "; | 645 | from+=" "; |
644 | named_from = true; | 646 | named_from = true; |
645 | } | 647 | } |
646 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 648 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
647 | from+="<"; | 649 | from+="<"; |
648 | } | 650 | } |
649 | if (current_address->ad_mailbox_name) { | 651 | if (current_address->ad_mailbox_name) { |
650 | from+=QString(current_address->ad_mailbox_name); | 652 | from+=QString(current_address->ad_mailbox_name); |
651 | from+="@"; | 653 | from+="@"; |
652 | } | 654 | } |
653 | if (current_address->ad_host_name) { | 655 | if (current_address->ad_host_name) { |
654 | from+=QString(current_address->ad_host_name); | 656 | from+=QString(current_address->ad_host_name); |
655 | } | 657 | } |
656 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 658 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
657 | from+=">"; | 659 | from+=">"; |
658 | } | 660 | } |
659 | l.append(QString(from)); | 661 | l.append(QString(from)); |
660 | if (++count > 99) { | 662 | if (++count > 99) { |
661 | break; | 663 | break; |
662 | } | 664 | } |
663 | } | 665 | } |
664 | return l; | 666 | return l; |
665 | } | 667 | } |
666 | 668 | ||
667 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) | 669 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const Q3ValueList<int>&path,bool internal_call) |
668 | { | 670 | { |
669 | encodedString*res=new encodedString; | 671 | encodedString*res=new encodedString; |
670 | int err; | 672 | int err; |
671 | mailimap_fetch_type *fetchType; | 673 | mailimap_fetch_type *fetchType; |
672 | mailimap_set *set; | 674 | mailimap_set *set; |
673 | clistcell*current,*cur; | 675 | clistcell*current,*cur; |
674 | mailimap_section_part * section_part = 0; | 676 | mailimap_section_part * section_part = 0; |
675 | mailimap_section_spec * section_spec = 0; | 677 | mailimap_section_spec * section_spec = 0; |
676 | mailimap_section * section = 0; | 678 | mailimap_section * section = 0; |
677 | mailimap_fetch_att * fetch_att = 0; | 679 | mailimap_fetch_att * fetch_att = 0; |
678 | 680 | ||
679 | login(); | 681 | login(); |
680 | if (!m_imap) { | 682 | if (!m_imap) { |
681 | return res; | 683 | return res; |
682 | } | 684 | } |
683 | if (!internal_call) { | 685 | if (!internal_call) { |
684 | err = selectMbox(mail->getMbox()); | 686 | err = selectMbox(mail->getMbox()); |
685 | if ( err != MAILIMAP_NO_ERROR ) { | 687 | if ( err != MAILIMAP_NO_ERROR ) { |
686 | return res; | 688 | return res; |
687 | } | 689 | } |
688 | } | 690 | } |
689 | set = mailimap_set_new_single(mail->getNumber()); | 691 | set = mailimap_set_new_single(mail->getNumber()); |
690 | 692 | ||
691 | clist*id_list = 0; | 693 | clist*id_list = 0; |
@@ -717,57 +719,57 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int | |||
717 | mailimap_msg_att * msg_att; | 719 | mailimap_msg_att * msg_att; |
718 | msg_att = (mailimap_msg_att*)current->data; | 720 | msg_att = (mailimap_msg_att*)current->data; |
719 | mailimap_msg_att_item*msg_att_item; | 721 | mailimap_msg_att_item*msg_att_item; |
720 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | 722 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { |
721 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | 723 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); |
722 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | 724 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { |
723 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 725 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
724 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 726 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
725 | /* detach - we take over the content */ | 727 | /* detach - we take over the content */ |
726 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 728 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
727 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); | 729 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); |
728 | } | 730 | } |
729 | } | 731 | } |
730 | } | 732 | } |
731 | } else { | 733 | } else { |
732 | ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; | 734 | ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; |
733 | } | 735 | } |
734 | if (result) mailimap_fetch_list_free(result); | 736 | if (result) mailimap_fetch_list_free(result); |
735 | return res; | 737 | return res; |
736 | } | 738 | } |
737 | 739 | ||
738 | /* current_recursion is for recursive calls. | 740 | /* current_recursion is for recursive calls. |
739 | current_count means the position inside the internal loop! */ | 741 | current_count means the position inside the internal loop! */ |
740 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, | 742 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, |
741 | int current_recursion,QValueList<int>recList,int current_count) | 743 | int current_recursion,Q3ValueList<int>recList,int current_count) |
742 | { | 744 | { |
743 | if (!body || current_recursion>=10) { | 745 | if (!body || current_recursion>=10) { |
744 | return; | 746 | return; |
745 | } | 747 | } |
746 | switch (body->bd_type) { | 748 | switch (body->bd_type) { |
747 | case MAILIMAP_BODY_1PART: | 749 | case MAILIMAP_BODY_1PART: |
748 | { | 750 | { |
749 | QValueList<int>countlist = recList; | 751 | Q3ValueList<int>countlist = recList; |
750 | countlist.append(current_count); | 752 | countlist.append(current_count); |
751 | RecPartP currentPart = new RecPart(); | 753 | RecPartP currentPart = new RecPart(); |
752 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; | 754 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; |
753 | QString id(""); | 755 | QString id(""); |
754 | currentPart->setPositionlist(countlist); | 756 | currentPart->setPositionlist(countlist); |
755 | for (unsigned int j = 0; j < countlist.count();++j) { | 757 | for (unsigned int j = 0; j < countlist.count();++j) { |
756 | id+=(j>0?" ":""); | 758 | id+=(j>0?" ":""); |
757 | id+=QString("%1").arg(countlist[j]); | 759 | id+=QString("%1").arg(countlist[j]); |
758 | } | 760 | } |
759 | //odebug << "ID = " << id.latin1() << "" << oendl; | 761 | //odebug << "ID = " << id.latin1() << "" << oendl; |
760 | currentPart->setIdentifier(id); | 762 | currentPart->setIdentifier(id); |
761 | fillSinglePart(currentPart,part1); | 763 | fillSinglePart(currentPart,part1); |
762 | /* important: Check for is NULL 'cause a body can be empty! | 764 | /* important: Check for is NULL 'cause a body can be empty! |
763 | And we put it only into the mail if it is the FIRST part */ | 765 | And we put it only into the mail if it is the FIRST part */ |
764 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { | 766 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { |
765 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); | 767 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); |
766 | 768 | ||
767 | size_t index = 0; | 769 | size_t index = 0; |
768 | char*res = 0; | 770 | char*res = 0; |
769 | int err = MAILIMF_NO_ERROR; | 771 | int err = MAILIMF_NO_ERROR; |
770 | 772 | ||
771 | QString charset = currentPart->searchParamter( "charset"); | 773 | QString charset = currentPart->searchParamter( "charset"); |
772 | qDebug("CHARSET %s ",charset.latin1() ); | 774 | qDebug("CHARSET %s ",charset.latin1() ); |
773 | if ( false ) { | 775 | if ( false ) { |
@@ -778,49 +780,49 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&t | |||
778 | err = mailmime_encoded_phrase_parse(charset.latin1(), | 780 | err = mailmime_encoded_phrase_parse(charset.latin1(), |
779 | body_text.latin1(), body_text.length(),&index, "utf-8",&res); | 781 | body_text.latin1(), body_text.length(),&index, "utf-8",&res); |
780 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { | 782 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { |
781 | //qDebug("res %d %s ", index, res); | 783 | //qDebug("res %d %s ", index, res); |
782 | body_text = QString::fromUtf8(res); | 784 | body_text = QString::fromUtf8(res); |
783 | } | 785 | } |
784 | if (res) free(res); | 786 | if (res) free(res); |
785 | } | 787 | } |
786 | //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() ); | 788 | //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() ); |
787 | target_body->setDescription(currentPart); | 789 | target_body->setDescription(currentPart); |
788 | target_body->setBodytext(body_text); | 790 | target_body->setBodytext(body_text); |
789 | if (countlist.count()>1) { | 791 | if (countlist.count()>1) { |
790 | target_body->addPart(currentPart); | 792 | target_body->addPart(currentPart); |
791 | } | 793 | } |
792 | } else { | 794 | } else { |
793 | target_body->addPart(currentPart); | 795 | target_body->addPart(currentPart); |
794 | } | 796 | } |
795 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { | 797 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { |
796 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); | 798 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); |
797 | } | 799 | } |
798 | } | 800 | } |
799 | break; | 801 | break; |
800 | case MAILIMAP_BODY_MPART: | 802 | case MAILIMAP_BODY_MPART: |
801 | { | 803 | { |
802 | QValueList<int>countlist = recList; | 804 | Q3ValueList<int>countlist = recList; |
803 | clistcell*current=0; | 805 | clistcell*current=0; |
804 | mailimap_body*current_body=0; | 806 | mailimap_body*current_body=0; |
805 | unsigned int ccount = 1; | 807 | unsigned int ccount = 1; |
806 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; | 808 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; |
807 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { | 809 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { |
808 | current_body = (mailimap_body*)current->data; | 810 | current_body = (mailimap_body*)current->data; |
809 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 811 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
810 | RecPartP targetPart = new RecPart(); | 812 | RecPartP targetPart = new RecPart(); |
811 | targetPart->setType("multipart"); | 813 | targetPart->setType("multipart"); |
812 | fillMultiPart(targetPart,mailDescription); | 814 | fillMultiPart(targetPart,mailDescription); |
813 | countlist.append(current_count); | 815 | countlist.append(current_count); |
814 | targetPart->setPositionlist(countlist); | 816 | targetPart->setPositionlist(countlist); |
815 | target_body->addPart(targetPart); | 817 | target_body->addPart(targetPart); |
816 | QString id(""); | 818 | QString id(""); |
817 | for (unsigned int j = 0; j < countlist.count();++j) { | 819 | for (unsigned int j = 0; j < countlist.count();++j) { |
818 | id+=(j>0?" ":""); | 820 | id+=(j>0?" ":""); |
819 | id+=QString("%1").arg(countlist[j]); | 821 | id+=QString("%1").arg(countlist[j]); |
820 | } | 822 | } |
821 | // odebug << "ID(mpart) = " << id.latin1() << "" << oendl; | 823 | // odebug << "ID(mpart) = " << id.latin1() << "" << oendl; |
822 | } | 824 | } |
823 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); | 825 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); |
824 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 826 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
825 | countlist = recList; | 827 | countlist = recList; |
826 | } | 828 | } |
@@ -964,69 +966,69 @@ void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which | |||
964 | case MAILIMAP_BODY_FLD_ENC_BINARY: | 966 | case MAILIMAP_BODY_FLD_ENC_BINARY: |
965 | encoding="binary"; | 967 | encoding="binary"; |
966 | break; | 968 | break; |
967 | case MAILIMAP_BODY_FLD_ENC_BASE64: | 969 | case MAILIMAP_BODY_FLD_ENC_BASE64: |
968 | encoding="base64"; | 970 | encoding="base64"; |
969 | break; | 971 | break; |
970 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: | 972 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: |
971 | encoding="quoted-printable"; | 973 | encoding="quoted-printable"; |
972 | break; | 974 | break; |
973 | case MAILIMAP_BODY_FLD_ENC_OTHER: | 975 | case MAILIMAP_BODY_FLD_ENC_OTHER: |
974 | default: | 976 | default: |
975 | if (enc->enc_value) { | 977 | if (enc->enc_value) { |
976 | char*t=enc->enc_value; | 978 | char*t=enc->enc_value; |
977 | encoding=QString(enc->enc_value); | 979 | encoding=QString(enc->enc_value); |
978 | enc->enc_value=0L; | 980 | enc->enc_value=0L; |
979 | free(t); | 981 | free(t); |
980 | } | 982 | } |
981 | } | 983 | } |
982 | if (which->bd_description) { | 984 | if (which->bd_description) { |
983 | target_part->setDescription(QString(which->bd_description)); | 985 | target_part->setDescription(QString(which->bd_description)); |
984 | } | 986 | } |
985 | target_part->setEncoding(encoding); | 987 | target_part->setEncoding(encoding); |
986 | target_part->setSize(which->bd_size); | 988 | target_part->setSize(which->bd_size); |
987 | } | 989 | } |
988 | void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) | 990 | void IMAPwrapper::deleteMailList(const Q3ValueList<RecMailP>&target) |
989 | { | 991 | { |
990 | //#if 0 | 992 | //#if 0 |
991 | mailimap_flag_list*flist; | 993 | mailimap_flag_list*flist; |
992 | mailimap_set *set; | 994 | mailimap_set *set; |
993 | mailimap_store_att_flags * store_flags; | 995 | mailimap_store_att_flags * store_flags; |
994 | int err; | 996 | int err; |
995 | login(); | 997 | login(); |
996 | //#endif | 998 | //#endif |
997 | if (!m_imap) { | 999 | if (!m_imap) { |
998 | return; | 1000 | return; |
999 | } | 1001 | } |
1000 | int iii = 0; | 1002 | int iii = 0; |
1001 | int count = target.count(); | 1003 | int count = target.count(); |
1002 | // qDebug("imap remove count %d ", count); | 1004 | // qDebug("imap remove count %d ", count); |
1003 | 1005 | ||
1004 | 1006 | ||
1005 | mMax = count; | 1007 | mMax = count; |
1006 | progress( i18n("Delete")); | 1008 | progress( i18n("Delete")); |
1007 | 1009 | ||
1008 | QProgressBar wid ( count ); | 1010 | Q3ProgressBar wid ( count ); |
1009 | wid.setCaption( i18n("Deleting ...")); | 1011 | wid.setCaption( i18n("Deleting ...")); |
1010 | wid.show(); | 1012 | wid.show(); |
1011 | while (iii < count ) { | 1013 | while (iii < count ) { |
1012 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); | 1014 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); |
1013 | wid.setProgress( iii ); | 1015 | wid.setProgress( iii ); |
1014 | wid.raise(); | 1016 | wid.raise(); |
1015 | qApp->processEvents(); | 1017 | qApp->processEvents(); |
1016 | RecMailP mail = (*target.at( iii )); | 1018 | RecMailP mail = (*target.at( iii )); |
1017 | //#if 0 | 1019 | //#if 0 |
1018 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); | 1020 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); |
1019 | err = selectMbox(mail->getMbox()); | 1021 | err = selectMbox(mail->getMbox()); |
1020 | if ( err != MAILIMAP_NO_ERROR ) { | 1022 | if ( err != MAILIMAP_NO_ERROR ) { |
1021 | return; | 1023 | return; |
1022 | } | 1024 | } |
1023 | flist = mailimap_flag_list_new_empty(); | 1025 | flist = mailimap_flag_list_new_empty(); |
1024 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 1026 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
1025 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 1027 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
1026 | set = mailimap_set_new_single(mail->getNumber()); | 1028 | set = mailimap_set_new_single(mail->getNumber()); |
1027 | err = mailimap_store(m_imap,set,store_flags); | 1029 | err = mailimap_store(m_imap,set,store_flags); |
1028 | mailimap_set_free( set ); | 1030 | mailimap_set_free( set ); |
1029 | mailimap_store_att_flags_free(store_flags); | 1031 | mailimap_store_att_flags_free(store_flags); |
1030 | 1032 | ||
1031 | if (err != MAILIMAP_NO_ERROR) { | 1033 | if (err != MAILIMAP_NO_ERROR) { |
1032 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 1034 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
@@ -1093,49 +1095,49 @@ void IMAPwrapper::answeredMail(const RecMailP&mail) | |||
1093 | mailimap_store_att_flags * store_flags; | 1095 | mailimap_store_att_flags * store_flags; |
1094 | int err; | 1096 | int err; |
1095 | login(); | 1097 | login(); |
1096 | if (!m_imap) { | 1098 | if (!m_imap) { |
1097 | return; | 1099 | return; |
1098 | } | 1100 | } |
1099 | err = selectMbox(mail->getMbox()); | 1101 | err = selectMbox(mail->getMbox()); |
1100 | if ( err != MAILIMAP_NO_ERROR ) { | 1102 | if ( err != MAILIMAP_NO_ERROR ) { |
1101 | return; | 1103 | return; |
1102 | } | 1104 | } |
1103 | flist = mailimap_flag_list_new_empty(); | 1105 | flist = mailimap_flag_list_new_empty(); |
1104 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); | 1106 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); |
1105 | store_flags = mailimap_store_att_flags_new_add_flags(flist); | 1107 | store_flags = mailimap_store_att_flags_new_add_flags(flist); |
1106 | set = mailimap_set_new_single(mail->getNumber()); | 1108 | set = mailimap_set_new_single(mail->getNumber()); |
1107 | err = mailimap_store(m_imap,set,store_flags); | 1109 | err = mailimap_store(m_imap,set,store_flags); |
1108 | mailimap_set_free( set ); | 1110 | mailimap_set_free( set ); |
1109 | mailimap_store_att_flags_free(store_flags); | 1111 | mailimap_store_att_flags_free(store_flags); |
1110 | 1112 | ||
1111 | if (err != MAILIMAP_NO_ERROR) { | 1113 | if (err != MAILIMAP_NO_ERROR) { |
1112 | // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; | 1114 | // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; |
1113 | return; | 1115 | return; |
1114 | } | 1116 | } |
1115 | } | 1117 | } |
1116 | 1118 | ||
1117 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | 1119 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const Q3ValueList<int>&path,bool internal_call,const QString&enc) |
1118 | { | 1120 | { |
1119 | QString body(""); | 1121 | QString body(""); |
1120 | encodedString*res = fetchRawPart(mail,path,internal_call); | 1122 | encodedString*res = fetchRawPart(mail,path,internal_call); |
1121 | encodedString*r = decode_String(res,enc); | 1123 | encodedString*r = decode_String(res,enc); |
1122 | delete res; | 1124 | delete res; |
1123 | if (r) { | 1125 | if (r) { |
1124 | if (r->Length()>0) { | 1126 | if (r->Length()>0) { |
1125 | body = r->Content(); | 1127 | body = r->Content(); |
1126 | } | 1128 | } |
1127 | delete r; | 1129 | delete r; |
1128 | } | 1130 | } |
1129 | return body; | 1131 | return body; |
1130 | } | 1132 | } |
1131 | 1133 | ||
1132 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) | 1134 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) |
1133 | { | 1135 | { |
1134 | return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); | 1136 | return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); |
1135 | } | 1137 | } |
1136 | 1138 | ||
1137 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) | 1139 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) |
1138 | { | 1140 | { |
1139 | encodedString*res = fetchRawPart(mail,part->Positionlist(),false); | 1141 | encodedString*res = fetchRawPart(mail,part->Positionlist(),false); |
1140 | encodedString*r = decode_String(res,part->Encoding()); | 1142 | encodedString*r = decode_String(res,part->Encoding()); |
1141 | delete res; | 1143 | delete res; |
@@ -1278,49 +1280,49 @@ void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folde | |||
1278 | { | 1280 | { |
1279 | login(); | 1281 | login(); |
1280 | if (!m_imap) return; | 1282 | if (!m_imap) return; |
1281 | if (!msg) return; | 1283 | if (!msg) return; |
1282 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); | 1284 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); |
1283 | if (r != MAILIMAP_NO_ERROR) { | 1285 | if (r != MAILIMAP_NO_ERROR) { |
1284 | Global::statusMessage("Error storing mail!"); | 1286 | Global::statusMessage("Error storing mail!"); |
1285 | } | 1287 | } |
1286 | } | 1288 | } |
1287 | 1289 | ||
1288 | MAILLIB::ATYPE IMAPwrapper::getType()const | 1290 | MAILLIB::ATYPE IMAPwrapper::getType()const |
1289 | { | 1291 | { |
1290 | return account->getType(); | 1292 | return account->getType(); |
1291 | } | 1293 | } |
1292 | 1294 | ||
1293 | const QString&IMAPwrapper::getName()const | 1295 | const QString&IMAPwrapper::getName()const |
1294 | { | 1296 | { |
1295 | // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; | 1297 | // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; |
1296 | return account->getAccountName(); | 1298 | return account->getAccountName(); |
1297 | } | 1299 | } |
1298 | 1300 | ||
1299 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) | 1301 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) |
1300 | { | 1302 | { |
1301 | // dummy | 1303 | // dummy |
1302 | QValueList<int> path; | 1304 | Q3ValueList<int> path; |
1303 | return fetchRawPart(mail,path,false); | 1305 | return fetchRawPart(mail,path,false); |
1304 | } | 1306 | } |
1305 | 1307 | ||
1306 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, | 1308 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, |
1307 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) | 1309 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) |
1308 | { | 1310 | { |
1309 | if (targetWrapper != this || maxSizeInKb > 0 ) { | 1311 | if (targetWrapper != this || maxSizeInKb > 0 ) { |
1310 | mMax = 0; | 1312 | mMax = 0; |
1311 | progress( i18n("Copy")); | 1313 | progress( i18n("Copy")); |
1312 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); | 1314 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); |
1313 | //qDebug("IMAPwrapper::mvcpAllMails::Using generic"); | 1315 | //qDebug("IMAPwrapper::mvcpAllMails::Using generic"); |
1314 | // odebug << "Using generic" << oendl; | 1316 | // odebug << "Using generic" << oendl; |
1315 | return; | 1317 | return; |
1316 | } | 1318 | } |
1317 | mailimap_set *set = 0; | 1319 | mailimap_set *set = 0; |
1318 | login(); | 1320 | login(); |
1319 | if (!m_imap) { | 1321 | if (!m_imap) { |
1320 | return; | 1322 | return; |
1321 | } | 1323 | } |
1322 | int err = selectMbox(fromFolder->getName()); | 1324 | int err = selectMbox(fromFolder->getName()); |
1323 | if ( err != MAILIMAP_NO_ERROR ) { | 1325 | if ( err != MAILIMAP_NO_ERROR ) { |
1324 | return; | 1326 | return; |
1325 | } | 1327 | } |
1326 | Global::statusMessage( i18n("Copying mails on server...") ); | 1328 | Global::statusMessage( i18n("Copying mails on server...") ); |
diff --git a/kmicromail/libmailwrapper/imapwrapper.h b/kmicromail/libmailwrapper/imapwrapper.h index 31c60a8..d3d3ecd 100644 --- a/kmicromail/libmailwrapper/imapwrapper.h +++ b/kmicromail/libmailwrapper/imapwrapper.h | |||
@@ -1,85 +1,87 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef __IMAPWRAPPER | 2 | #ifndef __IMAPWRAPPER |
3 | #define __IMAPWRAPPER | 3 | #define __IMAPWRAPPER |
4 | 4 | ||
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | //Added by qt3to4: | ||
7 | #include <Q3ValueList> | ||
6 | #include "mailwrapper.h" | 8 | #include "mailwrapper.h" |
7 | #include "abstractmail.h" | 9 | #include "abstractmail.h" |
8 | #include <libetpan/clist.h> | 10 | #include <libetpan/clist.h> |
9 | 11 | ||
10 | struct mailimap; | 12 | struct mailimap; |
11 | struct mailimap_body; | 13 | struct mailimap_body; |
12 | struct mailimap_body_type_1part; | 14 | struct mailimap_body_type_1part; |
13 | struct mailimap_body_type_text; | 15 | struct mailimap_body_type_text; |
14 | struct mailimap_body_type_basic; | 16 | struct mailimap_body_type_basic; |
15 | struct mailimap_body_type_msg; | 17 | struct mailimap_body_type_msg; |
16 | struct mailimap_body_type_mpart; | 18 | struct mailimap_body_type_mpart; |
17 | struct mailimap_body_fields; | 19 | struct mailimap_body_fields; |
18 | struct mailimap_msg_att; | 20 | struct mailimap_msg_att; |
19 | class encodedString; | 21 | class encodedString; |
20 | 22 | ||
21 | class IMAPwrapper : public AbstractMail | 23 | class IMAPwrapper : public AbstractMail |
22 | { | 24 | { |
23 | Q_OBJECT | 25 | Q_OBJECT |
24 | public: | 26 | public: |
25 | IMAPwrapper( IMAPaccount *a ); | 27 | IMAPwrapper( IMAPaccount *a ); |
26 | virtual ~IMAPwrapper(); | 28 | virtual ~IMAPwrapper(); |
27 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 29 | virtual Q3ValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
28 | virtual void listMessages(const QString & mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> >&target , int sizeInKb = 0); | 30 | virtual void listMessages(const QString & mailbox,Q3ValueList<Opie::Core::OSmartPointer<RecMail> >&target , int sizeInKb = 0); |
29 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 31 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
30 | 32 | ||
31 | virtual void deleteMail(const RecMailP&mail); | 33 | virtual void deleteMail(const RecMailP&mail); |
32 | void deleteMailList(const QValueList<RecMailP>&target); | 34 | void deleteMailList(const Q3ValueList<RecMailP>&target); |
33 | virtual void answeredMail(const RecMailP&mail); | 35 | virtual void answeredMail(const RecMailP&mail); |
34 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&folder); | 36 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&folder); |
35 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 37 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
36 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, | 38 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, |
37 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit,int sizeInKb = 0); | 39 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit,int sizeInKb = 0); |
38 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 40 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
39 | 41 | ||
40 | virtual RecBodyP fetchBody(const RecMailP&mail); | 42 | virtual RecBodyP fetchBody(const RecMailP&mail); |
41 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); | 43 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); |
42 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); | 44 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); |
43 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); | 45 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); |
44 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 46 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
45 | 47 | ||
46 | virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, | 48 | virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, |
47 | const QString& delemiter="/",bool getsubfolder=false); | 49 | const QString& delemiter="/",bool getsubfolder=false); |
48 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&folder); | 50 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&folder); |
49 | 51 | ||
50 | static void imap_progress( size_t current, size_t maximum ); | 52 | static void imap_progress( size_t current, size_t maximum ); |
51 | 53 | ||
52 | virtual void logout(); | 54 | virtual void logout(); |
53 | virtual MAILLIB::ATYPE getType()const; | 55 | virtual MAILLIB::ATYPE getType()const; |
54 | virtual const QString&getName()const; | 56 | virtual const QString&getName()const; |
55 | virtual Account* getAccount() { return account; }; | 57 | virtual Account* getAccount() { return account; }; |
56 | 58 | ||
57 | protected: | 59 | protected: |
58 | RecMail*parse_list_result(mailimap_msg_att*); | 60 | RecMail*parse_list_result(mailimap_msg_att*); |
59 | void login(bool tryTLS = true); | 61 | void login(bool tryTLS = true); |
60 | bool start_tls(bool force=true); | 62 | bool start_tls(bool force=true); |
61 | 63 | ||
62 | virtual QString fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); | 64 | virtual QString fetchTextPart(const RecMailP&mail,const Q3ValueList<int>&path,bool internal_call=false,const QString&enc=""); |
63 | virtual encodedString*fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call); | 65 | virtual encodedString*fetchRawPart(const RecMailP&mail,const Q3ValueList<int>&path,bool internal_call); |
64 | int selectMbox(const QString&mbox); | 66 | int selectMbox(const QString&mbox); |
65 | 67 | ||
66 | void fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description); | 68 | void fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description); |
67 | void fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which); | 69 | void fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which); |
68 | void fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which); | 70 | void fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which); |
69 | void fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which); | 71 | void fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which); |
70 | void fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which); | 72 | void fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which); |
71 | void traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body,int current_recursion,QValueList<int>recList,int current_count=1); | 73 | void traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body,int current_recursion,Q3ValueList<int>recList,int current_count=1); |
72 | 74 | ||
73 | /* just helpers */ | 75 | /* just helpers */ |
74 | static void fillBodyFields(RecPartP&target_part,mailimap_body_fields*which); | 76 | static void fillBodyFields(RecPartP&target_part,mailimap_body_fields*which); |
75 | static QStringList address_list_to_stringlist(clist*list); | 77 | static QStringList address_list_to_stringlist(clist*list); |
76 | 78 | ||
77 | static void progress(QString mess = QString::null); | 79 | static void progress(QString mess = QString::null); |
78 | static int mCurrent; | 80 | static int mCurrent; |
79 | static int mMax; | 81 | static int mMax; |
80 | IMAPaccount *account; | 82 | IMAPaccount *account; |
81 | mailimap *m_imap; | 83 | mailimap *m_imap; |
82 | QString m_Lastmbox; | 84 | QString m_Lastmbox; |
83 | }; | 85 | }; |
84 | 86 | ||
85 | #endif | 87 | #endif |
diff --git a/kmicromail/libmailwrapper/libmailwrapper.pro b/kmicromail/libmailwrapper/libmailwrapper.pro index 646630b..6b595ab 100644 --- a/kmicromail/libmailwrapper/libmailwrapper.pro +++ b/kmicromail/libmailwrapper/libmailwrapper.pro | |||
@@ -17,49 +17,55 @@ HEADERS = mailwrapper.h \ | |||
17 | nntpwrapper.h \ | 17 | nntpwrapper.h \ |
18 | generatemail.h \ | 18 | generatemail.h \ |
19 | storemail.h \ | 19 | storemail.h \ |
20 | ../qpe/global.h | 20 | ../qpe/global.h |
21 | 21 | ||
22 | SOURCES = imapwrapper.cpp \ | 22 | SOURCES = imapwrapper.cpp \ |
23 | mailwrapper.cpp \ | 23 | mailwrapper.cpp \ |
24 | mailtypes.cpp \ | 24 | mailtypes.cpp \ |
25 | pop3wrapper.cpp \ | 25 | pop3wrapper.cpp \ |
26 | abstractmail.cpp \ | 26 | abstractmail.cpp \ |
27 | smtpwrapper.cpp \ | 27 | smtpwrapper.cpp \ |
28 | genericwrapper.cpp \ | 28 | genericwrapper.cpp \ |
29 | mboxwrapper.cpp \ | 29 | mboxwrapper.cpp \ |
30 | settings.cpp \ | 30 | settings.cpp \ |
31 | logindialog.cpp \ | 31 | logindialog.cpp \ |
32 | sendmailprogress.cpp \ | 32 | sendmailprogress.cpp \ |
33 | statusmail.cpp \ | 33 | statusmail.cpp \ |
34 | mhwrapper.cpp \ | 34 | mhwrapper.cpp \ |
35 | nntpwrapper.cpp \ | 35 | nntpwrapper.cpp \ |
36 | generatemail.cpp \ | 36 | generatemail.cpp \ |
37 | storemail.cpp \ | 37 | storemail.cpp \ |
38 | ../qpe/qdialog_hacked.cpp \ | 38 | ../qpe/qdialog_hacked.cpp \ |
39 | ../qpe/global.cpp | 39 | ../qpe/global.cpp |
40 | 40 | ||
41 | INTERFACES = logindialogui.ui \ | 41 | #The following line was changed from INTERFACES to FORMS3 by qt3to4 |
42 | FORMS3 = logindialogui.ui \ | ||
42 | sendmailprogressui.ui | 43 | sendmailprogressui.ui |
43 | 44 | ||
44 | INCLUDEPATH += ../qpe .. ../../microkde ../../microkde/kdecore ../../libetpan/include | 45 | INCLUDEPATH += ../qpe .. ../../microkde ../../microkde/kdecore ../../libetpan/include |
45 | LIBS += -lssl -lcrypto | 46 | LIBS += -lssl -lcrypto |
46 | 47 | ||
47 | #-lqpe -letpan | 48 | #-lqpe -letpan |
48 | 49 | ||
49 | DESTDIR = ../../bin | 50 | DESTDIR = ../../bin |
50 | TARGET = micromailwrapper | 51 | TARGET = micromailwrapper |
51 | 52 | ||
52 | DEFINES += DESKTOP_VERSION | 53 | DEFINES += DESKTOP_VERSION |
53 | unix : { | 54 | unix : { |
54 | OBJECTS_DIR = obj/unix | 55 | OBJECTS_DIR = obj/unix |
55 | MOC_DIR = moc/unix | 56 | MOC_DIR = moc/unix |
56 | } | 57 | } |
57 | win32: { | 58 | win32: { |
58 | DEFINES += _WIN32_ | 59 | DEFINES += _WIN32_ |
59 | LIBS += mfc71u.lib | 60 | LIBS += mfc71u.lib |
60 | QMAKE_LINK += /NODEFAULTLIB:LIBC | 61 | QMAKE_LINK += /NODEFAULTLIB:LIBC |
61 | #QMAKE_LINK += /NODEFAULTLIB:MSVCRT | 62 | #QMAKE_LINK += /NODEFAULTLIB:MSVCRT |
62 | #QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib | 63 | #QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib |
63 | OBJECTS_DIR = obj/win | 64 | OBJECTS_DIR = obj/win |
64 | MOC_DIR = moc/win | 65 | MOC_DIR = moc/win |
65 | } | 66 | } |
67 | #The following line was inserted by qt3to4 | ||
68 | QT += xml qt3support | ||
69 | #The following line was inserted by qt3to4 | ||
70 | CONFIG += uic3 | ||
71 | |||
diff --git a/kmicromail/libmailwrapper/logindialog.cpp b/kmicromail/libmailwrapper/logindialog.cpp index 31b75d0..d1f4b5d 100644 --- a/kmicromail/libmailwrapper/logindialog.cpp +++ b/kmicromail/libmailwrapper/logindialog.cpp | |||
@@ -1,33 +1,33 @@ | |||
1 | #include <qlineedit.h> | 1 | #include <qlineedit.h> |
2 | 2 | ||
3 | #include "logindialog.h" | 3 | #include "logindialog.h" |
4 | 4 | ||
5 | 5 | ||
6 | 6 | ||
7 | //using namespace Opie::Core; | 7 | //using namespace Opie::Core; |
8 | 8 | ||
9 | LoginDialog::LoginDialog(const QString&user,const QString&pass, QWidget *parent, const char *name, bool modal, WFlags flags ) | 9 | LoginDialog::LoginDialog(const QString&user,const QString&pass, QWidget *parent, const char *name, bool modal, Qt::WFlags flags ) |
10 | : LoginDialogUI( parent, name, modal, flags ) | 10 | : LoginDialogUI( parent, name, modal, flags ) |
11 | { | 11 | { |
12 | userLine->setText( (user.isEmpty()?QString(""):user) ); | 12 | userLine->setText( (user.isEmpty()?QString(""):user) ); |
13 | passLine->setText( (pass.isEmpty()?QString(""):pass) ); | 13 | passLine->setText( (pass.isEmpty()?QString(""):pass) ); |
14 | _user = user; | 14 | _user = user; |
15 | _pass = pass; | 15 | _pass = pass; |
16 | 16 | ||
17 | if ( user.isEmpty() ) { | 17 | if ( user.isEmpty() ) { |
18 | userLine->setFocus(); | 18 | userLine->setFocus(); |
19 | } else { | 19 | } else { |
20 | passLine->setFocus(); | 20 | passLine->setFocus(); |
21 | } | 21 | } |
22 | } | 22 | } |
23 | 23 | ||
24 | void LoginDialog::accept() | 24 | void LoginDialog::accept() |
25 | { | 25 | { |
26 | //_user.replace( 0, _user.length(), userLine->text() ); | 26 | //_user.replace( 0, _user.length(), userLine->text() ); |
27 | //_pass.replace( 0, _pass.length(), passLine->text() ); | 27 | //_pass.replace( 0, _pass.length(), passLine->text() ); |
28 | _user = userLine->text(); | 28 | _user = userLine->text(); |
29 | _pass = passLine->text(); | 29 | _pass = passLine->text(); |
30 | 30 | ||
31 | //odebug << "User im accept: |" << _user.latin1() << "|" << oendl; | 31 | //odebug << "User im accept: |" << _user.latin1() << "|" << oendl; |
32 | QDialog::accept(); | 32 | QDialog::accept(); |
33 | } | 33 | } |
diff --git a/kmicromail/libmailwrapper/logindialog.h b/kmicromail/libmailwrapper/logindialog.h index f406f2c..a18daa5 100644 --- a/kmicromail/libmailwrapper/logindialog.h +++ b/kmicromail/libmailwrapper/logindialog.h | |||
@@ -1,23 +1,23 @@ | |||
1 | #ifndef LOGINDIALOG_H | 1 | #ifndef LOGINDIALOG_H |
2 | #define LOGINDIALOG_H | 2 | #define LOGINDIALOG_H |
3 | 3 | ||
4 | #include "logindialogui.h" | 4 | #include "logindialogui.h" |
5 | 5 | ||
6 | class LoginDialog : public LoginDialogUI | 6 | class LoginDialog : public LoginDialogUI |
7 | { | 7 | { |
8 | Q_OBJECT | 8 | Q_OBJECT |
9 | 9 | ||
10 | public: | 10 | public: |
11 | LoginDialog(const QString&user,const QString&pass, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); | 11 | LoginDialog(const QString&user,const QString&pass, QWidget *parent = 0, const char *name = 0, bool modal = false, Qt::WFlags flags = 0 ); |
12 | QString getUser() { return _user; } | 12 | QString getUser() { return _user; } |
13 | QString getPassword() { return _pass; } | 13 | QString getPassword() { return _pass; } |
14 | 14 | ||
15 | protected slots: | 15 | protected slots: |
16 | void accept(); | 16 | void accept(); |
17 | 17 | ||
18 | private: | 18 | private: |
19 | QString _user, _pass; | 19 | QString _user, _pass; |
20 | 20 | ||
21 | }; | 21 | }; |
22 | 22 | ||
23 | #endif | 23 | #endif |
diff --git a/kmicromail/libmailwrapper/mailtypes.cpp b/kmicromail/libmailwrapper/mailtypes.cpp index 70a0ab5..84ccf9f 100644 --- a/kmicromail/libmailwrapper/mailtypes.cpp +++ b/kmicromail/libmailwrapper/mailtypes.cpp | |||
@@ -1,29 +1,31 @@ | |||
1 | #include "mailtypes.h" | 1 | #include "mailtypes.h" |
2 | 2 | ||
3 | //#include <opie2/odebug.h> | 3 | //#include <opie2/odebug.h> |
4 | 4 | ||
5 | #include <stdlib.h> | 5 | #include <stdlib.h> |
6 | //Added by qt3to4: | ||
7 | #include <Q3ValueList> | ||
6 | 8 | ||
7 | using namespace Opie::Core; | 9 | using namespace Opie::Core; |
8 | RecMail::RecMail() | 10 | RecMail::RecMail() |
9 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) | 11 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) |
10 | { | 12 | { |
11 | init(); | 13 | init(); |
12 | } | 14 | } |
13 | 15 | ||
14 | RecMail::RecMail(const RecMail&old) | 16 | RecMail::RecMail(const RecMail&old) |
15 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) | 17 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) |
16 | { | 18 | { |
17 | init(); | 19 | init(); |
18 | copy_old(old); | 20 | copy_old(old); |
19 | // odebug << "Copy constructor RecMail" << oendl; | 21 | // odebug << "Copy constructor RecMail" << oendl; |
20 | } | 22 | } |
21 | 23 | ||
22 | RecMail::~RecMail() | 24 | RecMail::~RecMail() |
23 | { | 25 | { |
24 | wrapper = 0; | 26 | wrapper = 0; |
25 | } | 27 | } |
26 | static bool stringCompareRec( const QString& s1, const QString& s2 ) | 28 | static bool stringCompareRec( const QString& s1, const QString& s2 ) |
27 | { | 29 | { |
28 | if ( s1.isEmpty() && s2.isEmpty() ) | 30 | if ( s1.isEmpty() && s2.isEmpty() ) |
29 | return true; | 31 | return true; |
@@ -262,95 +264,95 @@ void RecPart::setParameters(const part_plist_t&list) | |||
262 | { | 264 | { |
263 | m_Parameters = list; | 265 | m_Parameters = list; |
264 | } | 266 | } |
265 | 267 | ||
266 | const part_plist_t& RecPart::Parameters()const | 268 | const part_plist_t& RecPart::Parameters()const |
267 | { | 269 | { |
268 | return m_Parameters; | 270 | return m_Parameters; |
269 | } | 271 | } |
270 | 272 | ||
271 | void RecPart::addParameter(const QString&key,const QString&value) | 273 | void RecPart::addParameter(const QString&key,const QString&value) |
272 | { | 274 | { |
273 | m_Parameters[key]=value; | 275 | m_Parameters[key]=value; |
274 | } | 276 | } |
275 | 277 | ||
276 | const QString RecPart::searchParamter(const QString&key)const | 278 | const QString RecPart::searchParamter(const QString&key)const |
277 | { | 279 | { |
278 | QString value(""); | 280 | QString value(""); |
279 | part_plist_t::ConstIterator it = m_Parameters.find(key); | 281 | part_plist_t::ConstIterator it = m_Parameters.find(key); |
280 | if (it != m_Parameters.end()) { | 282 | if (it != m_Parameters.end()) { |
281 | value = it.data(); | 283 | value = it.data(); |
282 | } | 284 | } |
283 | return value; | 285 | return value; |
284 | } | 286 | } |
285 | 287 | ||
286 | void RecPart::setPositionlist(const QValueList<int>&poslist) | 288 | void RecPart::setPositionlist(const Q3ValueList<int>&poslist) |
287 | { | 289 | { |
288 | m_poslist = poslist; | 290 | m_poslist = poslist; |
289 | } | 291 | } |
290 | 292 | ||
291 | const QValueList<int>& RecPart::Positionlist()const | 293 | const Q3ValueList<int>& RecPart::Positionlist()const |
292 | { | 294 | { |
293 | return m_poslist; | 295 | return m_poslist; |
294 | } | 296 | } |
295 | 297 | ||
296 | RecBody::RecBody() | 298 | RecBody::RecBody() |
297 | : Opie::Core::ORefCount(),m_BodyText(),m_description(new RecPart()) | 299 | : Opie::Core::ORefCount(),m_BodyText(),m_description(new RecPart()) |
298 | { | 300 | { |
299 | m_PartsList.clear(); | 301 | m_PartsList.clear(); |
300 | } | 302 | } |
301 | 303 | ||
302 | RecBody::RecBody(const RecBody&old) | 304 | RecBody::RecBody(const RecBody&old) |
303 | :Opie::Core::ORefCount(),m_BodyText(),m_PartsList(),m_description(new RecPart()) | 305 | :Opie::Core::ORefCount(),m_BodyText(),m_PartsList(),m_description(new RecPart()) |
304 | { | 306 | { |
305 | m_BodyText = old.m_BodyText; | 307 | m_BodyText = old.m_BodyText; |
306 | m_PartsList = old.m_PartsList; | 308 | m_PartsList = old.m_PartsList; |
307 | m_description = old.m_description; | 309 | m_description = old.m_description; |
308 | mCharset = old.mCharset; | 310 | mCharset = old.mCharset; |
309 | // odebug << "Recbody copy constructor" << oendl; | 311 | // odebug << "Recbody copy constructor" << oendl; |
310 | } | 312 | } |
311 | 313 | ||
312 | RecBody::~RecBody() | 314 | RecBody::~RecBody() |
313 | { | 315 | { |
314 | } | 316 | } |
315 | 317 | ||
316 | void RecBody::setBodytext(const QString&bodyText) | 318 | void RecBody::setBodytext(const QString&bodyText) |
317 | { | 319 | { |
318 | m_BodyText = bodyText; | 320 | m_BodyText = bodyText; |
319 | } | 321 | } |
320 | 322 | ||
321 | const QString& RecBody::Bodytext()const | 323 | const QString& RecBody::Bodytext()const |
322 | { | 324 | { |
323 | return m_BodyText; | 325 | return m_BodyText; |
324 | } | 326 | } |
325 | 327 | ||
326 | void RecBody::setParts(const QValueList<RecPartP>&parts) | 328 | void RecBody::setParts(const Q3ValueList<RecPartP>&parts) |
327 | { | 329 | { |
328 | m_PartsList.clear(); | 330 | m_PartsList.clear(); |
329 | m_PartsList = parts; | 331 | m_PartsList = parts; |
330 | } | 332 | } |
331 | 333 | ||
332 | const QValueList<RecPartP>& RecBody::Parts()const | 334 | const Q3ValueList<RecPartP>& RecBody::Parts()const |
333 | { | 335 | { |
334 | return m_PartsList; | 336 | return m_PartsList; |
335 | } | 337 | } |
336 | 338 | ||
337 | void RecBody::addPart(const RecPartP& part) | 339 | void RecBody::addPart(const RecPartP& part) |
338 | { | 340 | { |
339 | m_PartsList.append(part); | 341 | m_PartsList.append(part); |
340 | } | 342 | } |
341 | 343 | ||
342 | void RecBody::setDescription(const RecPartP&des) | 344 | void RecBody::setDescription(const RecPartP&des) |
343 | { | 345 | { |
344 | m_description = des; | 346 | m_description = des; |
345 | } | 347 | } |
346 | 348 | ||
347 | const RecPartP& RecBody::Description()const | 349 | const RecPartP& RecBody::Description()const |
348 | { | 350 | { |
349 | return m_description; | 351 | return m_description; |
350 | } | 352 | } |
351 | 353 | ||
352 | void RecBody::setCharset(const QString& str) | 354 | void RecBody::setCharset(const QString& str) |
353 | { | 355 | { |
354 | mCharset = str; | 356 | mCharset = str; |
355 | } | 357 | } |
356 | 358 | ||
diff --git a/kmicromail/libmailwrapper/mailtypes.h b/kmicromail/libmailwrapper/mailtypes.h index 97f10d7..ac7f8da 100644 --- a/kmicromail/libmailwrapper/mailtypes.h +++ b/kmicromail/libmailwrapper/mailtypes.h | |||
@@ -1,41 +1,41 @@ | |||
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 <q3valuelist.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;} |
@@ -88,103 +88,103 @@ public: | |||
88 | AbstractMail* Wrapper(); | 88 | AbstractMail* Wrapper(); |
89 | // public for debugging | 89 | // public for debugging |
90 | QString subject,date,isodate,from,mbox,msg_id,replyto; | 90 | QString subject,date,isodate,from,mbox,msg_id,replyto; |
91 | 91 | ||
92 | protected: | 92 | protected: |
93 | //QString subject,date,isodate,from,mbox,msg_id,replyto; | 93 | //QString subject,date,isodate,from,mbox,msg_id,replyto; |
94 | unsigned int msg_number,msg_size; | 94 | unsigned int msg_number,msg_size; |
95 | QBitArray msg_flags; | 95 | QBitArray msg_flags; |
96 | QStringList to,cc,bcc,in_reply_to,references; | 96 | QStringList to,cc,bcc,in_reply_to,references; |
97 | AbstractMail*wrapper; | 97 | AbstractMail*wrapper; |
98 | void init(); | 98 | void init(); |
99 | void copy_old(const RecMail&old); | 99 | void copy_old(const RecMail&old); |
100 | }; | 100 | }; |
101 | 101 | ||
102 | typedef Opie::Core::OSmartPointer<RecMail> RecMailP; | 102 | typedef Opie::Core::OSmartPointer<RecMail> RecMailP; |
103 | typedef QMap<QString,QString> part_plist_t; | 103 | typedef QMap<QString,QString> part_plist_t; |
104 | 104 | ||
105 | class RecPart:public Opie::Core::ORefCount | 105 | class RecPart:public Opie::Core::ORefCount |
106 | { | 106 | { |
107 | protected: | 107 | protected: |
108 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; | 108 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; |
109 | unsigned int m_lines,m_size; | 109 | unsigned int m_lines,m_size; |
110 | part_plist_t m_Parameters; | 110 | part_plist_t m_Parameters; |
111 | /* describes the position in the mail */ | 111 | /* describes the position in the mail */ |
112 | QValueList<int> m_poslist; | 112 | Q3ValueList<int> m_poslist; |
113 | 113 | ||
114 | public: | 114 | public: |
115 | RecPart(); | 115 | RecPart(); |
116 | RecPart(const RecPart&); | 116 | RecPart(const RecPart&); |
117 | virtual ~RecPart(); | 117 | virtual ~RecPart(); |
118 | 118 | ||
119 | const QString&Type()const; | 119 | const QString&Type()const; |
120 | void setType(const QString&type); | 120 | void setType(const QString&type); |
121 | const QString&Subtype()const; | 121 | const QString&Subtype()const; |
122 | void setSubtype(const QString&subtype); | 122 | void setSubtype(const QString&subtype); |
123 | const QString&Identifier()const; | 123 | const QString&Identifier()const; |
124 | void setIdentifier(const QString&identifier); | 124 | void setIdentifier(const QString&identifier); |
125 | const QString&Encoding()const; | 125 | const QString&Encoding()const; |
126 | void setEncoding(const QString&encoding); | 126 | void setEncoding(const QString&encoding); |
127 | const QString&Description()const; | 127 | const QString&Description()const; |
128 | void setDescription(const QString&desc); | 128 | void setDescription(const QString&desc); |
129 | void setLines(unsigned int lines); | 129 | void setLines(unsigned int lines); |
130 | const unsigned int Lines()const; | 130 | const unsigned int Lines()const; |
131 | void setSize(unsigned int size); | 131 | void setSize(unsigned int size); |
132 | const unsigned int Size()const; | 132 | const unsigned int Size()const; |
133 | 133 | ||
134 | 134 | ||
135 | void setParameters(const part_plist_t&list); | 135 | void setParameters(const part_plist_t&list); |
136 | const part_plist_t&Parameters()const; | 136 | const part_plist_t&Parameters()const; |
137 | void addParameter(const QString&key,const QString&value); | 137 | void addParameter(const QString&key,const QString&value); |
138 | const QString searchParamter(const QString&key)const; | 138 | const QString searchParamter(const QString&key)const; |
139 | void setPositionlist(const QValueList<int>&poslist); | 139 | void setPositionlist(const Q3ValueList<int>&poslist); |
140 | const QValueList<int>& Positionlist()const; | 140 | const Q3ValueList<int>& Positionlist()const; |
141 | }; | 141 | }; |
142 | 142 | ||
143 | typedef Opie::Core::OSmartPointer<RecPart> RecPartP; | 143 | typedef Opie::Core::OSmartPointer<RecPart> RecPartP; |
144 | 144 | ||
145 | class RecBody:public Opie::Core::ORefCount | 145 | class RecBody:public Opie::Core::ORefCount |
146 | { | 146 | { |
147 | protected: | 147 | protected: |
148 | QString m_BodyText; | 148 | QString m_BodyText; |
149 | QString mCharset; | 149 | QString mCharset; |
150 | QValueList<RecPartP> m_PartsList; | 150 | Q3ValueList<RecPartP> m_PartsList; |
151 | RecPartP m_description; | 151 | RecPartP m_description; |
152 | 152 | ||
153 | public: | 153 | public: |
154 | RecBody(); | 154 | RecBody(); |
155 | RecBody(const RecBody&old); | 155 | RecBody(const RecBody&old); |
156 | virtual ~RecBody(); | 156 | virtual ~RecBody(); |
157 | void setBodytext(const QString&); | 157 | void setBodytext(const QString&); |
158 | const QString& Bodytext()const; | 158 | const QString& Bodytext()const; |
159 | void setCharset(const QString&); | 159 | void setCharset(const QString&); |
160 | QString getCharset()const; | 160 | QString getCharset()const; |
161 | 161 | ||
162 | void setDescription(const RecPartP&des); | 162 | void setDescription(const RecPartP&des); |
163 | const RecPartP& Description()const; | 163 | const RecPartP& Description()const; |
164 | 164 | ||
165 | void setParts(const QValueList<RecPartP>&parts); | 165 | void setParts(const Q3ValueList<RecPartP>&parts); |
166 | const QValueList<RecPartP>& Parts()const; | 166 | const Q3ValueList<RecPartP>& Parts()const; |
167 | void addPart(const RecPartP&part); | 167 | void addPart(const RecPartP&part); |
168 | }; | 168 | }; |
169 | 169 | ||
170 | typedef Opie::Core::OSmartPointer<RecBody> RecBodyP; | 170 | typedef Opie::Core::OSmartPointer<RecBody> RecBodyP; |
171 | 171 | ||
172 | class encodedString | 172 | class encodedString |
173 | { | 173 | { |
174 | public: | 174 | public: |
175 | encodedString(); | 175 | encodedString(); |
176 | /* | 176 | /* |
177 | creates an new content string. | 177 | creates an new content string. |
178 | it makes a deep copy of it! | 178 | it makes a deep copy of it! |
179 | */ | 179 | */ |
180 | encodedString(const char*nContent,unsigned int length); | 180 | encodedString(const char*nContent,unsigned int length); |
181 | /* | 181 | /* |
182 | Take over the nContent. Means: it will just copy the pointer, not the content. | 182 | Take over the nContent. Means: it will just copy the pointer, not the content. |
183 | so make sure: No one else frees the string, the string has allocated with | 183 | so make sure: No one else frees the string, the string has allocated with |
184 | malloc for compatibility with c-based libs | 184 | malloc for compatibility with c-based libs |
185 | */ | 185 | */ |
186 | encodedString(char*nContent,unsigned int nSize); | 186 | encodedString(char*nContent,unsigned int nSize); |
187 | /* copy construkor - makes ALWAYS a deep copy!!!! */ | 187 | /* copy construkor - makes ALWAYS a deep copy!!!! */ |
188 | encodedString(const encodedString&old); | 188 | encodedString(const encodedString&old); |
189 | /* assign operator - makes ALWAYS a deep copy!!!! */ | 189 | /* assign operator - makes ALWAYS a deep copy!!!! */ |
190 | encodedString& operator=(const encodedString&old); | 190 | encodedString& operator=(const encodedString&old); |
diff --git a/kmicromail/libmailwrapper/mailwrapper.cpp b/kmicromail/libmailwrapper/mailwrapper.cpp index 2ee1ab3..9c299e8 100644 --- a/kmicromail/libmailwrapper/mailwrapper.cpp +++ b/kmicromail/libmailwrapper/mailwrapper.cpp | |||
@@ -1,31 +1,33 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <sys/stat.h> | 2 | #include <sys/stat.h> |
3 | #include <sys/types.h> | 3 | #include <sys/types.h> |
4 | #include <unistd.h> | 4 | #include <unistd.h> |
5 | #include <fcntl.h> | 5 | #include <fcntl.h> |
6 | #include <string.h> | 6 | #include <string.h> |
7 | #include <qdir.h> | 7 | #include <qdir.h> |
8 | //Added by qt3to4: | ||
9 | #include <Q3CString> | ||
8 | 10 | ||
9 | #include "mailwrapper.h" | 11 | #include "mailwrapper.h" |
10 | //#include "logindialog.h" | 12 | //#include "logindialog.h" |
11 | //#include "defines.h" | 13 | //#include "defines.h" |
12 | 14 | ||
13 | #define UNDEFINED 64 | 15 | #define UNDEFINED 64 |
14 | #define MAXLINE 76 | 16 | #define MAXLINE 76 |
15 | #define UTF16MASK 0x03FFUL | 17 | #define UTF16MASK 0x03FFUL |
16 | #define UTF16SHIFT 10 | 18 | #define UTF16SHIFT 10 |
17 | #define UTF16BASE 0x10000UL | 19 | #define UTF16BASE 0x10000UL |
18 | #define UTF16HIGHSTART 0xD800UL | 20 | #define UTF16HIGHSTART 0xD800UL |
19 | #define UTF16HIGHEND 0xDBFFUL | 21 | #define UTF16HIGHEND 0xDBFFUL |
20 | #define UTF16LOSTART 0xDC00UL | 22 | #define UTF16LOSTART 0xDC00UL |
21 | #define UTF16LOEND 0xDFFFUL | 23 | #define UTF16LOEND 0xDFFFUL |
22 | 24 | ||
23 | 25 | ||
24 | using namespace Opie::Core; | 26 | using namespace Opie::Core; |
25 | Attachment::Attachment( QString lnk ) | 27 | Attachment::Attachment( QString lnk ) |
26 | { | 28 | { |
27 | doc = lnk; | 29 | doc = lnk; |
28 | size = QFileInfo( doc ).size(); | 30 | size = QFileInfo( doc ).size(); |
29 | mPix = SmallIcon( "files" ); | 31 | mPix = SmallIcon( "files" ); |
30 | } | 32 | } |
31 | 33 | ||
@@ -60,117 +62,117 @@ IMAPFolder::IMAPFolder(const QString&t_name,const QString&sep, bool select,bool | |||
60 | if (prefix.length()>0) { | 62 | if (prefix.length()>0) { |
61 | if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) { | 63 | if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) { |
62 | nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length()); | 64 | nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length()); |
63 | } | 65 | } |
64 | } | 66 | } |
65 | } | 67 | } |
66 | 68 | ||
67 | IMAPFolder::~IMAPFolder() | 69 | IMAPFolder::~IMAPFolder() |
68 | { | 70 | { |
69 | } | 71 | } |
70 | 72 | ||
71 | static unsigned char base64chars[] = | 73 | static unsigned char base64chars[] = |
72 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,"; | 74 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,"; |
73 | 75 | ||
74 | /** | 76 | /** |
75 | * Decodes base64 encoded parts of the imapfolder name | 77 | * Decodes base64 encoded parts of the imapfolder name |
76 | * Code taken from kde cvs: kdebase/kioslave/imap4/rfcdecoder.cc | 78 | * Code taken from kde cvs: kdebase/kioslave/imap4/rfcdecoder.cc |
77 | */ | 79 | */ |
78 | QString IMAPFolder::decodeFolderName( const QString &name ) | 80 | QString IMAPFolder::decodeFolderName( const QString &name ) |
79 | { | 81 | { |
80 | unsigned char c, i, bitcount; | 82 | unsigned char c, i, bitcount; |
81 | unsigned long ucs4, utf16, bitbuf; | 83 | unsigned long ucs4, utf16, bitbuf; |
82 | unsigned char base64[256], utf8[6]; | 84 | unsigned char base64[256], utf8[6]; |
83 | unsigned long srcPtr = 0; | 85 | unsigned long srcPtr = 0; |
84 | QCString dst = ""; | 86 | Q3CString dst = ""; |
85 | QCString src = name.ascii(); | 87 | Q3CString src = name.ascii(); |
86 | 88 | ||
87 | /* initialize modified base64 decoding table */ | 89 | /* initialize modified base64 decoding table */ |
88 | memset(base64, UNDEFINED, sizeof(base64)); | 90 | memset(base64, UNDEFINED, sizeof(base64)); |
89 | for (i = 0; i < sizeof(base64chars); ++i) { | 91 | for (i = 0; i < sizeof(base64chars); ++i) { |
90 | base64[(int)base64chars[i]] = i; | 92 | base64[(int)base64chars[i]] = i; |
91 | } | 93 | } |
92 | 94 | ||
93 | /* loop until end of string */ | 95 | /* loop until end of string */ |
94 | while (srcPtr < src.length ()) { | 96 | while (srcPtr < src.length ()) { |
95 | c = src[srcPtr++]; | 97 | c = src.at(srcPtr++); |
96 | /* deal with literal characters and &- */ | 98 | /* deal with literal characters and &- */ |
97 | if (c != '&' || src[srcPtr] == '-') { | 99 | if (c != '&' || src.at(srcPtr) == '-') { |
98 | /* encode literally */ | 100 | /* encode literally */ |
99 | dst += c; | 101 | dst += c; |
100 | /* skip over the '-' if this is an &- sequence */ | 102 | /* skip over the '-' if this is an &- sequence */ |
101 | if (c == '&') | 103 | if (c == '&') |
102 | srcPtr++; | 104 | srcPtr++; |
103 | } else { | 105 | } else { |
104 | /* convert modified UTF-7 -> UTF-16 -> UCS-4 -> UTF-8 -> HEX */ | 106 | /* convert modified UTF-7 -> UTF-16 -> UCS-4 -> UTF-8 -> HEX */ |
105 | bitbuf = 0; | 107 | bitbuf = 0; |
106 | bitcount = 0; | 108 | bitcount = 0; |
107 | ucs4 = 0; | 109 | ucs4 = 0; |
108 | while ((c = base64[(unsigned char) src[srcPtr]]) != UNDEFINED) { | 110 | while ((c = base64[(unsigned char) src.at(srcPtr)]) != UNDEFINED) { |
109 | ++srcPtr; | 111 | ++srcPtr; |
110 | bitbuf = (bitbuf << 6) | c; | 112 | bitbuf = (bitbuf << 6) | c; |
111 | bitcount += 6; | 113 | bitcount += 6; |
112 | /* enough bits for a UTF-16 character? */ | 114 | /* enough bits for a UTF-16 character? */ |
113 | if (bitcount >= 16) { | 115 | if (bitcount >= 16) { |
114 | bitcount -= 16; | 116 | bitcount -= 16; |
115 | utf16 = (bitcount ? bitbuf >> bitcount : bitbuf) & 0xffff; | 117 | utf16 = (bitcount ? bitbuf >> bitcount : bitbuf) & 0xffff; |
116 | /* convert UTF16 to UCS4 */ | 118 | /* convert UTF16 to UCS4 */ |
117 | if (utf16 >= UTF16HIGHSTART && utf16 <= UTF16HIGHEND) { | 119 | if (utf16 >= UTF16HIGHSTART && utf16 <= UTF16HIGHEND) { |
118 | ucs4 = (utf16 - UTF16HIGHSTART) << UTF16SHIFT; | 120 | ucs4 = (utf16 - UTF16HIGHSTART) << UTF16SHIFT; |
119 | continue; | 121 | continue; |
120 | } else if (utf16 >= UTF16LOSTART && utf16 <= UTF16LOEND) { | 122 | } else if (utf16 >= UTF16LOSTART && utf16 <= UTF16LOEND) { |
121 | ucs4 += utf16 - UTF16LOSTART + UTF16BASE; | 123 | ucs4 += utf16 - UTF16LOSTART + UTF16BASE; |
122 | } else { | 124 | } else { |
123 | ucs4 = utf16; | 125 | ucs4 = utf16; |
124 | } | 126 | } |
125 | /* convert UTF-16 range of UCS4 to UTF-8 */ | 127 | /* convert UTF-16 range of UCS4 to UTF-8 */ |
126 | if (ucs4 <= 0x7fUL) { | 128 | if (ucs4 <= 0x7fUL) { |
127 | utf8[0] = ucs4; | 129 | utf8[0] = ucs4; |
128 | i = 1; | 130 | i = 1; |
129 | } else if (ucs4 <= 0x7ffUL) { | 131 | } else if (ucs4 <= 0x7ffUL) { |
130 | utf8[0] = 0xc0 | (ucs4 >> 6); | 132 | utf8[0] = 0xc0 | (ucs4 >> 6); |
131 | utf8[1] = 0x80 | (ucs4 & 0x3f); | 133 | utf8[1] = 0x80 | (ucs4 & 0x3f); |
132 | i = 2; | 134 | i = 2; |
133 | } else if (ucs4 <= 0xffffUL) { | 135 | } else if (ucs4 <= 0xffffUL) { |
134 | utf8[0] = 0xe0 | (ucs4 >> 12); | 136 | utf8[0] = 0xe0 | (ucs4 >> 12); |
135 | utf8[1] = 0x80 | ((ucs4 >> 6) & 0x3f); | 137 | utf8[1] = 0x80 | ((ucs4 >> 6) & 0x3f); |
136 | utf8[2] = 0x80 | (ucs4 & 0x3f); | 138 | utf8[2] = 0x80 | (ucs4 & 0x3f); |
137 | i = 3; | 139 | i = 3; |
138 | } else { | 140 | } else { |
139 | utf8[0] = 0xf0 | (ucs4 >> 18); | 141 | utf8[0] = 0xf0 | (ucs4 >> 18); |
140 | utf8[1] = 0x80 | ((ucs4 >> 12) & 0x3f); | 142 | utf8[1] = 0x80 | ((ucs4 >> 12) & 0x3f); |
141 | utf8[2] = 0x80 | ((ucs4 >> 6) & 0x3f); | 143 | utf8[2] = 0x80 | ((ucs4 >> 6) & 0x3f); |
142 | utf8[3] = 0x80 | (ucs4 & 0x3f); | 144 | utf8[3] = 0x80 | (ucs4 & 0x3f); |
143 | i = 4; | 145 | i = 4; |
144 | } | 146 | } |
145 | /* copy it */ | 147 | /* copy it */ |
146 | for (c = 0; c < i; ++c) { | 148 | for (c = 0; c < i; ++c) { |
147 | dst += utf8[c]; | 149 | dst += utf8[c]; |
148 | } | 150 | } |
149 | } | 151 | } |
150 | } | 152 | } |
151 | /* skip over trailing '-' in modified UTF-7 encoding */ | 153 | /* skip over trailing '-' in modified UTF-7 encoding */ |
152 | if (src[srcPtr] == '-') | 154 | if (src.at(srcPtr) == '-') |
153 | ++srcPtr; | 155 | ++srcPtr; |
154 | } | 156 | } |
155 | } | 157 | } |
156 | 158 | ||
157 | return QString::fromUtf8( dst.data() ); | 159 | return QString::fromUtf8( dst.data() ); |
158 | } | 160 | } |
159 | 161 | ||
160 | Mail::Mail() | 162 | Mail::Mail() |
161 | :Opie::Core::ORefCount(),name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") | 163 | :Opie::Core::ORefCount(),name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") |
162 | { | 164 | { |
163 | } | 165 | } |
164 | 166 | ||
165 | MHFolder::MHFolder(const QString&disp_name,const QString&mbox) | 167 | MHFolder::MHFolder(const QString&disp_name,const QString&mbox) |
166 | : Folder( disp_name,"/" ) | 168 | : Folder( disp_name,"/" ) |
167 | { | 169 | { |
168 | separator = "/"; | 170 | separator = "/"; |
169 | name = mbox; | 171 | name = mbox; |
170 | if (!disp_name.startsWith("/") && disp_name.length()>0) | 172 | if (!disp_name.startsWith("/") && disp_name.length()>0) |
171 | name+="/"; | 173 | name+="/"; |
172 | name+=disp_name; | 174 | name+=disp_name; |
173 | if (disp_name.length()==0) { | 175 | if (disp_name.length()==0) { |
174 | nameDisplay = separator; | 176 | nameDisplay = separator; |
175 | } | 177 | } |
176 | prefix = mbox; | 178 | prefix = mbox; |
diff --git a/kmicromail/libmailwrapper/mailwrapper.h b/kmicromail/libmailwrapper/mailwrapper.h index 3e8b51f..bebabf4 100644 --- a/kmicromail/libmailwrapper/mailwrapper.h +++ b/kmicromail/libmailwrapper/mailwrapper.h | |||
@@ -1,32 +1,34 @@ | |||
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 | //Added by qt3to4: | ||
10 | #include <QPixmap> | ||
9 | #include <kiconloader.h> | 11 | #include <kiconloader.h> |
10 | 12 | ||
11 | #include "settings.h" | 13 | #include "settings.h" |
12 | 14 | ||
13 | #include <opie2/osmartpointer.h> | 15 | #include <opie2/osmartpointer.h> |
14 | /* | 16 | /* |
15 | class Attachment | 17 | class Attachment |
16 | { | 18 | { |
17 | public: | 19 | public: |
18 | Attachment( DocLnk lnk ); | 20 | Attachment( DocLnk lnk ); |
19 | virtual ~Attachment(){} | 21 | virtual ~Attachment(){} |
20 | const QString getFileName()const{ return doc.file(); } | 22 | const QString getFileName()const{ return doc.file(); } |
21 | const QString getName()const{ return doc.name(); } | 23 | const QString getName()const{ return doc.name(); } |
22 | const QString getMimeType()const{ return doc.type(); } | 24 | const QString getMimeType()const{ return doc.type(); } |
23 | const QPixmap getPixmap()const{ return doc.pixmap(); } | 25 | const QPixmap getPixmap()const{ return doc.pixmap(); } |
24 | const int getSize()const { return size; } | 26 | const int getSize()const { return size; } |
25 | DocLnk getDocLnk() { return doc; } | 27 | DocLnk getDocLnk() { return doc; } |
26 | 28 | ||
27 | protected: | 29 | protected: |
28 | DocLnk doc; | 30 | DocLnk doc; |
29 | int size; | 31 | int size; |
30 | 32 | ||
31 | }; | 33 | }; |
32 | */ | 34 | */ |
@@ -40,74 +42,74 @@ public: | |||
40 | const QString getName()const{ return QFileInfo( doc ).baseName (); } | 42 | const QString getName()const{ return QFileInfo( doc ).baseName (); } |
41 | const QString getMimeType()const{ return QFileInfo( doc ).extension(false); } | 43 | const QString getMimeType()const{ return QFileInfo( doc ).extension(false); } |
42 | const QPixmap getPixmap()const{ return mPix; } | 44 | const QPixmap getPixmap()const{ return mPix; } |
43 | const int getSize()const { return size; } | 45 | const int getSize()const { return size; } |
44 | QString getDocLnk() { return doc; } | 46 | QString getDocLnk() { return doc; } |
45 | 47 | ||
46 | protected: | 48 | protected: |
47 | QPixmap mPix; | 49 | QPixmap mPix; |
48 | QString doc; | 50 | QString doc; |
49 | int size; | 51 | int size; |
50 | 52 | ||
51 | }; | 53 | }; |
52 | 54 | ||
53 | class Mail:public Opie::Core::ORefCount | 55 | class Mail:public Opie::Core::ORefCount |
54 | { | 56 | { |
55 | public: | 57 | public: |
56 | Mail(); | 58 | Mail(); |
57 | /* Possible that this destructor must not be declared virtual | 59 | /* Possible that this destructor must not be declared virtual |
58 | * 'cause it seems that it will never have some child classes. | 60 | * '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 | 61 | * in this case this object will not get a virtual table -> memory and |
60 | * speed will be a little bit better? | 62 | * speed will be a little bit better? |
61 | */ | 63 | */ |
62 | virtual ~Mail(){} | 64 | virtual ~Mail(){} |
63 | void addAttachment( Attachment *att ) { attList.append( att ); } | 65 | void addAttachment( Attachment *att ) { attList.append( att ); } |
64 | const QList<Attachment>& getAttachments()const { return attList; } | 66 | const QList<Attachment*>& getAttachments()const { return attList; } |
65 | void removeAttachment( Attachment *att ) { attList.remove( att ); } | 67 | void removeAttachment( Attachment *att ) { attList.remove( att ); } |
66 | const QString&getName()const { return name; } | 68 | const QString&getName()const { return name; } |
67 | void setName( QString s ) { name = s; } | 69 | void setName( QString s ) { name = s; } |
68 | const QString&getMail()const{ return mail; } | 70 | const QString&getMail()const{ return mail; } |
69 | void setMail( const QString&s ) { mail = s; } | 71 | void setMail( const QString&s ) { mail = s; } |
70 | const QString&getTo()const{ return to; } | 72 | const QString&getTo()const{ return to; } |
71 | void setTo( const QString&s ) { to = s; } | 73 | void setTo( const QString&s ) { to = s; } |
72 | const QString&getCC()const{ return cc; } | 74 | const QString&getCC()const{ return cc; } |
73 | void setCC( const QString&s ) { cc = s; } | 75 | void setCC( const QString&s ) { cc = s; } |
74 | const QString&getBCC()const { return bcc; } | 76 | const QString&getBCC()const { return bcc; } |
75 | void setBCC( const QString&s ) { bcc = s; } | 77 | void setBCC( const QString&s ) { bcc = s; } |
76 | const QString&getMessage()const { return message; } | 78 | const QString&getMessage()const { return message; } |
77 | void setMessage( const QString&s ) { message = s; } | 79 | void setMessage( const QString&s ) { message = s; } |
78 | const QString&getSubject()const { return subject; } | 80 | const QString&getSubject()const { return subject; } |
79 | void setSubject( const QString&s ) { subject = s; } | 81 | void setSubject( const QString&s ) { subject = s; } |
80 | const QString&getReply()const{ return reply; } | 82 | const QString&getReply()const{ return reply; } |
81 | void setReply( const QString&a ) { reply = a; } | 83 | void setReply( const QString&a ) { reply = a; } |
82 | void setInreply(const QStringList&list){m_in_reply_to = list;} | 84 | void setInreply(const QStringList&list){m_in_reply_to = list;} |
83 | const QStringList&Inreply()const{return m_in_reply_to;} | 85 | const QStringList&Inreply()const{return m_in_reply_to;} |
84 | 86 | ||
85 | void setCharset( const QString&a ) { charset= a; } | 87 | void setCharset( const QString&a ) { charset= a; } |
86 | const QString& getCharset() const { return charset; } | 88 | const QString& getCharset() const { return charset; } |
87 | 89 | ||
88 | private: | 90 | private: |
89 | QList<Attachment> attList; | 91 | QList<Attachment*> attList; |
90 | QString name, mail, to, cc, bcc, reply, subject, message, charset; | 92 | QString name, mail, to, cc, bcc, reply, subject, message, charset; |
91 | QStringList m_in_reply_to; | 93 | QStringList m_in_reply_to; |
92 | }; | 94 | }; |
93 | 95 | ||
94 | class Folder:public Opie::Core::ORefCount | 96 | class Folder:public Opie::Core::ORefCount |
95 | { | 97 | { |
96 | public: | 98 | public: |
97 | Folder( const QString&init_name,const QString&sep ); | 99 | Folder( const QString&init_name,const QString&sep ); |
98 | virtual ~Folder(); | 100 | virtual ~Folder(); |
99 | const QString&getDisplayName()const { return nameDisplay; } | 101 | const QString&getDisplayName()const { return nameDisplay; } |
100 | const QString&getName()const { return name; } | 102 | const QString&getName()const { return name; } |
101 | const QString&getPrefix()const{return prefix; } | 103 | const QString&getPrefix()const{return prefix; } |
102 | virtual bool may_select()const{return true;} | 104 | virtual bool may_select()const{return true;} |
103 | virtual bool no_inferior()const{return true;} | 105 | virtual bool no_inferior()const{return true;} |
104 | const QString&Separator()const; | 106 | const QString&Separator()const; |
105 | 107 | ||
106 | protected: | 108 | protected: |
107 | QString nameDisplay, name, separator,prefix; | 109 | QString nameDisplay, name, separator,prefix; |
108 | }; | 110 | }; |
109 | 111 | ||
110 | typedef Opie::Core::OSmartPointer<Folder> FolderP; | 112 | typedef Opie::Core::OSmartPointer<Folder> FolderP; |
111 | 113 | ||
112 | class MHFolder : public Folder | 114 | class MHFolder : public Folder |
113 | { | 115 | { |
diff --git a/kmicromail/libmailwrapper/mboxwrapper.cpp b/kmicromail/libmailwrapper/mboxwrapper.cpp index 87f8c8a..888cae2 100644 --- a/kmicromail/libmailwrapper/mboxwrapper.cpp +++ b/kmicromail/libmailwrapper/mboxwrapper.cpp | |||
@@ -1,77 +1,79 @@ | |||
1 | #include "mboxwrapper.h" | 1 | #include "mboxwrapper.h" |
2 | #include "mailtypes.h" | 2 | #include "mailtypes.h" |
3 | #include "mailwrapper.h" | 3 | #include "mailwrapper.h" |
4 | #include <libetpan/libetpan.h> | 4 | #include <libetpan/libetpan.h> |
5 | #include <qdir.h> | 5 | #include <qdir.h> |
6 | //Added by qt3to4: | ||
7 | #include <Q3ValueList> | ||
6 | #include <stdlib.h> | 8 | #include <stdlib.h> |
7 | #include <klocale.h> | 9 | #include <klocale.h> |
8 | 10 | ||
9 | 11 | ||
10 | #include <qpe/global.h> | 12 | #include <qpe/global.h> |
11 | 13 | ||
12 | using namespace Opie::Core; | 14 | using namespace Opie::Core; |
13 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) | 15 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) |
14 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) | 16 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) |
15 | { | 17 | { |
16 | QDir dir(MBOXPath); | 18 | QDir dir(MBOXPath); |
17 | if (!dir.exists()) { | 19 | if (!dir.exists()) { |
18 | dir.mkdir(MBOXPath); | 20 | dir.mkdir(MBOXPath); |
19 | } | 21 | } |
20 | } | 22 | } |
21 | 23 | ||
22 | MBOXwrapper::~MBOXwrapper() | 24 | MBOXwrapper::~MBOXwrapper() |
23 | { | 25 | { |
24 | } | 26 | } |
25 | 27 | ||
26 | void MBOXwrapper::listMessages(const QString & mailbox, QValueList<RecMailP> &target ) | 28 | void MBOXwrapper::listMessages(const QString & mailbox, Q3ValueList<RecMailP> &target ) |
27 | { | 29 | { |
28 | mailstorage*storage = mailstorage_new(NULL); | 30 | mailstorage*storage = mailstorage_new(NULL); |
29 | QString p = MBOXPath+"/"; | 31 | QString p = MBOXPath+"/"; |
30 | p+=mailbox; | 32 | p+=mailbox; |
31 | 33 | ||
32 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 34 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
33 | mailfolder*folder; | 35 | mailfolder*folder; |
34 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 36 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
35 | r = mailfolder_connect(folder); | 37 | r = mailfolder_connect(folder); |
36 | if (r != MAIL_NO_ERROR) { | 38 | if (r != MAIL_NO_ERROR) { |
37 | //odebug << "Error initializing mbox" << oendl; | 39 | //odebug << "Error initializing mbox" << oendl; |
38 | mailfolder_free(folder); | 40 | mailfolder_free(folder); |
39 | mailstorage_free(storage); | 41 | mailstorage_free(storage); |
40 | return; | 42 | return; |
41 | } | 43 | } |
42 | 44 | ||
43 | parseList(target,folder->fld_session,mailbox); | 45 | parseList(target,folder->fld_session,mailbox); |
44 | 46 | ||
45 | mailfolder_disconnect(folder); | 47 | mailfolder_disconnect(folder); |
46 | mailfolder_free(folder); | 48 | mailfolder_free(folder); |
47 | mailstorage_free(storage); | 49 | mailstorage_free(storage); |
48 | Global::statusMessage(i18n("Mailbox has %1 mail(s)").arg(target.count())); | 50 | Global::statusMessage(i18n("Mailbox has %1 mail(s)").arg(target.count())); |
49 | } | 51 | } |
50 | 52 | ||
51 | QValueList<Opie::Core::OSmartPointer<Folder> >* MBOXwrapper::listFolders() | 53 | Q3ValueList<Opie::Core::OSmartPointer<Folder> >* MBOXwrapper::listFolders() |
52 | { | 54 | { |
53 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 55 | Q3ValueList<Opie::Core::OSmartPointer<Folder> >* folders = new Q3ValueList<Opie::Core::OSmartPointer<Folder> >(); |
54 | QDir dir(MBOXPath); | 56 | QDir dir(MBOXPath); |
55 | if (!dir.exists()) return folders; | 57 | if (!dir.exists()) return folders; |
56 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); | 58 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); |
57 | QStringList entries = dir.entryList(); | 59 | QStringList entries = dir.entryList(); |
58 | QStringList::ConstIterator it = entries.begin(); | 60 | QStringList::ConstIterator it = entries.begin(); |
59 | for (;it!=entries.end();++it) { | 61 | for (;it!=entries.end();++it) { |
60 | FolderP inb=new Folder(*it,"/"); | 62 | FolderP inb=new Folder(*it,"/"); |
61 | folders->append(inb); | 63 | folders->append(inb); |
62 | } | 64 | } |
63 | return folders; | 65 | return folders; |
64 | } | 66 | } |
65 | 67 | ||
66 | void MBOXwrapper::deleteMail(const RecMailP & mail) | 68 | void MBOXwrapper::deleteMail(const RecMailP & mail) |
67 | { | 69 | { |
68 | mailstorage*storage = mailstorage_new(NULL); | 70 | mailstorage*storage = mailstorage_new(NULL); |
69 | QString p = MBOXPath+"/"; | 71 | QString p = MBOXPath+"/"; |
70 | p+=mail->getMbox(); | 72 | p+=mail->getMbox(); |
71 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 73 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
72 | mailfolder*folder; | 74 | mailfolder*folder; |
73 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 75 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
74 | r = mailfolder_connect(folder); | 76 | r = mailfolder_connect(folder); |
75 | if (r != MAIL_NO_ERROR) { | 77 | if (r != MAIL_NO_ERROR) { |
76 | ; // << "Error initializing mbox" << oendl; | 78 | ; // << "Error initializing mbox" << oendl; |
77 | mailfolder_free(folder); | 79 | mailfolder_free(folder); |
@@ -196,67 +198,67 @@ encodedString* MBOXwrapper::fetchRawBody(const RecMailP&mail) | |||
196 | } | 198 | } |
197 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); | 199 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); |
198 | if (r != MAIL_NO_ERROR) { | 200 | if (r != MAIL_NO_ERROR) { |
199 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); | 201 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); |
200 | mailfolder_free(folder); | 202 | mailfolder_free(folder); |
201 | mailstorage_free(storage); | 203 | mailstorage_free(storage); |
202 | return 0; | 204 | return 0; |
203 | } | 205 | } |
204 | r = mailmessage_fetch(msg,&data,&size); | 206 | r = mailmessage_fetch(msg,&data,&size); |
205 | if (r != MAIL_NO_ERROR) { | 207 | if (r != MAIL_NO_ERROR) { |
206 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); | 208 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); |
207 | mailfolder_free(folder); | 209 | mailfolder_free(folder); |
208 | mailstorage_free(storage); | 210 | mailstorage_free(storage); |
209 | mailmessage_free(msg); | 211 | mailmessage_free(msg); |
210 | return 0; | 212 | return 0; |
211 | } | 213 | } |
212 | encodedString*result = new encodedString(data,size); | 214 | encodedString*result = new encodedString(data,size); |
213 | 215 | ||
214 | mailfolder_free(folder); | 216 | mailfolder_free(folder); |
215 | mailstorage_free(storage); | 217 | mailstorage_free(storage); |
216 | mailmessage_free(msg); | 218 | mailmessage_free(msg); |
217 | return result; | 219 | return result; |
218 | } | 220 | } |
219 | 221 | ||
220 | void MBOXwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) | 222 | void MBOXwrapper::deleteMails(const QString & mailbox,const Q3ValueList<RecMailP> &target) |
221 | { | 223 | { |
222 | QString p = MBOXPath+"/"; | 224 | QString p = MBOXPath+"/"; |
223 | p+=mailbox; | 225 | p+=mailbox; |
224 | mailmbox_folder*f = 0; | 226 | mailmbox_folder*f = 0; |
225 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 227 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
226 | if (r != MAIL_NO_ERROR) { | 228 | if (r != MAIL_NO_ERROR) { |
227 | ; // << "Error init folder" << oendl; | 229 | ; // << "Error init folder" << oendl; |
228 | return; | 230 | return; |
229 | } | 231 | } |
230 | deleteMails(f,target); | 232 | deleteMails(f,target); |
231 | mailmbox_done(f); | 233 | mailmbox_done(f); |
232 | } | 234 | } |
233 | 235 | ||
234 | void MBOXwrapper::deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target) | 236 | void MBOXwrapper::deleteMails(mailmbox_folder*f,const Q3ValueList<RecMailP> &target) |
235 | { | 237 | { |
236 | if (!f) return; | 238 | if (!f) return; |
237 | int r; | 239 | int r; |
238 | QValueList<RecMailP>::ConstIterator it; | 240 | Q3ValueList<RecMailP>::ConstIterator it; |
239 | for (it=target.begin(); it != target.end();++it) { | 241 | for (it=target.begin(); it != target.end();++it) { |
240 | r = mailmbox_delete_msg(f,(*it)->getNumber()); | 242 | r = mailmbox_delete_msg(f,(*it)->getNumber()); |
241 | if (r!=MAILMBOX_NO_ERROR) { | 243 | if (r!=MAILMBOX_NO_ERROR) { |
242 | ; // << "error delete mail" << oendl; | 244 | ; // << "error delete mail" << oendl; |
243 | } | 245 | } |
244 | } | 246 | } |
245 | r = mailmbox_expunge(f); | 247 | r = mailmbox_expunge(f); |
246 | if (r != MAILMBOX_NO_ERROR) { | 248 | if (r != MAILMBOX_NO_ERROR) { |
247 | ; // << "error expunge mailbox" << oendl; | 249 | ; // << "error expunge mailbox" << oendl; |
248 | } | 250 | } |
249 | } | 251 | } |
250 | 252 | ||
251 | int MBOXwrapper::deleteAllMail(const FolderP&tfolder) | 253 | int MBOXwrapper::deleteAllMail(const FolderP&tfolder) |
252 | { | 254 | { |
253 | if (!tfolder) return 0; | 255 | if (!tfolder) return 0; |
254 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); | 256 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); |
255 | int res = 1; | 257 | int res = 1; |
256 | 258 | ||
257 | mailfolder*folder = 0; | 259 | mailfolder*folder = 0; |
258 | mailmessage_list*l=0; | 260 | mailmessage_list*l=0; |
259 | mailstorage*storage = mailstorage_new(NULL); | 261 | mailstorage*storage = mailstorage_new(NULL); |
260 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 262 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
261 | if (r != MAIL_NO_ERROR) { | 263 | if (r != MAIL_NO_ERROR) { |
262 | Global::statusMessage(i18n("Error initializing mbox")); | 264 | Global::statusMessage(i18n("Error initializing mbox")); |
diff --git a/kmicromail/libmailwrapper/mboxwrapper.h b/kmicromail/libmailwrapper/mboxwrapper.h index d03940f..e658a71 100644 --- a/kmicromail/libmailwrapper/mboxwrapper.h +++ b/kmicromail/libmailwrapper/mboxwrapper.h | |||
@@ -1,47 +1,49 @@ | |||
1 | #ifndef __MBOX_WRAPPER_H | 1 | #ifndef __MBOX_WRAPPER_H |
2 | #define __MBOX_WRAPPER_H | 2 | #define __MBOX_WRAPPER_H |
3 | 3 | ||
4 | #include "genericwrapper.h" | 4 | #include "genericwrapper.h" |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | //Added by qt3to4: | ||
7 | #include <Q3ValueList> | ||
6 | 8 | ||
7 | class encodedString; | 9 | class encodedString; |
8 | struct mailmbox_folder; | 10 | struct mailmbox_folder; |
9 | 11 | ||
10 | class MBOXwrapper : public Genericwrapper | 12 | class MBOXwrapper : public Genericwrapper |
11 | { | 13 | { |
12 | Q_OBJECT | 14 | Q_OBJECT |
13 | 15 | ||
14 | public: | 16 | public: |
15 | MBOXwrapper(const QString & dir,const QString&name); | 17 | MBOXwrapper(const QString & dir,const QString&name); |
16 | virtual ~MBOXwrapper(); | 18 | virtual ~MBOXwrapper(); |
17 | 19 | ||
18 | virtual void listMessages(const QString & mailbox, QValueList<RecMailP>&target ); | 20 | virtual void listMessages(const QString & mailbox, Q3ValueList<RecMailP>&target ); |
19 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 21 | virtual Q3ValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
20 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 22 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
21 | 23 | ||
22 | virtual void deleteMail(const RecMailP&mail); | 24 | virtual void deleteMail(const RecMailP&mail); |
23 | virtual void answeredMail(const RecMailP&mail); | 25 | virtual void answeredMail(const RecMailP&mail); |
24 | 26 | ||
25 | virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0, | 27 | virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0, |
26 | const QString&d="",bool s=false); | 28 | const QString&d="",bool s=false); |
27 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&); | 29 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&); |
28 | 30 | ||
29 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 31 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
30 | 32 | ||
31 | virtual RecBodyP fetchBody( const RecMailP &mail ); | 33 | virtual RecBodyP fetchBody( const RecMailP &mail ); |
32 | static void mbox_progress( size_t current, size_t maximum ); | 34 | static void mbox_progress( size_t current, size_t maximum ); |
33 | 35 | ||
34 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 36 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
35 | virtual void deleteMails(const QString & FolderName,const QValueList<RecMailP> &target); | 37 | virtual void deleteMails(const QString & FolderName,const Q3ValueList<RecMailP> &target); |
36 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); | 38 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
37 | virtual MAILLIB::ATYPE getType()const; | 39 | virtual MAILLIB::ATYPE getType()const; |
38 | virtual const QString&getName()const; | 40 | virtual const QString&getName()const; |
39 | virtual Account* getAccount() { return 0; }; | 41 | virtual Account* getAccount() { return 0; }; |
40 | 42 | ||
41 | protected: | 43 | protected: |
42 | static void deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target); | 44 | static void deleteMails(mailmbox_folder*f,const Q3ValueList<RecMailP> &target); |
43 | QString MBOXPath; | 45 | QString MBOXPath; |
44 | QString MBOXName; | 46 | QString MBOXName; |
45 | }; | 47 | }; |
46 | 48 | ||
47 | #endif | 49 | #endif |
diff --git a/kmicromail/libmailwrapper/mhwrapper.cpp b/kmicromail/libmailwrapper/mhwrapper.cpp index 787e85d..4cd7a94 100644 --- a/kmicromail/libmailwrapper/mhwrapper.cpp +++ b/kmicromail/libmailwrapper/mhwrapper.cpp | |||
@@ -1,31 +1,33 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "mhwrapper.h" | 2 | #include "mhwrapper.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include <libetpan/libetpan.h> | 5 | #include <libetpan/libetpan.h> |
6 | #include <qdir.h> | 6 | #include <qdir.h> |
7 | #include <qmessagebox.h> | 7 | #include <qmessagebox.h> |
8 | //Added by qt3to4: | ||
9 | #include <Q3ValueList> | ||
8 | #include <stdlib.h> | 10 | #include <stdlib.h> |
9 | #include <qpe/global.h> | 11 | #include <qpe/global.h> |
10 | #include <klocale.h> | 12 | #include <klocale.h> |
11 | #include <kglobal.h> | 13 | #include <kglobal.h> |
12 | //#include <opie2/odebug.h> | 14 | //#include <opie2/odebug.h> |
13 | 15 | ||
14 | using namespace Opie::Core; | 16 | using namespace Opie::Core; |
15 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) | 17 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) |
16 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) | 18 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) |
17 | { | 19 | { |
18 | if (MHPath.length()>0) { | 20 | if (MHPath.length()>0) { |
19 | if (MHPath[MHPath.length()-1]=='/') { | 21 | if (MHPath[MHPath.length()-1]=='/') { |
20 | MHPath=MHPath.left(MHPath.length()-1); | 22 | MHPath=MHPath.left(MHPath.length()-1); |
21 | } | 23 | } |
22 | //odebug << MHPath << oendl; | 24 | //odebug << MHPath << oendl; |
23 | QDir dir(MHPath); | 25 | QDir dir(MHPath); |
24 | if (!dir.exists()) { | 26 | if (!dir.exists()) { |
25 | dir.mkdir(MHPath); | 27 | dir.mkdir(MHPath); |
26 | } | 28 | } |
27 | init_storage(); | 29 | init_storage(); |
28 | } | 30 | } |
29 | } | 31 | } |
30 | 32 | ||
31 | void MHwrapper::init_storage() | 33 | void MHwrapper::init_storage() |
@@ -43,67 +45,67 @@ void MHwrapper::init_storage() | |||
43 | } | 45 | } |
44 | } | 46 | } |
45 | r = mailstorage_connect(m_storage); | 47 | r = mailstorage_connect(m_storage); |
46 | if (r!=MAIL_NO_ERROR) { | 48 | if (r!=MAIL_NO_ERROR) { |
47 | qDebug("error connecting storage "); | 49 | qDebug("error connecting storage "); |
48 | mailstorage_free(m_storage); | 50 | mailstorage_free(m_storage); |
49 | m_storage = 0; | 51 | m_storage = 0; |
50 | } | 52 | } |
51 | } | 53 | } |
52 | 54 | ||
53 | void MHwrapper::clean_storage() | 55 | void MHwrapper::clean_storage() |
54 | { | 56 | { |
55 | if (m_storage) { | 57 | if (m_storage) { |
56 | mailstorage_disconnect(m_storage); | 58 | mailstorage_disconnect(m_storage); |
57 | mailstorage_free(m_storage); | 59 | mailstorage_free(m_storage); |
58 | m_storage = 0; | 60 | m_storage = 0; |
59 | } | 61 | } |
60 | } | 62 | } |
61 | 63 | ||
62 | MHwrapper::~MHwrapper() | 64 | MHwrapper::~MHwrapper() |
63 | { | 65 | { |
64 | clean_storage(); | 66 | clean_storage(); |
65 | } | 67 | } |
66 | 68 | ||
67 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) | 69 | void MHwrapper::listMessages(const QString & mailbox, Q3ValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) |
68 | { | 70 | { |
69 | init_storage(); | 71 | init_storage(); |
70 | if (!m_storage) { | 72 | if (!m_storage) { |
71 | return; | 73 | return; |
72 | } | 74 | } |
73 | QString f = buildPath(mailbox); | 75 | QString f = buildPath(mailbox); |
74 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 76 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
75 | if (r!=MAIL_NO_ERROR) { | 77 | if (r!=MAIL_NO_ERROR) { |
76 | qDebug("listMessages: error selecting folder! "); | 78 | qDebug("listMessages: error selecting folder! "); |
77 | return; | 79 | return; |
78 | } | 80 | } |
79 | parseList(target,m_storage->sto_session,f, false, maxSizeInKb ); | 81 | parseList(target,m_storage->sto_session,f, false, maxSizeInKb ); |
80 | Global::statusMessage(i18n("Mailbox has %1 mail(s)").arg(target.count())); | 82 | Global::statusMessage(i18n("Mailbox has %1 mail(s)").arg(target.count())); |
81 | } | 83 | } |
82 | 84 | ||
83 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() | 85 | Q3ValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() |
84 | { | 86 | { |
85 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 87 | Q3ValueList<Opie::Core::OSmartPointer<Folder> >* folders = new Q3ValueList<Opie::Core::OSmartPointer<Folder> >(); |
86 | /* this is needed! */ | 88 | /* this is needed! */ |
87 | if (m_storage) mailstorage_disconnect(m_storage); | 89 | if (m_storage) mailstorage_disconnect(m_storage); |
88 | init_storage(); | 90 | init_storage(); |
89 | if (!m_storage) { | 91 | if (!m_storage) { |
90 | return folders; | 92 | return folders; |
91 | } | 93 | } |
92 | mail_list*flist = 0; | 94 | mail_list*flist = 0; |
93 | clistcell*current=0; | 95 | clistcell*current=0; |
94 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); | 96 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); |
95 | if (r != MAIL_NO_ERROR || !flist) { | 97 | if (r != MAIL_NO_ERROR || !flist) { |
96 | qDebug("error getting folder list "); | 98 | qDebug("error getting folder list "); |
97 | return folders; | 99 | return folders; |
98 | } | 100 | } |
99 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { | 101 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { |
100 | QString t = (char*)current->data; | 102 | QString t = (char*)current->data; |
101 | t.replace(0,MHPath.length(),""); | 103 | t.replace(0,MHPath.length(),""); |
102 | folders->append(new MHFolder(t,MHPath)); | 104 | folders->append(new MHFolder(t,MHPath)); |
103 | } | 105 | } |
104 | mail_list_free(flist); | 106 | mail_list_free(flist); |
105 | return folders; | 107 | return folders; |
106 | } | 108 | } |
107 | 109 | ||
108 | void MHwrapper::deleteMail(const RecMailP&mail) | 110 | void MHwrapper::deleteMail(const RecMailP&mail) |
109 | { | 111 | { |
@@ -234,57 +236,57 @@ encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) | |||
234 | mailmessage * msg = 0; | 236 | mailmessage * msg = 0; |
235 | char*data=0; | 237 | char*data=0; |
236 | size_t size; | 238 | size_t size; |
237 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 239 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
238 | if (r!=MAIL_NO_ERROR) { | 240 | if (r!=MAIL_NO_ERROR) { |
239 | qDebug("error selecting folder! "); | 241 | qDebug("error selecting folder! "); |
240 | return result; | 242 | return result; |
241 | } | 243 | } |
242 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); | 244 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); |
243 | if (r != MAIL_NO_ERROR) { | 245 | if (r != MAIL_NO_ERROR) { |
244 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); | 246 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); |
245 | return 0; | 247 | return 0; |
246 | } | 248 | } |
247 | r = mailmessage_fetch(msg,&data,&size); | 249 | r = mailmessage_fetch(msg,&data,&size); |
248 | if (r != MAIL_NO_ERROR) { | 250 | if (r != MAIL_NO_ERROR) { |
249 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); | 251 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); |
250 | if (msg) mailmessage_free(msg); | 252 | if (msg) mailmessage_free(msg); |
251 | return 0; | 253 | return 0; |
252 | } | 254 | } |
253 | result = new encodedString(data,size); | 255 | result = new encodedString(data,size); |
254 | if (msg) mailmessage_free(msg); | 256 | if (msg) mailmessage_free(msg); |
255 | return result; | 257 | return result; |
256 | } | 258 | } |
257 | 259 | ||
258 | void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) | 260 | void MHwrapper::deleteMails(const QString & mailbox,const Q3ValueList<RecMailP> &target) |
259 | { | 261 | { |
260 | QString f = buildPath(mailbox); | 262 | QString f = buildPath(mailbox); |
261 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 263 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
262 | if (r!=MAIL_NO_ERROR) { | 264 | if (r!=MAIL_NO_ERROR) { |
263 | qDebug("deleteMails: error selecting folder! "); | 265 | qDebug("deleteMails: error selecting folder! "); |
264 | return; | 266 | return; |
265 | } | 267 | } |
266 | QValueList<RecMailP>::ConstIterator it; | 268 | Q3ValueList<RecMailP>::ConstIterator it; |
267 | for (it=target.begin(); it!=target.end();++it) { | 269 | for (it=target.begin(); it!=target.end();++it) { |
268 | r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); | 270 | r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); |
269 | if (r != MAIL_NO_ERROR) { | 271 | if (r != MAIL_NO_ERROR) { |
270 | qDebug("error deleting mail "); | 272 | qDebug("error deleting mail "); |
271 | break; | 273 | break; |
272 | } | 274 | } |
273 | } | 275 | } |
274 | } | 276 | } |
275 | 277 | ||
276 | int MHwrapper::deleteAllMail(const FolderP&tfolder) | 278 | int MHwrapper::deleteAllMail(const FolderP&tfolder) |
277 | { | 279 | { |
278 | init_storage(); | 280 | init_storage(); |
279 | if (!m_storage) { | 281 | if (!m_storage) { |
280 | return 0; | 282 | return 0; |
281 | } | 283 | } |
282 | int res = 1; | 284 | int res = 1; |
283 | if (!tfolder) return 0; | 285 | if (!tfolder) return 0; |
284 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 286 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
285 | if (r!=MAIL_NO_ERROR) { | 287 | if (r!=MAIL_NO_ERROR) { |
286 | qDebug("error selecting folder! "); | 288 | qDebug("error selecting folder! "); |
287 | return 0; | 289 | return 0; |
288 | } | 290 | } |
289 | mailmessage_list*l=0; | 291 | mailmessage_list*l=0; |
290 | r = mailsession_get_messages_list(m_storage->sto_session,&l); | 292 | r = mailsession_get_messages_list(m_storage->sto_session,&l); |
diff --git a/kmicromail/libmailwrapper/mhwrapper.h b/kmicromail/libmailwrapper/mhwrapper.h index 36a443a..6151ff1 100644 --- a/kmicromail/libmailwrapper/mhwrapper.h +++ b/kmicromail/libmailwrapper/mhwrapper.h | |||
@@ -1,59 +1,61 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef __MH_WRAPPER_H | 2 | #ifndef __MH_WRAPPER_H |
3 | #define __MH_WRAPPER_H | 3 | #define __MH_WRAPPER_H |
4 | 4 | ||
5 | #include "maildefines.h" | 5 | #include "maildefines.h" |
6 | 6 | ||
7 | #include "genericwrapper.h" | 7 | #include "genericwrapper.h" |
8 | #include <qstring.h> | 8 | #include <qstring.h> |
9 | //Added by qt3to4: | ||
10 | #include <Q3ValueList> | ||
9 | 11 | ||
10 | class encodedString; | 12 | class encodedString; |
11 | struct mailmbox_folder; | 13 | struct mailmbox_folder; |
12 | class MHwrapper : public Genericwrapper | 14 | class MHwrapper : public Genericwrapper |
13 | { | 15 | { |
14 | Q_OBJECT | 16 | Q_OBJECT |
15 | public: | 17 | public: |
16 | MHwrapper(const QString & dir,const QString&name); | 18 | MHwrapper(const QString & dir,const QString&name); |
17 | virtual ~MHwrapper(); | 19 | virtual ~MHwrapper(); |
18 | 20 | ||
19 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); | 21 | virtual void listMessages(const QString & mailbox, Q3ValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); |
20 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 22 | virtual Q3ValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
21 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 23 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
22 | 24 | ||
23 | virtual void deleteMail(const RecMailP&mail); | 25 | virtual void deleteMail(const RecMailP&mail); |
24 | virtual void answeredMail(const RecMailP&mail); | 26 | virtual void answeredMail(const RecMailP&mail); |
25 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 27 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
26 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, | 28 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, |
27 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 29 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
28 | 30 | ||
29 | virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0, | 31 | virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0, |
30 | const QString&d="",bool s=false); | 32 | const QString&d="",bool s=false); |
31 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&); | 33 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&); |
32 | 34 | ||
33 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 35 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
34 | 36 | ||
35 | virtual RecBodyP fetchBody( const RecMailP &mail ); | 37 | virtual RecBodyP fetchBody( const RecMailP &mail ); |
36 | static void mbox_progress( size_t current, size_t maximum ); | 38 | static void mbox_progress( size_t current, size_t maximum ); |
37 | 39 | ||
38 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 40 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
39 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> > &target); | 41 | virtual void deleteMails(const QString & FolderName,const Q3ValueList<Opie::Core::OSmartPointer<RecMail> > &target); |
40 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); | 42 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
41 | virtual MAILLIB::ATYPE getType()const; | 43 | virtual MAILLIB::ATYPE getType()const; |
42 | virtual const QString&getName()const; | 44 | virtual const QString&getName()const; |
43 | virtual Account* getAccount() { return 0; }; | 45 | virtual Account* getAccount() { return 0; }; |
44 | 46 | ||
45 | public slots: | 47 | public slots: |
46 | 48 | ||
47 | protected: | 49 | protected: |
48 | QString buildPath(const QString&p); | 50 | QString buildPath(const QString&p); |
49 | QString MHPath; | 51 | QString MHPath; |
50 | QString MHName; | 52 | QString MHName; |
51 | 53 | ||
52 | void init_storage(); | 54 | void init_storage(); |
53 | void clean_storage(); | 55 | void clean_storage(); |
54 | bool rmDir(QString folderabspath); | 56 | bool rmDir(QString folderabspath); |
55 | 57 | ||
56 | bool removeMboxfailed; | 58 | bool removeMboxfailed; |
57 | }; | 59 | }; |
58 | 60 | ||
59 | #endif | 61 | #endif |
diff --git a/kmicromail/libmailwrapper/nntpwrapper.cpp b/kmicromail/libmailwrapper/nntpwrapper.cpp index 93cd2b5..b328ecd 100644 --- a/kmicromail/libmailwrapper/nntpwrapper.cpp +++ b/kmicromail/libmailwrapper/nntpwrapper.cpp | |||
@@ -1,30 +1,32 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "nntpwrapper.h" | 2 | #include "nntpwrapper.h" |
3 | #include "logindialog.h" | 3 | #include "logindialog.h" |
4 | #include "mailtypes.h" | 4 | #include "mailtypes.h" |
5 | 5 | ||
6 | #include <qfile.h> | 6 | #include <qfile.h> |
7 | //Added by qt3to4: | ||
8 | #include <Q3ValueList> | ||
7 | 9 | ||
8 | #include <stdlib.h> | 10 | #include <stdlib.h> |
9 | 11 | ||
10 | #include <libetpan/libetpan.h> | 12 | #include <libetpan/libetpan.h> |
11 | 13 | ||
12 | 14 | ||
13 | 15 | ||
14 | #define HARD_MSG_SIZE_LIMIT 5242880 | 16 | #define HARD_MSG_SIZE_LIMIT 5242880 |
15 | 17 | ||
16 | using namespace Opie::Core; | 18 | using namespace Opie::Core; |
17 | NNTPwrapper::NNTPwrapper( NNTPaccount *a ) | 19 | NNTPwrapper::NNTPwrapper( NNTPaccount *a ) |
18 | : Genericwrapper() { | 20 | : Genericwrapper() { |
19 | account = a; | 21 | account = a; |
20 | m_nntp = NULL; | 22 | m_nntp = NULL; |
21 | msgTempName = a->getFileName()+"_msg_cache"; | 23 | msgTempName = a->getFileName()+"_msg_cache"; |
22 | last_msg_id = 0; | 24 | last_msg_id = 0; |
23 | } | 25 | } |
24 | 26 | ||
25 | NNTPwrapper::~NNTPwrapper() { | 27 | NNTPwrapper::~NNTPwrapper() { |
26 | logout(); | 28 | logout(); |
27 | QFile msg_cache(msgTempName); | 29 | QFile msg_cache(msgTempName); |
28 | if (msg_cache.exists()) { | 30 | if (msg_cache.exists()) { |
29 | msg_cache.remove(); | 31 | msg_cache.remove(); |
30 | } | 32 | } |
@@ -39,88 +41,88 @@ RecBodyP NNTPwrapper::fetchBody( const RecMailP &mail ) { | |||
39 | int err = NEWSNNTP_NO_ERROR; | 41 | int err = NEWSNNTP_NO_ERROR; |
40 | char *message = 0; | 42 | char *message = 0; |
41 | size_t length = 0; | 43 | size_t length = 0; |
42 | 44 | ||
43 | RecBodyP body = new RecBody(); | 45 | RecBodyP body = new RecBody(); |
44 | login(); | 46 | login(); |
45 | if ( !m_nntp ) { | 47 | if ( !m_nntp ) { |
46 | return body; | 48 | return body; |
47 | } | 49 | } |
48 | 50 | ||
49 | mailmessage * mailmsg; | 51 | mailmessage * mailmsg; |
50 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { | 52 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { |
51 | ; // << "Message to large: " << mail->Msgsize() << "" << oendl; | 53 | ; // << "Message to large: " << mail->Msgsize() << "" << oendl; |
52 | return body; | 54 | return body; |
53 | } | 55 | } |
54 | 56 | ||
55 | QFile msg_cache(msgTempName); | 57 | QFile msg_cache(msgTempName); |
56 | 58 | ||
57 | cleanMimeCache(); | 59 | cleanMimeCache(); |
58 | 60 | ||
59 | if (mail->getNumber()!=last_msg_id) { | 61 | if (mail->getNumber()!=last_msg_id) { |
60 | if (msg_cache.exists()) { | 62 | if (msg_cache.exists()) { |
61 | msg_cache.remove(); | 63 | msg_cache.remove(); |
62 | } | 64 | } |
63 | msg_cache.open(IO_ReadWrite|IO_Truncate); | 65 | msg_cache.open(QIODevice::ReadWrite|QIODevice::Truncate); |
64 | last_msg_id = mail->getNumber(); | 66 | last_msg_id = mail->getNumber(); |
65 | err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg); | 67 | err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg); |
66 | err = mailmessage_fetch(mailmsg,&message,&length); | 68 | err = mailmessage_fetch(mailmsg,&message,&length); |
67 | msg_cache.writeBlock(message,length); | 69 | msg_cache.writeBlock(message,length); |
68 | } else { | 70 | } else { |
69 | QString msg=""; | 71 | QString msg=""; |
70 | msg_cache.open(IO_ReadOnly); | 72 | msg_cache.open(QIODevice::ReadOnly); |
71 | message = new char[4096]; | 73 | message = new char[4096]; |
72 | memset(message,0,4096); | 74 | memset(message,0,4096); |
73 | while (msg_cache.readBlock(message,4095)>0) { | 75 | while (msg_cache.readBlock(message,4095)>0) { |
74 | msg+=message; | 76 | msg+=message; |
75 | memset(message,0,4096); | 77 | memset(message,0,4096); |
76 | } | 78 | } |
77 | delete message; | 79 | delete message; |
78 | message = (char*)malloc(msg.length()+1*sizeof(char)); | 80 | message = (char*)malloc(msg.length()+1*sizeof(char)); |
79 | memset(message,0,msg.length()+1); | 81 | memset(message,0,msg.length()+1); |
80 | memcpy(message,msg.latin1(),msg.length()); | 82 | memcpy(message,msg.latin1(),msg.length()); |
81 | /* transform to libetpan stuff */ | 83 | /* transform to libetpan stuff */ |
82 | mailmsg = mailmessage_new(); | 84 | mailmsg = mailmessage_new(); |
83 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); | 85 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); |
84 | generic_message_t * msg_data; | 86 | generic_message_t * msg_data; |
85 | msg_data = (generic_message_t *)mailmsg->msg_data; | 87 | msg_data = (generic_message_t *)mailmsg->msg_data; |
86 | msg_data->msg_fetched = 1; | 88 | msg_data->msg_fetched = 1; |
87 | msg_data->msg_message = message; | 89 | msg_data->msg_message = message; |
88 | msg_data->msg_length = strlen(message); | 90 | msg_data->msg_length = strlen(message); |
89 | } | 91 | } |
90 | body = parseMail(mailmsg); | 92 | body = parseMail(mailmsg); |
91 | 93 | ||
92 | /* clean up */ | 94 | /* clean up */ |
93 | if (mailmsg) | 95 | if (mailmsg) |
94 | mailmessage_free(mailmsg); | 96 | mailmessage_free(mailmsg); |
95 | if (message) | 97 | if (message) |
96 | free(message); | 98 | free(message); |
97 | 99 | ||
98 | return body; | 100 | return body; |
99 | } | 101 | } |
100 | 102 | ||
101 | 103 | ||
102 | void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb) | 104 | void NNTPwrapper::listMessages(const QString & which, Q3ValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb) |
103 | { | 105 | { |
104 | login(); | 106 | login(); |
105 | if (!m_nntp) | 107 | if (!m_nntp) |
106 | return; | 108 | return; |
107 | uint32_t res_messages,res_recent,res_unseen; | 109 | uint32_t res_messages,res_recent,res_unseen; |
108 | mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); | 110 | mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); |
109 | parseList(target,m_nntp->sto_session,which,true, maxSizeInKb); | 111 | parseList(target,m_nntp->sto_session,which,true, maxSizeInKb); |
110 | } | 112 | } |
111 | 113 | ||
112 | void NNTPwrapper::login() | 114 | void NNTPwrapper::login() |
113 | { | 115 | { |
114 | if (account->getOffline()) | 116 | if (account->getOffline()) |
115 | return; | 117 | return; |
116 | /* we'll hold the line */ | 118 | /* we'll hold the line */ |
117 | if ( m_nntp != NULL ) | 119 | if ( m_nntp != NULL ) |
118 | return; | 120 | return; |
119 | 121 | ||
120 | QString server; | 122 | QString server; |
121 | QString User,Pass; | 123 | QString User,Pass; |
122 | uint16_t port; | 124 | uint16_t port; |
123 | int err = NEWSNNTP_NO_ERROR; | 125 | int err = NEWSNNTP_NO_ERROR; |
124 | 126 | ||
125 | server = account->getServer(); | 127 | server = account->getServer(); |
126 | port = account->getPort().toUInt(); | 128 | port = account->getPort().toUInt(); |
@@ -165,51 +167,51 @@ void NNTPwrapper::login() | |||
165 | 167 | ||
166 | if (err != NEWSNNTP_NO_ERROR) { | 168 | if (err != NEWSNNTP_NO_ERROR) { |
167 | ; // << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; | 169 | ; // << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; |
168 | // Global::statusMessage(tr("Error initializing folder")); | 170 | // Global::statusMessage(tr("Error initializing folder")); |
169 | mailstorage_free(m_nntp); | 171 | mailstorage_free(m_nntp); |
170 | m_nntp = 0; | 172 | m_nntp = 0; |
171 | 173 | ||
172 | } else { | 174 | } else { |
173 | mailsession * session = m_nntp->sto_session; | 175 | mailsession * session = m_nntp->sto_session; |
174 | newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; | 176 | newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; |
175 | news->nntp_progr_fun = &nntp_progress; | 177 | news->nntp_progr_fun = &nntp_progress; |
176 | } | 178 | } |
177 | 179 | ||
178 | } | 180 | } |
179 | 181 | ||
180 | void NNTPwrapper::logout() | 182 | void NNTPwrapper::logout() |
181 | { | 183 | { |
182 | int err = NEWSNNTP_NO_ERROR; | 184 | int err = NEWSNNTP_NO_ERROR; |
183 | if ( m_nntp == NULL ) | 185 | if ( m_nntp == NULL ) |
184 | return; | 186 | return; |
185 | mailstorage_free(m_nntp); | 187 | mailstorage_free(m_nntp); |
186 | m_nntp = 0; | 188 | m_nntp = 0; |
187 | } | 189 | } |
188 | 190 | ||
189 | QValueList<Opie::Core::OSmartPointer<Folder> >* NNTPwrapper::listFolders() { | 191 | Q3ValueList<Opie::Core::OSmartPointer<Folder> >* NNTPwrapper::listFolders() { |
190 | 192 | ||
191 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 193 | Q3ValueList<Opie::Core::OSmartPointer<Folder> >* folders = new Q3ValueList<Opie::Core::OSmartPointer<Folder> >(); |
192 | QStringList groups; | 194 | QStringList groups; |
193 | if (account) { | 195 | if (account) { |
194 | groups = account->getGroups(); | 196 | groups = account->getGroups(); |
195 | } | 197 | } |
196 | for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { | 198 | for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { |
197 | folders->append(new Folder((*it),".")); | 199 | folders->append(new Folder((*it),".")); |
198 | } | 200 | } |
199 | return folders; | 201 | return folders; |
200 | } | 202 | } |
201 | 203 | ||
202 | /* we made this method in raw nntp access of etpan and not via generic interface | 204 | /* we made this method in raw nntp access of etpan and not via generic interface |
203 | * 'cause in that case there will be doubled copy operations. eg. the etpan would | 205 | * 'cause in that case there will be doubled copy operations. eg. the etpan would |
204 | * copy that stuff into its own structures and we must copy it into useable c++ | 206 | * copy that stuff into its own structures and we must copy it into useable c++ |
205 | * structures for our frontend. this would not make sense, so it is better to reimplement | 207 | * structures for our frontend. this would not make sense, so it is better to reimplement |
206 | * the stuff from generic interface of etpan but copy it direct to qt classes. | 208 | * the stuff from generic interface of etpan but copy it direct to qt classes. |
207 | */ | 209 | */ |
208 | QStringList NNTPwrapper::listAllNewsgroups(const QString&mask) { | 210 | QStringList NNTPwrapper::listAllNewsgroups(const QString&mask) { |
209 | login(); | 211 | login(); |
210 | QStringList res; | 212 | QStringList res; |
211 | clist *result = 0; | 213 | clist *result = 0; |
212 | clistcell *current = 0; | 214 | clistcell *current = 0; |
213 | newsnntp_group_description *group; | 215 | newsnntp_group_description *group; |
214 | 216 | ||
215 | if ( m_nntp ) { | 217 | if ( m_nntp ) { |
diff --git a/kmicromail/libmailwrapper/nntpwrapper.h b/kmicromail/libmailwrapper/nntpwrapper.h index 8c54f12..7c8e671 100644 --- a/kmicromail/libmailwrapper/nntpwrapper.h +++ b/kmicromail/libmailwrapper/nntpwrapper.h | |||
@@ -1,50 +1,52 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef __NNTPWRAPPER | 2 | #ifndef __NNTPWRAPPER |
3 | #define __NNTPWRAPPER | 3 | #define __NNTPWRAPPER |
4 | 4 | ||
5 | #include "mailwrapper.h" | 5 | #include "mailwrapper.h" |
6 | #include "genericwrapper.h" | 6 | #include "genericwrapper.h" |
7 | #include <qstring.h> | 7 | #include <qstring.h> |
8 | //Added by qt3to4: | ||
9 | #include <Q3ValueList> | ||
8 | #include <libetpan/clist.h> | 10 | #include <libetpan/clist.h> |
9 | 11 | ||
10 | class encodedString; | 12 | class encodedString; |
11 | struct mailstorage; | 13 | struct mailstorage; |
12 | struct mailfolder; | 14 | struct mailfolder; |
13 | 15 | ||
14 | class NNTPwrapper : public Genericwrapper | 16 | class NNTPwrapper : public Genericwrapper |
15 | { | 17 | { |
16 | 18 | ||
17 | Q_OBJECT | 19 | Q_OBJECT |
18 | 20 | ||
19 | public: | 21 | public: |
20 | NNTPwrapper( NNTPaccount *a ); | 22 | NNTPwrapper( NNTPaccount *a ); |
21 | virtual ~NNTPwrapper(); | 23 | virtual ~NNTPwrapper(); |
22 | 24 | ||
23 | /* mailbox will be ignored */ | 25 | /* mailbox will be ignored */ |
24 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); | 26 | virtual void listMessages(const QString & mailbox, Q3ValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); |
25 | /* should only get the subscribed one */ | 27 | /* should only get the subscribed one */ |
26 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 28 | virtual Q3ValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
27 | /* mailbox will be ignored */ | 29 | /* mailbox will be ignored */ |
28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 30 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
29 | QStringList listAllNewsgroups(const QString&mask = QString::null); | 31 | QStringList listAllNewsgroups(const QString&mask = QString::null); |
30 | virtual void deleteMail(const RecMailP&mail); | 32 | virtual void deleteMail(const RecMailP&mail); |
31 | virtual void answeredMail(const RecMailP&mail); | 33 | virtual void answeredMail(const RecMailP&mail); |
32 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); | 34 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
33 | 35 | ||
34 | virtual RecBodyP fetchBody( const RecMailP &mail ); | 36 | virtual RecBodyP fetchBody( const RecMailP &mail ); |
35 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 37 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
36 | virtual void logout(); | 38 | virtual void logout(); |
37 | virtual MAILLIB::ATYPE getType()const; | 39 | virtual MAILLIB::ATYPE getType()const; |
38 | virtual const QString&getName()const; | 40 | virtual const QString&getName()const; |
39 | static void nntp_progress( size_t current, size_t maximum ); | 41 | static void nntp_progress( size_t current, size_t maximum ); |
40 | virtual Account* getAccount() { return account; }; | 42 | virtual Account* getAccount() { return account; }; |
41 | 43 | ||
42 | protected: | 44 | protected: |
43 | void login(); | 45 | void login(); |
44 | NNTPaccount *account; | 46 | NNTPaccount *account; |
45 | mailstorage* m_nntp; | 47 | mailstorage* m_nntp; |
46 | 48 | ||
47 | 49 | ||
48 | }; | 50 | }; |
49 | 51 | ||
50 | #endif | 52 | #endif |
diff --git a/kmicromail/libmailwrapper/pop3wrapper.cpp b/kmicromail/libmailwrapper/pop3wrapper.cpp index 2888f7c..ebeed71 100644 --- a/kmicromail/libmailwrapper/pop3wrapper.cpp +++ b/kmicromail/libmailwrapper/pop3wrapper.cpp | |||
@@ -1,37 +1,39 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include "pop3wrapper.h" | 3 | #include "pop3wrapper.h" |
4 | #include "mailtypes.h" | 4 | #include "mailtypes.h" |
5 | #include "logindialog.h" | 5 | #include "logindialog.h" |
6 | #include <libetpan/libetpan.h> | 6 | #include <libetpan/libetpan.h> |
7 | 7 | ||
8 | #include <klocale.h> | 8 | #include <klocale.h> |
9 | 9 | ||
10 | #include <qpe/global.h> | 10 | #include <qpe/global.h> |
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qprogressbar.h> | 12 | #include <q3progressbar.h> |
13 | #include <qapplication.h> | 13 | #include <qapplication.h> |
14 | //Added by qt3to4: | ||
15 | #include <Q3ValueList> | ||
14 | 16 | ||
15 | /* we don't fetch messages larger than 5 MB */ | 17 | /* we don't fetch messages larger than 5 MB */ |
16 | #define HARD_MSG_SIZE_LIMIT 5242880 | 18 | #define HARD_MSG_SIZE_LIMIT 5242880 |
17 | 19 | ||
18 | using namespace Opie::Core; | 20 | using namespace Opie::Core; |
19 | POP3wrapper::POP3wrapper( POP3account *a ) | 21 | POP3wrapper::POP3wrapper( POP3account *a ) |
20 | : Genericwrapper() { | 22 | : Genericwrapper() { |
21 | account = a; | 23 | account = a; |
22 | m_pop3 = NULL; | 24 | m_pop3 = NULL; |
23 | msgTempName = a->getFileName()+"_msg_cache"; | 25 | msgTempName = a->getFileName()+"_msg_cache"; |
24 | last_msg_id = 0; | 26 | last_msg_id = 0; |
25 | } | 27 | } |
26 | 28 | ||
27 | POP3wrapper::~POP3wrapper() { | 29 | POP3wrapper::~POP3wrapper() { |
28 | logout(); | 30 | logout(); |
29 | QFile msg_cache(msgTempName); | 31 | QFile msg_cache(msgTempName); |
30 | if (msg_cache.exists()) { | 32 | if (msg_cache.exists()) { |
31 | msg_cache.remove(); | 33 | msg_cache.remove(); |
32 | } | 34 | } |
33 | } | 35 | } |
34 | 36 | ||
35 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { | 37 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { |
36 | ; // odebug << "POP3: " << current << " of " << maximum << "" << oendl; | 38 | ; // odebug << "POP3: " << current << " of " << maximum << "" << oendl; |
37 | } | 39 | } |
@@ -41,87 +43,87 @@ RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { | |||
41 | char *message = 0; | 43 | char *message = 0; |
42 | size_t length = 0; | 44 | size_t length = 0; |
43 | 45 | ||
44 | RecBodyP body = new RecBody(); | 46 | RecBodyP body = new RecBody(); |
45 | 47 | ||
46 | login(); | 48 | login(); |
47 | if ( !m_pop3 ) { | 49 | if ( !m_pop3 ) { |
48 | return body; | 50 | return body; |
49 | } | 51 | } |
50 | 52 | ||
51 | mailmessage * mailmsg; | 53 | mailmessage * mailmsg; |
52 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { | 54 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { |
53 | ; // odebug << "Message to large: " << mail->Msgsize() << "" << oendl; | 55 | ; // odebug << "Message to large: " << mail->Msgsize() << "" << oendl; |
54 | return body; | 56 | return body; |
55 | } | 57 | } |
56 | 58 | ||
57 | QFile msg_cache(msgTempName); | 59 | QFile msg_cache(msgTempName); |
58 | 60 | ||
59 | cleanMimeCache(); | 61 | cleanMimeCache(); |
60 | 62 | ||
61 | if (mail->getNumber()!=last_msg_id) { | 63 | if (mail->getNumber()!=last_msg_id) { |
62 | if (msg_cache.exists()) { | 64 | if (msg_cache.exists()) { |
63 | msg_cache.remove(); | 65 | msg_cache.remove(); |
64 | } | 66 | } |
65 | msg_cache.open(IO_ReadWrite|IO_Truncate); | 67 | msg_cache.open(QIODevice::ReadWrite|QIODevice::Truncate); |
66 | last_msg_id = mail->getNumber(); | 68 | last_msg_id = mail->getNumber(); |
67 | err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); | 69 | err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); |
68 | err = mailmessage_fetch(mailmsg,&message,&length); | 70 | err = mailmessage_fetch(mailmsg,&message,&length); |
69 | msg_cache.writeBlock(message,length); | 71 | msg_cache.writeBlock(message,length); |
70 | } else { | 72 | } else { |
71 | QString msg=""; | 73 | QString msg=""; |
72 | msg_cache.open(IO_ReadOnly); | 74 | msg_cache.open(QIODevice::ReadOnly); |
73 | message = new char[4096]; | 75 | message = new char[4096]; |
74 | memset(message,0,4096); | 76 | memset(message,0,4096); |
75 | while (msg_cache.readBlock(message,4095)>0) { | 77 | while (msg_cache.readBlock(message,4095)>0) { |
76 | msg+=message; | 78 | msg+=message; |
77 | memset(message,0,4096); | 79 | memset(message,0,4096); |
78 | } | 80 | } |
79 | delete message; | 81 | delete message; |
80 | message = (char*)malloc(msg.length()+1*sizeof(char)); | 82 | message = (char*)malloc(msg.length()+1*sizeof(char)); |
81 | memset(message,0,msg.length()+1); | 83 | memset(message,0,msg.length()+1); |
82 | memcpy(message,msg.latin1(),msg.length()); | 84 | memcpy(message,msg.latin1(),msg.length()); |
83 | /* transform to libetpan stuff */ | 85 | /* transform to libetpan stuff */ |
84 | mailmsg = mailmessage_new(); | 86 | mailmsg = mailmessage_new(); |
85 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); | 87 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); |
86 | generic_message_t * msg_data; | 88 | generic_message_t * msg_data; |
87 | msg_data = (generic_message_t *)mailmsg->msg_data; | 89 | msg_data = (generic_message_t *)mailmsg->msg_data; |
88 | msg_data->msg_fetched = 1; | 90 | msg_data->msg_fetched = 1; |
89 | msg_data->msg_message = message; | 91 | msg_data->msg_message = message; |
90 | msg_data->msg_length = strlen(message); | 92 | msg_data->msg_length = strlen(message); |
91 | } | 93 | } |
92 | body = parseMail(mailmsg); | 94 | body = parseMail(mailmsg); |
93 | 95 | ||
94 | /* clean up */ | 96 | /* clean up */ |
95 | if (mailmsg) | 97 | if (mailmsg) |
96 | mailmessage_free(mailmsg); | 98 | mailmessage_free(mailmsg); |
97 | if (message) | 99 | if (message) |
98 | free(message); | 100 | free(message); |
99 | 101 | ||
100 | return body; | 102 | return body; |
101 | } | 103 | } |
102 | 104 | ||
103 | void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) | 105 | void POP3wrapper::listMessages(const QString &, Q3ValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) |
104 | { | 106 | { |
105 | login(); | 107 | login(); |
106 | if (!m_pop3) | 108 | if (!m_pop3) |
107 | return; | 109 | return; |
108 | uint32_t res_messages,res_recent,res_unseen; | 110 | uint32_t res_messages,res_recent,res_unseen; |
109 | mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); | 111 | mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); |
110 | parseList(target,m_pop3->sto_session,"INBOX", false, maxSizeInKb); | 112 | parseList(target,m_pop3->sto_session,"INBOX", false, maxSizeInKb); |
111 | Global::statusMessage( i18n("Mailbox contains %1 mail(s)").arg(res_messages)); | 113 | Global::statusMessage( i18n("Mailbox contains %1 mail(s)").arg(res_messages)); |
112 | } | 114 | } |
113 | 115 | ||
114 | void POP3wrapper::login() | 116 | void POP3wrapper::login() |
115 | { | 117 | { |
116 | if (account->getOffline()) | 118 | if (account->getOffline()) |
117 | return; | 119 | return; |
118 | /* we'll hold the line */ | 120 | /* we'll hold the line */ |
119 | if ( m_pop3 != NULL ) | 121 | if ( m_pop3 != NULL ) |
120 | return; | 122 | return; |
121 | 123 | ||
122 | QString server,user, pass; | 124 | QString server,user, pass; |
123 | uint16_t port; | 125 | uint16_t port; |
124 | int err = MAILPOP3_NO_ERROR; | 126 | int err = MAILPOP3_NO_ERROR; |
125 | 127 | ||
126 | server = account->getServer(); | 128 | server = account->getServer(); |
127 | port = account->getPort().toUInt(); | 129 | port = account->getPort().toUInt(); |
@@ -166,108 +168,108 @@ void POP3wrapper::login() | |||
166 | err = mailstorage_connect(m_pop3); | 168 | err = mailstorage_connect(m_pop3); |
167 | if (err != MAIL_NO_ERROR) { | 169 | if (err != MAIL_NO_ERROR) { |
168 | ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; | 170 | ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; |
169 | Global::statusMessage(i18n("Error %1 initializing folder").arg( err )); | 171 | Global::statusMessage(i18n("Error %1 initializing folder").arg( err )); |
170 | mailstorage_free(m_pop3); | 172 | mailstorage_free(m_pop3); |
171 | m_pop3 = 0; | 173 | m_pop3 = 0; |
172 | } else { | 174 | } else { |
173 | mailsession * session = m_pop3->sto_session; | 175 | mailsession * session = m_pop3->sto_session; |
174 | mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; | 176 | mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; |
175 | if (mail) { | 177 | if (mail) { |
176 | mail->pop3_progr_fun = &pop3_progress; | 178 | mail->pop3_progr_fun = &pop3_progress; |
177 | } | 179 | } |
178 | } | 180 | } |
179 | } | 181 | } |
180 | 182 | ||
181 | void POP3wrapper::logout() | 183 | void POP3wrapper::logout() |
182 | { | 184 | { |
183 | if ( m_pop3 == NULL ) | 185 | if ( m_pop3 == NULL ) |
184 | return; | 186 | return; |
185 | mailstorage_free(m_pop3); | 187 | mailstorage_free(m_pop3); |
186 | m_pop3 = 0; | 188 | m_pop3 = 0; |
187 | } | 189 | } |
188 | 190 | ||
189 | 191 | ||
190 | QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { | 192 | Q3ValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { |
191 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); | 193 | Q3ValueList<Opie::Core::OSmartPointer<Folder> >* folders = new Q3ValueList<FolderP>(); |
192 | FolderP inb=new Folder("INBOX","/"); | 194 | FolderP inb=new Folder("INBOX","/"); |
193 | folders->append(inb); | 195 | folders->append(inb); |
194 | return folders; | 196 | return folders; |
195 | } | 197 | } |
196 | 198 | ||
197 | void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target) | 199 | void POP3wrapper::deleteMailList(const Q3ValueList<RecMailP>&target) |
198 | { | 200 | { |
199 | login(); | 201 | login(); |
200 | if (!m_pop3) | 202 | if (!m_pop3) |
201 | return; | 203 | return; |
202 | int iii = 0; | 204 | int iii = 0; |
203 | int count = target.count(); | 205 | int count = target.count(); |
204 | 206 | ||
205 | QProgressBar wid ( count ); | 207 | Q3ProgressBar wid ( count ); |
206 | wid.setCaption( i18n("Deleting ...")); | 208 | wid.setCaption( i18n("Deleting ...")); |
207 | wid.show(); | 209 | wid.show(); |
208 | while (iii < count ) { | 210 | while (iii < count ) { |
209 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); | 211 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); |
210 | wid.setProgress( iii ); | 212 | wid.setProgress( iii ); |
211 | wid.raise(); | 213 | wid.raise(); |
212 | qApp->processEvents(); | 214 | qApp->processEvents(); |
213 | //qDebug("delete "); | 215 | //qDebug("delete "); |
214 | RecMailP mail = (*target.at( iii )); | 216 | RecMailP mail = (*target.at( iii )); |
215 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); | 217 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); |
216 | if (err != MAIL_NO_ERROR) { | 218 | if (err != MAIL_NO_ERROR) { |
217 | Global::statusMessage(i18n("Error deleting mail")); | 219 | Global::statusMessage(i18n("Error deleting mail")); |
218 | } | 220 | } |
219 | ++iii; | 221 | ++iii; |
220 | } | 222 | } |
221 | } | 223 | } |
222 | void POP3wrapper::deleteMail(const RecMailP&mail) { | 224 | void POP3wrapper::deleteMail(const RecMailP&mail) { |
223 | login(); | 225 | login(); |
224 | if (!m_pop3) | 226 | if (!m_pop3) |
225 | return; | 227 | return; |
226 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); | 228 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); |
227 | if (err != MAIL_NO_ERROR) { | 229 | if (err != MAIL_NO_ERROR) { |
228 | Global::statusMessage(i18n("error deleting mail")); | 230 | Global::statusMessage(i18n("error deleting mail")); |
229 | } | 231 | } |
230 | } | 232 | } |
231 | 233 | ||
232 | void POP3wrapper::answeredMail(const RecMailP&) {} | 234 | void POP3wrapper::answeredMail(const RecMailP&) {} |
233 | 235 | ||
234 | int POP3wrapper::deleteAllMail(const FolderP&) { | 236 | int POP3wrapper::deleteAllMail(const FolderP&) { |
235 | login(); | 237 | login(); |
236 | if (!m_pop3) | 238 | if (!m_pop3) |
237 | return 0; | 239 | return 0; |
238 | int res = 1; | 240 | int res = 1; |
239 | 241 | ||
240 | uint32_t result = 0; | 242 | uint32_t result = 0; |
241 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); | 243 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); |
242 | if (err != MAIL_NO_ERROR) { | 244 | if (err != MAIL_NO_ERROR) { |
243 | Global::statusMessage(i18n("Error getting folder info")); | 245 | Global::statusMessage(i18n("Error getting folder info")); |
244 | return 0; | 246 | return 0; |
245 | } | 247 | } |
246 | 248 | ||
247 | 249 | ||
248 | 250 | ||
249 | QProgressBar wid ( result ); | 251 | Q3ProgressBar wid ( result ); |
250 | wid.setCaption( i18n("Deleting ...")); | 252 | wid.setCaption( i18n("Deleting ...")); |
251 | wid.show(); | 253 | wid.show(); |
252 | for (unsigned int i = 0; i < result; ++i) { | 254 | for (unsigned int i = 0; i < result; ++i) { |
253 | Global::statusMessage(i18n("Delete message %1 of %2").arg(i).arg(result)); | 255 | Global::statusMessage(i18n("Delete message %1 of %2").arg(i).arg(result)); |
254 | wid.setProgress( i ); | 256 | wid.setProgress( i ); |
255 | wid.raise(); | 257 | wid.raise(); |
256 | qApp->processEvents(); | 258 | qApp->processEvents(); |
257 | 259 | ||
258 | err = mailsession_remove_message(m_pop3->sto_session,i+1); | 260 | err = mailsession_remove_message(m_pop3->sto_session,i+1); |
259 | if (err != MAIL_NO_ERROR) { | 261 | if (err != MAIL_NO_ERROR) { |
260 | Global::statusMessage(i18n("Error deleting mail %1").arg(i+1)); | 262 | Global::statusMessage(i18n("Error deleting mail %1").arg(i+1)); |
261 | res=0; | 263 | res=0; |
262 | } | 264 | } |
263 | break; | 265 | break; |
264 | } | 266 | } |
265 | return res; | 267 | return res; |
266 | } | 268 | } |
267 | 269 | ||
268 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { | 270 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { |
269 | login(); | 271 | login(); |
270 | target_stat.message_count = 0; | 272 | target_stat.message_count = 0; |
271 | target_stat.message_unseen = 0; | 273 | target_stat.message_unseen = 0; |
272 | target_stat.message_recent = 0; | 274 | target_stat.message_recent = 0; |
273 | if (!m_pop3) | 275 | if (!m_pop3) |
diff --git a/kmicromail/libmailwrapper/pop3wrapper.h b/kmicromail/libmailwrapper/pop3wrapper.h index ebc2fc7..a077877 100644 --- a/kmicromail/libmailwrapper/pop3wrapper.h +++ b/kmicromail/libmailwrapper/pop3wrapper.h | |||
@@ -1,44 +1,46 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef __POP3WRAPPER | 2 | #ifndef __POP3WRAPPER |
3 | #define __POP3WRAPPER | 3 | #define __POP3WRAPPER |
4 | 4 | ||
5 | #include "mailwrapper.h" | 5 | #include "mailwrapper.h" |
6 | #include "genericwrapper.h" | 6 | #include "genericwrapper.h" |
7 | #include <qstring.h> | 7 | #include <qstring.h> |
8 | //Added by qt3to4: | ||
9 | #include <Q3ValueList> | ||
8 | 10 | ||
9 | class encodedString; | 11 | class encodedString; |
10 | struct mailstorage; | 12 | struct mailstorage; |
11 | struct mailfolder; | 13 | struct mailfolder; |
12 | 14 | ||
13 | class POP3wrapper : public Genericwrapper | 15 | class POP3wrapper : public Genericwrapper |
14 | { | 16 | { |
15 | Q_OBJECT | 17 | Q_OBJECT |
16 | 18 | ||
17 | public: | 19 | public: |
18 | POP3wrapper( POP3account *a ); | 20 | POP3wrapper( POP3account *a ); |
19 | virtual ~POP3wrapper(); | 21 | virtual ~POP3wrapper(); |
20 | /* mailbox will be ignored */ | 22 | /* mailbox will be ignored */ |
21 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); | 23 | virtual void listMessages(const QString & mailbox, Q3ValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); |
22 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 24 | virtual Q3ValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
23 | /* mailbox will be ignored */ | 25 | /* mailbox will be ignored */ |
24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 26 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
25 | 27 | ||
26 | virtual void deleteMail(const RecMailP&mail); | 28 | virtual void deleteMail(const RecMailP&mail); |
27 | virtual void deleteMailList(const QValueList<RecMailP>&target); | 29 | virtual void deleteMailList(const Q3ValueList<RecMailP>&target); |
28 | virtual void answeredMail(const RecMailP&mail); | 30 | virtual void answeredMail(const RecMailP&mail); |
29 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); | 31 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
30 | 32 | ||
31 | virtual RecBodyP fetchBody( const RecMailP &mail ); | 33 | virtual RecBodyP fetchBody( const RecMailP &mail ); |
32 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 34 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
33 | virtual void logout(); | 35 | virtual void logout(); |
34 | virtual MAILLIB::ATYPE getType()const; | 36 | virtual MAILLIB::ATYPE getType()const; |
35 | virtual const QString&getName()const; | 37 | virtual const QString&getName()const; |
36 | static void pop3_progress( size_t current, size_t maximum ); | 38 | static void pop3_progress( size_t current, size_t maximum ); |
37 | virtual Account* getAccount() { return account; }; | 39 | virtual Account* getAccount() { return account; }; |
38 | protected: | 40 | protected: |
39 | void login(); | 41 | void login(); |
40 | POP3account *account; | 42 | POP3account *account; |
41 | mailstorage*m_pop3; | 43 | mailstorage*m_pop3; |
42 | }; | 44 | }; |
43 | 45 | ||
44 | #endif | 46 | #endif |
diff --git a/kmicromail/libmailwrapper/sendmailprogress.cpp b/kmicromail/libmailwrapper/sendmailprogress.cpp index 20dfe9b..6cd6409 100644 --- a/kmicromail/libmailwrapper/sendmailprogress.cpp +++ b/kmicromail/libmailwrapper/sendmailprogress.cpp | |||
@@ -1,26 +1,26 @@ | |||
1 | #include "sendmailprogress.h" | 1 | #include "sendmailprogress.h" |
2 | #include <qprogressbar.h> | 2 | #include <q3progressbar.h> |
3 | #include <qlabel.h> | 3 | #include <qlabel.h> |
4 | #include <klocale.h> | 4 | #include <klocale.h> |
5 | 5 | ||
6 | progressMailSend::progressMailSend(QWidget*parent, const char * name) | 6 | progressMailSend::progressMailSend(QWidget*parent, const char * name) |
7 | :progressMailSendUI(parent,name,true),m_current_mail(0),m_current_single(0),m_max_mail(0),m_max_single(0) | 7 | :progressMailSendUI(parent,name,true),m_current_mail(0),m_current_single(0),m_max_mail(0),m_max_single(0) |
8 | { | 8 | { |
9 | } | 9 | } |
10 | 10 | ||
11 | progressMailSend::~progressMailSend() | 11 | progressMailSend::~progressMailSend() |
12 | { | 12 | { |
13 | } | 13 | } |
14 | 14 | ||
15 | void progressMailSend::setMaxMails(unsigned int aMaxMails) | 15 | void progressMailSend::setMaxMails(unsigned int aMaxMails) |
16 | { | 16 | { |
17 | m_max_mail = aMaxMails; | 17 | m_max_mail = aMaxMails; |
18 | allMailProgressBar->setTotalSteps(aMaxMails); | 18 | allMailProgressBar->setTotalSteps(aMaxMails); |
19 | setMails(); | 19 | setMails(); |
20 | } | 20 | } |
21 | 21 | ||
22 | void progressMailSend::setCurrentMails(unsigned int aCurrent) | 22 | void progressMailSend::setCurrentMails(unsigned int aCurrent) |
23 | { | 23 | { |
24 | m_current_mail = aCurrent; | 24 | m_current_mail = aCurrent; |
25 | allMailProgressBar->setProgress(aCurrent); | 25 | allMailProgressBar->setProgress(aCurrent); |
26 | setMails(); | 26 | setMails(); |
diff --git a/kmicromail/libmailwrapper/settings.cpp b/kmicromail/libmailwrapper/settings.cpp index 9436d43..fc01528 100644 --- a/kmicromail/libmailwrapper/settings.cpp +++ b/kmicromail/libmailwrapper/settings.cpp | |||
@@ -1,29 +1,29 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <qdir.h> | 2 | #include <qdir.h> |
3 | 3 | ||
4 | #include <qtextcodec.h> | 4 | #include <qtextcodec.h> |
5 | #include <qtextstream.h> | 5 | #include <q3textstream.h> |
6 | #include <qfile.h> | 6 | #include <qfile.h> |
7 | 7 | ||
8 | //#include <opie2/odebug.h> | 8 | //#include <opie2/odebug.h> |
9 | #include <kconfig.h> | 9 | #include <kconfig.h> |
10 | 10 | ||
11 | #include <kstandarddirs.h> | 11 | #include <kstandarddirs.h> |
12 | #include "settings.h" | 12 | #include "settings.h" |
13 | //#include "defines.h" | 13 | //#include "defines.h" |
14 | 14 | ||
15 | #define IMAP_PORT "143" | 15 | #define IMAP_PORT "143" |
16 | #define IMAP_SSL_PORT "993" | 16 | #define IMAP_SSL_PORT "993" |
17 | #define SMTP_PORT "25" | 17 | #define SMTP_PORT "25" |
18 | #define SMTP_SSL_PORT "465" | 18 | #define SMTP_SSL_PORT "465" |
19 | #define POP3_PORT "110" | 19 | #define POP3_PORT "110" |
20 | #define POP3_SSL_PORT "995" | 20 | #define POP3_SSL_PORT "995" |
21 | #define NNTP_PORT "119" | 21 | #define NNTP_PORT "119" |
22 | #define NNTP_SSL_PORT "563" | 22 | #define NNTP_SSL_PORT "563" |
23 | 23 | ||
24 | 24 | ||
25 | Settings::Settings() | 25 | Settings::Settings() |
26 | : QObject() | 26 | : QObject() |
27 | { | 27 | { |
28 | accounts.setAutoDelete( true ); ; | 28 | accounts.setAutoDelete( true ); ; |
29 | updateAccounts(); | 29 | updateAccounts(); |
@@ -355,76 +355,76 @@ SMTPaccount::SMTPaccount() | |||
355 | useReply = false; | 355 | useReply = false; |
356 | type = MAILLIB::A_SMTP; | 356 | type = MAILLIB::A_SMTP; |
357 | port = SMTP_PORT; | 357 | port = SMTP_PORT; |
358 | } | 358 | } |
359 | 359 | ||
360 | SMTPaccount::SMTPaccount( QString filename ) | 360 | SMTPaccount::SMTPaccount( QString filename ) |
361 | : Account() | 361 | : Account() |
362 | { | 362 | { |
363 | file = filename; | 363 | file = filename; |
364 | accountName = "New SMTP Account"; | 364 | accountName = "New SMTP Account"; |
365 | ssl = false; | 365 | ssl = false; |
366 | connectionType = 1; | 366 | connectionType = 1; |
367 | login = false; | 367 | login = false; |
368 | type = MAILLIB::A_SMTP; | 368 | type = MAILLIB::A_SMTP; |
369 | port = SMTP_PORT; | 369 | port = SMTP_PORT; |
370 | } | 370 | } |
371 | 371 | ||
372 | QString SMTPaccount::getSignature() | 372 | QString SMTPaccount::getSignature() |
373 | { | 373 | { |
374 | QFileInfo fi ( signature ); | 374 | QFileInfo fi ( signature ); |
375 | if ( ! fi.exists() ) | 375 | if ( ! fi.exists() ) |
376 | return QString(); | 376 | return QString(); |
377 | 377 | ||
378 | QFile file( signature ); | 378 | QFile file( signature ); |
379 | if (!file.open( IO_ReadOnly ) ) { | 379 | if (!file.open( QIODevice::ReadOnly ) ) { |
380 | return QString(); | 380 | return QString(); |
381 | 381 | ||
382 | } | 382 | } |
383 | QTextStream ts( &file ); | 383 | Q3TextStream ts( &file ); |
384 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 384 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
385 | QString text = ts.read(); | 385 | QString text = ts.read(); |
386 | file.close(); | 386 | file.close(); |
387 | 387 | ||
388 | return text; | 388 | return text; |
389 | 389 | ||
390 | } | 390 | } |
391 | void SMTPaccount::setSignature( QString b ) | 391 | void SMTPaccount::setSignature( QString b ) |
392 | { | 392 | { |
393 | 393 | ||
394 | QFileInfo fi ( signature ); | 394 | QFileInfo fi ( signature ); |
395 | if ( ! fi.exists() ) { | 395 | if ( ! fi.exists() ) { |
396 | QString filedir( locateLocal("data", "kopiemail" ) ); | 396 | QString filedir( locateLocal("data", "kopiemail" ) ); |
397 | signature = filedir+ "/" + getAccountName() +".sig"; | 397 | signature = filedir+ "/" + getAccountName() +".sig"; |
398 | qDebug("new sig %s ", signature.latin1()); | 398 | qDebug("new sig %s ", signature.latin1()); |
399 | save(); | 399 | save(); |
400 | } | 400 | } |
401 | QFile fileIn( signature ); | 401 | QFile fileIn( signature ); |
402 | if (!fileIn.open( IO_WriteOnly ) ) { | 402 | if (!fileIn.open( QIODevice::WriteOnly ) ) { |
403 | qDebug("OM: Cannot write signature file %s ", signature.latin1() ); | 403 | qDebug("OM: Cannot write signature file %s ", signature.latin1() ); |
404 | return ; | 404 | return ; |
405 | } | 405 | } |
406 | QTextStream tsIn( &fileIn ); | 406 | Q3TextStream tsIn( &fileIn ); |
407 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 407 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
408 | tsIn << b ; | 408 | tsIn << b ; |
409 | fileIn.close(); | 409 | fileIn.close(); |
410 | } | 410 | } |
411 | QString SMTPaccount::getUniqueFileName() | 411 | QString SMTPaccount::getUniqueFileName() |
412 | { | 412 | { |
413 | int num = 0; | 413 | int num = 0; |
414 | QString unique; | 414 | QString unique; |
415 | 415 | ||
416 | QDir dir( locateLocal("data", "kopiemail" ) ); | 416 | QDir dir( locateLocal("data", "kopiemail" ) ); |
417 | 417 | ||
418 | QStringList imap = dir.entryList( "smtp-*" ); | 418 | QStringList imap = dir.entryList( "smtp-*" ); |
419 | do { | 419 | do { |
420 | unique.setNum( num++ ); | 420 | unique.setNum( num++ ); |
421 | } while ( imap.contains( "smtp-" + unique ) > 0 ); | 421 | } while ( imap.contains( "smtp-" + unique ) > 0 ); |
422 | 422 | ||
423 | return unique; | 423 | return unique; |
424 | } | 424 | } |
425 | 425 | ||
426 | void SMTPaccount::read() | 426 | void SMTPaccount::read() |
427 | { | 427 | { |
428 | KConfig *conf = new KConfig( getFileName() ); | 428 | KConfig *conf = new KConfig( getFileName() ); |
429 | conf->setGroup( "SMTP Account" ); | 429 | conf->setGroup( "SMTP Account" ); |
430 | accountName = conf->readEntry( "Account" ); | 430 | accountName = conf->readEntry( "Account" ); |
diff --git a/kmicromail/libmailwrapper/smtpwrapper.cpp b/kmicromail/libmailwrapper/smtpwrapper.cpp index 7c813cc..2df55ff 100644 --- a/kmicromail/libmailwrapper/smtpwrapper.cpp +++ b/kmicromail/libmailwrapper/smtpwrapper.cpp | |||
@@ -1,35 +1,37 @@ | |||
1 | #include "smtpwrapper.h" | 1 | #include "smtpwrapper.h" |
2 | #include "mailwrapper.h" | 2 | #include "mailwrapper.h" |
3 | #include "abstractmail.h" | 3 | #include "abstractmail.h" |
4 | #include "logindialog.h" | 4 | #include "logindialog.h" |
5 | #include "mailtypes.h" | 5 | #include "mailtypes.h" |
6 | #include "sendmailprogress.h" | 6 | #include "sendmailprogress.h" |
7 | 7 | ||
8 | //#include <opie2/odebug.h> | 8 | //#include <opie2/odebug.h> |
9 | //#include <qt.h> | 9 | //#include <qt.h> |
10 | #include <qapplication.h> | 10 | #include <qapplication.h> |
11 | #include <qmessagebox.h> | 11 | #include <qmessagebox.h> |
12 | //Added by qt3to4: | ||
13 | #include <Q3ValueList> | ||
12 | #include <stdlib.h> | 14 | #include <stdlib.h> |
13 | #ifndef DESKTOP_VERSION | 15 | #ifndef DESKTOP_VERSION |
14 | //#include <qpe/config.h> | 16 | //#include <qpe/config.h> |
15 | #include <qpe/qcopenvelope_qws.h> | 17 | #include <qpe/qcopenvelope_qws.h> |
16 | #endif | 18 | #endif |
17 | #include <libetpan/libetpan.h> | 19 | #include <libetpan/libetpan.h> |
18 | #include <klocale.h> | 20 | #include <klocale.h> |
19 | #include <kglobal.h> | 21 | #include <kglobal.h> |
20 | #include <kconfig.h> | 22 | #include <kconfig.h> |
21 | 23 | ||
22 | 24 | ||
23 | using namespace Opie::Core; | 25 | using namespace Opie::Core; |
24 | progressMailSend*SMTPwrapper::sendProgress = 0; | 26 | progressMailSend*SMTPwrapper::sendProgress = 0; |
25 | 27 | ||
26 | SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp ) | 28 | SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp ) |
27 | : Generatemail() | 29 | : Generatemail() |
28 | { | 30 | { |
29 | m_SmtpAccount = aSmtp; | 31 | m_SmtpAccount = aSmtp; |
30 | KConfig cfg( locateLocal("config", "kopiemailrc" ) ); | 32 | KConfig cfg( locateLocal("config", "kopiemailrc" ) ); |
31 | cfg.setGroup( "Status" ); | 33 | cfg.setGroup( "Status" ); |
32 | m_queuedMail = cfg.readNumEntry( "outgoing", 0 ); | 34 | m_queuedMail = cfg.readNumEntry( "outgoing", 0 ); |
33 | emit queuedMails( m_queuedMail ); | 35 | emit queuedMails( m_queuedMail ); |
34 | connect( this, SIGNAL( queuedMails(int) ), this, SLOT( emitQCop(int) ) ); | 36 | connect( this, SIGNAL( queuedMails(int) ), this, SLOT( emitQCop(int) ) ); |
35 | m_smtp = 0; | 37 | m_smtp = 0; |
@@ -413,50 +415,50 @@ int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) { | |||
413 | if (rcpts) { | 415 | if (rcpts) { |
414 | smtp_address_list_free( rcpts ); | 416 | smtp_address_list_free( rcpts ); |
415 | } | 417 | } |
416 | return res; | 418 | return res; |
417 | } | 419 | } |
418 | 420 | ||
419 | /* this is a special fun */ | 421 | /* this is a special fun */ |
420 | bool SMTPwrapper::flushOutbox() { | 422 | bool SMTPwrapper::flushOutbox() { |
421 | bool returnValue = true; | 423 | bool returnValue = true; |
422 | 424 | ||
423 | ; // odebug << "Sending the queue" << oendl; | 425 | ; // odebug << "Sending the queue" << oendl; |
424 | if (!m_SmtpAccount) { | 426 | if (!m_SmtpAccount) { |
425 | ; // odebug << "No smtp account given" << oendl; | 427 | ; // odebug << "No smtp account given" << oendl; |
426 | return false; | 428 | return false; |
427 | } | 429 | } |
428 | 430 | ||
429 | bool reset_user_value = false; | 431 | bool reset_user_value = false; |
430 | QString localfolders = AbstractMail::defaultLocalfolder(); | 432 | QString localfolders = AbstractMail::defaultLocalfolder(); |
431 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); | 433 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); |
432 | if (!wrap) { | 434 | if (!wrap) { |
433 | ; // odebug << "memory error" << oendl; | 435 | ; // odebug << "memory error" << oendl; |
434 | return false; | 436 | return false; |
435 | } | 437 | } |
436 | QString oldPw, oldUser; | 438 | QString oldPw, oldUser; |
437 | QValueList<RecMailP> mailsToSend; | 439 | Q3ValueList<RecMailP> mailsToSend; |
438 | QValueList<RecMailP> mailsToRemove; | 440 | Q3ValueList<RecMailP> mailsToRemove; |
439 | QString mbox("Outgoing"); | 441 | QString mbox("Outgoing"); |
440 | wrap->listMessages(mbox,mailsToSend); | 442 | wrap->listMessages(mbox,mailsToSend); |
441 | if (mailsToSend.count()==0) { | 443 | if (mailsToSend.count()==0) { |
442 | delete wrap; | 444 | delete wrap; |
443 | ; // odebug << "No mails to send" << oendl; | 445 | ; // odebug << "No mails to send" << oendl; |
444 | return false; | 446 | return false; |
445 | } | 447 | } |
446 | 448 | ||
447 | oldPw = m_SmtpAccount->getPassword(); | 449 | oldPw = m_SmtpAccount->getPassword(); |
448 | oldUser = m_SmtpAccount->getUser(); | 450 | oldUser = m_SmtpAccount->getUser(); |
449 | if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) { | 451 | if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) { |
450 | // get'em | 452 | // get'em |
451 | QString user,pass; | 453 | QString user,pass; |
452 | LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true ); | 454 | LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true ); |
453 | login.show(); | 455 | login.show(); |
454 | if ( QDialog::Accepted == login.exec() ) { | 456 | if ( QDialog::Accepted == login.exec() ) { |
455 | // ok | 457 | // ok |
456 | user = login.getUser().latin1(); | 458 | user = login.getUser().latin1(); |
457 | pass = login.getPassword().latin1(); | 459 | pass = login.getPassword().latin1(); |
458 | reset_user_value = true; | 460 | reset_user_value = true; |
459 | m_SmtpAccount->setUser(user); | 461 | m_SmtpAccount->setUser(user); |
460 | m_SmtpAccount->setPassword(pass); | 462 | m_SmtpAccount->setPassword(pass); |
461 | } else { | 463 | } else { |
462 | return true; | 464 | return true; |