summaryrefslogtreecommitdiff
path: root/noncore/net/mail/libmailwrapper
Unidiff
Diffstat (limited to 'noncore/net/mail/libmailwrapper') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp95
-rw-r--r--noncore/net/mail/libmailwrapper/settings.cpp7
-rw-r--r--noncore/net/mail/libmailwrapper/settings.h5
3 files changed, 64 insertions, 43 deletions
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index 67bde38..f5eca4a 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -12,6 +12,5 @@
12 12
13POP3wrapper::POP3wrapper( POP3account *a ) 13POP3wrapper::POP3wrapper( POP3account *a )
14 : Genericwrapper() 14: Genericwrapper() {
15{
16 account = a; 15 account = a;
17 m_pop3 = NULL; 16 m_pop3 = NULL;
@@ -21,6 +20,5 @@ POP3wrapper::POP3wrapper( POP3account *a )
21} 20}
22 21
23POP3wrapper::~POP3wrapper() 22POP3wrapper::~POP3wrapper() {
24{
25 logout(); 23 logout();
26 QFile msg_cache(msgTempName); 24 QFile msg_cache(msgTempName);
@@ -30,11 +28,9 @@ POP3wrapper::~POP3wrapper()
30} 28}
31 29
32void POP3wrapper::pop3_progress( size_t current, size_t maximum ) 30void POP3wrapper::pop3_progress( size_t current, size_t maximum ) {
33{
34 qDebug( "POP3: %i of %i", current, maximum ); 31 qDebug( "POP3: %i of %i", current, maximum );
35} 32}
36 33
37RecBody POP3wrapper::fetchBody( const RecMail &mail ) 34RecBody POP3wrapper::fetchBody( const RecMail &mail ) {
38{
39 int err = MAILPOP3_NO_ERROR; 35 int err = MAILPOP3_NO_ERROR;
40 char *message = 0; 36 char *message = 0;
@@ -91,14 +87,16 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail )
91 87
92 /* clean up */ 88 /* clean up */
93 if (mailmsg) mailmessage_free(mailmsg); 89 if (mailmsg)
94 if (message) free(message); 90 mailmessage_free(mailmsg);
91 if (message)
92 free(message);
95 93
96 return body; 94 return body;
97} 95}
98 96
99void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) 97void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) {
100{
101 login(); 98 login();
102 if (!m_pop3) return; 99 if (!m_pop3)
100 return;
103 uint32_t res_messages,res_recent,res_unseen; 101 uint32_t res_messages,res_recent,res_unseen;
104 mailsession_status_folder(m_folder->fld_session,"INBOX",&res_messages,&res_recent,&res_unseen); 102 mailsession_status_folder(m_folder->fld_session,"INBOX",&res_messages,&res_recent,&res_unseen);
@@ -107,9 +105,10 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
107} 105}
108 106
109void POP3wrapper::login() 107void POP3wrapper::login() {
110{ 108 if (account->getOffline())
111 if (account->getOffline()) return; 109 return;
112 /* we'll hold the line */ 110 /* we'll hold the line */
113 if ( m_pop3 != NULL ) return; 111 if ( m_pop3 != NULL )
112 return;
114 113
115 const char *server, *user, *pass; 114 const char *server, *user, *pass;
@@ -137,12 +136,27 @@ void POP3wrapper::login()
137 } 136 }
138 137
139 bool ssl = account->getSSL(); 138 // bool ssl = account->getSSL();
140 139
141 m_pop3=mailstorage_new(NULL); 140 m_pop3=mailstorage_new(NULL);
142 int conntype = (ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); 141
142 int conntypeset = account->ConnectionType();
143 int conntype = 0;
144 if ( conntypeset == 3 ) {
145 conntype = CONNECTION_TYPE_COMMAND;
146 } else if ( conntypeset == 2 ) {
147 conntype = CONNECTION_TYPE_TLS;
148 } else if ( conntypeset == 1 ) {
149 conntype = CONNECTION_TYPE_STARTTLS;
150 } else if ( conntypeset == 0 ) {
151 conntype = CONNECTION_TYPE_TRY_STARTTLS;
152 }
153
154 //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN);
143 155
144 pop3_mailstorage_init(m_pop3,(char*)server,port,NULL,conntype,POP3_AUTH_TYPE_PLAIN, 156 pop3_mailstorage_init(m_pop3,(char*)server,port,NULL,conntype,POP3_AUTH_TYPE_PLAIN,
145 (char*)user,(char*)pass,0,0,0); 157 (char*)user,(char*)pass,0,0,0);
146 158
159
160
147 m_folder = mailfolder_new(m_pop3, NULL, NULL); 161 m_folder = mailfolder_new(m_pop3, NULL, NULL);
148 162
@@ -164,8 +178,8 @@ void POP3wrapper::login()
164} 178}
165 179
166void POP3wrapper::logout() 180void POP3wrapper::logout() {
167{
168 int err = MAILPOP3_NO_ERROR; 181 int err = MAILPOP3_NO_ERROR;
169 if ( m_pop3 == NULL ) return; 182 if ( m_pop3 == NULL )
183 return;
170 mailfolder_free(m_folder); 184 mailfolder_free(m_folder);
171 m_folder = 0; 185 m_folder = 0;
@@ -175,6 +189,5 @@ void POP3wrapper::logout()
175 189
176 190
177QList<Folder>* POP3wrapper::listFolders() 191QList<Folder>* POP3wrapper::listFolders() {
178{
179 QList<Folder> * folders = new QList<Folder>(); 192 QList<Folder> * folders = new QList<Folder>();
180 folders->setAutoDelete( false ); 193 folders->setAutoDelete( false );
@@ -184,8 +197,8 @@ QList<Folder>* POP3wrapper::listFolders()
184} 197}
185 198
186void POP3wrapper::deleteMail(const RecMail&mail) 199void POP3wrapper::deleteMail(const RecMail&mail) {
187{
188 login(); 200 login();
189 if (!m_pop3) return; 201 if (!m_pop3)
202 return;
190 int err = mailsession_remove_message(m_folder->fld_session,mail.getNumber()); 203 int err = mailsession_remove_message(m_folder->fld_session,mail.getNumber());
191 if (err != MAIL_NO_ERROR) { 204 if (err != MAIL_NO_ERROR) {
@@ -194,12 +207,10 @@ void POP3wrapper::deleteMail(const RecMail&mail)
194} 207}
195 208
196void POP3wrapper::answeredMail(const RecMail&) 209void POP3wrapper::answeredMail(const RecMail&) {}
197{
198}
199 210
200int POP3wrapper::deleteAllMail(const Folder*) 211int POP3wrapper::deleteAllMail(const Folder*) {
201{
202 login(); 212 login();
203 if (!m_pop3) return 0; 213 if (!m_pop3)
214 return 0;
204 int res = 1; 215 int res = 1;
205 216
@@ -221,17 +232,16 @@ int POP3wrapper::deleteAllMail(const Folder*)
221} 232}
222 233
223void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) 234void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) {
224{
225 login(); 235 login();
226 target_stat.message_count = 0; 236 target_stat.message_count = 0;
227 target_stat.message_unseen = 0; 237 target_stat.message_unseen = 0;
228 target_stat.message_recent = 0; 238 target_stat.message_recent = 0;
229 if (!m_pop3) return; 239 if (!m_pop3)
240 return;
230 int r = mailsession_status_folder(m_folder->fld_session,0,&target_stat.message_count, 241 int r = mailsession_status_folder(m_folder->fld_session,0,&target_stat.message_count,
231 &target_stat.message_recent,&target_stat.message_unseen); 242 &target_stat.message_recent,&target_stat.message_unseen);
232} 243}
233 244
234encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) 245encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) {
235{
236 char*target=0; 246 char*target=0;
237 size_t length=0; 247 size_t length=0;
@@ -240,5 +250,6 @@ encodedString* POP3wrapper::fetchRawBody(const RecMail&mail)
240 int err = mailsession_get_message(m_folder->fld_session, mail.getNumber(), &mailmsg); 250 int err = mailsession_get_message(m_folder->fld_session, mail.getNumber(), &mailmsg);
241 err = mailmessage_fetch(mailmsg,&target,&length); 251 err = mailmessage_fetch(mailmsg,&target,&length);
242 if (mailmsg) mailmessage_free(mailmsg); 252 if (mailmsg)
253 mailmessage_free(mailmsg);
243 if (target) { 254 if (target) {
244 res = new encodedString(target,length); 255 res = new encodedString(target,length);
@@ -247,11 +258,9 @@ encodedString* POP3wrapper::fetchRawBody(const RecMail&mail)
247} 258}
248 259
249const QString&POP3wrapper::getType()const 260const QString&POP3wrapper::getType()const {
250{
251 return account->getType(); 261 return account->getType();
252} 262}
253 263
254const QString&POP3wrapper::getName()const 264const QString&POP3wrapper::getName()const {
255{
256 return account->getAccountName(); 265 return account->getAccountName();
257} 266}
diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp
index 02a80a3..83e51e3 100644
--- a/noncore/net/mail/libmailwrapper/settings.cpp
+++ b/noncore/net/mail/libmailwrapper/settings.cpp
@@ -109,4 +109,5 @@ Account::Account()
109 type = "changeMe"; 109 type = "changeMe";
110 ssl = false; 110 ssl = false;
111 connectionType = 1;
111} 112}
112 113
@@ -123,4 +124,5 @@ IMAPaccount::IMAPaccount()
123 accountName = "New IMAP Account"; 124 accountName = "New IMAP Account";
124 ssl = false; 125 ssl = false;
126 connectionType = 1;
125 type = "IMAP"; 127 type = "IMAP";
126 port = IMAP_PORT; 128 port = IMAP_PORT;
@@ -133,4 +135,5 @@ IMAPaccount::IMAPaccount( QString filename )
133 accountName = "New IMAP Account"; 135 accountName = "New IMAP Account";
134 ssl = false; 136 ssl = false;
137 connectionType = 1;
135 type = "IMAP"; 138 type = "IMAP";
136 port = IMAP_PORT; 139 port = IMAP_PORT;
@@ -204,4 +207,5 @@ POP3account::POP3account()
204 accountName = "New POP3 Account"; 207 accountName = "New POP3 Account";
205 ssl = false; 208 ssl = false;
209 connectionType = 1;
206 type = "POP3"; 210 type = "POP3";
207 port = POP3_PORT; 211 port = POP3_PORT;
@@ -214,4 +218,5 @@ POP3account::POP3account( QString filename )
214 accountName = "New POP3 Account"; 218 accountName = "New POP3 Account";
215 ssl = false; 219 ssl = false;
220 connectionType = 1;
216 type = "POP3"; 221 type = "POP3";
217 port = POP3_PORT; 222 port = POP3_PORT;
@@ -241,4 +246,5 @@ void POP3account::read()
241 port = conf->readEntry( "Port" ); 246 port = conf->readEntry( "Port" );
242 ssl = conf->readBoolEntry( "SSL" ); 247 ssl = conf->readBoolEntry( "SSL" );
248 connectionType = conf->readNumEntry( "ConnectionType" );
243 user = conf->readEntry( "User" ); 249 user = conf->readEntry( "User" );
244 password = conf->readEntryCrypt( "Password" ); 250 password = conf->readEntryCrypt( "Password" );
@@ -258,4 +264,5 @@ void POP3account::save()
258 conf->writeEntry( "Port", port ); 264 conf->writeEntry( "Port", port );
259 conf->writeEntry( "SSL", ssl ); 265 conf->writeEntry( "SSL", ssl );
266 conf->writeEntry( "ConnectionType", connectionType );
260 conf->writeEntry( "User", user ); 267 conf->writeEntry( "User", user );
261 conf->writeEntryCrypt( "Password", password ); 268 conf->writeEntryCrypt( "Password", password );
diff --git a/noncore/net/mail/libmailwrapper/settings.h b/noncore/net/mail/libmailwrapper/settings.h
index 2104997..8d7df92 100644
--- a/noncore/net/mail/libmailwrapper/settings.h
+++ b/noncore/net/mail/libmailwrapper/settings.h
@@ -32,4 +32,8 @@ public:
32 bool getSSL() { return ssl; } 32 bool getSSL() { return ssl; }
33 33
34 void setConnectionType( int x ) { connectionType = x; }
35 int ConnectionType() { return connectionType; }
36
37
34 void setOffline(bool b) {offline = b;} 38 void setOffline(bool b) {offline = b;}
35 bool getOffline()const{return offline;} 39 bool getOffline()const{return offline;}
@@ -42,4 +46,5 @@ protected:
42 QString accountName, type, server, port, user, password; 46 QString accountName, type, server, port, user, password;
43 bool ssl; 47 bool ssl;
48 int connectionType;
44 bool offline; 49 bool offline;
45}; 50};