Diffstat (limited to 'noncore/net/mail/libmailwrapper/settings.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp index 3c9b25c..09be91b 100644 --- a/noncore/net/mail/libmailwrapper/settings.cpp +++ b/noncore/net/mail/libmailwrapper/settings.cpp | |||
@@ -1,43 +1,42 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
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 "settings.h" | 7 | #include "settings.h" |
8 | //#include "defines.h" | 8 | //#include "defines.h" |
9 | 9 | ||
10 | #define IMAP_PORT "143" | 10 | #define IMAP_PORT "143" |
11 | #define IMAP_SSL_PORT "993" | 11 | #define IMAP_SSL_PORT "993" |
12 | #define SMTP_PORT "25" | 12 | #define SMTP_PORT "25" |
13 | #define SMTP_SSL_PORT "465" | 13 | #define SMTP_SSL_PORT "465" |
14 | #define POP3_PORT "110" | 14 | #define POP3_PORT "110" |
15 | #define POP3_SSL_PORT "995" | 15 | #define POP3_SSL_PORT "995" |
16 | #define NNTP_PORT "119" | 16 | #define NNTP_PORT "119" |
17 | #define NNTP_SSL_PORT "563" | 17 | #define NNTP_SSL_PORT "563" |
18 | 18 | ||
19 | |||
20 | Settings::Settings() | 19 | Settings::Settings() |
21 | : QObject() | 20 | : QObject() |
22 | { | 21 | { |
23 | updateAccounts(); | 22 | updateAccounts(); |
24 | } | 23 | } |
25 | 24 | ||
26 | void Settings::checkDirectory() | 25 | void Settings::checkDirectory() |
27 | { | 26 | { |
28 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { | 27 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { |
29 | system( "mkdir -p $HOME/Applications/opiemail" ); | 28 | system( "mkdir -p $HOME/Applications/opiemail" ); |
30 | odebug << "$HOME/Applications/opiemail created" << oendl; | 29 | odebug << "$HOME/Applications/opiemail created" << oendl; |
31 | } | 30 | } |
32 | } | 31 | } |
33 | 32 | ||
34 | QList<Account> Settings::getAccounts() | 33 | QList<Account> Settings::getAccounts() |
35 | { | 34 | { |
36 | return accounts; | 35 | return accounts; |
37 | } | 36 | } |
38 | 37 | ||
39 | void Settings::addAccount( Account *account ) | 38 | void Settings::addAccount( Account *account ) |
40 | { | 39 | { |
41 | accounts.append( account ); | 40 | accounts.append( account ); |
42 | } | 41 | } |
43 | 42 | ||
@@ -192,116 +191,144 @@ void IMAPaccount::save() | |||
192 | conf->writeEntry( "ConnectionType", connectionType ); | 191 | conf->writeEntry( "ConnectionType", connectionType ); |
193 | conf->writeEntry( "User", user ); | 192 | conf->writeEntry( "User", user ); |
194 | conf->writeEntryCrypt( "Password", password ); | 193 | conf->writeEntryCrypt( "Password", password ); |
195 | conf->writeEntry( "MailPrefix",prefix); | 194 | conf->writeEntry( "MailPrefix",prefix); |
196 | conf->writeEntry( "Offline",offline); | 195 | conf->writeEntry( "Offline",offline); |
197 | conf->write(); | 196 | conf->write(); |
198 | delete conf; | 197 | delete conf; |
199 | } | 198 | } |
200 | 199 | ||
201 | 200 | ||
202 | QString IMAPaccount::getFileName() | 201 | QString IMAPaccount::getFileName() |
203 | { | 202 | { |
204 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; | 203 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; |
205 | } | 204 | } |
206 | 205 | ||
207 | POP3account::POP3account() | 206 | POP3account::POP3account() |
208 | : Account() | 207 | : Account() |
209 | { | 208 | { |
210 | file = POP3account::getUniqueFileName(); | 209 | file = POP3account::getUniqueFileName(); |
211 | accountName = "New POP3 Account"; | 210 | accountName = "New POP3 Account"; |
212 | ssl = false; | 211 | ssl = false; |
213 | connectionType = 1; | 212 | connectionType = 1; |
214 | type = MAILLIB::A_POP3; | 213 | type = MAILLIB::A_POP3; |
215 | port = POP3_PORT; | 214 | port = POP3_PORT; |
215 | m_CheckSize = true; | ||
216 | m_MaxSize = 1024; | ||
216 | } | 217 | } |
217 | 218 | ||
218 | POP3account::POP3account( QString filename ) | 219 | POP3account::POP3account( QString filename ) |
219 | : Account() | 220 | : Account() |
220 | { | 221 | { |
221 | file = filename; | 222 | file = filename; |
222 | accountName = "New POP3 Account"; | 223 | accountName = "New POP3 Account"; |
223 | ssl = false; | 224 | ssl = false; |
224 | connectionType = 1; | 225 | connectionType = 1; |
225 | type = MAILLIB::A_POP3; | 226 | type = MAILLIB::A_POP3; |
226 | port = POP3_PORT; | 227 | port = POP3_PORT; |
228 | m_CheckSize = true; | ||
229 | m_MaxSize = 1024; | ||
227 | } | 230 | } |
228 | 231 | ||
229 | QString POP3account::getUniqueFileName() | 232 | QString POP3account::getUniqueFileName() |
230 | { | 233 | { |
231 | int num = 0; | 234 | int num = 0; |
232 | QString unique; | 235 | QString unique; |
233 | 236 | ||
234 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 237 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
235 | 238 | ||
236 | QStringList imap = dir.entryList( "pop3-*" ); | 239 | QStringList imap = dir.entryList( "pop3-*" ); |
237 | do { | 240 | do { |
238 | unique.setNum( num++ ); | 241 | unique.setNum( num++ ); |
239 | } while ( imap.contains( "pop3-" + unique ) > 0 ); | 242 | } while ( imap.contains( "pop3-" + unique ) > 0 ); |
240 | 243 | ||
241 | return unique; | 244 | return unique; |
242 | } | 245 | } |
243 | 246 | ||
244 | void POP3account::read() | 247 | void POP3account::read() |
245 | { | 248 | { |
246 | Config *conf = new Config( getFileName(), Config::File ); | 249 | Config *conf = new Config( getFileName(), Config::File ); |
247 | conf->setGroup( "POP3 Account" ); | 250 | conf->setGroup( "POP3 Account" ); |
248 | accountName = conf->readEntry( "Account" ); | 251 | accountName = conf->readEntry( "Account" ); |
249 | server = conf->readEntry( "Server" ); | 252 | server = conf->readEntry( "Server" ); |
250 | port = conf->readEntry( "Port" ); | 253 | port = conf->readEntry( "Port" ); |
251 | ssl = conf->readBoolEntry( "SSL" ); | 254 | ssl = conf->readBoolEntry( "SSL" ); |
252 | connectionType = conf->readNumEntry( "ConnectionType" ); | 255 | connectionType = conf->readNumEntry( "ConnectionType" ); |
253 | user = conf->readEntry( "User" ); | 256 | user = conf->readEntry( "User" ); |
254 | password = conf->readEntryCrypt( "Password" ); | 257 | password = conf->readEntryCrypt( "Password" ); |
255 | offline = conf->readBoolEntry("Offline",false); | 258 | offline = conf->readBoolEntry("Offline",false); |
259 | m_CheckSize = conf->readBoolEntry("Checkmaxsize",true); | ||
260 | m_MaxSize = conf->readNumEntry("Maxsize",1024); | ||
256 | delete conf; | 261 | delete conf; |
257 | } | 262 | } |
258 | 263 | ||
259 | void POP3account::save() | 264 | void POP3account::save() |
260 | { | 265 | { |
261 | odebug << "saving " + getFileName() << oendl; | 266 | odebug << "saving " + getFileName() << oendl; |
262 | Settings::checkDirectory(); | 267 | Settings::checkDirectory(); |
263 | 268 | ||
264 | Config *conf = new Config( getFileName(), Config::File ); | 269 | Config *conf = new Config( getFileName(), Config::File ); |
265 | conf->setGroup( "POP3 Account" ); | 270 | conf->setGroup( "POP3 Account" ); |
266 | conf->writeEntry( "Account", accountName ); | 271 | conf->writeEntry( "Account", accountName ); |
267 | conf->writeEntry( "Server", server ); | 272 | conf->writeEntry( "Server", server ); |
268 | conf->writeEntry( "Port", port ); | 273 | conf->writeEntry( "Port", port ); |
269 | conf->writeEntry( "SSL", ssl ); | 274 | conf->writeEntry( "SSL", ssl ); |
270 | conf->writeEntry( "ConnectionType", connectionType ); | 275 | conf->writeEntry( "ConnectionType", connectionType ); |
271 | conf->writeEntry( "User", user ); | 276 | conf->writeEntry( "User", user ); |
272 | conf->writeEntryCrypt( "Password", password ); | 277 | conf->writeEntryCrypt( "Password", password ); |
273 | conf->writeEntry( "Offline",offline); | 278 | conf->writeEntry( "Offline",offline); |
279 | conf->writeEntry("Checkmaxsize",m_CheckSize); | ||
280 | conf->writeEntry("Maxsize",m_MaxSize); | ||
274 | conf->write(); | 281 | conf->write(); |
275 | delete conf; | 282 | delete conf; |
276 | } | 283 | } |
277 | 284 | ||
278 | 285 | ||
279 | QString POP3account::getFileName() | 286 | QString POP3account::getFileName() |
280 | { | 287 | { |
281 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; | 288 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; |
282 | } | 289 | } |
283 | 290 | ||
291 | bool POP3account::getCheckMaxSize()const | ||
292 | { | ||
293 | return m_CheckSize; | ||
294 | } | ||
295 | |||
296 | void POP3account::setCheckMaxSize(bool aValue) | ||
297 | { | ||
298 | m_CheckSize = aValue; | ||
299 | } | ||
300 | |||
301 | int POP3account::getMaxSize()const | ||
302 | { | ||
303 | return m_MaxSize; | ||
304 | } | ||
305 | |||
306 | void POP3account::setMaxSize(int aValue) | ||
307 | { | ||
308 | m_MaxSize = aValue; | ||
309 | } | ||
310 | |||
284 | SMTPaccount::SMTPaccount() | 311 | SMTPaccount::SMTPaccount() |
285 | : Account() | 312 | : Account() |
286 | { | 313 | { |
287 | file = SMTPaccount::getUniqueFileName(); | 314 | file = SMTPaccount::getUniqueFileName(); |
288 | accountName = "New SMTP Account"; | 315 | accountName = "New SMTP Account"; |
289 | ssl = false; | 316 | ssl = false; |
290 | connectionType = 1; | 317 | connectionType = 1; |
291 | login = false; | 318 | login = false; |
292 | useCC = false; | 319 | useCC = false; |
293 | useBCC = false; | 320 | useBCC = false; |
294 | useReply = false; | 321 | useReply = false; |
295 | type = MAILLIB::A_SMTP; | 322 | type = MAILLIB::A_SMTP; |
296 | port = SMTP_PORT; | 323 | port = SMTP_PORT; |
297 | } | 324 | } |
298 | 325 | ||
299 | SMTPaccount::SMTPaccount( QString filename ) | 326 | SMTPaccount::SMTPaccount( QString filename ) |
300 | : Account() | 327 | : Account() |
301 | { | 328 | { |
302 | file = filename; | 329 | file = filename; |
303 | accountName = "New SMTP Account"; | 330 | accountName = "New SMTP Account"; |
304 | ssl = false; | 331 | ssl = false; |
305 | connectionType = 1; | 332 | connectionType = 1; |
306 | login = false; | 333 | login = false; |
307 | type = MAILLIB::A_SMTP; | 334 | type = MAILLIB::A_SMTP; |