author | alwin <alwin> | 2004-01-08 02:52:13 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-01-08 02:52:13 (UTC) |
commit | 05d47b2603adfab0e16f7395e34b7aa56ce6d8de (patch) (unidiff) | |
tree | 4253654acb70b859fd0d32981132dffd35092b9f | |
parent | dfa1477a28ecd90e08cf09aeecbe816e94bec0b5 (diff) | |
download | opie-05d47b2603adfab0e16f7395e34b7aa56ce6d8de.zip opie-05d47b2603adfab0e16f7395e34b7aa56ce6d8de.tar.gz opie-05d47b2603adfab0e16f7395e34b7aa56ce6d8de.tar.bz2 |
move/copy mails to another folder resides inside wrappers so we can
use special funs of libetpan and/or mailserver itself (eg. imap)
libetpan 0.32 requires for that feature a patch! (see libetpanstuff/)
accounts marked as "offline" get a new icon
TODO:
- when creating a new folder while copy/move on imap-server, get the
real resulting foldername when using prefix
- implement usage of copy/move inside one mbox using special etpan funs
-rw-r--r-- | noncore/net/mail/accountview.cpp | 40 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/defines.h | 3 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.cpp | 19 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 31 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 1 |
7 files changed, 83 insertions, 14 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index eea021f..b7de7b9 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -1,467 +1,483 @@ | |||
1 | #include "accountview.h" | 1 | #include "accountview.h" |
2 | #include <libmailwrapper/mailtypes.h> | 2 | #include <libmailwrapper/mailtypes.h> |
3 | #include <libmailwrapper/abstractmail.h> | 3 | #include <libmailwrapper/abstractmail.h> |
4 | #include "defines.h" | 4 | #include "defines.h" |
5 | #include "newmaildir.h" | 5 | #include "newmaildir.h" |
6 | #include "selectstore.h" | 6 | #include "selectstore.h" |
7 | #include <qmessagebox.h> | 7 | #include <qmessagebox.h> |
8 | #include <qpopupmenu.h> | 8 | #include <qpopupmenu.h> |
9 | 9 | ||
10 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} | ||
10 | /** | 11 | /** |
11 | * POP3 Account stuff | 12 | * POP3 Account stuff |
12 | */ | 13 | */ |
13 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) | 14 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) |
14 | : AccountViewItem( parent ) | 15 | : AccountViewItem( parent ) |
15 | { | 16 | { |
16 | account = a; | 17 | account = a; |
17 | wrapper = AbstractMail::getWrapper( account ); | 18 | wrapper = AbstractMail::getWrapper( account ); |
18 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 19 | SETPIX(PIXMAP_POP3FOLDER); |
20 | #if 0 | ||
21 | if (!account->getOffline()) { | ||
22 | setPixmap( 0, ); | ||
23 | } else { | ||
24 | setPixmap( 0, PIXMAP_OFFLINE ); | ||
25 | } | ||
26 | #endif | ||
19 | setText( 0, account->getAccountName() ); | 27 | setText( 0, account->getAccountName() ); |
20 | setOpen( true ); | 28 | setOpen( true ); |
21 | } | 29 | } |
22 | 30 | ||
23 | POP3viewItem::~POP3viewItem() | 31 | POP3viewItem::~POP3viewItem() |
24 | { | 32 | { |
25 | delete wrapper; | 33 | delete wrapper; |
26 | } | 34 | } |
27 | 35 | ||
28 | AbstractMail *POP3viewItem::getWrapper() | 36 | AbstractMail *POP3viewItem::getWrapper() |
29 | { | 37 | { |
30 | return wrapper; | 38 | return wrapper; |
31 | } | 39 | } |
32 | 40 | ||
33 | void POP3viewItem::refresh( QList<RecMail> & ) | 41 | void POP3viewItem::refresh( QList<RecMail> & ) |
34 | { | 42 | { |
43 | refresh(); | ||
44 | } | ||
45 | |||
46 | void POP3viewItem::refresh() | ||
47 | { | ||
35 | if (account->getOffline()) return; | 48 | if (account->getOffline()) return; |
36 | QList<Folder> *folders = wrapper->listFolders(); | 49 | QList<Folder> *folders = wrapper->listFolders(); |
37 | QListViewItem *child = firstChild(); | 50 | QListViewItem *child = firstChild(); |
38 | while ( child ) { | 51 | while ( child ) { |
39 | QListViewItem *tmp = child; | 52 | QListViewItem *tmp = child; |
40 | child = child->nextSibling(); | 53 | child = child->nextSibling(); |
41 | delete tmp; | 54 | delete tmp; |
42 | } | 55 | } |
43 | Folder *it; | 56 | Folder *it; |
44 | QListViewItem*item = 0; | 57 | QListViewItem*item = 0; |
45 | for ( it = folders->first(); it; it = folders->next() ) { | 58 | for ( it = folders->first(); it; it = folders->next() ) { |
46 | item = new POP3folderItem( it, this , item ); | 59 | item = new POP3folderItem( it, this , item ); |
47 | item->setSelectable(it->may_select()); | 60 | item->setSelectable(it->may_select()); |
48 | } | 61 | } |
49 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 62 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
50 | folders->setAutoDelete(false); | 63 | folders->setAutoDelete(false); |
51 | delete folders; | 64 | delete folders; |
52 | } | 65 | } |
53 | 66 | ||
54 | RecBody POP3viewItem::fetchBody( const RecMail &mail ) | 67 | RecBody POP3viewItem::fetchBody( const RecMail &mail ) |
55 | { | 68 | { |
56 | qDebug( "POP3 fetchBody" ); | 69 | qDebug( "POP3 fetchBody" ); |
57 | return wrapper->fetchBody( mail ); | 70 | return wrapper->fetchBody( mail ); |
58 | } | 71 | } |
59 | 72 | ||
60 | QPopupMenu * POP3viewItem::getContextMenu() | 73 | QPopupMenu * POP3viewItem::getContextMenu() |
61 | { | 74 | { |
62 | QPopupMenu *m = new QPopupMenu(0); | 75 | QPopupMenu *m = new QPopupMenu(0); |
63 | if (m) { | 76 | if (m) { |
64 | if (!account->getOffline()) { | 77 | if (!account->getOffline()) { |
65 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 78 | m->insertItem(QObject::tr("Disconnect",contextName),0); |
66 | m->insertItem(QObject::tr("Set offline",contextName),1); | 79 | m->insertItem(QObject::tr("Set offline",contextName),1); |
67 | } else { | 80 | } else { |
68 | m->insertItem(QObject::tr("Set online",contextName),1); | 81 | m->insertItem(QObject::tr("Set online",contextName),1); |
69 | } | 82 | } |
70 | } | 83 | } |
71 | return m; | 84 | return m; |
72 | } | 85 | } |
73 | 86 | ||
74 | void POP3viewItem::disconnect() | 87 | void POP3viewItem::disconnect() |
75 | { | 88 | { |
76 | QListViewItem *child = firstChild(); | 89 | QListViewItem *child = firstChild(); |
77 | while ( child ) { | 90 | while ( child ) { |
78 | QListViewItem *tmp = child; | 91 | QListViewItem *tmp = child; |
79 | child = child->nextSibling(); | 92 | child = child->nextSibling(); |
80 | delete tmp; | 93 | delete tmp; |
81 | } | 94 | } |
82 | wrapper->logout(); | 95 | wrapper->logout(); |
83 | } | 96 | } |
84 | 97 | ||
85 | void POP3viewItem::setOnOffline() | 98 | void POP3viewItem::setOnOffline() |
86 | { | 99 | { |
87 | if (!account->getOffline()) { | 100 | if (!account->getOffline()) { |
88 | disconnect(); | 101 | disconnect(); |
89 | } | 102 | } |
90 | account->setOffline(!account->getOffline()); | 103 | account->setOffline(!account->getOffline()); |
91 | account->save(); | 104 | account->save(); |
105 | SETPIX(PIXMAP_POP3FOLDER); | ||
106 | refresh(); | ||
92 | } | 107 | } |
93 | 108 | ||
94 | void POP3viewItem::contextMenuSelected(int which) | 109 | void POP3viewItem::contextMenuSelected(int which) |
95 | { | 110 | { |
96 | switch (which) { | 111 | switch (which) { |
97 | case 0: | 112 | case 0: |
98 | disconnect(); | 113 | disconnect(); |
99 | break; | 114 | break; |
100 | case 1: | 115 | case 1: |
101 | setOnOffline(); | 116 | setOnOffline(); |
102 | break; | 117 | break; |
103 | } | 118 | } |
104 | } | 119 | } |
105 | 120 | ||
106 | POP3folderItem::~POP3folderItem() | 121 | POP3folderItem::~POP3folderItem() |
107 | { | 122 | { |
108 | delete folder; | 123 | delete folder; |
109 | } | 124 | } |
110 | 125 | ||
111 | POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) | 126 | POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) |
112 | : AccountViewItem( parent,after ) | 127 | : AccountViewItem( parent,after ) |
113 | { | 128 | { |
114 | folder = folderInit; | 129 | folder = folderInit; |
115 | pop3 = parent; | 130 | pop3 = parent; |
116 | if (folder->getDisplayName().lower()!="inbox") { | 131 | if (folder->getDisplayName().lower()!="inbox") { |
117 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 132 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
118 | } else { | 133 | } else { |
119 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 134 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
120 | } | 135 | } |
121 | setText( 0, folder->getDisplayName() ); | 136 | setText( 0, folder->getDisplayName() ); |
122 | } | 137 | } |
123 | 138 | ||
124 | void POP3folderItem::refresh(QList<RecMail>&target) | 139 | void POP3folderItem::refresh(QList<RecMail>&target) |
125 | { | 140 | { |
126 | if (folder->may_select()) | 141 | if (folder->may_select()) |
127 | pop3->getWrapper()->listMessages( folder->getName(),target ); | 142 | pop3->getWrapper()->listMessages( folder->getName(),target ); |
128 | } | 143 | } |
129 | 144 | ||
130 | RecBody POP3folderItem::fetchBody(const RecMail&aMail) | 145 | RecBody POP3folderItem::fetchBody(const RecMail&aMail) |
131 | { | 146 | { |
132 | return pop3->getWrapper()->fetchBody(aMail); | 147 | return pop3->getWrapper()->fetchBody(aMail); |
133 | } | 148 | } |
134 | 149 | ||
135 | QPopupMenu * POP3folderItem::getContextMenu() | 150 | QPopupMenu * POP3folderItem::getContextMenu() |
136 | { | 151 | { |
137 | QPopupMenu *m = new QPopupMenu(0); | 152 | QPopupMenu *m = new QPopupMenu(0); |
138 | if (m) { | 153 | if (m) { |
139 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 154 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
140 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 155 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
141 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | 156 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); |
142 | } | 157 | } |
143 | return m; | 158 | return m; |
144 | } | 159 | } |
145 | 160 | ||
146 | void POP3folderItem::downloadMails() | 161 | void POP3folderItem::downloadMails() |
147 | { | 162 | { |
148 | AccountView*bl = pop3->accountView(); | 163 | AccountView*bl = pop3->accountView(); |
149 | if (!bl) return; | 164 | if (!bl) return; |
150 | bl->downloadMails(folder,pop3->getWrapper()); | 165 | bl->downloadMails(folder,pop3->getWrapper()); |
151 | } | 166 | } |
152 | 167 | ||
153 | void POP3folderItem::contextMenuSelected(int which) | 168 | void POP3folderItem::contextMenuSelected(int which) |
154 | { | 169 | { |
155 | AccountView * view = (AccountView*)listView(); | 170 | AccountView * view = (AccountView*)listView(); |
156 | switch (which) { | 171 | switch (which) { |
157 | case 0: | 172 | case 0: |
158 | /* must be 'cause pop3 lists are cached */ | 173 | /* must be 'cause pop3 lists are cached */ |
159 | pop3->getWrapper()->logout(); | 174 | pop3->getWrapper()->logout(); |
160 | view->refreshCurrent(); | 175 | view->refreshCurrent(); |
161 | break; | 176 | break; |
162 | case 1: | 177 | case 1: |
163 | deleteAllMail(pop3->getWrapper(),folder); | 178 | deleteAllMail(pop3->getWrapper(),folder); |
164 | break; | 179 | break; |
165 | case 2: | 180 | case 2: |
166 | downloadMails(); | 181 | downloadMails(); |
167 | break; | 182 | break; |
168 | default: | 183 | default: |
169 | break; | 184 | break; |
170 | } | 185 | } |
171 | } | 186 | } |
172 | 187 | ||
173 | /** | 188 | /** |
174 | * IMAP Account stuff | 189 | * IMAP Account stuff |
175 | */ | 190 | */ |
176 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) | 191 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) |
177 | : AccountViewItem( parent ) | 192 | : AccountViewItem( parent ) |
178 | { | 193 | { |
179 | account = a; | 194 | account = a; |
180 | wrapper = AbstractMail::getWrapper( account ); | 195 | wrapper = AbstractMail::getWrapper( account ); |
181 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 196 | SETPIX(PIXMAP_IMAPFOLDER); |
182 | setText( 0, account->getAccountName() ); | 197 | setText( 0, account->getAccountName() ); |
183 | setOpen( true ); | 198 | setOpen( true ); |
184 | } | 199 | } |
185 | 200 | ||
186 | IMAPviewItem::~IMAPviewItem() | 201 | IMAPviewItem::~IMAPviewItem() |
187 | { | 202 | { |
188 | delete wrapper; | 203 | delete wrapper; |
189 | } | 204 | } |
190 | 205 | ||
191 | AbstractMail *IMAPviewItem::getWrapper() | 206 | AbstractMail *IMAPviewItem::getWrapper() |
192 | { | 207 | { |
193 | return wrapper; | 208 | return wrapper; |
194 | } | 209 | } |
195 | 210 | ||
196 | IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start) | 211 | IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start) |
197 | { | 212 | { |
198 | IMAPfolderItem*pitem,*sitem; | 213 | IMAPfolderItem*pitem,*sitem; |
199 | if (!start) pitem = (IMAPfolderItem*)firstChild(); | 214 | if (!start) pitem = (IMAPfolderItem*)firstChild(); |
200 | else pitem = (IMAPfolderItem*)start->firstChild(); | 215 | else pitem = (IMAPfolderItem*)start->firstChild(); |
201 | while (pitem) { | 216 | while (pitem) { |
202 | if (pitem->matchName(path)) { | 217 | if (pitem->matchName(path)) { |
203 | break; | 218 | break; |
204 | } | 219 | } |
205 | if (pitem->childCount()>0) { | 220 | if (pitem->childCount()>0) { |
206 | sitem = findSubItem(path,pitem); | 221 | sitem = findSubItem(path,pitem); |
207 | if (sitem) { | 222 | if (sitem) { |
208 | pitem = sitem; | 223 | pitem = sitem; |
209 | break; | 224 | break; |
210 | } | 225 | } |
211 | } | 226 | } |
212 | pitem=(IMAPfolderItem*)pitem->nextSibling(); | 227 | pitem=(IMAPfolderItem*)pitem->nextSibling(); |
213 | } | 228 | } |
214 | return pitem; | 229 | return pitem; |
215 | } | 230 | } |
216 | 231 | ||
217 | void IMAPviewItem::refresh(QList<RecMail>&) | 232 | void IMAPviewItem::refresh(QList<RecMail>&) |
218 | { | 233 | { |
219 | refreshFolders(false); | 234 | refreshFolders(false); |
220 | } | 235 | } |
221 | 236 | ||
222 | void IMAPviewItem::removeChilds() | 237 | void IMAPviewItem::removeChilds() |
223 | { | 238 | { |
224 | QListViewItem *child = firstChild(); | 239 | QListViewItem *child = firstChild(); |
225 | while ( child ) { | 240 | while ( child ) { |
226 | QListViewItem *tmp = child; | 241 | QListViewItem *tmp = child; |
227 | child = child->nextSibling(); | 242 | child = child->nextSibling(); |
228 | delete tmp; | 243 | delete tmp; |
229 | } | 244 | } |
230 | 245 | ||
231 | } | 246 | } |
232 | 247 | ||
233 | const QStringList&IMAPviewItem::subFolders() | 248 | const QStringList&IMAPviewItem::subFolders() |
234 | { | 249 | { |
235 | return currentFolders; | 250 | return currentFolders; |
236 | } | 251 | } |
237 | 252 | ||
238 | void IMAPviewItem::refreshFolders(bool force) | 253 | void IMAPviewItem::refreshFolders(bool force) |
239 | { | 254 | { |
240 | if (childCount()>0 && force==false) return; | 255 | if (childCount()>0 && force==false) return; |
241 | if (account->getOffline()) return; | 256 | if (account->getOffline()) return; |
242 | 257 | ||
243 | removeChilds(); | 258 | removeChilds(); |
244 | currentFolders.clear(); | 259 | currentFolders.clear(); |
245 | QList<Folder> *folders = wrapper->listFolders(); | 260 | QList<Folder> *folders = wrapper->listFolders(); |
246 | 261 | ||
247 | Folder *it; | 262 | Folder *it; |
248 | QListViewItem*item = 0; | 263 | QListViewItem*item = 0; |
249 | QListViewItem*titem = 0; | 264 | QListViewItem*titem = 0; |
250 | QString fname,del,search; | 265 | QString fname,del,search; |
251 | int pos; | 266 | int pos; |
252 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 267 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
253 | folders->setAutoDelete(false); | 268 | folders->setAutoDelete(false); |
254 | 269 | ||
255 | for ( it = folders->first(); it; it = folders->next() ) { | 270 | for ( it = folders->first(); it; it = folders->next() ) { |
256 | if (it->getDisplayName().lower()=="inbox") { | 271 | if (it->getDisplayName().lower()=="inbox") { |
257 | item = new IMAPfolderItem( it, this , item ); | 272 | item = new IMAPfolderItem( it, this , item ); |
258 | folders->remove(it); | 273 | folders->remove(it); |
259 | qDebug("inbox found"); | 274 | qDebug("inbox found"); |
260 | break; | 275 | break; |
261 | } | 276 | } |
262 | } | 277 | } |
263 | for ( it = folders->first(); it; it = folders->next() ) { | 278 | for ( it = folders->first(); it; it = folders->next() ) { |
264 | fname = it->getDisplayName(); | 279 | fname = it->getDisplayName(); |
265 | currentFolders.append(it->getName()); | 280 | currentFolders.append(it->getName()); |
266 | pos = fname.findRev(it->Separator()); | 281 | pos = fname.findRev(it->Separator()); |
267 | if (pos != -1) { | 282 | if (pos != -1) { |
268 | fname = fname.left(pos); | 283 | fname = fname.left(pos); |
269 | } | 284 | } |
270 | IMAPfolderItem*pitem = findSubItem(fname); | 285 | IMAPfolderItem*pitem = findSubItem(fname); |
271 | if (pitem) { | 286 | if (pitem) { |
272 | titem = item; | 287 | titem = item; |
273 | item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this); | 288 | item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this); |
274 | /* setup the short name */ | 289 | /* setup the short name */ |
275 | item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); | 290 | item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); |
276 | item = titem; | 291 | item = titem; |
277 | } else { | 292 | } else { |
278 | item = new IMAPfolderItem( it, this , item ); | 293 | item = new IMAPfolderItem( it, this , item ); |
279 | } | 294 | } |
280 | } | 295 | } |
281 | delete folders; | 296 | delete folders; |
282 | } | 297 | } |
283 | 298 | ||
284 | QPopupMenu * IMAPviewItem::getContextMenu() | 299 | QPopupMenu * IMAPviewItem::getContextMenu() |
285 | { | 300 | { |
286 | QPopupMenu *m = new QPopupMenu(0); | 301 | QPopupMenu *m = new QPopupMenu(0); |
287 | if (m) { | 302 | if (m) { |
288 | if (!account->getOffline()) { | 303 | if (!account->getOffline()) { |
289 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 304 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); |
290 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 305 | m->insertItem(QObject::tr("Create new folder",contextName),1); |
291 | m->insertSeparator(); | 306 | m->insertSeparator(); |
292 | m->insertItem(QObject::tr("Disconnect",contextName),2); | 307 | m->insertItem(QObject::tr("Disconnect",contextName),2); |
293 | m->insertItem(QObject::tr("Set offline",contextName),3); | 308 | m->insertItem(QObject::tr("Set offline",contextName),3); |
294 | } else { | 309 | } else { |
295 | m->insertItem(QObject::tr("Set online",contextName),3); | 310 | m->insertItem(QObject::tr("Set online",contextName),3); |
296 | } | 311 | } |
297 | } | 312 | } |
298 | return m; | 313 | return m; |
299 | } | 314 | } |
300 | 315 | ||
301 | void IMAPviewItem::createNewFolder() | 316 | void IMAPviewItem::createNewFolder() |
302 | { | 317 | { |
303 | Newmdirdlg ndirdlg; | 318 | Newmdirdlg ndirdlg; |
304 | ndirdlg.showMaximized(); | 319 | ndirdlg.showMaximized(); |
305 | if (ndirdlg.exec()) { | 320 | if (ndirdlg.exec()) { |
306 | QString ndir = ndirdlg.Newdir(); | 321 | QString ndir = ndirdlg.Newdir(); |
307 | bool makesubs = ndirdlg.subpossible(); | 322 | bool makesubs = ndirdlg.subpossible(); |
308 | QString delemiter = "/"; | 323 | QString delemiter = "/"; |
309 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); | 324 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); |
310 | if (item) { | 325 | if (item) { |
311 | delemiter = item->Delemiter(); | 326 | delemiter = item->Delemiter(); |
312 | } | 327 | } |
313 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) { | 328 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) { |
314 | refreshFolders(true); | 329 | refreshFolders(true); |
315 | } | 330 | } |
316 | } | 331 | } |
317 | } | 332 | } |
318 | 333 | ||
319 | void IMAPviewItem::contextMenuSelected(int id) | 334 | void IMAPviewItem::contextMenuSelected(int id) |
320 | { | 335 | { |
321 | qDebug("Id selected: %i",id); | 336 | qDebug("Id selected: %i",id); |
322 | switch (id) { | 337 | switch (id) { |
323 | case 0: | 338 | case 0: |
324 | refreshFolders(true); | 339 | refreshFolders(true); |
325 | break; | 340 | break; |
326 | case 1: | 341 | case 1: |
327 | createNewFolder(); | 342 | createNewFolder(); |
328 | break; | 343 | break; |
329 | case 2: | 344 | case 2: |
330 | removeChilds(); | 345 | removeChilds(); |
331 | wrapper->logout(); | 346 | wrapper->logout(); |
332 | break; | 347 | break; |
333 | case 3: | 348 | case 3: |
334 | if (account->getOffline()==false) { | 349 | if (account->getOffline()==false) { |
335 | removeChilds(); | 350 | removeChilds(); |
336 | wrapper->logout(); | 351 | wrapper->logout(); |
337 | } | 352 | } |
338 | account->setOffline(!account->getOffline()); | 353 | account->setOffline(!account->getOffline()); |
339 | account->save(); | 354 | account->save(); |
355 | SETPIX(PIXMAP_IMAPFOLDER); | ||
340 | refreshFolders(false); | 356 | refreshFolders(false); |
341 | break; | 357 | break; |
342 | default: | 358 | default: |
343 | break; | 359 | break; |
344 | } | 360 | } |
345 | } | 361 | } |
346 | 362 | ||
347 | RecBody IMAPviewItem::fetchBody(const RecMail&) | 363 | RecBody IMAPviewItem::fetchBody(const RecMail&) |
348 | { | 364 | { |
349 | return RecBody(); | 365 | return RecBody(); |
350 | } | 366 | } |
351 | 367 | ||
352 | bool IMAPviewItem::offline() | 368 | bool IMAPviewItem::offline() |
353 | { | 369 | { |
354 | return account->getOffline(); | 370 | return account->getOffline(); |
355 | } | 371 | } |
356 | 372 | ||
357 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) | 373 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) |
358 | : AccountViewItem( parent , after ) | 374 | : AccountViewItem( parent , after ) |
359 | { | 375 | { |
360 | folder = folderInit; | 376 | folder = folderInit; |
361 | imap = parent; | 377 | imap = parent; |
362 | if (folder->getDisplayName().lower()!="inbox") { | 378 | if (folder->getDisplayName().lower()!="inbox") { |
363 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 379 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
364 | } else { | 380 | } else { |
365 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 381 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
366 | } | 382 | } |
367 | setText( 0, folder->getDisplayName() ); | 383 | setText( 0, folder->getDisplayName() ); |
368 | } | 384 | } |
369 | 385 | ||
370 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) | 386 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) |
371 | : AccountViewItem( parent,after ) | 387 | : AccountViewItem( parent,after ) |
372 | { | 388 | { |
373 | folder = folderInit; | 389 | folder = folderInit; |
374 | imap = master; | 390 | imap = master; |
375 | if (folder->getDisplayName().lower()!="inbox") { | 391 | if (folder->getDisplayName().lower()!="inbox") { |
376 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 392 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
377 | } else { | 393 | } else { |
378 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 394 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
379 | } | 395 | } |
380 | setText( 0, folder->getDisplayName() ); | 396 | setText( 0, folder->getDisplayName() ); |
381 | } | 397 | } |
382 | 398 | ||
383 | IMAPfolderItem::~IMAPfolderItem() | 399 | IMAPfolderItem::~IMAPfolderItem() |
384 | { | 400 | { |
385 | delete folder; | 401 | delete folder; |
386 | } | 402 | } |
387 | 403 | ||
388 | const QString& IMAPfolderItem::Delemiter()const | 404 | const QString& IMAPfolderItem::Delemiter()const |
389 | { | 405 | { |
390 | return folder->Separator(); | 406 | return folder->Separator(); |
391 | } | 407 | } |
392 | 408 | ||
393 | bool IMAPfolderItem::matchName(const QString&name)const | 409 | bool IMAPfolderItem::matchName(const QString&name)const |
394 | { | 410 | { |
395 | return folder->getDisplayName()==name; | 411 | return folder->getDisplayName()==name; |
396 | } | 412 | } |
397 | 413 | ||
398 | void IMAPfolderItem::refresh(QList<RecMail>&target) | 414 | void IMAPfolderItem::refresh(QList<RecMail>&target) |
399 | { | 415 | { |
400 | if (folder->may_select()) { | 416 | if (folder->may_select()) { |
401 | imap->getWrapper()->listMessages( folder->getName(),target ); | 417 | imap->getWrapper()->listMessages( folder->getName(),target ); |
402 | } else { | 418 | } else { |
403 | target.clear(); | 419 | target.clear(); |
404 | } | 420 | } |
405 | } | 421 | } |
406 | 422 | ||
407 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) | 423 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) |
408 | { | 424 | { |
409 | return imap->getWrapper()->fetchBody(aMail); | 425 | return imap->getWrapper()->fetchBody(aMail); |
410 | } | 426 | } |
411 | 427 | ||
412 | QPopupMenu * IMAPfolderItem::getContextMenu() | 428 | QPopupMenu * IMAPfolderItem::getContextMenu() |
413 | { | 429 | { |
414 | QPopupMenu *m = new QPopupMenu(0); | 430 | QPopupMenu *m = new QPopupMenu(0); |
415 | if (m) { | 431 | if (m) { |
416 | if (folder->may_select()) { | 432 | if (folder->may_select()) { |
417 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 433 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
418 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); | 434 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); |
419 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 435 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
420 | } | 436 | } |
421 | if (folder->no_inferior()==false) { | 437 | if (folder->no_inferior()==false) { |
422 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); | 438 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); |
423 | } | 439 | } |
424 | if (folder->getDisplayName().lower()!="inbox") { | 440 | if (folder->getDisplayName().lower()!="inbox") { |
425 | m->insertItem(QObject::tr("Delete folder",contextName),3); | 441 | m->insertItem(QObject::tr("Delete folder",contextName),3); |
426 | } | 442 | } |
427 | } | 443 | } |
428 | return m; | 444 | return m; |
429 | } | 445 | } |
430 | 446 | ||
431 | void IMAPfolderItem::createNewFolder() | 447 | void IMAPfolderItem::createNewFolder() |
432 | { | 448 | { |
433 | Newmdirdlg ndirdlg; | 449 | Newmdirdlg ndirdlg; |
434 | ndirdlg.showMaximized(); | 450 | ndirdlg.showMaximized(); |
435 | if (ndirdlg.exec()) { | 451 | if (ndirdlg.exec()) { |
436 | QString ndir = ndirdlg.Newdir(); | 452 | QString ndir = ndirdlg.Newdir(); |
437 | bool makesubs = ndirdlg.subpossible(); | 453 | bool makesubs = ndirdlg.subpossible(); |
438 | QString delemiter = Delemiter(); | 454 | QString delemiter = Delemiter(); |
439 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) { | 455 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) { |
440 | imap->refreshFolders(true); | 456 | imap->refreshFolders(true); |
441 | } | 457 | } |
442 | } | 458 | } |
443 | } | 459 | } |
444 | 460 | ||
445 | void IMAPfolderItem::deleteFolder() | 461 | void IMAPfolderItem::deleteFolder() |
446 | { | 462 | { |
447 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | 463 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), |
448 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | 464 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), |
449 | QObject::tr("Yes",contextName), | 465 | QObject::tr("Yes",contextName), |
450 | QObject::tr("No",contextName),QString::null,1,1); | 466 | QObject::tr("No",contextName),QString::null,1,1); |
451 | qDebug("Auswahl: %i",yesno); | 467 | qDebug("Auswahl: %i",yesno); |
452 | if (yesno == 0) { | 468 | if (yesno == 0) { |
453 | if (imap->getWrapper()->deleteMbox(folder)) { | 469 | if (imap->getWrapper()->deleteMbox(folder)) { |
454 | QListView*v=listView(); | 470 | QListView*v=listView(); |
455 | IMAPviewItem * box = imap; | 471 | IMAPviewItem * box = imap; |
456 | /* be carefull - after that this object is destroyd so don't use | 472 | /* be carefull - after that this object is destroyd so don't use |
457 | * any member of it after that call!!*/ | 473 | * any member of it after that call!!*/ |
458 | imap->refreshFolders(true); | 474 | imap->refreshFolders(true); |
459 | if (v) { | 475 | if (v) { |
460 | v->setSelected(box,true); | 476 | v->setSelected(box,true); |
461 | } | 477 | } |
462 | } | 478 | } |
463 | } | 479 | } |
464 | } | 480 | } |
465 | 481 | ||
466 | void IMAPfolderItem::downloadMails() | 482 | void IMAPfolderItem::downloadMails() |
467 | { | 483 | { |
@@ -540,280 +556,276 @@ void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder) | |||
540 | QObject::tr("No",contextName),QString::null,1,1); | 556 | QObject::tr("No",contextName),QString::null,1,1); |
541 | qDebug("Auswahl: %i",yesno); | 557 | qDebug("Auswahl: %i",yesno); |
542 | if (yesno == 0) { | 558 | if (yesno == 0) { |
543 | if (wrapper->deleteAllMail(folder)) { | 559 | if (wrapper->deleteAllMail(folder)) { |
544 | AccountView * view = (AccountView*)listView(); | 560 | AccountView * view = (AccountView*)listView(); |
545 | if (view) view->refreshCurrent(); | 561 | if (view) view->refreshCurrent(); |
546 | } | 562 | } |
547 | } | 563 | } |
548 | } | 564 | } |
549 | 565 | ||
550 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 566 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
551 | : QListView( parent, name, flags ) | 567 | : QListView( parent, name, flags ) |
552 | { | 568 | { |
553 | connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), | 569 | connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), |
554 | SLOT( refresh( QListViewItem * ) ) ); | 570 | SLOT( refresh( QListViewItem * ) ) ); |
555 | connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, | 571 | connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, |
556 | SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); | 572 | SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); |
557 | 573 | ||
558 | setSorting(0); | 574 | setSorting(0); |
559 | } | 575 | } |
560 | 576 | ||
561 | AccountView::~AccountView() | 577 | AccountView::~AccountView() |
562 | { | 578 | { |
563 | imapAccounts.clear(); | 579 | imapAccounts.clear(); |
564 | mboxAccounts.clear(); | 580 | mboxAccounts.clear(); |
565 | } | 581 | } |
566 | 582 | ||
567 | void AccountView::slotContextMenu(int id) | 583 | void AccountView::slotContextMenu(int id) |
568 | { | 584 | { |
569 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 585 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
570 | if (!view) return; | 586 | if (!view) return; |
571 | view->contextMenuSelected(id); | 587 | view->contextMenuSelected(id); |
572 | } | 588 | } |
573 | 589 | ||
574 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) | 590 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) |
575 | { | 591 | { |
576 | if (button==1) {return;} | 592 | if (button==1) {return;} |
577 | if (!item) return; | 593 | if (!item) return; |
578 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 594 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
579 | QPopupMenu*m = view->getContextMenu(); | 595 | QPopupMenu*m = view->getContextMenu(); |
580 | if (!m) return; | 596 | if (!m) return; |
581 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); | 597 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); |
582 | m->setFocus(); | 598 | m->setFocus(); |
583 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 599 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
584 | delete m; | 600 | delete m; |
585 | } | 601 | } |
586 | 602 | ||
587 | void AccountView::populate( QList<Account> list ) | 603 | void AccountView::populate( QList<Account> list ) |
588 | { | 604 | { |
589 | clear(); | 605 | clear(); |
590 | 606 | ||
591 | imapAccounts.clear(); | 607 | imapAccounts.clear(); |
592 | mboxAccounts.clear(); | 608 | mboxAccounts.clear(); |
593 | 609 | ||
594 | mboxAccounts.append(new MBOXviewItem(AbstractMail::defaultLocalfolder(),this)); | 610 | mboxAccounts.append(new MBOXviewItem(AbstractMail::defaultLocalfolder(),this)); |
595 | 611 | ||
596 | Account *it; | 612 | Account *it; |
597 | for ( it = list.first(); it; it = list.next() ) { | 613 | for ( it = list.first(); it; it = list.next() ) { |
598 | if ( it->getType().compare( "IMAP" ) == 0 ) { | 614 | if ( it->getType().compare( "IMAP" ) == 0 ) { |
599 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); | 615 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); |
600 | qDebug( "added IMAP " + imap->getAccountName() ); | 616 | qDebug( "added IMAP " + imap->getAccountName() ); |
601 | imapAccounts.append(new IMAPviewItem( imap, this )); | 617 | imapAccounts.append(new IMAPviewItem( imap, this )); |
602 | } else if ( it->getType().compare( "POP3" ) == 0 ) { | 618 | } else if ( it->getType().compare( "POP3" ) == 0 ) { |
603 | POP3account *pop3 = static_cast<POP3account *>(it); | 619 | POP3account *pop3 = static_cast<POP3account *>(it); |
604 | qDebug( "added POP3 " + pop3->getAccountName() ); | 620 | qDebug( "added POP3 " + pop3->getAccountName() ); |
605 | /* must not be hold 'cause it isn't required */ | 621 | /* must not be hold 'cause it isn't required */ |
606 | (void) new POP3viewItem( pop3, this ); | 622 | (void) new POP3viewItem( pop3, this ); |
607 | } | 623 | } |
608 | } | 624 | } |
609 | } | 625 | } |
610 | 626 | ||
611 | void AccountView::refresh(QListViewItem *item) { | 627 | void AccountView::refresh(QListViewItem *item) { |
612 | 628 | ||
613 | qDebug("AccountView refresh..."); | 629 | qDebug("AccountView refresh..."); |
614 | if ( item ) { | 630 | if ( item ) { |
615 | m_currentItem = item; | 631 | m_currentItem = item; |
616 | QList<RecMail> headerlist; | 632 | QList<RecMail> headerlist; |
617 | headerlist.setAutoDelete(true); | 633 | headerlist.setAutoDelete(true); |
618 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 634 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
619 | view->refresh(headerlist); | 635 | view->refresh(headerlist); |
620 | emit refreshMailview(&headerlist); | 636 | emit refreshMailview(&headerlist); |
621 | } | 637 | } |
622 | } | 638 | } |
623 | 639 | ||
624 | void AccountView::refreshCurrent() | 640 | void AccountView::refreshCurrent() |
625 | { | 641 | { |
626 | m_currentItem = currentItem(); | 642 | m_currentItem = currentItem(); |
627 | if ( !m_currentItem ) return; | 643 | if ( !m_currentItem ) return; |
628 | QList<RecMail> headerlist; | 644 | QList<RecMail> headerlist; |
629 | headerlist.setAutoDelete(true); | 645 | headerlist.setAutoDelete(true); |
630 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); | 646 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); |
631 | view->refresh(headerlist); | 647 | view->refresh(headerlist); |
632 | emit refreshMailview(&headerlist); | 648 | emit refreshMailview(&headerlist); |
633 | } | 649 | } |
634 | 650 | ||
635 | void AccountView::refreshAll() | 651 | void AccountView::refreshAll() |
636 | { | 652 | { |
637 | 653 | ||
638 | } | 654 | } |
639 | 655 | ||
640 | RecBody AccountView::fetchBody(const RecMail&aMail) | 656 | RecBody AccountView::fetchBody(const RecMail&aMail) |
641 | { | 657 | { |
642 | QListViewItem*item = selectedItem (); | 658 | QListViewItem*item = selectedItem (); |
643 | if (!item) return RecBody(); | 659 | if (!item) return RecBody(); |
644 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 660 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
645 | return view->fetchBody(aMail); | 661 | return view->fetchBody(aMail); |
646 | } | 662 | } |
647 | 663 | ||
648 | void AccountView::setupFolderselect(Selectstore*sels) | 664 | void AccountView::setupFolderselect(Selectstore*sels) |
649 | { | 665 | { |
650 | sels->showMaximized(); | 666 | sels->showMaximized(); |
651 | QStringList sFolders; | 667 | QStringList sFolders; |
652 | unsigned int i = 0; | 668 | unsigned int i = 0; |
653 | for (i=0; i < mboxAccounts.count();++i) { | 669 | for (i=0; i < mboxAccounts.count();++i) { |
654 | mboxAccounts[i]->refresh(false); | 670 | mboxAccounts[i]->refresh(false); |
655 | sFolders = mboxAccounts[i]->subFolders(); | 671 | sFolders = mboxAccounts[i]->subFolders(); |
656 | sels->addAccounts(mboxAccounts[i]->getWrapper(),sFolders); | 672 | sels->addAccounts(mboxAccounts[i]->getWrapper(),sFolders); |
657 | } | 673 | } |
658 | for (i=0; i < imapAccounts.count();++i) { | 674 | for (i=0; i < imapAccounts.count();++i) { |
659 | if (imapAccounts[i]->offline()) | 675 | if (imapAccounts[i]->offline()) |
660 | continue; | 676 | continue; |
661 | imapAccounts[i]->refreshFolders(false); | 677 | imapAccounts[i]->refreshFolders(false); |
662 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); | 678 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); |
663 | } | 679 | } |
664 | } | 680 | } |
665 | 681 | ||
666 | void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper) | 682 | void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper) |
667 | { | 683 | { |
668 | unsigned int i = 0; | ||
669 | AbstractMail*targetMail = 0; | 684 | AbstractMail*targetMail = 0; |
670 | QString targetFolder = ""; | 685 | QString targetFolder = ""; |
671 | Selectstore sels; | 686 | Selectstore sels; |
672 | setupFolderselect(&sels); | 687 | setupFolderselect(&sels); |
673 | if (!sels.exec()) return; | 688 | if (!sels.exec()) return; |
674 | targetMail = sels.currentMail(); | 689 | targetMail = sels.currentMail(); |
675 | targetFolder = sels.currentFolder(); | 690 | targetFolder = sels.currentFolder(); |
676 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | 691 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || |
677 | targetFolder.isEmpty()) { | 692 | targetFolder.isEmpty()) { |
678 | return; | 693 | return; |
679 | } | 694 | } |
680 | 695 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) { | |
681 | QList<RecMail> t; | 696 | QMessageBox::critical(0,tr("Error creating new Folder"), |
682 | fromWrapper->listMessages(fromFolder->getName(),t); | 697 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
683 | encodedString*st = 0; | 698 | return; |
684 | for (i = 0; i < t.count();++i) { | ||
685 | RecMail*r = t.at(i); | ||
686 | st = fromWrapper->fetchRawBody(*r); | ||
687 | if (st) { | ||
688 | targetMail->storeMessage(st->Content(),st->Length(),targetFolder); | ||
689 | delete st; | ||
690 | } | ||
691 | } | 699 | } |
700 | qDebug("Targetfolder: %s",targetFolder.latin1()); | ||
701 | qDebug("Fromfolder: %s",fromFolder->getName().latin1()); | ||
702 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); | ||
703 | refreshCurrent(); | ||
692 | } | 704 | } |
693 | 705 | ||
694 | /** | 706 | /** |
695 | * MBOX Account stuff | 707 | * MBOX Account stuff |
696 | */ | 708 | */ |
697 | 709 | ||
698 | MBOXviewItem::MBOXviewItem( const QString&aPath, AccountView *parent ) | 710 | MBOXviewItem::MBOXviewItem( const QString&aPath, AccountView *parent ) |
699 | : AccountViewItem( parent ) | 711 | : AccountViewItem( parent ) |
700 | { | 712 | { |
701 | m_Path = aPath; | 713 | m_Path = aPath; |
702 | /* be carefull - the space within settext is wanted - thats why the string twice */ | 714 | /* be carefull - the space within settext is wanted - thats why the string twice */ |
703 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); | 715 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); |
704 | setPixmap( 0, PIXMAP_LOCALFOLDER ); | 716 | setPixmap( 0, PIXMAP_LOCALFOLDER ); |
705 | setText( 0, " Local Folders" ); | 717 | setText( 0, " Local Folders" ); |
706 | setOpen( true ); | 718 | setOpen( true ); |
707 | } | 719 | } |
708 | 720 | ||
709 | MBOXviewItem::~MBOXviewItem() | 721 | MBOXviewItem::~MBOXviewItem() |
710 | { | 722 | { |
711 | delete wrapper; | 723 | delete wrapper; |
712 | } | 724 | } |
713 | 725 | ||
714 | AbstractMail *MBOXviewItem::getWrapper() | 726 | AbstractMail *MBOXviewItem::getWrapper() |
715 | { | 727 | { |
716 | return wrapper; | 728 | return wrapper; |
717 | } | 729 | } |
718 | 730 | ||
719 | void MBOXviewItem::refresh( QList<RecMail> & ) | 731 | void MBOXviewItem::refresh( QList<RecMail> & ) |
720 | { | 732 | { |
721 | refresh(false); | 733 | refresh(false); |
722 | } | 734 | } |
723 | 735 | ||
724 | void MBOXviewItem::refresh(bool force) | 736 | void MBOXviewItem::refresh(bool force) |
725 | { | 737 | { |
726 | if (childCount()>0 && force==false) return; | 738 | if (childCount()>0 && force==false) return; |
727 | QList<Folder> *folders = wrapper->listFolders(); | 739 | QList<Folder> *folders = wrapper->listFolders(); |
728 | QListViewItem *child = firstChild(); | 740 | QListViewItem *child = firstChild(); |
729 | while ( child ) { | 741 | while ( child ) { |
730 | QListViewItem *tmp = child; | 742 | QListViewItem *tmp = child; |
731 | child = child->nextSibling(); | 743 | child = child->nextSibling(); |
732 | delete tmp; | 744 | delete tmp; |
733 | } | 745 | } |
734 | Folder *it; | 746 | Folder *it; |
735 | QListViewItem*item = 0; | 747 | QListViewItem*item = 0; |
736 | for ( it = folders->first(); it; it = folders->next() ) { | 748 | for ( it = folders->first(); it; it = folders->next() ) { |
737 | item = new MBOXfolderItem( it, this , item ); | 749 | item = new MBOXfolderItem( it, this , item ); |
738 | item->setSelectable(it->may_select()); | 750 | item->setSelectable(it->may_select()); |
739 | } | 751 | } |
740 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 752 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
741 | folders->setAutoDelete(false); | 753 | folders->setAutoDelete(false); |
742 | delete folders; | 754 | delete folders; |
743 | } | 755 | } |
744 | 756 | ||
745 | RecBody MBOXviewItem::fetchBody( const RecMail &mail ) | 757 | RecBody MBOXviewItem::fetchBody( const RecMail &mail ) |
746 | { | 758 | { |
747 | qDebug( "MBOX fetchBody" ); | 759 | qDebug( "MBOX fetchBody" ); |
748 | return wrapper->fetchBody( mail ); | 760 | return wrapper->fetchBody( mail ); |
749 | } | 761 | } |
750 | 762 | ||
751 | QPopupMenu * MBOXviewItem::getContextMenu() | 763 | QPopupMenu * MBOXviewItem::getContextMenu() |
752 | { | 764 | { |
753 | QPopupMenu *m = new QPopupMenu(0); | 765 | QPopupMenu *m = new QPopupMenu(0); |
754 | if (m) { | 766 | if (m) { |
755 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 767 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); |
756 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 768 | m->insertItem(QObject::tr("Create new folder",contextName),1); |
757 | } | 769 | } |
758 | return m; | 770 | return m; |
759 | } | 771 | } |
760 | 772 | ||
761 | void MBOXviewItem::createFolder() | 773 | void MBOXviewItem::createFolder() |
762 | { | 774 | { |
763 | Newmdirdlg ndirdlg(0,0,true); | 775 | Newmdirdlg ndirdlg(0,0,true); |
764 | ndirdlg.showMaximized(); | 776 | ndirdlg.showMaximized(); |
765 | if (ndirdlg.exec()) { | 777 | if (ndirdlg.exec()) { |
766 | QString ndir = ndirdlg.Newdir(); | 778 | QString ndir = ndirdlg.Newdir(); |
767 | if (wrapper->createMbox(ndir)) { | 779 | if (wrapper->createMbox(ndir)) { |
768 | refresh(true); | 780 | refresh(true); |
769 | } | 781 | } |
770 | } | 782 | } |
771 | } | 783 | } |
772 | 784 | ||
773 | QStringList MBOXviewItem::subFolders() | 785 | QStringList MBOXviewItem::subFolders() |
774 | { | 786 | { |
775 | QStringList result; | 787 | QStringList result; |
776 | QListViewItem *child = firstChild(); | 788 | QListViewItem *child = firstChild(); |
777 | while ( child ) { | 789 | while ( child ) { |
778 | MBOXfolderItem *tmp = (MBOXfolderItem*)child; | 790 | MBOXfolderItem *tmp = (MBOXfolderItem*)child; |
779 | child = child->nextSibling(); | 791 | child = child->nextSibling(); |
780 | result.append(tmp->getFolder()->getName()); | 792 | result.append(tmp->getFolder()->getName()); |
781 | } | 793 | } |
782 | qDebug("Size of result: %i",result.count()); | 794 | qDebug("Size of result: %i",result.count()); |
783 | return result; | 795 | return result; |
784 | } | 796 | } |
785 | 797 | ||
786 | void MBOXviewItem::contextMenuSelected(int which) | 798 | void MBOXviewItem::contextMenuSelected(int which) |
787 | { | 799 | { |
788 | switch (which) { | 800 | switch (which) { |
789 | case 0: | 801 | case 0: |
790 | refresh(true); | 802 | refresh(true); |
791 | break; | 803 | break; |
792 | case 1: | 804 | case 1: |
793 | createFolder(); | 805 | createFolder(); |
794 | break; | 806 | break; |
795 | default: | 807 | default: |
796 | break; | 808 | break; |
797 | } | 809 | } |
798 | } | 810 | } |
799 | 811 | ||
800 | MBOXfolderItem::~MBOXfolderItem() | 812 | MBOXfolderItem::~MBOXfolderItem() |
801 | { | 813 | { |
802 | delete folder; | 814 | delete folder; |
803 | } | 815 | } |
804 | 816 | ||
805 | MBOXfolderItem::MBOXfolderItem( Folder *folderInit, MBOXviewItem *parent , QListViewItem*after ) | 817 | MBOXfolderItem::MBOXfolderItem( Folder *folderInit, MBOXviewItem *parent , QListViewItem*after ) |
806 | : AccountViewItem( parent,after ) | 818 | : AccountViewItem( parent,after ) |
807 | { | 819 | { |
808 | folder = folderInit; | 820 | folder = folderInit; |
809 | mbox = parent; | 821 | mbox = parent; |
810 | if (folder->getDisplayName().lower() == "outgoing") { | 822 | if (folder->getDisplayName().lower() == "outgoing") { |
811 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); | 823 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); |
812 | } else if (folder->getDisplayName().lower() == "inbox") { | 824 | } else if (folder->getDisplayName().lower() == "inbox") { |
813 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 825 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
814 | } else { | 826 | } else { |
815 | setPixmap( 0, PIXMAP_MBOXFOLDER ); | 827 | setPixmap( 0, PIXMAP_MBOXFOLDER ); |
816 | } | 828 | } |
817 | setText( 0, folder->getDisplayName() ); | 829 | setText( 0, folder->getDisplayName() ); |
818 | } | 830 | } |
819 | 831 | ||
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index 48f52c7..df916c1 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h | |||
@@ -1,178 +1,179 @@ | |||
1 | #ifndef ACCOUNTVIEW_H | 1 | #ifndef ACCOUNTVIEW_H |
2 | #define ACCOUNTVIEW_H | 2 | #define ACCOUNTVIEW_H |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | 6 | ||
7 | #include <libmailwrapper/settings.h> | 7 | #include <libmailwrapper/settings.h> |
8 | #include <libmailwrapper/mailwrapper.h> | 8 | #include <libmailwrapper/mailwrapper.h> |
9 | #include <libmailwrapper/abstractmail.h> | 9 | #include <libmailwrapper/abstractmail.h> |
10 | 10 | ||
11 | class POP3wrapper; | 11 | class POP3wrapper; |
12 | class RecMail; | 12 | class RecMail; |
13 | class RecBody; | 13 | class RecBody; |
14 | class QPopupMenu; | 14 | class QPopupMenu; |
15 | class Selectstore; | 15 | class Selectstore; |
16 | class AccountView; | 16 | class AccountView; |
17 | 17 | ||
18 | class AccountViewItem : public QListViewItem | 18 | class AccountViewItem : public QListViewItem |
19 | { | 19 | { |
20 | 20 | ||
21 | public: | 21 | public: |
22 | AccountViewItem( AccountView *parent ); | 22 | AccountViewItem( AccountView *parent ); |
23 | AccountViewItem( QListViewItem *parent); | 23 | AccountViewItem( QListViewItem *parent); |
24 | AccountViewItem( QListViewItem *parent , QListViewItem*after ); | 24 | AccountViewItem( QListViewItem *parent , QListViewItem*after ); |
25 | virtual ~AccountViewItem(); | 25 | virtual ~AccountViewItem(); |
26 | virtual void refresh(QList<RecMail>&)=0; | 26 | virtual void refresh(QList<RecMail>&)=0; |
27 | virtual RecBody fetchBody(const RecMail&)=0; | 27 | virtual RecBody fetchBody(const RecMail&)=0; |
28 | virtual QPopupMenu * getContextMenu(){return 0;}; | 28 | virtual QPopupMenu * getContextMenu(){return 0;}; |
29 | virtual void contextMenuSelected(int){} | 29 | virtual void contextMenuSelected(int){} |
30 | virtual AccountView*accountView(); | 30 | virtual AccountView*accountView(); |
31 | protected: | 31 | protected: |
32 | virtual void deleteAllMail(AbstractMail*wrapper,Folder*f); | 32 | virtual void deleteAllMail(AbstractMail*wrapper,Folder*f); |
33 | static const QString contextName; | 33 | static const QString contextName; |
34 | AccountView*m_Backlink; | 34 | AccountView*m_Backlink; |
35 | }; | 35 | }; |
36 | 36 | ||
37 | class POP3viewItem : public AccountViewItem | 37 | class POP3viewItem : public AccountViewItem |
38 | { | 38 | { |
39 | 39 | ||
40 | public: | 40 | public: |
41 | POP3viewItem( POP3account *a, AccountView *parent ); | 41 | POP3viewItem( POP3account *a, AccountView *parent ); |
42 | virtual ~POP3viewItem(); | 42 | virtual ~POP3viewItem(); |
43 | virtual void refresh( QList<RecMail> &target ); | 43 | virtual void refresh( QList<RecMail> &target ); |
44 | virtual RecBody fetchBody( const RecMail &mail ); | 44 | virtual RecBody fetchBody( const RecMail &mail ); |
45 | AbstractMail *getWrapper(); | 45 | AbstractMail *getWrapper(); |
46 | virtual QPopupMenu * getContextMenu(); | 46 | virtual QPopupMenu * getContextMenu(); |
47 | virtual void contextMenuSelected(int); | 47 | virtual void contextMenuSelected(int); |
48 | 48 | ||
49 | protected: | 49 | protected: |
50 | POP3account *account; | 50 | POP3account *account; |
51 | virtual void refresh(); | ||
51 | AbstractMail *wrapper; | 52 | AbstractMail *wrapper; |
52 | void disconnect(); | 53 | void disconnect(); |
53 | void setOnOffline(); | 54 | void setOnOffline(); |
54 | }; | 55 | }; |
55 | 56 | ||
56 | class POP3folderItem : public AccountViewItem | 57 | class POP3folderItem : public AccountViewItem |
57 | { | 58 | { |
58 | 59 | ||
59 | public: | 60 | public: |
60 | POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); | 61 | POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); |
61 | virtual ~POP3folderItem(); | 62 | virtual ~POP3folderItem(); |
62 | virtual void refresh(QList<RecMail>&); | 63 | virtual void refresh(QList<RecMail>&); |
63 | virtual RecBody fetchBody(const RecMail&); | 64 | virtual RecBody fetchBody(const RecMail&); |
64 | virtual QPopupMenu * getContextMenu(); | 65 | virtual QPopupMenu * getContextMenu(); |
65 | virtual void contextMenuSelected(int); | 66 | virtual void contextMenuSelected(int); |
66 | 67 | ||
67 | protected: | 68 | protected: |
68 | void downloadMails(); | 69 | void downloadMails(); |
69 | Folder *folder; | 70 | Folder *folder; |
70 | POP3viewItem *pop3; | 71 | POP3viewItem *pop3; |
71 | }; | 72 | }; |
72 | 73 | ||
73 | class IMAPfolderItem; | 74 | class IMAPfolderItem; |
74 | 75 | ||
75 | class IMAPviewItem : public AccountViewItem | 76 | class IMAPviewItem : public AccountViewItem |
76 | { | 77 | { |
77 | friend class IMAPfolderItem; | 78 | friend class IMAPfolderItem; |
78 | public: | 79 | public: |
79 | IMAPviewItem( IMAPaccount *a, AccountView *parent ); | 80 | IMAPviewItem( IMAPaccount *a, AccountView *parent ); |
80 | virtual ~IMAPviewItem(); | 81 | virtual ~IMAPviewItem(); |
81 | virtual void refresh(QList<RecMail>&); | 82 | virtual void refresh(QList<RecMail>&); |
82 | virtual RecBody fetchBody(const RecMail&); | 83 | virtual RecBody fetchBody(const RecMail&); |
83 | AbstractMail *getWrapper(); | 84 | AbstractMail *getWrapper(); |
84 | virtual QPopupMenu * getContextMenu(); | 85 | virtual QPopupMenu * getContextMenu(); |
85 | virtual void contextMenuSelected(int); | 86 | virtual void contextMenuSelected(int); |
86 | const QStringList&subFolders(); | 87 | const QStringList&subFolders(); |
87 | virtual void refreshFolders(bool force=false); | 88 | virtual void refreshFolders(bool force=false); |
88 | bool offline(); | 89 | bool offline(); |
89 | 90 | ||
90 | protected: | 91 | protected: |
91 | IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0); | 92 | IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0); |
92 | virtual void createNewFolder(); | 93 | virtual void createNewFolder(); |
93 | virtual void removeChilds(); | 94 | virtual void removeChilds(); |
94 | IMAPaccount *account; | 95 | IMAPaccount *account; |
95 | AbstractMail *wrapper; | 96 | AbstractMail *wrapper; |
96 | QStringList currentFolders; | 97 | QStringList currentFolders; |
97 | }; | 98 | }; |
98 | 99 | ||
99 | class IMAPfolderItem : public AccountViewItem | 100 | class IMAPfolderItem : public AccountViewItem |
100 | { | 101 | { |
101 | 102 | ||
102 | public: | 103 | public: |
103 | IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); | 104 | IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); |
104 | IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); | 105 | IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); |
105 | virtual ~IMAPfolderItem(); | 106 | virtual ~IMAPfolderItem(); |
106 | virtual void refresh(QList<RecMail>&); | 107 | virtual void refresh(QList<RecMail>&); |
107 | virtual RecBody fetchBody(const RecMail&); | 108 | virtual RecBody fetchBody(const RecMail&); |
108 | bool matchName(const QString&name)const; | 109 | bool matchName(const QString&name)const; |
109 | virtual QPopupMenu * getContextMenu(); | 110 | virtual QPopupMenu * getContextMenu(); |
110 | virtual void contextMenuSelected(int); | 111 | virtual void contextMenuSelected(int); |
111 | virtual const QString& Delemiter()const; | 112 | virtual const QString& Delemiter()const; |
112 | protected: | 113 | protected: |
113 | virtual void createNewFolder(); | 114 | virtual void createNewFolder(); |
114 | virtual void deleteFolder(); | 115 | virtual void deleteFolder(); |
115 | virtual void downloadMails(); | 116 | virtual void downloadMails(); |
116 | Folder *folder; | 117 | Folder *folder; |
117 | IMAPviewItem *imap; | 118 | IMAPviewItem *imap; |
118 | }; | 119 | }; |
119 | 120 | ||
120 | class MBOXviewItem : public AccountViewItem | 121 | class MBOXviewItem : public AccountViewItem |
121 | { | 122 | { |
122 | friend class MBOXfolderItem; | 123 | friend class MBOXfolderItem; |
123 | 124 | ||
124 | public: | 125 | public: |
125 | MBOXviewItem( const QString&aMboxPath, AccountView *parent ); | 126 | MBOXviewItem( const QString&aMboxPath, AccountView *parent ); |
126 | virtual ~MBOXviewItem(); | 127 | virtual ~MBOXviewItem(); |
127 | virtual void refresh( QList<RecMail> &target ); | 128 | virtual void refresh( QList<RecMail> &target ); |
128 | virtual RecBody fetchBody( const RecMail &mail ); | 129 | virtual RecBody fetchBody( const RecMail &mail ); |
129 | AbstractMail *getWrapper(); | 130 | AbstractMail *getWrapper(); |
130 | virtual QPopupMenu * getContextMenu(); | 131 | virtual QPopupMenu * getContextMenu(); |
131 | virtual void contextMenuSelected(int); | 132 | virtual void contextMenuSelected(int); |
132 | QStringList subFolders(); | 133 | QStringList subFolders(); |
133 | virtual void refresh(bool force=false); | 134 | virtual void refresh(bool force=false); |
134 | 135 | ||
135 | protected: | 136 | protected: |
136 | virtual void createFolder(); | 137 | virtual void createFolder(); |
137 | QString m_Path; | 138 | QString m_Path; |
138 | AbstractMail *wrapper; | 139 | AbstractMail *wrapper; |
139 | 140 | ||
140 | }; | 141 | }; |
141 | 142 | ||
142 | class MBOXfolderItem : public AccountViewItem | 143 | class MBOXfolderItem : public AccountViewItem |
143 | { | 144 | { |
144 | 145 | ||
145 | public: | 146 | public: |
146 | MBOXfolderItem( Folder *folder, MBOXviewItem *parent , QListViewItem*after ); | 147 | MBOXfolderItem( Folder *folder, MBOXviewItem *parent , QListViewItem*after ); |
147 | virtual ~MBOXfolderItem(); | 148 | virtual ~MBOXfolderItem(); |
148 | virtual void refresh(QList<RecMail>&); | 149 | virtual void refresh(QList<RecMail>&); |
149 | virtual RecBody fetchBody(const RecMail&); | 150 | virtual RecBody fetchBody(const RecMail&); |
150 | virtual QPopupMenu * getContextMenu(); | 151 | virtual QPopupMenu * getContextMenu(); |
151 | virtual void contextMenuSelected(int); | 152 | virtual void contextMenuSelected(int); |
152 | virtual Folder*getFolder(); | 153 | virtual Folder*getFolder(); |
153 | 154 | ||
154 | protected: | 155 | protected: |
155 | virtual void deleteFolder(); | 156 | virtual void deleteFolder(); |
156 | Folder *folder; | 157 | Folder *folder; |
157 | MBOXviewItem *mbox; | 158 | MBOXviewItem *mbox; |
158 | }; | 159 | }; |
159 | 160 | ||
160 | class AccountView : public QListView | 161 | class AccountView : public QListView |
161 | { | 162 | { |
162 | Q_OBJECT | 163 | Q_OBJECT |
163 | 164 | ||
164 | public: | 165 | public: |
165 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); | 166 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); |
166 | virtual ~AccountView(); | 167 | virtual ~AccountView(); |
167 | virtual void populate( QList<Account> list ); | 168 | virtual void populate( QList<Account> list ); |
168 | virtual RecBody fetchBody(const RecMail&aMail); | 169 | virtual RecBody fetchBody(const RecMail&aMail); |
169 | virtual void downloadMails(Folder*fromFolder,AbstractMail*fromWrapper); | 170 | virtual void downloadMails(Folder*fromFolder,AbstractMail*fromWrapper); |
170 | 171 | ||
171 | public slots: | 172 | public slots: |
172 | virtual void refreshAll(); | 173 | virtual void refreshAll(); |
173 | virtual void refresh(QListViewItem *item); | 174 | virtual void refresh(QListViewItem *item); |
174 | virtual void refreshCurrent(); | 175 | virtual void refreshCurrent(); |
175 | virtual void slotHold(int, QListViewItem *,const QPoint&,int); | 176 | virtual void slotHold(int, QListViewItem *,const QPoint&,int); |
176 | virtual void slotContextMenu(int id); | 177 | virtual void slotContextMenu(int id); |
177 | void setupFolderselect(Selectstore*sels); | 178 | void setupFolderselect(Selectstore*sels); |
178 | 179 | ||
diff --git a/noncore/net/mail/defines.h b/noncore/net/mail/defines.h index ebe8e08..d840f09 100644 --- a/noncore/net/mail/defines.h +++ b/noncore/net/mail/defines.h | |||
@@ -1,54 +1,57 @@ | |||
1 | #ifndef DEFINE_CONSTANTS_H | 1 | #ifndef DEFINE_CONSTANTS_H |
2 | #define DEFINE_CONSTANTS_H | 2 | #define DEFINE_CONSTANTS_H |
3 | 3 | ||
4 | #include <qpe/resource.h> | 4 | #include <qpe/resource.h> |
5 | 5 | ||
6 | #define USER_AGENT "OpieMail v0.3" | 6 | #define USER_AGENT "OpieMail v0.3" |
7 | 7 | ||
8 | #define PIC_COMPOSEMAIL "mail/composemail" | 8 | #define PIC_COMPOSEMAIL "mail/composemail" |
9 | #define PIC_SENDQUEUED "mail/sendqueued" | 9 | #define PIC_SENDQUEUED "mail/sendqueued" |
10 | #define PIC_SHOWFOLDERS "mail/showfolders" | 10 | #define PIC_SHOWFOLDERS "mail/showfolders" |
11 | #define PIC_SYNC "mail/sync" | 11 | #define PIC_SYNC "mail/sync" |
12 | #define PIC_IMAPFOLDER "mail/imapfolder" | 12 | #define PIC_IMAPFOLDER "mail/imapfolder" |
13 | #define PIC_MBOXFOLDER "mail/mboxfolder" | 13 | #define PIC_MBOXFOLDER "mail/mboxfolder" |
14 | #define PIC_POP3FOLDER "mail/pop3folder" | 14 | #define PIC_POP3FOLDER "mail/pop3folder" |
15 | #define PIC_INBOXFOLDER "mail/inbox" | 15 | #define PIC_INBOXFOLDER "mail/inbox" |
16 | #define PIC_OUTBOXFOLDER "mail/outbox" | 16 | #define PIC_OUTBOXFOLDER "mail/outbox" |
17 | #define PIC_LOCALFOLDER "mail/localfolder" | 17 | #define PIC_LOCALFOLDER "mail/localfolder" |
18 | 18 | ||
19 | #define PIC_OFFLINE "mail/notconnected" | ||
20 | |||
19 | #define ICON_COMPOSEMAIL QIconSet( Resource::loadPixmap( PIC_COMPOSEMAIL ) ) | 21 | #define ICON_COMPOSEMAIL QIconSet( Resource::loadPixmap( PIC_COMPOSEMAIL ) ) |
20 | #define ICON_SENDQUEUED QIconSet( Resource::loadPixmap( PIC_SENDQUEUED ) ) | 22 | #define ICON_SENDQUEUED QIconSet( Resource::loadPixmap( PIC_SENDQUEUED ) ) |
21 | #define ICON_SHOWFOLDERS QIconSet( Resource::loadPixmap( PIC_SHOWFOLDERS ) ) | 23 | #define ICON_SHOWFOLDERS QIconSet( Resource::loadPixmap( PIC_SHOWFOLDERS ) ) |
22 | #define ICON_SEARCHMAILS QIconSet( Resource::loadPixmap( PIC_SEARCHMAILS ) ) | 24 | #define ICON_SEARCHMAILS QIconSet( Resource::loadPixmap( PIC_SEARCHMAILS ) ) |
23 | #define ICON_EDITSETTINGS QIconSet( Resource::loadPixmap( PIC_EDITSETTINGS ) ) | 25 | #define ICON_EDITSETTINGS QIconSet( Resource::loadPixmap( PIC_EDITSETTINGS ) ) |
24 | #define ICON_EDITACCOUNTS QIconSet( Resource::loadPixmap( PIC_EDITACCOUNTS ) ) | 26 | #define ICON_EDITACCOUNTS QIconSet( Resource::loadPixmap( PIC_EDITACCOUNTS ) ) |
25 | #define ICON_SYNC QIconSet( Resource::loadPixmap( PIC_SYNC ) ) | 27 | #define ICON_SYNC QIconSet( Resource::loadPixmap( PIC_SYNC ) ) |
26 | 28 | ||
27 | #define PIXMAP_IMAPFOLDER QPixmap( Resource::loadPixmap( PIC_IMAPFOLDER ) ) | 29 | #define PIXMAP_IMAPFOLDER QPixmap( Resource::loadPixmap( PIC_IMAPFOLDER ) ) |
28 | #define PIXMAP_POP3FOLDER QPixmap( Resource::loadPixmap( PIC_POP3FOLDER ) ) | 30 | #define PIXMAP_POP3FOLDER QPixmap( Resource::loadPixmap( PIC_POP3FOLDER ) ) |
29 | #define PIXMAP_INBOXFOLDER QPixmap( Resource::loadPixmap( PIC_INBOXFOLDER) ) | 31 | #define PIXMAP_INBOXFOLDER QPixmap( Resource::loadPixmap( PIC_INBOXFOLDER) ) |
30 | #define PIXMAP_MBOXFOLDER QPixmap( Resource::loadPixmap( PIC_MBOXFOLDER ) ) | 32 | #define PIXMAP_MBOXFOLDER QPixmap( Resource::loadPixmap( PIC_MBOXFOLDER ) ) |
31 | #define PIXMAP_OUTBOXFOLDER QPixmap( Resource::loadPixmap( PIC_OUTBOXFOLDER) ) | 33 | #define PIXMAP_OUTBOXFOLDER QPixmap( Resource::loadPixmap( PIC_OUTBOXFOLDER) ) |
32 | #define PIXMAP_LOCALFOLDER QPixmap( Resource::loadPixmap( PIC_LOCALFOLDER) ) | 34 | #define PIXMAP_LOCALFOLDER QPixmap( Resource::loadPixmap( PIC_LOCALFOLDER) ) |
35 | #define PIXMAP_OFFLINE QPixmap( Resource::loadPixmap( PIC_OFFLINE) ) | ||
33 | 36 | ||
34 | #define IMAP_PORT "143" | 37 | #define IMAP_PORT "143" |
35 | #define IMAP_SSL_PORT "993" | 38 | #define IMAP_SSL_PORT "993" |
36 | #define SMTP_PORT "25" | 39 | #define SMTP_PORT "25" |
37 | #define SMTP_SSL_PORT "465" | 40 | #define SMTP_SSL_PORT "465" |
38 | #define POP3_PORT "110" | 41 | #define POP3_PORT "110" |
39 | #define POP3_SSL_PORT "995" | 42 | #define POP3_SSL_PORT "995" |
40 | #define NNTP_PORT "119" | 43 | #define NNTP_PORT "119" |
41 | #define NNTP_SSL_PORT "563" | 44 | #define NNTP_SSL_PORT "563" |
42 | 45 | ||
43 | /* used for decoding imapfoldername */ | 46 | /* used for decoding imapfoldername */ |
44 | #define UNDEFINED 64 | 47 | #define UNDEFINED 64 |
45 | #define MAXLINE 76 | 48 | #define MAXLINE 76 |
46 | #define UTF16MASK 0x03FFUL | 49 | #define UTF16MASK 0x03FFUL |
47 | #define UTF16SHIFT 10 | 50 | #define UTF16SHIFT 10 |
48 | #define UTF16BASE 0x10000UL | 51 | #define UTF16BASE 0x10000UL |
49 | #define UTF16HIGHSTART 0xD800UL | 52 | #define UTF16HIGHSTART 0xD800UL |
50 | #define UTF16HIGHEND 0xDBFFUL | 53 | #define UTF16HIGHEND 0xDBFFUL |
51 | #define UTF16LOSTART 0xDC00UL | 54 | #define UTF16LOSTART 0xDC00UL |
52 | #define UTF16LOEND 0xDFFFUL | 55 | #define UTF16LOEND 0xDFFFUL |
53 | 56 | ||
54 | #endif | 57 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp index 3dd2fce..4b4c728 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.cpp +++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp | |||
@@ -1,106 +1,125 @@ | |||
1 | #include "abstractmail.h" | 1 | #include "abstractmail.h" |
2 | #include "imapwrapper.h" | 2 | #include "imapwrapper.h" |
3 | #include "pop3wrapper.h" | 3 | #include "pop3wrapper.h" |
4 | #include "mboxwrapper.h" | 4 | #include "mboxwrapper.h" |
5 | #include "mailtypes.h" | 5 | #include "mailtypes.h" |
6 | 6 | ||
7 | #include <qstring.h> | 7 | #include <qstring.h> |
8 | #include <qfile.h> | 8 | #include <qfile.h> |
9 | #include <qtextstream.h> | 9 | #include <qtextstream.h> |
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <libetpan/mailmime_content.h> | 11 | #include <libetpan/mailmime_content.h> |
12 | #include <libetpan/mailmime.h> | 12 | #include <libetpan/mailmime.h> |
13 | 13 | ||
14 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) | 14 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) |
15 | { | 15 | { |
16 | return new IMAPwrapper(a); | 16 | return new IMAPwrapper(a); |
17 | } | 17 | } |
18 | 18 | ||
19 | AbstractMail* AbstractMail::getWrapper(POP3account *a) | 19 | AbstractMail* AbstractMail::getWrapper(POP3account *a) |
20 | { | 20 | { |
21 | return new POP3wrapper(a); | 21 | return new POP3wrapper(a); |
22 | } | 22 | } |
23 | 23 | ||
24 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) | 24 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) |
25 | { | 25 | { |
26 | return new MBOXwrapper(a,name); | 26 | return new MBOXwrapper(a,name); |
27 | } | 27 | } |
28 | 28 | ||
29 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) | 29 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) |
30 | { | 30 | { |
31 | qDebug("Decode string start"); | 31 | qDebug("Decode string start"); |
32 | char*result_text; | 32 | char*result_text; |
33 | size_t index = 0; | 33 | size_t index = 0; |
34 | /* reset for recursive use! */ | 34 | /* reset for recursive use! */ |
35 | size_t target_length = 0; | 35 | size_t target_length = 0; |
36 | result_text = 0; | 36 | result_text = 0; |
37 | int mimetype = MAILMIME_MECHANISM_7BIT; | 37 | int mimetype = MAILMIME_MECHANISM_7BIT; |
38 | if (enc.lower()=="quoted-printable") { | 38 | if (enc.lower()=="quoted-printable") { |
39 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; | 39 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; |
40 | } else if (enc.lower()=="base64") { | 40 | } else if (enc.lower()=="base64") { |
41 | mimetype = MAILMIME_MECHANISM_BASE64; | 41 | mimetype = MAILMIME_MECHANISM_BASE64; |
42 | } else if (enc.lower()=="8bit") { | 42 | } else if (enc.lower()=="8bit") { |
43 | mimetype = MAILMIME_MECHANISM_8BIT; | 43 | mimetype = MAILMIME_MECHANISM_8BIT; |
44 | } else if (enc.lower()=="binary") { | 44 | } else if (enc.lower()=="binary") { |
45 | mimetype = MAILMIME_MECHANISM_BINARY; | 45 | mimetype = MAILMIME_MECHANISM_BINARY; |
46 | } | 46 | } |
47 | 47 | ||
48 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, | 48 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, |
49 | &result_text,&target_length); | 49 | &result_text,&target_length); |
50 | 50 | ||
51 | encodedString* result = new encodedString(); | 51 | encodedString* result = new encodedString(); |
52 | if (err == MAILIMF_NO_ERROR) { | 52 | if (err == MAILIMF_NO_ERROR) { |
53 | result->setContent(result_text,target_length); | 53 | result->setContent(result_text,target_length); |
54 | } | 54 | } |
55 | qDebug("Decode string finished"); | 55 | qDebug("Decode string finished"); |
56 | return result; | 56 | return result; |
57 | } | 57 | } |
58 | 58 | ||
59 | QString AbstractMail::convert_String(const char*text) | 59 | QString AbstractMail::convert_String(const char*text) |
60 | { | 60 | { |
61 | size_t index = 0; | 61 | size_t index = 0; |
62 | char*res = 0; | 62 | char*res = 0; |
63 | 63 | ||
64 | /* attention - doesn't work with arm systems! */ | 64 | /* attention - doesn't work with arm systems! */ |
65 | int err = mailmime_encoded_phrase_parse("iso-8859-1", | 65 | int err = mailmime_encoded_phrase_parse("iso-8859-1", |
66 | text, strlen(text),&index, "iso-8859-1",&res); | 66 | text, strlen(text),&index, "iso-8859-1",&res); |
67 | if (err != MAILIMF_NO_ERROR) { | 67 | if (err != MAILIMF_NO_ERROR) { |
68 | if (res) free(res); | 68 | if (res) free(res); |
69 | return QString(text); | 69 | return QString(text); |
70 | } | 70 | } |
71 | if (res) { | 71 | if (res) { |
72 | QString result(res); | 72 | QString result(res); |
73 | free(res); | 73 | free(res); |
74 | return result; | 74 | return result; |
75 | } | 75 | } |
76 | return QString(text); | 76 | return QString(text); |
77 | } | 77 | } |
78 | 78 | ||
79 | /* cp & paste from launcher */ | 79 | /* cp & paste from launcher */ |
80 | QString AbstractMail::gen_attachment_id() | 80 | QString AbstractMail::gen_attachment_id() |
81 | { | 81 | { |
82 | QFile file( "/proc/sys/kernel/random/uuid" ); | 82 | QFile file( "/proc/sys/kernel/random/uuid" ); |
83 | if (!file.open(IO_ReadOnly ) ) | 83 | if (!file.open(IO_ReadOnly ) ) |
84 | return QString::null; | 84 | return QString::null; |
85 | 85 | ||
86 | QTextStream stream(&file); | 86 | QTextStream stream(&file); |
87 | 87 | ||
88 | return "{" + stream.read().stripWhiteSpace() + "}"; | 88 | return "{" + stream.read().stripWhiteSpace() + "}"; |
89 | } | 89 | } |
90 | 90 | ||
91 | int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool) | 91 | int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool) |
92 | { | 92 | { |
93 | return 0; | 93 | return 0; |
94 | } | 94 | } |
95 | 95 | ||
96 | QString AbstractMail::defaultLocalfolder() | 96 | QString AbstractMail::defaultLocalfolder() |
97 | { | 97 | { |
98 | QString f = getenv( "HOME" ); | 98 | QString f = getenv( "HOME" ); |
99 | f += "/Applications/opiemail/localmail"; | 99 | f += "/Applications/opiemail/localmail"; |
100 | return f; | 100 | return f; |
101 | } | 101 | } |
102 | 102 | ||
103 | /* temporary - will be removed when implemented in all classes */ | 103 | /* temporary - will be removed when implemented in all classes */ |
104 | void AbstractMail::deleteMails(const QString &,QList<RecMail> &) | 104 | void AbstractMail::deleteMails(const QString &,QList<RecMail> &) |
105 | { | 105 | { |
106 | } | 106 | } |
107 | |||
108 | void AbstractMail::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | ||
109 | { | ||
110 | QList<RecMail> t; | ||
111 | listMessages(fromFolder->getName(),t); | ||
112 | encodedString*st = 0; | ||
113 | while (t.count()>0) { | ||
114 | RecMail*r = t.at(0); | ||
115 | st = fetchRawBody(*r); | ||
116 | if (st) { | ||
117 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | ||
118 | delete st; | ||
119 | } | ||
120 | t.removeFirst(); | ||
121 | } | ||
122 | if (moveit) { | ||
123 | deleteAllMail(fromFolder); | ||
124 | } | ||
125 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h index 15d83cb..8debaae 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.h +++ b/noncore/net/mail/libmailwrapper/abstractmail.h | |||
@@ -1,62 +1,64 @@ | |||
1 | #ifndef __abstract_mail_ | 1 | #ifndef __abstract_mail_ |
2 | #define __abstract_mail_ | 2 | #define __abstract_mail_ |
3 | 3 | ||
4 | #include <qobject.h> | 4 | #include <qobject.h> |
5 | #include "settings.h" | 5 | #include "settings.h" |
6 | 6 | ||
7 | class RecMail; | 7 | class RecMail; |
8 | class RecBody; | 8 | class RecBody; |
9 | class RecPart; | 9 | class RecPart; |
10 | class IMAPwrapper; | 10 | class IMAPwrapper; |
11 | class POP3wrapper; | 11 | class POP3wrapper; |
12 | class Folder; | 12 | class Folder; |
13 | class encodedString; | 13 | class encodedString; |
14 | struct folderStat; | 14 | struct folderStat; |
15 | 15 | ||
16 | class AbstractMail:public QObject | 16 | class AbstractMail:public QObject |
17 | { | 17 | { |
18 | Q_OBJECT | 18 | Q_OBJECT |
19 | public: | 19 | public: |
20 | AbstractMail(){}; | 20 | AbstractMail(){}; |
21 | virtual ~AbstractMail(){} | 21 | virtual ~AbstractMail(){} |
22 | virtual QList<Folder>* listFolders()=0; | 22 | virtual QList<Folder>* listFolders()=0; |
23 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; | 23 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; |
24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; | 24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; |
25 | virtual RecBody fetchBody(const RecMail&mail)=0; | 25 | virtual RecBody fetchBody(const RecMail&mail)=0; |
26 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; | 26 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; |
27 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; | 27 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; |
28 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; | 28 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; |
29 | virtual encodedString* fetchRawBody(const RecMail&mail)=0; | 29 | virtual encodedString* fetchRawBody(const RecMail&mail)=0; |
30 | 30 | ||
31 | virtual void deleteMail(const RecMail&mail)=0; | 31 | virtual void deleteMail(const RecMail&mail)=0; |
32 | virtual void answeredMail(const RecMail&mail)=0; | 32 | virtual void answeredMail(const RecMail&mail)=0; |
33 | virtual int deleteAllMail(const Folder*)=0; | 33 | virtual int deleteAllMail(const Folder*)=0; |
34 | virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); | 34 | virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); |
35 | virtual int deleteMbox(const Folder*)=0; | 35 | virtual int deleteMbox(const Folder*)=0; |
36 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; | 36 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; |
37 | 37 | ||
38 | virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | ||
39 | |||
38 | virtual void cleanMimeCache(){}; | 40 | virtual void cleanMimeCache(){}; |
39 | /* mail box methods */ | 41 | /* mail box methods */ |
40 | /* parameter is the box to create. | 42 | /* parameter is the box to create. |
41 | * if the implementing subclass has prefixes, | 43 | * if the implementing subclass has prefixes, |
42 | * them has to be appended automatic. | 44 | * them has to be appended automatic. |
43 | */ | 45 | */ |
44 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); | 46 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); |
45 | virtual void logout()=0; | 47 | virtual void logout()=0; |
46 | 48 | ||
47 | static AbstractMail* getWrapper(IMAPaccount *a); | 49 | static AbstractMail* getWrapper(IMAPaccount *a); |
48 | static AbstractMail* getWrapper(POP3account *a); | 50 | static AbstractMail* getWrapper(POP3account *a); |
49 | /* mbox only! */ | 51 | /* mbox only! */ |
50 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); | 52 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); |
51 | 53 | ||
52 | static QString defaultLocalfolder(); | 54 | static QString defaultLocalfolder(); |
53 | 55 | ||
54 | virtual const QString&getType()const=0; | 56 | virtual const QString&getType()const=0; |
55 | virtual const QString&getName()const=0; | 57 | virtual const QString&getName()const=0; |
56 | 58 | ||
57 | protected: | 59 | protected: |
58 | static encodedString*decode_String(const encodedString*text,const QString&enc); | 60 | static encodedString*decode_String(const encodedString*text,const QString&enc); |
59 | static QString convert_String(const char*text); | 61 | static QString convert_String(const char*text); |
60 | static QString gen_attachment_id(); | 62 | static QString gen_attachment_id(); |
61 | }; | 63 | }; |
62 | #endif | 64 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index bb74de9..23c678b 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -884,137 +884,168 @@ int IMAPwrapper::deleteAllMail(const Folder*folder) | |||
884 | } | 884 | } |
885 | flist = mailimap_flag_list_new_empty(); | 885 | flist = mailimap_flag_list_new_empty(); |
886 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 886 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
887 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 887 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
888 | set = mailimap_set_new_interval( 1, last ); | 888 | set = mailimap_set_new_interval( 1, last ); |
889 | err = mailimap_store(m_imap,set,store_flags); | 889 | err = mailimap_store(m_imap,set,store_flags); |
890 | mailimap_set_free( set ); | 890 | mailimap_set_free( set ); |
891 | mailimap_store_att_flags_free(store_flags); | 891 | mailimap_store_att_flags_free(store_flags); |
892 | if (err != MAILIMAP_NO_ERROR) { | 892 | if (err != MAILIMAP_NO_ERROR) { |
893 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 893 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
894 | return 0; | 894 | return 0; |
895 | } | 895 | } |
896 | qDebug("deleting mail: %s",m_imap->imap_response); | 896 | qDebug("deleting mail: %s",m_imap->imap_response); |
897 | /* should we realy do that at this moment? */ | 897 | /* should we realy do that at this moment? */ |
898 | err = mailimap_expunge(m_imap); | 898 | err = mailimap_expunge(m_imap); |
899 | if (err != MAILIMAP_NO_ERROR) { | 899 | if (err != MAILIMAP_NO_ERROR) { |
900 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 900 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
901 | return 0; | 901 | return 0; |
902 | } | 902 | } |
903 | qDebug("Delete successfull %s",m_imap->imap_response); | 903 | qDebug("Delete successfull %s",m_imap->imap_response); |
904 | return 1; | 904 | return 1; |
905 | } | 905 | } |
906 | 906 | ||
907 | int IMAPwrapper::createMbox(const QString&folder,const Folder*parentfolder,const QString& delemiter,bool getsubfolder) | 907 | int IMAPwrapper::createMbox(const QString&folder,const Folder*parentfolder,const QString& delemiter,bool getsubfolder) |
908 | { | 908 | { |
909 | if (folder.length()==0) return 0; | 909 | if (folder.length()==0) return 0; |
910 | login(); | 910 | login(); |
911 | if (!m_imap) {return 0;} | 911 | if (!m_imap) {return 0;} |
912 | QString pre = account->getPrefix(); | 912 | QString pre = account->getPrefix(); |
913 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { | 913 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { |
914 | pre+=delemiter; | 914 | pre+=delemiter; |
915 | } | 915 | } |
916 | if (parentfolder) { | 916 | if (parentfolder) { |
917 | pre += parentfolder->getDisplayName()+delemiter; | 917 | pre += parentfolder->getDisplayName()+delemiter; |
918 | } | 918 | } |
919 | pre+=folder; | 919 | pre+=folder; |
920 | if (getsubfolder) { | 920 | if (getsubfolder) { |
921 | if (delemiter.length()>0) { | 921 | if (delemiter.length()>0) { |
922 | pre+=delemiter; | 922 | pre+=delemiter; |
923 | } else { | 923 | } else { |
924 | Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); | 924 | Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); |
925 | return 0; | 925 | return 0; |
926 | } | 926 | } |
927 | } | 927 | } |
928 | qDebug("Creating %s",pre.latin1()); | 928 | qDebug("Creating %s",pre.latin1()); |
929 | int res = mailimap_create(m_imap,pre.latin1()); | 929 | int res = mailimap_create(m_imap,pre.latin1()); |
930 | if (res != MAILIMAP_NO_ERROR) { | 930 | if (res != MAILIMAP_NO_ERROR) { |
931 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 931 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
932 | return 0; | 932 | return 0; |
933 | } | 933 | } |
934 | return 1; | 934 | return 1; |
935 | } | 935 | } |
936 | 936 | ||
937 | int IMAPwrapper::deleteMbox(const Folder*folder) | 937 | int IMAPwrapper::deleteMbox(const Folder*folder) |
938 | { | 938 | { |
939 | if (!folder) return 0; | 939 | if (!folder) return 0; |
940 | login(); | 940 | login(); |
941 | if (!m_imap) {return 0;} | 941 | if (!m_imap) {return 0;} |
942 | int res = mailimap_delete(m_imap,folder->getName()); | 942 | int res = mailimap_delete(m_imap,folder->getName()); |
943 | if (res != MAILIMAP_NO_ERROR) { | 943 | if (res != MAILIMAP_NO_ERROR) { |
944 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 944 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
945 | return 0; | 945 | return 0; |
946 | } | 946 | } |
947 | return 1; | 947 | return 1; |
948 | } | 948 | } |
949 | 949 | ||
950 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 950 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
951 | { | 951 | { |
952 | mailimap_status_att_list * att_list =0; | 952 | mailimap_status_att_list * att_list =0; |
953 | mailimap_mailbox_data_status * status=0; | 953 | mailimap_mailbox_data_status * status=0; |
954 | clistiter * cur = 0; | 954 | clistiter * cur = 0; |
955 | int r = 0; | 955 | int r = 0; |
956 | int res = 0; | 956 | int res = 0; |
957 | target_stat.message_count = 0; | 957 | target_stat.message_count = 0; |
958 | target_stat.message_unseen = 0; | 958 | target_stat.message_unseen = 0; |
959 | target_stat.message_recent = 0; | 959 | target_stat.message_recent = 0; |
960 | login(); | 960 | login(); |
961 | if (!m_imap) { | 961 | if (!m_imap) { |
962 | return; | 962 | return; |
963 | } | 963 | } |
964 | att_list = mailimap_status_att_list_new_empty(); | 964 | att_list = mailimap_status_att_list_new_empty(); |
965 | if (!att_list) return; | 965 | if (!att_list) return; |
966 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); | 966 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); |
967 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); | 967 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); |
968 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); | 968 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); |
969 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); | 969 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); |
970 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { | 970 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { |
971 | for (cur = clist_begin(status->st_info_list); | 971 | for (cur = clist_begin(status->st_info_list); |
972 | cur != NULL ; cur = clist_next(cur)) { | 972 | cur != NULL ; cur = clist_next(cur)) { |
973 | mailimap_status_info * status_info; | 973 | mailimap_status_info * status_info; |
974 | status_info = (mailimap_status_info *)clist_content(cur); | 974 | status_info = (mailimap_status_info *)clist_content(cur); |
975 | switch (status_info->st_att) { | 975 | switch (status_info->st_att) { |
976 | case MAILIMAP_STATUS_ATT_MESSAGES: | 976 | case MAILIMAP_STATUS_ATT_MESSAGES: |
977 | target_stat.message_count = status_info->st_value; | 977 | target_stat.message_count = status_info->st_value; |
978 | break; | 978 | break; |
979 | case MAILIMAP_STATUS_ATT_RECENT: | 979 | case MAILIMAP_STATUS_ATT_RECENT: |
980 | target_stat.message_recent = status_info->st_value; | 980 | target_stat.message_recent = status_info->st_value; |
981 | break; | 981 | break; |
982 | case MAILIMAP_STATUS_ATT_UNSEEN: | 982 | case MAILIMAP_STATUS_ATT_UNSEEN: |
983 | target_stat.message_unseen = status_info->st_value; | 983 | target_stat.message_unseen = status_info->st_value; |
984 | break; | 984 | break; |
985 | } | 985 | } |
986 | } | 986 | } |
987 | } else { | 987 | } else { |
988 | qDebug("Error retrieving status"); | 988 | qDebug("Error retrieving status"); |
989 | } | 989 | } |
990 | if (status) mailimap_mailbox_data_status_free(status); | 990 | if (status) mailimap_mailbox_data_status_free(status); |
991 | if (att_list) mailimap_status_att_list_free(att_list); | 991 | if (att_list) mailimap_status_att_list_free(att_list); |
992 | } | 992 | } |
993 | 993 | ||
994 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 994 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
995 | { | 995 | { |
996 | login(); | 996 | login(); |
997 | if (!m_imap) return; | 997 | if (!m_imap) return; |
998 | if (!msg) return; | 998 | if (!msg) return; |
999 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); | 999 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); |
1000 | if (r != MAILIMAP_NO_ERROR) { | 1000 | if (r != MAILIMAP_NO_ERROR) { |
1001 | Global::statusMessage("Error storing mail!"); | 1001 | Global::statusMessage("Error storing mail!"); |
1002 | } | 1002 | } |
1003 | } | 1003 | } |
1004 | 1004 | ||
1005 | const QString&IMAPwrapper::getType()const | 1005 | const QString&IMAPwrapper::getType()const |
1006 | { | 1006 | { |
1007 | return account->getType(); | 1007 | return account->getType(); |
1008 | } | 1008 | } |
1009 | 1009 | ||
1010 | const QString&IMAPwrapper::getName()const | 1010 | const QString&IMAPwrapper::getName()const |
1011 | { | 1011 | { |
1012 | qDebug("Get name: %s",account->getAccountName().latin1()); | ||
1012 | return account->getAccountName(); | 1013 | return account->getAccountName(); |
1013 | } | 1014 | } |
1014 | 1015 | ||
1015 | encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) | 1016 | encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) |
1016 | { | 1017 | { |
1017 | // dummy | 1018 | // dummy |
1018 | QValueList<int> path; | 1019 | QValueList<int> path; |
1019 | return fetchRawPart(mail,path,false); | 1020 | return fetchRawPart(mail,path,false); |
1020 | } | 1021 | } |
1022 | |||
1023 | void IMAPwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | ||
1024 | { | ||
1025 | qDebug("mvcp mail imap"); | ||
1026 | if (targetWrapper != this) { | ||
1027 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); | ||
1028 | qDebug("Using generic"); | ||
1029 | return; | ||
1030 | } | ||
1031 | qDebug("Using internal"); | ||
1032 | mailimap_set *set = 0; | ||
1033 | |||
1034 | int err = mailimap_select( m_imap, fromFolder->getName().latin1()); | ||
1035 | if ( err != MAILIMAP_NO_ERROR ) { | ||
1036 | Global::statusMessage(tr("error selecting mailbox: %1").arg(m_imap->imap_response)); | ||
1037 | return; | ||
1038 | } | ||
1039 | |||
1040 | int last = m_imap->imap_selection_info->sel_exists; | ||
1041 | set = mailimap_set_new_interval( 1, last ); | ||
1042 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | ||
1043 | if ( err != MAILIMAP_NO_ERROR ) { | ||
1044 | Global::statusMessage(tr("error copy mails: %1").arg(m_imap->imap_response)); | ||
1045 | return; | ||
1046 | } | ||
1047 | mailimap_set_free( set ); | ||
1048 | if (moveit) { | ||
1049 | deleteAllMail(fromFolder); | ||
1050 | } | ||
1051 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index b2bd7e9..07c6210 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -1,73 +1,74 @@ | |||
1 | #ifndef __IMAPWRAPPER | 1 | #ifndef __IMAPWRAPPER |
2 | #define __IMAPWRAPPER | 2 | #define __IMAPWRAPPER |
3 | 3 | ||
4 | #include <qlist.h> | 4 | #include <qlist.h> |
5 | #include "mailwrapper.h" | 5 | #include "mailwrapper.h" |
6 | #include "abstractmail.h" | 6 | #include "abstractmail.h" |
7 | #include <libetpan/clist.h> | 7 | #include <libetpan/clist.h> |
8 | 8 | ||
9 | struct mailimap; | 9 | struct mailimap; |
10 | struct mailimap_body; | 10 | struct mailimap_body; |
11 | struct mailimap_body_type_1part; | 11 | struct mailimap_body_type_1part; |
12 | struct mailimap_body_type_text; | 12 | struct mailimap_body_type_text; |
13 | struct mailimap_body_type_basic; | 13 | struct mailimap_body_type_basic; |
14 | struct mailimap_body_type_msg; | 14 | struct mailimap_body_type_msg; |
15 | struct mailimap_body_type_mpart; | 15 | struct mailimap_body_type_mpart; |
16 | struct mailimap_body_fields; | 16 | struct mailimap_body_fields; |
17 | struct mailimap_msg_att; | 17 | struct mailimap_msg_att; |
18 | class encodedString; | 18 | class encodedString; |
19 | 19 | ||
20 | class IMAPwrapper : public AbstractMail | 20 | class IMAPwrapper : public AbstractMail |
21 | { | 21 | { |
22 | Q_OBJECT | 22 | Q_OBJECT |
23 | public: | 23 | public: |
24 | IMAPwrapper( IMAPaccount *a ); | 24 | IMAPwrapper( IMAPaccount *a ); |
25 | virtual ~IMAPwrapper(); | 25 | virtual ~IMAPwrapper(); |
26 | virtual QList<Folder>* listFolders(); | 26 | virtual QList<Folder>* listFolders(); |
27 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); | 27 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); |
28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
29 | 29 | ||
30 | virtual void deleteMail(const RecMail&mail); | 30 | virtual void deleteMail(const RecMail&mail); |
31 | virtual void answeredMail(const RecMail&mail); | 31 | virtual void answeredMail(const RecMail&mail); |
32 | virtual int deleteAllMail(const Folder*folder); | 32 | virtual int deleteAllMail(const Folder*folder); |
33 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 33 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
34 | virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | ||
34 | 35 | ||
35 | virtual RecBody fetchBody(const RecMail&mail); | 36 | virtual RecBody fetchBody(const RecMail&mail); |
36 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); | 37 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); |
37 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | 38 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); |
38 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | 39 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); |
39 | virtual encodedString* fetchRawBody(const RecMail&mail); | 40 | virtual encodedString* fetchRawBody(const RecMail&mail); |
40 | 41 | ||
41 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); | 42 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); |
42 | virtual int deleteMbox(const Folder*folder); | 43 | virtual int deleteMbox(const Folder*folder); |
43 | 44 | ||
44 | static void imap_progress( size_t current, size_t maximum ); | 45 | static void imap_progress( size_t current, size_t maximum ); |
45 | 46 | ||
46 | virtual void logout(); | 47 | virtual void logout(); |
47 | virtual const QString&getType()const; | 48 | virtual const QString&getType()const; |
48 | virtual const QString&getName()const; | 49 | virtual const QString&getName()const; |
49 | 50 | ||
50 | protected: | 51 | protected: |
51 | RecMail*parse_list_result(mailimap_msg_att*); | 52 | RecMail*parse_list_result(mailimap_msg_att*); |
52 | void login(); | 53 | void login(); |
53 | 54 | ||
54 | virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); | 55 | virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); |
55 | virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); | 56 | virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); |
56 | 57 | ||
57 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); | 58 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); |
58 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); | 59 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); |
59 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); | 60 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); |
60 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); | 61 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); |
61 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); | 62 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); |
62 | void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); | 63 | void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); |
63 | 64 | ||
64 | /* just helpers */ | 65 | /* just helpers */ |
65 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); | 66 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); |
66 | static QStringList address_list_to_stringlist(clist*list); | 67 | static QStringList address_list_to_stringlist(clist*list); |
67 | 68 | ||
68 | 69 | ||
69 | IMAPaccount *account; | 70 | IMAPaccount *account; |
70 | mailimap *m_imap; | 71 | mailimap *m_imap; |
71 | }; | 72 | }; |
72 | 73 | ||
73 | #endif | 74 | #endif |