author | alwin <alwin> | 2004-01-05 22:21:41 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-01-05 22:21:41 (UTC) |
commit | c8d0dd53a75b7142a5ce924e4afbea77b86e56b0 (patch) (unidiff) | |
tree | 2845e68c4a3ee0daa7f732a29fefd81d47c90f9d /noncore/net/mail/libmailwrapper/mboxwrapper.cpp | |
parent | 07278dd6ba68e3ff55d22acc76a28956b06d5d9c (diff) | |
download | opie-c8d0dd53a75b7142a5ce924e4afbea77b86e56b0.zip opie-c8d0dd53a75b7142a5ce924e4afbea77b86e56b0.tar.gz opie-c8d0dd53a75b7142a5ce924e4afbea77b86e56b0.tar.bz2 |
bugfix in imapwrapper
storemail for all possible mail-accounts
raw body fetch in all wrappers
unified public interface
dialog for selecting a target mailbox started
Diffstat (limited to 'noncore/net/mail/libmailwrapper/mboxwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/mboxwrapper.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp index 60f7507..3a0b30a 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp | |||
@@ -127,136 +127,137 @@ RecBody MBOXwrapper::fetchBody( const RecMail &mail ) | |||
127 | body = parseMail(msg); | 127 | body = parseMail(msg); |
128 | mailmessage_fetch_result_free(msg,data); | 128 | mailmessage_fetch_result_free(msg,data); |
129 | mailfolder_free(folder); | 129 | mailfolder_free(folder); |
130 | mailstorage_free(storage); | 130 | mailstorage_free(storage); |
131 | 131 | ||
132 | return body; | 132 | return body; |
133 | } | 133 | } |
134 | 134 | ||
135 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) | 135 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) |
136 | { | 136 | { |
137 | qDebug("MBOX %i von %i",current,maximum); | 137 | qDebug("MBOX %i von %i",current,maximum); |
138 | } | 138 | } |
139 | 139 | ||
140 | int MBOXwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool ) | 140 | int MBOXwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool ) |
141 | { | 141 | { |
142 | QString p = MBOXPath+"/"; | 142 | QString p = MBOXPath+"/"; |
143 | p+=folder; | 143 | p+=folder; |
144 | QFileInfo fi(p); | 144 | QFileInfo fi(p); |
145 | if (fi.exists()) { | 145 | if (fi.exists()) { |
146 | Global::statusMessage(tr("Mailbox exists.")); | 146 | Global::statusMessage(tr("Mailbox exists.")); |
147 | return 0; | 147 | return 0; |
148 | } | 148 | } |
149 | mailmbox_folder*f = 0; | 149 | mailmbox_folder*f = 0; |
150 | if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { | 150 | if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { |
151 | Global::statusMessage(tr("Error init folder")); | 151 | Global::statusMessage(tr("Error init folder")); |
152 | return 0; | 152 | return 0; |
153 | } | 153 | } |
154 | if (f) mailmbox_done(f); | 154 | if (f) mailmbox_done(f); |
155 | return 1; | 155 | return 1; |
156 | } | 156 | } |
157 | 157 | ||
158 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 158 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
159 | { | 159 | { |
160 | QString p = MBOXPath+"/"; | 160 | QString p = MBOXPath+"/"; |
161 | p+=folder; | 161 | p+=folder; |
162 | mailmbox_folder*f = 0; | 162 | mailmbox_folder*f = 0; |
163 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 163 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
164 | if (r != MAIL_NO_ERROR) { | 164 | if (r != MAIL_NO_ERROR) { |
165 | Global::statusMessage(tr("Error init folder")); | 165 | Global::statusMessage(tr("Error init folder")); |
166 | return; | 166 | return; |
167 | } | 167 | } |
168 | r = mailmbox_append_message(f,msg,length); | 168 | r = mailmbox_append_message(f,msg,length); |
169 | if (r != MAIL_NO_ERROR) { | 169 | if (r != MAIL_NO_ERROR) { |
170 | Global::statusMessage(tr("Error writing to message folder")); | 170 | Global::statusMessage(tr("Error writing to message folder")); |
171 | } | 171 | } |
172 | mailmbox_done(f); | 172 | mailmbox_done(f); |
173 | } | 173 | } |
174 | 174 | ||
175 | void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) | 175 | encodedString* MBOXwrapper::fetchRawBody(const RecMail&mail) |
176 | { | 176 | { |
177 | RecBody body; | 177 | RecBody body; |
178 | mailstorage*storage = mailstorage_new(NULL); | 178 | mailstorage*storage = mailstorage_new(NULL); |
179 | QString p = MBOXPath+"/"; | 179 | QString p = MBOXPath+"/"; |
180 | p+=mail.getMbox(); | 180 | p+=mail.getMbox(); |
181 | mailmessage * msg; | 181 | mailmessage * msg; |
182 | char*data=0; | 182 | char*data=0; |
183 | size_t size; | 183 | size_t size; |
184 | 184 | ||
185 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 185 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
186 | mailfolder*folder; | 186 | mailfolder*folder; |
187 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 187 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
188 | r = mailfolder_connect(folder); | 188 | r = mailfolder_connect(folder); |
189 | if (r != MAIL_NO_ERROR) { | 189 | if (r != MAIL_NO_ERROR) { |
190 | Global::statusMessage(tr("Error initializing mbox")); | 190 | Global::statusMessage(tr("Error initializing mbox")); |
191 | mailfolder_free(folder); | 191 | mailfolder_free(folder); |
192 | mailstorage_free(storage); | 192 | mailstorage_free(storage); |
193 | return; | 193 | return 0; |
194 | } | 194 | } |
195 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); | 195 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); |
196 | if (r != MAIL_NO_ERROR) { | 196 | if (r != MAIL_NO_ERROR) { |
197 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); | 197 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
198 | mailfolder_free(folder); | 198 | mailfolder_free(folder); |
199 | mailstorage_free(storage); | 199 | mailstorage_free(storage); |
200 | return; | 200 | return 0; |
201 | } | 201 | } |
202 | r = mailmessage_fetch(msg,&data,&size); | 202 | r = mailmessage_fetch(msg,&data,&size); |
203 | if (r != MAIL_NO_ERROR) { | 203 | if (r != MAIL_NO_ERROR) { |
204 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); | 204 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
205 | mailfolder_free(folder); | 205 | mailfolder_free(folder); |
206 | mailstorage_free(storage); | 206 | mailstorage_free(storage); |
207 | mailmessage_free(msg); | 207 | mailmessage_free(msg); |
208 | return; | 208 | return 0; |
209 | } | 209 | } |
210 | *target = data; | 210 | encodedString*result = new encodedString(data,size); |
211 | *length = size; | 211 | |
212 | mailfolder_free(folder); | 212 | mailfolder_free(folder); |
213 | mailstorage_free(storage); | 213 | mailstorage_free(storage); |
214 | mailmessage_free(msg); | 214 | mailmessage_free(msg); |
215 | return result; | ||
215 | } | 216 | } |
216 | 217 | ||
217 | void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) | 218 | void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) |
218 | { | 219 | { |
219 | QString p = MBOXPath+"/"; | 220 | QString p = MBOXPath+"/"; |
220 | p+=mailbox; | 221 | p+=mailbox; |
221 | mailmbox_folder*f = 0; | 222 | mailmbox_folder*f = 0; |
222 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 223 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
223 | if (r != MAIL_NO_ERROR) { | 224 | if (r != MAIL_NO_ERROR) { |
224 | qDebug("Error init folder"); | 225 | qDebug("Error init folder"); |
225 | return; | 226 | return; |
226 | } | 227 | } |
227 | deleteMails(f,target); | 228 | deleteMails(f,target); |
228 | mailmbox_done(f); | 229 | mailmbox_done(f); |
229 | } | 230 | } |
230 | 231 | ||
231 | void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) | 232 | void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) |
232 | { | 233 | { |
233 | if (!f) return; | 234 | if (!f) return; |
234 | int r; | 235 | int r; |
235 | for (unsigned int i=0; i < target.count();++i) { | 236 | for (unsigned int i=0; i < target.count();++i) { |
236 | r = mailmbox_delete_msg(f,target.at(i)->getNumber()); | 237 | r = mailmbox_delete_msg(f,target.at(i)->getNumber()); |
237 | if (r!=MAILMBOX_NO_ERROR) { | 238 | if (r!=MAILMBOX_NO_ERROR) { |
238 | qDebug("error delete mail"); | 239 | qDebug("error delete mail"); |
239 | } | 240 | } |
240 | } | 241 | } |
241 | r = mailmbox_expunge(f); | 242 | r = mailmbox_expunge(f); |
242 | if (r != MAILMBOX_NO_ERROR) { | 243 | if (r != MAILMBOX_NO_ERROR) { |
243 | qDebug("error expunge mailbox"); | 244 | qDebug("error expunge mailbox"); |
244 | } | 245 | } |
245 | } | 246 | } |
246 | 247 | ||
247 | int MBOXwrapper::deleteAllMail(const Folder*tfolder) | 248 | int MBOXwrapper::deleteAllMail(const Folder*tfolder) |
248 | { | 249 | { |
249 | if (!tfolder) return 0; | 250 | if (!tfolder) return 0; |
250 | QString p = MBOXPath+tfolder->getDisplayName(); | 251 | QString p = MBOXPath+tfolder->getDisplayName(); |
251 | int res = 1; | 252 | int res = 1; |
252 | 253 | ||
253 | mailfolder*folder = 0; | 254 | mailfolder*folder = 0; |
254 | mailmessage_list*l=0; | 255 | mailmessage_list*l=0; |
255 | mailstorage*storage = mailstorage_new(NULL); | 256 | mailstorage*storage = mailstorage_new(NULL); |
256 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 257 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
257 | if (r != MAIL_NO_ERROR) { | 258 | if (r != MAIL_NO_ERROR) { |
258 | Global::statusMessage(tr("Error initializing mbox")); | 259 | Global::statusMessage(tr("Error initializing mbox")); |
259 | res = 0; | 260 | res = 0; |
260 | } | 261 | } |
261 | if (res) { | 262 | if (res) { |
262 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 263 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |