summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper
Unidiff
Diffstat (limited to 'kmicromail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/pop3wrapper.cpp2
-rw-r--r--kmicromail/libmailwrapper/settings.cpp10
-rw-r--r--kmicromail/libmailwrapper/settings.h9
3 files changed, 20 insertions, 1 deletions
diff --git a/kmicromail/libmailwrapper/pop3wrapper.cpp b/kmicromail/libmailwrapper/pop3wrapper.cpp
index 8d2f778..1edec9e 100644
--- a/kmicromail/libmailwrapper/pop3wrapper.cpp
+++ b/kmicromail/libmailwrapper/pop3wrapper.cpp
@@ -1,294 +1,294 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2#include <stdlib.h> 2#include <stdlib.h>
3#include "pop3wrapper.h" 3#include "pop3wrapper.h"
4#include "mailtypes.h" 4#include "mailtypes.h"
5#include "logindialog.h" 5#include "logindialog.h"
6#include <libetpan/libetpan.h> 6#include <libetpan/libetpan.h>
7 7
8 8
9#include <qpe/global.h> 9#include <qpe/global.h>
10#include <qfile.h> 10#include <qfile.h>
11#include <qprogressbar.h> 11#include <qprogressbar.h>
12#include <qapplication.h> 12#include <qapplication.h>
13 13
14/* we don't fetch messages larger than 5 MB */ 14/* we don't fetch messages larger than 5 MB */
15#define HARD_MSG_SIZE_LIMIT 5242880 15#define HARD_MSG_SIZE_LIMIT 5242880
16 16
17using namespace Opie::Core; 17using namespace Opie::Core;
18POP3wrapper::POP3wrapper( POP3account *a ) 18POP3wrapper::POP3wrapper( POP3account *a )
19: Genericwrapper() { 19: Genericwrapper() {
20 account = a; 20 account = a;
21 m_pop3 = NULL; 21 m_pop3 = NULL;
22 msgTempName = a->getFileName()+"_msg_cache"; 22 msgTempName = a->getFileName()+"_msg_cache";
23 last_msg_id = 0; 23 last_msg_id = 0;
24} 24}
25 25
26POP3wrapper::~POP3wrapper() { 26POP3wrapper::~POP3wrapper() {
27 logout(); 27 logout();
28 QFile msg_cache(msgTempName); 28 QFile msg_cache(msgTempName);
29 if (msg_cache.exists()) { 29 if (msg_cache.exists()) {
30 msg_cache.remove(); 30 msg_cache.remove();
31 } 31 }
32} 32}
33 33
34void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { 34void POP3wrapper::pop3_progress( size_t current, size_t maximum ) {
35 ; // odebug << "POP3: " << current << " of " << maximum << "" << oendl; 35 ; // odebug << "POP3: " << current << " of " << maximum << "" << oendl;
36} 36}
37 37
38RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { 38RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) {
39 int err = MAILPOP3_NO_ERROR; 39 int err = MAILPOP3_NO_ERROR;
40 char *message = 0; 40 char *message = 0;
41 size_t length = 0; 41 size_t length = 0;
42 42
43 RecBodyP body = new RecBody(); 43 RecBodyP body = new RecBody();
44 44
45 login(); 45 login();
46 if ( !m_pop3 ) { 46 if ( !m_pop3 ) {
47 return body; 47 return body;
48 } 48 }
49 49
50 mailmessage * mailmsg; 50 mailmessage * mailmsg;
51 if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { 51 if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) {
52 ; // odebug << "Message to large: " << mail->Msgsize() << "" << oendl; 52 ; // odebug << "Message to large: " << mail->Msgsize() << "" << oendl;
53 return body; 53 return body;
54 } 54 }
55 55
56 QFile msg_cache(msgTempName); 56 QFile msg_cache(msgTempName);
57 57
58 cleanMimeCache(); 58 cleanMimeCache();
59 59
60 if (mail->getNumber()!=last_msg_id) { 60 if (mail->getNumber()!=last_msg_id) {
61 if (msg_cache.exists()) { 61 if (msg_cache.exists()) {
62 msg_cache.remove(); 62 msg_cache.remove();
63 } 63 }
64 msg_cache.open(IO_ReadWrite|IO_Truncate); 64 msg_cache.open(IO_ReadWrite|IO_Truncate);
65 last_msg_id = mail->getNumber(); 65 last_msg_id = mail->getNumber();
66 err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); 66 err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg);
67 err = mailmessage_fetch(mailmsg,&message,&length); 67 err = mailmessage_fetch(mailmsg,&message,&length);
68 msg_cache.writeBlock(message,length); 68 msg_cache.writeBlock(message,length);
69 } else { 69 } else {
70 QString msg=""; 70 QString msg="";
71 msg_cache.open(IO_ReadOnly); 71 msg_cache.open(IO_ReadOnly);
72 message = new char[4096]; 72 message = new char[4096];
73 memset(message,0,4096); 73 memset(message,0,4096);
74 while (msg_cache.readBlock(message,4095)>0) { 74 while (msg_cache.readBlock(message,4095)>0) {
75 msg+=message; 75 msg+=message;
76 memset(message,0,4096); 76 memset(message,0,4096);
77 } 77 }
78 delete message; 78 delete message;
79 message = (char*)malloc(msg.length()+1*sizeof(char)); 79 message = (char*)malloc(msg.length()+1*sizeof(char));
80 memset(message,0,msg.length()+1); 80 memset(message,0,msg.length()+1);
81 memcpy(message,msg.latin1(),msg.length()); 81 memcpy(message,msg.latin1(),msg.length());
82 /* transform to libetpan stuff */ 82 /* transform to libetpan stuff */
83 mailmsg = mailmessage_new(); 83 mailmsg = mailmessage_new();
84 mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); 84 mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message));
85 generic_message_t * msg_data; 85 generic_message_t * msg_data;
86 msg_data = (generic_message_t *)mailmsg->msg_data; 86 msg_data = (generic_message_t *)mailmsg->msg_data;
87 msg_data->msg_fetched = 1; 87 msg_data->msg_fetched = 1;
88 msg_data->msg_message = message; 88 msg_data->msg_message = message;
89 msg_data->msg_length = strlen(message); 89 msg_data->msg_length = strlen(message);
90 } 90 }
91 body = parseMail(mailmsg); 91 body = parseMail(mailmsg);
92 92
93 /* clean up */ 93 /* clean up */
94 if (mailmsg) 94 if (mailmsg)
95 mailmessage_free(mailmsg); 95 mailmessage_free(mailmsg);
96 if (message) 96 if (message)
97 free(message); 97 free(message);
98 98
99 return body; 99 return body;
100} 100}
101 101
102void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) 102void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb )
103{ 103{
104 login(); 104 login();
105 if (!m_pop3) 105 if (!m_pop3)
106 return; 106 return;
107 uint32_t res_messages,res_recent,res_unseen; 107 uint32_t res_messages,res_recent,res_unseen;
108 mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); 108 mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen);
109 parseList(target,m_pop3->sto_session,"INBOX", false, maxSizeInKb); 109 parseList(target,m_pop3->sto_session,"INBOX", false, maxSizeInKb);
110 Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); 110 Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages));
111} 111}
112 112
113void POP3wrapper::login() 113void POP3wrapper::login()
114{ 114{
115 if (account->getOffline()) 115 if (account->getOffline())
116 return; 116 return;
117 /* we'll hold the line */ 117 /* we'll hold the line */
118 if ( m_pop3 != NULL ) 118 if ( m_pop3 != NULL )
119 return; 119 return;
120 120
121 QString server,user, pass; 121 QString server,user, pass;
122 uint16_t port; 122 uint16_t port;
123 int err = MAILPOP3_NO_ERROR; 123 int err = MAILPOP3_NO_ERROR;
124 124
125 server = account->getServer().latin1(); 125 server = account->getServer();
126 port = account->getPort().toUInt(); 126 port = account->getPort().toUInt();
127 127
128 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { 128 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
129 qApp->processEvents(); 129 qApp->processEvents();
130 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); 130 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
131 login.show(); 131 login.show();
132 if ( QDialog::Accepted == login.exec() ) { 132 if ( QDialog::Accepted == login.exec() ) {
133 // ok 133 // ok
134 user = login.getUser(); 134 user = login.getUser();
135 pass = login.getPassword(); 135 pass = login.getPassword();
136 } else { 136 } else {
137 // cancel 137 // cancel
138 ; // odebug << "POP3: Login canceled" << oendl; 138 ; // odebug << "POP3: Login canceled" << oendl;
139 return; 139 return;
140 } 140 }
141 } else { 141 } else {
142 user = account->getUser(); 142 user = account->getUser();
143 pass = account->getPassword(); 143 pass = account->getPassword();
144 } 144 }
145 // bool ssl = account->getSSL(); 145 // bool ssl = account->getSSL();
146 146
147 m_pop3=mailstorage_new(NULL); 147 m_pop3=mailstorage_new(NULL);
148 int conntypeset = account->ConnectionType(); 148 int conntypeset = account->ConnectionType();
149 int conntype = 0; 149 int conntype = 0;
150 if ( conntypeset == 3 ) { 150 if ( conntypeset == 3 ) {
151 conntype = CONNECTION_TYPE_COMMAND; 151 conntype = CONNECTION_TYPE_COMMAND;
152 } else if ( conntypeset == 2 ) { 152 } else if ( conntypeset == 2 ) {
153 conntype = CONNECTION_TYPE_TLS; 153 conntype = CONNECTION_TYPE_TLS;
154 } else if ( conntypeset == 1 ) { 154 } else if ( conntypeset == 1 ) {
155 conntype = CONNECTION_TYPE_STARTTLS; 155 conntype = CONNECTION_TYPE_STARTTLS;
156 } else if ( conntypeset == 0 ) { 156 } else if ( conntypeset == 0 ) {
157 conntype = CONNECTION_TYPE_TRY_STARTTLS; 157 conntype = CONNECTION_TYPE_TRY_STARTTLS;
158 } 158 }
159 159
160 //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); 160 //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN);
161 161
162 pop3_mailstorage_init(m_pop3,(char*)server.latin1(), port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, 162 pop3_mailstorage_init(m_pop3,(char*)server.latin1(), port, NULL, conntype, POP3_AUTH_TYPE_PLAIN,
163 (char*)user.latin1(),(char*)pass.latin1(),0,0,0); 163 (char*)user.latin1(),(char*)pass.latin1(),0,0,0);
164 164
165 err = mailstorage_connect(m_pop3); 165 err = mailstorage_connect(m_pop3);
166 if (err != MAIL_NO_ERROR) { 166 if (err != MAIL_NO_ERROR) {
167 ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; 167 ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl;
168 Global::statusMessage(tr("Error %1 initializing folder").arg( err )); 168 Global::statusMessage(tr("Error %1 initializing folder").arg( err ));
169 mailstorage_free(m_pop3); 169 mailstorage_free(m_pop3);
170 m_pop3 = 0; 170 m_pop3 = 0;
171 } else { 171 } else {
172 mailsession * session = m_pop3->sto_session; 172 mailsession * session = m_pop3->sto_session;
173 mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; 173 mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session;
174 if (mail) { 174 if (mail) {
175 mail->pop3_progr_fun = &pop3_progress; 175 mail->pop3_progr_fun = &pop3_progress;
176 } 176 }
177 } 177 }
178} 178}
179 179
180void POP3wrapper::logout() 180void POP3wrapper::logout()
181{ 181{
182 if ( m_pop3 == NULL ) 182 if ( m_pop3 == NULL )
183 return; 183 return;
184 mailstorage_free(m_pop3); 184 mailstorage_free(m_pop3);
185 m_pop3 = 0; 185 m_pop3 = 0;
186} 186}
187 187
188 188
189QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { 189QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() {
190 QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); 190 QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>();
191 FolderP inb=new Folder("INBOX","/"); 191 FolderP inb=new Folder("INBOX","/");
192 folders->append(inb); 192 folders->append(inb);
193 return folders; 193 return folders;
194} 194}
195 195
196void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target) 196void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target)
197{ 197{
198 login(); 198 login();
199 if (!m_pop3) 199 if (!m_pop3)
200 return; 200 return;
201 int iii = 0; 201 int iii = 0;
202 int count = target.count(); 202 int count = target.count();
203 QWidget wid; 203 QWidget wid;
204 wid.show(); 204 wid.show();
205 while (iii < count ) { 205 while (iii < count ) {
206 Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); 206 Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count));
207 wid.raise(); 207 wid.raise();
208 qApp->processEvents(); 208 qApp->processEvents();
209 //qDebug("delete "); 209 //qDebug("delete ");
210 RecMailP mail = (*target.at( iii )); 210 RecMailP mail = (*target.at( iii ));
211 int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); 211 int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber());
212 if (err != MAIL_NO_ERROR) { 212 if (err != MAIL_NO_ERROR) {
213 Global::statusMessage(tr("Error deleting mail")); 213 Global::statusMessage(tr("Error deleting mail"));
214 } 214 }
215 ++iii; 215 ++iii;
216 } 216 }
217} 217}
218void POP3wrapper::deleteMail(const RecMailP&mail) { 218void POP3wrapper::deleteMail(const RecMailP&mail) {
219 login(); 219 login();
220 if (!m_pop3) 220 if (!m_pop3)
221 return; 221 return;
222 int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); 222 int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber());
223 if (err != MAIL_NO_ERROR) { 223 if (err != MAIL_NO_ERROR) {
224 Global::statusMessage(tr("error deleting mail")); 224 Global::statusMessage(tr("error deleting mail"));
225 } 225 }
226} 226}
227 227
228void POP3wrapper::answeredMail(const RecMailP&) {} 228void POP3wrapper::answeredMail(const RecMailP&) {}
229 229
230int POP3wrapper::deleteAllMail(const FolderP&) { 230int POP3wrapper::deleteAllMail(const FolderP&) {
231 login(); 231 login();
232 if (!m_pop3) 232 if (!m_pop3)
233 return 0; 233 return 0;
234 int res = 1; 234 int res = 1;
235 235
236 uint32_t result = 0; 236 uint32_t result = 0;
237 int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); 237 int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result);
238 if (err != MAIL_NO_ERROR) { 238 if (err != MAIL_NO_ERROR) {
239 Global::statusMessage(tr("Error getting folder info")); 239 Global::statusMessage(tr("Error getting folder info"));
240 return 0; 240 return 0;
241 } 241 }
242 QWidget wid; 242 QWidget wid;
243 wid.show(); 243 wid.show();
244 for (unsigned int i = 0; i < result; ++i) { 244 for (unsigned int i = 0; i < result; ++i) {
245 Global::statusMessage(tr("Delete message %1 of %2").arg(i).arg(result)); 245 Global::statusMessage(tr("Delete message %1 of %2").arg(i).arg(result));
246 wid.raise(); 246 wid.raise();
247 qApp->processEvents(); 247 qApp->processEvents();
248 248
249 err = mailsession_remove_message(m_pop3->sto_session,i+1); 249 err = mailsession_remove_message(m_pop3->sto_session,i+1);
250 if (err != MAIL_NO_ERROR) { 250 if (err != MAIL_NO_ERROR) {
251 Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); 251 Global::statusMessage(tr("Error deleting mail %1").arg(i+1));
252 res=0; 252 res=0;
253 } 253 }
254 break; 254 break;
255 } 255 }
256 return res; 256 return res;
257} 257}
258 258
259void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { 259void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) {
260 login(); 260 login();
261 target_stat.message_count = 0; 261 target_stat.message_count = 0;
262 target_stat.message_unseen = 0; 262 target_stat.message_unseen = 0;
263 target_stat.message_recent = 0; 263 target_stat.message_recent = 0;
264 if (!m_pop3) 264 if (!m_pop3)
265 return; 265 return;
266 int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, 266 int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count,
267 &target_stat.message_recent,&target_stat.message_unseen); 267 &target_stat.message_recent,&target_stat.message_unseen);
268 if (r != MAIL_NO_ERROR) { 268 if (r != MAIL_NO_ERROR) {
269 ; // odebug << "error getting folter status." << oendl; 269 ; // odebug << "error getting folter status." << oendl;
270 } 270 }
271} 271}
272 272
273encodedString* POP3wrapper::fetchRawBody(const RecMailP&mail) { 273encodedString* POP3wrapper::fetchRawBody(const RecMailP&mail) {
274 char*target=0; 274 char*target=0;
275 size_t length=0; 275 size_t length=0;
276 encodedString*res = 0; 276 encodedString*res = 0;
277 mailmessage * mailmsg = 0; 277 mailmessage * mailmsg = 0;
278 int err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); 278 int err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg);
279 err = mailmessage_fetch(mailmsg,&target,&length); 279 err = mailmessage_fetch(mailmsg,&target,&length);
280 if (mailmsg) 280 if (mailmsg)
281 mailmessage_free(mailmsg); 281 mailmessage_free(mailmsg);
282 if (target) { 282 if (target) {
283 res = new encodedString(target,length); 283 res = new encodedString(target,length);
284 } 284 }
285 return res; 285 return res;
286} 286}
287 287
288MAILLIB::ATYPE POP3wrapper::getType()const { 288MAILLIB::ATYPE POP3wrapper::getType()const {
289 return account->getType(); 289 return account->getType();
290} 290}
291 291
292const QString&POP3wrapper::getName()const{ 292const QString&POP3wrapper::getName()const{
293 return account->getAccountName(); 293 return account->getAccountName();
294} 294}
diff --git a/kmicromail/libmailwrapper/settings.cpp b/kmicromail/libmailwrapper/settings.cpp
index b0a539e..90e32fa 100644
--- a/kmicromail/libmailwrapper/settings.cpp
+++ b/kmicromail/libmailwrapper/settings.cpp
@@ -2,439 +2,449 @@
2#include <qdir.h> 2#include <qdir.h>
3 3
4//#include <opie2/odebug.h> 4//#include <opie2/odebug.h>
5#include <qpe/config.h> 5#include <qpe/config.h>
6 6
7#include <kstandarddirs.h> 7#include <kstandarddirs.h>
8#include "settings.h" 8#include "settings.h"
9//#include "defines.h" 9//#include "defines.h"
10 10
11#define IMAP_PORT "143" 11#define IMAP_PORT "143"
12#define IMAP_SSL_PORT "993" 12#define IMAP_SSL_PORT "993"
13#define SMTP_PORT "25" 13#define SMTP_PORT "25"
14#define SMTP_SSL_PORT "465" 14#define SMTP_SSL_PORT "465"
15#define POP3_PORT "110" 15#define POP3_PORT "110"
16#define POP3_SSL_PORT "995" 16#define POP3_SSL_PORT "995"
17#define NNTP_PORT "119" 17#define NNTP_PORT "119"
18#define NNTP_SSL_PORT "563" 18#define NNTP_SSL_PORT "563"
19 19
20 20
21Settings::Settings() 21Settings::Settings()
22 : QObject() 22 : QObject()
23{ 23{
24 updateAccounts(); 24 updateAccounts();
25} 25}
26 26
27void Settings::checkDirectory() 27void Settings::checkDirectory()
28{ 28{
29 qDebug("Settings::checkDirectory() "); 29 qDebug("Settings::checkDirectory() ");
30 return; 30 return;
31 locateLocal("data", "kopiemail" ); 31 locateLocal("data", "kopiemail" );
32 /* 32 /*
33 if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { 33 if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) {
34 system( "mkdir -p $HOME/Applications/opiemail" ); 34 system( "mkdir -p $HOME/Applications/opiemail" );
35 qDebug("$HOME/Applications/opiemail created "); 35 qDebug("$HOME/Applications/opiemail created ");
36 } 36 }
37 */ 37 */
38} 38}
39 39
40QList<Account> Settings::getAccounts() 40QList<Account> Settings::getAccounts()
41{ 41{
42 return accounts; 42 return accounts;
43} 43}
44 44
45void Settings::addAccount( Account *account ) 45void Settings::addAccount( Account *account )
46{ 46{
47 accounts.append( account ); 47 accounts.append( account );
48} 48}
49 49
50void Settings::delAccount( Account *account ) 50void Settings::delAccount( Account *account )
51{ 51{
52 accounts.remove( account ); 52 accounts.remove( account );
53 account->remove(); 53 account->remove();
54} 54}
55 55
56void Settings::updateAccounts() 56void Settings::updateAccounts()
57{ 57{
58 accounts.clear(); 58 accounts.clear();
59 QDir dir( locateLocal("data", "kopiemail" ) ); 59 QDir dir( locateLocal("data", "kopiemail" ) );
60 QStringList::Iterator it; 60 QStringList::Iterator it;
61 61
62 QStringList imap = dir.entryList( "imap-*" ); 62 QStringList imap = dir.entryList( "imap-*" );
63 for ( it = imap.begin(); it != imap.end(); it++ ) { 63 for ( it = imap.begin(); it != imap.end(); it++ ) {
64 IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); 64 IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") );
65 accounts.append( account ); 65 accounts.append( account );
66 } 66 }
67 67
68 QStringList pop3 = dir.entryList( "pop3-*" ); 68 QStringList pop3 = dir.entryList( "pop3-*" );
69 for ( it = pop3.begin(); it != pop3.end(); it++ ) { 69 for ( it = pop3.begin(); it != pop3.end(); it++ ) {
70 POP3account *account = new POP3account( (*it).replace(0, 5, "") ); 70 POP3account *account = new POP3account( (*it).replace(0, 5, "") );
71 accounts.append( account ); 71 accounts.append( account );
72 } 72 }
73 73
74 QStringList smtp = dir.entryList( "smtp-*" ); 74 QStringList smtp = dir.entryList( "smtp-*" );
75 for ( it = smtp.begin(); it != smtp.end(); it++ ) { 75 for ( it = smtp.begin(); it != smtp.end(); it++ ) {
76 SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); 76 SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") );
77 accounts.append( account ); 77 accounts.append( account );
78 } 78 }
79 79
80 QStringList nntp = dir.entryList( "nntp-*" ); 80 QStringList nntp = dir.entryList( "nntp-*" );
81 for ( it = nntp.begin(); it != nntp.end(); it++ ) { 81 for ( it = nntp.begin(); it != nntp.end(); it++ ) {
82 NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); 82 NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") );
83 accounts.append( account ); 83 accounts.append( account );
84 } 84 }
85 85
86 readAccounts(); 86 readAccounts();
87} 87}
88 88
89void Settings::saveAccounts() 89void Settings::saveAccounts()
90{ 90{
91 checkDirectory(); 91 checkDirectory();
92 Account *it; 92 Account *it;
93 93
94 for ( it = accounts.first(); it; it = accounts.next() ) { 94 for ( it = accounts.first(); it; it = accounts.next() ) {
95 it->save(); 95 it->save();
96 } 96 }
97} 97}
98 98
99void Settings::readAccounts() 99void Settings::readAccounts()
100{ 100{
101 checkDirectory(); 101 checkDirectory();
102 Account *it; 102 Account *it;
103 103
104 for ( it = accounts.first(); it; it = accounts.next() ) { 104 for ( it = accounts.first(); it; it = accounts.next() ) {
105 it->read(); 105 it->read();
106 } 106 }
107} 107}
108 108
109Account::Account() 109Account::Account()
110{ 110{
111 accountName = "changeMe"; 111 accountName = "changeMe";
112 type = MAILLIB::A_UNDEFINED; 112 type = MAILLIB::A_UNDEFINED;
113 ssl = false; 113 ssl = false;
114 connectionType = 1; 114 connectionType = 1;
115 offline = false; 115 offline = false;
116} 116}
117 117
118void Account::remove() 118void Account::remove()
119{ 119{
120 QFile file( getFileName() ); 120 QFile file( getFileName() );
121 file.remove(); 121 file.remove();
122} 122}
123 123
124IMAPaccount::IMAPaccount() 124IMAPaccount::IMAPaccount()
125 : Account() 125 : Account()
126{ 126{
127 file = IMAPaccount::getUniqueFileName(); 127 file = IMAPaccount::getUniqueFileName();
128 accountName = "New IMAP Account"; 128 accountName = "New IMAP Account";
129 ssl = false; 129 ssl = false;
130 connectionType = 1; 130 connectionType = 1;
131 type = MAILLIB::A_IMAP; 131 type = MAILLIB::A_IMAP;
132 port = IMAP_PORT; 132 port = IMAP_PORT;
133} 133}
134 134
135IMAPaccount::IMAPaccount( QString filename ) 135IMAPaccount::IMAPaccount( QString filename )
136 : Account() 136 : Account()
137{ 137{
138 file = filename; 138 file = filename;
139 accountName = "New IMAP Account"; 139 accountName = "New IMAP Account";
140 ssl = false; 140 ssl = false;
141 connectionType = 1; 141 connectionType = 1;
142 type = MAILLIB::A_IMAP; 142 type = MAILLIB::A_IMAP;
143 port = IMAP_PORT; 143 port = IMAP_PORT;
144} 144}
145 145
146QString IMAPaccount::getUniqueFileName() 146QString IMAPaccount::getUniqueFileName()
147{ 147{
148 int num = 0; 148 int num = 0;
149 QString unique; 149 QString unique;
150 150
151 QDir dir( locateLocal("data", "kopiemail" ) ); 151 QDir dir( locateLocal("data", "kopiemail" ) );
152 152
153 QStringList imap = dir.entryList( "imap-*" ); 153 QStringList imap = dir.entryList( "imap-*" );
154 do { 154 do {
155 unique.setNum( num++ ); 155 unique.setNum( num++ );
156 } while ( imap.contains( "imap-" + unique ) > 0 ); 156 } while ( imap.contains( "imap-" + unique ) > 0 );
157 157
158 return unique; 158 return unique;
159} 159}
160 160
161void IMAPaccount::read() 161void IMAPaccount::read()
162{ 162{
163 Config *conf = new Config( getFileName(), Config::File ); 163 Config *conf = new Config( getFileName(), Config::File );
164 conf->setGroup( "IMAP Account" ); 164 conf->setGroup( "IMAP Account" );
165 accountName = conf->readEntry( "Account","" ); 165 accountName = conf->readEntry( "Account","" );
166 if (accountName.isNull()) accountName = ""; 166 if (accountName.isNull()) accountName = "";
167 server = conf->readEntry( "Server","" ); 167 server = conf->readEntry( "Server","" );
168 if (server.isNull()) server=""; 168 if (server.isNull()) server="";
169 port = conf->readEntry( "Port","" ); 169 port = conf->readEntry( "Port","" );
170 if (port.isNull()) port="143"; 170 if (port.isNull()) port="143";
171 connectionType = conf->readNumEntry( "ConnectionType" ); 171 connectionType = conf->readNumEntry( "ConnectionType" );
172 ssl = conf->readBoolEntry( "SSL",false ); 172 ssl = conf->readBoolEntry( "SSL",false );
173 user = conf->readEntry( "User","" ); 173 user = conf->readEntry( "User","" );
174 if (user.isNull()) user = ""; 174 if (user.isNull()) user = "";
175 password = conf->readEntryCrypt( "Password","" ); 175 password = conf->readEntryCrypt( "Password","" );
176 if (password.isNull()) password = ""; 176 if (password.isNull()) password = "";
177 prefix = conf->readEntry("MailPrefix",""); 177 prefix = conf->readEntry("MailPrefix","");
178 if (prefix.isNull()) prefix = ""; 178 if (prefix.isNull()) prefix = "";
179 offline = conf->readBoolEntry("Offline",false); 179 offline = conf->readBoolEntry("Offline",false);
180 delete conf; 180 delete conf;
181} 181}
182 182
183void IMAPaccount::save() 183void IMAPaccount::save()
184{ 184{
185 qDebug("saving %s ",getFileName().latin1() ); 185 qDebug("saving %s ",getFileName().latin1() );
186 Settings::checkDirectory(); 186 Settings::checkDirectory();
187 187
188 Config *conf = new Config( getFileName(), Config::File ); 188 Config *conf = new Config( getFileName(), Config::File );
189 conf->setGroup( "IMAP Account" ); 189 conf->setGroup( "IMAP Account" );
190 conf->writeEntry( "Account", accountName ); 190 conf->writeEntry( "Account", accountName );
191 conf->writeEntry( "Server", server ); 191 conf->writeEntry( "Server", server );
192 conf->writeEntry( "Port", port ); 192 conf->writeEntry( "Port", port );
193 conf->writeEntry( "SSL", ssl ); 193 conf->writeEntry( "SSL", ssl );
194 conf->writeEntry( "ConnectionType", connectionType ); 194 conf->writeEntry( "ConnectionType", connectionType );
195 conf->writeEntry( "User", user ); 195 conf->writeEntry( "User", user );
196 conf->writeEntryCrypt( "Password", password ); 196 conf->writeEntryCrypt( "Password", password );
197 conf->writeEntry( "MailPrefix",prefix); 197 conf->writeEntry( "MailPrefix",prefix);
198 conf->writeEntry( "Offline",offline); 198 conf->writeEntry( "Offline",offline);
199 conf->write(); 199 conf->write();
200 delete conf; 200 delete conf;
201} 201}
202 202
203 203
204QString IMAPaccount::getFileName() 204QString IMAPaccount::getFileName()
205{ 205{
206 return locateLocal("data", "kopiemail" ) +"/imap-" + file; 206 return locateLocal("data", "kopiemail" ) +"/imap-" + file;
207} 207}
208 208
209POP3account::POP3account() 209POP3account::POP3account()
210 : Account() 210 : Account()
211{ 211{
212 file = POP3account::getUniqueFileName(); 212 file = POP3account::getUniqueFileName();
213 accountName = "New POP3 Account"; 213 accountName = "New POP3 Account";
214 ssl = false; 214 ssl = false;
215 connectionType = 1; 215 connectionType = 1;
216 type = MAILLIB::A_POP3; 216 type = MAILLIB::A_POP3;
217 port = POP3_PORT; 217 port = POP3_PORT;
218} 218}
219 219
220POP3account::POP3account( QString filename ) 220POP3account::POP3account( QString filename )
221 : Account() 221 : Account()
222{ 222{
223 file = filename; 223 file = filename;
224 accountName = "New POP3 Account"; 224 accountName = "New POP3 Account";
225 ssl = false; 225 ssl = false;
226 connectionType = 1; 226 connectionType = 1;
227 type = MAILLIB::A_POP3; 227 type = MAILLIB::A_POP3;
228 port = POP3_PORT; 228 port = POP3_PORT;
229} 229}
230 230
231QString POP3account::getUniqueFileName() 231QString POP3account::getUniqueFileName()
232{ 232{
233 int num = 0; 233 int num = 0;
234 QString unique; 234 QString unique;
235 235
236 QDir dir( locateLocal("data", "kopiemail" ) ); 236 QDir dir( locateLocal("data", "kopiemail" ) );
237 237
238 QStringList imap = dir.entryList( "pop3-*" ); 238 QStringList imap = dir.entryList( "pop3-*" );
239 do { 239 do {
240 unique.setNum( num++ ); 240 unique.setNum( num++ );
241 } while ( imap.contains( "pop3-" + unique ) > 0 ); 241 } while ( imap.contains( "pop3-" + unique ) > 0 );
242 242
243 return unique; 243 return unique;
244} 244}
245 245
246void POP3account::read() 246void POP3account::read()
247{ 247{
248 Config *conf = new Config( getFileName(), Config::File ); 248 Config *conf = new Config( getFileName(), Config::File );
249 conf->setGroup( "POP3 Account" ); 249 conf->setGroup( "POP3 Account" );
250 accountName = conf->readEntry( "Account" ); 250 accountName = conf->readEntry( "Account" );
251 server = conf->readEntry( "Server" ); 251 server = conf->readEntry( "Server" );
252 port = conf->readEntry( "Port" ); 252 port = conf->readEntry( "Port" );
253 ssl = conf->readBoolEntry( "SSL" ); 253 ssl = conf->readBoolEntry( "SSL" );
254 connectionType = conf->readNumEntry( "ConnectionType" ); 254 connectionType = conf->readNumEntry( "ConnectionType" );
255 user = conf->readEntry( "User" ); 255 user = conf->readEntry( "User" );
256 password = conf->readEntryCrypt( "Password" ); 256 password = conf->readEntryCrypt( "Password" );
257 offline = conf->readBoolEntry("Offline",false); 257 offline = conf->readBoolEntry("Offline",false);
258 localFolder = conf->readEntry( "LocalFolder" );
259 maxMailSize = conf->readNumEntry( "MaxSize",0 );
260 int lf = conf->readNumEntry( "LastFetch",0 );
261 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) );
262 lastFetch = dt.addSecs( lf );
258 delete conf; 263 delete conf;
259} 264}
260 265
261void POP3account::save() 266void POP3account::save()
262{ 267{
263 Settings::checkDirectory(); 268 Settings::checkDirectory();
264 269
265 Config *conf = new Config( getFileName(), Config::File ); 270 Config *conf = new Config( getFileName(), Config::File );
266 conf->setGroup( "POP3 Account" ); 271 conf->setGroup( "POP3 Account" );
267 conf->writeEntry( "Account", accountName ); 272 conf->writeEntry( "Account", accountName );
268 conf->writeEntry( "Server", server ); 273 conf->writeEntry( "Server", server );
269 conf->writeEntry( "Port", port ); 274 conf->writeEntry( "Port", port );
270 conf->writeEntry( "SSL", ssl ); 275 conf->writeEntry( "SSL", ssl );
271 conf->writeEntry( "ConnectionType", connectionType ); 276 conf->writeEntry( "ConnectionType", connectionType );
272 conf->writeEntry( "User", user ); 277 conf->writeEntry( "User", user );
273 conf->writeEntryCrypt( "Password", password ); 278 conf->writeEntryCrypt( "Password", password );
274 conf->writeEntry( "Offline",offline); 279 conf->writeEntry( "Offline",offline);
280 conf->writeEntry( "LocalFolder", localFolder );
281 conf->writeEntry( "MaxSize", maxMailSize );
282 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) );
283 int lf = dt.secsTo ( lastFetch );
284 conf->writeEntry( "LastFetch", lf );
275 conf->write(); 285 conf->write();
276 delete conf; 286 delete conf;
277} 287}
278 288
279 289
280QString POP3account::getFileName() 290QString POP3account::getFileName()
281{ 291{
282 return locateLocal("data", "kopiemail" ) +"/pop3-" + file; 292 return locateLocal("data", "kopiemail" ) +"/pop3-" + file;
283} 293}
284 294
285SMTPaccount::SMTPaccount() 295SMTPaccount::SMTPaccount()
286 : Account() 296 : Account()
287{ 297{
288 file = SMTPaccount::getUniqueFileName(); 298 file = SMTPaccount::getUniqueFileName();
289 accountName = "New SMTP Account"; 299 accountName = "New SMTP Account";
290 ssl = false; 300 ssl = false;
291 connectionType = 1; 301 connectionType = 1;
292 login = false; 302 login = false;
293 useCC = false; 303 useCC = false;
294 useBCC = false; 304 useBCC = false;
295 useReply = false; 305 useReply = false;
296 type = MAILLIB::A_SMTP; 306 type = MAILLIB::A_SMTP;
297 port = SMTP_PORT; 307 port = SMTP_PORT;
298} 308}
299 309
300SMTPaccount::SMTPaccount( QString filename ) 310SMTPaccount::SMTPaccount( QString filename )
301 : Account() 311 : Account()
302{ 312{
303 file = filename; 313 file = filename;
304 accountName = "New SMTP Account"; 314 accountName = "New SMTP Account";
305 ssl = false; 315 ssl = false;
306 connectionType = 1; 316 connectionType = 1;
307 login = false; 317 login = false;
308 type = MAILLIB::A_SMTP; 318 type = MAILLIB::A_SMTP;
309 port = SMTP_PORT; 319 port = SMTP_PORT;
310} 320}
311 321
312QString SMTPaccount::getUniqueFileName() 322QString SMTPaccount::getUniqueFileName()
313{ 323{
314 int num = 0; 324 int num = 0;
315 QString unique; 325 QString unique;
316 326
317 QDir dir( locateLocal("data", "kopiemail" ) ); 327 QDir dir( locateLocal("data", "kopiemail" ) );
318 328
319 QStringList imap = dir.entryList( "smtp-*" ); 329 QStringList imap = dir.entryList( "smtp-*" );
320 do { 330 do {
321 unique.setNum( num++ ); 331 unique.setNum( num++ );
322 } while ( imap.contains( "smtp-" + unique ) > 0 ); 332 } while ( imap.contains( "smtp-" + unique ) > 0 );
323 333
324 return unique; 334 return unique;
325} 335}
326 336
327void SMTPaccount::read() 337void SMTPaccount::read()
328{ 338{
329 Config *conf = new Config( getFileName(), Config::File ); 339 Config *conf = new Config( getFileName(), Config::File );
330 conf->setGroup( "SMTP Account" ); 340 conf->setGroup( "SMTP Account" );
331 accountName = conf->readEntry( "Account" ); 341 accountName = conf->readEntry( "Account" );
332 server = conf->readEntry( "Server" ); 342 server = conf->readEntry( "Server" );
333 port = conf->readEntry( "Port" ); 343 port = conf->readEntry( "Port" );
334 ssl = conf->readBoolEntry( "SSL" ); 344 ssl = conf->readBoolEntry( "SSL" );
335 connectionType = conf->readNumEntry( "ConnectionType" ); 345 connectionType = conf->readNumEntry( "ConnectionType" );
336 login = conf->readBoolEntry( "Login" ); 346 login = conf->readBoolEntry( "Login" );
337 user = conf->readEntry( "User" ); 347 user = conf->readEntry( "User" );
338 password = conf->readEntryCrypt( "Password" ); 348 password = conf->readEntryCrypt( "Password" );
339 delete conf; 349 delete conf;
340} 350}
341 351
342void SMTPaccount::save() 352void SMTPaccount::save()
343{ 353{
344 Settings::checkDirectory(); 354 Settings::checkDirectory();
345 355
346 Config *conf = new Config( getFileName(), Config::File ); 356 Config *conf = new Config( getFileName(), Config::File );
347 conf->setGroup( "SMTP Account" ); 357 conf->setGroup( "SMTP Account" );
348 conf->writeEntry( "Account", accountName ); 358 conf->writeEntry( "Account", accountName );
349 conf->writeEntry( "Server", server ); 359 conf->writeEntry( "Server", server );
350 conf->writeEntry( "Port", port ); 360 conf->writeEntry( "Port", port );
351 conf->writeEntry( "SSL", ssl ); 361 conf->writeEntry( "SSL", ssl );
352 conf->writeEntry( "ConnectionType", connectionType ); 362 conf->writeEntry( "ConnectionType", connectionType );
353 conf->writeEntry( "Login", login ); 363 conf->writeEntry( "Login", login );
354 conf->writeEntry( "User", user ); 364 conf->writeEntry( "User", user );
355 conf->writeEntryCrypt( "Password", password ); 365 conf->writeEntryCrypt( "Password", password );
356 conf->write(); 366 conf->write();
357 delete conf; 367 delete conf;
358} 368}
359 369
360 370
361QString SMTPaccount::getFileName() 371QString SMTPaccount::getFileName()
362{ 372{
363 return locateLocal("data", "kopiemail" ) +"/smtp-" + file; 373 return locateLocal("data", "kopiemail" ) +"/smtp-" + file;
364} 374}
365 375
366NNTPaccount::NNTPaccount() 376NNTPaccount::NNTPaccount()
367 : Account() 377 : Account()
368{ 378{
369 file = NNTPaccount::getUniqueFileName(); 379 file = NNTPaccount::getUniqueFileName();
370 accountName = "New NNTP Account"; 380 accountName = "New NNTP Account";
371 ssl = false; 381 ssl = false;
372 login = false; 382 login = false;
373 type = MAILLIB::A_NNTP; 383 type = MAILLIB::A_NNTP;
374 port = NNTP_PORT; 384 port = NNTP_PORT;
375} 385}
376 386
377NNTPaccount::NNTPaccount( QString filename ) 387NNTPaccount::NNTPaccount( QString filename )
378 : Account() 388 : Account()
379{ 389{
380 file = filename; 390 file = filename;
381 accountName = "New NNTP Account"; 391 accountName = "New NNTP Account";
382 ssl = false; 392 ssl = false;
383 login = false; 393 login = false;
384 type = MAILLIB::A_NNTP; 394 type = MAILLIB::A_NNTP;
385 port = NNTP_PORT; 395 port = NNTP_PORT;
386} 396}
387 397
388QString NNTPaccount::getUniqueFileName() 398QString NNTPaccount::getUniqueFileName()
389{ 399{
390 int num = 0; 400 int num = 0;
391 QString unique; 401 QString unique;
392 402
393 QDir dir( locateLocal("data", "kopiemail" ) ); 403 QDir dir( locateLocal("data", "kopiemail" ) );
394 404
395 QStringList imap = dir.entryList( "nntp-*" ); 405 QStringList imap = dir.entryList( "nntp-*" );
396 do { 406 do {
397 unique.setNum( num++ ); 407 unique.setNum( num++ );
398 } while ( imap.contains( "nntp-" + unique ) > 0 ); 408 } while ( imap.contains( "nntp-" + unique ) > 0 );
399 409
400 return unique; 410 return unique;
401} 411}
402 412
403void NNTPaccount::read() 413void NNTPaccount::read()
404{ 414{
405 Config *conf = new Config( getFileName(), Config::File ); 415 Config *conf = new Config( getFileName(), Config::File );
406 conf->setGroup( "NNTP Account" ); 416 conf->setGroup( "NNTP Account" );
407 accountName = conf->readEntry( "Account" ); 417 accountName = conf->readEntry( "Account" );
408 server = conf->readEntry( "Server" ); 418 server = conf->readEntry( "Server" );
409 port = conf->readEntry( "Port" ); 419 port = conf->readEntry( "Port" );
410 ssl = conf->readBoolEntry( "SSL" ); 420 ssl = conf->readBoolEntry( "SSL" );
411 login = conf->readBoolEntry( "Login" ); 421 login = conf->readBoolEntry( "Login" );
412 user = conf->readEntry( "User" ); 422 user = conf->readEntry( "User" );
413 password = conf->readEntryCrypt( "Password" ); 423 password = conf->readEntryCrypt( "Password" );
414 subscribedGroups = conf->readListEntry( "Subscribed", ',' ); 424 subscribedGroups = conf->readListEntry( "Subscribed", ',' );
415 delete conf; 425 delete conf;
416} 426}
417 427
418void NNTPaccount::save() 428void NNTPaccount::save()
419{ 429{
420 Settings::checkDirectory(); 430 Settings::checkDirectory();
421 431
422 Config *conf = new Config( getFileName(), Config::File ); 432 Config *conf = new Config( getFileName(), Config::File );
423 conf->setGroup( "NNTP Account" ); 433 conf->setGroup( "NNTP Account" );
424 conf->writeEntry( "Account", accountName ); 434 conf->writeEntry( "Account", accountName );
425 conf->writeEntry( "Server", server ); 435 conf->writeEntry( "Server", server );
426 conf->writeEntry( "Port", port ); 436 conf->writeEntry( "Port", port );
427 conf->writeEntry( "SSL", ssl ); 437 conf->writeEntry( "SSL", ssl );
428 conf->writeEntry( "Login", login ); 438 conf->writeEntry( "Login", login );
429 conf->writeEntry( "User", user ); 439 conf->writeEntry( "User", user );
430 conf->writeEntryCrypt( "Password", password ); 440 conf->writeEntryCrypt( "Password", password );
431 conf->writeEntry( "Subscribed" , subscribedGroups, ',' ); 441 conf->writeEntry( "Subscribed" , subscribedGroups, ',' );
432 conf->write(); 442 conf->write();
433 delete conf; 443 delete conf;
434} 444}
435 445
436 446
437QString NNTPaccount::getFileName() 447QString NNTPaccount::getFileName()
438{ 448{
439 return locateLocal("data", "kopiemail" ) +"/nntp-" + file; 449 return locateLocal("data", "kopiemail" ) +"/nntp-" + file;
440} 450}
diff --git a/kmicromail/libmailwrapper/settings.h b/kmicromail/libmailwrapper/settings.h
index ba3ec89..c33c403 100644
--- a/kmicromail/libmailwrapper/settings.h
+++ b/kmicromail/libmailwrapper/settings.h
@@ -1,164 +1,173 @@
1#ifndef SETTINGS_H 1#ifndef SETTINGS_H
2#define SETTINGS_H 2#define SETTINGS_H
3 3
4#include "maildefines.h" 4#include "maildefines.h"
5 5
6/* OPIE */ 6/* OPIE */
7 7
8/* QT */ 8/* QT */
9#include <qobject.h> 9#include <qobject.h>
10#include <qlist.h> 10#include <qlist.h>
11#include <qdatetime.h>
11 12
12class Account 13class Account
13{ 14{
14 15
15public: 16public:
16 Account(); 17 Account();
17 virtual ~Account() {} 18 virtual ~Account() {}
18 19
19 void remove(); 20 void remove();
20 void setAccountName( QString name ) { accountName = name; } 21 void setAccountName( QString name ) { accountName = name; }
21 const QString&getAccountName()const{ return accountName; } 22 const QString&getAccountName()const{ return accountName; }
22 MAILLIB::ATYPE getType()const{ return type; } 23 MAILLIB::ATYPE getType()const{ return type; }
23 24
24 void setServer(const QString&str){ server = str; } 25 void setServer(const QString&str){ server = str; }
25 const QString&getServer()const{ return server; } 26 const QString&getServer()const{ return server; }
26 27
28 void setLocalFolder( QString name ) { localFolder = name; }
29 const QString& getLocalFolder()const{ return localFolder; }
30
27 void setPort(const QString&str) { port = str; } 31 void setPort(const QString&str) { port = str; }
28 const QString&getPort()const{ return port; } 32 const QString&getPort()const{ return port; }
29 33
30 void setUser(const QString&str){ user = str; } 34 void setUser(const QString&str){ user = str; }
31 const QString&getUser()const{ return user; } 35 const QString&getUser()const{ return user; }
32 36
33 void setPassword(const QString&str) { password = str; } 37 void setPassword(const QString&str) { password = str; }
34 const QString&getPassword()const { return password; } 38 const QString&getPassword()const { return password; }
35 39
36 void setSSL( bool b ) { ssl = b; } 40 void setSSL( bool b ) { ssl = b; }
37 bool getSSL() { return ssl; } 41 bool getSSL() { return ssl; }
38 42
39 void setConnectionType( int x ) { connectionType = x; } 43 void setConnectionType( int x ) { connectionType = x; }
40 int ConnectionType() { return connectionType; } 44 int ConnectionType() { return connectionType; }
41 45
46 void setMaxMailSize( int x ) { maxMailSize = x; }
47 int getMaxMailSize() { return maxMailSize; }
42 48
43 void setOffline(bool b) {offline = b;} 49 void setOffline(bool b) {offline = b;}
44 bool getOffline()const{return offline;} 50 bool getOffline()const{return offline;}
45 51
46 virtual QString getFileName() { return accountName; } 52 virtual QString getFileName() { return accountName; }
47 virtual void read() { ; } 53 virtual void read() { ; }
48 virtual void save() { ; } 54 virtual void save() { ; }
49 55
50protected: 56protected:
51 QString accountName, server, port, user, password; 57 QString accountName, server, port, user, password;
52 bool ssl; 58 bool ssl;
53 int connectionType; 59 int connectionType;
54 bool offline; 60 bool offline;
55 MAILLIB::ATYPE type; 61 MAILLIB::ATYPE type;
62 QString localFolder;
63 int maxMailSize;
64 QDateTime lastFetch;
56}; 65};
57 66
58class IMAPaccount : public Account 67class IMAPaccount : public Account
59{ 68{
60 69
61public: 70public:
62 IMAPaccount(); 71 IMAPaccount();
63 IMAPaccount( QString filename ); 72 IMAPaccount( QString filename );
64 73
65 static QString getUniqueFileName(); 74 static QString getUniqueFileName();
66 75
67 virtual void read(); 76 virtual void read();
68 virtual void save(); 77 virtual void save();
69 virtual QString getFileName(); 78 virtual QString getFileName();
70 79
71 void setPrefix(const QString&str) {prefix=str;} 80 void setPrefix(const QString&str) {prefix=str;}
72 const QString&getPrefix()const{return prefix;} 81 const QString&getPrefix()const{return prefix;}
73 82
74private: 83private:
75 QString file,prefix; 84 QString file,prefix;
76 85
77}; 86};
78 87
79class POP3account : public Account 88class POP3account : public Account
80{ 89{
81 90
82public: 91public:
83 POP3account(); 92 POP3account();
84 POP3account( QString filename ); 93 POP3account( QString filename );
85 94
86 static QString getUniqueFileName(); 95 static QString getUniqueFileName();
87 96
88 virtual void read(); 97 virtual void read();
89 virtual void save(); 98 virtual void save();
90 virtual QString getFileName(); 99 virtual QString getFileName();
91 100
92private: 101private:
93 QString file; 102 QString file;
94 103
95}; 104};
96 105
97class SMTPaccount : public Account 106class SMTPaccount : public Account
98{ 107{
99 108
100public: 109public:
101 SMTPaccount(); 110 SMTPaccount();
102 SMTPaccount( QString filename ); 111 SMTPaccount( QString filename );
103 112
104 static QString getUniqueFileName(); 113 static QString getUniqueFileName();
105 114
106 virtual void read(); 115 virtual void read();
107 virtual void save(); 116 virtual void save();
108 virtual QString getFileName(); 117 virtual QString getFileName();
109 118
110 void setLogin( bool b ) { login = b; } 119 void setLogin( bool b ) { login = b; }
111 bool getLogin() { return login; } 120 bool getLogin() { return login; }
112 121
113private: 122private:
114 QString file, name, mail, org, cc, bcc, reply, signature; 123 QString file, name, mail, org, cc, bcc, reply, signature;
115 bool useCC, useBCC, useReply, login; 124 bool useCC, useBCC, useReply, login;
116 125
117}; 126};
118 127
119class NNTPaccount : public Account 128class NNTPaccount : public Account
120{ 129{
121 130
122public: 131public:
123 NNTPaccount(); 132 NNTPaccount();
124 NNTPaccount( QString filename ); 133 NNTPaccount( QString filename );
125 134
126 static QString getUniqueFileName(); 135 static QString getUniqueFileName();
127 136
128 virtual void read(); 137 virtual void read();
129 virtual void save(); 138 virtual void save();
130 virtual QString getFileName(); 139 virtual QString getFileName();
131 140
132 void setLogin( bool b ) { login = b; } 141 void setLogin( bool b ) { login = b; }
133 bool getLogin() { return login; } 142 bool getLogin() { return login; }
134 143
135 void setGroups( QStringList list ) { subscribedGroups = list; } 144 void setGroups( QStringList list ) { subscribedGroups = list; }
136 QStringList getGroups() { return subscribedGroups; } 145 QStringList getGroups() { return subscribedGroups; }
137 146
138private: 147private:
139 QString file; 148 QString file;
140 bool login; 149 bool login;
141 QStringList subscribedGroups; 150 QStringList subscribedGroups;
142 151
143}; 152};
144 153
145class Settings : public QObject 154class Settings : public QObject
146{ 155{
147 Q_OBJECT 156 Q_OBJECT
148 157
149public: 158public:
150 Settings(); 159 Settings();
151 QList<Account> getAccounts(); 160 QList<Account> getAccounts();
152 void addAccount(Account *account); 161 void addAccount(Account *account);
153 void delAccount(Account *account); 162 void delAccount(Account *account);
154 void saveAccounts(); 163 void saveAccounts();
155 void readAccounts(); 164 void readAccounts();
156 static void checkDirectory(); 165 static void checkDirectory();
157 166
158private: 167private:
159 void updateAccounts(); 168 void updateAccounts();
160 QList<Account> accounts; 169 QList<Account> accounts;
161 170
162}; 171};
163 172
164#endif 173#endif