-rw-r--r-- | kmicromail/accountitem.cpp | 14 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 4 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mhwrapper.cpp | 2 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/settings.cpp | 4 | ||||
-rw-r--r-- | kmicromail/mainwindow.cpp | 7 | ||||
-rw-r--r-- | kmicromail/mainwindow.h | 1 | ||||
-rw-r--r-- | kmicromail/opiemail.cpp | 10 | ||||
-rw-r--r-- | kmicromail/opiemail.h | 1 |
8 files changed, 28 insertions, 15 deletions
diff --git a/kmicromail/accountitem.cpp b/kmicromail/accountitem.cpp index 7b9b881..59c8abb 100644 --- a/kmicromail/accountitem.cpp +++ b/kmicromail/accountitem.cpp | |||
@@ -1,1170 +1,1172 @@ | |||
1 | 1 | ||
2 | #include "accountitem.h" | 2 | #include "accountitem.h" |
3 | #include "accountview.h" | 3 | #include "accountview.h" |
4 | #include "newmaildir.h" | 4 | #include "newmaildir.h" |
5 | #include "nntpgroupsdlg.h" | 5 | #include "nntpgroupsdlg.h" |
6 | #include "defines.h" | 6 | #include "defines.h" |
7 | 7 | ||
8 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
9 | #include <libmailwrapper/abstractmail.h> | 9 | #include <libmailwrapper/abstractmail.h> |
10 | #include <libmailwrapper/mailwrapper.h> | 10 | #include <libmailwrapper/mailwrapper.h> |
11 | /* OPIE */ | 11 | /* OPIE */ |
12 | //#include <qpe/qpeapplication.h> | 12 | //#include <qpe/qpeapplication.h> |
13 | 13 | ||
14 | /* QT */ | 14 | /* QT */ |
15 | #include <qpopupmenu.h> | 15 | #include <qpopupmenu.h> |
16 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
17 | #include <kiconloader.h> | 17 | #include <kiconloader.h> |
18 | 18 | ||
19 | #define GET_NEW_MAILS 101 | ||
20 | |||
19 | using namespace Opie::Core; | 21 | using namespace Opie::Core; |
20 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} | 22 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} |
21 | /** | 23 | /** |
22 | * POP3 Account stuff | 24 | * POP3 Account stuff |
23 | */ | 25 | */ |
24 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) | 26 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) |
25 | : AccountViewItem( parent ) | 27 | : AccountViewItem( parent ) |
26 | { | 28 | { |
27 | account = a; | 29 | account = a; |
28 | wrapper = AbstractMail::getWrapper( account ); | 30 | wrapper = AbstractMail::getWrapper( account ); |
29 | SETPIX(PIXMAP_POP3FOLDER); | 31 | SETPIX(PIXMAP_POP3FOLDER); |
30 | #if 0 | 32 | #if 0 |
31 | if (!account->getOffline()) | 33 | if (!account->getOffline()) |
32 | { | 34 | { |
33 | setPixmap( 0, ); | 35 | setPixmap( 0, ); |
34 | } | 36 | } |
35 | else | 37 | else |
36 | { | 38 | { |
37 | setPixmap( 0, PIXMAP_OFFLINE ); | 39 | setPixmap( 0, PIXMAP_OFFLINE ); |
38 | } | 40 | } |
39 | #endif | 41 | #endif |
40 | setText( 0, account->getAccountName() ); | 42 | setText( 0, account->getAccountName() ); |
41 | setOpen( true ); | 43 | setOpen( true ); |
42 | } | 44 | } |
43 | 45 | ||
44 | POP3viewItem::~POP3viewItem() | 46 | POP3viewItem::~POP3viewItem() |
45 | { | 47 | { |
46 | delete wrapper; | 48 | delete wrapper; |
47 | } | 49 | } |
48 | 50 | ||
49 | AbstractMail *POP3viewItem::getWrapper() | 51 | AbstractMail *POP3viewItem::getWrapper() |
50 | { | 52 | { |
51 | return wrapper; | 53 | return wrapper; |
52 | } | 54 | } |
53 | 55 | ||
54 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) | 56 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) |
55 | { | 57 | { |
56 | refresh(); | 58 | refresh(); |
57 | } | 59 | } |
58 | 60 | ||
59 | void POP3viewItem::refresh() | 61 | void POP3viewItem::refresh() |
60 | { | 62 | { |
61 | if (account->getOffline()) return; | 63 | if (account->getOffline()) return; |
62 | QValueList<FolderP> *folders = wrapper->listFolders(); | 64 | QValueList<FolderP> *folders = wrapper->listFolders(); |
63 | QListViewItem *child = firstChild(); | 65 | QListViewItem *child = firstChild(); |
64 | while ( child ) | 66 | while ( child ) |
65 | { | 67 | { |
66 | QListViewItem *tmp = child; | 68 | QListViewItem *tmp = child; |
67 | child = child->nextSibling(); | 69 | child = child->nextSibling(); |
68 | delete tmp; | 70 | delete tmp; |
69 | } | 71 | } |
70 | QValueList<FolderP>::ConstIterator it; | 72 | QValueList<FolderP>::ConstIterator it; |
71 | QListViewItem*item = 0; | 73 | QListViewItem*item = 0; |
72 | for ( it = folders->begin(); it!=folders->end(); ++it) | 74 | for ( it = folders->begin(); it!=folders->end(); ++it) |
73 | { | 75 | { |
74 | item = new POP3folderItem( (*it), this , item ); | 76 | item = new POP3folderItem( (*it), this , item ); |
75 | item->setSelectable( (*it)->may_select()); | 77 | item->setSelectable( (*it)->may_select()); |
76 | } | 78 | } |
77 | delete folders; | 79 | delete folders; |
78 | } | 80 | } |
79 | 81 | ||
80 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) | 82 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) |
81 | { | 83 | { |
82 | 84 | ||
83 | return wrapper->fetchBody( mail ); | 85 | return wrapper->fetchBody( mail ); |
84 | } | 86 | } |
85 | 87 | ||
86 | QPopupMenu * POP3viewItem::getContextMenu() | 88 | QPopupMenu * POP3viewItem::getContextMenu() |
87 | { | 89 | { |
88 | QPopupMenu *m = new QPopupMenu(0); | 90 | QPopupMenu *m = new QPopupMenu(0); |
89 | if (m) | 91 | if (m) |
90 | { | 92 | { |
91 | if (!account->getOffline()) | 93 | if (!account->getOffline()) |
92 | { | 94 | { |
93 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 95 | m->insertItem(QObject::tr("Disconnect",contextName),0); |
94 | m->insertItem(QObject::tr("Set offline",contextName),1); | 96 | m->insertItem(QObject::tr("Set offline",contextName),1); |
95 | m->insertItem(QObject::tr("Download new INBOX messages",contextName),2); | 97 | m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); |
96 | } | 98 | } |
97 | else | 99 | else |
98 | { | 100 | { |
99 | m->insertItem(QObject::tr("Set online",contextName),1); | 101 | m->insertItem(QObject::tr("Set online",contextName),1); |
100 | m->insertItem(QObject::tr("Download new INBOX messages",contextName),2); | 102 | m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); |
101 | } | 103 | } |
102 | } | 104 | } |
103 | return m; | 105 | return m; |
104 | } | 106 | } |
105 | 107 | ||
106 | void POP3viewItem::disconnect() | 108 | void POP3viewItem::disconnect() |
107 | { | 109 | { |
108 | QListViewItem *child = firstChild(); | 110 | QListViewItem *child = firstChild(); |
109 | while ( child ) | 111 | while ( child ) |
110 | { | 112 | { |
111 | QListViewItem *tmp = child; | 113 | QListViewItem *tmp = child; |
112 | child = child->nextSibling(); | 114 | child = child->nextSibling(); |
113 | delete tmp; | 115 | delete tmp; |
114 | } | 116 | } |
115 | wrapper->logout(); | 117 | wrapper->logout(); |
116 | } | 118 | } |
117 | 119 | ||
118 | void POP3viewItem::setOnOffline() | 120 | void POP3viewItem::setOnOffline() |
119 | { | 121 | { |
120 | if (!account->getOffline()) | 122 | if (!account->getOffline()) |
121 | { | 123 | { |
122 | disconnect(); | 124 | disconnect(); |
123 | } | 125 | } |
124 | account->setOffline(!account->getOffline()); | 126 | account->setOffline(!account->getOffline()); |
125 | account->save(); | 127 | account->save(); |
126 | SETPIX(PIXMAP_POP3FOLDER); | 128 | SETPIX(PIXMAP_POP3FOLDER); |
127 | refresh(); | 129 | refresh(); |
128 | } | 130 | } |
129 | 131 | ||
130 | void POP3viewItem::contextMenuSelected(int which) | 132 | void POP3viewItem::contextMenuSelected(int which) |
131 | { | 133 | { |
132 | switch (which) | 134 | switch (which) |
133 | { | 135 | { |
134 | case 0: | 136 | case 0: |
135 | disconnect(); | 137 | disconnect(); |
136 | break; | 138 | break; |
137 | case 1: | 139 | case 1: |
138 | setOnOffline(); | 140 | setOnOffline(); |
139 | break; | 141 | break; |
140 | case 2: // daunlood | 142 | case GET_NEW_MAILS: // daunlood |
141 | if (account->getOffline()) | 143 | if (account->getOffline()) |
142 | setOnOffline(); | 144 | setOnOffline(); |
143 | AccountView*bl = accountView(); | 145 | AccountView*bl = accountView(); |
144 | if (!bl) return; | 146 | if (!bl) return; |
145 | AccountViewItem* in = findSubItem( "inbox" , 0); | 147 | AccountViewItem* in = findSubItem( "inbox" , 0); |
146 | if ( ! in ) | 148 | if ( ! in ) |
147 | return; | 149 | return; |
148 | bl->downloadMailsInbox(in->getFolder() ,getWrapper()); | 150 | bl->downloadMailsInbox(in->getFolder() ,getWrapper()); |
149 | setOnOffline(); | 151 | setOnOffline(); |
150 | break; | 152 | break; |
151 | } | 153 | } |
152 | } | 154 | } |
153 | 155 | ||
154 | POP3folderItem::~POP3folderItem() | 156 | POP3folderItem::~POP3folderItem() |
155 | {} | 157 | {} |
156 | 158 | ||
157 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) | 159 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) |
158 | : AccountViewItem(folderInit,parent,after ) | 160 | : AccountViewItem(folderInit,parent,after ) |
159 | { | 161 | { |
160 | pop3 = parent; | 162 | pop3 = parent; |
161 | if (folder->getDisplayName().lower()!="inbox") | 163 | if (folder->getDisplayName().lower()!="inbox") |
162 | { | 164 | { |
163 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 165 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
164 | } | 166 | } |
165 | else | 167 | else |
166 | { | 168 | { |
167 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 169 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
168 | } | 170 | } |
169 | setText( 0, folder->getDisplayName() ); | 171 | setText( 0, folder->getDisplayName() ); |
170 | } | 172 | } |
171 | 173 | ||
172 | void POP3folderItem::refresh(QValueList<RecMailP>&target) | 174 | void POP3folderItem::refresh(QValueList<RecMailP>&target) |
173 | { | 175 | { |
174 | if (folder->may_select()) | 176 | if (folder->may_select()) |
175 | pop3->getWrapper()->listMessages( folder->getName(),target ); | 177 | pop3->getWrapper()->listMessages( folder->getName(),target ); |
176 | } | 178 | } |
177 | 179 | ||
178 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) | 180 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) |
179 | { | 181 | { |
180 | return pop3->getWrapper()->fetchBody(aMail); | 182 | return pop3->getWrapper()->fetchBody(aMail); |
181 | } | 183 | } |
182 | 184 | ||
183 | QPopupMenu * POP3folderItem::getContextMenu() | 185 | QPopupMenu * POP3folderItem::getContextMenu() |
184 | { | 186 | { |
185 | QPopupMenu *m = new QPopupMenu(0); | 187 | QPopupMenu *m = new QPopupMenu(0); |
186 | if (m) | 188 | if (m) |
187 | { | 189 | { |
188 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 190 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
189 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 191 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
190 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | 192 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); |
191 | } | 193 | } |
192 | return m; | 194 | return m; |
193 | } | 195 | } |
194 | 196 | ||
195 | void POP3folderItem::downloadMails() | 197 | void POP3folderItem::downloadMails() |
196 | { | 198 | { |
197 | AccountView*bl = pop3->accountView(); | 199 | AccountView*bl = pop3->accountView(); |
198 | if (!bl) return; | 200 | if (!bl) return; |
199 | bl->downloadMails(folder,pop3->getWrapper()); | 201 | bl->downloadMails(folder,pop3->getWrapper()); |
200 | } | 202 | } |
201 | 203 | ||
202 | void POP3folderItem::contextMenuSelected(int which) | 204 | void POP3folderItem::contextMenuSelected(int which) |
203 | { | 205 | { |
204 | AccountView * view = (AccountView*)listView(); | 206 | AccountView * view = (AccountView*)listView(); |
205 | switch (which) | 207 | switch (which) |
206 | { | 208 | { |
207 | case 0: | 209 | case 0: |
208 | /* must be 'cause pop3 lists are cached */ | 210 | /* must be 'cause pop3 lists are cached */ |
209 | pop3->getWrapper()->logout(); | 211 | pop3->getWrapper()->logout(); |
210 | view->refreshCurrent(); | 212 | view->refreshCurrent(); |
211 | break; | 213 | break; |
212 | case 1: | 214 | case 1: |
213 | deleteAllMail(pop3->getWrapper(),folder); | 215 | deleteAllMail(pop3->getWrapper(),folder); |
214 | break; | 216 | break; |
215 | case 2: | 217 | case 2: |
216 | downloadMails(); | 218 | downloadMails(); |
217 | break; | 219 | break; |
218 | default: | 220 | default: |
219 | break; | 221 | break; |
220 | } | 222 | } |
221 | } | 223 | } |
222 | 224 | ||
223 | /** | 225 | /** |
224 | * NNTP Account stuff | 226 | * NNTP Account stuff |
225 | */ | 227 | */ |
226 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) | 228 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) |
227 | : AccountViewItem( parent ) | 229 | : AccountViewItem( parent ) |
228 | { | 230 | { |
229 | account = a; | 231 | account = a; |
230 | wrapper = AbstractMail::getWrapper( account ); | 232 | wrapper = AbstractMail::getWrapper( account ); |
231 | //FIXME | 233 | //FIXME |
232 | SETPIX(PIXMAP_POP3FOLDER); | 234 | SETPIX(PIXMAP_POP3FOLDER); |
233 | #if 0 | 235 | #if 0 |
234 | if (!account->getOffline()) | 236 | if (!account->getOffline()) |
235 | { | 237 | { |
236 | setPixmap( 0, ); | 238 | setPixmap( 0, ); |
237 | } | 239 | } |
238 | else | 240 | else |
239 | { | 241 | { |
240 | setPixmap( 0, PIXMAP_OFFLINE ); | 242 | setPixmap( 0, PIXMAP_OFFLINE ); |
241 | } | 243 | } |
242 | #endif | 244 | #endif |
243 | setText( 0, account->getAccountName() ); | 245 | setText( 0, account->getAccountName() ); |
244 | setOpen( true ); | 246 | setOpen( true ); |
245 | } | 247 | } |
246 | 248 | ||
247 | NNTPviewItem::~NNTPviewItem() | 249 | NNTPviewItem::~NNTPviewItem() |
248 | { | 250 | { |
249 | delete wrapper; | 251 | delete wrapper; |
250 | } | 252 | } |
251 | 253 | ||
252 | AbstractMail *NNTPviewItem::getWrapper() | 254 | AbstractMail *NNTPviewItem::getWrapper() |
253 | { | 255 | { |
254 | return wrapper; | 256 | return wrapper; |
255 | } | 257 | } |
256 | 258 | ||
257 | void NNTPviewItem::refresh( QValueList<RecMailP> & ) | 259 | void NNTPviewItem::refresh( QValueList<RecMailP> & ) |
258 | { | 260 | { |
259 | refresh(); | 261 | refresh(); |
260 | } | 262 | } |
261 | 263 | ||
262 | void NNTPviewItem::refresh() | 264 | void NNTPviewItem::refresh() |
263 | { | 265 | { |
264 | if (account->getOffline()) return; | 266 | if (account->getOffline()) return; |
265 | QValueList<FolderP> *folders = wrapper->listFolders(); | 267 | QValueList<FolderP> *folders = wrapper->listFolders(); |
266 | 268 | ||
267 | QListViewItem *child = firstChild(); | 269 | QListViewItem *child = firstChild(); |
268 | while ( child ) | 270 | while ( child ) |
269 | { | 271 | { |
270 | QListViewItem *tmp = child; | 272 | QListViewItem *tmp = child; |
271 | child = child->nextSibling(); | 273 | child = child->nextSibling(); |
272 | delete tmp; | 274 | delete tmp; |
273 | } | 275 | } |
274 | QValueList<FolderP>::ConstIterator it; | 276 | QValueList<FolderP>::ConstIterator it; |
275 | QListViewItem*item = 0; | 277 | QListViewItem*item = 0; |
276 | for ( it = folders->begin(); it!=folders->end(); ++it) | 278 | for ( it = folders->begin(); it!=folders->end(); ++it) |
277 | { | 279 | { |
278 | item = new NNTPfolderItem( (*it), this , item ); | 280 | item = new NNTPfolderItem( (*it), this , item ); |
279 | item->setSelectable( (*it)->may_select()); | 281 | item->setSelectable( (*it)->may_select()); |
280 | } | 282 | } |
281 | delete folders; | 283 | delete folders; |
282 | } | 284 | } |
283 | 285 | ||
284 | RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) | 286 | RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) |
285 | { | 287 | { |
286 | 288 | ||
287 | return wrapper->fetchBody( mail ); | 289 | return wrapper->fetchBody( mail ); |
288 | } | 290 | } |
289 | 291 | ||
290 | QPopupMenu * NNTPviewItem::getContextMenu() | 292 | QPopupMenu * NNTPviewItem::getContextMenu() |
291 | { | 293 | { |
292 | QPopupMenu *m = new QPopupMenu(0); | 294 | QPopupMenu *m = new QPopupMenu(0); |
293 | if (m) | 295 | if (m) |
294 | { | 296 | { |
295 | if (!account->getOffline()) | 297 | if (!account->getOffline()) |
296 | { | 298 | { |
297 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 299 | m->insertItem(QObject::tr("Disconnect",contextName),0); |
298 | m->insertItem(QObject::tr("Set offline",contextName),1); | 300 | m->insertItem(QObject::tr("Set offline",contextName),1); |
299 | m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2); | 301 | m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2); |
300 | } | 302 | } |
301 | else | 303 | else |
302 | { | 304 | { |
303 | m->insertItem(QObject::tr("Set online",contextName),1); | 305 | m->insertItem(QObject::tr("Set online",contextName),1); |
304 | } | 306 | } |
305 | } | 307 | } |
306 | return m; | 308 | return m; |
307 | } | 309 | } |
308 | 310 | ||
309 | void NNTPviewItem::subscribeGroups() | 311 | void NNTPviewItem::subscribeGroups() |
310 | { | 312 | { |
311 | NNTPGroupsDlg dlg(account); | 313 | NNTPGroupsDlg dlg(account); |
312 | dlg.showMaximized(); | 314 | dlg.showMaximized(); |
313 | if ( dlg.exec()== QDialog::Accepted ){ | 315 | if ( dlg.exec()== QDialog::Accepted ){ |
314 | refresh(); | 316 | refresh(); |
315 | } | 317 | } |
316 | } | 318 | } |
317 | 319 | ||
318 | void NNTPviewItem::disconnect() | 320 | void NNTPviewItem::disconnect() |
319 | { | 321 | { |
320 | QListViewItem *child = firstChild(); | 322 | QListViewItem *child = firstChild(); |
321 | while ( child ) | 323 | while ( child ) |
322 | { | 324 | { |
323 | QListViewItem *tmp = child; | 325 | QListViewItem *tmp = child; |
324 | child = child->nextSibling(); | 326 | child = child->nextSibling(); |
325 | delete tmp; | 327 | delete tmp; |
326 | } | 328 | } |
327 | wrapper->logout(); | 329 | wrapper->logout(); |
328 | } | 330 | } |
329 | 331 | ||
330 | void NNTPviewItem::setOnOffline() | 332 | void NNTPviewItem::setOnOffline() |
331 | { | 333 | { |
332 | if (!account->getOffline()) | 334 | if (!account->getOffline()) |
333 | { | 335 | { |
334 | disconnect(); | 336 | disconnect(); |
335 | } | 337 | } |
336 | account->setOffline(!account->getOffline()); | 338 | account->setOffline(!account->getOffline()); |
337 | account->save(); | 339 | account->save(); |
338 | //FIXME | 340 | //FIXME |
339 | SETPIX(PIXMAP_POP3FOLDER); | 341 | SETPIX(PIXMAP_POP3FOLDER); |
340 | refresh(); | 342 | refresh(); |
341 | } | 343 | } |
342 | 344 | ||
343 | void NNTPviewItem::contextMenuSelected(int which) | 345 | void NNTPviewItem::contextMenuSelected(int which) |
344 | { | 346 | { |
345 | switch (which) | 347 | switch (which) |
346 | { | 348 | { |
347 | case 0: | 349 | case 0: |
348 | disconnect(); | 350 | disconnect(); |
349 | break; | 351 | break; |
350 | case 1: | 352 | case 1: |
351 | setOnOffline(); | 353 | setOnOffline(); |
352 | break; | 354 | break; |
353 | case 2: | 355 | case 2: |
354 | subscribeGroups(); | 356 | subscribeGroups(); |
355 | break; | 357 | break; |
356 | } | 358 | } |
357 | } | 359 | } |
358 | 360 | ||
359 | NNTPfolderItem::~NNTPfolderItem() | 361 | NNTPfolderItem::~NNTPfolderItem() |
360 | {} | 362 | {} |
361 | 363 | ||
362 | NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) | 364 | NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) |
363 | : AccountViewItem( folderInit, parent,after ) | 365 | : AccountViewItem( folderInit, parent,after ) |
364 | { | 366 | { |
365 | nntp = parent; | 367 | nntp = parent; |
366 | if (folder->getDisplayName().lower()!="inbox") | 368 | if (folder->getDisplayName().lower()!="inbox") |
367 | { | 369 | { |
368 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 370 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
369 | } | 371 | } |
370 | else | 372 | else |
371 | { | 373 | { |
372 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 374 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
373 | } | 375 | } |
374 | setText( 0, folder->getDisplayName() ); | 376 | setText( 0, folder->getDisplayName() ); |
375 | } | 377 | } |
376 | 378 | ||
377 | void NNTPfolderItem::refresh(QValueList<RecMailP>&target) | 379 | void NNTPfolderItem::refresh(QValueList<RecMailP>&target) |
378 | { | 380 | { |
379 | if (folder->may_select()) | 381 | if (folder->may_select()) |
380 | nntp->getWrapper()->listMessages( folder->getName(),target ); | 382 | nntp->getWrapper()->listMessages( folder->getName(),target ); |
381 | } | 383 | } |
382 | 384 | ||
383 | RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) | 385 | RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) |
384 | { | 386 | { |
385 | return nntp->getWrapper()->fetchBody(aMail); | 387 | return nntp->getWrapper()->fetchBody(aMail); |
386 | } | 388 | } |
387 | 389 | ||
388 | QPopupMenu * NNTPfolderItem::getContextMenu() | 390 | QPopupMenu * NNTPfolderItem::getContextMenu() |
389 | { | 391 | { |
390 | QPopupMenu *m = new QPopupMenu(0); | 392 | QPopupMenu *m = new QPopupMenu(0); |
391 | if (m) | 393 | if (m) |
392 | { | 394 | { |
393 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 395 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
394 | m->insertItem(QObject::tr("Copy all postings",contextName),1); | 396 | m->insertItem(QObject::tr("Copy all postings",contextName),1); |
395 | } | 397 | } |
396 | return m; | 398 | return m; |
397 | } | 399 | } |
398 | 400 | ||
399 | void NNTPfolderItem::downloadMails() | 401 | void NNTPfolderItem::downloadMails() |
400 | { | 402 | { |
401 | AccountView*bl = nntp->accountView(); | 403 | AccountView*bl = nntp->accountView(); |
402 | if (!bl) return; | 404 | if (!bl) return; |
403 | bl->downloadMails(folder,nntp->getWrapper()); | 405 | bl->downloadMails(folder,nntp->getWrapper()); |
404 | } | 406 | } |
405 | 407 | ||
406 | void NNTPfolderItem::contextMenuSelected(int which) | 408 | void NNTPfolderItem::contextMenuSelected(int which) |
407 | { | 409 | { |
408 | AccountView * view = (AccountView*)listView(); | 410 | AccountView * view = (AccountView*)listView(); |
409 | switch (which) | 411 | switch (which) |
410 | { | 412 | { |
411 | case 0: | 413 | case 0: |
412 | /* must be 'cause pop3 lists are cached */ | 414 | /* must be 'cause pop3 lists are cached */ |
413 | nntp->getWrapper()->logout(); | 415 | nntp->getWrapper()->logout(); |
414 | view->refreshCurrent(); | 416 | view->refreshCurrent(); |
415 | break; | 417 | break; |
416 | case 1: | 418 | case 1: |
417 | downloadMails(); | 419 | downloadMails(); |
418 | break; | 420 | break; |
419 | default: | 421 | default: |
420 | break; | 422 | break; |
421 | } | 423 | } |
422 | } | 424 | } |
423 | 425 | ||
424 | /** | 426 | /** |
425 | * IMAP Account stuff | 427 | * IMAP Account stuff |
426 | */ | 428 | */ |
427 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) | 429 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) |
428 | : AccountViewItem( parent ) | 430 | : AccountViewItem( parent ) |
429 | { | 431 | { |
430 | account = a; | 432 | account = a; |
431 | wrapper = AbstractMail::getWrapper( account ); | 433 | wrapper = AbstractMail::getWrapper( account ); |
432 | SETPIX(PIXMAP_IMAPFOLDER); | 434 | SETPIX(PIXMAP_IMAPFOLDER); |
433 | setText( 0, account->getAccountName() ); | 435 | setText( 0, account->getAccountName() ); |
434 | setOpen( true ); | 436 | setOpen( true ); |
435 | } | 437 | } |
436 | 438 | ||
437 | IMAPviewItem::~IMAPviewItem() | 439 | IMAPviewItem::~IMAPviewItem() |
438 | { | 440 | { |
439 | delete wrapper; | 441 | delete wrapper; |
440 | } | 442 | } |
441 | 443 | ||
442 | AbstractMail *IMAPviewItem::getWrapper() | 444 | AbstractMail *IMAPviewItem::getWrapper() |
443 | { | 445 | { |
444 | return wrapper; | 446 | return wrapper; |
445 | } | 447 | } |
446 | 448 | ||
447 | void IMAPviewItem::refresh(QValueList<RecMailP>&) | 449 | void IMAPviewItem::refresh(QValueList<RecMailP>&) |
448 | { | 450 | { |
449 | refreshFolders(false); | 451 | refreshFolders(false); |
450 | } | 452 | } |
451 | 453 | ||
452 | const QStringList&IMAPviewItem::subFolders() | 454 | const QStringList&IMAPviewItem::subFolders() |
453 | { | 455 | { |
454 | return currentFolders; | 456 | return currentFolders; |
455 | } | 457 | } |
456 | 458 | ||
457 | void IMAPviewItem::refreshFolders(bool force) | 459 | void IMAPviewItem::refreshFolders(bool force) |
458 | { | 460 | { |
459 | if (childCount()>0 && force==false) return; | 461 | if (childCount()>0 && force==false) return; |
460 | if (account->getOffline()) return; | 462 | if (account->getOffline()) return; |
461 | 463 | ||
462 | removeChilds(); | 464 | removeChilds(); |
463 | currentFolders.clear(); | 465 | currentFolders.clear(); |
464 | QValueList<FolderP> * folders = wrapper->listFolders(); | 466 | QValueList<FolderP> * folders = wrapper->listFolders(); |
465 | 467 | ||
466 | QValueList<FolderP>::Iterator it; | 468 | QValueList<FolderP>::Iterator it; |
467 | QListViewItem*item = 0; | 469 | QListViewItem*item = 0; |
468 | QListViewItem*titem = 0; | 470 | QListViewItem*titem = 0; |
469 | QString fname,del,search; | 471 | QString fname,del,search; |
470 | int pos; | 472 | int pos; |
471 | 473 | ||
472 | for ( it = folders->begin(); it!=folders->end(); ++it) | 474 | for ( it = folders->begin(); it!=folders->end(); ++it) |
473 | { | 475 | { |
474 | if ((*it)->getDisplayName().lower()=="inbox") | 476 | if ((*it)->getDisplayName().lower()=="inbox") |
475 | { | 477 | { |
476 | item = new IMAPfolderItem( (*it), this , item ); | 478 | item = new IMAPfolderItem( (*it), this , item ); |
477 | folders->remove(it); | 479 | folders->remove(it); |
478 | break; | 480 | break; |
479 | } | 481 | } |
480 | } | 482 | } |
481 | for ( it = folders->begin(); it!=folders->end(); ++it) | 483 | for ( it = folders->begin(); it!=folders->end(); ++it) |
482 | { | 484 | { |
483 | fname = (*it)->getDisplayName(); | 485 | fname = (*it)->getDisplayName(); |
484 | currentFolders.append((*it)->getName()); | 486 | currentFolders.append((*it)->getName()); |
485 | pos = fname.findRev((*it)->Separator()); | 487 | pos = fname.findRev((*it)->Separator()); |
486 | if (pos != -1) | 488 | if (pos != -1) |
487 | { | 489 | { |
488 | fname = fname.left(pos); | 490 | fname = fname.left(pos); |
489 | } | 491 | } |
490 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); | 492 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); |
491 | if (pitem) | 493 | if (pitem) |
492 | { | 494 | { |
493 | titem = item; | 495 | titem = item; |
494 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); | 496 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); |
495 | /* setup the short name */ | 497 | /* setup the short name */ |
496 | item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); | 498 | item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); |
497 | item = titem; | 499 | item = titem; |
498 | } | 500 | } |
499 | else | 501 | else |
500 | { | 502 | { |
501 | item = new IMAPfolderItem( (*it), this , item ); | 503 | item = new IMAPfolderItem( (*it), this , item ); |
502 | } | 504 | } |
503 | } | 505 | } |
504 | delete folders; | 506 | delete folders; |
505 | } | 507 | } |
506 | 508 | ||
507 | QPopupMenu * IMAPviewItem::getContextMenu() | 509 | QPopupMenu * IMAPviewItem::getContextMenu() |
508 | { | 510 | { |
509 | QPopupMenu *m = new QPopupMenu(0); | 511 | QPopupMenu *m = new QPopupMenu(0); |
510 | if (m) | 512 | if (m) |
511 | { | 513 | { |
512 | if (!account->getOffline()) | 514 | if (!account->getOffline()) |
513 | { | 515 | { |
514 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 516 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); |
515 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 517 | m->insertItem(QObject::tr("Create new folder",contextName),1); |
516 | m->insertSeparator(); | 518 | m->insertSeparator(); |
517 | m->insertItem(QObject::tr("Disconnect",contextName),2); | 519 | m->insertItem(QObject::tr("Disconnect",contextName),2); |
518 | m->insertItem(QObject::tr("Set offline",contextName),3); | 520 | m->insertItem(QObject::tr("Set offline",contextName),3); |
519 | m->insertSeparator(); | 521 | m->insertSeparator(); |
520 | m->insertItem(QObject::tr("Download new INBOX messages",contextName),4); | 522 | m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); |
521 | } | 523 | } |
522 | else | 524 | else |
523 | { | 525 | { |
524 | m->insertItem(QObject::tr("Set online",contextName),3); | 526 | m->insertItem(QObject::tr("Set online",contextName),3); |
525 | m->insertSeparator(); | 527 | m->insertSeparator(); |
526 | m->insertItem(QObject::tr("Download new INBOX messages",contextName),4); | 528 | m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); |
527 | } | 529 | } |
528 | } | 530 | } |
529 | return m; | 531 | return m; |
530 | } | 532 | } |
531 | 533 | ||
532 | void IMAPviewItem::createNewFolder() | 534 | void IMAPviewItem::createNewFolder() |
533 | { | 535 | { |
534 | Newmdirdlg ndirdlg; | 536 | Newmdirdlg ndirdlg; |
535 | 537 | ||
536 | ndirdlg.showMaximized(); | 538 | ndirdlg.showMaximized(); |
537 | if ( ndirdlg.exec() ) | 539 | if ( ndirdlg.exec() ) |
538 | { | 540 | { |
539 | QString ndir = ndirdlg.Newdir(); | 541 | QString ndir = ndirdlg.Newdir(); |
540 | bool makesubs = ndirdlg.subpossible(); | 542 | bool makesubs = ndirdlg.subpossible(); |
541 | QString delemiter = "/"; | 543 | QString delemiter = "/"; |
542 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); | 544 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); |
543 | if (item) | 545 | if (item) |
544 | { | 546 | { |
545 | delemiter = item->Delemiter(); | 547 | delemiter = item->Delemiter(); |
546 | } | 548 | } |
547 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) | 549 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) |
548 | { | 550 | { |
549 | refreshFolders(true); | 551 | refreshFolders(true); |
550 | } | 552 | } |
551 | } | 553 | } |
552 | } | 554 | } |
553 | 555 | ||
554 | void IMAPviewItem::contextMenuSelected(int id) | 556 | void IMAPviewItem::contextMenuSelected(int id) |
555 | { | 557 | { |
556 | 558 | ||
557 | switch (id) | 559 | switch (id) |
558 | { | 560 | { |
559 | case 0: | 561 | case 0: |
560 | refreshFolders(true); | 562 | refreshFolders(true); |
561 | break; | 563 | break; |
562 | case 1: | 564 | case 1: |
563 | createNewFolder(); | 565 | createNewFolder(); |
564 | break; | 566 | break; |
565 | case 2: | 567 | case 2: |
566 | removeChilds(); | 568 | removeChilds(); |
567 | wrapper->logout(); | 569 | wrapper->logout(); |
568 | break; | 570 | break; |
569 | case 3: | 571 | case 3: |
570 | if (account->getOffline()==false) | 572 | if (account->getOffline()==false) |
571 | { | 573 | { |
572 | removeChilds(); | 574 | removeChilds(); |
573 | wrapper->logout(); | 575 | wrapper->logout(); |
574 | } | 576 | } |
575 | account->setOffline(!account->getOffline()); | 577 | account->setOffline(!account->getOffline()); |
576 | account->save(); | 578 | account->save(); |
577 | SETPIX(PIXMAP_IMAPFOLDER); | 579 | SETPIX(PIXMAP_IMAPFOLDER); |
578 | refreshFolders(false); | 580 | refreshFolders(false); |
579 | break; | 581 | break; |
580 | case 4: // daunlood | 582 | case GET_NEW_MAILS: // daunlood |
581 | { | 583 | { |
582 | if (account->getOffline()) { | 584 | if (account->getOffline()) { |
583 | contextMenuSelected( 3 ); | 585 | contextMenuSelected( 3 ); |
584 | } | 586 | } |
585 | AccountView*bl = accountView(); | 587 | AccountView*bl = accountView(); |
586 | if (!bl) return; | 588 | if (!bl) return; |
587 | AccountViewItem* in = findSubItem( "inbox" , 0); | 589 | AccountViewItem* in = findSubItem( "inbox" , 0); |
588 | if ( ! in ) | 590 | if ( ! in ) |
589 | return; | 591 | return; |
590 | bl->downloadMailsInbox(in->getFolder(),getWrapper()); | 592 | bl->downloadMailsInbox(in->getFolder(),getWrapper()); |
591 | } | 593 | } |
592 | break; | 594 | break; |
593 | default: | 595 | default: |
594 | break; | 596 | break; |
595 | } | 597 | } |
596 | } | 598 | } |
597 | 599 | ||
598 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) | 600 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) |
599 | { | 601 | { |
600 | return new RecBody(); | 602 | return new RecBody(); |
601 | } | 603 | } |
602 | 604 | ||
603 | bool IMAPviewItem::offline() | 605 | bool IMAPviewItem::offline() |
604 | { | 606 | { |
605 | return account->getOffline(); | 607 | return account->getOffline(); |
606 | } | 608 | } |
607 | 609 | ||
608 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) | 610 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) |
609 | : AccountViewItem( folderInit, parent , after ) | 611 | : AccountViewItem( folderInit, parent , after ) |
610 | { | 612 | { |
611 | imap = parent; | 613 | imap = parent; |
612 | if (folder->getDisplayName().lower()!="inbox") | 614 | if (folder->getDisplayName().lower()!="inbox") |
613 | { | 615 | { |
614 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 616 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
615 | } | 617 | } |
616 | else | 618 | else |
617 | { | 619 | { |
618 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 620 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
619 | } | 621 | } |
620 | setText( 0, folder->getDisplayName() ); | 622 | setText( 0, folder->getDisplayName() ); |
621 | } | 623 | } |
622 | 624 | ||
623 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) | 625 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) |
624 | : AccountViewItem(folderInit, parent,after ) | 626 | : AccountViewItem(folderInit, parent,after ) |
625 | { | 627 | { |
626 | imap = master; | 628 | imap = master; |
627 | if (folder->getDisplayName().lower()!="inbox") | 629 | if (folder->getDisplayName().lower()!="inbox") |
628 | { | 630 | { |
629 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 631 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
630 | } | 632 | } |
631 | else | 633 | else |
632 | { | 634 | { |
633 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 635 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
634 | } | 636 | } |
635 | setText( 0, folder->getDisplayName() ); | 637 | setText( 0, folder->getDisplayName() ); |
636 | } | 638 | } |
637 | 639 | ||
638 | IMAPfolderItem::~IMAPfolderItem() | 640 | IMAPfolderItem::~IMAPfolderItem() |
639 | {} | 641 | {} |
640 | 642 | ||
641 | const QString& IMAPfolderItem::Delemiter()const | 643 | const QString& IMAPfolderItem::Delemiter()const |
642 | { | 644 | { |
643 | return folder->Separator(); | 645 | return folder->Separator(); |
644 | } | 646 | } |
645 | 647 | ||
646 | void IMAPfolderItem::refresh(QValueList<RecMailP>&target) | 648 | void IMAPfolderItem::refresh(QValueList<RecMailP>&target) |
647 | { | 649 | { |
648 | if (folder->may_select()) | 650 | if (folder->may_select()) |
649 | { | 651 | { |
650 | imap->getWrapper()->listMessages( folder->getName(),target ); | 652 | imap->getWrapper()->listMessages( folder->getName(),target ); |
651 | } | 653 | } |
652 | else | 654 | else |
653 | { | 655 | { |
654 | target.clear(); | 656 | target.clear(); |
655 | } | 657 | } |
656 | } | 658 | } |
657 | 659 | ||
658 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) | 660 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) |
659 | { | 661 | { |
660 | return imap->getWrapper()->fetchBody(aMail); | 662 | return imap->getWrapper()->fetchBody(aMail); |
661 | } | 663 | } |
662 | 664 | ||
663 | QPopupMenu * IMAPfolderItem::getContextMenu() | 665 | QPopupMenu * IMAPfolderItem::getContextMenu() |
664 | { | 666 | { |
665 | QPopupMenu *m = new QPopupMenu(0); | 667 | QPopupMenu *m = new QPopupMenu(0); |
666 | if (m) | 668 | if (m) |
667 | { | 669 | { |
668 | if (folder->may_select()) | 670 | if (folder->may_select()) |
669 | { | 671 | { |
670 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 672 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
671 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); | 673 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); |
672 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 674 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
673 | } | 675 | } |
674 | if (folder->no_inferior()==false) | 676 | if (folder->no_inferior()==false) |
675 | { | 677 | { |
676 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); | 678 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); |
677 | } | 679 | } |
678 | if (folder->getDisplayName().lower()!="inbox") | 680 | if (folder->getDisplayName().lower()!="inbox") |
679 | { | 681 | { |
680 | m->insertItem(QObject::tr("Delete folder",contextName),3); | 682 | m->insertItem(QObject::tr("Delete folder",contextName),3); |
681 | } | 683 | } |
682 | } | 684 | } |
683 | return m; | 685 | return m; |
684 | } | 686 | } |
685 | 687 | ||
686 | void IMAPfolderItem::createNewFolder() | 688 | void IMAPfolderItem::createNewFolder() |
687 | { | 689 | { |
688 | Newmdirdlg ndirdlg; | 690 | Newmdirdlg ndirdlg; |
689 | ndirdlg.showMaximized(); | 691 | ndirdlg.showMaximized(); |
690 | if ( ndirdlg.exec() ) | 692 | if ( ndirdlg.exec() ) |
691 | { | 693 | { |
692 | QString ndir = ndirdlg.Newdir(); | 694 | QString ndir = ndirdlg.Newdir(); |
693 | bool makesubs = ndirdlg.subpossible(); | 695 | bool makesubs = ndirdlg.subpossible(); |
694 | QString delemiter = Delemiter(); | 696 | QString delemiter = Delemiter(); |
695 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) | 697 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) |
696 | { | 698 | { |
697 | imap->refreshFolders(true); | 699 | imap->refreshFolders(true); |
698 | } | 700 | } |
699 | } | 701 | } |
700 | } | 702 | } |
701 | 703 | ||
702 | void IMAPfolderItem::deleteFolder() | 704 | void IMAPfolderItem::deleteFolder() |
703 | { | 705 | { |
704 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | 706 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), |
705 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | 707 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), |
706 | QObject::tr("Yes",contextName), | 708 | QObject::tr("Yes",contextName), |
707 | QObject::tr("No",contextName),QString::null,1,1); | 709 | QObject::tr("No",contextName),QString::null,1,1); |
708 | 710 | ||
709 | if (yesno == 0) | 711 | if (yesno == 0) |
710 | { | 712 | { |
711 | if (imap->getWrapper()->deleteMbox(folder)) | 713 | if (imap->getWrapper()->deleteMbox(folder)) |
712 | { | 714 | { |
713 | QListView*v=listView(); | 715 | QListView*v=listView(); |
714 | IMAPviewItem * box = imap; | 716 | IMAPviewItem * box = imap; |
715 | /* be carefull - after that this object is destroyd so don't use | 717 | /* be carefull - after that this object is destroyd so don't use |
716 | * any member of it after that call!!*/ | 718 | * any member of it after that call!!*/ |
717 | imap->refreshFolders(true); | 719 | imap->refreshFolders(true); |
718 | if (v) | 720 | if (v) |
719 | { | 721 | { |
720 | v->setSelected(box,true); | 722 | v->setSelected(box,true); |
721 | } | 723 | } |
722 | } | 724 | } |
723 | } | 725 | } |
724 | } | 726 | } |
725 | 727 | ||
726 | void IMAPfolderItem::downloadMails() | 728 | void IMAPfolderItem::downloadMails() |
727 | { | 729 | { |
728 | AccountView*bl = imap->accountView(); | 730 | AccountView*bl = imap->accountView(); |
729 | if (!bl) return; | 731 | if (!bl) return; |
730 | bl->downloadMails(folder,imap->getWrapper()); | 732 | bl->downloadMails(folder,imap->getWrapper()); |
731 | } | 733 | } |
732 | 734 | ||
733 | void IMAPfolderItem::contextMenuSelected(int id) | 735 | void IMAPfolderItem::contextMenuSelected(int id) |
734 | { | 736 | { |
735 | 737 | ||
736 | AccountView * view = (AccountView*)listView(); | 738 | AccountView * view = (AccountView*)listView(); |
737 | switch(id) | 739 | switch(id) |
738 | { | 740 | { |
739 | case 0: | 741 | case 0: |
740 | view->refreshCurrent(); | 742 | view->refreshCurrent(); |
741 | break; | 743 | break; |
742 | case 1: | 744 | case 1: |
743 | deleteAllMail(imap->getWrapper(),folder); | 745 | deleteAllMail(imap->getWrapper(),folder); |
744 | break; | 746 | break; |
745 | case 2: | 747 | case 2: |
746 | createNewFolder(); | 748 | createNewFolder(); |
747 | break; | 749 | break; |
748 | case 3: | 750 | case 3: |
749 | deleteFolder(); | 751 | deleteFolder(); |
750 | break; | 752 | break; |
751 | case 4: | 753 | case 4: |
752 | downloadMails(); | 754 | downloadMails(); |
753 | break; | 755 | break; |
754 | default: | 756 | default: |
755 | break; | 757 | break; |
756 | } | 758 | } |
757 | } | 759 | } |
758 | 760 | ||
759 | /** | 761 | /** |
760 | * MH Account stuff | 762 | * MH Account stuff |
761 | */ | 763 | */ |
762 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and | 764 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and |
763 | POP3 and MBOX */ | 765 | POP3 and MBOX */ |
764 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) | 766 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) |
765 | : AccountViewItem( parent ) | 767 | : AccountViewItem( parent ) |
766 | { | 768 | { |
767 | m_Path = aPath; | 769 | m_Path = aPath; |
768 | /* be carefull - the space within settext is wanted - thats why the string twice */ | 770 | /* be carefull - the space within settext is wanted - thats why the string twice */ |
769 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); | 771 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); |
770 | setPixmap( 0, PIXMAP_LOCALFOLDER ); | 772 | setPixmap( 0, PIXMAP_LOCALFOLDER ); |
771 | setText( 0, " Local Folders" ); | 773 | setText( 0, " Local Folders" ); |
772 | setOpen( true ); | 774 | setOpen( true ); |
773 | folder = 0; | 775 | folder = 0; |
774 | } | 776 | } |
775 | 777 | ||
776 | MHviewItem::~MHviewItem() | 778 | MHviewItem::~MHviewItem() |
777 | { | 779 | { |
778 | delete wrapper; | 780 | delete wrapper; |
779 | } | 781 | } |
780 | 782 | ||
781 | AbstractMail *MHviewItem::getWrapper() | 783 | AbstractMail *MHviewItem::getWrapper() |
782 | { | 784 | { |
783 | return wrapper; | 785 | return wrapper; |
784 | } | 786 | } |
785 | 787 | ||
786 | void MHviewItem::refresh( QValueList<RecMailP> & target) | 788 | void MHviewItem::refresh( QValueList<RecMailP> & target) |
787 | { | 789 | { |
788 | refresh(false); | 790 | refresh(false); |
789 | getWrapper()->listMessages( "",target ); | 791 | getWrapper()->listMessages( "",target ); |
790 | } | 792 | } |
791 | 793 | ||
792 | void MHviewItem::refresh(bool force) | 794 | void MHviewItem::refresh(bool force) |
793 | { | 795 | { |
794 | if (childCount()>0 && force==false) return; | 796 | if (childCount()>0 && force==false) return; |
795 | removeChilds(); | 797 | removeChilds(); |
796 | currentFolders.clear(); | 798 | currentFolders.clear(); |
797 | QValueList<FolderP> *folders = wrapper->listFolders(); | 799 | QValueList<FolderP> *folders = wrapper->listFolders(); |
798 | QValueList<FolderP>::ConstIterator it; | 800 | QValueList<FolderP>::ConstIterator it; |
799 | MHfolderItem*item = 0; | 801 | MHfolderItem*item = 0; |
800 | MHfolderItem*pmaster = 0; | 802 | MHfolderItem*pmaster = 0; |
801 | QString fname = ""; | 803 | QString fname = ""; |
802 | int pos; | 804 | int pos; |
803 | for ( it = folders->begin(); it!=folders->end(); ++it) | 805 | for ( it = folders->begin(); it!=folders->end(); ++it) |
804 | { | 806 | { |
805 | fname = (*it)->getDisplayName(); | 807 | fname = (*it)->getDisplayName(); |
806 | /* this folder itself */ | 808 | /* this folder itself */ |
807 | if (fname=="/") | 809 | if (fname=="/") |
808 | { | 810 | { |
809 | currentFolders.append(fname); | 811 | currentFolders.append(fname); |
810 | folder = (*it); | 812 | folder = (*it); |
811 | continue; | 813 | continue; |
812 | } | 814 | } |
813 | currentFolders.append(fname); | 815 | currentFolders.append(fname); |
814 | pos = fname.findRev("/"); | 816 | pos = fname.findRev("/"); |
815 | if (pos > 0) | 817 | if (pos > 0) |
816 | { | 818 | { |
817 | fname = fname.left(pos); | 819 | fname = fname.left(pos); |
818 | pmaster = (MHfolderItem*)findSubItem(fname); | 820 | pmaster = (MHfolderItem*)findSubItem(fname); |
819 | } | 821 | } |
820 | else | 822 | else |
821 | { | 823 | { |
822 | pmaster = 0; | 824 | pmaster = 0; |
823 | } | 825 | } |
824 | if (pmaster) | 826 | if (pmaster) |
825 | { | 827 | { |
826 | item = new MHfolderItem( (*it), pmaster, item, this ); | 828 | item = new MHfolderItem( (*it), pmaster, item, this ); |
827 | } | 829 | } |
828 | else | 830 | else |
829 | { | 831 | { |
830 | item = new MHfolderItem( (*it), this , item ); | 832 | item = new MHfolderItem( (*it), this , item ); |
831 | } | 833 | } |
832 | item->setSelectable((*it)->may_select()); | 834 | item->setSelectable((*it)->may_select()); |
833 | } | 835 | } |
834 | delete folders; | 836 | delete folders; |
835 | } | 837 | } |
836 | 838 | ||
837 | RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) | 839 | RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) |
838 | { | 840 | { |
839 | 841 | ||
840 | return wrapper->fetchBody( mail ); | 842 | return wrapper->fetchBody( mail ); |
841 | } | 843 | } |
842 | 844 | ||
843 | QPopupMenu * MHviewItem::getContextMenu() | 845 | QPopupMenu * MHviewItem::getContextMenu() |
844 | { | 846 | { |
845 | QPopupMenu *m = new QPopupMenu(0); | 847 | QPopupMenu *m = new QPopupMenu(0); |
846 | if (m) | 848 | if (m) |
847 | { | 849 | { |
848 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 850 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); |
849 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 851 | m->insertItem(QObject::tr("Create new folder",contextName),1); |
850 | m->insertItem(QObject::tr("Delete all mails",contextName),2); | 852 | m->insertItem(QObject::tr("Delete all mails",contextName),2); |
851 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); | 853 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); |
852 | } | 854 | } |
853 | return m; | 855 | return m; |
854 | } | 856 | } |
855 | 857 | ||
856 | void MHviewItem::createFolder() | 858 | void MHviewItem::createFolder() |
857 | { | 859 | { |
858 | Newmdirdlg ndirdlg(0,0,true); | 860 | Newmdirdlg ndirdlg(0,0,true); |
859 | ndirdlg.showMaximized(); | 861 | ndirdlg.showMaximized(); |
860 | if ( ndirdlg.exec() ) | 862 | if ( ndirdlg.exec() ) |
861 | { | 863 | { |
862 | QString ndir = ndirdlg.Newdir(); | 864 | QString ndir = ndirdlg.Newdir(); |
863 | if (wrapper->createMbox(ndir)) | 865 | if (wrapper->createMbox(ndir)) |
864 | { | 866 | { |
865 | refresh(true); | 867 | refresh(true); |
866 | } | 868 | } |
867 | } | 869 | } |
868 | } | 870 | } |
869 | 871 | ||
870 | void MHviewItem::downloadMails() | 872 | void MHviewItem::downloadMails() |
871 | { | 873 | { |
872 | AccountView*bl = accountView(); | 874 | AccountView*bl = accountView(); |
873 | if (!bl) return; | 875 | if (!bl) return; |
874 | bl->downloadMails(folder,getWrapper()); | 876 | bl->downloadMails(folder,getWrapper()); |
875 | } | 877 | } |
876 | 878 | ||
877 | QStringList MHviewItem::subFolders() | 879 | QStringList MHviewItem::subFolders() |
878 | { | 880 | { |
879 | return currentFolders; | 881 | return currentFolders; |
880 | } | 882 | } |
881 | 883 | ||
882 | void MHviewItem::contextMenuSelected(int which) | 884 | void MHviewItem::contextMenuSelected(int which) |
883 | { | 885 | { |
884 | switch (which) | 886 | switch (which) |
885 | { | 887 | { |
886 | case 0: | 888 | case 0: |
887 | refresh(true); | 889 | refresh(true); |
888 | break; | 890 | break; |
889 | case 1: | 891 | case 1: |
890 | createFolder(); | 892 | createFolder(); |
891 | break; | 893 | break; |
892 | case 2: | 894 | case 2: |
893 | deleteAllMail(getWrapper(),folder); | 895 | deleteAllMail(getWrapper(),folder); |
894 | break; | 896 | break; |
895 | case 3: | 897 | case 3: |
896 | downloadMails(); | 898 | downloadMails(); |
897 | break; | 899 | break; |
898 | default: | 900 | default: |
899 | break; | 901 | break; |
900 | } | 902 | } |
901 | } | 903 | } |
902 | 904 | ||
903 | MHfolderItem::~MHfolderItem() | 905 | MHfolderItem::~MHfolderItem() |
904 | {} | 906 | {} |
905 | 907 | ||
906 | MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) | 908 | MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) |
907 | : AccountViewItem(folderInit, parent,after ) | 909 | : AccountViewItem(folderInit, parent,after ) |
908 | { | 910 | { |
909 | mbox = parent; | 911 | mbox = parent; |
910 | initName(); | 912 | initName(); |
911 | } | 913 | } |
912 | 914 | ||
913 | MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) | 915 | MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) |
914 | : AccountViewItem(folderInit, parent,after ) | 916 | : AccountViewItem(folderInit, parent,after ) |
915 | { | 917 | { |
916 | folder = folderInit; | 918 | folder = folderInit; |
917 | mbox = master; | 919 | mbox = master; |
918 | initName(); | 920 | initName(); |
919 | } | 921 | } |
920 | 922 | ||
921 | void MHfolderItem::initName() | 923 | void MHfolderItem::initName() |
922 | { | 924 | { |
923 | QString bName = folder->getDisplayName(); | 925 | QString bName = folder->getDisplayName(); |
924 | if (bName.startsWith("/")&&bName.length()>1) | 926 | if (bName.startsWith("/")&&bName.length()>1) |
925 | { | 927 | { |
926 | bName.replace(0,1,""); | 928 | bName.replace(0,1,""); |
927 | } | 929 | } |
928 | int pos = bName.findRev("/"); | 930 | int pos = bName.findRev("/"); |
929 | if (pos > 0) | 931 | if (pos > 0) |
930 | { | 932 | { |
931 | bName.replace(0,pos+1,""); | 933 | bName.replace(0,pos+1,""); |
932 | } | 934 | } |
933 | if (bName.lower() == "outgoing") | 935 | if (bName.lower() == "outgoing") |
934 | { | 936 | { |
935 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); | 937 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); |
936 | } | 938 | } |
937 | else if (bName.lower() == "inbox") | 939 | else if (bName.lower() == "inbox") |
938 | { | 940 | { |
939 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 941 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
940 | } else if (bName.lower() == "drafts") { | 942 | } else if (bName.lower() == "drafts") { |
941 | setPixmap(0, SmallIcon ("edit")); | 943 | setPixmap(0, SmallIcon ("edit")); |
942 | } else { | 944 | } else { |
943 | setPixmap( 0, PIXMAP_MBOXFOLDER ); | 945 | setPixmap( 0, PIXMAP_MBOXFOLDER ); |
944 | } | 946 | } |
945 | setText( 0, bName ); | 947 | setText( 0, bName ); |
946 | } | 948 | } |
947 | 949 | ||
948 | const FolderP&MHfolderItem::getFolder()const | 950 | const FolderP&MHfolderItem::getFolder()const |
949 | { | 951 | { |
950 | return folder; | 952 | return folder; |
951 | } | 953 | } |
952 | 954 | ||
953 | void MHfolderItem::refresh(QValueList<RecMailP>&target) | 955 | void MHfolderItem::refresh(QValueList<RecMailP>&target) |
954 | { | 956 | { |
955 | if (folder->may_select()) | 957 | if (folder->may_select()) |
956 | mbox->getWrapper()->listMessages( folder->getName(),target ); | 958 | mbox->getWrapper()->listMessages( folder->getName(),target ); |
957 | } | 959 | } |
958 | 960 | ||
959 | RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) | 961 | RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) |
960 | { | 962 | { |
961 | return mbox->getWrapper()->fetchBody(aMail); | 963 | return mbox->getWrapper()->fetchBody(aMail); |
962 | } | 964 | } |
963 | 965 | ||
964 | void MHfolderItem::deleteFolder() | 966 | void MHfolderItem::deleteFolder() |
965 | { | 967 | { |
966 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | 968 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), |
967 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | 969 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), |
968 | QObject::tr("Yes",contextName), | 970 | QObject::tr("Yes",contextName), |
969 | QObject::tr("No",contextName),QString::null,1,1); | 971 | QObject::tr("No",contextName),QString::null,1,1); |
970 | 972 | ||
971 | if (yesno == 0) | 973 | if (yesno == 0) |
972 | { | 974 | { |
973 | if (mbox->getWrapper()->deleteMbox(folder)) | 975 | if (mbox->getWrapper()->deleteMbox(folder)) |
974 | { | 976 | { |
975 | QListView*v=listView(); | 977 | QListView*v=listView(); |
976 | MHviewItem * box = mbox; | 978 | MHviewItem * box = mbox; |
977 | /* be carefull - after that this object is destroyd so don't use | 979 | /* be carefull - after that this object is destroyd so don't use |
978 | * any member of it after that call!!*/ | 980 | * any member of it after that call!!*/ |
979 | mbox->refresh(true); | 981 | mbox->refresh(true); |
980 | if (v) | 982 | if (v) |
981 | { | 983 | { |
982 | v->setSelected(box,true); | 984 | v->setSelected(box,true); |
983 | } | 985 | } |
984 | } | 986 | } |
985 | } | 987 | } |
986 | } | 988 | } |
987 | 989 | ||
988 | QPopupMenu * MHfolderItem::getContextMenu() | 990 | QPopupMenu * MHfolderItem::getContextMenu() |
989 | { | 991 | { |
990 | QPopupMenu *m = new QPopupMenu(0); | 992 | QPopupMenu *m = new QPopupMenu(0); |
991 | if (m) | 993 | if (m) |
992 | { | 994 | { |
993 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | 995 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); |
994 | m->insertItem(QObject::tr("Delete all mails",contextName),0); | 996 | m->insertItem(QObject::tr("Delete all mails",contextName),0); |
995 | m->insertItem(QObject::tr("Create new subfolder",contextName),3); | 997 | m->insertItem(QObject::tr("Create new subfolder",contextName),3); |
996 | m->insertItem(QObject::tr("Delete folder",contextName),1); | 998 | m->insertItem(QObject::tr("Delete folder",contextName),1); |
997 | } | 999 | } |
998 | return m; | 1000 | return m; |
999 | } | 1001 | } |
1000 | 1002 | ||
1001 | void MHfolderItem::downloadMails() | 1003 | void MHfolderItem::downloadMails() |
1002 | { | 1004 | { |
1003 | AccountView*bl = mbox->accountView(); | 1005 | AccountView*bl = mbox->accountView(); |
1004 | if (!bl) return; | 1006 | if (!bl) return; |
1005 | bl->downloadMails(folder,mbox->getWrapper()); | 1007 | bl->downloadMails(folder,mbox->getWrapper()); |
1006 | } | 1008 | } |
1007 | 1009 | ||
1008 | void MHfolderItem::createFolder() | 1010 | void MHfolderItem::createFolder() |
1009 | { | 1011 | { |
1010 | Newmdirdlg ndirdlg(0,0,true); | 1012 | Newmdirdlg ndirdlg(0,0,true); |
1011 | ndirdlg.showMaximized(); | 1013 | ndirdlg.showMaximized(); |
1012 | if (ndirdlg.exec() ) | 1014 | if (ndirdlg.exec() ) |
1013 | { | 1015 | { |
1014 | QString ndir = ndirdlg.Newdir(); | 1016 | QString ndir = ndirdlg.Newdir(); |
1015 | if (mbox->getWrapper()->createMbox(ndir,folder)) | 1017 | if (mbox->getWrapper()->createMbox(ndir,folder)) |
1016 | { | 1018 | { |
1017 | QListView*v=listView(); | 1019 | QListView*v=listView(); |
1018 | MHviewItem * box = mbox; | 1020 | MHviewItem * box = mbox; |
1019 | /* be carefull - after that this object is destroyd so don't use | 1021 | /* be carefull - after that this object is destroyd so don't use |
1020 | * any member of it after that call!!*/ | 1022 | * any member of it after that call!!*/ |
1021 | mbox->refresh(true); | 1023 | mbox->refresh(true); |
1022 | if (v) | 1024 | if (v) |
1023 | { | 1025 | { |
1024 | v->setSelected(box,true); | 1026 | v->setSelected(box,true); |
1025 | } | 1027 | } |
1026 | } | 1028 | } |
1027 | } | 1029 | } |
1028 | } | 1030 | } |
1029 | 1031 | ||
1030 | void MHfolderItem::contextMenuSelected(int which) | 1032 | void MHfolderItem::contextMenuSelected(int which) |
1031 | { | 1033 | { |
1032 | switch(which) | 1034 | switch(which) |
1033 | { | 1035 | { |
1034 | case 0: | 1036 | case 0: |
1035 | deleteAllMail(mbox->getWrapper(),folder); | 1037 | deleteAllMail(mbox->getWrapper(),folder); |
1036 | break; | 1038 | break; |
1037 | case 1: | 1039 | case 1: |
1038 | deleteFolder(); | 1040 | deleteFolder(); |
1039 | break; | 1041 | break; |
1040 | case 2: | 1042 | case 2: |
1041 | downloadMails(); | 1043 | downloadMails(); |
1042 | break; | 1044 | break; |
1043 | case 3: | 1045 | case 3: |
1044 | createFolder(); | 1046 | createFolder(); |
1045 | break; | 1047 | break; |
1046 | default: | 1048 | default: |
1047 | break; | 1049 | break; |
1048 | } | 1050 | } |
1049 | } | 1051 | } |
1050 | 1052 | ||
1051 | bool MHfolderItem::isDraftfolder() | 1053 | bool MHfolderItem::isDraftfolder() |
1052 | { | 1054 | { |
1053 | if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; | 1055 | if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; |
1054 | return false; | 1056 | return false; |
1055 | } | 1057 | } |
1056 | 1058 | ||
1057 | /** | 1059 | /** |
1058 | * Generic stuff | 1060 | * Generic stuff |
1059 | */ | 1061 | */ |
1060 | 1062 | ||
1061 | const QString AccountViewItem::contextName="AccountViewItem"; | 1063 | const QString AccountViewItem::contextName="AccountViewItem"; |
1062 | 1064 | ||
1063 | AccountViewItem::AccountViewItem( AccountView *parent ) | 1065 | AccountViewItem::AccountViewItem( AccountView *parent ) |
1064 | : QListViewItem( parent ) | 1066 | : QListViewItem( parent ) |
1065 | { | 1067 | { |
1066 | init(); | 1068 | init(); |
1067 | m_Backlink = parent; | 1069 | m_Backlink = parent; |
1068 | } | 1070 | } |
1069 | 1071 | ||
1070 | AccountViewItem::AccountViewItem( QListViewItem *parent) | 1072 | AccountViewItem::AccountViewItem( QListViewItem *parent) |
1071 | : QListViewItem( parent),folder(0) | 1073 | : QListViewItem( parent),folder(0) |
1072 | { | 1074 | { |
1073 | init(); | 1075 | init(); |
1074 | } | 1076 | } |
1075 | 1077 | ||
1076 | AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) | 1078 | AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) |
1077 | :QListViewItem( parent,after ),folder(0) | 1079 | :QListViewItem( parent,after ),folder(0) |
1078 | { | 1080 | { |
1079 | init(); | 1081 | init(); |
1080 | } | 1082 | } |
1081 | 1083 | ||
1082 | AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ) | 1084 | AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ) |
1083 | :QListViewItem( parent,after ),folder(folderInit) | 1085 | :QListViewItem( parent,after ),folder(folderInit) |
1084 | { | 1086 | { |
1085 | init(); | 1087 | init(); |
1086 | } | 1088 | } |
1087 | 1089 | ||
1088 | void AccountViewItem::init() | 1090 | void AccountViewItem::init() |
1089 | { | 1091 | { |
1090 | m_Backlink = 0; | 1092 | m_Backlink = 0; |
1091 | } | 1093 | } |
1092 | 1094 | ||
1093 | AccountViewItem::~AccountViewItem() | 1095 | AccountViewItem::~AccountViewItem() |
1094 | { | 1096 | { |
1095 | folder = 0; | 1097 | folder = 0; |
1096 | } | 1098 | } |
1097 | 1099 | ||
1098 | AccountView*AccountViewItem::accountView() | 1100 | AccountView*AccountViewItem::accountView() |
1099 | { | 1101 | { |
1100 | return m_Backlink; | 1102 | return m_Backlink; |
1101 | } | 1103 | } |
1102 | 1104 | ||
1103 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder) | 1105 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder) |
1104 | { | 1106 | { |
1105 | if (!wrapper) return; | 1107 | if (!wrapper) return; |
1106 | QString fname=""; | 1108 | QString fname=""; |
1107 | if (folder) fname = folder->getDisplayName(); | 1109 | if (folder) fname = folder->getDisplayName(); |
1108 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), | 1110 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), |
1109 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). | 1111 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). |
1110 | arg(fname), | 1112 | arg(fname), |
1111 | QObject::tr("Yes",contextName), | 1113 | QObject::tr("Yes",contextName), |
1112 | QObject::tr("No",contextName),QString::null,1,1); | 1114 | QObject::tr("No",contextName),QString::null,1,1); |
1113 | 1115 | ||
1114 | if (yesno == 0) | 1116 | if (yesno == 0) |
1115 | { | 1117 | { |
1116 | if (wrapper->deleteAllMail(folder)) | 1118 | if (wrapper->deleteAllMail(folder)) |
1117 | { | 1119 | { |
1118 | AccountView * view = (AccountView*)listView(); | 1120 | AccountView * view = (AccountView*)listView(); |
1119 | if (view) view->refreshCurrent(); | 1121 | if (view) view->refreshCurrent(); |
1120 | } | 1122 | } |
1121 | } | 1123 | } |
1122 | } | 1124 | } |
1123 | 1125 | ||
1124 | void AccountViewItem::removeChilds() | 1126 | void AccountViewItem::removeChilds() |
1125 | { | 1127 | { |
1126 | QListViewItem *child = firstChild(); | 1128 | QListViewItem *child = firstChild(); |
1127 | while ( child ) | 1129 | while ( child ) |
1128 | { | 1130 | { |
1129 | QListViewItem *tmp = child; | 1131 | QListViewItem *tmp = child; |
1130 | child = child->nextSibling(); | 1132 | child = child->nextSibling(); |
1131 | delete tmp; | 1133 | delete tmp; |
1132 | } | 1134 | } |
1133 | } | 1135 | } |
1134 | 1136 | ||
1135 | bool AccountViewItem::matchName(const QString&name)const | 1137 | bool AccountViewItem::matchName(const QString&name)const |
1136 | { | 1138 | { |
1137 | if (!folder) return false; | 1139 | if (!folder) return false; |
1138 | return folder->getDisplayName().lower()==name.lower(); | 1140 | return folder->getDisplayName().lower()==name.lower(); |
1139 | } | 1141 | } |
1140 | 1142 | ||
1141 | 1143 | ||
1142 | AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) | 1144 | AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) |
1143 | { | 1145 | { |
1144 | AccountViewItem*pitem,*sitem; | 1146 | AccountViewItem*pitem,*sitem; |
1145 | if (!start) pitem = (AccountViewItem*)firstChild(); | 1147 | if (!start) pitem = (AccountViewItem*)firstChild(); |
1146 | else pitem = (AccountViewItem*)start->firstChild(); | 1148 | else pitem = (AccountViewItem*)start->firstChild(); |
1147 | while (pitem) | 1149 | while (pitem) |
1148 | { | 1150 | { |
1149 | if (pitem->matchName(path)) | 1151 | if (pitem->matchName(path)) |
1150 | { | 1152 | { |
1151 | break; | 1153 | break; |
1152 | } | 1154 | } |
1153 | if (pitem->childCount()>0) | 1155 | if (pitem->childCount()>0) |
1154 | { | 1156 | { |
1155 | sitem = findSubItem(path,pitem); | 1157 | sitem = findSubItem(path,pitem); |
1156 | if (sitem) | 1158 | if (sitem) |
1157 | { | 1159 | { |
1158 | pitem = sitem; | 1160 | pitem = sitem; |
1159 | break; | 1161 | break; |
1160 | } | 1162 | } |
1161 | } | 1163 | } |
1162 | pitem=(AccountViewItem*)pitem->nextSibling(); | 1164 | pitem=(AccountViewItem*)pitem->nextSibling(); |
1163 | } | 1165 | } |
1164 | return pitem; | 1166 | return pitem; |
1165 | } | 1167 | } |
1166 | 1168 | ||
1167 | bool AccountViewItem::isDraftfolder() | 1169 | bool AccountViewItem::isDraftfolder() |
1168 | { | 1170 | { |
1169 | return false; | 1171 | return false; |
1170 | } | 1172 | } |
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index 5441a9b..91332c3 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,1307 +1,1307 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include <qpe/global.h> | 4 | #include <qpe/global.h> |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #include "imapwrapper.h" | 6 | #include "imapwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include "logindialog.h" | 8 | #include "logindialog.h" |
9 | #include <qprogressbar.h> | 9 | #include <qprogressbar.h> |
10 | #include "genericwrapper.h" | 10 | #include "genericwrapper.h" |
11 | 11 | ||
12 | using namespace Opie::Core; | 12 | using namespace Opie::Core; |
13 | int IMAPwrapper::mMax = 0; | 13 | int IMAPwrapper::mMax = 0; |
14 | int IMAPwrapper::mCurrent = 0; | 14 | int IMAPwrapper::mCurrent = 0; |
15 | 15 | ||
16 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 16 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
17 | : AbstractMail() | 17 | : AbstractMail() |
18 | { | 18 | { |
19 | account = a; | 19 | account = a; |
20 | m_imap = 0; | 20 | m_imap = 0; |
21 | m_Lastmbox = ""; | 21 | m_Lastmbox = ""; |
22 | mCurrent = 0; | 22 | mCurrent = 0; |
23 | mMax = 0; | 23 | mMax = 0; |
24 | } | 24 | } |
25 | 25 | ||
26 | IMAPwrapper::~IMAPwrapper() | 26 | IMAPwrapper::~IMAPwrapper() |
27 | { | 27 | { |
28 | logout(); | 28 | logout(); |
29 | } | 29 | } |
30 | 30 | ||
31 | /* to avoid to often select statements in loops etc. | 31 | /* to avoid to often select statements in loops etc. |
32 | we trust that we are logged in and connection is established!*/ | 32 | we trust that we are logged in and connection is established!*/ |
33 | int IMAPwrapper::selectMbox(const QString&mbox) | 33 | int IMAPwrapper::selectMbox(const QString&mbox) |
34 | { | 34 | { |
35 | if (mbox == m_Lastmbox) { | 35 | if (mbox == m_Lastmbox) { |
36 | return MAILIMAP_NO_ERROR; | 36 | return MAILIMAP_NO_ERROR; |
37 | } | 37 | } |
38 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | 38 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); |
39 | if ( err != MAILIMAP_NO_ERROR ) { | 39 | if ( err != MAILIMAP_NO_ERROR ) { |
40 | m_Lastmbox = ""; | 40 | m_Lastmbox = ""; |
41 | return err; | 41 | return err; |
42 | } | 42 | } |
43 | m_Lastmbox = mbox; | 43 | m_Lastmbox = mbox; |
44 | return err; | 44 | return err; |
45 | } | 45 | } |
46 | 46 | ||
47 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 47 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
48 | { | 48 | { |
49 | //qDebug("imap progress %d of %d ",current,maximum ); | 49 | //qDebug("imap progress %d of %d ",current,maximum ); |
50 | //Global::statusMessage(tr("Downloading message %1 of %2").arg( current).arg(maximum)); | 50 | //Global::statusMessage(tr("Downloading message %1 of %2").arg( current).arg(maximum)); |
51 | //qApp->processEvents() | 51 | //qApp->processEvents() |
52 | static int last = 0; | 52 | static int last = 0; |
53 | if ( last != current ) | 53 | if ( last != current ) |
54 | IMAPwrapper::progress(); | 54 | IMAPwrapper::progress(); |
55 | last = current; | 55 | last = current; |
56 | } | 56 | } |
57 | void IMAPwrapper::progress( QString m ) | 57 | void IMAPwrapper::progress( QString m ) |
58 | { | 58 | { |
59 | 59 | ||
60 | static QString mProgrMess; | 60 | static QString mProgrMess; |
61 | if ( m != QString::null ) { | 61 | if ( m != QString::null ) { |
62 | mProgrMess = m; | 62 | mProgrMess = m; |
63 | mCurrent = 0; | 63 | mCurrent = 0; |
64 | return; | 64 | return; |
65 | } | 65 | } |
66 | QString mess; | 66 | QString mess; |
67 | //qDebug("progress "); | 67 | //qDebug("progress "); |
68 | if ( mMax ) mess = mProgrMess +tr(" message %1 of %2").arg( mCurrent++).arg(mMax); | 68 | if ( mMax ) mess = mProgrMess +tr(" message %1 of %2").arg( mCurrent++).arg(mMax); |
69 | else mess = mProgrMess +tr(" message %1").arg( mCurrent++); | 69 | else mess = mProgrMess +tr(" message %1").arg( mCurrent++); |
70 | Global::statusMessage(mess); | 70 | Global::statusMessage(mess); |
71 | qApp->processEvents(); | 71 | qApp->processEvents(); |
72 | } | 72 | } |
73 | bool IMAPwrapper::start_tls(bool force_tls) | 73 | bool IMAPwrapper::start_tls(bool force_tls) |
74 | { | 74 | { |
75 | int err; | 75 | int err; |
76 | bool try_tls; | 76 | bool try_tls; |
77 | mailimap_capability_data * cap_data = 0; | 77 | mailimap_capability_data * cap_data = 0; |
78 | 78 | ||
79 | err = mailimap_capability(m_imap,&cap_data); | 79 | err = mailimap_capability(m_imap,&cap_data); |
80 | if (err != MAILIMAP_NO_ERROR) { | 80 | if (err != MAILIMAP_NO_ERROR) { |
81 | Global::statusMessage("error getting capabilities!"); | 81 | Global::statusMessage("error getting capabilities!"); |
82 | return false; | 82 | return false; |
83 | } | 83 | } |
84 | clistiter * cur; | 84 | clistiter * cur; |
85 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { | 85 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { |
86 | struct mailimap_capability * cap; | 86 | struct mailimap_capability * cap; |
87 | cap = (struct mailimap_capability *)clist_content(cur); | 87 | cap = (struct mailimap_capability *)clist_content(cur); |
88 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { | 88 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { |
89 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { | 89 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { |
90 | try_tls = true; | 90 | try_tls = true; |
91 | break; | 91 | break; |
92 | } | 92 | } |
93 | } | 93 | } |
94 | } | 94 | } |
95 | if (cap_data) { | 95 | if (cap_data) { |
96 | mailimap_capability_data_free(cap_data); | 96 | mailimap_capability_data_free(cap_data); |
97 | } | 97 | } |
98 | if (try_tls) { | 98 | if (try_tls) { |
99 | err = mailimap_starttls(m_imap); | 99 | err = mailimap_starttls(m_imap); |
100 | if (err != MAILIMAP_NO_ERROR && force_tls) { | 100 | if (err != MAILIMAP_NO_ERROR && force_tls) { |
101 | Global::statusMessage(tr("Server has no TLS support!")); | 101 | Global::statusMessage(tr("Server has no TLS support!")); |
102 | try_tls = false; | 102 | try_tls = false; |
103 | } else { | 103 | } else { |
104 | mailstream_low * low; | 104 | mailstream_low * low; |
105 | mailstream_low * new_low; | 105 | mailstream_low * new_low; |
106 | low = mailstream_get_low(m_imap->imap_stream); | 106 | low = mailstream_get_low(m_imap->imap_stream); |
107 | if (!low) { | 107 | if (!low) { |
108 | try_tls = false; | 108 | try_tls = false; |
109 | } else { | 109 | } else { |
110 | int fd = mailstream_low_get_fd(low); | 110 | int fd = mailstream_low_get_fd(low); |
111 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { | 111 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { |
112 | mailstream_low_free(low); | 112 | mailstream_low_free(low); |
113 | mailstream_set_low(m_imap->imap_stream, new_low); | 113 | mailstream_set_low(m_imap->imap_stream, new_low); |
114 | } else { | 114 | } else { |
115 | try_tls = false; | 115 | try_tls = false; |
116 | } | 116 | } |
117 | } | 117 | } |
118 | } | 118 | } |
119 | } | 119 | } |
120 | return try_tls; | 120 | return try_tls; |
121 | } | 121 | } |
122 | 122 | ||
123 | void IMAPwrapper::login() | 123 | void IMAPwrapper::login() |
124 | { | 124 | { |
125 | QString server, user, pass; | 125 | QString server, user, pass; |
126 | uint16_t port; | 126 | uint16_t port; |
127 | int err = MAILIMAP_NO_ERROR; | 127 | int err = MAILIMAP_NO_ERROR; |
128 | 128 | ||
129 | if (account->getOffline()) return; | 129 | if (account->getOffline()) return; |
130 | /* we are connected this moment */ | 130 | /* we are connected this moment */ |
131 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 131 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
132 | if (m_imap) { | 132 | if (m_imap) { |
133 | err = mailimap_noop(m_imap); | 133 | err = mailimap_noop(m_imap); |
134 | if (err!=MAILIMAP_NO_ERROR) { | 134 | if (err!=MAILIMAP_NO_ERROR) { |
135 | logout(); | 135 | logout(); |
136 | } else { | 136 | } else { |
137 | mailstream_flush(m_imap->imap_stream); | 137 | mailstream_flush(m_imap->imap_stream); |
138 | return; | 138 | return; |
139 | } | 139 | } |
140 | } | 140 | } |
141 | server = account->getServer(); | 141 | server = account->getServer(); |
142 | port = account->getPort().toUInt(); | 142 | port = account->getPort().toUInt(); |
143 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 143 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
144 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 144 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
145 | login.show(); | 145 | login.show(); |
146 | if ( QDialog::Accepted == login.exec() ) { | 146 | if ( QDialog::Accepted == login.exec() ) { |
147 | // ok | 147 | // ok |
148 | user = login.getUser(); | 148 | user = login.getUser(); |
149 | pass = login.getPassword(); | 149 | pass = login.getPassword(); |
150 | } else { | 150 | } else { |
151 | // cancel | 151 | // cancel |
152 | return; | 152 | return; |
153 | } | 153 | } |
154 | } else { | 154 | } else { |
155 | user = account->getUser(); | 155 | user = account->getUser(); |
156 | pass = account->getPassword(); | 156 | pass = account->getPassword(); |
157 | } | 157 | } |
158 | 158 | ||
159 | m_imap = mailimap_new( 20, &imap_progress ); | 159 | m_imap = mailimap_new( 20, &imap_progress ); |
160 | 160 | ||
161 | /* connect */ | 161 | /* connect */ |
162 | bool ssl = false; | 162 | bool ssl = false; |
163 | bool try_tls = false; | 163 | bool try_tls = false; |
164 | bool force_tls = false; | 164 | bool force_tls = false; |
165 | 165 | ||
166 | if ( account->ConnectionType() == 2 ) { | 166 | if ( account->ConnectionType() == 2 ) { |
167 | ssl = true; | 167 | ssl = true; |
168 | } | 168 | } |
169 | if (account->ConnectionType()==1) { | 169 | if (account->ConnectionType()==1) { |
170 | force_tls = true; | 170 | force_tls = true; |
171 | } | 171 | } |
172 | 172 | ||
173 | if ( ssl ) { | 173 | if ( ssl ) { |
174 | qDebug("using ssl "); | 174 | //qDebug("using ssl "); |
175 | err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); | 175 | err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); |
176 | } else { | 176 | } else { |
177 | err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); | 177 | err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); |
178 | } | 178 | } |
179 | 179 | ||
180 | if ( err != MAILIMAP_NO_ERROR && | 180 | if ( err != MAILIMAP_NO_ERROR && |
181 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 181 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
182 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 182 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
183 | QString failure = ""; | 183 | QString failure = ""; |
184 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { | 184 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { |
185 | failure="Connection refused"; | 185 | failure="Connection refused"; |
186 | } else { | 186 | } else { |
187 | failure="Unknown failure"; | 187 | failure="Unknown failure"; |
188 | } | 188 | } |
189 | Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); | 189 | Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); |
190 | mailimap_free( m_imap ); | 190 | mailimap_free( m_imap ); |
191 | m_imap = 0; | 191 | m_imap = 0; |
192 | return; | 192 | return; |
193 | } | 193 | } |
194 | 194 | ||
195 | if (!ssl) { | 195 | if (!ssl) { |
196 | try_tls = start_tls(force_tls); | 196 | try_tls = start_tls(force_tls); |
197 | } | 197 | } |
198 | 198 | ||
199 | bool ok = true; | 199 | bool ok = true; |
200 | if (force_tls && !try_tls) { | 200 | if (force_tls && !try_tls) { |
201 | Global::statusMessage(tr("Server has no TLS support!")); | 201 | Global::statusMessage(tr("Server has no TLS support!")); |
202 | ok = false; | 202 | ok = false; |
203 | } | 203 | } |
204 | 204 | ||
205 | 205 | ||
206 | /* login */ | 206 | /* login */ |
207 | 207 | ||
208 | if (ok) { | 208 | if (ok) { |
209 | err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); | 209 | err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); |
210 | if ( err != MAILIMAP_NO_ERROR ) { | 210 | if ( err != MAILIMAP_NO_ERROR ) { |
211 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); | 211 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); |
212 | ok = false; | 212 | ok = false; |
213 | } | 213 | } |
214 | } | 214 | } |
215 | if (!ok) { | 215 | if (!ok) { |
216 | err = mailimap_close( m_imap ); | 216 | err = mailimap_close( m_imap ); |
217 | mailimap_free( m_imap ); | 217 | mailimap_free( m_imap ); |
218 | m_imap = 0; | 218 | m_imap = 0; |
219 | } | 219 | } |
220 | } | 220 | } |
221 | 221 | ||
222 | void IMAPwrapper::logout() | 222 | void IMAPwrapper::logout() |
223 | { | 223 | { |
224 | int err = MAILIMAP_NO_ERROR; | 224 | int err = MAILIMAP_NO_ERROR; |
225 | if (!m_imap) return; | 225 | if (!m_imap) return; |
226 | err = mailimap_logout( m_imap ); | 226 | err = mailimap_logout( m_imap ); |
227 | err = mailimap_close( m_imap ); | 227 | err = mailimap_close( m_imap ); |
228 | mailimap_free( m_imap ); | 228 | mailimap_free( m_imap ); |
229 | m_imap = 0; | 229 | m_imap = 0; |
230 | m_Lastmbox = ""; | 230 | m_Lastmbox = ""; |
231 | } | 231 | } |
232 | 232 | ||
233 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) | 233 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) |
234 | { | 234 | { |
235 | int err = MAILIMAP_NO_ERROR; | 235 | int err = MAILIMAP_NO_ERROR; |
236 | clist *result = 0; | 236 | clist *result = 0; |
237 | clistcell *current; | 237 | clistcell *current; |
238 | mailimap_fetch_type *fetchType = 0; | 238 | mailimap_fetch_type *fetchType = 0; |
239 | mailimap_set *set = 0; | 239 | mailimap_set *set = 0; |
240 | 240 | ||
241 | login(); | 241 | login(); |
242 | if (!m_imap) { | 242 | if (!m_imap) { |
243 | return; | 243 | return; |
244 | } | 244 | } |
245 | /* select mailbox READONLY for operations */ | 245 | /* select mailbox READONLY for operations */ |
246 | err = selectMbox(mailbox); | 246 | err = selectMbox(mailbox); |
247 | if ( err != MAILIMAP_NO_ERROR ) { | 247 | if ( err != MAILIMAP_NO_ERROR ) { |
248 | return; | 248 | return; |
249 | } | 249 | } |
250 | 250 | ||
251 | int last = m_imap->imap_selection_info->sel_exists; | 251 | int last = m_imap->imap_selection_info->sel_exists; |
252 | 252 | ||
253 | if (last == 0) { | 253 | if (last == 0) { |
254 | Global::statusMessage(tr("Mailbox has no mails")); | 254 | Global::statusMessage(tr("Mailbox has no mails")); |
255 | return; | 255 | return; |
256 | } else { | 256 | } else { |
257 | } | 257 | } |
258 | 258 | ||
259 | Global::statusMessage(tr("Fetching header list")); | 259 | Global::statusMessage(tr("Fetching header list")); |
260 | qApp->processEvents(); | 260 | qApp->processEvents(); |
261 | /* the range has to start at 1!!! not with 0!!!! */ | 261 | /* the range has to start at 1!!! not with 0!!!! */ |
262 | set = mailimap_set_new_interval( 1, last ); | 262 | set = mailimap_set_new_interval( 1, last ); |
263 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); | 263 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); |
264 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); | 264 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); |
265 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); | 265 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); |
266 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); | 266 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); |
267 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); | 267 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); |
268 | 268 | ||
269 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 269 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
270 | mailimap_set_free( set ); | 270 | mailimap_set_free( set ); |
271 | mailimap_fetch_type_free( fetchType ); | 271 | mailimap_fetch_type_free( fetchType ); |
272 | 272 | ||
273 | QString date,subject,from; | 273 | QString date,subject,from; |
274 | 274 | ||
275 | if ( err == MAILIMAP_NO_ERROR ) { | 275 | if ( err == MAILIMAP_NO_ERROR ) { |
276 | mailimap_msg_att * msg_att; | 276 | mailimap_msg_att * msg_att; |
277 | int i = 0; | 277 | int i = 0; |
278 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | 278 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { |
279 | ++i; | 279 | ++i; |
280 | msg_att = (mailimap_msg_att*)current->data; | 280 | msg_att = (mailimap_msg_att*)current->data; |
281 | RecMail*m = parse_list_result(msg_att); | 281 | RecMail*m = parse_list_result(msg_att); |
282 | if (m) { | 282 | if (m) { |
283 | if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) { | 283 | if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) { |
284 | m->setNumber(i); | 284 | m->setNumber(i); |
285 | m->setMbox(mailbox); | 285 | m->setMbox(mailbox); |
286 | m->setWrapper(this); | 286 | m->setWrapper(this); |
287 | target.append(m); | 287 | target.append(m); |
288 | } | 288 | } |
289 | } | 289 | } |
290 | } | 290 | } |
291 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); | 291 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); |
292 | } else { | 292 | } else { |
293 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); | 293 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); |
294 | } | 294 | } |
295 | if (result) mailimap_fetch_list_free(result); | 295 | if (result) mailimap_fetch_list_free(result); |
296 | } | 296 | } |
297 | 297 | ||
298 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | 298 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() |
299 | { | 299 | { |
300 | const char *path, *mask; | 300 | const char *path, *mask; |
301 | int err = MAILIMAP_NO_ERROR; | 301 | int err = MAILIMAP_NO_ERROR; |
302 | clist *result = 0; | 302 | clist *result = 0; |
303 | clistcell *current = 0; | 303 | clistcell *current = 0; |
304 | clistcell*cur_flag = 0; | 304 | clistcell*cur_flag = 0; |
305 | mailimap_mbx_list_flags*bflags = 0; | 305 | mailimap_mbx_list_flags*bflags = 0; |
306 | 306 | ||
307 | QValueList<FolderP>* folders = new QValueList<FolderP>(); | 307 | QValueList<FolderP>* folders = new QValueList<FolderP>(); |
308 | login(); | 308 | login(); |
309 | if (!m_imap) { | 309 | if (!m_imap) { |
310 | return folders; | 310 | return folders; |
311 | } | 311 | } |
312 | 312 | ||
313 | /* | 313 | /* |
314 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 314 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
315 | * We must not forget to filter them out in next loop! | 315 | * We must not forget to filter them out in next loop! |
316 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 316 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
317 | */ | 317 | */ |
318 | Global::statusMessage(tr("Fetching folder list")); | 318 | Global::statusMessage(tr("Fetching folder list")); |
319 | qApp->processEvents(); | 319 | qApp->processEvents(); |
320 | QString temp; | 320 | QString temp; |
321 | mask = "INBOX" ; | 321 | mask = "INBOX" ; |
322 | mailimap_mailbox_list *list; | 322 | mailimap_mailbox_list *list; |
323 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 323 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
324 | QString del; | 324 | QString del; |
325 | bool selectable = true; | 325 | bool selectable = true; |
326 | bool no_inferiors = false; | 326 | bool no_inferiors = false; |
327 | if ( err == MAILIMAP_NO_ERROR ) { | 327 | if ( err == MAILIMAP_NO_ERROR ) { |
328 | current = result->first; | 328 | current = result->first; |
329 | for ( int i = result->count; i > 0; i-- ) { | 329 | for ( int i = result->count; i > 0; i-- ) { |
330 | list = (mailimap_mailbox_list *) current->data; | 330 | list = (mailimap_mailbox_list *) current->data; |
331 | // it is better use the deep copy mechanism of qt itself | 331 | // it is better use the deep copy mechanism of qt itself |
332 | // instead of using strdup! | 332 | // instead of using strdup! |
333 | temp = list->mb_name; | 333 | temp = list->mb_name; |
334 | del = list->mb_delimiter; | 334 | del = list->mb_delimiter; |
335 | current = current->next; | 335 | current = current->next; |
336 | if ( (bflags = list->mb_flag) ) { | 336 | if ( (bflags = list->mb_flag) ) { |
337 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 337 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
338 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 338 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
339 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 339 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
340 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 340 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
341 | no_inferiors = true; | 341 | no_inferiors = true; |
342 | } | 342 | } |
343 | } | 343 | } |
344 | } | 344 | } |
345 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 345 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
346 | } | 346 | } |
347 | } else { | 347 | } else { |
348 | qDebug("error fetching folders: "); | 348 | qDebug("error fetching folders: "); |
349 | 349 | ||
350 | } | 350 | } |
351 | mailimap_list_result_free( result ); | 351 | mailimap_list_result_free( result ); |
352 | 352 | ||
353 | /* | 353 | /* |
354 | * second stage - get the other then inbox folders | 354 | * second stage - get the other then inbox folders |
355 | */ | 355 | */ |
356 | mask = "*" ; | 356 | mask = "*" ; |
357 | path = account->getPrefix().latin1(); | 357 | path = account->getPrefix().latin1(); |
358 | if (!path) path = ""; | 358 | if (!path) path = ""; |
359 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 359 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
360 | if ( err == MAILIMAP_NO_ERROR ) { | 360 | if ( err == MAILIMAP_NO_ERROR ) { |
361 | current = result->first; | 361 | current = result->first; |
362 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { | 362 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { |
363 | no_inferiors = false; | 363 | no_inferiors = false; |
364 | list = (mailimap_mailbox_list *) current->data; | 364 | list = (mailimap_mailbox_list *) current->data; |
365 | // it is better use the deep copy mechanism of qt itself | 365 | // it is better use the deep copy mechanism of qt itself |
366 | // instead of using strdup! | 366 | // instead of using strdup! |
367 | temp = list->mb_name; | 367 | temp = list->mb_name; |
368 | if (temp.lower()=="inbox") | 368 | if (temp.lower()=="inbox") |
369 | continue; | 369 | continue; |
370 | if (temp.lower()==account->getPrefix().lower()) | 370 | if (temp.lower()==account->getPrefix().lower()) |
371 | continue; | 371 | continue; |
372 | if ( (bflags = list->mb_flag) ) { | 372 | if ( (bflags = list->mb_flag) ) { |
373 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 373 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
374 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 374 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
375 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 375 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
376 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 376 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
377 | no_inferiors = true; | 377 | no_inferiors = true; |
378 | } | 378 | } |
379 | } | 379 | } |
380 | } | 380 | } |
381 | del = list->mb_delimiter; | 381 | del = list->mb_delimiter; |
382 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 382 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
383 | } | 383 | } |
384 | } else { | 384 | } else { |
385 | qDebug("error fetching folders "); | 385 | qDebug("error fetching folders "); |
386 | 386 | ||
387 | } | 387 | } |
388 | if (result) mailimap_list_result_free( result ); | 388 | if (result) mailimap_list_result_free( result ); |
389 | return folders; | 389 | return folders; |
390 | } | 390 | } |
391 | 391 | ||
392 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 392 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
393 | { | 393 | { |
394 | RecMail * m = 0; | 394 | RecMail * m = 0; |
395 | mailimap_msg_att_item *item=0; | 395 | mailimap_msg_att_item *item=0; |
396 | clistcell *current,*c,*cf; | 396 | clistcell *current,*c,*cf; |
397 | mailimap_msg_att_dynamic*flist; | 397 | mailimap_msg_att_dynamic*flist; |
398 | mailimap_flag_fetch*cflag; | 398 | mailimap_flag_fetch*cflag; |
399 | int size; | 399 | int size; |
400 | QBitArray mFlags(7); | 400 | QBitArray mFlags(7); |
401 | QStringList addresslist; | 401 | QStringList addresslist; |
402 | 402 | ||
403 | if (!m_att) { | 403 | if (!m_att) { |
404 | return m; | 404 | return m; |
405 | } | 405 | } |
406 | m = new RecMail(); | 406 | m = new RecMail(); |
407 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 407 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
408 | current = c; | 408 | current = c; |
409 | size = 0; | 409 | size = 0; |
410 | item = (mailimap_msg_att_item*)current->data; | 410 | item = (mailimap_msg_att_item*)current->data; |
411 | if ( !item ) | 411 | if ( !item ) |
412 | continue; | 412 | continue; |
413 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 413 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
414 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 414 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
415 | if (!flist || !flist->att_list) { | 415 | if (!flist || !flist->att_list) { |
416 | continue; | 416 | continue; |
417 | } | 417 | } |
418 | cf = flist->att_list->first; | 418 | cf = flist->att_list->first; |
419 | if( ! cf ) | 419 | if( ! cf ) |
420 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 420 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
421 | cflag = (mailimap_flag_fetch*)cf->data; | 421 | cflag = (mailimap_flag_fetch*)cf->data; |
422 | if( ! cflag ) | 422 | if( ! cflag ) |
423 | qDebug("imap:not cflag "); | 423 | qDebug("imap:not cflag "); |
424 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 424 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
425 | switch (cflag->fl_flag->fl_type) { | 425 | switch (cflag->fl_flag->fl_type) { |
426 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 426 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
427 | mFlags.setBit(FLAG_ANSWERED); | 427 | mFlags.setBit(FLAG_ANSWERED); |
428 | break; | 428 | break; |
429 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 429 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
430 | mFlags.setBit(FLAG_FLAGGED); | 430 | mFlags.setBit(FLAG_FLAGGED); |
431 | break; | 431 | break; |
432 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 432 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
433 | mFlags.setBit(FLAG_DELETED); | 433 | mFlags.setBit(FLAG_DELETED); |
434 | break; | 434 | break; |
435 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 435 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
436 | mFlags.setBit(FLAG_SEEN); | 436 | mFlags.setBit(FLAG_SEEN); |
437 | break; | 437 | break; |
438 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 438 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
439 | mFlags.setBit(FLAG_DRAFT); | 439 | mFlags.setBit(FLAG_DRAFT); |
440 | break; | 440 | break; |
441 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 441 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
442 | break; | 442 | break; |
443 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 443 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
444 | break; | 444 | break; |
445 | default: | 445 | default: |
446 | break; | 446 | break; |
447 | } | 447 | } |
448 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 448 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
449 | mFlags.setBit(FLAG_RECENT); | 449 | mFlags.setBit(FLAG_RECENT); |
450 | } | 450 | } |
451 | } | 451 | } |
452 | continue; | 452 | continue; |
453 | } | 453 | } |
454 | if ( item->att_data.att_static == NULL ) | 454 | if ( item->att_data.att_static == NULL ) |
455 | continue; | 455 | continue; |
456 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 456 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
457 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 457 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
458 | if ( head == NULL ) | 458 | if ( head == NULL ) |
459 | continue; | 459 | continue; |
460 | if ( head->env_date != NULL ) { | 460 | if ( head->env_date != NULL ) { |
461 | m->setDate(head->env_date); | 461 | m->setDate(head->env_date); |
462 | struct mailimf_date_time result; | 462 | struct mailimf_date_time result; |
463 | struct mailimf_date_time* date = &result; | 463 | struct mailimf_date_time* date = &result; |
464 | struct mailimf_date_time **re = &date; | 464 | struct mailimf_date_time **re = &date; |
465 | size_t length = m->getDate().length(); | 465 | size_t length = m->getDate().length(); |
466 | size_t index = 0; | 466 | size_t index = 0; |
467 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { | 467 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { |
468 | m->setDate( Genericwrapper::parseDateTime( date ) ); | 468 | m->setDate( Genericwrapper::parseDateTime( date ) ); |
469 | char tmp[23]; | 469 | char tmp[23]; |
470 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %05i", | 470 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %05i", |
471 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 471 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
472 | m->setIsoDate( QString( tmp ) ); | 472 | m->setIsoDate( QString( tmp ) ); |
473 | } else { | 473 | } else { |
474 | m->setIsoDate(head->env_date); | 474 | m->setIsoDate(head->env_date); |
475 | } | 475 | } |
476 | } | 476 | } |
477 | if ( head->env_subject != NULL ) | 477 | if ( head->env_subject != NULL ) |
478 | m->setSubject(convert_String((const char*)head->env_subject)); | 478 | m->setSubject(convert_String((const char*)head->env_subject)); |
479 | //m->setSubject(head->env_subject); | 479 | //m->setSubject(head->env_subject); |
480 | if (head->env_from!=NULL) { | 480 | if (head->env_from!=NULL) { |
481 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 481 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
482 | if (addresslist.count()) { | 482 | if (addresslist.count()) { |
483 | m->setFrom(addresslist.first()); | 483 | m->setFrom(addresslist.first()); |
484 | } | 484 | } |
485 | } | 485 | } |
486 | if (head->env_to!=NULL) { | 486 | if (head->env_to!=NULL) { |
487 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 487 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
488 | m->setTo(addresslist); | 488 | m->setTo(addresslist); |
489 | } | 489 | } |
490 | if (head->env_cc!=NULL) { | 490 | if (head->env_cc!=NULL) { |
491 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 491 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
492 | m->setCC(addresslist); | 492 | m->setCC(addresslist); |
493 | } | 493 | } |
494 | if (head->env_bcc!=NULL) { | 494 | if (head->env_bcc!=NULL) { |
495 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 495 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
496 | m->setBcc(addresslist); | 496 | m->setBcc(addresslist); |
497 | } | 497 | } |
498 | /* reply to address, eg. email. */ | 498 | /* reply to address, eg. email. */ |
499 | if (head->env_reply_to!=NULL) { | 499 | if (head->env_reply_to!=NULL) { |
500 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 500 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
501 | if (addresslist.count()) { | 501 | if (addresslist.count()) { |
502 | m->setReplyto(addresslist.first()); | 502 | m->setReplyto(addresslist.first()); |
503 | } | 503 | } |
504 | } | 504 | } |
505 | if (head->env_in_reply_to!=NULL) { | 505 | if (head->env_in_reply_to!=NULL) { |
506 | QString h(head->env_in_reply_to); | 506 | QString h(head->env_in_reply_to); |
507 | while (h.length()>0 && h[0]=='<') { | 507 | while (h.length()>0 && h[0]=='<') { |
508 | h.remove(0,1); | 508 | h.remove(0,1); |
509 | } | 509 | } |
510 | while (h.length()>0 && h[h.length()-1]=='>') { | 510 | while (h.length()>0 && h[h.length()-1]=='>') { |
511 | h.remove(h.length()-1,1); | 511 | h.remove(h.length()-1,1); |
512 | } | 512 | } |
513 | if (h.length()>0) { | 513 | if (h.length()>0) { |
514 | m->setInreply(QStringList(h)); | 514 | m->setInreply(QStringList(h)); |
515 | } | 515 | } |
516 | } | 516 | } |
517 | if (head->env_message_id != NULL) { | 517 | if (head->env_message_id != NULL) { |
518 | m->setMsgid(QString(head->env_message_id)); | 518 | m->setMsgid(QString(head->env_message_id)); |
519 | } | 519 | } |
520 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 520 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
521 | #if 0 | 521 | #if 0 |
522 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 522 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
523 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 523 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
524 | qDebug("time %s ",da.toString().latin1() ); | 524 | qDebug("time %s ",da.toString().latin1() ); |
525 | #endif | 525 | #endif |
526 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 526 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
527 | size = item->att_data.att_static->att_data.att_rfc822_size; | 527 | size = item->att_data.att_static->att_data.att_rfc822_size; |
528 | } | 528 | } |
529 | } | 529 | } |
530 | /* msg is already deleted */ | 530 | /* msg is already deleted */ |
531 | if (mFlags.testBit(FLAG_DELETED) && m) { | 531 | if (mFlags.testBit(FLAG_DELETED) && m) { |
532 | delete m; | 532 | delete m; |
533 | m = 0; | 533 | m = 0; |
534 | } | 534 | } |
535 | if (m) { | 535 | if (m) { |
536 | m->setFlags(mFlags); | 536 | m->setFlags(mFlags); |
537 | m->setMsgsize(size); | 537 | m->setMsgsize(size); |
538 | } | 538 | } |
539 | return m; | 539 | return m; |
540 | } | 540 | } |
541 | 541 | ||
542 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) | 542 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) |
543 | { | 543 | { |
544 | RecBodyP body = new RecBody(); | 544 | RecBodyP body = new RecBody(); |
545 | const char *mb; | 545 | const char *mb; |
546 | int err = MAILIMAP_NO_ERROR; | 546 | int err = MAILIMAP_NO_ERROR; |
547 | clist *result = 0; | 547 | clist *result = 0; |
548 | clistcell *current; | 548 | clistcell *current; |
549 | mailimap_fetch_att *fetchAtt = 0; | 549 | mailimap_fetch_att *fetchAtt = 0; |
550 | mailimap_fetch_type *fetchType = 0; | 550 | mailimap_fetch_type *fetchType = 0; |
551 | mailimap_set *set = 0; | 551 | mailimap_set *set = 0; |
552 | mailimap_body*body_desc = 0; | 552 | mailimap_body*body_desc = 0; |
553 | 553 | ||
554 | mb = mail->getMbox().latin1(); | 554 | mb = mail->getMbox().latin1(); |
555 | 555 | ||
556 | login(); | 556 | login(); |
557 | if (!m_imap) { | 557 | if (!m_imap) { |
558 | return body; | 558 | return body; |
559 | } | 559 | } |
560 | err = selectMbox(mail->getMbox()); | 560 | err = selectMbox(mail->getMbox()); |
561 | if ( err != MAILIMAP_NO_ERROR ) { | 561 | if ( err != MAILIMAP_NO_ERROR ) { |
562 | return body; | 562 | return body; |
563 | } | 563 | } |
564 | 564 | ||
565 | /* the range has to start at 1!!! not with 0!!!! */ | 565 | /* the range has to start at 1!!! not with 0!!!! */ |
566 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); | 566 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); |
567 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 567 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
568 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 568 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
569 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 569 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
570 | mailimap_set_free( set ); | 570 | mailimap_set_free( set ); |
571 | mailimap_fetch_type_free( fetchType ); | 571 | mailimap_fetch_type_free( fetchType ); |
572 | 572 | ||
573 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 573 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
574 | mailimap_msg_att * msg_att; | 574 | mailimap_msg_att * msg_att; |
575 | msg_att = (mailimap_msg_att*)current->data; | 575 | msg_att = (mailimap_msg_att*)current->data; |
576 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 576 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
577 | QValueList<int> path; | 577 | QValueList<int> path; |
578 | body_desc = item->att_data.att_static->att_data.att_body; | 578 | body_desc = item->att_data.att_static->att_data.att_body; |
579 | traverseBody(mail,body_desc,body,0,path); | 579 | traverseBody(mail,body_desc,body,0,path); |
580 | } else { | 580 | } else { |
581 | //odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; | 581 | //odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; |
582 | } | 582 | } |
583 | if (result) mailimap_fetch_list_free(result); | 583 | if (result) mailimap_fetch_list_free(result); |
584 | return body; | 584 | return body; |
585 | } | 585 | } |
586 | 586 | ||
587 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 587 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
588 | { | 588 | { |
589 | QStringList l; | 589 | QStringList l; |
590 | QString from; | 590 | QString from; |
591 | bool named_from; | 591 | bool named_from; |
592 | clistcell *current = NULL; | 592 | clistcell *current = NULL; |
593 | mailimap_address * current_address=NULL; | 593 | mailimap_address * current_address=NULL; |
594 | if (!list) { | 594 | if (!list) { |
595 | return l; | 595 | return l; |
596 | } | 596 | } |
597 | unsigned int count = 0; | 597 | unsigned int count = 0; |
598 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { | 598 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { |
599 | from = ""; | 599 | from = ""; |
600 | named_from = false; | 600 | named_from = false; |
601 | current_address=(mailimap_address*)current->data; | 601 | current_address=(mailimap_address*)current->data; |
602 | if (current_address->ad_personal_name){ | 602 | if (current_address->ad_personal_name){ |
603 | from+=convert_String((const char*)current_address->ad_personal_name); | 603 | from+=convert_String((const char*)current_address->ad_personal_name); |
604 | from+=" "; | 604 | from+=" "; |
605 | named_from = true; | 605 | named_from = true; |
606 | } | 606 | } |
607 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 607 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
608 | from+="<"; | 608 | from+="<"; |
609 | } | 609 | } |
610 | if (current_address->ad_mailbox_name) { | 610 | if (current_address->ad_mailbox_name) { |
611 | from+=QString(current_address->ad_mailbox_name); | 611 | from+=QString(current_address->ad_mailbox_name); |
612 | from+="@"; | 612 | from+="@"; |
613 | } | 613 | } |
614 | if (current_address->ad_host_name) { | 614 | if (current_address->ad_host_name) { |
615 | from+=QString(current_address->ad_host_name); | 615 | from+=QString(current_address->ad_host_name); |
616 | } | 616 | } |
617 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 617 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
618 | from+=">"; | 618 | from+=">"; |
619 | } | 619 | } |
620 | l.append(QString(from)); | 620 | l.append(QString(from)); |
621 | if (++count > 99) { | 621 | if (++count > 99) { |
622 | break; | 622 | break; |
623 | } | 623 | } |
624 | } | 624 | } |
625 | return l; | 625 | return l; |
626 | } | 626 | } |
627 | 627 | ||
628 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) | 628 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) |
629 | { | 629 | { |
630 | encodedString*res=new encodedString; | 630 | encodedString*res=new encodedString; |
631 | int err; | 631 | int err; |
632 | mailimap_fetch_type *fetchType; | 632 | mailimap_fetch_type *fetchType; |
633 | mailimap_set *set; | 633 | mailimap_set *set; |
634 | clistcell*current,*cur; | 634 | clistcell*current,*cur; |
635 | mailimap_section_part * section_part = 0; | 635 | mailimap_section_part * section_part = 0; |
636 | mailimap_section_spec * section_spec = 0; | 636 | mailimap_section_spec * section_spec = 0; |
637 | mailimap_section * section = 0; | 637 | mailimap_section * section = 0; |
638 | mailimap_fetch_att * fetch_att = 0; | 638 | mailimap_fetch_att * fetch_att = 0; |
639 | 639 | ||
640 | login(); | 640 | login(); |
641 | if (!m_imap) { | 641 | if (!m_imap) { |
642 | return res; | 642 | return res; |
643 | } | 643 | } |
644 | if (!internal_call) { | 644 | if (!internal_call) { |
645 | err = selectMbox(mail->getMbox()); | 645 | err = selectMbox(mail->getMbox()); |
646 | if ( err != MAILIMAP_NO_ERROR ) { | 646 | if ( err != MAILIMAP_NO_ERROR ) { |
647 | return res; | 647 | return res; |
648 | } | 648 | } |
649 | } | 649 | } |
650 | set = mailimap_set_new_single(mail->getNumber()); | 650 | set = mailimap_set_new_single(mail->getNumber()); |
651 | 651 | ||
652 | clist*id_list = 0; | 652 | clist*id_list = 0; |
653 | 653 | ||
654 | /* if path == empty then its a request for the whole rfc822 mail and generates | 654 | /* if path == empty then its a request for the whole rfc822 mail and generates |
655 | a "fetch <id> (body[])" statement on imap server */ | 655 | a "fetch <id> (body[])" statement on imap server */ |
656 | if (path.count()>0 ) { | 656 | if (path.count()>0 ) { |
657 | id_list = clist_new(); | 657 | id_list = clist_new(); |
658 | for (unsigned j=0; j < path.count();++j) { | 658 | for (unsigned j=0; j < path.count();++j) { |
659 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); | 659 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); |
660 | *p_id = path[j]; | 660 | *p_id = path[j]; |
661 | clist_append(id_list,p_id); | 661 | clist_append(id_list,p_id); |
662 | } | 662 | } |
663 | section_part = mailimap_section_part_new(id_list); | 663 | section_part = mailimap_section_part_new(id_list); |
664 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); | 664 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); |
665 | } | 665 | } |
666 | 666 | ||
667 | section = mailimap_section_new(section_spec); | 667 | section = mailimap_section_new(section_spec); |
668 | fetch_att = mailimap_fetch_att_new_body_section(section); | 668 | fetch_att = mailimap_fetch_att_new_body_section(section); |
669 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); | 669 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); |
670 | 670 | ||
671 | clist*result = 0; | 671 | clist*result = 0; |
672 | 672 | ||
673 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 673 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
674 | mailimap_set_free( set ); | 674 | mailimap_set_free( set ); |
675 | mailimap_fetch_type_free( fetchType ); | 675 | mailimap_fetch_type_free( fetchType ); |
676 | 676 | ||
677 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 677 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
678 | mailimap_msg_att * msg_att; | 678 | mailimap_msg_att * msg_att; |
679 | msg_att = (mailimap_msg_att*)current->data; | 679 | msg_att = (mailimap_msg_att*)current->data; |
680 | mailimap_msg_att_item*msg_att_item; | 680 | mailimap_msg_att_item*msg_att_item; |
681 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | 681 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { |
682 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | 682 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); |
683 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | 683 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { |
684 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 684 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
685 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 685 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
686 | /* detach - we take over the content */ | 686 | /* detach - we take over the content */ |
687 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 687 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
688 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); | 688 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); |
689 | } | 689 | } |
690 | } | 690 | } |
691 | } | 691 | } |
692 | } else { | 692 | } else { |
693 | ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; | 693 | ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; |
694 | } | 694 | } |
695 | if (result) mailimap_fetch_list_free(result); | 695 | if (result) mailimap_fetch_list_free(result); |
696 | return res; | 696 | return res; |
697 | } | 697 | } |
698 | 698 | ||
699 | /* current_recursion is for recursive calls. | 699 | /* current_recursion is for recursive calls. |
700 | current_count means the position inside the internal loop! */ | 700 | current_count means the position inside the internal loop! */ |
701 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, | 701 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, |
702 | int current_recursion,QValueList<int>recList,int current_count) | 702 | int current_recursion,QValueList<int>recList,int current_count) |
703 | { | 703 | { |
704 | if (!body || current_recursion>=10) { | 704 | if (!body || current_recursion>=10) { |
705 | return; | 705 | return; |
706 | } | 706 | } |
707 | switch (body->bd_type) { | 707 | switch (body->bd_type) { |
708 | case MAILIMAP_BODY_1PART: | 708 | case MAILIMAP_BODY_1PART: |
709 | { | 709 | { |
710 | QValueList<int>countlist = recList; | 710 | QValueList<int>countlist = recList; |
711 | countlist.append(current_count); | 711 | countlist.append(current_count); |
712 | RecPartP currentPart = new RecPart(); | 712 | RecPartP currentPart = new RecPart(); |
713 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; | 713 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; |
714 | QString id(""); | 714 | QString id(""); |
715 | currentPart->setPositionlist(countlist); | 715 | currentPart->setPositionlist(countlist); |
716 | for (unsigned int j = 0; j < countlist.count();++j) { | 716 | for (unsigned int j = 0; j < countlist.count();++j) { |
717 | id+=(j>0?" ":""); | 717 | id+=(j>0?" ":""); |
718 | id+=QString("%1").arg(countlist[j]); | 718 | id+=QString("%1").arg(countlist[j]); |
719 | } | 719 | } |
720 | //odebug << "ID = " << id.latin1() << "" << oendl; | 720 | //odebug << "ID = " << id.latin1() << "" << oendl; |
721 | currentPart->setIdentifier(id); | 721 | currentPart->setIdentifier(id); |
722 | fillSinglePart(currentPart,part1); | 722 | fillSinglePart(currentPart,part1); |
723 | /* important: Check for is NULL 'cause a body can be empty! | 723 | /* important: Check for is NULL 'cause a body can be empty! |
724 | And we put it only into the mail if it is the FIRST part */ | 724 | And we put it only into the mail if it is the FIRST part */ |
725 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { | 725 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { |
726 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); | 726 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); |
727 | target_body->setDescription(currentPart); | 727 | target_body->setDescription(currentPart); |
728 | target_body->setBodytext(body_text); | 728 | target_body->setBodytext(body_text); |
729 | if (countlist.count()>1) { | 729 | if (countlist.count()>1) { |
730 | target_body->addPart(currentPart); | 730 | target_body->addPart(currentPart); |
731 | } | 731 | } |
732 | } else { | 732 | } else { |
733 | target_body->addPart(currentPart); | 733 | target_body->addPart(currentPart); |
734 | } | 734 | } |
735 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { | 735 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { |
736 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); | 736 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); |
737 | } | 737 | } |
738 | } | 738 | } |
739 | break; | 739 | break; |
740 | case MAILIMAP_BODY_MPART: | 740 | case MAILIMAP_BODY_MPART: |
741 | { | 741 | { |
742 | QValueList<int>countlist = recList; | 742 | QValueList<int>countlist = recList; |
743 | clistcell*current=0; | 743 | clistcell*current=0; |
744 | mailimap_body*current_body=0; | 744 | mailimap_body*current_body=0; |
745 | unsigned int ccount = 1; | 745 | unsigned int ccount = 1; |
746 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; | 746 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; |
747 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { | 747 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { |
748 | current_body = (mailimap_body*)current->data; | 748 | current_body = (mailimap_body*)current->data; |
749 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 749 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
750 | RecPartP targetPart = new RecPart(); | 750 | RecPartP targetPart = new RecPart(); |
751 | targetPart->setType("multipart"); | 751 | targetPart->setType("multipart"); |
752 | fillMultiPart(targetPart,mailDescription); | 752 | fillMultiPart(targetPart,mailDescription); |
753 | countlist.append(current_count); | 753 | countlist.append(current_count); |
754 | targetPart->setPositionlist(countlist); | 754 | targetPart->setPositionlist(countlist); |
755 | target_body->addPart(targetPart); | 755 | target_body->addPart(targetPart); |
756 | QString id(""); | 756 | QString id(""); |
757 | for (unsigned int j = 0; j < countlist.count();++j) { | 757 | for (unsigned int j = 0; j < countlist.count();++j) { |
758 | id+=(j>0?" ":""); | 758 | id+=(j>0?" ":""); |
759 | id+=QString("%1").arg(countlist[j]); | 759 | id+=QString("%1").arg(countlist[j]); |
760 | } | 760 | } |
761 | // odebug << "ID(mpart) = " << id.latin1() << "" << oendl; | 761 | // odebug << "ID(mpart) = " << id.latin1() << "" << oendl; |
762 | } | 762 | } |
763 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); | 763 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); |
764 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 764 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
765 | countlist = recList; | 765 | countlist = recList; |
766 | } | 766 | } |
767 | ++ccount; | 767 | ++ccount; |
768 | } | 768 | } |
769 | } | 769 | } |
770 | break; | 770 | break; |
771 | default: | 771 | default: |
772 | break; | 772 | break; |
773 | } | 773 | } |
774 | } | 774 | } |
775 | 775 | ||
776 | void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) | 776 | void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) |
777 | { | 777 | { |
778 | if (!Description) { | 778 | if (!Description) { |
779 | return; | 779 | return; |
780 | } | 780 | } |
781 | switch (Description->bd_type) { | 781 | switch (Description->bd_type) { |
782 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 782 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
783 | target_part->setType("text"); | 783 | target_part->setType("text"); |
784 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); | 784 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); |
785 | break; | 785 | break; |
786 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | 786 | case MAILIMAP_BODY_TYPE_1PART_BASIC: |
787 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); | 787 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); |
788 | break; | 788 | break; |
789 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 789 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
790 | target_part->setType("message"); | 790 | target_part->setType("message"); |
791 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); | 791 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); |
792 | break; | 792 | break; |
793 | default: | 793 | default: |
794 | break; | 794 | break; |
795 | } | 795 | } |
796 | } | 796 | } |
797 | 797 | ||
798 | void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) | 798 | void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) |
799 | { | 799 | { |
800 | if (!which) { | 800 | if (!which) { |
801 | return; | 801 | return; |
802 | } | 802 | } |
803 | QString sub; | 803 | QString sub; |
804 | sub = which->bd_media_text; | 804 | sub = which->bd_media_text; |
805 | //odebug << "Type= text/" << which->bd_media_text << "" << oendl; | 805 | //odebug << "Type= text/" << which->bd_media_text << "" << oendl; |
806 | target_part->setSubtype(sub.lower()); | 806 | target_part->setSubtype(sub.lower()); |
807 | target_part->setLines(which->bd_lines); | 807 | target_part->setLines(which->bd_lines); |
808 | fillBodyFields(target_part,which->bd_fields); | 808 | fillBodyFields(target_part,which->bd_fields); |
809 | } | 809 | } |
810 | 810 | ||
811 | void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) | 811 | void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) |
812 | { | 812 | { |
813 | if (!which) { | 813 | if (!which) { |
814 | return; | 814 | return; |
815 | } | 815 | } |
816 | target_part->setSubtype("rfc822"); | 816 | target_part->setSubtype("rfc822"); |
817 | //odebug << "Message part" << oendl; | 817 | //odebug << "Message part" << oendl; |
818 | /* we set this type to text/plain */ | 818 | /* we set this type to text/plain */ |
819 | target_part->setLines(which->bd_lines); | 819 | target_part->setLines(which->bd_lines); |
820 | fillBodyFields(target_part,which->bd_fields); | 820 | fillBodyFields(target_part,which->bd_fields); |
821 | } | 821 | } |
822 | 822 | ||
823 | void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) | 823 | void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) |
824 | { | 824 | { |
825 | if (!which) return; | 825 | if (!which) return; |
826 | QString sub = which->bd_media_subtype; | 826 | QString sub = which->bd_media_subtype; |
827 | target_part->setSubtype(sub.lower()); | 827 | target_part->setSubtype(sub.lower()); |
828 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { | 828 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { |
829 | clistcell*cur = 0; | 829 | clistcell*cur = 0; |
830 | mailimap_single_body_fld_param*param=0; | 830 | mailimap_single_body_fld_param*param=0; |
831 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 831 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
832 | param = (mailimap_single_body_fld_param*)cur->data; | 832 | param = (mailimap_single_body_fld_param*)cur->data; |
833 | if (param) { | 833 | if (param) { |
834 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 834 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
835 | } | 835 | } |
836 | } | 836 | } |
837 | } | 837 | } |
838 | } | 838 | } |
839 | 839 | ||
840 | void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) | 840 | void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) |
841 | { | 841 | { |
842 | if (!which) { | 842 | if (!which) { |
843 | return; | 843 | return; |
844 | } | 844 | } |
845 | QString type,sub; | 845 | QString type,sub; |
846 | switch (which->bd_media_basic->med_type) { | 846 | switch (which->bd_media_basic->med_type) { |
847 | case MAILIMAP_MEDIA_BASIC_APPLICATION: | 847 | case MAILIMAP_MEDIA_BASIC_APPLICATION: |
848 | type = "application"; | 848 | type = "application"; |
849 | break; | 849 | break; |
850 | case MAILIMAP_MEDIA_BASIC_AUDIO: | 850 | case MAILIMAP_MEDIA_BASIC_AUDIO: |
851 | type = "audio"; | 851 | type = "audio"; |
852 | break; | 852 | break; |
853 | case MAILIMAP_MEDIA_BASIC_IMAGE: | 853 | case MAILIMAP_MEDIA_BASIC_IMAGE: |
854 | type = "image"; | 854 | type = "image"; |
855 | break; | 855 | break; |
856 | case MAILIMAP_MEDIA_BASIC_MESSAGE: | 856 | case MAILIMAP_MEDIA_BASIC_MESSAGE: |
857 | type = "message"; | 857 | type = "message"; |
858 | break; | 858 | break; |
859 | case MAILIMAP_MEDIA_BASIC_VIDEO: | 859 | case MAILIMAP_MEDIA_BASIC_VIDEO: |
860 | type = "video"; | 860 | type = "video"; |
861 | break; | 861 | break; |
862 | case MAILIMAP_MEDIA_BASIC_OTHER: | 862 | case MAILIMAP_MEDIA_BASIC_OTHER: |
863 | default: | 863 | default: |
864 | if (which->bd_media_basic->med_basic_type) { | 864 | if (which->bd_media_basic->med_basic_type) { |
865 | type = which->bd_media_basic->med_basic_type; | 865 | type = which->bd_media_basic->med_basic_type; |
866 | } else { | 866 | } else { |
867 | type = ""; | 867 | type = ""; |
868 | } | 868 | } |
869 | break; | 869 | break; |
870 | } | 870 | } |
871 | if (which->bd_media_basic->med_subtype) { | 871 | if (which->bd_media_basic->med_subtype) { |
872 | sub = which->bd_media_basic->med_subtype; | 872 | sub = which->bd_media_basic->med_subtype; |
873 | } else { | 873 | } else { |
874 | sub = ""; | 874 | sub = ""; |
875 | } | 875 | } |
876 | // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; | 876 | // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; |
877 | target_part->setType(type.lower()); | 877 | target_part->setType(type.lower()); |
878 | target_part->setSubtype(sub.lower()); | 878 | target_part->setSubtype(sub.lower()); |
879 | fillBodyFields(target_part,which->bd_fields); | 879 | fillBodyFields(target_part,which->bd_fields); |
880 | } | 880 | } |
881 | 881 | ||
882 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) | 882 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) |
883 | { | 883 | { |
884 | if (!which) return; | 884 | if (!which) return; |
885 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { | 885 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { |
886 | clistcell*cur; | 886 | clistcell*cur; |
887 | mailimap_single_body_fld_param*param=0; | 887 | mailimap_single_body_fld_param*param=0; |
888 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 888 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
889 | param = (mailimap_single_body_fld_param*)cur->data; | 889 | param = (mailimap_single_body_fld_param*)cur->data; |
890 | if (param) { | 890 | if (param) { |
891 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 891 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
892 | } | 892 | } |
893 | } | 893 | } |
894 | } | 894 | } |
895 | mailimap_body_fld_enc*enc = which->bd_encoding; | 895 | mailimap_body_fld_enc*enc = which->bd_encoding; |
896 | QString encoding(""); | 896 | QString encoding(""); |
897 | switch (enc->enc_type) { | 897 | switch (enc->enc_type) { |
898 | case MAILIMAP_BODY_FLD_ENC_7BIT: | 898 | case MAILIMAP_BODY_FLD_ENC_7BIT: |
899 | encoding = "7bit"; | 899 | encoding = "7bit"; |
900 | break; | 900 | break; |
901 | case MAILIMAP_BODY_FLD_ENC_8BIT: | 901 | case MAILIMAP_BODY_FLD_ENC_8BIT: |
902 | encoding = "8bit"; | 902 | encoding = "8bit"; |
903 | break; | 903 | break; |
904 | case MAILIMAP_BODY_FLD_ENC_BINARY: | 904 | case MAILIMAP_BODY_FLD_ENC_BINARY: |
905 | encoding="binary"; | 905 | encoding="binary"; |
906 | break; | 906 | break; |
907 | case MAILIMAP_BODY_FLD_ENC_BASE64: | 907 | case MAILIMAP_BODY_FLD_ENC_BASE64: |
908 | encoding="base64"; | 908 | encoding="base64"; |
909 | break; | 909 | break; |
910 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: | 910 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: |
911 | encoding="quoted-printable"; | 911 | encoding="quoted-printable"; |
912 | break; | 912 | break; |
913 | case MAILIMAP_BODY_FLD_ENC_OTHER: | 913 | case MAILIMAP_BODY_FLD_ENC_OTHER: |
914 | default: | 914 | default: |
915 | if (enc->enc_value) { | 915 | if (enc->enc_value) { |
916 | char*t=enc->enc_value; | 916 | char*t=enc->enc_value; |
917 | encoding=QString(enc->enc_value); | 917 | encoding=QString(enc->enc_value); |
918 | enc->enc_value=0L; | 918 | enc->enc_value=0L; |
919 | free(t); | 919 | free(t); |
920 | } | 920 | } |
921 | } | 921 | } |
922 | if (which->bd_description) { | 922 | if (which->bd_description) { |
923 | target_part->setDescription(QString(which->bd_description)); | 923 | target_part->setDescription(QString(which->bd_description)); |
924 | } | 924 | } |
925 | target_part->setEncoding(encoding); | 925 | target_part->setEncoding(encoding); |
926 | target_part->setSize(which->bd_size); | 926 | target_part->setSize(which->bd_size); |
927 | } | 927 | } |
928 | void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) | 928 | void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) |
929 | { | 929 | { |
930 | //#if 0 | 930 | //#if 0 |
931 | mailimap_flag_list*flist; | 931 | mailimap_flag_list*flist; |
932 | mailimap_set *set; | 932 | mailimap_set *set; |
933 | mailimap_store_att_flags * store_flags; | 933 | mailimap_store_att_flags * store_flags; |
934 | int err; | 934 | int err; |
935 | login(); | 935 | login(); |
936 | //#endif | 936 | //#endif |
937 | if (!m_imap) { | 937 | if (!m_imap) { |
938 | return; | 938 | return; |
939 | } | 939 | } |
940 | int iii = 0; | 940 | int iii = 0; |
941 | int count = target.count(); | 941 | int count = target.count(); |
942 | // qDebug("imap remove count %d ", count); | 942 | // qDebug("imap remove count %d ", count); |
943 | 943 | ||
944 | 944 | ||
945 | mMax = count; | 945 | mMax = count; |
946 | //progress( tr("Delete")); | 946 | //progress( tr("Delete")); |
947 | QWidget wid; | 947 | QWidget wid; |
948 | wid.show(); | 948 | wid.show(); |
949 | while (iii < count ) { | 949 | while (iii < count ) { |
950 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); | 950 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); |
951 | wid.raise(); | 951 | wid.raise(); |
952 | qApp->processEvents(); | 952 | qApp->processEvents(); |
953 | RecMailP mail = (*target.at( iii )); | 953 | RecMailP mail = (*target.at( iii )); |
954 | //#if 0 | 954 | //#if 0 |
955 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); | 955 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); |
956 | err = selectMbox(mail->getMbox()); | 956 | err = selectMbox(mail->getMbox()); |
957 | if ( err != MAILIMAP_NO_ERROR ) { | 957 | if ( err != MAILIMAP_NO_ERROR ) { |
958 | return; | 958 | return; |
959 | } | 959 | } |
960 | flist = mailimap_flag_list_new_empty(); | 960 | flist = mailimap_flag_list_new_empty(); |
961 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 961 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
962 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 962 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
963 | set = mailimap_set_new_single(mail->getNumber()); | 963 | set = mailimap_set_new_single(mail->getNumber()); |
964 | err = mailimap_store(m_imap,set,store_flags); | 964 | err = mailimap_store(m_imap,set,store_flags); |
965 | mailimap_set_free( set ); | 965 | mailimap_set_free( set ); |
966 | mailimap_store_att_flags_free(store_flags); | 966 | mailimap_store_att_flags_free(store_flags); |
967 | 967 | ||
968 | if (err != MAILIMAP_NO_ERROR) { | 968 | if (err != MAILIMAP_NO_ERROR) { |
969 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 969 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
970 | return; | 970 | return; |
971 | } | 971 | } |
972 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 972 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
973 | /* should we realy do that at this moment? */ | 973 | /* should we realy do that at this moment? */ |
974 | 974 | ||
975 | // err = mailimap_expunge(m_imap); | 975 | // err = mailimap_expunge(m_imap); |
976 | //if (err != MAILIMAP_NO_ERROR) { | 976 | //if (err != MAILIMAP_NO_ERROR) { |
977 | // Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response)); | 977 | // Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response)); |
978 | // } | 978 | // } |
979 | //#endif | 979 | //#endif |
980 | //deleteMail( mail); | 980 | //deleteMail( mail); |
981 | ++iii; | 981 | ++iii; |
982 | } | 982 | } |
983 | //qDebug("Deleting imap mails... "); | 983 | //qDebug("Deleting imap mails... "); |
984 | err = mailimap_expunge(m_imap); | 984 | err = mailimap_expunge(m_imap); |
985 | if (err != MAILIMAP_NO_ERROR) { | 985 | if (err != MAILIMAP_NO_ERROR) { |
986 | Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response)); | 986 | Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response)); |
987 | } | 987 | } |
988 | } | 988 | } |
989 | void IMAPwrapper::deleteMail(const RecMailP&mail) | 989 | void IMAPwrapper::deleteMail(const RecMailP&mail) |
990 | { | 990 | { |
991 | mailimap_flag_list*flist; | 991 | mailimap_flag_list*flist; |
992 | mailimap_set *set; | 992 | mailimap_set *set; |
993 | mailimap_store_att_flags * store_flags; | 993 | mailimap_store_att_flags * store_flags; |
994 | int err; | 994 | int err; |
995 | login(); | 995 | login(); |
996 | if (!m_imap) { | 996 | if (!m_imap) { |
997 | return; | 997 | return; |
998 | } | 998 | } |
999 | err = selectMbox(mail->getMbox()); | 999 | err = selectMbox(mail->getMbox()); |
1000 | if ( err != MAILIMAP_NO_ERROR ) { | 1000 | if ( err != MAILIMAP_NO_ERROR ) { |
1001 | return; | 1001 | return; |
1002 | } | 1002 | } |
1003 | flist = mailimap_flag_list_new_empty(); | 1003 | flist = mailimap_flag_list_new_empty(); |
1004 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 1004 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
1005 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 1005 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
1006 | set = mailimap_set_new_single(mail->getNumber()); | 1006 | set = mailimap_set_new_single(mail->getNumber()); |
1007 | err = mailimap_store(m_imap,set,store_flags); | 1007 | err = mailimap_store(m_imap,set,store_flags); |
1008 | mailimap_set_free( set ); | 1008 | mailimap_set_free( set ); |
1009 | mailimap_store_att_flags_free(store_flags); | 1009 | mailimap_store_att_flags_free(store_flags); |
1010 | 1010 | ||
1011 | if (err != MAILIMAP_NO_ERROR) { | 1011 | if (err != MAILIMAP_NO_ERROR) { |
1012 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 1012 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
1013 | return; | 1013 | return; |
1014 | } | 1014 | } |
1015 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1015 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1016 | /* should we realy do that at this moment? */ | 1016 | /* should we realy do that at this moment? */ |
1017 | 1017 | ||
1018 | err = mailimap_expunge(m_imap); | 1018 | err = mailimap_expunge(m_imap); |
1019 | if (err != MAILIMAP_NO_ERROR) { | 1019 | if (err != MAILIMAP_NO_ERROR) { |
1020 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 1020 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
1021 | } | 1021 | } |
1022 | //qDebug("IMAPwrapper::deleteMail 2"); | 1022 | //qDebug("IMAPwrapper::deleteMail 2"); |
1023 | 1023 | ||
1024 | } | 1024 | } |
1025 | 1025 | ||
1026 | void IMAPwrapper::answeredMail(const RecMailP&mail) | 1026 | void IMAPwrapper::answeredMail(const RecMailP&mail) |
1027 | { | 1027 | { |
1028 | mailimap_flag_list*flist; | 1028 | mailimap_flag_list*flist; |
1029 | mailimap_set *set; | 1029 | mailimap_set *set; |
1030 | mailimap_store_att_flags * store_flags; | 1030 | mailimap_store_att_flags * store_flags; |
1031 | int err; | 1031 | int err; |
1032 | login(); | 1032 | login(); |
1033 | if (!m_imap) { | 1033 | if (!m_imap) { |
1034 | return; | 1034 | return; |
1035 | } | 1035 | } |
1036 | err = selectMbox(mail->getMbox()); | 1036 | err = selectMbox(mail->getMbox()); |
1037 | if ( err != MAILIMAP_NO_ERROR ) { | 1037 | if ( err != MAILIMAP_NO_ERROR ) { |
1038 | return; | 1038 | return; |
1039 | } | 1039 | } |
1040 | flist = mailimap_flag_list_new_empty(); | 1040 | flist = mailimap_flag_list_new_empty(); |
1041 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); | 1041 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); |
1042 | store_flags = mailimap_store_att_flags_new_add_flags(flist); | 1042 | store_flags = mailimap_store_att_flags_new_add_flags(flist); |
1043 | set = mailimap_set_new_single(mail->getNumber()); | 1043 | set = mailimap_set_new_single(mail->getNumber()); |
1044 | err = mailimap_store(m_imap,set,store_flags); | 1044 | err = mailimap_store(m_imap,set,store_flags); |
1045 | mailimap_set_free( set ); | 1045 | mailimap_set_free( set ); |
1046 | mailimap_store_att_flags_free(store_flags); | 1046 | mailimap_store_att_flags_free(store_flags); |
1047 | 1047 | ||
1048 | if (err != MAILIMAP_NO_ERROR) { | 1048 | if (err != MAILIMAP_NO_ERROR) { |
1049 | // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; | 1049 | // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; |
1050 | return; | 1050 | return; |
1051 | } | 1051 | } |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | 1054 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) |
1055 | { | 1055 | { |
1056 | QString body(""); | 1056 | QString body(""); |
1057 | encodedString*res = fetchRawPart(mail,path,internal_call); | 1057 | encodedString*res = fetchRawPart(mail,path,internal_call); |
1058 | encodedString*r = decode_String(res,enc); | 1058 | encodedString*r = decode_String(res,enc); |
1059 | delete res; | 1059 | delete res; |
1060 | if (r) { | 1060 | if (r) { |
1061 | if (r->Length()>0) { | 1061 | if (r->Length()>0) { |
1062 | body = r->Content(); | 1062 | body = r->Content(); |
1063 | } | 1063 | } |
1064 | delete r; | 1064 | delete r; |
1065 | } | 1065 | } |
1066 | return body; | 1066 | return body; |
1067 | } | 1067 | } |
1068 | 1068 | ||
1069 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) | 1069 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) |
1070 | { | 1070 | { |
1071 | return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); | 1071 | return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); |
1072 | } | 1072 | } |
1073 | 1073 | ||
1074 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) | 1074 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) |
1075 | { | 1075 | { |
1076 | encodedString*res = fetchRawPart(mail,part->Positionlist(),false); | 1076 | encodedString*res = fetchRawPart(mail,part->Positionlist(),false); |
1077 | encodedString*r = decode_String(res,part->Encoding()); | 1077 | encodedString*r = decode_String(res,part->Encoding()); |
1078 | delete res; | 1078 | delete res; |
1079 | return r; | 1079 | return r; |
1080 | } | 1080 | } |
1081 | 1081 | ||
1082 | encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part) | 1082 | encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part) |
1083 | { | 1083 | { |
1084 | return fetchRawPart(mail,part->Positionlist(),false); | 1084 | return fetchRawPart(mail,part->Positionlist(),false); |
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | int IMAPwrapper::deleteAllMail(const FolderP&folder) | 1087 | int IMAPwrapper::deleteAllMail(const FolderP&folder) |
1088 | { | 1088 | { |
1089 | login(); | 1089 | login(); |
1090 | if (!m_imap) { | 1090 | if (!m_imap) { |
1091 | return 0; | 1091 | return 0; |
1092 | } | 1092 | } |
1093 | mailimap_flag_list*flist; | 1093 | mailimap_flag_list*flist; |
1094 | mailimap_set *set; | 1094 | mailimap_set *set; |
1095 | mailimap_store_att_flags * store_flags; | 1095 | mailimap_store_att_flags * store_flags; |
1096 | int err = selectMbox(folder->getName()); | 1096 | int err = selectMbox(folder->getName()); |
1097 | if ( err != MAILIMAP_NO_ERROR ) { | 1097 | if ( err != MAILIMAP_NO_ERROR ) { |
1098 | return 0; | 1098 | return 0; |
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | int last = m_imap->imap_selection_info->sel_exists; | 1101 | int last = m_imap->imap_selection_info->sel_exists; |
1102 | if (last == 0) { | 1102 | if (last == 0) { |
1103 | Global::statusMessage(tr("Mailbox has no mails!")); | 1103 | Global::statusMessage(tr("Mailbox has no mails!")); |
1104 | return 0; | 1104 | return 0; |
1105 | } | 1105 | } |
1106 | flist = mailimap_flag_list_new_empty(); | 1106 | flist = mailimap_flag_list_new_empty(); |
1107 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 1107 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
1108 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 1108 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
1109 | set = mailimap_set_new_interval( 1, last ); | 1109 | set = mailimap_set_new_interval( 1, last ); |
1110 | err = mailimap_store(m_imap,set,store_flags); | 1110 | err = mailimap_store(m_imap,set,store_flags); |
1111 | mailimap_set_free( set ); | 1111 | mailimap_set_free( set ); |
1112 | mailimap_store_att_flags_free(store_flags); | 1112 | mailimap_store_att_flags_free(store_flags); |
1113 | if (err != MAILIMAP_NO_ERROR) { | 1113 | if (err != MAILIMAP_NO_ERROR) { |
1114 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 1114 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
1115 | return 0; | 1115 | return 0; |
1116 | } | 1116 | } |
1117 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1117 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1118 | /* should we realy do that at this moment? */ | 1118 | /* should we realy do that at this moment? */ |
1119 | err = mailimap_expunge(m_imap); | 1119 | err = mailimap_expunge(m_imap); |
1120 | if (err != MAILIMAP_NO_ERROR) { | 1120 | if (err != MAILIMAP_NO_ERROR) { |
1121 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 1121 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
1122 | return 0; | 1122 | return 0; |
1123 | } | 1123 | } |
1124 | // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; | 1124 | // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; |
1125 | return 1; | 1125 | return 1; |
1126 | } | 1126 | } |
1127 | 1127 | ||
1128 | int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) | 1128 | int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) |
1129 | { | 1129 | { |
1130 | if (folder.length()==0) return 0; | 1130 | if (folder.length()==0) return 0; |
1131 | login(); | 1131 | login(); |
1132 | if (!m_imap) {return 0;} | 1132 | if (!m_imap) {return 0;} |
1133 | QString pre = account->getPrefix(); | 1133 | QString pre = account->getPrefix(); |
1134 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { | 1134 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { |
1135 | pre+=delemiter; | 1135 | pre+=delemiter; |
1136 | } | 1136 | } |
1137 | if (parentfolder) { | 1137 | if (parentfolder) { |
1138 | pre += parentfolder->getDisplayName()+delemiter; | 1138 | pre += parentfolder->getDisplayName()+delemiter; |
1139 | } | 1139 | } |
1140 | pre+=folder; | 1140 | pre+=folder; |
1141 | if (getsubfolder) { | 1141 | if (getsubfolder) { |
1142 | if (delemiter.length()>0) { | 1142 | if (delemiter.length()>0) { |
1143 | pre+=delemiter; | 1143 | pre+=delemiter; |
1144 | } else { | 1144 | } else { |
1145 | Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); | 1145 | Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); |
1146 | return 0; | 1146 | return 0; |
1147 | } | 1147 | } |
1148 | } | 1148 | } |
1149 | // odebug << "Creating " << pre.latin1() << "" << oendl; | 1149 | // odebug << "Creating " << pre.latin1() << "" << oendl; |
1150 | int res = mailimap_create(m_imap,pre.latin1()); | 1150 | int res = mailimap_create(m_imap,pre.latin1()); |
1151 | if (res != MAILIMAP_NO_ERROR) { | 1151 | if (res != MAILIMAP_NO_ERROR) { |
1152 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 1152 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
1153 | return 0; | 1153 | return 0; |
1154 | } | 1154 | } |
1155 | return 1; | 1155 | return 1; |
1156 | } | 1156 | } |
1157 | 1157 | ||
1158 | int IMAPwrapper::deleteMbox(const FolderP&folder) | 1158 | int IMAPwrapper::deleteMbox(const FolderP&folder) |
1159 | { | 1159 | { |
1160 | if (!folder) return 0; | 1160 | if (!folder) return 0; |
1161 | login(); | 1161 | login(); |
1162 | if (!m_imap) {return 0;} | 1162 | if (!m_imap) {return 0;} |
1163 | int res = mailimap_delete(m_imap,folder->getName()); | 1163 | int res = mailimap_delete(m_imap,folder->getName()); |
1164 | if (res != MAILIMAP_NO_ERROR) { | 1164 | if (res != MAILIMAP_NO_ERROR) { |
1165 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 1165 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
1166 | return 0; | 1166 | return 0; |
1167 | } | 1167 | } |
1168 | return 1; | 1168 | return 1; |
1169 | } | 1169 | } |
1170 | 1170 | ||
1171 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 1171 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
1172 | { | 1172 | { |
1173 | mailimap_status_att_list * att_list =0; | 1173 | mailimap_status_att_list * att_list =0; |
1174 | mailimap_mailbox_data_status * status=0; | 1174 | mailimap_mailbox_data_status * status=0; |
1175 | clistiter * cur = 0; | 1175 | clistiter * cur = 0; |
1176 | int r = 0; | 1176 | int r = 0; |
1177 | target_stat.message_count = 0; | 1177 | target_stat.message_count = 0; |
1178 | target_stat.message_unseen = 0; | 1178 | target_stat.message_unseen = 0; |
1179 | target_stat.message_recent = 0; | 1179 | target_stat.message_recent = 0; |
1180 | login(); | 1180 | login(); |
1181 | if (!m_imap) { | 1181 | if (!m_imap) { |
1182 | return; | 1182 | return; |
1183 | } | 1183 | } |
1184 | att_list = mailimap_status_att_list_new_empty(); | 1184 | att_list = mailimap_status_att_list_new_empty(); |
1185 | if (!att_list) return; | 1185 | if (!att_list) return; |
1186 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); | 1186 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); |
1187 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); | 1187 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); |
1188 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); | 1188 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); |
1189 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); | 1189 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); |
1190 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { | 1190 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { |
1191 | for (cur = clist_begin(status->st_info_list); | 1191 | for (cur = clist_begin(status->st_info_list); |
1192 | cur != NULL ; cur = clist_next(cur)) { | 1192 | cur != NULL ; cur = clist_next(cur)) { |
1193 | mailimap_status_info * status_info; | 1193 | mailimap_status_info * status_info; |
1194 | status_info = (mailimap_status_info *)clist_content(cur); | 1194 | status_info = (mailimap_status_info *)clist_content(cur); |
1195 | switch (status_info->st_att) { | 1195 | switch (status_info->st_att) { |
1196 | case MAILIMAP_STATUS_ATT_MESSAGES: | 1196 | case MAILIMAP_STATUS_ATT_MESSAGES: |
1197 | target_stat.message_count = status_info->st_value; | 1197 | target_stat.message_count = status_info->st_value; |
1198 | break; | 1198 | break; |
1199 | case MAILIMAP_STATUS_ATT_RECENT: | 1199 | case MAILIMAP_STATUS_ATT_RECENT: |
1200 | target_stat.message_recent = status_info->st_value; | 1200 | target_stat.message_recent = status_info->st_value; |
1201 | break; | 1201 | break; |
1202 | case MAILIMAP_STATUS_ATT_UNSEEN: | 1202 | case MAILIMAP_STATUS_ATT_UNSEEN: |
1203 | target_stat.message_unseen = status_info->st_value; | 1203 | target_stat.message_unseen = status_info->st_value; |
1204 | break; | 1204 | break; |
1205 | } | 1205 | } |
1206 | } | 1206 | } |
1207 | } else { | 1207 | } else { |
1208 | // odebug << "Error retrieving status" << oendl; | 1208 | // odebug << "Error retrieving status" << oendl; |
1209 | } | 1209 | } |
1210 | if (status) mailimap_mailbox_data_status_free(status); | 1210 | if (status) mailimap_mailbox_data_status_free(status); |
1211 | if (att_list) mailimap_status_att_list_free(att_list); | 1211 | if (att_list) mailimap_status_att_list_free(att_list); |
1212 | } | 1212 | } |
1213 | 1213 | ||
1214 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 1214 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
1215 | { | 1215 | { |
1216 | login(); | 1216 | login(); |
1217 | if (!m_imap) return; | 1217 | if (!m_imap) return; |
1218 | if (!msg) return; | 1218 | if (!msg) return; |
1219 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); | 1219 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); |
1220 | if (r != MAILIMAP_NO_ERROR) { | 1220 | if (r != MAILIMAP_NO_ERROR) { |
1221 | Global::statusMessage("Error storing mail!"); | 1221 | Global::statusMessage("Error storing mail!"); |
1222 | } | 1222 | } |
1223 | } | 1223 | } |
1224 | 1224 | ||
1225 | MAILLIB::ATYPE IMAPwrapper::getType()const | 1225 | MAILLIB::ATYPE IMAPwrapper::getType()const |
1226 | { | 1226 | { |
1227 | return account->getType(); | 1227 | return account->getType(); |
1228 | } | 1228 | } |
1229 | 1229 | ||
1230 | const QString&IMAPwrapper::getName()const | 1230 | const QString&IMAPwrapper::getName()const |
1231 | { | 1231 | { |
1232 | // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; | 1232 | // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; |
1233 | return account->getAccountName(); | 1233 | return account->getAccountName(); |
1234 | } | 1234 | } |
1235 | 1235 | ||
1236 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) | 1236 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) |
1237 | { | 1237 | { |
1238 | // dummy | 1238 | // dummy |
1239 | QValueList<int> path; | 1239 | QValueList<int> path; |
1240 | return fetchRawPart(mail,path,false); | 1240 | return fetchRawPart(mail,path,false); |
1241 | } | 1241 | } |
1242 | 1242 | ||
1243 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, | 1243 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, |
1244 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) | 1244 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) |
1245 | { | 1245 | { |
1246 | if (targetWrapper != this || maxSizeInKb > 0 ) { | 1246 | if (targetWrapper != this || maxSizeInKb > 0 ) { |
1247 | mMax = 0; | 1247 | mMax = 0; |
1248 | progress( tr("Copy")); | 1248 | progress( tr("Copy")); |
1249 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); | 1249 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); |
1250 | qDebug("IMAPwrapper::mvcpAllMails::Using generic"); | 1250 | //qDebug("IMAPwrapper::mvcpAllMails::Using generic"); |
1251 | // odebug << "Using generic" << oendl; | 1251 | // odebug << "Using generic" << oendl; |
1252 | return; | 1252 | return; |
1253 | } | 1253 | } |
1254 | mailimap_set *set = 0; | 1254 | mailimap_set *set = 0; |
1255 | login(); | 1255 | login(); |
1256 | if (!m_imap) { | 1256 | if (!m_imap) { |
1257 | return; | 1257 | return; |
1258 | } | 1258 | } |
1259 | int err = selectMbox(fromFolder->getName()); | 1259 | int err = selectMbox(fromFolder->getName()); |
1260 | if ( err != MAILIMAP_NO_ERROR ) { | 1260 | if ( err != MAILIMAP_NO_ERROR ) { |
1261 | return; | 1261 | return; |
1262 | } | 1262 | } |
1263 | Global::statusMessage( tr("Copying mails on server...") ); | 1263 | Global::statusMessage( tr("Copying mails on server...") ); |
1264 | int last = m_imap->imap_selection_info->sel_exists; | 1264 | int last = m_imap->imap_selection_info->sel_exists; |
1265 | set = mailimap_set_new_interval( 1, last ); | 1265 | set = mailimap_set_new_interval( 1, last ); |
1266 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1266 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1267 | mailimap_set_free( set ); | 1267 | mailimap_set_free( set ); |
1268 | if ( err != MAILIMAP_NO_ERROR ) { | 1268 | if ( err != MAILIMAP_NO_ERROR ) { |
1269 | QString error_msg = tr("Error copy mails: %1").arg(m_imap->imap_response); | 1269 | QString error_msg = tr("Error copy mails: %1").arg(m_imap->imap_response); |
1270 | Global::statusMessage(error_msg); | 1270 | Global::statusMessage(error_msg); |
1271 | // odebug << error_msg << oendl; | 1271 | // odebug << error_msg << oendl; |
1272 | return; | 1272 | return; |
1273 | } | 1273 | } |
1274 | if (moveit) { | 1274 | if (moveit) { |
1275 | deleteAllMail(fromFolder); | 1275 | deleteAllMail(fromFolder); |
1276 | } | 1276 | } |
1277 | } | 1277 | } |
1278 | 1278 | ||
1279 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1279 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1280 | { | 1280 | { |
1281 | if (targetWrapper != this) { | 1281 | if (targetWrapper != this) { |
1282 | // odebug << "Using generic" << oendl; | 1282 | // odebug << "Using generic" << oendl; |
1283 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 1283 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
1284 | return; | 1284 | return; |
1285 | } | 1285 | } |
1286 | mailimap_set *set = 0; | 1286 | mailimap_set *set = 0; |
1287 | login(); | 1287 | login(); |
1288 | if (!m_imap) { | 1288 | if (!m_imap) { |
1289 | return; | 1289 | return; |
1290 | } | 1290 | } |
1291 | int err = selectMbox(mail->getMbox()); | 1291 | int err = selectMbox(mail->getMbox()); |
1292 | if ( err != MAILIMAP_NO_ERROR ) { | 1292 | if ( err != MAILIMAP_NO_ERROR ) { |
1293 | return; | 1293 | return; |
1294 | } | 1294 | } |
1295 | set = mailimap_set_new_single(mail->getNumber()); | 1295 | set = mailimap_set_new_single(mail->getNumber()); |
1296 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1296 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1297 | mailimap_set_free( set ); | 1297 | mailimap_set_free( set ); |
1298 | if ( err != MAILIMAP_NO_ERROR ) { | 1298 | if ( err != MAILIMAP_NO_ERROR ) { |
1299 | QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); | 1299 | QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); |
1300 | Global::statusMessage(error_msg); | 1300 | Global::statusMessage(error_msg); |
1301 | // odebug << error_msg << oendl; | 1301 | // odebug << error_msg << oendl; |
1302 | return; | 1302 | return; |
1303 | } | 1303 | } |
1304 | if (moveit) { | 1304 | if (moveit) { |
1305 | deleteMail(mail); | 1305 | deleteMail(mail); |
1306 | } | 1306 | } |
1307 | } | 1307 | } |
diff --git a/kmicromail/libmailwrapper/mhwrapper.cpp b/kmicromail/libmailwrapper/mhwrapper.cpp index 962dac0..641d4d9 100644 --- a/kmicromail/libmailwrapper/mhwrapper.cpp +++ b/kmicromail/libmailwrapper/mhwrapper.cpp | |||
@@ -1,448 +1,446 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "mhwrapper.h" | 2 | #include "mhwrapper.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include <libetpan/libetpan.h> | 5 | #include <libetpan/libetpan.h> |
6 | #include <qdir.h> | 6 | #include <qdir.h> |
7 | #include <qmessagebox.h> | 7 | #include <qmessagebox.h> |
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | #include <qpe/global.h> | 9 | #include <qpe/global.h> |
10 | #include <oprocess.h> | 10 | #include <oprocess.h> |
11 | //#include <opie2/odebug.h> | 11 | //#include <opie2/odebug.h> |
12 | 12 | ||
13 | using namespace Opie::Core; | 13 | using namespace Opie::Core; |
14 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) | 14 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) |
15 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) | 15 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) |
16 | { | 16 | { |
17 | if (MHPath.length()>0) { | 17 | if (MHPath.length()>0) { |
18 | if (MHPath[MHPath.length()-1]=='/') { | 18 | if (MHPath[MHPath.length()-1]=='/') { |
19 | MHPath=MHPath.left(MHPath.length()-1); | 19 | MHPath=MHPath.left(MHPath.length()-1); |
20 | } | 20 | } |
21 | //odebug << MHPath << oendl; | 21 | //odebug << MHPath << oendl; |
22 | QDir dir(MHPath); | 22 | QDir dir(MHPath); |
23 | if (!dir.exists()) { | 23 | if (!dir.exists()) { |
24 | dir.mkdir(MHPath); | 24 | dir.mkdir(MHPath); |
25 | } | 25 | } |
26 | init_storage(); | 26 | init_storage(); |
27 | } | 27 | } |
28 | } | 28 | } |
29 | 29 | ||
30 | void MHwrapper::init_storage() | 30 | void MHwrapper::init_storage() |
31 | { | 31 | { |
32 | int r; | 32 | int r; |
33 | QString pre = MHPath; | 33 | QString pre = MHPath; |
34 | if (!m_storage) { | 34 | if (!m_storage) { |
35 | m_storage = mailstorage_new(NULL); | 35 | m_storage = mailstorage_new(NULL); |
36 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); | 36 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); |
37 | if (r != MAIL_NO_ERROR) { | 37 | if (r != MAIL_NO_ERROR) { |
38 | qDebug(" error init storage "); | 38 | qDebug(" error init storage "); |
39 | mailstorage_free(m_storage); | 39 | mailstorage_free(m_storage); |
40 | m_storage = 0; | 40 | m_storage = 0; |
41 | return; | 41 | return; |
42 | } | 42 | } |
43 | } | 43 | } |
44 | r = mailstorage_connect(m_storage); | 44 | r = mailstorage_connect(m_storage); |
45 | if (r!=MAIL_NO_ERROR) { | 45 | if (r!=MAIL_NO_ERROR) { |
46 | qDebug("error connecting storage "); | 46 | qDebug("error connecting storage "); |
47 | mailstorage_free(m_storage); | 47 | mailstorage_free(m_storage); |
48 | m_storage = 0; | 48 | m_storage = 0; |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | void MHwrapper::clean_storage() | 52 | void MHwrapper::clean_storage() |
53 | { | 53 | { |
54 | if (m_storage) { | 54 | if (m_storage) { |
55 | mailstorage_disconnect(m_storage); | 55 | mailstorage_disconnect(m_storage); |
56 | mailstorage_free(m_storage); | 56 | mailstorage_free(m_storage); |
57 | m_storage = 0; | 57 | m_storage = 0; |
58 | } | 58 | } |
59 | } | 59 | } |
60 | 60 | ||
61 | MHwrapper::~MHwrapper() | 61 | MHwrapper::~MHwrapper() |
62 | { | 62 | { |
63 | clean_storage(); | 63 | clean_storage(); |
64 | } | 64 | } |
65 | 65 | ||
66 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) | 66 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) |
67 | { | 67 | { |
68 | qDebug("MHwrapper::listMessages "); | ||
69 | init_storage(); | 68 | init_storage(); |
70 | if (!m_storage) { | 69 | if (!m_storage) { |
71 | return; | 70 | return; |
72 | } | 71 | } |
73 | QString f = buildPath(mailbox); | 72 | QString f = buildPath(mailbox); |
74 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 73 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
75 | if (r!=MAIL_NO_ERROR) { | 74 | if (r!=MAIL_NO_ERROR) { |
76 | qDebug("listMessages: error selecting folder! "); | 75 | qDebug("listMessages: error selecting folder! "); |
77 | return; | 76 | return; |
78 | } | 77 | } |
79 | parseList(target,m_storage->sto_session,f, false, maxSizeInKb ); | 78 | parseList(target,m_storage->sto_session,f, false, maxSizeInKb ); |
80 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); | 79 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); |
81 | } | 80 | } |
82 | 81 | ||
83 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() | 82 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() |
84 | { | 83 | { |
85 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 84 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); |
86 | /* this is needed! */ | 85 | /* this is needed! */ |
87 | if (m_storage) mailstorage_disconnect(m_storage); | 86 | if (m_storage) mailstorage_disconnect(m_storage); |
88 | init_storage(); | 87 | init_storage(); |
89 | if (!m_storage) { | 88 | if (!m_storage) { |
90 | return folders; | 89 | return folders; |
91 | } | 90 | } |
92 | mail_list*flist = 0; | 91 | mail_list*flist = 0; |
93 | clistcell*current=0; | 92 | clistcell*current=0; |
94 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); | 93 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); |
95 | if (r != MAIL_NO_ERROR || !flist) { | 94 | if (r != MAIL_NO_ERROR || !flist) { |
96 | qDebug("error getting folder list "); | 95 | qDebug("error getting folder list "); |
97 | return folders; | 96 | return folders; |
98 | } | 97 | } |
99 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { | 98 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { |
100 | QString t = (char*)current->data; | 99 | QString t = (char*)current->data; |
101 | t.replace(0,MHPath.length(),""); | 100 | t.replace(0,MHPath.length(),""); |
102 | folders->append(new MHFolder(t,MHPath)); | 101 | folders->append(new MHFolder(t,MHPath)); |
103 | } | 102 | } |
104 | mail_list_free(flist); | 103 | mail_list_free(flist); |
105 | return folders; | 104 | return folders; |
106 | } | 105 | } |
107 | 106 | ||
108 | void MHwrapper::deleteMail(const RecMailP&mail) | 107 | void MHwrapper::deleteMail(const RecMailP&mail) |
109 | { | 108 | { |
110 | init_storage(); | 109 | init_storage(); |
111 | if (!m_storage) { | 110 | if (!m_storage) { |
112 | return; | 111 | return; |
113 | } | 112 | } |
114 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 113 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
115 | if (r!=MAIL_NO_ERROR) { | 114 | if (r!=MAIL_NO_ERROR) { |
116 | qDebug("error selecting folder! "); | 115 | qDebug("error selecting folder! "); |
117 | return; | 116 | return; |
118 | } | 117 | } |
119 | r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); | 118 | r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); |
120 | if (r != MAIL_NO_ERROR) { | 119 | if (r != MAIL_NO_ERROR) { |
121 | qDebug("error deleting mail "); | 120 | qDebug("error deleting mail "); |
122 | } | 121 | } |
123 | } | 122 | } |
124 | 123 | ||
125 | void MHwrapper::answeredMail(const RecMailP&) | 124 | void MHwrapper::answeredMail(const RecMailP&) |
126 | { | 125 | { |
127 | } | 126 | } |
128 | 127 | ||
129 | RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) | 128 | RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) |
130 | { | 129 | { |
131 | RecBodyP body = new RecBody(); | 130 | RecBodyP body = new RecBody(); |
132 | init_storage(); | 131 | init_storage(); |
133 | if (!m_storage) { | 132 | if (!m_storage) { |
134 | return body; | 133 | return body; |
135 | } | 134 | } |
136 | mailmessage * msg; | 135 | mailmessage * msg; |
137 | char*data=0; | 136 | char*data=0; |
138 | 137 | ||
139 | /* mail should hold the complete path! */ | 138 | /* mail should hold the complete path! */ |
140 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 139 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
141 | if (r != MAIL_NO_ERROR) { | 140 | if (r != MAIL_NO_ERROR) { |
142 | return body; | 141 | return body; |
143 | } | 142 | } |
144 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); | 143 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); |
145 | if (r != MAIL_NO_ERROR) { | 144 | if (r != MAIL_NO_ERROR) { |
146 | qDebug("Error fetching mail "); | 145 | qDebug("Error fetching mail "); |
147 | 146 | ||
148 | return body; | 147 | return body; |
149 | } | 148 | } |
150 | body = parseMail(msg); | 149 | body = parseMail(msg); |
151 | mailmessage_fetch_result_free(msg,data); | 150 | mailmessage_fetch_result_free(msg,data); |
152 | return body; | 151 | return body; |
153 | } | 152 | } |
154 | 153 | ||
155 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) | 154 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) |
156 | { | 155 | { |
157 | qDebug("MBox Progress %d of %d",current,maximum ); | 156 | qDebug("MBox Progress %d of %d",current,maximum ); |
158 | //odebug << "MH " << current << " von " << maximum << "" << oendl; | 157 | //odebug << "MH " << current << " von " << maximum << "" << oendl; |
159 | } | 158 | } |
160 | 159 | ||
161 | QString MHwrapper::buildPath(const QString&p) | 160 | QString MHwrapper::buildPath(const QString&p) |
162 | { | 161 | { |
163 | QString f=""; | 162 | QString f=""; |
164 | if (p.length()==0||p=="/") | 163 | if (p.length()==0||p=="/") |
165 | return MHPath; | 164 | return MHPath; |
166 | if (!p.startsWith(MHPath)) { | 165 | if (!p.startsWith(MHPath)) { |
167 | f+=MHPath; | 166 | f+=MHPath; |
168 | } | 167 | } |
169 | if (!p.startsWith("/")) { | 168 | if (!p.startsWith("/")) { |
170 | f+="/"; | 169 | f+="/"; |
171 | } | 170 | } |
172 | f+=p; | 171 | f+=p; |
173 | return f; | 172 | return f; |
174 | } | 173 | } |
175 | 174 | ||
176 | int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool ) | 175 | int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool ) |
177 | { | 176 | { |
178 | init_storage(); | 177 | init_storage(); |
179 | if (!m_storage) { | 178 | if (!m_storage) { |
180 | return 0; | 179 | return 0; |
181 | } | 180 | } |
182 | QString f; | 181 | QString f; |
183 | if (!pfolder) { | 182 | if (!pfolder) { |
184 | // toplevel folder | 183 | // toplevel folder |
185 | f = buildPath(folder); | 184 | f = buildPath(folder); |
186 | } else { | 185 | } else { |
187 | f = pfolder->getName(); | 186 | f = pfolder->getName(); |
188 | f+="/"; | 187 | f+="/"; |
189 | f+=folder; | 188 | f+=folder; |
190 | } | 189 | } |
191 | 190 | ||
192 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); | 191 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); |
193 | if (r != MAIL_NO_ERROR) { | 192 | if (r != MAIL_NO_ERROR) { |
194 | qDebug("error creating folder "); | 193 | qDebug("error creating folder "); |
195 | return 0; | 194 | return 0; |
196 | } | 195 | } |
197 | qDebug("Folder created "); | ||
198 | return 1; | 196 | return 1; |
199 | } | 197 | } |
200 | 198 | ||
201 | void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) | 199 | void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) |
202 | { | 200 | { |
203 | init_storage(); | 201 | init_storage(); |
204 | if (!m_storage) { | 202 | if (!m_storage) { |
205 | return; | 203 | return; |
206 | } | 204 | } |
207 | QString f = buildPath(Folder); | 205 | QString f = buildPath(Folder); |
208 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 206 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
209 | if (r!=MAIL_NO_ERROR) { | 207 | if (r!=MAIL_NO_ERROR) { |
210 | qDebug("error selecting folder! "); | 208 | qDebug("error selecting folder! "); |
211 | return; | 209 | return; |
212 | } | 210 | } |
213 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); | 211 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); |
214 | if (r!=MAIL_NO_ERROR) { | 212 | if (r!=MAIL_NO_ERROR) { |
215 | qDebug("error storing mail "); | 213 | qDebug("error storing mail "); |
216 | } | 214 | } |
217 | return; | 215 | return; |
218 | } | 216 | } |
219 | 217 | ||
220 | encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) | 218 | encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) |
221 | { | 219 | { |
222 | encodedString*result = 0; | 220 | encodedString*result = 0; |
223 | init_storage(); | 221 | init_storage(); |
224 | if (!m_storage) { | 222 | if (!m_storage) { |
225 | return result; | 223 | return result; |
226 | } | 224 | } |
227 | mailmessage * msg = 0; | 225 | mailmessage * msg = 0; |
228 | char*data=0; | 226 | char*data=0; |
229 | size_t size; | 227 | size_t size; |
230 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 228 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
231 | if (r!=MAIL_NO_ERROR) { | 229 | if (r!=MAIL_NO_ERROR) { |
232 | qDebug("error selecting folder! "); | 230 | qDebug("error selecting folder! "); |
233 | return result; | 231 | return result; |
234 | } | 232 | } |
235 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); | 233 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); |
236 | if (r != MAIL_NO_ERROR) { | 234 | if (r != MAIL_NO_ERROR) { |
237 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); | 235 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); |
238 | return 0; | 236 | return 0; |
239 | } | 237 | } |
240 | r = mailmessage_fetch(msg,&data,&size); | 238 | r = mailmessage_fetch(msg,&data,&size); |
241 | if (r != MAIL_NO_ERROR) { | 239 | if (r != MAIL_NO_ERROR) { |
242 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); | 240 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); |
243 | if (msg) mailmessage_free(msg); | 241 | if (msg) mailmessage_free(msg); |
244 | return 0; | 242 | return 0; |
245 | } | 243 | } |
246 | result = new encodedString(data,size); | 244 | result = new encodedString(data,size); |
247 | if (msg) mailmessage_free(msg); | 245 | if (msg) mailmessage_free(msg); |
248 | return result; | 246 | return result; |
249 | } | 247 | } |
250 | 248 | ||
251 | void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) | 249 | void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) |
252 | { | 250 | { |
253 | QString f = buildPath(mailbox); | 251 | QString f = buildPath(mailbox); |
254 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 252 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
255 | if (r!=MAIL_NO_ERROR) { | 253 | if (r!=MAIL_NO_ERROR) { |
256 | qDebug("deleteMails: error selecting folder! "); | 254 | qDebug("deleteMails: error selecting folder! "); |
257 | return; | 255 | return; |
258 | } | 256 | } |
259 | QValueList<RecMailP>::ConstIterator it; | 257 | QValueList<RecMailP>::ConstIterator it; |
260 | for (it=target.begin(); it!=target.end();++it) { | 258 | for (it=target.begin(); it!=target.end();++it) { |
261 | r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); | 259 | r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); |
262 | if (r != MAIL_NO_ERROR) { | 260 | if (r != MAIL_NO_ERROR) { |
263 | qDebug("error deleting mail "); | 261 | qDebug("error deleting mail "); |
264 | break; | 262 | break; |
265 | } | 263 | } |
266 | } | 264 | } |
267 | } | 265 | } |
268 | 266 | ||
269 | int MHwrapper::deleteAllMail(const FolderP&tfolder) | 267 | int MHwrapper::deleteAllMail(const FolderP&tfolder) |
270 | { | 268 | { |
271 | init_storage(); | 269 | init_storage(); |
272 | if (!m_storage) { | 270 | if (!m_storage) { |
273 | return 0; | 271 | return 0; |
274 | } | 272 | } |
275 | int res = 1; | 273 | int res = 1; |
276 | if (!tfolder) return 0; | 274 | if (!tfolder) return 0; |
277 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 275 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
278 | if (r!=MAIL_NO_ERROR) { | 276 | if (r!=MAIL_NO_ERROR) { |
279 | qDebug("error selecting folder! "); | 277 | qDebug("error selecting folder! "); |
280 | return 0; | 278 | return 0; |
281 | } | 279 | } |
282 | mailmessage_list*l=0; | 280 | mailmessage_list*l=0; |
283 | r = mailsession_get_messages_list(m_storage->sto_session,&l); | 281 | r = mailsession_get_messages_list(m_storage->sto_session,&l); |
284 | if (r != MAIL_NO_ERROR) { | 282 | if (r != MAIL_NO_ERROR) { |
285 | qDebug("Error message list "); | 283 | qDebug("Error message list "); |
286 | res = 0; | 284 | res = 0; |
287 | } | 285 | } |
288 | unsigned j = 0; | 286 | unsigned j = 0; |
289 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { | 287 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { |
290 | mailmessage * msg; | 288 | mailmessage * msg; |
291 | msg = (mailmessage*)carray_get(l->msg_tab, i); | 289 | msg = (mailmessage*)carray_get(l->msg_tab, i); |
292 | j = msg->msg_index; | 290 | j = msg->msg_index; |
293 | r = mailsession_remove_message(m_storage->sto_session,j); | 291 | r = mailsession_remove_message(m_storage->sto_session,j); |
294 | if (r != MAIL_NO_ERROR) { | 292 | if (r != MAIL_NO_ERROR) { |
295 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 293 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
296 | res = 0; | 294 | res = 0; |
297 | break; | 295 | break; |
298 | } | 296 | } |
299 | } | 297 | } |
300 | if (l) mailmessage_list_free(l); | 298 | if (l) mailmessage_list_free(l); |
301 | return res; | 299 | return res; |
302 | } | 300 | } |
303 | 301 | ||
304 | int MHwrapper::deleteMbox(const FolderP&tfolder) | 302 | int MHwrapper::deleteMbox(const FolderP&tfolder) |
305 | { | 303 | { |
306 | init_storage(); | 304 | init_storage(); |
307 | if (!m_storage) { | 305 | if (!m_storage) { |
308 | return 0; | 306 | return 0; |
309 | } | 307 | } |
310 | if (!tfolder) return 0; | 308 | if (!tfolder) return 0; |
311 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; | 309 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; |
312 | 310 | ||
313 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 311 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
314 | 312 | ||
315 | if (r != MAIL_NO_ERROR) { | 313 | if (r != MAIL_NO_ERROR) { |
316 | qDebug("error deleting mail box "); | 314 | qDebug("error deleting mail box "); |
317 | return 0; | 315 | return 0; |
318 | } | 316 | } |
319 | QString cmd = "rm -rf "+tfolder->getName(); | 317 | QString cmd = "rm -rf "+tfolder->getName(); |
320 | QStringList command; | 318 | QStringList command; |
321 | command << "/bin/sh"; | 319 | command << "/bin/sh"; |
322 | command << "-c"; | 320 | command << "-c"; |
323 | command << cmd.latin1(); | 321 | command << cmd.latin1(); |
324 | OProcess *process = new OProcess(); | 322 | OProcess *process = new OProcess(); |
325 | 323 | ||
326 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), | 324 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), |
327 | this, SLOT( processEnded(Opie::Core::OProcess*))); | 325 | this, SLOT( processEnded(Opie::Core::OProcess*))); |
328 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), | 326 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), |
329 | this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); | 327 | this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); |
330 | 328 | ||
331 | *process << command; | 329 | *process << command; |
332 | removeMboxfailed = false; | 330 | removeMboxfailed = false; |
333 | if(!process->start(OProcess::Block, OProcess::All) ) { | 331 | if(!process->start(OProcess::Block, OProcess::All) ) { |
334 | qDebug("could not start process "); | 332 | qDebug("could not start process "); |
335 | return 0; | 333 | return 0; |
336 | } | 334 | } |
337 | qDebug("mail box deleted "); | 335 | qDebug("mail box deleted "); |
338 | return 1; | 336 | return 1; |
339 | } | 337 | } |
340 | 338 | ||
341 | void MHwrapper::processEnded(OProcess *p) | 339 | void MHwrapper::processEnded(OProcess *p) |
342 | { | 340 | { |
343 | if (p) delete p; | 341 | if (p) delete p; |
344 | } | 342 | } |
345 | 343 | ||
346 | void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) | 344 | void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) |
347 | { | 345 | { |
348 | QString lineStr = buffer; | 346 | QString lineStr = buffer; |
349 | QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); | 347 | QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); |
350 | removeMboxfailed = true; | 348 | removeMboxfailed = true; |
351 | } | 349 | } |
352 | 350 | ||
353 | void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 351 | void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
354 | { | 352 | { |
355 | init_storage(); | 353 | init_storage(); |
356 | if (!m_storage) { | 354 | if (!m_storage) { |
357 | return; | 355 | return; |
358 | } | 356 | } |
359 | target_stat.message_count = 0; | 357 | target_stat.message_count = 0; |
360 | target_stat.message_unseen = 0; | 358 | target_stat.message_unseen = 0; |
361 | target_stat.message_recent = 0; | 359 | target_stat.message_recent = 0; |
362 | QString f = buildPath(mailbox); | 360 | QString f = buildPath(mailbox); |
363 | int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count, | 361 | int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count, |
364 | &target_stat.message_recent,&target_stat.message_unseen); | 362 | &target_stat.message_recent,&target_stat.message_unseen); |
365 | if (r != MAIL_NO_ERROR) { | 363 | if (r != MAIL_NO_ERROR) { |
366 | Global::statusMessage(tr("Error retrieving status")); | 364 | Global::statusMessage(tr("Error retrieving status")); |
367 | } | 365 | } |
368 | } | 366 | } |
369 | 367 | ||
370 | MAILLIB::ATYPE MHwrapper::getType()const | 368 | MAILLIB::ATYPE MHwrapper::getType()const |
371 | { | 369 | { |
372 | return MAILLIB::A_MH; | 370 | return MAILLIB::A_MH; |
373 | } | 371 | } |
374 | 372 | ||
375 | const QString&MHwrapper::getName()const | 373 | const QString&MHwrapper::getName()const |
376 | { | 374 | { |
377 | return MHName; | 375 | return MHName; |
378 | } | 376 | } |
379 | void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 377 | void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
380 | { | 378 | { |
381 | init_storage(); | 379 | init_storage(); |
382 | if (!m_storage) { | 380 | if (!m_storage) { |
383 | return; | 381 | return; |
384 | } | 382 | } |
385 | if (targetWrapper != this) { | 383 | if (targetWrapper != this) { |
386 | qDebug("Using generic "); | 384 | qDebug("Using generic "); |
387 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 385 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
388 | return; | 386 | return; |
389 | } | 387 | } |
390 | qDebug("Using internal routines for move/copy "); | 388 | qDebug("Using internal routines for move/copy "); |
391 | QString tf = buildPath(targetFolder); | 389 | QString tf = buildPath(targetFolder); |
392 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 390 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
393 | if (r != MAIL_NO_ERROR) { | 391 | if (r != MAIL_NO_ERROR) { |
394 | qDebug("Error selecting source mailbox "); | 392 | qDebug("Error selecting source mailbox "); |
395 | return; | 393 | return; |
396 | } | 394 | } |
397 | if (moveit) { | 395 | if (moveit) { |
398 | r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); | 396 | r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); |
399 | } else { | 397 | } else { |
400 | r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); | 398 | r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); |
401 | } | 399 | } |
402 | if (r != MAIL_NO_ERROR) { | 400 | if (r != MAIL_NO_ERROR) { |
403 | qDebug("Error copy/moving mail internal "); | 401 | qDebug("Error copy/moving mail internal "); |
404 | } | 402 | } |
405 | } | 403 | } |
406 | 404 | ||
407 | void MHwrapper::mvcpAllMails(const FolderP&fromFolder, | 405 | void MHwrapper::mvcpAllMails(const FolderP&fromFolder, |
408 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 406 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
409 | { | 407 | { |
410 | init_storage(); | 408 | init_storage(); |
411 | if (!m_storage) { | 409 | if (!m_storage) { |
412 | return; | 410 | return; |
413 | } | 411 | } |
414 | if (targetWrapper != this) { | 412 | if (targetWrapper != this) { |
415 | qDebug("Using generic "); | 413 | qDebug("Using generic "); |
416 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); | 414 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); |
417 | return; | 415 | return; |
418 | } | 416 | } |
419 | if (!fromFolder) return; | 417 | if (!fromFolder) return; |
420 | int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); | 418 | int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); |
421 | if (r!=MAIL_NO_ERROR) { | 419 | if (r!=MAIL_NO_ERROR) { |
422 | qDebug("error selecting source folder! "); | 420 | qDebug("error selecting source folder! "); |
423 | return; | 421 | return; |
424 | } | 422 | } |
425 | QString tf = buildPath(targetFolder); | 423 | QString tf = buildPath(targetFolder); |
426 | mailmessage_list*l=0; | 424 | mailmessage_list*l=0; |
427 | r = mailsession_get_messages_list(m_storage->sto_session,&l); | 425 | r = mailsession_get_messages_list(m_storage->sto_session,&l); |
428 | if (r != MAIL_NO_ERROR) { | 426 | if (r != MAIL_NO_ERROR) { |
429 | qDebug("Error message list "); | 427 | qDebug("Error message list "); |
430 | } | 428 | } |
431 | unsigned j = 0; | 429 | unsigned j = 0; |
432 | for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { | 430 | for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { |
433 | mailmessage * msg; | 431 | mailmessage * msg; |
434 | msg = (mailmessage*)carray_get(l->msg_tab, i); | 432 | msg = (mailmessage*)carray_get(l->msg_tab, i); |
435 | j = msg->msg_index; | 433 | j = msg->msg_index; |
436 | if (moveit) { | 434 | if (moveit) { |
437 | r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); | 435 | r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); |
438 | } else { | 436 | } else { |
439 | r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); | 437 | r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); |
440 | } | 438 | } |
441 | if (r != MAIL_NO_ERROR) { | 439 | if (r != MAIL_NO_ERROR) { |
442 | qDebug("Error copy/moving mail interna "); | 440 | qDebug("Error copy/moving mail interna "); |
443 | 441 | ||
444 | break; | 442 | break; |
445 | } | 443 | } |
446 | } | 444 | } |
447 | if (l) mailmessage_list_free(l); | 445 | if (l) mailmessage_list_free(l); |
448 | } | 446 | } |
diff --git a/kmicromail/libmailwrapper/settings.cpp b/kmicromail/libmailwrapper/settings.cpp index 766eba0..40b5591 100644 --- a/kmicromail/libmailwrapper/settings.cpp +++ b/kmicromail/libmailwrapper/settings.cpp | |||
@@ -1,501 +1,499 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <qdir.h> | 2 | #include <qdir.h> |
3 | 3 | ||
4 | //#include <opie2/odebug.h> | 4 | //#include <opie2/odebug.h> |
5 | #include <kconfig.h> | 5 | #include <kconfig.h> |
6 | 6 | ||
7 | #include <kstandarddirs.h> | 7 | #include <kstandarddirs.h> |
8 | #include "settings.h" | 8 | #include "settings.h" |
9 | //#include "defines.h" | 9 | //#include "defines.h" |
10 | 10 | ||
11 | #define IMAP_PORT "143" | 11 | #define IMAP_PORT "143" |
12 | #define IMAP_SSL_PORT "993" | 12 | #define IMAP_SSL_PORT "993" |
13 | #define SMTP_PORT "25" | 13 | #define SMTP_PORT "25" |
14 | #define SMTP_SSL_PORT "465" | 14 | #define SMTP_SSL_PORT "465" |
15 | #define POP3_PORT "110" | 15 | #define POP3_PORT "110" |
16 | #define POP3_SSL_PORT "995" | 16 | #define POP3_SSL_PORT "995" |
17 | #define NNTP_PORT "119" | 17 | #define NNTP_PORT "119" |
18 | #define NNTP_SSL_PORT "563" | 18 | #define NNTP_SSL_PORT "563" |
19 | 19 | ||
20 | 20 | ||
21 | Settings::Settings() | 21 | Settings::Settings() |
22 | : QObject() | 22 | : QObject() |
23 | { | 23 | { |
24 | updateAccounts(); | 24 | updateAccounts(); |
25 | } | 25 | } |
26 | 26 | ||
27 | void Settings::checkDirectory() | 27 | void Settings::checkDirectory() |
28 | { | 28 | { |
29 | qDebug("Settings::checkDirectory() "); | ||
30 | return; | 29 | return; |
31 | locateLocal("data", "kopiemail" ); | 30 | locateLocal("data", "kopiemail" ); |
32 | /* | 31 | /* |
33 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { | 32 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { |
34 | system( "mkdir -p $HOME/Applications/opiemail" ); | 33 | system( "mkdir -p $HOME/Applications/opiemail" ); |
35 | qDebug("$HOME/Applications/opiemail created "); | 34 | qDebug("$HOME/Applications/opiemail created "); |
36 | } | 35 | } |
37 | */ | 36 | */ |
38 | } | 37 | } |
39 | 38 | ||
40 | QList<Account> Settings::getAccounts() | 39 | QList<Account> Settings::getAccounts() |
41 | { | 40 | { |
42 | return accounts; | 41 | return accounts; |
43 | } | 42 | } |
44 | 43 | ||
45 | void Settings::addAccount( Account *account ) | 44 | void Settings::addAccount( Account *account ) |
46 | { | 45 | { |
47 | accounts.append( account ); | 46 | accounts.append( account ); |
48 | } | 47 | } |
49 | 48 | ||
50 | void Settings::delAccount( Account *account ) | 49 | void Settings::delAccount( Account *account ) |
51 | { | 50 | { |
52 | accounts.remove( account ); | 51 | accounts.remove( account ); |
53 | account->remove(); | 52 | account->remove(); |
54 | } | 53 | } |
55 | 54 | ||
56 | void Settings::updateAccounts() | 55 | void Settings::updateAccounts() |
57 | { | 56 | { |
58 | accounts.clear(); | 57 | accounts.clear(); |
59 | QDir dir( locateLocal("data", "kopiemail" ) ); | 58 | QDir dir( locateLocal("data", "kopiemail" ) ); |
60 | QStringList::Iterator it; | 59 | QStringList::Iterator it; |
61 | 60 | ||
62 | QStringList imap = dir.entryList( "imap-*" ); | 61 | QStringList imap = dir.entryList( "imap-*" ); |
63 | for ( it = imap.begin(); it != imap.end(); it++ ) { | 62 | for ( it = imap.begin(); it != imap.end(); it++ ) { |
64 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); | 63 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); |
65 | accounts.append( account ); | 64 | accounts.append( account ); |
66 | } | 65 | } |
67 | 66 | ||
68 | QStringList pop3 = dir.entryList( "pop3-*" ); | 67 | QStringList pop3 = dir.entryList( "pop3-*" ); |
69 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { | 68 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { |
70 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); | 69 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); |
71 | accounts.append( account ); | 70 | accounts.append( account ); |
72 | } | 71 | } |
73 | 72 | ||
74 | QStringList smtp = dir.entryList( "smtp-*" ); | 73 | QStringList smtp = dir.entryList( "smtp-*" ); |
75 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { | 74 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { |
76 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); | 75 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); |
77 | accounts.append( account ); | 76 | accounts.append( account ); |
78 | } | 77 | } |
79 | 78 | ||
80 | QStringList nntp = dir.entryList( "nntp-*" ); | 79 | QStringList nntp = dir.entryList( "nntp-*" ); |
81 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { | 80 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { |
82 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); | 81 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); |
83 | accounts.append( account ); | 82 | accounts.append( account ); |
84 | } | 83 | } |
85 | 84 | ||
86 | readAccounts(); | 85 | readAccounts(); |
87 | } | 86 | } |
88 | 87 | ||
89 | void Settings::saveAccounts() | 88 | void Settings::saveAccounts() |
90 | { | 89 | { |
91 | checkDirectory(); | 90 | checkDirectory(); |
92 | Account *it; | 91 | Account *it; |
93 | 92 | ||
94 | for ( it = accounts.first(); it; it = accounts.next() ) { | 93 | for ( it = accounts.first(); it; it = accounts.next() ) { |
95 | it->save(); | 94 | it->save(); |
96 | } | 95 | } |
97 | } | 96 | } |
98 | 97 | ||
99 | void Settings::readAccounts() | 98 | void Settings::readAccounts() |
100 | { | 99 | { |
101 | checkDirectory(); | 100 | checkDirectory(); |
102 | Account *it; | 101 | Account *it; |
103 | 102 | ||
104 | for ( it = accounts.first(); it; it = accounts.next() ) { | 103 | for ( it = accounts.first(); it; it = accounts.next() ) { |
105 | it->read(); | 104 | it->read(); |
106 | } | 105 | } |
107 | } | 106 | } |
108 | 107 | ||
109 | Account::Account() | 108 | Account::Account() |
110 | { | 109 | { |
111 | accountName = "changeMe"; | 110 | accountName = "changeMe"; |
112 | type = MAILLIB::A_UNDEFINED; | 111 | type = MAILLIB::A_UNDEFINED; |
113 | ssl = false; | 112 | ssl = false; |
114 | connectionType = 1; | 113 | connectionType = 1; |
115 | offline = false; | 114 | offline = false; |
116 | maxMailSize = 0; | 115 | maxMailSize = 0; |
117 | lastFetch; | 116 | lastFetch; |
118 | leaveOnServer = false; | 117 | leaveOnServer = false; |
119 | } | 118 | } |
120 | 119 | ||
121 | void Account::remove() | 120 | void Account::remove() |
122 | { | 121 | { |
123 | QFile file( getFileName() ); | 122 | QFile file( getFileName() ); |
124 | file.remove(); | 123 | file.remove(); |
125 | } | 124 | } |
126 | 125 | ||
127 | void Account::setPasswordList(const QStringList &str) | 126 | void Account::setPasswordList(const QStringList &str) |
128 | { | 127 | { |
129 | password = ""; | 128 | password = ""; |
130 | int i; | 129 | int i; |
131 | for ( i = 0; i < str.count() ; ++i ) { | 130 | for ( i = 0; i < str.count() ; ++i ) { |
132 | QChar c ( (str[i].toUInt()-131)/(str.count()- (i%3))); | 131 | QChar c ( (str[i].toUInt()-131)/(str.count()- (i%3))); |
133 | password.append( c ); | 132 | password.append( c ); |
134 | } | 133 | } |
135 | //qDebug("password %s ", password.latin1()); | 134 | //qDebug("password %s ", password.latin1()); |
136 | } | 135 | } |
137 | QStringList Account::getPasswordList() | 136 | QStringList Account::getPasswordList() |
138 | { | 137 | { |
139 | int i; | 138 | int i; |
140 | int len = password.length(); | 139 | int len = password.length(); |
141 | QStringList str; | 140 | QStringList str; |
142 | 141 | ||
143 | for ( i = 0; i < len ; ++i ) { | 142 | for ( i = 0; i < len ; ++i ) { |
144 | int val = password.at(i).unicode()*(len-(i%3))+131; | 143 | int val = password.at(i).unicode()*(len-(i%3))+131; |
145 | str.append( QString::number( val ) ); | 144 | str.append( QString::number( val ) ); |
146 | // qDebug("append %s ", str[i].latin1()); | 145 | // qDebug("append %s ", str[i].latin1()); |
147 | } | 146 | } |
148 | return str; | 147 | return str; |
149 | } | 148 | } |
150 | 149 | ||
151 | IMAPaccount::IMAPaccount() | 150 | IMAPaccount::IMAPaccount() |
152 | : Account() | 151 | : Account() |
153 | { | 152 | { |
154 | file = IMAPaccount::getUniqueFileName(); | 153 | file = IMAPaccount::getUniqueFileName(); |
155 | accountName = "New IMAP Account"; | 154 | accountName = "New IMAP Account"; |
156 | ssl = false; | 155 | ssl = false; |
157 | connectionType = 1; | 156 | connectionType = 1; |
158 | type = MAILLIB::A_IMAP; | 157 | type = MAILLIB::A_IMAP; |
159 | port = IMAP_PORT; | 158 | port = IMAP_PORT; |
160 | } | 159 | } |
161 | 160 | ||
162 | IMAPaccount::IMAPaccount( QString filename ) | 161 | IMAPaccount::IMAPaccount( QString filename ) |
163 | : Account() | 162 | : Account() |
164 | { | 163 | { |
165 | file = filename; | 164 | file = filename; |
166 | accountName = "New IMAP Account"; | 165 | accountName = "New IMAP Account"; |
167 | ssl = false; | 166 | ssl = false; |
168 | connectionType = 1; | 167 | connectionType = 1; |
169 | type = MAILLIB::A_IMAP; | 168 | type = MAILLIB::A_IMAP; |
170 | port = IMAP_PORT; | 169 | port = IMAP_PORT; |
171 | } | 170 | } |
172 | 171 | ||
173 | QString IMAPaccount::getUniqueFileName() | 172 | QString IMAPaccount::getUniqueFileName() |
174 | { | 173 | { |
175 | int num = 0; | 174 | int num = 0; |
176 | QString unique; | 175 | QString unique; |
177 | 176 | ||
178 | QDir dir( locateLocal("data", "kopiemail" ) ); | 177 | QDir dir( locateLocal("data", "kopiemail" ) ); |
179 | 178 | ||
180 | QStringList imap = dir.entryList( "imap-*" ); | 179 | QStringList imap = dir.entryList( "imap-*" ); |
181 | do { | 180 | do { |
182 | unique.setNum( num++ ); | 181 | unique.setNum( num++ ); |
183 | } while ( imap.contains( "imap-" + unique ) > 0 ); | 182 | } while ( imap.contains( "imap-" + unique ) > 0 ); |
184 | 183 | ||
185 | return unique; | 184 | return unique; |
186 | } | 185 | } |
187 | 186 | ||
188 | void IMAPaccount::read() | 187 | void IMAPaccount::read() |
189 | { | 188 | { |
190 | KConfig *conf = new KConfig( getFileName() ); | 189 | KConfig *conf = new KConfig( getFileName() ); |
191 | conf->setGroup( "IMAP Account" ); | 190 | conf->setGroup( "IMAP Account" ); |
192 | accountName = conf->readEntry( "Account","" ); | 191 | accountName = conf->readEntry( "Account","" ); |
193 | if (accountName.isNull()) accountName = ""; | 192 | if (accountName.isNull()) accountName = ""; |
194 | server = conf->readEntry( "Server","" ); | 193 | server = conf->readEntry( "Server","" ); |
195 | if (server.isNull()) server=""; | 194 | if (server.isNull()) server=""; |
196 | port = conf->readEntry( "Port","" ); | 195 | port = conf->readEntry( "Port","" ); |
197 | if (port.isNull()) port="143"; | 196 | if (port.isNull()) port="143"; |
198 | connectionType = conf->readNumEntry( "ConnectionType" ); | 197 | connectionType = conf->readNumEntry( "ConnectionType" ); |
199 | ssl = conf->readBoolEntry( "SSL",false ); | 198 | ssl = conf->readBoolEntry( "SSL",false ); |
200 | user = conf->readEntry( "User","" ); | 199 | user = conf->readEntry( "User","" ); |
201 | if (user.isNull()) user = ""; | 200 | if (user.isNull()) user = ""; |
202 | //password = conf->readEntryCrypt( "Password","" ); | 201 | //password = conf->readEntryCrypt( "Password","" ); |
203 | setPasswordList( conf->readListEntry( "FolderHistory")); | 202 | setPasswordList( conf->readListEntry( "FolderHistory")); |
204 | if (password.isNull()) password = ""; | 203 | if (password.isNull()) password = ""; |
205 | prefix = conf->readEntry("MailPrefix",""); | 204 | prefix = conf->readEntry("MailPrefix",""); |
206 | if (prefix.isNull()) prefix = ""; | 205 | if (prefix.isNull()) prefix = ""; |
207 | offline = conf->readBoolEntry("Offline",false); | 206 | offline = conf->readBoolEntry("Offline",false); |
208 | localFolder = conf->readEntry( "LocalFolder" ); | 207 | localFolder = conf->readEntry( "LocalFolder" ); |
209 | maxMailSize = conf->readNumEntry( "MaxSize",0 ); | 208 | maxMailSize = conf->readNumEntry( "MaxSize",0 ); |
210 | int lf = conf->readNumEntry( "LastFetch",0 ); | 209 | int lf = conf->readNumEntry( "LastFetch",0 ); |
211 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); | 210 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); |
212 | leaveOnServer = conf->readBoolEntry("LeaveOnServer",false); | 211 | leaveOnServer = conf->readBoolEntry("LeaveOnServer",false); |
213 | qDebug("reading last fetch: %d ", lf); | ||
214 | if ( lf < 0 ) lf = 0; | 212 | if ( lf < 0 ) lf = 0; |
215 | lastFetch = dt.addSecs( lf ); | 213 | lastFetch = dt.addSecs( lf ); |
216 | delete conf; | 214 | delete conf; |
217 | } | 215 | } |
218 | 216 | ||
219 | void IMAPaccount::save() | 217 | void IMAPaccount::save() |
220 | { | 218 | { |
221 | qDebug("saving %s ",getFileName().latin1() ); | 219 | |
222 | Settings::checkDirectory(); | 220 | Settings::checkDirectory(); |
223 | 221 | ||
224 | KConfig *conf = new KConfig( getFileName() ); | 222 | KConfig *conf = new KConfig( getFileName() ); |
225 | conf->setGroup( "IMAP Account" ); | 223 | conf->setGroup( "IMAP Account" ); |
226 | conf->writeEntry( "Account", accountName ); | 224 | conf->writeEntry( "Account", accountName ); |
227 | conf->writeEntry( "Server", server ); | 225 | conf->writeEntry( "Server", server ); |
228 | conf->writeEntry( "Port", port ); | 226 | conf->writeEntry( "Port", port ); |
229 | conf->writeEntry( "SSL", ssl ); | 227 | conf->writeEntry( "SSL", ssl ); |
230 | conf->writeEntry( "ConnectionType", connectionType ); | 228 | conf->writeEntry( "ConnectionType", connectionType ); |
231 | conf->writeEntry( "User", user ); | 229 | conf->writeEntry( "User", user ); |
232 | //conf->writeEntryCrypt( "Password", password ); | 230 | //conf->writeEntryCrypt( "Password", password ); |
233 | conf->writeEntry( "FolderHistory",getPasswordList() ); | 231 | conf->writeEntry( "FolderHistory",getPasswordList() ); |
234 | conf->writeEntry( "MailPrefix",prefix); | 232 | conf->writeEntry( "MailPrefix",prefix); |
235 | conf->writeEntry( "Offline",offline); | 233 | conf->writeEntry( "Offline",offline); |
236 | conf->writeEntry( "LocalFolder", localFolder ); | 234 | conf->writeEntry( "LocalFolder", localFolder ); |
237 | conf->writeEntry( "MaxSize", maxMailSize ); | 235 | conf->writeEntry( "MaxSize", maxMailSize ); |
238 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); | 236 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); |
239 | int lf = dt.secsTo ( lastFetch ); | 237 | int lf = dt.secsTo ( lastFetch ); |
240 | conf->writeEntry( "LastFetch", lf ); | 238 | conf->writeEntry( "LastFetch", lf ); |
241 | conf->writeEntry( "LeaveOnServer", leaveOnServer); | 239 | conf->writeEntry( "LeaveOnServer", leaveOnServer); |
242 | conf->sync(); | 240 | conf->sync(); |
243 | delete conf; | 241 | delete conf; |
244 | } | 242 | } |
245 | 243 | ||
246 | 244 | ||
247 | QString IMAPaccount::getFileName() | 245 | QString IMAPaccount::getFileName() |
248 | { | 246 | { |
249 | return locateLocal("data", "kopiemail" ) +"/imap-" + file; | 247 | return locateLocal("data", "kopiemail" ) +"/imap-" + file; |
250 | } | 248 | } |
251 | 249 | ||
252 | POP3account::POP3account() | 250 | POP3account::POP3account() |
253 | : Account() | 251 | : Account() |
254 | { | 252 | { |
255 | file = POP3account::getUniqueFileName(); | 253 | file = POP3account::getUniqueFileName(); |
256 | accountName = "New POP3 Account"; | 254 | accountName = "New POP3 Account"; |
257 | ssl = false; | 255 | ssl = false; |
258 | connectionType = 1; | 256 | connectionType = 1; |
259 | type = MAILLIB::A_POP3; | 257 | type = MAILLIB::A_POP3; |
260 | port = POP3_PORT; | 258 | port = POP3_PORT; |
261 | } | 259 | } |
262 | 260 | ||
263 | POP3account::POP3account( QString filename ) | 261 | POP3account::POP3account( QString filename ) |
264 | : Account() | 262 | : Account() |
265 | { | 263 | { |
266 | file = filename; | 264 | file = filename; |
267 | accountName = "New POP3 Account"; | 265 | accountName = "New POP3 Account"; |
268 | ssl = false; | 266 | ssl = false; |
269 | connectionType = 1; | 267 | connectionType = 1; |
270 | type = MAILLIB::A_POP3; | 268 | type = MAILLIB::A_POP3; |
271 | port = POP3_PORT; | 269 | port = POP3_PORT; |
272 | } | 270 | } |
273 | 271 | ||
274 | QString POP3account::getUniqueFileName() | 272 | QString POP3account::getUniqueFileName() |
275 | { | 273 | { |
276 | int num = 0; | 274 | int num = 0; |
277 | QString unique; | 275 | QString unique; |
278 | 276 | ||
279 | QDir dir( locateLocal("data", "kopiemail" ) ); | 277 | QDir dir( locateLocal("data", "kopiemail" ) ); |
280 | 278 | ||
281 | QStringList imap = dir.entryList( "pop3-*" ); | 279 | QStringList imap = dir.entryList( "pop3-*" ); |
282 | do { | 280 | do { |
283 | unique.setNum( num++ ); | 281 | unique.setNum( num++ ); |
284 | } while ( imap.contains( "pop3-" + unique ) > 0 ); | 282 | } while ( imap.contains( "pop3-" + unique ) > 0 ); |
285 | 283 | ||
286 | return unique; | 284 | return unique; |
287 | } | 285 | } |
288 | 286 | ||
289 | void POP3account::read() | 287 | void POP3account::read() |
290 | { | 288 | { |
291 | KConfig *conf = new KConfig( getFileName()); | 289 | KConfig *conf = new KConfig( getFileName()); |
292 | conf->setGroup( "POP3 Account" ); | 290 | conf->setGroup( "POP3 Account" ); |
293 | accountName = conf->readEntry( "Account" ); | 291 | accountName = conf->readEntry( "Account" ); |
294 | server = conf->readEntry( "Server" ); | 292 | server = conf->readEntry( "Server" ); |
295 | port = conf->readEntry( "Port" ); | 293 | port = conf->readEntry( "Port" ); |
296 | ssl = conf->readBoolEntry( "SSL" ); | 294 | ssl = conf->readBoolEntry( "SSL" ); |
297 | connectionType = conf->readNumEntry( "ConnectionType" ); | 295 | connectionType = conf->readNumEntry( "ConnectionType" ); |
298 | user = conf->readEntry( "User" ); | 296 | user = conf->readEntry( "User" ); |
299 | //password = conf->readEntryCrypt( "Password" ); | 297 | //password = conf->readEntryCrypt( "Password" ); |
300 | setPasswordList( conf->readListEntry( "FolderHistory")); | 298 | setPasswordList( conf->readListEntry( "FolderHistory")); |
301 | offline = conf->readBoolEntry("Offline",false); | 299 | offline = conf->readBoolEntry("Offline",false); |
302 | localFolder = conf->readEntry( "LocalFolder" ); | 300 | localFolder = conf->readEntry( "LocalFolder" ); |
303 | maxMailSize = conf->readNumEntry( "MaxSize",0 ); | 301 | maxMailSize = conf->readNumEntry( "MaxSize",0 ); |
304 | int lf = conf->readNumEntry( "LastFetch",0 ); | 302 | int lf = conf->readNumEntry( "LastFetch",0 ); |
305 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); | 303 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); |
306 | leaveOnServer = conf->readBoolEntry("LeaveOnServer",false); | 304 | leaveOnServer = conf->readBoolEntry("LeaveOnServer",false); |
307 | lastFetch = dt.addSecs( lf ); | 305 | lastFetch = dt.addSecs( lf ); |
308 | delete conf; | 306 | delete conf; |
309 | } | 307 | } |
310 | 308 | ||
311 | void POP3account::save() | 309 | void POP3account::save() |
312 | { | 310 | { |
313 | Settings::checkDirectory(); | 311 | Settings::checkDirectory(); |
314 | 312 | ||
315 | KConfig *conf = new KConfig( getFileName() ); | 313 | KConfig *conf = new KConfig( getFileName() ); |
316 | conf->setGroup( "POP3 Account" ); | 314 | conf->setGroup( "POP3 Account" ); |
317 | conf->writeEntry( "Account", accountName ); | 315 | conf->writeEntry( "Account", accountName ); |
318 | conf->writeEntry( "Server", server ); | 316 | conf->writeEntry( "Server", server ); |
319 | conf->writeEntry( "Port", port ); | 317 | conf->writeEntry( "Port", port ); |
320 | conf->writeEntry( "SSL", ssl ); | 318 | conf->writeEntry( "SSL", ssl ); |
321 | conf->writeEntry( "ConnectionType", connectionType ); | 319 | conf->writeEntry( "ConnectionType", connectionType ); |
322 | conf->writeEntry( "User", user ); | 320 | conf->writeEntry( "User", user ); |
323 | //conf->writeEntryCrypt( "Password", password ); | 321 | //conf->writeEntryCrypt( "Password", password ); |
324 | conf->writeEntry( "FolderHistory",getPasswordList() ); | 322 | conf->writeEntry( "FolderHistory",getPasswordList() ); |
325 | conf->writeEntry( "Offline",offline); | 323 | conf->writeEntry( "Offline",offline); |
326 | conf->writeEntry( "LocalFolder", localFolder ); | 324 | conf->writeEntry( "LocalFolder", localFolder ); |
327 | conf->writeEntry( "MaxSize", maxMailSize ); | 325 | conf->writeEntry( "MaxSize", maxMailSize ); |
328 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); | 326 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); |
329 | int lf = dt.secsTo ( lastFetch ); | 327 | int lf = dt.secsTo ( lastFetch ); |
330 | conf->writeEntry( "LastFetch", lf ); | 328 | conf->writeEntry( "LastFetch", lf ); |
331 | conf->writeEntry( "LeaveOnServer", leaveOnServer); | 329 | conf->writeEntry( "LeaveOnServer", leaveOnServer); |
332 | conf->sync(); | 330 | conf->sync(); |
333 | delete conf; | 331 | delete conf; |
334 | } | 332 | } |
335 | 333 | ||
336 | 334 | ||
337 | QString POP3account::getFileName() | 335 | QString POP3account::getFileName() |
338 | { | 336 | { |
339 | return locateLocal("data", "kopiemail" ) +"/pop3-" + file; | 337 | return locateLocal("data", "kopiemail" ) +"/pop3-" + file; |
340 | } | 338 | } |
341 | 339 | ||
342 | SMTPaccount::SMTPaccount() | 340 | SMTPaccount::SMTPaccount() |
343 | : Account() | 341 | : Account() |
344 | { | 342 | { |
345 | file = SMTPaccount::getUniqueFileName(); | 343 | file = SMTPaccount::getUniqueFileName(); |
346 | accountName = "New SMTP Account"; | 344 | accountName = "New SMTP Account"; |
347 | ssl = false; | 345 | ssl = false; |
348 | connectionType = 1; | 346 | connectionType = 1; |
349 | login = false; | 347 | login = false; |
350 | useCC = false; | 348 | useCC = false; |
351 | useBCC = false; | 349 | useBCC = false; |
352 | useReply = false; | 350 | useReply = false; |
353 | type = MAILLIB::A_SMTP; | 351 | type = MAILLIB::A_SMTP; |
354 | port = SMTP_PORT; | 352 | port = SMTP_PORT; |
355 | } | 353 | } |
356 | 354 | ||
357 | SMTPaccount::SMTPaccount( QString filename ) | 355 | SMTPaccount::SMTPaccount( QString filename ) |
358 | : Account() | 356 | : Account() |
359 | { | 357 | { |
360 | file = filename; | 358 | file = filename; |
361 | accountName = "New SMTP Account"; | 359 | accountName = "New SMTP Account"; |
362 | ssl = false; | 360 | ssl = false; |
363 | connectionType = 1; | 361 | connectionType = 1; |
364 | login = false; | 362 | login = false; |
365 | type = MAILLIB::A_SMTP; | 363 | type = MAILLIB::A_SMTP; |
366 | port = SMTP_PORT; | 364 | port = SMTP_PORT; |
367 | } | 365 | } |
368 | 366 | ||
369 | QString SMTPaccount::getUniqueFileName() | 367 | QString SMTPaccount::getUniqueFileName() |
370 | { | 368 | { |
371 | int num = 0; | 369 | int num = 0; |
372 | QString unique; | 370 | QString unique; |
373 | 371 | ||
374 | QDir dir( locateLocal("data", "kopiemail" ) ); | 372 | QDir dir( locateLocal("data", "kopiemail" ) ); |
375 | 373 | ||
376 | QStringList imap = dir.entryList( "smtp-*" ); | 374 | QStringList imap = dir.entryList( "smtp-*" ); |
377 | do { | 375 | do { |
378 | unique.setNum( num++ ); | 376 | unique.setNum( num++ ); |
379 | } while ( imap.contains( "smtp-" + unique ) > 0 ); | 377 | } while ( imap.contains( "smtp-" + unique ) > 0 ); |
380 | 378 | ||
381 | return unique; | 379 | return unique; |
382 | } | 380 | } |
383 | 381 | ||
384 | void SMTPaccount::read() | 382 | void SMTPaccount::read() |
385 | { | 383 | { |
386 | KConfig *conf = new KConfig( getFileName() ); | 384 | KConfig *conf = new KConfig( getFileName() ); |
387 | conf->setGroup( "SMTP Account" ); | 385 | conf->setGroup( "SMTP Account" ); |
388 | accountName = conf->readEntry( "Account" ); | 386 | accountName = conf->readEntry( "Account" ); |
389 | server = conf->readEntry( "Server" ); | 387 | server = conf->readEntry( "Server" ); |
390 | port = conf->readEntry( "Port" ); | 388 | port = conf->readEntry( "Port" ); |
391 | ssl = conf->readBoolEntry( "SSL" ); | 389 | ssl = conf->readBoolEntry( "SSL" ); |
392 | connectionType = conf->readNumEntry( "ConnectionType" ); | 390 | connectionType = conf->readNumEntry( "ConnectionType" ); |
393 | login = conf->readBoolEntry( "Login" ); | 391 | login = conf->readBoolEntry( "Login" ); |
394 | user = conf->readEntry( "User" ); | 392 | user = conf->readEntry( "User" ); |
395 | //password = conf->readEntryCrypt( "Password" ); | 393 | //password = conf->readEntryCrypt( "Password" ); |
396 | setPasswordList( conf->readListEntry( "FolderHistory")); | 394 | setPasswordList( conf->readListEntry( "FolderHistory")); |
397 | delete conf; | 395 | delete conf; |
398 | } | 396 | } |
399 | 397 | ||
400 | void SMTPaccount::save() | 398 | void SMTPaccount::save() |
401 | { | 399 | { |
402 | Settings::checkDirectory(); | 400 | Settings::checkDirectory(); |
403 | 401 | ||
404 | KConfig *conf = new KConfig( getFileName() ); | 402 | KConfig *conf = new KConfig( getFileName() ); |
405 | conf->setGroup( "SMTP Account" ); | 403 | conf->setGroup( "SMTP Account" ); |
406 | conf->writeEntry( "Account", accountName ); | 404 | conf->writeEntry( "Account", accountName ); |
407 | conf->writeEntry( "Server", server ); | 405 | conf->writeEntry( "Server", server ); |
408 | conf->writeEntry( "Port", port ); | 406 | conf->writeEntry( "Port", port ); |
409 | conf->writeEntry( "SSL", ssl ); | 407 | conf->writeEntry( "SSL", ssl ); |
410 | conf->writeEntry( "ConnectionType", connectionType ); | 408 | conf->writeEntry( "ConnectionType", connectionType ); |
411 | conf->writeEntry( "Login", login ); | 409 | conf->writeEntry( "Login", login ); |
412 | conf->writeEntry( "User", user ); | 410 | conf->writeEntry( "User", user ); |
413 | //conf->writeEntryCrypt( "Password", password ); | 411 | //conf->writeEntryCrypt( "Password", password ); |
414 | conf->writeEntry( "FolderHistory",getPasswordList() ); | 412 | conf->writeEntry( "FolderHistory",getPasswordList() ); |
415 | conf->sync(); | 413 | conf->sync(); |
416 | delete conf; | 414 | delete conf; |
417 | } | 415 | } |
418 | 416 | ||
419 | 417 | ||
420 | QString SMTPaccount::getFileName() | 418 | QString SMTPaccount::getFileName() |
421 | { | 419 | { |
422 | return locateLocal("data", "kopiemail" ) +"/smtp-" + file; | 420 | return locateLocal("data", "kopiemail" ) +"/smtp-" + file; |
423 | } | 421 | } |
424 | 422 | ||
425 | NNTPaccount::NNTPaccount() | 423 | NNTPaccount::NNTPaccount() |
426 | : Account() | 424 | : Account() |
427 | { | 425 | { |
428 | file = NNTPaccount::getUniqueFileName(); | 426 | file = NNTPaccount::getUniqueFileName(); |
429 | accountName = "New NNTP Account"; | 427 | accountName = "New NNTP Account"; |
430 | ssl = false; | 428 | ssl = false; |
431 | login = false; | 429 | login = false; |
432 | type = MAILLIB::A_NNTP; | 430 | type = MAILLIB::A_NNTP; |
433 | port = NNTP_PORT; | 431 | port = NNTP_PORT; |
434 | } | 432 | } |
435 | 433 | ||
436 | NNTPaccount::NNTPaccount( QString filename ) | 434 | NNTPaccount::NNTPaccount( QString filename ) |
437 | : Account() | 435 | : Account() |
438 | { | 436 | { |
439 | file = filename; | 437 | file = filename; |
440 | accountName = "New NNTP Account"; | 438 | accountName = "New NNTP Account"; |
441 | ssl = false; | 439 | ssl = false; |
442 | login = false; | 440 | login = false; |
443 | type = MAILLIB::A_NNTP; | 441 | type = MAILLIB::A_NNTP; |
444 | port = NNTP_PORT; | 442 | port = NNTP_PORT; |
445 | } | 443 | } |
446 | 444 | ||
447 | QString NNTPaccount::getUniqueFileName() | 445 | QString NNTPaccount::getUniqueFileName() |
448 | { | 446 | { |
449 | int num = 0; | 447 | int num = 0; |
450 | QString unique; | 448 | QString unique; |
451 | 449 | ||
452 | QDir dir( locateLocal("data", "kopiemail" ) ); | 450 | QDir dir( locateLocal("data", "kopiemail" ) ); |
453 | 451 | ||
454 | QStringList imap = dir.entryList( "nntp-*" ); | 452 | QStringList imap = dir.entryList( "nntp-*" ); |
455 | do { | 453 | do { |
456 | unique.setNum( num++ ); | 454 | unique.setNum( num++ ); |
457 | } while ( imap.contains( "nntp-" + unique ) > 0 ); | 455 | } while ( imap.contains( "nntp-" + unique ) > 0 ); |
458 | 456 | ||
459 | return unique; | 457 | return unique; |
460 | } | 458 | } |
461 | 459 | ||
462 | void NNTPaccount::read() | 460 | void NNTPaccount::read() |
463 | { | 461 | { |
464 | KConfig *conf = new KConfig( getFileName() ); | 462 | KConfig *conf = new KConfig( getFileName() ); |
465 | conf->setGroup( "NNTP Account" ); | 463 | conf->setGroup( "NNTP Account" ); |
466 | accountName = conf->readEntry( "Account" ); | 464 | accountName = conf->readEntry( "Account" ); |
467 | server = conf->readEntry( "Server" ); | 465 | server = conf->readEntry( "Server" ); |
468 | port = conf->readEntry( "Port" ); | 466 | port = conf->readEntry( "Port" ); |
469 | ssl = conf->readBoolEntry( "SSL" ); | 467 | ssl = conf->readBoolEntry( "SSL" ); |
470 | login = conf->readBoolEntry( "Login" ); | 468 | login = conf->readBoolEntry( "Login" ); |
471 | user = conf->readEntry( "User" ); | 469 | user = conf->readEntry( "User" ); |
472 | //password = conf->readEntryCrypt( "Password" ); | 470 | //password = conf->readEntryCrypt( "Password" ); |
473 | setPasswordList( conf->readListEntry( "FolderHistory")); | 471 | setPasswordList( conf->readListEntry( "FolderHistory")); |
474 | subscribedGroups = conf->readListEntry( "Subscribed"); | 472 | subscribedGroups = conf->readListEntry( "Subscribed"); |
475 | delete conf; | 473 | delete conf; |
476 | } | 474 | } |
477 | 475 | ||
478 | void NNTPaccount::save() | 476 | void NNTPaccount::save() |
479 | { | 477 | { |
480 | Settings::checkDirectory(); | 478 | Settings::checkDirectory(); |
481 | 479 | ||
482 | KConfig *conf = new KConfig( getFileName() ); | 480 | KConfig *conf = new KConfig( getFileName() ); |
483 | conf->setGroup( "NNTP Account" ); | 481 | conf->setGroup( "NNTP Account" ); |
484 | conf->writeEntry( "Account", accountName ); | 482 | conf->writeEntry( "Account", accountName ); |
485 | conf->writeEntry( "Server", server ); | 483 | conf->writeEntry( "Server", server ); |
486 | conf->writeEntry( "Port", port ); | 484 | conf->writeEntry( "Port", port ); |
487 | conf->writeEntry( "SSL", ssl ); | 485 | conf->writeEntry( "SSL", ssl ); |
488 | conf->writeEntry( "Login", login ); | 486 | conf->writeEntry( "Login", login ); |
489 | conf->writeEntry( "User", user ); | 487 | conf->writeEntry( "User", user ); |
490 | //conf->writeEntryCrypt( "Password", password ); | 488 | //conf->writeEntryCrypt( "Password", password ); |
491 | conf->writeEntry( "FolderHistory",getPasswordList() ); | 489 | conf->writeEntry( "FolderHistory",getPasswordList() ); |
492 | conf->writeEntry( "Subscribed" , subscribedGroups ); | 490 | conf->writeEntry( "Subscribed" , subscribedGroups ); |
493 | conf->sync(); | 491 | conf->sync(); |
494 | delete conf; | 492 | delete conf; |
495 | } | 493 | } |
496 | 494 | ||
497 | 495 | ||
498 | QString NNTPaccount::getFileName() | 496 | QString NNTPaccount::getFileName() |
499 | { | 497 | { |
500 | return locateLocal("data", "kopiemail" ) +"/nntp-" + file; | 498 | return locateLocal("data", "kopiemail" ) +"/nntp-" + file; |
501 | } | 499 | } |
diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp index 21edfd2..5f777a3 100644 --- a/kmicromail/mainwindow.cpp +++ b/kmicromail/mainwindow.cpp | |||
@@ -1,292 +1,297 @@ | |||
1 | 1 | ||
2 | // CHANGED 2004-08-06 Lutz Rogowski | 2 | // CHANGED 2004-08-06 Lutz Rogowski |
3 | #include <qlabel.h> | 3 | #include <qlabel.h> |
4 | #include <qvbox.h> | 4 | #include <qvbox.h> |
5 | #include <qheader.h> | 5 | #include <qheader.h> |
6 | #include <qtimer.h> | 6 | #include <qtimer.h> |
7 | #include <qlayout.h> | 7 | #include <qlayout.h> |
8 | #include <kdialog.h> | 8 | #include <kdialog.h> |
9 | #include <kiconloader.h> | 9 | #include <kiconloader.h> |
10 | #include <kapplication.h> | 10 | #include <kapplication.h> |
11 | 11 | ||
12 | #ifndef DESKTOP_VERSION | 12 | #ifndef DESKTOP_VERSION |
13 | #include <qpe/qpeapplication.h> | 13 | #include <qpe/qpeapplication.h> |
14 | #endif | 14 | #endif |
15 | #include "defines.h" | 15 | #include "defines.h" |
16 | #include "mainwindow.h" | 16 | #include "mainwindow.h" |
17 | #include <KDGanttMinimizeSplitter.h> | 17 | #include <KDGanttMinimizeSplitter.h> |
18 | 18 | ||
19 | 19 | ||
20 | #include <kabc/stdaddressbook.h> | 20 | #include <kabc/stdaddressbook.h> |
21 | 21 | ||
22 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | 22 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) |
23 | : QMainWindow( parent, name ) //, flags ) | 23 | : QMainWindow( parent, name ) //, flags ) |
24 | { | 24 | { |
25 | setCaption( tr( "KOpieMail/Pi" ) ); | 25 | setCaption( tr( "KOpieMail/Pi" ) ); |
26 | setToolBarsMovable( false ); | 26 | setToolBarsMovable( false ); |
27 | //KABC::StdAddressBook::self(); | 27 | //KABC::StdAddressBook::self(); |
28 | toolBar = new QToolBar( this ); | 28 | toolBar = new QToolBar( this ); |
29 | menuBar = new QPEMenuBar( toolBar ); | 29 | menuBar = new QPEMenuBar( toolBar ); |
30 | mailMenu = new QPopupMenu( menuBar ); | 30 | mailMenu = new QPopupMenu( menuBar ); |
31 | menuBar->insertItem( tr( "Mail" ), mailMenu ); | 31 | menuBar->insertItem( tr( "Mail" ), mailMenu ); |
32 | settingsMenu = new QPopupMenu( menuBar ); | 32 | settingsMenu = new QPopupMenu( menuBar ); |
33 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); | 33 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); |
34 | 34 | ||
35 | addToolBar( toolBar ); | 35 | addToolBar( toolBar ); |
36 | toolBar->setHorizontalStretchable( true ); | 36 | toolBar->setHorizontalStretchable( true ); |
37 | 37 | ||
38 | 38 | QAction* getMail = new QAction( tr( "Get new mail" ), SmallIcon("add"), | |
39 | 0, 0, this ); | ||
40 | getMail->addTo( toolBar ); | ||
41 | getMail->addTo( mailMenu ); | ||
42 | connect(getMail, SIGNAL( activated() ), | ||
43 | SLOT( slotGetMail() ) ); | ||
39 | 44 | ||
40 | composeMail = new QAction( tr( "Compose new mail" ), SmallIcon("composemail"), | 45 | composeMail = new QAction( tr( "Compose new mail" ), SmallIcon("composemail"), |
41 | 0, 0, this ); | 46 | 0, 0, this ); |
42 | composeMail->addTo( toolBar ); | 47 | composeMail->addTo( toolBar ); |
43 | composeMail->addTo( mailMenu ); | 48 | composeMail->addTo( mailMenu ); |
44 | 49 | ||
45 | sendQueued = new QAction( tr( "Send queued mails" ), SmallIcon("sendqueued") , | 50 | sendQueued = new QAction( tr( "Send queued mails" ), SmallIcon("sendqueued") , |
46 | 0, 0, this ); | 51 | 0, 0, this ); |
47 | sendQueued->addTo( toolBar ); | 52 | sendQueued->addTo( toolBar ); |
48 | sendQueued->addTo( mailMenu ); | 53 | sendQueued->addTo( mailMenu ); |
49 | 54 | ||
50 | /* | 55 | /* |
51 | syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, | 56 | syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, |
52 | 0, 0, this ); | 57 | 0, 0, this ); |
53 | syncFolders->addTo( toolBar ); | 58 | syncFolders->addTo( toolBar ); |
54 | syncFolders->addTo( mailMenu ); | 59 | syncFolders->addTo( mailMenu ); |
55 | */ | 60 | */ |
56 | 61 | ||
57 | showFolders = new QAction( tr( "Show/Hide folders" ), SmallIcon("showfolders") , | 62 | showFolders = new QAction( tr( "Show/Hide folders" ), SmallIcon("showfolders") , |
58 | 0, 0, this, 0, true ); | 63 | 0, 0, this, 0, true ); |
59 | showFolders->addTo( toolBar ); | 64 | showFolders->addTo( toolBar ); |
60 | showFolders->addTo( mailMenu ); | 65 | showFolders->addTo( mailMenu ); |
61 | showFolders->setOn( true ); | 66 | showFolders->setOn( true ); |
62 | connect(showFolders, SIGNAL( toggled(bool) ), | 67 | connect(showFolders, SIGNAL( toggled(bool) ), |
63 | SLOT( slotShowFolders(bool) ) ); | 68 | SLOT( slotShowFolders(bool) ) ); |
64 | 69 | ||
65 | /* | 70 | /* |
66 | searchMails = new QAction( tr( "Search mails" ), SmallIcon("find") ), | 71 | searchMails = new QAction( tr( "Search mails" ), SmallIcon("find") ), |
67 | 0, 0, this ); | 72 | 0, 0, this ); |
68 | searchMails->addTo( toolBar ); | 73 | searchMails->addTo( toolBar ); |
69 | searchMails->addTo( mailMenu ); | 74 | searchMails->addTo( mailMenu ); |
70 | */ | 75 | */ |
71 | 76 | ||
72 | deleteMails = new QAction(tr("Delete Mail"), SmallIcon("trash"), 0, 0, this); | 77 | deleteMails = new QAction(tr("Delete Mail"), SmallIcon("trash"), 0, 0, this); |
73 | deleteMails->addTo( toolBar ); | 78 | deleteMails->addTo( toolBar ); |
74 | deleteMails->addTo( mailMenu ); | 79 | deleteMails->addTo( mailMenu ); |
75 | connect( deleteMails, SIGNAL( activated() ), | 80 | connect( deleteMails, SIGNAL( activated() ), |
76 | SLOT( slotDeleteMail() ) ); | 81 | SLOT( slotDeleteMail() ) ); |
77 | 82 | ||
78 | editSettings = new QAction( tr( "Edit settings" ), SmallIcon("SettingsIcon") , | 83 | editSettings = new QAction( tr( "Edit settings" ), SmallIcon("SettingsIcon") , |
79 | 0, 0, this ); | 84 | 0, 0, this ); |
80 | editSettings->addTo( settingsMenu ); | 85 | editSettings->addTo( settingsMenu ); |
81 | connect( editSettings, SIGNAL( activated() ), | 86 | connect( editSettings, SIGNAL( activated() ), |
82 | SLOT( slotEditSettings() ) ); | 87 | SLOT( slotEditSettings() ) ); |
83 | editAccounts = new QAction( tr( "Configure accounts" ), SmallIcon("editaccounts") , | 88 | editAccounts = new QAction( tr( "Configure accounts" ), SmallIcon("editaccounts") , |
84 | 0, 0, this ); | 89 | 0, 0, this ); |
85 | editAccounts->addTo( settingsMenu ); | 90 | editAccounts->addTo( settingsMenu ); |
86 | 91 | ||
87 | //setCentralWidget( view ); | 92 | //setCentralWidget( view ); |
88 | 93 | ||
89 | QVBox* wrapperBox = new QVBox( this ); | 94 | QVBox* wrapperBox = new QVBox( this ); |
90 | setCentralWidget( wrapperBox ); | 95 | setCentralWidget( wrapperBox ); |
91 | 96 | ||
92 | // QWidget *view = new QWidget( wrapperBox ); | 97 | // QWidget *view = new QWidget( wrapperBox ); |
93 | KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox); | 98 | KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox); |
94 | split->setMinimizeDirection( KDGanttMinimizeSplitter::Left); | 99 | split->setMinimizeDirection( KDGanttMinimizeSplitter::Left); |
95 | //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight ); | 100 | //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight ); |
96 | 101 | ||
97 | folderView = new AccountView( split ); | 102 | folderView = new AccountView( split ); |
98 | folderView->header()->hide(); | 103 | folderView->header()->hide(); |
99 | folderView->setRootIsDecorated( false ); | 104 | folderView->setRootIsDecorated( false ); |
100 | folderView->addColumn( tr( "Mailbox" ) ); | 105 | folderView->addColumn( tr( "Mailbox" ) ); |
101 | 106 | ||
102 | //layout->addWidget( folderView ); | 107 | //layout->addWidget( folderView ); |
103 | 108 | ||
104 | mailView = new QListView( split ); | 109 | mailView = new QListView( split ); |
105 | mailView->addColumn( tr( " " ) ); | 110 | mailView->addColumn( tr( " " ) ); |
106 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); | 111 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); |
107 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); | 112 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); |
108 | mailView->addColumn( tr( "Size" ),QListView::Manual); | 113 | mailView->addColumn( tr( "Size" ),QListView::Manual); |
109 | mailView->addColumn( tr( "Date" ),QListView::Manual); | 114 | mailView->addColumn( tr( "Date" ),QListView::Manual); |
110 | mailView->setAllColumnsShowFocus(true); | 115 | mailView->setAllColumnsShowFocus(true); |
111 | //mailView->setSorting(-1); | 116 | //mailView->setSorting(-1); |
112 | mailView->setRootIsDecorated( false ); | 117 | mailView->setRootIsDecorated( false ); |
113 | statusWidget = new StatusWidget( wrapperBox ); | 118 | statusWidget = new StatusWidget( wrapperBox ); |
114 | statusWidget->hide(); | 119 | statusWidget->hide(); |
115 | 120 | ||
116 | //layout->addWidget( mailView ); | 121 | //layout->addWidget( mailView ); |
117 | //layout->setStretchFactor( folderView, 1 ); | 122 | //layout->setStretchFactor( folderView, 1 ); |
118 | //layout->setStretchFactor( mailView, 2 ); | 123 | //layout->setStretchFactor( mailView, 2 ); |
119 | 124 | ||
120 | slotAdjustLayout(); | 125 | slotAdjustLayout(); |
121 | #ifndef DESKTOP_VERSION | 126 | #ifndef DESKTOP_VERSION |
122 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); | 127 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); |
123 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); | 128 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); |
124 | #endif | 129 | #endif |
125 | connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this, | 130 | connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this, |
126 | SLOT( mailLeftClicked(QListViewItem*) ) ); | 131 | SLOT( mailLeftClicked(QListViewItem*) ) ); |
127 | connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this, | 132 | connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this, |
128 | SLOT( mailLeftClicked(QListViewItem*) ) ); | 133 | SLOT( mailLeftClicked(QListViewItem*) ) ); |
129 | connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, | 134 | connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, |
130 | SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); | 135 | SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); |
131 | connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), | 136 | connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), |
132 | this,SLOT(refreshMailView(const QValueList<RecMailP>&))); | 137 | this,SLOT(refreshMailView(const QValueList<RecMailP>&))); |
133 | connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); | 138 | connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); |
134 | connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); | 139 | connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); |
135 | // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); | 140 | // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); |
136 | connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); | 141 | connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); |
137 | //mailView->setMultiSelection ( true ); | 142 | //mailView->setMultiSelection ( true ); |
138 | mailView->setSelectionMode( QListView::Extended ); | 143 | mailView->setSelectionMode( QListView::Extended ); |
139 | QValueList<int> list; | 144 | QValueList<int> list; |
140 | int fw = 100; | 145 | int fw = 100; |
141 | if ( QApplication::desktop()->width() > 320 ) | 146 | if ( QApplication::desktop()->width() > 320 ) |
142 | fw = 50; | 147 | fw = 50; |
143 | list.append( fw ); | 148 | list.append( fw ); |
144 | list.append( 100 ); | 149 | list.append( 100 ); |
145 | split->setSizes( list ); | 150 | split->setSizes( list ); |
146 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); | 151 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); |
147 | mailView->setShowSortIndicator ( true ); | 152 | mailView->setShowSortIndicator ( true ); |
148 | QLabel *spacer = new QLabel( toolBar ); | 153 | QLabel *spacer = new QLabel( toolBar ); |
149 | spacer->setBackgroundMode( QWidget::PaletteButton ); | 154 | spacer->setBackgroundMode( QWidget::PaletteButton ); |
150 | toolBar->setStretchableWidget( spacer ); | 155 | toolBar->setStretchableWidget( spacer ); |
151 | 156 | ||
152 | QAction* closeMail = new QAction(tr("Close"),SmallIcon("exit"), 0, 0, this); | 157 | QAction* closeMail = new QAction(tr("Close"),SmallIcon("exit"), 0, 0, this); |
153 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); | 158 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); |
154 | closeMail->addTo(toolBar); | 159 | closeMail->addTo(toolBar); |
155 | closeMail->addTo(mailMenu); | 160 | closeMail->addTo(mailMenu); |
156 | 161 | ||
157 | 162 | ||
158 | QPopupMenu* helpMenu = new QPopupMenu( menuBar ); | 163 | QPopupMenu* helpMenu = new QPopupMenu( menuBar ); |
159 | menuBar->insertItem( tr( "Help" ), helpMenu ); | 164 | menuBar->insertItem( tr( "Help" ), helpMenu ); |
160 | QAction* li = new QAction(tr("About"), QPixmap(), 0, 0, this); | 165 | QAction* li = new QAction(tr("About"), QPixmap(), 0, 0, this); |
161 | connect( li, SIGNAL( activated() ), SLOT( showAbout()) ); | 166 | connect( li, SIGNAL( activated() ), SLOT( showAbout()) ); |
162 | li->addTo(helpMenu); | 167 | li->addTo(helpMenu); |
163 | li = new QAction(tr("Licence"),QPixmap(), 0, 0, this); | 168 | li = new QAction(tr("Licence"),QPixmap(), 0, 0, this); |
164 | connect( li, SIGNAL( activated() ), SLOT( showLicence()) ); | 169 | connect( li, SIGNAL( activated() ), SLOT( showLicence()) ); |
165 | li->addTo(helpMenu); | 170 | li->addTo(helpMenu); |
166 | li = new QAction(tr("LibEtPan Licence"), QPixmap(), 0, 0, this); | 171 | li = new QAction(tr("LibEtPan Licence"), QPixmap(), 0, 0, this); |
167 | connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) ); | 172 | connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) ); |
168 | li->addTo(helpMenu); | 173 | li->addTo(helpMenu); |
169 | } | 174 | } |
170 | 175 | ||
171 | MainWindow::~MainWindow() | 176 | MainWindow::~MainWindow() |
172 | { | 177 | { |
173 | } | 178 | } |
174 | 179 | ||
175 | void MainWindow::showLicence() | 180 | void MainWindow::showLicence() |
176 | { | 181 | { |
177 | KApplication::showLicence(); | 182 | KApplication::showLicence(); |
178 | } | 183 | } |
179 | void MainWindow::showAbout() | 184 | void MainWindow::showAbout() |
180 | { | 185 | { |
181 | QString version; | 186 | QString version; |
182 | #include <../version> | 187 | #include <../version> |
183 | 188 | ||
184 | QString cap = "About KOpieMail/Pi"; | 189 | QString cap = "About KOpieMail/Pi"; |
185 | QString text =i18n("KOpieMail/Platform-independent\n") + | 190 | QString text =i18n("KOpieMail/Platform-independent\n") + |
186 | "(OM/Pi) " + version + " - " | 191 | "(OM/Pi) " + version + " - " |
187 | 192 | ||
188 | #ifdef DESKTOP_VERSION | 193 | #ifdef DESKTOP_VERSION |
189 | "Desktop Edition\n" | 194 | "Desktop Edition\n" |
190 | #else | 195 | #else |
191 | "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n" | 196 | "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n" |
192 | #endif | 197 | #endif |
193 | "www.pi-sync.net\n\n" | 198 | "www.pi-sync.net\n\n" |
194 | 199 | ||
195 | 200 | ||
196 | 201 | ||
197 | "Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n" | 202 | "Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n" |
198 | "KOpieMail/Pi is based on Opie Mail\n" | 203 | "KOpieMail/Pi is based on Opie Mail\n" |
199 | "Copyright (c) Rajko Albrecht and the Opie team\n" | 204 | "Copyright (c) Rajko Albrecht and the Opie team\n" |
200 | "KOpieMail/Pi is licensed under the GPL\n" | 205 | "KOpieMail/Pi is licensed under the GPL\n" |
201 | "\n" | 206 | "\n" |
202 | "KOpieMail/Pi uses LibEtPan - a mail stuff library\n" | 207 | "KOpieMail/Pi uses LibEtPan - a mail stuff library\n" |
203 | "Copyright (C) 2001, 2002 - DINH Viet Hoa\n" | 208 | "Copyright (C) 2001, 2002 - DINH Viet Hoa\n" |
204 | "libEtPan has its own licence - see LibEtPan licence\n"; | 209 | "libEtPan has its own licence - see LibEtPan licence\n"; |
205 | 210 | ||
206 | KApplication::showText( cap, text ); | 211 | KApplication::showText( cap, text ); |
207 | } | 212 | } |
208 | void MainWindow::showEtpanLicence() | 213 | void MainWindow::showEtpanLicence() |
209 | { | 214 | { |
210 | KApplication::showFile( "LibEtPan licence", "kdepim/kopiemail/COPYRIGHTlibetpan" ); | 215 | KApplication::showFile( "LibEtPan licence", "kdepim/kopiemail/COPYRIGHTlibetpan" ); |
211 | 216 | ||
212 | } | 217 | } |
213 | void MainWindow::appMessage(const QCString &, const QByteArray &) | 218 | void MainWindow::appMessage(const QCString &, const QByteArray &) |
214 | { | 219 | { |
215 | qDebug("appMessage implemented by subclass"); | 220 | qDebug("appMessage implemented by subclass"); |
216 | } | 221 | } |
217 | 222 | ||
218 | void MainWindow::slotAdjustLayout() { | 223 | void MainWindow::slotAdjustLayout() { |
219 | 224 | ||
220 | /* | 225 | /* |
221 | QWidget *d = QApplication::desktop(); | 226 | QWidget *d = QApplication::desktop(); |
222 | 227 | ||
223 | if ( d->width() < d->height() ) { | 228 | if ( d->width() < d->height() ) { |
224 | layout->setDirection( QBoxLayout::TopToBottom ); | 229 | layout->setDirection( QBoxLayout::TopToBottom ); |
225 | } else { | 230 | } else { |
226 | layout->setDirection( QBoxLayout::LeftToRight ); | 231 | layout->setDirection( QBoxLayout::LeftToRight ); |
227 | } | 232 | } |
228 | */ | 233 | */ |
229 | } | 234 | } |
230 | 235 | ||
231 | void MainWindow::slotAdjustColumns() | 236 | void MainWindow::slotAdjustColumns() |
232 | { | 237 | { |
233 | bool hidden = folderView->isHidden(); | 238 | bool hidden = folderView->isHidden(); |
234 | if ( hidden ) folderView->show(); | 239 | if ( hidden ) folderView->show(); |
235 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); | 240 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); |
236 | if ( hidden ) folderView->hide(); | 241 | if ( hidden ) folderView->hide(); |
237 | 242 | ||
238 | mailView->setColumnWidth( 0, 10 ); | 243 | mailView->setColumnWidth( 0, 10 ); |
239 | mailView->setColumnWidth( 1, 100 ); | 244 | mailView->setColumnWidth( 1, 100 ); |
240 | mailView->setColumnWidth( 2, 100 ); | 245 | mailView->setColumnWidth( 2, 100 ); |
241 | mailView->setColumnWidth( 3, 50 ); | 246 | mailView->setColumnWidth( 3, 50 ); |
242 | mailView->setColumnWidth( 4, 120 ); | 247 | mailView->setColumnWidth( 4, 120 ); |
243 | } | 248 | } |
244 | 249 | ||
245 | void MainWindow::slotEditSettings() | 250 | void MainWindow::slotEditSettings() |
246 | { | 251 | { |
247 | } | 252 | } |
248 | 253 | ||
249 | void MainWindow::slotShowFolders( bool ) | 254 | void MainWindow::slotShowFolders( bool ) |
250 | { | 255 | { |
251 | qDebug("not implemented: "); | 256 | qDebug("not implemented: "); |
252 | } | 257 | } |
253 | 258 | ||
254 | void MainWindow::refreshMailView(const QValueList<RecMailP>&) | 259 | void MainWindow::refreshMailView(const QValueList<RecMailP>&) |
255 | { | 260 | { |
256 | qDebug("not implemented: "); | 261 | qDebug("not implemented: "); |
257 | } | 262 | } |
258 | 263 | ||
259 | void MainWindow::mailLeftClicked(QListViewItem * ) | 264 | void MainWindow::mailLeftClicked(QListViewItem * ) |
260 | { | 265 | { |
261 | qDebug("not implemented: "); | 266 | qDebug("not implemented: "); |
262 | } | 267 | } |
263 | 268 | ||
264 | void MainWindow::displayMail() | 269 | void MainWindow::displayMail() |
265 | { | 270 | { |
266 | qDebug("not implemented: "); | 271 | qDebug("not implemented: "); |
267 | } | 272 | } |
268 | 273 | ||
269 | void MainWindow::slotDeleteMail() | 274 | void MainWindow::slotDeleteMail() |
270 | { | 275 | { |
271 | qDebug("not implemented: "); | 276 | qDebug("not implemented: "); |
272 | } | 277 | } |
273 | 278 | ||
274 | void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) | 279 | void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) |
275 | { | 280 | { |
276 | qDebug("not implemented: "); | 281 | qDebug("not implemented: "); |
277 | } | 282 | } |
278 | 283 | ||
279 | void MainWindow::slotSendQueued() | 284 | void MainWindow::slotSendQueued() |
280 | { | 285 | { |
281 | qDebug("not implemented: "); | 286 | qDebug("not implemented: "); |
282 | } | 287 | } |
283 | 288 | ||
284 | void MainWindow::slotEditAccounts() | 289 | void MainWindow::slotEditAccounts() |
285 | { | 290 | { |
286 | qDebug("not implemented: "); | 291 | qDebug("not implemented: "); |
287 | } | 292 | } |
288 | 293 | ||
289 | void MainWindow::slotComposeMail() | 294 | void MainWindow::slotComposeMail() |
290 | { | 295 | { |
291 | qDebug("not implemented: "); | 296 | qDebug("not implemented: "); |
292 | } | 297 | } |
diff --git a/kmicromail/mainwindow.h b/kmicromail/mainwindow.h index 680f0a9..ff0ff20 100644 --- a/kmicromail/mainwindow.h +++ b/kmicromail/mainwindow.h | |||
@@ -1,65 +1,66 @@ | |||
1 | 1 | ||
2 | // CHANGED 2004-08-06 Lutz Rogowski | 2 | // CHANGED 2004-08-06 Lutz Rogowski |
3 | #ifndef MAINWINDOW_H | 3 | #ifndef MAINWINDOW_H |
4 | #define MAINWINDOW_H | 4 | #define MAINWINDOW_H |
5 | 5 | ||
6 | #include <qmainwindow.h> | 6 | #include <qmainwindow.h> |
7 | #include <qlistview.h> | 7 | #include <qlistview.h> |
8 | #include <qaction.h> | 8 | #include <qaction.h> |
9 | 9 | ||
10 | #include <qtoolbar.h> | 10 | #include <qtoolbar.h> |
11 | #ifdef DESKTOP_VERSION | 11 | #ifdef DESKTOP_VERSION |
12 | #include <qmenubar.h> | 12 | #include <qmenubar.h> |
13 | #else | 13 | #else |
14 | #include <qpe/qpemenubar.h> | 14 | #include <qpe/qpemenubar.h> |
15 | #endif | 15 | #endif |
16 | 16 | ||
17 | #include "accountview.h" | 17 | #include "accountview.h" |
18 | #include "statuswidget.h" | 18 | #include "statuswidget.h" |
19 | 19 | ||
20 | #include <libmailwrapper/mailtypes.h> | 20 | #include <libmailwrapper/mailtypes.h> |
21 | #include <opie2/osmartpointer.h> | 21 | #include <opie2/osmartpointer.h> |
22 | 22 | ||
23 | class RecMail; | 23 | class RecMail; |
24 | 24 | ||
25 | class MainWindow : public QMainWindow | 25 | class MainWindow : public QMainWindow |
26 | { | 26 | { |
27 | Q_OBJECT | 27 | Q_OBJECT |
28 | 28 | ||
29 | public: | 29 | public: |
30 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); | 30 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); |
31 | virtual ~MainWindow(); | 31 | virtual ~MainWindow(); |
32 | 32 | ||
33 | public slots: | 33 | public slots: |
34 | virtual void slotAdjustColumns(); | 34 | virtual void slotAdjustColumns(); |
35 | virtual void appMessage(const QCString &msg, const QByteArray &data); | 35 | virtual void appMessage(const QCString &msg, const QByteArray &data); |
36 | virtual void slotComposeMail(); | 36 | virtual void slotComposeMail(); |
37 | 37 | ||
38 | protected slots: | 38 | protected slots: |
39 | virtual void slotSendQueued(); | 39 | virtual void slotSendQueued(); |
40 | virtual void slotEditAccounts(); | 40 | virtual void slotEditAccounts(); |
41 | virtual void slotShowFolders( bool show ); | 41 | virtual void slotShowFolders( bool show ); |
42 | virtual void refreshMailView(const QValueList<RecMailP>&); | 42 | virtual void refreshMailView(const QValueList<RecMailP>&); |
43 | virtual void displayMail(); | 43 | virtual void displayMail(); |
44 | virtual void slotGetMail() = 0; | ||
44 | virtual void slotDeleteMail(); | 45 | virtual void slotDeleteMail(); |
45 | virtual void mailHold(int, QListViewItem *,const QPoint&,int); | 46 | virtual void mailHold(int, QListViewItem *,const QPoint&,int); |
46 | virtual void slotAdjustLayout(); | 47 | virtual void slotAdjustLayout(); |
47 | virtual void slotEditSettings(); | 48 | virtual void slotEditSettings(); |
48 | virtual void mailLeftClicked( QListViewItem * ); | 49 | virtual void mailLeftClicked( QListViewItem * ); |
49 | void showLicence(); | 50 | void showLicence(); |
50 | void showAbout(); | 51 | void showAbout(); |
51 | void showEtpanLicence(); | 52 | void showEtpanLicence(); |
52 | 53 | ||
53 | protected: | 54 | protected: |
54 | QToolBar *toolBar; | 55 | QToolBar *toolBar; |
55 | StatusWidget *statusWidget; | 56 | StatusWidget *statusWidget; |
56 | QPEMenuBar *menuBar; | 57 | QPEMenuBar *menuBar; |
57 | QPopupMenu *mailMenu, *settingsMenu; | 58 | QPopupMenu *mailMenu, *settingsMenu; |
58 | QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, | 59 | QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, |
59 | *editSettings, *editAccounts, *syncFolders; | 60 | *editSettings, *editAccounts, *syncFolders; |
60 | AccountView *folderView; | 61 | AccountView *folderView; |
61 | QListView *mailView; | 62 | QListView *mailView; |
62 | //QBoxLayout *layout; | 63 | //QBoxLayout *layout; |
63 | }; | 64 | }; |
64 | 65 | ||
65 | #endif | 66 | #endif |
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index b2119e6..19ffdb3 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -1,441 +1,449 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | // CHANGED 2004-08-06 Lutz Rogowski | 2 | // CHANGED 2004-08-06 Lutz Rogowski |
3 | 3 | ||
4 | #include "settingsdialog.h" | 4 | #include "settingsdialog.h" |
5 | #include "opiemail.h" | 5 | #include "opiemail.h" |
6 | #include "editaccounts.h" | 6 | #include "editaccounts.h" |
7 | #include "composemail.h" | 7 | #include "composemail.h" |
8 | #include "mailistviewitem.h" | 8 | #include "mailistviewitem.h" |
9 | #include "viewmail.h" | 9 | #include "viewmail.h" |
10 | #include "selectstore.h" | 10 | #include "selectstore.h" |
11 | #include "selectsmtp.h" | 11 | #include "selectsmtp.h" |
12 | #include "accountitem.h" | ||
12 | 13 | ||
13 | #include <qmessagebox.h> | 14 | #include <qmessagebox.h> |
14 | #include <qtimer.h> | 15 | #include <qtimer.h> |
15 | #include <libkdepim/externalapphandler.h> | 16 | #include <libkdepim/externalapphandler.h> |
16 | 17 | ||
17 | #include <qpe/qpeapplication.h> | 18 | #include <qpe/qpeapplication.h> |
18 | #include <libmailwrapper/smtpwrapper.h> | 19 | #include <libmailwrapper/smtpwrapper.h> |
19 | #include <libmailwrapper/mailtypes.h> | 20 | #include <libmailwrapper/mailtypes.h> |
20 | #include <libmailwrapper/abstractmail.h> | 21 | #include <libmailwrapper/abstractmail.h> |
21 | /* OPIE */ | 22 | /* OPIE */ |
22 | //#include <qpe/resource.h> | 23 | //#include <qpe/resource.h> |
23 | //#include <qpe/qpeapplication.h> | 24 | //#include <qpe/qpeapplication.h> |
24 | 25 | ||
25 | /* QT */ | 26 | /* QT */ |
26 | 27 | ||
27 | //using namespace Opie::Core; | 28 | //using namespace Opie::Core; |
28 | 29 | ||
29 | OpieMail::OpieMail( QWidget *parent, const char *name ) | 30 | OpieMail::OpieMail( QWidget *parent, const char *name ) |
30 | : MainWindow( parent, name) //, WStyle_ContextHelp ) | 31 | : MainWindow( parent, name) //, WStyle_ContextHelp ) |
31 | { | 32 | { |
32 | settings = new Settings(); | 33 | settings = new Settings(); |
33 | 34 | ||
34 | folderView->populate( settings->getAccounts() ); | 35 | folderView->populate( settings->getAccounts() ); |
35 | 36 | ||
36 | } | 37 | } |
37 | 38 | ||
38 | OpieMail::~OpieMail() | 39 | OpieMail::~OpieMail() |
39 | { | 40 | { |
40 | if (settings) delete settings; | 41 | if (settings) delete settings; |
41 | } | 42 | } |
42 | 43 | ||
43 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 44 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
44 | { | 45 | { |
45 | 46 | ||
46 | } | 47 | } |
47 | #include <stdlib.h> | 48 | #include <stdlib.h> |
48 | void OpieMail::message(const QCString &msg, const QByteArray &data) | 49 | void OpieMail::message(const QCString &msg, const QByteArray &data) |
49 | { | 50 | { |
50 | // copied from old mail2 | 51 | // copied from old mail2 |
51 | static int ii = 0; | 52 | static int ii = 0; |
52 | //qDebug("QCOP CALL ############################# %d ", ii); | 53 | //qDebug("QCOP CALL ############################# %d ", ii); |
53 | //QString mess ( msg ); | 54 | //QString mess ( msg ); |
54 | //qDebug("Message = %s ",mess.latin1()); | 55 | //qDebug("Message = %s ",mess.latin1()); |
55 | ++ii; | 56 | ++ii; |
56 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); | 57 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); |
57 | 58 | ||
58 | mPendingEmail = QString::null; | 59 | mPendingEmail = QString::null; |
59 | mPendingName = QString::null; | 60 | mPendingName = QString::null; |
60 | if (msg == "writeMail(QString,QString)") | 61 | if (msg == "writeMail(QString,QString)") |
61 | { | 62 | { |
62 | //qDebug("writeMail(QString,QString) "); | 63 | //qDebug("writeMail(QString,QString) "); |
63 | QDataStream stream(data,IO_ReadOnly); | 64 | QDataStream stream(data,IO_ReadOnly); |
64 | stream >> mPendingName >> mPendingEmail; | 65 | stream >> mPendingName >> mPendingEmail; |
65 | // removing the whitespaces at beginning and end is needed! | 66 | // removing the whitespaces at beginning and end is needed! |
66 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 67 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
67 | } | 68 | } |
68 | else if (msg == "newMail()") | 69 | else if (msg == "newMail()") |
69 | { | 70 | { |
70 | //qDebug("slotComposeMail() "); | 71 | //qDebug("slotComposeMail() "); |
71 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call | 72 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call |
72 | // and a QCOP call does not like a processevents in his execution | 73 | // and a QCOP call does not like a processevents in his execution |
73 | // with the Qtimer we call slotComposeMail() after we reached the main event loop | 74 | // with the Qtimer we call slotComposeMail() after we reached the main event loop |
74 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 75 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
75 | // slotComposeMail(); | 76 | // slotComposeMail(); |
76 | } | 77 | } |
77 | else if (msg == "newMail(QString)") | 78 | else if (msg == "newMail(QString)") |
78 | { | 79 | { |
79 | //qDebug(" newMail(QString)"); | 80 | //qDebug(" newMail(QString)"); |
80 | QDataStream stream(data,IO_ReadOnly); | 81 | QDataStream stream(data,IO_ReadOnly); |
81 | stream >> mPendingName; | 82 | stream >> mPendingName; |
82 | // the format is | 83 | // the format is |
83 | // NAME <EMAIL>:SUBJECT | 84 | // NAME <EMAIL>:SUBJECT |
84 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 85 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
85 | } else { | 86 | } else { |
86 | if ( ii == 1 ) { | 87 | if ( ii == 1 ) { |
87 | qDebug("Kopiemail::Error:: Initial QCOP call for ExternalAppHandler not supported "); | 88 | qDebug("Kopiemail::Error:: Initial QCOP call for ExternalAppHandler not supported "); |
88 | return; | 89 | return; |
89 | } | 90 | } |
90 | ExternalAppHandler::instance()->appMessage ( msg, data); | 91 | ExternalAppHandler::instance()->appMessage ( msg, data); |
91 | } | 92 | } |
92 | 93 | ||
93 | //qDebug("END OpieMail::message "); | 94 | //qDebug("END OpieMail::message "); |
94 | } | 95 | } |
95 | void OpieMail::slotwriteMail2(const QString& namemail ) | 96 | void OpieMail::slotwriteMail2(const QString& namemail ) |
96 | { | 97 | { |
97 | //qDebug("OpieMail::slotwriteMail2 "); | 98 | //qDebug("OpieMail::slotwriteMail2 "); |
98 | //qApp->processEvents(); | 99 | //qApp->processEvents(); |
99 | ComposeMail compose( settings, this, 0, true ); | 100 | ComposeMail compose( settings, this, 0, true ); |
100 | if ( !namemail.isEmpty() ) { | 101 | if ( !namemail.isEmpty() ) { |
101 | QString to = namemail; | 102 | QString to = namemail; |
102 | if ( namemail.find( " <") > 1 ) { | 103 | if ( namemail.find( " <") > 1 ) { |
103 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; | 104 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; |
104 | } else | 105 | } else |
105 | if ( namemail.find( "<") > 1 ) { | 106 | if ( namemail.find( "<") > 1 ) { |
106 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; | 107 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; |
107 | } | 108 | } |
108 | int sub = to.find( ">:"); | 109 | int sub = to.find( ">:"); |
109 | if ( sub > 0 ) { | 110 | if ( sub > 0 ) { |
110 | compose.setTo( to.left(sub+1) ); | 111 | compose.setTo( to.left(sub+1) ); |
111 | compose.setSubject( to.mid(sub+2) ); | 112 | compose.setSubject( to.mid(sub+2) ); |
112 | } else | 113 | } else |
113 | compose.setTo( to ); | 114 | compose.setTo( to ); |
114 | } | 115 | } |
115 | compose.slotAdjustColumns(); | 116 | compose.slotAdjustColumns(); |
116 | compose.showMaximized(); | 117 | compose.showMaximized(); |
117 | compose.exec(); | 118 | compose.exec(); |
118 | raise(); | 119 | raise(); |
119 | //qDebug("retttich "); | 120 | //qDebug("retttich "); |
120 | } | 121 | } |
121 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 122 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
122 | { | 123 | { |
123 | // qDebug("OpieMail::slotwriteMail "); | 124 | // qDebug("OpieMail::slotwriteMail "); |
124 | ComposeMail compose( settings, this, 0, true ); | 125 | ComposeMail compose( settings, this, 0, true ); |
125 | if (!email.isEmpty()) | 126 | if (!email.isEmpty()) |
126 | { | 127 | { |
127 | if (!name.isEmpty()) | 128 | if (!name.isEmpty()) |
128 | { | 129 | { |
129 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 130 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
130 | } | 131 | } |
131 | else | 132 | else |
132 | { | 133 | { |
133 | compose.setTo(email); | 134 | compose.setTo(email); |
134 | } | 135 | } |
135 | } | 136 | } |
136 | compose.slotAdjustColumns(); | 137 | compose.slotAdjustColumns(); |
137 | compose.showMaximized(); | 138 | compose.showMaximized(); |
138 | compose.exec(); | 139 | compose.exec(); |
139 | raise(); | 140 | raise(); |
140 | } | 141 | } |
141 | 142 | ||
142 | void OpieMail::slotComposeMail() | 143 | void OpieMail::slotComposeMail() |
143 | { | 144 | { |
144 | if ( mPendingEmail == QString::null && mPendingName == QString::null) | 145 | if ( mPendingEmail == QString::null && mPendingName == QString::null) |
145 | slotwriteMail2( QString () ); | 146 | slotwriteMail2( QString () ); |
146 | else { | 147 | else { |
147 | if ( mPendingEmail == QString::null ) | 148 | if ( mPendingEmail == QString::null ) |
148 | slotwriteMail2( mPendingName ); | 149 | slotwriteMail2( mPendingName ); |
149 | else | 150 | else |
150 | slotwriteMail( mPendingName, mPendingEmail ); | 151 | slotwriteMail( mPendingName, mPendingEmail ); |
151 | } | 152 | } |
152 | //slotwriteMail(0l,0l); | 153 | //slotwriteMail(0l,0l); |
153 | } | 154 | } |
154 | 155 | ||
155 | void OpieMail::slotSendQueued() | 156 | void OpieMail::slotSendQueued() |
156 | { | 157 | { |
157 | SMTPaccount *smtp = 0; | 158 | SMTPaccount *smtp = 0; |
158 | 159 | ||
159 | QList<Account> list = settings->getAccounts(); | 160 | QList<Account> list = settings->getAccounts(); |
160 | QList<SMTPaccount> smtpList; | 161 | QList<SMTPaccount> smtpList; |
161 | smtpList.setAutoDelete(false); | 162 | smtpList.setAutoDelete(false); |
162 | Account *it; | 163 | Account *it; |
163 | for ( it = list.first(); it; it = list.next() ) | 164 | for ( it = list.first(); it; it = list.next() ) |
164 | { | 165 | { |
165 | if ( it->getType() == MAILLIB::A_SMTP ) | 166 | if ( it->getType() == MAILLIB::A_SMTP ) |
166 | { | 167 | { |
167 | smtp = static_cast<SMTPaccount *>(it); | 168 | smtp = static_cast<SMTPaccount *>(it); |
168 | smtpList.append(smtp); | 169 | smtpList.append(smtp); |
169 | } | 170 | } |
170 | } | 171 | } |
171 | if (smtpList.count()==0) | 172 | if (smtpList.count()==0) |
172 | { | 173 | { |
173 | QMessageBox::information(0,tr("Info"),tr("Define a smtp account first!\n")); | 174 | QMessageBox::information(0,tr("Info"),tr("Define a smtp account first!\n")); |
174 | return; | 175 | return; |
175 | } | 176 | } |
176 | if (smtpList.count()==1) | 177 | if (smtpList.count()==1) |
177 | { | 178 | { |
178 | smtp = smtpList.at(0); | 179 | smtp = smtpList.at(0); |
179 | } | 180 | } |
180 | else | 181 | else |
181 | { | 182 | { |
182 | smtp = 0; | 183 | smtp = 0; |
183 | selectsmtp selsmtp; | 184 | selectsmtp selsmtp; |
184 | selsmtp.setSelectionlist(&smtpList); | 185 | selsmtp.setSelectionlist(&smtpList); |
185 | selsmtp.showMaximized(); | 186 | selsmtp.showMaximized(); |
186 | if ( selsmtp.exec() == QDialog::Accepted ) | 187 | if ( selsmtp.exec() == QDialog::Accepted ) |
187 | { | 188 | { |
188 | smtp = selsmtp.selected_smtp(); | 189 | smtp = selsmtp.selected_smtp(); |
189 | } | 190 | } |
190 | } | 191 | } |
191 | if (smtp) | 192 | if (smtp) |
192 | { | 193 | { |
193 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 194 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
194 | if ( wrap->flushOutbox() ) | 195 | if ( wrap->flushOutbox() ) |
195 | { | 196 | { |
196 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); | 197 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); |
197 | } | 198 | } |
198 | delete wrap; | 199 | delete wrap; |
199 | } | 200 | } |
200 | } | 201 | } |
201 | 202 | ||
202 | void OpieMail::slotSearchMails() | 203 | void OpieMail::slotSearchMails() |
203 | { | 204 | { |
204 | qDebug("OpieMail::slotSearchMails():not implemented "); | 205 | qDebug("OpieMail::slotSearchMails():not implemented "); |
205 | } | 206 | } |
206 | 207 | ||
207 | void OpieMail::slotEditSettings() | 208 | void OpieMail::slotEditSettings() |
208 | { | 209 | { |
209 | SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); | 210 | SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); |
210 | settingsDialog.showMaximized(); | 211 | settingsDialog.showMaximized(); |
211 | settingsDialog.exec(); | 212 | settingsDialog.exec(); |
212 | } | 213 | } |
213 | 214 | ||
214 | void OpieMail::slotEditAccounts() | 215 | void OpieMail::slotEditAccounts() |
215 | { | 216 | { |
216 | EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); | 217 | EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); |
217 | eaDialog.slotAdjustColumns(); | 218 | eaDialog.slotAdjustColumns(); |
218 | eaDialog.showMaximized(); | 219 | eaDialog.showMaximized(); |
219 | eaDialog.exec(); | 220 | eaDialog.exec(); |
220 | if ( settings ) delete settings; | 221 | if ( settings ) delete settings; |
221 | settings = new Settings(); | 222 | settings = new Settings(); |
222 | 223 | ||
223 | folderView->populate( settings->getAccounts() ); | 224 | folderView->populate( settings->getAccounts() ); |
224 | } | 225 | } |
225 | 226 | ||
226 | void OpieMail::displayMail() | 227 | void OpieMail::displayMail() |
227 | { | 228 | { |
228 | QListViewItem*item = mailView->currentItem(); | 229 | QListViewItem*item = mailView->currentItem(); |
229 | if (!item) return; | 230 | if (!item) return; |
230 | RecMailP mail = ((MailListViewItem*)item)->data(); | 231 | RecMailP mail = ((MailListViewItem*)item)->data(); |
231 | RecBodyP body = folderView->fetchBody(mail); | 232 | RecBodyP body = folderView->fetchBody(mail); |
232 | ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); | 233 | ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); |
233 | readMail.setBody( body ); | 234 | readMail.setBody( body ); |
234 | readMail.setMail( mail ); | 235 | readMail.setMail( mail ); |
235 | readMail.showMaximized(); | 236 | readMail.showMaximized(); |
236 | readMail.exec(); | 237 | readMail.exec(); |
237 | 238 | ||
238 | if ( readMail.deleted ) | 239 | if ( readMail.deleted ) |
239 | { | 240 | { |
240 | folderView->refreshCurrent(); | 241 | folderView->refreshCurrent(); |
241 | } | 242 | } |
242 | else | 243 | else |
243 | { | 244 | { |
244 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 245 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
245 | } | 246 | } |
246 | } | 247 | } |
247 | 248 | void OpieMail::slotGetMail() | |
249 | { | ||
250 | QListViewItem * item = folderView->currentItem(); | ||
251 | if ( ! item ) return; | ||
252 | while ( item->parent () ) | ||
253 | item = item->parent (); | ||
254 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | ||
255 | } | ||
248 | void OpieMail::slotDeleteMail() | 256 | void OpieMail::slotDeleteMail() |
249 | { | 257 | { |
250 | if (!mailView->currentItem()) return; | 258 | if (!mailView->currentItem()) return; |
251 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 259 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
252 | 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 ) | 260 | 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 ) |
253 | { | 261 | { |
254 | mail->Wrapper()->deleteMail( mail ); | 262 | mail->Wrapper()->deleteMail( mail ); |
255 | folderView->refreshCurrent(); | 263 | folderView->refreshCurrent(); |
256 | } | 264 | } |
257 | } | 265 | } |
258 | void OpieMail::slotDeleteAllMail() | 266 | void OpieMail::slotDeleteAllMail() |
259 | { | 267 | { |
260 | 268 | ||
261 | QValueList<RecMailP> t; | 269 | QValueList<RecMailP> t; |
262 | if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 270 | if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
263 | { | 271 | { |
264 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 272 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
265 | while ( item ) { | 273 | while ( item ) { |
266 | if ( item->isSelected() ) { | 274 | if ( item->isSelected() ) { |
267 | t.append( item->data() ); | 275 | t.append( item->data() ); |
268 | } | 276 | } |
269 | item = (MailListViewItem*)item->nextSibling(); | 277 | item = (MailListViewItem*)item->nextSibling(); |
270 | } | 278 | } |
271 | } | 279 | } |
272 | else | 280 | else |
273 | return; | 281 | return; |
274 | if ( t.count() == 0 ) | 282 | if ( t.count() == 0 ) |
275 | return; | 283 | return; |
276 | RecMailP mail = t.first(); | 284 | RecMailP mail = t.first(); |
277 | mail->Wrapper()->deleteMailList(t); | 285 | mail->Wrapper()->deleteMailList(t); |
278 | folderView->refreshCurrent(); | 286 | folderView->refreshCurrent(); |
279 | 287 | ||
280 | 288 | ||
281 | } | 289 | } |
282 | void OpieMail::clearSelection() | 290 | void OpieMail::clearSelection() |
283 | { | 291 | { |
284 | mailView->clearSelection(); | 292 | mailView->clearSelection(); |
285 | 293 | ||
286 | } | 294 | } |
287 | 295 | ||
288 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | 296 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) |
289 | { | 297 | { |
290 | if (!mailView->currentItem()) return; | 298 | if (!mailView->currentItem()) return; |
291 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); | 299 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); |
292 | /* just the RIGHT button - or hold on pda */ | 300 | /* just the RIGHT button - or hold on pda */ |
293 | if (button!=2) {return;} | 301 | if (button!=2) {return;} |
294 | if (!item) return; | 302 | if (!item) return; |
295 | QPopupMenu *m = new QPopupMenu(0); | 303 | QPopupMenu *m = new QPopupMenu(0); |
296 | if (m) | 304 | if (m) |
297 | { | 305 | { |
298 | if (mailtype==MAILLIB::A_NNTP) { | 306 | if (mailtype==MAILLIB::A_NNTP) { |
299 | m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); | 307 | m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); |
300 | // m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); | 308 | // m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); |
301 | } else { | 309 | } else { |
302 | if (folderView->currentisDraft()) { | 310 | if (folderView->currentisDraft()) { |
303 | m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); | 311 | m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); |
304 | } | 312 | } |
305 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); | 313 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); |
306 | m->insertItem(tr("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); | 314 | m->insertItem(tr("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); |
307 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); | 315 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); |
308 | m->insertSeparator(); | 316 | m->insertSeparator(); |
309 | m->insertItem(tr("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); | 317 | m->insertItem(tr("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); |
310 | m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); | 318 | m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); |
311 | m->insertItem(tr("Clear selection"),this,SLOT(clearSelection())); | 319 | m->insertItem(tr("Clear selection"),this,SLOT(clearSelection())); |
312 | } | 320 | } |
313 | m->setFocus(); | 321 | m->setFocus(); |
314 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 322 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
315 | delete m; | 323 | delete m; |
316 | } | 324 | } |
317 | } | 325 | } |
318 | 326 | ||
319 | void OpieMail::slotShowFolders( bool show ) | 327 | void OpieMail::slotShowFolders( bool show ) |
320 | { | 328 | { |
321 | if ( show && folderView->isHidden() ) | 329 | if ( show && folderView->isHidden() ) |
322 | { | 330 | { |
323 | folderView->show(); | 331 | folderView->show(); |
324 | } | 332 | } |
325 | else if ( !show && !folderView->isHidden() ) | 333 | else if ( !show && !folderView->isHidden() ) |
326 | { | 334 | { |
327 | folderView->hide(); | 335 | folderView->hide(); |
328 | } | 336 | } |
329 | } | 337 | } |
330 | 338 | ||
331 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) | 339 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) |
332 | { | 340 | { |
333 | MailListViewItem*item = 0; | 341 | MailListViewItem*item = 0; |
334 | mailView->clear(); | 342 | mailView->clear(); |
335 | 343 | ||
336 | QValueList<RecMailP>::ConstIterator it; | 344 | QValueList<RecMailP>::ConstIterator it; |
337 | for (it = list.begin(); it != list.end();++it) | 345 | for (it = list.begin(); it != list.end();++it) |
338 | { | 346 | { |
339 | item = new MailListViewItem(mailView,item); | 347 | item = new MailListViewItem(mailView,item); |
340 | item->storeData((*it)); | 348 | item->storeData((*it)); |
341 | item->showEntry(); | 349 | item->showEntry(); |
342 | } | 350 | } |
343 | } | 351 | } |
344 | 352 | ||
345 | void OpieMail::mailLeftClicked( QListViewItem *item ) | 353 | void OpieMail::mailLeftClicked( QListViewItem *item ) |
346 | { | 354 | { |
347 | mailView->clearSelection(); | 355 | mailView->clearSelection(); |
348 | /* just LEFT button - or tap with stylus on pda */ | 356 | /* just LEFT button - or tap with stylus on pda */ |
349 | //if (button!=1) return; | 357 | //if (button!=1) return; |
350 | if (!item) return; | 358 | if (!item) return; |
351 | if (folderView->currentisDraft()) { | 359 | if (folderView->currentisDraft()) { |
352 | reEditMail(); | 360 | reEditMail(); |
353 | } else { | 361 | } else { |
354 | displayMail(); | 362 | displayMail(); |
355 | } | 363 | } |
356 | } | 364 | } |
357 | 365 | ||
358 | void OpieMail::slotMoveCopyMail() | 366 | void OpieMail::slotMoveCopyMail() |
359 | { | 367 | { |
360 | if (!mailView->currentItem()) return; | 368 | if (!mailView->currentItem()) return; |
361 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 369 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
362 | AbstractMail*targetMail = 0; | 370 | AbstractMail*targetMail = 0; |
363 | QString targetFolder = ""; | 371 | QString targetFolder = ""; |
364 | Selectstore sels; | 372 | Selectstore sels; |
365 | folderView->setupFolderselect(&sels); | 373 | folderView->setupFolderselect(&sels); |
366 | if (!sels.exec()) return; | 374 | if (!sels.exec()) return; |
367 | targetMail = sels.currentMail(); | 375 | targetMail = sels.currentMail(); |
368 | targetFolder = sels.currentFolder(); | 376 | targetFolder = sels.currentFolder(); |
369 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || | 377 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || |
370 | targetFolder.isEmpty()) | 378 | targetFolder.isEmpty()) |
371 | { | 379 | { |
372 | return; | 380 | return; |
373 | } | 381 | } |
374 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 382 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
375 | { | 383 | { |
376 | QMessageBox::critical(0,tr("Error creating new Folder"), | 384 | QMessageBox::critical(0,tr("Error creating new Folder"), |
377 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 385 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
378 | return; | 386 | return; |
379 | } | 387 | } |
380 | sels.hide(); | 388 | sels.hide(); |
381 | qApp->processEvents(); | 389 | qApp->processEvents(); |
382 | // qDebug("hiding sels "); | 390 | // qDebug("hiding sels "); |
383 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); | 391 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); |
384 | folderView->refreshCurrent(); | 392 | folderView->refreshCurrent(); |
385 | } | 393 | } |
386 | 394 | ||
387 | void OpieMail::slotMoveCopyAllMail() | 395 | void OpieMail::slotMoveCopyAllMail() |
388 | { | 396 | { |
389 | 397 | ||
390 | if (!mailView->currentItem()) return; | 398 | if (!mailView->currentItem()) return; |
391 | QValueList<RecMailP> t; | 399 | QValueList<RecMailP> t; |
392 | // if ( QMessageBox::warning(this, tr("Move/Copy all selected mails"), tr("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 400 | // if ( QMessageBox::warning(this, tr("Move/Copy all selected mails"), tr("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
393 | { | 401 | { |
394 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 402 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
395 | while ( item ) { | 403 | while ( item ) { |
396 | if ( item->isSelected() ) { | 404 | if ( item->isSelected() ) { |
397 | t.append( item->data() ); | 405 | t.append( item->data() ); |
398 | } | 406 | } |
399 | item = (MailListViewItem*)item->nextSibling(); | 407 | item = (MailListViewItem*)item->nextSibling(); |
400 | } | 408 | } |
401 | } | 409 | } |
402 | // else | 410 | // else |
403 | // return; | 411 | // return; |
404 | if ( t.count() == 0 ) | 412 | if ( t.count() == 0 ) |
405 | return; | 413 | return; |
406 | RecMailP mail = t.first(); | 414 | RecMailP mail = t.first(); |
407 | AbstractMail*targetMail = 0; | 415 | AbstractMail*targetMail = 0; |
408 | QString targetFolder = ""; | 416 | QString targetFolder = ""; |
409 | Selectstore sels; | 417 | Selectstore sels; |
410 | folderView->setupFolderselect(&sels); | 418 | folderView->setupFolderselect(&sels); |
411 | if (!sels.exec()) return; | 419 | if (!sels.exec()) return; |
412 | targetMail = sels.currentMail(); | 420 | targetMail = sels.currentMail(); |
413 | targetFolder = sels.currentFolder(); | 421 | targetFolder = sels.currentFolder(); |
414 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || | 422 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || |
415 | targetFolder.isEmpty()) | 423 | targetFolder.isEmpty()) |
416 | { | 424 | { |
417 | return; | 425 | return; |
418 | } | 426 | } |
419 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 427 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
420 | { | 428 | { |
421 | QMessageBox::critical(0,tr("Error creating new Folder"), | 429 | QMessageBox::critical(0,tr("Error creating new Folder"), |
422 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 430 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
423 | return; | 431 | return; |
424 | } | 432 | } |
425 | sels.hide(); | 433 | sels.hide(); |
426 | qApp->processEvents(); | 434 | qApp->processEvents(); |
427 | //qDebug("hiding sels "); | 435 | //qDebug("hiding sels "); |
428 | mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); | 436 | mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); |
429 | folderView->refreshCurrent(); | 437 | folderView->refreshCurrent(); |
430 | } | 438 | } |
431 | 439 | ||
432 | void OpieMail::reEditMail() | 440 | void OpieMail::reEditMail() |
433 | { | 441 | { |
434 | if (!mailView->currentItem()) return; | 442 | if (!mailView->currentItem()) return; |
435 | 443 | ||
436 | ComposeMail compose( settings, this, 0, true ); | 444 | ComposeMail compose( settings, this, 0, true ); |
437 | compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); | 445 | compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); |
438 | compose.slotAdjustColumns(); | 446 | compose.slotAdjustColumns(); |
439 | compose.showMaximized(); | 447 | compose.showMaximized(); |
440 | compose.exec(); | 448 | compose.exec(); |
441 | } | 449 | } |
diff --git a/kmicromail/opiemail.h b/kmicromail/opiemail.h index 1de5f6b..e054b9e 100644 --- a/kmicromail/opiemail.h +++ b/kmicromail/opiemail.h | |||
@@ -1,50 +1,51 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef OPIEMAIL_H | 2 | #ifndef OPIEMAIL_H |
3 | #define OPIEMAIL_H | 3 | #define OPIEMAIL_H |
4 | 4 | ||
5 | #include "mainwindow.h" | 5 | #include "mainwindow.h" |
6 | #include <libmailwrapper/settings.h> | 6 | #include <libmailwrapper/settings.h> |
7 | 7 | ||
8 | #include <opie2/osmartpointer.h> | 8 | #include <opie2/osmartpointer.h> |
9 | #include <libmailwrapper/mailtypes.h> | 9 | #include <libmailwrapper/mailtypes.h> |
10 | 10 | ||
11 | class OpieMail : public MainWindow | 11 | class OpieMail : public MainWindow |
12 | { | 12 | { |
13 | Q_OBJECT | 13 | Q_OBJECT |
14 | 14 | ||
15 | public: | 15 | public: |
16 | OpieMail( QWidget *parent = 0, const char *name = 0 ); | 16 | OpieMail( QWidget *parent = 0, const char *name = 0 ); |
17 | virtual ~OpieMail(); | 17 | virtual ~OpieMail(); |
18 | static QString appName() { return QString::fromLatin1("kopiemail"); } | 18 | static QString appName() { return QString::fromLatin1("kopiemail"); } |
19 | 19 | ||
20 | public slots: | 20 | public slots: |
21 | virtual void slotwriteMail(const QString&name,const QString&email); | 21 | virtual void slotwriteMail(const QString&name,const QString&email); |
22 | virtual void slotwriteMail2(const QString&nameemail); | 22 | virtual void slotwriteMail2(const QString&nameemail); |
23 | virtual void slotComposeMail(); | 23 | virtual void slotComposeMail(); |
24 | virtual void appMessage(const QCString &msg, const QByteArray &data); | 24 | virtual void appMessage(const QCString &msg, const QByteArray &data); |
25 | virtual void message(const QCString &msg, const QByteArray &data); | 25 | virtual void message(const QCString &msg, const QByteArray &data); |
26 | protected slots: | 26 | protected slots: |
27 | virtual void slotSendQueued(); | 27 | virtual void slotSendQueued(); |
28 | virtual void slotSearchMails(); | 28 | virtual void slotSearchMails(); |
29 | virtual void slotEditSettings(); | 29 | virtual void slotEditSettings(); |
30 | virtual void slotEditAccounts(); | 30 | virtual void slotEditAccounts(); |
31 | virtual void displayMail(); | 31 | virtual void displayMail(); |
32 | virtual void slotDeleteMail(); | 32 | virtual void slotDeleteMail(); |
33 | virtual void slotGetMail(); | ||
33 | virtual void slotDeleteAllMail(); | 34 | virtual void slotDeleteAllMail(); |
34 | virtual void mailHold(int, QListViewItem *,const QPoint&,int); | 35 | virtual void mailHold(int, QListViewItem *,const QPoint&,int); |
35 | virtual void slotShowFolders( bool show ); | 36 | virtual void slotShowFolders( bool show ); |
36 | virtual void refreshMailView(const QValueList<RecMailP>&); | 37 | virtual void refreshMailView(const QValueList<RecMailP>&); |
37 | virtual void mailLeftClicked( QListViewItem * ); | 38 | virtual void mailLeftClicked( QListViewItem * ); |
38 | virtual void slotMoveCopyMail(); | 39 | virtual void slotMoveCopyMail(); |
39 | virtual void slotMoveCopyAllMail(); | 40 | virtual void slotMoveCopyAllMail(); |
40 | virtual void reEditMail(); | 41 | virtual void reEditMail(); |
41 | void clearSelection(); | 42 | void clearSelection(); |
42 | 43 | ||
43 | private: | 44 | private: |
44 | QString mPendingEmail; | 45 | QString mPendingEmail; |
45 | QString mPendingName; | 46 | QString mPendingName; |
46 | Settings *settings; | 47 | Settings *settings; |
47 | 48 | ||
48 | }; | 49 | }; |
49 | 50 | ||
50 | #endif | 51 | #endif |