author | harlekin <harlekin> | 2004-03-06 00:44:40 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2004-03-06 00:44:40 (UTC) |
commit | 4aea85aa2e205040da3ebdf50debde8b296e3c61 (patch) (unidiff) | |
tree | 424ee07b5886d70d45cc5d3b5c9ed6d32fd06d5f | |
parent | 7b10be8e0ed88afe9e8964e6b5f1fe449cee3609 (diff) | |
download | opie-4aea85aa2e205040da3ebdf50debde8b296e3c61.zip opie-4aea85aa2e205040da3ebdf50debde8b296e3c61.tar.gz opie-4aea85aa2e205040da3ebdf50debde8b296e3c61.tar.bz2 |
ups, works now .-)
-rw-r--r-- | noncore/net/mail/editaccounts.cpp | 11 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/nntpwrapper.cpp | 2 |
2 files changed, 8 insertions, 5 deletions
diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp index 215380d..b8aad11 100644 --- a/noncore/net/mail/editaccounts.cpp +++ b/noncore/net/mail/editaccounts.cpp | |||
@@ -1,575 +1,578 @@ | |||
1 | 1 | ||
2 | #include "defines.h" | 2 | #include "defines.h" |
3 | #include "editaccounts.h" | 3 | #include "editaccounts.h" |
4 | 4 | ||
5 | /* OPIE */ | 5 | /* OPIE */ |
6 | #include <qpe/qpeapplication.h> | 6 | #include <qpe/qpeapplication.h> |
7 | 7 | ||
8 | /* QT */ | 8 | /* QT */ |
9 | #include <qt.h> | 9 | #include <qt.h> |
10 | #include <qstringlist.h> | 10 | #include <qstringlist.h> |
11 | 11 | ||
12 | #include <libmailwrapper/nntpwrapper.h> | 12 | #include <libmailwrapper/nntpwrapper.h> |
13 | 13 | ||
14 | #include <libetpan/nntpdriver.h> | 14 | #include <libetpan/nntpdriver.h> |
15 | 15 | ||
16 | AccountListItem::AccountListItem( QListView *parent, Account *a) | 16 | AccountListItem::AccountListItem( QListView *parent, Account *a) |
17 | : QListViewItem( parent ) | 17 | : QListViewItem( parent ) |
18 | { | 18 | { |
19 | account = a; | 19 | account = a; |
20 | setText( 0, account->getAccountName() ); | 20 | setText( 0, account->getAccountName() ); |
21 | setText( 1, account->getType() ); | 21 | setText( 1, account->getType() ); |
22 | } | 22 | } |
23 | 23 | ||
24 | EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) | 24 | EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) |
25 | : EditAccountsUI( parent, name, modal, flags ) | 25 | : EditAccountsUI( parent, name, modal, flags ) |
26 | { | 26 | { |
27 | qDebug( "New Account Configuration Widget" ); | 27 | qDebug( "New Account Configuration Widget" ); |
28 | settings = s; | 28 | settings = s; |
29 | 29 | ||
30 | mailList->addColumn( tr( "Account" ) ); | 30 | mailList->addColumn( tr( "Account" ) ); |
31 | mailList->addColumn( tr( "Type" ) ); | 31 | mailList->addColumn( tr( "Type" ) ); |
32 | 32 | ||
33 | newsList->addColumn( tr( "Account" ) ); | 33 | newsList->addColumn( tr( "Account" ) ); |
34 | 34 | ||
35 | connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); | 35 | connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); |
36 | connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); | 36 | connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); |
37 | connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); | 37 | connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); |
38 | connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); | 38 | connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); |
39 | connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); | 39 | connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); |
40 | connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); | 40 | connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); |
41 | 41 | ||
42 | slotFillLists(); | 42 | slotFillLists(); |
43 | } | 43 | } |
44 | 44 | ||
45 | void EditAccounts::slotFillLists() | 45 | void EditAccounts::slotFillLists() |
46 | { | 46 | { |
47 | mailList->clear(); | 47 | mailList->clear(); |
48 | newsList->clear(); | 48 | newsList->clear(); |
49 | 49 | ||
50 | QList<Account> accounts = settings->getAccounts(); | 50 | QList<Account> accounts = settings->getAccounts(); |
51 | Account *it; | 51 | Account *it; |
52 | for ( it = accounts.first(); it; it = accounts.next() ) | 52 | for ( it = accounts.first(); it; it = accounts.next() ) |
53 | { | 53 | { |
54 | if ( it->getType().compare( "NNTP" ) == 0 ) | 54 | if ( it->getType().compare( "NNTP" ) == 0 ) |
55 | { | 55 | { |
56 | (void) new AccountListItem( newsList, it ); | 56 | (void) new AccountListItem( newsList, it ); |
57 | } | 57 | } |
58 | else | 58 | else |
59 | { | 59 | { |
60 | (void) new AccountListItem( mailList, it ); | 60 | (void) new AccountListItem( mailList, it ); |
61 | } | 61 | } |
62 | } | 62 | } |
63 | } | 63 | } |
64 | 64 | ||
65 | void EditAccounts::slotNewMail() | 65 | void EditAccounts::slotNewMail() |
66 | { | 66 | { |
67 | qDebug( "New Mail Account" ); | 67 | qDebug( "New Mail Account" ); |
68 | QString *selection = new QString(); | 68 | QString *selection = new QString(); |
69 | SelectMailType selType( selection, this, 0, true ); | 69 | SelectMailType selType( selection, this, 0, true ); |
70 | selType.show(); | 70 | selType.show(); |
71 | if ( QDialog::Accepted == selType.exec() ) | 71 | if ( QDialog::Accepted == selType.exec() ) |
72 | { | 72 | { |
73 | slotNewAccount( *selection ); | 73 | slotNewAccount( *selection ); |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | void EditAccounts::slotNewAccount( const QString &type ) | 77 | void EditAccounts::slotNewAccount( const QString &type ) |
78 | { | 78 | { |
79 | if ( type.compare( "IMAP" ) == 0 ) | 79 | if ( type.compare( "IMAP" ) == 0 ) |
80 | { | 80 | { |
81 | qDebug( "-> config IMAP" ); | 81 | qDebug( "-> config IMAP" ); |
82 | IMAPaccount *account = new IMAPaccount(); | 82 | IMAPaccount *account = new IMAPaccount(); |
83 | IMAPconfig imap( account, this, 0, true ); | 83 | IMAPconfig imap( account, this, 0, true ); |
84 | if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) | 84 | if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) |
85 | { | 85 | { |
86 | settings->addAccount( account ); | 86 | settings->addAccount( account ); |
87 | account->save(); | 87 | account->save(); |
88 | slotFillLists(); | 88 | slotFillLists(); |
89 | } | 89 | } |
90 | else | 90 | else |
91 | { | 91 | { |
92 | account->remove(); | 92 | account->remove(); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | else if ( type.compare( "POP3" ) == 0 ) | 95 | else if ( type.compare( "POP3" ) == 0 ) |
96 | { | 96 | { |
97 | qDebug( "-> config POP3" ); | 97 | qDebug( "-> config POP3" ); |
98 | POP3account *account = new POP3account(); | 98 | POP3account *account = new POP3account(); |
99 | POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); | 99 | POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); |
100 | if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) | 100 | if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) |
101 | { | 101 | { |
102 | settings->addAccount( account ); | 102 | settings->addAccount( account ); |
103 | account->save(); | 103 | account->save(); |
104 | slotFillLists(); | 104 | slotFillLists(); |
105 | } | 105 | } |
106 | else | 106 | else |
107 | { | 107 | { |
108 | account->remove(); | 108 | account->remove(); |
109 | } | 109 | } |
110 | } | 110 | } |
111 | else if ( type.compare( "SMTP" ) == 0 ) | 111 | else if ( type.compare( "SMTP" ) == 0 ) |
112 | { | 112 | { |
113 | qDebug( "-> config SMTP" ); | 113 | qDebug( "-> config SMTP" ); |
114 | SMTPaccount *account = new SMTPaccount(); | 114 | SMTPaccount *account = new SMTPaccount(); |
115 | SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); | 115 | SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); |
116 | if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) | 116 | if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) |
117 | { | 117 | { |
118 | settings->addAccount( account ); | 118 | settings->addAccount( account ); |
119 | account->save(); | 119 | account->save(); |
120 | slotFillLists(); | 120 | slotFillLists(); |
121 | 121 | ||
122 | } | 122 | } |
123 | else | 123 | else |
124 | { | 124 | { |
125 | account->remove(); | 125 | account->remove(); |
126 | } | 126 | } |
127 | } | 127 | } |
128 | else if ( type.compare( "NNTP" ) == 0 ) | 128 | else if ( type.compare( "NNTP" ) == 0 ) |
129 | { | 129 | { |
130 | qDebug( "-> config NNTP" ); | 130 | qDebug( "-> config NNTP" ); |
131 | NNTPaccount *account = new NNTPaccount(); | 131 | NNTPaccount *account = new NNTPaccount(); |
132 | NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); | 132 | NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); |
133 | if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) | 133 | if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) |
134 | { | 134 | { |
135 | settings->addAccount( account ); | 135 | settings->addAccount( account ); |
136 | account->save(); | 136 | account->save(); |
137 | slotFillLists(); | 137 | slotFillLists(); |
138 | } | 138 | } |
139 | else | 139 | else |
140 | { | 140 | { |
141 | account->remove(); | 141 | account->remove(); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | void EditAccounts::slotEditAccount( Account *account ) | 146 | void EditAccounts::slotEditAccount( Account *account ) |
147 | { | 147 | { |
148 | if ( account->getType().compare( "IMAP" ) == 0 ) | 148 | if ( account->getType().compare( "IMAP" ) == 0 ) |
149 | { | 149 | { |
150 | IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); | 150 | IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); |
151 | IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); | 151 | IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); |
152 | if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) | 152 | if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) |
153 | { | 153 | { |
154 | slotFillLists(); | 154 | slotFillLists(); |
155 | } | 155 | } |
156 | } | 156 | } |
157 | else if ( account->getType().compare( "POP3" ) == 0 ) | 157 | else if ( account->getType().compare( "POP3" ) == 0 ) |
158 | { | 158 | { |
159 | POP3account *pop3Acc = static_cast<POP3account *>(account); | 159 | POP3account *pop3Acc = static_cast<POP3account *>(account); |
160 | POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); | 160 | POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); |
161 | if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) | 161 | if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) |
162 | { | 162 | { |
163 | slotFillLists(); | 163 | slotFillLists(); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | else if ( account->getType().compare( "SMTP" ) == 0 ) | 166 | else if ( account->getType().compare( "SMTP" ) == 0 ) |
167 | { | 167 | { |
168 | SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); | 168 | SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); |
169 | SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); | 169 | SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); |
170 | if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) | 170 | if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) |
171 | { | 171 | { |
172 | slotFillLists(); | 172 | slotFillLists(); |
173 | } | 173 | } |
174 | } | 174 | } |
175 | else if ( account->getType().compare( "NNTP" ) == 0 ) | 175 | else if ( account->getType().compare( "NNTP" ) == 0 ) |
176 | { | 176 | { |
177 | NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); | 177 | NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); |
178 | NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); | 178 | NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); |
179 | if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) | 179 | if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) |
180 | { | 180 | { |
181 | slotFillLists(); | 181 | slotFillLists(); |
182 | } | 182 | } |
183 | } | 183 | } |
184 | } | 184 | } |
185 | 185 | ||
186 | void EditAccounts::slotDeleteAccount( Account *account ) | 186 | void EditAccounts::slotDeleteAccount( Account *account ) |
187 | { | 187 | { |
188 | if ( QMessageBox::information( this, tr( "Question" ), | 188 | if ( QMessageBox::information( this, tr( "Question" ), |
189 | tr( "<p>Do you really want to delete the selected Account?</p>" ), | 189 | tr( "<p>Do you really want to delete the selected Account?</p>" ), |
190 | tr( "Yes" ), tr( "No" ) ) == 0 ) | 190 | tr( "Yes" ), tr( "No" ) ) == 0 ) |
191 | { | 191 | { |
192 | settings->delAccount( account ); | 192 | settings->delAccount( account ); |
193 | slotFillLists(); | 193 | slotFillLists(); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | void EditAccounts::slotEditMail() | 197 | void EditAccounts::slotEditMail() |
198 | { | 198 | { |
199 | qDebug( "Edit Mail Account" ); | 199 | qDebug( "Edit Mail Account" ); |
200 | if ( !mailList->currentItem() ) | 200 | if ( !mailList->currentItem() ) |
201 | { | 201 | { |
202 | QMessageBox::information( this, tr( "Error" ), | 202 | QMessageBox::information( this, tr( "Error" ), |
203 | tr( "<p>Please select an account.</p>" ), | 203 | tr( "<p>Please select an account.</p>" ), |
204 | tr( "Ok" ) ); | 204 | tr( "Ok" ) ); |
205 | return; | 205 | return; |
206 | } | 206 | } |
207 | 207 | ||
208 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); | 208 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); |
209 | slotEditAccount( a ); | 209 | slotEditAccount( a ); |
210 | } | 210 | } |
211 | 211 | ||
212 | void EditAccounts::slotDeleteMail() | 212 | void EditAccounts::slotDeleteMail() |
213 | { | 213 | { |
214 | if ( !mailList->currentItem() ) | 214 | if ( !mailList->currentItem() ) |
215 | { | 215 | { |
216 | QMessageBox::information( this, tr( "Error" ), | 216 | QMessageBox::information( this, tr( "Error" ), |
217 | tr( "<p>Please select an account.</p>" ), | 217 | tr( "<p>Please select an account.</p>" ), |
218 | tr( "Ok" ) ); | 218 | tr( "Ok" ) ); |
219 | return; | 219 | return; |
220 | } | 220 | } |
221 | 221 | ||
222 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); | 222 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); |
223 | slotDeleteAccount( a ); | 223 | slotDeleteAccount( a ); |
224 | } | 224 | } |
225 | 225 | ||
226 | void EditAccounts::slotNewNews() | 226 | void EditAccounts::slotNewNews() |
227 | { | 227 | { |
228 | qDebug( "New News Account" ); | 228 | qDebug( "New News Account" ); |
229 | slotNewAccount( "NNTP" ); | 229 | slotNewAccount( "NNTP" ); |
230 | } | 230 | } |
231 | 231 | ||
232 | void EditAccounts::slotEditNews() | 232 | void EditAccounts::slotEditNews() |
233 | { | 233 | { |
234 | qDebug( "Edit News Account" ); | 234 | qDebug( "Edit News Account" ); |
235 | if ( !newsList->currentItem() ) | 235 | if ( !newsList->currentItem() ) |
236 | { | 236 | { |
237 | QMessageBox::information( this, tr( "Error" ), | 237 | QMessageBox::information( this, tr( "Error" ), |
238 | tr( "<p>Please select an account.</p>" ), | 238 | tr( "<p>Please select an account.</p>" ), |
239 | tr( "Ok" ) ); | 239 | tr( "Ok" ) ); |
240 | return; | 240 | return; |
241 | } | 241 | } |
242 | 242 | ||
243 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); | 243 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); |
244 | slotEditAccount( a ); | 244 | slotEditAccount( a ); |
245 | } | 245 | } |
246 | 246 | ||
247 | void EditAccounts::slotDeleteNews() | 247 | void EditAccounts::slotDeleteNews() |
248 | { | 248 | { |
249 | qDebug( "Delete News Account" ); | 249 | qDebug( "Delete News Account" ); |
250 | if ( !newsList->currentItem() ) | 250 | if ( !newsList->currentItem() ) |
251 | { | 251 | { |
252 | QMessageBox::information( this, tr( "Error" ), | 252 | QMessageBox::information( this, tr( "Error" ), |
253 | tr( "<p>Please select an account.</p>" ), | 253 | tr( "<p>Please select an account.</p>" ), |
254 | tr( "Ok" ) ); | 254 | tr( "Ok" ) ); |
255 | return; | 255 | return; |
256 | } | 256 | } |
257 | 257 | ||
258 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); | 258 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); |
259 | slotDeleteAccount( a ); | 259 | slotDeleteAccount( a ); |
260 | } | 260 | } |
261 | 261 | ||
262 | void EditAccounts::slotAdjustColumns() | 262 | void EditAccounts::slotAdjustColumns() |
263 | { | 263 | { |
264 | int currPage = configTab->currentPageIndex(); | 264 | int currPage = configTab->currentPageIndex(); |
265 | 265 | ||
266 | configTab->showPage( mailTab ); | 266 | configTab->showPage( mailTab ); |
267 | mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); | 267 | mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); |
268 | mailList->setColumnWidth( 1, 50 ); | 268 | mailList->setColumnWidth( 1, 50 ); |
269 | 269 | ||
270 | configTab->showPage( newsTab ); | 270 | configTab->showPage( newsTab ); |
271 | newsList->setColumnWidth( 0, newsList->visibleWidth() ); | 271 | newsList->setColumnWidth( 0, newsList->visibleWidth() ); |
272 | 272 | ||
273 | configTab->setCurrentPage( currPage ); | 273 | configTab->setCurrentPage( currPage ); |
274 | } | 274 | } |
275 | 275 | ||
276 | void EditAccounts::accept() | 276 | void EditAccounts::accept() |
277 | { | 277 | { |
278 | settings->saveAccounts(); | 278 | settings->saveAccounts(); |
279 | 279 | ||
280 | QDialog::accept(); | 280 | QDialog::accept(); |
281 | } | 281 | } |
282 | 282 | ||
283 | /** | 283 | /** |
284 | * SelectMailType | 284 | * SelectMailType |
285 | */ | 285 | */ |
286 | 286 | ||
287 | SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) | 287 | SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) |
288 | : SelectMailTypeUI( parent, name, modal, flags ) | 288 | : SelectMailTypeUI( parent, name, modal, flags ) |
289 | { | 289 | { |
290 | selected = selection; | 290 | selected = selection; |
291 | selected->replace( 0, selected->length(), typeBox->currentText() ); | 291 | selected->replace( 0, selected->length(), typeBox->currentText() ); |
292 | connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) ); | 292 | connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) ); |
293 | } | 293 | } |
294 | 294 | ||
295 | void SelectMailType::slotSelection( const QString &sel ) | 295 | void SelectMailType::slotSelection( const QString &sel ) |
296 | { | 296 | { |
297 | selected->replace( 0, selected->length(), sel ); | 297 | selected->replace( 0, selected->length(), sel ); |
298 | } | 298 | } |
299 | 299 | ||
300 | /** | 300 | /** |
301 | * IMAPconfig | 301 | * IMAPconfig |
302 | */ | 302 | */ |
303 | 303 | ||
304 | IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 304 | IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
305 | : IMAPconfigUI( parent, name, modal, flags ) | 305 | : IMAPconfigUI( parent, name, modal, flags ) |
306 | { | 306 | { |
307 | data = account; | 307 | data = account; |
308 | 308 | ||
309 | fillValues(); | 309 | fillValues(); |
310 | 310 | ||
311 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); | 311 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); |
312 | ComboBox1->insertItem( "Only if available", 0 ); | 312 | ComboBox1->insertItem( "Only if available", 0 ); |
313 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | 313 | ComboBox1->insertItem( "Always, Negotiated", 1 ); |
314 | ComboBox1->insertItem( "Connect on secure port", 2 ); | 314 | ComboBox1->insertItem( "Connect on secure port", 2 ); |
315 | ComboBox1->insertItem( "Run command instead", 3 ); | 315 | ComboBox1->insertItem( "Run command instead", 3 ); |
316 | CommandEdit->hide(); | 316 | CommandEdit->hide(); |
317 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 317 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
318 | } | 318 | } |
319 | 319 | ||
320 | void IMAPconfig::slotConnectionToggle( int index ) | 320 | void IMAPconfig::slotConnectionToggle( int index ) |
321 | { | 321 | { |
322 | if ( index == 2 ) | 322 | if ( index == 2 ) |
323 | { | 323 | { |
324 | portLine->setText( IMAP_SSL_PORT ); | 324 | portLine->setText( IMAP_SSL_PORT ); |
325 | } | 325 | } |
326 | else if ( index == 3 ) | 326 | else if ( index == 3 ) |
327 | { | 327 | { |
328 | portLine->setText( IMAP_PORT ); | 328 | portLine->setText( IMAP_PORT ); |
329 | CommandEdit->show(); | 329 | CommandEdit->show(); |
330 | } | 330 | } |
331 | else | 331 | else |
332 | { | 332 | { |
333 | portLine->setText( IMAP_PORT ); | 333 | portLine->setText( IMAP_PORT ); |
334 | } | 334 | } |
335 | } | 335 | } |
336 | 336 | ||
337 | void IMAPconfig::fillValues() | 337 | void IMAPconfig::fillValues() |
338 | { | 338 | { |
339 | accountLine->setText( data->getAccountName() ); | 339 | accountLine->setText( data->getAccountName() ); |
340 | serverLine->setText( data->getServer() ); | 340 | serverLine->setText( data->getServer() ); |
341 | portLine->setText( data->getPort() ); | 341 | portLine->setText( data->getPort() ); |
342 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 342 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
343 | userLine->setText( data->getUser() ); | 343 | userLine->setText( data->getUser() ); |
344 | passLine->setText( data->getPassword() ); | 344 | passLine->setText( data->getPassword() ); |
345 | prefixLine->setText(data->getPrefix()); | 345 | prefixLine->setText(data->getPrefix()); |
346 | } | 346 | } |
347 | 347 | ||
348 | void IMAPconfig::accept() | 348 | void IMAPconfig::accept() |
349 | { | 349 | { |
350 | data->setAccountName( accountLine->text() ); | 350 | data->setAccountName( accountLine->text() ); |
351 | data->setServer( serverLine->text() ); | 351 | data->setServer( serverLine->text() ); |
352 | data->setPort( portLine->text() ); | 352 | data->setPort( portLine->text() ); |
353 | data->setConnectionType( ComboBox1->currentItem() ); | 353 | data->setConnectionType( ComboBox1->currentItem() ); |
354 | data->setUser( userLine->text() ); | 354 | data->setUser( userLine->text() ); |
355 | data->setPassword( passLine->text() ); | 355 | data->setPassword( passLine->text() ); |
356 | data->setPrefix(prefixLine->text()); | 356 | data->setPrefix(prefixLine->text()); |
357 | 357 | ||
358 | QDialog::accept(); | 358 | QDialog::accept(); |
359 | } | 359 | } |
360 | 360 | ||
361 | /** | 361 | /** |
362 | * POP3config | 362 | * POP3config |
363 | */ | 363 | */ |
364 | 364 | ||
365 | POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 365 | POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
366 | : POP3configUI( parent, name, modal, flags ) | 366 | : POP3configUI( parent, name, modal, flags ) |
367 | { | 367 | { |
368 | data = account; | 368 | data = account; |
369 | fillValues(); | 369 | fillValues(); |
370 | 370 | ||
371 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); | 371 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); |
372 | ComboBox1->insertItem( "Only if available", 0 ); | 372 | ComboBox1->insertItem( "Only if available", 0 ); |
373 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | 373 | ComboBox1->insertItem( "Always, Negotiated", 1 ); |
374 | ComboBox1->insertItem( "Connect on secure port", 2 ); | 374 | ComboBox1->insertItem( "Connect on secure port", 2 ); |
375 | ComboBox1->insertItem( "Run command instead", 3 ); | 375 | ComboBox1->insertItem( "Run command instead", 3 ); |
376 | CommandEdit->hide(); | 376 | CommandEdit->hide(); |
377 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 377 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
378 | } | 378 | } |
379 | 379 | ||
380 | void POP3config::slotConnectionToggle( int index ) | 380 | void POP3config::slotConnectionToggle( int index ) |
381 | { | 381 | { |
382 | // 2 is ssl connection | 382 | // 2 is ssl connection |
383 | if ( index == 2 ) | 383 | if ( index == 2 ) |
384 | { | 384 | { |
385 | portLine->setText( POP3_SSL_PORT ); | 385 | portLine->setText( POP3_SSL_PORT ); |
386 | } | 386 | } |
387 | else if ( index == 3 ) | 387 | else if ( index == 3 ) |
388 | { | 388 | { |
389 | portLine->setText( POP3_PORT ); | 389 | portLine->setText( POP3_PORT ); |
390 | CommandEdit->show(); | 390 | CommandEdit->show(); |
391 | } | 391 | } |
392 | else | 392 | else |
393 | { | 393 | { |
394 | portLine->setText( POP3_PORT ); | 394 | portLine->setText( POP3_PORT ); |
395 | } | 395 | } |
396 | } | 396 | } |
397 | 397 | ||
398 | void POP3config::fillValues() | 398 | void POP3config::fillValues() |
399 | { | 399 | { |
400 | accountLine->setText( data->getAccountName() ); | 400 | accountLine->setText( data->getAccountName() ); |
401 | serverLine->setText( data->getServer() ); | 401 | serverLine->setText( data->getServer() ); |
402 | portLine->setText( data->getPort() ); | 402 | portLine->setText( data->getPort() ); |
403 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 403 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
404 | userLine->setText( data->getUser() ); | 404 | userLine->setText( data->getUser() ); |
405 | passLine->setText( data->getPassword() ); | 405 | passLine->setText( data->getPassword() ); |
406 | } | 406 | } |
407 | 407 | ||
408 | void POP3config::accept() | 408 | void POP3config::accept() |
409 | { | 409 | { |
410 | data->setAccountName( accountLine->text() ); | 410 | data->setAccountName( accountLine->text() ); |
411 | data->setServer( serverLine->text() ); | 411 | data->setServer( serverLine->text() ); |
412 | data->setPort( portLine->text() ); | 412 | data->setPort( portLine->text() ); |
413 | data->setConnectionType( ComboBox1->currentItem() ); | 413 | data->setConnectionType( ComboBox1->currentItem() ); |
414 | data->setUser( userLine->text() ); | 414 | data->setUser( userLine->text() ); |
415 | data->setPassword( passLine->text() ); | 415 | data->setPassword( passLine->text() ); |
416 | 416 | ||
417 | QDialog::accept(); | 417 | QDialog::accept(); |
418 | } | 418 | } |
419 | 419 | ||
420 | /** | 420 | /** |
421 | * SMTPconfig | 421 | * SMTPconfig |
422 | */ | 422 | */ |
423 | 423 | ||
424 | SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 424 | SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
425 | : SMTPconfigUI( parent, name, modal, flags ) | 425 | : SMTPconfigUI( parent, name, modal, flags ) |
426 | { | 426 | { |
427 | data = account; | 427 | data = account; |
428 | 428 | ||
429 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); | 429 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); |
430 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); | 430 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); |
431 | 431 | ||
432 | fillValues(); | 432 | fillValues(); |
433 | 433 | ||
434 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); | 434 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); |
435 | ComboBox1->insertItem( "Only if available", 0 ); | 435 | ComboBox1->insertItem( "Only if available", 0 ); |
436 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | 436 | ComboBox1->insertItem( "Always, Negotiated", 1 ); |
437 | ComboBox1->insertItem( "Connect on secure port", 2 ); | 437 | ComboBox1->insertItem( "Connect on secure port", 2 ); |
438 | ComboBox1->insertItem( "Run command instead", 3 ); | 438 | ComboBox1->insertItem( "Run command instead", 3 ); |
439 | CommandEdit->hide(); | 439 | CommandEdit->hide(); |
440 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 440 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
441 | } | 441 | } |
442 | 442 | ||
443 | void SMTPconfig::slotConnectionToggle( int index ) | 443 | void SMTPconfig::slotConnectionToggle( int index ) |
444 | { | 444 | { |
445 | // 2 is ssl connection | 445 | // 2 is ssl connection |
446 | if ( index == 2 ) | 446 | if ( index == 2 ) |
447 | { | 447 | { |
448 | portLine->setText( SMTP_SSL_PORT ); | 448 | portLine->setText( SMTP_SSL_PORT ); |
449 | } | 449 | } |
450 | else if ( index == 3 ) | 450 | else if ( index == 3 ) |
451 | { | 451 | { |
452 | portLine->setText( SMTP_PORT ); | 452 | portLine->setText( SMTP_PORT ); |
453 | CommandEdit->show(); | 453 | CommandEdit->show(); |
454 | } | 454 | } |
455 | else | 455 | else |
456 | { | 456 | { |
457 | portLine->setText( SMTP_PORT ); | 457 | portLine->setText( SMTP_PORT ); |
458 | } | 458 | } |
459 | } | 459 | } |
460 | 460 | ||
461 | void SMTPconfig::fillValues() | 461 | void SMTPconfig::fillValues() |
462 | { | 462 | { |
463 | accountLine->setText( data->getAccountName() ); | 463 | accountLine->setText( data->getAccountName() ); |
464 | serverLine->setText( data->getServer() ); | 464 | serverLine->setText( data->getServer() ); |
465 | portLine->setText( data->getPort() ); | 465 | portLine->setText( data->getPort() ); |
466 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 466 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
467 | loginBox->setChecked( data->getLogin() ); | 467 | loginBox->setChecked( data->getLogin() ); |
468 | userLine->setText( data->getUser() ); | 468 | userLine->setText( data->getUser() ); |
469 | passLine->setText( data->getPassword() ); | 469 | passLine->setText( data->getPassword() ); |
470 | } | 470 | } |
471 | 471 | ||
472 | void SMTPconfig::accept() | 472 | void SMTPconfig::accept() |
473 | { | 473 | { |
474 | data->setAccountName( accountLine->text() ); | 474 | data->setAccountName( accountLine->text() ); |
475 | data->setServer( serverLine->text() ); | 475 | data->setServer( serverLine->text() ); |
476 | data->setPort( portLine->text() ); | 476 | data->setPort( portLine->text() ); |
477 | data->setConnectionType( ComboBox1->currentItem() ); | 477 | data->setConnectionType( ComboBox1->currentItem() ); |
478 | data->setLogin( loginBox->isChecked() ); | 478 | data->setLogin( loginBox->isChecked() ); |
479 | data->setUser( userLine->text() ); | 479 | data->setUser( userLine->text() ); |
480 | data->setPassword( passLine->text() ); | 480 | data->setPassword( passLine->text() ); |
481 | 481 | ||
482 | QDialog::accept(); | 482 | QDialog::accept(); |
483 | } | 483 | } |
484 | 484 | ||
485 | /** | 485 | /** |
486 | * NNTPconfig | 486 | * NNTPconfig |
487 | */ | 487 | */ |
488 | 488 | ||
489 | NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 489 | NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
490 | : NNTPconfigUI( parent, name, modal, flags ) | 490 | : NNTPconfigUI( parent, name, modal, flags ) |
491 | { | 491 | { |
492 | data = account; | 492 | data = account; |
493 | 493 | ||
494 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); | 494 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); |
495 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); | 495 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); |
496 | connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); | 496 | connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); |
497 | fillValues(); | 497 | fillValues(); |
498 | 498 | ||
499 | connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); | 499 | connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); |
500 | } | 500 | } |
501 | 501 | ||
502 | void NNTPconfig::slotGetNG() { | 502 | void NNTPconfig::slotGetNG() { |
503 | save(); | 503 | save(); |
504 | data->save(); | 504 | data->save(); |
505 | NNTPwrapper* tmp = new NNTPwrapper( data ); | 505 | NNTPwrapper* tmp = new NNTPwrapper( data ); |
506 | clist* list = tmp->listAllNewsgroups(); | 506 | clist* list = tmp->listAllNewsgroups(); |
507 | 507 | ||
508 | clistcell *current; | 508 | clistcell *current; |
509 | newsnntp_group_description *group; | 509 | newsnntp_group_description *group; |
510 | 510 | ||
511 | // FIXME - test if not empty | 511 | // FIXME - test if not empty |
512 | current = list->first; | 512 | current = list->first; |
513 | for ( current=clist_begin(list);current!=NULL;current=clist_next(current) ) { | 513 | for ( current=clist_begin(list);current!=NULL;current=clist_next(current) ) { |
514 | group = ( newsnntp_group_description* ) current->data; | 514 | group = ( newsnntp_group_description* ) current->data; |
515 | // qDebug( group->grp_name ); | 515 | // qDebug( group->grp_name ); |
516 | 516 | ||
517 | QCheckListItem *item; | 517 | QCheckListItem *item; |
518 | item = new QCheckListItem( ListViewGroups, ( QString )group->grp_name, QCheckListItem::CheckBox ); | 518 | item = new QCheckListItem( ListViewGroups, ( QString )group->grp_name, QCheckListItem::CheckBox ); |
519 | if ( subscribedGroups.contains( ( QString )group->grp_name ) >= 1 ) { | 519 | if ( subscribedGroups.contains( ( QString )group->grp_name ) >= 1 ) { |
520 | item->setSelected( true ); | 520 | item->setOn( true ); |
521 | } | 521 | } |
522 | } | 522 | } |
523 | } | 523 | } |
524 | 524 | ||
525 | void NNTPconfig::slotSSL( bool enabled ) | 525 | void NNTPconfig::slotSSL( bool enabled ) |
526 | { | 526 | { |
527 | if ( enabled ) | 527 | if ( enabled ) |
528 | { | 528 | { |
529 | portLine->setText( NNTP_SSL_PORT ); | 529 | portLine->setText( NNTP_SSL_PORT ); |
530 | } | 530 | } |
531 | else | 531 | else |
532 | { | 532 | { |
533 | portLine->setText( NNTP_PORT ); | 533 | portLine->setText( NNTP_PORT ); |
534 | } | 534 | } |
535 | } | 535 | } |
536 | 536 | ||
537 | void NNTPconfig::fillValues() | 537 | void NNTPconfig::fillValues() |
538 | { | 538 | { |
539 | accountLine->setText( data->getAccountName() ); | 539 | accountLine->setText( data->getAccountName() ); |
540 | serverLine->setText( data->getServer() ); | 540 | serverLine->setText( data->getServer() ); |
541 | portLine->setText( data->getPort() ); | 541 | portLine->setText( data->getPort() ); |
542 | sslBox->setChecked( data->getSSL() ); | 542 | sslBox->setChecked( data->getSSL() ); |
543 | loginBox->setChecked( data->getLogin() ); | 543 | loginBox->setChecked( data->getLogin() ); |
544 | userLine->setText( data->getUser() ); | 544 | userLine->setText( data->getUser() ); |
545 | passLine->setText( data->getPassword() ); | 545 | passLine->setText( data->getPassword() ); |
546 | subscribedGroups = data->getGroups(); | 546 | subscribedGroups = data->getGroups(); |
547 | } | 547 | } |
548 | 548 | ||
549 | void NNTPconfig::save() | 549 | void NNTPconfig::save() |
550 | { | 550 | { |
551 | data->setAccountName( accountLine->text() ); | 551 | data->setAccountName( accountLine->text() ); |
552 | data->setServer( serverLine->text() ); | 552 | data->setServer( serverLine->text() ); |
553 | data->setPort( portLine->text() ); | 553 | data->setPort( portLine->text() ); |
554 | data->setSSL( sslBox->isChecked() ); | 554 | data->setSSL( sslBox->isChecked() ); |
555 | data->setLogin( loginBox->isChecked() ); | 555 | data->setLogin( loginBox->isChecked() ); |
556 | data->setUser( userLine->text() ); | 556 | data->setUser( userLine->text() ); |
557 | data->setPassword( passLine->text() ); | 557 | data->setPassword( passLine->text() ); |
558 | 558 | ||
559 | QListViewItemIterator list_it( ListViewGroups ); | 559 | QListViewItemIterator list_it( ListViewGroups ); |
560 | for ( ; list_it.current(); ++list_it ) { | 560 | |
561 | QStringList groupList; | 561 | QStringList groupList; |
562 | if ( list_it.current()->isSelected() ) { | 562 | for ( ; list_it.current(); ++list_it ) { |
563 | |||
564 | if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { | ||
563 | qDebug(list_it.current()->text(0) ); | 565 | qDebug(list_it.current()->text(0) ); |
564 | groupList.append( list_it.current()->text(0) ); | 566 | groupList.append( list_it.current()->text(0) ); |
565 | } | 567 | } |
566 | data->setGroups( groupList ); | 568 | |
567 | } | 569 | } |
570 | data->setGroups( groupList ); | ||
568 | } | 571 | } |
569 | 572 | ||
570 | void NNTPconfig::accept() | 573 | void NNTPconfig::accept() |
571 | { | 574 | { |
572 | save(); | 575 | save(); |
573 | QDialog::accept(); | 576 | QDialog::accept(); |
574 | } | 577 | } |
575 | 578 | ||
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp index 2d6f9a3..ecdf848 100644 --- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp | |||
@@ -1,257 +1,257 @@ | |||
1 | #include "nntpwrapper.h" | 1 | #include "nntpwrapper.h" |
2 | #include "logindialog.h" | 2 | #include "logindialog.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | 4 | ||
5 | #include <qfile.h> | 5 | #include <qfile.h> |
6 | 6 | ||
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | 8 | ||
9 | #include <libetpan/libetpan.h> | 9 | #include <libetpan/libetpan.h> |
10 | 10 | ||
11 | 11 | ||
12 | #define HARD_MSG_SIZE_LIMIT 5242880 | 12 | #define HARD_MSG_SIZE_LIMIT 5242880 |
13 | 13 | ||
14 | NNTPwrapper::NNTPwrapper( NNTPaccount *a ) | 14 | NNTPwrapper::NNTPwrapper( NNTPaccount *a ) |
15 | : Genericwrapper() { | 15 | : Genericwrapper() { |
16 | account = a; | 16 | account = a; |
17 | m_nntp = NULL; | 17 | m_nntp = NULL; |
18 | msgTempName = a->getFileName()+"_msg_cache"; | 18 | msgTempName = a->getFileName()+"_msg_cache"; |
19 | last_msg_id = 0; | 19 | last_msg_id = 0; |
20 | } | 20 | } |
21 | 21 | ||
22 | NNTPwrapper::~NNTPwrapper() { | 22 | NNTPwrapper::~NNTPwrapper() { |
23 | logout(); | 23 | logout(); |
24 | QFile msg_cache(msgTempName); | 24 | QFile msg_cache(msgTempName); |
25 | if (msg_cache.exists()) { | 25 | if (msg_cache.exists()) { |
26 | msg_cache.remove(); | 26 | msg_cache.remove(); |
27 | } | 27 | } |
28 | } | 28 | } |
29 | 29 | ||
30 | void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) { | 30 | void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) { |
31 | qDebug( "NNTP: %i of %i", current, maximum ); | 31 | qDebug( "NNTP: %i of %i", current, maximum ); |
32 | } | 32 | } |
33 | 33 | ||
34 | 34 | ||
35 | RecBody NNTPwrapper::fetchBody( const RecMail &mail ) { | 35 | RecBody NNTPwrapper::fetchBody( const RecMail &mail ) { |
36 | int err = NEWSNNTP_NO_ERROR; | 36 | int err = NEWSNNTP_NO_ERROR; |
37 | char *message = 0; | 37 | char *message = 0; |
38 | size_t length = 0; | 38 | size_t length = 0; |
39 | 39 | ||
40 | login(); | 40 | login(); |
41 | if ( !m_nntp ) { | 41 | if ( !m_nntp ) { |
42 | return RecBody(); | 42 | return RecBody(); |
43 | } | 43 | } |
44 | 44 | ||
45 | RecBody body; | 45 | RecBody body; |
46 | mailmessage * mailmsg; | 46 | mailmessage * mailmsg; |
47 | if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) { | 47 | if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) { |
48 | qDebug("Message to large: %i",mail.Msgsize()); | 48 | qDebug("Message to large: %i",mail.Msgsize()); |
49 | return body; | 49 | return body; |
50 | } | 50 | } |
51 | 51 | ||
52 | QFile msg_cache(msgTempName); | 52 | QFile msg_cache(msgTempName); |
53 | 53 | ||
54 | cleanMimeCache(); | 54 | cleanMimeCache(); |
55 | 55 | ||
56 | if (mail.getNumber()!=last_msg_id) { | 56 | if (mail.getNumber()!=last_msg_id) { |
57 | if (msg_cache.exists()) { | 57 | if (msg_cache.exists()) { |
58 | msg_cache.remove(); | 58 | msg_cache.remove(); |
59 | } | 59 | } |
60 | msg_cache.open(IO_ReadWrite|IO_Truncate); | 60 | msg_cache.open(IO_ReadWrite|IO_Truncate); |
61 | last_msg_id = mail.getNumber(); | 61 | last_msg_id = mail.getNumber(); |
62 | err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg); | 62 | err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg); |
63 | err = mailmessage_fetch(mailmsg,&message,&length); | 63 | err = mailmessage_fetch(mailmsg,&message,&length); |
64 | msg_cache.writeBlock(message,length); | 64 | msg_cache.writeBlock(message,length); |
65 | } else { | 65 | } else { |
66 | QString msg=""; | 66 | QString msg=""; |
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 | ||
99 | void NNTPwrapper::listMessages(const QString &, QList<RecMail> &target ) | 99 | void NNTPwrapper::listMessages(const QString &, 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,"INBOX",&res_messages,&res_recent,&res_unseen); |
106 | parseList(target,m_nntp->sto_session,"INBOX"); | 106 | parseList(target,m_nntp->sto_session,"INBOX"); |
107 | } | 107 | } |
108 | 108 | ||
109 | void NNTPwrapper::login() | 109 | void 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() ) { | 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 | } |
139 | } else { | 139 | } else { |
140 | User = account->getUser().latin1(); | 140 | User = account->getUser().latin1(); |
141 | Pass = account->getPassword().latin1(); | 141 | Pass = account->getPassword().latin1(); |
142 | } | 142 | } |
143 | 143 | ||
144 | if (User.isEmpty()) { | 144 | if (User.isEmpty()) { |
145 | user=0; | 145 | user=0; |
146 | pass = 0; | 146 | pass = 0; |
147 | } else { | 147 | } else { |
148 | user=User.latin1(); | 148 | user=User.latin1(); |
149 | pass=Pass.latin1(); | 149 | pass=Pass.latin1(); |
150 | } | 150 | } |
151 | // bool ssl = account->getSSL(); | 151 | // bool ssl = account->getSSL(); |
152 | 152 | ||
153 | m_nntp=mailstorage_new(NULL); | 153 | m_nntp=mailstorage_new(NULL); |
154 | 154 | ||
155 | int conntypeset = account->ConnectionType(); | 155 | int conntypeset = account->ConnectionType(); |
156 | int conntype = 0; | 156 | int conntype = 0; |
157 | if ( conntypeset == 3 ) { | 157 | if ( conntypeset == 3 ) { |
158 | conntype = CONNECTION_TYPE_COMMAND; | 158 | conntype = CONNECTION_TYPE_COMMAND; |
159 | } else if ( conntypeset == 2 ) { | 159 | } else if ( conntypeset == 2 ) { |
160 | conntype = CONNECTION_TYPE_TLS; | 160 | conntype = CONNECTION_TYPE_TLS; |
161 | } else if ( conntypeset == 1 ) { | 161 | } else if ( conntypeset == 1 ) { |
162 | conntype = CONNECTION_TYPE_STARTTLS; | 162 | conntype = CONNECTION_TYPE_STARTTLS; |
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 | ||
182 | void NNTPwrapper::logout() | 182 | void 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 | ||
191 | QList<Folder>* NNTPwrapper::listFolders() { | 191 | QList<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 | ||
196 | // folders->append(inb); | 196 | // folders->append(inb); |
197 | return folders; | 197 | return folders; |
198 | } | 198 | } |
199 | 199 | ||
200 | clist * NNTPwrapper::listAllNewsgroups() { | 200 | clist * NNTPwrapper::listAllNewsgroups() { |
201 | login(); | 201 | login(); |
202 | clist *result = 0; | 202 | clist *result = 0; |
203 | clistcell *current; | 203 | clistcell *current; |
204 | newsnntp_group_description *list; | 204 | newsnntp_group_description *list; |
205 | if ( m_nntp ) { | 205 | if ( m_nntp ) { |
206 | mailsession * session = m_nntp->sto_session; | 206 | mailsession * session = m_nntp->sto_session; |
207 | newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; | 207 | newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; |
208 | int err = newsnntp_list_newsgroups(news, NULL, &result); | 208 | int err = newsnntp_list_newsgroups(news, NULL, &result); |
209 | 209 | ||
210 | if ( err == NEWSNNTP_NO_ERROR ) { | 210 | if ( err == NEWSNNTP_NO_ERROR ) { |
211 | return result; | 211 | return result; |
212 | } | 212 | } |
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | void NNTPwrapper::answeredMail(const RecMail&) {} | 216 | void NNTPwrapper::answeredMail(const RecMail&) {} |
217 | 217 | ||
218 | void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) { | 218 | void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) { |
219 | login(); | 219 | login(); |
220 | target_stat.message_count = 0; | 220 | target_stat.message_count = 0; |
221 | target_stat.message_unseen = 0; | 221 | target_stat.message_unseen = 0; |
222 | target_stat.message_recent = 0; | 222 | target_stat.message_recent = 0; |
223 | if (!m_nntp) | 223 | if (!m_nntp) |
224 | return; | 224 | return; |
225 | int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count, | 225 | int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count, |
226 | &target_stat.message_recent,&target_stat.message_unseen); | 226 | &target_stat.message_recent,&target_stat.message_unseen); |
227 | } | 227 | } |
228 | 228 | ||
229 | 229 | ||
230 | encodedString* NNTPwrapper::fetchRawBody(const RecMail&mail) { | 230 | encodedString* NNTPwrapper::fetchRawBody(const RecMail&mail) { |
231 | char*target=0; | 231 | char*target=0; |
232 | size_t length=0; | 232 | size_t length=0; |
233 | encodedString*res = 0; | 233 | encodedString*res = 0; |
234 | mailmessage * mailmsg = 0; | 234 | mailmessage * mailmsg = 0; |
235 | int err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg); | 235 | int err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg); |
236 | err = mailmessage_fetch(mailmsg,&target,&length); | 236 | err = mailmessage_fetch(mailmsg,&target,&length); |
237 | if (mailmsg) | 237 | if (mailmsg) |
238 | mailmessage_free(mailmsg); | 238 | mailmessage_free(mailmsg); |
239 | if (target) { | 239 | if (target) { |
240 | res = new encodedString(target,length); | 240 | res = new encodedString(target,length); |
241 | } | 241 | } |
242 | return res; | 242 | return res; |
243 | } | 243 | } |
244 | 244 | ||
245 | const QString&NNTPwrapper::getType()const { | 245 | const QString&NNTPwrapper::getType()const { |
246 | return account->getType(); | 246 | return account->getType(); |
247 | } | 247 | } |
248 | 248 | ||
249 | const QString&NNTPwrapper::getName()const{ | 249 | const QString&NNTPwrapper::getName()const{ |
250 | return account->getAccountName(); | 250 | return account->getAccountName(); |
251 | } | 251 | } |
252 | 252 | ||
253 | void NNTPwrapper::deleteMail(const RecMail&mail) { | 253 | void NNTPwrapper::deleteMail(const RecMail&mail) { |
254 | } | 254 | } |
255 | 255 | ||
256 | int NNTPwrapper::deleteAllMail(const Folder*) { | 256 | int NNTPwrapper::deleteAllMail(const Folder*) { |
257 | } | 257 | } |