Diffstat (limited to 'kmicromail/libmailwrapper/mailwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/mailwrapper.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/kmicromail/libmailwrapper/mailwrapper.cpp b/kmicromail/libmailwrapper/mailwrapper.cpp index 2ee1ab3..9c299e8 100644 --- a/kmicromail/libmailwrapper/mailwrapper.cpp +++ b/kmicromail/libmailwrapper/mailwrapper.cpp | |||
@@ -1,23 +1,25 @@ | |||
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 | //Added by qt3to4: | ||
9 | #include <Q3CString> | ||
8 | 10 | ||
9 | #include "mailwrapper.h" | 11 | #include "mailwrapper.h" |
10 | //#include "logindialog.h" | 12 | //#include "logindialog.h" |
11 | //#include "defines.h" | 13 | //#include "defines.h" |
12 | 14 | ||
13 | #define UNDEFINED 64 | 15 | #define UNDEFINED 64 |
14 | #define MAXLINE 76 | 16 | #define MAXLINE 76 |
15 | #define UTF16MASK 0x03FFUL | 17 | #define UTF16MASK 0x03FFUL |
16 | #define UTF16SHIFT 10 | 18 | #define UTF16SHIFT 10 |
17 | #define UTF16BASE 0x10000UL | 19 | #define UTF16BASE 0x10000UL |
18 | #define UTF16HIGHSTART 0xD800UL | 20 | #define UTF16HIGHSTART 0xD800UL |
19 | #define UTF16HIGHEND 0xDBFFUL | 21 | #define UTF16HIGHEND 0xDBFFUL |
20 | #define UTF16LOSTART 0xDC00UL | 22 | #define UTF16LOSTART 0xDC00UL |
21 | #define UTF16LOEND 0xDFFFUL | 23 | #define UTF16LOEND 0xDFFFUL |
22 | 24 | ||
23 | 25 | ||
@@ -68,57 +70,57 @@ IMAPFolder::~IMAPFolder() | |||
68 | { | 70 | { |
69 | } | 71 | } |
70 | 72 | ||
71 | static unsigned char base64chars[] = | 73 | static unsigned char base64chars[] = |
72 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,"; | 74 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,"; |
73 | 75 | ||
74 | /** | 76 | /** |
75 | * Decodes base64 encoded parts of the imapfolder name | 77 | * Decodes base64 encoded parts of the imapfolder name |
76 | * Code taken from kde cvs: kdebase/kioslave/imap4/rfcdecoder.cc | 78 | * Code taken from kde cvs: kdebase/kioslave/imap4/rfcdecoder.cc |
77 | */ | 79 | */ |
78 | QString IMAPFolder::decodeFolderName( const QString &name ) | 80 | QString IMAPFolder::decodeFolderName( const QString &name ) |
79 | { | 81 | { |
80 | unsigned char c, i, bitcount; | 82 | unsigned char c, i, bitcount; |
81 | unsigned long ucs4, utf16, bitbuf; | 83 | unsigned long ucs4, utf16, bitbuf; |
82 | unsigned char base64[256], utf8[6]; | 84 | unsigned char base64[256], utf8[6]; |
83 | unsigned long srcPtr = 0; | 85 | unsigned long srcPtr = 0; |
84 | QCString dst = ""; | 86 | Q3CString dst = ""; |
85 | QCString src = name.ascii(); | 87 | Q3CString src = name.ascii(); |
86 | 88 | ||
87 | /* initialize modified base64 decoding table */ | 89 | /* initialize modified base64 decoding table */ |
88 | memset(base64, UNDEFINED, sizeof(base64)); | 90 | memset(base64, UNDEFINED, sizeof(base64)); |
89 | for (i = 0; i < sizeof(base64chars); ++i) { | 91 | for (i = 0; i < sizeof(base64chars); ++i) { |
90 | base64[(int)base64chars[i]] = i; | 92 | base64[(int)base64chars[i]] = i; |
91 | } | 93 | } |
92 | 94 | ||
93 | /* loop until end of string */ | 95 | /* loop until end of string */ |
94 | while (srcPtr < src.length ()) { | 96 | while (srcPtr < src.length ()) { |
95 | c = src[srcPtr++]; | 97 | c = src.at(srcPtr++); |
96 | /* deal with literal characters and &- */ | 98 | /* deal with literal characters and &- */ |
97 | if (c != '&' || src[srcPtr] == '-') { | 99 | if (c != '&' || src.at(srcPtr) == '-') { |
98 | /* encode literally */ | 100 | /* encode literally */ |
99 | dst += c; | 101 | dst += c; |
100 | /* skip over the '-' if this is an &- sequence */ | 102 | /* skip over the '-' if this is an &- sequence */ |
101 | if (c == '&') | 103 | if (c == '&') |
102 | srcPtr++; | 104 | srcPtr++; |
103 | } else { | 105 | } else { |
104 | /* convert modified UTF-7 -> UTF-16 -> UCS-4 -> UTF-8 -> HEX */ | 106 | /* convert modified UTF-7 -> UTF-16 -> UCS-4 -> UTF-8 -> HEX */ |
105 | bitbuf = 0; | 107 | bitbuf = 0; |
106 | bitcount = 0; | 108 | bitcount = 0; |
107 | ucs4 = 0; | 109 | ucs4 = 0; |
108 | while ((c = base64[(unsigned char) src[srcPtr]]) != UNDEFINED) { | 110 | while ((c = base64[(unsigned char) src.at(srcPtr)]) != UNDEFINED) { |
109 | ++srcPtr; | 111 | ++srcPtr; |
110 | bitbuf = (bitbuf << 6) | c; | 112 | bitbuf = (bitbuf << 6) | c; |
111 | bitcount += 6; | 113 | bitcount += 6; |
112 | /* enough bits for a UTF-16 character? */ | 114 | /* enough bits for a UTF-16 character? */ |
113 | if (bitcount >= 16) { | 115 | if (bitcount >= 16) { |
114 | bitcount -= 16; | 116 | bitcount -= 16; |
115 | utf16 = (bitcount ? bitbuf >> bitcount : bitbuf) & 0xffff; | 117 | utf16 = (bitcount ? bitbuf >> bitcount : bitbuf) & 0xffff; |
116 | /* convert UTF16 to UCS4 */ | 118 | /* convert UTF16 to UCS4 */ |
117 | if (utf16 >= UTF16HIGHSTART && utf16 <= UTF16HIGHEND) { | 119 | if (utf16 >= UTF16HIGHSTART && utf16 <= UTF16HIGHEND) { |
118 | ucs4 = (utf16 - UTF16HIGHSTART) << UTF16SHIFT; | 120 | ucs4 = (utf16 - UTF16HIGHSTART) << UTF16SHIFT; |
119 | continue; | 121 | continue; |
120 | } else if (utf16 >= UTF16LOSTART && utf16 <= UTF16LOEND) { | 122 | } else if (utf16 >= UTF16LOSTART && utf16 <= UTF16LOEND) { |
121 | ucs4 += utf16 - UTF16LOSTART + UTF16BASE; | 123 | ucs4 += utf16 - UTF16LOSTART + UTF16BASE; |
122 | } else { | 124 | } else { |
123 | ucs4 = utf16; | 125 | ucs4 = utf16; |
124 | } | 126 | } |
@@ -136,33 +138,33 @@ QString IMAPFolder::decodeFolderName( const QString &name ) | |||
136 | utf8[2] = 0x80 | (ucs4 & 0x3f); | 138 | utf8[2] = 0x80 | (ucs4 & 0x3f); |
137 | i = 3; | 139 | i = 3; |
138 | } else { | 140 | } else { |
139 | utf8[0] = 0xf0 | (ucs4 >> 18); | 141 | utf8[0] = 0xf0 | (ucs4 >> 18); |
140 | utf8[1] = 0x80 | ((ucs4 >> 12) & 0x3f); | 142 | utf8[1] = 0x80 | ((ucs4 >> 12) & 0x3f); |
141 | utf8[2] = 0x80 | ((ucs4 >> 6) & 0x3f); | 143 | utf8[2] = 0x80 | ((ucs4 >> 6) & 0x3f); |
142 | utf8[3] = 0x80 | (ucs4 & 0x3f); | 144 | utf8[3] = 0x80 | (ucs4 & 0x3f); |
143 | i = 4; | 145 | i = 4; |
144 | } | 146 | } |
145 | /* copy it */ | 147 | /* copy it */ |
146 | for (c = 0; c < i; ++c) { | 148 | for (c = 0; c < i; ++c) { |
147 | dst += utf8[c]; | 149 | dst += utf8[c]; |
148 | } | 150 | } |
149 | } | 151 | } |
150 | } | 152 | } |
151 | /* skip over trailing '-' in modified UTF-7 encoding */ | 153 | /* skip over trailing '-' in modified UTF-7 encoding */ |
152 | if (src[srcPtr] == '-') | 154 | if (src.at(srcPtr) == '-') |
153 | ++srcPtr; | 155 | ++srcPtr; |
154 | } | 156 | } |
155 | } | 157 | } |
156 | 158 | ||
157 | return QString::fromUtf8( dst.data() ); | 159 | return QString::fromUtf8( dst.data() ); |
158 | } | 160 | } |
159 | 161 | ||
160 | Mail::Mail() | 162 | Mail::Mail() |
161 | :Opie::Core::ORefCount(),name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") | 163 | :Opie::Core::ORefCount(),name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") |
162 | { | 164 | { |
163 | } | 165 | } |
164 | 166 | ||
165 | MHFolder::MHFolder(const QString&disp_name,const QString&mbox) | 167 | MHFolder::MHFolder(const QString&disp_name,const QString&mbox) |
166 | : Folder( disp_name,"/" ) | 168 | : Folder( disp_name,"/" ) |
167 | { | 169 | { |
168 | separator = "/"; | 170 | separator = "/"; |