• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kmail

  • sources
  • kde-4.14
  • kdepim
  • kmail
  • editor
  • codec
codecmanager.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of KMail.
3  * Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
4  *
5  * Based on KMMsgBase code by:
6  * Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org>
7  *
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.
12  *
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.
17  *
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.
21  */
22 
23 // Own
24 #include "codecmanager.h"
25 
26 // KMail
27 #include "kmkernel.h"
28 
29 // Qt
30 
31 // KDE libs
32 #include <kcodecaction.h>
33 #include <KDebug>
34 #include <KGlobal>
35 #include <KLocale>
36 #include <settings/messagecomposersettings.h>
37 
38 class CodecManagerPrivate
39 {
40 public:
41  CodecManagerPrivate();
42  ~CodecManagerPrivate();
43 
44  CodecManager *instance;
45  QList<QByteArray> preferredCharsets;
46 
47 };
48 
49 K_GLOBAL_STATIC( CodecManagerPrivate, sInstance )
50 
51 CodecManagerPrivate::CodecManagerPrivate()
52  : instance( new CodecManager( this ) )
53 {
54  instance->updatePreferredCharsets();
55 }
56 
57 CodecManagerPrivate::~CodecManagerPrivate()
58 {
59  delete instance;
60 }
61 
62 
63 
64 CodecManager::CodecManager( CodecManagerPrivate *dd )
65  : d( dd )
66 {
67 }
68 
69 // static
70 CodecManager* CodecManager::self()
71 {
72  return sInstance->instance;
73 }
74 
75 QList<QByteArray> CodecManager::preferredCharsets() const
76 {
77  return d->preferredCharsets;
78 }
79 
80 void CodecManager::updatePreferredCharsets()
81 {
82  const QStringList prefCharsets = MessageComposer::MessageComposerSettings::self()->preferredCharsets();
83  d->preferredCharsets.clear();
84  foreach( const QString &str, prefCharsets ) {
85  QByteArray charset = str.toLatin1().toLower();
86 
87  if( charset == "locale" ) {
88  charset = KGlobal::locale()->encoding().toLower();
89 
90  // Special case for Japanese:
91  // (Introduction to i18n, 6.6 Limit of Locale technology):
92  // EUC-JP is the de-facto standard for UNIX systems, ISO 2022-JP
93  // is the standard for Internet, and Shift-JIS is the encoding
94  // for Windows and Macintosh.
95  if( charset == "jisx0208.1983-0" ||
96  charset == "eucjp" ||
97  charset == "shift-jis" ) {
98  charset = "iso-2022-jp";
99  // TODO wtf is "jis7"?
100  }
101 
102  // Special case for Korean:
103  if( charset == "ksc5601.1987-0" ) {
104  charset = "euc-kr";
105  }
106  }
107  d->preferredCharsets << charset;
108  }
109 }
CodecManager::updatePreferredCharsets
void updatePreferredCharsets()
Re-read the preferred charsets from settings.
Definition: codecmanager.cpp:80
QByteArray::toLower
QByteArray toLower() const
QByteArray
CodecManager
Definition: codecmanager.h:28
CodecManager::preferredCharsets
QList< QByteArray > preferredCharsets() const
A list of preferred charsets to use when composing messages.
Definition: codecmanager.cpp:75
QString
QList< QByteArray >
QStringList
codecmanager.h
kmkernel.h
QString::toLatin1
QByteArray toLatin1() const
CodecManager::self
static CodecManager * self()
Returns the CodecManager instance.
Definition: codecmanager.cpp:70
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:32 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal