summaryrefslogtreecommitdiff
authoralwin <alwin>2003-12-18 01:52:02 (UTC)
committer alwin <alwin>2003-12-18 01:52:02 (UTC)
commit77e353da0c33bbfabf1b919e25008d62581bf164 (patch) (unidiff)
treeed9d2ccc255de8159598a647a39f31399568cbb9
parente996a7b13e2860280a63d089716958c7886cdc8d (diff)
downloadopie-77e353da0c33bbfabf1b919e25008d62581bf164.zip
opie-77e353da0c33bbfabf1b919e25008d62581bf164.tar.gz
opie-77e353da0c33bbfabf1b919e25008d62581bf164.tar.bz2
nothing much.
just only check in my tries to finish the pop3 stuff and found another bug inside libetpan. when decoding text with fun "mailmime_encoded_phrase_parse" it works fine on i386 machines but not on arm (segmentation fault inside this fun) - it has to be resolved.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/abstractmail.cpp23
-rw-r--r--noncore/net/mail/abstractmail.h1
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.cpp23
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h1
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp49
-rw-r--r--noncore/net/mail/pop3wrapper.cpp49
6 files changed, 130 insertions, 16 deletions
diff --git a/noncore/net/mail/abstractmail.cpp b/noncore/net/mail/abstractmail.cpp
index 92a46f1..b7e5eaa 100644
--- a/noncore/net/mail/abstractmail.cpp
+++ b/noncore/net/mail/abstractmail.cpp
@@ -47,2 +47,25 @@ encodedString* AbstractMail::decode_String(const encodedString*text,const QStrin
47 return result; 47 return result;
48} 48}
49
50QString AbstractMail::convert_String(const char*text)
51{
52#if 0
53 size_t index = 0;
54 char*res = 0;
55
56 qDebug("encode start %s",text);
57 /* attention - doesn't work with arm systems! */
58 int err = mailmime_encoded_phrase_parse("iso-8859-1",
59 text, strlen(text),&index, "iso-8859-1",&res);
60 qDebug("encode end");
61 if (err != MAILIMF_NO_ERROR) {
62 if (res) free(res);
63 return QString(text);
64 }
65 QString result(res);
66 free(res);
67 return result;
68#else
69 return QString(text);
70#endif
71}
diff --git a/noncore/net/mail/abstractmail.h b/noncore/net/mail/abstractmail.h
index f1a8468..c16e9c0 100644
--- a/noncore/net/mail/abstractmail.h
+++ b/noncore/net/mail/abstractmail.h
@@ -32,4 +32,5 @@ public:
32 static AbstractMail* getWrapper(POP3account *a); 32 static AbstractMail* getWrapper(POP3account *a);
33 static encodedString*decode_String(const encodedString*text,const QString&enc); 33 static encodedString*decode_String(const encodedString*text,const QString&enc);
34 static QString convert_String(const char*text);
34}; 35};
35#endif 36#endif
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp
index 92a46f1..b7e5eaa 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.cpp
+++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp
@@ -47,2 +47,25 @@ encodedString* AbstractMail::decode_String(const encodedString*text,const QStrin
47 return result; 47 return result;
48} 48}
49
50QString AbstractMail::convert_String(const char*text)
51{
52#if 0
53 size_t index = 0;
54 char*res = 0;
55
56 qDebug("encode start %s",text);
57 /* attention - doesn't work with arm systems! */
58 int err = mailmime_encoded_phrase_parse("iso-8859-1",
59 text, strlen(text),&index, "iso-8859-1",&res);
60 qDebug("encode end");
61 if (err != MAILIMF_NO_ERROR) {
62 if (res) free(res);
63 return QString(text);
64 }
65 QString result(res);
66 free(res);
67 return result;
68#else
69 return QString(text);
70#endif
71}
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index f1a8468..c16e9c0 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -32,4 +32,5 @@ public:
32 static AbstractMail* getWrapper(POP3account *a); 32 static AbstractMail* getWrapper(POP3account *a);
33 static encodedString*decode_String(const encodedString*text,const QString&enc); 33 static encodedString*decode_String(const encodedString*text,const QString&enc);
34 static QString convert_String(const char*text);
34}; 35};
35#endif 36#endif
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index 30f80ff..22a4c70 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -4,6 +4,10 @@
4#include <libetpan/mailpop3.h> 4#include <libetpan/mailpop3.h>
5#include <libetpan/mailmime.h> 5#include <libetpan/mailmime.h>
6#include <libetpan/data_message_driver.h>
6#include <qfile.h> 7#include <qfile.h>
7 8
9/* we don't fetch messages larger than 5 MB */
10#define HARD_MSG_SIZE_LIMIT 5242880
11
8POP3wrapper::POP3wrapper( POP3account *a ) 12POP3wrapper::POP3wrapper( POP3account *a )
9{ 13{
@@ -38,8 +42,13 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail )
38 return RecBody(); 42 return RecBody();
39 } 43 }
44
40 RecBody body; 45 RecBody body;
41 46
42 QFile msg_cache(msgTempName); 47 QFile msg_cache(msgTempName);
43 48
49 if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) {
50 qDebug("Message to large: %i",mail.Msgsize());
51 return body;
52 }
44 if (mail.getNumber()!=last_msg_id) { 53 if (mail.getNumber()!=last_msg_id) {
45 if (msg_cache.exists()) { 54 if (msg_cache.exists()) {
@@ -80,4 +89,8 @@ RecBody POP3wrapper::parseMail( char *message )
80 size_t curTok = 0; 89 size_t curTok = 0;
81 mailimf_message *result = 0; 90 mailimf_message *result = 0;
91 mailmessage * msg=0;
92 struct mailmime * mime=0;
93 struct mailmime_single_fields fields;
94
82 RecBody body; 95 RecBody body;
83 96
@@ -88,9 +101,29 @@ RecBody POP3wrapper::parseMail( char *message )
88 return body; 101 return body;
89 } 102 }
90 103
91 struct mailimf_body * b = 0; 104#if 0
92 struct mailimf_fields * f = 0; 105 char*body_msg = message;
93 106 if ( result && result->msg_body && result->msg_body->bd_text ) {
94 107 body_msg = (char*)result->msg_body->bd_text;
108 result->msg_body->bd_text = 0;
109 }
110
111 msg = mailmessage_new();
112 mailmessage_init(msg, NULL, data_message_driver, 0, strlen(body_msg));
113 generic_message_t * msg_data;
114 msg_data = (generic_message_t *)msg->msg_data;
115 msg_data->msg_fetched = 1;
116 msg_data->msg_message = body_msg;
117 msg_data->msg_length = strlen(body_msg);
118 memset(&fields, 0, sizeof(struct mailmime_single_fields));
119 err = mailmessage_get_bodystructure(msg,&mime);
120
121 if (mime->mm_mime_fields != NULL) {
122 mailmime_single_fields_init(&fields, mime->mm_mime_fields,
123 mime->mm_content_type);
124 }
125#endif
126
127#if 1
95 if ( result && result->msg_body && result->msg_body->bd_text ) { 128 if ( result && result->msg_body && result->msg_body->bd_text ) {
96 qDebug( "POP3: bodytext found" ); 129 qDebug( "POP3: bodytext found" );
@@ -109,4 +142,5 @@ RecBody POP3wrapper::parseMail( char *message )
109 mailimf_message_free(result); 142 mailimf_message_free(result);
110 } 143 }
144#endif
111 return body; 145 return body;
112} 146}
@@ -173,5 +207,5 @@ RecMail *POP3wrapper::parseHeader( const char *header )
173 break; 207 break;
174 case MAILIMF_FIELD_SUBJECT: 208 case MAILIMF_FIELD_SUBJECT:
175 mail->setSubject( QString( field->fld_data.fld_subject->sbj_value ) ); 209 mail->setSubject(convert_String( field->fld_data.fld_subject->sbj_value ) );
176 break; 210 break;
177 case MAILIMF_FIELD_ORIG_DATE: 211 case MAILIMF_FIELD_ORIG_DATE:
@@ -204,5 +238,4 @@ RecMail *POP3wrapper::parseHeader( const char *header )
204 qDebug("X-Status: %s",value.latin1()); 238 qDebug("X-Status: %s",value.latin1());
205 if (value.lower()=="a") { 239 if (value.lower()=="a") {
206
207 mFlags.setBit(FLAG_ANSWERED); 240 mFlags.setBit(FLAG_ANSWERED);
208 } 241 }
@@ -285,5 +318,5 @@ QString POP3wrapper::parseMailbox( mailimf_mailbox *box )
285 result.append( box->mb_addr_spec ); 318 result.append( box->mb_addr_spec );
286 } else { 319 } else {
287 result.append( box->mb_display_name ); 320 result.append( convert_String(box->mb_display_name).latin1() );
288 result.append( " <" ); 321 result.append( " <" );
289 result.append( box->mb_addr_spec ); 322 result.append( box->mb_addr_spec );
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp
index 30f80ff..22a4c70 100644
--- a/noncore/net/mail/pop3wrapper.cpp
+++ b/noncore/net/mail/pop3wrapper.cpp
@@ -4,6 +4,10 @@
4#include <libetpan/mailpop3.h> 4#include <libetpan/mailpop3.h>
5#include <libetpan/mailmime.h> 5#include <libetpan/mailmime.h>
6#include <libetpan/data_message_driver.h>
6#include <qfile.h> 7#include <qfile.h>
7 8
9/* we don't fetch messages larger than 5 MB */
10#define HARD_MSG_SIZE_LIMIT 5242880
11
8POP3wrapper::POP3wrapper( POP3account *a ) 12POP3wrapper::POP3wrapper( POP3account *a )
9{ 13{
@@ -38,8 +42,13 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail )
38 return RecBody(); 42 return RecBody();
39 } 43 }
44
40 RecBody body; 45 RecBody body;
41 46
42 QFile msg_cache(msgTempName); 47 QFile msg_cache(msgTempName);
43 48
49 if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) {
50 qDebug("Message to large: %i",mail.Msgsize());
51 return body;
52 }
44 if (mail.getNumber()!=last_msg_id) { 53 if (mail.getNumber()!=last_msg_id) {
45 if (msg_cache.exists()) { 54 if (msg_cache.exists()) {
@@ -80,4 +89,8 @@ RecBody POP3wrapper::parseMail( char *message )
80 size_t curTok = 0; 89 size_t curTok = 0;
81 mailimf_message *result = 0; 90 mailimf_message *result = 0;
91 mailmessage * msg=0;
92 struct mailmime * mime=0;
93 struct mailmime_single_fields fields;
94
82 RecBody body; 95 RecBody body;
83 96
@@ -88,9 +101,29 @@ RecBody POP3wrapper::parseMail( char *message )
88 return body; 101 return body;
89 } 102 }
90 103
91 struct mailimf_body * b = 0; 104#if 0
92 struct mailimf_fields * f = 0; 105 char*body_msg = message;
93 106 if ( result && result->msg_body && result->msg_body->bd_text ) {
94 107 body_msg = (char*)result->msg_body->bd_text;
108 result->msg_body->bd_text = 0;
109 }
110
111 msg = mailmessage_new();
112 mailmessage_init(msg, NULL, data_message_driver, 0, strlen(body_msg));
113 generic_message_t * msg_data;
114 msg_data = (generic_message_t *)msg->msg_data;
115 msg_data->msg_fetched = 1;
116 msg_data->msg_message = body_msg;
117 msg_data->msg_length = strlen(body_msg);
118 memset(&fields, 0, sizeof(struct mailmime_single_fields));
119 err = mailmessage_get_bodystructure(msg,&mime);
120
121 if (mime->mm_mime_fields != NULL) {
122 mailmime_single_fields_init(&fields, mime->mm_mime_fields,
123 mime->mm_content_type);
124 }
125#endif
126
127#if 1
95 if ( result && result->msg_body && result->msg_body->bd_text ) { 128 if ( result && result->msg_body && result->msg_body->bd_text ) {
96 qDebug( "POP3: bodytext found" ); 129 qDebug( "POP3: bodytext found" );
@@ -109,4 +142,5 @@ RecBody POP3wrapper::parseMail( char *message )
109 mailimf_message_free(result); 142 mailimf_message_free(result);
110 } 143 }
144#endif
111 return body; 145 return body;
112} 146}
@@ -173,5 +207,5 @@ RecMail *POP3wrapper::parseHeader( const char *header )
173 break; 207 break;
174 case MAILIMF_FIELD_SUBJECT: 208 case MAILIMF_FIELD_SUBJECT:
175 mail->setSubject( QString( field->fld_data.fld_subject->sbj_value ) ); 209 mail->setSubject(convert_String( field->fld_data.fld_subject->sbj_value ) );
176 break; 210 break;
177 case MAILIMF_FIELD_ORIG_DATE: 211 case MAILIMF_FIELD_ORIG_DATE:
@@ -204,5 +238,4 @@ RecMail *POP3wrapper::parseHeader( const char *header )
204 qDebug("X-Status: %s",value.latin1()); 238 qDebug("X-Status: %s",value.latin1());
205 if (value.lower()=="a") { 239 if (value.lower()=="a") {
206
207 mFlags.setBit(FLAG_ANSWERED); 240 mFlags.setBit(FLAG_ANSWERED);
208 } 241 }
@@ -285,5 +318,5 @@ QString POP3wrapper::parseMailbox( mailimf_mailbox *box )
285 result.append( box->mb_addr_spec ); 318 result.append( box->mb_addr_spec );
286 } else { 319 } else {
287 result.append( box->mb_display_name ); 320 result.append( convert_String(box->mb_display_name).latin1() );
288 result.append( " <" ); 321 result.append( " <" );
289 result.append( box->mb_addr_spec ); 322 result.append( box->mb_addr_spec );