Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F36624310
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
8 KB
Subscribers
None
View Options
diff --git a/src/Makefile.am b/src/Makefile.am
index 2010722..457c7b3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,124 +1,125 @@
# Makefile.am - main makefile for dialogs part of GPGol
# Copyright (C) 2005 g10 Code GmbH
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
## Process this file with automake to produce Makefile.in
unused_sources = item-events.cpp
bin_PROGRAMS = gpgol
#treeview
EXTRA_DIST = \
versioninfo.rc.in mapi32.def $(unused_sources) Outlook.gpl \
encrypt-16.bmp encrypt-16m.bmp \
sign-16.bmp sign-16m.bmp \
key-manager-16.bmp key-manager-16m.bmp \
decrypt-16.bmp decrypt-16m.bmp \
verify-16.bmp verify-16m.bmp \
decrypt-verify-16.bmp decrypt-verify-16m.bmp \
encrypt-16.png encrypt-48.png \
key-manager-64.png \
decrypt-16.png decrypt-48.png \
encrypt-sign-file-48.png \
sign-48.png verify-48.png \
dialogs.rc README.icons
EXEEXT = .dll
AM_CFLAGS = $(GPGME_CFLAGS) $(LIBASSUAN_CFLAGS) -shared
AM_CXXFLAGS = $(GPGME_CFLAGS) $(LIBASSUAN_CFLAGS) -shared
gpgol_SOURCES = \
main.c gpgol.def \
resource.rc \
gpgol-ids.h \
olflange.cpp olflange.h \
olflange-def.h \
olflange-dlgs.cpp \
dialogs.h \
myexchext.h \
display.cpp display.h \
message.cpp message.h \
revert.cpp revert.h \
mimeparser.c mimeparser.h \
mimemaker.c mimemaker.h \
msgcache.c msgcache.h \
engine.c engine.h \
engine-assuan.c engine-assuan.h \
rfc822parse.c rfc822parse.h \
common.h common.c util.h \
xmalloc.h \
config-dialog.c \
mapihelp.cpp mapihelp.h \
mymapi.h mymapitags.h \
serpent.c serpent.h \
ext-commands.cpp ext-commands.h \
user-events.cpp user-events.h \
session-events.cpp session-events.h \
message-events.cpp message-events.h \
attached-file-events.cpp attached-file-events.h \
property-sheets.cpp property-sheets.h \
item-events.h \
oomhelp.cpp oomhelp.h eventsink.h \
explorers.cpp explorers.h \
inspectors.cpp inspectors.h \
mailitem.cpp mailitem.h \
cmdbarcontrols.cpp cmdbarcontrols.h \
w32-gettext.c w32-gettext.h \
gpgoladdin.cpp gpgoladdin.h \
ribbon-callbacks.cpp ribbon-callbacks.h \
parsetlv.c parsetlv.h \
filetype.c filetype.h \
eventsinks.h application-events.cpp \
mailitem-events.cpp \
attachment.h attachment.cpp \
windowmessages.h windowmessages.cpp \
gpgolstr.h gpgolstr.cpp \
mail.h mail.cpp \
- rfc2047parse.h rfc2047parse.c
+ rfc2047parse.h rfc2047parse.c \
+ mlang-charset.cpp mlang-charset.h
#treeview_SOURCES = treeview.c
# W32API 3.2 comes with an unusable libmapi32.a. We build our own
# version. Note the omission of -k (--kill-at) from the DLLTOOL
# command line. We also create our own virtual copies to the _static_
# versions of GPGME and gpg-error, because we want to link to them
# statically, and not dynamically (otherwise Outlook would not find
# them).
gpgol_DEPENDENCIES = libmapi32.a libgpg-error.a libgpgme.a libassuan.a
libmapi32.a: mapi32.def
$(DLLTOOL) --output-lib $@ --def $<
libgpg-error.a:
ln -s $$($(GPG_ERROR_CONFIG) --prefix)/lib/libgpg-error.a .
libgpgme.a:
ln -s $$($(GPGME_CONFIG) --prefix)/lib/libgpgme.a .
libassuan.a:
ln -s $$($(LIBASSUAN_CONFIG) --prefix)/lib/libassuan.a .
clean-local:
rm -f libmapi32.a libgpg-error.a libgpgme.a libassuan.a
gpgol_LDFLAGS = -static-libgcc -static-libstdc++
gpgol_LDADD = $(srcdir)/gpgol.def \
-L . -lgpgme -lassuan -lgpg-error \
-lmapi32 -lshell32 -lgdi32 -lcomdlg32 \
-lole32 -loleaut32 -lws2_32 -ladvapi32 \
-luuid -lgdiplus
resource.o: resource.rc versioninfo.rc dialogs.rc dialogs.h
.rc.o:
$(WINDRES) -I $(srcdir) -I . `test -f '$<' || echo '$(srcdir)/'`$< $@
diff --git a/src/mlang-charset.cpp b/src/mlang-charset.cpp
new file mode 100644
index 0000000..221f57f
--- /dev/null
+++ b/src/mlang-charset.cpp
@@ -0,0 +1,98 @@
+/* @file mlang-charset.cpp
+ * @brief Convert between charsets using Mlang
+ *
+ * Copyright (C) 2015 Intevation GmbH
+ *
+ * This file is part of GpgOL.
+ *
+ * GpgOL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * GpgOL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "util.h"
+#define INITGUID
+#include <initguid.h>
+DEFINE_GUID (IID_IMultiLanguage, 0x275c23e1,0x3747,0x11d0,0x9f,
+ 0xea,0x00,0xaa,0x00,0x3f,0x86,0x46);
+#include <mlang.h>
+#undef INITGUID
+
+#include "mlang-charset.h"
+
+char *ansi_charset_to_utf8 (const char *charset, char *input,
+ size_t inlen)
+{
+ LPMULTILANGUAGE multilang = NULL;
+ MIMECSETINFO mime_info;
+ HRESULT err;
+ DWORD enc;
+ DWORD mode = 0;
+ unsigned int wlen = 0;
+ wchar_t *buf;
+ char *ret;
+
+ CoCreateInstance(CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
+ IID_IMultiLanguage, (void**)&multilang);
+
+ if (!multilang)
+ {
+ log_error ("%s:%s: Failed to get multilang obj.",
+ SRCNAME, __func__);
+ return NULL;
+ }
+
+
+ mime_info.uiCodePage = 0;
+ mime_info.uiInternetEncoding = 0;
+ BSTR w_charset = utf8_to_wchar (charset);
+ err = multilang->GetCharsetInfo (w_charset, &mime_info);
+ xfree (w_charset);
+ if (err != S_OK)
+ {
+ log_error ("%s:%s: Failed to find charset for: %s",
+ SRCNAME, __func__, charset);
+ multilang->Release ();
+ return NULL;
+ }
+ enc = (mime_info.uiInternetEncoding == 0) ? mime_info.uiCodePage :
+ mime_info.uiInternetEncoding;
+
+ /** Get the size of the result */
+ err = multilang->ConvertStringToUnicode(&mode, enc, input,
+ &inlen, NULL, &wlen);
+ if (FAILED (err))
+ {
+ log_error ("%s:%s: Failed conversion.",
+ SRCNAME, __func__);
+ multilang->Release ();
+ return NULL;
+ }
+ buf = (wchar_t*) xmalloc(sizeof(wchar_t) * (wlen + 1));
+
+ err = multilang->ConvertStringToUnicode(&mode, enc, input, &inlen,
+ buf, &wlen);
+ multilang->Release ();
+ if (FAILED (err))
+ {
+ log_error ("%s:%s: Failed conversion 2.",
+ SRCNAME, __func__);
+ xfree (buf);
+ return NULL;
+ }
+ /* Doc is not clear if this is terminated. */
+ buf[wlen] = L'\0';
+
+ ret = wchar_to_utf8 (buf);
+ xfree (buf);
+ return ret;
+}
diff --git a/src/mlang-charset.h b/src/mlang-charset.h
new file mode 100644
index 0000000..3c55fd3
--- /dev/null
+++ b/src/mlang-charset.h
@@ -0,0 +1,43 @@
+/* @file mlang-charset.h
+ * @brief Convert between charsets using Mlang
+ *
+ * Copyright (C) 2015 Intevation GmbH
+ *
+ * This file is part of GpgOL.
+ *
+ * GpgOL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * GpgOL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "util.h"
+#ifdef __cplusplus
+extern "C" {
+#if 0
+}
+#endif
+#endif
+
+/** @brief convert input to utf8.
+ *
+ * @param charset: ANSI name of the charset to decode.
+ * @param input: The input to convert.
+ * @param inlen: The size of the input.
+ *
+ * @returns NULL on error or an UTF-8 encoded NULL terminated string.
+ */
+
+char *ansi_charset_to_utf8 (const char *charset, char *input,
+ size_t inlen);
+#ifdef __cplusplus
+}
+#endif
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Feb 26, 7:18 PM (15 h, 30 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
2e/af/e59ab28b703a8af6b39454c916b0
Attached To
rO GpgOL
Event Timeline
Log In to Comment