summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp33
-rw-r--r--noncore/net/mail/accountview.h4
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h1
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp74
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h1
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.cpp13
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.h3
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp11
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h3
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.cpp17
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.h4
-rw-r--r--noncore/net/mail/mail.pro9
-rw-r--r--noncore/net/mail/selectstore.cpp19
-rw-r--r--noncore/net/mail/selectstore.h19
-rw-r--r--noncore/net/mail/selectstoreui.ui244
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,296 +1,321 @@
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 */
12POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) 13POP3viewItem::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
22POP3viewItem::~POP3viewItem() 23POP3viewItem::~POP3viewItem()
23{ 24{
24 delete wrapper; 25 delete wrapper;
25} 26}
26 27
27AbstractMail *POP3viewItem::getWrapper() 28AbstractMail *POP3viewItem::getWrapper()
28{ 29{
29 return wrapper; 30 return wrapper;
30} 31}
31 32
32void POP3viewItem::refresh( QList<RecMail> & ) 33void 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
52RecBody POP3viewItem::fetchBody( const RecMail &mail ) 53RecBody 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
58POP3folderItem::~POP3folderItem() 59POP3folderItem::~POP3folderItem()
59{ 60{
60 delete folder; 61 delete folder;
61} 62}
62 63
63POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) 64POP3folderItem::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
76void POP3folderItem::refresh(QList<RecMail>&target) 77void 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
82RecBody POP3folderItem::fetchBody(const RecMail&aMail) 83RecBody POP3folderItem::fetchBody(const RecMail&aMail)
83{ 84{
84 return pop3->getWrapper()->fetchBody(aMail); 85 return pop3->getWrapper()->fetchBody(aMail);
85} 86}
86 87
87QPopupMenu * POP3folderItem::getContextMenu() 88QPopupMenu * 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
99void POP3folderItem::downloadMails()
100{
101 Selectstore sels;
102 sels.showMaximized();
103 sels.exec();
104}
105
97void POP3folderItem::contextMenuSelected(int which) 106void 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 */
115IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) 129IMAPviewItem::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
125IMAPviewItem::~IMAPviewItem() 139IMAPviewItem::~IMAPviewItem()
126{ 140{
127 delete wrapper; 141 delete wrapper;
128} 142}
129 143
130AbstractMail *IMAPviewItem::getWrapper() 144AbstractMail *IMAPviewItem::getWrapper()
131{ 145{
132 return wrapper; 146 return wrapper;
133} 147}
134 148
135IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start) 149IMAPfolderItem*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
156void IMAPviewItem::refresh(QList<RecMail>&) 170void IMAPviewItem::refresh(QList<RecMail>&)
157{ 171{
158 refreshFolders(false); 172 refreshFolders(false);
159} 173}
160 174
161void IMAPviewItem::refreshFolders(bool force) 175void 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
186void 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
209QPopupMenu * IMAPviewItem::getContextMenu() 230QPopupMenu * 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
221void IMAPviewItem::createNewFolder() 242void 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
239void IMAPviewItem::contextMenuSelected(int id) 260void 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
254RecBody IMAPviewItem::fetchBody(const RecMail&) 279RecBody IMAPviewItem::fetchBody(const RecMail&)
255{ 280{
256 return RecBody(); 281 return RecBody();
257} 282}
258 283
259IMAPfolderItem::~IMAPfolderItem() 284IMAPfolderItem::~IMAPfolderItem()
260{ 285{
261 delete folder; 286 delete folder;
262} 287}
263 288
264IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) 289IMAPfolderItem::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
277IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) 302IMAPfolderItem::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
290const QString& IMAPfolderItem::Delemiter()const 315const QString& IMAPfolderItem::Delemiter()const
291{ 316{
292 return folder->Separator(); 317 return folder->Separator();
293} 318}
294 319
295bool IMAPfolderItem::matchName(const QString&name)const 320bool IMAPfolderItem::matchName(const QString&name)const
296{ 321{
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
@@ -10,119 +10,123 @@
10 10
11class POP3wrapper; 11class POP3wrapper;
12class RecMail; 12class RecMail;
13class RecBody; 13class RecBody;
14class QPopupMenu; 14class QPopupMenu;
15 15
16class AccountViewItem : public QListViewItem 16class AccountViewItem : public QListViewItem
17{ 17{
18 18
19public: 19public:
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){}
27protected: 27protected:
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
32class POP3viewItem : public AccountViewItem 32class POP3viewItem : public AccountViewItem
33{ 33{
34 34
35public: 35public:
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();
41private: 41private:
42 POP3account *account; 42 POP3account *account;
43 AbstractMail *wrapper; 43 AbstractMail *wrapper;
44 44
45}; 45};
46 46
47class POP3folderItem : public AccountViewItem 47class POP3folderItem : public AccountViewItem
48{ 48{
49 49
50public: 50public:
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
58protected:
59 void downloadMails();
60
58private: 61private:
59 Folder *folder; 62 Folder *folder;
60 POP3viewItem *pop3; 63 POP3viewItem *pop3;
61}; 64};
62 65
63class IMAPfolderItem; 66class IMAPfolderItem;
64 67
65class IMAPviewItem : public AccountViewItem 68class IMAPviewItem : public AccountViewItem
66{ 69{
67 friend class IMAPfolderItem; 70 friend class IMAPfolderItem;
68public: 71public:
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
77protected: 80protected:
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
82private: 86private:
83 IMAPaccount *account; 87 IMAPaccount *account;
84 AbstractMail *wrapper; 88 AbstractMail *wrapper;
85}; 89};
86 90
87class IMAPfolderItem : public AccountViewItem 91class IMAPfolderItem : public AccountViewItem
88{ 92{
89 93
90public: 94public:
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;
100protected: 104protected:
101 virtual void createNewFolder(); 105 virtual void createNewFolder();
102 virtual void deleteFolder(); 106 virtual void deleteFolder();
103 107
104private: 108private:
105 Folder *folder; 109 Folder *folder;
106 IMAPviewItem *imap; 110 IMAPviewItem *imap;
107}; 111};
108 112
109class MBOXviewItem : public AccountViewItem 113class MBOXviewItem : public AccountViewItem
110{ 114{
111 friend class MBOXfolderItem; 115 friend class MBOXfolderItem;
112 116
113public: 117public:
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
123protected: 127protected:
124 virtual void refresh(bool force=false); 128 virtual void refresh(bool force=false);
125 virtual void createFolder(); 129 virtual void createFolder();
126 130
127private: 131private:
128// MBOXaccount *account; 132// MBOXaccount *account;
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
7class RecMail; 7class RecMail;
8class RecBody; 8class RecBody;
9class RecPart; 9class RecPart;
10class IMAPwrapper; 10class IMAPwrapper;
11class POP3wrapper; 11class POP3wrapper;
12class Folder; 12class Folder;
13class encodedString; 13class encodedString;
14struct folderStat; 14struct folderStat;
15 15
16class AbstractMail:public QObject 16class AbstractMail:public QObject
17{ 17{
18 Q_OBJECT 18 Q_OBJECT
19public: 19public:
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
54protected: 55protected:
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
@@ -421,121 +421,132 @@ 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
461encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) 461encodedString*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! */
526void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body, 537void 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) {
@@ -910,83 +921,94 @@ int IMAPwrapper::createMbox(const QString&folder,const Folder*parentfolder,const
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
925int IMAPwrapper::deleteMbox(const Folder*folder) 936int 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
938void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) 949void 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
978void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) 993void 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
989const QString&IMAPwrapper::getType()const 1004const QString&IMAPwrapper::getType()const
990{ 1005{
991 return account->getType(); 1006 return account->getType();
992} 1007}
1008
1009encodedString* 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
9struct mailimap; 9struct mailimap;
10struct mailimap_body; 10struct mailimap_body;
11struct mailimap_body_type_1part; 11struct mailimap_body_type_1part;
12struct mailimap_body_type_text; 12struct mailimap_body_type_text;
13struct mailimap_body_type_basic; 13struct mailimap_body_type_basic;
14struct mailimap_body_type_msg; 14struct mailimap_body_type_msg;
15struct mailimap_body_type_mpart; 15struct mailimap_body_type_mpart;
16struct mailimap_body_fields; 16struct mailimap_body_fields;
17struct mailimap_msg_att; 17struct mailimap_msg_att;
18class encodedString; 18class encodedString;
19 19
20class IMAPwrapper : public AbstractMail 20class IMAPwrapper : public AbstractMail
21{ 21{
22 Q_OBJECT 22 Q_OBJECT
23public: 23public:
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;
47protected: 48protected:
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
@@ -127,136 +127,137 @@ RecBody MBOXwrapper::fetchBody( const RecMail &mail )
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
135void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) 135void 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
140int MBOXwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool ) 140int 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
158void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) 158void 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
175void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) 175encodedString* 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
217void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) 218void 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
231void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) 232void 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
247int MBOXwrapper::deleteAllMail(const Folder*tfolder) 248int 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);
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
7class RecMail; 7class RecMail;
8class RecBody; 8class RecBody;
9class encodedString;
9struct mailmbox_folder; 10struct mailmbox_folder;
10 11
11class MBOXwrapper : public Genericwrapper 12class MBOXwrapper : public Genericwrapper
12{ 13{
13 Q_OBJECT 14 Q_OBJECT
14public: 15public:
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
38protected: 39protected:
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
@@ -183,60 +183,67 @@ QList<Folder>* POP3wrapper::listFolders()
183void POP3wrapper::deleteMail(const RecMail&mail) 183void 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
193void POP3wrapper::answeredMail(const RecMail&) 193void POP3wrapper::answeredMail(const RecMail&)
194{ 194{
195} 195}
196 196
197int POP3wrapper::deleteAllMail(const Folder*) 197int 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
220void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) 220void 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
231void POP3wrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) 231encodedString* 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
239const QString&POP3wrapper::getType()const 246const 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
8class encodedString;
8struct mailstorage; 9struct mailstorage;
9struct mailfolder; 10struct mailfolder;
10 11
11class POP3wrapper : public Genericwrapper 12class POP3wrapper : public Genericwrapper
12{ 13{
13 Q_OBJECT 14 Q_OBJECT
14 15
15public: 16public:
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
34protected: 35protected:
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
@@ -440,148 +440,148 @@ clist *SMTPwrapper::createRcptList( mailimf_fields *fields )
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
456char *SMTPwrapper::getFrom( mailimf_field *ffrom) 456char *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
472char *SMTPwrapper::getFrom( mailmime *mail ) 472char *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
480void SMTPwrapper::progress( size_t current, size_t maximum ) 480void 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
488void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box) 488void 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
497void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) 497void 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
539int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ) 539int 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);
@@ -595,128 +595,125 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccou
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
602free_con_session: 602free_con_session:
603 mailsmtp_quit( session ); 603 mailsmtp_quit( session );
604free_mem_session: 604free_mem_session:
605 mailsmtp_free( session ); 605 mailsmtp_free( session );
606free_mem: 606free_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
615void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later ) 615void 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
641int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) 641int 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 */
686bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) 683bool 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" );
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
@@ -2,71 +2,71 @@
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
12class Mail; 12class Mail;
13class MBOXwrapper; 13class MBOXwrapper;
14class RecMail; 14class RecMail;
15class Attachment; 15class Attachment;
16struct mailimf_fields; 16struct mailimf_fields;
17struct mailimf_field; 17struct mailimf_field;
18struct mailimf_mailbox; 18struct mailimf_mailbox;
19struct mailmime; 19struct mailmime;
20struct mailimf_address_list; 20struct mailimf_address_list;
21class progressMailSend; 21class progressMailSend;
22 22
23class SMTPwrapper : public QObject 23class SMTPwrapper : public QObject
24{ 24{
25 Q_OBJECT 25 Q_OBJECT
26 26
27public: 27public:
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
35signals: 35signals:
36 void queuedMails( int ); 36 void queuedMails( int );
37 37
38protected: 38protected:
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
67protected slots: 67protected 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 @@
1CONFIG += qt warn_on debug quick-app 1CONFIG += qt warn_on debug quick-app
2 2
3HEADERS = defines.h \ 3HEADERS = 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
16SOURCES = main.cpp \ 17SOURCES = 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
29INTERFACES = editaccountsui.ui \ 31INTERFACES = 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
42INCLUDEPATH += $(OPIEDIR)/include 45INCLUDEPATH += $(OPIEDIR)/include
43 46
44CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) 47CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX )
45contains( CONFTEST, y ){ 48contains( 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
51TARGET = opiemail 54TARGET = opiemail
52 55
53include ( $(OPIEDIR)/include.pro ) 56include ( $(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
3Selectstore::Selectstore(QWidget* parent, const char* name)
4 :selectstoreui(parent,name,true)
5{
6
7}
8
9Selectstore::~Selectstore()
10{
11}
12
13void Selectstore::slotCreateNewFolder()
14{
15}
16
17void 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
6class Selectstore:public selectstoreui
7{
8 Q_OBJECT
9public:
10 Selectstore(QWidget* parent = 0, const char* name = 0);
11 virtual ~Selectstore();
12
13protected:
14 virtual void slotCreateNewFolder();
15 virtual void slotMoveMail();
16protected 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>&lt;b&gt;Store mail(s) to&lt;/b&gt;</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>