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

kmail

  • sources
  • kde-4.12
  • kdepim
  • kmail
  • editor
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 <KConfig>
34 #include <KDebug>
35 #include <KGlobal>
36 #include <KLocale>
37 #include <settings/messagecomposersettings.h>
38 
39 class CodecManagerPrivate
40 {
41 public:
42  CodecManagerPrivate();
43  ~CodecManagerPrivate();
44 
45  CodecManager *instance;
46  QList<QByteArray> preferredCharsets;
47 
48 };
49 
50 K_GLOBAL_STATIC( CodecManagerPrivate, sInstance )
51 
52 CodecManagerPrivate::CodecManagerPrivate()
53  : instance( new CodecManager( this ) )
54 {
55  instance->updatePreferredCharsets();
56 }
57 
58 CodecManagerPrivate::~CodecManagerPrivate()
59 {
60  delete instance;
61 }
62 
63 
64 
65 CodecManager::CodecManager( CodecManagerPrivate *dd )
66  : d( dd )
67 {
68 }
69 
70 // static
71 CodecManager* CodecManager::self()
72 {
73  return sInstance->instance;
74 }
75 
76 QList<QByteArray> CodecManager::preferredCharsets() const
77 {
78  return d->preferredCharsets;
79 }
80 
81 void CodecManager::updatePreferredCharsets()
82 {
83  const QStringList prefCharsets = MessageComposer::MessageComposerSettings::self()->preferredCharsets();
84  d->preferredCharsets.clear();
85  foreach( const QString &str, prefCharsets ) {
86  QByteArray charset = str.toLatin1().toLower();
87 
88  if( charset == "locale" ) {
89  charset = KGlobal::locale()->encoding().toLower();
90 
91  // Special case for Japanese:
92  // (Introduction to i18n, 6.6 Limit of Locale technology):
93  // EUC-JP is the de-facto standard for UNIX systems, ISO 2022-JP
94  // is the standard for Internet, and Shift-JIS is the encoding
95  // for Windows and Macintosh.
96  if( charset == "jisx0208.1983-0" ||
97  charset == "eucjp" ||
98  charset == "shift-jis" ) {
99  charset = "iso-2022-jp";
100  // TODO wtf is "jis7"?
101  }
102 
103  // Special case for Korean:
104  if( charset == "ksc5601.1987-0" ) {
105  charset = "euc-kr";
106  }
107  }
108  d->preferredCharsets << charset;
109  }
110 }
CodecManager::updatePreferredCharsets
void updatePreferredCharsets()
Re-read the preferred charsets from settings.
Definition: codecmanager.cpp:81
CodecManager
Definition: codecmanager.h:29
CodecManager::preferredCharsets
QList< QByteArray > preferredCharsets() const
A list of preferred charsets to use when composing messages.
Definition: codecmanager.cpp:76
codecmanager.h
kmkernel.h
CodecManager::self
static CodecManager * self()
Returns the CodecManager instance.
Definition: codecmanager.cpp:71
QList< QByteArray >
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:58:51 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

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