-
Notifications
You must be signed in to change notification settings - Fork 4
/
GPGPrettyInfo.m
162 lines (140 loc) · 5.26 KB
/
GPGPrettyInfo.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
//
// GPGPrettyInfo.m
// MacGPGME
//
// Created by Gordon Worley on Tue Jun 18 2002.
//
//
// Copyright (C) 2001-2006 Mac GPG Project.
//
// This code is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation; either version 2.1 of the License, or (at your option)
// any later version.
//
// This code is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
// details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, visit <http://www.gnu.org/> or write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
// MA 02111-1307, USA.
//
// More info at <http://macgpg.sourceforge.net/>
//
#include <MacGPGME/GPGPrettyInfo.h>
#include <MacGPGME/LocalizableStrings.h>
#include <MacGPGME/GPGInternals.h>
#define GPGLocalizedString(string) (string != nil ? NSLocalizedStringFromTableInBundle(string, nil, [NSBundle bundleForClass: [GPGObject class]], ""):nil)
NSString * GPGLocalizedPublicKeyAlgorithmDescription(GPGPublicKeyAlgorithm value)
{
NSString *aString = GPGPublicKeyAlgorithmDescription(value);
return GPGLocalizedString(aString);
}
NSString * GPGPublicKeyAlgorithmDescription(GPGPublicKeyAlgorithm value)
{
const char *aCString = gpgme_pubkey_algo_name(value); // statically allocated string or NULL
return GPGStringFromChars(aCString);
}
NSString * GPGSymmetricKeyAlgorithmDescription(GPGSymmetricKeyAlgorithm value)
{
NSString *return_value;
switch (value) {
case GPG_NoAlgorithm:
return_value = GPGLocalizedString(GPGNoAlgorithmString);
break;
case GPG_IDEAAlgorithm:
return_value = GPGLocalizedString(GPGIDEAAlgorithmString);
break;
case GPG_TripleDESAlgorithm:
return_value = GPGLocalizedString(GPGTripleDESAlgorithmString);
break;
case GPG_CAST5Algorithm:
return_value = GPGLocalizedString(GPGCAST5AlgorithmString);
break;
case GPG_BlowfishAlgorithm:
return_value = GPGLocalizedString(GPGBlowfishAlgorithmString);
break;
case GPG_SAFER_SK128Algorithm:
return_value = GPGLocalizedString(GPGSAFERSK128AlgorithmString);
break;
case GPG_DES_SKAlgorithm:
return_value = GPGLocalizedString(GPGDESSKAlgorithmString);
break;
case GPG_AES128Algorithm:
return_value = GPGLocalizedString(GPGAES128AlgorithmString);
break;
case GPG_AES192Algorithm:
return_value = GPGLocalizedString(GPGAES192AlgorithmString);
break;
case GPG_AES256Algorithm:
return_value = GPGLocalizedString(GPGAES256AlgorithmString);
break;
case GPG_TwoFishAlgorithm:
return_value = GPGLocalizedString(GPGTwoFishAlgorithmString);
break;
case GPG_SkipjackAlgorithm:
return_value = GPGLocalizedString(GPGSkipjackAlgorithmString);
break;
case GPG_TwoFish_OldAlgorithm:
return_value = GPGLocalizedString(GPGTwoFishOldAlgorithmString);
break;
case GPG_DummyAlgorithm:
return_value = GPGLocalizedString(GPGDummyAlgorithmString);
break;
default:
return_value = nil;
break;
}
return return_value;
}
NSString * GPGLocalizedHashAlgorithmDescription(GPGHashAlgorithm value)
{
NSString *aString = GPGHashAlgorithmDescription(value);
return GPGLocalizedString(aString);
}
NSString * GPGHashAlgorithmDescription(GPGHashAlgorithm value)
{
const char *aCString = gpgme_hash_algo_name(value); // statically allocated string or NULL
return GPGStringFromChars(aCString);
}
NSString * GPGValidityDescription(GPGValidity value)
{
NSString *return_value;
switch (value) {
case GPGValidityUndefined:
return_value = GPGLocalizedString(GPGValidityUndefinedString);
break;
case GPGValidityNever:
return_value = GPGLocalizedString(GPGValidityNeverString);
break;
case GPGValidityMarginal:
return_value = GPGLocalizedString(GPGValidityMarginalString);
break;
case GPGValidityFull:
return_value = GPGLocalizedString(GPGValidityFullString);
break;
case GPGValidityUltimate:
return_value = GPGLocalizedString(GPGValidityUltimateString);
break;
case GPGValidityUnknown:
return_value = GPGLocalizedString(GPGUnknownString);
break;
default:
return_value = nil;
break;
}
return return_value;
}
NSString *GPGLocalizedProtocolDescription(GPGProtocol protocol)
{
NSString *aString = GPGProtocolDescription(protocol);
return GPGLocalizedString(aString);
}
NSString *GPGProtocolDescription(GPGProtocol protocol)
{
const char *aCString = gpgme_get_protocol_name(protocol); // statically allocated string or NULL
return GPGStringFromChars(aCString);
}