-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp index d71d35c..ac6f380 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.cpp +++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp | |||
@@ -38,110 +38,110 @@ AbstractMail* AbstractMail::getWrapper(Account*a) | |||
38 | case MAILLIB::A_IMAP: | 38 | case MAILLIB::A_IMAP: |
39 | return new IMAPwrapper((IMAPaccount*)a); | 39 | return new IMAPwrapper((IMAPaccount*)a); |
40 | break; | 40 | break; |
41 | case MAILLIB::A_POP3: | 41 | case MAILLIB::A_POP3: |
42 | return new POP3wrapper((POP3account*)a); | 42 | return new POP3wrapper((POP3account*)a); |
43 | break; | 43 | break; |
44 | case MAILLIB::A_NNTP: | 44 | case MAILLIB::A_NNTP: |
45 | return new NNTPwrapper((NNTPaccount*)a); | 45 | return new NNTPwrapper((NNTPaccount*)a); |
46 | break; | 46 | break; |
47 | default: | 47 | default: |
48 | return 0; | 48 | return 0; |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) | 52 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) |
53 | { | 53 | { |
54 | qDebug("Decode string start"); | 54 | qDebug("Decode string start"); |
55 | char*result_text; | 55 | char*result_text; |
56 | size_t index = 0; | 56 | size_t index = 0; |
57 | /* reset for recursive use! */ | 57 | /* reset for recursive use! */ |
58 | size_t target_length = 0; | 58 | size_t target_length = 0; |
59 | result_text = 0; | 59 | result_text = 0; |
60 | int mimetype = MAILMIME_MECHANISM_7BIT; | 60 | int mimetype = MAILMIME_MECHANISM_7BIT; |
61 | if (enc.lower()=="quoted-printable") { | 61 | if (enc.lower()=="quoted-printable") { |
62 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; | 62 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; |
63 | } else if (enc.lower()=="base64") { | 63 | } else if (enc.lower()=="base64") { |
64 | mimetype = MAILMIME_MECHANISM_BASE64; | 64 | mimetype = MAILMIME_MECHANISM_BASE64; |
65 | } else if (enc.lower()=="8bit") { | 65 | } else if (enc.lower()=="8bit") { |
66 | mimetype = MAILMIME_MECHANISM_8BIT; | 66 | mimetype = MAILMIME_MECHANISM_8BIT; |
67 | } else if (enc.lower()=="binary") { | 67 | } else if (enc.lower()=="binary") { |
68 | mimetype = MAILMIME_MECHANISM_BINARY; | 68 | mimetype = MAILMIME_MECHANISM_BINARY; |
69 | } | 69 | } |
70 | 70 | ||
71 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, | 71 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, |
72 | &result_text,&target_length); | 72 | &result_text,&target_length); |
73 | 73 | ||
74 | encodedString* result = new encodedString(); | 74 | encodedString* result = new encodedString(); |
75 | if (err == MAILIMF_NO_ERROR) { | 75 | if (err == MAILIMF_NO_ERROR) { |
76 | result->setContent(result_text,target_length); | 76 | result->setContent(result_text,target_length); |
77 | } | 77 | } |
78 | qDebug("Decode string finished"); | 78 | qDebug("Decode string finished"); |
79 | return result; | 79 | return result; |
80 | } | 80 | } |
81 | 81 | ||
82 | QString AbstractMail::convert_String(const char*text) | 82 | QString AbstractMail::convert_String(const char*text) |
83 | { | 83 | { |
84 | size_t index = 0; | 84 | size_t index = 0; |
85 | char*res = 0; | 85 | char*res = 0; |
86 | int err = MAILIMF_NO_ERROR; | ||
86 | 87 | ||
87 | /* attention - doesn't work with arm systems! */ | 88 | QString result(text); |
88 | int err = mailmime_encoded_phrase_parse("iso-8859-1", | 89 | |
89 | text, strlen(text),&index, "iso-8859-1",&res); | 90 | /* due a bug in libetpan it isn't usable this moment */ |
90 | if (err != MAILIMF_NO_ERROR) { | 91 | /* int err = mailmime_encoded_phrase_parse("iso-8859-1", |
91 | if (res) free(res); | 92 | text, strlen(text),&index, "iso-8859-1",&res);*/ |
92 | return QString(text); | 93 | //qDebug("Input: %s",text); |
93 | } | 94 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { |
94 | if (res) { | 95 | // result = QString(res); |
95 | QString result(res); | 96 | // qDebug("Res: %s, length: %i",res,strlen(res)); |
96 | free(res); | ||
97 | return result; | ||
98 | } | 97 | } |
99 | return QString(text); | 98 | if (res) free(res); |
99 | return result; | ||
100 | } | 100 | } |
101 | 101 | ||
102 | /* cp & paste from launcher */ | 102 | /* cp & paste from launcher */ |
103 | QString AbstractMail::gen_attachment_id() | 103 | QString AbstractMail::gen_attachment_id() |
104 | { | 104 | { |
105 | QFile file( "/proc/sys/kernel/random/uuid" ); | 105 | QFile file( "/proc/sys/kernel/random/uuid" ); |
106 | if (!file.open(IO_ReadOnly ) ) | 106 | if (!file.open(IO_ReadOnly ) ) |
107 | return QString::null; | 107 | return QString::null; |
108 | 108 | ||
109 | QTextStream stream(&file); | 109 | QTextStream stream(&file); |
110 | 110 | ||
111 | return "{" + stream.read().stripWhiteSpace() + "}"; | 111 | return "{" + stream.read().stripWhiteSpace() + "}"; |
112 | } | 112 | } |
113 | 113 | ||
114 | int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool) | 114 | int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool) |
115 | { | 115 | { |
116 | return 0; | 116 | return 0; |
117 | } | 117 | } |
118 | 118 | ||
119 | QString AbstractMail::defaultLocalfolder() | 119 | QString AbstractMail::defaultLocalfolder() |
120 | { | 120 | { |
121 | QString f = getenv( "HOME" ); | 121 | QString f = getenv( "HOME" ); |
122 | f += "/Applications/opiemail/localmail"; | 122 | f += "/Applications/opiemail/localmail"; |
123 | return f; | 123 | return f; |
124 | } | 124 | } |
125 | 125 | ||
126 | QString AbstractMail::draftFolder() | 126 | QString AbstractMail::draftFolder() |
127 | { | 127 | { |
128 | return QString("Drafts"); | 128 | return QString("Drafts"); |
129 | } | 129 | } |
130 | 130 | ||
131 | /* temporary - will be removed when implemented in all classes */ | 131 | /* temporary - will be removed when implemented in all classes */ |
132 | void AbstractMail::deleteMails(const QString &,QList<RecMail> &) | 132 | void AbstractMail::deleteMails(const QString &,QList<RecMail> &) |
133 | { | 133 | { |
134 | } | 134 | } |
135 | 135 | ||
136 | void AbstractMail::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 136 | void AbstractMail::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
137 | { | 137 | { |
138 | QList<RecMail> t; | 138 | QList<RecMail> t; |
139 | listMessages(fromFolder->getName(),t); | 139 | listMessages(fromFolder->getName(),t); |
140 | encodedString*st = 0; | 140 | encodedString*st = 0; |
141 | while (t.count()>0) { | 141 | while (t.count()>0) { |
142 | RecMail*r = t.at(0); | 142 | RecMail*r = t.at(0); |
143 | st = fetchRawBody(*r); | 143 | st = fetchRawBody(*r); |
144 | if (st) { | 144 | if (st) { |
145 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 145 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
146 | delete st; | 146 | delete st; |
147 | } | 147 | } |