Convert the per-thread mutex list to a standard list.
[wine.git] / dlls / mlang / mlang.c
blob90e4941cb5c4217073a54fbdc95d20dd911aeeaa
1 /*
2 * MLANG Class Factory
4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2003,2004 Mike McCormack
6 * Copyright 2004 Dmitry Timoshkov
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "config.h"
25 #include <stdarg.h>
26 #include <stdio.h>
28 #define COBJMACROS
30 #include "windef.h"
31 #include "winbase.h"
32 #include "wingdi.h"
33 #include "winuser.h"
34 #include "winreg.h"
35 #include "ole2.h"
36 #include "mlang.h"
38 #include "uuids.h"
40 #include "wine/unicode.h"
41 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(mlang);
45 #include "initguid.h"
47 #define CP_UNICODE 1200
49 #define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
51 static HRESULT MultiLanguage_create(IUnknown *pUnkOuter, LPVOID *ppObj);
53 /* FIXME:
54 * Under what circumstances HKEY_CLASSES_ROOT\MIME\Database\Codepage and
55 * HKEY_CLASSES_ROOT\MIME\Database\Charset are used?
58 typedef struct
60 const char *description;
61 UINT cp;
62 DWORD flags;
63 const char *web_charset;
64 const char *header_charset;
65 const char *body_charset;
66 } MIME_CP_INFO;
68 /* These data are based on the codepage info in libs/unicode/cpmap.pl */
69 /* FIXME: Add 28604 (Celtic), 28606 (Balkan) */
71 static const MIME_CP_INFO arabic_cp[] =
73 { "Arabic (864)",
74 864, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
75 MIMECONTF_MIME_LATEST,
76 "ibm864", "ibm864", "ibm864" },
77 { "Arabic (1006)",
78 1006, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
79 MIMECONTF_MIME_LATEST,
80 "ibm1006", "ibm1006", "ibm1006" },
81 { "Arabic (Windows)",
82 1256, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
83 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
84 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
85 "windows-1256", "windows-1256", "windows-1256" },
86 { "Arabic (ISO)",
87 28596, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
88 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
89 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
90 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
91 "iso-8859-6", "iso-8859-6", "iso-8859-6" }
93 static const MIME_CP_INFO baltic_cp[] =
95 { "Baltic (DOS)",
96 775, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
97 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
98 "ibm775", "ibm775", "ibm775" },
99 { "Baltic (Windows)",
100 1257, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
101 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
102 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
103 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
104 "windows-1257", "windows-1257", "windows-1257" },
105 { "Baltic (ISO)",
106 28594, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
107 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
108 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
109 MIMECONTF_MIME_LATEST,
110 "iso-8859-4", "iso-8859-4", "iso-8859-4" },
111 { "Estonian (ISO)",
112 28603, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
113 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
114 "iso-8859-13", "iso-8859-13", "iso-8859-13" }
116 static const MIME_CP_INFO chinese_simplified_cp[] =
118 { "Chinese Simplified (GB2312)",
119 936, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
120 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
121 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
122 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
123 "gb2312", "gb2312", "gb2312" }
125 static const MIME_CP_INFO chinese_traditional_cp[] =
127 { "Chinese Traditional (Big5)",
128 950, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
129 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
130 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
131 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
132 "big5", "big5", "big5" }
134 static const MIME_CP_INFO central_european_cp[] =
136 { "Central European (DOS)",
137 852, MIMECONTF_BROWSER | MIMECONTF_IMPORT | MIMECONTF_SAVABLE_BROWSER |
138 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
139 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
140 "ibm852", "ibm852", "ibm852" },
141 { "Central European (Windows)",
142 1250, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
143 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
144 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
145 MIMECONTF_MIME_LATEST,
146 "windows-1250", "windows-1250", "windows-1250" },
147 { "Central European (Mac)",
148 10029, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
149 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
150 "x-mac-ce", "x-mac-ce", "x-mac-ce" },
151 { "Central European (ISO)",
152 28592, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
153 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
154 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
155 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
156 "iso-8859-2", "iso-8859-2", "iso-8859-2" }
158 static const MIME_CP_INFO cyrillic_cp[] =
160 { "OEM Cyrillic",
161 855, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
162 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
163 "ibm855", "ibm855", "ibm855" },
164 { "Cyrillic (DOS)",
165 866, MIMECONTF_BROWSER | MIMECONTF_IMPORT | MIMECONTF_SAVABLE_BROWSER |
166 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 |
167 MIMECONTF_MIME_LATEST,
168 "cp866", "cp866", "cp866" },
169 #if 0 /* Windows has 20866 as an official code page for KOI8-R */
170 { "Cyrillic (KOI8-R)",
171 878, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
172 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
173 "koi8-r", "koi8-r", "koi8-r" },
174 #endif
175 { "Cyrillic (Windows)",
176 1251, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
177 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
178 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
179 "windows-1251", "windows-1251", "windows-1251" },
180 { "Cyrillic (Mac)",
181 10007, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
182 MIMECONTF_MIME_LATEST,
183 "x-mac-cyrillic", "x-mac-cyrillic", "x-mac-cyrillic" },
184 { "Cyrillic (KOI8-R)",
185 20866, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
186 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
187 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
188 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
189 "koi8-r", "koi8-r", "koi8-r" },
190 { "Cyrillic (KOI8-U)",
191 21866, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
192 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
193 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
194 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
195 "koi8-u", "koi8-u", "koi8-u" },
196 { "Cyrillic (ISO)",
197 28595, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
198 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
199 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
200 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
201 "iso-8859-5", "iso-8859-5", "iso-8859-5" }
203 static const MIME_CP_INFO greek_cp[] =
205 { "Greek (DOS)",
206 737, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
207 MIMECONTF_MIME_LATEST,
208 "ibm737", "ibm737", "ibm737" },
209 { "Greek, Modern (DOS)",
210 869, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
211 MIMECONTF_MIME_LATEST,
212 "ibm869", "ibm869", "ibm869" },
213 { "IBM EBCDIC (Greek Modern)",
214 875, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
215 MIMECONTF_MIME_LATEST,
216 "cp875", "cp875", "cp875" },
217 { "Greek (Windows)",
218 1253, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
219 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
220 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
221 "windows-1253", "windows-1253", "windows-1253" },
222 { "Greek (Mac)",
223 10006, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
224 MIMECONTF_MIME_LATEST,
225 "x-mac-greek", "x-mac-greek", "x-mac-greek" },
226 { "Greek (ISO)",
227 28597, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
228 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
229 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
230 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
231 "iso-8859-7", "iso-8859-7", "iso-8859-7" }
233 static const MIME_CP_INFO hebrew_cp[] =
235 { "Hebrew (424)",
236 424, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
237 MIMECONTF_MIME_LATEST,
238 "ibm424", "ibm424", "ibm424" },
239 { "Hebrew (856)",
240 856, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
241 MIMECONTF_MIME_LATEST,
242 "cp856", "cp856", "cp856" },
243 { "Hebrew (DOS)",
244 862, MIMECONTF_BROWSER | MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
245 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
246 MIMECONTF_MIME_LATEST,
247 "dos-862", "dos-862", "dos-862" },
248 { "Hebrew (Windows)",
249 1255, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
250 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
251 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
252 "windows-1255", "windows-1255", "windows-1255" },
253 { "Hebrew (ISO-Visual)",
254 28598, MIMECONTF_BROWSER | MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
255 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
256 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
257 "iso-8859-8", "iso-8859-8", "iso-8859-8" }
259 static const MIME_CP_INFO japanese_cp[] =
261 { "Japanese (Shift-JIS)",
262 932, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
263 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
264 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
265 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
266 "shift_jis", "iso-2022-jp", "iso-2022-jp" },
267 { "Japanese (JIS 0208-1990 and 0212-1990)",
268 20932, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
269 MIMECONTF_MIME_LATEST,
270 "euc-jp", "euc-jp", "euc-jp" }
272 static const MIME_CP_INFO korean_cp[] =
274 { "Korean",
275 949, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
276 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
277 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
278 MIMECONTF_MIME_LATEST,
279 "ks_c_5601-1987", "ks_c_5601-1987", "ks_c_5601-1987" }
281 static const MIME_CP_INFO thai_cp[] =
283 { "Thai (Windows)",
284 874, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_MIME_LATEST,
285 "ibm-thai", "ibm-thai", "ibm-thai" }
287 static const MIME_CP_INFO turkish_cp[] =
289 { "Turkish (DOS)",
290 857, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
291 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
292 "ibm857", "ibm857", "ibm857" },
293 { "IBM EBCDIC (Turkish Latin-5)",
294 1026, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
295 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
296 "ibm1026", "ibm1026", "ibm1026" },
297 { "Turkish (Windows)",
298 1254, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
299 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
300 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
301 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
302 "windows-1254", "windows-1254", "windows-1254" },
303 { "Turkish (Mac)",
304 10081, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
305 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
306 "x-mac-turkish", "x-mac-turkish", "x-mac-turkish" },
307 { "Latin 3 (ISO)",
308 28593, MIMECONTF_MAILNEWS | MIMECONTF_IMPORT |
309 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_EXPORT | MIMECONTF_VALID |
310 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
311 "iso-8859-3", "iso-8859-3", "iso-8859-3" },
312 { "Turkish (ISO)",
313 28599, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
314 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
315 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
316 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
317 "iso-8859-9", "iso-8859-9", "iso-8859-9" }
319 static const MIME_CP_INFO vietnamese_cp[] =
321 { "Vietnamese (Windows)",
322 1258, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
323 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
324 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 |
325 MIMECONTF_MIME_LATEST,
326 "windows-1258", "windows-1258", "windows-1258" }
328 static const MIME_CP_INFO western_cp[] =
330 { "IBM EBCDIC (US-Canada)",
331 37, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
332 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
333 "ibm037", "ibm037", "ibm037" },
334 { "OEM United States",
335 437, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
336 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
337 "ibm437", "ibm437", "ibm437" },
338 { "IBM EBCDIC (International)",
339 500, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
340 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
341 "ibm500", "ibm500", "ibm500" },
342 { "Western European (DOS)",
343 850, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
344 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
345 "ibm850", "ibm850", "ibm850" },
346 { "Portuguese (DOS)",
347 860, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
348 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
349 "ibm860", "ibm860", "ibm860" },
350 { "Icelandic (DOS)",
351 861, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
352 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
353 "ibm861", "ibm861", "ibm861" },
354 { "French Canadian (DOS)",
355 863, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
356 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
357 "ibm863", "ibm863", "ibm863" },
358 { "Nordic (DOS)",
359 865, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
360 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
361 "ibm865", "ibm865", "ibm865" },
362 { "Western European (Windows)",
363 1252, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
364 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
365 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
366 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
367 "windows-1252", "windows-1252", "iso-8859-1" },
368 { "Western European (Mac)",
369 10000, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
370 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
371 "macintosh", "macintosh", "macintosh" },
372 { "Icelandic (Mac)",
373 10079, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
374 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
375 "x-mac-icelandic", "x-mac-icelandic", "x-mac-icelandic" },
376 { "Western European (ISO)",
377 28591, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
378 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
379 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
380 MIMECONTF_MIME_LATEST,
381 "iso-8859-1", "iso-8859-1", "iso-8859-1" },
382 { "Latin 9 (ISO)",
383 28605, MIMECONTF_MAILNEWS | MIMECONTF_IMPORT |
384 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
385 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
386 MIMECONTF_MIME_LATEST,
387 "iso-8859-15", "iso-8859-15", "iso-8859-15" }
389 static const MIME_CP_INFO unicode_cp[] =
391 { "Unicode",
392 CP_UNICODE, MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
393 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
394 MIMECONTF_VALID | MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 |
395 MIMECONTF_MIME_LATEST,
396 "unicode", "unicode", "unicode" },
397 { "Unicode (UTF-7)",
398 CP_UTF7, MIMECONTF_MAILNEWS | MIMECONTF_IMPORT |
399 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_EXPORT | MIMECONTF_VALID |
400 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
401 "utf-7", "utf-7", "utf-7" },
402 { "Unicode (UTF-8)",
403 CP_UTF8, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
404 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
405 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
406 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
407 "utf-8", "utf-8", "utf-8" }
410 static const struct mlang_data
412 const char *description;
413 UINT family_codepage;
414 UINT number_of_cp;
415 const MIME_CP_INFO *mime_cp_info;
416 const char *fixed_font;
417 const char *proportional_font;
418 } mlang_data[] =
420 { "Arabic",1256,sizeof(arabic_cp)/sizeof(arabic_cp[0]),arabic_cp,
421 "Courier","Arial" }, /* FIXME */
422 { "Baltic",1257,sizeof(baltic_cp)/sizeof(baltic_cp[0]),baltic_cp,
423 "Courier","Arial" }, /* FIXME */
424 { "Chinese Simplified",936,sizeof(chinese_simplified_cp)/sizeof(chinese_simplified_cp[0]),chinese_simplified_cp,
425 "Courier","Arial" }, /* FIXME */
426 { "Chinese Traditional",950,sizeof(chinese_traditional_cp)/sizeof(chinese_traditional_cp[0]),chinese_traditional_cp,
427 "Courier","Arial" }, /* FIXME */
428 { "Central European",1250,sizeof(central_european_cp)/sizeof(central_european_cp[0]),central_european_cp,
429 "Courier","Arial" }, /* FIXME */
430 { "Cyrillic",1251,sizeof(cyrillic_cp)/sizeof(cyrillic_cp[0]),cyrillic_cp,
431 "Courier","Arial" }, /* FIXME */
432 { "Greek",1253,sizeof(greek_cp)/sizeof(greek_cp[0]),greek_cp,
433 "Courier","Arial" }, /* FIXME */
434 { "Hebrew",1255,sizeof(hebrew_cp)/sizeof(hebrew_cp[0]),hebrew_cp,
435 "Courier","Arial" }, /* FIXME */
436 { "Japanese",932,sizeof(japanese_cp)/sizeof(japanese_cp[0]),japanese_cp,
437 "Courier","Arial" }, /* FIXME */
438 { "Korean",949,sizeof(korean_cp)/sizeof(korean_cp[0]),korean_cp,
439 "Courier","Arial" }, /* FIXME */
440 { "Thai",874,sizeof(thai_cp)/sizeof(thai_cp[0]),thai_cp,
441 "Courier","Arial" }, /* FIXME */
442 { "Turkish",1254,sizeof(turkish_cp)/sizeof(turkish_cp[0]),turkish_cp,
443 "Courier","Arial" }, /* FIXME */
444 { "Vietnamese",1258,sizeof(vietnamese_cp)/sizeof(vietnamese_cp[0]),vietnamese_cp,
445 "Courier","Arial" }, /* FIXME */
446 { "Western European",1252,sizeof(western_cp)/sizeof(western_cp[0]),western_cp,
447 "Courier","Arial" }, /* FIXME */
448 { "Unicode",CP_UNICODE,sizeof(unicode_cp)/sizeof(unicode_cp[0]),unicode_cp,
449 "Courier","Arial" } /* FIXME */
452 static void fill_cp_info(const struct mlang_data *ml_data, UINT index, MIMECPINFO *mime_cp_info);
454 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
456 switch(fdwReason) {
457 case DLL_PROCESS_ATTACH:
458 DisableThreadLibraryCalls(hInstDLL);
459 break;
460 case DLL_PROCESS_DETACH:
461 break;
463 return TRUE;
466 HRESULT WINAPI ConvertINetMultiByteToUnicode(
467 LPDWORD pdwMode,
468 DWORD dwEncoding,
469 LPCSTR pSrcStr,
470 LPINT pcSrcSize,
471 LPWSTR pDstStr,
472 LPINT pcDstSize)
474 INT src_len = -1;
476 TRACE("%p %ld %s %p %p %p\n", pdwMode, dwEncoding,
477 debugstr_a(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
479 if (!pcDstSize)
480 return E_FAIL;
482 if (!pcSrcSize)
483 pcSrcSize = &src_len;
485 if (!*pcSrcSize)
487 *pcDstSize = 0;
488 return S_OK;
491 switch (dwEncoding)
493 case CP_UNICODE:
494 if (*pcSrcSize == -1)
495 *pcSrcSize = lstrlenW((LPCWSTR)pSrcStr);
496 *pcDstSize = min(*pcSrcSize, *pcDstSize);
497 *pcSrcSize *= sizeof(WCHAR);
498 if (pDstStr)
499 memmove(pDstStr, pSrcStr, *pcDstSize * sizeof(WCHAR));
500 break;
502 default:
503 if (*pcSrcSize == -1)
504 *pcSrcSize = lstrlenA(pSrcStr);
506 if (pDstStr)
507 *pcDstSize = MultiByteToWideChar(dwEncoding, 0, pSrcStr, *pcSrcSize, pDstStr, *pcDstSize);
508 else
509 *pcDstSize = MultiByteToWideChar(dwEncoding, 0, pSrcStr, *pcSrcSize, NULL, 0);
510 break;
513 if (!*pcDstSize)
514 return E_FAIL;
516 return S_OK;
519 HRESULT WINAPI ConvertINetUnicodeToMultiByte(
520 LPDWORD pdwMode,
521 DWORD dwEncoding,
522 LPCWSTR pSrcStr,
523 LPINT pcSrcSize,
524 LPSTR pDstStr,
525 LPINT pcDstSize)
528 INT src_len = -1;
530 TRACE("%p %ld %s %p %p %p\n", pdwMode, dwEncoding,
531 debugstr_w(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
533 if (!pcDstSize)
534 return E_FAIL;
536 if (!pcSrcSize)
537 pcSrcSize = &src_len;
539 if (!*pcSrcSize)
541 *pcDstSize = 0;
542 return S_OK;
545 switch (dwEncoding)
547 case CP_UNICODE:
548 if (*pcSrcSize == -1)
549 *pcSrcSize = lstrlenW(pSrcStr);
550 *pcDstSize = min(*pcSrcSize * sizeof(WCHAR), *pcDstSize);
551 if (pDstStr)
552 memmove(pDstStr, pSrcStr, *pcDstSize);
553 break;
555 default:
556 if (*pcSrcSize == -1)
557 *pcSrcSize = lstrlenW(pSrcStr);
559 if (pDstStr)
560 *pcDstSize = WideCharToMultiByte(dwEncoding, 0, pSrcStr, *pcSrcSize, pDstStr, *pcDstSize, NULL, NULL);
561 else
562 *pcDstSize = WideCharToMultiByte(dwEncoding, 0, pSrcStr, *pcSrcSize, NULL, 0, NULL, NULL);
563 break;
567 if (!*pcDstSize)
568 return E_FAIL;
570 return S_OK;
573 HRESULT WINAPI ConvertINetString(
574 LPDWORD pdwMode,
575 DWORD dwSrcEncoding,
576 DWORD dwDstEncoding,
577 LPCSTR pSrcStr,
578 LPINT pcSrcSize,
579 LPSTR pDstStr,
580 LPINT pcDstSize
583 FIXME("%p %ld %ld %s %p %p %p: stub!\n", pdwMode, dwSrcEncoding, dwDstEncoding,
584 debugstr_a(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
585 return E_NOTIMPL;
588 static HRESULT GetFamilyCodePage(
589 UINT uiCodePage,
590 UINT* puiFamilyCodePage)
592 UINT i, n;
594 TRACE("%u %p\n", uiCodePage, puiFamilyCodePage);
596 if (!puiFamilyCodePage) return S_FALSE;
598 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
600 for (n = 0; n < mlang_data[i].number_of_cp; n++)
602 if (mlang_data[i].mime_cp_info[n].cp == uiCodePage)
604 *puiFamilyCodePage = mlang_data[i].family_codepage;
605 return S_OK;
610 return S_FALSE;
613 HRESULT WINAPI IsConvertINetStringAvailable(
614 DWORD dwSrcEncoding,
615 DWORD dwDstEncoding)
617 UINT src_family, dst_family;
619 TRACE("%ld %ld\n", dwSrcEncoding, dwDstEncoding);
621 if (GetFamilyCodePage(dwSrcEncoding, &src_family) != S_OK ||
622 GetFamilyCodePage(dwDstEncoding, &dst_family) != S_OK)
623 return S_FALSE;
625 if (src_family == dst_family) return S_OK;
627 /* we can convert any codepage to/from unicode */
628 if (src_family == CP_UNICODE || dst_family == CP_UNICODE) return S_OK;
630 return S_FALSE;
633 HRESULT WINAPI LcidToRfc1766A(
634 LCID Locale,
635 LPSTR pszRfc1766,
636 INT nChar)
638 FIXME("%ld %s %u\n", Locale, pszRfc1766, nChar);
639 return S_FALSE;
642 HRESULT WINAPI LcidToRfc1766W(
643 LCID Locale,
644 LPWSTR pszRfc1766,
645 INT nChar)
647 FIXME("%ld %p %u\n", Locale, pszRfc1766, nChar);
648 return S_FALSE;
651 /******************************************************************************
652 * MLANG ClassFactory
654 typedef struct {
655 IClassFactory ITF_IClassFactory;
657 DWORD ref;
658 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
659 } IClassFactoryImpl;
661 struct object_creation_info
663 const CLSID *clsid;
664 LPCSTR szClassName;
665 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
668 static const struct object_creation_info object_creation[] =
670 { &CLSID_CMultiLanguage, "CLSID_CMultiLanguage", MultiLanguage_create },
673 static HRESULT WINAPI
674 MLANGCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
676 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
678 TRACE("%s\n", debugstr_guid(riid) );
680 if (IsEqualGUID(riid, &IID_IUnknown)
681 || IsEqualGUID(riid, &IID_IClassFactory))
683 IClassFactory_AddRef(iface);
684 *ppobj = This;
685 return S_OK;
688 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
689 return E_NOINTERFACE;
692 static ULONG WINAPI MLANGCF_AddRef(LPCLASSFACTORY iface)
694 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
695 return InterlockedIncrement(&This->ref);
698 static ULONG WINAPI MLANGCF_Release(LPCLASSFACTORY iface)
700 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
702 ULONG ref = InterlockedDecrement(&This->ref);
704 if (ref == 0)
706 TRACE("Destroying %p\n", This);
707 HeapFree(GetProcessHeap(), 0, This);
710 return ref;
713 static HRESULT WINAPI MLANGCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
714 REFIID riid, LPVOID *ppobj)
716 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
717 HRESULT hres;
718 LPUNKNOWN punk;
720 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
722 *ppobj = NULL;
723 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
724 if (SUCCEEDED(hres)) {
725 hres = IUnknown_QueryInterface(punk, riid, ppobj);
726 IUnknown_Release(punk);
728 TRACE("returning (%p) -> %lx\n", *ppobj, hres);
729 return hres;
732 static HRESULT WINAPI MLANGCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
734 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
735 FIXME("(%p)->(%d),stub!\n",This,dolock);
736 return S_OK;
739 static IClassFactoryVtbl MLANGCF_Vtbl =
741 MLANGCF_QueryInterface,
742 MLANGCF_AddRef,
743 MLANGCF_Release,
744 MLANGCF_CreateInstance,
745 MLANGCF_LockServer
748 HRESULT WINAPI MLANG_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
750 int i;
751 IClassFactoryImpl *factory;
753 TRACE("%s %s %p\n",debugstr_guid(rclsid), debugstr_guid(iid), ppv);
755 if ( !IsEqualGUID( &IID_IClassFactory, iid )
756 && ! IsEqualGUID( &IID_IUnknown, iid) )
757 return E_NOINTERFACE;
759 for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
761 if (IsEqualGUID(object_creation[i].clsid, rclsid))
762 break;
765 if (i == sizeof(object_creation)/sizeof(object_creation[0]))
767 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
768 return CLASS_E_CLASSNOTAVAILABLE;
771 TRACE("Creating a class factory for %s\n",object_creation[i].szClassName);
773 factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
774 if (factory == NULL) return E_OUTOFMEMORY;
776 factory->ITF_IClassFactory.lpVtbl = &MLANGCF_Vtbl;
777 factory->ref = 1;
779 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
781 *ppv = &(factory->ITF_IClassFactory);
783 TRACE("(%p) <- %p\n", ppv, &(factory->ITF_IClassFactory) );
785 return S_OK;
789 /******************************************************************************/
791 typedef struct tagMLang_impl
793 IMLangFontLinkVtbl *vtbl_IMLangFontLink;
794 IMultiLanguageVtbl *vtbl_IMultiLanguage;
795 IMultiLanguage2Vtbl *vtbl_IMultiLanguage2;
796 DWORD ref;
797 DWORD total_cp, total_scripts;
798 } MLang_impl;
800 static ULONG WINAPI MLang_AddRef( MLang_impl* This)
802 return InterlockedIncrement(&This->ref);
805 static ULONG WINAPI MLang_Release( MLang_impl* This )
807 ULONG ref = InterlockedDecrement(&This->ref);
809 TRACE("%p ref = %ld\n", This, ref);
810 if (ref == 0)
812 TRACE("Destroying %p\n", This);
813 HeapFree(GetProcessHeap(), 0, This);
816 return ref;
819 static HRESULT WINAPI MLang_QueryInterface(
820 MLang_impl* This,
821 REFIID riid,
822 void** ppvObject)
824 TRACE("%p -> %s\n", This, debugstr_guid(riid) );
826 if (IsEqualGUID(riid, &IID_IUnknown)
827 || IsEqualGUID(riid, &IID_IMLangCodePages)
828 || IsEqualGUID(riid, &IID_IMLangFontLink))
830 MLang_AddRef(This);
831 TRACE("Returning IID_IMLangFontLink %p ref = %ld\n", This, This->ref);
832 *ppvObject = &(This->vtbl_IMLangFontLink);
833 return S_OK;
836 if (IsEqualGUID(riid, &IID_IMultiLanguage) )
838 MLang_AddRef(This);
839 TRACE("Returning IID_IMultiLanguage %p ref = %ld\n", This, This->ref);
840 *ppvObject = &(This->vtbl_IMultiLanguage);
841 return S_OK;
844 if (IsEqualGUID(riid, &IID_IMultiLanguage2) )
846 MLang_AddRef(This);
847 *ppvObject = &(This->vtbl_IMultiLanguage2);
848 TRACE("Returning IID_IMultiLanguage2 %p ref = %ld\n", This, This->ref);
849 return S_OK;
852 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
853 return E_NOINTERFACE;
856 /******************************************************************************/
858 typedef struct tagEnumCodePage_impl
860 IEnumCodePageVtbl *vtbl_IEnumCodePage;
861 DWORD ref;
862 MIMECPINFO *cpinfo;
863 DWORD total, pos;
864 } EnumCodePage_impl;
866 static HRESULT WINAPI fnIEnumCodePage_QueryInterface(
867 IEnumCodePage* iface,
868 REFIID riid,
869 void** ppvObject)
871 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
873 TRACE("%p -> %s\n", This, debugstr_guid(riid) );
875 if (IsEqualGUID(riid, &IID_IUnknown)
876 || IsEqualGUID(riid, &IID_IEnumCodePage))
878 IEnumCodePage_AddRef(iface);
879 TRACE("Returning IID_IEnumCodePage %p ref = %ld\n", This, This->ref);
880 *ppvObject = &(This->vtbl_IEnumCodePage);
881 return S_OK;
884 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
885 return E_NOINTERFACE;
888 static ULONG WINAPI fnIEnumCodePage_AddRef(
889 IEnumCodePage* iface)
891 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
892 return InterlockedIncrement(&This->ref);
895 static ULONG WINAPI fnIEnumCodePage_Release(
896 IEnumCodePage* iface)
898 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
899 ULONG ref = InterlockedDecrement(&This->ref);
901 TRACE("%p ref = %ld\n", This, ref);
902 if (ref == 0)
904 TRACE("Destroying %p\n", This);
905 HeapFree(GetProcessHeap(), 0, This->cpinfo);
906 HeapFree(GetProcessHeap(), 0, This);
909 return ref;
912 static HRESULT WINAPI fnIEnumCodePage_Clone(
913 IEnumCodePage* iface,
914 IEnumCodePage** ppEnum)
916 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
917 FIXME("%p %p\n", This, ppEnum);
918 return E_NOTIMPL;
921 static HRESULT WINAPI fnIEnumCodePage_Next(
922 IEnumCodePage* iface,
923 ULONG celt,
924 PMIMECPINFO rgelt,
925 ULONG* pceltFetched)
927 ULONG i;
929 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
930 TRACE("%p %lu %p %p\n", This, celt, rgelt, pceltFetched);
932 if (!pceltFetched) return S_FALSE;
933 *pceltFetched = 0;
935 if (!rgelt) return S_FALSE;
937 if (This->pos + celt > This->total)
938 celt = This->total - This->pos;
940 if (!celt) return S_FALSE;
942 memcpy(rgelt, This->cpinfo + This->pos, celt * sizeof(MIMECPINFO));
943 *pceltFetched = celt;
944 This->pos += celt;
946 for (i = 0; i < celt; i++)
948 TRACE("#%lu: %08lx %u %u %s %s %s %s %s %s %d\n",
949 i, rgelt[i].dwFlags, rgelt[i].uiCodePage,
950 rgelt[i].uiFamilyCodePage,
951 wine_dbgstr_w(rgelt[i].wszDescription),
952 wine_dbgstr_w(rgelt[i].wszWebCharset),
953 wine_dbgstr_w(rgelt[i].wszHeaderCharset),
954 wine_dbgstr_w(rgelt[i].wszBodyCharset),
955 wine_dbgstr_w(rgelt[i].wszFixedWidthFont),
956 wine_dbgstr_w(rgelt[i].wszProportionalFont),
957 rgelt[i].bGDICharset);
959 return S_OK;
962 static HRESULT WINAPI fnIEnumCodePage_Reset(
963 IEnumCodePage* iface)
965 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
966 TRACE("%p\n", This);
968 This->pos = 0;
969 return S_OK;
972 static HRESULT WINAPI fnIEnumCodePage_Skip(
973 IEnumCodePage* iface,
974 ULONG celt)
976 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
977 TRACE("%p %lu\n", This, celt);
979 if (celt >= This->total) return S_FALSE;
981 This->pos = celt; /* FIXME: should be += ?? */
982 return S_OK;
985 static IEnumCodePageVtbl IEnumCodePage_vtbl =
987 fnIEnumCodePage_QueryInterface,
988 fnIEnumCodePage_AddRef,
989 fnIEnumCodePage_Release,
990 fnIEnumCodePage_Clone,
991 fnIEnumCodePage_Next,
992 fnIEnumCodePage_Reset,
993 fnIEnumCodePage_Skip
996 static HRESULT EnumCodePage_create( MLang_impl* mlang, DWORD grfFlags,
997 LANGID LangId, IEnumCodePage** ppEnumCodePage )
999 EnumCodePage_impl *ecp;
1000 MIMECPINFO *cpinfo;
1001 UINT i, n;
1003 TRACE("%p, %08lx, %04x, %p\n", mlang, grfFlags, LangId, ppEnumCodePage);
1005 if (!grfFlags) /* enumerate internal data base of encodings */
1006 grfFlags = MIMECONTF_MIME_LATEST;
1008 ecp = HeapAlloc( GetProcessHeap(), 0, sizeof (EnumCodePage_impl) );
1009 ecp->vtbl_IEnumCodePage = &IEnumCodePage_vtbl;
1010 ecp->ref = 1;
1011 ecp->pos = 0;
1012 ecp->total = 0;
1013 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1015 for (n = 0; n < mlang_data[i].number_of_cp; n++)
1017 if (mlang_data[i].mime_cp_info[n].flags & grfFlags)
1018 ecp->total++;
1022 ecp->cpinfo = HeapAlloc(GetProcessHeap(), 0,
1023 sizeof(MIMECPINFO) * ecp->total);
1024 cpinfo = ecp->cpinfo;
1026 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1028 for (n = 0; n < mlang_data[i].number_of_cp; n++)
1030 if (mlang_data[i].mime_cp_info[n].flags & grfFlags)
1031 fill_cp_info(&mlang_data[i], n, cpinfo++);
1035 TRACE("enumerated %ld codepages with flags %08lx\n", ecp->total, grfFlags);
1037 *ppEnumCodePage = (IEnumCodePage*) ecp;
1039 return S_OK;
1042 /******************************************************************************/
1044 typedef struct tagEnumScript_impl
1046 IEnumScriptVtbl *vtbl_IEnumScript;
1047 DWORD ref;
1048 SCRIPTINFO *script_info;
1049 DWORD total, pos;
1050 } EnumScript_impl;
1052 static HRESULT WINAPI fnIEnumScript_QueryInterface(
1053 IEnumScript* iface,
1054 REFIID riid,
1055 void** ppvObject)
1057 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1059 TRACE("%p -> %s\n", This, debugstr_guid(riid) );
1061 if (IsEqualGUID(riid, &IID_IUnknown)
1062 || IsEqualGUID(riid, &IID_IEnumScript))
1064 IEnumScript_AddRef(iface);
1065 TRACE("Returning IID_IEnumScript %p ref = %ld\n", This, This->ref);
1066 *ppvObject = &(This->vtbl_IEnumScript);
1067 return S_OK;
1070 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
1071 return E_NOINTERFACE;
1074 static ULONG WINAPI fnIEnumScript_AddRef(
1075 IEnumScript* iface)
1077 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1078 return InterlockedIncrement(&This->ref);
1081 static ULONG WINAPI fnIEnumScript_Release(
1082 IEnumScript* iface)
1084 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1085 ULONG ref = InterlockedDecrement(&This->ref);
1087 TRACE("%p ref = %ld\n", This, ref);
1088 if (ref == 0)
1090 TRACE("Destroying %p\n", This);
1091 HeapFree(GetProcessHeap(), 0, This);
1094 return ref;
1097 static HRESULT WINAPI fnIEnumScript_Clone(
1098 IEnumScript* iface,
1099 IEnumScript** ppEnum)
1101 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1102 FIXME("%p %p: stub!\n", This, ppEnum);
1103 return E_NOTIMPL;
1106 static HRESULT WINAPI fnIEnumScript_Next(
1107 IEnumScript* iface,
1108 ULONG celt,
1109 PSCRIPTINFO rgelt,
1110 ULONG* pceltFetched)
1112 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1113 TRACE("%p %lu %p %p\n", This, celt, rgelt, pceltFetched);
1115 if (!pceltFetched || !rgelt) return E_FAIL;
1117 *pceltFetched = 0;
1119 if (This->pos + celt > This->total)
1120 celt = This->total - This->pos;
1122 if (!celt) return S_FALSE;
1124 memcpy(rgelt, This->script_info + This->pos, celt * sizeof(SCRIPTINFO));
1125 *pceltFetched = celt;
1126 This->pos += celt;
1128 return S_OK;
1131 static HRESULT WINAPI fnIEnumScript_Reset(
1132 IEnumScript* iface)
1134 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1135 TRACE("%p\n", This);
1137 This->pos = 0;
1138 return S_OK;
1141 static HRESULT WINAPI fnIEnumScript_Skip(
1142 IEnumScript* iface,
1143 ULONG celt)
1145 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1146 TRACE("%p %lu\n", This, celt);
1148 if (celt >= This->total) return S_FALSE;
1150 This->pos = celt; /* FIXME: should be += ?? */
1151 return S_OK;
1154 static IEnumScriptVtbl IEnumScript_vtbl =
1156 fnIEnumScript_QueryInterface,
1157 fnIEnumScript_AddRef,
1158 fnIEnumScript_Release,
1159 fnIEnumScript_Clone,
1160 fnIEnumScript_Next,
1161 fnIEnumScript_Reset,
1162 fnIEnumScript_Skip
1165 static HRESULT EnumScript_create( MLang_impl* mlang, DWORD dwFlags,
1166 LANGID LangId, IEnumScript** ppEnumScript )
1168 EnumScript_impl *es;
1169 UINT i;
1171 TRACE("%p, %08lx, %04x, %p: stub!\n", mlang, dwFlags, LangId, ppEnumScript);
1173 if (!dwFlags) /* enumerate all available scripts */
1174 dwFlags = SCRIPTCONTF_SCRIPT_USER | SCRIPTCONTF_SCRIPT_HIDE | SCRIPTCONTF_SCRIPT_SYSTEM;
1176 es = HeapAlloc( GetProcessHeap(), 0, sizeof (EnumScript_impl) );
1177 es->vtbl_IEnumScript = &IEnumScript_vtbl;
1178 es->ref = 1;
1179 es->pos = 0;
1180 /* do not enumerate unicode flavours */
1181 es->total = sizeof(mlang_data)/sizeof(mlang_data[0]) - 1;
1182 es->script_info = HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPTINFO) * es->total);
1184 for (i = 0; i < es->total; i++)
1186 es->script_info[i].ScriptId = i;
1187 es->script_info[i].uiCodePage = mlang_data[i].family_codepage;
1188 MultiByteToWideChar(CP_ACP, 0, mlang_data[i].description, -1,
1189 es->script_info[i].wszDescription, MAX_SCRIPT_NAME);
1190 MultiByteToWideChar(CP_ACP, 0, mlang_data[i].fixed_font, -1,
1191 es->script_info[i].wszFixedWidthFont, MAX_MIMEFACE_NAME);
1192 MultiByteToWideChar(CP_ACP, 0, mlang_data[i].proportional_font, -1,
1193 es->script_info[i].wszProportionalFont, MAX_MIMEFACE_NAME);
1196 TRACE("enumerated %ld scripts with flags %08lx\n", es->total, dwFlags);
1198 *ppEnumScript = (IEnumScript *)es;
1200 return S_OK;
1203 /******************************************************************************/
1205 static HRESULT WINAPI fnIMLangFontLink_QueryInterface(
1206 IMLangFontLink* iface,
1207 REFIID riid,
1208 void** ppvObject)
1210 ICOM_THIS_MULTI(MLang_impl, vtbl_IMLangFontLink, iface);
1211 return MLang_QueryInterface( This, riid, ppvObject );
1214 static ULONG WINAPI fnIMLangFontLink_AddRef(
1215 IMLangFontLink* iface)
1217 ICOM_THIS_MULTI(MLang_impl, vtbl_IMLangFontLink, iface);
1218 return MLang_AddRef( This );
1221 static ULONG WINAPI fnIMLangFontLink_Release(
1222 IMLangFontLink* iface)
1224 ICOM_THIS_MULTI(MLang_impl, vtbl_IMLangFontLink, iface);
1225 return MLang_Release( This );
1228 static HRESULT WINAPI fnIMLangFontLink_GetCharCodePages(
1229 IMLangFontLink* iface,
1230 WCHAR chSrc,
1231 DWORD* pdwCodePages)
1233 FIXME("\n");
1234 return E_NOTIMPL;
1237 static HRESULT WINAPI fnIMLangFontLink_GetStrCodePages(
1238 IMLangFontLink* iface,
1239 const WCHAR* pszSrc,
1240 long cchSrc,
1241 DWORD dwPriorityCodePages,
1242 DWORD* pdwCodePages,
1243 long* pcchCodePages)
1245 FIXME("\n");
1246 return E_NOTIMPL;
1249 static HRESULT WINAPI fnIMLangFontLink_CodePageToCodePages(
1250 IMLangFontLink* iface,
1251 UINT uCodePage,
1252 DWORD* pdwCodePages)
1254 FIXME("\n");
1255 return E_NOTIMPL;
1258 static HRESULT WINAPI fnIMLangFontLink_CodePagesToCodePage(
1259 IMLangFontLink* iface,
1260 DWORD dwCodePages,
1261 UINT uDefaultCodePage,
1262 UINT* puCodePage)
1264 FIXME("\n");
1265 return E_NOTIMPL;
1268 static HRESULT WINAPI fnIMLangFontLink_GetFontCodePages(
1269 IMLangFontLink* iface,
1270 HDC hDC,
1271 HFONT hFont,
1272 DWORD* pdwCodePages)
1274 FIXME("\n");
1275 return E_NOTIMPL;
1278 static HRESULT WINAPI fnIMLangFontLink_MapFont(
1279 IMLangFontLink* iface,
1280 HDC hDC,
1281 DWORD dwCodePages,
1282 HFONT hSrcFont,
1283 HFONT* phDestFont)
1285 FIXME("\n");
1286 return E_NOTIMPL;
1289 static HRESULT WINAPI fnIMLangFontLink_ReleaseFont(
1290 IMLangFontLink* iface,
1291 HFONT hFont)
1293 FIXME("\n");
1294 return E_NOTIMPL;
1297 static HRESULT WINAPI fnIMLangFontLink_ResetFontMapping(
1298 IMLangFontLink* iface)
1300 FIXME("\n");
1301 return E_NOTIMPL;
1305 static IMLangFontLinkVtbl IMLangFontLink_vtbl =
1307 fnIMLangFontLink_QueryInterface,
1308 fnIMLangFontLink_AddRef,
1309 fnIMLangFontLink_Release,
1310 fnIMLangFontLink_GetCharCodePages,
1311 fnIMLangFontLink_GetStrCodePages,
1312 fnIMLangFontLink_CodePageToCodePages,
1313 fnIMLangFontLink_CodePagesToCodePage,
1314 fnIMLangFontLink_GetFontCodePages,
1315 fnIMLangFontLink_MapFont,
1316 fnIMLangFontLink_ReleaseFont,
1317 fnIMLangFontLink_ResetFontMapping,
1320 /******************************************************************************/
1322 static HRESULT WINAPI fnIMultiLanguage_QueryInterface(
1323 IMultiLanguage* iface,
1324 REFIID riid,
1325 void** ppvObject)
1327 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
1328 return MLang_QueryInterface( This, riid, ppvObject );
1331 static ULONG WINAPI fnIMultiLanguage_AddRef( IMultiLanguage* iface )
1333 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
1334 return IMLangFontLink_AddRef( ((IMLangFontLink*)This) );
1337 static ULONG WINAPI fnIMultiLanguage_Release( IMultiLanguage* iface )
1339 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
1340 return IMLangFontLink_Release( ((IMLangFontLink*)This) );
1343 static HRESULT WINAPI fnIMultiLanguage_GetNumberOfCodePageInfo(
1344 IMultiLanguage* iface,
1345 UINT* pcCodePage)
1347 FIXME("\n");
1348 return E_NOTIMPL;
1351 static HRESULT WINAPI fnIMultiLanguage_GetCodePageInfo(
1352 IMultiLanguage* iface,
1353 UINT uiCodePage,
1354 PMIMECPINFO pCodePageInfo)
1356 FIXME("\n");
1357 return E_NOTIMPL;
1360 static HRESULT WINAPI fnIMultiLanguage_GetFamilyCodePage(
1361 IMultiLanguage* iface,
1362 UINT uiCodePage,
1363 UINT* puiFamilyCodePage)
1365 return GetFamilyCodePage(uiCodePage, puiFamilyCodePage);
1368 static HRESULT WINAPI fnIMultiLanguage_EnumCodePages(
1369 IMultiLanguage* iface,
1370 DWORD grfFlags,
1371 IEnumCodePage** ppEnumCodePage)
1373 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
1374 TRACE("%p %08lx %p\n", This, grfFlags, ppEnumCodePage);
1376 return EnumCodePage_create( This, grfFlags, 0, ppEnumCodePage );
1379 static HRESULT WINAPI fnIMultiLanguage_GetCharsetInfo(
1380 IMultiLanguage* iface,
1381 BSTR Charset,
1382 PMIMECSETINFO pCharsetInfo)
1384 FIXME("\n");
1385 return E_NOTIMPL;
1388 static HRESULT WINAPI fnIMultiLanguage_IsConvertible(
1389 IMultiLanguage* iface,
1390 DWORD dwSrcEncoding,
1391 DWORD dwDstEncoding)
1393 return IsConvertINetStringAvailable(dwSrcEncoding, dwDstEncoding);
1396 static HRESULT WINAPI fnIMultiLanguage_ConvertString(
1397 IMultiLanguage* iface,
1398 DWORD* pdwMode,
1399 DWORD dwSrcEncoding,
1400 DWORD dwDstEncoding,
1401 BYTE* pSrcStr,
1402 UINT* pcSrcSize,
1403 BYTE* pDstStr,
1404 UINT* pcDstSize)
1406 return ConvertINetString(pdwMode, dwSrcEncoding, dwDstEncoding,
1407 pSrcStr, pcSrcSize, pDstStr, pcDstSize);
1410 static HRESULT WINAPI fnIMultiLanguage_ConvertStringToUnicode(
1411 IMultiLanguage* iface,
1412 DWORD* pdwMode,
1413 DWORD dwEncoding,
1414 CHAR* pSrcStr,
1415 UINT* pcSrcSize,
1416 WCHAR* pDstStr,
1417 UINT* pcDstSize)
1419 return ConvertINetMultiByteToUnicode(pdwMode, dwEncoding,
1420 pSrcStr, pcSrcSize, pDstStr, pcDstSize);
1423 static HRESULT WINAPI fnIMultiLanguage_ConvertStringFromUnicode(
1424 IMultiLanguage* iface,
1425 DWORD* pdwMode,
1426 DWORD dwEncoding,
1427 WCHAR* pSrcStr,
1428 UINT* pcSrcSize,
1429 CHAR* pDstStr,
1430 UINT* pcDstSize)
1432 return ConvertINetUnicodeToMultiByte(pdwMode, dwEncoding,
1433 pSrcStr, pcSrcSize, pDstStr, pcDstSize);
1436 static HRESULT WINAPI fnIMultiLanguage_ConvertStringReset(
1437 IMultiLanguage* iface)
1439 FIXME("\n");
1440 return E_NOTIMPL;
1443 static HRESULT WINAPI fnIMultiLanguage_GetRfc1766FromLcid(
1444 IMultiLanguage* iface,
1445 LCID Locale,
1446 BSTR* pbstrRfc1766)
1448 FIXME("\n");
1449 return E_NOTIMPL;
1452 static HRESULT WINAPI fnIMultiLanguage_GetLcidFromRfc1766(
1453 IMultiLanguage* iface,
1454 LCID* pLocale,
1455 BSTR bstrRfc1766)
1457 FIXME("\n");
1458 return E_NOTIMPL;
1461 static HRESULT WINAPI fnIMultiLanguage_EnumRfc1766(
1462 IMultiLanguage* iface,
1463 IEnumRfc1766** ppEnumRfc1766)
1465 FIXME("\n");
1466 return E_NOTIMPL;
1469 static HRESULT WINAPI fnIMultiLanguage_GetRfc1766Info(
1470 IMultiLanguage* iface,
1471 LCID Locale,
1472 PRFC1766INFO pRfc1766Info)
1474 FIXME("\n");
1475 return E_NOTIMPL;
1478 static HRESULT WINAPI fnIMultiLanguage_CreateConvertCharset(
1479 IMultiLanguage* iface,
1480 UINT uiSrcCodePage,
1481 UINT uiDstCodePage,
1482 DWORD dwProperty,
1483 IMLangConvertCharset** ppMLangConvertCharset)
1485 FIXME("\n");
1486 return E_NOTIMPL;
1489 static IMultiLanguageVtbl IMultiLanguage_vtbl =
1491 fnIMultiLanguage_QueryInterface,
1492 fnIMultiLanguage_AddRef,
1493 fnIMultiLanguage_Release,
1494 fnIMultiLanguage_GetNumberOfCodePageInfo,
1495 fnIMultiLanguage_GetCodePageInfo,
1496 fnIMultiLanguage_GetFamilyCodePage,
1497 fnIMultiLanguage_EnumCodePages,
1498 fnIMultiLanguage_GetCharsetInfo,
1499 fnIMultiLanguage_IsConvertible,
1500 fnIMultiLanguage_ConvertString,
1501 fnIMultiLanguage_ConvertStringToUnicode,
1502 fnIMultiLanguage_ConvertStringFromUnicode,
1503 fnIMultiLanguage_ConvertStringReset,
1504 fnIMultiLanguage_GetRfc1766FromLcid,
1505 fnIMultiLanguage_GetLcidFromRfc1766,
1506 fnIMultiLanguage_EnumRfc1766,
1507 fnIMultiLanguage_GetRfc1766Info,
1508 fnIMultiLanguage_CreateConvertCharset,
1512 /******************************************************************************/
1514 static HRESULT WINAPI fnIMultiLanguage2_QueryInterface(
1515 IMultiLanguage2* iface,
1516 REFIID riid,
1517 void** ppvObject)
1519 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1520 return MLang_QueryInterface( This, riid, ppvObject );
1523 static ULONG WINAPI fnIMultiLanguage2_AddRef( IMultiLanguage2* iface )
1525 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1526 return MLang_AddRef( This );
1529 static ULONG WINAPI fnIMultiLanguage2_Release( IMultiLanguage2* iface )
1531 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1532 return MLang_Release( This );
1535 static HRESULT WINAPI fnIMultiLanguage2_GetNumberOfCodePageInfo(
1536 IMultiLanguage2* iface,
1537 UINT* pcCodePage)
1539 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1540 TRACE("%p, %p\n", This, pcCodePage);
1542 if (!pcCodePage) return S_FALSE;
1544 *pcCodePage = This->total_cp;
1545 return S_OK;
1548 static void fill_cp_info(const struct mlang_data *ml_data, UINT index, MIMECPINFO *mime_cp_info)
1550 CHARSETINFO csi;
1552 if (TranslateCharsetInfo((DWORD *)ml_data->family_codepage, &csi, TCI_SRCCODEPAGE))
1553 mime_cp_info->bGDICharset = csi.ciCharset;
1554 else
1555 mime_cp_info->bGDICharset = DEFAULT_CHARSET;
1557 mime_cp_info->dwFlags = ml_data->mime_cp_info[index].flags;
1558 mime_cp_info->uiCodePage = ml_data->mime_cp_info[index].cp;
1559 mime_cp_info->uiFamilyCodePage = ml_data->family_codepage;
1560 MultiByteToWideChar(CP_ACP, 0, ml_data->mime_cp_info[index].description, -1,
1561 mime_cp_info->wszDescription, sizeof(mime_cp_info->wszDescription)/sizeof(WCHAR));
1562 MultiByteToWideChar(CP_ACP, 0, ml_data->mime_cp_info[index].web_charset, -1,
1563 mime_cp_info->wszWebCharset, sizeof(mime_cp_info->wszWebCharset)/sizeof(WCHAR));
1564 MultiByteToWideChar(CP_ACP, 0, ml_data->mime_cp_info[index].header_charset, -1,
1565 mime_cp_info->wszHeaderCharset, sizeof(mime_cp_info->wszHeaderCharset)/sizeof(WCHAR));
1566 MultiByteToWideChar(CP_ACP, 0, ml_data->mime_cp_info[index].body_charset, -1,
1567 mime_cp_info->wszBodyCharset, sizeof(mime_cp_info->wszBodyCharset)/sizeof(WCHAR));
1569 MultiByteToWideChar(CP_ACP, 0, ml_data->fixed_font, -1,
1570 mime_cp_info->wszFixedWidthFont, sizeof(mime_cp_info->wszFixedWidthFont)/sizeof(WCHAR));
1571 MultiByteToWideChar(CP_ACP, 0, ml_data->proportional_font, -1,
1572 mime_cp_info->wszProportionalFont, sizeof(mime_cp_info->wszProportionalFont)/sizeof(WCHAR));
1574 TRACE("%08lx %u %u %s %s %s %s %s %s %d\n",
1575 mime_cp_info->dwFlags, mime_cp_info->uiCodePage,
1576 mime_cp_info->uiFamilyCodePage,
1577 wine_dbgstr_w(mime_cp_info->wszDescription),
1578 wine_dbgstr_w(mime_cp_info->wszWebCharset),
1579 wine_dbgstr_w(mime_cp_info->wszHeaderCharset),
1580 wine_dbgstr_w(mime_cp_info->wszBodyCharset),
1581 wine_dbgstr_w(mime_cp_info->wszFixedWidthFont),
1582 wine_dbgstr_w(mime_cp_info->wszProportionalFont),
1583 mime_cp_info->bGDICharset);
1586 static HRESULT WINAPI fnIMultiLanguage2_GetCodePageInfo(
1587 IMultiLanguage2* iface,
1588 UINT uiCodePage,
1589 LANGID LangId,
1590 PMIMECPINFO pCodePageInfo)
1592 UINT i, n;
1594 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1595 TRACE("%p, %u, %04x, %p\n", This, uiCodePage, LangId, pCodePageInfo);
1597 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1599 for (n = 0; n < mlang_data[i].number_of_cp; n++)
1601 if (mlang_data[i].mime_cp_info[n].cp == uiCodePage)
1603 fill_cp_info(&mlang_data[i], n, pCodePageInfo);
1604 return S_OK;
1609 return S_FALSE;
1612 static HRESULT WINAPI fnIMultiLanguage2_GetFamilyCodePage(
1613 IMultiLanguage2* iface,
1614 UINT uiCodePage,
1615 UINT* puiFamilyCodePage)
1617 return GetFamilyCodePage(uiCodePage, puiFamilyCodePage);
1620 static HRESULT WINAPI fnIMultiLanguage2_EnumCodePages(
1621 IMultiLanguage2* iface,
1622 DWORD grfFlags,
1623 LANGID LangId,
1624 IEnumCodePage** ppEnumCodePage)
1626 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1627 TRACE("%p %08lx %04x %p\n", This, grfFlags, LangId, ppEnumCodePage);
1629 return EnumCodePage_create( This, grfFlags, LangId, ppEnumCodePage );
1632 static HRESULT WINAPI fnIMultiLanguage2_GetCharsetInfo(
1633 IMultiLanguage2* iface,
1634 BSTR Charset,
1635 PMIMECSETINFO pCharsetInfo)
1637 UINT i, n;
1639 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1640 TRACE("%p %s %p\n", This, debugstr_w(Charset), pCharsetInfo);
1642 if (!pCharsetInfo) return E_FAIL;
1644 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1646 for (n = 0; n < mlang_data[i].number_of_cp; n++)
1648 WCHAR csetW[MAX_MIMECSET_NAME];
1650 MultiByteToWideChar(CP_ACP, 0, mlang_data[i].mime_cp_info[n].web_charset, -1, csetW, MAX_MIMECSET_NAME);
1651 if (!lstrcmpiW(Charset, csetW))
1653 pCharsetInfo->uiCodePage = mlang_data[i].family_codepage;
1654 pCharsetInfo->uiInternetEncoding = mlang_data[i].mime_cp_info[n].cp;
1655 strcpyW(pCharsetInfo->wszCharset, csetW);
1656 return S_OK;
1661 /* FIXME:
1662 * Since we do not support charsets like iso-2022-jp and do not have
1663 * them in our database as a primary (web_charset) encoding this loop
1664 * does an attempt to 'approximate' charset name by header_charset.
1666 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1668 for (n = 0; n < mlang_data[i].number_of_cp; n++)
1670 WCHAR csetW[MAX_MIMECSET_NAME];
1672 MultiByteToWideChar(CP_ACP, 0, mlang_data[i].mime_cp_info[n].header_charset, -1, csetW, MAX_MIMECSET_NAME);
1673 if (!lstrcmpiW(Charset, csetW))
1675 pCharsetInfo->uiCodePage = mlang_data[i].family_codepage;
1676 pCharsetInfo->uiInternetEncoding = mlang_data[i].mime_cp_info[n].cp;
1677 strcpyW(pCharsetInfo->wszCharset, csetW);
1678 return S_OK;
1683 return E_FAIL;
1686 static HRESULT WINAPI fnIMultiLanguage2_IsConvertible(
1687 IMultiLanguage2* iface,
1688 DWORD dwSrcEncoding,
1689 DWORD dwDstEncoding)
1691 return IsConvertINetStringAvailable(dwSrcEncoding, dwDstEncoding);
1694 static HRESULT WINAPI fnIMultiLanguage2_ConvertString(
1695 IMultiLanguage2* iface,
1696 DWORD* pdwMode,
1697 DWORD dwSrcEncoding,
1698 DWORD dwDstEncoding,
1699 BYTE* pSrcStr,
1700 UINT* pcSrcSize,
1701 BYTE* pDstStr,
1702 UINT* pcDstSize)
1704 return ConvertINetString(pdwMode, dwSrcEncoding, dwDstEncoding,
1705 pSrcStr, pcSrcSize, pDstStr, pcDstSize);
1708 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringToUnicode(
1709 IMultiLanguage2* iface,
1710 DWORD* pdwMode,
1711 DWORD dwEncoding,
1712 CHAR* pSrcStr,
1713 UINT* pcSrcSize,
1714 WCHAR* pDstStr,
1715 UINT* pcDstSize)
1717 return ConvertINetMultiByteToUnicode(pdwMode, dwEncoding,
1718 pSrcStr, pcSrcSize, pDstStr, pcDstSize);
1721 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringFromUnicode(
1722 IMultiLanguage2* iface,
1723 DWORD* pdwMode,
1724 DWORD dwEncoding,
1725 WCHAR* pSrcStr,
1726 UINT* pcSrcSize,
1727 CHAR* pDstStr,
1728 UINT* pcDstSize)
1730 return ConvertINetUnicodeToMultiByte(pdwMode, dwEncoding,
1731 pSrcStr, pcSrcSize, pDstStr, pcDstSize);
1734 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringReset(
1735 IMultiLanguage2* iface)
1737 FIXME("\n");
1738 return E_NOTIMPL;
1741 static HRESULT WINAPI fnIMultiLanguage2_GetRfc1766FromLcid(
1742 IMultiLanguage2* iface,
1743 LCID Locale,
1744 BSTR* pbstrRfc1766)
1746 FIXME("\n");
1747 return E_NOTIMPL;
1750 static HRESULT WINAPI fnIMultiLanguage2_GetLcidFromRfc1766(
1751 IMultiLanguage2* iface,
1752 LCID* pLocale,
1753 BSTR bstrRfc1766)
1755 FIXME("\n");
1756 return E_NOTIMPL;
1759 static HRESULT WINAPI fnIMultiLanguage2_EnumRfc1766(
1760 IMultiLanguage2* iface,
1761 LANGID LangId,
1762 IEnumRfc1766** ppEnumRfc1766)
1764 FIXME("\n");
1765 return E_NOTIMPL;
1768 static HRESULT WINAPI fnIMultiLanguage2_GetRfc1766Info(
1769 IMultiLanguage2* iface,
1770 LCID Locale,
1771 LANGID LangId,
1772 PRFC1766INFO pRfc1766Info)
1774 FIXME("\n");
1775 return E_NOTIMPL;
1778 static HRESULT WINAPI fnIMultiLanguage2_CreateConvertCharset(
1779 IMultiLanguage2* iface,
1780 UINT uiSrcCodePage,
1781 UINT uiDstCodePage,
1782 DWORD dwProperty,
1783 IMLangConvertCharset** ppMLangConvertCharset)
1785 FIXME("\n");
1786 return E_NOTIMPL;
1789 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringInIStream(
1790 IMultiLanguage2* iface,
1791 DWORD* pdwMode,
1792 DWORD dwFlag,
1793 WCHAR* lpFallBack,
1794 DWORD dwSrcEncoding,
1795 DWORD dwDstEncoding,
1796 IStream* pstmIn,
1797 IStream* pstmOut)
1799 FIXME("\n");
1800 return E_NOTIMPL;
1803 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringToUnicodeEx(
1804 IMultiLanguage2* iface,
1805 DWORD* pdwMode,
1806 DWORD dwEncoding,
1807 CHAR* pSrcStr,
1808 UINT* pcSrcSize,
1809 WCHAR* pDstStr,
1810 UINT* pcDstSize,
1811 DWORD dwFlag,
1812 WCHAR* lpFallBack)
1814 FIXME("\n");
1815 return E_NOTIMPL;
1818 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringFromUnicodeEx(
1819 IMultiLanguage2* This,
1820 DWORD* pdwMode,
1821 DWORD dwEncoding,
1822 WCHAR* pSrcStr,
1823 UINT* pcSrcSize,
1824 CHAR* pDstStr,
1825 UINT* pcDstSize,
1826 DWORD dwFlag,
1827 WCHAR* lpFallBack)
1829 FIXME("\n");
1830 return E_NOTIMPL;
1833 static HRESULT WINAPI fnIMultiLanguage2_DetectCodepageInIStream(
1834 IMultiLanguage2* iface,
1835 DWORD dwFlag,
1836 DWORD dwPrefWinCodePage,
1837 IStream* pstmIn,
1838 DetectEncodingInfo* lpEncoding,
1839 INT* pnScores)
1841 FIXME("\n");
1842 return E_NOTIMPL;
1845 static HRESULT WINAPI fnIMultiLanguage2_DetectInputCodepage(
1846 IMultiLanguage2* iface,
1847 DWORD dwFlag,
1848 DWORD dwPrefWinCodePage,
1849 CHAR* pSrcStr,
1850 INT* pcSrcSize,
1851 DetectEncodingInfo* lpEncoding,
1852 INT* pnScores)
1854 FIXME("\n");
1855 return E_NOTIMPL;
1858 static HRESULT WINAPI fnIMultiLanguage2_ValidateCodePage(
1859 IMultiLanguage2* iface,
1860 UINT uiCodePage,
1861 HWND hwnd)
1863 FIXME("\n");
1864 return E_NOTIMPL;
1867 static HRESULT WINAPI fnIMultiLanguage2_GetCodePageDescription(
1868 IMultiLanguage2* iface,
1869 UINT uiCodePage,
1870 LCID lcid,
1871 LPWSTR lpWideCharStr,
1872 int cchWideChar)
1874 FIXME("\n");
1875 return E_NOTIMPL;
1878 static HRESULT WINAPI fnIMultiLanguage2_IsCodePageInstallable(
1879 IMultiLanguage2* iface,
1880 UINT uiCodePage)
1882 FIXME("\n");
1883 return E_NOTIMPL;
1886 static HRESULT WINAPI fnIMultiLanguage2_SetMimeDBSource(
1887 IMultiLanguage2* iface,
1888 MIMECONTF dwSource)
1890 FIXME("\n");
1891 return E_NOTIMPL;
1894 static HRESULT WINAPI fnIMultiLanguage2_GetNumberOfScripts(
1895 IMultiLanguage2* iface,
1896 UINT* pnScripts)
1898 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1899 TRACE("%p %p\n", This, pnScripts);
1901 if (!pnScripts) return S_FALSE;
1903 *pnScripts = This->total_scripts;
1904 return S_OK;
1907 static HRESULT WINAPI fnIMultiLanguage2_EnumScripts(
1908 IMultiLanguage2* iface,
1909 DWORD dwFlags,
1910 LANGID LangId,
1911 IEnumScript** ppEnumScript)
1913 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1914 TRACE("%p %08lx %04x %p\n", This, dwFlags, LangId, ppEnumScript);
1916 return EnumScript_create( This, dwFlags, LangId, ppEnumScript );
1919 static HRESULT WINAPI fnIMultiLanguage2_ValidateCodePageEx(
1920 IMultiLanguage2* iface,
1921 UINT uiCodePage,
1922 HWND hwnd,
1923 DWORD dwfIODControl)
1925 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1926 FIXME("%p %u %p %08lx: stub!\n", This, uiCodePage, hwnd, dwfIODControl);
1928 return S_FALSE;
1931 static IMultiLanguage2Vtbl IMultiLanguage2_vtbl =
1933 fnIMultiLanguage2_QueryInterface,
1934 fnIMultiLanguage2_AddRef,
1935 fnIMultiLanguage2_Release,
1936 fnIMultiLanguage2_GetNumberOfCodePageInfo,
1937 fnIMultiLanguage2_GetCodePageInfo,
1938 fnIMultiLanguage2_GetFamilyCodePage,
1939 fnIMultiLanguage2_EnumCodePages,
1940 fnIMultiLanguage2_GetCharsetInfo,
1941 fnIMultiLanguage2_IsConvertible,
1942 fnIMultiLanguage2_ConvertString,
1943 fnIMultiLanguage2_ConvertStringToUnicode,
1944 fnIMultiLanguage2_ConvertStringFromUnicode,
1945 fnIMultiLanguage2_ConvertStringReset,
1946 fnIMultiLanguage2_GetRfc1766FromLcid,
1947 fnIMultiLanguage2_GetLcidFromRfc1766,
1948 fnIMultiLanguage2_EnumRfc1766,
1949 fnIMultiLanguage2_GetRfc1766Info,
1950 fnIMultiLanguage2_CreateConvertCharset,
1951 fnIMultiLanguage2_ConvertStringInIStream,
1952 fnIMultiLanguage2_ConvertStringToUnicodeEx,
1953 fnIMultiLanguage2_ConvertStringFromUnicodeEx,
1954 fnIMultiLanguage2_DetectCodepageInIStream,
1955 fnIMultiLanguage2_DetectInputCodepage,
1956 fnIMultiLanguage2_ValidateCodePage,
1957 fnIMultiLanguage2_GetCodePageDescription,
1958 fnIMultiLanguage2_IsCodePageInstallable,
1959 fnIMultiLanguage2_SetMimeDBSource,
1960 fnIMultiLanguage2_GetNumberOfScripts,
1961 fnIMultiLanguage2_EnumScripts,
1962 fnIMultiLanguage2_ValidateCodePageEx,
1965 static HRESULT MultiLanguage_create(IUnknown *pUnkOuter, LPVOID *ppObj)
1967 MLang_impl *mlang;
1968 UINT i;
1970 TRACE("Creating MultiLanguage object\n");
1972 if( pUnkOuter )
1973 return CLASS_E_NOAGGREGATION;
1975 mlang = HeapAlloc( GetProcessHeap(), 0, sizeof (MLang_impl) );
1976 mlang->vtbl_IMLangFontLink = &IMLangFontLink_vtbl;
1977 mlang->vtbl_IMultiLanguage = &IMultiLanguage_vtbl;
1978 mlang->vtbl_IMultiLanguage2 = &IMultiLanguage2_vtbl;
1980 mlang->total_cp = 0;
1981 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1982 mlang->total_cp += mlang_data[i].number_of_cp;
1984 /* do not enumerate unicode flavours */
1985 mlang->total_scripts = sizeof(mlang_data)/sizeof(mlang_data[0]) - 1;
1987 mlang->ref = 1;
1988 *ppObj = (LPVOID) mlang;
1989 TRACE("returning %p\n", mlang);
1990 return S_OK;
1993 /******************************************************************************/
1995 HRESULT WINAPI MLANG_DllCanUnloadNow(void)
1997 FIXME("\n");
1998 return S_FALSE;