doc fixes found while translating
[kdepim.git] / kmail / codecmanager.cpp
blob6c8ee598cdc086347f1ed9d6ac9b0f68f9a37cee
1 /*
2 * This file is part of KMail.
3 * Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
5 * Based on KMMsgBase code by:
6 * Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program 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
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 // Own
24 #include "codecmanager.h"
26 // KMail
27 #include "kmkernel.h"
29 // Qt
31 // KDE libs
32 #include <kcodecaction.h>
33 #include <KConfig>
34 #include <KDebug>
35 #include <KGlobal>
36 #include <KLocale>
37 #include <messagecomposersettings.h>
39 class CodecManagerPrivate
41 public:
42 CodecManagerPrivate();
43 ~CodecManagerPrivate();
45 CodecManager *instance;
46 QList<QByteArray> preferredCharsets;
50 K_GLOBAL_STATIC( CodecManagerPrivate, sInstance )
52 CodecManagerPrivate::CodecManagerPrivate()
53 : instance( new CodecManager( this ) )
55 instance->updatePreferredCharsets();
58 CodecManagerPrivate::~CodecManagerPrivate()
60 delete instance;
65 CodecManager::CodecManager( CodecManagerPrivate *dd )
66 : QObject() // TODO does it need to be a QObject?
67 , d( dd )
71 // static
72 CodecManager* CodecManager::self()
74 return sInstance->instance;
77 QList<QByteArray> CodecManager::preferredCharsets() const
79 return d->preferredCharsets;
82 void CodecManager::updatePreferredCharsets()
84 const QStringList prefCharsets = MessageComposer::MessageComposerSettings::self()->preferredCharsets();
85 d->preferredCharsets.clear();
86 foreach( const QString &str, prefCharsets ) {
87 QByteArray charset = str.toLatin1().toLower();
89 if( charset == "locale" ) {
90 charset = KGlobal::locale()->encoding().toLower();
92 // Special case for Japanese:
93 // (Introduction to i18n, 6.6 Limit of Locale technology):
94 // EUC-JP is the de-facto standard for UNIX systems, ISO 2022-JP
95 // is the standard for Internet, and Shift-JIS is the encoding
96 // for Windows and Macintosh.
97 if( charset == "jisx0208.1983-0" ||
98 charset == "eucjp" ||
99 charset == "shift-jis" ) {
100 charset = "iso-2022-jp";
101 // TODO wtf is "jis7"?
104 // Special case for Korean:
105 if( charset == "ksc5601.1987-0" ) {
106 charset = "euc-kr";
109 d->preferredCharsets << charset;
113 #include "codecmanager.moc"