author | alwin <alwin> | 2003-12-28 02:45:07 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-28 02:45:07 (UTC) |
commit | d1a7eb08cad465c5fc0de53f75aaecf7803f0945 (patch) (unidiff) | |
tree | 422b73af760cdd44e4fbbc96bd6876a15939ff19 | |
parent | e889485e945d8fa9564566f286114be10d2a1ce5 (diff) | |
download | opie-d1a7eb08cad465c5fc0de53f75aaecf7803f0945.zip opie-d1a7eb08cad465c5fc0de53f75aaecf7803f0945.tar.gz opie-d1a7eb08cad465c5fc0de53f75aaecf7803f0945.tar.bz2 |
- dir handling for mbox accounts (delete, new, delete all mail)
- fixed memory leaks in mbox account class
- reduced count of used string constants while using "tr" with context string
- mbox displays messages into global status bar
- fixed a possible raise condition when deleting a mail directory
-rw-r--r-- | noncore/net/mail/accountview.cpp | 143 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 18 | ||||
-rw-r--r-- | noncore/net/mail/genericwrapper.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/genericwrapper.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mboxwrapper.cpp | 126 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mboxwrapper.h | 8 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 7 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 3 | ||||
-rw-r--r-- | noncore/net/mail/mboxwrapper.cpp | 126 | ||||
-rw-r--r-- | noncore/net/mail/mboxwrapper.h | 8 | ||||
-rw-r--r-- | noncore/net/mail/newmaildir.cpp | 6 | ||||
-rw-r--r-- | noncore/net/mail/newmaildir.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.cpp | 7 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.h | 3 |
14 files changed, 375 insertions, 86 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 8aac14b..30765cf 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -60,487 +60,596 @@ POP3folderItem::~POP3folderItem() | |||
60 | delete folder; | 60 | delete folder; |
61 | } | 61 | } |
62 | 62 | ||
63 | POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) | 63 | POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) |
64 | : AccountViewItem( parent,after ) | 64 | : AccountViewItem( parent,after ) |
65 | { | 65 | { |
66 | folder = folderInit; | 66 | folder = folderInit; |
67 | pop3 = parent; | 67 | pop3 = parent; |
68 | if (folder->getDisplayName().lower()!="inbox") { | 68 | if (folder->getDisplayName().lower()!="inbox") { |
69 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 69 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
70 | } else { | 70 | } else { |
71 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 71 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
72 | } | 72 | } |
73 | setText( 0, folder->getDisplayName() ); | 73 | setText( 0, folder->getDisplayName() ); |
74 | } | 74 | } |
75 | 75 | ||
76 | void POP3folderItem::refresh(QList<RecMail>&target) | 76 | void POP3folderItem::refresh(QList<RecMail>&target) |
77 | { | 77 | { |
78 | if (folder->may_select()) | 78 | if (folder->may_select()) |
79 | pop3->getWrapper()->listMessages( folder->getName(),target ); | 79 | pop3->getWrapper()->listMessages( folder->getName(),target ); |
80 | } | 80 | } |
81 | 81 | ||
82 | RecBody POP3folderItem::fetchBody(const RecMail&aMail) | 82 | RecBody POP3folderItem::fetchBody(const RecMail&aMail) |
83 | { | 83 | { |
84 | return pop3->getWrapper()->fetchBody(aMail); | 84 | return pop3->getWrapper()->fetchBody(aMail); |
85 | } | 85 | } |
86 | 86 | ||
87 | /** | 87 | /** |
88 | * IMAP Account stuff | 88 | * IMAP Account stuff |
89 | */ | 89 | */ |
90 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) | 90 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) |
91 | : AccountViewItem( parent ) | 91 | : AccountViewItem( parent ) |
92 | { | 92 | { |
93 | account = a; | 93 | account = a; |
94 | wrapper = AbstractMail::getWrapper( account ); | 94 | wrapper = AbstractMail::getWrapper( account ); |
95 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 95 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
96 | setText( 0, account->getAccountName() ); | 96 | setText( 0, account->getAccountName() ); |
97 | setOpen( true ); | 97 | setOpen( true ); |
98 | } | 98 | } |
99 | 99 | ||
100 | IMAPviewItem::~IMAPviewItem() | 100 | IMAPviewItem::~IMAPviewItem() |
101 | { | 101 | { |
102 | delete wrapper; | 102 | delete wrapper; |
103 | } | 103 | } |
104 | 104 | ||
105 | AbstractMail *IMAPviewItem::getWrapper() | 105 | AbstractMail *IMAPviewItem::getWrapper() |
106 | { | 106 | { |
107 | return wrapper; | 107 | return wrapper; |
108 | } | 108 | } |
109 | 109 | ||
110 | IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start) | 110 | IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start) |
111 | { | 111 | { |
112 | IMAPfolderItem*pitem,*sitem; | 112 | IMAPfolderItem*pitem,*sitem; |
113 | if (!start) pitem = (IMAPfolderItem*)firstChild(); | 113 | if (!start) pitem = (IMAPfolderItem*)firstChild(); |
114 | else pitem = (IMAPfolderItem*)start->firstChild(); | 114 | else pitem = (IMAPfolderItem*)start->firstChild(); |
115 | while (pitem) { | 115 | while (pitem) { |
116 | if (pitem->matchName(path)) { | 116 | if (pitem->matchName(path)) { |
117 | break; | 117 | break; |
118 | } | 118 | } |
119 | if (pitem->childCount()>0) { | 119 | if (pitem->childCount()>0) { |
120 | sitem = findSubItem(path,pitem); | 120 | sitem = findSubItem(path,pitem); |
121 | if (sitem) { | 121 | if (sitem) { |
122 | pitem = sitem; | 122 | pitem = sitem; |
123 | break; | 123 | break; |
124 | } | 124 | } |
125 | } | 125 | } |
126 | pitem=(IMAPfolderItem*)pitem->nextSibling(); | 126 | pitem=(IMAPfolderItem*)pitem->nextSibling(); |
127 | } | 127 | } |
128 | return pitem; | 128 | return pitem; |
129 | } | 129 | } |
130 | 130 | ||
131 | void IMAPviewItem::refresh(QList<RecMail>&) | 131 | void IMAPviewItem::refresh(QList<RecMail>&) |
132 | { | 132 | { |
133 | refreshFolders(false); | 133 | refreshFolders(false); |
134 | } | 134 | } |
135 | 135 | ||
136 | void IMAPviewItem::refreshFolders(bool force) | 136 | void IMAPviewItem::refreshFolders(bool force) |
137 | { | 137 | { |
138 | if (childCount()>0 && force==false) return; | 138 | if (childCount()>0 && force==false) return; |
139 | QList<Folder> *folders = wrapper->listFolders(); | 139 | QList<Folder> *folders = wrapper->listFolders(); |
140 | 140 | ||
141 | QListViewItem *child = firstChild(); | 141 | QListViewItem *child = firstChild(); |
142 | while ( child ) { | 142 | while ( child ) { |
143 | QListViewItem *tmp = child; | 143 | QListViewItem *tmp = child; |
144 | child = child->nextSibling(); | 144 | child = child->nextSibling(); |
145 | delete tmp; | 145 | delete tmp; |
146 | } | 146 | } |
147 | 147 | ||
148 | Folder *it; | 148 | Folder *it; |
149 | QListViewItem*item = 0; | 149 | QListViewItem*item = 0; |
150 | QListViewItem*titem = 0; | 150 | QListViewItem*titem = 0; |
151 | QString fname,del,search; | 151 | QString fname,del,search; |
152 | int pos; | 152 | int pos; |
153 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 153 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
154 | folders->setAutoDelete(false); | 154 | folders->setAutoDelete(false); |
155 | 155 | ||
156 | for ( it = folders->first(); it; it = folders->next() ) { | 156 | for ( it = folders->first(); it; it = folders->next() ) { |
157 | if (it->getDisplayName().lower()=="inbox") { | 157 | if (it->getDisplayName().lower()=="inbox") { |
158 | item = new IMAPfolderItem( it, this , item ); | 158 | item = new IMAPfolderItem( it, this , item ); |
159 | folders->remove(it); | 159 | folders->remove(it); |
160 | qDebug("inbox found"); | 160 | qDebug("inbox found"); |
161 | break; | 161 | break; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | for ( it = folders->first(); it; it = folders->next() ) { | 164 | for ( it = folders->first(); it; it = folders->next() ) { |
165 | fname = it->getDisplayName(); | 165 | fname = it->getDisplayName(); |
166 | pos = fname.findRev(it->Separator()); | 166 | pos = fname.findRev(it->Separator()); |
167 | if (pos != -1) { | 167 | if (pos != -1) { |
168 | fname = fname.left(pos); | 168 | fname = fname.left(pos); |
169 | } | 169 | } |
170 | IMAPfolderItem*pitem = findSubItem(fname); | 170 | IMAPfolderItem*pitem = findSubItem(fname); |
171 | if (pitem) { | 171 | if (pitem) { |
172 | titem = item; | 172 | titem = item; |
173 | item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this); | 173 | item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this); |
174 | /* setup the short name */ | 174 | /* setup the short name */ |
175 | item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); | 175 | item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); |
176 | item = titem; | 176 | item = titem; |
177 | } else { | 177 | } else { |
178 | item = new IMAPfolderItem( it, this , item ); | 178 | item = new IMAPfolderItem( it, this , item ); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | delete folders; | 181 | delete folders; |
182 | } | 182 | } |
183 | 183 | ||
184 | QPopupMenu * IMAPviewItem::getContextMenu() | 184 | QPopupMenu * IMAPviewItem::getContextMenu() |
185 | { | 185 | { |
186 | QPopupMenu *m = new QPopupMenu(0); | 186 | QPopupMenu *m = new QPopupMenu(0); |
187 | if (m) { | 187 | if (m) { |
188 | m->insertItem(QObject::tr("Refresh folder list","IMAPviewItem"),0); | 188 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); |
189 | m->insertItem(QObject::tr("Create new folder","IMAPviewItem"),1); | 189 | m->insertItem(QObject::tr("Create new folder",contextName),1); |
190 | m->insertSeparator(); | 190 | m->insertSeparator(); |
191 | m->insertItem(QObject::tr("Disconnect","IMAPviewItem"),2); | 191 | m->insertItem(QObject::tr("Disconnect",contextName),2); |
192 | } | 192 | } |
193 | return m; | 193 | return m; |
194 | } | 194 | } |
195 | 195 | ||
196 | void IMAPviewItem::createNewFolder() | 196 | void IMAPviewItem::createNewFolder() |
197 | { | 197 | { |
198 | Newmdirdlg ndirdlg; | 198 | Newmdirdlg ndirdlg; |
199 | ndirdlg.showMaximized(); | 199 | ndirdlg.showMaximized(); |
200 | if (ndirdlg.exec()) { | 200 | if (ndirdlg.exec()) { |
201 | QString ndir = ndirdlg.Newdir(); | 201 | QString ndir = ndirdlg.Newdir(); |
202 | bool makesubs = ndirdlg.subpossible(); | 202 | bool makesubs = ndirdlg.subpossible(); |
203 | QString delemiter = "/"; | 203 | QString delemiter = "/"; |
204 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); | 204 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); |
205 | if (item) { | 205 | if (item) { |
206 | delemiter = item->Delemiter(); | 206 | delemiter = item->Delemiter(); |
207 | } | 207 | } |
208 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) { | 208 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) { |
209 | refreshFolders(true); | 209 | refreshFolders(true); |
210 | } | 210 | } |
211 | } | 211 | } |
212 | } | 212 | } |
213 | 213 | ||
214 | void IMAPviewItem::contextMenuSelected(int id) | 214 | void IMAPviewItem::contextMenuSelected(int id) |
215 | { | 215 | { |
216 | qDebug("Id selected: %i",id); | 216 | qDebug("Id selected: %i",id); |
217 | switch (id) { | 217 | switch (id) { |
218 | case 0: | 218 | case 0: |
219 | refreshFolders(true); | 219 | refreshFolders(true); |
220 | break; | 220 | break; |
221 | case 1: | 221 | case 1: |
222 | createNewFolder(); | 222 | createNewFolder(); |
223 | break; | 223 | break; |
224 | default: | 224 | default: |
225 | break; | 225 | break; |
226 | } | 226 | } |
227 | } | 227 | } |
228 | 228 | ||
229 | RecBody IMAPviewItem::fetchBody(const RecMail&) | 229 | RecBody IMAPviewItem::fetchBody(const RecMail&) |
230 | { | 230 | { |
231 | return RecBody(); | 231 | return RecBody(); |
232 | } | 232 | } |
233 | 233 | ||
234 | IMAPfolderItem::~IMAPfolderItem() | 234 | IMAPfolderItem::~IMAPfolderItem() |
235 | { | 235 | { |
236 | delete folder; | 236 | delete folder; |
237 | } | 237 | } |
238 | 238 | ||
239 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) | 239 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) |
240 | : AccountViewItem( parent , after ) | 240 | : AccountViewItem( parent , after ) |
241 | { | 241 | { |
242 | folder = folderInit; | 242 | folder = folderInit; |
243 | imap = parent; | 243 | imap = parent; |
244 | if (folder->getDisplayName().lower()!="inbox") { | 244 | if (folder->getDisplayName().lower()!="inbox") { |
245 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 245 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
246 | } else { | 246 | } else { |
247 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 247 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
248 | } | 248 | } |
249 | setText( 0, folder->getDisplayName() ); | 249 | setText( 0, folder->getDisplayName() ); |
250 | } | 250 | } |
251 | 251 | ||
252 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) | 252 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) |
253 | : AccountViewItem( parent,after ) | 253 | : AccountViewItem( parent,after ) |
254 | { | 254 | { |
255 | folder = folderInit; | 255 | folder = folderInit; |
256 | imap = master; | 256 | imap = master; |
257 | if (folder->getDisplayName().lower()!="inbox") { | 257 | if (folder->getDisplayName().lower()!="inbox") { |
258 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 258 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
259 | } else { | 259 | } else { |
260 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 260 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
261 | } | 261 | } |
262 | setText( 0, folder->getDisplayName() ); | 262 | setText( 0, folder->getDisplayName() ); |
263 | } | 263 | } |
264 | 264 | ||
265 | const QString& IMAPfolderItem::Delemiter()const | 265 | const QString& IMAPfolderItem::Delemiter()const |
266 | { | 266 | { |
267 | return folder->Separator(); | 267 | return folder->Separator(); |
268 | } | 268 | } |
269 | 269 | ||
270 | bool IMAPfolderItem::matchName(const QString&name)const | 270 | bool IMAPfolderItem::matchName(const QString&name)const |
271 | { | 271 | { |
272 | return folder->getDisplayName()==name; | 272 | return folder->getDisplayName()==name; |
273 | } | 273 | } |
274 | 274 | ||
275 | void IMAPfolderItem::refresh(QList<RecMail>&target) | 275 | void IMAPfolderItem::refresh(QList<RecMail>&target) |
276 | { | 276 | { |
277 | if (folder->may_select()) { | 277 | if (folder->may_select()) { |
278 | imap->getWrapper()->listMessages( folder->getName(),target ); | 278 | imap->getWrapper()->listMessages( folder->getName(),target ); |
279 | } else { | 279 | } else { |
280 | target.clear(); | 280 | target.clear(); |
281 | } | 281 | } |
282 | } | 282 | } |
283 | 283 | ||
284 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) | 284 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) |
285 | { | 285 | { |
286 | return imap->getWrapper()->fetchBody(aMail); | 286 | return imap->getWrapper()->fetchBody(aMail); |
287 | } | 287 | } |
288 | 288 | ||
289 | QPopupMenu * IMAPfolderItem::getContextMenu() | 289 | QPopupMenu * IMAPfolderItem::getContextMenu() |
290 | { | 290 | { |
291 | QPopupMenu *m = new QPopupMenu(0); | 291 | QPopupMenu *m = new QPopupMenu(0); |
292 | if (m) { | 292 | if (m) { |
293 | if (folder->may_select()) { | 293 | if (folder->may_select()) { |
294 | m->insertItem(QObject::tr("Refresh header list","IMAPfolderItem"),0); | 294 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
295 | m->insertItem(QObject::tr("Delete all mails","IMAPfolderItem"),1); | 295 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
296 | } | 296 | } |
297 | if (folder->no_inferior()==false) { | 297 | if (folder->no_inferior()==false) { |
298 | m->insertItem(QObject::tr("Create new subfolder","IMAPfolderItem"),2); | 298 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); |
299 | } | 299 | } |
300 | if (folder->getDisplayName().lower()!="inbox") { | 300 | if (folder->getDisplayName().lower()!="inbox") { |
301 | m->insertItem(QObject::tr("Delete folder","IMAPfolderItem"),3); | 301 | m->insertItem(QObject::tr("Delete folder",contextName),3); |
302 | } | 302 | } |
303 | } | 303 | } |
304 | return m; | 304 | return m; |
305 | } | 305 | } |
306 | 306 | ||
307 | void IMAPfolderItem::deleteAllMails() | 307 | void IMAPfolderItem::deleteAllMails() |
308 | { | 308 | { |
309 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails","IMAPfolderItem"), | 309 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), |
310 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>","IMAPfolderItem").arg(folder->getDisplayName()), | 310 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).arg(folder->getDisplayName()), |
311 | QObject::tr("Yes","IMAPfolderItem"), | 311 | QObject::tr("Yes",contextName), |
312 | QObject::tr("No","IMAPfolderItem"),QString::null,1,1); | 312 | QObject::tr("No",contextName),QString::null,1,1); |
313 | qDebug("Auswahl: %i",yesno); | 313 | qDebug("Auswahl: %i",yesno); |
314 | if (yesno == 0) { | 314 | if (yesno == 0) { |
315 | if (imap->getWrapper()->deleteAllMail(folder)) { | 315 | if (imap->getWrapper()->deleteAllMail(folder)) { |
316 | AccountView * view = (AccountView*)listView(); | 316 | AccountView * view = (AccountView*)listView(); |
317 | if (view) view->refreshCurrent(); | 317 | if (view) view->refreshCurrent(); |
318 | } | 318 | } |
319 | } | 319 | } |
320 | } | 320 | } |
321 | 321 | ||
322 | void IMAPfolderItem::createNewFolder() | 322 | void IMAPfolderItem::createNewFolder() |
323 | { | 323 | { |
324 | Newmdirdlg ndirdlg; | 324 | Newmdirdlg ndirdlg; |
325 | ndirdlg.showMaximized(); | 325 | ndirdlg.showMaximized(); |
326 | if (ndirdlg.exec()) { | 326 | if (ndirdlg.exec()) { |
327 | QString ndir = ndirdlg.Newdir(); | 327 | QString ndir = ndirdlg.Newdir(); |
328 | bool makesubs = ndirdlg.subpossible(); | 328 | bool makesubs = ndirdlg.subpossible(); |
329 | QString delemiter = Delemiter(); | 329 | QString delemiter = Delemiter(); |
330 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) { | 330 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) { |
331 | imap->refreshFolders(true); | 331 | imap->refreshFolders(true); |
332 | } | 332 | } |
333 | } | 333 | } |
334 | } | 334 | } |
335 | 335 | ||
336 | void IMAPfolderItem::deleteFolder() | 336 | void IMAPfolderItem::deleteFolder() |
337 | { | 337 | { |
338 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder","IMAPfolderItem"), | 338 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), |
339 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>","IMAPfolderItem").arg(folder->getDisplayName()), | 339 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), |
340 | QObject::tr("Yes","IMAPfolderItem"), | 340 | QObject::tr("Yes",contextName), |
341 | QObject::tr("No","IMAPfolderItem"),QString::null,1,1); | 341 | QObject::tr("No",contextName),QString::null,1,1); |
342 | qDebug("Auswahl: %i",yesno); | 342 | qDebug("Auswahl: %i",yesno); |
343 | if (yesno == 0) { | 343 | if (yesno == 0) { |
344 | if (imap->getWrapper()->deleteMbox(folder)) { | 344 | if (imap->getWrapper()->deleteMbox(folder)) { |
345 | /* be carefull - after that this object is destroyd so don't call | 345 | QListView*v=listView(); |
346 | IMAPviewItem * box = imap; | ||
347 | /* be carefull - after that this object is destroyd so don't use | ||
346 | * any member of it after that call!!*/ | 348 | * any member of it after that call!!*/ |
347 | imap->refreshFolders(true); | 349 | imap->refreshFolders(true); |
350 | if (v) { | ||
351 | v->setSelected(box,true); | ||
352 | } | ||
348 | } | 353 | } |
349 | } | 354 | } |
350 | } | 355 | } |
351 | 356 | ||
352 | void IMAPfolderItem::contextMenuSelected(int id) | 357 | void IMAPfolderItem::contextMenuSelected(int id) |
353 | { | 358 | { |
354 | qDebug("Selected id: %i",id); | 359 | qDebug("Selected id: %i",id); |
355 | AccountView * view = (AccountView*)listView(); | 360 | AccountView * view = (AccountView*)listView(); |
356 | switch(id) { | 361 | switch(id) { |
357 | case 0: | 362 | case 0: |
358 | view->refreshCurrent(); | 363 | view->refreshCurrent(); |
359 | break; | 364 | break; |
360 | case 1: | 365 | case 1: |
361 | deleteAllMails(); | 366 | deleteAllMails(); |
362 | break; | 367 | break; |
363 | case 2: | 368 | case 2: |
364 | createNewFolder(); | 369 | createNewFolder(); |
365 | break; | 370 | break; |
366 | case 3: | 371 | case 3: |
367 | deleteFolder(); | 372 | deleteFolder(); |
368 | break; | 373 | break; |
369 | default: | 374 | default: |
370 | break; | 375 | break; |
371 | } | 376 | } |
372 | } | 377 | } |
373 | 378 | ||
374 | /** | 379 | /** |
375 | * Generic stuff | 380 | * Generic stuff |
376 | */ | 381 | */ |
377 | 382 | ||
383 | const QString AccountViewItem::contextName="AccountViewItem"; | ||
384 | |||
378 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 385 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
379 | : QListView( parent, name, flags ) | 386 | : QListView( parent, name, flags ) |
380 | { | 387 | { |
381 | connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), | 388 | connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), |
382 | SLOT( refresh( QListViewItem * ) ) ); | 389 | SLOT( refresh( QListViewItem * ) ) ); |
383 | connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, | 390 | connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, |
384 | SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); | 391 | SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); |
385 | 392 | ||
386 | setSorting(0); | 393 | setSorting(0); |
387 | } | 394 | } |
388 | 395 | ||
389 | void AccountView::slotContextMenu(int id) | 396 | void AccountView::slotContextMenu(int id) |
390 | { | 397 | { |
391 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 398 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
392 | if (!view) return; | 399 | if (!view) return; |
393 | view->contextMenuSelected(id); | 400 | view->contextMenuSelected(id); |
394 | } | 401 | } |
395 | 402 | ||
396 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) | 403 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) |
397 | { | 404 | { |
398 | if (button==1) {return;} | 405 | if (button==1) {return;} |
399 | if (!item) return; | 406 | if (!item) return; |
400 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 407 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
401 | QPopupMenu*m = view->getContextMenu(); | 408 | QPopupMenu*m = view->getContextMenu(); |
402 | if (!m) return; | 409 | if (!m) return; |
403 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); | 410 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); |
404 | m->setFocus(); | 411 | m->setFocus(); |
405 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 412 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
406 | delete m; | 413 | delete m; |
407 | } | 414 | } |
408 | 415 | ||
409 | void AccountView::populate( QList<Account> list ) | 416 | void AccountView::populate( QList<Account> list ) |
410 | { | 417 | { |
411 | clear(); | 418 | clear(); |
412 | 419 | ||
413 | QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); | 420 | QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); |
414 | (void) new MBOXviewItem(localfolders,this); | 421 | (void) new MBOXviewItem(localfolders,this); |
415 | 422 | ||
416 | Account *it; | 423 | Account *it; |
417 | for ( it = list.first(); it; it = list.next() ) { | 424 | for ( it = list.first(); it; it = list.next() ) { |
418 | if ( it->getType().compare( "IMAP" ) == 0 ) { | 425 | if ( it->getType().compare( "IMAP" ) == 0 ) { |
419 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); | 426 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); |
420 | qDebug( "added IMAP " + imap->getAccountName() ); | 427 | qDebug( "added IMAP " + imap->getAccountName() ); |
421 | (void) new IMAPviewItem( imap, this ); | 428 | (void) new IMAPviewItem( imap, this ); |
422 | } else if ( it->getType().compare( "POP3" ) == 0 ) { | 429 | } else if ( it->getType().compare( "POP3" ) == 0 ) { |
423 | POP3account *pop3 = static_cast<POP3account *>(it); | 430 | POP3account *pop3 = static_cast<POP3account *>(it); |
424 | qDebug( "added POP3 " + pop3->getAccountName() ); | 431 | qDebug( "added POP3 " + pop3->getAccountName() ); |
425 | (void) new POP3viewItem( pop3, this ); | 432 | (void) new POP3viewItem( pop3, this ); |
426 | } | 433 | } |
427 | } | 434 | } |
428 | } | 435 | } |
429 | 436 | ||
430 | void AccountView::refresh(QListViewItem *item) { | 437 | void AccountView::refresh(QListViewItem *item) { |
431 | 438 | ||
432 | qDebug("AccountView refresh..."); | 439 | qDebug("AccountView refresh..."); |
433 | if ( item ) { | 440 | if ( item ) { |
434 | m_currentItem = item; | 441 | m_currentItem = item; |
435 | QList<RecMail> headerlist; | 442 | QList<RecMail> headerlist; |
436 | headerlist.setAutoDelete(true); | 443 | headerlist.setAutoDelete(true); |
437 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 444 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
438 | view->refresh(headerlist); | 445 | view->refresh(headerlist); |
439 | emit refreshMailview(&headerlist); | 446 | emit refreshMailview(&headerlist); |
440 | } | 447 | } |
441 | } | 448 | } |
442 | 449 | ||
443 | void AccountView::refreshCurrent() | 450 | void AccountView::refreshCurrent() |
444 | { | 451 | { |
445 | m_currentItem = currentItem(); | 452 | m_currentItem = currentItem(); |
446 | if ( !m_currentItem ) return; | 453 | if ( !m_currentItem ) return; |
447 | QList<RecMail> headerlist; | 454 | QList<RecMail> headerlist; |
448 | headerlist.setAutoDelete(true); | 455 | headerlist.setAutoDelete(true); |
449 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); | 456 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); |
450 | view->refresh(headerlist); | 457 | view->refresh(headerlist); |
451 | emit refreshMailview(&headerlist); | 458 | emit refreshMailview(&headerlist); |
452 | } | 459 | } |
453 | 460 | ||
454 | void AccountView::refreshAll() | 461 | void AccountView::refreshAll() |
455 | { | 462 | { |
456 | 463 | ||
457 | } | 464 | } |
458 | 465 | ||
459 | RecBody AccountView::fetchBody(const RecMail&aMail) | 466 | RecBody AccountView::fetchBody(const RecMail&aMail) |
460 | { | 467 | { |
461 | QListViewItem*item = selectedItem (); | 468 | QListViewItem*item = selectedItem (); |
462 | if (!item) return RecBody(); | 469 | if (!item) return RecBody(); |
463 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 470 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
464 | return view->fetchBody(aMail); | 471 | return view->fetchBody(aMail); |
465 | } | 472 | } |
466 | 473 | ||
467 | /** | 474 | /** |
468 | * MBOX Account stuff | 475 | * MBOX Account stuff |
469 | */ | 476 | */ |
470 | 477 | ||
471 | MBOXviewItem::MBOXviewItem( const QString&aPath, QListView *parent ) | 478 | MBOXviewItem::MBOXviewItem( const QString&aPath, QListView *parent ) |
472 | : AccountViewItem( parent ) | 479 | : AccountViewItem( parent ) |
473 | { | 480 | { |
474 | m_Path = aPath; | 481 | m_Path = aPath; |
475 | wrapper = AbstractMail::getWrapper( m_Path ); | 482 | wrapper = AbstractMail::getWrapper( m_Path ); |
476 | setPixmap( 0, PIXMAP_LOCALFOLDER ); | 483 | setPixmap( 0, PIXMAP_LOCALFOLDER ); |
477 | setText( 0, " Local Folders" ); | 484 | setText( 0, " Local Folders" ); |
478 | setOpen( true ); | 485 | setOpen( true ); |
479 | } | 486 | } |
480 | 487 | ||
481 | MBOXviewItem::~MBOXviewItem() | 488 | MBOXviewItem::~MBOXviewItem() |
482 | { | 489 | { |
483 | delete wrapper; | 490 | delete wrapper; |
484 | } | 491 | } |
485 | 492 | ||
486 | AbstractMail *MBOXviewItem::getWrapper() | 493 | AbstractMail *MBOXviewItem::getWrapper() |
487 | { | 494 | { |
488 | return wrapper; | 495 | return wrapper; |
489 | } | 496 | } |
490 | 497 | ||
491 | void MBOXviewItem::refresh( QList<RecMail> & ) | 498 | void MBOXviewItem::refresh( QList<RecMail> & ) |
492 | { | 499 | { |
500 | refresh(false); | ||
501 | } | ||
502 | |||
503 | void MBOXviewItem::refresh(bool force) | ||
504 | { | ||
505 | if (childCount()>0 && force==false) return; | ||
493 | QList<Folder> *folders = wrapper->listFolders(); | 506 | QList<Folder> *folders = wrapper->listFolders(); |
494 | QListViewItem *child = firstChild(); | 507 | QListViewItem *child = firstChild(); |
495 | while ( child ) { | 508 | while ( child ) { |
496 | QListViewItem *tmp = child; | 509 | QListViewItem *tmp = child; |
497 | child = child->nextSibling(); | 510 | child = child->nextSibling(); |
498 | delete tmp; | 511 | delete tmp; |
499 | } | 512 | } |
500 | Folder *it; | 513 | Folder *it; |
501 | QListViewItem*item = 0; | 514 | QListViewItem*item = 0; |
502 | for ( it = folders->first(); it; it = folders->next() ) { | 515 | for ( it = folders->first(); it; it = folders->next() ) { |
503 | item = new MBOXfolderItem( it, this , item ); | 516 | item = new MBOXfolderItem( it, this , item ); |
504 | item->setSelectable(it->may_select()); | 517 | item->setSelectable(it->may_select()); |
505 | } | 518 | } |
506 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 519 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
507 | folders->setAutoDelete(false); | 520 | folders->setAutoDelete(false); |
508 | delete folders; | 521 | delete folders; |
509 | } | 522 | } |
510 | 523 | ||
511 | RecBody MBOXviewItem::fetchBody( const RecMail &mail ) | 524 | RecBody MBOXviewItem::fetchBody( const RecMail &mail ) |
512 | { | 525 | { |
513 | qDebug( "POP3 fetchBody" ); | 526 | qDebug( "MBOX fetchBody" ); |
514 | return wrapper->fetchBody( mail ); | 527 | return wrapper->fetchBody( mail ); |
515 | } | 528 | } |
516 | 529 | ||
530 | QPopupMenu * MBOXviewItem::getContextMenu() | ||
531 | { | ||
532 | QPopupMenu *m = new QPopupMenu(0); | ||
533 | if (m) { | ||
534 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | ||
535 | m->insertItem(QObject::tr("Create new folder",contextName),1); | ||
536 | } | ||
537 | return m; | ||
538 | } | ||
539 | |||
540 | void MBOXviewItem::createFolder() | ||
541 | { | ||
542 | Newmdirdlg ndirdlg(0,0,true); | ||
543 | ndirdlg.showMaximized(); | ||
544 | if (ndirdlg.exec()) { | ||
545 | QString ndir = ndirdlg.Newdir(); | ||
546 | if (wrapper->createMbox(ndir)) { | ||
547 | refresh(true); | ||
548 | } | ||
549 | } | ||
550 | } | ||
551 | |||
552 | void MBOXviewItem::contextMenuSelected(int which) | ||
553 | { | ||
554 | switch (which) { | ||
555 | case 0: | ||
556 | refresh(true); | ||
557 | break; | ||
558 | case 1: | ||
559 | createFolder(); | ||
560 | break; | ||
561 | default: | ||
562 | break; | ||
563 | } | ||
564 | } | ||
565 | |||
517 | MBOXfolderItem::~MBOXfolderItem() | 566 | MBOXfolderItem::~MBOXfolderItem() |
518 | { | 567 | { |
519 | delete folder; | 568 | delete folder; |
520 | } | 569 | } |
521 | 570 | ||
522 | MBOXfolderItem::MBOXfolderItem( Folder *folderInit, MBOXviewItem *parent , QListViewItem*after ) | 571 | MBOXfolderItem::MBOXfolderItem( Folder *folderInit, MBOXviewItem *parent , QListViewItem*after ) |
523 | : AccountViewItem( parent,after ) | 572 | : AccountViewItem( parent,after ) |
524 | { | 573 | { |
525 | folder = folderInit; | 574 | folder = folderInit; |
526 | mbox = parent; | 575 | mbox = parent; |
527 | if (folder->getDisplayName().lower() == "outgoing") { | 576 | if (folder->getDisplayName().lower() == "outgoing") { |
528 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); | 577 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); |
529 | } else if (folder->getDisplayName().lower() == "inbox") { | 578 | } else if (folder->getDisplayName().lower() == "inbox") { |
530 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 579 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
531 | } else { | 580 | } else { |
532 | setPixmap( 0, PIXMAP_MBOXFOLDER ); | 581 | setPixmap( 0, PIXMAP_MBOXFOLDER ); |
533 | } | 582 | } |
534 | setText( 0, folder->getDisplayName() ); | 583 | setText( 0, folder->getDisplayName() ); |
535 | } | 584 | } |
536 | 585 | ||
537 | void MBOXfolderItem::refresh(QList<RecMail>&target) | 586 | void MBOXfolderItem::refresh(QList<RecMail>&target) |
538 | { | 587 | { |
539 | if (folder->may_select()) | 588 | if (folder->may_select()) |
540 | mbox->getWrapper()->listMessages( folder->getName(),target ); | 589 | mbox->getWrapper()->listMessages( folder->getName(),target ); |
541 | } | 590 | } |
542 | 591 | ||
543 | RecBody MBOXfolderItem::fetchBody(const RecMail&aMail) | 592 | RecBody MBOXfolderItem::fetchBody(const RecMail&aMail) |
544 | { | 593 | { |
545 | return mbox->getWrapper()->fetchBody(aMail); | 594 | return mbox->getWrapper()->fetchBody(aMail); |
546 | } | 595 | } |
596 | |||
597 | void MBOXfolderItem::deleteAllMails() | ||
598 | { | ||
599 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), | ||
600 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).arg(folder->getDisplayName()), | ||
601 | QObject::tr("Yes",contextName), | ||
602 | QObject::tr("No",contextName),QString::null,1,1); | ||
603 | qDebug("Auswahl: %i",yesno); | ||
604 | if (yesno == 0) { | ||
605 | if (mbox->getWrapper()->deleteAllMail(folder)) { | ||
606 | AccountView * view = (AccountView*)listView(); | ||
607 | if (view) view->refreshCurrent(); | ||
608 | } | ||
609 | } | ||
610 | } | ||
611 | |||
612 | void MBOXfolderItem::deleteFolder() | ||
613 | { | ||
614 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | ||
615 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | ||
616 | QObject::tr("Yes",contextName), | ||
617 | QObject::tr("No",contextName),QString::null,1,1); | ||
618 | qDebug("Auswahl: %i",yesno); | ||
619 | if (yesno == 0) { | ||
620 | if (mbox->getWrapper()->deleteMbox(folder)) { | ||
621 | QListView*v=listView(); | ||
622 | MBOXviewItem * box = mbox; | ||
623 | /* be carefull - after that this object is destroyd so don't use | ||
624 | * any member of it after that call!!*/ | ||
625 | mbox->refresh(true); | ||
626 | if (v) { | ||
627 | v->setSelected(box,true); | ||
628 | } | ||
629 | } | ||
630 | } | ||
631 | } | ||
632 | |||
633 | QPopupMenu * MBOXfolderItem::getContextMenu() | ||
634 | { | ||
635 | QPopupMenu *m = new QPopupMenu(0); | ||
636 | if (m) { | ||
637 | m->insertItem(QObject::tr("Delete all mails",contextName),0); | ||
638 | m->insertItem(QObject::tr("Delete folder",contextName),1); | ||
639 | } | ||
640 | return m; | ||
641 | } | ||
642 | |||
643 | void MBOXfolderItem::contextMenuSelected(int which) | ||
644 | { | ||
645 | switch(which) { | ||
646 | case 0: | ||
647 | deleteAllMails(); | ||
648 | break; | ||
649 | case 1: | ||
650 | deleteFolder(); | ||
651 | break; | ||
652 | default: | ||
653 | break; | ||
654 | } | ||
655 | } | ||
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index e7fe038..98abf44 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h | |||
@@ -1,157 +1,173 @@ | |||
1 | #ifndef ACCOUNTVIEW_H | 1 | #ifndef ACCOUNTVIEW_H |
2 | #define ACCOUNTVIEW_H | 2 | #define ACCOUNTVIEW_H |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | 6 | ||
7 | #include "settings.h" | 7 | #include "settings.h" |
8 | #include "mailwrapper.h" | 8 | #include "mailwrapper.h" |
9 | #include "abstractmail.h" | 9 | #include "abstractmail.h" |
10 | 10 | ||
11 | class POP3wrapper; | 11 | class POP3wrapper; |
12 | class RecMail; | 12 | class RecMail; |
13 | class RecBody; | 13 | class RecBody; |
14 | class QPopupMenu; | 14 | class QPopupMenu; |
15 | 15 | ||
16 | class AccountViewItem : public QListViewItem | 16 | class AccountViewItem : public QListViewItem |
17 | { | 17 | { |
18 | 18 | ||
19 | public: | 19 | public: |
20 | AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} | 20 | AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} |
21 | AccountViewItem( QListViewItem *parent) : QListViewItem( parent) {} | 21 | AccountViewItem( QListViewItem *parent) : QListViewItem( parent) {} |
22 | AccountViewItem( QListViewItem *parent , QListViewItem*after ) : QListViewItem( parent,after ) {} | 22 | AccountViewItem( QListViewItem *parent , QListViewItem*after ) : QListViewItem( parent,after ) {} |
23 | virtual void refresh(QList<RecMail>&)=0; | 23 | virtual void refresh(QList<RecMail>&)=0; |
24 | virtual RecBody fetchBody(const RecMail&)=0; | 24 | virtual RecBody fetchBody(const RecMail&)=0; |
25 | virtual QPopupMenu * getContextMenu(){return 0;}; | 25 | virtual QPopupMenu * getContextMenu(){return 0;}; |
26 | virtual void contextMenuSelected(int){} | 26 | virtual void contextMenuSelected(int){} |
27 | protected: | ||
28 | static const QString contextName; | ||
27 | }; | 29 | }; |
28 | 30 | ||
29 | class POP3viewItem : public AccountViewItem | 31 | class POP3viewItem : public AccountViewItem |
30 | { | 32 | { |
31 | 33 | ||
32 | public: | 34 | public: |
33 | POP3viewItem( POP3account *a, QListView *parent ); | 35 | POP3viewItem( POP3account *a, QListView *parent ); |
34 | ~POP3viewItem(); | 36 | ~POP3viewItem(); |
35 | virtual void refresh( QList<RecMail> &target ); | 37 | virtual void refresh( QList<RecMail> &target ); |
36 | virtual RecBody fetchBody( const RecMail &mail ); | 38 | virtual RecBody fetchBody( const RecMail &mail ); |
37 | AbstractMail *getWrapper(); | 39 | AbstractMail *getWrapper(); |
38 | private: | 40 | private: |
39 | POP3account *account; | 41 | POP3account *account; |
40 | AbstractMail *wrapper; | 42 | AbstractMail *wrapper; |
41 | 43 | ||
42 | }; | 44 | }; |
43 | 45 | ||
44 | class POP3folderItem : public AccountViewItem | 46 | class POP3folderItem : public AccountViewItem |
45 | { | 47 | { |
46 | 48 | ||
47 | public: | 49 | public: |
48 | POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); | 50 | POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); |
49 | ~POP3folderItem(); | 51 | ~POP3folderItem(); |
50 | virtual void refresh(QList<RecMail>&); | 52 | virtual void refresh(QList<RecMail>&); |
51 | virtual RecBody fetchBody(const RecMail&); | 53 | virtual RecBody fetchBody(const RecMail&); |
52 | private: | 54 | private: |
53 | Folder *folder; | 55 | Folder *folder; |
54 | POP3viewItem *pop3; | 56 | POP3viewItem *pop3; |
55 | }; | 57 | }; |
56 | 58 | ||
57 | class IMAPfolderItem; | 59 | class IMAPfolderItem; |
58 | 60 | ||
59 | class IMAPviewItem : public AccountViewItem | 61 | class IMAPviewItem : public AccountViewItem |
60 | { | 62 | { |
61 | friend class IMAPfolderItem; | 63 | friend class IMAPfolderItem; |
62 | public: | 64 | public: |
63 | IMAPviewItem( IMAPaccount *a, QListView *parent ); | 65 | IMAPviewItem( IMAPaccount *a, QListView *parent ); |
64 | ~IMAPviewItem(); | 66 | ~IMAPviewItem(); |
65 | virtual void refresh(QList<RecMail>&); | 67 | virtual void refresh(QList<RecMail>&); |
66 | virtual RecBody fetchBody(const RecMail&); | 68 | virtual RecBody fetchBody(const RecMail&); |
67 | AbstractMail *getWrapper(); | 69 | AbstractMail *getWrapper(); |
68 | virtual QPopupMenu * getContextMenu(); | 70 | virtual QPopupMenu * getContextMenu(); |
69 | virtual void contextMenuSelected(int); | 71 | virtual void contextMenuSelected(int); |
70 | 72 | ||
71 | protected: | 73 | protected: |
72 | IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0); | 74 | IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0); |
73 | virtual void refreshFolders(bool force=false); | 75 | virtual void refreshFolders(bool force=false); |
74 | virtual void createNewFolder(); | 76 | virtual void createNewFolder(); |
75 | 77 | ||
76 | private: | 78 | private: |
77 | IMAPaccount *account; | 79 | IMAPaccount *account; |
78 | AbstractMail *wrapper; | 80 | AbstractMail *wrapper; |
79 | }; | 81 | }; |
80 | 82 | ||
81 | class IMAPfolderItem : public AccountViewItem | 83 | class IMAPfolderItem : public AccountViewItem |
82 | { | 84 | { |
83 | 85 | ||
84 | public: | 86 | public: |
85 | IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); | 87 | IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); |
86 | IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); | 88 | IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); |
87 | ~IMAPfolderItem(); | 89 | ~IMAPfolderItem(); |
88 | virtual void refresh(QList<RecMail>&); | 90 | virtual void refresh(QList<RecMail>&); |
89 | virtual RecBody fetchBody(const RecMail&); | 91 | virtual RecBody fetchBody(const RecMail&); |
90 | bool matchName(const QString&name)const; | 92 | bool matchName(const QString&name)const; |
91 | virtual void deleteAllMails(); | ||
92 | virtual QPopupMenu * getContextMenu(); | 93 | virtual QPopupMenu * getContextMenu(); |
93 | virtual void contextMenuSelected(int); | 94 | virtual void contextMenuSelected(int); |
94 | virtual const QString& Delemiter()const; | 95 | virtual const QString& Delemiter()const; |
95 | protected: | 96 | protected: |
96 | virtual void createNewFolder(); | 97 | virtual void createNewFolder(); |
97 | virtual void deleteFolder(); | 98 | virtual void deleteFolder(); |
99 | virtual void deleteAllMails(); | ||
98 | 100 | ||
99 | private: | 101 | private: |
100 | Folder *folder; | 102 | Folder *folder; |
101 | IMAPviewItem *imap; | 103 | IMAPviewItem *imap; |
102 | }; | 104 | }; |
103 | 105 | ||
104 | class MBOXviewItem : public AccountViewItem | 106 | class MBOXviewItem : public AccountViewItem |
105 | { | 107 | { |
108 | friend class MBOXfolderItem; | ||
106 | 109 | ||
107 | public: | 110 | public: |
108 | // MBOXviewItem( MBOXaccount *a, QListView *parent ); | 111 | // MBOXviewItem( MBOXaccount *a, QListView *parent ); |
109 | MBOXviewItem( const QString&aMboxPath, QListView *parent ); | 112 | MBOXviewItem( const QString&aMboxPath, QListView *parent ); |
110 | ~MBOXviewItem(); | 113 | ~MBOXviewItem(); |
111 | virtual void refresh( QList<RecMail> &target ); | 114 | virtual void refresh( QList<RecMail> &target ); |
112 | virtual RecBody fetchBody( const RecMail &mail ); | 115 | virtual RecBody fetchBody( const RecMail &mail ); |
113 | AbstractMail *getWrapper(); | 116 | AbstractMail *getWrapper(); |
117 | virtual QPopupMenu * getContextMenu(); | ||
118 | virtual void contextMenuSelected(int); | ||
119 | |||
120 | protected: | ||
121 | virtual void refresh(bool force=false); | ||
122 | virtual void createFolder(); | ||
123 | |||
114 | private: | 124 | private: |
115 | // MBOXaccount *account; | 125 | // MBOXaccount *account; |
116 | QString m_Path; | 126 | QString m_Path; |
117 | AbstractMail *wrapper; | 127 | AbstractMail *wrapper; |
118 | 128 | ||
119 | }; | 129 | }; |
120 | 130 | ||
121 | class MBOXfolderItem : public AccountViewItem | 131 | class MBOXfolderItem : public AccountViewItem |
122 | { | 132 | { |
123 | 133 | ||
124 | public: | 134 | public: |
125 | MBOXfolderItem( Folder *folder, MBOXviewItem *parent , QListViewItem*after ); | 135 | MBOXfolderItem( Folder *folder, MBOXviewItem *parent , QListViewItem*after ); |
126 | ~MBOXfolderItem(); | 136 | ~MBOXfolderItem(); |
127 | virtual void refresh(QList<RecMail>&); | 137 | virtual void refresh(QList<RecMail>&); |
128 | virtual RecBody fetchBody(const RecMail&); | 138 | virtual RecBody fetchBody(const RecMail&); |
139 | virtual QPopupMenu * getContextMenu(); | ||
140 | virtual void contextMenuSelected(int); | ||
141 | |||
142 | protected: | ||
143 | virtual void deleteAllMails(); | ||
144 | virtual void deleteFolder(); | ||
129 | private: | 145 | private: |
130 | Folder *folder; | 146 | Folder *folder; |
131 | MBOXviewItem *mbox; | 147 | MBOXviewItem *mbox; |
132 | }; | 148 | }; |
133 | 149 | ||
134 | class AccountView : public QListView | 150 | class AccountView : public QListView |
135 | { | 151 | { |
136 | Q_OBJECT | 152 | Q_OBJECT |
137 | 153 | ||
138 | public: | 154 | public: |
139 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); | 155 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); |
140 | void populate( QList<Account> list ); | 156 | void populate( QList<Account> list ); |
141 | RecBody fetchBody(const RecMail&aMail); | 157 | RecBody fetchBody(const RecMail&aMail); |
142 | 158 | ||
143 | public slots: | 159 | public slots: |
144 | virtual void refreshAll(); | 160 | virtual void refreshAll(); |
145 | virtual void refresh(QListViewItem *item); | 161 | virtual void refresh(QListViewItem *item); |
146 | virtual void refreshCurrent(); | 162 | virtual void refreshCurrent(); |
147 | virtual void slotHold(int, QListViewItem *,const QPoint&,int); | 163 | virtual void slotHold(int, QListViewItem *,const QPoint&,int); |
148 | virtual void slotContextMenu(int id); | 164 | virtual void slotContextMenu(int id); |
149 | 165 | ||
150 | signals: | 166 | signals: |
151 | void refreshMailview(QList<RecMail>*); | 167 | void refreshMailview(QList<RecMail>*); |
152 | 168 | ||
153 | private: | 169 | private: |
154 | QListViewItem* m_currentItem; | 170 | QListViewItem* m_currentItem; |
155 | }; | 171 | }; |
156 | 172 | ||
157 | #endif | 173 | #endif |
diff --git a/noncore/net/mail/genericwrapper.h b/noncore/net/mail/genericwrapper.h index 12f6928..90c4b50 100644 --- a/noncore/net/mail/genericwrapper.h +++ b/noncore/net/mail/genericwrapper.h | |||
@@ -1,59 +1,57 @@ | |||
1 | #ifndef __GENERIC_WRAPPER_H | 1 | #ifndef __GENERIC_WRAPPER_H |
2 | #define __GENERIC_WRAPPER_H | 2 | #define __GENERIC_WRAPPER_H |
3 | 3 | ||
4 | #include "abstractmail.h" | 4 | #include "abstractmail.h" |
5 | #include <qmap.h> | 5 | #include <qmap.h> |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <libetpan/clist.h> | 7 | #include <libetpan/clist.h> |
8 | 8 | ||
9 | class RecMail; | 9 | class RecMail; |
10 | class RecBody; | 10 | class RecBody; |
11 | class encodedString; | 11 | class encodedString; |
12 | struct mailpop3; | 12 | struct mailpop3; |
13 | struct mailmessage; | 13 | struct mailmessage; |
14 | struct mailmime; | 14 | struct mailmime; |
15 | struct mailmime_mechanism; | 15 | struct mailmime_mechanism; |
16 | struct mailimf_mailbox_list; | 16 | struct mailimf_mailbox_list; |
17 | struct mailimf_mailbox; | 17 | struct mailimf_mailbox; |
18 | struct mailimf_date_time; | 18 | struct mailimf_date_time; |
19 | struct mailimf_group; | 19 | struct mailimf_group; |
20 | struct mailimf_address_list; | 20 | struct mailimf_address_list; |
21 | 21 | ||
22 | /* this class hold just the funs shared between | 22 | /* this class hold just the funs shared between |
23 | * mbox and pop3 (later mh, too) mail access. | 23 | * mbox and pop3 (later mh, too) mail access. |
24 | * it is not desigend to make a instance of it! | 24 | * it is not desigend to make a instance of it! |
25 | */ | 25 | */ |
26 | class Genericwrapper : public AbstractMail | 26 | class Genericwrapper : public AbstractMail |
27 | { | 27 | { |
28 | Q_OBJECT | 28 | Q_OBJECT |
29 | public: | 29 | public: |
30 | Genericwrapper(); | 30 | Genericwrapper(); |
31 | virtual ~Genericwrapper(); | 31 | virtual ~Genericwrapper(); |
32 | 32 | ||
33 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | 33 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); |
34 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | 34 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); |
35 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); | 35 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); |
36 | virtual void cleanMimeCache(); | 36 | virtual void cleanMimeCache(); |
37 | 37 | ||
38 | protected: | 38 | protected: |
39 | RecMail *parseHeader( const char *header ); | 39 | RecMail *parseHeader( const char *header ); |
40 | RecBody parseMail( mailmessage * msg ); | 40 | RecBody parseMail( mailmessage * msg ); |
41 | QString parseMailboxList( mailimf_mailbox_list *list ); | 41 | QString parseMailboxList( mailimf_mailbox_list *list ); |
42 | QString parseMailbox( mailimf_mailbox *box ); | 42 | QString parseMailbox( mailimf_mailbox *box ); |
43 | QString parseGroup( mailimf_group *group ); | 43 | QString parseGroup( mailimf_group *group ); |
44 | QString parseAddressList( mailimf_address_list *list ); | 44 | QString parseAddressList( mailimf_address_list *list ); |
45 | QString parseDateTime( mailimf_date_time *date ); | 45 | QString parseDateTime( mailimf_date_time *date ); |
46 | 46 | ||
47 | void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rek=0); | 47 | void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rek=0); |
48 | static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); | 48 | static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); |
49 | static void fillParameters(RecPart&target,clist*parameters); | 49 | static void fillParameters(RecPart&target,clist*parameters); |
50 | static QString getencoding(mailmime_mechanism*aEnc); | 50 | static QString getencoding(mailmime_mechanism*aEnc); |
51 | 51 | ||
52 | POP3account *account; | ||
53 | mailpop3 *m_pop3; | ||
54 | QString msgTempName; | 52 | QString msgTempName; |
55 | unsigned int last_msg_id; | 53 | unsigned int last_msg_id; |
56 | QMap<QString,encodedString*> bodyCache; | 54 | QMap<QString,encodedString*> bodyCache; |
57 | }; | 55 | }; |
58 | 56 | ||
59 | #endif | 57 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.h b/noncore/net/mail/libmailwrapper/genericwrapper.h index 12f6928..90c4b50 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.h +++ b/noncore/net/mail/libmailwrapper/genericwrapper.h | |||
@@ -1,59 +1,57 @@ | |||
1 | #ifndef __GENERIC_WRAPPER_H | 1 | #ifndef __GENERIC_WRAPPER_H |
2 | #define __GENERIC_WRAPPER_H | 2 | #define __GENERIC_WRAPPER_H |
3 | 3 | ||
4 | #include "abstractmail.h" | 4 | #include "abstractmail.h" |
5 | #include <qmap.h> | 5 | #include <qmap.h> |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <libetpan/clist.h> | 7 | #include <libetpan/clist.h> |
8 | 8 | ||
9 | class RecMail; | 9 | class RecMail; |
10 | class RecBody; | 10 | class RecBody; |
11 | class encodedString; | 11 | class encodedString; |
12 | struct mailpop3; | 12 | struct mailpop3; |
13 | struct mailmessage; | 13 | struct mailmessage; |
14 | struct mailmime; | 14 | struct mailmime; |
15 | struct mailmime_mechanism; | 15 | struct mailmime_mechanism; |
16 | struct mailimf_mailbox_list; | 16 | struct mailimf_mailbox_list; |
17 | struct mailimf_mailbox; | 17 | struct mailimf_mailbox; |
18 | struct mailimf_date_time; | 18 | struct mailimf_date_time; |
19 | struct mailimf_group; | 19 | struct mailimf_group; |
20 | struct mailimf_address_list; | 20 | struct mailimf_address_list; |
21 | 21 | ||
22 | /* this class hold just the funs shared between | 22 | /* this class hold just the funs shared between |
23 | * mbox and pop3 (later mh, too) mail access. | 23 | * mbox and pop3 (later mh, too) mail access. |
24 | * it is not desigend to make a instance of it! | 24 | * it is not desigend to make a instance of it! |
25 | */ | 25 | */ |
26 | class Genericwrapper : public AbstractMail | 26 | class Genericwrapper : public AbstractMail |
27 | { | 27 | { |
28 | Q_OBJECT | 28 | Q_OBJECT |
29 | public: | 29 | public: |
30 | Genericwrapper(); | 30 | Genericwrapper(); |
31 | virtual ~Genericwrapper(); | 31 | virtual ~Genericwrapper(); |
32 | 32 | ||
33 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | 33 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); |
34 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | 34 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); |
35 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); | 35 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); |
36 | virtual void cleanMimeCache(); | 36 | virtual void cleanMimeCache(); |
37 | 37 | ||
38 | protected: | 38 | protected: |
39 | RecMail *parseHeader( const char *header ); | 39 | RecMail *parseHeader( const char *header ); |
40 | RecBody parseMail( mailmessage * msg ); | 40 | RecBody parseMail( mailmessage * msg ); |
41 | QString parseMailboxList( mailimf_mailbox_list *list ); | 41 | QString parseMailboxList( mailimf_mailbox_list *list ); |
42 | QString parseMailbox( mailimf_mailbox *box ); | 42 | QString parseMailbox( mailimf_mailbox *box ); |
43 | QString parseGroup( mailimf_group *group ); | 43 | QString parseGroup( mailimf_group *group ); |
44 | QString parseAddressList( mailimf_address_list *list ); | 44 | QString parseAddressList( mailimf_address_list *list ); |
45 | QString parseDateTime( mailimf_date_time *date ); | 45 | QString parseDateTime( mailimf_date_time *date ); |
46 | 46 | ||
47 | void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rek=0); | 47 | void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rek=0); |
48 | static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); | 48 | static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); |
49 | static void fillParameters(RecPart&target,clist*parameters); | 49 | static void fillParameters(RecPart&target,clist*parameters); |
50 | static QString getencoding(mailmime_mechanism*aEnc); | 50 | static QString getencoding(mailmime_mechanism*aEnc); |
51 | 51 | ||
52 | POP3account *account; | ||
53 | mailpop3 *m_pop3; | ||
54 | QString msgTempName; | 52 | QString msgTempName; |
55 | unsigned int last_msg_id; | 53 | unsigned int last_msg_id; |
56 | QMap<QString,encodedString*> bodyCache; | 54 | QMap<QString,encodedString*> bodyCache; |
57 | }; | 55 | }; |
58 | 56 | ||
59 | #endif | 57 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp index 6d69263..162a0c9 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp | |||
@@ -1,293 +1,367 @@ | |||
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 <libetpan/mailstorage.h> | ||
6 | #include <qdir.h> | 5 | #include <qdir.h> |
7 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | #include <qpe/global.h> | ||
8 | 8 | ||
9 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir) | 9 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir) |
10 | : Genericwrapper(),MBOXPath(mbox_dir) | 10 | : Genericwrapper(),MBOXPath(mbox_dir) |
11 | { | 11 | { |
12 | QDir dir(MBOXPath); | 12 | QDir dir(MBOXPath); |
13 | if (!dir.exists()) { | 13 | if (!dir.exists()) { |
14 | dir.mkdir(MBOXPath); | 14 | dir.mkdir(MBOXPath); |
15 | } | 15 | } |
16 | } | 16 | } |
17 | 17 | ||
18 | MBOXwrapper::~MBOXwrapper() | 18 | MBOXwrapper::~MBOXwrapper() |
19 | { | 19 | { |
20 | } | 20 | } |
21 | 21 | ||
22 | void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) | 22 | void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) |
23 | { | 23 | { |
24 | mailstorage*storage = mailstorage_new(NULL); | 24 | mailstorage*storage = mailstorage_new(NULL); |
25 | QString p = MBOXPath+"/"; | 25 | QString p = MBOXPath+"/"; |
26 | p+=mailbox; | 26 | p+=mailbox; |
27 | char*fname = 0; | 27 | |
28 | 28 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | |
29 | fname = strdup(p.latin1()); | ||
30 | |||
31 | int r = mbox_mailstorage_init(storage,fname,0,0,0); | ||
32 | mailfolder*folder; | 29 | mailfolder*folder; |
33 | folder = mailfolder_new( storage,fname,NULL); | 30 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
34 | r = mailfolder_connect(folder); | 31 | r = mailfolder_connect(folder); |
35 | if (r != MAIL_NO_ERROR) { | 32 | if (r != MAIL_NO_ERROR) { |
36 | qDebug("Error initializing mbox"); | 33 | qDebug("Error initializing mbox"); |
37 | mailfolder_free(folder); | 34 | mailfolder_free(folder); |
38 | mailstorage_free(storage); | 35 | mailstorage_free(storage); |
39 | free(fname); | ||
40 | return; | 36 | return; |
41 | } | 37 | } |
42 | mailmessage_list * env_list = 0; | 38 | mailmessage_list * env_list = 0; |
43 | r = mailsession_get_messages_list(folder->fld_session,&env_list); | 39 | r = mailsession_get_messages_list(folder->fld_session,&env_list); |
44 | if (r != MAIL_NO_ERROR) { | 40 | if (r != MAIL_NO_ERROR) { |
45 | qDebug("Error message list"); | 41 | qDebug("Error message list"); |
46 | mailfolder_free(folder); | 42 | mailfolder_free(folder); |
47 | mailstorage_free(storage); | 43 | mailstorage_free(storage); |
48 | free(fname); | ||
49 | return; | 44 | return; |
50 | } | 45 | } |
51 | r = mailsession_get_envelopes_list(folder->fld_session, env_list); | 46 | r = mailsession_get_envelopes_list(folder->fld_session, env_list); |
52 | if (r != MAIL_NO_ERROR) { | 47 | if (r != MAIL_NO_ERROR) { |
53 | qDebug("Error filling message list"); | 48 | qDebug("Error filling message list"); |
54 | if (env_list) { | 49 | if (env_list) { |
55 | mailmessage_list_free(env_list); | 50 | mailmessage_list_free(env_list); |
56 | } | 51 | } |
57 | mailfolder_free(folder); | 52 | mailfolder_free(folder); |
58 | mailstorage_free(storage); | 53 | mailstorage_free(storage); |
59 | free(fname); | ||
60 | return; | 54 | return; |
61 | } | 55 | } |
62 | mailimf_references * refs; | 56 | mailimf_references * refs; |
63 | 57 | ||
64 | for(int i = 0 ; i < carray_count(env_list->msg_tab) ; ++i) { | 58 | uint32_t i = 0; |
59 | for(; i < carray_count(env_list->msg_tab) ; ++i) { | ||
65 | mailmessage * msg; | 60 | mailmessage * msg; |
66 | QBitArray mFlags(7); | 61 | QBitArray mFlags(7); |
67 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); | 62 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); |
68 | if (msg->msg_fields == NULL) { | 63 | if (msg->msg_fields == NULL) { |
69 | qDebug("could not fetch envelope of message %i", i); | 64 | qDebug("could not fetch envelope of message %i", i); |
70 | continue; | 65 | continue; |
71 | } | 66 | } |
72 | RecMail * mail = new RecMail(); | 67 | RecMail * mail = new RecMail(); |
73 | mail->setWrapper(this); | 68 | mail->setWrapper(this); |
74 | mail_flags * flag_result = 0; | 69 | mail_flags * flag_result = 0; |
75 | r = mailmessage_get_flags(msg,&flag_result); | 70 | r = mailmessage_get_flags(msg,&flag_result); |
76 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { | 71 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { |
77 | mFlags.setBit(FLAG_SEEN); | 72 | mFlags.setBit(FLAG_SEEN); |
78 | } | 73 | } |
79 | mailimf_single_fields single_fields; | 74 | mailimf_single_fields single_fields; |
80 | mailimf_single_fields_init(&single_fields, msg->msg_fields); | 75 | mailimf_single_fields_init(&single_fields, msg->msg_fields); |
81 | mail->setMsgsize(msg->msg_size); | 76 | mail->setMsgsize(msg->msg_size); |
82 | mail->setFlags(mFlags); | 77 | mail->setFlags(mFlags); |
83 | mail->setMbox(mailbox); | 78 | mail->setMbox(mailbox); |
84 | mail->setNumber(i+1); | 79 | mail->setNumber(i+1); |
85 | if (single_fields.fld_subject) | 80 | if (single_fields.fld_subject) |
86 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); | 81 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); |
87 | if (single_fields.fld_from) | 82 | if (single_fields.fld_from) |
88 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); | 83 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); |
89 | if (single_fields.fld_to) | 84 | if (single_fields.fld_to) |
90 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); | 85 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); |
91 | if (single_fields.fld_cc) | 86 | if (single_fields.fld_cc) |
92 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); | 87 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); |
93 | if (single_fields.fld_bcc) | 88 | if (single_fields.fld_bcc) |
94 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); | 89 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); |
95 | if (single_fields.fld_orig_date) | 90 | if (single_fields.fld_orig_date) |
96 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); | 91 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); |
97 | if (single_fields.fld_message_id->mid_value) | 92 | if (single_fields.fld_message_id->mid_value) |
98 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); | 93 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); |
99 | refs = single_fields.fld_references; | 94 | refs = single_fields.fld_references; |
100 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { | 95 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { |
101 | char * text = (char*)refs->mid_list->first->data; | 96 | char * text = (char*)refs->mid_list->first->data; |
102 | mail->setReplyto(QString(text)); | 97 | mail->setReplyto(QString(text)); |
103 | } | 98 | } |
104 | 99 | ||
105 | target.append(mail); | 100 | target.append(mail); |
106 | } | 101 | } |
107 | if (env_list) { | 102 | if (env_list) { |
108 | mailmessage_list_free(env_list); | 103 | mailmessage_list_free(env_list); |
109 | } | 104 | } |
110 | mailfolder_disconnect(folder); | 105 | mailfolder_disconnect(folder); |
111 | mailfolder_free(folder); | 106 | mailfolder_free(folder); |
112 | mailstorage_free(storage); | 107 | mailstorage_free(storage); |
113 | free(fname); | 108 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(i)); |
114 | } | 109 | } |
115 | 110 | ||
116 | QList<Folder>* MBOXwrapper::listFolders() | 111 | QList<Folder>* MBOXwrapper::listFolders() |
117 | { | 112 | { |
118 | QList<Folder> * folders = new QList<Folder>(); | 113 | QList<Folder> * folders = new QList<Folder>(); |
119 | folders->setAutoDelete( false ); | 114 | folders->setAutoDelete( false ); |
120 | QDir dir(MBOXPath); | 115 | QDir dir(MBOXPath); |
121 | if (!dir.exists()) return folders; | 116 | if (!dir.exists()) return folders; |
122 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); | 117 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); |
123 | QStringList entries = dir.entryList(); | 118 | QStringList entries = dir.entryList(); |
124 | QStringList::ConstIterator it = entries.begin(); | 119 | QStringList::ConstIterator it = entries.begin(); |
125 | for (;it!=entries.end();++it) { | 120 | for (;it!=entries.end();++it) { |
126 | Folder*inb=new Folder(*it,"/"); | 121 | Folder*inb=new Folder(*it,"/"); |
127 | folders->append(inb); | 122 | folders->append(inb); |
128 | } | 123 | } |
129 | return folders; | 124 | return folders; |
130 | } | 125 | } |
131 | 126 | ||
132 | void MBOXwrapper::deleteMail(const RecMail&mail) | 127 | void MBOXwrapper::deleteMail(const RecMail&mail) |
133 | { | 128 | { |
134 | mailstorage*storage = mailstorage_new(NULL); | 129 | mailstorage*storage = mailstorage_new(NULL); |
135 | QString p = MBOXPath+"/"; | 130 | QString p = MBOXPath+"/"; |
136 | p+=mail.getMbox(); | 131 | p+=mail.getMbox(); |
137 | mailmessage * msg; | 132 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
138 | int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0); | ||
139 | mailfolder*folder; | 133 | mailfolder*folder; |
140 | folder = mailfolder_new( storage,strdup(p.latin1()),NULL); | 134 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
141 | r = mailfolder_connect(folder); | 135 | r = mailfolder_connect(folder); |
142 | if (r != MAIL_NO_ERROR) { | 136 | if (r != MAIL_NO_ERROR) { |
143 | qDebug("Error initializing mbox"); | 137 | qDebug("Error initializing mbox"); |
144 | mailfolder_free(folder); | 138 | mailfolder_free(folder); |
145 | mailstorage_free(storage); | 139 | mailstorage_free(storage); |
146 | return; | 140 | return; |
147 | } | 141 | } |
148 | r = mailsession_remove_message(folder->fld_session,mail.getNumber()); | 142 | r = mailsession_remove_message(folder->fld_session,mail.getNumber()); |
149 | if (r != MAIL_NO_ERROR) { | 143 | if (r != MAIL_NO_ERROR) { |
150 | qDebug("error deleting mail"); | 144 | qDebug("error deleting mail"); |
151 | } | 145 | } |
152 | mailfolder_free(folder); | 146 | mailfolder_free(folder); |
153 | mailstorage_free(storage); | 147 | mailstorage_free(storage); |
154 | } | 148 | } |
155 | 149 | ||
156 | void MBOXwrapper::answeredMail(const RecMail&) | 150 | void MBOXwrapper::answeredMail(const RecMail&) |
157 | { | 151 | { |
158 | } | 152 | } |
159 | 153 | ||
160 | RecBody MBOXwrapper::fetchBody( const RecMail &mail ) | 154 | RecBody MBOXwrapper::fetchBody( const RecMail &mail ) |
161 | { | 155 | { |
162 | RecBody body; | 156 | RecBody body; |
163 | mailstorage*storage = mailstorage_new(NULL); | 157 | mailstorage*storage = mailstorage_new(NULL); |
164 | QString p = MBOXPath+"/"; | 158 | QString p = MBOXPath+"/"; |
165 | p+=mail.getMbox(); | 159 | p+=mail.getMbox(); |
166 | mailmessage * msg; | 160 | mailmessage * msg; |
167 | char*data=0; | 161 | char*data=0; |
168 | size_t size; | 162 | size_t size; |
169 | 163 | ||
170 | int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0); | 164 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
171 | mailfolder*folder; | 165 | mailfolder*folder; |
172 | folder = mailfolder_new( storage,strdup(p.latin1()),NULL); | 166 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
173 | r = mailfolder_connect(folder); | 167 | r = mailfolder_connect(folder); |
174 | if (r != MAIL_NO_ERROR) { | 168 | if (r != MAIL_NO_ERROR) { |
175 | qDebug("Error initializing mbox"); | 169 | qDebug("Error initializing mbox"); |
176 | mailfolder_free(folder); | 170 | mailfolder_free(folder); |
177 | mailstorage_free(storage); | 171 | mailstorage_free(storage); |
178 | return body; | 172 | return body; |
179 | } | 173 | } |
180 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); | 174 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); |
181 | if (r != MAIL_NO_ERROR) { | 175 | if (r != MAIL_NO_ERROR) { |
182 | qDebug("Error fetching mail %i",mail.getNumber()); | 176 | qDebug("Error fetching mail %i",mail.getNumber()); |
183 | mailfolder_free(folder); | 177 | mailfolder_free(folder); |
184 | mailstorage_free(storage); | 178 | mailstorage_free(storage); |
185 | return body; | 179 | return body; |
186 | } | 180 | } |
187 | r = mailmessage_fetch(msg,&data,&size); | 181 | r = mailmessage_fetch(msg,&data,&size); |
188 | if (r != MAIL_NO_ERROR) { | 182 | if (r != MAIL_NO_ERROR) { |
189 | qDebug("Error fetching mail %i",mail.getNumber()); | 183 | qDebug("Error fetching mail %i",mail.getNumber()); |
190 | mailfolder_free(folder); | 184 | mailfolder_free(folder); |
191 | mailstorage_free(storage); | 185 | mailstorage_free(storage); |
192 | mailmessage_free(msg); | 186 | mailmessage_free(msg); |
193 | return body; | 187 | return body; |
194 | } | 188 | } |
195 | body = parseMail(msg); | 189 | body = parseMail(msg); |
196 | mailmessage_fetch_result_free(msg,data); | 190 | mailmessage_fetch_result_free(msg,data); |
197 | mailfolder_free(folder); | 191 | mailfolder_free(folder); |
198 | mailstorage_free(storage); | 192 | mailstorage_free(storage); |
199 | 193 | ||
200 | return body; | 194 | return body; |
201 | } | 195 | } |
202 | 196 | ||
203 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) | 197 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) |
204 | { | 198 | { |
205 | qDebug("MBOX %i von %i",current,maximum); | 199 | qDebug("MBOX %i von %i",current,maximum); |
206 | } | 200 | } |
207 | 201 | ||
208 | void MBOXwrapper::createFolder(const QString&) | 202 | int MBOXwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool ) |
209 | { | 203 | { |
204 | QString p = MBOXPath+"/"; | ||
205 | p+=folder; | ||
206 | QFileInfo fi(p); | ||
207 | if (fi.exists()) { | ||
208 | Global::statusMessage(tr("Mailbox exists.")); | ||
209 | return 0; | ||
210 | } | ||
211 | mailmbox_folder*f = 0; | ||
212 | if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { | ||
213 | Global::statusMessage(tr("Error init folder")); | ||
214 | return 0; | ||
215 | } | ||
216 | if (f) mailmbox_done(f); | ||
217 | return 1; | ||
210 | } | 218 | } |
211 | 219 | ||
212 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 220 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
213 | { | 221 | { |
214 | QString p = MBOXPath+"/"; | 222 | QString p = MBOXPath+"/"; |
215 | p+=folder; | 223 | p+=folder; |
216 | mailmbox_folder*f = 0; | 224 | mailmbox_folder*f = 0; |
217 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 225 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
218 | if (r != MAIL_NO_ERROR) { | 226 | if (r != MAIL_NO_ERROR) { |
219 | qDebug("Error init folder"); | 227 | Global::statusMessage(tr("Error init folder")); |
220 | return; | 228 | return; |
221 | } | 229 | } |
222 | r = mailmbox_append_message(f,msg,length); | 230 | r = mailmbox_append_message(f,msg,length); |
223 | if (r != MAIL_NO_ERROR) { | 231 | if (r != MAIL_NO_ERROR) { |
224 | qDebug("Error writing message folder"); | 232 | Global::statusMessage(tr("Error writing to message folder")); |
225 | } | 233 | } |
226 | mailmbox_done(f); | 234 | mailmbox_done(f); |
227 | } | 235 | } |
228 | 236 | ||
229 | void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) | 237 | void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) |
230 | { | 238 | { |
231 | RecBody body; | 239 | RecBody body; |
232 | mailstorage*storage = mailstorage_new(NULL); | 240 | mailstorage*storage = mailstorage_new(NULL); |
233 | QString p = MBOXPath+"/"; | 241 | QString p = MBOXPath+"/"; |
234 | p+=mail.getMbox(); | 242 | p+=mail.getMbox(); |
235 | mailmessage * msg; | 243 | mailmessage * msg; |
236 | char*data=0; | 244 | char*data=0; |
237 | size_t size; | 245 | size_t size; |
238 | 246 | ||
239 | int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0); | 247 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
240 | mailfolder*folder; | 248 | mailfolder*folder; |
241 | folder = mailfolder_new( storage,strdup(p.latin1()),NULL); | 249 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
242 | r = mailfolder_connect(folder); | 250 | r = mailfolder_connect(folder); |
243 | if (r != MAIL_NO_ERROR) { | 251 | if (r != MAIL_NO_ERROR) { |
244 | qDebug("Error initializing mbox"); | 252 | Global::statusMessage(tr("Error initializing mbox")); |
245 | mailfolder_free(folder); | 253 | mailfolder_free(folder); |
246 | mailstorage_free(storage); | 254 | mailstorage_free(storage); |
247 | return; | 255 | return; |
248 | } | 256 | } |
249 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); | 257 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); |
250 | if (r != MAIL_NO_ERROR) { | 258 | if (r != MAIL_NO_ERROR) { |
251 | qDebug("Error fetching mail %i",mail.getNumber()); | 259 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
252 | mailfolder_free(folder); | 260 | mailfolder_free(folder); |
253 | mailstorage_free(storage); | 261 | mailstorage_free(storage); |
254 | return; | 262 | return; |
255 | } | 263 | } |
256 | r = mailmessage_fetch(msg,&data,&size); | 264 | r = mailmessage_fetch(msg,&data,&size); |
257 | if (r != MAIL_NO_ERROR) { | 265 | if (r != MAIL_NO_ERROR) { |
258 | qDebug("Error fetching mail %i",mail.getNumber()); | 266 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
259 | mailfolder_free(folder); | 267 | mailfolder_free(folder); |
260 | mailstorage_free(storage); | 268 | mailstorage_free(storage); |
261 | mailmessage_free(msg); | 269 | mailmessage_free(msg); |
262 | return; | 270 | return; |
263 | } | 271 | } |
264 | *target = data; | 272 | *target = data; |
265 | *length = size; | 273 | *length = size; |
266 | mailfolder_free(folder); | 274 | mailfolder_free(folder); |
267 | mailstorage_free(storage); | 275 | mailstorage_free(storage); |
268 | mailmessage_free(msg); | 276 | mailmessage_free(msg); |
269 | } | 277 | } |
270 | 278 | ||
271 | void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) | 279 | void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) |
272 | { | 280 | { |
273 | QString p = MBOXPath+"/"; | 281 | QString p = MBOXPath+"/"; |
274 | p+=mailbox; | 282 | p+=mailbox; |
275 | mailmbox_folder*f = 0; | 283 | mailmbox_folder*f = 0; |
276 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 284 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
277 | if (r != MAIL_NO_ERROR) { | 285 | if (r != MAIL_NO_ERROR) { |
278 | qDebug("Error init folder"); | 286 | qDebug("Error init folder"); |
279 | return; | 287 | return; |
280 | } | 288 | } |
289 | deleteMails(f,target); | ||
290 | mailmbox_done(f); | ||
291 | } | ||
292 | |||
293 | void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) | ||
294 | { | ||
295 | if (!f) return; | ||
296 | int r; | ||
281 | for (unsigned int i=0; i < target.count();++i) { | 297 | for (unsigned int i=0; i < target.count();++i) { |
282 | r = mailmbox_delete_msg(f,target.at(i)->getNumber()); | 298 | r = mailmbox_delete_msg(f,target.at(i)->getNumber()); |
283 | if (r!=MAILMBOX_NO_ERROR) { | 299 | if (r!=MAILMBOX_NO_ERROR) { |
284 | qDebug("error delete mail"); | 300 | qDebug("error delete mail"); |
285 | } | 301 | } |
286 | } | 302 | } |
287 | r = mailmbox_expunge(f); | 303 | r = mailmbox_expunge(f); |
288 | if (r != MAILMBOX_NO_ERROR) { | 304 | if (r != MAILMBOX_NO_ERROR) { |
289 | qDebug("error expunge mailbox"); | 305 | qDebug("error expunge mailbox"); |
290 | } | 306 | } |
291 | mailmbox_done(f); | 307 | } |
308 | |||
309 | int MBOXwrapper::deleteAllMail(const Folder*tfolder) | ||
310 | { | ||
311 | if (!tfolder) return 0; | ||
312 | QString p = MBOXPath+tfolder->getDisplayName(); | ||
313 | int res = 1; | ||
314 | |||
315 | mailfolder*folder = 0; | ||
316 | mailmessage_list*l=0; | ||
317 | mailstorage*storage = mailstorage_new(NULL); | ||
318 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | ||
319 | if (r != MAIL_NO_ERROR) { | ||
320 | Global::statusMessage(tr("Error initializing mbox")); | ||
321 | res = 0; | ||
322 | } | ||
323 | if (res) { | ||
324 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | ||
325 | r = mailfolder_connect(folder); | ||
326 | if (r != MAIL_NO_ERROR) { | ||
327 | Global::statusMessage(tr("Error initializing mbox")); | ||
328 | res = 0; | ||
329 | } | ||
330 | } | ||
331 | if (res) { | ||
332 | r = mailsession_get_messages_list(folder->fld_session,&l); | ||
333 | if (r != MAIL_NO_ERROR) { | ||
334 | qDebug("Error message list"); | ||
335 | res=0; | ||
336 | } | ||
337 | } | ||
338 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { | ||
339 | r = mailsession_remove_message(folder->fld_session,i+1); | ||
340 | if (r != MAIL_NO_ERROR) { | ||
341 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | ||
342 | res = 0; | ||
343 | break; | ||
344 | } | ||
345 | } | ||
346 | if (l) mailmessage_list_free(l); | ||
347 | if (folder) mailfolder_free(folder); | ||
348 | if (storage) mailstorage_free(storage); | ||
349 | return res; | ||
350 | } | ||
351 | |||
352 | int MBOXwrapper::deleteMbox(const Folder*tfolder) | ||
353 | { | ||
354 | if (!tfolder) return 0; | ||
355 | QString p = MBOXPath+tfolder->getDisplayName(); | ||
356 | QFile fi(p); | ||
357 | if (!fi.exists()) { | ||
358 | Global::statusMessage(tr("Mailbox doesn't exist.")); | ||
359 | return 0; | ||
360 | } | ||
361 | if (!fi.remove()) { | ||
362 | Global::statusMessage(tr("Error deleting Mailbox.")); | ||
363 | return 0; | ||
364 | } | ||
365 | return 1; | ||
292 | } | 366 | } |
293 | 367 | ||
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h index f64ad52..226a544 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.h +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h | |||
@@ -1,35 +1,41 @@ | |||
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 | 6 | ||
7 | class RecMail; | 7 | class RecMail; |
8 | class RecBody; | 8 | class RecBody; |
9 | struct mailmbox_folder; | ||
9 | 10 | ||
10 | class MBOXwrapper : public Genericwrapper | 11 | class MBOXwrapper : public Genericwrapper |
11 | { | 12 | { |
12 | Q_OBJECT | 13 | Q_OBJECT |
13 | public: | 14 | public: |
14 | MBOXwrapper(const QString & dir); | 15 | MBOXwrapper(const QString & dir); |
15 | virtual ~MBOXwrapper(); | 16 | virtual ~MBOXwrapper(); |
16 | 17 | ||
17 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 18 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
18 | virtual QList<Folder>* listFolders(); | 19 | virtual QList<Folder>* listFolders(); |
19 | 20 | ||
20 | virtual void deleteMail(const RecMail&mail); | 21 | virtual void deleteMail(const RecMail&mail); |
21 | virtual void answeredMail(const RecMail&mail); | 22 | virtual void answeredMail(const RecMail&mail); |
22 | virtual void createFolder(const QString&aFolder); | 23 | |
24 | virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); | ||
25 | virtual int deleteMbox(const Folder*); | ||
26 | |||
23 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 27 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
24 | 28 | ||
25 | virtual RecBody fetchBody( const RecMail &mail ); | 29 | virtual RecBody fetchBody( const RecMail &mail ); |
26 | static void mbox_progress( size_t current, size_t maximum ); | 30 | static void mbox_progress( size_t current, size_t maximum ); |
27 | 31 | ||
28 | virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); | 32 | virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); |
29 | virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); | 33 | virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); |
34 | virtual int deleteAllMail(const Folder*); | ||
30 | 35 | ||
31 | protected: | 36 | protected: |
37 | static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); | ||
32 | QString MBOXPath; | 38 | QString MBOXPath; |
33 | }; | 39 | }; |
34 | 40 | ||
35 | #endif | 41 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index efd83ba..b85fbf6 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -1,230 +1,231 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include "pop3wrapper.h" | 2 | #include "pop3wrapper.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | #include "logindialog.h" | 4 | #include "logindialog.h" |
5 | #include <libetpan/mailpop3.h> | 5 | #include <libetpan/libetpan.h> |
6 | #include <libetpan/mailmime.h> | 6 | #include <qpe/global.h> |
7 | #include <libetpan/data_message_driver.h> | ||
8 | #include <qfile.h> | 7 | #include <qfile.h> |
9 | 8 | ||
10 | /* we don't fetch messages larger than 5 MB */ | 9 | /* we don't fetch messages larger than 5 MB */ |
11 | #define HARD_MSG_SIZE_LIMIT 5242880 | 10 | #define HARD_MSG_SIZE_LIMIT 5242880 |
12 | 11 | ||
13 | POP3wrapper::POP3wrapper( POP3account *a ) | 12 | POP3wrapper::POP3wrapper( POP3account *a ) |
14 | : Genericwrapper() | 13 | : Genericwrapper() |
15 | { | 14 | { |
16 | account = a; | 15 | account = a; |
17 | m_pop3 = NULL; | 16 | m_pop3 = NULL; |
18 | msgTempName = a->getFileName()+"_msg_cache"; | 17 | msgTempName = a->getFileName()+"_msg_cache"; |
19 | last_msg_id = 0; | 18 | last_msg_id = 0; |
20 | } | 19 | } |
21 | 20 | ||
22 | POP3wrapper::~POP3wrapper() | 21 | POP3wrapper::~POP3wrapper() |
23 | { | 22 | { |
24 | logout(); | 23 | logout(); |
25 | QFile msg_cache(msgTempName); | 24 | QFile msg_cache(msgTempName); |
26 | if (msg_cache.exists()) { | 25 | if (msg_cache.exists()) { |
27 | msg_cache.remove(); | 26 | msg_cache.remove(); |
28 | } | 27 | } |
29 | } | 28 | } |
30 | 29 | ||
31 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) | 30 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) |
32 | { | 31 | { |
33 | //qDebug( "POP3: %i of %i", current, maximum ); | 32 | //qDebug( "POP3: %i of %i", current, maximum ); |
34 | } | 33 | } |
35 | 34 | ||
36 | RecBody POP3wrapper::fetchBody( const RecMail &mail ) | 35 | RecBody POP3wrapper::fetchBody( const RecMail &mail ) |
37 | { | 36 | { |
38 | int err = MAILPOP3_NO_ERROR; | 37 | int err = MAILPOP3_NO_ERROR; |
39 | char *message; | 38 | char *message; |
40 | size_t length = 0; | 39 | size_t length = 0; |
41 | 40 | ||
42 | login(); | 41 | login(); |
43 | if ( !m_pop3 ) { | 42 | if ( !m_pop3 ) { |
44 | return RecBody(); | 43 | return RecBody(); |
45 | } | 44 | } |
46 | 45 | ||
47 | RecBody body; | 46 | RecBody body; |
48 | mailmessage * msg = 0; | 47 | mailmessage * msg = 0; |
49 | 48 | ||
50 | QFile msg_cache(msgTempName); | 49 | QFile msg_cache(msgTempName); |
51 | 50 | ||
52 | if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) { | 51 | if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) { |
53 | qDebug("Message to large: %i",mail.Msgsize()); | 52 | qDebug("Message to large: %i",mail.Msgsize()); |
54 | return body; | 53 | return body; |
55 | } | 54 | } |
56 | cleanMimeCache(); | 55 | cleanMimeCache(); |
57 | if (mail.getNumber()!=last_msg_id) { | 56 | if (mail.getNumber()!=last_msg_id) { |
58 | if (msg_cache.exists()) { | 57 | if (msg_cache.exists()) { |
59 | msg_cache.remove(); | 58 | msg_cache.remove(); |
60 | } | 59 | } |
61 | msg_cache.open(IO_ReadWrite|IO_Truncate); | 60 | msg_cache.open(IO_ReadWrite|IO_Truncate); |
62 | last_msg_id = mail.getNumber(); | 61 | last_msg_id = mail.getNumber(); |
63 | err = mailpop3_retr( m_pop3, mail.getNumber(), &message, &length ); | 62 | err = mailpop3_retr( m_pop3, mail.getNumber(), &message, &length ); |
64 | if ( err != MAILPOP3_NO_ERROR ) { | 63 | if ( err != MAILPOP3_NO_ERROR ) { |
65 | qDebug( "POP3: error retrieving body with index %i", mail.getNumber() ); | 64 | qDebug( "POP3: error retrieving body with index %i", mail.getNumber() ); |
66 | last_msg_id = 0; | 65 | last_msg_id = 0; |
67 | return RecBody(); | 66 | return RecBody(); |
68 | } | 67 | } |
69 | msg_cache.writeBlock(message,length); | 68 | msg_cache.writeBlock(message,length); |
70 | } else { | 69 | } else { |
71 | QString msg=""; | 70 | QString msg=""; |
72 | msg_cache.open(IO_ReadOnly); | 71 | msg_cache.open(IO_ReadOnly); |
73 | message = new char[4096]; | 72 | message = new char[4096]; |
74 | memset(message,0,4096); | 73 | memset(message,0,4096); |
75 | while (msg_cache.readBlock(message,4095)>0) { | 74 | while (msg_cache.readBlock(message,4095)>0) { |
76 | msg+=message; | 75 | msg+=message; |
77 | memset(message,0,4096); | 76 | memset(message,0,4096); |
78 | } | 77 | } |
79 | delete message; | 78 | delete message; |
80 | message = (char*)malloc(msg.length()+1*sizeof(char)); | 79 | message = (char*)malloc(msg.length()+1*sizeof(char)); |
81 | memset(message,0,msg.length()+1); | 80 | memset(message,0,msg.length()+1); |
82 | memcpy(message,msg.latin1(),msg.length()); | 81 | memcpy(message,msg.latin1(),msg.length()); |
83 | } | 82 | } |
84 | 83 | ||
85 | /* transform to libetpan stuff */ | 84 | /* transform to libetpan stuff */ |
86 | msg = mailmessage_new(); | 85 | msg = mailmessage_new(); |
87 | mailmessage_init(msg, NULL, data_message_driver, 0, strlen(message)); | 86 | mailmessage_init(msg, NULL, data_message_driver, 0, strlen(message)); |
88 | generic_message_t * msg_data; | 87 | generic_message_t * msg_data; |
89 | msg_data = (generic_message_t *)msg->msg_data; | 88 | msg_data = (generic_message_t *)msg->msg_data; |
90 | msg_data->msg_fetched = 1; | 89 | msg_data->msg_fetched = 1; |
91 | msg_data->msg_message = message; | 90 | msg_data->msg_message = message; |
92 | msg_data->msg_length = strlen(message); | 91 | msg_data->msg_length = strlen(message); |
93 | 92 | ||
94 | /* parse the mail */ | 93 | /* parse the mail */ |
95 | body = parseMail(msg); | 94 | body = parseMail(msg); |
96 | 95 | ||
97 | /* clean up */ | 96 | /* clean up */ |
98 | mailmessage_free(msg); | 97 | mailmessage_free(msg); |
99 | free(message); | 98 | free(message); |
100 | 99 | ||
101 | /* finish */ | 100 | /* finish */ |
102 | return body; | 101 | return body; |
103 | } | 102 | } |
104 | 103 | ||
105 | void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | 104 | void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) |
106 | { | 105 | { |
107 | int err = MAILPOP3_NO_ERROR; | 106 | int err = MAILPOP3_NO_ERROR; |
108 | char * header = 0; | 107 | char * header = 0; |
109 | /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */ | 108 | /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */ |
110 | size_t length = 0; | 109 | size_t length = 0; |
111 | carray * messages = 0; | 110 | carray * messages = 0; |
112 | 111 | ||
113 | login(); | 112 | login(); |
114 | if (!m_pop3) return; | 113 | if (!m_pop3) return; |
114 | |||
115 | mailpop3_list( m_pop3, &messages ); | 115 | mailpop3_list( m_pop3, &messages ); |
116 | 116 | ||
117 | for (unsigned int i = 0; i < carray_count(messages);++i) { | 117 | for (unsigned int i = 0; i < carray_count(messages);++i) { |
118 | mailpop3_msg_info *info; | 118 | mailpop3_msg_info *info; |
119 | err = mailpop3_get_msg_info(m_pop3,i+1,&info); | 119 | err = mailpop3_get_msg_info(m_pop3,i+1,&info); |
120 | if (info->msg_deleted) | 120 | if (info->msg_deleted) |
121 | continue; | 121 | continue; |
122 | err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); | 122 | err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); |
123 | if ( err != MAILPOP3_NO_ERROR ) { | 123 | if ( err != MAILPOP3_NO_ERROR ) { |
124 | qDebug( "POP3: error retrieving header msgid: %i", info->msg_index ); | 124 | qDebug( "POP3: error retrieving header msgid: %i", info->msg_index ); |
125 | free(header); | 125 | free(header); |
126 | return; | 126 | return; |
127 | } | 127 | } |
128 | RecMail *mail = parseHeader( header ); | 128 | RecMail *mail = parseHeader( header ); |
129 | mail->setNumber( info->msg_index ); | 129 | mail->setNumber( info->msg_index ); |
130 | mail->setWrapper(this); | 130 | mail->setWrapper(this); |
131 | mail->setMsgsize(info->msg_size); | 131 | mail->setMsgsize(info->msg_size); |
132 | target.append( mail ); | 132 | target.append( mail ); |
133 | free(header); | 133 | free(header); |
134 | } | 134 | } |
135 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(carray_count(messages)-m_pop3->pop3_deleted_count)); | ||
135 | } | 136 | } |
136 | 137 | ||
137 | void POP3wrapper::login() | 138 | void POP3wrapper::login() |
138 | { | 139 | { |
139 | /* we'll hold the line */ | 140 | /* we'll hold the line */ |
140 | if ( m_pop3 != NULL ) return; | 141 | if ( m_pop3 != NULL ) return; |
141 | 142 | ||
142 | const char *server, *user, *pass; | 143 | const char *server, *user, *pass; |
143 | uint16_t port; | 144 | uint16_t port; |
144 | int err = MAILPOP3_NO_ERROR; | 145 | int err = MAILPOP3_NO_ERROR; |
145 | 146 | ||
146 | server = account->getServer().latin1(); | 147 | server = account->getServer().latin1(); |
147 | port = account->getPort().toUInt(); | 148 | port = account->getPort().toUInt(); |
148 | 149 | ||
149 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 150 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
150 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 151 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
151 | login.show(); | 152 | login.show(); |
152 | if ( QDialog::Accepted == login.exec() ) { | 153 | if ( QDialog::Accepted == login.exec() ) { |
153 | // ok | 154 | // ok |
154 | user = strdup( login.getUser().latin1() ); | 155 | user = strdup( login.getUser().latin1() ); |
155 | pass = strdup( login.getPassword().latin1() ); | 156 | pass = strdup( login.getPassword().latin1() ); |
156 | } else { | 157 | } else { |
157 | // cancel | 158 | // cancel |
158 | qDebug( "POP3: Login canceled" ); | 159 | qDebug( "POP3: Login canceled" ); |
159 | return; | 160 | return; |
160 | } | 161 | } |
161 | } else { | 162 | } else { |
162 | user = account->getUser().latin1(); | 163 | user = account->getUser().latin1(); |
163 | pass = account->getPassword().latin1(); | 164 | pass = account->getPassword().latin1(); |
164 | } | 165 | } |
165 | 166 | ||
166 | m_pop3 = mailpop3_new( 200, &pop3_progress ); | 167 | m_pop3 = mailpop3_new( 200, &pop3_progress ); |
167 | 168 | ||
168 | // connect | 169 | // connect |
169 | if (account->getSSL()) { | 170 | if (account->getSSL()) { |
170 | err = mailpop3_ssl_connect( m_pop3, (char*)server, port ); | 171 | err = mailpop3_ssl_connect( m_pop3, (char*)server, port ); |
171 | } else { | 172 | } else { |
172 | err = mailpop3_socket_connect( m_pop3, (char*)server, port ); | 173 | err = mailpop3_socket_connect( m_pop3, (char*)server, port ); |
173 | } | 174 | } |
174 | 175 | ||
175 | if ( err != MAILPOP3_NO_ERROR ) { | 176 | if ( err != MAILPOP3_NO_ERROR ) { |
176 | qDebug( "pop3: error connecting to %s\n reason: %s", server, | 177 | qDebug( "pop3: error connecting to %s\n reason: %s", server, |
177 | m_pop3->pop3_response ); | 178 | m_pop3->pop3_response ); |
178 | mailpop3_free( m_pop3 ); | 179 | mailpop3_free( m_pop3 ); |
179 | m_pop3 = NULL; | 180 | m_pop3 = NULL; |
180 | return; | 181 | return; |
181 | } | 182 | } |
182 | qDebug( "POP3: connected!" ); | 183 | qDebug( "POP3: connected!" ); |
183 | 184 | ||
184 | // login | 185 | // login |
185 | // TODO: decide if apop or plain login should be used | 186 | // TODO: decide if apop or plain login should be used |
186 | err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); | 187 | err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); |
187 | if ( err != MAILPOP3_NO_ERROR ) { | 188 | if ( err != MAILPOP3_NO_ERROR ) { |
188 | qDebug( "pop3: error logging in: %s", m_pop3->pop3_response ); | 189 | qDebug( "pop3: error logging in: %s", m_pop3->pop3_response ); |
189 | logout(); | 190 | logout(); |
190 | return; | 191 | return; |
191 | } | 192 | } |
192 | 193 | ||
193 | qDebug( "POP3: logged in!" ); | 194 | qDebug( "POP3: logged in!" ); |
194 | } | 195 | } |
195 | 196 | ||
196 | void POP3wrapper::logout() | 197 | void POP3wrapper::logout() |
197 | { | 198 | { |
198 | int err = MAILPOP3_NO_ERROR; | 199 | int err = MAILPOP3_NO_ERROR; |
199 | if ( m_pop3 == NULL ) return; | 200 | if ( m_pop3 == NULL ) return; |
200 | err = mailpop3_quit( m_pop3 ); | 201 | err = mailpop3_quit( m_pop3 ); |
201 | mailpop3_free( m_pop3 ); | 202 | mailpop3_free( m_pop3 ); |
202 | m_pop3 = NULL; | 203 | m_pop3 = NULL; |
203 | } | 204 | } |
204 | 205 | ||
205 | 206 | ||
206 | QList<Folder>* POP3wrapper::listFolders() | 207 | QList<Folder>* POP3wrapper::listFolders() |
207 | { | 208 | { |
208 | /* TODO: integrate MH directories | 209 | /* TODO: integrate MH directories |
209 | but not before version 0.1 ;) | 210 | but not before version 0.1 ;) |
210 | */ | 211 | */ |
211 | QList<Folder> * folders = new QList<Folder>(); | 212 | QList<Folder> * folders = new QList<Folder>(); |
212 | folders->setAutoDelete( false ); | 213 | folders->setAutoDelete( false ); |
213 | Folder*inb=new Folder("INBOX","/"); | 214 | Folder*inb=new Folder("INBOX","/"); |
214 | folders->append(inb); | 215 | folders->append(inb); |
215 | return folders; | 216 | return folders; |
216 | } | 217 | } |
217 | 218 | ||
218 | void POP3wrapper::deleteMail(const RecMail&mail) | 219 | void POP3wrapper::deleteMail(const RecMail&mail) |
219 | { | 220 | { |
220 | login(); | 221 | login(); |
221 | if (!m_pop3) return; | 222 | if (!m_pop3) return; |
222 | int err = mailpop3_dele(m_pop3,mail.getNumber()); | 223 | int err = mailpop3_dele(m_pop3,mail.getNumber()); |
223 | if (err != MAILPOP3_NO_ERROR) { | 224 | if (err != MAILPOP3_NO_ERROR) { |
224 | qDebug("error deleting mail"); | 225 | qDebug("error deleting mail"); |
225 | } | 226 | } |
226 | } | 227 | } |
227 | 228 | ||
228 | void POP3wrapper::answeredMail(const RecMail&) | 229 | void POP3wrapper::answeredMail(const RecMail&) |
229 | { | 230 | { |
230 | } | 231 | } |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h index b738cca..7502720 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.h +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h | |||
@@ -1,32 +1,33 @@ | |||
1 | #ifndef __POP3WRAPPER | 1 | #ifndef __POP3WRAPPER |
2 | #define __POP3WRAPPER | 2 | #define __POP3WRAPPER |
3 | 3 | ||
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include "genericwrapper.h" | 5 | #include "genericwrapper.h" |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | 7 | ||
8 | 8 | ||
9 | class POP3wrapper : public Genericwrapper | 9 | class POP3wrapper : public Genericwrapper |
10 | { | 10 | { |
11 | Q_OBJECT | 11 | Q_OBJECT |
12 | 12 | ||
13 | public: | 13 | public: |
14 | POP3wrapper( POP3account *a ); | 14 | POP3wrapper( POP3account *a ); |
15 | virtual ~POP3wrapper(); | 15 | virtual ~POP3wrapper(); |
16 | /* mailbox will be ignored */ | 16 | /* mailbox will be ignored */ |
17 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 17 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
18 | virtual QList<Folder>* listFolders(); | 18 | virtual QList<Folder>* listFolders(); |
19 | 19 | ||
20 | virtual void deleteMail(const RecMail&mail); | 20 | virtual void deleteMail(const RecMail&mail); |
21 | virtual void answeredMail(const RecMail&mail); | 21 | virtual void answeredMail(const RecMail&mail); |
22 | 22 | ||
23 | virtual RecBody fetchBody( const RecMail &mail ); | 23 | virtual RecBody fetchBody( const RecMail &mail ); |
24 | static void pop3_progress( size_t current, size_t maximum ); | 24 | static void pop3_progress( size_t current, size_t maximum ); |
25 | 25 | ||
26 | protected: | 26 | protected: |
27 | void login(); | 27 | void login(); |
28 | void logout(); | 28 | void logout(); |
29 | 29 | POP3account *account; | |
30 | mailpop3 *m_pop3; | ||
30 | }; | 31 | }; |
31 | 32 | ||
32 | #endif | 33 | #endif |
diff --git a/noncore/net/mail/mboxwrapper.cpp b/noncore/net/mail/mboxwrapper.cpp index 6d69263..162a0c9 100644 --- a/noncore/net/mail/mboxwrapper.cpp +++ b/noncore/net/mail/mboxwrapper.cpp | |||
@@ -1,293 +1,367 @@ | |||
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 <libetpan/mailstorage.h> | ||
6 | #include <qdir.h> | 5 | #include <qdir.h> |
7 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | #include <qpe/global.h> | ||
8 | 8 | ||
9 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir) | 9 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir) |
10 | : Genericwrapper(),MBOXPath(mbox_dir) | 10 | : Genericwrapper(),MBOXPath(mbox_dir) |
11 | { | 11 | { |
12 | QDir dir(MBOXPath); | 12 | QDir dir(MBOXPath); |
13 | if (!dir.exists()) { | 13 | if (!dir.exists()) { |
14 | dir.mkdir(MBOXPath); | 14 | dir.mkdir(MBOXPath); |
15 | } | 15 | } |
16 | } | 16 | } |
17 | 17 | ||
18 | MBOXwrapper::~MBOXwrapper() | 18 | MBOXwrapper::~MBOXwrapper() |
19 | { | 19 | { |
20 | } | 20 | } |
21 | 21 | ||
22 | void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) | 22 | void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) |
23 | { | 23 | { |
24 | mailstorage*storage = mailstorage_new(NULL); | 24 | mailstorage*storage = mailstorage_new(NULL); |
25 | QString p = MBOXPath+"/"; | 25 | QString p = MBOXPath+"/"; |
26 | p+=mailbox; | 26 | p+=mailbox; |
27 | char*fname = 0; | 27 | |
28 | 28 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | |
29 | fname = strdup(p.latin1()); | ||
30 | |||
31 | int r = mbox_mailstorage_init(storage,fname,0,0,0); | ||
32 | mailfolder*folder; | 29 | mailfolder*folder; |
33 | folder = mailfolder_new( storage,fname,NULL); | 30 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
34 | r = mailfolder_connect(folder); | 31 | r = mailfolder_connect(folder); |
35 | if (r != MAIL_NO_ERROR) { | 32 | if (r != MAIL_NO_ERROR) { |
36 | qDebug("Error initializing mbox"); | 33 | qDebug("Error initializing mbox"); |
37 | mailfolder_free(folder); | 34 | mailfolder_free(folder); |
38 | mailstorage_free(storage); | 35 | mailstorage_free(storage); |
39 | free(fname); | ||
40 | return; | 36 | return; |
41 | } | 37 | } |
42 | mailmessage_list * env_list = 0; | 38 | mailmessage_list * env_list = 0; |
43 | r = mailsession_get_messages_list(folder->fld_session,&env_list); | 39 | r = mailsession_get_messages_list(folder->fld_session,&env_list); |
44 | if (r != MAIL_NO_ERROR) { | 40 | if (r != MAIL_NO_ERROR) { |
45 | qDebug("Error message list"); | 41 | qDebug("Error message list"); |
46 | mailfolder_free(folder); | 42 | mailfolder_free(folder); |
47 | mailstorage_free(storage); | 43 | mailstorage_free(storage); |
48 | free(fname); | ||
49 | return; | 44 | return; |
50 | } | 45 | } |
51 | r = mailsession_get_envelopes_list(folder->fld_session, env_list); | 46 | r = mailsession_get_envelopes_list(folder->fld_session, env_list); |
52 | if (r != MAIL_NO_ERROR) { | 47 | if (r != MAIL_NO_ERROR) { |
53 | qDebug("Error filling message list"); | 48 | qDebug("Error filling message list"); |
54 | if (env_list) { | 49 | if (env_list) { |
55 | mailmessage_list_free(env_list); | 50 | mailmessage_list_free(env_list); |
56 | } | 51 | } |
57 | mailfolder_free(folder); | 52 | mailfolder_free(folder); |
58 | mailstorage_free(storage); | 53 | mailstorage_free(storage); |
59 | free(fname); | ||
60 | return; | 54 | return; |
61 | } | 55 | } |
62 | mailimf_references * refs; | 56 | mailimf_references * refs; |
63 | 57 | ||
64 | for(int i = 0 ; i < carray_count(env_list->msg_tab) ; ++i) { | 58 | uint32_t i = 0; |
59 | for(; i < carray_count(env_list->msg_tab) ; ++i) { | ||
65 | mailmessage * msg; | 60 | mailmessage * msg; |
66 | QBitArray mFlags(7); | 61 | QBitArray mFlags(7); |
67 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); | 62 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); |
68 | if (msg->msg_fields == NULL) { | 63 | if (msg->msg_fields == NULL) { |
69 | qDebug("could not fetch envelope of message %i", i); | 64 | qDebug("could not fetch envelope of message %i", i); |
70 | continue; | 65 | continue; |
71 | } | 66 | } |
72 | RecMail * mail = new RecMail(); | 67 | RecMail * mail = new RecMail(); |
73 | mail->setWrapper(this); | 68 | mail->setWrapper(this); |
74 | mail_flags * flag_result = 0; | 69 | mail_flags * flag_result = 0; |
75 | r = mailmessage_get_flags(msg,&flag_result); | 70 | r = mailmessage_get_flags(msg,&flag_result); |
76 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { | 71 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { |
77 | mFlags.setBit(FLAG_SEEN); | 72 | mFlags.setBit(FLAG_SEEN); |
78 | } | 73 | } |
79 | mailimf_single_fields single_fields; | 74 | mailimf_single_fields single_fields; |
80 | mailimf_single_fields_init(&single_fields, msg->msg_fields); | 75 | mailimf_single_fields_init(&single_fields, msg->msg_fields); |
81 | mail->setMsgsize(msg->msg_size); | 76 | mail->setMsgsize(msg->msg_size); |
82 | mail->setFlags(mFlags); | 77 | mail->setFlags(mFlags); |
83 | mail->setMbox(mailbox); | 78 | mail->setMbox(mailbox); |
84 | mail->setNumber(i+1); | 79 | mail->setNumber(i+1); |
85 | if (single_fields.fld_subject) | 80 | if (single_fields.fld_subject) |
86 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); | 81 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); |
87 | if (single_fields.fld_from) | 82 | if (single_fields.fld_from) |
88 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); | 83 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); |
89 | if (single_fields.fld_to) | 84 | if (single_fields.fld_to) |
90 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); | 85 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); |
91 | if (single_fields.fld_cc) | 86 | if (single_fields.fld_cc) |
92 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); | 87 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); |
93 | if (single_fields.fld_bcc) | 88 | if (single_fields.fld_bcc) |
94 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); | 89 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); |
95 | if (single_fields.fld_orig_date) | 90 | if (single_fields.fld_orig_date) |
96 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); | 91 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); |
97 | if (single_fields.fld_message_id->mid_value) | 92 | if (single_fields.fld_message_id->mid_value) |
98 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); | 93 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); |
99 | refs = single_fields.fld_references; | 94 | refs = single_fields.fld_references; |
100 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { | 95 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { |
101 | char * text = (char*)refs->mid_list->first->data; | 96 | char * text = (char*)refs->mid_list->first->data; |
102 | mail->setReplyto(QString(text)); | 97 | mail->setReplyto(QString(text)); |
103 | } | 98 | } |
104 | 99 | ||
105 | target.append(mail); | 100 | target.append(mail); |
106 | } | 101 | } |
107 | if (env_list) { | 102 | if (env_list) { |
108 | mailmessage_list_free(env_list); | 103 | mailmessage_list_free(env_list); |
109 | } | 104 | } |
110 | mailfolder_disconnect(folder); | 105 | mailfolder_disconnect(folder); |
111 | mailfolder_free(folder); | 106 | mailfolder_free(folder); |
112 | mailstorage_free(storage); | 107 | mailstorage_free(storage); |
113 | free(fname); | 108 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(i)); |
114 | } | 109 | } |
115 | 110 | ||
116 | QList<Folder>* MBOXwrapper::listFolders() | 111 | QList<Folder>* MBOXwrapper::listFolders() |
117 | { | 112 | { |
118 | QList<Folder> * folders = new QList<Folder>(); | 113 | QList<Folder> * folders = new QList<Folder>(); |
119 | folders->setAutoDelete( false ); | 114 | folders->setAutoDelete( false ); |
120 | QDir dir(MBOXPath); | 115 | QDir dir(MBOXPath); |
121 | if (!dir.exists()) return folders; | 116 | if (!dir.exists()) return folders; |
122 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); | 117 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); |
123 | QStringList entries = dir.entryList(); | 118 | QStringList entries = dir.entryList(); |
124 | QStringList::ConstIterator it = entries.begin(); | 119 | QStringList::ConstIterator it = entries.begin(); |
125 | for (;it!=entries.end();++it) { | 120 | for (;it!=entries.end();++it) { |
126 | Folder*inb=new Folder(*it,"/"); | 121 | Folder*inb=new Folder(*it,"/"); |
127 | folders->append(inb); | 122 | folders->append(inb); |
128 | } | 123 | } |
129 | return folders; | 124 | return folders; |
130 | } | 125 | } |
131 | 126 | ||
132 | void MBOXwrapper::deleteMail(const RecMail&mail) | 127 | void MBOXwrapper::deleteMail(const RecMail&mail) |
133 | { | 128 | { |
134 | mailstorage*storage = mailstorage_new(NULL); | 129 | mailstorage*storage = mailstorage_new(NULL); |
135 | QString p = MBOXPath+"/"; | 130 | QString p = MBOXPath+"/"; |
136 | p+=mail.getMbox(); | 131 | p+=mail.getMbox(); |
137 | mailmessage * msg; | 132 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
138 | int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0); | ||
139 | mailfolder*folder; | 133 | mailfolder*folder; |
140 | folder = mailfolder_new( storage,strdup(p.latin1()),NULL); | 134 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
141 | r = mailfolder_connect(folder); | 135 | r = mailfolder_connect(folder); |
142 | if (r != MAIL_NO_ERROR) { | 136 | if (r != MAIL_NO_ERROR) { |
143 | qDebug("Error initializing mbox"); | 137 | qDebug("Error initializing mbox"); |
144 | mailfolder_free(folder); | 138 | mailfolder_free(folder); |
145 | mailstorage_free(storage); | 139 | mailstorage_free(storage); |
146 | return; | 140 | return; |
147 | } | 141 | } |
148 | r = mailsession_remove_message(folder->fld_session,mail.getNumber()); | 142 | r = mailsession_remove_message(folder->fld_session,mail.getNumber()); |
149 | if (r != MAIL_NO_ERROR) { | 143 | if (r != MAIL_NO_ERROR) { |
150 | qDebug("error deleting mail"); | 144 | qDebug("error deleting mail"); |
151 | } | 145 | } |
152 | mailfolder_free(folder); | 146 | mailfolder_free(folder); |
153 | mailstorage_free(storage); | 147 | mailstorage_free(storage); |
154 | } | 148 | } |
155 | 149 | ||
156 | void MBOXwrapper::answeredMail(const RecMail&) | 150 | void MBOXwrapper::answeredMail(const RecMail&) |
157 | { | 151 | { |
158 | } | 152 | } |
159 | 153 | ||
160 | RecBody MBOXwrapper::fetchBody( const RecMail &mail ) | 154 | RecBody MBOXwrapper::fetchBody( const RecMail &mail ) |
161 | { | 155 | { |
162 | RecBody body; | 156 | RecBody body; |
163 | mailstorage*storage = mailstorage_new(NULL); | 157 | mailstorage*storage = mailstorage_new(NULL); |
164 | QString p = MBOXPath+"/"; | 158 | QString p = MBOXPath+"/"; |
165 | p+=mail.getMbox(); | 159 | p+=mail.getMbox(); |
166 | mailmessage * msg; | 160 | mailmessage * msg; |
167 | char*data=0; | 161 | char*data=0; |
168 | size_t size; | 162 | size_t size; |
169 | 163 | ||
170 | int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0); | 164 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
171 | mailfolder*folder; | 165 | mailfolder*folder; |
172 | folder = mailfolder_new( storage,strdup(p.latin1()),NULL); | 166 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
173 | r = mailfolder_connect(folder); | 167 | r = mailfolder_connect(folder); |
174 | if (r != MAIL_NO_ERROR) { | 168 | if (r != MAIL_NO_ERROR) { |
175 | qDebug("Error initializing mbox"); | 169 | qDebug("Error initializing mbox"); |
176 | mailfolder_free(folder); | 170 | mailfolder_free(folder); |
177 | mailstorage_free(storage); | 171 | mailstorage_free(storage); |
178 | return body; | 172 | return body; |
179 | } | 173 | } |
180 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); | 174 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); |
181 | if (r != MAIL_NO_ERROR) { | 175 | if (r != MAIL_NO_ERROR) { |
182 | qDebug("Error fetching mail %i",mail.getNumber()); | 176 | qDebug("Error fetching mail %i",mail.getNumber()); |
183 | mailfolder_free(folder); | 177 | mailfolder_free(folder); |
184 | mailstorage_free(storage); | 178 | mailstorage_free(storage); |
185 | return body; | 179 | return body; |
186 | } | 180 | } |
187 | r = mailmessage_fetch(msg,&data,&size); | 181 | r = mailmessage_fetch(msg,&data,&size); |
188 | if (r != MAIL_NO_ERROR) { | 182 | if (r != MAIL_NO_ERROR) { |
189 | qDebug("Error fetching mail %i",mail.getNumber()); | 183 | qDebug("Error fetching mail %i",mail.getNumber()); |
190 | mailfolder_free(folder); | 184 | mailfolder_free(folder); |
191 | mailstorage_free(storage); | 185 | mailstorage_free(storage); |
192 | mailmessage_free(msg); | 186 | mailmessage_free(msg); |
193 | return body; | 187 | return body; |
194 | } | 188 | } |
195 | body = parseMail(msg); | 189 | body = parseMail(msg); |
196 | mailmessage_fetch_result_free(msg,data); | 190 | mailmessage_fetch_result_free(msg,data); |
197 | mailfolder_free(folder); | 191 | mailfolder_free(folder); |
198 | mailstorage_free(storage); | 192 | mailstorage_free(storage); |
199 | 193 | ||
200 | return body; | 194 | return body; |
201 | } | 195 | } |
202 | 196 | ||
203 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) | 197 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) |
204 | { | 198 | { |
205 | qDebug("MBOX %i von %i",current,maximum); | 199 | qDebug("MBOX %i von %i",current,maximum); |
206 | } | 200 | } |
207 | 201 | ||
208 | void MBOXwrapper::createFolder(const QString&) | 202 | int MBOXwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool ) |
209 | { | 203 | { |
204 | QString p = MBOXPath+"/"; | ||
205 | p+=folder; | ||
206 | QFileInfo fi(p); | ||
207 | if (fi.exists()) { | ||
208 | Global::statusMessage(tr("Mailbox exists.")); | ||
209 | return 0; | ||
210 | } | ||
211 | mailmbox_folder*f = 0; | ||
212 | if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { | ||
213 | Global::statusMessage(tr("Error init folder")); | ||
214 | return 0; | ||
215 | } | ||
216 | if (f) mailmbox_done(f); | ||
217 | return 1; | ||
210 | } | 218 | } |
211 | 219 | ||
212 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 220 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
213 | { | 221 | { |
214 | QString p = MBOXPath+"/"; | 222 | QString p = MBOXPath+"/"; |
215 | p+=folder; | 223 | p+=folder; |
216 | mailmbox_folder*f = 0; | 224 | mailmbox_folder*f = 0; |
217 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 225 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
218 | if (r != MAIL_NO_ERROR) { | 226 | if (r != MAIL_NO_ERROR) { |
219 | qDebug("Error init folder"); | 227 | Global::statusMessage(tr("Error init folder")); |
220 | return; | 228 | return; |
221 | } | 229 | } |
222 | r = mailmbox_append_message(f,msg,length); | 230 | r = mailmbox_append_message(f,msg,length); |
223 | if (r != MAIL_NO_ERROR) { | 231 | if (r != MAIL_NO_ERROR) { |
224 | qDebug("Error writing message folder"); | 232 | Global::statusMessage(tr("Error writing to message folder")); |
225 | } | 233 | } |
226 | mailmbox_done(f); | 234 | mailmbox_done(f); |
227 | } | 235 | } |
228 | 236 | ||
229 | void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) | 237 | void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) |
230 | { | 238 | { |
231 | RecBody body; | 239 | RecBody body; |
232 | mailstorage*storage = mailstorage_new(NULL); | 240 | mailstorage*storage = mailstorage_new(NULL); |
233 | QString p = MBOXPath+"/"; | 241 | QString p = MBOXPath+"/"; |
234 | p+=mail.getMbox(); | 242 | p+=mail.getMbox(); |
235 | mailmessage * msg; | 243 | mailmessage * msg; |
236 | char*data=0; | 244 | char*data=0; |
237 | size_t size; | 245 | size_t size; |
238 | 246 | ||
239 | int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0); | 247 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
240 | mailfolder*folder; | 248 | mailfolder*folder; |
241 | folder = mailfolder_new( storage,strdup(p.latin1()),NULL); | 249 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
242 | r = mailfolder_connect(folder); | 250 | r = mailfolder_connect(folder); |
243 | if (r != MAIL_NO_ERROR) { | 251 | if (r != MAIL_NO_ERROR) { |
244 | qDebug("Error initializing mbox"); | 252 | Global::statusMessage(tr("Error initializing mbox")); |
245 | mailfolder_free(folder); | 253 | mailfolder_free(folder); |
246 | mailstorage_free(storage); | 254 | mailstorage_free(storage); |
247 | return; | 255 | return; |
248 | } | 256 | } |
249 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); | 257 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); |
250 | if (r != MAIL_NO_ERROR) { | 258 | if (r != MAIL_NO_ERROR) { |
251 | qDebug("Error fetching mail %i",mail.getNumber()); | 259 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
252 | mailfolder_free(folder); | 260 | mailfolder_free(folder); |
253 | mailstorage_free(storage); | 261 | mailstorage_free(storage); |
254 | return; | 262 | return; |
255 | } | 263 | } |
256 | r = mailmessage_fetch(msg,&data,&size); | 264 | r = mailmessage_fetch(msg,&data,&size); |
257 | if (r != MAIL_NO_ERROR) { | 265 | if (r != MAIL_NO_ERROR) { |
258 | qDebug("Error fetching mail %i",mail.getNumber()); | 266 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
259 | mailfolder_free(folder); | 267 | mailfolder_free(folder); |
260 | mailstorage_free(storage); | 268 | mailstorage_free(storage); |
261 | mailmessage_free(msg); | 269 | mailmessage_free(msg); |
262 | return; | 270 | return; |
263 | } | 271 | } |
264 | *target = data; | 272 | *target = data; |
265 | *length = size; | 273 | *length = size; |
266 | mailfolder_free(folder); | 274 | mailfolder_free(folder); |
267 | mailstorage_free(storage); | 275 | mailstorage_free(storage); |
268 | mailmessage_free(msg); | 276 | mailmessage_free(msg); |
269 | } | 277 | } |
270 | 278 | ||
271 | void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) | 279 | void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) |
272 | { | 280 | { |
273 | QString p = MBOXPath+"/"; | 281 | QString p = MBOXPath+"/"; |
274 | p+=mailbox; | 282 | p+=mailbox; |
275 | mailmbox_folder*f = 0; | 283 | mailmbox_folder*f = 0; |
276 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 284 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
277 | if (r != MAIL_NO_ERROR) { | 285 | if (r != MAIL_NO_ERROR) { |
278 | qDebug("Error init folder"); | 286 | qDebug("Error init folder"); |
279 | return; | 287 | return; |
280 | } | 288 | } |
289 | deleteMails(f,target); | ||
290 | mailmbox_done(f); | ||
291 | } | ||
292 | |||
293 | void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) | ||
294 | { | ||
295 | if (!f) return; | ||
296 | int r; | ||
281 | for (unsigned int i=0; i < target.count();++i) { | 297 | for (unsigned int i=0; i < target.count();++i) { |
282 | r = mailmbox_delete_msg(f,target.at(i)->getNumber()); | 298 | r = mailmbox_delete_msg(f,target.at(i)->getNumber()); |
283 | if (r!=MAILMBOX_NO_ERROR) { | 299 | if (r!=MAILMBOX_NO_ERROR) { |
284 | qDebug("error delete mail"); | 300 | qDebug("error delete mail"); |
285 | } | 301 | } |
286 | } | 302 | } |
287 | r = mailmbox_expunge(f); | 303 | r = mailmbox_expunge(f); |
288 | if (r != MAILMBOX_NO_ERROR) { | 304 | if (r != MAILMBOX_NO_ERROR) { |
289 | qDebug("error expunge mailbox"); | 305 | qDebug("error expunge mailbox"); |
290 | } | 306 | } |
291 | mailmbox_done(f); | 307 | } |
308 | |||
309 | int MBOXwrapper::deleteAllMail(const Folder*tfolder) | ||
310 | { | ||
311 | if (!tfolder) return 0; | ||
312 | QString p = MBOXPath+tfolder->getDisplayName(); | ||
313 | int res = 1; | ||
314 | |||
315 | mailfolder*folder = 0; | ||
316 | mailmessage_list*l=0; | ||
317 | mailstorage*storage = mailstorage_new(NULL); | ||
318 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | ||
319 | if (r != MAIL_NO_ERROR) { | ||
320 | Global::statusMessage(tr("Error initializing mbox")); | ||
321 | res = 0; | ||
322 | } | ||
323 | if (res) { | ||
324 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | ||
325 | r = mailfolder_connect(folder); | ||
326 | if (r != MAIL_NO_ERROR) { | ||
327 | Global::statusMessage(tr("Error initializing mbox")); | ||
328 | res = 0; | ||
329 | } | ||
330 | } | ||
331 | if (res) { | ||
332 | r = mailsession_get_messages_list(folder->fld_session,&l); | ||
333 | if (r != MAIL_NO_ERROR) { | ||
334 | qDebug("Error message list"); | ||
335 | res=0; | ||
336 | } | ||
337 | } | ||
338 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { | ||
339 | r = mailsession_remove_message(folder->fld_session,i+1); | ||
340 | if (r != MAIL_NO_ERROR) { | ||
341 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | ||
342 | res = 0; | ||
343 | break; | ||
344 | } | ||
345 | } | ||
346 | if (l) mailmessage_list_free(l); | ||
347 | if (folder) mailfolder_free(folder); | ||
348 | if (storage) mailstorage_free(storage); | ||
349 | return res; | ||
350 | } | ||
351 | |||
352 | int MBOXwrapper::deleteMbox(const Folder*tfolder) | ||
353 | { | ||
354 | if (!tfolder) return 0; | ||
355 | QString p = MBOXPath+tfolder->getDisplayName(); | ||
356 | QFile fi(p); | ||
357 | if (!fi.exists()) { | ||
358 | Global::statusMessage(tr("Mailbox doesn't exist.")); | ||
359 | return 0; | ||
360 | } | ||
361 | if (!fi.remove()) { | ||
362 | Global::statusMessage(tr("Error deleting Mailbox.")); | ||
363 | return 0; | ||
364 | } | ||
365 | return 1; | ||
292 | } | 366 | } |
293 | 367 | ||
diff --git a/noncore/net/mail/mboxwrapper.h b/noncore/net/mail/mboxwrapper.h index f64ad52..226a544 100644 --- a/noncore/net/mail/mboxwrapper.h +++ b/noncore/net/mail/mboxwrapper.h | |||
@@ -1,35 +1,41 @@ | |||
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 | 6 | ||
7 | class RecMail; | 7 | class RecMail; |
8 | class RecBody; | 8 | class RecBody; |
9 | struct mailmbox_folder; | ||
9 | 10 | ||
10 | class MBOXwrapper : public Genericwrapper | 11 | class MBOXwrapper : public Genericwrapper |
11 | { | 12 | { |
12 | Q_OBJECT | 13 | Q_OBJECT |
13 | public: | 14 | public: |
14 | MBOXwrapper(const QString & dir); | 15 | MBOXwrapper(const QString & dir); |
15 | virtual ~MBOXwrapper(); | 16 | virtual ~MBOXwrapper(); |
16 | 17 | ||
17 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 18 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
18 | virtual QList<Folder>* listFolders(); | 19 | virtual QList<Folder>* listFolders(); |
19 | 20 | ||
20 | virtual void deleteMail(const RecMail&mail); | 21 | virtual void deleteMail(const RecMail&mail); |
21 | virtual void answeredMail(const RecMail&mail); | 22 | virtual void answeredMail(const RecMail&mail); |
22 | virtual void createFolder(const QString&aFolder); | 23 | |
24 | virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); | ||
25 | virtual int deleteMbox(const Folder*); | ||
26 | |||
23 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 27 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
24 | 28 | ||
25 | virtual RecBody fetchBody( const RecMail &mail ); | 29 | virtual RecBody fetchBody( const RecMail &mail ); |
26 | static void mbox_progress( size_t current, size_t maximum ); | 30 | static void mbox_progress( size_t current, size_t maximum ); |
27 | 31 | ||
28 | virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); | 32 | virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); |
29 | virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); | 33 | virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); |
34 | virtual int deleteAllMail(const Folder*); | ||
30 | 35 | ||
31 | protected: | 36 | protected: |
37 | static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); | ||
32 | QString MBOXPath; | 38 | QString MBOXPath; |
33 | }; | 39 | }; |
34 | 40 | ||
35 | #endif | 41 | #endif |
diff --git a/noncore/net/mail/newmaildir.cpp b/noncore/net/mail/newmaildir.cpp index 3fc66f4..ab0d4e3 100644 --- a/noncore/net/mail/newmaildir.cpp +++ b/noncore/net/mail/newmaildir.cpp | |||
@@ -1,34 +1,38 @@ | |||
1 | #include "newmaildir.h" | 1 | #include "newmaildir.h" |
2 | #include <qdialog.h> | 2 | #include <qdialog.h> |
3 | #include <qvariant.h> | 3 | #include <qvariant.h> |
4 | #include <qlineedit.h> | 4 | #include <qlineedit.h> |
5 | #include <qcheckbox.h> | 5 | #include <qcheckbox.h> |
6 | 6 | ||
7 | Newmdirdlg::Newmdirdlg( QWidget* parent, const char* name) | 7 | Newmdirdlg::Newmdirdlg( QWidget* parent, const char* name,bool no_sub) |
8 | : Newmdirdlgui(parent,name,true),ndir(""),possible_subs(false) | 8 | : Newmdirdlgui(parent,name,true),ndir(""),possible_subs(false) |
9 | { | 9 | { |
10 | if (no_sub) { | ||
11 | subdirsPossibleBox->setChecked(false); | ||
12 | subdirsPossibleBox->hide(); | ||
13 | } | ||
10 | } | 14 | } |
11 | 15 | ||
12 | Newmdirdlg::~Newmdirdlg() | 16 | Newmdirdlg::~Newmdirdlg() |
13 | { | 17 | { |
14 | } | 18 | } |
15 | 19 | ||
16 | void Newmdirdlg::accept() | 20 | void Newmdirdlg::accept() |
17 | { | 21 | { |
18 | ndir = dirnameEdit->text(); | 22 | ndir = dirnameEdit->text(); |
19 | possible_subs = subdirsPossibleBox->isChecked(); | 23 | possible_subs = subdirsPossibleBox->isChecked(); |
20 | if (ndir.isEmpty()) { | 24 | if (ndir.isEmpty()) { |
21 | return; | 25 | return; |
22 | } | 26 | } |
23 | Newmdirdlgui::accept(); | 27 | Newmdirdlgui::accept(); |
24 | } | 28 | } |
25 | 29 | ||
26 | const QString&Newmdirdlg::Newdir()const | 30 | const QString&Newmdirdlg::Newdir()const |
27 | { | 31 | { |
28 | return ndir; | 32 | return ndir; |
29 | } | 33 | } |
30 | 34 | ||
31 | const bool Newmdirdlg::subpossible()const | 35 | const bool Newmdirdlg::subpossible()const |
32 | { | 36 | { |
33 | return possible_subs; | 37 | return possible_subs; |
34 | } | 38 | } |
diff --git a/noncore/net/mail/newmaildir.h b/noncore/net/mail/newmaildir.h index 1eb904e..496eaf4 100644 --- a/noncore/net/mail/newmaildir.h +++ b/noncore/net/mail/newmaildir.h | |||
@@ -1,20 +1,20 @@ | |||
1 | #include "newmaildirui.h" | 1 | #include "newmaildirui.h" |
2 | #include <qvariant.h> | 2 | #include <qvariant.h> |
3 | 3 | ||
4 | class Newmdirdlg : public Newmdirdlgui | 4 | class Newmdirdlg : public Newmdirdlgui |
5 | { | 5 | { |
6 | Q_OBJECT | 6 | Q_OBJECT |
7 | public: | 7 | public: |
8 | Newmdirdlg( QWidget* parent = 0, const char* name = 0); | 8 | Newmdirdlg( QWidget* parent = 0, const char* name = 0,bool no_sub=false); |
9 | ~Newmdirdlg(); | 9 | ~Newmdirdlg(); |
10 | 10 | ||
11 | const QString&Newdir()const; | 11 | const QString&Newdir()const; |
12 | const bool subpossible()const; | 12 | const bool subpossible()const; |
13 | 13 | ||
14 | protected slots: | 14 | protected slots: |
15 | virtual void accept(); | 15 | virtual void accept(); |
16 | 16 | ||
17 | protected: | 17 | protected: |
18 | QString ndir; | 18 | QString ndir; |
19 | bool possible_subs; | 19 | bool possible_subs; |
20 | }; | 20 | }; |
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp index efd83ba..b85fbf6 100644 --- a/noncore/net/mail/pop3wrapper.cpp +++ b/noncore/net/mail/pop3wrapper.cpp | |||
@@ -1,230 +1,231 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include "pop3wrapper.h" | 2 | #include "pop3wrapper.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | #include "logindialog.h" | 4 | #include "logindialog.h" |
5 | #include <libetpan/mailpop3.h> | 5 | #include <libetpan/libetpan.h> |
6 | #include <libetpan/mailmime.h> | 6 | #include <qpe/global.h> |
7 | #include <libetpan/data_message_driver.h> | ||
8 | #include <qfile.h> | 7 | #include <qfile.h> |
9 | 8 | ||
10 | /* we don't fetch messages larger than 5 MB */ | 9 | /* we don't fetch messages larger than 5 MB */ |
11 | #define HARD_MSG_SIZE_LIMIT 5242880 | 10 | #define HARD_MSG_SIZE_LIMIT 5242880 |
12 | 11 | ||
13 | POP3wrapper::POP3wrapper( POP3account *a ) | 12 | POP3wrapper::POP3wrapper( POP3account *a ) |
14 | : Genericwrapper() | 13 | : Genericwrapper() |
15 | { | 14 | { |
16 | account = a; | 15 | account = a; |
17 | m_pop3 = NULL; | 16 | m_pop3 = NULL; |
18 | msgTempName = a->getFileName()+"_msg_cache"; | 17 | msgTempName = a->getFileName()+"_msg_cache"; |
19 | last_msg_id = 0; | 18 | last_msg_id = 0; |
20 | } | 19 | } |
21 | 20 | ||
22 | POP3wrapper::~POP3wrapper() | 21 | POP3wrapper::~POP3wrapper() |
23 | { | 22 | { |
24 | logout(); | 23 | logout(); |
25 | QFile msg_cache(msgTempName); | 24 | QFile msg_cache(msgTempName); |
26 | if (msg_cache.exists()) { | 25 | if (msg_cache.exists()) { |
27 | msg_cache.remove(); | 26 | msg_cache.remove(); |
28 | } | 27 | } |
29 | } | 28 | } |
30 | 29 | ||
31 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) | 30 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) |
32 | { | 31 | { |
33 | //qDebug( "POP3: %i of %i", current, maximum ); | 32 | //qDebug( "POP3: %i of %i", current, maximum ); |
34 | } | 33 | } |
35 | 34 | ||
36 | RecBody POP3wrapper::fetchBody( const RecMail &mail ) | 35 | RecBody POP3wrapper::fetchBody( const RecMail &mail ) |
37 | { | 36 | { |
38 | int err = MAILPOP3_NO_ERROR; | 37 | int err = MAILPOP3_NO_ERROR; |
39 | char *message; | 38 | char *message; |
40 | size_t length = 0; | 39 | size_t length = 0; |
41 | 40 | ||
42 | login(); | 41 | login(); |
43 | if ( !m_pop3 ) { | 42 | if ( !m_pop3 ) { |
44 | return RecBody(); | 43 | return RecBody(); |
45 | } | 44 | } |
46 | 45 | ||
47 | RecBody body; | 46 | RecBody body; |
48 | mailmessage * msg = 0; | 47 | mailmessage * msg = 0; |
49 | 48 | ||
50 | QFile msg_cache(msgTempName); | 49 | QFile msg_cache(msgTempName); |
51 | 50 | ||
52 | if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) { | 51 | if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) { |
53 | qDebug("Message to large: %i",mail.Msgsize()); | 52 | qDebug("Message to large: %i",mail.Msgsize()); |
54 | return body; | 53 | return body; |
55 | } | 54 | } |
56 | cleanMimeCache(); | 55 | cleanMimeCache(); |
57 | if (mail.getNumber()!=last_msg_id) { | 56 | if (mail.getNumber()!=last_msg_id) { |
58 | if (msg_cache.exists()) { | 57 | if (msg_cache.exists()) { |
59 | msg_cache.remove(); | 58 | msg_cache.remove(); |
60 | } | 59 | } |
61 | msg_cache.open(IO_ReadWrite|IO_Truncate); | 60 | msg_cache.open(IO_ReadWrite|IO_Truncate); |
62 | last_msg_id = mail.getNumber(); | 61 | last_msg_id = mail.getNumber(); |
63 | err = mailpop3_retr( m_pop3, mail.getNumber(), &message, &length ); | 62 | err = mailpop3_retr( m_pop3, mail.getNumber(), &message, &length ); |
64 | if ( err != MAILPOP3_NO_ERROR ) { | 63 | if ( err != MAILPOP3_NO_ERROR ) { |
65 | qDebug( "POP3: error retrieving body with index %i", mail.getNumber() ); | 64 | qDebug( "POP3: error retrieving body with index %i", mail.getNumber() ); |
66 | last_msg_id = 0; | 65 | last_msg_id = 0; |
67 | return RecBody(); | 66 | return RecBody(); |
68 | } | 67 | } |
69 | msg_cache.writeBlock(message,length); | 68 | msg_cache.writeBlock(message,length); |
70 | } else { | 69 | } else { |
71 | QString msg=""; | 70 | QString msg=""; |
72 | msg_cache.open(IO_ReadOnly); | 71 | msg_cache.open(IO_ReadOnly); |
73 | message = new char[4096]; | 72 | message = new char[4096]; |
74 | memset(message,0,4096); | 73 | memset(message,0,4096); |
75 | while (msg_cache.readBlock(message,4095)>0) { | 74 | while (msg_cache.readBlock(message,4095)>0) { |
76 | msg+=message; | 75 | msg+=message; |
77 | memset(message,0,4096); | 76 | memset(message,0,4096); |
78 | } | 77 | } |
79 | delete message; | 78 | delete message; |
80 | message = (char*)malloc(msg.length()+1*sizeof(char)); | 79 | message = (char*)malloc(msg.length()+1*sizeof(char)); |
81 | memset(message,0,msg.length()+1); | 80 | memset(message,0,msg.length()+1); |
82 | memcpy(message,msg.latin1(),msg.length()); | 81 | memcpy(message,msg.latin1(),msg.length()); |
83 | } | 82 | } |
84 | 83 | ||
85 | /* transform to libetpan stuff */ | 84 | /* transform to libetpan stuff */ |
86 | msg = mailmessage_new(); | 85 | msg = mailmessage_new(); |
87 | mailmessage_init(msg, NULL, data_message_driver, 0, strlen(message)); | 86 | mailmessage_init(msg, NULL, data_message_driver, 0, strlen(message)); |
88 | generic_message_t * msg_data; | 87 | generic_message_t * msg_data; |
89 | msg_data = (generic_message_t *)msg->msg_data; | 88 | msg_data = (generic_message_t *)msg->msg_data; |
90 | msg_data->msg_fetched = 1; | 89 | msg_data->msg_fetched = 1; |
91 | msg_data->msg_message = message; | 90 | msg_data->msg_message = message; |
92 | msg_data->msg_length = strlen(message); | 91 | msg_data->msg_length = strlen(message); |
93 | 92 | ||
94 | /* parse the mail */ | 93 | /* parse the mail */ |
95 | body = parseMail(msg); | 94 | body = parseMail(msg); |
96 | 95 | ||
97 | /* clean up */ | 96 | /* clean up */ |
98 | mailmessage_free(msg); | 97 | mailmessage_free(msg); |
99 | free(message); | 98 | free(message); |
100 | 99 | ||
101 | /* finish */ | 100 | /* finish */ |
102 | return body; | 101 | return body; |
103 | } | 102 | } |
104 | 103 | ||
105 | void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | 104 | void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) |
106 | { | 105 | { |
107 | int err = MAILPOP3_NO_ERROR; | 106 | int err = MAILPOP3_NO_ERROR; |
108 | char * header = 0; | 107 | char * header = 0; |
109 | /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */ | 108 | /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */ |
110 | size_t length = 0; | 109 | size_t length = 0; |
111 | carray * messages = 0; | 110 | carray * messages = 0; |
112 | 111 | ||
113 | login(); | 112 | login(); |
114 | if (!m_pop3) return; | 113 | if (!m_pop3) return; |
114 | |||
115 | mailpop3_list( m_pop3, &messages ); | 115 | mailpop3_list( m_pop3, &messages ); |
116 | 116 | ||
117 | for (unsigned int i = 0; i < carray_count(messages);++i) { | 117 | for (unsigned int i = 0; i < carray_count(messages);++i) { |
118 | mailpop3_msg_info *info; | 118 | mailpop3_msg_info *info; |
119 | err = mailpop3_get_msg_info(m_pop3,i+1,&info); | 119 | err = mailpop3_get_msg_info(m_pop3,i+1,&info); |
120 | if (info->msg_deleted) | 120 | if (info->msg_deleted) |
121 | continue; | 121 | continue; |
122 | err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); | 122 | err = mailpop3_header( m_pop3, info->msg_index, &header, &length ); |
123 | if ( err != MAILPOP3_NO_ERROR ) { | 123 | if ( err != MAILPOP3_NO_ERROR ) { |
124 | qDebug( "POP3: error retrieving header msgid: %i", info->msg_index ); | 124 | qDebug( "POP3: error retrieving header msgid: %i", info->msg_index ); |
125 | free(header); | 125 | free(header); |
126 | return; | 126 | return; |
127 | } | 127 | } |
128 | RecMail *mail = parseHeader( header ); | 128 | RecMail *mail = parseHeader( header ); |
129 | mail->setNumber( info->msg_index ); | 129 | mail->setNumber( info->msg_index ); |
130 | mail->setWrapper(this); | 130 | mail->setWrapper(this); |
131 | mail->setMsgsize(info->msg_size); | 131 | mail->setMsgsize(info->msg_size); |
132 | target.append( mail ); | 132 | target.append( mail ); |
133 | free(header); | 133 | free(header); |
134 | } | 134 | } |
135 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(carray_count(messages)-m_pop3->pop3_deleted_count)); | ||
135 | } | 136 | } |
136 | 137 | ||
137 | void POP3wrapper::login() | 138 | void POP3wrapper::login() |
138 | { | 139 | { |
139 | /* we'll hold the line */ | 140 | /* we'll hold the line */ |
140 | if ( m_pop3 != NULL ) return; | 141 | if ( m_pop3 != NULL ) return; |
141 | 142 | ||
142 | const char *server, *user, *pass; | 143 | const char *server, *user, *pass; |
143 | uint16_t port; | 144 | uint16_t port; |
144 | int err = MAILPOP3_NO_ERROR; | 145 | int err = MAILPOP3_NO_ERROR; |
145 | 146 | ||
146 | server = account->getServer().latin1(); | 147 | server = account->getServer().latin1(); |
147 | port = account->getPort().toUInt(); | 148 | port = account->getPort().toUInt(); |
148 | 149 | ||
149 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 150 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
150 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 151 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
151 | login.show(); | 152 | login.show(); |
152 | if ( QDialog::Accepted == login.exec() ) { | 153 | if ( QDialog::Accepted == login.exec() ) { |
153 | // ok | 154 | // ok |
154 | user = strdup( login.getUser().latin1() ); | 155 | user = strdup( login.getUser().latin1() ); |
155 | pass = strdup( login.getPassword().latin1() ); | 156 | pass = strdup( login.getPassword().latin1() ); |
156 | } else { | 157 | } else { |
157 | // cancel | 158 | // cancel |
158 | qDebug( "POP3: Login canceled" ); | 159 | qDebug( "POP3: Login canceled" ); |
159 | return; | 160 | return; |
160 | } | 161 | } |
161 | } else { | 162 | } else { |
162 | user = account->getUser().latin1(); | 163 | user = account->getUser().latin1(); |
163 | pass = account->getPassword().latin1(); | 164 | pass = account->getPassword().latin1(); |
164 | } | 165 | } |
165 | 166 | ||
166 | m_pop3 = mailpop3_new( 200, &pop3_progress ); | 167 | m_pop3 = mailpop3_new( 200, &pop3_progress ); |
167 | 168 | ||
168 | // connect | 169 | // connect |
169 | if (account->getSSL()) { | 170 | if (account->getSSL()) { |
170 | err = mailpop3_ssl_connect( m_pop3, (char*)server, port ); | 171 | err = mailpop3_ssl_connect( m_pop3, (char*)server, port ); |
171 | } else { | 172 | } else { |
172 | err = mailpop3_socket_connect( m_pop3, (char*)server, port ); | 173 | err = mailpop3_socket_connect( m_pop3, (char*)server, port ); |
173 | } | 174 | } |
174 | 175 | ||
175 | if ( err != MAILPOP3_NO_ERROR ) { | 176 | if ( err != MAILPOP3_NO_ERROR ) { |
176 | qDebug( "pop3: error connecting to %s\n reason: %s", server, | 177 | qDebug( "pop3: error connecting to %s\n reason: %s", server, |
177 | m_pop3->pop3_response ); | 178 | m_pop3->pop3_response ); |
178 | mailpop3_free( m_pop3 ); | 179 | mailpop3_free( m_pop3 ); |
179 | m_pop3 = NULL; | 180 | m_pop3 = NULL; |
180 | return; | 181 | return; |
181 | } | 182 | } |
182 | qDebug( "POP3: connected!" ); | 183 | qDebug( "POP3: connected!" ); |
183 | 184 | ||
184 | // login | 185 | // login |
185 | // TODO: decide if apop or plain login should be used | 186 | // TODO: decide if apop or plain login should be used |
186 | err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); | 187 | err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); |
187 | if ( err != MAILPOP3_NO_ERROR ) { | 188 | if ( err != MAILPOP3_NO_ERROR ) { |
188 | qDebug( "pop3: error logging in: %s", m_pop3->pop3_response ); | 189 | qDebug( "pop3: error logging in: %s", m_pop3->pop3_response ); |
189 | logout(); | 190 | logout(); |
190 | return; | 191 | return; |
191 | } | 192 | } |
192 | 193 | ||
193 | qDebug( "POP3: logged in!" ); | 194 | qDebug( "POP3: logged in!" ); |
194 | } | 195 | } |
195 | 196 | ||
196 | void POP3wrapper::logout() | 197 | void POP3wrapper::logout() |
197 | { | 198 | { |
198 | int err = MAILPOP3_NO_ERROR; | 199 | int err = MAILPOP3_NO_ERROR; |
199 | if ( m_pop3 == NULL ) return; | 200 | if ( m_pop3 == NULL ) return; |
200 | err = mailpop3_quit( m_pop3 ); | 201 | err = mailpop3_quit( m_pop3 ); |
201 | mailpop3_free( m_pop3 ); | 202 | mailpop3_free( m_pop3 ); |
202 | m_pop3 = NULL; | 203 | m_pop3 = NULL; |
203 | } | 204 | } |
204 | 205 | ||
205 | 206 | ||
206 | QList<Folder>* POP3wrapper::listFolders() | 207 | QList<Folder>* POP3wrapper::listFolders() |
207 | { | 208 | { |
208 | /* TODO: integrate MH directories | 209 | /* TODO: integrate MH directories |
209 | but not before version 0.1 ;) | 210 | but not before version 0.1 ;) |
210 | */ | 211 | */ |
211 | QList<Folder> * folders = new QList<Folder>(); | 212 | QList<Folder> * folders = new QList<Folder>(); |
212 | folders->setAutoDelete( false ); | 213 | folders->setAutoDelete( false ); |
213 | Folder*inb=new Folder("INBOX","/"); | 214 | Folder*inb=new Folder("INBOX","/"); |
214 | folders->append(inb); | 215 | folders->append(inb); |
215 | return folders; | 216 | return folders; |
216 | } | 217 | } |
217 | 218 | ||
218 | void POP3wrapper::deleteMail(const RecMail&mail) | 219 | void POP3wrapper::deleteMail(const RecMail&mail) |
219 | { | 220 | { |
220 | login(); | 221 | login(); |
221 | if (!m_pop3) return; | 222 | if (!m_pop3) return; |
222 | int err = mailpop3_dele(m_pop3,mail.getNumber()); | 223 | int err = mailpop3_dele(m_pop3,mail.getNumber()); |
223 | if (err != MAILPOP3_NO_ERROR) { | 224 | if (err != MAILPOP3_NO_ERROR) { |
224 | qDebug("error deleting mail"); | 225 | qDebug("error deleting mail"); |
225 | } | 226 | } |
226 | } | 227 | } |
227 | 228 | ||
228 | void POP3wrapper::answeredMail(const RecMail&) | 229 | void POP3wrapper::answeredMail(const RecMail&) |
229 | { | 230 | { |
230 | } | 231 | } |
diff --git a/noncore/net/mail/pop3wrapper.h b/noncore/net/mail/pop3wrapper.h index b738cca..7502720 100644 --- a/noncore/net/mail/pop3wrapper.h +++ b/noncore/net/mail/pop3wrapper.h | |||
@@ -1,32 +1,33 @@ | |||
1 | #ifndef __POP3WRAPPER | 1 | #ifndef __POP3WRAPPER |
2 | #define __POP3WRAPPER | 2 | #define __POP3WRAPPER |
3 | 3 | ||
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include "genericwrapper.h" | 5 | #include "genericwrapper.h" |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | 7 | ||
8 | 8 | ||
9 | class POP3wrapper : public Genericwrapper | 9 | class POP3wrapper : public Genericwrapper |
10 | { | 10 | { |
11 | Q_OBJECT | 11 | Q_OBJECT |
12 | 12 | ||
13 | public: | 13 | public: |
14 | POP3wrapper( POP3account *a ); | 14 | POP3wrapper( POP3account *a ); |
15 | virtual ~POP3wrapper(); | 15 | virtual ~POP3wrapper(); |
16 | /* mailbox will be ignored */ | 16 | /* mailbox will be ignored */ |
17 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 17 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
18 | virtual QList<Folder>* listFolders(); | 18 | virtual QList<Folder>* listFolders(); |
19 | 19 | ||
20 | virtual void deleteMail(const RecMail&mail); | 20 | virtual void deleteMail(const RecMail&mail); |
21 | virtual void answeredMail(const RecMail&mail); | 21 | virtual void answeredMail(const RecMail&mail); |
22 | 22 | ||
23 | virtual RecBody fetchBody( const RecMail &mail ); | 23 | virtual RecBody fetchBody( const RecMail &mail ); |
24 | static void pop3_progress( size_t current, size_t maximum ); | 24 | static void pop3_progress( size_t current, size_t maximum ); |
25 | 25 | ||
26 | protected: | 26 | protected: |
27 | void login(); | 27 | void login(); |
28 | void logout(); | 28 | void logout(); |
29 | 29 | POP3account *account; | |
30 | mailpop3 *m_pop3; | ||
30 | }; | 31 | }; |
31 | 32 | ||
32 | #endif | 33 | #endif |