Diffstat (limited to 'kmicromail/libmailwrapper/abstractmail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/abstractmail.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/kmicromail/libmailwrapper/abstractmail.cpp b/kmicromail/libmailwrapper/abstractmail.cpp index 44878e0..8f67566 100644 --- a/kmicromail/libmailwrapper/abstractmail.cpp +++ b/kmicromail/libmailwrapper/abstractmail.cpp | |||
@@ -103,170 +103,175 @@ QString AbstractMail::convert_String(const char*text) | |||
103 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { | 103 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { |
104 | // result = QString(res); | 104 | // result = QString(res); |
105 | // odebug << "Res: " << res << ", length: " << strlen(res) << "" << oendl; | 105 | // odebug << "Res: " << res << ", length: " << strlen(res) << "" << oendl; |
106 | } | 106 | } |
107 | if (res) free(res); | 107 | if (res) free(res); |
108 | return result; | 108 | return result; |
109 | } | 109 | } |
110 | 110 | ||
111 | /* cp & paste from launcher */ | 111 | /* cp & paste from launcher */ |
112 | QString AbstractMail::gen_attachment_id() | 112 | QString AbstractMail::gen_attachment_id() |
113 | { | 113 | { |
114 | QFile file( "/proc/sys/kernel/random/uuid" ); | 114 | QFile file( "/proc/sys/kernel/random/uuid" ); |
115 | if (!file.open(IO_ReadOnly ) ) | 115 | if (!file.open(IO_ReadOnly ) ) |
116 | return QString::null; | 116 | return QString::null; |
117 | 117 | ||
118 | QTextStream stream(&file); | 118 | QTextStream stream(&file); |
119 | 119 | ||
120 | return "{" + stream.read().stripWhiteSpace() + "}"; | 120 | return "{" + stream.read().stripWhiteSpace() + "}"; |
121 | } | 121 | } |
122 | 122 | ||
123 | int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) | 123 | int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) |
124 | { | 124 | { |
125 | return 0; | 125 | return 0; |
126 | } | 126 | } |
127 | 127 | ||
128 | QString AbstractMail::defaultLocalfolder() | 128 | QString AbstractMail::defaultLocalfolder() |
129 | { | 129 | { |
130 | // QString f = getenv( "HOME" ); | 130 | // QString f = getenv( "HOME" ); |
131 | QString f = locateLocal( "data", "kopiemail/localmail"); | 131 | QString f = locateLocal( "data", "kopiemail/localmail"); |
132 | // f += "/Applications/opiemail/localmail"; | 132 | // f += "/Applications/opiemail/localmail"; |
133 | return f; | 133 | return f; |
134 | } | 134 | } |
135 | 135 | ||
136 | QString AbstractMail::draftFolder() | 136 | QString AbstractMail::draftFolder() |
137 | { | 137 | { |
138 | return QString("Drafts"); | 138 | return QString("Drafts"); |
139 | } | 139 | } |
140 | 140 | ||
141 | /* temporary - will be removed when implemented in all classes */ | 141 | /* temporary - will be removed when implemented in all classes */ |
142 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) | 142 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) |
143 | { | 143 | { |
144 | } | 144 | } |
145 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) | 145 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) |
146 | { | 146 | { |
147 | //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); | 147 | //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); |
148 | // this is currently re-implemented in pop3wrapper and imapwrapper | 148 | // this is currently re-implemented in pop3wrapper and imapwrapper |
149 | int iii = 0; | 149 | int iii = 0; |
150 | int count = target.count(); | 150 | int count = target.count(); |
151 | QWidget wid; | 151 | QProgressBar wid ( count ); |
152 | wid.setCaption( tr("Deleting ...")); | ||
152 | wid.show(); | 153 | wid.show(); |
153 | while (iii < count ) { | 154 | while (iii < count ) { |
154 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); | 155 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); |
156 | wid.setProgress( iii ); | ||
155 | wid.raise(); | 157 | wid.raise(); |
156 | qApp->processEvents(); | 158 | qApp->processEvents(); |
157 | RecMailP mail = (*target.at( iii )); | 159 | RecMailP mail = (*target.at( iii )); |
158 | deleteMail(mail); | 160 | deleteMail(mail); |
159 | ++iii; | 161 | ++iii; |
160 | } | 162 | } |
161 | } | 163 | } |
162 | 164 | ||
163 | void AbstractMail::downloadNewMails(const FolderP&fromFolder, AbstractMail*targetMail ) | 165 | void AbstractMail::downloadNewMails(const FolderP&fromFolder, AbstractMail*targetMail ) |
164 | { | 166 | { |
165 | //qDebug("AbstractMail::downloadNewMails %s ", fromFolder->getName().latin1()); | 167 | //qDebug("AbstractMail::downloadNewMails %s ", fromFolder->getName().latin1()); |
166 | // get local folder | 168 | // get local folder |
167 | Account * acc = getAccount(); | 169 | Account * acc = getAccount(); |
168 | if ( !acc ) return; | 170 | if ( !acc ) return; |
169 | QString lfName = acc->getLocalFolder(); | 171 | QString lfName = acc->getLocalFolder(); |
170 | if ( lfName.isEmpty() ) | 172 | if ( lfName.isEmpty() ) |
171 | lfName = acc->getAccountName(); | 173 | lfName = acc->getAccountName(); |
172 | // create local folder | 174 | // create local folder |
173 | if ( !targetMail->createMbox(lfName)) | 175 | if ( !targetMail->createMbox(lfName)) |
174 | { | 176 | { |
175 | QMessageBox::critical(0,tr("Error creating new Folder"), | 177 | QMessageBox::critical(0,tr("Error creating new Folder"), |
176 | tr("Error while creating new folder\n%1\n\nCancelling action.").arg(lfName)); | 178 | tr("Error while creating new folder\n%1\n\nCancelling action.").arg(lfName)); |
177 | return; | 179 | return; |
178 | } | 180 | } |
179 | QValueList<RecMailP> t; | 181 | QValueList<RecMailP> t; |
180 | listMessages(fromFolder->getName(),t,acc->getMaxMailSize() ); | 182 | listMessages(fromFolder->getName(),t,acc->getMaxMailSize() ); |
181 | if ( t.count() == 0 ) { | 183 | if ( t.count() == 0 ) { |
182 | Global::statusMessage(tr("There are no new messages")); | 184 | Global::statusMessage(tr("There are no new messages")); |
183 | return; | 185 | return; |
184 | } | 186 | } |
185 | QValueList<RecMailP> e; | 187 | QValueList<RecMailP> e; |
186 | targetMail->listMessages(lfName,e,acc->getMaxMailSize() ); | 188 | targetMail->listMessages(lfName,e,acc->getMaxMailSize() ); |
187 | //qDebug("target has mails %d ", e.count()); | 189 | //qDebug("target has mails %d ", e.count()); |
188 | QValueList<RecMailP> n; | 190 | QValueList<RecMailP> n; |
189 | int iii = 0; | 191 | int iii = 0; |
190 | int count = t.count(); | 192 | int count = t.count(); |
191 | while (iii < count ) { | 193 | while (iii < count ) { |
192 | RecMailP r = (*t.at( iii )); | 194 | RecMailP r = (*t.at( iii )); |
193 | bool found = false; | 195 | bool found = false; |
194 | int jjj = 0; | 196 | int jjj = 0; |
195 | int countE = e.count(); | 197 | int countE = e.count(); |
196 | while (jjj < countE ) { | 198 | while (jjj < countE ) { |
197 | RecMailP re = (*e.at( jjj )); | 199 | RecMailP re = (*e.at( jjj )); |
198 | if ( re->isEqual(r) ) { | 200 | if ( re->isEqual(r) ) { |
199 | found = true; | 201 | found = true; |
200 | break; | 202 | break; |
201 | } | 203 | } |
202 | ++jjj; | 204 | ++jjj; |
203 | } | 205 | } |
204 | if ( !found ) { | 206 | if ( !found ) { |
205 | n.append( r ); | 207 | n.append( r ); |
206 | } | 208 | } |
207 | ++iii; | 209 | ++iii; |
208 | } | 210 | } |
209 | if ( n.count() == 0 ) { | 211 | if ( n.count() == 0 ) { |
210 | Global::statusMessage(tr("There are no new messages")); | 212 | Global::statusMessage(tr("There are no new messages")); |
211 | return; | 213 | return; |
212 | } | 214 | } |
213 | mvcpMailList( n,lfName,targetMail,!acc->getLeaveOnServer()); | 215 | mvcpMailList( n,lfName,targetMail,!acc->getLeaveOnServer()); |
214 | Global::statusMessage(tr("Downloaded %1 messages").arg(n.count())); | 216 | Global::statusMessage(tr("Downloaded %1 messages").arg(n.count())); |
215 | 217 | ||
216 | #if 0 | 218 | #if 0 |
217 | QValueList<RecMailP> t; | 219 | QValueList<RecMailP> t; |
218 | listMessages(fromFolder->getName(),t, maxSizeInKb); | 220 | listMessages(fromFolder->getName(),t, maxSizeInKb); |
219 | mvcpMailList( t,targetFolder,targetWrapper,moveit); | 221 | mvcpMailList( t,targetFolder,targetWrapper,moveit); |
220 | #endif | 222 | #endif |
221 | 223 | ||
222 | } | 224 | } |
223 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, | 225 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, |
224 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) | 226 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) |
225 | { | 227 | { |
226 | QValueList<RecMailP> t; | 228 | QValueList<RecMailP> t; |
227 | listMessages(fromFolder->getName(),t, maxSizeInKb); | 229 | listMessages(fromFolder->getName(),t, maxSizeInKb); |
228 | mvcpMailList( t,targetFolder,targetWrapper,moveit); | 230 | mvcpMailList( t,targetFolder,targetWrapper,moveit); |
229 | 231 | ||
230 | } | 232 | } |
231 | void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, | 233 | void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, |
232 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 234 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
233 | { | 235 | { |
234 | encodedString*st = 0; | 236 | encodedString*st = 0; |
235 | int iii = 0; | 237 | int iii = 0; |
236 | int count = t.count(); | 238 | int count = t.count(); |
237 | if ( count == 0 ) | 239 | if ( count == 0 ) |
238 | return; | 240 | return; |
239 | // wel, processevents is qite strange, we need a widget for getting | 241 | // wel, processevents is qite strange, we need a widget for getting |
240 | // Global::statusMessage(tr("Copy2 message %1").arg(iii)); displayed | 242 | // Global::statusMessage(tr("Copy2 message %1").arg(iii)); displaye |
241 | QWidget wid; | 243 | |
244 | QProgressBar wid ( count ); | ||
245 | wid.setCaption( tr("Copying ...")); | ||
242 | wid.show(); | 246 | wid.show(); |
243 | while (iii < count ) { | 247 | while (iii < count ) { |
244 | Global::statusMessage(tr("Copy message %1 of %2").arg(iii).arg(count)); | 248 | Global::statusMessage(tr("Copy message %1 of %2").arg(iii).arg(count)); |
249 | wid.setProgress( iii ); | ||
245 | wid.raise(); | 250 | wid.raise(); |
246 | qApp->processEvents(); | 251 | qApp->processEvents(); |
247 | RecMailP r = (*t.at( iii )); | 252 | RecMailP r = (*t.at( iii )); |
248 | st = fetchRawBody(r); | 253 | st = fetchRawBody(r); |
249 | if (st) { | 254 | if (st) { |
250 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 255 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
251 | delete st; | 256 | delete st; |
252 | } | 257 | } |
253 | ++iii; | 258 | ++iii; |
254 | } | 259 | } |
255 | if (moveit) { | 260 | if (moveit) { |
256 | deleteMailList( t ); | 261 | deleteMailList( t ); |
257 | //deleteAllMail(fromFolder); | 262 | //deleteAllMail(fromFolder); |
258 | } | 263 | } |
259 | } | 264 | } |
260 | 265 | ||
261 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 266 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
262 | { | 267 | { |
263 | encodedString*st = 0; | 268 | encodedString*st = 0; |
264 | st = fetchRawBody(mail); | 269 | st = fetchRawBody(mail); |
265 | if (st) { | 270 | if (st) { |
266 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 271 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
267 | delete st; | 272 | delete st; |
268 | } | 273 | } |
269 | if (moveit) { | 274 | if (moveit) { |
270 | deleteMail(mail); | 275 | deleteMail(mail); |
271 | } | 276 | } |
272 | } | 277 | } |