-rw-r--r-- | noncore/net/mail/accountitem.cpp | 155 | ||||
-rw-r--r-- | noncore/net/mail/accountitem.h | 13 | ||||
-rw-r--r-- | noncore/net/mail/accountview.cpp | 52 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 11 | ||||
-rw-r--r-- | noncore/net/mail/defines.h | 27 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 35 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.h | 5 | ||||
-rw-r--r-- | noncore/net/mail/opiemail.cpp | 4 |
8 files changed, 217 insertions, 85 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp index c1574fd..4869df8 100644 --- a/noncore/net/mail/accountitem.cpp +++ b/noncore/net/mail/accountitem.cpp | |||
@@ -1,1135 +1,1152 @@ | |||
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 <opie2/odebug.h> | 12 | #include <opie2/odebug.h> |
13 | #include <qpe/qpeapplication.h> | 13 | #include <qpe/qpeapplication.h> |
14 | 14 | ||
15 | /* QT */ | 15 | /* QT */ |
16 | #include <qpopupmenu.h> | 16 | #include <qpopupmenu.h> |
17 | #include <qmessagebox.h> | 17 | #include <qmessagebox.h> |
18 | 18 | ||
19 | using namespace Opie::Core; | 19 | using namespace Opie::Core; |
20 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} | 20 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} |
21 | /** | 21 | /** |
22 | * POP3 Account stuff | 22 | * POP3 Account stuff |
23 | */ | 23 | */ |
24 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) | 24 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) |
25 | : AccountViewItem( parent ) | 25 | : AccountViewItem( parent ) |
26 | { | 26 | { |
27 | account = a; | 27 | account = a; |
28 | wrapper = AbstractMail::getWrapper( account ); | 28 | wrapper = AbstractMail::getWrapper( account ); |
29 | SETPIX(PIXMAP_POP3FOLDER); | 29 | SETPIX(PIXMAP_POP3FOLDER); |
30 | #if 0 | 30 | #if 0 |
31 | if (!account->getOffline()) | 31 | if (!account->getOffline()) |
32 | { | 32 | { |
33 | setPixmap( 0, ); | 33 | setPixmap( 0, ); |
34 | } | 34 | } |
35 | else | 35 | else |
36 | { | 36 | { |
37 | setPixmap( 0, PIXMAP_OFFLINE ); | 37 | setPixmap( 0, PIXMAP_OFFLINE ); |
38 | } | 38 | } |
39 | #endif | 39 | #endif |
40 | setText( 0, account->getAccountName() ); | 40 | setText( 0, account->getAccountName() ); |
41 | setOpen( true ); | 41 | setOpen( true ); |
42 | } | 42 | } |
43 | 43 | ||
44 | POP3viewItem::~POP3viewItem() | 44 | POP3viewItem::~POP3viewItem() |
45 | { | 45 | { |
46 | delete wrapper; | 46 | delete wrapper; |
47 | } | 47 | } |
48 | 48 | ||
49 | AbstractMail *POP3viewItem::getWrapper() | 49 | AbstractMail *POP3viewItem::getWrapper() |
50 | { | 50 | { |
51 | return wrapper; | 51 | return wrapper; |
52 | } | 52 | } |
53 | 53 | ||
54 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) | 54 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) |
55 | { | 55 | { |
56 | refresh(); | 56 | refresh(); |
57 | } | 57 | } |
58 | 58 | ||
59 | void POP3viewItem::refresh() | 59 | void POP3viewItem::refresh() |
60 | { | 60 | { |
61 | if (account->getOffline()) return; | 61 | if (account->getOffline()) return; |
62 | QValueList<FolderP> *folders = wrapper->listFolders(); | 62 | QValueList<FolderP> *folders = wrapper->listFolders(); |
63 | QListViewItem *child = firstChild(); | 63 | QListViewItem *child = firstChild(); |
64 | while ( child ) | 64 | while ( child ) |
65 | { | 65 | { |
66 | QListViewItem *tmp = child; | 66 | QListViewItem *tmp = child; |
67 | child = child->nextSibling(); | 67 | child = child->nextSibling(); |
68 | delete tmp; | 68 | delete tmp; |
69 | } | 69 | } |
70 | QValueList<FolderP>::ConstIterator it; | 70 | QValueList<FolderP>::ConstIterator it; |
71 | QListViewItem*item = 0; | 71 | QListViewItem*item = 0; |
72 | for ( it = folders->begin(); it!=folders->end(); ++it) | 72 | for ( it = folders->begin(); it!=folders->end(); ++it) |
73 | { | 73 | { |
74 | item = new POP3folderItem( (*it), this , item ); | 74 | item = new POP3folderItem( (*it), this , item ); |
75 | item->setSelectable( (*it)->may_select()); | 75 | item->setSelectable( (*it)->may_select()); |
76 | } | 76 | } |
77 | delete folders; | 77 | delete folders; |
78 | } | 78 | } |
79 | 79 | ||
80 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) | 80 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) |
81 | { | 81 | { |
82 | odebug << "POP3 fetchBody" << oendl; | 82 | odebug << "POP3 fetchBody" << oendl; |
83 | return wrapper->fetchBody( mail ); | 83 | return wrapper->fetchBody( mail ); |
84 | } | 84 | } |
85 | 85 | ||
86 | QPopupMenu * POP3viewItem::getContextMenu() | 86 | QPopupMenu * POP3viewItem::getContextMenu() |
87 | { | 87 | { |
88 | QPopupMenu *m = new QPopupMenu(0); | 88 | QPopupMenu *m = new QPopupMenu(0); |
89 | if (m) | 89 | if (m) |
90 | { | 90 | { |
91 | if (!account->getOffline()) | 91 | if (!account->getOffline()) |
92 | { | 92 | { |
93 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 93 | m->insertItem(QObject::tr("Disconnect",contextName),SERVER_MENU_DISCONNECT); |
94 | m->insertItem(QObject::tr("Set offline",contextName),1); | 94 | m->insertItem(QObject::tr("Set offline",contextName),SERVER_MENU_OFFLINE); |
95 | } | 95 | } |
96 | else | 96 | else |
97 | { | 97 | { |
98 | m->insertItem(QObject::tr("Set online",contextName),1); | 98 | m->insertItem(QObject::tr("Set online",contextName),SERVER_MENU_OFFLINE); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | return m; | 101 | return m; |
102 | } | 102 | } |
103 | 103 | ||
104 | void POP3viewItem::disconnect() | 104 | void POP3viewItem::disconnect() |
105 | { | 105 | { |
106 | QListViewItem *child = firstChild(); | 106 | QListViewItem *child = firstChild(); |
107 | while ( child ) | 107 | while ( child ) |
108 | { | 108 | { |
109 | QListViewItem *tmp = child; | 109 | QListViewItem *tmp = child; |
110 | child = child->nextSibling(); | 110 | child = child->nextSibling(); |
111 | delete tmp; | 111 | delete tmp; |
112 | } | 112 | } |
113 | wrapper->logout(); | 113 | wrapper->logout(); |
114 | } | 114 | } |
115 | 115 | ||
116 | void POP3viewItem::setOnOffline() | 116 | void POP3viewItem::setOnOffline() |
117 | { | 117 | { |
118 | if (!account->getOffline()) | 118 | if (!account->getOffline()) |
119 | { | 119 | { |
120 | disconnect(); | 120 | disconnect(); |
121 | } | 121 | } |
122 | account->setOffline(!account->getOffline()); | 122 | account->setOffline(!account->getOffline()); |
123 | account->save(); | 123 | account->save(); |
124 | SETPIX(PIXMAP_POP3FOLDER); | 124 | SETPIX(PIXMAP_POP3FOLDER); |
125 | refresh(); | 125 | refresh(); |
126 | } | 126 | } |
127 | 127 | ||
128 | void POP3viewItem::contextMenuSelected(int which) | 128 | void POP3viewItem::contextMenuSelected(int which) |
129 | { | 129 | { |
130 | switch (which) | 130 | switch (which) |
131 | { | 131 | { |
132 | case 0: | 132 | case SERVER_MENU_DISCONNECT: |
133 | disconnect(); | 133 | disconnect(); |
134 | break; | 134 | break; |
135 | case 1: | 135 | case SERVER_MENU_OFFLINE: |
136 | setOnOffline(); | 136 | setOnOffline(); |
137 | break; | 137 | break; |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | POP3folderItem::~POP3folderItem() | 141 | POP3folderItem::~POP3folderItem() |
142 | {} | 142 | {} |
143 | 143 | ||
144 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) | 144 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) |
145 | : AccountViewItem(folderInit,parent,after ) | 145 | : AccountViewItem(folderInit,parent,after ) |
146 | { | 146 | { |
147 | pop3 = parent; | 147 | pop3 = parent; |
148 | if (folder->getDisplayName().lower()!="inbox") | 148 | if (folder->getDisplayName().lower()!="inbox") |
149 | { | 149 | { |
150 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 150 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
151 | } | 151 | } |
152 | else | 152 | else |
153 | { | 153 | { |
154 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 154 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
155 | } | 155 | } |
156 | setText( 0, folder->getDisplayName() ); | 156 | setText( 0, folder->getDisplayName() ); |
157 | } | 157 | } |
158 | 158 | ||
159 | void POP3folderItem::refresh(QValueList<RecMailP>&target) | 159 | void POP3folderItem::refresh(QValueList<RecMailP>&target) |
160 | { | 160 | { |
161 | if (folder->may_select()) | 161 | if (folder->may_select()) |
162 | pop3->getWrapper()->listMessages( folder->getName(),target ); | 162 | pop3->getWrapper()->listMessages( folder->getName(),target ); |
163 | } | 163 | } |
164 | 164 | ||
165 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) | 165 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) |
166 | { | 166 | { |
167 | return pop3->getWrapper()->fetchBody(aMail); | 167 | return pop3->getWrapper()->fetchBody(aMail); |
168 | } | 168 | } |
169 | 169 | ||
170 | QPopupMenu * POP3folderItem::getContextMenu() | 170 | QPopupMenu * POP3folderItem::getContextMenu() |
171 | { | 171 | { |
172 | QPopupMenu *m = new QPopupMenu(0); | 172 | QPopupMenu *m = new QPopupMenu(0); |
173 | if (m) | 173 | if (m) |
174 | { | 174 | { |
175 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 175 | m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER); |
176 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 176 | m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); |
177 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | 177 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS); |
178 | } | 178 | } |
179 | return m; | 179 | return m; |
180 | } | 180 | } |
181 | 181 | ||
182 | void POP3folderItem::downloadMails() | 182 | void POP3folderItem::downloadMails() |
183 | { | 183 | { |
184 | AccountView*bl = pop3->accountView(); | 184 | AccountView*bl = pop3->accountView(); |
185 | if (!bl) return; | 185 | if (!bl) return; |
186 | bl->downloadMails(folder,pop3->getWrapper()); | 186 | bl->downloadMails(folder,pop3->getWrapper()); |
187 | } | 187 | } |
188 | 188 | ||
189 | void POP3folderItem::contextMenuSelected(int which) | 189 | void POP3folderItem::contextMenuSelected(int which) |
190 | { | 190 | { |
191 | AccountView * view = (AccountView*)listView(); | 191 | AccountView * view = (AccountView*)listView(); |
192 | switch (which) | 192 | switch (which) |
193 | { | 193 | { |
194 | case 0: | 194 | case FOLDER_MENU_REFRESH_HEADER: |
195 | /* must be 'cause pop3 lists are cached */ | 195 | /* must be 'cause pop3 lists are cached */ |
196 | pop3->getWrapper()->logout(); | 196 | pop3->getWrapper()->logout(); |
197 | view->refreshCurrent(); | 197 | view->refreshCurrent(); |
198 | break; | 198 | break; |
199 | case 1: | 199 | case FOLDER_MENU_DELETE_ALL_MAILS: |
200 | deleteAllMail(pop3->getWrapper(),folder); | 200 | deleteAllMail(pop3->getWrapper(),folder); |
201 | break; | 201 | break; |
202 | case 2: | 202 | case FOLDER_MENU_MOVE_MAILS: |
203 | downloadMails(); | 203 | downloadMails(); |
204 | break; | 204 | break; |
205 | default: | 205 | default: |
206 | break; | 206 | break; |
207 | } | 207 | } |
208 | } | 208 | } |
209 | 209 | ||
210 | /** | 210 | /** |
211 | * NNTP Account stuff | 211 | * NNTP Account stuff |
212 | */ | 212 | */ |
213 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) | 213 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) |
214 | : AccountViewItem( parent ) | 214 | : AccountViewItem( parent ) |
215 | { | 215 | { |
216 | account = a; | 216 | account = a; |
217 | wrapper = AbstractMail::getWrapper( account ); | 217 | wrapper = AbstractMail::getWrapper( account ); |
218 | //FIXME | 218 | //FIXME |
219 | SETPIX(PIXMAP_POP3FOLDER); | 219 | SETPIX(PIXMAP_POP3FOLDER); |
220 | #if 0 | 220 | #if 0 |
221 | if (!account->getOffline()) | 221 | if (!account->getOffline()) |
222 | { | 222 | { |
223 | setPixmap( 0, ); | 223 | setPixmap( 0, ); |
224 | } | 224 | } |
225 | else | 225 | else |
226 | { | 226 | { |
227 | setPixmap( 0, PIXMAP_OFFLINE ); | 227 | setPixmap( 0, PIXMAP_OFFLINE ); |
228 | } | 228 | } |
229 | #endif | 229 | #endif |
230 | setText( 0, account->getAccountName() ); | 230 | setText( 0, account->getAccountName() ); |
231 | setOpen( true ); | 231 | setOpen( true ); |
232 | } | 232 | } |
233 | 233 | ||
234 | NNTPviewItem::~NNTPviewItem() | 234 | NNTPviewItem::~NNTPviewItem() |
235 | { | 235 | { |
236 | delete wrapper; | 236 | delete wrapper; |
237 | } | 237 | } |
238 | 238 | ||
239 | AbstractMail *NNTPviewItem::getWrapper() | 239 | AbstractMail *NNTPviewItem::getWrapper() |
240 | { | 240 | { |
241 | return wrapper; | 241 | return wrapper; |
242 | } | 242 | } |
243 | 243 | ||
244 | void NNTPviewItem::refresh( QValueList<RecMailP> & ) | 244 | void NNTPviewItem::refresh( QValueList<RecMailP> & ) |
245 | { | 245 | { |
246 | refresh(); | 246 | refresh(); |
247 | } | 247 | } |
248 | 248 | ||
249 | void NNTPviewItem::refresh() | 249 | void NNTPviewItem::refresh() |
250 | { | 250 | { |
251 | if (account->getOffline()) return; | 251 | if (account->getOffline()) return; |
252 | QValueList<FolderP> *folders = wrapper->listFolders(); | 252 | QValueList<FolderP> *folders = wrapper->listFolders(); |
253 | 253 | ||
254 | QListViewItem *child = firstChild(); | 254 | QListViewItem *child = firstChild(); |
255 | while ( child ) | 255 | while ( child ) |
256 | { | 256 | { |
257 | QListViewItem *tmp = child; | 257 | QListViewItem *tmp = child; |
258 | child = child->nextSibling(); | 258 | child = child->nextSibling(); |
259 | delete tmp; | 259 | delete tmp; |
260 | } | 260 | } |
261 | QValueList<FolderP>::ConstIterator it; | 261 | QValueList<FolderP>::ConstIterator it; |
262 | QListViewItem*item = 0; | 262 | QListViewItem*item = 0; |
263 | for ( it = folders->begin(); it!=folders->end(); ++it) | 263 | for ( it = folders->begin(); it!=folders->end(); ++it) |
264 | { | 264 | { |
265 | item = new NNTPfolderItem( (*it), this , item ); | 265 | item = new NNTPfolderItem( (*it), this , item ); |
266 | item->setSelectable( (*it)->may_select()); | 266 | item->setSelectable( (*it)->may_select()); |
267 | } | 267 | } |
268 | delete folders; | 268 | delete folders; |
269 | } | 269 | } |
270 | 270 | ||
271 | RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) | 271 | RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) |
272 | { | 272 | { |
273 | odebug << "NNTP fetchBody" << oendl; | 273 | odebug << "NNTP fetchBody" << oendl; |
274 | return wrapper->fetchBody( mail ); | 274 | return wrapper->fetchBody( mail ); |
275 | } | 275 | } |
276 | 276 | ||
277 | QPopupMenu * NNTPviewItem::getContextMenu() | 277 | QPopupMenu * NNTPviewItem::getContextMenu() |
278 | { | 278 | { |
279 | QPopupMenu *m = new QPopupMenu(0); | 279 | QPopupMenu *m = new QPopupMenu(0); |
280 | if (m) | 280 | if (m) |
281 | { | 281 | { |
282 | if (!account->getOffline()) | 282 | if (!account->getOffline()) |
283 | { | 283 | { |
284 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 284 | m->insertItem(QObject::tr("Disconnect",contextName),SERVER_MENU_DISCONNECT); |
285 | m->insertItem(QObject::tr("Set offline",contextName),1); | 285 | m->insertItem(QObject::tr("Set offline",contextName),SERVER_MENU_OFFLINE); |
286 | m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2); | 286 | m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),SERVER_MENU_SUBSCRIBE); |
287 | } | 287 | } |
288 | else | 288 | else |
289 | { | 289 | { |
290 | m->insertItem(QObject::tr("Set online",contextName),1); | 290 | m->insertItem(QObject::tr("Set online",contextName),SERVER_MENU_OFFLINE); |
291 | } | 291 | } |
292 | } | 292 | } |
293 | return m; | 293 | return m; |
294 | } | 294 | } |
295 | 295 | ||
296 | void NNTPviewItem::subscribeGroups() | 296 | void NNTPviewItem::subscribeGroups() |
297 | { | 297 | { |
298 | NNTPGroupsDlg dlg(account); | 298 | NNTPGroupsDlg dlg(account); |
299 | if (QPEApplication::execDialog(&dlg)== QDialog::Accepted ){ | 299 | if (QPEApplication::execDialog(&dlg)== QDialog::Accepted ){ |
300 | refresh(); | 300 | refresh(); |
301 | } | 301 | } |
302 | } | 302 | } |
303 | 303 | ||
304 | void NNTPviewItem::disconnect() | 304 | void NNTPviewItem::disconnect() |
305 | { | 305 | { |
306 | QListViewItem *child = firstChild(); | 306 | QListViewItem *child = firstChild(); |
307 | while ( child ) | 307 | while ( child ) |
308 | { | 308 | { |
309 | QListViewItem *tmp = child; | 309 | QListViewItem *tmp = child; |
310 | child = child->nextSibling(); | 310 | child = child->nextSibling(); |
311 | delete tmp; | 311 | delete tmp; |
312 | } | 312 | } |
313 | wrapper->logout(); | 313 | wrapper->logout(); |
314 | } | 314 | } |
315 | 315 | ||
316 | void NNTPviewItem::setOnOffline() | 316 | void NNTPviewItem::setOnOffline() |
317 | { | 317 | { |
318 | if (!account->getOffline()) | 318 | if (!account->getOffline()) |
319 | { | 319 | { |
320 | disconnect(); | 320 | disconnect(); |
321 | } | 321 | } |
322 | account->setOffline(!account->getOffline()); | 322 | account->setOffline(!account->getOffline()); |
323 | account->save(); | 323 | account->save(); |
324 | //FIXME | 324 | //FIXME |
325 | SETPIX(PIXMAP_POP3FOLDER); | 325 | SETPIX(PIXMAP_POP3FOLDER); |
326 | refresh(); | 326 | refresh(); |
327 | } | 327 | } |
328 | 328 | ||
329 | void NNTPviewItem::contextMenuSelected(int which) | 329 | void NNTPviewItem::contextMenuSelected(int which) |
330 | { | 330 | { |
331 | switch (which) | 331 | switch (which) |
332 | { | 332 | { |
333 | case 0: | 333 | case SERVER_MENU_DISCONNECT: |
334 | disconnect(); | 334 | disconnect(); |
335 | break; | 335 | break; |
336 | case 1: | 336 | case SERVER_MENU_OFFLINE: |
337 | setOnOffline(); | 337 | setOnOffline(); |
338 | break; | 338 | break; |
339 | case 2: | 339 | case SERVER_MENU_SUBSCRIBE: |
340 | subscribeGroups(); | 340 | subscribeGroups(); |
341 | break; | 341 | break; |
342 | } | 342 | } |
343 | } | 343 | } |
344 | 344 | ||
345 | NNTPfolderItem::~NNTPfolderItem() | 345 | NNTPfolderItem::~NNTPfolderItem() |
346 | {} | 346 | {} |
347 | 347 | ||
348 | NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) | 348 | NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) |
349 | : AccountViewItem( folderInit, parent,after ) | 349 | : AccountViewItem( folderInit, parent,after ) |
350 | { | 350 | { |
351 | nntp = parent; | 351 | nntp = parent; |
352 | if (folder->getDisplayName().lower()!="inbox") | 352 | if (folder->getDisplayName().lower()!="inbox") |
353 | { | 353 | { |
354 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 354 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
355 | } | 355 | } |
356 | else | 356 | else |
357 | { | 357 | { |
358 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 358 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
359 | } | 359 | } |
360 | setText( 0, folder->getDisplayName() ); | 360 | setText( 0, folder->getDisplayName() ); |
361 | } | 361 | } |
362 | 362 | ||
363 | void NNTPfolderItem::refresh(QValueList<RecMailP>&target) | 363 | void NNTPfolderItem::refresh(QValueList<RecMailP>&target) |
364 | { | 364 | { |
365 | if (folder->may_select()) | 365 | if (folder->may_select()) |
366 | nntp->getWrapper()->listMessages( folder->getName(),target ); | 366 | nntp->getWrapper()->listMessages( folder->getName(),target ); |
367 | } | 367 | } |
368 | 368 | ||
369 | RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) | 369 | RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) |
370 | { | 370 | { |
371 | return nntp->getWrapper()->fetchBody(aMail); | 371 | return nntp->getWrapper()->fetchBody(aMail); |
372 | } | 372 | } |
373 | 373 | ||
374 | QPopupMenu * NNTPfolderItem::getContextMenu() | 374 | QPopupMenu * NNTPfolderItem::getContextMenu() |
375 | { | 375 | { |
376 | QPopupMenu *m = new QPopupMenu(0); | 376 | QPopupMenu *m = new QPopupMenu(0); |
377 | if (m) | 377 | if (m) |
378 | { | 378 | { |
379 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 379 | m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER); |
380 | m->insertItem(QObject::tr("Copy all postings",contextName),1); | 380 | m->insertItem(QObject::tr("Copy all postings",contextName),FOLDER_MENU_MOVE_MAILS); |
381 | } | 381 | } |
382 | return m; | 382 | return m; |
383 | } | 383 | } |
384 | 384 | ||
385 | void NNTPfolderItem::downloadMails() | 385 | void NNTPfolderItem::downloadMails() |
386 | { | 386 | { |
387 | AccountView*bl = nntp->accountView(); | 387 | AccountView*bl = nntp->accountView(); |
388 | if (!bl) return; | 388 | if (!bl) return; |
389 | bl->downloadMails(folder,nntp->getWrapper()); | 389 | bl->downloadMails(folder,nntp->getWrapper()); |
390 | } | 390 | } |
391 | 391 | ||
392 | void NNTPfolderItem::contextMenuSelected(int which) | 392 | void NNTPfolderItem::contextMenuSelected(int which) |
393 | { | 393 | { |
394 | AccountView * view = (AccountView*)listView(); | 394 | AccountView * view = (AccountView*)listView(); |
395 | switch (which) | 395 | switch (which) |
396 | { | 396 | { |
397 | case 0: | 397 | case FOLDER_MENU_REFRESH_HEADER: |
398 | /* must be 'cause pop3 lists are cached */ | 398 | /* must be 'cause nntp lists are cached */ |
399 | nntp->getWrapper()->logout(); | 399 | nntp->getWrapper()->logout(); |
400 | view->refreshCurrent(); | 400 | view->refreshCurrent(); |
401 | break; | 401 | break; |
402 | case 1: | 402 | case FOLDER_MENU_MOVE_MAILS: |
403 | downloadMails(); | 403 | downloadMails(); |
404 | break; | 404 | break; |
405 | default: | 405 | default: |
406 | break; | 406 | break; |
407 | } | 407 | } |
408 | } | 408 | } |
409 | 409 | ||
410 | /** | 410 | /** |
411 | * IMAP Account stuff | 411 | * IMAP Account stuff |
412 | */ | 412 | */ |
413 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) | 413 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) |
414 | : AccountViewItem( parent ) | 414 | : AccountViewItem( parent ) |
415 | { | 415 | { |
416 | account = a; | 416 | account = a; |
417 | wrapper = AbstractMail::getWrapper( account ); | 417 | wrapper = AbstractMail::getWrapper( account ); |
418 | SETPIX(PIXMAP_IMAPFOLDER); | 418 | SETPIX(PIXMAP_IMAPFOLDER); |
419 | setText( 0, account->getAccountName() ); | 419 | setText( 0, account->getAccountName() ); |
420 | setOpen( true ); | 420 | setOpen( true ); |
421 | } | 421 | } |
422 | 422 | ||
423 | IMAPviewItem::~IMAPviewItem() | 423 | IMAPviewItem::~IMAPviewItem() |
424 | { | 424 | { |
425 | delete wrapper; | 425 | delete wrapper; |
426 | } | 426 | } |
427 | 427 | ||
428 | AbstractMail *IMAPviewItem::getWrapper() | 428 | AbstractMail *IMAPviewItem::getWrapper() |
429 | { | 429 | { |
430 | return wrapper; | 430 | return wrapper; |
431 | } | 431 | } |
432 | 432 | ||
433 | void IMAPviewItem::refresh(QValueList<RecMailP>&) | 433 | void IMAPviewItem::refresh(QValueList<RecMailP>&) |
434 | { | 434 | { |
435 | refreshFolders(false); | 435 | refreshFolders(false); |
436 | } | 436 | } |
437 | 437 | ||
438 | const QStringList&IMAPviewItem::subFolders() | 438 | const QStringList&IMAPviewItem::subFolders() |
439 | { | 439 | { |
440 | return currentFolders; | 440 | return currentFolders; |
441 | } | 441 | } |
442 | 442 | ||
443 | void IMAPviewItem::refreshFolders(bool force) | 443 | void IMAPviewItem::refreshFolders(bool force) |
444 | { | 444 | { |
445 | if (childCount()>0 && force==false) return; | 445 | if (childCount()>0 && force==false) return; |
446 | if (account->getOffline()) return; | 446 | if (account->getOffline()) return; |
447 | 447 | ||
448 | removeChilds(); | 448 | removeChilds(); |
449 | currentFolders.clear(); | 449 | currentFolders.clear(); |
450 | QValueList<FolderP> * folders = wrapper->listFolders(); | 450 | QValueList<FolderP> * folders = wrapper->listFolders(); |
451 | 451 | ||
452 | QValueList<FolderP>::Iterator it; | 452 | QValueList<FolderP>::Iterator it; |
453 | QListViewItem*item = 0; | 453 | QListViewItem*item = 0; |
454 | QListViewItem*titem = 0; | 454 | QListViewItem*titem = 0; |
455 | QString fname,del,search; | 455 | QString fname,del,search; |
456 | int pos; | 456 | int pos; |
457 | 457 | ||
458 | for ( it = folders->begin(); it!=folders->end(); ++it) | 458 | for ( it = folders->begin(); it!=folders->end(); ++it) |
459 | { | 459 | { |
460 | if ((*it)->getDisplayName().lower()=="inbox") | 460 | if ((*it)->getDisplayName().lower()=="inbox") |
461 | { | 461 | { |
462 | item = new IMAPfolderItem( (*it), this , item ); | 462 | item = new IMAPfolderItem( (*it), this , item ); |
463 | folders->remove(it); | 463 | folders->remove(it); |
464 | odebug << "inbox found" << oendl; | 464 | odebug << "inbox found" << oendl; |
465 | break; | 465 | break; |
466 | } | 466 | } |
467 | } | 467 | } |
468 | for ( it = folders->begin(); it!=folders->end(); ++it) | 468 | for ( it = folders->begin(); it!=folders->end(); ++it) |
469 | { | 469 | { |
470 | fname = (*it)->getDisplayName(); | 470 | fname = (*it)->getDisplayName(); |
471 | currentFolders.append((*it)->getName()); | 471 | currentFolders.append((*it)->getName()); |
472 | pos = fname.findRev((*it)->Separator()); | 472 | pos = fname.findRev((*it)->Separator()); |
473 | if (pos != -1) | 473 | if (pos != -1) |
474 | { | 474 | { |
475 | fname = fname.left(pos); | 475 | fname = fname.left(pos); |
476 | } | 476 | } |
477 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); | 477 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); |
478 | if (pitem) | 478 | if (pitem) |
479 | { | 479 | { |
480 | titem = item; | 480 | titem = item; |
481 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); | 481 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); |
482 | /* setup the short name */ | 482 | /* setup the short name */ |
483 | item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); | 483 | item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); |
484 | item = titem; | 484 | item = titem; |
485 | } | 485 | } |
486 | else | 486 | else |
487 | { | 487 | { |
488 | item = new IMAPfolderItem( (*it), this , item ); | 488 | item = new IMAPfolderItem( (*it), this , item ); |
489 | } | 489 | } |
490 | } | 490 | } |
491 | delete folders; | 491 | delete folders; |
492 | } | 492 | } |
493 | 493 | ||
494 | QPopupMenu * IMAPviewItem::getContextMenu() | 494 | QPopupMenu * IMAPviewItem::getContextMenu() |
495 | { | 495 | { |
496 | QPopupMenu *m = new QPopupMenu(0); | 496 | QPopupMenu *m = new QPopupMenu(0); |
497 | if (m) | 497 | if (m) |
498 | { | 498 | { |
499 | if (!account->getOffline()) | 499 | if (!account->getOffline()) |
500 | { | 500 | { |
501 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 501 | m->insertItem(QObject::tr("Disconnect",contextName),SERVER_MENU_DISCONNECT); |
502 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 502 | m->insertItem(QObject::tr("Set offline",contextName),SERVER_MENU_OFFLINE); |
503 | m->insertSeparator(); | 503 | m->insertSeparator(); |
504 | m->insertItem(QObject::tr("Disconnect",contextName),2); | 504 | m->insertItem(QObject::tr("Refresh folder list",contextName),SERVER_MENU_REFRESH_FOLDER); |
505 | m->insertItem(QObject::tr("Set offline",contextName),3); | 505 | m->insertItem(QObject::tr("Create new folder",contextName),SERVER_MENU_CREATE_FOLDER); |
506 | } | 506 | } |
507 | else | 507 | else |
508 | { | 508 | { |
509 | m->insertItem(QObject::tr("Set online",contextName),3); | 509 | m->insertItem(QObject::tr("Set online",contextName),SERVER_MENU_OFFLINE); |
510 | } | 510 | } |
511 | } | 511 | } |
512 | return m; | 512 | return m; |
513 | } | 513 | } |
514 | 514 | ||
515 | void IMAPviewItem::createNewFolder() | 515 | void IMAPviewItem::createNewFolder() |
516 | { | 516 | { |
517 | Newmdirdlg ndirdlg; | 517 | Newmdirdlg ndirdlg; |
518 | if ( QPEApplication::execDialog( &ndirdlg )) | 518 | if ( QPEApplication::execDialog( &ndirdlg )) |
519 | { | 519 | { |
520 | QString ndir = ndirdlg.Newdir(); | 520 | QString ndir = ndirdlg.Newdir(); |
521 | bool makesubs = ndirdlg.subpossible(); | 521 | bool makesubs = ndirdlg.subpossible(); |
522 | QString delemiter = "/"; | 522 | QString delemiter = "/"; |
523 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); | 523 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); |
524 | if (item) | 524 | if (item) |
525 | { | 525 | { |
526 | delemiter = item->Delemiter(); | 526 | delemiter = item->Delemiter(); |
527 | } | 527 | } |
528 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) | 528 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) |
529 | { | 529 | { |
530 | refreshFolders(true); | 530 | refreshFolders(true); |
531 | } | 531 | } |
532 | } | 532 | } |
533 | } | 533 | } |
534 | 534 | ||
535 | void IMAPviewItem::contextMenuSelected(int id) | 535 | void IMAPviewItem::contextMenuSelected(int id) |
536 | { | 536 | { |
537 | odebug << "Id selected: " << id << "" << oendl; | 537 | odebug << "Id selected: " << id << "" << oendl; |
538 | switch (id) | 538 | switch (id) |
539 | { | 539 | { |
540 | case 0: | 540 | case SERVER_MENU_REFRESH_FOLDER: |
541 | refreshFolders(true); | 541 | refreshFolders(true); |
542 | break; | 542 | break; |
543 | case 1: | 543 | case SERVER_MENU_CREATE_FOLDER: |
544 | createNewFolder(); | 544 | createNewFolder(); |
545 | break; | 545 | break; |
546 | case 2: | 546 | case SERVER_MENU_DISCONNECT: |
547 | removeChilds(); | 547 | removeChilds(); |
548 | wrapper->logout(); | 548 | wrapper->logout(); |
549 | break; | 549 | break; |
550 | case 3: | 550 | case SERVER_MENU_OFFLINE: |
551 | if (account->getOffline()==false) | 551 | if (account->getOffline()==false) |
552 | { | 552 | { |
553 | removeChilds(); | 553 | removeChilds(); |
554 | wrapper->logout(); | 554 | wrapper->logout(); |
555 | } | 555 | } |
556 | account->setOffline(!account->getOffline()); | 556 | account->setOffline(!account->getOffline()); |
557 | account->save(); | 557 | account->save(); |
558 | SETPIX(PIXMAP_IMAPFOLDER); | 558 | SETPIX(PIXMAP_IMAPFOLDER); |
559 | refreshFolders(false); | 559 | refreshFolders(false); |
560 | break; | 560 | break; |
561 | default: | 561 | default: |
562 | break; | 562 | break; |
563 | } | 563 | } |
564 | } | 564 | } |
565 | 565 | ||
566 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) | 566 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) |
567 | { | 567 | { |
568 | return new RecBody(); | 568 | return new RecBody(); |
569 | } | 569 | } |
570 | 570 | ||
571 | bool IMAPviewItem::offline() | 571 | bool IMAPviewItem::offline() |
572 | { | 572 | { |
573 | return account->getOffline(); | 573 | return account->getOffline(); |
574 | } | 574 | } |
575 | 575 | ||
576 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) | 576 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) |
577 | : AccountViewItem( folderInit, parent , after ) | 577 | : AccountViewItem( folderInit, parent , after ) |
578 | { | 578 | { |
579 | imap = parent; | 579 | imap = parent; |
580 | if (folder->getDisplayName().lower()!="inbox") | 580 | if (folder->getDisplayName().lower()!="inbox") |
581 | { | 581 | { |
582 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 582 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
583 | } | 583 | } |
584 | else | 584 | else |
585 | { | 585 | { |
586 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 586 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
587 | } | 587 | } |
588 | setText( 0, folder->getDisplayName() ); | 588 | setText( 0, folder->getDisplayName() ); |
589 | } | 589 | } |
590 | 590 | ||
591 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) | 591 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) |
592 | : AccountViewItem(folderInit, parent,after ) | 592 | : AccountViewItem(folderInit, parent,after ) |
593 | { | 593 | { |
594 | imap = master; | 594 | imap = master; |
595 | if (folder->getDisplayName().lower()!="inbox") | 595 | if (folder->getDisplayName().lower()!="inbox") |
596 | { | 596 | { |
597 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 597 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
598 | } | 598 | } |
599 | else | 599 | else |
600 | { | 600 | { |
601 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 601 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
602 | } | 602 | } |
603 | setText( 0, folder->getDisplayName() ); | 603 | setText( 0, folder->getDisplayName() ); |
604 | } | 604 | } |
605 | 605 | ||
606 | IMAPfolderItem::~IMAPfolderItem() | 606 | IMAPfolderItem::~IMAPfolderItem() |
607 | {} | 607 | {} |
608 | 608 | ||
609 | const QString& IMAPfolderItem::Delemiter()const | 609 | const QString& IMAPfolderItem::Delemiter()const |
610 | { | 610 | { |
611 | return folder->Separator(); | 611 | return folder->Separator(); |
612 | } | 612 | } |
613 | 613 | ||
614 | void IMAPfolderItem::refresh(QValueList<RecMailP>&target) | 614 | void IMAPfolderItem::refresh(QValueList<RecMailP>&target) |
615 | { | 615 | { |
616 | if (folder->may_select()) | 616 | if (folder->may_select()) |
617 | { | 617 | { |
618 | imap->getWrapper()->listMessages( folder->getName(),target ); | 618 | imap->getWrapper()->listMessages( folder->getName(),target ); |
619 | } | 619 | } |
620 | else | 620 | else |
621 | { | 621 | { |
622 | target.clear(); | 622 | target.clear(); |
623 | } | 623 | } |
624 | } | 624 | } |
625 | 625 | ||
626 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) | 626 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) |
627 | { | 627 | { |
628 | return imap->getWrapper()->fetchBody(aMail); | 628 | return imap->getWrapper()->fetchBody(aMail); |
629 | } | 629 | } |
630 | 630 | ||
631 | QPopupMenu * IMAPfolderItem::getContextMenu() | 631 | QPopupMenu * IMAPfolderItem::getContextMenu() |
632 | { | 632 | { |
633 | QPopupMenu *m = new QPopupMenu(0); | 633 | QPopupMenu *m = new QPopupMenu(0); |
634 | if (m) | 634 | if (m) |
635 | { | 635 | { |
636 | if (folder->may_select()) | 636 | if (folder->may_select()) |
637 | { | 637 | { |
638 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 638 | m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER); |
639 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); | 639 | m->insertItem(QObject::tr("Move/Copy all mails",contextName),FOLDER_MENU_MOVE_MAILS); |
640 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 640 | m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); |
641 | } | 641 | } |
642 | if (folder->no_inferior()==false) | 642 | if (folder->no_inferior()==false) |
643 | { | 643 | { |
644 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); | 644 | m->insertItem(QObject::tr("Create new subfolder",contextName),FOLDER_MENU_NEW_SUBFOLDER); |
645 | } | 645 | } |
646 | if (folder->getDisplayName().lower()!="inbox") | 646 | if (folder->getDisplayName().lower()!="inbox") |
647 | { | 647 | { |
648 | m->insertItem(QObject::tr("Delete folder",contextName),3); | 648 | m->insertItem(QObject::tr("Delete folder",contextName),FOLDER_MENU_DELETE_FOLDER); |
649 | } | 649 | } |
650 | } | 650 | } |
651 | return m; | 651 | return m; |
652 | } | 652 | } |
653 | 653 | ||
654 | void IMAPfolderItem::createNewFolder() | 654 | void IMAPfolderItem::createNewFolder() |
655 | { | 655 | { |
656 | Newmdirdlg ndirdlg; | 656 | Newmdirdlg ndirdlg; |
657 | if ( QPEApplication::execDialog( &ndirdlg ) ) | 657 | if ( QPEApplication::execDialog( &ndirdlg ) ) |
658 | { | 658 | { |
659 | QString ndir = ndirdlg.Newdir(); | 659 | QString ndir = ndirdlg.Newdir(); |
660 | bool makesubs = ndirdlg.subpossible(); | 660 | bool makesubs = ndirdlg.subpossible(); |
661 | QString delemiter = Delemiter(); | 661 | QString delemiter = Delemiter(); |
662 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) | 662 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) |
663 | { | 663 | { |
664 | imap->refreshFolders(true); | 664 | imap->refreshFolders(true); |
665 | } | 665 | } |
666 | } | 666 | } |
667 | } | 667 | } |
668 | 668 | ||
669 | void IMAPfolderItem::deleteFolder() | 669 | void IMAPfolderItem::deleteFolder() |
670 | { | 670 | { |
671 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | 671 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), |
672 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | 672 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), |
673 | QObject::tr("Yes",contextName), | 673 | QObject::tr("Yes",contextName), |
674 | QObject::tr("No",contextName),QString::null,1,1); | 674 | QObject::tr("No",contextName),QString::null,1,1); |
675 | odebug << "Auswahl: " << yesno << "" << oendl; | 675 | odebug << "Auswahl: " << yesno << "" << oendl; |
676 | if (yesno == 0) | 676 | if (yesno == 0) |
677 | { | 677 | { |
678 | if (imap->getWrapper()->deleteMbox(folder)) | 678 | if (imap->getWrapper()->deleteMbox(folder)) |
679 | { | 679 | { |
680 | QListView*v=listView(); | 680 | QListView*v=listView(); |
681 | IMAPviewItem * box = imap; | 681 | IMAPviewItem * box = imap; |
682 | /* be carefull - after that this object is destroyd so don't use | 682 | /* be carefull - after that this object is destroyd so don't use |
683 | * any member of it after that call!!*/ | 683 | * any member of it after that call!!*/ |
684 | imap->refreshFolders(true); | 684 | imap->refreshFolders(true); |
685 | if (v) | 685 | if (v) |
686 | { | 686 | { |
687 | v->setSelected(box,true); | 687 | v->setSelected(box,true); |
688 | } | 688 | } |
689 | } | 689 | } |
690 | } | 690 | } |
691 | } | 691 | } |
692 | 692 | ||
693 | void IMAPfolderItem::downloadMails() | 693 | void IMAPfolderItem::downloadMails() |
694 | { | 694 | { |
695 | AccountView*bl = imap->accountView(); | 695 | AccountView*bl = imap->accountView(); |
696 | if (!bl) return; | 696 | if (!bl) return; |
697 | bl->downloadMails(folder,imap->getWrapper()); | 697 | bl->downloadMails(folder,imap->getWrapper()); |
698 | } | 698 | } |
699 | 699 | ||
700 | void IMAPfolderItem::contextMenuSelected(int id) | 700 | void IMAPfolderItem::contextMenuSelected(int id) |
701 | { | 701 | { |
702 | odebug << "Selected id: " << id << "" << oendl; | 702 | odebug << "Selected id: " << id << "" << oendl; |
703 | AccountView * view = (AccountView*)listView(); | 703 | AccountView * view = (AccountView*)listView(); |
704 | switch(id) | 704 | switch(id) |
705 | { | 705 | { |
706 | case 0: | 706 | case FOLDER_MENU_REFRESH_HEADER: |
707 | view->refreshCurrent(); | 707 | view->refreshCurrent(); |
708 | break; | 708 | break; |
709 | case 1: | 709 | case FOLDER_MENU_DELETE_ALL_MAILS: |
710 | deleteAllMail(imap->getWrapper(),folder); | 710 | deleteAllMail(imap->getWrapper(),folder); |
711 | break; | 711 | break; |
712 | case 2: | 712 | case FOLDER_MENU_NEW_SUBFOLDER: |
713 | createNewFolder(); | 713 | if (folder->no_inferior()==false) { |
714 | createNewFolder(); | ||
715 | } | ||
714 | break; | 716 | break; |
715 | case 3: | 717 | case FOLDER_MENU_DELETE_FOLDER: |
716 | deleteFolder(); | 718 | if (folder->getDisplayName().lower()!="inbox") { |
719 | deleteFolder(); | ||
720 | } | ||
717 | break; | 721 | break; |
718 | case 4: | 722 | case FOLDER_MENU_MOVE_MAILS: |
719 | downloadMails(); | 723 | downloadMails(); |
720 | break; | 724 | break; |
721 | default: | 725 | default: |
722 | break; | 726 | break; |
723 | } | 727 | } |
724 | } | 728 | } |
725 | 729 | ||
726 | /** | 730 | /** |
727 | * MH Account stuff | 731 | * MH Account stuff |
728 | */ | 732 | */ |
729 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and | 733 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and |
730 | POP3 and MBOX */ | 734 | POP3 and MBOX */ |
731 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) | 735 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) |
732 | : AccountViewItem( parent ) | 736 | : AccountViewItem( parent ) |
733 | { | 737 | { |
734 | m_Path = aPath; | 738 | m_Path = aPath; |
735 | /* be carefull - the space within settext is wanted - thats why the string twice */ | 739 | /* be carefull - the space within settext is wanted - thats why the string twice */ |
736 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); | 740 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); |
737 | setPixmap( 0, PIXMAP_LOCALFOLDER ); | 741 | setPixmap( 0, PIXMAP_LOCALFOLDER ); |
738 | setText( 0, " Local Folders" ); | 742 | setText( 0, " Local Folders" ); |
739 | setOpen( true ); | 743 | setOpen( true ); |
740 | folder = 0; | 744 | folder = 0; |
741 | } | 745 | } |
742 | 746 | ||
743 | MHviewItem::~MHviewItem() | 747 | MHviewItem::~MHviewItem() |
744 | { | 748 | { |
745 | delete wrapper; | 749 | delete wrapper; |
746 | } | 750 | } |
747 | 751 | ||
748 | AbstractMail *MHviewItem::getWrapper() | 752 | AbstractMail *MHviewItem::getWrapper() |
749 | { | 753 | { |
750 | return wrapper; | 754 | return wrapper; |
751 | } | 755 | } |
752 | 756 | ||
753 | void MHviewItem::refresh( QValueList<RecMailP> & target) | 757 | void MHviewItem::refresh( QValueList<RecMailP> & target) |
754 | { | 758 | { |
755 | refresh(false); | 759 | refresh(false); |
756 | getWrapper()->listMessages( "",target ); | 760 | getWrapper()->listMessages( "",target ); |
757 | } | 761 | } |
758 | 762 | ||
759 | void MHviewItem::refresh(bool force) | 763 | void MHviewItem::refresh(bool force) |
760 | { | 764 | { |
761 | if (childCount()>0 && force==false) return; | 765 | if (childCount()>0 && force==false) return; |
766 | odebug << "Refresh mh folders" << oendl; | ||
762 | removeChilds(); | 767 | removeChilds(); |
763 | currentFolders.clear(); | 768 | currentFolders.clear(); |
764 | QValueList<FolderP> *folders = wrapper->listFolders(); | 769 | QValueList<FolderP> *folders = wrapper->listFolders(); |
765 | QValueList<FolderP>::ConstIterator it; | 770 | QValueList<FolderP>::ConstIterator it; |
766 | MHfolderItem*item = 0; | 771 | MHfolderItem*item = 0; |
767 | MHfolderItem*pmaster = 0; | 772 | MHfolderItem*pmaster = 0; |
768 | QString fname = ""; | 773 | QString fname = ""; |
769 | int pos; | 774 | int pos; |
770 | for ( it = folders->begin(); it!=folders->end(); ++it) | 775 | for ( it = folders->begin(); it!=folders->end(); ++it) |
771 | { | 776 | { |
772 | fname = (*it)->getDisplayName(); | 777 | fname = (*it)->getDisplayName(); |
773 | /* this folder itself */ | 778 | /* this folder itself */ |
774 | if (fname=="/") | 779 | if (fname=="/") |
775 | { | 780 | { |
776 | currentFolders.append(fname); | 781 | currentFolders.append(fname); |
777 | folder = (*it); | 782 | folder = (*it); |
778 | continue; | 783 | continue; |
779 | } | 784 | } |
780 | currentFolders.append(fname); | 785 | currentFolders.append(fname); |
781 | pos = fname.findRev("/"); | 786 | pos = fname.findRev("/"); |
782 | if (pos > 0) | 787 | if (pos > 0) |
783 | { | 788 | { |
784 | fname = fname.left(pos); | 789 | fname = fname.left(pos); |
785 | pmaster = (MHfolderItem*)findSubItem(fname); | 790 | pmaster = (MHfolderItem*)findSubItem(fname); |
786 | } | 791 | } |
787 | else | 792 | else |
788 | { | 793 | { |
789 | pmaster = 0; | 794 | pmaster = 0; |
790 | } | 795 | } |
791 | if (pmaster) | 796 | if (pmaster) |
792 | { | 797 | { |
793 | item = new MHfolderItem( (*it), pmaster, item, this ); | 798 | item = new MHfolderItem( (*it), pmaster, item, this ); |
794 | } | 799 | } |
795 | else | 800 | else |
796 | { | 801 | { |
797 | item = new MHfolderItem( (*it), this , item ); | 802 | item = new MHfolderItem( (*it), this , item ); |
798 | } | 803 | } |
799 | item->setSelectable((*it)->may_select()); | 804 | item->setSelectable((*it)->may_select()); |
800 | } | 805 | } |
801 | delete folders; | 806 | delete folders; |
802 | } | 807 | } |
803 | 808 | ||
804 | RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) | 809 | RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) |
805 | { | 810 | { |
806 | odebug << "MH fetchBody" << oendl; | 811 | odebug << "MH fetchBody" << oendl; |
807 | return wrapper->fetchBody( mail ); | 812 | return wrapper->fetchBody( mail ); |
808 | } | 813 | } |
809 | 814 | ||
810 | QPopupMenu * MHviewItem::getContextMenu() | 815 | QPopupMenu * MHviewItem::getContextMenu() |
811 | { | 816 | { |
812 | QPopupMenu *m = new QPopupMenu(0); | 817 | QPopupMenu *m = new QPopupMenu(0); |
813 | if (m) | 818 | if (m) |
814 | { | 819 | { |
815 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 820 | m->insertItem(QObject::tr("Refresh folder list",contextName),SERVER_MENU_REFRESH_FOLDER); |
816 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 821 | m->insertItem(QObject::tr("Create new folder",contextName),FOLDER_MENU_NEW_SUBFOLDER); |
817 | m->insertItem(QObject::tr("Delete all mails",contextName),2); | 822 | m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); |
818 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); | 823 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS); |
819 | } | 824 | } |
820 | return m; | 825 | return m; |
821 | } | 826 | } |
822 | 827 | ||
823 | void MHviewItem::createFolder() | 828 | void MHviewItem::createFolder() |
824 | { | 829 | { |
825 | Newmdirdlg ndirdlg(0,0,true); | 830 | Newmdirdlg ndirdlg(0,0,true); |
826 | if ( QPEApplication::execDialog( &ndirdlg ) ) | 831 | if ( QPEApplication::execDialog( &ndirdlg ) ) |
827 | { | 832 | { |
828 | QString ndir = ndirdlg.Newdir(); | 833 | QString ndir = ndirdlg.Newdir(); |
829 | if (wrapper->createMbox(ndir)) | 834 | if (wrapper->createMbox(ndir)) |
830 | { | 835 | { |
831 | refresh(true); | 836 | refresh(true); |
832 | } | 837 | } |
833 | } | 838 | } |
834 | } | 839 | } |
835 | 840 | ||
836 | void MHviewItem::downloadMails() | 841 | void MHviewItem::downloadMails() |
837 | { | 842 | { |
838 | AccountView*bl = accountView(); | 843 | AccountView*bl = accountView(); |
839 | if (!bl) return; | 844 | if (!bl) return; |
840 | bl->downloadMails(folder,getWrapper()); | 845 | bl->downloadMails(folder,getWrapper()); |
841 | } | 846 | } |
842 | 847 | ||
843 | QStringList MHviewItem::subFolders() | 848 | QStringList MHviewItem::subFolders() |
844 | { | 849 | { |
845 | return currentFolders; | 850 | return currentFolders; |
846 | } | 851 | } |
847 | 852 | ||
848 | void MHviewItem::contextMenuSelected(int which) | 853 | void MHviewItem::contextMenuSelected(int which) |
849 | { | 854 | { |
855 | AccountView*view = 0; | ||
856 | |||
850 | switch (which) | 857 | switch (which) |
851 | { | 858 | { |
852 | case 0: | 859 | case SERVER_MENU_REFRESH_FOLDER: |
853 | refresh(true); | 860 | refresh(true); |
854 | break; | 861 | break; |
855 | case 1: | 862 | case FOLDER_MENU_NEW_SUBFOLDER: |
856 | createFolder(); | 863 | createFolder(); |
857 | break; | 864 | break; |
858 | case 2: | 865 | case FOLDER_MENU_DELETE_ALL_MAILS: |
859 | deleteAllMail(getWrapper(),folder); | 866 | deleteAllMail(getWrapper(),folder); |
860 | break; | 867 | break; |
861 | case 3: | 868 | case FOLDER_MENU_MOVE_MAILS: |
862 | downloadMails(); | 869 | downloadMails(); |
863 | break; | 870 | break; |
871 | case FOLDER_MENU_REFRESH_HEADER: | ||
872 | view = (AccountView*)listView(); | ||
873 | if (view) view->refreshCurrent(); | ||
874 | break; | ||
864 | default: | 875 | default: |
865 | break; | 876 | break; |
866 | } | 877 | } |
867 | } | 878 | } |
868 | 879 | ||
869 | MHfolderItem::~MHfolderItem() | 880 | MHfolderItem::~MHfolderItem() |
870 | {} | 881 | {} |
871 | 882 | ||
872 | MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) | 883 | MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) |
873 | : AccountViewItem(folderInit, parent,after ) | 884 | : AccountViewItem(folderInit, parent,after ) |
874 | { | 885 | { |
875 | mbox = parent; | 886 | mbox = parent; |
876 | initName(); | 887 | initName(); |
877 | } | 888 | } |
878 | 889 | ||
879 | MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) | 890 | MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) |
880 | : AccountViewItem(folderInit, parent,after ) | 891 | : AccountViewItem(folderInit, parent,after ) |
881 | { | 892 | { |
882 | folder = folderInit; | 893 | folder = folderInit; |
883 | mbox = master; | 894 | mbox = master; |
884 | initName(); | 895 | initName(); |
885 | } | 896 | } |
886 | 897 | ||
887 | void MHfolderItem::initName() | 898 | void MHfolderItem::initName() |
888 | { | 899 | { |
889 | QString bName = folder->getDisplayName(); | 900 | QString bName = folder->getDisplayName(); |
890 | if (bName.startsWith("/")&&bName.length()>1) | 901 | if (bName.startsWith("/")&&bName.length()>1) |
891 | { | 902 | { |
892 | bName.replace(0,1,""); | 903 | bName.replace(0,1,""); |
893 | } | 904 | } |
894 | int pos = bName.findRev("/"); | 905 | int pos = bName.findRev("/"); |
895 | if (pos > 0) | 906 | if (pos > 0) |
896 | { | 907 | { |
897 | bName.replace(0,pos+1,""); | 908 | bName.replace(0,pos+1,""); |
898 | } | 909 | } |
899 | if (bName.lower() == "outgoing") | 910 | if (bName.lower() == "outgoing") |
900 | { | 911 | { |
901 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); | 912 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); |
902 | } | 913 | } |
903 | else if (bName.lower() == "inbox") | 914 | else if (bName.lower() == "inbox") |
904 | { | 915 | { |
905 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 916 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
906 | } else if (bName.lower() == "drafts") { | 917 | } else if (bName.lower() == "drafts") { |
907 | setPixmap(0, Resource::loadPixmap("inline/edit")); | 918 | setPixmap(0, Resource::loadPixmap("inline/edit")); |
908 | } else { | 919 | } else { |
909 | setPixmap( 0, PIXMAP_MBOXFOLDER ); | 920 | setPixmap( 0, PIXMAP_MBOXFOLDER ); |
910 | } | 921 | } |
911 | setText( 0, bName ); | 922 | setText( 0, bName ); |
912 | } | 923 | } |
913 | 924 | ||
914 | const FolderP&MHfolderItem::getFolder()const | 925 | const FolderP&MHfolderItem::getFolder()const |
915 | { | 926 | { |
916 | return folder; | 927 | return folder; |
917 | } | 928 | } |
918 | 929 | ||
919 | void MHfolderItem::refresh(QValueList<RecMailP>&target) | 930 | void MHfolderItem::refresh(QValueList<RecMailP>&target) |
920 | { | 931 | { |
921 | if (folder->may_select()) | 932 | if (folder->may_select()) |
922 | mbox->getWrapper()->listMessages( folder->getName(),target ); | 933 | mbox->getWrapper()->listMessages( folder->getName(),target ); |
923 | } | 934 | } |
924 | 935 | ||
925 | RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) | 936 | RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) |
926 | { | 937 | { |
927 | return mbox->getWrapper()->fetchBody(aMail); | 938 | return mbox->getWrapper()->fetchBody(aMail); |
928 | } | 939 | } |
929 | 940 | ||
930 | void MHfolderItem::deleteFolder() | 941 | void MHfolderItem::deleteFolder() |
931 | { | 942 | { |
932 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | 943 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), |
933 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | 944 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), |
934 | QObject::tr("Yes",contextName), | 945 | QObject::tr("Yes",contextName), |
935 | QObject::tr("No",contextName),QString::null,1,1); | 946 | QObject::tr("No",contextName),QString::null,1,1); |
936 | odebug << "Auswahl: " << yesno << "" << oendl; | 947 | odebug << "Auswahl: " << yesno << "" << oendl; |
937 | if (yesno == 0) | 948 | if (yesno == 0) |
938 | { | 949 | { |
939 | if (mbox->getWrapper()->deleteMbox(folder)) | 950 | if (mbox->getWrapper()->deleteMbox(folder)) |
940 | { | 951 | { |
941 | QListView*v=listView(); | 952 | QListView*v=listView(); |
942 | MHviewItem * box = mbox; | 953 | MHviewItem * box = mbox; |
943 | /* be carefull - after that this object is destroyd so don't use | 954 | /* be carefull - after that this object is destroyd so don't use |
944 | * any member of it after that call!!*/ | 955 | * any member of it after that call!!*/ |
945 | mbox->refresh(true); | 956 | mbox->refresh(true); |
946 | if (v) | 957 | if (v) |
947 | { | 958 | { |
948 | v->setSelected(box,true); | 959 | v->setSelected(box,true); |
949 | } | 960 | } |
950 | } | 961 | } |
951 | } | 962 | } |
952 | } | 963 | } |
953 | 964 | ||
954 | QPopupMenu * MHfolderItem::getContextMenu() | 965 | QPopupMenu * MHfolderItem::getContextMenu() |
955 | { | 966 | { |
956 | QPopupMenu *m = new QPopupMenu(0); | 967 | QPopupMenu *m = new QPopupMenu(0); |
957 | if (m) | 968 | if (m) |
958 | { | 969 | { |
959 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | 970 | m->insertItem(QObject::tr("Create new subfolder",contextName),FOLDER_MENU_NEW_SUBFOLDER); |
960 | m->insertItem(QObject::tr("Delete all mails",contextName),0); | 971 | m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER); |
961 | m->insertItem(QObject::tr("Create new subfolder",contextName),3); | 972 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS); |
962 | m->insertItem(QObject::tr("Delete folder",contextName),1); | 973 | m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); |
974 | m->insertItem(QObject::tr("Delete folder",contextName),FOLDER_MENU_DELETE_FOLDER); | ||
963 | } | 975 | } |
964 | return m; | 976 | return m; |
965 | } | 977 | } |
966 | 978 | ||
967 | void MHfolderItem::downloadMails() | 979 | void MHfolderItem::downloadMails() |
968 | { | 980 | { |
969 | AccountView*bl = mbox->accountView(); | 981 | AccountView*bl = mbox->accountView(); |
970 | if (!bl) return; | 982 | if (!bl) return; |
971 | bl->downloadMails(folder,mbox->getWrapper()); | 983 | bl->downloadMails(folder,mbox->getWrapper()); |
972 | } | 984 | } |
973 | 985 | ||
974 | void MHfolderItem::createFolder() | 986 | void MHfolderItem::createFolder() |
975 | { | 987 | { |
976 | Newmdirdlg ndirdlg(0,0,true); | 988 | Newmdirdlg ndirdlg(0,0,true); |
977 | if ( QPEApplication::execDialog( &ndirdlg ) ) | 989 | if ( QPEApplication::execDialog( &ndirdlg ) ) |
978 | { | 990 | { |
979 | QString ndir = ndirdlg.Newdir(); | 991 | QString ndir = ndirdlg.Newdir(); |
980 | if (mbox->getWrapper()->createMbox(ndir,folder)) | 992 | if (mbox->getWrapper()->createMbox(ndir,folder)) |
981 | { | 993 | { |
982 | QListView*v=listView(); | 994 | QListView*v=listView(); |
983 | MHviewItem * box = mbox; | 995 | MHviewItem * box = mbox; |
984 | /* be carefull - after that this object is destroyd so don't use | 996 | /* be carefull - after that this object is destroyd so don't use |
985 | * any member of it after that call!!*/ | 997 | * any member of it after that call!!*/ |
986 | mbox->refresh(true); | 998 | mbox->refresh(true); |
987 | if (v) | 999 | if (v) |
988 | { | 1000 | { |
989 | v->setSelected(box,true); | 1001 | v->setSelected(box,true); |
990 | } | 1002 | } |
991 | } | 1003 | } |
992 | } | 1004 | } |
993 | } | 1005 | } |
994 | 1006 | ||
995 | void MHfolderItem::contextMenuSelected(int which) | 1007 | void MHfolderItem::contextMenuSelected(int which) |
996 | { | 1008 | { |
1009 | AccountView*view = 0; | ||
997 | switch(which) | 1010 | switch(which) |
998 | { | 1011 | { |
999 | case 0: | 1012 | case FOLDER_MENU_DELETE_ALL_MAILS: |
1000 | deleteAllMail(mbox->getWrapper(),folder); | 1013 | deleteAllMail(mbox->getWrapper(),folder); |
1001 | break; | 1014 | break; |
1002 | case 1: | 1015 | case FOLDER_MENU_DELETE_FOLDER: |
1003 | deleteFolder(); | 1016 | deleteFolder(); |
1004 | break; | 1017 | break; |
1005 | case 2: | 1018 | case FOLDER_MENU_MOVE_MAILS: |
1006 | downloadMails(); | 1019 | downloadMails(); |
1007 | break; | 1020 | break; |
1008 | case 3: | 1021 | case FOLDER_MENU_NEW_SUBFOLDER: |
1009 | createFolder(); | 1022 | createFolder(); |
1010 | break; | 1023 | break; |
1024 | case FOLDER_MENU_REFRESH_HEADER: | ||
1025 | view = (AccountView*)listView(); | ||
1026 | if (view) view->refreshCurrent(); | ||
1027 | break; | ||
1011 | default: | 1028 | default: |
1012 | break; | 1029 | break; |
1013 | } | 1030 | } |
1014 | } | 1031 | } |
1015 | 1032 | ||
1016 | bool MHfolderItem::isDraftfolder() | 1033 | bool MHfolderItem::isDraftfolder() |
1017 | { | 1034 | { |
1018 | if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; | 1035 | if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; |
1019 | return false; | 1036 | return false; |
1020 | } | 1037 | } |
1021 | 1038 | ||
1022 | /** | 1039 | /** |
1023 | * Generic stuff | 1040 | * Generic stuff |
1024 | */ | 1041 | */ |
1025 | 1042 | ||
1026 | const QString AccountViewItem::contextName="AccountViewItem"; | 1043 | const QString AccountViewItem::contextName="AccountViewItem"; |
1027 | 1044 | ||
1028 | AccountViewItem::AccountViewItem( AccountView *parent ) | 1045 | AccountViewItem::AccountViewItem( AccountView *parent ) |
1029 | : QListViewItem( parent ) | 1046 | : QListViewItem( parent ) |
1030 | { | 1047 | { |
1031 | init(); | 1048 | init(); |
1032 | m_Backlink = parent; | 1049 | m_Backlink = parent; |
1033 | } | 1050 | } |
1034 | 1051 | ||
1035 | AccountViewItem::AccountViewItem( QListViewItem *parent) | 1052 | AccountViewItem::AccountViewItem( QListViewItem *parent) |
1036 | : QListViewItem( parent),folder(0) | 1053 | : QListViewItem( parent),folder(0) |
1037 | { | 1054 | { |
1038 | init(); | 1055 | init(); |
1039 | } | 1056 | } |
1040 | 1057 | ||
1041 | AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) | 1058 | AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) |
1042 | :QListViewItem( parent,after ),folder(0) | 1059 | :QListViewItem( parent,after ),folder(0) |
1043 | { | 1060 | { |
1044 | init(); | 1061 | init(); |
1045 | } | 1062 | } |
1046 | 1063 | ||
1047 | AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ) | 1064 | AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ) |
1048 | :QListViewItem( parent,after ),folder(folderInit) | 1065 | :QListViewItem( parent,after ),folder(folderInit) |
1049 | { | 1066 | { |
1050 | init(); | 1067 | init(); |
1051 | } | 1068 | } |
1052 | 1069 | ||
1053 | void AccountViewItem::init() | 1070 | void AccountViewItem::init() |
1054 | { | 1071 | { |
1055 | m_Backlink = 0; | 1072 | m_Backlink = 0; |
1056 | } | 1073 | } |
1057 | 1074 | ||
1058 | AccountViewItem::~AccountViewItem() | 1075 | AccountViewItem::~AccountViewItem() |
1059 | { | 1076 | { |
1060 | folder = 0; | 1077 | folder = 0; |
1061 | } | 1078 | } |
1062 | 1079 | ||
1063 | AccountView*AccountViewItem::accountView() | 1080 | AccountView*AccountViewItem::accountView() |
1064 | { | 1081 | { |
1065 | return m_Backlink; | 1082 | return m_Backlink; |
1066 | } | 1083 | } |
1067 | 1084 | ||
1068 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder) | 1085 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder) |
1069 | { | 1086 | { |
1070 | if (!wrapper) return; | 1087 | if (!wrapper) return; |
1071 | QString fname=""; | 1088 | QString fname=""; |
1072 | if (folder) fname = folder->getDisplayName(); | 1089 | if (folder) fname = folder->getDisplayName(); |
1073 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), | 1090 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), |
1074 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). | 1091 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). |
1075 | arg(fname), | 1092 | arg(fname), |
1076 | QObject::tr("Yes",contextName), | 1093 | QObject::tr("Yes",contextName), |
1077 | QObject::tr("No",contextName),QString::null,1,1); | 1094 | QObject::tr("No",contextName),QString::null,1,1); |
1078 | odebug << "Auswahl: " << yesno << "" << oendl; | 1095 | odebug << "Auswahl: " << yesno << "" << oendl; |
1079 | if (yesno == 0) | 1096 | if (yesno == 0) |
1080 | { | 1097 | { |
1081 | if (wrapper->deleteAllMail(folder)) | 1098 | if (wrapper->deleteAllMail(folder)) |
1082 | { | 1099 | { |
1083 | AccountView * view = (AccountView*)listView(); | 1100 | AccountView * view = (AccountView*)listView(); |
1084 | if (view) view->refreshCurrent(); | 1101 | if (view) view->refreshCurrent(); |
1085 | } | 1102 | } |
1086 | } | 1103 | } |
1087 | } | 1104 | } |
1088 | 1105 | ||
1089 | void AccountViewItem::removeChilds() | 1106 | void AccountViewItem::removeChilds() |
1090 | { | 1107 | { |
1091 | QListViewItem *child = firstChild(); | 1108 | QListViewItem *child = firstChild(); |
1092 | while ( child ) | 1109 | while ( child ) |
1093 | { | 1110 | { |
1094 | QListViewItem *tmp = child; | 1111 | QListViewItem *tmp = child; |
1095 | child = child->nextSibling(); | 1112 | child = child->nextSibling(); |
1096 | delete tmp; | 1113 | delete tmp; |
1097 | } | 1114 | } |
1098 | } | 1115 | } |
1099 | 1116 | ||
1100 | bool AccountViewItem::matchName(const QString&name)const | 1117 | bool AccountViewItem::matchName(const QString&name)const |
1101 | { | 1118 | { |
1102 | if (!folder) return false; | 1119 | if (!folder) return false; |
1103 | return folder->getDisplayName()==name; | 1120 | return folder->getDisplayName()==name; |
1104 | } | 1121 | } |
1105 | 1122 | ||
1106 | 1123 | ||
1107 | AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) | 1124 | AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) |
1108 | { | 1125 | { |
1109 | AccountViewItem*pitem,*sitem; | 1126 | AccountViewItem*pitem,*sitem; |
1110 | if (!start) pitem = (AccountViewItem*)firstChild(); | 1127 | if (!start) pitem = (AccountViewItem*)firstChild(); |
1111 | else pitem = (AccountViewItem*)start->firstChild(); | 1128 | else pitem = (AccountViewItem*)start->firstChild(); |
1112 | while (pitem) | 1129 | while (pitem) |
1113 | { | 1130 | { |
1114 | if (pitem->matchName(path)) | 1131 | if (pitem->matchName(path)) |
1115 | { | 1132 | { |
1116 | break; | 1133 | break; |
1117 | } | 1134 | } |
1118 | if (pitem->childCount()>0) | 1135 | if (pitem->childCount()>0) |
1119 | { | 1136 | { |
1120 | sitem = findSubItem(path,pitem); | 1137 | sitem = findSubItem(path,pitem); |
1121 | if (sitem) | 1138 | if (sitem) |
1122 | { | 1139 | { |
1123 | pitem = sitem; | 1140 | pitem = sitem; |
1124 | break; | 1141 | break; |
1125 | } | 1142 | } |
1126 | } | 1143 | } |
1127 | pitem=(AccountViewItem*)pitem->nextSibling(); | 1144 | pitem=(AccountViewItem*)pitem->nextSibling(); |
1128 | } | 1145 | } |
1129 | return pitem; | 1146 | return pitem; |
1130 | } | 1147 | } |
1131 | 1148 | ||
1132 | bool AccountViewItem::isDraftfolder() | 1149 | bool AccountViewItem::isDraftfolder() |
1133 | { | 1150 | { |
1134 | return false; | 1151 | return false; |
1135 | } | 1152 | } |
diff --git a/noncore/net/mail/accountitem.h b/noncore/net/mail/accountitem.h index f125eeb..b2c50a1 100644 --- a/noncore/net/mail/accountitem.h +++ b/noncore/net/mail/accountitem.h | |||
@@ -1,212 +1,225 @@ | |||
1 | #ifndef __ACCOUNT_ITEM | 1 | #ifndef __ACCOUNT_ITEM |
2 | #define __ACCOUNT_ITEM | 2 | #define __ACCOUNT_ITEM |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | #include <opie2/osmartpointer.h> | 6 | #include <opie2/osmartpointer.h> |
7 | 7 | ||
8 | class POP3wrapper; | 8 | class POP3wrapper; |
9 | class RecMail; | 9 | class RecMail; |
10 | class RecBody; | 10 | class RecBody; |
11 | class QPopupMenu; | 11 | class QPopupMenu; |
12 | class Selectstore; | 12 | class Selectstore; |
13 | class AccountView; | 13 | class AccountView; |
14 | class POP3account; | 14 | class POP3account; |
15 | class NNTPaccount; | 15 | class NNTPaccount; |
16 | class IMAPaccount; | 16 | class IMAPaccount; |
17 | class AbstractMail; | 17 | class AbstractMail; |
18 | class Folder; | 18 | class Folder; |
19 | 19 | ||
20 | #define RECBODYP Opie::Core::OSmartPointer<RecBody> | 20 | #define RECBODYP Opie::Core::OSmartPointer<RecBody> |
21 | 21 | ||
22 | class AccountViewItem : public QListViewItem | 22 | class AccountViewItem : public QListViewItem |
23 | { | 23 | { |
24 | 24 | ||
25 | public: | 25 | public: |
26 | AccountViewItem( AccountView *parent ); | 26 | AccountViewItem( AccountView *parent ); |
27 | AccountViewItem( QListViewItem *parent); | 27 | AccountViewItem( QListViewItem *parent); |
28 | AccountViewItem( QListViewItem *parent , QListViewItem*after ); | 28 | AccountViewItem( QListViewItem *parent , QListViewItem*after ); |
29 | AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ); | 29 | AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ); |
30 | 30 | ||
31 | virtual ~AccountViewItem(); | 31 | virtual ~AccountViewItem(); |
32 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&)=0; | 32 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&)=0; |
33 | virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&)=0; | 33 | virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&)=0; |
34 | virtual QPopupMenu * getContextMenu(){return 0;}; | 34 | virtual QPopupMenu * getContextMenu(){return 0;}; |
35 | virtual void contextMenuSelected(int){} | 35 | virtual void contextMenuSelected(int){} |
36 | virtual AccountView*accountView(); | 36 | virtual AccountView*accountView(); |
37 | virtual bool matchName(const QString&name)const; | 37 | virtual bool matchName(const QString&name)const; |
38 | virtual bool isDraftfolder(); | 38 | virtual bool isDraftfolder(); |
39 | /* 1 - server | ||
40 | * 2 - folder | ||
41 | * 3 - beides | ||
42 | */ | ||
43 | virtual int isServer()const=0; | ||
39 | 44 | ||
40 | protected: | 45 | protected: |
41 | AccountViewItem*findSubItem(const QString&path,AccountViewItem*start=0); | 46 | AccountViewItem*findSubItem(const QString&path,AccountViewItem*start=0); |
42 | virtual void init(); | 47 | virtual void init(); |
43 | virtual void removeChilds(); | 48 | virtual void removeChilds(); |
44 | virtual void deleteAllMail(AbstractMail*wrapper,const Opie::Core::OSmartPointer<Folder>&f); | 49 | virtual void deleteAllMail(AbstractMail*wrapper,const Opie::Core::OSmartPointer<Folder>&f); |
45 | static const QString contextName; | 50 | static const QString contextName; |
46 | AccountView*m_Backlink; | 51 | AccountView*m_Backlink; |
47 | Opie::Core::OSmartPointer<Folder> folder; | 52 | Opie::Core::OSmartPointer<Folder> folder; |
48 | }; | 53 | }; |
49 | 54 | ||
50 | class POP3viewItem : public AccountViewItem | 55 | class POP3viewItem : public AccountViewItem |
51 | { | 56 | { |
52 | 57 | ||
53 | public: | 58 | public: |
54 | POP3viewItem( POP3account *a, AccountView *parent ); | 59 | POP3viewItem( POP3account *a, AccountView *parent ); |
55 | virtual ~POP3viewItem(); | 60 | virtual ~POP3viewItem(); |
56 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); | 61 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); |
57 | virtual RECBODYP fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail ); | 62 | virtual RECBODYP fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail ); |
58 | AbstractMail *getWrapper(); | 63 | AbstractMail *getWrapper(); |
59 | virtual QPopupMenu * getContextMenu(); | 64 | virtual QPopupMenu * getContextMenu(); |
60 | virtual void contextMenuSelected(int); | 65 | virtual void contextMenuSelected(int); |
66 | virtual int isServer()const{return 1;} | ||
61 | 67 | ||
62 | protected: | 68 | protected: |
63 | POP3account *account; | 69 | POP3account *account; |
64 | virtual void refresh(); | 70 | virtual void refresh(); |
65 | AbstractMail *wrapper; | 71 | AbstractMail *wrapper; |
66 | void disconnect(); | 72 | void disconnect(); |
67 | void setOnOffline(); | 73 | void setOnOffline(); |
68 | }; | 74 | }; |
69 | 75 | ||
70 | class POP3folderItem : public AccountViewItem | 76 | class POP3folderItem : public AccountViewItem |
71 | { | 77 | { |
72 | 78 | ||
73 | public: | 79 | public: |
74 | POP3folderItem( const Opie::Core::OSmartPointer<Folder>&folder, POP3viewItem *parent , QListViewItem*after ); | 80 | POP3folderItem( const Opie::Core::OSmartPointer<Folder>&folder, POP3viewItem *parent , QListViewItem*after ); |
75 | virtual ~POP3folderItem(); | 81 | virtual ~POP3folderItem(); |
76 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); | 82 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); |
77 | virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); | 83 | virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); |
78 | virtual QPopupMenu * getContextMenu(); | 84 | virtual QPopupMenu * getContextMenu(); |
79 | virtual void contextMenuSelected(int); | 85 | virtual void contextMenuSelected(int); |
86 | virtual int isServer()const{return 2;} | ||
80 | 87 | ||
81 | protected: | 88 | protected: |
82 | void downloadMails(); | 89 | void downloadMails(); |
83 | POP3viewItem *pop3; | 90 | POP3viewItem *pop3; |
84 | }; | 91 | }; |
85 | 92 | ||
86 | 93 | ||
87 | class NNTPviewItem : public AccountViewItem | 94 | class NNTPviewItem : public AccountViewItem |
88 | { | 95 | { |
89 | 96 | ||
90 | public: | 97 | public: |
91 | NNTPviewItem( NNTPaccount *a, AccountView *parent ); | 98 | NNTPviewItem( NNTPaccount *a, AccountView *parent ); |
92 | virtual ~NNTPviewItem(); | 99 | virtual ~NNTPviewItem(); |
93 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); | 100 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); |
94 | virtual RECBODYP fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail ); | 101 | virtual RECBODYP fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail ); |
95 | AbstractMail *getWrapper(); | 102 | AbstractMail *getWrapper(); |
96 | virtual QPopupMenu * getContextMenu(); | 103 | virtual QPopupMenu * getContextMenu(); |
97 | virtual void contextMenuSelected(int); | 104 | virtual void contextMenuSelected(int); |
105 | virtual int isServer()const{return 1;} | ||
98 | 106 | ||
99 | protected: | 107 | protected: |
100 | NNTPaccount *account; | 108 | NNTPaccount *account; |
101 | virtual void refresh(); | 109 | virtual void refresh(); |
102 | AbstractMail *wrapper; | 110 | AbstractMail *wrapper; |
103 | void disconnect(); | 111 | void disconnect(); |
104 | void setOnOffline(); | 112 | void setOnOffline(); |
105 | void subscribeGroups(); | 113 | void subscribeGroups(); |
106 | }; | 114 | }; |
107 | 115 | ||
108 | class NNTPfolderItem : public AccountViewItem | 116 | class NNTPfolderItem : public AccountViewItem |
109 | { | 117 | { |
110 | 118 | ||
111 | public: | 119 | public: |
112 | NNTPfolderItem(const Opie::Core::OSmartPointer<Folder>&folder, NNTPviewItem *parent , QListViewItem*after ); | 120 | NNTPfolderItem(const Opie::Core::OSmartPointer<Folder>&folder, NNTPviewItem *parent , QListViewItem*after ); |
113 | virtual ~NNTPfolderItem(); | 121 | virtual ~NNTPfolderItem(); |
114 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); | 122 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); |
115 | virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); | 123 | virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); |
116 | virtual QPopupMenu * getContextMenu(); | 124 | virtual QPopupMenu * getContextMenu(); |
117 | virtual void contextMenuSelected(int); | 125 | virtual void contextMenuSelected(int); |
126 | virtual int isServer()const{return 2;} | ||
118 | 127 | ||
119 | protected: | 128 | protected: |
120 | void downloadMails(); | 129 | void downloadMails(); |
121 | NNTPviewItem *nntp; | 130 | NNTPviewItem *nntp; |
122 | }; | 131 | }; |
123 | 132 | ||
124 | 133 | ||
125 | 134 | ||
126 | class IMAPviewItem : public AccountViewItem | 135 | class IMAPviewItem : public AccountViewItem |
127 | { | 136 | { |
128 | friend class IMAPfolderItem; | 137 | friend class IMAPfolderItem; |
129 | public: | 138 | public: |
130 | IMAPviewItem( IMAPaccount *a, AccountView *parent ); | 139 | IMAPviewItem( IMAPaccount *a, AccountView *parent ); |
131 | virtual ~IMAPviewItem(); | 140 | virtual ~IMAPviewItem(); |
132 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); | 141 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); |
133 | virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); | 142 | virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); |
134 | AbstractMail *getWrapper(); | 143 | AbstractMail *getWrapper(); |
135 | virtual QPopupMenu * getContextMenu(); | 144 | virtual QPopupMenu * getContextMenu(); |
136 | virtual void contextMenuSelected(int); | 145 | virtual void contextMenuSelected(int); |
137 | const QStringList&subFolders(); | 146 | const QStringList&subFolders(); |
138 | virtual void refreshFolders(bool force=false); | 147 | virtual void refreshFolders(bool force=false); |
148 | virtual int isServer()const{return 1;} | ||
139 | bool offline(); | 149 | bool offline(); |
140 | 150 | ||
141 | protected: | 151 | protected: |
142 | virtual void createNewFolder(); | 152 | virtual void createNewFolder(); |
143 | IMAPaccount *account; | 153 | IMAPaccount *account; |
144 | AbstractMail *wrapper; | 154 | AbstractMail *wrapper; |
145 | QStringList currentFolders; | 155 | QStringList currentFolders; |
146 | }; | 156 | }; |
147 | 157 | ||
148 | class IMAPfolderItem : public AccountViewItem | 158 | class IMAPfolderItem : public AccountViewItem |
149 | { | 159 | { |
150 | 160 | ||
151 | public: | 161 | public: |
152 | IMAPfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, IMAPviewItem *parent , QListViewItem*after ); | 162 | IMAPfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, IMAPviewItem *parent , QListViewItem*after ); |
153 | IMAPfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); | 163 | IMAPfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); |
154 | virtual ~IMAPfolderItem(); | 164 | virtual ~IMAPfolderItem(); |
155 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); | 165 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); |
156 | virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); | 166 | virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); |
157 | virtual QPopupMenu * getContextMenu(); | 167 | virtual QPopupMenu * getContextMenu(); |
158 | virtual void contextMenuSelected(int); | 168 | virtual void contextMenuSelected(int); |
159 | virtual const QString& Delemiter()const; | 169 | virtual const QString& Delemiter()const; |
170 | virtual int isServer()const{return 2;} | ||
160 | protected: | 171 | protected: |
161 | virtual void createNewFolder(); | 172 | virtual void createNewFolder(); |
162 | virtual void deleteFolder(); | 173 | virtual void deleteFolder(); |
163 | virtual void downloadMails(); | 174 | virtual void downloadMails(); |
164 | IMAPviewItem *imap; | 175 | IMAPviewItem *imap; |
165 | }; | 176 | }; |
166 | 177 | ||
167 | class MHviewItem : public AccountViewItem | 178 | class MHviewItem : public AccountViewItem |
168 | { | 179 | { |
169 | friend class MHfolderItem; | 180 | friend class MHfolderItem; |
170 | 181 | ||
171 | public: | 182 | public: |
172 | MHviewItem( const QString&aMboxPath, AccountView *parent ); | 183 | MHviewItem( const QString&aMboxPath, AccountView *parent ); |
173 | virtual ~MHviewItem(); | 184 | virtual ~MHviewItem(); |
174 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); | 185 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); |
175 | virtual RECBODYP fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail ); | 186 | virtual RECBODYP fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail ); |
176 | AbstractMail *getWrapper(); | 187 | AbstractMail *getWrapper(); |
177 | virtual QPopupMenu * getContextMenu(); | 188 | virtual QPopupMenu * getContextMenu(); |
178 | virtual void contextMenuSelected(int); | 189 | virtual void contextMenuSelected(int); |
179 | QStringList subFolders(); | 190 | QStringList subFolders(); |
180 | virtual void refresh(bool force=false); | 191 | virtual void refresh(bool force=false); |
192 | virtual int isServer()const{return 3;} | ||
181 | 193 | ||
182 | protected: | 194 | protected: |
183 | void downloadMails(); | 195 | void downloadMails(); |
184 | virtual void createFolder(); | 196 | virtual void createFolder(); |
185 | QString m_Path; | 197 | QString m_Path; |
186 | AbstractMail *wrapper; | 198 | AbstractMail *wrapper; |
187 | QStringList currentFolders; | 199 | QStringList currentFolders; |
188 | }; | 200 | }; |
189 | 201 | ||
190 | class MHfolderItem : public AccountViewItem | 202 | class MHfolderItem : public AccountViewItem |
191 | { | 203 | { |
192 | 204 | ||
193 | public: | 205 | public: |
194 | MHfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, MHviewItem *parent , QListViewItem*after ); | 206 | MHfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, MHviewItem *parent , QListViewItem*after ); |
195 | MHfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master); | 207 | MHfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master); |
196 | virtual ~MHfolderItem(); | 208 | virtual ~MHfolderItem(); |
197 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); | 209 | virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); |
198 | virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); | 210 | virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); |
199 | virtual QPopupMenu * getContextMenu(); | 211 | virtual QPopupMenu * getContextMenu(); |
200 | virtual void contextMenuSelected(int); | 212 | virtual void contextMenuSelected(int); |
201 | virtual const Opie::Core::OSmartPointer<Folder>&getFolder()const; | 213 | virtual const Opie::Core::OSmartPointer<Folder>&getFolder()const; |
202 | virtual bool isDraftfolder(); | 214 | virtual bool isDraftfolder(); |
215 | virtual int isServer()const{return 2;} | ||
203 | 216 | ||
204 | protected: | 217 | protected: |
205 | void downloadMails(); | 218 | void downloadMails(); |
206 | virtual void createFolder(); | 219 | virtual void createFolder(); |
207 | virtual void deleteFolder(); | 220 | virtual void deleteFolder(); |
208 | void initName(); | 221 | void initName(); |
209 | MHviewItem *mbox; | 222 | MHviewItem *mbox; |
210 | }; | 223 | }; |
211 | 224 | ||
212 | #endif | 225 | #endif |
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index c747a8b..d01d6bb 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -1,172 +1,214 @@ | |||
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 <opie2/odebug.h> | 12 | #include <opie2/odebug.h> |
13 | #include <qpe/qpeapplication.h> | 13 | #include <qpe/qpeapplication.h> |
14 | 14 | ||
15 | /* QT */ | 15 | /* QT */ |
16 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
17 | #include <qpopupmenu.h> | 17 | #include <qpopupmenu.h> |
18 | 18 | ||
19 | using namespace Opie::Core; | 19 | using namespace Opie::Core; |
20 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 20 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
21 | : QListView( parent, name, flags ) | 21 | : QListView( parent, name, flags ) |
22 | { | 22 | { |
23 | setSorting(0); | ||
24 | setSelectionMode(Single); | ||
25 | m_rightPressed = false; | ||
26 | |||
23 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), | 27 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), |
24 | SLOT( refresh(QListViewItem*) ) ); | 28 | SLOT( slotSelectionChanged(QListViewItem*) ) ); |
25 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, | 29 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, |
26 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); | 30 | SLOT( slotMouseButton(int,QListViewItem*,const QPoint&,int) ) ); |
27 | setSorting(0); | 31 | connect( this, SIGNAL(clicked(QListViewItem*) ),this, |
32 | SLOT( slotMouseClicked(QListViewItem*) ) ); | ||
33 | m_currentItem = 0; | ||
28 | } | 34 | } |
29 | 35 | ||
30 | AccountView::~AccountView() | 36 | AccountView::~AccountView() |
31 | { | 37 | { |
32 | imapAccounts.clear(); | 38 | imapAccounts.clear(); |
33 | mhAccounts.clear(); | 39 | mhAccounts.clear(); |
34 | } | 40 | } |
35 | 41 | ||
42 | void AccountView::slotSelectionChanged(QListViewItem*item) | ||
43 | { | ||
44 | odebug << "AccountView: Selection changed" << oendl; | ||
45 | if (!item) { | ||
46 | emit serverSelected(0); | ||
47 | return; | ||
48 | } | ||
49 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | ||
50 | |||
51 | emit serverSelected(view->isServer()); | ||
52 | } | ||
53 | |||
36 | void AccountView::slotContextMenu(int id) | 54 | void AccountView::slotContextMenu(int id) |
37 | { | 55 | { |
38 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 56 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
39 | if (!view) return; | 57 | if (!view) return; |
40 | view->contextMenuSelected(id); | 58 | view->contextMenuSelected(id); |
41 | } | 59 | } |
42 | 60 | ||
43 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) | 61 | void AccountView::slotRightButton(int button, QListViewItem * item,const QPoint&,int) |
44 | { | 62 | { |
45 | if (button==1) {return;} | 63 | m_rightPressed = true; |
46 | if (!item) return; | 64 | if (!item) return; |
47 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 65 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
48 | QPopupMenu*m = view->getContextMenu(); | 66 | QPopupMenu*m = view->getContextMenu(); |
49 | if (!m) return; | 67 | if (!m) return; |
50 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); | 68 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); |
51 | m->setFocus(); | 69 | m->setFocus(); |
52 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 70 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
53 | delete m; | 71 | delete m; |
72 | setSelected(item,true); | ||
73 | } | ||
74 | |||
75 | void AccountView::slotLeftButton(int button, QListViewItem * item,const QPoint&,int) | ||
76 | { | ||
77 | m_rightPressed = false; | ||
78 | } | ||
79 | |||
80 | void AccountView::slotMouseClicked(QListViewItem*item) | ||
81 | { | ||
82 | if (m_rightPressed) return; | ||
83 | if (!item || m_currentItem == item) return; | ||
84 | /* ### ToDo check settings if on single tab it should open */ | ||
85 | m_currentItem = item; | ||
86 | refresh(m_currentItem); | ||
87 | } | ||
88 | |||
89 | void AccountView::slotMouseButton(int button, QListViewItem * item,const QPoint&pos,int column) | ||
90 | { | ||
91 | if (button==1) { | ||
92 | slotLeftButton(button,item,pos,column); | ||
93 | } else if (button==2) { | ||
94 | slotRightButton(button,item,pos,column); | ||
95 | } | ||
54 | } | 96 | } |
55 | 97 | ||
56 | void AccountView::populate( QList<Account> list ) | 98 | void AccountView::populate( QList<Account> list ) |
57 | { | 99 | { |
58 | clear(); | 100 | clear(); |
59 | 101 | ||
60 | imapAccounts.clear(); | 102 | imapAccounts.clear(); |
61 | mhAccounts.clear(); | 103 | mhAccounts.clear(); |
62 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); | 104 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); |
63 | 105 | ||
64 | Account *it; | 106 | Account *it; |
65 | for ( it = list.first(); it; it = list.next() ) { | 107 | for ( it = list.first(); it; it = list.next() ) { |
66 | if ( it->getType() == MAILLIB::A_IMAP ) { | 108 | if ( it->getType() == MAILLIB::A_IMAP ) { |
67 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); | 109 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); |
68 | odebug << "added IMAP " + imap->getAccountName() << oendl; | 110 | odebug << "added IMAP " + imap->getAccountName() << oendl; |
69 | imapAccounts.append(new IMAPviewItem( imap, this )); | 111 | imapAccounts.append(new IMAPviewItem( imap, this )); |
70 | } else if ( it->getType() == MAILLIB::A_POP3 ) { | 112 | } else if ( it->getType() == MAILLIB::A_POP3 ) { |
71 | POP3account *pop3 = static_cast<POP3account *>(it); | 113 | POP3account *pop3 = static_cast<POP3account *>(it); |
72 | odebug << "added POP3 " + pop3->getAccountName() << oendl; | 114 | odebug << "added POP3 " + pop3->getAccountName() << oendl; |
73 | /* must not be hold 'cause it isn't required */ | 115 | /* must not be hold 'cause it isn't required */ |
74 | (void) new POP3viewItem( pop3, this ); | 116 | (void) new POP3viewItem( pop3, this ); |
75 | } else if ( it->getType() == MAILLIB::A_NNTP ) { | 117 | } else if ( it->getType() == MAILLIB::A_NNTP ) { |
76 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); | 118 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); |
77 | odebug << "added NNTP " + nntp->getAccountName() << oendl; | 119 | odebug << "added NNTP " + nntp->getAccountName() << oendl; |
78 | /* must not be hold 'cause it isn't required */ | 120 | /* must not be hold 'cause it isn't required */ |
79 | (void) new NNTPviewItem( nntp, this ); | 121 | (void) new NNTPviewItem( nntp, this ); |
80 | } else if ( it->getType() == MAILLIB::A_MH ) { | 122 | } else if ( it->getType() == MAILLIB::A_MH ) { |
81 | } | 123 | } |
82 | } | 124 | } |
83 | } | 125 | } |
84 | 126 | ||
85 | void AccountView::refresh(QListViewItem *item) | 127 | void AccountView::refresh(QListViewItem *item) |
86 | { | 128 | { |
87 | 129 | ||
88 | odebug << "AccountView refresh..." << oendl; | 130 | odebug << "AccountView refresh..." << oendl; |
89 | if ( item ) | 131 | if ( item ) |
90 | { | 132 | { |
91 | m_currentItem = item; | 133 | m_currentItem = item; |
92 | QValueList<RecMailP> headerlist; | 134 | QValueList<RecMailP> headerlist; |
93 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 135 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
94 | view->refresh(headerlist); | 136 | view->refresh(headerlist); |
95 | emit refreshMailview(headerlist); | 137 | emit refreshMailview(headerlist); |
96 | } | 138 | } |
97 | } | 139 | } |
98 | 140 | ||
99 | void AccountView::refreshCurrent() | 141 | void AccountView::refreshCurrent() |
100 | { | 142 | { |
101 | m_currentItem = currentItem(); | 143 | m_currentItem = currentItem(); |
102 | if ( !m_currentItem ) return; | 144 | if ( !m_currentItem ) return; |
103 | QValueList<RecMailP> headerlist; | 145 | QValueList<RecMailP> headerlist; |
104 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); | 146 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); |
105 | view->refresh(headerlist); | 147 | view->refresh(headerlist); |
106 | emit refreshMailview(headerlist); | 148 | emit refreshMailview(headerlist); |
107 | } | 149 | } |
108 | 150 | ||
109 | void AccountView::refreshAll() | 151 | void AccountView::refreshAll() |
110 | { | 152 | { |
111 | } | 153 | } |
112 | 154 | ||
113 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) | 155 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) |
114 | { | 156 | { |
115 | QListViewItem*item = selectedItem (); | 157 | QListViewItem*item = selectedItem (); |
116 | if (!item) return new RecBody(); | 158 | if (!item) return new RecBody(); |
117 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 159 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
118 | return view->fetchBody(aMail); | 160 | return view->fetchBody(aMail); |
119 | } | 161 | } |
120 | 162 | ||
121 | void AccountView::setupFolderselect(Selectstore*sels) | 163 | void AccountView::setupFolderselect(Selectstore*sels) |
122 | { | 164 | { |
123 | QPEApplication::showDialog( sels ); | 165 | QPEApplication::showDialog( sels ); |
124 | QStringList sFolders; | 166 | QStringList sFolders; |
125 | unsigned int i = 0; | 167 | unsigned int i = 0; |
126 | for (i=0; i < mhAccounts.count();++i) | 168 | for (i=0; i < mhAccounts.count();++i) |
127 | { | 169 | { |
128 | mhAccounts[i]->refresh(false); | 170 | mhAccounts[i]->refresh(false); |
129 | sFolders = mhAccounts[i]->subFolders(); | 171 | sFolders = mhAccounts[i]->subFolders(); |
130 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); | 172 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); |
131 | } | 173 | } |
132 | for (i=0; i < imapAccounts.count();++i) | 174 | for (i=0; i < imapAccounts.count();++i) |
133 | { | 175 | { |
134 | if (imapAccounts[i]->offline()) | 176 | if (imapAccounts[i]->offline()) |
135 | continue; | 177 | continue; |
136 | imapAccounts[i]->refreshFolders(false); | 178 | imapAccounts[i]->refreshFolders(false); |
137 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); | 179 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); |
138 | } | 180 | } |
139 | } | 181 | } |
140 | 182 | ||
141 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) | 183 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) |
142 | { | 184 | { |
143 | AbstractMail*targetMail = 0; | 185 | AbstractMail*targetMail = 0; |
144 | QString targetFolder = ""; | 186 | QString targetFolder = ""; |
145 | Selectstore sels; | 187 | Selectstore sels; |
146 | setupFolderselect(&sels); | 188 | setupFolderselect(&sels); |
147 | if (!sels.exec()) return; | 189 | if (!sels.exec()) return; |
148 | targetMail = sels.currentMail(); | 190 | targetMail = sels.currentMail(); |
149 | targetFolder = sels.currentFolder(); | 191 | targetFolder = sels.currentFolder(); |
150 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | 192 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || |
151 | targetFolder.isEmpty()) | 193 | targetFolder.isEmpty()) |
152 | { | 194 | { |
153 | return; | 195 | return; |
154 | } | 196 | } |
155 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 197 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
156 | { | 198 | { |
157 | QMessageBox::critical(0,tr("Error creating new Folder"), | 199 | QMessageBox::critical(0,tr("Error creating new Folder"), |
158 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 200 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
159 | return; | 201 | return; |
160 | } | 202 | } |
161 | odebug << "Targetfolder: " << targetFolder.latin1() << "" << oendl; | 203 | odebug << "Targetfolder: " << targetFolder.latin1() << "" << oendl; |
162 | odebug << "Fromfolder: " << fromFolder->getName().latin1() << "" << oendl; | 204 | odebug << "Fromfolder: " << fromFolder->getName().latin1() << "" << oendl; |
163 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); | 205 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); |
164 | refreshCurrent(); | 206 | refreshCurrent(); |
165 | } | 207 | } |
166 | 208 | ||
167 | bool AccountView::currentisDraft() | 209 | bool AccountView::currentisDraft() |
168 | { | 210 | { |
169 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 211 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
170 | if (!view) return false; | 212 | if (!view) return false; |
171 | return view->isDraftfolder(); | 213 | return view->isDraftfolder(); |
172 | } | 214 | } |
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index 787b0b0..ae24dce 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h | |||
@@ -1,45 +1,54 @@ | |||
1 | #ifndef ACCOUNTVIEW_H | 1 | #ifndef ACCOUNTVIEW_H |
2 | #define ACCOUNTVIEW_H | 2 | #define ACCOUNTVIEW_H |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | #include <opie2/osmartpointer.h> | 6 | #include <opie2/osmartpointer.h> |
7 | #include <libmailwrapper/mailtypes.h> | 7 | #include <libmailwrapper/mailtypes.h> |
8 | 8 | ||
9 | class Selectstore; | 9 | class Selectstore; |
10 | class Folder; | 10 | class Folder; |
11 | class AbstractMail; | 11 | class AbstractMail; |
12 | class Account; | 12 | class Account; |
13 | class IMAPviewItem; | 13 | class IMAPviewItem; |
14 | class MHviewItem; | 14 | class MHviewItem; |
15 | 15 | ||
16 | class AccountView : public QListView | 16 | class AccountView : public QListView |
17 | { | 17 | { |
18 | Q_OBJECT | 18 | Q_OBJECT |
19 | 19 | ||
20 | public: | 20 | public: |
21 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); | 21 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); |
22 | virtual ~AccountView(); | 22 | virtual ~AccountView(); |
23 | virtual void populate( QList<Account> list ); | 23 | virtual void populate( QList<Account> list ); |
24 | virtual RecBodyP fetchBody(const Opie::Core::OSmartPointer<RecMail>&aMail); | 24 | virtual RecBodyP fetchBody(const Opie::Core::OSmartPointer<RecMail>&aMail); |
25 | virtual void downloadMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,AbstractMail*fromWrapper); | 25 | virtual void downloadMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,AbstractMail*fromWrapper); |
26 | virtual bool currentisDraft(); | 26 | virtual bool currentisDraft(); |
27 | 27 | ||
28 | public slots: | 28 | public slots: |
29 | virtual void refreshAll(); | 29 | virtual void refreshAll(); |
30 | virtual void refresh(QListViewItem *item); | 30 | virtual void refresh(QListViewItem *item); |
31 | virtual void refreshCurrent(); | 31 | virtual void refreshCurrent(); |
32 | virtual void slotHold(int, QListViewItem *,const QPoint&,int); | ||
33 | virtual void slotContextMenu(int id); | 32 | virtual void slotContextMenu(int id); |
33 | |||
34 | void setupFolderselect(Selectstore*sels); | 34 | void setupFolderselect(Selectstore*sels); |
35 | 35 | ||
36 | signals: | 36 | signals: |
37 | void refreshMailview(const QValueList<RecMailP>& ); | 37 | void refreshMailview(const QValueList<RecMailP>& ); |
38 | void serverSelected(int); | ||
38 | 39 | ||
39 | protected: | 40 | protected: |
40 | QListViewItem* m_currentItem; | 41 | QListViewItem* m_currentItem; |
41 | QValueList<IMAPviewItem*> imapAccounts; | 42 | QValueList<IMAPviewItem*> imapAccounts; |
42 | QValueList<MHviewItem*> mhAccounts; | 43 | QValueList<MHviewItem*> mhAccounts; |
44 | bool m_rightPressed:1; | ||
45 | |||
46 | protected slots: | ||
47 | virtual void slotRightButton(int, QListViewItem *,const QPoint&,int); | ||
48 | virtual void slotLeftButton(int, QListViewItem *,const QPoint&,int); | ||
49 | virtual void slotMouseButton(int, QListViewItem *,const QPoint&,int); | ||
50 | virtual void slotMouseClicked(QListViewItem*); | ||
51 | virtual void slotSelectionChanged(QListViewItem*); | ||
43 | }; | 52 | }; |
44 | 53 | ||
45 | #endif | 54 | #endif |
diff --git a/noncore/net/mail/defines.h b/noncore/net/mail/defines.h index d840f09..5fcbf0f 100644 --- a/noncore/net/mail/defines.h +++ b/noncore/net/mail/defines.h | |||
@@ -1,57 +1,70 @@ | |||
1 | #ifndef DEFINE_CONSTANTS_H | 1 | #ifndef DEFINE_CONSTANTS_H |
2 | #define DEFINE_CONSTANTS_H | 2 | #define DEFINE_CONSTANTS_H |
3 | 3 | ||
4 | #include <qpe/resource.h> | 4 | #include <qpe/resource.h> |
5 | 5 | ||
6 | #define USER_AGENT "OpieMail v0.3" | 6 | #define USER_AGENT "OpieMail v0.3" |
7 | 7 | ||
8 | #define PIC_COMPOSEMAIL "mail/composemail" | 8 | #define PIC_COMPOSEMAIL "mail/composemail" |
9 | #define PIC_SENDQUEUED "mail/sendqueued" | 9 | #define PIC_SENDQUEUED "mail/sendqueued" |
10 | #define PIC_SHOWFOLDERS "mail/showfolders" | 10 | #define PIC_SHOWFOLDERS "mail/showfolders" |
11 | #define PIC_SYNC "mail/sync" | 11 | #define PIC_SYNC "mail/sync" |
12 | #define PIC_IMAPFOLDER "mail/imapfolder" | 12 | #define PIC_IMAPFOLDER "mail/imapfolder" |
13 | #define PIC_MBOXFOLDER "mail/mboxfolder" | 13 | #define PIC_MBOXFOLDER "mail/mboxfolder" |
14 | #define PIC_POP3FOLDER "mail/pop3folder" | 14 | #define PIC_POP3FOLDER "mail/pop3folder" |
15 | #define PIC_INBOXFOLDER "mail/inbox" | 15 | #define PIC_INBOXFOLDER "mail/inbox" |
16 | #define PIC_OUTBOXFOLDER "mail/outbox" | 16 | #define PIC_OUTBOXFOLDER "mail/outbox" |
17 | #define PIC_LOCALFOLDER "mail/localfolder" | 17 | #define PIC_LOCALFOLDER "mail/localfolder" |
18 | 18 | ||
19 | #define PIC_OFFLINE "mail/notconnected" | 19 | #define PIC_OFFLINE "mail/notconnected" |
20 | 20 | ||
21 | #define ICON_COMPOSEMAIL QIconSet( Resource::loadPixmap( PIC_COMPOSEMAIL ) ) | 21 | #define ICON_COMPOSEMAIL QIconSet( Resource::loadPixmap( PIC_COMPOSEMAIL ) ) |
22 | #define ICON_SENDQUEUED QIconSet( Resource::loadPixmap( PIC_SENDQUEUED ) ) | 22 | #define ICON_SENDQUEUED QIconSet( Resource::loadPixmap( PIC_SENDQUEUED ) ) |
23 | #define ICON_SHOWFOLDERS QIconSet( Resource::loadPixmap( PIC_SHOWFOLDERS ) ) | 23 | #define ICON_SHOWFOLDERS QIconSet( Resource::loadPixmap( PIC_SHOWFOLDERS ) ) |
24 | #define ICON_SEARCHMAILS QIconSet( Resource::loadPixmap( PIC_SEARCHMAILS ) ) | 24 | #define ICON_SEARCHMAILS QIconSet( Resource::loadPixmap( PIC_SEARCHMAILS ) ) |
25 | #define ICON_EDITSETTINGS QIconSet( Resource::loadPixmap( PIC_EDITSETTINGS ) ) | 25 | #define ICON_EDITSETTINGS QIconSet( Resource::loadPixmap( PIC_EDITSETTINGS ) ) |
26 | #define ICON_EDITACCOUNTS QIconSet( Resource::loadPixmap( PIC_EDITACCOUNTS ) ) | 26 | #define ICON_EDITACCOUNTS QIconSet( Resource::loadPixmap( PIC_EDITACCOUNTS ) ) |
27 | #define ICON_SYNC QIconSet( Resource::loadPixmap( PIC_SYNC ) ) | 27 | #define ICON_SYNC QIconSet( Resource::loadPixmap( PIC_SYNC ) ) |
28 | 28 | ||
29 | #define PIXMAP_IMAPFOLDER QPixmap( Resource::loadPixmap( PIC_IMAPFOLDER ) ) | 29 | #define PIXMAP_IMAPFOLDER QPixmap( Resource::loadPixmap( PIC_IMAPFOLDER ) ) |
30 | #define PIXMAP_POP3FOLDER QPixmap( Resource::loadPixmap( PIC_POP3FOLDER ) ) | 30 | #define PIXMAP_POP3FOLDER QPixmap( Resource::loadPixmap( PIC_POP3FOLDER ) ) |
31 | #define PIXMAP_INBOXFOLDER QPixmap( Resource::loadPixmap( PIC_INBOXFOLDER) ) | 31 | #define PIXMAP_INBOXFOLDER QPixmap( Resource::loadPixmap( PIC_INBOXFOLDER) ) |
32 | #define PIXMAP_MBOXFOLDER QPixmap( Resource::loadPixmap( PIC_MBOXFOLDER ) ) | 32 | #define PIXMAP_MBOXFOLDER QPixmap( Resource::loadPixmap( PIC_MBOXFOLDER ) ) |
33 | #define PIXMAP_OUTBOXFOLDER QPixmap( Resource::loadPixmap( PIC_OUTBOXFOLDER) ) | 33 | #define PIXMAP_OUTBOXFOLDER QPixmap( Resource::loadPixmap( PIC_OUTBOXFOLDER) ) |
34 | #define PIXMAP_LOCALFOLDER QPixmap( Resource::loadPixmap( PIC_LOCALFOLDER) ) | 34 | #define PIXMAP_LOCALFOLDER QPixmap( Resource::loadPixmap( PIC_LOCALFOLDER) ) |
35 | #define PIXMAP_OFFLINE QPixmap( Resource::loadPixmap( PIC_OFFLINE) ) | 35 | #define PIXMAP_OFFLINE QPixmap( Resource::loadPixmap( PIC_OFFLINE) ) |
36 | 36 | ||
37 | #define IMAP_PORT "143" | 37 | #define IMAP_PORT "143" |
38 | #define IMAP_SSL_PORT "993" | 38 | #define IMAP_SSL_PORT "993" |
39 | #define SMTP_PORT "25" | 39 | #define SMTP_PORT "25" |
40 | #define SMTP_SSL_PORT "465" | 40 | #define SMTP_SSL_PORT "465" |
41 | #define POP3_PORT "110" | 41 | #define POP3_PORT "110" |
42 | #define POP3_SSL_PORT "995" | 42 | #define POP3_SSL_PORT "995" |
43 | #define NNTP_PORT "119" | 43 | #define NNTP_PORT "119" |
44 | #define NNTP_SSL_PORT "563" | 44 | #define NNTP_SSL_PORT "563" |
45 | 45 | ||
46 | /* used for decoding imapfoldername */ | 46 | /* used for decoding imapfoldername */ |
47 | #define UNDEFINED 64 | 47 | #define UNDEFINED 64 |
48 | #define MAXLINE 76 | 48 | #define MAXLINE 76 |
49 | #define UTF16MASK 0x03FFUL | 49 | #define UTF16MASK 0x03FFUL |
50 | #define UTF16SHIFT 10 | 50 | #define UTF16SHIFT 10 |
51 | #define UTF16BASE 0x10000UL | 51 | #define UTF16BASE 0x10000UL |
52 | #define UTF16HIGHSTART 0xD800UL | 52 | #define UTF16HIGHSTART 0xD800UL |
53 | #define UTF16HIGHEND 0xDBFFUL | 53 | #define UTF16HIGHEND 0xDBFFUL |
54 | #define UTF16LOSTART 0xDC00UL | 54 | #define UTF16LOSTART 0xDC00UL |
55 | #define UTF16LOEND 0xDFFFUL | 55 | #define UTF16LOEND 0xDFFFUL |
56 | 56 | ||
57 | /* used for making menuids transparent */ | ||
58 | #define FOLDER_MENU_REFRESH_HEADER 0 | ||
59 | #define FOLDER_MENU_DELETE_ALL_MAILS 1 | ||
60 | #define FOLDER_MENU_NEW_SUBFOLDER 2 | ||
61 | #define FOLDER_MENU_DELETE_FOLDER 3 | ||
62 | #define FOLDER_MENU_MOVE_MAILS 4 | ||
63 | |||
64 | #define SERVER_MENU_DISCONNECT 5 | ||
65 | #define SERVER_MENU_OFFLINE 6 | ||
66 | #define SERVER_MENU_REFRESH_FOLDER 7 | ||
67 | #define SERVER_MENU_CREATE_FOLDER 8 | ||
68 | #define SERVER_MENU_SUBSCRIBE 9 | ||
69 | |||
57 | #endif | 70 | #endif |
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index 0a45445..81c8fee 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp | |||
@@ -1,235 +1,270 @@ | |||
1 | #include <qlabel.h> | 1 | #include <qlabel.h> |
2 | #include <qvbox.h> | 2 | #include <qvbox.h> |
3 | #include <qheader.h> | 3 | #include <qheader.h> |
4 | #include <qtimer.h> | 4 | #include <qtimer.h> |
5 | #include <qlayout.h> | 5 | #include <qlayout.h> |
6 | 6 | ||
7 | #include <opie2/odebug.h> | 7 | #include <opie2/odebug.h> |
8 | #include <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
9 | #include <qpe/qcopenvelope_qws.h> | 9 | #include <qpe/qcopenvelope_qws.h> |
10 | 10 | ||
11 | #include "defines.h" | 11 | #include "defines.h" |
12 | #include "mainwindow.h" | 12 | #include "mainwindow.h" |
13 | 13 | ||
14 | using namespace Opie::Core; | 14 | using namespace Opie::Core; |
15 | 15 | ||
16 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | 16 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) |
17 | : QMainWindow( parent, name, flags ) | 17 | : QMainWindow( parent, name, flags ) |
18 | { | 18 | { |
19 | 19 | ||
20 | setCaption( tr( "Mail" ) ); | 20 | setCaption( tr( "Mail" ) ); |
21 | setToolBarsMovable( false ); | 21 | setToolBarsMovable( false ); |
22 | 22 | ||
23 | toolBar = new QToolBar( this ); | 23 | toolBar = new QToolBar( this ); |
24 | |||
24 | menuBar = new QMenuBar( toolBar ); | 25 | menuBar = new QMenuBar( toolBar ); |
26 | |||
25 | mailMenu = new QPopupMenu( menuBar ); | 27 | mailMenu = new QPopupMenu( menuBar ); |
26 | menuBar->insertItem( tr( "Mail" ), mailMenu ); | 28 | menuBar->insertItem( tr( "Mail" ), mailMenu ); |
29 | |||
27 | settingsMenu = new QPopupMenu( menuBar ); | 30 | settingsMenu = new QPopupMenu( menuBar ); |
28 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); | 31 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); |
29 | 32 | ||
33 | serverMenu = new QPopupMenu( menuBar ); | ||
34 | m_ServerMenuId = menuBar->insertItem( tr( "Server" ), serverMenu ); | ||
35 | serverMenu->insertItem(tr("Disconnect"),SERVER_MENU_DISCONNECT); | ||
36 | serverMenu->insertItem(tr("Set on/offline"),SERVER_MENU_OFFLINE); | ||
37 | serverMenu->insertSeparator(); | ||
38 | serverMenu->insertItem(tr("Refresh folder list"),SERVER_MENU_REFRESH_FOLDER); | ||
39 | serverMenu->insertItem(tr("Create new folder"),SERVER_MENU_CREATE_FOLDER); | ||
40 | serverMenu->insertSeparator(); | ||
41 | serverMenu->insertItem(tr("(Un-)Subscribe groups"),SERVER_MENU_SUBSCRIBE); | ||
42 | |||
43 | folderMenu = new QPopupMenu( menuBar ); | ||
44 | m_FolderMenuId = menuBar->insertItem( tr( "Folder" ), folderMenu ); | ||
45 | folderMenu->insertItem(tr("Refresh headerlist"),FOLDER_MENU_REFRESH_HEADER); | ||
46 | folderMenu->insertItem(tr("Delete all mails"),FOLDER_MENU_DELETE_ALL_MAILS); | ||
47 | folderMenu->insertItem(tr("New subfolder"),FOLDER_MENU_NEW_SUBFOLDER); | ||
48 | folderMenu->insertItem(tr("Delete folder"),FOLDER_MENU_DELETE_FOLDER); | ||
49 | folderMenu->insertItem(tr("Move/Copie all mails"),FOLDER_MENU_MOVE_MAILS); | ||
50 | |||
51 | menuBar->setItemEnabled(m_ServerMenuId,false); | ||
52 | menuBar->setItemEnabled(m_FolderMenuId,false); | ||
53 | |||
30 | addToolBar( toolBar ); | 54 | addToolBar( toolBar ); |
31 | toolBar->setHorizontalStretchable( true ); | 55 | toolBar->setHorizontalStretchable( true ); |
32 | 56 | ||
33 | QLabel *spacer = new QLabel( toolBar ); | 57 | QLabel *spacer = new QLabel( toolBar ); |
34 | spacer->setBackgroundMode( QWidget::PaletteButton ); | 58 | spacer->setBackgroundMode( QWidget::PaletteButton ); |
35 | toolBar->setStretchableWidget( spacer ); | 59 | toolBar->setStretchableWidget( spacer ); |
36 | 60 | ||
37 | composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, | 61 | composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, |
38 | 0, 0, this ); | 62 | 0, 0, this ); |
39 | composeMail->addTo( toolBar ); | 63 | composeMail->addTo( toolBar ); |
40 | composeMail->addTo( mailMenu ); | 64 | composeMail->addTo( mailMenu ); |
41 | 65 | ||
42 | sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, | 66 | sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, |
43 | 0, 0, this ); | 67 | 0, 0, this ); |
44 | sendQueued->addTo( toolBar ); | 68 | sendQueued->addTo( toolBar ); |
45 | sendQueued->addTo( mailMenu ); | 69 | sendQueued->addTo( mailMenu ); |
46 | 70 | ||
47 | /* | 71 | /* |
48 | syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, | 72 | syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, |
49 | 0, 0, this ); | 73 | 0, 0, this ); |
50 | syncFolders->addTo( toolBar ); | 74 | syncFolders->addTo( toolBar ); |
51 | syncFolders->addTo( mailMenu ); | 75 | syncFolders->addTo( mailMenu ); |
52 | */ | 76 | */ |
53 | 77 | ||
54 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, | 78 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, |
55 | 0, 0, this, 0, true ); | 79 | 0, 0, this, 0, true ); |
56 | showFolders->addTo( toolBar ); | 80 | showFolders->addTo( toolBar ); |
57 | showFolders->addTo( mailMenu ); | 81 | showFolders->addTo( mailMenu ); |
58 | showFolders->setOn( true ); | 82 | showFolders->setOn( true ); |
59 | connect(showFolders, SIGNAL( toggled(bool) ), | 83 | connect(showFolders, SIGNAL( toggled(bool) ), |
60 | SLOT( slotShowFolders(bool) ) ); | 84 | SLOT( slotShowFolders(bool) ) ); |
61 | 85 | ||
62 | /* | 86 | /* |
63 | searchMails = new QAction( tr( "Search mails" ), QIconSet( Resource::loadPixmap("find") ), | 87 | searchMails = new QAction( tr( "Search mails" ), QIconSet( Resource::loadPixmap("find") ), |
64 | 0, 0, this ); | 88 | 0, 0, this ); |
65 | searchMails->addTo( toolBar ); | 89 | searchMails->addTo( toolBar ); |
66 | searchMails->addTo( mailMenu ); | 90 | searchMails->addTo( mailMenu ); |
67 | */ | 91 | */ |
68 | 92 | ||
69 | deleteMails = new QAction(tr("Delete Mail"), QIconSet( Resource::loadPixmap("trash")), 0, 0, this); | 93 | deleteMails = new QAction(tr("Delete Mail"), QIconSet( Resource::loadPixmap("trash")), 0, 0, this); |
70 | deleteMails->addTo( toolBar ); | 94 | deleteMails->addTo( toolBar ); |
71 | deleteMails->addTo( mailMenu ); | 95 | deleteMails->addTo( mailMenu ); |
72 | connect( deleteMails, SIGNAL( activated() ), | 96 | connect( deleteMails, SIGNAL( activated() ), |
73 | SLOT( slotDeleteMail() ) ); | 97 | SLOT( slotDeleteMail() ) ); |
74 | 98 | ||
75 | editSettings = new QAction( tr( "Edit settings" ), QIconSet( Resource::loadPixmap("SettingsIcon") ) , | 99 | editSettings = new QAction( tr( "Edit settings" ), QIconSet( Resource::loadPixmap("SettingsIcon") ) , |
76 | 0, 0, this ); | 100 | 0, 0, this ); |
77 | editSettings->addTo( settingsMenu ); | 101 | editSettings->addTo( settingsMenu ); |
78 | connect( editSettings, SIGNAL( activated() ), | 102 | connect( editSettings, SIGNAL( activated() ), |
79 | SLOT( slotEditSettings() ) ); | 103 | SLOT( slotEditSettings() ) ); |
80 | editAccounts = new QAction( tr( "Configure accounts" ), QIconSet( Resource::loadPixmap("mail/editaccounts") ) , | 104 | editAccounts = new QAction( tr( "Configure accounts" ), QIconSet( Resource::loadPixmap("mail/editaccounts") ) , |
81 | 0, 0, this ); | 105 | 0, 0, this ); |
82 | editAccounts->addTo( settingsMenu ); | 106 | editAccounts->addTo( settingsMenu ); |
83 | 107 | ||
84 | 108 | ||
85 | QWidget *view = new QWidget( this ); | 109 | QWidget *view = new QWidget( this ); |
86 | setCentralWidget( view ); | 110 | setCentralWidget( view ); |
87 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); | 111 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); |
88 | 112 | ||
89 | folderView = new AccountView( view ); | 113 | folderView = new AccountView( view ); |
90 | folderView->header()->hide(); | 114 | folderView->header()->hide(); |
91 | folderView->setRootIsDecorated( true ); | 115 | folderView->setRootIsDecorated( true ); |
92 | folderView->addColumn( tr( "Mailbox" ) ); | 116 | folderView->addColumn( tr( "Mailbox" ) ); |
117 | connect(folderView,SIGNAL(serverSelected(int)),this,SLOT(serverSelected(int))); | ||
118 | connect(serverMenu,SIGNAL(activated(int)),folderView,SLOT(slotContextMenu(int))); | ||
119 | connect(folderMenu,SIGNAL(activated(int)),folderView,SLOT(slotContextMenu(int))); | ||
120 | |||
93 | 121 | ||
94 | layout->addWidget( folderView ); | 122 | layout->addWidget( folderView ); |
95 | 123 | ||
96 | mailView = new QListView( view ); | 124 | mailView = new QListView( view ); |
97 | mailView->addColumn( "" ); | 125 | mailView->addColumn( "" ); |
98 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); | 126 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); |
99 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); | 127 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); |
100 | mailView->addColumn( tr( "Size" ),QListView::Manual); | 128 | mailView->addColumn( tr( "Size" ),QListView::Manual); |
101 | mailView->addColumn( tr( "Date" )); | 129 | mailView->addColumn( tr( "Date" )); |
102 | mailView->setAllColumnsShowFocus(true); | 130 | mailView->setAllColumnsShowFocus(true); |
103 | mailView->setShowSortIndicator(true); | 131 | mailView->setShowSortIndicator(true); |
104 | mailView->setSorting(4,false); | 132 | mailView->setSorting(4,false); |
105 | 133 | ||
106 | layout->addWidget( mailView ); | 134 | layout->addWidget( mailView ); |
107 | layout->setStretchFactor( folderView, 1 ); | 135 | layout->setStretchFactor( folderView, 1 ); |
108 | layout->setStretchFactor( mailView, 2 ); | 136 | layout->setStretchFactor( mailView, 2 ); |
109 | 137 | ||
110 | m_Rotate = (QApplication::desktop()->width() > QApplication::desktop()->height()?0:90); | 138 | m_Rotate = (QApplication::desktop()->width() > QApplication::desktop()->height()?0:90); |
111 | 139 | ||
112 | slotAdjustLayout(); | 140 | slotAdjustLayout(); |
113 | 141 | ||
114 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); | 142 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); |
115 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); | 143 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); |
116 | 144 | ||
117 | connect( mailView, SIGNAL( mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),this, | 145 | connect( mailView, SIGNAL( mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),this, |
118 | SLOT( mailLeftClicked(int,QListViewItem*,const QPoint&,int) ) ); | 146 | SLOT( mailLeftClicked(int,QListViewItem*,const QPoint&,int) ) ); |
119 | connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, | 147 | connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, |
120 | SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); | 148 | SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); |
121 | 149 | ||
122 | connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), | 150 | connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), |
123 | this,SLOT(refreshMailView(const QValueList<RecMailP>&))); | 151 | this,SLOT(refreshMailView(const QValueList<RecMailP>&))); |
124 | 152 | ||
125 | connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); | 153 | connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); |
126 | connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); | 154 | connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); |
127 | 155 | ||
128 | // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); | 156 | // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); |
129 | connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); | 157 | connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); |
130 | // Added by Stefan Eilers to allow starting by addressbook.. | 158 | // Added by Stefan Eilers to allow starting by addressbook.. |
131 | // copied from old mail2 | 159 | // copied from old mail2 |
132 | 160 | ||
133 | #if !defined(QT_NO_COP) | 161 | #if !defined(QT_NO_COP) |
134 | connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), | 162 | connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), |
135 | this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); | 163 | this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); |
136 | m_sysChannel = new QCopChannel( "QPE/System", this ); | 164 | m_sysChannel = new QCopChannel( "QPE/System", this ); |
137 | connect( m_sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 165 | connect( m_sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
138 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); | 166 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); |
139 | #endif | 167 | #endif |
140 | 168 | ||
141 | QTimer::singleShot( 10, this, SLOT( slotAdjustColumns() ) ); | 169 | QTimer::singleShot( 10, this, SLOT( slotAdjustColumns() ) ); |
142 | } | 170 | } |
143 | 171 | ||
144 | MainWindow::~MainWindow() | 172 | MainWindow::~MainWindow() |
145 | { | 173 | { |
146 | } | 174 | } |
147 | 175 | ||
176 | void MainWindow::serverSelected(int m_isFolder) | ||
177 | { | ||
178 | mailView->clear(); | ||
179 | menuBar->setItemEnabled(m_ServerMenuId,m_isFolder&1); | ||
180 | menuBar->setItemEnabled(m_FolderMenuId,m_isFolder&2); | ||
181 | } | ||
182 | |||
148 | void MainWindow::systemMessage( const QCString& msg, const QByteArray& data ) | 183 | void MainWindow::systemMessage( const QCString& msg, const QByteArray& data ) |
149 | { | 184 | { |
150 | int _newrotation; | 185 | int _newrotation; |
151 | QDataStream stream( data, IO_ReadOnly ); | 186 | QDataStream stream( data, IO_ReadOnly ); |
152 | if ( msg == "setCurrentRotation(int)" ) | 187 | if ( msg == "setCurrentRotation(int)" ) |
153 | { | 188 | { |
154 | stream >> _newrotation; | 189 | stream >> _newrotation; |
155 | if (m_Rotate != _newrotation) { | 190 | if (m_Rotate != _newrotation) { |
156 | slotAdjustLayout(); | 191 | slotAdjustLayout(); |
157 | m_Rotate = _newrotation; | 192 | m_Rotate = _newrotation; |
158 | } | 193 | } |
159 | } | 194 | } |
160 | } | 195 | } |
161 | 196 | ||
162 | void MainWindow::appMessage(const QCString &, const QByteArray &) | 197 | void MainWindow::appMessage(const QCString &, const QByteArray &) |
163 | { | 198 | { |
164 | odebug << "appMessage not reached" << oendl; | 199 | odebug << "appMessage not reached" << oendl; |
165 | } | 200 | } |
166 | 201 | ||
167 | void MainWindow::slotAdjustLayout() { | 202 | void MainWindow::slotAdjustLayout() { |
168 | 203 | ||
169 | QWidget *d = QApplication::desktop(); | 204 | QWidget *d = QApplication::desktop(); |
170 | if ( d->width() < d->height() ) { | 205 | if ( d->width() < d->height() ) { |
171 | layout->setDirection( QBoxLayout::TopToBottom ); | 206 | layout->setDirection( QBoxLayout::TopToBottom ); |
172 | } else { | 207 | } else { |
173 | layout->setDirection( QBoxLayout::LeftToRight ); | 208 | layout->setDirection( QBoxLayout::LeftToRight ); |
174 | } | 209 | } |
175 | } | 210 | } |
176 | 211 | ||
177 | void MainWindow::slotAdjustColumns() | 212 | void MainWindow::slotAdjustColumns() |
178 | { | 213 | { |
179 | bool hidden = folderView->isHidden(); | 214 | bool hidden = folderView->isHidden(); |
180 | if ( hidden ) folderView->show(); | 215 | if ( hidden ) folderView->show(); |
181 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); | 216 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); |
182 | if ( hidden ) folderView->hide(); | 217 | if ( hidden ) folderView->hide(); |
183 | 218 | ||
184 | mailView->setColumnWidth( 0, 10 ); | 219 | mailView->setColumnWidth( 0, 10 ); |
185 | mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); | 220 | mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); |
186 | mailView->setColumnWidth( 2, 80 ); | 221 | mailView->setColumnWidth( 2, 80 ); |
187 | mailView->setColumnWidth( 3, 50 ); | 222 | mailView->setColumnWidth( 3, 50 ); |
188 | mailView->setColumnWidth( 4, 50 ); | 223 | mailView->setColumnWidth( 4, 50 ); |
189 | } | 224 | } |
190 | 225 | ||
191 | void MainWindow::slotEditSettings() | 226 | void MainWindow::slotEditSettings() |
192 | { | 227 | { |
193 | } | 228 | } |
194 | 229 | ||
195 | void MainWindow::slotShowFolders( bool ) | 230 | void MainWindow::slotShowFolders( bool ) |
196 | { | 231 | { |
197 | odebug << "slotShowFolders not reached" << oendl; | 232 | odebug << "slotShowFolders not reached" << oendl; |
198 | } | 233 | } |
199 | 234 | ||
200 | void MainWindow::refreshMailView(const QValueList<RecMailP>&) | 235 | void MainWindow::refreshMailView(const QValueList<RecMailP>&) |
201 | { | 236 | { |
202 | odebug << "refreshMailView not reached" << oendl; | 237 | odebug << "refreshMailView not reached" << oendl; |
203 | } | 238 | } |
204 | 239 | ||
205 | void MainWindow::mailLeftClicked(int, QListViewItem *,const QPoint&,int ) | 240 | void MainWindow::mailLeftClicked(int, QListViewItem *,const QPoint&,int ) |
206 | { | 241 | { |
207 | odebug << "mailLeftClicked not reached" << oendl; | 242 | odebug << "mailLeftClicked not reached" << oendl; |
208 | } | 243 | } |
209 | 244 | ||
210 | void MainWindow::displayMail() | 245 | void MainWindow::displayMail() |
211 | { | 246 | { |
212 | odebug << "displayMail not reached" << oendl; | 247 | odebug << "displayMail not reached" << oendl; |
213 | } | 248 | } |
214 | 249 | ||
215 | void MainWindow::slotDeleteMail() | 250 | void MainWindow::slotDeleteMail() |
216 | { | 251 | { |
217 | odebug << "deleteMail not reached" << oendl; | 252 | odebug << "deleteMail not reached" << oendl; |
218 | } | 253 | } |
219 | 254 | ||
220 | void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) | 255 | void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) |
221 | { | 256 | { |
222 | odebug << "mailHold not reached" << oendl; | 257 | odebug << "mailHold not reached" << oendl; |
223 | } | 258 | } |
224 | 259 | ||
225 | void MainWindow::slotSendQueued() | 260 | void MainWindow::slotSendQueued() |
226 | { | 261 | { |
227 | } | 262 | } |
228 | 263 | ||
229 | void MainWindow::slotEditAccounts() | 264 | void MainWindow::slotEditAccounts() |
230 | { | 265 | { |
231 | } | 266 | } |
232 | 267 | ||
233 | void MainWindow::slotComposeMail() | 268 | void MainWindow::slotComposeMail() |
234 | { | 269 | { |
235 | } | 270 | } |
diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h index ad71a54..409f160 100644 --- a/noncore/net/mail/mainwindow.h +++ b/noncore/net/mail/mainwindow.h | |||
@@ -1,58 +1,61 @@ | |||
1 | #ifndef MAINWINDOW_H | 1 | #ifndef MAINWINDOW_H |
2 | #define MAINWINDOW_H | 2 | #define MAINWINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qlistview.h> | 5 | #include <qlistview.h> |
6 | #include <qaction.h> | 6 | #include <qaction.h> |
7 | 7 | ||
8 | #include <qtoolbar.h> | 8 | #include <qtoolbar.h> |
9 | #include <qmenubar.h> | 9 | #include <qmenubar.h> |
10 | 10 | ||
11 | #include "accountview.h" | 11 | #include "accountview.h" |
12 | 12 | ||
13 | #include <libmailwrapper/mailtypes.h> | 13 | #include <libmailwrapper/mailtypes.h> |
14 | #include <opie2/osmartpointer.h> | 14 | #include <opie2/osmartpointer.h> |
15 | 15 | ||
16 | class RecMail; | 16 | class RecMail; |
17 | class QCopChannel; | 17 | class QCopChannel; |
18 | 18 | ||
19 | class MainWindow : public QMainWindow | 19 | class MainWindow : public QMainWindow |
20 | { | 20 | { |
21 | Q_OBJECT | 21 | Q_OBJECT |
22 | 22 | ||
23 | public: | 23 | public: |
24 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); | 24 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); |
25 | virtual ~MainWindow(); | 25 | virtual ~MainWindow(); |
26 | 26 | ||
27 | public slots: | 27 | public slots: |
28 | virtual void slotAdjustColumns(); | 28 | virtual void slotAdjustColumns(); |
29 | virtual void appMessage(const QCString &msg, const QByteArray &data); | 29 | virtual void appMessage(const QCString &msg, const QByteArray &data); |
30 | virtual void slotComposeMail(); | 30 | virtual void slotComposeMail(); |
31 | virtual void systemMessage( const QCString&, const QByteArray& ); | 31 | virtual void systemMessage( const QCString&, const QByteArray& ); |
32 | 32 | ||
33 | protected slots: | 33 | protected slots: |
34 | virtual void slotSendQueued(); | 34 | virtual void slotSendQueued(); |
35 | virtual void slotEditAccounts(); | 35 | virtual void slotEditAccounts(); |
36 | virtual void slotShowFolders( bool show ); | 36 | virtual void slotShowFolders( bool show ); |
37 | virtual void refreshMailView(const QValueList<RecMailP>&); | 37 | virtual void refreshMailView(const QValueList<RecMailP>&); |
38 | virtual void displayMail(); | 38 | virtual void displayMail(); |
39 | virtual void slotDeleteMail(); | 39 | virtual void slotDeleteMail(); |
40 | virtual void mailHold(int, QListViewItem *,const QPoint&,int); | 40 | virtual void mailHold(int, QListViewItem *,const QPoint&,int); |
41 | virtual void slotAdjustLayout(); | 41 | virtual void slotAdjustLayout(); |
42 | virtual void slotEditSettings(); | 42 | virtual void slotEditSettings(); |
43 | virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int ); | 43 | virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int ); |
44 | virtual void serverSelected(int); | ||
44 | 45 | ||
45 | protected: | 46 | protected: |
46 | QToolBar *toolBar; | 47 | QToolBar *toolBar; |
47 | QMenuBar *menuBar; | 48 | QMenuBar *menuBar; |
48 | QPopupMenu *mailMenu, *settingsMenu; | 49 | QPopupMenu *mailMenu, *settingsMenu,*serverMenu,*folderMenu; |
50 | |||
49 | QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, | 51 | QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, |
50 | *editSettings, *editAccounts, *syncFolders; | 52 | *editSettings, *editAccounts, *syncFolders; |
51 | AccountView *folderView; | 53 | AccountView *folderView; |
52 | QListView *mailView; | 54 | QListView *mailView; |
53 | QBoxLayout *layout; | 55 | QBoxLayout *layout; |
54 | int m_Rotate; | 56 | int m_Rotate; |
55 | QCopChannel* m_sysChannel; | 57 | QCopChannel* m_sysChannel; |
58 | int m_ServerMenuId,m_FolderMenuId; | ||
56 | }; | 59 | }; |
57 | 60 | ||
58 | #endif | 61 | #endif |
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp index 9eba23e..7c6d314 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp | |||
@@ -1,388 +1,388 @@ | |||
1 | 1 | ||
2 | #include "settingsdialog.h" | 2 | #include "settingsdialog.h" |
3 | #include "opiemail.h" | 3 | #include "opiemail.h" |
4 | #include "editaccounts.h" | 4 | #include "editaccounts.h" |
5 | #include "composemail.h" | 5 | #include "composemail.h" |
6 | #include "mailistviewitem.h" | 6 | #include "mailistviewitem.h" |
7 | #include "viewmail.h" | 7 | #include "viewmail.h" |
8 | #include "selectstore.h" | 8 | #include "selectstore.h" |
9 | #include "selectsmtp.h" | 9 | #include "selectsmtp.h" |
10 | 10 | ||
11 | #include <libmailwrapper/smtpwrapper.h> | 11 | #include <libmailwrapper/smtpwrapper.h> |
12 | #include <libmailwrapper/mailtypes.h> | 12 | #include <libmailwrapper/mailtypes.h> |
13 | #include <libmailwrapper/abstractmail.h> | 13 | #include <libmailwrapper/abstractmail.h> |
14 | /* OPIE */ | 14 | /* OPIE */ |
15 | #include <opie2/odebug.h> | 15 | #include <opie2/odebug.h> |
16 | #include <qpe/resource.h> | 16 | #include <qpe/resource.h> |
17 | #include <qpe/qpeapplication.h> | 17 | #include <qpe/qpeapplication.h> |
18 | 18 | ||
19 | /* QT */ | 19 | /* QT */ |
20 | #include <qmap.h> | 20 | #include <qmap.h> |
21 | #include <qvaluelist.h> | 21 | #include <qvaluelist.h> |
22 | 22 | ||
23 | /* UNIX */ | 23 | /* UNIX */ |
24 | #include <signal.h> | 24 | #include <signal.h> |
25 | 25 | ||
26 | using namespace Opie::Core; | 26 | using namespace Opie::Core; |
27 | 27 | ||
28 | typedef QMapNode<QString,QString> tkeyvalues; | 28 | typedef QMapNode<QString,QString> tkeyvalues; |
29 | typedef QValueList<tkeyvalues> tvaluelist; | 29 | typedef QValueList<tkeyvalues> tvaluelist; |
30 | 30 | ||
31 | class ValueExplode | 31 | class ValueExplode |
32 | { | 32 | { |
33 | protected: | 33 | protected: |
34 | //! what was parsed last | 34 | //! what was parsed last |
35 | tvaluelist m_LastParsed; | 35 | tvaluelist m_LastParsed; |
36 | //! the delemiter to use | 36 | //! the delemiter to use |
37 | QString mDelemiter; | 37 | QString mDelemiter; |
38 | //! the inner delemiter | 38 | //! the inner delemiter |
39 | QString m2Delemiter; | 39 | QString m2Delemiter; |
40 | //! the real split routine | 40 | //! the real split routine |
41 | void splitit(); | 41 | void splitit(); |
42 | //! the content | 42 | //! the content |
43 | QString m_Command; | 43 | QString m_Command; |
44 | //! constructor | 44 | //! constructor |
45 | ValueExplode(){} | 45 | ValueExplode(){} |
46 | public: | 46 | public: |
47 | //! constructor | 47 | //! constructor |
48 | /*! | 48 | /*! |
49 | * \param aCommand the string to be splitted | 49 | * \param aCommand the string to be splitted |
50 | * \param aDelemiter which sign will be the delemiter character | 50 | * \param aDelemiter which sign will be the delemiter character |
51 | * \param a2Delemiter which sign will delemiter the key-value-pairs between other delemiters | 51 | * \param a2Delemiter which sign will delemiter the key-value-pairs between other delemiters |
52 | */ | 52 | */ |
53 | ValueExplode(const QString&aCommand,const char aDelemiter = '&',const char a2Delemiter='='); | 53 | ValueExplode(const QString&aCommand,const char aDelemiter = '&',const char a2Delemiter='='); |
54 | //! destructor | 54 | //! destructor |
55 | virtual ~ValueExplode(); | 55 | virtual ~ValueExplode(); |
56 | //! assigen operator | 56 | //! assigen operator |
57 | /*! | 57 | /*! |
58 | * \return a list of substrings | 58 | * \return a list of substrings |
59 | */ | 59 | */ |
60 | operator const tvaluelist& (){return m_LastParsed;} | 60 | operator const tvaluelist& (){return m_LastParsed;} |
61 | }; | 61 | }; |
62 | 62 | ||
63 | ValueExplode::~ValueExplode() | 63 | ValueExplode::~ValueExplode() |
64 | { | 64 | { |
65 | } | 65 | } |
66 | 66 | ||
67 | ValueExplode::ValueExplode(const QString&aCommand,const char aDelemiter,const char a2Delemiter) | 67 | ValueExplode::ValueExplode(const QString&aCommand,const char aDelemiter,const char a2Delemiter) |
68 | :m_LastParsed(),m_Command(aCommand) | 68 | :m_LastParsed(),m_Command(aCommand) |
69 | { | 69 | { |
70 | mDelemiter = aDelemiter; | 70 | mDelemiter = aDelemiter; |
71 | m2Delemiter = a2Delemiter; | 71 | m2Delemiter = a2Delemiter; |
72 | splitit(); | 72 | splitit(); |
73 | } | 73 | } |
74 | 74 | ||
75 | void ValueExplode::splitit() | 75 | void ValueExplode::splitit() |
76 | { | 76 | { |
77 | QString iLine; | 77 | QString iLine; |
78 | m_LastParsed.clear(); | 78 | m_LastParsed.clear(); |
79 | if (mDelemiter.isEmpty()||m2Delemiter.isEmpty()) { | 79 | if (mDelemiter.isEmpty()||m2Delemiter.isEmpty()) { |
80 | m_LastParsed.append(tkeyvalues(m_Command,"")); | 80 | m_LastParsed.append(tkeyvalues(m_Command,"")); |
81 | return; | 81 | return; |
82 | } | 82 | } |
83 | int pos,pos2,startpos; | 83 | int pos,pos2; |
84 | startpos = 0; | 84 | unsigned startpos = 0; |
85 | iLine = m_Command; | 85 | iLine = m_Command; |
86 | while ( (pos = iLine.find(mDelemiter,startpos))!=-1) { | 86 | while ( (pos = iLine.find(mDelemiter,startpos))!=-1) { |
87 | pos2 = iLine.find(m2Delemiter,startpos); | 87 | pos2 = iLine.find(m2Delemiter,startpos); |
88 | if (pos2==-1||pos2>pos) { | 88 | if (pos2==-1||pos2>pos) { |
89 | m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos-startpos),"")); | 89 | m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos-startpos),"")); |
90 | } else { | 90 | } else { |
91 | m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos2-startpos),iLine.mid(pos2+1,pos-pos2-1))); | 91 | m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos2-startpos),iLine.mid(pos2+1,pos-pos2-1))); |
92 | } | 92 | } |
93 | startpos = pos+1; | 93 | startpos = pos+1; |
94 | } | 94 | } |
95 | if (startpos<iLine.length()) { | 95 | if (startpos<iLine.length()) { |
96 | pos2 = iLine.find(m2Delemiter,startpos); | 96 | pos2 = iLine.find(m2Delemiter,startpos); |
97 | if (pos2==-1) { | 97 | if (pos2==-1) { |
98 | m_LastParsed.append(tkeyvalues(iLine.mid(startpos),"")); | 98 | m_LastParsed.append(tkeyvalues(iLine.mid(startpos),"")); |
99 | } else { | 99 | } else { |
100 | m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos2-startpos),iLine.mid(pos2+1))); | 100 | m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos2-startpos),iLine.mid(pos2+1))); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | OpieMail::OpieMail( QWidget *parent, const char *name, WFlags ) | 105 | OpieMail::OpieMail( QWidget *parent, const char *name, WFlags ) |
106 | : MainWindow( parent, name, WStyle_ContextHelp ) | 106 | : MainWindow( parent, name, WStyle_ContextHelp ) |
107 | { | 107 | { |
108 | setup_signalblocking(); | 108 | setup_signalblocking(); |
109 | settings = new Settings(); | 109 | settings = new Settings(); |
110 | folderView->populate( settings->getAccounts() ); | 110 | folderView->populate( settings->getAccounts() ); |
111 | } | 111 | } |
112 | 112 | ||
113 | OpieMail::~OpieMail() | 113 | OpieMail::~OpieMail() |
114 | { | 114 | { |
115 | if (settings) delete settings; | 115 | if (settings) delete settings; |
116 | } | 116 | } |
117 | 117 | ||
118 | void OpieMail::setup_signalblocking() | 118 | void OpieMail::setup_signalblocking() |
119 | { | 119 | { |
120 | /* for networking we must block SIGPIPE and Co. */ | 120 | /* for networking we must block SIGPIPE and Co. */ |
121 | struct sigaction blocking_action,temp_action; | 121 | struct sigaction blocking_action,temp_action; |
122 | blocking_action.sa_handler = SIG_IGN; | 122 | blocking_action.sa_handler = SIG_IGN; |
123 | sigemptyset(&(blocking_action.sa_mask)); | 123 | sigemptyset(&(blocking_action.sa_mask)); |
124 | blocking_action.sa_flags = 0; | 124 | blocking_action.sa_flags = 0; |
125 | sigaction(SIGPIPE,&blocking_action,&temp_action); | 125 | sigaction(SIGPIPE,&blocking_action,&temp_action); |
126 | } | 126 | } |
127 | 127 | ||
128 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 128 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
129 | { | 129 | { |
130 | // copied from old mail2 | 130 | // copied from old mail2 |
131 | if (msg == "writeMail(QString,QString)") | 131 | if (msg == "writeMail(QString,QString)") |
132 | { | 132 | { |
133 | QDataStream stream(data,IO_ReadOnly); | 133 | QDataStream stream(data,IO_ReadOnly); |
134 | QString name, email; | 134 | QString name, email; |
135 | stream >> name >> email; | 135 | stream >> name >> email; |
136 | // removing the whitespaces at beginning and end is needed! | 136 | // removing the whitespaces at beginning and end is needed! |
137 | slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); | 137 | slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); |
138 | } | 138 | } |
139 | else if (msg == "newMail()") | 139 | else if (msg == "newMail()") |
140 | { | 140 | { |
141 | slotComposeMail(); | 141 | slotComposeMail(); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | /** | 145 | /** |
146 | * Konqueror calls us with the mailto:name@address | 146 | * Konqueror calls us with the mailto:name@address |
147 | */ | 147 | */ |
148 | void OpieMail::setDocument(const QString& mail) | 148 | void OpieMail::setDocument(const QString& mail) |
149 | { | 149 | { |
150 | /* | 150 | /* |
151 | * It looks like a mailto address, lets try it | 151 | * It looks like a mailto address, lets try it |
152 | */ | 152 | */ |
153 | if( mail.startsWith(QString::fromLatin1("mailto:")) ) | 153 | if( mail.startsWith(QString::fromLatin1("mailto:")) ) |
154 | slotwriteMail(QString::null, mail.mid(7)); | 154 | slotwriteMail(QString::null, mail.mid(7)); |
155 | } | 155 | } |
156 | 156 | ||
157 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 157 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
158 | { | 158 | { |
159 | ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); | 159 | ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); |
160 | if (!email.isEmpty()) | 160 | if (!email.isEmpty()) |
161 | { | 161 | { |
162 | if (!name.isEmpty()) | 162 | if (!name.isEmpty()) |
163 | { | 163 | { |
164 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 164 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
165 | } | 165 | } |
166 | else | 166 | else |
167 | { | 167 | { |
168 | compose.setTo(email); | 168 | compose.setTo(email); |
169 | } | 169 | } |
170 | } | 170 | } |
171 | compose.slotAdjustColumns(); | 171 | compose.slotAdjustColumns(); |
172 | QPEApplication::execDialog( &compose ); | 172 | QPEApplication::execDialog( &compose ); |
173 | } | 173 | } |
174 | 174 | ||
175 | void OpieMail::slotComposeMail() | 175 | void OpieMail::slotComposeMail() |
176 | { | 176 | { |
177 | odebug << "Compose Mail" << oendl; | 177 | odebug << "Compose Mail" << oendl; |
178 | slotwriteMail(0l,0l); | 178 | slotwriteMail(0l,0l); |
179 | } | 179 | } |
180 | 180 | ||
181 | void OpieMail::slotSendQueued() | 181 | void OpieMail::slotSendQueued() |
182 | { | 182 | { |
183 | odebug << "Send Queued" << oendl; | 183 | odebug << "Send Queued" << oendl; |
184 | SMTPaccount *smtp = 0; | 184 | SMTPaccount *smtp = 0; |
185 | 185 | ||
186 | QList<Account> list = settings->getAccounts(); | 186 | QList<Account> list = settings->getAccounts(); |
187 | QList<SMTPaccount> smtpList; | 187 | QList<SMTPaccount> smtpList; |
188 | smtpList.setAutoDelete(false); | 188 | smtpList.setAutoDelete(false); |
189 | Account *it; | 189 | Account *it; |
190 | for ( it = list.first(); it; it = list.next() ) | 190 | for ( it = list.first(); it; it = list.next() ) |
191 | { | 191 | { |
192 | if ( it->getType() == MAILLIB::A_SMTP ) | 192 | if ( it->getType() == MAILLIB::A_SMTP ) |
193 | { | 193 | { |
194 | smtp = static_cast<SMTPaccount *>(it); | 194 | smtp = static_cast<SMTPaccount *>(it); |
195 | smtpList.append(smtp); | 195 | smtpList.append(smtp); |
196 | } | 196 | } |
197 | } | 197 | } |
198 | if (smtpList.count()==0) | 198 | if (smtpList.count()==0) |
199 | { | 199 | { |
200 | QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); | 200 | QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); |
201 | return; | 201 | return; |
202 | } | 202 | } |
203 | if (smtpList.count()==1) | 203 | if (smtpList.count()==1) |
204 | { | 204 | { |
205 | smtp = smtpList.at(0); | 205 | smtp = smtpList.at(0); |
206 | } | 206 | } |
207 | else | 207 | else |
208 | { | 208 | { |
209 | smtp = 0; | 209 | smtp = 0; |
210 | selectsmtp selsmtp; | 210 | selectsmtp selsmtp; |
211 | selsmtp.setSelectionlist(&smtpList); | 211 | selsmtp.setSelectionlist(&smtpList); |
212 | if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted ) | 212 | if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted ) |
213 | { | 213 | { |
214 | smtp = selsmtp.selected_smtp(); | 214 | smtp = selsmtp.selected_smtp(); |
215 | } | 215 | } |
216 | } | 216 | } |
217 | if (smtp) | 217 | if (smtp) |
218 | { | 218 | { |
219 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 219 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
220 | if ( wrap->flushOutbox() ) | 220 | if ( wrap->flushOutbox() ) |
221 | { | 221 | { |
222 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); | 222 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); |
223 | } | 223 | } |
224 | delete wrap; | 224 | delete wrap; |
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
228 | void OpieMail::slotSearchMails() | 228 | void OpieMail::slotSearchMails() |
229 | { | 229 | { |
230 | odebug << "Search Mails" << oendl; | 230 | odebug << "Search Mails" << oendl; |
231 | } | 231 | } |
232 | 232 | ||
233 | void OpieMail::slotEditSettings() | 233 | void OpieMail::slotEditSettings() |
234 | { | 234 | { |
235 | SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); | 235 | SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); |
236 | QPEApplication::execDialog( &settingsDialog ); | 236 | QPEApplication::execDialog( &settingsDialog ); |
237 | } | 237 | } |
238 | 238 | ||
239 | void OpieMail::slotEditAccounts() | 239 | void OpieMail::slotEditAccounts() |
240 | { | 240 | { |
241 | odebug << "Edit Accounts" << oendl; | 241 | odebug << "Edit Accounts" << oendl; |
242 | EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); | 242 | EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); |
243 | eaDialog.slotAdjustColumns(); | 243 | eaDialog.slotAdjustColumns(); |
244 | if (QPEApplication::execDialog( &eaDialog )==QDialog::Rejected);// return; | 244 | if (QPEApplication::execDialog( &eaDialog )==QDialog::Rejected);// return; |
245 | 245 | ||
246 | if ( settings ) delete settings; | 246 | if ( settings ) delete settings; |
247 | settings = new Settings(); | 247 | settings = new Settings(); |
248 | mailView->clear(); | 248 | mailView->clear(); |
249 | folderView->populate( settings->getAccounts() ); | 249 | folderView->populate( settings->getAccounts() ); |
250 | } | 250 | } |
251 | 251 | ||
252 | void OpieMail::displayMail() | 252 | void OpieMail::displayMail() |
253 | { | 253 | { |
254 | QListViewItem*item = mailView->currentItem(); | 254 | QListViewItem*item = mailView->currentItem(); |
255 | if (!item) return; | 255 | if (!item) return; |
256 | RecMailP mail = ((MailListViewItem*)item)->data(); | 256 | RecMailP mail = ((MailListViewItem*)item)->data(); |
257 | RecBodyP body = folderView->fetchBody(mail); | 257 | RecBodyP body = folderView->fetchBody(mail); |
258 | ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); | 258 | ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); |
259 | readMail.setBody( body ); | 259 | readMail.setBody( body ); |
260 | readMail.setMail( mail ); | 260 | readMail.setMail( mail ); |
261 | readMail.showMaximized(); | 261 | readMail.showMaximized(); |
262 | readMail.exec(); | 262 | readMail.exec(); |
263 | 263 | ||
264 | if ( readMail.deleted ) | 264 | if ( readMail.deleted ) |
265 | { | 265 | { |
266 | folderView->refreshCurrent(); | 266 | folderView->refreshCurrent(); |
267 | } | 267 | } |
268 | else | 268 | else |
269 | { | 269 | { |
270 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); | 270 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); |
271 | } | 271 | } |
272 | } | 272 | } |
273 | 273 | ||
274 | void OpieMail::slotDeleteMail() | 274 | void OpieMail::slotDeleteMail() |
275 | { | 275 | { |
276 | if (!mailView->currentItem()) return; | 276 | if (!mailView->currentItem()) return; |
277 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 277 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
278 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 278 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
279 | { | 279 | { |
280 | mail->Wrapper()->deleteMail( mail ); | 280 | mail->Wrapper()->deleteMail( mail ); |
281 | folderView->refreshCurrent(); | 281 | folderView->refreshCurrent(); |
282 | } | 282 | } |
283 | } | 283 | } |
284 | 284 | ||
285 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | 285 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) |
286 | { | 286 | { |
287 | if (!mailView->currentItem()) return; | 287 | if (!mailView->currentItem()) return; |
288 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); | 288 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); |
289 | /* just the RIGHT button - or hold on pda */ | 289 | /* just the RIGHT button - or hold on pda */ |
290 | if (button!=2) {return;} | 290 | if (button!=2) {return;} |
291 | odebug << "Event right/hold" << oendl; | 291 | odebug << "Event right/hold" << oendl; |
292 | if (!item) return; | 292 | if (!item) return; |
293 | QPopupMenu *m = new QPopupMenu(0); | 293 | QPopupMenu *m = new QPopupMenu(0); |
294 | if (m) | 294 | if (m) |
295 | { | 295 | { |
296 | if (mailtype==MAILLIB::A_NNTP) { | 296 | if (mailtype==MAILLIB::A_NNTP) { |
297 | m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); | 297 | m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); |
298 | // m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); | 298 | // m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); |
299 | } else { | 299 | } else { |
300 | if (folderView->currentisDraft()) { | 300 | if (folderView->currentisDraft()) { |
301 | m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); | 301 | m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); |
302 | } | 302 | } |
303 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); | 303 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); |
304 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); | 304 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); |
305 | m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); | 305 | m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); |
306 | } | 306 | } |
307 | m->setFocus(); | 307 | m->setFocus(); |
308 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 308 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
309 | delete m; | 309 | delete m; |
310 | } | 310 | } |
311 | } | 311 | } |
312 | 312 | ||
313 | void OpieMail::slotShowFolders( bool show ) | 313 | void OpieMail::slotShowFolders( bool show ) |
314 | { | 314 | { |
315 | odebug << "Show Folders" << oendl; | 315 | odebug << "Show Folders" << oendl; |
316 | if ( show && folderView->isHidden() ) | 316 | if ( show && folderView->isHidden() ) |
317 | { | 317 | { |
318 | odebug << "-> showing" << oendl; | 318 | odebug << "-> showing" << oendl; |
319 | folderView->show(); | 319 | folderView->show(); |
320 | } | 320 | } |
321 | else if ( !show && !folderView->isHidden() ) | 321 | else if ( !show && !folderView->isHidden() ) |
322 | { | 322 | { |
323 | odebug << "-> hiding" << oendl; | 323 | odebug << "-> hiding" << oendl; |
324 | folderView->hide(); | 324 | folderView->hide(); |
325 | } | 325 | } |
326 | } | 326 | } |
327 | 327 | ||
328 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) | 328 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) |
329 | { | 329 | { |
330 | MailListViewItem*item = 0; | 330 | MailListViewItem*item = 0; |
331 | mailView->clear(); | 331 | mailView->clear(); |
332 | 332 | ||
333 | QValueList<RecMailP>::ConstIterator it; | 333 | QValueList<RecMailP>::ConstIterator it; |
334 | for (it = list.begin(); it != list.end();++it) | 334 | for (it = list.begin(); it != list.end();++it) |
335 | { | 335 | { |
336 | item = new MailListViewItem(mailView,item); | 336 | item = new MailListViewItem(mailView,item); |
337 | item->storeData((*it)); | 337 | item->storeData((*it)); |
338 | item->showEntry(); | 338 | item->showEntry(); |
339 | } | 339 | } |
340 | } | 340 | } |
341 | 341 | ||
342 | void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) | 342 | void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) |
343 | { | 343 | { |
344 | /* just LEFT button - or tap with stylus on pda */ | 344 | /* just LEFT button - or tap with stylus on pda */ |
345 | if (button!=1) return; | 345 | if (button!=1) return; |
346 | if (!item) return; | 346 | if (!item) return; |
347 | if (folderView->currentisDraft()) { | 347 | if (folderView->currentisDraft()) { |
348 | reEditMail(); | 348 | reEditMail(); |
349 | } else { | 349 | } else { |
350 | displayMail(); | 350 | displayMail(); |
351 | } | 351 | } |
352 | } | 352 | } |
353 | 353 | ||
354 | void OpieMail::slotMoveCopyMail() | 354 | void OpieMail::slotMoveCopyMail() |
355 | { | 355 | { |
356 | if (!mailView->currentItem()) return; | 356 | if (!mailView->currentItem()) return; |
357 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 357 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
358 | AbstractMail*targetMail = 0; | 358 | AbstractMail*targetMail = 0; |
359 | QString targetFolder = ""; | 359 | QString targetFolder = ""; |
360 | Selectstore sels; | 360 | Selectstore sels; |
361 | folderView->setupFolderselect(&sels); | 361 | folderView->setupFolderselect(&sels); |
362 | if (!sels.exec()) return; | 362 | if (!sels.exec()) return; |
363 | targetMail = sels.currentMail(); | 363 | targetMail = sels.currentMail(); |
364 | targetFolder = sels.currentFolder(); | 364 | targetFolder = sels.currentFolder(); |
365 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || | 365 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || |
366 | targetFolder.isEmpty()) | 366 | targetFolder.isEmpty()) |
367 | { | 367 | { |
368 | return; | 368 | return; |
369 | } | 369 | } |
370 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 370 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
371 | { | 371 | { |
372 | QMessageBox::critical(0,tr("Error creating new Folder"), | 372 | QMessageBox::critical(0,tr("Error creating new Folder"), |
373 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 373 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
374 | return; | 374 | return; |
375 | } | 375 | } |
376 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); | 376 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); |
377 | folderView->refreshCurrent(); | 377 | folderView->refreshCurrent(); |
378 | } | 378 | } |
379 | 379 | ||
380 | void OpieMail::reEditMail() | 380 | void OpieMail::reEditMail() |
381 | { | 381 | { |
382 | if (!mailView->currentItem()) return; | 382 | if (!mailView->currentItem()) return; |
383 | 383 | ||
384 | ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); | 384 | ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); |
385 | compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); | 385 | compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); |
386 | compose.slotAdjustColumns(); | 386 | compose.slotAdjustColumns(); |
387 | QPEApplication::execDialog( &compose ); | 387 | QPEApplication::execDialog( &compose ); |
388 | } | 388 | } |