summaryrefslogtreecommitdiff
authoralwin <alwin>2004-01-06 22:26:57 (UTC)
committer alwin <alwin>2004-01-06 22:26:57 (UTC)
commita24b39a49ac49d2d3b0f2ff53f0f3b7839447d6e (patch) (unidiff)
treed03a60b7e53389607a692b0784c8f5292e168920
parenta513de3ae1549428595db1b6c70e4203b0a3dedd (diff)
downloadopie-a24b39a49ac49d2d3b0f2ff53f0f3b7839447d6e.zip
opie-a24b39a49ac49d2d3b0f2ff53f0f3b7839447d6e.tar.gz
opie-a24b39a49ac49d2d3b0f2ff53f0f3b7839447d6e.tar.bz2
bugfix while building mbox path
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
index 3a0b30a..bc496f7 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
@@ -59,274 +59,274 @@ QList<Folder>* MBOXwrapper::listFolders()
59 Folder*inb=new Folder(*it,"/"); 59 Folder*inb=new Folder(*it,"/");
60 folders->append(inb); 60 folders->append(inb);
61 } 61 }
62 return folders; 62 return folders;
63} 63}
64 64
65void MBOXwrapper::deleteMail(const RecMail&mail) 65void MBOXwrapper::deleteMail(const RecMail&mail)
66{ 66{
67 mailstorage*storage = mailstorage_new(NULL); 67 mailstorage*storage = mailstorage_new(NULL);
68 QString p = MBOXPath+"/"; 68 QString p = MBOXPath+"/";
69 p+=mail.getMbox(); 69 p+=mail.getMbox();
70 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); 70 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
71 mailfolder*folder; 71 mailfolder*folder;
72 folder = mailfolder_new( storage,(char*)p.latin1(),NULL); 72 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
73 r = mailfolder_connect(folder); 73 r = mailfolder_connect(folder);
74 if (r != MAIL_NO_ERROR) { 74 if (r != MAIL_NO_ERROR) {
75 qDebug("Error initializing mbox"); 75 qDebug("Error initializing mbox");
76 mailfolder_free(folder); 76 mailfolder_free(folder);
77 mailstorage_free(storage); 77 mailstorage_free(storage);
78 return; 78 return;
79 } 79 }
80 r = mailsession_remove_message(folder->fld_session,mail.getNumber()); 80 r = mailsession_remove_message(folder->fld_session,mail.getNumber());
81 if (r != MAIL_NO_ERROR) { 81 if (r != MAIL_NO_ERROR) {
82 qDebug("error deleting mail"); 82 qDebug("error deleting mail");
83 } 83 }
84 mailfolder_free(folder); 84 mailfolder_free(folder);
85 mailstorage_free(storage); 85 mailstorage_free(storage);
86} 86}
87 87
88void MBOXwrapper::answeredMail(const RecMail&) 88void MBOXwrapper::answeredMail(const RecMail&)
89{ 89{
90} 90}
91 91
92RecBody MBOXwrapper::fetchBody( const RecMail &mail ) 92RecBody MBOXwrapper::fetchBody( const RecMail &mail )
93{ 93{
94 RecBody body; 94 RecBody body;
95 mailstorage*storage = mailstorage_new(NULL); 95 mailstorage*storage = mailstorage_new(NULL);
96 QString p = MBOXPath+"/"; 96 QString p = MBOXPath+"/";
97 p+=mail.getMbox(); 97 p+=mail.getMbox();
98 mailmessage * msg; 98 mailmessage * msg;
99 char*data=0; 99 char*data=0;
100 size_t size; 100 size_t size;
101 101
102 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); 102 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
103 mailfolder*folder; 103 mailfolder*folder;
104 folder = mailfolder_new( storage,(char*)p.latin1(),NULL); 104 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
105 r = mailfolder_connect(folder); 105 r = mailfolder_connect(folder);
106 if (r != MAIL_NO_ERROR) { 106 if (r != MAIL_NO_ERROR) {
107 qDebug("Error initializing mbox"); 107 qDebug("Error initializing mbox");
108 mailfolder_free(folder); 108 mailfolder_free(folder);
109 mailstorage_free(storage); 109 mailstorage_free(storage);
110 return body; 110 return body;
111 } 111 }
112 r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); 112 r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg);
113 if (r != MAIL_NO_ERROR) { 113 if (r != MAIL_NO_ERROR) {
114 qDebug("Error fetching mail %i",mail.getNumber()); 114 qDebug("Error fetching mail %i",mail.getNumber());
115 mailfolder_free(folder); 115 mailfolder_free(folder);
116 mailstorage_free(storage); 116 mailstorage_free(storage);
117 return body; 117 return body;
118 } 118 }
119 r = mailmessage_fetch(msg,&data,&size); 119 r = mailmessage_fetch(msg,&data,&size);
120 if (r != MAIL_NO_ERROR) { 120 if (r != MAIL_NO_ERROR) {
121 qDebug("Error fetching mail %i",mail.getNumber()); 121 qDebug("Error fetching mail %i",mail.getNumber());
122 mailfolder_free(folder); 122 mailfolder_free(folder);
123 mailstorage_free(storage); 123 mailstorage_free(storage);
124 mailmessage_free(msg); 124 mailmessage_free(msg);
125 return body; 125 return body;
126 } 126 }
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
135void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) 135void 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
140int MBOXwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool ) 140int 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
158void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) 158void 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
175encodedString* MBOXwrapper::fetchRawBody(const RecMail&mail) 175encodedString* 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 0; 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 0; 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 0; 208 return 0;
209 } 209 }
210 encodedString*result = new encodedString(data,size); 210 encodedString*result = new encodedString(data,size);
211 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 return result;
216} 216}
217 217
218void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) 218void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target)
219{ 219{
220 QString p = MBOXPath+"/"; 220 QString p = MBOXPath+"/";
221 p+=mailbox; 221 p+=mailbox;
222 mailmbox_folder*f = 0; 222 mailmbox_folder*f = 0;
223 int r = mailmbox_init(p.latin1(),0,1,0,&f); 223 int r = mailmbox_init(p.latin1(),0,1,0,&f);
224 if (r != MAIL_NO_ERROR) { 224 if (r != MAIL_NO_ERROR) {
225 qDebug("Error init folder"); 225 qDebug("Error init folder");
226 return; 226 return;
227 } 227 }
228 deleteMails(f,target); 228 deleteMails(f,target);
229 mailmbox_done(f); 229 mailmbox_done(f);
230} 230}
231 231
232void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) 232void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target)
233{ 233{
234 if (!f) return; 234 if (!f) return;
235 int r; 235 int r;
236 for (unsigned int i=0; i < target.count();++i) { 236 for (unsigned int i=0; i < target.count();++i) {
237 r = mailmbox_delete_msg(f,target.at(i)->getNumber()); 237 r = mailmbox_delete_msg(f,target.at(i)->getNumber());
238 if (r!=MAILMBOX_NO_ERROR) { 238 if (r!=MAILMBOX_NO_ERROR) {
239 qDebug("error delete mail"); 239 qDebug("error delete mail");
240 } 240 }
241 } 241 }
242 r = mailmbox_expunge(f); 242 r = mailmbox_expunge(f);
243 if (r != MAILMBOX_NO_ERROR) { 243 if (r != MAILMBOX_NO_ERROR) {
244 qDebug("error expunge mailbox"); 244 qDebug("error expunge mailbox");
245 } 245 }
246} 246}
247 247
248int MBOXwrapper::deleteAllMail(const Folder*tfolder) 248int MBOXwrapper::deleteAllMail(const Folder*tfolder)
249{ 249{
250 if (!tfolder) return 0; 250 if (!tfolder) return 0;
251 QString p = MBOXPath+tfolder->getDisplayName(); 251 QString p = MBOXPath+"/"+tfolder->getDisplayName();
252 int res = 1; 252 int res = 1;
253 253
254 mailfolder*folder = 0; 254 mailfolder*folder = 0;
255 mailmessage_list*l=0; 255 mailmessage_list*l=0;
256 mailstorage*storage = mailstorage_new(NULL); 256 mailstorage*storage = mailstorage_new(NULL);
257 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);
258 if (r != MAIL_NO_ERROR) { 258 if (r != MAIL_NO_ERROR) {
259 Global::statusMessage(tr("Error initializing mbox")); 259 Global::statusMessage(tr("Error initializing mbox"));
260 res = 0; 260 res = 0;
261 } 261 }
262 if (res) { 262 if (res) {
263 folder = mailfolder_new( storage,(char*)p.latin1(),NULL); 263 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
264 r = mailfolder_connect(folder); 264 r = mailfolder_connect(folder);
265 if (r != MAIL_NO_ERROR) { 265 if (r != MAIL_NO_ERROR) {
266 Global::statusMessage(tr("Error initializing mbox")); 266 Global::statusMessage(tr("Error initializing mbox"));
267 res = 0; 267 res = 0;
268 } 268 }
269 } 269 }
270 if (res) { 270 if (res) {
271 r = mailsession_get_messages_list(folder->fld_session,&l); 271 r = mailsession_get_messages_list(folder->fld_session,&l);
272 if (r != MAIL_NO_ERROR) { 272 if (r != MAIL_NO_ERROR) {
273 qDebug("Error message list"); 273 qDebug("Error message list");
274 res=0; 274 res=0;
275 } 275 }
276 } 276 }
277 for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { 277 for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) {
278 r = mailsession_remove_message(folder->fld_session,i+1); 278 r = mailsession_remove_message(folder->fld_session,i+1);
279 if (r != MAIL_NO_ERROR) { 279 if (r != MAIL_NO_ERROR) {
280 Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); 280 Global::statusMessage(tr("Error deleting mail %1").arg(i+1));
281 res = 0; 281 res = 0;
282 break; 282 break;
283 } 283 }
284 } 284 }
285 if (l) mailmessage_list_free(l); 285 if (l) mailmessage_list_free(l);
286 if (folder) mailfolder_free(folder); 286 if (folder) mailfolder_free(folder);
287 if (storage) mailstorage_free(storage); 287 if (storage) mailstorage_free(storage);
288 return res; 288 return res;
289} 289}
290 290
291int MBOXwrapper::deleteMbox(const Folder*tfolder) 291int MBOXwrapper::deleteMbox(const Folder*tfolder)
292{ 292{
293 if (!tfolder) return 0; 293 if (!tfolder) return 0;
294 QString p = MBOXPath+tfolder->getDisplayName(); 294 QString p = MBOXPath+"/"+tfolder->getDisplayName();
295 QFile fi(p); 295 QFile fi(p);
296 if (!fi.exists()) { 296 if (!fi.exists()) {
297 Global::statusMessage(tr("Mailbox doesn't exist.")); 297 Global::statusMessage(tr("Mailbox doesn't exist."));
298 return 0; 298 return 0;
299 } 299 }
300 if (!fi.remove()) { 300 if (!fi.remove()) {
301 Global::statusMessage(tr("Error deleting Mailbox.")); 301 Global::statusMessage(tr("Error deleting Mailbox."));
302 return 0; 302 return 0;
303 } 303 }
304 return 1; 304 return 1;
305} 305}
306 306
307void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) 307void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
308{ 308{
309 mailfolder*folder = 0; 309 mailfolder*folder = 0;
310 mailstorage*storage = mailstorage_new(NULL); 310 mailstorage*storage = mailstorage_new(NULL);
311 target_stat.message_count = 0; 311 target_stat.message_count = 0;
312 target_stat.message_unseen = 0; 312 target_stat.message_unseen = 0;
313 target_stat.message_recent = 0; 313 target_stat.message_recent = 0;
314 QString p = MBOXPath+"/"+mailbox; 314 QString p = MBOXPath+"/"+mailbox;
315 QFile fi(p); 315 QFile fi(p);
316 if (!fi.exists()) { 316 if (!fi.exists()) {
317 Global::statusMessage(tr("Mailbox doesn't exist.")); 317 Global::statusMessage(tr("Mailbox doesn't exist."));
318 return; 318 return;
319 } 319 }
320 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); 320 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
321 folder = mailfolder_new( storage,(char*)p.latin1(),NULL); 321 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
322 r = mailfolder_connect(folder); 322 r = mailfolder_connect(folder);
323 r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count, 323 r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count,
324 &target_stat.message_recent,&target_stat.message_unseen); 324 &target_stat.message_recent,&target_stat.message_unseen);
325 if (folder) mailfolder_free(folder); 325 if (folder) mailfolder_free(folder);
326 if (storage) mailstorage_free(storage); 326 if (storage) mailstorage_free(storage);
327} 327}
328 328
329const QString&MBOXwrapper::getType()const 329const QString&MBOXwrapper::getType()const
330{ 330{
331 return wrapperType; 331 return wrapperType;
332} 332}