author | zautrix <zautrix> | 2004-09-10 22:52:50 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-10 22:52:50 (UTC) |
commit | 1b41a0e3bf63364940daf132446939e3570c57ad (patch) (unidiff) | |
tree | 81db8e427beadcf3bbd5356962b5d08b970a87e4 /kmicromail/libmailwrapper | |
parent | c280882f788b31f874f928e23fc29c2aaca991eb (diff) | |
download | kdepimpi-1b41a0e3bf63364940daf132446939e3570c57ad.zip kdepimpi-1b41a0e3bf63364940daf132446939e3570c57ad.tar.gz kdepimpi-1b41a0e3bf63364940daf132446939e3570c57ad.tar.bz2 |
Added pop3 settings
-rw-r--r-- | kmicromail/libmailwrapper/pop3wrapper.cpp | 2 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/settings.cpp | 10 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/settings.h | 9 |
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 | |||
@@ -29,193 +29,193 @@ POP3wrapper::~POP3wrapper() { | |||
29 | if (msg_cache.exists()) { | 29 | if (msg_cache.exists()) { |
30 | msg_cache.remove(); | 30 | msg_cache.remove(); |
31 | } | 31 | } |
32 | } | 32 | } |
33 | 33 | ||
34 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { | 34 | void 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 | ||
38 | RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { | 38 | RecBodyP 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 | ||
102 | void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) | 102 | void 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 | ||
113 | void POP3wrapper::login() | 113 | void 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 | ||
180 | void POP3wrapper::logout() | 180 | void 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 | ||
189 | QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { | 189 | QValueList<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 | ||
196 | void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target) | 196 | void 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 | } |
218 | void POP3wrapper::deleteMail(const RecMailP&mail) { | 218 | void POP3wrapper::deleteMail(const RecMailP&mail) { |
219 | login(); | 219 | login(); |
220 | if (!m_pop3) | 220 | if (!m_pop3) |
221 | return; | 221 | return; |
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 | |||
@@ -162,209 +162,219 @@ void 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 | ||
183 | void IMAPaccount::save() | 183 | void 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 | ||
204 | QString IMAPaccount::getFileName() | 204 | QString IMAPaccount::getFileName() |
205 | { | 205 | { |
206 | return locateLocal("data", "kopiemail" ) +"/imap-" + file; | 206 | return locateLocal("data", "kopiemail" ) +"/imap-" + file; |
207 | } | 207 | } |
208 | 208 | ||
209 | POP3account::POP3account() | 209 | POP3account::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 | ||
220 | POP3account::POP3account( QString filename ) | 220 | POP3account::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 | ||
231 | QString POP3account::getUniqueFileName() | 231 | QString 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 | ||
246 | void POP3account::read() | 246 | void 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 | ||
261 | void POP3account::save() | 266 | void 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 | ||
280 | QString POP3account::getFileName() | 290 | QString POP3account::getFileName() |
281 | { | 291 | { |
282 | return locateLocal("data", "kopiemail" ) +"/pop3-" + file; | 292 | return locateLocal("data", "kopiemail" ) +"/pop3-" + file; |
283 | } | 293 | } |
284 | 294 | ||
285 | SMTPaccount::SMTPaccount() | 295 | SMTPaccount::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 | ||
300 | SMTPaccount::SMTPaccount( QString filename ) | 310 | SMTPaccount::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 | ||
312 | QString SMTPaccount::getUniqueFileName() | 322 | QString 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 | ||
327 | void SMTPaccount::read() | 337 | void 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 | ||
342 | void SMTPaccount::save() | 352 | void 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 | ||
361 | QString SMTPaccount::getFileName() | 371 | QString SMTPaccount::getFileName() |
362 | { | 372 | { |
363 | return locateLocal("data", "kopiemail" ) +"/smtp-" + file; | 373 | return locateLocal("data", "kopiemail" ) +"/smtp-" + file; |
364 | } | 374 | } |
365 | 375 | ||
366 | NNTPaccount::NNTPaccount() | 376 | NNTPaccount::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"; |
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,151 +1,160 @@ | |||
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 | ||
12 | class Account | 13 | class Account |
13 | { | 14 | { |
14 | 15 | ||
15 | public: | 16 | public: |
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 | ||
50 | protected: | 56 | protected: |
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 | ||
58 | class IMAPaccount : public Account | 67 | class IMAPaccount : public Account |
59 | { | 68 | { |
60 | 69 | ||
61 | public: | 70 | public: |
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 | ||
74 | private: | 83 | private: |
75 | QString file,prefix; | 84 | QString file,prefix; |
76 | 85 | ||
77 | }; | 86 | }; |
78 | 87 | ||
79 | class POP3account : public Account | 88 | class POP3account : public Account |
80 | { | 89 | { |
81 | 90 | ||
82 | public: | 91 | public: |
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 | ||
92 | private: | 101 | private: |
93 | QString file; | 102 | QString file; |
94 | 103 | ||
95 | }; | 104 | }; |
96 | 105 | ||
97 | class SMTPaccount : public Account | 106 | class SMTPaccount : public Account |
98 | { | 107 | { |
99 | 108 | ||
100 | public: | 109 | public: |
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 | ||
113 | private: | 122 | private: |
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 | ||
119 | class NNTPaccount : public Account | 128 | class NNTPaccount : public Account |
120 | { | 129 | { |
121 | 130 | ||
122 | public: | 131 | public: |
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 | ||
138 | private: | 147 | private: |
139 | QString file; | 148 | QString file; |
140 | bool login; | 149 | bool login; |
141 | QStringList subscribedGroups; | 150 | QStringList subscribedGroups; |
142 | 151 | ||
143 | }; | 152 | }; |
144 | 153 | ||
145 | class Settings : public QObject | 154 | class Settings : public QObject |
146 | { | 155 | { |
147 | Q_OBJECT | 156 | Q_OBJECT |
148 | 157 | ||
149 | public: | 158 | public: |
150 | Settings(); | 159 | Settings(); |
151 | QList<Account> getAccounts(); | 160 | QList<Account> getAccounts(); |