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
@@ -28,6 +28,15 @@ public:
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);
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
@@ -2,11 +2,13 @@
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{
@@ -128,7 +130,12 @@ IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start
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();
@@ -164,18 +171,61 @@ void IMAPviewItem::refresh(QList<RecMail>&)
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();
@@ -212,6 +262,11 @@ IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QLi
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;
@@ -219,8 +274,11 @@ bool IMAPfolderItem::matchName(const QString&name)const
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)
@@ -228,6 +286,90 @@ RecBody IMAPfolderItem::fetchBody(const RecMail&aMail)
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
@@ -237,10 +379,33 @@ AccountView::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();
@@ -277,6 +442,7 @@ void AccountView::refresh(QListViewItem *item) {
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);
@@ -378,4 +544,3 @@ RecBody 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
@@ -11,6 +11,7 @@
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{
@@ -21,6 +22,8 @@ public:
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
@@ -55,16 +58,20 @@ class 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;
@@ -81,6 +88,14 @@ public:
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;
@@ -126,10 +141,12 @@ public:
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
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,7 +1,6 @@
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"
@@ -71,7 +70,7 @@ void IMAPwrapper::login()
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;
@@ -80,7 +79,7 @@ void IMAPwrapper::login()
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;
@@ -115,15 +114,17 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
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!!!! */
@@ -155,7 +156,7 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
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}
@@ -166,6 +167,8 @@ QList<Folder>* IMAPwrapper::listFolders()
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 );
@@ -184,6 +187,8 @@ QList<Folder>* IMAPwrapper::listFolders()
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-- ) {
@@ -192,8 +197,17 @@ QList<Folder>* IMAPwrapper::listFolders()
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);
@@ -207,12 +221,11 @@ QList<Folder>* IMAPwrapper::listFolders()
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!
@@ -224,9 +237,14 @@ QList<Folder>* IMAPwrapper::listFolders()
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);
@@ -818,3 +836,87 @@ encodedString* 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
@@ -27,12 +27,16 @@ public:
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:
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
@@ -28,6 +28,15 @@ public:
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);
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,7 +1,6 @@
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"
@@ -71,7 +70,7 @@ void IMAPwrapper::login()
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;
@@ -80,7 +79,7 @@ void IMAPwrapper::login()
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;
@@ -115,15 +114,17 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
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!!!! */
@@ -155,7 +156,7 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
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}
@@ -166,6 +167,8 @@ QList<Folder>* IMAPwrapper::listFolders()
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 );
@@ -184,6 +187,8 @@ QList<Folder>* IMAPwrapper::listFolders()
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-- ) {
@@ -192,8 +197,17 @@ QList<Folder>* IMAPwrapper::listFolders()
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);
@@ -207,12 +221,11 @@ QList<Folder>* IMAPwrapper::listFolders()
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!
@@ -224,9 +237,14 @@ QList<Folder>* IMAPwrapper::listFolders()
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);
@@ -818,3 +836,87 @@ encodedString* 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
@@ -27,12 +27,16 @@ public:
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:
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
@@ -28,8 +28,8 @@ const QString& Folder::Separator()const
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 );
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
@@ -69,7 +69,8 @@ public:
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:
@@ -80,12 +81,12 @@ protected:
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
@@ -15,13 +15,14 @@ HEADERS = defines.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 \
@@ -38,13 +39,14 @@ SOURCES = main.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 \
@@ -55,9 +57,10 @@ INTERFACES = editaccountsui.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
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
@@ -28,8 +28,8 @@ const QString& Folder::Separator()const
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 );
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
@@ -69,7 +69,8 @@ public:
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:
@@ -80,12 +81,12 @@ protected:
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
@@ -117,24 +117,18 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
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
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>