summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/nntpwrapper.cpp15
-rw-r--r--noncore/net/mail/libmailwrapper/nntpwrapper.h2
-rw-r--r--noncore/net/mail/libmailwrapper/settings.cpp1
3 files changed, 11 insertions, 7 deletions
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
index ecdf848..798879d 100644
--- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
@@ -67,72 +67,72 @@ RecBody NNTPwrapper::fetchBody( const RecMail &mail ) {
67 msg_cache.open(IO_ReadOnly); 67 msg_cache.open(IO_ReadOnly);
68 message = new char[4096]; 68 message = new char[4096];
69 memset(message,0,4096); 69 memset(message,0,4096);
70 while (msg_cache.readBlock(message,4095)>0) { 70 while (msg_cache.readBlock(message,4095)>0) {
71 msg+=message; 71 msg+=message;
72 memset(message,0,4096); 72 memset(message,0,4096);
73 } 73 }
74 delete message; 74 delete message;
75 message = (char*)malloc(msg.length()+1*sizeof(char)); 75 message = (char*)malloc(msg.length()+1*sizeof(char));
76 memset(message,0,msg.length()+1); 76 memset(message,0,msg.length()+1);
77 memcpy(message,msg.latin1(),msg.length()); 77 memcpy(message,msg.latin1(),msg.length());
78 /* transform to libetpan stuff */ 78 /* transform to libetpan stuff */
79 mailmsg = mailmessage_new(); 79 mailmsg = mailmessage_new();
80 mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); 80 mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message));
81 generic_message_t * msg_data; 81 generic_message_t * msg_data;
82 msg_data = (generic_message_t *)mailmsg->msg_data; 82 msg_data = (generic_message_t *)mailmsg->msg_data;
83 msg_data->msg_fetched = 1; 83 msg_data->msg_fetched = 1;
84 msg_data->msg_message = message; 84 msg_data->msg_message = message;
85 msg_data->msg_length = strlen(message); 85 msg_data->msg_length = strlen(message);
86 } 86 }
87 body = parseMail(mailmsg); 87 body = parseMail(mailmsg);
88 88
89 /* clean up */ 89 /* clean up */
90 if (mailmsg) 90 if (mailmsg)
91 mailmessage_free(mailmsg); 91 mailmessage_free(mailmsg);
92 if (message) 92 if (message)
93 free(message); 93 free(message);
94 94
95 return body; 95 return body;
96} 96}
97 97
98 98
99void NNTPwrapper::listMessages(const QString &, QList<RecMail> &target ) 99void NNTPwrapper::listMessages(const QString & which, QList<RecMail> &target )
100{ 100{
101 login(); 101 login();
102 if (!m_nntp) 102 if (!m_nntp)
103 return; 103 return;
104 uint32_t res_messages,res_recent,res_unseen; 104 uint32_t res_messages,res_recent,res_unseen;
105 mailsession_status_folder(m_nntp->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); 105 mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen);
106 parseList(target,m_nntp->sto_session,"INBOX"); 106 parseList(target,m_nntp->sto_session,which);
107} 107}
108 108
109void NNTPwrapper::login() 109void NNTPwrapper::login()
110{ 110{
111 if (account->getOffline()) 111 if (account->getOffline())
112 return; 112 return;
113 /* we'll hold the line */ 113 /* we'll hold the line */
114 if ( m_nntp != NULL ) 114 if ( m_nntp != NULL )
115 return; 115 return;
116 116
117 const char *server, *user, *pass; 117 const char *server, *user, *pass;
118 QString User,Pass; 118 QString User,Pass;
119 uint16_t port; 119 uint16_t port;
120 int err = NEWSNNTP_NO_ERROR; 120 int err = NEWSNNTP_NO_ERROR;
121 121
122 server = account->getServer().latin1(); 122 server = account->getServer().latin1();
123 port = account->getPort().toUInt(); 123 port = account->getPort().toUInt();
124 124
125 user = pass = 0; 125 user = pass = 0;
126 126
127 if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { 127 if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) {
128 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); 128 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
129 login.show(); 129 login.show();
130 if ( QDialog::Accepted == login.exec() ) { 130 if ( QDialog::Accepted == login.exec() ) {
131 // ok 131 // ok
132 User = login.getUser().latin1(); 132 User = login.getUser().latin1();
133 Pass = login.getPassword().latin1(); 133 Pass = login.getPassword().latin1();
134 } else { 134 } else {
135 // cancel 135 // cancel
136 qDebug( "NNTP: Login canceled" ); 136 qDebug( "NNTP: Login canceled" );
137 return; 137 return;
138 } 138 }
@@ -163,66 +163,71 @@ void NNTPwrapper::login()
163 } else if ( conntypeset == 0 ) { 163 } else if ( conntypeset == 0 ) {
164 conntype = CONNECTION_TYPE_TRY_STARTTLS; 164 conntype = CONNECTION_TYPE_TRY_STARTTLS;
165 } 165 }
166 166
167 nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, 167 nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN,
168 (char*)user,(char*)pass,0,0,0); 168 (char*)user,(char*)pass,0,0,0);
169 169
170 err = mailstorage_connect( m_nntp ); 170 err = mailstorage_connect( m_nntp );
171 171
172 if (err != NEWSNNTP_NO_ERROR) { 172 if (err != NEWSNNTP_NO_ERROR) {
173 qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); 173 qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) );
174 // Global::statusMessage(tr("Error initializing folder")); 174 // Global::statusMessage(tr("Error initializing folder"));
175 mailstorage_free(m_nntp); 175 mailstorage_free(m_nntp);
176 m_nntp = 0; 176 m_nntp = 0;
177 177
178 } 178 }
179 179
180} 180}
181 181
182void NNTPwrapper::logout() 182void NNTPwrapper::logout()
183{ 183{
184 int err = NEWSNNTP_NO_ERROR; 184 int err = NEWSNNTP_NO_ERROR;
185 if ( m_nntp == NULL ) 185 if ( m_nntp == NULL )
186 return; 186 return;
187 mailstorage_free(m_nntp); 187 mailstorage_free(m_nntp);
188 m_nntp = 0; 188 m_nntp = 0;
189} 189}
190 190
191QList<Folder>* NNTPwrapper::listFolders() { 191QList<Folder>* NNTPwrapper::listFolders() {
192 192
193 QList<Folder> * folders = new QList<Folder>(); 193 QList<Folder> * folders = new QList<Folder>();
194 folders->setAutoDelete( false ); 194 folders->setAutoDelete( false );
195 195 QStringList groups;
196// folders->append(inb); 196 if (account) {
197 groups = account->getGroups();
198 }
199 for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) {
200 folders->append(new Folder((*it),"."));
201 }
197 return folders; 202 return folders;
198} 203}
199 204
200 clist * NNTPwrapper::listAllNewsgroups() { 205 clist * NNTPwrapper::listAllNewsgroups() {
201 login(); 206 login();
202 clist *result = 0; 207 clist *result = 0;
203 clistcell *current; 208 clistcell *current;
204 newsnntp_group_description *list; 209 newsnntp_group_description *list;
205 if ( m_nntp ) { 210 if ( m_nntp ) {
206 mailsession * session = m_nntp->sto_session; 211 mailsession * session = m_nntp->sto_session;
207 newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; 212 newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session;
208 int err = newsnntp_list_newsgroups(news, NULL, &result); 213 int err = newsnntp_list_newsgroups(news, NULL, &result);
209 214
210 if ( err == NEWSNNTP_NO_ERROR ) { 215 if ( err == NEWSNNTP_NO_ERROR ) {
211 return result; 216 return result;
212 } 217 }
213 } 218 }
214} 219}
215 220
216void NNTPwrapper::answeredMail(const RecMail&) {} 221void NNTPwrapper::answeredMail(const RecMail&) {}
217 222
218void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) { 223void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) {
219 login(); 224 login();
220 target_stat.message_count = 0; 225 target_stat.message_count = 0;
221 target_stat.message_unseen = 0; 226 target_stat.message_unseen = 0;
222 target_stat.message_recent = 0; 227 target_stat.message_recent = 0;
223 if (!m_nntp) 228 if (!m_nntp)
224 return; 229 return;
225 int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count, 230 int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count,
226 &target_stat.message_recent,&target_stat.message_unseen); 231 &target_stat.message_recent,&target_stat.message_unseen);
227} 232}
228 233
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.h b/noncore/net/mail/libmailwrapper/nntpwrapper.h
index e4d4a37..e8e2cf4 100644
--- a/noncore/net/mail/libmailwrapper/nntpwrapper.h
+++ b/noncore/net/mail/libmailwrapper/nntpwrapper.h
@@ -1,48 +1,48 @@
1#ifndef __NNTPWRAPPER 1#ifndef __NNTPWRAPPER
2#define __NNTPWRAPPER 2#define __NNTPWRAPPER
3 3
4#include "mailwrapper.h" 4#include "mailwrapper.h"
5#include "genericwrapper.h" 5#include "genericwrapper.h"
6#include <qstring.h> 6#include <qstring.h>
7#include <libetpan/clist.h> 7#include <libetpan/clist.h>
8 8
9class encodedString; 9class encodedString;
10struct mailstorage; 10struct mailstorage;
11struct mailfolder; 11struct mailfolder;
12 12
13class NNTPwrapper : public Genericwrapper 13class NNTPwrapper : public Genericwrapper
14{ 14{
15 15
16 Q_OBJECT 16 Q_OBJECT
17 17
18public: 18public:
19 NNTPwrapper( NNTPaccount *a ); 19 NNTPwrapper( NNTPaccount *a );
20 virtual ~NNTPwrapper(); 20 virtual ~NNTPwrapper();
21 21
22 /* mailbox will be ignored */ 22 /* mailbox will be ignored */
23 virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); 23 virtual void listMessages(const QString & mailbox, QList<RecMail> &target );
24 /* should only get the subscribed one */ 24 /* should only get the subscribed one */
25 virtual QList<Folder>* listFolders(); 25 virtual QList<Folder>* listFolders();
26 /* mailbox will be ignored */ 26 /* mailbox will be ignored */
27 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); 27 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
28 clist * listAllNewsgroups(); 28 clist * listAllNewsgroups();
29 virtual void deleteMail(const RecMail&mail); 29 virtual void deleteMail(const RecMail&mail);
30 virtual void answeredMail(const RecMail&mail); 30 virtual void answeredMail(const RecMail&mail);
31 virtual int deleteAllMail(const Folder*); 31 virtual int deleteAllMail(const Folder*);
32 32
33 virtual RecBody fetchBody( const RecMail &mail ); 33 virtual RecBody fetchBody( const RecMail &mail );
34 virtual encodedString* fetchRawBody(const RecMail&mail); 34 virtual encodedString* fetchRawBody(const RecMail&mail);
35 virtual void logout(); 35 virtual void logout();
36 virtual const QString&getType()const; 36 virtual const QString&getType()const;
37 virtual const QString&getName()const; 37 virtual const QString&getName()const;
38 static void nntp_progress( size_t current, size_t maximum ); 38 static void nntp_progress( size_t current, size_t maximum );
39 39
40protected: 40protected:
41 void login(); 41 void login();
42 NNTPaccount *account; 42 NNTPaccount *account;
43 mailstorage* m_nntp; 43 mailstorage* m_nntp;
44 44
45 45
46}; 46};
47 47
48#endif 48#endif
diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp
index f64c17d..0d34fd5 100644
--- a/noncore/net/mail/libmailwrapper/settings.cpp
+++ b/noncore/net/mail/libmailwrapper/settings.cpp
@@ -409,33 +409,32 @@ void NNTPaccount::read()
409 ssl = conf->readBoolEntry( "SSL" ); 409 ssl = conf->readBoolEntry( "SSL" );
410 login = conf->readBoolEntry( "Login" ); 410 login = conf->readBoolEntry( "Login" );
411 user = conf->readEntry( "User" ); 411 user = conf->readEntry( "User" );
412 password = conf->readEntryCrypt( "Password" ); 412 password = conf->readEntryCrypt( "Password" );
413 subscribedGroups = conf->readListEntry( "Subscribed", ',' ); 413 subscribedGroups = conf->readListEntry( "Subscribed", ',' );
414 delete conf; 414 delete conf;
415} 415}
416 416
417void NNTPaccount::save() 417void NNTPaccount::save()
418{ 418{
419 qDebug( "saving " + getFileName() ); 419 qDebug( "saving " + getFileName() );
420 Settings::checkDirectory(); 420 Settings::checkDirectory();
421 421
422 Config *conf = new Config( getFileName(), Config::File ); 422 Config *conf = new Config( getFileName(), Config::File );
423 conf->setGroup( "NNTP Account" ); 423 conf->setGroup( "NNTP Account" );
424 conf->writeEntry( "Account", accountName ); 424 conf->writeEntry( "Account", accountName );
425 conf->writeEntry( "Server", server ); 425 conf->writeEntry( "Server", server );
426 conf->writeEntry( "Port", port ); 426 conf->writeEntry( "Port", port );
427 conf->writeEntry( "SSL", ssl ); 427 conf->writeEntry( "SSL", ssl );
428 conf->writeEntry( "Login", login ); 428 conf->writeEntry( "Login", login );
429 conf->writeEntry( "User", user ); 429 conf->writeEntry( "User", user );
430 conf->writeEntryCrypt( "Password", password ); 430 conf->writeEntryCrypt( "Password", password );
431 conf->writeEntry( "Subscribed" , subscribedGroups, ',' ); 431 conf->writeEntry( "Subscribed" , subscribedGroups, ',' );
432 conf->write(); 432 conf->write();
433 delete conf; 433 delete conf;
434} 434}
435 435
436 436
437QString NNTPaccount::getFileName() 437QString NNTPaccount::getFileName()
438{ 438{
439 return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file; 439 return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file;
440} 440}
441