Diffstat (limited to 'kmicromail/libmailwrapper/nntpwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/nntpwrapper.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/kmicromail/libmailwrapper/nntpwrapper.cpp b/kmicromail/libmailwrapper/nntpwrapper.cpp index daa128e..f5d7f16 100644 --- a/kmicromail/libmailwrapper/nntpwrapper.cpp +++ b/kmicromail/libmailwrapper/nntpwrapper.cpp | |||
@@ -1,24 +1,25 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | ||
1 | #include "nntpwrapper.h" | 2 | #include "nntpwrapper.h" |
2 | #include "logindialog.h" | 3 | #include "logindialog.h" |
3 | #include "mailtypes.h" | 4 | #include "mailtypes.h" |
4 | 5 | ||
5 | #include <qfile.h> | 6 | #include <qfile.h> |
6 | 7 | ||
7 | #include <stdlib.h> | 8 | #include <stdlib.h> |
8 | 9 | ||
9 | #include <libetpan/libetpan.h> | 10 | #include <libetpan/libetpan.h> |
10 | 11 | ||
11 | 12 | ||
12 | 13 | ||
13 | #define HARD_MSG_SIZE_LIMIT 5242880 | 14 | #define HARD_MSG_SIZE_LIMIT 5242880 |
14 | 15 | ||
15 | using namespace Opie::Core; | 16 | using namespace Opie::Core; |
16 | NNTPwrapper::NNTPwrapper( NNTPaccount *a ) | 17 | NNTPwrapper::NNTPwrapper( NNTPaccount *a ) |
17 | : Genericwrapper() { | 18 | : Genericwrapper() { |
18 | account = a; | 19 | account = a; |
19 | m_nntp = NULL; | 20 | m_nntp = NULL; |
20 | msgTempName = a->getFileName()+"_msg_cache"; | 21 | msgTempName = a->getFileName()+"_msg_cache"; |
21 | last_msg_id = 0; | 22 | last_msg_id = 0; |
22 | } | 23 | } |
23 | 24 | ||
24 | NNTPwrapper::~NNTPwrapper() { | 25 | NNTPwrapper::~NNTPwrapper() { |
@@ -77,56 +78,56 @@ RecBodyP NNTPwrapper::fetchBody( const RecMailP &mail ) { | |||
77 | message = (char*)malloc(msg.length()+1*sizeof(char)); | 78 | message = (char*)malloc(msg.length()+1*sizeof(char)); |
78 | memset(message,0,msg.length()+1); | 79 | memset(message,0,msg.length()+1); |
79 | memcpy(message,msg.latin1(),msg.length()); | 80 | memcpy(message,msg.latin1(),msg.length()); |
80 | /* transform to libetpan stuff */ | 81 | /* transform to libetpan stuff */ |
81 | mailmsg = mailmessage_new(); | 82 | mailmsg = mailmessage_new(); |
82 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); | 83 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); |
83 | generic_message_t * msg_data; | 84 | generic_message_t * msg_data; |
84 | msg_data = (generic_message_t *)mailmsg->msg_data; | 85 | msg_data = (generic_message_t *)mailmsg->msg_data; |
85 | msg_data->msg_fetched = 1; | 86 | msg_data->msg_fetched = 1; |
86 | msg_data->msg_message = message; | 87 | msg_data->msg_message = message; |
87 | msg_data->msg_length = strlen(message); | 88 | msg_data->msg_length = strlen(message); |
88 | } | 89 | } |
89 | body = parseMail(mailmsg); | 90 | body = parseMail(mailmsg); |
90 | 91 | ||
91 | /* clean up */ | 92 | /* clean up */ |
92 | if (mailmsg) | 93 | if (mailmsg) |
93 | mailmessage_free(mailmsg); | 94 | mailmessage_free(mailmsg); |
94 | if (message) | 95 | if (message) |
95 | free(message); | 96 | free(message); |
96 | 97 | ||
97 | return body; | 98 | return body; |
98 | } | 99 | } |
99 | 100 | ||
100 | 101 | ||
101 | void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) | 102 | void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb) |
102 | { | 103 | { |
103 | login(); | 104 | login(); |
104 | if (!m_nntp) | 105 | if (!m_nntp) |
105 | return; | 106 | return; |
106 | uint32_t res_messages,res_recent,res_unseen; | 107 | uint32_t res_messages,res_recent,res_unseen; |
107 | mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); | 108 | mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); |
108 | parseList(target,m_nntp->sto_session,which,true); | 109 | parseList(target,m_nntp->sto_session,which,true, maxSizeInKb); |
109 | } | 110 | } |
110 | 111 | ||
111 | void NNTPwrapper::login() | 112 | void NNTPwrapper::login() |
112 | { | 113 | { |
113 | if (account->getOffline()) | 114 | if (account->getOffline()) |
114 | return; | 115 | return; |
115 | /* we'll hold the line */ | 116 | /* we'll hold the line */ |
116 | if ( m_nntp != NULL ) | 117 | if ( m_nntp != NULL ) |
117 | return; | 118 | return; |
118 | 119 | ||
119 | const char *server, *user, *pass; | 120 | const char *server, *user, *pass; |
120 | QString User,Pass; | 121 | QString User,Pass; |
121 | uint16_t port; | 122 | uint16_t port; |
122 | int err = NEWSNNTP_NO_ERROR; | 123 | int err = NEWSNNTP_NO_ERROR; |
123 | 124 | ||
124 | server = account->getServer().latin1(); | 125 | server = account->getServer().latin1(); |
125 | port = account->getPort().toUInt(); | 126 | port = account->getPort().toUInt(); |
126 | 127 | ||
127 | user = pass = 0; | 128 | user = pass = 0; |
128 | 129 | ||
129 | if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { | 130 | if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { |
130 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 131 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
131 | login.show(); | 132 | login.show(); |
132 | if ( QDialog::Accepted == login.exec() ) { | 133 | if ( QDialog::Accepted == login.exec() ) { |