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

libkleo

  • sources
  • kde-4.12
  • kdepim
  • libkleo
  • backends
  • qgpgme
qgpgmeprogresstokenmapper.cpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-file-style: "gnu" -*-
2  qgpgmeprogresstokenmapper.cpp
3 
4  This file is part of libkleopatra, the KDE keymanagement library
5  Copyright (c) 2004 Klarälvdalens Datakonsult AB
6 
7  Libkleopatra is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of the
10  License, or (at your option) any later version.
11 
12  Libkleopatra is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License along
18  with this program; if not, write to the Free Software Foundation, Inc.,
19  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  In addition, as a special exception, the copyright holders give
22  permission to link the code of this program with any edition of
23  the Qt library by Trolltech AS, Norway (or with modified versions
24  of Qt that use the same license as Qt), and distribute linked
25  combinations including the two. You must obey the GNU General
26  Public License in all respects for all of the code used other than
27  Qt. If you modify this file, you may extend this exception to
28  your version of the file, but you are not obligated to do so. If
29  you do not wish to do so, delete this exception statement from
30  your version.
31 */
32 
33 #include "qgpgmeprogresstokenmapper.h"
34 
35 #include <klocale.h>
36 #include <KDebug>
37 
38 #include <QString>
39 
40 #include <boost/range.hpp>
41 
42 #include <cassert>
43 
44 struct Desc {
45  int type; // 0 == fallback
46  const char * display; // add %1 for useCur ^ useTot and %1 %2 for useCur == useTot == true
47 };
48 
49 static const struct Desc pk_dsa[] = {
50  { 0, I18N_NOOP("Generating DSA key...") }
51 };
52 
53 static const struct Desc pk_elg[] = {
54  { 0, I18N_NOOP("Generating ElGamal key...") }
55 };
56 
57 static const struct Desc primegen[] = {
58  // FIXME: add all type's?
59  { 0, I18N_NOOP("Searching for a large prime number...") }
60 };
61 
62 static const struct Desc need_entropy[] = {
63  { 0, I18N_NOOP("Waiting for new entropy from random number generator (you might want to exercise the harddisks or move the mouse)...") }
64 };
65 
66 static const struct Desc tick[] = {
67  { 0, I18N_NOOP("Please wait...") }
68 };
69 
70 static const struct Desc starting_agent[] = {
71  { 0, I18N_NOOP("Starting gpg-agent (you should consider starting a global instance instead)...") }
72 };
73 
74 static const struct _tokens {
75  const char * token;
76  const Desc * desc;
77  unsigned int numDesc;
78 } tokens[] = {
79 #define make_token(x) { #x, x, sizeof(x) / sizeof(*x) }
80  make_token(pk_dsa),
81  make_token(pk_elg),
82  make_token(primegen),
83  make_token(need_entropy),
84  make_token(tick),
85  make_token(starting_agent)
86 #undef make_token
87 };
88 
89 
90 
91 QString Kleo::QGpgMEProgressTokenMapper::map( const char * tokenUtf8, int subtoken ) {
92  if ( !tokenUtf8 || !*tokenUtf8 )
93  return QString();
94 
95  if ( qstrcmp( tokenUtf8, "file:" ) == 0 )
96  return QString(); // gpgme's job
97 
98  return map( QString::fromUtf8( tokenUtf8 ), subtoken );
99 }
100 
101 QString Kleo::QGpgMEProgressTokenMapper::map( const QString & token, int subtoken ) {
102  if ( token.startsWith( QLatin1String("file:") ) )
103  return QString(); // gpgme's job
104 
105  kDebug(5150) << token << subtoken;
106 
107  for ( const _tokens * it = boost::begin( tokens ), *end = boost::end( tokens ) ; it != end ; ++it ) {
108  if ( token.compare( QLatin1String( it->token ), Qt::CaseInsensitive ) == 0 ) {
109  if ( it->desc && it->numDesc ) {
110  for ( unsigned int i = 0, e = it->numDesc ; i != e ; ++i )
111  if ( it->desc[i].type == subtoken )
112  return i18n( it->desc[i].display );
113  return i18n( it->desc[0].display );
114  } else {
115  break;
116  }
117  }
118  }
119 
120  return token;
121 }
122 
tokens
static const struct _tokens tokens[]
pk_elg
static const struct Desc pk_elg[]
Definition: qgpgmeprogresstokenmapper.cpp:53
QString
Kleo::QGpgMEProgressTokenMapper::map
QString map(const char *token, int subtoken)
Definition: qgpgmeprogresstokenmapper.cpp:91
qgpgmeprogresstokenmapper.h
tick
static const struct Desc tick[]
Definition: qgpgmeprogresstokenmapper.cpp:66
make_token
#define make_token(x)
pk_dsa
static const struct Desc pk_dsa[]
Definition: qgpgmeprogresstokenmapper.cpp:49
starting_agent
static const struct Desc starting_agent[]
Definition: qgpgmeprogresstokenmapper.cpp:70
primegen
static const struct Desc primegen[]
Definition: qgpgmeprogresstokenmapper.cpp:57
need_entropy
static const struct Desc need_entropy[]
Definition: qgpgmeprogresstokenmapper.cpp:62
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:57:49 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkleo

Skip menu "libkleo"
  • 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