summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/mainwindow.cpp5
-rw-r--r--noncore/net/mail/mainwindow.h1
-rw-r--r--noncore/net/mail/opiemail.cpp5
-rw-r--r--noncore/net/mail/opiemail.h1
4 files changed, 11 insertions, 1 deletions
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index d2e887b..e16f853 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -1,261 +1,264 @@
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#include <qmessagebox.h> 6#include <qmessagebox.h>
7#include <qtextstream.h> 7#include <qtextstream.h>
8 8
9#include <qpe/qpeapplication.h> 9#include <qpe/qpeapplication.h>
10#include <qpe/resource.h> 10#include <qpe/resource.h>
11 11
12 12
13#include "defines.h" 13#include "defines.h"
14#include "mainwindow.h" 14#include "mainwindow.h"
15#include "viewmail.h" 15#include "viewmail.h"
16#include <libmailwrapper/mailtypes.h> 16#include <libmailwrapper/mailtypes.h>
17#include "mailistviewitem.h" 17#include "mailistviewitem.h"
18 18
19 19
20MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 20MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
21 : QMainWindow( parent, name, flags ) 21 : QMainWindow( parent, name, flags )
22{ 22{
23 23
24 setCaption( tr( "Mail" ) ); 24 setCaption( tr( "Mail" ) );
25 setToolBarsMovable( false ); 25 setToolBarsMovable( false );
26 26
27 toolBar = new QToolBar( this ); 27 toolBar = new QToolBar( this );
28 menuBar = new QMenuBar( toolBar ); 28 menuBar = new QMenuBar( toolBar );
29 mailMenu = new QPopupMenu( menuBar ); 29 mailMenu = new QPopupMenu( menuBar );
30 menuBar->insertItem( tr( "Mail" ), mailMenu ); 30 menuBar->insertItem( tr( "Mail" ), mailMenu );
31 settingsMenu = new QPopupMenu( menuBar ); 31 settingsMenu = new QPopupMenu( menuBar );
32 menuBar->insertItem( tr( "Settings" ), settingsMenu ); 32 menuBar->insertItem( tr( "Settings" ), settingsMenu );
33 33
34 addToolBar( toolBar ); 34 addToolBar( toolBar );
35 toolBar->setHorizontalStretchable( true ); 35 toolBar->setHorizontalStretchable( true );
36 36
37 QLabel *spacer = new QLabel( toolBar ); 37 QLabel *spacer = new QLabel( toolBar );
38 spacer->setBackgroundMode( QWidget::PaletteButton ); 38 spacer->setBackgroundMode( QWidget::PaletteButton );
39 toolBar->setStretchableWidget( spacer ); 39 toolBar->setStretchableWidget( spacer );
40 40
41 composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, 41 composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL,
42 0, 0, this ); 42 0, 0, this );
43 composeMail->addTo( toolBar ); 43 composeMail->addTo( toolBar );
44 composeMail->addTo( mailMenu ); 44 composeMail->addTo( mailMenu );
45 45
46 sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, 46 sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED,
47 0, 0, this ); 47 0, 0, this );
48 sendQueued->addTo( toolBar ); 48 sendQueued->addTo( toolBar );
49 sendQueued->addTo( mailMenu ); 49 sendQueued->addTo( mailMenu );
50 50
51 /* 51 /*
52 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, 52 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC,
53 0, 0, this ); 53 0, 0, this );
54 syncFolders->addTo( toolBar ); 54 syncFolders->addTo( toolBar );
55 syncFolders->addTo( mailMenu ); 55 syncFolders->addTo( mailMenu );
56 */ 56 */
57 57
58 showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, 58 showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS,
59 0, 0, this, 0, true ); 59 0, 0, this, 0, true );
60 showFolders->addTo( toolBar ); 60 showFolders->addTo( toolBar );
61 showFolders->addTo( mailMenu ); 61 showFolders->addTo( mailMenu );
62 showFolders->setOn( true ); 62 showFolders->setOn( true );
63 connect(showFolders, SIGNAL( toggled( bool ) ), 63 connect(showFolders, SIGNAL( toggled( bool ) ),
64 SLOT( slotShowFolders( bool ) ) ); 64 SLOT( slotShowFolders( bool ) ) );
65 65
66 /* 66 /*
67 searchMails = new QAction( tr( "Search mails" ), QIconSet( Resource::loadPixmap("find") ), 67 searchMails = new QAction( tr( "Search mails" ), QIconSet( Resource::loadPixmap("find") ),
68 0, 0, this ); 68 0, 0, this );
69 searchMails->addTo( toolBar ); 69 searchMails->addTo( toolBar );
70 searchMails->addTo( mailMenu ); 70 searchMails->addTo( mailMenu );
71 */ 71 */
72 72
73 deleteMails = new QAction(tr("Delete Mail"), QIconSet( Resource::loadPixmap("trash")), 0, 0, this); 73 deleteMails = new QAction(tr("Delete Mail"), QIconSet( Resource::loadPixmap("trash")), 0, 0, this);
74 deleteMails->addTo( toolBar ); 74 deleteMails->addTo( toolBar );
75 deleteMails->addTo( mailMenu ); 75 deleteMails->addTo( mailMenu );
76 connect( deleteMails, SIGNAL( activated() ), 76 connect( deleteMails, SIGNAL( activated() ),
77 SLOT( slotDeleteMail() ) ); 77 SLOT( slotDeleteMail() ) );
78 78
79 editSettings = new QAction( tr( "Edit settings" ), QIconSet( Resource::loadPixmap("SettingsIcon") ) , 79 editSettings = new QAction( tr( "Edit settings" ), QIconSet( Resource::loadPixmap("SettingsIcon") ) ,
80 0, 0, this ); 80 0, 0, this );
81 editSettings->addTo( settingsMenu ); 81 editSettings->addTo( settingsMenu );
82 connect( editSettings, SIGNAL( activated() ), 82 connect( editSettings, SIGNAL( activated() ),
83 SLOT( slotEditSettings() ) ); 83 SLOT( slotEditSettings() ) );
84 editAccounts = new QAction( tr( "Configure accounts" ), QIconSet( Resource::loadPixmap("SettingsIcon") ) , 84 editAccounts = new QAction( tr( "Configure accounts" ), QIconSet( Resource::loadPixmap("mail/editaccounts") ) ,
85 0, 0, this ); 85 0, 0, this );
86 editAccounts->addTo( settingsMenu ); 86 editAccounts->addTo( settingsMenu );
87 87
88 //setCentralWidget( view ); 88 //setCentralWidget( view );
89 89
90 QVBox* wrapperBox = new QVBox( this ); 90 QVBox* wrapperBox = new QVBox( this );
91 setCentralWidget( wrapperBox ); 91 setCentralWidget( wrapperBox );
92 92
93 QWidget *view = new QWidget( wrapperBox ); 93 QWidget *view = new QWidget( wrapperBox );
94 94
95 layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); 95 layout = new QBoxLayout ( view, QBoxLayout::LeftToRight );
96 96
97 folderView = new AccountView( view ); 97 folderView = new AccountView( view );
98 folderView->header()->hide(); 98 folderView->header()->hide();
99 folderView->setRootIsDecorated( true ); 99 folderView->setRootIsDecorated( true );
100 folderView->addColumn( tr( "Mailbox" ) ); 100 folderView->addColumn( tr( "Mailbox" ) );
101 101
102 layout->addWidget( folderView ); 102 layout->addWidget( folderView );
103 103
104 mailView = new QListView( view ); 104 mailView = new QListView( view );
105 mailView->addColumn( tr( "" ) ); 105 mailView->addColumn( tr( "" ) );
106 mailView->addColumn( tr( "Subject" ),QListView::Manual ); 106 mailView->addColumn( tr( "Subject" ),QListView::Manual );
107 mailView->addColumn( tr( "Sender" ),QListView::Manual ); 107 mailView->addColumn( tr( "Sender" ),QListView::Manual );
108 mailView->addColumn( tr( "Size" ),QListView::Manual); 108 mailView->addColumn( tr( "Size" ),QListView::Manual);
109 mailView->addColumn( tr( "Date" )); 109 mailView->addColumn( tr( "Date" ));
110 mailView->setAllColumnsShowFocus(true); 110 mailView->setAllColumnsShowFocus(true);
111 mailView->setSorting(-1); 111 mailView->setSorting(-1);
112 112
113 statusWidget = new StatusWidget( wrapperBox ); 113 statusWidget = new StatusWidget( wrapperBox );
114 statusWidget->hide(); 114 statusWidget->hide();
115 115
116 layout->addWidget( mailView ); 116 layout->addWidget( mailView );
117 layout->setStretchFactor( folderView, 1 ); 117 layout->setStretchFactor( folderView, 1 );
118 layout->setStretchFactor( mailView, 2 ); 118 layout->setStretchFactor( mailView, 2 );
119 119
120 slotAdjustLayout(); 120 slotAdjustLayout();
121 121
122 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); 122 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold);
123 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); 123 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold);
124 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 connect( mailView, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, 127 connect( mailView, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this,
128 SLOT( mailHold( int, QListViewItem *,const QPoint&,int ) ) ); 128 SLOT( mailHold( int, QListViewItem *,const QPoint&,int ) ) );
129 connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); 129 connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*)));
130 130
131 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 131 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
132} 132}
133 133
134MainWindow::~MainWindow()
135{
136}
134 137
135void MainWindow::slotAdjustLayout() { 138void MainWindow::slotAdjustLayout() {
136 139
137 QWidget *d = QApplication::desktop(); 140 QWidget *d = QApplication::desktop();
138 141
139 if ( d->width() < d->height() ) { 142 if ( d->width() < d->height() ) {
140 layout->setDirection( QBoxLayout::TopToBottom ); 143 layout->setDirection( QBoxLayout::TopToBottom );
141 } else { 144 } else {
142 layout->setDirection( QBoxLayout::LeftToRight ); 145 layout->setDirection( QBoxLayout::LeftToRight );
143 } 146 }
144} 147}
145 148
146void MainWindow::slotAdjustColumns() 149void MainWindow::slotAdjustColumns()
147{ 150{
148 bool hidden = folderView->isHidden(); 151 bool hidden = folderView->isHidden();
149 if ( hidden ) folderView->show(); 152 if ( hidden ) folderView->show();
150 folderView->setColumnWidth( 0, folderView->visibleWidth() ); 153 folderView->setColumnWidth( 0, folderView->visibleWidth() );
151 if ( hidden ) folderView->hide(); 154 if ( hidden ) folderView->hide();
152 155
153 mailView->setColumnWidth( 0, 10 ); 156 mailView->setColumnWidth( 0, 10 );
154 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); 157 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 );
155 mailView->setColumnWidth( 2, 80 ); 158 mailView->setColumnWidth( 2, 80 );
156 mailView->setColumnWidth( 3, 50 ); 159 mailView->setColumnWidth( 3, 50 );
157 mailView->setColumnWidth( 4, 50 ); 160 mailView->setColumnWidth( 4, 50 );
158} 161}
159 162
160void MainWindow::slotEditSettings() 163void MainWindow::slotEditSettings()
161{ 164{
162} 165}
163 166
164void MainWindow::slotShowFolders( bool show ) 167void MainWindow::slotShowFolders( bool show )
165{ 168{
166 qDebug( "Show Folders" ); 169 qDebug( "Show Folders" );
167 if ( show && folderView->isHidden() ) { 170 if ( show && folderView->isHidden() ) {
168 qDebug( "-> showing" ); 171 qDebug( "-> showing" );
169 folderView->show(); 172 folderView->show();
170 } else if ( !show && !folderView->isHidden() ) { 173 } else if ( !show && !folderView->isHidden() ) {
171 qDebug( "-> hiding" ); 174 qDebug( "-> hiding" );
172 folderView->hide(); 175 folderView->hide();
173 } 176 }
174} 177}
175 178
176void MainWindow::refreshMailView(QList<RecMail>*list) 179void MainWindow::refreshMailView(QList<RecMail>*list)
177{ 180{
178 MailListViewItem*item = 0; 181 MailListViewItem*item = 0;
179 mailView->clear(); 182 mailView->clear();
180 for (unsigned int i = 0; i < list->count();++i) { 183 for (unsigned int i = 0; i < list->count();++i) {
181 item = new MailListViewItem(mailView,item); 184 item = new MailListViewItem(mailView,item);
182 item->storeData(*(list->at(i))); 185 item->storeData(*(list->at(i)));
183 item->showEntry(); 186 item->showEntry();
184 } 187 }
185} 188}
186void MainWindow::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) 189void MainWindow::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int )
187{ 190{
188 /* just LEFT button - or tap with stylus on pda */ 191 /* just LEFT button - or tap with stylus on pda */
189 if (button!=1) return; 192 if (button!=1) return;
190 if (!item) return; 193 if (!item) return;
191 displayMail(); 194 displayMail();
192} 195}
193 196
194void MainWindow::displayMail() 197void MainWindow::displayMail()
195{ 198{
196 QListViewItem*item = mailView->currentItem(); 199 QListViewItem*item = mailView->currentItem();
197 if (!item) return; 200 if (!item) return;
198 RecMail mail = ((MailListViewItem*)item)->data(); 201 RecMail mail = ((MailListViewItem*)item)->data();
199 RecBody body = folderView->fetchBody(mail); 202 RecBody body = folderView->fetchBody(mail);
200 ViewMail readMail( this ); 203 ViewMail readMail( this );
201 readMail.setBody( body ); 204 readMail.setBody( body );
202 readMail.setMail( mail ); 205 readMail.setMail( mail );
203 readMail.showMaximized(); 206 readMail.showMaximized();
204 readMail.exec(); 207 readMail.exec();
205 208
206 if ( readMail.deleted ) { 209 if ( readMail.deleted ) {
207 folderView->refreshCurrent(); 210 folderView->refreshCurrent();
208 } else { 211 } else {
209 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "") ); 212 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "") );
210 } 213 }
211} 214}
212 215
213void MainWindow::slotDeleteMail() 216void MainWindow::slotDeleteMail()
214{ 217{
215 if (!mailView->currentItem()) return; 218 if (!mailView->currentItem()) return;
216 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); 219 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
217 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 ) { 220 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 ) {
218 mail.Wrapper()->deleteMail( mail ); 221 mail.Wrapper()->deleteMail( mail );
219 folderView->refreshCurrent(); 222 folderView->refreshCurrent();
220 } 223 }
221} 224}
222 225
223void MainWindow::mailHold(int button, QListViewItem *item,const QPoint&,int ) 226void MainWindow::mailHold(int button, QListViewItem *item,const QPoint&,int )
224{ 227{
225 /* just the RIGHT button - or hold on pda */ 228 /* just the RIGHT button - or hold on pda */
226 if (button!=2) {return;} 229 if (button!=2) {return;}
227 qDebug("Event right/hold"); 230 qDebug("Event right/hold");
228 if (!item) return; 231 if (!item) return;
229 QPopupMenu *m = new QPopupMenu(0); 232 QPopupMenu *m = new QPopupMenu(0);
230 if (m) { 233 if (m) {
231 m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); 234 m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
232 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); 235 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
233 m->setFocus(); 236 m->setFocus();
234 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 237 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
235 delete m; 238 delete m;
236 } 239 }
237} 240}
238 241
239MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) 242MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item )
240 :QListViewItem(parent,item),mail_data() 243 :QListViewItem(parent,item),mail_data()
241{ 244{
242} 245}
243 246
244void MailListViewItem::showEntry() 247void MailListViewItem::showEntry()
245{ 248{
246 if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) { 249 if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) {
247 setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") ); 250 setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") );
248 } else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { 251 } else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) {
249 /* I think it looks nicer if there are not such a log of icons but only on mails 252 /* I think it looks nicer if there are not such a log of icons but only on mails
250 replied or new - Alwin*/ 253 replied or new - Alwin*/
251 //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") ); 254 //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") );
252 } else { 255 } else {
253 setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") ); 256 setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") );
254 } 257 }
255 double s = mail_data.Msgsize(); 258 double s = mail_data.Msgsize();
256 int w; 259 int w;
257 w=0; 260 w=0;
258 261
259 while (s>1024) { 262 while (s>1024) {
260 s/=1024; 263 s/=1024;
261 ++w; 264 ++w;
diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h
index 0e077f6..15d216a 100644
--- a/noncore/net/mail/mainwindow.h
+++ b/noncore/net/mail/mainwindow.h
@@ -1,48 +1,49 @@
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" 12#include "statuswidget.h"
13 13
14class RecMail; 14class RecMail;
15 15
16class MainWindow : public QMainWindow 16class MainWindow : public QMainWindow
17{ 17{
18 Q_OBJECT 18 Q_OBJECT
19 19
20public: 20public:
21 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 21 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
22 virtual ~MainWindow();
22 23
23public slots: 24public slots:
24 virtual void slotAdjustColumns(); 25 virtual void slotAdjustColumns();
25 26
26protected slots: 27protected slots:
27 virtual void slotShowFolders( bool show ); 28 virtual void slotShowFolders( bool show );
28 virtual void refreshMailView(QList<RecMail>*); 29 virtual void refreshMailView(QList<RecMail>*);
29 virtual void displayMail(); 30 virtual void displayMail();
30 virtual void slotDeleteMail(); 31 virtual void slotDeleteMail();
31 virtual void mailHold(int, QListViewItem *,const QPoint&,int); 32 virtual void mailHold(int, QListViewItem *,const QPoint&,int);
32 virtual void slotAdjustLayout(); 33 virtual void slotAdjustLayout();
33 virtual void slotEditSettings(); 34 virtual void slotEditSettings();
34 virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int ); 35 virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int );
35 36
36protected: 37protected:
37 QToolBar *toolBar; 38 QToolBar *toolBar;
38 StatusWidget *statusWidget; 39 StatusWidget *statusWidget;
39 QMenuBar *menuBar; 40 QMenuBar *menuBar;
40 QPopupMenu *mailMenu, *settingsMenu; 41 QPopupMenu *mailMenu, *settingsMenu;
41 QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, 42 QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails,
42 *editSettings, *editAccounts, *syncFolders; 43 *editSettings, *editAccounts, *syncFolders;
43 AccountView *folderView; 44 AccountView *folderView;
44 QListView *mailView; 45 QListView *mailView;
45 QBoxLayout *layout; 46 QBoxLayout *layout;
46}; 47};
47 48
48#endif 49#endif
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp
index fcd48e2..c888708 100644
--- a/noncore/net/mail/opiemail.cpp
+++ b/noncore/net/mail/opiemail.cpp
@@ -1,115 +1,120 @@
1#include <qmessagebox.h> 1#include <qmessagebox.h>
2#include "settingsdialog.h" 2#include "settingsdialog.h"
3#include "opiemail.h" 3#include "opiemail.h"
4#include "editaccounts.h" 4#include "editaccounts.h"
5#include "composemail.h" 5#include "composemail.h"
6#include <libmailwrapper/smtpwrapper.h> 6#include <libmailwrapper/smtpwrapper.h>
7#include <qpe/qcopenvelope_qws.h> 7#include <qpe/qcopenvelope_qws.h>
8#include <qaction.h> 8#include <qaction.h>
9#include <qapplication.h> 9#include <qapplication.h>
10 10
11OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) 11OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags )
12 : MainWindow( parent, name, flags ) 12 : MainWindow( parent, name, flags )
13{ 13{
14 settings = new Settings(); 14 settings = new Settings();
15 15
16 folderView->populate( settings->getAccounts() ); 16 folderView->populate( settings->getAccounts() );
17 17
18 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); 18 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) );
19 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); 19 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) );
20// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); 20// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) );
21 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); 21 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) );
22 // Added by Stefan Eilers to allow starting by addressbook.. 22 // Added by Stefan Eilers to allow starting by addressbook..
23 // copied from old mail2 23 // copied from old mail2
24#if !defined(QT_NO_COP) 24#if !defined(QT_NO_COP)
25 connect( qApp, SIGNAL( appMessage( const QCString&, const QByteArray& ) ), 25 connect( qApp, SIGNAL( appMessage( const QCString&, const QByteArray& ) ),
26 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); 26 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) );
27#endif 27#endif
28 28
29 29
30 30
31} 31}
32 32
33OpieMail::~OpieMail()
34{
35 if (settings) delete settings;
36}
37
33void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 38void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
34{ 39{
35 // copied from old mail2 40 // copied from old mail2
36 if (msg == "writeMail(QString,QString)") { 41 if (msg == "writeMail(QString,QString)") {
37 QDataStream stream(data,IO_ReadOnly); 42 QDataStream stream(data,IO_ReadOnly);
38 QString name, email; 43 QString name, email;
39 stream >> name >> email; 44 stream >> name >> email;
40 // removing the whitespaces at beginning and end is needed! 45 // removing the whitespaces at beginning and end is needed!
41 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); 46 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace());
42 } else if (msg == "newMail()") { 47 } else if (msg == "newMail()") {
43 slotComposeMail(); 48 slotComposeMail();
44 } 49 }
45} 50}
46 51
47void OpieMail::slotwriteMail(const QString&name,const QString&email) 52void OpieMail::slotwriteMail(const QString&name,const QString&email)
48{ 53{
49 ComposeMail compose( settings, this, 0 , true ); 54 ComposeMail compose( settings, this, 0 , true );
50 if (!email.isEmpty()) { 55 if (!email.isEmpty()) {
51 if (!name.isEmpty()) { 56 if (!name.isEmpty()) {
52 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 57 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
53 } else { 58 } else {
54 compose.setTo(email); 59 compose.setTo(email);
55 } 60 }
56 } 61 }
57 compose.showMaximized(); 62 compose.showMaximized();
58 compose.slotAdjustColumns(); 63 compose.slotAdjustColumns();
59 compose.exec(); 64 compose.exec();
60} 65}
61 66
62void OpieMail::slotComposeMail() 67void OpieMail::slotComposeMail()
63{ 68{
64 qDebug( "Compose Mail" ); 69 qDebug( "Compose Mail" );
65 slotwriteMail(0l,0l); 70 slotwriteMail(0l,0l);
66} 71}
67 72
68void OpieMail::slotSendQueued() 73void OpieMail::slotSendQueued()
69{ 74{
70 qDebug( "Send Queued" ); 75 qDebug( "Send Queued" );
71 SMTPaccount *smtp = 0; 76 SMTPaccount *smtp = 0;
72 77
73 QList<Account> list = settings->getAccounts(); 78 QList<Account> list = settings->getAccounts();
74 Account *it; 79 Account *it;
75// if (list.count()==1) { 80// if (list.count()==1) {
76 for ( it = list.first(); it; it = list.next() ) { 81 for ( it = list.first(); it; it = list.next() ) {
77 if ( it->getType().compare( "SMTP" ) == 0 ) { 82 if ( it->getType().compare( "SMTP" ) == 0 ) {
78 smtp = static_cast<SMTPaccount *>(it); 83 smtp = static_cast<SMTPaccount *>(it);
79 break; 84 break;
80 } 85 }
81 } 86 }
82// } 87// }
83 if (smtp) { 88 if (smtp) {
84 SMTPwrapper * wrap = new SMTPwrapper(settings); 89 SMTPwrapper * wrap = new SMTPwrapper(settings);
85 if ( wrap->flushOutbox(smtp) ) { 90 if ( wrap->flushOutbox(smtp) ) {
86 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); 91 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
87 } 92 }
88 } 93 }
89} 94}
90 95
91void OpieMail::slotSearchMails() 96void OpieMail::slotSearchMails()
92{ 97{
93 qDebug( "Search Mails" ); 98 qDebug( "Search Mails" );
94} 99}
95 100
96void OpieMail::slotEditSettings() 101void OpieMail::slotEditSettings()
97{ 102{
98 SettingsDialog settingsDialog( this, 0, true ); 103 SettingsDialog settingsDialog( this, 0, true );
99 settingsDialog.showMaximized(); 104 settingsDialog.showMaximized();
100 settingsDialog.exec(); 105 settingsDialog.exec();
101} 106}
102 107
103void OpieMail::slotEditAccounts() 108void OpieMail::slotEditAccounts()
104{ 109{
105 qDebug( "Edit Accounts" ); 110 qDebug( "Edit Accounts" );
106 EditAccounts eaDialog( settings, this, 0, true ); 111 EditAccounts eaDialog( settings, this, 0, true );
107 eaDialog.showMaximized(); 112 eaDialog.showMaximized();
108 eaDialog.slotAdjustColumns(); 113 eaDialog.slotAdjustColumns();
109 eaDialog.exec(); 114 eaDialog.exec();
110 if ( settings ) delete settings; 115 if ( settings ) delete settings;
111 settings = new Settings(); 116 settings = new Settings();
112 117
113 folderView->populate( settings->getAccounts() ); 118 folderView->populate( settings->getAccounts() );
114} 119}
115 120
diff --git a/noncore/net/mail/opiemail.h b/noncore/net/mail/opiemail.h
index ebed5d8..69b8d43 100644
--- a/noncore/net/mail/opiemail.h
+++ b/noncore/net/mail/opiemail.h
@@ -1,30 +1,31 @@
1#ifndef OPIEMAIL_H 1#ifndef OPIEMAIL_H
2#define OPIEMAIL_H 2#define OPIEMAIL_H
3 3
4#include "mainwindow.h" 4#include "mainwindow.h"
5#include <libmailwrapper/settings.h> 5#include <libmailwrapper/settings.h>
6 6
7 7
8class OpieMail : public MainWindow 8class OpieMail : public MainWindow
9{ 9{
10 Q_OBJECT 10 Q_OBJECT
11 11
12public: 12public:
13 OpieMail( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 13 OpieMail( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
14 virtual ~OpieMail();
14 static QString appName() { return QString::fromLatin1("opiemail"); } 15 static QString appName() { return QString::fromLatin1("opiemail"); }
15 16
16public slots: 17public slots:
17 virtual void slotwriteMail(const QString&name,const QString&email); 18 virtual void slotwriteMail(const QString&name,const QString&email);
18 virtual void slotComposeMail(); 19 virtual void slotComposeMail();
19 virtual void appMessage(const QCString &msg, const QByteArray &data); 20 virtual void appMessage(const QCString &msg, const QByteArray &data);
20protected slots: 21protected slots:
21 virtual void slotSendQueued(); 22 virtual void slotSendQueued();
22 virtual void slotSearchMails(); 23 virtual void slotSearchMails();
23 virtual void slotEditSettings(); 24 virtual void slotEditSettings();
24 virtual void slotEditAccounts(); 25 virtual void slotEditAccounts();
25private: 26private:
26 Settings *settings; 27 Settings *settings;
27 28
28}; 29};
29 30
30#endif 31#endif