summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/opiemail.cpp30
-rw-r--r--noncore/net/mail/opiemail.h3
2 files changed, 25 insertions, 8 deletions
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp
index 5399c3c..2f87e44 100644
--- a/noncore/net/mail/opiemail.cpp
+++ b/noncore/net/mail/opiemail.cpp
@@ -1,250 +1,264 @@
1 1
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 "mailistviewitem.h" 6#include "mailistviewitem.h"
7#include "viewmail.h" 7#include "viewmail.h"
8#include "selectstore.h" 8#include "selectstore.h"
9#include "selectsmtp.h" 9#include "selectsmtp.h"
10 10
11#include <libmailwrapper/smtpwrapper.h> 11#include <libmailwrapper/smtpwrapper.h>
12#include <libmailwrapper/mailtypes.h> 12#include <libmailwrapper/mailtypes.h>
13#include <libmailwrapper/abstractmail.h> 13#include <libmailwrapper/abstractmail.h>
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 20
21/* UNIX */
22#include <signal.h>
23
21using namespace Opie::Core; 24using namespace Opie::Core;
22 25
23OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) 26OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags )
24 : MainWindow( parent, name, WStyle_ContextHelp ) 27 : MainWindow( parent, name, WStyle_ContextHelp )
25{ 28{
29 setup_signalblocking();
26 settings = new Settings(); 30 settings = new Settings();
27 31
28 folderView->populate( settings->getAccounts() ); 32 folderView->populate( settings->getAccounts() );
29} 33}
30 34
31OpieMail::~OpieMail() 35OpieMail::~OpieMail()
32{ 36{
33 if (settings) delete settings; 37 if (settings) delete settings;
34} 38}
35 39
40void OpieMail::setup_signalblocking()
41{
42 /* for networking we must block SIGPIPE and Co. */
43 struct sigaction blocking_action,temp_action;
44 blocking_action.sa_handler = SIG_IGN;
45 sigemptyset(&(blocking_action.sa_mask));
46 blocking_action.sa_flags = 0;
47 sigaction(SIGPIPE,&blocking_action,&temp_action);
48}
49
36void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 50void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
37{ 51{
38 // copied from old mail2 52 // copied from old mail2
39 if (msg == "writeMail(QString,QString)") 53 if (msg == "writeMail(QString,QString)")
40 { 54 {
41 QDataStream stream(data,IO_ReadOnly); 55 QDataStream stream(data,IO_ReadOnly);
42 QString name, email; 56 QString name, email;
43 stream >> name >> email; 57 stream >> name >> email;
44 // removing the whitespaces at beginning and end is needed! 58 // removing the whitespaces at beginning and end is needed!
45 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); 59 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace());
46 } 60 }
47 else if (msg == "newMail()") 61 else if (msg == "newMail()")
48 { 62 {
49 slotComposeMail(); 63 slotComposeMail();
50 } 64 }
51} 65}
52 66
53void OpieMail::slotwriteMail(const QString&name,const QString&email) 67void OpieMail::slotwriteMail(const QString&name,const QString&email)
54{ 68{
55 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); 69 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
56 if (!email.isEmpty()) 70 if (!email.isEmpty())
57 { 71 {
58 if (!name.isEmpty()) 72 if (!name.isEmpty())
59 { 73 {
60 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 74 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
61 } 75 }
62 else 76 else
63 { 77 {
64 compose.setTo(email); 78 compose.setTo(email);
65 } 79 }
66 } 80 }
67 compose.slotAdjustColumns(); 81 compose.slotAdjustColumns();
68 QPEApplication::execDialog( &compose ); 82 QPEApplication::execDialog( &compose );
69} 83}
70 84
71void OpieMail::slotComposeMail() 85void OpieMail::slotComposeMail()
72{ 86{
73 odebug << "Compose Mail" << oendl; 87 odebug << "Compose Mail" << oendl;
74 slotwriteMail(0l,0l); 88 slotwriteMail(0l,0l);
75} 89}
76 90
77void OpieMail::slotSendQueued() 91void OpieMail::slotSendQueued()
78{ 92{
79 odebug << "Send Queued" << oendl; 93 odebug << "Send Queued" << oendl;
80 SMTPaccount *smtp = 0; 94 SMTPaccount *smtp = 0;
81 95
82 QList<Account> list = settings->getAccounts(); 96 QList<Account> list = settings->getAccounts();
83 QList<SMTPaccount> smtpList; 97 QList<SMTPaccount> smtpList;
84 smtpList.setAutoDelete(false); 98 smtpList.setAutoDelete(false);
85 Account *it; 99 Account *it;
86 for ( it = list.first(); it; it = list.next() ) 100 for ( it = list.first(); it; it = list.next() )
87 { 101 {
88 if ( it->getType() == MAILLIB::A_SMTP ) 102 if ( it->getType() == MAILLIB::A_SMTP )
89 { 103 {
90 smtp = static_cast<SMTPaccount *>(it); 104 smtp = static_cast<SMTPaccount *>(it);
91 smtpList.append(smtp); 105 smtpList.append(smtp);
92 } 106 }
93 } 107 }
94 if (smtpList.count()==0) 108 if (smtpList.count()==0)
95 { 109 {
96 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); 110 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first"));
97 return; 111 return;
98 } 112 }
99 if (smtpList.count()==1) 113 if (smtpList.count()==1)
100 { 114 {
101 smtp = smtpList.at(0); 115 smtp = smtpList.at(0);
102 } 116 }
103 else 117 else
104 { 118 {
105 smtp = 0; 119 smtp = 0;
106 selectsmtp selsmtp; 120 selectsmtp selsmtp;
107 selsmtp.setSelectionlist(&smtpList); 121 selsmtp.setSelectionlist(&smtpList);
108 if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted ) 122 if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted )
109 { 123 {
110 smtp = selsmtp.selected_smtp(); 124 smtp = selsmtp.selected_smtp();
111 } 125 }
112 } 126 }
113 if (smtp) 127 if (smtp)
114 { 128 {
115 SMTPwrapper * wrap = new SMTPwrapper(smtp); 129 SMTPwrapper * wrap = new SMTPwrapper(smtp);
116 if ( wrap->flushOutbox() ) 130 if ( wrap->flushOutbox() )
117 { 131 {
118 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); 132 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
119 } 133 }
120 delete wrap; 134 delete wrap;
121 } 135 }
122} 136}
123 137
124void OpieMail::slotSearchMails() 138void OpieMail::slotSearchMails()
125{ 139{
126 odebug << "Search Mails" << oendl; 140 odebug << "Search Mails" << oendl;
127} 141}
128 142
129void OpieMail::slotEditSettings() 143void OpieMail::slotEditSettings()
130{ 144{
131 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); 145 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
132 QPEApplication::execDialog( &settingsDialog ); 146 QPEApplication::execDialog( &settingsDialog );
133} 147}
134 148
135void OpieMail::slotEditAccounts() 149void OpieMail::slotEditAccounts()
136{ 150{
137 odebug << "Edit Accounts" << oendl; 151 odebug << "Edit Accounts" << oendl;
138 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); 152 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp );
139 eaDialog.slotAdjustColumns(); 153 eaDialog.slotAdjustColumns();
140 QPEApplication::execDialog( &eaDialog ); 154 QPEApplication::execDialog( &eaDialog );
141 if ( settings ) delete settings; 155 if ( settings ) delete settings;
142 settings = new Settings(); 156 settings = new Settings();
143 157
144 folderView->populate( settings->getAccounts() ); 158 folderView->populate( settings->getAccounts() );
145} 159}
146 160
147void OpieMail::displayMail() 161void OpieMail::displayMail()
148{ 162{
149 QListViewItem*item = mailView->currentItem(); 163 QListViewItem*item = mailView->currentItem();
150 if (!item) return; 164 if (!item) return;
151 RecMailP mail = ((MailListViewItem*)item)->data(); 165 RecMailP mail = ((MailListViewItem*)item)->data();
152 RecBodyP body = folderView->fetchBody(mail); 166 RecBodyP body = folderView->fetchBody(mail);
153 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); 167 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp );
154 readMail.setBody( body ); 168 readMail.setBody( body );
155 readMail.setMail( mail ); 169 readMail.setMail( mail );
156 readMail.showMaximized(); 170 readMail.showMaximized();
157 readMail.exec(); 171 readMail.exec();
158 172
159 if ( readMail.deleted ) 173 if ( readMail.deleted )
160 { 174 {
161 folderView->refreshCurrent(); 175 folderView->refreshCurrent();
162 } 176 }
163 else 177 else
164 { 178 {
165 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); 179 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) );
166 } 180 }
167} 181}
168 182
169void OpieMail::slotDeleteMail() 183void OpieMail::slotDeleteMail()
170{ 184{
171 if (!mailView->currentItem()) return; 185 if (!mailView->currentItem()) return;
172 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 186 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
173 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 ) 187 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 )
174 { 188 {
175 mail->Wrapper()->deleteMail( mail ); 189 mail->Wrapper()->deleteMail( mail );
176 folderView->refreshCurrent(); 190 folderView->refreshCurrent();
177 } 191 }
178} 192}
179 193
180void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) 194void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
181{ 195{
182 if (!mailView->currentItem()) return; 196 if (!mailView->currentItem()) return;
183 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); 197 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType();
184 /* just the RIGHT button - or hold on pda */ 198 /* just the RIGHT button - or hold on pda */
185 if (button!=2) {return;} 199 if (button!=2) {return;}
186 odebug << "Event right/hold" << oendl; 200 odebug << "Event right/hold" << oendl;
187 if (!item) return; 201 if (!item) return;
188 QPopupMenu *m = new QPopupMenu(0); 202 QPopupMenu *m = new QPopupMenu(0);
189 if (m) 203 if (m)
190 { 204 {
191 if (mailtype==MAILLIB::A_NNTP) { 205 if (mailtype==MAILLIB::A_NNTP) {
192 m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); 206 m->insertItem(tr("Read this posting"),this,SLOT(displayMail()));
193// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); 207// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail()));
194 } else { 208 } else {
195 if (folderView->currentisDraft()) { 209 if (folderView->currentisDraft()) {
196 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); 210 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail()));
197 } 211 }
198 m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); 212 m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
199 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); 213 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
200 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); 214 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail()));
201 } 215 }
202 m->setFocus(); 216 m->setFocus();
203 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 217 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
204 delete m; 218 delete m;
205 } 219 }
206} 220}
207 221
208void OpieMail::slotShowFolders( bool show ) 222void OpieMail::slotShowFolders( bool show )
209{ 223{
210 odebug << "Show Folders" << oendl; 224 odebug << "Show Folders" << oendl;
211 if ( show && folderView->isHidden() ) 225 if ( show && folderView->isHidden() )
212 { 226 {
213 odebug << "-> showing" << oendl; 227 odebug << "-> showing" << oendl;
214 folderView->show(); 228 folderView->show();
215 } 229 }
216 else if ( !show && !folderView->isHidden() ) 230 else if ( !show && !folderView->isHidden() )
217 { 231 {
218 odebug << "-> hiding" << oendl; 232 odebug << "-> hiding" << oendl;
219 folderView->hide(); 233 folderView->hide();
220 } 234 }
221} 235}
222 236
223void OpieMail::refreshMailView(const QValueList<RecMailP>&list) 237void OpieMail::refreshMailView(const QValueList<RecMailP>&list)
224{ 238{
225 MailListViewItem*item = 0; 239 MailListViewItem*item = 0;
226 mailView->clear(); 240 mailView->clear();
227 241
228 QValueList<RecMailP>::ConstIterator it; 242 QValueList<RecMailP>::ConstIterator it;
229 for (it = list.begin(); it != list.end();++it) 243 for (it = list.begin(); it != list.end();++it)
230 { 244 {
231 item = new MailListViewItem(mailView,item); 245 item = new MailListViewItem(mailView,item);
232 item->storeData((*it)); 246 item->storeData((*it));
233 item->showEntry(); 247 item->showEntry();
234 } 248 }
235} 249}
236 250
237void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) 251void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int )
238{ 252{
239 /* just LEFT button - or tap with stylus on pda */ 253 /* just LEFT button - or tap with stylus on pda */
240 if (button!=1) return; 254 if (button!=1) return;
241 if (!item) return; 255 if (!item) return;
242 if (folderView->currentisDraft()) { 256 if (folderView->currentisDraft()) {
243 reEditMail(); 257 reEditMail();
244 } else { 258 } else {
245 displayMail(); 259 displayMail();
246 } 260 }
247} 261}
248 262
249void OpieMail::slotMoveCopyMail() 263void OpieMail::slotMoveCopyMail()
250{ 264{
diff --git a/noncore/net/mail/opiemail.h b/noncore/net/mail/opiemail.h
index b93bd60..3d25b3d 100644
--- a/noncore/net/mail/opiemail.h
+++ b/noncore/net/mail/opiemail.h
@@ -5,38 +5,41 @@
5#include <libmailwrapper/settings.h> 5#include <libmailwrapper/settings.h>
6 6
7#include <opie2/osmartpointer.h> 7#include <opie2/osmartpointer.h>
8#include <libmailwrapper/mailtypes.h> 8#include <libmailwrapper/mailtypes.h>
9 9
10class OpieMail : public MainWindow 10class OpieMail : public MainWindow
11{ 11{
12 Q_OBJECT 12 Q_OBJECT
13 13
14public: 14public:
15 OpieMail( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 15 OpieMail( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
16 virtual ~OpieMail(); 16 virtual ~OpieMail();
17 static QString appName() { return QString::fromLatin1("opiemail"); } 17 static QString appName() { return QString::fromLatin1("opiemail"); }
18 18
19public slots: 19public slots:
20 virtual void slotwriteMail(const QString&name,const QString&email); 20 virtual void slotwriteMail(const QString&name,const QString&email);
21 virtual void slotComposeMail(); 21 virtual void slotComposeMail();
22 virtual void appMessage(const QCString &msg, const QByteArray &data); 22 virtual void appMessage(const QCString &msg, const QByteArray &data);
23protected slots: 23protected slots:
24 virtual void slotSendQueued(); 24 virtual void slotSendQueued();
25 virtual void slotSearchMails(); 25 virtual void slotSearchMails();
26 virtual void slotEditSettings(); 26 virtual void slotEditSettings();
27 virtual void slotEditAccounts(); 27 virtual void slotEditAccounts();
28 virtual void displayMail(); 28 virtual void displayMail();
29 virtual void slotDeleteMail(); 29 virtual void slotDeleteMail();
30 virtual void mailHold(int, QListViewItem *,const QPoint&,int); 30 virtual void mailHold(int, QListViewItem *,const QPoint&,int);
31 virtual void slotShowFolders( bool show ); 31 virtual void slotShowFolders( bool show );
32 virtual void refreshMailView(const QValueList<RecMailP>&); 32 virtual void refreshMailView(const QValueList<RecMailP>&);
33 virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int ); 33 virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int );
34 virtual void slotMoveCopyMail(); 34 virtual void slotMoveCopyMail();
35 virtual void reEditMail(); 35 virtual void reEditMail();
36 36
37protected:
38 void setup_signalblocking();
39
37private: 40private:
38 Settings *settings; 41 Settings *settings;
39 42
40}; 43};
41 44
42#endif 45#endif