-rw-r--r-- | kmicromail/accountitem.cpp | 12 | ||||
-rw-r--r-- | kmicromail/accountview.cpp | 5 | ||||
-rw-r--r-- | kmicromail/editaccounts.cpp | 3 | ||||
-rw-r--r-- | kmicromail/opiemail.cpp | 6 |
4 files changed, 22 insertions, 4 deletions
diff --git a/kmicromail/accountitem.cpp b/kmicromail/accountitem.cpp index 567de87..fcb2052 100644 --- a/kmicromail/accountitem.cpp +++ b/kmicromail/accountitem.cpp | |||
@@ -1,1183 +1,1187 @@ | |||
1 | 1 | ||
2 | #include "accountitem.h" | 2 | #include "accountitem.h" |
3 | #include "accountview.h" | 3 | #include "accountview.h" |
4 | #include "newmaildir.h" | 4 | #include "newmaildir.h" |
5 | #include "nntpgroupsdlg.h" | 5 | #include "nntpgroupsdlg.h" |
6 | #include "defines.h" | 6 | #include "defines.h" |
7 | 7 | ||
8 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
9 | #include <libmailwrapper/abstractmail.h> | 9 | #include <libmailwrapper/abstractmail.h> |
10 | #include <libmailwrapper/mailwrapper.h> | 10 | #include <libmailwrapper/mailwrapper.h> |
11 | /* OPIE */ | 11 | /* OPIE */ |
12 | //#include <qpe/qpeapplication.h> | 12 | //#include <qpe/qpeapplication.h> |
13 | 13 | ||
14 | /* QT */ | 14 | /* QT */ |
15 | #include <qpopupmenu.h> | 15 | #include <qpopupmenu.h> |
16 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
17 | #include <kiconloader.h> | 17 | #include <kiconloader.h> |
18 | #include <klocale.h> | 18 | #include <klocale.h> |
19 | 19 | ||
20 | #define GET_NEW_MAILS 101 | 20 | #define GET_NEW_MAILS 101 |
21 | 21 | ||
22 | using namespace Opie::Core; | 22 | using namespace Opie::Core; |
23 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} | 23 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} |
24 | /** | 24 | /** |
25 | * POP3 Account stuff | 25 | * POP3 Account stuff |
26 | */ | 26 | */ |
27 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) | 27 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) |
28 | : AccountViewItem( parent ) | 28 | : AccountViewItem( parent ) |
29 | { | 29 | { |
30 | account = a; | 30 | account = a; |
31 | wrapper = AbstractMail::getWrapper( account ); | 31 | wrapper = AbstractMail::getWrapper( account ); |
32 | SETPIX(PIXMAP_POP3FOLDER); | 32 | SETPIX(PIXMAP_POP3FOLDER); |
33 | #if 0 | 33 | #if 0 |
34 | if (!account->getOffline()) | 34 | if (!account->getOffline()) |
35 | { | 35 | { |
36 | setPixmap( 0, ); | 36 | setPixmap( 0, ); |
37 | } | 37 | } |
38 | else | 38 | else |
39 | { | 39 | { |
40 | setPixmap( 0, PIXMAP_OFFLINE ); | 40 | setPixmap( 0, PIXMAP_OFFLINE ); |
41 | } | 41 | } |
42 | #endif | 42 | #endif |
43 | setText( 0, account->getAccountName() ); | 43 | setText( 0, account->getAccountName() ); |
44 | setOpen( true ); | 44 | setOpen( true ); |
45 | } | 45 | } |
46 | 46 | ||
47 | POP3viewItem::~POP3viewItem() | 47 | POP3viewItem::~POP3viewItem() |
48 | { | 48 | { |
49 | delete wrapper; | 49 | delete wrapper; |
50 | } | 50 | } |
51 | 51 | ||
52 | AbstractMail *POP3viewItem::getWrapper() | 52 | AbstractMail *POP3viewItem::getWrapper() |
53 | { | 53 | { |
54 | return wrapper; | 54 | return wrapper; |
55 | } | 55 | } |
56 | 56 | ||
57 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) | 57 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) |
58 | { | 58 | { |
59 | refresh(); | 59 | refresh(); |
60 | } | 60 | } |
61 | 61 | ||
62 | void POP3viewItem::refresh() | 62 | void POP3viewItem::refresh() |
63 | { | 63 | { |
64 | if (account->getOffline()) return; | 64 | if (account->getOffline()) return; |
65 | QValueList<FolderP> *folders = wrapper->listFolders(); | 65 | QValueList<FolderP> *folders = wrapper->listFolders(); |
66 | QListViewItem *child = firstChild(); | 66 | QListViewItem *child = firstChild(); |
67 | while ( child ) | 67 | while ( child ) |
68 | { | 68 | { |
69 | QListViewItem *tmp = child; | 69 | QListViewItem *tmp = child; |
70 | child = child->nextSibling(); | 70 | child = child->nextSibling(); |
71 | delete tmp; | 71 | delete tmp; |
72 | } | 72 | } |
73 | QValueList<FolderP>::ConstIterator it; | 73 | QValueList<FolderP>::ConstIterator it; |
74 | QListViewItem*item = 0; | 74 | QListViewItem*item = 0; |
75 | for ( it = folders->begin(); it!=folders->end(); ++it) | 75 | for ( it = folders->begin(); it!=folders->end(); ++it) |
76 | { | 76 | { |
77 | item = new POP3folderItem( (*it), this , item ); | 77 | item = new POP3folderItem( (*it), this , item ); |
78 | item->setSelectable( (*it)->may_select()); | 78 | item->setSelectable( (*it)->may_select()); |
79 | } | 79 | } |
80 | delete folders; | 80 | delete folders; |
81 | } | 81 | } |
82 | 82 | ||
83 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) | 83 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) |
84 | { | 84 | { |
85 | 85 | ||
86 | return wrapper->fetchBody( mail ); | 86 | return wrapper->fetchBody( mail ); |
87 | } | 87 | } |
88 | 88 | ||
89 | QPopupMenu * POP3viewItem::getContextMenu() | 89 | QPopupMenu * POP3viewItem::getContextMenu() |
90 | { | 90 | { |
91 | QPopupMenu *m = new QPopupMenu(0); | 91 | QPopupMenu *m = new QPopupMenu(0); |
92 | if (m) | 92 | if (m) |
93 | { | 93 | { |
94 | if (!account->getOffline()) | 94 | if (!account->getOffline()) |
95 | { | 95 | { |
96 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); | 96 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); |
97 | m->insertItem(i18n("Disconnect"),0); | 97 | m->insertItem(i18n("Disconnect"),0); |
98 | m->insertItem(i18n("Set offline"),1); | 98 | m->insertItem(i18n("Set offline"),1); |
99 | } | 99 | } |
100 | else | 100 | else |
101 | { | 101 | { |
102 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); | 102 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); |
103 | m->insertItem(i18n("Set online"),1); | 103 | m->insertItem(i18n("Set online"),1); |
104 | } | 104 | } |
105 | } | 105 | } |
106 | return m; | 106 | return m; |
107 | } | 107 | } |
108 | 108 | ||
109 | void POP3viewItem::disconnect() | 109 | void POP3viewItem::disconnect() |
110 | { | 110 | { |
111 | QListViewItem *child = firstChild(); | 111 | QListViewItem *child = firstChild(); |
112 | while ( child ) | 112 | while ( child ) |
113 | { | 113 | { |
114 | QListViewItem *tmp = child; | 114 | QListViewItem *tmp = child; |
115 | child = child->nextSibling(); | 115 | child = child->nextSibling(); |
116 | delete tmp; | 116 | delete tmp; |
117 | } | 117 | } |
118 | wrapper->logout(); | 118 | wrapper->logout(); |
119 | } | 119 | } |
120 | 120 | ||
121 | void POP3viewItem::setOnOffline() | 121 | void POP3viewItem::setOnOffline() |
122 | { | 122 | { |
123 | if (!account->getOffline()) | 123 | if (!account->getOffline()) |
124 | { | 124 | { |
125 | disconnect(); | 125 | disconnect(); |
126 | } | 126 | } |
127 | account->setOffline(!account->getOffline()); | 127 | account->setOffline(!account->getOffline()); |
128 | account->save(); | 128 | account->save(); |
129 | SETPIX(PIXMAP_POP3FOLDER); | 129 | SETPIX(PIXMAP_POP3FOLDER); |
130 | refresh(); | 130 | refresh(); |
131 | } | 131 | } |
132 | 132 | ||
133 | void POP3viewItem::contextMenuSelected(int which) | 133 | void POP3viewItem::contextMenuSelected(int which) |
134 | { | 134 | { |
135 | switch (which) | 135 | switch (which) |
136 | { | 136 | { |
137 | case 0: | 137 | case 0: |
138 | disconnect(); | 138 | disconnect(); |
139 | break; | 139 | break; |
140 | case 1: | 140 | case 1: |
141 | setOnOffline(); | 141 | setOnOffline(); |
142 | break; | 142 | break; |
143 | case GET_NEW_MAILS: // daunlood | 143 | case GET_NEW_MAILS: // daunlood |
144 | if (account->getOffline()) | 144 | if (account->getOffline()) |
145 | setOnOffline(); | 145 | setOnOffline(); |
146 | AccountView*bl = accountView(); | 146 | AccountView*bl = accountView(); |
147 | if (!bl) return; | 147 | if (!bl) return; |
148 | AccountViewItem* in = findSubItem( "inbox" , 0); | 148 | AccountViewItem* in = findSubItem( "inbox" , 0); |
149 | if ( ! in ) | 149 | if ( ! in ) |
150 | return; | 150 | return; |
151 | bl->downloadMailsInbox(in->getFolder() ,getWrapper()); | 151 | bl->downloadMailsInbox(in->getFolder() ,getWrapper()); |
152 | setOnOffline(); | 152 | setOnOffline(); |
153 | break; | 153 | break; |
154 | } | 154 | } |
155 | } | 155 | } |
156 | 156 | ||
157 | POP3folderItem::~POP3folderItem() | 157 | POP3folderItem::~POP3folderItem() |
158 | {} | 158 | {} |
159 | 159 | ||
160 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) | 160 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) |
161 | : AccountViewItem(folderInit,parent,after ) | 161 | : AccountViewItem(folderInit,parent,after ) |
162 | { | 162 | { |
163 | pop3 = parent; | 163 | pop3 = parent; |
164 | if (folder->getDisplayName().lower()!="inbox") | 164 | if (folder->getDisplayName().lower()!="inbox") |
165 | { | 165 | { |
166 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 166 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
167 | } | 167 | } |
168 | else | 168 | else |
169 | { | 169 | { |
170 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 170 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
171 | } | 171 | } |
172 | setText( 0, folder->getDisplayName() ); | 172 | setText( 0, folder->getDisplayName() ); |
173 | } | 173 | } |
174 | 174 | ||
175 | void POP3folderItem::refresh(QValueList<RecMailP>&target) | 175 | void POP3folderItem::refresh(QValueList<RecMailP>&target) |
176 | { | 176 | { |
177 | if (folder->may_select()) | 177 | if (folder->may_select()) |
178 | pop3->getWrapper()->listMessages( folder->getName(),target ); | 178 | pop3->getWrapper()->listMessages( folder->getName(),target ); |
179 | } | 179 | } |
180 | 180 | ||
181 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) | 181 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) |
182 | { | 182 | { |
183 | return pop3->getWrapper()->fetchBody(aMail); | 183 | return pop3->getWrapper()->fetchBody(aMail); |
184 | } | 184 | } |
185 | 185 | ||
186 | QPopupMenu * POP3folderItem::getContextMenu() | 186 | QPopupMenu * POP3folderItem::getContextMenu() |
187 | { | 187 | { |
188 | QPopupMenu *m = new QPopupMenu(0); | 188 | QPopupMenu *m = new QPopupMenu(0); |
189 | if (m) | 189 | if (m) |
190 | { | 190 | { |
191 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); | 191 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); |
192 | m->insertItem(i18n("Refresh header list"),0); | 192 | m->insertItem(i18n("Refresh header list"),0); |
193 | m->insertItem(i18n("Delete all mails"),1); | 193 | m->insertItem(i18n("Delete all mails"),1); |
194 | m->insertItem(i18n("Move/Copie all mails"),2); | 194 | m->insertItem(i18n("Move/Copie all mails"),2); |
195 | } | 195 | } |
196 | return m; | 196 | return m; |
197 | } | 197 | } |
198 | 198 | ||
199 | void POP3folderItem::downloadMails() | 199 | void POP3folderItem::downloadMails() |
200 | { | 200 | { |
201 | AccountView*bl = pop3->accountView(); | 201 | AccountView*bl = pop3->accountView(); |
202 | if (!bl) return; | 202 | if (!bl) return; |
203 | bl->downloadMails(folder,pop3->getWrapper()); | 203 | bl->downloadMails(folder,pop3->getWrapper()); |
204 | } | 204 | } |
205 | 205 | ||
206 | void POP3folderItem::contextMenuSelected(int which) | 206 | void POP3folderItem::contextMenuSelected(int which) |
207 | { | 207 | { |
208 | AccountView * view = (AccountView*)listView(); | 208 | AccountView * view = (AccountView*)listView(); |
209 | switch (which) | 209 | switch (which) |
210 | { | 210 | { |
211 | case 0: | 211 | case 0: |
212 | /* must be 'cause pop3 lists are cached */ | 212 | /* must be 'cause pop3 lists are cached */ |
213 | pop3->getWrapper()->logout(); | 213 | pop3->getWrapper()->logout(); |
214 | view->refreshCurrent(); | 214 | view->refreshCurrent(); |
215 | break; | 215 | break; |
216 | case 1: | 216 | case 1: |
217 | deleteAllMail(pop3->getWrapper(),folder); | 217 | deleteAllMail(pop3->getWrapper(),folder); |
218 | break; | 218 | break; |
219 | case 2: | 219 | case 2: |
220 | downloadMails(); | 220 | downloadMails(); |
221 | break; | 221 | break; |
222 | case GET_NEW_MAILS: // daunlood | 222 | case GET_NEW_MAILS: // daunlood |
223 | view->downloadMailsInbox(getFolder() ,pop3->getWrapper()); | 223 | view->downloadMailsInbox(getFolder() ,pop3->getWrapper()); |
224 | break; | 224 | break; |
225 | default: | 225 | default: |
226 | break; | 226 | break; |
227 | } | 227 | } |
228 | } | 228 | } |
229 | 229 | ||
230 | /** | 230 | /** |
231 | * NNTP Account stuff | 231 | * NNTP Account stuff |
232 | */ | 232 | */ |
233 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) | 233 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) |
234 | : AccountViewItem( parent ) | 234 | : AccountViewItem( parent ) |
235 | { | 235 | { |
236 | account = a; | 236 | account = a; |
237 | wrapper = AbstractMail::getWrapper( account ); | 237 | wrapper = AbstractMail::getWrapper( account ); |
238 | //FIXME | 238 | //FIXME |
239 | SETPIX(PIXMAP_POP3FOLDER); | 239 | SETPIX(PIXMAP_POP3FOLDER); |
240 | #if 0 | 240 | #if 0 |
241 | if (!account->getOffline()) | 241 | if (!account->getOffline()) |
242 | { | 242 | { |
243 | setPixmap( 0, ); | 243 | setPixmap( 0, ); |
244 | } | 244 | } |
245 | else | 245 | else |
246 | { | 246 | { |
247 | setPixmap( 0, PIXMAP_OFFLINE ); | 247 | setPixmap( 0, PIXMAP_OFFLINE ); |
248 | } | 248 | } |
249 | #endif | 249 | #endif |
250 | setText( 0, account->getAccountName() ); | 250 | setText( 0, account->getAccountName() ); |
251 | setOpen( true ); | 251 | setOpen( true ); |
252 | } | 252 | } |
253 | 253 | ||
254 | NNTPviewItem::~NNTPviewItem() | 254 | NNTPviewItem::~NNTPviewItem() |
255 | { | 255 | { |
256 | delete wrapper; | 256 | delete wrapper; |
257 | } | 257 | } |
258 | 258 | ||
259 | AbstractMail *NNTPviewItem::getWrapper() | 259 | AbstractMail *NNTPviewItem::getWrapper() |
260 | { | 260 | { |
261 | return wrapper; | 261 | return wrapper; |
262 | } | 262 | } |
263 | 263 | ||
264 | void NNTPviewItem::refresh( QValueList<RecMailP> & ) | 264 | void NNTPviewItem::refresh( QValueList<RecMailP> & ) |
265 | { | 265 | { |
266 | refresh(); | 266 | refresh(); |
267 | } | 267 | } |
268 | 268 | ||
269 | void NNTPviewItem::refresh() | 269 | void NNTPviewItem::refresh() |
270 | { | 270 | { |
271 | if (account->getOffline()) return; | 271 | if (account->getOffline()) return; |
272 | QValueList<FolderP> *folders = wrapper->listFolders(); | 272 | QValueList<FolderP> *folders = wrapper->listFolders(); |
273 | 273 | ||
274 | QListViewItem *child = firstChild(); | 274 | QListViewItem *child = firstChild(); |
275 | while ( child ) | 275 | while ( child ) |
276 | { | 276 | { |
277 | QListViewItem *tmp = child; | 277 | QListViewItem *tmp = child; |
278 | child = child->nextSibling(); | 278 | child = child->nextSibling(); |
279 | delete tmp; | 279 | delete tmp; |
280 | } | 280 | } |
281 | QValueList<FolderP>::ConstIterator it; | 281 | QValueList<FolderP>::ConstIterator it; |
282 | QListViewItem*item = 0; | 282 | QListViewItem*item = 0; |
283 | for ( it = folders->begin(); it!=folders->end(); ++it) | 283 | for ( it = folders->begin(); it!=folders->end(); ++it) |
284 | { | 284 | { |
285 | item = new NNTPfolderItem( (*it), this , item ); | 285 | item = new NNTPfolderItem( (*it), this , item ); |
286 | item->setSelectable( (*it)->may_select()); | 286 | item->setSelectable( (*it)->may_select()); |
287 | } | 287 | } |
288 | delete folders; | 288 | delete folders; |
289 | } | 289 | } |
290 | 290 | ||
291 | RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) | 291 | RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) |
292 | { | 292 | { |
293 | 293 | ||
294 | return wrapper->fetchBody( mail ); | 294 | return wrapper->fetchBody( mail ); |
295 | } | 295 | } |
296 | 296 | ||
297 | QPopupMenu * NNTPviewItem::getContextMenu() | 297 | QPopupMenu * NNTPviewItem::getContextMenu() |
298 | { | 298 | { |
299 | QPopupMenu *m = new QPopupMenu(0); | 299 | QPopupMenu *m = new QPopupMenu(0); |
300 | if (m) | 300 | if (m) |
301 | { | 301 | { |
302 | if (!account->getOffline()) | 302 | if (!account->getOffline()) |
303 | { | 303 | { |
304 | m->insertItem(i18n("Disconnect"),0); | 304 | m->insertItem(i18n("Disconnect"),0); |
305 | m->insertItem(i18n("Set offline"),1); | 305 | m->insertItem(i18n("Set offline"),1); |
306 | //m->insertItem(i18n("(Un-)Subscribe groups"),2); | 306 | //m->insertItem(i18n("(Un-)Subscribe groups"),2); |
307 | } | 307 | } |
308 | else | 308 | else |
309 | { | 309 | { |
310 | m->insertItem(i18n("Set online"),1); | 310 | m->insertItem(i18n("Set online"),1); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | return m; | 313 | return m; |
314 | } | 314 | } |
315 | 315 | ||
316 | void NNTPviewItem::subscribeGroups() | 316 | void NNTPviewItem::subscribeGroups() |
317 | { | 317 | { |
318 | NNTPGroupsDlg dlg(account); | 318 | NNTPGroupsDlg dlg(account); |
319 | #ifndef DESKTOP_VERSION | ||
319 | dlg.showMaximized(); | 320 | dlg.showMaximized(); |
321 | #endif | ||
320 | if ( dlg.exec()== QDialog::Accepted ){ | 322 | if ( dlg.exec()== QDialog::Accepted ){ |
321 | refresh(); | 323 | refresh(); |
322 | } | 324 | } |
323 | } | 325 | } |
324 | 326 | ||
325 | void NNTPviewItem::disconnect() | 327 | void NNTPviewItem::disconnect() |
326 | { | 328 | { |
327 | QListViewItem *child = firstChild(); | 329 | QListViewItem *child = firstChild(); |
328 | while ( child ) | 330 | while ( child ) |
329 | { | 331 | { |
330 | QListViewItem *tmp = child; | 332 | QListViewItem *tmp = child; |
331 | child = child->nextSibling(); | 333 | child = child->nextSibling(); |
332 | delete tmp; | 334 | delete tmp; |
333 | } | 335 | } |
334 | wrapper->logout(); | 336 | wrapper->logout(); |
335 | } | 337 | } |
336 | 338 | ||
337 | void NNTPviewItem::setOnOffline() | 339 | void NNTPviewItem::setOnOffline() |
338 | { | 340 | { |
339 | if (!account->getOffline()) | 341 | if (!account->getOffline()) |
340 | { | 342 | { |
341 | disconnect(); | 343 | disconnect(); |
342 | } | 344 | } |
343 | account->setOffline(!account->getOffline()); | 345 | account->setOffline(!account->getOffline()); |
344 | account->save(); | 346 | account->save(); |
345 | //FIXME | 347 | //FIXME |
346 | SETPIX(PIXMAP_POP3FOLDER); | 348 | SETPIX(PIXMAP_POP3FOLDER); |
347 | refresh(); | 349 | refresh(); |
348 | } | 350 | } |
349 | 351 | ||
350 | void NNTPviewItem::contextMenuSelected(int which) | 352 | void NNTPviewItem::contextMenuSelected(int which) |
351 | { | 353 | { |
352 | switch (which) | 354 | switch (which) |
353 | { | 355 | { |
354 | case 0: | 356 | case 0: |
355 | disconnect(); | 357 | disconnect(); |
356 | break; | 358 | break; |
357 | case 1: | 359 | case 1: |
358 | setOnOffline(); | 360 | setOnOffline(); |
359 | break; | 361 | break; |
360 | case 2: | 362 | case 2: |
361 | subscribeGroups(); | 363 | subscribeGroups(); |
362 | break; | 364 | break; |
363 | } | 365 | } |
364 | } | 366 | } |
365 | 367 | ||
366 | NNTPfolderItem::~NNTPfolderItem() | 368 | NNTPfolderItem::~NNTPfolderItem() |
367 | {} | 369 | {} |
368 | 370 | ||
369 | NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) | 371 | NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) |
370 | : AccountViewItem( folderInit, parent,after ) | 372 | : AccountViewItem( folderInit, parent,after ) |
371 | { | 373 | { |
372 | nntp = parent; | 374 | nntp = parent; |
373 | if (folder->getDisplayName().lower()!="inbox") | 375 | if (folder->getDisplayName().lower()!="inbox") |
374 | { | 376 | { |
375 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 377 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
376 | } | 378 | } |
377 | else | 379 | else |
378 | { | 380 | { |
379 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 381 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
380 | } | 382 | } |
381 | setText( 0, folder->getDisplayName() ); | 383 | setText( 0, folder->getDisplayName() ); |
382 | } | 384 | } |
383 | 385 | ||
384 | void NNTPfolderItem::refresh(QValueList<RecMailP>&target) | 386 | void NNTPfolderItem::refresh(QValueList<RecMailP>&target) |
385 | { | 387 | { |
386 | if (folder->may_select()) | 388 | if (folder->may_select()) |
387 | nntp->getWrapper()->listMessages( folder->getName(),target ); | 389 | nntp->getWrapper()->listMessages( folder->getName(),target ); |
388 | } | 390 | } |
389 | 391 | ||
390 | RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) | 392 | RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) |
391 | { | 393 | { |
392 | return nntp->getWrapper()->fetchBody(aMail); | 394 | return nntp->getWrapper()->fetchBody(aMail); |
393 | } | 395 | } |
394 | 396 | ||
395 | QPopupMenu * NNTPfolderItem::getContextMenu() | 397 | QPopupMenu * NNTPfolderItem::getContextMenu() |
396 | { | 398 | { |
397 | QPopupMenu *m = new QPopupMenu(0); | 399 | QPopupMenu *m = new QPopupMenu(0); |
398 | if (m) | 400 | if (m) |
399 | { | 401 | { |
400 | m->insertItem(i18n("Refresh header list"),0); | 402 | m->insertItem(i18n("Refresh header list"),0); |
401 | m->insertItem(i18n("Copy all postings"),1); | 403 | m->insertItem(i18n("Copy all postings"),1); |
402 | } | 404 | } |
403 | return m; | 405 | return m; |
404 | } | 406 | } |
405 | 407 | ||
406 | void NNTPfolderItem::downloadMails() | 408 | void NNTPfolderItem::downloadMails() |
407 | { | 409 | { |
408 | AccountView*bl = nntp->accountView(); | 410 | AccountView*bl = nntp->accountView(); |
409 | if (!bl) return; | 411 | if (!bl) return; |
410 | bl->downloadMails(folder,nntp->getWrapper()); | 412 | bl->downloadMails(folder,nntp->getWrapper()); |
411 | } | 413 | } |
412 | 414 | ||
413 | void NNTPfolderItem::contextMenuSelected(int which) | 415 | void NNTPfolderItem::contextMenuSelected(int which) |
414 | { | 416 | { |
415 | AccountView * view = (AccountView*)listView(); | 417 | AccountView * view = (AccountView*)listView(); |
416 | switch (which) | 418 | switch (which) |
417 | { | 419 | { |
418 | case 0: | 420 | case 0: |
419 | /* must be 'cause pop3 lists are cached */ | 421 | /* must be 'cause pop3 lists are cached */ |
420 | nntp->getWrapper()->logout(); | 422 | nntp->getWrapper()->logout(); |
421 | view->refreshCurrent(); | 423 | view->refreshCurrent(); |
422 | break; | 424 | break; |
423 | case 1: | 425 | case 1: |
424 | downloadMails(); | 426 | downloadMails(); |
425 | break; | 427 | break; |
426 | default: | 428 | default: |
427 | break; | 429 | break; |
428 | } | 430 | } |
429 | } | 431 | } |
430 | 432 | ||
431 | /** | 433 | /** |
432 | * IMAP Account stuff | 434 | * IMAP Account stuff |
433 | */ | 435 | */ |
434 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) | 436 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) |
435 | : AccountViewItem( parent ) | 437 | : AccountViewItem( parent ) |
436 | { | 438 | { |
437 | account = a; | 439 | account = a; |
438 | wrapper = AbstractMail::getWrapper( account ); | 440 | wrapper = AbstractMail::getWrapper( account ); |
439 | SETPIX(PIXMAP_IMAPFOLDER); | 441 | SETPIX(PIXMAP_IMAPFOLDER); |
440 | setText( 0, account->getAccountName() ); | 442 | setText( 0, account->getAccountName() ); |
441 | setOpen( true ); | 443 | setOpen( true ); |
442 | } | 444 | } |
443 | 445 | ||
444 | IMAPviewItem::~IMAPviewItem() | 446 | IMAPviewItem::~IMAPviewItem() |
445 | { | 447 | { |
446 | delete wrapper; | 448 | delete wrapper; |
447 | } | 449 | } |
448 | 450 | ||
449 | AbstractMail *IMAPviewItem::getWrapper() | 451 | AbstractMail *IMAPviewItem::getWrapper() |
450 | { | 452 | { |
451 | return wrapper; | 453 | return wrapper; |
452 | } | 454 | } |
453 | 455 | ||
454 | void IMAPviewItem::refresh(QValueList<RecMailP>&) | 456 | void IMAPviewItem::refresh(QValueList<RecMailP>&) |
455 | { | 457 | { |
456 | refreshFolders(false); | 458 | refreshFolders(false); |
457 | } | 459 | } |
458 | 460 | ||
459 | const QStringList&IMAPviewItem::subFolders() | 461 | const QStringList&IMAPviewItem::subFolders() |
460 | { | 462 | { |
461 | return currentFolders; | 463 | return currentFolders; |
462 | } | 464 | } |
463 | 465 | ||
464 | void IMAPviewItem::refreshFolders(bool force) | 466 | void IMAPviewItem::refreshFolders(bool force) |
465 | { | 467 | { |
466 | if (childCount()>0 && force==false) return; | 468 | if (childCount()>0 && force==false) return; |
467 | if (account->getOffline()) return; | 469 | if (account->getOffline()) return; |
468 | 470 | ||
469 | removeChilds(); | 471 | removeChilds(); |
470 | currentFolders.clear(); | 472 | currentFolders.clear(); |
471 | QValueList<FolderP> * folders = wrapper->listFolders(); | 473 | QValueList<FolderP> * folders = wrapper->listFolders(); |
472 | 474 | ||
473 | QValueList<FolderP>::Iterator it; | 475 | QValueList<FolderP>::Iterator it; |
474 | QListViewItem*item = 0; | 476 | QListViewItem*item = 0; |
475 | QListViewItem*titem = 0; | 477 | QListViewItem*titem = 0; |
476 | QString fname,del,search; | 478 | QString fname,del,search; |
477 | int pos; | 479 | int pos; |
478 | 480 | ||
479 | for ( it = folders->begin(); it!=folders->end(); ++it) | 481 | for ( it = folders->begin(); it!=folders->end(); ++it) |
480 | { | 482 | { |
481 | if ((*it)->getDisplayName().lower()=="inbox") | 483 | if ((*it)->getDisplayName().lower()=="inbox") |
482 | { | 484 | { |
483 | item = new IMAPfolderItem( (*it), this , item ); | 485 | item = new IMAPfolderItem( (*it), this , item ); |
484 | folders->remove(it); | 486 | folders->remove(it); |
485 | break; | 487 | break; |
486 | } | 488 | } |
487 | } | 489 | } |
488 | for ( it = folders->begin(); it!=folders->end(); ++it) | 490 | for ( it = folders->begin(); it!=folders->end(); ++it) |
489 | { | 491 | { |
490 | fname = (*it)->getDisplayName(); | 492 | fname = (*it)->getDisplayName(); |
491 | currentFolders.append((*it)->getName()); | 493 | currentFolders.append((*it)->getName()); |
492 | pos = fname.findRev((*it)->Separator()); | 494 | pos = fname.findRev((*it)->Separator()); |
493 | if (pos != -1) | 495 | if (pos != -1) |
494 | { | 496 | { |
495 | fname = fname.left(pos); | 497 | fname = fname.left(pos); |
496 | } | 498 | } |
497 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); | 499 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); |
498 | if (pitem) | 500 | if (pitem) |
499 | { | 501 | { |
500 | titem = item; | 502 | titem = item; |
501 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); | 503 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); |
502 | /* setup the short name */ | 504 | /* setup the short name */ |
503 | item->setText(0,(*it)->getDisplayName().mid(pos+1)); | 505 | item->setText(0,(*it)->getDisplayName().mid(pos+1)); |
504 | item = titem; | 506 | item = titem; |
505 | } | 507 | } |
506 | else | 508 | else |
507 | { | 509 | { |
508 | item = new IMAPfolderItem( (*it), this , item ); | 510 | item = new IMAPfolderItem( (*it), this , item ); |
509 | } | 511 | } |
510 | } | 512 | } |
511 | delete folders; | 513 | delete folders; |
512 | } | 514 | } |
513 | 515 | ||
514 | QPopupMenu * IMAPviewItem::getContextMenu() | 516 | QPopupMenu * IMAPviewItem::getContextMenu() |
515 | { | 517 | { |
516 | QPopupMenu *m = new QPopupMenu(0); | 518 | QPopupMenu *m = new QPopupMenu(0); |
517 | if (m) | 519 | if (m) |
518 | { | 520 | { |
519 | if (!account->getOffline()) | 521 | if (!account->getOffline()) |
520 | { | 522 | { |
521 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); | 523 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); |
522 | m->insertItem(i18n("Refresh folder list"),0); | 524 | m->insertItem(i18n("Refresh folder list"),0); |
523 | m->insertItem(i18n("Create new folder"),1); | 525 | m->insertItem(i18n("Create new folder"),1); |
524 | m->insertSeparator(); | 526 | m->insertSeparator(); |
525 | m->insertItem(i18n("Disconnect"),2); | 527 | m->insertItem(i18n("Disconnect"),2); |
526 | m->insertItem(i18n("Set offline"),3); | 528 | m->insertItem(i18n("Set offline"),3); |
527 | m->insertSeparator(); | 529 | m->insertSeparator(); |
528 | } | 530 | } |
529 | else | 531 | else |
530 | { | 532 | { |
531 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); | 533 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); |
532 | m->insertItem(i18n("Set online"),3); | 534 | m->insertItem(i18n("Set online"),3); |
533 | } | 535 | } |
534 | } | 536 | } |
535 | return m; | 537 | return m; |
536 | } | 538 | } |
537 | 539 | ||
538 | void IMAPviewItem::createNewFolder() | 540 | void IMAPviewItem::createNewFolder() |
539 | { | 541 | { |
540 | Newmdirdlg ndirdlg; | 542 | Newmdirdlg ndirdlg; |
541 | 543 | ||
542 | ndirdlg.showMaximized(); | 544 | #ifndef DESKTOP_VERSION |
545 | //ndirdlg.showMaximized(); | ||
546 | #endif | ||
543 | if ( ndirdlg.exec() ) | 547 | if ( ndirdlg.exec() ) |
544 | { | 548 | { |
545 | QString ndir = ndirdlg.Newdir(); | 549 | QString ndir = ndirdlg.Newdir(); |
546 | bool makesubs = ndirdlg.subpossible(); | 550 | bool makesubs = ndirdlg.subpossible(); |
547 | QString delemiter = "/"; | 551 | QString delemiter = "/"; |
548 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); | 552 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); |
549 | if (item) | 553 | if (item) |
550 | { | 554 | { |
551 | delemiter = item->Delemiter(); | 555 | delemiter = item->Delemiter(); |
552 | } | 556 | } |
553 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) | 557 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) |
554 | { | 558 | { |
555 | refreshFolders(true); | 559 | refreshFolders(true); |
556 | } | 560 | } |
557 | } | 561 | } |
558 | } | 562 | } |
559 | 563 | ||
560 | void IMAPviewItem::contextMenuSelected(int id) | 564 | void IMAPviewItem::contextMenuSelected(int id) |
561 | { | 565 | { |
562 | 566 | ||
563 | switch (id) | 567 | switch (id) |
564 | { | 568 | { |
565 | case 0: | 569 | case 0: |
566 | refreshFolders(true); | 570 | refreshFolders(true); |
567 | break; | 571 | break; |
568 | case 1: | 572 | case 1: |
569 | createNewFolder(); | 573 | createNewFolder(); |
570 | break; | 574 | break; |
571 | case 2: | 575 | case 2: |
572 | removeChilds(); | 576 | removeChilds(); |
573 | wrapper->logout(); | 577 | wrapper->logout(); |
574 | break; | 578 | break; |
575 | case 3: | 579 | case 3: |
576 | if (account->getOffline()==false) | 580 | if (account->getOffline()==false) |
577 | { | 581 | { |
578 | removeChilds(); | 582 | removeChilds(); |
579 | wrapper->logout(); | 583 | wrapper->logout(); |
580 | } | 584 | } |
581 | account->setOffline(!account->getOffline()); | 585 | account->setOffline(!account->getOffline()); |
582 | account->save(); | 586 | account->save(); |
583 | SETPIX(PIXMAP_IMAPFOLDER); | 587 | SETPIX(PIXMAP_IMAPFOLDER); |
584 | refreshFolders(false); | 588 | refreshFolders(false); |
585 | break; | 589 | break; |
586 | case GET_NEW_MAILS: // daunlood | 590 | case GET_NEW_MAILS: // daunlood |
587 | { | 591 | { |
588 | if (account->getOffline()) { | 592 | if (account->getOffline()) { |
589 | contextMenuSelected( 3 ); | 593 | contextMenuSelected( 3 ); |
590 | } | 594 | } |
591 | AccountView*bl = accountView(); | 595 | AccountView*bl = accountView(); |
592 | if (!bl) return; | 596 | if (!bl) return; |
593 | AccountViewItem* in = findSubItem( "inbox" , 0); | 597 | AccountViewItem* in = findSubItem( "inbox" , 0); |
594 | if ( ! in ) | 598 | if ( ! in ) |
595 | return; | 599 | return; |
596 | bl->downloadMailsInbox(in->getFolder(),getWrapper()); | 600 | bl->downloadMailsInbox(in->getFolder(),getWrapper()); |
597 | } | 601 | } |
598 | break; | 602 | break; |
599 | default: | 603 | default: |
600 | break; | 604 | break; |
601 | } | 605 | } |
602 | } | 606 | } |
603 | 607 | ||
604 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) | 608 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) |
605 | { | 609 | { |
606 | return new RecBody(); | 610 | return new RecBody(); |
607 | } | 611 | } |
608 | 612 | ||
609 | bool IMAPviewItem::offline() | 613 | bool IMAPviewItem::offline() |
610 | { | 614 | { |
611 | return account->getOffline(); | 615 | return account->getOffline(); |
612 | } | 616 | } |
613 | 617 | ||
614 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) | 618 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) |
615 | : AccountViewItem( folderInit, parent , after ) | 619 | : AccountViewItem( folderInit, parent , after ) |
616 | { | 620 | { |
617 | imap = parent; | 621 | imap = parent; |
618 | if (folder->getDisplayName().lower()!="inbox") | 622 | if (folder->getDisplayName().lower()!="inbox") |
619 | { | 623 | { |
620 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 624 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
621 | } | 625 | } |
622 | else | 626 | else |
623 | { | 627 | { |
624 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 628 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
625 | } | 629 | } |
626 | setText( 0, folder->getDisplayName() ); | 630 | setText( 0, folder->getDisplayName() ); |
627 | } | 631 | } |
628 | 632 | ||
629 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) | 633 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) |
630 | : AccountViewItem(folderInit, parent,after ) | 634 | : AccountViewItem(folderInit, parent,after ) |
631 | { | 635 | { |
632 | imap = master; | 636 | imap = master; |
633 | if (folder->getDisplayName().lower()!="inbox") | 637 | if (folder->getDisplayName().lower()!="inbox") |
634 | { | 638 | { |
635 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 639 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
636 | } | 640 | } |
637 | else | 641 | else |
638 | { | 642 | { |
639 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 643 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
640 | } | 644 | } |
641 | setText( 0, folder->getDisplayName() ); | 645 | setText( 0, folder->getDisplayName() ); |
642 | } | 646 | } |
643 | 647 | ||
644 | IMAPfolderItem::~IMAPfolderItem() | 648 | IMAPfolderItem::~IMAPfolderItem() |
645 | {} | 649 | {} |
646 | 650 | ||
647 | const QString& IMAPfolderItem::Delemiter()const | 651 | const QString& IMAPfolderItem::Delemiter()const |
648 | { | 652 | { |
649 | return folder->Separator(); | 653 | return folder->Separator(); |
650 | } | 654 | } |
651 | 655 | ||
652 | void IMAPfolderItem::refresh(QValueList<RecMailP>&target) | 656 | void IMAPfolderItem::refresh(QValueList<RecMailP>&target) |
653 | { | 657 | { |
654 | if (folder->may_select()) | 658 | if (folder->may_select()) |
655 | { | 659 | { |
656 | imap->getWrapper()->listMessages( folder->getName(),target ); | 660 | imap->getWrapper()->listMessages( folder->getName(),target ); |
657 | } | 661 | } |
658 | else | 662 | else |
659 | { | 663 | { |
660 | target.clear(); | 664 | target.clear(); |
661 | } | 665 | } |
662 | } | 666 | } |
663 | 667 | ||
664 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) | 668 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) |
665 | { | 669 | { |
666 | return imap->getWrapper()->fetchBody(aMail); | 670 | return imap->getWrapper()->fetchBody(aMail); |
667 | } | 671 | } |
668 | 672 | ||
669 | QPopupMenu * IMAPfolderItem::getContextMenu() | 673 | QPopupMenu * IMAPfolderItem::getContextMenu() |
670 | { | 674 | { |
671 | QPopupMenu *m = new QPopupMenu(0); | 675 | QPopupMenu *m = new QPopupMenu(0); |
672 | if (m) | 676 | if (m) |
673 | { | 677 | { |
674 | if (folder->may_select()) | 678 | if (folder->may_select()) |
675 | { | 679 | { |
676 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); | 680 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); |
677 | m->insertItem(i18n("Refresh header list"),0); | 681 | m->insertItem(i18n("Refresh header list"),0); |
678 | m->insertItem(i18n("Move/Copie all mails"),4); | 682 | m->insertItem(i18n("Move/Copie all mails"),4); |
679 | m->insertItem(i18n("Delete all mails"),1); | 683 | m->insertItem(i18n("Delete all mails"),1); |
680 | } | 684 | } |
681 | if (folder->no_inferior()==false) | 685 | if (folder->no_inferior()==false) |
682 | { | 686 | { |
683 | m->insertItem(i18n("Create new subfolder"),2); | 687 | m->insertItem(i18n("Create new subfolder"),2); |
684 | } | 688 | } |
685 | if (folder->getDisplayName().lower()!="inbox") | 689 | if (folder->getDisplayName().lower()!="inbox") |
686 | { | 690 | { |
687 | m->insertItem(i18n("Delete folder"),3); | 691 | m->insertItem(i18n("Delete folder"),3); |
688 | } | 692 | } |
689 | } | 693 | } |
690 | return m; | 694 | return m; |
691 | } | 695 | } |
692 | 696 | ||
693 | void IMAPfolderItem::createNewFolder() | 697 | void IMAPfolderItem::createNewFolder() |
694 | { | 698 | { |
695 | Newmdirdlg ndirdlg; | 699 | Newmdirdlg ndirdlg; |
696 | ndirdlg.showMaximized(); | 700 | //ndirdlg.showMaximized(); |
697 | if ( ndirdlg.exec() ) | 701 | if ( ndirdlg.exec() ) |
698 | { | 702 | { |
699 | QString ndir = ndirdlg.Newdir(); | 703 | QString ndir = ndirdlg.Newdir(); |
700 | bool makesubs = ndirdlg.subpossible(); | 704 | bool makesubs = ndirdlg.subpossible(); |
701 | QString delemiter = Delemiter(); | 705 | QString delemiter = Delemiter(); |
702 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) | 706 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) |
703 | { | 707 | { |
704 | imap->refreshFolders(true); | 708 | imap->refreshFolders(true); |
705 | } | 709 | } |
706 | } | 710 | } |
707 | } | 711 | } |
708 | 712 | ||
709 | void IMAPfolderItem::deleteFolder() | 713 | void IMAPfolderItem::deleteFolder() |
710 | { | 714 | { |
711 | int yesno = QMessageBox::warning(0,i18n("Delete folder"), | 715 | int yesno = QMessageBox::warning(0,i18n("Delete folder"), |
712 | i18n("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>").arg(folder->getDisplayName()), | 716 | i18n("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>").arg(folder->getDisplayName()), |
713 | i18n("Yes"), | 717 | i18n("Yes"), |
714 | i18n("No"),QString::null,1,1); | 718 | i18n("No"),QString::null,1,1); |
715 | 719 | ||
716 | if (yesno == 0) | 720 | if (yesno == 0) |
717 | { | 721 | { |
718 | if (imap->getWrapper()->deleteMbox(folder)) | 722 | if (imap->getWrapper()->deleteMbox(folder)) |
719 | { | 723 | { |
720 | QListView*v=listView(); | 724 | QListView*v=listView(); |
721 | IMAPviewItem * box = imap; | 725 | IMAPviewItem * box = imap; |
722 | /* be carefull - after that this object is destroyd so don't use | 726 | /* be carefull - after that this object is destroyd so don't use |
723 | * any member of it after that call!!*/ | 727 | * any member of it after that call!!*/ |
724 | imap->refreshFolders(true); | 728 | imap->refreshFolders(true); |
725 | if (v) | 729 | if (v) |
726 | { | 730 | { |
727 | v->setSelected(box,true); | 731 | v->setSelected(box,true); |
728 | } | 732 | } |
729 | } | 733 | } |
730 | } | 734 | } |
731 | } | 735 | } |
732 | 736 | ||
733 | void IMAPfolderItem::downloadMails() | 737 | void IMAPfolderItem::downloadMails() |
734 | { | 738 | { |
735 | AccountView*bl = imap->accountView(); | 739 | AccountView*bl = imap->accountView(); |
736 | if (!bl) return; | 740 | if (!bl) return; |
737 | bl->downloadMails(folder,imap->getWrapper()); | 741 | bl->downloadMails(folder,imap->getWrapper()); |
738 | } | 742 | } |
739 | 743 | ||
740 | void IMAPfolderItem::contextMenuSelected(int id) | 744 | void IMAPfolderItem::contextMenuSelected(int id) |
741 | { | 745 | { |
742 | 746 | ||
743 | AccountView * view = (AccountView*)listView(); | 747 | AccountView * view = (AccountView*)listView(); |
744 | switch(id) | 748 | switch(id) |
745 | { | 749 | { |
746 | case 0: | 750 | case 0: |
747 | view->refreshCurrent(); | 751 | view->refreshCurrent(); |
748 | break; | 752 | break; |
749 | case 1: | 753 | case 1: |
750 | deleteAllMail(imap->getWrapper(),folder); | 754 | deleteAllMail(imap->getWrapper(),folder); |
751 | break; | 755 | break; |
752 | case 2: | 756 | case 2: |
753 | createNewFolder(); | 757 | createNewFolder(); |
754 | break; | 758 | break; |
755 | case 3: | 759 | case 3: |
756 | deleteFolder(); | 760 | deleteFolder(); |
757 | break; | 761 | break; |
758 | case 4: | 762 | case 4: |
759 | downloadMails(); | 763 | downloadMails(); |
760 | break; | 764 | break; |
761 | case GET_NEW_MAILS: // daunlood | 765 | case GET_NEW_MAILS: // daunlood |
762 | { | 766 | { |
763 | if (!view) return; | 767 | if (!view) return; |
764 | view->downloadMailsInbox(getFolder(),imap->getWrapper()); | 768 | view->downloadMailsInbox(getFolder(),imap->getWrapper()); |
765 | } | 769 | } |
766 | break; | 770 | break; |
767 | default: | 771 | default: |
768 | break; | 772 | break; |
769 | } | 773 | } |
770 | } | 774 | } |
771 | 775 | ||
772 | /** | 776 | /** |
773 | * MH Account stuff | 777 | * MH Account stuff |
774 | */ | 778 | */ |
775 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and | 779 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and |
776 | POP3 and MBOX */ | 780 | POP3 and MBOX */ |
777 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) | 781 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) |
778 | : AccountViewItem( parent ) | 782 | : AccountViewItem( parent ) |
779 | { | 783 | { |
780 | m_Path = aPath; | 784 | m_Path = aPath; |
781 | /* be carefull - the space within settext is wanted - thats why the string twice */ | 785 | /* be carefull - the space within settext is wanted - thats why the string twice */ |
782 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); | 786 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); |
783 | setPixmap( 0, PIXMAP_LOCALFOLDER ); | 787 | setPixmap( 0, PIXMAP_LOCALFOLDER ); |
784 | setText( 0, " Local Folders" ); | 788 | setText( 0, " Local Folders" ); |
785 | setOpen( true ); | 789 | setOpen( true ); |
786 | folder = 0; | 790 | folder = 0; |
787 | } | 791 | } |
788 | 792 | ||
789 | MHviewItem::~MHviewItem() | 793 | MHviewItem::~MHviewItem() |
790 | { | 794 | { |
791 | delete wrapper; | 795 | delete wrapper; |
792 | } | 796 | } |
793 | 797 | ||
794 | AbstractMail *MHviewItem::getWrapper() | 798 | AbstractMail *MHviewItem::getWrapper() |
795 | { | 799 | { |
796 | return wrapper; | 800 | return wrapper; |
797 | } | 801 | } |
798 | 802 | ||
799 | void MHviewItem::refresh( QValueList<RecMailP> & target) | 803 | void MHviewItem::refresh( QValueList<RecMailP> & target) |
800 | { | 804 | { |
801 | refresh(false); | 805 | refresh(false); |
802 | getWrapper()->listMessages( "",target ); | 806 | getWrapper()->listMessages( "",target ); |
803 | } | 807 | } |
804 | 808 | ||
805 | void MHviewItem::refresh(bool force) | 809 | void MHviewItem::refresh(bool force) |
806 | { | 810 | { |
807 | if (childCount()>0 && force==false) return; | 811 | if (childCount()>0 && force==false) return; |
808 | removeChilds(); | 812 | removeChilds(); |
809 | currentFolders.clear(); | 813 | currentFolders.clear(); |
810 | QValueList<FolderP> *folders = wrapper->listFolders(); | 814 | QValueList<FolderP> *folders = wrapper->listFolders(); |
811 | QValueList<FolderP>::ConstIterator it; | 815 | QValueList<FolderP>::ConstIterator it; |
812 | MHfolderItem*item = 0; | 816 | MHfolderItem*item = 0; |
813 | MHfolderItem*pmaster = 0; | 817 | MHfolderItem*pmaster = 0; |
814 | QString fname = ""; | 818 | QString fname = ""; |
815 | int pos; | 819 | int pos; |
816 | for ( it = folders->begin(); it!=folders->end(); ++it) | 820 | for ( it = folders->begin(); it!=folders->end(); ++it) |
817 | { | 821 | { |
818 | fname = (*it)->getDisplayName(); | 822 | fname = (*it)->getDisplayName(); |
819 | /* this folder itself */ | 823 | /* this folder itself */ |
820 | if (fname=="/") | 824 | if (fname=="/") |
821 | { | 825 | { |
822 | currentFolders.append(fname); | 826 | currentFolders.append(fname); |
823 | folder = (*it); | 827 | folder = (*it); |
824 | continue; | 828 | continue; |
825 | } | 829 | } |
826 | currentFolders.append(fname); | 830 | currentFolders.append(fname); |
827 | pos = fname.findRev("/"); | 831 | pos = fname.findRev("/"); |
828 | if (pos > 0) | 832 | if (pos > 0) |
829 | { | 833 | { |
830 | fname = fname.left(pos); | 834 | fname = fname.left(pos); |
831 | pmaster = (MHfolderItem*)findSubItem(fname); | 835 | pmaster = (MHfolderItem*)findSubItem(fname); |
832 | } | 836 | } |
833 | else | 837 | else |
834 | { | 838 | { |
835 | pmaster = 0; | 839 | pmaster = 0; |
836 | } | 840 | } |
837 | if (pmaster) | 841 | if (pmaster) |
838 | { | 842 | { |
839 | item = new MHfolderItem( (*it), pmaster, item, this ); | 843 | item = new MHfolderItem( (*it), pmaster, item, this ); |
840 | } | 844 | } |
841 | else | 845 | else |
842 | { | 846 | { |
843 | item = new MHfolderItem( (*it), this , item ); | 847 | item = new MHfolderItem( (*it), this , item ); |
844 | } | 848 | } |
845 | item->setSelectable((*it)->may_select()); | 849 | item->setSelectable((*it)->may_select()); |
846 | } | 850 | } |
847 | delete folders; | 851 | delete folders; |
848 | } | 852 | } |
849 | 853 | ||
850 | RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) | 854 | RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) |
851 | { | 855 | { |
852 | 856 | ||
853 | return wrapper->fetchBody( mail ); | 857 | return wrapper->fetchBody( mail ); |
854 | } | 858 | } |
855 | 859 | ||
856 | QPopupMenu * MHviewItem::getContextMenu() | 860 | QPopupMenu * MHviewItem::getContextMenu() |
857 | { | 861 | { |
858 | QPopupMenu *m = new QPopupMenu(0); | 862 | QPopupMenu *m = new QPopupMenu(0); |
859 | if (m) | 863 | if (m) |
860 | { | 864 | { |
861 | m->insertItem(i18n("Refresh folder list"),0); | 865 | m->insertItem(i18n("Refresh folder list"),0); |
862 | m->insertItem(i18n("Create new folder"),1); | 866 | m->insertItem(i18n("Create new folder"),1); |
863 | m->insertItem(i18n("Delete all mails"),2); | 867 | m->insertItem(i18n("Delete all mails"),2); |
864 | m->insertItem(i18n("Move/Copie all mails"),3); | 868 | m->insertItem(i18n("Move/Copie all mails"),3); |
865 | } | 869 | } |
866 | return m; | 870 | return m; |
867 | } | 871 | } |
868 | 872 | ||
869 | void MHviewItem::createFolder() | 873 | void MHviewItem::createFolder() |
870 | { | 874 | { |
871 | Newmdirdlg ndirdlg(0,0,true); | 875 | Newmdirdlg ndirdlg(0,0,true); |
872 | ndirdlg.showMaximized(); | 876 | //ndirdlg.showMaximized(); |
873 | if ( ndirdlg.exec() ) | 877 | if ( ndirdlg.exec() ) |
874 | { | 878 | { |
875 | QString ndir = ndirdlg.Newdir(); | 879 | QString ndir = ndirdlg.Newdir(); |
876 | if (wrapper->createMbox(ndir)) | 880 | if (wrapper->createMbox(ndir)) |
877 | { | 881 | { |
878 | refresh(true); | 882 | refresh(true); |
879 | } | 883 | } |
880 | } | 884 | } |
881 | } | 885 | } |
882 | 886 | ||
883 | void MHviewItem::downloadMails() | 887 | void MHviewItem::downloadMails() |
884 | { | 888 | { |
885 | AccountView*bl = accountView(); | 889 | AccountView*bl = accountView(); |
886 | if (!bl) return; | 890 | if (!bl) return; |
887 | bl->downloadMails(folder,getWrapper()); | 891 | bl->downloadMails(folder,getWrapper()); |
888 | } | 892 | } |
889 | 893 | ||
890 | QStringList MHviewItem::subFolders() | 894 | QStringList MHviewItem::subFolders() |
891 | { | 895 | { |
892 | return currentFolders; | 896 | return currentFolders; |
893 | } | 897 | } |
894 | 898 | ||
895 | void MHviewItem::contextMenuSelected(int which) | 899 | void MHviewItem::contextMenuSelected(int which) |
896 | { | 900 | { |
897 | switch (which) | 901 | switch (which) |
898 | { | 902 | { |
899 | case 0: | 903 | case 0: |
900 | refresh(true); | 904 | refresh(true); |
901 | break; | 905 | break; |
902 | case 1: | 906 | case 1: |
903 | createFolder(); | 907 | createFolder(); |
904 | break; | 908 | break; |
905 | case 2: | 909 | case 2: |
906 | deleteAllMail(getWrapper(),folder); | 910 | deleteAllMail(getWrapper(),folder); |
907 | break; | 911 | break; |
908 | case 3: | 912 | case 3: |
909 | downloadMails(); | 913 | downloadMails(); |
910 | break; | 914 | break; |
911 | default: | 915 | default: |
912 | break; | 916 | break; |
913 | } | 917 | } |
914 | } | 918 | } |
915 | 919 | ||
916 | MHfolderItem::~MHfolderItem() | 920 | MHfolderItem::~MHfolderItem() |
917 | {} | 921 | {} |
918 | 922 | ||
919 | MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) | 923 | MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) |
920 | : AccountViewItem(folderInit, parent,after ) | 924 | : AccountViewItem(folderInit, parent,after ) |
921 | { | 925 | { |
922 | mbox = parent; | 926 | mbox = parent; |
923 | initName(); | 927 | initName(); |
924 | } | 928 | } |
925 | 929 | ||
926 | MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) | 930 | MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) |
927 | : AccountViewItem(folderInit, parent,after ) | 931 | : AccountViewItem(folderInit, parent,after ) |
928 | { | 932 | { |
929 | folder = folderInit; | 933 | folder = folderInit; |
930 | mbox = master; | 934 | mbox = master; |
931 | initName(); | 935 | initName(); |
932 | } | 936 | } |
933 | 937 | ||
934 | void MHfolderItem::initName() | 938 | void MHfolderItem::initName() |
935 | { | 939 | { |
936 | QString bName = folder->getDisplayName(); | 940 | QString bName = folder->getDisplayName(); |
937 | if (bName.startsWith("/")&&bName.length()>1) | 941 | if (bName.startsWith("/")&&bName.length()>1) |
938 | { | 942 | { |
939 | bName.replace(0,1,""); | 943 | bName.replace(0,1,""); |
940 | } | 944 | } |
941 | int pos = bName.findRev("/"); | 945 | int pos = bName.findRev("/"); |
942 | if (pos > 0) | 946 | if (pos > 0) |
943 | { | 947 | { |
944 | bName.replace(0,pos+1,""); | 948 | bName.replace(0,pos+1,""); |
945 | } | 949 | } |
946 | if (bName.lower() == "outgoing") | 950 | if (bName.lower() == "outgoing") |
947 | { | 951 | { |
948 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); | 952 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); |
949 | } | 953 | } |
950 | else if (bName.lower() == "inbox") | 954 | else if (bName.lower() == "inbox") |
951 | { | 955 | { |
952 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 956 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
953 | } else if (bName.lower() == "drafts") { | 957 | } else if (bName.lower() == "drafts") { |
954 | setPixmap(0, SmallIcon ("edit")); | 958 | setPixmap(0, SmallIcon ("edit")); |
955 | } else { | 959 | } else { |
956 | setPixmap( 0, PIXMAP_MBOXFOLDER ); | 960 | setPixmap( 0, PIXMAP_MBOXFOLDER ); |
957 | } | 961 | } |
958 | setText( 0, bName ); | 962 | setText( 0, bName ); |
959 | } | 963 | } |
960 | 964 | ||
961 | const FolderP&MHfolderItem::getFolder()const | 965 | const FolderP&MHfolderItem::getFolder()const |
962 | { | 966 | { |
963 | return folder; | 967 | return folder; |
964 | } | 968 | } |
965 | 969 | ||
966 | void MHfolderItem::refresh(QValueList<RecMailP>&target) | 970 | void MHfolderItem::refresh(QValueList<RecMailP>&target) |
967 | { | 971 | { |
968 | if (folder->may_select()) | 972 | if (folder->may_select()) |
969 | mbox->getWrapper()->listMessages( folder->getName(),target ); | 973 | mbox->getWrapper()->listMessages( folder->getName(),target ); |
970 | } | 974 | } |
971 | 975 | ||
972 | RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) | 976 | RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) |
973 | { | 977 | { |
974 | return mbox->getWrapper()->fetchBody(aMail); | 978 | return mbox->getWrapper()->fetchBody(aMail); |
975 | } | 979 | } |
976 | 980 | ||
977 | void MHfolderItem::deleteFolder() | 981 | void MHfolderItem::deleteFolder() |
978 | { | 982 | { |
979 | int yesno = QMessageBox::warning(0,i18n("Delete folder"), | 983 | int yesno = QMessageBox::warning(0,i18n("Delete folder"), |
980 | i18n("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>").arg(folder->getDisplayName()), | 984 | i18n("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>").arg(folder->getDisplayName()), |
981 | i18n("Yes"), | 985 | i18n("Yes"), |
982 | i18n("No"),QString::null,1,1); | 986 | i18n("No"),QString::null,1,1); |
983 | 987 | ||
984 | if (yesno == 0) | 988 | if (yesno == 0) |
985 | { | 989 | { |
986 | if (mbox->getWrapper()->deleteMbox(folder)) | 990 | if (mbox->getWrapper()->deleteMbox(folder)) |
987 | { | 991 | { |
988 | QListView*v=listView(); | 992 | QListView*v=listView(); |
989 | MHviewItem * box = mbox; | 993 | MHviewItem * box = mbox; |
990 | /* be carefull - after that this object is destroyd so don't use | 994 | /* be carefull - after that this object is destroyd so don't use |
991 | * any member of it after that call!!*/ | 995 | * any member of it after that call!!*/ |
992 | mbox->refresh(true); | 996 | mbox->refresh(true); |
993 | if (v) | 997 | if (v) |
994 | { | 998 | { |
995 | v->setSelected(box,true); | 999 | v->setSelected(box,true); |
996 | } | 1000 | } |
997 | } | 1001 | } |
998 | } | 1002 | } |
999 | } | 1003 | } |
1000 | 1004 | ||
1001 | QPopupMenu * MHfolderItem::getContextMenu() | 1005 | QPopupMenu * MHfolderItem::getContextMenu() |
1002 | { | 1006 | { |
1003 | QPopupMenu *m = new QPopupMenu(0); | 1007 | QPopupMenu *m = new QPopupMenu(0); |
1004 | if (m) | 1008 | if (m) |
1005 | { | 1009 | { |
1006 | m->insertItem(i18n("Move/Copie all mails"),2); | 1010 | m->insertItem(i18n("Move/Copie all mails"),2); |
1007 | m->insertItem(i18n("Delete all mails"),0); | 1011 | m->insertItem(i18n("Delete all mails"),0); |
1008 | m->insertItem(i18n("Create new subfolder"),3); | 1012 | m->insertItem(i18n("Create new subfolder"),3); |
1009 | m->insertItem(i18n("Delete folder"),1); | 1013 | m->insertItem(i18n("Delete folder"),1); |
1010 | } | 1014 | } |
1011 | return m; | 1015 | return m; |
1012 | } | 1016 | } |
1013 | 1017 | ||
1014 | void MHfolderItem::downloadMails() | 1018 | void MHfolderItem::downloadMails() |
1015 | { | 1019 | { |
1016 | AccountView*bl = mbox->accountView(); | 1020 | AccountView*bl = mbox->accountView(); |
1017 | if (!bl) return; | 1021 | if (!bl) return; |
1018 | bl->downloadMails(folder,mbox->getWrapper()); | 1022 | bl->downloadMails(folder,mbox->getWrapper()); |
1019 | } | 1023 | } |
1020 | 1024 | ||
1021 | void MHfolderItem::createFolder() | 1025 | void MHfolderItem::createFolder() |
1022 | { | 1026 | { |
1023 | Newmdirdlg ndirdlg(0,0,true); | 1027 | Newmdirdlg ndirdlg(0,0,true); |
1024 | ndirdlg.showMaximized(); | 1028 | //ndirdlg.showMaximized(); |
1025 | if (ndirdlg.exec() ) | 1029 | if (ndirdlg.exec() ) |
1026 | { | 1030 | { |
1027 | QString ndir = ndirdlg.Newdir(); | 1031 | QString ndir = ndirdlg.Newdir(); |
1028 | if (mbox->getWrapper()->createMbox(ndir,folder)) | 1032 | if (mbox->getWrapper()->createMbox(ndir,folder)) |
1029 | { | 1033 | { |
1030 | QListView*v=listView(); | 1034 | QListView*v=listView(); |
1031 | MHviewItem * box = mbox; | 1035 | MHviewItem * box = mbox; |
1032 | /* be carefull - after that this object is destroyd so don't use | 1036 | /* be carefull - after that this object is destroyd so don't use |
1033 | * any member of it after that call!!*/ | 1037 | * any member of it after that call!!*/ |
1034 | mbox->refresh(true); | 1038 | mbox->refresh(true); |
1035 | if (v) | 1039 | if (v) |
1036 | { | 1040 | { |
1037 | v->setSelected(box,true); | 1041 | v->setSelected(box,true); |
1038 | } | 1042 | } |
1039 | } | 1043 | } |
1040 | } | 1044 | } |
1041 | } | 1045 | } |
1042 | 1046 | ||
1043 | void MHfolderItem::contextMenuSelected(int which) | 1047 | void MHfolderItem::contextMenuSelected(int which) |
1044 | { | 1048 | { |
1045 | switch(which) | 1049 | switch(which) |
1046 | { | 1050 | { |
1047 | case 0: | 1051 | case 0: |
1048 | deleteAllMail(mbox->getWrapper(),folder); | 1052 | deleteAllMail(mbox->getWrapper(),folder); |
1049 | break; | 1053 | break; |
1050 | case 1: | 1054 | case 1: |
1051 | deleteFolder(); | 1055 | deleteFolder(); |
1052 | break; | 1056 | break; |
1053 | case 2: | 1057 | case 2: |
1054 | downloadMails(); | 1058 | downloadMails(); |
1055 | break; | 1059 | break; |
1056 | case 3: | 1060 | case 3: |
1057 | createFolder(); | 1061 | createFolder(); |
1058 | break; | 1062 | break; |
1059 | default: | 1063 | default: |
1060 | break; | 1064 | break; |
1061 | } | 1065 | } |
1062 | } | 1066 | } |
1063 | 1067 | ||
1064 | bool MHfolderItem::isDraftfolder() | 1068 | bool MHfolderItem::isDraftfolder() |
1065 | { | 1069 | { |
1066 | if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; | 1070 | if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; |
1067 | return false; | 1071 | return false; |
1068 | } | 1072 | } |
1069 | 1073 | ||
1070 | /** | 1074 | /** |
1071 | * Generic stuff | 1075 | * Generic stuff |
1072 | */ | 1076 | */ |
1073 | 1077 | ||
1074 | const QString AccountViewItem::contextName="AccountViewItem"; | 1078 | const QString AccountViewItem::contextName="AccountViewItem"; |
1075 | 1079 | ||
1076 | AccountViewItem::AccountViewItem( AccountView *parent ) | 1080 | AccountViewItem::AccountViewItem( AccountView *parent ) |
1077 | : QListViewItem( parent ) | 1081 | : QListViewItem( parent ) |
1078 | { | 1082 | { |
1079 | init(); | 1083 | init(); |
1080 | m_Backlink = parent; | 1084 | m_Backlink = parent; |
1081 | } | 1085 | } |
1082 | 1086 | ||
1083 | AccountViewItem::AccountViewItem( QListViewItem *parent) | 1087 | AccountViewItem::AccountViewItem( QListViewItem *parent) |
1084 | : QListViewItem( parent),folder(0) | 1088 | : QListViewItem( parent),folder(0) |
1085 | { | 1089 | { |
1086 | init(); | 1090 | init(); |
1087 | } | 1091 | } |
1088 | 1092 | ||
1089 | AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) | 1093 | AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) |
1090 | :QListViewItem( parent,after ),folder(0) | 1094 | :QListViewItem( parent,after ),folder(0) |
1091 | { | 1095 | { |
1092 | init(); | 1096 | init(); |
1093 | } | 1097 | } |
1094 | 1098 | ||
1095 | AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ) | 1099 | AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ) |
1096 | :QListViewItem( parent,after ),folder(folderInit) | 1100 | :QListViewItem( parent,after ),folder(folderInit) |
1097 | { | 1101 | { |
1098 | init(); | 1102 | init(); |
1099 | } | 1103 | } |
1100 | 1104 | ||
1101 | void AccountViewItem::init() | 1105 | void AccountViewItem::init() |
1102 | { | 1106 | { |
1103 | m_Backlink = 0; | 1107 | m_Backlink = 0; |
1104 | } | 1108 | } |
1105 | 1109 | ||
1106 | AccountViewItem::~AccountViewItem() | 1110 | AccountViewItem::~AccountViewItem() |
1107 | { | 1111 | { |
1108 | folder = 0; | 1112 | folder = 0; |
1109 | } | 1113 | } |
1110 | 1114 | ||
1111 | AccountView*AccountViewItem::accountView() | 1115 | AccountView*AccountViewItem::accountView() |
1112 | { | 1116 | { |
1113 | return m_Backlink; | 1117 | return m_Backlink; |
1114 | } | 1118 | } |
1115 | 1119 | ||
1116 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder) | 1120 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder) |
1117 | { | 1121 | { |
1118 | if (!wrapper) return; | 1122 | if (!wrapper) return; |
1119 | QString fname=""; | 1123 | QString fname=""; |
1120 | if (folder) fname = folder->getDisplayName(); | 1124 | if (folder) fname = folder->getDisplayName(); |
1121 | int yesno = QMessageBox::warning(0,i18n("Delete all mails"), | 1125 | int yesno = QMessageBox::warning(0,i18n("Delete all mails"), |
1122 | i18n("<center>Realy delete all mails in box <br>%1</center>"). | 1126 | i18n("<center>Realy delete all mails in box <br>%1</center>"). |
1123 | arg(fname), | 1127 | arg(fname), |
1124 | i18n("Yes"), | 1128 | i18n("Yes"), |
1125 | i18n("No"),QString::null,1,1); | 1129 | i18n("No"),QString::null,1,1); |
1126 | 1130 | ||
1127 | if (yesno == 0) | 1131 | if (yesno == 0) |
1128 | { | 1132 | { |
1129 | if (wrapper->deleteAllMail(folder)) | 1133 | if (wrapper->deleteAllMail(folder)) |
1130 | { | 1134 | { |
1131 | AccountView * view = (AccountView*)listView(); | 1135 | AccountView * view = (AccountView*)listView(); |
1132 | if (view) view->refreshCurrent(); | 1136 | if (view) view->refreshCurrent(); |
1133 | } | 1137 | } |
1134 | } | 1138 | } |
1135 | } | 1139 | } |
1136 | 1140 | ||
1137 | void AccountViewItem::removeChilds() | 1141 | void AccountViewItem::removeChilds() |
1138 | { | 1142 | { |
1139 | QListViewItem *child = firstChild(); | 1143 | QListViewItem *child = firstChild(); |
1140 | while ( child ) | 1144 | while ( child ) |
1141 | { | 1145 | { |
1142 | QListViewItem *tmp = child; | 1146 | QListViewItem *tmp = child; |
1143 | child = child->nextSibling(); | 1147 | child = child->nextSibling(); |
1144 | delete tmp; | 1148 | delete tmp; |
1145 | } | 1149 | } |
1146 | } | 1150 | } |
1147 | 1151 | ||
1148 | bool AccountViewItem::matchName(const QString&name)const | 1152 | bool AccountViewItem::matchName(const QString&name)const |
1149 | { | 1153 | { |
1150 | if (!folder) return false; | 1154 | if (!folder) return false; |
1151 | return folder->getDisplayName().lower()==name.lower(); | 1155 | return folder->getDisplayName().lower()==name.lower(); |
1152 | } | 1156 | } |
1153 | 1157 | ||
1154 | 1158 | ||
1155 | AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) | 1159 | AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) |
1156 | { | 1160 | { |
1157 | AccountViewItem*pitem,*sitem; | 1161 | AccountViewItem*pitem,*sitem; |
1158 | if (!start) pitem = (AccountViewItem*)firstChild(); | 1162 | if (!start) pitem = (AccountViewItem*)firstChild(); |
1159 | else pitem = (AccountViewItem*)start->firstChild(); | 1163 | else pitem = (AccountViewItem*)start->firstChild(); |
1160 | while (pitem) | 1164 | while (pitem) |
1161 | { | 1165 | { |
1162 | if (pitem->matchName(path)) | 1166 | if (pitem->matchName(path)) |
1163 | { | 1167 | { |
1164 | break; | 1168 | break; |
1165 | } | 1169 | } |
1166 | if (pitem->childCount()>0) | 1170 | if (pitem->childCount()>0) |
1167 | { | 1171 | { |
1168 | sitem = findSubItem(path,pitem); | 1172 | sitem = findSubItem(path,pitem); |
1169 | if (sitem) | 1173 | if (sitem) |
1170 | { | 1174 | { |
1171 | pitem = sitem; | 1175 | pitem = sitem; |
1172 | break; | 1176 | break; |
1173 | } | 1177 | } |
1174 | } | 1178 | } |
1175 | pitem=(AccountViewItem*)pitem->nextSibling(); | 1179 | pitem=(AccountViewItem*)pitem->nextSibling(); |
1176 | } | 1180 | } |
1177 | return pitem; | 1181 | return pitem; |
1178 | } | 1182 | } |
1179 | 1183 | ||
1180 | bool AccountViewItem::isDraftfolder() | 1184 | bool AccountViewItem::isDraftfolder() |
1181 | { | 1185 | { |
1182 | return false; | 1186 | return false; |
1183 | } | 1187 | } |
diff --git a/kmicromail/accountview.cpp b/kmicromail/accountview.cpp index c10d384..c9c4a0f 100644 --- a/kmicromail/accountview.cpp +++ b/kmicromail/accountview.cpp | |||
@@ -1,207 +1,212 @@ | |||
1 | 1 | ||
2 | #include "accountview.h" | 2 | #include "accountview.h" |
3 | #include "accountitem.h" | 3 | #include "accountitem.h" |
4 | #include "selectstore.h" | 4 | #include "selectstore.h" |
5 | 5 | ||
6 | #include <libmailwrapper/settings.h> | 6 | #include <libmailwrapper/settings.h> |
7 | #include <libmailwrapper/mailwrapper.h> | 7 | #include <libmailwrapper/mailwrapper.h> |
8 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
9 | #include <libmailwrapper/abstractmail.h> | 9 | #include <libmailwrapper/abstractmail.h> |
10 | 10 | ||
11 | /* OPIE */ | 11 | /* OPIE */ |
12 | #include <qpe/qpeapplication.h> | 12 | #include <qpe/qpeapplication.h> |
13 | 13 | ||
14 | /* QT */ | 14 | /* QT */ |
15 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
16 | #include <qpopupmenu.h> | 16 | #include <qpopupmenu.h> |
17 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
18 | #include <qspinbox.h> | 18 | #include <qspinbox.h> |
19 | #include <klocale.h> | 19 | #include <klocale.h> |
20 | 20 | ||
21 | using namespace Opie::Core; | 21 | using namespace Opie::Core; |
22 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 22 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
23 | : QListView( parent, name, flags ) | 23 | : QListView( parent, name, flags ) |
24 | { | 24 | { |
25 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), | 25 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), |
26 | SLOT( refresh(QListViewItem*) ) ); | 26 | SLOT( refresh(QListViewItem*) ) ); |
27 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, | 27 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, |
28 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); | 28 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); |
29 | setSorting(0); | 29 | setSorting(0); |
30 | } | 30 | } |
31 | 31 | ||
32 | AccountView::~AccountView() | 32 | AccountView::~AccountView() |
33 | { | 33 | { |
34 | imapAccounts.clear(); | 34 | imapAccounts.clear(); |
35 | mhAccounts.clear(); | 35 | mhAccounts.clear(); |
36 | } | 36 | } |
37 | 37 | ||
38 | void AccountView::slotContextMenu(int id) | 38 | void AccountView::slotContextMenu(int id) |
39 | { | 39 | { |
40 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 40 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
41 | if (!view) return; | 41 | if (!view) return; |
42 | view->contextMenuSelected(id); | 42 | view->contextMenuSelected(id); |
43 | } | 43 | } |
44 | 44 | ||
45 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) | 45 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) |
46 | { | 46 | { |
47 | if (button==1) {return;} | 47 | if (button==1) {return;} |
48 | if (!item) return; | 48 | if (!item) return; |
49 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 49 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
50 | QPopupMenu*m = view->getContextMenu(); | 50 | QPopupMenu*m = view->getContextMenu(); |
51 | if (!m) return; | 51 | if (!m) return; |
52 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); | 52 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); |
53 | m->setFocus(); | 53 | m->setFocus(); |
54 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 54 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
55 | delete m; | 55 | delete m; |
56 | } | 56 | } |
57 | 57 | ||
58 | void AccountView::populate( QList<Account> list ) | 58 | void AccountView::populate( QList<Account> list ) |
59 | { | 59 | { |
60 | clear(); | 60 | clear(); |
61 | 61 | ||
62 | imapAccounts.clear(); | 62 | imapAccounts.clear(); |
63 | mhAccounts.clear(); | 63 | mhAccounts.clear(); |
64 | 64 | ||
65 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); | 65 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); |
66 | 66 | ||
67 | Account *it; | 67 | Account *it; |
68 | for ( it = list.first(); it; it = list.next() ) | 68 | for ( it = list.first(); it; it = list.next() ) |
69 | { | 69 | { |
70 | if ( it->getType() == MAILLIB::A_IMAP ) | 70 | if ( it->getType() == MAILLIB::A_IMAP ) |
71 | { | 71 | { |
72 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); | 72 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); |
73 | imapAccounts.append(new IMAPviewItem( imap, this )); | 73 | imapAccounts.append(new IMAPviewItem( imap, this )); |
74 | } | 74 | } |
75 | else if ( it->getType() == MAILLIB::A_POP3 ) | 75 | else if ( it->getType() == MAILLIB::A_POP3 ) |
76 | { | 76 | { |
77 | POP3account *pop3 = static_cast<POP3account *>(it); | 77 | POP3account *pop3 = static_cast<POP3account *>(it); |
78 | /* must not be hold 'cause it isn't required */ | 78 | /* must not be hold 'cause it isn't required */ |
79 | (void) new POP3viewItem( pop3, this ); | 79 | (void) new POP3viewItem( pop3, this ); |
80 | } | 80 | } |
81 | else if ( it->getType() == MAILLIB::A_NNTP ) | 81 | else if ( it->getType() == MAILLIB::A_NNTP ) |
82 | { | 82 | { |
83 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); | 83 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); |
84 | /* must not be hold 'cause it isn't required */ | 84 | /* must not be hold 'cause it isn't required */ |
85 | (void) new NNTPviewItem( nntp, this ); | 85 | (void) new NNTPviewItem( nntp, this ); |
86 | } | 86 | } |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | void AccountView::refresh(QListViewItem *item) | 90 | void AccountView::refresh(QListViewItem *item) |
91 | { | 91 | { |
92 | if ( item ) | 92 | if ( item ) |
93 | { | 93 | { |
94 | m_currentItem = item; | 94 | m_currentItem = item; |
95 | QValueList<RecMailP> headerlist; | 95 | QValueList<RecMailP> headerlist; |
96 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 96 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
97 | view->refresh(headerlist); | 97 | view->refresh(headerlist); |
98 | emit refreshMailview(headerlist); | 98 | emit refreshMailview(headerlist); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
102 | void AccountView::refreshCurrent() | 102 | void AccountView::refreshCurrent() |
103 | { | 103 | { |
104 | m_currentItem = currentItem(); | 104 | m_currentItem = currentItem(); |
105 | if ( !m_currentItem ) return; | 105 | if ( !m_currentItem ) return; |
106 | QValueList<RecMailP> headerlist; | 106 | QValueList<RecMailP> headerlist; |
107 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); | 107 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); |
108 | view->refresh(headerlist); | 108 | view->refresh(headerlist); |
109 | emit refreshMailview(headerlist); | 109 | emit refreshMailview(headerlist); |
110 | } | 110 | } |
111 | 111 | ||
112 | void AccountView::refreshAll() | 112 | void AccountView::refreshAll() |
113 | { | 113 | { |
114 | } | 114 | } |
115 | 115 | ||
116 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) | 116 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) |
117 | { | 117 | { |
118 | QListViewItem*item = selectedItem (); | 118 | QListViewItem*item = selectedItem (); |
119 | if (!item) return new RecBody(); | 119 | if (!item) return new RecBody(); |
120 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 120 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
121 | return view->fetchBody(aMail); | 121 | return view->fetchBody(aMail); |
122 | } | 122 | } |
123 | 123 | ||
124 | void AccountView::setupFolderselect(Selectstore*sels) | 124 | void AccountView::setupFolderselect(Selectstore*sels) |
125 | { | 125 | { |
126 | |||
127 | #ifndef DESKTOP_VERSION | ||
126 | sels->showMaximized(); | 128 | sels->showMaximized(); |
129 | #else | ||
130 | sels->show(); | ||
131 | #endif | ||
127 | QStringList sFolders; | 132 | QStringList sFolders; |
128 | unsigned int i = 0; | 133 | unsigned int i = 0; |
129 | for (i=0; i < mhAccounts.count();++i) | 134 | for (i=0; i < mhAccounts.count();++i) |
130 | { | 135 | { |
131 | mhAccounts[i]->refresh(false); | 136 | mhAccounts[i]->refresh(false); |
132 | sFolders = mhAccounts[i]->subFolders(); | 137 | sFolders = mhAccounts[i]->subFolders(); |
133 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); | 138 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); |
134 | } | 139 | } |
135 | for (i=0; i < imapAccounts.count();++i) | 140 | for (i=0; i < imapAccounts.count();++i) |
136 | { | 141 | { |
137 | if (imapAccounts[i]->offline()) | 142 | if (imapAccounts[i]->offline()) |
138 | continue; | 143 | continue; |
139 | imapAccounts[i]->refreshFolders(false); | 144 | imapAccounts[i]->refreshFolders(false); |
140 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); | 145 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); |
141 | } | 146 | } |
142 | } | 147 | } |
143 | void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) | 148 | void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) |
144 | { | 149 | { |
145 | #if 0 | 150 | #if 0 |
146 | AbstractMail*targetMail = 0; | 151 | AbstractMail*targetMail = 0; |
147 | QString targetFolder = ""; | 152 | QString targetFolder = ""; |
148 | Selectstore sels; | 153 | Selectstore sels; |
149 | setupFolderselect(&sels); | 154 | setupFolderselect(&sels); |
150 | if (!sels.exec()) return; | 155 | if (!sels.exec()) return; |
151 | targetMail = sels.currentMail(); | 156 | targetMail = sels.currentMail(); |
152 | targetFolder = sels.currentFolder(); | 157 | targetFolder = sels.currentFolder(); |
153 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | 158 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || |
154 | targetFolder.isEmpty()) | 159 | targetFolder.isEmpty()) |
155 | { | 160 | { |
156 | return; | 161 | return; |
157 | } | 162 | } |
158 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 163 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
159 | { | 164 | { |
160 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 165 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
161 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); | 166 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); |
162 | return; | 167 | return; |
163 | } | 168 | } |
164 | int maxsize = 0; | 169 | int maxsize = 0; |
165 | if ( sels.useSize->isChecked()) | 170 | if ( sels.useSize->isChecked()) |
166 | maxsize = sels.sizeSpinBox->value(); | 171 | maxsize = sels.sizeSpinBox->value(); |
167 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); | 172 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); |
168 | #endif | 173 | #endif |
169 | fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper()); | 174 | fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper()); |
170 | refreshCurrent(); | 175 | refreshCurrent(); |
171 | 176 | ||
172 | } | 177 | } |
173 | 178 | ||
174 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) | 179 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) |
175 | { | 180 | { |
176 | AbstractMail*targetMail = 0; | 181 | AbstractMail*targetMail = 0; |
177 | QString targetFolder = ""; | 182 | QString targetFolder = ""; |
178 | Selectstore sels; | 183 | Selectstore sels; |
179 | setupFolderselect(&sels); | 184 | setupFolderselect(&sels); |
180 | if (!sels.exec()) return; | 185 | if (!sels.exec()) return; |
181 | targetMail = sels.currentMail(); | 186 | targetMail = sels.currentMail(); |
182 | targetFolder = sels.currentFolder(); | 187 | targetFolder = sels.currentFolder(); |
183 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | 188 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || |
184 | targetFolder.isEmpty()) | 189 | targetFolder.isEmpty()) |
185 | { | 190 | { |
186 | return; | 191 | return; |
187 | } | 192 | } |
188 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 193 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
189 | { | 194 | { |
190 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 195 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
191 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); | 196 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); |
192 | return; | 197 | return; |
193 | } | 198 | } |
194 | int maxsize = 0; | 199 | int maxsize = 0; |
195 | if ( sels.useSize->isChecked()) | 200 | if ( sels.useSize->isChecked()) |
196 | maxsize = sels.sizeSpinBox->value(); | 201 | maxsize = sels.sizeSpinBox->value(); |
197 | 202 | ||
198 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); | 203 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); |
199 | refreshCurrent(); | 204 | refreshCurrent(); |
200 | } | 205 | } |
201 | 206 | ||
202 | bool AccountView::currentisDraft() | 207 | bool AccountView::currentisDraft() |
203 | { | 208 | { |
204 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 209 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
205 | if (!view) return false; | 210 | if (!view) return false; |
206 | return view->isDraftfolder(); | 211 | return view->isDraftfolder(); |
207 | } | 212 | } |
diff --git a/kmicromail/editaccounts.cpp b/kmicromail/editaccounts.cpp index 0d30097..48c3963 100644 --- a/kmicromail/editaccounts.cpp +++ b/kmicromail/editaccounts.cpp | |||
@@ -1,494 +1,497 @@ | |||
1 | 1 | ||
2 | #include <qdialog.h> | 2 | #include <qdialog.h> |
3 | #include "kapplication.h" | 3 | #include "kapplication.h" |
4 | #include "defines.h" | 4 | #include "defines.h" |
5 | #include "editaccounts.h" | 5 | #include "editaccounts.h" |
6 | /* OPIE */ | 6 | /* OPIE */ |
7 | #include <qpe/qpeapplication.h> | 7 | #include <qpe/qpeapplication.h> |
8 | 8 | ||
9 | /* QT */ | 9 | /* QT */ |
10 | #include <qstringlist.h> | 10 | #include <qstringlist.h> |
11 | 11 | ||
12 | #include <qcombobox.h> | 12 | #include <qcombobox.h> |
13 | #include <qcheckbox.h> | 13 | #include <qcheckbox.h> |
14 | #include <qmessagebox.h> | 14 | #include <qmessagebox.h> |
15 | #include <qpushbutton.h> | 15 | #include <qpushbutton.h> |
16 | #include <qlineedit.h> | 16 | #include <qlineedit.h> |
17 | #include <qlabel.h> | 17 | #include <qlabel.h> |
18 | #include <qtabwidget.h> | 18 | #include <qtabwidget.h> |
19 | #include <qlistview.h> | 19 | #include <qlistview.h> |
20 | #include <qspinbox.h> | 20 | #include <qspinbox.h> |
21 | #include <klocale.h> | 21 | #include <klocale.h> |
22 | 22 | ||
23 | #include <libmailwrapper/nntpwrapper.h> | 23 | #include <libmailwrapper/nntpwrapper.h> |
24 | 24 | ||
25 | using namespace Opie::Core; | 25 | using namespace Opie::Core; |
26 | 26 | ||
27 | AccountListItem::AccountListItem( QListView *parent, Account *a) | 27 | AccountListItem::AccountListItem( QListView *parent, Account *a) |
28 | : QListViewItem( parent ) | 28 | : QListViewItem( parent ) |
29 | { | 29 | { |
30 | account = a; | 30 | account = a; |
31 | setText( 0, account->getAccountName() ); | 31 | setText( 0, account->getAccountName() ); |
32 | QString ttext = ""; | 32 | QString ttext = ""; |
33 | switch (account->getType()) { | 33 | switch (account->getType()) { |
34 | case MAILLIB::A_NNTP: | 34 | case MAILLIB::A_NNTP: |
35 | ttext="NNTP"; | 35 | ttext="NNTP"; |
36 | break; | 36 | break; |
37 | case MAILLIB::A_POP3: | 37 | case MAILLIB::A_POP3: |
38 | ttext = "POP3"; | 38 | ttext = "POP3"; |
39 | break; | 39 | break; |
40 | case MAILLIB::A_IMAP: | 40 | case MAILLIB::A_IMAP: |
41 | ttext = "IMAP"; | 41 | ttext = "IMAP"; |
42 | break; | 42 | break; |
43 | case MAILLIB::A_SMTP: | 43 | case MAILLIB::A_SMTP: |
44 | ttext = "SMTP"; | 44 | ttext = "SMTP"; |
45 | break; | 45 | break; |
46 | default: | 46 | default: |
47 | ttext = "UNKNOWN"; | 47 | ttext = "UNKNOWN"; |
48 | break; | 48 | break; |
49 | } | 49 | } |
50 | setText( 1, ttext); | 50 | setText( 1, ttext); |
51 | } | 51 | } |
52 | 52 | ||
53 | EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) | 53 | EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) |
54 | : EditAccountsUI( parent, name, modal, flags ) | 54 | : EditAccountsUI( parent, name, modal, flags ) |
55 | { | 55 | { |
56 | settings = s; | 56 | settings = s; |
57 | 57 | ||
58 | mailList->addColumn( i18n( "Account" ) ); | 58 | mailList->addColumn( i18n( "Account" ) ); |
59 | mailList->addColumn( i18n( "Type" ) ); | 59 | mailList->addColumn( i18n( "Type" ) ); |
60 | 60 | ||
61 | newsList->addColumn( i18n( "Account" ) ); | 61 | newsList->addColumn( i18n( "Account" ) ); |
62 | 62 | ||
63 | connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); | 63 | connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); |
64 | connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); | 64 | connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); |
65 | connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); | 65 | connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); |
66 | connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); | 66 | connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); |
67 | connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); | 67 | connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); |
68 | connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); | 68 | connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); |
69 | 69 | ||
70 | slotFillLists(); | 70 | slotFillLists(); |
71 | } | 71 | } |
72 | 72 | ||
73 | void EditAccounts::slotFillLists() | 73 | void EditAccounts::slotFillLists() |
74 | { | 74 | { |
75 | mailList->clear(); | 75 | mailList->clear(); |
76 | newsList->clear(); | 76 | newsList->clear(); |
77 | 77 | ||
78 | QList<Account> accounts = settings->getAccounts(); | 78 | QList<Account> accounts = settings->getAccounts(); |
79 | Account *it; | 79 | Account *it; |
80 | for ( it = accounts.first(); it; it = accounts.next() ) | 80 | for ( it = accounts.first(); it; it = accounts.next() ) |
81 | { | 81 | { |
82 | if ( it->getType()==MAILLIB::A_NNTP ) | 82 | if ( it->getType()==MAILLIB::A_NNTP ) |
83 | { | 83 | { |
84 | (void) new AccountListItem( newsList, it ); | 84 | (void) new AccountListItem( newsList, it ); |
85 | } | 85 | } |
86 | else | 86 | else |
87 | { | 87 | { |
88 | (void) new AccountListItem( mailList, it ); | 88 | (void) new AccountListItem( mailList, it ); |
89 | } | 89 | } |
90 | } | 90 | } |
91 | } | 91 | } |
92 | 92 | ||
93 | void EditAccounts::slotNewMail() | 93 | void EditAccounts::slotNewMail() |
94 | { | 94 | { |
95 | QString *selection = new QString(); | 95 | QString *selection = new QString(); |
96 | SelectMailType selType( selection, this, 0, true ); | 96 | SelectMailType selType( selection, this, 0, true ); |
97 | selType.show(); | 97 | selType.show(); |
98 | if ( QDialog::Accepted == selType.exec() ) | 98 | if ( QDialog::Accepted == selType.exec() ) |
99 | { | 99 | { |
100 | slotNewAccount( *selection ); | 100 | slotNewAccount( *selection ); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | 103 | ||
104 | void EditAccounts::slotNewAccount( const QString &type ) | 104 | void EditAccounts::slotNewAccount( const QString &type ) |
105 | { | 105 | { |
106 | if ( type.compare( i18n("IMAP") ) == 0 ) | 106 | if ( type.compare( i18n("IMAP") ) == 0 ) |
107 | { | 107 | { |
108 | IMAPaccount *account = new IMAPaccount(); | 108 | IMAPaccount *account = new IMAPaccount(); |
109 | IMAPconfig imap( account, this, 0, true ); | 109 | IMAPconfig imap( account, this, 0, true ); |
110 | |||
111 | #ifndef DESKTOP_VERSION | ||
110 | imap.showMaximized(); | 112 | imap.showMaximized(); |
113 | #endif | ||
111 | if ( QDialog::Accepted == imap.exec() ) | 114 | if ( QDialog::Accepted == imap.exec() ) |
112 | { | 115 | { |
113 | settings->addAccount( account ); | 116 | settings->addAccount( account ); |
114 | account->save(); | 117 | account->save(); |
115 | slotFillLists(); | 118 | slotFillLists(); |
116 | } | 119 | } |
117 | else | 120 | else |
118 | { | 121 | { |
119 | account->remove(); | 122 | account->remove(); |
120 | } | 123 | } |
121 | } | 124 | } |
122 | else if ( type.compare( i18n("POP3") ) == 0 ) | 125 | else if ( type.compare( i18n("POP3") ) == 0 ) |
123 | { | 126 | { |
124 | POP3account *account = new POP3account(); | 127 | POP3account *account = new POP3account(); |
125 | POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); | 128 | POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); |
126 | if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) | 129 | if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) |
127 | { | 130 | { |
128 | settings->addAccount( account ); | 131 | settings->addAccount( account ); |
129 | account->save(); | 132 | account->save(); |
130 | slotFillLists(); | 133 | slotFillLists(); |
131 | } | 134 | } |
132 | else | 135 | else |
133 | { | 136 | { |
134 | account->remove(); | 137 | account->remove(); |
135 | } | 138 | } |
136 | } | 139 | } |
137 | else if ( type.compare( i18n("SMTP") ) == 0 ) | 140 | else if ( type.compare( i18n("SMTP") ) == 0 ) |
138 | { | 141 | { |
139 | SMTPaccount *account = new SMTPaccount(); | 142 | SMTPaccount *account = new SMTPaccount(); |
140 | SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); | 143 | SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); |
141 | if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) | 144 | if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) |
142 | { | 145 | { |
143 | settings->addAccount( account ); | 146 | settings->addAccount( account ); |
144 | account->save(); | 147 | account->save(); |
145 | slotFillLists(); | 148 | slotFillLists(); |
146 | 149 | ||
147 | } | 150 | } |
148 | else | 151 | else |
149 | { | 152 | { |
150 | account->remove(); | 153 | account->remove(); |
151 | } | 154 | } |
152 | } | 155 | } |
153 | else if ( type.compare( i18n("NNTP") ) == 0 ) | 156 | else if ( type.compare( i18n("NNTP") ) == 0 ) |
154 | { | 157 | { |
155 | NNTPaccount *account = new NNTPaccount(); | 158 | NNTPaccount *account = new NNTPaccount(); |
156 | NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); | 159 | NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); |
157 | if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) | 160 | if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) |
158 | { | 161 | { |
159 | settings->addAccount( account ); | 162 | settings->addAccount( account ); |
160 | account->save(); | 163 | account->save(); |
161 | slotFillLists(); | 164 | slotFillLists(); |
162 | } | 165 | } |
163 | else | 166 | else |
164 | { | 167 | { |
165 | account->remove(); | 168 | account->remove(); |
166 | } | 169 | } |
167 | } | 170 | } |
168 | } | 171 | } |
169 | 172 | ||
170 | void EditAccounts::slotEditAccount( Account *account ) | 173 | void EditAccounts::slotEditAccount( Account *account ) |
171 | { | 174 | { |
172 | if ( account->getType() == MAILLIB::A_IMAP ) | 175 | if ( account->getType() == MAILLIB::A_IMAP ) |
173 | { | 176 | { |
174 | IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); | 177 | IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); |
175 | IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); | 178 | IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); |
176 | if ( QDialog::Accepted == KApplication::execDialog( &imap ) ) | 179 | if ( QDialog::Accepted == KApplication::execDialog( &imap ) ) |
177 | { | 180 | { |
178 | slotFillLists(); | 181 | slotFillLists(); |
179 | } | 182 | } |
180 | } | 183 | } |
181 | else if ( account->getType()==MAILLIB::A_POP3 ) | 184 | else if ( account->getType()==MAILLIB::A_POP3 ) |
182 | { | 185 | { |
183 | POP3account *pop3Acc = static_cast<POP3account *>(account); | 186 | POP3account *pop3Acc = static_cast<POP3account *>(account); |
184 | POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); | 187 | POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); |
185 | if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) | 188 | if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) |
186 | { | 189 | { |
187 | slotFillLists(); | 190 | slotFillLists(); |
188 | } | 191 | } |
189 | } | 192 | } |
190 | else if ( account->getType()==MAILLIB::A_SMTP ) | 193 | else if ( account->getType()==MAILLIB::A_SMTP ) |
191 | { | 194 | { |
192 | SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); | 195 | SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); |
193 | SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); | 196 | SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); |
194 | if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) | 197 | if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) |
195 | { | 198 | { |
196 | slotFillLists(); | 199 | slotFillLists(); |
197 | } | 200 | } |
198 | } | 201 | } |
199 | else if ( account->getType()==MAILLIB::A_NNTP) | 202 | else if ( account->getType()==MAILLIB::A_NNTP) |
200 | { | 203 | { |
201 | NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); | 204 | NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); |
202 | NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); | 205 | NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); |
203 | if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) | 206 | if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) |
204 | { | 207 | { |
205 | slotFillLists(); | 208 | slotFillLists(); |
206 | } | 209 | } |
207 | } | 210 | } |
208 | } | 211 | } |
209 | 212 | ||
210 | void EditAccounts::slotDeleteAccount( Account *account ) | 213 | void EditAccounts::slotDeleteAccount( Account *account ) |
211 | { | 214 | { |
212 | if ( QMessageBox::information( this, i18n( "Question" ), | 215 | if ( QMessageBox::information( this, i18n( "Question" ), |
213 | i18n( "<p>Do you really want to delete the selected Account?</p>" ), | 216 | i18n( "<p>Do you really want to delete the selected Account?</p>" ), |
214 | i18n( "Yes" ), i18n( "No" ) ) == 0 ) | 217 | i18n( "Yes" ), i18n( "No" ) ) == 0 ) |
215 | { | 218 | { |
216 | settings->delAccount( account ); | 219 | settings->delAccount( account ); |
217 | slotFillLists(); | 220 | slotFillLists(); |
218 | } | 221 | } |
219 | } | 222 | } |
220 | 223 | ||
221 | void EditAccounts::slotEditMail() | 224 | void EditAccounts::slotEditMail() |
222 | { | 225 | { |
223 | if ( !mailList->currentItem() ) | 226 | if ( !mailList->currentItem() ) |
224 | { | 227 | { |
225 | QMessageBox::information( this, i18n( "Error" ), | 228 | QMessageBox::information( this, i18n( "Error" ), |
226 | i18n( "<p>Please select an account.</p>" ), | 229 | i18n( "<p>Please select an account.</p>" ), |
227 | i18n( "Ok" ) ); | 230 | i18n( "Ok" ) ); |
228 | return; | 231 | return; |
229 | } | 232 | } |
230 | 233 | ||
231 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); | 234 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); |
232 | slotEditAccount( a ); | 235 | slotEditAccount( a ); |
233 | } | 236 | } |
234 | 237 | ||
235 | void EditAccounts::slotDeleteMail() | 238 | void EditAccounts::slotDeleteMail() |
236 | { | 239 | { |
237 | if ( !mailList->currentItem() ) | 240 | if ( !mailList->currentItem() ) |
238 | { | 241 | { |
239 | QMessageBox::information( this, i18n( "Error" ), | 242 | QMessageBox::information( this, i18n( "Error" ), |
240 | i18n( "<p>Please select an account.</p>" ), | 243 | i18n( "<p>Please select an account.</p>" ), |
241 | i18n( "Ok" ) ); | 244 | i18n( "Ok" ) ); |
242 | return; | 245 | return; |
243 | } | 246 | } |
244 | 247 | ||
245 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); | 248 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); |
246 | slotDeleteAccount( a ); | 249 | slotDeleteAccount( a ); |
247 | } | 250 | } |
248 | 251 | ||
249 | void EditAccounts::slotNewNews() | 252 | void EditAccounts::slotNewNews() |
250 | { | 253 | { |
251 | slotNewAccount( "NNTP" ); | 254 | slotNewAccount( "NNTP" ); |
252 | } | 255 | } |
253 | 256 | ||
254 | void EditAccounts::slotEditNews() | 257 | void EditAccounts::slotEditNews() |
255 | { | 258 | { |
256 | if ( !newsList->currentItem() ) | 259 | if ( !newsList->currentItem() ) |
257 | { | 260 | { |
258 | QMessageBox::information( this, i18n( "Error" ), | 261 | QMessageBox::information( this, i18n( "Error" ), |
259 | i18n( "<p>Please select an account.</p>" ), | 262 | i18n( "<p>Please select an account.</p>" ), |
260 | i18n( "Ok" ) ); | 263 | i18n( "Ok" ) ); |
261 | return; | 264 | return; |
262 | } | 265 | } |
263 | 266 | ||
264 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); | 267 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); |
265 | slotEditAccount( a ); | 268 | slotEditAccount( a ); |
266 | } | 269 | } |
267 | 270 | ||
268 | void EditAccounts::slotDeleteNews() | 271 | void EditAccounts::slotDeleteNews() |
269 | { | 272 | { |
270 | if ( !newsList->currentItem() ) | 273 | if ( !newsList->currentItem() ) |
271 | { | 274 | { |
272 | QMessageBox::information( this, i18n( "Error" ), | 275 | QMessageBox::information( this, i18n( "Error" ), |
273 | i18n( "<p>Please select an account.</p>" ), | 276 | i18n( "<p>Please select an account.</p>" ), |
274 | i18n( "Ok" ) ); | 277 | i18n( "Ok" ) ); |
275 | return; | 278 | return; |
276 | } | 279 | } |
277 | 280 | ||
278 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); | 281 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); |
279 | slotDeleteAccount( a ); | 282 | slotDeleteAccount( a ); |
280 | } | 283 | } |
281 | 284 | ||
282 | void EditAccounts::slotAdjustColumns() | 285 | void EditAccounts::slotAdjustColumns() |
283 | { | 286 | { |
284 | int currPage = configTab->currentPageIndex(); | 287 | int currPage = configTab->currentPageIndex(); |
285 | 288 | ||
286 | configTab->showPage( mailTab ); | 289 | configTab->showPage( mailTab ); |
287 | mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); | 290 | mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); |
288 | mailList->setColumnWidth( 1, 50 ); | 291 | mailList->setColumnWidth( 1, 50 ); |
289 | 292 | ||
290 | configTab->showPage( newsTab ); | 293 | configTab->showPage( newsTab ); |
291 | newsList->setColumnWidth( 0, newsList->visibleWidth() ); | 294 | newsList->setColumnWidth( 0, newsList->visibleWidth() ); |
292 | 295 | ||
293 | configTab->setCurrentPage( currPage ); | 296 | configTab->setCurrentPage( currPage ); |
294 | } | 297 | } |
295 | 298 | ||
296 | void EditAccounts::accept() | 299 | void EditAccounts::accept() |
297 | { | 300 | { |
298 | settings->saveAccounts(); | 301 | settings->saveAccounts(); |
299 | 302 | ||
300 | QDialog::accept(); | 303 | QDialog::accept(); |
301 | } | 304 | } |
302 | 305 | ||
303 | /** | 306 | /** |
304 | * SelectMailType | 307 | * SelectMailType |
305 | */ | 308 | */ |
306 | 309 | ||
307 | SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) | 310 | SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) |
308 | : SelectMailTypeUI( parent, name, modal, flags ) | 311 | : SelectMailTypeUI( parent, name, modal, flags ) |
309 | { | 312 | { |
310 | selected = selection; | 313 | selected = selection; |
311 | selected->replace( 0, selected->length(), typeBox->currentText() ); | 314 | selected->replace( 0, selected->length(), typeBox->currentText() ); |
312 | connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) ); | 315 | connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) ); |
313 | } | 316 | } |
314 | 317 | ||
315 | void SelectMailType::slotSelection( const QString &sel ) | 318 | void SelectMailType::slotSelection( const QString &sel ) |
316 | { | 319 | { |
317 | selected->replace( 0, selected->length(), sel ); | 320 | selected->replace( 0, selected->length(), sel ); |
318 | } | 321 | } |
319 | 322 | ||
320 | /** | 323 | /** |
321 | * IMAPconfig | 324 | * IMAPconfig |
322 | */ | 325 | */ |
323 | 326 | ||
324 | IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 327 | IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
325 | : IMAPconfigUI( parent, name, modal, flags ) | 328 | : IMAPconfigUI( parent, name, modal, flags ) |
326 | { | 329 | { |
327 | data = account; | 330 | data = account; |
328 | 331 | ||
329 | fillValues(); | 332 | fillValues(); |
330 | 333 | ||
331 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); | 334 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); |
332 | ComboBox1->insertItem( "Only if available", 0 ); | 335 | ComboBox1->insertItem( "Only if available", 0 ); |
333 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | 336 | ComboBox1->insertItem( "Always, Negotiated", 1 ); |
334 | ComboBox1->insertItem( "Connect on secure port", 2 ); | 337 | ComboBox1->insertItem( "Connect on secure port", 2 ); |
335 | ComboBox1->insertItem( "Run command instead", 3 ); | 338 | ComboBox1->insertItem( "Run command instead", 3 ); |
336 | CommandEdit->hide(); | 339 | CommandEdit->hide(); |
337 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 340 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
338 | } | 341 | } |
339 | 342 | ||
340 | void IMAPconfig::slotConnectionToggle( int index ) | 343 | void IMAPconfig::slotConnectionToggle( int index ) |
341 | { | 344 | { |
342 | if ( index == 2 ) | 345 | if ( index == 2 ) |
343 | { | 346 | { |
344 | portLine->setText( IMAP_SSL_PORT ); | 347 | portLine->setText( IMAP_SSL_PORT ); |
345 | } | 348 | } |
346 | else if ( index == 3 ) | 349 | else if ( index == 3 ) |
347 | { | 350 | { |
348 | portLine->setText( IMAP_PORT ); | 351 | portLine->setText( IMAP_PORT ); |
349 | CommandEdit->show(); | 352 | CommandEdit->show(); |
350 | } | 353 | } |
351 | else | 354 | else |
352 | { | 355 | { |
353 | portLine->setText( IMAP_PORT ); | 356 | portLine->setText( IMAP_PORT ); |
354 | } | 357 | } |
355 | } | 358 | } |
356 | 359 | ||
357 | void IMAPconfig::fillValues() | 360 | void IMAPconfig::fillValues() |
358 | { | 361 | { |
359 | accountLine->setText( data->getAccountName() ); | 362 | accountLine->setText( data->getAccountName() ); |
360 | serverLine->setText( data->getServer() ); | 363 | serverLine->setText( data->getServer() ); |
361 | portLine->setText( data->getPort() ); | 364 | portLine->setText( data->getPort() ); |
362 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 365 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
363 | userLine->setText( data->getUser() ); | 366 | userLine->setText( data->getUser() ); |
364 | passLine->setText( data->getPassword() ); | 367 | passLine->setText( data->getPassword() ); |
365 | prefixLine->setText(data->getPrefix()); | 368 | prefixLine->setText(data->getPrefix()); |
366 | localFolder->setText( data->getLocalFolder() ); | 369 | localFolder->setText( data->getLocalFolder() ); |
367 | int max = data->getMaxMailSize() ; | 370 | int max = data->getMaxMailSize() ; |
368 | if ( max ) { | 371 | if ( max ) { |
369 | CheckBoxDown->setChecked( true ); | 372 | CheckBoxDown->setChecked( true ); |
370 | SpinBoxDown->setValue ( max ); | 373 | SpinBoxDown->setValue ( max ); |
371 | } else { | 374 | } else { |
372 | CheckBoxDown->setChecked( false ); | 375 | CheckBoxDown->setChecked( false ); |
373 | SpinBoxDown->setValue ( 5 ); | 376 | SpinBoxDown->setValue ( 5 ); |
374 | } | 377 | } |
375 | CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() ); | 378 | CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() ); |
376 | } | 379 | } |
377 | 380 | ||
378 | void IMAPconfig::accept() | 381 | void IMAPconfig::accept() |
379 | { | 382 | { |
380 | data->setAccountName( accountLine->text() ); | 383 | data->setAccountName( accountLine->text() ); |
381 | data->setServer( serverLine->text() ); | 384 | data->setServer( serverLine->text() ); |
382 | data->setPort( portLine->text() ); | 385 | data->setPort( portLine->text() ); |
383 | data->setConnectionType( ComboBox1->currentItem() ); | 386 | data->setConnectionType( ComboBox1->currentItem() ); |
384 | data->setUser( userLine->text() ); | 387 | data->setUser( userLine->text() ); |
385 | data->setPassword( passLine->text() ); | 388 | data->setPassword( passLine->text() ); |
386 | data->setPrefix(prefixLine->text()); | 389 | data->setPrefix(prefixLine->text()); |
387 | data->setLocalFolder( localFolder->text() ); | 390 | data->setLocalFolder( localFolder->text() ); |
388 | data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ; | 391 | data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ; |
389 | data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() ); | 392 | data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() ); |
390 | 393 | ||
391 | QDialog::accept(); | 394 | QDialog::accept(); |
392 | } | 395 | } |
393 | 396 | ||
394 | /** | 397 | /** |
395 | * POP3config | 398 | * POP3config |
396 | */ | 399 | */ |
397 | 400 | ||
398 | POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 401 | POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
399 | : POP3configUI( parent, name, modal, flags ) | 402 | : POP3configUI( parent, name, modal, flags ) |
400 | { | 403 | { |
401 | data = account; | 404 | data = account; |
402 | fillValues(); | 405 | fillValues(); |
403 | 406 | ||
404 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); | 407 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); |
405 | ComboBox1->insertItem( "Only if available", 0 ); | 408 | ComboBox1->insertItem( "Only if available", 0 ); |
406 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | 409 | ComboBox1->insertItem( "Always, Negotiated", 1 ); |
407 | ComboBox1->insertItem( "Connect on secure port", 2 ); | 410 | ComboBox1->insertItem( "Connect on secure port", 2 ); |
408 | ComboBox1->insertItem( "Run command instead", 3 ); | 411 | ComboBox1->insertItem( "Run command instead", 3 ); |
409 | CommandEdit->hide(); | 412 | CommandEdit->hide(); |
410 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 413 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
411 | } | 414 | } |
412 | 415 | ||
413 | void POP3config::slotConnectionToggle( int index ) | 416 | void POP3config::slotConnectionToggle( int index ) |
414 | { | 417 | { |
415 | // 2 is ssl connection | 418 | // 2 is ssl connection |
416 | if ( index == 2 ) | 419 | if ( index == 2 ) |
417 | { | 420 | { |
418 | portLine->setText( POP3_SSL_PORT ); | 421 | portLine->setText( POP3_SSL_PORT ); |
419 | } | 422 | } |
420 | else if ( index == 3 ) | 423 | else if ( index == 3 ) |
421 | { | 424 | { |
422 | portLine->setText( POP3_PORT ); | 425 | portLine->setText( POP3_PORT ); |
423 | CommandEdit->show(); | 426 | CommandEdit->show(); |
424 | } | 427 | } |
425 | else | 428 | else |
426 | { | 429 | { |
427 | portLine->setText( POP3_PORT ); | 430 | portLine->setText( POP3_PORT ); |
428 | } | 431 | } |
429 | } | 432 | } |
430 | 433 | ||
431 | void POP3config::fillValues() | 434 | void POP3config::fillValues() |
432 | { | 435 | { |
433 | accountLine->setText( data->getAccountName() ); | 436 | accountLine->setText( data->getAccountName() ); |
434 | serverLine->setText( data->getServer() ); | 437 | serverLine->setText( data->getServer() ); |
435 | portLine->setText( data->getPort() ); | 438 | portLine->setText( data->getPort() ); |
436 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 439 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
437 | userLine->setText( data->getUser() ); | 440 | userLine->setText( data->getUser() ); |
438 | passLine->setText( data->getPassword() ); | 441 | passLine->setText( data->getPassword() ); |
439 | localFolder->setText( data->getLocalFolder() ); | 442 | localFolder->setText( data->getLocalFolder() ); |
440 | int max = data->getMaxMailSize() ; | 443 | int max = data->getMaxMailSize() ; |
441 | if ( max ) { | 444 | if ( max ) { |
442 | CheckBoxDown->setChecked( true ); | 445 | CheckBoxDown->setChecked( true ); |
443 | SpinBoxDown->setValue ( max ); | 446 | SpinBoxDown->setValue ( max ); |
444 | } else { | 447 | } else { |
445 | CheckBoxDown->setChecked( false ); | 448 | CheckBoxDown->setChecked( false ); |
446 | SpinBoxDown->setValue ( 5 ); | 449 | SpinBoxDown->setValue ( 5 ); |
447 | } | 450 | } |
448 | CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() ); | 451 | CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() ); |
449 | } | 452 | } |
450 | 453 | ||
451 | void POP3config::accept() | 454 | void POP3config::accept() |
452 | { | 455 | { |
453 | data->setAccountName( accountLine->text() ); | 456 | data->setAccountName( accountLine->text() ); |
454 | data->setServer( serverLine->text() ); | 457 | data->setServer( serverLine->text() ); |
455 | data->setPort( portLine->text() ); | 458 | data->setPort( portLine->text() ); |
456 | data->setConnectionType( ComboBox1->currentItem() ); | 459 | data->setConnectionType( ComboBox1->currentItem() ); |
457 | data->setUser( userLine->text() ); | 460 | data->setUser( userLine->text() ); |
458 | data->setPassword( passLine->text() ); | 461 | data->setPassword( passLine->text() ); |
459 | data->setLocalFolder( localFolder->text() ); | 462 | data->setLocalFolder( localFolder->text() ); |
460 | data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ; | 463 | data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ; |
461 | data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() ); | 464 | data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() ); |
462 | 465 | ||
463 | QDialog::accept(); | 466 | QDialog::accept(); |
464 | } | 467 | } |
465 | 468 | ||
466 | /** | 469 | /** |
467 | * SMTPconfig | 470 | * SMTPconfig |
468 | */ | 471 | */ |
469 | 472 | ||
470 | SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 473 | SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
471 | : SMTPconfigUI( parent, name, modal, flags ) | 474 | : SMTPconfigUI( parent, name, modal, flags ) |
472 | { | 475 | { |
473 | data = account; | 476 | data = account; |
474 | 477 | ||
475 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); | 478 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); |
476 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); | 479 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); |
477 | 480 | ||
478 | fillValues(); | 481 | fillValues(); |
479 | 482 | ||
480 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); | 483 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); |
481 | ComboBox1->insertItem( "Only if available", 0 ); | 484 | ComboBox1->insertItem( "Only if available", 0 ); |
482 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | 485 | ComboBox1->insertItem( "Always, Negotiated", 1 ); |
483 | ComboBox1->insertItem( "Connect on secure port", 2 ); | 486 | ComboBox1->insertItem( "Connect on secure port", 2 ); |
484 | ComboBox1->insertItem( "Run command instead", 3 ); | 487 | ComboBox1->insertItem( "Run command instead", 3 ); |
485 | CommandEdit->hide(); | 488 | CommandEdit->hide(); |
486 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 489 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
487 | } | 490 | } |
488 | 491 | ||
489 | void SMTPconfig::slotConnectionToggle( int index ) | 492 | void SMTPconfig::slotConnectionToggle( int index ) |
490 | { | 493 | { |
491 | // 2 is ssl connection | 494 | // 2 is ssl connection |
492 | if ( index == 2 ) | 495 | if ( index == 2 ) |
493 | { | 496 | { |
494 | portLine->setText( SMTP_SSL_PORT ); | 497 | portLine->setText( SMTP_SSL_PORT ); |
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index fe9df87..8d16ae7 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -1,529 +1,535 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | // CHANGED 2004-08-06 Lutz Rogowski | 2 | // CHANGED 2004-08-06 Lutz Rogowski |
3 | 3 | ||
4 | #include "koprefsdialog.h" | 4 | #include "koprefsdialog.h" |
5 | #include <kapplication.h> | 5 | #include <kapplication.h> |
6 | #include <libkdepim/externalapphandler.h> | 6 | #include <libkdepim/externalapphandler.h> |
7 | #include <libkdepim/kpimglobalprefs.h> | 7 | #include <libkdepim/kpimglobalprefs.h> |
8 | #ifdef MINIKDE_KDIALOG_H | 8 | #ifdef MINIKDE_KDIALOG_H |
9 | #undef MINIKDE_KDIALOG_H | 9 | #undef MINIKDE_KDIALOG_H |
10 | #endif | 10 | #endif |
11 | #include "settingsdialog.h" | 11 | #include "settingsdialog.h" |
12 | #include "opiemail.h" | 12 | #include "opiemail.h" |
13 | #include "editaccounts.h" | 13 | #include "editaccounts.h" |
14 | #include "composemail.h" | 14 | #include "composemail.h" |
15 | #include "mailistviewitem.h" | 15 | #include "mailistviewitem.h" |
16 | #include "viewmail.h" | 16 | #include "viewmail.h" |
17 | #include "selectstore.h" | 17 | #include "selectstore.h" |
18 | #include "selectsmtp.h" | 18 | #include "selectsmtp.h" |
19 | #include "accountitem.h" | 19 | #include "accountitem.h" |
20 | #include "klocale.h" | 20 | #include "klocale.h" |
21 | 21 | ||
22 | #include <qmessagebox.h> | 22 | #include <qmessagebox.h> |
23 | #include <qtimer.h> | 23 | #include <qtimer.h> |
24 | #include <qcursor.h> | 24 | #include <qcursor.h> |
25 | #include <qregexp.h> | 25 | #include <qregexp.h> |
26 | 26 | ||
27 | #ifdef DESKTOP_VERSION | 27 | #ifdef DESKTOP_VERSION |
28 | #include <qapplication.h> | 28 | #include <qapplication.h> |
29 | #else | 29 | #else |
30 | #include <qpe/qpeapplication.h> | 30 | #include <qpe/qpeapplication.h> |
31 | #endif | 31 | #endif |
32 | #include <libmailwrapper/smtpwrapper.h> | 32 | #include <libmailwrapper/smtpwrapper.h> |
33 | #include <libmailwrapper/mailtypes.h> | 33 | #include <libmailwrapper/mailtypes.h> |
34 | #include <libmailwrapper/abstractmail.h> | 34 | #include <libmailwrapper/abstractmail.h> |
35 | 35 | ||
36 | //using namespace Opie::Core; | 36 | //using namespace Opie::Core; |
37 | 37 | ||
38 | OpieMail::OpieMail( QWidget *parent, const char *name ) | 38 | OpieMail::OpieMail( QWidget *parent, const char *name ) |
39 | : MainWindow( parent, name) //, WStyle_ContextHelp ) | 39 | : MainWindow( parent, name) //, WStyle_ContextHelp ) |
40 | { | 40 | { |
41 | settings = new Settings(); | 41 | settings = new Settings(); |
42 | 42 | ||
43 | setIcon(SmallIcon( "kmicromail" ) ); | 43 | setIcon(SmallIcon( "kmicromail" ) ); |
44 | folderView->populate( settings->getAccounts() ); | 44 | folderView->populate( settings->getAccounts() ); |
45 | 45 | ||
46 | } | 46 | } |
47 | 47 | ||
48 | OpieMail::~OpieMail() | 48 | OpieMail::~OpieMail() |
49 | { | 49 | { |
50 | if (settings) delete settings; | 50 | if (settings) delete settings; |
51 | } | 51 | } |
52 | 52 | ||
53 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 53 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
54 | { | 54 | { |
55 | 55 | ||
56 | } | 56 | } |
57 | #include <stdlib.h> | 57 | #include <stdlib.h> |
58 | void OpieMail::message(const QCString &msg, const QByteArray &data) | 58 | void OpieMail::message(const QCString &msg, const QByteArray &data) |
59 | { | 59 | { |
60 | // copied from old mail2 | 60 | // copied from old mail2 |
61 | static int ii = 0; | 61 | static int ii = 0; |
62 | //qDebug("QCOP CALL ############################# %d ", ii); | 62 | //qDebug("QCOP CALL ############################# %d ", ii); |
63 | //QString mess ( msg ); | 63 | //QString mess ( msg ); |
64 | //qDebug("Message = %s ",mess.latin1()); | 64 | //qDebug("Message = %s ",mess.latin1()); |
65 | ++ii; | 65 | ++ii; |
66 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); | 66 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); |
67 | 67 | ||
68 | mPendingEmail = QString::null; | 68 | mPendingEmail = QString::null; |
69 | mPendingName = QString::null; | 69 | mPendingName = QString::null; |
70 | if (msg == "writeMail(QString,QString)") | 70 | if (msg == "writeMail(QString,QString)") |
71 | { | 71 | { |
72 | //qDebug("writeMail(QString,QString) "); | 72 | //qDebug("writeMail(QString,QString) "); |
73 | QDataStream stream(data,IO_ReadOnly); | 73 | QDataStream stream(data,IO_ReadOnly); |
74 | stream >> mPendingName >> mPendingEmail; | 74 | stream >> mPendingName >> mPendingEmail; |
75 | // removing the whitespaces at beginning and end is needed! | 75 | // removing the whitespaces at beginning and end is needed! |
76 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 76 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
77 | } | 77 | } |
78 | else if (msg == "newMail()") | 78 | else if (msg == "newMail()") |
79 | { | 79 | { |
80 | //qDebug("slotComposeMail() "); | 80 | //qDebug("slotComposeMail() "); |
81 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call | 81 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call |
82 | // and a QCOP call does not like a processevents in his execution | 82 | // and a QCOP call does not like a processevents in his execution |
83 | // with the Qtimer we call slotComposeMail() after we reached the main event loop | 83 | // with the Qtimer we call slotComposeMail() after we reached the main event loop |
84 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 84 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
85 | // slotComposeMail(); | 85 | // slotComposeMail(); |
86 | } | 86 | } |
87 | else if (msg == "newMail(QString)") | 87 | else if (msg == "newMail(QString)") |
88 | { | 88 | { |
89 | //qDebug(" newMail(QString)"); | 89 | //qDebug(" newMail(QString)"); |
90 | QDataStream stream(data,IO_ReadOnly); | 90 | QDataStream stream(data,IO_ReadOnly); |
91 | stream >> mPendingName; | 91 | stream >> mPendingName; |
92 | // the format is | 92 | // the format is |
93 | // NAME <EMAIL>:SUBJECT | 93 | // NAME <EMAIL>:SUBJECT |
94 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 94 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
95 | } else { | 95 | } else { |
96 | mPendingData = data; | 96 | mPendingData = data; |
97 | mPendingMessage = msg; | 97 | mPendingMessage = msg; |
98 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); | 98 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); |
99 | } | 99 | } |
100 | 100 | ||
101 | //qDebug("END OpieMail::message "); | 101 | //qDebug("END OpieMail::message "); |
102 | } | 102 | } |
103 | void OpieMail::slotExtAppHandler() | 103 | void OpieMail::slotExtAppHandler() |
104 | { | 104 | { |
105 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); | 105 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); |
106 | } | 106 | } |
107 | void OpieMail::slotwriteMail2(const QString& namemail ) | 107 | void OpieMail::slotwriteMail2(const QString& namemail ) |
108 | { | 108 | { |
109 | //qDebug("OpieMail::slotwriteMail2 "); | 109 | //qDebug("OpieMail::slotwriteMail2 "); |
110 | //qApp->processEvents(); | 110 | //qApp->processEvents(); |
111 | ComposeMail compose( settings, this, 0, true ); | 111 | ComposeMail compose( settings, this, 0, true ); |
112 | if ( !namemail.isEmpty() ) { | 112 | if ( !namemail.isEmpty() ) { |
113 | QString to = namemail; | 113 | QString to = namemail; |
114 | if ( namemail.find( " <") > 1 ) { | 114 | if ( namemail.find( " <") > 1 ) { |
115 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; | 115 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; |
116 | } else | 116 | } else |
117 | if ( namemail.find( "<") > 1 ) { | 117 | if ( namemail.find( "<") > 1 ) { |
118 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; | 118 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; |
119 | } | 119 | } |
120 | int sub = to.find( ">:"); | 120 | int sub = to.find( ">:"); |
121 | if ( sub > 0 ) { | 121 | if ( sub > 0 ) { |
122 | compose.setTo( to.left(sub+1) ); | 122 | compose.setTo( to.left(sub+1) ); |
123 | compose.setSubject( to.mid(sub+2) ); | 123 | compose.setSubject( to.mid(sub+2) ); |
124 | } else | 124 | } else |
125 | compose.setTo( to ); | 125 | compose.setTo( to ); |
126 | } | 126 | } |
127 | compose.slotAdjustColumns(); | 127 | compose.slotAdjustColumns(); |
128 | #ifndef DESKTOP_VERSION | ||
128 | compose.showMaximized(); | 129 | compose.showMaximized(); |
130 | #endif | ||
129 | compose.exec(); | 131 | compose.exec(); |
130 | raise(); | 132 | raise(); |
131 | //qDebug("retttich "); | 133 | //qDebug("retttich "); |
132 | } | 134 | } |
133 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 135 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
134 | { | 136 | { |
135 | // qDebug("OpieMail::slotwriteMail "); | 137 | // qDebug("OpieMail::slotwriteMail "); |
136 | ComposeMail compose( settings, this, 0, true ); | 138 | ComposeMail compose( settings, this, 0, true ); |
137 | if (!email.isEmpty()) | 139 | if (!email.isEmpty()) |
138 | { | 140 | { |
139 | if (!name.isEmpty()) | 141 | if (!name.isEmpty()) |
140 | { | 142 | { |
141 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 143 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
142 | } | 144 | } |
143 | else | 145 | else |
144 | { | 146 | { |
145 | compose.setTo(email); | 147 | compose.setTo(email); |
146 | } | 148 | } |
147 | } | 149 | } |
148 | compose.slotAdjustColumns(); | 150 | compose.slotAdjustColumns(); |
151 | #ifndef DESKTOP_VERSION | ||
149 | compose.showMaximized(); | 152 | compose.showMaximized(); |
153 | #endif | ||
150 | compose.exec(); | 154 | compose.exec(); |
151 | raise(); | 155 | raise(); |
152 | } | 156 | } |
153 | 157 | ||
154 | void OpieMail::slotComposeMail() | 158 | void OpieMail::slotComposeMail() |
155 | { | 159 | { |
156 | if ( mPendingEmail == QString::null && mPendingName == QString::null) | 160 | if ( mPendingEmail == QString::null && mPendingName == QString::null) |
157 | slotwriteMail2( QString () ); | 161 | slotwriteMail2( QString () ); |
158 | else { | 162 | else { |
159 | if ( mPendingEmail == QString::null ) | 163 | if ( mPendingEmail == QString::null ) |
160 | slotwriteMail2( mPendingName ); | 164 | slotwriteMail2( mPendingName ); |
161 | else | 165 | else |
162 | slotwriteMail( mPendingName, mPendingEmail ); | 166 | slotwriteMail( mPendingName, mPendingEmail ); |
163 | } | 167 | } |
164 | //slotwriteMail(0l,0l); | 168 | //slotwriteMail(0l,0l); |
165 | } | 169 | } |
166 | 170 | ||
167 | void OpieMail::slotSendQueued() | 171 | void OpieMail::slotSendQueued() |
168 | { | 172 | { |
169 | SMTPaccount *smtp = 0; | 173 | SMTPaccount *smtp = 0; |
170 | 174 | ||
171 | QList<Account> list = settings->getAccounts(); | 175 | QList<Account> list = settings->getAccounts(); |
172 | QList<SMTPaccount> smtpList; | 176 | QList<SMTPaccount> smtpList; |
173 | smtpList.setAutoDelete(false); | 177 | smtpList.setAutoDelete(false); |
174 | Account *it; | 178 | Account *it; |
175 | for ( it = list.first(); it; it = list.next() ) | 179 | for ( it = list.first(); it; it = list.next() ) |
176 | { | 180 | { |
177 | if ( it->getType() == MAILLIB::A_SMTP ) | 181 | if ( it->getType() == MAILLIB::A_SMTP ) |
178 | { | 182 | { |
179 | smtp = static_cast<SMTPaccount *>(it); | 183 | smtp = static_cast<SMTPaccount *>(it); |
180 | smtpList.append(smtp); | 184 | smtpList.append(smtp); |
181 | } | 185 | } |
182 | } | 186 | } |
183 | if (smtpList.count()==0) | 187 | if (smtpList.count()==0) |
184 | { | 188 | { |
185 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); | 189 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); |
186 | return; | 190 | return; |
187 | } | 191 | } |
188 | if (smtpList.count()==1) | 192 | if (smtpList.count()==1) |
189 | { | 193 | { |
190 | smtp = smtpList.at(0); | 194 | smtp = smtpList.at(0); |
191 | } | 195 | } |
192 | else | 196 | else |
193 | { | 197 | { |
194 | smtp = 0; | 198 | smtp = 0; |
195 | selectsmtp selsmtp; | 199 | selectsmtp selsmtp; |
196 | selsmtp.setSelectionlist(&smtpList); | 200 | selsmtp.setSelectionlist(&smtpList); |
201 | #ifndef DESKTOP_VERSION | ||
197 | selsmtp.showMaximized(); | 202 | selsmtp.showMaximized(); |
203 | #endif | ||
198 | if ( selsmtp.exec() == QDialog::Accepted ) | 204 | if ( selsmtp.exec() == QDialog::Accepted ) |
199 | { | 205 | { |
200 | smtp = selsmtp.selected_smtp(); | 206 | smtp = selsmtp.selected_smtp(); |
201 | } | 207 | } |
202 | } | 208 | } |
203 | if (smtp) | 209 | if (smtp) |
204 | { | 210 | { |
205 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 211 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
206 | if ( wrap->flushOutbox() ) | 212 | if ( wrap->flushOutbox() ) |
207 | { | 213 | { |
208 | QMessageBox::information(0,i18n("Info"),i18n("Mail queue flushed")); | 214 | QMessageBox::information(0,i18n("Info"),i18n("Mail queue flushed")); |
209 | } | 215 | } |
210 | delete wrap; | 216 | delete wrap; |
211 | } | 217 | } |
212 | } | 218 | } |
213 | 219 | ||
214 | void OpieMail::slotSearchMails() | 220 | void OpieMail::slotSearchMails() |
215 | { | 221 | { |
216 | qDebug("OpieMail::slotSearchMails():not implemented "); | 222 | qDebug("OpieMail::slotSearchMails():not implemented "); |
217 | } | 223 | } |
218 | 224 | ||
219 | void OpieMail::slotEditSettings() | 225 | void OpieMail::slotEditSettings() |
220 | { | 226 | { |
221 | 227 | ||
222 | KOPrefsDialog settingsDialog( this, "koprefs", true ); | 228 | KOPrefsDialog settingsDialog( this, "koprefs", true ); |
223 | #ifndef DESKTOP_VERSION | 229 | #ifndef DESKTOP_VERSION |
224 | settingsDialog.showMaximized(); | 230 | settingsDialog.showMaximized(); |
225 | #endif | 231 | #endif |
226 | settingsDialog.exec(); | 232 | settingsDialog.exec(); |
227 | 233 | ||
228 | // KApplication::execDialog(settingsDialog); | 234 | // KApplication::execDialog(settingsDialog); |
229 | } | 235 | } |
230 | 236 | ||
231 | void OpieMail::slotEditAccounts() | 237 | void OpieMail::slotEditAccounts() |
232 | { | 238 | { |
233 | EditAccounts eaDialog( settings, this, 0, true ); | 239 | EditAccounts eaDialog( settings, this, 0, true ); |
234 | eaDialog.slotAdjustColumns(); | 240 | eaDialog.slotAdjustColumns(); |
235 | #ifndef DESKTOP_VERSION | 241 | #ifndef DESKTOP_VERSION |
236 | eaDialog.showMaximized(); | 242 | eaDialog.showMaximized(); |
237 | #endif | 243 | #endif |
238 | eaDialog.exec(); | 244 | eaDialog.exec(); |
239 | if ( settings ) delete settings; | 245 | if ( settings ) delete settings; |
240 | settings = new Settings(); | 246 | settings = new Settings(); |
241 | 247 | ||
242 | folderView->populate( settings->getAccounts() ); | 248 | folderView->populate( settings->getAccounts() ); |
243 | } | 249 | } |
244 | void OpieMail::replyMail() | 250 | void OpieMail::replyMail() |
245 | { | 251 | { |
246 | 252 | ||
247 | QListViewItem*item = mailView->currentItem(); | 253 | QListViewItem*item = mailView->currentItem(); |
248 | if (!item) return; | 254 | if (!item) return; |
249 | RecMailP mail = ((MailListViewItem*)item)->data(); | 255 | RecMailP mail = ((MailListViewItem*)item)->data(); |
250 | RecBodyP body = folderView->fetchBody(mail); | 256 | RecBodyP body = folderView->fetchBody(mail); |
251 | 257 | ||
252 | QString rtext; | 258 | QString rtext; |
253 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 259 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
254 | .arg( QString::fromUtf8( mail->getFrom().latin1())) | 260 | .arg( QString::fromUtf8( mail->getFrom().latin1())) |
255 | .arg( QString::fromUtf8( mail->getDate().latin1() )); | 261 | .arg( QString::fromUtf8( mail->getDate().latin1() )); |
256 | 262 | ||
257 | QString text = QString::fromUtf8( body->Bodytext().latin1() ); | 263 | QString text = QString::fromUtf8( body->Bodytext().latin1() ); |
258 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 264 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
259 | QStringList::Iterator it; | 265 | QStringList::Iterator it; |
260 | for (it = lines.begin(); it != lines.end(); it++) | 266 | for (it = lines.begin(); it != lines.end(); it++) |
261 | { | 267 | { |
262 | rtext += "> " + *it + "\n"; | 268 | rtext += "> " + *it + "\n"; |
263 | } | 269 | } |
264 | rtext += "\n"; | 270 | rtext += "\n"; |
265 | 271 | ||
266 | QString prefix; | 272 | QString prefix; |
267 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 273 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
268 | else prefix = "Re: "; // no i18n on purpose | 274 | else prefix = "Re: "; // no i18n on purpose |
269 | 275 | ||
270 | Settings *settings = new Settings(); | 276 | Settings *settings = new Settings(); |
271 | ComposeMail composer( settings ,this, 0, true); | 277 | ComposeMail composer( settings ,this, 0, true); |
272 | if (mail->Replyto().isEmpty()) { | 278 | if (mail->Replyto().isEmpty()) { |
273 | composer.setTo( QString::fromUtf8( mail->getFrom().latin1())); | 279 | composer.setTo( QString::fromUtf8( mail->getFrom().latin1())); |
274 | } else { | 280 | } else { |
275 | composer.setTo( QString::fromUtf8(mail->Replyto().latin1())); | 281 | composer.setTo( QString::fromUtf8(mail->Replyto().latin1())); |
276 | } | 282 | } |
277 | composer.setSubject( prefix + QString::fromUtf8( mail->getSubject().latin1() ) ); | 283 | composer.setSubject( prefix + QString::fromUtf8( mail->getSubject().latin1() ) ); |
278 | composer.setMessage( rtext ); | 284 | composer.setMessage( rtext ); |
279 | composer.setInReplyTo( QString::fromUtf8(mail->Msgid().latin1())); | 285 | composer.setInReplyTo( QString::fromUtf8(mail->Msgid().latin1())); |
280 | 286 | ||
281 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 287 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
282 | { | 288 | { |
283 | mail->Wrapper()->answeredMail(mail); | 289 | mail->Wrapper()->answeredMail(mail); |
284 | } | 290 | } |
285 | delete settings; | 291 | delete settings; |
286 | 292 | ||
287 | } | 293 | } |
288 | void OpieMail::displayMail() | 294 | void OpieMail::displayMail() |
289 | { | 295 | { |
290 | QListViewItem*item = mailView->currentItem(); | 296 | QListViewItem*item = mailView->currentItem(); |
291 | if (!item) return; | 297 | if (!item) return; |
292 | RecMailP mail = ((MailListViewItem*)item)->data(); | 298 | RecMailP mail = ((MailListViewItem*)item)->data(); |
293 | RecBodyP body = folderView->fetchBody(mail); | 299 | RecBodyP body = folderView->fetchBody(mail); |
294 | ViewMail readMail( this,"", Qt::WType_Modal ); | 300 | ViewMail readMail( this,"", Qt::WType_Modal ); |
295 | readMail.setBody( body ); | 301 | readMail.setBody( body ); |
296 | readMail.setMail( mail ); | 302 | readMail.setMail( mail ); |
297 | #ifndef DESKTOP_VERSION | 303 | #ifndef DESKTOP_VERSION |
298 | readMail.showMaximized(); | 304 | readMail.showMaximized(); |
299 | #else | 305 | #else |
300 | readMail.resize( 640, 480); | 306 | readMail.resize( 640, 480); |
301 | #endif | 307 | #endif |
302 | readMail.exec(); | 308 | readMail.exec(); |
303 | 309 | ||
304 | if ( readMail.deleted ) | 310 | if ( readMail.deleted ) |
305 | { | 311 | { |
306 | folderView->refreshCurrent(); | 312 | folderView->refreshCurrent(); |
307 | } | 313 | } |
308 | else | 314 | else |
309 | { | 315 | { |
310 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 316 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
311 | } | 317 | } |
312 | } | 318 | } |
313 | void OpieMail::slotGetAllMail() | 319 | void OpieMail::slotGetAllMail() |
314 | { | 320 | { |
315 | QListViewItem * item = folderView->firstChild(); | 321 | QListViewItem * item = folderView->firstChild(); |
316 | while ( item ){ | 322 | while ( item ){ |
317 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 323 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
318 | item = item->nextSibling (); | 324 | item = item->nextSibling (); |
319 | } | 325 | } |
320 | } | 326 | } |
321 | void OpieMail::slotGetMail() | 327 | void OpieMail::slotGetMail() |
322 | { | 328 | { |
323 | QListViewItem * item = folderView->currentItem(); | 329 | QListViewItem * item = folderView->currentItem(); |
324 | if ( ! item ) return; | 330 | if ( ! item ) return; |
325 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 331 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
326 | } | 332 | } |
327 | void OpieMail::slotDeleteMail() | 333 | void OpieMail::slotDeleteMail() |
328 | { | 334 | { |
329 | if (!mailView->currentItem()) return; | 335 | if (!mailView->currentItem()) return; |
330 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 336 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
331 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 337 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
332 | { | 338 | { |
333 | mail->Wrapper()->deleteMail( mail ); | 339 | mail->Wrapper()->deleteMail( mail ); |
334 | folderView->refreshCurrent(); | 340 | folderView->refreshCurrent(); |
335 | } | 341 | } |
336 | } | 342 | } |
337 | void OpieMail::slotDeleteAllMail() | 343 | void OpieMail::slotDeleteAllMail() |
338 | { | 344 | { |
339 | 345 | ||
340 | QValueList<RecMailP> t; | 346 | QValueList<RecMailP> t; |
341 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 347 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
342 | { | 348 | { |
343 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 349 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
344 | while ( item ) { | 350 | while ( item ) { |
345 | if ( item->isSelected() ) { | 351 | if ( item->isSelected() ) { |
346 | t.append( item->data() ); | 352 | t.append( item->data() ); |
347 | } | 353 | } |
348 | item = (MailListViewItem*)item->nextSibling(); | 354 | item = (MailListViewItem*)item->nextSibling(); |
349 | } | 355 | } |
350 | } | 356 | } |
351 | else | 357 | else |
352 | return; | 358 | return; |
353 | if ( t.count() == 0 ) | 359 | if ( t.count() == 0 ) |
354 | return; | 360 | return; |
355 | RecMailP mail = t.first(); | 361 | RecMailP mail = t.first(); |
356 | mail->Wrapper()->deleteMailList(t); | 362 | mail->Wrapper()->deleteMailList(t); |
357 | folderView->refreshCurrent(); | 363 | folderView->refreshCurrent(); |
358 | 364 | ||
359 | 365 | ||
360 | } | 366 | } |
361 | void OpieMail::clearSelection() | 367 | void OpieMail::clearSelection() |
362 | { | 368 | { |
363 | mailView->clearSelection(); | 369 | mailView->clearSelection(); |
364 | 370 | ||
365 | } | 371 | } |
366 | 372 | ||
367 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | 373 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) |
368 | { | 374 | { |
369 | if (!mailView->currentItem()) return; | 375 | if (!mailView->currentItem()) return; |
370 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); | 376 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); |
371 | /* just the RIGHT button - or hold on pda */ | 377 | /* just the RIGHT button - or hold on pda */ |
372 | if (button!=2) {return;} | 378 | if (button!=2) {return;} |
373 | if (!item) return; | 379 | if (!item) return; |
374 | QPopupMenu *m = new QPopupMenu(0); | 380 | QPopupMenu *m = new QPopupMenu(0); |
375 | if (m) | 381 | if (m) |
376 | { | 382 | { |
377 | if (mailtype==MAILLIB::A_NNTP) { | 383 | if (mailtype==MAILLIB::A_NNTP) { |
378 | m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); | 384 | m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); |
379 | m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); | 385 | m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); |
380 | m->insertSeparator(); | 386 | m->insertSeparator(); |
381 | m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); | 387 | m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); |
382 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); | 388 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); |
383 | } else { | 389 | } else { |
384 | if (folderView->currentisDraft()) { | 390 | if (folderView->currentisDraft()) { |
385 | m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); | 391 | m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); |
386 | } | 392 | } |
387 | m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); | 393 | m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); |
388 | m->insertSeparator(); | 394 | m->insertSeparator(); |
389 | m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); | 395 | m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); |
390 | m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); | 396 | m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); |
391 | m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); | 397 | m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); |
392 | m->insertSeparator(); | 398 | m->insertSeparator(); |
393 | m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); | 399 | m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); |
394 | m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); | 400 | m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); |
395 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); | 401 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); |
396 | } | 402 | } |
397 | m->setFocus(); | 403 | m->setFocus(); |
398 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 404 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
399 | delete m; | 405 | delete m; |
400 | } | 406 | } |
401 | } | 407 | } |
402 | 408 | ||
403 | void OpieMail::slotShowFolders( bool show ) | 409 | void OpieMail::slotShowFolders( bool show ) |
404 | { | 410 | { |
405 | if ( show && folderView->isHidden() ) | 411 | if ( show && folderView->isHidden() ) |
406 | { | 412 | { |
407 | folderView->show(); | 413 | folderView->show(); |
408 | } | 414 | } |
409 | else if ( !show && !folderView->isHidden() ) | 415 | else if ( !show && !folderView->isHidden() ) |
410 | { | 416 | { |
411 | folderView->hide(); | 417 | folderView->hide(); |
412 | } | 418 | } |
413 | } | 419 | } |
414 | 420 | ||
415 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) | 421 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) |
416 | { | 422 | { |
417 | MailListViewItem*item = 0; | 423 | MailListViewItem*item = 0; |
418 | mailView->clear(); | 424 | mailView->clear(); |
419 | 425 | ||
420 | QValueList<RecMailP>::ConstIterator it; | 426 | QValueList<RecMailP>::ConstIterator it; |
421 | for (it = list.begin(); it != list.end();++it) | 427 | for (it = list.begin(); it != list.end();++it) |
422 | { | 428 | { |
423 | item = new MailListViewItem(mailView,item); | 429 | item = new MailListViewItem(mailView,item); |
424 | item->storeData((*it)); | 430 | item->storeData((*it)); |
425 | item->showEntry(); | 431 | item->showEntry(); |
426 | } | 432 | } |
427 | } | 433 | } |
428 | 434 | ||
429 | void OpieMail::mailLeftClicked( QListViewItem *item ) | 435 | void OpieMail::mailLeftClicked( QListViewItem *item ) |
430 | { | 436 | { |
431 | mailView->clearSelection(); | 437 | mailView->clearSelection(); |
432 | /* just LEFT button - or tap with stylus on pda */ | 438 | /* just LEFT button - or tap with stylus on pda */ |
433 | //if (button!=1) return; | 439 | //if (button!=1) return; |
434 | if (!item) return; | 440 | if (!item) return; |
435 | if (folderView->currentisDraft()) { | 441 | if (folderView->currentisDraft()) { |
436 | reEditMail(); | 442 | reEditMail(); |
437 | } else { | 443 | } else { |
438 | displayMail(); | 444 | displayMail(); |
439 | } | 445 | } |
440 | } | 446 | } |
441 | 447 | ||
442 | void OpieMail::slotMoveCopyMail() | 448 | void OpieMail::slotMoveCopyMail() |
443 | { | 449 | { |
444 | if (!mailView->currentItem()) return; | 450 | if (!mailView->currentItem()) return; |
445 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 451 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
446 | AbstractMail*targetMail = 0; | 452 | AbstractMail*targetMail = 0; |
447 | QString targetFolder = ""; | 453 | QString targetFolder = ""; |
448 | Selectstore sels; | 454 | Selectstore sels; |
449 | folderView->setupFolderselect(&sels); | 455 | folderView->setupFolderselect(&sels); |
450 | if (!sels.exec()) return; | 456 | if (!sels.exec()) return; |
451 | targetMail = sels.currentMail(); | 457 | targetMail = sels.currentMail(); |
452 | targetFolder = sels.currentFolder(); | 458 | targetFolder = sels.currentFolder(); |
453 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || | 459 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || |
454 | targetFolder.isEmpty()) | 460 | targetFolder.isEmpty()) |
455 | { | 461 | { |
456 | return; | 462 | return; |
457 | } | 463 | } |
458 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 464 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
459 | { | 465 | { |
460 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 466 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
461 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); | 467 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); |
462 | return; | 468 | return; |
463 | } | 469 | } |
464 | sels.hide(); | 470 | sels.hide(); |
465 | qApp->processEvents(); | 471 | qApp->processEvents(); |
466 | // qDebug("hiding sels "); | 472 | // qDebug("hiding sels "); |
467 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); | 473 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); |
468 | folderView->refreshCurrent(); | 474 | folderView->refreshCurrent(); |
469 | } | 475 | } |
470 | 476 | ||
471 | void OpieMail::slotMoveCopyAllMail() | 477 | void OpieMail::slotMoveCopyAllMail() |
472 | { | 478 | { |
473 | 479 | ||
474 | if (!mailView->currentItem()) return; | 480 | if (!mailView->currentItem()) return; |
475 | QValueList<RecMailP> t; | 481 | QValueList<RecMailP> t; |
476 | // if ( QMessageBox::warning(this, i18n("Move/Copy all selected mails"), i18n("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 482 | // if ( QMessageBox::warning(this, i18n("Move/Copy all selected mails"), i18n("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
477 | { | 483 | { |
478 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 484 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
479 | while ( item ) { | 485 | while ( item ) { |
480 | if ( item->isSelected() ) { | 486 | if ( item->isSelected() ) { |
481 | t.append( item->data() ); | 487 | t.append( item->data() ); |
482 | } | 488 | } |
483 | item = (MailListViewItem*)item->nextSibling(); | 489 | item = (MailListViewItem*)item->nextSibling(); |
484 | } | 490 | } |
485 | } | 491 | } |
486 | // else | 492 | // else |
487 | // return; | 493 | // return; |
488 | if ( t.count() == 0 ) | 494 | if ( t.count() == 0 ) |
489 | return; | 495 | return; |
490 | RecMailP mail = t.first(); | 496 | RecMailP mail = t.first(); |
491 | AbstractMail*targetMail = 0; | 497 | AbstractMail*targetMail = 0; |
492 | QString targetFolder = ""; | 498 | QString targetFolder = ""; |
493 | Selectstore sels; | 499 | Selectstore sels; |
494 | folderView->setupFolderselect(&sels); | 500 | folderView->setupFolderselect(&sels); |
495 | if (!sels.exec()) return; | 501 | if (!sels.exec()) return; |
496 | targetMail = sels.currentMail(); | 502 | targetMail = sels.currentMail(); |
497 | targetFolder = sels.currentFolder(); | 503 | targetFolder = sels.currentFolder(); |
498 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || | 504 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || |
499 | targetFolder.isEmpty()) | 505 | targetFolder.isEmpty()) |
500 | { | 506 | { |
501 | return; | 507 | return; |
502 | } | 508 | } |
503 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 509 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
504 | { | 510 | { |
505 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 511 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
506 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); | 512 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); |
507 | return; | 513 | return; |
508 | } | 514 | } |
509 | sels.hide(); | 515 | sels.hide(); |
510 | qApp->processEvents(); | 516 | qApp->processEvents(); |
511 | //qDebug("hiding sels "); | 517 | //qDebug("hiding sels "); |
512 | mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); | 518 | mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); |
513 | folderView->refreshCurrent(); | 519 | folderView->refreshCurrent(); |
514 | } | 520 | } |
515 | 521 | ||
516 | void OpieMail::reEditMail() | 522 | void OpieMail::reEditMail() |
517 | { | 523 | { |
518 | if (!mailView->currentItem()) return; | 524 | if (!mailView->currentItem()) return; |
519 | 525 | ||
520 | ComposeMail compose( settings, this, 0, true ); | 526 | ComposeMail compose( settings, this, 0, true ); |
521 | compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); | 527 | compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); |
522 | compose.slotAdjustColumns(); | 528 | compose.slotAdjustColumns(); |
523 | #ifndef DESKTOP_VERSION | 529 | #ifndef DESKTOP_VERSION |
524 | compose.showMaximized(); | 530 | compose.showMaximized(); |
525 | #else | 531 | #else |
526 | compose.resize(640,480); | 532 | compose.resize(640,480); |
527 | #endif | 533 | #endif |
528 | compose.exec(); | 534 | compose.exec(); |
529 | } | 535 | } |