summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/abstractmail.h9
-rw-r--r--noncore/net/mail/accountview.cpp179
-rw-r--r--noncore/net/mail/accountview.h27
-rw-r--r--noncore/net/mail/imapwrapper.cpp124
-rw-r--r--noncore/net/mail/imapwrapper.h4
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h9
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp124
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h4
-rw-r--r--noncore/net/mail/libmailwrapper/mailwrapper.cpp4
-rw-r--r--noncore/net/mail/libmailwrapper/mailwrapper.h11
-rw-r--r--noncore/net/mail/mail.pro37
-rw-r--r--noncore/net/mail/mailwrapper.cpp4
-rw-r--r--noncore/net/mail/mailwrapper.h11
-rw-r--r--noncore/net/mail/mainwindow.cpp12
-rw-r--r--noncore/net/mail/newmaildir.cpp34
-rw-r--r--noncore/net/mail/newmaildir.h20
-rw-r--r--noncore/net/mail/newmaildirui.ui100
17 files changed, 639 insertions, 74 deletions
diff --git a/noncore/net/mail/abstractmail.h b/noncore/net/mail/abstractmail.h
index 509b68e..b609aa7 100644
--- a/noncore/net/mail/abstractmail.h
+++ b/noncore/net/mail/abstractmail.h
@@ -15,28 +15,37 @@ class encodedString;
15class AbstractMail:public QObject 15class AbstractMail:public QObject
16{ 16{
17 Q_OBJECT 17 Q_OBJECT
18public: 18public:
19 AbstractMail(){}; 19 AbstractMail(){};
20 virtual ~AbstractMail(){} 20 virtual ~AbstractMail(){}
21 virtual QList<Folder>* listFolders()=0; 21 virtual QList<Folder>* listFolders()=0;
22 virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; 22 virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0;
23 virtual RecBody fetchBody(const RecMail&mail)=0; 23 virtual RecBody fetchBody(const RecMail&mail)=0;
24 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; 24 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0;
25 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; 25 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0;
26 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; 26 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0;
27 27
28 virtual void deleteMail(const RecMail&mail)=0; 28 virtual void deleteMail(const RecMail&mail)=0;
29 virtual void answeredMail(const RecMail&mail)=0; 29 virtual void answeredMail(const RecMail&mail)=0;
30 virtual void cleanMimeCache(){}; 30 virtual void cleanMimeCache(){};
31 virtual int deleteAllMail(const Folder*){return 1;}
32
33 /* mail box methods */
34 /* parameter is the box to create.
35 * if the implementing subclass has prefixes,
36 * them has to be appended automatic.
37 */
38 virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false){return 0;}
39 virtual int deleteMbox(const Folder*){return 1;}
31 40
32 static AbstractMail* getWrapper(IMAPaccount *a); 41 static AbstractMail* getWrapper(IMAPaccount *a);
33 static AbstractMail* getWrapper(POP3account *a); 42 static AbstractMail* getWrapper(POP3account *a);
34 /* mbox only! */ 43 /* mbox only! */
35 static AbstractMail* getWrapper(const QString&a); 44 static AbstractMail* getWrapper(const QString&a);
36 45
37protected: 46protected:
38 static encodedString*decode_String(const encodedString*text,const QString&enc); 47 static encodedString*decode_String(const encodedString*text,const QString&enc);
39 static QString convert_String(const char*text); 48 static QString convert_String(const char*text);
40 static QString gen_attachment_id(); 49 static QString gen_attachment_id();
41}; 50};
42#endif 51#endif
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index 59e8bc0..8aac14b 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -1,25 +1,27 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include "accountview.h" 2#include "accountview.h"
3#include "mailtypes.h" 3#include "mailtypes.h"
4#include "defines.h" 4#include "defines.h"
5#include "newmaildir.h"
6#include <qmessagebox.h>
7#include <qpopupmenu.h>
5 8
6/** 9/**
7 * POP3 Account stuff 10 * POP3 Account stuff
8 */ 11 */
9
10POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) 12POP3viewItem::POP3viewItem( POP3account *a, QListView *parent )
11 : AccountViewItem( parent ) 13 : AccountViewItem( parent )
12{ 14{
13 account = a; 15 account = a;
14 wrapper = AbstractMail::getWrapper( account ); 16 wrapper = AbstractMail::getWrapper( account );
15 setPixmap( 0, PIXMAP_POP3FOLDER ); 17 setPixmap( 0, PIXMAP_POP3FOLDER );
16 setText( 0, account->getAccountName() ); 18 setText( 0, account->getAccountName() );
17 setOpen( true ); 19 setOpen( true );
18} 20}
19 21
20POP3viewItem::~POP3viewItem() 22POP3viewItem::~POP3viewItem()
21{ 23{
22 delete wrapper; 24 delete wrapper;
23} 25}
24 26
25AbstractMail *POP3viewItem::getWrapper() 27AbstractMail *POP3viewItem::getWrapper()
@@ -115,33 +117,38 @@ IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start
115 break; 117 break;
116 } 118 }
117 if (pitem->childCount()>0) { 119 if (pitem->childCount()>0) {
118 sitem = findSubItem(path,pitem); 120 sitem = findSubItem(path,pitem);
119 if (sitem) { 121 if (sitem) {
120 pitem = sitem; 122 pitem = sitem;
121 break; 123 break;
122 } 124 }
123 } 125 }
124 pitem=(IMAPfolderItem*)pitem->nextSibling(); 126 pitem=(IMAPfolderItem*)pitem->nextSibling();
125 } 127 }
126 return pitem; 128 return pitem;
127} 129}
128 130
129void IMAPviewItem::refresh(QList<RecMail>&) 131void IMAPviewItem::refresh(QList<RecMail>&)
130{ 132{
131 if (childCount()>0) return; 133 refreshFolders(false);
134}
135
136void IMAPviewItem::refreshFolders(bool force)
137{
138 if (childCount()>0 && force==false) return;
132 QList<Folder> *folders = wrapper->listFolders(); 139 QList<Folder> *folders = wrapper->listFolders();
133 140
134 QListViewItem *child = firstChild(); 141 QListViewItem *child = firstChild();
135 while ( child ) { 142 while ( child ) {
136 QListViewItem *tmp = child; 143 QListViewItem *tmp = child;
137 child = child->nextSibling(); 144 child = child->nextSibling();
138 delete tmp; 145 delete tmp;
139 } 146 }
140 147
141 Folder *it; 148 Folder *it;
142 QListViewItem*item = 0; 149 QListViewItem*item = 0;
143 QListViewItem*titem = 0; 150 QListViewItem*titem = 0;
144 QString fname,del,search; 151 QString fname,del,search;
145 int pos; 152 int pos;
146 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 153 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
147 folders->setAutoDelete(false); 154 folders->setAutoDelete(false);
@@ -151,44 +158,87 @@ void IMAPviewItem::refresh(QList<RecMail>&)
151 item = new IMAPfolderItem( it, this , item ); 158 item = new IMAPfolderItem( it, this , item );
152 folders->remove(it); 159 folders->remove(it);
153 qDebug("inbox found"); 160 qDebug("inbox found");
154 break; 161 break;
155 } 162 }
156 } 163 }
157 for ( it = folders->first(); it; it = folders->next() ) { 164 for ( it = folders->first(); it; it = folders->next() ) {
158 fname = it->getDisplayName(); 165 fname = it->getDisplayName();
159 pos = fname.findRev(it->Separator()); 166 pos = fname.findRev(it->Separator());
160 if (pos != -1) { 167 if (pos != -1) {
161 fname = fname.left(pos); 168 fname = fname.left(pos);
162 } 169 }
163 IMAPfolderItem*pitem = findSubItem(fname); 170 IMAPfolderItem*pitem = findSubItem(fname);
164 if (pitem) { 171 if (pitem) {
165 titem = item; 172 titem = item;
166 item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this); 173 item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this);
167 item->setSelectable(it->may_select());
168 /* setup the short name */ 174 /* setup the short name */
169 item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); 175 item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1));
170 item = titem; 176 item = titem;
171 } else { 177 } else {
172 item = new IMAPfolderItem( it, this , item ); 178 item = new IMAPfolderItem( it, this , item );
173 item->setSelectable(it->may_select());
174 } 179 }
175 } 180 }
176 delete folders; 181 delete folders;
177} 182}
178 183
184QPopupMenu * IMAPviewItem::getContextMenu()
185{
186 QPopupMenu *m = new QPopupMenu(0);
187 if (m) {
188 m->insertItem(QObject::tr("Refresh folder list","IMAPviewItem"),0);
189 m->insertItem(QObject::tr("Create new folder","IMAPviewItem"),1);
190 m->insertSeparator();
191 m->insertItem(QObject::tr("Disconnect","IMAPviewItem"),2);
192 }
193 return m;
194}
195
196void IMAPviewItem::createNewFolder()
197{
198 Newmdirdlg ndirdlg;
199 ndirdlg.showMaximized();
200 if (ndirdlg.exec()) {
201 QString ndir = ndirdlg.Newdir();
202 bool makesubs = ndirdlg.subpossible();
203 QString delemiter = "/";
204 IMAPfolderItem*item = (IMAPfolderItem*)firstChild();
205 if (item) {
206 delemiter = item->Delemiter();
207 }
208 if (wrapper->createMbox(ndir,0,delemiter,makesubs)) {
209 refreshFolders(true);
210 }
211 }
212}
213
214void IMAPviewItem::contextMenuSelected(int id)
215{
216 qDebug("Id selected: %i",id);
217 switch (id) {
218 case 0:
219 refreshFolders(true);
220 break;
221 case 1:
222 createNewFolder();
223 break;
224 default:
225 break;
226 }
227}
228
179RecBody IMAPviewItem::fetchBody(const RecMail&) 229RecBody IMAPviewItem::fetchBody(const RecMail&)
180{ 230{
181 return RecBody(); 231 return RecBody();
182} 232}
183 233
184IMAPfolderItem::~IMAPfolderItem() 234IMAPfolderItem::~IMAPfolderItem()
185{ 235{
186 delete folder; 236 delete folder;
187} 237}
188 238
189IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) 239IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after )
190 : AccountViewItem( parent , after ) 240 : AccountViewItem( parent , after )
191{ 241{
192 folder = folderInit; 242 folder = folderInit;
193 imap = parent; 243 imap = parent;
194 if (folder->getDisplayName().lower()!="inbox") { 244 if (folder->getDisplayName().lower()!="inbox") {
@@ -199,61 +249,176 @@ IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QList
199 setText( 0, folder->getDisplayName() ); 249 setText( 0, folder->getDisplayName() );
200} 250}
201 251
202IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) 252IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master )
203 : AccountViewItem( parent,after ) 253 : AccountViewItem( parent,after )
204{ 254{
205 folder = folderInit; 255 folder = folderInit;
206 imap = master; 256 imap = master;
207 if (folder->getDisplayName().lower()!="inbox") { 257 if (folder->getDisplayName().lower()!="inbox") {
208 setPixmap( 0, PIXMAP_IMAPFOLDER ); 258 setPixmap( 0, PIXMAP_IMAPFOLDER );
209 } else { 259 } else {
210 setPixmap( 0, PIXMAP_INBOXFOLDER); 260 setPixmap( 0, PIXMAP_INBOXFOLDER);
211 } 261 }
212 setText( 0, folder->getDisplayName() ); 262 setText( 0, folder->getDisplayName() );
213} 263}
214 264
265const QString& IMAPfolderItem::Delemiter()const
266{
267 return folder->Separator();
268}
269
215bool IMAPfolderItem::matchName(const QString&name)const 270bool IMAPfolderItem::matchName(const QString&name)const
216{ 271{
217 return folder->getDisplayName()==name; 272 return folder->getDisplayName()==name;
218} 273}
219 274
220void IMAPfolderItem::refresh(QList<RecMail>&target) 275void IMAPfolderItem::refresh(QList<RecMail>&target)
221{ 276{
222 if (folder->may_select()) 277 if (folder->may_select()) {
223 imap->getWrapper()->listMessages( folder->getName(),target ); 278 imap->getWrapper()->listMessages( folder->getName(),target );
279 } else {
280 target.clear();
281 }
224} 282}
225 283
226RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) 284RecBody IMAPfolderItem::fetchBody(const RecMail&aMail)
227{ 285{
228 return imap->getWrapper()->fetchBody(aMail); 286 return imap->getWrapper()->fetchBody(aMail);
229} 287}
230 288
289QPopupMenu * IMAPfolderItem::getContextMenu()
290{
291 QPopupMenu *m = new QPopupMenu(0);
292 if (m) {
293 if (folder->may_select()) {
294 m->insertItem(QObject::tr("Refresh header list","IMAPfolderItem"),0);
295 m->insertItem(QObject::tr("Delete all mails","IMAPfolderItem"),1);
296 }
297 if (folder->no_inferior()==false) {
298 m->insertItem(QObject::tr("Create new subfolder","IMAPfolderItem"),2);
299 }
300 if (folder->getDisplayName().lower()!="inbox") {
301 m->insertItem(QObject::tr("Delete folder","IMAPfolderItem"),3);
302 }
303 }
304 return m;
305}
306
307void IMAPfolderItem::deleteAllMails()
308{
309 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails","IMAPfolderItem"),
310 QObject::tr("<center>Realy delete all mails in box <br>%1</center>","IMAPfolderItem").arg(folder->getDisplayName()),
311 QObject::tr("Yes","IMAPfolderItem"),
312 QObject::tr("No","IMAPfolderItem"),QString::null,1,1);
313 qDebug("Auswahl: %i",yesno);
314 if (yesno == 0) {
315 if (imap->getWrapper()->deleteAllMail(folder)) {
316 AccountView * view = (AccountView*)listView();
317 if (view) view->refreshCurrent();
318 }
319 }
320}
321
322void IMAPfolderItem::createNewFolder()
323{
324 Newmdirdlg ndirdlg;
325 ndirdlg.showMaximized();
326 if (ndirdlg.exec()) {
327 QString ndir = ndirdlg.Newdir();
328 bool makesubs = ndirdlg.subpossible();
329 QString delemiter = Delemiter();
330 if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) {
331 imap->refreshFolders(true);
332 }
333 }
334}
335
336void IMAPfolderItem::deleteFolder()
337{
338 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder","IMAPfolderItem"),
339 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>","IMAPfolderItem").arg(folder->getDisplayName()),
340 QObject::tr("Yes","IMAPfolderItem"),
341 QObject::tr("No","IMAPfolderItem"),QString::null,1,1);
342 qDebug("Auswahl: %i",yesno);
343 if (yesno == 0) {
344 if (imap->getWrapper()->deleteMbox(folder)) {
345 /* be carefull - after that this object is destroyd so don't call
346 * any member of it after that call!!*/
347 imap->refreshFolders(true);
348 }
349 }
350}
351
352void IMAPfolderItem::contextMenuSelected(int id)
353{
354 qDebug("Selected id: %i",id);
355 AccountView * view = (AccountView*)listView();
356 switch(id) {
357 case 0:
358 view->refreshCurrent();
359 break;
360 case 1:
361 deleteAllMails();
362 break;
363 case 2:
364 createNewFolder();
365 break;
366 case 3:
367 deleteFolder();
368 break;
369 default:
370 break;
371 }
372}
231 373
232/** 374/**
233 * Generic stuff 375 * Generic stuff
234 */ 376 */
235 377
236AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) 378AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
237 : QListView( parent, name, flags ) 379 : QListView( parent, name, flags )
238{ 380{
239 connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), 381 connect( this, SIGNAL( selectionChanged( QListViewItem * ) ),
240 SLOT( refresh( QListViewItem * ) ) ); 382 SLOT( refresh( QListViewItem * ) ) );
383 connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this,
384 SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) );
385
241 setSorting(0); 386 setSorting(0);
242} 387}
243 388
389void AccountView::slotContextMenu(int id)
390{
391 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
392 if (!view) return;
393 view->contextMenuSelected(id);
394}
395
396void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int)
397{
398 if (button==1) {return;}
399 if (!item) return;
400 AccountViewItem *view = static_cast<AccountViewItem *>(item);
401 QPopupMenu*m = view->getContextMenu();
402 if (!m) return;
403 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int)));
404 m->setFocus();
405 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
406 delete m;
407}
408
244void AccountView::populate( QList<Account> list ) 409void AccountView::populate( QList<Account> list )
245{ 410{
246 clear(); 411 clear();
247 412
248 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); 413 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/");
249 (void) new MBOXviewItem(localfolders,this); 414 (void) new MBOXviewItem(localfolders,this);
250 415
251 Account *it; 416 Account *it;
252 for ( it = list.first(); it; it = list.next() ) { 417 for ( it = list.first(); it; it = list.next() ) {
253 if ( it->getType().compare( "IMAP" ) == 0 ) { 418 if ( it->getType().compare( "IMAP" ) == 0 ) {
254 IMAPaccount *imap = static_cast<IMAPaccount *>(it); 419 IMAPaccount *imap = static_cast<IMAPaccount *>(it);
255 qDebug( "added IMAP " + imap->getAccountName() ); 420 qDebug( "added IMAP " + imap->getAccountName() );
256 (void) new IMAPviewItem( imap, this ); 421 (void) new IMAPviewItem( imap, this );
257 } else if ( it->getType().compare( "POP3" ) == 0 ) { 422 } else if ( it->getType().compare( "POP3" ) == 0 ) {
258 POP3account *pop3 = static_cast<POP3account *>(it); 423 POP3account *pop3 = static_cast<POP3account *>(it);
259 qDebug( "added POP3 " + pop3->getAccountName() ); 424 qDebug( "added POP3 " + pop3->getAccountName() );
@@ -264,32 +429,33 @@ void AccountView::populate( QList<Account> list )
264 429
265void AccountView::refresh(QListViewItem *item) { 430void AccountView::refresh(QListViewItem *item) {
266 431
267 qDebug("AccountView refresh..."); 432 qDebug("AccountView refresh...");
268 if ( item ) { 433 if ( item ) {
269 m_currentItem = item; 434 m_currentItem = item;
270 QList<RecMail> headerlist; 435 QList<RecMail> headerlist;
271 headerlist.setAutoDelete(true); 436 headerlist.setAutoDelete(true);
272 AccountViewItem *view = static_cast<AccountViewItem *>(item); 437 AccountViewItem *view = static_cast<AccountViewItem *>(item);
273 view->refresh(headerlist); 438 view->refresh(headerlist);
274 emit refreshMailview(&headerlist); 439 emit refreshMailview(&headerlist);
275 } 440 }
276} 441}
277 442
278void AccountView::refreshCurrent() 443void AccountView::refreshCurrent()
279{ 444{
445 m_currentItem = currentItem();
280 if ( !m_currentItem ) return; 446 if ( !m_currentItem ) return;
281 QList<RecMail> headerlist; 447 QList<RecMail> headerlist;
282 headerlist.setAutoDelete(true); 448 headerlist.setAutoDelete(true);
283 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); 449 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
284 view->refresh(headerlist); 450 view->refresh(headerlist);
285 emit refreshMailview(&headerlist); 451 emit refreshMailview(&headerlist);
286} 452}
287 453
288void AccountView::refreshAll() 454void AccountView::refreshAll()
289{ 455{
290 456
291} 457}
292 458
293RecBody AccountView::fetchBody(const RecMail&aMail) 459RecBody AccountView::fetchBody(const RecMail&aMail)
294{ 460{
295 QListViewItem*item = selectedItem (); 461 QListViewItem*item = selectedItem ();
@@ -365,17 +531,16 @@ MBOXfolderItem::MBOXfolderItem( Folder *folderInit, MBOXviewItem *parent , QList
365 } else { 531 } else {
366 setPixmap( 0, PIXMAP_MBOXFOLDER ); 532 setPixmap( 0, PIXMAP_MBOXFOLDER );
367 } 533 }
368 setText( 0, folder->getDisplayName() ); 534 setText( 0, folder->getDisplayName() );
369} 535}
370 536
371void MBOXfolderItem::refresh(QList<RecMail>&target) 537void MBOXfolderItem::refresh(QList<RecMail>&target)
372{ 538{
373 if (folder->may_select()) 539 if (folder->may_select())
374 mbox->getWrapper()->listMessages( folder->getName(),target ); 540 mbox->getWrapper()->listMessages( folder->getName(),target );
375} 541}
376 542
377RecBody MBOXfolderItem::fetchBody(const RecMail&aMail) 543RecBody MBOXfolderItem::fetchBody(const RecMail&aMail)
378{ 544{
379 return mbox->getWrapper()->fetchBody(aMail); 545 return mbox->getWrapper()->fetchBody(aMail);
380} 546}
381
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index 35499ac..e7fe038 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -1,39 +1,42 @@
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
11class POP3wrapper; 11class POP3wrapper;
12class RecMail; 12class RecMail;
13class RecBody; 13class RecBody;
14class QPopupMenu;
14 15
15class AccountViewItem : public QListViewItem 16class AccountViewItem : public QListViewItem
16{ 17{
17 18
18public: 19public:
19 AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} 20 AccountViewItem( QListView *parent ) : QListViewItem( parent ) {}
20 AccountViewItem( QListViewItem *parent) : QListViewItem( parent) {} 21 AccountViewItem( QListViewItem *parent) : QListViewItem( parent) {}
21 AccountViewItem( QListViewItem *parent , QListViewItem*after ) : QListViewItem( parent,after ) {} 22 AccountViewItem( QListViewItem *parent , QListViewItem*after ) : QListViewItem( parent,after ) {}
22 virtual void refresh(QList<RecMail>&)=0; 23 virtual void refresh(QList<RecMail>&)=0;
23 virtual RecBody fetchBody(const RecMail&)=0; 24 virtual RecBody fetchBody(const RecMail&)=0;
25 virtual QPopupMenu * getContextMenu(){return 0;};
26 virtual void contextMenuSelected(int){}
24}; 27};
25 28
26class POP3viewItem : public AccountViewItem 29class POP3viewItem : public AccountViewItem
27{ 30{
28 31
29public: 32public:
30 POP3viewItem( POP3account *a, QListView *parent ); 33 POP3viewItem( POP3account *a, QListView *parent );
31 ~POP3viewItem(); 34 ~POP3viewItem();
32 virtual void refresh( QList<RecMail> &target ); 35 virtual void refresh( QList<RecMail> &target );
33 virtual RecBody fetchBody( const RecMail &mail ); 36 virtual RecBody fetchBody( const RecMail &mail );
34 AbstractMail *getWrapper(); 37 AbstractMail *getWrapper();
35private: 38private:
36 POP3account *account; 39 POP3account *account;
37 AbstractMail *wrapper; 40 AbstractMail *wrapper;
38 41
39}; 42};
@@ -42,58 +45,70 @@ class POP3folderItem : public AccountViewItem
42{ 45{
43 46
44public: 47public:
45 POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); 48 POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after );
46 ~POP3folderItem(); 49 ~POP3folderItem();
47 virtual void refresh(QList<RecMail>&); 50 virtual void refresh(QList<RecMail>&);
48 virtual RecBody fetchBody(const RecMail&); 51 virtual RecBody fetchBody(const RecMail&);
49private: 52private:
50 Folder *folder; 53 Folder *folder;
51 POP3viewItem *pop3; 54 POP3viewItem *pop3;
52}; 55};
53 56
54class IMAPfolderItem; 57class IMAPfolderItem;
55 58
56class IMAPviewItem : public AccountViewItem 59class IMAPviewItem : public AccountViewItem
57{ 60{
58 61 friend class IMAPfolderItem;
59public: 62public:
60 IMAPviewItem( IMAPaccount *a, QListView *parent ); 63 IMAPviewItem( IMAPaccount *a, QListView *parent );
61 ~IMAPviewItem(); 64 ~IMAPviewItem();
62 virtual void refresh(QList<RecMail>&); 65 virtual void refresh(QList<RecMail>&);
63 virtual RecBody fetchBody(const RecMail&); 66 virtual RecBody fetchBody(const RecMail&);
64 AbstractMail *getWrapper(); 67 AbstractMail *getWrapper();
68 virtual QPopupMenu * getContextMenu();
69 virtual void contextMenuSelected(int);
65 70
66protected: 71protected:
67 IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0); 72 IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0);
73 virtual void refreshFolders(bool force=false);
74 virtual void createNewFolder();
68 75
69private: 76private:
70 IMAPaccount *account; 77 IMAPaccount *account;
71 AbstractMail *wrapper; 78 AbstractMail *wrapper;
72}; 79};
73 80
74class IMAPfolderItem : public AccountViewItem 81class IMAPfolderItem : public AccountViewItem
75{ 82{
76 83
77public: 84public:
78 IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); 85 IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after );
79 IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); 86 IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master );
80 ~IMAPfolderItem(); 87 ~IMAPfolderItem();
81 virtual void refresh(QList<RecMail>&); 88 virtual void refresh(QList<RecMail>&);
82 virtual RecBody fetchBody(const RecMail&); 89 virtual RecBody fetchBody(const RecMail&);
83 bool matchName(const QString&name)const; 90 bool matchName(const QString&name)const;
91 virtual void deleteAllMails();
92 virtual QPopupMenu * getContextMenu();
93 virtual void contextMenuSelected(int);
94 virtual const QString& Delemiter()const;
95protected:
96 virtual void createNewFolder();
97 virtual void deleteFolder();
98
84private: 99private:
85 Folder *folder; 100 Folder *folder;
86 IMAPviewItem *imap; 101 IMAPviewItem *imap;
87}; 102};
88 103
89class MBOXviewItem : public AccountViewItem 104class MBOXviewItem : public AccountViewItem
90{ 105{
91 106
92public: 107public:
93// MBOXviewItem( MBOXaccount *a, QListView *parent ); 108// MBOXviewItem( MBOXaccount *a, QListView *parent );
94 MBOXviewItem( const QString&aMboxPath, QListView *parent ); 109 MBOXviewItem( const QString&aMboxPath, QListView *parent );
95 ~MBOXviewItem(); 110 ~MBOXviewItem();
96 virtual void refresh( QList<RecMail> &target ); 111 virtual void refresh( QList<RecMail> &target );
97 virtual RecBody fetchBody( const RecMail &mail ); 112 virtual RecBody fetchBody( const RecMail &mail );
98 AbstractMail *getWrapper(); 113 AbstractMail *getWrapper();
99private: 114private:
@@ -113,28 +128,30 @@ public:
113 virtual RecBody fetchBody(const RecMail&); 128 virtual RecBody fetchBody(const RecMail&);
114private: 129private:
115 Folder *folder; 130 Folder *folder;
116 MBOXviewItem *mbox; 131 MBOXviewItem *mbox;
117}; 132};
118 133
119class AccountView : public QListView 134class AccountView : public QListView
120{ 135{
121 Q_OBJECT 136 Q_OBJECT
122 137
123public: 138public:
124 AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 139 AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
125 void populate( QList<Account> list ); 140 void populate( QList<Account> list );
126 RecBody fetchBody(const RecMail&aMail); 141 RecBody fetchBody(const RecMail&aMail);
127 142
128public slots: 143public slots:
129 void refreshAll(); 144 virtual void refreshAll();
130 void refresh(QListViewItem *item); 145 virtual void refresh(QListViewItem *item);
131 void refreshCurrent(); 146 virtual void refreshCurrent();
132 147 virtual void slotHold(int, QListViewItem *,const QPoint&,int);
148 virtual void slotContextMenu(int id);
149
133signals: 150signals:
134 void refreshMailview(QList<RecMail>*); 151 void refreshMailview(QList<RecMail>*);
135 152
136private: 153private:
137 QListViewItem* m_currentItem; 154 QListViewItem* m_currentItem;
138}; 155};
139 156
140#endif 157#endif
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp
index ab20249..406c57c 100644
--- a/noncore/net/mail/imapwrapper.cpp
+++ b/noncore/net/mail/imapwrapper.cpp
@@ -1,20 +1,19 @@
1
2#include <stdlib.h> 1#include <stdlib.h>
3
4#include <libetpan/libetpan.h> 2#include <libetpan/libetpan.h>
3#include <qpe/global.h>
5 4
6#include "imapwrapper.h" 5#include "imapwrapper.h"
7#include "mailtypes.h" 6#include "mailtypes.h"
8#include "logindialog.h" 7#include "logindialog.h"
9 8
10IMAPwrapper::IMAPwrapper( IMAPaccount *a ) 9IMAPwrapper::IMAPwrapper( IMAPaccount *a )
11 : AbstractMail() 10 : AbstractMail()
12{ 11{
13 account = a; 12 account = a;
14 m_imap = 0; 13 m_imap = 0;
15} 14}
16 15
17IMAPwrapper::~IMAPwrapper() 16IMAPwrapper::~IMAPwrapper()
18{ 17{
19 logout(); 18 logout();
20} 19}
@@ -58,42 +57,42 @@ void IMAPwrapper::login()
58 } else { 57 } else {
59 user = account->getUser().latin1(); 58 user = account->getUser().latin1();
60 pass = account->getPassword().latin1(); 59 pass = account->getPassword().latin1();
61 } 60 }
62 61
63 m_imap = mailimap_new( 20, &imap_progress ); 62 m_imap = mailimap_new( 20, &imap_progress );
64 /* connect */ 63 /* connect */
65 if (account->getSSL()) { 64 if (account->getSSL()) {
66 err = mailimap_ssl_connect( m_imap, (char*)server, port ); 65 err = mailimap_ssl_connect( m_imap, (char*)server, port );
67 } else { 66 } else {
68 err = mailimap_socket_connect( m_imap, (char*)server, port ); 67 err = mailimap_socket_connect( m_imap, (char*)server, port );
69 } 68 }
70 69
71 if ( err != MAILIMAP_NO_ERROR && 70 if ( err != MAILIMAP_NO_ERROR &&
72 err != MAILIMAP_NO_ERROR_AUTHENTICATED && 71 err != MAILIMAP_NO_ERROR_AUTHENTICATED &&
73 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { 72 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) {
74 qDebug("error connecting server: %s",m_imap->imap_response); 73 Global::statusMessage(tr("error connecting imap server: %1").arg(m_imap->imap_response));
75 mailimap_free( m_imap ); 74 mailimap_free( m_imap );
76 m_imap = 0; 75 m_imap = 0;
77 return; 76 return;
78 } 77 }
79 78
80 /* login */ 79 /* login */
81 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); 80 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass );
82 if ( err != MAILIMAP_NO_ERROR ) { 81 if ( err != MAILIMAP_NO_ERROR ) {
83 qDebug("error logging in imap: %s",m_imap->imap_response); 82 Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response));
84 err = mailimap_close( m_imap ); 83 err = mailimap_close( m_imap );
85 mailimap_free( m_imap ); 84 mailimap_free( m_imap );
86 m_imap = 0; 85 m_imap = 0;
87 } 86 }
88} 87}
89 88
90void IMAPwrapper::logout() 89void IMAPwrapper::logout()
91{ 90{
92 int err = MAILIMAP_NO_ERROR; 91 int err = MAILIMAP_NO_ERROR;
93 if (!m_imap) return; 92 if (!m_imap) return;
94 err = mailimap_logout( m_imap ); 93 err = mailimap_logout( m_imap );
95 err = mailimap_close( m_imap ); 94 err = mailimap_close( m_imap );
96 mailimap_free( m_imap ); 95 mailimap_free( m_imap );
97 m_imap = 0; 96 m_imap = 0;
98} 97}
99 98
@@ -102,144 +101,163 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
102 const char *mb = 0; 101 const char *mb = 0;
103 int err = MAILIMAP_NO_ERROR; 102 int err = MAILIMAP_NO_ERROR;
104 clist *result = 0; 103 clist *result = 0;
105 clistcell *current; 104 clistcell *current;
106// mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize; 105// mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize;
107 mailimap_fetch_type *fetchType = 0; 106 mailimap_fetch_type *fetchType = 0;
108 mailimap_set *set = 0; 107 mailimap_set *set = 0;
109 108
110 mb = mailbox.latin1(); 109 mb = mailbox.latin1();
111 login(); 110 login();
112 if (!m_imap) { 111 if (!m_imap) {
113 return; 112 return;
114 } 113 }
115 /* select mailbox READONLY for operations */ 114 /* select mailbox READONLY for operations */
116 err = mailimap_examine( m_imap, (char*)mb); 115 err = mailimap_examine( m_imap, (char*)mb);
117 if ( err != MAILIMAP_NO_ERROR ) { 116 if ( err != MAILIMAP_NO_ERROR ) {
118 qDebug("error selecting mailbox: %s",m_imap->imap_response); 117 Global::statusMessage(tr("error selecting mailbox: %1").arg(m_imap->imap_response));
119 return; 118 return;
120 } 119 }
121 120
122 int last = m_imap->imap_selection_info->sel_exists; 121 int last = m_imap->imap_selection_info->sel_exists;
123 122
124 if (last == 0) { 123 if (last == 0) {
125 qDebug("mailbox has no mails"); 124 Global::statusMessage(tr("Mailbox has no mails"));
126 return; 125 return;
126 } else {
127 Global::statusMessage(tr("Mailbox has %1 mails").arg(last));
127 } 128 }
128 129
129 /* the range has to start at 1!!! not with 0!!!! */ 130 /* the range has to start at 1!!! not with 0!!!! */
130 set = mailimap_set_new_interval( 1, last ); 131 set = mailimap_set_new_interval( 1, last );
131 fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); 132 fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
132 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); 133 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope());
133 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); 134 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags());
134 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); 135 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate());
135 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); 136 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size());
136 137
137 err = mailimap_fetch( m_imap, set, fetchType, &result ); 138 err = mailimap_fetch( m_imap, set, fetchType, &result );
138 mailimap_set_free( set ); 139 mailimap_set_free( set );
139 mailimap_fetch_type_free( fetchType ); 140 mailimap_fetch_type_free( fetchType );
140 141
141 QString date,subject,from; 142 QString date,subject,from;
142 143
143 if ( err == MAILIMAP_NO_ERROR ) { 144 if ( err == MAILIMAP_NO_ERROR ) {
144 mailimap_msg_att * msg_att; 145 mailimap_msg_att * msg_att;
145 int i = 0; 146 int i = 0;
146 for (current = clist_begin(result); current != 0; current=clist_next(current)) { 147 for (current = clist_begin(result); current != 0; current=clist_next(current)) {
147 ++i; 148 ++i;
148 msg_att = (mailimap_msg_att*)current->data; 149 msg_att = (mailimap_msg_att*)current->data;
149 RecMail*m = parse_list_result(msg_att); 150 RecMail*m = parse_list_result(msg_att);
150 if (m) { 151 if (m) {
151 m->setNumber(i); 152 m->setNumber(i);
152 m->setMbox(mailbox); 153 m->setMbox(mailbox);
153 m->setWrapper(this); 154 m->setWrapper(this);
154 target.append(m); 155 target.append(m);
155 } 156 }
156 } 157 }
157 } else { 158 } else {
158 qDebug("Error fetching headers: %s",m_imap->imap_response); 159 Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response));
159 } 160 }
160 if (result) mailimap_fetch_list_free(result); 161 if (result) mailimap_fetch_list_free(result);
161} 162}
162 163
163QList<Folder>* IMAPwrapper::listFolders() 164QList<Folder>* IMAPwrapper::listFolders()
164{ 165{
165 const char *path, *mask; 166 const char *path, *mask;
166 int err = MAILIMAP_NO_ERROR; 167 int err = MAILIMAP_NO_ERROR;
167 clist *result = 0; 168 clist *result = 0;
168 clistcell *current = 0; 169 clistcell *current = 0;
170 clistcell*cur_flag = 0;
171 mailimap_mbx_list_flags*bflags = 0;
169 172
170 QList<Folder> * folders = new QList<Folder>(); 173 QList<Folder> * folders = new QList<Folder>();
171 folders->setAutoDelete( false ); 174 folders->setAutoDelete( false );
172 login(); 175 login();
173 if (!m_imap) { 176 if (!m_imap) {
174 return folders; 177 return folders;
175 } 178 }
176 179
177/* 180/*
178 * First we have to check for INBOX 'cause it sometimes it's not inside the path. 181 * First we have to check for INBOX 'cause it sometimes it's not inside the path.
179 * We must not forget to filter them out in next loop! 182 * We must not forget to filter them out in next loop!
180 * it seems like ugly code. and yes - it is ugly code. but the best way. 183 * it seems like ugly code. and yes - it is ugly code. but the best way.
181 */ 184 */
182 QString temp; 185 QString temp;
183 mask = "INBOX" ; 186 mask = "INBOX" ;
184 mailimap_mailbox_list *list; 187 mailimap_mailbox_list *list;
185 err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); 188 err = mailimap_list( m_imap, (char*)"", (char*)mask, &result );
186 QString del; 189 QString del;
190 bool selectable = true;
191 bool no_inferiors = false;
187 if ( err == MAILIMAP_NO_ERROR ) { 192 if ( err == MAILIMAP_NO_ERROR ) {
188 current = result->first; 193 current = result->first;
189 for ( int i = result->count; i > 0; i-- ) { 194 for ( int i = result->count; i > 0; i-- ) {
190 list = (mailimap_mailbox_list *) current->data; 195 list = (mailimap_mailbox_list *) current->data;
191 // it is better use the deep copy mechanism of qt itself 196 // it is better use the deep copy mechanism of qt itself
192 // instead of using strdup! 197 // instead of using strdup!
193 temp = list->mb_name; 198 temp = list->mb_name;
194 del = list->mb_delimiter; 199 del = list->mb_delimiter;
195 folders->append( new IMAPFolder(temp,del,true,account->getPrefix()));
196 current = current->next; 200 current = current->next;
201 if ( (bflags = list->mb_flag) ) {
202 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&&
203 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT);
204 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) {
205 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) {
206 no_inferiors = true;
207 }
208 }
209 }
210 folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix()));
197 } 211 }
198 } else { 212 } else {
199 qDebug("error fetching folders: %s",m_imap->imap_response); 213 qDebug("error fetching folders: %s",m_imap->imap_response);
200 } 214 }
201 mailimap_list_result_free( result ); 215 mailimap_list_result_free( result );
202 216
203/* 217/*
204 * second stage - get the other then inbox folders 218 * second stage - get the other then inbox folders
205 */ 219 */
206 mask = "*" ; 220 mask = "*" ;
207 path = account->getPrefix().latin1(); 221 path = account->getPrefix().latin1();
208 if (!path) path = ""; 222 if (!path) path = "";
209 qDebug(path); 223 qDebug(path);
210 bool selectable = true;
211 mailimap_mbx_list_flags*bflags;
212 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); 224 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result );
213 if ( err == MAILIMAP_NO_ERROR ) { 225 if ( err == MAILIMAP_NO_ERROR ) {
214 current = result->first; 226 current = result->first;
215 for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { 227 for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) {
228 no_inferiors = false;
216 list = (mailimap_mailbox_list *) current->data; 229 list = (mailimap_mailbox_list *) current->data;
217 // it is better use the deep copy mechanism of qt itself 230 // it is better use the deep copy mechanism of qt itself
218 // instead of using strdup! 231 // instead of using strdup!
219 temp = list->mb_name; 232 temp = list->mb_name;
220 if (temp.lower()=="inbox") 233 if (temp.lower()=="inbox")
221 continue; 234 continue;
222 if (temp.lower()==account->getPrefix().lower()) 235 if (temp.lower()==account->getPrefix().lower())
223 continue; 236 continue;
224 if ( (bflags = list->mb_flag) ) { 237 if ( (bflags = list->mb_flag) ) {
225 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& 238 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&&
226 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); 239 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT);
240 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) {
241 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) {
242 no_inferiors = true;
243 }
244 }
227 } 245 }
228 del = list->mb_delimiter; 246 del = list->mb_delimiter;
229 folders->append(new IMAPFolder(temp,del,selectable,account->getPrefix())); 247 folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix()));
230 } 248 }
231 } else { 249 } else {
232 qDebug("error fetching folders %s",m_imap->imap_response); 250 qDebug("error fetching folders %s",m_imap->imap_response);
233 } 251 }
234 if (result) mailimap_list_result_free( result ); 252 if (result) mailimap_list_result_free( result );
235 return folders; 253 return folders;
236} 254}
237 255
238RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) 256RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
239{ 257{
240 RecMail * m = 0; 258 RecMail * m = 0;
241 mailimap_msg_att_item *item=0; 259 mailimap_msg_att_item *item=0;
242 clistcell *current,*c,*cf; 260 clistcell *current,*c,*cf;
243 mailimap_msg_att_dynamic*flist; 261 mailimap_msg_att_dynamic*flist;
244 mailimap_flag_fetch*cflag; 262 mailimap_flag_fetch*cflag;
245 int size; 263 int size;
@@ -805,16 +823,100 @@ QString IMAPwrapper::fetchTextPart(const RecMail&mail,const RecPart&part)
805{ 823{
806 return fetchTextPart(mail,part.Positionlist(),false,part.Encoding()); 824 return fetchTextPart(mail,part.Positionlist(),false,part.Encoding());
807} 825}
808 826
809encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&part) 827encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&part)
810{ 828{
811 encodedString*res = fetchRawPart(mail,part.Positionlist(),false); 829 encodedString*res = fetchRawPart(mail,part.Positionlist(),false);
812 encodedString*r = decode_String(res,part.Encoding()); 830 encodedString*r = decode_String(res,part.Encoding());
813 delete res; 831 delete res;
814 return r; 832 return r;
815} 833}
816 834
817encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) 835encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part)
818{ 836{
819 return fetchRawPart(mail,part.Positionlist(),false); 837 return fetchRawPart(mail,part.Positionlist(),false);
820} 838}
839
840int IMAPwrapper::deleteAllMail(const Folder*folder)
841{
842 login();
843 if (!m_imap) {
844 return 0;
845 }
846 mailimap_flag_list*flist;
847 mailimap_set *set;
848 mailimap_store_att_flags * store_flags;
849 int err = mailimap_select( m_imap, folder->getName().latin1());
850 if ( err != MAILIMAP_NO_ERROR ) {
851 Global::statusMessage(tr("error selecting mailbox: %1").arg(m_imap->imap_response));
852 return 0;
853 }
854 int last = m_imap->imap_selection_info->sel_exists;
855 if (last == 0) {
856 Global::statusMessage(tr("Mailbox has no mails!"));
857 return 0;
858 }
859 flist = mailimap_flag_list_new_empty();
860 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
861 store_flags = mailimap_store_att_flags_new_set_flags(flist);
862 set = mailimap_set_new_interval( 1, last );
863 err = mailimap_store(m_imap,set,store_flags);
864 mailimap_set_free( set );
865 mailimap_store_att_flags_free(store_flags);
866 if (err != MAILIMAP_NO_ERROR) {
867 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
868 return 0;
869 }
870 qDebug("deleting mail: %s",m_imap->imap_response);
871 /* should we realy do that at this moment? */
872 err = mailimap_expunge(m_imap);
873 if (err != MAILIMAP_NO_ERROR) {
874 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
875 return 0;
876 }
877 qDebug("Delete successfull %s",m_imap->imap_response);
878 return 1;
879}
880
881int IMAPwrapper::createMbox(const QString&folder,const Folder*parentfolder,const QString& delemiter,bool getsubfolder)
882{
883 if (folder.length()==0) return 0;
884 login();
885 if (!m_imap) {return 0;}
886 QString pre = account->getPrefix();
887 if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) {
888 pre+=delemiter;
889 }
890 if (parentfolder) {
891 pre += parentfolder->getDisplayName()+delemiter;
892 }
893 pre+=folder;
894 if (getsubfolder) {
895 if (delemiter.length()>0) {
896 pre+=delemiter;
897 } else {
898 Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre));
899 return 0;
900 }
901 }
902 qDebug("Creating %s",pre.latin1());
903 int res = mailimap_create(m_imap,pre.latin1());
904 if (res != MAILIMAP_NO_ERROR) {
905 Global::statusMessage(tr("%1").arg(m_imap->imap_response));
906 return 0;
907 }
908 return 1;
909}
910
911int IMAPwrapper::deleteMbox(const Folder*folder)
912{
913 if (!folder) return 0;
914 login();
915 if (!m_imap) {return 0;}
916 int res = mailimap_delete(m_imap,folder->getName());
917 if (res != MAILIMAP_NO_ERROR) {
918 Global::statusMessage(tr("%1").arg(m_imap->imap_response));
919 return 0;
920 }
921 return 1;
922}
diff --git a/noncore/net/mail/imapwrapper.h b/noncore/net/mail/imapwrapper.h
index f046297..9b20288 100644
--- a/noncore/net/mail/imapwrapper.h
+++ b/noncore/net/mail/imapwrapper.h
@@ -14,38 +14,42 @@ struct mailimap_body_type_msg;
14struct mailimap_body_type_mpart; 14struct mailimap_body_type_mpart;
15struct mailimap_body_fields; 15struct mailimap_body_fields;
16struct mailimap_msg_att; 16struct mailimap_msg_att;
17class encodedString; 17class encodedString;
18 18
19class IMAPwrapper : public AbstractMail 19class IMAPwrapper : public AbstractMail
20{ 20{
21 Q_OBJECT 21 Q_OBJECT
22public: 22public:
23 IMAPwrapper( IMAPaccount *a ); 23 IMAPwrapper( IMAPaccount *a );
24 virtual ~IMAPwrapper(); 24 virtual ~IMAPwrapper();
25 virtual QList<Folder>* listFolders(); 25 virtual QList<Folder>* listFolders();
26 virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); 26 virtual void listMessages(const QString & mailbox,QList<RecMail>&target );
27 27
28 virtual void deleteMail(const RecMail&mail); 28 virtual void deleteMail(const RecMail&mail);
29 virtual void answeredMail(const RecMail&mail); 29 virtual void answeredMail(const RecMail&mail);
30 virtual int deleteAllMail(const Folder*folder);
30 31
31 virtual RecBody fetchBody(const RecMail&mail); 32 virtual RecBody fetchBody(const RecMail&mail);
32 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); 33 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part);
33 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); 34 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part);
34 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); 35 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part);
35 36
37 virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false);
38 virtual int deleteMbox(const Folder*folder);
39
36 static void imap_progress( size_t current, size_t maximum ); 40 static void imap_progress( size_t current, size_t maximum );
37 41
38protected: 42protected:
39 RecMail*parse_list_result(mailimap_msg_att*); 43 RecMail*parse_list_result(mailimap_msg_att*);
40 void login(); 44 void login();
41 void logout(); 45 void logout();
42 46
43 virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); 47 virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc="");
44 virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); 48 virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call);
45 49
46 void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); 50 void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body);
47 void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>()); 51 void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>());
48 52
49 void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); 53 void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description);
50 void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); 54 void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which);
51 void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); 55 void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which);
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index 509b68e..b609aa7 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -15,28 +15,37 @@ class encodedString;
15class AbstractMail:public QObject 15class AbstractMail:public QObject
16{ 16{
17 Q_OBJECT 17 Q_OBJECT
18public: 18public:
19 AbstractMail(){}; 19 AbstractMail(){};
20 virtual ~AbstractMail(){} 20 virtual ~AbstractMail(){}
21 virtual QList<Folder>* listFolders()=0; 21 virtual QList<Folder>* listFolders()=0;
22 virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; 22 virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0;
23 virtual RecBody fetchBody(const RecMail&mail)=0; 23 virtual RecBody fetchBody(const RecMail&mail)=0;
24 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; 24 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0;
25 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; 25 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0;
26 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; 26 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0;
27 27
28 virtual void deleteMail(const RecMail&mail)=0; 28 virtual void deleteMail(const RecMail&mail)=0;
29 virtual void answeredMail(const RecMail&mail)=0; 29 virtual void answeredMail(const RecMail&mail)=0;
30 virtual void cleanMimeCache(){}; 30 virtual void cleanMimeCache(){};
31 virtual int deleteAllMail(const Folder*){return 1;}
32
33 /* mail box methods */
34 /* parameter is the box to create.
35 * if the implementing subclass has prefixes,
36 * them has to be appended automatic.
37 */
38 virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false){return 0;}
39 virtual int deleteMbox(const Folder*){return 1;}
31 40
32 static AbstractMail* getWrapper(IMAPaccount *a); 41 static AbstractMail* getWrapper(IMAPaccount *a);
33 static AbstractMail* getWrapper(POP3account *a); 42 static AbstractMail* getWrapper(POP3account *a);
34 /* mbox only! */ 43 /* mbox only! */
35 static AbstractMail* getWrapper(const QString&a); 44 static AbstractMail* getWrapper(const QString&a);
36 45
37protected: 46protected:
38 static encodedString*decode_String(const encodedString*text,const QString&enc); 47 static encodedString*decode_String(const encodedString*text,const QString&enc);
39 static QString convert_String(const char*text); 48 static QString convert_String(const char*text);
40 static QString gen_attachment_id(); 49 static QString gen_attachment_id();
41}; 50};
42#endif 51#endif
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index ab20249..406c57c 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -1,20 +1,19 @@
1
2#include <stdlib.h> 1#include <stdlib.h>
3
4#include <libetpan/libetpan.h> 2#include <libetpan/libetpan.h>
3#include <qpe/global.h>
5 4
6#include "imapwrapper.h" 5#include "imapwrapper.h"
7#include "mailtypes.h" 6#include "mailtypes.h"
8#include "logindialog.h" 7#include "logindialog.h"
9 8
10IMAPwrapper::IMAPwrapper( IMAPaccount *a ) 9IMAPwrapper::IMAPwrapper( IMAPaccount *a )
11 : AbstractMail() 10 : AbstractMail()
12{ 11{
13 account = a; 12 account = a;
14 m_imap = 0; 13 m_imap = 0;
15} 14}
16 15
17IMAPwrapper::~IMAPwrapper() 16IMAPwrapper::~IMAPwrapper()
18{ 17{
19 logout(); 18 logout();
20} 19}
@@ -58,42 +57,42 @@ void IMAPwrapper::login()
58 } else { 57 } else {
59 user = account->getUser().latin1(); 58 user = account->getUser().latin1();
60 pass = account->getPassword().latin1(); 59 pass = account->getPassword().latin1();
61 } 60 }
62 61
63 m_imap = mailimap_new( 20, &imap_progress ); 62 m_imap = mailimap_new( 20, &imap_progress );
64 /* connect */ 63 /* connect */
65 if (account->getSSL()) { 64 if (account->getSSL()) {
66 err = mailimap_ssl_connect( m_imap, (char*)server, port ); 65 err = mailimap_ssl_connect( m_imap, (char*)server, port );
67 } else { 66 } else {
68 err = mailimap_socket_connect( m_imap, (char*)server, port ); 67 err = mailimap_socket_connect( m_imap, (char*)server, port );
69 } 68 }
70 69
71 if ( err != MAILIMAP_NO_ERROR && 70 if ( err != MAILIMAP_NO_ERROR &&
72 err != MAILIMAP_NO_ERROR_AUTHENTICATED && 71 err != MAILIMAP_NO_ERROR_AUTHENTICATED &&
73 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { 72 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) {
74 qDebug("error connecting server: %s",m_imap->imap_response); 73 Global::statusMessage(tr("error connecting imap server: %1").arg(m_imap->imap_response));
75 mailimap_free( m_imap ); 74 mailimap_free( m_imap );
76 m_imap = 0; 75 m_imap = 0;
77 return; 76 return;
78 } 77 }
79 78
80 /* login */ 79 /* login */
81 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); 80 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass );
82 if ( err != MAILIMAP_NO_ERROR ) { 81 if ( err != MAILIMAP_NO_ERROR ) {
83 qDebug("error logging in imap: %s",m_imap->imap_response); 82 Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response));
84 err = mailimap_close( m_imap ); 83 err = mailimap_close( m_imap );
85 mailimap_free( m_imap ); 84 mailimap_free( m_imap );
86 m_imap = 0; 85 m_imap = 0;
87 } 86 }
88} 87}
89 88
90void IMAPwrapper::logout() 89void IMAPwrapper::logout()
91{ 90{
92 int err = MAILIMAP_NO_ERROR; 91 int err = MAILIMAP_NO_ERROR;
93 if (!m_imap) return; 92 if (!m_imap) return;
94 err = mailimap_logout( m_imap ); 93 err = mailimap_logout( m_imap );
95 err = mailimap_close( m_imap ); 94 err = mailimap_close( m_imap );
96 mailimap_free( m_imap ); 95 mailimap_free( m_imap );
97 m_imap = 0; 96 m_imap = 0;
98} 97}
99 98
@@ -102,144 +101,163 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
102 const char *mb = 0; 101 const char *mb = 0;
103 int err = MAILIMAP_NO_ERROR; 102 int err = MAILIMAP_NO_ERROR;
104 clist *result = 0; 103 clist *result = 0;
105 clistcell *current; 104 clistcell *current;
106// mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize; 105// mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize;
107 mailimap_fetch_type *fetchType = 0; 106 mailimap_fetch_type *fetchType = 0;
108 mailimap_set *set = 0; 107 mailimap_set *set = 0;
109 108
110 mb = mailbox.latin1(); 109 mb = mailbox.latin1();
111 login(); 110 login();
112 if (!m_imap) { 111 if (!m_imap) {
113 return; 112 return;
114 } 113 }
115 /* select mailbox READONLY for operations */ 114 /* select mailbox READONLY for operations */
116 err = mailimap_examine( m_imap, (char*)mb); 115 err = mailimap_examine( m_imap, (char*)mb);
117 if ( err != MAILIMAP_NO_ERROR ) { 116 if ( err != MAILIMAP_NO_ERROR ) {
118 qDebug("error selecting mailbox: %s",m_imap->imap_response); 117 Global::statusMessage(tr("error selecting mailbox: %1").arg(m_imap->imap_response));
119 return; 118 return;
120 } 119 }
121 120
122 int last = m_imap->imap_selection_info->sel_exists; 121 int last = m_imap->imap_selection_info->sel_exists;
123 122
124 if (last == 0) { 123 if (last == 0) {
125 qDebug("mailbox has no mails"); 124 Global::statusMessage(tr("Mailbox has no mails"));
126 return; 125 return;
126 } else {
127 Global::statusMessage(tr("Mailbox has %1 mails").arg(last));
127 } 128 }
128 129
129 /* the range has to start at 1!!! not with 0!!!! */ 130 /* the range has to start at 1!!! not with 0!!!! */
130 set = mailimap_set_new_interval( 1, last ); 131 set = mailimap_set_new_interval( 1, last );
131 fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); 132 fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
132 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); 133 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope());
133 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); 134 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags());
134 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); 135 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate());
135 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); 136 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size());
136 137
137 err = mailimap_fetch( m_imap, set, fetchType, &result ); 138 err = mailimap_fetch( m_imap, set, fetchType, &result );
138 mailimap_set_free( set ); 139 mailimap_set_free( set );
139 mailimap_fetch_type_free( fetchType ); 140 mailimap_fetch_type_free( fetchType );
140 141
141 QString date,subject,from; 142 QString date,subject,from;
142 143
143 if ( err == MAILIMAP_NO_ERROR ) { 144 if ( err == MAILIMAP_NO_ERROR ) {
144 mailimap_msg_att * msg_att; 145 mailimap_msg_att * msg_att;
145 int i = 0; 146 int i = 0;
146 for (current = clist_begin(result); current != 0; current=clist_next(current)) { 147 for (current = clist_begin(result); current != 0; current=clist_next(current)) {
147 ++i; 148 ++i;
148 msg_att = (mailimap_msg_att*)current->data; 149 msg_att = (mailimap_msg_att*)current->data;
149 RecMail*m = parse_list_result(msg_att); 150 RecMail*m = parse_list_result(msg_att);
150 if (m) { 151 if (m) {
151 m->setNumber(i); 152 m->setNumber(i);
152 m->setMbox(mailbox); 153 m->setMbox(mailbox);
153 m->setWrapper(this); 154 m->setWrapper(this);
154 target.append(m); 155 target.append(m);
155 } 156 }
156 } 157 }
157 } else { 158 } else {
158 qDebug("Error fetching headers: %s",m_imap->imap_response); 159 Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response));
159 } 160 }
160 if (result) mailimap_fetch_list_free(result); 161 if (result) mailimap_fetch_list_free(result);
161} 162}
162 163
163QList<Folder>* IMAPwrapper::listFolders() 164QList<Folder>* IMAPwrapper::listFolders()
164{ 165{
165 const char *path, *mask; 166 const char *path, *mask;
166 int err = MAILIMAP_NO_ERROR; 167 int err = MAILIMAP_NO_ERROR;
167 clist *result = 0; 168 clist *result = 0;
168 clistcell *current = 0; 169 clistcell *current = 0;
170 clistcell*cur_flag = 0;
171 mailimap_mbx_list_flags*bflags = 0;
169 172
170 QList<Folder> * folders = new QList<Folder>(); 173 QList<Folder> * folders = new QList<Folder>();
171 folders->setAutoDelete( false ); 174 folders->setAutoDelete( false );
172 login(); 175 login();
173 if (!m_imap) { 176 if (!m_imap) {
174 return folders; 177 return folders;
175 } 178 }
176 179
177/* 180/*
178 * First we have to check for INBOX 'cause it sometimes it's not inside the path. 181 * First we have to check for INBOX 'cause it sometimes it's not inside the path.
179 * We must not forget to filter them out in next loop! 182 * We must not forget to filter them out in next loop!
180 * it seems like ugly code. and yes - it is ugly code. but the best way. 183 * it seems like ugly code. and yes - it is ugly code. but the best way.
181 */ 184 */
182 QString temp; 185 QString temp;
183 mask = "INBOX" ; 186 mask = "INBOX" ;
184 mailimap_mailbox_list *list; 187 mailimap_mailbox_list *list;
185 err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); 188 err = mailimap_list( m_imap, (char*)"", (char*)mask, &result );
186 QString del; 189 QString del;
190 bool selectable = true;
191 bool no_inferiors = false;
187 if ( err == MAILIMAP_NO_ERROR ) { 192 if ( err == MAILIMAP_NO_ERROR ) {
188 current = result->first; 193 current = result->first;
189 for ( int i = result->count; i > 0; i-- ) { 194 for ( int i = result->count; i > 0; i-- ) {
190 list = (mailimap_mailbox_list *) current->data; 195 list = (mailimap_mailbox_list *) current->data;
191 // it is better use the deep copy mechanism of qt itself 196 // it is better use the deep copy mechanism of qt itself
192 // instead of using strdup! 197 // instead of using strdup!
193 temp = list->mb_name; 198 temp = list->mb_name;
194 del = list->mb_delimiter; 199 del = list->mb_delimiter;
195 folders->append( new IMAPFolder(temp,del,true,account->getPrefix()));
196 current = current->next; 200 current = current->next;
201 if ( (bflags = list->mb_flag) ) {
202 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&&
203 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT);
204 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) {
205 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) {
206 no_inferiors = true;
207 }
208 }
209 }
210 folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix()));
197 } 211 }
198 } else { 212 } else {
199 qDebug("error fetching folders: %s",m_imap->imap_response); 213 qDebug("error fetching folders: %s",m_imap->imap_response);
200 } 214 }
201 mailimap_list_result_free( result ); 215 mailimap_list_result_free( result );
202 216
203/* 217/*
204 * second stage - get the other then inbox folders 218 * second stage - get the other then inbox folders
205 */ 219 */
206 mask = "*" ; 220 mask = "*" ;
207 path = account->getPrefix().latin1(); 221 path = account->getPrefix().latin1();
208 if (!path) path = ""; 222 if (!path) path = "";
209 qDebug(path); 223 qDebug(path);
210 bool selectable = true;
211 mailimap_mbx_list_flags*bflags;
212 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); 224 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result );
213 if ( err == MAILIMAP_NO_ERROR ) { 225 if ( err == MAILIMAP_NO_ERROR ) {
214 current = result->first; 226 current = result->first;
215 for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { 227 for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) {
228 no_inferiors = false;
216 list = (mailimap_mailbox_list *) current->data; 229 list = (mailimap_mailbox_list *) current->data;
217 // it is better use the deep copy mechanism of qt itself 230 // it is better use the deep copy mechanism of qt itself
218 // instead of using strdup! 231 // instead of using strdup!
219 temp = list->mb_name; 232 temp = list->mb_name;
220 if (temp.lower()=="inbox") 233 if (temp.lower()=="inbox")
221 continue; 234 continue;
222 if (temp.lower()==account->getPrefix().lower()) 235 if (temp.lower()==account->getPrefix().lower())
223 continue; 236 continue;
224 if ( (bflags = list->mb_flag) ) { 237 if ( (bflags = list->mb_flag) ) {
225 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& 238 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&&
226 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); 239 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT);
240 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) {
241 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) {
242 no_inferiors = true;
243 }
244 }
227 } 245 }
228 del = list->mb_delimiter; 246 del = list->mb_delimiter;
229 folders->append(new IMAPFolder(temp,del,selectable,account->getPrefix())); 247 folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix()));
230 } 248 }
231 } else { 249 } else {
232 qDebug("error fetching folders %s",m_imap->imap_response); 250 qDebug("error fetching folders %s",m_imap->imap_response);
233 } 251 }
234 if (result) mailimap_list_result_free( result ); 252 if (result) mailimap_list_result_free( result );
235 return folders; 253 return folders;
236} 254}
237 255
238RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) 256RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
239{ 257{
240 RecMail * m = 0; 258 RecMail * m = 0;
241 mailimap_msg_att_item *item=0; 259 mailimap_msg_att_item *item=0;
242 clistcell *current,*c,*cf; 260 clistcell *current,*c,*cf;
243 mailimap_msg_att_dynamic*flist; 261 mailimap_msg_att_dynamic*flist;
244 mailimap_flag_fetch*cflag; 262 mailimap_flag_fetch*cflag;
245 int size; 263 int size;
@@ -805,16 +823,100 @@ QString IMAPwrapper::fetchTextPart(const RecMail&mail,const RecPart&part)
805{ 823{
806 return fetchTextPart(mail,part.Positionlist(),false,part.Encoding()); 824 return fetchTextPart(mail,part.Positionlist(),false,part.Encoding());
807} 825}
808 826
809encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&part) 827encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&part)
810{ 828{
811 encodedString*res = fetchRawPart(mail,part.Positionlist(),false); 829 encodedString*res = fetchRawPart(mail,part.Positionlist(),false);
812 encodedString*r = decode_String(res,part.Encoding()); 830 encodedString*r = decode_String(res,part.Encoding());
813 delete res; 831 delete res;
814 return r; 832 return r;
815} 833}
816 834
817encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) 835encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part)
818{ 836{
819 return fetchRawPart(mail,part.Positionlist(),false); 837 return fetchRawPart(mail,part.Positionlist(),false);
820} 838}
839
840int IMAPwrapper::deleteAllMail(const Folder*folder)
841{
842 login();
843 if (!m_imap) {
844 return 0;
845 }
846 mailimap_flag_list*flist;
847 mailimap_set *set;
848 mailimap_store_att_flags * store_flags;
849 int err = mailimap_select( m_imap, folder->getName().latin1());
850 if ( err != MAILIMAP_NO_ERROR ) {
851 Global::statusMessage(tr("error selecting mailbox: %1").arg(m_imap->imap_response));
852 return 0;
853 }
854 int last = m_imap->imap_selection_info->sel_exists;
855 if (last == 0) {
856 Global::statusMessage(tr("Mailbox has no mails!"));
857 return 0;
858 }
859 flist = mailimap_flag_list_new_empty();
860 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
861 store_flags = mailimap_store_att_flags_new_set_flags(flist);
862 set = mailimap_set_new_interval( 1, last );
863 err = mailimap_store(m_imap,set,store_flags);
864 mailimap_set_free( set );
865 mailimap_store_att_flags_free(store_flags);
866 if (err != MAILIMAP_NO_ERROR) {
867 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
868 return 0;
869 }
870 qDebug("deleting mail: %s",m_imap->imap_response);
871 /* should we realy do that at this moment? */
872 err = mailimap_expunge(m_imap);
873 if (err != MAILIMAP_NO_ERROR) {
874 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
875 return 0;
876 }
877 qDebug("Delete successfull %s",m_imap->imap_response);
878 return 1;
879}
880
881int IMAPwrapper::createMbox(const QString&folder,const Folder*parentfolder,const QString& delemiter,bool getsubfolder)
882{
883 if (folder.length()==0) return 0;
884 login();
885 if (!m_imap) {return 0;}
886 QString pre = account->getPrefix();
887 if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) {
888 pre+=delemiter;
889 }
890 if (parentfolder) {
891 pre += parentfolder->getDisplayName()+delemiter;
892 }
893 pre+=folder;
894 if (getsubfolder) {
895 if (delemiter.length()>0) {
896 pre+=delemiter;
897 } else {
898 Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre));
899 return 0;
900 }
901 }
902 qDebug("Creating %s",pre.latin1());
903 int res = mailimap_create(m_imap,pre.latin1());
904 if (res != MAILIMAP_NO_ERROR) {
905 Global::statusMessage(tr("%1").arg(m_imap->imap_response));
906 return 0;
907 }
908 return 1;
909}
910
911int IMAPwrapper::deleteMbox(const Folder*folder)
912{
913 if (!folder) return 0;
914 login();
915 if (!m_imap) {return 0;}
916 int res = mailimap_delete(m_imap,folder->getName());
917 if (res != MAILIMAP_NO_ERROR) {
918 Global::statusMessage(tr("%1").arg(m_imap->imap_response));
919 return 0;
920 }
921 return 1;
922}
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index f046297..9b20288 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -14,38 +14,42 @@ struct mailimap_body_type_msg;
14struct mailimap_body_type_mpart; 14struct mailimap_body_type_mpart;
15struct mailimap_body_fields; 15struct mailimap_body_fields;
16struct mailimap_msg_att; 16struct mailimap_msg_att;
17class encodedString; 17class encodedString;
18 18
19class IMAPwrapper : public AbstractMail 19class IMAPwrapper : public AbstractMail
20{ 20{
21 Q_OBJECT 21 Q_OBJECT
22public: 22public:
23 IMAPwrapper( IMAPaccount *a ); 23 IMAPwrapper( IMAPaccount *a );
24 virtual ~IMAPwrapper(); 24 virtual ~IMAPwrapper();
25 virtual QList<Folder>* listFolders(); 25 virtual QList<Folder>* listFolders();
26 virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); 26 virtual void listMessages(const QString & mailbox,QList<RecMail>&target );
27 27
28 virtual void deleteMail(const RecMail&mail); 28 virtual void deleteMail(const RecMail&mail);
29 virtual void answeredMail(const RecMail&mail); 29 virtual void answeredMail(const RecMail&mail);
30 virtual int deleteAllMail(const Folder*folder);
30 31
31 virtual RecBody fetchBody(const RecMail&mail); 32 virtual RecBody fetchBody(const RecMail&mail);
32 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); 33 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part);
33 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); 34 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part);
34 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); 35 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part);
35 36
37 virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false);
38 virtual int deleteMbox(const Folder*folder);
39
36 static void imap_progress( size_t current, size_t maximum ); 40 static void imap_progress( size_t current, size_t maximum );
37 41
38protected: 42protected:
39 RecMail*parse_list_result(mailimap_msg_att*); 43 RecMail*parse_list_result(mailimap_msg_att*);
40 void login(); 44 void login();
41 void logout(); 45 void logout();
42 46
43 virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); 47 virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc="");
44 virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); 48 virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call);
45 49
46 void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); 50 void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body);
47 void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>()); 51 void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>());
48 52
49 void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); 53 void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description);
50 void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); 54 void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which);
51 void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); 55 void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which);
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp
index 6479783..9398823 100644
--- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp
@@ -15,34 +15,34 @@ Attachment::Attachment( DocLnk lnk )
15 doc = lnk; 15 doc = lnk;
16 size = QFileInfo( doc.file() ).size(); 16 size = QFileInfo( doc.file() ).size();
17} 17}
18 18
19Folder::Folder(const QString&tmp_name, const QString&sep ) 19Folder::Folder(const QString&tmp_name, const QString&sep )
20{ 20{
21 name = tmp_name; 21 name = tmp_name;
22 nameDisplay = name; 22 nameDisplay = name;
23 separator = sep; 23 separator = sep;
24} 24}
25 25
26const QString& Folder::Separator()const 26const QString& Folder::Separator()const
27{ 27{
28 return separator; 28 return separator;
29} 29}
30 30
31IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,const QString&prefix ) 31IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,bool no_inf, const QString&prefix )
32 : Folder( name,sep ),m_MaySelect(select) 32 : Folder( name,sep ),m_MaySelect(select),m_NoInferior(no_inf)
33{ 33{
34 // Decode IMAP foldername 34 // Decode IMAP foldername
35 nameDisplay = IMAPFolder::decodeFolderName( name ); 35 nameDisplay = IMAPFolder::decodeFolderName( name );
36 qDebug( "folder " + name + " - displayed as " + nameDisplay ); 36 qDebug( "folder " + name + " - displayed as " + nameDisplay );
37 37
38 if (prefix.length()>0) { 38 if (prefix.length()>0) {
39 if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) { 39 if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) {
40 nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length()); 40 nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length());
41 } 41 }
42 } 42 }
43} 43}
44 44
45static unsigned char base64chars[] = 45static unsigned char base64chars[] =
46 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,"; 46 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,";
47 47
48/** 48/**
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.h b/noncore/net/mail/libmailwrapper/mailwrapper.h
index 8fd886f..a60777d 100644
--- a/noncore/net/mail/libmailwrapper/mailwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mailwrapper.h
@@ -56,36 +56,37 @@ public:
56 const QString&getReply()const{ return reply; } 56 const QString&getReply()const{ return reply; }
57 void setReply( const QString&a ) { reply = a; } 57 void setReply( const QString&a ) { reply = a; }
58 58
59private: 59private:
60 QList<Attachment> attList; 60 QList<Attachment> attList;
61 QString name, mail, to, cc, bcc, reply, subject, message; 61 QString name, mail, to, cc, bcc, reply, subject, message;
62}; 62};
63 63
64class Folder : public QObject 64class Folder : public QObject
65{ 65{
66 Q_OBJECT 66 Q_OBJECT
67 67
68public: 68public:
69 Folder( const QString&init_name,const QString&sep ); 69 Folder( const QString&init_name,const QString&sep );
70 const QString&getDisplayName()const { return nameDisplay; } 70 const QString&getDisplayName()const { return nameDisplay; }
71 const QString&getName()const { return name; } 71 const QString&getName()const { return name; }
72 virtual bool may_select()const{return true;}; 72 virtual bool may_select()const{return true;}
73 virtual bool no_inferior()const{return true;}
73 const QString&Separator()const; 74 const QString&Separator()const;
74 75
75protected: 76protected:
76 QString nameDisplay, name, separator; 77 QString nameDisplay, name, separator;
77 78
78}; 79};
79 80
80class IMAPFolder : public Folder 81class IMAPFolder : public Folder
81{ 82{
82 public: 83 public:
83 IMAPFolder(const QString&name, const QString&sep, bool select=true,const QString&prefix="" ); 84 IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" );
84 virtual bool may_select()const{return m_MaySelect;} 85 virtual bool may_select()const{return m_MaySelect;}
86 virtual bool no_inferior()const{return m_NoInferior;}
85 private: 87 private:
86 static QString decodeFolderName( const QString &name ); 88 static QString decodeFolderName( const QString &name );
87 bool m_MaySelect; 89 bool m_MaySelect,m_NoInferior;
88
89}; 90};
90 91
91#endif 92#endif
diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro
index ea5fb58..2c15a7b 100644
--- a/noncore/net/mail/mail.pro
+++ b/noncore/net/mail/mail.pro
@@ -2,72 +2,75 @@ CONFIG += qt warn_on debug quick-app
2 2
3HEADERS = defines.h \ 3HEADERS = defines.h \
4 logindialog.h \ 4 logindialog.h \
5 settings.h \ 5 settings.h \
6 editaccounts.h \ 6 editaccounts.h \
7 mailwrapper.h \ 7 mailwrapper.h \
8 composemail.h \ 8 composemail.h \
9 accountview.h \ 9 accountview.h \
10 mainwindow.h \ 10 mainwindow.h \
11 viewmail.h \ 11 viewmail.h \
12 viewmailbase.h \ 12 viewmailbase.h \
13 opiemail.h \ 13 opiemail.h \
14 imapwrapper.h \ 14 imapwrapper.h \
15 mailtypes.h \ 15 mailtypes.h \
16 mailistviewitem.h \ 16 mailistviewitem.h \
17 pop3wrapper.h \ 17 pop3wrapper.h \
18 abstractmail.h \ 18 abstractmail.h \
19 settingsdialog.h \ 19 settingsdialog.h \
20 statuswidget.h \ 20 statuswidget.h \
21 smtpwrapper.h \ 21 smtpwrapper.h \
22 genericwrapper.h \ 22 genericwrapper.h \
23 mboxwrapper.h \ 23 mboxwrapper.h \
24 sendmailprogress.h 24 sendmailprogress.h \
25 newmaildir.h
25 26
26SOURCES = main.cpp \ 27SOURCES = main.cpp \
27 opiemail.cpp \ 28 opiemail.cpp \
28 mainwindow.cpp \ 29 mainwindow.cpp \
29 accountview.cpp \ 30 accountview.cpp \
30 composemail.cpp \ 31 composemail.cpp \
31 mailwrapper.cpp \ 32 mailwrapper.cpp \
32 imapwrapper.cpp \ 33 imapwrapper.cpp \
33 addresspicker.cpp \ 34 addresspicker.cpp \
34 editaccounts.cpp \ 35 editaccounts.cpp \
35 logindialog.cpp \ 36 logindialog.cpp \
36 viewmail.cpp \ 37 viewmail.cpp \
37 viewmailbase.cpp \ 38 viewmailbase.cpp \
38 settings.cpp \ 39 settings.cpp \
39 mailtypes.cpp \ 40 mailtypes.cpp \
40 pop3wrapper.cpp \ 41 pop3wrapper.cpp \
41 abstractmail.cpp \ 42 abstractmail.cpp \
42 settingsdialog.cpp \ 43 settingsdialog.cpp \
43 statuswidget.cpp \ 44 statuswidget.cpp \
44 smtpwrapper.cpp \ 45 smtpwrapper.cpp \
45 genericwrapper.cpp \ 46 genericwrapper.cpp \
46 mboxwrapper.cpp \ 47 mboxwrapper.cpp \
47 sendmailprogress.cpp 48 sendmailprogress.cpp \
49 newmaildir.cpp
48 50
49INTERFACES = editaccountsui.ui \ 51INTERFACES = editaccountsui.ui \
50 selectmailtypeui.ui \ 52 selectmailtypeui.ui \
51 imapconfigui.ui \ 53 imapconfigui.ui \
52 pop3configui.ui \ 54 pop3configui.ui \
53 nntpconfigui.ui \ 55 nntpconfigui.ui \
54 smtpconfigui.ui \ 56 smtpconfigui.ui \
55 addresspickerui.ui \ 57 addresspickerui.ui \
56 logindialogui.ui \ 58 logindialogui.ui \
57 composemailui.ui \ 59 composemailui.ui \
58 settingsdialogui.ui \ 60 settingsdialogui.ui \
59 statuswidgetui.ui \ 61 statuswidgetui.ui \
60 sendmailprogressui.ui 62 sendmailprogressui.ui \
63 newmaildirui.ui
61 64
62INCLUDEPATH += $(OPIEDIR)/include 65INCLUDEPATH += $(OPIEDIR)/include
63 66
64CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) 67CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX )
65contains( CONFTEST, y ){ 68contains( CONFTEST, y ){
66 LIBS += -lqpe -letpan -lssl -lcrypto -lopie -liconv 69 LIBS += -lqpe -letpan -lssl -lcrypto -lopie -liconv
67}else{ 70}else{
68 LIBS += -lqpe -letpan -lssl -lcrypto -lopie 71 LIBS += -lqpe -letpan -lssl -lcrypto -lopie
69} 72}
70 73
71TARGET = opiemail 74TARGET = opiemail
72 75
73include ( $(OPIEDIR)/include.pro ) 76include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/net/mail/mailwrapper.cpp b/noncore/net/mail/mailwrapper.cpp
index 6479783..9398823 100644
--- a/noncore/net/mail/mailwrapper.cpp
+++ b/noncore/net/mail/mailwrapper.cpp
@@ -15,34 +15,34 @@ Attachment::Attachment( DocLnk lnk )
15 doc = lnk; 15 doc = lnk;
16 size = QFileInfo( doc.file() ).size(); 16 size = QFileInfo( doc.file() ).size();
17} 17}
18 18
19Folder::Folder(const QString&tmp_name, const QString&sep ) 19Folder::Folder(const QString&tmp_name, const QString&sep )
20{ 20{
21 name = tmp_name; 21 name = tmp_name;
22 nameDisplay = name; 22 nameDisplay = name;
23 separator = sep; 23 separator = sep;
24} 24}
25 25
26const QString& Folder::Separator()const 26const QString& Folder::Separator()const
27{ 27{
28 return separator; 28 return separator;
29} 29}
30 30
31IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,const QString&prefix ) 31IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,bool no_inf, const QString&prefix )
32 : Folder( name,sep ),m_MaySelect(select) 32 : Folder( name,sep ),m_MaySelect(select),m_NoInferior(no_inf)
33{ 33{
34 // Decode IMAP foldername 34 // Decode IMAP foldername
35 nameDisplay = IMAPFolder::decodeFolderName( name ); 35 nameDisplay = IMAPFolder::decodeFolderName( name );
36 qDebug( "folder " + name + " - displayed as " + nameDisplay ); 36 qDebug( "folder " + name + " - displayed as " + nameDisplay );
37 37
38 if (prefix.length()>0) { 38 if (prefix.length()>0) {
39 if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) { 39 if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) {
40 nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length()); 40 nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length());
41 } 41 }
42 } 42 }
43} 43}
44 44
45static unsigned char base64chars[] = 45static unsigned char base64chars[] =
46 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,"; 46 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,";
47 47
48/** 48/**
diff --git a/noncore/net/mail/mailwrapper.h b/noncore/net/mail/mailwrapper.h
index 8fd886f..a60777d 100644
--- a/noncore/net/mail/mailwrapper.h
+++ b/noncore/net/mail/mailwrapper.h
@@ -56,36 +56,37 @@ public:
56 const QString&getReply()const{ return reply; } 56 const QString&getReply()const{ return reply; }
57 void setReply( const QString&a ) { reply = a; } 57 void setReply( const QString&a ) { reply = a; }
58 58
59private: 59private:
60 QList<Attachment> attList; 60 QList<Attachment> attList;
61 QString name, mail, to, cc, bcc, reply, subject, message; 61 QString name, mail, to, cc, bcc, reply, subject, message;
62}; 62};
63 63
64class Folder : public QObject 64class Folder : public QObject
65{ 65{
66 Q_OBJECT 66 Q_OBJECT
67 67
68public: 68public:
69 Folder( const QString&init_name,const QString&sep ); 69 Folder( const QString&init_name,const QString&sep );
70 const QString&getDisplayName()const { return nameDisplay; } 70 const QString&getDisplayName()const { return nameDisplay; }
71 const QString&getName()const { return name; } 71 const QString&getName()const { return name; }
72 virtual bool may_select()const{return true;}; 72 virtual bool may_select()const{return true;}
73 virtual bool no_inferior()const{return true;}
73 const QString&Separator()const; 74 const QString&Separator()const;
74 75
75protected: 76protected:
76 QString nameDisplay, name, separator; 77 QString nameDisplay, name, separator;
77 78
78}; 79};
79 80
80class IMAPFolder : public Folder 81class IMAPFolder : public Folder
81{ 82{
82 public: 83 public:
83 IMAPFolder(const QString&name, const QString&sep, bool select=true,const QString&prefix="" ); 84 IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" );
84 virtual bool may_select()const{return m_MaySelect;} 85 virtual bool may_select()const{return m_MaySelect;}
86 virtual bool no_inferior()const{return m_NoInferior;}
85 private: 87 private:
86 static QString decodeFolderName( const QString &name ); 88 static QString decodeFolderName( const QString &name );
87 bool m_MaySelect; 89 bool m_MaySelect,m_NoInferior;
88
89}; 90};
90 91
91#endif 92#endif
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index dc8c188..cf4cbe8 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -104,50 +104,44 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
104 mailView = new QListView( view ); 104 mailView = new QListView( view );
105 mailView->addColumn( tr( "" ) ); 105 mailView->addColumn( tr( "" ) );
106 mailView->addColumn( tr( "Subject" ),QListView::Manual ); 106 mailView->addColumn( tr( "Subject" ),QListView::Manual );
107 mailView->addColumn( tr( "Sender" ),QListView::Manual ); 107 mailView->addColumn( tr( "Sender" ),QListView::Manual );
108 mailView->addColumn( tr( "Size" ),QListView::Manual); 108 mailView->addColumn( tr( "Size" ),QListView::Manual);
109 mailView->addColumn( tr( "Date" )); 109 mailView->addColumn( tr( "Date" ));
110 mailView->setAllColumnsShowFocus(true); 110 mailView->setAllColumnsShowFocus(true);
111 mailView->setSorting(-1); 111 mailView->setSorting(-1);
112 112
113 statusWidget = new StatusWidget( wrapperBox ); 113 statusWidget = new StatusWidget( wrapperBox );
114 statusWidget->hide(); 114 statusWidget->hide();
115 115
116 layout->addWidget( mailView ); 116 layout->addWidget( mailView );
117 layout->setStretchFactor( folderView, 1 ); 117 layout->setStretchFactor( folderView, 1 );
118 layout->setStretchFactor( mailView, 2 ); 118 layout->setStretchFactor( mailView, 2 );
119 119
120
121 slotAdjustLayout(); 120 slotAdjustLayout();
122 121
123 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); 122 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold);
124 123 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold);
124
125 connect( mailView, SIGNAL( mouseButtonClicked(int, QListViewItem *,const QPoint&,int ) ),this, 125 connect( mailView, SIGNAL( mouseButtonClicked(int, QListViewItem *,const QPoint&,int ) ),this,
126 SLOT( mailLeftClicked( int, QListViewItem *,const QPoint&,int ) ) ); 126 SLOT( mailLeftClicked( int, QListViewItem *,const QPoint&,int ) ) );
127
128 connect( mailView, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, 127 connect( mailView, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this,
129 SLOT( mailHold( int, QListViewItem *,const QPoint&,int ) ) ); 128 SLOT( mailHold( int, QListViewItem *,const QPoint&,int ) ) );
130#if 0
131 connect( mailView, SIGNAL( rightButtonClicked( QListViewItem *,const QPoint&,int ) ),this,
132 SLOT( mailHold(QListViewItem *,const QPoint&,int) ));
133#endif
134 connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); 129 connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*)));
135 130
136 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 131 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
137
138} 132}
139 133
140 134
141void MainWindow::slotAdjustLayout() { 135void MainWindow::slotAdjustLayout() {
142 136
143 QWidget *d = QApplication::desktop(); 137 QWidget *d = QApplication::desktop();
144 138
145 if ( d->width() < d->height() ) { 139 if ( d->width() < d->height() ) {
146 layout->setDirection( QBoxLayout::TopToBottom ); 140 layout->setDirection( QBoxLayout::TopToBottom );
147 } else { 141 } else {
148 layout->setDirection( QBoxLayout::LeftToRight ); 142 layout->setDirection( QBoxLayout::LeftToRight );
149 } 143 }
150} 144}
151 145
152void MainWindow::slotAdjustColumns() 146void MainWindow::slotAdjustColumns()
153{ 147{
diff --git a/noncore/net/mail/newmaildir.cpp b/noncore/net/mail/newmaildir.cpp
new file mode 100644
index 0000000..3fc66f4
--- a/dev/null
+++ b/noncore/net/mail/newmaildir.cpp
@@ -0,0 +1,34 @@
1#include "newmaildir.h"
2#include <qdialog.h>
3#include <qvariant.h>
4#include <qlineedit.h>
5#include <qcheckbox.h>
6
7Newmdirdlg::Newmdirdlg( QWidget* parent, const char* name)
8 : Newmdirdlgui(parent,name,true),ndir(""),possible_subs(false)
9{
10}
11
12Newmdirdlg::~Newmdirdlg()
13{
14}
15
16void Newmdirdlg::accept()
17{
18 ndir = dirnameEdit->text();
19 possible_subs = subdirsPossibleBox->isChecked();
20 if (ndir.isEmpty()) {
21 return;
22 }
23 Newmdirdlgui::accept();
24}
25
26const QString&Newmdirdlg::Newdir()const
27{
28 return ndir;
29}
30
31const bool Newmdirdlg::subpossible()const
32{
33 return possible_subs;
34}
diff --git a/noncore/net/mail/newmaildir.h b/noncore/net/mail/newmaildir.h
new file mode 100644
index 0000000..1eb904e
--- a/dev/null
+++ b/noncore/net/mail/newmaildir.h
@@ -0,0 +1,20 @@
1#include "newmaildirui.h"
2#include <qvariant.h>
3
4class Newmdirdlg : public Newmdirdlgui
5{
6 Q_OBJECT
7public:
8 Newmdirdlg( QWidget* parent = 0, const char* name = 0);
9 ~Newmdirdlg();
10
11 const QString&Newdir()const;
12 const bool subpossible()const;
13
14protected slots:
15 virtual void accept();
16
17protected:
18 QString ndir;
19 bool possible_subs;
20};
diff --git a/noncore/net/mail/newmaildirui.ui b/noncore/net/mail/newmaildirui.ui
new file mode 100644
index 0000000..72b2d04
--- a/dev/null
+++ b/noncore/net/mail/newmaildirui.ui
@@ -0,0 +1,100 @@
1<!DOCTYPE UI><UI>
2<class>Newmdirdlgui</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>newmdirdlg</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>223</width>
15 <height>110</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Enter directory name</string>
21 </property>
22 <vbox>
23 <property stdset="1">
24 <name>margin</name>
25 <number>11</number>
26 </property>
27 <property stdset="1">
28 <name>spacing</name>
29 <number>6</number>
30 </property>
31 <widget>
32 <class>QLayoutWidget</class>
33 <property stdset="1">
34 <name>name</name>
35 <cstring>Layout5</cstring>
36 </property>
37 <grid>
38 <property stdset="1">
39 <name>margin</name>
40 <number>0</number>
41 </property>
42 <property stdset="1">
43 <name>spacing</name>
44 <number>6</number>
45 </property>
46 <widget row="0" column="0" >
47 <class>QLabel</class>
48 <property stdset="1">
49 <name>name</name>
50 <cstring>dirnameLabel</cstring>
51 </property>
52 <property stdset="1">
53 <name>text</name>
54 <string>Directory name:</string>
55 </property>
56 </widget>
57 <widget row="0" column="1" >
58 <class>QLineEdit</class>
59 <property stdset="1">
60 <name>name</name>
61 <cstring>dirnameEdit</cstring>
62 </property>
63 </widget>
64 </grid>
65 </widget>
66 <widget>
67 <class>QCheckBox</class>
68 <property stdset="1">
69 <name>name</name>
70 <cstring>subdirsPossibleBox</cstring>
71 </property>
72 <property stdset="1">
73 <name>text</name>
74 <string>Directory contains other subdirs</string>
75 </property>
76 </widget>
77 <spacer>
78 <property>
79 <name>name</name>
80 <cstring>Spacer4</cstring>
81 </property>
82 <property stdset="1">
83 <name>orientation</name>
84 <enum>Vertical</enum>
85 </property>
86 <property stdset="1">
87 <name>sizeType</name>
88 <enum>Expanding</enum>
89 </property>
90 <property>
91 <name>sizeHint</name>
92 <size>
93 <width>20</width>
94 <height>20</height>
95 </size>
96 </property>
97 </spacer>
98 </vbox>
99</widget>
100</UI>