Diffstat (limited to 'kmicromail/libmailwrapper/abstractmail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/abstractmail.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/kmicromail/libmailwrapper/abstractmail.cpp b/kmicromail/libmailwrapper/abstractmail.cpp index f876235..374d606 100644 --- a/kmicromail/libmailwrapper/abstractmail.cpp +++ b/kmicromail/libmailwrapper/abstractmail.cpp | |||
@@ -1,36 +1,37 @@ | |||
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 <qprogressbar.h> |
12 | #include <qapplication.h> | 12 | #include <qapplication.h> |
13 | #include <qmessagebox.h> | ||
13 | 14 | ||
14 | #include <kdecore/kstandarddirs.h> | 15 | #include <kdecore/kstandarddirs.h> |
15 | #include <qfile.h> | 16 | #include <qfile.h> |
16 | #include <qtextstream.h> | 17 | #include <qtextstream.h> |
17 | #include <stdlib.h> | 18 | #include <stdlib.h> |
18 | #include <libetpan/mailmime_content.h> | 19 | #include <libetpan/mailmime_content.h> |
19 | #include <libetpan/mailmime.h> | 20 | #include <libetpan/mailmime.h> |
20 | 21 | ||
21 | using namespace Opie::Core; | 22 | using namespace Opie::Core; |
22 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) | 23 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) |
23 | { | 24 | { |
24 | return new IMAPwrapper(a); | 25 | return new IMAPwrapper(a); |
25 | } | 26 | } |
26 | 27 | ||
27 | AbstractMail* AbstractMail::getWrapper(POP3account *a) | 28 | AbstractMail* AbstractMail::getWrapper(POP3account *a) |
28 | { | 29 | { |
29 | return new POP3wrapper(a); | 30 | return new POP3wrapper(a); |
30 | } | 31 | } |
31 | 32 | ||
32 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) | 33 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) |
33 | { | 34 | { |
34 | return new NNTPwrapper(a); | 35 | return new NNTPwrapper(a); |
35 | } | 36 | } |
36 | 37 | ||
@@ -137,48 +138,114 @@ QString AbstractMail::draftFolder() | |||
137 | return QString("Drafts"); | 138 | return QString("Drafts"); |
138 | } | 139 | } |
139 | 140 | ||
140 | /* temporary - will be removed when implemented in all classes */ | 141 | /* temporary - will be removed when implemented in all classes */ |
141 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) | 142 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) |
142 | { | 143 | { |
143 | } | 144 | } |
144 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) | 145 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) |
145 | { | 146 | { |
146 | //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); | 147 | //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); |
147 | // this is currently re-implemented in pop3wrapper and imapwrapper | 148 | // this is currently re-implemented in pop3wrapper and imapwrapper |
148 | int iii = 0; | 149 | int iii = 0; |
149 | int count = target.count(); | 150 | int count = target.count(); |
150 | QWidget wid; | 151 | QWidget wid; |
151 | wid.show(); | 152 | wid.show(); |
152 | while (iii < count ) { | 153 | while (iii < count ) { |
153 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); | 154 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); |
154 | wid.raise(); | 155 | wid.raise(); |
155 | qApp->processEvents(); | 156 | qApp->processEvents(); |
156 | RecMailP mail = (*target.at( iii )); | 157 | RecMailP mail = (*target.at( iii )); |
157 | deleteMail(mail); | 158 | deleteMail(mail); |
158 | ++iii; | 159 | ++iii; |
159 | } | 160 | } |
160 | } | 161 | } |
162 | |||
163 | void AbstractMail::downloadNewMails(const FolderP&fromFolder, AbstractMail*targetMail ) | ||
164 | { | ||
165 | qDebug("AbstractMail::downloadNewMails %s ", fromFolder->getName().latin1()); | ||
166 | // get local folder | ||
167 | Account * acc = getAccount(); | ||
168 | if ( !acc ) return; | ||
169 | QString lfName = acc->getLocalFolder(); | ||
170 | if ( lfName.isEmpty() ) | ||
171 | lfName = acc->getAccountName(); | ||
172 | // create local folder | ||
173 | if ( !targetMail->createMbox(lfName)) | ||
174 | { | ||
175 | QMessageBox::critical(0,tr("Error creating new Folder"), | ||
176 | tr("Error while creating new folder\n%1\n\nCancelling action.").arg(lfName)); | ||
177 | return; | ||
178 | } | ||
179 | QValueList<RecMailP> t; | ||
180 | listMessages(fromFolder->getName(),t,acc->getMaxMailSize() ); | ||
181 | if ( t.count() == 0 ) { | ||
182 | Global::statusMessage(tr("There are no new messages")); | ||
183 | return; | ||
184 | } | ||
185 | QValueList<RecMailP> e; | ||
186 | targetMail->listMessages(lfName,e,acc->getMaxMailSize() ); | ||
187 | qDebug("target has mails %d ", e.count()); | ||
188 | QValueList<RecMailP> n; | ||
189 | int iii = 0; | ||
190 | int count = t.count(); | ||
191 | while (iii < count ) { | ||
192 | RecMailP r = (*t.at( iii )); | ||
193 | bool found = false; | ||
194 | int jjj = 0; | ||
195 | int countE = e.count(); | ||
196 | while (jjj < countE ) { | ||
197 | RecMailP re = (*e.at( jjj )); | ||
198 | if ( re->isEqual(r) ) { | ||
199 | found = true; | ||
200 | break; | ||
201 | } | ||
202 | ++jjj; | ||
203 | } | ||
204 | if ( found ) | ||
205 | qDebug("found "); | ||
206 | else | ||
207 | qDebug("NOT found "); | ||
208 | |||
209 | if ( !found ) { | ||
210 | n.append( r ); | ||
211 | } | ||
212 | ++iii; | ||
213 | } | ||
214 | if ( n.count() == 0 ) { | ||
215 | Global::statusMessage(tr("There are no new messages")); | ||
216 | return; | ||
217 | } | ||
218 | mvcpMailList( n,lfName,targetMail,!acc->getLeaveOnServer()); | ||
219 | |||
220 | |||
221 | #if 0 | ||
222 | QValueList<RecMailP> t; | ||
223 | listMessages(fromFolder->getName(),t, maxSizeInKb); | ||
224 | mvcpMailList( t,targetFolder,targetWrapper,moveit); | ||
225 | #endif | ||
226 | |||
227 | } | ||
161 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, | 228 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, |
162 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) | 229 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) |
163 | { | 230 | { |
164 | QValueList<RecMailP> t; | 231 | QValueList<RecMailP> t; |
165 | listMessages(fromFolder->getName(),t, maxSizeInKb); | 232 | listMessages(fromFolder->getName(),t, maxSizeInKb); |
166 | mvcpMailList( t,targetFolder,targetWrapper,moveit); | 233 | mvcpMailList( t,targetFolder,targetWrapper,moveit); |
167 | 234 | ||
168 | } | 235 | } |
169 | void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, | 236 | void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, |
170 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 237 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
171 | { | 238 | { |
172 | encodedString*st = 0; | 239 | encodedString*st = 0; |
173 | int iii = 0; | 240 | int iii = 0; |
174 | int count = t.count(); | 241 | int count = t.count(); |
175 | if ( count == 0 ) | 242 | if ( count == 0 ) |
176 | return; | 243 | return; |
177 | // wel, processevents is qite strange, we need a widget for getting | 244 | // wel, processevents is qite strange, we need a widget for getting |
178 | // Global::statusMessage(tr("Copy2 message %1").arg(iii)); displayed | 245 | // Global::statusMessage(tr("Copy2 message %1").arg(iii)); displayed |
179 | QWidget wid; | 246 | QWidget wid; |
180 | wid.show(); | 247 | wid.show(); |
181 | while (iii < count ) { | 248 | while (iii < count ) { |
182 | Global::statusMessage(tr("Copy message %1 of %2").arg(iii).arg(count)); | 249 | Global::statusMessage(tr("Copy message %1 of %2").arg(iii).arg(count)); |
183 | wid.raise(); | 250 | wid.raise(); |
184 | qApp->processEvents(); | 251 | qApp->processEvents(); |