-rw-r--r-- | noncore/net/mail/accountview.cpp | 33 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 74 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mboxwrapper.cpp | 13 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mboxwrapper.h | 3 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 11 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 3 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.cpp | 17 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/mail.pro | 9 | ||||
-rw-r--r-- | noncore/net/mail/selectstore.cpp | 19 | ||||
-rw-r--r-- | noncore/net/mail/selectstore.h | 19 | ||||
-rw-r--r-- | noncore/net/mail/selectstoreui.ui | 244 |
15 files changed, 400 insertions, 55 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 77fa706..faa6982 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -1,440 +1,465 @@ | |||
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 <qmessagebox.h> | 7 | #include <qmessagebox.h> |
7 | #include <qpopupmenu.h> | 8 | #include <qpopupmenu.h> |
8 | 9 | ||
9 | /** | 10 | /** |
10 | * POP3 Account stuff | 11 | * POP3 Account stuff |
11 | */ | 12 | */ |
12 | POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) | 13 | POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) |
13 | : AccountViewItem( parent ) | 14 | : AccountViewItem( parent ) |
14 | { | 15 | { |
15 | account = a; | 16 | account = a; |
16 | wrapper = AbstractMail::getWrapper( account ); | 17 | wrapper = AbstractMail::getWrapper( account ); |
17 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 18 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
18 | setText( 0, account->getAccountName() ); | 19 | setText( 0, account->getAccountName() ); |
19 | setOpen( true ); | 20 | setOpen( true ); |
20 | } | 21 | } |
21 | 22 | ||
22 | POP3viewItem::~POP3viewItem() | 23 | POP3viewItem::~POP3viewItem() |
23 | { | 24 | { |
24 | delete wrapper; | 25 | delete wrapper; |
25 | } | 26 | } |
26 | 27 | ||
27 | AbstractMail *POP3viewItem::getWrapper() | 28 | AbstractMail *POP3viewItem::getWrapper() |
28 | { | 29 | { |
29 | return wrapper; | 30 | return wrapper; |
30 | } | 31 | } |
31 | 32 | ||
32 | void POP3viewItem::refresh( QList<RecMail> & ) | 33 | void POP3viewItem::refresh( QList<RecMail> & ) |
33 | { | 34 | { |
34 | QList<Folder> *folders = wrapper->listFolders(); | 35 | QList<Folder> *folders = wrapper->listFolders(); |
35 | QListViewItem *child = firstChild(); | 36 | QListViewItem *child = firstChild(); |
36 | while ( child ) { | 37 | while ( child ) { |
37 | QListViewItem *tmp = child; | 38 | QListViewItem *tmp = child; |
38 | child = child->nextSibling(); | 39 | child = child->nextSibling(); |
39 | delete tmp; | 40 | delete tmp; |
40 | } | 41 | } |
41 | Folder *it; | 42 | Folder *it; |
42 | QListViewItem*item = 0; | 43 | QListViewItem*item = 0; |
43 | for ( it = folders->first(); it; it = folders->next() ) { | 44 | for ( it = folders->first(); it; it = folders->next() ) { |
44 | item = new POP3folderItem( it, this , item ); | 45 | item = new POP3folderItem( it, this , item ); |
45 | item->setSelectable(it->may_select()); | 46 | item->setSelectable(it->may_select()); |
46 | } | 47 | } |
47 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 48 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
48 | folders->setAutoDelete(false); | 49 | folders->setAutoDelete(false); |
49 | delete folders; | 50 | delete folders; |
50 | } | 51 | } |
51 | 52 | ||
52 | RecBody POP3viewItem::fetchBody( const RecMail &mail ) | 53 | RecBody POP3viewItem::fetchBody( const RecMail &mail ) |
53 | { | 54 | { |
54 | qDebug( "POP3 fetchBody" ); | 55 | qDebug( "POP3 fetchBody" ); |
55 | return wrapper->fetchBody( mail ); | 56 | return wrapper->fetchBody( mail ); |
56 | } | 57 | } |
57 | 58 | ||
58 | POP3folderItem::~POP3folderItem() | 59 | POP3folderItem::~POP3folderItem() |
59 | { | 60 | { |
60 | delete folder; | 61 | delete folder; |
61 | } | 62 | } |
62 | 63 | ||
63 | POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) | 64 | POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) |
64 | : AccountViewItem( parent,after ) | 65 | : AccountViewItem( parent,after ) |
65 | { | 66 | { |
66 | folder = folderInit; | 67 | folder = folderInit; |
67 | pop3 = parent; | 68 | pop3 = parent; |
68 | if (folder->getDisplayName().lower()!="inbox") { | 69 | if (folder->getDisplayName().lower()!="inbox") { |
69 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 70 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
70 | } else { | 71 | } else { |
71 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 72 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
72 | } | 73 | } |
73 | setText( 0, folder->getDisplayName() ); | 74 | setText( 0, folder->getDisplayName() ); |
74 | } | 75 | } |
75 | 76 | ||
76 | void POP3folderItem::refresh(QList<RecMail>&target) | 77 | void POP3folderItem::refresh(QList<RecMail>&target) |
77 | { | 78 | { |
78 | if (folder->may_select()) | 79 | if (folder->may_select()) |
79 | pop3->getWrapper()->listMessages( folder->getName(),target ); | 80 | pop3->getWrapper()->listMessages( folder->getName(),target ); |
80 | } | 81 | } |
81 | 82 | ||
82 | RecBody POP3folderItem::fetchBody(const RecMail&aMail) | 83 | RecBody POP3folderItem::fetchBody(const RecMail&aMail) |
83 | { | 84 | { |
84 | return pop3->getWrapper()->fetchBody(aMail); | 85 | return pop3->getWrapper()->fetchBody(aMail); |
85 | } | 86 | } |
86 | 87 | ||
87 | QPopupMenu * POP3folderItem::getContextMenu() | 88 | QPopupMenu * POP3folderItem::getContextMenu() |
88 | { | 89 | { |
89 | QPopupMenu *m = new QPopupMenu(0); | 90 | QPopupMenu *m = new QPopupMenu(0); |
90 | if (m) { | 91 | if (m) { |
91 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 92 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
92 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 93 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
94 | m->insertItem(QObject::tr("Download all mails",contextName),2); | ||
93 | } | 95 | } |
94 | return m; | 96 | return m; |
95 | } | 97 | } |
96 | 98 | ||
99 | void POP3folderItem::downloadMails() | ||
100 | { | ||
101 | Selectstore sels; | ||
102 | sels.showMaximized(); | ||
103 | sels.exec(); | ||
104 | } | ||
105 | |||
97 | void POP3folderItem::contextMenuSelected(int which) | 106 | void POP3folderItem::contextMenuSelected(int which) |
98 | { | 107 | { |
99 | AccountView * view = (AccountView*)listView(); | 108 | AccountView * view = (AccountView*)listView(); |
100 | switch (which) { | 109 | switch (which) { |
101 | case 0: | 110 | case 0: |
111 | /* must be 'cause pop3 lists are cached */ | ||
112 | pop3->getWrapper()->logout(); | ||
102 | view->refreshCurrent(); | 113 | view->refreshCurrent(); |
103 | break; | 114 | break; |
104 | case 1: | 115 | case 1: |
105 | deleteAllMail(pop3->getWrapper(),folder); | 116 | deleteAllMail(pop3->getWrapper(),folder); |
106 | break; | 117 | break; |
118 | case 2: | ||
119 | downloadMails(); | ||
120 | break; | ||
107 | default: | 121 | default: |
108 | break; | 122 | break; |
109 | } | 123 | } |
110 | } | 124 | } |
111 | 125 | ||
112 | /** | 126 | /** |
113 | * IMAP Account stuff | 127 | * IMAP Account stuff |
114 | */ | 128 | */ |
115 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) | 129 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) |
116 | : AccountViewItem( parent ) | 130 | : AccountViewItem( parent ) |
117 | { | 131 | { |
118 | account = a; | 132 | account = a; |
119 | wrapper = AbstractMail::getWrapper( account ); | 133 | wrapper = AbstractMail::getWrapper( account ); |
120 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 134 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
121 | setText( 0, account->getAccountName() ); | 135 | setText( 0, account->getAccountName() ); |
122 | setOpen( true ); | 136 | setOpen( true ); |
123 | } | 137 | } |
124 | 138 | ||
125 | IMAPviewItem::~IMAPviewItem() | 139 | IMAPviewItem::~IMAPviewItem() |
126 | { | 140 | { |
127 | delete wrapper; | 141 | delete wrapper; |
128 | } | 142 | } |
129 | 143 | ||
130 | AbstractMail *IMAPviewItem::getWrapper() | 144 | AbstractMail *IMAPviewItem::getWrapper() |
131 | { | 145 | { |
132 | return wrapper; | 146 | return wrapper; |
133 | } | 147 | } |
134 | 148 | ||
135 | IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start) | 149 | IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start) |
136 | { | 150 | { |
137 | IMAPfolderItem*pitem,*sitem; | 151 | IMAPfolderItem*pitem,*sitem; |
138 | if (!start) pitem = (IMAPfolderItem*)firstChild(); | 152 | if (!start) pitem = (IMAPfolderItem*)firstChild(); |
139 | else pitem = (IMAPfolderItem*)start->firstChild(); | 153 | else pitem = (IMAPfolderItem*)start->firstChild(); |
140 | while (pitem) { | 154 | while (pitem) { |
141 | if (pitem->matchName(path)) { | 155 | if (pitem->matchName(path)) { |
142 | break; | 156 | break; |
143 | } | 157 | } |
144 | if (pitem->childCount()>0) { | 158 | if (pitem->childCount()>0) { |
145 | sitem = findSubItem(path,pitem); | 159 | sitem = findSubItem(path,pitem); |
146 | if (sitem) { | 160 | if (sitem) { |
147 | pitem = sitem; | 161 | pitem = sitem; |
148 | break; | 162 | break; |
149 | } | 163 | } |
150 | } | 164 | } |
151 | pitem=(IMAPfolderItem*)pitem->nextSibling(); | 165 | pitem=(IMAPfolderItem*)pitem->nextSibling(); |
152 | } | 166 | } |
153 | return pitem; | 167 | return pitem; |
154 | } | 168 | } |
155 | 169 | ||
156 | void IMAPviewItem::refresh(QList<RecMail>&) | 170 | void IMAPviewItem::refresh(QList<RecMail>&) |
157 | { | 171 | { |
158 | refreshFolders(false); | 172 | refreshFolders(false); |
159 | } | 173 | } |
160 | 174 | ||
161 | void IMAPviewItem::refreshFolders(bool force) | 175 | void IMAPviewItem::removeChilds() |
162 | { | 176 | { |
163 | if (childCount()>0 && force==false) return; | ||
164 | QList<Folder> *folders = wrapper->listFolders(); | ||
165 | |||
166 | QListViewItem *child = firstChild(); | 177 | QListViewItem *child = firstChild(); |
167 | while ( child ) { | 178 | while ( child ) { |
168 | QListViewItem *tmp = child; | 179 | QListViewItem *tmp = child; |
169 | child = child->nextSibling(); | 180 | child = child->nextSibling(); |
170 | delete tmp; | 181 | delete tmp; |
171 | } | 182 | } |
172 | 183 | ||
184 | } | ||
185 | |||
186 | void IMAPviewItem::refreshFolders(bool force) | ||
187 | { | ||
188 | if (childCount()>0 && force==false) return; | ||
189 | |||
190 | removeChilds(); | ||
191 | |||
192 | QList<Folder> *folders = wrapper->listFolders(); | ||
193 | |||
173 | Folder *it; | 194 | Folder *it; |
174 | QListViewItem*item = 0; | 195 | QListViewItem*item = 0; |
175 | QListViewItem*titem = 0; | 196 | QListViewItem*titem = 0; |
176 | QString fname,del,search; | 197 | QString fname,del,search; |
177 | int pos; | 198 | int pos; |
178 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 199 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
179 | folders->setAutoDelete(false); | 200 | folders->setAutoDelete(false); |
180 | 201 | ||
181 | for ( it = folders->first(); it; it = folders->next() ) { | 202 | for ( it = folders->first(); it; it = folders->next() ) { |
182 | if (it->getDisplayName().lower()=="inbox") { | 203 | if (it->getDisplayName().lower()=="inbox") { |
183 | item = new IMAPfolderItem( it, this , item ); | 204 | item = new IMAPfolderItem( it, this , item ); |
184 | folders->remove(it); | 205 | folders->remove(it); |
185 | qDebug("inbox found"); | 206 | qDebug("inbox found"); |
186 | break; | 207 | break; |
187 | } | 208 | } |
188 | } | 209 | } |
189 | for ( it = folders->first(); it; it = folders->next() ) { | 210 | for ( it = folders->first(); it; it = folders->next() ) { |
190 | fname = it->getDisplayName(); | 211 | fname = it->getDisplayName(); |
191 | pos = fname.findRev(it->Separator()); | 212 | pos = fname.findRev(it->Separator()); |
192 | if (pos != -1) { | 213 | if (pos != -1) { |
193 | fname = fname.left(pos); | 214 | fname = fname.left(pos); |
194 | } | 215 | } |
195 | IMAPfolderItem*pitem = findSubItem(fname); | 216 | IMAPfolderItem*pitem = findSubItem(fname); |
196 | if (pitem) { | 217 | if (pitem) { |
197 | titem = item; | 218 | titem = item; |
198 | item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this); | 219 | item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this); |
199 | /* setup the short name */ | 220 | /* setup the short name */ |
200 | item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); | 221 | item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); |
201 | item = titem; | 222 | item = titem; |
202 | } else { | 223 | } else { |
203 | item = new IMAPfolderItem( it, this , item ); | 224 | item = new IMAPfolderItem( it, this , item ); |
204 | } | 225 | } |
205 | } | 226 | } |
206 | delete folders; | 227 | delete folders; |
207 | } | 228 | } |
208 | 229 | ||
209 | QPopupMenu * IMAPviewItem::getContextMenu() | 230 | QPopupMenu * IMAPviewItem::getContextMenu() |
210 | { | 231 | { |
211 | QPopupMenu *m = new QPopupMenu(0); | 232 | QPopupMenu *m = new QPopupMenu(0); |
212 | if (m) { | 233 | if (m) { |
213 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 234 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); |
214 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 235 | m->insertItem(QObject::tr("Create new folder",contextName),1); |
215 | m->insertSeparator(); | 236 | m->insertSeparator(); |
216 | m->insertItem(QObject::tr("Disconnect",contextName),2); | 237 | m->insertItem(QObject::tr("Disconnect",contextName),2); |
217 | } | 238 | } |
218 | return m; | 239 | return m; |
219 | } | 240 | } |
220 | 241 | ||
221 | void IMAPviewItem::createNewFolder() | 242 | void IMAPviewItem::createNewFolder() |
222 | { | 243 | { |
223 | Newmdirdlg ndirdlg; | 244 | Newmdirdlg ndirdlg; |
224 | ndirdlg.showMaximized(); | 245 | ndirdlg.showMaximized(); |
225 | if (ndirdlg.exec()) { | 246 | if (ndirdlg.exec()) { |
226 | QString ndir = ndirdlg.Newdir(); | 247 | QString ndir = ndirdlg.Newdir(); |
227 | bool makesubs = ndirdlg.subpossible(); | 248 | bool makesubs = ndirdlg.subpossible(); |
228 | QString delemiter = "/"; | 249 | QString delemiter = "/"; |
229 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); | 250 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); |
230 | if (item) { | 251 | if (item) { |
231 | delemiter = item->Delemiter(); | 252 | delemiter = item->Delemiter(); |
232 | } | 253 | } |
233 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) { | 254 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) { |
234 | refreshFolders(true); | 255 | refreshFolders(true); |
235 | } | 256 | } |
236 | } | 257 | } |
237 | } | 258 | } |
238 | 259 | ||
239 | void IMAPviewItem::contextMenuSelected(int id) | 260 | void IMAPviewItem::contextMenuSelected(int id) |
240 | { | 261 | { |
241 | qDebug("Id selected: %i",id); | 262 | qDebug("Id selected: %i",id); |
242 | switch (id) { | 263 | switch (id) { |
243 | case 0: | 264 | case 0: |
244 | refreshFolders(true); | 265 | refreshFolders(true); |
245 | break; | 266 | break; |
246 | case 1: | 267 | case 1: |
247 | createNewFolder(); | 268 | createNewFolder(); |
248 | break; | 269 | break; |
270 | case 2: | ||
271 | removeChilds(); | ||
272 | wrapper->logout(); | ||
273 | break; | ||
249 | default: | 274 | default: |
250 | break; | 275 | break; |
251 | } | 276 | } |
252 | } | 277 | } |
253 | 278 | ||
254 | RecBody IMAPviewItem::fetchBody(const RecMail&) | 279 | RecBody IMAPviewItem::fetchBody(const RecMail&) |
255 | { | 280 | { |
256 | return RecBody(); | 281 | return RecBody(); |
257 | } | 282 | } |
258 | 283 | ||
259 | IMAPfolderItem::~IMAPfolderItem() | 284 | IMAPfolderItem::~IMAPfolderItem() |
260 | { | 285 | { |
261 | delete folder; | 286 | delete folder; |
262 | } | 287 | } |
263 | 288 | ||
264 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) | 289 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) |
265 | : AccountViewItem( parent , after ) | 290 | : AccountViewItem( parent , after ) |
266 | { | 291 | { |
267 | folder = folderInit; | 292 | folder = folderInit; |
268 | imap = parent; | 293 | imap = parent; |
269 | if (folder->getDisplayName().lower()!="inbox") { | 294 | if (folder->getDisplayName().lower()!="inbox") { |
270 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 295 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
271 | } else { | 296 | } else { |
272 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 297 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
273 | } | 298 | } |
274 | setText( 0, folder->getDisplayName() ); | 299 | setText( 0, folder->getDisplayName() ); |
275 | } | 300 | } |
276 | 301 | ||
277 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) | 302 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) |
278 | : AccountViewItem( parent,after ) | 303 | : AccountViewItem( parent,after ) |
279 | { | 304 | { |
280 | folder = folderInit; | 305 | folder = folderInit; |
281 | imap = master; | 306 | imap = master; |
282 | if (folder->getDisplayName().lower()!="inbox") { | 307 | if (folder->getDisplayName().lower()!="inbox") { |
283 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 308 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
284 | } else { | 309 | } else { |
285 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 310 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
286 | } | 311 | } |
287 | setText( 0, folder->getDisplayName() ); | 312 | setText( 0, folder->getDisplayName() ); |
288 | } | 313 | } |
289 | 314 | ||
290 | const QString& IMAPfolderItem::Delemiter()const | 315 | const QString& IMAPfolderItem::Delemiter()const |
291 | { | 316 | { |
292 | return folder->Separator(); | 317 | return folder->Separator(); |
293 | } | 318 | } |
294 | 319 | ||
295 | bool IMAPfolderItem::matchName(const QString&name)const | 320 | bool IMAPfolderItem::matchName(const QString&name)const |
296 | { | 321 | { |
297 | return folder->getDisplayName()==name; | 322 | return folder->getDisplayName()==name; |
298 | } | 323 | } |
299 | 324 | ||
300 | void IMAPfolderItem::refresh(QList<RecMail>&target) | 325 | void IMAPfolderItem::refresh(QList<RecMail>&target) |
301 | { | 326 | { |
302 | if (folder->may_select()) { | 327 | if (folder->may_select()) { |
303 | imap->getWrapper()->listMessages( folder->getName(),target ); | 328 | imap->getWrapper()->listMessages( folder->getName(),target ); |
304 | } else { | 329 | } else { |
305 | target.clear(); | 330 | target.clear(); |
306 | } | 331 | } |
307 | } | 332 | } |
308 | 333 | ||
309 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) | 334 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) |
310 | { | 335 | { |
311 | return imap->getWrapper()->fetchBody(aMail); | 336 | return imap->getWrapper()->fetchBody(aMail); |
312 | } | 337 | } |
313 | 338 | ||
314 | QPopupMenu * IMAPfolderItem::getContextMenu() | 339 | QPopupMenu * IMAPfolderItem::getContextMenu() |
315 | { | 340 | { |
316 | QPopupMenu *m = new QPopupMenu(0); | 341 | QPopupMenu *m = new QPopupMenu(0); |
317 | if (m) { | 342 | if (m) { |
318 | if (folder->may_select()) { | 343 | if (folder->may_select()) { |
319 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 344 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
320 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 345 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
321 | } | 346 | } |
322 | if (folder->no_inferior()==false) { | 347 | if (folder->no_inferior()==false) { |
323 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); | 348 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); |
324 | } | 349 | } |
325 | if (folder->getDisplayName().lower()!="inbox") { | 350 | if (folder->getDisplayName().lower()!="inbox") { |
326 | m->insertItem(QObject::tr("Delete folder",contextName),3); | 351 | m->insertItem(QObject::tr("Delete folder",contextName),3); |
327 | } | 352 | } |
328 | } | 353 | } |
329 | return m; | 354 | return m; |
330 | } | 355 | } |
331 | 356 | ||
332 | void IMAPfolderItem::createNewFolder() | 357 | void IMAPfolderItem::createNewFolder() |
333 | { | 358 | { |
334 | Newmdirdlg ndirdlg; | 359 | Newmdirdlg ndirdlg; |
335 | ndirdlg.showMaximized(); | 360 | ndirdlg.showMaximized(); |
336 | if (ndirdlg.exec()) { | 361 | if (ndirdlg.exec()) { |
337 | QString ndir = ndirdlg.Newdir(); | 362 | QString ndir = ndirdlg.Newdir(); |
338 | bool makesubs = ndirdlg.subpossible(); | 363 | bool makesubs = ndirdlg.subpossible(); |
339 | QString delemiter = Delemiter(); | 364 | QString delemiter = Delemiter(); |
340 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) { | 365 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) { |
341 | imap->refreshFolders(true); | 366 | imap->refreshFolders(true); |
342 | } | 367 | } |
343 | } | 368 | } |
344 | } | 369 | } |
345 | 370 | ||
346 | void IMAPfolderItem::deleteFolder() | 371 | void IMAPfolderItem::deleteFolder() |
347 | { | 372 | { |
348 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | 373 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), |
349 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | 374 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), |
350 | QObject::tr("Yes",contextName), | 375 | QObject::tr("Yes",contextName), |
351 | QObject::tr("No",contextName),QString::null,1,1); | 376 | QObject::tr("No",contextName),QString::null,1,1); |
352 | qDebug("Auswahl: %i",yesno); | 377 | qDebug("Auswahl: %i",yesno); |
353 | if (yesno == 0) { | 378 | if (yesno == 0) { |
354 | if (imap->getWrapper()->deleteMbox(folder)) { | 379 | if (imap->getWrapper()->deleteMbox(folder)) { |
355 | QListView*v=listView(); | 380 | QListView*v=listView(); |
356 | IMAPviewItem * box = imap; | 381 | IMAPviewItem * box = imap; |
357 | /* be carefull - after that this object is destroyd so don't use | 382 | /* be carefull - after that this object is destroyd so don't use |
358 | * any member of it after that call!!*/ | 383 | * any member of it after that call!!*/ |
359 | imap->refreshFolders(true); | 384 | imap->refreshFolders(true); |
360 | if (v) { | 385 | if (v) { |
361 | v->setSelected(box,true); | 386 | v->setSelected(box,true); |
362 | } | 387 | } |
363 | } | 388 | } |
364 | } | 389 | } |
365 | } | 390 | } |
366 | 391 | ||
367 | void IMAPfolderItem::contextMenuSelected(int id) | 392 | void IMAPfolderItem::contextMenuSelected(int id) |
368 | { | 393 | { |
369 | qDebug("Selected id: %i",id); | 394 | qDebug("Selected id: %i",id); |
370 | AccountView * view = (AccountView*)listView(); | 395 | AccountView * view = (AccountView*)listView(); |
371 | switch(id) { | 396 | switch(id) { |
372 | case 0: | 397 | case 0: |
373 | view->refreshCurrent(); | 398 | view->refreshCurrent(); |
374 | break; | 399 | break; |
375 | case 1: | 400 | case 1: |
376 | deleteAllMail(imap->getWrapper(),folder); | 401 | deleteAllMail(imap->getWrapper(),folder); |
377 | break; | 402 | break; |
378 | case 2: | 403 | case 2: |
379 | createNewFolder(); | 404 | createNewFolder(); |
380 | break; | 405 | break; |
381 | case 3: | 406 | case 3: |
382 | deleteFolder(); | 407 | deleteFolder(); |
383 | break; | 408 | break; |
384 | default: | 409 | default: |
385 | break; | 410 | break; |
386 | } | 411 | } |
387 | } | 412 | } |
388 | 413 | ||
389 | /** | 414 | /** |
390 | * Generic stuff | 415 | * Generic stuff |
391 | */ | 416 | */ |
392 | 417 | ||
393 | const QString AccountViewItem::contextName="AccountViewItem"; | 418 | const QString AccountViewItem::contextName="AccountViewItem"; |
394 | 419 | ||
395 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder) | 420 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder) |
396 | { | 421 | { |
397 | if (!wrapper) return; | 422 | if (!wrapper) return; |
398 | QString fname=""; | 423 | QString fname=""; |
399 | if (folder) fname = folder->getDisplayName(); | 424 | if (folder) fname = folder->getDisplayName(); |
400 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), | 425 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), |
401 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). | 426 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). |
402 | arg(fname), | 427 | arg(fname), |
403 | QObject::tr("Yes",contextName), | 428 | QObject::tr("Yes",contextName), |
404 | QObject::tr("No",contextName),QString::null,1,1); | 429 | QObject::tr("No",contextName),QString::null,1,1); |
405 | qDebug("Auswahl: %i",yesno); | 430 | qDebug("Auswahl: %i",yesno); |
406 | if (yesno == 0) { | 431 | if (yesno == 0) { |
407 | if (wrapper->deleteAllMail(folder)) { | 432 | if (wrapper->deleteAllMail(folder)) { |
408 | AccountView * view = (AccountView*)listView(); | 433 | AccountView * view = (AccountView*)listView(); |
409 | if (view) view->refreshCurrent(); | 434 | if (view) view->refreshCurrent(); |
410 | } | 435 | } |
411 | } | 436 | } |
412 | } | 437 | } |
413 | 438 | ||
414 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 439 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
415 | : QListView( parent, name, flags ) | 440 | : QListView( parent, name, flags ) |
416 | { | 441 | { |
417 | connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), | 442 | connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), |
418 | SLOT( refresh( QListViewItem * ) ) ); | 443 | SLOT( refresh( QListViewItem * ) ) ); |
419 | connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, | 444 | connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, |
420 | SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); | 445 | SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); |
421 | 446 | ||
422 | setSorting(0); | 447 | setSorting(0); |
423 | } | 448 | } |
424 | 449 | ||
425 | void AccountView::slotContextMenu(int id) | 450 | void AccountView::slotContextMenu(int id) |
426 | { | 451 | { |
427 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 452 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
428 | if (!view) return; | 453 | if (!view) return; |
429 | view->contextMenuSelected(id); | 454 | view->contextMenuSelected(id); |
430 | } | 455 | } |
431 | 456 | ||
432 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) | 457 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) |
433 | { | 458 | { |
434 | if (button==1) {return;} | 459 | if (button==1) {return;} |
435 | if (!item) return; | 460 | if (!item) return; |
436 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 461 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
437 | QPopupMenu*m = view->getContextMenu(); | 462 | QPopupMenu*m = view->getContextMenu(); |
438 | if (!m) return; | 463 | if (!m) return; |
439 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); | 464 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); |
440 | m->setFocus(); | 465 | m->setFocus(); |
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index 1d2bf19..7131192 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h | |||
@@ -1,175 +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 | 15 | ||
16 | class AccountViewItem : public QListViewItem | 16 | class AccountViewItem : public QListViewItem |
17 | { | 17 | { |
18 | 18 | ||
19 | public: | 19 | public: |
20 | AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} | 20 | AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} |
21 | AccountViewItem( QListViewItem *parent) : QListViewItem( parent) {} | 21 | AccountViewItem( QListViewItem *parent) : QListViewItem( parent) {} |
22 | AccountViewItem( QListViewItem *parent , QListViewItem*after ) : QListViewItem( parent,after ) {} | 22 | AccountViewItem( QListViewItem *parent , QListViewItem*after ) : QListViewItem( parent,after ) {} |
23 | virtual void refresh(QList<RecMail>&)=0; | 23 | virtual void refresh(QList<RecMail>&)=0; |
24 | virtual RecBody fetchBody(const RecMail&)=0; | 24 | virtual RecBody fetchBody(const RecMail&)=0; |
25 | virtual QPopupMenu * getContextMenu(){return 0;}; | 25 | virtual QPopupMenu * getContextMenu(){return 0;}; |
26 | virtual void contextMenuSelected(int){} | 26 | virtual void contextMenuSelected(int){} |
27 | protected: | 27 | protected: |
28 | virtual void deleteAllMail(AbstractMail*wrapper,Folder*f); | 28 | virtual void deleteAllMail(AbstractMail*wrapper,Folder*f); |
29 | static const QString contextName; | 29 | static const QString contextName; |
30 | }; | 30 | }; |
31 | 31 | ||
32 | class POP3viewItem : public AccountViewItem | 32 | class POP3viewItem : public AccountViewItem |
33 | { | 33 | { |
34 | 34 | ||
35 | public: | 35 | public: |
36 | POP3viewItem( POP3account *a, QListView *parent ); | 36 | POP3viewItem( POP3account *a, QListView *parent ); |
37 | ~POP3viewItem(); | 37 | ~POP3viewItem(); |
38 | virtual void refresh( QList<RecMail> &target ); | 38 | virtual void refresh( QList<RecMail> &target ); |
39 | virtual RecBody fetchBody( const RecMail &mail ); | 39 | virtual RecBody fetchBody( const RecMail &mail ); |
40 | AbstractMail *getWrapper(); | 40 | AbstractMail *getWrapper(); |
41 | private: | 41 | private: |
42 | POP3account *account; | 42 | POP3account *account; |
43 | AbstractMail *wrapper; | 43 | AbstractMail *wrapper; |
44 | 44 | ||
45 | }; | 45 | }; |
46 | 46 | ||
47 | class POP3folderItem : public AccountViewItem | 47 | class POP3folderItem : public AccountViewItem |
48 | { | 48 | { |
49 | 49 | ||
50 | public: | 50 | public: |
51 | POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); | 51 | POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); |
52 | ~POP3folderItem(); | 52 | ~POP3folderItem(); |
53 | virtual void refresh(QList<RecMail>&); | 53 | virtual void refresh(QList<RecMail>&); |
54 | virtual RecBody fetchBody(const RecMail&); | 54 | virtual RecBody fetchBody(const RecMail&); |
55 | virtual QPopupMenu * getContextMenu(); | 55 | virtual QPopupMenu * getContextMenu(); |
56 | virtual void contextMenuSelected(int); | 56 | virtual void contextMenuSelected(int); |
57 | 57 | ||
58 | protected: | ||
59 | void downloadMails(); | ||
60 | |||
58 | private: | 61 | private: |
59 | Folder *folder; | 62 | Folder *folder; |
60 | POP3viewItem *pop3; | 63 | POP3viewItem *pop3; |
61 | }; | 64 | }; |
62 | 65 | ||
63 | class IMAPfolderItem; | 66 | class IMAPfolderItem; |
64 | 67 | ||
65 | class IMAPviewItem : public AccountViewItem | 68 | class IMAPviewItem : public AccountViewItem |
66 | { | 69 | { |
67 | friend class IMAPfolderItem; | 70 | friend class IMAPfolderItem; |
68 | public: | 71 | public: |
69 | IMAPviewItem( IMAPaccount *a, QListView *parent ); | 72 | IMAPviewItem( IMAPaccount *a, QListView *parent ); |
70 | ~IMAPviewItem(); | 73 | ~IMAPviewItem(); |
71 | virtual void refresh(QList<RecMail>&); | 74 | virtual void refresh(QList<RecMail>&); |
72 | virtual RecBody fetchBody(const RecMail&); | 75 | virtual RecBody fetchBody(const RecMail&); |
73 | AbstractMail *getWrapper(); | 76 | AbstractMail *getWrapper(); |
74 | virtual QPopupMenu * getContextMenu(); | 77 | virtual QPopupMenu * getContextMenu(); |
75 | virtual void contextMenuSelected(int); | 78 | virtual void contextMenuSelected(int); |
76 | 79 | ||
77 | protected: | 80 | protected: |
78 | IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0); | 81 | IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0); |
79 | virtual void refreshFolders(bool force=false); | 82 | virtual void refreshFolders(bool force=false); |
80 | virtual void createNewFolder(); | 83 | virtual void createNewFolder(); |
84 | virtual void removeChilds(); | ||
81 | 85 | ||
82 | private: | 86 | private: |
83 | IMAPaccount *account; | 87 | IMAPaccount *account; |
84 | AbstractMail *wrapper; | 88 | AbstractMail *wrapper; |
85 | }; | 89 | }; |
86 | 90 | ||
87 | class IMAPfolderItem : public AccountViewItem | 91 | class IMAPfolderItem : public AccountViewItem |
88 | { | 92 | { |
89 | 93 | ||
90 | public: | 94 | public: |
91 | IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); | 95 | IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); |
92 | IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); | 96 | IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); |
93 | ~IMAPfolderItem(); | 97 | ~IMAPfolderItem(); |
94 | virtual void refresh(QList<RecMail>&); | 98 | virtual void refresh(QList<RecMail>&); |
95 | virtual RecBody fetchBody(const RecMail&); | 99 | virtual RecBody fetchBody(const RecMail&); |
96 | bool matchName(const QString&name)const; | 100 | bool matchName(const QString&name)const; |
97 | virtual QPopupMenu * getContextMenu(); | 101 | virtual QPopupMenu * getContextMenu(); |
98 | virtual void contextMenuSelected(int); | 102 | virtual void contextMenuSelected(int); |
99 | virtual const QString& Delemiter()const; | 103 | virtual const QString& Delemiter()const; |
100 | protected: | 104 | protected: |
101 | virtual void createNewFolder(); | 105 | virtual void createNewFolder(); |
102 | virtual void deleteFolder(); | 106 | virtual void deleteFolder(); |
103 | 107 | ||
104 | private: | 108 | private: |
105 | Folder *folder; | 109 | Folder *folder; |
106 | IMAPviewItem *imap; | 110 | IMAPviewItem *imap; |
107 | }; | 111 | }; |
108 | 112 | ||
109 | class MBOXviewItem : public AccountViewItem | 113 | class MBOXviewItem : public AccountViewItem |
110 | { | 114 | { |
111 | friend class MBOXfolderItem; | 115 | friend class MBOXfolderItem; |
112 | 116 | ||
113 | public: | 117 | public: |
114 | // MBOXviewItem( MBOXaccount *a, QListView *parent ); | 118 | // MBOXviewItem( MBOXaccount *a, QListView *parent ); |
115 | MBOXviewItem( const QString&aMboxPath, QListView *parent ); | 119 | MBOXviewItem( const QString&aMboxPath, QListView *parent ); |
116 | ~MBOXviewItem(); | 120 | ~MBOXviewItem(); |
117 | virtual void refresh( QList<RecMail> &target ); | 121 | virtual void refresh( QList<RecMail> &target ); |
118 | virtual RecBody fetchBody( const RecMail &mail ); | 122 | virtual RecBody fetchBody( const RecMail &mail ); |
119 | AbstractMail *getWrapper(); | 123 | AbstractMail *getWrapper(); |
120 | virtual QPopupMenu * getContextMenu(); | 124 | virtual QPopupMenu * getContextMenu(); |
121 | virtual void contextMenuSelected(int); | 125 | virtual void contextMenuSelected(int); |
122 | 126 | ||
123 | protected: | 127 | protected: |
124 | virtual void refresh(bool force=false); | 128 | virtual void refresh(bool force=false); |
125 | virtual void createFolder(); | 129 | virtual void createFolder(); |
126 | 130 | ||
127 | private: | 131 | private: |
128 | // MBOXaccount *account; | 132 | // MBOXaccount *account; |
129 | QString m_Path; | 133 | QString m_Path; |
130 | AbstractMail *wrapper; | 134 | AbstractMail *wrapper; |
131 | 135 | ||
132 | }; | 136 | }; |
133 | 137 | ||
134 | class MBOXfolderItem : public AccountViewItem | 138 | class MBOXfolderItem : public AccountViewItem |
135 | { | 139 | { |
136 | 140 | ||
137 | public: | 141 | public: |
138 | MBOXfolderItem( Folder *folder, MBOXviewItem *parent , QListViewItem*after ); | 142 | MBOXfolderItem( Folder *folder, MBOXviewItem *parent , QListViewItem*after ); |
139 | ~MBOXfolderItem(); | 143 | ~MBOXfolderItem(); |
140 | virtual void refresh(QList<RecMail>&); | 144 | virtual void refresh(QList<RecMail>&); |
141 | virtual RecBody fetchBody(const RecMail&); | 145 | virtual RecBody fetchBody(const RecMail&); |
142 | virtual QPopupMenu * getContextMenu(); | 146 | virtual QPopupMenu * getContextMenu(); |
143 | virtual void contextMenuSelected(int); | 147 | virtual void contextMenuSelected(int); |
144 | 148 | ||
145 | protected: | 149 | protected: |
146 | virtual void deleteFolder(); | 150 | virtual void deleteFolder(); |
147 | private: | 151 | private: |
148 | Folder *folder; | 152 | Folder *folder; |
149 | MBOXviewItem *mbox; | 153 | MBOXviewItem *mbox; |
150 | }; | 154 | }; |
151 | 155 | ||
152 | class AccountView : public QListView | 156 | class AccountView : public QListView |
153 | { | 157 | { |
154 | Q_OBJECT | 158 | Q_OBJECT |
155 | 159 | ||
156 | public: | 160 | public: |
157 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); | 161 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); |
158 | void populate( QList<Account> list ); | 162 | void populate( QList<Account> list ); |
159 | RecBody fetchBody(const RecMail&aMail); | 163 | RecBody fetchBody(const RecMail&aMail); |
160 | 164 | ||
161 | public slots: | 165 | public slots: |
162 | virtual void refreshAll(); | 166 | virtual void refreshAll(); |
163 | virtual void refresh(QListViewItem *item); | 167 | virtual void refresh(QListViewItem *item); |
164 | virtual void refreshCurrent(); | 168 | virtual void refreshCurrent(); |
165 | virtual void slotHold(int, QListViewItem *,const QPoint&,int); | 169 | virtual void slotHold(int, QListViewItem *,const QPoint&,int); |
166 | virtual void slotContextMenu(int id); | 170 | virtual void slotContextMenu(int id); |
167 | 171 | ||
168 | signals: | 172 | signals: |
169 | void refreshMailview(QList<RecMail>*); | 173 | void refreshMailview(QList<RecMail>*); |
170 | 174 | ||
171 | private: | 175 | private: |
172 | QListViewItem* m_currentItem; | 176 | QListViewItem* m_currentItem; |
173 | }; | 177 | }; |
174 | 178 | ||
175 | #endif | 179 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h index 7c060db..9770991 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.h +++ b/noncore/net/mail/libmailwrapper/abstractmail.h | |||
@@ -1,59 +1,60 @@ | |||
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 | 30 | ||
30 | virtual void deleteMail(const RecMail&mail)=0; | 31 | virtual void deleteMail(const RecMail&mail)=0; |
31 | virtual void answeredMail(const RecMail&mail)=0; | 32 | virtual void answeredMail(const RecMail&mail)=0; |
32 | virtual int deleteAllMail(const Folder*)=0; | 33 | virtual int deleteAllMail(const Folder*)=0; |
33 | virtual int deleteMbox(const Folder*)=0; | 34 | virtual int deleteMbox(const Folder*)=0; |
34 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; | 35 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; |
35 | 36 | ||
36 | virtual void cleanMimeCache(){}; | 37 | virtual void cleanMimeCache(){}; |
37 | /* mail box methods */ | 38 | /* mail box methods */ |
38 | /* parameter is the box to create. | 39 | /* parameter is the box to create. |
39 | * if the implementing subclass has prefixes, | 40 | * if the implementing subclass has prefixes, |
40 | * them has to be appended automatic. | 41 | * them has to be appended automatic. |
41 | */ | 42 | */ |
42 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); | 43 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); |
43 | virtual void logout()=0; | 44 | virtual void logout()=0; |
44 | 45 | ||
45 | static AbstractMail* getWrapper(IMAPaccount *a); | 46 | static AbstractMail* getWrapper(IMAPaccount *a); |
46 | static AbstractMail* getWrapper(POP3account *a); | 47 | static AbstractMail* getWrapper(POP3account *a); |
47 | /* mbox only! */ | 48 | /* mbox only! */ |
48 | static AbstractMail* getWrapper(const QString&a); | 49 | static AbstractMail* getWrapper(const QString&a); |
49 | 50 | ||
50 | static QString defaultLocalfolder(); | 51 | static QString defaultLocalfolder(); |
51 | 52 | ||
52 | virtual const QString&getType()const=0; | 53 | virtual const QString&getType()const=0; |
53 | 54 | ||
54 | protected: | 55 | protected: |
55 | static encodedString*decode_String(const encodedString*text,const QString&enc); | 56 | static encodedString*decode_String(const encodedString*text,const QString&enc); |
56 | static QString convert_String(const char*text); | 57 | static QString convert_String(const char*text); |
57 | static QString gen_attachment_id(); | 58 | static QString gen_attachment_id(); |
58 | }; | 59 | }; |
59 | #endif | 60 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 95b317a..d252159 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -277,409 +277,420 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
277 | m = new RecMail(); | 277 | m = new RecMail(); |
278 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 278 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
279 | current = c; | 279 | current = c; |
280 | size = 0; | 280 | size = 0; |
281 | item = (mailimap_msg_att_item*)current->data; | 281 | item = (mailimap_msg_att_item*)current->data; |
282 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 282 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
283 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 283 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
284 | if (!flist->att_list) { | 284 | if (!flist->att_list) { |
285 | continue; | 285 | continue; |
286 | } | 286 | } |
287 | cf = flist->att_list->first; | 287 | cf = flist->att_list->first; |
288 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 288 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
289 | cflag = (mailimap_flag_fetch*)cf->data; | 289 | cflag = (mailimap_flag_fetch*)cf->data; |
290 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 290 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
291 | switch (cflag->fl_flag->fl_type) { | 291 | switch (cflag->fl_flag->fl_type) { |
292 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 292 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
293 | mFlags.setBit(FLAG_ANSWERED); | 293 | mFlags.setBit(FLAG_ANSWERED); |
294 | break; | 294 | break; |
295 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 295 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
296 | mFlags.setBit(FLAG_FLAGGED); | 296 | mFlags.setBit(FLAG_FLAGGED); |
297 | break; | 297 | break; |
298 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 298 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
299 | mFlags.setBit(FLAG_DELETED); | 299 | mFlags.setBit(FLAG_DELETED); |
300 | break; | 300 | break; |
301 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 301 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
302 | mFlags.setBit(FLAG_SEEN); | 302 | mFlags.setBit(FLAG_SEEN); |
303 | break; | 303 | break; |
304 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 304 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
305 | mFlags.setBit(FLAG_DRAFT); | 305 | mFlags.setBit(FLAG_DRAFT); |
306 | break; | 306 | break; |
307 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 307 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
308 | break; | 308 | break; |
309 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 309 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
310 | break; | 310 | break; |
311 | default: | 311 | default: |
312 | break; | 312 | break; |
313 | } | 313 | } |
314 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 314 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
315 | mFlags.setBit(FLAG_RECENT); | 315 | mFlags.setBit(FLAG_RECENT); |
316 | } | 316 | } |
317 | } | 317 | } |
318 | continue; | 318 | continue; |
319 | } | 319 | } |
320 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 320 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
321 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 321 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
322 | m->setDate(head->env_date); | 322 | m->setDate(head->env_date); |
323 | m->setSubject(convert_String((const char*)head->env_subject)); | 323 | m->setSubject(convert_String((const char*)head->env_subject)); |
324 | //m->setSubject(head->env_subject); | 324 | //m->setSubject(head->env_subject); |
325 | if (head->env_from!=NULL) { | 325 | if (head->env_from!=NULL) { |
326 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 326 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
327 | if (addresslist.count()) { | 327 | if (addresslist.count()) { |
328 | m->setFrom(addresslist.first()); | 328 | m->setFrom(addresslist.first()); |
329 | } | 329 | } |
330 | } | 330 | } |
331 | if (head->env_to!=NULL) { | 331 | if (head->env_to!=NULL) { |
332 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 332 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
333 | m->setTo(addresslist); | 333 | m->setTo(addresslist); |
334 | } | 334 | } |
335 | if (head->env_cc!=NULL) { | 335 | if (head->env_cc!=NULL) { |
336 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 336 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
337 | m->setCC(addresslist); | 337 | m->setCC(addresslist); |
338 | } | 338 | } |
339 | if (head->env_bcc!=NULL) { | 339 | if (head->env_bcc!=NULL) { |
340 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 340 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
341 | m->setBcc(addresslist); | 341 | m->setBcc(addresslist); |
342 | } | 342 | } |
343 | if (head->env_reply_to!=NULL) { | 343 | if (head->env_reply_to!=NULL) { |
344 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 344 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
345 | if (addresslist.count()) { | 345 | if (addresslist.count()) { |
346 | m->setReplyto(addresslist.first()); | 346 | m->setReplyto(addresslist.first()); |
347 | } | 347 | } |
348 | } | 348 | } |
349 | m->setMsgid(QString(head->env_message_id)); | 349 | m->setMsgid(QString(head->env_message_id)); |
350 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 350 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
351 | #if 0 | 351 | #if 0 |
352 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 352 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
353 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 353 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
354 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); | 354 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); |
355 | qDebug(da.toString()); | 355 | qDebug(da.toString()); |
356 | #endif | 356 | #endif |
357 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 357 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
358 | size = item->att_data.att_static->att_data.att_rfc822_size; | 358 | size = item->att_data.att_static->att_data.att_rfc822_size; |
359 | } | 359 | } |
360 | } | 360 | } |
361 | /* msg is already deleted */ | 361 | /* msg is already deleted */ |
362 | if (mFlags.testBit(FLAG_DELETED) && m) { | 362 | if (mFlags.testBit(FLAG_DELETED) && m) { |
363 | delete m; | 363 | delete m; |
364 | m = 0; | 364 | m = 0; |
365 | } | 365 | } |
366 | if (m) { | 366 | if (m) { |
367 | m->setFlags(mFlags); | 367 | m->setFlags(mFlags); |
368 | m->setMsgsize(size); | 368 | m->setMsgsize(size); |
369 | } | 369 | } |
370 | return m; | 370 | return m; |
371 | } | 371 | } |
372 | 372 | ||
373 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) | 373 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) |
374 | { | 374 | { |
375 | RecBody body; | 375 | RecBody body; |
376 | const char *mb; | 376 | const char *mb; |
377 | int err = MAILIMAP_NO_ERROR; | 377 | int err = MAILIMAP_NO_ERROR; |
378 | clist *result = 0; | 378 | clist *result = 0; |
379 | clistcell *current; | 379 | clistcell *current; |
380 | mailimap_fetch_att *fetchAtt = 0; | 380 | mailimap_fetch_att *fetchAtt = 0; |
381 | mailimap_fetch_type *fetchType = 0; | 381 | mailimap_fetch_type *fetchType = 0; |
382 | mailimap_set *set = 0; | 382 | mailimap_set *set = 0; |
383 | mailimap_body*body_desc = 0; | 383 | mailimap_body*body_desc = 0; |
384 | 384 | ||
385 | mb = mail.getMbox().latin1(); | 385 | mb = mail.getMbox().latin1(); |
386 | 386 | ||
387 | login(); | 387 | login(); |
388 | if (!m_imap) { | 388 | if (!m_imap) { |
389 | return body; | 389 | return body; |
390 | } | 390 | } |
391 | 391 | ||
392 | err = mailimap_select( m_imap, (char*)mb); | 392 | err = mailimap_select( m_imap, (char*)mb); |
393 | if ( err != MAILIMAP_NO_ERROR ) { | 393 | if ( err != MAILIMAP_NO_ERROR ) { |
394 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 394 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
395 | return body; | 395 | return body; |
396 | } | 396 | } |
397 | 397 | ||
398 | /* the range has to start at 1!!! not with 0!!!! */ | 398 | /* the range has to start at 1!!! not with 0!!!! */ |
399 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); | 399 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); |
400 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 400 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
401 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 401 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
402 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 402 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
403 | mailimap_set_free( set ); | 403 | mailimap_set_free( set ); |
404 | mailimap_fetch_type_free( fetchType ); | 404 | mailimap_fetch_type_free( fetchType ); |
405 | 405 | ||
406 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 406 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
407 | mailimap_msg_att * msg_att; | 407 | mailimap_msg_att * msg_att; |
408 | msg_att = (mailimap_msg_att*)current->data; | 408 | msg_att = (mailimap_msg_att*)current->data; |
409 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 409 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
410 | QValueList<int> path; | 410 | QValueList<int> path; |
411 | body_desc = item->att_data.att_static->att_data.att_body; | 411 | body_desc = item->att_data.att_static->att_data.att_body; |
412 | traverseBody(mail,body_desc,body,0,path); | 412 | traverseBody(mail,body_desc,body,0,path); |
413 | } else { | 413 | } else { |
414 | qDebug("error fetching body: %s",m_imap->imap_response); | 414 | qDebug("error fetching body: %s",m_imap->imap_response); |
415 | } | 415 | } |
416 | if (result) mailimap_fetch_list_free(result); | 416 | if (result) mailimap_fetch_list_free(result); |
417 | return body; | 417 | return body; |
418 | } | 418 | } |
419 | 419 | ||
420 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 420 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
421 | { | 421 | { |
422 | QStringList l; | 422 | QStringList l; |
423 | QString from; | 423 | QString from; |
424 | bool named_from; | 424 | bool named_from; |
425 | clistcell *current = NULL; | 425 | clistcell *current = NULL; |
426 | mailimap_address * current_address=NULL; | 426 | mailimap_address * current_address=NULL; |
427 | if (!list) { | 427 | if (!list) { |
428 | return l; | 428 | return l; |
429 | } | 429 | } |
430 | unsigned int count = 0; | 430 | unsigned int count = 0; |
431 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { | 431 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { |
432 | from = ""; | 432 | from = ""; |
433 | named_from = false; | 433 | named_from = false; |
434 | current_address=(mailimap_address*)current->data; | 434 | current_address=(mailimap_address*)current->data; |
435 | if (current_address->ad_personal_name){ | 435 | if (current_address->ad_personal_name){ |
436 | from+=convert_String((const char*)current_address->ad_personal_name); | 436 | from+=convert_String((const char*)current_address->ad_personal_name); |
437 | from+=" "; | 437 | from+=" "; |
438 | named_from = true; | 438 | named_from = true; |
439 | } | 439 | } |
440 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 440 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
441 | from+="<"; | 441 | from+="<"; |
442 | } | 442 | } |
443 | if (current_address->ad_mailbox_name) { | 443 | if (current_address->ad_mailbox_name) { |
444 | from+=QString(current_address->ad_mailbox_name); | 444 | from+=QString(current_address->ad_mailbox_name); |
445 | from+="@"; | 445 | from+="@"; |
446 | } | 446 | } |
447 | if (current_address->ad_host_name) { | 447 | if (current_address->ad_host_name) { |
448 | from+=QString(current_address->ad_host_name); | 448 | from+=QString(current_address->ad_host_name); |
449 | } | 449 | } |
450 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 450 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
451 | from+=">"; | 451 | from+=">"; |
452 | } | 452 | } |
453 | l.append(QString(from)); | 453 | l.append(QString(from)); |
454 | if (++count > 99) { | 454 | if (++count > 99) { |
455 | break; | 455 | break; |
456 | } | 456 | } |
457 | } | 457 | } |
458 | return l; | 458 | return l; |
459 | } | 459 | } |
460 | 460 | ||
461 | encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) | 461 | encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) |
462 | { | 462 | { |
463 | encodedString*res=new encodedString; | 463 | encodedString*res=new encodedString; |
464 | const char*mb; | 464 | const char*mb; |
465 | int err; | 465 | int err; |
466 | mailimap_fetch_type *fetchType; | 466 | mailimap_fetch_type *fetchType; |
467 | mailimap_set *set; | 467 | mailimap_set *set; |
468 | clistcell*current,*cur; | 468 | clistcell*current,*cur; |
469 | mailimap_section_part * section_part = 0; | ||
470 | mailimap_section_spec * section_spec = 0; | ||
471 | mailimap_section * section = 0; | ||
472 | mailimap_fetch_att * fetch_att = 0; | ||
469 | 473 | ||
470 | login(); | 474 | login(); |
471 | if (!m_imap) { | 475 | if (!m_imap) { |
472 | return res; | 476 | return res; |
473 | } | 477 | } |
474 | if (!internal_call) { | 478 | if (!internal_call) { |
475 | mb = mail.getMbox().latin1(); | 479 | mb = mail.getMbox().latin1(); |
476 | err = mailimap_select( m_imap, (char*)mb); | 480 | err = mailimap_select( m_imap, (char*)mb); |
477 | if ( err != MAILIMAP_NO_ERROR ) { | 481 | if ( err != MAILIMAP_NO_ERROR ) { |
478 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 482 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
479 | return res; | 483 | return res; |
480 | } | 484 | } |
481 | } | 485 | } |
482 | set = mailimap_set_new_single(mail.getNumber()); | 486 | set = mailimap_set_new_single(mail.getNumber()); |
483 | clist*id_list=clist_new(); | ||
484 | for (unsigned j=0; j < path.count();++j) { | ||
485 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); | ||
486 | *p_id = path[j]; | ||
487 | clist_append(id_list,p_id); | ||
488 | } | ||
489 | mailimap_section_part * section_part = mailimap_section_part_new(id_list); | ||
490 | mailimap_section_spec * section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); | ||
491 | mailimap_section * section = mailimap_section_new(section_spec); | ||
492 | mailimap_fetch_att * fetch_att = mailimap_fetch_att_new_body_section(section); | ||
493 | 487 | ||
488 | clist*id_list = 0; | ||
489 | |||
490 | /* if path == empty then its a request for the whole rfc822 mail and generates | ||
491 | a "fetch <id> (body[])" statement on imap server */ | ||
492 | if (path.count()>0 ) { | ||
493 | id_list = clist_new(); | ||
494 | for (unsigned j=0; j < path.count();++j) { | ||
495 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); | ||
496 | *p_id = path[j]; | ||
497 | clist_append(id_list,p_id); | ||
498 | } | ||
499 | section_part = mailimap_section_part_new(id_list); | ||
500 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); | ||
501 | } | ||
502 | |||
503 | section = mailimap_section_new(section_spec); | ||
504 | fetch_att = mailimap_fetch_att_new_body_section(section); | ||
494 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); | 505 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); |
495 | 506 | ||
496 | clist*result = 0; | 507 | clist*result = 0; |
497 | 508 | ||
498 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 509 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
499 | mailimap_set_free( set ); | 510 | mailimap_set_free( set ); |
500 | mailimap_fetch_type_free( fetchType ); | 511 | mailimap_fetch_type_free( fetchType ); |
501 | 512 | ||
502 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 513 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
503 | mailimap_msg_att * msg_att; | 514 | mailimap_msg_att * msg_att; |
504 | msg_att = (mailimap_msg_att*)current->data; | 515 | msg_att = (mailimap_msg_att*)current->data; |
505 | mailimap_msg_att_item*msg_att_item; | 516 | mailimap_msg_att_item*msg_att_item; |
506 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | 517 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { |
507 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | 518 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); |
508 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | 519 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { |
509 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 520 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
510 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 521 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
511 | /* detach - we take over the content */ | 522 | /* detach - we take over the content */ |
512 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 523 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
513 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); | 524 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); |
514 | } | 525 | } |
515 | } | 526 | } |
516 | } | 527 | } |
517 | } else { | 528 | } else { |
518 | qDebug("error fetching text: %s",m_imap->imap_response); | 529 | qDebug("error fetching text: %s",m_imap->imap_response); |
519 | } | 530 | } |
520 | if (result) mailimap_fetch_list_free(result); | 531 | if (result) mailimap_fetch_list_free(result); |
521 | return res; | 532 | return res; |
522 | } | 533 | } |
523 | 534 | ||
524 | /* current_recursion is for recursive calls. | 535 | /* current_recursion is for recursive calls. |
525 | current_count means the position inside the internal loop! */ | 536 | current_count means the position inside the internal loop! */ |
526 | void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body, | 537 | void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body, |
527 | int current_recursion,QValueList<int>recList,int current_count) | 538 | int current_recursion,QValueList<int>recList,int current_count) |
528 | { | 539 | { |
529 | if (!body || current_recursion>=10) { | 540 | if (!body || current_recursion>=10) { |
530 | return; | 541 | return; |
531 | } | 542 | } |
532 | switch (body->bd_type) { | 543 | switch (body->bd_type) { |
533 | case MAILIMAP_BODY_1PART: | 544 | case MAILIMAP_BODY_1PART: |
534 | { | 545 | { |
535 | QValueList<int>countlist = recList; | 546 | QValueList<int>countlist = recList; |
536 | countlist.append(current_count); | 547 | countlist.append(current_count); |
537 | RecPart currentPart; | 548 | RecPart currentPart; |
538 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; | 549 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; |
539 | QString id(""); | 550 | QString id(""); |
540 | currentPart.setPositionlist(countlist); | 551 | currentPart.setPositionlist(countlist); |
541 | for (unsigned int j = 0; j < countlist.count();++j) { | 552 | for (unsigned int j = 0; j < countlist.count();++j) { |
542 | id+=(j>0?" ":""); | 553 | id+=(j>0?" ":""); |
543 | id+=QString("%1").arg(countlist[j]); | 554 | id+=QString("%1").arg(countlist[j]); |
544 | } | 555 | } |
545 | qDebug("ID = %s",id.latin1()); | 556 | qDebug("ID = %s",id.latin1()); |
546 | currentPart.setIdentifier(id); | 557 | currentPart.setIdentifier(id); |
547 | fillSinglePart(currentPart,part1); | 558 | fillSinglePart(currentPart,part1); |
548 | /* important: Check for is NULL 'cause a body can be empty! | 559 | /* important: Check for is NULL 'cause a body can be empty! |
549 | And we put it only into the mail if it is the FIRST part */ | 560 | And we put it only into the mail if it is the FIRST part */ |
550 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body.Bodytext().isNull() && countlist[0]==1) { | 561 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body.Bodytext().isNull() && countlist[0]==1) { |
551 | QString body_text = fetchTextPart(mail,countlist,true,currentPart.Encoding()); | 562 | QString body_text = fetchTextPart(mail,countlist,true,currentPart.Encoding()); |
552 | target_body.setDescription(currentPart); | 563 | target_body.setDescription(currentPart); |
553 | target_body.setBodytext(body_text); | 564 | target_body.setBodytext(body_text); |
554 | if (countlist.count()>1) { | 565 | if (countlist.count()>1) { |
555 | target_body.addPart(currentPart); | 566 | target_body.addPart(currentPart); |
556 | } | 567 | } |
557 | } else { | 568 | } else { |
558 | target_body.addPart(currentPart); | 569 | target_body.addPart(currentPart); |
559 | } | 570 | } |
560 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { | 571 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { |
561 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); | 572 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); |
562 | } | 573 | } |
563 | } | 574 | } |
564 | break; | 575 | break; |
565 | case MAILIMAP_BODY_MPART: | 576 | case MAILIMAP_BODY_MPART: |
566 | { | 577 | { |
567 | QValueList<int>countlist = recList; | 578 | QValueList<int>countlist = recList; |
568 | clistcell*current=0; | 579 | clistcell*current=0; |
569 | mailimap_body*current_body=0; | 580 | mailimap_body*current_body=0; |
570 | unsigned int ccount = 1; | 581 | unsigned int ccount = 1; |
571 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; | 582 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; |
572 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { | 583 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { |
573 | current_body = (mailimap_body*)current->data; | 584 | current_body = (mailimap_body*)current->data; |
574 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 585 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
575 | RecPart targetPart; | 586 | RecPart targetPart; |
576 | targetPart.setType("multipart"); | 587 | targetPart.setType("multipart"); |
577 | fillMultiPart(targetPart,mailDescription); | 588 | fillMultiPart(targetPart,mailDescription); |
578 | countlist.append(current_count); | 589 | countlist.append(current_count); |
579 | targetPart.setPositionlist(countlist); | 590 | targetPart.setPositionlist(countlist); |
580 | target_body.addPart(targetPart); | 591 | target_body.addPart(targetPart); |
581 | QString id(""); | 592 | QString id(""); |
582 | for (unsigned int j = 0; j < countlist.count();++j) { | 593 | for (unsigned int j = 0; j < countlist.count();++j) { |
583 | id+=(j>0?" ":""); | 594 | id+=(j>0?" ":""); |
584 | id+=QString("%1").arg(countlist[j]); | 595 | id+=QString("%1").arg(countlist[j]); |
585 | } | 596 | } |
586 | qDebug("ID(mpart) = %s",id.latin1()); | 597 | qDebug("ID(mpart) = %s",id.latin1()); |
587 | } | 598 | } |
588 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); | 599 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); |
589 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 600 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
590 | countlist = recList; | 601 | countlist = recList; |
591 | } | 602 | } |
592 | ++ccount; | 603 | ++ccount; |
593 | } | 604 | } |
594 | } | 605 | } |
595 | break; | 606 | break; |
596 | default: | 607 | default: |
597 | break; | 608 | break; |
598 | } | 609 | } |
599 | } | 610 | } |
600 | 611 | ||
601 | void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description) | 612 | void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description) |
602 | { | 613 | { |
603 | if (!Description) { | 614 | if (!Description) { |
604 | return; | 615 | return; |
605 | } | 616 | } |
606 | switch (Description->bd_type) { | 617 | switch (Description->bd_type) { |
607 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 618 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
608 | target_part.setType("text"); | 619 | target_part.setType("text"); |
609 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); | 620 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); |
610 | break; | 621 | break; |
611 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | 622 | case MAILIMAP_BODY_TYPE_1PART_BASIC: |
612 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); | 623 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); |
613 | break; | 624 | break; |
614 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 625 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
615 | target_part.setType("message"); | 626 | target_part.setType("message"); |
616 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); | 627 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); |
617 | break; | 628 | break; |
618 | default: | 629 | default: |
619 | break; | 630 | break; |
620 | } | 631 | } |
621 | } | 632 | } |
622 | 633 | ||
623 | void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which) | 634 | void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which) |
624 | { | 635 | { |
625 | if (!which) { | 636 | if (!which) { |
626 | return; | 637 | return; |
627 | } | 638 | } |
628 | QString sub; | 639 | QString sub; |
629 | sub = which->bd_media_text; | 640 | sub = which->bd_media_text; |
630 | qDebug("Type= text/%s",which->bd_media_text); | 641 | qDebug("Type= text/%s",which->bd_media_text); |
631 | target_part.setSubtype(sub.lower()); | 642 | target_part.setSubtype(sub.lower()); |
632 | target_part.setLines(which->bd_lines); | 643 | target_part.setLines(which->bd_lines); |
633 | fillBodyFields(target_part,which->bd_fields); | 644 | fillBodyFields(target_part,which->bd_fields); |
634 | } | 645 | } |
635 | 646 | ||
636 | void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which) | 647 | void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which) |
637 | { | 648 | { |
638 | if (!which) { | 649 | if (!which) { |
639 | return; | 650 | return; |
640 | } | 651 | } |
641 | target_part.setSubtype("rfc822"); | 652 | target_part.setSubtype("rfc822"); |
642 | qDebug("Message part"); | 653 | qDebug("Message part"); |
643 | /* we set this type to text/plain */ | 654 | /* we set this type to text/plain */ |
644 | target_part.setLines(which->bd_lines); | 655 | target_part.setLines(which->bd_lines); |
645 | fillBodyFields(target_part,which->bd_fields); | 656 | fillBodyFields(target_part,which->bd_fields); |
646 | } | 657 | } |
647 | 658 | ||
648 | void IMAPwrapper::fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which) | 659 | void IMAPwrapper::fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which) |
649 | { | 660 | { |
650 | if (!which) return; | 661 | if (!which) return; |
651 | QString sub = which->bd_media_subtype; | 662 | QString sub = which->bd_media_subtype; |
652 | target_part.setSubtype(sub.lower()); | 663 | target_part.setSubtype(sub.lower()); |
653 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { | 664 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { |
654 | clistcell*cur = 0; | 665 | clistcell*cur = 0; |
655 | mailimap_single_body_fld_param*param=0; | 666 | mailimap_single_body_fld_param*param=0; |
656 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 667 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
657 | param = (mailimap_single_body_fld_param*)cur->data; | 668 | param = (mailimap_single_body_fld_param*)cur->data; |
658 | if (param) { | 669 | if (param) { |
659 | target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 670 | target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
660 | } | 671 | } |
661 | } | 672 | } |
662 | } | 673 | } |
663 | } | 674 | } |
664 | 675 | ||
665 | void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) | 676 | void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) |
666 | { | 677 | { |
667 | if (!which) { | 678 | if (!which) { |
668 | return; | 679 | return; |
669 | } | 680 | } |
670 | QString type,sub; | 681 | QString type,sub; |
671 | switch (which->bd_media_basic->med_type) { | 682 | switch (which->bd_media_basic->med_type) { |
672 | case MAILIMAP_MEDIA_BASIC_APPLICATION: | 683 | case MAILIMAP_MEDIA_BASIC_APPLICATION: |
673 | type = "application"; | 684 | type = "application"; |
674 | break; | 685 | break; |
675 | case MAILIMAP_MEDIA_BASIC_AUDIO: | 686 | case MAILIMAP_MEDIA_BASIC_AUDIO: |
676 | type = "audio"; | 687 | type = "audio"; |
677 | break; | 688 | break; |
678 | case MAILIMAP_MEDIA_BASIC_IMAGE: | 689 | case MAILIMAP_MEDIA_BASIC_IMAGE: |
679 | type = "image"; | 690 | type = "image"; |
680 | break; | 691 | break; |
681 | case MAILIMAP_MEDIA_BASIC_MESSAGE: | 692 | case MAILIMAP_MEDIA_BASIC_MESSAGE: |
682 | type = "message"; | 693 | type = "message"; |
683 | break; | 694 | break; |
684 | case MAILIMAP_MEDIA_BASIC_VIDEO: | 695 | case MAILIMAP_MEDIA_BASIC_VIDEO: |
685 | type = "video"; | 696 | type = "video"; |
@@ -766,227 +777,238 @@ void IMAPwrapper::deleteMail(const RecMail&mail) | |||
766 | if ( err != MAILIMAP_NO_ERROR ) { | 777 | if ( err != MAILIMAP_NO_ERROR ) { |
767 | qDebug("error selecting mailbox for delete: %s",m_imap->imap_response); | 778 | qDebug("error selecting mailbox for delete: %s",m_imap->imap_response); |
768 | return; | 779 | return; |
769 | } | 780 | } |
770 | flist = mailimap_flag_list_new_empty(); | 781 | flist = mailimap_flag_list_new_empty(); |
771 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 782 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
772 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 783 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
773 | set = mailimap_set_new_single(mail.getNumber()); | 784 | set = mailimap_set_new_single(mail.getNumber()); |
774 | err = mailimap_store(m_imap,set,store_flags); | 785 | err = mailimap_store(m_imap,set,store_flags); |
775 | mailimap_set_free( set ); | 786 | mailimap_set_free( set ); |
776 | mailimap_store_att_flags_free(store_flags); | 787 | mailimap_store_att_flags_free(store_flags); |
777 | 788 | ||
778 | if (err != MAILIMAP_NO_ERROR) { | 789 | if (err != MAILIMAP_NO_ERROR) { |
779 | qDebug("error deleting mail: %s",m_imap->imap_response); | 790 | qDebug("error deleting mail: %s",m_imap->imap_response); |
780 | return; | 791 | return; |
781 | } | 792 | } |
782 | qDebug("deleting mail: %s",m_imap->imap_response); | 793 | qDebug("deleting mail: %s",m_imap->imap_response); |
783 | /* should we realy do that at this moment? */ | 794 | /* should we realy do that at this moment? */ |
784 | err = mailimap_expunge(m_imap); | 795 | err = mailimap_expunge(m_imap); |
785 | if (err != MAILIMAP_NO_ERROR) { | 796 | if (err != MAILIMAP_NO_ERROR) { |
786 | qDebug("error deleting mail: %s",m_imap->imap_response); | 797 | qDebug("error deleting mail: %s",m_imap->imap_response); |
787 | } | 798 | } |
788 | qDebug("Delete successfull %s",m_imap->imap_response); | 799 | qDebug("Delete successfull %s",m_imap->imap_response); |
789 | } | 800 | } |
790 | 801 | ||
791 | void IMAPwrapper::answeredMail(const RecMail&mail) | 802 | void IMAPwrapper::answeredMail(const RecMail&mail) |
792 | { | 803 | { |
793 | mailimap_flag_list*flist; | 804 | mailimap_flag_list*flist; |
794 | mailimap_set *set; | 805 | mailimap_set *set; |
795 | mailimap_store_att_flags * store_flags; | 806 | mailimap_store_att_flags * store_flags; |
796 | int err; | 807 | int err; |
797 | login(); | 808 | login(); |
798 | if (!m_imap) { | 809 | if (!m_imap) { |
799 | return; | 810 | return; |
800 | } | 811 | } |
801 | const char *mb = mail.getMbox().latin1(); | 812 | const char *mb = mail.getMbox().latin1(); |
802 | err = mailimap_select( m_imap, (char*)mb); | 813 | err = mailimap_select( m_imap, (char*)mb); |
803 | if ( err != MAILIMAP_NO_ERROR ) { | 814 | if ( err != MAILIMAP_NO_ERROR ) { |
804 | qDebug("error selecting mailbox for mark: %s",m_imap->imap_response); | 815 | qDebug("error selecting mailbox for mark: %s",m_imap->imap_response); |
805 | return; | 816 | return; |
806 | } | 817 | } |
807 | flist = mailimap_flag_list_new_empty(); | 818 | flist = mailimap_flag_list_new_empty(); |
808 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); | 819 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); |
809 | store_flags = mailimap_store_att_flags_new_add_flags(flist); | 820 | store_flags = mailimap_store_att_flags_new_add_flags(flist); |
810 | set = mailimap_set_new_single(mail.getNumber()); | 821 | set = mailimap_set_new_single(mail.getNumber()); |
811 | err = mailimap_store(m_imap,set,store_flags); | 822 | err = mailimap_store(m_imap,set,store_flags); |
812 | mailimap_set_free( set ); | 823 | mailimap_set_free( set ); |
813 | mailimap_store_att_flags_free(store_flags); | 824 | mailimap_store_att_flags_free(store_flags); |
814 | 825 | ||
815 | if (err != MAILIMAP_NO_ERROR) { | 826 | if (err != MAILIMAP_NO_ERROR) { |
816 | qDebug("error marking mail: %s",m_imap->imap_response); | 827 | qDebug("error marking mail: %s",m_imap->imap_response); |
817 | return; | 828 | return; |
818 | } | 829 | } |
819 | } | 830 | } |
820 | 831 | ||
821 | QString IMAPwrapper::fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | 832 | QString IMAPwrapper::fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call,const QString&enc) |
822 | { | 833 | { |
823 | QString body(""); | 834 | QString body(""); |
824 | encodedString*res = fetchRawPart(mail,path,internal_call); | 835 | encodedString*res = fetchRawPart(mail,path,internal_call); |
825 | encodedString*r = decode_String(res,enc); | 836 | encodedString*r = decode_String(res,enc); |
826 | delete res; | 837 | delete res; |
827 | if (r) { | 838 | if (r) { |
828 | if (r->Length()>0) { | 839 | if (r->Length()>0) { |
829 | body = r->Content(); | 840 | body = r->Content(); |
830 | } | 841 | } |
831 | delete r; | 842 | delete r; |
832 | } | 843 | } |
833 | return body; | 844 | return body; |
834 | } | 845 | } |
835 | 846 | ||
836 | QString IMAPwrapper::fetchTextPart(const RecMail&mail,const RecPart&part) | 847 | QString IMAPwrapper::fetchTextPart(const RecMail&mail,const RecPart&part) |
837 | { | 848 | { |
838 | return fetchTextPart(mail,part.Positionlist(),false,part.Encoding()); | 849 | return fetchTextPart(mail,part.Positionlist(),false,part.Encoding()); |
839 | } | 850 | } |
840 | 851 | ||
841 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&part) | 852 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&part) |
842 | { | 853 | { |
843 | encodedString*res = fetchRawPart(mail,part.Positionlist(),false); | 854 | encodedString*res = fetchRawPart(mail,part.Positionlist(),false); |
844 | encodedString*r = decode_String(res,part.Encoding()); | 855 | encodedString*r = decode_String(res,part.Encoding()); |
845 | delete res; | 856 | delete res; |
846 | return r; | 857 | return r; |
847 | } | 858 | } |
848 | 859 | ||
849 | encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) | 860 | encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) |
850 | { | 861 | { |
851 | return fetchRawPart(mail,part.Positionlist(),false); | 862 | return fetchRawPart(mail,part.Positionlist(),false); |
852 | } | 863 | } |
853 | 864 | ||
854 | int IMAPwrapper::deleteAllMail(const Folder*folder) | 865 | int IMAPwrapper::deleteAllMail(const Folder*folder) |
855 | { | 866 | { |
856 | login(); | 867 | login(); |
857 | if (!m_imap) { | 868 | if (!m_imap) { |
858 | return 0; | 869 | return 0; |
859 | } | 870 | } |
860 | mailimap_flag_list*flist; | 871 | mailimap_flag_list*flist; |
861 | mailimap_set *set; | 872 | mailimap_set *set; |
862 | mailimap_store_att_flags * store_flags; | 873 | mailimap_store_att_flags * store_flags; |
863 | int err = mailimap_select( m_imap, folder->getName().latin1()); | 874 | int err = mailimap_select( m_imap, folder->getName().latin1()); |
864 | if ( err != MAILIMAP_NO_ERROR ) { | 875 | if ( err != MAILIMAP_NO_ERROR ) { |
865 | Global::statusMessage(tr("error selecting mailbox: %1").arg(m_imap->imap_response)); | 876 | Global::statusMessage(tr("error selecting mailbox: %1").arg(m_imap->imap_response)); |
866 | return 0; | 877 | return 0; |
867 | } | 878 | } |
868 | int last = m_imap->imap_selection_info->sel_exists; | 879 | int last = m_imap->imap_selection_info->sel_exists; |
869 | if (last == 0) { | 880 | if (last == 0) { |
870 | Global::statusMessage(tr("Mailbox has no mails!")); | 881 | Global::statusMessage(tr("Mailbox has no mails!")); |
871 | return 0; | 882 | return 0; |
872 | } | 883 | } |
873 | flist = mailimap_flag_list_new_empty(); | 884 | flist = mailimap_flag_list_new_empty(); |
874 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 885 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
875 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 886 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
876 | set = mailimap_set_new_interval( 1, last ); | 887 | set = mailimap_set_new_interval( 1, last ); |
877 | err = mailimap_store(m_imap,set,store_flags); | 888 | err = mailimap_store(m_imap,set,store_flags); |
878 | mailimap_set_free( set ); | 889 | mailimap_set_free( set ); |
879 | mailimap_store_att_flags_free(store_flags); | 890 | mailimap_store_att_flags_free(store_flags); |
880 | if (err != MAILIMAP_NO_ERROR) { | 891 | if (err != MAILIMAP_NO_ERROR) { |
881 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 892 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
882 | return 0; | 893 | return 0; |
883 | } | 894 | } |
884 | qDebug("deleting mail: %s",m_imap->imap_response); | 895 | qDebug("deleting mail: %s",m_imap->imap_response); |
885 | /* should we realy do that at this moment? */ | 896 | /* should we realy do that at this moment? */ |
886 | err = mailimap_expunge(m_imap); | 897 | err = mailimap_expunge(m_imap); |
887 | if (err != MAILIMAP_NO_ERROR) { | 898 | if (err != MAILIMAP_NO_ERROR) { |
888 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 899 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
889 | return 0; | 900 | return 0; |
890 | } | 901 | } |
891 | qDebug("Delete successfull %s",m_imap->imap_response); | 902 | qDebug("Delete successfull %s",m_imap->imap_response); |
892 | return 1; | 903 | return 1; |
893 | } | 904 | } |
894 | 905 | ||
895 | int IMAPwrapper::createMbox(const QString&folder,const Folder*parentfolder,const QString& delemiter,bool getsubfolder) | 906 | int IMAPwrapper::createMbox(const QString&folder,const Folder*parentfolder,const QString& delemiter,bool getsubfolder) |
896 | { | 907 | { |
897 | if (folder.length()==0) return 0; | 908 | if (folder.length()==0) return 0; |
898 | login(); | 909 | login(); |
899 | if (!m_imap) {return 0;} | 910 | if (!m_imap) {return 0;} |
900 | QString pre = account->getPrefix(); | 911 | QString pre = account->getPrefix(); |
901 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { | 912 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { |
902 | pre+=delemiter; | 913 | pre+=delemiter; |
903 | } | 914 | } |
904 | if (parentfolder) { | 915 | if (parentfolder) { |
905 | pre += parentfolder->getDisplayName()+delemiter; | 916 | pre += parentfolder->getDisplayName()+delemiter; |
906 | } | 917 | } |
907 | pre+=folder; | 918 | pre+=folder; |
908 | if (getsubfolder) { | 919 | if (getsubfolder) { |
909 | if (delemiter.length()>0) { | 920 | if (delemiter.length()>0) { |
910 | pre+=delemiter; | 921 | pre+=delemiter; |
911 | } else { | 922 | } else { |
912 | Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); | 923 | Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); |
913 | return 0; | 924 | return 0; |
914 | } | 925 | } |
915 | } | 926 | } |
916 | qDebug("Creating %s",pre.latin1()); | 927 | qDebug("Creating %s",pre.latin1()); |
917 | int res = mailimap_create(m_imap,pre.latin1()); | 928 | int res = mailimap_create(m_imap,pre.latin1()); |
918 | if (res != MAILIMAP_NO_ERROR) { | 929 | if (res != MAILIMAP_NO_ERROR) { |
919 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 930 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
920 | return 0; | 931 | return 0; |
921 | } | 932 | } |
922 | return 1; | 933 | return 1; |
923 | } | 934 | } |
924 | 935 | ||
925 | int IMAPwrapper::deleteMbox(const Folder*folder) | 936 | int IMAPwrapper::deleteMbox(const Folder*folder) |
926 | { | 937 | { |
927 | if (!folder) return 0; | 938 | if (!folder) return 0; |
928 | login(); | 939 | login(); |
929 | if (!m_imap) {return 0;} | 940 | if (!m_imap) {return 0;} |
930 | int res = mailimap_delete(m_imap,folder->getName()); | 941 | int res = mailimap_delete(m_imap,folder->getName()); |
931 | if (res != MAILIMAP_NO_ERROR) { | 942 | if (res != MAILIMAP_NO_ERROR) { |
932 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 943 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
933 | return 0; | 944 | return 0; |
934 | } | 945 | } |
935 | return 1; | 946 | return 1; |
936 | } | 947 | } |
937 | 948 | ||
938 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 949 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
939 | { | 950 | { |
940 | mailimap_status_att_list * att_list =0; | 951 | mailimap_status_att_list * att_list =0; |
941 | mailimap_mailbox_data_status * status=0; | 952 | mailimap_mailbox_data_status * status=0; |
942 | clistiter * cur = 0; | 953 | clistiter * cur = 0; |
943 | int r = 0; | 954 | int r = 0; |
944 | int res = 0; | 955 | int res = 0; |
945 | target_stat.message_count = 0; | 956 | target_stat.message_count = 0; |
946 | target_stat.message_unseen = 0; | 957 | target_stat.message_unseen = 0; |
947 | target_stat.message_recent = 0; | 958 | target_stat.message_recent = 0; |
948 | login(); | 959 | login(); |
949 | if (!m_imap) { | 960 | if (!m_imap) { |
950 | return; | 961 | return; |
951 | } | 962 | } |
952 | att_list = mailimap_status_att_list_new_empty(); | 963 | att_list = mailimap_status_att_list_new_empty(); |
953 | if (!att_list) return; | 964 | if (!att_list) return; |
954 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); | 965 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); |
955 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); | 966 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); |
956 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); | 967 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); |
957 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); | 968 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); |
958 | for (cur = clist_begin(status->st_info_list); | 969 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { |
959 | cur != NULL ; cur = clist_next(cur)) { | 970 | for (cur = clist_begin(status->st_info_list); |
960 | mailimap_status_info * status_info; | 971 | cur != NULL ; cur = clist_next(cur)) { |
961 | status_info = (mailimap_status_info *)clist_content(cur); | 972 | mailimap_status_info * status_info; |
962 | switch (status_info->st_att) { | 973 | status_info = (mailimap_status_info *)clist_content(cur); |
963 | case MAILIMAP_STATUS_ATT_MESSAGES: | 974 | switch (status_info->st_att) { |
964 | target_stat.message_count = status_info->st_value; | 975 | case MAILIMAP_STATUS_ATT_MESSAGES: |
965 | break; | 976 | target_stat.message_count = status_info->st_value; |
966 | case MAILIMAP_STATUS_ATT_RECENT: | 977 | break; |
967 | target_stat.message_recent = status_info->st_value; | 978 | case MAILIMAP_STATUS_ATT_RECENT: |
968 | break; | 979 | target_stat.message_recent = status_info->st_value; |
969 | case MAILIMAP_STATUS_ATT_UNSEEN: | 980 | break; |
970 | target_stat.message_unseen = status_info->st_value; | 981 | case MAILIMAP_STATUS_ATT_UNSEEN: |
971 | break; | 982 | target_stat.message_unseen = status_info->st_value; |
983 | break; | ||
984 | } | ||
972 | } | 985 | } |
986 | } else { | ||
987 | qDebug("Error retrieving status"); | ||
973 | } | 988 | } |
974 | mailimap_mailbox_data_status_free(status); | 989 | if (status) mailimap_mailbox_data_status_free(status); |
975 | mailimap_status_att_list_free(att_list); | 990 | if (att_list) mailimap_status_att_list_free(att_list); |
976 | } | 991 | } |
977 | 992 | ||
978 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 993 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
979 | { | 994 | { |
980 | login(); | 995 | login(); |
981 | if (!m_imap) return; | 996 | if (!m_imap) return; |
982 | if (!msg) return; | 997 | if (!msg) return; |
983 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); | 998 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); |
984 | if (r != MAILIMAP_NO_ERROR) { | 999 | if (r != MAILIMAP_NO_ERROR) { |
985 | Global::statusMessage("Error storing mail!"); | 1000 | Global::statusMessage("Error storing mail!"); |
986 | } | 1001 | } |
987 | } | 1002 | } |
988 | 1003 | ||
989 | const QString&IMAPwrapper::getType()const | 1004 | const QString&IMAPwrapper::getType()const |
990 | { | 1005 | { |
991 | return account->getType(); | 1006 | return account->getType(); |
992 | } | 1007 | } |
1008 | |||
1009 | encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) | ||
1010 | { | ||
1011 | // dummy | ||
1012 | QValueList<int> path; | ||
1013 | return fetchRawPart(mail,path,false); | ||
1014 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index 6a9c411..b246f58 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -1,70 +1,71 @@ | |||
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 | 34 | ||
35 | virtual RecBody fetchBody(const RecMail&mail); | 35 | virtual RecBody fetchBody(const RecMail&mail); |
36 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); | 36 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); |
37 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | 37 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); |
38 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | 38 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); |
39 | virtual encodedString* fetchRawBody(const RecMail&mail); | ||
39 | 40 | ||
40 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); | 41 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); |
41 | virtual int deleteMbox(const Folder*folder); | 42 | virtual int deleteMbox(const Folder*folder); |
42 | 43 | ||
43 | static void imap_progress( size_t current, size_t maximum ); | 44 | static void imap_progress( size_t current, size_t maximum ); |
44 | 45 | ||
45 | virtual void logout(); | 46 | virtual void logout(); |
46 | virtual const QString&getType()const; | 47 | virtual const QString&getType()const; |
47 | protected: | 48 | protected: |
48 | RecMail*parse_list_result(mailimap_msg_att*); | 49 | RecMail*parse_list_result(mailimap_msg_att*); |
49 | void login(); | 50 | void login(); |
50 | 51 | ||
51 | virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); | 52 | virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); |
52 | virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); | 53 | virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); |
53 | 54 | ||
54 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); | 55 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); |
55 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); | 56 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); |
56 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); | 57 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); |
57 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); | 58 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); |
58 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); | 59 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); |
59 | void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); | 60 | void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); |
60 | 61 | ||
61 | /* just helpers */ | 62 | /* just helpers */ |
62 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); | 63 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); |
63 | static QStringList address_list_to_stringlist(clist*list); | 64 | static QStringList address_list_to_stringlist(clist*list); |
64 | 65 | ||
65 | 66 | ||
66 | IMAPaccount *account; | 67 | IMAPaccount *account; |
67 | mailimap *m_imap; | 68 | mailimap *m_imap; |
68 | }; | 69 | }; |
69 | 70 | ||
70 | #endif | 71 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp index 60f7507..3a0b30a 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp | |||
@@ -1,331 +1,332 @@ | |||
1 | #include "mboxwrapper.h" | 1 | #include "mboxwrapper.h" |
2 | #include "mailtypes.h" | 2 | #include "mailtypes.h" |
3 | #include "mailwrapper.h" | 3 | #include "mailwrapper.h" |
4 | #include <libetpan/libetpan.h> | 4 | #include <libetpan/libetpan.h> |
5 | #include <qdir.h> | 5 | #include <qdir.h> |
6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | #include <qpe/global.h> | 7 | #include <qpe/global.h> |
8 | 8 | ||
9 | const QString MBOXwrapper::wrapperType="MBOX"; | 9 | const QString MBOXwrapper::wrapperType="MBOX"; |
10 | 10 | ||
11 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir) | 11 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir) |
12 | : Genericwrapper(),MBOXPath(mbox_dir) | 12 | : Genericwrapper(),MBOXPath(mbox_dir) |
13 | { | 13 | { |
14 | QDir dir(MBOXPath); | 14 | QDir dir(MBOXPath); |
15 | if (!dir.exists()) { | 15 | if (!dir.exists()) { |
16 | dir.mkdir(MBOXPath); | 16 | dir.mkdir(MBOXPath); |
17 | } | 17 | } |
18 | } | 18 | } |
19 | 19 | ||
20 | MBOXwrapper::~MBOXwrapper() | 20 | MBOXwrapper::~MBOXwrapper() |
21 | { | 21 | { |
22 | } | 22 | } |
23 | 23 | ||
24 | void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) | 24 | void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) |
25 | { | 25 | { |
26 | mailstorage*storage = mailstorage_new(NULL); | 26 | mailstorage*storage = mailstorage_new(NULL); |
27 | QString p = MBOXPath+"/"; | 27 | QString p = MBOXPath+"/"; |
28 | p+=mailbox; | 28 | p+=mailbox; |
29 | 29 | ||
30 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 30 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
31 | mailfolder*folder; | 31 | mailfolder*folder; |
32 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 32 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
33 | r = mailfolder_connect(folder); | 33 | r = mailfolder_connect(folder); |
34 | if (r != MAIL_NO_ERROR) { | 34 | if (r != MAIL_NO_ERROR) { |
35 | qDebug("Error initializing mbox"); | 35 | qDebug("Error initializing mbox"); |
36 | mailfolder_free(folder); | 36 | mailfolder_free(folder); |
37 | mailstorage_free(storage); | 37 | mailstorage_free(storage); |
38 | return; | 38 | return; |
39 | } | 39 | } |
40 | 40 | ||
41 | parseList(target,folder->fld_session,mailbox); | 41 | parseList(target,folder->fld_session,mailbox); |
42 | 42 | ||
43 | mailfolder_disconnect(folder); | 43 | mailfolder_disconnect(folder); |
44 | mailfolder_free(folder); | 44 | mailfolder_free(folder); |
45 | mailstorage_free(storage); | 45 | mailstorage_free(storage); |
46 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); | 46 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); |
47 | } | 47 | } |
48 | 48 | ||
49 | QList<Folder>* MBOXwrapper::listFolders() | 49 | QList<Folder>* MBOXwrapper::listFolders() |
50 | { | 50 | { |
51 | QList<Folder> * folders = new QList<Folder>(); | 51 | QList<Folder> * folders = new QList<Folder>(); |
52 | folders->setAutoDelete( false ); | 52 | folders->setAutoDelete( false ); |
53 | QDir dir(MBOXPath); | 53 | QDir dir(MBOXPath); |
54 | if (!dir.exists()) return folders; | 54 | if (!dir.exists()) return folders; |
55 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); | 55 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); |
56 | QStringList entries = dir.entryList(); | 56 | QStringList entries = dir.entryList(); |
57 | QStringList::ConstIterator it = entries.begin(); | 57 | QStringList::ConstIterator it = entries.begin(); |
58 | for (;it!=entries.end();++it) { | 58 | for (;it!=entries.end();++it) { |
59 | Folder*inb=new Folder(*it,"/"); | 59 | Folder*inb=new Folder(*it,"/"); |
60 | folders->append(inb); | 60 | folders->append(inb); |
61 | } | 61 | } |
62 | return folders; | 62 | return folders; |
63 | } | 63 | } |
64 | 64 | ||
65 | void MBOXwrapper::deleteMail(const RecMail&mail) | 65 | void MBOXwrapper::deleteMail(const RecMail&mail) |
66 | { | 66 | { |
67 | mailstorage*storage = mailstorage_new(NULL); | 67 | mailstorage*storage = mailstorage_new(NULL); |
68 | QString p = MBOXPath+"/"; | 68 | QString p = MBOXPath+"/"; |
69 | p+=mail.getMbox(); | 69 | p+=mail.getMbox(); |
70 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 70 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
71 | mailfolder*folder; | 71 | mailfolder*folder; |
72 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 72 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
73 | r = mailfolder_connect(folder); | 73 | r = mailfolder_connect(folder); |
74 | if (r != MAIL_NO_ERROR) { | 74 | if (r != MAIL_NO_ERROR) { |
75 | qDebug("Error initializing mbox"); | 75 | qDebug("Error initializing mbox"); |
76 | mailfolder_free(folder); | 76 | mailfolder_free(folder); |
77 | mailstorage_free(storage); | 77 | mailstorage_free(storage); |
78 | return; | 78 | return; |
79 | } | 79 | } |
80 | r = mailsession_remove_message(folder->fld_session,mail.getNumber()); | 80 | r = mailsession_remove_message(folder->fld_session,mail.getNumber()); |
81 | if (r != MAIL_NO_ERROR) { | 81 | if (r != MAIL_NO_ERROR) { |
82 | qDebug("error deleting mail"); | 82 | qDebug("error deleting mail"); |
83 | } | 83 | } |
84 | mailfolder_free(folder); | 84 | mailfolder_free(folder); |
85 | mailstorage_free(storage); | 85 | mailstorage_free(storage); |
86 | } | 86 | } |
87 | 87 | ||
88 | void MBOXwrapper::answeredMail(const RecMail&) | 88 | void MBOXwrapper::answeredMail(const RecMail&) |
89 | { | 89 | { |
90 | } | 90 | } |
91 | 91 | ||
92 | RecBody MBOXwrapper::fetchBody( const RecMail &mail ) | 92 | RecBody MBOXwrapper::fetchBody( const RecMail &mail ) |
93 | { | 93 | { |
94 | RecBody body; | 94 | RecBody body; |
95 | mailstorage*storage = mailstorage_new(NULL); | 95 | mailstorage*storage = mailstorage_new(NULL); |
96 | QString p = MBOXPath+"/"; | 96 | QString p = MBOXPath+"/"; |
97 | p+=mail.getMbox(); | 97 | p+=mail.getMbox(); |
98 | mailmessage * msg; | 98 | mailmessage * msg; |
99 | char*data=0; | 99 | char*data=0; |
100 | size_t size; | 100 | size_t size; |
101 | 101 | ||
102 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 102 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
103 | mailfolder*folder; | 103 | mailfolder*folder; |
104 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 104 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
105 | r = mailfolder_connect(folder); | 105 | r = mailfolder_connect(folder); |
106 | if (r != MAIL_NO_ERROR) { | 106 | if (r != MAIL_NO_ERROR) { |
107 | qDebug("Error initializing mbox"); | 107 | qDebug("Error initializing mbox"); |
108 | mailfolder_free(folder); | 108 | mailfolder_free(folder); |
109 | mailstorage_free(storage); | 109 | mailstorage_free(storage); |
110 | return body; | 110 | return body; |
111 | } | 111 | } |
112 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); | 112 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); |
113 | if (r != MAIL_NO_ERROR) { | 113 | if (r != MAIL_NO_ERROR) { |
114 | qDebug("Error fetching mail %i",mail.getNumber()); | 114 | qDebug("Error fetching mail %i",mail.getNumber()); |
115 | mailfolder_free(folder); | 115 | mailfolder_free(folder); |
116 | mailstorage_free(storage); | 116 | mailstorage_free(storage); |
117 | return body; | 117 | return body; |
118 | } | 118 | } |
119 | r = mailmessage_fetch(msg,&data,&size); | 119 | r = mailmessage_fetch(msg,&data,&size); |
120 | if (r != MAIL_NO_ERROR) { | 120 | if (r != MAIL_NO_ERROR) { |
121 | qDebug("Error fetching mail %i",mail.getNumber()); | 121 | qDebug("Error fetching mail %i",mail.getNumber()); |
122 | mailfolder_free(folder); | 122 | mailfolder_free(folder); |
123 | mailstorage_free(storage); | 123 | mailstorage_free(storage); |
124 | mailmessage_free(msg); | 124 | mailmessage_free(msg); |
125 | return body; | 125 | return body; |
126 | } | 126 | } |
127 | body = parseMail(msg); | 127 | body = parseMail(msg); |
128 | mailmessage_fetch_result_free(msg,data); | 128 | mailmessage_fetch_result_free(msg,data); |
129 | mailfolder_free(folder); | 129 | mailfolder_free(folder); |
130 | mailstorage_free(storage); | 130 | mailstorage_free(storage); |
131 | 131 | ||
132 | return body; | 132 | return body; |
133 | } | 133 | } |
134 | 134 | ||
135 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) | 135 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) |
136 | { | 136 | { |
137 | qDebug("MBOX %i von %i",current,maximum); | 137 | qDebug("MBOX %i von %i",current,maximum); |
138 | } | 138 | } |
139 | 139 | ||
140 | int MBOXwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool ) | 140 | int MBOXwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool ) |
141 | { | 141 | { |
142 | QString p = MBOXPath+"/"; | 142 | QString p = MBOXPath+"/"; |
143 | p+=folder; | 143 | p+=folder; |
144 | QFileInfo fi(p); | 144 | QFileInfo fi(p); |
145 | if (fi.exists()) { | 145 | if (fi.exists()) { |
146 | Global::statusMessage(tr("Mailbox exists.")); | 146 | Global::statusMessage(tr("Mailbox exists.")); |
147 | return 0; | 147 | return 0; |
148 | } | 148 | } |
149 | mailmbox_folder*f = 0; | 149 | mailmbox_folder*f = 0; |
150 | if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { | 150 | if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { |
151 | Global::statusMessage(tr("Error init folder")); | 151 | Global::statusMessage(tr("Error init folder")); |
152 | return 0; | 152 | return 0; |
153 | } | 153 | } |
154 | if (f) mailmbox_done(f); | 154 | if (f) mailmbox_done(f); |
155 | return 1; | 155 | return 1; |
156 | } | 156 | } |
157 | 157 | ||
158 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 158 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
159 | { | 159 | { |
160 | QString p = MBOXPath+"/"; | 160 | QString p = MBOXPath+"/"; |
161 | p+=folder; | 161 | p+=folder; |
162 | mailmbox_folder*f = 0; | 162 | mailmbox_folder*f = 0; |
163 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 163 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
164 | if (r != MAIL_NO_ERROR) { | 164 | if (r != MAIL_NO_ERROR) { |
165 | Global::statusMessage(tr("Error init folder")); | 165 | Global::statusMessage(tr("Error init folder")); |
166 | return; | 166 | return; |
167 | } | 167 | } |
168 | r = mailmbox_append_message(f,msg,length); | 168 | r = mailmbox_append_message(f,msg,length); |
169 | if (r != MAIL_NO_ERROR) { | 169 | if (r != MAIL_NO_ERROR) { |
170 | Global::statusMessage(tr("Error writing to message folder")); | 170 | Global::statusMessage(tr("Error writing to message folder")); |
171 | } | 171 | } |
172 | mailmbox_done(f); | 172 | mailmbox_done(f); |
173 | } | 173 | } |
174 | 174 | ||
175 | void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) | 175 | encodedString* MBOXwrapper::fetchRawBody(const RecMail&mail) |
176 | { | 176 | { |
177 | RecBody body; | 177 | RecBody body; |
178 | mailstorage*storage = mailstorage_new(NULL); | 178 | mailstorage*storage = mailstorage_new(NULL); |
179 | QString p = MBOXPath+"/"; | 179 | QString p = MBOXPath+"/"; |
180 | p+=mail.getMbox(); | 180 | p+=mail.getMbox(); |
181 | mailmessage * msg; | 181 | mailmessage * msg; |
182 | char*data=0; | 182 | char*data=0; |
183 | size_t size; | 183 | size_t size; |
184 | 184 | ||
185 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 185 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
186 | mailfolder*folder; | 186 | mailfolder*folder; |
187 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 187 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
188 | r = mailfolder_connect(folder); | 188 | r = mailfolder_connect(folder); |
189 | if (r != MAIL_NO_ERROR) { | 189 | if (r != MAIL_NO_ERROR) { |
190 | Global::statusMessage(tr("Error initializing mbox")); | 190 | Global::statusMessage(tr("Error initializing mbox")); |
191 | mailfolder_free(folder); | 191 | mailfolder_free(folder); |
192 | mailstorage_free(storage); | 192 | mailstorage_free(storage); |
193 | return; | 193 | return 0; |
194 | } | 194 | } |
195 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); | 195 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); |
196 | if (r != MAIL_NO_ERROR) { | 196 | if (r != MAIL_NO_ERROR) { |
197 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); | 197 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
198 | mailfolder_free(folder); | 198 | mailfolder_free(folder); |
199 | mailstorage_free(storage); | 199 | mailstorage_free(storage); |
200 | return; | 200 | return 0; |
201 | } | 201 | } |
202 | r = mailmessage_fetch(msg,&data,&size); | 202 | r = mailmessage_fetch(msg,&data,&size); |
203 | if (r != MAIL_NO_ERROR) { | 203 | if (r != MAIL_NO_ERROR) { |
204 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); | 204 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
205 | mailfolder_free(folder); | 205 | mailfolder_free(folder); |
206 | mailstorage_free(storage); | 206 | mailstorage_free(storage); |
207 | mailmessage_free(msg); | 207 | mailmessage_free(msg); |
208 | return; | 208 | return 0; |
209 | } | 209 | } |
210 | *target = data; | 210 | encodedString*result = new encodedString(data,size); |
211 | *length = size; | 211 | |
212 | mailfolder_free(folder); | 212 | mailfolder_free(folder); |
213 | mailstorage_free(storage); | 213 | mailstorage_free(storage); |
214 | mailmessage_free(msg); | 214 | mailmessage_free(msg); |
215 | return result; | ||
215 | } | 216 | } |
216 | 217 | ||
217 | void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) | 218 | void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) |
218 | { | 219 | { |
219 | QString p = MBOXPath+"/"; | 220 | QString p = MBOXPath+"/"; |
220 | p+=mailbox; | 221 | p+=mailbox; |
221 | mailmbox_folder*f = 0; | 222 | mailmbox_folder*f = 0; |
222 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 223 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
223 | if (r != MAIL_NO_ERROR) { | 224 | if (r != MAIL_NO_ERROR) { |
224 | qDebug("Error init folder"); | 225 | qDebug("Error init folder"); |
225 | return; | 226 | return; |
226 | } | 227 | } |
227 | deleteMails(f,target); | 228 | deleteMails(f,target); |
228 | mailmbox_done(f); | 229 | mailmbox_done(f); |
229 | } | 230 | } |
230 | 231 | ||
231 | void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) | 232 | void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) |
232 | { | 233 | { |
233 | if (!f) return; | 234 | if (!f) return; |
234 | int r; | 235 | int r; |
235 | for (unsigned int i=0; i < target.count();++i) { | 236 | for (unsigned int i=0; i < target.count();++i) { |
236 | r = mailmbox_delete_msg(f,target.at(i)->getNumber()); | 237 | r = mailmbox_delete_msg(f,target.at(i)->getNumber()); |
237 | if (r!=MAILMBOX_NO_ERROR) { | 238 | if (r!=MAILMBOX_NO_ERROR) { |
238 | qDebug("error delete mail"); | 239 | qDebug("error delete mail"); |
239 | } | 240 | } |
240 | } | 241 | } |
241 | r = mailmbox_expunge(f); | 242 | r = mailmbox_expunge(f); |
242 | if (r != MAILMBOX_NO_ERROR) { | 243 | if (r != MAILMBOX_NO_ERROR) { |
243 | qDebug("error expunge mailbox"); | 244 | qDebug("error expunge mailbox"); |
244 | } | 245 | } |
245 | } | 246 | } |
246 | 247 | ||
247 | int MBOXwrapper::deleteAllMail(const Folder*tfolder) | 248 | int MBOXwrapper::deleteAllMail(const Folder*tfolder) |
248 | { | 249 | { |
249 | if (!tfolder) return 0; | 250 | if (!tfolder) return 0; |
250 | QString p = MBOXPath+tfolder->getDisplayName(); | 251 | QString p = MBOXPath+tfolder->getDisplayName(); |
251 | int res = 1; | 252 | int res = 1; |
252 | 253 | ||
253 | mailfolder*folder = 0; | 254 | mailfolder*folder = 0; |
254 | mailmessage_list*l=0; | 255 | mailmessage_list*l=0; |
255 | mailstorage*storage = mailstorage_new(NULL); | 256 | mailstorage*storage = mailstorage_new(NULL); |
256 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 257 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
257 | if (r != MAIL_NO_ERROR) { | 258 | if (r != MAIL_NO_ERROR) { |
258 | Global::statusMessage(tr("Error initializing mbox")); | 259 | Global::statusMessage(tr("Error initializing mbox")); |
259 | res = 0; | 260 | res = 0; |
260 | } | 261 | } |
261 | if (res) { | 262 | if (res) { |
262 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 263 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
263 | r = mailfolder_connect(folder); | 264 | r = mailfolder_connect(folder); |
264 | if (r != MAIL_NO_ERROR) { | 265 | if (r != MAIL_NO_ERROR) { |
265 | Global::statusMessage(tr("Error initializing mbox")); | 266 | Global::statusMessage(tr("Error initializing mbox")); |
266 | res = 0; | 267 | res = 0; |
267 | } | 268 | } |
268 | } | 269 | } |
269 | if (res) { | 270 | if (res) { |
270 | r = mailsession_get_messages_list(folder->fld_session,&l); | 271 | r = mailsession_get_messages_list(folder->fld_session,&l); |
271 | if (r != MAIL_NO_ERROR) { | 272 | if (r != MAIL_NO_ERROR) { |
272 | qDebug("Error message list"); | 273 | qDebug("Error message list"); |
273 | res=0; | 274 | res=0; |
274 | } | 275 | } |
275 | } | 276 | } |
276 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { | 277 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { |
277 | r = mailsession_remove_message(folder->fld_session,i+1); | 278 | r = mailsession_remove_message(folder->fld_session,i+1); |
278 | if (r != MAIL_NO_ERROR) { | 279 | if (r != MAIL_NO_ERROR) { |
279 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 280 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
280 | res = 0; | 281 | res = 0; |
281 | break; | 282 | break; |
282 | } | 283 | } |
283 | } | 284 | } |
284 | if (l) mailmessage_list_free(l); | 285 | if (l) mailmessage_list_free(l); |
285 | if (folder) mailfolder_free(folder); | 286 | if (folder) mailfolder_free(folder); |
286 | if (storage) mailstorage_free(storage); | 287 | if (storage) mailstorage_free(storage); |
287 | return res; | 288 | return res; |
288 | } | 289 | } |
289 | 290 | ||
290 | int MBOXwrapper::deleteMbox(const Folder*tfolder) | 291 | int MBOXwrapper::deleteMbox(const Folder*tfolder) |
291 | { | 292 | { |
292 | if (!tfolder) return 0; | 293 | if (!tfolder) return 0; |
293 | QString p = MBOXPath+tfolder->getDisplayName(); | 294 | QString p = MBOXPath+tfolder->getDisplayName(); |
294 | QFile fi(p); | 295 | QFile fi(p); |
295 | if (!fi.exists()) { | 296 | if (!fi.exists()) { |
296 | Global::statusMessage(tr("Mailbox doesn't exist.")); | 297 | Global::statusMessage(tr("Mailbox doesn't exist.")); |
297 | return 0; | 298 | return 0; |
298 | } | 299 | } |
299 | if (!fi.remove()) { | 300 | if (!fi.remove()) { |
300 | Global::statusMessage(tr("Error deleting Mailbox.")); | 301 | Global::statusMessage(tr("Error deleting Mailbox.")); |
301 | return 0; | 302 | return 0; |
302 | } | 303 | } |
303 | return 1; | 304 | return 1; |
304 | } | 305 | } |
305 | 306 | ||
306 | void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 307 | void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
307 | { | 308 | { |
308 | mailfolder*folder = 0; | 309 | mailfolder*folder = 0; |
309 | mailstorage*storage = mailstorage_new(NULL); | 310 | mailstorage*storage = mailstorage_new(NULL); |
310 | target_stat.message_count = 0; | 311 | target_stat.message_count = 0; |
311 | target_stat.message_unseen = 0; | 312 | target_stat.message_unseen = 0; |
312 | target_stat.message_recent = 0; | 313 | target_stat.message_recent = 0; |
313 | QString p = MBOXPath+"/"+mailbox; | 314 | QString p = MBOXPath+"/"+mailbox; |
314 | QFile fi(p); | 315 | QFile fi(p); |
315 | if (!fi.exists()) { | 316 | if (!fi.exists()) { |
316 | Global::statusMessage(tr("Mailbox doesn't exist.")); | 317 | Global::statusMessage(tr("Mailbox doesn't exist.")); |
317 | return; | 318 | return; |
318 | } | 319 | } |
319 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 320 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
320 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 321 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
321 | r = mailfolder_connect(folder); | 322 | r = mailfolder_connect(folder); |
322 | r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count, | 323 | r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count, |
323 | &target_stat.message_recent,&target_stat.message_unseen); | 324 | &target_stat.message_recent,&target_stat.message_unseen); |
324 | if (folder) mailfolder_free(folder); | 325 | if (folder) mailfolder_free(folder); |
325 | if (storage) mailstorage_free(storage); | 326 | if (storage) mailstorage_free(storage); |
326 | } | 327 | } |
327 | 328 | ||
328 | const QString&MBOXwrapper::getType()const | 329 | const QString&MBOXwrapper::getType()const |
329 | { | 330 | { |
330 | return wrapperType; | 331 | return wrapperType; |
331 | } | 332 | } |
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h index f97fce2..2794014 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.h +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h | |||
@@ -1,44 +1,45 @@ | |||
1 | #ifndef __MBOX_WRAPPER_H | 1 | #ifndef __MBOX_WRAPPER_H |
2 | #define __MBOX_WRAPPER_H | 2 | #define __MBOX_WRAPPER_H |
3 | 3 | ||
4 | #include "genericwrapper.h" | 4 | #include "genericwrapper.h" |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | 6 | ||
7 | class RecMail; | 7 | class RecMail; |
8 | class RecBody; | 8 | class RecBody; |
9 | class encodedString; | ||
9 | struct mailmbox_folder; | 10 | struct mailmbox_folder; |
10 | 11 | ||
11 | class MBOXwrapper : public Genericwrapper | 12 | class MBOXwrapper : public Genericwrapper |
12 | { | 13 | { |
13 | Q_OBJECT | 14 | Q_OBJECT |
14 | public: | 15 | public: |
15 | MBOXwrapper(const QString & dir); | 16 | MBOXwrapper(const QString & dir); |
16 | virtual ~MBOXwrapper(); | 17 | virtual ~MBOXwrapper(); |
17 | 18 | ||
18 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 19 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
19 | virtual QList<Folder>* listFolders(); | 20 | virtual QList<Folder>* listFolders(); |
20 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 21 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
21 | 22 | ||
22 | virtual void deleteMail(const RecMail&mail); | 23 | virtual void deleteMail(const RecMail&mail); |
23 | virtual void answeredMail(const RecMail&mail); | 24 | virtual void answeredMail(const RecMail&mail); |
24 | 25 | ||
25 | virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); | 26 | virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); |
26 | virtual int deleteMbox(const Folder*); | 27 | virtual int deleteMbox(const Folder*); |
27 | 28 | ||
28 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 29 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
29 | 30 | ||
30 | virtual RecBody fetchBody( const RecMail &mail ); | 31 | virtual RecBody fetchBody( const RecMail &mail ); |
31 | static void mbox_progress( size_t current, size_t maximum ); | 32 | static void mbox_progress( size_t current, size_t maximum ); |
32 | 33 | ||
33 | virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); | 34 | virtual encodedString* fetchRawBody(const RecMail&mail); |
34 | virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); | 35 | virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); |
35 | virtual int deleteAllMail(const Folder*); | 36 | virtual int deleteAllMail(const Folder*); |
36 | virtual const QString&getType()const; | 37 | virtual const QString&getType()const; |
37 | 38 | ||
38 | protected: | 39 | protected: |
39 | static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); | 40 | static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); |
40 | QString MBOXPath; | 41 | QString MBOXPath; |
41 | static const QString wrapperType; | 42 | static const QString wrapperType; |
42 | }; | 43 | }; |
43 | 44 | ||
44 | #endif | 45 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index 45408dd..72c145b 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -39,204 +39,211 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) | |||
39 | int err = MAILPOP3_NO_ERROR; | 39 | int err = MAILPOP3_NO_ERROR; |
40 | char *message = 0; | 40 | char *message = 0; |
41 | size_t length = 0; | 41 | size_t length = 0; |
42 | 42 | ||
43 | login(); | 43 | login(); |
44 | if ( !m_pop3 ) { | 44 | if ( !m_pop3 ) { |
45 | return RecBody(); | 45 | return RecBody(); |
46 | } | 46 | } |
47 | 47 | ||
48 | RecBody body; | 48 | RecBody body; |
49 | mailmessage * mailmsg; | 49 | mailmessage * mailmsg; |
50 | if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) { | 50 | if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) { |
51 | qDebug("Message to large: %i",mail.Msgsize()); | 51 | qDebug("Message to large: %i",mail.Msgsize()); |
52 | return body; | 52 | return body; |
53 | } | 53 | } |
54 | 54 | ||
55 | QFile msg_cache(msgTempName); | 55 | QFile msg_cache(msgTempName); |
56 | 56 | ||
57 | cleanMimeCache(); | 57 | cleanMimeCache(); |
58 | 58 | ||
59 | if (mail.getNumber()!=last_msg_id) { | 59 | if (mail.getNumber()!=last_msg_id) { |
60 | if (msg_cache.exists()) { | 60 | if (msg_cache.exists()) { |
61 | msg_cache.remove(); | 61 | msg_cache.remove(); |
62 | } | 62 | } |
63 | msg_cache.open(IO_ReadWrite|IO_Truncate); | 63 | msg_cache.open(IO_ReadWrite|IO_Truncate); |
64 | last_msg_id = mail.getNumber(); | 64 | last_msg_id = mail.getNumber(); |
65 | err = mailsession_get_message(m_folder->fld_session, mail.getNumber(), &mailmsg); | 65 | err = mailsession_get_message(m_folder->fld_session, mail.getNumber(), &mailmsg); |
66 | err = mailmessage_fetch(mailmsg,&message,&length); | 66 | err = mailmessage_fetch(mailmsg,&message,&length); |
67 | msg_cache.writeBlock(message,length); | 67 | msg_cache.writeBlock(message,length); |
68 | } else { | 68 | } else { |
69 | QString msg=""; | 69 | QString msg=""; |
70 | msg_cache.open(IO_ReadOnly); | 70 | msg_cache.open(IO_ReadOnly); |
71 | message = new char[4096]; | 71 | message = new char[4096]; |
72 | memset(message,0,4096); | 72 | memset(message,0,4096); |
73 | while (msg_cache.readBlock(message,4095)>0) { | 73 | while (msg_cache.readBlock(message,4095)>0) { |
74 | msg+=message; | 74 | msg+=message; |
75 | memset(message,0,4096); | 75 | memset(message,0,4096); |
76 | } | 76 | } |
77 | delete message; | 77 | delete message; |
78 | message = (char*)malloc(msg.length()+1*sizeof(char)); | 78 | message = (char*)malloc(msg.length()+1*sizeof(char)); |
79 | memset(message,0,msg.length()+1); | 79 | memset(message,0,msg.length()+1); |
80 | memcpy(message,msg.latin1(),msg.length()); | 80 | memcpy(message,msg.latin1(),msg.length()); |
81 | /* transform to libetpan stuff */ | 81 | /* transform to libetpan stuff */ |
82 | mailmsg = mailmessage_new(); | 82 | mailmsg = mailmessage_new(); |
83 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); | 83 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); |
84 | generic_message_t * msg_data; | 84 | generic_message_t * msg_data; |
85 | msg_data = (generic_message_t *)mailmsg->msg_data; | 85 | msg_data = (generic_message_t *)mailmsg->msg_data; |
86 | msg_data->msg_fetched = 1; | 86 | msg_data->msg_fetched = 1; |
87 | msg_data->msg_message = message; | 87 | msg_data->msg_message = message; |
88 | msg_data->msg_length = strlen(message); | 88 | msg_data->msg_length = strlen(message); |
89 | } | 89 | } |
90 | body = parseMail(mailmsg); | 90 | body = parseMail(mailmsg); |
91 | 91 | ||
92 | /* clean up */ | 92 | /* clean up */ |
93 | if (mailmsg) mailmessage_free(mailmsg); | 93 | if (mailmsg) mailmessage_free(mailmsg); |
94 | if (message) free(message); | 94 | if (message) free(message); |
95 | 95 | ||
96 | return body; | 96 | return body; |
97 | } | 97 | } |
98 | 98 | ||
99 | void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | 99 | void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) |
100 | { | 100 | { |
101 | login(); | 101 | login(); |
102 | if (!m_pop3) return; | 102 | if (!m_pop3) return; |
103 | uint32_t res_messages,res_recent,res_unseen; | 103 | uint32_t res_messages,res_recent,res_unseen; |
104 | mailsession_status_folder(m_folder->fld_session,"INBOX",&res_messages,&res_recent,&res_unseen); | 104 | mailsession_status_folder(m_folder->fld_session,"INBOX",&res_messages,&res_recent,&res_unseen); |
105 | parseList(target,m_folder->fld_session,"INBOX"); | 105 | parseList(target,m_folder->fld_session,"INBOX"); |
106 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); | 106 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); |
107 | } | 107 | } |
108 | 108 | ||
109 | void POP3wrapper::login() | 109 | void POP3wrapper::login() |
110 | { | 110 | { |
111 | /* we'll hold the line */ | 111 | /* we'll hold the line */ |
112 | if ( m_pop3 != NULL ) return; | 112 | if ( m_pop3 != NULL ) return; |
113 | 113 | ||
114 | const char *server, *user, *pass; | 114 | const char *server, *user, *pass; |
115 | uint16_t port; | 115 | uint16_t port; |
116 | int err = MAILPOP3_NO_ERROR; | 116 | int err = MAILPOP3_NO_ERROR; |
117 | 117 | ||
118 | server = account->getServer().latin1(); | 118 | server = account->getServer().latin1(); |
119 | port = account->getPort().toUInt(); | 119 | port = account->getPort().toUInt(); |
120 | 120 | ||
121 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 121 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
122 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 122 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
123 | login.show(); | 123 | login.show(); |
124 | if ( QDialog::Accepted == login.exec() ) { | 124 | if ( QDialog::Accepted == login.exec() ) { |
125 | // ok | 125 | // ok |
126 | user = login.getUser().latin1(); | 126 | user = login.getUser().latin1(); |
127 | pass = login.getPassword().latin1(); | 127 | pass = login.getPassword().latin1(); |
128 | } else { | 128 | } else { |
129 | // cancel | 129 | // cancel |
130 | qDebug( "POP3: Login canceled" ); | 130 | qDebug( "POP3: Login canceled" ); |
131 | return; | 131 | return; |
132 | } | 132 | } |
133 | } else { | 133 | } else { |
134 | user = account->getUser().latin1(); | 134 | user = account->getUser().latin1(); |
135 | pass = account->getPassword().latin1(); | 135 | pass = account->getPassword().latin1(); |
136 | } | 136 | } |
137 | 137 | ||
138 | bool ssl = account->getSSL(); | 138 | bool ssl = account->getSSL(); |
139 | 139 | ||
140 | m_pop3=mailstorage_new(NULL); | 140 | m_pop3=mailstorage_new(NULL); |
141 | pop3_mailstorage_init(m_pop3,(char*)server,port,NULL,CONNECTION_TYPE_TRY_STARTTLS,POP3_AUTH_TYPE_TRY_APOP, | 141 | pop3_mailstorage_init(m_pop3,(char*)server,port,NULL,CONNECTION_TYPE_TRY_STARTTLS,POP3_AUTH_TYPE_TRY_APOP, |
142 | (char*)user,(char*)pass,0,0,0); | 142 | (char*)user,(char*)pass,0,0,0); |
143 | 143 | ||
144 | m_folder = mailfolder_new(m_pop3, NULL, NULL); | 144 | m_folder = mailfolder_new(m_pop3, NULL, NULL); |
145 | 145 | ||
146 | if (m_folder==0) { | 146 | if (m_folder==0) { |
147 | Global::statusMessage(tr("Error initializing folder")); | 147 | Global::statusMessage(tr("Error initializing folder")); |
148 | mailstorage_free(m_pop3); | 148 | mailstorage_free(m_pop3); |
149 | m_pop3 = NULL; | 149 | m_pop3 = NULL; |
150 | return; | 150 | return; |
151 | } | 151 | } |
152 | err = mailfolder_connect(m_folder); | 152 | err = mailfolder_connect(m_folder); |
153 | if (err != MAIL_NO_ERROR) { | 153 | if (err != MAIL_NO_ERROR) { |
154 | Global::statusMessage(tr("Error initializing folder")); | 154 | Global::statusMessage(tr("Error initializing folder")); |
155 | mailfolder_free(m_folder); | 155 | mailfolder_free(m_folder); |
156 | m_folder = 0; | 156 | m_folder = 0; |
157 | mailstorage_free(m_pop3); | 157 | mailstorage_free(m_pop3); |
158 | m_pop3 = 0; | 158 | m_pop3 = 0; |
159 | } | 159 | } |
160 | qDebug( "POP3: logged in!" ); | 160 | qDebug( "POP3: logged in!" ); |
161 | } | 161 | } |
162 | 162 | ||
163 | void POP3wrapper::logout() | 163 | void POP3wrapper::logout() |
164 | { | 164 | { |
165 | int err = MAILPOP3_NO_ERROR; | 165 | int err = MAILPOP3_NO_ERROR; |
166 | if ( m_pop3 == NULL ) return; | 166 | if ( m_pop3 == NULL ) return; |
167 | mailfolder_free(m_folder); | 167 | mailfolder_free(m_folder); |
168 | m_folder = 0; | 168 | m_folder = 0; |
169 | mailstorage_free(m_pop3); | 169 | mailstorage_free(m_pop3); |
170 | m_pop3 = 0; | 170 | m_pop3 = 0; |
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | QList<Folder>* POP3wrapper::listFolders() | 174 | QList<Folder>* POP3wrapper::listFolders() |
175 | { | 175 | { |
176 | QList<Folder> * folders = new QList<Folder>(); | 176 | QList<Folder> * folders = new QList<Folder>(); |
177 | folders->setAutoDelete( false ); | 177 | folders->setAutoDelete( false ); |
178 | Folder*inb=new Folder("INBOX","/"); | 178 | Folder*inb=new Folder("INBOX","/"); |
179 | folders->append(inb); | 179 | folders->append(inb); |
180 | return folders; | 180 | return folders; |
181 | } | 181 | } |
182 | 182 | ||
183 | void POP3wrapper::deleteMail(const RecMail&mail) | 183 | void POP3wrapper::deleteMail(const RecMail&mail) |
184 | { | 184 | { |
185 | login(); | 185 | login(); |
186 | if (!m_pop3) return; | 186 | if (!m_pop3) return; |
187 | int err = mailsession_remove_message(m_folder->fld_session,mail.getNumber()); | 187 | int err = mailsession_remove_message(m_folder->fld_session,mail.getNumber()); |
188 | if (err != MAIL_NO_ERROR) { | 188 | if (err != MAIL_NO_ERROR) { |
189 | Global::statusMessage(tr("error deleting mail")); | 189 | Global::statusMessage(tr("error deleting mail")); |
190 | } | 190 | } |
191 | } | 191 | } |
192 | 192 | ||
193 | void POP3wrapper::answeredMail(const RecMail&) | 193 | void POP3wrapper::answeredMail(const RecMail&) |
194 | { | 194 | { |
195 | } | 195 | } |
196 | 196 | ||
197 | int POP3wrapper::deleteAllMail(const Folder*) | 197 | int POP3wrapper::deleteAllMail(const Folder*) |
198 | { | 198 | { |
199 | login(); | 199 | login(); |
200 | if (!m_pop3) return 0; | 200 | if (!m_pop3) return 0; |
201 | int res = 1; | 201 | int res = 1; |
202 | 202 | ||
203 | uint32_t result = 0; | 203 | uint32_t result = 0; |
204 | int err = mailsession_messages_number(m_folder->fld_session,NULL,&result); | 204 | int err = mailsession_messages_number(m_folder->fld_session,NULL,&result); |
205 | if (err != MAIL_NO_ERROR) { | 205 | if (err != MAIL_NO_ERROR) { |
206 | Global::statusMessage(tr("Error getting folder info")); | 206 | Global::statusMessage(tr("Error getting folder info")); |
207 | return 0; | 207 | return 0; |
208 | } | 208 | } |
209 | for (unsigned int i = 0; i < result; ++i) { | 209 | for (unsigned int i = 0; i < result; ++i) { |
210 | err = mailsession_remove_message(m_folder->fld_session,i+1); | 210 | err = mailsession_remove_message(m_folder->fld_session,i+1); |
211 | if (err != MAIL_NO_ERROR) { | 211 | if (err != MAIL_NO_ERROR) { |
212 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 212 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
213 | res=0; | 213 | res=0; |
214 | } | 214 | } |
215 | break; | 215 | break; |
216 | } | 216 | } |
217 | return res; | 217 | return res; |
218 | } | 218 | } |
219 | 219 | ||
220 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) | 220 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) |
221 | { | 221 | { |
222 | login(); | 222 | login(); |
223 | target_stat.message_count = 0; | 223 | target_stat.message_count = 0; |
224 | target_stat.message_unseen = 0; | 224 | target_stat.message_unseen = 0; |
225 | target_stat.message_recent = 0; | 225 | target_stat.message_recent = 0; |
226 | if (!m_pop3) return; | 226 | if (!m_pop3) return; |
227 | int r = mailsession_status_folder(m_folder->fld_session,0,&target_stat.message_count, | 227 | int r = mailsession_status_folder(m_folder->fld_session,0,&target_stat.message_count, |
228 | &target_stat.message_recent,&target_stat.message_unseen); | 228 | &target_stat.message_recent,&target_stat.message_unseen); |
229 | } | 229 | } |
230 | 230 | ||
231 | void POP3wrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) | 231 | encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) |
232 | { | 232 | { |
233 | char*target=0; | ||
234 | size_t length=0; | ||
235 | encodedString*res = 0; | ||
233 | mailmessage * mailmsg = 0; | 236 | mailmessage * mailmsg = 0; |
234 | int err = mailsession_get_message(m_folder->fld_session, mail.getNumber(), &mailmsg); | 237 | int err = mailsession_get_message(m_folder->fld_session, mail.getNumber(), &mailmsg); |
235 | err = mailmessage_fetch(mailmsg,target,length); | 238 | err = mailmessage_fetch(mailmsg,&target,&length); |
236 | if (mailmsg) mailmessage_free(mailmsg); | 239 | if (mailmsg) mailmessage_free(mailmsg); |
240 | if (target) { | ||
241 | res = new encodedString(target,length); | ||
242 | } | ||
243 | return res; | ||
237 | } | 244 | } |
238 | 245 | ||
239 | const QString&POP3wrapper::getType()const | 246 | const QString&POP3wrapper::getType()const |
240 | { | 247 | { |
241 | return account->getType(); | 248 | return account->getType(); |
242 | } | 249 | } |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h index b7e8f27..f0307b6 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.h +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h | |||
@@ -1,41 +1,42 @@ | |||
1 | #ifndef __POP3WRAPPER | 1 | #ifndef __POP3WRAPPER |
2 | #define __POP3WRAPPER | 2 | #define __POP3WRAPPER |
3 | 3 | ||
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include "genericwrapper.h" | 5 | #include "genericwrapper.h" |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | 7 | ||
8 | class encodedString; | ||
8 | struct mailstorage; | 9 | struct mailstorage; |
9 | struct mailfolder; | 10 | struct mailfolder; |
10 | 11 | ||
11 | class POP3wrapper : public Genericwrapper | 12 | class POP3wrapper : public Genericwrapper |
12 | { | 13 | { |
13 | Q_OBJECT | 14 | Q_OBJECT |
14 | 15 | ||
15 | public: | 16 | public: |
16 | POP3wrapper( POP3account *a ); | 17 | POP3wrapper( POP3account *a ); |
17 | virtual ~POP3wrapper(); | 18 | virtual ~POP3wrapper(); |
18 | /* mailbox will be ignored */ | 19 | /* mailbox will be ignored */ |
19 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 20 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
20 | virtual QList<Folder>* listFolders(); | 21 | virtual QList<Folder>* listFolders(); |
21 | /* mailbox will be ignored */ | 22 | /* mailbox will be ignored */ |
22 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 23 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
23 | 24 | ||
24 | virtual void deleteMail(const RecMail&mail); | 25 | virtual void deleteMail(const RecMail&mail); |
25 | virtual void answeredMail(const RecMail&mail); | 26 | virtual void answeredMail(const RecMail&mail); |
26 | virtual int deleteAllMail(const Folder*); | 27 | virtual int deleteAllMail(const Folder*); |
27 | 28 | ||
28 | virtual RecBody fetchBody( const RecMail &mail ); | 29 | virtual RecBody fetchBody( const RecMail &mail ); |
29 | virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); | 30 | virtual encodedString* fetchRawBody(const RecMail&mail); |
30 | virtual void logout(); | 31 | virtual void logout(); |
31 | virtual const QString&getType()const; | 32 | virtual const QString&getType()const; |
32 | static void pop3_progress( size_t current, size_t maximum ); | 33 | static void pop3_progress( size_t current, size_t maximum ); |
33 | 34 | ||
34 | protected: | 35 | protected: |
35 | void login(); | 36 | void login(); |
36 | POP3account *account; | 37 | POP3account *account; |
37 | mailstorage*m_pop3; | 38 | mailstorage*m_pop3; |
38 | mailfolder*m_folder; | 39 | mailfolder*m_folder; |
39 | }; | 40 | }; |
40 | 41 | ||
41 | #endif | 42 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp index e054365..00181ff 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp | |||
@@ -296,439 +296,436 @@ mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimety | |||
296 | } else { | 296 | } else { |
297 | err = mailmime_set_body_text(filePart,strdup(TextContent.data()),TextContent.length()); | 297 | err = mailmime_set_body_text(filePart,strdup(TextContent.data()),TextContent.length()); |
298 | } | 298 | } |
299 | if (err != MAILIMF_NO_ERROR) { | 299 | if (err != MAILIMF_NO_ERROR) { |
300 | qDebug("Error setting body with file %s",file); | 300 | qDebug("Error setting body with file %s",file); |
301 | mailmime_free( filePart ); | 301 | mailmime_free( filePart ); |
302 | filePart = 0; | 302 | filePart = 0; |
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | if (!filePart) { | 306 | if (!filePart) { |
307 | if ( param != NULL ) { | 307 | if ( param != NULL ) { |
308 | mailmime_parameter_free( param ); | 308 | mailmime_parameter_free( param ); |
309 | } | 309 | } |
310 | if (content) { | 310 | if (content) { |
311 | mailmime_content_free( content ); | 311 | mailmime_content_free( content ); |
312 | } | 312 | } |
313 | if (fields) { | 313 | if (fields) { |
314 | mailmime_fields_free( fields ); | 314 | mailmime_fields_free( fields ); |
315 | } else { | 315 | } else { |
316 | if (name) { | 316 | if (name) { |
317 | free( name ); | 317 | free( name ); |
318 | } | 318 | } |
319 | if (file) { | 319 | if (file) { |
320 | free( file ); | 320 | free( file ); |
321 | } | 321 | } |
322 | } | 322 | } |
323 | } | 323 | } |
324 | return filePart; // Success :) | 324 | return filePart; // Success :) |
325 | 325 | ||
326 | } | 326 | } |
327 | 327 | ||
328 | void SMTPwrapper::addFileParts( mailmime *message,const QList<Attachment>&files ) | 328 | void SMTPwrapper::addFileParts( mailmime *message,const QList<Attachment>&files ) |
329 | { | 329 | { |
330 | const Attachment *it; | 330 | const Attachment *it; |
331 | unsigned int count = files.count(); | 331 | unsigned int count = files.count(); |
332 | qDebug("List contains %i values",count); | 332 | qDebug("List contains %i values",count); |
333 | for ( unsigned int i = 0; i < count; ++i ) { | 333 | for ( unsigned int i = 0; i < count; ++i ) { |
334 | qDebug( "Adding file" ); | 334 | qDebug( "Adding file" ); |
335 | mailmime *filePart; | 335 | mailmime *filePart; |
336 | int err; | 336 | int err; |
337 | it = ((QList<Attachment>)files).at(i); | 337 | it = ((QList<Attachment>)files).at(i); |
338 | 338 | ||
339 | filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" ); | 339 | filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" ); |
340 | if ( filePart == NULL ) { | 340 | if ( filePart == NULL ) { |
341 | qDebug( "addFileParts: error adding file:" ); | 341 | qDebug( "addFileParts: error adding file:" ); |
342 | qDebug( it->getFileName() ); | 342 | qDebug( it->getFileName() ); |
343 | continue; | 343 | continue; |
344 | } | 344 | } |
345 | err = mailmime_smart_add_part( message, filePart ); | 345 | err = mailmime_smart_add_part( message, filePart ); |
346 | if ( err != MAILIMF_NO_ERROR ) { | 346 | if ( err != MAILIMF_NO_ERROR ) { |
347 | mailmime_free( filePart ); | 347 | mailmime_free( filePart ); |
348 | qDebug("error smart add"); | 348 | qDebug("error smart add"); |
349 | } | 349 | } |
350 | } | 350 | } |
351 | } | 351 | } |
352 | 352 | ||
353 | mailmime *SMTPwrapper::createMimeMail(const Mail &mail ) | 353 | mailmime *SMTPwrapper::createMimeMail(const Mail &mail ) |
354 | { | 354 | { |
355 | mailmime *message, *txtPart; | 355 | mailmime *message, *txtPart; |
356 | mailimf_fields *fields; | 356 | mailimf_fields *fields; |
357 | int err; | 357 | int err; |
358 | 358 | ||
359 | fields = createImfFields( mail ); | 359 | fields = createImfFields( mail ); |
360 | if ( fields == NULL ) goto err_free; | 360 | if ( fields == NULL ) goto err_free; |
361 | 361 | ||
362 | message = mailmime_new_message_data( NULL ); | 362 | message = mailmime_new_message_data( NULL ); |
363 | if ( message == NULL ) goto err_free_fields; | 363 | if ( message == NULL ) goto err_free_fields; |
364 | 364 | ||
365 | mailmime_set_imf_fields( message, fields ); | 365 | mailmime_set_imf_fields( message, fields ); |
366 | 366 | ||
367 | txtPart = buildTxtPart( mail.getMessage() ); | 367 | txtPart = buildTxtPart( mail.getMessage() ); |
368 | 368 | ||
369 | if ( txtPart == NULL ) goto err_free_message; | 369 | if ( txtPart == NULL ) goto err_free_message; |
370 | 370 | ||
371 | err = mailmime_smart_add_part( message, txtPart ); | 371 | err = mailmime_smart_add_part( message, txtPart ); |
372 | if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; | 372 | if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; |
373 | 373 | ||
374 | addFileParts( message, mail.getAttachments() ); | 374 | addFileParts( message, mail.getAttachments() ); |
375 | 375 | ||
376 | return message; // Success :) | 376 | return message; // Success :) |
377 | 377 | ||
378 | err_free_txtPart: | 378 | err_free_txtPart: |
379 | mailmime_free( txtPart ); | 379 | mailmime_free( txtPart ); |
380 | err_free_message: | 380 | err_free_message: |
381 | mailmime_free( message ); | 381 | mailmime_free( message ); |
382 | err_free_fields: | 382 | err_free_fields: |
383 | mailimf_fields_free( fields ); | 383 | mailimf_fields_free( fields ); |
384 | err_free: | 384 | err_free: |
385 | qDebug( "createMimeMail: error" ); | 385 | qDebug( "createMimeMail: error" ); |
386 | 386 | ||
387 | return NULL; // Error :( | 387 | return NULL; // Error :( |
388 | } | 388 | } |
389 | 389 | ||
390 | mailimf_field *SMTPwrapper::getField( mailimf_fields *fields, int type ) | 390 | mailimf_field *SMTPwrapper::getField( mailimf_fields *fields, int type ) |
391 | { | 391 | { |
392 | mailimf_field *field; | 392 | mailimf_field *field; |
393 | clistiter *it; | 393 | clistiter *it; |
394 | 394 | ||
395 | it = clist_begin( fields->fld_list ); | 395 | it = clist_begin( fields->fld_list ); |
396 | while ( it ) { | 396 | while ( it ) { |
397 | field = (mailimf_field *) it->data; | 397 | field = (mailimf_field *) it->data; |
398 | if ( field->fld_type == type ) { | 398 | if ( field->fld_type == type ) { |
399 | return field; | 399 | return field; |
400 | } | 400 | } |
401 | it = it->next; | 401 | it = it->next; |
402 | } | 402 | } |
403 | 403 | ||
404 | return NULL; | 404 | return NULL; |
405 | } | 405 | } |
406 | 406 | ||
407 | void SMTPwrapper::addRcpts( clist *list, mailimf_address_list *addr_list ) | 407 | void SMTPwrapper::addRcpts( clist *list, mailimf_address_list *addr_list ) |
408 | { | 408 | { |
409 | clistiter *it, *it2; | 409 | clistiter *it, *it2; |
410 | 410 | ||
411 | for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { | 411 | for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { |
412 | mailimf_address *addr; | 412 | mailimf_address *addr; |
413 | addr = (mailimf_address *) it->data; | 413 | addr = (mailimf_address *) it->data; |
414 | 414 | ||
415 | if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { | 415 | if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { |
416 | esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); | 416 | esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); |
417 | } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { | 417 | } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { |
418 | clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; | 418 | clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; |
419 | for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { | 419 | for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { |
420 | mailimf_mailbox *mbox; | 420 | mailimf_mailbox *mbox; |
421 | mbox = (mailimf_mailbox *) it2->data; | 421 | mbox = (mailimf_mailbox *) it2->data; |
422 | esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL ); | 422 | esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL ); |
423 | } | 423 | } |
424 | } | 424 | } |
425 | } | 425 | } |
426 | } | 426 | } |
427 | 427 | ||
428 | clist *SMTPwrapper::createRcptList( mailimf_fields *fields ) | 428 | clist *SMTPwrapper::createRcptList( mailimf_fields *fields ) |
429 | { | 429 | { |
430 | clist *rcptList; | 430 | clist *rcptList; |
431 | mailimf_field *field; | 431 | mailimf_field *field; |
432 | 432 | ||
433 | rcptList = esmtp_address_list_new(); | 433 | rcptList = esmtp_address_list_new(); |
434 | 434 | ||
435 | field = getField( fields, MAILIMF_FIELD_TO ); | 435 | field = getField( fields, MAILIMF_FIELD_TO ); |
436 | if ( field && (field->fld_type == MAILIMF_FIELD_TO) | 436 | if ( field && (field->fld_type == MAILIMF_FIELD_TO) |
437 | && field->fld_data.fld_to->to_addr_list ) { | 437 | && field->fld_data.fld_to->to_addr_list ) { |
438 | addRcpts( rcptList, field->fld_data.fld_to->to_addr_list ); | 438 | addRcpts( rcptList, field->fld_data.fld_to->to_addr_list ); |
439 | } | 439 | } |
440 | 440 | ||
441 | field = getField( fields, MAILIMF_FIELD_CC ); | 441 | field = getField( fields, MAILIMF_FIELD_CC ); |
442 | if ( field && (field->fld_type == MAILIMF_FIELD_CC) | 442 | if ( field && (field->fld_type == MAILIMF_FIELD_CC) |
443 | && field->fld_data.fld_cc->cc_addr_list ) { | 443 | && field->fld_data.fld_cc->cc_addr_list ) { |
444 | addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list ); | 444 | addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list ); |
445 | } | 445 | } |
446 | 446 | ||
447 | field = getField( fields, MAILIMF_FIELD_BCC ); | 447 | field = getField( fields, MAILIMF_FIELD_BCC ); |
448 | if ( field && (field->fld_type == MAILIMF_FIELD_BCC) | 448 | if ( field && (field->fld_type == MAILIMF_FIELD_BCC) |
449 | && field->fld_data.fld_bcc->bcc_addr_list ) { | 449 | && field->fld_data.fld_bcc->bcc_addr_list ) { |
450 | addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list ); | 450 | addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list ); |
451 | } | 451 | } |
452 | 452 | ||
453 | return rcptList; | 453 | return rcptList; |
454 | } | 454 | } |
455 | 455 | ||
456 | char *SMTPwrapper::getFrom( mailimf_field *ffrom) | 456 | char *SMTPwrapper::getFrom( mailimf_field *ffrom) |
457 | { | 457 | { |
458 | char *from = NULL; | 458 | char *from = NULL; |
459 | if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM) | 459 | if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM) |
460 | && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) { | 460 | && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) { |
461 | clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list; | 461 | clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list; |
462 | clistiter *it; | 462 | clistiter *it; |
463 | for ( it = clist_begin( cl ); it; it = it->next ) { | 463 | for ( it = clist_begin( cl ); it; it = it->next ) { |
464 | mailimf_mailbox *mb = (mailimf_mailbox *) it->data; | 464 | mailimf_mailbox *mb = (mailimf_mailbox *) it->data; |
465 | from = strdup( mb->mb_addr_spec ); | 465 | from = strdup( mb->mb_addr_spec ); |
466 | } | 466 | } |
467 | } | 467 | } |
468 | 468 | ||
469 | return from; | 469 | return from; |
470 | } | 470 | } |
471 | 471 | ||
472 | char *SMTPwrapper::getFrom( mailmime *mail ) | 472 | char *SMTPwrapper::getFrom( mailmime *mail ) |
473 | { | 473 | { |
474 | /* no need to delete - its just a pointer to structure content */ | 474 | /* no need to delete - its just a pointer to structure content */ |
475 | mailimf_field *ffrom = 0; | 475 | mailimf_field *ffrom = 0; |
476 | ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); | 476 | ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); |
477 | return getFrom(ffrom); | 477 | return getFrom(ffrom); |
478 | } | 478 | } |
479 | 479 | ||
480 | void SMTPwrapper::progress( size_t current, size_t maximum ) | 480 | void SMTPwrapper::progress( size_t current, size_t maximum ) |
481 | { | 481 | { |
482 | if (SMTPwrapper::sendProgress) { | 482 | if (SMTPwrapper::sendProgress) { |
483 | SMTPwrapper::sendProgress->setSingleMail(current, maximum ); | 483 | SMTPwrapper::sendProgress->setSingleMail(current, maximum ); |
484 | qApp->processEvents(); | 484 | qApp->processEvents(); |
485 | } | 485 | } |
486 | } | 486 | } |
487 | 487 | ||
488 | void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box) | 488 | void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) |
489 | { | 489 | { |
490 | if (!mail) return; | 490 | if (!mail) return; |
491 | QString localfolders = AbstractMail::defaultLocalfolder(); | 491 | QString localfolders = AbstractMail::defaultLocalfolder(); |
492 | MBOXwrapper*wrap = new MBOXwrapper(localfolders); | 492 | MBOXwrapper*wrap = new MBOXwrapper(localfolders); |
493 | wrap->storeMessage(mail,length,box); | 493 | wrap->storeMessage(mail,length,box); |
494 | delete wrap; | 494 | delete wrap; |
495 | } | 495 | } |
496 | 496 | ||
497 | void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) | 497 | void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) |
498 | { | 498 | { |
499 | clist *rcpts = 0; | 499 | clist *rcpts = 0; |
500 | char *from, *data; | 500 | char *from, *data; |
501 | size_t size; | 501 | size_t size; |
502 | 502 | ||
503 | if ( smtp == NULL ) { | 503 | if ( smtp == NULL ) { |
504 | return; | 504 | return; |
505 | } | 505 | } |
506 | from = data = 0; | 506 | from = data = 0; |
507 | 507 | ||
508 | mailmessage * msg = 0; | 508 | mailmessage * msg = 0; |
509 | msg = mime_message_init(mail); | 509 | msg = mime_message_init(mail); |
510 | mime_message_set_tmpdir(msg,getenv( "HOME" )); | 510 | mime_message_set_tmpdir(msg,getenv( "HOME" )); |
511 | int r = mailmessage_fetch(msg,&data,&size); | 511 | int r = mailmessage_fetch(msg,&data,&size); |
512 | mime_message_detach_mime(msg); | 512 | mime_message_detach_mime(msg); |
513 | mailmessage_free(msg); | 513 | mailmessage_free(msg); |
514 | if (r != MAIL_NO_ERROR || !data) { | 514 | if (r != MAIL_NO_ERROR || !data) { |
515 | if (data) free(data); | 515 | if (data) free(data); |
516 | qDebug("Error fetching mime..."); | 516 | qDebug("Error fetching mime..."); |
517 | return; | 517 | return; |
518 | } | 518 | } |
519 | QString tmp = data; | 519 | QString tmp = data; |
520 | tmp.replace(QRegExp("\r+",true,false),""); | 520 | tmp.replace(QRegExp("\r+",true,false),""); |
521 | msg = 0; | 521 | msg = 0; |
522 | if (later) { | 522 | if (later) { |
523 | storeMail((char*)tmp.data(),tmp.length(),"Outgoing"); | 523 | storeMail((char*)tmp.data(),tmp.length(),"Outgoing"); |
524 | if (data) free( data ); | 524 | if (data) free( data ); |
525 | Config cfg( "mail" ); | 525 | Config cfg( "mail" ); |
526 | cfg.setGroup( "Status" ); | 526 | cfg.setGroup( "Status" ); |
527 | cfg.writeEntry( "outgoing", ++m_queuedMail ); | 527 | cfg.writeEntry( "outgoing", ++m_queuedMail ); |
528 | emit queuedMails( m_queuedMail ); | 528 | emit queuedMails( m_queuedMail ); |
529 | return; | 529 | return; |
530 | } | 530 | } |
531 | from = getFrom( mail ); | 531 | from = getFrom( mail ); |
532 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); | 532 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); |
533 | smtpSend(from,rcpts,data,size,smtp); | 533 | smtpSend(from,rcpts,data,size,smtp); |
534 | if (data) {free(data);} | 534 | if (data) {free(data);} |
535 | if (from) {free(from);} | 535 | if (from) {free(from);} |
536 | if (rcpts) smtp_address_list_free( rcpts ); | 536 | if (rcpts) smtp_address_list_free( rcpts ); |
537 | } | 537 | } |
538 | 538 | ||
539 | int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ) | 539 | int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMTPaccount *smtp ) |
540 | { | 540 | { |
541 | char *server, *user, *pass; | 541 | char *server, *user, *pass; |
542 | bool ssl; | 542 | bool ssl; |
543 | uint16_t port; | 543 | uint16_t port; |
544 | mailsmtp *session; | 544 | mailsmtp *session; |
545 | int err,result; | 545 | int err,result; |
546 | 546 | ||
547 | result = 1; | 547 | result = 1; |
548 | server = user = pass = 0; | 548 | server = user = pass = 0; |
549 | server = strdup( smtp->getServer().latin1() ); | 549 | server = strdup( smtp->getServer().latin1() ); |
550 | ssl = smtp->getSSL(); | 550 | ssl = smtp->getSSL(); |
551 | port = smtp->getPort().toUInt(); | 551 | port = smtp->getPort().toUInt(); |
552 | 552 | ||
553 | session = mailsmtp_new( 20, &progress ); | 553 | session = mailsmtp_new( 20, &progress ); |
554 | if ( session == NULL ) goto free_mem; | 554 | if ( session == NULL ) goto free_mem; |
555 | 555 | ||
556 | qDebug( "Servername %s at port %i", server, port ); | 556 | qDebug( "Servername %s at port %i", server, port ); |
557 | if ( ssl ) { | 557 | if ( ssl ) { |
558 | qDebug( "SSL session" ); | 558 | qDebug( "SSL session" ); |
559 | err = mailsmtp_ssl_connect( session, server, port ); | 559 | err = mailsmtp_ssl_connect( session, server, port ); |
560 | } else { | 560 | } else { |
561 | qDebug( "No SSL session" ); | 561 | qDebug( "No SSL session" ); |
562 | err = mailsmtp_socket_connect( session, server, port ); | 562 | err = mailsmtp_socket_connect( session, server, port ); |
563 | } | 563 | } |
564 | if ( err != MAILSMTP_NO_ERROR ) {result = 0;goto free_mem_session;} | 564 | if ( err != MAILSMTP_NO_ERROR ) {result = 0;goto free_mem_session;} |
565 | 565 | ||
566 | err = mailsmtp_init( session ); | 566 | err = mailsmtp_init( session ); |
567 | if ( err != MAILSMTP_NO_ERROR ) {result = 0; goto free_con_session;} | 567 | if ( err != MAILSMTP_NO_ERROR ) {result = 0; goto free_con_session;} |
568 | 568 | ||
569 | qDebug( "INIT OK" ); | 569 | qDebug( "INIT OK" ); |
570 | 570 | ||
571 | if ( smtp->getLogin() ) { | 571 | if ( smtp->getLogin() ) { |
572 | if ( smtp->getUser().isEmpty() || smtp->getPassword().isEmpty() ) { | 572 | if ( smtp->getUser().isEmpty() || smtp->getPassword().isEmpty() ) { |
573 | // get'em | 573 | // get'em |
574 | LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true ); | 574 | LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true ); |
575 | login.show(); | 575 | login.show(); |
576 | if ( QDialog::Accepted == login.exec() ) { | 576 | if ( QDialog::Accepted == login.exec() ) { |
577 | // ok | 577 | // ok |
578 | user = strdup( login.getUser().latin1() ); | 578 | user = strdup( login.getUser().latin1() ); |
579 | pass = strdup( login.getPassword().latin1() ); | 579 | pass = strdup( login.getPassword().latin1() ); |
580 | } else { | 580 | } else { |
581 | result = 0; goto free_con_session; | 581 | result = 0; goto free_con_session; |
582 | } | 582 | } |
583 | } else { | 583 | } else { |
584 | user = strdup( smtp->getUser().latin1() ); | 584 | user = strdup( smtp->getUser().latin1() ); |
585 | pass = strdup( smtp->getPassword().latin1() ); | 585 | pass = strdup( smtp->getPassword().latin1() ); |
586 | } | 586 | } |
587 | qDebug( "session->auth: %i", session->auth); | 587 | qDebug( "session->auth: %i", session->auth); |
588 | err = mailsmtp_auth( session, user, pass ); | 588 | err = mailsmtp_auth( session, user, pass ); |
589 | if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok"); | 589 | if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok"); |
590 | qDebug( "Done auth!" ); | 590 | qDebug( "Done auth!" ); |
591 | } | 591 | } |
592 | 592 | ||
593 | err = mailsmtp_send( session, from, rcpts, data, size ); | 593 | err = mailsmtp_send( session, from, rcpts, data, size ); |
594 | if ( err != MAILSMTP_NO_ERROR ) { | 594 | if ( err != MAILSMTP_NO_ERROR ) { |
595 | qDebug("Error sending mail: %s",mailsmtpError(err).latin1()); | 595 | qDebug("Error sending mail: %s",mailsmtpError(err).latin1()); |
596 | result = 0; goto free_con_session; | 596 | result = 0; goto free_con_session; |
597 | } | 597 | } |
598 | 598 | ||
599 | qDebug( "Mail sent." ); | 599 | qDebug( "Mail sent." ); |
600 | storeMail(data,size,"Sent"); | 600 | storeMail(data,size,"Sent"); |
601 | 601 | ||
602 | free_con_session: | 602 | free_con_session: |
603 | mailsmtp_quit( session ); | 603 | mailsmtp_quit( session ); |
604 | free_mem_session: | 604 | free_mem_session: |
605 | mailsmtp_free( session ); | 605 | mailsmtp_free( session ); |
606 | free_mem: | 606 | free_mem: |
607 | if (server) free( server ); | 607 | if (server) free( server ); |
608 | if ( smtp->getLogin() ) { | 608 | if ( smtp->getLogin() ) { |
609 | free( user ); | 609 | free( user ); |
610 | free( pass ); | 610 | free( pass ); |
611 | } | 611 | } |
612 | return result; | 612 | return result; |
613 | } | 613 | } |
614 | 614 | ||
615 | void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later ) | 615 | void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later ) |
616 | { | 616 | { |
617 | mailmime * mimeMail; | 617 | mailmime * mimeMail; |
618 | 618 | ||
619 | SMTPaccount *smtp = aSmtp; | 619 | SMTPaccount *smtp = aSmtp; |
620 | 620 | ||
621 | if (!later && !smtp) { | 621 | if (!later && !smtp) { |
622 | qDebug("Didn't get any send method - giving up"); | 622 | qDebug("Didn't get any send method - giving up"); |
623 | return; | 623 | return; |
624 | } | 624 | } |
625 | mimeMail = createMimeMail(mail ); | 625 | mimeMail = createMimeMail(mail ); |
626 | if ( mimeMail == NULL ) { | 626 | if ( mimeMail == NULL ) { |
627 | qDebug( "sendMail: error creating mime mail" ); | 627 | qDebug( "sendMail: error creating mime mail" ); |
628 | } else { | 628 | } else { |
629 | sendProgress = new progressMailSend(); | 629 | sendProgress = new progressMailSend(); |
630 | sendProgress->show(); | 630 | sendProgress->show(); |
631 | sendProgress->setMaxMails(1); | 631 | sendProgress->setMaxMails(1); |
632 | smtpSend( mimeMail,later,smtp); | 632 | smtpSend( mimeMail,later,smtp); |
633 | qDebug("Clean up done"); | 633 | qDebug("Clean up done"); |
634 | sendProgress->hide(); | 634 | sendProgress->hide(); |
635 | delete sendProgress; | 635 | delete sendProgress; |
636 | sendProgress = 0; | 636 | sendProgress = 0; |
637 | mailmime_free( mimeMail ); | 637 | mailmime_free( mimeMail ); |
638 | } | 638 | } |
639 | } | 639 | } |
640 | 640 | ||
641 | int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) | 641 | int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) |
642 | { | 642 | { |
643 | char*data = 0; | ||
644 | size_t length = 0; | ||
645 | size_t curTok = 0; | 643 | size_t curTok = 0; |
646 | mailimf_fields *fields = 0; | 644 | mailimf_fields *fields = 0; |
647 | mailimf_field*ffrom = 0; | 645 | mailimf_field*ffrom = 0; |
648 | clist *rcpts = 0; | 646 | clist *rcpts = 0; |
649 | char*from = 0; | 647 | char*from = 0; |
650 | int res = 0; | 648 | int res = 0; |
651 | 649 | ||
652 | wrap->fetchRawBody(*which,&data,&length); | 650 | encodedString * data = wrap->fetchRawBody(*which); |
653 | if (!data) return 0; | 651 | if (!data) return 0; |
654 | int err = mailimf_fields_parse( data, length, &curTok, &fields ); | 652 | int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields ); |
655 | if (err != MAILIMF_NO_ERROR) { | 653 | if (err != MAILIMF_NO_ERROR) { |
656 | free(data); | 654 | delete data; |
657 | delete wrap; | 655 | delete wrap; |
658 | return 0; | 656 | return 0; |
659 | } | 657 | } |
660 | 658 | ||
661 | rcpts = createRcptList( fields ); | 659 | rcpts = createRcptList( fields ); |
662 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); | 660 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); |
663 | from = getFrom(ffrom); | 661 | from = getFrom(ffrom); |
664 | 662 | ||
665 | qDebug("Size: %i vs. %i",length,strlen(data)); | ||
666 | if (rcpts && from) { | 663 | if (rcpts && from) { |
667 | res = smtpSend(from,rcpts,data,length,smtp ); | 664 | res = smtpSend(from,rcpts,data->Content(),data->Length(),smtp ); |
668 | } | 665 | } |
669 | if (fields) { | 666 | if (fields) { |
670 | mailimf_fields_free(fields); | 667 | mailimf_fields_free(fields); |
671 | fields = 0; | 668 | fields = 0; |
672 | } | 669 | } |
673 | if (data) { | 670 | if (data) { |
674 | free(data); | 671 | delete data; |
675 | } | 672 | } |
676 | if (from) { | 673 | if (from) { |
677 | free(from); | 674 | free(from); |
678 | } | 675 | } |
679 | if (rcpts) { | 676 | if (rcpts) { |
680 | smtp_address_list_free( rcpts ); | 677 | smtp_address_list_free( rcpts ); |
681 | } | 678 | } |
682 | return res; | 679 | return res; |
683 | } | 680 | } |
684 | 681 | ||
685 | /* this is a special fun */ | 682 | /* this is a special fun */ |
686 | bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) | 683 | bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) |
687 | { | 684 | { |
688 | bool returnValue = true; | 685 | bool returnValue = true; |
689 | 686 | ||
690 | if (!smtp) return false; | 687 | if (!smtp) return false; |
691 | 688 | ||
692 | QString localfolders = AbstractMail::defaultLocalfolder(); | 689 | QString localfolders = AbstractMail::defaultLocalfolder(); |
693 | MBOXwrapper*wrap = new MBOXwrapper(localfolders); | 690 | MBOXwrapper*wrap = new MBOXwrapper(localfolders); |
694 | if (!wrap) { | 691 | if (!wrap) { |
695 | qDebug("memory error"); | 692 | qDebug("memory error"); |
696 | return false; | 693 | return false; |
697 | } | 694 | } |
698 | QList<RecMail> mailsToSend; | 695 | QList<RecMail> mailsToSend; |
699 | QList<RecMail> mailsToRemove; | 696 | QList<RecMail> mailsToRemove; |
700 | QString mbox("Outgoing"); | 697 | QString mbox("Outgoing"); |
701 | wrap->listMessages(mbox,mailsToSend); | 698 | wrap->listMessages(mbox,mailsToSend); |
702 | if (mailsToSend.count()==0) { | 699 | if (mailsToSend.count()==0) { |
703 | delete wrap; | 700 | delete wrap; |
704 | return false; | 701 | return false; |
705 | } | 702 | } |
706 | mailsToSend.setAutoDelete(false); | 703 | mailsToSend.setAutoDelete(false); |
707 | sendProgress = new progressMailSend(); | 704 | sendProgress = new progressMailSend(); |
708 | sendProgress->show(); | 705 | sendProgress->show(); |
709 | sendProgress->setMaxMails(mailsToSend.count()); | 706 | sendProgress->setMaxMails(mailsToSend.count()); |
710 | 707 | ||
711 | while (mailsToSend.count()>0) { | 708 | while (mailsToSend.count()>0) { |
712 | if (sendQueuedMail(wrap,smtp,mailsToSend.at(0))==0) { | 709 | if (sendQueuedMail(wrap,smtp,mailsToSend.at(0))==0) { |
713 | QMessageBox::critical(0,tr("Error sending mail"), | 710 | QMessageBox::critical(0,tr("Error sending mail"), |
714 | tr("Error sending queued mail - breaking")); | 711 | tr("Error sending queued mail - breaking")); |
715 | returnValue = false; | 712 | returnValue = false; |
716 | break; | 713 | break; |
717 | } | 714 | } |
718 | mailsToRemove.append(mailsToSend.at(0)); | 715 | mailsToRemove.append(mailsToSend.at(0)); |
719 | mailsToSend.removeFirst(); | 716 | mailsToSend.removeFirst(); |
720 | sendProgress->setCurrentMails(mailsToRemove.count()); | 717 | sendProgress->setCurrentMails(mailsToRemove.count()); |
721 | } | 718 | } |
722 | Config cfg( "mail" ); | 719 | Config cfg( "mail" ); |
723 | cfg.setGroup( "Status" ); | 720 | cfg.setGroup( "Status" ); |
724 | m_queuedMail = 0; | 721 | m_queuedMail = 0; |
725 | cfg.writeEntry( "outgoing", m_queuedMail ); | 722 | cfg.writeEntry( "outgoing", m_queuedMail ); |
726 | emit queuedMails( m_queuedMail ); | 723 | emit queuedMails( m_queuedMail ); |
727 | sendProgress->hide(); | 724 | sendProgress->hide(); |
728 | delete sendProgress; | 725 | delete sendProgress; |
729 | sendProgress = 0; | 726 | sendProgress = 0; |
730 | wrap->deleteMails(mbox,mailsToRemove); | 727 | wrap->deleteMails(mbox,mailsToRemove); |
731 | mailsToSend.setAutoDelete(true); | 728 | mailsToSend.setAutoDelete(true); |
732 | delete wrap; | 729 | delete wrap; |
733 | return returnValue; | 730 | return returnValue; |
734 | } | 731 | } |
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.h b/noncore/net/mail/libmailwrapper/smtpwrapper.h index 4a4352f..04fc4b0 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.h +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h | |||
@@ -1,72 +1,72 @@ | |||
1 | #ifndef SMTPwrapper_H | 1 | #ifndef SMTPwrapper_H |
2 | #define SMTPwrapper_H | 2 | #define SMTPwrapper_H |
3 | 3 | ||
4 | #include <qpe/applnk.h> | 4 | #include <qpe/applnk.h> |
5 | 5 | ||
6 | #include <qbitarray.h> | 6 | #include <qbitarray.h> |
7 | #include <qdatetime.h> | 7 | #include <qdatetime.h> |
8 | #include <libetpan/clist.h> | 8 | #include <libetpan/clist.h> |
9 | 9 | ||
10 | #include "settings.h" | 10 | #include "settings.h" |
11 | 11 | ||
12 | class Mail; | 12 | class Mail; |
13 | class MBOXwrapper; | 13 | class MBOXwrapper; |
14 | class RecMail; | 14 | class RecMail; |
15 | class Attachment; | 15 | class Attachment; |
16 | struct mailimf_fields; | 16 | struct mailimf_fields; |
17 | struct mailimf_field; | 17 | struct mailimf_field; |
18 | struct mailimf_mailbox; | 18 | struct mailimf_mailbox; |
19 | struct mailmime; | 19 | struct mailmime; |
20 | struct mailimf_address_list; | 20 | struct mailimf_address_list; |
21 | class progressMailSend; | 21 | class progressMailSend; |
22 | 22 | ||
23 | class SMTPwrapper : public QObject | 23 | class SMTPwrapper : public QObject |
24 | { | 24 | { |
25 | Q_OBJECT | 25 | Q_OBJECT |
26 | 26 | ||
27 | public: | 27 | public: |
28 | SMTPwrapper( Settings *s ); | 28 | SMTPwrapper( Settings *s ); |
29 | virtual ~SMTPwrapper(){} | 29 | virtual ~SMTPwrapper(){} |
30 | void sendMail(const Mail& mail,SMTPaccount*smtp,bool later=false ); | 30 | void sendMail(const Mail& mail,SMTPaccount*smtp,bool later=false ); |
31 | bool flushOutbox(SMTPaccount*smtp); | 31 | bool flushOutbox(SMTPaccount*smtp); |
32 | 32 | ||
33 | static progressMailSend*sendProgress; | 33 | static progressMailSend*sendProgress; |
34 | 34 | ||
35 | signals: | 35 | signals: |
36 | void queuedMails( int ); | 36 | void queuedMails( int ); |
37 | 37 | ||
38 | protected: | 38 | protected: |
39 | mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); | 39 | mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); |
40 | mailimf_fields *createImfFields(const Mail &mail ); | 40 | mailimf_fields *createImfFields(const Mail &mail ); |
41 | mailmime *createMimeMail(const Mail&mail ); | 41 | mailmime *createMimeMail(const Mail&mail ); |
42 | 42 | ||
43 | mailimf_address_list *parseAddresses(const QString&addr ); | 43 | mailimf_address_list *parseAddresses(const QString&addr ); |
44 | void addFileParts( mailmime *message,const QList<Attachment>&files ); | 44 | void addFileParts( mailmime *message,const QList<Attachment>&files ); |
45 | mailmime *buildTxtPart(const QString&str ); | 45 | mailmime *buildTxtPart(const QString&str ); |
46 | mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); | 46 | mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); |
47 | void smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ); | 47 | void smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ); |
48 | clist *createRcptList( mailimf_fields *fields ); | 48 | clist *createRcptList( mailimf_fields *fields ); |
49 | 49 | ||
50 | static void storeMail(char*mail, size_t length, const QString&box); | 50 | static void storeMail(const char*mail, size_t length, const QString&box); |
51 | static QString mailsmtpError( int err ); | 51 | static QString mailsmtpError( int err ); |
52 | static void progress( size_t current, size_t maximum ); | 52 | static void progress( size_t current, size_t maximum ); |
53 | static void addRcpts( clist *list, mailimf_address_list *addr_list ); | 53 | static void addRcpts( clist *list, mailimf_address_list *addr_list ); |
54 | static char *getFrom( mailmime *mail ); | 54 | static char *getFrom( mailmime *mail ); |
55 | static char *getFrom( mailimf_field *ffrom); | 55 | static char *getFrom( mailimf_field *ffrom); |
56 | static mailimf_field *getField( mailimf_fields *fields, int type ); | 56 | static mailimf_field *getField( mailimf_fields *fields, int type ); |
57 | int smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ); | 57 | int smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMTPaccount *smtp ); |
58 | 58 | ||
59 | void storeMail(mailmime*mail, const QString&box); | 59 | void storeMail(mailmime*mail, const QString&box); |
60 | Settings *settings; | 60 | Settings *settings; |
61 | 61 | ||
62 | int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which); | 62 | int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which); |
63 | 63 | ||
64 | int m_queuedMail; | 64 | int m_queuedMail; |
65 | static const char* USER_AGENT; | 65 | static const char* USER_AGENT; |
66 | 66 | ||
67 | protected slots: | 67 | protected slots: |
68 | void emitQCop( int queued ); | 68 | void emitQCop( int queued ); |
69 | 69 | ||
70 | }; | 70 | }; |
71 | 71 | ||
72 | #endif | 72 | #endif |
diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro index 96ffaa8..1abd2e8 100644 --- a/noncore/net/mail/mail.pro +++ b/noncore/net/mail/mail.pro | |||
@@ -1,53 +1,56 @@ | |||
1 | CONFIG += qt warn_on debug quick-app | 1 | CONFIG += qt warn_on debug quick-app |
2 | 2 | ||
3 | HEADERS = defines.h \ | 3 | HEADERS = defines.h \ |
4 | editaccounts.h \ | 4 | editaccounts.h \ |
5 | composemail.h \ | 5 | composemail.h \ |
6 | accountview.h \ | 6 | accountview.h \ |
7 | mainwindow.h \ | 7 | mainwindow.h \ |
8 | viewmail.h \ | 8 | viewmail.h \ |
9 | viewmailbase.h \ | 9 | viewmailbase.h \ |
10 | opiemail.h \ | 10 | opiemail.h \ |
11 | mailistviewitem.h \ | 11 | mailistviewitem.h \ |
12 | settingsdialog.h \ | 12 | settingsdialog.h \ |
13 | statuswidget.h \ | 13 | statuswidget.h \ |
14 | newmaildir.h | 14 | newmaildir.h \ |
15 | selectstore.h | ||
15 | 16 | ||
16 | SOURCES = main.cpp \ | 17 | SOURCES = main.cpp \ |
17 | opiemail.cpp \ | 18 | opiemail.cpp \ |
18 | mainwindow.cpp \ | 19 | mainwindow.cpp \ |
19 | accountview.cpp \ | 20 | accountview.cpp \ |
20 | composemail.cpp \ | 21 | composemail.cpp \ |
21 | addresspicker.cpp \ | 22 | addresspicker.cpp \ |
22 | editaccounts.cpp \ | 23 | editaccounts.cpp \ |
23 | viewmail.cpp \ | 24 | viewmail.cpp \ |
24 | viewmailbase.cpp \ | 25 | viewmailbase.cpp \ |
25 | settingsdialog.cpp \ | 26 | settingsdialog.cpp \ |
26 | statuswidget.cpp \ | 27 | statuswidget.cpp \ |
27 | newmaildir.cpp | 28 | newmaildir.cpp \ |
29 | selectstore.cpp | ||
28 | 30 | ||
29 | INTERFACES = editaccountsui.ui \ | 31 | INTERFACES = editaccountsui.ui \ |
30 | selectmailtypeui.ui \ | 32 | selectmailtypeui.ui \ |
31 | imapconfigui.ui \ | 33 | imapconfigui.ui \ |
32 | pop3configui.ui \ | 34 | pop3configui.ui \ |
33 | nntpconfigui.ui \ | 35 | nntpconfigui.ui \ |
34 | smtpconfigui.ui \ | 36 | smtpconfigui.ui \ |
35 | addresspickerui.ui \ | 37 | addresspickerui.ui \ |
36 | composemailui.ui \ | 38 | composemailui.ui \ |
37 | settingsdialogui.ui \ | 39 | settingsdialogui.ui \ |
38 | statuswidgetui.ui \ | 40 | statuswidgetui.ui \ |
39 | newmaildirui.ui | 41 | newmaildirui.ui \ |
42 | selectstoreui.ui | ||
40 | 43 | ||
41 | 44 | ||
42 | INCLUDEPATH += $(OPIEDIR)/include | 45 | INCLUDEPATH += $(OPIEDIR)/include |
43 | 46 | ||
44 | CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) | 47 | CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) |
45 | contains( CONFTEST, y ){ | 48 | contains( CONFTEST, y ){ |
46 | LIBS += -lqpe -lopie -lmailwrapper -liconv | 49 | LIBS += -lqpe -lopie -lmailwrapper -liconv |
47 | }else{ | 50 | }else{ |
48 | LIBS += -lqpe -lopie -lmailwrapper | 51 | LIBS += -lqpe -lopie -lmailwrapper |
49 | } | 52 | } |
50 | 53 | ||
51 | TARGET = opiemail | 54 | TARGET = opiemail |
52 | 55 | ||
53 | include ( $(OPIEDIR)/include.pro ) | 56 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/net/mail/selectstore.cpp b/noncore/net/mail/selectstore.cpp new file mode 100644 index 0000000..28ab5a8 --- a/dev/null +++ b/noncore/net/mail/selectstore.cpp | |||
@@ -0,0 +1,19 @@ | |||
1 | #include "selectstore.h" | ||
2 | |||
3 | Selectstore::Selectstore(QWidget* parent, const char* name) | ||
4 | :selectstoreui(parent,name,true) | ||
5 | { | ||
6 | |||
7 | } | ||
8 | |||
9 | Selectstore::~Selectstore() | ||
10 | { | ||
11 | } | ||
12 | |||
13 | void Selectstore::slotCreateNewFolder() | ||
14 | { | ||
15 | } | ||
16 | |||
17 | void Selectstore::slotMoveMail() | ||
18 | { | ||
19 | } | ||
diff --git a/noncore/net/mail/selectstore.h b/noncore/net/mail/selectstore.h new file mode 100644 index 0000000..8b8e8ee --- a/dev/null +++ b/noncore/net/mail/selectstore.h | |||
@@ -0,0 +1,19 @@ | |||
1 | #ifndef _SELECTSTORE_H | ||
2 | #define _SELECTSTORE_H | ||
3 | |||
4 | #include "selectstoreui.h" | ||
5 | |||
6 | class Selectstore:public selectstoreui | ||
7 | { | ||
8 | Q_OBJECT | ||
9 | public: | ||
10 | Selectstore(QWidget* parent = 0, const char* name = 0); | ||
11 | virtual ~Selectstore(); | ||
12 | |||
13 | protected: | ||
14 | virtual void slotCreateNewFolder(); | ||
15 | virtual void slotMoveMail(); | ||
16 | protected slots: | ||
17 | |||
18 | }; | ||
19 | #endif | ||
diff --git a/noncore/net/mail/selectstoreui.ui b/noncore/net/mail/selectstoreui.ui new file mode 100644 index 0000000..3741b71 --- a/dev/null +++ b/noncore/net/mail/selectstoreui.ui | |||
@@ -0,0 +1,244 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>selectstoreui</class> | ||
3 | <widget> | ||
4 | <class>QDialog</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>selectstoreui</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>190</width> | ||
15 | <height>273</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Select target box</string> | ||
21 | </property> | ||
22 | <property> | ||
23 | <name>layoutMargin</name> | ||
24 | </property> | ||
25 | <property> | ||
26 | <name>layoutSpacing</name> | ||
27 | </property> | ||
28 | <vbox> | ||
29 | <property stdset="1"> | ||
30 | <name>margin</name> | ||
31 | <number>2</number> | ||
32 | </property> | ||
33 | <property stdset="1"> | ||
34 | <name>spacing</name> | ||
35 | <number>2</number> | ||
36 | </property> | ||
37 | <widget> | ||
38 | <class>QLabel</class> | ||
39 | <property stdset="1"> | ||
40 | <name>name</name> | ||
41 | <cstring>headlabel</cstring> | ||
42 | </property> | ||
43 | <property stdset="1"> | ||
44 | <name>text</name> | ||
45 | <string><b>Store mail(s) to</b></string> | ||
46 | </property> | ||
47 | <property stdset="1"> | ||
48 | <name>alignment</name> | ||
49 | <set>AlignCenter</set> | ||
50 | </property> | ||
51 | <property> | ||
52 | <name>hAlign</name> | ||
53 | </property> | ||
54 | </widget> | ||
55 | <widget> | ||
56 | <class>QLayoutWidget</class> | ||
57 | <property stdset="1"> | ||
58 | <name>name</name> | ||
59 | <cstring>Layout2</cstring> | ||
60 | </property> | ||
61 | <grid> | ||
62 | <property stdset="1"> | ||
63 | <name>margin</name> | ||
64 | <number>0</number> | ||
65 | </property> | ||
66 | <property stdset="1"> | ||
67 | <name>spacing</name> | ||
68 | <number>6</number> | ||
69 | </property> | ||
70 | <widget row="1" column="1" > | ||
71 | <class>QComboBox</class> | ||
72 | <property stdset="1"> | ||
73 | <name>name</name> | ||
74 | <cstring>folderSelection</cstring> | ||
75 | </property> | ||
76 | <property stdset="1"> | ||
77 | <name>sizePolicy</name> | ||
78 | <sizepolicy> | ||
79 | <hsizetype>3</hsizetype> | ||
80 | <vsizetype>0</vsizetype> | ||
81 | </sizepolicy> | ||
82 | </property> | ||
83 | </widget> | ||
84 | <widget row="1" column="0" > | ||
85 | <class>QLabel</class> | ||
86 | <property stdset="1"> | ||
87 | <name>name</name> | ||
88 | <cstring>folderLabel</cstring> | ||
89 | </property> | ||
90 | <property stdset="1"> | ||
91 | <name>text</name> | ||
92 | <string>Folder:</string> | ||
93 | </property> | ||
94 | <property stdset="1"> | ||
95 | <name>alignment</name> | ||
96 | <set>AlignVCenter|AlignRight</set> | ||
97 | </property> | ||
98 | <property> | ||
99 | <name>hAlign</name> | ||
100 | </property> | ||
101 | </widget> | ||
102 | <widget row="0" column="1" > | ||
103 | <class>QComboBox</class> | ||
104 | <property stdset="1"> | ||
105 | <name>name</name> | ||
106 | <cstring>accountSelection</cstring> | ||
107 | </property> | ||
108 | <property stdset="1"> | ||
109 | <name>sizePolicy</name> | ||
110 | <sizepolicy> | ||
111 | <hsizetype>3</hsizetype> | ||
112 | <vsizetype>0</vsizetype> | ||
113 | </sizepolicy> | ||
114 | </property> | ||
115 | </widget> | ||
116 | <widget row="0" column="0" > | ||
117 | <class>QLabel</class> | ||
118 | <property stdset="1"> | ||
119 | <name>name</name> | ||
120 | <cstring>accountlabel</cstring> | ||
121 | </property> | ||
122 | <property stdset="1"> | ||
123 | <name>sizePolicy</name> | ||
124 | <sizepolicy> | ||
125 | <hsizetype>1</hsizetype> | ||
126 | <vsizetype>1</vsizetype> | ||
127 | </sizepolicy> | ||
128 | </property> | ||
129 | <property stdset="1"> | ||
130 | <name>text</name> | ||
131 | <string>Account:</string> | ||
132 | </property> | ||
133 | <property stdset="1"> | ||
134 | <name>alignment</name> | ||
135 | <set>AlignVCenter|AlignRight</set> | ||
136 | </property> | ||
137 | <property> | ||
138 | <name>hAlign</name> | ||
139 | </property> | ||
140 | </widget> | ||
141 | </grid> | ||
142 | </widget> | ||
143 | <widget> | ||
144 | <class>Line</class> | ||
145 | <property stdset="1"> | ||
146 | <name>name</name> | ||
147 | <cstring>Line1</cstring> | ||
148 | </property> | ||
149 | <property stdset="1"> | ||
150 | <name>orientation</name> | ||
151 | <enum>Horizontal</enum> | ||
152 | </property> | ||
153 | </widget> | ||
154 | <widget> | ||
155 | <class>QCheckBox</class> | ||
156 | <property stdset="1"> | ||
157 | <name>name</name> | ||
158 | <cstring>newFoldersel</cstring> | ||
159 | </property> | ||
160 | <property stdset="1"> | ||
161 | <name>text</name> | ||
162 | <string>Create new folder</string> | ||
163 | </property> | ||
164 | </widget> | ||
165 | <widget> | ||
166 | <class>QLineEdit</class> | ||
167 | <property stdset="1"> | ||
168 | <name>name</name> | ||
169 | <cstring>newFolderedit</cstring> | ||
170 | </property> | ||
171 | <property stdset="1"> | ||
172 | <name>enabled</name> | ||
173 | <bool>false</bool> | ||
174 | </property> | ||
175 | </widget> | ||
176 | <widget> | ||
177 | <class>Line</class> | ||
178 | <property stdset="1"> | ||
179 | <name>name</name> | ||
180 | <cstring>Line2</cstring> | ||
181 | </property> | ||
182 | <property stdset="1"> | ||
183 | <name>orientation</name> | ||
184 | <enum>Horizontal</enum> | ||
185 | </property> | ||
186 | </widget> | ||
187 | <widget> | ||
188 | <class>QCheckBox</class> | ||
189 | <property stdset="1"> | ||
190 | <name>name</name> | ||
191 | <cstring>selMove</cstring> | ||
192 | </property> | ||
193 | <property stdset="1"> | ||
194 | <name>text</name> | ||
195 | <string>Move mail(s)</string> | ||
196 | </property> | ||
197 | </widget> | ||
198 | <spacer> | ||
199 | <property> | ||
200 | <name>name</name> | ||
201 | <cstring>Spacer2</cstring> | ||
202 | </property> | ||
203 | <property stdset="1"> | ||
204 | <name>orientation</name> | ||
205 | <enum>Vertical</enum> | ||
206 | </property> | ||
207 | <property stdset="1"> | ||
208 | <name>sizeType</name> | ||
209 | <enum>Expanding</enum> | ||
210 | </property> | ||
211 | <property> | ||
212 | <name>sizeHint</name> | ||
213 | <size> | ||
214 | <width>20</width> | ||
215 | <height>20</height> | ||
216 | </size> | ||
217 | </property> | ||
218 | </spacer> | ||
219 | </vbox> | ||
220 | </widget> | ||
221 | <connections> | ||
222 | <connection> | ||
223 | <sender>selMove</sender> | ||
224 | <signal>clicked()</signal> | ||
225 | <receiver>selectstoreui</receiver> | ||
226 | <slot>slotMoveMail()</slot> | ||
227 | </connection> | ||
228 | <connection> | ||
229 | <sender>newFoldersel</sender> | ||
230 | <signal>clicked()</signal> | ||
231 | <receiver>selectstoreui</receiver> | ||
232 | <slot>slotCreateNewFolder()</slot> | ||
233 | </connection> | ||
234 | <slot access="protected">slotMoveMail()</slot> | ||
235 | <slot access="protected">slotCreateNewFolder()</slot> | ||
236 | </connections> | ||
237 | <tabstops> | ||
238 | <tabstop>accountSelection</tabstop> | ||
239 | <tabstop>folderSelection</tabstop> | ||
240 | <tabstop>newFoldersel</tabstop> | ||
241 | <tabstop>newFolderedit</tabstop> | ||
242 | <tabstop>selMove</tabstop> | ||
243 | </tabstops> | ||
244 | </UI> | ||