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
@@ -23,16 +23,25 @@ public:
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);
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,17 +1,19 @@
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 );
@@ -123,17 +125,22 @@ IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start
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 }
@@ -159,28 +166,71 @@ void IMAPviewItem::refresh(QList<RecMail>&)
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;
@@ -207,45 +257,160 @@ IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QLi
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;
@@ -272,16 +437,17 @@ void AccountView::refresh(QListViewItem *item) {
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
@@ -373,9 +539,8 @@ void MBOXfolderItem::refresh(QList<RecMail>&target)
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
@@ -6,26 +6,29 @@
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();
@@ -50,42 +53,54 @@ private:
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
@@ -121,20 +136,22 @@ class AccountView : public QListView
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,12 +1,11 @@
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{
@@ -66,26 +65,26 @@ void IMAPwrapper::login()
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{
@@ -110,25 +109,27 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
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());
@@ -150,27 +151,29 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
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
@@ -179,59 +182,74 @@ QList<Folder>* IMAPwrapper::listFolders()
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
@@ -813,8 +831,92 @@ encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&pa
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
@@ -22,22 +22,26 @@ class IMAPwrapper : public AbstractMail
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="");
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
@@ -23,16 +23,25 @@ public:
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);
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,12 +1,11 @@
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{
@@ -66,26 +65,26 @@ void IMAPwrapper::login()
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{
@@ -110,25 +109,27 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
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());
@@ -150,27 +151,29 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
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
@@ -179,59 +182,74 @@ QList<Folder>* IMAPwrapper::listFolders()
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
@@ -813,8 +831,92 @@ encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&pa
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
@@ -22,22 +22,26 @@ class IMAPwrapper : public AbstractMail
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="");
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
@@ -23,18 +23,18 @@ Folder::Folder(const QString&tmp_name, const QString&sep )
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());
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
@@ -64,28 +64,29 @@ private:
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
@@ -10,59 +10,62 @@ HEADERS = defines.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
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
@@ -23,18 +23,18 @@ Folder::Folder(const QString&tmp_name, const QString&sep )
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());
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
@@ -64,28 +64,29 @@ private:
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
@@ -112,34 +112,28 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
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() ) {
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>