summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper
Unidiff
Diffstat (limited to 'kmicromail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/abstractmail.cpp13
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp5
-rw-r--r--kmicromail/libmailwrapper/pop3wrapper.cpp12
3 files changed, 23 insertions, 7 deletions
diff --git a/kmicromail/libmailwrapper/abstractmail.cpp b/kmicromail/libmailwrapper/abstractmail.cpp
index 44878e0..8f67566 100644
--- a/kmicromail/libmailwrapper/abstractmail.cpp
+++ b/kmicromail/libmailwrapper/abstractmail.cpp
@@ -1,272 +1,277 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2#include "abstractmail.h" 2#include "abstractmail.h"
3#include "imapwrapper.h" 3#include "imapwrapper.h"
4#include "pop3wrapper.h" 4#include "pop3wrapper.h"
5#include "nntpwrapper.h" 5#include "nntpwrapper.h"
6#include "mhwrapper.h" 6#include "mhwrapper.h"
7#include "mailtypes.h" 7#include "mailtypes.h"
8#include <qpe/global.h> 8#include <qpe/global.h>
9 9
10 10
11#include <qprogressbar.h> 11#include <qprogressbar.h>
12#include <qapplication.h> 12#include <qapplication.h>
13#include <qmessagebox.h> 13#include <qmessagebox.h>
14 14
15#include <kdecore/kstandarddirs.h> 15#include <kdecore/kstandarddirs.h>
16#include <qfile.h> 16#include <qfile.h>
17#include <qtextstream.h> 17#include <qtextstream.h>
18#include <stdlib.h> 18#include <stdlib.h>
19#include <libetpan/mailmime_content.h> 19#include <libetpan/mailmime_content.h>
20#include <libetpan/mailmime.h> 20#include <libetpan/mailmime.h>
21 21
22using namespace Opie::Core; 22using namespace Opie::Core;
23AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) 23AbstractMail* AbstractMail::getWrapper(IMAPaccount *a)
24{ 24{
25 return new IMAPwrapper(a); 25 return new IMAPwrapper(a);
26} 26}
27 27
28AbstractMail* AbstractMail::getWrapper(POP3account *a) 28AbstractMail* AbstractMail::getWrapper(POP3account *a)
29{ 29{
30 return new POP3wrapper(a); 30 return new POP3wrapper(a);
31} 31}
32 32
33AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) 33AbstractMail* AbstractMail::getWrapper(NNTPaccount *a)
34{ 34{
35 return new NNTPwrapper(a); 35 return new NNTPwrapper(a);
36} 36}
37 37
38AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) 38AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name)
39{ 39{
40 return new MHwrapper(a,name); 40 return new MHwrapper(a,name);
41} 41}
42 42
43AbstractMail* AbstractMail::getWrapper(Account*a) 43AbstractMail* AbstractMail::getWrapper(Account*a)
44{ 44{
45 if (!a) return 0; 45 if (!a) return 0;
46 switch (a->getType()) { 46 switch (a->getType()) {
47 case MAILLIB::A_IMAP: 47 case MAILLIB::A_IMAP:
48 return new IMAPwrapper((IMAPaccount*)a); 48 return new IMAPwrapper((IMAPaccount*)a);
49 break; 49 break;
50 case MAILLIB::A_POP3: 50 case MAILLIB::A_POP3:
51 return new POP3wrapper((POP3account*)a); 51 return new POP3wrapper((POP3account*)a);
52 break; 52 break;
53 case MAILLIB::A_NNTP: 53 case MAILLIB::A_NNTP:
54 return new NNTPwrapper((NNTPaccount*)a); 54 return new NNTPwrapper((NNTPaccount*)a);
55 break; 55 break;
56 default: 56 default:
57 return 0; 57 return 0;
58 } 58 }
59} 59}
60 60
61encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) 61encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc)
62{ 62{
63 // odebug << "Decode string start" << oendl; 63 // odebug << "Decode string start" << oendl;
64 char*result_text; 64 char*result_text;
65 size_t index = 0; 65 size_t index = 0;
66 /* reset for recursive use! */ 66 /* reset for recursive use! */
67 size_t target_length = 0; 67 size_t target_length = 0;
68 result_text = 0; 68 result_text = 0;
69 int mimetype = MAILMIME_MECHANISM_7BIT; 69 int mimetype = MAILMIME_MECHANISM_7BIT;
70 if (enc.lower()=="quoted-printable") { 70 if (enc.lower()=="quoted-printable") {
71 mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; 71 mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE;
72 } else if (enc.lower()=="base64") { 72 } else if (enc.lower()=="base64") {
73 mimetype = MAILMIME_MECHANISM_BASE64; 73 mimetype = MAILMIME_MECHANISM_BASE64;
74 } else if (enc.lower()=="8bit") { 74 } else if (enc.lower()=="8bit") {
75 mimetype = MAILMIME_MECHANISM_8BIT; 75 mimetype = MAILMIME_MECHANISM_8BIT;
76 } else if (enc.lower()=="binary") { 76 } else if (enc.lower()=="binary") {
77 mimetype = MAILMIME_MECHANISM_BINARY; 77 mimetype = MAILMIME_MECHANISM_BINARY;
78 } 78 }
79 79
80 int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, 80 int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype,
81 &result_text,&target_length); 81 &result_text,&target_length);
82 82
83 encodedString* result = new encodedString(); 83 encodedString* result = new encodedString();
84 if (err == MAILIMF_NO_ERROR) { 84 if (err == MAILIMF_NO_ERROR) {
85 result->setContent(result_text,target_length); 85 result->setContent(result_text,target_length);
86 } 86 }
87 //odebug << "Decode string finished" << oendl; 87 //odebug << "Decode string finished" << oendl;
88 return result; 88 return result;
89} 89}
90 90
91QString AbstractMail::convert_String(const char*text) 91QString AbstractMail::convert_String(const char*text)
92{ 92{
93 //size_t index = 0; 93 //size_t index = 0;
94 char*res = 0; 94 char*res = 0;
95 int err = MAILIMF_NO_ERROR; 95 int err = MAILIMF_NO_ERROR;
96 96
97 QString result(text); 97 QString result(text);
98 98
99 /* due a bug in libetpan it isn't usable this moment */ 99 /* due a bug in libetpan it isn't usable this moment */
100/* int err = mailmime_encoded_phrase_parse("iso-8859-1", 100/* int err = mailmime_encoded_phrase_parse("iso-8859-1",
101 text, strlen(text),&index, "iso-8859-1",&res);*/ 101 text, strlen(text),&index, "iso-8859-1",&res);*/
102 //odebug << "Input: " << text << "" << oendl; 102 //odebug << "Input: " << text << "" << oendl;
103 if (err == MAILIMF_NO_ERROR && res && strlen(res)) { 103 if (err == MAILIMF_NO_ERROR && res && strlen(res)) {
104// result = QString(res); 104// result = QString(res);
105// odebug << "Res: " << res << ", length: " << strlen(res) << "" << oendl; 105// odebug << "Res: " << res << ", length: " << strlen(res) << "" << oendl;
106 } 106 }
107 if (res) free(res); 107 if (res) free(res);
108 return result; 108 return result;
109} 109}
110 110
111/* cp & paste from launcher */ 111/* cp & paste from launcher */
112QString AbstractMail::gen_attachment_id() 112QString AbstractMail::gen_attachment_id()
113{ 113{
114 QFile file( "/proc/sys/kernel/random/uuid" ); 114 QFile file( "/proc/sys/kernel/random/uuid" );
115 if (!file.open(IO_ReadOnly ) ) 115 if (!file.open(IO_ReadOnly ) )
116 return QString::null; 116 return QString::null;
117 117
118 QTextStream stream(&file); 118 QTextStream stream(&file);
119 119
120 return "{" + stream.read().stripWhiteSpace() + "}"; 120 return "{" + stream.read().stripWhiteSpace() + "}";
121} 121}
122 122
123int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) 123int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool)
124{ 124{
125 return 0; 125 return 0;
126} 126}
127 127
128QString AbstractMail::defaultLocalfolder() 128QString AbstractMail::defaultLocalfolder()
129{ 129{
130 // QString f = getenv( "HOME" ); 130 // QString f = getenv( "HOME" );
131 QString f = locateLocal( "data", "kopiemail/localmail"); 131 QString f = locateLocal( "data", "kopiemail/localmail");
132 // f += "/Applications/opiemail/localmail"; 132 // f += "/Applications/opiemail/localmail";
133 return f; 133 return f;
134} 134}
135 135
136QString AbstractMail::draftFolder() 136QString AbstractMail::draftFolder()
137{ 137{
138 return QString("Drafts"); 138 return QString("Drafts");
139} 139}
140 140
141/* temporary - will be removed when implemented in all classes */ 141/* temporary - will be removed when implemented in all classes */
142void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) 142void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &)
143{ 143{
144} 144}
145void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) 145void AbstractMail::deleteMailList(const QValueList<RecMailP>&target)
146{ 146{
147 //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); 147 //qDebug("AbstractMail::deleteMailList:: Please reimplement! ");
148 // this is currently re-implemented in pop3wrapper and imapwrapper 148 // this is currently re-implemented in pop3wrapper and imapwrapper
149 int iii = 0; 149 int iii = 0;
150 int count = target.count(); 150 int count = target.count();
151 QWidget wid; 151 QProgressBar wid ( count );
152 wid.setCaption( tr("Deleting ..."));
152 wid.show(); 153 wid.show();
153 while (iii < count ) { 154 while (iii < count ) {
154 Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); 155 Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count));
156 wid.setProgress( iii );
155 wid.raise(); 157 wid.raise();
156 qApp->processEvents(); 158 qApp->processEvents();
157 RecMailP mail = (*target.at( iii )); 159 RecMailP mail = (*target.at( iii ));
158 deleteMail(mail); 160 deleteMail(mail);
159 ++iii; 161 ++iii;
160 } 162 }
161} 163}
162 164
163void AbstractMail::downloadNewMails(const FolderP&fromFolder, AbstractMail*targetMail ) 165void AbstractMail::downloadNewMails(const FolderP&fromFolder, AbstractMail*targetMail )
164{ 166{
165 //qDebug("AbstractMail::downloadNewMails %s ", fromFolder->getName().latin1()); 167 //qDebug("AbstractMail::downloadNewMails %s ", fromFolder->getName().latin1());
166 // get local folder 168 // get local folder
167 Account * acc = getAccount(); 169 Account * acc = getAccount();
168 if ( !acc ) return; 170 if ( !acc ) return;
169 QString lfName = acc->getLocalFolder(); 171 QString lfName = acc->getLocalFolder();
170 if ( lfName.isEmpty() ) 172 if ( lfName.isEmpty() )
171 lfName = acc->getAccountName(); 173 lfName = acc->getAccountName();
172 // create local folder 174 // create local folder
173 if ( !targetMail->createMbox(lfName)) 175 if ( !targetMail->createMbox(lfName))
174 { 176 {
175 QMessageBox::critical(0,tr("Error creating new Folder"), 177 QMessageBox::critical(0,tr("Error creating new Folder"),
176 tr("Error while creating new folder\n%1\n\nCancelling action.").arg(lfName)); 178 tr("Error while creating new folder\n%1\n\nCancelling action.").arg(lfName));
177 return; 179 return;
178 } 180 }
179 QValueList<RecMailP> t; 181 QValueList<RecMailP> t;
180 listMessages(fromFolder->getName(),t,acc->getMaxMailSize() ); 182 listMessages(fromFolder->getName(),t,acc->getMaxMailSize() );
181 if ( t.count() == 0 ) { 183 if ( t.count() == 0 ) {
182 Global::statusMessage(tr("There are no new messages")); 184 Global::statusMessage(tr("There are no new messages"));
183 return; 185 return;
184 } 186 }
185 QValueList<RecMailP> e; 187 QValueList<RecMailP> e;
186 targetMail->listMessages(lfName,e,acc->getMaxMailSize() ); 188 targetMail->listMessages(lfName,e,acc->getMaxMailSize() );
187 //qDebug("target has mails %d ", e.count()); 189 //qDebug("target has mails %d ", e.count());
188 QValueList<RecMailP> n; 190 QValueList<RecMailP> n;
189 int iii = 0; 191 int iii = 0;
190 int count = t.count(); 192 int count = t.count();
191 while (iii < count ) { 193 while (iii < count ) {
192 RecMailP r = (*t.at( iii )); 194 RecMailP r = (*t.at( iii ));
193 bool found = false; 195 bool found = false;
194 int jjj = 0; 196 int jjj = 0;
195 int countE = e.count(); 197 int countE = e.count();
196 while (jjj < countE ) { 198 while (jjj < countE ) {
197 RecMailP re = (*e.at( jjj )); 199 RecMailP re = (*e.at( jjj ));
198 if ( re->isEqual(r) ) { 200 if ( re->isEqual(r) ) {
199 found = true; 201 found = true;
200 break; 202 break;
201 } 203 }
202 ++jjj; 204 ++jjj;
203 } 205 }
204 if ( !found ) { 206 if ( !found ) {
205 n.append( r ); 207 n.append( r );
206 } 208 }
207 ++iii; 209 ++iii;
208 } 210 }
209 if ( n.count() == 0 ) { 211 if ( n.count() == 0 ) {
210 Global::statusMessage(tr("There are no new messages")); 212 Global::statusMessage(tr("There are no new messages"));
211 return; 213 return;
212 } 214 }
213 mvcpMailList( n,lfName,targetMail,!acc->getLeaveOnServer()); 215 mvcpMailList( n,lfName,targetMail,!acc->getLeaveOnServer());
214 Global::statusMessage(tr("Downloaded %1 messages").arg(n.count())); 216 Global::statusMessage(tr("Downloaded %1 messages").arg(n.count()));
215 217
216#if 0 218#if 0
217 QValueList<RecMailP> t; 219 QValueList<RecMailP> t;
218 listMessages(fromFolder->getName(),t, maxSizeInKb); 220 listMessages(fromFolder->getName(),t, maxSizeInKb);
219 mvcpMailList( t,targetFolder,targetWrapper,moveit); 221 mvcpMailList( t,targetFolder,targetWrapper,moveit);
220#endif 222#endif
221 223
222} 224}
223void AbstractMail::mvcpAllMails(const FolderP&fromFolder, 225void AbstractMail::mvcpAllMails(const FolderP&fromFolder,
224 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) 226 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb)
225{ 227{
226 QValueList<RecMailP> t; 228 QValueList<RecMailP> t;
227 listMessages(fromFolder->getName(),t, maxSizeInKb); 229 listMessages(fromFolder->getName(),t, maxSizeInKb);
228 mvcpMailList( t,targetFolder,targetWrapper,moveit); 230 mvcpMailList( t,targetFolder,targetWrapper,moveit);
229 231
230} 232}
231void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, 233void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t,
232 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 234 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
233{ 235{
234 encodedString*st = 0; 236 encodedString*st = 0;
235 int iii = 0; 237 int iii = 0;
236 int count = t.count(); 238 int count = t.count();
237 if ( count == 0 ) 239 if ( count == 0 )
238 return; 240 return;
239 // wel, processevents is qite strange, we need a widget for getting 241 // wel, processevents is qite strange, we need a widget for getting
240 // Global::statusMessage(tr("Copy2 message %1").arg(iii)); displayed 242 // Global::statusMessage(tr("Copy2 message %1").arg(iii)); displaye
241 QWidget wid; 243
244 QProgressBar wid ( count );
245 wid.setCaption( tr("Copying ..."));
242 wid.show(); 246 wid.show();
243 while (iii < count ) { 247 while (iii < count ) {
244 Global::statusMessage(tr("Copy message %1 of %2").arg(iii).arg(count)); 248 Global::statusMessage(tr("Copy message %1 of %2").arg(iii).arg(count));
249 wid.setProgress( iii );
245 wid.raise(); 250 wid.raise();
246 qApp->processEvents(); 251 qApp->processEvents();
247 RecMailP r = (*t.at( iii )); 252 RecMailP r = (*t.at( iii ));
248 st = fetchRawBody(r); 253 st = fetchRawBody(r);
249 if (st) { 254 if (st) {
250 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); 255 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder);
251 delete st; 256 delete st;
252 } 257 }
253 ++iii; 258 ++iii;
254 } 259 }
255 if (moveit) { 260 if (moveit) {
256 deleteMailList( t ); 261 deleteMailList( t );
257 //deleteAllMail(fromFolder); 262 //deleteAllMail(fromFolder);
258 } 263 }
259} 264}
260 265
261void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 266void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
262{ 267{
263 encodedString*st = 0; 268 encodedString*st = 0;
264 st = fetchRawBody(mail); 269 st = fetchRawBody(mail);
265 if (st) { 270 if (st) {
266 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); 271 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder);
267 delete st; 272 delete st;
268 } 273 }
269 if (moveit) { 274 if (moveit) {
270 deleteMail(mail); 275 deleteMail(mail);
271 } 276 }
272} 277}
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp
index 91332c3..d79df4f 100644
--- a/kmicromail/libmailwrapper/imapwrapper.cpp
+++ b/kmicromail/libmailwrapper/imapwrapper.cpp
@@ -691,516 +691,519 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int
691 } 691 }
692 } else { 692 } else {
693 ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; 693 ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl;
694 } 694 }
695 if (result) mailimap_fetch_list_free(result); 695 if (result) mailimap_fetch_list_free(result);
696 return res; 696 return res;
697} 697}
698 698
699/* current_recursion is for recursive calls. 699/* current_recursion is for recursive calls.
700 current_count means the position inside the internal loop! */ 700 current_count means the position inside the internal loop! */
701void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, 701void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body,
702 int current_recursion,QValueList<int>recList,int current_count) 702 int current_recursion,QValueList<int>recList,int current_count)
703{ 703{
704 if (!body || current_recursion>=10) { 704 if (!body || current_recursion>=10) {
705 return; 705 return;
706 } 706 }
707 switch (body->bd_type) { 707 switch (body->bd_type) {
708 case MAILIMAP_BODY_1PART: 708 case MAILIMAP_BODY_1PART:
709 { 709 {
710 QValueList<int>countlist = recList; 710 QValueList<int>countlist = recList;
711 countlist.append(current_count); 711 countlist.append(current_count);
712 RecPartP currentPart = new RecPart(); 712 RecPartP currentPart = new RecPart();
713 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; 713 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part;
714 QString id(""); 714 QString id("");
715 currentPart->setPositionlist(countlist); 715 currentPart->setPositionlist(countlist);
716 for (unsigned int j = 0; j < countlist.count();++j) { 716 for (unsigned int j = 0; j < countlist.count();++j) {
717 id+=(j>0?" ":""); 717 id+=(j>0?" ":"");
718 id+=QString("%1").arg(countlist[j]); 718 id+=QString("%1").arg(countlist[j]);
719 } 719 }
720 //odebug << "ID = " << id.latin1() << "" << oendl; 720 //odebug << "ID = " << id.latin1() << "" << oendl;
721 currentPart->setIdentifier(id); 721 currentPart->setIdentifier(id);
722 fillSinglePart(currentPart,part1); 722 fillSinglePart(currentPart,part1);
723 /* important: Check for is NULL 'cause a body can be empty! 723 /* important: Check for is NULL 'cause a body can be empty!
724 And we put it only into the mail if it is the FIRST part */ 724 And we put it only into the mail if it is the FIRST part */
725 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { 725 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) {
726 QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); 726 QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding());
727 target_body->setDescription(currentPart); 727 target_body->setDescription(currentPart);
728 target_body->setBodytext(body_text); 728 target_body->setBodytext(body_text);
729 if (countlist.count()>1) { 729 if (countlist.count()>1) {
730 target_body->addPart(currentPart); 730 target_body->addPart(currentPart);
731 } 731 }
732 } else { 732 } else {
733 target_body->addPart(currentPart); 733 target_body->addPart(currentPart);
734 } 734 }
735 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { 735 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) {
736 traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); 736 traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist);
737 } 737 }
738 } 738 }
739 break; 739 break;
740 case MAILIMAP_BODY_MPART: 740 case MAILIMAP_BODY_MPART:
741 { 741 {
742 QValueList<int>countlist = recList; 742 QValueList<int>countlist = recList;
743 clistcell*current=0; 743 clistcell*current=0;
744 mailimap_body*current_body=0; 744 mailimap_body*current_body=0;
745 unsigned int ccount = 1; 745 unsigned int ccount = 1;
746 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; 746 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart;
747 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { 747 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) {
748 current_body = (mailimap_body*)current->data; 748 current_body = (mailimap_body*)current->data;
749 if (current_body->bd_type==MAILIMAP_BODY_MPART) { 749 if (current_body->bd_type==MAILIMAP_BODY_MPART) {
750 RecPartP targetPart = new RecPart(); 750 RecPartP targetPart = new RecPart();
751 targetPart->setType("multipart"); 751 targetPart->setType("multipart");
752 fillMultiPart(targetPart,mailDescription); 752 fillMultiPart(targetPart,mailDescription);
753 countlist.append(current_count); 753 countlist.append(current_count);
754 targetPart->setPositionlist(countlist); 754 targetPart->setPositionlist(countlist);
755 target_body->addPart(targetPart); 755 target_body->addPart(targetPart);
756 QString id(""); 756 QString id("");
757 for (unsigned int j = 0; j < countlist.count();++j) { 757 for (unsigned int j = 0; j < countlist.count();++j) {
758 id+=(j>0?" ":""); 758 id+=(j>0?" ":"");
759 id+=QString("%1").arg(countlist[j]); 759 id+=QString("%1").arg(countlist[j]);
760 } 760 }
761 // odebug << "ID(mpart) = " << id.latin1() << "" << oendl; 761 // odebug << "ID(mpart) = " << id.latin1() << "" << oendl;
762 } 762 }
763 traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); 763 traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount);
764 if (current_body->bd_type==MAILIMAP_BODY_MPART) { 764 if (current_body->bd_type==MAILIMAP_BODY_MPART) {
765 countlist = recList; 765 countlist = recList;
766 } 766 }
767 ++ccount; 767 ++ccount;
768 } 768 }
769 } 769 }
770 break; 770 break;
771 default: 771 default:
772 break; 772 break;
773 } 773 }
774} 774}
775 775
776void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) 776void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description)
777{ 777{
778 if (!Description) { 778 if (!Description) {
779 return; 779 return;
780 } 780 }
781 switch (Description->bd_type) { 781 switch (Description->bd_type) {
782 case MAILIMAP_BODY_TYPE_1PART_TEXT: 782 case MAILIMAP_BODY_TYPE_1PART_TEXT:
783 target_part->setType("text"); 783 target_part->setType("text");
784 fillSingleTextPart(target_part,Description->bd_data.bd_type_text); 784 fillSingleTextPart(target_part,Description->bd_data.bd_type_text);
785 break; 785 break;
786 case MAILIMAP_BODY_TYPE_1PART_BASIC: 786 case MAILIMAP_BODY_TYPE_1PART_BASIC:
787 fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); 787 fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic);
788 break; 788 break;
789 case MAILIMAP_BODY_TYPE_1PART_MSG: 789 case MAILIMAP_BODY_TYPE_1PART_MSG:
790 target_part->setType("message"); 790 target_part->setType("message");
791 fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); 791 fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg);
792 break; 792 break;
793 default: 793 default:
794 break; 794 break;
795 } 795 }
796} 796}
797 797
798void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) 798void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which)
799{ 799{
800 if (!which) { 800 if (!which) {
801 return; 801 return;
802 } 802 }
803 QString sub; 803 QString sub;
804 sub = which->bd_media_text; 804 sub = which->bd_media_text;
805 //odebug << "Type= text/" << which->bd_media_text << "" << oendl; 805 //odebug << "Type= text/" << which->bd_media_text << "" << oendl;
806 target_part->setSubtype(sub.lower()); 806 target_part->setSubtype(sub.lower());
807 target_part->setLines(which->bd_lines); 807 target_part->setLines(which->bd_lines);
808 fillBodyFields(target_part,which->bd_fields); 808 fillBodyFields(target_part,which->bd_fields);
809} 809}
810 810
811void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) 811void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which)
812{ 812{
813 if (!which) { 813 if (!which) {
814 return; 814 return;
815 } 815 }
816 target_part->setSubtype("rfc822"); 816 target_part->setSubtype("rfc822");
817 //odebug << "Message part" << oendl; 817 //odebug << "Message part" << oendl;
818 /* we set this type to text/plain */ 818 /* we set this type to text/plain */
819 target_part->setLines(which->bd_lines); 819 target_part->setLines(which->bd_lines);
820 fillBodyFields(target_part,which->bd_fields); 820 fillBodyFields(target_part,which->bd_fields);
821} 821}
822 822
823void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) 823void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which)
824{ 824{
825 if (!which) return; 825 if (!which) return;
826 QString sub = which->bd_media_subtype; 826 QString sub = which->bd_media_subtype;
827 target_part->setSubtype(sub.lower()); 827 target_part->setSubtype(sub.lower());
828 if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { 828 if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) {
829 clistcell*cur = 0; 829 clistcell*cur = 0;
830 mailimap_single_body_fld_param*param=0; 830 mailimap_single_body_fld_param*param=0;
831 for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { 831 for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
832 param = (mailimap_single_body_fld_param*)cur->data; 832 param = (mailimap_single_body_fld_param*)cur->data;
833 if (param) { 833 if (param) {
834 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 834 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
835 } 835 }
836 } 836 }
837 } 837 }
838} 838}
839 839
840void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) 840void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which)
841{ 841{
842 if (!which) { 842 if (!which) {
843 return; 843 return;
844 } 844 }
845 QString type,sub; 845 QString type,sub;
846 switch (which->bd_media_basic->med_type) { 846 switch (which->bd_media_basic->med_type) {
847 case MAILIMAP_MEDIA_BASIC_APPLICATION: 847 case MAILIMAP_MEDIA_BASIC_APPLICATION:
848 type = "application"; 848 type = "application";
849 break; 849 break;
850 case MAILIMAP_MEDIA_BASIC_AUDIO: 850 case MAILIMAP_MEDIA_BASIC_AUDIO:
851 type = "audio"; 851 type = "audio";
852 break; 852 break;
853 case MAILIMAP_MEDIA_BASIC_IMAGE: 853 case MAILIMAP_MEDIA_BASIC_IMAGE:
854 type = "image"; 854 type = "image";
855 break; 855 break;
856 case MAILIMAP_MEDIA_BASIC_MESSAGE: 856 case MAILIMAP_MEDIA_BASIC_MESSAGE:
857 type = "message"; 857 type = "message";
858 break; 858 break;
859 case MAILIMAP_MEDIA_BASIC_VIDEO: 859 case MAILIMAP_MEDIA_BASIC_VIDEO:
860 type = "video"; 860 type = "video";
861 break; 861 break;
862 case MAILIMAP_MEDIA_BASIC_OTHER: 862 case MAILIMAP_MEDIA_BASIC_OTHER:
863 default: 863 default:
864 if (which->bd_media_basic->med_basic_type) { 864 if (which->bd_media_basic->med_basic_type) {
865 type = which->bd_media_basic->med_basic_type; 865 type = which->bd_media_basic->med_basic_type;
866 } else { 866 } else {
867 type = ""; 867 type = "";
868 } 868 }
869 break; 869 break;
870 } 870 }
871 if (which->bd_media_basic->med_subtype) { 871 if (which->bd_media_basic->med_subtype) {
872 sub = which->bd_media_basic->med_subtype; 872 sub = which->bd_media_basic->med_subtype;
873 } else { 873 } else {
874 sub = ""; 874 sub = "";
875 } 875 }
876 // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; 876 // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl;
877 target_part->setType(type.lower()); 877 target_part->setType(type.lower());
878 target_part->setSubtype(sub.lower()); 878 target_part->setSubtype(sub.lower());
879 fillBodyFields(target_part,which->bd_fields); 879 fillBodyFields(target_part,which->bd_fields);
880} 880}
881 881
882void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) 882void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which)
883{ 883{
884 if (!which) return; 884 if (!which) return;
885 if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { 885 if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) {
886 clistcell*cur; 886 clistcell*cur;
887 mailimap_single_body_fld_param*param=0; 887 mailimap_single_body_fld_param*param=0;
888 for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { 888 for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
889 param = (mailimap_single_body_fld_param*)cur->data; 889 param = (mailimap_single_body_fld_param*)cur->data;
890 if (param) { 890 if (param) {
891 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 891 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
892 } 892 }
893 } 893 }
894 } 894 }
895 mailimap_body_fld_enc*enc = which->bd_encoding; 895 mailimap_body_fld_enc*enc = which->bd_encoding;
896 QString encoding(""); 896 QString encoding("");
897 switch (enc->enc_type) { 897 switch (enc->enc_type) {
898 case MAILIMAP_BODY_FLD_ENC_7BIT: 898 case MAILIMAP_BODY_FLD_ENC_7BIT:
899 encoding = "7bit"; 899 encoding = "7bit";
900 break; 900 break;
901 case MAILIMAP_BODY_FLD_ENC_8BIT: 901 case MAILIMAP_BODY_FLD_ENC_8BIT:
902 encoding = "8bit"; 902 encoding = "8bit";
903 break; 903 break;
904 case MAILIMAP_BODY_FLD_ENC_BINARY: 904 case MAILIMAP_BODY_FLD_ENC_BINARY:
905 encoding="binary"; 905 encoding="binary";
906 break; 906 break;
907 case MAILIMAP_BODY_FLD_ENC_BASE64: 907 case MAILIMAP_BODY_FLD_ENC_BASE64:
908 encoding="base64"; 908 encoding="base64";
909 break; 909 break;
910 case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: 910 case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE:
911 encoding="quoted-printable"; 911 encoding="quoted-printable";
912 break; 912 break;
913 case MAILIMAP_BODY_FLD_ENC_OTHER: 913 case MAILIMAP_BODY_FLD_ENC_OTHER:
914 default: 914 default:
915 if (enc->enc_value) { 915 if (enc->enc_value) {
916 char*t=enc->enc_value; 916 char*t=enc->enc_value;
917 encoding=QString(enc->enc_value); 917 encoding=QString(enc->enc_value);
918 enc->enc_value=0L; 918 enc->enc_value=0L;
919 free(t); 919 free(t);
920 } 920 }
921 } 921 }
922 if (which->bd_description) { 922 if (which->bd_description) {
923 target_part->setDescription(QString(which->bd_description)); 923 target_part->setDescription(QString(which->bd_description));
924 } 924 }
925 target_part->setEncoding(encoding); 925 target_part->setEncoding(encoding);
926 target_part->setSize(which->bd_size); 926 target_part->setSize(which->bd_size);
927} 927}
928void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) 928void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target)
929{ 929{
930 //#if 0 930 //#if 0
931 mailimap_flag_list*flist; 931 mailimap_flag_list*flist;
932 mailimap_set *set; 932 mailimap_set *set;
933 mailimap_store_att_flags * store_flags; 933 mailimap_store_att_flags * store_flags;
934 int err; 934 int err;
935 login(); 935 login();
936 //#endif 936 //#endif
937 if (!m_imap) { 937 if (!m_imap) {
938 return; 938 return;
939 } 939 }
940 int iii = 0; 940 int iii = 0;
941 int count = target.count(); 941 int count = target.count();
942 // qDebug("imap remove count %d ", count); 942 // qDebug("imap remove count %d ", count);
943 943
944 944
945 mMax = count; 945 mMax = count;
946 //progress( tr("Delete")); 946 //progress( tr("Delete"));
947 QWidget wid; 947
948 QProgressBar wid ( count );
949 wid.setCaption( tr("Deleting ..."));
948 wid.show(); 950 wid.show();
949 while (iii < count ) { 951 while (iii < count ) {
950 Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); 952 Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count));
953 wid.setProgress( iii );
951 wid.raise(); 954 wid.raise();
952 qApp->processEvents(); 955 qApp->processEvents();
953 RecMailP mail = (*target.at( iii )); 956 RecMailP mail = (*target.at( iii ));
954 //#if 0 957 //#if 0
955 //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); 958 //qDebug("IMAP remove %d %d ", iii, mail->getNumber() );
956 err = selectMbox(mail->getMbox()); 959 err = selectMbox(mail->getMbox());
957 if ( err != MAILIMAP_NO_ERROR ) { 960 if ( err != MAILIMAP_NO_ERROR ) {
958 return; 961 return;
959 } 962 }
960 flist = mailimap_flag_list_new_empty(); 963 flist = mailimap_flag_list_new_empty();
961 mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); 964 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
962 store_flags = mailimap_store_att_flags_new_set_flags(flist); 965 store_flags = mailimap_store_att_flags_new_set_flags(flist);
963 set = mailimap_set_new_single(mail->getNumber()); 966 set = mailimap_set_new_single(mail->getNumber());
964 err = mailimap_store(m_imap,set,store_flags); 967 err = mailimap_store(m_imap,set,store_flags);
965 mailimap_set_free( set ); 968 mailimap_set_free( set );
966 mailimap_store_att_flags_free(store_flags); 969 mailimap_store_att_flags_free(store_flags);
967 970
968 if (err != MAILIMAP_NO_ERROR) { 971 if (err != MAILIMAP_NO_ERROR) {
969 // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; 972 // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl;
970 return; 973 return;
971 } 974 }
972 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; 975 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
973 /* should we realy do that at this moment? */ 976 /* should we realy do that at this moment? */
974 977
975 // err = mailimap_expunge(m_imap); 978 // err = mailimap_expunge(m_imap);
976 //if (err != MAILIMAP_NO_ERROR) { 979 //if (err != MAILIMAP_NO_ERROR) {
977 // Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response)); 980 // Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response));
978 // } 981 // }
979 //#endif 982 //#endif
980 //deleteMail( mail); 983 //deleteMail( mail);
981 ++iii; 984 ++iii;
982 } 985 }
983 //qDebug("Deleting imap mails... "); 986 //qDebug("Deleting imap mails... ");
984 err = mailimap_expunge(m_imap); 987 err = mailimap_expunge(m_imap);
985 if (err != MAILIMAP_NO_ERROR) { 988 if (err != MAILIMAP_NO_ERROR) {
986 Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response)); 989 Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response));
987 } 990 }
988} 991}
989void IMAPwrapper::deleteMail(const RecMailP&mail) 992void IMAPwrapper::deleteMail(const RecMailP&mail)
990{ 993{
991 mailimap_flag_list*flist; 994 mailimap_flag_list*flist;
992 mailimap_set *set; 995 mailimap_set *set;
993 mailimap_store_att_flags * store_flags; 996 mailimap_store_att_flags * store_flags;
994 int err; 997 int err;
995 login(); 998 login();
996 if (!m_imap) { 999 if (!m_imap) {
997 return; 1000 return;
998 } 1001 }
999 err = selectMbox(mail->getMbox()); 1002 err = selectMbox(mail->getMbox());
1000 if ( err != MAILIMAP_NO_ERROR ) { 1003 if ( err != MAILIMAP_NO_ERROR ) {
1001 return; 1004 return;
1002 } 1005 }
1003 flist = mailimap_flag_list_new_empty(); 1006 flist = mailimap_flag_list_new_empty();
1004 mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); 1007 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
1005 store_flags = mailimap_store_att_flags_new_set_flags(flist); 1008 store_flags = mailimap_store_att_flags_new_set_flags(flist);
1006 set = mailimap_set_new_single(mail->getNumber()); 1009 set = mailimap_set_new_single(mail->getNumber());
1007 err = mailimap_store(m_imap,set,store_flags); 1010 err = mailimap_store(m_imap,set,store_flags);
1008 mailimap_set_free( set ); 1011 mailimap_set_free( set );
1009 mailimap_store_att_flags_free(store_flags); 1012 mailimap_store_att_flags_free(store_flags);
1010 1013
1011 if (err != MAILIMAP_NO_ERROR) { 1014 if (err != MAILIMAP_NO_ERROR) {
1012 // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; 1015 // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl;
1013 return; 1016 return;
1014 } 1017 }
1015 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; 1018 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
1016 /* should we realy do that at this moment? */ 1019 /* should we realy do that at this moment? */
1017 1020
1018 err = mailimap_expunge(m_imap); 1021 err = mailimap_expunge(m_imap);
1019 if (err != MAILIMAP_NO_ERROR) { 1022 if (err != MAILIMAP_NO_ERROR) {
1020 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); 1023 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
1021 } 1024 }
1022 //qDebug("IMAPwrapper::deleteMail 2"); 1025 //qDebug("IMAPwrapper::deleteMail 2");
1023 1026
1024} 1027}
1025 1028
1026void IMAPwrapper::answeredMail(const RecMailP&mail) 1029void IMAPwrapper::answeredMail(const RecMailP&mail)
1027{ 1030{
1028 mailimap_flag_list*flist; 1031 mailimap_flag_list*flist;
1029 mailimap_set *set; 1032 mailimap_set *set;
1030 mailimap_store_att_flags * store_flags; 1033 mailimap_store_att_flags * store_flags;
1031 int err; 1034 int err;
1032 login(); 1035 login();
1033 if (!m_imap) { 1036 if (!m_imap) {
1034 return; 1037 return;
1035 } 1038 }
1036 err = selectMbox(mail->getMbox()); 1039 err = selectMbox(mail->getMbox());
1037 if ( err != MAILIMAP_NO_ERROR ) { 1040 if ( err != MAILIMAP_NO_ERROR ) {
1038 return; 1041 return;
1039 } 1042 }
1040 flist = mailimap_flag_list_new_empty(); 1043 flist = mailimap_flag_list_new_empty();
1041 mailimap_flag_list_add(flist,mailimap_flag_new_answered()); 1044 mailimap_flag_list_add(flist,mailimap_flag_new_answered());
1042 store_flags = mailimap_store_att_flags_new_add_flags(flist); 1045 store_flags = mailimap_store_att_flags_new_add_flags(flist);
1043 set = mailimap_set_new_single(mail->getNumber()); 1046 set = mailimap_set_new_single(mail->getNumber());
1044 err = mailimap_store(m_imap,set,store_flags); 1047 err = mailimap_store(m_imap,set,store_flags);
1045 mailimap_set_free( set ); 1048 mailimap_set_free( set );
1046 mailimap_store_att_flags_free(store_flags); 1049 mailimap_store_att_flags_free(store_flags);
1047 1050
1048 if (err != MAILIMAP_NO_ERROR) { 1051 if (err != MAILIMAP_NO_ERROR) {
1049 // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; 1052 // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl;
1050 return; 1053 return;
1051 } 1054 }
1052} 1055}
1053 1056
1054QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) 1057QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc)
1055{ 1058{
1056 QString body(""); 1059 QString body("");
1057 encodedString*res = fetchRawPart(mail,path,internal_call); 1060 encodedString*res = fetchRawPart(mail,path,internal_call);
1058 encodedString*r = decode_String(res,enc); 1061 encodedString*r = decode_String(res,enc);
1059 delete res; 1062 delete res;
1060 if (r) { 1063 if (r) {
1061 if (r->Length()>0) { 1064 if (r->Length()>0) {
1062 body = r->Content(); 1065 body = r->Content();
1063 } 1066 }
1064 delete r; 1067 delete r;
1065 } 1068 }
1066 return body; 1069 return body;
1067} 1070}
1068 1071
1069QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) 1072QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part)
1070{ 1073{
1071 return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); 1074 return fetchTextPart(mail,part->Positionlist(),false,part->Encoding());
1072} 1075}
1073 1076
1074encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) 1077encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part)
1075{ 1078{
1076 encodedString*res = fetchRawPart(mail,part->Positionlist(),false); 1079 encodedString*res = fetchRawPart(mail,part->Positionlist(),false);
1077 encodedString*r = decode_String(res,part->Encoding()); 1080 encodedString*r = decode_String(res,part->Encoding());
1078 delete res; 1081 delete res;
1079 return r; 1082 return r;
1080} 1083}
1081 1084
1082encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part) 1085encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part)
1083{ 1086{
1084 return fetchRawPart(mail,part->Positionlist(),false); 1087 return fetchRawPart(mail,part->Positionlist(),false);
1085} 1088}
1086 1089
1087int IMAPwrapper::deleteAllMail(const FolderP&folder) 1090int IMAPwrapper::deleteAllMail(const FolderP&folder)
1088{ 1091{
1089 login(); 1092 login();
1090 if (!m_imap) { 1093 if (!m_imap) {
1091 return 0; 1094 return 0;
1092 } 1095 }
1093 mailimap_flag_list*flist; 1096 mailimap_flag_list*flist;
1094 mailimap_set *set; 1097 mailimap_set *set;
1095 mailimap_store_att_flags * store_flags; 1098 mailimap_store_att_flags * store_flags;
1096 int err = selectMbox(folder->getName()); 1099 int err = selectMbox(folder->getName());
1097 if ( err != MAILIMAP_NO_ERROR ) { 1100 if ( err != MAILIMAP_NO_ERROR ) {
1098 return 0; 1101 return 0;
1099 } 1102 }
1100 1103
1101 int last = m_imap->imap_selection_info->sel_exists; 1104 int last = m_imap->imap_selection_info->sel_exists;
1102 if (last == 0) { 1105 if (last == 0) {
1103 Global::statusMessage(tr("Mailbox has no mails!")); 1106 Global::statusMessage(tr("Mailbox has no mails!"));
1104 return 0; 1107 return 0;
1105 } 1108 }
1106 flist = mailimap_flag_list_new_empty(); 1109 flist = mailimap_flag_list_new_empty();
1107 mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); 1110 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
1108 store_flags = mailimap_store_att_flags_new_set_flags(flist); 1111 store_flags = mailimap_store_att_flags_new_set_flags(flist);
1109 set = mailimap_set_new_interval( 1, last ); 1112 set = mailimap_set_new_interval( 1, last );
1110 err = mailimap_store(m_imap,set,store_flags); 1113 err = mailimap_store(m_imap,set,store_flags);
1111 mailimap_set_free( set ); 1114 mailimap_set_free( set );
1112 mailimap_store_att_flags_free(store_flags); 1115 mailimap_store_att_flags_free(store_flags);
1113 if (err != MAILIMAP_NO_ERROR) { 1116 if (err != MAILIMAP_NO_ERROR) {
1114 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); 1117 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
1115 return 0; 1118 return 0;
1116 } 1119 }
1117 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; 1120 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
1118 /* should we realy do that at this moment? */ 1121 /* should we realy do that at this moment? */
1119 err = mailimap_expunge(m_imap); 1122 err = mailimap_expunge(m_imap);
1120 if (err != MAILIMAP_NO_ERROR) { 1123 if (err != MAILIMAP_NO_ERROR) {
1121 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); 1124 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
1122 return 0; 1125 return 0;
1123 } 1126 }
1124 // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; 1127 // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl;
1125 return 1; 1128 return 1;
1126} 1129}
1127 1130
1128int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) 1131int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder)
1129{ 1132{
1130 if (folder.length()==0) return 0; 1133 if (folder.length()==0) return 0;
1131 login(); 1134 login();
1132 if (!m_imap) {return 0;} 1135 if (!m_imap) {return 0;}
1133 QString pre = account->getPrefix(); 1136 QString pre = account->getPrefix();
1134 if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { 1137 if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) {
1135 pre+=delemiter; 1138 pre+=delemiter;
1136 } 1139 }
1137 if (parentfolder) { 1140 if (parentfolder) {
1138 pre += parentfolder->getDisplayName()+delemiter; 1141 pre += parentfolder->getDisplayName()+delemiter;
1139 } 1142 }
1140 pre+=folder; 1143 pre+=folder;
1141 if (getsubfolder) { 1144 if (getsubfolder) {
1142 if (delemiter.length()>0) { 1145 if (delemiter.length()>0) {
1143 pre+=delemiter; 1146 pre+=delemiter;
1144 } else { 1147 } else {
1145 Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); 1148 Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre));
1146 return 0; 1149 return 0;
1147 } 1150 }
1148 } 1151 }
1149 // odebug << "Creating " << pre.latin1() << "" << oendl; 1152 // odebug << "Creating " << pre.latin1() << "" << oendl;
1150 int res = mailimap_create(m_imap,pre.latin1()); 1153 int res = mailimap_create(m_imap,pre.latin1());
1151 if (res != MAILIMAP_NO_ERROR) { 1154 if (res != MAILIMAP_NO_ERROR) {
1152 Global::statusMessage(tr("%1").arg(m_imap->imap_response)); 1155 Global::statusMessage(tr("%1").arg(m_imap->imap_response));
1153 return 0; 1156 return 0;
1154 } 1157 }
1155 return 1; 1158 return 1;
1156} 1159}
1157 1160
1158int IMAPwrapper::deleteMbox(const FolderP&folder) 1161int IMAPwrapper::deleteMbox(const FolderP&folder)
1159{ 1162{
1160 if (!folder) return 0; 1163 if (!folder) return 0;
1161 login(); 1164 login();
1162 if (!m_imap) {return 0;} 1165 if (!m_imap) {return 0;}
1163 int res = mailimap_delete(m_imap,folder->getName()); 1166 int res = mailimap_delete(m_imap,folder->getName());
1164 if (res != MAILIMAP_NO_ERROR) { 1167 if (res != MAILIMAP_NO_ERROR) {
1165 Global::statusMessage(tr("%1").arg(m_imap->imap_response)); 1168 Global::statusMessage(tr("%1").arg(m_imap->imap_response));
1166 return 0; 1169 return 0;
1167 } 1170 }
1168 return 1; 1171 return 1;
1169} 1172}
1170 1173
1171void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) 1174void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
1172{ 1175{
1173 mailimap_status_att_list * att_list =0; 1176 mailimap_status_att_list * att_list =0;
1174 mailimap_mailbox_data_status * status=0; 1177 mailimap_mailbox_data_status * status=0;
1175 clistiter * cur = 0; 1178 clistiter * cur = 0;
1176 int r = 0; 1179 int r = 0;
1177 target_stat.message_count = 0; 1180 target_stat.message_count = 0;
1178 target_stat.message_unseen = 0; 1181 target_stat.message_unseen = 0;
1179 target_stat.message_recent = 0; 1182 target_stat.message_recent = 0;
1180 login(); 1183 login();
1181 if (!m_imap) { 1184 if (!m_imap) {
1182 return; 1185 return;
1183 } 1186 }
1184 att_list = mailimap_status_att_list_new_empty(); 1187 att_list = mailimap_status_att_list_new_empty();
1185 if (!att_list) return; 1188 if (!att_list) return;
1186 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); 1189 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES);
1187 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); 1190 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT);
1188 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); 1191 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN);
1189 r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); 1192 r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status);
1190 if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { 1193 if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) {
1191 for (cur = clist_begin(status->st_info_list); 1194 for (cur = clist_begin(status->st_info_list);
1192 cur != NULL ; cur = clist_next(cur)) { 1195 cur != NULL ; cur = clist_next(cur)) {
1193 mailimap_status_info * status_info; 1196 mailimap_status_info * status_info;
1194 status_info = (mailimap_status_info *)clist_content(cur); 1197 status_info = (mailimap_status_info *)clist_content(cur);
1195 switch (status_info->st_att) { 1198 switch (status_info->st_att) {
1196 case MAILIMAP_STATUS_ATT_MESSAGES: 1199 case MAILIMAP_STATUS_ATT_MESSAGES:
1197 target_stat.message_count = status_info->st_value; 1200 target_stat.message_count = status_info->st_value;
1198 break; 1201 break;
1199 case MAILIMAP_STATUS_ATT_RECENT: 1202 case MAILIMAP_STATUS_ATT_RECENT:
1200 target_stat.message_recent = status_info->st_value; 1203 target_stat.message_recent = status_info->st_value;
1201 break; 1204 break;
1202 case MAILIMAP_STATUS_ATT_UNSEEN: 1205 case MAILIMAP_STATUS_ATT_UNSEEN:
1203 target_stat.message_unseen = status_info->st_value; 1206 target_stat.message_unseen = status_info->st_value;
1204 break; 1207 break;
1205 } 1208 }
1206 } 1209 }
diff --git a/kmicromail/libmailwrapper/pop3wrapper.cpp b/kmicromail/libmailwrapper/pop3wrapper.cpp
index 1edec9e..9d52f52 100644
--- a/kmicromail/libmailwrapper/pop3wrapper.cpp
+++ b/kmicromail/libmailwrapper/pop3wrapper.cpp
@@ -1,294 +1,302 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2#include <stdlib.h> 2#include <stdlib.h>
3#include "pop3wrapper.h" 3#include "pop3wrapper.h"
4#include "mailtypes.h" 4#include "mailtypes.h"
5#include "logindialog.h" 5#include "logindialog.h"
6#include <libetpan/libetpan.h> 6#include <libetpan/libetpan.h>
7 7
8 8
9#include <qpe/global.h> 9#include <qpe/global.h>
10#include <qfile.h> 10#include <qfile.h>
11#include <qprogressbar.h> 11#include <qprogressbar.h>
12#include <qapplication.h> 12#include <qapplication.h>
13 13
14/* we don't fetch messages larger than 5 MB */ 14/* we don't fetch messages larger than 5 MB */
15#define HARD_MSG_SIZE_LIMIT 5242880 15#define HARD_MSG_SIZE_LIMIT 5242880
16 16
17using namespace Opie::Core; 17using namespace Opie::Core;
18POP3wrapper::POP3wrapper( POP3account *a ) 18POP3wrapper::POP3wrapper( POP3account *a )
19: Genericwrapper() { 19: Genericwrapper() {
20 account = a; 20 account = a;
21 m_pop3 = NULL; 21 m_pop3 = NULL;
22 msgTempName = a->getFileName()+"_msg_cache"; 22 msgTempName = a->getFileName()+"_msg_cache";
23 last_msg_id = 0; 23 last_msg_id = 0;
24} 24}
25 25
26POP3wrapper::~POP3wrapper() { 26POP3wrapper::~POP3wrapper() {
27 logout(); 27 logout();
28 QFile msg_cache(msgTempName); 28 QFile msg_cache(msgTempName);
29 if (msg_cache.exists()) { 29 if (msg_cache.exists()) {
30 msg_cache.remove(); 30 msg_cache.remove();
31 } 31 }
32} 32}
33 33
34void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { 34void POP3wrapper::pop3_progress( size_t current, size_t maximum ) {
35 ; // odebug << "POP3: " << current << " of " << maximum << "" << oendl; 35 ; // odebug << "POP3: " << current << " of " << maximum << "" << oendl;
36} 36}
37 37
38RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { 38RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) {
39 int err = MAILPOP3_NO_ERROR; 39 int err = MAILPOP3_NO_ERROR;
40 char *message = 0; 40 char *message = 0;
41 size_t length = 0; 41 size_t length = 0;
42 42
43 RecBodyP body = new RecBody(); 43 RecBodyP body = new RecBody();
44 44
45 login(); 45 login();
46 if ( !m_pop3 ) { 46 if ( !m_pop3 ) {
47 return body; 47 return body;
48 } 48 }
49 49
50 mailmessage * mailmsg; 50 mailmessage * mailmsg;
51 if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { 51 if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) {
52 ; // odebug << "Message to large: " << mail->Msgsize() << "" << oendl; 52 ; // odebug << "Message to large: " << mail->Msgsize() << "" << oendl;
53 return body; 53 return body;
54 } 54 }
55 55
56 QFile msg_cache(msgTempName); 56 QFile msg_cache(msgTempName);
57 57
58 cleanMimeCache(); 58 cleanMimeCache();
59 59
60 if (mail->getNumber()!=last_msg_id) { 60 if (mail->getNumber()!=last_msg_id) {
61 if (msg_cache.exists()) { 61 if (msg_cache.exists()) {
62 msg_cache.remove(); 62 msg_cache.remove();
63 } 63 }
64 msg_cache.open(IO_ReadWrite|IO_Truncate); 64 msg_cache.open(IO_ReadWrite|IO_Truncate);
65 last_msg_id = mail->getNumber(); 65 last_msg_id = mail->getNumber();
66 err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); 66 err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg);
67 err = mailmessage_fetch(mailmsg,&message,&length); 67 err = mailmessage_fetch(mailmsg,&message,&length);
68 msg_cache.writeBlock(message,length); 68 msg_cache.writeBlock(message,length);
69 } else { 69 } else {
70 QString msg=""; 70 QString msg="";
71 msg_cache.open(IO_ReadOnly); 71 msg_cache.open(IO_ReadOnly);
72 message = new char[4096]; 72 message = new char[4096];
73 memset(message,0,4096); 73 memset(message,0,4096);
74 while (msg_cache.readBlock(message,4095)>0) { 74 while (msg_cache.readBlock(message,4095)>0) {
75 msg+=message; 75 msg+=message;
76 memset(message,0,4096); 76 memset(message,0,4096);
77 } 77 }
78 delete message; 78 delete message;
79 message = (char*)malloc(msg.length()+1*sizeof(char)); 79 message = (char*)malloc(msg.length()+1*sizeof(char));
80 memset(message,0,msg.length()+1); 80 memset(message,0,msg.length()+1);
81 memcpy(message,msg.latin1(),msg.length()); 81 memcpy(message,msg.latin1(),msg.length());
82 /* transform to libetpan stuff */ 82 /* transform to libetpan stuff */
83 mailmsg = mailmessage_new(); 83 mailmsg = mailmessage_new();
84 mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); 84 mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message));
85 generic_message_t * msg_data; 85 generic_message_t * msg_data;
86 msg_data = (generic_message_t *)mailmsg->msg_data; 86 msg_data = (generic_message_t *)mailmsg->msg_data;
87 msg_data->msg_fetched = 1; 87 msg_data->msg_fetched = 1;
88 msg_data->msg_message = message; 88 msg_data->msg_message = message;
89 msg_data->msg_length = strlen(message); 89 msg_data->msg_length = strlen(message);
90 } 90 }
91 body = parseMail(mailmsg); 91 body = parseMail(mailmsg);
92 92
93 /* clean up */ 93 /* clean up */
94 if (mailmsg) 94 if (mailmsg)
95 mailmessage_free(mailmsg); 95 mailmessage_free(mailmsg);
96 if (message) 96 if (message)
97 free(message); 97 free(message);
98 98
99 return body; 99 return body;
100} 100}
101 101
102void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) 102void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb )
103{ 103{
104 login(); 104 login();
105 if (!m_pop3) 105 if (!m_pop3)
106 return; 106 return;
107 uint32_t res_messages,res_recent,res_unseen; 107 uint32_t res_messages,res_recent,res_unseen;
108 mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); 108 mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen);
109 parseList(target,m_pop3->sto_session,"INBOX", false, maxSizeInKb); 109 parseList(target,m_pop3->sto_session,"INBOX", false, maxSizeInKb);
110 Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); 110 Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages));
111} 111}
112 112
113void POP3wrapper::login() 113void POP3wrapper::login()
114{ 114{
115 if (account->getOffline()) 115 if (account->getOffline())
116 return; 116 return;
117 /* we'll hold the line */ 117 /* we'll hold the line */
118 if ( m_pop3 != NULL ) 118 if ( m_pop3 != NULL )
119 return; 119 return;
120 120
121 QString server,user, pass; 121 QString server,user, pass;
122 uint16_t port; 122 uint16_t port;
123 int err = MAILPOP3_NO_ERROR; 123 int err = MAILPOP3_NO_ERROR;
124 124
125 server = account->getServer(); 125 server = account->getServer();
126 port = account->getPort().toUInt(); 126 port = account->getPort().toUInt();
127 127
128 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { 128 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
129 qApp->processEvents(); 129 qApp->processEvents();
130 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); 130 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
131 login.show(); 131 login.show();
132 if ( QDialog::Accepted == login.exec() ) { 132 if ( QDialog::Accepted == login.exec() ) {
133 // ok 133 // ok
134 user = login.getUser(); 134 user = login.getUser();
135 pass = login.getPassword(); 135 pass = login.getPassword();
136 } else { 136 } else {
137 // cancel 137 // cancel
138 ; // odebug << "POP3: Login canceled" << oendl; 138 ; // odebug << "POP3: Login canceled" << oendl;
139 return; 139 return;
140 } 140 }
141 } else { 141 } else {
142 user = account->getUser(); 142 user = account->getUser();
143 pass = account->getPassword(); 143 pass = account->getPassword();
144 } 144 }
145 // bool ssl = account->getSSL(); 145 // bool ssl = account->getSSL();
146 146
147 m_pop3=mailstorage_new(NULL); 147 m_pop3=mailstorage_new(NULL);
148 int conntypeset = account->ConnectionType(); 148 int conntypeset = account->ConnectionType();
149 int conntype = 0; 149 int conntype = 0;
150 if ( conntypeset == 3 ) { 150 if ( conntypeset == 3 ) {
151 conntype = CONNECTION_TYPE_COMMAND; 151 conntype = CONNECTION_TYPE_COMMAND;
152 } else if ( conntypeset == 2 ) { 152 } else if ( conntypeset == 2 ) {
153 conntype = CONNECTION_TYPE_TLS; 153 conntype = CONNECTION_TYPE_TLS;
154 } else if ( conntypeset == 1 ) { 154 } else if ( conntypeset == 1 ) {
155 conntype = CONNECTION_TYPE_STARTTLS; 155 conntype = CONNECTION_TYPE_STARTTLS;
156 } else if ( conntypeset == 0 ) { 156 } else if ( conntypeset == 0 ) {
157 conntype = CONNECTION_TYPE_TRY_STARTTLS; 157 conntype = CONNECTION_TYPE_TRY_STARTTLS;
158 } 158 }
159 159
160 //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); 160 //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN);
161 161
162 pop3_mailstorage_init(m_pop3,(char*)server.latin1(), port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, 162 pop3_mailstorage_init(m_pop3,(char*)server.latin1(), port, NULL, conntype, POP3_AUTH_TYPE_PLAIN,
163 (char*)user.latin1(),(char*)pass.latin1(),0,0,0); 163 (char*)user.latin1(),(char*)pass.latin1(),0,0,0);
164 164
165 err = mailstorage_connect(m_pop3); 165 err = mailstorage_connect(m_pop3);
166 if (err != MAIL_NO_ERROR) { 166 if (err != MAIL_NO_ERROR) {
167 ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; 167 ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl;
168 Global::statusMessage(tr("Error %1 initializing folder").arg( err )); 168 Global::statusMessage(tr("Error %1 initializing folder").arg( err ));
169 mailstorage_free(m_pop3); 169 mailstorage_free(m_pop3);
170 m_pop3 = 0; 170 m_pop3 = 0;
171 } else { 171 } else {
172 mailsession * session = m_pop3->sto_session; 172 mailsession * session = m_pop3->sto_session;
173 mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; 173 mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session;
174 if (mail) { 174 if (mail) {
175 mail->pop3_progr_fun = &pop3_progress; 175 mail->pop3_progr_fun = &pop3_progress;
176 } 176 }
177 } 177 }
178} 178}
179 179
180void POP3wrapper::logout() 180void POP3wrapper::logout()
181{ 181{
182 if ( m_pop3 == NULL ) 182 if ( m_pop3 == NULL )
183 return; 183 return;
184 mailstorage_free(m_pop3); 184 mailstorage_free(m_pop3);
185 m_pop3 = 0; 185 m_pop3 = 0;
186} 186}
187 187
188 188
189QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { 189QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() {
190 QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); 190 QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>();
191 FolderP inb=new Folder("INBOX","/"); 191 FolderP inb=new Folder("INBOX","/");
192 folders->append(inb); 192 folders->append(inb);
193 return folders; 193 return folders;
194} 194}
195 195
196void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target) 196void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target)
197{ 197{
198 login(); 198 login();
199 if (!m_pop3) 199 if (!m_pop3)
200 return; 200 return;
201 int iii = 0; 201 int iii = 0;
202 int count = target.count(); 202 int count = target.count();
203 QWidget wid; 203
204 QProgressBar wid ( count );
205 wid.setCaption( tr("Deleting ..."));
204 wid.show(); 206 wid.show();
205 while (iii < count ) { 207 while (iii < count ) {
206 Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); 208 Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count));
209 wid.setProgress( iii );
207 wid.raise(); 210 wid.raise();
208 qApp->processEvents(); 211 qApp->processEvents();
209 //qDebug("delete "); 212 //qDebug("delete ");
210 RecMailP mail = (*target.at( iii )); 213 RecMailP mail = (*target.at( iii ));
211 int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); 214 int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber());
212 if (err != MAIL_NO_ERROR) { 215 if (err != MAIL_NO_ERROR) {
213 Global::statusMessage(tr("Error deleting mail")); 216 Global::statusMessage(tr("Error deleting mail"));
214 } 217 }
215 ++iii; 218 ++iii;
216 } 219 }
217} 220}
218void POP3wrapper::deleteMail(const RecMailP&mail) { 221void POP3wrapper::deleteMail(const RecMailP&mail) {
219 login(); 222 login();
220 if (!m_pop3) 223 if (!m_pop3)
221 return; 224 return;
222 int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); 225 int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber());
223 if (err != MAIL_NO_ERROR) { 226 if (err != MAIL_NO_ERROR) {
224 Global::statusMessage(tr("error deleting mail")); 227 Global::statusMessage(tr("error deleting mail"));
225 } 228 }
226} 229}
227 230
228void POP3wrapper::answeredMail(const RecMailP&) {} 231void POP3wrapper::answeredMail(const RecMailP&) {}
229 232
230int POP3wrapper::deleteAllMail(const FolderP&) { 233int POP3wrapper::deleteAllMail(const FolderP&) {
231 login(); 234 login();
232 if (!m_pop3) 235 if (!m_pop3)
233 return 0; 236 return 0;
234 int res = 1; 237 int res = 1;
235 238
236 uint32_t result = 0; 239 uint32_t result = 0;
237 int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); 240 int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result);
238 if (err != MAIL_NO_ERROR) { 241 if (err != MAIL_NO_ERROR) {
239 Global::statusMessage(tr("Error getting folder info")); 242 Global::statusMessage(tr("Error getting folder info"));
240 return 0; 243 return 0;
241 } 244 }
242 QWidget wid; 245
246
247
248 QProgressBar wid ( result );
249 wid.setCaption( tr("Deleting ..."));
243 wid.show(); 250 wid.show();
244 for (unsigned int i = 0; i < result; ++i) { 251 for (unsigned int i = 0; i < result; ++i) {
245 Global::statusMessage(tr("Delete message %1 of %2").arg(i).arg(result)); 252 Global::statusMessage(tr("Delete message %1 of %2").arg(i).arg(result));
253 wid.setProgress( i );
246 wid.raise(); 254 wid.raise();
247 qApp->processEvents(); 255 qApp->processEvents();
248 256
249 err = mailsession_remove_message(m_pop3->sto_session,i+1); 257 err = mailsession_remove_message(m_pop3->sto_session,i+1);
250 if (err != MAIL_NO_ERROR) { 258 if (err != MAIL_NO_ERROR) {
251 Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); 259 Global::statusMessage(tr("Error deleting mail %1").arg(i+1));
252 res=0; 260 res=0;
253 } 261 }
254 break; 262 break;
255 } 263 }
256 return res; 264 return res;
257} 265}
258 266
259void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { 267void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) {
260 login(); 268 login();
261 target_stat.message_count = 0; 269 target_stat.message_count = 0;
262 target_stat.message_unseen = 0; 270 target_stat.message_unseen = 0;
263 target_stat.message_recent = 0; 271 target_stat.message_recent = 0;
264 if (!m_pop3) 272 if (!m_pop3)
265 return; 273 return;
266 int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, 274 int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count,
267 &target_stat.message_recent,&target_stat.message_unseen); 275 &target_stat.message_recent,&target_stat.message_unseen);
268 if (r != MAIL_NO_ERROR) { 276 if (r != MAIL_NO_ERROR) {
269 ; // odebug << "error getting folter status." << oendl; 277 ; // odebug << "error getting folter status." << oendl;
270 } 278 }
271} 279}
272 280
273encodedString* POP3wrapper::fetchRawBody(const RecMailP&mail) { 281encodedString* POP3wrapper::fetchRawBody(const RecMailP&mail) {
274 char*target=0; 282 char*target=0;
275 size_t length=0; 283 size_t length=0;
276 encodedString*res = 0; 284 encodedString*res = 0;
277 mailmessage * mailmsg = 0; 285 mailmessage * mailmsg = 0;
278 int err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); 286 int err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg);
279 err = mailmessage_fetch(mailmsg,&target,&length); 287 err = mailmessage_fetch(mailmsg,&target,&length);
280 if (mailmsg) 288 if (mailmsg)
281 mailmessage_free(mailmsg); 289 mailmessage_free(mailmsg);
282 if (target) { 290 if (target) {
283 res = new encodedString(target,length); 291 res = new encodedString(target,length);
284 } 292 }
285 return res; 293 return res;
286} 294}
287 295
288MAILLIB::ATYPE POP3wrapper::getType()const { 296MAILLIB::ATYPE POP3wrapper::getType()const {
289 return account->getType(); 297 return account->getType();
290} 298}
291 299
292const QString&POP3wrapper::getName()const{ 300const QString&POP3wrapper::getName()const{
293 return account->getAccountName(); 301 return account->getAccountName();
294} 302}