author | alwin <alwin> | 2004-03-05 13:15:15 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-05 13:15:15 (UTC) |
commit | 4a18103940564be8585af8121203561e16f0a32c (patch) (unidiff) | |
tree | a3abb3b7b80674ddb956847e2ae7e1b42fa78301 | |
parent | 5af6bb27d2ba6a1d00fd0a6df0550d02164f87e6 (diff) | |
download | opie-4a18103940564be8585af8121203561e16f0a32c.zip opie-4a18103940564be8585af8121203561e16f0a32c.tar.gz opie-4a18103940564be8585af8121203561e16f0a32c.tar.bz2 |
could hold pointer to destructed content
connection problem fixed as quick hack, must done better or real.
-rw-r--r-- | noncore/net/mail/libmailwrapper/nntpwrapper.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp index c68964d..54e0ed4 100644 --- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp | |||
@@ -72,136 +72,146 @@ RecBody NNTPwrapper::fetchBody( const RecMail &mail ) { | |||
72 | while (msg_cache.readBlock(message,4095)>0) { | 72 | while (msg_cache.readBlock(message,4095)>0) { |
73 | msg+=message; | 73 | msg+=message; |
74 | memset(message,0,4096); | 74 | memset(message,0,4096); |
75 | } | 75 | } |
76 | delete message; | 76 | delete message; |
77 | message = (char*)malloc(msg.length()+1*sizeof(char)); | 77 | message = (char*)malloc(msg.length()+1*sizeof(char)); |
78 | memset(message,0,msg.length()+1); | 78 | memset(message,0,msg.length()+1); |
79 | memcpy(message,msg.latin1(),msg.length()); | 79 | memcpy(message,msg.latin1(),msg.length()); |
80 | /* transform to libetpan stuff */ | 80 | /* transform to libetpan stuff */ |
81 | mailmsg = mailmessage_new(); | 81 | mailmsg = mailmessage_new(); |
82 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); | 82 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); |
83 | generic_message_t * msg_data; | 83 | generic_message_t * msg_data; |
84 | msg_data = (generic_message_t *)mailmsg->msg_data; | 84 | msg_data = (generic_message_t *)mailmsg->msg_data; |
85 | msg_data->msg_fetched = 1; | 85 | msg_data->msg_fetched = 1; |
86 | msg_data->msg_message = message; | 86 | msg_data->msg_message = message; |
87 | msg_data->msg_length = strlen(message); | 87 | msg_data->msg_length = strlen(message); |
88 | } | 88 | } |
89 | body = parseMail(mailmsg); | 89 | body = parseMail(mailmsg); |
90 | 90 | ||
91 | /* clean up */ | 91 | /* clean up */ |
92 | if (mailmsg) | 92 | if (mailmsg) |
93 | mailmessage_free(mailmsg); | 93 | mailmessage_free(mailmsg); |
94 | if (message) | 94 | if (message) |
95 | free(message); | 95 | free(message); |
96 | 96 | ||
97 | return body; | 97 | return body; |
98 | } | 98 | } |
99 | 99 | ||
100 | 100 | ||
101 | void NNTPwrapper::listMessages(const QString &, QList<RecMail> &target ) | 101 | void NNTPwrapper::listMessages(const QString &, QList<RecMail> &target ) |
102 | { | 102 | { |
103 | login(); | 103 | login(); |
104 | if (!m_nntp) | 104 | if (!m_nntp) |
105 | return; | 105 | return; |
106 | uint32_t res_messages,res_recent,res_unseen; | 106 | uint32_t res_messages,res_recent,res_unseen; |
107 | mailsession_status_folder(m_nntp->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); | 107 | mailsession_status_folder(m_nntp->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); |
108 | parseList(target,m_nntp->sto_session,"INBOX"); | 108 | parseList(target,m_nntp->sto_session,"INBOX"); |
109 | } | 109 | } |
110 | 110 | ||
111 | void NNTPwrapper::login() | 111 | void NNTPwrapper::login() |
112 | { | 112 | { |
113 | if (account->getOffline()) | 113 | if (account->getOffline()) |
114 | return; | 114 | return; |
115 | /* we'll hold the line */ | 115 | /* we'll hold the line */ |
116 | if ( m_nntp != NULL ) | 116 | if ( m_nntp != NULL ) |
117 | return; | 117 | return; |
118 | 118 | ||
119 | const char *server, *user, *pass; | 119 | const char *server, *user, *pass; |
120 | QString User,Pass; | ||
120 | uint16_t port; | 121 | uint16_t port; |
121 | int err = NEWSNNTP_NO_ERROR; | 122 | int err = NEWSNNTP_NO_ERROR; |
122 | 123 | ||
123 | server = account->getServer().latin1(); | 124 | server = account->getServer().latin1(); |
124 | port = account->getPort().toUInt(); | 125 | port = account->getPort().toUInt(); |
125 | 126 | ||
127 | user = pass = 0; | ||
128 | |||
126 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 129 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
127 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 130 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
128 | login.show(); | 131 | login.show(); |
129 | if ( QDialog::Accepted == login.exec() ) { | 132 | if ( QDialog::Accepted == login.exec() ) { |
130 | // ok | 133 | // ok |
131 | user = login.getUser().latin1(); | 134 | User = login.getUser().latin1(); |
132 | pass = login.getPassword().latin1(); | 135 | Pass = login.getPassword().latin1(); |
133 | } else { | 136 | } else { |
134 | // cancel | 137 | // cancel |
135 | qDebug( "NNTP: Login canceled" ); | 138 | qDebug( "NNTP: Login canceled" ); |
136 | return; | 139 | return; |
137 | } | 140 | } |
138 | } else { | 141 | } else { |
139 | user = account->getUser().latin1(); | 142 | User = account->getUser().latin1(); |
140 | pass = account->getPassword().latin1(); | 143 | Pass = account->getPassword().latin1(); |
141 | } | 144 | } |
142 | 145 | ||
146 | if (User.isEmpty()) { | ||
147 | user=0; | ||
148 | pass = 0; | ||
149 | } else { | ||
150 | user=User.latin1(); | ||
151 | pass=Pass.latin1(); | ||
152 | } | ||
143 | // bool ssl = account->getSSL(); | 153 | // bool ssl = account->getSSL(); |
144 | 154 | ||
145 | m_nntp=mailstorage_new(NULL); | 155 | m_nntp=mailstorage_new(NULL); |
146 | 156 | ||
147 | int conntypeset = account->ConnectionType(); | 157 | int conntypeset = account->ConnectionType(); |
148 | int conntype = 0; | 158 | int conntype = 0; |
149 | if ( conntypeset == 3 ) { | 159 | if ( conntypeset == 3 ) { |
150 | conntype = CONNECTION_TYPE_COMMAND; | 160 | conntype = CONNECTION_TYPE_COMMAND; |
151 | } else if ( conntypeset == 2 ) { | 161 | } else if ( conntypeset == 2 ) { |
152 | conntype = CONNECTION_TYPE_TLS; | 162 | conntype = CONNECTION_TYPE_TLS; |
153 | } else if ( conntypeset == 1 ) { | 163 | } else if ( conntypeset == 1 ) { |
154 | conntype = CONNECTION_TYPE_STARTTLS; | 164 | conntype = CONNECTION_TYPE_STARTTLS; |
155 | } else if ( conntypeset == 0 ) { | 165 | } else if ( conntypeset == 0 ) { |
156 | conntype = CONNECTION_TYPE_TRY_STARTTLS; | 166 | conntype = CONNECTION_TYPE_TRY_STARTTLS; |
157 | } | 167 | } |
158 | 168 | ||
159 | nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, conntype, NNTP_AUTH_TYPE_PLAIN, | 169 | nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, |
160 | (char*)user,(char*)pass,0,0,0); | 170 | (char*)user,(char*)pass,0,0,0); |
161 | 171 | ||
162 | err = mailstorage_connect( m_nntp ); | 172 | err = mailstorage_connect( m_nntp ); |
163 | 173 | ||
164 | if (err != NEWSNNTP_NO_ERROR) { | 174 | if (err != NEWSNNTP_NO_ERROR) { |
165 | qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); | 175 | qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); |
166 | // Global::statusMessage(tr("Error initializing folder")); | 176 | // Global::statusMessage(tr("Error initializing folder")); |
167 | mailstorage_free(m_nntp); | 177 | mailstorage_free(m_nntp); |
168 | m_nntp = 0; | 178 | m_nntp = 0; |
169 | 179 | ||
170 | } | 180 | } |
171 | 181 | ||
172 | } | 182 | } |
173 | 183 | ||
174 | void NNTPwrapper::logout() | 184 | void NNTPwrapper::logout() |
175 | { | 185 | { |
176 | int err = NEWSNNTP_NO_ERROR; | 186 | int err = NEWSNNTP_NO_ERROR; |
177 | if ( m_nntp == NULL ) | 187 | if ( m_nntp == NULL ) |
178 | return; | 188 | return; |
179 | mailstorage_free(m_nntp); | 189 | mailstorage_free(m_nntp); |
180 | m_nntp = 0; | 190 | m_nntp = 0; |
181 | } | 191 | } |
182 | 192 | ||
183 | QList<Folder>* NNTPwrapper::listFolders() { | 193 | QList<Folder>* NNTPwrapper::listFolders() { |
184 | 194 | ||
185 | 195 | ||
186 | 196 | ||
187 | 197 | ||
188 | QList<Folder> * folders = new QList<Folder>(); | 198 | QList<Folder> * folders = new QList<Folder>(); |
189 | folders->setAutoDelete( false ); | 199 | folders->setAutoDelete( false ); |
190 | clist *result = 0; | 200 | clist *result = 0; |
191 | clistcell *current; | 201 | clistcell *current; |
192 | newsnntp_group_description *list; | 202 | newsnntp_group_description *list; |
193 | 203 | ||
194 | login(); | 204 | login(); |
195 | if ( m_nntp ) { | 205 | if ( m_nntp ) { |
196 | mailsession * session = m_nntp->sto_session; | 206 | mailsession * session = m_nntp->sto_session; |
197 | newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; | 207 | newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; |
198 | int err = newsnntp_list_newsgroups(news, NULL, &result); | 208 | int err = newsnntp_list_newsgroups(news, NULL, &result); |
199 | 209 | ||
200 | if ( err == NEWSNNTP_NO_ERROR ) { | 210 | if ( err == NEWSNNTP_NO_ERROR ) { |
201 | current = result->first; | 211 | current = result->first; |
202 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { | 212 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { |
203 | list = ( newsnntp_group_description* ) current->data; | 213 | list = ( newsnntp_group_description* ) current->data; |
204 | qDebug( list->grp_name ); | 214 | qDebug( list->grp_name ); |
205 | } | 215 | } |
206 | // Folder*inb=new Folder("INBOX","/"); | 216 | // Folder*inb=new Folder("INBOX","/"); |
207 | } | 217 | } |