summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-07 23:12:51 (UTC)
committer alwin <alwin>2005-03-07 23:12:51 (UTC)
commit2ba21de3fce9ca9fe9a70474a1927f0106d1d7ce (patch) (unidiff)
treed0ff8c035e34a83fbc935c8f3f6ab926ed432559
parenta1fab1e1abd009a6a64c7ea3957bdb5587f4be81 (diff)
downloadopie-2ba21de3fce9ca9fe9a70474a1927f0106d1d7ce.zip
opie-2ba21de3fce9ca9fe9a70474a1927f0106d1d7ce.tar.gz
opie-2ba21de3fce9ca9fe9a70474a1927f0106d1d7ce.tar.bz2
beauty
hopefull some speedups obsolete stuff removed fixed a crasher
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp1
-rw-r--r--noncore/net/mail/mail.pro3
-rw-r--r--noncore/net/mail/mainwindow.cpp16
-rw-r--r--noncore/net/mail/mainwindow.h2
-rw-r--r--noncore/net/mail/opiemail.cpp12
-rw-r--r--noncore/net/mail/statuswidget.cpp33
-rw-r--r--noncore/net/mail/statuswidget.h24
-rw-r--r--noncore/net/mail/statuswidgetui.ui71
-rw-r--r--noncore/net/mail/viewmail.cpp37
-rw-r--r--noncore/net/mail/viewmail.h4
10 files changed, 44 insertions, 159 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index 0fe8475..c747a8b 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -1,158 +1,157 @@
1 1
2#include "accountview.h" 2#include "accountview.h"
3#include "accountitem.h" 3#include "accountitem.h"
4#include "selectstore.h" 4#include "selectstore.h"
5 5
6#include <libmailwrapper/settings.h> 6#include <libmailwrapper/settings.h>
7#include <libmailwrapper/mailwrapper.h> 7#include <libmailwrapper/mailwrapper.h>
8#include <libmailwrapper/mailtypes.h> 8#include <libmailwrapper/mailtypes.h>
9#include <libmailwrapper/abstractmail.h> 9#include <libmailwrapper/abstractmail.h>
10 10
11/* OPIE */ 11/* OPIE */
12#include <opie2/odebug.h> 12#include <opie2/odebug.h>
13#include <qpe/qpeapplication.h> 13#include <qpe/qpeapplication.h>
14 14
15/* QT */ 15/* QT */
16#include <qmessagebox.h> 16#include <qmessagebox.h>
17#include <qpopupmenu.h> 17#include <qpopupmenu.h>
18 18
19using namespace Opie::Core; 19using namespace Opie::Core;
20AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) 20AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
21 : QListView( parent, name, flags ) 21 : QListView( parent, name, flags )
22{ 22{
23 connect( this, SIGNAL( selectionChanged(QListViewItem*) ), 23 connect( this, SIGNAL( selectionChanged(QListViewItem*) ),
24 SLOT( refresh(QListViewItem*) ) ); 24 SLOT( refresh(QListViewItem*) ) );
25 connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, 25 connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
26 SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); 26 SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) );
27 setSorting(0); 27 setSorting(0);
28} 28}
29 29
30AccountView::~AccountView() 30AccountView::~AccountView()
31{ 31{
32 imapAccounts.clear(); 32 imapAccounts.clear();
33 mhAccounts.clear(); 33 mhAccounts.clear();
34} 34}
35 35
36void AccountView::slotContextMenu(int id) 36void AccountView::slotContextMenu(int id)
37{ 37{
38 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); 38 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
39 if (!view) return; 39 if (!view) return;
40 view->contextMenuSelected(id); 40 view->contextMenuSelected(id);
41} 41}
42 42
43void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) 43void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int)
44{ 44{
45 if (button==1) {return;} 45 if (button==1) {return;}
46 if (!item) return; 46 if (!item) return;
47 AccountViewItem *view = static_cast<AccountViewItem *>(item); 47 AccountViewItem *view = static_cast<AccountViewItem *>(item);
48 QPopupMenu*m = view->getContextMenu(); 48 QPopupMenu*m = view->getContextMenu();
49 if (!m) return; 49 if (!m) return;
50 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); 50 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int)));
51 m->setFocus(); 51 m->setFocus();
52 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 52 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
53 delete m; 53 delete m;
54} 54}
55 55
56void AccountView::populate( QList<Account> list ) 56void AccountView::populate( QList<Account> list )
57{ 57{
58 clear(); 58 clear();
59 59
60 imapAccounts.clear(); 60 imapAccounts.clear();
61 mhAccounts.clear(); 61 mhAccounts.clear();
62
63 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); 62 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this));
64 63
65 Account *it; 64 Account *it;
66 for ( it = list.first(); it; it = list.next() ) { 65 for ( it = list.first(); it; it = list.next() ) {
67 if ( it->getType() == MAILLIB::A_IMAP ) { 66 if ( it->getType() == MAILLIB::A_IMAP ) {
68 IMAPaccount *imap = static_cast<IMAPaccount *>(it); 67 IMAPaccount *imap = static_cast<IMAPaccount *>(it);
69 odebug << "added IMAP " + imap->getAccountName() << oendl; 68 odebug << "added IMAP " + imap->getAccountName() << oendl;
70 imapAccounts.append(new IMAPviewItem( imap, this )); 69 imapAccounts.append(new IMAPviewItem( imap, this ));
71 } else if ( it->getType() == MAILLIB::A_POP3 ) { 70 } else if ( it->getType() == MAILLIB::A_POP3 ) {
72 POP3account *pop3 = static_cast<POP3account *>(it); 71 POP3account *pop3 = static_cast<POP3account *>(it);
73 odebug << "added POP3 " + pop3->getAccountName() << oendl; 72 odebug << "added POP3 " + pop3->getAccountName() << oendl;
74 /* must not be hold 'cause it isn't required */ 73 /* must not be hold 'cause it isn't required */
75 (void) new POP3viewItem( pop3, this ); 74 (void) new POP3viewItem( pop3, this );
76 } else if ( it->getType() == MAILLIB::A_NNTP ) { 75 } else if ( it->getType() == MAILLIB::A_NNTP ) {
77 NNTPaccount *nntp = static_cast<NNTPaccount *>(it); 76 NNTPaccount *nntp = static_cast<NNTPaccount *>(it);
78 odebug << "added NNTP " + nntp->getAccountName() << oendl; 77 odebug << "added NNTP " + nntp->getAccountName() << oendl;
79 /* must not be hold 'cause it isn't required */ 78 /* must not be hold 'cause it isn't required */
80 (void) new NNTPviewItem( nntp, this ); 79 (void) new NNTPviewItem( nntp, this );
81 } else if ( it->getType() == MAILLIB::A_MH ) { 80 } else if ( it->getType() == MAILLIB::A_MH ) {
82 } 81 }
83 } 82 }
84} 83}
85 84
86void AccountView::refresh(QListViewItem *item) 85void AccountView::refresh(QListViewItem *item)
87{ 86{
88 87
89 odebug << "AccountView refresh..." << oendl; 88 odebug << "AccountView refresh..." << oendl;
90 if ( item ) 89 if ( item )
91 { 90 {
92 m_currentItem = item; 91 m_currentItem = item;
93 QValueList<RecMailP> headerlist; 92 QValueList<RecMailP> headerlist;
94 AccountViewItem *view = static_cast<AccountViewItem *>(item); 93 AccountViewItem *view = static_cast<AccountViewItem *>(item);
95 view->refresh(headerlist); 94 view->refresh(headerlist);
96 emit refreshMailview(headerlist); 95 emit refreshMailview(headerlist);
97 } 96 }
98} 97}
99 98
100void AccountView::refreshCurrent() 99void AccountView::refreshCurrent()
101{ 100{
102 m_currentItem = currentItem(); 101 m_currentItem = currentItem();
103 if ( !m_currentItem ) return; 102 if ( !m_currentItem ) return;
104 QValueList<RecMailP> headerlist; 103 QValueList<RecMailP> headerlist;
105 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); 104 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
106 view->refresh(headerlist); 105 view->refresh(headerlist);
107 emit refreshMailview(headerlist); 106 emit refreshMailview(headerlist);
108} 107}
109 108
110void AccountView::refreshAll() 109void AccountView::refreshAll()
111{ 110{
112} 111}
113 112
114RecBodyP AccountView::fetchBody(const RecMailP&aMail) 113RecBodyP AccountView::fetchBody(const RecMailP&aMail)
115{ 114{
116 QListViewItem*item = selectedItem (); 115 QListViewItem*item = selectedItem ();
117 if (!item) return new RecBody(); 116 if (!item) return new RecBody();
118 AccountViewItem *view = static_cast<AccountViewItem *>(item); 117 AccountViewItem *view = static_cast<AccountViewItem *>(item);
119 return view->fetchBody(aMail); 118 return view->fetchBody(aMail);
120} 119}
121 120
122void AccountView::setupFolderselect(Selectstore*sels) 121void AccountView::setupFolderselect(Selectstore*sels)
123{ 122{
124 QPEApplication::showDialog( sels ); 123 QPEApplication::showDialog( sels );
125 QStringList sFolders; 124 QStringList sFolders;
126 unsigned int i = 0; 125 unsigned int i = 0;
127 for (i=0; i < mhAccounts.count();++i) 126 for (i=0; i < mhAccounts.count();++i)
128 { 127 {
129 mhAccounts[i]->refresh(false); 128 mhAccounts[i]->refresh(false);
130 sFolders = mhAccounts[i]->subFolders(); 129 sFolders = mhAccounts[i]->subFolders();
131 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); 130 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders);
132 } 131 }
133 for (i=0; i < imapAccounts.count();++i) 132 for (i=0; i < imapAccounts.count();++i)
134 { 133 {
135 if (imapAccounts[i]->offline()) 134 if (imapAccounts[i]->offline())
136 continue; 135 continue;
137 imapAccounts[i]->refreshFolders(false); 136 imapAccounts[i]->refreshFolders(false);
138 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); 137 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders());
139 } 138 }
140} 139}
141 140
142void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) 141void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper)
143{ 142{
144 AbstractMail*targetMail = 0; 143 AbstractMail*targetMail = 0;
145 QString targetFolder = ""; 144 QString targetFolder = "";
146 Selectstore sels; 145 Selectstore sels;
147 setupFolderselect(&sels); 146 setupFolderselect(&sels);
148 if (!sels.exec()) return; 147 if (!sels.exec()) return;
149 targetMail = sels.currentMail(); 148 targetMail = sels.currentMail();
150 targetFolder = sels.currentFolder(); 149 targetFolder = sels.currentFolder();
151 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || 150 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
152 targetFolder.isEmpty()) 151 targetFolder.isEmpty())
153 { 152 {
154 return; 153 return;
155 } 154 }
156 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 155 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
157 { 156 {
158 QMessageBox::critical(0,tr("Error creating new Folder"), 157 QMessageBox::critical(0,tr("Error creating new Folder"),
diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro
index e394bbf..a1de8b5 100644
--- a/noncore/net/mail/mail.pro
+++ b/noncore/net/mail/mail.pro
@@ -1,72 +1,69 @@
1CONFIG += qt warn_on quick-app 1CONFIG += qt warn_on quick-app
2 2
3HEADERS = defines.h \ 3HEADERS = defines.h \
4 editaccounts.h \ 4 editaccounts.h \
5 composemail.h \ 5 composemail.h \
6 accountview.h \ 6 accountview.h \
7 accountitem.h \ 7 accountitem.h \
8 mainwindow.h \ 8 mainwindow.h \
9 viewmail.h \ 9 viewmail.h \
10 viewmailbase.h \ 10 viewmailbase.h \
11 opiemail.h \ 11 opiemail.h \
12 mailistviewitem.h \ 12 mailistviewitem.h \
13 settingsdialog.h \ 13 settingsdialog.h \
14 statuswidget.h \
15 newmaildir.h \ 14 newmaildir.h \
16 selectstore.h \ 15 selectstore.h \
17 selectsmtp.h \ 16 selectsmtp.h \
18 nntpgroups.h \ 17 nntpgroups.h \
19 nntpgroupsdlg.h 18 nntpgroupsdlg.h
20 19
21SOURCES = main.cpp \ 20SOURCES = main.cpp \
22 opiemail.cpp \ 21 opiemail.cpp \
23 mainwindow.cpp \ 22 mainwindow.cpp \
24 accountview.cpp \ 23 accountview.cpp \
25 accountitem.cpp \ 24 accountitem.cpp \
26 composemail.cpp \ 25 composemail.cpp \
27 addresspicker.cpp \ 26 addresspicker.cpp \
28 editaccounts.cpp \ 27 editaccounts.cpp \
29 viewmail.cpp \ 28 viewmail.cpp \
30 viewmailbase.cpp \ 29 viewmailbase.cpp \
31 mailistviewitem.cpp \ 30 mailistviewitem.cpp \
32 settingsdialog.cpp \ 31 settingsdialog.cpp \
33 statuswidget.cpp \
34 newmaildir.cpp \ 32 newmaildir.cpp \
35 selectstore.cpp \ 33 selectstore.cpp \
36 selectsmtp.cpp \ 34 selectsmtp.cpp \
37 nntpgroups.cpp \ 35 nntpgroups.cpp \
38 nntpgroupsdlg.cpp 36 nntpgroupsdlg.cpp
39 37
40INTERFACES = editaccountsui.ui \ 38INTERFACES = editaccountsui.ui \
41 selectmailtypeui.ui \ 39 selectmailtypeui.ui \
42 imapconfigui.ui \ 40 imapconfigui.ui \
43 pop3configui.ui \ 41 pop3configui.ui \
44 nntpconfigui.ui \ 42 nntpconfigui.ui \
45 smtpconfigui.ui \ 43 smtpconfigui.ui \
46 addresspickerui.ui \ 44 addresspickerui.ui \
47 composemailui.ui \ 45 composemailui.ui \
48 settingsdialogui.ui \ 46 settingsdialogui.ui \
49 statuswidgetui.ui \
50 newmaildirui.ui \ 47 newmaildirui.ui \
51 selectstoreui.ui \ 48 selectstoreui.ui \
52 nntpgroupsui.ui 49 nntpgroupsui.ui
53 50
54 51
55INCLUDEPATH += $(OPIEDIR)/include /usr/local/include 52INCLUDEPATH += $(OPIEDIR)/include /usr/local/include
56 53
57CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) 54CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX )
58contains( CONFTEST, y ){ 55contains( CONFTEST, y ){
59 LIBS += -lqpe -lopieui2 -lopiecore2 -lopiepim2 -lmailwrapper -liconv -lopiemm2 56 LIBS += -lqpe -lopieui2 -lopiecore2 -lopiepim2 -lmailwrapper -liconv -lopiemm2
60}else{ 57}else{
61 LIBS += -lqpe -lopieui2 -lopiecore2 -lopiepim2 -lmailwrapper -lopiemm2 58 LIBS += -lqpe -lopieui2 -lopiecore2 -lopiepim2 -lmailwrapper -lopiemm2
62} 59}
63 60
64TARGET = opiemail 61TARGET = opiemail
65 62
66include( $(OPIEDIR)/include.pro ) 63include( $(OPIEDIR)/include.pro )
67!isEmpty( LIBETPAN_INC_DIR ) { 64!isEmpty( LIBETPAN_INC_DIR ) {
68 INCLUDEPATH = $$LIBETPAN_INC_DIR $$INCLUDEPATH 65 INCLUDEPATH = $$LIBETPAN_INC_DIR $$INCLUDEPATH
69} 66}
70!isEmpty( LIBETPAN_LIB_DIR ) { 67!isEmpty( LIBETPAN_LIB_DIR ) {
71 LIBS = -Wl,-rpath-link,$$LIBETPAN_LIB_DIR $$LIBS 68 LIBS = -Wl,-rpath-link,$$LIBETPAN_LIB_DIR $$LIBS
72} 69}
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index 93d80d9..0a45445 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -1,237 +1,235 @@
1#include <qlabel.h> 1#include <qlabel.h>
2#include <qvbox.h> 2#include <qvbox.h>
3#include <qheader.h> 3#include <qheader.h>
4#include <qtimer.h> 4#include <qtimer.h>
5#include <qlayout.h> 5#include <qlayout.h>
6 6
7#include <opie2/odebug.h> 7#include <opie2/odebug.h>
8#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
9#include <qpe/qcopenvelope_qws.h> 9#include <qpe/qcopenvelope_qws.h>
10 10
11#include "defines.h" 11#include "defines.h"
12#include "mainwindow.h" 12#include "mainwindow.h"
13 13
14using namespace Opie::Core; 14using namespace Opie::Core;
15 15
16MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 16MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
17 : QMainWindow( parent, name, flags ) 17 : QMainWindow( parent, name, flags )
18{ 18{
19 19
20 setCaption( tr( "Mail" ) ); 20 setCaption( tr( "Mail" ) );
21 setToolBarsMovable( false ); 21 setToolBarsMovable( false );
22 22
23 toolBar = new QToolBar( this ); 23 toolBar = new QToolBar( this );
24 menuBar = new QMenuBar( toolBar ); 24 menuBar = new QMenuBar( toolBar );
25 mailMenu = new QPopupMenu( menuBar ); 25 mailMenu = new QPopupMenu( menuBar );
26 menuBar->insertItem( tr( "Mail" ), mailMenu ); 26 menuBar->insertItem( tr( "Mail" ), mailMenu );
27 settingsMenu = new QPopupMenu( menuBar ); 27 settingsMenu = new QPopupMenu( menuBar );
28 menuBar->insertItem( tr( "Settings" ), settingsMenu ); 28 menuBar->insertItem( tr( "Settings" ), settingsMenu );
29 29
30 addToolBar( toolBar ); 30 addToolBar( toolBar );
31 toolBar->setHorizontalStretchable( true ); 31 toolBar->setHorizontalStretchable( true );
32 32
33 QLabel *spacer = new QLabel( toolBar ); 33 QLabel *spacer = new QLabel( toolBar );
34 spacer->setBackgroundMode( QWidget::PaletteButton ); 34 spacer->setBackgroundMode( QWidget::PaletteButton );
35 toolBar->setStretchableWidget( spacer ); 35 toolBar->setStretchableWidget( spacer );
36 36
37 composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, 37 composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL,
38 0, 0, this ); 38 0, 0, this );
39 composeMail->addTo( toolBar ); 39 composeMail->addTo( toolBar );
40 composeMail->addTo( mailMenu ); 40 composeMail->addTo( mailMenu );
41 41
42 sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, 42 sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED,
43 0, 0, this ); 43 0, 0, this );
44 sendQueued->addTo( toolBar ); 44 sendQueued->addTo( toolBar );
45 sendQueued->addTo( mailMenu ); 45 sendQueued->addTo( mailMenu );
46 46
47 /* 47 /*
48 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, 48 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC,
49 0, 0, this ); 49 0, 0, this );
50 syncFolders->addTo( toolBar ); 50 syncFolders->addTo( toolBar );
51 syncFolders->addTo( mailMenu ); 51 syncFolders->addTo( mailMenu );
52 */ 52 */
53 53
54 showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, 54 showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS,
55 0, 0, this, 0, true ); 55 0, 0, this, 0, true );
56 showFolders->addTo( toolBar ); 56 showFolders->addTo( toolBar );
57 showFolders->addTo( mailMenu ); 57 showFolders->addTo( mailMenu );
58 showFolders->setOn( true ); 58 showFolders->setOn( true );
59 connect(showFolders, SIGNAL( toggled(bool) ), 59 connect(showFolders, SIGNAL( toggled(bool) ),
60 SLOT( slotShowFolders(bool) ) ); 60 SLOT( slotShowFolders(bool) ) );
61 61
62 /* 62 /*
63 searchMails = new QAction( tr( "Search mails" ), QIconSet( Resource::loadPixmap("find") ), 63 searchMails = new QAction( tr( "Search mails" ), QIconSet( Resource::loadPixmap("find") ),
64 0, 0, this ); 64 0, 0, this );
65 searchMails->addTo( toolBar ); 65 searchMails->addTo( toolBar );
66 searchMails->addTo( mailMenu ); 66 searchMails->addTo( mailMenu );
67 */ 67 */
68 68
69 deleteMails = new QAction(tr("Delete Mail"), QIconSet( Resource::loadPixmap("trash")), 0, 0, this); 69 deleteMails = new QAction(tr("Delete Mail"), QIconSet( Resource::loadPixmap("trash")), 0, 0, this);
70 deleteMails->addTo( toolBar ); 70 deleteMails->addTo( toolBar );
71 deleteMails->addTo( mailMenu ); 71 deleteMails->addTo( mailMenu );
72 connect( deleteMails, SIGNAL( activated() ), 72 connect( deleteMails, SIGNAL( activated() ),
73 SLOT( slotDeleteMail() ) ); 73 SLOT( slotDeleteMail() ) );
74 74
75 editSettings = new QAction( tr( "Edit settings" ), QIconSet( Resource::loadPixmap("SettingsIcon") ) , 75 editSettings = new QAction( tr( "Edit settings" ), QIconSet( Resource::loadPixmap("SettingsIcon") ) ,
76 0, 0, this ); 76 0, 0, this );
77 editSettings->addTo( settingsMenu ); 77 editSettings->addTo( settingsMenu );
78 connect( editSettings, SIGNAL( activated() ), 78 connect( editSettings, SIGNAL( activated() ),
79 SLOT( slotEditSettings() ) ); 79 SLOT( slotEditSettings() ) );
80 editAccounts = new QAction( tr( "Configure accounts" ), QIconSet( Resource::loadPixmap("mail/editaccounts") ) , 80 editAccounts = new QAction( tr( "Configure accounts" ), QIconSet( Resource::loadPixmap("mail/editaccounts") ) ,
81 0, 0, this ); 81 0, 0, this );
82 editAccounts->addTo( settingsMenu ); 82 editAccounts->addTo( settingsMenu );
83 83
84 //setCentralWidget( view );
85 84
86 QVBox* wrapperBox = new QVBox( this ); 85 QWidget *view = new QWidget( this );
87 setCentralWidget( wrapperBox ); 86 setCentralWidget( view );
88
89 QWidget *view = new QWidget( wrapperBox );
90 layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); 87 layout = new QBoxLayout ( view, QBoxLayout::LeftToRight );
91 88
92 folderView = new AccountView( view ); 89 folderView = new AccountView( view );
93 folderView->header()->hide(); 90 folderView->header()->hide();
94 folderView->setRootIsDecorated( true ); 91 folderView->setRootIsDecorated( true );
95 folderView->addColumn( tr( "Mailbox" ) ); 92 folderView->addColumn( tr( "Mailbox" ) );
96 93
97 layout->addWidget( folderView ); 94 layout->addWidget( folderView );
98 95
99 mailView = new QListView( view ); 96 mailView = new QListView( view );
100 mailView->addColumn( "" ); 97 mailView->addColumn( "" );
101 mailView->addColumn( tr( "Subject" ),QListView::Manual ); 98 mailView->addColumn( tr( "Subject" ),QListView::Manual );
102 mailView->addColumn( tr( "Sender" ),QListView::Manual ); 99 mailView->addColumn( tr( "Sender" ),QListView::Manual );
103 mailView->addColumn( tr( "Size" ),QListView::Manual); 100 mailView->addColumn( tr( "Size" ),QListView::Manual);
104 mailView->addColumn( tr( "Date" )); 101 mailView->addColumn( tr( "Date" ));
105 mailView->setAllColumnsShowFocus(true); 102 mailView->setAllColumnsShowFocus(true);
106 mailView->setShowSortIndicator(true); 103 mailView->setShowSortIndicator(true);
107 mailView->setSorting(4,false); 104 mailView->setSorting(4,false);
108 105
109 statusWidget = new StatusWidget( wrapperBox );
110 statusWidget->hide();
111
112 layout->addWidget( mailView ); 106 layout->addWidget( mailView );
113 layout->setStretchFactor( folderView, 1 ); 107 layout->setStretchFactor( folderView, 1 );
114 layout->setStretchFactor( mailView, 2 ); 108 layout->setStretchFactor( mailView, 2 );
115 109
116 m_Rotate = (QApplication::desktop()->width() > QApplication::desktop()->height()?0:90); 110 m_Rotate = (QApplication::desktop()->width() > QApplication::desktop()->height()?0:90);
117 111
118 slotAdjustLayout(); 112 slotAdjustLayout();
119 113
120 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); 114 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold);
121 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); 115 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold);
122 116
123 connect( mailView, SIGNAL( mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),this, 117 connect( mailView, SIGNAL( mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),this,
124 SLOT( mailLeftClicked(int,QListViewItem*,const QPoint&,int) ) ); 118 SLOT( mailLeftClicked(int,QListViewItem*,const QPoint&,int) ) );
125 connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, 119 connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
126 SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); 120 SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) );
121
127 connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), 122 connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)),
128 this,SLOT(refreshMailView(const QValueList<RecMailP>&))); 123 this,SLOT(refreshMailView(const QValueList<RecMailP>&)));
124
129 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); 125 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) );
130 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); 126 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) );
127
131// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); 128// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) );
132 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); 129 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) );
133 // Added by Stefan Eilers to allow starting by addressbook.. 130 // Added by Stefan Eilers to allow starting by addressbook..
134 // copied from old mail2 131 // copied from old mail2
132
135#if !defined(QT_NO_COP) 133#if !defined(QT_NO_COP)
136 connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), 134 connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ),
137 this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); 135 this, SLOT( appMessage(const QCString&,const QByteArray&) ) );
138 m_sysChannel = new QCopChannel( "QPE/System", this ); 136 m_sysChannel = new QCopChannel( "QPE/System", this );
139 connect( m_sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 137 connect( m_sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
140 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); 138 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
141#endif 139#endif
142 140
143 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 141 QTimer::singleShot( 10, this, SLOT( slotAdjustColumns() ) );
144} 142}
145 143
146MainWindow::~MainWindow() 144MainWindow::~MainWindow()
147{ 145{
148} 146}
149 147
150void MainWindow::systemMessage( const QCString& msg, const QByteArray& data ) 148void MainWindow::systemMessage( const QCString& msg, const QByteArray& data )
151{ 149{
152 int _newrotation; 150 int _newrotation;
153 QDataStream stream( data, IO_ReadOnly ); 151 QDataStream stream( data, IO_ReadOnly );
154 if ( msg == "setCurrentRotation(int)" ) 152 if ( msg == "setCurrentRotation(int)" )
155 { 153 {
156 stream >> _newrotation; 154 stream >> _newrotation;
157 if (m_Rotate != _newrotation) { 155 if (m_Rotate != _newrotation) {
158 slotAdjustLayout(); 156 slotAdjustLayout();
159 m_Rotate = _newrotation; 157 m_Rotate = _newrotation;
160 } 158 }
161 } 159 }
162} 160}
163 161
164void MainWindow::appMessage(const QCString &, const QByteArray &) 162void MainWindow::appMessage(const QCString &, const QByteArray &)
165{ 163{
166 odebug << "appMessage not reached" << oendl; 164 odebug << "appMessage not reached" << oendl;
167} 165}
168 166
169void MainWindow::slotAdjustLayout() { 167void MainWindow::slotAdjustLayout() {
170 168
171 QWidget *d = QApplication::desktop(); 169 QWidget *d = QApplication::desktop();
172 if ( d->width() < d->height() ) { 170 if ( d->width() < d->height() ) {
173 layout->setDirection( QBoxLayout::TopToBottom ); 171 layout->setDirection( QBoxLayout::TopToBottom );
174 } else { 172 } else {
175 layout->setDirection( QBoxLayout::LeftToRight ); 173 layout->setDirection( QBoxLayout::LeftToRight );
176 } 174 }
177} 175}
178 176
179void MainWindow::slotAdjustColumns() 177void MainWindow::slotAdjustColumns()
180{ 178{
181 bool hidden = folderView->isHidden(); 179 bool hidden = folderView->isHidden();
182 if ( hidden ) folderView->show(); 180 if ( hidden ) folderView->show();
183 folderView->setColumnWidth( 0, folderView->visibleWidth() ); 181 folderView->setColumnWidth( 0, folderView->visibleWidth() );
184 if ( hidden ) folderView->hide(); 182 if ( hidden ) folderView->hide();
185 183
186 mailView->setColumnWidth( 0, 10 ); 184 mailView->setColumnWidth( 0, 10 );
187 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); 185 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 );
188 mailView->setColumnWidth( 2, 80 ); 186 mailView->setColumnWidth( 2, 80 );
189 mailView->setColumnWidth( 3, 50 ); 187 mailView->setColumnWidth( 3, 50 );
190 mailView->setColumnWidth( 4, 50 ); 188 mailView->setColumnWidth( 4, 50 );
191} 189}
192 190
193void MainWindow::slotEditSettings() 191void MainWindow::slotEditSettings()
194{ 192{
195} 193}
196 194
197void MainWindow::slotShowFolders( bool ) 195void MainWindow::slotShowFolders( bool )
198{ 196{
199 odebug << "slotShowFolders not reached" << oendl; 197 odebug << "slotShowFolders not reached" << oendl;
200} 198}
201 199
202void MainWindow::refreshMailView(const QValueList<RecMailP>&) 200void MainWindow::refreshMailView(const QValueList<RecMailP>&)
203{ 201{
204 odebug << "refreshMailView not reached" << oendl; 202 odebug << "refreshMailView not reached" << oendl;
205} 203}
206 204
207void MainWindow::mailLeftClicked(int, QListViewItem *,const QPoint&,int ) 205void MainWindow::mailLeftClicked(int, QListViewItem *,const QPoint&,int )
208{ 206{
209 odebug << "mailLeftClicked not reached" << oendl; 207 odebug << "mailLeftClicked not reached" << oendl;
210} 208}
211 209
212void MainWindow::displayMail() 210void MainWindow::displayMail()
213{ 211{
214 odebug << "displayMail not reached" << oendl; 212 odebug << "displayMail not reached" << oendl;
215} 213}
216 214
217void MainWindow::slotDeleteMail() 215void MainWindow::slotDeleteMail()
218{ 216{
219 odebug << "deleteMail not reached" << oendl; 217 odebug << "deleteMail not reached" << oendl;
220} 218}
221 219
222void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) 220void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int )
223{ 221{
224 odebug << "mailHold not reached" << oendl; 222 odebug << "mailHold not reached" << oendl;
225} 223}
226 224
227void MainWindow::slotSendQueued() 225void MainWindow::slotSendQueued()
228{ 226{
229} 227}
230 228
231void MainWindow::slotEditAccounts() 229void MainWindow::slotEditAccounts()
232{ 230{
233} 231}
234 232
235void MainWindow::slotComposeMail() 233void MainWindow::slotComposeMail()
236{ 234{
237} 235}
diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h
index 8cec888..ad71a54 100644
--- a/noncore/net/mail/mainwindow.h
+++ b/noncore/net/mail/mainwindow.h
@@ -1,60 +1,58 @@
1#ifndef MAINWINDOW_H 1#ifndef MAINWINDOW_H
2#define MAINWINDOW_H 2#define MAINWINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qlistview.h> 5#include <qlistview.h>
6#include <qaction.h> 6#include <qaction.h>
7 7
8#include <qtoolbar.h> 8#include <qtoolbar.h>
9#include <qmenubar.h> 9#include <qmenubar.h>
10 10
11#include "accountview.h" 11#include "accountview.h"
12#include "statuswidget.h"
13 12
14#include <libmailwrapper/mailtypes.h> 13#include <libmailwrapper/mailtypes.h>
15#include <opie2/osmartpointer.h> 14#include <opie2/osmartpointer.h>
16 15
17class RecMail; 16class RecMail;
18class QCopChannel; 17class QCopChannel;
19 18
20class MainWindow : public QMainWindow 19class MainWindow : public QMainWindow
21{ 20{
22 Q_OBJECT 21 Q_OBJECT
23 22
24public: 23public:
25 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 24 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
26 virtual ~MainWindow(); 25 virtual ~MainWindow();
27 26
28public slots: 27public slots:
29 virtual void slotAdjustColumns(); 28 virtual void slotAdjustColumns();
30 virtual void appMessage(const QCString &msg, const QByteArray &data); 29 virtual void appMessage(const QCString &msg, const QByteArray &data);
31 virtual void slotComposeMail(); 30 virtual void slotComposeMail();
32 virtual void systemMessage( const QCString&, const QByteArray& ); 31 virtual void systemMessage( const QCString&, const QByteArray& );
33 32
34protected slots: 33protected slots:
35 virtual void slotSendQueued(); 34 virtual void slotSendQueued();
36 virtual void slotEditAccounts(); 35 virtual void slotEditAccounts();
37 virtual void slotShowFolders( bool show ); 36 virtual void slotShowFolders( bool show );
38 virtual void refreshMailView(const QValueList<RecMailP>&); 37 virtual void refreshMailView(const QValueList<RecMailP>&);
39 virtual void displayMail(); 38 virtual void displayMail();
40 virtual void slotDeleteMail(); 39 virtual void slotDeleteMail();
41 virtual void mailHold(int, QListViewItem *,const QPoint&,int); 40 virtual void mailHold(int, QListViewItem *,const QPoint&,int);
42 virtual void slotAdjustLayout(); 41 virtual void slotAdjustLayout();
43 virtual void slotEditSettings(); 42 virtual void slotEditSettings();
44 virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int ); 43 virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int );
45 44
46protected: 45protected:
47 QToolBar *toolBar; 46 QToolBar *toolBar;
48 StatusWidget *statusWidget;
49 QMenuBar *menuBar; 47 QMenuBar *menuBar;
50 QPopupMenu *mailMenu, *settingsMenu; 48 QPopupMenu *mailMenu, *settingsMenu;
51 QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, 49 QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails,
52 *editSettings, *editAccounts, *syncFolders; 50 *editSettings, *editAccounts, *syncFolders;
53 AccountView *folderView; 51 AccountView *folderView;
54 QListView *mailView; 52 QListView *mailView;
55 QBoxLayout *layout; 53 QBoxLayout *layout;
56 int m_Rotate; 54 int m_Rotate;
57 QCopChannel* m_sysChannel; 55 QCopChannel* m_sysChannel;
58}; 56};
59 57
60#endif 58#endif
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp
index 2bbc8f1..9eba23e 100644
--- a/noncore/net/mail/opiemail.cpp
+++ b/noncore/net/mail/opiemail.cpp
@@ -14,337 +14,331 @@
14/* OPIE */ 14/* OPIE */
15#include <opie2/odebug.h> 15#include <opie2/odebug.h>
16#include <qpe/resource.h> 16#include <qpe/resource.h>
17#include <qpe/qpeapplication.h> 17#include <qpe/qpeapplication.h>
18 18
19/* QT */ 19/* QT */
20#include <qmap.h> 20#include <qmap.h>
21#include <qvaluelist.h> 21#include <qvaluelist.h>
22 22
23/* UNIX */ 23/* UNIX */
24#include <signal.h> 24#include <signal.h>
25 25
26using namespace Opie::Core; 26using namespace Opie::Core;
27 27
28typedef QMapNode<QString,QString> tkeyvalues; 28typedef QMapNode<QString,QString> tkeyvalues;
29typedef QValueList<tkeyvalues> tvaluelist; 29typedef QValueList<tkeyvalues> tvaluelist;
30 30
31class ValueExplode 31class ValueExplode
32{ 32{
33protected: 33protected:
34 //! what was parsed last 34 //! what was parsed last
35 tvaluelist m_LastParsed; 35 tvaluelist m_LastParsed;
36 //! the delemiter to use 36 //! the delemiter to use
37 QString mDelemiter; 37 QString mDelemiter;
38 //! the inner delemiter 38 //! the inner delemiter
39 QString m2Delemiter; 39 QString m2Delemiter;
40 //! the real split routine 40 //! the real split routine
41 void splitit(); 41 void splitit();
42 //! the content 42 //! the content
43 QString m_Command; 43 QString m_Command;
44 //! constructor 44 //! constructor
45 ValueExplode(){} 45 ValueExplode(){}
46public: 46public:
47 //! constructor 47 //! constructor
48 /*! 48 /*!
49 * \param aCommand the string to be splitted 49 * \param aCommand the string to be splitted
50 * \param aDelemiter which sign will be the delemiter character 50 * \param aDelemiter which sign will be the delemiter character
51 * \param a2Delemiter which sign will delemiter the key-value-pairs between other delemiters 51 * \param a2Delemiter which sign will delemiter the key-value-pairs between other delemiters
52 */ 52 */
53 ValueExplode(const QString&aCommand,const char aDelemiter = '&',const char a2Delemiter='='); 53 ValueExplode(const QString&aCommand,const char aDelemiter = '&',const char a2Delemiter='=');
54 //! destructor 54 //! destructor
55 virtual ~ValueExplode(); 55 virtual ~ValueExplode();
56 //! assigen operator 56 //! assigen operator
57 /*! 57 /*!
58 * \return a list of substrings 58 * \return a list of substrings
59 */ 59 */
60 operator const tvaluelist& (){return m_LastParsed;} 60 operator const tvaluelist& (){return m_LastParsed;}
61}; 61};
62 62
63ValueExplode::~ValueExplode() 63ValueExplode::~ValueExplode()
64{ 64{
65} 65}
66 66
67ValueExplode::ValueExplode(const QString&aCommand,const char aDelemiter,const char a2Delemiter) 67ValueExplode::ValueExplode(const QString&aCommand,const char aDelemiter,const char a2Delemiter)
68 :m_LastParsed(),m_Command(aCommand) 68 :m_LastParsed(),m_Command(aCommand)
69{ 69{
70 mDelemiter = aDelemiter; 70 mDelemiter = aDelemiter;
71 m2Delemiter = a2Delemiter; 71 m2Delemiter = a2Delemiter;
72 splitit(); 72 splitit();
73} 73}
74 74
75void ValueExplode::splitit() 75void ValueExplode::splitit()
76{ 76{
77 QString iLine; 77 QString iLine;
78 m_LastParsed.clear(); 78 m_LastParsed.clear();
79 if (mDelemiter.isEmpty()||m2Delemiter.isEmpty()) { 79 if (mDelemiter.isEmpty()||m2Delemiter.isEmpty()) {
80 m_LastParsed.append(tkeyvalues(m_Command,"")); 80 m_LastParsed.append(tkeyvalues(m_Command,""));
81 return; 81 return;
82 } 82 }
83 int pos,pos2,startpos; 83 int pos,pos2,startpos;
84 startpos = 0; 84 startpos = 0;
85 iLine = m_Command; 85 iLine = m_Command;
86 while ( (pos = iLine.find(mDelemiter,startpos))!=-1) { 86 while ( (pos = iLine.find(mDelemiter,startpos))!=-1) {
87 pos2 = iLine.find(m2Delemiter,startpos); 87 pos2 = iLine.find(m2Delemiter,startpos);
88 if (pos2==-1||pos2>pos) { 88 if (pos2==-1||pos2>pos) {
89 m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos-startpos),"")); 89 m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos-startpos),""));
90 } else { 90 } else {
91 m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos2-startpos),iLine.mid(pos2+1,pos-pos2-1))); 91 m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos2-startpos),iLine.mid(pos2+1,pos-pos2-1)));
92 } 92 }
93 startpos = pos+1; 93 startpos = pos+1;
94 } 94 }
95 if (startpos<iLine.length()) { 95 if (startpos<iLine.length()) {
96 pos2 = iLine.find(m2Delemiter,startpos); 96 pos2 = iLine.find(m2Delemiter,startpos);
97 if (pos2==-1) { 97 if (pos2==-1) {
98 m_LastParsed.append(tkeyvalues(iLine.mid(startpos),"")); 98 m_LastParsed.append(tkeyvalues(iLine.mid(startpos),""));
99 } else { 99 } else {
100 m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos2-startpos),iLine.mid(pos2+1))); 100 m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos2-startpos),iLine.mid(pos2+1)));
101 } 101 }
102 } 102 }
103} 103}
104 104
105OpieMail::OpieMail( QWidget *parent, const char *name, WFlags ) 105OpieMail::OpieMail( QWidget *parent, const char *name, WFlags )
106 : MainWindow( parent, name, WStyle_ContextHelp ) 106 : MainWindow( parent, name, WStyle_ContextHelp )
107{ 107{
108 setup_signalblocking(); 108 setup_signalblocking();
109 settings = new Settings(); 109 settings = new Settings();
110
111 folderView->populate( settings->getAccounts() ); 110 folderView->populate( settings->getAccounts() );
112#if 0
113 tvaluelist s = ValueExplode("a=1&b=holladiewaldfee&c=3&d=&e=3450");
114 for (int i = 0; i < s.count();++i) {
115 odebug<<"Key: " << s[i].key << " Value: " << s[i].data << oendl;
116 }
117#endif
118} 111}
119 112
120OpieMail::~OpieMail() 113OpieMail::~OpieMail()
121{ 114{
122 if (settings) delete settings; 115 if (settings) delete settings;
123} 116}
124 117
125void OpieMail::setup_signalblocking() 118void OpieMail::setup_signalblocking()
126{ 119{
127 /* for networking we must block SIGPIPE and Co. */ 120 /* for networking we must block SIGPIPE and Co. */
128 struct sigaction blocking_action,temp_action; 121 struct sigaction blocking_action,temp_action;
129 blocking_action.sa_handler = SIG_IGN; 122 blocking_action.sa_handler = SIG_IGN;
130 sigemptyset(&(blocking_action.sa_mask)); 123 sigemptyset(&(blocking_action.sa_mask));
131 blocking_action.sa_flags = 0; 124 blocking_action.sa_flags = 0;
132 sigaction(SIGPIPE,&blocking_action,&temp_action); 125 sigaction(SIGPIPE,&blocking_action,&temp_action);
133} 126}
134 127
135void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 128void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
136{ 129{
137 // copied from old mail2 130 // copied from old mail2
138 if (msg == "writeMail(QString,QString)") 131 if (msg == "writeMail(QString,QString)")
139 { 132 {
140 QDataStream stream(data,IO_ReadOnly); 133 QDataStream stream(data,IO_ReadOnly);
141 QString name, email; 134 QString name, email;
142 stream >> name >> email; 135 stream >> name >> email;
143 // removing the whitespaces at beginning and end is needed! 136 // removing the whitespaces at beginning and end is needed!
144 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); 137 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace());
145 } 138 }
146 else if (msg == "newMail()") 139 else if (msg == "newMail()")
147 { 140 {
148 slotComposeMail(); 141 slotComposeMail();
149 } 142 }
150} 143}
151 144
152/** 145/**
153 * Konqueror calls us with the mailto:name@address 146 * Konqueror calls us with the mailto:name@address
154 */ 147 */
155void OpieMail::setDocument(const QString& mail) 148void OpieMail::setDocument(const QString& mail)
156{ 149{
157 /* 150 /*
158 * It looks like a mailto address, lets try it 151 * It looks like a mailto address, lets try it
159 */ 152 */
160 if( mail.startsWith(QString::fromLatin1("mailto:")) ) 153 if( mail.startsWith(QString::fromLatin1("mailto:")) )
161 slotwriteMail(QString::null, mail.mid(7)); 154 slotwriteMail(QString::null, mail.mid(7));
162} 155}
163 156
164void OpieMail::slotwriteMail(const QString&name,const QString&email) 157void OpieMail::slotwriteMail(const QString&name,const QString&email)
165{ 158{
166 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); 159 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
167 if (!email.isEmpty()) 160 if (!email.isEmpty())
168 { 161 {
169 if (!name.isEmpty()) 162 if (!name.isEmpty())
170 { 163 {
171 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 164 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
172 } 165 }
173 else 166 else
174 { 167 {
175 compose.setTo(email); 168 compose.setTo(email);
176 } 169 }
177 } 170 }
178 compose.slotAdjustColumns(); 171 compose.slotAdjustColumns();
179 QPEApplication::execDialog( &compose ); 172 QPEApplication::execDialog( &compose );
180} 173}
181 174
182void OpieMail::slotComposeMail() 175void OpieMail::slotComposeMail()
183{ 176{
184 odebug << "Compose Mail" << oendl; 177 odebug << "Compose Mail" << oendl;
185 slotwriteMail(0l,0l); 178 slotwriteMail(0l,0l);
186} 179}
187 180
188void OpieMail::slotSendQueued() 181void OpieMail::slotSendQueued()
189{ 182{
190 odebug << "Send Queued" << oendl; 183 odebug << "Send Queued" << oendl;
191 SMTPaccount *smtp = 0; 184 SMTPaccount *smtp = 0;
192 185
193 QList<Account> list = settings->getAccounts(); 186 QList<Account> list = settings->getAccounts();
194 QList<SMTPaccount> smtpList; 187 QList<SMTPaccount> smtpList;
195 smtpList.setAutoDelete(false); 188 smtpList.setAutoDelete(false);
196 Account *it; 189 Account *it;
197 for ( it = list.first(); it; it = list.next() ) 190 for ( it = list.first(); it; it = list.next() )
198 { 191 {
199 if ( it->getType() == MAILLIB::A_SMTP ) 192 if ( it->getType() == MAILLIB::A_SMTP )
200 { 193 {
201 smtp = static_cast<SMTPaccount *>(it); 194 smtp = static_cast<SMTPaccount *>(it);
202 smtpList.append(smtp); 195 smtpList.append(smtp);
203 } 196 }
204 } 197 }
205 if (smtpList.count()==0) 198 if (smtpList.count()==0)
206 { 199 {
207 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); 200 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first"));
208 return; 201 return;
209 } 202 }
210 if (smtpList.count()==1) 203 if (smtpList.count()==1)
211 { 204 {
212 smtp = smtpList.at(0); 205 smtp = smtpList.at(0);
213 } 206 }
214 else 207 else
215 { 208 {
216 smtp = 0; 209 smtp = 0;
217 selectsmtp selsmtp; 210 selectsmtp selsmtp;
218 selsmtp.setSelectionlist(&smtpList); 211 selsmtp.setSelectionlist(&smtpList);
219 if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted ) 212 if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted )
220 { 213 {
221 smtp = selsmtp.selected_smtp(); 214 smtp = selsmtp.selected_smtp();
222 } 215 }
223 } 216 }
224 if (smtp) 217 if (smtp)
225 { 218 {
226 SMTPwrapper * wrap = new SMTPwrapper(smtp); 219 SMTPwrapper * wrap = new SMTPwrapper(smtp);
227 if ( wrap->flushOutbox() ) 220 if ( wrap->flushOutbox() )
228 { 221 {
229 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); 222 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
230 } 223 }
231 delete wrap; 224 delete wrap;
232 } 225 }
233} 226}
234 227
235void OpieMail::slotSearchMails() 228void OpieMail::slotSearchMails()
236{ 229{
237 odebug << "Search Mails" << oendl; 230 odebug << "Search Mails" << oendl;
238} 231}
239 232
240void OpieMail::slotEditSettings() 233void OpieMail::slotEditSettings()
241{ 234{
242 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); 235 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
243 QPEApplication::execDialog( &settingsDialog ); 236 QPEApplication::execDialog( &settingsDialog );
244} 237}
245 238
246void OpieMail::slotEditAccounts() 239void OpieMail::slotEditAccounts()
247{ 240{
248 odebug << "Edit Accounts" << oendl; 241 odebug << "Edit Accounts" << oendl;
249 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); 242 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp );
250 eaDialog.slotAdjustColumns(); 243 eaDialog.slotAdjustColumns();
251 QPEApplication::execDialog( &eaDialog ); 244 if (QPEApplication::execDialog( &eaDialog )==QDialog::Rejected);// return;
245
252 if ( settings ) delete settings; 246 if ( settings ) delete settings;
253 settings = new Settings(); 247 settings = new Settings();
254 248 mailView->clear();
255 folderView->populate( settings->getAccounts() ); 249 folderView->populate( settings->getAccounts() );
256} 250}
257 251
258void OpieMail::displayMail() 252void OpieMail::displayMail()
259{ 253{
260 QListViewItem*item = mailView->currentItem(); 254 QListViewItem*item = mailView->currentItem();
261 if (!item) return; 255 if (!item) return;
262 RecMailP mail = ((MailListViewItem*)item)->data(); 256 RecMailP mail = ((MailListViewItem*)item)->data();
263 RecBodyP body = folderView->fetchBody(mail); 257 RecBodyP body = folderView->fetchBody(mail);
264 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); 258 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp );
265 readMail.setBody( body ); 259 readMail.setBody( body );
266 readMail.setMail( mail ); 260 readMail.setMail( mail );
267 readMail.showMaximized(); 261 readMail.showMaximized();
268 readMail.exec(); 262 readMail.exec();
269 263
270 if ( readMail.deleted ) 264 if ( readMail.deleted )
271 { 265 {
272 folderView->refreshCurrent(); 266 folderView->refreshCurrent();
273 } 267 }
274 else 268 else
275 { 269 {
276 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); 270 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) );
277 } 271 }
278} 272}
279 273
280void OpieMail::slotDeleteMail() 274void OpieMail::slotDeleteMail()
281{ 275{
282 if (!mailView->currentItem()) return; 276 if (!mailView->currentItem()) return;
283 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 277 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
284 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 278 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
285 { 279 {
286 mail->Wrapper()->deleteMail( mail ); 280 mail->Wrapper()->deleteMail( mail );
287 folderView->refreshCurrent(); 281 folderView->refreshCurrent();
288 } 282 }
289} 283}
290 284
291void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) 285void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
292{ 286{
293 if (!mailView->currentItem()) return; 287 if (!mailView->currentItem()) return;
294 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); 288 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType();
295 /* just the RIGHT button - or hold on pda */ 289 /* just the RIGHT button - or hold on pda */
296 if (button!=2) {return;} 290 if (button!=2) {return;}
297 odebug << "Event right/hold" << oendl; 291 odebug << "Event right/hold" << oendl;
298 if (!item) return; 292 if (!item) return;
299 QPopupMenu *m = new QPopupMenu(0); 293 QPopupMenu *m = new QPopupMenu(0);
300 if (m) 294 if (m)
301 { 295 {
302 if (mailtype==MAILLIB::A_NNTP) { 296 if (mailtype==MAILLIB::A_NNTP) {
303 m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); 297 m->insertItem(tr("Read this posting"),this,SLOT(displayMail()));
304// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); 298// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail()));
305 } else { 299 } else {
306 if (folderView->currentisDraft()) { 300 if (folderView->currentisDraft()) {
307 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); 301 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail()));
308 } 302 }
309 m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); 303 m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
310 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); 304 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
311 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); 305 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail()));
312 } 306 }
313 m->setFocus(); 307 m->setFocus();
314 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 308 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
315 delete m; 309 delete m;
316 } 310 }
317} 311}
318 312
319void OpieMail::slotShowFolders( bool show ) 313void OpieMail::slotShowFolders( bool show )
320{ 314{
321 odebug << "Show Folders" << oendl; 315 odebug << "Show Folders" << oendl;
322 if ( show && folderView->isHidden() ) 316 if ( show && folderView->isHidden() )
323 { 317 {
324 odebug << "-> showing" << oendl; 318 odebug << "-> showing" << oendl;
325 folderView->show(); 319 folderView->show();
326 } 320 }
327 else if ( !show && !folderView->isHidden() ) 321 else if ( !show && !folderView->isHidden() )
328 { 322 {
329 odebug << "-> hiding" << oendl; 323 odebug << "-> hiding" << oendl;
330 folderView->hide(); 324 folderView->hide();
331 } 325 }
332} 326}
333 327
334void OpieMail::refreshMailView(const QValueList<RecMailP>&list) 328void OpieMail::refreshMailView(const QValueList<RecMailP>&list)
335{ 329{
336 MailListViewItem*item = 0; 330 MailListViewItem*item = 0;
337 mailView->clear(); 331 mailView->clear();
338 332
339 QValueList<RecMailP>::ConstIterator it; 333 QValueList<RecMailP>::ConstIterator it;
340 for (it = list.begin(); it != list.end();++it) 334 for (it = list.begin(); it != list.end();++it)
341 { 335 {
342 item = new MailListViewItem(mailView,item); 336 item = new MailListViewItem(mailView,item);
343 item->storeData((*it)); 337 item->storeData((*it));
344 item->showEntry(); 338 item->showEntry();
345 } 339 }
346} 340}
347 341
348void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) 342void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int )
349{ 343{
350 /* just LEFT button - or tap with stylus on pda */ 344 /* just LEFT button - or tap with stylus on pda */
diff --git a/noncore/net/mail/statuswidget.cpp b/noncore/net/mail/statuswidget.cpp
deleted file mode 100644
index 19cf635..0000000
--- a/noncore/net/mail/statuswidget.cpp
+++ b/dev/null
@@ -1,33 +0,0 @@
1#include <qtimer.h>
2#include <qprogressbar.h>
3#include <qlabel.h>
4
5#include "statuswidget.h"
6
7// the current problem I see is "locking": used exclusive by one sender
8
9
10StatusWidget::StatusWidget( QWidget* parent, const char* name,WFlags fl )
11 : StatusWidgetUI( parent, name, fl ) {
12
13 setMaximumHeight( 15 );
14 // hide for now since nothing reports decent progress data yet.
15 statusProgress->hide();
16 }
17
18StatusWidget::~StatusWidget() {
19}
20
21void StatusWidget::setText( const QString& text ) {
22 show();
23 statusText->setText( text );
24 QTimer::singleShot( 5000, this, SLOT( hide() ) );
25}
26
27void StatusWidget::setProgress( int progress ) {
28 show();
29 statusProgress->setProgress( progress );
30 if ( progress == 100 ) {
31 hide();
32 }
33}
diff --git a/noncore/net/mail/statuswidget.h b/noncore/net/mail/statuswidget.h
deleted file mode 100644
index 73f0d75..0000000
--- a/noncore/net/mail/statuswidget.h
+++ b/dev/null
@@ -1,24 +0,0 @@
1#ifndef STATUS_WIDGET_H
2#define STATUS_WIDGET_H
3
4#include <qwidget.h>
5#include "statuswidgetui.h"
6
7class StatusWidget : public StatusWidgetUI {
8
9Q_OBJECT
10
11public:
12 StatusWidget( QWidget* parent = 0, const char* name = 0,WFlags fl = 0 );
13 ~StatusWidget();
14
15
16public slots:
17
18 void setText( const QString& text );
19 void setProgress( int progress );
20};
21
22
23#endif
24
diff --git a/noncore/net/mail/statuswidgetui.ui b/noncore/net/mail/statuswidgetui.ui
deleted file mode 100644
index ffe3528..0000000
--- a/noncore/net/mail/statuswidgetui.ui
+++ b/dev/null
@@ -1,71 +0,0 @@
1<!DOCTYPE UI><UI>
2<class>StatusWidgetUI</class>
3<widget>
4 <class>QWidget</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>StatusWidgetUI</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>596</width>
15 <height>480</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Form1</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <property>
26 <name>layoutSpacing</name>
27 </property>
28 <hbox>
29 <property stdset="1">
30 <name>margin</name>
31 <number>3</number>
32 </property>
33 <property stdset="1">
34 <name>spacing</name>
35 <number>3</number>
36 </property>
37 <widget>
38 <class>QProgressBar</class>
39 <property stdset="1">
40 <name>name</name>
41 <cstring>statusProgress</cstring>
42 </property>
43 <property stdset="1">
44 <name>sizePolicy</name>
45 <sizepolicy>
46 <hsizetype>5</hsizetype>
47 <vsizetype>0</vsizetype>
48 </sizepolicy>
49 </property>
50 </widget>
51 <widget>
52 <class>QLabel</class>
53 <property stdset="1">
54 <name>name</name>
55 <cstring>statusText</cstring>
56 </property>
57 <property stdset="1">
58 <name>sizePolicy</name>
59 <sizepolicy>
60 <hsizetype>5</hsizetype>
61 <vsizetype>1</vsizetype>
62 </sizepolicy>
63 </property>
64 <property stdset="1">
65 <name>text</name>
66 <string>TextLabel1</string>
67 </property>
68 </widget>
69 </hbox>
70</widget>
71</UI>
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index a64a168..5206220 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -103,368 +103,393 @@ void ViewMail::setBody(const RecBodyP&body )
103 int w; 103 int w;
104 w=0; 104 w=0;
105 105
106 while (s>1024) 106 while (s>1024)
107 { 107 {
108 s/=1024; 108 s/=1024;
109 ++w; 109 ++w;
110 if (w>=2) break; 110 if (w>=2) break;
111 } 111 }
112 112
113 QString q=""; 113 QString q="";
114 switch(w) 114 switch(w)
115 { 115 {
116 case 1: 116 case 1:
117 q="k"; 117 q="k";
118 break; 118 break;
119 case 2: 119 case 2:
120 q="M"; 120 q="M";
121 break; 121 break;
122 default: 122 default:
123 break; 123 break;
124 } 124 }
125 125
126 { 126 {
127 /* I did not found a method to make a CONTENT reset on a QTextStream 127 /* I did not found a method to make a CONTENT reset on a QTextStream
128 so I use this construct that the stream will re-constructed in each 128 so I use this construct that the stream will re-constructed in each
129 loop. To let it work, the textstream is packed into a own area of 129 loop. To let it work, the textstream is packed into a own area of
130 code is it will be destructed after finishing its small job. 130 code is it will be destructed after finishing its small job.
131 */ 131 */
132 QTextOStream o(&fsize); 132 QTextOStream o(&fsize);
133 if (w>0) o.precision(2); else o.precision(0); 133 if (w>0) o.precision(2); else o.precision(0);
134 o.setf(QTextStream::fixed); 134 o.setf(QTextStream::fixed);
135 o << s << " " << q << "Byte"; 135 o << s << " " << q << "Byte";
136 } 136 }
137 137
138 curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); 138 curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist());
139 QString filename = ""; 139 QString filename = "";
140 140
141 for (unsigned int i = 0; i < body->Parts().count();++i) 141 for (unsigned int i = 0; i < body->Parts().count();++i)
142 { 142 {
143 filename = ""; 143 filename = "";
144 type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); 144 type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype();
145 part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); 145 part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin();
146 for (;it!=body->Parts()[i]->Parameters().end();++it) 146 for (;it!=body->Parts()[i]->Parameters().end();++it)
147 { 147 {
148 odebug << it.key() << oendl; 148 odebug << it.key() << oendl;
149 if (it.key().lower()=="name") 149 if (it.key().lower()=="name")
150 { 150 {
151 filename=it.data(); 151 filename=it.data();
152 } 152 }
153 } 153 }
154 s = body->Parts()[i]->Size(); 154 s = body->Parts()[i]->Size();
155 w = 0; 155 w = 0;
156 while (s>1024) 156 while (s>1024)
157 { 157 {
158 s/=1024; 158 s/=1024;
159 ++w; 159 ++w;
160 if (w>=2) break; 160 if (w>=2) break;
161 } 161 }
162 switch(w) 162 switch(w)
163 { 163 {
164 case 1: 164 case 1:
165 q="k"; 165 q="k";
166 break; 166 break;
167 case 2: 167 case 2:
168 q="M"; 168 q="M";
169 break; 169 break;
170 default: 170 default:
171 q=""; 171 q="";
172 break; 172 break;
173 } 173 }
174 QTextOStream o(&fsize); 174 QTextOStream o(&fsize);
175 if (w>0) o.precision(2); else o.precision(0); 175 if (w>0) o.precision(2); else o.precision(0);
176 o.setf(QTextStream::fixed); 176 o.setf(QTextStream::fixed);
177 o << s << " " << q << "Byte"; 177 o << s << " " << q << "Byte";
178 desc = body->Parts()[i]->Description(); 178 desc = body->Parts()[i]->Description();
179 parentItem = searchParent(body->Parts()[i]->Positionlist()); 179 parentItem = searchParent(body->Parts()[i]->Positionlist());
180 if (parentItem) 180 if (parentItem)
181 { 181 {
182 AttachItem*temp = lastChild(parentItem); 182 AttachItem*temp = lastChild(parentItem);
183 if (temp) curItem = temp; 183 if (temp) curItem = temp;
184 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); 184 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist());
185 attachments->setRootIsDecorated(true); 185 attachments->setRootIsDecorated(true);
186 curItem = parentItem; 186 curItem = parentItem;
187 } 187 }
188 else 188 else
189 { 189 {
190 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); 190 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist());
191 } 191 }
192 } 192 }
193} 193}
194 194
195 195
196void ViewMail::slotShowHtml( bool state ) 196void ViewMail::slotShowHtml( bool state )
197{ 197{
198 m_showHtml = state; 198 m_showHtml = state;
199 setText(); 199 setMainText();
200} 200}
201 201
202void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) 202void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int )
203{ 203{
204 if (!item ) 204 if (!item )
205 return; 205 return;
206 206
207 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 207 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
208 { 208 {
209 setText(); 209 setMainText();
210 return; 210 return;
211 } 211 }
212 QPopupMenu *menu = new QPopupMenu(); 212 QPopupMenu *menu = new QPopupMenu();
213 int ret=0; 213 int ret=0;
214 214
215 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) 215 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" )
216 { 216 {
217 menu->insertItem( tr( "Show Text" ), 1 ); 217 menu->insertItem( tr( "Show Text" ), 1 );
218 } 218 }
219 if (item->text(0).left(6)=="image/") { 219 if (item->text(0).left(6)=="image/") {
220 menu->insertItem(tr("Display image preview"),2); 220 menu->insertItem(tr("Display image preview"),2);
221 } 221 }
222 menu->insertItem( tr( "Save Attachment" ), 0 ); 222 menu->insertItem( tr( "Save Attachment" ), 0 );
223 menu->insertSeparator(1); 223 menu->insertSeparator(1);
224 224
225 ret = menu->exec( point, 0 ); 225 ret = menu->exec( point, 0 );
226 226
227 switch(ret) 227 switch(ret)
228 { 228 {
229 case 0: 229 case 0:
230 { 230 {
231 MimeTypes types; 231 MimeTypes types;
232 types.insert( "all", "*" ); 232 types.insert( "all", "*" );
233 QString str = OFileDialog::getSaveFileName( 1, 233 QString str = OFileDialog::getSaveFileName( 1,
234 "/", item->text( 2 ) , types, 0 ); 234 "/", item->text( 2 ) , types, 0 );
235 235
236 if( !str.isEmpty() ) 236 if( !str.isEmpty() )
237 { 237 {
238 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 238 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
239 if (content) 239 if (content)
240 { 240 {
241 QFile output(str); 241 QFile output(str);
242 output.open(IO_WriteOnly); 242 output.open(IO_WriteOnly);
243 output.writeBlock(content->Content(),content->Length()); 243 output.writeBlock(content->Content(),content->Length());
244 output.close(); 244 output.close();
245 delete content; 245 delete content;
246 } 246 }
247 } 247 }
248 } 248 }
249 break ; 249 break ;
250 250
251 case 2: 251 case 2:
252 { 252 {
253 if (m_lastimagepart== (( AttachItem* )item )->Partnumber()) {
254 if (m_lastdlg) {
255 setUpdatesEnabled(false);
256 browser->hide();
257 m_lastdlg->show();
258 setUpdatesEnabled(true);
259 return;
260 }
261 }
253 QString tmpfile = QString("/tmp/opiemail-image-%1").arg(_icounter++); 262 QString tmpfile = QString("/tmp/opiemail-image-%1").arg(_icounter++);
254 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 263 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
255 if (content && content->Length()) { 264 if (content && content->Length()) {
256 QFile output(tmpfile); 265 QFile output(tmpfile);
257 output.open(IO_WriteOnly); 266 output.open(IO_WriteOnly);
258 output.writeBlock(content->Content(),content->Length()); 267 output.writeBlock(content->Content(),content->Length());
259 output.close(); 268 output.close();
260 delete content; 269 delete content;
261 if (!m_PicsInline) { 270 if (!m_PicsInline) {
262 MailImageDlg iview(""); 271 MailImageDlg iview("");
263 iview.setName(tmpfile); 272 iview.setName(tmpfile);
264 QPEApplication::execDialog(&iview); 273 QPEApplication::execDialog(&iview);
265 } else { 274 } else {
266 if (!m_lastdlg) { 275 if (!m_lastdlg) {
267 m_lastdlg=new Opie::MM::OImageScrollView("",browser->parentWidget(),false); 276 m_lastdlg=new Opie::MM::OImageScrollView("",browser->parentWidget(),false);
268 m_lastdlg->setAutoScale(true); 277 m_lastdlg->setAutoScale(true);
269 } 278 }
270 //m_lastdlg->setImage(""); 279 //m_lastdlg->setImage("");
271 m_lastdlg->setImage(tmpfile); 280 m_lastdlg->setImage(tmpfile);
272 browser->hide(); 281 browser->hide();
273 m_lastdlg->show(); 282 m_lastdlg->show();
274 } 283 }
275 output.remove(); 284 output.remove();
276 } else { 285 } else {
277 QMessageBox::critical(this, tr("Reading attachment"), tr("Could not read content of attachment")); 286 QMessageBox::critical(this, tr("Reading attachment"), tr("Could not read content of attachment"));
278 } 287 }
288 m_lastimagepart=(( AttachItem* )item )->Partnumber();
279 } 289 }
280 break; 290 break;
281 case 1: 291 case 1:
282 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 292 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
283 { 293 {
284 setText(); 294 setMainText();
285 } 295 }
286 else 296 else
287 { 297 {
288 if ( m_recMail->Wrapper() != 0l ) 298 if ( m_recMail->Wrapper() != 0l )
289 { // make sure that there is a wrapper , even after delete or simular actions 299 { // make sure that there is a wrapper , even after delete or simular actions
290 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); 300 if (m_lastdlg) {
301 m_lastdlg->hide();
302 browser->show();
303 }
304 if (m_lasttextpart == ( ( AttachItem* )item )->Partnumber() ) return;
305 m_lasttextpart = ( ( AttachItem* )item )->Partnumber();
306 QString s = m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );;
307 if (item->text(0).right(4)!="html") {
308 s = QString("<html><body>\n<font face=fixed>%1</font></body></html>").arg(QStyleSheet::convertFromPlainText(s));
309 }
310 browser->setText(s);
291 } 311 }
292 } 312 }
293 break; 313 break;
294 } 314 }
295 delete menu; 315 delete menu;
296} 316}
297 317
298 318
299void ViewMail::setMail(const RecMailP&mail ) 319void ViewMail::setMail(const RecMailP&mail )
300{ 320{
301 321
302 m_recMail = mail; 322 m_recMail = mail;
303 323
304 m_mail[0] = mail->getFrom(); 324 m_mail[0] = mail->getFrom();
305 m_mail[1] = mail->getSubject(); 325 m_mail[1] = mail->getSubject();
306 m_mail[3] = mail->getStringDate(); 326 m_mail[3] = mail->getStringDate();
307 m_mail[4] = mail->Msgid(); 327 m_mail[4] = mail->Msgid();
308 328
309 m_mail2[0] = mail->To(); 329 m_mail2[0] = mail->To();
310 m_mail2[1] = mail->CC(); 330 m_mail2[1] = mail->CC();
311 m_mail2[2] = mail->Bcc(); 331 m_mail2[2] = mail->Bcc();
312 332
313 setCaption(tr("E-Mail by %1").arg( m_mail[0] ) ); 333 setCaption(tr("E-Mail by %1").arg( m_mail[0] ) );
314 setText(); 334 setMainText();
315} 335}
316 336
317 337
318 338
319ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 339ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
320 : ViewMailBase(parent, name, fl), _inLoop(false) 340 : ViewMailBase(parent, name, fl), _inLoop(false)
321{ 341{
322 m_gotBody = false; 342 m_gotBody = false;
323 deleted = false; 343 deleted = false;
324 344
325 connect( reply, SIGNAL(activated()), SLOT(slotReply())); 345 connect( reply, SIGNAL(activated()), SLOT(slotReply()));
326 connect( forward, SIGNAL(activated()), SLOT(slotForward())); 346 connect( forward, SIGNAL(activated()), SLOT(slotForward()));
327 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); 347 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) );
328 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); 348 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) );
329 connect( showPicsInline, SIGNAL( toggled(bool) ), SLOT( slotImageInline(bool) ) ); 349 connect( showPicsInline, SIGNAL( toggled(bool) ), SLOT( slotImageInline(bool) ) );
330 350
331 attachments->setEnabled(m_gotBody); 351 attachments->setEnabled(m_gotBody);
332 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); 352 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) );
333 m_lastdlg = 0; 353 m_lastdlg = 0;
334 _icounter = 0; 354 _icounter = 0;
355 m_lastimagepart = -1;
356 m_lasttextpart = -2;
335 357
336 readConfig(); 358 readConfig();
337 attachments->setSorting(-1); 359 attachments->setSorting(-1);
338} 360}
339 361
340void ViewMail::slotImageInline(bool how) 362void ViewMail::slotImageInline(bool how)
341{ 363{
342 Config cfg( "mail" ); 364 Config cfg( "mail" );
343 cfg.writeEntry( "showPicsInline", how); 365 cfg.writeEntry( "showPicsInline", how);
344 m_PicsInline = how; 366 m_PicsInline = how;
345 if (m_lastdlg&&!how) { 367 if (m_lastdlg&&!how) {
346 browser->show(); 368 browser->show();
347 m_lastdlg->hide(); 369 m_lastdlg->hide();
348 m_lastdlg->reparent(0,QPoint(0,0),false); 370 m_lastdlg->reparent(0,QPoint(0,0),false);
349 delete m_lastdlg; 371 delete m_lastdlg;
350 m_lastdlg = 0; 372 m_lastdlg = 0;
373 m_lastimagepart = -1;
351 } 374 }
352} 375}
353 376
354void ViewMail::readConfig() 377void ViewMail::readConfig()
355{ 378{
356 Config cfg( "mail" ); 379 Config cfg( "mail" );
357 cfg.setGroup( "Settings" ); 380 cfg.setGroup( "Settings" );
358 m_showHtml = cfg.readBoolEntry( "showHtml", false ); 381 m_showHtml = cfg.readBoolEntry( "showHtml", false );
359 m_PicsInline = cfg.readBoolEntry( "showPicsInline", true ); 382 m_PicsInline = cfg.readBoolEntry( "showPicsInline", true );
360 showPicsInline->setOn(m_PicsInline); 383 showPicsInline->setOn(m_PicsInline);
361 showHtml->setOn( m_showHtml ); 384 showHtml->setOn( m_showHtml );
362} 385}
363 386
364void ViewMail::setText() 387void ViewMail::setMainText()
365{ 388{
366 QString toString; 389 QString toString;
367 QString ccString; 390 QString ccString;
368 QString bccString; 391 QString bccString;
369 QString mailHtml; 392 QString mailHtml;
370 393
371 if (m_lastdlg) { 394 if (m_lastdlg) {
372 m_lastdlg->hide(); 395 m_lastdlg->hide();
373 } 396 }
374 browser->show(); 397 browser->show();
398 if (m_lasttextpart == -1) return;
399 m_lasttextpart = -1;
375 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) 400 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it )
376 { 401 {
377 toString += (*it); 402 toString += (*it);
378 } 403 }
379 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) 404 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it )
380 { 405 {
381 ccString += (*it); 406 ccString += (*it);
382 } 407 }
383 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) 408 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it )
384 { 409 {
385 bccString += (*it); 410 bccString += (*it);
386 } 411 }
387 browser->setTextFormat(Qt::RichText); 412 browser->setTextFormat(Qt::RichText);
388 mailHtml = "<html><body>" 413 mailHtml = "<html><body>"
389 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" 414 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>"
390 "<div align=left><b>" + deHtml(m_mail[1]) + "</b></div>" 415 "<div align=left><b>" + deHtml(m_mail[1]) + "</b></div>"
391 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" 416 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>"
392 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" 417 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>"
393 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + 418 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" +
394 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" 419 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>"
395 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + 420 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] +
396 "</td></tr></table>"; 421 "</td></tr></table>";
397 if ( !m_showHtml ) { 422 if ( !m_showHtml ) {
398 browser->setText( mailHtml+"<font face=fixed>" + QStyleSheet::convertFromPlainText(m_mail[2]) + "</font></body></html>" ); 423 browser->setText( mailHtml+"<font face=fixed>" + QStyleSheet::convertFromPlainText(m_mail[2]) + "</font></body></html>" );
399 } else { 424 } else {
400 browser->setText(mailHtml+m_mail[2].simplifyWhiteSpace()+"</html>"); 425 browser->setText(mailHtml+m_mail[2].simplifyWhiteSpace()+"</html>");
401 } 426 }
402 // remove later in favor of a real handling 427 // remove later in favor of a real handling
403 m_gotBody = true; 428 m_gotBody = true;
404} 429}
405 430
406 431
407ViewMail::~ViewMail() 432ViewMail::~ViewMail()
408{ 433{
409 m_recMail->Wrapper()->cleanMimeCache(); 434 m_recMail->Wrapper()->cleanMimeCache();
410 hide(); 435 hide();
411} 436}
412 437
413void ViewMail::hide() 438void ViewMail::hide()
414{ 439{
415 QWidget::hide(); 440 QWidget::hide();
416 441
417 if (_inLoop) 442 if (_inLoop)
418 { 443 {
419 _inLoop = false; 444 _inLoop = false;
420 qApp->exit_loop(); 445 qApp->exit_loop();
421 446
422 } 447 }
423 448
424} 449}
425 450
426void ViewMail::exec() 451void ViewMail::exec()
427{ 452{
428 show(); 453 show();
429 454
430 if (!_inLoop) 455 if (!_inLoop)
431 { 456 {
432 _inLoop = true; 457 _inLoop = true;
433 qApp->enter_loop(); 458 qApp->enter_loop();
434 } 459 }
435 460
436} 461}
437 462
438QString ViewMail::deHtml(const QString &aString) 463QString ViewMail::deHtml(const QString &aString)
439{ 464{
440 QString string_ = aString; 465 QString string_ = aString;
441 string_.replace(QRegExp("&"), "&amp;"); 466 string_.replace(QRegExp("&"), "&amp;");
442 string_.replace(QRegExp("<"), "&lt;"); 467 string_.replace(QRegExp("<"), "&lt;");
443 string_.replace(QRegExp(">"), "&gt;"); 468 string_.replace(QRegExp(">"), "&gt;");
444 string_.replace(QRegExp("\\n"), "<br>"); 469 string_.replace(QRegExp("\\n"), "<br>");
445 return string_; 470 return string_;
446} 471}
447 472
448void ViewMail::slotReply() 473void ViewMail::slotReply()
449{ 474{
450 if (!m_gotBody) 475 if (!m_gotBody)
451 { 476 {
452 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); 477 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok"));
453 return; 478 return;
454 } 479 }
455 480
456 QString rtext; 481 QString rtext;
457 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 482 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
458 .arg( m_mail[0] ) 483 .arg( m_mail[0] )
459 .arg( m_mail[3] ); 484 .arg( m_mail[3] );
460 485
461 QString text = m_mail[2]; 486 QString text = m_mail[2];
462 QStringList lines = QStringList::split(QRegExp("\\n"), text); 487 QStringList lines = QStringList::split(QRegExp("\\n"), text);
463 QStringList::Iterator it; 488 QStringList::Iterator it;
464 for (it = lines.begin(); it != lines.end(); it++) 489 for (it = lines.begin(); it != lines.end(); it++)
465 { 490 {
466 rtext += "> " + *it + "\n"; 491 rtext += "> " + *it + "\n";
467 } 492 }
468 rtext += "\n"; 493 rtext += "\n";
469 494
470 QString prefix; 495 QString prefix;
diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h
index f5033f0..18b1796 100644
--- a/noncore/net/mail/viewmail.h
+++ b/noncore/net/mail/viewmail.h
@@ -1,93 +1,95 @@
1#ifndef VIEWMAIL_H 1#ifndef VIEWMAIL_H
2#define VIEWMAIL_H 2#define VIEWMAIL_H
3 3
4#include "viewmailbase.h" 4#include "viewmailbase.h"
5#include <libmailwrapper/mailtypes.h> 5#include <libmailwrapper/mailtypes.h>
6 6
7#include <opie2/odialog.h> 7#include <opie2/odialog.h>
8 8
9#include <qlistview.h> 9#include <qlistview.h>
10#include <qmap.h> 10#include <qmap.h>
11#include <qstringlist.h> 11#include <qstringlist.h>
12#include <qvaluelist.h> 12#include <qvaluelist.h>
13 13
14class MailImageDlg; 14class MailImageDlg;
15 15
16namespace Opie { namespace MM { class OImageScrollView; } } 16namespace Opie { namespace MM { class OImageScrollView; } }
17 17
18class AttachItem : public QListViewItem 18class AttachItem : public QListViewItem
19{ 19{
20public: 20public:
21 AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 21 AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
22 const QString&fsize,int num,const QValueList<int>&path); 22 const QString&fsize,int num,const QValueList<int>&path);
23 AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 23 AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
24 const QString&fsize,int num,const QValueList<int>&path); 24 const QString&fsize,int num,const QValueList<int>&path);
25 int Partnumber() { return _partNum; } 25 int Partnumber() { return _partNum; }
26 bool isParentof(const QValueList<int>&path); 26 bool isParentof(const QValueList<int>&path);
27 27
28private: 28private:
29 int _partNum; 29 int _partNum;
30 /* needed for a better display of attachments */ 30 /* needed for a better display of attachments */
31 QValueList<int> _path; 31 QValueList<int> _path;
32}; 32};
33 33
34class ViewMail : public ViewMailBase 34class ViewMail : public ViewMailBase
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37 37
38public: 38public:
39 ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = 0); 39 ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
40 ~ViewMail(); 40 ~ViewMail();
41 41
42 void hide(); 42 void hide();
43 void exec(); 43 void exec();
44 void setMail(const RecMailP&mail ); 44 void setMail(const RecMailP&mail );
45 void setBody(const RecBodyP&body); 45 void setBody(const RecBodyP&body);
46 bool deleted; 46 bool deleted;
47 47
48protected: 48protected:
49 QString deHtml(const QString &string); 49 QString deHtml(const QString &string);
50 AttachItem* searchParent(const QValueList<int>&path); 50 AttachItem* searchParent(const QValueList<int>&path);
51 AttachItem* lastChild(AttachItem*parent); 51 AttachItem* lastChild(AttachItem*parent);
52 52
53 Opie::MM::OImageScrollView*m_lastdlg; 53 Opie::MM::OImageScrollView*m_lastdlg;
54 54
55protected slots: 55protected slots:
56 void slotReply(); 56 void slotReply();
57 void slotForward(); 57 void slotForward();
58 void setText(); 58 void setMainText();
59 void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); 59 void slotItemClicked( QListViewItem * item , const QPoint & point, int c );
60 void slotDeleteMail( ); 60 void slotDeleteMail( );
61 void slotShowHtml( bool ); 61 void slotShowHtml( bool );
62 void slotImageInline(bool); 62 void slotImageInline(bool);
63 63
64private: 64private:
65 void readConfig(); 65 void readConfig();
66 66
67 bool _inLoop; 67 bool _inLoop;
68 QString m_mailHtml; 68 QString m_mailHtml;
69 bool m_gotBody; 69 bool m_gotBody;
70 RecBodyP m_body; 70 RecBodyP m_body;
71 RecMailP m_recMail; 71 RecMailP m_recMail;
72 bool m_showHtml:1; 72 bool m_showHtml:1;
73 bool m_PicsInline:1; 73 bool m_PicsInline:1;
74 unsigned int _icounter; 74 unsigned int _icounter;
75 int m_lastimagepart;
76 int m_lasttextpart;
75 77
76 // 0 from 1 subject 2 bodytext 3 date 78 // 0 from 1 subject 2 bodytext 3 date
77 QMap <int,QString> m_mail; 79 QMap <int,QString> m_mail;
78 // 0 to 1 cc 2 bcc 80 // 0 to 1 cc 2 bcc
79 QMap <int,QStringList> m_mail2; 81 QMap <int,QStringList> m_mail2;
80}; 82};
81 83
82class MailImageDlg:public Opie::Ui::ODialog 84class MailImageDlg:public Opie::Ui::ODialog
83{ 85{
84 Q_OBJECT 86 Q_OBJECT
85public: 87public:
86 MailImageDlg(const QString&,QWidget *parent = 0, const char *name = 0, bool modal = true, WFlags f = 0); 88 MailImageDlg(const QString&,QWidget *parent = 0, const char *name = 0, bool modal = true, WFlags f = 0);
87 ~MailImageDlg(); 89 ~MailImageDlg();
88 void setName(const QString&); 90 void setName(const QString&);
89protected: 91protected:
90 Opie::MM::OImageScrollView*m_imageview; 92 Opie::MM::OImageScrollView*m_imageview;
91}; 93};
92 94
93#endif 95#endif