summaryrefslogtreecommitdiff
path: root/noncore
authoralwin <alwin>2003-12-17 00:30:31 (UTC)
committer alwin <alwin>2003-12-17 00:30:31 (UTC)
commita928f1fc8469124e10a7042846d258401e41f7d6 (patch) (unidiff)
tree225db6d7356d3ff3a0a3f3768c2fc0fa10360edc /noncore
parent27151bb106e2cbd7f649dae228189ebcaccd7aac (diff)
downloadopie-a928f1fc8469124e10a7042846d258401e41f7d6.zip
opie-a928f1fc8469124e10a7042846d258401e41f7d6.tar.gz
opie-a928f1fc8469124e10a7042846d258401e41f7d6.tar.bz2
imap folder will be displayed more structured
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp69
-rw-r--r--noncore/net/mail/accountview.h2
-rw-r--r--noncore/net/mail/imapwrapper.cpp7
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp7
-rw-r--r--noncore/net/mail/libmailwrapper/mailwrapper.cpp11
-rw-r--r--noncore/net/mail/libmailwrapper/mailwrapper.h7
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp2
-rw-r--r--noncore/net/mail/mailwrapper.cpp11
-rw-r--r--noncore/net/mail/mailwrapper.h7
-rw-r--r--noncore/net/mail/pop3wrapper.cpp2
10 files changed, 100 insertions, 25 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index 8e21d39..b6bf298 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -61,160 +61,215 @@ POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QList
61 : AccountViewItem( parent,after ) 61 : AccountViewItem( parent,after )
62{ 62{
63 folder = folderInit; 63 folder = folderInit;
64 pop3 = parent; 64 pop3 = parent;
65 if (folder->getDisplayName().lower()!="inbox") { 65 if (folder->getDisplayName().lower()!="inbox") {
66 setPixmap( 0, PIXMAP_POP3FOLDER ); 66 setPixmap( 0, PIXMAP_POP3FOLDER );
67 } else { 67 } else {
68 setPixmap( 0, PIXMAP_INBOXFOLDER); 68 setPixmap( 0, PIXMAP_INBOXFOLDER);
69 } 69 }
70 setText( 0, folder->getDisplayName() ); 70 setText( 0, folder->getDisplayName() );
71} 71}
72 72
73void POP3folderItem::refresh(QList<RecMail>&target) 73void POP3folderItem::refresh(QList<RecMail>&target)
74{ 74{
75 if (folder->may_select()) 75 if (folder->may_select())
76 pop3->getWrapper()->listMessages( folder->getName(),target ); 76 pop3->getWrapper()->listMessages( folder->getName(),target );
77} 77}
78 78
79RecBody POP3folderItem::fetchBody(const RecMail&aMail) 79RecBody POP3folderItem::fetchBody(const RecMail&aMail)
80{ 80{
81 return pop3->getWrapper()->fetchBody(aMail); 81 return pop3->getWrapper()->fetchBody(aMail);
82} 82}
83 83
84/** 84/**
85 * IMAP Account stuff 85 * IMAP Account stuff
86 */ 86 */
87IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) 87IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent )
88 : AccountViewItem( parent ) 88 : AccountViewItem( parent )
89{ 89{
90 account = a; 90 account = a;
91 wrapper = AbstractMail::getWrapper( account ); 91 wrapper = AbstractMail::getWrapper( account );
92 setPixmap( 0, PIXMAP_IMAPFOLDER ); 92 setPixmap( 0, PIXMAP_IMAPFOLDER );
93 setText( 0, account->getAccountName() ); 93 setText( 0, account->getAccountName() );
94 setOpen( true ); 94 setOpen( true );
95} 95}
96 96
97IMAPviewItem::~IMAPviewItem() 97IMAPviewItem::~IMAPviewItem()
98{ 98{
99 delete wrapper; 99 delete wrapper;
100} 100}
101 101
102AbstractMail *IMAPviewItem::getWrapper() 102AbstractMail *IMAPviewItem::getWrapper()
103{ 103{
104 return wrapper; 104 return wrapper;
105} 105}
106 106
107void IMAPviewItem::refresh(QList<RecMail>&) 107void IMAPviewItem::refresh(QList<RecMail>&)
108{ 108{
109 if (childCount()>0) return;
109 QList<Folder> *folders = wrapper->listFolders(); 110 QList<Folder> *folders = wrapper->listFolders();
110 111
111 QListViewItem *child = firstChild(); 112 QListViewItem *child = firstChild();
112 while ( child ) { 113 while ( child ) {
113 QListViewItem *tmp = child; 114 QListViewItem *tmp = child;
114 child = child->nextSibling(); 115 child = child->nextSibling();
115 delete tmp; 116 delete tmp;
116 } 117 }
117 118
118 Folder *it; 119 Folder *it;
119 QListViewItem*item = 0; 120 QListViewItem*item = 0;
120 for ( it = folders->first(); it; it = folders->next() ) { 121 QListViewItem*titem = 0;
121 item = new IMAPfolderItem( it, this , item ); 122 QListViewItem*inboxitem = 0;
122 item->setSelectable(it->may_select()); 123 QString fname,del,search;
123 } 124 int pos;
124 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 125 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
125 folders->setAutoDelete(false); 126 folders->setAutoDelete(false);
127
128 for ( it = folders->first(); it; it = folders->next() ) {
129 if (it->getDisplayName().lower()=="inbox") {
130 inboxitem = new IMAPfolderItem( it, this , item );
131 folders->remove(it);
132 qDebug("inbox found");
133 break;
134 }
135 }
136
137 for ( it = folders->first(); it; it = folders->next() ) {
138 fname = it->getDisplayName();
139 pos = fname.findRev(it->Separator());
140 if (pos != -1) {
141 fname = fname.left(pos);
142 qDebug(fname);
143 }
144 IMAPfolderItem*pitem = (IMAPfolderItem*)firstChild();
145 while (pitem) {
146 if (pitem->matchName(fname)) {
147 break;
148 }
149 pitem=(IMAPfolderItem*)pitem->nextSibling();
150 }
151 if (pitem) {
152 titem = item;
153 item = new IMAPfolderItem(it,pitem,item,this);
154 item->setSelectable(it->may_select());
155 /* setup the short name */
156 item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1));
157 item = titem;
158 } else {
159 item = new IMAPfolderItem( it, this , (inboxitem?inboxitem:item) );
160 item->setSelectable(it->may_select());
161 }
162 }
126 delete folders; 163 delete folders;
127} 164}
128 165
129RecBody IMAPviewItem::fetchBody(const RecMail&) 166RecBody IMAPviewItem::fetchBody(const RecMail&)
130{ 167{
131 return RecBody(); 168 return RecBody();
132} 169}
133 170
134IMAPfolderItem::~IMAPfolderItem() 171IMAPfolderItem::~IMAPfolderItem()
135{ 172{
136 delete folder; 173 delete folder;
137} 174}
138 175
139IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) 176IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after )
140 : AccountViewItem( parent,after ) 177 : AccountViewItem( parent )
141{ 178{
142 folder = folderInit; 179 folder = folderInit;
143 imap = parent; 180 imap = parent;
144 if (folder->getDisplayName().lower()!="inbox") { 181 if (folder->getDisplayName().lower()!="inbox") {
145 setPixmap( 0, PIXMAP_IMAPFOLDER ); 182 setPixmap( 0, PIXMAP_IMAPFOLDER );
146 } else { 183 } else {
147 setPixmap( 0, PIXMAP_INBOXFOLDER); 184 setPixmap( 0, PIXMAP_INBOXFOLDER);
148 } 185 }
149 setText( 0, folder->getDisplayName() ); 186 setText( 0, folder->getDisplayName() );
150} 187}
151 188
189IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master )
190 : AccountViewItem( parent,after )
191{
192 folder = folderInit;
193 imap = master;
194 if (folder->getDisplayName().lower()!="inbox") {
195 setPixmap( 0, PIXMAP_IMAPFOLDER );
196 } else {
197 setPixmap( 0, PIXMAP_INBOXFOLDER);
198 }
199 setText( 0, folder->getDisplayName() );
200}
201
202bool IMAPfolderItem::matchName(const QString&name)const
203{
204 return folder->getDisplayName()==name;
205}
206
152void IMAPfolderItem::refresh(QList<RecMail>&target) 207void IMAPfolderItem::refresh(QList<RecMail>&target)
153{ 208{
154 if (folder->may_select()) 209 if (folder->may_select())
155 imap->getWrapper()->listMessages( folder->getName(),target ); 210 imap->getWrapper()->listMessages( folder->getName(),target );
156} 211}
157 212
158RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) 213RecBody IMAPfolderItem::fetchBody(const RecMail&aMail)
159{ 214{
160 return imap->getWrapper()->fetchBody(aMail); 215 return imap->getWrapper()->fetchBody(aMail);
161} 216}
162 217
163/** 218/**
164 * Generic stuff 219 * Generic stuff
165 */ 220 */
166 221
167AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) 222AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
168 : QListView( parent, name, flags ) 223 : QListView( parent, name, flags )
169{ 224{
170 connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), 225 connect( this, SIGNAL( selectionChanged( QListViewItem * ) ),
171 SLOT( refresh( QListViewItem * ) ) ); 226 SLOT( refresh( QListViewItem * ) ) );
172 setSorting(-1); 227 setSorting(0);
173} 228}
174 229
175void AccountView::populate( QList<Account> list ) 230void AccountView::populate( QList<Account> list )
176{ 231{
177 clear(); 232 clear();
178 233
179 Account *it; 234 Account *it;
180 for ( it = list.first(); it; it = list.next() ) { 235 for ( it = list.first(); it; it = list.next() ) {
181 if ( it->getType().compare( "IMAP" ) == 0 ) { 236 if ( it->getType().compare( "IMAP" ) == 0 ) {
182 IMAPaccount *imap = static_cast<IMAPaccount *>(it); 237 IMAPaccount *imap = static_cast<IMAPaccount *>(it);
183 qDebug( "added IMAP " + imap->getAccountName() ); 238 qDebug( "added IMAP " + imap->getAccountName() );
184 (void) new IMAPviewItem( imap, this ); 239 (void) new IMAPviewItem( imap, this );
185 } else if ( it->getType().compare( "POP3" ) == 0 ) { 240 } else if ( it->getType().compare( "POP3" ) == 0 ) {
186 POP3account *pop3 = static_cast<POP3account *>(it); 241 POP3account *pop3 = static_cast<POP3account *>(it);
187 qDebug( "added POP3 " + pop3->getAccountName() ); 242 qDebug( "added POP3 " + pop3->getAccountName() );
188 (void) new POP3viewItem( pop3, this ); 243 (void) new POP3viewItem( pop3, this );
189 } 244 }
190 } 245 }
191} 246}
192 247
193void AccountView::refresh(QListViewItem *item) { 248void AccountView::refresh(QListViewItem *item) {
194 249
195 qDebug("AccountView refresh..."); 250 qDebug("AccountView refresh...");
196 if ( item ) { 251 if ( item ) {
197 m_currentItem = item; 252 m_currentItem = item;
198 QList<RecMail> headerlist; 253 QList<RecMail> headerlist;
199 headerlist.setAutoDelete(true); 254 headerlist.setAutoDelete(true);
200 AccountViewItem *view = static_cast<AccountViewItem *>(item); 255 AccountViewItem *view = static_cast<AccountViewItem *>(item);
201 view->refresh(headerlist); 256 view->refresh(headerlist);
202 emit refreshMailview(&headerlist); 257 emit refreshMailview(&headerlist);
203 } 258 }
204} 259}
205 260
206void AccountView::refreshCurrent() 261void AccountView::refreshCurrent()
207{ 262{
208 if ( !m_currentItem ) return; 263 if ( !m_currentItem ) return;
209 QList<RecMail> headerlist; 264 QList<RecMail> headerlist;
210 headerlist.setAutoDelete(true); 265 headerlist.setAutoDelete(true);
211 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); 266 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
212 view->refresh(headerlist); 267 view->refresh(headerlist);
213 emit refreshMailview(&headerlist); 268 emit refreshMailview(&headerlist);
214} 269}
215 270
216void AccountView::refreshAll() 271void AccountView::refreshAll()
217{ 272{
218 273
219} 274}
220 275
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index d035af4..a57935f 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -25,78 +25,80 @@ public:
25 25
26class POP3viewItem : public AccountViewItem 26class POP3viewItem : public AccountViewItem
27{ 27{
28 28
29public: 29public:
30 POP3viewItem( POP3account *a, QListView *parent ); 30 POP3viewItem( POP3account *a, QListView *parent );
31 ~POP3viewItem(); 31 ~POP3viewItem();
32 virtual void refresh( QList<RecMail> &target ); 32 virtual void refresh( QList<RecMail> &target );
33 virtual RecBody fetchBody( const RecMail &mail ); 33 virtual RecBody fetchBody( const RecMail &mail );
34 AbstractMail *getWrapper(); 34 AbstractMail *getWrapper();
35private: 35private:
36 POP3account *account; 36 POP3account *account;
37 AbstractMail *wrapper; 37 AbstractMail *wrapper;
38 38
39}; 39};
40 40
41class POP3folderItem : public AccountViewItem 41class POP3folderItem : public AccountViewItem
42{ 42{
43 43
44public: 44public:
45 POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); 45 POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after );
46 ~POP3folderItem(); 46 ~POP3folderItem();
47 virtual void refresh(QList<RecMail>&); 47 virtual void refresh(QList<RecMail>&);
48 virtual RecBody fetchBody(const RecMail&); 48 virtual RecBody fetchBody(const RecMail&);
49private: 49private:
50 Folder *folder; 50 Folder *folder;
51 POP3viewItem *pop3; 51 POP3viewItem *pop3;
52}; 52};
53 53
54class IMAPviewItem : public AccountViewItem 54class IMAPviewItem : public AccountViewItem
55{ 55{
56 56
57public: 57public:
58 IMAPviewItem( IMAPaccount *a, QListView *parent ); 58 IMAPviewItem( IMAPaccount *a, QListView *parent );
59 ~IMAPviewItem(); 59 ~IMAPviewItem();
60 virtual void refresh(QList<RecMail>&); 60 virtual void refresh(QList<RecMail>&);
61 virtual RecBody fetchBody(const RecMail&); 61 virtual RecBody fetchBody(const RecMail&);
62 AbstractMail *getWrapper(); 62 AbstractMail *getWrapper();
63private: 63private:
64 IMAPaccount *account; 64 IMAPaccount *account;
65 AbstractMail *wrapper; 65 AbstractMail *wrapper;
66}; 66};
67 67
68class IMAPfolderItem : public AccountViewItem 68class IMAPfolderItem : public AccountViewItem
69{ 69{
70 70
71public: 71public:
72 IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); 72 IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after );
73 IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master );
73 ~IMAPfolderItem(); 74 ~IMAPfolderItem();
74 virtual void refresh(QList<RecMail>&); 75 virtual void refresh(QList<RecMail>&);
75 virtual RecBody fetchBody(const RecMail&); 76 virtual RecBody fetchBody(const RecMail&);
77 bool matchName(const QString&name)const;
76private: 78private:
77 Folder *folder; 79 Folder *folder;
78 IMAPviewItem *imap; 80 IMAPviewItem *imap;
79}; 81};
80 82
81class AccountView : public QListView 83class AccountView : public QListView
82{ 84{
83 Q_OBJECT 85 Q_OBJECT
84 86
85public: 87public:
86 AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 88 AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
87 void populate( QList<Account> list ); 89 void populate( QList<Account> list );
88 RecBody fetchBody(const RecMail&aMail); 90 RecBody fetchBody(const RecMail&aMail);
89 91
90public slots: 92public slots:
91 void refreshAll(); 93 void refreshAll();
92 void refresh(QListViewItem *item); 94 void refresh(QListViewItem *item);
93 void refreshCurrent(); 95 void refreshCurrent();
94 96
95signals: 97signals:
96 void refreshMailview(QList<RecMail>*); 98 void refreshMailview(QList<RecMail>*);
97 99
98private: 100private:
99 QListViewItem* m_currentItem; 101 QListViewItem* m_currentItem;
100}; 102};
101 103
102#endif 104#endif
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp
index d56d7f9..8a86c95 100644
--- a/noncore/net/mail/imapwrapper.cpp
+++ b/noncore/net/mail/imapwrapper.cpp
@@ -120,138 +120,141 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
120 120
121 QString date,subject,from; 121 QString date,subject,from;
122 122
123 if ( err == MAILIMAP_NO_ERROR ) { 123 if ( err == MAILIMAP_NO_ERROR ) {
124 124
125 mailimap_msg_att * msg_att; 125 mailimap_msg_att * msg_att;
126 int i = 0; 126 int i = 0;
127 for (current = clist_begin(result); current != 0; current=clist_next(current)) { 127 for (current = clist_begin(result); current != 0; current=clist_next(current)) {
128 ++i; 128 ++i;
129 msg_att = (mailimap_msg_att*)current->data; 129 msg_att = (mailimap_msg_att*)current->data;
130 RecMail*m = parse_list_result(msg_att); 130 RecMail*m = parse_list_result(msg_att);
131 if (m) { 131 if (m) {
132 m->setNumber(i); 132 m->setNumber(i);
133 m->setMbox(mailbox); 133 m->setMbox(mailbox);
134 m->setWrapper(this); 134 m->setWrapper(this);
135 target.append(m); 135 target.append(m);
136 } 136 }
137 } 137 }
138 } else { 138 } else {
139 qDebug("Error fetching headers: %s",m_imap->imap_response); 139 qDebug("Error fetching headers: %s",m_imap->imap_response);
140 } 140 }
141 mailimap_fetch_list_free(result); 141 mailimap_fetch_list_free(result);
142} 142}
143 143
144QList<Folder>* IMAPwrapper::listFolders() 144QList<Folder>* IMAPwrapper::listFolders()
145{ 145{
146 const char *path, *mask; 146 const char *path, *mask;
147 int err = MAILIMAP_NO_ERROR; 147 int err = MAILIMAP_NO_ERROR;
148 clist *result; 148 clist *result;
149 clistcell *current; 149 clistcell *current;
150 150
151 QList<Folder> * folders = new QList<Folder>(); 151 QList<Folder> * folders = new QList<Folder>();
152 folders->setAutoDelete( false ); 152 folders->setAutoDelete( false );
153 login(); 153 login();
154 if (!m_imap) { 154 if (!m_imap) {
155 return folders; 155 return folders;
156 } 156 }
157 157
158/* 158/*
159 * First we have to check for INBOX 'cause it sometimes it's not inside the path. 159 * First we have to check for INBOX 'cause it sometimes it's not inside the path.
160 * We must not forget to filter them out in next loop! 160 * We must not forget to filter them out in next loop!
161 * it seems like ugly code. and yes - it is ugly code. but the best way. 161 * it seems like ugly code. and yes - it is ugly code. but the best way.
162 */ 162 */
163 QString temp; 163 QString temp;
164 mask = "INBOX" ; 164 mask = "INBOX" ;
165 result = clist_new(); 165 result = clist_new();
166 mailimap_mailbox_list *list; 166 mailimap_mailbox_list *list;
167 err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); 167 err = mailimap_list( m_imap, (char*)"", (char*)mask, &result );
168 QString del;
168 if ( err == MAILIMAP_NO_ERROR ) { 169 if ( err == MAILIMAP_NO_ERROR ) {
169 current = result->first; 170 current = result->first;
170 for ( int i = result->count; i > 0; i-- ) { 171 for ( int i = result->count; i > 0; i-- ) {
171 list = (mailimap_mailbox_list *) current->data; 172 list = (mailimap_mailbox_list *) current->data;
172 // it is better use the deep copy mechanism of qt itself 173 // it is better use the deep copy mechanism of qt itself
173 // instead of using strdup! 174 // instead of using strdup!
174 temp = list->mb_name; 175 temp = list->mb_name;
175 folders->append( new IMAPFolder(temp)); 176 del = list->mb_delimiter;
177 folders->append( new IMAPFolder(temp,del,true,account->getPrefix()));
176 current = current->next; 178 current = current->next;
177 } 179 }
178 } else { 180 } else {
179 qDebug("error fetching folders: %s",m_imap->imap_response); 181 qDebug("error fetching folders: %s",m_imap->imap_response);
180 } 182 }
181 mailimap_list_result_free( result ); 183 mailimap_list_result_free( result );
182 184
183/* 185/*
184 * second stage - get the other then inbox folders 186 * second stage - get the other then inbox folders
185 */ 187 */
186 mask = "*" ; 188 mask = "*" ;
187 path = account->getPrefix().latin1(); 189 path = account->getPrefix().latin1();
188 if (!path) path = ""; 190 if (!path) path = "";
189 result = clist_new(); 191 result = clist_new();
190 qDebug(path); 192 qDebug(path);
191 bool selectable = true; 193 bool selectable = true;
192 mailimap_mbx_list_flags*bflags; 194 mailimap_mbx_list_flags*bflags;
193 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); 195 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result );
194 if ( err == MAILIMAP_NO_ERROR ) { 196 if ( err == MAILIMAP_NO_ERROR ) {
195 current = result->first; 197 current = result->first;
196 for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { 198 for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) {
197 list = (mailimap_mailbox_list *) current->data; 199 list = (mailimap_mailbox_list *) current->data;
198 // it is better use the deep copy mechanism of qt itself 200 // it is better use the deep copy mechanism of qt itself
199 // instead of using strdup! 201 // instead of using strdup!
200 temp = list->mb_name; 202 temp = list->mb_name;
201 if (temp.lower()=="inbox") 203 if (temp.lower()=="inbox")
202 continue; 204 continue;
203 if (temp.lower()==account->getPrefix().lower()) 205 if (temp.lower()==account->getPrefix().lower())
204 continue; 206 continue;
205 if ( (bflags = list->mb_flag) ) { 207 if ( (bflags = list->mb_flag) ) {
206 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& 208 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&&
207 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); 209 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT);
208 } 210 }
209 folders->append(new IMAPFolder(temp,selectable,account->getPrefix())); 211 del = list->mb_delimiter;
212 folders->append(new IMAPFolder(temp,del,selectable,account->getPrefix()));
210 } 213 }
211 } else { 214 } else {
212 qDebug("error fetching folders %s",m_imap->imap_response); 215 qDebug("error fetching folders %s",m_imap->imap_response);
213 } 216 }
214 mailimap_list_result_free( result ); 217 mailimap_list_result_free( result );
215 return folders; 218 return folders;
216} 219}
217 220
218RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) 221RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
219{ 222{
220 RecMail * m = 0; 223 RecMail * m = 0;
221 mailimap_msg_att_item *item=0; 224 mailimap_msg_att_item *item=0;
222 clistcell *current,*c,*cf; 225 clistcell *current,*c,*cf;
223 mailimap_msg_att_dynamic*flist; 226 mailimap_msg_att_dynamic*flist;
224 mailimap_flag_fetch*cflag; 227 mailimap_flag_fetch*cflag;
225 int size; 228 int size;
226 QBitArray mFlags(7); 229 QBitArray mFlags(7);
227 QStringList addresslist; 230 QStringList addresslist;
228 231
229 if (!m_att) { 232 if (!m_att) {
230 return m; 233 return m;
231 } 234 }
232 m = new RecMail(); 235 m = new RecMail();
233 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { 236 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) {
234 current = c; 237 current = c;
235 size = 0; 238 size = 0;
236 item = (mailimap_msg_att_item*)current->data; 239 item = (mailimap_msg_att_item*)current->data;
237 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { 240 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) {
238 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; 241 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn;
239 if (!flist->att_list) { 242 if (!flist->att_list) {
240 continue; 243 continue;
241 } 244 }
242 cf = flist->att_list->first; 245 cf = flist->att_list->first;
243 for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { 246 for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) {
244 cflag = (mailimap_flag_fetch*)cf->data; 247 cflag = (mailimap_flag_fetch*)cf->data;
245 if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { 248 if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) {
246 switch (cflag->fl_flag->fl_type) { 249 switch (cflag->fl_flag->fl_type) {
247 case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ 250 case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */
248 mFlags.setBit(FLAG_ANSWERED); 251 mFlags.setBit(FLAG_ANSWERED);
249 break; 252 break;
250 case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ 253 case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */
251 mFlags.setBit(FLAG_FLAGGED); 254 mFlags.setBit(FLAG_FLAGGED);
252 break; 255 break;
253 case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ 256 case MAILIMAP_FLAG_DELETED: /* \Deleted flag */
254 mFlags.setBit(FLAG_DELETED); 257 mFlags.setBit(FLAG_DELETED);
255 break; 258 break;
256 case MAILIMAP_FLAG_SEEN: /* \Seen flag */ 259 case MAILIMAP_FLAG_SEEN: /* \Seen flag */
257 mFlags.setBit(FLAG_SEEN); 260 mFlags.setBit(FLAG_SEEN);
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index d56d7f9..8a86c95 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -120,138 +120,141 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
120 120
121 QString date,subject,from; 121 QString date,subject,from;
122 122
123 if ( err == MAILIMAP_NO_ERROR ) { 123 if ( err == MAILIMAP_NO_ERROR ) {
124 124
125 mailimap_msg_att * msg_att; 125 mailimap_msg_att * msg_att;
126 int i = 0; 126 int i = 0;
127 for (current = clist_begin(result); current != 0; current=clist_next(current)) { 127 for (current = clist_begin(result); current != 0; current=clist_next(current)) {
128 ++i; 128 ++i;
129 msg_att = (mailimap_msg_att*)current->data; 129 msg_att = (mailimap_msg_att*)current->data;
130 RecMail*m = parse_list_result(msg_att); 130 RecMail*m = parse_list_result(msg_att);
131 if (m) { 131 if (m) {
132 m->setNumber(i); 132 m->setNumber(i);
133 m->setMbox(mailbox); 133 m->setMbox(mailbox);
134 m->setWrapper(this); 134 m->setWrapper(this);
135 target.append(m); 135 target.append(m);
136 } 136 }
137 } 137 }
138 } else { 138 } else {
139 qDebug("Error fetching headers: %s",m_imap->imap_response); 139 qDebug("Error fetching headers: %s",m_imap->imap_response);
140 } 140 }
141 mailimap_fetch_list_free(result); 141 mailimap_fetch_list_free(result);
142} 142}
143 143
144QList<Folder>* IMAPwrapper::listFolders() 144QList<Folder>* IMAPwrapper::listFolders()
145{ 145{
146 const char *path, *mask; 146 const char *path, *mask;
147 int err = MAILIMAP_NO_ERROR; 147 int err = MAILIMAP_NO_ERROR;
148 clist *result; 148 clist *result;
149 clistcell *current; 149 clistcell *current;
150 150
151 QList<Folder> * folders = new QList<Folder>(); 151 QList<Folder> * folders = new QList<Folder>();
152 folders->setAutoDelete( false ); 152 folders->setAutoDelete( false );
153 login(); 153 login();
154 if (!m_imap) { 154 if (!m_imap) {
155 return folders; 155 return folders;
156 } 156 }
157 157
158/* 158/*
159 * First we have to check for INBOX 'cause it sometimes it's not inside the path. 159 * First we have to check for INBOX 'cause it sometimes it's not inside the path.
160 * We must not forget to filter them out in next loop! 160 * We must not forget to filter them out in next loop!
161 * it seems like ugly code. and yes - it is ugly code. but the best way. 161 * it seems like ugly code. and yes - it is ugly code. but the best way.
162 */ 162 */
163 QString temp; 163 QString temp;
164 mask = "INBOX" ; 164 mask = "INBOX" ;
165 result = clist_new(); 165 result = clist_new();
166 mailimap_mailbox_list *list; 166 mailimap_mailbox_list *list;
167 err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); 167 err = mailimap_list( m_imap, (char*)"", (char*)mask, &result );
168 QString del;
168 if ( err == MAILIMAP_NO_ERROR ) { 169 if ( err == MAILIMAP_NO_ERROR ) {
169 current = result->first; 170 current = result->first;
170 for ( int i = result->count; i > 0; i-- ) { 171 for ( int i = result->count; i > 0; i-- ) {
171 list = (mailimap_mailbox_list *) current->data; 172 list = (mailimap_mailbox_list *) current->data;
172 // it is better use the deep copy mechanism of qt itself 173 // it is better use the deep copy mechanism of qt itself
173 // instead of using strdup! 174 // instead of using strdup!
174 temp = list->mb_name; 175 temp = list->mb_name;
175 folders->append( new IMAPFolder(temp)); 176 del = list->mb_delimiter;
177 folders->append( new IMAPFolder(temp,del,true,account->getPrefix()));
176 current = current->next; 178 current = current->next;
177 } 179 }
178 } else { 180 } else {
179 qDebug("error fetching folders: %s",m_imap->imap_response); 181 qDebug("error fetching folders: %s",m_imap->imap_response);
180 } 182 }
181 mailimap_list_result_free( result ); 183 mailimap_list_result_free( result );
182 184
183/* 185/*
184 * second stage - get the other then inbox folders 186 * second stage - get the other then inbox folders
185 */ 187 */
186 mask = "*" ; 188 mask = "*" ;
187 path = account->getPrefix().latin1(); 189 path = account->getPrefix().latin1();
188 if (!path) path = ""; 190 if (!path) path = "";
189 result = clist_new(); 191 result = clist_new();
190 qDebug(path); 192 qDebug(path);
191 bool selectable = true; 193 bool selectable = true;
192 mailimap_mbx_list_flags*bflags; 194 mailimap_mbx_list_flags*bflags;
193 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); 195 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result );
194 if ( err == MAILIMAP_NO_ERROR ) { 196 if ( err == MAILIMAP_NO_ERROR ) {
195 current = result->first; 197 current = result->first;
196 for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { 198 for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) {
197 list = (mailimap_mailbox_list *) current->data; 199 list = (mailimap_mailbox_list *) current->data;
198 // it is better use the deep copy mechanism of qt itself 200 // it is better use the deep copy mechanism of qt itself
199 // instead of using strdup! 201 // instead of using strdup!
200 temp = list->mb_name; 202 temp = list->mb_name;
201 if (temp.lower()=="inbox") 203 if (temp.lower()=="inbox")
202 continue; 204 continue;
203 if (temp.lower()==account->getPrefix().lower()) 205 if (temp.lower()==account->getPrefix().lower())
204 continue; 206 continue;
205 if ( (bflags = list->mb_flag) ) { 207 if ( (bflags = list->mb_flag) ) {
206 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& 208 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&&
207 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); 209 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT);
208 } 210 }
209 folders->append(new IMAPFolder(temp,selectable,account->getPrefix())); 211 del = list->mb_delimiter;
212 folders->append(new IMAPFolder(temp,del,selectable,account->getPrefix()));
210 } 213 }
211 } else { 214 } else {
212 qDebug("error fetching folders %s",m_imap->imap_response); 215 qDebug("error fetching folders %s",m_imap->imap_response);
213 } 216 }
214 mailimap_list_result_free( result ); 217 mailimap_list_result_free( result );
215 return folders; 218 return folders;
216} 219}
217 220
218RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) 221RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
219{ 222{
220 RecMail * m = 0; 223 RecMail * m = 0;
221 mailimap_msg_att_item *item=0; 224 mailimap_msg_att_item *item=0;
222 clistcell *current,*c,*cf; 225 clistcell *current,*c,*cf;
223 mailimap_msg_att_dynamic*flist; 226 mailimap_msg_att_dynamic*flist;
224 mailimap_flag_fetch*cflag; 227 mailimap_flag_fetch*cflag;
225 int size; 228 int size;
226 QBitArray mFlags(7); 229 QBitArray mFlags(7);
227 QStringList addresslist; 230 QStringList addresslist;
228 231
229 if (!m_att) { 232 if (!m_att) {
230 return m; 233 return m;
231 } 234 }
232 m = new RecMail(); 235 m = new RecMail();
233 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { 236 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) {
234 current = c; 237 current = c;
235 size = 0; 238 size = 0;
236 item = (mailimap_msg_att_item*)current->data; 239 item = (mailimap_msg_att_item*)current->data;
237 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { 240 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) {
238 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; 241 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn;
239 if (!flist->att_list) { 242 if (!flist->att_list) {
240 continue; 243 continue;
241 } 244 }
242 cf = flist->att_list->first; 245 cf = flist->att_list->first;
243 for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { 246 for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) {
244 cflag = (mailimap_flag_fetch*)cf->data; 247 cflag = (mailimap_flag_fetch*)cf->data;
245 if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { 248 if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) {
246 switch (cflag->fl_flag->fl_type) { 249 switch (cflag->fl_flag->fl_type) {
247 case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ 250 case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */
248 mFlags.setBit(FLAG_ANSWERED); 251 mFlags.setBit(FLAG_ANSWERED);
249 break; 252 break;
250 case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ 253 case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */
251 mFlags.setBit(FLAG_FLAGGED); 254 mFlags.setBit(FLAG_FLAGGED);
252 break; 255 break;
253 case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ 256 case MAILIMAP_FLAG_DELETED: /* \Deleted flag */
254 mFlags.setBit(FLAG_DELETED); 257 mFlags.setBit(FLAG_DELETED);
255 break; 258 break;
256 case MAILIMAP_FLAG_SEEN: /* \Seen flag */ 259 case MAILIMAP_FLAG_SEEN: /* \Seen flag */
257 mFlags.setBit(FLAG_SEEN); 260 mFlags.setBit(FLAG_SEEN);
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp
index 96602c2..858283f 100644
--- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp
@@ -1,90 +1,95 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <sys/stat.h> 2#include <sys/stat.h>
3#include <sys/types.h> 3#include <sys/types.h>
4#include <unistd.h> 4#include <unistd.h>
5#include <fcntl.h> 5#include <fcntl.h>
6#include <string.h> 6#include <string.h>
7#include <qdir.h> 7#include <qdir.h>
8 8
9#include "mailwrapper.h" 9#include "mailwrapper.h"
10#include "logindialog.h" 10#include "logindialog.h"
11//#include "mail.h" 11//#include "mail.h"
12#include "defines.h" 12#include "defines.h"
13 13
14Attachment::Attachment( DocLnk lnk ) 14Attachment::Attachment( DocLnk lnk )
15{ 15{
16 doc = lnk; 16 doc = lnk;
17 size = QFileInfo( doc.file() ).size(); 17 size = QFileInfo( doc.file() ).size();
18} 18}
19 19
20Folder::Folder(const QString&tmp_name ) 20Folder::Folder(const QString&tmp_name, const QString&sep )
21{ 21{
22 name = tmp_name; 22 name = tmp_name;
23 nameDisplay = name; 23 nameDisplay = name;
24 24
25 for ( int pos = nameDisplay.find( '&' ); pos != -1; 25 for ( int pos = nameDisplay.find( '&' ); pos != -1;
26 pos = nameDisplay.find( '&' ) ) { 26 pos = nameDisplay.find( '&' ) ) {
27 int end = nameDisplay.find( '-' ); 27 int end = nameDisplay.find( '-' );
28 if ( end == -1 || end <= pos ) break; 28 if ( end == -1 || end <= pos ) break;
29 QString str64 = nameDisplay.mid( pos + 1, end - pos - 1 ); 29 QString str64 = nameDisplay.mid( pos + 1, end - pos - 1 );
30 // TODO: do real base64 decoding here ! 30 // TODO: do real base64 decoding here !
31 if ( str64.compare( "APw" ) == 0 ) { 31 if ( str64.compare( "APw" ) == 0 ) {
32 nameDisplay = nameDisplay.replace( pos, end - pos + 1, "ue" ); 32 nameDisplay = nameDisplay.replace( pos, end - pos + 1, "ue" );
33 } else if ( str64.compare( "APY" ) == 0 ) { 33 } else if ( str64.compare( "APY" ) == 0 ) {
34 nameDisplay = nameDisplay.replace( pos, end - pos + 1, "oe" ); 34 nameDisplay = nameDisplay.replace( pos, end - pos + 1, "oe" );
35 } 35 }
36 } 36 }
37 qDebug( "folder " + name + " - displayed as " + nameDisplay ); 37 qDebug( "folder " + name + " - displayed as " + nameDisplay );
38 separator = sep;
38} 39}
39 40
41const QString& Folder::Separator()const
42{
43 return separator;
44}
40 45
41IMAPFolder::IMAPFolder(const QString&name,bool select,const QString&prefix ) 46IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,const QString&prefix )
42 : Folder( name ),m_MaySelect(select) 47 : Folder( name,sep ),m_MaySelect(select)
43{ 48{
44 if (prefix.length()>0) { 49 if (prefix.length()>0) {
45 if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) { 50 if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) {
46 nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length()); 51 nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length());
47 } 52 }
48 } 53 }
49} 54}
50 55
51MailWrapper::MailWrapper( Settings *s ) 56MailWrapper::MailWrapper( Settings *s )
52 : QObject() 57 : QObject()
53{ 58{
54 settings = s; 59 settings = s;
55} 60}
56 61
57QString MailWrapper::mailsmtpError( int errnum ) 62QString MailWrapper::mailsmtpError( int errnum )
58{ 63{
59 switch ( errnum ) { 64 switch ( errnum ) {
60 case MAILSMTP_NO_ERROR: 65 case MAILSMTP_NO_ERROR:
61 return tr( "No error" ); 66 return tr( "No error" );
62 case MAILSMTP_ERROR_UNEXPECTED_CODE: 67 case MAILSMTP_ERROR_UNEXPECTED_CODE:
63 return tr( "Unexpected error code" ); 68 return tr( "Unexpected error code" );
64 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: 69 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE:
65 return tr( "Service not available" ); 70 return tr( "Service not available" );
66 case MAILSMTP_ERROR_STREAM: 71 case MAILSMTP_ERROR_STREAM:
67 return tr( "Stream error" ); 72 return tr( "Stream error" );
68 case MAILSMTP_ERROR_HOSTNAME: 73 case MAILSMTP_ERROR_HOSTNAME:
69 return tr( "gethostname() failed" ); 74 return tr( "gethostname() failed" );
70 case MAILSMTP_ERROR_NOT_IMPLEMENTED: 75 case MAILSMTP_ERROR_NOT_IMPLEMENTED:
71 return tr( "Not implemented" ); 76 return tr( "Not implemented" );
72 case MAILSMTP_ERROR_ACTION_NOT_TAKEN: 77 case MAILSMTP_ERROR_ACTION_NOT_TAKEN:
73 return tr( "Error, action not taken" ); 78 return tr( "Error, action not taken" );
74 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: 79 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION:
75 return tr( "Data exceeds storage allocation" ); 80 return tr( "Data exceeds storage allocation" );
76 case MAILSMTP_ERROR_IN_PROCESSING: 81 case MAILSMTP_ERROR_IN_PROCESSING:
77 return tr( "Error in processing" ); 82 return tr( "Error in processing" );
78 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: 83 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE:
79 // return tr( "Insufficient system storage" ); 84 // return tr( "Insufficient system storage" );
80 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: 85 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE:
81 return tr( "Mailbox unavailable" ); 86 return tr( "Mailbox unavailable" );
82 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: 87 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED:
83 return tr( "Mailbox name not allowed" ); 88 return tr( "Mailbox name not allowed" );
84 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: 89 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND:
85 return tr( "Bad command sequence" ); 90 return tr( "Bad command sequence" );
86 case MAILSMTP_ERROR_USER_NOT_LOCAL: 91 case MAILSMTP_ERROR_USER_NOT_LOCAL:
87 return tr( "User not local" ); 92 return tr( "User not local" );
88 case MAILSMTP_ERROR_TRANSACTION_FAILED: 93 case MAILSMTP_ERROR_TRANSACTION_FAILED:
89 return tr( "Transaction failed" ); 94 return tr( "Transaction failed" );
90 case MAILSMTP_ERROR_MEMORY: 95 case MAILSMTP_ERROR_MEMORY:
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.h b/noncore/net/mail/libmailwrapper/mailwrapper.h
index 6994dd8..d78f8e9 100644
--- a/noncore/net/mail/libmailwrapper/mailwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mailwrapper.h
@@ -26,98 +26,99 @@ public:
26 DocLnk getDocLnk() { return doc; } 26 DocLnk getDocLnk() { return doc; }
27 27
28protected: 28protected:
29 DocLnk doc; 29 DocLnk doc;
30 int size; 30 int size;
31 31
32}; 32};
33 33
34class Mail 34class Mail
35{ 35{
36public: 36public:
37 Mail(); 37 Mail();
38 /* Possible that this destructor must not be declared virtual 38 /* Possible that this destructor must not be declared virtual
39 * 'cause it seems that it will never have some child classes. 39 * 'cause it seems that it will never have some child classes.
40 * in this case this object will not get a virtual table -> memory and 40 * in this case this object will not get a virtual table -> memory and
41 * speed will be a little bit better? 41 * speed will be a little bit better?
42 */ 42 */
43 virtual ~Mail(){} 43 virtual ~Mail(){}
44 void addAttachment( Attachment *att ) { attList.append( att ); } 44 void addAttachment( Attachment *att ) { attList.append( att ); }
45 const QList<Attachment>& getAttachments()const { return attList; } 45 const QList<Attachment>& getAttachments()const { return attList; }
46 void removeAttachment( Attachment *att ) { attList.remove( att ); } 46 void removeAttachment( Attachment *att ) { attList.remove( att ); }
47 const QString&getName()const { return name; } 47 const QString&getName()const { return name; }
48 void setName( QString s ) { name = s; } 48 void setName( QString s ) { name = s; }
49 const QString&getMail()const{ return mail; } 49 const QString&getMail()const{ return mail; }
50 void setMail( const QString&s ) { mail = s; } 50 void setMail( const QString&s ) { mail = s; }
51 const QString&getTo()const{ return to; } 51 const QString&getTo()const{ return to; }
52 void setTo( const QString&s ) { to = s; } 52 void setTo( const QString&s ) { to = s; }
53 const QString&getCC()const{ return cc; } 53 const QString&getCC()const{ return cc; }
54 void setCC( const QString&s ) { cc = s; } 54 void setCC( const QString&s ) { cc = s; }
55 const QString&getBCC()const { return bcc; } 55 const QString&getBCC()const { return bcc; }
56 void setBCC( const QString&s ) { bcc = s; } 56 void setBCC( const QString&s ) { bcc = s; }
57 const QString&getMessage()const { return message; } 57 const QString&getMessage()const { return message; }
58 void setMessage( const QString&s ) { message = s; } 58 void setMessage( const QString&s ) { message = s; }
59 const QString&getSubject()const { return subject; } 59 const QString&getSubject()const { return subject; }
60 void setSubject( const QString&s ) { subject = s; } 60 void setSubject( const QString&s ) { subject = s; }
61 const QString&getReply()const{ return reply; } 61 const QString&getReply()const{ return reply; }
62 void setReply( const QString&a ) { reply = a; } 62 void setReply( const QString&a ) { reply = a; }
63 63
64private: 64private:
65 QList<Attachment> attList; 65 QList<Attachment> attList;
66 QString name, mail, to, cc, bcc, reply, subject, message; 66 QString name, mail, to, cc, bcc, reply, subject, message;
67}; 67};
68 68
69class Folder : public QObject 69class Folder : public QObject
70{ 70{
71 Q_OBJECT 71 Q_OBJECT
72 72
73public: 73public:
74 Folder( const QString&init_name ); 74 Folder( const QString&init_name,const QString&sep );
75 const QString&getDisplayName()const { return nameDisplay; } 75 const QString&getDisplayName()const { return nameDisplay; }
76 const QString&getName()const { return name; } 76 const QString&getName()const { return name; }
77 virtual bool may_select()const{return true;}; 77 virtual bool may_select()const{return true;};
78 const QString&Separator()const;
78 79
79protected: 80protected:
80 QString nameDisplay, name; 81 QString nameDisplay, name, separator;
81 82
82}; 83};
83 84
84class IMAPFolder : public Folder 85class IMAPFolder : public Folder
85{ 86{
86 public: 87 public:
87 IMAPFolder(const QString&name,bool select=true,const QString&prefix="" ); 88 IMAPFolder(const QString&name, const QString&sep, bool select=true,const QString&prefix="" );
88 virtual bool may_select()const{return m_MaySelect;} 89 virtual bool may_select()const{return m_MaySelect;}
89 private: 90 private:
90 bool m_MaySelect; 91 bool m_MaySelect;
91}; 92};
92 93
93class MailWrapper : public QObject 94class MailWrapper : public QObject
94{ 95{
95 Q_OBJECT 96 Q_OBJECT
96 97
97public: 98public:
98 MailWrapper( Settings *s ); 99 MailWrapper( Settings *s );
99 void sendMail( Mail mail ); 100 void sendMail( Mail mail );
100 101
101private: 102private:
102 mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); 103 mailimf_mailbox *newMailbox(const QString&name,const QString&mail );
103 mailimf_address_list *parseAddresses(const QString&addr ); 104 mailimf_address_list *parseAddresses(const QString&addr );
104 mailimf_fields *createImfFields( Mail *mail ); 105 mailimf_fields *createImfFields( Mail *mail );
105 mailmime *buildTxtPart( QString str ); 106 mailmime *buildTxtPart( QString str );
106 mailmime *buildFilePart( QString filename, QString mimetype ); 107 mailmime *buildFilePart( QString filename, QString mimetype );
107 void addFileParts( mailmime *message, QList<Attachment> files ); 108 void addFileParts( mailmime *message, QList<Attachment> files );
108 mailmime *createMimeMail( Mail *mail ); 109 mailmime *createMimeMail( Mail *mail );
109 void smtpSend( mailmime *mail ); 110 void smtpSend( mailmime *mail );
110 mailimf_field *getField( mailimf_fields *fields, int type ); 111 mailimf_field *getField( mailimf_fields *fields, int type );
111 clist *createRcptList( mailimf_fields *fields ); 112 clist *createRcptList( mailimf_fields *fields );
112 char *getFrom( mailmime *mail ); 113 char *getFrom( mailmime *mail );
113 SMTPaccount *getAccount( QString from ); 114 SMTPaccount *getAccount( QString from );
114 void writeToFile( QString file, mailmime *mail ); 115 void writeToFile( QString file, mailmime *mail );
115 void readFromFile( QString file, char **data, size_t *size ); 116 void readFromFile( QString file, char **data, size_t *size );
116 static QString mailsmtpError( int err ); 117 static QString mailsmtpError( int err );
117 static QString getTmpFile(); 118 static QString getTmpFile();
118 119
119 Settings *settings; 120 Settings *settings;
120 121
121}; 122};
122 123
123#endif 124#endif
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index 075d8c7..4508a95 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -278,81 +278,81 @@ void POP3wrapper::login()
278 278
279 m_pop3 = mailpop3_new( 200, &pop3_progress ); 279 m_pop3 = mailpop3_new( 200, &pop3_progress );
280 280
281 // connect 281 // connect
282 if (account->getSSL()) { 282 if (account->getSSL()) {
283 err = mailpop3_ssl_connect( m_pop3, (char*)server, port ); 283 err = mailpop3_ssl_connect( m_pop3, (char*)server, port );
284 } else { 284 } else {
285 err = mailpop3_socket_connect( m_pop3, (char*)server, port ); 285 err = mailpop3_socket_connect( m_pop3, (char*)server, port );
286 } 286 }
287 287
288 if ( err != MAILPOP3_NO_ERROR ) { 288 if ( err != MAILPOP3_NO_ERROR ) {
289 qDebug( "pop3: error connecting to %s\n reason: %s", server, 289 qDebug( "pop3: error connecting to %s\n reason: %s", server,
290 m_pop3->pop3_response ); 290 m_pop3->pop3_response );
291 mailpop3_free( m_pop3 ); 291 mailpop3_free( m_pop3 );
292 m_pop3 = NULL; 292 m_pop3 = NULL;
293 return; 293 return;
294 } 294 }
295 qDebug( "POP3: connected!" ); 295 qDebug( "POP3: connected!" );
296 296
297 // login 297 // login
298 // TODO: decide if apop or plain login should be used 298 // TODO: decide if apop or plain login should be used
299 err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); 299 err = mailpop3_login( m_pop3, (char *) user, (char *) pass );
300 if ( err != MAILPOP3_NO_ERROR ) { 300 if ( err != MAILPOP3_NO_ERROR ) {
301 qDebug( "pop3: error logging in: %s", m_pop3->pop3_response ); 301 qDebug( "pop3: error logging in: %s", m_pop3->pop3_response );
302 logout(); 302 logout();
303 return; 303 return;
304 } 304 }
305 305
306 qDebug( "POP3: logged in!" ); 306 qDebug( "POP3: logged in!" );
307} 307}
308 308
309void POP3wrapper::logout() 309void POP3wrapper::logout()
310{ 310{
311 int err = MAILPOP3_NO_ERROR; 311 int err = MAILPOP3_NO_ERROR;
312 if ( m_pop3 == NULL ) return; 312 if ( m_pop3 == NULL ) return;
313 err = mailpop3_quit( m_pop3 ); 313 err = mailpop3_quit( m_pop3 );
314 mailpop3_free( m_pop3 ); 314 mailpop3_free( m_pop3 );
315 m_pop3 = NULL; 315 m_pop3 = NULL;
316} 316}
317 317
318 318
319QList<Folder>* POP3wrapper::listFolders() 319QList<Folder>* POP3wrapper::listFolders()
320{ 320{
321 /* TODO: integrate MH directories 321 /* TODO: integrate MH directories
322 but not before version 0.1 ;) 322 but not before version 0.1 ;)
323 */ 323 */
324 QList<Folder> * folders = new QList<Folder>(); 324 QList<Folder> * folders = new QList<Folder>();
325 folders->setAutoDelete( false ); 325 folders->setAutoDelete( false );
326 Folder*inb=new Folder("INBOX"); 326 Folder*inb=new Folder("INBOX","/");
327 folders->append(inb); 327 folders->append(inb);
328 return folders; 328 return folders;
329} 329}
330 330
331QString POP3wrapper::fetchTextPart(const RecMail&,const RecPart&) 331QString POP3wrapper::fetchTextPart(const RecMail&,const RecPart&)
332{ 332{
333 return ""; 333 return "";
334} 334}
335 335
336void POP3wrapper::deleteMail(const RecMail&mail) 336void POP3wrapper::deleteMail(const RecMail&mail)
337{ 337{
338 login(); 338 login();
339 if (!m_pop3) return; 339 if (!m_pop3) return;
340 int err = mailpop3_dele(m_pop3,mail.getNumber()); 340 int err = mailpop3_dele(m_pop3,mail.getNumber());
341 if (err != MAILPOP3_NO_ERROR) { 341 if (err != MAILPOP3_NO_ERROR) {
342 qDebug("error deleting mail"); 342 qDebug("error deleting mail");
343 } 343 }
344} 344}
345 345
346void POP3wrapper::answeredMail(const RecMail&) 346void POP3wrapper::answeredMail(const RecMail&)
347{ 347{
348} 348}
349 349
350encodedString* POP3wrapper::fetchDecodedPart(const RecMail&,const RecPart&) 350encodedString* POP3wrapper::fetchDecodedPart(const RecMail&,const RecPart&)
351{ 351{
352 return new encodedString(); 352 return new encodedString();
353} 353}
354 354
355encodedString* POP3wrapper::fetchRawPart(const RecMail&,const RecPart&) 355encodedString* POP3wrapper::fetchRawPart(const RecMail&,const RecPart&)
356{ 356{
357 return new encodedString(); 357 return new encodedString();
358} 358}
diff --git a/noncore/net/mail/mailwrapper.cpp b/noncore/net/mail/mailwrapper.cpp
index 96602c2..858283f 100644
--- a/noncore/net/mail/mailwrapper.cpp
+++ b/noncore/net/mail/mailwrapper.cpp
@@ -1,90 +1,95 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <sys/stat.h> 2#include <sys/stat.h>
3#include <sys/types.h> 3#include <sys/types.h>
4#include <unistd.h> 4#include <unistd.h>
5#include <fcntl.h> 5#include <fcntl.h>
6#include <string.h> 6#include <string.h>
7#include <qdir.h> 7#include <qdir.h>
8 8
9#include "mailwrapper.h" 9#include "mailwrapper.h"
10#include "logindialog.h" 10#include "logindialog.h"
11//#include "mail.h" 11//#include "mail.h"
12#include "defines.h" 12#include "defines.h"
13 13
14Attachment::Attachment( DocLnk lnk ) 14Attachment::Attachment( DocLnk lnk )
15{ 15{
16 doc = lnk; 16 doc = lnk;
17 size = QFileInfo( doc.file() ).size(); 17 size = QFileInfo( doc.file() ).size();
18} 18}
19 19
20Folder::Folder(const QString&tmp_name ) 20Folder::Folder(const QString&tmp_name, const QString&sep )
21{ 21{
22 name = tmp_name; 22 name = tmp_name;
23 nameDisplay = name; 23 nameDisplay = name;
24 24
25 for ( int pos = nameDisplay.find( '&' ); pos != -1; 25 for ( int pos = nameDisplay.find( '&' ); pos != -1;
26 pos = nameDisplay.find( '&' ) ) { 26 pos = nameDisplay.find( '&' ) ) {
27 int end = nameDisplay.find( '-' ); 27 int end = nameDisplay.find( '-' );
28 if ( end == -1 || end <= pos ) break; 28 if ( end == -1 || end <= pos ) break;
29 QString str64 = nameDisplay.mid( pos + 1, end - pos - 1 ); 29 QString str64 = nameDisplay.mid( pos + 1, end - pos - 1 );
30 // TODO: do real base64 decoding here ! 30 // TODO: do real base64 decoding here !
31 if ( str64.compare( "APw" ) == 0 ) { 31 if ( str64.compare( "APw" ) == 0 ) {
32 nameDisplay = nameDisplay.replace( pos, end - pos + 1, "ue" ); 32 nameDisplay = nameDisplay.replace( pos, end - pos + 1, "ue" );
33 } else if ( str64.compare( "APY" ) == 0 ) { 33 } else if ( str64.compare( "APY" ) == 0 ) {
34 nameDisplay = nameDisplay.replace( pos, end - pos + 1, "oe" ); 34 nameDisplay = nameDisplay.replace( pos, end - pos + 1, "oe" );
35 } 35 }
36 } 36 }
37 qDebug( "folder " + name + " - displayed as " + nameDisplay ); 37 qDebug( "folder " + name + " - displayed as " + nameDisplay );
38 separator = sep;
38} 39}
39 40
41const QString& Folder::Separator()const
42{
43 return separator;
44}
40 45
41IMAPFolder::IMAPFolder(const QString&name,bool select,const QString&prefix ) 46IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,const QString&prefix )
42 : Folder( name ),m_MaySelect(select) 47 : Folder( name,sep ),m_MaySelect(select)
43{ 48{
44 if (prefix.length()>0) { 49 if (prefix.length()>0) {
45 if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) { 50 if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) {
46 nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length()); 51 nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length());
47 } 52 }
48 } 53 }
49} 54}
50 55
51MailWrapper::MailWrapper( Settings *s ) 56MailWrapper::MailWrapper( Settings *s )
52 : QObject() 57 : QObject()
53{ 58{
54 settings = s; 59 settings = s;
55} 60}
56 61
57QString MailWrapper::mailsmtpError( int errnum ) 62QString MailWrapper::mailsmtpError( int errnum )
58{ 63{
59 switch ( errnum ) { 64 switch ( errnum ) {
60 case MAILSMTP_NO_ERROR: 65 case MAILSMTP_NO_ERROR:
61 return tr( "No error" ); 66 return tr( "No error" );
62 case MAILSMTP_ERROR_UNEXPECTED_CODE: 67 case MAILSMTP_ERROR_UNEXPECTED_CODE:
63 return tr( "Unexpected error code" ); 68 return tr( "Unexpected error code" );
64 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: 69 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE:
65 return tr( "Service not available" ); 70 return tr( "Service not available" );
66 case MAILSMTP_ERROR_STREAM: 71 case MAILSMTP_ERROR_STREAM:
67 return tr( "Stream error" ); 72 return tr( "Stream error" );
68 case MAILSMTP_ERROR_HOSTNAME: 73 case MAILSMTP_ERROR_HOSTNAME:
69 return tr( "gethostname() failed" ); 74 return tr( "gethostname() failed" );
70 case MAILSMTP_ERROR_NOT_IMPLEMENTED: 75 case MAILSMTP_ERROR_NOT_IMPLEMENTED:
71 return tr( "Not implemented" ); 76 return tr( "Not implemented" );
72 case MAILSMTP_ERROR_ACTION_NOT_TAKEN: 77 case MAILSMTP_ERROR_ACTION_NOT_TAKEN:
73 return tr( "Error, action not taken" ); 78 return tr( "Error, action not taken" );
74 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: 79 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION:
75 return tr( "Data exceeds storage allocation" ); 80 return tr( "Data exceeds storage allocation" );
76 case MAILSMTP_ERROR_IN_PROCESSING: 81 case MAILSMTP_ERROR_IN_PROCESSING:
77 return tr( "Error in processing" ); 82 return tr( "Error in processing" );
78 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: 83 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE:
79 // return tr( "Insufficient system storage" ); 84 // return tr( "Insufficient system storage" );
80 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: 85 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE:
81 return tr( "Mailbox unavailable" ); 86 return tr( "Mailbox unavailable" );
82 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: 87 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED:
83 return tr( "Mailbox name not allowed" ); 88 return tr( "Mailbox name not allowed" );
84 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: 89 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND:
85 return tr( "Bad command sequence" ); 90 return tr( "Bad command sequence" );
86 case MAILSMTP_ERROR_USER_NOT_LOCAL: 91 case MAILSMTP_ERROR_USER_NOT_LOCAL:
87 return tr( "User not local" ); 92 return tr( "User not local" );
88 case MAILSMTP_ERROR_TRANSACTION_FAILED: 93 case MAILSMTP_ERROR_TRANSACTION_FAILED:
89 return tr( "Transaction failed" ); 94 return tr( "Transaction failed" );
90 case MAILSMTP_ERROR_MEMORY: 95 case MAILSMTP_ERROR_MEMORY:
diff --git a/noncore/net/mail/mailwrapper.h b/noncore/net/mail/mailwrapper.h
index 6994dd8..d78f8e9 100644
--- a/noncore/net/mail/mailwrapper.h
+++ b/noncore/net/mail/mailwrapper.h
@@ -26,98 +26,99 @@ public:
26 DocLnk getDocLnk() { return doc; } 26 DocLnk getDocLnk() { return doc; }
27 27
28protected: 28protected:
29 DocLnk doc; 29 DocLnk doc;
30 int size; 30 int size;
31 31
32}; 32};
33 33
34class Mail 34class Mail
35{ 35{
36public: 36public:
37 Mail(); 37 Mail();
38 /* Possible that this destructor must not be declared virtual 38 /* Possible that this destructor must not be declared virtual
39 * 'cause it seems that it will never have some child classes. 39 * 'cause it seems that it will never have some child classes.
40 * in this case this object will not get a virtual table -> memory and 40 * in this case this object will not get a virtual table -> memory and
41 * speed will be a little bit better? 41 * speed will be a little bit better?
42 */ 42 */
43 virtual ~Mail(){} 43 virtual ~Mail(){}
44 void addAttachment( Attachment *att ) { attList.append( att ); } 44 void addAttachment( Attachment *att ) { attList.append( att ); }
45 const QList<Attachment>& getAttachments()const { return attList; } 45 const QList<Attachment>& getAttachments()const { return attList; }
46 void removeAttachment( Attachment *att ) { attList.remove( att ); } 46 void removeAttachment( Attachment *att ) { attList.remove( att ); }
47 const QString&getName()const { return name; } 47 const QString&getName()const { return name; }
48 void setName( QString s ) { name = s; } 48 void setName( QString s ) { name = s; }
49 const QString&getMail()const{ return mail; } 49 const QString&getMail()const{ return mail; }
50 void setMail( const QString&s ) { mail = s; } 50 void setMail( const QString&s ) { mail = s; }
51 const QString&getTo()const{ return to; } 51 const QString&getTo()const{ return to; }
52 void setTo( const QString&s ) { to = s; } 52 void setTo( const QString&s ) { to = s; }
53 const QString&getCC()const{ return cc; } 53 const QString&getCC()const{ return cc; }
54 void setCC( const QString&s ) { cc = s; } 54 void setCC( const QString&s ) { cc = s; }
55 const QString&getBCC()const { return bcc; } 55 const QString&getBCC()const { return bcc; }
56 void setBCC( const QString&s ) { bcc = s; } 56 void setBCC( const QString&s ) { bcc = s; }
57 const QString&getMessage()const { return message; } 57 const QString&getMessage()const { return message; }
58 void setMessage( const QString&s ) { message = s; } 58 void setMessage( const QString&s ) { message = s; }
59 const QString&getSubject()const { return subject; } 59 const QString&getSubject()const { return subject; }
60 void setSubject( const QString&s ) { subject = s; } 60 void setSubject( const QString&s ) { subject = s; }
61 const QString&getReply()const{ return reply; } 61 const QString&getReply()const{ return reply; }
62 void setReply( const QString&a ) { reply = a; } 62 void setReply( const QString&a ) { reply = a; }
63 63
64private: 64private:
65 QList<Attachment> attList; 65 QList<Attachment> attList;
66 QString name, mail, to, cc, bcc, reply, subject, message; 66 QString name, mail, to, cc, bcc, reply, subject, message;
67}; 67};
68 68
69class Folder : public QObject 69class Folder : public QObject
70{ 70{
71 Q_OBJECT 71 Q_OBJECT
72 72
73public: 73public:
74 Folder( const QString&init_name ); 74 Folder( const QString&init_name,const QString&sep );
75 const QString&getDisplayName()const { return nameDisplay; } 75 const QString&getDisplayName()const { return nameDisplay; }
76 const QString&getName()const { return name; } 76 const QString&getName()const { return name; }
77 virtual bool may_select()const{return true;}; 77 virtual bool may_select()const{return true;};
78 const QString&Separator()const;
78 79
79protected: 80protected:
80 QString nameDisplay, name; 81 QString nameDisplay, name, separator;
81 82
82}; 83};
83 84
84class IMAPFolder : public Folder 85class IMAPFolder : public Folder
85{ 86{
86 public: 87 public:
87 IMAPFolder(const QString&name,bool select=true,const QString&prefix="" ); 88 IMAPFolder(const QString&name, const QString&sep, bool select=true,const QString&prefix="" );
88 virtual bool may_select()const{return m_MaySelect;} 89 virtual bool may_select()const{return m_MaySelect;}
89 private: 90 private:
90 bool m_MaySelect; 91 bool m_MaySelect;
91}; 92};
92 93
93class MailWrapper : public QObject 94class MailWrapper : public QObject
94{ 95{
95 Q_OBJECT 96 Q_OBJECT
96 97
97public: 98public:
98 MailWrapper( Settings *s ); 99 MailWrapper( Settings *s );
99 void sendMail( Mail mail ); 100 void sendMail( Mail mail );
100 101
101private: 102private:
102 mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); 103 mailimf_mailbox *newMailbox(const QString&name,const QString&mail );
103 mailimf_address_list *parseAddresses(const QString&addr ); 104 mailimf_address_list *parseAddresses(const QString&addr );
104 mailimf_fields *createImfFields( Mail *mail ); 105 mailimf_fields *createImfFields( Mail *mail );
105 mailmime *buildTxtPart( QString str ); 106 mailmime *buildTxtPart( QString str );
106 mailmime *buildFilePart( QString filename, QString mimetype ); 107 mailmime *buildFilePart( QString filename, QString mimetype );
107 void addFileParts( mailmime *message, QList<Attachment> files ); 108 void addFileParts( mailmime *message, QList<Attachment> files );
108 mailmime *createMimeMail( Mail *mail ); 109 mailmime *createMimeMail( Mail *mail );
109 void smtpSend( mailmime *mail ); 110 void smtpSend( mailmime *mail );
110 mailimf_field *getField( mailimf_fields *fields, int type ); 111 mailimf_field *getField( mailimf_fields *fields, int type );
111 clist *createRcptList( mailimf_fields *fields ); 112 clist *createRcptList( mailimf_fields *fields );
112 char *getFrom( mailmime *mail ); 113 char *getFrom( mailmime *mail );
113 SMTPaccount *getAccount( QString from ); 114 SMTPaccount *getAccount( QString from );
114 void writeToFile( QString file, mailmime *mail ); 115 void writeToFile( QString file, mailmime *mail );
115 void readFromFile( QString file, char **data, size_t *size ); 116 void readFromFile( QString file, char **data, size_t *size );
116 static QString mailsmtpError( int err ); 117 static QString mailsmtpError( int err );
117 static QString getTmpFile(); 118 static QString getTmpFile();
118 119
119 Settings *settings; 120 Settings *settings;
120 121
121}; 122};
122 123
123#endif 124#endif
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp
index 075d8c7..4508a95 100644
--- a/noncore/net/mail/pop3wrapper.cpp
+++ b/noncore/net/mail/pop3wrapper.cpp
@@ -278,81 +278,81 @@ void POP3wrapper::login()
278 278
279 m_pop3 = mailpop3_new( 200, &pop3_progress ); 279 m_pop3 = mailpop3_new( 200, &pop3_progress );
280 280
281 // connect 281 // connect
282 if (account->getSSL()) { 282 if (account->getSSL()) {
283 err = mailpop3_ssl_connect( m_pop3, (char*)server, port ); 283 err = mailpop3_ssl_connect( m_pop3, (char*)server, port );
284 } else { 284 } else {
285 err = mailpop3_socket_connect( m_pop3, (char*)server, port ); 285 err = mailpop3_socket_connect( m_pop3, (char*)server, port );
286 } 286 }
287 287
288 if ( err != MAILPOP3_NO_ERROR ) { 288 if ( err != MAILPOP3_NO_ERROR ) {
289 qDebug( "pop3: error connecting to %s\n reason: %s", server, 289 qDebug( "pop3: error connecting to %s\n reason: %s", server,
290 m_pop3->pop3_response ); 290 m_pop3->pop3_response );
291 mailpop3_free( m_pop3 ); 291 mailpop3_free( m_pop3 );
292 m_pop3 = NULL; 292 m_pop3 = NULL;
293 return; 293 return;
294 } 294 }
295 qDebug( "POP3: connected!" ); 295 qDebug( "POP3: connected!" );
296 296
297 // login 297 // login
298 // TODO: decide if apop or plain login should be used 298 // TODO: decide if apop or plain login should be used
299 err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); 299 err = mailpop3_login( m_pop3, (char *) user, (char *) pass );
300 if ( err != MAILPOP3_NO_ERROR ) { 300 if ( err != MAILPOP3_NO_ERROR ) {
301 qDebug( "pop3: error logging in: %s", m_pop3->pop3_response ); 301 qDebug( "pop3: error logging in: %s", m_pop3->pop3_response );
302 logout(); 302 logout();
303 return; 303 return;
304 } 304 }
305 305
306 qDebug( "POP3: logged in!" ); 306 qDebug( "POP3: logged in!" );
307} 307}
308 308
309void POP3wrapper::logout() 309void POP3wrapper::logout()
310{ 310{
311 int err = MAILPOP3_NO_ERROR; 311 int err = MAILPOP3_NO_ERROR;
312 if ( m_pop3 == NULL ) return; 312 if ( m_pop3 == NULL ) return;
313 err = mailpop3_quit( m_pop3 ); 313 err = mailpop3_quit( m_pop3 );
314 mailpop3_free( m_pop3 ); 314 mailpop3_free( m_pop3 );
315 m_pop3 = NULL; 315 m_pop3 = NULL;
316} 316}
317 317
318 318
319QList<Folder>* POP3wrapper::listFolders() 319QList<Folder>* POP3wrapper::listFolders()
320{ 320{
321 /* TODO: integrate MH directories 321 /* TODO: integrate MH directories
322 but not before version 0.1 ;) 322 but not before version 0.1 ;)
323 */ 323 */
324 QList<Folder> * folders = new QList<Folder>(); 324 QList<Folder> * folders = new QList<Folder>();
325 folders->setAutoDelete( false ); 325 folders->setAutoDelete( false );
326 Folder*inb=new Folder("INBOX"); 326 Folder*inb=new Folder("INBOX","/");
327 folders->append(inb); 327 folders->append(inb);
328 return folders; 328 return folders;
329} 329}
330 330
331QString POP3wrapper::fetchTextPart(const RecMail&,const RecPart&) 331QString POP3wrapper::fetchTextPart(const RecMail&,const RecPart&)
332{ 332{
333 return ""; 333 return "";
334} 334}
335 335
336void POP3wrapper::deleteMail(const RecMail&mail) 336void POP3wrapper::deleteMail(const RecMail&mail)
337{ 337{
338 login(); 338 login();
339 if (!m_pop3) return; 339 if (!m_pop3) return;
340 int err = mailpop3_dele(m_pop3,mail.getNumber()); 340 int err = mailpop3_dele(m_pop3,mail.getNumber());
341 if (err != MAILPOP3_NO_ERROR) { 341 if (err != MAILPOP3_NO_ERROR) {
342 qDebug("error deleting mail"); 342 qDebug("error deleting mail");
343 } 343 }
344} 344}
345 345
346void POP3wrapper::answeredMail(const RecMail&) 346void POP3wrapper::answeredMail(const RecMail&)
347{ 347{
348} 348}
349 349
350encodedString* POP3wrapper::fetchDecodedPart(const RecMail&,const RecPart&) 350encodedString* POP3wrapper::fetchDecodedPart(const RecMail&,const RecPart&)
351{ 351{
352 return new encodedString(); 352 return new encodedString();
353} 353}
354 354
355encodedString* POP3wrapper::fetchRawPart(const RecMail&,const RecPart&) 355encodedString* POP3wrapper::fetchRawPart(const RecMail&,const RecPart&)
356{ 356{
357 return new encodedString(); 357 return new encodedString();
358} 358}