Revision: 7334
http://mahogany.svn.sourceforge.net/mahogany/?rev=7334&view=rev
Author: vadz
Date: 2007-08-24 11:27:43 -0700 (Fri, 24 Aug 2007)
Log Message:
-----------
don't use encoding hacks in Unicode build, they're at best useless and
potentially harmful
Modified Paths:
--------------
trunk/M/include/MessageView.h
trunk/M/include/guidef.h
trunk/M/include/strutil.h
trunk/M/src/classes/MessageView.cpp
trunk/M/src/gui/wxComposeView.cpp
trunk/M/src/gui/wxFolderView.cpp
trunk/M/src/gui/wxMGuiUtils.cpp
trunk/M/src/modules/BareBonesEditor.cpp
trunk/M/src/util/strutil.cpp
Modified: trunk/M/include/MessageView.h
===================================================================
--- trunk/M/include/MessageView.h 2007-08-22 21:14:48 UTC (rev 7333)
+++ trunk/M/include/MessageView.h 2007-08-24 18:27:43 UTC (rev 7334)
@@ -696,10 +696,12 @@
/// reset the encoding to the default value
void ResetUserEncoding();
- /// the encoding specified by the user or wxFONTENCODING_SYSTEM if none
+ /// the encoding specified by the user or wxFONTENCODING_DEFAULT if none
+ /// (this one is never equal to wxFONTENCODING_SYSTEM)
wxFontEncoding m_encodingUser;
- /// the auto detected encoding for the current message so far
+ /// the auto detected encoding for the current message so far or
+ /// wxFONTENCODING_SYSTEM if we don't know yet
wxFontEncoding m_encodingAuto;
//@}
Modified: trunk/M/include/guidef.h
===================================================================
--- trunk/M/include/guidef.h 2007-08-22 21:14:48 UTC (rev 7333)
+++ trunk/M/include/guidef.h 2007-08-24 18:27:43 UTC (rev 7334)
@@ -60,6 +60,8 @@
return GET_PARENT_OF_CLASS(win, wxFrame);
}
+#if !wxUSE_UNICODE
+
/**
Check if the given font encoding is available on this system. If not, try to
find a replacement encoding - if this succeeds, the text is translated into
@@ -73,6 +75,8 @@
wxString *text = NULL,
bool mayAskUser = false);
+#endif // !wxUSE_UNICODE
+
/**
Create a font from the given native font description or font family and
size.
Modified: trunk/M/include/strutil.h
===================================================================
--- trunk/M/include/strutil.h 2007-08-22 21:14:48 UTC (rev 7333)
+++ trunk/M/include/strutil.h 2007-08-24 18:27:43 UTC (rev 7334)
@@ -335,6 +335,8 @@
*/
extern wxFontEncoding GuessUnicodeCharset(const wchar_t *pwz);
+#if !wxUSE_UNICODE
+
/**
Try to convert text in UTF-8 or 7 to a multibyte encoding.
@@ -353,6 +355,8 @@
*/
extern wxFontEncoding ConvertUTFToMB(wxString *str, wxFontEncoding utfEnc);
+#endif // !wxUSE_UNICODE
+
// return the length of the line terminator if we're at the end of line or 0
// otherwise
extern size_t IsEndOfLine(const wxChar *p);
Modified: trunk/M/src/classes/MessageView.cpp
===================================================================
--- trunk/M/src/classes/MessageView.cpp 2007-08-22 21:14:48 UTC (rev 7333)
+++ trunk/M/src/classes/MessageView.cpp 2007-08-24 18:27:43 UTC (rev 7334)
@@ -1204,12 +1204,13 @@
m_viewer->ShowHeaderName(name);
String value(valueOrig);
- wxFontEncoding encReal = encHeader;
+#if !wxUSE_UNICODE
if ( encHeader != wxFONTENCODING_SYSTEM )
{
// convert the string to an encoding we can show, if needed
- EnsureAvailableTextEncoding(&encReal, &value);
+ EnsureAvailableTextEncoding(&encHeader, &value);
}
+#endif // !wxUSE_UNICODE
// don't highlight URLs in headers which contain message IDs or other things
// which look just like the URLs but, in fact, are not ones
@@ -1290,9 +1291,9 @@
// do this even if "before" is empty if we have to change the
// encoding (it will affect the URL following it)
- if ( !before.empty() || encReal != wxFONTENCODING_SYSTEM )
+ if ( !before.empty() || encHeader != wxFONTENCODING_SYSTEM )
{
- m_viewer->ShowHeaderValue(before, encReal);
+ m_viewer->ShowHeaderValue(before, encHeader);
}
if ( !url.empty() )
@@ -1315,14 +1316,18 @@
{
HeaderIterator headers(m_mailMessage->GetHeader());
+ const wxFontEncoding encHeaders = m_encodingUser ==
wxFONTENCODING_DEFAULT
+ ? wxFONTENCODING_SYSTEM
+ : m_encodingUser;
+
String name,
value;
while ( headers.GetNext(&name, &value, HeaderIterator::MultiLineOk) )
{
- ShowHeader(name, value, wxFONTENCODING_SYSTEM);
+ ShowHeader(name, value, encHeaders);
}
}
- else
+ else // show just a few standard headers
{
// retrieve all headers at once instead of calling
Message::GetHeaderLine()
// many times: this is incomparably faster with remote servers (one round
@@ -1624,20 +1629,21 @@
{
encHeader = m_encodingAuto;
}
+
+#if wxUSE_UNICODE
+ if ( encHeader != wxFONTENCODING_SYSTEM )
+ value = wxString(value.To8BitData(), wxCSConv(encHeader));
+#endif // wxUSE_UNICODE
}
-#if 0
- // does not work - EnsureAvailableTextEncoding for UTF-8 always
succeeds
- if ( !EnsureAvailableTextEncoding(&encHeader, &value) )
-#endif
+#if !wxUSE_UNICODE
+ // special handling for the UTF-7|8 if it's not supported natively
+ if ( encHeader == wxFONTENCODING_UTF8 ||
+ encHeader == wxFONTENCODING_UTF7 )
{
- // special handling for the UTF-7|8 if it's not supported natively
- if ( encHeader == wxFONTENCODING_UTF8 ||
- encHeader == wxFONTENCODING_UTF7 )
- {
- encHeader = ConvertUTFToMB(&value, encHeader);
- }
+ encHeader = ConvertUTFToMB(&value, encHeader);
}
+#endif // !wxUSE_UNICODE
// show the header and mark the URLs in it
const String& name = headerNames[n];
@@ -1698,11 +1704,12 @@
if ( encPart == wxFONTENCODING_UTF8 || encPart == wxFONTENCODING_UTF7 )
{
- // show UTF-8|7, not env. encoding in Language menu
m_encodingAuto = encPart;
+#if !wxUSE_UNICODE
// convert from UTF-8|7 to environment's default encoding
encPart = ConvertUTFToMB(&textPart, encPart);
+#endif // wxUSE_UNICODE
}
else if ( encPart == wxFONTENCODING_SYSTEM ||
encPart == wxFONTENCODING_DEFAULT )
@@ -1728,8 +1735,9 @@
}
// init the style we're going to use
+ MTextStyle style;
+#if !wxUSE_UNICODE
bool fontSet = false;
- MTextStyle style;
if ( encPart != wxFONTENCODING_SYSTEM )
{
if ( EnsureAvailableTextEncoding(&encPart, &textPart) )
@@ -1746,6 +1754,7 @@
// we need to reset the font and the colour because they may have been
// changed by the headers
if ( !fontSet )
+#endif // !wxUSE_UNICODE
style.SetFont(m_ProfileValues.GetFont());
style.SetTextColour(m_ProfileValues.FgCol);
Modified: trunk/M/src/gui/wxComposeView.cpp
===================================================================
--- trunk/M/src/gui/wxComposeView.cpp 2007-08-22 21:14:48 UTC (rev 7333)
+++ trunk/M/src/gui/wxComposeView.cpp 2007-08-24 18:27:43 UTC (rev 7334)
@@ -3092,8 +3092,10 @@
if ( encConv == wxFONTENCODING_SYSTEM )
{
encConv = encoding;
+#if !wxUSE_UNICODE
if ( !EnsureAvailableTextEncoding(&encConv) )
encConv = wxFONTENCODING_SYSTEM;
+#endif // !wxUSE_UNICODE
}
m_editor->SetEncoding(encConv == wxFONTENCODING_SYSTEM ? encoding :
encConv);
@@ -3118,12 +3120,14 @@
// Unicode parts are converted by the message viewer (from which we
// get our text) to another encoding, get it
wxFontEncoding encConv;
+#if !wxUSE_UNICODE
if ( enc == wxFONTENCODING_UTF7 || enc == wxFONTENCODING_UTF8 )
{
String textPart(part->GetTextContent());
encConv = ConvertUTFToMB(&textPart, enc);
}
else // not Unicode
+#endif // !wxUSE_UNICODE
{
encConv = wxFONTENCODING_SYSTEM;
}
Modified: trunk/M/src/gui/wxFolderView.cpp
===================================================================
--- trunk/M/src/gui/wxFolderView.cpp 2007-08-22 21:14:48 UTC (rev 7333)
+++ trunk/M/src/gui/wxFolderView.cpp 2007-08-24 18:27:43 UTC (rev 7334)
@@ -2549,6 +2549,7 @@
//else: hmm, can it happen at all?
}
+#if !wxUSE_UNICODE
// check that we have the fonts to display the encodings of the
// messages: we won't be able to do this when displaying them because
// EnsureAvailableTextEncoding() uses wxFontMapper which may pop up a
@@ -2579,6 +2580,7 @@
//else: do *not* change the encoding in HeaderInfo as we will
// have to translate text as well
}
+#endif // !wxUSE_UNICODE
// now the header info should be in cache, so GetHeaderInfo() will
// return it
@@ -3102,6 +3104,7 @@
wxFAIL_MSG( _T("unknown column") );
}
+#if !wxUSE_UNICODE
if ( field == WXFLC_FROM || field == WXFLC_SUBJECT )
{
wxFontEncoding encoding = hi->GetEncoding();
@@ -3120,6 +3123,7 @@
EnsureAvailableTextEncoding(&encoding, &text);
}
}
+#endif // !wxUSE_UNICODE
return text;
}
@@ -3192,6 +3196,7 @@
// reset the colour to default
m_attr->SetTextColour(GetEntryColour(hi));
+#if !wxUSE_UNICODE
// cache the last used encoding as creating new font is an expensive
// operation
wxFontEncoding enc = hi->GetEncoding();
@@ -3224,6 +3229,7 @@
m_attr->SetFont(wxNullFont);
}
}
+#endif // !wxUSE_UNICODE
return m_attr;
}
Modified: trunk/M/src/gui/wxMGuiUtils.cpp
===================================================================
--- trunk/M/src/gui/wxMGuiUtils.cpp 2007-08-22 21:14:48 UTC (rev 7333)
+++ trunk/M/src/gui/wxMGuiUtils.cpp 2007-08-24 18:27:43 UTC (rev 7334)
@@ -31,6 +31,8 @@
// implementation
// ============================================================================
+#if wxUSE_UNICODE
+
bool
EnsureAvailableTextEncoding(wxFontEncoding *enc, wxString *text, bool
mayAskUser)
{
@@ -98,6 +100,8 @@
return true;
}
+#endif // !wxUSE_UNICODE
+
wxFont
CreateFontFromDesc(const String& fontDesc, int fontSize, int fontFamily)
{
Modified: trunk/M/src/modules/BareBonesEditor.cpp
===================================================================
--- trunk/M/src/modules/BareBonesEditor.cpp 2007-08-22 21:14:48 UTC (rev
7333)
+++ trunk/M/src/modules/BareBonesEditor.cpp 2007-08-24 18:27:43 UTC (rev
7334)
@@ -1137,6 +1137,7 @@
String text(strutil_enforceLF(textOrig));
+#if !wxUSE_UNICODE
// we may have to translate the text in another encoding if exactly this one
// is not available (but equivalent one is)
if ( EnsureAvailableTextEncoding(&m_encoding, &text, true /* may ask */) )
@@ -1144,6 +1145,7 @@
SetFontEncoding(m_encoding);
}
//else: don't change the font, encoding is not supported anyhow
+#endif // !wxUSE_UNICODE
switch ( insMode )
Modified: trunk/M/src/util/strutil.cpp
===================================================================
--- trunk/M/src/util/strutil.cpp 2007-08-22 21:14:48 UTC (rev 7333)
+++ trunk/M/src/util/strutil.cpp 2007-08-24 18:27:43 UTC (rev 7334)
@@ -1516,6 +1516,8 @@
#endif // __WXGTK20__
+#if !wxUSE_UNICODE
+
// convert a string in UTF-8 or 7 into the string in some multibyte encoding:
// of course, this doesn't work in general as Unicode is not representable as
// an 8 bit charset but it works in some common cases and is better than no
@@ -1561,6 +1563,9 @@
return encConv;
}
+#endif // !wxUSE_UNICODE
+
+
// return the length of the line terminator if we're at the end of line or 0
// otherwise
size_t IsEndOfLine(const wxChar *p)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates