Update of /cvsroot/mahogany/M/src/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3693/src/gui
Modified Files:
wxComposeView.cpp
Log Message:
do the conversion to ensure that the message is sent in the encoding specified
by the user in the language menu (if possible)
Index: wxComposeView.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxComposeView.cpp,v
retrieving revision 1.377
retrieving revision 1.378
diff -b -u -2 -r1.377 -r1.378
--- wxComposeView.cpp 15 Nov 2004 23:47:21 -0000 1.377
+++ wxComposeView.cpp 16 Nov 2004 00:12:35 -0000 1.378
@@ -70,4 +70,6 @@
#include <wx/tokenzr.h>
#include <wx/textbuf.h>
+#include <wx/encconv.h>
+#include <wx/fontmap.h>
#include <wx/fontutil.h> // for wxNativeFontInfo
// windows.h included from wx/fontutil.h under Windows #defines this
@@ -147,4 +149,5 @@
extern const MPersMsgBox *M_MSGBOX_SEND_EMPTY_SUBJECT;
extern const MPersMsgBox *M_MSGBOX_ASK_SAVE_HEADERS;
+extern const MPersMsgBox *M_MSGBOX_SEND_DIFF_ENCODING;
// ----------------------------------------------------------------------------
@@ -3923,4 +3926,6 @@
// ----------------
+ wxFontEncoding encodingMsg = m_encoding;
+
for ( EditorContentPart *part = m_editor->GetFirstPart();
part;
@@ -3930,7 +3935,61 @@
{
case EditorContentPart::Type_Text:
+ {
+ // the part may be written either in the same encoding as chosen
+ // in the "Language" menu or in a different -- but hopefully
+ // compatible -- one, in which case we need to translate it
+ wxString textConv;
+ const wxString *text wxDUMMY_INITIALIZE(NULL);
+
+ wxFontEncoding encodingPart = part->GetEncoding();
+ if ( encodingMsg != wxFONTENCODING_SYSTEM &&
+ encodingPart != encodingMsg )
+ {
+ wxEncodingConverter conv;
+ if ( !conv.Init(encodingPart, encodingMsg) )
+ {
+ if ( !MDialog_YesNoDialog
+ (
+ wxString::Format
+ (
+ _("Text of this message can't be converted to
"
+ "the encoding \"%s\", would you like to "
+ "send it in encoding \"%s\" instead?"),
+ wxFontMapper::GetEncodingName(encodingMsg),
+ wxFontMapper::GetEncodingName(encodingPart)
+ ),
+ this,
+ MDIALOG_YESNOTITLE,
+ M_DLG_YES_DEFAULT,
+ M_MSGBOX_SEND_DIFF_ENCODING
+ ) )
+ {
+ // send aborted
+ part->DecRef();
+ return NULL;
+ }
+
+ // FIXME: this doesn't work if we have 2 text parts in
+ // different encodings, we should use UTF8 in this
+ // case but for this we must do a preliminary
+ // iteration over all text parts
+ encodingMsg = encodingPart;
+ }
+ else // can convert, do it
+ {
+ textConv = conv.Convert(part->GetText());
+ text = &textConv;
+ }
+ }
+ else // use the encoding as is
+ {
+ encodingMsg = encodingPart;
+
+ text = &part->GetText();
+ }
+
msg->AddPart(
MimeType::TEXT,
- part->GetText(),
+ *text,
part->GetLength(),
_T("PLAIN"),
@@ -3938,6 +3997,7 @@
NULL, // disposition parameters
NULL, // other parameters
- part->GetEncoding()
+ encodingMsg
);
+ }
break;
@@ -4055,7 +4115,7 @@
// -----------------
- if ( m_encoding != wxFONTENCODING_DEFAULT )
+ if ( encodingMsg != wxFONTENCODING_DEFAULT )
{
- msg->SetHeaderEncoding(m_encoding);
+ msg->SetHeaderEncoding(encodingMsg);
}
-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates