summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp1
-rw-r--r--kmicromail/mainwindow.cpp2
-rw-r--r--kmicromail/mainwindow.h1
3 files changed, 2 insertions, 2 deletions
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp
index b890725..d9496af 100644
--- a/kmicromail/libmailwrapper/imapwrapper.cpp
+++ b/kmicromail/libmailwrapper/imapwrapper.cpp
@@ -1,254 +1,253 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2#include <stdlib.h> 2#include <stdlib.h>
3#include <libetpan/libetpan.h> 3#include <libetpan/libetpan.h>
4#include <qpe/global.h> 4#include <qpe/global.h>
5#include <qapplication.h> 5#include <qapplication.h>
6#include "imapwrapper.h" 6#include "imapwrapper.h"
7#include "mailtypes.h" 7#include "mailtypes.h"
8#include "logindialog.h" 8#include "logindialog.h"
9#include <qprogressbar.h> 9#include <qprogressbar.h>
10#include "genericwrapper.h" 10#include "genericwrapper.h"
11#include <kglobal.h> 11#include <kglobal.h>
12 12
13using namespace Opie::Core; 13using namespace Opie::Core;
14int IMAPwrapper::mMax = 0; 14int IMAPwrapper::mMax = 0;
15int IMAPwrapper::mCurrent = 0; 15int IMAPwrapper::mCurrent = 0;
16 16
17IMAPwrapper::IMAPwrapper( IMAPaccount *a ) 17IMAPwrapper::IMAPwrapper( IMAPaccount *a )
18 : AbstractMail() 18 : AbstractMail()
19{ 19{
20 account = a; 20 account = a;
21 m_imap = 0; 21 m_imap = 0;
22 m_Lastmbox = ""; 22 m_Lastmbox = "";
23 mCurrent = 0; 23 mCurrent = 0;
24 mMax = 0; 24 mMax = 0;
25} 25}
26 26
27IMAPwrapper::~IMAPwrapper() 27IMAPwrapper::~IMAPwrapper()
28{ 28{
29 logout(); 29 logout();
30} 30}
31 31
32/* to avoid to often select statements in loops etc. 32/* to avoid to often select statements in loops etc.
33 we trust that we are logged in and connection is established!*/ 33 we trust that we are logged in and connection is established!*/
34int IMAPwrapper::selectMbox(const QString&mbox) 34int IMAPwrapper::selectMbox(const QString&mbox)
35{ 35{
36 if (mbox == m_Lastmbox) { 36 if (mbox == m_Lastmbox) {
37 return MAILIMAP_NO_ERROR; 37 return MAILIMAP_NO_ERROR;
38 } 38 }
39 int err = mailimap_select( m_imap, (char*)mbox.latin1()); 39 int err = mailimap_select( m_imap, (char*)mbox.latin1());
40 if ( err != MAILIMAP_NO_ERROR ) { 40 if ( err != MAILIMAP_NO_ERROR ) {
41 m_Lastmbox = ""; 41 m_Lastmbox = "";
42 return err; 42 return err;
43 } 43 }
44 m_Lastmbox = mbox; 44 m_Lastmbox = mbox;
45 return err; 45 return err;
46} 46}
47 47
48void IMAPwrapper::imap_progress( size_t current, size_t maximum ) 48void IMAPwrapper::imap_progress( size_t current, size_t maximum )
49{ 49{
50 qApp->processEvents(); 50 qApp->processEvents();
51 return; 51 return;
52 //qDebug("imap progress %d of %d ",current,maximum ); 52 //qDebug("imap progress %d of %d ",current,maximum );
53 //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum)); 53 //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum));
54 //qApp->processEvents() 54 //qApp->processEvents()
55 static unsigned int last = 0; 55 static unsigned int last = 0;
56 if ( last != current ) 56 if ( last != current )
57 IMAPwrapper::progress(); 57 IMAPwrapper::progress();
58 last = current; 58 last = current;
59} 59}
60void IMAPwrapper::progress( QString m ) 60void IMAPwrapper::progress( QString m )
61{ 61{
62
63 static QString mProgrMess; 62 static QString mProgrMess;
64 if ( m != QString::null ) { 63 if ( m != QString::null ) {
65 mProgrMess = m; 64 mProgrMess = m;
66 mCurrent = 1; 65 mCurrent = 1;
67 return; 66 return;
68 } 67 }
69 QString mess; 68 QString mess;
70 //qDebug("progress "); 69 //qDebug("progress ");
71 if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax); 70 if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax);
72 else mess = mProgrMess +i18n(" message %1").arg( mCurrent++); 71 else mess = mProgrMess +i18n(" message %1").arg( mCurrent++);
73 Global::statusMessage(mess); 72 Global::statusMessage(mess);
74 //qDebug("Progress %s %s", mess.latin1(), m.latin1()); 73 //qDebug("Progress %s %s", mess.latin1(), m.latin1());
75 qApp->processEvents(); 74 qApp->processEvents();
76} 75}
77bool IMAPwrapper::start_tls(bool force_tls) 76bool IMAPwrapper::start_tls(bool force_tls)
78{ 77{
79 int err; 78 int err;
80 bool try_tls = force_tls; 79 bool try_tls = force_tls;
81 mailimap_capability_data * cap_data = 0; 80 mailimap_capability_data * cap_data = 0;
82 81
83 err = mailimap_capability(m_imap,&cap_data); 82 err = mailimap_capability(m_imap,&cap_data);
84 if (err != MAILIMAP_NO_ERROR) { 83 if (err != MAILIMAP_NO_ERROR) {
85 Global::statusMessage("error getting capabilities!"); 84 Global::statusMessage("error getting capabilities!");
86 return false; 85 return false;
87 } 86 }
88 clistiter * cur; 87 clistiter * cur;
89 for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { 88 for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) {
90 struct mailimap_capability * cap; 89 struct mailimap_capability * cap;
91 cap = (struct mailimap_capability *)clist_content(cur); 90 cap = (struct mailimap_capability *)clist_content(cur);
92 if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { 91 if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) {
93 if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { 92 if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) {
94 try_tls = true; 93 try_tls = true;
95 break; 94 break;
96 } 95 }
97 } 96 }
98 } 97 }
99 if (cap_data) { 98 if (cap_data) {
100 mailimap_capability_data_free(cap_data); 99 mailimap_capability_data_free(cap_data);
101 } 100 }
102 if (try_tls) { 101 if (try_tls) {
103 err = mailimap_starttls(m_imap); 102 err = mailimap_starttls(m_imap);
104 if (err != MAILIMAP_NO_ERROR && force_tls) { 103 if (err != MAILIMAP_NO_ERROR && force_tls) {
105 Global::statusMessage(i18n("Server has no TLS support!")); 104 Global::statusMessage(i18n("Server has no TLS support!"));
106 try_tls = false; 105 try_tls = false;
107 } else { 106 } else {
108 mailstream_low * low; 107 mailstream_low * low;
109 mailstream_low * new_low; 108 mailstream_low * new_low;
110 low = mailstream_get_low(m_imap->imap_stream); 109 low = mailstream_get_low(m_imap->imap_stream);
111 if (!low) { 110 if (!low) {
112 try_tls = false; 111 try_tls = false;
113 } else { 112 } else {
114 int fd = mailstream_low_get_fd(low); 113 int fd = mailstream_low_get_fd(low);
115 if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { 114 if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) {
116 mailstream_low_free(low); 115 mailstream_low_free(low);
117 mailstream_set_low(m_imap->imap_stream, new_low); 116 mailstream_set_low(m_imap->imap_stream, new_low);
118 } else { 117 } else {
119 try_tls = false; 118 try_tls = false;
120 } 119 }
121 } 120 }
122 } 121 }
123 } 122 }
124 return try_tls; 123 return try_tls;
125} 124}
126 125
127void IMAPwrapper::login() 126void IMAPwrapper::login()
128{ 127{
129 QString server, user, pass; 128 QString server, user, pass;
130 uint16_t port; 129 uint16_t port;
131 int err = MAILIMAP_NO_ERROR; 130 int err = MAILIMAP_NO_ERROR;
132 131
133 if (account->getOffline()) return; 132 if (account->getOffline()) return;
134 /* we are connected this moment */ 133 /* we are connected this moment */
135 /* TODO: setup a timer holding the line or if connection closed - delete the value */ 134 /* TODO: setup a timer holding the line or if connection closed - delete the value */
136 if (m_imap) { 135 if (m_imap) {
137 err = mailimap_noop(m_imap); 136 err = mailimap_noop(m_imap);
138 if (err!=MAILIMAP_NO_ERROR) { 137 if (err!=MAILIMAP_NO_ERROR) {
139 logout(); 138 logout();
140 } else { 139 } else {
141 mailstream_flush(m_imap->imap_stream); 140 mailstream_flush(m_imap->imap_stream);
142 return; 141 return;
143 } 142 }
144 } 143 }
145 server = account->getServer(); 144 server = account->getServer();
146 port = account->getPort().toUInt(); 145 port = account->getPort().toUInt();
147 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { 146 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
148 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); 147 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
149 login.show(); 148 login.show();
150 if ( QDialog::Accepted == login.exec() ) { 149 if ( QDialog::Accepted == login.exec() ) {
151 // ok 150 // ok
152 user = login.getUser(); 151 user = login.getUser();
153 pass = login.getPassword(); 152 pass = login.getPassword();
154 } else { 153 } else {
155 // cancel 154 // cancel
156 return; 155 return;
157 } 156 }
158 } else { 157 } else {
159 user = account->getUser(); 158 user = account->getUser();
160 pass = account->getPassword(); 159 pass = account->getPassword();
161 } 160 }
162 161
163 m_imap = mailimap_new( 20, &imap_progress ); 162 m_imap = mailimap_new( 20, &imap_progress );
164 163
165 /* connect */ 164 /* connect */
166 bool ssl = false; 165 bool ssl = false;
167 bool try_tls = false; 166 bool try_tls = false;
168 bool force_tls = false; 167 bool force_tls = false;
169 168
170 if ( account->ConnectionType() == 2 ) { 169 if ( account->ConnectionType() == 2 ) {
171 ssl = true; 170 ssl = true;
172 } 171 }
173 if (account->ConnectionType()==1) { 172 if (account->ConnectionType()==1) {
174 force_tls = true; 173 force_tls = true;
175 } 174 }
176 175
177 if ( ssl ) { 176 if ( ssl ) {
178 qDebug("using ssl "); 177 qDebug("using ssl ");
179 err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); 178 err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port );
180 qDebug("back "); 179 qDebug("back ");
181 } else { 180 } else {
182 err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); 181 err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port );
183 } 182 }
184 183
185 if ( err != MAILIMAP_NO_ERROR && 184 if ( err != MAILIMAP_NO_ERROR &&
186 err != MAILIMAP_NO_ERROR_AUTHENTICATED && 185 err != MAILIMAP_NO_ERROR_AUTHENTICATED &&
187 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { 186 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) {
188 QString failure = ""; 187 QString failure = "";
189 if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { 188 if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) {
190 failure="Connection refused"; 189 failure="Connection refused";
191 } else { 190 } else {
192 failure="Unknown failure"; 191 failure="Unknown failure";
193 } 192 }
194 Global::statusMessage(i18n("error connecting imap server: %1").arg(failure)); 193 Global::statusMessage(i18n("error connecting imap server: %1").arg(failure));
195 mailimap_free( m_imap ); 194 mailimap_free( m_imap );
196 m_imap = 0; 195 m_imap = 0;
197 return; 196 return;
198 } 197 }
199 198
200 if (!ssl) { 199 if (!ssl) {
201 try_tls = start_tls(force_tls); 200 try_tls = start_tls(force_tls);
202 } 201 }
203 202
204 bool ok = true; 203 bool ok = true;
205 if (force_tls && !try_tls) { 204 if (force_tls && !try_tls) {
206 Global::statusMessage(i18n("Server has no TLS support!")); 205 Global::statusMessage(i18n("Server has no TLS support!"));
207 ok = false; 206 ok = false;
208 } 207 }
209 208
210 209
211 /* login */ 210 /* login */
212 211
213 if (ok) { 212 if (ok) {
214 err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); 213 err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() );
215 if ( err != MAILIMAP_NO_ERROR ) { 214 if ( err != MAILIMAP_NO_ERROR ) {
216 Global::statusMessage(i18n("error logging in imap server: %1").arg(m_imap->imap_response)); 215 Global::statusMessage(i18n("error logging in imap server: %1").arg(m_imap->imap_response));
217 ok = false; 216 ok = false;
218 } 217 }
219 } 218 }
220 if (!ok) { 219 if (!ok) {
221 err = mailimap_close( m_imap ); 220 err = mailimap_close( m_imap );
222 mailimap_free( m_imap ); 221 mailimap_free( m_imap );
223 m_imap = 0; 222 m_imap = 0;
224 } 223 }
225} 224}
226 225
227void IMAPwrapper::logout() 226void IMAPwrapper::logout()
228{ 227{
229 int err = MAILIMAP_NO_ERROR; 228 int err = MAILIMAP_NO_ERROR;
230 if (!m_imap) return; 229 if (!m_imap) return;
231 err = mailimap_logout( m_imap ); 230 err = mailimap_logout( m_imap );
232 err = mailimap_close( m_imap ); 231 err = mailimap_close( m_imap );
233 mailimap_free( m_imap ); 232 mailimap_free( m_imap );
234 m_imap = 0; 233 m_imap = 0;
235 m_Lastmbox = ""; 234 m_Lastmbox = "";
236} 235}
237 236
238void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) 237void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb)
239{ 238{
240 239
241 int tryAgain = 1; 240 int tryAgain = 1;
242 while ( tryAgain >= 0 ) { 241 while ( tryAgain >= 0 ) {
243 int err = MAILIMAP_NO_ERROR; 242 int err = MAILIMAP_NO_ERROR;
244 clist *result = 0; 243 clist *result = 0;
245 clistcell *current; 244 clistcell *current;
246 mailimap_fetch_type *fetchType = 0; 245 mailimap_fetch_type *fetchType = 0;
247 mailimap_set *set = 0; 246 mailimap_set *set = 0;
248 247
249 login(); 248 login();
250 if (!m_imap) { 249 if (!m_imap) {
251 return; 250 return;
252 } 251 }
253 /* select mailbox READONLY for operations */ 252 /* select mailbox READONLY for operations */
254 err = selectMbox(mailbox); 253 err = selectMbox(mailbox);
diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp
index 0e4a64f..1dc374b 100644
--- a/kmicromail/mainwindow.cpp
+++ b/kmicromail/mainwindow.cpp
@@ -1,286 +1,286 @@
1 1
2// CHANGED 2004-08-06 Lutz Rogowski 2// CHANGED 2004-08-06 Lutz Rogowski
3#include <qlabel.h> 3#include <qlabel.h>
4#include <qvbox.h> 4#include <qvbox.h>
5#include <qheader.h> 5#include <qheader.h>
6#include <qtimer.h> 6#include <qtimer.h>
7#include <qlayout.h> 7#include <qlayout.h>
8//#include <kdialog.h> 8//#include <kdialog.h>
9#include <kiconloader.h> 9#include <kiconloader.h>
10#include <kapplication.h> 10#include <kapplication.h>
11 11
12#ifdef DESKTOP_VERSION 12#ifdef DESKTOP_VERSION
13#include <qapplication.h> 13#include <qapplication.h>
14#include <qstatusbar.h> 14#include <qstatusbar.h>
15#include <kabc/stdaddressbook.h> 15#include <kabc/stdaddressbook.h>
16extern QStatusBar* globalSstatusBarMainWindow; 16extern QStatusBar* globalSstatusBarMainWindow;
17#else 17#else
18#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
19#include <klocale.h> 19#include <klocale.h>
20#endif 20#endif
21#include "defines.h" 21#include "defines.h"
22#include "mainwindow.h" 22#include "mainwindow.h"
23#include <KDGanttMinimizeSplitter.h> 23#include <KDGanttMinimizeSplitter.h>
24 24
25#include "koprefs.h" 25#include "koprefs.h"
26 26
27MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 27MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
28 : QMainWindow( parent, name ) //, flags ) 28 : QMainWindow( parent, name ) //, flags )
29{ 29{
30#ifdef DESKTOP_VERSION 30#ifdef DESKTOP_VERSION
31 globalSstatusBarMainWindow = statusBar(); 31 globalSstatusBarMainWindow = statusBar();
32#endif 32#endif
33 setCaption( i18n( "KOpieMail/Pi" ) ); 33 setCaption( i18n( "KOpieMail/Pi" ) );
34 setToolBarsMovable( false ); 34 setToolBarsMovable( false );
35 //KABC::StdAddressBook::self(); 35 //KABC::StdAddressBook::self();
36 toolBar = new QToolBar( this ); 36 toolBar = new QToolBar( this );
37 menuBar = new QPEMenuBar( toolBar ); 37 menuBar = new QPEMenuBar( toolBar );
38 mailMenu = new QPopupMenu( menuBar ); 38 mailMenu = new QPopupMenu( menuBar );
39 menuBar->insertItem( i18n( "Mail" ), mailMenu ); 39 menuBar->insertItem( i18n( "Mail" ), mailMenu );
40 settingsMenu = new QPopupMenu( menuBar ); 40 settingsMenu = new QPopupMenu( menuBar );
41 menuBar->insertItem( i18n( "Settings" ), settingsMenu ); 41 menuBar->insertItem( i18n( "Settings" ), settingsMenu );
42 42
43 addToolBar( toolBar ); 43 addToolBar( toolBar );
44 toolBar->setHorizontalStretchable( true ); 44 toolBar->setHorizontalStretchable( true );
45 QAction* getMail = new QAction( i18n( "Get all new mails" ), SmallIcon("enter"), 45 QAction* getMail = new QAction( i18n( "Get all new mails" ), SmallIcon("enter"),
46 0, 0, this ); 46 0, 0, this );
47 connect(getMail, SIGNAL( activated() ), 47 connect(getMail, SIGNAL( activated() ),
48 SLOT( slotGetAllMail() ) ); 48 SLOT( slotGetAllMail() ) );
49 getMail->addTo( mailMenu ); 49 getMail->addTo( mailMenu );
50 50
51 getMail = new QAction( i18n( "Get new messages" ), SmallIcon("add"), 51 getMail = new QAction( i18n( "Get new messages" ), SmallIcon("add"),
52 0, 0, this ); 52 0, 0, this );
53 getMail->addTo( toolBar ); 53 getMail->addTo( toolBar );
54 getMail->addTo( mailMenu ); 54 getMail->addTo( mailMenu );
55 connect(getMail, SIGNAL( activated() ), 55 connect(getMail, SIGNAL( activated() ),
56 SLOT( slotGetMail() ) ); 56 SLOT( slotGetMail() ) );
57 57
58 composeMail = new QAction( i18n( "Compose new mail" ), SmallIcon("composemail"), 58 composeMail = new QAction( i18n( "Compose new mail" ), SmallIcon("composemail"),
59 0, 0, this ); 59 0, 0, this );
60 composeMail->addTo( toolBar ); 60 composeMail->addTo( toolBar );
61 composeMail->addTo( mailMenu ); 61 composeMail->addTo( mailMenu );
62 62
63 sendQueued = new QAction( i18n( "Send queued mails" ), SmallIcon("sendqueued") , 63 sendQueued = new QAction( i18n( "Send queued mails" ), SmallIcon("sendqueued") ,
64 0, 0, this ); 64 0, 0, this );
65 sendQueued->addTo( toolBar ); 65 sendQueued->addTo( toolBar );
66 sendQueued->addTo( mailMenu ); 66 sendQueued->addTo( mailMenu );
67 67
68 /* 68 /*
69 syncFolders = new QAction( i18n( "Sync mailfolders" ), ICON_SYNC, 69 syncFolders = new QAction( i18n( "Sync mailfolders" ), ICON_SYNC,
70 0, 0, this ); 70 0, 0, this );
71 syncFolders->addTo( toolBar ); 71 syncFolders->addTo( toolBar );
72 syncFolders->addTo( mailMenu ); 72 syncFolders->addTo( mailMenu );
73 */ 73 */
74 74
75 showFolders = new QAction( i18n( "Show/Hide folders" ), SmallIcon("showfolders") , 75 showFolders = new QAction( i18n( "Show/Hide folders" ), SmallIcon("showfolders") ,
76 0, 0, this, 0, true ); 76 0, 0, this, 0, true );
77 showFolders->addTo( toolBar ); 77 showFolders->addTo( toolBar );
78 showFolders->addTo( mailMenu ); 78 showFolders->addTo( mailMenu );
79 showFolders->setOn( true ); 79 showFolders->setOn( true );
80 connect(showFolders, SIGNAL( toggled(bool) ), 80 connect(showFolders, SIGNAL( toggled(bool) ),
81 SLOT( slotShowFolders(bool) ) ); 81 SLOT( slotShowFolders(bool) ) );
82 82
83 /* 83 /*
84 searchMails = new QAction( i18n( "Search mails" ), SmallIcon("find") ), 84 searchMails = new QAction( i18n( "Search mails" ), SmallIcon("find") ),
85 0, 0, this ); 85 0, 0, this );
86 searchMails->addTo( toolBar ); 86 searchMails->addTo( toolBar );
87 searchMails->addTo( mailMenu ); 87 searchMails->addTo( mailMenu );
88 */ 88 */
89 89
90 deleteMails = new QAction(i18n("Delete Mail"), SmallIcon("trash"), 0, 0, this); 90 deleteMails = new QAction(i18n("Delete Mail"), SmallIcon("trash"), 0, 0, this);
91 deleteMails->addTo( toolBar ); 91 deleteMails->addTo( toolBar );
92 deleteMails->addTo( mailMenu ); 92 deleteMails->addTo( mailMenu );
93 connect( deleteMails, SIGNAL( activated() ), 93 connect( deleteMails, SIGNAL( activated() ),
94 SLOT( slotDeleteMail() ) ); 94 SLOT( slotDeleteAllMail() ) );
95 95
96 editSettings = new QAction( i18n( "Edit settings" ), SmallIcon("SettingsIcon") , 96 editSettings = new QAction( i18n( "Edit settings" ), SmallIcon("SettingsIcon") ,
97 0, 0, this ); 97 0, 0, this );
98 editSettings->addTo( settingsMenu ); 98 editSettings->addTo( settingsMenu );
99 connect( editSettings, SIGNAL( activated() ), 99 connect( editSettings, SIGNAL( activated() ),
100 SLOT( slotEditSettings() ) ); 100 SLOT( slotEditSettings() ) );
101 editAccounts = new QAction( i18n( "Configure accounts" ), SmallIcon("editaccounts") , 101 editAccounts = new QAction( i18n( "Configure accounts" ), SmallIcon("editaccounts") ,
102 0, 0, this ); 102 0, 0, this );
103 editAccounts->addTo( settingsMenu ); 103 editAccounts->addTo( settingsMenu );
104 codecMenu = new QPopupMenu( menuBar ); 104 codecMenu = new QPopupMenu( menuBar );
105 codecMenu->insertItem( "Western (iso-8859-1)",0,0); 105 codecMenu->insertItem( "Western (iso-8859-1)",0,0);
106 codecMenu->insertItem( "Cyrillic (iso-8859-5)",1,1); 106 codecMenu->insertItem( "Cyrillic (iso-8859-5)",1,1);
107 codecMenu->insertItem( "Western (iso-8859-15)",2,2); 107 codecMenu->insertItem( "Western (iso-8859-15)",2,2);
108 codecMenu->insertItem( "Chinese (big-5)",3,3); 108 codecMenu->insertItem( "Chinese (big-5)",3,3);
109 codecMenu->insertItem( "Unicode (utf-8)",4,4); 109 codecMenu->insertItem( "Unicode (utf-8)",4,4);
110 codecMenu->insertItem( "Userdefined ("+KOPrefs::instance()->mSendCodec+")",5,5); 110 codecMenu->insertItem( "Userdefined ("+KOPrefs::instance()->mSendCodec+")",5,5);
111 //disabled 111 //disabled
112 //settingsMenu->insertItem( i18n("Codec for new mails"), codecMenu); 112 //settingsMenu->insertItem( i18n("Codec for new mails"), codecMenu);
113 //setCentralWidget( view ); 113 //setCentralWidget( view );
114 114
115 QVBox* wrapperBox = new QVBox( this ); 115 QVBox* wrapperBox = new QVBox( this );
116 setCentralWidget( wrapperBox ); 116 setCentralWidget( wrapperBox );
117 117
118 // QWidget *view = new QWidget( wrapperBox ); 118 // QWidget *view = new QWidget( wrapperBox );
119 KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox); 119 KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox);
120 split->setMinimizeDirection( KDGanttMinimizeSplitter::Left); 120 split->setMinimizeDirection( KDGanttMinimizeSplitter::Left);
121 //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight ); 121 //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight );
122 122
123 folderView = new AccountView( split ); 123 folderView = new AccountView( split );
124 folderView->header()->hide(); 124 folderView->header()->hide();
125 folderView->setRootIsDecorated( false ); 125 folderView->setRootIsDecorated( false );
126 folderView->addColumn( i18n( "Mailbox" ) ); 126 folderView->addColumn( i18n( "Mailbox" ) );
127 127
128 //layout->addWidget( folderView ); 128 //layout->addWidget( folderView );
129 129
130 mailView = new QListView( split ); 130 mailView = new QListView( split );
131 mailView->addColumn( i18n( " " ) ); 131 mailView->addColumn( i18n( " " ) );
132 mailView->addColumn( i18n( "Subject" ),QListView::Manual ); 132 mailView->addColumn( i18n( "Subject" ),QListView::Manual );
133 mailView->addColumn( i18n( "Sender" ),QListView::Manual ); 133 mailView->addColumn( i18n( "Sender" ),QListView::Manual );
134 mailView->addColumn( i18n( "Size" ),QListView::Manual); 134 mailView->addColumn( i18n( "Size" ),QListView::Manual);
135 mailView->addColumn( i18n( "Date" ),QListView::Manual); 135 mailView->addColumn( i18n( "Date" ),QListView::Manual);
136 mailView->setAllColumnsShowFocus(true); 136 mailView->setAllColumnsShowFocus(true);
137 //mailView->setSorting(-1); 137 //mailView->setSorting(-1);
138 mailView->setRootIsDecorated( false ); 138 mailView->setRootIsDecorated( false );
139 statusWidget = new StatusWidget( wrapperBox ); 139 statusWidget = new StatusWidget( wrapperBox );
140 statusWidget->hide(); 140 statusWidget->hide();
141 141
142 //layout->addWidget( mailView ); 142 //layout->addWidget( mailView );
143 //layout->setStretchFactor( folderView, 1 ); 143 //layout->setStretchFactor( folderView, 1 );
144 //layout->setStretchFactor( mailView, 2 ); 144 //layout->setStretchFactor( mailView, 2 );
145 145
146 slotAdjustLayout(); 146 slotAdjustLayout();
147#ifndef DESKTOP_VERSION 147#ifndef DESKTOP_VERSION
148 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); 148 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold);
149 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); 149 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold);
150#endif 150#endif
151 connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this, 151 connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this,
152 SLOT( mailLeftClicked(QListViewItem*) ) ); 152 SLOT( mailLeftClicked(QListViewItem*) ) );
153 connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this, 153 connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this,
154 SLOT( mailLeftClicked(QListViewItem*) ) ); 154 SLOT( mailLeftClicked(QListViewItem*) ) );
155 connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, 155 connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
156 SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); 156 SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) );
157 connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), 157 connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)),
158 this,SLOT(refreshMailView(const QValueList<RecMailP>&))); 158 this,SLOT(refreshMailView(const QValueList<RecMailP>&)));
159 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); 159 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) );
160 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); 160 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) );
161// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); 161// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) );
162 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); 162 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) );
163 //mailView->setMultiSelection ( true ); 163 //mailView->setMultiSelection ( true );
164 mailView->setSelectionMode( QListView::Extended ); 164 mailView->setSelectionMode( QListView::Extended );
165 QValueList<int> list; 165 QValueList<int> list;
166 int fw = 100; 166 int fw = 100;
167 if ( QApplication::desktop()->width() > 320 ) 167 if ( QApplication::desktop()->width() > 320 )
168 fw = 50; 168 fw = 50;
169 list.append( fw ); 169 list.append( fw );
170 list.append( 100 ); 170 list.append( 100 );
171 split->setSizes( list ); 171 split->setSizes( list );
172 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 172 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
173 mailView->setShowSortIndicator ( true ); 173 mailView->setShowSortIndicator ( true );
174 QLabel *spacer = new QLabel( toolBar ); 174 QLabel *spacer = new QLabel( toolBar );
175 spacer->setBackgroundMode( QWidget::PaletteButton ); 175 spacer->setBackgroundMode( QWidget::PaletteButton );
176 toolBar->setStretchableWidget( spacer ); 176 toolBar->setStretchableWidget( spacer );
177 177
178 QAction* closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this); 178 QAction* closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this);
179 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); 179 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) );
180 if ( QApplication::desktop()->width() > 320 ) 180 if ( QApplication::desktop()->width() > 320 )
181 closeMail->addTo(toolBar); 181 closeMail->addTo(toolBar);
182 closeMail->addTo(mailMenu); 182 closeMail->addTo(mailMenu);
183 183
184 184
185 QPopupMenu* helpMenu = new QPopupMenu( menuBar ); 185 QPopupMenu* helpMenu = new QPopupMenu( menuBar );
186 menuBar->insertItem( i18n( "Help" ), helpMenu ); 186 menuBar->insertItem( i18n( "Help" ), helpMenu );
187 QAction* li = new QAction(i18n("About"), QPixmap(), 0, 0, this); 187 QAction* li = new QAction(i18n("About"), QPixmap(), 0, 0, this);
188 connect( li, SIGNAL( activated() ), SLOT( showAbout()) ); 188 connect( li, SIGNAL( activated() ), SLOT( showAbout()) );
189 li->addTo(helpMenu); 189 li->addTo(helpMenu);
190 li = new QAction(i18n("Licence"),QPixmap(), 0, 0, this); 190 li = new QAction(i18n("Licence"),QPixmap(), 0, 0, this);
191 connect( li, SIGNAL( activated() ), SLOT( showLicence()) ); 191 connect( li, SIGNAL( activated() ), SLOT( showLicence()) );
192 li->addTo(helpMenu); 192 li->addTo(helpMenu);
193 li = new QAction(i18n("LibEtPan Licence"), QPixmap(), 0, 0, this); 193 li = new QAction(i18n("LibEtPan Licence"), QPixmap(), 0, 0, this);
194 connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) ); 194 connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) );
195 li->addTo(helpMenu); 195 li->addTo(helpMenu);
196 connect( codecMenu, SIGNAL( activated(int) ), this, SLOT( slotSetCodec( int )) ); 196 connect( codecMenu, SIGNAL( activated(int) ), this, SLOT( slotSetCodec( int )) );
197 slotSetCodec( KOPrefs::instance()->mCurrentCodec ); 197 slotSetCodec( KOPrefs::instance()->mCurrentCodec );
198#ifdef DESKTOP_VERSION 198#ifdef DESKTOP_VERSION
199 resize ( 640, 480 ); 199 resize ( 640, 480 );
200#endif 200#endif
201} 201}
202 202
203MainWindow::~MainWindow() 203MainWindow::~MainWindow()
204{ 204{
205} 205}
206 206
207void MainWindow::slotSetCodec( int codec ) 207void MainWindow::slotSetCodec( int codec )
208{ 208{
209 codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, false ); 209 codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, false );
210 //qDebug("codec %d ", codec); 210 //qDebug("codec %d ", codec);
211 KOPrefs::instance()->mCurrentCodec = codec; 211 KOPrefs::instance()->mCurrentCodec = codec;
212 KOPrefs::instance()->isDirty = true; 212 KOPrefs::instance()->isDirty = true;
213 QString name; 213 QString name;
214 switch ( codec ) { 214 switch ( codec ) {
215 case 0: 215 case 0:
216 name = "iso-8859-1"; 216 name = "iso-8859-1";
217 break; 217 break;
218 case 1: 218 case 1:
219 name = "iso-8859-5"; 219 name = "iso-8859-5";
220 break; 220 break;
221 case 2: 221 case 2:
222 name = "iso-8859-15"; 222 name = "iso-8859-15";
223 break; 223 break;
224 case 3: 224 case 3:
225 name = "big-5"; 225 name = "big-5";
226 break; 226 break;
227 case 4: 227 case 4:
228 name = "utf-8"; 228 name = "utf-8";
229 break; 229 break;
230 case 5: 230 case 5:
231 name = KOPrefs::instance()->mSendCodec.lower(); 231 name = KOPrefs::instance()->mSendCodec.lower();
232 break; 232 break;
233 } 233 }
234 KOPrefs::instance()->mCurrentCodeName = name ; 234 KOPrefs::instance()->mCurrentCodeName = name ;
235 codecMenu->changeItem ( 5, "Userdefined ("+KOPrefs::instance()->mSendCodec+")"); 235 codecMenu->changeItem ( 5, "Userdefined ("+KOPrefs::instance()->mSendCodec+")");
236 codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, true ); 236 codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, true );
237} 237}
238void MainWindow::showLicence() 238void MainWindow::showLicence()
239{ 239{
240 KApplication::showLicence(); 240 KApplication::showLicence();
241} 241}
242void MainWindow::showAbout() 242void MainWindow::showAbout()
243{ 243{
244 QString version; 244 QString version;
245#include <../version> 245#include <../version>
246 246
247 QString cap = "About KOpieMail/Pi"; 247 QString cap = "About KOpieMail/Pi";
248 QString text =i18n("KOpieMail/Platform-independent\n") + 248 QString text =i18n("KOpieMail/Platform-independent\n") +
249 "(OM/Pi) " + version + " - " 249 "(OM/Pi) " + version + " - "
250 250
251#ifdef DESKTOP_VERSION 251#ifdef DESKTOP_VERSION
252 "Desktop Edition\n" 252 "Desktop Edition\n"
253#else 253#else
254 "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n" 254 "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n"
255#endif 255#endif
256 "www.pi-sync.net\n\n" 256 "www.pi-sync.net\n\n"
257 257
258 258
259 259
260"Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n" 260"Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n"
261 "KOpieMail/Pi is based on Opie Mail\n" 261 "KOpieMail/Pi is based on Opie Mail\n"
262 "Copyright (c) Rajko Albrecht and the Opie team\n" 262 "Copyright (c) Rajko Albrecht and the Opie team\n"
263 "KOpieMail/Pi is licensed under the GPL\n" 263 "KOpieMail/Pi is licensed under the GPL\n"
264 "\n" 264 "\n"
265 "KOpieMail/Pi uses LibEtPan - a mail stuff library\n" 265 "KOpieMail/Pi uses LibEtPan - a mail stuff library\n"
266 "Copyright (C) 2001, 2002 - DINH Viet Hoa\n" 266 "Copyright (C) 2001, 2002 - DINH Viet Hoa\n"
267 "libEtPan has its own licence - see LibEtPan licence\n"; 267 "libEtPan has its own licence - see LibEtPan licence\n";
268 268
269 KApplication::showText( cap, text ); 269 KApplication::showText( cap, text );
270} 270}
271void MainWindow::showEtpanLicence() 271void MainWindow::showEtpanLicence()
272{ 272{
273 KApplication::showFile( "LibEtPan licence", "kdepim/kopiemail/COPYRIGHTlibetpan" ); 273 KApplication::showFile( "LibEtPan licence", "kdepim/kopiemail/COPYRIGHTlibetpan" );
274 274
275} 275}
276void MainWindow::appMessage(const QCString &, const QByteArray &) 276void MainWindow::appMessage(const QCString &, const QByteArray &)
277{ 277{
278 qDebug("appMessage implemented by subclass"); 278 qDebug("appMessage implemented by subclass");
279} 279}
280 280
281void MainWindow::slotAdjustLayout() { 281void MainWindow::slotAdjustLayout() {
282 282
283 /* 283 /*
284 QWidget *d = QApplication::desktop(); 284 QWidget *d = QApplication::desktop();
285 285
286 if ( d->width() < d->height() ) { 286 if ( d->width() < d->height() ) {
diff --git a/kmicromail/mainwindow.h b/kmicromail/mainwindow.h
index d0a5caf..016e44c 100644
--- a/kmicromail/mainwindow.h
+++ b/kmicromail/mainwindow.h
@@ -1,69 +1,70 @@
1 1
2// CHANGED 2004-08-06 Lutz Rogowski 2// CHANGED 2004-08-06 Lutz Rogowski
3#ifndef MAINWINDOW_H 3#ifndef MAINWINDOW_H
4#define MAINWINDOW_H 4#define MAINWINDOW_H
5 5
6#include <qmainwindow.h> 6#include <qmainwindow.h>
7#include <qlistview.h> 7#include <qlistview.h>
8#include <qaction.h> 8#include <qaction.h>
9 9
10#include <qtoolbar.h> 10#include <qtoolbar.h>
11#ifdef DESKTOP_VERSION 11#ifdef DESKTOP_VERSION
12#include <qmenubar.h> 12#include <qmenubar.h>
13#define QPEMenuBar QMenuBar 13#define QPEMenuBar QMenuBar
14#else 14#else
15#include <qpe/qpemenubar.h> 15#include <qpe/qpemenubar.h>
16#endif 16#endif
17 17
18#include "accountview.h" 18#include "accountview.h"
19#include "statuswidget.h" 19#include "statuswidget.h"
20 20
21#include <libmailwrapper/mailtypes.h> 21#include <libmailwrapper/mailtypes.h>
22#include <opie2/osmartpointer.h> 22#include <opie2/osmartpointer.h>
23 23
24class RecMail; 24class RecMail;
25 25
26class MainWindow : public QMainWindow 26class MainWindow : public QMainWindow
27{ 27{
28 Q_OBJECT 28 Q_OBJECT
29 29
30public: 30public:
31 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 31 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
32 virtual ~MainWindow(); 32 virtual ~MainWindow();
33 33
34public slots: 34public slots:
35 virtual void slotAdjustColumns(); 35 virtual void slotAdjustColumns();
36 virtual void appMessage(const QCString &msg, const QByteArray &data); 36 virtual void appMessage(const QCString &msg, const QByteArray &data);
37 virtual void slotComposeMail(); 37 virtual void slotComposeMail();
38 38
39protected slots: 39protected slots:
40 virtual void slotSendQueued(); 40 virtual void slotSendQueued();
41 virtual void slotEditAccounts(); 41 virtual void slotEditAccounts();
42 virtual void slotShowFolders( bool show ); 42 virtual void slotShowFolders( bool show );
43 virtual void refreshMailView(const QValueList<RecMailP>&); 43 virtual void refreshMailView(const QValueList<RecMailP>&);
44 virtual void displayMail(); 44 virtual void displayMail();
45 virtual void slotGetMail() = 0; 45 virtual void slotGetMail() = 0;
46 virtual void slotGetAllMail() = 0; 46 virtual void slotGetAllMail() = 0;
47 virtual void slotDeleteMail(); 47 virtual void slotDeleteMail();
48 virtual void slotDeleteAllMail() = 0;
48 virtual void slotSetCodec(int); 49 virtual void slotSetCodec(int);
49 virtual void mailHold(int, QListViewItem *,const QPoint&,int); 50 virtual void mailHold(int, QListViewItem *,const QPoint&,int);
50 virtual void slotAdjustLayout(); 51 virtual void slotAdjustLayout();
51 virtual void slotEditSettings(); 52 virtual void slotEditSettings();
52 virtual void mailLeftClicked( QListViewItem * ); 53 virtual void mailLeftClicked( QListViewItem * );
53 void showLicence(); 54 void showLicence();
54 void showAbout(); 55 void showAbout();
55 void showEtpanLicence(); 56 void showEtpanLicence();
56 57
57protected: 58protected:
58 QToolBar *toolBar; 59 QToolBar *toolBar;
59 StatusWidget *statusWidget; 60 StatusWidget *statusWidget;
60 QPEMenuBar *menuBar; 61 QPEMenuBar *menuBar;
61 QPopupMenu *mailMenu, *settingsMenu, *codecMenu; 62 QPopupMenu *mailMenu, *settingsMenu, *codecMenu;
62 QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, 63 QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails,
63 *editSettings, *editAccounts, *syncFolders; 64 *editSettings, *editAccounts, *syncFolders;
64 AccountView *folderView; 65 AccountView *folderView;
65 QListView *mailView; 66 QListView *mailView;
66 //QBoxLayout *layout; 67 //QBoxLayout *layout;
67}; 68};
68 69
69#endif 70#endif